hexsha stringlengths 40 40 | size int64 22 2.4M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 260 | max_stars_repo_name stringlengths 5 109 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 260 | max_issues_repo_name stringlengths 5 109 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 260 | max_forks_repo_name stringlengths 5 109 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 22 2.4M | avg_line_length float64 5 169k | max_line_length int64 5 786k | alphanum_fraction float64 0.06 0.95 | matches listlengths 1 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
89335260d73cc296f3da34d0bd63a2011b4108f8 | 2,595 | h | C | include/debug.h | Niklas-Seppala/mineload | e558b9a762a5bb84d17a5dc18c3c01d46245c683 | [
"MIT"
] | null | null | null | include/debug.h | Niklas-Seppala/mineload | e558b9a762a5bb84d17a5dc18c3c01d46245c683 | [
"MIT"
] | null | null | null | include/debug.h | Niklas-Seppala/mineload | e558b9a762a5bb84d17a5dc18c3c01d46245c683 | [
"MIT"
] | null | null | null | /**
* @brief This debug module is only included with DEBUG - buildflag.
* ALL calls to this module MUST be wrapped in ifdefs.
*/
#ifdef DEBUG
#ifndef DEBUG_H
#define DEBUG_H
#include <stdio.h>
#include "core.h"
// Toggle more specific debug options
//-----------------------------------
// #define DEBUG_TILE_COLLIDERS
// #define DEBUG_PLAYER_COLLIDERS
// #define DEBUG_PLAYER_SPRITE
// #define DEBUG_PARALLAX
#define DEBUG_PROCM
#define DEBUG_PLAYER_STATUS
//-----------------------------------
/**
* @brief Process memory statistics.
*/
struct proc_stats
{
size_t memory; // Virtual memory
size_t resident; // RAM memory
size_t shared; // Shared memory
size_t text; // Program text size
size_t data; // Program data size
};
/**
* @brief callback
*/
void debug_init(void);
/**
* @brief callback
*/
void debug_update(void);
/**
* @brief callback
*/
void debug_render(void);
/**
* @brief callback
*/
void debug_cleanup(void);
/**
* @brief Draws dot with specified radius to screen.
* NOTE! Must be called inside module's render callback.
*
* @param pos World position.
* @param radius Dot radius.
* @param color Dot color.
*/
void debug_dot(Vector2 pos, float radius, Color color);
/**
* @brief Draws dot wit specified radius to screen. Can be
* called anywhere, not just render cb.
*
* @param pos World position
* @param radius Dot radius.
* @param color Dot color.
*/
void debug_dot_anywhere(Vector2 pos, float radius, Color color);
/**
* @brief Draws rectangle outlines to screen.
* NOTE! Must be called from module's render callback.
*
* @param rec Rectangle object.
* @param color Rectangle color.
*/
void debug_rec_outlines(const Rectangle *rec, Color color);
/**
* @brief Draws rectangle outlines to screen. Can be
* called anywhere, not just render cb.
*
* @param rec Rectangle object.
* @param color Rectangle color.
*/
void debug_rec_outlines_anywhere(const Rectangle *rec, Color color);
/**
* @brief Printf function frow drawing text to game world. Can be
* called anywhere, not just render cb.
*
* @param pos World position.
* @param size Font size. Use constants; FONT_S, FONT_M, FONT_L
* @param color Text color.
* @param format Format string.
* @param ...
*/
void debug_printf_world_anywhere(Vector2 pos, int size, Color color, const char *format, ...);
/**
* @brief Read and parse process memory stats from
* /proc/self/statm.
*
* @return struct proc_stats Parsed stats.
*/
struct proc_stats debug_procstatm(void);
#endif
#endif | 23.807339 | 94 | 0.668979 | [
"render",
"object"
] |
8933d2d6d6e69809b035603148be448df89f8698 | 1,688 | h | C | Source/Base/Base/Matrix.h | Cube219/CubeEngine_old2 | d251d540a4fdbc993ec5c9183eb30ac4dc81d5be | [
"MIT"
] | null | null | null | Source/Base/Base/Matrix.h | Cube219/CubeEngine_old2 | d251d540a4fdbc993ec5c9183eb30ac4dc81d5be | [
"MIT"
] | null | null | null | Source/Base/Base/Matrix.h | Cube219/CubeEngine_old2 | d251d540a4fdbc993ec5c9183eb30ac4dc81d5be | [
"MIT"
] | null | null | null | #pragma once
#include "Vector.h"
namespace cube
{
class Matrix
{
public:
static Matrix Zero();
static Matrix Identity();
Matrix();
Matrix(const VectorBase& row1, const VectorBase& row2, const VectorBase& row3, const VectorBase& row4);
Matrix(float v[16]);
Matrix(float v11, float v12, float v13, float v14,
float v21, float v22, float v23, float v24,
float v31, float v32, float v33, float v34,
float v41, float v42, float v43, float v44);
~Matrix();
Matrix(const Matrix& other);
Matrix& operator=(const Matrix& rhs);
VectorBase& operator[](int i);
Matrix operator+ (const Matrix& rhs) const;
Matrix operator- (const Matrix& rhs) const;
Matrix operator* (float rhs) const;
Matrix operator* (const Matrix& rhs) const;
Matrix operator/ (float rhs) const;
Matrix& operator+= (const Matrix& rhs);
Matrix& operator-= (const Matrix& rhs);
Matrix& operator*= (float rhs);
Matrix& operator*= (const Matrix& rhs);
Matrix& operator/= (float rhs);
VectorBase GetCol(int index) const;
VectorBase GetRow(int index) const;
void SetCol(int index, const VectorBase& col);
void SetRow(int index, const VectorBase& row);
void Transpose();
Matrix Transposed() const;
void Inverse(); // TODO: 차후 구현
Matrix Inversed() const; // TODO: 차후 구현
private:
VectorBase mRows[4];
friend Matrix operator* (float lhs, const Matrix& rhs);
friend VectorBase operator* (const Vector4& lhs, const Matrix& rhs);
};
} // namespace cube
#ifndef MATRIX_IMPLEMENTATION
#if defined(SIMD_SSE) // SSE
#include "Matrix/MatrixSSE.h"
#elif defined(SIMD_NONE) // NONE
#include "Matrix/MatrixArray.h"
#endif
#endif // !MATRIX_IMPLEMENTATION
| 23.444444 | 105 | 0.696682 | [
"vector"
] |
89372c55a85eeee4ecb94517f9faec2924ddebb5 | 19,646 | h | C | Utilities/include/mtf/Utilities/miscUtils.h | abhineet123/MTF | 6cb45c88d924fb2659696c3375bd25c683802621 | [
"BSD-3-Clause"
] | 100 | 2016-12-11T00:34:06.000Z | 2022-01-27T23:03:40.000Z | Utilities/include/mtf/Utilities/miscUtils.h | siqiyan/MTF | 9a76388c907755448bb7223420fe74349130f636 | [
"BSD-3-Clause"
] | 21 | 2017-09-04T06:27:13.000Z | 2021-07-14T19:07:23.000Z | Utilities/include/mtf/Utilities/miscUtils.h | siqiyan/MTF | 9a76388c907755448bb7223420fe74349130f636 | [
"BSD-3-Clause"
] | 21 | 2017-02-19T02:12:11.000Z | 2020-09-23T03:47:55.000Z | #ifndef MTF_MISC_UTILS_H
#define MTF_MISC_UTILS_H
#include "mtf/Macros/common.h"
#ifndef DISABLE_VISP
#include <visp3/core/vpImage.h>
#include <visp3/core/vpColor.h>
#endif
_MTF_BEGIN_NAMESPACE
namespace utils{
/**
compute the rectangle that best fits an arbitrry quadrilateral
in terms of maximizing the Jaccard index of overlap
between the corresponding regions;
an optional resize factor is provided to avaoid further loss in precision
in case a resizing is needed and the input corners are floating point numbers;
*/
template<typename ValT>
cv::Rect_<ValT> getBestFitRectangle(const cv::Mat &corners,
int img_width = 0, int img_height = 0, int border_size = 0);
//! adjust the rectangle bounds so it lies entirely within the image with the given size
template<typename ValT>
cv::Rect_<ValT> getBoundedRectangle(const cv::Rect_<ValT> &_in_rect, int img_width, int img_height,
int border_size = 0);
//! convert region corners between various formats
struct Corners{
template<typename PtScalarT>
Corners(const cv::Point_<PtScalarT>(&pt_corners)[4],
PtScalarT offset_x = 0, PtScalarT offset_y = 0){
corners.create(2, 4, CV_64FC1);
for(unsigned int corner_id = 0; corner_id < 4; ++corner_id) {
corners.at<double>(0, corner_id) = pt_corners[corner_id].x + offset_x;
corners.at<double>(1, corner_id) = pt_corners[corner_id].y + offset_y;
}
}
template<typename RectScalarT>
Corners(const cv::Rect_<RectScalarT> rect,
RectScalarT offset_x = 0, RectScalarT offset_y = 0){
corners.create(2, 4, CV_64FC1);
RectScalarT min_x = rect.x + offset_x, min_y = rect.y + offset_y;
RectScalarT max_x = min_x + rect.width, max_y = min_y + rect.height;
corners.at<double>(0, 0) = corners.at<double>(0, 3) = min_x;
corners.at<double>(0, 1) = corners.at<double>(0, 2) = max_x;
corners.at<double>(1, 0) = corners.at<double>(1, 1) = min_y;
corners.at<double>(1, 2) = corners.at<double>(1, 3) = max_y;
}
Corners(const cv::Mat &mat_corners,
double offset_x = 0, double offset_y = 0){
corners = mat_corners.clone();
corners.row(0) += offset_x;
corners.row(1) += offset_y;
}
Corners(const CornersT &eig_corners,
double offset_x = 0, double offset_y = 0){
corners.create(2, 4, CV_64FC1);
for(unsigned int corner_id = 0; corner_id < 4; ++corner_id){
corners.at<double>(0, corner_id) = eig_corners(0, corner_id) + offset_x;
corners.at<double>(1, corner_id) = eig_corners(1, corner_id) + offset_y;
}
}
template<typename RectScalarT>
cv::Rect_<RectScalarT> rect(){
return getBestFitRectangle<RectScalarT>(corners);
}
template<typename PtScalarT>
void points(cv::Point_<PtScalarT>(&pt_corners)[4]){
for(unsigned int corner_id = 0; corner_id < 4; ++corner_id) {
pt_corners[corner_id].x = static_cast<PtScalarT>(
corners.at<double>(0, corner_id));
pt_corners[corner_id].y = static_cast<PtScalarT>(
corners.at<double>(1, corner_id));
}
}
cv::Mat mat(){ return corners; }
void mat(cv::Mat &mat_corners){ mat_corners = corners.clone(); }
CornersT eig(){
CornersT eig_corners;
eig(eig_corners);
return eig_corners;
}
void eig(CornersT &eig_corners){
for(unsigned int corner_id = 0; corner_id < 4; ++corner_id){
eig_corners(0, corner_id) = corners.at<double>(0, corner_id);
eig_corners(1, corner_id) = corners.at<double>(1, corner_id);
}
}
private:
cv::Mat corners;
};
template<typename MatT>
inline void printMatrix(const MatT &eig_mat, const char* mat_name = nullptr,
const char* fmt = "%15.9f", const char *coeff_sep = "\t",
const char *row_sep = "\n"){
if(mat_name)
printf("%s:\n", mat_name);
for(int i = 0; i < eig_mat.rows(); i++){
for(int j = 0; j < eig_mat.cols(); j++){
printf(fmt, eig_mat(i, j));
printf("%s", coeff_sep);
}
printf("%s", row_sep);
}
printf("\n");
}
template<typename ScalarT>
inline void printScalar(ScalarT scalar_val, const char* scalar_name,
const char* fmt = "%15.9f", const char *name_sep = "\t",
const char *val_sep = "\n"){
fprintf(stdout, "%s:%s", scalar_name, name_sep);
fprintf(stdout, fmt, scalar_val);
fprintf(stdout, "%s", val_sep);
}
// write matrix values to a custom formatted ASCII text file
template<typename MatT>
inline void printMatrixToFile(const MatT &eig_mat, const char* mat_name,
const char* fname, const char* fmt = "%15.9f", const char* mode = "a",
const char *coeff_sep = "\t", const char *row_sep = "\n",
char** const row_labels = nullptr, const char **mat_header = nullptr,
const char* header_fmt = "%15s", const char *name_sep = "\n"){
//typedef typename ImageT::RealScalar ScalarT;
//printf("Opening file: %s to write %s\n", fname, mat_name);
#ifdef _WIN32
FILE *fid;
errno_t err;
if((err = fopen_s(&fid, fname, mode)) != 0) {
printf("File %s could not be opened successfully: %s\n",
fname, strerror(err));
}
#else
FILE *fid = fopen(fname, mode);
if(!fid){
printf("File %s could not be opened successfully\n", fname);
return;
}
#endif
if(mat_name)
fprintf(fid, "%s:%s", mat_name, name_sep);
if(mat_header){
for(int j = 0; j < eig_mat.cols(); j++){
fprintf(fid, header_fmt, mat_header[j]);
fprintf(fid, "%s", coeff_sep);
}
fprintf(fid, "%s", row_sep);
}
for(int i = 0; i < eig_mat.rows(); i++){
for(int j = 0; j < eig_mat.cols(); j++){
fprintf(fid, fmt, eig_mat(i, j));
fprintf(fid, "%s", coeff_sep);
}
if(row_labels){
fprintf(fid, "\t%s", row_labels[i]);
}
fprintf(fid, "%s", row_sep);
}
fclose(fid);
}
// write scalar value to a custom formatted ASCII text file
template<typename ScalarT>
inline void printScalarToFile(ScalarT scalar_val, const char* scalar_name,
const char* fname, const char* fmt = "%15.9f", const char* mode = "a",
const char *name_sep = "\t", const char *val_sep = "\n"){
//typedef typename ImageT::RealScalar ScalarT;
#ifdef _WIN32
FILE *fid;
errno_t err;
if((err = fopen_s(&fid, fname, mode)) != 0) {
printf("File %s could not be opened successfully: %s\n",
fname, strerror(err));
}
#else
FILE *fid = fopen(fname, mode);
if(!fid){
printf("File %s could not be opened successfully\n", fname);
return;
}
#endif
if(scalar_name)
fprintf(fid, "%s:%s", scalar_name, name_sep);
fprintf(fid, fmt, scalar_val);
fprintf(fid, "%s", val_sep);
fclose(fid);
}
// save matrix data to binary file
template<typename ScalarT, typename MatT>
inline void saveMatrixToFile(const MatT &eig_mat, const char* fname,
const char* mode = "ab"){
FILE *fid = fopen(fname, "ab");
if(!fid){
printf("File %s could not be opened successfully\n", fname);
return;
}
fwrite(eig_mat.data(), sizeof(ScalarT), eig_mat.size(), fid);
fclose(fid);
}
// save scalar data to binary file
template<typename ScalarT>
inline void saveScalarToFile(ScalarT &scalar_val, const char* fname,
const char* mode = "ab"){
FILE *fid = fopen(fname, mode);
if(!fid){
printf("File %s could not be opened successfully\n", fname);
return;
}
fwrite(&scalar_val, sizeof(ScalarT), 1, fid);
fclose(fid);
}
// printing functions for OpenCV Mat matrices
template<typename ScalarT>
inline void printMatrix(const cv::Mat &cv_mat, const char* mat_name,
const char* fmt = "%15.9f", const char *coeff_sep = "\t",
const char *row_sep = "\n", const char *name_sep = "\n"){
if(mat_name)
printf("%s:%s", mat_name, name_sep);
for(int i = 0; i < cv_mat.rows; i++){
for(int j = 0; j < cv_mat.cols; j++){
printf(fmt, cv_mat.at<ScalarT>(i, j));
printf("%s", coeff_sep);
}
printf("%s", row_sep);
}
printf("\n");
}
template<typename ScalarT>
inline void printMatrixToFile(const cv::Mat &cv_mat, const char* mat_name,
const char* fname, const char* fmt = "%15.9f", const char* mode = "a",
const char *coeff_sep = "\t", const char *row_sep = "\n",
const char **row_labels = nullptr, const char **mat_header = nullptr,
const char* header_fmt = "%15s", const char *name_sep = "\n"){
//typedef typename ImageT::RealScalar ScalarT;
//printf("Opening file: %s to write %s\n", fname, mat_name);
FILE *fid = fopen(fname, mode);
if(!fid){
printf("File %s could not be opened successfully\n", fname);
return;
}
if(mat_name)
fprintf(fid, "%s:%s", mat_name, name_sep);
if(mat_header){
for(int j = 0; j < cv_mat.cols; j++){
fprintf(fid, header_fmt, mat_header[j]);
fprintf(fid, "%s", coeff_sep);
}
fprintf(fid, "%s", row_sep);
}
for(int i = 0; i < cv_mat.rows; i++){
for(int j = 0; j < cv_mat.cols; j++){
fprintf(fid, fmt, cv_mat.at<ScalarT>(i, j));
fprintf(fid, "%s", coeff_sep);
}
if(row_labels){
fprintf(fid, "\t%s", row_labels[i]);
}
fprintf(fid, "%s", row_sep);
}
fclose(fid);
}
template<typename MatT>
inline bool hasInf(const MatT &eig_mat){
for(int row_id = 0; row_id < eig_mat.rows(); row_id++){
for(int col_id = 0; col_id < eig_mat.cols(); col_id++){
if(std::isinf(eig_mat(row_id, col_id))){ return true; }
}
}
return false;
}
template<typename MatT>
inline bool hasNaN(const MatT &eig_mat){
for(int row_id = 0; row_id < eig_mat.rows(); row_id++){
for(int col_id = 0; col_id < eig_mat.cols(); col_id++){
if(std::isnan(eig_mat(row_id, col_id))){ return true; }
}
}
return false;
}
template<typename ScalarT>
inline bool hasInf(const cv::Mat &cv_mat){
for(int row_id = 0; row_id < cv_mat.rows; ++row_id){
for(int col_id = 0; col_id < cv_mat.cols; ++col_id){
if(std::isinf(cv_mat.at<ScalarT>(row_id, col_id))){ return true; }
}
}
return false;
}
template<typename ScalarT>
inline bool hasNaN(const cv::Mat &cv_mat){
for(int row_id = 0; row_id < cv_mat.rows; ++row_id){
for(int col_id = 0; col_id < cv_mat.cols; ++col_id){
if(std::isnan(cv_mat.at<ScalarT>(row_id, col_id))){ return true; }
}
}
return false;
}
template<typename ScalarT>
inline bool isFinite(const cv::Mat &cv_mat){
for(int row_id = 0; row_id < cv_mat.rows; ++row_id){
for(int col_id = 0; col_id < cv_mat.cols; ++col_id){
if(std::isnan(cv_mat.at<ScalarT>(row_id, col_id)) ||
std::isinf(cv_mat.at<ScalarT>(row_id, col_id))){
return false;
}
}
}
return true;
}
//! remove elements from OpenCV Mat or other compatible structures
//! according to the provided binary mask
//! copied from its namesake defined in fundam.cpp inside calib3d module of OpenCV
template<typename T> int icvCompressPoints(T* ptr,
const uchar* mask, int mstep, int count){
int i, j;
for(i = j = 0; i < count; i++)
if(mask[i*mstep]){
if(i > j)
ptr[j] = ptr[i];
j++;
}
return j;
}
void drawCorners(cv::Mat &img, const cv::Point2d(&cv_corners)[4],
const cv::Scalar corners_col, const std::string label);
// mask a vector, i.e. retain only those entries where the given mask is true
void maskVector(VectorXd &masked_vec, const VectorXd &in_vec,
const VectorXb &mask, int masked_size, int in_size);
// returning version
VectorXd maskVector(const VectorXd &in_vec,
const VectorXb &mask, int masked_size, int in_size);
// mask 2D matrix by row, i.e. retain only those columns whee the mask is true
template<typename MatT>
inline void maskMatrixByRow(MatT &masked_mat, const MatT &in_mat,
const VectorXb &mask, int n_cols){
assert(in_mat.cols() == n_cols);
assert(in_mat.cols() == mask.size());
assert(masked_mat.rows() == in_mat.rows());
int masked_size = mask.array().count();
masked_mat.resize(NoChange, masked_size);
int mask_id = 0;
for(int i = 0; i < n_cols; i++){
if(mask(i)){ masked_mat.col(mask_id++) = in_mat.col(i); }
}
}
// returning version
template<typename MatT>
inline MatT maskMatrixByRow(const MatT &in_mat,
const VectorXb &mask, int n_cols){
int masked_size = mask.array().count();
MatT masked_mat(in_mat.rows(), masked_size);
maskMatrixByRow(masked_mat, in_mat, mask, n_cols);
return masked_mat;
}
// mask 2D matrix by column, i.e. retain only those rows where the mask is true
template<typename MatT>
inline void maskMatrixByCol(MatT &masked_mat, const MatT &in_mat,
const VectorXb &mask, int n_rows){
assert(in_mat.rows() == n_rows);
assert(in_mat.rows() == mask.size());
assert(masked_mat.rows() == in_mat.rows());
int masked_size = mask.array().count();
masked_mat.resize(NoChange, masked_size);
int mask_id = 0;
for(int i = 0; i < n_rows; i++){
if(mask(i)){ masked_mat.row(mask_id++) = in_mat.row(i); }
}
}
// returning version
template<typename MatT>
inline MatT maskMatrixByCol(const MatT &in_mat,
const VectorXb &mask, int n_rows){
int masked_size = mask.array().count();
MatT masked_mat(masked_size, in_mat.cols());
maskMatrixByRow(masked_mat, in_mat, mask, n_rows);
return masked_mat;
}
template<typename ScalarT, typename EigT>
inline void copyCVToEigen(EigT &eig_mat, const cv::Mat &cv_mat){
assert(eig_mat.rows() == cv_mat.rows && eig_mat.cols() == cv_mat.cols);
for(int i = 0; i < cv_mat.rows; i++){
for(int j = 0; j < cv_mat.cols; j++){
eig_mat(i, j) = cv_mat.at<ScalarT>(i, j);
}
}
}
// specialization with loop unrolling for copying a warp matrix from OpenCV to Eigen
template<>
void copyCVToEigen<double, Matrix3d>(Matrix3d &eig_mat, const cv::Mat &cv_mat);
//returning version
template<typename ScalarT>
inline MatrixXd copyCVToEigen(const cv::Mat &cv_mat){
MatrixXd eig_mat(cv_mat.rows, cv_mat.cols);
copyCVToEigen<MatrixXd, ScalarT>(eig_mat, cv_mat);
return eig_mat;
}
template<typename ScalarT, typename EigT>
inline void copyEigenToCV(cv::Mat &cv_mat, const EigT &eig_mat){
assert(cv_mat.rows == eig_mat.rows() && cv_mat.cols == eig_mat.cols());
for(int i = 0; i < cv_mat.rows; i++){
for(int j = 0; j < cv_mat.cols; j++){
cv_mat.at<ScalarT>(i, j) = eig_mat(i, j);
}
}
}
// specialization for copying corners
template<>
void copyEigenToCV<double, CornersT>(cv::Mat &cv_mat,
const CornersT &eig_mat);
//returning version
template<typename EigT, typename ScalarT, int CVMatT>
inline cv::Mat copyEigenToCV(const EigT &eig_mat){
cv::Mat cv_mat(eig_mat.rows(), eig_mat.cols(), CVMatT);
copyEigenToCV<EigT, ScalarT>(cv_mat, eig_mat);
return cv_mat;
}
double writeTimesToFile(vector<double> &proc_times,
vector<char*> &proc_labels, char *time_fname, int iter_id);
//! draw the boundary of the image region represented by the polygon formed by the specified vertices
void drawRegion(cv::Mat &img, const cv::Mat &vertices, cv::Scalar col = cv::Scalar(0, 255, 0),
int line_thickness = 2, const char *label = nullptr, double font_size = 0.50,
bool show_corner_ids = false, bool show_label = false, int line_type = 0);
#ifndef DISABLE_VISP
void drawRegion(vpImage<vpRGBa> &img, const cv::Mat &vertices, vpColor col = vpColor::green,
int line_thickness = 2, const char *label = nullptr, double font_size = 0.50,
bool show_corner_ids = false, bool show_label = false, int line_type = 0);
#endif
void drawGrid(cv::Mat &img, const PtsT &grid_pts, int res_x, int res_y,
cv::Scalar col = cv::Scalar(0, 255, 0), int thickness = 1);
template<typename ImgValT, typename PatchValT>
void drawPatch(cv::Mat &img, const cv::Mat &patch, int n_channels = 1, int start_x = 0, int start_y = 0);
template<typename ScalarT>
void drawPts(cv::Mat &img, const cv::Mat &pts, cv::Scalar col, int radius = 2,
int thickness = -1);
void writeCorners(FILE *out_fid, const cv::Mat &corners, int frame_id, bool write_header = false);
//! functions to handle tracking error computation
enum class TrackErrT{ MCD, CL, Jaccard };
const char* toString(TrackErrT _er_type);
template<TrackErrT tracking_err_type>
double getTrackingError(const cv::Mat >_corners, const cv::Mat &tracker_corners){
throw invalid_argument(cv::format("Invalid tracking error type provided: %d", tracking_err_type));
}
template<> double getTrackingError<TrackErrT::MCD>(const cv::Mat >_corners,
const cv::Mat &tracker_corners);
template<> double getTrackingError<TrackErrT::CL>(const cv::Mat >_corners,
const cv::Mat &tracker_corners);
template<> double getTrackingError<TrackErrT::Jaccard>(const cv::Mat >_corners,
const cv::Mat &tracker_corners);
double getJaccardError(const cv::Mat >_corners, const cv::Mat &tracker_corners,
int img_width, int img_height);
double getTrackingError(TrackErrT tracking_err_type,
const cv::Mat >_corners, const cv::Mat &tracker_corners,
FILE *out_fid = nullptr, int frame_id = 0,
int img_width = 0, int img_height = 0);
cv::Mat readTrackerLocation(const std::string &file_path);
cv::Mat getFrameCorners(const cv::Mat &img, int borner_size = 1);
mtf::PtsT getFramePts(const cv::Mat &img, int borner_size = 1);
cv::Point2d getCentroid(const cv::Mat &corners);
template<typename ScalarT>
inline void getCentroid(cv::Point_<ScalarT> ¢roid,
const cv::Mat &corners){
centroid.x = static_cast<ScalarT>((corners.at<double>(0, 0) + corners.at<double>(0, 1)
+ corners.at<double>(0, 2) + corners.at<double>(0, 3)) / 4.0);
centroid.y = static_cast<ScalarT>((corners.at<double>(1, 0) + corners.at<double>(1, 1)
+ corners.at<double>(1, 2) + corners.at<double>(1, 3)) / 4.0);
}
inline void getCentroid(Vector2d ¢roid,
const cv::Mat &corners){
centroid(0) = (corners.at<double>(0, 0) + corners.at<double>(0, 1)
+ corners.at<double>(0, 2) + corners.at<double>(0, 3)) / 4.0;
centroid(1) = (corners.at<double>(1, 0) + corners.at<double>(1, 1)
+ corners.at<double>(1, 2) + corners.at<double>(1, 3)) / 4.0;
}
template<typename T>
std::string to_string(T val){
stringstream ss;
ss << val;
return ss.str();
}
//! get the indices that will rearrange the given points so that they become
//! consecutive points along the border of a connected region
std::vector<int> rearrangeIntoRegion(const cv::Mat ®ion_corners);
//! rearrange elements in vector according to the given indices
template<typename ElementT>
inline void rearrange(std::vector<ElementT> &vec,
const std::vector<int> &indices){
assert(indices.size() == vec.size());
auto vec_copy(vec);
for(unsigned int id = 0; id < vec.size(); ++id) {
vec[indices[id]] = vec_copy[id];
}
}
//! rearrange columns of the matrix according to the given indices
template<typename ElementT>
inline void rearrangeCols(cv::Mat &mat,
const std::vector<int> &indices){
assert(indices.size() == mat.cols);
cv::Mat mat_copy(mat.clone());
for(int id = 0; id < mat.cols; ++id) {
mat_copy.col(id).copyTo(mat.col(indices[id]));
}
}
//! rearrange rows of the matrix according to the given indices
template<typename ElementT>
inline void rearrangeRows(cv::Mat &mat,
const std::vector<int> &indices){
assert(indices.size() == mat.rows);
cv::Mat mat_copy(mat.clone());
for(int id = 0; id < mat.rows; ++id) {
mat_copy.row(id).copyTo(mat.row(indices[id]));
}
}
cv::Mat concatenate(const cv::Mat img_list[], int n_images, int axis);
//! stack_order :: 0: row major 1 : column major
cv::Mat stackImages(const std::vector<cv::Mat> &img_list, int stack_order = 0);
std::string getDateTime();
}
_MTF_END_NAMESPACE
#endif
| 36.58473 | 106 | 0.661356 | [
"vector"
] |
dec79cf511ab2810902ed66bb0e7e70a5fe4e936 | 4,709 | h | C | Labyrint/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Runtime_Serialization_Serializatio2501037015.h | mimietti/Labyball | c4b03f5b5d5ec1a1cae5831d22391bc2a171230f | [
"MIT"
] | null | null | null | Labyrint/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Runtime_Serialization_Serializatio2501037015.h | mimietti/Labyball | c4b03f5b5d5ec1a1cae5831d22391bc2a171230f | [
"MIT"
] | 23 | 2016-07-21T13:03:02.000Z | 2016-10-03T12:43:01.000Z | Labyrint/labyrinti1/Classes/Native/mscorlib_System_Runtime_Serialization_Serializatio2501037015.h | mimietti/Labyball | c4b03f5b5d5ec1a1cae5831d22391bc2a171230f | [
"MIT"
] | 1 | 2019-09-08T17:32:17.000Z | 2019-09-08T17:32:17.000Z | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
// System.Collections.ArrayList
struct ArrayList_t2121638921;
// System.Collections.Hashtable
struct Hashtable_t3875263730;
// System.Object
struct Il2CppObject;
#include "mscorlib_System_Object837106420.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Runtime.Serialization.SerializationCallbacks
struct SerializationCallbacks_t2501037015 : public Il2CppObject
{
public:
// System.Collections.ArrayList System.Runtime.Serialization.SerializationCallbacks::onSerializingList
ArrayList_t2121638921 * ___onSerializingList_0;
// System.Collections.ArrayList System.Runtime.Serialization.SerializationCallbacks::onSerializedList
ArrayList_t2121638921 * ___onSerializedList_1;
// System.Collections.ArrayList System.Runtime.Serialization.SerializationCallbacks::onDeserializingList
ArrayList_t2121638921 * ___onDeserializingList_2;
// System.Collections.ArrayList System.Runtime.Serialization.SerializationCallbacks::onDeserializedList
ArrayList_t2121638921 * ___onDeserializedList_3;
public:
inline static int32_t get_offset_of_onSerializingList_0() { return static_cast<int32_t>(offsetof(SerializationCallbacks_t2501037015, ___onSerializingList_0)); }
inline ArrayList_t2121638921 * get_onSerializingList_0() const { return ___onSerializingList_0; }
inline ArrayList_t2121638921 ** get_address_of_onSerializingList_0() { return &___onSerializingList_0; }
inline void set_onSerializingList_0(ArrayList_t2121638921 * value)
{
___onSerializingList_0 = value;
Il2CppCodeGenWriteBarrier(&___onSerializingList_0, value);
}
inline static int32_t get_offset_of_onSerializedList_1() { return static_cast<int32_t>(offsetof(SerializationCallbacks_t2501037015, ___onSerializedList_1)); }
inline ArrayList_t2121638921 * get_onSerializedList_1() const { return ___onSerializedList_1; }
inline ArrayList_t2121638921 ** get_address_of_onSerializedList_1() { return &___onSerializedList_1; }
inline void set_onSerializedList_1(ArrayList_t2121638921 * value)
{
___onSerializedList_1 = value;
Il2CppCodeGenWriteBarrier(&___onSerializedList_1, value);
}
inline static int32_t get_offset_of_onDeserializingList_2() { return static_cast<int32_t>(offsetof(SerializationCallbacks_t2501037015, ___onDeserializingList_2)); }
inline ArrayList_t2121638921 * get_onDeserializingList_2() const { return ___onDeserializingList_2; }
inline ArrayList_t2121638921 ** get_address_of_onDeserializingList_2() { return &___onDeserializingList_2; }
inline void set_onDeserializingList_2(ArrayList_t2121638921 * value)
{
___onDeserializingList_2 = value;
Il2CppCodeGenWriteBarrier(&___onDeserializingList_2, value);
}
inline static int32_t get_offset_of_onDeserializedList_3() { return static_cast<int32_t>(offsetof(SerializationCallbacks_t2501037015, ___onDeserializedList_3)); }
inline ArrayList_t2121638921 * get_onDeserializedList_3() const { return ___onDeserializedList_3; }
inline ArrayList_t2121638921 ** get_address_of_onDeserializedList_3() { return &___onDeserializedList_3; }
inline void set_onDeserializedList_3(ArrayList_t2121638921 * value)
{
___onDeserializedList_3 = value;
Il2CppCodeGenWriteBarrier(&___onDeserializedList_3, value);
}
};
struct SerializationCallbacks_t2501037015_StaticFields
{
public:
// System.Collections.Hashtable System.Runtime.Serialization.SerializationCallbacks::cache
Hashtable_t3875263730 * ___cache_4;
// System.Object System.Runtime.Serialization.SerializationCallbacks::cache_lock
Il2CppObject * ___cache_lock_5;
public:
inline static int32_t get_offset_of_cache_4() { return static_cast<int32_t>(offsetof(SerializationCallbacks_t2501037015_StaticFields, ___cache_4)); }
inline Hashtable_t3875263730 * get_cache_4() const { return ___cache_4; }
inline Hashtable_t3875263730 ** get_address_of_cache_4() { return &___cache_4; }
inline void set_cache_4(Hashtable_t3875263730 * value)
{
___cache_4 = value;
Il2CppCodeGenWriteBarrier(&___cache_4, value);
}
inline static int32_t get_offset_of_cache_lock_5() { return static_cast<int32_t>(offsetof(SerializationCallbacks_t2501037015_StaticFields, ___cache_lock_5)); }
inline Il2CppObject * get_cache_lock_5() const { return ___cache_lock_5; }
inline Il2CppObject ** get_address_of_cache_lock_5() { return &___cache_lock_5; }
inline void set_cache_lock_5(Il2CppObject * value)
{
___cache_lock_5 = value;
Il2CppCodeGenWriteBarrier(&___cache_lock_5, value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| 42.809091 | 165 | 0.832449 | [
"object"
] |
decadfd268a272492fd8e728ab93ac6394aee6f8 | 5,709 | h | C | server/server.h | Seriont/MSU_study_SMK | c9e3555ceb9ea12ee101033a9eb6eef6dfb2261b | [
"Apache-2.0"
] | 1 | 2015-11-29T20:17:05.000Z | 2015-11-29T20:17:05.000Z | server/server.h | Seriont/MSU_study_SMK | c9e3555ceb9ea12ee101033a9eb6eef6dfb2261b | [
"Apache-2.0"
] | 2 | 2015-11-30T17:19:53.000Z | 2019-07-11T16:24:57.000Z | server/server.h | Seriont/MSU_study_SMK | c9e3555ceb9ea12ee101033a9eb6eef6dfb2261b | [
"Apache-2.0"
] | 1 | 2019-08-25T09:21:17.000Z | 2019-08-25T09:21:17.000Z | #include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <unistd.h>
#include <iostream>
#include "../constants.h"
#include "../errorexept.h"
#include "../functions.h"
#include <cstdio>
class User
{
friend class Server;
private:
int socket;
public:
char *username;
bool is_online;
Status status;
User();
~User();
};
class Server
{
public:
void startServer();
void process();
void sendServerMessage(char message[]);
Server() {}
private:
void getInputMessage(char message[]);
void getMessage(char message[], User *user, DataType type);
void sendToAllMessage(char message[]);
void addNewClient();
void makeMessage(char message[], char username[], char text[]);
// bool isNameValid(void); // checking for forbidden characters
// bool isNameUsed(void); // checking for equal usernames
std::set<User *> clients;
int listen_socket;
};
User::User()
{
is_online = true;
status = USERNAME_REQUIRED;
}
User::~User()
{
delete[] username;
}
void Server::getInputMessage(char message[])
{
int i = 0, character;
while((character = getchar()) != '\n' && i < MAX_MESSAGE_LEN)
{
message[i++] = character;
}
message[i] = '\0';
}
void Server::startServer()
{
listen_socket = socket(AF_INET, SOCK_STREAM, 0);
if (listen_socket < 0)
{
throw ErrorExept("error: couldn't call socket");
}
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
addr.sin_addr.s_addr = INADDR_ANY;
if (bind(listen_socket, (struct sockaddr *) &addr, sizeof(addr)) != 0)
{
close(listen_socket);
throw ErrorExept("error: couldn't call bind");
}
if (listen(listen_socket, MAX_REQUESTS) != 0)
{
close(listen_socket);
throw ErrorExept("error: couldn't call listen");
}
}
void Server::addNewClient()
{
// here we can save the IP adress of the client
int socket = accept(listen_socket, NULL, NULL);
if (socket < 0)
{
throw ErrorExept("error: couldn't connect user");
}
User *new_user = new User();
new_user->socket = socket;
clients.insert(new_user);
}
void Server::getMessage(char message[], User *user, DataType type)
{
size_t bytes_read;
if (type == MESSAGE)
bytes_read = read(user->socket, message, MAX_MESSAGE_LEN);
else if (type == USERNAME)
bytes_read = read(user->socket, message, USERNAME_MAX_LEN);
if (bytes_read < 0)
{
throw ErrorExept("error: couldn't get message");
}
message[bytes_read/sizeof(char)] = '\0';
normalizeString(message);
}
void Server::sendToAllMessage(char message[])
{
for (std::set<User *>::iterator it = clients.begin();
it != clients.end(); it++)
{
if ((*it)->is_online == false)
continue;
if (write((*it)->socket, message, strlen(message) + 1) < 0)
{
throw ErrorExept("error: couldn't send message");
}
}
}
void Server::sendServerMessage(char message[])
{
sendToAllMessage(message);
}
void Server::makeMessage(char message[], char username[], char text[])
{
int i = 0;
while (username[i] != '\0')
{
message[i] = username[i];
i++;
}
message[i++] = ':';
message[i++] = ' ';
int j = 0;
while (text[j] != '\0')
{
message[i] = text[j];
i++;
j++;
}
message[i] = '\0';
}
void Server::process()
{
fd_set read_fds;
while (true)
{
// read_fds initialization
FD_ZERO(&read_fds);
int max_ds = listen_socket;
FD_SET(listen_socket, &read_fds);
FD_SET(0, &read_fds);
for (std::set<User *>::iterator it = clients.begin();
it != clients.end(); it++)
{
FD_SET((*it)->socket, &read_fds);
if ((*it)->socket > max_ds)
max_ds = (*it)->socket;
}
// query handling
// waiting for queries
// the last pointer is a timer
if (select(max_ds + 1, &read_fds, NULL, NULL, NULL) < 1)
{
sendServerMessage((char *)"server's fallen");
throw ErrorExept("error: server's fallen");
}
// new client adding
if (FD_ISSET(listen_socket, &read_fds))
{
try
{
addNewClient();
std::cout << "New connection." << std::endl;
}
catch(const ErrorExept& exeption)
{
exeption.printError();
}
}
if (FD_ISSET(0, &read_fds))
{
char *message = new char[MAX_MESSAGE_LEN+1];
getInputMessage(message);
sendToAllMessage(message);
delete[] message;
}
// message reading and deleting closed sockets
for (std::set<User *>::iterator it = clients.begin();
it != clients.end(); it++)
{
User *client = *it;
if (FD_ISSET(client->socket, &read_fds))
{
if (client->is_online == false)
continue;
try
{
if (client->status == USERNAME_REQUIRED)
{
char *username = new char[USERNAME_MAX_LEN+1];
getMessage(username, client, USERNAME);
if (strlen(username) == 0)
client->is_online = false;
else
{
client->username = username;
client->status = AUTHORIZED;
}
}
else if (client->status == AUTHORIZED)
{
char *message = new char[MAX_MESSAGE_LEN];
char *text = new char[TEXT_MAX_LEN];
getMessage(text, client, MESSAGE);
if (strlen(text) == 0)
client->is_online = false;
else
{
makeMessage(message, client->username, text);
delete[] text;
sendToAllMessage(message);
}
delete[] message;
}
}
catch (const ErrorExept& exeption)
{
exeption.printError();
}
}
}
std::set<User *>::iterator it = clients.begin();
while(it != clients.end())
{
User *client = *it;
if (client->is_online == true)
{
it++;
continue;
}
close(client->socket);
clients.erase(client);
delete client;
it = clients.begin();
}
}
}
| 20.244681 | 71 | 0.620249 | [
"vector"
] |
decefa04a5cbd42cf0be93de5dd2e38dc99e21fd | 1,397 | h | C | src/Box.h | RokKos/eol-cloth | b9c6f55f25ba17f33532ea5eefa41fedd29c5206 | [
"MIT"
] | null | null | null | src/Box.h | RokKos/eol-cloth | b9c6f55f25ba17f33532ea5eefa41fedd29c5206 | [
"MIT"
] | null | null | null | src/Box.h | RokKos/eol-cloth | b9c6f55f25ba17f33532ea5eefa41fedd29c5206 | [
"MIT"
] | null | null | null | #pragma once
#ifndef __Box__
#define __Box__
#include "Brenderable.h"
#ifdef EOLC_ONLINE
#include "online/MatrixStack.h"
#include "online/Program.h"
#endif // EOLC_ONLINE
#include "Shape.h"
#include "Rigid.h"
namespace EOL {
class Box : public Brenderable
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
std::shared_ptr<Rigid> rigid;
Box(const std::shared_ptr<Shape> shape, std::string en);
virtual ~Box();
void step(const double h);
#ifdef EOLC_ONLINE
void draw(std::shared_ptr<Rendering::MatrixStack> MV, const std::shared_ptr<Rendering::Program> p) const;
void drawSimple(std::shared_ptr<Rendering::MatrixStack> MV, const std::shared_ptr<Rendering::Program> p) const;
void init();
#endif // EOLC_ONLINE
int num_points;
int num_edges;
Eigen::Vector3d dim;
Eigen::Vector3d rot;
Eigen::Vector3d x; // position
Eigen::Matrix4d E1;
Eigen::Matrix4d E1inv;
Eigen::VectorXd v;
Eigen::MatrixXd adjoint;
// These are used for constraints
Eigen::MatrixXd faceNorms;
Eigen::MatrixXi edgeFaces;
Eigen::VectorXi edgeTan;
Eigen::MatrixXi vertEdges1;
// Export
std::string exportName;
int getBrenderCount() const;
std::vector<std::string> getBrenderNames() const;
void exportBrender(std::vector< std::shared_ptr< std::ofstream > > outfiles) const;
private:
void generateConstraints();
const std::shared_ptr<Shape> boxShape;
};
}
#endif
| 21.166667 | 113 | 0.725841 | [
"shape",
"vector"
] |
ded5c0a8ef4093c82b1a00dbf5bc380d874bb574 | 7,873 | h | C | applications/physbam/physbam-lib/Public_Library/PhysBAM_Rendering/PhysBAM_OptiX/Rendering_Objects/OPTIX_RENDERING_IMPLICIT_SURFACE.h | schinmayee/nimbus | 170cd15e24a7a88243a6ea80aabadc0fc0e6e177 | [
"BSD-3-Clause"
] | 20 | 2017-07-03T19:09:09.000Z | 2021-09-10T02:53:56.000Z | applications/physbam/physbam-lib/Public_Library/PhysBAM_Rendering/PhysBAM_OptiX/Rendering_Objects/OPTIX_RENDERING_IMPLICIT_SURFACE.h | schinmayee/nimbus | 170cd15e24a7a88243a6ea80aabadc0fc0e6e177 | [
"BSD-3-Clause"
] | null | null | null | applications/physbam/physbam-lib/Public_Library/PhysBAM_Rendering/PhysBAM_OptiX/Rendering_Objects/OPTIX_RENDERING_IMPLICIT_SURFACE.h | schinmayee/nimbus | 170cd15e24a7a88243a6ea80aabadc0fc0e6e177 | [
"BSD-3-Clause"
] | 9 | 2017-09-17T02:05:06.000Z | 2020-01-31T00:12:01.000Z | //#####################################################################
// Copyright 2011, Valeria Nikolaenko, Rahul Sheth
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class OPTIX_RENDERING_IMPLICIT_SURFACE
//#####################################################################
#ifdef USE_OPTIX
#ifndef __OPTIX_RENDERING_IMPLICIT_SURFACE__
#define __OPTIX_RENDERING_IMPLICIT_SURFACE__
#include <PhysBAM_Tools/Arrays/ARRAY.h>
#include <PhysBAM_Tools/Matrices/MATRIX_4X4.h>
#include <PhysBAM_Tools/Vectors/VECTOR_3D.h>
#include <PhysBAM_Tools/Read_Write/Utilities/FILE_UTILITIES.h>
#include <PhysBAM_Geometry/Geometry_Particles/REGISTER_GEOMETRY_READ_WRITE.h>
#include <PhysBAM_Dynamics/Geometry/GENERAL_GEOMETRY_FORWARD.h>
#include <PhysBAM_Rendering/PhysBAM_OptiX/Rendering_Objects/OPTIX_RENDERING_OBJECT.h>
#include <PhysBAM_Geometry/Implicit_Objects_Uniform/LEVELSET_IMPLICIT_OBJECT.h>
#include <PhysBAM_Tools/Read_Write/Grids_Uniform/READ_WRITE_GRID.h>
#include <PhysBAM_Geometry/Read_Write/Implicit_Objects_Uniform/READ_WRITE_LEVELSET_IMPLICIT_OBJECT.h>
#include <iostream>
#include <string>
#include <optix_world.h>
#include <optixu/optixpp_namespace.h>
#include <PhysBAM_Rendering/PhysBAM_OptiX/Rendering_Utilities/OPTIX_UTILITIES.h>
namespace PhysBAM{
using namespace optix;
template<class T> class OPTIX_RENDERING_IMPLICIT_SURFACE : public OPTIX_RENDERING_OBJECT<T> {
typedef VECTOR<T,3> TV;
GENERIC_PARSER<T> *parser;
Geometry rt_object;
Program rt_object_intersection_program;
Program rt_object_bounding_box_program;
Acceleration rt_acceleration;
LEVELSET_IMPLICIT_OBJECT<VECTOR<T,3> >* surface;
typedef OPTIX_RENDERING_OBJECT<T> BASE;
// using BASE::Set_Transform;using BASE::Update_Transform;
public:
OPTIX_RENDERING_IMPLICIT_SURFACE(const std::string filename, OPTIX_MATERIAL<T>* material):OPTIX_RENDERING_OBJECT<T>("Implicit Surface", material) {
Initialize_Geometry_Particle();
Initialize_Read_Write_General_Structures();
try{
FILE_UTILITIES::Create_From_File<T>(filename,surface);
/*
phi=&surface->levelset.phi;
std::cout<<filename<<" statistics:"<<std::endl;
std::cout<<" grid = "<<surface->levelset.grid<<std::endl;
std::cout<<" phi array bounds = "<<phi->domain.min_corner.x<<" "<<phi->domain.max_corner.x<<", "<<phi->domain.min_corner.y<<" "<<phi->domain.max_corner.y<<", "<<phi->domain.min_corner.z<<" "<<phi->domain.max_corner.z<<std::endl;
// checking that all the surface lay inside the domain
for(int i=phi->domain.min_corner.x;i<=phi->domain.max_corner.x;i++)for(int j=phi->domain.min_corner.y;j<=phi->domain.max_corner.y;j++)if((*phi)(i,j,phi->domain.min_corner.z)<=0){std::cout<<" phi<=0 on domain.min_corner.z"<<std::endl;goto check1_end;}check1_end:
for(int i=phi->domain.min_corner.x;i<=phi->domain.max_corner.x;i++)for(int j=phi->domain.min_corner.y;j<=phi->domain.max_corner.y;j++)if((*phi)(i,j,phi->domain.max_corner.z)<=0){std::cout<<" phi<=0 on domain.max_corner.z"<<std::endl;goto check2_end;}check2_end:
for(int i=phi->domain.min_corner.x;i<=phi->domain.max_corner.x;i++)for(int k=phi->domain.min_corner.z;k<=phi->domain.max_corner.z;k++)if((*phi)(i,phi->domain.min_corner.y,k)<=0){std::cout<<" phi<=0 on domain.min_corner.y"<<std::endl;goto check3_end;}check3_end:
for(int i=phi->domain.min_corner.x;i<=phi->domain.max_corner.x;i++)for(int k=phi->domain.min_corner.z;k<=phi->domain.max_corner.z;k++)if((*phi)(i,phi->domain.max_corner.y,k)<=0){std::cout<<" phi<=0 on domain.max_corner.y"<<std::endl;goto check4_end;}check4_end:
for(int j=phi->domain.min_corner.y;j<=phi->domain.max_corner.y;j++)for(int k=phi->domain.min_corner.z;k<=phi->domain.max_corner.z;k++)if((*phi)(phi->domain.min_corner.x,j,k)<=0){std::cout<<" phi<=0 on domain.min_corner.x"<<std::endl;goto check5_end;}check5_end:
for(int j=phi->domain.min_corner.y;j<=phi->domain.max_corner.y;j++)for(int k=phi->domain.min_corner.z;k<=phi->domain.max_corner.z;k++)if((*phi)(phi->domain.max_corner.x,j,k)<=0){std::cout<<" phi<=0 on domain.max_corner.x"<<std::endl;goto check6_end;}check6_end:
int i = 0;
*/
}
catch(FILESYSTEM_ERROR&){}
}
~OPTIX_RENDERING_IMPLICIT_SURFACE() {}
Geometry getGeometryObject() {
return rt_object;
}
Acceleration getAcceleration() {
return rt_acceleration;
}
void InitializeGeometry(OPTIX_RENDER_WORLD<T>& world_input) {
Context rt_context = world_input.RTContext();
ARRAY<T,VECTOR<int,3> >* phi=&surface->levelset.phi;
// creating 3D phi texture
int dx = (phi->domain.max_corner.x - phi->domain.min_corner.x),
dy = (phi->domain.max_corner.y - phi->domain.min_corner.y),
dz = (phi->domain.max_corner.z - phi->domain.min_corner.z);
Buffer phi_tex_buffer = rt_context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT, dx + 1, dy + 1, dz + 1);
TextureSampler phi_map_tex_sampler = rt_context->createTextureSampler();
phi_map_tex_sampler->setWrapMode(0, RT_WRAP_CLAMP_TO_EDGE);
phi_map_tex_sampler->setWrapMode(1, RT_WRAP_CLAMP_TO_EDGE);
phi_map_tex_sampler->setWrapMode(2, RT_WRAP_CLAMP_TO_EDGE);
phi_map_tex_sampler->setFilteringModes(RT_FILTER_LINEAR, RT_FILTER_LINEAR, RT_FILTER_NONE);
phi_map_tex_sampler->setIndexingMode(RT_TEXTURE_INDEX_NORMALIZED_COORDINATES);
phi_map_tex_sampler->setReadMode(RT_TEXTURE_READ_ELEMENT_TYPE);
phi_map_tex_sampler->setMaxAnisotropy(1.0f);
phi_map_tex_sampler->setMipLevelCount(1);
phi_map_tex_sampler->setArraySize(1);
phi_map_tex_sampler->setBuffer(0, 0, phi_tex_buffer);
float* phi_tex_buffer_data = static_cast<float*>(phi_tex_buffer->map());
for(int k=0;k<=dz;k++)
for(int j=0;j<=dy;j++) {
for(int i=0;i<=dx;i++) {
int index = i + (j + k * (dy + 1)) * (dx + 1);
/*
float x = i / (float)dx * 2 - 1;
float y = j / (float)dy * 2 - 1;
float z = k / (float)dz * 2 - 1;
phi_tex_buffer_data[index] = x*x * 0.5 + y*y*0.5 + z*z*0.5 - 1;
*/
phi_tex_buffer_data[index] = (*phi)(i + phi->domain.min_corner.x,j + phi->domain.min_corner.y, k + phi->domain.min_corner.z);
/*
if (k == dz / 2)
std::cout << std::setprecision(2) << phi_tex_buffer_data[index] << " ";
*/
}
/*
if (k == dz / 2)
std::cout << "\n";
*/
}
// std::cout << "\n";
phi_tex_buffer->unmap();
rt_object = rt_context->createGeometry();
std::string path_to_ptx = world_input.shader_prefix + "_generated_OPTIX_LEVELSET_SURFACE.cu.ptx";
rt_object_intersection_program = rt_context->createProgramFromPTXFile(path_to_ptx, "intersect");
rt_object->setIntersectionProgram(rt_object_intersection_program);
rt_object_bounding_box_program = rt_context->createProgramFromPTXFile(path_to_ptx, "box_bounds");
rt_object->setBoundingBoxProgram(rt_object_bounding_box_program);
rt_object->setPrimitiveCount(1);
rt_acceleration = rt_context->createAcceleration("Sbvh","Bvh");
rt_object["phi_tex"]->setTextureSampler(phi_map_tex_sampler);
rt_object["phi_tex_delta"]->setFloat(1.f / dx, 1.f / dy, 1.f / dz);
}
};
}
#endif
#endif
| 52.838926 | 274 | 0.649689 | [
"geometry",
"vector",
"3d"
] |
dee129ae9f9a91ba26f1b59ddfb6f196f9325d8f | 1,402 | h | C | libs/fenwick.h | teacup123123/win_competitive_programming_console | d043e775d836f8400ff4602623a556f292a4754e | [
"MIT"
] | null | null | null | libs/fenwick.h | teacup123123/win_competitive_programming_console | d043e775d836f8400ff4602623a556f292a4754e | [
"MIT"
] | null | null | null | libs/fenwick.h | teacup123123/win_competitive_programming_console | d043e775d836f8400ff4602623a556f292a4754e | [
"MIT"
] | null | null | null | //
// Created by teacup123123 on 1/15/2021.
//
#ifndef STARTCF_PY_FENWICK_H
#define STARTCF_PY_FENWICK_H
class fenwick {
private:
vl data;
vl single;
public:
fenwick(int sz) {
//x & -x is the LST
// data[5<1>] = ]5-1, 5]
data.resize(1), single.resize(1);
while (sz(data) < sz + 1)data.resize(sz(data) * 2), single.resize(sz(data));
}
template<class T>
fenwick(vector<T> &src):fenwick(src.size()) {
f0r(i, src.size())update(i, src[i]);
}
ll sum(int index) {
ll sum = 0; // Iniialize result
// index in BITree[] is 1 more than the index in arr[]
// index = index + 1; non-inclusive
while (index > 0) {
sum += data[index];
// Move index to parent node in getSum View
index -= index & (-index);
}
return sum;
}
void update(int index, ll val) {
// index in BITree[] is 1 more than the index in arr[]
index = index + 1;
ll dval = val - single[index];
single[index] = val;
while (index < sz(data)) {
// Add 'val' to current node of BI Tree
data[index] += dval;
// Update index to that of parent in update View
index += index & (-index);
}
}
ll sum(int i, int j) {
return sum(j) - sum(i);
}
};
#endif //STARTCF_PY_FENWICK_H
| 25.035714 | 84 | 0.521398 | [
"vector"
] |
deedcdc6956750047dc49248a457b1da8f735bbb | 1,558 | h | C | cpp/db/DataBlock.h | simpla-fusion/spdb | be6667eb6c7d464f68b0fd51ca2a8f021581eb84 | [
"MIT"
] | null | null | null | cpp/db/DataBlock.h | simpla-fusion/spdb | be6667eb6c7d464f68b0fd51ca2a8f021581eb84 | [
"MIT"
] | null | null | null | cpp/db/DataBlock.h | simpla-fusion/spdb | be6667eb6c7d464f68b0fd51ca2a8f021581eb84 | [
"MIT"
] | null | null | null | #ifndef SP_DATABLOCK_H_
#define SP_DATABLOCK_H_
#include <memory>
#include <vector>
namespace sp::db
{
class DataBlock
{
std::shared_ptr<void> m_data_;
std::vector<size_t> m_dimensions_;
public:
DataBlock() = default;
~DataBlock() = default;
DataBlock(int nd, const size_t* dimensions, void* data = nullptr, int element_size = sizeof(double));
template <typename TDIM>
DataBlock(int nd, const TDIM* dimensions);
DataBlock(DataBlock const&);
DataBlock(DataBlock&&);
void swap(DataBlock& other);
DataBlock& operator=(const DataBlock& other)
{
DataBlock(other).swap(*this);
return *this;
}
std::type_info const& value_type_info() const { return typeid(double); }
bool is_slow_first() const { return true; }
template <typename TDim>
void reshape(int ndims, const TDim* dims)
{
std::vector<size_t>(dims, dims + ndims).swap(m_dimensions_);
}
const std::vector<size_t>& shape() const { return m_dimensions_; }
void* data() { return m_data_.get(); }
const void* data() const { return m_data_.get(); }
size_t element_size() const;
size_t ndims() const;
size_t const* dims() const;
template <typename U>
U* as();
template <typename U>
const U* as() const;
DataBlock slice(const std::tuple<int, int, int>& slice)
{
return DataBlock{};
}
DataBlock slice(const std::tuple<int, int, int>& slice) const
{
return DataBlock{};
}
};
} // namespace sp::db
#endif // SP_DATABLOCK_H_ | 22.911765 | 105 | 0.639281 | [
"shape",
"vector"
] |
def9f6ad6997c506f4e378ab2797b847630834ae | 19,514 | h | C | ThirdParty/PSCommon/XnLib/ThirdParty/GL/glh/glh_glut.h | gajgeospatial/OpenNI2-2.2.0.33 | 86d57aa61bcf1fd96922af1960ab711c2e9c1ed5 | [
"Apache-2.0"
] | 925 | 2015-01-04T03:47:56.000Z | 2022-03-28T11:18:18.000Z | ThirdParty/PSCommon/XnLib/ThirdParty/GL/glh/glh_glut.h | gajgeospatial/OpenNI2-2.2.0.33 | 86d57aa61bcf1fd96922af1960ab711c2e9c1ed5 | [
"Apache-2.0"
] | 125 | 2015-01-12T11:28:09.000Z | 2021-03-29T09:38:04.000Z | ThirdParty/PSCommon/XnLib/ThirdParty/GL/glh/glh_glut.h | gajgeospatial/OpenNI2-2.2.0.33 | 86d57aa61bcf1fd96922af1960ab711c2e9c1ed5 | [
"Apache-2.0"
] | 475 | 2015-01-02T02:58:01.000Z | 2022-02-24T06:53:46.000Z | /*
glh - is a platform-indepenedent C++ OpenGL helper library
Copyright (c) 2000 Cass Everitt
Copyright (c) 2000 NVIDIA Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
* 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.
* The names of contributors to this software may not 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
REGENTS 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.
Cass Everitt - cass@r3.nu
*/
#ifndef GLH_GLUT_H
#define GLH_GLUT_H
// some helper functions and object to
// make writing simple glut programs even easier! :-)
#ifdef MACOS
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <glh/glh_convenience.h>
#include <algorithm>
#include <list>
namespace glh
{
class glut_interactor
{
public:
glut_interactor() { enabled = true; }
virtual void display() {}
virtual void idle() {}
virtual void keyboard(unsigned char key, int x, int y) {}
virtual void menu_status(int status, int x, int y) {}
virtual void motion(int x, int y) {}
virtual void mouse(int button, int state, int x, int y) {}
virtual void passive_motion(int x, int y) {}
virtual void reshape(int w, int h) {}
virtual void special(int key, int x, int y) {}
virtual void timer(int value) {}
virtual void visibility(int v) {}
virtual void enable() { enabled = true; }
virtual void disable() { enabled = false; }
bool enabled;
};
std::list<glut_interactor *> interactors;
bool propagate;
void glut_display_function()
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->display();
}
void glut_idle_function()
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->idle();
}
void glut_keyboard_function(unsigned char k, int x, int y)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->keyboard(k, x, y);
}
void glut_menu_status_function(int status, int x, int y)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->menu_status(status, x, y);
}
void glut_motion_function(int x, int y)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->motion(x, y);
}
void glut_mouse_function(int button, int state, int x, int y)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->mouse(button, state, x, y);
}
void glut_passive_motion_function(int x, int y)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->passive_motion(x, y);
}
void glut_reshape_function(int w, int h)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->reshape(w,h);
}
void glut_special_function(int k, int x, int y)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->special(k, x, y);
}
void glut_timer_function(int v)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->timer(v);
}
void glut_visibility_function(int v)
{
propagate = true;
for(std::list<glut_interactor *>::iterator it=interactors.begin(); it != interactors.end() && propagate; it++)
(*it)->visibility(v);
}
// stop processing the current event
inline void glut_event_processed()
{
propagate = false;
}
inline void glut_helpers_initialize()
{
glutDisplayFunc(glut_display_function);
glutIdleFunc(0);
glutKeyboardFunc(glut_keyboard_function);
glutMenuStatusFunc(glut_menu_status_function);
glutMotionFunc(glut_motion_function);
glutMouseFunc(glut_mouse_function);
glutPassiveMotionFunc(glut_passive_motion_function);
glutReshapeFunc(glut_reshape_function);
glutSpecialFunc(glut_special_function);
glutVisibilityFunc(glut_visibility_function);
}
inline void glut_remove_interactor(glut_interactor *gi)
{
std::list<glut_interactor *>::iterator it =
std::find(interactors.begin(), interactors.end(), gi);
if(it != interactors.end())
interactors.erase(it);
}
inline void glut_add_interactor(glut_interactor *gi, bool append=true)
{
glut_remove_interactor(gi);
if(append)
interactors.push_back(gi);
else
interactors.push_front(gi);
}
inline void glut_timer(int msec, int value)
{
glutTimerFunc(msec, glut_timer_function, value);
}
inline void glut_idle(bool do_idle)
{
glutIdleFunc(do_idle ? glut_idle_function : 0);
}
class glut_callbacks : public glut_interactor
{
public:
glut_callbacks() :
display_function(0),
idle_function(0),
keyboard_function(0),
menu_status_function(0),
motion_function(0),
mouse_function(0),
passive_motion_function(0),
reshape_function(0),
special_function(0),
timer_function(0),
visibility_function()
{}
virtual void display()
{ if(display_function) display_function(); }
virtual void idle()
{ if(idle_function) idle_function(); }
virtual void keyboard(unsigned char k, int x, int y)
{ if(keyboard_function) keyboard_function(k, x, y); }
virtual void menu_status(int status, int x, int y)
{ if(menu_status_function) menu_status_function(status, x, y); }
virtual void motion(int x, int y)
{ if(motion_function) motion_function(x,y); }
virtual void mouse(int button, int state, int x, int y)
{ if(mouse_function) mouse_function(button, state, x, y); }
virtual void passive_motion(int x, int y)
{ if(passive_motion_function) passive_motion_function(x, y); }
virtual void reshape(int w, int h)
{ if(reshape_function) reshape_function(w, h); }
virtual void special(int key, int x, int y)
{ if(special_function) special_function(key, x, y); }
virtual void timer(int value)
{ if(timer_function) timer_function(value); }
virtual void visibility(int v)
{ if(visibility_function) visibility_function(v); }
void (* display_function) ();
void (* idle_function) ();
void (* keyboard_function) (unsigned char, int, int);
void (* menu_status_function) (int, int, int);
void (* motion_function) (int, int);
void (* mouse_function) (int, int, int, int);
void (* passive_motion_function) (int, int);
void (* reshape_function) (int, int);
void (* special_function) (int, int, int);
void (* timer_function) (int);
void (* visibility_function) (int);
};
class glut_perspective_reshaper : public glut_interactor
{
public:
glut_perspective_reshaper(float infovy = 60.f, float inzNear = .1f, float inzFar = 10.f)
: fovy(infovy), zNear(inzNear), zFar(inzFar), aspect_factor(1) {}
void reshape(int w, int h)
{
width = w; height = h;
if(enabled) apply();
}
void apply()
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
apply_perspective();
glMatrixMode(GL_MODELVIEW);
}
void apply_perspective()
{
aspect = aspect_factor * float(width)/float(height);
if ( aspect < 1 )
{
// fovy is a misnomer.. we really mean the fov applies to the
// smaller dimension
float fovx = fovy;
float real_fov = to_degrees(2 * atan(tan(to_radians(fovx/2))/aspect));
gluPerspective(real_fov, aspect, zNear, zFar);
}
else
gluPerspective(fovy, aspect, zNear, zFar);
}
int width, height;
float fovy, aspect, zNear, zFar;
float aspect_factor;
};
// activates/deactivates on a particular mouse button
// and calculates deltas while active
class glut_simple_interactor : public glut_interactor
{
public:
glut_simple_interactor()
{
activate_on = GLUT_LEFT_BUTTON;
active = false;
use_modifiers = true;
modifiers = 0;
width = height = 0;
x0 = y0 = x = y = dx = dy = 0;
}
virtual void mouse(int button, int state, int X, int Y)
{
if(enabled && button == activate_on && state == GLUT_DOWN &&
(! use_modifiers || (modifiers == glutGetModifiers())) )
{
active = true;
x = x0 = X;
y = y0 = Y;
dx = dy = 0;
}
else if (enabled && button == activate_on && state == GLUT_UP)
{
if(dx == 0 && dy == 0)
update();
active = false;
dx = dy = 0;
}
}
virtual void motion(int X, int Y)
{
if(enabled && active)
{
dx = X - x; dy = y - Y;
x = X; y = Y;
update();
}
}
void reshape(int w, int h)
{
width = w; height = h;
}
virtual void apply_transform() = 0;
virtual void apply_inverse_transform() = 0;
virtual matrix4f get_transform() = 0;
virtual matrix4f get_inverse_transform() = 0;
virtual void update() {}
int activate_on;
bool use_modifiers;
int modifiers;
bool active;
int x0, y0;
int x, y;
int dx, dy;
int width, height;
};
class glut_pan : public glut_simple_interactor
{
public:
glut_pan()
{
scale = .01f;
invert_increment = false;
parent_rotation = 0;
}
void update()
{
vec3f v(dx, dy, 0);
if(parent_rotation != 0) parent_rotation->mult_vec(v);
if(invert_increment)
pan -= v * scale;
else
pan += v * scale;
glutPostRedisplay();
}
void apply_transform()
{
//cerr << "Applying transform: " << (x - x0) << ", " << (y - y0) << endl;
glTranslatef(pan[0], pan[1], pan[2]);
}
void apply_inverse_transform()
{
//cerr << "Applying transform: " << (x - x0) << ", " << (y - y0) << endl;
glTranslatef(-pan[0], -pan[1], -pan[2]);
}
matrix4f get_transform()
{
matrix4f m;
m.make_identity();
m.set_translate(pan);
return m;
}
matrix4f get_inverse_transform()
{
matrix4f m;
m.make_identity();
m.set_translate(-pan);
return m;
}
bool invert_increment;
const rotationf * parent_rotation;
vec3f pan;
float scale;
};
class glut_dolly : public glut_simple_interactor
{
public:
glut_dolly()
{
scale = .01f;
invert_increment = false;
parent_rotation = 0;
}
void update()
{
vec3f v(0,0,dy);
if(parent_rotation != 0) parent_rotation->mult_vec(v);
if(invert_increment)
dolly += v * scale;
else
dolly -= v * scale;
glutPostRedisplay();
}
void apply_transform()
{
//cerr << "Applying transform: " << (x - x0) << ", " << (y - y0) << endl;
glTranslatef(dolly[0], dolly[1], dolly[2]);
}
void apply_inverse_transform()
{
//cerr << "Applying transform: " << (x - x0) << ", " << (y - y0) << endl;
glTranslatef(-dolly[0], -dolly[1], -dolly[2]);
}
matrix4f get_transform()
{
matrix4f m;
m.make_identity();
m.set_translate(dolly);
return m;
}
matrix4f get_inverse_transform()
{
matrix4f m;
m.make_identity();
m.set_translate(-dolly);
return m;
}
bool invert_increment;
const rotationf * parent_rotation;
vec3f dolly;
float scale;
};
class glut_trackball : public glut_simple_interactor
{
public:
glut_trackball()
{
r = rotationf(vec3f(0, 1, 0), 0);
centroid = vec3f(0,0,0);
scale = 1;
invert_increment = false;
parent_rotation = 0;
legacy_mode = false;
}
void update()
{
if(dx == 0 && dy == 0)
{
incr = rotationf();
return;
}
if(legacy_mode)
{
vec3f v(dy, -dx, 0);
float len = v.normalize();
if(parent_rotation != 0) parent_rotation->mult_vec(v);
//r.mult_dir(vec3f(v), v);
if(invert_increment)
incr.set_value(v, -len * scale * -.01);
else
incr.set_value(v, len * scale * -.01);
}
else
{
float min = width < height ? width : height;
min /= 2.f;
vec3f offset(width/2.f, height/2.f, 0);
vec3f a(x-dx, height - (y+dy), 0);
vec3f b( x, height - y , 0);
a -= offset;
b -= offset;
a /= min;
b /= min;
a[2] = pow(2.0f, -0.5f * a.length());
a.normalize();
b[2] = pow(2.0f, -0.5f * b.length());
b.normalize();
vec3f axis = a.cross(b);
axis.normalize();
float angle = acos(a.dot(b));
if(parent_rotation != 0) parent_rotation->mult_vec(axis);
if(invert_increment)
incr.set_value(axis, -angle * scale);
else
incr.set_value(axis, angle * scale);
}
// fixme: shouldn't operator*() preserve 'r' in this case?
if(incr[3] != 0)
r = incr * r;
glutPostRedisplay();
}
void increment_rotation()
{
if(active) return;
// fixme: shouldn't operator*() preserve 'r' in this case?
if(incr[3] != 0)
r = incr * r;
glutPostRedisplay();
}
void apply_transform()
{
glTranslatef(centroid[0], centroid[1], centroid[2]);
glh_rotate(r);
glTranslatef(-centroid[0], -centroid[1], -centroid[2]);
}
void apply_inverse_transform()
{
glTranslatef(centroid[0], centroid[1], centroid[2]);
glh_rotate(r.inverse());
glTranslatef(-centroid[0], -centroid[1], -centroid[2]);
}
matrix4f get_transform()
{
matrix4f mt, mr, minvt;
mt.set_translate(centroid);
r.get_value(mr);
minvt.set_translate(-centroid);
return mt * mr * minvt;
}
matrix4f get_inverse_transform()
{
matrix4f mt, mr, minvt;
mt.set_translate(centroid);
r.inverse().get_value(mr);
minvt.set_translate(-centroid);
return mt * mr * minvt;
}
bool invert_increment;
const rotationf * parent_rotation;
rotationf r;
vec3f centroid;
float scale;
bool legacy_mode;
rotationf incr;
};
class glut_rotate : public glut_simple_interactor
{
public:
glut_rotate()
{
rotate_x = rotate_y = 0;
scale = 1;
}
void update()
{
rotate_x += dx * scale;
rotate_y += dy * scale;
glutPostRedisplay();
}
void apply_transform()
{
glRotatef(rotate_x, 0, 1, 0);
glRotatef(rotate_y, -1, 0, 0);
}
void apply_inverse_transform()
{
glRotatef(-rotate_y, -1, 0, 0);
glRotatef(-rotate_x, 0, 1, 0);
}
matrix4f get_transform()
{
rotationf rx(to_radians(rotate_x), 0, 1, 0);
rotationf ry(to_radians(rotate_y), -1, 0, 0);
matrix4f mx, my;
rx.get_value(mx);
ry.get_value(my);
return mx * my;
}
matrix4f get_inverse_transform()
{
rotationf rx(to_radians(-rotate_x), 0, 1, 0);
rotationf ry(to_radians(-rotate_y), -1, 0, 0);
matrix4f mx, my;
rx.get_value(mx);
ry.get_value(my);
return my * mx;
}
float rotate_x, rotate_y, scale;
};
class glut_mouse_to_keyboard : public glut_simple_interactor
{
public:
glut_mouse_to_keyboard()
{
keyboard_function = 0;
pos_dx_key = neg_dx_key = pos_dy_key = neg_dy_key = 0;
}
void apply_transform() {}
void apply_inverse_transform() {}
matrix4f get_transform() {return matrix4f();}
matrix4f get_inverse_transform() {return matrix4f();}
void update()
{
if(!keyboard_function) return;
if(dx > 0)
keyboard_function(pos_dx_key, x, y);
else if(dx < 0)
keyboard_function(neg_dx_key, x, y);
if(dy > 0)
keyboard_function(pos_dy_key, x, y);
else if(dy < 0)
keyboard_function(neg_dy_key, x, y);
}
unsigned char pos_dx_key, neg_dx_key, pos_dy_key, neg_dy_key;
void (*keyboard_function)(unsigned char, int, int);
};
inline void glut_exit_on_escape(unsigned char k, int x = 0, int y = 0)
{ if(k==27) exit(0); }
struct glut_simple_mouse_interactor : public glut_interactor
{
public:
glut_simple_mouse_interactor(int num_buttons_to_use=3)
{
configure_buttons(num_buttons_to_use);
camera_mode = false;
}
void enable()
{
trackball.enable();
pan.enable();
dolly.enable();
}
void disable()
{
trackball.disable();
pan.disable();
dolly.disable();
}
void set_camera_mode(bool cam)
{
camera_mode = cam;
if(camera_mode)
{
trackball.invert_increment = true;
pan.invert_increment = true;
dolly.invert_increment = true;
pan.parent_rotation = & trackball.r;
dolly.parent_rotation = & trackball.r;
}
else
{
trackball.invert_increment = false;
pan.invert_increment = false;
dolly.invert_increment = false;
if(pan.parent_rotation == &trackball.r) pan.parent_rotation = 0;
if(dolly.parent_rotation == &trackball.r) dolly.parent_rotation = 0;
}
}
void configure_buttons(int num_buttons_to_use = 3)
{
switch(num_buttons_to_use)
{
case 1:
trackball.activate_on = GLUT_LEFT_BUTTON;
trackball.modifiers = 0;
pan.activate_on = GLUT_LEFT_BUTTON;
pan.modifiers = GLUT_ACTIVE_SHIFT;
dolly.activate_on = GLUT_LEFT_BUTTON;
dolly.modifiers = GLUT_ACTIVE_CTRL;
break;
case 2:
trackball.activate_on = GLUT_LEFT_BUTTON;
trackball.modifiers = 0;
pan.activate_on = GLUT_MIDDLE_BUTTON;
pan.modifiers = 0;
dolly.activate_on = GLUT_LEFT_BUTTON;
dolly.modifiers = GLUT_ACTIVE_CTRL;
break;
case 3:
default:
trackball.activate_on = GLUT_LEFT_BUTTON;
trackball.modifiers = 0;
pan.activate_on = GLUT_MIDDLE_BUTTON;
pan.modifiers = 0;
dolly.activate_on = GLUT_RIGHT_BUTTON;
dolly.modifiers = 0;
break;
}
}
virtual void motion(int x, int y)
{
trackball.motion(x,y);
pan.motion(x,y);
dolly.motion(x,y);
}
virtual void mouse(int button, int state, int x, int y)
{
trackball.mouse(button, state, x, y);
pan.mouse(button, state, x, y);
dolly.mouse(button, state, x, y);
}
virtual void reshape(int x, int y)
{
trackball.reshape(x,y);
pan.reshape(x,y);
dolly.reshape(x,y);
}
void apply_transform()
{
pan.apply_transform();
dolly.apply_transform();
trackball.apply_transform();
}
void apply_inverse_transform()
{
trackball.apply_inverse_transform();
dolly.apply_inverse_transform();
pan.apply_inverse_transform();
}
matrix4f get_transform()
{
return ( pan.get_transform() *
dolly.get_transform() *
trackball.get_transform() );
}
matrix4f get_inverse_transform()
{
return ( trackball.get_inverse_transform() *
dolly.get_inverse_transform() *
pan.get_inverse_transform() );
}
void set_parent_rotation(rotationf *rp)
{
trackball.parent_rotation = rp;
dolly.parent_rotation = rp;
pan.parent_rotation = rp;
}
bool camera_mode;
glut_trackball trackball;
glut_pan pan;
glut_dolly dolly;
};
}
#endif
| 22.638051 | 111 | 0.666752 | [
"object",
"transform"
] |
720eee2d7f3173a19024c50ce71fb1b716708da9 | 3,164 | h | C | ports/renesas-ra/boards/RA6M1_EK/ra_cfg/fsp_cfg/bsp/bsp_mcu_family_cfg.h | andypiper/micropython | 7883ae413ddfa6181d784533b236658658383d0c | [
"MIT"
] | 1 | 2022-03-06T10:05:36.000Z | 2022-03-06T10:05:36.000Z | ports/renesas-ra/boards/RA6M1_EK/ra_cfg/fsp_cfg/bsp/bsp_mcu_family_cfg.h | andypiper/micropython | 7883ae413ddfa6181d784533b236658658383d0c | [
"MIT"
] | null | null | null | ports/renesas-ra/boards/RA6M1_EK/ra_cfg/fsp_cfg/bsp/bsp_mcu_family_cfg.h | andypiper/micropython | 7883ae413ddfa6181d784533b236658658383d0c | [
"MIT"
] | null | null | null | /* generated configuration header file - do not edit */
#ifndef BSP_MCU_FAMILY_CFG_H_
#define BSP_MCU_FAMILY_CFG_H_
#include "bsp_mcu_device_pn_cfg.h"
#include "bsp_mcu_device_cfg.h"
#include "../../../ra/fsp/src/bsp/mcu/ra6m1/bsp_mcu_info.h"
#include "bsp_clock_cfg.h"
#define BSP_MCU_GROUP_RA6M1 (1)
#define BSP_LOCO_HZ (32768)
#define BSP_MOCO_HZ (8000000)
#define BSP_SUB_CLOCK_HZ (32768)
#if BSP_CFG_HOCO_FREQUENCY == 0
#define BSP_HOCO_HZ (16000000)
#elif BSP_CFG_HOCO_FREQUENCY == 1
#define BSP_HOCO_HZ (18000000)
#elif BSP_CFG_HOCO_FREQUENCY == 2
#define BSP_HOCO_HZ (20000000)
#else
#error "Invalid HOCO frequency chosen (BSP_CFG_HOCO_FREQUENCY) in bsp_clock_cfg.h"
#endif
#define BSP_CFG_FLL_ENABLE (0)
#define BSP_CORTEX_VECTOR_TABLE_ENTRIES (16U)
#define BSP_VECTOR_TABLE_MAX_ENTRIES (112U)
#define BSP_MCU_VBATT_SUPPORT (1)
#define OFS_SEQ1 0xA001A001 | (1 << 1) | (3 << 2)
#define OFS_SEQ2 (15 << 4) | (3 << 8) | (3 << 10)
#define OFS_SEQ3 (1 << 12) | (1 << 14) | (1 << 17)
#define OFS_SEQ4 (3 << 18) | (15 << 20) | (3 << 24) | (3 << 26)
#define OFS_SEQ5 (1 << 28) | (1 << 30)
#define BSP_CFG_ROM_REG_OFS0 (OFS_SEQ1 | OFS_SEQ2 | OFS_SEQ3 | OFS_SEQ4 | OFS_SEQ5)
#define BSP_CFG_ROM_REG_OFS1 (0xFFFFFEF8 | (1 << 2) | (3) | (1 << 8))
#define BSP_CFG_ROM_REG_MPU_PC0_ENABLE (1)
#define BSP_CFG_ROM_REG_MPU_PC0_START (0xFFFFFFFC)
#define BSP_CFG_ROM_REG_MPU_PC0_END (0xFFFFFFFF)
#define BSP_CFG_ROM_REG_MPU_PC1_ENABLE (1)
#define BSP_CFG_ROM_REG_MPU_PC1_START (0xFFFFFFFC)
#define BSP_CFG_ROM_REG_MPU_PC1_END (0xFFFFFFFF)
#define BSP_CFG_ROM_REG_MPU_REGION0_ENABLE (1)
#define BSP_CFG_ROM_REG_MPU_REGION0_START (0x00FFFFFC)
#define BSP_CFG_ROM_REG_MPU_REGION0_END (0x00FFFFFF)
#define BSP_CFG_ROM_REG_MPU_REGION1_ENABLE (1)
#define BSP_CFG_ROM_REG_MPU_REGION1_START (0x200FFFFC)
#define BSP_CFG_ROM_REG_MPU_REGION1_END (0x200FFFFF)
#define BSP_CFG_ROM_REG_MPU_REGION2_ENABLE (1)
#define BSP_CFG_ROM_REG_MPU_REGION2_START (0x407FFFFC)
#define BSP_CFG_ROM_REG_MPU_REGION2_END (0x407FFFFF)
#define BSP_CFG_ROM_REG_MPU_REGION3_ENABLE (1)
#define BSP_CFG_ROM_REG_MPU_REGION3_START (0x400DFFFC)
#define BSP_CFG_ROM_REG_MPU_REGION3_END (0x400DFFFF)
/* Used to create IELS values for the interrupt initialization table g_interrupt_event_link_select. */
#define BSP_PRV_IELS_ENUM(vector) (ELC_##vector)
/*
ID Code
Note: To permanently lock and disable the debug interface define the BSP_ID_CODE_PERMANENTLY_LOCKED in the compiler settings.
WARNING: This will disable debug access to the part and cannot be reversed by a debug probe.
*/
#if defined(BSP_ID_CODE_PERMANENTLY_LOCKED)
#define BSP_CFG_ID_CODE_LONG_1 (0x00000000)
#define BSP_CFG_ID_CODE_LONG_2 (0x00000000)
#define BSP_CFG_ID_CODE_LONG_3 (0x00000000)
#define BSP_CFG_ID_CODE_LONG_4 (0x00000000)
#else
/* ID CODE: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF */
#define BSP_CFG_ID_CODE_LONG_1 (0xFFFFFFFF)
#define BSP_CFG_ID_CODE_LONG_2 (0xFFFFFFFF)
#define BSP_CFG_ID_CODE_LONG_3 (0xFFFFFFFF)
#define BSP_CFG_ID_CODE_LONG_4 (0xffFFFFFF)
#endif
#endif /* BSP_MCU_FAMILY_CFG_H_ */
| 42.186667 | 126 | 0.766435 | [
"vector"
] |
7212777379ca77c63c3d8e5de397dcec48c21a25 | 8,350 | c | C | app/bluetooth/common/btmesh_provisioning_decorator/sl_btmesh_provisioning_decorator.c | lmnotran/gecko_sdk | 2e82050dc8823c9fe0e8908c1b2666fb83056230 | [
"Zlib"
] | 69 | 2021-12-16T01:34:09.000Z | 2022-03-31T08:27:39.000Z | app/bluetooth/common/btmesh_provisioning_decorator/sl_btmesh_provisioning_decorator.c | lmnotran/gecko_sdk | 2e82050dc8823c9fe0e8908c1b2666fb83056230 | [
"Zlib"
] | 6 | 2022-01-12T18:22:08.000Z | 2022-03-25T10:19:27.000Z | app/bluetooth/common/btmesh_provisioning_decorator/sl_btmesh_provisioning_decorator.c | lmnotran/gecko_sdk | 2e82050dc8823c9fe0e8908c1b2666fb83056230 | [
"Zlib"
] | 21 | 2021-12-20T09:05:45.000Z | 2022-03-28T02:52:28.000Z | /***************************************************************************//**
* @file
* @brief Provisioning decorator module
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* 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.
*
******************************************************************************/
#include "sl_status.h"
#include "sl_bt_api.h"
#include "sl_btmesh_api.h"
#include "em_common.h"
#include "app_assert.h"
#include "sl_simple_timer.h"
#ifdef SL_COMPONENT_CATALOG_PRESENT
#include "sl_component_catalog.h"
#endif // SL_COMPONENT_CATALOG_PRESENT
#ifdef SL_CATALOG_APP_LOG_PRESENT
#include "app_log.h"
#endif // SL_CATALOG_APP_LOG_PRESENT
#include "sl_btmesh_provisioning_decorator.h"
#include "sl_btmesh_provisioning_decorator_config.h"
// Warning! The app_btmesh_util shall be included after the component configuration
// header file in order to provide the component specific logging macro.
#include "app_btmesh_util.h"
/***************************************************************************//**
* @addtogroup ProvisioningDecorator
* @{
******************************************************************************/
/// High Priority
#define HIGH_PRIORITY 0
/// No Timer Options
#define NO_FLAGS 0
/// Callback has no parameters
#define NO_CALLBACK_DATA (void *)NULL
// periodic timer handle
static sl_simple_timer_t restart_timer;
// periodic timer callback
static void prov_decor_restart_timer_cb(sl_simple_timer_t *handle,
void *data);
// -----------------------------------------------------------------------------
// Provisioning Callbacks
/*******************************************************************************
* Called at node initialization time to provide provisioning information
*
* @param[in] provisioned true: provisioned, false: unprovisioned
* @param[in] address Unicast address of the primary element of the node.
Ignored if unprovisioned.
* @param[in] iv_index IV index for the first network of the node
Ignored if unprovisioned.
*
* This is a callback which can be implemented in the application.
* @note If no implementation is provided in the application then a default weak
* implementation is provided which is a no-operation. (empty function)
******************************************************************************/
SL_WEAK void sl_btmesh_on_provision_init_status(bool provisioned,
uint16_t address,
uint32_t iv_index)
{
(void) provisioned;
(void) address;
(void) iv_index;
}
/*******************************************************************************
* Called when the Provisioning starts
*
* @param[in] result Result code. 0: success, non-zero: error
*
* This is a callback which can be implemented in the application.
* @note If no implementation is provided in the application then a default weak
* implementation is provided which is a no-operation. (empty function)
******************************************************************************/
SL_WEAK void sl_btmesh_on_node_provisioning_started(uint16_t result)
{
(void) result;
}
/*******************************************************************************
* Called when the Provisioning finishes successfully
*
* @param[in] address Unicast address of the primary element of the node.
Ignored if unprovisioned.
* @param[in] iv_index IV index for the first network of the node
Ignored if unprovisioned.
* This is a callback which can be implemented in the application.
* @note If no implementation is provided in the application then a default weak
* implementation is provided which is a no-operation. (empty function)
******************************************************************************/
SL_WEAK void sl_btmesh_on_node_provisioned(uint16_t address,
uint32_t iv_index)
{
(void) address;
(void) iv_index;
}
/*******************************************************************************
* Called when the Provisioning fails
*
* @param[in] result Result code. 0: success, non-zero: error
*
* This is a callback which can be implemented in the application.
* @note If no implementation is provided in the application then a default weak
* implementation is provided which is a no-operation. (empty function)
******************************************************************************/
SL_WEAK void sl_btmesh_on_node_provisioning_failed(uint16_t result)
{
(void) result;
}
// -----------------------------------------------------------------------------
// Provisioning Decorator Callbacks
/*******************************************************************************
* Handling of Provisioning Decorator stack events.
*
* @param[in] evt Event type
******************************************************************************/
void sl_btmesh_handle_provisioning_decorator_event(sl_btmesh_msg_t *evt)
{
if (NULL == evt) {
return;
}
// Handle events
switch (SL_BT_MSG_ID(evt->header)) {
case sl_btmesh_evt_node_initialized_id:
sl_btmesh_on_provision_init_status(evt->data.evt_node_initialized.provisioned,
evt->data.evt_node_initialized.address,
evt->data.evt_node_initialized.iv_index);
break;
case sl_btmesh_evt_node_provisioning_started_id:
sl_btmesh_on_node_provisioning_started(evt->data.evt_node_provisioning_started.result);
break;
case sl_btmesh_evt_node_provisioned_id:
sl_btmesh_on_node_provisioned(evt->data.evt_node_provisioned.address,
evt->data.evt_node_provisioned.iv_index);
break;
case sl_btmesh_evt_node_provisioning_failed_id: {
sl_btmesh_on_node_provisioning_failed(evt->data.evt_node_provisioning_failed.result);
log("BT mesh system reset timer is started with %d ms timeout.\r\n",
SL_BTMESH_PROVISIONING_DECORATOR_RESTART_TIMER_TIMEOUT_CFG_VAL);
sl_status_t sc =
sl_simple_timer_start(&restart_timer,
SL_BTMESH_PROVISIONING_DECORATOR_RESTART_TIMER_TIMEOUT_CFG_VAL,
prov_decor_restart_timer_cb,
NO_CALLBACK_DATA,
false);
app_assert_status_f(sc, "Failed to start timer\n");
break;
}
default:
break;
}
}
/***************************************************************************//**
* Called when the restart timer expires.
*
* @param[in] handle Pointer to the timer handle
* @param[in] data Pointer to callback data
******************************************************************************/
static void prov_decor_restart_timer_cb(sl_simple_timer_t *handle,
void *data)
{
(void)data;
(void)handle;
sl_bt_system_reset(0);
}
/** @} (end addtogroup ProvisioningDecorator) */
| 39.57346 | 93 | 0.558443 | [
"mesh"
] |
7220095aafaa4e1cdffdf9244ba358d0bde0f0e4 | 3,377 | h | C | vc/MySQL Screensaver/Timer.h | neozhou2009/nehe-opengl | 9f073e5b092ad8dbcb21393871a2855fe86a65c6 | [
"MIT"
] | 177 | 2017-12-31T04:44:27.000Z | 2022-03-23T10:08:03.000Z | vc/MySQL Screensaver/Timer.h | neozhou2009/nehe-opengl | 9f073e5b092ad8dbcb21393871a2855fe86a65c6 | [
"MIT"
] | 2 | 2018-06-28T20:28:33.000Z | 2018-09-09T17:34:44.000Z | vc/MySQL Screensaver/Timer.h | neozhou2009/nehe-opengl | 9f073e5b092ad8dbcb21393871a2855fe86a65c6 | [
"MIT"
] | 72 | 2018-01-07T16:41:29.000Z | 2022-03-18T17:57:38.000Z | #ifndef _TIMER_H_
#define _TIMER_H_
//Created by Kristo Kaas in 2002
//
//This file is free for any kinds of use - just don't blame me if something goes wrong :)
//You can modify it, rewrite it, copy-paste it and what-not, but I'd really appreciate
//if you included my name and a reference to nehe.gamedev.net (the place where I got the
//idea, reason and motivation to write this). I'm not very good with the licensing thingy
//so, moving on:
//Use:
// TTimer* Timer = new TTimer();
// Timer->Push(); //create a snapshot of the current time instance
// Timer->Pop(); //get the time offset since last call to Timer->Push()
// Timer->Counter(); //returns nr of milliseconds since Win was restarted
// Timer->Random(x); //generates a random number where 0 < return_value < x;
//Additional Notes:
//
// If you initialize a timer class, it is confined within the scope of the file you initialize
// it in. E g - if you create a Timer in Main.cpp, and provide some "extern TTimer* Timer"
// in Global.h which is included also in Secondary.cpp, then calling Timer->Pop() in
// Secondary.cpp will return 0.
//
// Solution: add a global function "long GetTime()" (or something) to Main.cpp and its prototype
// to Global.h. From Secondary.cpp call GetTime() instead.
//
// If you don't want TTimer to reseed the internal random number generator, call its constructor
// with one parameter, it being set to false
//include to initialize a new random number
//generator based on system time
#ifdef __BORLANDC__
#include <time>
#include <windows>
#else
#include <time.h>
#include <windows.h>
#endif
class TTimer
{
struct {
__int64 frequency;
double resolution;
unsigned long mm_timer_start;
unsigned long mm_timer_elapsed;
bool performance_timer;
__int64 performance_timer_start;
__int64 performance_timer_elapsed;
double timer_mark;
} timer;
private:
void Init(bool _randomize)
{
memset(&timer, 0, sizeof(timer));
if(!QueryPerformanceFrequency((LARGE_INTEGER *) &timer.frequency))
{
timer.performance_timer = FALSE;
timer.mm_timer_start = timeGetTime();
timer.resolution = 1.0f / 1000;
timer.frequency = 1000;
timer.mm_timer_elapsed = timer.mm_timer_start;
}
else
{
QueryPerformanceCounter((LARGE_INTEGER *) &timer.performance_timer_start);
timer.performance_timer = TRUE;
timer.resolution = (double) (((double)1.0f)/((double)timer.frequency));
timer.performance_timer_elapsed = timer.performance_timer_start;
}
//if the flag was set, reinit the srand() function with the t_time object
if(_randomize)
{
time_t t;
srand((unsigned) time(&t));
}
}
public:
TTimer() { Init(true); timer.timer_mark = Counter(); }
TTimer(bool _randomize) { Init(_randomize); timer.timer_mark = Counter(); }
virtual ~TTimer() { }
int Random(int scale = 100) { return random(scale); }
double Counter()
{
__int64 time;
if(timer.performance_timer)
{
QueryPerformanceCounter((LARGE_INTEGER *)&time);
return((double)(time - timer.performance_timer_start) * timer.resolution) * 1000.0f;
}
else return((double)(timeGetTime() - timer.mm_timer_start) * timer.resolution) * 1000.0f;
}
void Push() { timer.timer_mark = Counter(); }
unsigned long Pop() { return(Counter() - timer.timer_mark); }
};
#endif
| 31.560748 | 96 | 0.696476 | [
"object"
] |
7221ceb2ac24a5935c2f162d14cd8c90c81d55ab | 1,068 | h | C | dwt/buffer_obj.h | dwtscript/dwt | ca0c0b0edb5cc6318f384121fe5630fc7fced598 | [
"MIT"
] | 1 | 2022-01-05T21:31:50.000Z | 2022-01-05T21:31:50.000Z | dwt/buffer_obj.h | dwtscript/dwt | ca0c0b0edb5cc6318f384121fe5630fc7fced598 | [
"MIT"
] | 1 | 2022-03-27T14:13:42.000Z | 2022-03-27T14:13:42.000Z | dwt/buffer_obj.h | dwtscript/dwt | ca0c0b0edb5cc6318f384121fe5630fc7fced598 | [
"MIT"
] | 1 | 2021-12-02T22:42:24.000Z | 2021-12-02T22:42:24.000Z | /* SPDX-FileCopyrightText: (c) 2021 Andrew Scott-Jones <andrew@dwtscript.org>
* SPDX-License-Identifier: MIT
*/
#ifndef GUARD_DWT_BUFFER_OBJ_H
#define GUARD_DWT_BUFFER_OBJ_H
#include <dwt/macros.h>
#include <dwt/object.h>
#define AS_BUFFER(o) ((dwt_buffer_obj_t *) (o))
BEGIN_C_DECLS
CFG_CHECK
struct dwt_state;
typedef struct dwt_buffer_obj
{
dwt_object_t super;
int nr_bytes;
int max_bytes;
} dwt_buffer_obj_t;
EXPORT dwt_buffer_obj_t *
dwt_buffer_obj_alloc(
int nr_bytes,
dwt_object_flags_t flags,
struct dwt_state *state);
EXPORT void
dwt_buffer_obj_copy(dwt_buffer_obj_t *buf, dwt_buffer_obj_t *src);
EXPORT dwt_buffer_obj_t *
dwt_buffer_obj_clone(dwt_buffer_obj_t *buf, struct dwt_state *state);
EXPORT int
dwt_buffer_obj_footprint(dwt_buffer_obj_t *obj);
EXPORT void *
dwt_buffer_obj_base(dwt_buffer_obj_t *obj);
#if !CONFIG_DWT_NO_OBJECT_SQUASHING
EXPORT int
dwt_buffer_obj_squashiness(dwt_buffer_obj_t *obj);
EXPORT int
dwt_buffer_obj_squash(dwt_buffer_obj_t *obj);
#endif
ENDOF_C_DECLS
#endif
| 19.071429 | 77 | 0.776217 | [
"object"
] |
72250b101e2f1d5ed80c2e599b9d04455e9ac696 | 9,105 | h | C | common/include/math/Vector4.h | medina325/Computer-Graphics-Homework---RayTracer-Renderer-with-BVH | 62d95109c7358a1f9c004138a9007d91cba47987 | [
"Apache-2.0"
] | null | null | null | common/include/math/Vector4.h | medina325/Computer-Graphics-Homework---RayTracer-Renderer-with-BVH | 62d95109c7358a1f9c004138a9007d91cba47987 | [
"Apache-2.0"
] | null | null | null | common/include/math/Vector4.h | medina325/Computer-Graphics-Homework---RayTracer-Renderer-with-BVH | 62d95109c7358a1f9c004138a9007d91cba47987 | [
"Apache-2.0"
] | null | null | null | //[]---------------------------------------------------------------[]
//| |
//| Copyright (C) 2014, 2019 Orthrus Group. |
//| |
//| 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. |
//| |
//[]---------------------------------------------------------------[]
//
// OVERVIEW: Vector4.h
// ========
// Class definition for 4D vector.
//
// Author: Paulo Pagliosa
// Last revision: 05/09/2019
#ifndef __Vector4_h
#define __Vector4_h
#include "math/Vector3.h"
namespace cg
{ // begin namespace cg
/////////////////////////////////////////////////////////////////////
//
// Vector4: 4D vector class
// =======
template <typename real>
class Vector4
{
public:
using vec3 = Vector3<real>;
using vec4 = Vector4<real>;
using value_type = real;
real x;
real y;
real z;
real w;
/// Default constructor.
HOST DEVICE
Vector4() = default;
/// Constructs a Vector4 object from (x, y, z, w).
HOST DEVICE
Vector4(real x, real y, real z, real w = 0)
{
set(x, y, z, w);
}
/// Constructs a Vector4 object from v[4].
HOST DEVICE
explicit Vector4(const real v[])
{
set(v);
}
/// Constructs a Vector4 object with (s, s, s, s).
HOST DEVICE
explicit Vector4(real s)
{
set(s);
}
/// Constructs a Vector4 object from (v, w).
HOST DEVICE
explicit Vector4(const vec3& v, real w = 0)
{
set(v, w);
}
/// Constructs a Vector4 object from v.
HOST DEVICE
template <typename V>
explicit Vector4(const V& v):
x{real(v.x)},
y{real(v.y)},
z{real(v.z)},
w{real(v.w)}
{
// do nothing
}
/// Sets this object to v.
HOST DEVICE
void set(const vec4& v)
{
*this = v;
}
/// Sets the coordinates of this object to (x, y, z, w).
HOST DEVICE
void set(real x, real y, real z, real w = 0)
{
this->x = x;
this->y = y;
this->z = z;
this->w = w;
}
/// Sets the coordinates of this object to v[4].
HOST DEVICE
void set(const real v[])
{
x = v[0];
y = v[1];
z = v[2];
w = v[3];
}
/// Sets the coordinates of this object to (s, s, s, s).
HOST DEVICE
void set(real s)
{
x = y = z = w = s;
}
/// Sets the coordinates of this object to (v, w).
HOST DEVICE
void set(const vec3& v, real w = 0)
{
x = v.x;
y = v.y;
z = v.z;
this->w = w;
}
/// Sets the coordinates of this object from v.
HOST DEVICE
template <typename V>
void set(const V& v)
{
set(real(v.x), real(v.y), real(v.z), real(v.w));
}
HOST DEVICE
template <typename V>
vec4& operator =(const V& v)
{
set(v);
return *this;
}
/// Returns a null vector.
HOST DEVICE
static vec4 null()
{
return vec4(real(0));
}
/// Returns true if this object is equal to v.
HOST DEVICE
bool equals(const vec4& v, real eps = math::Limits<real>::eps()) const
{
return math::isNull(x - v.x, y - v.y, z - v.z, w - v.w, eps);
}
HOST DEVICE
bool operator ==(const vec4& v) const
{
return equals(v);
}
/// Returns true if this object is not equal to v.
HOST DEVICE
bool operator !=(const vec4& v) const
{
return !operator ==(v);
}
/// Returns a reference to this object += v.
HOST DEVICE
vec4& operator +=(const vec4& v)
{
x += v.x;
y += v.y;
z += v.z;
w += v.w;
return *this;
}
/// Returns a reference to this object -= v.
HOST DEVICE
vec4& operator -=(const vec4& v)
{
x -= v.x;
y -= v.y;
z -= v.z;
w -= v.w;
return *this;
}
/// Returns a reference to this object *= s.
HOST DEVICE
vec4& operator *=(real s)
{
x *= s;
y *= s;
z *= s;
w *= s;
return *this;
}
/// Returns a reference to this object *= v.
HOST DEVICE
vec4& operator *=(const vec4& v)
{
x *= v.x;
y *= v.y;
z *= v.z;
w *= v.w;
return *this;
}
/// Returns a reference to the i-th coordinate of this object.
HOST DEVICE
real& operator [](int i)
{
return (&x)[i];
}
/// Returns the i-th coordinate of this object.
HOST DEVICE
const real& operator [](int i) const
{
return (&x)[i];
}
/// Returns a pointer to the elements of this object.
HOST DEVICE
explicit operator const real*() const
{
return &x;
}
/// Returns this object + v.
HOST DEVICE
vec4 operator +(const vec4& v) const
{
return vec4{x + v.x, y + v.y, z + v.z, w + v.w};
}
/// Returns this object - v.
HOST DEVICE
vec4 operator -(const vec4& v) const
{
return vec4{x - v.x, y - v.y, z - v.z, w - v.w};
}
/// Returns a vector in the direction opposite to this object.
HOST DEVICE
vec4 operator -() const
{
return vec4{-x, -y, -z, -w};
}
/// Returns the scalar multiplication of this object and s.
HOST DEVICE
vec4 operator *(real s) const
{
return vec4{x * s, y * s, z * s, w * s};
}
/// Returns the multiplication of this object and v.
HOST DEVICE
vec4 operator *(const vec4& v) const
{
return vec4{x * v.x, y * v.y, z * v.z, w * v.w};
}
/// Returns true if this object is null.
HOST DEVICE
bool isNull(real eps = math::Limits<real>::eps()) const
{
return math::isNull(x, y, z, w, eps);
}
/// Returns the squared norm of this object.
HOST DEVICE
real squaredNorm() const
{
return math::sqr(x) + math::sqr(y) + math::sqr(z) + math::sqr(w);
}
/// Returns the length of this object.
HOST DEVICE
real length() const
{
return sqrt(squaredNorm());
}
/// Returns the maximum coordinate of this object.
HOST DEVICE
real max() const
{
return std::max(x, std::max(y, std::max(z, w)));
}
/// Returns the minimum coordinate of this object.
HOST DEVICE
real min() const
{
return std::min(x, std::min(y, std::min(z, w)));
}
/// Returns the inverse of this object.
HOST DEVICE
vec4 inverse() const
{
return vec4{1 / x, 1 / y, 1 / z, 1 / w};
}
/// Inverts and returns a reference to this object.
HOST DEVICE
vec3& invert()
{
x = 1 / x;
y = 1 / y;
z = 1 / z;
w = 1 / w;
return *this;
}
/// Negates and returns a reference to this object.
HOST DEVICE
vec4& negate()
{
x = -x;
y = -y;
z = -z;
w = -w;
return *this;
}
/// Normalizes and returns a reference to this object.
HOST DEVICE
vec4& normalize(real eps = math::Limits<real>::eps())
{
const auto len = length();
if (!math::isZero(len, eps))
operator *=(math::inverse(len));
return *this;
}
/// Returns the unit vector of this this object.
HOST DEVICE
vec4 versor(real eps = math::Limits<real>::eps()) const
{
return vec4(*this).normalize(eps);
}
/// Returns the unit vector of v.
HOST DEVICE
static vec4 versor(const vec4& v, real eps = math::Limits<real>::eps())
{
return v.versor(eps);
}
/// Returns the dot product of this object and v.
HOST DEVICE
real dot(const vec4& v) const
{
return x * v.x + y * v.y + z * v.z + w * v.w;
}
/// Returns the dot product of this object and (x, y, z, w).
HOST DEVICE
real dot(real x, real y, real z, real w) const
{
return dot(vec4(x, y, z, w));
}
/// Returns the dot product of v and w.
HOST DEVICE
static real dot(const vec4& v, const vec4& w)
{
return v.dot(w);
}
void print(const char* s, FILE* f = stdout) const
{
fprintf(f, "%s<%g,%g,%g,%g>\n", s, x, y, z, w);
}
}; // Vector4
/// Returns the scalar multiplication of s and v.
template <typename real>
HOST DEVICE inline Vector4<real>
operator *(double s, const Vector4<real>& v)
{
return v * real(s);
}
using vec4f = cg::Vector4<float>;
using vec4d = cg::Vector4<double>;
} // end namespace cg
#endif // __Vector4_h
| 21.627078 | 73 | 0.534651 | [
"object",
"vector"
] |
7228e920985c8b7d1ae918eecc57858cdd222fe5 | 418 | h | C | WitchEngine3/src/WE3/mesh/WEMeshSourceImpl.h | jadnohra/World-Of-Football | fc4c9dd23e0b2d8381ae8f62b1c387af7f28fcfc | [
"MIT"
] | 3 | 2018-12-02T14:09:22.000Z | 2021-11-22T07:14:05.000Z | WitchEngine3/src/WE3/mesh/WEMeshSourceImpl.h | jadnohra/World-Of-Football | fc4c9dd23e0b2d8381ae8f62b1c387af7f28fcfc | [
"MIT"
] | 1 | 2018-12-03T22:54:38.000Z | 2018-12-03T22:54:38.000Z | WitchEngine3/src/WE3/mesh/WEMeshSourceImpl.h | jadnohra/World-Of-Football | fc4c9dd23e0b2d8381ae8f62b1c387af7f28fcfc | [
"MIT"
] | 2 | 2020-09-22T21:04:14.000Z | 2021-05-24T09:43:28.000Z | #ifndef _WEMeshSourceImpl_h
#define _WEMeshSourceImpl_h
#include "WEMeshSource.h"
#include "WEMeshPool.h"
namespace WE {
class MeshSourceImpl : public MeshSource {
public:
MeshSourceImpl(MeshPool* pPool = NULL);
~MeshSourceImpl();
bool setPool(MeshPool* pPool);
MeshPool* getPool();
virtual Mesh* get(MeshLoadInfo& loadInfo);
protected:
MeshPool* mpPool;
};
}
#endif | 15.481481 | 45 | 0.684211 | [
"mesh"
] |
722c208dc6dd471b0ed810369b48aaea0511727a | 5,207 | h | C | include/swift/Frontend/DiagnosticVerifier.h | NuriAmari/swift | d7254b9100742a74021ec4df7412ef79f51c460c | [
"Apache-2.0"
] | 1 | 2022-02-18T12:23:21.000Z | 2022-02-18T12:23:21.000Z | include/swift/Frontend/DiagnosticVerifier.h | NuriAmari/swift | d7254b9100742a74021ec4df7412ef79f51c460c | [
"Apache-2.0"
] | 1 | 2019-11-27T22:18:41.000Z | 2019-11-27T22:18:41.000Z | include/swift/Frontend/DiagnosticVerifier.h | NuriAmari/swift | d7254b9100742a74021ec4df7412ef79f51c460c | [
"Apache-2.0"
] | 1 | 2020-07-15T03:23:59.000Z | 2020-07-15T03:23:59.000Z | //===--- DiagnosticVerifier.h - Diagnostic Verifier (-verify) ---*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file exposes support for the diagnostic verifier, which is used to
// implement -verify mode in the compiler.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_FRONTEND_DIAGNOSTIC_VERIFIER_H
#define SWIFT_FRONTEND_DIAGNOSTIC_VERIFIER_H
#include "llvm/ADT/SmallString.h"
#include "swift/AST/DiagnosticConsumer.h"
#include "swift/Basic/LLVM.h"
namespace swift {
class DependencyTracker;
class FileUnit;
class SourceManager;
class SourceFile;
// MARK: - DependencyVerifier
bool verifyDependencies(SourceManager &SM, ArrayRef<FileUnit *> SFs);
bool verifyDependencies(SourceManager &SM, ArrayRef<SourceFile *> SFs);
// MARK: - DiagnosticVerifier
struct ExpectedFixIt;
/// A range expressed in terms of line-and-column pairs.
struct LineColumnRange {
static constexpr unsigned NoValue = ~0u;
unsigned StartLine, StartCol;
unsigned EndLine, EndCol;
LineColumnRange()
: StartLine(NoValue), StartCol(NoValue), EndLine(NoValue),
EndCol(NoValue) {}
};
class CapturedFixItInfo final {
DiagnosticInfo::FixIt FixIt;
mutable LineColumnRange LineColRange;
public:
CapturedFixItInfo(DiagnosticInfo::FixIt FixIt) : FixIt(FixIt) {}
CharSourceRange &getSourceRange() { return FixIt.getRange(); }
const CharSourceRange &getSourceRange() const { return FixIt.getRange(); }
StringRef getText() const { return FixIt.getText(); }
/// Obtain the line-column range corresponding to the fix-it's
/// replacement range.
const LineColumnRange &getLineColumnRange(const SourceManager &SM,
unsigned BufferID,
bool ComputeStartLocLine,
bool ComputeEndLocLine) const;
};
struct CapturedDiagnosticInfo {
llvm::SmallString<128> Message;
llvm::SmallString<32> FileName;
DiagnosticKind Classification;
SourceLoc Loc;
unsigned Line;
unsigned Column;
SmallVector<CapturedFixItInfo, 2> FixIts;
SmallVector<std::string, 1> EducationalNotes;
CapturedDiagnosticInfo(llvm::SmallString<128> Message,
llvm::SmallString<32> FileName,
DiagnosticKind Classification, SourceLoc Loc,
unsigned Line, unsigned Column,
SmallVector<CapturedFixItInfo, 2> FixIts,
SmallVector<std::string, 1> EducationalNotes)
: Message(Message), FileName(FileName), Classification(Classification),
Loc(Loc), Line(Line), Column(Column), FixIts(FixIts),
EducationalNotes(EducationalNotes) {
std::sort(EducationalNotes.begin(), EducationalNotes.end());
}
};
/// This class implements support for -verify mode in the compiler. It
/// buffers up diagnostics produced during compilation, then checks them
/// against expected-error markers in the source file.
class DiagnosticVerifier : public DiagnosticConsumer {
SourceManager &SM;
std::vector<CapturedDiagnosticInfo> CapturedDiagnostics;
ArrayRef<unsigned> BufferIDs;
SmallVector<unsigned, 4> AdditionalBufferIDs;
bool AutoApplyFixes;
bool IgnoreUnknown;
public:
explicit DiagnosticVerifier(SourceManager &SM, ArrayRef<unsigned> BufferIDs,
bool AutoApplyFixes, bool IgnoreUnknown)
: SM(SM), BufferIDs(BufferIDs), AutoApplyFixes(AutoApplyFixes),
IgnoreUnknown(IgnoreUnknown) {}
void appendAdditionalBufferID(unsigned bufferID) {
AdditionalBufferIDs.push_back(bufferID);
}
virtual void handleDiagnostic(SourceManager &SM,
const DiagnosticInfo &Info) override;
virtual bool finishProcessing() override;
private:
/// Result of verifying a file.
struct Result {
/// Were there any errors? All of the following are considered errors:
/// - Expected diagnostics that were not present
/// - Unexpected diagnostics that were present
/// - Errors in the definition of expected diagnostics
bool HadError;
bool HadUnexpectedDiag;
};
/// verifyFile - After the file has been processed, check to see if we
/// got all of the expected diagnostics and check to see if there were any
/// unexpected ones.
Result verifyFile(unsigned BufferID);
bool checkForFixIt(const ExpectedFixIt &Expected,
const CapturedDiagnosticInfo &D, unsigned BufferID) const;
// Render the verifier syntax for a given set of fix-its.
std::string renderFixits(ArrayRef<CapturedFixItInfo> ActualFixIts,
unsigned BufferID, unsigned DiagnosticLineNo) const;
void printRemainingDiagnostics() const;
};
} // end namespace swift
#endif
| 35.182432 | 80 | 0.680622 | [
"render",
"vector"
] |
722d1300c8f23222aa8caf93c9c479041746ffb6 | 420 | h | C | evoke/include/Executor.h | Resurr3ction/evoke | e154a3385c016aa83726c8c0ef973f17de0b7065 | [
"Apache-2.0"
] | null | null | null | evoke/include/Executor.h | Resurr3ction/evoke | e154a3385c016aa83726c8c0ef973f17de0b7065 | [
"Apache-2.0"
] | null | null | null | evoke/include/Executor.h | Resurr3ction/evoke | e154a3385c016aa83726c8c0ef973f17de0b7065 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <functional>
#include <mutex>
#include <string>
#include <vector>
struct PendingCommand;
class Process;
class Executor
{
public:
Executor(size_t jobcount);
~Executor();
void Run(PendingCommand *cmd);
void Start();
bool Busy();
private:
void RunMoreCommands();
std::mutex m;
std::vector<PendingCommand *> commands;
std::vector<Process *> activeProcesses;
};
| 15.555556 | 43 | 0.67619 | [
"vector"
] |
723177976206890cab27d25ce7512c9a93a54b72 | 447 | h | C | PUBG/Game/World.h | Wolchy/PUBG | 6386d2d552415056d00e8d9941d51bf5550b69bf | [
"MIT"
] | 1 | 2019-03-05T05:19:54.000Z | 2019-03-05T05:19:54.000Z | PUBG/Game/World.h | Wolchy/PUBG | 6386d2d552415056d00e8d9941d51bf5550b69bf | [
"MIT"
] | 2 | 2019-02-15T09:12:19.000Z | 2019-03-06T00:47:34.000Z | PUBG/Game/World.h | Wolchy/PUBG | 6386d2d552415056d00e8d9941d51bf5550b69bf | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include <ctime>
#include "Entity/Dummy.h"
class World {
public:
int PLAYERS_ON_STARTUP = 4, players_ig = 0, TIMER_xd = 60, TIMER_XD = 10;
std::string STATE = "IDLE", STATE_IDLE = "IDLE", STATE_WAITING = "WAITING", STATE_TIMER = "TIMING",
STATE_BR = "BATTLE", STATE_WINNER = "WINNER";
time_t timerxd, timerXD;
std::vector<Dummy*> players;
World();
void update();
bool playerJoin(Dummy * _player);
}; | 19.434783 | 100 | 0.684564 | [
"vector"
] |
72318ac3597e1f0c6736e65fa53e7aaa93b94b92 | 223,279 | h | C | mrubybind.h | lihaochen910/mrubybind | 118affc09bc458a32936cc60d74b75bf213cbfda | [
"MIT"
] | null | null | null | mrubybind.h | lihaochen910/mrubybind | 118affc09bc458a32936cc60d74b75bf213cbfda | [
"MIT"
] | null | null | null | mrubybind.h | lihaochen910/mrubybind | 118affc09bc458a32936cc60d74b75bf213cbfda | [
"MIT"
] | 1 | 2020-07-16T11:22:52.000Z | 2020-07-16T11:22:52.000Z | // Do not modify this file directly, this is generated
/**
* mrubybind - Binding library for mruby/C++
*
* Usage:
* 1. Prepare a function which you want to call from mruby:
* > int square(int x) { return x * x; }
*
* 2. Create MrubyBind instance:
* > MrubyBind b(mirb)
*
* 3. Bind a function:
* > b.bind("square", square);
*
* 4. You can call it from mruby:
* > puts square(1111) #=> 1234321
*
* There are other methods to bind constant/class/instance method in
* MrubyBind. Please see the definition of MrubyBind
* (the bottom of this file), or README.
*/
#ifndef __MRUBYBIND_H__
#define __MRUBYBIND_H__
#ifndef __cplusplus
#error mrubybind can be used from C++ only.
#endif
#include "mruby.h"
#include "mruby/class.h"
#include "mruby/data.h"
#include "mruby/proc.h"
#include "mruby/variable.h"
//#include "mrubybind_types.h"
#include <iostream>
#include <vector>
// Describe type conversion between C type value and mruby value.
#include "mruby/string.h"
#include "mruby/proc.h"
#include "mruby/array.h"
#include "mruby/hash.h"
#include "mruby/variable.h"
#include <string>
#include <functional>
#include <memory>
#include <map>
#include <iostream>
namespace mrubybind {
extern const char* untouchable_table;
extern const char* untouchable_object;
//================================================================//
// MrubyArenaStore
//================================================================//
class MrubyArenaStore {
mrb_state* mrb;
int ai;
public:
MrubyArenaStore ( mrb_state* mrb ) {
this->mrb = mrb;
this->ai = mrb_gc_arena_save ( mrb );
}
~MrubyArenaStore () {
mrb_gc_arena_restore ( this->mrb, this->ai );
}
};
//================================================================//
// MrubyBindStatus
//================================================================//
class MrubyBindStatus {
public:
struct Data;
typedef std::shared_ptr< Data > Data_ptr;
typedef std::map< mrb_state*, Data_ptr > Table;
struct ObjectInfo {
size_t ref_count;
size_t id;
ObjectInfo () {
this->ref_count = 0;
this->id = 0;
}
ObjectInfo ( size_t id ) {
this->ref_count = 1;
this->id = id;
}
};
typedef std::map< RBasic*, ObjectInfo > ObjectIdTable;
typedef std::vector< size_t > FreeIdArray;
static Table& get_living_table () {
static Table table;
return table;
}
struct Data {
typedef std::map< std::string, std::map< std::string, bool > > ClassConvertableTable;
mrb_state* mrb;
mrb_value avoid_gc_table;
ClassConvertableTable class_convertable_table;
ObjectIdTable object_id_table;
FreeIdArray free_id_array;
Data () {}
~Data () {}
mrb_state* get_mrb () {
return mrb;
}
mrb_value get_avoid_gc_table () {
return avoid_gc_table;
}
size_t new_id () {
//return mrb_ary_len(mrb, avoid_gc_table);
return RARRAY_LEN ( avoid_gc_table );
}
ObjectIdTable& get_object_id_table () {
return object_id_table;
}
FreeIdArray& get_free_id_array () {
return free_id_array;
}
void set_class_conversion ( const std::string& s, const std::string& d, bool c ) {
class_convertable_table [ s ][ d ] = c;
}
bool is_convertable ( const std::string& s, const std::string& d ) {
auto fs = class_convertable_table.find ( s );
if ( fs != class_convertable_table.end () ) {
auto fd = fs->second.find ( d );
if ( fd != fs->second.end () ) {
return fd->second;
}
}
return false;
}
bool add_avoid_gc_object ( const mrb_value& v ) {
if ( !mrb_immediate_p ( v ) ) {
auto& mrbsp = MrubyBindStatus::search ( mrb );
mrb_value avoid_gc_table = mrbsp->get_avoid_gc_table ();
auto& object_id_table = mrbsp->get_object_id_table ();
auto& free_id_array = mrbsp->get_free_id_array ();
if ( object_id_table.find ( mrb_basic_ptr ( v ) ) == object_id_table.end () ) {
size_t new_id;
if ( !free_id_array.empty () ) {
new_id = free_id_array.back ();
free_id_array.pop_back ();
mrb_ary_set ( mrb, avoid_gc_table, ( mrb_int )new_id, v );
}
else {
new_id = mrbsp->new_id ();
mrb_ary_push ( mrb, avoid_gc_table, v );
}
object_id_table [ mrb_basic_ptr ( v ) ] = MrubyBindStatus::ObjectInfo ( new_id );
}
else {
object_id_table [ mrb_basic_ptr ( v ) ].ref_count++;
}
return true;
}
return false;
}
bool reduce_avoid_gc_object ( const mrb_value& v ) {
if ( !mrb_immediate_p ( v ) ) {
auto& mrbsp = MrubyBindStatus::search ( mrb );
mrb_value avoid_gc_table = mrbsp->get_avoid_gc_table ();
auto& object_id_table = mrbsp->get_object_id_table ();
auto& free_id_array = mrbsp->get_free_id_array ();
if ( object_id_table.find ( mrb_basic_ptr ( v ) ) != object_id_table.end () ) {
auto& obj_info = object_id_table [ mrb_basic_ptr ( v ) ];
obj_info.ref_count--;
if ( obj_info.ref_count <= 0 ) {
mrb_ary_set ( mrb, avoid_gc_table, ( mrb_int )obj_info.id, mrb_nil_value () );
free_id_array.push_back ( obj_info.id );
object_id_table.erase ( mrb_basic_ptr ( v ) );
}
return true;
}
return false;
}
return false;
}
};
MrubyBindStatus () {
}
MrubyBindStatus ( mrb_state* mrb, mrb_value avoid_gc_table ) {
Table& living_table = MrubyBindStatus::get_living_table ();
data = std::make_shared < Data > ();
data->mrb = mrb;
data->avoid_gc_table = avoid_gc_table;
living_table [ mrb ] = data;
}
~MrubyBindStatus () {
Table& living_table = MrubyBindStatus::get_living_table ();
living_table.erase ( data->mrb );
data->mrb = NULL;
}
static bool is_living ( mrb_state* mrb ) {
Table& living_table = get_living_table ();
if ( living_table.find ( mrb ) != living_table.end () ) {
return living_table [ mrb ].get ();
}
return false;
}
static Data_ptr search ( mrb_state* mrb ) {
Table& living_table = MrubyBindStatus::get_living_table ();
if ( living_table.find ( mrb ) != living_table.end () ) {
return living_table [ mrb ];
}
return Data_ptr ( NULL );
}
private:
std::shared_ptr< Data > data;
};
//================================================================//
// NullDeleter<T>
//================================================================//
template<class T>
struct NullDeleter {
void operator()( T* p ) const {}
};
struct GCDeleter {
mrb_state* mrb;
GCDeleter ( mrb_state* mrb ) { this->mrb = mrb; }
void operator()( RBasic* p ) const { mrb_gc_unregister ( mrb, mrb_obj_value(p) ); }
};
//================================================================//
// Deleter<T>
//================================================================//
template<class T>
class Deleter {
private:
MrubyBindStatus::Data_ptr mrbsp;
mrb_value v_;
public:
Deleter() { }
Deleter ( mrb_state* mrb, mrb_value v ) {
if ( !mrb_immediate_p ( v ) ) {
mrbsp = MrubyBindStatus::search ( mrb );
mrbsp->add_avoid_gc_object ( v );
/*mrb_value avoid_gc_table = mrbsp->get_avoid_gc_table ();
auto& object_id_table = mrbsp->get_object_id_table ();
auto& free_id_array = mrbsp->get_free_id_array ();
if ( object_id_table.find ( mrb_basic_ptr ( v ) ) == object_id_table.end () ) {
size_t new_id;
if ( !free_id_array.empty () ) {
new_id = free_id_array.back ();
free_id_array.pop_back ();
mrb_ary_set ( mrb, avoid_gc_table, ( mrb_int )new_id, v );
}
else {
new_id = mrbsp->new_id ();
mrb_ary_push ( mrb, avoid_gc_table, v );
}
object_id_table [ mrb_basic_ptr ( v ) ] = MrubyBindStatus::ObjectInfo ( new_id );
}
else {
object_id_table [ mrb_basic_ptr ( v ) ].ref_count++;
}*/
}
v_ = v;
}
~Deleter() { }
mrb_state* get_mrb () {
return mrbsp->mrb;
}
void operator()( T* p ) const {
if ( mrbsp.get () ) {
mrb_state* mrb = mrbsp->get_mrb ();
if ( mrb ) {
mrbsp->reduce_avoid_gc_object ( v_ );
/*mrb_value v = v_;
if ( !mrb_immediate_p ( v ) ) {
mrb_value avoid_gc_table = mrbsp->get_avoid_gc_table ();
auto& object_id_table = mrbsp->get_object_id_table ();
auto& free_id_array = mrbsp->get_free_id_array ();
auto& oi = object_id_table [ mrb_basic_ptr ( v ) ];
oi.ref_count--;
if ( oi.ref_count <= 0 ) {
mrb_ary_set ( mrb, avoid_gc_table, ( mrb_int )oi.id, mrb_nil_value () );
free_id_array.push_back ( oi.id );
object_id_table.erase ( mrb_basic_ptr ( v ) );
}
}*/
}
}
if ( p ) {
delete p;
}
}
};
template<class T> using obj_ptr = std::shared_ptr<T>;
//template<class T> using FuncPtr = std::shared_ptr<std::function<T> >;
//================================================================//
// FuncPtr<T>
//================================================================//
template<class T>
class FuncPtr {
private:
mrb_state* mrb;
std::shared_ptr< std::function<T> > p;
public:
FuncPtr () {
}
template<class D>FuncPtr ( std::function<T>* pt, D d ) : p ( pt, d ) {
mrb = d.get_mrb ();
}
~FuncPtr () {
}
const std::shared_ptr<std::function<T> >& ref () const {
return p;
}
bool is_living () const {
return MrubyBindStatus::is_living ( mrb );
}
std::function<T>& func () const {
if ( !p.get () ) {
throw std::runtime_error ( "empty function." );
}
return *p.get ();
}
operator bool () const {
if ( !p.get () ) {
return false;
}
return ( bool )*p.get ();
}
void reset () {
p.reset ();
}
template<class Y> void reset ( Y* y ) {
p.reset ( y );
}
template<class Y, class D> void reset ( Y* y, D d ) {
p.reset ( y, d );
}
template<class Y, class D, class A> void reset ( Y* y, D d, A a ) {
p.reset ( y, d, a );
}
};
template<class T> Deleter<T> set_avoid_gc(mrb_state* mrb, mrb_value v){
return Deleter<T>(mrb, v);
}
template<class T> obj_ptr<T> make_obj_ptr(Deleter<T> d, T t){
T* pt = new T();
*pt = t;
return obj_ptr<T>(pt, d);
}
template<class T> FuncPtr<T> make_FuncPtr(Deleter<std::function<T> > d, std::function<T> t){
std::function<T>* pt = new std::function<T>();
*pt = t;
return FuncPtr<T>(pt, d);
}
template <class T>
struct Type;
//================================================================//
// MrubyRef
//================================================================//
class MrubyRef {
protected:
mrb_state* mrb;
std::shared_ptr<mrb_value> v;
std::shared_ptr<RObject> strong_v;
std::weak_ptr<RObject> weak_v;
public:
enum {
MAKE_STRONG,
MAKE_WEAK,
};
friend class MrubyStrongRef;
friend class MrubyWeakRef;
MrubyRef ();
MrubyRef ( mrb_state* mrb, const mrb_value& v );
MrubyRef ( const MrubyRef& assign );
~MrubyRef ();
void clear ();
void make_strong ( mrb_state* mrb, const mrb_value& v );
void make_weak ( mrb_state* mrb, const mrb_value& v );
virtual void set_ref ( mrb_state* mrb, const mrb_value& v );
void set_ref ( mrb_state* mrb, const mrb_value& v, unsigned int type );
void take ( const MrubyRef& assign );
bool is_living () const;
mrb_state* get_mrb () const;
virtual mrb_value get_v () const;
virtual bool empty () const;
bool test () const;
bool obj_equal ( const MrubyRef& r ) const;
std::string to_s () const;
int to_i () const;
float to_float () const;
double to_double () const;
//----------------------------------------------------------------//
/*inline mrb_value* operator -> () const {
return &this->get_v ();
};*/
//----------------------------------------------------------------//
/*inline mrb_value& operator * () const {
return this->get_v ();
};*/
//----------------------------------------------------------------//
/*inline operator mrb_value* () {
return &this->get_v ();
};*/
MrubyRef call(std::string name);
#include "mrubybind_call_generated.h"
};
//================================================================//
// MrubyStrongRef
//================================================================//
class MrubyStrongRef :
public MrubyRef {
public:
//----------------------------------------------------------------//
MrubyStrongRef ();
MrubyStrongRef ( mrb_state* mrb, const mrb_value& v );
MrubyStrongRef ( const MrubyStrongRef& assign );
void set_ref ( mrb_state* mrb, const mrb_value& v );
mrb_value get_v () const;
bool empty () const;
//----------------------------------------------------------------//
inline operator bool () const {
return !this->empty ();
};
//----------------------------------------------------------------//
inline operator mrb_value() const {
return this->get_v ();
};
//----------------------------------------------------------------//
inline MrubyStrongRef& operator = ( const MrubyStrongRef& rhs ) {
if ( this == &rhs ) {
return *this;
}
this->mrb = rhs.mrb;
this->strong_v = rhs.strong_v;
return *this;
};
};
//================================================================//
// MrubyStrongRef
//================================================================//
class MrubyWeakRef :
public MrubyRef {
public:
//----------------------------------------------------------------//
MrubyWeakRef ();
MrubyWeakRef ( mrb_state* mrb, const mrb_value& v );
MrubyWeakRef ( const MrubyWeakRef& assign );
void set_ref ( mrb_state* mrb, const mrb_value& v );
mrb_value get_v () const;
bool empty () const;
//----------------------------------------------------------------//
inline operator bool() const {
return !this->empty ();
};
//----------------------------------------------------------------//
inline operator mrb_value() const {
return this->get_v ();
};
//----------------------------------------------------------------//
inline MrubyWeakRef& operator = ( const MrubyWeakRef& rhs ) {
if ( this == &rhs ) {
return *this;
}
this->mrb = rhs.mrb;
this->weak_v = rhs.weak_v;
return *this;
};
};
//===========================================================================
// C <-> mruby type converter.
//template <class T>
//struct Type {
// Type name used for error message.
// static const char TYPE_NAME[];
// Returns whether the given mrb_value can be converted into type T.
//static int check(mrb_value v) = 0;
// Converts mrb_value to type T value.
//static T get(mrb_value v) = 0;
// Converts type T value to mrb_value.
//static mrb_value ret(mrb_state*, T i) = 0;
//};
// Fixnum
template<>
struct Type<int> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_fixnum_p(v) || mrb_float_p(v); }
static int get(mrb_state* mrb, mrb_value v) { (void)mrb; return mrb_fixnum_p(v) ? mrb_fixnum(v) : mrb_float(v); }
static mrb_value ret(mrb_state*, int i) { return mrb_fixnum_value(i); }
};
template<>
struct Type<unsigned int> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_fixnum_p(v) || mrb_float_p(v); }
static unsigned int get(mrb_state* mrb, mrb_value v) { (void)mrb; return mrb_fixnum_p(v) ? mrb_fixnum(v) : mrb_float(v); }
static mrb_value ret(mrb_state*, unsigned int i) { return mrb_fixnum_value(i); }
};
// float
template<>
struct Type<float> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_float_p(v) || mrb_fixnum_p(v); }
static float get(mrb_state* mrb, mrb_value v) { (void)mrb; return mrb_float_p(v) ? mrb_float(v) : mrb_fixnum(v); }
static mrb_value ret(mrb_state* mrb, float f) { return mrb_float_value(mrb, f); }
};
// double
template<>
struct Type<double> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_float_p(v) || mrb_fixnum_p(v); }
static double get(mrb_state* mrb, mrb_value v) { (void)mrb; return mrb_float_p(v) ? mrb_float(v) : mrb_fixnum(v); }
static mrb_value ret(mrb_state* mrb, double f) { return mrb_float_value(mrb, f); }
};
// String
template<>
struct Type<const char*> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_string_p(v); }
static const char* get(mrb_state* mrb, mrb_value v) { (void)mrb; return RSTRING_PTR(v); }
static mrb_value ret(mrb_state* mrb, const char* s) { return mrb_str_new_cstr(mrb, s); }
};
template<>
struct Type<std::string> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_string_p(v); }
static const std::string get(mrb_state* mrb, mrb_value v) { (void)mrb; return std::string(RSTRING_PTR(v), RSTRING_LEN(v)); }
static mrb_value ret(mrb_state* mrb, const std::string& s) { return mrb_str_new(mrb, s.c_str(), s.size()); }
};
template<>
struct Type<const std::string> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_string_p(v); }
static const std::string get(mrb_state* mrb, mrb_value v) { (void)mrb; return std::string(RSTRING_PTR(v), RSTRING_LEN(v)); }
static mrb_value ret(mrb_state* mrb, const std::string& s) { return mrb_str_new(mrb, s.c_str(), s.size()); }
};
template<>
struct Type<const std::string&> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_string_p(v); }
static const std::string get(mrb_state* mrb, mrb_value v) { (void)mrb; return std::string(RSTRING_PTR(v), RSTRING_LEN(v)); }
static mrb_value ret(mrb_state* mrb, const std::string& s) { return mrb_str_new(mrb, s.c_str(), s.size()); }
};
// Boolean
template<>
struct Type<bool> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value /*v*/) { return 1; }
static bool get(mrb_state* mrb, mrb_value v) { (void)mrb; return mrb_test(v); }
static mrb_value ret(mrb_state* /*mrb*/, bool b) { return b ? mrb_true_value() : mrb_false_value(); }
};
// Raw pointer
template<>
struct Type<void*> {
static const char TYPE_NAME[];
static int check(mrb_state*, mrb_value v) { return mrb_cptr_p(v); }
static void* get(mrb_state*, mrb_value v) { return mrb_cptr(v); }
static mrb_value ret(mrb_state* mrb, void* p) { printf("Type<void*>::ret()"); return mrb_cptr_value(mrb, p); }
};
// Function
struct TypeFuncBase{
static const char TYPE_NAME[];
};
template<class R>
struct Type<FuncPtr<R()> > :public TypeFuncBase {
static int check(mrb_state*, mrb_value v) { return mrb_type(v) == MRB_TT_PROC; }
static FuncPtr<R()> get(mrb_state* mrb, mrb_value v) {
Deleter<std::function<R()> > d = set_avoid_gc<std::function<R()> >(mrb, v);
return make_FuncPtr<R()>(d, [=](){
MrubyArenaStore mas(mrb);
return Type<R>::get(mrb, mrb_yield(mrb, v, mrb_nil_value()));
});
}
static mrb_value ret(mrb_state* mrb, FuncPtr<R()> p) {
// don't call.
throw std::runtime_error("don't call Type<FuncPtr<R()> >::ret");
(void)mrb; (void)p; return mrb_nil_value();
}
};
template<>
struct Type<FuncPtr<void()> > :public TypeFuncBase {
static int check(mrb_state*, mrb_value v) { return mrb_type(v) == MRB_TT_PROC; }
static FuncPtr<void()> get(mrb_state* mrb, mrb_value v) {
Deleter<std::function<void()> > d = set_avoid_gc<std::function<void()> >(mrb, v);
return make_FuncPtr<void()>(d, [=](){
MrubyArenaStore mas(mrb);
mrb_yield(mrb, v, mrb_nil_value());
});
}
static mrb_value ret(mrb_state* mrb, FuncPtr<void()> p) {
// don't call.
throw std::runtime_error("don't call Type<FuncPtr<void()> >::ret");
(void)mrb; (void)p; return mrb_nil_value();
}
};
// mruby value
template<>
struct Type<MrubyRef> {
static const char TYPE_NAME[];
static int check ( mrb_state*, mrb_value ) { return 1; }
static MrubyRef get ( mrb_state* mrb, mrb_value v ) { ( void )mrb; return MrubyRef ( mrb, v ); }
static mrb_value ret ( mrb_state*, MrubyRef r ) { return r.get_v (); }
};
// mruby StrongRef
template<>
struct Type<MrubyStrongRef> {
static const char TYPE_NAME[];
static int check ( mrb_state*, mrb_value ) { return 1; }
static MrubyStrongRef get ( mrb_state* mrb, mrb_value v ) { ( void )mrb; return MrubyStrongRef ( mrb, v ); }
static mrb_value ret ( mrb_state*, MrubyStrongRef r ) { return r.get_v (); }
};
// mruby WeakRef
template<>
struct Type<MrubyWeakRef> {
static const char TYPE_NAME[];
static int check ( mrb_state*, mrb_value ) { return 1; }
static MrubyWeakRef get ( mrb_state* mrb, mrb_value v ) { ( void )mrb; return MrubyWeakRef ( mrb, v ); }
static mrb_value ret ( mrb_state*, MrubyWeakRef r ) { return r; }
};
#include "mrubybind_types_generated.h"
//===========================================================================
// Binder
// Template class for Binder.
// Binder template class is specialized with type.
template <class T>
struct Binder {
// Template specialization.
//static mrb_value call(mrb_state* mrb, void* p, mrb_value* args, int narg) = 0;
};
// Template class for Binder.
// Binder template class is specialized with type.
template <class C>
struct ClassBinder {
static struct mrb_data_type type_info;
static void dtor(mrb_state*, void* p) {
C* instance = static_cast< C* >(p);
delete instance;
}
// Template specialization.
//static void ctor(mrb_state* mrb, mrb_value self, void* new_func_ptr, mrb_value* args, int narg) {
};
template<class C>
mrb_data_type ClassBinder<C>::type_info = { "???", dtor };
template <class T>
struct CustomClassBinder {
// Template specialization.
//static mrb_value call(mrb_state* mrb, void* p, mrb_value* args, int narg) = 0;
};
// Other Class
struct TypeClassBase{
static const char TYPE_NAME[];
};
template<class T> struct Type<T&> :public TypeClassBase {
static std::string class_name;
static int check(mrb_state* mrb, mrb_value v) {
return mrb_type(v) == MRB_TT_DATA &&
MrubyBindStatus::search(mrb)->is_convertable(mrb_obj_classname(mrb, v), class_name);
}
static T& get(mrb_state* mrb, mrb_value v) {
(void)mrb; return *(T*)DATA_PTR(v);
}
static mrb_value ret(mrb_state* mrb, T t) {
RClass* cls;
mrb_value v;
cls = mrb_class_get(mrb, class_name.c_str());
v = mrb_class_new_instance(mrb, 0, NULL, cls);
DATA_TYPE(v) = &ClassBinder<T>::type_info;
T* nt = new T();
*nt = t;
DATA_PTR(v) = nt;
return v;
}
};
template<class T> std::string Type<T&>::class_name = "";
template<class T> struct Type : public TypeClassBase {
static std::string class_name;
static int check(mrb_state* mrb, mrb_value v) {
return mrb_type(v) == MRB_TT_DATA &&
MrubyBindStatus::search(mrb)->is_convertable(mrb_obj_classname(mrb, v), class_name);
}
static T get(mrb_state* mrb, mrb_value v) {
(void)mrb; return *(T*)DATA_PTR(v);
}
static mrb_value ret(mrb_state* mrb, T t) {
RClass* cls;
mrb_value v;
cls = mrb_class_get(mrb, class_name.c_str());
v = mrb_class_new_instance(mrb, 0, NULL, cls);
DATA_TYPE(v) = &ClassBinder<T>::type_info;
T* nt = new T();
*nt = t;
DATA_PTR(v) = nt;
return v;
}
};
template<class T> std::string Type<T>::class_name = "";
//
mrb_value raise(mrb_state *mrb, int parameter_index,
const char* required_type_name, mrb_value value);
mrb_value raisenarg(mrb_state *mrb, mrb_value func_name, int narg, int nparam);
// Includes generated template specialization.
//#include "mrubybind.inc"
// This file is generated from gen_template.rb
#define ARG(mrb, i) Type<P##i>::get(mrb, args[i])
#define ARGSHIFT(mrb, i, j) Type<P##i>::get(mrb, args[j])
#define CHECK(i) {if(!Type<P##i>::check(mrb, args[i])) return RAISE(i);}
#define CHECKSHIFT(i, j) {if(!Type<P##i>::check(mrb, args[j])) return RAISE(j);}
#define RAISE(i) raise(mrb, i, Type<P##i>::TYPE_NAME, args[i])
#define CHECKNARG(narg) {if(narg != NPARAM) RAISENARG(narg);}
#define RAISENARG(narg) raisenarg(mrb, mrb_cfunc_env_get(mrb, 1), narg, NPARAM)
// void f(void);
template<>
struct Binder<void (*)(void)> {
static const int NPARAM = 0;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(void) = (void (*)(void))mrb_cptr(cfunc);
fp();
return mrb_nil_value();
}
};
// R f(void);
template<class R>
struct Binder<R (*)(void)> {
static const int NPARAM = 0;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(void) = (R (*)(void))mrb_cptr(cfunc);
R result = fp();
return Type<R>::ret(mrb, result);
}
};
// C* ctor(void);
template<class C>
struct ClassBinder<C* (*)(void)> {
static const int NPARAM = 0;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(void) = (C* (*)(void))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor();
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(void) };
template<class C>
struct ClassBinder<void (C::*)(void)> {
static const int NPARAM = 0;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(void);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)();
return mrb_nil_value();
}
};
// class C { R f(void) };
template<class C, class R>
struct ClassBinder<R (C::*)(void)> {
static const int NPARAM = 0;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(void);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)();
return Type<R>::ret(mrb, result);
}
};
// void f(P0);
template<class P0>
struct Binder<void (*)(P0)> {
static const int NPARAM = 1;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0) = (void (*)(P0))mrb_cptr(cfunc);
fp(ARG(mrb, 0));
return mrb_nil_value();
}
};
// R f(P0);
template<class R, class P0>
struct Binder<R (*)(P0)> {
static const int NPARAM = 1;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0) = (R (*)(P0))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0);
template<class C, class P0>
struct ClassBinder<C* (*)(P0)> {
static const int NPARAM = 1;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0) = (C* (*)(P0))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0) };
template<class C, class P0>
struct ClassBinder<void (C::*)(P0)> {
static const int NPARAM = 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0));
return mrb_nil_value();
}
};
// class C { R f(P0) };
template<class C, class R, class P0>
struct ClassBinder<R (C::*)(P0)> {
static const int NPARAM = 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0>
struct CustomClassBinder<void (*)(P0)> {
static const int NPARAM = 1 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance);
return mrb_nil_value();
}
};
template<class R, class P0>
struct CustomClassBinder<R (*)(P0)> {
static const int NPARAM = 1 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance);
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0>
struct CustomClassBinder<void (*)(P0&)> {
static const int NPARAM = 1 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance);
return mrb_nil_value();
}
};
template<class R, class P0>
struct CustomClassBinder<R (*)(P0&)> {
static const int NPARAM = 1 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance);
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1);
template<class P0, class P1>
struct Binder<void (*)(P0, P1)> {
static const int NPARAM = 2;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1) = (void (*)(P0, P1))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1));
return mrb_nil_value();
}
};
// R f(P0, P1);
template<class R, class P0, class P1>
struct Binder<R (*)(P0, P1)> {
static const int NPARAM = 2;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1) = (R (*)(P0, P1))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1);
template<class C, class P0, class P1>
struct ClassBinder<C* (*)(P0, P1)> {
static const int NPARAM = 2;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1) = (C* (*)(P0, P1))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1) };
template<class C, class P0, class P1>
struct ClassBinder<void (C::*)(P0, P1)> {
static const int NPARAM = 2;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1));
return mrb_nil_value();
}
};
// class C { R f(P0, P1) };
template<class C, class R, class P0, class P1>
struct ClassBinder<R (C::*)(P0, P1)> {
static const int NPARAM = 2;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1>
struct CustomClassBinder<void (*)(P0, P1)> {
static const int NPARAM = 2 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0));
return mrb_nil_value();
}
};
template<class R, class P0, class P1>
struct CustomClassBinder<R (*)(P0, P1)> {
static const int NPARAM = 2 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1>
struct CustomClassBinder<void (*)(P0&, P1)> {
static const int NPARAM = 2 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0));
return mrb_nil_value();
}
};
template<class R, class P0, class P1>
struct CustomClassBinder<R (*)(P0&, P1)> {
static const int NPARAM = 2 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2);
template<class P0, class P1, class P2>
struct Binder<void (*)(P0, P1, P2)> {
static const int NPARAM = 3;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2) = (void (*)(P0, P1, P2))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2));
return mrb_nil_value();
}
};
// R f(P0, P1, P2);
template<class R, class P0, class P1, class P2>
struct Binder<R (*)(P0, P1, P2)> {
static const int NPARAM = 3;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2) = (R (*)(P0, P1, P2))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2);
template<class C, class P0, class P1, class P2>
struct ClassBinder<C* (*)(P0, P1, P2)> {
static const int NPARAM = 3;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2) = (C* (*)(P0, P1, P2))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2) };
template<class C, class P0, class P1, class P2>
struct ClassBinder<void (C::*)(P0, P1, P2)> {
static const int NPARAM = 3;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2) };
template<class C, class R, class P0, class P1, class P2>
struct ClassBinder<R (C::*)(P0, P1, P2)> {
static const int NPARAM = 3;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2>
struct CustomClassBinder<void (*)(P0, P1, P2)> {
static const int NPARAM = 3 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2>
struct CustomClassBinder<R (*)(P0, P1, P2)> {
static const int NPARAM = 3 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2>
struct CustomClassBinder<void (*)(P0&, P1, P2)> {
static const int NPARAM = 3 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2>
struct CustomClassBinder<R (*)(P0&, P1, P2)> {
static const int NPARAM = 3 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3);
template<class P0, class P1, class P2, class P3>
struct Binder<void (*)(P0, P1, P2, P3)> {
static const int NPARAM = 4;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3) = (void (*)(P0, P1, P2, P3))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3);
template<class R, class P0, class P1, class P2, class P3>
struct Binder<R (*)(P0, P1, P2, P3)> {
static const int NPARAM = 4;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3) = (R (*)(P0, P1, P2, P3))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3);
template<class C, class P0, class P1, class P2, class P3>
struct ClassBinder<C* (*)(P0, P1, P2, P3)> {
static const int NPARAM = 4;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3) = (C* (*)(P0, P1, P2, P3))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3) };
template<class C, class P0, class P1, class P2, class P3>
struct ClassBinder<void (C::*)(P0, P1, P2, P3)> {
static const int NPARAM = 4;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3) };
template<class C, class R, class P0, class P1, class P2, class P3>
struct ClassBinder<R (C::*)(P0, P1, P2, P3)> {
static const int NPARAM = 4;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3>
struct CustomClassBinder<void (*)(P0, P1, P2, P3)> {
static const int NPARAM = 4 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3>
struct CustomClassBinder<R (*)(P0, P1, P2, P3)> {
static const int NPARAM = 4 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3)> {
static const int NPARAM = 4 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3)> {
static const int NPARAM = 4 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4);
template<class P0, class P1, class P2, class P3, class P4>
struct Binder<void (*)(P0, P1, P2, P3, P4)> {
static const int NPARAM = 5;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4) = (void (*)(P0, P1, P2, P3, P4))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4);
template<class R, class P0, class P1, class P2, class P3, class P4>
struct Binder<R (*)(P0, P1, P2, P3, P4)> {
static const int NPARAM = 5;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4) = (R (*)(P0, P1, P2, P3, P4))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4);
template<class C, class P0, class P1, class P2, class P3, class P4>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4)> {
static const int NPARAM = 5;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4) = (C* (*)(P0, P1, P2, P3, P4))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4) };
template<class C, class P0, class P1, class P2, class P3, class P4>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4)> {
static const int NPARAM = 5;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4)> {
static const int NPARAM = 5;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4)> {
static const int NPARAM = 5 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4)> {
static const int NPARAM = 5 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4)> {
static const int NPARAM = 5 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4)> {
static const int NPARAM = 5 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5);
template<class P0, class P1, class P2, class P3, class P4, class P5>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5) = (void (*)(P0, P1, P2, P3, P4, P5))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5) = (R (*)(P0, P1, P2, P3, P4, P5))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5) = (C* (*)(P0, P1, P2, P3, P4, P5))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5)> {
static const int NPARAM = 6 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6) = (void (*)(P0, P1, P2, P3, P4, P5, P6))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6) = (R (*)(P0, P1, P2, P3, P4, P5, P6))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6) = (C* (*)(P0, P1, P2, P3, P4, P5, P6))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6)> {
static const int NPARAM = 7 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7)> {
static const int NPARAM = 8 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8)> {
static const int NPARAM = 9 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9)> {
static const int NPARAM = 10 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)> {
static const int NPARAM = 11 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)> {
static const int NPARAM = 12 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)> {
static const int NPARAM = 13 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)> {
static const int NPARAM = 14 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14)> {
static const int NPARAM = 15 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13); CHECKSHIFT(15, 14);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13), ARGSHIFT(mrb, 15, 14));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13); CHECKSHIFT(15, 14);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13), ARGSHIFT(mrb, 15, 14));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13); CHECKSHIFT(15, 14);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13), ARGSHIFT(mrb, 15, 14));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15)> {
static const int NPARAM = 16 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13); CHECKSHIFT(15, 14);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13), ARGSHIFT(mrb, 15, 14));
return Type<R>::ret(mrb, result);
}
};
// void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct Binder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15); CHECK(16);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
void (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) = (void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16))mrb_cptr(cfunc);
fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15), ARG(mrb, 16));
return mrb_nil_value();
}
};
// R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct Binder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17;
static mrb_value call(mrb_state* mrb, mrb_value /*self*/) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15); CHECK(16);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
R (*fp)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) = (R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16))mrb_cptr(cfunc);
R result = fp(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15), ARG(mrb, 16));
return Type<R>::ret(mrb, result);
}
};
// C* ctor(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct ClassBinder<C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17;
static mrb_value ctor(mrb_state* mrb, mrb_value self) {
DATA_TYPE(self) = &ClassBinder<C>::type_info;
DATA_PTR(self) = NULL;
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15); CHECK(16);
mrb_value cfunc = mrb_cfunc_env_get(mrb, 0);
C* (*ctor)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) = (C* (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16))mrb_cptr(cfunc);
if(ctor)
{
C* instance = ctor(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15), ARG(mrb, 16));
DATA_PTR(self) = instance;
}
return self;
}
};
// class C { void f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) };
template<class C, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct ClassBinder<void (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15); CHECK(16);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
M mp = *(M*)RSTRING_PTR(cmethod);
(instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15), ARG(mrb, 16));
return mrb_nil_value();
}
};
// class C { R f(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) };
template<class C, class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct ClassBinder<R (C::*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECK(0); CHECK(1); CHECK(2); CHECK(3); CHECK(4); CHECK(5); CHECK(6); CHECK(7); CHECK(8); CHECK(9); CHECK(10); CHECK(11); CHECK(12); CHECK(13); CHECK(14); CHECK(15); CHECK(16);
C* instance = static_cast<C*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (C::*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = (instance->*mp)(ARG(mrb, 0), ARG(mrb, 1), ARG(mrb, 2), ARG(mrb, 3), ARG(mrb, 4), ARG(mrb, 5), ARG(mrb, 6), ARG(mrb, 7), ARG(mrb, 8), ARG(mrb, 9), ARG(mrb, 10), ARG(mrb, 11), ARG(mrb, 12), ARG(mrb, 13), ARG(mrb, 14), ARG(mrb, 15), ARG(mrb, 16));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct CustomClassBinder<void (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13); CHECKSHIFT(15, 14); CHECKSHIFT(16, 15);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13), ARGSHIFT(mrb, 15, 14), ARGSHIFT(mrb, 16, 15));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct CustomClassBinder<R (*)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13); CHECKSHIFT(15, 14); CHECKSHIFT(16, 15);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13), ARGSHIFT(mrb, 15, 14), ARGSHIFT(mrb, 16, 15));
return Type<R>::ret(mrb, result);
}
};
// custom method
template<class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct CustomClassBinder<void (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13); CHECKSHIFT(15, 14); CHECKSHIFT(16, 15);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef void (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
M mp = *(M*)RSTRING_PTR(cmethod);
mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13), ARGSHIFT(mrb, 15, 14), ARGSHIFT(mrb, 16, 15));
return mrb_nil_value();
}
};
template<class R, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12, class P13, class P14, class P15, class P16>
struct CustomClassBinder<R (*)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16)> {
static const int NPARAM = 17 - 1;
static mrb_value call(mrb_state* mrb, mrb_value self) {
mrb_value* targs;
int narg;
mrb_value block = mrb_nil_value();
std::vector<mrb_value> args;
mrb_get_args(mrb, "*|&", &targs, &narg, &block);
args.resize(narg);
if(narg > 0){
::memmove(&args[0], &targs[0], narg * sizeof(mrb_value));
}
if(mrb_test(block)){
args.push_back(block);
narg++;
}
CHECKNARG(narg); CHECKSHIFT(1, 0); CHECKSHIFT(2, 1); CHECKSHIFT(3, 2); CHECKSHIFT(4, 3); CHECKSHIFT(5, 4); CHECKSHIFT(6, 5); CHECKSHIFT(7, 6); CHECKSHIFT(8, 7); CHECKSHIFT(9, 8); CHECKSHIFT(10, 9); CHECKSHIFT(11, 10); CHECKSHIFT(12, 11); CHECKSHIFT(13, 12); CHECKSHIFT(14, 13); CHECKSHIFT(15, 14); CHECKSHIFT(16, 15);
P0* instance = static_cast<P0*>(DATA_PTR(self));
mrb_value cmethod = mrb_cfunc_env_get(mrb, 0);
typedef R (*M)(P0&, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16);
M mp = *(M*)RSTRING_PTR(cmethod);
R result = mp(*instance, ARGSHIFT(mrb, 1, 0), ARGSHIFT(mrb, 2, 1), ARGSHIFT(mrb, 3, 2), ARGSHIFT(mrb, 4, 3), ARGSHIFT(mrb, 5, 4), ARGSHIFT(mrb, 6, 5), ARGSHIFT(mrb, 7, 6), ARGSHIFT(mrb, 8, 7), ARGSHIFT(mrb, 9, 8), ARGSHIFT(mrb, 10, 9), ARGSHIFT(mrb, 11, 10), ARGSHIFT(mrb, 12, 11), ARGSHIFT(mrb, 13, 12), ARGSHIFT(mrb, 14, 13), ARGSHIFT(mrb, 15, 14), ARGSHIFT(mrb, 16, 15));
return Type<R>::ret(mrb, result);
}
};
#undef ARG
#undef CHECK
} // namespace mrubybind
namespace mrubybind {
//===========================================================================
// MrubyBind - utility class for binding C functions/classes to mruby.
class MrubyBind {
public:
MrubyBind(mrb_state* mrb);
MrubyBind(mrb_state* mrb, RClass* mod);
~MrubyBind();
// Bind constant value.
template <class T>
void bind_const(const char* name, T v) {
MrubyArenaStore store(mrb_);
mrb_define_const(mrb_, mod_, name, Type<T>::ret(mrb_, v));
}
template <class T>
void bind_const(const char* module_name, const char* class_name, const char* name, T v) {
MrubyArenaStore store(mrb_);
struct RClass * tc = DefineClass(module_name, class_name);
mrb_define_const(mrb_, tc, name, Type<T>::ret(mrb_, v));
}
// Bind function.
template <class Func>
void bind(const char* func_name, Func func_ptr) {
MrubyArenaStore store(mrb_);
mrb_sym func_name_s = mrb_intern_cstr(mrb_, func_name);
mrb_value env[] = {
mrb_cptr_value(mrb_, (void*)func_ptr), // 0: c function pointer
mrb_symbol_value(func_name_s), // 1: function name
};
struct RProc* proc = mrb_proc_new_cfunc_with_env(mrb_, Binder<Func>::call, 2, env);
mrb_field_write_barrier(mrb_, (RBasic *)proc, (RBasic *)proc->e.env);
mrb_method_t m;
MRB_METHOD_FROM_PROC(m, proc);
if (mod_ == mrb_->kernel_module)
mrb_define_method_raw(mrb_, mod_, func_name_s, m);
else
mrb_define_class_method_raw(mrb_, mod_, func_name_s, proc);
}
// Bind class.
template <class Func>
void bind_class(const char* class_name, Func new_func_ptr) {
MrubyArenaStore store(mrb_);
struct RClass *tc = mrb_define_class(mrb_, class_name, mrb_->object_class);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
BindInstanceMethod(class_name, "initialize",
mrb_cptr_value(mrb_, (void*)new_func_ptr),
ClassBinder<Func>::ctor);
}
// Bind class.(no new func)
template <class C>
void bind_class(const char* module_name, const char* class_name) {
MrubyArenaStore store(mrb_);
struct RClass * tc = DefineClass(module_name, class_name);
std::string name;
if(module_name){
name += module_name;
name += "::";
}
name += class_name;
Type<C>::class_name = name;
Type<C&>::class_name = name;
MrubyBindStatus::search(mrb_)->set_class_conversion(name, name, true);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
BindInstanceMethod(module_name, class_name, "initialize",
mrb_cptr_value(mrb_, NULL),
ClassBinder<C*(*)(void)>::ctor);
}
template <class C>
void bind_class(const char* class_name) {
bind_class<C>(NULL, class_name);
}
// Bind instance method.
template <class Method>
void bind_instance_method(const char* class_name, const char* method_name,
Method method_ptr) {
MrubyArenaStore store(mrb_);
mrb_value method_pptr_v = mrb_str_new(mrb_,
reinterpret_cast<char*>(&method_ptr),
sizeof(method_ptr));
BindInstanceMethod(class_name, method_name,
method_pptr_v, ClassBinder<Method>::call);
}
// Bind static method.
template <class Method>
void bind_static_method(const char* module_name, const char* class_name, const char* method_name,
Method method_ptr) {
MrubyArenaStore store(mrb_);
mrb_sym method_name_s = mrb_intern_cstr(mrb_, method_name);
mrb_value env[] = {
mrb_cptr_value(mrb_, (void*)method_ptr), // 0: method pointer
mrb_symbol_value(method_name_s), // 1: method name
};
struct RProc* proc = mrb_proc_new_cfunc_with_env(mrb_, Binder<Method>::call, 2, env);
mrb_field_write_barrier(mrb_, (RBasic *)proc, (RBasic *)proc->e.env);
struct RClass* klass = GetClass(module_name, class_name);
mrb_define_class_method_raw(mrb_, klass, method_name_s, proc);
}
template <class Method>
void bind_static_method(const char* class_name, const char* method_name,
Method method_ptr) {
bind_static_method(NULL, class_name, method_name,
method_ptr);
}
// Bind custom method.
template <class Func>
void bind_custom_method(const char* module_name, const char* class_name, const char* method_name, Func func_ptr) {
MrubyArenaStore store(mrb_);
mrb_value (*binder_func)(mrb_state*, mrb_value) = CustomClassBinder<Func>::call;
mrb_value original_func_v = mrb_str_new(mrb_,
reinterpret_cast<char*>(&func_ptr),
sizeof(func_ptr));
mrb_sym method_name_s = mrb_intern_cstr(mrb_, method_name);
mrb_value env[] = {
original_func_v, // 0: c function pointer
mrb_symbol_value(method_name_s), // 1: method name
};
struct RProc* proc = mrb_proc_new_cfunc_with_env(mrb_, binder_func, 2, env);
mrb_field_write_barrier(mrb_, (RBasic *)proc, (RBasic *)proc->e.env);
mrb_method_t m;
MRB_METHOD_FROM_PROC(m, proc);
struct RClass* klass = GetClass(module_name, class_name);
mrb_define_method_raw(mrb_, klass, method_name_s, m);
}
template <class Func>
void bind_custom_method(const char* class_name, const char* method_name, Func func_ptr) {
bind_custom_method(NULL, class_name, method_name, func_ptr);
}
//add convertable class pair
void add_convertable(const char* class_name_first, const char* class_name_second)
{
MrubyBindStatus::search(mrb_)->set_class_conversion(class_name_first, class_name_second, true);
MrubyBindStatus::search(mrb_)->set_class_conversion(class_name_second, class_name_first, true);
}
mrb_state* get_mrb(){
return mrb_;
}
mrb_value get_avoid_gc_table(){
return avoid_gc_table_;
}
private:
void Initialize();
// Returns mruby class under a module.
std::vector<std::string> SplitModule(const char* module_name);
struct RClass* DefineModule(const char* module_name);
struct RClass* DefineClass(const char* module_name, const char* class_name);
struct RClass* GetClass(const char* class_name);
struct RClass* GetClass(const char* module_name, const char* class_name);
// Utility for binding instance method.
void BindInstanceMethod(const char* class_name, const char* method_name,
mrb_value original_func_v,
mrb_value (*binder_func)(mrb_state*, mrb_value));
void BindInstanceMethod(const char* module_name,
const char* class_name, const char* method_name,
mrb_value original_func_v,
mrb_value (*binder_func)(mrb_state*, mrb_value));
// Mimic mruby API.
// TODO: Send pull request to the official mruby repository.
void
mrb_define_class_method_raw(mrb_state *mrb, struct RClass *c, mrb_sym mid, struct RProc *p);
static mrb_value mrb_get_untouchable_table( mrb_state* mrb, mrb_value self );
static mrb_value mrb_get_untouchable_object( mrb_state* mrb, mrb_value self );
mrb_state* mrb_;
RClass* mod_;
mrb_value avoid_gc_table_;
int arena_index_;
};
MrubyRef load_string(mrb_state* mrb, std::string code);
} // namespace mrubybind
#endif
| 40.419804 | 379 | 0.589079 | [
"vector"
] |
7231c51b08c27a15f2d28901d1157c2100c1be2c | 1,654 | h | C | Othuum/AhwassaGraphicsLib/PostProcessing/PostProcessingEffect.h | Liech/Yathsou | 95b6dda3c053bc25789cce416088e22f54a743b4 | [
"MIT"
] | 5 | 2021-04-20T17:00:41.000Z | 2022-01-18T20:16:03.000Z | Othuum/AhwassaGraphicsLib/PostProcessing/PostProcessingEffect.h | Liech/Yathsou | 95b6dda3c053bc25789cce416088e22f54a743b4 | [
"MIT"
] | 7 | 2021-08-22T21:30:50.000Z | 2022-01-14T16:56:34.000Z | Othuum/AhwassaGraphicsLib/PostProcessing/PostProcessingEffect.h | Liech/Yathsou | 95b6dda3c053bc25789cce416088e22f54a743b4 | [
"MIT"
] | null | null | null | #pragma once
#include <memory>
#include "AhwassaGraphicsLib/BufferObjects/VBO.h"
#include "AhwassaGraphicsLib/Vertex/PositionTextureVertex.h"
namespace Ahwassa {
class Window;
class Texture;
class Rendertarget;
class VAO;
class ShaderProgram;
class UniformMat4;
class Uniform;
class PostProcessingEffect {
public:
PostProcessingEffect(std::string name, Ahwassa::Window* w, int width, int height);
std::shared_ptr<Ahwassa::Texture> getResult();
void drawResult();
protected:
virtual void start();
void end();
int getWidth();
int getHeight();
Ahwassa::Window* getWindow();
std::vector<Ahwassa::Uniform*> getUniforms();
bool enabled();
void setEnabled(bool);
private:
std::unique_ptr<Ahwassa::VBO<Ahwassa::PositionTextureVertex>> _vbo ;
std::unique_ptr<Ahwassa::VAO> _vao ;
std::shared_ptr<Ahwassa::Rendertarget> _result ;
std::shared_ptr<Ahwassa::ShaderProgram> _shader ;
std::unique_ptr<Ahwassa::UniformMat4> _projection;
std::vector<Ahwassa::PositionTextureVertex> _vertices ;
std::string _name;
int _width ;
int _height;
Ahwassa::Window* _window;
bool _enabled = true;
};
} | 33.08 | 88 | 0.506651 | [
"vector"
] |
72352f6a228072f21e6ec6cab397fff0b1faf0ac | 3,086 | h | C | graphics/cgal/Mesh_3/doc/Mesh_3/Concepts/MeshVertexBase_3.h | hlzz/dotfiles | 0591f71230c919c827ba569099eb3b75897e163e | [
"BSD-3-Clause"
] | 4 | 2016-03-30T14:31:52.000Z | 2019-02-02T05:01:32.000Z | graphics/cgal/Mesh_3/doc/Mesh_3/Concepts/MeshVertexBase_3.h | hlzz/dotfiles | 0591f71230c919c827ba569099eb3b75897e163e | [
"BSD-3-Clause"
] | null | null | null | graphics/cgal/Mesh_3/doc/Mesh_3/Concepts/MeshVertexBase_3.h | hlzz/dotfiles | 0591f71230c919c827ba569099eb3b75897e163e | [
"BSD-3-Clause"
] | null | null | null | /*!
\ingroup PkgMesh_3SecondaryConcepts
\cgalConcept
The concept `MeshVertexBase_3` describes the requirements
for the `Vertex` type of the triangulation
used by a 3D mesh generation process. The type `MeshVertexBase_3` refines both the concept `TriangulationVertexBase_3`
and
the concept `SurfaceMeshVertexBase_3`.
It provides additional members to store and retrieve
information about the location of the vertex with respect
to the input domain describing the domain to be discretized.
More specifically, the concept `MeshVertexBase_3` provides read-write access
to an integer representing the dimension of the lowest dimensional face
of the input 3D complex on which the vertex lies,
and to an index characteristic of this face.
The concept `MeshVertexBase_3` provides storage and read-write access to a boolean, a `FT` value,
and two `Vertex_handle` called 'intrusive'.
The parallel algorithms require an erase counter in
each cell (see below).
\cgalRefines `TriangulationVertexBase_3`
\cgalRefines `SurfaceMeshVertexBase_3`
\cgalHasModel `CGAL::Mesh_vertex_base_3<Gt,MD,Vb>`
\sa `CGAL::make_mesh_3()`
\sa `CGAL::refine_mesh_3()`
\sa `MeshDomain_3`
*/
class MeshVertexBase_3 {
public:
/// \name Types
/// @{
/*!
Index type. Must match the type `MeshDomain_3::Index`.
*/
typedef unspecified_type Index;
/*!
Numerical type.
*/
typedef unspecified_type FT;
/// @}
/// \name Operations
/// @{
/*!
Returns the dimension of the lowest dimensional face of the input 3D complex that contains the vertex.
*/
int in_dimension() const;
/*!
Sets the dimension of the lowest dimensional face of the input 3D complex that contains the vertex.
*/
void set_dimension(int);
/*!
Returns the index of the lowest dimensional face of the input 3D complex that contains the vertex.
*/
Index index();
/*!
Sets the index of the lowest dimensional face of the input 3D complex that contains the vertex.
*/
void set_index(Index);
/// @}
/*! \name Internal
These functions are used internally. The user is
not encouraged to use them directly as they may change in the future.
*/
/// @{
/*!
Returns a boolean, used for feature edges protection.
*/
bool is_special();
/*!
Sets the special aspect of the vertex.
*/
void set_special(bool);
/*!
*/
FT meshing_info() const;
/*!
*/
void set_meshing_info(FT);
/*!
*/
Vertex_handle next_intrusive() const;
/*!
*/
void set_next_intrusive(Vertex_handle);
/*!
*/
Vertex_handle previous_intrusive() const;
/*!
*/
void set_previous_intrusive(Vertex_handle);
/// Get the erase counter.
/// Only required by the parallel algorithms.
/// See `CGAL::Compact_container` for more details.
unsigned int erase_counter() const;
/// Sets the erase counter.
/// Only required by the parallel algorithms.
/// See `CGAL::Compact_container` for more details.
void set_erase_counter(unsigned int c);
/// Increments the erase counter.
/// Only required by the parallel algorithms.
/// See `CGAL::Compact_container` for more details.
void increment_erase_counter();
/// @}
}; /* end MeshVertexBase_3 */
| 22.042857 | 119 | 0.738496 | [
"mesh",
"3d"
] |
724449436fc576a5e0118a3c8153354ab3ecd039 | 6,749 | h | C | include/shadertrans/SpirvGenTwo.h | xzrunner/shadertrans | c7480da714b08541cf8de655452fd54725880395 | [
"MIT"
] | 1 | 2021-06-27T22:40:11.000Z | 2021-06-27T22:40:11.000Z | include/shadertrans/SpirvGenTwo.h | xzrunner/shadertrans | c7480da714b08541cf8de655452fd54725880395 | [
"MIT"
] | null | null | null | include/shadertrans/SpirvGenTwo.h | xzrunner/shadertrans | c7480da714b08541cf8de655452fd54725880395 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include <string>
namespace spvgentwo {
class Module;
class Function;
class BasicBlock;
class Instruction;
}
namespace shadertrans
{
class SpirvGenTwo
{
public:
// info
static const char* GetType(const spvgentwo::Instruction& inst);
static bool IsVector(const spvgentwo::Instruction& inst);
static int GetVectorNum(const spvgentwo::Instruction& inst);
// block
static spvgentwo::BasicBlock* GetFuncBlock(spvgentwo::Function* func);
// inst
static spvgentwo::BasicBlock* If(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* cond,
spvgentwo::BasicBlock* bb_true, spvgentwo::BasicBlock* bb_false, spvgentwo::BasicBlock* bb_merge);
static spvgentwo::Instruction* VariableFloat(spvgentwo::Function* func, const char* name = nullptr);
static spvgentwo::Instruction* VariableFloat2(spvgentwo::Function* func, const char* name = nullptr);
static spvgentwo::Instruction* VariableFloat3(spvgentwo::Function* func, const char* name = nullptr);
static spvgentwo::Instruction* VariableFloat4(spvgentwo::Function* func, const char* name = nullptr);
static spvgentwo::BasicBlock* AddBlock(spvgentwo::Function* func, const char* name);
static spvgentwo::Instruction* AddVariable(spvgentwo::Function* func, const char* name, spvgentwo::Instruction* value);
static spvgentwo::Instruction* ConstBool(spvgentwo::Module* module, bool b);
static spvgentwo::Instruction* ConstInt(spvgentwo::Module* module, int x);
static spvgentwo::Instruction* ConstFloat(spvgentwo::Module* module, float x);
static spvgentwo::Instruction* ConstFloat2(spvgentwo::Module* module, float x, float y);
static spvgentwo::Instruction* ConstFloat3(spvgentwo::Module* module, float x, float y, float z);
static spvgentwo::Instruction* ConstFloat4(spvgentwo::Module* module, float x, float y, float z, float w);
static spvgentwo::Instruction* ConstMatrix2(spvgentwo::Module* module, const float m[4]);
static spvgentwo::Instruction* ConstMatrix3(spvgentwo::Module* module, const float m[9]);
static spvgentwo::Instruction* ConstMatrix4(spvgentwo::Module* module, const float m[16]);
// bb
static spvgentwo::Instruction* AccessChain(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* base, unsigned int index);
static spvgentwo::Instruction* ComposeFloat2(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* x, spvgentwo::Instruction* y);
static spvgentwo::Instruction* ComposeFloat3(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* x, spvgentwo::Instruction* y, spvgentwo::Instruction* z);
static spvgentwo::Instruction* ComposeFloat4(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* x, spvgentwo::Instruction* y, spvgentwo::Instruction* z, spvgentwo::Instruction* w);
static spvgentwo::Instruction* ComposeExtract(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* comp, unsigned int index);
static spvgentwo::Instruction* Dot(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* Cross(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* Add(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* Sub(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* Mul(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* Div(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* Negate(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* v);
static spvgentwo::Instruction* Reflect(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* I, spvgentwo::Instruction* N);
static spvgentwo::Instruction* Sqrt(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* v);
static spvgentwo::Instruction* Pow(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* x, spvgentwo::Instruction* y);
static spvgentwo::Instruction* Normalize(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* v);
static spvgentwo::Instruction* Length(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* v);
static spvgentwo::Instruction* Max(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* Min(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* Clamp(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* x, spvgentwo::Instruction* min, spvgentwo::Instruction* max);
static spvgentwo::Instruction* Mix(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* x, spvgentwo::Instruction* y, spvgentwo::Instruction* a);
static spvgentwo::Instruction* IsEqual(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* IsNotEqual(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* IsGreater(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* IsGreaterEqual(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* IsLess(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static spvgentwo::Instruction* IsLessEqual(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* a, spvgentwo::Instruction* b);
static void Kill(spvgentwo::BasicBlock* bb);
static void Return(spvgentwo::BasicBlock* bb);
static void ReturnValue(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* inst);
static spvgentwo::Instruction* Load(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* var);
static void Store(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* dst, spvgentwo::Instruction* src);
static spvgentwo::Instruction* ImageSample(spvgentwo::BasicBlock* bb, spvgentwo::Instruction* img, spvgentwo::Instruction* uv, spvgentwo::Instruction* lod);
// func
static spvgentwo::Function* QueryFunction(spvgentwo::Module& lib, const std::string& name);
static spvgentwo::Function* CreateDeclFunc(spvgentwo::Module* module, spvgentwo::Function* func);
static spvgentwo::Function* CreateFunc(spvgentwo::Module* module, const std::string& name,
const std::string& ret, const std::vector<std::string>& args);
static spvgentwo::Instruction* GetFuncParam(spvgentwo::Function* func, int index);
static void GetFuncParamNames(spvgentwo::Function* func, std::vector<std::string>& names);
static spvgentwo::Instruction* FuncCall(spvgentwo::Function* caller, spvgentwo::Function* callee, const std::vector<spvgentwo::Instruction*>& params);
// tools
static void Print(spvgentwo::Module& module);
}; // SpirvGenTwo
} | 59.725664 | 181 | 0.777893 | [
"vector"
] |
724cd004c1b42e815fd52155399fae02106ccf80 | 31,710 | h | C | Tools/WebKitTestRunner/TestController.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | 6 | 2021-07-05T16:09:39.000Z | 2022-03-06T22:44:42.000Z | Tools/WebKitTestRunner/TestController.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | 7 | 2022-03-15T13:25:39.000Z | 2022-03-15T13:25:44.000Z | Tools/WebKitTestRunner/TestController.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (C) 2010-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "GeolocationProviderMock.h"
#include "TestOptions.h"
#include "WebNotificationProvider.h"
#include "WorkQueueManager.h"
#include <WebKit/WKRetainPtr.h>
#include <set>
#include <string>
#include <vector>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/Seconds.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
#if PLATFORM(COCOA)
#include "ClassMethodSwizzler.h"
#include "InstanceMethodSwizzler.h"
#endif
OBJC_CLASS NSString;
OBJC_CLASS UIKeyboardInputMode;
OBJC_CLASS WKWebViewConfiguration;
namespace WTR {
class TestInvocation;
class OriginSettings;
class PlatformWebView;
class EventSenderProxy;
struct TestCommand;
struct TestOptions;
class AsyncTask {
public:
AsyncTask(WTF::Function<void ()>&& task, WTF::Seconds timeout)
: m_task(WTFMove(task))
, m_timeout(timeout)
{
ASSERT(!currentTask());
}
// Returns false on timeout.
bool run();
void taskComplete()
{
m_taskDone = true;
}
static AsyncTask* currentTask();
private:
static AsyncTask* m_currentTask;
WTF::Function<void ()> m_task;
WTF::Seconds m_timeout;
bool m_taskDone { false };
};
// FIXME: Rename this TestRunner?
class TestController {
public:
static TestController& singleton();
static void configureWebsiteDataStoreTemporaryDirectories(WKWebsiteDataStoreConfigurationRef);
static WKWebsiteDataStoreRef defaultWebsiteDataStore();
static const unsigned viewWidth;
static const unsigned viewHeight;
static const unsigned w3cSVGViewWidth;
static const unsigned w3cSVGViewHeight;
static const WTF::Seconds defaultShortTimeout;
static const WTF::Seconds noTimeout;
TestController(int argc, const char* argv[]);
~TestController();
bool verbose() const { return m_verbose; }
WKStringRef injectedBundlePath() const { return m_injectedBundlePath.get(); }
WKStringRef testPluginDirectory() const { return m_testPluginDirectory.get(); }
PlatformWebView* mainWebView() { return m_mainWebView.get(); }
WKContextRef context() { return m_context.get(); }
WKUserContentControllerRef userContentController() { return m_userContentController.get(); }
WKWebsiteDataStoreRef websiteDataStore();
EventSenderProxy* eventSenderProxy() { return m_eventSenderProxy.get(); }
bool shouldUseRemoteLayerTree() const { return m_shouldUseRemoteLayerTree; }
// Runs the run loop until `done` is true or the timeout elapses.
bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; }
void runUntil(bool& done, WTF::Seconds timeout);
void notifyDone();
bool shouldShowWebView() const { return m_shouldShowWebView; }
bool usingServerMode() const { return m_usingServerMode; }
void configureViewForTest(const TestInvocation&);
bool shouldShowTouches() const { return m_shouldShowTouches; }
bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue; }
void setBeforeUnloadReturnValue(bool value) { m_beforeUnloadReturnValue = value; }
void simulateWebNotificationClick(uint64_t notificationID);
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
bool accessibilityIsolatedTreeMode() const { return m_accessibilityIsolatedTreeMode; }
#endif
// Geolocation.
void setGeolocationPermission(bool);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel);
void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef);
bool isGeolocationProviderActive() const;
// MediaStream.
String saltForOrigin(WKFrameRef, String);
void getUserMediaInfoForOrigin(WKFrameRef, WKStringRef originKey, bool&, WKRetainPtr<WKStringRef>&);
WKStringRef getUserMediaSaltForOrigin(WKFrameRef, WKStringRef originKey);
void setUserMediaPermission(bool);
void resetUserMediaPermission();
void setUserMediaPersistentPermissionForOrigin(bool, WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
void handleUserMediaPermissionRequest(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, WKUserMediaPermissionRequestRef);
void handleCheckOfUserMediaPermissionForOrigin(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, const WKUserMediaPermissionCheckRef&);
OriginSettings& settingsForOrigin(const String&);
unsigned userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
// Device Orientation / Motion.
bool handleDeviceOrientationAndMotionAccessRequest(WKSecurityOriginRef);
// Content Extensions.
void configureContentExtensionForTest(const TestInvocation&);
void resetContentExtensions();
// Policy delegate.
void setCustomPolicyDelegate(bool enabled, bool permissive);
// Page Visibility.
void setHidden(bool);
unsigned imageCountInGeneralPasteboard() const;
enum class ResetStage { BeforeTest, AfterTest };
bool resetStateToConsistentValues(const TestOptions&, ResetStage);
void resetPreferencesToConsistentValues(const TestOptions&);
void willDestroyWebView();
void terminateWebContentProcess();
void reattachPageToWebProcess();
static const char* webProcessName();
static const char* networkProcessName();
static const char* databaseProcessName();
WorkQueueManager& workQueueManager() { return m_workQueueManager; }
void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool value) { m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges = value; }
void setHandlesAuthenticationChallenges(bool value) { m_handlesAuthenticationChallenges = value; }
void setAuthenticationUsername(String username) { m_authenticationUsername = username; }
void setAuthenticationPassword(String password) { m_authenticationPassword = password; }
void setAllowsAnySSLCertificate(bool);
void setShouldSwapToEphemeralSessionOnNextNavigation(bool value) { m_shouldSwapToEphemeralSessionOnNextNavigation = value; }
void setShouldSwapToDefaultSessionOnNextNavigation(bool value) { m_shouldSwapToDefaultSessionOnNextNavigation = value; }
void setBlockAllPlugins(bool shouldBlock);
void setPluginSupportedMode(const String&);
void setShouldLogHistoryClientCallbacks(bool shouldLog) { m_shouldLogHistoryClientCallbacks = shouldLog; }
void setShouldLogCanAuthenticateAgainstProtectionSpace(bool shouldLog) { m_shouldLogCanAuthenticateAgainstProtectionSpace = shouldLog; }
void setShouldLogDownloadCallbacks(bool shouldLog) { m_shouldLogDownloadCallbacks = shouldLog; }
bool isCurrentInvocation(TestInvocation* invocation) const { return invocation == m_currentInvocation.get(); }
void setShouldDecideNavigationPolicyAfterDelay(bool value) { m_shouldDecideNavigationPolicyAfterDelay = value; }
void setShouldDecideResponsePolicyAfterDelay(bool value) { m_shouldDecideResponsePolicyAfterDelay = value; }
void setNavigationGesturesEnabled(bool value);
void setIgnoresViewportScaleLimits(bool);
void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; }
void setShouldAllowDeviceOrientationAndMotionAccess(bool value) { m_shouldAllowDeviceOrientationAndMotionAccess = value; }
void clearStatisticsDataForDomain(WKStringRef domain);
bool doesStatisticsDomainIDExistInDatabase(unsigned domainID);
void setStatisticsEnabled(bool value);
bool isStatisticsEphemeral();
void setStatisticsDebugMode(bool value);
void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName);
void setStatisticsLastSeen(WKStringRef hostName, double seconds);
void setStatisticsMergeStatistic(WKStringRef host, WKStringRef topFrameDomain1, WKStringRef topFrameDomain2, double lastSeen, bool hadUserInteraction, double mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, int dataRecordsRemoved);
void setStatisticsExpiredStatistic(WKStringRef host, bool hadUserInteraction, bool isScheduledForAllButCookieDataRemoval, bool isPrevalent);
void setStatisticsPrevalentResource(WKStringRef hostName, bool value);
void setStatisticsVeryPrevalentResource(WKStringRef hostName, bool value);
String dumpResourceLoadStatistics();
bool isStatisticsPrevalentResource(WKStringRef hostName);
bool isStatisticsVeryPrevalentResource(WKStringRef hostName);
bool isStatisticsRegisteredAsSubresourceUnder(WKStringRef subresourceHost, WKStringRef topFrameHost);
bool isStatisticsRegisteredAsSubFrameUnder(WKStringRef subFrameHost, WKStringRef topFrameHost);
bool isStatisticsRegisteredAsRedirectingTo(WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo);
void setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value);
bool isStatisticsHasHadUserInteraction(WKStringRef hostName);
bool isStatisticsOnlyInDatabaseOnce(WKStringRef subHost, WKStringRef topHost);
void setStatisticsGrandfathered(WKStringRef hostName, bool value);
bool isStatisticsGrandfathered(WKStringRef hostName);
void setUseITPDatabase(bool value);
void setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
void setStatisticsSubresourceUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom);
void setStatisticsTopFrameUniqueRedirectTo(WKStringRef host, WKStringRef hostRedirectedTo);
void setStatisticsTopFrameUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom);
void setStatisticsCrossSiteLoadWithLinkDecoration(WKStringRef fromHost, WKStringRef toHost);
void setStatisticsTimeToLiveUserInteraction(double seconds);
void statisticsProcessStatisticsAndDataRecords();
void statisticsUpdateCookieBlocking();
void statisticsSubmitTelemetry();
void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
void setStatisticsIsRunningTest(bool);
void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double);
void setStatisticsGrandfatheringTime(double seconds);
void setStatisticsMaxStatisticsEntries(unsigned);
void setStatisticsPruneEntriesDownTo(unsigned);
void statisticsClearInMemoryAndPersistentStore();
void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned);
void statisticsClearThroughWebsiteDataRemoval();
void statisticsDeleteCookiesForHost(WKStringRef host, bool includeHttpOnlyCookies);
bool isStatisticsHasLocalStorage(WKStringRef hostName);
void setStatisticsCacheMaxAgeCap(double seconds);
bool hasStatisticsIsolatedSession(WKStringRef hostName);
void setStatisticsShouldDowngradeReferrer(bool value);
void setStatisticsShouldBlockThirdPartyCookies(bool value, bool onlyOnSitesWithoutUserInteraction);
void setStatisticsFirstPartyWebsiteDataRemovalMode(bool value);
void setStatisticsToSameSiteStrictCookies(WKStringRef hostName);
void setStatisticsFirstPartyHostCNAMEDomain(WKStringRef firstPartyURLString, WKStringRef cnameURLString);
void setStatisticsThirdPartyCNAMEDomain(WKStringRef cnameURLString);
void setAppBoundDomains(WKArrayRef originURLs);
void statisticsResetToConsistentState();
void getAllStorageAccessEntries();
void loadedThirdPartyDomains();
void clearLoadedThirdPartyDomains();
void clearAppBoundSession();
void reinitializeAppBoundDomains();
void updateBundleIdentifierInNetworkProcess(const String& bundleIdentifier);
void clearBundleIdentifierInNetworkProcess();
WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; }
#if PLATFORM(IOS_FAMILY)
WKDataRef openPanelFileURLsMediaIcon() const { return m_openPanelFileURLsMediaIcon.get(); }
void setOpenPanelFileURLsMediaIcon(WKDataRef mediaIcon) { m_openPanelFileURLsMediaIcon = mediaIcon; }
#endif
void terminateNetworkProcess();
void terminateServiceWorkers();
void resetQuota();
void removeAllSessionCredentials();
void clearIndexedDatabases();
void clearLocalStorage();
void syncLocalStorage();
void clearServiceWorkerRegistrations();
void clearDOMCache(WKStringRef origin);
void clearDOMCaches();
bool hasDOMCache(WKStringRef origin);
uint64_t domCacheSize(WKStringRef origin);
void setAllowStorageQuotaIncrease(bool);
bool didReceiveServerRedirectForProvisionalNavigation() const { return m_didReceiveServerRedirectForProvisionalNavigation; }
void clearDidReceiveServerRedirectForProvisionalNavigation() { m_didReceiveServerRedirectForProvisionalNavigation = false; }
void addMockMediaDevice(WKStringRef persistentID, WKStringRef label, WKStringRef type);
void clearMockMediaDevices();
void removeMockMediaDevice(WKStringRef persistentID);
void resetMockMediaDevices();
void setMockCameraOrientation(uint64_t);
bool isMockRealtimeMediaSourceCenterEnabled() const;
bool hasAppBoundSession();
void injectUserScript(WKStringRef);
void sendDisplayConfigurationChangedMessageForTesting();
void setServiceWorkerFetchTimeoutForTesting(double seconds);
void addTestKeyToKeychain(const String& privateKeyBase64, const String& attrLabel, const String& applicationTagBase64);
void cleanUpKeychain(const String& attrLabel, const String& applicationLabelBase64);
bool keyExistsInKeychain(const String& attrLabel, const String& applicationLabelBase64);
#if PLATFORM(COCOA)
NSString *overriddenCalendarIdentifier() const;
NSString *overriddenCalendarLocaleIdentifier() const;
void setDefaultCalendarType(NSString *identifier, NSString *localeIdentifier);
#endif // PLATFORM(COCOA)
#if PLATFORM(IOS_FAMILY)
void setKeyboardInputModeIdentifier(const String&);
UIKeyboardInputMode *overriddenKeyboardInputMode() const { return m_overriddenKeyboardInputMode.get(); }
#endif
void setAllowedMenuActions(const Vector<String>&);
void installCustomMenuAction(const String& name, bool dismissesAutomatically);
uint64_t serverTrustEvaluationCallbackCallsCount() const { return m_serverTrustEvaluationCallbackCallsCount; }
void setShouldDismissJavaScriptAlertsAsynchronously(bool);
void handleJavaScriptAlert(WKPageRunJavaScriptAlertResultListenerRef);
void abortModal();
bool isDoingMediaCapture() const;
String dumpAdClickAttribution();
void clearAdClickAttribution();
void clearAdClickAttributionsThroughWebsiteDataRemoval();
void setAdClickAttributionOverrideTimerForTesting(bool value);
void setAdClickAttributionConversionURLForTesting(WKURLRef);
void markAdClickAttributionsAsExpiredForTesting();
void didSetAppBoundDomains() const;
private:
WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(const TestOptions&);
WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration(const TestOptions::ContextOptions&) const;
void initialize(int argc, const char* argv[]);
void createWebViewWithOptions(const TestOptions&);
void run();
void runTestingServerLoop();
bool runTest(const char* pathOrURL);
// Returns false if timed out.
bool waitForCompletion(const WTF::Function<void ()>&, WTF::Seconds timeout);
bool handleControlCommand(const char* command);
void platformInitialize();
void platformInitializeDataStore(WKPageConfigurationRef, const TestOptions&);
void platformDestroy();
WKContextRef platformAdjustContext(WKContextRef, WKContextConfigurationRef);
void platformInitializeContext();
void platformAddTestOptions(TestOptions&) const;
void platformCreateWebView(WKPageConfigurationRef, const TestOptions&);
static PlatformWebView* platformCreateOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, const TestOptions&);
void platformResetPreferencesToConsistentValues();
// Returns false if the reset timed out.
bool platformResetStateToConsistentValues(const TestOptions&);
#if PLATFORM(COCOA)
void cocoaPlatformInitialize();
void cocoaResetStateToConsistentValues(const TestOptions&);
void setApplicationBundleIdentifier(const String&);
void clearApplicationBundleIdentifierTestingOverride();
#endif
void platformConfigureViewForTest(const TestInvocation&);
void platformWillRunTest(const TestInvocation&);
void platformRunUntil(bool& done, WTF::Seconds timeout);
void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef);
WKContextRef platformContext();
WKPreferencesRef platformPreferences();
void initializeInjectedBundlePath();
void initializeTestPluginDirectory();
void ensureViewSupportsOptionsForTest(const TestInvocation&);
TestOptions testOptionsForTest(const TestCommand&) const;
void updatePlatformSpecificTestOptionsForTest(TestOptions&, const std::string& pathOrURL) const;
void updateWebViewSizeForTest(const TestInvocation&);
void updateWindowScaleForTest(PlatformWebView*, const TestInvocation&);
void updateLiveDocumentsAfterTest();
void checkForWorldLeaks();
void didReceiveLiveDocumentsList(WKArrayRef);
void dumpResponse(const String&);
void findAndDumpWebKitProcessIdentifiers();
void findAndDumpWorldLeaks();
void decidePolicyForGeolocationPermissionRequestIfPossible();
void decidePolicyForUserMediaPermissionRequestIfPossible();
// WKContextInjectedBundleClient
static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*);
static void didReceiveSynchronousMessageFromInjectedBundleWithListener(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, WKMessageListenerRef, const void*);
static WKTypeRef getInjectedBundleInitializationUserData(WKContextRef, const void *clientInfo);
// WKPageInjectedBundleClient
static void didReceivePageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef messageBody, const void*);
static void didReceiveSynchronousPageMessageFromInjectedBundleWithListener(WKPageRef, WKStringRef messageName, WKTypeRef messageBody, WKMessageListenerRef, const void*);
void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
void didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody, WKMessageListenerRef);
WKRetainPtr<WKTypeRef> getInjectedBundleInitializationUserData();
void didReceiveKeyDownMessageFromInjectedBundle(WKDictionaryRef messageBodyDictionary, bool synchronous);
// WKContextClient
static void networkProcessDidCrash(WKContextRef, const void*);
void networkProcessDidCrash();
static void serviceWorkerProcessDidCrash(WKContextRef, WKProcessID, const void*);
void serviceWorkerProcessDidCrash(WKProcessID);
static void gpuProcessDidCrash(WKContextRef, WKProcessID, const void*);
void gpuProcessDidCrash(WKProcessID);
// WKPageNavigationClient
static void didCommitNavigation(WKPageRef, WKNavigationRef, WKTypeRef userData, const void*);
void didCommitNavigation(WKPageRef, WKNavigationRef);
static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef userData, const void*);
void didFinishNavigation(WKPageRef, WKNavigationRef);
// WKContextDownloadClient
static void downloadDidStart(WKContextRef, WKDownloadRef, const void*);
void downloadDidStart(WKContextRef, WKDownloadRef);
static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool* allowOverwrite, const void *clientInfo);
WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool*& allowOverwrite);
static void downloadDidFinish(WKContextRef, WKDownloadRef, const void*);
void downloadDidFinish(WKContextRef, WKDownloadRef);
static void downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef, const void*);
void downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef);
static void downloadDidCancel(WKContextRef, WKDownloadRef, const void*);
void downloadDidCancel(WKContextRef, WKDownloadRef);
static void downloadDidReceiveServerRedirectToURL(WKContextRef, WKDownloadRef, WKURLRef, const void*);
void downloadDidReceiveServerRedirectToURL(WKContextRef, WKDownloadRef, WKURLRef);
static void processDidCrash(WKPageRef, const void* clientInfo);
void processDidCrash();
static void didBeginNavigationGesture(WKPageRef, const void*);
static void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*);
static void didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*);
static void didRemoveNavigationGestureSnapshot(WKPageRef, const void*);
void didBeginNavigationGesture(WKPageRef);
void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef);
void didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef);
void didRemoveNavigationGestureSnapshot(WKPageRef);
static WKPluginLoadPolicy decidePolicyForPluginLoad(WKPageRef, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription, const void* clientInfo);
WKPluginLoadPolicy decidePolicyForPluginLoad(WKPageRef, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription);
static void decidePolicyForNotificationPermissionRequest(WKPageRef, WKSecurityOriginRef, WKNotificationPermissionRequestRef, const void*);
void decidePolicyForNotificationPermissionRequest(WKPageRef, WKSecurityOriginRef, WKNotificationPermissionRequestRef);
static void unavailablePluginButtonClicked(WKPageRef, WKPluginUnavailabilityReason, WKDictionaryRef, const void*);
static void didReceiveServerRedirectForProvisionalNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*);
void didReceiveServerRedirectForProvisionalNavigation(WKPageRef, WKNavigationRef, WKTypeRef);
static bool canAuthenticateAgainstProtectionSpace(WKPageRef, WKProtectionSpaceRef, const void*);
bool canAuthenticateAgainstProtectionSpace(WKPageRef, WKProtectionSpaceRef);
static void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef, const void*);
void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef);
static void decidePolicyForNavigationAction(WKPageRef, WKNavigationActionRef, WKFramePolicyListenerRef, WKTypeRef, const void*);
void decidePolicyForNavigationAction(WKNavigationActionRef, WKFramePolicyListenerRef);
static void decidePolicyForNavigationResponse(WKPageRef, WKNavigationResponseRef, WKFramePolicyListenerRef, WKTypeRef, const void*);
void decidePolicyForNavigationResponse(WKNavigationResponseRef, WKFramePolicyListenerRef);
// WKContextHistoryClient
static void didNavigateWithNavigationData(WKContextRef, WKPageRef, WKNavigationDataRef, WKFrameRef, const void*);
void didNavigateWithNavigationData(WKNavigationDataRef, WKFrameRef);
static void didPerformClientRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void*);
void didPerformClientRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef);
static void didPerformServerRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void*);
void didPerformServerRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef);
static void didUpdateHistoryTitle(WKContextRef, WKPageRef, WKStringRef title, WKURLRef, WKFrameRef, const void*);
void didUpdateHistoryTitle(WKStringRef title, WKURLRef, WKFrameRef);
static WKPageRef createOtherPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void*);
WKPageRef createOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef);
static void runModal(WKPageRef, const void* clientInfo);
static void runModal(PlatformWebView*);
#if PLATFORM(COCOA)
static void finishCreatingPlatformWebView(PlatformWebView*, const TestOptions&);
void configureContentMode(WKWebViewConfiguration *, const TestOptions&);
#endif
static const char* libraryPathForTesting();
static const char* platformLibraryPathForTesting();
std::unique_ptr<TestInvocation> m_currentInvocation;
#if PLATFORM(COCOA)
std::unique_ptr<ClassMethodSwizzler> m_calendarSwizzler;
std::pair<RetainPtr<NSString>, RetainPtr<NSString>> m_overriddenCalendarAndLocaleIdentifiers;
#endif // PLATFORM(COCOA)
bool m_verbose { false };
bool m_printSeparators { false };
bool m_usingServerMode { false };
bool m_gcBetweenTests { false };
bool m_shouldDumpPixelsForAllTests { false };
bool m_createdOtherPage { false };
std::vector<std::string> m_paths;
std::set<std::string> m_allowedHosts;
HashMap<String, bool> m_internalFeatures;
HashMap<String, bool> m_experimentalFeatures;
WKRetainPtr<WKStringRef> m_injectedBundlePath;
WKRetainPtr<WKStringRef> m_testPluginDirectory;
WebNotificationProvider m_webNotificationProvider;
std::unique_ptr<PlatformWebView> m_mainWebView;
WKRetainPtr<WKContextRef> m_context;
Optional<TestOptions::ContextOptions> m_contextOptions;
WKRetainPtr<WKPageGroupRef> m_pageGroup;
WKRetainPtr<WKUserContentControllerRef> m_userContentController;
#if PLATFORM(IOS_FAMILY)
Vector<std::unique_ptr<InstanceMethodSwizzler>> m_inputModeSwizzlers;
RetainPtr<UIKeyboardInputMode> m_overriddenKeyboardInputMode;
Vector<std::unique_ptr<InstanceMethodSwizzler>> m_presentPopoverSwizzlers;
#if !HAVE(NONDESTRUCTIVE_IMAGE_PASTE_SUPPORT_QUERY)
std::unique_ptr<InstanceMethodSwizzler> m_keyboardDelegateSupportsImagePasteSwizzler;
#endif
#endif
enum State {
Initial,
Resetting,
RunningTest
};
State m_state { Initial };
bool m_doneResetting { false };
bool m_useWaitToDumpWatchdogTimer { true };
bool m_forceNoTimeout { false };
bool m_didPrintWebProcessCrashedMessage { false };
bool m_shouldExitWhenWebProcessCrashes { true };
bool m_beforeUnloadReturnValue { true };
std::unique_ptr<GeolocationProviderMock> m_geolocationProvider;
Vector<WKRetainPtr<WKGeolocationPermissionRequestRef> > m_geolocationPermissionRequests;
bool m_isGeolocationPermissionSet { false };
bool m_isGeolocationPermissionAllowed { false };
HashMap<String, RefPtr<OriginSettings>> m_cachedUserMediaPermissions;
typedef Vector<std::pair<String, WKRetainPtr<WKUserMediaPermissionRequestRef>>> PermissionRequestList;
PermissionRequestList m_userMediaPermissionRequests;
bool m_isUserMediaPermissionSet { false };
bool m_isUserMediaPermissionAllowed { false };
bool m_policyDelegateEnabled { false };
bool m_policyDelegatePermissive { false };
bool m_shouldDownloadUndisplayableMIMETypes { false };
bool m_shouldAllowDeviceOrientationAndMotionAccess { false };
bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges { false };
bool m_handlesAuthenticationChallenges { false };
String m_authenticationUsername;
String m_authenticationPassword;
bool m_shouldBlockAllPlugins { false };
String m_unsupportedPluginMode;
bool m_forceComplexText { false };
bool m_shouldUseAcceleratedDrawing { false };
bool m_shouldUseRemoteLayerTree { false };
bool m_shouldLogCanAuthenticateAgainstProtectionSpace { false };
bool m_shouldLogDownloadCallbacks { false };
bool m_shouldLogHistoryClientCallbacks { false };
bool m_shouldShowWebView { false };
bool m_shouldShowTouches { false };
bool m_checkForWorldLeaks { false };
bool m_allowAnyHTTPSCertificateForAllowedHosts { false };
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
bool m_accessibilityIsolatedTreeMode { false };
#endif
bool m_shouldDecideNavigationPolicyAfterDelay { false };
bool m_shouldDecideResponsePolicyAfterDelay { false };
bool m_didReceiveServerRedirectForProvisionalNavigation { false };
WKRetainPtr<WKArrayRef> m_openPanelFileURLs;
#if PLATFORM(IOS_FAMILY)
WKRetainPtr<WKDataRef> m_openPanelFileURLsMediaIcon;
#endif
std::unique_ptr<EventSenderProxy> m_eventSenderProxy;
WKRetainPtr<WKWebsiteDataStoreRef> m_websiteDataStore;
WorkQueueManager m_workQueueManager;
struct AbandonedDocumentInfo {
String testURL;
String abandonedDocumentURL;
AbandonedDocumentInfo() = default;
AbandonedDocumentInfo(String inTestURL, String inAbandonedDocumentURL)
: testURL(inTestURL)
, abandonedDocumentURL(inAbandonedDocumentURL)
{ }
};
HashMap<uint64_t, AbandonedDocumentInfo> m_abandonedDocumentInfo;
uint64_t m_serverTrustEvaluationCallbackCallsCount { 0 };
bool m_shouldDismissJavaScriptAlertsAsynchronously { false };
bool m_allowsAnySSLCertificate { true };
bool m_shouldSwapToEphemeralSessionOnNextNavigation { false };
bool m_shouldSwapToDefaultSessionOnNextNavigation { false };
#if PLATFORM(COCOA)
bool m_hasSetApplicationBundleIdentifier { false };
#endif
};
struct TestCommand {
std::string pathOrURL;
std::string absolutePath;
std::string expectedPixelHash;
WTF::Seconds timeout;
bool shouldDumpPixels { false };
bool dumpJSConsoleLogInStdErr { false };
};
} // namespace WTR
| 47.257824 | 300 | 0.802491 | [
"vector"
] |
72501359f345e4425b0b52b335612e8a296e85c4 | 8,431 | h | C | Alignment/OfflineValidation/plugins/MuonAlignmentAnalyzer.h | m-sedghi/cmssw | 859df8affee372c53be79cdd2d8a5ff001eae841 | [
"Apache-2.0"
] | 1 | 2020-05-27T10:52:33.000Z | 2020-05-27T10:52:33.000Z | Alignment/OfflineValidation/plugins/MuonAlignmentAnalyzer.h | m-sedghi/cmssw | 859df8affee372c53be79cdd2d8a5ff001eae841 | [
"Apache-2.0"
] | 28 | 2019-08-15T15:21:11.000Z | 2021-12-29T14:13:18.000Z | Alignment/OfflineValidation/plugins/MuonAlignmentAnalyzer.h | m-sedghi/cmssw | 859df8affee372c53be79cdd2d8a5ff001eae841 | [
"Apache-2.0"
] | 1 | 2020-08-18T10:29:49.000Z | 2020-08-18T10:29:49.000Z | #ifndef Alignment_OfflineValidation_MuonAlignmentAnalyzer_H
#define Alignment_OfflineValidation_MuonAlignmentAnalyzer_H
/** \class MuonAlignmentANalyzer
* MuonAlignment offline Monitor Analyzer
* Makes histograms of high level Muon objects/quantities
* and residuals (base EDAnalyzer for Muon Alignment Offline DQM)
* for Alignment Scenarios/DB comparison
*
* $Date: 2010/03/29 13:18:44 $
* $Revision: 1.8 $
* \author J. Fernandez - Univ. Oviedo <Javier.Fernandez@cern.ch>
*/
// Base Class Headers
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "TrackingTools/GeomPropagators/interface/Propagator.h"
#include <vector>
namespace edm {
class ParameterSet;
class EventSetup;
} // namespace edm
class TH1F;
class TH2F;
typedef std::vector<std::vector<int> > intDVector;
typedef std::vector<TrackingRecHit *> RecHitVector;
class MuonAlignmentAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// Constructor
MuonAlignmentAnalyzer(const edm::ParameterSet &pset);
/// Destructor
~MuonAlignmentAnalyzer() override;
// Operations
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override;
void beginJob() override;
void endJob() override;
protected:
private:
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> trackingGeometryToken_;
RecHitVector doMatching(const reco::Track &,
edm::Handle<DTRecSegment4DCollection> &,
edm::Handle<CSCSegmentCollection> &,
intDVector *,
intDVector *,
edm::ESHandle<GlobalTrackingGeometry> &);
edm::Service<TFileService> fs;
// InputTags
edm::InputTag theGLBMuonTag;
edm::InputTag theSTAMuonTag;
// Collections needed
edm::InputTag theRecHits4DTagDT;
edm::InputTag theRecHits4DTagCSC;
// To switch between real data and MC
std::string theDataType;
bool doSAplots, doGBplots, doResplots;
// Histograms
//# muons per event
TH1F *hGBNmuons;
TH1F *hSANmuons;
TH1F *hSimNmuons;
TH1F *hGBNmuons_Barrel;
TH1F *hSANmuons_Barrel;
TH1F *hSimNmuons_Barrel;
TH1F *hGBNmuons_Endcap;
TH1F *hSANmuons_Endcap;
TH1F *hSimNmuons_Endcap;
// # hits per track
TH1F *hGBNhits;
TH1F *hGBNhits_Barrel;
TH1F *hGBNhits_Endcap;
TH1F *hSANhits;
TH1F *hSANhits_Barrel;
TH1F *hSANhits_Endcap;
// Chi2 of Track
TH1F *hGBChi2;
TH1F *hSAChi2;
TH1F *hGBChi2_Barrel;
TH1F *hSAChi2_Barrel;
TH1F *hGBChi2_Endcap;
TH1F *hSAChi2_Endcap;
// Invariant mass for dimuons
TH1F *hGBInvM;
TH1F *hSAInvM;
TH1F *hSimInvM;
// Invariant Mass distributions in Barrel (eta<1.04) region
TH1F *hGBInvM_Barrel;
TH1F *hSAInvM_Barrel;
TH1F *hSimInvM_Barrel;
// Invariant Mass distributions in Endcap (eta>=1.04) region
TH1F *hGBInvM_Endcap;
TH1F *hSAInvM_Endcap;
TH1F *hSimInvM_Endcap;
// Invariant Mass distributions in Barrel-Endcap overlap region
// 1 muon barrel & 1 muon endcap
TH1F *hGBInvM_Overlap;
TH1F *hSAInvM_Overlap;
TH1F *hSimInvM_Overlap;
// pT
TH1F *hSAPTRec;
TH1F *hGBPTRec;
TH1F *hSimPT;
TH1F *hSAPTRec_Barrel;
TH1F *hGBPTRec_Barrel;
TH1F *hSimPT_Barrel;
TH1F *hSAPTRec_Endcap;
TH1F *hGBPTRec_Endcap;
TH1F *hSimPT_Endcap;
TH2F *hGBPTvsEta;
TH2F *hGBPTvsPhi;
TH2F *hSAPTvsEta;
TH2F *hSAPTvsPhi;
TH2F *hSimPTvsEta;
TH2F *hSimPTvsPhi;
// For reco efficiency calculations
TH2F *hSimPhivsEta;
TH2F *hSAPhivsEta;
TH2F *hGBPhivsEta;
// pT resolution
TH1F *hSAPTres;
TH1F *hSAinvPTres;
TH1F *hGBPTres;
TH1F *hGBinvPTres;
TH1F *hSAPTres_Barrel;
TH1F *hSAPTres_Endcap;
TH1F *hGBPTres_Barrel;
TH1F *hGBPTres_Endcap;
//pT rec - pT gen
TH1F *hSAPTDiff;
TH1F *hGBPTDiff;
TH2F *hSAPTDiffvsEta;
TH2F *hSAPTDiffvsPhi;
TH2F *hGBPTDiffvsEta;
TH2F *hGBPTDiffvsPhi;
TH2F *hGBinvPTvsEta;
TH2F *hGBinvPTvsPhi;
TH2F *hSAinvPTvsEta;
TH2F *hSAinvPTvsPhi;
TH2F *hSAinvPTvsNhits;
TH2F *hGBinvPTvsNhits;
// Vector of chambers Residuals
std::vector<TH1F *> unitsLocalX;
std::vector<TH1F *> unitsLocalPhi;
std::vector<TH1F *> unitsLocalTheta;
std::vector<TH1F *> unitsLocalY;
std::vector<TH1F *> unitsGlobalRPhi;
std::vector<TH1F *> unitsGlobalPhi;
std::vector<TH1F *> unitsGlobalTheta;
std::vector<TH1F *> unitsGlobalRZ;
// DT & CSC Residuals
TH1F *hResidualLocalXDT;
TH1F *hResidualLocalPhiDT;
TH1F *hResidualLocalThetaDT;
TH1F *hResidualLocalYDT;
TH1F *hResidualLocalXCSC;
TH1F *hResidualLocalPhiCSC;
TH1F *hResidualLocalThetaCSC;
TH1F *hResidualLocalYCSC;
std::vector<TH1F *> hResidualLocalXDT_W;
std::vector<TH1F *> hResidualLocalPhiDT_W;
std::vector<TH1F *> hResidualLocalThetaDT_W;
std::vector<TH1F *> hResidualLocalYDT_W;
std::vector<TH1F *> hResidualLocalXCSC_ME;
std::vector<TH1F *> hResidualLocalPhiCSC_ME;
std::vector<TH1F *> hResidualLocalThetaCSC_ME;
std::vector<TH1F *> hResidualLocalYCSC_ME;
std::vector<TH1F *> hResidualLocalXDT_MB;
std::vector<TH1F *> hResidualLocalPhiDT_MB;
std::vector<TH1F *> hResidualLocalThetaDT_MB;
std::vector<TH1F *> hResidualLocalYDT_MB;
TH1F *hResidualGlobalRPhiDT;
TH1F *hResidualGlobalPhiDT;
TH1F *hResidualGlobalThetaDT;
TH1F *hResidualGlobalZDT;
TH1F *hResidualGlobalRPhiCSC;
TH1F *hResidualGlobalPhiCSC;
TH1F *hResidualGlobalThetaCSC;
TH1F *hResidualGlobalRCSC;
std::vector<TH1F *> hResidualGlobalRPhiDT_W;
std::vector<TH1F *> hResidualGlobalPhiDT_W;
std::vector<TH1F *> hResidualGlobalThetaDT_W;
std::vector<TH1F *> hResidualGlobalZDT_W;
std::vector<TH1F *> hResidualGlobalRPhiCSC_ME;
std::vector<TH1F *> hResidualGlobalPhiCSC_ME;
std::vector<TH1F *> hResidualGlobalThetaCSC_ME;
std::vector<TH1F *> hResidualGlobalRCSC_ME;
std::vector<TH1F *> hResidualGlobalRPhiDT_MB;
std::vector<TH1F *> hResidualGlobalPhiDT_MB;
std::vector<TH1F *> hResidualGlobalThetaDT_MB;
std::vector<TH1F *> hResidualGlobalZDT_MB;
// Mean and RMS of residuals for DQM
TH2F *hprofLocalPositionCSC;
TH2F *hprofLocalAngleCSC;
TH2F *hprofLocalPositionRmsCSC;
TH2F *hprofLocalAngleRmsCSC;
TH2F *hprofGlobalPositionCSC;
TH2F *hprofGlobalAngleCSC;
TH2F *hprofGlobalPositionRmsCSC;
TH2F *hprofGlobalAngleRmsCSC;
TH2F *hprofLocalPositionDT;
TH2F *hprofLocalAngleDT;
TH2F *hprofLocalPositionRmsDT;
TH2F *hprofLocalAngleRmsDT;
TH2F *hprofGlobalPositionDT;
TH2F *hprofGlobalAngleDT;
TH2F *hprofGlobalPositionRmsDT;
TH2F *hprofGlobalAngleRmsDT;
TH1F *hprofLocalXDT;
TH1F *hprofLocalPhiDT;
TH1F *hprofLocalThetaDT;
TH1F *hprofLocalYDT;
TH1F *hprofLocalXCSC;
TH1F *hprofLocalPhiCSC;
TH1F *hprofLocalThetaCSC;
TH1F *hprofLocalYCSC;
TH1F *hprofGlobalRPhiDT;
TH1F *hprofGlobalPhiDT;
TH1F *hprofGlobalThetaDT;
TH1F *hprofGlobalZDT;
TH1F *hprofGlobalRPhiCSC;
TH1F *hprofGlobalPhiCSC;
TH1F *hprofGlobalThetaCSC;
TH1F *hprofGlobalRCSC;
std::vector<long> detectorCollection;
// ESHandle<MagneticField> theMGField;
Propagator *thePropagator;
// Counters
int numberOfSimTracks;
int numberOfGBRecTracks;
int numberOfSARecTracks;
int numberOfHits;
// hist kinematic range
double ptRangeMin, ptRangeMax, invMassRangeMin, invMassRangeMax;
// hist residual range
double resLocalXRangeStation1, resLocalXRangeStation2, resLocalXRangeStation3, resLocalXRangeStation4;
double resLocalYRangeStation1, resLocalYRangeStation2, resLocalYRangeStation3, resLocalYRangeStation4;
double resPhiRange, resThetaRange;
unsigned int nbins, min1DTrackRecHitSize, min4DTrackSegmentSize;
};
#endif
| 29.68662 | 104 | 0.755545 | [
"geometry",
"vector"
] |
897aa09e5efbea9880549abf8f52f3259d819408 | 13,825 | c | C | dlls/sane.ds/unixlib.c | xilwen/wine | 2318484e1e33cb30f00eb9a62cb9aa5f83e5dc99 | [
"MIT"
] | 2,322 | 2015-01-10T13:48:25.000Z | 2022-03-31T18:52:48.000Z | dlls/sane.ds/unixlib.c | xilwen/wine | 2318484e1e33cb30f00eb9a62cb9aa5f83e5dc99 | [
"MIT"
] | 19 | 2015-09-01T14:36:04.000Z | 2022-03-31T11:59:59.000Z | dlls/sane.ds/unixlib.c | xilwen/wine | 2318484e1e33cb30f00eb9a62cb9aa5f83e5dc99 | [
"MIT"
] | 980 | 2015-01-05T05:50:50.000Z | 2022-03-31T09:29:07.000Z | /*
* Unix library interface for SANE
*
* Copyright 2000 Shi Quan He
* Copyright 2021 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdarg.h>
#include <stdlib.h>
#include <sane/sane.h>
#include <sane/saneopts.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "unixlib.h"
#include "wine/list.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(twain);
static SANE_Handle device_handle;
static BOOL device_started;
static const SANE_Device **device_list;
/* Sane returns device names that are longer than the 32 bytes allowed
by TWAIN. However, it colon separates them, and the last bit is
the most interesting. So we use the last bit, and add a signature
to ensure uniqueness */
static void copy_sane_short_name(const char *in, char *out, size_t outsize)
{
const char *p;
int signature = 0;
if (strlen(in) <= outsize - 1)
{
strcpy(out, in);
return;
}
for (p = in; *p; p++)
signature += *p;
p = strrchr(in, ':');
if (!p)
p = in;
else
p++;
if (strlen(p) > outsize - 7 - 1)
p += strlen(p) - (outsize - 7 - 1);
strcpy(out, p);
sprintf(out + strlen(out), "(%04X)", signature % 0x10000);
}
static void detect_sane_devices(void)
{
if (device_list && device_list[0]) return;
TRACE("detecting sane...\n");
sane_get_devices( &device_list, SANE_FALSE );
}
static TW_UINT16 sane_status_to_twcc(SANE_Status rc)
{
switch (rc)
{
case SANE_STATUS_GOOD:
return TWCC_SUCCESS;
case SANE_STATUS_UNSUPPORTED:
return TWCC_CAPUNSUPPORTED;
case SANE_STATUS_JAMMED:
return TWCC_PAPERJAM;
case SANE_STATUS_NO_MEM:
return TWCC_LOWMEMORY;
case SANE_STATUS_ACCESS_DENIED:
return TWCC_DENIED;
case SANE_STATUS_IO_ERROR:
case SANE_STATUS_NO_DOCS:
case SANE_STATUS_COVER_OPEN:
case SANE_STATUS_EOF:
case SANE_STATUS_INVAL:
case SANE_STATUS_CANCELLED:
case SANE_STATUS_DEVICE_BUSY:
default:
return TWCC_BUMMER;
}
}
static int map_type( SANE_Value_Type type )
{
switch (type)
{
case SANE_TYPE_BOOL: return TYPE_BOOL;
case SANE_TYPE_INT: return TYPE_INT;
case SANE_TYPE_FIXED: return TYPE_FIXED;
case SANE_TYPE_STRING: return TYPE_STRING;
case SANE_TYPE_BUTTON: return TYPE_BUTTON;
case SANE_TYPE_GROUP: return TYPE_GROUP;
default: return -1;
}
}
static int map_unit( SANE_Unit unit )
{
switch (unit)
{
case SANE_UNIT_NONE: return UNIT_NONE;
case SANE_UNIT_PIXEL: return UNIT_PIXEL;
case SANE_UNIT_BIT: return UNIT_BIT;
case SANE_UNIT_MM: return UNIT_MM;
case SANE_UNIT_DPI: return UNIT_DPI;
case SANE_UNIT_PERCENT: return UNIT_PERCENT;
case SANE_UNIT_MICROSECOND: return UNIT_MICROSECOND;
default: return -1;
}
}
static int map_constraint_type( SANE_Constraint_Type type )
{
switch (type)
{
case SANE_CONSTRAINT_NONE: return CONSTRAINT_NONE;
case SANE_CONSTRAINT_RANGE: return CONSTRAINT_RANGE;
case SANE_CONSTRAINT_WORD_LIST: return CONSTRAINT_WORD_LIST;
case SANE_CONSTRAINT_STRING_LIST: return CONSTRAINT_STRING_LIST;
default: return CONSTRAINT_NONE;
}
}
static void map_descr( struct option_descriptor *descr, const SANE_Option_Descriptor *opt )
{
unsigned int i, size, len = 0;
WCHAR *p;
descr->type = map_type( opt->type );
descr->unit = map_unit( opt->unit );
descr->constraint_type = map_constraint_type( opt->constraint_type );
descr->size = opt->size;
descr->is_active = SANE_OPTION_IS_ACTIVE( opt->cap );
if (opt->title) len = ntdll_umbstowcs( opt->title, strlen(opt->title),
descr->title, ARRAY_SIZE(descr->title) );
descr->title[len] = 0;
switch (descr->constraint_type)
{
case CONSTRAINT_RANGE:
descr->constraint.range.min = opt->constraint.range->min;
descr->constraint.range.max = opt->constraint.range->max;
descr->constraint.range.quant = opt->constraint.range->quant;
break;
case CONSTRAINT_WORD_LIST:
size = min( opt->constraint.word_list[0], ARRAY_SIZE(descr->constraint.word_list) - 1 );
descr->constraint.word_list[0] = size;
for (i = 1; i <= size; i++) descr->constraint.word_list[i] = opt->constraint.word_list[i];
break;
case CONSTRAINT_STRING_LIST:
p = descr->constraint.strings;
size = ARRAY_SIZE(descr->constraint.strings) - 1;
for (i = 0; size && opt->constraint.string_list[i]; i++)
{
len = ntdll_umbstowcs( opt->constraint.string_list[i], strlen(opt->constraint.string_list[i]),
p, size );
p[len++] = 0;
size -= len;
p += len;
}
*p = 0;
break;
default:
break;
}
}
static NTSTATUS process_attach( void *args )
{
SANE_Int version_code;
sane_init( &version_code, NULL );
return STATUS_SUCCESS;
}
static NTSTATUS process_detach( void *args )
{
sane_exit();
return STATUS_SUCCESS;
}
static NTSTATUS get_identity( void *args )
{
TW_IDENTITY *id = args;
static int cur_dev;
detect_sane_devices();
if (!device_list[cur_dev]) return STATUS_DEVICE_NOT_CONNECTED;
id->ProtocolMajor = TWON_PROTOCOLMAJOR;
id->ProtocolMinor = TWON_PROTOCOLMINOR;
id->SupportedGroups = DG_CONTROL | DG_IMAGE | DF_DS2;
copy_sane_short_name(device_list[cur_dev]->name, id->ProductName, sizeof(id->ProductName) - 1);
lstrcpynA (id->Manufacturer, device_list[cur_dev]->vendor, sizeof(id->Manufacturer) - 1);
lstrcpynA (id->ProductFamily, device_list[cur_dev]->model, sizeof(id->ProductFamily) - 1);
cur_dev++;
if (!device_list[cur_dev] || !device_list[cur_dev]->model ||
!device_list[cur_dev]->vendor ||
!device_list[cur_dev]->name)
cur_dev = 0; /* wrap to begin */
return STATUS_SUCCESS;
}
static NTSTATUS open_ds( void *args )
{
TW_IDENTITY *id = args;
SANE_Status status;
int i;
detect_sane_devices();
if (!device_list[0])
{
ERR("No scanners? We should not get to OpenDS?\n");
return STATUS_DEVICE_NOT_CONNECTED;
}
for (i = 0; device_list[i] && device_list[i]->model; i++)
{
TW_STR32 name;
/* To make string as short as above */
lstrcpynA(name, device_list[i]->vendor, sizeof(name)-1);
if (*id->Manufacturer && strcmp(name, id->Manufacturer))
continue;
lstrcpynA(name, device_list[i]->model, sizeof(name)-1);
if (*id->ProductFamily && strcmp(name, id->ProductFamily))
continue;
copy_sane_short_name(device_list[i]->name, name, sizeof(name) - 1);
if (*id->ProductName && strcmp(name, id->ProductName))
continue;
break;
}
if (!device_list[i]) {
WARN("Scanner not found.\n");
return STATUS_DEVICE_NOT_CONNECTED;
}
status = sane_open( device_list[i]->name, &device_handle );
if (status == SANE_STATUS_GOOD) return STATUS_SUCCESS;
ERR("sane_open(%s): %s\n", device_list[i]->name, sane_strstatus (status));
return STATUS_DEVICE_NOT_CONNECTED;
}
static NTSTATUS close_ds( void *args )
{
if (device_handle) sane_close( device_handle );
device_handle = NULL;
device_started = FALSE;
return STATUS_SUCCESS;
}
static NTSTATUS start_device( void *args )
{
SANE_Status status;
if (device_started) return STATUS_SUCCESS;
status = sane_start( device_handle );
if (status != SANE_STATUS_GOOD)
{
TRACE("sane_start returns %s\n", sane_strstatus(status));
return STATUS_DEVICE_NOT_CONNECTED;
}
device_started = TRUE;
return STATUS_SUCCESS;
}
static NTSTATUS cancel_device( void *args )
{
if (device_started) sane_cancel( device_handle );
device_started = FALSE;
return STATUS_SUCCESS;
}
static NTSTATUS read_data( void *args )
{
const struct read_data_params *params = args;
unsigned char *buffer = params->buffer;
int read_len, remaining = params->len;
SANE_Status status;
*params->retlen = 0;
while (remaining)
{
status = sane_read( device_handle, buffer, remaining, &read_len );
if (status != SANE_STATUS_GOOD) break;
*params->retlen += read_len;
buffer += read_len;
remaining -= read_len;
}
if (status == SANE_STATUS_EOF) return TWCC_SUCCESS;
return sane_status_to_twcc( status );
}
static NTSTATUS get_params( void *args )
{
struct frame_parameters *params = args;
SANE_Parameters sane_params;
if (sane_get_parameters( device_handle, &sane_params )) return STATUS_UNSUCCESSFUL;
switch (sane_params.format)
{
case SANE_FRAME_GRAY:
params->format = FMT_GRAY;
break;
case SANE_FRAME_RGB:
params->format = FMT_RGB;
break;
default:
ERR("Unhandled source frame format %i\n", sane_params.format);
params->format = FMT_OTHER;
break;
}
params->last_frame = sane_params.last_frame;
params->bytes_per_line = sane_params.bytes_per_line;
params->pixels_per_line = sane_params.pixels_per_line;
params->lines = sane_params.lines;
params->depth = sane_params.depth;
return STATUS_SUCCESS;
}
static NTSTATUS option_get_value( void *args )
{
const struct option_get_value_params *params = args;
return sane_status_to_twcc( sane_control_option( device_handle, params->optno,
SANE_ACTION_GET_VALUE, params->val, NULL ));
}
static NTSTATUS option_set_value( void *args )
{
const struct option_set_value_params *params = args;
int status = 0;
TW_UINT16 rc = sane_status_to_twcc( sane_control_option( device_handle, params->optno,
SANE_ACTION_SET_VALUE, params->val, &status ));
if (rc == TWCC_SUCCESS && params->reload)
*params->reload = (status & (SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS | SANE_INFO_INEXACT)) != 0;
return rc;
}
static NTSTATUS option_get_descriptor( void *args )
{
struct option_descriptor *descr = args;
const SANE_Option_Descriptor *opt = sane_get_option_descriptor( device_handle, descr->optno );
if (!opt) return STATUS_NO_MORE_ENTRIES;
map_descr( descr, opt );
return STATUS_SUCCESS;
}
static NTSTATUS option_find_descriptor( void *args )
{
const struct option_find_descriptor_params *params = args;
struct option_descriptor *descr = params->descr;
const SANE_Option_Descriptor *opt;
int i;
for (i = 1; (opt = sane_get_option_descriptor( device_handle, i )) != NULL; i++)
{
if (params->type != map_type( opt->type )) continue;
if (strcmp( params->name, opt->name )) continue;
descr->optno = i;
map_descr( descr, opt );
return STATUS_SUCCESS;
}
return STATUS_NO_MORE_ENTRIES;
}
const unixlib_entry_t __wine_unix_call_funcs[] =
{
process_attach,
process_detach,
get_identity,
open_ds,
close_ds,
start_device,
cancel_device,
read_data,
get_params,
option_get_value,
option_set_value,
option_get_descriptor,
option_find_descriptor,
};
#ifdef _WIN64
typedef ULONG PTR32;
static NTSTATUS wow64_read_data( void *args )
{
struct
{
PTR32 buffer;
int len;
PTR32 retlen;
} const *params32 = args;
struct read_data_params params =
{
ULongToPtr(params32->buffer),
params32->len,
ULongToPtr(params32->retlen)
};
return read_data( ¶ms );
}
static NTSTATUS wow64_option_get_value( void *args )
{
struct
{
int optno;
PTR32 val;
} const *params32 = args;
struct option_get_value_params params =
{
params32->optno,
ULongToPtr(params32->val)
};
return option_get_value( ¶ms );
}
static NTSTATUS wow64_option_set_value( void *args )
{
struct
{
int optno;
PTR32 val;
PTR32 reload;
} const *params32 = args;
struct option_set_value_params params =
{
params32->optno,
ULongToPtr(params32->val),
ULongToPtr(params32->reload)
};
return option_set_value( ¶ms );
}
static NTSTATUS wow64_option_find_descriptor( void *args )
{
struct
{
PTR32 name;
int type;
PTR32 descr;
} const *params32 = args;
struct option_find_descriptor_params params =
{
ULongToPtr(params32->name),
params32->type,
ULongToPtr(params32->descr)
};
return option_find_descriptor( ¶ms );
}
const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
{
process_attach,
process_detach,
get_identity,
open_ds,
close_ds,
start_device,
cancel_device,
wow64_read_data,
get_params,
wow64_option_get_value,
wow64_option_set_value,
option_get_descriptor,
wow64_option_find_descriptor,
};
#endif /* _WIN64 */
| 27.107843 | 115 | 0.660036 | [
"model"
] |
897aa72298c250f9d573211ba69060be3036dd0c | 26,976 | c | C | nrf5/light_lightness/client/src/main.c | AlexRogalskiy/nodemcu-test-flight | 7d4fefe0262d3deb904dccc8a082669627f80625 | [
"MIT"
] | 1 | 2021-04-10T10:01:06.000Z | 2021-04-10T10:01:06.000Z | nrf5/light_lightness/client/src/main.c | AlexRogalskiy/nodemcu-test-flight | 7d4fefe0262d3deb904dccc8a082669627f80625 | [
"MIT"
] | 1 | 2021-04-17T19:44:28.000Z | 2021-04-17T19:44:28.000Z | nrf5/light_lightness/client/src/main.c | AlexRogalskiy/nodemcu-test-flight | 7d4fefe0262d3deb904dccc8a082669627f80625 | [
"MIT"
] | 3 | 2021-04-10T10:01:08.000Z | 2021-09-02T00:14:31.000Z | /* Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, 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 Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
#include <string.h>
/* HAL */
#include "boards.h"
#include "simple_hal.h"
#include "app_timer.h"
/* Core */
#include "nrf_mesh_config_core.h"
#include "nrf_mesh_gatt.h"
#include "nrf_mesh_configure.h"
#include "nrf_mesh.h"
#include "mesh_stack.h"
#include "mesh_config_entry.h"
#include "device_state_manager.h"
#include "access_config.h"
/* Provisioning and configuration */
#include "mesh_provisionee.h"
#include "mesh_app_utils.h"
/* Models */
#include "light_lightness_client.h"
/* Logging and RTT */
#include "log.h"
#include "rtt_input.h"
/* Example specific includes */
#include "app_config.h"
#include "nrf_mesh_config_examples.h"
#include "example_common.h"
#include "ble_softdevice_support.h"
/*****************************************************************************
* Definitions
*****************************************************************************/
#define APP_STATE_OFF (0)
#define APP_STATE_ON (1)
#define APP_UNACK_MSG_REPEAT_COUNT (2)
/* Timeout, in seconds, to demonstrate cumulative Delta Set messages with same TID value */
#define APP_TIMEOUT_FOR_TID_CHANGE (3)
/* Client lightness parameter step size */
#define APP_LIGHTNESS_STEP_SIZE (10000L)
/* Controls if the model instance should force all mesh messages to be segmented messages. */
#define APP_FORCE_SEGMENTATION (false)
/* Controls the MIC size used by the model instance for sending the mesh messages. */
#define APP_MIC_SIZE (NRF_MESH_TRANSMIC_SIZE_SMALL)
/* Delay value used by the Lightness client for sending messages. */
#define APP_LIGHTNESS_DELAY_MS (0)
/* Transition time value used by the Lightness client for sending messages. */
#define APP_LIGHTNESS_TRANSITION_TIME_MS (0)
/*****************************************************************************
* Forward declaration of static functions
*****************************************************************************/
static void app_light_lightness_client_publish_interval_cb(access_model_handle_t handle, void *p_self);
static void app_light_lightness_client_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_status_params_t *p_in);
static void app_light_lightness_client_linear_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_linear_status_params_t *p_in);
static void app_light_lightness_client_last_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_last_status_params_t *p_in);
static void app_light_lightness_client_default_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_default_status_params_t *p_in);
static void app_light_lightness_client_range_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_range_status_params_t *p_in);
static void app_light_lightness_client_transaction_status_cb(access_model_handle_t model_handle,
void *p_args,
access_reliable_status_t status);
/*****************************************************************************
* Static variables
*****************************************************************************/
static light_lightness_client_t m_clients[CLIENT_MODEL_INSTANCE_COUNT];
static bool m_device_provisioned;
static const light_lightness_client_callbacks_t client_cbs =
{
.lightness_status_cb = app_light_lightness_client_status_cb,
.lightness_linear_status_cb = app_light_lightness_client_linear_status_cb,
.lightness_last_status_cb = app_light_lightness_client_last_status_cb,
.lightness_default_status_cb = app_light_lightness_client_default_status_cb,
.lightness_range_status_cb = app_light_lightness_client_range_status_cb,
.ack_transaction_status_cb = app_light_lightness_client_transaction_status_cb,
.periodic_publish_cb = app_light_lightness_client_publish_interval_cb
};
static void device_identification_start_cb(uint8_t attention_duration_s)
{
hal_led_mask_set(LEDS_MASK, false);
hal_led_blink_ms(BSP_LED_2_MASK | BSP_LED_3_MASK,
LED_BLINK_ATTENTION_INTERVAL_MS,
LED_BLINK_ATTENTION_COUNT(attention_duration_s));
}
static void provisioning_aborted_cb(void)
{
hal_led_blink_stop();
}
static void unicast_address_print(void)
{
dsm_local_unicast_address_t node_address;
dsm_local_unicast_addresses_get(&node_address);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Node Address: 0x%04x \n", node_address.address_start);
}
static void provisioning_complete_cb(void)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Successfully provisioned\n");
#if MESH_FEATURE_GATT_ENABLED
/* Restores the application parameters after switching from the Provisioning
* service to the Proxy */
gap_params_init();
conn_params_init();
#endif
unicast_address_print();
hal_led_blink_stop();
hal_led_mask_set(LEDS_MASK, LED_MASK_STATE_OFF);
hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_PROV);
}
/* This callback is called periodically if model is configured for periodic publishing */
static void app_light_lightness_client_publish_interval_cb(access_model_handle_t handle, void *p_self)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_WARN, "Publish desired message here.\n");
}
/* Acknowledged transaction status callback, if acknowledged transfer fails, application can
* determine suitable course of action (e.g. re-initiate previous transaction) by using this
* callback.
*/
static void app_light_lightness_client_transaction_status_cb(access_model_handle_t model_handle,
void *p_args,
access_reliable_status_t status)
{
switch(status)
{
case ACCESS_RELIABLE_TRANSFER_SUCCESS:
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Acknowledged transfer success.\n");
break;
case ACCESS_RELIABLE_TRANSFER_TIMEOUT:
hal_led_blink_ms(LEDS_MASK, LED_BLINK_SHORT_INTERVAL_MS, LED_BLINK_CNT_NO_REPLY);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Acknowledged transfer timeout.\n");
break;
case ACCESS_RELIABLE_TRANSFER_CANCELLED:
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Acknowledged transfer cancelled.\n");
break;
default:
ERROR_CHECK(NRF_ERROR_INTERNAL);
break;
}
}
/* Light lightness client model interface: Process the received status message in this callback */
static void app_light_lightness_client_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_status_params_t *p_in)
{
if (p_in->remaining_time_ms > 0)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Lightness client: 0x%04x, Present Lightness: %d, Target Lightness: %d, Remaining Time: %d ms\n",
p_meta->src.value, p_in->present_lightness, p_in->target_lightness, p_in->remaining_time_ms);
}
else
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Lightness client: 0x%04x, Present lightness: %d\n",
p_meta->src.value, p_in->present_lightness);
}
}
/* Light lightness client model interface: Process the received linear status message in this callback */
static void app_light_lightness_client_linear_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_linear_status_params_t *p_in)
{
if (p_in->remaining_time_ms > 0)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Lightness client: 0x%04x, Present linear lightness: %d, Target Linear lightness: %d, Remaining Time: %d ms\n",
p_meta->src.value, p_in->present_lightness, p_in->target_lightness, p_in->remaining_time_ms);
}
else
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Lightness client: 0x%04x, Present Linear Lightness: %d\n",
p_meta->src.value, p_in->present_lightness);
}
}
/* Light lightness client model interface: Process the received last status message in this callback */
static void app_light_lightness_client_last_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_last_status_params_t *p_in)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Lightness client: 0x%04x, Last Lightness: %d\n",
p_meta->src.value, p_in->lightness);
}
/* Light lightness client model interface: Process the received default status message in this callback */
static void app_light_lightness_client_default_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_default_status_params_t *p_in)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Lightness client: 0x%04x, Default Lightness: %d\n",
p_meta->src.value, p_in->lightness);
}
/* Light lightness client model interface: Process the received range status message in this callback */
static void app_light_lightness_client_range_status_cb(const light_lightness_client_t *p_self,
const access_message_rx_meta_t *p_meta,
const light_lightness_range_status_params_t *p_in)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Lightness client: 0x%04x, Range Lightness status: %s, min: %d, max: %d\n",
p_meta->src.value, (p_in->status == 0)?"success":"can't set range",
p_in->range_min, p_in->range_max);
}
static void node_reset(void)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- Node reset -----\n");
hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_RESET);
/* This function may return if there are ongoing flash operations. */
mesh_stack_device_reset();
}
static void config_server_evt_cb(const config_server_evt_t *p_evt)
{
if (p_evt->type == CONFIG_SERVER_EVT_NODE_RESET)
{
node_reset();
}
}
#if NRF_MESH_LOG_ENABLE
static const char m_usage_string[] =
"\n"
"\t\t---------------------------------------------------\n"
"\t\t Button/RTT 1) Set actual increase (unack).\n"
"\t\t Button/RTT 2) Set actual decrease (unack).\n"
"\t\t Button/RTT 3) Set linear increase (unack).\n"
"\t\t Button/RTT 4) Set linear decrease (unack).\n\n"
"\t\t RTT 5) Send get last lightness message.\n"
"\t\t RTT 6) Send get default lightness message.\n"
"\t\t RTT 7) Send get range message.\n"
"\t\t RTT 8) Send get actual lightness message.\n"
"\t\t RTT 9) Send get linear lightness message.\n\n"
"\t\t RTT a) Send set default increase (unack).\n"
"\t\t RTT b) Send set default decrease (unack).\n\n"
"\t\t RTT c) Send set range min increase (unack).\n"
"\t\t RTT d) Send set range min decrease (unack).\n"
"\t\t RTT e) Send set range max increase (unack).\n"
"\t\t RTT f) Send set range max decrease (unack).\n\n"
"\t\t RTT g) Send linear value of 0.\n\n"
"\t\t RTT h) Switch between the clients.\n"
"\t\t---------------------------------------------------\n";
#endif
static void button_event_handler(uint32_t button_number)
{
if (button_number < 0xa)
{
/* Increase button number because the buttons on the board is marked with 1 to 4 */
button_number++;
}
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number);
uint32_t status = NRF_SUCCESS;
static uint8_t client = 0;
static light_lightness_set_params_t set_params = {0};
static light_lightness_linear_set_params_t linear_set_params = {0};
static light_lightness_default_set_params_t default_set_params = {0};
static light_lightness_range_set_params_t range_set_params = {1, 65535};
model_transition_t transition_params;
static uint32_t timestamp = 0;
timestamp_t current_time;
switch(button_number)
{
case 1:
set_params.lightness = MIN(UINT16_MAX,
(int32_t)set_params.lightness + APP_LIGHTNESS_STEP_SIZE);
set_params.tid++;
break;
case 2:
set_params.lightness = MAX(0, (int32_t)set_params.lightness - APP_LIGHTNESS_STEP_SIZE);
set_params.tid++;
break;
case 3:
linear_set_params.lightness = MIN(UINT16_MAX,
(int32_t)linear_set_params.lightness + APP_LIGHTNESS_STEP_SIZE);
linear_set_params.tid++;
break;
case 4:
linear_set_params.lightness = MAX(0, (int32_t)linear_set_params.lightness - APP_LIGHTNESS_STEP_SIZE);
linear_set_params.tid++;
break;
case 0xa:
default_set_params.lightness = MIN(UINT16_MAX,
(int32_t)default_set_params.lightness + APP_LIGHTNESS_STEP_SIZE);
// no TID for this cmd
break;
case 0xb:
default_set_params.lightness = MAX(0, (int32_t)default_set_params.lightness - APP_LIGHTNESS_STEP_SIZE);
// no TID for this cmd
break;
case 0xc:
range_set_params.range_min = MIN(UINT16_MAX,
(int32_t)range_set_params.range_min + APP_LIGHTNESS_STEP_SIZE);
// no TID for this cmd
break;
case 0xd:
range_set_params.range_min = MAX(0, (int32_t)range_set_params.range_min - APP_LIGHTNESS_STEP_SIZE);
// no TID for this cmd
break;
case 0xe:
range_set_params.range_max = MIN(UINT16_MAX,
(int32_t)range_set_params.range_max + APP_LIGHTNESS_STEP_SIZE);
// no TID for this cmd
break;
case 0xf:
range_set_params.range_max = MAX(0, (int32_t)range_set_params.range_max - APP_LIGHTNESS_STEP_SIZE);
// no TID for this cmd
break;
case 0x10:
linear_set_params.lightness = 0;
linear_set_params.tid++;
break;
default:
break;
}
current_time = timer_now();
if (timestamp + SEC_TO_US(APP_TIMEOUT_FOR_TID_CHANGE) < current_time)
{
linear_set_params.tid++;
set_params.tid++;
}
timestamp = current_time;
transition_params.delay_ms = APP_LIGHTNESS_DELAY_MS;
transition_params.transition_time_ms = APP_LIGHTNESS_TRANSITION_TIME_MS;
switch (button_number)
{
case 1:
case 2:
/* Demonstrate un-acknowledged transaction, using 1st client model instance, set actual*/
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Sending msg: UnAck Lightness Set: Lightness: %d Tid: %d Trans time: %d ms Delay: %d ms\n",
set_params.lightness, set_params.tid, transition_params.transition_time_ms,
transition_params.delay_ms);
status = light_lightness_client_set_unack(&m_clients[client],
&set_params, &transition_params, 0);
break;
case 3:
case 4:
/* Demonstrate un-acknowledged transaction, using 1st client model instance, set linear*/
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Sending msg: UnAck linear Set: lightness: %d Tid: %d Trans time: %d ms Delay: %d ms\n",
linear_set_params.lightness, linear_set_params.tid,
transition_params.transition_time_ms,
transition_params.delay_ms);
status = light_lightness_client_linear_set_unack(&m_clients[client],
&linear_set_params,
&transition_params, 0);
break;
/* Following cases are accessible only via RTT input */
case 5:
/* lightness last get */
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "requesting last lightness\n");
status = light_lightness_client_last_get(&m_clients[client]);
break;
case 6:
/* lightness default get */
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "requesting default lightness\n");
status = light_lightness_client_default_get(&m_clients[client]);
break;
case 7:
/* lightness range get */
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "requesting range lightness\n");
status = light_lightness_client_range_get(&m_clients[client]);
break;
case 8:
/* get lightness (actual) status */
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "requesting lightness status\n");
status = light_lightness_client_get(&m_clients[client]);
break;
case 9:
/* get lightness linear status */
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "requesting lightness linear status\n");
status = light_lightness_client_linear_get(&m_clients[client]);
break;
case 0xa:
case 0xb:
/* set the light lightness default */
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Sending msg: UnAck Default Set: default: %d \n",
default_set_params.lightness);
status = light_lightness_client_default_set_unack(&m_clients[client],
&default_set_params, 0);
break;
case 0xc:
case 0xd:
case 0xe:
case 0xf:
/* set the light lightness range */
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Sending msg: UnAck Range Set: range: %d %d \n",
range_set_params.range_min, range_set_params.range_max);
status = light_lightness_client_range_set_unack(&m_clients[client],
&range_set_params, 0);
break;
case 0x10:
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Sending msg: linear set: Lightness: %d Tid: %d Trans time: %d ms Delay: %d ms\n",
linear_set_params.lightness, linear_set_params.tid,
transition_params.transition_time_ms,
transition_params.delay_ms);
(void)access_model_reliable_cancel(m_clients[client].model_handle);
status = light_lightness_client_linear_set(&m_clients[client],
&linear_set_params,
&transition_params);
break;
/* Switch between each client instance */
case 0x11:
client++;
client = (client < CLIENT_MODEL_INSTANCE_COUNT) ? client : 0;
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Switching to client instance: %d\n", client);
break;
default:
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
break;
}
switch (status)
{
case NRF_SUCCESS:
break;
case NRF_ERROR_NO_MEM:
case NRF_ERROR_BUSY:
case NRF_ERROR_INVALID_STATE:
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Client %u cannot send: status: %d\n", client, status);
hal_led_blink_ms(LEDS_MASK, LED_BLINK_SHORT_INTERVAL_MS, LED_BLINK_CNT_NO_REPLY);
break;
case NRF_ERROR_INVALID_PARAM:
/* Publication not enabled for this client. One (or more) of the following is wrong:
* - An application key is missing, or there is no application key bound to the model
* - The client does not have its publication state set
*
* It is the provisioner that adds an application key, binds it to the model and sets
* the model's publication state.
*/
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Publication not configured for client %u\n", client);
break;
default:
ERROR_CHECK(status);
break;
}
}
static void rtt_input_handler(int key)
{
uint32_t button_number = UINT32_MAX;
if (key >= '1' && key <= '9')
{
button_number = key - '1';
button_event_handler(button_number);
}
if (key >= 'a' && key <= 'h')
{
button_number = key - 'a' + 0xa;
button_event_handler(button_number);
}
if (button_number == UINT32_MAX)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
}
}
static void models_init_cb(void)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing and adding models\n");
for (uint32_t i = 0; i < CLIENT_MODEL_INSTANCE_COUNT; ++i)
{
m_clients[i].settings.p_callbacks = &client_cbs;
m_clients[i].settings.timeout = 0;
m_clients[i].settings.force_segmented = APP_FORCE_SEGMENTATION;
m_clients[i].settings.transmic_size = APP_MIC_SIZE;
ERROR_CHECK(light_lightness_client_init(&m_clients[i], i + 1));
}
}
static void mesh_init(void)
{
mesh_stack_init_params_t init_params =
{
.core.irq_priority = NRF_MESH_IRQ_PRIORITY_LOWEST,
.core.lfclksrc = DEV_BOARD_LF_CLK_CFG,
.core.p_uuid = NULL,
.models.models_init_cb = models_init_cb,
.models.config_server_cb = config_server_evt_cb
};
uint32_t status = mesh_stack_init(&init_params, &m_device_provisioned);
switch (status)
{
case NRF_ERROR_INVALID_DATA:
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO,
"Data in the persistent memory was corrupted. Device starts as unprovisioned.\n");
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Reset device before starting of the provisioning process.\n");
break;
case NRF_SUCCESS:
break;
default:
APP_ERROR_CHECK(status);
}
}
static void initialize(void)
{
__LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS, LOG_LEVEL_INFO, LOG_CALLBACK_DEFAULT);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- BLE Mesh Light Lightness Client Demo -----\n");
ERROR_CHECK(app_timer_init());
hal_leds_init();
#if BUTTON_BOARD
ERROR_CHECK(hal_buttons_init(button_event_handler));
#endif
ble_stack_init();
#if MESH_FEATURE_GATT_ENABLED
gap_params_init();
conn_params_init();
#endif
mesh_init();
}
static void start(void)
{
rtt_input_enable(rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
if (!m_device_provisioned)
{
static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
mesh_provisionee_start_params_t prov_start_params =
{
.p_static_data = static_auth_data,
.prov_complete_cb = provisioning_complete_cb,
.prov_device_identification_start_cb = device_identification_start_cb,
.prov_device_identification_stop_cb = NULL,
.prov_abort_cb = provisioning_aborted_cb,
.p_device_uri = EX_URI_LL_CLIENT
};
ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
}
else
{
unicast_address_print();
}
mesh_app_uuid_print(nrf_mesh_configure_device_uuid_get());
ERROR_CHECK(mesh_stack_start());
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
hal_led_mask_set(LEDS_MASK, LED_MASK_STATE_OFF);
hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_START);
}
int main(void)
{
initialize();
start();
for (;;)
{
(void)sd_app_evt_wait();
}
}
| 41.62963 | 140 | 0.626483 | [
"mesh",
"model"
] |
898fd457be776ee1ef512f5041fc5366b07b288e | 12,712 | c | C | oor/fwd_policies/balancing_locators.c | MiquelFerriol/OOR_CBA | 4036c6623d618a6538edd1c194315c5ed0aae7cd | [
"Apache-2.0"
] | null | null | null | oor/fwd_policies/balancing_locators.c | MiquelFerriol/OOR_CBA | 4036c6623d618a6538edd1c194315c5ed0aae7cd | [
"Apache-2.0"
] | null | null | null | oor/fwd_policies/balancing_locators.c | MiquelFerriol/OOR_CBA | 4036c6623d618a6538edd1c194315c5ed0aae7cd | [
"Apache-2.0"
] | null | null | null | /*
*
* Copyright (C) 2011, 2015 Cisco Systems, Inc.
* Copyright (C) 2015 CBA research group, Technical University of Catalonia.
*
* 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 "balancing_locators.h"
#include "fwd_addr_func.h"
#include "fwd_utils.h"
#include "../lib/oor_log.h"
static void balancing_locators_vecs_reset(balancing_locators_vecs *blv);
static int select_best_priority_locators(glist_t *loct_list, locator_t **selected_locators,
uint8_t is_mce);
static locator_t **set_balancing_vector(locator_t **locators, int total_weight, int hcf,
int *locators_vec_length);
static inline void get_hcf_locators_weight(locator_t **locators, int *total_weight,int *hcf);
static int highest_common_factor(int a, int b);
static inline balancing_locators_vecs *
balancing_locators_vecs_new()
{
balancing_locators_vecs * bal_loct_vec;
bal_loct_vec = (balancing_locators_vecs *)xzalloc(sizeof(balancing_locators_vecs));
if (bal_loct_vec == NULL){
OOR_LOG(LWRN, "balancing_locators_vecs_new: Couldn't allocate memory for balancing_locators_vecs");
}
return (bal_loct_vec);
}
void *
balancing_locators_vecs_new_init(mapping_t *map, glist_t *loc_loct, uint8_t is_mce)
{
balancing_locators_vecs *bal_vec;
bal_vec = balancing_locators_vecs_new();
if (!bal_vec){
return (NULL);
}
if (balancing_vectors_calculate(bal_vec, map, loc_loct, is_mce) != GOOD){
balancing_locators_vecs_del(bal_vec);
OOR_LOG(LDBG_2,"balancing_locators_vecs_new_init: Error calculating balancing vectors");
return (NULL);
}
return((void *)bal_vec);
}
void
balancing_locators_vecs_del(void * bal_vec)
{
balancing_locators_vecs_reset((balancing_locators_vecs *)bal_vec);
free((balancing_locators_vecs *)bal_vec);
}
/* Print balancing locators vector information */
void
balancing_locators_vec_dump(balancing_locators_vecs b_locators_vecs,
mapping_t *mapping, int log_level)
{
int ctr;
char str[3000];
if (is_loggable(log_level)) {
OOR_LOG(log_level, "Balancing locator vector for %s: ",
lisp_addr_to_char(mapping_eid(mapping)));
sprintf(str, " IPv4 locators vector (%d locators): ",
b_locators_vecs.v4_locators_vec_length);
for (ctr = 0; ctr < b_locators_vecs.v4_locators_vec_length; ctr++) {
if (strlen(str) > 2850) {
sprintf(str + strlen(str), " ...");
break;
}
sprintf(str + strlen(str), " %s ",
lisp_addr_to_char(
b_locators_vecs.v4_balancing_locators_vec[ctr]->addr));
}
OOR_LOG(log_level, "%s", str);
sprintf(str, " IPv6 locators vector (%d locators): ",
b_locators_vecs.v6_locators_vec_length);
for (ctr = 0; ctr < b_locators_vecs.v6_locators_vec_length; ctr++) {
if (strlen(str) > 2900) {
sprintf(str + strlen(str), " ...");
break;
}
sprintf(str + strlen(str), " %s ",
lisp_addr_to_char(
b_locators_vecs.v6_balancing_locators_vec[ctr]->addr));
}
OOR_LOG(log_level, "%s", str);
sprintf(str, " IPv4 & IPv6 locators vector (%d locators): ",
b_locators_vecs.locators_vec_length);
for (ctr = 0; ctr < b_locators_vecs.locators_vec_length; ctr++) {
if (strlen(str) > 2950) {
sprintf(str + strlen(str), " ...");
break;
}
sprintf(str + strlen(str), " %s ",
lisp_addr_to_char(
b_locators_vecs.balancing_locators_vec[ctr]->addr));
}
OOR_LOG(log_level, "%s", str);
}
}
/*
* Calculate the vectors used to distribute the load from the priority and weight of the locators of the mapping
*/
int
balancing_vectors_calculate(balancing_locators_vecs *blv, mapping_t * map, glist_t *loc_loct, uint8_t is_mce)
{
// Store locators with same priority. Maximum 32 locators (33 to no get out of array)
locator_t *locators[3][33];
// Aux list to classify all locators between IP4 and IPv6
glist_t *ipv4_loct_list = glist_new();
glist_t *ipv6_loct_list = glist_new();
int min_priority[2] = { 255, 255 };
int total_weight[3] = { 0, 0, 0 };
int hcf[3] = { 0, 0, 0 };
int ctr = 0;
int ctr1 = 0;
int pos = 0;
locators[0][0] = NULL;
locators[1][0] = NULL;
balancing_locators_vecs_reset(blv);
locators_classify_in_4_6(map,loc_loct,ipv4_loct_list,ipv6_loct_list, laddr_get_fwd_ip_addr);
/* Fill the locator balancing vec using only IPv4 locators and according
* to their priority and weight */
if (glist_size(ipv4_loct_list) != 0)
{
min_priority[0] = select_best_priority_locators(
ipv4_loct_list, locators[0], is_mce);
if (min_priority[0] != UNUSED_RLOC_PRIORITY) {
get_hcf_locators_weight(locators[0], &total_weight[0], &hcf[0]);
blv->v4_balancing_locators_vec = set_balancing_vector(
locators[0], total_weight[0], hcf[0],
&(blv->v4_locators_vec_length));
}
}
/* Fill the locator balancing vec using only IPv6 locators and according
* to their priority and weight*/
if (glist_size(ipv6_loct_list) != 0)
{
min_priority[1] = select_best_priority_locators(
ipv6_loct_list, locators[1], is_mce);
if (min_priority[1] != UNUSED_RLOC_PRIORITY) {
get_hcf_locators_weight(locators[1], &total_weight[1], &hcf[1]);
blv->v6_balancing_locators_vec = set_balancing_vector(
locators[1], total_weight[1], hcf[1],
&(blv->v6_locators_vec_length));
}
}
/* Fill the locator balancing vec using IPv4 and IPv6 locators and according
* to their priority and weight*/
if (blv->v4_balancing_locators_vec != NULL
&& blv->v6_balancing_locators_vec != NULL) {
//Only IPv4 locators are involved (due to priority reasons)
if (min_priority[0] < min_priority[1]) {
blv->balancing_locators_vec =
blv->v4_balancing_locators_vec;
blv->locators_vec_length =
blv->v4_locators_vec_length;
} //Only IPv6 locators are involved (due to priority reasons)
else if (min_priority[0] > min_priority[1]) {
blv->balancing_locators_vec =
blv->v6_balancing_locators_vec;
blv->locators_vec_length =
blv->v6_locators_vec_length;
} //IPv4 and IPv6 locators are involved
else {
hcf[2] = highest_common_factor(hcf[0], hcf[1]);
total_weight[2] = total_weight[0] + total_weight[1];
for (ctr = 0; ctr < 2; ctr++) {
ctr1 = 0;
while (locators[ctr][ctr1] != NULL) {
locators[2][pos] = locators[ctr][ctr1];
ctr1++;
pos++;
}
}
locators[2][pos] = NULL;
blv->balancing_locators_vec = set_balancing_vector(
locators[2], total_weight[2], hcf[2],
&(blv->locators_vec_length));
}
}
balancing_locators_vec_dump(*blv, map, LDBG_1);
glist_destroy(ipv4_loct_list);
glist_destroy(ipv6_loct_list);
return (GOOD);
}
/* Initialize to 0 balancing_locators_vecs */
static void
balancing_locators_vecs_reset(balancing_locators_vecs *blv)
{
/* IPv4 locators more priority -> IPv4_IPv6 vector = IPv4 locator vector
* IPv6 locators more priority -> IPv4_IPv6 vector = IPv4 locator vector */
if (blv->balancing_locators_vec != NULL
&& blv->balancing_locators_vec
!= blv->v4_balancing_locators_vec
&& blv->balancing_locators_vec
!= blv->v6_balancing_locators_vec) {
free(blv->balancing_locators_vec);
}
if (blv->v4_balancing_locators_vec != NULL) {
free(blv->v4_balancing_locators_vec);
}
if (blv->v6_balancing_locators_vec != NULL) {
free(blv->v6_balancing_locators_vec);
}
blv->v4_balancing_locators_vec = NULL;
blv->v4_locators_vec_length = 0;
blv->v6_balancing_locators_vec = NULL;
blv->v6_locators_vec_length = 0;
blv->balancing_locators_vec = NULL;
blv->locators_vec_length = 0;
}
static int
select_best_priority_locators(glist_t *loct_list, locator_t **selected_locators, uint8_t is_mce)
{
glist_entry_t *it_loct;
locator_t *locator;
int min_priority = UNUSED_RLOC_PRIORITY;
int pos = 0;
if (glist_size(loct_list) == 0){
return (BAD);
}
glist_for_each_entry(it_loct,loct_list){
locator = (locator_t *)glist_entry_data(it_loct);
/* Only use locators with status UP */
if (locator_state(locator) == DOWN
|| locator_priority(locator) == UNUSED_RLOC_PRIORITY ) {
continue;
}
/* For local mappings, the locator should be local */
if (!is_mce && locator_L_bit(locator) == 0){
continue;
}
/* If priority of the locator equal to min_priority, then add the
* locator to the list */
if (locator_priority(locator) == min_priority) {
selected_locators[pos] = locator;
pos++;
selected_locators[pos] = NULL;
}
/* If priority of the locator is minor than the min_priority, then
* min_priority and list of rlocs is updated */
if (locator_priority(locator) < min_priority) {
pos = 0;
min_priority = locator_priority(locator);
selected_locators[pos] = locator;
pos++;
selected_locators[pos] = NULL;
}
}
return (min_priority);
}
static locator_t **
set_balancing_vector(locator_t **locators, int total_weight, int hcf,
int *locators_vec_length)
{
locator_t **balancing_locators_vec;
int vector_length = 0;
int used_pos = 0;
int ctr = 0;
int ctr1 = 0;
int pos = 0;
if (total_weight != 0) {
/* Length of the dynamic vector */
vector_length = total_weight / hcf;
} else {
/* If all locators have weight equal to 0, we assign one position for
* each locator */
while (locators[ctr] != NULL) {
ctr++;
}
vector_length = ctr;
ctr = 0;
}
/* Reserve memory for the dynamic vector */
balancing_locators_vec = xmalloc(vector_length * sizeof(locator_t *));
*locators_vec_length = vector_length;
while (locators[ctr] != NULL) {
if (total_weight != 0) {
used_pos = locator_weight(locators[ctr]) / hcf;
} else {
/* If all locators has weight equal to 0, we assign one position
* for each locator. Simetric balancing */
used_pos = 1;
}
ctr1 = 0;
for (ctr1 = 0; ctr1 < used_pos; ctr1++) {
balancing_locators_vec[pos] = locators[ctr];
pos++;
}
ctr++;
}
return (balancing_locators_vec);
}
static inline void
get_hcf_locators_weight(locator_t **locators, int *total_weight,
int *hcf)
{
int ctr = 0;
int weight = 0;
int tmp_hcf = 0;
if (locators[0] != NULL) {
tmp_hcf = locator_weight(locators[0]);
while (locators[ctr] != NULL) {
weight = weight + locator_weight(locators[ctr]);
tmp_hcf = highest_common_factor(tmp_hcf, locator_weight(locators[ctr]));
ctr++;
}
}
*total_weight = weight;
*hcf = tmp_hcf;
}
static int
highest_common_factor(int a, int b)
{
int c;
if (b == 0) {
return a;
}
if (a == 0) {
return b;
}
if (a < b) {
c = a;
a = b;
a = c;
}
c = 1;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
return (a);
}
| 32.594872 | 112 | 0.603446 | [
"vector"
] |
8992d5dd2573a58013b5217596769d405b950ffd | 1,902 | h | C | kubernetes/model/io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry.h | zouxiaoliang/nerv-kubernetes-client-c | 07528948c643270fd757d38edc68da8c9628ee7a | [
"Apache-2.0"
] | null | null | null | kubernetes/model/io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry.h | zouxiaoliang/nerv-kubernetes-client-c | 07528948c643270fd757d38edc68da8c9628ee7a | [
"Apache-2.0"
] | null | null | null | kubernetes/model/io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry.h | zouxiaoliang/nerv-kubernetes-client-c | 07528948c643270fd757d38edc68da8c9628ee7a | [
"Apache-2.0"
] | null | null | null | /*
* io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry.h
*
* ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to.
*/
#ifndef _io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_H_
#define _io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
typedef struct io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_t io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_t;
#include "object.h"
typedef struct io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_t {
char *api_version; // string
char *fields_type; // string
object_t *fields_v1; //object
char *manager; // string
char *operation; // string
char *time; //date time
} io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_t;
io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_t *io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_create(
char *api_version,
char *fields_type,
object_t *fields_v1,
char *manager,
char *operation,
char *time
);
void io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_free(io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_t *io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry);
io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_t *io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_parseFromJSON(cJSON *io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entryJSON);
cJSON *io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_convertToJSON(io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_t *io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry);
#endif /* _io_k8s_apimachinery_pkg_apis_meta_v1_managed_fields_entry_H_ */
| 38.816327 | 203 | 0.851735 | [
"object"
] |
899ca28a88dc700d6e8269c575afe390f25e84f4 | 5,948 | c | C | melang/print/mln_lang_print.c | Water-Melon/Melon | 78a7714973d8a313d99b4e410946ab6fef8b7fb0 | [
"BSD-3-Clause"
] | 237 | 2015-03-06T02:57:56.000Z | 2022-03-30T03:27:51.000Z | melang/print/mln_lang_print.c | GogeBlue/Melon | 639c531909d5bc9ea97deb3eefa1ed302c53bbf7 | [
"BSD-3-Clause"
] | 2 | 2021-08-25T09:49:54.000Z | 2021-09-08T07:48:12.000Z | melang/print/mln_lang_print.c | GogeBlue/Melon | 639c531909d5bc9ea97deb3eefa1ed302c53bbf7 | [
"BSD-3-Clause"
] | 18 | 2017-09-22T02:53:41.000Z | 2022-02-22T01:34:51.000Z |
/*
* Copyright (C) Niklaus F.Schen.
*/
#include "print/mln_lang_print.h"
#include "mln_log.h"
#ifdef __DEBUG__
#include <assert.h>
#define ASSERT(x) assert(x)
#else
#define ASSERT(x);
#endif
static mln_lang_var_t *mln_lang_print_process(mln_lang_ctx_t *ctx);
static int mln_lang_print_array_cmp(const void *addr1, const void *addr2);
static void mln_lang_print_array(mln_lang_array_t *arr, mln_rbtree_t *check);
static int mln_lang_print_array_elem(mln_rbtree_node_t *node, void *rn_data, void *udata);
int mln_lang_print(mln_lang_ctx_t *ctx)
{
mln_lang_val_t *val;
mln_lang_var_t *var;
mln_lang_func_detail_t *func;
mln_string_t funcname = mln_string("mln_print");
mln_string_t v = mln_string("var");
if ((func = mln_lang_func_detail_new(ctx, M_FUNC_INTERNAL, mln_lang_print_process, NULL, NULL)) == NULL) {
mln_lang_errmsg(ctx, "No memory.");
return -1;
}
if ((val = mln_lang_val_new(ctx, M_LANG_VAL_TYPE_NIL, NULL)) == NULL) {
mln_lang_errmsg(ctx, "No memory.");
mln_lang_func_detail_free(func);
return -1;
}
if ((var = mln_lang_var_new(ctx, &v, M_LANG_VAR_NORMAL, val, NULL)) == NULL) {
mln_lang_errmsg(ctx, "No memory.");
mln_lang_val_free(val);
mln_lang_func_detail_free(func);
return -1;
}
func->args_head = func->args_tail = var;
func->nargs = 1;
if ((val = mln_lang_val_new(ctx, M_LANG_VAL_TYPE_FUNC, func)) == NULL) {
mln_lang_errmsg(ctx, "No memory.");
mln_lang_func_detail_free(func);
return -1;
}
if ((var = mln_lang_var_new(ctx, &funcname, M_LANG_VAR_NORMAL, val, NULL)) == NULL) {
mln_lang_errmsg(ctx, "No memory.");
mln_lang_val_free(val);
return -1;
}
if (mln_lang_symbol_node_join(ctx, M_LANG_SYMBOL_VAR, var) < 0) {
mln_lang_errmsg(ctx, "No memory.");
mln_lang_var_free(var);
return -1;
}
return 0;
}
static mln_lang_var_t *mln_lang_print_process(mln_lang_ctx_t *ctx)
{
mln_s32_t type;
mln_lang_val_t *val;
mln_lang_var_t *ret_var;
mln_string_t var = mln_string("var");
mln_lang_symbol_node_t *sym;
if ((sym = mln_lang_symbol_node_search(ctx, &var, 1)) == NULL) {
ASSERT(0);
mln_lang_errmsg(ctx, "Argument missing.");
return NULL;
}
ASSERT(sym->type == M_LANG_SYMBOL_VAR);
type = mln_lang_var_val_type_get(sym->data.var);
val = sym->data.var->val;
switch (type) {
case M_LANG_VAL_TYPE_NIL:
mln_log(none, "nil\n");
break;
case M_LANG_VAL_TYPE_INT:
mln_log(none, "%i\n", val->data.i);
break;
case M_LANG_VAL_TYPE_BOOL:
mln_log(none, "%s\n", val->data.b?"true":"false");
break;
case M_LANG_VAL_TYPE_REAL:
mln_log(none, "%f\n", val->data.f);
break;
case M_LANG_VAL_TYPE_STRING:
mln_log(none, "%S\n", val->data.s);
break;
case M_LANG_VAL_TYPE_OBJECT:
mln_log(none, "OBJECT\n");
break;
case M_LANG_VAL_TYPE_FUNC:
mln_log(none, "FUNCTION\n");
break;
case M_LANG_VAL_TYPE_ARRAY:
{
struct mln_rbtree_attr rbattr;
mln_rbtree_t *check;
rbattr.pool = ctx->pool;
rbattr.cmp = mln_lang_print_array_cmp;
rbattr.data_free = NULL;
rbattr.cache = 0;
if ((check = mln_rbtree_init(&rbattr)) == NULL) {
mln_lang_errmsg(ctx, "No memory.\n");
return NULL;
}
mln_lang_print_array(val->data.array, check);
mln_log(none, "\n");
mln_rbtree_destroy(check);
break;
}
default:
mln_log(none, "<type error>\n");
break;
}
if ((ret_var = mln_lang_var_create_true(ctx, NULL)) == NULL) {
mln_lang_errmsg(ctx, "No memory.");
return NULL;
}
return ret_var;
}
static int mln_lang_print_array_cmp(const void *addr1, const void *addr2)
{
return (mln_s8ptr_t)addr1 - (mln_s8ptr_t)addr2;
}
static void mln_lang_print_array(mln_lang_array_t *arr, mln_rbtree_t *check)
{
mln_rbtree_node_t *rn = mln_rbtree_search(check, check->root, arr);
if (!mln_rbtree_null(rn, check)) {
mln_log(none, "[...]");
return;
}
rn = mln_rbtree_node_new(check, arr);
if (rn == NULL) return;
mln_rbtree_insert(check, rn);
mln_log(none, "[");
mln_rbtree_scan_all(arr->elems_index, mln_lang_print_array_elem, check);
mln_log(none, "]");
}
static int mln_lang_print_array_elem(mln_rbtree_node_t *node, void *rn_data, void *udata)
{
mln_lang_array_elem_t *elem = (mln_lang_array_elem_t *)rn_data;
mln_rbtree_t *check = (mln_rbtree_t *)udata;
mln_lang_var_t *var = elem->value;
mln_lang_val_t *val = var->val;
mln_s32_t type = mln_lang_var_val_type_get(var);
switch (type) {
case M_LANG_VAL_TYPE_NIL:
mln_log(none, "nil, ");
break;
case M_LANG_VAL_TYPE_INT:
mln_log(none, "%i, ", val->data.i);
break;
case M_LANG_VAL_TYPE_BOOL:
mln_log(none, "%s, ", val->data.b?"true":"false");
break;
case M_LANG_VAL_TYPE_REAL:
mln_log(none, "%f, ", val->data.f);
break;
case M_LANG_VAL_TYPE_STRING:
mln_log(none, "%S, ", val->data.s);
break;
case M_LANG_VAL_TYPE_OBJECT:
mln_log(none, "OBJECT, ");
break;
case M_LANG_VAL_TYPE_FUNC:
mln_log(none, "FUNCTION, ");
break;
case M_LANG_VAL_TYPE_ARRAY:
mln_lang_print_array(val->data.array, check);
mln_log(none, ", ");
break;
default:
mln_log(none, "<type error>, ");
break;
}
return 0;
}
| 31.305263 | 110 | 0.597344 | [
"object"
] |
89a4775950d4fa1c3375d87c991c2542ee1314de | 9,537 | h | C | app/Remeshing/src/remeshing/UniformRemeshing.h | wildmeshing/wildmeshing-toolkit | 7f4c60e5a6d366d9c3850b720b42b610e10600c2 | [
"MIT"
] | 8 | 2021-12-10T08:26:45.000Z | 2022-03-24T00:19:41.000Z | app/Remeshing/src/remeshing/UniformRemeshing.h | wildmeshing/wildmeshing-toolkit | 7f4c60e5a6d366d9c3850b720b42b610e10600c2 | [
"MIT"
] | 86 | 2021-12-03T01:46:30.000Z | 2022-03-23T19:33:17.000Z | app/Remeshing/src/remeshing/UniformRemeshing.h | wildmeshing/wildmeshing-toolkit | 7f4c60e5a6d366d9c3850b720b42b610e10600c2 | [
"MIT"
] | 2 | 2021-11-26T08:29:38.000Z | 2022-01-03T22:10:42.000Z | #pragma once
#include <wmtk/ConcurrentTriMesh.h>
#include <wmtk/utils/PartitionMesh.h>
#include <wmtk/utils/VectorUtils.h>
// clang-format off
#include <wmtk/utils/DisableWarnings.hpp>
#include <igl/write_triangle_mesh.h>
#include <tbb/concurrent_priority_queue.h>
#include <tbb/concurrent_vector.h>
#include <tbb/enumerable_thread_specific.h>
#include <tbb/parallel_for.h>
#include <tbb/task_group.h>
#include <tbb/parallel_sort.h>
#include <fastenvelope/FastEnvelope.h>
#include <wmtk/utils/EnableWarnings.hpp>
// clang-format on
#include <memory>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include <atomic>
#include <queue>
#include <sec/envelope/SampleEnvelope.hpp>
#include "wmtk/AttributeCollection.hpp"
namespace remeshing {
struct VertexAttributes
{
Eigen::Vector3d pos;
// TODO: in fact, partition id should not be vertex attribute, it is a fixed marker to distinguish tuple/operations.
size_t partition_id;
bool freeze = false;
};
class UniformRemeshing : public wmtk::ConcurrentTriMesh
{
public:
sample_envelope::SampleEnvelope m_envelope;
bool m_has_envelope = false;
using VertAttCol = wmtk::AttributeCollection<VertexAttributes>;
VertAttCol vertex_attrs;
int NUM_THREADS = 1;
int retry_limit = 10;
UniformRemeshing(std::vector<Eigen::Vector3d> _m_vertex_positions, int num_threads = 1, bool use_exact = true)
: NUM_THREADS(num_threads)
{
m_envelope.use_exact = use_exact;
p_vertex_attrs = &vertex_attrs;
vertex_attrs.resize(_m_vertex_positions.size());
for (auto i = 0; i < _m_vertex_positions.size(); i++)
vertex_attrs[i] = {_m_vertex_positions[i], 0};
}
void create_mesh(
size_t n_vertices,
const std::vector<std::array<size_t, 3>>& tris,
const std::vector<size_t>& frozen_verts = std::vector<size_t>(),
bool m_freeze = true,
double eps = 0)
{
wmtk::ConcurrentTriMesh::create_mesh(n_vertices, tris);
std::vector<Eigen::Vector3d> V(n_vertices);
std::vector<Eigen::Vector3i> F(tris.size());
for (auto i = 0; i < V.size(); i++) {
V[i] = vertex_attrs[i].pos;
}
for (int i = 0; i < F.size(); ++i) F[i] << tris[i][0], tris[i][1], tris[i][2];
if (eps > 0) {
m_envelope.init(V, F, eps);
m_has_envelope = true;
} else
m_envelope.init(V, F, 0.0);
partition_mesh_morton();
for (auto v : frozen_verts) vertex_attrs[v].freeze = true;
if (m_freeze) {
for (auto e : get_edges()) {
if (is_boundary_edge(e)) {
vertex_attrs[e.vid(*this)].freeze = true;
vertex_attrs[e.switch_vertex(*this).vid(*this)].freeze = true;
}
}
}
}
~UniformRemeshing() {}
struct PositionInfoCache
{
Eigen::Vector3d v1p;
Eigen::Vector3d v2p;
};
tbb::enumerable_thread_specific<PositionInfoCache> position_cache;
void cache_edge_positions(const Tuple& t)
{
position_cache.local().v1p = vertex_attrs[t.vid(*this)].pos;
position_cache.local().v2p = vertex_attrs[t.switch_vertex(*this).vid(*this)].pos;
}
bool invariants(const std::vector<Tuple>& new_tris) override
{
if (m_has_envelope) {
for (auto& t : new_tris) {
std::array<Eigen::Vector3d, 3> tris;
auto vs = t.oriented_tri_vertices(*this);
for (auto j = 0; j < 3; j++) tris[j] = vertex_attrs[vs[j].vid(*this)].pos;
if (m_envelope.is_outside(tris)) {
return false;
}
}
}
return true;
}
void partition_mesh()
{
auto m_vertex_partition_id = partition_TriMesh(*this, NUM_THREADS);
for (auto i = 0; i < m_vertex_partition_id.size(); i++)
vertex_attrs[i].partition_id = m_vertex_partition_id[i];
}
void partition_mesh_morton()
{
if (NUM_THREADS == 0) return;
wmtk::logger().info("Number of parts: {} by morton", NUM_THREADS);
tbb::task_arena arena(NUM_THREADS);
arena.execute([&] {
std::vector<Eigen::Vector3d> V_v(vert_capacity());
tbb::parallel_for(
tbb::blocked_range<int>(0, V_v.size()),
[&](tbb::blocked_range<int> r) {
for (int i = r.begin(); i < r.end(); i++) {
V_v[i] = vertex_attrs[i].pos;
}
});
struct sortstruct
{
int order;
Resorting::MortonCode64 morton;
};
std::vector<sortstruct> list_v;
list_v.resize(V_v.size());
const int multi = 1000;
// since the morton code requires a correct scale of input vertices,
// we need to scale the vertices if their coordinates are out of range
std::vector<Eigen::Vector3d> V = V_v; // this is for rescaling vertices
Eigen::Vector3d vmin, vmax;
vmin = V.front();
vmax = V.front();
for (size_t j = 0; j < V.size(); j++) {
for (int i = 0; i < 3; i++) {
vmin(i) = std::min(vmin(i), V[j](i));
vmax(i) = std::max(vmax(i), V[j](i));
}
}
Eigen::Vector3d center = (vmin + vmax) / 2;
tbb::parallel_for(tbb::blocked_range<int>(0, V.size()), [&](tbb::blocked_range<int> r) {
for (int i = r.begin(); i < r.end(); i++) {
V[i] = V[i] - center;
}
});
Eigen::Vector3d scale_point =
vmax - center; // after placing box at origin, vmax and vmin are symetric.
double xscale, yscale, zscale;
xscale = fabs(scale_point[0]);
yscale = fabs(scale_point[1]);
zscale = fabs(scale_point[2]);
double scale = std::max(std::max(xscale, yscale), zscale);
if (scale > 300) {
tbb::parallel_for(
tbb::blocked_range<int>(0, V.size()),
[&](tbb::blocked_range<int> r) {
for (int i = r.begin(); i < r.end(); i++) {
V[i] = V[i] / scale;
}
});
}
tbb::parallel_for(tbb::blocked_range<int>(0, V.size()), [&](tbb::blocked_range<int> r) {
for (int i = r.begin(); i < r.end(); i++) {
list_v[i].morton = Resorting::MortonCode64(
int(V[i][0] * multi),
int(V[i][1] * multi),
int(V[i][2] * multi));
list_v[i].order = i;
}
});
const auto morton_compare = [](const sortstruct& a, const sortstruct& b) {
return (a.morton < b.morton);
};
tbb::parallel_sort(list_v.begin(), list_v.end(), morton_compare);
int interval = list_v.size() / NUM_THREADS + 1;
tbb::parallel_for(
tbb::blocked_range<int>(0, list_v.size()),
[&](tbb::blocked_range<int> r) {
for (int i = r.begin(); i < r.end(); i++) {
vertex_attrs[list_v[i].order].partition_id = i / interval;
}
});
});
}
Eigen::Vector3d smooth(const Tuple& t);
Eigen::Vector3d tangential_smooth(const Tuple& t);
bool is_edge_freeze(const Tuple& t)
{
if (vertex_attrs[t.vid(*this)].freeze ||
vertex_attrs[t.switch_vertex(*this).vid(*this)].freeze)
return true;
return false;
}
bool collapse_edge_before(const Tuple& t) override
{
if (!TriMesh::collapse_edge_before(t)) return false;
if (is_edge_freeze(t)) return false;
cache_edge_positions(t);
return true;
}
bool collapse_edge_after(const Tuple& t) override;
bool swap_edge_before(const Tuple& t) override
{
if (!TriMesh::swap_edge_before(t)) return false;
if (is_edge_freeze(t)) return false;
return true;
}
bool swap_edge_after(const Tuple& t) override;
std::vector<TriMesh::Tuple> new_edges_after(const std::vector<TriMesh::Tuple>& t) const;
std::vector<TriMesh::Tuple> new_edges_after_swap(const TriMesh::Tuple& t) const;
bool split_edge_before(const Tuple& t) override
{
if (!TriMesh::split_edge_before(t)) return false;
if (is_edge_freeze(t)) return false;
cache_edge_positions(t);
return true;
}
bool split_edge_after(const Tuple& t) override;
bool smooth_before(const Tuple& t) override
{
if (vertex_attrs[t.vid(*this)].freeze) return false;
return true;
}
bool smooth_after(const Tuple& t) override;
double compute_edge_cost_collapse(const TriMesh::Tuple& t, double L) const;
double compute_edge_cost_split(const TriMesh::Tuple& t, double L) const;
double compute_vertex_valence(const TriMesh::Tuple& t) const;
std::vector<double> average_len_valen();
bool split_remeshing(double L);
bool collapse_remeshing(double L);
bool swap_remeshing();
bool uniform_remeshing(double L, int interations);
bool write_triangle_mesh(std::string path);
};
} // namespace remeshing
| 32.660959 | 120 | 0.557932 | [
"geometry",
"vector"
] |
89af761a7d85b141f5c1ae0b2edd01442ea77f54 | 1,051 | h | C | frameworks/cocos2d-x/cocos/flash/PandoraLib/NotificationDirector.h | xslkim/FlashEngine | 30aedbe92447bcd5bd3c8abd7831776f67f8df46 | [
"MIT"
] | 1 | 2022-03-05T09:28:51.000Z | 2022-03-05T09:28:51.000Z | frameworks/cocos2d-x/cocos/flash/PandoraLib/NotificationDirector.h | xslkim/FlashEngine | 30aedbe92447bcd5bd3c8abd7831776f67f8df46 | [
"MIT"
] | null | null | null | frameworks/cocos2d-x/cocos/flash/PandoraLib/NotificationDirector.h | xslkim/FlashEngine | 30aedbe92447bcd5bd3c8abd7831776f67f8df46 | [
"MIT"
] | null | null | null | #ifndef __NOTIFICATION_DIRECTOR_H__
#define __NOTIFICATION_DIRECTOR_H__
#include "cocos2d.h"
#include <map>
#include <string>
typedef struct _NotificationItem
{
std::string noteKey;
void* object;
}NotificationItem;
class INotificationDelegate;
class NotificationDirector :public cocos2d::CCObject
{
public:
virtual ~NotificationDirector();
static NotificationDirector* getInstance();
void registerNotification(const char* noteKey, INotificationDelegate* delegate );
void removeNotification(const char* noteKey, INotificationDelegate* delegate);
void removeNotification(const char* noteKey);
void post(const char* noteKey, void* object, bool immediate = true);
void step(float dt);
private:
void doPost(NotificationItem& item);
static NotificationDirector* _instance;
NotificationDirector();
std::multimap<std::string, INotificationDelegate*> _delegateMap;
std::vector<NotificationItem>_itemList;
std::vector<NotificationItem>_itemListBackupOnLock;
bool _itemPostLock;
};
#endif | 25.634146 | 83 | 0.765937 | [
"object",
"vector"
] |
89b170eba4625eb729232989f23e267e26d41946 | 2,800 | c | C | src/afl-performance.c | StarGazerM/AFLplusplus | 15340b85e88c72176ef303950376234abca7ee6b | [
"Apache-2.0"
] | 2,104 | 2020-03-19T16:17:10.000Z | 2022-03-31T16:22:30.000Z | src/afl-performance.c | StarGazerM/AFLplusplus | 15340b85e88c72176ef303950376234abca7ee6b | [
"Apache-2.0"
] | 788 | 2020-03-19T14:54:09.000Z | 2022-03-31T17:38:00.000Z | src/afl-performance.c | StarGazerM/AFLplusplus | 15340b85e88c72176ef303950376234abca7ee6b | [
"Apache-2.0"
] | 518 | 2020-03-21T01:24:55.000Z | 2022-03-30T21:05:53.000Z | /*
Written in 2019 by David Blackman and Sebastiano Vigna (vigna@acm.org)
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>.
This is xoshiro256++ 1.0, one of our all-purpose, rock-solid generators.
It has excellent (sub-ns) speed, a state (256 bits) that is large
enough for any parallel application, and it passes all tests we are
aware of.
For generating just floating-point numbers, xoshiro256+ is even faster.
The state must be seeded so that it is not everywhere zero. If you have
a 64-bit seed, we suggest to seed a splitmix64 generator and use its
output to fill s[].
*/
#include <stdint.h>
#include "afl-fuzz.h"
#include "types.h"
#define XXH_INLINE_ALL
#include "xxhash.h"
#undef XXH_INLINE_ALL
void rand_set_seed(afl_state_t *afl, s64 init_seed) {
afl->init_seed = init_seed;
afl->rand_seed[0] =
hash64((u8 *)&afl->init_seed, sizeof(afl->init_seed), HASH_CONST);
afl->rand_seed[1] = afl->rand_seed[0] ^ 0x1234567890abcdef;
afl->rand_seed[2] = (afl->rand_seed[0] & 0x1234567890abcdef) ^
(afl->rand_seed[1] | 0xfedcba9876543210);
}
#define ROTL(d, lrot) ((d << (lrot)) | (d >> (8 * sizeof(d) - (lrot))))
#ifdef WORD_SIZE_64
// romuDuoJr
inline AFL_RAND_RETURN rand_next(afl_state_t *afl) {
AFL_RAND_RETURN xp = afl->rand_seed[0];
afl->rand_seed[0] = 15241094284759029579u * afl->rand_seed[1];
afl->rand_seed[1] = afl->rand_seed[1] - xp;
afl->rand_seed[1] = ROTL(afl->rand_seed[1], 27);
return xp;
}
#else
// RomuTrio32
inline AFL_RAND_RETURN rand_next(afl_state_t *afl) {
AFL_RAND_RETURN xp = afl->rand_seed[0], yp = afl->rand_seed[1],
zp = afl->rand_seed[2];
afl->rand_seed[0] = 3323815723u * zp;
afl->rand_seed[1] = yp - xp;
afl->rand_seed[1] = ROTL(afl->rand_seed[1], 6);
afl->rand_seed[2] = zp - yp;
afl->rand_seed[2] = ROTL(afl->rand_seed[2], 22);
return xp;
}
#endif
#undef ROTL
/* returns a double between 0.000000000 and 1.000000000 */
inline double rand_next_percent(afl_state_t *afl) {
return (double)(((double)rand_next(afl)) / (double)0xffffffffffffffff);
}
/* we switch from afl's murmur implementation to xxh3 as it is 30% faster -
and get 64 bit hashes instead of just 32 bit. Less collisions! :-) */
#ifdef _DEBUG
u32 hash32(u8 *key, u32 len, u32 seed) {
#else
inline u32 hash32(u8 *key, u32 len, u32 seed) {
#endif
return (u32)XXH64(key, len, seed);
}
#ifdef _DEBUG
u64 hash64(u8 *key, u32 len, u64 seed) {
#else
inline u64 hash64(u8 *key, u32 len, u64 seed) {
#endif
return XXH64(key, len, seed);
}
| 25.688073 | 75 | 0.686071 | [
"solid"
] |
89b2596c403aa13ede0fee39bf11f92975f34ee6 | 4,781 | h | C | src/lib/dns/rdata/generic/detail/nsec3param_common.h | svenauhagen/kea | 8a575ad46dee1487364fad394e7a325337200839 | [
"Apache-2.0"
] | 273 | 2015-01-22T14:14:42.000Z | 2022-03-13T10:27:44.000Z | src/lib/dns/rdata/generic/detail/nsec3param_common.h | jxiaobin/kea | 1987a50a458921f9e5ac84cb612782c07f3b601d | [
"Apache-2.0"
] | 104 | 2015-01-16T16:37:06.000Z | 2021-08-08T19:38:45.000Z | src/lib/dns/rdata/generic/detail/nsec3param_common.h | jxiaobin/kea | 1987a50a458921f9e5ac84cb612782c07f3b601d | [
"Apache-2.0"
] | 133 | 2015-02-21T14:06:39.000Z | 2022-02-27T08:56:40.000Z | // Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef NSEC3PARAM_COMMON_H
#define NSEC3PARAM_COMMON_H 1
#include <dns/master_lexer.h>
#include <util/buffer.h>
#include <stdint.h>
#include <vector>
namespace isc {
namespace dns {
namespace rdata {
namespace generic {
namespace detail {
namespace nsec3 {
/// \file
///
/// This helper module provides some utilities that handle NSEC3 and
/// NSEC3PARAM RDATA. They share the first few fields, and some operations
/// on these fields are sufficiently complicated, so it would make sense to
/// consolidate the processing logic into a single implementation module.
///
/// The functions defined here are essentially private and are only expected
/// to be called from the \c NSEC3 and \c NSEC3PARAM class implementations.
/// \brief Result values of the utilities.
///
/// This structure encapsulates a tuple of NSEC3/NSEC3PARAM algorithm,
/// flags and iterations field values. This is used as the return value
/// of the utility functions defined in this module so the caller can
/// use it for constructing the corresponding RDATA.
struct ParseNSEC3ParamResult {
ParseNSEC3ParamResult(uint8_t param_algorithm, uint8_t param_flags,
uint16_t param_iterations) :
algorithm(param_algorithm), flags(param_flags),
iterations(param_iterations)
{}
const uint8_t algorithm;
const uint8_t flags;
const uint16_t iterations;
};
/// \brief Convert textual representation of NSEC3 parameters.
///
/// This function takes an input MasterLexer that points at a complete
/// textual representation of an NSEC3 or NSEC3PARAM RDATA and parses it
/// extracting the hash algorithm, flags, iterations, and salt fields.
///
/// The first three fields are returned as the return value of this function.
/// The salt will be stored in the given vector. The vector is expected
/// to be empty, but if not, the existing content will be overridden.
///
/// On successful return the given MasterLexer will reach the end of the
/// salt field.
///
/// \exception isc::BadValue The salt is not a valid hex string.
/// \exception InvalidRdataText The given RDATA is otherwise invalid for
/// NSEC3 or NSEC3PARAM fields.
/// \exception MasterLexer::LexerError There was a syntax error reading
/// a field from the MasterLexer.
///
/// \param rrtype_name Either "NSEC3" or "NSEC3PARAM"; used as part of
/// exception messages.
/// \param lexer The MasterLexer to read NSEC3 parameter fields from.
/// \param salt A placeholder for the salt field value of the RDATA.
/// Expected to be empty, but it's not checked (and will be overridden).
///
/// \return The hash algorithm, flags, iterations in the form of
/// ParseNSEC3ParamResult.
ParseNSEC3ParamResult parseNSEC3ParamFromLexer(const char* const rrtype_name,
isc::dns::MasterLexer& lexer,
std::vector<uint8_t>& salt);
/// \brief Extract NSEC3 parameters from wire-format data.
///
/// This function takes an input buffer that stores wire-format NSEC3 or
/// NSEC3PARAM RDATA and parses it extracting the hash algorithm, flags,
/// iterations, and salt fields.
///
/// The first three fields are returned as the return value of this function.
/// The salt will be stored in the given vector. The vector is expected
/// to be empty, but if not, the existing content will be overridden.
///
/// On successful return the input buffer will point to the end of the
/// salt field; rdata_len will be the length of the rest of RDATA
/// (in the case of a valid NSEC3PARAM, it should be 0).
///
/// \exception DNSMessageFORMERR The wire data is invalid.
///
/// \param rrtype_name Either "NSEC3" or "NSEC3PARAM"; used as part of
/// exception messages.
/// \param buffer An input buffer that stores wire-format RDATA. It must
/// point to the beginning of the data.
/// \param rdata_len The total length of the RDATA.
/// \param salt A placeholder for the salt field value of the RDATA.
/// Expected to be empty, but it's not checked (and will be overridden).
///
/// \return The hash algorithm, flags, iterations in the form of
/// ParseNSEC3ParamResult.
ParseNSEC3ParamResult parseNSEC3ParamWire(const char* const rrtype_name,
isc::util::InputBuffer& buffer,
size_t& rdata_len,
std::vector<uint8_t>& salt);
}
}
}
}
}
}
#endif // NSEC3PARAM_COMMON_H
// Local Variables:
// mode: c++
// End:
| 38.556452 | 77 | 0.702364 | [
"vector"
] |
89babf98f0ece9cfe41bba7c6e3d2e3f0fb91b0d | 10,659 | c | C | pib/setpib.c | qsdk/open-plc-utils | 3c0005379390e857a650abbc09afea02adae6097 | [
"0BSD"
] | 3 | 2016-04-05T07:09:08.000Z | 2018-04-08T01:42:23.000Z | pib/setpib.c | qsdk/open-plc-utils | 3c0005379390e857a650abbc09afea02adae6097 | [
"0BSD"
] | null | null | null | pib/setpib.c | qsdk/open-plc-utils | 3c0005379390e857a650abbc09afea02adae6097 | [
"0BSD"
] | null | null | null | /*====================================================================*
*
* Copyright (c) 2011 Qualcomm Atheros Inc.
*
* Permission to use, copy, setpib, and/or distribute this software
* for any purpose with or without fee is hereby granted, provided
* that the above copyright notice and this permission notice appear
* in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*--------------------------------------------------------------------*/
/*====================================================================*"
*
* setpib.c -
*
*
* Contributor(s):
* Charles Maier <cmaier@qca.qualcomm.com>
*
*--------------------------------------------------------------------*/
/*====================================================================*"
* system header files;
*--------------------------------------------------------------------*/
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <ctype.h>
/*====================================================================*
* custom header files;
*--------------------------------------------------------------------*/
#include "../tools/getoptv.h"
#include "../tools/putoptv.h"
#include "../tools/memory.h"
#include "../tools/number.h"
#include "../tools/error.h"
#include "../tools/types.h"
#include "../tools/flags.h"
#include "../tools/files.h"
#include "../pib/pib.h"
#include "../nvm/nvm.h"
/*====================================================================*
* custom source files;
*--------------------------------------------------------------------*/
#ifndef MAKEFILE
#include "../tools/getoptv.c"
#include "../tools/putoptv.c"
#include "../tools/version.c"
#include "../tools/uintspec.c"
#include "../tools/basespec.c"
#include "../tools/dataspec.c"
#include "../tools/bytespec.c"
#include "../tools/todigit.c"
#include "../tools/hexdump.c"
#include "../tools/hexpeek.c"
#include "../tools/fdchecksum32.c"
#include "../tools/checksum32.c"
#include "../tools/memencode.c"
#include "../tools/error.c"
#endif
#ifndef MAKEFILE
#include "../nvm/nvmseek2.c"
#endif
/*====================================================================*
* constants;
*--------------------------------------------------------------------*/
#define SETPIB_VERBOSE (1 << 0)
#define SETPIB_SILENCE (1 << 1)
#define SETPIB_HEADERS (1 << 2)
#define SETPIB_CHANGED (1 << 3)
#define SETPIB_WINDOW 32
/*====================================================================*
* variables;
*--------------------------------------------------------------------*/
static flag_t flags = (flag_t)(0);
/*====================================================================*
*
* signed modify (void * memory, size_t extent, int argc, char const * argv [], unsigned window)
*
* apply a series of edits to a memory region; edits are specified
* in string vector argv [] which must follow rules understood by
* function memencode(); this function merely walks the vector and
* deals with error and display options;
*
*
* Contributor(s):
* Charles Maier <cmaier@qca.qualcomm.com>
*
*--------------------------------------------------------------------*/
static signed modify (void * memory, size_t extent, int argc, char const * argv [], unsigned window)
{
uint32_t origin;
uint32_t offset;
if (!argc)
{
error (1, ENOTSUP, "Need an offset");
}
origin = offset = (size_t)(basespec (* argv, 16, sizeof (offset)));
if (offset >= extent)
{
error (1, ECANCELED, "Offset %X exceeds file length of " SIZE_T_SPEC, offset, extent);
}
argc--;
argv++;
if (!argc)
{
_setbits (flags, SETPIB_VERBOSE);
}
while ((argc > 1) && (* argv))
{
_setbits (flags, SETPIB_CHANGED);
offset += (unsigned)(memencode ((byte *)(memory) + offset, extent - offset, argv [0], argv [1]));
argc -= 2;
argv += 2;
}
if (argc)
{
error (1, ECANCELED, "object %s needs a value", *argv);
}
if (_anyset (flags, SETPIB_VERBOSE))
{
hexpeek (memory, origin, offset, extent, window, stdout);
}
return (0);
}
/*====================================================================*
*
* signed pibimage1 (signed fd, char const * filename, int argc, char const * argv [], unsigned window);
*
* read an entire flat parameter file into memory, edit it, save
* it and display it;
*
*
* Contributor(s):
* Charles Maier <cmaier@qca.qualcomm.com>
*
*--------------------------------------------------------------------*/
static signed pibimage1 (signed fd, char const * filename, int argc, char const * argv [], unsigned window)
{
off_t extent;
void * memory;
if ((extent = lseek (fd, 0, SEEK_END)) == -1)
{
error (1, errno, FILE_CANTSIZE, filename);
}
if (!(memory = malloc (extent)))
{
error (1, errno, FILE_CANTLOAD, filename);
}
if (lseek (fd, 0, SEEK_SET))
{
error (1, errno, FILE_CANTHOME, filename);
}
if (read (fd, memory, extent) != extent)
{
error (1, errno, FILE_CANTREAD, filename);
}
if (lseek (fd, 0, SEEK_SET))
{
error (1, errno, FILE_CANTHOME, filename);
}
if (modify (memory, extent, argc, argv, window))
{
error (1, errno, FILE_CANTEDIT, filename);
}
if (_anyset (flags, SETPIB_CHANGED))
{
struct pib_header * pib_header = (struct pib_header *)(memory);
pib_header->CHECKSUM = checksum32 (memory, extent, pib_header->CHECKSUM);
if (write (fd, memory, extent) != extent)
{
error (1, errno, FILE_CANTSAVE, filename);
}
if (lseek (fd, (off_t)(0) - extent, SEEK_CUR) == -1)
{
error (1, errno, FILE_CANTHOME, filename);
}
}
free (memory);
close (fd);
return (0);
}
/*====================================================================*
*
* signed pibimage2 (signed fd, char const * filename, int argc, char const * argv [], unsigned window);
*
* read an entire flat parameter file into memory, edit it, save
* it and display it;
*
*
* Contributor(s):
* Charles Maier <cmaier@qca.qualcomm.com>
*
*--------------------------------------------------------------------*/
static signed pibimage2 (signed fd, char const * filename, struct nvm_header2 * nvm_header, int argc, char const * argv [], unsigned window)
{
void * memory;
off_t extent = LE32TOH (nvm_header->ImageLength);
if (!(memory = malloc (extent)))
{
error (1, errno, FILE_CANTLOAD, filename);
}
if (read (fd, memory, extent) != extent)
{
error (1, errno, FILE_CANTREAD, filename);
}
if (lseek (fd, (off_t)(0) - extent, SEEK_CUR) == -1)
{
error (1, errno, FILE_CANTHOME, filename);
}
if (modify (memory, extent, argc, argv, window))
{
error (1, errno, FILE_CANTEDIT, filename);
}
if (_anyset (flags, SETPIB_CHANGED))
{
nvm_header->ImageChecksum = checksum32 (memory, extent, 0);
if (write (fd, memory, extent) != extent)
{
error (1, errno, FILE_CANTSAVE, filename);
}
if (lseek (fd, (off_t)(0) - extent, SEEK_CUR) == -1)
{
error (1, errno, FILE_CANTHOME, filename);
}
nvm_header->HeaderChecksum = checksum32 (nvm_header, sizeof (* nvm_header), nvm_header->HeaderChecksum);
if (lseek (fd, (off_t)(0) - sizeof (* nvm_header), SEEK_CUR) == -1)
{
error (1, errno, FILE_CANTHOME, filename);
}
if (write (fd, nvm_header, sizeof (* nvm_header)) != sizeof (* nvm_header))
{
error (1, errno, FILE_CANTSAVE, filename);
}
if (lseek (fd, (off_t)(0) - sizeof (* nvm_header), SEEK_CUR) == -1)
{
error (1, errno, FILE_CANTHOME, filename);
}
}
free (memory);
return (0);
}
/*====================================================================*
*
* signed function (int argc, char const * argv [], unsigned window);
*
* call an appropriate parameter edit function based on the file
* header;
*
* older parameter files are flat with their own header; newer ones
* are image chains where one of image contains the parameter block;
*
*
* Contributor(s):
* Charles Maier <cmaier@qca.qualcomm.com>
*
*--------------------------------------------------------------------*/
static signed function (int argc, char const * argv [], unsigned window)
{
uint32_t version;
char const * filename = * argv;
signed status;
signed fd;
if ((fd = open (filename, O_BINARY|O_RDWR)) == -1)
{
error (1, errno, FILE_CANTOPEN, filename);
}
if (read (fd, &version, sizeof (version)) != sizeof (version))
{
error (1, errno, FILE_CANTREAD, filename);
}
if (lseek (fd, 0, SEEK_SET))
{
error (1, errno, FILE_CANTHOME, filename);
}
argc--;
argv++;
if (LE32TOH (version) == 0x00010001)
{
struct nvm_header2 nvm_header;
if (!nvmseek2 (fd, filename, &nvm_header, NVM_IMAGE_PIB))
{
status = pibimage2 (fd, filename, &nvm_header, argc, argv, window);
}
}
else
{
status = pibimage1 (fd, filename, argc, argv, window);
}
close (fd);
return (status);
}
/*====================================================================*
*
* int main (int argc, char const * argv []);
*
*
*--------------------------------------------------------------------*/
int main (int argc, char const * argv [])
{
static char const * optv [] =
{
"qvw:x",
"file base [type data] [type data] [...]\n\n\tstandard-length types are 'byte'|'word'|'long'|'huge'|'hfid'|'mac'|'key'\n\tvariable-length types are 'data'|'text'|'fill'|'skip'",
"Qualcomm Atheros PIB File Editor",
"q\tquiet mode",
"v[v]\tverbose mode",
"w n\twindow size is (n) [" LITERAL (SETPIB_WINDOW) "]",
"x\trepair checksum",
(char const *) (0)
};
unsigned window = SETPIB_WINDOW;
signed c;
optind = 1;
opterr = 1;
while ((c = getoptv (argc, argv, optv)) != -1)
{
switch (c)
{
case 'q':
_setbits (flags, SETPIB_SILENCE);
break;
case 'v':
if (_anyset (flags, SETPIB_VERBOSE))
{
_setbits (flags, SETPIB_HEADERS);
}
_setbits (flags, SETPIB_VERBOSE);
break;
case 'w':
window = (unsigned)(uintspec (optarg, 0, UINT_MAX));
_setbits (flags, SETPIB_VERBOSE);
break;
case 'x':
_setbits (flags, SETPIB_CHANGED);
break;
default:
break;
}
}
argc -= optind;
argv += optind;
if ((argc) && (* argv))
{
function (argc, argv, window);
}
return (0);
}
| 27.401028 | 179 | 0.537855 | [
"object",
"vector"
] |
89bbf525bd6914586d6f252d61ef849898ec7098 | 1,389 | h | C | src/module/native_module_handle.h | Alex-Werner/isolated-vm | d9f0a22b3b7959bf071d018f3eddfbace10d5537 | [
"ISC"
] | 1,162 | 2017-05-24T04:17:25.000Z | 2022-03-31T12:03:50.000Z | node_modules/isolated-vm/src/module/native_module_handle.h | bobbymcgonigle/isolated-vm-cli | 74797da03a5912731af3743500f243ac450c0f0d | [
"MIT"
] | 290 | 2017-10-21T01:51:40.000Z | 2022-03-30T15:00:46.000Z | node_modules/isolated-vm/src/module/native_module_handle.h | bobbymcgonigle/isolated-vm-cli | 74797da03a5912731af3743500f243ac450c0f0d | [
"MIT"
] | 98 | 2017-10-21T03:38:49.000Z | 2022-03-21T17:03:11.000Z | #pragma once
#include <v8.h>
#include <uv.h>
#include <memory>
#include "transferable.h"
#include "context_handle.h"
#include "transferable.h"
namespace ivm {
class NativeModule {
private:
using init_t = void(*)(v8::Isolate *, v8::Local<v8::Context>, v8::Local<v8::Object>);
uv_lib_t lib;
init_t init;
public:
explicit NativeModule(const std::string& filename);
NativeModule(const NativeModule&) = delete;
auto operator= (const NativeModule&) -> NativeModule& = delete;
~NativeModule();
void InitForContext(v8::Isolate* isolate, v8::Local<v8::Context> context, v8::Local<v8::Object> target);
};
class NativeModuleHandle : public TransferableHandle {
private:
class NativeModuleTransferable : public Transferable {
private:
std::shared_ptr<NativeModule> module;
public:
explicit NativeModuleTransferable(std::shared_ptr<NativeModule> module);
auto TransferIn() -> v8::Local<v8::Value> final;
};
std::shared_ptr<NativeModule> module;
template <int async>
auto Create(ContextHandle& context_handle) -> v8::Local<v8::Value>;
public:
explicit NativeModuleHandle(std::shared_ptr<NativeModule> module);
static auto Definition() -> v8::Local<v8::FunctionTemplate>;
static auto New(v8::Local<v8::String> value) -> std::unique_ptr<NativeModuleHandle>;
auto TransferOut() -> std::unique_ptr<Transferable> final;
};
} // namespace ivm
| 27.78 | 106 | 0.723542 | [
"object"
] |
3723a5eef9887fe9a87d4538016fa65e70edc710 | 8,024 | h | C | APU/duty/debug/obj_dir/Vduty.h | RollMan/famicom_GO | 3a1b9de670ff8691357ba7980dda7aee3cbdfc96 | [
"MIT"
] | null | null | null | APU/duty/debug/obj_dir/Vduty.h | RollMan/famicom_GO | 3a1b9de670ff8691357ba7980dda7aee3cbdfc96 | [
"MIT"
] | null | null | null | APU/duty/debug/obj_dir/Vduty.h | RollMan/famicom_GO | 3a1b9de670ff8691357ba7980dda7aee3cbdfc96 | [
"MIT"
] | null | null | null | // Verilated -*- C++ -*-
// DESCRIPTION: Verilator output: Primary design header
//
// This header should be included by all source files instantiating the design.
// The class here is then constructed to instantiate the design.
// See the Verilator manual for examples.
#ifndef _Vduty_H_
#define _Vduty_H_
#include "verilated_heavy.h"
class Vduty__Syms;
//----------
VL_MODULE(Vduty) {
public:
// CELLS
// Public to allow access to /*verilator_public*/ items;
// otherwise the application code can consider these internals.
// PORTS
// The application code writes and reads these signals to
// propagate new values into/out from the Verilated model.
VL_IN8(p_reset,0,0);
VL_IN8(m_clock,0,0);
VL_IN8(Vin,3,0);
VL_IN8(dnum,1,0);
VL_OUT8(V0,3,0);
VL_IN8(setduty,0,0);
VL_IN8(exec,0,0);
//char __VpadToAlign7[1];
// LOCAL SIGNALS
// Internals; generally not touched by application code
VL_SIG8(duty__DOT__cnt,5,0);
VL_SIG8(duty__DOT__d,1,0);
VL_SIG8(duty__DOT___net_0,0,0);
VL_SIG8(duty__DOT___net_1,0,0);
VL_SIG8(duty__DOT___net_3,0,0);
VL_SIG8(duty__DOT___net_4,0,0);
VL_SIG8(duty__DOT___net_5,0,0);
VL_SIG8(duty__DOT___net_6,0,0);
VL_SIG8(duty__DOT___net_7,0,0);
VL_SIG8(duty__DOT___net_8,0,0);
VL_SIG8(duty__DOT___net_9,0,0);
VL_SIG8(duty__DOT___net_10,0,0);
VL_SIG8(duty__DOT___net_11,0,0);
VL_SIG8(duty__DOT___net_12,0,0);
VL_SIG8(duty__DOT___net_13,0,0);
VL_SIG8(duty__DOT___net_14,0,0);
VL_SIG8(duty__DOT___net_15,0,0);
VL_SIG8(duty__DOT___net_16,0,0);
VL_SIG8(duty__DOT___net_17,0,0);
VL_SIG8(duty__DOT___net_18,0,0);
VL_SIG8(duty__DOT___net_19,0,0);
VL_SIG8(duty__DOT___net_20,0,0);
VL_SIG8(duty__DOT___net_21,0,0);
VL_SIG8(duty__DOT___net_22,0,0);
VL_SIG8(duty__DOT___net_23,0,0);
VL_SIG8(duty__DOT___net_24,0,0);
VL_SIG8(duty__DOT___net_25,0,0);
VL_SIG8(duty__DOT___net_26,0,0);
VL_SIG8(duty__DOT___net_27,0,0);
VL_SIG8(duty__DOT___net_28,0,0);
VL_SIG8(duty__DOT___net_29,0,0);
VL_SIG8(duty__DOT___net_30,0,0);
VL_SIG8(duty__DOT___net_31,0,0);
VL_SIG8(duty__DOT___net_32,0,0);
VL_SIG8(duty__DOT___net_33,0,0);
VL_SIG8(duty__DOT___net_34,0,0);
VL_SIG8(duty__DOT___net_36,0,0);
VL_SIG8(duty__DOT___net_37,0,0);
VL_SIG8(duty__DOT___net_38,0,0);
VL_SIG8(duty__DOT___net_39,0,0);
VL_SIG8(duty__DOT___net_40,0,0);
VL_SIG8(duty__DOT___net_41,0,0);
VL_SIG8(duty__DOT___net_42,0,0);
VL_SIG8(duty__DOT___net_43,0,0);
VL_SIG8(duty__DOT___net_44,0,0);
VL_SIG8(duty__DOT___net_45,0,0);
VL_SIG8(duty__DOT___net_46,0,0);
VL_SIG8(duty__DOT___net_47,0,0);
VL_SIG8(duty__DOT___net_48,0,0);
VL_SIG8(duty__DOT___net_49,0,0);
VL_SIG8(duty__DOT___net_50,0,0);
VL_SIG8(duty__DOT___net_51,0,0);
VL_SIG8(duty__DOT___net_52,0,0);
VL_SIG8(duty__DOT___net_53,0,0);
VL_SIG8(duty__DOT___net_54,0,0);
VL_SIG8(duty__DOT___net_55,0,0);
VL_SIG8(duty__DOT___net_56,0,0);
VL_SIG8(duty__DOT___net_57,0,0);
VL_SIG8(duty__DOT___net_58,0,0);
VL_SIG8(duty__DOT___net_59,0,0);
VL_SIG8(duty__DOT___net_60,0,0);
VL_SIG8(duty__DOT___net_61,0,0);
VL_SIG8(duty__DOT___net_62,0,0);
VL_SIG8(duty__DOT___net_63,0,0);
VL_SIG8(duty__DOT___net_64,0,0);
VL_SIG8(duty__DOT___net_65,0,0);
VL_SIG8(duty__DOT___net_66,0,0);
VL_SIG8(duty__DOT___net_67,0,0);
VL_SIG8(duty__DOT___net_69,0,0);
VL_SIG8(duty__DOT___net_70,0,0);
VL_SIG8(duty__DOT___net_71,0,0);
VL_SIG8(duty__DOT___net_72,0,0);
VL_SIG8(duty__DOT___net_73,0,0);
VL_SIG8(duty__DOT___net_74,0,0);
VL_SIG8(duty__DOT___net_75,0,0);
VL_SIG8(duty__DOT___net_76,0,0);
VL_SIG8(duty__DOT___net_77,0,0);
VL_SIG8(duty__DOT___net_78,0,0);
VL_SIG8(duty__DOT___net_79,0,0);
VL_SIG8(duty__DOT___net_80,0,0);
VL_SIG8(duty__DOT___net_81,0,0);
VL_SIG8(duty__DOT___net_82,0,0);
VL_SIG8(duty__DOT___net_83,0,0);
VL_SIG8(duty__DOT___net_84,0,0);
VL_SIG8(duty__DOT___net_85,0,0);
VL_SIG8(duty__DOT___net_86,0,0);
VL_SIG8(duty__DOT___net_87,0,0);
VL_SIG8(duty__DOT___net_88,0,0);
VL_SIG8(duty__DOT___net_89,0,0);
VL_SIG8(duty__DOT___net_90,0,0);
VL_SIG8(duty__DOT___net_91,0,0);
VL_SIG8(duty__DOT___net_92,0,0);
VL_SIG8(duty__DOT___net_93,0,0);
VL_SIG8(duty__DOT___net_94,0,0);
VL_SIG8(duty__DOT___net_95,0,0);
VL_SIG8(duty__DOT___net_96,0,0);
VL_SIG8(duty__DOT___net_97,0,0);
VL_SIG8(duty__DOT___net_98,0,0);
VL_SIG8(duty__DOT___net_99,0,0);
VL_SIG8(duty__DOT___net_100,0,0);
VL_SIG8(duty__DOT___net_102,0,0);
VL_SIG8(duty__DOT___net_103,0,0);
VL_SIG8(duty__DOT___net_104,0,0);
VL_SIG8(duty__DOT___net_105,0,0);
VL_SIG8(duty__DOT___net_106,0,0);
VL_SIG8(duty__DOT___net_107,0,0);
VL_SIG8(duty__DOT___net_108,0,0);
VL_SIG8(duty__DOT___net_109,0,0);
VL_SIG8(duty__DOT___net_110,0,0);
VL_SIG8(duty__DOT___net_111,0,0);
VL_SIG8(duty__DOT___net_112,0,0);
VL_SIG8(duty__DOT___net_113,0,0);
VL_SIG8(duty__DOT___net_114,0,0);
VL_SIG8(duty__DOT___net_115,0,0);
VL_SIG8(duty__DOT___net_116,0,0);
VL_SIG8(duty__DOT___net_117,0,0);
VL_SIG8(duty__DOT___net_118,0,0);
VL_SIG8(duty__DOT___net_119,0,0);
VL_SIG8(duty__DOT___net_120,0,0);
VL_SIG8(duty__DOT___net_121,0,0);
VL_SIG8(duty__DOT___net_122,0,0);
VL_SIG8(duty__DOT___net_123,0,0);
VL_SIG8(duty__DOT___net_124,0,0);
VL_SIG8(duty__DOT___net_125,0,0);
VL_SIG8(duty__DOT___net_126,0,0);
VL_SIG8(duty__DOT___net_127,0,0);
VL_SIG8(duty__DOT___net_128,0,0);
VL_SIG8(duty__DOT___net_129,0,0);
VL_SIG8(duty__DOT___net_130,0,0);
VL_SIG8(duty__DOT___net_131,0,0);
VL_SIG8(duty__DOT___net_132,0,0);
VL_SIG8(duty__DOT___net_133,0,0);
// LOCAL VARIABLES
// Internals; generally not touched by application code
VL_SIG8(__Vclklast__TOP__m_clock,0,0);
VL_SIG8(__Vclklast__TOP__p_reset,0,0);
//char __VpadToAlign150[2];
// INTERNAL VARIABLES
// Internals; generally not touched by application code
//char __VpadToAlign156[4];
Vduty__Syms* __VlSymsp; // Symbol table
// PARAMETERS
// Parameters marked /*verilator public*/ for use by application code
// CONSTRUCTORS
private:
Vduty& operator= (const Vduty&); ///< Copying not allowed
Vduty(const Vduty&); ///< Copying not allowed
public:
/// Construct the model; called by application code
/// The special name may be used to make a wrapper with a
/// single model invisible WRT DPI scope names.
Vduty(const char* name="TOP");
/// Destroy the model; called (often implicitly) by application code
~Vduty();
// USER METHODS
// API METHODS
/// Evaluate the model. Application must call when inputs change.
void eval();
/// Simulation complete, run final blocks. Application must call on completion.
void final();
// INTERNAL METHODS
private:
static void _eval_initial_loop(Vduty__Syms* __restrict vlSymsp);
public:
void __Vconfigure(Vduty__Syms* symsp, bool first);
private:
static QData _change_request(Vduty__Syms* __restrict vlSymsp);
public:
static void _combo__TOP__4(Vduty__Syms* __restrict vlSymsp);
static void _combo__TOP__7(Vduty__Syms* __restrict vlSymsp);
private:
void _ctor_var_reset();
public:
static void _eval(Vduty__Syms* __restrict vlSymsp);
static void _eval_initial(Vduty__Syms* __restrict vlSymsp);
static void _eval_settle(Vduty__Syms* __restrict vlSymsp);
static void _sequent__TOP__1(Vduty__Syms* __restrict vlSymsp);
static void _sequent__TOP__2(Vduty__Syms* __restrict vlSymsp);
static void _sequent__TOP__3(Vduty__Syms* __restrict vlSymsp);
static void _sequent__TOP__6(Vduty__Syms* __restrict vlSymsp);
static void _settle__TOP__5(Vduty__Syms* __restrict vlSymsp);
} VL_ATTR_ALIGNED(128);
#endif /*guard*/
| 35.348018 | 84 | 0.719217 | [
"model"
] |
3724cc42d8ebe897e8901bd414416e21237f4273 | 189 | h | C | lecture_code/classes2/init_list.h | ahurta92/ams562-notes | e66baa1e50654e125902651f388d45cb32c81f00 | [
"MIT"
] | 1 | 2021-09-01T19:09:54.000Z | 2021-09-01T19:09:54.000Z | lecture_code/classes2/init_list.h | ahurta92/ams562-notes | e66baa1e50654e125902651f388d45cb32c81f00 | [
"MIT"
] | null | null | null | lecture_code/classes2/init_list.h | ahurta92/ams562-notes | e66baa1e50654e125902651f388d45cb32c81f00 | [
"MIT"
] | 1 | 2021-11-30T19:26:02.000Z | 2021-11-30T19:26:02.000Z | // method 1 initializer-list constructor
Vector(std::initializer_list<double> l)
: elem{new double[l.size()]}, sz{static_cast<int>(l.size())} {
std::copy(l.begin(), l.end(), elem);
}
| 31.5 | 66 | 0.661376 | [
"vector"
] |
37254137526e618499f18fde29bba3308d495923 | 2,981 | h | C | src/app/qgsmaptooltrimextendfeature.h | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | null | null | null | src/app/qgsmaptooltrimextendfeature.h | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | null | null | null | src/app/qgsmaptooltrimextendfeature.h | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | 1 | 2021-12-25T08:40:30.000Z | 2021-12-25T08:40:30.000Z | /***************************************************************************
qgmaptooltrimextendfeature.h - map tool to trim or extend feature
---------------------
begin : October 2018
copyright : (C) 2018 by Loïc Bartoletti
email : loic dot bartoletti at oslandia dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMAPTOOLTRIMEXTENDFEATURE_H
#define QGSMAPTOOLTRIMEXTENDFEATURE_H
#include "qgsmaptooledit.h"
#include "qgis_app.h"
#include "qgsrubberband.h"
class APP_EXPORT QgsMapToolTrimExtendFeature : public QgsMapToolEdit
{
public:
Q_OBJECT
public:
QgsMapToolTrimExtendFeature( QgsMapCanvas *canvas );
~QgsMapToolTrimExtendFeature() override = default;
void canvasMoveEvent( QgsMapMouseEvent *e ) override;
void canvasReleaseEvent( QgsMapMouseEvent *e ) override;
void keyPressEvent( QKeyEvent *e ) override;
//! called when map tool is being deactivated
void deactivate() override;
private:
//! Rubberband that shows the limit
std::unique_ptr<QgsRubberBand>mRubberBandLimit;
//! Rubberband that shows the feature being extended
std::unique_ptr<QgsRubberBand>mRubberBandExtend;
//! Rubberband that shows the intersection point
std::unique_ptr<QgsRubberBand>mRubberBandIntersection;
//! Points for the limit
QgsPoint pLimit1, pLimit2;
//! Points for extend
QgsPoint pExtend1, pExtend2;
//! intersection point between the projection of [pExtend1 - pExtend2] on [pLimit1 - pLimit2]
QgsPoint mIntersection;
//! map point used to determine which edges will be used for trim the feature
QgsPointXY mMapPoint;
//! geometry that will be returned
QgsGeometry mGeom;
//! Current layer which will be modified
QgsVectorLayer *mVlayer = nullptr;
//! Keep information about the state of the intersection
bool mIsIntersection = false;
//! Keep information of the first layer snapped is 3D or not
bool mIs3DLayer = false;
//! if feature is modified
bool mIsModified = false;
//! if the segments are intersected = trim
bool mSegmentIntersects = false;
enum Step
{
StepLimit,
StepExtend,
};
//! The first step (0): choose the limit. The second step (1): choose the segment to trim/extend
Step mStep = StepLimit;
};
#endif // QGSMAPTOOLTRIMEXTENDFEATURE_H
| 38.217949 | 100 | 0.60047 | [
"geometry",
"3d"
] |
3729630df2d8c166cd155c4909d8c623069d2042 | 37,684 | h | C | dpsk_buck_acmc.X/sources/power_control/drivers/npnz16b.h | microchip-pic-avr-examples/dpsk3-power-buck-average-current-mode-control | ca8bb2a7c663f43f64f1f882bc50b39d93540f1f | [
"ADSL"
] | 2 | 2021-11-05T20:54:44.000Z | 2022-02-14T09:41:09.000Z | dpsk_buck_acmc.X/sources/power_control/drivers/npnz16b.h | microchip-pic-avr-examples/dpsk3-power-buck-average-current-mode-control | ca8bb2a7c663f43f64f1f882bc50b39d93540f1f | [
"ADSL"
] | null | null | null | dpsk_buck_acmc.X/sources/power_control/drivers/npnz16b.h | microchip-pic-avr-examples/dpsk3-power-buck-average-current-mode-control | ca8bb2a7c663f43f64f1f882bc50b39d93540f1f | [
"ADSL"
] | 2 | 2022-02-08T06:22:33.000Z | 2022-02-26T11:13:51.000Z | /* *********************************************************************************
* PowerSmart™ Digital Control Library Designer, Version 0.9.14.676
* *********************************************************************************
* Generic library header for z-domain compensation filter assembly functions
* CGS Version: 3.0.8
* CGS Date: 03/12/2021
* ********************************************************************************/
// This is a guard condition so that contents of this file are not included
// more than once.
#ifndef __SPECIAL_FUNCTION_LAYER_LIB_NPNZ16B_H__
#define __SPECIAL_FUNCTION_LAYER_LIB_NPNZ16B_H__
#include <xc.h> // include processor files - each processor file is guarded
#include <dsp.h> // include DSP data types (e.g. fractional)
#include <stdint.h> // include standard integer number data types
#include <stddef.h> // include standard definition data types
#include <stdbool.h> // include standard boolean data types (true/false)
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-macros
* @def __PSDCLD_VERSION
* @brief Generic macro allowing to identify the file version of 'npnz16b.h'
*
* @details
* This version key represents the product version of PS-DCLD as integer number
* of the form [MAJOR][MINOR][REVISION] => version 0.9.3.xxx would be shown as 903.
* User code can check if the file version is compliant with the proprietary user
* code by using pre-compiler directives such as
*
* @code{.c}
* #if (__PSDCLD_VERSION > 908)
* #pragma message "This code has not been tested with the recently included version of npnz16b.h"
* #endif
* @endcode
*
***************************************************************************************************/
#ifndef __PSDCLD_VERSION
#define __PSDCLD_VERSION 914
#endif
/***************************************************************************************************
* @enum NPNZ_STATUS_FLAGS_e
* @brief Common Controller Status and Control Flag Bits
* @details
* The 16-bit wide NPNZ_STATUS_s data object holds status and control bits for
* monitoring and control of the NPNZ16b_s controller during runtime. The lower 8 bit
* of the status word are used for status indication while the upper 8 bit are used
* by control bits.
* For enhanced programming convenience, definitions of status and control flags are
* provided in single bit and full word format. All available flags are consolidated
* in the npnzFlagList object.
***************************************************************************************************/
enum NPNZ_STATUS_FLAGS_e
{
NPNZ_STATUS_CLEAR = 0b0000000000000000,
NPNZ_STATUS_SATUATION_MSK = 0b0000000000000011,
NPNZ_STATUS_LSAT_ACTIVE = 0b0000000000000001,
NPNZ_STATUS_LSAT_CLEAR = 0b0000000000000000,
NPNZ_STATUS_USAT_ACTIVE = 0b0000000000000010,
NPNZ_STATUS_USAT_CLEAR = 0b0000000000000000,
NPNZ_STATUS_AGC_DISABLE = 0b0000000000000000,
NPNZ_STATUS_AGC_ENABLED = 0b0000100000000000,
NPNZ_STATUS_TARGET_DEFAULT = 0b0000000000000000,
NPNZ_STATUS_TARGET_SWAPED = 0b0001000000000000,
NPNZ_STATUS_SOURCE_DEFAULT = 0b0000000000000000,
NPNZ_STATUS_SOURCE_SWAPED = 0b0010000000000000,
NPNZ_STATUS_INV_INPUT_OFF = 0b0000000000000000,
NPNZ_STATUS_INV_INPUT_ON = 0b0100000000000000,
NPNZ_STATUS_ENABLE_OFF = 0b0000000000000000,
NPNZ_STATUS_ENABLE_ON = 0b1000000000000000
}; ///< NPNZ controller status flags
typedef enum NPNZ_STATUS_FLAGS_e NPNZ_STATUS_FLAGS_t; ///< NPNZ controller status flags data type
/***************************************************************************************************
* @enum NPNZ_STATUS_SATURATION_e
* @brief Enumeration of control loop saturation status bits
**************************************************************************************************/
enum NPNZ_STATUS_SATURATION_e{
NPNZ_SAT_CLEAR = 0b0, ///< No saturation condition detected
NPNZ_SAT_ACTIVE = 0b1 ///< Saturation limit violation detected
}; ///< NPNZ output saturation status bits
typedef enum NPNZ_STATUS_SATURATION_e NPNZ_STATUS_SATURATION_t; ///< NPNZ output saturation status bits data type
extern volatile enum NPNZ_STATUS_SATURATION_e npnzEnumControlStatusSaturation; ///< List Object Control Status Saturation
/* Control flags (bit-field) */
/***************************************************************************************************
* @enum NPNZ_STATUS_AGC_ENABLE_e
* @brief Enumeration of Adaptive Gain Modulation enable/disable control bits
**************************************************************************************************/
enum NPNZ_STATUS_AGC_ENABLE_e{
NPNZ_AGC_DISABLED = 0b0, ///< Adaptive Gain Modulation is disabled
NPNZ_AGC_ENABLED = 0b1 ///< Adaptive Gain Modulation is enabled
}; ///< Adaptive Gain Modulation control bits
typedef enum NPNZ_STATUS_AGC_ENABLE_e NPNZ_STATUS_AGC_ENABLE_t; ///< Adaptive Gain Modulation control bits data type
extern volatile enum NPNZ_STATUS_AGC_ENABLE_e npnzEnumControlAgcEnable; ///< List Object Control AGC Enable
/***************************************************************************************************
* @enum NPNZ_STATUS_SOURCE_SWAP_e
* @brief Enumeration of control input port swap control bits
**************************************************************************************************/
enum NPNZ_STATUS_SOURCE_SWAP_e{
NPNZ_SOURCE_DEFAULT = 0b0, ///< Controller source ports are not swapped, primary source is active input
NPNZ_SOURCE_SWAPED = 0b1 ///< Controller source ports are swapped, alternate source is active input
}; ///< NPNZ Source Port Swap Control bits
typedef enum NPNZ_STATUS_SOURCE_SWAP_e NPNZ_STATUS_SOURCE_SWAP_t; ///< NPNZ Source Port Swap Control bits data type
extern volatile enum NPNZ_STATUS_SOURCE_SWAP_e npnzEnumControlSourceSwap; ///< List Object Control Source Swap
/***************************************************************************************************
* @enum NPNZ_STATUS_TARGET_SWAP_e
* @brief Enumeration of control output port swap control bits
**************************************************************************************************/
enum NPNZ_STATUS_TARGET_SWAP_e{
NPNZ_TARGET_DEFAULT = 0b0, ///< Controller target ports are not swapped, primary source is active output
NPNZ_TARGET_SWAPED = 0b1 ///< Controller target ports are swapped, alternate target is active output
}; ///< NPNZ Target Port Swap Control bits
typedef enum NPNZ_STATUS_TARGET_SWAP_e NPNZ_STATUS_TARGET_SWAP_t; ///< NPNZ Target Port Swap Control bits
extern volatile enum NPNZ_STATUS_TARGET_SWAP_e npnzEnumControlTargetSwap; ///< List Object Control Target Swap
/***************************************************************************************************
* @enum NPNZ_STATUS_INPUT_INV_e
* @brief Enumeration of input value inversion control bits
**************************************************************************************************/
enum NPNZ_STATUS_INPUT_INV_e{
NPNZ_INPUT_DEFAULT = 0b0, ///< Controller error value is not inverted
NPNZ_INPUT_INVERTED = 0b1 ///< Controller error value is inverted
}; ///< NPNZ Error Value Inversion Control bit
typedef enum NPNZ_STATUS_INPUT_INV_e NPNZ_STATUS_INPUT_INV_t; ///< NPNZ Error Value Inversion Control bit
extern volatile enum NPNZ_STATUS_INPUT_INV_e npnzEnumControlInputInversion; ///< List Object Control Input Inversion
/***************************************************************************************************
* @enum NPNZ_STATUS_ENABLE_e
* @brief Enumeration of control loop enable/disable control bits
**************************************************************************************************/
enum NPNZ_STATUS_ENABLE_e{
NPNZ_DISABLED = 0b0, ///< Controller error value is not inverted
NPNZ_ENABLED = 0b1 ///< Controller error value is inverted
}; ///< NPNZ Controller Enable Control bit
typedef enum NPNZ_STATUS_ENABLE_e NPNZ_STATUS_ENABLE_t; ///< NPNZ Controller Enable Control bit
extern volatile enum NPNZ_STATUS_ENABLE_e npnzEnumControlEnable; ///< List Object Control Enable
/****************************************************************************************************
* @struct NPNZ_FLAGS_s
* @brief Structure providing all public enumerated lists of constants
**************************************************************************************************** */
struct NPNZ_FLAGS_s
{
volatile enum NPNZ_STATUS_FLAGS_e StatusWordFlags; ///< List of all status and control flags of the NPNZ16b status word
volatile enum NPNZ_STATUS_SATURATION_e flagSaturation; ///< List of all status and control flags of the NPNZ16b status word
volatile enum NPNZ_STATUS_AGC_ENABLE_e flagAgcControl; ///< List of all status and control flags of the NPNZ16b status word
volatile enum NPNZ_STATUS_SOURCE_SWAP_e flagSourceSwap; ///< List of State Machine Operating State IDs
volatile enum NPNZ_STATUS_TARGET_SWAP_e flagTargetSwap; ///< List of State Machine Sub-State IDs
volatile enum NPNZ_STATUS_INPUT_INV_e flagCtrlInputInversion; ///< List of State Machine Operating State Return Values
volatile enum NPNZ_STATUS_ENABLE_e flagControlEnable; ///< List of Supported Control Modes
}; ///< Consolidated list of status bit value enumerations
typedef struct NPNZ_FLAGS_s NPNZ_FLAGS_t; ///< Consolidated list of status bit value enumerations data type
extern volatile struct NPNZ_FLAGS_s npnzFlagList; ///< List object of consolidated status bit value enumerations
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_STATUS_s
* @brief NPNZ16b controller object status and control word
* @extends NPNZ16b_s
*
* @details
* The NPNZ16b_s status word is providing status flag bits for monitoring and controlling the
* NPNZ16b control library code execution from outside the library module.
*
* 1) Status Byte
* The low byte of the NPNZ16b_s status word is used for READ ONLY status flags, set and cleared
* automatically by the control loop library routine.
*
* 2) Control Byte
* The high byte of the status word is used for control flags, through which users can control
* the control loop execution. This includes enabling/disabling the control loop execution,
* switch between different input and output sources, invert input values or enable/disable
* advanced functions.
*
***************************************************************************************************/
/* Controller status data structure */
struct NPNZ_STATUS_s {
union {
struct {
volatile bool lower_saturation_event : 1; ///< Bit 0: control loop is clamped at minimum output level
volatile bool upper_saturation_event : 1; ///< Bit 1: control loop is clamped at maximum output level
volatile unsigned : 1; ///< Bit 2: reserved
volatile unsigned : 1; ///< Bit 3: reserved
volatile unsigned : 1; ///< Bit 4: reserved
volatile unsigned : 1; ///< Bit 5: reserved
volatile unsigned : 1; ///< Bit 6: reserved
volatile unsigned : 1; ///< Bit 7: reserved
volatile unsigned : 1; ///< Bit 8: reserved
volatile unsigned : 1; ///< Bit 9: reserved
volatile unsigned : 1; ///< Bit 11: reserved
volatile bool agc_enabled: 1; ///< Bit 11: when set, Adaptive Gain Control Modulation is enabled
volatile bool swap_target: 1; ///< Bit 12: when set, AltTarget is used as data output of controller
volatile bool swap_source: 1; ///< Bit 13: when set, AltSource is used as data input to controller
volatile bool invert_input: 1; ///< Bit 14: when set, most recent error input value to controller is inverted
volatile bool enabled : 1; ///< Bit 15: enables/disables control loop execution
} __attribute__((packed))bits; ///< Controller status bit-field for direct bit access
volatile uint16_t value; ///< Controller status full register access
};
} __attribute__((packed)); ///< Controller status word data structure allowing bit-wise access to status and control bits
typedef struct NPNZ_STATUS_s NPNZ_STATUS_t; ///< Data type of controller status word data structure allowing bit-wise access to status and control bits
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_PORT_s
* @brief Data Input/Output Port declaration of memory addresses, signal offsets and normalization settings
* @extends NPNZ_PORTS_s
*
* @details
* The NPNZ_PORT_s data object defines the basic parameters required to read data from or write
* data to user-defined memory addresses as well as offers data fields for additional settings
* such as normalization scaling factors or signal offsets, which can be used to compensate analog
* offsets and normalize raw ADC data to other ADC input values and their respective physical
* struct NPNZ_PORT_t declares its individual source/target memory address, normalization
* quantity.
*
***************************************************************************************************/
/* Controller Input/Output Port */
struct NPNZ_PORT_s{
volatile uint16_t* ptrAddress; ///< Pointer to register or variable where the value is read from (e.g. ADCBUFx) or written to (e.g. PGxDC)
volatile int16_t NormScaler; ///< Bit-shift scaler of the Q15 normalization factor
volatile fractional NormFactor; ///< Q15 normalization factor
volatile int16_t Offset; ///< Value/signal offset of this port
} __attribute__((packed)); ///< Data structure defining parameters of a controller input or output port
typedef struct NPNZ_PORT_s NPNZ_PORT_t; ///< Data structure data type defining parameters of a controller input or output port
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_PORTS_s
* @brief Filter Coefficient Arrays, Number Format Handling and Input/Output History Parameters
* @extends NPNZ16b_s
*
* @details
* The NPNZ_PORTS_t data object holds a list of nested NPNZ_PORT_t data objects, each
* defining an individual controller input or output port. The NPNZ16b_s data objects defines
* up to two input and two output ports of type struct NPNZ_PORT_t and one additional
* pointer to an external, user-defined 16-bit reference source variable. Each port of type
* struct NPNZ_PORT_t declares its individual source/target memory address, normalization
* scaler and offset:
*
* - Primary Source: common feedback input object
* - Alternate Source: additional, alternate feedback input object (optional)
* - Primary Target: common control output target object
* - Alternate Target: additional, alternate control output target object (optional)
* - Control Reference: pointer to external 16-bit reference source variable
*
***************************************************************************************************/
/* List of Controller Input/Output Ports */
struct NPNZ_PORTS_s{
volatile struct NPNZ_PORT_s Source; ///< Primary data input port declaration
volatile struct NPNZ_PORT_s AltSource; ///< Secondary data input port declaration
volatile struct NPNZ_PORT_s Target; ///< Primary data output port declaration
volatile struct NPNZ_PORT_s AltTarget; ///< Secondary data output port declaration
volatile uint16_t* ptrControlReference; ///< Pointer to global variable of input register holding the controller reference value (e.g. uint16_t my_ref)
} __attribute__((packed)); ///< Data structure merging all defined controller input and output ports
typedef struct NPNZ_PORTS_s NPNZ_PORTS_t; ///< Data structure merging all defined controller input and output ports
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_FILTER_PARAMS_s
* @brief Filter Coefficient Arrays, Number Format Handling and Input/Output History Parameters
* @extends NPNZ16b_s
*
* @details
* The NPNZ_FILTER_PARAMS_t data object holds all configuration parameters of the compensation
* filter. These parameters include pointers to external arrays of filter coefficients, error
* and control history as well as number format normalization parameters like pre- and post-
* scalers.
*
***************************************************************************************************/
struct NPNZ_FILTER_PARAMS_s{
volatile int32_t* ptrACoefficients; ///< Pointer to A coefficients located in X-space
volatile int32_t* ptrBCoefficients; ///< Pointer to B coefficients located in X-space
volatile fractional* ptrControlHistory; ///< Pointer to n delay-line samples located in Y-space with first sample being the most recent
volatile fractional* ptrErrorHistory; ///< Pointer to n+1 delay-line samples located in Y-space with first sample being the most recent
// Array size information
volatile uint16_t ACoefficientsArraySize; ///< Size of the A coefficients array in X-space
volatile uint16_t BCoefficientsArraySize; ///< Size of the B coefficients array in X-space
volatile uint16_t ControlHistoryArraySize; ///< Size of the control history array in Y-space
volatile uint16_t ErrorHistoryArraySize; ///< Size of the error history array in Y-space
// Feedback scaling Input/Output Normalization
volatile int16_t normPreShift; ///< Normalization of ADC-resolution to Q15 (R/W)
volatile int16_t normPostShiftA; ///< Normalization of A-term control output to Q15 (R/W)
volatile int16_t normPostShiftB; ///< Normalization of B-term control output to Q15 (R/W)
volatile int16_t normPostScaler; ///< Control output normalization factor (Q15) (R/W)
// P-Term Coefficients (for plant measurements only)
volatile int16_t PTermScaler; ///< Q15 P-Term Coefficient Bit-Shift Scaler (R/W)
volatile int16_t PTermFactor; ///< Q15 P-Term Coefficient Factor (R/W)
} __attribute__((packed)); ///< Data structure for filter parameters such as pointer to history and coefficient arrays and number scaling factors
typedef struct NPNZ_FILTER_PARAMS_s NPNZ_FILTER_PARAMS_t; ///< Data structure for filter parameters such as pointer to history and coefficient arrays and number scaling factors
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_LIMITS_s
* @brief System Anti-Windup (Output Clamping) Thresholds
* @extends NPNZ16b_s
*
* @details
* The NPNZ_LIMITS_t data object holds all parameters required to automatically clamp the
* most recent control output to user-defined thresholds. This data type allows the
* definition of individual minimum and maximum output values for the NPNZ controller primary
* and alternate output port.
*
* This feature is optional and needs to be enabled, configured and managed manually in
* user code.
*
***************************************************************************************************/
struct NPNZ_LIMITS_s{
volatile int16_t MinOutput; ///< Minimum output value used for clamping (R/W)
volatile int16_t MaxOutput; ///< Maximum output value used for clamping (R/W)
volatile int16_t AltMinOutput; ///< Alternate minimum output value used for clamping (R/W)
volatile int16_t AltMaxOutput; ///< Alternate maximum output value used for clamping (R/W)
} __attribute__((packed)); ///< Data strucure holding control output clamping threshold values
typedef struct NPNZ_LIMITS_s NPNZ_LIMITS_t; ///< Data strucure holding control output clamping threshold values
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_ADC_TRGCTRL_s
* @brief Automated ADC Trigger handling
* @extends NPNZ16b_s
*
* @details
* The NPNZ_ADC_TRGCTRL_t data object holds all parameters required to automatically position
* ADC triggers based on the most recent control output. This feature is used in voltage or
* average current mode control to automatically track average values in triangular feedback
* signal waveforms.
*
* This feature is optional and needs to be enabled, configured and managed manually in
* user code.
*
***************************************************************************************************/
struct NPNZ_ADC_TRGCTRL_s{
volatile uint16_t* ptrADCTriggerARegister; ///< Pointer to ADC trigger #1 register (e.g. TRIG1)
volatile uint16_t ADCTriggerAOffset; ///< ADC trigger #1 offset to compensate propagation delays
volatile uint16_t* ptrADCTriggerBRegister; ///< Pointer to ADC trigger #2 register (e.g. TRIG2)
volatile uint16_t ADCTriggerBOffset; ///< ADC trigger #2 offset to compensate propagation delays
} __attribute__((packed)); ///< Automatic ADC trigger placement parameters for primary ADC trigger A and secondary trigger B
typedef struct NPNZ_ADC_TRGCTRL_s NPNZ_ADC_TRGCTRL_t; ///< Automatic ADC trigger placement parameters for primary ADC trigger A and secondary trigger B
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_DATA_PROVIDERS_s
* @brief Data Provider Target Memory Addresses
* @extends NPNZ16b_s
*
* @details
* The NPNZ_DATA_PROVIDERS_t data object holds pointers to external, user-defined, global
* variables allowing the NPNZ controller to push internal data to external, user-defined,
* global variables during the execution of the NPNZ controller, resulting in an automated
* updated of user-code variable values during runtime.
*
* This feature is optional and needs to be enabled, configured and managed manually in
* user code.
*
***************************************************************************************************/
struct NPNZ_DATA_PROVIDERS_s{
volatile uint16_t* ptrDProvControlInput; ///< Pointer to external data buffer of most recent, raw control input
volatile uint16_t* ptrDProvControlInputCompensated; ///< Pointer to external data buffer of most recent, compensated control input
volatile uint16_t* ptrDProvControlError; ///< Pointer to external data buffer of most recent control error
volatile uint16_t* ptrDProvControlOutput; ///< Pointer to external data buffer of most recent control output
} __attribute__((packed)); ///< Automated data provider pointers used to push most recent data points to user-defined variables
typedef struct NPNZ_DATA_PROVIDERS_s NPNZ_DATA_PROVIDERS_t; ///< Automated data provider pointers used to push most recent data points to user-defined variables
/**************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_EXTENSION_HOOKS_s
* @brief User Extension Function Call Parameters
* @extends NPNZ16b_s
*
* @details
* The NPNZ_EXTENSION_HOOKS_s data object holds all parameters required to call user-defined extension
* functions supporting advanced use cases, which are not covered by the standard functions provided.
* When enabled, the NPNZ controller can automatically call user-defined functions at specific points
* within the control loop execution flow. Each function pointer is supporting function calls with one
* additional, 16-bit wide function parameter for each extension call. These parameters can either be
* variables or pointers to variables including start addresses of user defined data structures.
*
* Each extension function call is optional and needs to be enabled, configured and managed manually
* in user code.
*
***************************************************************************************************/
struct NPNZ_EXTENSION_HOOKS_s{
volatile uint16_t ptrExtHookStartFunction; ///< Pointer to Function which will be called at the beginning of the control loop. This function pointer is stored in the data field as common unsigned integer value and needs to be casted as such. Example: my_loop.ExtensionHooks.ptrExtHookStartFunction = (uint16_t)(&my_StartHookFunction).
volatile uint16_t ExtHookStartFunctionParam; ///< Parameter of function called (can be a variable or pointer to a data structure). This parameter is optional and needs to be supported by the assembly routine to be pushed to the user function. Parameter support can be enabled/disabled for each hook function by selecting the respective option in PS-DCLD.
volatile uint16_t ptrExtHookSourceFunction; ///< Pointer to Function which will be called after the source has been read and compensated. This function pointer is stored in the data field as common unsigned integer value and needs to be casted as such. Example: my_loop.ExtensionHooks.ptrExtHookSourceFunction = (uint16_t)(&my_SourceHookFunction).
volatile uint16_t ExtHookSourceFunctionParam; ///< Parameter of function called (can be a variable or a pointer to a data structure). This parameter is optional and needs to be supported by the assembly routine to be pushed to the user function. Parameter support can be enabled/disabled for each hook function by selecting the respective option in PS-DCLD.
volatile uint16_t ptrExtHookPreAntiWindupFunction; ///< Pointer to Function which will be called after the compensation filter computation is complete and before anti-windup clamping is applied. This function pointer is stored in the data field as common unsigned integer value and needs to be casted as such. Example: my_loop.ExtensionHooks.ptrExtHookPreAntiWindupFunction = (uint16_t)(&my_PreAntiWindupHookFunction).
volatile uint16_t ExtHookPreAntiWindupFunctionParam; ///< Parameter of function called (can be a variable or a pointer to a data structure). This parameter is optional and needs to be supported by the assembly routine to be pushed to the user function. Parameter support can be enabled/disabled for each hook function by selecting the respective option in PS-DCLD.
volatile uint16_t ptrExtHookPreTargetWriteFunction; ///< Pointer to Function which will be called before the most recent control output is written to target. This function pointer is stored in the data field as common unsigned integer value and needs to be casted as such. Example: my_loop.ExtensionHooks.ptrExtHookPreTargetWriteFunction = (uint16_t)(&my_PreTargetWriteHookFunction).
volatile uint16_t ExtHookPreTargetWriteFunctionParam; ///< Parameter of function called (can be a variable or a pointer to a data structure). This parameter is optional and needs to be supported by the assembly routine to be pushed to the user function. Parameter support can be enabled/disabled for each hook function by selecting the respective option in PS-DCLD.
volatile uint16_t ptrExtHookEndOfLoopFunction; ///< Pointer to Function which is called at the end of the control loop but will be bypassed when the control loop is disabled. This function pointer is stored in the data field as common unsigned integer value and needs to be casted as such. Example: my_loop.ExtensionHooks.ptrExtHookEndOfLoopFunction = (uint16_t)(&my_EndOfLoopHookFunction).
volatile uint16_t ExtHookEndOfLoopFunctionParam; ///< Parameter of function called (can be a variable or a pointer to a data structure). This parameter is optional and needs to be supported by the assembly routine to be pushed to the user function. Parameter support can be enabled/disabled for each hook function by selecting the respective option in PS-DCLD.
volatile uint16_t ptrExtHookExitFunction; ///< Pointer to Function which is called at the end of the control loop and will also be called when the control loop is disabled. This function pointer is stored in the data field as common unsigned integer value and needs to be casted as such. Example: my_loop.ExtensionHooks.ptrExtHookExitFunction = (uint16_t)(&my_ExitHookFunction).
volatile uint16_t ExtHookExitFunctionParam; ///< Parameter of function called (can be a variable or a pointer to a data structure). This parameter is optional and needs to be supported by the assembly routine to be pushed to the user function. Parameter support can be enabled/disabled for each hook function by selecting the respective option in PS-DCLD.
} __attribute__((packed)); ///< Set of function pointers and parameters used to tie in user-defined, external extension functions at specific points of the control loop execution
typedef struct NPNZ_EXTENSION_HOOKS_s NPNZ_EXTENSION_HOOKS_t; ///< Function pointers and parameters used to tie in user-defined, external extension functions at specific points of the control loop execution
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_GAIN_CONTROL_s
* @brief Adaptive Gain Control Modulation Parameters
* @extends NPNZ16b_s
*
* @details
* The NPNZ_GAIN_CONTROL_t data object holds all parameters required to perform real-time
* gain modulation of the z-domain feedback loop. The loop gain is modulated by multiplying
* the result of the NPNZ controller B-term with an additional scaling factor. This scaling
* factor is represented by a fast floating point number, consisting of a factional factor
* <AgcFactor> between -1 and 1 and an integer bit-shift scaler <AgcScaler>.
*
* This feature is optional and needs to be enabled, configured and managed manually in
* user code.
*
***************************************************************************************************/
struct NPNZ_GAIN_CONTROL_s{
volatile uint16_t AgcScaler; ///< Bit-shift scaler of Adaptive Gain Modulation factor
volatile fractional AgcFactor; ///< Q15 value of Adaptive Gain Modulation factor
volatile fractional AgcMedian; ///< Q15 value of Adaptive Gain Modulation nominal operating point
volatile uint16_t ptrAgcObserverFunction; ///< Function Pointer to Observer function updating the AGC modulation factor. This function pointer is stored in the data field as common unsigned integer value and needs to be casted as such. Example: my_loop.GainControl.ptrAgcObserverFunction = (uint16_t)(&my_AGCFactorUpdate);
} __attribute__((packed)); ///< Data structure holding parameters required for adaptive or manual loop gain manipulation during runtime
typedef struct NPNZ_GAIN_CONTROL_s NPNZ_GAIN_CONTROL_t; ///< Data structure data type holding parameters required for adaptive or manual loop gain manipulation during runtime
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-object-members
* @struct NPNZ_USER_DATA_BUFFER_s
* @brief User Data Space for Advanced Control Functions
* @extends NPNZ16b_s
* @details
* The NPNZ_USER_DATA_BUFFER_t data object reserves four word of additional data space for
* user parameters. These parameters may be handled by user code and are not assigned to any
* specific, pre-defined functions.
*
***************************************************************************************************/
struct NPNZ_USER_DATA_BUFFER_s{
volatile uint16_t usrParam0; ///< generic 16-bit wide, user-defined parameter #1 for advanced control options
volatile uint16_t usrParam1; ///< generic 16-bit wide, user-defined parameter #2 for advanced control options
volatile uint16_t usrParam2; ///< generic 16-bit wide, user-defined parameter #3 for advanced control options
volatile uint16_t usrParam3; ///< generic 16-bit wide, user-defined parameter #4 for advanced control options
volatile uint16_t usrParam4; ///< generic 16-bit wide, user-defined parameter #5 for advanced control options
volatile uint16_t usrParam5; ///< generic 16-bit wide, user-defined parameter #6 for advanced control options
volatile uint16_t usrParam6; ///< generic 16-bit wide, user-defined parameter #7 for advanced control options
volatile uint16_t usrParam7; ///< generic 16-bit wide, user-defined parameter #8 for advanced control options
} __attribute__((packed)); ///< Generic data buffer for undetermined use. These data buffers may be used by advanced control algorithms or be used by proprietary user code modules
typedef struct NPNZ_USER_DATA_BUFFER_s NPNZ_USER_DATA_BUFFER_t; ///< Data type of generic data buffer for undetermined use. These data buffers may be used by advanced control algorithms or be used by proprietary user code modules
/***************************************************************************************************
* @ingroup special-function-layer-npnz16-data-objects
* @struct NPNZ16b_s
* @brief Global NPNZ controller data object
*
* @details
* The NPNZ16b_s data object holds all configuration, status, control and monitoring values
* of a z-domain lead-lag compensator based controller. All data types of this data object,
* including floating, are scaled to a 16 bit number space, optimized for code execution on
* Microchip dsPIC33 family of devices. Please refer to the description of nested data
* structures above for more information about nested data objects.
*
***************************************************************************************************/
struct NPNZ16b_s {
volatile struct NPNZ_STATUS_s status; ///< Control Loop Status and Control flags
volatile struct NPNZ_PORTS_s Ports; ///< Controller input and output ports
volatile struct NPNZ_FILTER_PARAMS_s Filter; ///< Filter parameters such as pointer to history and coefficient arrays and number scaling
volatile struct NPNZ_GAIN_CONTROL_s GainControl; ///< Parameter section for advanced control options
volatile struct NPNZ_LIMITS_s Limits; ///< Input and output clamping values
volatile struct NPNZ_ADC_TRGCTRL_s ADCTriggerControl; ///< Automatic ADC trigger placement options for ADC Trigger A and B
volatile struct NPNZ_DATA_PROVIDERS_s DataProviders; ///< Automated data sources pushing recent data points to user-defined variables
volatile struct NPNZ_EXTENSION_HOOKS_s ExtensionHooks; ///< User extension function triggers using function pointers with parameters
volatile struct NPNZ_USER_DATA_BUFFER_s Advanced; ///< Parameter section for advanced user control options
} __attribute__((packed)) ; ///< Generic NPNZ16b Controller Object. This data structure is the main API data object providing single-point access to all controller settings and parameters
typedef struct NPNZ16b_s NPNZ16b_t; ///< Generic NPNZ16b Controller Object Data Type. This data structure is the main API data object providing single-point access to all controller settings and parameters
/* ********************************************************************************/
#endif // end of __SPECIAL_FUNCTION_LAYER_LIB_NPNZ16B_H__ header file section
//**********************************************************************************
// Download latest version of this tool here: https://areiter128.github.io/DCLD
//**********************************************************************************
| 71.642586 | 422 | 0.64412 | [
"object"
] |
37303f7f1ad2cc937f35bc13ee9472ebfce08fa8 | 5,690 | h | C | source/frontend/models/compare/memory_leak_finder_model.h | GPUOpen-Tools/radeon_memory_visualizer | 309ac5b04b870aef408603eaac4bd727d5d3e698 | [
"MIT"
] | 86 | 2020-05-14T17:20:22.000Z | 2022-01-21T22:53:24.000Z | source/frontend/models/compare/memory_leak_finder_model.h | GPUOpen-Tools/radeon_memory_visualizer | 309ac5b04b870aef408603eaac4bd727d5d3e698 | [
"MIT"
] | 6 | 2020-05-16T18:50:00.000Z | 2022-01-21T15:30:16.000Z | source/frontend/models/compare/memory_leak_finder_model.h | GPUOpen-Tools/radeon_memory_visualizer | 309ac5b04b870aef408603eaac4bd727d5d3e698 | [
"MIT"
] | 11 | 2020-10-15T15:55:56.000Z | 2022-03-16T20:38:29.000Z | //=============================================================================
// Copyright (c) 2018-2021 Advanced Micro Devices, Inc. All rights reserved.
/// @author AMD Developer Tools Team
/// @file
/// @brief Header for the Memory Leak Finder model.
//=============================================================================
#ifndef RMV_MODELS_COMPARE_MEMORY_LEAK_FINDER_MODEL_H_
#define RMV_MODELS_COMPARE_MEMORY_LEAK_FINDER_MODEL_H_
#include "qt_common/custom_widgets/scaled_table_view.h"
#include "qt_common/utils/model_view_mapper.h"
#include "rmt_data_set.h"
#include "rmt_data_snapshot.h"
#include "rmt_resource_list.h"
#include "rmt_virtual_allocation_list.h"
#include "models/proxy_models/memory_leak_finder_proxy_model.h"
#include "models/resource_item_model.h"
#include "util/constants.h"
namespace rmv
{
/// @brief Enum containing the id's of UI elements needed by the model.
enum MemoryLeakFinderWidgets
{
kMemoryLeakFinderBaseStats,
kMemoryLeakFinderBothStats,
kMemoryLeakFinderDiffStats,
kMemoryLeakFinderTotalResources,
kMemoryLeakFinderTotalSize,
kMemoryLeakFinderBaseCheckbox,
kMemoryLeakFinderDiffCheckbox,
kMemoryLeakFinderBaseSnapshot,
kMemoryLeakFinderDiffSnapshot,
kMemoryLeakFinderNumWidgets,
};
/// @brief Container class that holds model data for the memory leak finder pane.
class MemoryLeakFinderModel : public ModelViewMapper
{
public:
/// @brief Constructor.
explicit MemoryLeakFinderModel();
/// @brief Destructor.
virtual ~MemoryLeakFinderModel();
/// @brief Initialize the table model.
///
/// @param [in] table_view The view to the table.
/// @param [in] num_rows Total rows of the table.
/// @param [in] num_columns Total columns of the table.
/// @param [in] compare_id_filter The starting filter value.
void InitializeTableModel(ScaledTableView* table_view, uint num_rows, uint num_columns, uint32_t compare_id_filter);
/// @brief Update the model.
///
/// @param [in] compare_filter The compare filter ID, to indicate which resources are to be displayed.
void Update(SnapshotCompareId compare_filter);
/// @brief Initialize blank data for the model.
void ResetModelValues();
/// @brief Handle what happens when user changes the search filter.
///
/// @param [in] filter The search text filter.
void SearchBoxChanged(const QString& filter);
/// @brief Handle what happens when user changes the 'filter by size' slider.
///
/// @param [in] min_value Minimum value of slider span.
/// @param [in] max_value Maximum value of slider span.
void FilterBySizeChanged(int min_value, int max_value);
/// @brief Update the list of heaps selected. This is set up from the preferred heap combo box.
///
/// @param [in] preferred_heap_filter The regular expression string of selected heaps.
void UpdatePreferredHeapList(const QString& preferred_heap_filter);
/// @brief Update the list of resources available. This is set up from the resource usage combo box.
///
/// @param [in] resource_usage_filter The regular expression string of selected resource usage types.
void UpdateResourceUsageList(const QString& resource_usage_filter);
/// @brief Get the resource proxy model. Used to set up a connection between the table being sorted and the UI update.
///
/// @return the proxy model.
MemoryLeakFinderProxyModel* GetResourceProxyModel() const;
/// @brief Figure out which snapshot the selected table entry is from and set up the snapshot
/// for load if it's not already loaded.
///
/// It will be in memory already but just needs assigning to be the snapshot that is visible
/// in the snapshot tab.
///
/// @param [in] index The model index for the entry selected in the memory leak resource table.
///
/// @return The snapshot point of the snapshot containing the resource.
RmtSnapshotPoint* FindSnapshot(const QModelIndex& index) const;
private:
/// @brief Update the resource size buckets.
///
/// This is used by the double-slider to group the resource sizes. Called whenever the table data changes.
void UpdateResourceThresholds();
/// @brief Update labels at the bottom.
void UpdateLabels();
/// @brief Reset the snapshot stats.
void ResetStats();
ResourceItemModel* table_model_; ///< The data for the resource table.
MemoryLeakFinderProxyModel* proxy_model_; ///< The proxy model for the resource table.
uint64_t resource_thresholds_[kSizeSliderRange + 1]; ///< List of resource size thresholds for the filter by size sliders.
/// @brief struct to describe the snapshot statistics
struct SnapshotStats
{
uint32_t num_resources; ///< The number of resources.
uint64_t size; ///< The total size of all resources.
};
SnapshotStats stats_in_both_; ///< Attributes in both snapshots.
SnapshotStats stats_in_base_only_; ///< Attributes in the base snapshot only.
SnapshotStats stats_in_diff_only_; ///< Attributes in the diff snapshot only.
};
} // namespace rmv
#endif // RMV_MODELS_COMPARE_MEMORY_LEAK_FINDER_MODEL_H_
| 42.462687 | 150 | 0.647276 | [
"model"
] |
373ddc1fb410f0974056048c68aa9ca8183ffba5 | 4,459 | h | C | src/condor_utils/sshd_wrapper.dead.h | neurodebian/htcondor | 113a5c9921a4fce8a21e3ab96b2c1ba47441bf39 | [
"Apache-2.0"
] | 2 | 2018-06-18T23:11:20.000Z | 2021-01-11T06:30:00.000Z | src/condor_utils/sshd_wrapper.dead.h | neurodebian/htcondor | 113a5c9921a4fce8a21e3ab96b2c1ba47441bf39 | [
"Apache-2.0"
] | 1 | 2021-04-06T04:19:40.000Z | 2021-04-06T04:19:40.000Z | src/condor_utils/sshd_wrapper.dead.h | neurodebian/htcondor | 113a5c9921a4fce8a21e3ab96b2c1ba47441bf39 | [
"Apache-2.0"
] | 2 | 2017-11-09T01:42:58.000Z | 2020-07-14T20:20:05.000Z | /***************************************************************
*
* Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
* University of Wisconsin-Madison, WI.
*
* 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.
*
***************************************************************/
class SshdWrapper
{
public:
/** Create an object to manage our interaction with sshd.
*/
SshdWrapper();
/// dtor
virtual ~SshdWrapper();
/**
@param filename This is the filename to use to
store the key files. It should be an
absolute path
*/
bool initialize(char *filename);
/** Create identity keys in filename passed to the
initialize method (filename.pub, filename.key).
@return true on success, false on failure.
*/
bool createIdentityKeys();
/** Get the public key as an alphanumeric string.
@return On failure, returns NULL. On success, returns
a pointer to a null-terminated alphanumeric string.
It is expected this string will be used as input to
extractPubKeyFromAd(). This pointer must be
deallocated by the caller with free().
@see extractPubKeyFromAd
*/
char* getPubKeyFromFile();
/** Set the public key into an sshd happy .pub file.
@param keyString This should be a null-terminated
string returned from a previous call to
getPubKeyFromFile(). @return true on success,
false on failure. @see getPubKeyFromFile
*/
bool setPubKeyToFile(const char* keyString);
/** This method returns info on how the sshd should
be spawned. @param executable null
terminated string with the absolute pathname
to the sshd. caller is responsible
deallocating with free(). @param args null
terminated string with the arguments for the
sshd; each arg is separated via spaces.
caller is responsible deallocating with
free(). @param env null terminated string
with the environment to use when starting the
sshd. each env variable is seperated with
something, maybe semi-colons. Who knows? But
we do know that the caller is responsible
deallocating with free(). @return On
failure, returns false and all pointers will
be NULL. On success returns true and no
pointers will be NULL.
*/
bool getSshdExecInfo(char* & executable, char* & args, char* & env );
/**
This method decides if we should try to span sshd again.
@param exit_status the exit status from running sshd.
@return true if we should try again, false if not.
*/
bool onSshdExitTryAgain(int exit_status);
/**
Only can call after call to getSshdExecInfo, user
responsible for freeing.
@param sinful_string address:port
@param dir execute directory on the remote side
@param username system username to ssh -l
@return true if all went well
*/
bool getSshRuntimeInfo(char* & sinful_string, char* & dir, char* &
username);
/**
@param sinful_string address:port
@param dir execute directory on the remote side
@param username system username to ssh -l
@return true
*/
bool setSshRuntimeInfo(const char* sinful_string, const char* dir,
const char* username);
/**
This method sends (via scp) the private key file and
the contact file over.
@param contactFileSrc filename of contact file to send
@return true if all went well
*/
bool sendPrivateKeyAndContactFile(const char* contactFileSrc);
/**
Only can call after setSshRuntimeInfo, NULL
@return a user-freeable string containing the line
to append to the contact file
*/
char* generateContactFileLine(int node);
protected:
bool createIdentityKeys(char *privateKey);
private:
SshdWrapper(const SshdWrapper &) {}
SshdWrapper &operator=(const SshdWrapper &l) {return *this;}
char *pubKeyFile;
char *privKeyFile;
char *hostKeyFile;
int port;
int launchTime;
const char *sinful;
const char *dir;
const char *username;
};
| 29.335526 | 75 | 0.688944 | [
"object"
] |
374c1df7a2c886ddcbc0a0b4c5503e919ce31fc7 | 4,058 | c | C | ext/Gaussian/cgaussian.c | Himeyama/ruby-filter-gaussian | 93e9d28ccbd7540c3c4da6f869a088e49d39a8ac | [
"MIT"
] | null | null | null | ext/Gaussian/cgaussian.c | Himeyama/ruby-filter-gaussian | 93e9d28ccbd7540c3c4da6f869a088e49d39a8ac | [
"MIT"
] | 1 | 2021-09-10T06:19:26.000Z | 2021-09-10T06:24:55.000Z | ext/Gaussian/cgaussian.c | Himeyama/ruby-filter-gaussian | 93e9d28ccbd7540c3c4da6f869a088e49d39a8ac | [
"MIT"
] | null | null | null | /*
* (c) 2021 Murata Mitsuharu
* Licensed under the MIT License.
* source: https://github.com/Himeyama/C-Gaussian-Filter
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ruby.h>
#include <numo/narray.h>
#include "gaussian.h"
void Vector_p(Vector vec){
double* data = vec.data;
char* str = (char*)malloc(100000000); // 100MB
char d[16];
for(int i = 0; i < vec.size; i++){
sprintf(d, i == vec.size - 1 ? "%f" : "%f, ", data[i]);
// \(^o^)/
strcat(str, d);
}
printf("[%s]\n", str);
}
void Vector_txt(Vector vec){
double* data = vec.data;
char* str = (char*)malloc(100000000); // 100MB
char d[16];
for(int i = 0; i < vec.size; i++){
sprintf(d, "%f\n", data[i]);
// \(^o^)/
strcat(str, d);
}
printf("%s", str);
}
void Vector_destroy(Vector vec){
free(vec.data);
}
Vector Vector_initialize(long size){
Vector vec;
vec.size = size;
vec.data = (double*)malloc(sizeof(double) * size);
return vec;
}
Vector Vector_initializeP(long size, Vector* vec){
vec->size = size;
vec->data = (double*)malloc(sizeof(double) * size);
return *vec;
}
Vector Vector_zeros(long size){
Vector vec = Vector_initialize(size);
for(int i = 0; i < size; i++)
vec.data[i] = 0;
return vec;
}
double Vector_dot(Vector vec1, Vector vec2){
if(vec1.size != vec2.size){
fprintf(stderr, "ベクトルのサイズが異なります\n");
exit(EXIT_FAILURE);
}
double dot = 0;
for(int i = 0; i < vec1.size; i++){
dot += vec1.data[i] * vec2.data[i];
}
return dot;
}
Vector Vector_arange(int start, int stop){
int size = stop - start;
Vector vec = Vector_initialize(size);
for(int i = 0; i < size; i++){
vec.data[i] = start + i;
}
return vec;
}
double Vector_sum(Vector vec){
double sum = 0;
for(int i = 0; i < vec.size; i++)
sum += vec.data[i];
return sum;
}
// 破壊的関数
void Vector_div(Vector vec, double n){
for(int i = 0; i < vec.size; i++){
vec.data[i] /= n;
}
}
// 正規分布 (0, 1) に従う乱数
Vector Vector_normal(long size){
Vector vec = Vector_initialize(size);
for(int i = 0; i < size; i++){
double u1 = drand48();
double u2 = drand48();
vec.data[i] = sqrt(-2 * log(u1)) * sin(2 * M_PI * u2);
}
return vec;
}
Vector Vector_clone(Vector vec){
Vector c = Vector_initialize(vec.size);
for(int i = 0; i < vec.size; i++)
c.data[i] = vec.data[i];
return c;
}
void* gaussian(GaussianArgsRet* ga){
Vector src_data = ga->src_data;
double sd = ga->sd;
double truncate = ga->truncate;
// printf("sd: %lf\n", sd);
// printf("truncate: %lf\n", truncate);
// Vector_p(src_data);
int r = (int)(truncate * sd + 0.5);
if(r > src_data.size){
fprintf(stderr, "データが小さすぎます\n");
exit(EXIT_FAILURE);
}
Vector data = Vector_initialize(src_data.size + 2 * r);
for(int i = 0; i < r; i++)
data.data[i] = src_data.data[r-i-1];
for(int i = r; i < src_data.size + r; i++)
data.data[i] = src_data.data[i-r];
for(int i = 0; i < r; i++)
data.data[i+r+src_data.size] = src_data.data[src_data.size-i-1];
Vector f = Vector_initialize(data.size);
Vector x = Vector_arange(-r, r+1);
Vector gauss = Vector_zeros(2*r+1);
for(int i = 0; i < x.size; i++){
gauss.data[i] = exp(-0.5 * x.data[i] * x.data[i] / (sd * sd));
}
Vector_div(gauss, Vector_sum(gauss));
for(int i = r; i < data.size - r; i++){
Vector d;
d.size = 2 * r + 1;
d.data = data.data + i - r;
f.data[i] = Vector_dot(gauss, d);
}
Vector *filtered = ga->dst_data;
Vector_initializeP(src_data.size, filtered);
for(int i = 0; i < filtered->size; i++){
filtered->data[i] = f.data[i + r];
}
Vector_destroy(data);
Vector_destroy(f);
Vector_destroy(x);
Vector_destroy(gauss);
return NULL;
} | 23.730994 | 72 | 0.553228 | [
"vector"
] |
375f04eb218f4d68cf6f86f87c21b958cf3286b1 | 740 | h | C | Unix/samples/Providers/Test_AssociationProvider/CommonUtils.h | Beguiled/omi | 1c824681ee86f32314f430db972e5d3938f10fd4 | [
"MIT"
] | 165 | 2016-08-18T22:06:39.000Z | 2019-05-05T11:09:37.000Z | Unix/samples/Providers/Test_AssociationProvider/CommonUtils.h | snchennapragada/omi | 4fa565207d3445d1f44bfc7b890f9ea5ea7b41d0 | [
"MIT"
] | 409 | 2016-08-18T20:52:56.000Z | 2019-05-06T10:03:11.000Z | Unix/samples/Providers/Test_AssociationProvider/CommonUtils.h | snchennapragada/omi | 4fa565207d3445d1f44bfc7b890f9ea5ea7b41d0 | [
"MIT"
] | 72 | 2016-08-23T02:30:08.000Z | 2019-04-30T22:57:03.000Z | /*
**==============================================================================
**
** Copyright (c) Microsoft Corporation. All rights reserved. See file LICENSE
** for license information.
**
**==============================================================================
*/
#ifndef _CommonUtils_h
#define _CommonUtils_h
#include "Test_LogicalDisk.h"
#include "Test_PhysicalDisk.h"
#include "Test_VirtualDisk.h"
#include <vector>
void CreateVirtualDiskInstances(MI_Context* context, std::vector<Test_VirtualDisk*>& virtualStore);
void CreatePhysicalDiskInstances(MI_Context* context, std::vector<Test_PhysicalDisk*>& phyStore);
void CreateLogicalDiskInstances(MI_Context* context, std::vector<Test_LogicalDisk*>& logStore);
#endif
| 32.173913 | 99 | 0.62027 | [
"vector"
] |
376172a6f91a608ff08679b5042eedfe10e0885e | 5,577 | c | C | src/frr/bgpd/bgp_table.c | zhouhaifeng/vpe | 9c644ffd561988e5740021ed26e0f7739844353d | [
"Apache-2.0"
] | null | null | null | src/frr/bgpd/bgp_table.c | zhouhaifeng/vpe | 9c644ffd561988e5740021ed26e0f7739844353d | [
"Apache-2.0"
] | null | null | null | src/frr/bgpd/bgp_table.c | zhouhaifeng/vpe | 9c644ffd561988e5740021ed26e0f7739844353d | [
"Apache-2.0"
] | null | null | null | /* BGP routing table
* Copyright (C) 1998, 2001 Kunihiro Ishiguro
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "prefix.h"
#include "memory.h"
#include "sockunion.h"
#include "queue.h"
#include "filter.h"
#include "command.h"
#include "printfrr.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
#include "bgp_addpath.h"
#include "bgp_trace.h"
void bgp_table_lock(struct bgp_table *rt)
{
rt->lock++;
}
void bgp_table_unlock(struct bgp_table *rt)
{
assert(rt->lock > 0);
rt->lock--;
if (rt->lock != 0) {
return;
}
route_table_finish(rt->route_table);
rt->route_table = NULL;
XFREE(MTYPE_BGP_TABLE, rt);
}
void bgp_table_finish(struct bgp_table **rt)
{
if (*rt != NULL) {
bgp_table_unlock(*rt);
*rt = NULL;
}
}
/*
* bgp_dest_unlock_node
*/
void bgp_dest_unlock_node(struct bgp_dest *dest)
{
frrtrace(1, frr_bgp, bgp_dest_unlock, dest);
bgp_delete_listnode(dest);
route_unlock_node(bgp_dest_to_rnode(dest));
}
/*
* bgp_dest_lock_node
*/
struct bgp_dest *bgp_dest_lock_node(struct bgp_dest *dest)
{
frrtrace(1, frr_bgp, bgp_dest_lock, dest);
struct route_node *rn = route_lock_node(bgp_dest_to_rnode(dest));
return bgp_dest_from_rnode(rn);
}
/*
* bgp_dest_get_prefix_str
*/
const char *bgp_dest_get_prefix_str(struct bgp_dest *dest)
{
const struct prefix *p = NULL;
char str[PREFIX_STRLEN] = {0};
p = bgp_dest_get_prefix(dest);
if (p)
return prefix2str(p, str, sizeof(str));
return NULL;
}
/*
* bgp_node_create
*/
static struct route_node *bgp_node_create(route_table_delegate_t *delegate,
struct route_table *table)
{
struct bgp_node *node;
node = XCALLOC(MTYPE_BGP_NODE, sizeof(struct bgp_node));
RB_INIT(bgp_adj_out_rb, &node->adj_out);
return bgp_dest_to_rnode(node);
}
/*
* bgp_node_destroy
*/
static void bgp_node_destroy(route_table_delegate_t *delegate,
struct route_table *table, struct route_node *node)
{
struct bgp_node *bgp_node;
struct bgp_table *rt;
bgp_node = bgp_dest_from_rnode(node);
rt = table->info;
if (rt->bgp) {
bgp_addpath_free_node_data(&rt->bgp->tx_addpath,
&bgp_node->tx_addpath,
rt->afi, rt->safi);
}
XFREE(MTYPE_BGP_NODE, bgp_node);
}
/*
* Function vector to customize the behavior of the route table
* library for BGP route tables.
*/
route_table_delegate_t bgp_table_delegate = {.create_node = bgp_node_create,
.destroy_node = bgp_node_destroy};
/*
* bgp_table_init
*/
struct bgp_table *bgp_table_init(struct bgp *bgp, afi_t afi, safi_t safi)
{
struct bgp_table *rt;
rt = XCALLOC(MTYPE_BGP_TABLE, sizeof(struct bgp_table));
rt->route_table = route_table_init_with_delegate(&bgp_table_delegate);
/*
* Set up back pointer to bgp_table.
*/
route_table_set_info(rt->route_table, rt);
/*
* pointer to bgp instance allows working back from bgp_path_info to bgp
*/
rt->bgp = bgp;
bgp_table_lock(rt);
rt->afi = afi;
rt->safi = safi;
return rt;
}
/* Delete the route node from the selection deferral route list */
void bgp_delete_listnode(struct bgp_node *node)
{
struct route_node *rn = NULL;
struct bgp_table *table = NULL;
struct bgp *bgp = NULL;
afi_t afi;
safi_t safi;
/* If the route to be deleted is selection pending, update the
* route node in gr_info
*/
if (CHECK_FLAG(node->flags, BGP_NODE_SELECT_DEFER)) {
table = bgp_dest_table(node);
if (table) {
bgp = table->bgp;
afi = table->afi;
safi = table->safi;
} else
return;
rn = bgp_dest_to_rnode(node);
if (bgp && rn && rn->lock == 1) {
/* Delete the route from the selection pending list */
bgp->gr_info[afi][safi].gr_deferred--;
UNSET_FLAG(node->flags, BGP_NODE_SELECT_DEFER);
}
}
}
struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table,
const struct prefix *p)
{
struct bgp_node *node = bgp_dest_from_rnode(table->route_table->top);
struct bgp_node *matched = NULL;
if (node == NULL)
return NULL;
while (node) {
const struct prefix *node_p = bgp_dest_get_prefix(node);
if (node_p->prefixlen >= p->prefixlen) {
if (!prefix_match(p, node_p))
return NULL;
matched = node;
break;
}
if (!prefix_match(node_p, p))
return NULL;
if (node_p->prefixlen == p->prefixlen) {
matched = node;
break;
}
node = bgp_dest_from_rnode(node->link[prefix_bit(
&p->u.prefix, node_p->prefixlen)]);
}
if (!matched)
return NULL;
bgp_dest_lock_node(matched);
return matched;
}
printfrr_ext_autoreg_p("BD", printfrr_bd)
static ssize_t printfrr_bd(struct fbuf *buf, struct printfrr_eargs *ea,
const void *ptr)
{
const struct bgp_dest *dest = ptr;
const struct prefix *p = bgp_dest_get_prefix(dest);
char cbuf[PREFIX_STRLEN];
if (!dest)
return bputs(buf, "(null)");
/* need to get the real length even if buffer too small */
prefix2str(p, cbuf, sizeof(cbuf));
return bputs(buf, cbuf);
}
| 21.870588 | 78 | 0.70719 | [
"vector"
] |
377179499abfbc5f15cfad31a2c9966d52d43c90 | 1,175 | h | C | Sintactico.h | ivanovishado/Mini-Compilador | 189a2399a59d4710213eab147190c40176626bfa | [
"MIT"
] | null | null | null | Sintactico.h | ivanovishado/Mini-Compilador | 189a2399a59d4710213eab147190c40176626bfa | [
"MIT"
] | null | null | null | Sintactico.h | ivanovishado/Mini-Compilador | 189a2399a59d4710213eab147190c40176626bfa | [
"MIT"
] | null | null | null | #ifndef SINTACTICO_H_INCLUDED
#define SINTACTICO_H_INCLUDED
#include <iostream>
#include <cstring>
#include "Lexico.h"
#include "Asignacion.h"
#include "Bloque.h"
#include "Entero.h"
#include "Expresion.h"
#include "ExpresionRelacional.h"
#include "Identificador.h"
#include "Mientras.h"
#include "Operacion.h"
#include "Otro.h"
#include "Real.h"
#include "Si.h"
#include "Signo.h"
class Sintactico
{
public:
Sintactico(std::ifstream& ifs)
{
lexico.asignaEntrada(ifs);
lexico.sigSimbolo();
}
void analiza(std::vector<Nodo*>& v);
private:
Lexico lexico;
void comprueba(std::string simbolo)
{
(lexico.dameSimbolo() == simbolo) ? lexico.sigSimbolo() : throw ExcepcionSintactica();
}
void comprueba(int tipo)
{
(lexico.dameTipo() == tipo) ? lexico.sigSimbolo() : throw ExcepcionSintactica();
}
Asignacion* generaAsignacion(void);
Mientras* generaMientras(void);
Si* generaSi(void);
Expresion* expresion(void);
Expresion* multiplicacion(void);
Expresion* factor(void);
Nodo* sentencias(void);
ExpresionRelacional* expresionRelacional(void);
ExpresionRelacional* otraExpresion(void);
Otro* otro(void);
};
#endif //SINTACTICO_H_INCLUDED
| 18.076923 | 88 | 0.730213 | [
"vector"
] |
3773b74351579c5c01fe29fc10ed777c01885629 | 6,149 | h | C | SPHINXsys/src/shared/particles/diffusion_reaction_particles.h | konmenel/SPHinXsys | 6be5430767c6a3a38aec39ffcc6620e66f71f16c | [
"Apache-2.0"
] | null | null | null | SPHINXsys/src/shared/particles/diffusion_reaction_particles.h | konmenel/SPHinXsys | 6be5430767c6a3a38aec39ffcc6620e66f71f16c | [
"Apache-2.0"
] | null | null | null | SPHINXsys/src/shared/particles/diffusion_reaction_particles.h | konmenel/SPHinXsys | 6be5430767c6a3a38aec39ffcc6620e66f71f16c | [
"Apache-2.0"
] | null | null | null | /* -------------------------------------------------------------------------*
* SPHinXsys *
* --------------------------------------------------------------------------*
* SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle *
* Hydrodynamics for industrial compleX systems. It provides C++ APIs for *
* physical accurate simulation and aims to model coupled industrial dynamic *
* systems including fluid, solid, multi-body dynamics and beyond with SPH *
* (smoothed particle hydrodynamics), a meshless computational method using *
* particle discretization. *
* *
* SPHinXsys is partially funded by German Research Foundation *
* (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1 *
* and HU1527/12-1. *
* *
* Portions copyright (c) 2017-2020 Technical University of Munich and *
* the authors' affiliations. *
* *
* 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. *
* *
* --------------------------------------------------------------------------*/
/**
* @file diffusion_reaction_particles.h
* @brief This is the derived class of diffusion reaction particles.
* @author Xiangyu Huand Chi Zhang
*/
#ifndef DIFFUSION_REACTION_PARTICLES_H
#define DIFFUSION_REACTION_PARTICLES_H
#include "base_particles.h"
#include "base_body.h"
#include "base_material.h"
#include "diffusion_reaction.h"
#include "xml_engine.h"
#include "solid_particles.h"
namespace SPH
{
/**
* @class DiffusionReactionParticles
* @brief A group of particles with diffusion or/and reactions particle data.
*/
template <class BaseParticlesType = BaseParticles, class BaseMaterialType = BaseMaterial>
class DiffusionReactionParticles : public BaseParticlesType
{
protected:
size_t number_of_species_; /**< Total number of diffusion and reaction species . */
size_t number_of_diffusion_species_; /**< Total number of diffusion species . */
std::map<std::string, size_t> species_indexes_map_;
public:
StdVec<StdLargeVec<Real>> species_n_; /**< array of diffusion/reaction scalars */
StdVec<StdLargeVec<Real>> diffusion_dt_; /**< array of the time derivative of diffusion species */
DiffusionReactionParticles(SPHBody &sph_body,
SharedPtr<DiffusionReaction<BaseParticlesType, BaseMaterialType>> diffusion_reaction_material_ptr,
SharedPtr<ParticleGenerator> particle_generator_ptr = makeShared<ParticleGeneratorLattice>())
: BaseParticlesType(sph_body, diffusion_reaction_material_ptr, particle_generator_ptr)
{
diffusion_reaction_material_ptr->assignDiffusionReactionParticles(this);
species_indexes_map_ = diffusion_reaction_material_ptr->SpeciesIndexMap();
number_of_species_ = diffusion_reaction_material_ptr->NumberOfSpecies();
species_n_.resize(number_of_species_);
std::map<std::string, size_t>::iterator itr;
for (itr = species_indexes_map_.begin(); itr != species_indexes_map_.end(); ++itr)
{
//Register a species. Note that we call a template function from a template class
this->template registerAVariable<indexScalar, Real>(species_n_[itr->second], itr->first);
//the scalars will be sorted if particle sorting is called
this->template registerASortableVariable<indexScalar, Real>(itr->first);
// add species to basic output particle data
this->template addAVariableToWrite<indexScalar, Real>(itr->first);
}
number_of_diffusion_species_ = diffusion_reaction_material_ptr->NumberOfSpeciesDiffusion();
diffusion_dt_.resize(number_of_diffusion_species_);
for (size_t m = 0; m < number_of_diffusion_species_; ++m)
{
//----------------------------------------------------------------------
// register reactive change rate terms without giving variable name
//----------------------------------------------------------------------
std::get<indexScalar>(this->all_particle_data_).push_back(&diffusion_dt_[m]);
diffusion_dt_[m].resize(this->real_particles_bound_, Real(0));
}
};
virtual ~DiffusionReactionParticles(){};
std::map<std::string, size_t> SpeciesIndexMap() { return species_indexes_map_; };
virtual DiffusionReactionParticles<BaseParticlesType, BaseMaterialType> *
ThisObjectPtr() override { return this; };
};
/**
* @class ElectroPhysiologyParticles
* @brief A group of particles with electrophysiology particle data.
*/
class ElectroPhysiologyParticles
: public DiffusionReactionParticles<SolidParticles, Solid>
{
public:
ElectroPhysiologyParticles(SPHBody &sph_body,
SharedPtr<DiffusionReaction<SolidParticles, Solid>> diffusion_reaction_material_ptr,
SharedPtr<ParticleGenerator> particle_generator_ptr = makeShared<ParticleGeneratorLattice>());
virtual ~ElectroPhysiologyParticles(){};
virtual ElectroPhysiologyParticles *ThisObjectPtr() override { return this; };
};
/**
* @class ElectroPhysiologyReducedParticles
* @brief A group of reduced particles with electrophysiology particle data.
*/
class ElectroPhysiologyReducedParticles
: public DiffusionReactionParticles<SolidParticles, Solid>
{
public:
/** Constructor. */
ElectroPhysiologyReducedParticles(SPHBody &sph_body,
SharedPtr<DiffusionReaction<SolidParticles, Solid>> diffusion_reaction_material_ptr,
SharedPtr<ParticleGenerator> particle_generator_ptr = makeShared<ParticleGeneratorLattice>());
/** Destructor. */
virtual ~ElectroPhysiologyReducedParticles(){};
virtual ElectroPhysiologyReducedParticles *ThisObjectPtr() override { return this; };
virtual Vecd getKernelGradient(size_t particle_index_i, size_t particle_index_j, Real dW_ij, Vecd &e_ij) override
{
return dW_ij * e_ij;
};
};
}
#endif //DIFFUSION_REACTION_PARTICLES_H | 45.88806 | 115 | 0.680598 | [
"model",
"solid"
] |
3774345c76478e5fb306492fbb378263e747768b | 10,115 | c | C | unix/OLD_table.c | chayward/libui | 34d1d0ac48f4695d3170a20e480567d68f587de0 | [
"MIT"
] | 11,062 | 2015-04-17T00:46:13.000Z | 2022-03-31T11:24:06.000Z | unix/OLD_table.c | chayward/libui | 34d1d0ac48f4695d3170a20e480567d68f587de0 | [
"MIT"
] | 505 | 2015-09-03T15:15:45.000Z | 2022-03-06T04:55:33.000Z | unix/OLD_table.c | chayward/libui | 34d1d0ac48f4695d3170a20e480567d68f587de0 | [
"MIT"
] | 798 | 2015-09-29T11:01:06.000Z | 2022-03-29T10:24:18.000Z | // 26 june 2016
#include "uipriv_unix.h"
void *uiTableModelStrdup(const char *str)
{
return g_strdup(str);
}
void *uiTableModelGiveColor(double r, double g, double b, double a)
{
GdkRGBA rgba;
rgba.red = r;
rgba.green = g;
rgba.blue = b;
rgba.alpha = a;
return gdk_rgba_copy(&rgba);
}
uiTableModel *uiNewTableModel(uiTableModelHandler *mh)
{
uiTableModel *m;
m = uiTableModel(g_object_new(uiTableModelType, NULL));
m->mh = mh;
return m;
}
void uiFreeTableModel(uiTableModel *m)
{
g_object_unref(m);
}
void uiTableModelRowInserted(uiTableModel *m, int newIndex)
{
GtkTreePath *path;
GtkTreeIter iter;
path = gtk_tree_path_new_from_indices(newIndex, -1);
iter.stamp = STAMP_GOOD;
iter.user_data = GINT_TO_POINTER(newIndex);
gtk_tree_model_row_inserted(GTK_TREE_MODEL(m), path, &iter);
gtk_tree_path_free(path);
}
void uiTableModelRowChanged(uiTableModel *m, int index)
{
GtkTreePath *path;
GtkTreeIter iter;
path = gtk_tree_path_new_from_indices(index, -1);
iter.stamp = STAMP_GOOD;
iter.user_data = GINT_TO_POINTER(index);
gtk_tree_model_row_changed(GTK_TREE_MODEL(m), path, &iter);
gtk_tree_path_free(path);
}
void uiTableModelRowDeleted(uiTableModel *m, int oldIndex)
{
GtkTreePath *path;
path = gtk_tree_path_new_from_indices(oldIndex, -1);
gtk_tree_model_row_deleted(GTK_TREE_MODEL(m), path);
gtk_tree_path_free(path);
}
enum {
partText,
partImage,
partButton,
partCheckbox,
partProgressBar,
};
struct tablePart {
int type;
int textColumn;
int imageColumn;
int valueColumn;
int colorColumn;
GtkCellRenderer *r;
uiTable *tv; // for pixbufs and background color
};
struct uiTableColumn {
GtkTreeViewColumn *c;
uiTable *tv; // for pixbufs and background color
GPtrArray *parts;
};
struct uiTable {
uiUnixControl c;
GtkWidget *widget;
GtkContainer *scontainer;
GtkScrolledWindow *sw;
GtkWidget *treeWidget;
GtkTreeView *tv;
GPtrArray *columns;
uiTableModel *model;
int backgroundColumn;
};
// use the same size as GtkFileChooserWidget's treeview
// TODO refresh when icon theme changes
// TODO doesn't work when scaled
// TODO is this even necessary?
static void setImageSize(GtkCellRenderer *r)
{
gint size;
gint width, height;
gint xpad, ypad;
size = 16; // fallback used by GtkFileChooserWidget
if (gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height) != FALSE)
size = MAX(width, height);
gtk_cell_renderer_get_padding(r, &xpad, &ypad);
gtk_cell_renderer_set_fixed_size(r,
2 * xpad + size,
2 * ypad + size);
}
static void applyColor(GtkTreeModel *mm, GtkTreeIter *iter, int modelColumn, GtkCellRenderer *r, const char *prop, const char *propSet)
{
GValue value = G_VALUE_INIT;
GdkRGBA *rgba;
gtk_tree_model_get_value(mm, iter, modelColumn, &value);
rgba = (GdkRGBA *) g_value_get_boxed(&value);
if (rgba != NULL)
g_object_set(r, prop, rgba, NULL);
else
g_object_set(r, propSet, FALSE, NULL);
g_value_unset(&value);
}
static void dataFunc(GtkTreeViewColumn *c, GtkCellRenderer *r, GtkTreeModel *mm, GtkTreeIter *iter, gpointer data)
{
struct tablePart *part = (struct tablePart *) data;
GValue value = G_VALUE_INIT;
const gchar *str;
uiImage *img;
int pval;
switch (part->type) {
case partText:
gtk_tree_model_get_value(mm, iter, part->textColumn, &value);
str = g_value_get_string(&value);
g_object_set(r, "text", str, NULL);
if (part->colorColumn != -1)
applyColor(mm, iter,
part->colorColumn,
r, "foreground-rgba", "foreground-set");
break;
case partImage:
//TODO setImageSize(r);
gtk_tree_model_get_value(mm, iter, part->imageColumn, &value);
img = (uiImage *) g_value_get_pointer(&value);
g_object_set(r, "surface",
uiprivImageAppropriateSurface(img, part->tv->treeWidget),
NULL);
break;
case partButton:
gtk_tree_model_get_value(mm, iter, part->textColumn, &value);
str = g_value_get_string(&value);
g_object_set(r, "text", str, NULL);
break;
case partCheckbox:
gtk_tree_model_get_value(mm, iter, part->valueColumn, &value);
g_object_set(r, "active", g_value_get_int(&value) != 0, NULL);
break;
case partProgressBar:
gtk_tree_model_get_value(mm, iter, part->valueColumn, &value);
pval = g_value_get_int(&value);
if (pval == -1) {
// TODO
} else
g_object_set(r,
"pulse", -1,
"value", pval,
NULL);
break;
}
g_value_unset(&value);
if (part->tv->backgroundColumn != -1)
applyColor(mm, iter,
part->tv->backgroundColumn,
r, "cell-background-rgba", "cell-background-set");
}
static void onEdited(struct tablePart *part, int column, const char *pathstr, const void *data)
{
GtkTreePath *path;
int row;
uiTableModel *m;
path = gtk_tree_path_new_from_string(pathstr);
row = gtk_tree_path_get_indices(path)[0];
gtk_tree_path_free(path);
m = part->tv->model;
(*(m->mh->SetCellValue))(m->mh, m, row, column, data);
// and update
uiTableModelRowChanged(m, row);
}
static void appendPart(uiTableColumn *c, struct tablePart *part, GtkCellRenderer *r, int expand)
{
part->r = r;
gtk_tree_view_column_pack_start(c->c, part->r, expand != 0);
gtk_tree_view_column_set_cell_data_func(c->c, part->r, dataFunc, part, NULL);
g_ptr_array_add(c->parts, part);
}
static void textEdited(GtkCellRendererText *renderer, gchar *path, gchar *newText, gpointer data)
{
struct tablePart *part = (struct tablePart *) data;
onEdited(part, part->textColumn, path, newText);
}
void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand)
{
struct tablePart *part;
GtkCellRenderer *r;
part = uiprivNew(struct tablePart);
part->type = partText;
part->textColumn = modelColumn;
part->tv = c->tv;
part->colorColumn = -1;
r = gtk_cell_renderer_text_new();
g_object_set(r, "editable", FALSE, NULL);
g_signal_connect(r, "edited", G_CALLBACK(textEdited), part);
appendPart(c, part, r, expand);
}
void uiTableColumnAppendImagePart(uiTableColumn *c, int modelColumn, int expand)
{
struct tablePart *part;
part = uiprivNew(struct tablePart);
part->type = partImage;
part->imageColumn = modelColumn;
part->tv = c->tv;
appendPart(c, part,
gtk_cell_renderer_pixbuf_new(),
expand);
}
// TODO wrong type here
static void buttonClicked(GtkCellRenderer *r, gchar *pathstr, gpointer data)
{
struct tablePart *part = (struct tablePart *) data;
onEdited(part, part->textColumn, pathstr, NULL);
}
void uiTableColumnAppendButtonPart(uiTableColumn *c, int modelColumn, int expand)
{
struct tablePart *part;
GtkCellRenderer *r;
part = uiprivNew(struct tablePart);
part->type = partButton;
part->textColumn = modelColumn;
part->tv = c->tv;
r = uiprivNewCellRendererButton();
g_object_set(r, "sensitive", TRUE, NULL); // editable by default
g_signal_connect(r, "clicked", G_CALLBACK(buttonClicked), part);
appendPart(c, part, r, expand);
}
// yes, we need to do all this twice :|
static void checkboxToggled(GtkCellRendererToggle *r, gchar *pathstr, gpointer data)
{
struct tablePart *part = (struct tablePart *) data;
GtkTreePath *path;
int row;
uiTableModel *m;
void *value;
int intval;
path = gtk_tree_path_new_from_string(pathstr);
row = gtk_tree_path_get_indices(path)[0];
gtk_tree_path_free(path);
m = part->tv->model;
value = (*(m->mh->CellValue))(m->mh, m, row, part->valueColumn);
intval = !uiTableModelTakeInt(value);
onEdited(part, part->valueColumn, pathstr, uiTableModelGiveInt(intval));
}
void uiTableColumnAppendCheckboxPart(uiTableColumn *c, int modelColumn, int expand)
{
struct tablePart *part;
GtkCellRenderer *r;
part = uiprivNew(struct tablePart);
part->type = partCheckbox;
part->valueColumn = modelColumn;
part->tv = c->tv;
r = gtk_cell_renderer_toggle_new();
g_object_set(r, "sensitive", TRUE, NULL); // editable by default
g_signal_connect(r, "toggled", G_CALLBACK(checkboxToggled), part);
appendPart(c, part, r, expand);
}
void uiTableColumnAppendProgressBarPart(uiTableColumn *c, int modelColumn, int expand)
{
struct tablePart *part;
part = uiprivNew(struct tablePart);
part->type = partProgressBar;
part->valueColumn = modelColumn;
part->tv = c->tv;
appendPart(c, part,
gtk_cell_renderer_progress_new(),
expand);
}
void uiTableColumnPartSetEditable(uiTableColumn *c, int part, int editable)
{
struct tablePart *p;
p = (struct tablePart *) g_ptr_array_index(c->parts, part);
switch (p->type) {
case partImage:
case partProgressBar:
return;
case partButton:
case partCheckbox:
g_object_set(p->r, "sensitive", editable != 0, NULL);
return;
}
g_object_set(p->r, "editable", editable != 0, NULL);
}
void uiTableColumnPartSetTextColor(uiTableColumn *c, int part, int modelColumn)
{
struct tablePart *p;
p = (struct tablePart *) g_ptr_array_index(c->parts, part);
p->colorColumn = modelColumn;
// TODO refresh table
}
uiUnixControlAllDefaultsExceptDestroy(uiTable)
static void uiTableDestroy(uiControl *c)
{
uiTable *t = uiTable(c);
// TODO
g_object_unref(t->widget);
uiFreeControl(uiControl(t));
}
uiTableColumn *uiTableAppendColumn(uiTable *t, const char *name)
{
uiTableColumn *c;
c = uiprivNew(uiTableColumn);
c->c = gtk_tree_view_column_new();
gtk_tree_view_column_set_resizable(c->c, TRUE);
gtk_tree_view_column_set_title(c->c, name);
gtk_tree_view_append_column(t->tv, c->c);
c->tv = t; // TODO rename field to t, cascade
c->parts = g_ptr_array_new();
return c;
}
void uiTableSetRowBackgroundColorModelColumn(uiTable *t, int modelColumn)
{
t->backgroundColumn = modelColumn;
// TODO refresh table
}
uiTable *uiNewTable(uiTableModel *model)
{
uiTable *t;
uiUnixNewControl(uiTable, t);
t->model = model;
t->backgroundColumn = -1;
t->widget = gtk_scrolled_window_new(NULL, NULL);
t->scontainer = GTK_CONTAINER(t->widget);
t->sw = GTK_SCROLLED_WINDOW(t->widget);
gtk_scrolled_window_set_shadow_type(t->sw, GTK_SHADOW_IN);
t->treeWidget = gtk_tree_view_new_with_model(GTK_TREE_MODEL(t->model));
t->tv = GTK_TREE_VIEW(t->treeWidget);
// TODO set up t->tv
gtk_container_add(t->scontainer, t->treeWidget);
// and make the tree view visible; only the scrolled window's visibility is controlled by libui
gtk_widget_show(t->treeWidget);
return t;
}
| 24.85258 | 135 | 0.731982 | [
"model"
] |
377814587a62984b6d69d19f3a7888fda3e8f178 | 50,213 | h | C | JUCEAmalgam/include/juce_audio_formats_amalgam.h | vinniefalco/DSPFiltersDemo | 75d90440de43731e4f915926cb62ac504a60daf5 | [
"MIT"
] | 35 | 2015-05-07T02:08:57.000Z | 2021-10-12T05:47:27.000Z | JUCEAmalgam/include/juce_audio_formats_amalgam.h | EQ4/DSPFiltersDemo | 75d90440de43731e4f915926cb62ac504a60daf5 | [
"MIT"
] | 2 | 2016-05-01T20:45:59.000Z | 2017-06-03T12:21:31.000Z | JUCEAmalgam/include/juce_audio_formats_amalgam.h | EQ4/DSPFiltersDemo | 75d90440de43731e4f915926cb62ac504a60daf5 | [
"MIT"
] | 19 | 2015-02-08T02:40:35.000Z | 2021-06-29T10:55:29.000Z | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE 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.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
// must come before juce_audio_devices.h because of JUCE_CD_READER
/*** Start of inlined file: juce_audio_formats.h ***/
#ifndef __JUCE_AUDIO_FORMATS_JUCEHEADER__
#define __JUCE_AUDIO_FORMATS_JUCEHEADER__
#include "juce_audio_basics_amalgam.h"
/** Config: JUCE_USE_FLAC
Enables the FLAC audio codec classes (available on all platforms).
If your app doesn't need to read FLAC files, you might want to disable this to
reduce the size of your codebase and build time.
*/
#ifndef JUCE_USE_FLAC
#define JUCE_USE_FLAC 1
#endif
/** Config: JUCE_USE_OGGVORBIS
Enables the Ogg-Vorbis audio codec classes (available on all platforms).
If your app doesn't need to read Ogg-Vorbis files, you might want to disable this to
reduce the size of your codebase and build time.
*/
#ifndef JUCE_USE_OGGVORBIS
#define JUCE_USE_OGGVORBIS 1
#endif
/** Config: JUCE_USE_MP3AUDIOFORMAT
Enables the software-based MP3AudioFormat class.
IMPORTANT DISCLAIMER: By choosing to enable the JUCE_USE_MP3AUDIOFORMAT flag and to compile
this MP3 code into your software, you do so AT YOUR OWN RISK! By doing so, you are agreeing
that Raw Material Software is in no way responsible for any patent, copyright, or other
legal issues that you may suffer as a result.
The code in juce_MP3AudioFormat.cpp is NOT guaranteed to be free from infringements of 3rd-party
intellectual property. If you wish to use it, please seek your own independent advice about the
legality of doing so. If you are not willing to accept full responsibility for the consequences
of using this code, then do not enable this setting.
*/
#ifndef JUCE_USE_MP3AUDIOFORMAT
#define JUCE_USE_MP3AUDIOFORMAT 0
#endif
/** Config: JUCE_USE_WINDOWS_MEDIA_FORMAT
Enables the Windows Media SDK codecs.
*/
#ifndef JUCE_USE_WINDOWS_MEDIA_FORMAT
#define JUCE_USE_WINDOWS_MEDIA_FORMAT 1
#endif
#if ! JUCE_MSVC
#undef JUCE_USE_WINDOWS_MEDIA_FORMAT
#define JUCE_USE_WINDOWS_MEDIA_FORMAT 0
#endif
namespace juce
{
// START_AUTOINCLUDE format, codecs, sampler
#ifndef __JUCE_AUDIOFORMAT_JUCEHEADER__
/*** Start of inlined file: juce_AudioFormat.h ***/
#ifndef __JUCE_AUDIOFORMAT_JUCEHEADER__
#define __JUCE_AUDIOFORMAT_JUCEHEADER__
/*** Start of inlined file: juce_AudioFormatReader.h ***/
#ifndef __JUCE_AUDIOFORMATREADER_JUCEHEADER__
#define __JUCE_AUDIOFORMATREADER_JUCEHEADER__
class AudioFormat;
/**
Reads samples from an audio file stream.
A subclass that reads a specific type of audio format will be created by
an AudioFormat object.
@see AudioFormat, AudioFormatWriter
*/
class JUCE_API AudioFormatReader
{
protected:
/** Creates an AudioFormatReader object.
@param sourceStream the stream to read from - this will be deleted
by this object when it is no longer needed. (Some
specialised readers might not use this parameter and
can leave it as 0).
@param formatName the description that will be returned by the getFormatName()
method
*/
AudioFormatReader (InputStream* sourceStream,
const String& formatName);
public:
/** Destructor. */
virtual ~AudioFormatReader();
/** Returns a description of what type of format this is.
E.g. "AIFF"
*/
const String& getFormatName() const noexcept { return formatName; }
/** Reads samples from the stream.
@param destSamples an array of buffers into which the sample data for each
channel will be written.
If the format is fixed-point, each channel will be written
as an array of 32-bit signed integers using the full
range -0x80000000 to 0x7fffffff, regardless of the source's
bit-depth. If it is a floating-point format, you should cast
the resulting array to a (float**) to get the values (in the
range -1.0 to 1.0 or beyond)
If the format is stereo, then destSamples[0] is the left channel
data, and destSamples[1] is the right channel.
The numDestChannels parameter indicates how many pointers this array
contains, but some of these pointers can be null if you don't want to
read data for some of the channels
@param numDestChannels the number of array elements in the destChannels array
@param startSampleInSource the position in the audio file or stream at which the samples
should be read, as a number of samples from the start of the
stream. It's ok for this to be beyond the start or end of the
available data - any samples that are out-of-range will be returned
as zeros.
@param numSamplesToRead the number of samples to read. If this is greater than the number
of samples that the file or stream contains. the result will be padded
with zeros
@param fillLeftoverChannelsWithCopies if true, this indicates that if there's no source data available
for some of the channels that you pass in, then they should be filled with
copies of valid source channels.
E.g. if you're reading a mono file and you pass 2 channels to this method, then
if fillLeftoverChannelsWithCopies is true, both destination channels will be filled
with the same data from the file's single channel. If fillLeftoverChannelsWithCopies
was false, then only the first channel would be filled with the file's contents, and
the second would be cleared. If there are many channels, e.g. you try to read 4 channels
from a stereo file, then the last 3 would all end up with copies of the same data.
@returns true if the operation succeeded, false if there was an error. Note
that reading sections of data beyond the extent of the stream isn't an
error - the reader should just return zeros for these regions
@see readMaxLevels
*/
bool read (int* const* destSamples,
int numDestChannels,
int64 startSampleInSource,
int numSamplesToRead,
bool fillLeftoverChannelsWithCopies);
/** Fills a section of an AudioSampleBuffer from this reader.
This will convert the reader's fixed- or floating-point data to
the buffer's floating-point format, and will try to intelligently
cope with mismatches between the number of channels in the reader
and the buffer.
*/
void read (AudioSampleBuffer* buffer,
int startSampleInDestBuffer,
int numSamples,
int64 readerStartSample,
bool useReaderLeftChan,
bool useReaderRightChan);
/** Finds the highest and lowest sample levels from a section of the audio stream.
This will read a block of samples from the stream, and measure the
highest and lowest sample levels from the channels in that section, returning
these as normalised floating-point levels.
@param startSample the offset into the audio stream to start reading from. It's
ok for this to be beyond the start or end of the stream.
@param numSamples how many samples to read
@param lowestLeft on return, this is the lowest absolute sample from the left channel
@param highestLeft on return, this is the highest absolute sample from the left channel
@param lowestRight on return, this is the lowest absolute sample from the right
channel (if there is one)
@param highestRight on return, this is the highest absolute sample from the right
channel (if there is one)
@see read
*/
virtual void readMaxLevels (int64 startSample,
int64 numSamples,
float& lowestLeft,
float& highestLeft,
float& lowestRight,
float& highestRight);
/** Scans the source looking for a sample whose magnitude is in a specified range.
This will read from the source, either forwards or backwards between two sample
positions, until it finds a sample whose magnitude lies between two specified levels.
If it finds a suitable sample, it returns its position; if not, it will return -1.
There's also a minimumConsecutiveSamples setting to help avoid spikes or zero-crossing
points when you're searching for a continuous range of samples
@param startSample the first sample to look at
@param numSamplesToSearch the number of samples to scan. If this value is negative,
the search will go backwards
@param magnitudeRangeMinimum the lowest magnitude (inclusive) that is considered a hit, from 0 to 1.0
@param magnitudeRangeMaximum the highest magnitude (inclusive) that is considered a hit, from 0 to 1.0
@param minimumConsecutiveSamples if this is > 0, the method will only look for a sequence
of this many consecutive samples, all of which lie
within the target range. When it finds such a sequence,
it returns the position of the first in-range sample
it found (i.e. the earliest one if scanning forwards, the
latest one if scanning backwards)
*/
int64 searchForLevel (int64 startSample,
int64 numSamplesToSearch,
double magnitudeRangeMinimum,
double magnitudeRangeMaximum,
int minimumConsecutiveSamples);
/** The sample-rate of the stream. */
double sampleRate;
/** The number of bits per sample, e.g. 16, 24, 32. */
unsigned int bitsPerSample;
/** The total number of samples in the audio stream. */
int64 lengthInSamples;
/** The total number of channels in the audio stream. */
unsigned int numChannels;
/** Indicates whether the data is floating-point or fixed. */
bool usesFloatingPointData;
/** A set of metadata values that the reader has pulled out of the stream.
Exactly what these values are depends on the format, so you can
check out the format implementation code to see what kind of stuff
they understand.
*/
StringPairArray metadataValues;
/** The input stream, for use by subclasses. */
InputStream* input;
/** Subclasses must implement this method to perform the low-level read operation.
Callers should use read() instead of calling this directly.
@param destSamples the array of destination buffers to fill. Some of these
pointers may be null
@param numDestChannels the number of items in the destSamples array. This
value is guaranteed not to be greater than the number of
channels that this reader object contains
@param startOffsetInDestBuffer the number of samples from the start of the
dest data at which to begin writing
@param startSampleInFile the number of samples into the source data at which
to begin reading. This value is guaranteed to be >= 0.
@param numSamples the number of samples to read
*/
virtual bool readSamples (int** destSamples,
int numDestChannels,
int startOffsetInDestBuffer,
int64 startSampleInFile,
int numSamples) = 0;
protected:
/** Used by AudioFormatReader subclasses to copy data to different formats. */
template <class DestSampleType, class SourceSampleType, class SourceEndianness>
struct ReadHelper
{
typedef AudioData::Pointer <DestSampleType, AudioData::NativeEndian, AudioData::NonInterleaved, AudioData::NonConst> DestType;
typedef AudioData::Pointer <SourceSampleType, SourceEndianness, AudioData::Interleaved, AudioData::Const> SourceType;
static void read (int** destData, int destOffset, int numDestChannels, const void* sourceData, int numSourceChannels, int numSamples) noexcept
{
for (int i = 0; i < numDestChannels; ++i)
{
if (destData[i] != nullptr)
{
DestType dest (destData[i]);
dest += destOffset;
if (i < numSourceChannels)
dest.convertSamples (SourceType (addBytesToPointer (sourceData, i * SourceType::getBytesPerSample()), numSourceChannels), numSamples);
else
dest.clearSamples (numSamples);
}
}
}
};
private:
String formatName;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatReader);
};
#endif // __JUCE_AUDIOFORMATREADER_JUCEHEADER__
/*** End of inlined file: juce_AudioFormatReader.h ***/
/*** Start of inlined file: juce_AudioFormatWriter.h ***/
#ifndef __JUCE_AUDIOFORMATWRITER_JUCEHEADER__
#define __JUCE_AUDIOFORMATWRITER_JUCEHEADER__
/**
Writes samples to an audio file stream.
A subclass that writes a specific type of audio format will be created by
an AudioFormat object.
After creating one of these with the AudioFormat::createWriterFor() method
you can call its write() method to store the samples, and then delete it.
@see AudioFormat, AudioFormatReader
*/
class JUCE_API AudioFormatWriter
{
protected:
/** Creates an AudioFormatWriter object.
@param destStream the stream to write to - this will be deleted
by this object when it is no longer needed
@param formatName the description that will be returned by the getFormatName()
method
@param sampleRate the sample rate to use - the base class just stores
this value, it doesn't do anything with it
@param numberOfChannels the number of channels to write - the base class just stores
this value, it doesn't do anything with it
@param bitsPerSample the bit depth of the stream - the base class just stores
this value, it doesn't do anything with it
*/
AudioFormatWriter (OutputStream* destStream,
const String& formatName,
double sampleRate,
unsigned int numberOfChannels,
unsigned int bitsPerSample);
public:
/** Destructor. */
virtual ~AudioFormatWriter();
/** Returns a description of what type of format this is.
E.g. "AIFF file"
*/
const String& getFormatName() const noexcept { return formatName; }
/** Writes a set of samples to the audio stream.
Note that if you're trying to write the contents of an AudioSampleBuffer, you
can use AudioSampleBuffer::writeToAudioWriter().
@param samplesToWrite an array of arrays containing the sample data for
each channel to write. This is a zero-terminated
array of arrays, and can contain a different number
of channels than the actual stream uses, and the
writer should do its best to cope with this.
If the format is fixed-point, each channel will be formatted
as an array of signed integers using the full 32-bit
range -0x80000000 to 0x7fffffff, regardless of the source's
bit-depth. If it is a floating-point format, you should treat
the arrays as arrays of floats, and just cast it to an (int**)
to pass it into the method.
@param numSamples the number of samples to write
*/
virtual bool write (const int** samplesToWrite,
int numSamples) = 0;
/** Reads a section of samples from an AudioFormatReader, and writes these to
the output.
This will take care of any floating-point conversion that's required to convert
between the two formats. It won't deal with sample-rate conversion, though.
If numSamplesToRead < 0, it will write the entire length of the reader.
@returns false if it can't read or write properly during the operation
*/
bool writeFromAudioReader (AudioFormatReader& reader,
int64 startSample,
int64 numSamplesToRead);
/** Reads some samples from an AudioSource, and writes these to the output.
The source must already have been initialised with the AudioSource::prepareToPlay() method
@param source the source to read from
@param numSamplesToRead total number of samples to read and write
@param samplesPerBlock the maximum number of samples to fetch from the source
@returns false if it can't read or write properly during the operation
*/
bool writeFromAudioSource (AudioSource& source,
int numSamplesToRead,
int samplesPerBlock = 2048);
/** Writes some samples from an AudioSampleBuffer. */
bool writeFromAudioSampleBuffer (const AudioSampleBuffer& source,
int startSample, int numSamples);
/** Returns the sample rate being used. */
double getSampleRate() const noexcept { return sampleRate; }
/** Returns the number of channels being written. */
int getNumChannels() const noexcept { return (int) numChannels; }
/** Returns the bit-depth of the data being written. */
int getBitsPerSample() const noexcept { return (int) bitsPerSample; }
/** Returns true if it's a floating-point format, false if it's fixed-point. */
bool isFloatingPoint() const noexcept { return usesFloatingPointData; }
/**
Provides a FIFO for an AudioFormatWriter, allowing you to push incoming
data into a buffer which will be flushed to disk by a background thread.
*/
class ThreadedWriter
{
public:
/** Creates a ThreadedWriter for a given writer and a thread.
The writer object which is passed in here will be owned and deleted by
the ThreadedWriter when it is no longer needed.
To stop the writer and flush the buffer to disk, simply delete this object.
*/
ThreadedWriter (AudioFormatWriter* writer,
TimeSliceThread& backgroundThread,
int numSamplesToBuffer);
/** Destructor. */
~ThreadedWriter();
/** Pushes some incoming audio data into the FIFO.
If there's enough free space in the buffer, this will add the data to it,
If the FIFO is too full to accept this many samples, the method will return
false - then you could either wait until the background thread has had time to
consume some of the buffered data and try again, or you can give up
and lost this block.
The data must be an array containing the same number of channels as the
AudioFormatWriter object is using. None of these channels can be null.
*/
bool write (const float** data, int numSamples);
class JUCE_API IncomingDataReceiver
{
public:
IncomingDataReceiver() {}
virtual ~IncomingDataReceiver() {}
virtual void reset (int numChannels, double sampleRate, int64 totalSamplesInSource) = 0;
virtual void addBlock (int64 sampleNumberInSource, const AudioSampleBuffer& newData,
int startOffsetInBuffer, int numSamples) = 0;
};
/** Allows you to specify a callback that this writer should update with the
incoming data.
The receiver will be cleared and will the writer will begin adding data to
it as the data arrives. Pass a null pointer to remove the current receiver.
The object passed-in must not be deleted while this writer is still using it.
*/
void setDataReceiver (IncomingDataReceiver* receiver);
private:
class Buffer;
friend class ScopedPointer<Buffer>;
ScopedPointer<Buffer> buffer;
};
protected:
/** The sample rate of the stream. */
double sampleRate;
/** The number of channels being written to the stream. */
unsigned int numChannels;
/** The bit depth of the file. */
unsigned int bitsPerSample;
/** True if it's a floating-point format, false if it's fixed-point. */
bool usesFloatingPointData;
/** The output stream for Use by subclasses. */
OutputStream* output;
/** Used by AudioFormatWriter subclasses to copy data to different formats. */
template <class DestSampleType, class SourceSampleType, class DestEndianness>
struct WriteHelper
{
typedef AudioData::Pointer <DestSampleType, DestEndianness, AudioData::Interleaved, AudioData::NonConst> DestType;
typedef AudioData::Pointer <SourceSampleType, AudioData::NativeEndian, AudioData::NonInterleaved, AudioData::Const> SourceType;
static void write (void* destData, int numDestChannels, const int** source,
int numSamples, const int sourceOffset = 0) noexcept
{
for (int i = 0; i < numDestChannels; ++i)
{
const DestType dest (addBytesToPointer (destData, i * DestType::getBytesPerSample()), numDestChannels);
if (*source != nullptr)
{
dest.convertSamples (SourceType (*source + sourceOffset), numSamples);
++source;
}
else
{
dest.clearSamples (numSamples);
}
}
}
};
private:
String formatName;
friend class ThreadedWriter;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatWriter);
};
#endif // __JUCE_AUDIOFORMATWRITER_JUCEHEADER__
/*** End of inlined file: juce_AudioFormatWriter.h ***/
/**
Subclasses of AudioFormat are used to read and write different audio
file formats.
@see AudioFormatReader, AudioFormatWriter, WavAudioFormat, AiffAudioFormat
*/
class JUCE_API AudioFormat
{
public:
/** Destructor. */
virtual ~AudioFormat();
/** Returns the name of this format.
e.g. "WAV file" or "AIFF file"
*/
const String& getFormatName() const;
/** Returns all the file extensions that might apply to a file of this format.
The first item will be the one that's preferred when creating a new file.
So for a wav file this might just return ".wav"; for an AIFF file it might
return two items, ".aif" and ".aiff"
*/
const StringArray& getFileExtensions() const;
/** Returns true if this the given file can be read by this format.
Subclasses shouldn't do too much work here, just check the extension or
file type. The base class implementation just checks the file's extension
against one of the ones that was registered in the constructor.
*/
virtual bool canHandleFile (const File& fileToTest);
/** Returns a set of sample rates that the format can read and write. */
virtual Array<int> getPossibleSampleRates() = 0;
/** Returns a set of bit depths that the format can read and write. */
virtual Array<int> getPossibleBitDepths() = 0;
/** Returns true if the format can do 2-channel audio. */
virtual bool canDoStereo() = 0;
/** Returns true if the format can do 1-channel audio. */
virtual bool canDoMono() = 0;
/** Returns true if the format uses compressed data. */
virtual bool isCompressed();
/** Returns a list of different qualities that can be used when writing.
Non-compressed formats will just return an empty array, but for something
like Ogg-Vorbis or MP3, it might return a list of bit-rates, etc.
When calling createWriterFor(), an index from this array is passed in to
tell the format which option is required.
*/
virtual StringArray getQualityOptions();
/** Tries to create an object that can read from a stream containing audio
data in this format.
The reader object that is returned can be used to read from the stream, and
should then be deleted by the caller.
@param sourceStream the stream to read from - the AudioFormatReader object
that is returned will delete this stream when it no longer
needs it.
@param deleteStreamIfOpeningFails if no reader can be created, this determines whether this method
should delete the stream object that was passed-in. (If a valid
reader is returned, it will always be in charge of deleting the
stream, so this parameter is ignored)
@see AudioFormatReader
*/
virtual AudioFormatReader* createReaderFor (InputStream* sourceStream,
bool deleteStreamIfOpeningFails) = 0;
/** Tries to create an object that can write to a stream with this audio format.
The writer object that is returned can be used to write to the stream, and
should then be deleted by the caller.
If the stream can't be created for some reason (e.g. the parameters passed in
here aren't suitable), this will return 0.
@param streamToWriteTo the stream that the data will go to - this will be
deleted by the AudioFormatWriter object when it's no longer
needed. If no AudioFormatWriter can be created by this method,
the stream will NOT be deleted, so that the caller can re-use it
to try to open a different format, etc
@param sampleRateToUse the sample rate for the file, which must be one of the ones
returned by getPossibleSampleRates()
@param numberOfChannels the number of channels - this must be either 1 or 2, and
the choice will depend on the results of canDoMono() and
canDoStereo()
@param bitsPerSample the bits per sample to use - this must be one of the values
returned by getPossibleBitDepths()
@param metadataValues a set of metadata values that the writer should try to write
to the stream. Exactly what these are depends on the format,
and the subclass doesn't actually have to do anything with
them if it doesn't want to. Have a look at the specific format
implementation classes to see possible values that can be
used
@param qualityOptionIndex the index of one of compression qualities returned by the
getQualityOptions() method. If there aren't any quality options
for this format, just pass 0 in this parameter, as it'll be
ignored
@see AudioFormatWriter
*/
virtual AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
unsigned int numberOfChannels,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex) = 0;
protected:
/** Creates an AudioFormat object.
@param formatName this sets the value that will be returned by getFormatName()
@param fileExtensions a zero-terminated list of file extensions - this is what will
be returned by getFileExtension()
*/
AudioFormat (const String& formatName,
const StringArray& fileExtensions);
private:
String formatName;
StringArray fileExtensions;
};
#endif // __JUCE_AUDIOFORMAT_JUCEHEADER__
/*** End of inlined file: juce_AudioFormat.h ***/
#endif
#ifndef __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__
/*** Start of inlined file: juce_AudioFormatManager.h ***/
#ifndef __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__
#define __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__
/**
A class for keeping a list of available audio formats, and for deciding which
one to use to open a given file.
After creating an AudioFormatManager object, you should call registerFormat()
or registerBasicFormats() to give it a list of format types that it can use.
@see AudioFormat
*/
class JUCE_API AudioFormatManager
{
public:
/** Creates an empty format manager.
Before it'll be any use, you'll need to call registerFormat() with all the
formats you want it to be able to recognise.
*/
AudioFormatManager();
/** Destructor. */
~AudioFormatManager();
/** Adds a format to the manager's list of available file types.
The object passed-in will be deleted by this object, so don't keep a pointer
to it!
If makeThisTheDefaultFormat is true, then the getDefaultFormat() method will
return this one when called.
*/
void registerFormat (AudioFormat* newFormat,
bool makeThisTheDefaultFormat);
/** Handy method to make it easy to register the formats that come with Juce.
Currently, this will add WAV and AIFF to the list.
*/
void registerBasicFormats();
/** Clears the list of known formats. */
void clearFormats();
/** Returns the number of currently registered file formats. */
int getNumKnownFormats() const;
/** Returns one of the registered file formats. */
AudioFormat* getKnownFormat (int index) const;
/** Looks for which of the known formats is listed as being for a given file
extension.
The extension may have a dot before it, so e.g. ".wav" or "wav" are both ok.
*/
AudioFormat* findFormatForFileExtension (const String& fileExtension) const;
/** Returns the format which has been set as the default one.
You can set a format as being the default when it is registered. It's useful
when you want to write to a file, because the best format may change between
platforms, e.g. AIFF is preferred on the Mac, WAV on Windows.
If none has been set as the default, this method will just return the first
one in the list.
*/
AudioFormat* getDefaultFormat() const;
/** Returns a set of wildcards for file-matching that contains the extensions for
all known formats.
E.g. if might return "*.wav;*.aiff" if it just knows about wavs and aiffs.
*/
String getWildcardForAllFormats() const;
/** Searches through the known formats to try to create a suitable reader for
this file.
If none of the registered formats can open the file, it'll return 0. If it
returns a reader, it's the caller's responsibility to delete the reader.
*/
AudioFormatReader* createReaderFor (const File& audioFile);
/** Searches through the known formats to try to create a suitable reader for
this stream.
The stream object that is passed-in will be deleted by this method or by the
reader that is returned, so the caller should not keep any references to it.
The stream that is passed-in must be capable of being repositioned so
that all the formats can have a go at opening it.
If none of the registered formats can open the stream, it'll return 0. If it
returns a reader, it's the caller's responsibility to delete the reader.
*/
AudioFormatReader* createReaderFor (InputStream* audioFileStream);
private:
OwnedArray<AudioFormat> knownFormats;
int defaultFormatIndex;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatManager);
};
#endif // __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__
/*** End of inlined file: juce_AudioFormatManager.h ***/
#endif
#ifndef __JUCE_AUDIOFORMATREADER_JUCEHEADER__
#endif
#ifndef __JUCE_AUDIOFORMATREADERSOURCE_JUCEHEADER__
/*** Start of inlined file: juce_AudioFormatReaderSource.h ***/
#ifndef __JUCE_AUDIOFORMATREADERSOURCE_JUCEHEADER__
#define __JUCE_AUDIOFORMATREADERSOURCE_JUCEHEADER__
/**
A type of AudioSource that will read from an AudioFormatReader.
@see PositionableAudioSource, AudioTransportSource, BufferingAudioSource
*/
class JUCE_API AudioFormatReaderSource : public PositionableAudioSource
{
public:
/** Creates an AudioFormatReaderSource for a given reader.
@param sourceReader the reader to use as the data source - this must
not be null
@param deleteReaderWhenThisIsDeleted if true, the reader passed-in will be deleted
when this object is deleted; if false it will be
left up to the caller to manage its lifetime
*/
AudioFormatReaderSource (AudioFormatReader* sourceReader,
bool deleteReaderWhenThisIsDeleted);
/** Destructor. */
~AudioFormatReaderSource();
/** Toggles loop-mode.
If set to true, it will continuously loop the input source. If false,
it will just emit silence after the source has finished.
@see isLooping
*/
void setLooping (bool shouldLoop);
/** Returns whether loop-mode is turned on or not. */
bool isLooping() const { return looping; }
/** Returns the reader that's being used. */
AudioFormatReader* getAudioFormatReader() const noexcept { return reader; }
/** Implementation of the AudioSource method. */
void prepareToPlay (int samplesPerBlockExpected, double sampleRate);
/** Implementation of the AudioSource method. */
void releaseResources();
/** Implementation of the AudioSource method. */
void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill);
/** Implements the PositionableAudioSource method. */
void setNextReadPosition (int64 newPosition);
/** Implements the PositionableAudioSource method. */
int64 getNextReadPosition() const;
/** Implements the PositionableAudioSource method. */
int64 getTotalLength() const;
private:
OptionalScopedPointer<AudioFormatReader> reader;
int64 volatile nextPlayPos;
bool volatile looping;
void readBufferSection (int start, int length, AudioSampleBuffer& buffer, int startSample);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatReaderSource);
};
#endif // __JUCE_AUDIOFORMATREADERSOURCE_JUCEHEADER__
/*** End of inlined file: juce_AudioFormatReaderSource.h ***/
#endif
#ifndef __JUCE_AUDIOFORMATWRITER_JUCEHEADER__
#endif
#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__
/*** Start of inlined file: juce_AudioSubsectionReader.h ***/
#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__
#define __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__
/**
This class is used to wrap an AudioFormatReader and only read from a
subsection of the file.
So if you have a reader which can read a 1000 sample file, you could wrap it
in one of these to only access, e.g. samples 100 to 200, and any samples
outside that will come back as 0. Accessing sample 0 from this reader will
actually read the first sample from the other's subsection, which might
be at a non-zero position.
@see AudioFormatReader
*/
class JUCE_API AudioSubsectionReader : public AudioFormatReader
{
public:
/** Creates a AudioSubsectionReader for a given data source.
@param sourceReader the source reader from which we'll be taking data
@param subsectionStartSample the sample within the source reader which will be
mapped onto sample 0 for this reader.
@param subsectionLength the number of samples from the source that will
make up the subsection. If this reader is asked for
any samples beyond this region, it will return zero.
@param deleteSourceWhenDeleted if true, the sourceReader object will be deleted when
this object is deleted.
*/
AudioSubsectionReader (AudioFormatReader* sourceReader,
int64 subsectionStartSample,
int64 subsectionLength,
bool deleteSourceWhenDeleted);
/** Destructor. */
~AudioSubsectionReader();
bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
int64 startSampleInFile, int numSamples);
void readMaxLevels (int64 startSample,
int64 numSamples,
float& lowestLeft,
float& highestLeft,
float& lowestRight,
float& highestRight);
private:
AudioFormatReader* const source;
int64 startSample, length;
const bool deleteSourceWhenDeleted;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSubsectionReader);
};
#endif // __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__
/*** End of inlined file: juce_AudioSubsectionReader.h ***/
#endif
/*** Start of inlined file: juce_AiffAudioFormat.h ***/
/**
Reads and Writes AIFF format audio files.
@see AudioFormat
*/
class JUCE_API AiffAudioFormat : public AudioFormat
{
public:
/** Creates an format object. */
AiffAudioFormat();
/** Destructor. */
~AiffAudioFormat();
Array<int> getPossibleSampleRates();
Array<int> getPossibleBitDepths();
bool canDoStereo();
bool canDoMono();
#if JUCE_MAC
bool canHandleFile (const File& fileToTest);
#endif
AudioFormatReader* createReaderFor (InputStream* sourceStream,
bool deleteStreamIfOpeningFails);
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
unsigned int numberOfChannels,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex);
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AiffAudioFormat);
};
/*** End of inlined file: juce_AiffAudioFormat.h ***/
/*** Start of inlined file: juce_CoreAudioFormat.h ***/
#if JUCE_MAC || JUCE_IOS
/**
OSX and iOS only - This uses the AudioToolbox framework to read any audio
format that the system has a codec for.
This should be able to understand formats such as mp3, m4a, etc.
@see AudioFormat
*/
class JUCE_API CoreAudioFormat : public AudioFormat
{
public:
/** Creates a format object. */
CoreAudioFormat();
/** Destructor. */
~CoreAudioFormat();
Array<int> getPossibleSampleRates();
Array<int> getPossibleBitDepths();
bool canDoStereo();
bool canDoMono();
AudioFormatReader* createReaderFor (InputStream* sourceStream,
bool deleteStreamIfOpeningFails);
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
unsigned int numberOfChannels,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex);
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreAudioFormat);
};
#endif
/*** End of inlined file: juce_CoreAudioFormat.h ***/
/*** Start of inlined file: juce_FlacAudioFormat.h ***/
#if JUCE_USE_FLAC || defined (DOXYGEN)
/**
Reads and writes the lossless-compression FLAC audio format.
To compile this, you'll need to set the JUCE_USE_FLAC flag.
@see AudioFormat
*/
class JUCE_API FlacAudioFormat : public AudioFormat
{
public:
FlacAudioFormat();
~FlacAudioFormat();
Array<int> getPossibleSampleRates();
Array<int> getPossibleBitDepths();
bool canDoStereo();
bool canDoMono();
bool isCompressed();
StringArray getQualityOptions();
AudioFormatReader* createReaderFor (InputStream* sourceStream,
bool deleteStreamIfOpeningFails);
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
unsigned int numberOfChannels,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex);
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FlacAudioFormat);
};
#endif
/*** End of inlined file: juce_FlacAudioFormat.h ***/
/*** Start of inlined file: juce_MP3AudioFormat.h ***/
#if JUCE_USE_MP3AUDIOFORMAT
/**
Software-based MP3 decoding format (doesn't currently provide an encoder).
IMPORTANT DISCLAIMER: By choosing to enable the JUCE_USE_MP3AUDIOFORMAT flag and
to compile the MP3 code into your software, you do so AT YOUR OWN RISK! By doing so,
you are agreeing that Raw Material Software is in no way responsible for any patent,
copyright, or other legal issues that you may suffer as a result.
The code in juce_MP3AudioFormat.cpp is NOT guaranteed to be free from infringements of 3rd-party
intellectual property. If you wish to use it, please seek your own independent advice about the
legality of doing so. If you are not willing to accept full responsibility for the consequences
of using this code, then do not enable the JUCE_USE_MP3AUDIOFORMAT setting.
*/
class MP3AudioFormat : public AudioFormat
{
public:
MP3AudioFormat();
~MP3AudioFormat();
Array<int> getPossibleSampleRates();
Array<int> getPossibleBitDepths();
bool canDoStereo();
bool canDoMono();
bool isCompressed();
StringArray getQualityOptions();
AudioFormatReader* createReaderFor (InputStream*, bool deleteStreamIfOpeningFails);
AudioFormatWriter* createWriterFor (OutputStream*, double sampleRateToUse,
unsigned int numberOfChannels, int bitsPerSample,
const StringPairArray& metadataValues, int qualityOptionIndex);
};
#endif
/*** End of inlined file: juce_MP3AudioFormat.h ***/
/*** Start of inlined file: juce_OggVorbisAudioFormat.h ***/
#if JUCE_USE_OGGVORBIS || defined (DOXYGEN)
/**
Reads and writes the Ogg-Vorbis audio format.
To compile this, you'll need to set the JUCE_USE_OGGVORBIS flag.
@see AudioFormat,
*/
class JUCE_API OggVorbisAudioFormat : public AudioFormat
{
public:
OggVorbisAudioFormat();
~OggVorbisAudioFormat();
Array<int> getPossibleSampleRates();
Array<int> getPossibleBitDepths();
bool canDoStereo();
bool canDoMono();
bool isCompressed();
StringArray getQualityOptions();
/** Tries to estimate the quality level of an ogg file based on its size.
If it can't read the file for some reason, this will just return 1 (medium quality),
otherwise it will return the approximate quality setting that would have been used
to create the file.
@see getQualityOptions
*/
int estimateOggFileQuality (const File& source);
/** Metadata property name used by the Ogg writer - if you set a string for this
value, it will be written into the ogg file as the name of the encoder app.
@see createWriterFor
*/
static const char* const encoderName;
AudioFormatReader* createReaderFor (InputStream* sourceStream,
bool deleteStreamIfOpeningFails);
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
unsigned int numberOfChannels,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex);
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OggVorbisAudioFormat);
};
#endif
/*** End of inlined file: juce_OggVorbisAudioFormat.h ***/
/*** Start of inlined file: juce_QuickTimeAudioFormat.h ***/
#if JUCE_QUICKTIME
/**
Uses QuickTime to read the audio track a movie or media file.
As well as QuickTime movies, this should also manage to open other audio
files that quicktime can understand, like mp3, m4a, etc.
@see AudioFormat
*/
class JUCE_API QuickTimeAudioFormat : public AudioFormat
{
public:
/** Creates a format object. */
QuickTimeAudioFormat();
/** Destructor. */
~QuickTimeAudioFormat();
Array<int> getPossibleSampleRates();
Array<int> getPossibleBitDepths();
bool canDoStereo();
bool canDoMono();
AudioFormatReader* createReaderFor (InputStream* sourceStream,
bool deleteStreamIfOpeningFails);
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
unsigned int numberOfChannels,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex);
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (QuickTimeAudioFormat);
};
#endif
/*** End of inlined file: juce_QuickTimeAudioFormat.h ***/
/*** Start of inlined file: juce_WavAudioFormat.h ***/
/**
Reads and Writes WAV format audio files.
@see AudioFormat
*/
class JUCE_API WavAudioFormat : public AudioFormat
{
public:
/** Creates a format object. */
WavAudioFormat();
/** Destructor. */
~WavAudioFormat();
/** Metadata property name used by wav readers and writers for adding
a BWAV chunk to the file.
@see AudioFormatReader::metadataValues, createWriterFor
*/
static const char* const bwavDescription;
/** Metadata property name used by wav readers and writers for adding
a BWAV chunk to the file.
@see AudioFormatReader::metadataValues, createWriterFor
*/
static const char* const bwavOriginator;
/** Metadata property name used by wav readers and writers for adding
a BWAV chunk to the file.
@see AudioFormatReader::metadataValues, createWriterFor
*/
static const char* const bwavOriginatorRef;
/** Metadata property name used by wav readers and writers for adding
a BWAV chunk to the file.
Date format is: yyyy-mm-dd
@see AudioFormatReader::metadataValues, createWriterFor
*/
static const char* const bwavOriginationDate;
/** Metadata property name used by wav readers and writers for adding
a BWAV chunk to the file.
Time format is: hh-mm-ss
@see AudioFormatReader::metadataValues, createWriterFor
*/
static const char* const bwavOriginationTime;
/** Metadata property name used by wav readers and writers for adding
a BWAV chunk to the file.
This is the number of samples from the start of an edit that the
file is supposed to begin at. Seems like an obvious mistake to
only allow a file to occur in an edit once, but that's the way
it is..
@see AudioFormatReader::metadataValues, createWriterFor
*/
static const char* const bwavTimeReference;
/** Metadata property name used by wav readers and writers for adding
a BWAV chunk to the file.
This is a
@see AudioFormatReader::metadataValues, createWriterFor
*/
static const char* const bwavCodingHistory;
/** Utility function to fill out the appropriate metadata for a BWAV file.
This just makes it easier than using the property names directly, and it
fills out the time and date in the right format.
*/
static StringPairArray createBWAVMetadata (const String& description,
const String& originator,
const String& originatorRef,
const Time& dateAndTime,
const int64 timeReferenceSamples,
const String& codingHistory);
Array<int> getPossibleSampleRates();
Array<int> getPossibleBitDepths();
bool canDoStereo();
bool canDoMono();
AudioFormatReader* createReaderFor (InputStream* sourceStream,
bool deleteStreamIfOpeningFails);
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
unsigned int numberOfChannels,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex);
/** Utility function to replace the metadata in a wav file with a new set of values.
If possible, this cheats by overwriting just the metadata region of the file, rather
than by copying the whole file again.
*/
bool replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata);
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WavAudioFormat);
};
/*** End of inlined file: juce_WavAudioFormat.h ***/
/*** Start of inlined file: juce_WindowsMediaAudioFormat.h ***/
#if JUCE_WINDOWS
/**
Audio format which uses the Windows Media codecs (Windows only).
*/
class WindowsMediaAudioFormat : public AudioFormat
{
public:
WindowsMediaAudioFormat();
~WindowsMediaAudioFormat();
Array<int> getPossibleSampleRates();
Array<int> getPossibleBitDepths();
bool canDoStereo();
bool canDoMono();
AudioFormatReader* createReaderFor (InputStream*, bool deleteStreamIfOpeningFails);
AudioFormatWriter* createWriterFor (OutputStream*, double sampleRateToUse,
unsigned int numberOfChannels, int bitsPerSample,
const StringPairArray& metadataValues, int qualityOptionIndex);
};
#endif
/*** End of inlined file: juce_WindowsMediaAudioFormat.h ***/
#ifndef __JUCE_SAMPLER_JUCEHEADER__
/*** Start of inlined file: juce_Sampler.h ***/
#ifndef __JUCE_SAMPLER_JUCEHEADER__
#define __JUCE_SAMPLER_JUCEHEADER__
/**
A subclass of SynthesiserSound that represents a sampled audio clip.
This is a pretty basic sampler, and just attempts to load the whole audio stream
into memory.
To use it, create a Synthesiser, add some SamplerVoice objects to it, then
give it some SampledSound objects to play.
@see SamplerVoice, Synthesiser, SynthesiserSound
*/
class JUCE_API SamplerSound : public SynthesiserSound
{
public:
/** Creates a sampled sound from an audio reader.
This will attempt to load the audio from the source into memory and store
it in this object.
@param name a name for the sample
@param source the audio to load. This object can be safely deleted by the
caller after this constructor returns
@param midiNotes the set of midi keys that this sound should be played on. This
is used by the SynthesiserSound::appliesToNote() method
@param midiNoteForNormalPitch the midi note at which the sample should be played
with its natural rate. All other notes will be pitched
up or down relative to this one
@param attackTimeSecs the attack (fade-in) time, in seconds
@param releaseTimeSecs the decay (fade-out) time, in seconds
@param maxSampleLengthSeconds a maximum length of audio to read from the audio
source, in seconds
*/
SamplerSound (const String& name,
AudioFormatReader& source,
const BigInteger& midiNotes,
int midiNoteForNormalPitch,
double attackTimeSecs,
double releaseTimeSecs,
double maxSampleLengthSeconds);
/** Destructor. */
~SamplerSound();
/** Returns the sample's name */
const String& getName() const { return name; }
/** Returns the audio sample data.
This could be 0 if there was a problem loading it.
*/
AudioSampleBuffer* getAudioData() const { return data; }
bool appliesToNote (const int midiNoteNumber);
bool appliesToChannel (const int midiChannel);
private:
friend class SamplerVoice;
String name;
ScopedPointer <AudioSampleBuffer> data;
double sourceSampleRate;
BigInteger midiNotes;
int length, attackSamples, releaseSamples;
int midiRootNote;
JUCE_LEAK_DETECTOR (SamplerSound);
};
/**
A subclass of SynthesiserVoice that can play a SamplerSound.
To use it, create a Synthesiser, add some SamplerVoice objects to it, then
give it some SampledSound objects to play.
@see SamplerSound, Synthesiser, SynthesiserVoice
*/
class JUCE_API SamplerVoice : public SynthesiserVoice
{
public:
/** Creates a SamplerVoice.
*/
SamplerVoice();
/** Destructor. */
~SamplerVoice();
bool canPlaySound (SynthesiserSound* sound);
void startNote (const int midiNoteNumber,
const float velocity,
SynthesiserSound* sound,
const int currentPitchWheelPosition);
void stopNote (const bool allowTailOff);
void pitchWheelMoved (const int newValue);
void controllerMoved (const int controllerNumber,
const int newValue);
void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples);
private:
double pitchRatio;
double sourceSamplePosition;
float lgain, rgain, attackReleaseLevel, attackDelta, releaseDelta;
bool isInAttack, isInRelease;
JUCE_LEAK_DETECTOR (SamplerVoice);
};
#endif // __JUCE_SAMPLER_JUCEHEADER__
/*** End of inlined file: juce_Sampler.h ***/
#endif
// END_AUTOINCLUDE
}
#endif // __JUCE_AUDIO_FORMATS_JUCEHEADER__
/*** End of inlined file: juce_audio_formats.h ***/
| 33.034868 | 144 | 0.731185 | [
"object"
] |
3778c2f37b673f5e5735d7e81411637f1c43b19c | 2,229 | h | C | Source/DarkLab/Placeable.h | rinial/DarkLab | 82d29368d8b009eec02522706f368c1545fa3514 | [
"MIT"
] | 6 | 2020-09-05T02:25:37.000Z | 2022-02-07T02:05:57.000Z | Source/DarkLab/Placeable.h | Ziririn/DarkLab | 82d29368d8b009eec02522706f368c1545fa3514 | [
"MIT"
] | null | null | null | Source/DarkLab/Placeable.h | Ziririn/DarkLab | 82d29368d8b009eec02522706f368c1545fa3514 | [
"MIT"
] | 1 | 2020-09-05T02:25:56.000Z | 2020-09-05T02:25:56.000Z | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "Placeable.generated.h"
// TODO move somewhere else
// Direction
UENUM(BlueprintType)
enum class EDirectionEnum : uint8
{
VE_Up UMETA(DisplayName = "Up"),
VE_Right UMETA(DisplayName = "Right"),
VE_Down UMETA(DisplayName = "Down"),
VE_Left UMETA(DisplayName = "Left")
};
// TODO move somewhere else
// Represents a rectangular space on the grid
USTRUCT()
struct FRectSpaceStruct
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
int BotLeftX;
UPROPERTY()
int BotLeftY;
UPROPERTY()
int SizeX;
UPROPERTY()
int SizeY;
ENGINE_API bool operator== (const FRectSpaceStruct& other)
{
return BotLeftX == other.BotLeftX && BotLeftY == other.BotLeftY && SizeX == other.SizeX && SizeY == other.SizeY;
}
ENGINE_API friend bool operator== (const FRectSpaceStruct& a, const FRectSpaceStruct& b)
{
return a.BotLeftX == b.BotLeftX && a.BotLeftY == b.BotLeftY && a.SizeX == b.SizeX && a.SizeY == b.SizeY;
}
FRectSpaceStruct()
{
SizeX = 1;
SizeY = 1;
}
FRectSpaceStruct(int botLeftX, int botLeftY, int sizeX, int sizeY) : BotLeftX(botLeftX), BotLeftY(botLeftY)
{
SizeX = sizeX > 0 ? sizeX : 1;
SizeY = sizeY > 0 ? sizeY : 1;
}
};
// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UPlaceable : public UInterface
{
GENERATED_BODY()
};
// Represents objects that can be placed on the map or are parts of the map itself
class DARKLAB_API IPlaceable
{
GENERATED_BODY()
public:
// Returns the size of the object in cells
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Placeable")
FIntVector GetSize();
// Tries to set new size of the object in cells, returns success
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Placeable")
bool SetSize(const FIntVector size);
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Placeable")
bool SetSizeXY(const int x, const int y);
// Places the object on the map, using bottom left corner
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Placeable")
void Place(const FIntVector botLeftLoc, const EDirectionEnum direction);
}; | 25.918605 | 114 | 0.736653 | [
"object"
] |
98bdc1d0fdf0adcbfeae5daef929302b1ba4c3ea | 1,616 | c | C | d/dagger/drow/temple/obj/funeral.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/dagger/drow/temple/obj/funeral.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/dagger/drow/temple/obj/funeral.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | #include <std.h>
inherit OBJECT;
void init() {
::init();
add_action("bury_func","bury");
}
void create() {
::create();
set_id(({"rites","funeral rites"}));
set_short("Funeral rites");
set_long("This is the funeral rites of the gods which will allow a "
"player to bury <target> in the event of lost heartbeats. It "
"will simply inform the creature it is dead and remove it. You "
"will not recieve xp for creatures this is used upon but atleast "
"it remedies the problem. Please remember to inform your local "
"wizards still of creatures who lose heartbeats.");
set_weight(1);
set_value(0);
}
int bury_func(string str) {
object tp;
object ob;
tp = this_player();
if(!str) {
notify_fail("Bury what?\n");
return 0;
}
ob = present(str, environment(tp));
if(!ob) {
notify_fail("No "+str+" here!\n");
return 0;
}
if(!living(ob)) {
notify_fail(ob->query_cap_name()+" is not a living thing!\n");
return 0;
}
if(interactive(ob)) {
notify_fail("This is not a valid target for burial you idiot!\n");
return 0;
}
if((int)ob->query_hp() < -1) {
write(
"%^RED%^You inform "+ob->query_cap_name()+
" that "
+ob->query_subjective()+" should be dead!\n"
"%^BLUE%^"+ob->query_cap_name()+" agrees and vanishes!%^RESET%^"
);
say(
"%^RED%^"+TPQCN+" delivers the last rites to "
+ob->query_cap_name()+"!\n%^BLUE%^"
+ob->query_cap_name()+" vanishes!%^RESET%^"
,TP);
ob->remove();
return 1;
} else {
notify_fail("This creature is fine!\n");
return 0;
}
}
| 26.933333 | 72 | 0.600866 | [
"object"
] |
98bebb5cbc79d4f9787185851aeffc1e193863e9 | 1,259 | c | C | orientation/est_euler_acc.c | gswly/sensor-imu | 26836898d12681c55737bef35c02e155c9cbbad0 | [
"MIT"
] | 1 | 2019-09-18T12:58:41.000Z | 2019-09-18T12:58:41.000Z | orientation/est_euler_acc.c | gswly/sensor-imu | 26836898d12681c55737bef35c02e155c9cbbad0 | [
"MIT"
] | null | null | null | orientation/est_euler_acc.c | gswly/sensor-imu | 26836898d12681c55737bef35c02e155c9cbbad0 | [
"MIT"
] | null | null | null |
#include <math.h>
#include <stdlib.h>
#include "est_euler_acc.h"
typedef struct {
const matrix *align_dcm;
double alpha;
double prev_roll;
double prev_pitch;
} _objt;
error *est_euler_acc_init(est_euler_acct **pobj, const matrix *align_dcm,
double alpha) {
_objt *_obj = malloc(sizeof(_objt));
_obj->align_dcm = align_dcm;
_obj->alpha = alpha;
_obj->prev_roll = 0;
_obj->prev_pitch = 0;
*pobj = _obj;
return NULL;
}
void est_euler_acc_do(est_euler_acct *obj, const double *acc,
estimator_output *eo) {
_objt *_obj = (_objt *)obj;
vector aligned_acc;
matrix_multiply(_obj->align_dcm, (const vector *)acc, &aligned_acc);
double cur_roll = atan2(aligned_acc.y, aligned_acc.z);
double cur_pitch =
-atan2(aligned_acc.x, sqrt(aligned_acc.y * aligned_acc.y +
aligned_acc.z * aligned_acc.z));
_obj->prev_roll =
_obj->alpha * cur_roll + _obj->prev_roll * (1 - _obj->alpha);
_obj->prev_pitch =
_obj->alpha * cur_pitch + _obj->prev_pitch * (1 - _obj->alpha);
eo->roll = _obj->prev_roll * (180.0f / M_PI);
eo->pitch = _obj->prev_pitch * (180.0f / M_PI);
eo->yaw = 0;
}
| 26.229167 | 73 | 0.606831 | [
"vector"
] |
98c120d6100c06b8fe3baa918d73e4ffbe61297e | 3,204 | h | C | sources/System/Null/NullSound.h | LukasBanana/AcousticsLib | 176bb2613409f65c93046f6e5333d0607ffe0fd2 | [
"BSD-3-Clause"
] | 9 | 2017-12-20T08:00:55.000Z | 2022-03-09T01:33:00.000Z | sources/System/Null/NullSound.h | LukasBanana/AcousticsLib | 176bb2613409f65c93046f6e5333d0607ffe0fd2 | [
"BSD-3-Clause"
] | null | null | null | sources/System/Null/NullSound.h | LukasBanana/AcousticsLib | 176bb2613409f65c93046f6e5333d0607ffe0fd2 | [
"BSD-3-Clause"
] | 5 | 2017-02-05T08:31:24.000Z | 2021-03-10T22:19:32.000Z | /*
* NullSound.h
*
* This file is part of the "AcousticsLib" project (Copyright (c) 2016 by Lukas Hermanns)
* See "LICENSE.txt" for license information.
*/
#ifndef AC_NULL_SOUND_H
#define AC_NULL_SOUND_H
#include <Ac/Sound.h>
#include <mutex>
#include <memory>
namespace Ac
{
class NullAudioSystem;
class NullSound : public Sound
{
public:
NullSound(NullAudioSystem* audioSystem);
~NullSound();
/* ----- Playback ----- */
void Play() override;
void Pause() override;
void Stop() override;
void SetLooping(bool enable) override;
bool GetLooping() const override;
void SetVolume(float volume) override;
float GetVolume() const override;
void SetPitch(float pitch) override;
float GetPitch() const override;
bool IsPlaying() const override;
bool IsPaused() const override;
void SetSeek(double position) override;
double GetSeek() const override;
double TotalTime() const override;
/* ----- Buffers and streaming ----- */
void AttachBuffer(const WaveBuffer& waveBuffer) override;
void AttachSharedBuffer(const Sound& sourceBufferSound) override;
void QueueBuffer(const WaveBuffer& waveBuffer) override;
std::size_t GetQueueSize() const override;
std::size_t GetProcessedQueueSize() const override;
/* ----- 3D sound ----- */
void Enable3D(bool enable = true) override;
bool Is3DEnabled() const override;
void SetPosition(const Gs::Vector3f& position) override;
Gs::Vector3f GetPosition() const override;
void SetVelocity(const Gs::Vector3f& velocity) override;
Gs::Vector3f GetVelocity() const override;
void SetSpaceRelative(bool enable) override;
bool GetSpaceRelative() const override;
private:
friend class NullAudioSystem;
void SyncPlay();
void SyncPause();
void SyncStop();
void UnsynchPlay();
void UnsynchPause();
void UnsynchStop();
double UnsynchTotalTime() const;
void RegisterInSoundManager();
void UnregisterInSoundManager();
NullAudioSystem* audioSystem_ = nullptr;
std::weak_ptr<bool> audioSystemLive_;
mutable std::mutex mutex_;
// synchronized {
std::shared_ptr<WaveBuffer> waveBuffer_;
double seek_ = 0.0f;
bool playing_ = false;
bool paused_ = false;
bool looping_ = false;
float pitch_ = 1.0f;
// }
float volume_ = 1.0f;
bool enabled3D_ = false;
bool spaceRelative_ = false;
Gs::Vector3f position_;
Gs::Vector3f velocity_;
};
} // /namespace Ac
#endif
// ================================================================================
| 25.632 | 89 | 0.541823 | [
"3d"
] |
98c5e9990b87b544a5568feded34ac2a488d18c7 | 3,784 | h | C | MemoryPool.h | reunanen/CPPShift-MemoryPool | 5d3df2e3ddb3dbaf95cc1a7fc5215fa22756be5c | [
"Apache-2.0"
] | null | null | null | MemoryPool.h | reunanen/CPPShift-MemoryPool | 5d3df2e3ddb3dbaf95cc1a7fc5215fa22756be5c | [
"Apache-2.0"
] | null | null | null | MemoryPool.h | reunanen/CPPShift-MemoryPool | 5d3df2e3ddb3dbaf95cc1a7fc5215fa22756be5c | [
"Apache-2.0"
] | null | null | null | /**
* CPPShift Memory Pool v2.0.0
*
* Copyright 2020-present Sapir Shemer, DevShift (devshift.biz)
*
* 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.
*
* @author Sapir Shemer
*/
#pragma once
#include "MemoryPoolData.h"
#include <cstring>
#include <cstddef>
#include <memory>
namespace CPPShift::Memory {
class MemoryPool {
public:
/**
* Creates a memory pool structure and initializes it
*
* @param size_t block_size Defines the default size of a block in the pool, by default uses MEMORYPOOL_DEFAULT_BLOCK_SIZE
*/
MemoryPool(size_t block_size = MEMORYPOOL_DEFAULT_BLOCK_SIZE);
// Destructor
~MemoryPool();
// Data about the memory pool blocks
SMemoryBlockHeader* firstBlock;
SMemoryBlockHeader* currentBlock;
size_t defaultBlockSize;
// Data about memory scopes
SMemoryScopeHeader* currentScope;
/**
* Create a new standalone memory block unattached to any memory pool
*
* @param size_t block_size Defines the default size of a block in the pool, by default uses MEMORYPOOL_DEFAULT_BLOCK_SIZE
*
* @returns SMemoryBlockHeader* Pointer to the header of the memory block
*/
void createMemoryBlock(size_t block_size = MEMORYPOOL_DEFAULT_BLOCK_SIZE);
/**
* Allocates memory in a pool
*
* @param MemoryPool* mp Memory pool to allocate memory in
* @param size_t size Size to allocate in memory pool
*
* @returns void* Pointer to the newly allocate space
*/
void* allocate(size_t size);
// Templated allocation
template<typename T>
T* allocate(size_t instances);
/**
* Re-allocates memory in a pool
*
* @param void* unit_pointer_start Pointer to the object to re-allocate
* @param size_t new_size New size to allocate in memory pool
*
* @returns void* Pointer to the newly allocate space
*/
void* reallocate(void* unit_pointer_start, size_t new_size);
// Templated re-allocation
template<typename T>
T* reallocate(T* unit_pointer_start, size_t new_size);
/**
* Frees memory in a pool
*
* @param void* unit_pointer_start Pointer to the object to free
*/
void free(void* unit_pointer_start);
/**
* Dump memory pool meta data of blocks unit to stream.
* Might be useful for debugging and analyzing memory usage
*
* @param MemoryPool* mp Memory pool to dump data from
*/
void dumpPoolData();
/**
* Start a scope in the memory pool.
* All the allocations between startScope and andScope will be freed.
* It is a very efficient way to free multiple allocations
*
* @param MemoryPool* mp Memory pool to start the scope in
*/
void startScope();
/**
*
*/
void endScope();
};
template<typename T>
inline T* MemoryPool::allocate(size_t instances) {
return reinterpret_cast<T*>(this->allocate(instances * sizeof(T)));
}
template<typename T>
inline T* MemoryPool::reallocate(T* unit_pointer_start, size_t instances) {
return reinterpret_cast<T*>(this->reallocate(reinterpret_cast<void*>(unit_pointer_start), instances * sizeof(T)));
}
}
// Override new operators to create with memory pool
extern void* operator new(size_t size, CPPShift::Memory::MemoryPool* mp);
extern void* operator new[](size_t size, CPPShift::Memory::MemoryPool* mp); | 29.795276 | 124 | 0.711416 | [
"object"
] |
98ca88f29a28cce3f6021ee1eb1cb83a45a4c51e | 5,802 | h | C | src/util/WaspOptions.h | alviano/wasp | fd6d1e2e7ec037f63d401d3255c2c814aef32896 | [
"Apache-2.0"
] | 19 | 2015-12-03T08:53:45.000Z | 2022-03-31T02:09:43.000Z | src/util/WaspOptions.h | alviano/wasp | fd6d1e2e7ec037f63d401d3255c2c814aef32896 | [
"Apache-2.0"
] | 5 | 2016-04-07T10:20:23.000Z | 2021-12-24T10:23:12.000Z | src/util/WaspOptions.h | alviano/wasp | fd6d1e2e7ec037f63d401d3255c2c814aef32896 | [
"Apache-2.0"
] | 6 | 2015-01-15T07:51:48.000Z | 2020-06-18T14:47:48.000Z | /*
*
* Copyright 2013 Mario Alviano, Carmine Dodaro, and Francesco Ricca.
*
* 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 WASP_OPTIONS_H
#define WASP_OPTIONS_H
#include <vector>
#include <map>
#include "WaspConstants.h"
#include "WaspTrace.h"
using namespace std;
class WaspFacade;
namespace wasp
{
/**
* This class contains a field for each option of wasp.
*
*/
class Options
{
public:
#ifdef TRACE_ON
static TraceLevels traceLevels;
#endif
static void parse( int argc, char* const* argv );
static void setOptions( WaspFacade& waspFacade );
static unsigned int maxCost;
static bool forwardPartialChecks;
static bool heuristicPartialChecks;
static unsigned int queryAlgorithm;
static unsigned int queryVerbosity;
static bool computeFirstModel;
static unsigned int budget;
static bool printLastModelOnly;
static bool printBounds;
static bool printAtomTable;
static bool stratification;
static unsigned int interpreter;
static char* heuristic_scriptname;
static vector< string > pluginsFilenames;
static SHIFT_STRATEGY shiftStrategy;
static string scriptDirectory;
static bool oneDefShift;
static bool simplifications;
static unsigned int minimizationStrategy;
static unsigned int minimizationBudget;
static unsigned int enumerationStrategy;
static WEAK_CONSTRAINTS_ALG weakConstraintsAlg;
static unsigned int kthreshold;
static unsigned int silent;
static bool printOnlyOptimum;
static bool useLazyWeakConstraints;
static unsigned int chunkPercentage;
static unsigned int chunkSize;
static unsigned int minimizePredicateChunkPercentage;
static unsigned int modelcheckerAlgorithm;
static bool compactReasonsForHCC;
static DELETION_POLICY deletionPolicy;
static unsigned int deletionThreshold;
static vector< const char* > inputFiles;
static unsigned int maxModels;
static OUTPUT_POLICY outputPolicy;
static bool minisatPolicy;
static RESTARTS_POLICY restartsPolicy;
static unsigned int restartsThreshold;
static unsigned int timeLimit;
static bool disjCoresPreprocessing;
static bool minimizeUnsatCore;
static bool callPyFinalize;
static double sizeLBDQueue;
static double sizeTrailQueue;
static double K;
static double R;
static int nbclausesBeforeReduce;
static int incReduceDB;
static int specialIncReduceDB;
static unsigned int lbLBDFrozenClause;
static unsigned int lbLBDMinimizingClause;
static bool stats;
static unsigned int statsVerbosity;
static double initVariableIncrement;
static double initVariableDecay;
static unsigned int initValue;
static unsigned int initMinisatHeuristic;
static unsigned int initSign;
static bool multiAggregates;
static bool queryCoreCache;
static unsigned int predMinimizationAlgorithm;
static vector< string > predicatesToMinimize;
static vector< string > predicatesMUS;
static unsigned int multiThreshold;
static map< string, WEAK_CONSTRAINTS_ALG > stringToWeak;
static map< string, SHIFT_STRATEGY > stringToShift;
static map< string, unsigned int > stringToMinimization;
static map< string, unsigned int > stringToQueryAlgorithms;
static map< string, unsigned int > stringToInitMinisatHeuristic;
static map< string, unsigned int > stringToPredMinimization;
static WEAK_CONSTRAINTS_ALG getAlgorithm( const string& s );
static SHIFT_STRATEGY getShiftStrategy( const string& s );
static unsigned int getMinimizationStrategy( const string& s );
static unsigned int getEnumerationStrategy( const string& s );
static unsigned int getQueryAlgorithm( const string& s );
static unsigned int getInitMinisatHeuristic( const string& s );
static void initMap();
static void checkOptions();
};
}
#endif
| 32.965909 | 90 | 0.573423 | [
"vector"
] |
98cb1125af63704f5e11e8bf4169beb1aabffc62 | 7,170 | h | C | sources/lv1/driver/rsx/core/context.h | AlexAltea/lv1-reversing | 3d9ea0a243e403a9b5eb881e9c97949a72e47ef1 | [
"MIT"
] | 16 | 2016-03-16T21:25:49.000Z | 2021-09-26T03:58:42.000Z | sources/lv1/driver/rsx/core/context.h | x0rloser/lv1-reversing | 3d9ea0a243e403a9b5eb881e9c97949a72e47ef1 | [
"MIT"
] | null | null | null | sources/lv1/driver/rsx/core/context.h | x0rloser/lv1-reversing | 3d9ea0a243e403a9b5eb881e9c97949a72e47ef1 | [
"MIT"
] | 4 | 2018-03-26T11:05:33.000Z | 2021-03-13T18:21:20.000Z | /**
* (c) 2016 The LV1RE Project.
* Released under MIT license. Read LICENSE for more details.
*/
#pragma once
#include "common/types.h"
#include "lv1/driver/rsx/core/device.h"
#include "lv1/driver/rsx/core/memory.h"
#include "lv1/driver/rsx/object/channel.h"
#include "lv1/driver/rsx/object/context_dma.h"
#include "lv1/driver/rsx/object/nv_class.h"
#include "lv1/driver/rsx/object/sw_class.h"
enum {
L1GPU_SYSTEM_MODE_SMALL_IO_PAGES = (1 << 1), // Use 64 KB pages for GART memory mapping (otherwise 1 MB)
L1GPU_SYSTEM_MODE_GSEMU = (1 << 2), // Create DMA objects: 0xFEED0003, 0xFEED0004
L1GPU_SYSTEM_MODE_SYSTEM_SEMA = (1 << 3), // System semaphore
L1GPU_SYSTEM_MODE_LOCAL_PB = (1 << 4), // Local PB
L1GPU_SYSTEM_MODE_UNK20 = (1 << 5), // Create DMA objects: 0xBAD68000
L1GPU_SYSTEM_MODE_UNK400 = (1 << 10), // Use 512 MB of VRAM IO address space (otherwise 256 MB)
L1GPU_SYSTEM_MODE_UNK800 = (1 << 11), // Set IRQ mask to 0x00000000 (otherwise 0xFFFFFFFF)
};
// LV1 RSX context display buffer object, size 0x28
struct rsx_ctx_dbuf_obj_t {
S08 unk_00; // 0x00: flag
S08 pad0[3]; // 0x01:
S32 width; // 0x04: display buffer width in pixels
S32 height; // 0x08: display buffer height in pixels
S32 pitch; // 0x0C: display buffer pitch size in byte
S64 unk_10; // 0x10:
S64 bar1_addr; // 0x18: BAR1(VRAM) address of display buffer
S64 dma_obj; // 0x20: DMA object, e.g. 0xDAC10001
};
// LV1 RSX context object, size 0x340
class rsx_core_context_t {
S64 core_id; // 0x000: RSX core object ID
U32 id; // 0x008: RSX context ID, (index XOR 0x55555555)
S32* unk_00C; // 0x00C: ? ptr
S64* mem_ctx; // 0x010: RSX memory context
U64 system_mode; // 0x018: system mode flags, [27:27]("flag local pb"), [28:28]("flag system sema"), [29:29]("flag gsemu ctx"), [30:30]("small io page size")
S64 unk_020; // 0x020: ? eic, ctx 0(0x38), ctx 1(0x39)
S32 index; // 0x028: RSX context object index, 0, 1 or 2
S32 unk_02C; // 0x02C: ?
S64 io_offset; // 0x030: IO offset, ctx 0(0x80000000), ctx 1(0x90000000)
S64 unk_038; // 0x038: ?
S64 io_size; // 0x040: IO size, 0x10000000(256 MB)
S64 page_size; // 0x048: page size, based on system mode[29:29]: 0(1 MB), 1(64 KB)
//--------------------------------------------------------------------
rsx_object_nv_class_t* nv_obj[8]; // 0x050: nv class objects
//--------------------------------------------------------------------
rsx_object_sw_class_t* sw_obj; // 0x090: sw class object, 0xCAFEBABE
//--------------------------------------------------------------------
rsx_object_context_dma_t* dma_098; // 0x098: dma class object, 0xFEED0000 or 0xFEED0001
//--------------------------------------------------------------------
rsx_object_context_dma_t* dma_0A0; // 0x0A0: dma class object, 0xFEED0000
rsx_object_context_dma_t* dma_0A8; // 0x0A8: dma class object, 0xFEED0001
//--------------------------------------------------------------------
S64 unk_0B0; // 0x0B0:
//--- if "flag gsemu ctx" --------------------------------------------
rsx_object_context_dma_t* dma_0B8; // 0x0B8: dma class object, 0xFEED0003
rsx_object_context_dma_t* dma_0C0; // 0x0C0: dma class object, 0xFEED0004
//--------------------------------------------------------------------
S64 reports_lpar_addr; // 0x0C8:
S64 reports_addr; // 0x0D0: BAR1 reports address, ctx 0(0x2808FE00000), ctx 1(0x2808FE10000)
S64 reports_size; // 0x0D8: size of reports, 0x10000(64 KB)
S64 unk_0E0; // 0x0E0: BAR1 address: ctx 0(0x2808FE01000), ctx 1(0x2808FE11000)
S64 unk_0E8; // 0x0E8: BAR1 address: ctx 0(0x2808FE00000), ctx 1(0x2808FE10000)
S64 unk_0F0; // 0x0F0: BAR1 address: ctx 0(0x2808FF10000), ctx 1(0x2808FF10000)
S64 unk_0F8; // 0x0F8: BAR1 address: ctx 0(0x2808FE01400), ctx 1(0x2808FE11400)
//--------------------------------------------------------------------
rsx_object_context_dma_t* dma_array_0[8]; // 0x100: dma class objects, 0x66604200 to 0x66604207
rsx_object_context_dma_t* dma_array_1[8]; // 0x140: dma class objects, 0x66604208 to 0x6660420F
//--------------------------------------------------------------------
rsx_object_context_dma_t* dma_180; // 0x180: dma class object, 0x66606660
rsx_object_context_dma_t* dma_188; // 0x188: dma class object, 0x66616661
rsx_object_context_dma_t* dma_190; // 0x190: dma class object, 0x66626660
rsx_object_context_dma_t* dma_198; // 0x198: dma class object, 0xBAD68000
rsx_object_context_dma_t* dma_1A0; // 0x1A0: dma class object, 0x13378086
rsx_object_context_dma_t* dma_1A8; // 0x1A8: dma class object, 0x13378080
rsx_object_context_dma_t* dma_1B0; // 0x1B0: dma class object, 0x56616660
rsx_object_context_dma_t* dma_1B8; // 0x1B8: dma class object, 0x56616661
//--------------------------------------------------------------------
rsx_object_channel_t* ch_obj; // 0x1C0: RSX channel object
S64 unk_1C8; // 0x1C8: BAR1 address: ctx 0(0x2808FE01000), ctx 1(0x2808FE11000)
S64 unk_1D0; // 0x1D0: BAR1 address: ctx 0(0x2808FE00000), ctx 1(0x2808FE10000)
S64 unk_1D8; // 0x1D8: BAR1 address: ctx 0(0x2808FE01400), ctx 1(0x2808FE11400)
//--------------------------------------------------------------------
S08 db_flag[8]; // 0x1E0: display buffer flag, 0 to 7
rsx_ctx_dbuf_obj_t d_buf[8];// 0x1E8: display buffer objects, 0 to 7
//--------------------------------------------------------------------
S64 driver_info_addr; // 0x328: driver info address
S64 driver_info_lpar; // 0x330: driver info LPAR address
S64 driver_info_addr_0; // 0x338: driver info address too ?
// Methods
rsx_object_context_dma_t* get_dma_object_by_index(S32 index)
// Related with initialization
void sub212F78();
void sub213614();
void sub2136CC();
void sub214040();
void sub2143E0();
void sub2146F4();
void sub214C58();
public:
// Methods
rsx_core_context_t(S64 core_id, rsx_memory_context_t* mem_ctx, U64 system_mode);
void init(U64 *out, S64 core_id, rsx_memory_context_t* mem_ctx, U64 system_mode, S32 idx);
S32 iomap(U64 ea, S64 lpar_addr, S32 size, U64 flags);
S64 get_dma_control_lpar_address();
S64 get_driver_info_lpar_addr();
U32 get_rsx_context_id();
S32 get_size_of_reports(void);
};
| 57.822581 | 175 | 0.546304 | [
"object"
] |
98ea36cd0853efeb9573aaf8ef6fad6e4bcb0af9 | 1,129 | h | C | clfsm/CLReflect.v1/CLMetaMachine.h | mipalgu/gufsm | d822d36fa04946ffa6c3680725dfdba03fa9a0c5 | [
"BSD-4-Clause"
] | null | null | null | clfsm/CLReflect.v1/CLMetaMachine.h | mipalgu/gufsm | d822d36fa04946ffa6c3680725dfdba03fa9a0c5 | [
"BSD-4-Clause"
] | null | null | null | clfsm/CLReflect.v1/CLMetaMachine.h | mipalgu/gufsm | d822d36fa04946ffa6c3680725dfdba03fa9a0c5 | [
"BSD-4-Clause"
] | 1 | 2021-09-14T18:37:16.000Z | 2021-09-14T18:37:16.000Z | #ifndef CLMETAMACHINE_H
#define CLMETAMACHINE_H
#include "CLMetaState.h"
#include "CLMetaProperty.h"
#include <string>
#include <map>
#include <memory>
#include <vector>
namespace CLReflect
{
class CLMetaMachine
{
protected:
std::string _name;
std::string _type;
std::map<std::string, std::shared_ptr<CLMetaProperty> > _properties;
std::map<std::string, std::shared_ptr<CLMetaState> > _states;
public:
CLMetaMachine() {}
CLMetaMachine(std::string name, std::string type) :
_name(name), _type(type) {}
std::string getType() const { return _type; }
std::string getName() const { return _name; }
void setName(std::string newName) { _name = newName; }
void addProperty(std::shared_ptr<CLMetaProperty> newProperty);
std::shared_ptr<CLMetaProperty> getProperty(std::string propertyName);
void addState(std::shared_ptr<CLMetaState> newState);
std::shared_ptr<CLMetaState> getState(std::string stateName);
std::vector< std::shared_ptr<CLMetaState> > getStates();
};
}
#endif
| 22.137255 | 78 | 0.651904 | [
"vector"
] |
98ebd058e9aa62513cd73ad516e2be58d99ab21d | 5,492 | h | C | genetics/algo/ProceduralAlgorithm.h | crest01/ShapeGenetics | 7321f6484be668317ad763c0ca5e4d6cbfef8cd1 | [
"MIT"
] | 18 | 2017-04-26T13:53:43.000Z | 2021-05-29T03:55:27.000Z | genetics/algo/ProceduralAlgorithm.h | crest01/ShapeGenetics | 7321f6484be668317ad763c0ca5e4d6cbfef8cd1 | [
"MIT"
] | null | null | null | genetics/algo/ProceduralAlgorithm.h | crest01/ShapeGenetics | 7321f6484be668317ad763c0ca5e4d6cbfef8cd1 | [
"MIT"
] | 2 | 2017-10-17T10:32:01.000Z | 2019-11-11T07:23:54.000Z | /*
* ProceduralAlgorithm.h
*
* Created on: Jul 15, 2016
* Author: toe
*/
#ifndef PROCEDURALALGORITHM_H_
#define PROCEDURALALGORITHM_H_
#include <fstream>
#include "Evaluation_IF.h"
#include "Genome_IF.h"
#include "Grammar_IF.h"
#include "Mutation_IF.h"
#include "Population_IF.h"
#include "Recombination_IF.h"
#include "Selection_IF.h"
#include "Algorithm_IF.h"
#include "Statistics_IF.h"
#include "GeometryBufferInstanced.h"
#include "GeneratedVertex.h"
#include "Config.h"
#include "SymbolManager.h"
#include "GeneticAlgoConfig.h"
namespace PGA {
class ProceduralAlgorithm_impl {
private:
ProceduralAlgorithm* _algo;
std::string _type;
ProceduralAlgorithm_impl() :
_current_index(-1)
{
_algo = new ProceduralAlgorithm;
}
~ProceduralAlgorithm_impl()
{
// stats_file.close();
delete _algo;
};
ProceduralAlgorithm_impl(ProceduralAlgorithm_impl const&) = delete;
void operator=(ProceduralAlgorithm_impl const&) = delete;
int _current_index;
std::ofstream stats_file;
bool _display_target;
static void createBasicAlgoFromConfig(ProceduralAlgorithm* algo, Config& config);
void initCommonAlgo();
static ProceduralAlgorithm_impl* createGeneticAlgoFromConfig(Config& config);
void initGeneticAlgo();
static ProceduralAlgorithm_impl* createMHAlgoFromConfig(Config& config);
void initMHAlgo();
static ProceduralAlgorithm_impl* createSMCAlgoFromConfig(Config& config);
void initSMCAlgo();
static ProceduralAlgorithm_impl* createSOSMCAlgoFromConfig(Config& config);
void initSOSMCAlgo();
public:
static ProceduralAlgorithm_impl* createFromConfig(const std::string& filename);
void init();
void findSolution();
void toggleDisplayTarget() {
_display_target = ! _display_target;
}
void displayNext()
{
_current_index ++;
PopulationConf* pop = _algo->get<PopulationConf*>("population");
if (_current_index >= pop->impl()->activeGenerationSize()) {
_current_index = -1;
}
}
void displayPrev()
{
_current_index --;
PopulationConf* pop = _algo->get<PopulationConf*>("population");
if (_current_index < -1) {
_current_index = pop->impl()->activeGenerationSize() - 1;
}
}
GeometryBufferInstanced& getGeometryBufferInstanced()
{
GeometryConf* geometry_conf = _algo->get<GeometryConf*>("geometry");
if (_display_target) {
return *geometry_conf->getInstancedTargetMeshBuffer();
}
else {
return *geometry_conf->getInstancedObjectMeshBuffer();
}
}
const std::string& getName()
{
AlgorithmConf* conf = _algo->get<AlgorithmConf*>("base");
return conf->getName();
}
void getVoxels(std::vector<math::float4>& center)
{
EvaluationConf* conf = _algo->get<EvaluationConf*>("evaluation");
if (_display_target) {
conf->impl()->generateTargetVoxels(center);
}
else {
conf->impl()->generateVoxels(_current_index, center);
}
}
void generateGeometry()
{
if (_display_target) {
std::cerr << "Display target" << std::endl;
return;
}
else {
GeometryConf* geometry = _algo->get<GeometryConf*>("geometry");
PopulationConf* pop = _algo->get<PopulationConf*>("population");
Genome_IF* genome = nullptr;
if (_current_index == -1) {
genome = pop->impl()->getBestGenome();
}
else {
genome = pop->impl()->getGenome(_current_index);
}
if (genome == nullptr) {
return;
}
GrammarConf* grammar = _algo->get<GrammarConf*>("grammar");
grammar->impl()->createGeometry(genome);
if (_current_index == -1) {
std::cerr << "Display best Genome (" << genome->getEvalPoints() << " Points, " << genome->length() << " symbols) of " << pop->impl()->activeGenerationSize() << std::endl;
}
else {
std::cerr << "Display Genome " << _current_index << " (" << genome->getEvalPoints() << " Points, " << genome->length() << " symbols) of " << pop->impl()->activeGenerationSize() << std::endl;
}
}
}
void getCameraParameters(float& phi, float& theta, float& radius, math::float3& lookat)
{
EvaluationConf* eval = _algo->get<EvaluationConf*>("evaluation");
if(ImageEvaluationConf* v = dynamic_cast<ImageEvaluationConf*>(eval)) {
float fov, znear, zfar;
v->getCameraParameters(fov, znear, zfar, phi, theta, radius, lookat);
}
}
void create_next_generation()
{
AlgorithmConf* conf = _algo->get<AlgorithmConf*>("base");
conf->impl()->createNewGeneration();
conf->impl()->evaluatePopulation();
//_current_index = 0;
}
int getMaxNumGenerations() {
AlgorithmConf* conf = _algo->get<AlgorithmConf*>("base");
return conf->getMaxGenerations();
}
void doOneGeneration()
{
AlgorithmConf* conf = _algo->get<AlgorithmConf*>("base");
conf->impl()->doOneGeneration();
//_current_index = 0;
}
void writeStatistics() {
StatisticsConf* conf = _algo->get<StatisticsConf*>("statistics");
conf->impl()->writeStatistics(false);
}
void reset() {
AlgorithmConf* conf = _algo->get<AlgorithmConf*>("base");
StatisticsConf* stats = _algo->get<StatisticsConf*>("statistics");
stats->impl()->clearStats();
conf->impl()->reset();
}
void run()
{
AlgorithmConf* conf = _algo->get<AlgorithmConf*>("base");
StatisticsConf* stats = _algo->get<StatisticsConf*>("statistics");
conf->impl()->run();
_current_index = -1;
stats->impl()->writeStatistics(true);
}
void saveObj()
{
GeometryConf* geometry = _algo->get<GeometryConf*>("geometry");
geometry->getInstancedMeshBuffer()->saveToObj("result.obj");
}
};
} // namespace PGA
#endif /* PROCEDURALALGORITHM_H_ */
| 23.982533 | 194 | 0.694465 | [
"geometry",
"vector"
] |
98ed4e79468251eae0f1187c109b819224e0d99e | 5,106 | h | C | ants/lib/antsRegistrationCommandIterationUpdate.h | ncullen93/ANTsPy | a4c990dcd5b7445a45ce7b366ee018c7350e7d9f | [
"Apache-2.0"
] | 3 | 2018-06-07T19:11:47.000Z | 2019-06-10T05:24:06.000Z | ants/lib/antsRegistrationCommandIterationUpdate.h | ncullen93/ANTsPy | a4c990dcd5b7445a45ce7b366ee018c7350e7d9f | [
"Apache-2.0"
] | null | null | null | ants/lib/antsRegistrationCommandIterationUpdate.h | ncullen93/ANTsPy | a4c990dcd5b7445a45ce7b366ee018c7350e7d9f | [
"Apache-2.0"
] | 1 | 2019-04-04T06:18:44.000Z | 2019-04-04T06:18:44.000Z | #ifndef antsRegistrationCommandIterationUpdate__h_
#define antsRegistrationCommandIterationUpdate__h_
namespace ants
{
/** \class antsRegistrationCommandIterationUpdate
* \brief change parameters between iterations of registration
*/
template <class TFilter>
class antsRegistrationCommandIterationUpdate : public itk::Command
{
public:
typedef antsRegistrationCommandIterationUpdate Self;
typedef itk::Command Superclass;
typedef itk::SmartPointer<Self> Pointer;
itkNewMacro( Self );
protected:
antsRegistrationCommandIterationUpdate()
{
m_clock.Start();
m_clock.Stop();
const itk::RealTimeClock::TimeStampType now = m_clock.GetTotal();
this->m_lastTotalTime = now;
m_clock.Start();
this->m_LogStream = &std::cout;
}
public:
void Execute(itk::Object *caller, const itk::EventObject & event) ITK_OVERRIDE
{
Execute( (const itk::Object *) caller, event);
}
void Execute(const itk::Object * object, const itk::EventObject & event ) ITK_OVERRIDE
{
TFilter const * const filter = dynamic_cast<const TFilter *>( object );
if( typeid( event ) == typeid( itk::InitializeEvent ) )
{
const unsigned int currentLevel = filter->GetCurrentLevel();
typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension( currentLevel );
typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel();
typename TFilter::TransformParametersAdaptorsContainerType adaptors =
filter->GetTransformParametersAdaptorsPerLevel();
bool smoothingSigmasAreInPhysicalUnits = filter->GetSmoothingSigmasAreSpecifiedInPhysicalUnits();
m_clock.Stop();
const itk::RealTimeClock::TimeStampType now = m_clock.GetTotal();
this->Logger() << " Current level = " << currentLevel + 1 << " of " << this->m_NumberOfIterations.size()
<< std::endl;
this->Logger() << " number of iterations = " << this->m_NumberOfIterations[currentLevel] << std::endl;
this->Logger() << " shrink factors = " << shrinkFactors << std::endl;
this->Logger() << " smoothing sigmas = " << smoothingSigmas[currentLevel];
if( smoothingSigmasAreInPhysicalUnits )
{
this->Logger() << " mm" << std::endl;
}
else
{
this->Logger() << " vox" << std::endl;
}
this->Logger() << " required fixed parameters = " << adaptors[currentLevel]->GetRequiredFixedParameters()
<< std::flush << std::endl;
// this->Logger() << "\n LEVEL_TIME_INDEX: " << now << " SINCE_LAST: " << (now-this->m_lastTotalTime) <<
// std::endl;
this->m_lastTotalTime = now;
m_clock.Start();
typedef itk::GradientDescentOptimizerv4Template<typename TFilter::RealType> GradientDescentOptimizerType;
GradientDescentOptimizerType * optimizer = reinterpret_cast<GradientDescentOptimizerType *>( const_cast<TFilter *>( filter )->GetModifiableOptimizer() );
// TODO: This looks very wrong. There is a const_cast above, and then the change
// of the number of iterations here on what should be a const object.
optimizer->SetNumberOfIterations( this->m_NumberOfIterations[currentLevel] );
}
else if( typeid( event ) == typeid( itk::IterationEvent ) )
{
const unsigned int lCurrentIteration = filter->GetCurrentIteration();
if( lCurrentIteration == 1 )
{
// Print header line one time
this->Logger() << "XDIAGNOSTIC,Iteration,metricValue,convergenceValue,ITERATION_TIME_INDEX,SINCE_LAST"
<< std::flush << std::endl;
}
m_clock.Stop();
const itk::RealTimeClock::TimeStampType now = m_clock.GetTotal();
this->Logger() << "WDIAGNOSTIC, "
<< std::setw(5) << lCurrentIteration << ", "
<< std::scientific << std::setprecision(12) << filter->GetCurrentMetricValue() << ", "
<< std::scientific << std::setprecision(12) << filter->GetCurrentConvergenceValue() << ", "
<< std::setprecision(4) << now << ", "
<< std::setprecision(4) << (now - this->m_lastTotalTime) << ", "
<< std::flush << std::endl;
this->m_lastTotalTime = now;
m_clock.Start();
}
}
void SetNumberOfIterations( const std::vector<unsigned int> & iterations )
{
this->m_NumberOfIterations = iterations;
}
void SetLogStream(std::ostream & logStream)
{
this->m_LogStream = &logStream;
}
private:
std::ostream & Logger() const
{
return *m_LogStream;
}
std::vector<unsigned int> m_NumberOfIterations;
std::ostream * m_LogStream;
itk::TimeProbe m_clock;
itk::RealTimeClock::TimeStampType m_lastTotalTime;
// typename ImageType::Pointer m_origFixedImage;
// typename ImageType::Pointer m_origMovingImage;
};
}; // end namespace ants
#endif // antsRegistrationCommandIterationUpdate__h_
| 39.890625 | 159 | 0.648061 | [
"object",
"vector"
] |
98f66fe71a170cec362aabdd840b54cf9d07074d | 3,813 | h | C | src/rl/sg/fcl/Shape.h | Broekman/rl | 285a7adab0bca3aa4ce4382bf5385f5b0626f10e | [
"BSD-2-Clause"
] | 568 | 2015-01-23T03:38:45.000Z | 2022-03-30T16:12:56.000Z | src/rl/sg/fcl/Shape.h | Broekman/rl | 285a7adab0bca3aa4ce4382bf5385f5b0626f10e | [
"BSD-2-Clause"
] | 53 | 2016-03-23T13:16:47.000Z | 2022-03-17T05:58:06.000Z | src/rl/sg/fcl/Shape.h | Broekman/rl | 285a7adab0bca3aa4ce4382bf5385f5b0626f10e | [
"BSD-2-Clause"
] | 169 | 2015-01-26T12:59:41.000Z | 2022-03-29T13:44:54.000Z | //
// Copyright (c) 2009, Markus Rickert
// 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.
//
// 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 RL_SG_FCL_SHAPE_H
#define RL_SG_FCL_SHAPE_H
#include <memory>
#include <fcl/config.h>
#include <Inventor/actions/SoCallbackAction.h>
#include <Inventor/VRMLnodes/SoVRMLShape.h>
#if FCL_MAJOR_VERSION < 1 && FCL_MINOR_VERSION < 6
#include <fcl/collision.h>
#else
#include <fcl/narrowphase/collision.h>
#endif
#include "../Shape.h"
namespace rl
{
namespace sg
{
namespace fcl
{
#if FCL_MAJOR_VERSION < 1 && FCL_MINOR_VERSION < 6
typedef ::fcl::CollisionGeometry CollisionGeometry;
typedef ::fcl::CollisionObject CollisionObject;
typedef ::fcl::FCL_REAL Real;
typedef ::fcl::Vec3f Vector3;
#else
typedef ::fcl::CollisionGeometry<::rl::math::Real> CollisionGeometry;
typedef ::fcl::CollisionObject<::rl::math::Real> CollisionObject;
typedef ::rl::math::Real Real;
typedef ::fcl::Vector3<::rl::math::Real> Vector3;
#endif
class RL_SG_EXPORT Shape : public ::rl::sg::Shape
{
public:
Shape(::SoVRMLShape* shape, ::rl::sg::Body* body);
#if FCL_MAJOR_VERSION < 1 && FCL_MINOR_VERSION < 5
Shape(const ::boost::shared_ptr<CollisionGeometry>& geometry, ::rl::sg::Body* body);
#else
Shape(const ::std::shared_ptr<CollisionGeometry>& geometry, ::rl::sg::Body* body);
#endif
virtual ~Shape();
CollisionObject* getCollisionObject() const;
using ::rl::sg::Shape::getTransform;
::rl::math::Transform getTransform() const;
void setTransform(const ::rl::math::Transform& transform);
void update(const ::rl::math::Transform& frame);
protected:
private:
static void triangleCallback(void* userData, ::SoCallbackAction* action, const ::SoPrimitiveVertex* v1, const ::SoPrimitiveVertex* v2, const ::SoPrimitiveVertex* v3);
::rl::math::Transform base;
#if FCL_MAJOR_VERSION < 1 && FCL_MINOR_VERSION < 6
::std::vector<Real> distances;
#endif
::rl::math::Transform frame;
#if FCL_MAJOR_VERSION < 1 && FCL_MINOR_VERSION < 5
::boost::shared_ptr<CollisionGeometry> geometry;
#else
::std::shared_ptr<CollisionGeometry> geometry;
#endif
::std::vector<int> indices;
#if FCL_MAJOR_VERSION < 1 && FCL_MINOR_VERSION < 6
::std::vector<Vector3> normals;
#endif
::std::shared_ptr<CollisionObject> object;
::std::vector<int> polygons;
::rl::math::Transform transform;
::std::vector<Vector3> vertices;
};
}
}
}
#endif // RL_SG_FCL_SHAPE_H
| 31.254098 | 170 | 0.708891 | [
"geometry",
"object",
"shape",
"vector",
"transform"
] |
98fd4bf62291cb4ed7fd22344189a31dc93dfbd9 | 2,172 | h | C | chrome/browser/task_manager/sampling/arc_shared_sampler.h | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 575 | 2015-06-18T23:58:20.000Z | 2022-03-23T09:32:39.000Z | chrome/browser/task_manager/sampling/arc_shared_sampler.h | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 113 | 2015-05-04T09:58:14.000Z | 2022-01-31T19:35:03.000Z | chrome/browser/task_manager/sampling/arc_shared_sampler.h | iridium-browser/iridium-browser | 907e31cf5ce5ad14d832796e3a7c11e496828959 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 52 | 2015-07-14T10:40:50.000Z | 2022-03-15T01:11:49.000Z | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_TASK_MANAGER_SAMPLING_ARC_SHARED_SAMPLER_H_
#define CHROME_BROWSER_TASK_MANAGER_SAMPLING_ARC_SHARED_SAMPLER_H_
#include <stdint.h>
#include <map>
#include "base/callback.h"
#include "base/containers/flat_map.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/process/process_handle.h"
#include "components/arc/mojom/process.mojom.h"
namespace task_manager {
// Defines sampler that will retrieve memory footprint metrics for all arc
// processes at once. Created by TaskManagerImpl on the UI thread.
class ArcSharedSampler {
public:
ArcSharedSampler();
~ArcSharedSampler();
using MemoryFootprintBytes = uint64_t;
using OnSamplingCompleteCallback =
base::RepeatingCallback<void(base::Optional<MemoryFootprintBytes>)>;
// Registers task group specific callback.
void RegisterCallback(base::ProcessId process_id,
OnSamplingCompleteCallback on_sampling_complete);
// Unregisters task group specific callbacks.
void UnregisterCallback(base::ProcessId process_id);
// Triggers a refresh of process stats.
void Refresh();
private:
using CallbacksMap =
base::flat_map<base::ProcessId, OnSamplingCompleteCallback>;
// Called when ArcProcessService returns memory dump.
void OnReceiveMemoryDump(
int dump_type,
std::vector<arc::mojom::ArcMemoryDumpPtr> process_dumps);
// Holds callbacks registered by TaskGroup objects.
CallbacksMap callbacks_;
// Keeps track of whether there is a pending request for memory footprint of
// app or system processes.
int pending_memory_dump_types_ = 0;
// The timestamp of when the last refresh call finished, for system and
// app processes.
base::Time last_system_refresh_;
base::Time last_app_refresh_;
base::WeakPtrFactory<ArcSharedSampler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ArcSharedSampler);
};
} // namespace task_manager
#endif // CHROME_BROWSER_TASK_MANAGER_SAMPLING_ARC_SHARED_SAMPLER_H_
| 31.028571 | 78 | 0.77302 | [
"vector"
] |
c70362324ba2be6af34ac08b2cfa23fe342a2d73 | 1,694 | h | C | chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2020-10-18T02:33:40.000Z | 2020-10-18T02:33:40.000Z | chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 3 | 2021-05-17T16:28:52.000Z | 2021-05-21T22:42:22.000Z | chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_PREFETCH_PREFETCH_PROXY_CHROME_SPECULATION_HOST_DELEGATE_H_
#define CHROME_BROWSER_PREFETCH_PREFETCH_PROXY_CHROME_SPECULATION_HOST_DELEGATE_H_
#include <vector>
#include "content/public/browser/speculation_host_delegate.h"
#include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom.h"
#include "url/gurl.h"
namespace content {
class RenderFrameHost;
} // namespace content
namespace prerender {
class NoStatePrefetchHandle;
}
class ChromeSpeculationHostDelegate : public content::SpeculationHostDelegate {
public:
explicit ChromeSpeculationHostDelegate(
content::RenderFrameHost& render_frame_host);
~ChromeSpeculationHostDelegate() override;
// Disallows copy and move operations.
ChromeSpeculationHostDelegate(const ChromeSpeculationHostDelegate&) = delete;
ChromeSpeculationHostDelegate& operator=(
const ChromeSpeculationHostDelegate&) = delete;
// content::SpeculationRulesDelegate implementation.
void ProcessCandidates(
std::vector<blink::mojom::SpeculationCandidatePtr>& candidates) override;
private:
// content::SpeculationHostImpl, which inherits content::DocumentServiceBase,
// owns `this`, so `this` can access `render_frame_host_` safely.
content::RenderFrameHost& render_frame_host_;
// All on-going NoStatePrefetches
std::vector<std::unique_ptr<prerender::NoStatePrefetchHandle>>
same_origin_no_state_prefetches_;
};
#endif // CHROME_BROWSER_PREFETCH_PREFETCH_PROXY_CHROME_SPECULATION_HOST_DELEGATE_H_
| 35.291667 | 85 | 0.812279 | [
"vector"
] |
c70d3f407f503386563772c34ad6aeb0c6253391 | 9,956 | c | C | src/evaltest.c | aiporre/whisk | e07c381bc5d0df4e5dcabd7d75c0c97d0de3ad2c | [
"BSD-3-Clause"
] | 4 | 2016-06-22T14:30:14.000Z | 2021-05-15T18:24:58.000Z | src/evaltest.c | aiporre/whisk | e07c381bc5d0df4e5dcabd7d75c0c97d0de3ad2c | [
"BSD-3-Clause"
] | 20 | 2015-09-28T14:43:59.000Z | 2020-05-23T00:43:46.000Z | src/evaltest.c | aiporre/whisk | e07c381bc5d0df4e5dcabd7d75c0c97d0de3ad2c | [
"BSD-3-Clause"
] | 9 | 2015-10-12T22:31:39.000Z | 2021-09-09T04:44:20.000Z | /* Author: Nathan Clack <clackn@janelia.hhmi.org>
* Date : May 2009
*
* Copyright 2010 Howard Hughes Medical Institute.
* All rights reserved.
* Use is subject to Janelia Farm Research Campus Software Copyright 1.1
* license terms (http://license.janelia.org/license/jfrc_copyright_1_1.html).
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <float.h>
#include "image_lib.h"
#include "tiff_io.h"
#include "tiff_image.h"
#include "eval.h"
#define _USE_MATH_DEFINES
#include <math.h> //for testing
//typedef unsigned char uint8;
typedef struct _rgb{uint8 r; uint8 g; uint8 b;} rgb;
typedef struct _hsv{uint8 h; uint8 s; uint8 v;} hsv;
//typedef struct {float x; float y;} point;
void hsv2rgb( hsv *im, rgb *r )
{ float h, s, v;
h = im->h / 255.; // maps to [0,1)
s = im->s / 255.; // maps to [0,1)
v = im->v;
if( s < 0.001 ) // low saturation so just gray value
{ rgb tr = {v,v,v};
*r = tr;
}
else
{ uint8 a,b,c;
float f;
h *= 6.0;
f = h - floor(h);
a = v * (1.0 - s);
b = v * (1.0 - s*f);
c = v * (1.0 - s*(1.0-f));
v = v;
switch ((int) h) {
case 0:
{ rgb tr = {v, c, a}; *r = tr; }
break;
case 1:
{ rgb tr = {b, v, a}; *r = tr; }
break;
case 2:
{ rgb tr = {a, v, c}; *r = tr; }
break;
case 3:
{ rgb tr = {a, b, v}; *r = tr; }
break;
case 4:
{ rgb tr = {c, a, v}; *r = tr; }
break;
case 5:
{ rgb tr = {v, a, b}; *r = tr; }
break;
}
}
return;
}
void blend_rgb_ip( rgb *im, rgb *b, float a )
{ im->r = (uint8)( (im->r * (1.0-a)) + b->r * a );
im->g = (uint8)( (im->g * (1.0-a)) + b->g * a );
im->b = (uint8)( (im->b * (1.0-a)) + b->b * a );
return;
}
void write_tiff_stack_rgb( char *name, rgb* buf, int width, int height, int depth )
{ int iframe;
Tiff_Writer *tiff = Open_Tiff_Writer(name,0);
Tiff_Image *plane = Create_Tiff_Image( width, height );
void *tr,*tb,*tg;
Add_Tiff_Image_Channel( plane, CHAN_RED, 8, CHAN_UNSIGNED );
Add_Tiff_Image_Channel( plane, CHAN_GREEN, 8, CHAN_UNSIGNED );
Add_Tiff_Image_Channel( plane, CHAN_BLUE, 8, CHAN_UNSIGNED );
for( iframe = 0; iframe < depth; iframe++ )
{ uint8 *dest;
rgb *im, *src;
/* Select Plane and copy out to channels of Tiff_Image */
im = buf + iframe * width * height;
/* red */
src = im + width*height ;
dest = (uint8*) ( plane->channels[0]->plane)+ width*height ;
while( --src >= im )
*(--dest) = src->r;
/* green */
src = im + width*height ;
dest = (uint8*) ( plane->channels[1]->plane)+ width*height ;
while( --src >= im )
*(--dest) = src->g;
/* blue */
src = im + width*height ;
dest = (uint8*) ( plane->channels[2]->plane)+ width*height ;
while( --src >= im )
*(--dest) = src->b;
{ Tiff_IFD *ifd = Make_IFD_For_Image( plane, 0 );
Write_Tiff_IFD(tiff, ifd );
Free_Tiff_IFD(ifd);
}
}
Free_Tiff_Image( plane );
Close_Tiff_Writer(tiff);
Free_Tiff_Writer(tiff);
}
#ifdef EVAL_TEST_1
#define WIDTH 100
#define HEIGHT 100
#define NFRAMES 50
#define N 20
int main(int argc, char* argv[])
{ float grid[ WIDTH*HEIGHT ];
int strides[3] = { WIDTH*HEIGHT, WIDTH, 1 }; // for grid which is 1 channel
uint8 *image, stack[ 3*WIDTH*HEIGHT*NFRAMES ];
int iframe;
float poly[2*N];
memset(stack, 0, 3*WIDTH*HEIGHT*NFRAMES );
iframe = NFRAMES;
while(iframe--)
{ float sc = 80.0 * (NFRAMES-iframe) / (float) NFRAMES;
float tr = 40.0 * ( iframe) / (float) NFRAMES;
float rr = (M_PI/2.0) * ( iframe) / (float) NFRAMES;
printf("frame: %d\n",iframe);
image = stack + iframe*3*WIDTH*HEIGHT;
{ int i = 2*N;
while( i )
{ poly[--i] = sin(2.*M_PI*i/(2.0*N));
poly[--i] = cos(2.*M_PI*(0.2 + (i+1)/(2.0*N)));
}
}
// poly[0] = -1.0; poly[1] = -0.005;
// poly[2] = -1.0; poly[3] = 0.005;
// poly[4] = 1.0; poly[5] = 0.005;
// poly[6] = 1.0; poly[7] = -0.005;
scale( (point*) poly, N, sc );
rotate( (point*) poly, N, rr );
{ point shift = { tr + WIDTH/2.0, tr + HEIGHT/2.0 };
translate( (point*) poly, N, shift );
}
{ float th;
//hsv px_hsv;
rgb px_rgb;
for( th = 0; th < M_PI; th += M_PI/8.0)
{ const point shift = { -tr -WIDTH/2.0, -tr -HEIGHT/2.0 },
ishift = { tr +WIDTH/2.0, tr + HEIGHT/2.0 };
translate( (point*) poly, N, shift );
rotate( (point*) poly, N, th );
translate( (point*) poly, N, ishift );
memset(grid, 0, sizeof(float)*WIDTH*HEIGHT );
Compute_Pixel_Overlap( poly, N, 1.0, grid, strides );
{ int i = WIDTH*HEIGHT;
hsv px_hsv = { 255 * th / M_PI , //255 * fabs(grid[i]);
255 ,
255 };
hsv2rgb( &px_hsv, &px_rgb );
while(i--)
blend_rgb_ip( (rgb*)(image+3*i), &px_rgb, 0.7*fabs(grid[i]));
}
}
}
}
write_tiff_stack_rgb( "test.tif", (rgb*) stack, WIDTH, HEIGHT, NFRAMES);
return 0;
}
#endif //EVAL_TEST_1
#ifdef EVAL_TEST_2
int main(int argc, char* argv[])
{ Image *im = Make_Image( FLOAT32, 101, 101);
int strides[3] = {101*101,101,1};
point p = { 50.5, 50.5 };
memset( im->array, 0, im->kind * im->width * im->height );
Render_Line_Detector( 0.1, 8.0, 0.0, 2.0,
p,
(float*) im->array, strides );
Scale_Image_To_Range(im, 0, 0, 255);
im = Translate_Image(im, GREY8, 1);
Write_Image("evaltest2.tif",im);
Free_Image(im);
return 0;
}
#endif //EVAL_TEST_2
#ifdef EVAL_TEST_3
int main(int argc, char* argv[])
{ Range params[3] = { {0.0, 1.0, 0.2},
{0.5, 6.5, 0.4},
{-M_PI/4.0, M_PI/4.0, M_PI/36.0} };
Array *bank = Build_Line_Detectors( params[0], params[1], params[2],
7, 2*7+3 );
{ float *p,*d,sum=0.0;
d = (float*) bank->data;
p = d + bank->strides_px[0];
while( p-- > d )
sum += *p;
printf("sum: %g\n",sum);
if( sum > 0.01 )
printf("Mean is not zero: The image is probably too small to support the detector\n");
}
{ Stack stk, *t;
stk.kind = 4;
stk.width = bank->shape[0];
stk.height = bank->shape[1];
stk.depth = bank->strides_px[0] / bank->strides_px[3];
stk.array = (uint8*) bank->data;
Scale_Stack_To_Range( &stk, 0, 0, 255 );
t = Translate_Stack( &stk, GREY8 , 0 );
Write_Stack( "bank.tif", t );
Free_Stack(t);
}
Free_Array( bank );
return 0;
}
#endif //EVAL_TEST_3
#ifdef EVAL_TEST_4
int main(int argc, char* argv[])
{ Range params[3] = { {0.0, 1.0, 0.1},
{0.5, 4.5, 0.5},
{-M_PI/4.0, M_PI/4.0, M_PI/72.0} };
Array *bank = Build_Half_Space_Detectors(
params[0],
params[1],
params[2],
7,
2*7+3);
{ float *p,*d,sum=0.0;
d = (float*) bank->data;
p = d + bank->strides_px[0];
while( p-- > d )
sum += *p;
printf("sum: %g\n",sum);
if( sum > 0.01 )
printf("Mean is not zero: The image is probably too small to support the detector\n");
}
{ Stack stk, *t;
stk.kind = 4;
stk.width = bank->shape[0];
stk.height = bank->shape[1];
stk.depth = bank->strides_px[0] / bank->strides_px[3];
stk.array = (uint8*) bank->data;
Scale_Stack_To_Range( &stk, 0, 0, 255 );
t = Translate_Stack( &stk, GREY8 , 0 );
Write_Stack( "evaltest4.tif", t );
Free_Stack(t);
}
Free_Array( bank );
return 0;
}
#endif //EVAL_TEST_4
#ifdef EVAL_TEST_5
#define NLABELS 2
int main(int argc, char* argv[])
{ Range params[3] = { {0.0, 1.0, 0.1},
{0.5, 4.5, 0.5},
{-M_PI/4.0, M_PI/4.0, M_PI/72.0} };
Array *bank = Build_Harmonic_Line_Detectors(
params[0],
params[1],
params[2],
7,
2*7+3);
{ float *p,*d,sum=0.0;
d = (float*) bank->data;
p = d + bank->strides_px[0];
while( p-- > d )
sum += ( *p - round(*p) )*10.0;;
printf("sum: %g\n",sum);
if( sum > 0.01 )
printf("Mean is not zero: The image is probably too small to support the detector\n");
}
{ Stack stk, *lbl, *t;
float *d;
int i;
d = (float*) bank->data;
stk.kind = 4;
stk.width = bank->shape[0];
stk.height = bank->shape[1];
stk.depth = bank->strides_px[0] / bank->strides_px[3];
stk.array = (uint8*) bank->data;
lbl = Make_Stack(stk.kind, stk.width, stk.height, stk.depth);
{ int j,labels[NLABELS] = {2,3/*,5,7*/};
d = (float*) bank->data;
i = bank->strides_px[0];
while( i-- )
{ float v = d[i];
int l = lround(v);
int cnt = 0;
( (float*) stk.array )[i] = (v-l)*10.0;
( (float*) lbl->array )[i] = 0;
for(j=0;j<NLABELS;j++)
if( l > 0.0 )
if( ((int)l) % labels[j] == 0 )
{ ( (float*) lbl->array )[i] += (j+1);
cnt++;
}
if(cnt)
( (float*) lbl->array )[i] /= cnt;
}
}
Scale_Stack_To_Range( &stk, 0, 0, 255 );
Scale_Stack_To_Range( lbl, 0, 0, 255 );
t = Translate_Stack( &stk, GREY8 , 0 );
Free_Stack(t);
Write_Stack( "evaltest5_weights.tif", t );
t = Translate_Stack( lbl, GREY8 , 0 );
Write_Stack( "evaltest5_labels.tif", t );
Free_Stack(t);
Free_Stack(lbl);
}
Free_Array( bank );
return 0;
}
#endif //EVAL_TEST_5
| 28.691643 | 93 | 0.502411 | [
"shape"
] |
c70e0d70367dcc0efd7123ad7ff7f83d271560f5 | 3,862 | h | C | arccore/src/base/arccore/base/Functor.h | cedricga91/framework | 143eeccb5bf375df4a3f11b888681f84f60380c6 | [
"Apache-2.0"
] | 16 | 2021-09-20T12:37:01.000Z | 2022-03-18T09:19:14.000Z | arccore/src/base/arccore/base/Functor.h | cedricga91/framework | 143eeccb5bf375df4a3f11b888681f84f60380c6 | [
"Apache-2.0"
] | 66 | 2021-09-17T13:49:39.000Z | 2022-03-30T16:24:07.000Z | arccore/src/base/arccore/base/Functor.h | cedricga91/framework | 143eeccb5bf375df4a3f11b888681f84f60380c6 | [
"Apache-2.0"
] | 11 | 2021-09-27T16:48:55.000Z | 2022-03-23T19:06:56.000Z | // -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* Functor.h (C) 2000-2018 */
/* */
/* Classes utilitaires pour gérer des fonctors. */
/*---------------------------------------------------------------------------*/
#ifndef ARCCORE_BASE_FUNCTOR_H
#define ARCCORE_BASE_FUNCTOR_H
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
#include "arccore/base/IFunctor.h"
#include <functional>
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
namespace Arccore
{
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!
* \internal
* \brief Functor associé à une méthode d'une classe \a T.
*/
template<typename T>
class FunctorT
: public IFunctor
{
public:
typedef void (T::*FuncPtr)(); //!< Type du pointeur sur la méthode
public:
//! Constructeur
FunctorT(T* object,FuncPtr funcptr)
: m_function(funcptr), m_object(object){}
~FunctorT() override { }
protected:
//! Exécute la méthode associé
void executeFunctor() override
{
(m_object->*m_function)();
}
private:
FuncPtr m_function; //!< Pointeur vers la méthode associée.
T* m_object; //!< Objet associé.
};
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!
* \internal
* \brief Functor associé à une méthode d'une classe \a T.
*/
template<typename ClassType,typename ArgType>
class FunctorWithArgumentT
: public IFunctorWithArgumentT<ArgType>
{
public:
typedef void (ClassType::*FuncPtr)(ArgType); //!< Type du pointeur sur la méthode
public:
//! Constructeur
FunctorWithArgumentT(ClassType* object,FuncPtr funcptr)
: m_object(object), m_function(funcptr) {}
protected:
//! Exécute la méthode associé
void executeFunctor(ArgType arg)
{
(m_object->*m_function)(arg);
}
private:
ClassType* m_object; //!< Objet associé.
FuncPtr m_function; //!< Pointeur vers la méthode associée.
};
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!
* \internal
* \brief Functor générique utilisant la classe std::function.
*/
template<typename ArgType>
class StdFunctorWithArgumentT
: public IFunctorWithArgumentT<ArgType>
{
public:
//! Constructeur
StdFunctorWithArgumentT(const std::function<void(ArgType)>& function)
: m_function(function) {}
public:
protected:
//! Exécute la méthode associé
void executeFunctor(ArgType arg)
{
m_function(arg);
}
private:
std::function<void(ArgType)> m_function;
};
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
} // End namespace Arccore
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
#endif
| 27.985507 | 83 | 0.411186 | [
"object"
] |
c71b90d3298a8311071338cfc084e9a2090a7fd1 | 1,298 | h | C | scheduling/pcb.h | zubernetes/tokaido | 8f8156165f3aca74dcd21fcb795b17025a915be0 | [
"MIT"
] | null | null | null | scheduling/pcb.h | zubernetes/tokaido | 8f8156165f3aca74dcd21fcb795b17025a915be0 | [
"MIT"
] | 5 | 2016-03-22T21:21:28.000Z | 2016-04-10T23:14:52.000Z | scheduling/pcb.h | zubernetes/tokaido | 8f8156165f3aca74dcd21fcb795b17025a915be0 | [
"MIT"
] | null | null | null | // pcb.h
//
// A Linked-List (simple) implementation of the
// Process Control Block that simulates the behavior
// of different scheduling algorithms.
#ifndef PCB_H
#define PCB_H
/* Required Libraries */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <queue>
#include <iostream>
#include <ctime>
#include <sys/time.h>
#include <fstream>
#include <list>
#include <vector>
class PCB {
private:
int _process_num;
int _burst_size;
int _arrival_time;
PCB *_next;
public:
PCB();
~PCB();
void setProcessID(int);
void setBurstSize(int);
void setArrivalTime(int);
void makeNull();
int getProcessID();
int getBurstSize();
int getArrivalTime();
};
PCB::PCB() {
_process_num = 0;
_burst_size = 0;
_arrival_time = 0;
}
PCB::~PCB() {
delete _next;
}
void PCB::setProcessID(int x) {
_process_num = x;
}
void PCB::setBurstSize(int x) {
_burst_size = x;
}
void PCB::setArrivalTime(int x) {
_arrival_time = x;
}
void PCB::makeNull() {
_process_num = 0;
_burst_size = 0;
_arrival_time = 0;
}
int PCB::getProcessID() {
return _process_num;
}
int PCB::getBurstSize() {
return _burst_size;
}
int PCB::getArrivalTime() {
return _arrival_time;
}
#endif
| 15.638554 | 52 | 0.644838 | [
"vector"
] |
c71c2936e2d87e365792ee94661a25d311d2ff43 | 886 | h | C | src/fcluster.h | Shao-Group/scallop-umi | 85d5d645d36b1fee9088c59db3ee358909276bd8 | [
"BSD-3-Clause"
] | 1 | 2021-12-02T15:48:07.000Z | 2021-12-02T15:48:07.000Z | src/fcluster.h | Shao-Group/scallop-umi | 85d5d645d36b1fee9088c59db3ee358909276bd8 | [
"BSD-3-Clause"
] | 4 | 2021-11-23T17:54:56.000Z | 2021-12-30T07:17:55.000Z | src/fcluster.h | Shao-Group/scallop2 | 85d5d645d36b1fee9088c59db3ee358909276bd8 | [
"BSD-3-Clause"
] | null | null | null | /*
Part of Coral
(c) 2019 by Mingfu Shao and The Pennsylvania State University.
See LICENSE for licensing.
*/
#ifndef __FRAGMENT_CLUSTER_H__
#define __FRAGMENT_CLUSTER_H__
#include <vector>
#include "path.h"
#include "fragment.h"
using namespace std;
class fcluster
{
public:
vector<fragment*> fset; // set of fragments in this cluster
int type; // for multiple uses
vector<int> v0; // vlist for closed fragments
vector<int> v1; // vlist for mate1
vector<int> v2; // vlist for mate2
vector< vector<int> > phase; // possible phasing w.r.t. reference
vector<int> count; // phase count
public:
int clear();
int print(int k) const;
int add_phase(const vector<int> &v);
const vector<int> & get_vlist() const;
};
bool compare_fcluster(const fcluster &fx, const fcluster &fy);
bool compare_fcluster_v1_v2(const fcluster &fx, const fcluster &fy);
#endif
| 23.315789 | 68 | 0.714447 | [
"vector"
] |
c71fb73601df1a0e039b96b02d057fa25133efa5 | 2,834 | h | C | data/AGNC-Lab_Quad/multithreaded/control/MatricesAndVectors.h | khairulislam/phys | fc702520fcd3b23022b9253e7d94f878978b4500 | [
"MIT"
] | null | null | null | data/AGNC-Lab_Quad/multithreaded/control/MatricesAndVectors.h | khairulislam/phys | fc702520fcd3b23022b9253e7d94f878978b4500 | [
"MIT"
] | null | null | null | data/AGNC-Lab_Quad/multithreaded/control/MatricesAndVectors.h | khairulislam/phys | fc702520fcd3b23022b9253e7d94f878978b4500 | [
"MIT"
] | null | null | null | #ifndef FSW_CONTROL_MATRICESANDVECTORS_H
#define FSW_CONTROL_MATRICESANDVECTORS_H
#include <Eigen/Dense>
using Eigen::Matrix;
// Structures
// struct Mat3x3{
// double M[3][3];
// };
// struct Mat4x4{
// double M[4][4];
// };
// struct Vec4{
// double v[4];
// };
// struct Vec3{
// double v[3];
// bool operator==(const Vec3& rhs) const
// {
// return (v[0] == rhs.v[0])
// && (v[1] == rhs.v[1])
// && (v[2] == rhs.v[2]);
// }
// bool operator!=(const Vec3 rhs) const
// {
// return !operator==(rhs);
// }
// };
//Functions
/* Create a 3x3 diagonal matrix from a 3x1 vector */
// Mat3x3 Diag3(double vec[3]);
// Multiply 3x3 matrices: M_out = M1*M2
// Mat3x3 MultiplyMat3x3(Mat3x3 M1, Mat3x3 M2);
// Sum 3x3 matrices: M_out = M1 + M2
// Mat3x3 AddMat3x3(Mat3x3 M1, Mat3x3 M2);
// // Subtract 3x3 matrices: M_out = M1 - M2
// Mat3x3 SubtractMat3x3(Mat3x3 M1, Mat3x3 M2);
// // Transpose 3x3 matrix: M_out = M_in'
// Mat3x3 TransposeMat3x3(Mat3x3 M_in);
// Calculate Skew symmetric matrix from vector
// Mat3x3 skew(Vec3 V);
// Inverse operation for Skew symmetric matrices
Matrix<float, 3, 1> invSkew(Matrix<float, 3, 3> Mat);
//Cross product between two vectors
// Vec3 cross(Vec3 V1, Vec3 V2);
// //Calculate the p-norm of a 3x1 vector
// double p_normVec3(Vec3 V, int p);
// //Normalize a vector into unit norm
Matrix<float, 3, 1> normalizeVec3(Matrix<float, 3, 1> V);
// //Inner product between two matrices
// double innerProd(Vec3 V1, Vec3 V2);
// Print 3x3 matrices for debugging
// void PrintMat3x3(Mat3x3 Mat);
/* Print 4x4 matrices for debugging*/
void PrintMat4x4(Matrix<float, 4, 4> Mat);
/* Print 3x1 vectors for debugging*/
void PrintVec3(Matrix<float, 3, 1> V, char const *Text);
/* Print 4x1 vectors for debugging*/
void PrintVec4(Matrix<float, 4, 1> V, char const *Text);
// Multiply 3x3 matrix by a 3x1 vectos: V_out = M*V
// Vec3 MultiplyMat3x3Vec3(Mat3x3 Mat, Vec3 V);
// Scale 3x1 vector: V_out = c.V_in, where c is a constant
// Vec3 ScaleVec3(Vec3 V_in, float c);
// Add 3x1 vectors: V_out = V1 + V2
// Vec3 Add3x1Vec(Vec3 V1, Vec3 V2);
// // Subtract 3x1 vectors: V_out = V1 - V2
// Vec3 Subtract3x1Vec(Vec3 V1, Vec3 V2);
// // Multiply 4x4 matrix by a 4x1 vector: V_out = M*V
// Vec4 MultiplyMat4x4Vec4(Mat4x4 Mat, Vec4 V);
// //Concatenate three vectors into a 3x3 matrix
// // Mat3x3 Concatenate3Vec3_2_Mat3x3(Vec3 V1, Vec3 V2, Vec3 V3);
// //Verify if any of the terms in a Vec3 is NaN
int isNanVec3(Matrix<float, 3, 1> V);
////////////////////////////////////////////////////////////////////////////////////////////////////
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
| 26.485981 | 101 | 0.59139 | [
"vector"
] |
a65baa6f2c77f28d82b0635893b44e4124313e29 | 30,818 | h | C | sumi-mpi/mpi_api.h | calewis/sst-macro | 067a2cb9f1606b652396b5dda6093096e5bcf2d7 | [
"BSD-Source-Code"
] | 1 | 2020-04-20T08:23:30.000Z | 2020-04-20T08:23:30.000Z | sumi-mpi/mpi_api.h | calewis/sst-macro | 067a2cb9f1606b652396b5dda6093096e5bcf2d7 | [
"BSD-Source-Code"
] | 6 | 2020-04-20T08:22:20.000Z | 2020-05-15T09:39:59.000Z | sumi-mpi/mpi_api.h | calewis/sst-macro | 067a2cb9f1606b652396b5dda6093096e5bcf2d7 | [
"BSD-Source-Code"
] | null | null | null | /**
Copyright 2009-2020 National Technology and Engineering Solutions of Sandia,
LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government
retains certain rights in this software.
Sandia National Laboratories is a multimission laboratory managed and operated
by National Technology and Engineering Solutions of Sandia, LLC., a wholly
owned subsidiary of Honeywell International, Inc., for the U.S. Department of
Energy's National Nuclear Security Administration under contract DE-NA0003525.
Copyright (c) 2009-2020, NTESS
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Questions? Contact sst-macro-help@sandia.gov
*/
#ifndef SSTMAC_SOFTWARE_LIBRARIES_MPI_MPIAPI_H_INCLUDED
#define SSTMAC_SOFTWARE_LIBRARIES_MPI_MPIAPI_H_INCLUDED
#include <sstmac/software/libraries/library.h>
#include <sstmac/software/api/api.h>
#include <sstmac/common/stats/ftq_tag.h>
#include <sumi/message_fwd.h>
#include <sumi-mpi/mpi_types.h>
#include <sumi-mpi/mpi_integers.h>
#include <sumi-mpi/mpi_comm/mpi_comm.h>
#include <sumi-mpi/mpi_types/mpi_type_fwd.h>
#include <sumi-mpi/mpi_request.h>
#include <sumi-mpi/mpi_status.h>
#include <sumi-mpi/mpi_call.h>
#include <sumi-mpi/mpi_comm/mpi_comm_factory.h>
#include <sumi-mpi/mpi_debug.h>
#include <sumi-mpi/mpi_queue/mpi_queue_fwd.h>
#include <sumi-mpi/mpi_delay_stats.h>
#include <sstmac/software/process/software_id.h>
#include <sstmac/software/process/backtrace.h>
#include <sstmac/software/process/operating_system_fwd.h>
#include <sstmac/common/stats/stat_spyplot_fwd.h>
#include <sprockit/sim_parameters_fwd.h>
#include <unordered_map>
#include <sprockit/factory.h>
#include <sumi/sim_transport.h>
#include <sumi-mpi/otf2_output_stat_fwd.h>
namespace sumi {
class MpiApi : public sumi::SimTransport
{
friend class OTF2Writer;
public:
SST_ELI_REGISTER_DERIVED(
API,
MpiApi,
"macro",
"mpi",
SST_ELI_ELEMENT_VERSION(1,0,0),
"provides the MPI transport API")
MpiApi(SST::Params& params, sstmac::sw::App* app, SST::Component* comp);
static void deleteStatics();
public:
~MpiApi() override;
MpiQueue* queue() {
return queue_;
}
/**
* @brief crossed_comm_world_barrier
* Useful for statistics based on globally synchronous timings.
* @return Whether a global collective has been crossed
*
*/
bool crossedCommWorldBarrier() const {
return crossed_comm_world_barrier_;
}
MpiComm* commWorld() const {
return worldcomm_;
}
MpiComm* commSelf() const {
return selfcomm_;
}
int commGetAttr(MPI_Comm, int comm_keyval, void* attribute_val, int* flag);
int commRank(MPI_Comm comm, int* rank);
int commSize(MPI_Comm comm, int* size);
int typeSize(MPI_Datatype type, int* size);
int initialized(int* flag){
*flag = (status_ == is_initialized);
return MPI_SUCCESS;
}
int finalized(int* flag){
*flag = (status_ == is_finalized);
return MPI_SUCCESS;
}
int bufferAttach(void* /*buffer*/, int /*size*/){
return MPI_SUCCESS;
}
int bufferDetach(void* /*buffer*/, int* /*size*/){
return MPI_SUCCESS;
}
int initThread(int* argc, char*** argv, int required, int* provided){
init(argc, argv);
*provided = required;
return MPI_SUCCESS;
}
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
int init(int* argc, char*** argv);
int finalize();
double wtime();
void setGenerateIds(bool flag){
generate_ids_ = flag;
}
bool generateIds() const {
return generate_ids_;
}
int abort(MPI_Comm comm, int errcode);
int errhandlerSet(MPI_Comm /*comm*/, MPI_Errhandler /*handler*/){
return MPI_SUCCESS;
}
int errhandlerCreate(MPI_Handler_function * /*function*/, MPI_Errhandler * /*errhandler*/){
return MPI_SUCCESS;
}
int errorClass(int /*errorcode*/, int* errorclass){
*errorclass = 0;
return MPI_SUCCESS;
}
int errorString(int errorcode, char* str, int* resultlen);
int commSplit(MPI_Comm incomm, int color, int key, MPI_Comm* outcomm);
int commDup(MPI_Comm input, MPI_Comm* output);
int commCreate(MPI_Comm input, MPI_Group group, MPI_Comm* output);
int commGroup(MPI_Comm comm, MPI_Group* grp);
int commCreateGroup(MPI_Comm comm, MPI_Group group, int tag, MPI_Comm * newcomm);
void commCreateWithId(MPI_Comm input, MPI_Group group, MPI_Comm new_comm);
/**
* @param group
* @param num_members
* @param members
* @return Whether the current rank is in the group
*/
bool groupCreateWithId(MPI_Group group, int num_members, const int* members);
int cartCreate(MPI_Comm comm_old, int ndims, const int dims[],
const int periods[], int reorder, MPI_Comm *comm_cart);
int cartGet(MPI_Comm comm, int maxdims, int dims[], int periods[], int coords[]);
int cartdimGet(MPI_Comm comm, int *ndims);
int cartRank(MPI_Comm comm, const int coords[], int *rank);
int cartShift(MPI_Comm comm, int direction, int disp,
int *rank_source, int *rank_dest);
int cartCoords(MPI_Comm comm, int rank, int maxdims, int coords[]);
int commFree(MPI_Comm* input);
int commSetErrhandler(MPI_Comm /*comm*/, MPI_Errhandler /*errhandler*/){
return MPI_SUCCESS;
}
int groupIncl(MPI_Group oldgrp,
int num_ranks,
const int* ranks,
MPI_Group* newgrp);
int groupRangeIncl(MPI_Group oldgrp, int n, int ranges[][3], MPI_Group* newgrp);
int groupFree(MPI_Group* grp);
int groupTranslateRanks(MPI_Group grp1, int n, const int* ranks1, MPI_Group grp2, int* ranks2);
int sendrecv(const void* sendbuf, int sendcount,
MPI_Datatype sendtype, int dest, int sendtag,
void* recvbuf, int recvcount,
MPI_Datatype recvtype, int source, int recvtag,
MPI_Comm comm, MPI_Status* status);
int send(const void *buf, int count,
MPI_Datatype datatype, int dest, int tag,
MPI_Comm comm);
int sendInit(const void *buf, int count, MPI_Datatype datatype, int dest,
int tag, MPI_Comm comm, MPI_Request *request);
int isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
MPI_Comm comm, MPI_Request *request);
int recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
MPI_Comm comm, MPI_Status *status);
int irecv(void *buf, int count, MPI_Datatype datatype, int source,
int tag, MPI_Comm comm, MPI_Request *request);
int recvInit(void *buf, int count, MPI_Datatype datatype,
int source, int tag, MPI_Comm comm, MPI_Request *request);
int request_free(MPI_Request* req);
int start(MPI_Request* req);
int startall(int count, MPI_Request* req);
int wait(MPI_Request *request, MPI_Status *status);
int waitall(int count, MPI_Request requests[], MPI_Status statuses[]);
int waitany(int count, MPI_Request requests[], int *indx, MPI_Status *status);
int waitsome(int incount, MPI_Request requests[],
int *outcount, int indices[], MPI_Status statuses[]);
int test(MPI_Request *request, int *flag, MPI_Status *status);
int testall(int count, MPI_Request requests[], int *flag, MPI_Status statuses[]);
int testany(int count, MPI_Request requests[], int *indx, int *flag, MPI_Status *status);
int testsome(int incount, MPI_Request requests[], int *outcount,
int indices[], MPI_Status statuses[]);
int probe(int source, int tag, MPI_Comm comm, MPI_Status *status);
int iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status *status);
int barrier(MPI_Comm comm);
int bcast(int count, MPI_Datatype datatype, int root, MPI_Comm comm);
int bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
int scatter(int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype, int root,
MPI_Comm comm);
int scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
MPI_Comm comm);
int scatterv(const int *sendcounts,
MPI_Datatype sendtype, int recvcount,
MPI_Datatype recvtype,
int root, MPI_Comm comm);
int scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
MPI_Datatype sendtype, void *recvbuf, int recvcount,
MPI_Datatype recvtype,
int root, MPI_Comm comm);
int gather(int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm);
int gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm);
int gatherv(int sendcount, MPI_Datatype sendtype,
const int *recvcounts,
MPI_Datatype recvtype, int root, MPI_Comm comm);
int gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int *recvcounts, const int *displs,
MPI_Datatype recvtype, int root, MPI_Comm comm);
int allgather(int count, MPI_Datatype type, MPI_Comm comm);
int allgather(int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype,
MPI_Comm comm);
int allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
MPI_Comm comm);
int allgatherv(int sendcount, MPI_Datatype sendtype,
const int *recvcounts,
MPI_Datatype recvtype, MPI_Comm comm);
int allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int *recvcounts, const int *displs,
MPI_Datatype recvtype, MPI_Comm comm);
int alltoall(int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype,
MPI_Comm comm);
int alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
MPI_Comm comm);
int alltoallv(const int *sendcounts,
MPI_Datatype sendtype,
const int *recvcounts,
MPI_Datatype recvtype,
MPI_Comm comm);
int alltoallv(const void *sendbuf, const int *sendcounts,
const int *sdispls, MPI_Datatype sendtype, void *recvbuf,
const int *recvcounts, const int *rdispls, MPI_Datatype recvtype,
MPI_Comm comm);
int reduce(int count, MPI_Datatype type, MPI_Op op, int root, MPI_Comm comm);
int reduce(const void* src, void* dst,
int count, MPI_Datatype type, MPI_Op op, int root,
MPI_Comm comm);
int allreduce(int count, MPI_Datatype type, MPI_Op op,
MPI_Comm comm);
int allreduce(const void* src, void* dst,
int count, MPI_Datatype type, MPI_Op op,
MPI_Comm comm);
int scan(int count, MPI_Datatype type, MPI_Op op,
MPI_Comm comm);
int scan(const void* src, void* dst,
int count, MPI_Datatype type, MPI_Op op,
MPI_Comm comm);
int reduceScatter(int* recvcnts, MPI_Datatype type,
MPI_Op op, MPI_Comm comm);
int reduceScatter(const void* src, void* dst,
const int* recvcnts, MPI_Datatype type,
MPI_Op op, MPI_Comm comm);
int reduceScatterBlock(int recvcnt, MPI_Datatype type,
MPI_Op op, MPI_Comm comm);
int reduceScatterBlock(const void* src, void* dst,
int recvcnt, MPI_Datatype type,
MPI_Op op, MPI_Comm comm);
int ibarrier(MPI_Comm comm, MPI_Request* req);
int ibcast(int count, MPI_Datatype datatype, int root,
MPI_Comm comm, MPI_Request* req);
int ibcast(void *buffer, int count, MPI_Datatype datatype, int root,
MPI_Comm comm, MPI_Request* req);
int iscatter(int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype, int root,
MPI_Comm comm, MPI_Request* req);
int iscatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
MPI_Comm comm, MPI_Request* req);
int iscatterv(const int *sendcounts,
MPI_Datatype sendtype, int recvcount,
MPI_Datatype recvtype,
int root, MPI_Comm comm, MPI_Request* req);
int iscatterv(const void *sendbuf, const int *sendcounts, const int *displs,
MPI_Datatype sendtype, void *recvbuf, int recvcount,
MPI_Datatype recvtype,
int root, MPI_Comm comm, MPI_Request* req);
int igather(int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm, MPI_Request* req);
int igather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm, MPI_Request* req);
int igatherv(int sendcount, MPI_Datatype sendtype,
const int *recvcounts,
MPI_Datatype recvtype, int root,
MPI_Comm comm, MPI_Request* req);
int igatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int *recvcounts, const int *displs,
MPI_Datatype recvtype, int root,
MPI_Comm comm, MPI_Request* req);
int iallgather(int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype,
MPI_Comm comm, MPI_Request* req);
int iallgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
MPI_Comm comm, MPI_Request* req);
int iallgatherv(int sendcount, MPI_Datatype sendtype,
const int *recvcounts,
MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* req);
int iallgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int *recvcounts, const int *displs,
MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* req);
int ialltoall(int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype,
MPI_Comm comm, MPI_Request* req);
int ialltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
MPI_Comm comm, MPI_Request* req);
int ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispls[],
const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[],
const int rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm,
MPI_Request *request);
int ialltoallv(const int *sendcounts, MPI_Datatype sendtype,
const int *recvcounts, MPI_Datatype recvtype,
MPI_Comm comm, MPI_Request* req);
int ialltoallv(const void *sendbuf, const int *sendcounts,
const int *sdispls, MPI_Datatype sendtype, void *recvbuf,
const int *recvcounts, const int *rdispls, MPI_Datatype recvtype,
MPI_Comm comm, MPI_Request* req);
int ireduce(int count, MPI_Datatype type, MPI_Op op, int root,
MPI_Comm comm, MPI_Request* req);
int ireduce(const void* src, void* dst,
int count, MPI_Datatype type, MPI_Op op, int root,
MPI_Comm comm, MPI_Request* req);
int iallreduce(int count, MPI_Datatype type, MPI_Op op,
MPI_Comm comm, MPI_Request* req);
int iallreduce(const void* src, void* dst,
int count, MPI_Datatype type, MPI_Op op,
MPI_Comm comm, MPI_Request* req);
int iscan(int count, MPI_Datatype type, MPI_Op op,
MPI_Comm comm, MPI_Request* req);
int iscan(const void* src, void* dst,
int count, MPI_Datatype type, MPI_Op op,
MPI_Comm comm, MPI_Request* req);
int ireduceScatter(int* recvcnts, MPI_Datatype type,
MPI_Op op, MPI_Comm comm, MPI_Request* req);
int ireduceScatter(const void* src, void* dst,
const int* recvcnts, MPI_Datatype type,
MPI_Op op, MPI_Comm comm, MPI_Request* req);
int ireduceScatterBlock(int recvcnt, MPI_Datatype type,
MPI_Op op, MPI_Comm comm, MPI_Request* req);
int ireduceScatterBlock(const void* src, void* dst,
int recvcnt, MPI_Datatype type,
MPI_Op op, MPI_Comm comm, MPI_Request* req);
int typeGetName(MPI_Datatype type, char* type_name, int* resultlen);
int typeSetName(MPI_Datatype type, const char* type_name);
int typeExtent(MPI_Datatype type, MPI_Aint* extent);
int packSize(int incount, MPI_Datatype datatype,
MPI_Comm comm, int *size);
int winFlush(int rank, MPI_Win win);
int winFlushLocal(int rank, MPI_Win win);
int winCreate(void *base, MPI_Aint size, int disp_unit, MPI_Info info,
MPI_Comm comm, MPI_Win *win);
int winFree(MPI_Win *win);
int winLock(int lock_type, int rank, int assert, MPI_Win win);
int winUnlock(int rank, MPI_Win win);
int get(void *origin_addr, int origin_count, MPI_Datatype
origin_datatype, int target_rank, MPI_Aint target_disp,
int target_count, MPI_Datatype target_datatype, MPI_Win win);
int put(const void *origin_addr, int origin_count, MPI_Datatype
origin_datatype, int target_rank, MPI_Aint target_disp,
int target_count, MPI_Datatype target_datatype, MPI_Win win);
public:
int opCreate(MPI_User_function* user_fn, int commute, MPI_Op* op);
int opFree(MPI_Op* op);
int getCount(const MPI_Status* status, MPI_Datatype datatype, int* count);
int typeDup(MPI_Datatype intype, MPI_Datatype* outtype);
int typeSetName(MPI_Datatype id, const std::string &name);
int typeIndexed(int count, const int _blocklens_[],
const int* _indices_,
MPI_Datatype intype, MPI_Datatype* outtype);
int typeHindexed(int count, const int _blocklens_[],
const MPI_Aint* _indices_,
MPI_Datatype intype, MPI_Datatype* outtype);
int typeContiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type);
int typeVector(int count, int blocklength, int stride,
MPI_Datatype old_type,
MPI_Datatype* new_type);
int typeHvector(int count, int blocklength, MPI_Aint stride,
MPI_Datatype old_type,
MPI_Datatype* new_type);
int typeCreateStruct(const int count, const int* blocklens,
const MPI_Aint* displs,
const MPI_Datatype* old_types,
MPI_Datatype* newtype);
int typeCreateStruct(const int count, const int* blocklens,
const int* displs,
const MPI_Datatype* old_types,
MPI_Datatype* newtype);
int typeCommit(MPI_Datatype* type);
int typeFree(MPI_Datatype* type);
MpiType* typeFromId(MPI_Datatype id);
void allocateTypeId(MpiType* type);
std::string commStr(MpiComm* comm);
std::string commStr(MPI_Comm comm);
std::string tagStr(int tag);
std::string srcStr(int id);
std::string srcStr(MpiComm* comm, int id);
std::string typeStr(MPI_Datatype mid);
const char* opStr(MPI_Op op);
MpiComm* getComm(MPI_Comm comm);
MpiGroup* getGroup(MPI_Group grp);
MpiRequest* getRequest(MPI_Request req);
void addCommPtr(MpiComm* ptr, MPI_Comm* comm);
void eraseCommPtr(MPI_Comm comm);
void addGroupPtr(MpiGroup* ptr, MPI_Group* grp);
void addGroupPtr(MPI_Group grp, MpiGroup* ptr);
void eraseGroupPtr(MPI_Group grp);
void addRequestPtr(MpiRequest* ptr, MPI_Request* req);
void eraseRequestPtr(MPI_Request req);
void checkKey(int key);
void addKeyval(int key, keyval* keyval);
keyval *getKeyval(int key);
void finishCollective(CollectiveOpBase* op);
private:
int doWait(MPI_Request *request, MPI_Status *status, int& tag, int& source);
void finalizeWaitRequest(MpiRequest* reqPtr, MPI_Request* request, MPI_Status* status);
int doTypeHvector(int count, int blocklength, MPI_Aint stride,
MpiType* old_type,
MPI_Datatype* new_type);
int doTypeHindexed(int count, const int _blocklens_[],
const MPI_Aint* _indices_,
MpiType* old_type, MPI_Datatype* outtype);
void startMpiCollective(
Collective::type_t ty,
const void* sendbuf, void* recvbuf,
MPI_Datatype sendtype, MPI_Datatype recvtype,
CollectiveOpBase* op);
void* allocateTempPackBuffer(int count, MpiType* type);
void freeTempPackBuffer(void* srcbuf);
/**
* @brief waitCollective The function takes ownership of the op.
* This should only be called with a single pending collective.
* If there are multiple pending collectives,
* this can lead to an error condition
* @param op Moved collective operation
*/
void waitCollective(CollectiveOpBase::ptr&& op);
void waitCollectives(std::vector<CollectiveOpBase::ptr>&& op);
void freeRequests(int nreqs, MPI_Request* reqs, int* inds);
void commitBuiltinTypes();
void commitBuiltinType(MpiType* type, MPI_Datatype id);
std::string typeLabel(MPI_Datatype tid);
sumi::CollectiveDoneMessage* startAllgather(CollectiveOp* op);
sumi::CollectiveDoneMessage* startAlltoall(CollectiveOp* op);
sumi::CollectiveDoneMessage* startAllreduce(CollectiveOp* op);
sumi::CollectiveDoneMessage* startBarrier(CollectiveOp* op);
sumi::CollectiveDoneMessage* startBcast(CollectiveOp* op);
sumi::CollectiveDoneMessage* startGather(CollectiveOp* op);
sumi::CollectiveDoneMessage* startReduce(CollectiveOp* op);
sumi::CollectiveDoneMessage* startReduceScatter(CollectiveOp* op);
sumi::CollectiveDoneMessage* startReduceScatterBlock(CollectiveOp* op);
sumi::CollectiveDoneMessage* startScan(CollectiveOp* op);
sumi::CollectiveDoneMessage* startScatter(CollectiveOp* op);
sumi::CollectiveDoneMessage* startAllgatherv(CollectivevOp* op);
sumi::CollectiveDoneMessage* startAlltoallv(CollectivevOp* op);
sumi::CollectiveDoneMessage* startGatherv(CollectivevOp* op);
sumi::CollectiveDoneMessage* startScatterv(CollectivevOp* op);
void finishCollectiveOp(CollectiveOpBase* op_);
void finishVcollectiveOp(CollectiveOpBase* op_);
/* Collective operations */
CollectiveOpBase::ptr startBarrier(const char* name, MPI_Comm comm);
CollectiveOpBase::ptr startBcast(const char* name, MPI_Comm comm, int count, MPI_Datatype datatype,
int root, void *buffer);
CollectiveOpBase::ptr
startScatter(const char* name, MPI_Comm comm, int sendcount, MPI_Datatype sendtype, int root,
int recvcount, MPI_Datatype recvtype, const void *sendbuf, void *recvbuf);
CollectiveOpBase::ptr
startScatterv(const char* name, MPI_Comm comm, const int *sendcounts, MPI_Datatype sendtype, int root,
const int *displs, int recvcount, MPI_Datatype recvtype, const void *sendbuf, void *recvbuf);
CollectiveOpBase::ptr
startGather(const char* name, MPI_Comm comm, int sendcount, MPI_Datatype sendtype, int root,
int recvcount, MPI_Datatype recvtype, const void *sendbuf, void *recvbuf);
CollectiveOpBase::ptr
startGatherv(const char* name, MPI_Comm comm, int sendcount, MPI_Datatype sendtype, int root,
const int *recvcounts, const int *displs, MPI_Datatype recvtype,
const void *sendbuf, void *recvbuf);
CollectiveOpBase::ptr
startAllgather(const char* name, MPI_Comm comm, int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype, const void *sendbuf, void *recvbuf);
CollectiveOpBase::ptr
startAllgatherv(const char* name, MPI_Comm comm, int sendcount, MPI_Datatype sendtype,
const int *recvcounts, const int *displs, MPI_Datatype recvtype,
const void *sendbuf, void *recvbuf);
CollectiveOpBase::ptr
startAlltoall(const char* name, MPI_Comm comm, int sendcount, MPI_Datatype sendtype,
int recvcount, MPI_Datatype recvtype, const void *sendbuf, void *recvbuf);
CollectiveOpBase::ptr
startAlltoallv(const char* name, MPI_Comm comm, const int *sendcounts, MPI_Datatype sendtype, const int *sdispls,
const int *recvcounts, MPI_Datatype recvtype, const int *rdispls,
const void *sendbuf, void *recvbuf);
CollectiveOpBase::ptr
startReduce(const char* name, MPI_Comm comm, int count, MPI_Datatype type, int root,
MPI_Op op, const void* src, void* dst);
CollectiveOpBase::ptr
startAllreduce(const char* name, MPI_Comm comm, int count, MPI_Datatype type,
MPI_Op op, const void* src, void* dst);
CollectiveOpBase::ptr
startAllreduce(MpiComm* commPtr, int count, MPI_Datatype type,
MPI_Op op, const void* src, void* dst);
CollectiveOpBase::ptr
startReduceScatter(const char* name, MPI_Comm comm, const int* recvcounts, MPI_Datatype type,
MPI_Op op, const void* src, void* dst);
CollectiveOpBase::ptr
startReduceScatterBlock(const char* name, MPI_Comm comm, int count, MPI_Datatype type,
MPI_Op op, const void* src, void* dst);
CollectiveOpBase::ptr
startScan(const char* name, MPI_Comm comm, int count, MPI_Datatype type,
MPI_Op op, const void* src, void* dst);
void doStart(MPI_Request req);
MpiRequest* addImmediateCollective(CollectiveOpBase::ptr&& op);
void addImmediateCollective(CollectiveOpBase::ptr&& op, MPI_Request* req);
void finishCurrentMpiCall();
void setNewMpiCall(MPI_function func){
current_call_.ID = func;
current_call_.start = last_collection_ = now();
//update this to at least the beginning of this function
}
bool test(MPI_Request *request, MPI_Status *status, int& tag, int& source);
int typeSize(MPI_Datatype type){
int ret;
typeSize(type, &ret);
return ret;
}
reduce_fxn getCollectiveFunction(CollectiveOpBase* op);
void checkInit();
MpiRequest* doIsend(const void *buf, int count, MPI_Datatype datatype, int dest,
int tag, MPI_Comm comm);
int doRecv(void *buf, int count, MPI_Datatype datatype, int source,
int tag, MPI_Comm comm, MPI_Status* status);
int doIsend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
MPI_Comm comm, MPI_Request *request, bool print);
private:
friend class MpiCommFactory;
MpiQueue* queue_;
MPI_Datatype next_type_id_;
static const MPI_Op first_custom_op_id = 1000;
MPI_Op next_op_id_;
static sstmac::FTQTag mpi_tag;
MpiCommFactory comm_factory_;
int iprobe_delay_us_;
int test_delay_us_;
enum {
is_fresh, is_initialized, is_finalizing, is_finalized
} status_;
bool crossed_comm_world_barrier_;
MpiComm* worldcomm_;
MpiComm* selfcomm_;
std::map<MPI_Datatype, MpiType*> known_types_;
std::map<MPI_Datatype, MpiType::ptr> allocatedTypes_;
typedef std::unordered_map<MPI_Op, MPI_User_function*> op_map;
op_map custom_ops_;
typedef std::unordered_map<MPI_Comm, MpiComm*> comm_ptr_map;
comm_ptr_map comm_map_;
typedef std::unordered_map<MPI_Group, MpiGroup*> group_ptr_map;
group_ptr_map grp_map_;
MPI_Group group_counter_;
typedef std::unordered_map<MPI_Request, MpiRequest*> req_ptr_map;
req_ptr_map req_map_;
MPI_Request req_counter_;
SST::Statistics::MultiStatistic<int, //sender
int, //recver
int, //type
int, //stage
uint64_t, //byte length
uint64_t, //flow ID
double, //send sync delay
double, //recv sync delay
double, //injection delay
double, //contention delay
double, //min delay in absence of contention
double, //active sync delay experienced by app
double, //active delay experienced by app
double, //time since last quiescence
double //global clock time
>* delays_;
std::unordered_map<int, keyval*> keyvals_;
bool generate_ids_;
uint64_t traceClock() const;
#ifdef SSTMAC_OTF2_ENABLED
OTF2Writer* OTF2Writer_;
#endif
public:
void logMessageDelay(Message *msg, uint64_t bytes, int stage,
sstmac::TimeDelta sync_delay, sstmac::TimeDelta active_delay,
sstmac::TimeDelta time_since_quiesce) override;
private:
MPI_Call current_call_;
};
MpiApi* sstmac_mpi();
}
#define _StartMPICall_(fxn) \
CallGraphAppend(fxn); \
sstmac::sw::FTQScope scope(activeThread(), mpi_tag); \
startAPICall()
#define StartMPICall(fxn) \
_StartMPICall_(fxn); \
setNewMpiCall(Call_ID_##fxn)
#define FinishMPICall(fxn) \
mpi_api_debug(sprockit::dbg::mpi, #fxn " finished"); \
finishCurrentMpiCall(); \
endAPICall()
#define mpi_api_debug(flags, ...) \
mpi_debug(commWorld()->rank(), flags, __VA_ARGS__)
#define mpi_api_cond_debug(flags, cond, ...) \
mpi_cond_debug(commWorld()->rank(), flags, cond, __VA_ARGS__)
#endif
| 33.425163 | 115 | 0.691576 | [
"vector"
] |
a677257c23912f4909ef3c8b67af822d942e4e14 | 893 | h | C | inst/include/sourcetools/parse/ParseStatus.h | kevinushey/sourcetools | 15263b7dcad552b007d1a1f2367c2482872faece | [
"MIT"
] | 72 | 2016-02-12T16:56:14.000Z | 2022-03-11T14:08:25.000Z | inst/include/sourcetools/parse/ParseStatus.h | kevinushey/parsr | 15263b7dcad552b007d1a1f2367c2482872faece | [
"MIT"
] | 21 | 2016-02-05T02:21:45.000Z | 2021-07-06T23:29:29.000Z | inst/include/sourcetools/parse/ParseStatus.h | kevinushey/parsr | 15263b7dcad552b007d1a1f2367c2482872faece | [
"MIT"
] | 7 | 2016-02-12T16:56:17.000Z | 2018-11-08T18:06:05.000Z | #ifndef SOURCETOOLS_PARSE_PARSE_STATUS_H
#define SOURCETOOLS_PARSE_PARSE_STATUS_H
#include <sourcetools/collection/Position.h>
#include <sourcetools/parse/ParseError.h>
namespace sourcetools {
namespace parser {
class ParseNode;
class ParseStatus
{
typedef collections::Position Position;
public:
ParseStatus() {}
void recordNodeLocation(const Position& position,
ParseNode* pNode)
{
map_[position] = pNode;
}
ParseNode* getNodeAtPosition(const Position& position)
{
return map_[position];
}
void addError(const ParseError& error)
{
errors_.push_back(error);
}
const std::vector<ParseError>& getErrors() const
{
return errors_;
}
private:
std::map<Position, ParseNode*> map_;
std::vector<ParseError> errors_;
};
} // namespace parser
} // namespace sourcetools
#endif /* SOURCETOOLS_PARSE_PARSE_STATUS_H */
| 18.22449 | 56 | 0.714446 | [
"vector"
] |
a67a27e8c3e28fff4ee4a9efd943558e0a0d8f01 | 6,736 | c | C | rtdb/kogmo_rtdb_housekeeping.c | mischumok/kogmo-rtdb | c64eabb4f78ebd15186301576c4ea07157f3ce5d | [
"Apache-2.0"
] | 1 | 2021-04-09T08:55:07.000Z | 2021-04-09T08:55:07.000Z | rtdb/kogmo_rtdb_housekeeping.c | mischumok/kogmo-rtdb | c64eabb4f78ebd15186301576c4ea07157f3ce5d | [
"Apache-2.0"
] | null | null | null | rtdb/kogmo_rtdb_housekeeping.c | mischumok/kogmo-rtdb | c64eabb4f78ebd15186301576c4ea07157f3ce5d | [
"Apache-2.0"
] | null | null | null | /* KogMo-RTDB: Real-time Database for Cognitive Automobiles
* Copyright (c) 2003-2007 Matthias Goebl <matthias.goebl*goebl.net>
* Lehrstuhl fuer Realzeit-Computersysteme (RCS)
* Technische Universitaet Muenchen (TUM)
* Licensed under the Apache License Version 2.0.
*/
/*! \file kogmo_rtdb_housekeeping.c
* \brief Housekeeping Functions for the RTDB (used by manager process)
*
* Copyright (c) 2003-2006 Matthias Goebl <matthias.goebl*goebl.net>
* Lehrstuhl fuer Realzeit-Computersysteme (RCS)
* Technische Universitaet Muenchen (TUM)
*/
#include "kogmo_rtdb_internal.h"
int
kogmo_rtdb_objmeta_purge_objs (kogmo_rtdb_handle_t *db_h)
{
int i;
kogmo_rtdb_obj_info_t *scan_objmeta_p;
kogmo_rtdb_objid_t scan_oid;
kogmo_timestamp_t ts,scan_delete_ts;
int purge_keep_alloc = 0;
int percent_free;
CHK_DBH("kogmo_rtdb_objmeta_purge",db_h,0);
percent_free = (float)db_h->localdata_p -> heap_free * 100 /
db_h->localdata_p -> heap_size;
#ifndef KOGMO_RTDB_HARDREALTIME
if ( percent_free < KOGMO_RTDB_PURGE_KEEPALLOC_PERCFREE )
{
DBG("purging preallocated memory, because only %i%% (<%i%%) is free",
percent_free, KOGMO_RTDB_PURGE_KEEPALLOC_PERCFREE);
purge_keep_alloc = 1;
}
#endif
ts = kogmo_rtdb_timestamp_now(db_h);
kogmo_rtdb_objmeta_lock(db_h);
for(i=0;i<KOGMO_RTDB_OBJ_MAX;i++)
{
scan_objmeta_p = &db_h->localdata_p -> objmeta[i];
scan_oid = scan_objmeta_p->oid;
scan_delete_ts = scan_objmeta_p -> deleted_ts;
if (scan_oid && scan_delete_ts)
{
scan_delete_ts = kogmo_timestamp_add_secs(
scan_delete_ts,
scan_objmeta_p -> history_interval > db_h->localdata_p->default_keep_deleted_interval ?
scan_objmeta_p -> history_interval : db_h->localdata_p->default_keep_deleted_interval);
if ( scan_delete_ts < ts )
{
if ( scan_objmeta_p->flags.keep_alloc &&
( !purge_keep_alloc ||
kogmo_timestamp_diff_secs ( scan_delete_ts, ts ) < KOGMO_RTDB_PURGE_KEEPALLOC_MAXSECS) )
continue; // this is kept allocated and alloc-purce time is not reached or we do not purge
kogmo_rtdb_obj_purgeslot(db_h, i);
kogmo_rtdb_objmeta_unlock_notify(db_h);
// give priority inheritance protocols a point to kick in
kogmo_rtdb_objmeta_lock(db_h);
}
}
}
kogmo_rtdb_objmeta_unlock(db_h);
percent_free = (float)db_h->localdata_p -> heap_free * 100 /
db_h->localdata_p -> heap_size;
DBG("purge: %i%% free (%lli/%lli)", percent_free,
(long long int) db_h->localdata_p -> heap_free,
(long long int) db_h->localdata_p -> heap_size);
return 0;
}
int
kogmo_rtdb_objmeta_purge_procs (kogmo_rtdb_handle_t *db_h)
{
int i;
kogmo_rtdb_objid_t err;
CHK_DBH("kogmo_rtdb_objmeta_purge_procs",db_h,0);
for(i=0;i<KOGMO_RTDB_PROC_MAX;i++)
{
if(db_h->ipc_h.shm_p->proc[i].proc_oid != 0 )
{
err = kill ( db_h->ipc_h.shm_p->proc[i].pid , 0);
if ( err == -1 && errno == ESRCH )
{
kogmo_rtdb_obj_info_t used_objmeta;
kogmo_rtdb_objid_list_t objlist;
int j, immediately_delete;
kogmo_rtdb_objid_t err;
immediately_delete = db_h->ipc_h.shm_p->proc[i].flags & KOGMO_RTDB_CONNECT_FLAGS_IMMEDIATELYDELETE;
DBGL(DBGL_APP,"DEAD PROCESS: %s [OID %lli, PID %i]",
db_h->ipc_h.shm_p->proc[i].name,
(long long int)db_h->ipc_h.shm_p->proc[i].proc_oid,
db_h->ipc_h.shm_p->proc[i].pid);
err = kogmo_rtdb_obj_searchinfo_deleted (db_h, "", 0, 0,
db_h->ipc_h.shm_p->proc[i].proc_oid, 0, objlist, 0);
if (err < 0 )
{
DBGL(DBGL_APP,"search for objectlist failed: %d",err);
}
else
{
DBGL(DBGL_APP,"dead process has %i objects to%s delete",err,
immediately_delete ? " immediately":"");
for (j=0; objlist[j] != 0; j++ )
{
err = kogmo_rtdb_obj_readinfo (db_h, objlist[j], 0, &used_objmeta );
if ( err >= 0 && used_objmeta.flags.persistent )
{
DBGL(DBGL_APP,"keeping persistent object '%s'",used_objmeta.name);
continue;
}
else
{
used_objmeta.oid = objlist[j]; // enough for delete
}
kogmo_rtdb_obj_delete_imm(db_h, &used_objmeta, immediately_delete);
}
}
kogmo_rtdb_ipc_mutex_lock (&db_h->ipc_h.shm_p->proc_lock);
memset(&db_h->ipc_h.shm_p->proc[i],0,sizeof(struct kogmo_rtdb_ipc_process_t));
db_h->ipc_h.shm_p->proc_free++;
kogmo_rtdb_ipc_mutex_unlock (&db_h->ipc_h.shm_p->proc_lock);
}
}
}
return 0;
}
int
kogmo_rtdb_kill_procs (kogmo_rtdb_handle_t *db_h, int sig)
{
int i;
CHK_DBH("kogmo_rtdb_kill_procs",db_h,0);
DBGL(DBGL_APP,"killing connected processes with signal %i..", sig);
for(i=0;i<KOGMO_RTDB_PROC_MAX;i++)
{
if(db_h->ipc_h.shm_p->proc[i].proc_oid != 0 )
{
DBGL(DBGL_APP,"killing process %s [OID %lli, PID %i]",
db_h->ipc_h.shm_p->proc[i].name,
(long long int)db_h->ipc_h.shm_p->proc[i].proc_oid,
db_h->ipc_h.shm_p->proc[i].pid);
kill ( db_h->ipc_h.shm_p->proc[i].pid, sig);
}
}
return 0;
}
int
kogmo_rtdb_objmeta_upd_stats (kogmo_rtdb_handle_t *db_h)
{
kogmo_rtdb_objid_t oid;
//kogmo_rtdb_obj_info_t rtdbobj_info;
kogmo_rtdb_obj_c3_rtdb_t rtdbobj;
kogmo_rtdb_objid_t err;
CHK_DBH("kogmo_rtdb_objmeta_upd_stats",db_h,0);
oid = kogmo_rtdb_obj_searchinfo (db_h, "rtdb", KOGMO_RTDB_OBJTYPE_C3_RTDB, 0, 0, 0, NULL, 1);
if (oid<0) return oid;
//err = kogmo_rtdb_obj_readinfo (db_h, oid, 0, &rtdbobj_info);
//if (err<0) return err;
err = kogmo_rtdb_obj_readdata (db_h, oid, 0, &rtdbobj, sizeof(rtdbobj));
if (err<0) return err;
rtdbobj.base.data_ts = kogmo_timestamp_now();
rtdbobj.rtdb.objects_free=db_h->localdata_p->objmeta_free;
rtdbobj.rtdb.processes_free=db_h->ipc_h.shm_p->proc_free;
rtdbobj.rtdb.memory_free=db_h->localdata_p -> heap_free;
err = kogmo_rtdb_obj_writedata (db_h, oid, &rtdbobj);
if (err<0) return err;
return 0;
}
| 36.215054 | 113 | 0.606888 | [
"object"
] |
a67a682af7eab4340617a8bc49c905c8d29fd3d7 | 3,976 | h | C | Collisions/include/Debug/OgreBulletCollisionsDebugDrawer.h | abraha2d/ogrebullet | 36b6e7255d72b58de459b429e629f64af458a8ac | [
"MIT"
] | null | null | null | Collisions/include/Debug/OgreBulletCollisionsDebugDrawer.h | abraha2d/ogrebullet | 36b6e7255d72b58de459b429e629f64af458a8ac | [
"MIT"
] | null | null | null | Collisions/include/Debug/OgreBulletCollisionsDebugDrawer.h | abraha2d/ogrebullet | 36b6e7255d72b58de459b429e629f64af458a8ac | [
"MIT"
] | null | null | null | /***************************************************************************
This source file is part of OGREBULLET
(Object-oriented Graphics Rendering Engine Bullet Wrapper)
For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
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.
-----------------------------------------------------------------------------
*/
#ifndef _OgreBulletCollisions_DebugDrawer_H_
#define _OgreBulletCollisions_DebugDrawer_H_
#include "OgreBulletCollisionsPreRequisites.h"
#include "Debug/OgreBulletCollisionsDebugLines.h"
namespace OgreBulletCollisions
{
//------------------------------------------------------------------------------------------------
class DebugDrawer : public DebugLines, public btIDebugDraw
{
public:
DebugDrawer();
virtual ~DebugDrawer();
virtual void setDebugMode(int mode) { mDebugMode = mode; }
virtual int getDebugMode() const { return mDebugMode; }
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color);
virtual void drawContactPoint(const btVector3 &PointOnB, const btVector3 &normalOnB,
btScalar distance, int lifeTime, const btVector3 &color);
void drawAabb(const Ogre::Vector3 &from, const Ogre::Vector3 &to, const Ogre::Vector3 &color);
void drawLine(const Ogre::Vector3 &from, const Ogre::Vector3 &to, const Ogre::Vector3 &color);
void drawContactPoint(const Ogre::Vector3 &PointOnB, const Ogre::Vector3 &normalOnB,
Ogre::Real distance, int lifeTime, const Ogre::Vector3 &color);
void setDrawAabb(bool enable);
void setDrawWireframe(bool enable);
void setDrawFeaturesText(bool enable);
void setDrawContactPoints(bool enable);
void setNoDeactivation(bool enable);
void setNoHelpText(bool enable);
void setDrawText(bool enable);
void setProfileTimings(bool enable);
void setEnableSatComparison(bool enable);
void setDisableBulletLCP (bool enable);
void setEnableCCD(bool enable);
bool doesDrawAabb() const;
bool doesDrawWireframe() const;
bool doesDrawFeaturesText() const;
bool doesDrawContactPoints() const;
bool doesNoDeactivation() const;
bool doesNoHelpText() const;
bool doesDrawText() const;
bool doesProfileTimings() const;
bool doesEnableSatComparison() const;
bool doesDisableBulletLCP() const;
bool doesEnableCCD() const;
void drawAabb(const btVector3 &from, const btVector3 &to, const btVector3 &color);
// TODO
void draw3dText(const btVector3 &location, const char *textString);
void reportErrorWarning(const char *warningString);
protected:
int mDebugMode;
};
}
#endif //_OgreBulletCollisions_DebugDrawer_H_
| 41.416667 | 110 | 0.685111 | [
"object"
] |
a689becb6ef7490b8b0e398bc689c077549c0b40 | 5,404 | h | C | Asap-3.8.4/Basics/Vec.h | auag92/n2dm | 03403ef8da303b79478580ae76466e374ec9da60 | [
"MIT"
] | 1 | 2021-10-19T11:35:34.000Z | 2021-10-19T11:35:34.000Z | Asap-3.8.4/Basics/Vec.h | auag92/n2dm | 03403ef8da303b79478580ae76466e374ec9da60 | [
"MIT"
] | null | null | null | Asap-3.8.4/Basics/Vec.h | auag92/n2dm | 03403ef8da303b79478580ae76466e374ec9da60 | [
"MIT"
] | 3 | 2016-07-18T19:22:48.000Z | 2021-07-06T03:06:42.000Z | // -*- C++ -*-
// Vec.h: Vectors in three-dimensional space, i.e. three doubles.
//
// Copyright (C) 2001-2011 Jakob Schiotz and Center for Individual
// Nanoparticle Functionality, Department of Physics, Technical
// University of Denmark. Email: schiotz@fysik.dtu.dk
//
// This file is part of Asap version 3.
// Asap is released under the GNU Lesser Public License (LGPL) version 3.
// However, the parts of Asap distributed within the OpenKIM project
// (including this file) are also released under the Common Development
// and Distribution License (CDDL) version 1.0.
//
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// version 3 as published by the Free Software Foundation. Permission
// to use other versions of the GNU Lesser General Public License may
// granted by Jakob Schiotz or the head of department of the
// Department of Physics, Technical University of Denmark, as
// described in section 14 of the GNU General Public License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// and the GNU Lesser Public License along with this program. If not,
// see <http://www.gnu.org/licenses/>.
#ifndef _VEC_H
#define _VEC_H
#include "Asap.h"
#include <iostream>
using std::istream;
using std::ostream;
namespace ASAPSPACE {
/// A 3-vector useful for postions etc.
/// The only data is the three positions (and there are no virtual
/// functions), so the memory layout of an array of Vecs will be x0,
/// y0, z0, x1, y1, z1, x2, ...
///
/// Almost all operations are inline for speed.
class Vec
{
public:
/// Dummy constructor needed by STL containers.
Vec() {};
/// Construct a 3-vector from three doubles.
Vec(double x0, double x1, double x2);
/// Dot product
double operator*(const Vec& v) const;
/// Multiplication with scalar
Vec operator*(const double& s) const;
friend Vec operator*(const double &s, const Vec v);
/// Division with scalar
Vec operator/(const double& s) const;
/// Add two Vecs
Vec operator+(const Vec& v) const;
/// Subtract two Vecs
Vec operator-(const Vec& v) const;
/// Unary minus
Vec operator-() const;
/// Add a Vec to this one.
Vec& operator+=(const Vec& v);
/// Subtract a vec from this one.
Vec& operator-=(const Vec& v);
/// Multiply this vec with a scalar
Vec& operator*=(double s);
/// Divide this Vec with a scalar.
Vec& operator/=(double s);
/// Vec equality (bitwise!)
bool operator==(const Vec &v) const;
/// Vec inequality (bitwise!)
bool operator!=(const Vec &v) const;
/// const indexing
double operator[](int n) const;
/// Non-const indexing
double& operator[](int n);
/// Cross product of two Vecs.
friend Vec Cross(const Vec& v1, const Vec& v2);
/// The length of a Vec
friend double Length2(const Vec& v);
/// Increment y with a times x.
friend void Vaxpy(double a, const Vec& x, Vec& y);
/// Print a Vec
friend ostream& operator<<(ostream& out, const Vec& v);
/// Read a Vec
friend istream& operator>>(istream& in, Vec& v);
public:
double x[3]; ///< The actual data.
};
inline Vec::Vec(double x0, double x1, double x2)
{
x[0] = x0;
x[1] = x1;
x[2] = x2;
}
inline double Vec::operator*(const Vec& v) const
{
return x[0] * v.x[0] + x[1] * v.x[1] + x[2] * v.x[2];
}
inline Vec Vec::operator*(const double& s) const
{
return Vec(s * x[0], s * x[1], s * x[2]);
}
inline Vec operator*(const double &s, const Vec v)
{
return Vec(s * v.x[0], s * v.x[1], s * v.x[2]);
}
inline Vec Vec::operator/(const double& s) const
{
return Vec(x[0] / s, x[1] / s, x[2] / s);
}
inline Vec Vec::operator+(const Vec& v) const
{
return Vec(x[0] + v.x[0], x[1] + v.x[1], x[2] + v.x[2]);
}
inline Vec Vec::operator-(const Vec& v) const
{
return Vec(x[0] - v.x[0], x[1] - v.x[1], x[2] - v.x[2]);
}
inline Vec Vec::operator-() const
{
return Vec(-x[0], -x[1], -x[2]);
}
inline Vec& Vec::operator+=(const Vec& v)
{
x[0] += v.x[0]; x[1] += v.x[1]; x[2] += v.x[2];
return *this;
}
inline Vec& Vec::operator-=(const Vec& v)
{
x[0] -= v.x[0]; x[1] -= v.x[1]; x[2] -= v.x[2];
return *this;
}
inline Vec& Vec::operator*=(double s)
{
x[0] *= s; x[1] *= s; x[2] *= s;
return *this;
}
inline Vec& Vec::operator/=(double s)
{
x[0] /= s; x[1] /= s; x[2] /= s;
return *this;
}
inline bool Vec::operator==(const Vec &v) const
{
return (x[0] == v.x[0]) && (x[1] == v.x[1]) && (x[2] == v.x[2]);
}
inline bool Vec::operator!=(const Vec &v) const
{
return !(*this == v);
}
inline double Vec::operator[](int n) const
{
return x[n];
}
inline double& Vec::operator[](int n)
{
return x[n];
}
inline Vec Cross(const Vec& v1, const Vec& v2)
{
return Vec(v1.x[1] * v2.x[2] - v1.x[2] * v2.x[1],
v1.x[2] * v2.x[0] - v1.x[0] * v2.x[2],
v1.x[0] * v2.x[1] - v1.x[1] * v2.x[0]);
}
inline void Vaxpy(double a, const Vec& x, Vec& y)
{
y.x[0] += a * x.x[0];
y.x[1] += a * x.x[1];
y.x[2] += a * x.x[2];
}
inline double Length2(const Vec& v)
{
return v.x[0] * v.x[0] + v.x[1] * v.x[1] + v.x[2] * v.x[2];
}
} // end namespace
#endif // _VEC_H
| 25.980769 | 73 | 0.628793 | [
"vector"
] |
a6902108738d7116f3faaa523336d6e834cce9b3 | 2,518 | h | C | dist/linux/genometools/src/extended/match_sw_api.h | thmourikis/erv_annotator | 448b2dfc2972f9bf4e743df36fe0232813590fec | [
"MIT"
] | null | null | null | dist/linux/genometools/src/extended/match_sw_api.h | thmourikis/erv_annotator | 448b2dfc2972f9bf4e743df36fe0232813590fec | [
"MIT"
] | 1 | 2018-09-30T00:45:55.000Z | 2018-09-30T00:45:55.000Z | dist/linux/genometools/src/extended/match_sw_api.h | thmourikis/erv_annotator | 448b2dfc2972f9bf4e743df36fe0232813590fec | [
"MIT"
] | null | null | null | /*
Copyright (c) 2012 Sascha Steinbiss <steinbiss@zbh.uni-hamburg.de>
Copyright (c) 2012 Center for Bioinformatics, University of Hamburg
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef MATCH_SW_API_H
#define MATCH_SW_API_H
/* The <GtMatchSW> class, implementing the <GtMatch> interface, is meant to
store results from Smith-Waterman matching (using the <swalign> module). */
typedef struct GtMatchSW GtMatchSW;
#include "extended/match_api.h"
/* Creates a new <GtMatch> object, storing the alignment length <length>,
the edit distance <edist> and the sequence numbers in the sequence
collections in addition to the generic match contents <seqid1>, <seqid2>,
<start_seq1>, <start_seq2>, <end_seq1> and <end_seq2>. */
GtMatch* gt_match_sw_new(const char *seqid1,
const char *seqid2,
unsigned long seqno1,
unsigned long seqno2,
unsigned long length,
unsigned long edist,
unsigned long start_seq1,
unsigned long start_seq2,
unsigned long end_seq1,
unsigned long end_seq2,
GtMatchDirection dir);
/* Returns the sequence number of the match <ms> in the first sequence set. */
unsigned long gt_match_sw_get_seqno1(const GtMatchSW *ms);
/* Returns the sequence number of the match <ms> in the second sequence set. */
unsigned long gt_match_sw_get_seqno2(const GtMatchSW *ms);
/* Returns the alignment length of the match <ms>. */
unsigned long gt_match_sw_get_alignment_length(const GtMatchSW *ms);
/* Returns the edit distance of the match <ms>. */
unsigned long gt_match_sw_get_edist(const GtMatchSW *ms);
#endif
| 44.964286 | 79 | 0.682288 | [
"object"
] |
a6a1336258cb4becbeb56532c75af390449d4d0c | 7,706 | h | C | devel/include/shape_msgs/SolidPrimitive.h | hyu-nani/ydlidar_ws | 56316db999c057c4315a20ba8277826d6a043120 | [
"MIT"
] | 1 | 2021-11-08T12:24:24.000Z | 2021-11-08T12:24:24.000Z | devel/include/shape_msgs/SolidPrimitive.h | hyu-nani/ydlidar_ws | 56316db999c057c4315a20ba8277826d6a043120 | [
"MIT"
] | null | null | null | devel/include/shape_msgs/SolidPrimitive.h | hyu-nani/ydlidar_ws | 56316db999c057c4315a20ba8277826d6a043120 | [
"MIT"
] | null | null | null | // Generated by gencpp from file shape_msgs/SolidPrimitive.msg
// DO NOT EDIT!
#ifndef SHAPE_MSGS_MESSAGE_SOLIDPRIMITIVE_H
#define SHAPE_MSGS_MESSAGE_SOLIDPRIMITIVE_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
namespace shape_msgs
{
template <class ContainerAllocator>
struct SolidPrimitive_
{
typedef SolidPrimitive_<ContainerAllocator> Type;
SolidPrimitive_()
: type(0)
, dimensions() {
}
SolidPrimitive_(const ContainerAllocator& _alloc)
: type(0)
, dimensions(_alloc) {
(void)_alloc;
}
typedef uint8_t _type_type;
_type_type type;
typedef std::vector<double, typename ContainerAllocator::template rebind<double>::other > _dimensions_type;
_dimensions_type dimensions;
// reducing the odds to have name collisions with Windows.h
#if defined(_WIN32) && defined(BOX)
#undef BOX
#endif
#if defined(_WIN32) && defined(SPHERE)
#undef SPHERE
#endif
#if defined(_WIN32) && defined(CYLINDER)
#undef CYLINDER
#endif
#if defined(_WIN32) && defined(CONE)
#undef CONE
#endif
#if defined(_WIN32) && defined(BOX_X)
#undef BOX_X
#endif
#if defined(_WIN32) && defined(BOX_Y)
#undef BOX_Y
#endif
#if defined(_WIN32) && defined(BOX_Z)
#undef BOX_Z
#endif
#if defined(_WIN32) && defined(SPHERE_RADIUS)
#undef SPHERE_RADIUS
#endif
#if defined(_WIN32) && defined(CYLINDER_HEIGHT)
#undef CYLINDER_HEIGHT
#endif
#if defined(_WIN32) && defined(CYLINDER_RADIUS)
#undef CYLINDER_RADIUS
#endif
#if defined(_WIN32) && defined(CONE_HEIGHT)
#undef CONE_HEIGHT
#endif
#if defined(_WIN32) && defined(CONE_RADIUS)
#undef CONE_RADIUS
#endif
enum {
BOX = 1u,
SPHERE = 2u,
CYLINDER = 3u,
CONE = 4u,
BOX_X = 0u,
BOX_Y = 1u,
BOX_Z = 2u,
SPHERE_RADIUS = 0u,
CYLINDER_HEIGHT = 0u,
CYLINDER_RADIUS = 1u,
CONE_HEIGHT = 0u,
CONE_RADIUS = 1u,
};
typedef boost::shared_ptr< ::shape_msgs::SolidPrimitive_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::shape_msgs::SolidPrimitive_<ContainerAllocator> const> ConstPtr;
}; // struct SolidPrimitive_
typedef ::shape_msgs::SolidPrimitive_<std::allocator<void> > SolidPrimitive;
typedef boost::shared_ptr< ::shape_msgs::SolidPrimitive > SolidPrimitivePtr;
typedef boost::shared_ptr< ::shape_msgs::SolidPrimitive const> SolidPrimitiveConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::shape_msgs::SolidPrimitive_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >::stream(s, "", v);
return s;
}
template<typename ContainerAllocator1, typename ContainerAllocator2>
bool operator==(const ::shape_msgs::SolidPrimitive_<ContainerAllocator1> & lhs, const ::shape_msgs::SolidPrimitive_<ContainerAllocator2> & rhs)
{
return lhs.type == rhs.type &&
lhs.dimensions == rhs.dimensions;
}
template<typename ContainerAllocator1, typename ContainerAllocator2>
bool operator!=(const ::shape_msgs::SolidPrimitive_<ContainerAllocator1> & lhs, const ::shape_msgs::SolidPrimitive_<ContainerAllocator2> & rhs)
{
return !(lhs == rhs);
}
} // namespace shape_msgs
namespace ros
{
namespace message_traits
{
template <class ContainerAllocator>
struct IsMessage< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::shape_msgs::SolidPrimitive_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::shape_msgs::SolidPrimitive_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::shape_msgs::SolidPrimitive_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >
{
static const char* value()
{
return "d8f8cbc74c5ff283fca29569ccefb45d";
}
static const char* value(const ::shape_msgs::SolidPrimitive_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0xd8f8cbc74c5ff283ULL;
static const uint64_t static_value2 = 0xfca29569ccefb45dULL;
};
template<class ContainerAllocator>
struct DataType< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >
{
static const char* value()
{
return "shape_msgs/SolidPrimitive";
}
static const char* value(const ::shape_msgs::SolidPrimitive_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >
{
static const char* value()
{
return "# Define box, sphere, cylinder, cone \n"
"# All shapes are defined to have their bounding boxes centered around 0,0,0.\n"
"\n"
"uint8 BOX=1\n"
"uint8 SPHERE=2\n"
"uint8 CYLINDER=3\n"
"uint8 CONE=4\n"
"\n"
"# The type of the shape\n"
"uint8 type\n"
"\n"
"\n"
"# The dimensions of the shape\n"
"float64[] dimensions\n"
"\n"
"# The meaning of the shape dimensions: each constant defines the index in the 'dimensions' array\n"
"\n"
"# For the BOX type, the X, Y, and Z dimensions are the length of the corresponding\n"
"# sides of the box.\n"
"uint8 BOX_X=0\n"
"uint8 BOX_Y=1\n"
"uint8 BOX_Z=2\n"
"\n"
"\n"
"# For the SPHERE type, only one component is used, and it gives the radius of\n"
"# the sphere.\n"
"uint8 SPHERE_RADIUS=0\n"
"\n"
"\n"
"# For the CYLINDER and CONE types, the center line is oriented along\n"
"# the Z axis. Therefore the CYLINDER_HEIGHT (CONE_HEIGHT) component\n"
"# of dimensions gives the height of the cylinder (cone). The\n"
"# CYLINDER_RADIUS (CONE_RADIUS) component of dimensions gives the\n"
"# radius of the base of the cylinder (cone). Cone and cylinder\n"
"# primitives are defined to be circular. The tip of the cone is\n"
"# pointing up, along +Z axis.\n"
"\n"
"uint8 CYLINDER_HEIGHT=0\n"
"uint8 CYLINDER_RADIUS=1\n"
"\n"
"uint8 CONE_HEIGHT=0\n"
"uint8 CONE_RADIUS=1\n"
;
}
static const char* value(const ::shape_msgs::SolidPrimitive_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.type);
stream.next(m.dimensions);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct SolidPrimitive_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::shape_msgs::SolidPrimitive_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::shape_msgs::SolidPrimitive_<ContainerAllocator>& v)
{
s << indent << "type: ";
Printer<uint8_t>::stream(s, indent + " ", v.type);
s << indent << "dimensions[]" << std::endl;
for (size_t i = 0; i < v.dimensions.size(); ++i)
{
s << indent << " dimensions[" << i << "]: ";
Printer<double>::stream(s, indent + " ", v.dimensions[i]);
}
}
};
} // namespace message_operations
} // namespace ros
#endif // SHAPE_MSGS_MESSAGE_SOLIDPRIMITIVE_H
| 23.638037 | 144 | 0.722035 | [
"shape",
"vector"
] |
a6a696018e2e4da685b654e845774416778dc2d5 | 752 | h | C | code/utility/viewmodel/commands/RubberCommand.h | flyoob/Trabecula | d09fbe6685d56102af7e4626e562130811d78df0 | [
"BSD-2-Clause"
] | null | null | null | code/utility/viewmodel/commands/RubberCommand.h | flyoob/Trabecula | d09fbe6685d56102af7e4626e562130811d78df0 | [
"BSD-2-Clause"
] | 1 | 2018-07-08T09:13:42.000Z | 2018-07-08T09:13:42.000Z | code/utility/viewmodel/commands/RubberCommand.h | flyoob/Trabecula | d09fbe6685d56102af7e4626e562130811d78df0 | [
"BSD-2-Clause"
] | 7 | 2018-02-08T08:00:30.000Z | 2021-02-06T14:19:03.000Z | ////////////////////////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////////////////////////
template <class TViewModel>
class RubberCommand : public ICommandBase
{
public:
RubberCommand(TViewModel* pVM) throw() : m_pVM(pVM)
{
}
~RubberCommand() throw()
{
}
// ICommandBase
virtual void SetParameter(const std::any& param)
{
m_param = param;
}
virtual void Exec()
{
std::vector<PAIR>& track = *(std::any_cast<std::vector<PAIR>>(&m_param));
bool bRet = m_pVM->RubberMask(track);
}
private:
TViewModel* m_pVM;
std::any m_param;
};
////////////////////////////////////////////////////////////////////////////////
| 22.787879 | 82 | 0.428191 | [
"vector"
] |
a6a71582857072d4c07fcc5d15fb7aaf0d5ffaaa | 42,565 | c | C | wgrib2-v0.1.9.4/extensions/lats/lats.c | jprules321/colas | 2757d5c077c3306d510488a0134ac4120e2d3fa0 | [
"MIT"
] | null | null | null | wgrib2-v0.1.9.4/extensions/lats/lats.c | jprules321/colas | 2757d5c077c3306d510488a0134ac4120e2d3fa0 | [
"MIT"
] | null | null | null | wgrib2-v0.1.9.4/extensions/lats/lats.c | jprules321/colas | 2757d5c077c3306d510488a0134ac4120e2d3fa0 | [
"MIT"
] | null | null | null |
/*
* Include ./configure's header file
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
/* -*-Mode: C;-*-
* Module: LATS user API
*
* Copyright: 1996, Regents of the University of California
* This software may not be distributed to others without
* permission of the author.
*
* Author: Bob Drach, Lawrence Livermore National Laboratory
* drach@llnl.gov
*
* Version: $Id$
* Version: $Id$
*
* Revision History:
*
* $Log$
* Revision 1.14 2010/02/16 23:01:31 mike_fiorino
* mods for supporting yflip and better handling of forecast_hourly forecast_minutes
*
* Revision 1.13 2009/10/15 03:42:42 dasilva
* ams: working in progress, still cannot run twice in a row
*
* Revision 1.12 2009/10/15 02:21:00 dasilva
* ams: added missing break;
*
* Revision 1.11 2009/10/15 01:44:35 dasilva
* ams: work in progress
*
* Revision 1.10 2009/10/15 01:17:52 dasilva
* ams: work in progress
*
* Revision 1.9 2009/10/15 00:25:37 dasilva
* ams: work in progress
*
* Revision 1.8 2009/10/14 22:19:05 dasilva
* ams: work in progress
*
* Revision 1.7 2009/10/14 22:16:58 dasilva
* ams: work in progress
*
* Revision 1.6 2009/10/14 04:00:32 dasilva
* ams: work in progress
*
* Revision 1.5 2009/10/13 04:22:39 dasilva
* ams: nc-4 compression seems to work
*
* Revision 1.4 2009/10/13 04:07:58 dasilva
* ams: nc-4 compression seems to work
*
* Revision 1.3 2009/10/13 03:34:20 dasilva
* ams: work in progress
*
* Revision 1.2 2009/10/10 06:34:15 mike_fiorino
* mf 20091010 -- incorporate all my mods 1.10 lats into 2.0 lats extension
*
* Revision 1.10 2009/03/18 15:52:39 mike_fiorino
* mf:lats bugs fix + minutes support; set z 1 last ; control of line properties of gxout grid
* Revision 1.1 2009/10/05 13:44:26 dasilva
* ams: porting LATS to grads v2; work in progress
*
* Revision 1.9 2008/01/19 19:24:47 pertusus
* Use the pkgconfig result unless dap root was set.
* change <config.h> to "config.h".
*
* Revision 1.8 2007/11/12 14:44:46 dasilva
* ams: fixed bug reported by Mike Fiorino
*
* Revision 1.7 2007/10/19 13:07:31 pertusus
* Compilation fixes from Graziano Giuliani.
*
* Revision 1.6 2007/08/26 23:32:03 pertusus
* Add standard headers includes.
*
* Revision 1.5 2007/08/25 02:39:13 dasilva
* ams: mods for build with new supplibs; changed dods to dap, renamed dodstn.c to dapstn.c
*
* Revision 1.2 2002/10/28 19:08:33 joew
* Preliminary change for 'autonconfiscation' of GrADS: added a conditional
* #include "config.h" to each C file. The GNU configure script generates a unique config.h for each platform in place of -D arguments to the compiler.
* The include is only done when GNU configure is used.
*
* Revision 1.1.1.1 2002/06/27 19:44:12 cvsadmin
* initial GrADS CVS import - release 1.8sl10
*
* Revision 1.1.1.1 2001/10/18 02:00:56 Administrator
* Initial repository: v1.8SL8 plus slight MSDOS mods
*
* Revision 1.17 1997/10/15 17:53:13 drach
* - remove name collisions with cdunif
* - only one vertical dimension with GrADS/GRIB
* - in sync with Mike's GrADS src170
* - parameter table in sync with standard model output listing
*
* Revision 1.3 1997/02/14 20:11:52 fiorino
* before latsmode change
*
* Revision 1.2 1997/01/17 00:38:03 fiorino
* with latsTimeCmp bug diagnostics
*
* Revision 1.1 1997/01/03 00:30:15 fiorino
* Initial revision
*
* Revision 1.16 1996/12/18 22:06:20 fiorino
* initialize fltpnt in gagmap.c to cover c90 compiler problem
* added support for climatological and 365-day calendars in GrADS
*
* Revision 1.15 1996/11/11 22:39:18 drach
* - Added function to set the basetime (lats_basetime)
*
* Revision 1.14 1996/10/22 19:05:02 fiorino
* latsgrib bug in .ctl creator
*
* Revision 1.13 1996/10/21 17:20:15 drach
* - Fixed LATS_MONTHLY_TABLE_COMP option
*
* Revision 1.12 1996/10/10 23:15:43 drach
* - lats_create filetype changed to convention, with options LATS_PCMDI,
* LATS_GRADS_GRIB, and LATS_NC3.
* - monthly data defaults to 16-bit compression
* - LATS_MONTHLY_TABLE_COMP option added to override 16-bit compression
* - AMIP II standard parameter file
* - parameter file incorporates GRIB center and subcenter
* - if time delta is positive, check that (new_time - old_time)=integer*delta
*
* Revision 1.11 1996/08/27 19:40:21 drach
* - Corrected generation of basetime string for climatologies
*
* Revision 1.10 1996/08/20 18:34:06 drach
* - lats_create has a new argument: calendar
* - lats_grid: longitude, latitude dimension vectors are now double
* precision (double, C).
* - lats_vert_dim: vector of levels is now double precision (double,
* C). lats_vert_dim need not be called for single-value/surface
* dimensions, if defined in the parameter table. Multi-valued vertical
* dimensions, such as pressure levels, must be defined with
* lats_vert_dim.
* - lats_var: set level ID to 0 for implicitly defined surface
* dimension.
* - lats_write: level value is double precision (double, C).
* - lats_parmtab: replaces routine lats_vartab.
* - FORTRAN latserropt added: allows program to set error handling
* options.
* - The parameter file format changed.
*
* Revision 1.9 1996/07/12 00:36:25 drach
* - (GRIB) use undefined flag only when set via lats_miss_XX
* - (GRIB) use delta when checking for missing data
* - (GRIB) define maximum and default precision
* - fixed lats_vartab to work correctly.
* - Added report of routine names, vertical dimension types
*
* Revision 1.8 1996/06/27 01:07:02 drach
* - Added QC weights calculation
*
* Revision 1.7 1996/05/25 00:27:47 drach
* - Added tables for vertical dimension types, time statistics, originating
* centers, and quality control marks
* - Modified signatures of lats_create and lats_vert_dim
*
* Revision 1.6 1996/05/11 00:08:01 fiorino
* - Added COARDS compliance
*
* Revision 1.5 1996/05/10 22:44:38 drach
* - Initial version before GRIB driver added:
* - Made grids, vertical dimensions file-independent
*
* Revision 1.4 1996/05/04 01:11:09 drach
* - Added name, units to lats_vert_dim
* - Added missing data attribute (latsnc.c)
*
* Revision 1.3 1996/05/03 18:59:23 drach
* - Moved vertical dimension definition from lats_var to lats_vert_dim
* - Changed lats_miss_double to lats_miss_float
* - Made time dimension file-dependent, revised lats_write accordingly
* - Added lats_var_nc, lats_vert_dim_nc
* - Allow GRIB-only compilation
* - Added FORTRAN interface
*
* Revision 1.2 1996/04/25 23:32:03 drach
* - Added checks for correct number of times, levels written
* - Stubbed in statistics routines
*
* Revision 1.1 1996/04/25 00:52:59 drach
* Initial repository version
*
*
*/
#define _POSIX_SOURCE 1
#define MAX(a,b) ((a)>(b)?(a):(b))
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "latsint.h"
#include "latstime.h"
#ifdef GOT_NETCDF
# include "netcdf.h"
#endif
char *_lats_routine_name_ = (char *)0;
static int latsParmTableCreated = 0; /* 1 iff parameter table has been created */
#include "galats.h"; /*ams not very kosher, but simplifies implementation ams*/
extern struct galats glats ; /* LATS option struct */
/* Set the basetime for file 'fileid' Return 1 on success, 0 on failure */
int lats_basetime(int fileid, int year, int month, int day, int hour, int min) {
latsFile *file;
latsCompTime time;
_lats_routine_name_ = "lats_basetime";
if((file = latsFileLookup(fileid))==0) {
return 0;
}
if(file->latsmode != LATS_MODE_DEFINE && file->ntimewritten > 0){
latsError("LATS (lats.c) --> lats_basetime calls must precede any lats_write call");
return 0;
}
/*mf---
check if climo field for GRIB options
set year to 2 it will be overwritten in latsgrib.c by GRADS_CLIM_YEAR
---mf*/
if(!(file->calendar & cdStandardCal) &&
file->type == LATS_GRIB &&
file->frequency != LATS_FIXED) {
year=2;
}
/* Check that basetime not set yet */
if(file->basetimeset==1) {
latsError("LATS (lats.c) --> Basetime must be set at most once before any data is written, file %s", file->path);
return 0;
}
/* Check valid time */
if(month<1 || month>12){
latsError("LATS (lats.c) --> Invalid month: %d, file %s", month, file->path);
return 0;
}
/*mf 970121 --- year 0 not supported ---mf*/
if(file->frequency != LATS_FIXED) {
if(year <= 0) {
latsError("LATS (lats.c) --> Invalid year: %d, file %s year <0 NOT Supported", year, file->path);
return 0;
}
} else {
/*mf --- set year to 1 for fixed data --- mf*/
year=1;
}
if(day<1 || day>31){
latsError("LATS (lats.c) --> Invalid day: %d, file %s",day, file->path);
return 0;
}
if(hour<0 || hour>23){
latsError("LATS (lats.c) --> Invalid hour: %d, file %s",hour, file->path);
return 0;
}
if(min<0 || min>59){
latsError("LATS (lats.c) --> Invalid min: %d, file %s",min, file->path);
return 0;
}
time.year = year;
time.month = month;
time.day = day;
time.hour = (double)hour;
time.min = (double)min;
file->btime.year = year;
file->btime.month = month;
file->btime.day = day;
file->btime.hour = (double)hour;
file->btime.min = (double)min;
/* Generate base time */
/* Non-climatology base time */
if(file->calendar & cdStandardCal){
sprintf(file->latstimeunits,"%s since %d-%d-%d %d",
(file->frequency == LATS_YEARLY ? "years" :
file->frequency == LATS_MONTHLY ? "months" :
file->frequency == LATS_WEEKLY ? "days" :
file->frequency == LATS_DAILY ? "days" : "hours"),
time.year, time.month, time.day, hour);
}
/* Climatology base time */
else {
sprintf(file->latstimeunits,"%s since %d-%d %d",
(file->frequency == LATS_MONTHLY ? "months" :
file->frequency == LATS_WEEKLY ? "days" :
file->frequency == LATS_DAILY ? "days" : "hours"),
time.month, time.day, hour);
}
strncpy(file->timeunits, file->latstimeunits, LATS_MAX_RELUNITS); file->timeunits[LATS_MAX_RELUNITS-1]='\0';
if(file->convention == LATS_NC3 && file->frequency == LATS_MONTHLY){
sprintf(file->timeunits, "days since %d-%d-%d %d",
time.year, time.month, time.day, hour);
}
file->basetimeset = 1;
return 1; /* Success */
}
/* Close file with ID 'fileid'. Return 1 on success, 0 on failure. */
int lats_close(int fileid) {
latsFile *file;
int ierr;
double timevalue;
cdCompTime lasttime;
_lats_routine_name_ = "lats_close";
if((file = latsFileLookup(fileid))==0)
return 0;
/* Number of time increments for GrADS control file */
file->ndelta = file->ntimewritten;
/* Calculate global statistics */
latsStatFile(file);
// ierr = (file->type == LATS_GRIB ? lats_close_grib(file) : lats_close_nc(file));
switch(file->type) {
case LATS_GRIB: ierr=lats_close_grib(file); break;
case LATS_NETCDF: ierr=lats_close_nc(file); break;
case LATS_HDF: ierr=lats_close_sd(file); break;
default: ierr=-2;
}
if(latsFileDeleteEntry(fileid)==0)
return 0;
return ierr;
}
/* Create file with pathname 'path'. Return file ID on success, 0 on failure. */
int lats_create(char* path, int convention, int calendar, int frequency, int delta, char* center, char* model, char* comments) {
latsFile *file;
char *defaultParmFile;
latsCenter *cent;
char tempname[LATS_MAX_COMMENTS];
char tmppath[LATS_MAX_PATH];
char *extension;
latsCompressionType compressiontype;
latsFileType filetype;
_lats_routine_name_ = "lats_create";
/* Validity checks */
if(convention != LATS_PCMDI &&
convention != LATS_GRADS_GRIB &&
convention != LATS_GRIB_ONLY &&
convention != LATS_NC3 &&
convention != LATS_NC4 &&
convention != LATS_HDF4){
latsError("LATS (lats.c) --> Invalid file convention: %d", convention);
return 0;
}
if(frequency != LATS_YEARLY &&
frequency != LATS_MONTHLY &&
frequency != LATS_WEEKLY &&
frequency != LATS_DAILY &&
frequency != LATS_HOURLY &&
frequency != LATS_MINUTES &&
frequency != LATS_FORECAST_HOURLY &&
frequency != LATS_FORECAST_MINUTES &&
frequency != LATS_FIXED &&
frequency != LATS_MONTHLY_TABLE_COMP){
latsError("LATS (lats.c) --> Invalid frequency: %d", frequency);
return 0;
}
if(calendar != LATS_STANDARD &&
calendar != LATS_JULIAN &&
calendar != LATS_NOLEAP &&
calendar != LATS_360 &&
calendar != LATS_CLIM &&
calendar != LATS_CLIMLEAP &&
calendar != LATS_CLIM360){
latsError("LATS (lats.c) --> Invalid calendar: %d", calendar);
return 0;
}
if(convention == LATS_NC3 && calendar != LATS_STANDARD){
latsError("LATS (lats.c) --> COARDS data must be written with the standard Gregorian calendar, file %s", path);
return 0;
}
if( (convention == LATS_GRADS_GRIB || convention == LATS_GRIB_ONLY)
&& !(calendar == LATS_STANDARD
|| calendar == LATS_NOLEAP
|| calendar == LATS_CLIM
|| calendar == LATS_CLIMLEAP ) )
{
latsError("LATS (lats.c) --> GRADS/GRIB data must be written with: 1) the standard Gregorian; 2) 365 day ; or 3) climatology calendar , file %s", path);
return 0;
}
if( (frequency == LATS_FORECAST_HOURLY || frequency == LATS_MINUTES || frequency == LATS_FORECAST_MINUTES) && !(calendar == LATS_STANDARD) ) {
latsError("LATS (lats.c) --> Forecast hourly data must written with the standard Gregorian calendar (LATS_STANDARD), file %s", path);
return 0;
}
if(convention == LATS_GRADS_GRIB && delta <= 0){
latsError("LATS (lats.c) --> GRADS_GRIB data must be written with nonzero delta, file %s", path);
return 0;
}
/* Map weekly data to daily */
if(frequency == LATS_WEEKLY){
frequency = LATS_DAILY;
delta *= 7;
}
/* Set the file type */
switch(convention){
case LATS_PCMDI:
case LATS_NC3:
filetype = LATS_NETCDF;
break;
case LATS_NC4:
filetype = LATS_NETCDF;
break;
case LATS_HDF4:
filetype = LATS_HDF;
break;
case LATS_GRADS_GRIB:
filetype = LATS_GRIB;
break;
case LATS_GRIB_ONLY:
filetype = LATS_GRIB;
break;
}
/* Override parameter table compression values for monthly data */
compressiontype = (frequency == LATS_MONTHLY ? LATS_FIXED_COMP : LATS_TABLE_COMP);
if (frequency == LATS_MONTHLY_TABLE_COMP) frequency = LATS_MONTHLY;
/* Set the correct file extension */
latsCpyTrim(tmppath, path, LATS_MAX_PATH-4);
if ( filetype==LATS_NETCDF ) {
#ifdef NC_NETCDF4
if ( glats.convention==LATS_NC4) extension = ".nc4";
else extension = ".nc";
#else
extension = ".nc";
#endif
} else if ( filetype==LATS_HDF ) {
extension = ".hdf";
} else {
extension = ".grb";
}
if(strcmp(extension, tmppath + MAX(0,strlen(tmppath)-strlen(extension))) != 0)
strcat(tmppath,extension);
/* Create file entry, add to file list */
if((file = latsFileAddEntry(tmppath)) == 0)
return 0;
/* Create the parameter table, if necessary */
if(latsParmTableCreated == 0){
if((defaultParmFile = getenv("LATS_PARMS")) == NULL) {
if(latsParmCreateDefaultTable()==0)
return 0;
}
else {
if(latsParmCreateTable(defaultParmFile)==0)
return 0;
}
latsParmTableCreated = 1;
}
/* Lookup center for GRIB */
if(filetype == LATS_GRIB){
latsCpyLower(tempname, center, LATS_MAX_COMMENTS);
if((cent = latsCenterLookup(tempname))==0){
latsError("LATS (lats.c) --> Center not found in center table: %s, file %s", tempname, tmppath);
return 0;
}
file->centerid = cent->gribid;
file->grib_center = cent->grib_center;
file->grib_subcenter = cent->grib_subcenter;
}
else
file->centerid = file->grib_center = file->grib_subcenter = -1;
file->type = filetype;
file->calendar = (latsCalenType) calendar;
file->frequency = (latsTimeFreq) frequency;
file->delta = delta;
file->convention = (latsConvention) convention;
file->compressiontype = compressiontype;
strncpy(file->center, center, LATS_MAX_COMMENTS); file->center[LATS_MAX_COMMENTS-1]='\0';
strncpy(file->model, model, LATS_MAX_COMMENTS); file->model[LATS_MAX_COMMENTS-1]='\0';
strncpy(file->comments, comments, LATS_MAX_COMMENTS); file->comments[LATS_MAX_COMMENTS-1]='\0';
/*mf set latsmode to DEFINE mf*/
file->latsmode = LATS_MODE_DEFINE;
// return (filetype == LATS_GRIB ? lats_create_grib(file) : lats_create_nc(file));
switch(file->type) {
case LATS_GRIB: return (lats_create_grib(file));
case LATS_NETCDF: return (lats_create_nc(file));
case LATS_HDF: return (lats_create_sd(file));
default: return (-2);
}
}
/* Set the error options. `erropt' is a logical
combination of flags LATS_EXIT_ON_ERROR and
LATS_REPORT_ERROR. */
void lats_erropt(int erropt){
lats_fatal = (erropt & LATS_EXIT_ON_ERROR);
lats_verbose = (erropt & LATS_REPORT_ERRORS);
}
#define LATS_TORAD (3.14159265359/180.0) /* Degrees to radians */
/* Define a grid. The longitude vector 'lons' */
/* has length 'nlon', latitude vector 'lats' has length 'nlat'. Return 1 on success, */
/* 0 on failure. */
int lats_grid(char *name, int gridtype, int nlon, double lons[], int nlat, double lats[]) {
latsFile *file;
latsGrid *grid;
latsMonotonicity monolon, monolat;
int i, j;
double *tlon, *plat;
_lats_routine_name_ = "lats_grid";
/* Validity checks */
if(gridtype != LATS_GAUSSIAN &&
gridtype != LATS_LINEAR &&
gridtype != LATS_GENERIC){
latsError("LATS (lats.c) --> Invalid grid type: %d, grid %s", gridtype, name);
return 0;
}
if(nlon <= 0 || nlat <= 0){
latsError("LATS (lats.c) --> Number of longitudes: %d, and number of latitudes: %d must be positive, grid %s",
nlon, nlat, name);
return 0;
}
if((monolon=latsCheckMono(nlon, lons))==0 || (monolat=latsCheckMono(nlat, lats))==0){
latsError("LATS (lats.c) --> Longitude and latitude vectors must be monotonic, grid %s",
name);
return 0;
}
if(fabs((double)(lons[nlon-1]-lons[0])) >= 360.0){
latsError("LATS (lats.c) --> Longitude vector must not wrap around, grid %s", name);
return 0;
}
if(fabs((double)(lats[nlat-1]))>90.0 || fabs((double)lats[0])>90.0){
latsError("LATS (lats.c) --> Latitude values must be in the range -90 to 90");
return 0;
}
if((grid = latsGridAddEntry(name)) == 0)
return 0;
/* Create the grid */
latsCpyTrim(grid->name, name, LATS_MAX_NAME);
grid->type = (latsGridType) gridtype;
if((grid->lats = (double *)malloc(nlat*sizeof(double)))==NULL){
latsError("LATS (lats.c) --> Allocating latitude vector memory, nlat=%d",nlat);
return 0;
}
grid->nlat = nlat;
memcpy(grid->lats, lats, nlat*sizeof(double));
if((grid->lons = (double *)malloc(nlon*sizeof(double)))==NULL){
latsError("LATS (lats.c) --> Allocating longitude vector memory, nlon=%d",nlon);
return 0;
}
grid->nlon = nlon;
memcpy(grid->lons, lons, nlon*sizeof(double));
/* Calculate longitude weights */
if(((grid->wlons = (double *)malloc(nlon*sizeof(double)))==NULL) ||
((tlon = (double *)malloc(nlon*sizeof(double)))==NULL)){
latsError("LATS (lats.c) --> Allocating longitude weight vector, nlon=%d",nlon);
return 0;
}
tlon[0] = (lons[0] + lons[nlon-1] + 360.0)/2.0;
for(i=1; i<nlon; i++){
tlon[i] = (lons[i-1] + lons[i])/2.0;
}
if(monolon == LATS_INCREASING){
grid->wlons[0] = tlon[1]-tlon[0]+360.0;
for(i=1; i<nlon-1; i++){
grid->wlons[i] = tlon[i+1]-tlon[i];
}
grid->wlons[nlon-1] = tlon[0] - tlon[nlon-1];
}
else {
grid->wlons[0] = tlon[0]-tlon[1];
for(i=1; i<nlon-1; i++){
grid->wlons[i] = tlon[i]-tlon[i+1];
}
grid->wlons[nlon-1] = tlon[nlon-1]-tlon[0]+360.0;
}
/* Calculate latitude weights */
if(((grid->wlats = (double *)malloc(nlat*sizeof(double)))==NULL) ||
((plat = (double *)malloc((nlat+1)*sizeof(double)))==NULL)){
latsError("LATS (lats.c) --> Allocating latitude weight vector, nlat=%d",nlat);
return 0;
}
plat[0] = (monolat==LATS_INCREASING ? -90.0 : 90.0);
for(j=1; j<nlat; j++){
plat[j] = (lats[j-1] + lats[j])/2.0;
}
plat[nlat] = (monolat==LATS_INCREASING ? 90.0 : -90.0);
for(j=0; j<nlat; j++){
grid->wlats[j] = fabs(sin(LATS_TORAD*(double)plat[j+1]) - sin(LATS_TORAD*(double)plat[j]));
}
free(tlon);
free(plat);
return grid->id;
}
/* Set the quality control:
qcopt = LATS_QC_ON iff turn on quality control calculations
qcopt = 0 iff turn off QC calcs */
void lats_qcopt(qcopt){
lats_qc = (qcopt & LATS_QC_ON);
}
/* Define a variable to be written to file with ID 'fileid'. */
/* 'gridid' is the grid identifier, 'levid' is the vertical dimension identifier. */
/* Return the variable ID on success, 0 on failure. */
int lats_var(int fileid, char* varname, int datatype, int timestat, int gridid, int levid, char* comments) {
latsFile *file;
latsVar *var;
latsVertDim *vertdim;
latsParm *parm;
latsParmQC *qc;
latsGrid *grid;
latsTimeStatEntry *stat;
double levdelta, delta, *levvalue;
int i, nlev, nprev, ierr;
size_t qcalloc;
_lats_routine_name_ = "lats_var";
/* Lookup the parameter */
if((parm = latsParmLookup(varname))==0){
latsError("LATS (lats.c) --> Variable %s: not in the variable table, file ID %d", varname, fileid);
return 0;
}
/* Validity checks */
if(datatype != LATS_FLOAT &&
datatype != LATS_INT){
latsError("LATS (lats.c) --> Datatype: %d, must be LATS_FLOAT or LATS_INT, file %d, var %s",
datatype, fileid, varname);
return 0;
}
if(datatype != parm->datatype){
latsError("LATS (lats.c) --> Variable %s, file ID %d: datatype %s does not match predefined datatype",
varname, fileid, (datatype == LATS_FLOAT ? "LATS_FLOAT" : "LATS_INT"));
return 0;
}
if(parm->id>255 | parm->id<1) {
latsError("LATS (lats.c) --> Variable %s, file ID %d: GRIB parameter id %d is invalid, must be >1 and < 255",
fileid, parm->id);
return 0;
}
/* Create the variable */
if((var = latsVarAddEntry(fileid, varname))==0)
return 0;
file = var->file;
/* mode check */
if(file->latsmode != LATS_MODE_DEFINE){
latsError("LATS (lats.c) --> lats_var calls MUST PRECEDE ANY lats_write call");
return 0;
}
if(file->frequency != LATS_FIXED &&
timestat != LATS_AVERAGE &&
timestat != LATS_INSTANT &&
timestat != LATS_ACCUM &&
timestat != LATS_OTHER_TIME_STAT){
latsError("LATS (lats.c) --> Time statistic: %d must be LATS_AVERAGE, LATS_INSTANT, or LATS_ACCUM, file %d, var %s",
timestat, fileid, varname);
return 0;
}
/* Lookup the time statistic for non-fixed variables */
/*mf ----
961212
bug fix -- LATS_FIXED now handled properly
if(file->type == LATS_GRIB && file->frequency != LATS_FIXED &&
---mf*/
if(file->type == LATS_GRIB &&
(stat = latsTimeStatLookup(file->frequency, file->delta, (latsTimeStat) timestat))==0){
latsError("LATS (lats.c) --> Time statistic not defined: frequency = %s, delta = %d, timestat = %s, for variable %s",
(file->frequency == LATS_YEARLY ? "year" :
file->frequency == LATS_MONTHLY ? "month" :
file->frequency == LATS_WEEKLY ? "week" :
file->frequency == LATS_DAILY ? "day" : "hour"),
file->delta,
(timestat == LATS_AVERAGE ? "average" :
timestat == LATS_INSTANT ? "instant" :
timestat == LATS_ACCUM ? "accum" : "other"),
varname);
return 0;
}
/* Check level ID */
if(levid == 0) {
vertdim = (latsVertDim *)0;
nlev = 0;
levdelta = 1.0e20;
}
else if(levid>0) {
nprev = file->nvertdim;
if((vertdim = latsFileVertLookup(file, levid))==0){
latsError("LATS (lats.c) --> Vertical dimension not found, ID: %d, file %s, variable %s",
levid, file->path, var->name);
return 0;
}
/* If the lookup added the vertical dimension to */
/* the file vertlist, create it in the file. */
/*mf 970822
abort if trying to use more than one vertical dimension for GrADS_GRIB
mf*/
if(file->convention == LATS_GRADS_GRIB && file->nvertdim > 1) {
latsError("LATS (lats.c) --> For LATS_GRADS_GRIB convention,\nvertdim can only be called once; define a vertical dimension that includes all levels\nVertical Dim ID: %d, file %s, variable %s",levid, file->path, var->name);
return 0;
}
if(nprev<file->nvertdim) {
// if ( (file->type == LATS_GRIB ? lats_vert_dim_grib(file, vertdim) :
// lats_vert_dim_nc(file, vertdim))==0)
// return 0;
switch(file->type) {
case LATS_GRIB: ierr = (lats_vert_dim_grib(file,vertdim)); break;
case LATS_NETCDF: ierr = (lats_vert_dim_nc(file,vertdim)); break;
case LATS_HDF: ierr = (lats_vert_dim_sd(file,vertdim)); break;
default: return (-2);
}
if ( ierr==0 ) return 0;
}
nlev = vertdim->nlev;
levdelta = vertdim->delta;
/* Warning if changing the default surface type*/
if(parm->levelset==1 && strcmp(vertdim->type->name,parm->verttype->name)){
latsWarning("Overriding default level type %s, for variable %s",
parm->verttype->name, varname);
}
}
else {
latsError("LATS (lats.c) --> Level dimension: %d, invalid, variable %s, file %s",
levid, varname, file->path);
return 0;
}
/* levs must be monotonic */
if(parm->levelset == 1 && nlev > 1){
latsError("LATS (lats.c) --> Variable %s, file ID %d: number of levels: %d, must be 0 or 1 for single-level (surface) variable",varname, fileid, nlev);
return 0;
}
/*
if(vertdim && strcmp(parm->levunits,vertdim->units)!=0){
latsError("Defined level units (%s), differs from prescribed units (%s), variable %s, file %s",
parm->levunits, vertdim->units, var->name, file->path);
}
*/
/* Override table compression values for 'fixed compression' file */
/* Note: Use var->scalefac instead of parm->scalefac, since other */
/* non-fixed-compression variables may point to parm !!! */
if(file->compressiontype == LATS_FIXED_COMP){
var->scalefac = -999;
var->precision = LATS_FIXED_COMPRESSION_NBITS;
}
else {
var->scalefac = parm->scalefac;
var->precision = parm->precision;
}
var->parm = parm;
strncpy(var->comments, comments, LATS_MAX_COMMENTS); var->comments[LATS_MAX_COMMENTS-1]='\0';
var->levdelta = levdelta;
var->nlev = nlev;
var->levs = (vertdim ? vertdim->levs : (double *)0);
/*mf---
961212
bug fix -- LATS_FIXED now properly processed ...
var->timestat = (file->frequency == LATS_FIXED ? (latsTimeStatEntry *)0 : stat);
---mf*/
var->timestat = stat;
var->tstat = (latsTimeStat) timestat;
var->vertdim = vertdim;
/* Declare the grid for this file, if necessary */
nprev = file->ngrid;
if((grid = latsFileGridLookup(file, gridid))==0)
return 0;
if(nprev < file->ngrid){
// ierr = (file->type == LATS_GRIB ? lats_grid_grib(file, grid) : lats_grid_nc(file, grid));
switch(file->type) {
case LATS_GRIB: ierr = (lats_grid_grib(file,grid)); break;
case LATS_NETCDF: ierr = (lats_grid_nc(file,grid)); break;
case LATS_HDF: ierr = (lats_grid_sd(file,grid)); break;
default: return (-2);
}
if(ierr == 0)
return 0;
}
var->grid = grid;
/* Fill QC table: at most one entry for every level */
if(lats_qc){
qcalloc = (var->levs ? var->nlev : 1);
if((var->qctable = (latsParmQC **)calloc(qcalloc,sizeof(latsParmQC *)))==0){
latsError("LATS (lats.c) --> Creating quality control table, variable %s", var->name);
return 0;
}
/* Explicit vertical dimension? */
if(var->levs){
for(i=0; i<var->nlev; i++){
if((qc = latsQCLookup(var->name, var->vertdim->type->name, var->levs[i], levdelta)))
var->qctable[i] = qc;
else
var->qctable[i] = (latsParmQC *)0;
}
}
/* Implicit vertical dimension? */
else if(parm->levelset == 1){
if((qc = latsQCLookup(var->name, parm->verttype->name, LATS_DEFAULT_QC_VALUE, 0.0)))
var->qctable[0] = qc;
else
var->qctable[0] = (latsParmQC *)0;
}
else { /* No associated level, look for empty string*/
if((qc = latsQCLookup(var->name, "", LATS_DEFAULT_QC_VALUE, 0.0)))
var->qctable[0] = qc;
else
var->qctable[0] = (latsParmQC *)0;
}
}
// return (file->type == LATS_GRIB ? lats_var_grib(file, var, grid, vertdim) : lats_var_nc(file, var, grid, vertdim));
switch(file->type) {
case LATS_GRIB: return (lats_var_grib(file,var,grid,vertdim));
case LATS_NETCDF: return (lats_var_nc(file,var,grid,vertdim));
case LATS_HDF: return (lats_var_sd(file,var,grid,vertdim));
default: return (-2);
}
}
/* Declare the missing data value for a floating-point variable. */
/* Return 1 on success, 0 on failure*/
int lats_miss_float(int fileid, int varid, float missing, float delta){
latsVar *var;
latsFile *file;
_lats_routine_name_ = "lats_miss_float";
if((file = latsFileLookup(fileid))==0) {
return 0;
}
if(file->latsmode != LATS_MODE_DEFINE){
latsError("LATS (lats.c) --> lats_miss_float calls must precede any lats_write call");
return 0;
}
if((var = latsVarLookup(fileid, varid))==0)
return 0;
if(var->parm->datatype != LATS_FLOAT){
latsError("LATS (lats.c) --> Missing data value for variable %s declared as float, but variable is not floating-point",
var->name);
return 0;
}
if(delta < 0.0){
latsError("LATS (lats.c) --> Missing delta value = %f, must be nonnegative",delta);
return 0;
}
var->missing.f = missing;
var->missingdelta = delta;
var->hasmissing = 1;
return 1;
}
/* Declare the missing data value for an integer variable. */
/* Return 1 on success, 0 on failure*/
int lats_miss_int(int fileid, int varid, int missing){
latsVar *var;
latsFile *file;
_lats_routine_name_ = "lats_miss_int";
if((file = latsFileLookup(fileid))==0) {
return 0;
}
if(file->latsmode != LATS_MODE_DEFINE){
latsError("LATS (lats.c) --> lats_miss_int calls must precede any lats_write call");
return 0;
}
if((var = latsVarLookup(fileid, varid))==0)
return 0;
if(var->parm->datatype != LATS_INT){
latsError("LATS (lats.c) --> Missing data value for variable %s declared as integer, but variable is not an integer",
var->name);
return 0;
}
var->missing.i = missing;
var->hasmissing = 1;
return 1;
}
/* Specify an alternate parameter table. */
int lats_parmtab(char* table_path) {
_lats_routine_name_ = "lats_parmtab";
if(latsParmCreateTable(table_path)==0)
return 0;
else{
latsParmTableCreated = 1;
return 1;
}
}
/* Define a vertical dimension */
int lats_vert_dim(char* name, char* levtype, int nlev, double levs[]) {
latsFile *file;
latsVertDim *vertdim,*vertdim_check;
latsVertType *verttype;
latsMonotonicity mono;
double levdelta, delta;
int i;
char *units;
char *defaultParmFile;
_lats_routine_name_ = "lats_vert_dim";
/*mf mode check
if(file->latsmode != LATS_MODE_DEFINE){
latsError("LATS (lats.c) --> lats_vert_dim calls must precede any lats_write call");
return 0;
}
*/
/* Create the parameter table, if necessary */
if(latsParmTableCreated == 0){
if((defaultParmFile = getenv("LATS_PARMS")) == NULL) {
if(latsParmCreateDefaultTable()==0)
return 0;
}
else {
if(latsParmCreateTable(defaultParmFile)==0)
return 0;
}
latsParmTableCreated = 1;
}
if((verttype = latsVertTypeLookup(levtype))==0){
latsVertTypeList();
latsError("LATS (lats.c) --> Vertical dimension type not found: %s, vertical dimension %s", levtype, name);
return 0;
}
if(nlev <= 0){
latsError("LATS (lats.c) --> Vertical dimension: %s, length: %d, must be positive",
name, nlev);
return 0;
}
if(nlev>0 && (mono = latsCheckMono(nlev, levs))==0){
latsError("LATS (lats.c) --> Vertical dimension: %s: must be strictly monotonic, increasing or decreasing",
name);
return 0;
}
/* Determine lookup fudge factor for level values */
if(mono == LATS_INCREASING){
levdelta = 1.0e20;
for(i=0; i<nlev-1; i++){
delta = levs[i+1] - levs[i];
levdelta = (levdelta < delta) ? levdelta : delta;
}
}
else if(mono == LATS_DECREASING){
levdelta = 1.0e20;
for(i=0; i<nlev-1; i++){
delta = levs[i] - levs[i+1];
levdelta = (levdelta < delta) ? levdelta : delta;
}
}
else
/* Singleton level, make sure delta is positive, */
/* otherwise lookup will fail. */
levdelta = ((delta=fabs((double)levs[0])) > 0.0 ? delta : 1.0);
levdelta *= LATS_DELTA_FACTOR;
if((vertdim = latsVertAddEntry(name))==0)
return 0;
vertdim->delta = levdelta;
vertdim->nlev = nlev;
vertdim->vncid = vertdim->ncid = -1;
vertdim->type = verttype;
latsCpyTrim(vertdim->name, name, LATS_MAX_NAME);
if((vertdim->levs = (double *)malloc(nlev*sizeof(double)))==0){
latsError("LATS (lats.c) --> Allocating memory for vertical dimension: %s, length %d",
name, nlev);
return 0;
}
memcpy(vertdim->levs, levs, nlev*sizeof(double));
return vertdim->id;
}
/* Write a horizontal lon-lat section 'data' to file with ID 'fileid', */
/* variable with ID 'varid'. Return 1 on success, 0 on failure. */
int lats_write(int fileid, int varid, double lev, int year, int month, int day, int hour, int min,
int fhour, int fmin,
void* data) {
latsFile *file;
latsVar *var;
int ierr, levindex, timeindex, ihour, imin;
latsCompTime time,curtime;
cdCompTime cdtime;
int timecmp;
double old_time, new_time;
int idel, ndels;
static int monthdays[12]={31,29,31,30,31,30,31,31,30,31,30,31};
static char monthnames[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
_lats_routine_name_ = "lats_write";
/* Lookup the file and variable */
if((var = latsVarLookup(fileid, varid))==0)
return 0;
file = var->file;
/*mf - put lats in DATA mode mf*/
file->latsmode=LATS_MODE_DATA;
/* Validity checks */
switch(file->frequency){
case LATS_HOURLY:
break;
case LATS_MINUTES:
break;
case LATS_FORECAST_HOURLY:
break;
case LATS_FORECAST_MINUTES:
break;
case LATS_DAILY:
case LATS_WEEKLY:
hour = 0;
min = 0;
break;
case LATS_MONTHLY:
day = 1;
hour = 0;
min = 0;
break;
case LATS_YEARLY:
month = 1;
day = 1;
hour = 0;
min = 0;
break;
case LATS_FIXED:
year = 1;
month = 1;
day = 1;
hour = 0;
min = 0;
break;
}
/*mf---
check if climo field for GRIB options
set year to 2, but it will be overwritten in latsgrib.c by GRADS_CLIM_YEAR
---mf*/
if(!(file->calendar & cdStandardCal) &&
file->type == LATS_GRIB &&
file->frequency != LATS_FIXED) {
year=2;
}
/*
* time QC
*/
if(file->frequency != LATS_FORECAST_HOURLY && file->frequency != LATS_FORECAST_MINUTES) {
if(year <= 0){
latsError("LATS (lats.c) --> \n Invalid year: %d, file %s year <= 0 NOT Supported\n if climatology use year 2 in lats_write", year, file->path);
}
if(month<1 || month>12){
latsError("LATS (lats.c) --> Invalid month: %d, file %s, variable %s",
month, file->path, var->name);
return 0;
}
if(day<1 || day>31){
latsError("LATS (lats.c) --> Invalid day: %d, file %s, variable %s",
day, file->path, var->name);
return 0;
}
if(hour<0 || hour>23){
latsError("LATS (lats.c) --> Invalid hour: %d, file %s, variable %s",
hour, file->path, var->name);
return 0;
}
if(min<0 || min>59){
latsError("LATS (lats.c) --> Invalid min: %d, file %s, variable %s",
min, file->path, var->name);
return 0;
}
} else {
if(hour<0){
latsError("LATS (lats.c) --> Invalid hour for LATS_FORECAST_HOURLY: %d, file %s, variable %s",
hour, file->path, var->name);
return 0;
}
if(min<0){
latsError("LATS (lats.c) --> Invalid hour for LATS_FORECAST_MINUTES: %d, file %s, variable %s",
min, file->path, var->name);
return 0;
}
}
if(file->frequency == LATS_FORECAST_HOURLY || file->frequency == LATS_FORECAST_HOURLY) {
/* set the time to the base time */
time.year = file->btime.year;
time.month = file->btime.month;
time.day = file->btime.day;
time.hour = (double)file->btime.hour;
time.min = (double)file->btime.min;
time.year = year;
time.month = month;
time.day = day;
time.hour = (double)hour;
time.min = (double)min;
} else {
time.year = year;
time.month = month;
time.day = day;
time.hour = (double)hour;
time.min = (double)min;
}
timecmp=latsTimeCmp(time,file->time);
/* if no times have been written; require that basetime be called for forecasts or call with current time */
if(file->ntimewritten == 0) {
timeindex = 0;
if(file->basetimeset == 0) {
if(file->frequency == LATS_FORECAST_HOURLY || file->frequency == LATS_FORECAST_MINUTES) {
latsError("LATS (lats.c) --> lats_basetime must be called before writing data for LATS_FORECAST_HOURLY|MINUTES");
return 0;
} else {
if(lats_basetime(fileid, year, month, day, hour, min) != 1)
return 0;
}
}
/* Time == current file time */
} else if(timecmp == 0) {
timeindex = file->ntimewritten-1;
/* Time > current file time */
} else if(timecmp > 0) {
timeindex = file->ntimewritten;
/* Check that (new_time - old_time)/delta is integral */
if(file->delta > 0) {
cdtime.year = file->time.year;
cdtime.month = file->time.month;
cdtime.day = file->time.day;
cdtime.hour = file->time.hour;
cdtime.min = file->time.min;
latsComp2Rel((cdCalenType)file->calendar, cdtime, file->latstimeunits, &old_time);
cdtime.year = time.year;
cdtime.month = time.month;
cdtime.day = time.day;
cdtime.hour = time.hour;
cdtime.min = time.min;
latsComp2Rel((cdCalenType)file->calendar, cdtime, file->latstimeunits, &new_time);
/* --- old_time,new_time in hours....*/
if(file->frequency == LATS_MINUTES || file->frequency == LATS_FORECAST_MINUTES) {
idel = (int)((new_time - old_time)*60.0 + 0.5);
} else {
idel = (int)(new_time - old_time + 0.5);
}
ndels = idel % file->delta;
if(file->convention==LATS_GRADS_GRIB && idel != file->delta){
latsError("LATS (lats.c) --> For GrADS convention, cannot skip timepoints; current time = %f %s, previous time = %f %s, delta = %d, file = %s, variable = %s",
new_time,file->latstimeunits,old_time,file->latstimeunits,file->delta, file->path, var->name);
return 0;
}
if(ndels != 0){
latsError("LATS (lats.c) --> Current time (%f %s) minus previous time (%f %s) not a multiple of delta (%d), file = %s, variable = %s",
new_time,file->latstimeunits,old_time,file->latstimeunits,file->delta, file->path, var->name);
return 0;
}
if(idel != file->delta) var->timemissing = 1;
} else if(file->delta == 0) {
timeindex = file->ntimewritten;
var->timeerror=1;
}
/* Time < current file time (only report error once) */
} else if(var->timeerror == 0){
latsError("LATS (lats.c) --> Variable(s) must be written in non-decreasing time order:\n Last time written = %d:%02dZ %d %s %d\n Current time = %dZ %d %s %d\n File = %s, variable = %s",
(ihour = file->time.hour),(imin = file->time.min), file->time.day, monthnames[file->time.month-1], file->time.year,
hour, day, monthnames[month-1], year,
file->path, var->name);
var->timeerror = 1;
return 0;
}
/* Lookup the level (set levindex to index of level being written */
if(var->nlev > 0){
if((levindex = latsLevLookup(lev, var->nlev, var->levs, var->levdelta))==-1){
latsError("LATS (lats.c) --> Level not found: %f, file %s, variable %s",
lev, file->path, var->name);
return 0;
}
} else {
levindex = -1;
} /* ---------------------------------------- END OF ntimewritten check*/
/* Check that number of times, levels written makes sense */
/* New time for this variable */
if(timeindex > var->ntimewritten-1 && var->ntimewritten>0){
if(var->nlev>0 && var->nlevwritten<var->nlev){
latsError("LATS (lats.c) --> Warning, fewer levels written (%d) then declared, file %s, variable %s, time = %dZ %d %s %d: The output file may be unnecessarily large",
var->nlevwritten, file->path, var->name,
hour, day, monthnames[month-1], year);
}
var->nlevwritten = 0;
} else {
/* Current time for this variable, or fixed variable */
if((var->nlev>0 && var->nlevwritten==var->nlev) ||
(var->nlev==0 && var->nlevwritten==1)) {
latsError("LATS (lats.c) --> Warning, too many levels written (%d) than declared, file %s, variable %s, time = %dZ %d %s %d: Data may be overwritten or duplicated",
var->nlevwritten+1, file->path, var->name,
hour, day, monthnames[month-1], year);
}
}
/* Calculate statistics */
if(lats_qc && latsStatVar(file, var, (var->levs ? var->qctable[levindex] : var->qctable[0]), levindex, timeindex, time, data)==0){
latsWarning("Quality control exception, variable %s, level %f, time %2dZ%d%s%d; see log file",
var->name, (var->levs ? var->levs[levindex] : 0.0), (ihour = time.hour),
time.day, monthnames[time.month-1], time.year);
}
// if((file->type == LATS_GRIB ? lats_write_grib(file, var, levindex, timeindex, time, data)
// : lats_write_nc(file, var, levindex, timeindex, time, data)) == 0)
// return 0;
/* Write the data */
switch(file->type) {
case LATS_GRIB: ierr = (lats_write_grib(file,var,levindex,timeindex,time,fhour,fmin,data)); break;
case LATS_NETCDF: ierr = (lats_write_nc(file,var,levindex,timeindex,time,fhour,fmin,data)); break;
case LATS_HDF: ierr = (lats_write_sd(file,var,levindex,timeindex,time,fhour,fmin,data)); break;
default: return (-2);
}
if ( ierr==0 ) return 0;
/* Update file, variable time and level counters */
var->nlevwritten++;
/* If a new time ... */
if(timeindex == file->ntimewritten){
file->time = time;
file->ntimewritten++;
}
if(timeindex > var->ntimewritten-1)
var->ntimewritten++;
if(var->ntimewritten != file->ntimewritten){
latsError("LATS (lats.c) --> Warning: more times (%d) written to file %s than for variable %s (%d), time = %dZ %d %s %d",
file->ntimewritten, file->path, var->name, var->ntimewritten,
(ihour = file->time.hour), file->time.day, monthnames[file->time.month-1],
file->time.year);
}
return 1;
}
| 30.88897 | 226 | 0.645014 | [
"vector",
"model"
] |
a6b0ec3356de31fffe4d327b2b9c35f632ab0b74 | 2,824 | h | C | aws-cpp-sdk-transcribestreaming/include/aws/transcribestreaming/model/AudioEvent.h | crazecdwn/aws-sdk-cpp | e74b9181a56e82ee04cf36a4cb31686047f4be42 | [
"Apache-2.0"
] | 1 | 2019-10-10T20:58:44.000Z | 2019-10-10T20:58:44.000Z | aws-cpp-sdk-transcribestreaming/include/aws/transcribestreaming/model/AudioEvent.h | novaquark/aws-sdk-cpp | a0969508545bec9ae2864c9e1e2bb9aff109f90c | [
"Apache-2.0"
] | null | null | null | aws-cpp-sdk-transcribestreaming/include/aws/transcribestreaming/model/AudioEvent.h | novaquark/aws-sdk-cpp | a0969508545bec9ae2864c9e1e2bb9aff109f90c | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/transcribestreaming/TranscribeStreamingService_EXPORTS.h>
#include <aws/core/utils/Array.h>
#include <utility>
namespace Aws
{
namespace TranscribeStreamingService
{
namespace Model
{
/**
* <p>Provides a wrapper for the audio chunks that you are sending.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/transcribe-streaming-2017-10-26/AudioEvent">AWS
* API Reference</a></p>
*/
class AWS_TRANSCRIBESTREAMINGSERVICE_API AudioEvent
{
public:
AudioEvent() = default;
AudioEvent(Aws::Vector<unsigned char>&& value) { m_audioChunk = std::move(value); }
/**
* <p>An audio blob that contains the next part of the audio that you want to
* transcribe.</p>
*/
inline const Aws::Vector<unsigned char>& GetAudioChunk() const { return m_audioChunk; }
/**
* <p>An audio blob that contains the next part of the audio that you want to
* transcribe.</p>
*/
inline Aws::Vector<unsigned char>&& GetAudioChunkWithOwnership() { return std::move(m_audioChunk); }
/**
* <p>An audio blob that contains the next part of the audio that you want to
* transcribe.</p>
*/
inline void SetAudioChunk(const Aws::Vector<unsigned char>& value) { m_audioChunkHasBeenSet = true; m_audioChunk = value; }
/**
* <p>An audio blob that contains the next part of the audio that you want to
* transcribe.</p>
*/
inline void SetAudioChunk(Aws::Vector<unsigned char>&& value) { m_audioChunkHasBeenSet = true; m_audioChunk = std::move(value); }
/**
* <p>An audio blob that contains the next part of the audio that you want to
* transcribe.</p>
*/
inline AudioEvent& WithAudioChunk(const Aws::Vector<unsigned char>& value) { SetAudioChunk(value); return *this;}
/**
* <p>An audio blob that contains the next part of the audio that you want to
* transcribe.</p>
*/
inline AudioEvent& WithAudioChunk(Aws::Vector<unsigned char>&& value) { SetAudioChunk(std::move(value)); return *this;}
private:
Aws::Vector<unsigned char> m_audioChunk;
bool m_audioChunkHasBeenSet;
};
} // namespace Model
} // namespace TranscribeStreamingService
} // namespace Aws
| 33.619048 | 133 | 0.690864 | [
"vector",
"model"
] |
a6b7e978fd10b277ad5ee53766d9717e1be81dab | 3,404 | h | C | include/sp2/script/bindingClass.h | daid/SeriousProton2 | 6cc9c2291ea63ffc82427ed82f51a84611f7f45c | [
"MIT"
] | 8 | 2018-01-26T20:21:08.000Z | 2021-08-30T20:28:43.000Z | include/sp2/script/bindingClass.h | daid/SeriousProton2 | 6cc9c2291ea63ffc82427ed82f51a84611f7f45c | [
"MIT"
] | 7 | 2018-10-28T14:52:25.000Z | 2020-12-28T19:59:04.000Z | include/sp2/script/bindingClass.h | daid/SeriousProton2 | 6cc9c2291ea63ffc82427ed82f51a84611f7f45c | [
"MIT"
] | 7 | 2017-05-27T16:33:37.000Z | 2022-02-18T14:07:17.000Z | #ifndef SP2_SCRIPT_BINDING_CLASS_H
#define SP2_SCRIPT_BINDING_CLASS_H
#include <sp2/pointer.h>
#include <sp2/string.h>
#include <sp2/script/luaBindings.h>
#include <sp2/logging.h>
#include <sp2/attributes.h>
namespace sp {
namespace script {
class Callback;
class BindingObject;
class BindingClass
{
public:
template<class TYPE, typename RET, typename... ARGS> void bind(const string& name, RET(TYPE::*func)(ARGS...))
{
typedef RET(TYPE::*FT)(ARGS...);
FT* f = reinterpret_cast<FT*>(lua_newuserdata(L, sizeof(FT)));
*f = func;
lua_pushvalue(L, object_table_index); //push the table of this object
lua_pushcclosure(L, &script::callMember<TYPE, RET, ARGS...>, 2);
lua_setfield(L, function_table_index, name.c_str());
}
template<class TYPE, typename RET, typename... ARGS> void bind(const string& name, RET(TYPE::*func)(ARGS...) const)
{
typedef RET(TYPE::*FT)(ARGS...) const;
FT* f = reinterpret_cast<FT*>(lua_newuserdata(L, sizeof(FT)));
*f = func;
lua_pushvalue(L, object_table_index); //push the table of this object
lua_pushcclosure(L, &script::callConstMember<TYPE, RET, ARGS...>, 2);
lua_setfield(L, function_table_index, name.c_str());
}
void bind(const string& name, sp::script::Callback& callback);
template<class TYPE> void bindProperty(const string& name, TYPE& t)
{
lua_newtable(L);
lua_pushlightuserdata(L, &t);
lua_pushcclosure(L, &script::getProperty<TYPE>, 1);
lua_setfield(L, -2, "get");
lua_pushlightuserdata(L, &t);
lua_pushcclosure(L, &script::setProperty<TYPE>, 1);
lua_setfield(L, -2, "set");
lua_setfield(L, function_table_index, name.c_str());
}
template<class OBJECT_TYPE, typename PROPERTY_TYPE> void bindProperty(const string& name, PROPERTY_TYPE(OBJECT_TYPE::*getter)() const, void(OBJECT_TYPE::*setter)(PROPERTY_TYPE))
{
typedef PROPERTY_TYPE(OBJECT_TYPE::*GET_FT)() const;
typedef void(OBJECT_TYPE::*SET_FT)(PROPERTY_TYPE);
lua_newtable(L);
GET_FT* get_ptr = reinterpret_cast<GET_FT*>(lua_newuserdata(L, sizeof(GET_FT)));
*get_ptr = getter;
lua_pushvalue(L, object_table_index); //push the table of this object
lua_pushcclosure(L, &script::callMember<OBJECT_TYPE, PROPERTY_TYPE>, 2);
lua_setfield(L, -2, "get");
SET_FT* set_ptr = reinterpret_cast<SET_FT*>(lua_newuserdata(L, sizeof(SET_FT)));
*set_ptr = setter;
lua_pushvalue(L, object_table_index); //push the table of this object
lua_pushcclosure(L, &script::callMember<OBJECT_TYPE, void, PROPERTY_TYPE>, 2);
lua_setfield(L, -2, "set");
lua_setfield(L, function_table_index, name.c_str());
}
private:
BindingClass(lua_State* L, int object_table_index, int function_table_index)
: L(L), object_table_index(object_table_index), function_table_index(function_table_index) {}
lua_State* L;
int object_table_index;
int function_table_index;
friend void lazyLoading(int table_index, lua_State* L);
};
}//namespace script
using ScriptBindingClass SP2_DEPRECATED("Use sp::script::BindingClass instead") = script::BindingClass;
}//namespace sp
#include <sp2/script/callback.h>
#endif//SP2_SCRIPT_BINDING_OBJECT_H
| 35.831579 | 181 | 0.668331 | [
"object"
] |
a6b9916de9bc1de18bfbb4d53bffaaee67364f75 | 2,981 | h | C | src/bvh/bvh_build.h | pyrochlore/cycles | 8ffcbb723843ff0544a4898308c8f4ef9f4ded21 | [
"Apache-2.0"
] | 1 | 2015-03-15T00:17:33.000Z | 2015-03-15T00:17:33.000Z | src/bvh/bvh_build.h | pyrochlore/cycles | 8ffcbb723843ff0544a4898308c8f4ef9f4ded21 | [
"Apache-2.0"
] | null | null | null | src/bvh/bvh_build.h | pyrochlore/cycles | 8ffcbb723843ff0544a4898308c8f4ef9f4ded21 | [
"Apache-2.0"
] | null | null | null | /*
* Adapted from code copyright 2009-2010 NVIDIA Corporation
* Modifications Copyright 2011, Blender 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.
*/
#ifndef __BVH_BUILD_H__
#define __BVH_BUILD_H__
#include <float.h>
#include "bvh.h"
#include "bvh_binning.h"
#include "util_boundbox.h"
#include "util_task.h"
#include "util_vector.h"
CCL_NAMESPACE_BEGIN
class BVHBuildTask;
class BVHParams;
class InnerNode;
class Mesh;
class Object;
class Progress;
/* BVH Builder */
class BVHBuild
{
public:
/* Constructor/Destructor */
BVHBuild(
const vector<Object*>& objects,
vector<int>& prim_type,
vector<int>& prim_index,
vector<int>& prim_object,
const BVHParams& params,
Progress& progress);
~BVHBuild();
BVHNode *run();
protected:
friend class BVHMixedSplit;
friend class BVHObjectSplit;
friend class BVHSpatialSplit;
friend class BVHBuildTask;
/* adding references */
void add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh, int i);
void add_reference_object(BoundBox& root, BoundBox& center, Object *ob, int i);
void add_references(BVHRange& root);
/* building */
BVHNode *build_node(const BVHRange& range, int level);
BVHNode *build_node(const BVHObjectBinning& range, int level);
BVHNode *create_leaf_node(const BVHRange& range);
BVHNode *create_object_leaf_nodes(const BVHReference *ref, int start, int num);
bool range_within_max_leaf_size(const BVHRange& range);
/* threads */
enum { THREAD_TASK_SIZE = 4096 };
void thread_build_node(InnerNode *node, int child, BVHObjectBinning *range, int level);
thread_mutex build_mutex;
/* progress */
void progress_update();
/* tree rotations */
void rotate(BVHNode *node, int max_depth);
void rotate(BVHNode *node, int max_depth, int iterations);
/* objects and primitive references */
vector<Object*> objects;
vector<BVHReference> references;
int num_original_references;
/* output primitive indexes and objects */
vector<int>& prim_type;
vector<int>& prim_index;
vector<int>& prim_object;
/* build parameters */
BVHParams params;
/* progress reporting */
Progress& progress;
double progress_start_time;
size_t progress_count;
size_t progress_total;
size_t progress_original_total;
/* spatial splitting */
float spatial_min_overlap;
vector<BoundBox> spatial_right_bounds;
BVHSpatialBin spatial_bins[3][BVHParams::NUM_SPATIAL_BINS];
/* threads */
TaskPool task_pool;
};
CCL_NAMESPACE_END
#endif /* __BVH_BUILD_H__ */
| 24.841667 | 88 | 0.754445 | [
"mesh",
"object",
"vector"
] |
a6c8699b5b74ff8f785dbf43ef13ac80a4ba7559 | 1,743 | h | C | src/public/src/FM7/util/lib/fm7lib.h | rothberg-cmu/rothberg-run | a42df5ca9fae97de77753864f60d05295d77b59f | [
"MIT"
] | 1 | 2019-08-10T00:24:09.000Z | 2019-08-10T00:24:09.000Z | src/public/src/FM7/util/lib/fm7lib.h | rothberg-cmu/rothberg-run | a42df5ca9fae97de77753864f60d05295d77b59f | [
"MIT"
] | null | null | null | src/public/src/FM7/util/lib/fm7lib.h | rothberg-cmu/rothberg-run | a42df5ca9fae97de77753864f60d05295d77b59f | [
"MIT"
] | 2 | 2019-05-01T03:11:10.000Z | 2019-05-01T03:30:35.000Z | #ifndef FM7LIB_IS_INCLUDED
#define FM7LIB_IS_INCLUDED
/* { */
#include <vector>
#include <string>
class FM7File
{
public:
enum
{
FTYPE_BASIC_BINARY,
FTYPE_BASIC_ASCII,
FTYPE_BINARY,
FTYPE_DATA_BINARY, // I don't know if such a data type exists. This constant is for more like a reservation in the future. If the future exists!!
FTYPE_DATA_ASCII,
FTYPE_UNKNOWN
};
std::string fName;
void CleanUp(void);
static int DecodeFMHeaderFileType(unsigned char byte10,unsigned char byte11);
static const char *FileTypeToString(int fType);
/*! Returns a default FM-File extension for file type.
*/
static const char *GetDefaultFMFileExtensionForType(int fType);
};
class FM7BinaryFile : public FM7File
{
public:
std::string fName;
unsigned int storeAddr,execAddr;
std::vector <unsigned char> dat;
FM7BinaryFile();
~FM7BinaryFile();
void CleanUp(void);
bool DecodeSREC(const std::vector <std::string> &srec);
bool DecodeSREC(const char *const srec[]);
bool Decode2B0(const std::vector <unsigned char> &dat,bool verbose=false);
/*! Create a byte array for T77.
The differencefrom a byte array for D77 is it doesn't have a 0x1A in the end.
*/
std::vector <unsigned char> MakeByteArrayForT77(void) const;
};
////////////////////////////////////////////////////////////
class SRECDecoder
{
private:
unsigned char dat[65536],used[65536];
public:
unsigned int storeAddr,length,execAddr;
SRECDecoder();
bool Decode(const std::vector <std::string> &fileDat);
bool Decode(const char *const fileDat[]);
std::vector <unsigned char> data(void) const;
private:
bool DecodeOneLine(const char str[]);
bool PostProc(void);
std::vector <unsigned char> GetByteData(const char str[]) const;
};
/* } */
#endif
| 22.636364 | 149 | 0.708548 | [
"vector"
] |
a6d63b548ba3022fe347563173946b7b70589e93 | 4,860 | c | C | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56996_a0/bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56996_a0/bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56996_a0/bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*******************************************************************************
*
* DO NOT EDIT THIS FILE!
* This file is auto-generated by fltg from Logical Table mapping files.
*
* Tool: $SDK/INTERNAL/fltg/bin/fltg
*
* Edits to this file will be lost when it is regenerated.
*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
/* Logical Table Adaptor for component bcmltx */
/* Handler: bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler */
#include <bcmlrd/bcmlrd_types.h>
#include <bcmltd/chip/bcmltd_id.h>
#include <bcmltx/bcmltx_field_demux.h>
#include <bcmdrd/chip/bcm56996_a0_enum.h>
#include <bcmlrd/chip/bcm56996_a0/bcm56996_a0_lrd_xfrm_field_desc.h>
extern const bcmltd_field_desc_t
bcm56996_a0_lrd_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_src_field_desc_s0[];
static const bcmltd_field_desc_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_dst_field_desc[2] = {
{
.field_id = BCMLTD_INTERNAL_FIELD_BASE + 57,
.field_idx = 0,
.minbit = 70,
.maxbit = 95,
.entry_idx = 0,
.sym = "L3_TUNNEL_QUADm.IPV6::SIP_LWR_90f[89:64]",
.reserved = 0
},
{
.field_id = IPV6v_SIP_UPR_38f,
.field_idx = 0,
.minbit = 243,
.maxbit = 280,
.entry_idx = 0,
.reserved = 0
},
};
static const
bcmltd_field_list_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_src_list_s0 = {
.field_num = 2,
.field_array = bcm56996_a0_lrd_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_src_field_desc_s0
};
static const bcmltd_field_list_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_dst_list_d0 = {
.field_num = 2,
.field_array = bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_dst_field_desc
};
static const uint32_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_transform_src_s0[1] = {
TNL_IPV6_DECAP_EMt_SRC_IPV6u_UPPERf,
};
static const uint32_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_transform_dst_d0[2] = {
BCMLTD_INTERNAL_FIELD_BASE + 57,
IPV6v_SIP_UPR_38f,
};
static const bcmltd_generic_arg_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_comp_data = {
.sid = TNL_IPV6_DECAP_EMt,
.values = 0,
.value = NULL,
.user_data = NULL
};
static const bcmltd_transform_arg_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler_fwd_arg_s0_d0 = {
.values = 0,
.value = NULL,
.tables = 0,
.table = NULL,
.fields = 1,
.field = bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_transform_src_s0,
.field_list = &bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_src_list_s0,
.rfields = 2,
.rfield = bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_transform_dst_d0,
.rfield_list = &bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_dst_list_d0,
.comp_data = &bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_comp_data
};
static const bcmltd_transform_arg_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler_rev_arg_s0_d0 = {
.values = 0,
.value = NULL,
.tables = 0,
.table = NULL,
.fields = 2,
.field = bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_transform_dst_d0,
.field_list = &bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_dst_list_d0,
.rfields = 1,
.rfield = bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_transform_src_s0,
.rfield_list = &bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_src_list_s0,
.comp_data = &bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_comp_data
};
const bcmltd_xfrm_handler_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler_fwd_s0_d0 = {
.transform = bcmltx_field_demux_transform,
.arg = &bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler_fwd_arg_s0_d0
};
const bcmltd_xfrm_handler_t
bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler_rev_s0_d0 = {
.transform = bcmltx_field_mux_transform,
.arg = &bcm56996_a0_lta_bcmltx_field_demux_tnl_ipv6_decap_emt_src_ipv6u_upperf_0_xfrm_handler_rev_arg_s0_d0
};
| 39.836066 | 134 | 0.770165 | [
"transform"
] |
a6e6c385f5d54dcb2c10257c135c49badeba978d | 767 | h | C | src/solver/ark/mass.h | Abhisheknishant/Flint | 441beab56d21e4069b858ae6588fa0fa3084d722 | [
"MIT"
] | 9 | 2015-09-07T05:33:50.000Z | 2022-01-07T03:35:08.000Z | src/solver/ark/mass.h | Abhisheknishant/Flint | 441beab56d21e4069b858ae6588fa0fa3084d722 | [
"MIT"
] | 27 | 2018-03-19T02:10:06.000Z | 2021-12-09T08:20:51.000Z | src/solver/ark/mass.h | Abhisheknishant/Flint | 441beab56d21e4069b858ae6588fa0fa3084d722 | [
"MIT"
] | 6 | 2019-03-26T00:32:03.000Z | 2021-03-11T23:21:42.000Z | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- vim:set ts=4 sw=4 sts=4 noet: */
#ifndef FLINT_SOLVER_ARK_MASS_H_
#define FLINT_SOLVER_ARK_MASS_H_
#include <memory>
#include <utility>
#include <vector>
#include <arkode/arkode_direct.h>
namespace flint {
class Processor;
namespace solver {
namespace ark {
class MassExecutor;
class Mmdm;
class Mass {
public:
Mass(const Mass &) = delete;
Mass &operator=(const Mass &) = delete;
Mass(Processor *processor, Mmdm *mmdm);
~Mass();
bool Evaluate(double *data);
void Write(const double *data, DlsMat M);
private:
Processor *processor_;
Mmdm *mmdm_;
std::unique_ptr<MassExecutor> executor_;
std::unique_ptr<intptr_t[]> ir_;
std::unique_ptr<double[]> tmp_;
};
}
}
}
#endif
| 16.319149 | 107 | 0.702738 | [
"vector"
] |
a6ec99edbdd4c0643bd194fb5132160d40fbca7a | 6,434 | h | C | JIT Compiler.h | ncortiz/Cool-gists | ed824e6954a19f936a361231a0cdd67a61bc521e | [
"MIT"
] | null | null | null | JIT Compiler.h | ncortiz/Cool-gists | ed824e6954a19f936a361231a0cdd67a61bc521e | [
"MIT"
] | null | null | null | JIT Compiler.h | ncortiz/Cool-gists | ed824e6954a19f936a361231a0cdd67a61bc521e | [
"MIT"
] | null | null | null | /*
This code is a simple example of a program that can encode x86 instructions and run them on runtime (Just in time compiler technically).
Code below works (I think) and generates x86 instructions for a bunch of simple math operations and puts them in virtual memory space
of function which then gets called with one of the parameters being a pointer so we can retrieve the result (which should be 8)
*/
//Mit License
//Copyright © 2020 Nicolas Ortiz
#include <stdio.h>
#include <windows.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <utility>
typedef unsigned char byte;
//Everything is written around Win32 VirtualAllocEx function (see down below) this function can allow us to allocate data onto virtual memory and write/read onto/from it.
//Then we can cast a pointer to it into a function ptr and call it like a function.
/* By inserting x86 machine code into the virtual address space of a function in Windows
we can use the function to cause the CPU to run whatever instructions we want (to some extent).
This file contains a WIP program that compiles into machine code which is inserted
into the adress space of a function (using Win32 api) and then the function is called,
running the code. This allows us to compile and run machine code on realtime hence JIT.
It has a bunch of enums and methods for encoding x86-64 which also work for standalones (with a bit more work)
and it also has a pointer to the virtual adress space of the function which can then be called.
In its current state it is able to compile programs with math expressions but cmp loops don't work.*/
/* Some of the references i used
http://ref.x86asm.net/#column_flds
http://www.c-jump.com/CIS77/reference/ISA/index.html
http://ref.x86asm.net/coder64.html#x0FA1
https://gist.github.com/mikesmullin/6259449
http://www.c-jump.com/CIS77/CPU/x86/lecture.html#X77_0140_encoding_add_ecx_eax
http://www.c-jump.com/CIS77/CPU/x86/lecture.html
*/
class JITEmitter
{
public:
bool init()
{
buff = (byte*)VirtualAllocEx(GetCurrentProcess(), 0, 1 << 16, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
p = buff;
if (buff == 0)
return false;
return true;
}
enum mod
{
IndirectSIBNoDispDispOnly = 0b00,
OneByteSignedDisp = 0b01,
FourByteSignedDisp = 0b10,
RegAdressing = 0b11
};
enum reg
{
al = 0b000,
cl = 0b001,
dl = 0b010,
bl = 0b011,
ah = 0b100,
ch = 0b101,
dh = 0b110,
bh = 0b111,
ax = 0b000,
cx = 0b001,
dx = 0b010,
bx = 0b011,
sp = 0b100,
bp = 0b101,
si = 0b110,
di = 0b111,
eax = 0b000,
ecx = 0b001,
edx = 0b010,
ebx = 0b011,
esp = 0b100,
ebp = 0b101,
esi = 0b110,
edi = 0b111
};
enum op_modregrm
{
imul = 0xF7,
idiv = 0xF6,
xor_ = 0x33,
cmp = 0x3B,
add = 0x3,
sub = 0x2b,
jmp = 0xff
};
enum ext_modregrm
{
imul_ext = 5,
idiv_ext = 7,
xor_ext = 0,
cmp_ext = 0,
add_ext = 0,
sub_ext = 0,
jmp_ext = 4
};
enum op_reg
{
swap_reg_eax = 0x90,
push_reg = 0x50,
pop_reg = 0x58
};
enum op_ptr
{
move_from_eax = 0xA3,
move_to_eax = 0xA1
};
enum op
{
swap_edx_eax = 0x92
};
void emit_instr_modregrm(uint8_t op, uint8_t ext, reg src, reg dst)
{
*p++ = op;
*p++ = (RegAdressing & 0x7) << 6 | ((src + ext) & 0x7) << 3 | dst & 0x7;
}
void emit_instr_modregrm(op_modregrm op, ext_modregrm ext, reg src, reg dst)
{
*p++ = op;
*p++ = (RegAdressing & 0x7) << 6 | ((src + ext) & 0x7) << 3 | dst & 0x7;
}
void emit_instr_modregrm(op_modregrm op, ext_modregrm ext, reg src)
{
*p++ = op;
*p++ = (RegAdressing & 0x7) << 6 | ((src + ext) & 0x7) << 3;
}
void emit_instr_reg(op_reg op, reg r)
{
*p++ = op + r;
}
void emit_instr_ptr(op_ptr op, void* ptr, size_t sz_ptr)
{
*p++ = op;
(void*&)p[0] = ptr; p += sz_ptr;
}
void emit(byte b)
{
*p++ = b;
}
void pre()
{
*p++ = 0x50; // push eax
*p++ = 0x52; // push edx
}
void post()
{
*p++ = 0x5A; // pop edx
*p++ = 0x58; // pop eax
*p++ = 0xC3; // ret
}
void execute()
{
//cast buff into func ptr and call it
union funcptr {
void(*x)();
byte* y;
} func;
func.y = buff;
func.x();
}
byte* buff;
byte* p;
private:
};
int main()
{
JITEmitter emitter;
if (!emitter.init())
return -1;
int arg1;
int arg2;
int res1;
int arg3;
emitter.pre(); //function prologue
emitter.emit_instr_ptr(emitter.move_to_eax, &arg3, sizeof(int*)); //mov eax, arg3
emitter.emit_instr_reg(emitter.push_reg, emitter.eax); //push eax
emitter.emit_instr_ptr(emitter.move_to_eax, &arg2, sizeof(int*)); //mov eax, arg2
emitter.emit_instr_reg(emitter.push_reg, emitter.eax); //push eax
emitter.emit_instr_ptr(emitter.move_to_eax, &arg1, sizeof(int*)); //mov eax, arg1
emitter.emit_instr_reg(emitter.push_reg, emitter.eax); //push eax
emitter.emit_instr_reg(emitter.pop_reg, emitter.eax); //pop eax(arg3 into eax)
emitter.emit_instr_reg(emitter.pop_reg, emitter.edx); //pop edx(arg2 into edx)
emitter.emit_instr_modregrm(emitter.imul, emitter.imul_ext, emitter.eax, emitter.edx); //imul eax, edx (into eax)
emitter.emit_instr_reg(emitter.pop_reg, emitter.edx); //pop edx(arg1 into edx)
emitter.emit_instr_modregrm(emitter.idiv, emitter.idiv_ext, emitter.eax, emitter.edx); //idiv eax, edx (into eax)
emitter.emit_instr_ptr(emitter.move_to_eax, &arg2, sizeof(int*)); //move arg2 into eax
emitter.emit_instr_reg(emitter.push_reg, emitter.eax); //push eax
emitter.emit_instr_ptr(emitter.move_to_eax, &arg1, sizeof(int*)); //move arg1 into eax
emitter.emit_instr_reg(emitter.swap_reg_eax, emitter.edx); //swap edx, eax
emitter.emit_instr_ptr(emitter.move_to_eax, &arg2, sizeof(int*)); //move eax, arg2
emitter.emit_instr_modregrm(emitter.imul, emitter.imul_ext, emitter.eax, emitter.edx); //imul eax, edx
emitter.emit_instr_reg(emitter.swap_reg_eax, emitter.edx); //swap eax, edx
emitter.emit_instr_ptr(emitter.move_to_eax, &arg3, sizeof(int*)); //mov eax, arg3
emitter.emit_instr_reg(emitter.swap_reg_eax, emitter.edx); //swap eax, edx
emitter.emit_instr_modregrm(emitter.idiv, emitter.idiv_ext, emitter.eax, emitter.edx); //idiv eax, edx (into eax)
emitter.emit_instr_reg(emitter.pop_reg, emitter.eax); //pop eax (result into eax)
emitter.emit_instr_ptr(emitter.move_from_eax, &res1, sizeof(long*)); //mov ptr, eax (from eax into ptr)
emitter.post(); //function epilogue
arg1 = 8; arg2 = 8; arg3 = 2; res1 = 0;
emitter.execute();
printf("=%i\n", res1);
}
| 26.154472 | 171 | 0.692104 | [
"vector"
] |
a6edf8cc901df2a6f4d0a2bd10e56f95bb108707 | 2,906 | h | C | common/cdna/GencodeGFFReader.h | mchaisso/blasr | 044b97e6e581a936d93e8226b25ac44aebf3c9da | [
"BSD-3-Clause"
] | 17 | 2015-05-05T12:41:15.000Z | 2021-03-24T05:50:58.000Z | common/cdna/GencodeGFFReader.h | EichlerLab/blasr | c9bced1fedfb026b4992e2b49e4ffa0f107819ea | [
"BSD-3-Clause"
] | 6 | 2015-07-07T14:01:00.000Z | 2021-04-17T07:53:12.000Z | common/cdna/GencodeGFFReader.h | EichlerLab/blasr | c9bced1fedfb026b4992e2b49e4ffa0f107819ea | [
"BSD-3-Clause"
] | 10 | 2015-01-22T19:27:40.000Z | 2022-02-17T06:43:01.000Z | #ifndef CDNA_GENCODE_GFF_READER_H_
#define CDNA_GENCODE_GFF_READER_H_
#include "GencodeGFFEntry.h"
#include "utils/StringUtils.h"
template<typename T_Value>
void StringToValue(string valueStr, T_Value &value) {
stringstream strm(valueStr);
strm >> value;
}
void StringToValue(string valueStr, string &value) {
//
// The string value just has extra quotes around it.
//
// Make sure the quotes are there.
if (valueStr.size() < 2) {
value = "";
return;
}
if (valueStr[0] != '"' or valueStr[valueStr.size()-1] != '"') {
value = "";
return;
}
value = valueStr.substr(1,valueStr.size()-2);
}
void KWStringToPair(string &kwPair, string &key, string &value) {
stringstream strm(kwPair);
strm >> key >> value;
}
bool ReadGencodeGFFLine(istream &in, GencodeGFFEntry &entry) {
// Here is a sample line:
// chr1 HAVANA exon 35721 36073 . - . gene_id "ENSG00000237613.2"; transcript_id "ENST00000461467.1"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "FAM138A"; transcript_type "processed_transcript"; transcript_status "KNOWN"; transcript_name "FAM138A-002"; level 2; havana_gene "OTTHUMG00000000960.1"; havana_transcript "OTTHUMT00000002843.1";
string line;
getline(in, line);
stringstream strm(line);
if (! (strm >> entry.chr >> entry.annotationSource >> entry.genomicLocusType >> entry.start >> entry.end
>> entry.scoreNOTUSED >> entry.strand >> entry.phase) ) {
return false;
}
string kwPairsLine;
getline(strm, kwPairsLine);
vector<string> kwPairs;
ParseSeparatedList(kwPairsLine, kwPairs, ';');
int i;
for (i = 0; i < kwPairs.size(); i++) {
string key, value;
KWStringToPair(kwPairs[i], key, value);
if (key == "gene_id") {
StringToValue(value, entry.geneId);
}
else if (key == "transcript_id") {
StringToValue(value, entry.transcriptId);
}
else if (key == "gene_type") {
StringToValue(value, entry.geneType);
}
else if (key == "gene_status") {
StringToValue(value, entry.geneStatus);
}
else if (key == "gene_name") {
StringToValue(value, entry.geneName);
}
else if (key == "transcript_type") {
StringToValue(value, entry.transcriptType);
}
else if (key == "transcript_status") {
StringToValue(value, entry.transcriptStatus);
}
else if (key == "transcript_name") {
StringToValue(value, entry.transcriptName);
}
else if (key == "level") {
StringToValue(value, entry.level);
}
else if (key == "havana_gene" or
key == "havana_transcript" or
key == "tag" or
key == "ccdsid" or
key == "ont") {
}
else {
cout <<" ERROR. Keyword-value " << kwPairs[i] << " is not supported." << endl;
cout << "The offending line is " << line << endl;
return false;
}
}
return true;
}
#endif
| 28.772277 | 359 | 0.632485 | [
"vector"
] |
a6f2da4c6a2866c66b62ccebf9575bbf383c6544 | 2,434 | h | C | laneDetection.h | xiaorun2345/laneDetction | 5f3aed996542c4eb2ab33ed7ca7a0b16bc8618d6 | [
"MIT"
] | null | null | null | laneDetection.h | xiaorun2345/laneDetction | 5f3aed996542c4eb2ab33ed7ca7a0b16bc8618d6 | [
"MIT"
] | null | null | null | laneDetection.h | xiaorun2345/laneDetction | 5f3aed996542c4eb2ab33ed7ca7a0b16bc8618d6 | [
"MIT"
] | null | null | null | #pragma once
#include <opencv2/opencv.hpp>
#include <vector>
#include <algorithm>
#include <Eigen/Dense>
#include "math.h"
using namespace cv;
using namespace std;
using namespace Eigen;
class laneDetection
{
private:
Mat perspectiveMatrix;
Mat oriImage; //The original input image.
Mat edgeImage; // The result of applying canny edge detection.
Mat warpEdgeImage;
Mat warpOriImage;
vector<Mat> imageChannels;
Mat RedBinary;
Mat mergeImage;
Mat mergeImageRGB;
Mat histImage; //Histogram visualization.
Mat maskImage; //The curve image used to blend to the original image.
Mat maskImageWarp;
Mat finalResult;
vector<int> histogram; //Histogram of the detected features
vector<Point2f> laneL;
vector<Point2f> laneR;
vector<Point2f> curvePointsL;
vector<Point2f> curvePointsR;
int laneLcount;
int laneRcount;
int midPoint; //The mid position of the view.
int midHeight;
int leftLanePos; //The detected left lane boundary position.
int rightLanePos; //The detected right lane boundary position.
short initRecordCount; // To record the number of times of executions in the first 5 frames.
const int blockNum; //Number of windows per line.
int stepY; //Window moving step.
const int windowSize; //Window Size (Horizontal).
Vector3d curveCoefL; //The coefficients of the curve (left).
Vector3d curveCoefR; //The coefficients of the curve (left).
Vector3d curveCoefRecordL[5]; //To keep the last five record to smooth the current coefficients (left).
Vector3d curveCoefRecordR[5]; //To keep the last five record to smooth the current coefficients (right).
int recordCounter;
bool failDetectFlag; // To indicate whether the road marks is detected succesfully.
void calHist();
void boundaryDetection();
void laneSearch(const int& lanePos, vector<Point2f>& _line, int& lanecount, vector<Point2f>& curvePoints, char dir);
bool laneCoefEstimate();
void laneFitting();
public:
laneDetection(Mat _oriImage, Mat _perspectiveMatrix);
~laneDetection();
void laneDetctAlgo();
Mat getEdgeDetectResult();
Mat getWarpEdgeDetectResult();
Mat getRedChannel();
Mat getRedBinary();
Mat getMergeImage();
Mat getHistImage();
Mat getMaskImage();
Mat getWarpMask();
Mat getFinalResult();
float getLaneCenterDist();
void setInputImage(Mat& image);
};
| 34.771429 | 120 | 0.716927 | [
"vector"
] |
a6fa7bf4a1babd696e09bd8fa9395f4755c3bdaa | 4,394 | h | C | src/ColourPalette.h | James-Oldfield/ofxAlbers | 6ce7c08838f478b43c039b60b3fc03d1dfb6a6f4 | [
"MIT"
] | 1 | 2019-08-06T13:01:40.000Z | 2019-08-06T13:01:40.000Z | src/ColourPalette.h | james-oldfield/ofxAlbers | 6ce7c08838f478b43c039b60b3fc03d1dfb6a6f4 | [
"MIT"
] | null | null | null | src/ColourPalette.h | james-oldfield/ofxAlbers | 6ce7c08838f478b43c039b60b3fc03d1dfb6a6f4 | [
"MIT"
] | null | null | null | /**
* @class ColourPalette
* @brief Top of the inheritance chain, describes a colour palette.
* @author James Oldfield.
*/
#ifndef ____ColourPalette__
#define ____ColourPalette__
#include "ofMain.h"
using ColVec = vector<ofColor>;
using SharedPtrColVec = shared_ptr<ColVec>;
class ColourPalette {
protected:
SharedPtrColVec colours; //!< stores the of representation of the generated colours.
ofColor seedColour = ofColor(255, 255, 255); //!< the base colour with which to generate a scheme from.
public:
virtual ~ColourPalette() {};
/**
* @brief Constructor used to instantiate member objects, viz. 'colours'.
*/
ColourPalette();
/**
* @brief ABS's copy constructor. Creates a 'unique' shared pointer from the old one
* as we don't want it to point to the previous instantiation's 'colours'.
*/
ColourPalette(const ColourPalette & old): colours(make_shared<ColVec>(*old.colours)) {}
/**
* @brief ABS's assignment operator. Creates a 'unique' shared pointer from the old one
* as we don't want it to point to the previous instantiation's 'colours'.
*/
void operator = (const ColourPalette & old) {
colours = make_shared<ColVec>(*old.colours);
}
/**
* @brief Generic colour scheme getter. Returns a shared pointer to the colour scheme itself.
* @return a shared pointer to the vector of ofColours.
*/
SharedPtrColVec getPalette() const;
/**
* @brief Used to sort the palette of colours based on chosen channel.
* @param channel The channel to sort by.
*/
void sortPalette(string channel = "hue");
/**
* @brief Used to darken a colour scheme by a given percentage.
* @param percent The percentage with which to change the colour by.
*/
void darken(unsigned int percent);
/**
* @brief Used to lighten a colour scheme by a given percentage.
* @param percent The percentage with which to change the colour by.
*/
void lighten(unsigned int percent);
/**
* @brief Used to saturate a colour scheme by a given percentage.
* @param percent The percentage with which to change the colour by.
*/
void saturate(unsigned int percent);
/**
* @brief Used to desaturate a colour scheme by a given percentage.
* @param percent The percentage with which to change the colour by.
*/
void desaturate(unsigned int percent);
/**
* @brief Used to adjust the hue by a given percentage - n.b. can be a negative value.
* @param percent The percentage with which to change the colour by.
*/
void adjustHue(int percent);
/**
* STATIC COLOUR OPERATION FUNCTIONS
*/
/**
* @brief Used to darken a colour by a given percentage.
* @param col A reference to the colour to be altered.
* @param percent The percentage with which to change the colour by.
* @return The new colour, post-operation.
*/
static ofColor darken(ofColor & col, unsigned int percent);
/**
* @brief Used to lighten a colour by a given percentage.
* @param col A reference to the colour to be altered.
* @param percent The percentage with which to change the colour by.
* @return The new colour, post-operation.
*/
static ofColor lighten(ofColor & col, unsigned int percent);
/**
* @brief Used to saturate a colour by a given percentage.
* @param col A reference to the colour to be altered.
* @param percent The percentage with which to change the colour by.
* @return The new colour, post-operation.
*/
static ofColor saturate(ofColor & col, unsigned int percent);
/**
* @brief Used to desaturate a colour by a given percentage.
* @param col A reference to the colour to be altered.
* @param percent The percentage with which to change the colour by.
* @return The new colour, post-operation.
*/
static ofColor desaturate(ofColor & col, unsigned int percent);
/**
* @brief Used to adjust the hue by a given percentage - n.b. can be a negative value.
* @param col A reference to the colour to be altered.
* @param percent The percentage with which to change the colour by.
* @return The new colour, post-operation.
*/
static ofColor adjustHue(ofColor & col, int percent);
};
#endif /* defined(____ColourPalette__) */
| 33.8 | 107 | 0.668867 | [
"vector"
] |
470060a3238cd1060d2344d2227e434c5248c0e9 | 5,786 | h | C | hybridse/src/codegen/type_ir_builder.h | jasleon/OpenMLDB | 2f85d12cd8dadd3a1ec822e1f591632341f3b23f | [
"Apache-2.0"
] | 2,659 | 2021-06-07T12:59:15.000Z | 2022-03-30T15:29:37.000Z | hybridse/src/codegen/type_ir_builder.h | jasleon/OpenMLDB | 2f85d12cd8dadd3a1ec822e1f591632341f3b23f | [
"Apache-2.0"
] | 1,396 | 2021-05-28T09:50:13.000Z | 2022-03-31T16:37:49.000Z | hybridse/src/codegen/type_ir_builder.h | jasleon/OpenMLDB | 2f85d12cd8dadd3a1ec822e1f591632341f3b23f | [
"Apache-2.0"
] | 499 | 2021-05-31T07:36:48.000Z | 2022-03-31T15:10:12.000Z | /*
* Copyright 2021 4Paradigm
*
* 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 HYBRIDSE_SRC_CODEGEN_TYPE_IR_BUILDER_H_
#define HYBRIDSE_SRC_CODEGEN_TYPE_IR_BUILDER_H_
#include <string>
#include <vector>
#include "base/fe_status.h"
#include "codec/fe_row_codec.h"
#include "codegen/ir_base_builder.h"
#include "node/node_enum.h"
#include "node/sql_node.h"
#include "node/type_node.h"
namespace hybridse {
namespace codegen {
class TypeIRBuilder {
public:
TypeIRBuilder() {}
virtual ~TypeIRBuilder() {}
static bool IsTimestampPtr(::llvm::Type* type);
static bool IsDatePtr(::llvm::Type* type);
static bool IsStringPtr(::llvm::Type* type);
static bool IsStructPtr(::llvm::Type* type);
static bool IsInt64(::llvm::Type* type);
static bool IsBool(::llvm::Type* type);
static bool IsNull(::llvm::Type* type);
static bool IsInterger(::llvm::Type* type);
static bool IsNumber(::llvm::Type* type);
static bool isFloatPoint(::llvm::Type* type);
static const std::string TypeName(::llvm::Type* type);
static base::Status UnaryOpTypeInfer(
const std::function<base::Status(
node::NodeManager*, const node::TypeNode*, const node::TypeNode**)>,
::llvm::Type* lhs);
static base::Status BinaryOpTypeInfer(
const std::function<
base::Status(node::NodeManager*, const node::TypeNode*,
const node::TypeNode*, const node::TypeNode**)>,
::llvm::Type* lhs, ::llvm::Type* rhs);
};
class Int64IRBuilder : public TypeIRBuilder {
public:
Int64IRBuilder() : TypeIRBuilder() {}
~Int64IRBuilder() {}
static ::llvm::Type* GetType(::llvm::Module* m) {
return ::llvm::Type::getInt64Ty(m->getContext());
}
};
class Int32IRBuilder : public TypeIRBuilder {
public:
Int32IRBuilder() : TypeIRBuilder() {}
~Int32IRBuilder() {}
static ::llvm::Type* GetType(::llvm::Module* m) {
return ::llvm::Type::getInt32Ty(m->getContext());
}
};
class Int16IRBuilder : public TypeIRBuilder {
public:
Int16IRBuilder() : TypeIRBuilder() {}
~Int16IRBuilder() {}
static ::llvm::Type* GetType(::llvm::Module* m) {
return ::llvm::Type::getInt16Ty(m->getContext());
}
};
class BoolIRBuilder : public TypeIRBuilder {
public:
BoolIRBuilder() : TypeIRBuilder() {}
~BoolIRBuilder() {}
static ::llvm::Type* GetType(::llvm::Module* m) {
return ::llvm::Type::getInt1Ty(m->getContext());
}
};
inline const bool ConvertHybridSeType2LlvmType(const node::TypeNode* data_type,
::llvm::Module* m, // NOLINT
::llvm::Type** llvm_type) {
if (nullptr == data_type) {
LOG(WARNING) << "fail to convert data type to llvm type";
return false;
}
switch (data_type->base_) {
case hybridse::node::kVoid:
*llvm_type = (::llvm::Type::getVoidTy(m->getContext()));
break;
case hybridse::node::kInt16:
*llvm_type = (::llvm::Type::getInt16Ty(m->getContext()));
break;
case hybridse::node::kInt32:
*llvm_type = (::llvm::Type::getInt32Ty(m->getContext()));
break;
case hybridse::node::kInt64:
*llvm_type = (::llvm::Type::getInt64Ty(m->getContext()));
break;
case hybridse::node::kFloat:
*llvm_type = (::llvm::Type::getFloatTy(m->getContext()));
break;
case hybridse::node::kDouble:
*llvm_type = (::llvm::Type::getDoubleTy(m->getContext()));
break;
case hybridse::node::kInt8Ptr:
*llvm_type = (::llvm::Type::getInt8PtrTy(m->getContext()));
break;
case hybridse::node::kVarchar: {
std::string name = "fe.string_ref";
::llvm::StringRef sr(name);
::llvm::StructType* stype = m->getTypeByName(sr);
if (stype != NULL) {
*llvm_type = stype;
return true;
}
stype = ::llvm::StructType::create(m->getContext(), name);
::llvm::Type* size_ty = (::llvm::Type::getInt32Ty(m->getContext()));
::llvm::Type* data_ptr_ty =
(::llvm::Type::getInt8PtrTy(m->getContext()));
std::vector<::llvm::Type*> elements;
elements.push_back(size_ty);
elements.push_back(data_ptr_ty);
stype->setBody(::llvm::ArrayRef<::llvm::Type*>(elements));
*llvm_type = stype;
return true;
}
case hybridse::node::kList: {
if (data_type->generics_.size() != 1) {
LOG(WARNING) << "fail to convert data type: list generic types "
"number is " +
std::to_string(data_type->generics_.size());
return false;
}
std::string name;
}
default: {
LOG(WARNING) << "fail to convert hybridse datatype to llvm type: "
<< data_type;
return false;
}
}
return true;
}
} // namespace codegen
} // namespace hybridse
#endif // HYBRIDSE_SRC_CODEGEN_TYPE_IR_BUILDER_H_
| 35.716049 | 80 | 0.586243 | [
"vector"
] |
47009bfecc7407a0542ceac66711df0cd3a4797e | 26,590 | h | C | mi8/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h | wqk317/mi8_kernel_source | e3482d1a7ea6021de2fc8f3178496b4b043bb727 | [
"MIT"
] | null | null | null | mi8/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h | wqk317/mi8_kernel_source | e3482d1a7ea6021de2fc8f3178496b4b043bb727 | [
"MIT"
] | null | null | null | mi8/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h | wqk317/mi8_kernel_source | e3482d1a7ea6021de2fc8f3178496b4b043bb727 | [
"MIT"
] | 1 | 2020-03-28T11:26:15.000Z | 2020-03-28T11:26:15.000Z | /*
* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only 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 for more details.
*
*/
#ifndef _DSI_CTRL_H_
#define _DSI_CTRL_H_
#include <linux/debugfs.h>
#include "dsi_defs.h"
#include "dsi_ctrl_hw.h"
#include "dsi_clk.h"
#include "dsi_pwr.h"
#include "drm_mipi_dsi.h"
/*
* DSI Command transfer modifiers
* @DSI_CTRL_CMD_READ: The current transfer involves reading data.
* @DSI_CTRL_CMD_BROADCAST: The current transfer needs to be done in
* broadcast mode to multiple slaves.
* @DSI_CTRL_CMD_BROADCAST_MASTER: This controller is the master and the slaves
* sync to this trigger.
* @DSI_CTRL_CMD_DEFER_TRIGGER: Defer the command trigger to later.
* @DSI_CTRL_CMD_FIFO_STORE: Use FIFO for command transfer in place of
* reading data from memory.
* @DSI_CTRL_CMD_FETCH_MEMORY: Fetch command from memory through AXI bus
* and transfer it.
* @DSI_CTRL_CMD_LAST_COMMAND: Trigger the DMA cmd transfer if this is last
* command in the batch.
* @DSI_CTRL_CMD_NON_EMBEDDED_MODE:Trasfer cmd packets in non embedded mode.
* @DSI_CTRL_CMD_CUSTOM_DMA_SCHED: Use the dma scheduling line number defined in
* display panel dtsi file instead of default.
*/
#define DSI_CTRL_CMD_READ 0x1
#define DSI_CTRL_CMD_BROADCAST 0x2
#define DSI_CTRL_CMD_BROADCAST_MASTER 0x4
#define DSI_CTRL_CMD_DEFER_TRIGGER 0x8
#define DSI_CTRL_CMD_FIFO_STORE 0x10
#define DSI_CTRL_CMD_FETCH_MEMORY 0x20
#define DSI_CTRL_CMD_LAST_COMMAND 0x40
#define DSI_CTRL_CMD_NON_EMBEDDED_MODE 0x80
#define DSI_CTRL_CMD_CUSTOM_DMA_SCHED 0x100
/* DSI embedded mode fifo size
* If the command is greater than 256 bytes it is sent in non-embedded mode.
*/
#define DSI_EMBEDDED_MODE_DMA_MAX_SIZE_BYTES 256
/* max size supported for dsi cmd transfer using TPG */
#define DSI_CTRL_MAX_CMD_FIFO_STORE_SIZE 64
/**
* enum dsi_channel_id - defines dsi channel id.
* @DSI_CTRL_LEFT: DSI 0 channel
* @DSI_CTRL_RIGHT: DSI 1 channel
* @DSI_CTRL_MAX: Maximum value.
*/
enum dsi_channel_id {
DSI_CTRL_LEFT = 0,
DSI_CTRL_RIGHT,
DSI_CTRL_MAX,
};
/**
* enum dsi_power_state - defines power states for dsi controller.
* @DSI_CTRL_POWER_VREG_OFF: Digital and analog supplies for DSI controller
turned off
* @DSI_CTRL_POWER_VREG_ON: Digital and analog supplies for DSI controller
* @DSI_CTRL_POWER_MAX: Maximum value.
*/
enum dsi_power_state {
DSI_CTRL_POWER_VREG_OFF = 0,
DSI_CTRL_POWER_VREG_ON,
DSI_CTRL_POWER_MAX,
};
/**
* enum dsi_engine_state - define engine status for dsi controller.
* @DSI_CTRL_ENGINE_OFF: Engine is turned off.
* @DSI_CTRL_ENGINE_ON: Engine is turned on.
* @DSI_CTRL_ENGINE_MAX: Maximum value.
*/
enum dsi_engine_state {
DSI_CTRL_ENGINE_OFF = 0,
DSI_CTRL_ENGINE_ON,
DSI_CTRL_ENGINE_MAX,
};
/**
* struct dsi_ctrl_power_info - digital and analog power supplies for dsi host
* @digital: Digital power supply required to turn on DSI controller hardware.
* @host_pwr: Analog power supplies required to turn on DSI controller hardware.
* Even though DSI controller it self does not require an analog
* power supply, supplies required for PLL can be defined here to
* allow proper control over these supplies.
*/
struct dsi_ctrl_power_info {
struct dsi_regulator_info digital;
struct dsi_regulator_info host_pwr;
};
/**
* struct dsi_ctrl_clk_info - clock information for DSI controller
* @core_clks: Core clocks needed to access DSI controller registers.
* @hs_link_clks: Clocks required to transmit high speed data over DSI
* @lp_link_clks: Clocks required to perform low power ops over DSI
* @rcg_clks: Root clock generation clocks generated in MMSS_CC. The
* output of the PLL is set as parent for these root
* clocks. These clocks are specific to controller
* instance.
* @mux_clks: Mux clocks used for Dynamic refresh feature.
* @ext_clks: External byte/pixel clocks from the MMSS block. These
* clocks are set as parent to rcg clocks.
* @pll_op_clks: TODO:
* @shadow_clks: TODO:
*/
struct dsi_ctrl_clk_info {
/* Clocks parsed from DT */
struct dsi_core_clk_info core_clks;
struct dsi_link_hs_clk_info hs_link_clks;
struct dsi_link_lp_clk_info lp_link_clks;
struct dsi_clk_link_set rcg_clks;
/* Clocks set by DSI Manager */
struct dsi_clk_link_set mux_clks;
struct dsi_clk_link_set ext_clks;
struct dsi_clk_link_set pll_op_clks;
struct dsi_clk_link_set shadow_clks;
};
/**
* struct dsi_ctrl_bus_scale_info - Bus scale info for msm-bus bandwidth voting
* @bus_scale_table: Bus scale voting usecases.
* @bus_handle: Handle used for voting bandwidth.
*/
struct dsi_ctrl_bus_scale_info {
struct msm_bus_scale_pdata *bus_scale_table;
u32 bus_handle;
};
/**
* struct dsi_ctrl_state_info - current driver state information
* @power_state: Status of power states on DSI controller.
* @cmd_engine_state: Status of DSI command engine.
* @vid_engine_state: Status of DSI video engine.
* @controller_state: Status of DSI Controller engine.
* @host_initialized: Boolean to indicate status of DSi host Initialization
* @tpg_enabled: Boolean to indicate whether tpg is enabled.
*/
struct dsi_ctrl_state_info {
enum dsi_power_state power_state;
enum dsi_engine_state cmd_engine_state;
enum dsi_engine_state vid_engine_state;
enum dsi_engine_state controller_state;
bool host_initialized;
bool tpg_enabled;
};
/**
* struct dsi_ctrl_interrupts - define interrupt information
* @irq_lock: Spinlock for ISR handler.
* @irq_num: Linux interrupt number associated with device.
* @irq_stat_mask: Hardware mask of currently enabled interrupts.
* @irq_stat_refcount: Number of times each interrupt has been requested.
* @irq_stat_cb: Status IRQ callback definitions.
* @irq_err_cb: IRQ callback definition to handle DSI ERRORs.
* @cmd_dma_done: Completion signal for DSI_CMD_MODE_DMA_DONE interrupt
* @vid_frame_done: Completion signal for DSI_VIDEO_MODE_FRAME_DONE int.
* @cmd_frame_done: Completion signal for DSI_CMD_FRAME_DONE interrupt.
*/
struct dsi_ctrl_interrupts {
spinlock_t irq_lock;
int irq_num;
uint32_t irq_stat_mask;
int irq_stat_refcount[DSI_STATUS_INTERRUPT_COUNT];
struct dsi_event_cb_info irq_stat_cb[DSI_STATUS_INTERRUPT_COUNT];
struct dsi_event_cb_info irq_err_cb;
struct completion cmd_dma_done;
struct completion vid_frame_done;
struct completion cmd_frame_done;
struct completion bta_done;
};
/**
* struct dsi_ctrl - DSI controller object
* @pdev: Pointer to platform device.
* @cell_index: Instance cell id.
* @horiz_index: Index in physical horizontal CTRL layout, 0 = leftmost
* @name: Name of the controller instance.
* @refcount: ref counter.
* @ctrl_lock: Mutex for hardware and object access.
* @drm_dev: Pointer to DRM device.
* @version: DSI controller version.
* @hw: DSI controller hardware object.
* @current_state: Current driver and hardware state.
* @clk_cb: Callback for DSI clock control.
* @irq_info: Interrupt information.
* @recovery_cb: Recovery call back to SDE.
* @clk_info: Clock information.
* @clk_freq: DSi Link clock frequency information.
* @pwr_info: Power information.
* @axi_bus_info: AXI bus information.
* @host_config: Current host configuration.
* @mode_bounds: Boundaries of the default mode ROI.
* Origin is at top left of all CTRLs.
* @roi: Partial update region of interest.
* Origin is top left of this CTRL.
* @tx_cmd_buf: Tx command buffer.
* @cmd_buffer_iova: cmd buffer mapped address.
* @cmd_buffer_size: Size of command buffer.
* @vaddr: CPU virtual address of cmd buffer.
* @secure_mode: Indicates if secure-session is in progress
* @esd_check_underway: Indicates if esd status check is in progress
* @debugfs_root: Root for debugfs entries.
* @misr_enable: Frame MISR enable/disable
* @misr_cache: Cached Frame MISR value
* @phy_isolation_enabled: A boolean property allows to isolate the phy from
* dsi controller and run only dsi controller.
* @null_insertion_enabled: A boolean property to allow dsi controller to
* insert null packet.
* @modeupdated: Boolean to send new roi if mode is updated.
*/
struct dsi_ctrl {
struct platform_device *pdev;
u32 cell_index;
u32 horiz_index;
const char *name;
u32 refcount;
struct mutex ctrl_lock;
struct drm_device *drm_dev;
enum dsi_ctrl_version version;
struct dsi_ctrl_hw hw;
/* Current state */
struct dsi_ctrl_state_info current_state;
struct clk_ctrl_cb clk_cb;
struct dsi_ctrl_interrupts irq_info;
struct dsi_event_cb_info recovery_cb;
/* Clock and power states */
struct dsi_ctrl_clk_info clk_info;
struct link_clk_freq clk_freq;
struct dsi_ctrl_power_info pwr_info;
struct dsi_ctrl_bus_scale_info axi_bus_info;
struct dsi_host_config host_config;
struct dsi_rect mode_bounds;
struct dsi_rect roi;
/* Command tx and rx */
struct drm_gem_object *tx_cmd_buf;
u32 cmd_buffer_size;
u32 cmd_buffer_iova;
u32 cmd_len;
void *vaddr;
bool secure_mode;
bool esd_check_underway;
/* Debug Information */
struct dentry *debugfs_root;
/* MISR */
bool misr_enable;
u32 misr_cache;
bool phy_isolation_enabled;
bool null_insertion_enabled;
bool modeupdated;
};
/**
* dsi_ctrl_get() - get a dsi_ctrl handle from an of_node
* @of_node: of_node of the DSI controller.
*
* Gets the DSI controller handle for the corresponding of_node. The ref count
* is incremented to one and all subsequent gets will fail until the original
* clients calls a put.
*
* Return: DSI Controller handle.
*/
struct dsi_ctrl *dsi_ctrl_get(struct device_node *of_node);
/**
* dsi_ctrl_put() - releases a dsi controller handle.
* @dsi_ctrl: DSI controller handle.
*
* Releases the DSI controller. Driver will clean up all resources and puts back
* the DSI controller into reset state.
*/
void dsi_ctrl_put(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_drv_init() - initialize dsi controller driver.
* @dsi_ctrl: DSI controller handle.
* @parent: Parent directory for debug fs.
*
* Initializes DSI controller driver. Driver should be initialized after
* dsi_ctrl_get() succeeds.
*
* Return: error code.
*/
int dsi_ctrl_drv_init(struct dsi_ctrl *dsi_ctrl, struct dentry *parent);
/**
* dsi_ctrl_drv_deinit() - de-initializes dsi controller driver
* @dsi_ctrl: DSI controller handle.
*
* Releases all resources acquired by dsi_ctrl_drv_init().
*
* Return: error code.
*/
int dsi_ctrl_drv_deinit(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_validate_timing() - validate a video timing configuration
* @dsi_ctrl: DSI controller handle.
* @timing: Pointer to timing data.
*
* Driver will validate if the timing configuration is supported on the
* controller hardware.
*
* Return: error code if timing is not supported.
*/
int dsi_ctrl_validate_timing(struct dsi_ctrl *dsi_ctrl,
struct dsi_mode_info *timing);
/**
* dsi_ctrl_update_host_config() - update dsi host configuration
* @dsi_ctrl: DSI controller handle.
* @config: DSI host configuration.
* @flags: dsi_mode_flags modifying the behavior
* @clk_handle: Clock handle for DSI clocks
*
* Updates driver with new Host configuration to use for host initialization.
* This function call will only update the software context. The stored
* configuration information will be used when the host is initialized.
*
* Return: error code.
*/
int dsi_ctrl_update_host_config(struct dsi_ctrl *dsi_ctrl,
struct dsi_host_config *config,
int flags, void *clk_handle);
/**
* dsi_ctrl_timing_db_update() - update only controller Timing DB
* @dsi_ctrl: DSI controller handle.
* @enable: Enable/disable Timing DB register
*
* Update timing db register value during dfps usecases
*
* Return: error code.
*/
int dsi_ctrl_timing_db_update(struct dsi_ctrl *dsi_ctrl,
bool enable);
/**
* dsi_ctrl_async_timing_update() - update only controller timing
* @dsi_ctrl: DSI controller handle.
* @timing: New DSI timing info
*
* Updates host timing values to asynchronously transition to new timing
* For example, to update the porch values in a seamless/dynamic fps switch.
*
* Return: error code.
*/
int dsi_ctrl_async_timing_update(struct dsi_ctrl *dsi_ctrl,
struct dsi_mode_info *timing);
/**
* dsi_ctrl_phy_sw_reset() - perform a PHY software reset
* @dsi_ctrl: DSI controller handle.
*
* Performs a PHY software reset on the DSI controller. Reset should be done
* when the controller power state is DSI_CTRL_POWER_CORE_CLK_ON and the PHY is
* not enabled.
*
* This function will fail if driver is in any other state.
*
* Return: error code.
*/
int dsi_ctrl_phy_sw_reset(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_phy_reset_config() - Mask/unmask propagation of ahb reset signal
* to DSI PHY hardware.
* @dsi_ctrl: DSI controller handle.
* @enable: Mask/unmask the PHY reset signal.
*
* Return: error code.
*/
int dsi_ctrl_phy_reset_config(struct dsi_ctrl *dsi_ctrl, bool enable);
/**
* dsi_ctrl_soft_reset() - perform a soft reset on DSI controller
* @dsi_ctrl: DSI controller handle.
*
* The video, command and controller engines will be disabled before the
* reset is triggered. After, the engines will be re-enabled to the same state
* as before the reset.
*
* If the reset is done while MDP timing engine is turned on, the video
* engine should be re-enabled only during the vertical blanking time.
*
* Return: error code
*/
int dsi_ctrl_soft_reset(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_host_timing_update - reinitialize host with new timing values
* @dsi_ctrl: DSI controller handle.
*
* Reinitialize DSI controller hardware with new display timing values
* when resolution is switched dynamically.
*
* Return: error code
*/
int dsi_ctrl_host_timing_update(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_host_init() - Initialize DSI host hardware.
* @dsi_ctrl: DSI controller handle.
* @is_splash_enabled: boolean signifying splash status.
*
* Initializes DSI controller hardware with host configuration provided by
* dsi_ctrl_update_host_config(). Initialization can be performed only during
* DSI_CTRL_POWER_CORE_CLK_ON state and after the PHY SW reset has been
* performed.
*
* Return: error code.
*/
int dsi_ctrl_host_init(struct dsi_ctrl *dsi_ctrl, bool is_splash_enabled);
/**
* dsi_ctrl_host_deinit() - De-Initialize DSI host hardware.
* @dsi_ctrl: DSI controller handle.
*
* De-initializes DSI controller hardware. It can be performed only during
* DSI_CTRL_POWER_CORE_CLK_ON state after LINK clocks have been turned off.
*
* Return: error code.
*/
int dsi_ctrl_host_deinit(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_set_ulps() - set ULPS state for DSI lanes.
* @dsi_ctrl: DSI controller handle.
* @enable: enable/disable ULPS.
*
* ULPS can be enabled/disabled after DSI host engine is turned on.
*
* Return: error code.
*/
int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable);
/**
* dsi_ctrl_setup() - Setup DSI host hardware while coming out of idle screen.
* @dsi_ctrl: DSI controller handle.
*
* Initializes DSI controller hardware with host configuration provided by
* dsi_ctrl_update_host_config(). Initialization can be performed only during
* DSI_CTRL_POWER_CORE_CLK_ON state and after the PHY SW reset has been
* performed.
*
* Also used to program the video mode timing values.
*
* Return: error code.
*/
int dsi_ctrl_setup(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_set_roi() - Set DSI controller's region of interest
* @dsi_ctrl: DSI controller handle.
* @roi: Region of interest rectangle, must be less than mode bounds
* @changed: Output parameter, set to true of the controller's ROI was
* dirtied by setting the new ROI, and DCS cmd update needed
*
* Return: error code.
*/
int dsi_ctrl_set_roi(struct dsi_ctrl *dsi_ctrl, struct dsi_rect *roi,
bool *changed);
/**
* dsi_ctrl_set_tpg_state() - enable/disable test pattern on the controller
* @dsi_ctrl: DSI controller handle.
* @on: enable/disable test pattern.
*
* Test pattern can be enabled only after Video engine (for video mode panels)
* or command engine (for cmd mode panels) is enabled.
*
* Return: error code.
*/
int dsi_ctrl_set_tpg_state(struct dsi_ctrl *dsi_ctrl, bool on);
/**
* dsi_ctrl_cmd_transfer() - Transfer commands on DSI link
* @dsi_ctrl: DSI controller handle.
* @msg: Message to transfer on DSI link.
* @flags: Modifiers for message transfer.
*
* Command transfer can be done only when command engine is enabled. The
* transfer API will until either the command transfer finishes or the timeout
* value is reached. If the trigger is deferred, it will return without
* triggering the transfer. Command parameters are programmed to hardware.
*
* Return: error code.
*/
int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl,
const struct mipi_dsi_msg *msg,
u32 flags);
/**
* dsi_ctrl_cmd_tx_trigger() - Trigger a deferred command.
* @dsi_ctrl: DSI controller handle.
* @flags: Modifiers.
*
* Return: error code.
*/
int dsi_ctrl_cmd_tx_trigger(struct dsi_ctrl *dsi_ctrl, u32 flags);
/**
* dsi_ctrl_update_host_engine_state_for_cont_splash() - update engine
* states for cont splash usecase
* @dsi_ctrl: DSI controller handle.
* @state: DSI engine state
*
* Return: error code.
*/
int dsi_ctrl_update_host_engine_state_for_cont_splash(struct dsi_ctrl *dsi_ctrl,
enum dsi_engine_state state);
/**
* dsi_ctrl_set_power_state() - set power state for dsi controller
* @dsi_ctrl: DSI controller handle.
* @state: Power state.
*
* Set power state for DSI controller. Power state can be changed only when
* Controller, Video and Command engines are turned off.
*
* Return: error code.
*/
int dsi_ctrl_set_power_state(struct dsi_ctrl *dsi_ctrl,
enum dsi_power_state state);
/**
* dsi_ctrl_set_cmd_engine_state() - set command engine state
* @dsi_ctrl: DSI Controller handle.
* @state: Engine state.
*
* Command engine state can be modified only when DSI controller power state is
* set to DSI_CTRL_POWER_LINK_CLK_ON.
*
* Return: error code.
*/
int dsi_ctrl_set_cmd_engine_state(struct dsi_ctrl *dsi_ctrl,
enum dsi_engine_state state);
/**
* dsi_ctrl_validate_host_state() - validate DSI ctrl host state
* @dsi_ctrl: DSI Controller handle.
*
* Validate DSI cotroller host state
*
* Return: boolean indicating whether host is not initalized.
*/
bool dsi_ctrl_validate_host_state(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_set_vid_engine_state() - set video engine state
* @dsi_ctrl: DSI Controller handle.
* @state: Engine state.
*
* Video engine state can be modified only when DSI controller power state is
* set to DSI_CTRL_POWER_LINK_CLK_ON.
*
* Return: error code.
*/
int dsi_ctrl_set_vid_engine_state(struct dsi_ctrl *dsi_ctrl,
enum dsi_engine_state state);
/**
* dsi_ctrl_set_host_engine_state() - set host engine state
* @dsi_ctrl: DSI Controller handle.
* @state: Engine state.
*
* Host engine state can be modified only when DSI controller power state is
* set to DSI_CTRL_POWER_LINK_CLK_ON and cmd, video engines are disabled.
*
* Return: error code.
*/
int dsi_ctrl_set_host_engine_state(struct dsi_ctrl *dsi_ctrl,
enum dsi_engine_state state);
/**
* dsi_ctrl_set_ulps() - set ULPS state for DSI lanes.
* @dsi_ctrl: DSI controller handle.
* @enable: enable/disable ULPS.
*
* ULPS can be enabled/disabled after DSI host engine is turned on.
*
* Return: error code.
*/
int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable);
/**
* dsi_ctrl_clk_cb_register() - Register DSI controller clk control callback
* @dsi_ctrl: DSI controller handle.
* @clk__cb: Structure containing callback for clock control.
*
* Register call for DSI clock control
*
* Return: error code.
*/
int dsi_ctrl_clk_cb_register(struct dsi_ctrl *dsi_ctrl,
struct clk_ctrl_cb *clk_cb);
/**
* dsi_ctrl_set_clamp_state() - set clamp state for DSI phy
* @dsi_ctrl: DSI controller handle.
* @enable: enable/disable clamping.
* @ulps_enabled: ulps state.
*
* Clamps can be enabled/disabled while DSI contoller is still turned on.
*
* Return: error code.
*/
int dsi_ctrl_set_clamp_state(struct dsi_ctrl *dsi_Ctrl,
bool enable, bool ulps_enabled);
/**
* dsi_ctrl_set_clock_source() - set clock source fpr dsi link clocks
* @dsi_ctrl: DSI controller handle.
* @source_clks: Source clocks for DSI link clocks.
*
* Clock source should be changed while link clocks are disabled.
*
* Return: error code.
*/
int dsi_ctrl_set_clock_source(struct dsi_ctrl *dsi_ctrl,
struct dsi_clk_link_set *source_clks);
/**
* dsi_ctrl_enable_status_interrupt() - enable status interrupts
* @dsi_ctrl: DSI controller handle.
* @intr_idx: Index interrupt to disable.
* @event_info: Pointer to event callback definition
*/
void dsi_ctrl_enable_status_interrupt(struct dsi_ctrl *dsi_ctrl,
uint32_t intr_idx, struct dsi_event_cb_info *event_info);
/**
* dsi_ctrl_disable_status_interrupt() - disable status interrupts
* @dsi_ctrl: DSI controller handle.
* @intr_idx: Index interrupt to disable.
*/
void dsi_ctrl_disable_status_interrupt(
struct dsi_ctrl *dsi_ctrl, uint32_t intr_idx);
/**
* dsi_ctrl_setup_misr() - Setup frame MISR
* @dsi_ctrl: DSI controller handle.
* @enable: enable/disable MISR.
* @frame_count: Number of frames to accumulate MISR.
*
* Return: error code.
*/
int dsi_ctrl_setup_misr(struct dsi_ctrl *dsi_ctrl,
bool enable,
u32 frame_count);
/**
* dsi_ctrl_collect_misr() - Read frame MISR
* @dsi_ctrl: DSI controller handle.
*
* Return: MISR value.
*/
u32 dsi_ctrl_collect_misr(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_drv_register() - register platform driver for dsi controller
*/
void dsi_ctrl_drv_register(void);
/**
* dsi_ctrl_drv_unregister() - unregister platform driver
*/
void dsi_ctrl_drv_unregister(void);
/**
* dsi_ctrl_reset() - Reset DSI PHY CLK/DATA lane
* @dsi_ctrl: DSI controller handle.
* @mask: Mask to indicate if CLK and/or DATA lane needs reset.
*/
int dsi_ctrl_reset(struct dsi_ctrl *dsi_ctrl, int mask);
/**
* dsi_ctrl_get_hw_version() - read dsi controller hw revision
* @dsi_ctrl: DSI controller handle.
*/
int dsi_ctrl_get_hw_version(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_vid_engine_en() - Control DSI video engine HW state
* @dsi_ctrl: DSI controller handle.
* @on: variable to control video engine ON/OFF.
*/
int dsi_ctrl_vid_engine_en(struct dsi_ctrl *dsi_ctrl, bool on);
/**
* @dsi_ctrl: DSI controller handle.
* cmd_len: Length of command.
* flags: Config mode flags.
*/
void dsi_message_setup_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len,
u32 *flags);
/**
* @dsi_ctrl: DSI controller handle.
* cmd_len: Length of command.
* flags: Config mode flags.
*/
int dsi_message_validate_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len,
u32 *flags);
/**
* dsi_ctrl_isr_configure() - API to register/deregister dsi isr
* @dsi_ctrl: DSI controller handle.
* @enable: variable to control register/deregister isr
*/
void dsi_ctrl_isr_configure(struct dsi_ctrl *dsi_ctrl, bool enable);
/**
* dsi_ctrl_mask_error_status_interrupts() - API to mask dsi ctrl error status
* interrupts
* @dsi_ctrl: DSI controller handle.
* @idx: id indicating which interrupts to enable/disable.
* @mask_enable: boolean to enable/disable masking.
*/
void dsi_ctrl_mask_error_status_interrupts(struct dsi_ctrl *dsi_ctrl, u32 idx,
bool mask_enable);
/**
* dsi_ctrl_irq_update() - Put a irq vote to process DSI error
* interrupts at any time.
* @dsi_ctrl: DSI controller handle.
* @enable: variable to control enable/disable irq line
*/
void dsi_ctrl_irq_update(struct dsi_ctrl *dsi_ctrl, bool enable);
/**
* dsi_ctrl_get_host_engine_init_state() - Return host init state
*/
int dsi_ctrl_get_host_engine_init_state(struct dsi_ctrl *dsi_ctrl,
bool *state);
/**
* dsi_ctrl_update_host_init_state() - Set the host initialization state
*/
int dsi_ctrl_update_host_init_state(struct dsi_ctrl *dsi_ctrl, bool en);
/**
* dsi_ctrl_wait_for_cmd_mode_mdp_idle() - Wait for command mode engine not to
* be busy sending data from display engine.
* @dsi_ctrl: DSI controller handle.
*/
int dsi_ctrl_wait_for_cmd_mode_mdp_idle(struct dsi_ctrl *dsi_ctrl);
/**
* dsi_ctrl_set_continuous_clk() - API to set/unset force clock lane HS request.
* @dsi_ctrl: DSI controller handle.
* @enable: variable to control continuous clock.
*/
void dsi_ctrl_set_continuous_clk(struct dsi_ctrl *dsi_ctrl, bool enable);
/**
* dsi_ctrl_wait4dynamic_refresh_done() - Poll for dynamic refresh done
* interrupt.
* @dsi_ctrl: DSI controller handle.
*/
int dsi_ctrl_wait4dynamic_refresh_done(struct dsi_ctrl *ctrl);
#endif /* _DSI_CTRL_H_ */
| 33.488665 | 80 | 0.713163 | [
"object"
] |
4726086f91022f1c878853365dd1913b9c8a5065 | 963 | h | C | shell/themes/themeui/screensaverpg.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | shell/themes/themeui/screensaverpg.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | shell/themes/themeui/screensaverpg.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*****************************************************************************\
FILE: ScreenSaverPg.cpp
DESCRIPTION:
This file contains the COM object implementation that will display the
ScreenSaver tab in the Display Control Panel.
18-Feb-94 (Tracy Sharpe) Added power management functionality.
Commented out several pieces of code that weren't being
used.
5/30/2000 (Bryan Starbuck) BryanSt: Turned into C++ and COM. Exposed
as an API so other tabs can communicate with it. This enables
the Plus! Theme page to modify the screen saver.
Copyright (C) Microsoft Corp 1994-2000. All rights reserved.
\*****************************************************************************/
#ifndef _SSDLG_H
#define _SSDLG_H
HRESULT CScreenSaverPage_CreateInstance(IN IUnknown * punkOuter, IN REFIID riid, OUT LPVOID * ppvObj);
#endif // _SSDLG_H
| 37.038462 | 103 | 0.561786 | [
"object"
] |
4729bd208696af18bc188d6fb2f2faa561acffc8 | 3,483 | h | C | include/ICollisionGeometry.h | aggieblue92/IndigoFrost-Physics | 9cc35397ee5ee38a55d8d09d5038436edf26d5c1 | [
"MIT"
] | null | null | null | include/ICollisionGeometry.h | aggieblue92/IndigoFrost-Physics | 9cc35397ee5ee38a55d8d09d5038436edf26d5c1 | [
"MIT"
] | null | null | null | include/ICollisionGeometry.h | aggieblue92/IndigoFrost-Physics | 9cc35397ee5ee38a55d8d09d5038436edf26d5c1 | [
"MIT"
] | null | null | null | /*
This source file is part of the Indigo Frost physics engine
The MIT License (MIT)
Copyright (c) 2014 Kamaron Peterson (aggieblue92)
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.
*/
/////////////////////////////////////////
// ICollisionGeometry: Interface for collision
// geometry. Encapsulates all supported types.
/////////////////////////////////////////
#ifndef FROST_COLLISION_GEOMETRY_INTERFACE_H
#define FROST_COLLISION_GEOMETRY_INTERFACE_H
#include "Movable.h"
#include "IContact.h"
#include "IPhysicsObject.h"
#include <vector>
namespace Frost
{
enum FROST_COLLISION_GEOMETRY_TYPE
{
FROST_COLLISION_GEOMETRY_TYPE_BOX,
FROST_COLLISION_GEOMETRY_TYPE_SPHERE
};
class CollisionBox;
class CollisionSphere;
// Exception for handling unsupported future geometry types
class UnsupportedCollisionGeometryEvent : public NotImplementedException
{
public:
FROST_COLLISION_GEOMETRY_TYPE _type1;
FROST_COLLISION_GEOMETRY_TYPE _type2;
UnsupportedCollisionGeometryEvent(FROST_COLLISION_GEOMETRY_TYPE firstType, FROST_COLLISION_GEOMETRY_TYPE secondType)
: _type1(firstType), _type2(secondType) {}
};
class ICollisionGeometry : public Movable
{
public:
/////////////////// CTORS //////////////////////
// Base ctor - type only
ICollisionGeometry(FROST_COLLISION_GEOMETRY_TYPE type);
// Construct with type and local spatial information
ICollisionGeometry(FROST_COLLISION_GEOMETRY_TYPE type, const FLOAT3& pos, const Quaternion& orientation);
// Constructor with type, spatial information and attached object
ICollisionGeometry(FROST_COLLISION_GEOMETRY_TYPE type, const FLOAT3& pos, const Quaternion& orientation, std::shared_ptr<IPhysicsObject> attachedObject);
// Copy ctor
ICollisionGeometry(const ICollisionGeometry& copy);
/////////////////// VIRTUAL FUNCS ///////////////
virtual bool isTouching(const ICollisionGeometry& otherGeometry) const = 0;
virtual void genContacts(const ICollisionGeometry& otherGeometry, std::vector<std::shared_ptr<IContact>>& o_list) const = 0;
/////////////////// HELPERS //////////////////////
FROST_COLLISION_GEOMETRY_TYPE getType() const;
std::shared_ptr<IPhysicsObject> getAttachedObjectPtr() const;
// Attach an object to the collision geometry. Fails if
// the collision geometry already has an attached object.
void attachObject(std::shared_ptr<IPhysicsObject> toAttach);
protected:
FROST_COLLISION_GEOMETRY_TYPE _type;
std::shared_ptr<IPhysicsObject> _attachedObject;
};
}
#endif | 36.663158 | 155 | 0.756819 | [
"geometry",
"object",
"vector"
] |
472ae92dd16285c7d5e30d4d973a728e2f427a91 | 2,470 | h | C | cms/include/alibabacloud/cms/model/DescribeAlarmsRequest.h | sdk-team/aliyun-openapi-cpp-sdk | d0e92f6f33126dcdc7e40f60582304faf2c229b7 | [
"Apache-2.0"
] | 3 | 2020-01-06T08:23:14.000Z | 2022-01-22T04:41:35.000Z | cms/include/alibabacloud/cms/model/DescribeAlarmsRequest.h | sdk-team/aliyun-openapi-cpp-sdk | d0e92f6f33126dcdc7e40f60582304faf2c229b7 | [
"Apache-2.0"
] | null | null | null | cms/include/alibabacloud/cms/model/DescribeAlarmsRequest.h | sdk-team/aliyun-openapi-cpp-sdk | d0e92f6f33126dcdc7e40f60582304faf2c229b7 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_CMS_MODEL_DESCRIBEALARMSREQUEST_H_
#define ALIBABACLOUD_CMS_MODEL_DESCRIBEALARMSREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/cms/CmsExport.h>
namespace AlibabaCloud
{
namespace Cms
{
namespace Model
{
class ALIBABACLOUD_CMS_EXPORT DescribeAlarmsRequest : public RpcServiceRequest
{
public:
DescribeAlarmsRequest();
~DescribeAlarmsRequest();
bool getEnableState()const;
void setEnableState(bool enableState);
std::string getNames()const;
void setNames(const std::string& names);
std::string getDisplayName()const;
void setDisplayName(const std::string& displayName);
std::string getGroupId()const;
void setGroupId(const std::string& groupId);
std::string get_Namespace()const;
void set_Namespace(const std::string& _namespace);
std::string getPageSize()const;
void setPageSize(const std::string& pageSize);
std::string getAlertState()const;
void setAlertState(const std::string& alertState);
std::string getNameKeyword()const;
void setNameKeyword(const std::string& nameKeyword);
std::string getGroupBy()const;
void setGroupBy(const std::string& groupBy);
std::string getPage()const;
void setPage(const std::string& page);
std::string getMetricName()const;
void setMetricName(const std::string& metricName);
private:
bool enableState_;
std::string names_;
std::string displayName_;
std::string groupId_;
std::string _namespace_;
std::string pageSize_;
std::string alertState_;
std::string nameKeyword_;
std::string groupBy_;
std::string page_;
std::string metricName_;
};
}
}
}
#endif // !ALIBABACLOUD_CMS_MODEL_DESCRIBEALARMSREQUEST_H_ | 31.666667 | 81 | 0.719433 | [
"vector",
"model"
] |
472dcf8d03fdfdb7e055b868f43a736e89eb62a0 | 1,303 | h | C | Command/Editor/Document.h | chosti34/ood | 3d74b5253f667d3de1ee610fb7509cf3015ea79c | [
"MIT"
] | null | null | null | Command/Editor/Document.h | chosti34/ood | 3d74b5253f667d3de1ee610fb7509cf3015ea79c | [
"MIT"
] | 9 | 2018-02-09T06:12:29.000Z | 2018-06-06T06:26:40.000Z | Command/Editor/Document.h | chosti34/ood | 3d74b5253f667d3de1ee610fb7509cf3015ea79c | [
"MIT"
] | null | null | null | #pragma once
#include "IDocument.h"
#include "ICommandManager.h"
#include "ImageFileStorage.h"
#include <vector>
class Document : public IDocument
{
public:
Document(const std::string& title,
const std::shared_ptr<IImageFileStorage>& storage = std::make_shared<ImageFileStorage>("images"));
void InsertParagraph(const std::string& text, boost::optional<size_t> position) override;
void InsertImage(const std::string& path, unsigned width, unsigned height, boost::optional<size_t> position) override;
void RemoveItem(size_t index) override;
void ReplaceText(const std::string& text, size_t index) override;
void ResizeImage(unsigned width, unsigned height, size_t index) override;
void SetTitle(const std::string& title) override;
std::string GetTitle()const override;
size_t GetItemsCount()const override;
std::shared_ptr<DocumentItem> GetItem(size_t index) override;
std::shared_ptr<const DocumentItem> GetItem(size_t index)const override;
bool CanUndo()const override;
void Undo() override;
bool CanRedo()const override;
void Redo() override;
void Save(const std::string& path)override;
private:
std::string m_title;
std::vector<std::shared_ptr<DocumentItem>> m_items;
std::unique_ptr<ICommandManager> m_commandManager;
std::shared_ptr<IImageFileStorage> m_storage;
};
| 31.780488 | 119 | 0.777437 | [
"vector"
] |
4742fb5a54029b3d1ad2ebd5f7250f4fc103b189 | 569 | h | C | utshp.h | gwentruong/utshp | bcd6da73678bc1609b41cc99f9bcf21a741f8703 | [
"WTFPL"
] | 1 | 2019-02-20T13:47:36.000Z | 2019-02-20T13:47:36.000Z | utshp.h | gwentruong/utshp | bcd6da73678bc1609b41cc99f9bcf21a741f8703 | [
"WTFPL"
] | null | null | null | utshp.h | gwentruong/utshp | bcd6da73678bc1609b41cc99f9bcf21a741f8703 | [
"WTFPL"
] | 1 | 2019-02-20T08:58:02.000Z | 2019-02-20T08:58:02.000Z | #ifndef __UTSHP_H
#define __UTSHP_H
typedef struct record {
int num;
int len;
int shape_type;
void *shape;
struct record *next;
} Record;
int parse_header(FILE *fp);
void parse_int32(unsigned char *buf, int *p, int n, int big_endian);
void parse_double(unsigned char *buf, double *p, int n);
int record_prepend(Record **p_head, Record *new_record);
void record_reverse(Record **p_head);
int record_length(Record *head);
const char *shape_type(int x);
#endif
| 25.863636 | 75 | 0.611599 | [
"shape"
] |
474a6aeb31fabc27b4fc4817f304afc4079450cd | 11,124 | h | C | palacios/include/palacios/vmcb.h | jnouyang/palacios | e06aee743c38e53901d2e80590d687e5b93f93f2 | [
"BSD-3-Clause"
] | 1 | 2015-07-14T01:02:15.000Z | 2015-07-14T01:02:15.000Z | palacios/include/palacios/vmcb.h | jnouyang/palacios | e06aee743c38e53901d2e80590d687e5b93f93f2 | [
"BSD-3-Clause"
] | null | null | null | palacios/include/palacios/vmcb.h | jnouyang/palacios | e06aee743c38e53901d2e80590d687e5b93f93f2 | [
"BSD-3-Clause"
] | null | null | null | /*
* This file is part of the Palacios Virtual Machine Monitor developed
* by the V3VEE Project with funding from the United States National
* Science Foundation and the Department of Energy.
*
* The V3VEE Project is a joint project between Northwestern University
* and the University of New Mexico. You can find out more at
* http://www.v3vee.org
*
* Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
* Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
* All rights reserved.
*
* Author: Jack Lange <jarusl@cs.northwestern.edu>
*
* This is free software. You are permitted to use,
* redistribute, and modify it as specified in the file "V3VEE_LICENSE".
*/
#ifndef __VMCB_H
#define __VMCB_H
#ifdef __V3VEE__
#include <palacios/vmm_types.h>
#include <palacios/vm.h>
#define VMCB_CTRL_AREA_OFFSET 0x0
#define VMCB_STATE_SAVE_AREA_OFFSET 0x400
#define GET_VMCB_CTRL_AREA(page) (page + VMCB_CTRL_AREA_OFFSET)
#define GET_VMCB_SAVE_STATE_AREA(page) (page + VMCB_STATE_SAVE_AREA_OFFSET)
typedef void vmcb_t;
struct Ctrl_Registers {
uint32_t cr0 : 1;
uint32_t cr1 : 1;
uint32_t cr2 : 1;
uint32_t cr3 : 1;
uint32_t cr4 : 1;
uint32_t cr5 : 1;
uint32_t cr6 : 1;
uint32_t cr7 : 1;
uint32_t cr8 : 1;
uint32_t cr9 : 1;
uint32_t cr10 : 1;
uint32_t cr11 : 1;
uint32_t cr12 : 1;
uint32_t cr13 : 1;
uint32_t cr14 : 1;
uint32_t cr15 : 1;
} __attribute__((packed));
struct Debug_Registers {
uint32_t dr0 : 1;
uint32_t dr1 : 1;
uint32_t dr2 : 1;
uint32_t dr3 : 1;
uint32_t dr4 : 1;
uint32_t dr5 : 1;
uint32_t dr6 : 1;
uint32_t dr7 : 1;
uint32_t dr8 : 1;
uint32_t dr9 : 1;
uint32_t dr10 : 1;
uint32_t dr11 : 1;
uint32_t dr12 : 1;
uint32_t dr13 : 1;
uint32_t dr14 : 1;
uint32_t dr15 : 1;
} __attribute__((packed));
struct Exception_Vectors {
uint32_t de : 1; // (0) divide by zero
uint32_t db : 1; // (1) Debug
uint32_t nmi : 1; // (2) Non-maskable interrupt
uint32_t bp : 1; // (3) Breakpoint
uint32_t of : 1; // (4) Overflow
uint32_t br : 1; // (5) Bound-Range
uint32_t ud : 1; // (6) Invalid-Opcode
uint32_t nm : 1; // (7) Device-not-available
uint32_t df : 1; // (8) Double Fault
uint32_t ex9 : 1;
uint32_t ts : 1; // (10) Invalid TSS
uint32_t np : 1; // (11) Segment-not-present
uint32_t ss : 1; // (12) Stack
uint32_t gp : 1; // (13) General Protection Fault
uint32_t pf : 1; // (14) Page fault
uint32_t ex15 : 1;
uint32_t mf : 1; // (15) Floating point exception
uint32_t ac : 1; // (16) Alignment-check
uint32_t mc : 1; // (17) Machine Check
uint32_t xf : 1; // (18) SIMD floating-point
uint32_t ex20 : 1;
uint32_t ex21 : 1;
uint32_t ex22 : 1;
uint32_t ex23 : 1;
uint32_t ex24 : 1;
uint32_t ex25 : 1;
uint32_t ex26 : 1;
uint32_t ex27 : 1;
uint32_t ex28 : 1;
uint32_t ex29 : 1;
uint32_t sx : 1; // (30) Security Exception
uint32_t ex31 : 1;
} __attribute__((packed));
struct Instr_Intercepts {
uint32_t INTR : 1;
uint32_t NMI : 1;
uint32_t SMI : 1;
uint32_t INIT : 1;
uint32_t VINTR : 1;
uint32_t CR0 : 1;
uint32_t RD_IDTR : 1;
uint32_t RD_GDTR : 1;
uint32_t RD_LDTR : 1;
uint32_t RD_TR : 1;
uint32_t WR_IDTR : 1;
uint32_t WR_GDTR : 1;
uint32_t WR_LDTR : 1;
uint32_t WR_TR : 1;
uint32_t RDTSC : 1;
uint32_t RDPMC : 1;
uint32_t PUSHF : 1;
uint32_t POPF : 1;
uint32_t CPUID : 1;
uint32_t RSM : 1;
uint32_t IRET : 1;
uint32_t INTn : 1;
uint32_t INVD : 1;
uint32_t PAUSE : 1;
uint32_t HLT : 1;
uint32_t INVLPG : 1;
uint32_t INVLPGA : 1;
uint32_t IOIO_PROT : 1;
uint32_t MSR_PROT : 1;
uint32_t task_switch : 1;
uint32_t FERR_FREEZE : 1;
uint32_t shutdown_evts : 1;
} __attribute__((packed));
struct SVM_Instr_Intercepts {
uint32_t VMRUN : 1;
uint32_t VMMCALL : 1;
uint32_t VMLOAD : 1;
uint32_t VMSAVE : 1;
uint32_t STGI : 1;
uint32_t CLGI : 1;
uint32_t SKINIT : 1;
uint32_t RDTSCP : 1;
uint32_t ICEBP : 1;
uint32_t WBINVD : 1;
uint32_t MONITOR : 1;
uint32_t MWAIT_always : 1;
uint32_t MWAIT_if_armed : 1;
uint32_t reserved : 19; // Should be 0
} __attribute__((packed));
struct Guest_Control {
uint32_t V_TPR : 8;
uint32_t V_IRQ : 1;
uint32_t rsvd1 : 7; // Should be 0
uint32_t V_INTR_PRIO : 4;
uint32_t V_IGN_TPR : 1;
uint32_t rsvd2 : 3; // Should be 0
uint32_t V_INTR_MASKING : 1;
uint32_t rsvd3 : 7; // Should be 0
uint32_t V_INTR_VECTOR : 8;
uint32_t rsvd4 : 24; // Should be 0
} __attribute__((packed));
#define SVM_INJECTION_IRQ 0
#define SVM_INJECTION_NMI 2
#define SVM_INJECTION_EXCEPTION 3
#define SVM_INJECTION_SOFT_INTR 4
struct Interrupt_Info {
uint64_t vector : 8;
uint64_t type : 3;
uint64_t ev : 1;
uint64_t rsvd : 19;
uint64_t valid : 1;
uint64_t error_code : 32;
} __attribute__((packed));
struct VMCB_Control_Area {
// offset 0x0
struct Ctrl_Registers cr_reads;
struct Ctrl_Registers cr_writes;
struct Debug_Registers dr_reads;
struct Debug_Registers dr_writes;
struct Exception_Vectors exceptions;
struct Instr_Intercepts instrs;
struct SVM_Instr_Intercepts svm_instrs;
uint8_t rsvd1[44]; // Should be 0
// offset 0x040
uint64_t IOPM_BASE_PA;
uint64_t MSRPM_BASE_PA;
uint64_t TSC_OFFSET;
uint32_t guest_ASID;
uint8_t TLB_CONTROL;
uint8_t rsvd2[3]; // Should be 0
struct Guest_Control guest_ctrl;
uint32_t interrupt_shadow;
uint32_t rsvd4; // Should be 0
uint64_t exit_code;
uint64_t exit_info1;
uint64_t exit_info2;
/* This could be a typo in the manual....
* It doesn't actually say that there is a reserved bit
* But it does say that the EXITINTINFO field is in bits 63-1
* ALL other occurances mention a 1 bit reserved field
*/
// uint_t rsvd5 : 1;
//uint64_t exit_int_info : 63;
/* ** */
// AMD Manual 2, pg 391, sect: 15.19
struct Interrupt_Info exit_int_info;
uint64_t NP_ENABLE;
uint8_t rsvd7[16]; // Should be 0
// Offset 0xA8
struct Interrupt_Info EVENTINJ;
uint64_t N_CR3;
uint64_t LBR_VIRTUALIZATION_ENABLE;
} __attribute__((packed));
typedef struct VMCB_Control_Area vmcb_ctrl_t;
struct vmcb_selector {
uint16_t selector;
/* These attributes are basically a direct map of the attribute fields of a segment desc.
* The segment limit in the middle is removed and the fields are fused together
* There IS empty space at the end... See AMD Arch vol3, sect. 4.7.1, pg 78
*/
union {
uint16_t raw;
struct {
uint16_t type : 4; // segment type, [see Intel vol. 3b, sect. 3.4.5.1 (because I have the books)]
uint16_t S : 1; // System=0, code/data=1
uint16_t dpl : 2; // priviledge level, corresonds to protection ring
uint16_t P : 1; // present flag
uint16_t avl : 1; // available for use by system software
uint16_t L : 1; // long mode (64 bit?)
uint16_t db : 1; // default op size (0=16 bit seg, 1=32 bit seg)
uint16_t G : 1; // Granularity, (0=bytes, 1=4k)
uint16_t rsvd : 4;
} __attribute__((packed)) fields;
} __attribute__((packed)) attrib;
uint32_t limit;
uint64_t base;
} __attribute__((packed));
struct VMCB_State_Save_Area {
struct vmcb_selector es; // only lower 32 bits of base are implemented
struct vmcb_selector cs; // only lower 32 bits of base are implemented
struct vmcb_selector ss; // only lower 32 bits of base are implemented
struct vmcb_selector ds; // only lower 32 bits of base are implemented
struct vmcb_selector fs;
struct vmcb_selector gs;
struct vmcb_selector gdtr; // selector+attrib are reserved, only lower 16 bits of limit are implemented
struct vmcb_selector ldtr;
struct vmcb_selector idtr; // selector+attrib are reserved, only lower 16 bits of limit are implemented
struct vmcb_selector tr;
uint8_t rsvd1[43];
//offset 0x0cb
uint8_t cpl; // if the guest is real-mode then the CPL is forced to 0
// if the guest is virtual-mode then the CPL is forced to 3
uint32_t rsvd2;
// offset 0x0d0
uint64_t efer;
uint8_t rsvd3[112];
//offset 0x148
uint64_t cr4;
uint64_t cr3;
uint64_t cr0;
uint64_t dr7;
uint64_t dr6;
uint64_t rflags;
uint64_t rip;
uint8_t rsvd4[88];
//offset 0x1d8
uint64_t rsp;
uint8_t rsvd5[24];
//offset 0x1f8
uint64_t rax;
uint64_t star;
uint64_t lstar;
uint64_t cstar;
uint64_t sfmask;
uint64_t KernelGsBase;
uint64_t sysenter_cs;
uint64_t sysenter_esp;
uint64_t sysenter_eip;
uint64_t cr2;
uint8_t rsvd6[32];
//offset 0x268
uint64_t g_pat; /* Guest PAT (only used if nested paging is enabled) */
uint64_t dbgctl; /* Guest DBGCTL MSR (only used if the LBR registers are virtualized) */
uint64_t br_from; /* Guest LastBranchFromIP MSR (only used if the LBR registers are virtualized) */
uint64_t br_to; /* Guest LastBranchToIP MSR (only used if the LBR registers are virtualize) */
uint64_t lastexcpfrom; /* Guest LastExceptionFromIP MSR (only used if the LBR registers are virtualized) */
uint64_t lastexcpto; /* Guest LastExceptionToIP MSR (only used if the LBR registers are virtualized) */
} __attribute__((packed));
typedef struct VMCB_State_Save_Area vmcb_saved_state_t;
void v3_print_vmcb(vmcb_t * vmcb);
void v3_set_vmcb_segments(vmcb_t * vmcb, struct v3_segments * segs);
void v3_get_vmcb_segments(vmcb_t * vmcb, struct v3_segments * segs);
#endif // ! __V3VEE__
#endif
| 30.310627 | 115 | 0.58621 | [
"vector"
] |
812748270197fa3f8b010582d3125cfe986e35d7 | 2,433 | h | C | include/rtc_rtp_sender.h | dkubrakov/libwebrtc | 955b4c1e082f8bff7d82706c6cc82b91cf038527 | [
"MIT"
] | 1 | 2021-02-03T07:53:25.000Z | 2021-02-03T07:53:25.000Z | include/rtc_rtp_sender.h | dkubrakov/libwebrtc | 955b4c1e082f8bff7d82706c6cc82b91cf038527 | [
"MIT"
] | null | null | null | include/rtc_rtp_sender.h | dkubrakov/libwebrtc | 955b4c1e082f8bff7d82706c6cc82b91cf038527 | [
"MIT"
] | null | null | null | #ifndef LIBWEBRTC_RTC_RTP_SENDER_HXX
#define LIBWEBRTC_RTC_RTP_SENDER_HXX
#include "rtc_media_track.h"
#include "rtc_types.h"
namespace libwebrtc {
enum MediaType { MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO, MEDIA_TYPE_DATA };
struct RtpHeaderExtensionParameters {
public:
char uri[kMaxStringLength]{};
int id = 0;
bool encrypted = false;
};
struct RtpCodecParameters {
public:
int payload_type = 0;
char name[kMaxStringLength]{};
MediaType kind;
int clock_rate;
int num_channels;
// TODO std::unordered_map<std::string, std::string> parameters{};
};
struct RtpEncodingParameters : public RefCountInterface {
public:
char rid[kMaxStringLength]{};
bool active = true;
int max_bitrate_bps;
int min_bitrate_bps;
int max_framerate;
int num_temporal_layers;
double scale_resolution_down_by;
double scale_framerate_down_by;
int ssrc;
};
typedef Vector<scoped_refptr<RtpEncodingParameters>> RtpEncodingParametersVector;
struct RtcpParameters {
public:
uint32_t ssrc;
char cname[kMaxStringLength]{};
bool reduced_size = false;
bool mux = true;
};
struct RtpParameters {
public:
char transaction_id[kMaxStringLength]{};
char mid[kMaxStringLength]{};
// Vector<RtpCodecParameters> codecs{};
// Vector<scoped_refptr<RtpHeaderExtensionParameters>> header_extensions{};
RtpEncodingParametersVector encodings;
RtcpParameters rtcp{};
};
struct DtmfSender {
public:
int interToneGap; // @(dtmf.interToneGap / 1000.0) - Objective-C
int duration; // @(dtmf.duration / 1000.0) - Objective-C
};
class RTCRtpSender : public RefCountInterface{
public:
// senderId
virtual const char* id() const = 0;
virtual scoped_refptr<RTCMediaTrack> track() = 0;
virtual bool ownsTrack() = 0;
virtual RtpParameters parameters() = 0;
virtual RtpParameters* parameters1() = 0;
// not use in flutter - only 'sendDtmf'
virtual DtmfSender dtmfSender() = 0;
virtual RtpEncodingParametersVector encodings() = 0;
virtual const char* message() = 0;
protected:
virtual ~RTCRtpSender() {};
};
}
#endif //LIBWEBRTC_RTC_RTP_SENDER_HXX
| 25.082474 | 85 | 0.639129 | [
"vector"
] |
8128c229894680c3f1e321fc34c045fc6a5a76f5 | 13,977 | h | C | src/mixer/mixer.application.h | 3dhater/mixer | 52dca419de53abf3b61acd020c2fc9a52bce2255 | [
"libpng-2.0"
] | null | null | null | src/mixer/mixer.application.h | 3dhater/mixer | 52dca419de53abf3b61acd020c2fc9a52bce2255 | [
"libpng-2.0"
] | null | null | null | src/mixer/mixer.application.h | 3dhater/mixer | 52dca419de53abf3b61acd020c2fc9a52bce2255 | [
"libpng-2.0"
] | null | null | null | #ifndef _MI_APP_H_
#define _MI_APP_H_
#include "mixer.sdkImpl.h"
constexpr f32 g_leftPanelWidth = 24.f;
constexpr f32 g_topPanelHeight = 24.f;
constexpr f32 g_rightPanelWidth = 225.f;
constexpr f32 g_rightPanelButtonWidth = 24.f;
constexpr f32 g_bottomPanelHeight = 50.f;
#define miViewportBorderSize 1.f
#define miCommandID_CameraReset 1
#define miCommandID_CameraMoveToSelection 2
#define miCommandID_ViewportViewPerspective 3
#define miCommandID_ViewportViewFront 4
#define miCommandID_ViewportViewBack 5
#define miCommandID_ViewportViewTop 6
#define miCommandID_ViewportViewBottom 7
#define miCommandID_ViewportViewLeft 8
#define miCommandID_ViewportViewRight 9
#define miCommandID_ViewportToggleFullView 10
#define miCommandID_ViewportToggleGrid 11
#define miCommandID_ViewportDrawMaterial 12
#define miCommandID_ViewportDrawMaterialWireframe 13
#define miCommandID_ViewportDrawWireframe 14
#define miCommandID_ViewportToggleDrawMaterial 15
#define miCommandID_ViewportToggleDrawWireframe 16
#define miCommandID_ConvertToEditableObject 17
#define miCommandID_DeleteSelectedObjects 18
#define miCommandID_ViewportToggleDrawAABB 19
#define miCommandID_EditDuplicate 20
#define miCommandID_EditDuplicateMirrorX 21
#define miCommandID_EditDuplicateMirrorY 22
#define miCommandID_EditDuplicateMirrorZ 23
#define miCommandID_for_plugins 100
#define miViewportLayout_Full 0
#define miViewportLayout_Standart 1
#define miViewportLayout_Count 2
// right side of GUI
enum class miObjectParametersMode : u32
{
CommonParameters,
ObjectParameters,
Materials,
UV
};
enum class miEditorType
{
_3D,
UV
};
class miViewport;
class miViewportLayout;
class miSDKImpl;
class miShortcutManager;
class miPluginGUIImpl;
class miEditableObject;
class miRootObject;
class miViewportCamera;
class miGizmo;
class ApplicationGUI
{
public:
ApplicationGUI();
~ApplicationGUI();
void Init();
void OnSetTransformMode(miTransformMode mode);
void OnSetEditMode(miEditMode mode);
void OnObjectSelect();
void OnNewMaterial(miMaterial*);
void OnDeleteMaterial(miMaterial*);
void UpdateMaterialMapPictureBox();
miGUIContext* m_context = 0;
miGUIFont* m_fontDefault = 0;
miGUITextureAtlas* m_textureAtlas = 0;
u32 m_iconID_menu_main = 0;
u32 m_iconID_menu_parameters = 0;
u32 m_iconID_trMode_no = 0;
u32 m_iconID_trMode_move = 0;
u32 m_iconID_trMode_scale = 0;
u32 m_iconID_trMode_rotate = 0;
u32 m_iconID_trMode_scaleLocal = 0;
u32 m_iconID_trMode_rotateLocal = 0;
u32 m_iconID_edMode_vertex = 0;
u32 m_iconID_edMode_edge = 0;
u32 m_iconID_edMode_polygon = 0;
u32 m_iconID_prmCommon = 0;
u32 m_iconID_prmObject = 0;
u32 m_iconID_prmMaterial = 0;
u32 m_iconID_prmUV = 0;
miGUIText* m_txt_rotationAngle = 0;
// left panel with buttons
miGUIPanel* m_panel_left = 0;
miGUIButton* m_button_menu_main = 0;
miGUIButton* m_button_menu_parameters = 0;
// full window panel
miGUIPanel* m_panel_mainMenuBG = 0;
// `window` with save/load and other things
miGUIPanel* m_panel_mainMenu = 0;
miGUIPanel* m_panel_mainParameters = 0;
miGUIButton* m_button_trModeNo = 0;
miGUIButton* m_button_trModeMove = 0;
miGUIButton* m_button_trModeScale = 0;
miGUIButton* m_button_trModeRotate = 0;
miGUIButton* m_button_trModeScaleLocal = 0;
miGUIButton* m_button_trModeRotateLocal = 0;
miGUIButton* m_button_edModeVertex = 0;
miGUIButton* m_button_edModeEdge = 0;
miGUIButton* m_button_edModePolygon = 0;
miGUIPanel* m_panel_top = 0;
miGUIComboBox* m_cmbEditorType = 0;
miGUIComboBoxItem* m_cmbEditorTypeItem_3D = 0;
miGUIComboBoxItem* m_cmbEditorTypeItem_UV = 0;
miGUIPanel* m_panel_right = 0;
miGUITextInput* m_txtRename = 0;
miGUIButton* m_btnCommonParameters = 0;
miGUIButton* m_btnObjectParameters = 0;
miGUIButton* m_btnMaterials= 0;
miGUIButton* m_btnUV = 0;
miGUIPanel* m_panel_commonParameters = 0;
miGUIPanel* m_panel_UV = 0;
miGUIPanel* m_panel_materials = 0;
miGUIListBox* m_mtl_lstBx_materials = 0;
miGUIListBox* m_mtl_lstBx_maps = 0;
miGUIPictureBox* m_mtl_pictureBox_map = 0;
void AssignSelectedMaterial();
//void DeleteSelectedMaterial();
void LoadNewImageForMaterial();
void ReloadMaterialImage();
void DeleteImageFromMaterial();
//miGUIGroup* m_grp_cmnPrm_common = 0;
v3f m_rng_cmnPrm_position_many;
v3f m_rng_cmnPrm_pivotOffset_many;
miGUIRangeSlider* m_rng_cmnPrm_positionX = 0;
miGUIRangeSlider* m_rng_cmnPrm_positionY = 0;
miGUIRangeSlider* m_rng_cmnPrm_positionZ = 0;
miGUIRangeSlider* m_rng_cmnPrm_pivotX = 0;
miGUIRangeSlider* m_rng_cmnPrm_pivotY = 0;
miGUIRangeSlider* m_rng_cmnPrm_pivotZ = 0;
miGUIButton* m_btn_cmnPrm_pivotToObjCntr = 0;
miGUIButton* m_btn_cmnPrm_pivotToScnCntr = 0;
miGUIButton* m_btn_cmnPrm_pivotApply = 0;
miGUIButton* m_btn_cmnPrm_mtxReset = 0;
miGUIButton* m_btn_cmnPrm_mtxApply = 0;
miGUICheckBox* m_chk_cmnPrm_cullbf = 0;
//miGUIGroup* m_grp_cmnPrm_pivot = 0;
//miGUIGroup* m_grp_cmnPrm_matrix = 0;
miGUIPanel* m_panel_bottom = 0;
// full window panel
miGUIPanel* m_panel_onImportBG = 0;
miGUIPanel* m_panel_onImportWindow = 0;
miGUIButton* m_btn_import = 0;
miGUIButton* m_btn_export = 0;
v2f m_btn_import_size;
miPluginGUIImpl* m_activePluginGUI = 0;
void OnImport(miPluginGUI* gui);
void OnExport(miPluginGUI* gui);
miPluginGUIImpl* m_oldGui = 0;
miGUIComboBox* m_UVSaveTemplateSizeCombo = 0;
};
class miApplication
{
public:
miApplication();
~miApplication();
const char* m_version = "0.1.1";
miInputContext* m_inputContext = nullptr;
miLibContext* m_libContext = nullptr;
miWindow* m_mainWindow = nullptr;
f32 m_dt = 0.f;
miVideoDriver* m_gpu = nullptr;
v4f m_moveWindowRect;
miObjectParametersMode m_objectParametersMode = miObjectParametersMode::CommonParameters;
miCursor* m_cursors[(u32)miCursorType::_count];
std::vector<miStringA> m_supportedImages;
ApplicationGUI* m_GUI = 0;
void OnCreate(const char* videoDriver);
void MainLoop();
void WriteLog(const char* message);
miTransformMode m_transformMode = miTransformMode::NoTransform;
bool m_localScale = false;
bool m_localRotate = false;
void SetTransformMode(miTransformMode);
miEditMode m_editMode = miEditMode::Object;
void SetEditMode(miEditMode);
void ToggleEditMode(miEditMode);
miEditorType m_editorType = miEditorType::_3D;
void SetEditorType(miEditorType);
Aabb m_sceneAabb;
Aabb m_selectionAabb;
v4f m_selectionAabb_center;
v4f m_selectionAabb_extent;
void UpdateSceneAabb();
void UpdateSelectionAabb();
bool m_isSelectByRectangle = false;
bool m_isClickAndDrag = false;
v2f m_cursorLMBClickPosition; // save coords onLMB
v4f m_cursorLMBClickPosition3D; // intersection point
v4f m_cursorPosition3D; // intersection point
miMouseMode m_mouseMode = miMouseMode::CommonMode;
void SetMouseMode(miMouseMode mm);
miPlugin* m_pluginActive = 0;
miPlugin* m_pluginForApp = 0;
struct plugin_info {
miPlugin* m_plugin = 0;
std::string m_path;
};
miArray<plugin_info> m_plugins;
void _initPlugins();
std::string GetPluginFilePath(miPlugin* p);
miPlugin* GetPluginByFileName(const miString& p);
// for every popup command ID from plugins
u32 m_miCommandID_for_plugins_count = 0;
v2f m_gpuDepthRange;
// every viewport will set this when drawing
miViewport* m_currentViewportDraw = 0;
miViewport* m_viewportUnderCursor = 0;
miViewport* m_viewportInMouseFocus = 0; // lmb down and hold
miViewportLayout* m_activeViewportLayout = 0;
miViewportLayout* m_previousViewportLayout = 0; // save here when Alt + W
miViewportLayout* m_viewportLayouts[miViewportLayout_Count];
miViewportLayout* m_UVViewport = 0;
void _initViewports();
void UpdateViewports();
miPopup* _getPopupInViewport();
void DrawViewports();
void _callViewportOnWindowSize();
// надо определить первый клик в зоне вьюпорта. если был то true. потом двигать камеру и объекты
// только если m_isViewportInFocus == true;
bool m_isViewportInFocus = false;
miViewportCamera* GetActiveCamera();
// true if text input is active
bool m_isGUIInputFocus = false;
bool m_isCursorInViewport = false;
bool m_isCursorInUVEditor = false;
bool m_isCursorInWindow = false;
bool m_isCursorInGUI = false;
// true if mouseDelta != 0
bool m_isCursorMove = false;
miArray<miSceneObject*> m_objectsOnScene;
// call it when acreate/import/duplicate/delete...other_operations object
void _updateObjectsOnSceneArray(miSceneObject*);
void _updateObjectsOnSceneArray();
miArray<miSceneObject*> m_selectedObjects;
void _update_selected_objects_array(miSceneObject*);
void UpdateSelectedObjectsArray();
void _initPopups();
miPopup* m_popup_ViewportCamera = 0;
miPopup* m_popup_ViewportParameters = 0;
miPopup* m_popup_NewObject = 0;
miPopup* m_popup_Importers = 0;
miPopup* m_popup_Exporters = 0;
miPopup* m_popup_edit = 0;
miViewport* m_popupViewport = 0;
void ShowPopupAtCursor(miPopup* popup);
// like camera frustum but build from 2d rectangle or aabb
// very easy to select object/vertex/edge/polygon using this
miSelectionFrust* m_selectionFrust = 0;
miSDKImpl* m_sdk = 0;
bool _isDoNotSelect();
bool _isVertexMouseHover();
bool _isEdgeMouseHover();
void _isObjectMouseHover();
//bool m_isMouseHoverEdge = false;
miVertex* m_mouseHoverVertex = 0;
miEdge* m_mouseHoverEdge = 0;
miSceneObject* m_mouseHoverObject = 0;
miColor m_color_windowClearColor = miColor(0.41f);
miColor m_color_viewportColor = miColor(0.35f);
miColor m_color_viewportBorder = ColorDarkGray;
miGPUMesh* m_gridModel_perspective1 = 0;
miGPUMesh* m_gridModel_perspective2 = 0;
miGPUMesh* m_gridModel_top1 = 0;
miGPUMesh* m_gridModel_top2 = 0;
miGPUMesh* m_gridModel_front1 = 0;
miGPUMesh* m_gridModel_front2 = 0;
miGPUMesh* m_gridModel_left1 = 0;
miGPUMesh* m_gridModel_left2 = 0;
miMaterial m_gridModelMaterial;
void _initGrid();
miRay m_screenRayOnClick;
miRay m_screenRayCurrent;
miShortcutManager* m_shortcutManager = 0;
void ProcessShortcuts3D();
void ProcessShortcutsUV();
bool m_UVFitInRange0_1 = true;
Aabb m_UVAabb;
Aabb m_UVAabbOnClick;
v4f m_UVAabbCenterOnClick;
v4f m_UVAabbMoveOffset;
f32 m_UVAngle;
void UVSelectAll();
void CameraMoveToSelection();
void CameraReset();
void ViewportChangeView(miViewportCameraType);
void ViewportToggleFullView();
void ViewportToggleGrid();
void ViewportToggleDrawMaterial();
void ViewportToggleDrawWireframe();
void ViewportToggleAABB();
void ViewportSetDrawMode(miViewportDrawMode);
void SelectAll();
void _deselectAll();
void DeselectAll();
void InvertSelection();
void DeleteSelected();
void DeleteObject(miSceneObject*);
void ConvertSelectedObjectsToEditableObjects();
miEditableObject* ConvertObjectToEditableObject(miSceneObject*);
void _initEditableObjectGUI();
miPluginGUIImpl* m_currentPluginGUI = 0;
miPluginGUIImpl* m_pluginGuiForEditableObject = 0;
miArray<miPluginGUI*> m_pluginGuiAll;
miString GetFreeName(const wchar_t* name);
miRootObject* m_rootObject = 0;
void AddObjectToScene(miSceneObject* o, const wchar_t* name);
void NameIsFree(const miString& name, miSceneObject*, u8*);
void DestroyAllSceneObjects(miSceneObject* o);
void RemoveObjectFromScene(miSceneObject* o);
void EditDuplicate(bool isMirror, miAxis x);
miImporter* m_onImport_importer = 0;
void OnImport(miImporter* importer);
void OnImport_openDialog();
miImporter* m_onExport_exporter = 0;
void OnExport(miImporter* exporter);
void OnExport_openDialog();
miGPUTexture* m_transparentTexture = 0;
miGPUTexture* m_blackTexture = 0;
miGPUTexture* m_UVPlaneTexture = 0;
miGPUMesh* m_UVPlaneModel = 0;
void OnGizmoUVClick();
void UVTransform();
void UVTransformCancel();
void UVTransformAccept();
void UvMakePlanar(bool useScreenPlane);
void UvFlattenMapping();
void UvSaveUVTemplate();
void DrawAabb(const Aabb& aabb, const v4f& _color, const v3f& offset);
miGizmoMode m_gizmoMode = miGizmoMode::NoTransform;
miGizmoUVMode m_gizmoModeUV = miGizmoUVMode::NoTransform;
void _setGizmoMode(miGizmoMode);
miGizmo* m_gizmo = 0;
bool m_isGizmoMouseHover = false;
miRay m_rayCursor;
void _getRayFromCursor();
miArray<miSceneObject*> m_objectsUnderCursor;
void _getObjectsUnderCursor();
void _getViewportUnderCursor();
// I need to know if vertex or edge or polygon is selected
bool m_isVertexEdgePolygonSelected = false;
void _updateIsVertexEdgePolygonSelected();
// Call this when select (LMB click, or when m_isSelectByRectangle == true, or when selectiong by other function)
void OnSelect();
void _callVisualObjectOnSelect();
void DrawSelectionBox(const v2f& p1, const v2f& p2);
// call this when select using mouse (LMB or m_isSelectByRectangle)
void _select();
void _select_multiple();
void _select_single();
void _transformObjects();
void _transformObjects_move(miSceneObject* o);
void _transformObjects_scale(miSceneObject* o);
void _transformObjects_rotate(miSceneObject* o);
void _transformObjectsReset();
void _transformObjectsApply();
// second - 0 or 1. 0 free. 1 used.
//miArray<miPair<miMaterial*, u8>*> m_materials;
miArray<miMaterial*> m_materials;
miMaterial* MaterialCreate();
miGPUTexture* MaterialGetTexture(const wchar_t*);
void MaterialDeleteTexture(miGPUTexture*);
void MaterialRename(miMaterial* m, const wchar_t* newName);
void MaterialAssign(miMaterial* m, miSceneObject* object);
void MaterialDeleteAll();
void MaterialDelete(miMaterial*);
miString MaterialGetFreeName(const wchar_t*);
s32 m_materialNameCounter = 0;
// for example when RMB when targetWeld button is active
void CallPluginGUIOnCancel();
void CallSelectObjectCallback();
void OnDragNDropFiles(u32 num, u32 i, const wchar_t*, f32 x, f32 y);
void OnDragNDropFiles_assignNewMaterial(const wchar_t* fn);
miString m_workingSceneFile;
bool SceneNew();
void SceneOpen();
bool SceneSave();
bool SceneSaveAs();
void _sceneSave();
void _sceneLoad();
u32 m_sceneFileVersion = 1;
bool m_needSave = false;
void NeedSave();
void UpdateWindowTitle();
bool AskNeedSave();
};
#endif | 29.179541 | 114 | 0.793518 | [
"object",
"vector"
] |
813b80aa87cb47c913a47abc3328c07403836705 | 20,352 | c | C | software/mesa/src/gallium/drivers/ilo/ilo_render_dynamic.c | dhanna11/OpenGPU | ab2f01253bba311e082dfae695b9e70138de75d4 | [
"Apache-2.0"
] | 7 | 2019-09-04T03:44:26.000Z | 2022-01-06T02:54:24.000Z | software/mesa/src/gallium/drivers/ilo/ilo_render_dynamic.c | dhanna11/OpenGPU | ab2f01253bba311e082dfae695b9e70138de75d4 | [
"Apache-2.0"
] | null | null | null | software/mesa/src/gallium/drivers/ilo/ilo_render_dynamic.c | dhanna11/OpenGPU | ab2f01253bba311e082dfae695b9e70138de75d4 | [
"Apache-2.0"
] | 3 | 2021-06-11T23:53:38.000Z | 2021-08-31T03:18:34.000Z | /*
* Mesa 3-D graphics library
*
* Copyright (C) 2012-2014 LunarG, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Chia-I Wu <olv@lunarg.com>
*/
#include "core/ilo_builder_3d.h"
#include "core/ilo_builder_media.h"
#include "ilo_common.h"
#include "ilo_blitter.h"
#include "ilo_shader.h"
#include "ilo_state.h"
#include "ilo_render_gen.h"
#define DIRTY(state) (session->pipe_dirty & ILO_DIRTY_ ## state)
static void
gen6_emit_draw_dynamic_viewports(struct ilo_render *r,
const struct ilo_state_vector *vec,
struct ilo_render_draw_session *session)
{
ILO_DEV_ASSERT(r->dev, 6, 6);
/* CLIP_VIEWPORT, SF_VIEWPORT, and CC_VIEWPORT */
if ((session->vp_delta.dirty & (ILO_STATE_VIEWPORT_SF_CLIP_VIEWPORT |
ILO_STATE_VIEWPORT_CC_VIEWPORT)) ||
r->state_bo_changed) {
r->state.CLIP_VIEWPORT = gen6_CLIP_VIEWPORT(r->builder,
&vec->viewport.vp);
r->state.SF_VIEWPORT = gen6_SF_VIEWPORT(r->builder, &vec->viewport.vp);
r->state.CC_VIEWPORT = gen6_CC_VIEWPORT(r->builder, &vec->viewport.vp);
session->viewport_changed = true;
}
}
static void
gen7_emit_draw_dynamic_viewports(struct ilo_render *r,
const struct ilo_state_vector *vec,
struct ilo_render_draw_session *session)
{
ILO_DEV_ASSERT(r->dev, 7, 8);
/* SF_CLIP_VIEWPORT and CC_VIEWPORT */
if ((session->vp_delta.dirty & (ILO_STATE_VIEWPORT_SF_CLIP_VIEWPORT |
ILO_STATE_VIEWPORT_CC_VIEWPORT)) ||
r->state_bo_changed) {
r->state.SF_CLIP_VIEWPORT = gen7_SF_CLIP_VIEWPORT(r->builder,
&vec->viewport.vp);
r->state.CC_VIEWPORT = gen6_CC_VIEWPORT(r->builder, &vec->viewport.vp);
session->viewport_changed = true;
}
}
static void
gen6_emit_draw_dynamic_scissors(struct ilo_render *r,
const struct ilo_state_vector *vec,
struct ilo_render_draw_session *session)
{
ILO_DEV_ASSERT(r->dev, 6, 8);
/* SCISSOR_RECT */
if ((session->vp_delta.dirty & ILO_STATE_VIEWPORT_SCISSOR_RECT) ||
r->state_bo_changed) {
r->state.SCISSOR_RECT = gen6_SCISSOR_RECT(r->builder,
&vec->viewport.vp);
session->scissor_changed = true;
}
}
static void
gen6_emit_draw_dynamic_cc(struct ilo_render *r,
const struct ilo_state_vector *vec,
struct ilo_render_draw_session *session)
{
ILO_DEV_ASSERT(r->dev, 6, 8);
/* BLEND_STATE */
if ((session->cc_delta.dirty & ILO_STATE_CC_BLEND_STATE) ||
r->state_bo_changed) {
if (ilo_dev_gen(r->dev) >= ILO_GEN(8))
r->state.BLEND_STATE = gen8_BLEND_STATE(r->builder, &vec->blend->cc);
else
r->state.BLEND_STATE = gen6_BLEND_STATE(r->builder, &vec->blend->cc);
session->blend_changed = true;
}
/* COLOR_CALC_STATE */
if ((session->cc_delta.dirty & ILO_STATE_CC_COLOR_CALC_STATE) ||
r->state_bo_changed) {
r->state.COLOR_CALC_STATE =
gen6_COLOR_CALC_STATE(r->builder, &vec->blend->cc);
session->cc_changed = true;
}
/* DEPTH_STENCIL_STATE */
if (ilo_dev_gen(r->dev) < ILO_GEN(8) &&
((session->cc_delta.dirty & ILO_STATE_CC_DEPTH_STENCIL_STATE) ||
r->state_bo_changed)) {
r->state.DEPTH_STENCIL_STATE =
gen6_DEPTH_STENCIL_STATE(r->builder, &vec->blend->cc);
session->dsa_changed = true;
}
}
static void
gen6_emit_draw_dynamic_samplers(struct ilo_render *r,
const struct ilo_state_vector *vec,
int shader_type,
struct ilo_render_draw_session *session)
{
const struct ilo_view_cso * const *views =
(const struct ilo_view_cso **) vec->view[shader_type].states;
struct ilo_state_sampler samplers[ILO_MAX_SAMPLERS];
uint32_t *sampler_state, *border_color_state;
int sampler_count, i;
bool emit_border_color = false;
bool skip = false;
ILO_DEV_ASSERT(r->dev, 6, 8);
/* SAMPLER_BORDER_COLOR_STATE and SAMPLER_STATE */
switch (shader_type) {
case PIPE_SHADER_VERTEX:
if (DIRTY(VS) || DIRTY(SAMPLER_VS) || DIRTY(VIEW_VS)) {
sampler_state = &r->state.vs.SAMPLER_STATE;
border_color_state = r->state.vs.SAMPLER_BORDER_COLOR_STATE;
if (DIRTY(VS) || DIRTY(SAMPLER_VS))
emit_border_color = true;
sampler_count = (vec->vs) ? ilo_shader_get_kernel_param(vec->vs,
ILO_KERNEL_SAMPLER_COUNT) : 0;
session->sampler_vs_changed = true;
} else {
skip = true;
}
break;
case PIPE_SHADER_FRAGMENT:
if (DIRTY(FS) || DIRTY(SAMPLER_FS) || DIRTY(VIEW_FS)) {
sampler_state = &r->state.wm.SAMPLER_STATE;
border_color_state = r->state.wm.SAMPLER_BORDER_COLOR_STATE;
if (DIRTY(VS) || DIRTY(SAMPLER_FS))
emit_border_color = true;
sampler_count = (vec->fs) ? ilo_shader_get_kernel_param(vec->fs,
ILO_KERNEL_SAMPLER_COUNT) : 0;
session->sampler_fs_changed = true;
} else {
skip = true;
}
break;
default:
skip = true;
break;
}
if (skip)
return;
assert(sampler_count <= ARRAY_SIZE(vec->view[shader_type].states) &&
sampler_count <= ARRAY_SIZE(vec->sampler[shader_type].cso));
if (emit_border_color) {
for (i = 0; i < sampler_count; i++) {
const struct ilo_sampler_cso *cso = vec->sampler[shader_type].cso[i];
border_color_state[i] = (cso) ?
gen6_SAMPLER_BORDER_COLOR_STATE(r->builder, &cso->border) : 0;
}
}
for (i = 0; i < sampler_count; i++) {
const struct ilo_sampler_cso *cso = vec->sampler[shader_type].cso[i];
if (cso && views[i]) {
samplers[i] = cso->sampler;
ilo_state_sampler_set_surface(&samplers[i],
r->dev, &views[i]->surface);
} else {
samplers[i] = vec->disabled_sampler;
}
}
*sampler_state = gen6_SAMPLER_STATE(r->builder, samplers,
border_color_state, sampler_count);
}
static void
gen6_emit_draw_dynamic_pcb(struct ilo_render *r,
const struct ilo_state_vector *vec,
struct ilo_render_draw_session *session)
{
ILO_DEV_ASSERT(r->dev, 6, 8);
/* push constant buffer for VS */
if (DIRTY(VS) || DIRTY(CBUF) || DIRTY(CLIP)) {
const int cbuf0_size = (vec->vs) ?
ilo_shader_get_kernel_param(vec->vs,
ILO_KERNEL_PCB_CBUF0_SIZE) : 0;
const int clip_state_size = (vec->vs) ?
ilo_shader_get_kernel_param(vec->vs,
ILO_KERNEL_VS_PCB_UCP_SIZE) : 0;
const int total_size = cbuf0_size + clip_state_size;
if (total_size) {
void *pcb;
r->state.vs.PUSH_CONSTANT_BUFFER =
gen6_push_constant_buffer(r->builder, total_size, &pcb);
r->state.vs.PUSH_CONSTANT_BUFFER_size = total_size;
if (cbuf0_size) {
const struct ilo_cbuf_state *cbuf =
&vec->cbuf[PIPE_SHADER_VERTEX];
if (cbuf0_size <= cbuf->cso[0].info.size) {
memcpy(pcb, cbuf->cso[0].user_buffer, cbuf0_size);
} else {
memcpy(pcb, cbuf->cso[0].user_buffer,
cbuf->cso[0].info.size);
memset(pcb + cbuf->cso[0].info.size, 0,
cbuf0_size - cbuf->cso[0].info.size);
}
pcb += cbuf0_size;
}
if (clip_state_size)
memcpy(pcb, &vec->clip, clip_state_size);
session->pcb_vs_changed = true;
} else if (r->state.vs.PUSH_CONSTANT_BUFFER_size) {
r->state.vs.PUSH_CONSTANT_BUFFER = 0;
r->state.vs.PUSH_CONSTANT_BUFFER_size = 0;
session->pcb_vs_changed = true;
}
}
/* push constant buffer for FS */
if (DIRTY(FS) || DIRTY(CBUF)) {
const int cbuf0_size = (vec->fs) ?
ilo_shader_get_kernel_param(vec->fs, ILO_KERNEL_PCB_CBUF0_SIZE) : 0;
if (cbuf0_size) {
const struct ilo_cbuf_state *cbuf = &vec->cbuf[PIPE_SHADER_FRAGMENT];
void *pcb;
r->state.wm.PUSH_CONSTANT_BUFFER =
gen6_push_constant_buffer(r->builder, cbuf0_size, &pcb);
r->state.wm.PUSH_CONSTANT_BUFFER_size = cbuf0_size;
if (cbuf0_size <= cbuf->cso[0].info.size) {
memcpy(pcb, cbuf->cso[0].user_buffer, cbuf0_size);
} else {
memcpy(pcb, cbuf->cso[0].user_buffer,
cbuf->cso[0].info.size);
memset(pcb + cbuf->cso[0].info.size, 0,
cbuf0_size - cbuf->cso[0].info.size);
}
session->pcb_fs_changed = true;
} else if (r->state.wm.PUSH_CONSTANT_BUFFER_size) {
r->state.wm.PUSH_CONSTANT_BUFFER = 0;
r->state.wm.PUSH_CONSTANT_BUFFER_size = 0;
session->pcb_fs_changed = true;
}
}
}
#undef DIRTY
int
ilo_render_get_draw_dynamic_states_len(const struct ilo_render *render,
const struct ilo_state_vector *vec)
{
static int static_len;
int sh_type, len;
ILO_DEV_ASSERT(render->dev, 6, 8);
if (!static_len) {
/* 64 bytes, or 16 dwords */
const int alignment = 64 / 4;
/* pad first */
len = alignment - 1;
/* CC states */
len += align(GEN6_BLEND_STATE__SIZE, alignment);
len += align(GEN6_COLOR_CALC_STATE__SIZE, alignment);
if (ilo_dev_gen(render->dev) < ILO_GEN(8))
len += align(GEN6_DEPTH_STENCIL_STATE__SIZE, alignment);
/* viewport arrays */
if (ilo_dev_gen(render->dev) >= ILO_GEN(7)) {
len += 15 + /* pad first */
align(GEN7_SF_CLIP_VIEWPORT__SIZE, 16) +
align(GEN6_CC_VIEWPORT__SIZE, 8) +
align(GEN6_SCISSOR_RECT__SIZE, 8);
} else {
len += 7 + /* pad first */
align(GEN6_SF_VIEWPORT__SIZE, 8) +
align(GEN6_CLIP_VIEWPORT__SIZE, 8) +
align(GEN6_CC_VIEWPORT__SIZE, 8) +
align(GEN6_SCISSOR_RECT__SIZE, 8);
}
static_len = len;
}
len = static_len;
for (sh_type = 0; sh_type < PIPE_SHADER_TYPES; sh_type++) {
const int alignment = 32 / 4;
int num_samplers = 0, pcb_len = 0;
switch (sh_type) {
case PIPE_SHADER_VERTEX:
if (vec->vs) {
num_samplers = ilo_shader_get_kernel_param(vec->vs,
ILO_KERNEL_SAMPLER_COUNT);
pcb_len = ilo_shader_get_kernel_param(vec->vs,
ILO_KERNEL_PCB_CBUF0_SIZE);
pcb_len += ilo_shader_get_kernel_param(vec->vs,
ILO_KERNEL_VS_PCB_UCP_SIZE);
}
break;
case PIPE_SHADER_GEOMETRY:
break;
case PIPE_SHADER_FRAGMENT:
if (vec->fs) {
num_samplers = ilo_shader_get_kernel_param(vec->fs,
ILO_KERNEL_SAMPLER_COUNT);
pcb_len = ilo_shader_get_kernel_param(vec->fs,
ILO_KERNEL_PCB_CBUF0_SIZE);
}
break;
default:
break;
}
/* SAMPLER_STATE array and SAMPLER_BORDER_COLORs */
if (num_samplers) {
/* prefetches are done in multiples of 4 */
num_samplers = align(num_samplers, 4);
len += align(GEN6_SAMPLER_STATE__SIZE * num_samplers, alignment);
if (ilo_dev_gen(render->dev) >= ILO_GEN(8)) {
len += align(GEN6_SAMPLER_BORDER_COLOR_STATE__SIZE, 64 / 4) *
num_samplers;
} else {
len += align(GEN6_SAMPLER_BORDER_COLOR_STATE__SIZE, alignment) *
num_samplers;
}
}
/* PCB */
if (pcb_len)
len += align(pcb_len, alignment);
}
return len;
}
void
ilo_render_emit_draw_dynamic_states(struct ilo_render *render,
const struct ilo_state_vector *vec,
struct ilo_render_draw_session *session)
{
const unsigned dynamic_used = ilo_builder_dynamic_used(render->builder);
ILO_DEV_ASSERT(render->dev, 6, 8);
if (ilo_dev_gen(render->dev) >= ILO_GEN(7))
gen7_emit_draw_dynamic_viewports(render, vec, session);
else
gen6_emit_draw_dynamic_viewports(render, vec, session);
gen6_emit_draw_dynamic_cc(render, vec, session);
gen6_emit_draw_dynamic_scissors(render, vec, session);
gen6_emit_draw_dynamic_pcb(render, vec, session);
gen6_emit_draw_dynamic_samplers(render, vec,
PIPE_SHADER_VERTEX, session);
gen6_emit_draw_dynamic_samplers(render, vec,
PIPE_SHADER_FRAGMENT, session);
assert(ilo_builder_dynamic_used(render->builder) <= dynamic_used +
ilo_render_get_draw_dynamic_states_len(render, vec));
}
int
ilo_render_get_rectlist_dynamic_states_len(const struct ilo_render *render,
const struct ilo_blitter *blitter)
{
ILO_DEV_ASSERT(render->dev, 6, 8);
return (ilo_dev_gen(render->dev) >= ILO_GEN(8)) ? 0 : 96;
}
void
ilo_render_emit_rectlist_dynamic_states(struct ilo_render *render,
const struct ilo_blitter *blitter,
struct ilo_render_rectlist_session *session)
{
const unsigned dynamic_used = ilo_builder_dynamic_used(render->builder);
ILO_DEV_ASSERT(render->dev, 6, 8);
if (ilo_dev_gen(render->dev) >= ILO_GEN(8))
return;
/* both are inclusive */
session->vb_start = gen6_user_vertex_buffer(render->builder,
sizeof(blitter->vertices), (const void *) blitter->vertices);
session->vb_end = session->vb_start + sizeof(blitter->vertices) - 1;
if (blitter->uses & ILO_BLITTER_USE_DSA) {
render->state.DEPTH_STENCIL_STATE =
gen6_DEPTH_STENCIL_STATE(render->builder, &blitter->cc);
}
if (blitter->uses & ILO_BLITTER_USE_CC) {
render->state.COLOR_CALC_STATE =
gen6_COLOR_CALC_STATE(render->builder, &blitter->cc);
}
if (blitter->uses & ILO_BLITTER_USE_VIEWPORT) {
render->state.CC_VIEWPORT =
gen6_CC_VIEWPORT(render->builder, &blitter->vp);
}
assert(ilo_builder_dynamic_used(render->builder) <= dynamic_used +
ilo_render_get_rectlist_dynamic_states_len(render, blitter));
}
static void
gen6_emit_launch_grid_dynamic_samplers(struct ilo_render *r,
const struct ilo_state_vector *vec,
struct ilo_render_launch_grid_session *session)
{
const unsigned shader_type = PIPE_SHADER_COMPUTE;
const struct ilo_shader_state *cs = vec->cs;
const struct ilo_view_cso * const *views =
(const struct ilo_view_cso **) vec->view[shader_type].states;
struct ilo_state_sampler samplers[ILO_MAX_SAMPLERS];
int sampler_count, i;
ILO_DEV_ASSERT(r->dev, 7, 7.5);
sampler_count = ilo_shader_get_kernel_param(cs, ILO_KERNEL_SAMPLER_COUNT);
assert(sampler_count <= ARRAY_SIZE(vec->view[shader_type].states) &&
sampler_count <= ARRAY_SIZE(vec->sampler[shader_type].cso));
for (i = 0; i < sampler_count; i++) {
const struct ilo_sampler_cso *cso = vec->sampler[shader_type].cso[i];
r->state.cs.SAMPLER_BORDER_COLOR_STATE[i] = (cso) ?
gen6_SAMPLER_BORDER_COLOR_STATE(r->builder, &cso->border) : 0;
}
for (i = 0; i < sampler_count; i++) {
const struct ilo_sampler_cso *cso = vec->sampler[shader_type].cso[i];
if (cso && views[i]) {
samplers[i] = cso->sampler;
ilo_state_sampler_set_surface(&samplers[i],
r->dev, &views[i]->surface);
} else {
samplers[i] = vec->disabled_sampler;
}
}
r->state.cs.SAMPLER_STATE = gen6_SAMPLER_STATE(r->builder, samplers,
r->state.cs.SAMPLER_BORDER_COLOR_STATE, sampler_count);
}
static void
gen6_emit_launch_grid_dynamic_pcb(struct ilo_render *r,
const struct ilo_state_vector *vec,
struct ilo_render_launch_grid_session *session)
{
r->state.cs.PUSH_CONSTANT_BUFFER = 0;
r->state.cs.PUSH_CONSTANT_BUFFER_size = 0;
}
static void
gen6_emit_launch_grid_dynamic_idrt(struct ilo_render *r,
const struct ilo_state_vector *vec,
struct ilo_render_launch_grid_session *session)
{
const struct ilo_shader_state *cs = vec->cs;
struct ilo_state_compute_interface_info interface;
struct ilo_state_compute_info info;
uint32_t kernel_offset;
ILO_DEV_ASSERT(r->dev, 7, 7.5);
memset(&interface, 0, sizeof(interface));
interface.sampler_count =
ilo_shader_get_kernel_param(cs, ILO_KERNEL_SAMPLER_COUNT);
interface.surface_count =
ilo_shader_get_kernel_param(cs, ILO_KERNEL_SURFACE_TOTAL_COUNT);
interface.thread_group_size = session->thread_group_size;
interface.slm_size =
ilo_shader_get_kernel_param(cs, ILO_KERNEL_CS_LOCAL_SIZE);
interface.curbe_read_length = r->state.cs.PUSH_CONSTANT_BUFFER_size;
memset(&info, 0, sizeof(info));
info.data = session->compute_data;
info.data_size = sizeof(session->compute_data);
info.interfaces = &interface;
info.interface_count = 1;
info.cv_urb_alloc_size = r->dev->urb_size;
info.curbe_alloc_size = r->state.cs.PUSH_CONSTANT_BUFFER_size;
ilo_state_compute_init(&session->compute, r->dev, &info);
kernel_offset = ilo_shader_get_kernel_offset(cs);
session->idrt = gen6_INTERFACE_DESCRIPTOR_DATA(r->builder,
&session->compute, &kernel_offset,
&r->state.cs.SAMPLER_STATE, &r->state.cs.BINDING_TABLE_STATE);
session->idrt_size = 32;
}
int
ilo_render_get_launch_grid_dynamic_states_len(const struct ilo_render *render,
const struct ilo_state_vector *vec)
{
const int alignment = 32 / 4;
int num_samplers;
int len = 0;
ILO_DEV_ASSERT(render->dev, 7, 7.5);
num_samplers = ilo_shader_get_kernel_param(vec->cs,
ILO_KERNEL_SAMPLER_COUNT);
/* SAMPLER_STATE array and SAMPLER_BORDER_COLORs */
if (num_samplers) {
/* prefetches are done in multiples of 4 */
num_samplers = align(num_samplers, 4);
len += align(GEN6_SAMPLER_STATE__SIZE * num_samplers, alignment) +
align(GEN6_SAMPLER_BORDER_COLOR_STATE__SIZE, alignment) *
num_samplers;
}
len += GEN6_INTERFACE_DESCRIPTOR_DATA__SIZE;
return len;
}
void
ilo_render_emit_launch_grid_dynamic_states(struct ilo_render *render,
const struct ilo_state_vector *vec,
struct ilo_render_launch_grid_session *session)
{
const unsigned dynamic_used = ilo_builder_dynamic_used(render->builder);
ILO_DEV_ASSERT(render->dev, 7, 7.5);
gen6_emit_launch_grid_dynamic_samplers(render, vec, session);
gen6_emit_launch_grid_dynamic_pcb(render, vec, session);
gen6_emit_launch_grid_dynamic_idrt(render, vec, session);
assert(ilo_builder_dynamic_used(render->builder) <= dynamic_used +
ilo_render_get_launch_grid_dynamic_states_len(render, vec));
}
| 33.584158 | 90 | 0.634778 | [
"render"
] |
81451337abffe64c8d6b6aaa78d7e1d1ffe1ce6a | 621 | h | C | algorithms/sort/comparison/selection/selection.h | gau0522/Algorithms-DataStructures | c6a262bc582b6b2a3cd0394c25cc1efd9ed1f3ed | [
"MIT"
] | null | null | null | algorithms/sort/comparison/selection/selection.h | gau0522/Algorithms-DataStructures | c6a262bc582b6b2a3cd0394c25cc1efd9ed1f3ed | [
"MIT"
] | null | null | null | algorithms/sort/comparison/selection/selection.h | gau0522/Algorithms-DataStructures | c6a262bc582b6b2a3cd0394c25cc1efd9ed1f3ed | [
"MIT"
] | null | null | null | #ifndef SELECTION_H_INCLUDED
#define SELECTION_H_INCLUDED
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
#include "utils/basic.h"
void selection_sort(
std::vector<int> &arr,
int n){
for(int i=0; i<n; i++){
int min_index=-1;
int min_v=INT_MAX;
for(int j=i; j<n; j++){
if(arr[j]<min_v){
min_v=arr[j];
min_index=j;
}
}
// replace swap with shifting to make this stable sort
std::swap(arr[i], arr[min_index]);
}
return;
}
#endif // SELECTION_H_INCLUDED | 21.413793 | 62 | 0.52818 | [
"vector"
] |
81479c7a20d7bbeeecae8acbcd23373598459f3b | 28,463 | c | C | vector-clocks/vectorClocks.c | 108bots/Archives | 8ada367fd83cc5e699ab48e9c6edf586ccbb219b | [
"MIT"
] | null | null | null | vector-clocks/vectorClocks.c | 108bots/Archives | 8ada367fd83cc5e699ab48e9c6edf586ccbb219b | [
"MIT"
] | null | null | null | vector-clocks/vectorClocks.c | 108bots/Archives | 8ada367fd83cc5e699ab48e9c6edf586ccbb219b | [
"MIT"
] | null | null | null | /*
Vector Clocks Program
Authors : Hemanth Srinivasan
Year: 2007
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <signal.h>
#include <sys/wait.h>
#include <math.h>
#include <pthread.h>
#define SERVER_PORT 6061
int *vectorClock;
struct vcMessage {
char **msgTimestamp;
char data[5];
};
int numProcess; //number of processes in the distributed system
int dValue; // incremental d value in vector clocks
int tMin, tMax; //timeout range for msg generation
float pValue; // probability of local and send events
int EValue; // total event count
char **peerAddrList;
char logfileName[25];
char inputfileName[25];
int selfID; //ID of this process
int *connected_socks; /* Array of connected sockets to know who we are talking to */
//pthread variables
pthread_mutex_t safe_mutex, vector_mutex, file_mutex, connect_mutex;
FILE *logfile;
char title[] = "Event Type To/From Vector Clock\n\n";
//function declarations
void parse_Input (void);
int is_Connected (int);
void set_Connected (int, int);
void *serverFunctionThread (void *arg);
void *clientFunctionThread (void *arg);
int getProcessID (struct in_addr);
void updateLogfile (char [], int *, int);
int readVectorClock (int);
void writeVectorClock (int, int);
void vectorClockSimulation (void);
int randomTimeout (void);
int eventType (void);
int *randomPeerSelect (void);
char *buildsendMsg(void);
void itoa(int, char []);
int updateVectorTimeStamp(char *);
void printVectorClock ();
int main (int argc, char *argv[]) {
int i;
pthread_t clientThread_id;
pthread_t serverThread_id;
void *cexitStatus,*sexitStatus;
if (argc != 3) {
printf("\nUsage: vectorClocks <ProcessID> <Config File>\n");
exit(0);
}
strcpy (inputfileName, argv[2]);
strcpy (logfileName, argv[1]);
strcat (logfileName, "_");
strcat (logfileName, "vectorClocks.log");
selfID = atoi(argv[1]);
printf("\nReading Input File...\n");
//function call to parse the input file and fill up the parameters
parse_Input();
//Allocate space and Initialize vector clock structure
vectorClock = (int *)malloc(numProcess * sizeof(int));
for (i = 0; i < numProcess; i++)
vectorClock[i] = 0;
//create log file
if ((logfile = fopen(logfileName, "w")) == NULL) {
printf("\nError in creating log file\n");
}
if (fputs(title, logfile) < 0) {
printf("\nError in writing to log file\n");
}
fclose(logfile);
//initialize the mutexes
pthread_mutex_init(&safe_mutex,NULL);
pthread_mutex_init(&vector_mutex,NULL);
pthread_mutex_init(&file_mutex,NULL);
pthread_mutex_init(&connect_mutex,NULL);
//list of connected sockets
connected_socks = (int *)malloc(numProcess * sizeof(int));
for (i = 0; i < numProcess; i++ )
connected_socks[i] = -1;
// Creating worker threads
if(pthread_create(&clientThread_id,NULL,clientFunctionThread,NULL) < 0) {
printf("\nProblem in client worker thread creation \n");
}
if(pthread_create(&serverThread_id,NULL,serverFunctionThread,NULL) < 0) {
printf("\nproblem in server worker thread creation \n");
}
pthread_join(clientThread_id,&cexitStatus);
pthread_join(serverThread_id,&sexitStatus);
return 0;
}
void parse_Input () {
FILE *input_file;
char cN[4], cD[4], cTmin[4], cTmax[4], cP[4], cE[4];
int c, i, j;
if ((input_file = fopen(inputfileName, "r")) == NULL) {
printf("\nError in opening input file\n");
exit(0);
}
while(1) {
j = 0;
while ((c = getc(input_file)) != '/') { //read the total number of nodes
cN [j++] = c;
}
cN [j] = '\0';
// printf("\ncN is %s\n", cN );
numProcess = atoi(cN);
printf("\nnumProcess is %d\n", numProcess );
while ((c = getc(input_file)) != '\n'); //goto end of line
j = 0;
while ((c = getc(input_file)) != '/') { //read value of d
cD [j++] = c;
}
cD [j] = '\0';
//printf("\ncD is %s\n", cD );
dValue = atoi(cD);
printf("\ndValue is %d\n", dValue );
while ((c = getc(input_file)) != '\n'); //goto end of line
//allocate space for storing peer addresses
peerAddrList = (char **)calloc(numProcess, sizeof(char *));
for (i = 0; i < numProcess; i++)
peerAddrList[i] = (char *)calloc(6, sizeof(char));
//fill the addresses
for (i = 0; i < numProcess; i++) {
j = 0;
while ((c = getc(input_file)) != '.') { //read the netid
peerAddrList[i][j++] = c;
}
peerAddrList[i][j] = '\0';
printf("\npeerAddrList[%d] is %s\n", i, peerAddrList[i]);
while ((c = getc(input_file)) != '\n'); //goto end of line
}
j = 0;
while ((c = getc(input_file)) != '/') { //read value of tmin
cTmin [j++] = c;
}
cTmin [j] = '\0';
//printf("\ncTmin is %s\n", cTmin );
tMin = atoi(cTmin);
printf("\ntMin is %d\n", tMin );
while ((c = getc(input_file)) != '\n'); //goto end of line
j = 0;
while ((c = getc(input_file)) != '/') { //read value of tmax
cTmax [j++] = c;
}
cTmax [j] = '\0';
//printf("\ncTmax is %s\n", cTmax );
tMax = atoi(cTmax);
printf("\ntMax is %d\n", tMax );
while ((c = getc(input_file)) != '\n'); //goto end of line
j = 0;
while ((c = getc(input_file)) != '/') { //read the probability value
cP [j++] = c;
}
cP [j] = '\0';
//printf("\ncP is %s\n", cP);
pValue = atof(cP);
printf("\npValue is %f\n", pValue);
while ((c = getc(input_file)) != '\n'); //goto end of line
j = 0;
while ((c = getc(input_file)) != '/') { //read value of E
cE [j++] = c;
}
cE [j] = '\0';
//printf("\ncE is %s\n", cE);
EValue = atoi(cE);
printf("\nEValue is %d\n", EValue );
break;
} //end while(1)
fclose(input_file);
}
int is_Connected (int seekvalue) {
pthread_mutex_lock(&safe_mutex);
if( connected_socks[seekvalue] > -1 )
{
pthread_mutex_unlock(&safe_mutex);
return 1;
}
else
{
pthread_mutex_unlock(&safe_mutex);
return 0;
}
}
void set_Connected (int seekvalue, int pfd) {
pthread_mutex_lock(&safe_mutex);
connected_socks[seekvalue] = pfd;
pthread_mutex_unlock(&safe_mutex);
}
void *serverFunctionThread (void *arg) {
//Server variables
struct sockaddr_in servAddress, peerAddress;
struct timeval servTimeout;
char opt= '1';
int listenfd, peer_fd, socks_read;
int maxsock, i;
fd_set mon_socks;
int listnum, peer_id;
int sin_size = sizeof(struct sockaddr_in);
char *mrecv_data;
int recv_num, rcvID;
/* creating a socket */
if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
fprintf(stderr, "\nError in creating listening socket");
perror("socket");
exit(1);
}
/*Prevent the address already in use error*/
if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)) == 1) {
fprintf(stderr, "\nError in setting socket options of reuse address.\n");
perror("setsockopt");
exit(1);
}
/* configuring server address structure */
servAddress.sin_family = AF_INET;
servAddress.sin_addr.s_addr = htonl(INADDR_ANY);
servAddress.sin_port = htons(SERVER_PORT);
memset(&(servAddress.sin_zero), '\0', 8);
/* binding the socket to the service port */
if (bind(listenfd, (struct sockaddr*) &servAddress, sizeof(servAddress)) < 0) {
fprintf(stderr, "\nError in binding the socket to the port\n");
perror("bind");
exit(1);
}
/* listen on the port*/
if (listen(listenfd, numProcess) < 0) {
fprintf(stderr, "\nError in listening on the port\n");
perror("listen");
exit(1);
}
maxsock = listenfd;
while(1) {
FD_ZERO(&mon_socks);
FD_SET(listenfd,&mon_socks);
pthread_mutex_lock(&connect_mutex);
for (listnum = 0; listnum < numProcess; listnum++) {
if (connected_socks[listnum] > -1) {
FD_SET(connected_socks[listnum],&mon_socks);
if (connected_socks[listnum] > maxsock)
maxsock = connected_socks[listnum];
}
}
pthread_mutex_unlock(&connect_mutex);
/*call select with 10 sec timeout interval*/
servTimeout.tv_sec = 10;
servTimeout.tv_usec = 0;
socks_read = select(maxsock+1, &mon_socks, NULL, NULL, &servTimeout);
// printf ("\nsocks_read = %d", socks_read);
if (socks_read < 0) {
fprintf(stderr, "\nError in selecting connections\n");
perror("select");
exit(1);
}
if (socks_read == 0) {
/* print "S" to show server is alive */
printf(".");
fflush(stdout);
}
else { //activity on some socket
if (FD_ISSET(listenfd,&mon_socks)) { /*new connection*/
peer_fd = accept(listenfd,(struct sockaddr *)&peerAddress,&sin_size);
printf("\nAccepted a connection on socket %d\n", peer_fd);
//get processID based on peer's IP address
if( (peer_id = getProcessID(peerAddress.sin_addr)) == -1 ) {
printf("\nPeer not recognized\n");
continue;
}
printf("Peer_ID is :%d\n", peer_id);
//safely store peer_fd to connected_socks
if(!is_Connected(peer_id)) {
set_Connected (peer_id, peer_fd);
if (send(peer_fd, "A", 10, 0) < 0) {
fprintf(stderr, "\nError in sending Accept Message\n");
perror("send");
}
}
else { //connection already established, close the socket
printf("\nClosing already connected socket with peer[%d] %s\n", peer_id, peerAddrList[peer_id] );
if (send(peer_fd, "D", 10, 0) < 0) {
fprintf(stderr, "\nError in sending Deny Message\n");
perror("send");
}
close(peer_fd);
}
}
else { //data recieved on some socket
pthread_mutex_lock(&connect_mutex);
for (listnum = 0; listnum < numProcess; listnum++) {
if (connected_socks[listnum] < 0) continue;
if (FD_ISSET(connected_socks[listnum],&mon_socks)) {
//printf("\nData Received on connected_sock[%d] = %d", listnum, connected_socks[listnum]);
//recv msg
mrecv_data = (char *)calloc((numProcess*6+10),sizeof(char));
recv_num = recv(connected_socks[listnum], mrecv_data, ((numProcess*6+10)*sizeof(char)), 0);
if (recv_num == 0) {
fprintf(stderr, "\nError in recieving timestamped message\n");
perror("recv");
continue;
}
else if (recv_num > 0) {
printf("\nReceived a Message!!!");
// printf("\nmessage contains:\n %s", mrecv_data);
//termination notification message
if (strcmp(mrecv_data, "T") == 0) {
printf("\nMessage is a Termination Notification Message from Process[%d] (%s)", listnum, peerAddrList[listnum]);
continue;
}
//update vector timestamp based on recieved timestamp
printf("\nMessage is a Timestamp Message!!!");
rcvID = updateVectorTimeStamp(mrecv_data);
printf("\nSender of the Message was Process[%d] (%s)", rcvID, peerAddrList[rcvID]);
//update logfile
updateLogfile ("Receive", &rcvID, 3);
printVectorClock ();
}
free(mrecv_data);
}
} //end listnum
pthread_mutex_unlock(&connect_mutex);
} //end data recv
} //end socket activity
} //end while
}
void *clientFunctionThread (void *arg) {
int connect_flag = 0, id = -1, sockfd;
struct sockaddr_in cliAddress;
struct timeval cliTimeout;
struct hostent *peer_info;
int i;
int maxin_socks, insocks_read;
fd_set in_socks;
char in_buf[8];
char perm[10];
int recv_perm;
while (!connect_flag) {
for (i = 0; i < numProcess; i++) {
if(i == selfID) continue;
if(is_Connected(i))
connect_flag = 1;
else {
connect_flag = 0;
id = i;
break;
}
}
if ((!connect_flag) && (id > -1) && (id != selfID)) {
cliAddress.sin_family = AF_INET;
cliAddress.sin_port = htons((unsigned)SERVER_PORT);
memset(&(cliAddress.sin_zero), '\0', 8);
if ((peer_info=gethostbyname(peerAddrList[id])) == NULL) {
fprintf(stderr, "\nCould not resolve the Hostname\n");
perror("gethostbyname");
continue;
}
cliAddress.sin_addr = *((struct in_addr *)peer_info->h_addr);
//printf("\nIP address of - %s - is %s\n", peerAddrList[id], inet_ntoa(cliAddress.sin_addr));
if (inet_pton(AF_INET, inet_ntoa(cliAddress.sin_addr), &cliAddress.sin_addr) <= 0) {
fprintf(stderr, "\nError in connecting using hostname\n");
perror("inet_pton");
continue;
}
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
fprintf(stderr, "\nClient:Error in creating socket\n");
perror("socket");
continue;
}
/* connecting to the server */
if (connect(sockfd, (struct sockaddr *)&cliAddress, sizeof(cliAddress)) < 0) {
fprintf(stderr, "\nError in connecting to the server\n");
perror("connect");
continue;
}
recv_perm = recv(sockfd, perm, 10, 0);
if (recv_perm == 0) {
fprintf(stderr, "\nError in recieving connection status message\n");
perror("recv");
continue;
}
else if (recv_perm > 0) {
if(strcmp(perm, "A") == 0) {
set_Connected (id, sockfd);
}
else if(strcmp(perm, "D") == 0) {
close(sockfd);
}
}
} //end if !connect
} //end while !connect
printf("\nConnections among all processes established successfully!!!\n");
printf("\nPress 'S' to start VectorClock Simulation!!!\n");
pthread_mutex_lock(&connect_mutex);
for (i = 0; i < numProcess; i++) {
printf("\nFinal ConnectedState[%d] is %d", i, connected_socks[i]);
}
pthread_mutex_unlock(&connect_mutex);
cliTimeout.tv_sec = 10;
cliTimeout.tv_usec = 0;
maxin_socks = fileno(stdin);
while (1) {
FD_ZERO(&in_socks);
FD_SET(fileno(stdin),&in_socks);
/*call select with the timeout interval*/
insocks_read = select(maxin_socks+1, &in_socks, NULL, NULL, &cliTimeout);
if (insocks_read < 0) {
fprintf(stderr, "\nError in reading user input\n");
perror("select");
continue;
}
if (insocks_read == 0) {
/* print "." to show client is waiting for user input */
printf(".");
fflush(stdout);
}
else if (FD_ISSET(fileno(stdin),&in_socks)) { //if some activity on socket
if (read(1, in_buf, 8) < 0)
printf("\nError in select/reading user input!!");
printf("\nKey Pressed!!!!" );
if (strstr(in_buf,"S") != NULL) { //S to start the vector clock compuation
printf("\nNow Starting Vector Clock Recording!!!\n");
vectorClockSimulation();
}
else if(strstr(in_buf,"T") != NULL) { //Termination notification
pthread_mutex_lock(&connect_mutex);
printf("\nNow Sending Finished signal to all Processes!!!\n");
for (i = 0; i < numProcess; i++) {
if (i == selfID) continue;
if (send(connected_socks[i], "T", 10, 0) < 0) {
fprintf(stderr, "\nError in sending Termination Notification Message\n");
perror("send");
}
}
pthread_mutex_unlock(&connect_mutex);
//reseting vectorClocks
printf("\nNow Resetting the Vector Clocks!!!\n");
pthread_mutex_lock(&vector_mutex);
for (i = 0; i < numProcess; i++)
vectorClock[i] = 0;
pthread_mutex_unlock(&vector_mutex);
//Reseting Logfiles
printf("\nNow Resetting the Logfiles!!!\n");
pthread_mutex_lock(&file_mutex);
//removing log file
if (remove(logfileName) != 0) {
printf("\nError in removing log file\n");
}
//create log file
if ((logfile = fopen(logfileName, "w")) == NULL) {
printf("\nError in re-creating log file\n");
}
if (fputs(title, logfile) < 0) {
printf("\nError in re-writing to log file\n");
}
fclose(logfile);
pthread_mutex_unlock(&file_mutex);
}
fflush(stdin);
}
}//end while
}
int getProcessID (struct in_addr peerAddr) {
struct hostent *peer_info;
int i;
if ((peer_info = gethostbyaddr((const char *)&peerAddr, sizeof(peerAddr), AF_INET)) == NULL) {
fprintf(stderr, "\nError in getting IP address for peer\n");
perror("gethostbyaddr");
}
printf("Peer name is: %s\n", peer_info->h_name);
for (i = 0; i < numProcess; i++) {
if ( strstr(peer_info->h_name, peerAddrList[i] ) != NULL)
return i;
else
continue;
}
return -1;
}
void updateLogfile (char buffer[], int *prcID, int type) { //type 1-local, 2-send, 3-Receive
FILE *log_file;
char *fileBuffer;
int i;
char tmpStmp[6];
char tmpID[5];
int count=0;;
//printf("\nEntering Update log file\n");
fileBuffer = (char *)malloc((numProcess*6+10+50)*sizeof(char));
switch (type) {
case 1: strcpy(fileBuffer, buffer);
count = strlen(fileBuffer);
for (i = 0; i < (19 - strlen(fileBuffer)); i++ ) {
strcat(fileBuffer, " ");
count++;
}
strcat(fileBuffer, "-");
count++;
for (i = 0; i < (((numProcess-1)*3+17) - count); i++ ) {
strcat(fileBuffer, " ");
}
for (i = 0; i < numProcess; i++ ) {
itoa(readVectorClock (i), tmpStmp);
strcat(fileBuffer, tmpStmp);
strcat(fileBuffer, ",");
}
strcat(fileBuffer, "\n");
break;
case 2: strcpy(fileBuffer, buffer);
count = strlen(fileBuffer);
for (i = 0; i < (19 - strlen(fileBuffer)); i++ ) {
strcat(fileBuffer, " ");
count++;
}
for (i = 1; i <= prcID[0]; i++ ) {
strcat(fileBuffer, "P");
itoa(prcID[i], tmpID);
strcat(fileBuffer, tmpID);
strcat(fileBuffer, ",");
count+=3;
}
for (i = 0; i < (((numProcess-1)*3+17) - count); i++ ) {
strcat(fileBuffer, " ");
}
for (i = 0; i < numProcess; i++ ) {
itoa(readVectorClock (i), tmpStmp);
strcat(fileBuffer, tmpStmp);
strcat(fileBuffer, ",");
}
strcat(fileBuffer, "\n");
break;
case 3: strcpy(fileBuffer, buffer);
count = strlen(fileBuffer);
for (i = 0; i < (19 - strlen(fileBuffer)); i++ ) {
strcat(fileBuffer, " ");
count++;
}
strcat(fileBuffer, "P");
count++;
itoa(*prcID, tmpID);
strcat(fileBuffer, tmpID);
count++;
for (i = 0; i < (((numProcess-1)*3+17) - count); i++ ) {
strcat(fileBuffer, " ");
}
for (i = 0; i < numProcess; i++ ) {
itoa(readVectorClock (i), tmpStmp);
strcat(fileBuffer, tmpStmp);
strcat(fileBuffer, ",");
}
strcat(fileBuffer, "\n");
break;
default: printf("\nInvalid Event Type\n");
}
pthread_mutex_lock(&file_mutex);
if ((log_file = fopen(logfileName, "a")) == NULL) {
printf("\nError in opening log file\n");
}
if (fputs(fileBuffer, log_file) < 0) {
printf("\nError in writing to log file\n");
}
fclose(log_file);
pthread_mutex_unlock(&file_mutex);
free(fileBuffer);
//printf("\nLeaving Update log file\n");
}
int readVectorClock (int index) {
int value;
pthread_mutex_lock(&vector_mutex);
value = vectorClock[index];
pthread_mutex_unlock(&vector_mutex);
return value;
}
void writeVectorClock (int index, int value) {
pthread_mutex_lock(&vector_mutex);
vectorClock[index] = value;
pthread_mutex_unlock(&vector_mutex);
}
void printVectorClock () {
int i;
pthread_mutex_lock(&vector_mutex);
printf("\nMy Current Vector Clock Value is:\n");
for (i = 0; i < numProcess; i++)
printf("P[%d] = %d, ", i, vectorClock[i]);
printf("\n");
pthread_mutex_unlock(&vector_mutex);
}
void vectorClockSimulation () {
int eventCount = 0;
int waitTime, i, count;
int localEvent;
int selfvectorValue;
int *sendList;
char *buffer;
while (eventCount < EValue) {
waitTime = randomTimeout();
sleep(waitTime);
localEvent = eventType();
if (localEvent) {
printf("\nGenerating Local Event\n");
//update self vector clock
selfvectorValue = readVectorClock (selfID);
selfvectorValue += dValue;
writeVectorClock (selfID, selfvectorValue);
eventCount++;
printf ("\nEvent count = %d", eventCount);
//update log file
updateLogfile ("Local", NULL, 1);
printVectorClock ();
}
else { //send event
printf("\nGenerating Send Event\n");
//update self vector clock
selfvectorValue = readVectorClock (selfID);
selfvectorValue += dValue;
writeVectorClock (selfID, selfvectorValue);
eventCount++;
sendList = randomPeerSelect ();
//build send packet
buffer = buildsendMsg();
//send packet
count = sendList[0];
pthread_mutex_lock(&connect_mutex);
for (i = 1; i <= count; i++) {
if (send(connected_socks[sendList[i]], (const void*) buffer, strlen(buffer), 0) < 0) {
fprintf(stderr, "\nError in sending Message\n");
perror("send");
}
else
printf("\nSent TimeStamped Message to Process[%d] (%s) on socket %d", sendList[i], peerAddrList[sendList[i]], connected_socks[sendList[i]]);
}
pthread_mutex_unlock(&connect_mutex);
printf ("\nEvent count = %d", eventCount);
//update log file
updateLogfile ("Send", sendList, 2);
printVectorClock ();
}
free (sendList);
free (buffer);
}
printf("\nGenerated %d Events. Stopping Vector Clock Simulation!!!", EValue);
printf("\nPress 'T' to send Termination notification to all Processes and Reset the Vector clocks.");
}
char *buildsendMsg() {
struct vcMessage sendMsg;
int i, val, tmp, maxLen = 0;
char *msgBuf;
sendMsg.msgTimestamp = (char **)calloc(numProcess, sizeof(char *));
for (i = 0; i < numProcess; i++)
sendMsg.msgTimestamp[i] = (char *)calloc(6, sizeof(char));
//copy timestamp into structure
for (i = 0; i < numProcess; i++) {
val = readVectorClock (i);
itoa (val, sendMsg.msgTimestamp[i]);
}
//find maxLength of timestamp string
for (i = 0; i < numProcess; i++) {
tmp = strlen(sendMsg.msgTimestamp[i]);
if(tmp > maxLen)
maxLen = tmp;
}
itoa (selfID, sendMsg.data);
//allocate space for the msg buffer
msgBuf = (char *)calloc((numProcess*maxLen+10),sizeof(char));
strcpy(msgBuf, sendMsg.msgTimestamp[0]);
strcat(msgBuf, ",");
for (i = 1; i < numProcess; i++) {
strcat(msgBuf, sendMsg.msgTimestamp[i]);
strcat(msgBuf, ",");
}
strcat(msgBuf, sendMsg.data);
strcat(msgBuf, "\0");
printf("\nSend Message contains: %s\n", msgBuf);
return msgBuf;
}
void itoa(int n, char str[]) {
int i, j, sign;
char *temp;
if ((sign = n) < 0)
n = -n;
i = 0;
do { // generate string digits in reverse order
str[i++] = n % 10 + '0';
}while((n /= 10) > 0);
if (sign < 0)
str[i++] = '-';
str[i] = '\0';
//reverse the string
temp = (char *)malloc (strlen(str) * sizeof(char));
for (j = strlen(str) - 1, i = 0;j >= 0; j--, i++)
temp[i] = str[j];
temp[i] = '\0';
strcpy(str,temp);
free(temp);
}
int randomTimeout () {
int ran_val = 0;
while ((ran_val <= tMin) || (ran_val >= tMax)) {
ran_val = rand() % 10;
}
printf("\nTimeout Value = %d", ran_val);
return ran_val;
}
int eventType () {
float myrand = 0;
while (myrand == 0)
myrand=(double)rand()/RAND_MAX;
printf("\n Random Event = %f", myrand);
if(myrand <= pValue) {
return 1; //local event
}
else
return 0; //send event
}
int *randomPeerSelect () {
int *ran_list; //1st element of this list the number of processes, remaining elements are the id's of those
int i, ranPeerVal = numProcess + 1;
int ranPeerID = numProcess + 1;
int j, dupFlag = 0;
int temp[numProcess];
//generating the number of peers
while (ranPeerVal >= numProcess) {
ranPeerVal = rand() % 10;
if (ranPeerVal == 0)
ranPeerVal = numProcess + 1;
}
printf ("\nranPeerVal = %d", ranPeerVal);
ran_list = (int *)malloc((ranPeerVal+1) * sizeof(int));
for (i = 0; i < ranPeerVal+1; i++)
ran_list[i] = 0;
ran_list[0] = ranPeerVal; //number of processes
if (ranPeerVal == numProcess - 1) {
for (i = 0; i < numProcess; i++)
temp[i] = i;
j = 0;
for (i = 1; i < ranPeerVal+1 ; i++) {
if (temp[j] == selfID) {
i--;
j++;
continue;
}
ran_list[i] = temp[j++];
printf ("\nran_list[%d] = %d", i, ran_list[i]);
}
}
else {
for (i = 1; i < ranPeerVal+1; i++) {
while ((ranPeerID >= numProcess) || (ranPeerID == selfID)) {
ranPeerID = rand() % 10;
if (i > 1) {
for (j = 1; j < i; j++) {
if (ranPeerID == ran_list[j])
dupFlag = 1;
}
if (dupFlag) {
ranPeerID = numProcess + 1; //reset
dupFlag = 0;
continue;
}
}
}
ran_list[i] = ranPeerID; //list of peer IDs
printf ("\nran_list[%d] = %d", i, ran_list[i]);
ranPeerID = numProcess + 1; //reset
dupFlag = 0;
}
}
return ran_list;
}
int updateVectorTimeStamp(char *recv_msg) {
int i, j, k;
char msgTm[6];
int recvTmVal, myTmVal, newTmVal;
char recvID[5];
int selfvectorValue;
//printf("\nReceived message contains:\n %s", recv_msg);
//update self vector clock
selfvectorValue = readVectorClock (selfID);
selfvectorValue += dValue;
writeVectorClock (selfID, selfvectorValue);
//update based on received time stamp
for (i = 0, j = 0; i < numProcess; i++) {
k=0;
while (recv_msg[j] != ',') {
msgTm[k++] = recv_msg[j++];
}
msgTm[k] = '\0';
j++;
recvTmVal = atoi(msgTm);
myTmVal = readVectorClock (i);
if(myTmVal > recvTmVal)
newTmVal = myTmVal;
else
newTmVal = recvTmVal;
writeVectorClock (i, newTmVal);
printf("\nMy TimeStamp for Process[%d] is %d. Recieved TimeStamp is %d. Updated TimeStamp is %d", i, myTmVal, recvTmVal, newTmVal);
}
k = 0;
while (recv_msg[j] != '\0')
recvID[k++] = recv_msg[j++] ;
recvID[k] = '\0';
free (recv_msg);
return atoi(recvID); //return the recieved process ID
}
| 25.619262 | 155 | 0.552612 | [
"vector"
] |
81491a56f898223fbc3e71dd0d1a987bd3b7e6a6 | 930 | h | C | rGWB/csmapto3d.h | mfernba/rGWB | 346de75519b1752c1ac9bea8ad7e5526096506ca | [
"MIT"
] | 10 | 2017-11-23T14:14:04.000Z | 2022-03-14T20:22:30.000Z | rGWB/csmapto3d.h | mfernba/rGWB | 346de75519b1752c1ac9bea8ad7e5526096506ca | [
"MIT"
] | null | null | null | rGWB/csmapto3d.h | mfernba/rGWB | 346de75519b1752c1ac9bea8ad7e5526096506ca | [
"MIT"
] | 1 | 2020-11-30T14:35:09.000Z | 2020-11-30T14:35:09.000Z | // Array de array 3D...
#include "csmfwddecl.hxx"
#include "csmapto3d.hxx"
#ifdef __cplusplus
extern "C" {
#endif
DLL_RGWB CONSTRUCTOR(csmArrPoint3D *, csmArrPoint3D_new, (unsigned long no_elems));
DLL_RGWB CONSTRUCTOR(csmArrPoint3D *, csmArrPoint3D_copy, (const csmArrPoint3D *array));
DLL_RGWB void csmArrPoint3D_free(csmArrPoint3D **array);
DLL_RGWB unsigned long csmArrPoint3D_count(const csmArrPoint3D *array);
DLL_RGWB void csmArrPoint3D_append(csmArrPoint3D *array, double x, double y, double z);
DLL_RGWB void csmArrPoint3D_delete(csmArrPoint3D *array, unsigned long idx);
DLL_RGWB void csmArrPoint3D_set(csmArrPoint3D *array, unsigned long idx, double x, double y, double z);
DLL_RGWB void csmArrPoint3D_get(const csmArrPoint3D *array, unsigned long idx, double *x, double *y, double *z);
DLL_RGWB void csmArrPoint3D_invert(csmArrPoint3D *array);
#ifdef __cplusplus
}
#endif
| 30 | 113 | 0.764516 | [
"3d"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.