hexsha stringlengths 40 40 | size int64 5 2.72M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 976 | max_stars_repo_name stringlengths 5 113 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:01:43 2022-03-31 23:59:48 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 00:06:24 2022-03-31 23:59:53 ⌀ | max_issues_repo_path stringlengths 3 976 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | 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 976 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:19 2022-03-31 23:59:49 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 12:00:57 2022-03-31 23:59:49 ⌀ | content stringlengths 5 2.72M | avg_line_length float64 1.38 573k | max_line_length int64 2 1.01M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4defde0ecd8cb9cc8bcafa4be4cc4c3c33d4a4df | 2,190 | c | C | srcs/get_cone.c | paribro/raytracer | 7bdac3ece8f70e9ec22542dbe5b16c4b4de8d2af | [
"MIT"
] | null | null | null | srcs/get_cone.c | paribro/raytracer | 7bdac3ece8f70e9ec22542dbe5b16c4b4de8d2af | [
"MIT"
] | null | null | null | srcs/get_cone.c | paribro/raytracer | 7bdac3ece8f70e9ec22542dbe5b16c4b4de8d2af | [
"MIT"
] | null | null | null | #include <stdlib.h>
#include <math.h>
#include <rt.h>
#include <libft.h>
void cone_intersection(t_env *e, t_obj *cone, double dir[3], double orig[3])
{
double var[4];
double eye[3];
double ray[3];
vect_dup(eye, orig);
vect_dup(ray, dir);
trasl_inv(eye, cone->c);
rot_dir(eye, cone->sincos_inv);
rot_dir(ray, cone->sincos_inv);
var[F] = pow(ray[X], 2) + pow(ray[Y], 2) - cone->a * pow(ray[Z], 2);
var[S] = 2 * (ray[X] * eye[X] + ray[Y] * eye[Y]
- cone->a * ray[Z] * eye[Z]);
var[T] = pow(eye[X], 2) + pow(eye[Y], 2) - cone->a * pow(eye[Z], 2);
var[DELTA] = pow(var[S], 2) - (4 * var[F] * var[T]);
solve_equation(cone, var);
if (cone->h > 1e-6)
{
get_inters_coord(e->eye, dir, cone->dist, cone->inters);
trasl_inv(cone->inters, cone->c);
rot_dir(cone->inters, cone->sincos_inv);
if (abs(cone->inters[Z]) > cone->h || cone->inters[Z] > 1e-6)
cone->dist = -1;
}
}
void cone_normal(t_obj *cone, double norm[3], double inters[3])
{
vect_dup(norm, inters);
trasl_inv(norm, cone->c);
rot_dir(norm, cone->sincos_inv);
norm[Z] = -(cone->a * norm[Z]);
rot_dir(norm, cone->sincos);
}
void get_cone(t_env *e, char **data)
{
if (ft_tablen(data) != 15)
fail(PARAM_CONE);
e->obj[e->n].c[X] = (double)atoi(data[1] + 2);
e->obj[e->n].c[Y] = (double)atoi(data[2] + 2);
e->obj[e->n].c[Z] = (double)atoi(data[3] + 2);
e->obj[e->n].rot[X] = (double)atoi(data[4] + 6) * (M_PI / 180);
e->obj[e->n].rot[Y] = (double)atoi(data[5] + 6) * (M_PI / 180);
e->obj[e->n].rot[Z] = (double)atoi(data[6] + 6) * (M_PI / 180);
calc_trigonometry(e->obj[e->n].sincos_inv, e->obj[e->n].rot, INV);
calc_trigonometry(e->obj[e->n].sincos, e->obj[e->n].rot, DIR);
e->obj[e->n].h = (double)atoi(data[7] + 7);
e->obj[e->n].a = tan((double)atoi(data[8] + 6) * M_PI / 180);
e->obj[e->n].col.comp[B] = atoi(data[9] + 6);
e->obj[e->n].col.comp[G] = atoi(data[10] + 6);
e->obj[e->n].col.comp[R] = atoi(data[11] + 6);
e->obj[e->n].bright = (double)atoi(data[12] + 7) * 0.1;
e->obj[e->n].reflex = (double)atoi(data[13] + 7) * 0.1;
e->obj[e->n].trans = (double)atoi(data[14] + 6) * 0.1;
e->obj[e->n].calc_norm = cone_normal;
e->obj[e->n].calc_inters = cone_intersection;
e->n++;
}
| 33.181818 | 76 | 0.579452 |
4df1d73f4a6fe009e42a50b4d19a753516f1dde1 | 8,798 | h | C | aplcore/include/apl/datagrammar/databindingerrors.h | tschaffter/apl-core-library | 3a05342ba0fa2432c320476795c13e8cd990e8ee | [
"Apache-2.0"
] | 28 | 2019-11-05T12:23:01.000Z | 2022-03-22T10:01:53.000Z | aplcore/include/apl/datagrammar/databindingerrors.h | alexa/apl-core-library | b0859273851c4f62290d1f85c42bf22eb087fb35 | [
"Apache-2.0"
] | 7 | 2020-03-28T12:44:08.000Z | 2022-01-23T17:02:27.000Z | aplcore/include/apl/datagrammar/databindingerrors.h | tschaffter/apl-core-library | 3a05342ba0fa2432c320476795c13e8cd990e8ee | [
"Apache-2.0"
] | 15 | 2019-12-25T10:15:52.000Z | 2021-12-30T03:50:00.000Z | /**
* Copyright 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.
*/
#ifndef _APL_DATA_BINDING_ERRORS_H
#define _APL_DATA_BINDING_ERRORS_H
#include <string>
#include "grammarerror.h"
#include "databindingrules.h"
namespace apl {
namespace datagrammar {
/**
* Standard PEGTL parsing error controller. This raises a parse_error exception
* if a problem occurs. The static "error_value" defined in this template converts
* from a templated action to a numbered error message. The "errorToString" method
* further converts the error message into a human-readable string.
* @tparam Rule
*/
template< typename Rule >
struct error_control : tao::pegtl::normal< Rule > {
static const GrammarError error_value;
template<typename Input, typename... States>
static void raise(const Input &in, States &&...) {
throw tao::pegtl::parse_error(errorToString(error_value), in);
}
};
/**
* Convenience routine for printing out the current character being processed
* by the PEGTL grammar.
* @tparam Input
* @param in
* @return A string showing the character (if printable) and the numeric value of the character.
*/
template< typename Input > std::string
get_current(const Input& in)
{
streamer out;
if( in.empty() ) {
out << "<eof>";
}
else {
const auto c = in.peek_uint8();
switch( c ) {
case 0:
out << "<nul> = ";
break;
case 9:
out << "<ht> = ";
break;
case 10:
out << "<lf> = ";
break;
case 13:
out << "<cr> = ";
break;
default:
if( isprint( c ) ) {
out << "'" << (char) c << "' = ";
}
}
out << "(char)" << unsigned( c );
}
return out.str();
}
// These are only enabled if DEBUG_DATA_BINDING is true
const bool TRACED_ERROR_CONTROL_SHOW_START = false; // Log starting blocks
const bool TRACED_ERROR_CONTROL_SHOW_SUCCESS = false; // Log successful blocks
const bool TRACED_ERROR_CONTROL_SHOW_FAILURE = false; // Log failed blocks
/**
* Fancing PEGTL parsing error controller. This is enabled with DEBUG_DATA_BINDING.
* The messages are output as the PEGTL grammar is parsed.
* @tparam Rule
*/
template< typename Rule >
struct traced_error_control : error_control<Rule>
{
template<typename Input, typename... States>
static void start(const Input& in, States&& ... /*unused*/ ) {
LOG_IF(TRACED_ERROR_CONTROL_SHOW_START) << pegtl::to_string(in.position())
<< " start " << pegtl::internal::demangle<Rule>()
<< "; current " << get_current(in);
}
template<typename Input, typename... States>
static void success(const Input& in, States&& ... /*unused*/ ) {
LOG_IF(TRACED_ERROR_CONTROL_SHOW_SUCCESS) << pegtl::to_string(in.position())
<< " success " << pegtl::internal::demangle<Rule>()
<< "; next " << get_current(in);
}
template<typename Input, typename... States>
static void failure(const Input& in, States&& ... /*unused*/ ) {
LOG_IF(TRACED_ERROR_CONTROL_SHOW_FAILURE) << pegtl::to_string(in.position())
<< " failure " << pegtl::internal::demangle<Rule>();
}
template<template<typename...> class Action, typename Iterator, typename Input, typename... States>
static auto apply(const Iterator& begin, const Input& in, States&& ... st)
-> decltype(pegtl::normal<Rule>::template apply<Action>(begin, in, st...)) {
LOG(LogLevel::kDebug) << pegtl::to_string(in.position())
<< " apply " << pegtl::internal::demangle<Rule>()
<< " '" << std::string(in.begin() + begin.byte, in.current())
<< "' position=" << begin.byte;
return pegtl::normal<Rule>::template apply<Action>(begin, in, st...);
}
template<template<typename...> class Action, typename Input, typename... States>
static auto apply0(const Input& in, States&& ... st)
-> decltype(pegtl::normal<Rule>::template apply0<Action>(in, st...)) {
LOG(LogLevel::kDebug) << pegtl::to_string(in.position())
<< " apply " << pegtl::internal::demangle<Rule>()
<< " '" << std::string(in.begin() + in.byte, in.current())
<< "' position=" << in.byte;
return pegtl::normal<Rule>::template apply0<Action>(in, st...);
}
};
template<> const GrammarError error_control<not_at<digit>>::error_value = INVALID_NUMBER_FORMAT;
template<> const GrammarError error_control<sym_dbend>::error_value = UNEXPECTED_TOKEN;
template<> const GrammarError error_control<eof>::error_value = UNEXPECTED_TOKEN_BEFORE_EOF;
template<> const GrammarError error_control<unary_expression>::error_value = EXPECTED_OPERAND_AFTER_MULTIPLICATIVE;
template<> const GrammarError error_control<multiplicative_expression>::error_value = EXPECTED_OPERAND_AFTER_ADDITIVE;
template<> const GrammarError error_control<additive_expression>::error_value = EXPECTED_OPERAND_AFTER_COMPARISON;
template<> const GrammarError error_control<comparison_expression>::error_value = EXPECTED_OPERAND_AFTER_EQUALITY;
template<> const GrammarError error_control<equality_expression>::error_value = EXPECTED_OPERAND_AFTER_LOGICAL_AND;
template<> const GrammarError error_control<logical_and_expression>::error_value = EXPECTED_OPERAND_AFTER_LOGICAL_OR;
template<> const GrammarError error_control<logical_or_expression>::error_value = EXPECTED_OPERAND_AFTER_NULLC;
template<> const GrammarError error_control<expression>::error_value = EXPECTED_EXPRESSION;
template<> const GrammarError error_control<array_end>::error_value = MALFORMED_ARRAY;
template<> const GrammarError error_control<ss_char>::error_value = UNTERMINATED_SS_STRING;
template<> const GrammarError error_control<ds_char>::error_value = UNTERMINATED_DS_STRING;
template<> const GrammarError error_control<map_assign>::error_value = EXPECTED_MAP_VALUE_ASSIGNMENT;
template<> const GrammarError error_control<map_element>::error_value = EXPECTED_MAP_ASSIGNMENT;
template<> const GrammarError error_control<map_end>::error_value = MALFORMED_MAP;
template<> const GrammarError error_control<ternary_tail>::error_value = MALFORMED_TERNARY_EXPRESSION;
template<> const GrammarError error_control<postfix_right_paren>::error_value = EXPECTED_POSTFIX_RIGHT_PAREN;
// Untested items
template<> const GrammarError error_control<char_>::error_value = static_cast<GrammarError>(105);
template<> const GrammarError error_control<ws>::error_value = static_cast<GrammarError>(106);
template<> const GrammarError error_control<postfix_expression>::error_value = static_cast<GrammarError>(107);
template<> const GrammarError error_control<ternary_expression>::error_value = static_cast<GrammarError>(111);
template<> const GrammarError error_control<db_body>::error_value = static_cast<GrammarError>(117);
template<> const GrammarError error_control<map_body>::error_value = static_cast<GrammarError>(118);
template<> const GrammarError error_control<array_body>::error_value = static_cast<GrammarError>(119);
template<> const GrammarError error_control<ds_end>::error_value = static_cast<GrammarError>(120);
template<> const GrammarError error_control<ss_end>::error_value = static_cast<GrammarError>(121);
template<> const GrammarError error_control<ss_body>::error_value = static_cast<GrammarError>(122);
template<> const GrammarError error_control<ds_body>::error_value = static_cast<GrammarError>(123);
template<> const GrammarError error_control<group_end>::error_value = static_cast<GrammarError>(127);
template<> const GrammarError error_control<os_string>::error_value = static_cast<GrammarError>(131);
template<> const GrammarError error_control<pad_opt<argument_list, sep>>::error_value = static_cast<GrammarError>(141);
template<> const GrammarError error_control<one<(char)93>>::error_value = static_cast<GrammarError>(204);
} // namespace datagrammar
} // namespace apl
#endif // _APL_DATA_BINDING_ERRORS_H
| 47.556757 | 119 | 0.692771 |
4df208051776c8046a9c9f4dfacea68bd0072c1f | 7,284 | c | C | assignment2/src/knnring_mpi.c | kv13/Parallel-And-Distributed-Systems | d3f91cf8ffc41a7beae0d3dc3017960efc5b8b3c | [
"MIT"
] | null | null | null | assignment2/src/knnring_mpi.c | kv13/Parallel-And-Distributed-Systems | d3f91cf8ffc41a7beae0d3dc3017960efc5b8b3c | [
"MIT"
] | null | null | null | assignment2/src/knnring_mpi.c | kv13/Parallel-And-Distributed-Systems | d3f91cf8ffc41a7beae0d3dc3017960efc5b8b3c | [
"MIT"
] | null | null | null | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <cblas.h>
#include <string.h>
#include <mpi.h>
#include "../inc/knnring.h"
knnresult kNN(double *X, double *Y, int n, int m, int d, int k){
knnresult k_nearest;
//initalize the result's variable
k_nearest.nidx = (int *)malloc(m*k*sizeof(int));
k_nearest.ndist = (double *)malloc(m*k*sizeof(double));
k_nearest.m = m;
k_nearest.k = k;
//compute the distance Matrix D
double *D = compute_D(X,Y,n,m,d,k);
//select k-nearest neighbors for every point in QUERY
k_select(D,k_nearest.ndist, k_nearest.nidx,n,m,k);
return k_nearest;
}
double *compute_D(double *X, double *Y, int n, int m, int d, int k){
//compute distances using
//D = (X*X)ee_t - 2XY_t + ee_t(Y*Y)_t
double *tempD = (double *)malloc(n*m*sizeof(double));
double *e_1 = (double *)malloc(d*m*sizeof(double));
double *XX = (double *)malloc(n*d*sizeof(double));
for(int i=0;i<d*m;i++)
e_1[i]=1;
for(int i=0;i<n*d;i++)
XX[i] = X[i]*X[i];
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n,m,d,1,XX,d,e_1,m,0,tempD,m);
free(e_1);
free(XX);
double *e_2 = (double *)malloc(n*d*sizeof(double));
double *YY = (double *)malloc(m*d*sizeof(double));
for(int i=0;i<n*d;i++)
e_2[i]=1;
for(int i=0;i<m*d;i++)
YY[i] = Y[i]*Y[i];
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans, n,m,d,-2,X,d,Y,d,1,tempD,m);
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans, n,m,d,1,e_2,d,YY,d,1,tempD,m);
for(int i=0;i<n*m;i++)
tempD[i] = sqrt(fabs(tempD[i]));
free(e_2);
free(YY);
return tempD;
}
void k_select(double *D, double *ndist, int *nidx,int n, int m, int k){
for(int j=0;j<m;j++){
for(int i=0;i<k;i++){
ndist[j*k+i] = D[j+i*m];
nidx[j*k+i] = i;
}
//sort the initial k neighbors
quick_sort(ndist,nidx,j*k,k*(j+1)-1);
}
//search the rest points to find it there are closer neighbors
for(int j=0;j<m;j++){
for(int i=k;i<n;i++){
if(D[j+i*m] < ndist[k*(j+1)-1]){
ndist[k*(j+1)-1] = D[j+i*m];
nidx[k*(j+1)-1] = i;
quick_sort(ndist,nidx,j*k,(j+1)*k-1);
}
}
}
}
void quick_sort(double *k_dist, int *k_neigh, int low, int high){
if(low<high){
//actuall sorting an element
int pi = partition(k_dist,k_neigh,low,high);
//recursivelly call quick_sort
quick_sort(k_dist,k_neigh,low,pi-1);
quick_sort(k_dist,k_neigh,pi+1,high);
}
}
int partition(double *k_dist, int *k_neigh,int low, int high){
double temp_dist;
int temp_point;
int checker = 0;
double pivot = k_dist[high];
//printf("the pivot is %lf \n",pivot);
int i = (low-1);
for(int j=low;j<=high-1;j++){
if(k_dist[j]<=pivot){
/*swap the two elements*/
i=i+1;
temp_dist = k_dist[i];
temp_point = k_neigh[i];
k_dist[i] = k_dist[j];
k_neigh[i] = k_neigh[j];
k_dist[j] = temp_dist;
k_neigh[j] = temp_point;
checker = 1;
}
}
/* swap the pivot */
i=i+1;
temp_dist = k_dist[i];
temp_point = k_neigh[i];
k_dist[i] = k_dist[high];
k_neigh[i] = k_neigh[high];
k_dist[high] = temp_dist;
k_neigh[high] = temp_point;
return i;
}
void create_points(double *X,int size){
double *temp;
temp = X;
srand(time(NULL));
for(int i=0;i<size;i++)
temp[i] = (double) 1000*rand()/RAND_MAX;
}
void write_to_file(char *str1, int *nidx, double *ndist, int amount, int k){
FILE *fp;
//file for indexes
fp = fopen(str1,"a+");
int counter = 1;
for(int i=0;i<amount;i++){
fprintf(fp,"%d)%d -- %lf\n",counter,nidx[i],ndist[i]);
counter ++;
if((i+1)%k == 0){
fprintf(fp,"k nearest neighbors for next point \n");
counter = 1;
}
}
fclose(fp);
}
//######################### V1 FUNCTIONS ############################
knnresult distrAllkNN(double *X, int n, int d, int k){
//results variables
knnresult knn_process;
knnresult knn_temp;
int p_rank; //PROCESS RANK
int p_size; //TOTAL NUMBER OF PROCESSES
int next,prev; //NEXT AND PREVIOUS PROCESSES
double *receive_buff; //BUFFERS FOR COMMUNICATION
double *Y; //QUERY POINTS
//variables for MPI COMMUNICATION.
MPI_Status status;
MPI_Request send_request,receive_request;
int tag;
//time variables
struct timespec ts_start;
struct timespec ts_end;
double time;
//find the number of processes
MPI_Comm_size(MPI_COMM_WORLD, &p_size);
//find the id of the process
MPI_Comm_rank(MPI_COMM_WORLD, &p_rank);
//define the communication tag
tag = 1;
//define the next and the previous process.
//and create the circular communication
next = p_rank+1;
if(next == p_size) next = 0;
prev = p_rank-1;
if(prev== -1) prev = p_size-1;
//initialize Y block
Y = (double *)malloc(n*d*sizeof(double));
//in the first iteration every process computes distances between its own points
memcpy(Y,X,n*d*sizeof(double));
//initialize receive buffer
receive_buff = (double *)malloc(n*d*sizeof(double));
//MASK COMMUNICATION TIME
//Send and receive point for the next iteration
//clock_gettime(CLOCK_MONOTONIC,&ts_start);
MPI_Isend(Y,n*d,MPI_DOUBLE,next,tag,MPI_COMM_WORLD, &send_request);
MPI_Irecv(receive_buff,n*d, MPI_DOUBLE, prev, tag, MPI_COMM_WORLD, &receive_request);
//find k-nearest neighbors in this set of points.
knn_process = kNN(X,Y,n,n,d,k);
for(int i=0;i<n*k;i++) knn_process.nidx[i] = knn_process.nidx[i]+n*p_rank;
MPI_Wait(&send_request,&status);
//make sure receive_buffer is ready
MPI_Wait(&receive_request,&status);
//clock_gettime(CLOCK_MONOTONIC,&ts_end);
//time = 1000000*(double)(ts_end.tv_sec-ts_start.tv_sec)+(double)(ts_end.tv_nsec-ts_start.tv_nsec)/1000;
//printf("communication time and computation time%lf\n",time);
for(int i=0;i<p_size-1;i++){
memcpy(Y,receive_buff,n*d*sizeof(double));
//MASK COMMUNICATION TIME
//send the block to the next node
clock_gettime(CLOCK_MONOTONIC,&ts_start);
MPI_Isend(Y,n*d,MPI_DOUBLE,next,tag,MPI_COMM_WORLD, &send_request);
MPI_Irecv(receive_buff,n*d,MPI_DOUBLE,prev,tag,MPI_COMM_WORLD,&receive_request);
knn_temp = kNN(Y,X,n,n,d,k);
//compare k-nearest points
knn_combine(knn_process, knn_temp,n,k,(p_rank-i-1+p_size)%p_size);
//make sure Y buffer has been send in order to change it
MPI_Wait(&send_request,&status);
//make sure receive_buffer is ready
MPI_Wait(&receive_request,&status);
//clock_gettime(CLOCK_MONOTONIC,&ts_end);
//time = 1000000*(double)(ts_end.tv_sec-ts_start.tv_sec)+(double)(ts_end.tv_nsec-ts_start.tv_nsec)/1000;
//printf("communication time and knn compute time%lf\n",time);
}
free(Y);
free(knn_temp.nidx);
free(knn_temp.ndist);
for(int i=0;i<knn_process.m;i++) quick_sort(knn_process.ndist,knn_process.nidx,i*k,k*(i+1)-1);
return knn_process;
}
void knn_combine(knnresult knn_total,knnresult knn_temp, int n, int k, int no_block){
for(int m=0;m<knn_total.m;m++){
for(int j=0;j<k;j++){
if(knn_temp.ndist[m*k+j]>knn_total.ndist[k*(m+1)-1])
break;
else{
knn_total.ndist[k*(m+1)-1] = knn_temp.ndist[m*k+j];
knn_total.nidx[k*(m+1)-1] = knn_temp.nidx[m*k+j] + no_block*n;
//sort the new element
quick_sort(knn_total.ndist,knn_total.nidx,m*k,(m+1)*k-1);
}
}
}
}
| 24.442953 | 107 | 0.647446 |
4df264f4b50ab310119422f9f4c28bcf4e12ad22 | 210 | h | C | fbx2bvh/src/fbx-sdk.h | zyndor/fbx2bvh | 945aac34df8bff61c0839fcdff206b8205272660 | [
"CC0-1.0"
] | null | null | null | fbx2bvh/src/fbx-sdk.h | zyndor/fbx2bvh | 945aac34df8bff61c0839fcdff206b8205272660 | [
"CC0-1.0"
] | 1 | 2021-03-19T09:56:03.000Z | 2021-03-19T09:56:03.000Z | fbx2bvh/src/fbx-sdk.h | zyndor/fbx2bvh | 945aac34df8bff61c0839fcdff206b8205272660 | [
"CC0-1.0"
] | 1 | 2021-06-29T08:20:32.000Z | 2021-06-29T08:20:32.000Z | #pragma once
namespace fbxsdk
{
class FbxManager;
class FbxScene;
}
struct FbxSdk
{
fbxsdk::FbxManager* mManager;
fbxsdk::FbxScene* mScene;
FbxSdk();
~FbxSdk();
bool LoadScene(char const* filename);
}; | 11.666667 | 38 | 0.719048 |
4df505c6bd96b47fece544ea5b9777f447308b56 | 3,668 | c | C | boot/legacy/stage3/multiboot.c | CyberFlameGO/tilck | 4c32541874102e524374ab79d46b68af9d759390 | [
"BSD-2-Clause"
] | 1,059 | 2018-07-30T14:48:42.000Z | 2022-03-30T19:54:49.000Z | boot/legacy/stage3/multiboot.c | CyberFlameGO/tilck | 4c32541874102e524374ab79d46b68af9d759390 | [
"BSD-2-Clause"
] | 15 | 2019-06-17T13:58:08.000Z | 2021-10-16T18:19:25.000Z | boot/legacy/stage3/multiboot.c | CyberFlameGO/tilck | 4c32541874102e524374ab79d46b68af9d759390 | [
"BSD-2-Clause"
] | 47 | 2020-03-09T16:54:07.000Z | 2022-03-12T08:53:56.000Z | /* SPDX-License-Identifier: BSD-2-Clause */
#include <tilck/common/basic_defs.h>
#include <tilck/common/string_util.h>
#include <tilck/common/printk.h>
#include "common.h"
#include "mm.h"
#include "vbe.h"
static multiboot_info_t *mbi;
static multiboot_module_t *mod;
static multiboot_memory_map_t *mmmap;
static char *cmdline_buf;
char *
legacy_boot_get_cmdline_buf(u32 *buf_sz)
{
ASSERT(cmdline_buf != NULL);
*buf_sz = CMDLINE_BUF_SZ;
return cmdline_buf;
}
void
alloc_mbi(void)
{
ulong free_mem;
free_mem = get_usable_mem(&g_meminfo, 16 * KB, 48 * KB);
if (!free_mem)
panic("Unable to allocate memory for the multiboot info");
mbi = (multiboot_info_t *) free_mem;
bzero(mbi, sizeof(*mbi));
mod = (multiboot_module_t *)((char *)mbi + sizeof(*mbi));
bzero(mod, sizeof(*mod));
cmdline_buf = (char *)mod + (1 /* count */ * sizeof(multiboot_module_t));
bzero(cmdline_buf, CMDLINE_BUF_SZ);
mmmap = (void *)(cmdline_buf + CMDLINE_BUF_SZ);
bzero(mmmap, g_meminfo.count * sizeof(multiboot_memory_map_t));
}
multiboot_info_t *
setup_multiboot_info(ulong ramdisk_paddr, ulong ramdisk_size)
{
ASSERT(mbi != NULL);
ASSERT(mod != NULL);
mbi->flags |= MULTIBOOT_INFO_MEMORY;
mbi->mem_lower = 0;
mbi->mem_upper = 0;
if (cmdline_buf[0]) {
mbi->flags |= MULTIBOOT_INFO_CMDLINE;
mbi->cmdline = (u32) cmdline_buf;
}
mbi->flags |= MULTIBOOT_INFO_FRAMEBUFFER_INFO;
if (selected_mode == VGA_COLOR_TEXT_MODE_80x25) {
mbi->framebuffer_addr = 0xB8000;
mbi->framebuffer_pitch = 80 * 2;
mbi->framebuffer_width = 80;
mbi->framebuffer_height = 25;
mbi->framebuffer_bpp = 4;
mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT;
} else {
struct ModeInfoBlock *mi = usable_vbe_mode_info_block;
if (!vbe_get_mode_info(selected_mode, mi))
panic("vbe_get_mode_info(0x%x) failed", selected_mode);
mbi->framebuffer_addr = mi->PhysBasePtr;
mbi->framebuffer_pitch = mi->BytesPerScanLine;
mbi->framebuffer_width = mi->XResolution;
mbi->framebuffer_height = mi->YResolution;
mbi->framebuffer_bpp = mi->BitsPerPixel;
mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_RGB;
mbi->framebuffer_red_field_position = mi->RedFieldPosition;
mbi->framebuffer_red_mask_size = mi->RedMaskSize;
mbi->framebuffer_green_field_position = mi->GreenFieldPosition;
mbi->framebuffer_green_mask_size = mi->GreenMaskSize;
mbi->framebuffer_blue_field_position = mi->BlueFieldPosition;
mbi->framebuffer_blue_mask_size = mi->BlueMaskSize;
if (vbe_info_block->VbeVersion >= 0x300)
mbi->framebuffer_pitch = mi->LinBytesPerScanLine;
}
mbi->flags |= MULTIBOOT_INFO_MODS;
mbi->mods_addr = (u32)mod;
mbi->mods_count = 1;
mod->mod_start = ramdisk_paddr;
mod->mod_end = mod->mod_start + ramdisk_size;
mbi->flags |= MULTIBOOT_INFO_MEM_MAP;
mbi->mmap_addr = (u32)mmmap;
mbi->mmap_length = g_meminfo.count * sizeof(multiboot_memory_map_t);
for (u32 i = 0; i < g_meminfo.count; i++) {
struct mem_area *ma = g_meminfo.mem_areas + i;
if (ma->type == MEM_USABLE) {
if (ma->base < mbi->mem_lower * KB)
mbi->mem_lower = (u32)(ma->base / KB);
if (ma->base + ma->len > mbi->mem_upper * KB)
mbi->mem_upper = (u32)((ma->base + ma->len) / KB);
}
mmmap[i] = (multiboot_memory_map_t) {
.size = sizeof(multiboot_memory_map_t) - sizeof(u32),
.addr = ma->base,
.len = ma->len,
.type = bios_to_multiboot_mem_region(ma->type),
};
}
return mbi;
}
| 28.215385 | 76 | 0.667666 |
4df5a891cd19c4fd0d484ba431d79ee2c45c6240 | 1,892 | h | C | MFCApplication2/MFCApplication2View.h | yg88/class2017 | c5b40a48f91a5676a4f07c3404e09d50a49f2bd2 | [
"MIT"
] | null | null | null | MFCApplication2/MFCApplication2View.h | yg88/class2017 | c5b40a48f91a5676a4f07c3404e09d50a49f2bd2 | [
"MIT"
] | 1 | 2019-01-05T11:53:18.000Z | 2019-01-05T11:53:18.000Z | MFCApplication2/MFCApplication2View.h | yg88/class2017 | c5b40a48f91a5676a4f07c3404e09d50a49f2bd2 | [
"MIT"
] | 1 | 2017-11-23T08:05:38.000Z | 2017-11-23T08:05:38.000Z | // This MFC Samples source code demonstrates using MFC Microsoft Office Fluent User Interface
// (the "Fluent UI") and is provided only as referential material to supplement the
// Microsoft Foundation Classes Reference and related electronic documentation
// included with the MFC C++ library software.
// License terms to copy, use or distribute the Fluent UI are available separately.
// To learn more about our Fluent UI licensing program, please visit
// http://go.microsoft.com/fwlink/?LinkId=238214.
//
// Copyright (C) Microsoft Corporation
// All rights reserved.
// MFCApplication2View.h : interface of the CMFCApplication2View class
//
#pragma once
class CMFCApplication2View : public CView
{
protected: // create from serialization only
CMFCApplication2View();
DECLARE_DYNCREATE(CMFCApplication2View)
// Attributes
public:
CMFCApplication2Doc* GetDocument() const;
// Operations
public:
// Overrides
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
// Implementation
public:
virtual ~CMFCApplication2View();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
afx_msg void OnFilePrintPreview();
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in MFCApplication2View.cpp
inline CMFCApplication2Doc* CMFCApplication2View::GetDocument() const
{ return reinterpret_cast<CMFCApplication2Doc*>(m_pDocument); }
#endif
| 30.031746 | 95 | 0.754757 |
4dfa62def0329aff80633833172ac5d5dac1becd | 3,993 | c | C | Versionen/2021_06_15/RMF/rmf_ws/install/rmf_fleet_msgs/include/rmf_fleet_msgs/msg/detail/fleet_state__functions.c | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | null | null | null | Versionen/2021_06_15/RMF/rmf_ws/install/rmf_fleet_msgs/include/rmf_fleet_msgs/msg/detail/fleet_state__functions.c | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | null | null | null | Versionen/2021_06_15/RMF/rmf_ws/install/rmf_fleet_msgs/include/rmf_fleet_msgs/msg/detail/fleet_state__functions.c | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | 2 | 2021-06-21T07:32:09.000Z | 2021-08-17T03:05:38.000Z | // generated from rosidl_generator_c/resource/idl__functions.c.em
// with input from rmf_fleet_msgs:msg/FleetState.idl
// generated code does not contain a copyright notice
#include "rmf_fleet_msgs/msg/detail/fleet_state__functions.h"
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
// Include directives for member types
// Member `name`
#include "rosidl_runtime_c/string_functions.h"
// Member `robots`
#include "rmf_fleet_msgs/msg/detail/robot_state__functions.h"
bool
rmf_fleet_msgs__msg__FleetState__init(rmf_fleet_msgs__msg__FleetState * msg)
{
if (!msg) {
return false;
}
// name
if (!rosidl_runtime_c__String__init(&msg->name)) {
rmf_fleet_msgs__msg__FleetState__fini(msg);
return false;
}
// robots
if (!rmf_fleet_msgs__msg__RobotState__Sequence__init(&msg->robots, 0)) {
rmf_fleet_msgs__msg__FleetState__fini(msg);
return false;
}
return true;
}
void
rmf_fleet_msgs__msg__FleetState__fini(rmf_fleet_msgs__msg__FleetState * msg)
{
if (!msg) {
return;
}
// name
rosidl_runtime_c__String__fini(&msg->name);
// robots
rmf_fleet_msgs__msg__RobotState__Sequence__fini(&msg->robots);
}
rmf_fleet_msgs__msg__FleetState *
rmf_fleet_msgs__msg__FleetState__create()
{
rmf_fleet_msgs__msg__FleetState * msg = (rmf_fleet_msgs__msg__FleetState *)malloc(sizeof(rmf_fleet_msgs__msg__FleetState));
if (!msg) {
return NULL;
}
memset(msg, 0, sizeof(rmf_fleet_msgs__msg__FleetState));
bool success = rmf_fleet_msgs__msg__FleetState__init(msg);
if (!success) {
free(msg);
return NULL;
}
return msg;
}
void
rmf_fleet_msgs__msg__FleetState__destroy(rmf_fleet_msgs__msg__FleetState * msg)
{
if (msg) {
rmf_fleet_msgs__msg__FleetState__fini(msg);
}
free(msg);
}
bool
rmf_fleet_msgs__msg__FleetState__Sequence__init(rmf_fleet_msgs__msg__FleetState__Sequence * array, size_t size)
{
if (!array) {
return false;
}
rmf_fleet_msgs__msg__FleetState * data = NULL;
if (size) {
data = (rmf_fleet_msgs__msg__FleetState *)calloc(size, sizeof(rmf_fleet_msgs__msg__FleetState));
if (!data) {
return false;
}
// initialize all array elements
size_t i;
for (i = 0; i < size; ++i) {
bool success = rmf_fleet_msgs__msg__FleetState__init(&data[i]);
if (!success) {
break;
}
}
if (i < size) {
// if initialization failed finalize the already initialized array elements
for (; i > 0; --i) {
rmf_fleet_msgs__msg__FleetState__fini(&data[i - 1]);
}
free(data);
return false;
}
}
array->data = data;
array->size = size;
array->capacity = size;
return true;
}
void
rmf_fleet_msgs__msg__FleetState__Sequence__fini(rmf_fleet_msgs__msg__FleetState__Sequence * array)
{
if (!array) {
return;
}
if (array->data) {
// ensure that data and capacity values are consistent
assert(array->capacity > 0);
// finalize all array elements
for (size_t i = 0; i < array->capacity; ++i) {
rmf_fleet_msgs__msg__FleetState__fini(&array->data[i]);
}
free(array->data);
array->data = NULL;
array->size = 0;
array->capacity = 0;
} else {
// ensure that data, size, and capacity values are consistent
assert(0 == array->size);
assert(0 == array->capacity);
}
}
rmf_fleet_msgs__msg__FleetState__Sequence *
rmf_fleet_msgs__msg__FleetState__Sequence__create(size_t size)
{
rmf_fleet_msgs__msg__FleetState__Sequence * array = (rmf_fleet_msgs__msg__FleetState__Sequence *)malloc(sizeof(rmf_fleet_msgs__msg__FleetState__Sequence));
if (!array) {
return NULL;
}
bool success = rmf_fleet_msgs__msg__FleetState__Sequence__init(array, size);
if (!success) {
free(array);
return NULL;
}
return array;
}
void
rmf_fleet_msgs__msg__FleetState__Sequence__destroy(rmf_fleet_msgs__msg__FleetState__Sequence * array)
{
if (array) {
rmf_fleet_msgs__msg__FleetState__Sequence__fini(array);
}
free(array);
}
| 25.433121 | 157 | 0.720511 |
4dfcbf1b23e56a856d67f3679742b2249e20b224 | 627 | h | C | src/lokobook/lokomupdf.h | gale320/loko | bc47184bd89bf18456e5ed0270800b8c2f7e60f7 | [
"Apache-2.0"
] | null | null | null | src/lokobook/lokomupdf.h | gale320/loko | bc47184bd89bf18456e5ed0270800b8c2f7e60f7 | [
"Apache-2.0"
] | null | null | null | src/lokobook/lokomupdf.h | gale320/loko | bc47184bd89bf18456e5ed0270800b8c2f7e60f7 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <mupdf/fitz.h>
#include "mupdf/pdf.h"
#include "lokoinc.h"
#include "lokobuf.h"
#include <stdlib.h>
namespace loko{
class LokoMupdf{
public:
LokoMupdf();
~LokoMupdf();
bool SetFile(std::string str);
bool Open();
bool GetPage(int num);
bool GetPageData(LokoBuf * buf);
private:
std::string filename;
int page_number, page_count;
fz_context *ctx;
fz_document *doc;
fz_pixmap *pix;
fz_outline * outline;
fz_matrix ctm;
float zoom, rotate;
std::string version;
};
}
| 18.441176 | 40 | 0.570973 |
4dfdf294cd959e8be578ca83d1f7e002de978617 | 484 | h | C | WeatherFontIcon/ViewController.h | shafiullakhan/WeatherFontIcon | dac9bc8db38fbf92e2de363734fc4d6e74acb935 | [
"MIT"
] | 32 | 2015-01-03T12:46:17.000Z | 2018-05-17T03:12:45.000Z | WeatherFontIcon/ViewController.h | msAndroid/WeatherFontIcon | dac9bc8db38fbf92e2de363734fc4d6e74acb935 | [
"MIT"
] | null | null | null | WeatherFontIcon/ViewController.h | msAndroid/WeatherFontIcon | dac9bc8db38fbf92e2de363734fc4d6e74acb935 | [
"MIT"
] | 9 | 2015-01-21T15:03:36.000Z | 2016-04-19T13:53:55.000Z | //
// ViewController.h
// WeatherFontIcon
//
// Created by Shaffiulla Khan on 10/28/14.
// Copyright (c) 2014 Shaffiulla Khan. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIView *stageView;
@property (weak, nonatomic) IBOutlet UILabel *stageIcon;
@property (weak, nonatomic) IBOutlet UIPickerView *pickerView;
- (IBAction)sizeChanged:(id)sender;
- (IBAction)colorChanged:(id)sender;
@end
| 22 | 62 | 0.743802 |
4dfe06ee56bc22efab62ee7d034a61036e62f4bf | 274 | h | C | MKLoggingFiles/LogRecordAutoSink.h | MarnixKoerselman/MkLogging | 24ff8f4e6326c139b75844389941edaee03781c5 | [
"Unlicense"
] | null | null | null | MKLoggingFiles/LogRecordAutoSink.h | MarnixKoerselman/MkLogging | 24ff8f4e6326c139b75844389941edaee03781c5 | [
"Unlicense"
] | 3 | 2020-12-28T16:12:11.000Z | 2021-02-23T12:54:37.000Z | MKLoggingFiles/LogRecordAutoSink.h | MarnixKoerselman/MkLogging | 24ff8f4e6326c139b75844389941edaee03781c5 | [
"Unlicense"
] | null | null | null | #pragma once
#include "LogRecord.h"
struct LogRecordAutoSink : public LogRecord
{
LogRecordAutoSink(ILogSink* pLogSink, ELogLevel logLevel, const char* szFunction, const char* szFile, long lineNumber);
virtual ~LogRecordAutoSink();
private:
ILogSink* m_LogSink;
};
| 21.076923 | 121 | 0.770073 |
4dfe0bf5e6d0eea9461ef1e8851859e08041c6cc | 562 | c | C | gurba/lib/domains/sewer/rooms/19-j.c | DEFCON-MUD/defcon-28-mud-source | b25b5bd15fee6a4acda5119ea864bde4dff62714 | [
"Unlicense"
] | 4 | 2021-07-21T17:49:01.000Z | 2022-03-11T20:50:59.000Z | gurba/lib/domains/sewer/rooms/19-j.c | DEFCON-MUD/defcon-28-mud-source | b25b5bd15fee6a4acda5119ea864bde4dff62714 | [
"Unlicense"
] | null | null | null | gurba/lib/domains/sewer/rooms/19-j.c | DEFCON-MUD/defcon-28-mud-source | b25b5bd15fee6a4acda5119ea864bde4dff62714 | [
"Unlicense"
] | 1 | 2021-12-31T00:55:05.000Z | 2021-12-31T00:55:05.000Z | inherit "/std/room";
#include "../domain.h"
void setup( void ) {
add_area( "sewer" );
set_short( "Access Tunnel - 19-j" );
set_objects( DIR+"/monsters/strong_snake_7.c");
set_exits( ([
"north" : DIR+"/rooms/18-j.c",
"east" : DIR+"/rooms/19-k.c",
"west" : DIR+"/rooms/19-i.c"
]) );
set_long( "This is a narrow corridor, illuminated only by the red glow of the muck in this stink-pit. The walls and floors are covered with mud. The smell is outright dreadful.%^RESET%^\n\nYou may be able to find escape to the north, east, and west.%^RESET%^");
}
| 35.125 | 263 | 0.656584 |
4dffb2375467df10bc12e335cad83e1ec13f7249 | 480 | h | C | quickdialog/QSelectItemElement.h | Medigram/QuickDialog | 8880c80c143888be834bfc1051a4c9f69e0dc7b0 | [
"Apache-2.0"
] | 1 | 2017-09-09T11:42:52.000Z | 2017-09-09T11:42:52.000Z | quickdialog/QSelectItemElement.h | Medigram/QuickDialog | 8880c80c143888be834bfc1051a4c9f69e0dc7b0 | [
"Apache-2.0"
] | null | null | null | quickdialog/QSelectItemElement.h | Medigram/QuickDialog | 8880c80c143888be834bfc1051a4c9f69e0dc7b0 | [
"Apache-2.0"
] | null | null | null | //
// QSelectItemElement.h
// QuickDialog
//
// Created by HiveHicks on 23.03.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "QLabelElement.h"
#import "QuickDialogTableView.h"
#import "QLabelElement.h"
#import "QSelectSection.h"
@interface QSelectItemElement : QLabelElement
{
NSUInteger _index;
QSelectSection *_selectSection;
}
- (QSelectItemElement *)initWithIndex:(NSUInteger)integer selectSection:(QSelectSection *)section;
@end
| 20.869565 | 98 | 0.752083 |
15010c0ba3c0193bbef4f466659c47a4b71ccc5a | 1,537 | h | C | src/recycler.h | joecodemonkey/ssclib | b238da2a90c8d044180ae107788669a4b82a8cc8 | [
"BSD-3-Clause"
] | 1 | 2020-09-10T05:33:23.000Z | 2020-09-10T05:33:23.000Z | src/recycler.h | joecodemonkey/ssclib | b238da2a90c8d044180ae107788669a4b82a8cc8 | [
"BSD-3-Clause"
] | null | null | null | src/recycler.h | joecodemonkey/ssclib | b238da2a90c8d044180ae107788669a4b82a8cc8 | [
"BSD-3-Clause"
] | null | null | null | //
// Created by Joseph Hurdle on 7/5/20.
//
#ifndef SEARCHFILEC_RECYCLER_H
#define SEARCHFILEC_RECYCLER_H
#include <stdlib.h>
#include <stdbool.h>
typedef struct stMemChunk {
void *p;
size_t cap;
} MemoryChunk;
typedef struct stBufferFactory {
MemoryChunk *memory;
size_t cap;
} Recycler;
// initialize a memory chunk [mc]
// [mc] - pointer to memory chunk to be initialized
void mem_chunk_init(MemoryChunk *mc);
// initialize a recycler structure [rc] with some sane defaults
// [rc] - recycler to be initalized
void recycler_init(Recycler *rc);
// return memory[mem] to a recycler [rc] of length [size]
// [rc] - recycler to store the chunk
// [size] - number of bytes to return
// [mem] - bytes to return
void recycler_return(Recycler *rc, size_t size, void *mem);
// free the recycler [rc] and all chunks it currently owns
// [rc] - recycler to free
// returns buffer ptr
void recycler_free(Recycler *rc);
// get a memory chunk out of the recylcer
// [rc] - recycler to retrieve memory from
// [out] - memory chunk to populate
// [bytes] - number of bytes to allocate
// returns true on success
bool recycler_get(Recycler *rc, MemoryChunk *out, size_t bytes);
// get memory out of the recylcer [rc] of exactly [size_t] bytes or, allocate
// memory using malloc
// [rc] - recycler to retrieve memory from
// [bytes] - number of bytes to allocate
// returns exactly size_t byte allocated buffer or NULL if malloc fails
void * recycler_get_exact(Recycler *rc, size_t bytes);
#endif //SEARCHFILEC_RECYCLER_H
| 27.945455 | 77 | 0.724789 |
1501947e99bce4cd0d26bd3a0cb4f3efe2eafb90 | 647 | h | C | examples/service/TerminalService/terminalservice.h | skovatch/QtService | 4cea1c97d56f7afe8bc47ccc95e6c0110fafe580 | [
"BSD-3-Clause"
] | 94 | 2018-05-24T08:21:58.000Z | 2022-03-03T13:14:51.000Z | examples/service/TerminalService/terminalservice.h | skovatch/QtService | 4cea1c97d56f7afe8bc47ccc95e6c0110fafe580 | [
"BSD-3-Clause"
] | 24 | 2019-03-28T07:26:42.000Z | 2022-03-14T04:59:49.000Z | examples/service/TerminalService/terminalservice.h | skovatch/QtService | 4cea1c97d56f7afe8bc47ccc95e6c0110fafe580 | [
"BSD-3-Clause"
] | 33 | 2018-08-22T11:56:42.000Z | 2022-01-25T14:30:59.000Z | #ifndef TERMINALSERVICE_H
#define TERMINALSERVICE_H
#include <QtService/Service>
#include <QtCore/QCommandLineParser>
class TerminalService : public QtService::Service
{
Q_OBJECT
public:
explicit TerminalService(int &argc, char **argv);
// Service interface
protected:
CommandResult onStart() override;
CommandResult onStop(int &exitCode) override;
bool verifyCommand(const QStringList &arguments) override;
// Service interface
protected Q_SLOTS:
void terminalConnected(QtService::Terminal *terminal) override;
private:
bool parseArguments(QCommandLineParser &parser, const QStringList &arguments);
};
#endif // TERMINALSERVICE_H
| 22.310345 | 79 | 0.799073 |
15067d1e5047fe8ecc72778f92674c91bc90a88e | 464 | h | C | src/PluginCommunityChest.h | yaustar/MonopolyCppSample | 337c26959137e74627110a593c5e7f9c86d802ea | [
"MIT"
] | null | null | null | src/PluginCommunityChest.h | yaustar/MonopolyCppSample | 337c26959137e74627110a593c5e7f9c86d802ea | [
"MIT"
] | null | null | null | src/PluginCommunityChest.h | yaustar/MonopolyCppSample | 337c26959137e74627110a593c5e7f9c86d802ea | [
"MIT"
] | null | null | null | #ifndef PLUGIN_COMMUNITY_CHEST_H
#define PLUGIN_COMMUNITY_CHEST_H
#include <istream>
#include "PluginBase.h"
class PluginCommunityChest : public PluginBase
{
public:
DECLARE_PLUGIN_META_DATA;
PluginCommunityChest( BoardSquare * pParentSquare, std::istream & dataStream );
virtual void OnPlayerLand( MonopolyGame & game, Player & player );
private:
PluginCommunityChest();
static const int SPACES_TO_MOVE_BACK_BY;
};
#endif // PLUGIN_COMMUNITY_CHEST_H
| 20.173913 | 80 | 0.797414 |
150699cbb8d9971638a5eec292702574a557460c | 15,518 | c | C | src/builtin.c | teoet6/tueslisp | a6307781c2f809610575fa70415fcae5ed2a6813 | [
"MIT"
] | null | null | null | src/builtin.c | teoet6/tueslisp | a6307781c2f809610575fa70415fcae5ed2a6813 | [
"MIT"
] | null | null | null | src/builtin.c | teoet6/tueslisp | a6307781c2f809610575fa70415fcae5ed2a6813 | [
"MIT"
] | null | null | null | #include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
#include "tueslisp.h"
extern unsigned long long unquote_hash;
extern unsigned long long quasiquote_hash;
#define BUILTIN_TYPE_P(NAME, TYPE) \
Any *builtin_ ## NAME ## _p(Any *stack, Any *env, Any *body) { \
if (list_len(body) != 1) \
ERROR("Error, `%s` expects 1 argument!\n", #NAME "?"); \
Any *evaled = eval_any(stack, env, CAR(body)); \
RETNULL(evaled); \
if (evaled->type == TYPE) return make_symbol("t"); \
else return make_nil(); \
}
BUILTIN_TYPE_P(nil, NIL);
BUILTIN_TYPE_P(symbol, SYMBOL);
BUILTIN_TYPE_P(pair, PAIR);
BUILTIN_TYPE_P(number, NUMBER);
Any *builtin_quote(Any *stack, Any *env, Any *body) {
if (list_len(body) != 1)
ERROR("Error, `quote` expects 1 argument.\n");
return CAR(body);
}
Any *builtin_cons(Any *stack, Any *env, Any *body) {
stack = make_pair(make_nil(), stack);
if (list_len(body) != 2)
ERROR("Error: `cons` expects 2 arguments.\n");
Any *car_val = eval_any(stack, env, CAR(body));
RETNULL(car_val);
append(car_val, CAR(stack));
Any *cdr_val = eval_any(stack, env, CAR(CDR(body)));
RETNULL(cdr_val);
return make_pair(car_val, cdr_val);
}
#define BUILTIN_CAR_OR_CDR(WHICH) \
Any *builtin_ ## WHICH(Any *stack, Any *env, Any *body) { \
if (list_len(body) != 1) \
ERROR("Error: `%s` expects 1 argument.\n", #WHICH); \
Any *to_car_or_cdr = eval_any(stack, env, CAR(body)); \
if (to_car_or_cdr->type == NIL) return make_nil(); \
if (to_car_or_cdr->type == SYMBOL) { \
/* The problem is that we need to do very different */ \
/* Thing on car compared to cdr */ \
/* This is a very hacky solution */ \
int car = 0; \
int cdr = 0; \
WHICH = 1; \
if (car) { \
char car_sym[2]; \
car_sym[0] = to_car_or_cdr->sym->val[0]; \
car_sym[1] = 0; \
return make_symbol(car_sym); \
} else { \
if (to_car_or_cdr->sym->val[1] == 0) return make_nil(); \
return make_symbol(to_car_or_cdr->sym->val + 1); \
} \
} \
if (to_car_or_cdr->type != PAIR) { \
eprintf("Error: "); \
print_any(stderr, CAR(body)); \
eprintf(" does not evaluate to a pair.\n"); \
return NULL; \
} \
return to_car_or_cdr->pair->WHICH; \
}
BUILTIN_CAR_OR_CDR(cdr);
BUILTIN_CAR_OR_CDR(car);
Any *builtin_cat(Any *stack, Any *env, Any *body) {
stack = make_pair(make_nil(), stack);
if (list_len(body) < 0)
return NULL;
Any *ret = make_symbol("");
while (body->type) {
append(ret, CAR(stack));
Any *cur = eval_any(stack, env, CAR(body));
RETNULL(cur);
if (cur->type != SYMBOL)
ERROR("Error: all argument to `cat` should be symbols.\n");
char new[strlen(ret->sym->val) + strlen(cur->sym->val) + 1];
strcpy(new, ret->sym->val);
strcat(new, cur->sym->val);
ret = make_symbol(new);
body = CDR(body);
}
if (ret->sym->val[0] == 0) return make_nil();
return ret;
}
Any *do_quasiquoting(Any *stack, Any *env, Any *body) {
stack = make_pair(make_nil(), stack);
if(body->type == PAIR) {
if (CAR(body)->type == SYMBOL && CAR(body)->sym->hash == unquote_hash) {
if (list_len(CDR(body)) != 1)
ERROR("Error: unquote expects 1 argument.\n");
return eval_any(stack, env, CAR(CDR(body)));
}
if (CAR(body)->type == SYMBOL && CAR(body)->sym->hash == quasiquote_hash) {
if (list_len(CDR(body)) != 1)
ERROR("Error: quasiquote expects 1 argument.\n");
return body;
}
Any *car_val = do_quasiquoting(stack, env, CAR(body));
RETNULL(car_val);
append(car_val, CAR(stack));
Any *cdr_val = do_quasiquoting(stack, env, CDR(body));
RETNULL(cdr_val);
return make_pair(car_val, cdr_val);
}
return body;
}
Any *builtin_quasiquote(Any *stack, Any *env, Any *body) {
if (list_len(body) != 1)
ERROR("Error: `quasiquote` expects 1 argument.\n");
return do_quasiquoting(stack, env, CAR(body));
}
Any *builtin_defsym(Any *stack, Any *env, Any *body) {
if (list_len(body) < 2)
ERROR("Error `defsym` expects at least 2 arguments.\n");
if (CAR(body)->type != SYMBOL)
ERROR("Error: first argument to `defsym` should be a symbol\n");
Any *curr = CDR(body);
while (curr->pair->cdr->type) {
eval_any(stack, env, CAR(curr));
curr = curr->pair->cdr;
}
Any *val = eval_any(stack, env, CAR(curr));
RETNULL(val);
append(make_pair(CAR(body), val), env);
return val;
}
Any *builtin_set(Any *stack, Any *env, Any *body) {
stack = make_pair(make_nil(), stack);
if (list_len(body) != 2)
ERROR("Error: `set!` expects 2 arguments.\n");
Any *dest = eval_any(stack, env, CAR(body));
RETNULL(dest);
append(dest, CAR(stack));
Any *src = eval_any(stack, env, CAR(CDR(body)));
RETNULL(src);
set(dest, src);
return src;
}
#define BUILTIN_LAMBDA_OR_MACRO(WHICH) \
Any *builtin_ ## WHICH (Any *stack, Any *env, Any *body) { \
if (list_len(body) < 2) \
ERROR("Error: `%s` expects at least 2 arguments.\n", #WHICH); \
return make_ ## WHICH(env, \
CAR(body), \
make_pair(make_symbol("progn"), \
CDR(body))); \
}
BUILTIN_LAMBDA_OR_MACRO(lambda);
BUILTIN_LAMBDA_OR_MACRO(macro);
Any *builtin_plus(Any *stack, Any *env, Any *body) {
if (list_len(body) < 0)
return NULL;
long long top = 0, bot = 1;
while (body->type) {
Any *cur = eval_any(stack, env, CAR(body));
RETNULL(cur);
if (cur->type != NUMBER)
ERROR("Error: all arguments to `+` should be numbers.\n");
top = top * cur->num->bot + cur->num->top * bot;
bot = bot * cur->num->bot;
long long simple = gcd(top, bot);
top /= simple;
bot /= simple;
body = CDR(body);
}
return make_number(top, bot);
}
Any *builtin_minus(Any *stack, Any *env, Any *body) {
int len = list_len(body);
if (len < 0)
return NULL;
if (len == 0)
return make_number(0, 1);
Any *cur;
long long first_top = 0, first_bot = 1, rest_top = 0, rest_bot = 1;
cur = eval_any(stack, env, CAR(body));
RETNULL(cur);
if (cur->type != NUMBER)
ERROR("Error: all arguments to `-` should be numbers.\n");
first_top = cur->num->top;
first_bot = cur->num->bot;
body = CDR(body);
if (len == 1)
return make_number(-first_top, first_bot);
while (body->type) {
cur = eval_any(stack, env, CAR(body));
RETNULL(cur);
if (cur->type != NUMBER)
ERROR("Error: all arguments to `-` should be numbers.\n");
rest_top = rest_top * cur->num->bot + cur->num->top * rest_bot;
rest_bot *= cur->num->bot;
long long simple = gcd(rest_top, rest_bot);
rest_top /= simple;
rest_bot /= simple;
body = CDR(body);
}
return make_number(first_top * rest_bot - rest_top * first_bot,
first_bot * rest_bot);
}
Any *builtin_multiply(Any *stack, Any *env, Any *body) {
if (list_len(body) < 0)
return NULL;
long long top = 1, bot = 1;
while (body->type) {
Any *cur = eval_any(stack, env, CAR(body));
RETNULL(cur);
if (cur->type != NUMBER)
ERROR("Error: all arguments to `*` should be numbers.\n");
top *= cur->num->top;
bot *= cur->num->bot;
long long simple = gcd(top, bot);
top /= simple;
bot /= simple;
body = CDR(body);
}
return make_number(top, bot);
}
Any *builtin_divide(Any *stack, Any *env, Any *body) {
int len = list_len(body);
if (len < 0)
return NULL;
if (len == 0)
return make_number(0, 1);
Any *cur;
long long first_top = 1, first_bot = 1, rest_top = 1, rest_bot = 1;
cur = eval_any(stack, env, CAR(body));
RETNULL(cur);
if (cur->type != NUMBER)
ERROR("Error: all arguments to `/` should be numbers.\n");
first_top = cur->num->top;
first_bot = cur->num->bot;
body = CDR(body);
if (len == 1)
return make_number(first_bot, first_top);
while (body->type) {
cur = eval_any(stack, env, CAR(body));
RETNULL(cur);
if (cur->type != NUMBER)
ERROR("Error: all arguments to `/` should be numbers.\n");
rest_top *= cur->num->top;
rest_bot *= cur->num->bot;
long long simple = gcd(rest_top, rest_bot);
rest_top /= simple;
rest_bot /= simple;
body = CDR(body);
}
return make_number(first_top * rest_bot, first_bot * rest_top);
}
Any *builtin_equal(Any *stack, Any *env, Any *body) {
stack = make_pair(make_nil(), stack);
if (list_len(body) != 2)
ERROR("Error: `equal` expects 2 arguments.\n");
Any *val1 = eval_any(stack, env, CAR(body));
RETNULL(val1);
append(val1, CAR(stack));
Any *val2 = eval_any(stack, env, CAR(CDR(body)));
RETNULL(val2);
if (val1->type != val2->type)
return make_nil();
switch(val1->type) {
case EOF: return make_bool(1);
case NIL: return make_bool(1);
case SYMBOL: return make_bool(val1->sym->hash == val2->sym->hash);
case PAIR: return make_bool(val1->pair == val2->pair);
case NUMBER: return make_bool(val1->num->top == val2->num->top &&
val1->num->bot == val2->num->bot);
case BUILTIN_MACRO: return make_bool(val1->builtin_macro ==
val2->builtin_macro);
case BUILTIN_FUNCTION: return make_bool(val1->builtin_function ==
val2->builtin_function);
case LAMBDA: return make_bool(val1->lambda == val2->lambda);
case MACRO: return make_bool(val1->macro == val2->macro);
}
}
Any *builtin_less_than(Any *stack, Any *env, Any *body) {
stack = make_pair(make_nil(), stack);
if (list_len(body) != 2)
ERROR("Error: `<` expects 2 arguments.\n");
Any *val1 = eval_any(stack, env, CAR(body));
RETNULL(val1);
append(val1, CAR(stack));
Any *val2 = eval_any(stack, env, CAR(CDR(body)));
RETNULL(val2);
if (val1->type == NUMBER && val2->type == NUMBER)
return make_bool(val1->num->top * val2->num->bot <
val2->num->top * val1->num->bot);
if (val1->type == SYMBOL && val2->type == SYMBOL)
return make_bool(strcmp(val1->sym->val, val2->sym->val) < 0);
ERROR("Error: arguments to `<` should be either two numbers or two symbols!\n");
}
Any *builtin_greater_than(Any *stack, Any *env, Any *body) {
stack = make_pair(make_nil(), stack);
if (list_len(body) != 2)
ERROR("Error: `>` expects 2 arguments.\n");
Any *val1 = eval_any(stack, env, CAR(body));
RETNULL(val1);
append(val1, CAR(stack));
Any *val2 = eval_any(stack, env, CAR(CDR(body)));
RETNULL(val2);
if (val1->type == NUMBER && val2->type == NUMBER)
return make_bool(val1->num->top * val2->num->bot >
val2->num->top * val1->num->bot);
if (val1->type == SYMBOL && val2->type == SYMBOL)
return make_bool(strcmp(val1->sym->val, val2->sym->val) > 0);
ERROR("Error: arguments to `>` should be either two numbers or two symbols!\n");
}
Any *builtin_whole_part(Any *stack, Any *env, Any *body) {
if (list_len(body) != 1)
ERROR("Error: `whole-part` expects 2 arguments.\n");
Any *val = eval_any(stack, env, CAR(body));
RETNULL(val);
if (val->type != NUMBER)
ERROR("Error first argument to `whole-part` is not a number.\n");
return make_number(val->num->top / val->num->bot, 1);
}
Any *builtin_print(Any *stack, Any *env, Any *body) {
if (list_len(body) < 1)
ERROR("Error: `print` expects at least 1 argument.\n");
while (body->type) {
Any *cur = eval_any(stack, env, CAR(body));
RETNULL(cur);
print_any(stdout, cur);
body = CDR(body);
}
return make_nil();
}
Any *builtin_import(Any *stack, Any *env, Any *body) {
if (list_len(body) != 1)
ERROR("Error: `import` expects one argument.\n");
Any *filename = eval_any(stack, env, CAR(body));
RETNULL(filename);
if(filename->type != SYMBOL)
ERROR("Error: first argument to `import` is not a symbol!\n");
FILE *fp = fopen(filename->sym->val, "r");
if (!fp) return make_nil();
eval_file(stack, global_env, fp);
return filename;
}
Any *builtin_extract_function(Any *stack, Any *env, Any *body) {
stack = make_pair(make_nil(), stack);
if (list_len(body) != 2)
ERROR("Error: `extract-function` expects 2 arguments.\n");
Any *dl_name = eval_any(stack, env, CAR(body));
RETNULL(dl_name);
if (dl_name->type != SYMBOL)
ERROR("Error: first argument to `extract-function` doesn't evaluate to a symbol!.\n");
append(dl_name, CAR(stack));
Any *sig = eval_any(stack, env, CAR(CDR(body)));
RETNULL(sig);
if (sig->type != SYMBOL)
ERROR("Error: first argument to `extract function` doesn't evaluate to a symbol!.\n");
void *handle = dlopen(dl_name->sym->val, RTLD_NOW);
RETNULL(handle);
void *fun = dlsym(handle, sig->sym->val);
RETNULL(fun);
return make_builtin_function(fun);
}
Any *builtin_exit(Any *stack, Any *env, Any *body) {
int len = list_len(body);
if (len < 0)
return NULL;
if (len == 0)
exit(0);
if (len == 1) {
Any *exit_code = eval_any(stack, env, CAR(body));
RETNULL(exit_code);
if (exit_code->type != NUMBER)
ERROR("Error: first argument to `exit` doesn't evaluate to a number!\n");
exit(exit_code->num->top / exit_code->num->bot);
}
ERROR("Error: `exit` expects one or zero arguments!\n");
}
| 37.57385 | 94 | 0.52017 |
15084119d679fdb110114162d91735e50e328f6d | 1,037 | h | C | HdataBase/HDataArhiever/core/NSObject+Base.h | HLoveMe/HDataBase | bcf16b2dc192c98a8fdba1c2eebd6906486893ce | [
"Apache-2.0"
] | 1 | 2017-04-26T15:31:47.000Z | 2017-04-26T15:31:47.000Z | HdataBase/HDataArhiever/core/NSObject+Base.h | HLoveMe/HDataBase | bcf16b2dc192c98a8fdba1c2eebd6906486893ce | [
"Apache-2.0"
] | null | null | null | HdataBase/HDataArhiever/core/NSObject+Base.h | HLoveMe/HDataBase | bcf16b2dc192c98a8fdba1c2eebd6906486893ce | [
"Apache-2.0"
] | null | null | null | //
// NSObject+Base.h
// HChat
//
// Created by 朱子豪 on 2017/4/21.
// Copyright © 2017年 朱子豪. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@class IvarInfomation;
@interface NSObject (Base)
//判断是否为
+(BOOL)isBaseTarget;
-(BOOL)isBaseTarget;
//判断是否可以转换保存
-(BOOL)isEnCode;
+(BOOL)isEnCode;
//遍历本类 和 父类
-(void)enumerateObjectsUsingBlock:(void(^)(IvarInfomation *info))Block;
-(void)enumeratePropertyValue:(void(^)(NSString *proName,id value))Block;
+(void)enumerateIvar:(void(^)(NSString *proName))Block;
+(void)enumerateIvar2:(void (^)(NSString *name,NSString *type))Block;
//辅助函数
-(void)db_enumerateClazz:(Class)clazz propertys:(void(^)(objc_property_t t,NSString *name,id value))block;
-(void)db_enumerateClazz:(Class)clazz ivars:(void(^)(Ivar t,NSString *name,id value))block;
+(void)db_enumeratePropertys:(void(^)(objc_property_t t,NSString *name))block;
+(void)db_enumerateIvars:(void(^)(Ivar t,NSString *name))block;
//是否实现摸个协议
+(BOOL)isimplementationProtocol:(NSString *)name;
@end
| 24.690476 | 106 | 0.731919 |
1508c6536bd8c0966057eeb726a2039e3be3f4d4 | 177 | h | C | CutPodSource/CopyLabel.h | diankuanghuolong/CutPod | 68692931ad1774dace4d04a4a8952fcc23ba2dbd | [
"MIT"
] | null | null | null | CutPodSource/CopyLabel.h | diankuanghuolong/CutPod | 68692931ad1774dace4d04a4a8952fcc23ba2dbd | [
"MIT"
] | null | null | null | CutPodSource/CopyLabel.h | diankuanghuolong/CutPod | 68692931ad1774dace4d04a4a8952fcc23ba2dbd | [
"MIT"
] | null | null | null | //
// CopyLabel.h
// CutDemo
//
// Created by 小白 on 16/8/19.
// Copyright © 2016年 小白. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CopyLabel : UILabel
@end
| 12.642857 | 46 | 0.638418 |
150bd2e754739785df1d43288c17dbe7fd111dec | 512 | h | C | NuweScoreDemoApp/NuweScoreDemoApp/Frameworks/NuweScoreCharts.framework/Versions/A/Headers/PNBar.h | nuwehq/nuwe-charts-ios | 70f4e0d6e808a4c9e89843270b541bc08c8e73a9 | [
"MIT"
] | 460 | 2015-01-29T06:16:18.000Z | 2021-06-16T05:56:30.000Z | NuweScoreDemoApp/NuweScoreDemoApp/Frameworks/NuweScoreCharts.framework/Versions/A/Headers/PNBar.h | mohsinalimat/nuwe-charts-ios | 70f4e0d6e808a4c9e89843270b541bc08c8e73a9 | [
"MIT"
] | 6 | 2015-01-15T10:21:32.000Z | 2019-01-21T07:55:52.000Z | NuweScoreDemoApp/NuweScoreDemoApp/Frameworks/NuweScoreCharts.framework/Versions/A/Headers/PNBar.h | mohsinalimat/nuwe-charts-ios | 70f4e0d6e808a4c9e89843270b541bc08c8e73a9 | [
"MIT"
] | 53 | 2015-01-29T11:39:36.000Z | 2020-08-16T07:36:52.000Z | //
// PNBar.h
// PNChartDemo
//
// Created by kevin on 11/7/13.
// Copyright (c) 2013年 kevinzhow. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@protocol PNBarDelegate <NSObject>
- (void) clickedBar:(id) bar;
@end
@interface PNBar : UIView
@property (nonatomic) float grade;
@property (nonatomic,strong) CAShapeLayer * chartLine;
@property (nonatomic, strong) UIColor * barColor;
@property (nonatomic, assign) id<PNBarDelegate> pDelegate;
-(void)rollBack;
@end
| 16.516129 | 58 | 0.712891 |
151129f082dd81469ef9deae4fc417c7306f2fc7 | 1,661 | c | C | src/armci-memdev.c | jeffhammond/armci-mpi-fork | 1fc528a65f87f8cb6685a4b1b51d3406fd8cfe39 | [
"BSD-3-Clause-Open-MPI"
] | 10 | 2017-04-10T13:25:39.000Z | 2021-09-22T18:02:56.000Z | src/armci-memdev.c | jeffhammond/armci-mpi-fork | 1fc528a65f87f8cb6685a4b1b51d3406fd8cfe39 | [
"BSD-3-Clause-Open-MPI"
] | 26 | 2018-08-28T14:43:48.000Z | 2022-03-04T12:18:33.000Z | src/armci-memdev.c | jeffhammond/armci-mpi-fork | 1fc528a65f87f8cb6685a4b1b51d3406fd8cfe39 | [
"BSD-3-Clause-Open-MPI"
] | 3 | 2016-01-04T01:01:43.000Z | 2019-01-27T08:39:09.000Z | /*
* Copyright (C) 2019. See COPYRIGHT in top-level directory.
*/
#include <armci.h>
#include <armci_internals.h>
/* -- begin weak symbols block -- */
#if defined(HAVE_PRAGMA_WEAK)
# pragma weak ARMCI_Malloc_memdev = PARMCI_Malloc_memdev
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
# pragma _HP_SECONDARY_DEF PARMCI_Malloc_memdev ARMCI_Malloc_memdev
#elif defined(HAVE_PRAGMA_CRI_DUP)
# pragma _CRI duplicate ARMCI_Malloc_memdev as PARMCI_Malloc_memdev
#endif
/* -- end weak symbols block -- */
int PARMCI_Malloc_memdev(void **ptr_arr, armci_size_t bytes, const char* device)
{
return ARMCI_Malloc_group(ptr_arr, bytes, &ARMCI_GROUP_WORLD);
}
/* -- begin weak symbols block -- */
#if defined(HAVE_PRAGMA_WEAK)
# pragma weak ARMCI_Malloc_group_memdev = PARMCI_Malloc_group_memdev
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
# pragma _HP_SECONDARY_DEF PARMCI_Malloc_group_memdev ARMCI_Malloc_group_memdev
#elif defined(HAVE_PRAGMA_CRI_DUP)
# pragma _CRI duplicate ARMCI_Malloc_group_memdev as PARMCI_Malloc_group_memdev
#endif
/* -- end weak symbols block -- */
int PARMCI_Malloc_group_memdev(void **ptr_arr, armci_size_t bytes, ARMCI_Group *group, const char *device)
{
return ARMCI_Malloc_group(ptr_arr, bytes, group);
}
/* -- begin weak symbols block -- */
#if defined(HAVE_PRAGMA_WEAK)
# pragma weak ARMCI_Free_memdev = PARMCI_Free_memdev
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
# pragma _HP_SECONDARY_DEF PARMCI_Free_memdev ARMCI_Free_memdev
#elif defined(HAVE_PRAGMA_CRI_DUP)
# pragma _CRI duplicate ARMCI_Free_memdev as PARMCI_Free_memdev
#endif
/* -- end weak symbols block -- */
int PARMCI_Free_memdev(void *ptr)
{
return ARMCI_Free(ptr);
}
| 33.897959 | 106 | 0.789886 |
1513889a077480d0525bf793ef942f5541e0e5e6 | 11,124 | h | C | pulsemodule/eqpro_gui/pulsedriver.h | pac85/audioeqpro | 9b9be7eed74dbd229c9a645a3847f6f857e8f0cd | [
"MIT"
] | 11 | 2016-11-09T21:12:10.000Z | 2020-10-07T06:47:08.000Z | pulsemodule/eqpro_gui/pulsedriver.h | pac85/audioeqpro | 9b9be7eed74dbd229c9a645a3847f6f857e8f0cd | [
"MIT"
] | 1 | 2016-11-14T10:59:43.000Z | 2016-11-14T10:59:43.000Z | pulsemodule/eqpro_gui/pulsedriver.h | pac85/audioeqpro | 9b9be7eed74dbd229c9a645a3847f6f857e8f0cd | [
"MIT"
] | 6 | 2016-11-12T15:21:40.000Z | 2018-11-15T20:08:41.000Z | #ifndef PULSEDRIVER_H
#define PULSEDRIVER_H
extern "C"
{
#include <pulse/pulseaudio.h>
#include <pulse/message-params.h>
}
#include <iostream>
#include <stdexcept>
#include <string>
#include <QList>
#include <QtDebug>
#include <QObject>
#include <QStringList>
class PulseDriver;
enum class Actions{
getSinks,
getModules,
sendMsg,
subscrive //fixme
};
struct ud_t
{
void *rawout;
PulseDriver* pd_context;
pa_mainloop *m;
Actions a;
pa_context* c;
pa_mainloop_api *mapi;
pa_operation* pa_op;
};
class PulseDriver : public QObject
{
Q_OBJECT
public:
struct Eqinfo
{
int nBands;
double fmin;
double dB;
double r;
double K;
QVector<double> par;
};
PulseDriver(QObject* parent=0):
QObject(parent), modulenum(-1)
{}
~PulseDriver()
{}
void SendSliderChangeMsg(double val, int idx)
{
pa_message_param *param = pa_message_param_new();
pa_message_param_begin_list(param);
pa_message_param_write_double(param,val,32);
pa_message_param_write_int64(param,idx);
pa_message_param_end_list(param);
Message mx("sliderchange",pa_message_param_to_string(param),MessageDest());
SendMessage(mx);
if(mx.response != "OK")
emit module_seems_disconnected();
}
void SendDialChangeMsg(double val)
{
pa_message_param *param = pa_message_param_new();
pa_message_param_write_double(param,val,32);
Message mx("dialchange",pa_message_param_to_string(param),MessageDest());
SendMessage(mx);
if(mx.response != "OK")
emit module_seems_disconnected();
}
Eqinfo RequireEqInfo()
{
Eqinfo info;
Message mx( "getinfo", "", MessageDest());
SendMessage(mx);
void *state=NULL, *state2=NULL;
//pa_message_param* param;
char* startpos=NULL;
QByteArray resp = mx.response.toLocal8Bit();
pa_message_param_split_list(resp.data(), &startpos, NULL, &state);
int64_t n;
pa_message_param_read_int64(startpos, &n,&state2);
info.nBands=n;
pa_message_param_read_double(startpos, &info.fmin, &state2);
pa_message_param_read_double(startpos, &info.dB, &state2);
pa_message_param_read_double(startpos, &info.r, &state2);
pa_message_param_read_double(startpos, &info.K, &state2);
for (int i=0; i<info.nBands; i++)
{
double x;
pa_message_param_read_double(startpos, &x, &state2);
info.par.append(x);
}
return info;
}
QVector<int> GetEqproModules()
{
QList<Module> modules=GetModule();
QVector<int> out;
foreach (auto s, modules)
{
if(s.name == DRIVERNAME)
out.append(s.idx);
}
return out;
}
// doesn't work
void RegisterModuleDiconnectCallback()
{
MakeOperation<void*>(Actions::subscrive);
}
int getModuleNum() const { return modulenum; }
void setModuleNum(unsigned n)
{
QList<Module> ml=GetModule();
foreach (auto m, ml)
{
if(m.idx == int(n) && m.name == DRIVERNAME)
{
modulenum = n;
return;
}
}
throw std::logic_error("Module number is not correct");
}
private:
const QString DRIVERNAME="module-eqpro-sink";
const QString MSGDEST="/modules/eqpro";
int modulenum;
struct Sink
{
Sink(const QString &name="", const QString &driver="", int idx=0):
name(name), driver(driver), idx(idx)
{}
QString name;
QString driver;
int idx;
};
struct Message
{
Message(const QString& message="", const QString& param="", const QString& to="", const QString& response=""):
to(to), message(message), param(param), response(response)
{}
QString to;
QString message;
QString param;
QString response;
};
struct Module
{
Module(const QString &name="", int idx=0):
name(name), idx(idx)
{}
QString name;
int idx;
};
QString MessageDest()
{
if (modulenum<0)
throw std::logic_error("No module selected");
return MSGDEST + QString("/") + QString::number(modulenum);
}
template<typename T>
T MakeOperation(Actions a, T x=T())
{
pa_context *context = nullptr;
pa_mainloop *m = nullptr;
pa_mainloop_api *mapi = nullptr;
if (!(m = pa_mainloop_new()))
throw std::runtime_error("pa_mainloop_new() failed.");
mapi = pa_mainloop_get_api(m);
if (!(context = pa_context_new(mapi,"eqpro_gui")))
throw std::runtime_error("pa_context_new() failed.");
ud_t ud={(void*)&x, this, m, a, context, mapi, nullptr};
pa_context_set_state_callback(context, context_state_callback, (void*)&ud);
pa_context_connect(context, NULL, (pa_context_flags)0, NULL);
pa_mainloop_run(m, NULL);
pa_context_unref(context);
pa_mainloop_free(m);
return x;
}
QList<Sink> GetSinks()
{
return MakeOperation<QList<Sink>>(Actions::getSinks);
}
QList<Module> GetModule()
{
return MakeOperation<QList<Module>>(Actions::getModules);
}
void SendMessage(Message& message)
{
message=MakeOperation<Message>(Actions::sendMsg,message);
}
static void get_sink_info_callback(pa_context *c, const pa_sink_info *l, int is_last, void *userdata)
{
qDebug()<<"sink callback";
ud_t* ud=(ud_t*)userdata;
QList<Sink>* list=(QList<Sink>*)ud->rawout;
if(is_last > 0)
return;
list->append(Sink(l->name,l->driver,l->index));
}
static void get_module_info_callback(pa_context *c, const pa_module_info *l, int is_last, void *userdata)
{
qDebug()<<"module callback";
ud_t* ud=(ud_t*)userdata;
QList<Module>* list=(QList<Module>*)ud->rawout;
if(is_last > 0)
return;
list->append(Module(l->name,l->index));
}
static void get_content_string_callback(pa_context *c, int success, char *response, void *userdata)
{
qDebug()<<"get_content_string_callback";
ud_t* ud=(ud_t*)userdata;
Message* mx =(Message*)ud->rawout;
if(!success)
{
qDebug()<<"not success, send emit";
ud->mapi->quit(ud->mapi,0);
emit ud->pd_context->module_seems_disconnected();
return;
}
if(response)
{
mx->response=response;
qDebug()<<mx->response;
}
}
static void context_subscribe_callback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata)
{
qDebug()<<"context_subscribe_callback";
ud_t* ud=(ud_t*)userdata;
if (idx == (int)ud->pd_context->getModuleNum())
{
switch (t & PA_SUBSCRIPTION_EVENT_TYPE_MASK)
{
case PA_SUBSCRIPTION_EVENT_NEW:
case PA_SUBSCRIPTION_EVENT_CHANGE:
break;
case PA_SUBSCRIPTION_EVENT_REMOVE:
emit ud->pd_context->module_seems_disconnected();
}
}
}
static void context_state_callback(pa_context *c, void *userdata)
{
assert(c);
ud_t* ud=(ud_t*)userdata;
Message* mx;
qDebug()<<"context state";
switch (pa_context_get_state(c))
{
case PA_CONTEXT_CONNECTING:
case PA_CONTEXT_AUTHORIZING:
case PA_CONTEXT_SETTING_NAME:
break;
case PA_CONTEXT_READY:
qDebug()<<"Ready";
switch(ud->a)
{
case Actions::getSinks:
ud->pa_op = pa_context_get_sink_info_list(c, get_sink_info_callback, userdata);
break;
case Actions::getModules:
ud->pa_op = pa_context_get_module_info_list(c, get_module_info_callback, userdata);
break;
case Actions::sendMsg:
mx=(Message*)ud->rawout;
ud->pa_op = pa_context_send_message_to_object(c,
mx->to.toLocal8Bit().constData(),
mx->message.toLocal8Bit().constData(),
mx->param.toLocal8Bit().constData(),
get_content_string_callback,
userdata);
break;
case Actions::subscrive:
pa_context_set_subscribe_callback(c, context_subscribe_callback, userdata);
ud->pa_op = pa_context_subscribe(c,
(pa_subscription_mask)(PA_SUBSCRIPTION_MASK_SINK|
PA_SUBSCRIPTION_MASK_SOURCE|
PA_SUBSCRIPTION_MASK_SINK_INPUT|
PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT|
PA_SUBSCRIPTION_MASK_MODULE|
PA_SUBSCRIPTION_MASK_CLIENT|
PA_SUBSCRIPTION_MASK_SAMPLE_CACHE|
PA_SUBSCRIPTION_MASK_SERVER|
PA_SUBSCRIPTION_MASK_CARD),
NULL,userdata);
break;
}
pa_operation_set_state_callback(ud->pa_op, get_operation_state, userdata);
break;
case PA_CONTEXT_TERMINATED:
qDebug()<<"terminated";
break;
case PA_CONTEXT_FAILED:
ud->mapi->quit(ud->mapi,0); //stop mainloop
emit ud->pd_context->module_seems_disconnected();
break;
default:
throw std::runtime_error("Connection failure: " + std::string(pa_strerror(pa_context_errno(c))));
}
}
static void get_operation_state(pa_operation* pa_op, void* userdata)
{
ud_t* ud=(ud_t*)userdata;
qDebug()<<"op state "<< (int)ud->a;
switch(pa_operation_get_state(pa_op))
{
case PA_OPERATION_RUNNING:
qDebug()<<"Op running";
break;
case PA_OPERATION_CANCELLED:
qDebug()<<"Op canc";
case PA_OPERATION_DONE:
qDebug()<<"Op done canc";
pa_operation_unref(ud->pa_op);
ud->mapi->quit(ud->mapi,0); //stop mainloop
break;
}
}
private slots:
signals:
void module_seems_disconnected();
};
#endif // PULSEDRIVER_H
| 26.485714 | 119 | 0.546206 |
151a20029c54c962034d7eace67191a22a4e50b9 | 955 | h | C | class/n21/at_device_n21.h | liukangcc/at_device | 86390375518a421e5d58ec481ced484c349e8a76 | [
"Apache-2.0"
] | null | null | null | class/n21/at_device_n21.h | liukangcc/at_device | 86390375518a421e5d58ec481ced484c349e8a76 | [
"Apache-2.0"
] | null | null | null | class/n21/at_device_n21.h | liukangcc/at_device | 86390375518a421e5d58ec481ced484c349e8a76 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-05-22 shuobatian first version
*/
#ifndef __AT_DEVICE_N21_H__
#define __AT_DEVICE_N21_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <at_device.h>
/* The maximum number of sockets supported by the N21 device */
#define AT_DEVICE_N21_SOCKETS_NUM 4
struct at_device_n21
{
char *device_name;
char *client_name;
int power_pin;
int power_status_pin;
size_t recv_line_num;
struct at_device device;
void *user_data;
};
#ifdef AT_USING_SOCKET
/* n21 device socket initialize */
int n21_socket_init(struct at_device *device);
/* n21 device class socket register */
int n21_socket_class_register(struct at_device_class *class);
#endif /* AT_USING_SOCKET */
#ifdef __cplusplus
}
#endif
#endif /* __AT_DEVICE_N21_H__ */
| 18.018868 | 63 | 0.709948 |
151aa15df0b776a4f52676b6576a7b950ff0d061 | 1,206 | h | C | Freestyle/clsquare/src/utils/costfunc.h | AADC-Fruit/AADC_2015_FRUIT | 88bd18871228cb48c46a3bd803eded6f14dbac08 | [
"BSD-3-Clause"
] | 1 | 2018-05-10T22:35:25.000Z | 2018-05-10T22:35:25.000Z | Freestyle/clsquare/src/utils/costfunc.h | AADC-Fruit/AADC_2015_FRUIT | 88bd18871228cb48c46a3bd803eded6f14dbac08 | [
"BSD-3-Clause"
] | null | null | null | Freestyle/clsquare/src/utils/costfunc.h | AADC-Fruit/AADC_2015_FRUIT | 88bd18871228cb48c46a3bd803eded6f14dbac08 | [
"BSD-3-Clause"
] | null | null | null | /*
CLSquare
Copyright (c) Martin Riedmiller
Author: Martin Riedmiller
All rights reserved.
No distribution without permission.
*/
#ifndef _COSTFUNC_H_
#define _COSTFUNC_H_
#include "utils/setdef.h"
namespace CLS {
namespace Util {
class CostFunc{
public:
bool init(const int xdim, const int udim, const char *fname=0, const char *section_name=0);
bool deinit(); //terminate
double get_costs_standard(const double* state, const double* action, const double* nextstate);
double get_costs_absdist(const double* state, const double* action, const double* nextstate);
bool in_xplus(const double *state);
bool in_xplusterminal(const double *state);
bool is_failure(const double *state);
void get_center_of_xplusterminal(double *result);
double costs_for_terminal_failure;
double costs_for_terminal_success;
double costs_inside_xplus;
double costs_outside_xplus;
protected:
bool read_options(const char * fname, const char *section_name);
int u_dim, x_dim;
double* weights;
/** definition of working state set. */
CLS::Util::SetDef XworkSet;
CLS::Util::SetDef XplusSet;
CLS::Util::SetDef XminusSet;
CLS::Util::SetDef xplusterminal;
};
};
};
#endif
| 22.333333 | 96 | 0.747927 |
151e72a5a14f825ab2455f67509f7aabb670df7a | 1,226 | h | C | src/object.h | brick-lang/brandt-gc | fd02059aec76da2ffeee4b3ed2348f0ffceff195 | [
"MIT"
] | 3 | 2019-05-29T19:30:32.000Z | 2020-08-07T13:43:38.000Z | src/object.h | brick-lang/brandt-gc | fd02059aec76da2ffeee4b3ed2348f0ffceff195 | [
"MIT"
] | null | null | null | src/object.h | brick-lang/brandt-gc | fd02059aec76da2ffeee4b3ed2348f0ffceff195 | [
"MIT"
] | 1 | 2019-05-30T07:39:45.000Z | 2019-05-30T07:39:45.000Z | #ifndef OBJECT_H
#define OBJECT_H
#include <stdatomic.h>
#include "../lib/collectc/hashtable.h"
#include "idlock.h"
#include "safelist.h"
/**
* Keeps track of the state of the "which" bit. */
typedef atomic_uint_fast8_t bit_t;
typedef struct acid_header_t {
idlock_t lock;
HashTable *links; // HashTable<String, Link>
bit_t which;
bool phantomized;
int count[3];
struct collector_t *collector;
bool phantomization_complete;
void (*dtor)(void *);
void *data;
uint64_t magic; // magic number to determine if an object is GC-tracked
} Object;
Object *object_init(Object *o);
Object *object_init_strong(Object *o);
Object *object_get(Object *obj, size_t field_offset);
void object_set(Object *obj, size_t field_offset, Object *referent);
void object_phantomize_node(Object *obj, struct collector_t *cptr);
void object_recover_node(Object *obj, struct collector_t *cptr);
void object_inc_strong(Object *obj);
void object_dec(Object *obj, bit_t w);
void object_dec_phantom(Object *obj);
void object_dec_strong(Object *obj);
void object_clean_node(Object *obj);
bool object_merge_collectors(Object *obj, Object *target);
void object_set_collector(Object *obj, struct collector_t *c);
#endif // OBJECT_H
| 29.190476 | 74 | 0.75938 |
1520152f159d8d561dc2c60109d05d16fc021429 | 528 | h | C | MIDIFish/MFAudiobusDestination.h | Air-Craft/MIDIFish | 5bf71cc1d294717f2e2ed636762e35e49fe21b76 | [
"MIT"
] | 5 | 2016-03-29T16:20:04.000Z | 2021-11-15T09:38:35.000Z | MIDIFish/MFAudiobusDestination.h | Air-Craft/MIDIFish | 5bf71cc1d294717f2e2ed636762e35e49fe21b76 | [
"MIT"
] | 1 | 2015-11-11T11:18:28.000Z | 2015-11-18T17:45:39.000Z | MIDIFish/MFAudiobusDestination.h | Air-Craft/MIDIFish | 5bf71cc1d294717f2e2ed636762e35e49fe21b76 | [
"MIT"
] | null | null | null | //
// MFAudiobusDestination.h
// AC-Sabre
//
// Created by Hari Karam Singh on 15/03/2017.
//
//
#import "MFAudiobusConnection.h"
@class ABMIDISenderPort;
@interface MFAudiobusDestination : MFAudiobusConnection <MFMIDIMessageSender>
// Readonly as for audiobus we'll keep the management within their environment as to not confuse users.
@property (nonatomic, readonly) BOOL enabled;
/** Ref to the audiobus port for your convenvience */
@property (nonatomic, strong, readonly) ABMIDISenderPort *abMIDISenderPort;
@end
| 24 | 104 | 0.763258 |
1527dec4b27ce5f6381e3d4961aecc8c37700f03 | 24 | h | C | include/stdarg.h | bukinr/mdepx | 4d972445d1483e476db0b396db27005f9f2c3a02 | [
"BSD-2-Clause"
] | 13 | 2019-10-10T04:20:54.000Z | 2021-08-31T18:20:39.000Z | include/stdarg.h | CTSRD-CHERI/osfive | 726b15972685079b2d8ab4a2ab23dbc26b9d18dc | [
"BSD-2-Clause"
] | null | null | null | include/stdarg.h | CTSRD-CHERI/osfive | 726b15972685079b2d8ab4a2ab23dbc26b9d18dc | [
"BSD-2-Clause"
] | 2 | 2021-02-05T01:59:00.000Z | 2021-06-22T01:00:04.000Z | #include <sys/stdarg.h>
| 12 | 23 | 0.708333 |
152876ea0648c9ffcae7cd1acb074417fc3e1098 | 225 | c | C | src/ast/position.c | Hejsil/compiler | ced80cd011528e35c6e3301897b9f8474b9ee9c4 | [
"MIT"
] | null | null | null | src/ast/position.c | Hejsil/compiler | ced80cd011528e35c6e3301897b9f8474b9ee9c4 | [
"MIT"
] | null | null | null | src/ast/position.c | Hejsil/compiler | ced80cd011528e35c6e3301897b9f8474b9ee9c4 | [
"MIT"
] | null | null | null | //
// Created by jimmi on 12/25/16.
//
#include "position.h"
void init_position(Position *position, char *source) {
position->source = source;
position->column = 0;
position->line = 0;
position->index = 0;
} | 18.75 | 54 | 0.635556 |
1529ad86365b63427314ac15dddab92df8732dca | 1,032 | h | C | Spark/Spark/Spark.h | JARVIS-AI/Spark | d21b39cf483d6e1c43f427564e31016416c01ad8 | [
"MIT"
] | 81 | 2015-07-22T16:01:43.000Z | 2022-01-07T15:49:39.000Z | Spark/Spark/Spark.h | JARVIS-AI/Spark | d21b39cf483d6e1c43f427564e31016416c01ad8 | [
"MIT"
] | 16 | 2016-04-14T21:16:40.000Z | 2022-01-26T08:45:23.000Z | Spark/Spark/Spark.h | JARVIS-AI/Spark | d21b39cf483d6e1c43f427564e31016416c01ad8 | [
"MIT"
] | 19 | 2015-10-16T07:18:42.000Z | 2022-01-25T20:22:23.000Z | /*
* Spark.h
* Spark Editor
*
* Created by Black Moon Team.
* Copyright (c) 2004 - 2007 Shadow Lab. All rights reserved.
*/
#import <SparkKit/SparkAppleScriptSuite.h>
SPARK_PRIVATE
NSArray *gSortByNameDescriptors;
SPARK_PRIVATE
NSString * const SparkEntriesPboardType;
SPARK_PRIVATE
NSString * const SESparkEditorDidChangePlugInStatusNotification;
SPARK_PRIVATE
void SEPopulatePlugInMenu(NSMenu *menu);
@interface SparkEditor : NSApplication
- (NSMenu *)plugInsMenu;
@end
@interface Spark : NSObject <NSApplicationDelegate>
+ (Spark *)sharedSpark;
// MARK: Menu IBActions
- (IBAction)setAgentEnabled:(id)sender;
- (IBAction)setAgentDisabled:(id)sender;
- (IBAction)showPreferences:(id)sender;
// MARK: Import/Export Support
//- (IBAction)importLibrary:(id)sender;
// MARK: PlugIn Help Support
- (IBAction)showPlugInHelp:(id)sender;
- (void)showPlugInHelpPage:(NSString *)page;
// MARK: Live Update Support
//- (IBAction)checkForNewVersion:(id)sender;
- (void)createAboutMenu;
- (void)createDebugMenu;
@end
| 19.846154 | 64 | 0.75969 |
152c54fe0980f63ccd9d605d98d2623680fd83a1 | 1,091 | h | C | System/Library/PrivateFrameworks/ARKitCore.framework/ARMLImageMattingMetadataTechnique.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | System/Library/PrivateFrameworks/ARKitCore.framework/ARMLImageMattingMetadataTechnique.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/ARKitCore.framework/ARMLImageMattingMetadataTechnique.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, September 27, 2020 at 11:52:30 AM Mountain Standard Time
* Operating System: Version 14.0 (Build 18A373)
* Image Source: /System/Library/PrivateFrameworks/ARKitCore.framework/ARKitCore
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <ARKitCore/ARKitCore-Structs.h>
#import <ARKitCore/ARImageBasedTechnique.h>
@protocol OS_dispatch_queue;
@class ARImageScalingTechnique, NSObject;
@interface ARMLImageMattingMetadataTechnique : ARImageBasedTechnique {
BOOL _enableDoubleMLResolutionForIPad;
ARImageScalingTechnique* _mattingImageScalingTechnique;
CVPixelBufferPoolRef _bgraMattingPixelBufferPool;
vImageCVImageFormatRef _cvImageFormatRef;
NSObject*<OS_dispatch_queue> _processingQueue;
BOOL _deterministic;
}
-(id)processData:(id)arg1 ;
-(void)dealloc;
-(id)init;
-(void)prepare:(BOOL)arg1 ;
-(id)_generateMattingMetadata:(id)arg1 ;
-(id)_convertImageColorSpace:(id)arg1 pPoolToUse:(_CVPixelBufferPool*)arg2 ;
-(double)requiredTimeInterval;
-(id)resultDataClasses;
@end
| 31.171429 | 81 | 0.809349 |
152ea57446f42f241f2acb83f2cea8b37df1d8d0 | 16,510 | h | C | src/rl/hal/UniversalRobotsRtde.h | Broekman/rl | 285a7adab0bca3aa4ce4382bf5385f5b0626f10e | [
"BSD-2-Clause"
] | 568 | 2015-01-23T03:38:45.000Z | 2022-03-30T16:12:56.000Z | src/rl/hal/UniversalRobotsRtde.h | Broekman/rl | 285a7adab0bca3aa4ce4382bf5385f5b0626f10e | [
"BSD-2-Clause"
] | 53 | 2016-03-23T13:16:47.000Z | 2022-03-17T05:58:06.000Z | src/rl/hal/UniversalRobotsRtde.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_HAL_UNIVERSALROBOTSRTDE_H
#define RL_HAL_UNIVERSALROBOTSRTDE_H
#include <cstdint>
#include <boost/optional.hpp>
#include "AnalogInputReader.h"
#include "AnalogOutputReader.h"
#include "AnalogOutputWriter.h"
#include "CartesianForceSensor.h"
#include "CartesianPositionSensor.h"
#include "CartesianVelocitySensor.h"
#include "CyclicDevice.h"
#include "DigitalInputReader.h"
#include "DigitalOutputReader.h"
#include "DigitalOutputWriter.h"
#include "Endian.h"
#include "JointAccelerationActuator.h"
#include "JointCurrentSensor.h"
#include "JointPositionActuator.h"
#include "JointPositionSensor.h"
#include "JointVelocityActuator.h"
#include "JointVelocitySensor.h"
#include "Socket.h"
namespace rl
{
namespace hal
{
/**
* Universal Robots RTDE interface (3.3).
*/
class RL_HAL_EXPORT UniversalRobotsRtde :
public CyclicDevice,
public AnalogInputReader,
public AnalogOutputReader,
public AnalogOutputWriter,
public CartesianForceSensor,
public CartesianPositionSensor,
public CartesianVelocitySensor,
public DigitalInputReader,
public DigitalOutputReader,
public DigitalOutputWriter,
public JointAccelerationActuator,
public JointCurrentSensor,
public JointPositionActuator,
public JointPositionSensor,
public JointVelocityActuator,
public JointVelocitySensor
{
public:
enum class JointMode
{
shuttingDown = 236,
partDCalibration = 237,
backdrive = 238,
powerOff = 239,
notResponding = 245,
motorInitialisation = 246,
booting = 247,
partDCalibrationError = 248,
bootloader = 249,
calibration = 250,
fault = 252,
running = 253,
idleMode = 255
};
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_SHUTTING_DOWN = JointMode::shuttingDown;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_PART_D_CALIBRATION = JointMode::partDCalibration;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_BACKDRIVE = JointMode::backdrive;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_POWER_OFF = JointMode::powerOff;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_NOT_RESPONDING = JointMode::notResponding;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_MOTOR_INITIALISATION = JointMode::motorInitialisation;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_BOOTING = JointMode::booting;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_PART_D_CALIBRATION_ERROR = JointMode::partDCalibrationError;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_BOOTLOADER = JointMode::bootloader;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_CALIBRATION = JointMode::calibration;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_FAULT = JointMode::fault;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_RUNNING = JointMode::running;
RL_HAL_DEPRECATED static constexpr JointMode JOINT_MODE_IDLE_MODE = JointMode::idleMode;
enum class RobotMode
{
disconnected = 0,
confirmSafety = 1,
booting = 2,
powerOff = 3,
powerOn = 4,
idle = 5,
backdrive = 6,
running = 7,
updatingFirmware = 8
};
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_DISCONNECTED = RobotMode::disconnected;
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_CONFIRM_SAFETY = RobotMode::confirmSafety;
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_BOOTING = RobotMode::booting;
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_POWER_OFF = RobotMode::powerOff;
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_POWER_ON = RobotMode::powerOn;
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_IDLE = RobotMode::idle;
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_BACKDRIVE = RobotMode::backdrive;
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_RUNNING = RobotMode::running;
RL_HAL_DEPRECATED static constexpr RobotMode ROBOT_MODE_UPDATING_FIRMWARE = RobotMode::updatingFirmware;
enum class RobotStatus
{
powerOn = 1,
programRunning = 2,
teachButtonPressed = 4,
powerButtonPressed = 8
};
RL_HAL_DEPRECATED static constexpr RobotStatus ROBOT_STATUS_POWER_ON = RobotStatus::powerOn;
RL_HAL_DEPRECATED static constexpr RobotStatus ROBOT_STATUS_PROGRAM_RUNNING = RobotStatus::programRunning;
RL_HAL_DEPRECATED static constexpr RobotStatus ROBOT_STATUS_TEACH_BUTTON_PRESSED = RobotStatus::teachButtonPressed;
RL_HAL_DEPRECATED static constexpr RobotStatus ROBOT_STATUS_POWER_BUTTON_PRESSED = RobotStatus::powerButtonPressed;
enum class RuntimeState
{
stopping = 0,
stopped = 1,
playing = 2,
pausing = 3,
paused = 4,
resuming = 5
};
RL_HAL_DEPRECATED static constexpr RuntimeState RUNTIME_STATE_STOPPING = RuntimeState::stopping;
RL_HAL_DEPRECATED static constexpr RuntimeState RUNTIME_STATE_STOPPED = RuntimeState::stopped;
RL_HAL_DEPRECATED static constexpr RuntimeState RUNTIME_STATE_PLAYING = RuntimeState::playing;
RL_HAL_DEPRECATED static constexpr RuntimeState RUNTIME_STATE_PAUSING = RuntimeState::pausing;
RL_HAL_DEPRECATED static constexpr RuntimeState RUNTIME_STATE_PAUSED = RuntimeState::paused;
RL_HAL_DEPRECATED static constexpr RuntimeState RUNTIME_STATE_RESUMING = RuntimeState::resuming;
enum class SafetyMode
{
normal = 1,
reduced = 2,
protectiveStop = 3,
recovery = 4,
safeguardStop = 5,
systemEmergencyStop = 6,
robotEmergencyStop = 7,
violation = 8,
fault = 9
};
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_NORMAL = SafetyMode::normal;
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_REDUCED = SafetyMode::reduced;
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_PROTECTIVE_STOP = SafetyMode::protectiveStop;
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_RECOVERY = SafetyMode::recovery;
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_SAFEGUARD_STOP = SafetyMode::safeguardStop;
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_SYSTEM_EMERGENCY_STOP = SafetyMode::systemEmergencyStop;
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_ROBOT_EMERGENCY_STOP = SafetyMode::robotEmergencyStop;
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_VIOLATION = SafetyMode::violation;
RL_HAL_DEPRECATED static constexpr SafetyMode SAFETY_MODE_FAULT = SafetyMode::fault;
enum class SafetyStatus
{
normalMode = 1,
reducedMode = 2,
protectiveStopped = 4,
recoveryMode = 8,
safeguardStopped = 16,
systemEmergencyStopped = 32,
robotEmergencyStopped = 64,
emergencyStopped = 128,
violation = 256,
fault = 512,
stoppedDueToSafety = 1024
};
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_NORMAL_MODE = SafetyStatus::normalMode;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_REDUCED_MODE = SafetyStatus::reducedMode;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_PROTECTIVE_STOPPED = SafetyStatus::protectiveStopped;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_RECOVERY_MODE = SafetyStatus::recoveryMode;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_SAFEGUARD_STOPPED = SafetyStatus::safeguardStopped;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_SYSTEM_EMERGENCY_STOPPED = SafetyStatus::systemEmergencyStopped;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_ROBOT_EMERGENCY_STOPPED = SafetyStatus::robotEmergencyStopped;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_EMERGENCY_STOPPED = SafetyStatus::emergencyStopped;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_VIOLATION = SafetyStatus::violation;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_FAULT = SafetyStatus::fault;
RL_HAL_DEPRECATED static constexpr SafetyStatus SAFETY_STATUS_STOPPED_DUE_TO_SAFETY = SafetyStatus::stoppedDueToSafety;
UniversalRobotsRtde(const ::std::string& address, const ::std::chrono::nanoseconds& updateRate = ::std::chrono::milliseconds(8));
virtual ~UniversalRobotsRtde();
void close();
void doScript(const ::std::string& script);
using AnalogInputReader::getAnalogInput;
::rl::math::Real getAnalogInput(const ::std::size_t& i) const;
::std::size_t getAnalogInputCount() const;
::rl::math::Real getAnalogInputMaximum(const ::std::size_t& i) const;
::rl::math::Real getAnalogInputMinimum(const ::std::size_t& i) const;
::std::vector<::rl::math::Units> getAnalogInputUnit() const;
::rl::math::Units getAnalogInputUnit(const ::std::size_t& i) const;
using AnalogOutputReader::getAnalogOutput;
::rl::math::Real getAnalogOutput(const ::std::size_t& i) const;
::std::size_t getAnalogOutputCount() const;
::rl::math::Real getAnalogOutputMaximum(const ::std::size_t& i) const;
::rl::math::Real getAnalogOutputMinimum(const ::std::size_t& i) const;
::std::vector<::rl::math::Units> getAnalogOutputUnit() const;
::rl::math::Units getAnalogOutputUnit(const ::std::size_t& i) const;
::rl::math::ForceVector getCartesianForce() const;
::rl::math::Transform getCartesianPosition() const;
::rl::math::Transform getCartesianPositionTarget() const;
::rl::math::MotionVector getCartesianVelocity() const;
::rl::math::MotionVector getCartesianVelocityTarget() const;
::boost::dynamic_bitset<> getDigitalInput() const;
bool getDigitalInput(const ::std::size_t& i) const;
::std::size_t getDigitalInputCount() const;
::boost::dynamic_bitset<> getDigitalOutput() const;
bool getDigitalOutput(const ::std::size_t& i) const;
::std::size_t getDigitalOutputCount() const;
::rl::math::Vector getJointCurrent() const;
JointMode getJointMode(const ::std::size_t& i) const;
::rl::math::Vector getJointPosition() const;
::rl::math::Vector getJointTemperature() const;
::rl::math::Vector getJointVelocity() const;
RobotMode getRobotMode() const;
::std::uint32_t getRobotStatusBits() const;
RuntimeState getRuntimeState() const;
SafetyMode getSafetyMode() const;
::std::uint32_t getSafetyStatusBits() const;
void open();
using AnalogOutputWriter::setAnalogOutput;
void setAnalogOutput(const ::std::size_t& i, const ::rl::math::Real& value);
void setAnalogOutputUnit(const ::std::vector<::rl::math::Units>& values);
void setAnalogOutputUnit(const ::std::size_t& i, const ::rl::math::Units& value);
using DigitalOutputWriter::setDigitalOutput;
void setDigitalOutput(const ::std::size_t& i, const bool& value);
void setJointAcceleration(const ::rl::math::Vector& qdd);
void setJointPosition(const ::rl::math::Vector& q);
void setJointVelocity(const ::rl::math::Vector& qd);
void start();
void step();
void stop();
protected:
private:
enum class Command : ::std::uint8_t
{
controlPackagePause = 80,
controlPackageSetupInputs = 73,
controlPackageSetupOutputs = 79,
controlPackageStart = 83,
dataPackage = 85,
getUrcontrolVersion = 118,
requestProtocolVersion = 86,
textMessage = 77
};
struct Input
{
::boost::optional<::std::uint8_t> configurableDigitalOutput;
::boost::optional<::std::uint8_t> configurableDigitalOutputMask;
::boost::optional<::std::uint32_t> inputBitRegisters0;
::boost::optional<::std::uint32_t> inputBitRegisters1;
::std::vector<double> inputDoubleRegister;
::std::vector<::std::int32_t> inputIntRegister;
::boost::optional<double> standardAnalogOutput0;
::boost::optional<double> standardAnalogOutput1;
::boost::optional<::std::uint8_t> standardAnalogOutputMask;
::std::uint8_t standardAnalogOutputType;
::boost::optional<::std::uint8_t> standardDigitalOutput;
::boost::optional<::std::uint8_t> standardDigitalOutputMask;
};
struct Output
{
double actualCurrent[6];
::std::uint64_t actualDigitalInputBits;
::std::uint64_t actualDigitalOutputBits;
double actualQ[6];
double actualQd[6];
double actualTcpForce[6];
double actualTcpPose[6];
double actualTcpSpeed[6];
::std::uint32_t analogIoTypes;
::std::int32_t jointMode[6];
double jointTemperatures[6];
::std::uint32_t outputBitRegisters0;
::std::uint32_t outputBitRegisters1;
double outputDoubleRegister[24];
::std::int32_t outputIntRegister[24];
::std::int32_t robotMode;
::std::uint32_t robotStatusBits;
::std::uint32_t runtimeState;
::std::int32_t safetyMode;
::std::uint32_t safetyStatusBits;
double speedScaling;
double standardAnalogInput0;
double standardAnalogInput1;
double standardAnalogOutput0;
double standardAnalogOutput1;
double targetCurrent[6];
double targetMoment[6];
double targetQ[6];
double targetQd[6];
double targetQdd[6];
double targetTcpPose[6];
double targetTcpSpeed[6];
double timestamp;
double toolAnalogInput0;
double toolAnalogInput1;
::std::uint32_t toolAnalogInputTypes;
double toolOutputCurrent;
::std::int32_t toolOutputVoltage;
};
struct Version
{
::std::uint32_t bugfix;
::std::uint32_t build;
::std::uint32_t major;
::std::uint32_t minor;
};
void recv();
void send(::std::uint8_t* buffer, const ::std::size_t& size);
void send(const Command& command);
void send(const Command& command, const ::std::vector<::std::string>& strings);
void send(const Command& command, const ::std::uint16_t& word);
void sendAnalogOutputs();
void sendBitRegisters();
void sendDigitalOutputs();
void sendDoubleRegister();
void sendIntegerRegister();
template<typename T>
void serialize(T& t, ::std::uint8_t*& ptr)
{
Endian::hostToBig(t);
::std::memcpy(ptr, &t, sizeof(t));
ptr += sizeof(t);
}
template<typename T, ::std::size_t N>
void serialize(T (&t)[N], ::std::uint8_t*& ptr)
{
for (::std::size_t i = 0; i < N; ++i)
{
this->serialize(t[i], ptr);
}
}
template<typename T>
void unserialize(::std::uint8_t*& ptr, T& t)
{
::std::memcpy(&t, ptr, sizeof(t));
Endian::bigToHost(t);
ptr += sizeof(t);
}
template<typename T, ::std::size_t N>
void unserialize(::std::uint8_t*& ptr, T (&t)[N])
{
for (::std::size_t i = 0; i < N; ++i)
{
this->unserialize(ptr, t[i]);
}
}
Input input;
Output output;
Socket socket2;
Socket socket4;
Version version;
};
}
}
#endif // RL_HAL_UNIVERSALROBOTSRTDE_H
| 31.996124 | 132 | 0.723864 |
1530a43d7e9fef0e8a2ef25020b95480fbcba5e7 | 1,243 | h | C | Engine/Plugins/Tests/EditorTests/Source/EditorTests/Public/EditorTestsUtilityLibrary.h | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | 1 | 2022-01-29T18:36:12.000Z | 2022-01-29T18:36:12.000Z | Engine/Plugins/Tests/EditorTests/Source/EditorTests/Public/EditorTestsUtilityLibrary.h | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | null | null | null | Engine/Plugins/Tests/EditorTests/Source/EditorTests/Public/EditorTestsUtilityLibrary.h | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | null | null | null | // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Components/StaticMeshComponent.h"
#include "Engine/MeshMerging.h"
#include "EditorTestsUtilityLibrary.generated.h"
class UMaterialOptions;
struct FMeshMergingSettings;
/** Blueprint library for altering and analyzing animation / skeletal data */
UCLASS()
class UEditorTestsUtilityLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/** Bakes out material in-place for the given set of static mesh components using the MaterialMergeOptions */
UFUNCTION(BlueprintCallable, Category = "MeshMergingLibrary|Test")
static void BakeMaterialsForComponent(UStaticMeshComponent* InStaticMeshComponent, const UMaterialOptions* MaterialOptions, const UMaterialMergeOptions* MaterialMergeOptions);
/** Merges meshes and bakes out materials into a atlas-material for the given set of static mesh components using the MergeSettings */
UFUNCTION(BlueprintCallable, Category = "MeshMergingLibrary|Test")
static void MergeStaticMeshComponents(TArray<UStaticMeshComponent*> InStaticMeshComponents, const FMeshMergingSettings& MergeSettings, const bool bReplaceActors, TArray<int32>& OutLODIndices);
}; | 44.392857 | 193 | 0.824618 |
1531012cba3a7d3abb1bb1449706b0c457669039 | 250 | h | C | lib/XLQSKit.framework/Headers/NSMutableArray+LQS.h | yococoxc/TicketUnion | 2049970f458d48b5359562ebaf61bc794268a014 | [
"MIT"
] | null | null | null | lib/XLQSKit.framework/Headers/NSMutableArray+LQS.h | yococoxc/TicketUnion | 2049970f458d48b5359562ebaf61bc794268a014 | [
"MIT"
] | null | null | null | lib/XLQSKit.framework/Headers/NSMutableArray+LQS.h | yococoxc/TicketUnion | 2049970f458d48b5359562ebaf61bc794268a014 | [
"MIT"
] | null | null | null | //
// NSMutableArray+LQS.h
// XLQSKit
//
// Created by muzico on 2020/5/9.
// Copyright © 2020 muzico. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSMutableArray (LQS)
- (void) lqs_addObjectNoNull:(id)anObject;
@end
| 14.705882 | 49 | 0.692 |
1531e1cbe4e87568b79fce860ba804f4996c2f60 | 20,231 | c | C | Software/tests/main.c | jay-hamlin/rpncalculator | 09969f861a7241d3824ec30478070f37ff2fb4d2 | [
"MIT"
] | 1 | 2021-10-02T03:49:32.000Z | 2021-10-02T03:49:32.000Z | Software/tests/main.c | jay-hamlin/rpncalculator | 09969f861a7241d3824ec30478070f37ff2fb4d2 | [
"MIT"
] | null | null | null | Software/tests/main.c | jay-hamlin/rpncalculator | 09969f861a7241d3824ec30478070f37ff2fb4d2 | [
"MIT"
] | null | null | null | //
// main.c
//
//
// Created by Jay Hamlin on 11/22/19.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "calcMaths.h"
#include "calcUtilities.h"
#include "keyFunctions.h"
#include "calculator.h"
#define EDIT_STRING_SIZE 32
#define DISP_STR_LENGTH EDIT_STRING_SIZE
decimal_t registerT;
decimal_t registerZ;
decimal_t registerX;
decimal_t registerY;
char dispEditString[EDIT_STRING_SIZE];
display_t display;
// pi = 3.14159265358979323846264338327950288419716939937510
const decimal_t pi = {
0,0,
{0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93}
};
// Euler's number e = 2.71828182845904523536028747135266249775724709369995
const decimal_t e = {
0,0,
{0x27, 0x18, 0x28, 0x45, 0x90, 0x45, 0x23, 0x53}
};
void TestMultiplying(char *x,char *y);
void TestDividing(char *x,char *y);
void TestAdding(char *x,char *y,int16_t doadd);
void TestNibbleShifting(int16_t shift);
void DecimalNumberFromString(decimal_t *dec,char *str);
void DecimalNumberToString(char *str,decimal_t *dec);
int main( int argc, char *argv[] ) {
int val;
decimal_t regX,regY,regZ,regT;
char xStr[48];
char yStr[48];
char tStr[48];
display.radix=RADIX_DECIMAL;
display.format = DISP_FORMAT_FIXED;
display.points = 16;
if(argc>2)
DecimalNumberFromString(®X,argv[2]);
if(argc>3)
DecimalNumberFromString(®Y,argv[3]);
DecimalNumberFromString(®T,"0.00");
// PrintDecimal_tDebug("X",®X);
// PrintDecimal_tDebug("Y",®Y);
// argc is one more than the number of arguments.
if(strcmp(argv[1],"pi")==0){
memcpy(®X,(decimal_t*)&pi,sizeof(decimal_t));
memcpy(®Y,(decimal_t*)&e,sizeof(decimal_t));
DecimalNumberToString(xStr,®X);
DecimalNumberToString(yStr,®Y);
printf("pi=%s,e=%s\r\n",xStr,yStr);
CalcAdd(®T,®X,®Y);
} else if(strcmp(argv[1],"add")==0){
CalcAdd(®T,®X,®Y);
} else if(strcmp(argv[1],"sub")==0){
CalcSubtract(®T,®X,®Y);
} else if(strcmp(argv[1],"mul")==0){
CalcMultiply(®T,®X,®Y);
} else if(strcmp(argv[1],"div")==0){
CalcDivide(®T,®X,®Y);
} else if(strcmp(argv[1],"sft")==0){
val = strtol(argv[3], NULL, 10);
ShiftSigNibbles(regX.sig,val,16);
} else if(strcmp(argv[1],"mod")==0){
CalcModulo(®T,®X,®Y);
} else {
printf("unknown argument %s\r\n",argv[1]);
}
// PrintDecimal_tDebug("T",®T);
DecimalNumberToString(xStr,®X);
DecimalNumberToString(yStr,®Y);
DecimalNumberToString(tStr,®T);
printf("%s,%s,%s,%s\r\n",argv[1],xStr,yStr,tStr);
}
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
* DecimalNumberFromString - Parses a string for the decimal_t number.
* INPUT: *dec = pointer to the results decimal_t
* *str = input string
* OUTPUT: none
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
void DecimalNumberFromString(decimal_t *dec,char *str)
{
uint8_t sig_temp[BCD_DIGIT_BYTES];
int16_t i;
int16_t strLen=strlen(str);
int16_t digitCount,firstNonZeroIndex,dpIndex,sig_index;
int16_t foundExponent;
int16_t foundExponentValue;
int16_t calculatedExp;
int8_t num;
dec->sign =0;
calculatedExp=0;
foundExponent=0;
foundExponentValue=0;
firstNonZeroIndex=-1;
dpIndex=-1;
digitCount=0;
memset(sig_temp,0,BCD_DIGIT_BYTES);
sig_index =0;
// parse and validate the string
i=0;
while((i<strLen)&&(sig_index<BCD_DIGIT_COUNT)){
if(str[i]=='-'){
if(foundExponent){
foundExponent=-1;
} else {
dec->sign = DECIMAL_SIGN_NEGATIVE; // minus
}
}else if(str[i]=='.') { // decimal point
if(dpIndex == -1){
dpIndex=i;// dp
}
}else if(str[i]=='E'){ // exponent
foundExponent = 1;
}
else if((str[i]>='0')&&(str[i]<='9')) { // number
num = str[i]-'0';
if(foundExponent){
foundExponentValue*=10;
foundExponentValue+=(num);
} else {
// first, we need to skip over leading zeros
if(firstNonZeroIndex == -1){
if(num>0){ // zero after the dp are significant
firstNonZeroIndex=i;
digitCount++;
SetBCDNibble(sig_temp,num,sig_index++);// store then next nibble
}
} else {
digitCount++;
SetBCDNibble(sig_temp,num,sig_index++);// store then next nibble
}
}
}
i++;
}
// if there was a minus sign our indexes are wrong
if(dec->sign == DECIMAL_SIGN_NEGATIVE){
if(firstNonZeroIndex != -1)
firstNonZeroIndex--;
if(dpIndex != -1)
dpIndex--;
}
if(dpIndex == -1){ // then there was no dp
calculatedExp = digitCount-1;
} else {
if(dpIndex>firstNonZeroIndex){ // dp is after the first digit
// ie: 3.14159
calculatedExp = (dpIndex-firstNonZeroIndex-1);
} else{ // dp is before the first digit
// ie: 0.0314159 exp=-2
calculatedExp = (dpIndex-firstNonZeroIndex);
}
}
if(foundExponent){
if(foundExponent==-1){
foundExponentValue = -1*foundExponentValue;
}
calculatedExp = (calculatedExp+foundExponentValue);
}
dec->exp = calculatedExp;
memcpy(dec->sig,sig_temp, BCD_DIGIT_BYTES);
}
#if 1
void NumberToStringBIN(char *str,decimal_t *dec);
void NumberToStringOCT(char *str,decimal_t *dec);
void NumberToStringDEC_FIXED(char *str,decimal_t *dec);
void NumberToStringDEC_SCI(char *str,decimal_t *dec);
void NumberToStringHEX(char *str,decimal_t *dec);
void MakeOctalTriple(char *str,uint8_t bin);
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
* DecimalNumberToString - Converts a decimat_t number to an ascii string
* INPUT: str = results string pointer for the representation of the input decimal_t
* *dec = pointer to the decimal_t input
* radix = formatting radix.
* OUTPUT: none
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
void DecimalNumberToString(char *str,decimal_t *dec)
{
uint8_t digits;
if(dec->sign==(int8_t)NOT_A_NUMBER){
sprintf(str,"NOT A NUMBER");
}else {
switch(display.radix){
case RADIX_BINARY:
NumberToStringBIN(str,dec);
break;
case RADIX_OCTAL:
NumberToStringOCT(str,dec);
break;
case RADIX_DECIMAL:
if(display.format == DISP_FORMAT_FIXED){
// Will this number fit into the 12 digit display?
// if not we need to switch to SCI or ENG mode
// -3.14E1 == -31.40
digits = 1 + 1 + 1 + dec->exp + display.points;
if(digits>=24){
NumberToStringDEC_SCI(str,dec);
}else{
NumberToStringDEC_FIXED(str,dec);
}
}
break;
case RADIX_HEXADECIMAL:
NumberToStringHEX(str,dec);
break;
default:
printf("Unknown display radix\r\n");
break;
}
}
}
void NumberToStringBIN(char *str,decimal_t *dec)
{
sprintf(str,"BIN unimplemented");
}
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
* NumberToStringOCT - Formats a decimat_t into a octal string for display
* Integer only, factions are truncated.
* 32 bit word maximum.
*
* INPUT: display string pointer and decimal_t pointer
* OUTPUT: none
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
void NumberToStringOCT(char *str,decimal_t *dec)
{
char tstr[DISP_STR_LENGTH];
int16_t i,digitIndex;
int16_t strIndex;
int16_t binWord;
binWord=0; // sum is zero
memset(tstr,0,DISP_STR_LENGTH);
strIndex= 0; // zero string length
// The first thing we do is figure out the binary value we want to display.
// get a pointer to the least significant integer digit
digitIndex = dec->exp; // yep, easy
if(digitIndex>16){
sprintf(tstr," Too large ");
} else if(digitIndex<0){
sprintf(tstr," Too small ");
} else {
// Insert the leading negative sign if there is one.
if(dec->sign == DECIMAL_SIGN_NEGATIVE){
tstr[strIndex++]='-'; // negative
}
digitIndex++;
i=0;
while(i<digitIndex){
binWord *= 10;
binWord += GetBCDNibble(dec->sig,i);
i++;
}
// assume a 16 bit word
// 32 bits o 377 377 377
// 16 bits OCT 377 377
// 'cause that's all we can fit in the display
tstr[strIndex++]='O'; // start with "OCT"
tstr[strIndex++]='C';
tstr[strIndex++]='T';
tstr[strIndex++]=' ';
MakeOctalTriple(&tstr[strIndex],(binWord&0x00FF));
strIndex+=3;
binWord>>=8;
tstr[strIndex++]=' ';
MakeOctalTriple(&tstr[strIndex],(binWord&0x00FF));
strIndex+=3;
}
tstr[strIndex++]=' ';
tstr[strIndex] = 0; // END
// copy it out.
strIndex++; //so we copy the null too
memcpy(str,tstr,strIndex);
}
void MakeOctalTriple(char *str,uint8_t bin)
{
uint8_t b2=bin;
str[2] = (b2&0x07)+'0';
b2>>=3;
str[1] = (b2&0x07)+'0';
b2>>=3;
str[0] = (b2&0x03)+'0';
}
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
* NumberToStringDEC_FIXED - Formats a decimat_t into a string for display
* on the calculator in fixed point notation.
*
* INPUT: display string pointer and decimal_t pointer
* OUTPUT: none
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
void NumberToStringDEC_FIXED(char *str,decimal_t *dec)
{
char tstr[DISP_STR_LENGTH];
uint8_t ch;
int16_t sig_index;
int16_t strIndex;
int16_t firstDigitIndex,dpIndex,chopIndex;
/* display.format can be one of:
DISP_FORMAT_FIXED
DISP_FORMAT_SCI
DISP_FORMAT_ENG
*/
memset(tstr,0,DISP_STR_LENGTH);
strIndex= 0; // zero string length
dpIndex = 0; // dp at zero is not valid because such a string would be "0.123" making dpIndex=1
// Insert the leading negative sign if there is one.
if(dec->sign == DECIMAL_SIGN_NEGATIVE){
tstr[strIndex++]='-'; // negative
strIndex=1;
}
// what about the decimal point? Do we have to pad the string with leading zeros?
if(dec->exp<0){
tstr[strIndex++] = '0';
dpIndex = strIndex;
tstr[strIndex++] = '.';
} else {
dpIndex=(strIndex+dec->exp+1);
}
// dpIndex points to the decimal point.
// we are doing fixed point... so where is the first non-zero digit?
if(dec->exp<0){
firstDigitIndex = dpIndex - dec->exp;
} else {
firstDigitIndex = strIndex;
}
// if we aren't there yet we have to pad with zeros.
while((strIndex<firstDigitIndex)&&(strIndex<DISP_STR_LENGTH)){
tstr[strIndex++] = '0';
}
// so we build up the string one nibble at a time
sig_index=0;
while((sig_index<BCD_DIGIT_COUNT)&&(strIndex<DISP_STR_LENGTH)){
if(strIndex==dpIndex){
tstr[strIndex++] = '.'; // insert dp
} else {
ch=GetBCDNibble(dec->sig,sig_index);
tstr[strIndex++] = ch+'0'; // convert BCD to ascii
sig_index++;
}
}
#if 0
if((strIndex == dpIndex)&&(strIndex<DISP_STR_LENGTH)){ // we still need to add dp
tstr[strIndex++] = '.';
}
// fill to the end with zeros
while(strIndex<DISP_STR_LENGTH){
tstr[strIndex++] = '0';
}
// now we chop off so many places after the dp and fill the string with spaces.
chopIndex = dpIndex+display.points;
dpIndex++;
while(dpIndex<DISP_STR_LENGTH){
if(chopIndex<dpIndex)
tstr[dpIndex] = ' ';
dpIndex++;
}
#endif
tstr[strIndex] = 0; // END
// copy it out.
strIndex++; //so we copy the null too
memcpy(str,tstr,strIndex);
}
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
* NumberToStringDEC_SCI - Formats a decimat_t into a string for display
* on the calculator in scientific notation.
*
* INPUT: display string pointer and decimal_t pointer
* OUTPUT: none
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
void NumberToStringDEC_SCI(char *str,decimal_t *dec)
{
char tstr[DISP_STR_LENGTH];
int16_t workingDigit,stopHere;
int16_t strIndex;
int16_t i,reserve, exponent;
/* display.format can be one of:
DISP_FORMAT_FIXED
DISP_FORMAT_SCI
DISP_FORMAT_ENG
*/
memset(tstr,0,DISP_STR_LENGTH);
strIndex= 0; // zero string length
workingDigit = 0; // which sig digit wwe are working on
// Insert the leading negative sign if there is one.
if(dec->sign == DECIMAL_SIGN_NEGATIVE){
tstr[strIndex++]='-'; // negative
}
// for SCI notation there is always 1 significant digit then the dp.
tstr[strIndex++] = GetBCDNibble(dec->sig,workingDigit++)+'0';
tstr[strIndex++] = '.';
// how many digits do we need to reserve for the exponent?
reserve = 1; // 'E'
exponent = dec->exp;
if(exponent<0) // negative
exponent = 0-exponent; // change sign
do{ // count the number of exponent digits.
reserve++;
exponent /= 10; // div 10;
} while(exponent);
// add digits until we get to the number of places or end of string.
stopHere = DISP_STR_LENGTH - reserve;
if(stopHere > (strIndex+display.points))
stopHere = strIndex+display.points;
if(stopHere>15)
stopHere=15;
while(strIndex<stopHere){
tstr[strIndex++] = GetBCDNibble(dec->sig,workingDigit++)+'0';
}
// Now the exponent
tstr[strIndex++] = 'E';
exponent = dec->exp;
if(exponent<0) { // negative
tstr[strIndex++] = '-';
exponent = 0-exponent; // change sign
}
reserve--;
i= strIndex+reserve-1;
while(reserve){
tstr[i--] = (exponent%10)+'0';
exponent /= 10;
reserve--;
strIndex++;
}
tstr[strIndex] = 0; // END
// copy it out.
strIndex++; //so we copy the null too
memcpy(str,tstr,strIndex);
}
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
* NumberToStringHEX - Formats a decimat_t into a hexadecimal string for display
* Integer only, factions are truncated.
* 32 bit word maximum.
*
* INPUT: display string pointer and decimal_t pointer
* OUTPUT: none
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
void NumberToStringHEX(char *str,decimal_t *dec)
{
char tstr[DISP_STR_LENGTH];
uint8_t ch;
int16_t i,digitIndex;
int16_t strIndex;
int32_t binWord;
binWord=0; // sum is zero
memset(tstr,0,DISP_STR_LENGTH);
strIndex= 0; // zero string length
// The first thing we do is figure out the binary value we want to display.
// get a pointer to the least significant integer digit
digitIndex = dec->exp; // yep, easy
if(digitIndex>16){
sprintf(tstr," Too large ");
} else if(digitIndex<0){
sprintf(tstr," Too small ");
} else {
// Insert the leading negative sign if there is one.
if(dec->sign == DECIMAL_SIGN_NEGATIVE){
tstr[strIndex++]='-'; // negative
}
digitIndex++;
i=0;
while(i<digitIndex){
// printf("i=%d, binword=0x%.8x\r\n",i,binWord);
binWord *= 10;
binWord += GetBCDNibble(dec->sig,i);
i++;
}
// assume a full 32 bit word
tstr[strIndex++]='0'; // why not start with "0x"
tstr[strIndex++]='x';
i=strIndex+8;
while(i>strIndex){
i--;
ch = (binWord&0x0000000F);
if(ch<10)
ch = (ch+'0');
else
ch = (ch + 'A' - 10);
tstr[i]=ch;
binWord>>=4;
}
strIndex+=8;
}
tstr[strIndex] = 0; // END
// copy it out.
strIndex++; //so we copy the null too
memcpy(str,tstr,strIndex);
}
#else
void DecimalNumberToString(char *str,int16_t strLength,decimal_t *dec,char radix)
{
char tstr[64];
uint8_t ch;
int16_t sig_index;
int16_t strIndex,places;
int16_t firstDigitIndex,dpIndex,chopIndex;
/* display.format can be one of:
DISP_FORMAT_FIXED
DISP_FORMAT_SCI
DISP_FORMAT_ENG
*/
memset(tstr,0,strLength+1);
strIndex= 0; // zero string length
dpIndex = 0; // dp at zero is not valid because such a string would be "0.123" making dpIndex=1
// Insert the leading negative sign if there is one.
if(dec->sign == DECIMAL_SIGN_NEGATIVE){
tstr[strIndex++]='-'; // negative
strIndex=1;
}
// what about the decimal point? Do we have to pad the string with leading zeros?
if(dec->exp<0){
tstr[strIndex++] = '0';
dpIndex = strIndex;
tstr[strIndex++] = '.';
} else {
dpIndex=(strIndex+dec->exp+1);
}
// dpIndex points to the decimal point.
// we are doing fixed point... so where is the first non-zero digit?
if(dec->exp<0){
firstDigitIndex = dpIndex - dec->exp;
} else {
firstDigitIndex = strIndex;
}
// if we aren't there yet we have to pad with zeros.
while((strIndex<firstDigitIndex)&&(strIndex<strLength)){
tstr[strIndex++] = '0';
}
// so we build up the string one nibble at a time
sig_index=0;
while((sig_index<BCD_DIGIT_COUNT)&&(strIndex<strLength)){
if(strIndex==dpIndex){
tstr[strIndex++] = '.'; // insert dp
} else {
ch=GetBCDNibble(dec->sig,sig_index);
tstr[strIndex++] = ch+'0'; // convert BCD to ascii
sig_index++;
}
}
#if 0
if((strIndex == dpIndex)&&(strIndex<strLength)){ // we still need to add dp
tstr[strIndex++] = '.';
}
// fill to the end with zeros
while(strIndex<strLength){
tstr[strIndex++] = '0';
}
// now we chop off so many places after the dp and fill the string with spaces.
places = 16;
chopIndex = dpIndex+places;
dpIndex++;
while(dpIndex<strLength){
if(chopIndex<dpIndex)
tstr[dpIndex] = ' ';
dpIndex++;
}
#endif
tstr[strIndex] = 0; // END
// copy it out.
strIndex++; //so we copy the null too
memcpy(str,tstr,strIndex);
}
#endif
| 30.150522 | 116 | 0.524937 |
153357660212011b6e3b7729cd907f034ea45e08 | 1,096 | h | C | tests/src/ProcessTests/ChildProcessBuilderTests.h | codesmithyide/Process | a4b037803737a60bbb9568db61967ffd18ba8818 | [
"MIT"
] | null | null | null | tests/src/ProcessTests/ChildProcessBuilderTests.h | codesmithyide/Process | a4b037803737a60bbb9568db61967ffd18ba8818 | [
"MIT"
] | null | null | null | tests/src/ProcessTests/ChildProcessBuilderTests.h | codesmithyide/Process | a4b037803737a60bbb9568db61967ffd18ba8818 | [
"MIT"
] | null | null | null | /*
Copyright (c) 2016-2020 Xavier Leclercq
Released under the MIT License
See https://github.com/Ishiko-cpp/Process/blob/master/LICENSE.txt
*/
#ifndef _ISHIKO_TEST_PROCESS_PROCESSTESTS_CHILDPROCESSBUILDERTESTS_H_
#define _ISHIKO_TEST_PROCESS_PROCESSTESTS_CHILDPROCESSBUILDERTESTS_H_
#include "Ishiko/TestFramework/TestFrameworkCore.h"
class ChildProcessBuilderTests : public Ishiko::Tests::TestSequence
{
public:
ChildProcessBuilderTests(const Ishiko::Tests::TestNumber& number, const Ishiko::Tests::TestEnvironment& environment);
private:
static void ConstructorTest1(Ishiko::Tests::Test& test);
static void StartTest1(Ishiko::Tests::Test& test);
static void StartTest2(Ishiko::Tests::Test& test);
static void StartTest3(Ishiko::Tests::Test& test);
static void RedirectStandardOutputToFileTest1(Ishiko::Tests::FileComparisonTest& test);
static void StartTest4(Ishiko::Tests::FileComparisonTest& test);
static void StartTest5(Ishiko::Tests::FileComparisonTest& test);
static void StartTest6(Ishiko::Tests::FileComparisonTest& test);
};
#endif
| 37.793103 | 121 | 0.784672 |
15339791fa6466e6081758dd438f9b4cd87a6fe4 | 244 | h | C | lib/Data Structs/LineData.h | henrybatt/Morph-2019 | 48c75c784435630e76ae0b331f140143432264b6 | [
"MIT"
] | null | null | null | lib/Data Structs/LineData.h | henrybatt/Morph-2019 | 48c75c784435630e76ae0b331f140143432264b6 | [
"MIT"
] | null | null | null | lib/Data Structs/LineData.h | henrybatt/Morph-2019 | 48c75c784435630e76ae0b331f140143432264b6 | [
"MIT"
] | null | null | null | #ifndef LINEDATA_H
#define LINEDATA_H
struct LineData {
double angle;
double size;
bool onField;
LineData() {}
LineData(double a, double s, bool o) : angle(a), size(s), onField(o) {}
};
extern LineData lineInfo;
#endif | 14.352941 | 75 | 0.651639 |
1538716019240c6989525fdb0f8a41b2406856ec | 798 | h | C | StoChemSimSequential/common/inputVerifier.h | jaxondl/StoChemSim | 6efb890620c4029727e00101a58e8ab3bf00ebdf | [
"MIT"
] | null | null | null | StoChemSimSequential/common/inputVerifier.h | jaxondl/StoChemSim | 6efb890620c4029727e00101a58e8ab3bf00ebdf | [
"MIT"
] | null | null | null | StoChemSimSequential/common/inputVerifier.h | jaxondl/StoChemSim | 6efb890620c4029727e00101a58e8ab3bf00ebdf | [
"MIT"
] | null | null | null | #ifndef INPUTVERIFIER_H
#define INPUTVERIFIER_H
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
class inputVerifier {
public:
bool verifyFile(string iFile);
string chopOffComments(string line);
bool checkReactionSlice(string reactionSlice, int lineNumber, bool errorExists, bool alreadyWarned);
bool containsNonDigitNonDecimal(string reactionSlice);
bool isReactionRate(string reactionSlice);
bool isValidReactionRate(string reactionSlice, int lineNumber);
bool checkReactantsOrProducts(string reactionDefLine, int lineNumber, bool errorExists);
bool checkSingleMolecule(string molNumAndName, int lineNumber, bool errorExists);
int checkReactionDefLine(ifstream inputFile, string reactionDefLine);
};
#endif //INPUTVERIFIER_H
| 30.692308 | 104 | 0.796992 |
153b67351052ed3f7f86f95a72fdf952a6b9f757 | 734 | h | C | src/backend/backend.h | pfaco/guicpp | 7eb230757f33ff74d61f01d1af26199061c65115 | [
"MIT"
] | null | null | null | src/backend/backend.h | pfaco/guicpp | 7eb230757f33ff74d61f01d1af26199061c65115 | [
"MIT"
] | null | null | null | src/backend/backend.h | pfaco/guicpp | 7eb230757f33ff74d61f01d1af26199061c65115 | [
"MIT"
] | null | null | null | #pragma once
#include <memory>
namespace guicpp
{
struct BackendContext {
void *window;
};
struct BackendTexture {
unsigned int id;
};
auto backend_init(int width, int height, const char *title, const uint8_t *font_data = nullptr, size_t font_data_size = 0, float font_size = 13.0) -> BackendContext;
bool backend_should_close(BackendContext ctx);
void backend_set_frame(BackendContext ctx);
void backend_render(BackendContext ctx);
void backend_teardown(BackendContext ctx);
auto backend_load_texture(const char *path, int *width, int *height) -> BackendTexture;
auto backend_load_texture(const uint8_t *data, size_t size, int *width, int *height) -> BackendTexture;
}
| 31.913043 | 169 | 0.719346 |
153c3d41f0479d8bffd1e10d1cc0dcfd068c9553 | 278 | h | C | Stealth/String.h | doodlemeat/Terminal | ca0bf1f29a85f2b46b8b153e76bf4f4d8a36e0d5 | [
"MIT"
] | null | null | null | Stealth/String.h | doodlemeat/Terminal | ca0bf1f29a85f2b46b8b153e76bf4f4d8a36e0d5 | [
"MIT"
] | null | null | null | Stealth/String.h | doodlemeat/Terminal | ca0bf1f29a85f2b46b8b153e76bf4f4d8a36e0d5 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include <string>
namespace sf
{
class String;
}
namespace String
{
std::vector<sf::String> explode(sf::String str, sf::String delim);
std::vector<std::string> explode(std::string str, std::string delim);
int to_int();
float to_float();
} | 15.444444 | 70 | 0.697842 |
d172047f55773ac25da1e30236f462a9bbad7cf2 | 2,593 | c | C | crypto/bio/bio_meth.c | akki47/openssl-b | d37b203f513f4fcab63fef330ad3ced7849caead | [
"OpenSSL"
] | 2 | 2017-04-11T16:36:09.000Z | 2021-07-26T16:04:02.000Z | crypto/bio/bio_meth.c | akki47/openssl-b | d37b203f513f4fcab63fef330ad3ced7849caead | [
"OpenSSL"
] | null | null | null | crypto/bio/bio_meth.c | akki47/openssl-b | d37b203f513f4fcab63fef330ad3ced7849caead | [
"OpenSSL"
] | 1 | 2019-10-19T10:39:30.000Z | 2019-10-19T10:39:30.000Z | /*
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include "bio_lcl.h"
BIO_METHOD *BIO_meth_new(int type, const char *name)
{
BIO_METHOD *biom = OPENSSL_zalloc(sizeof(BIO_METHOD));
if (biom != NULL) {
biom->type = type;
biom->name = name;
}
return biom;
}
void BIO_meth_free(BIO_METHOD *biom)
{
OPENSSL_free(biom);
}
int (*BIO_meth_get_write(BIO_METHOD *biom)) (BIO *, const char *, int)
{
return biom->bwrite;
}
int BIO_meth_set_write(BIO_METHOD *biom,
int (*bwrite) (BIO *, const char *, int))
{
biom->bwrite = bwrite;
return 1;
}
int (*BIO_meth_get_read(BIO_METHOD *biom)) (BIO *, char *, int)
{
return biom->bread;
}
int BIO_meth_set_read(BIO_METHOD *biom,
int (*bread) (BIO *, char *, int))
{
biom->bread = bread;
return 1;
}
int (*BIO_meth_get_puts(BIO_METHOD *biom)) (BIO *, const char *)
{
return biom->bputs;
}
int BIO_meth_set_puts(BIO_METHOD *biom,
int (*bputs) (BIO *, const char *))
{
biom->bputs = bputs;
return 1;
}
int (*BIO_meth_get_gets(BIO_METHOD *biom)) (BIO *, char *, int)
{
return biom->bgets;
}
int BIO_meth_set_gets(BIO_METHOD *biom,
int (*bgets) (BIO *, char *, int))
{
biom->bgets = bgets;
return 1;
}
long (*BIO_meth_get_ctrl(BIO_METHOD *biom)) (BIO *, int, long, void *)
{
return biom->ctrl;
}
int BIO_meth_set_ctrl(BIO_METHOD *biom,
long (*ctrl) (BIO *, int, long, void *))
{
biom->ctrl = ctrl;
return 1;
}
int (*BIO_meth_get_create(BIO_METHOD *biom)) (BIO *)
{
return biom->create;
}
int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *))
{
biom->create = create;
return 1;
}
int (*BIO_meth_get_destroy(BIO_METHOD *biom)) (BIO *)
{
return biom->destroy;
}
int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *))
{
biom->destroy = destroy;
return 1;
}
long (*BIO_meth_get_callback_ctrl(BIO_METHOD *biom)) (BIO *, int, bio_info_cb *)
{
return biom->callback_ctrl;
}
int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
long (*callback_ctrl) (BIO *, int,
bio_info_cb *))
{
biom->callback_ctrl = callback_ctrl;
return 1;
}
| 21.254098 | 80 | 0.607405 |
d17c0c6a62842c2f89d3c0010bc415ed2d2fbab9 | 2,634 | h | C | interface_kit/CDButton/Observer.h | return/BeOSSampleCode | ca5a319fecf425a69e944f3c928a85011563a932 | [
"BSD-3-Clause"
] | 5 | 2018-09-09T21:01:57.000Z | 2022-03-27T10:01:27.000Z | interface_kit/CDButton/Observer.h | return/BeOSSampleCode | ca5a319fecf425a69e944f3c928a85011563a932 | [
"BSD-3-Clause"
] | null | null | null | interface_kit/CDButton/Observer.h | return/BeOSSampleCode | ca5a319fecf425a69e944f3c928a85011563a932 | [
"BSD-3-Clause"
] | 5 | 2018-04-03T01:45:23.000Z | 2021-05-14T08:23:01.000Z | /*
Copyright 1999, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
*/
// This defines the Observer and Notifier classes
// The idea of observing is make it easier to support a client-server
// setup where a client want's to react to changes in the server state,
// for instance a view displaying a track number needs to change whenever
// a track changes. Normally this is done by the client periodically checking
// the server from within a Pulse call or a simillar mechanism. With Observer
// and Notifier, the Observer (client) starts observing a Notifier (server)
// and then just sits back and wait to get a notice, whenever the Notifier
// changes.
#ifndef __OBSERVER__
#define __OBSERVER__
#include "TypedList.h"
#include <Handler.h>
const uint32 kNoticeChange = 'notc';
const uint32 kStartObserving = 'stob';
const uint32 kEndObserving = 'edob';
class Notifier;
class NotifierListEntry {
public:
Notifier *observed;
BHandler *handler;
BLooper *looper;
};
class Observer {
public:
Observer(Notifier *target = NULL);
virtual ~Observer();
void StartObserving(Notifier *);
// start observing a speficied notifier
void StopObserving(Notifier *);
// stop observing a speficied notifier
void StopObserving();
// stop observing all the observed notifiers
virtual void NoticeChange(Notifier *) = 0;
// override this to get your job done, your class will get called
// whenever the Notifier changes
static bool HandleObservingMessages(const BMessage *message);
// call this from subclasses MessageReceived
virtual BHandler *RecipientHandler() const = 0;
// hook this up to return subclasses looper
private:
void SendStopObserving(NotifierListEntry *);
// keep a list of all the observed notifiers
TypedList<NotifierListEntry *> observedList;
friend NotifierListEntry *StopObservingOne(NotifierListEntry *, void *);
};
class ObserverListEntry {
public:
Observer *observer;
BHandler *handler;
BLooper *looper;
};
class Notifier {
public:
Notifier()
{}
virtual ~Notifier()
{}
virtual void Notify();
// call this when the notifier object changes to send notices
// to all the observers
static bool HandleObservingMessages(const BMessage *message);
// call this from subclasses MessageReceived
virtual BHandler *RecipientHandler() const = 0;
// hook this up to return subclasses looper
// keep a list of all the observers so that we can send them notices
void AddObserver(Observer *);
void RemoveObserver(Observer *);
private:
TypedList<ObserverListEntry *> observerList;
friend class Observer;
};
#endif | 26.877551 | 77 | 0.755505 |
d17d10c17244795e138b311ffb8f88462b99c9a9 | 1,025 | c | C | src/ft_isascii.c | almayor/libft | 4ec1ef0d262d1e4cdbca62c1e02cd4fd5cc6628e | [
"MIT"
] | null | null | null | src/ft_isascii.c | almayor/libft | 4ec1ef0d262d1e4cdbca62c1e02cd4fd5cc6628e | [
"MIT"
] | null | null | null | src/ft_isascii.c | almayor/libft | 4ec1ef0d262d1e4cdbca62c1e02cd4fd5cc6628e | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: unite <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/05 00:17:51 by unite #+# #+# */
/* Updated: 2020/07/16 03:05:00 by unite ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** Replicates behaviour of `isascii` from `libc`.
*/
int ft_isascii(int c)
{
return (c >= 0 && c <= 127);
}
| 44.565217 | 80 | 0.16 |
d17eaeee7ff4f6a36ecbb4a794c162f28a9f70e9 | 816 | h | C | include/UI/ModelProperty.h | maifeeulasad/AshEngine | bb567a4e3543cb32332681f5f12e491b90aa6ebb | [
"MIT"
] | null | null | null | include/UI/ModelProperty.h | maifeeulasad/AshEngine | bb567a4e3543cb32332681f5f12e491b90aa6ebb | [
"MIT"
] | 1 | 2021-02-13T07:56:53.000Z | 2021-02-13T07:58:11.000Z | include/UI/ModelProperty.h | maifeeulasad/AshEngine | bb567a4e3543cb32332681f5f12e491b90aa6ebb | [
"MIT"
] | null | null | null | #pragma once
#include <Model.h>
#include <Vector3DEditSlider.h>
class ModelProperty: public QWidget {
Q_OBJECT
public:
ModelProperty(Model * model, QWidget * parent = 0);
private:
Model *m_host;
QCheckBox *m_visibleCheckBox, *m_wireFrameModeCheckBox;
QLabel *m_numOfChildMeshesTextLabel, *m_numOfChildMeshesValueLabel;
QLabel *m_numOfChildModelsTextLabel, *m_numOfChildModelsValueLabel;
Vector3DEdit *m_positionEdit, *m_scalingEdit;
Vector3DEditSlider *m_rotationEditSlider;
void configLayout();
void configSignals();
private slots:
void hostDestroyed(QObject* host);
void childMeshAdded(Mesh* mesh);
void childMeshRemoved(QObject* object);
void childModelAdded(Model* model);
void childModelRemoved(QObject* object);
};
| 27.2 | 72 | 0.72549 |
d1837e22ad8bfff445f092eeb71da4a5a9485264 | 1,458 | h | C | Finance/Macro/Global.h | JoyShare2017/Finance | a6931230c7848a52a8f0a622ca3bd1a7d4a98af1 | [
"MIT"
] | null | null | null | Finance/Macro/Global.h | JoyShare2017/Finance | a6931230c7848a52a8f0a622ca3bd1a7d4a98af1 | [
"MIT"
] | null | null | null | Finance/Macro/Global.h | JoyShare2017/Finance | a6931230c7848a52a8f0a622ca3bd1a7d4a98af1 | [
"MIT"
] | null | null | null | //
// Global.h
// CommonProject
//
// Created by 郝旭珊 on 2017/12/19.
// Copyright © 2017年 郝旭珊. All rights reserved.
//
#ifndef Global_h
#define Global_h
#ifdef DEBUG
#define DebugLog(...) NSLog(@"-------%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define DebugLog(...)
#endif
//#define OPENAPIHOST @"http://192.168.2.250:8012/" //本地地址
#define OPENAPIHOST @"http://caisou.emof.net/" //线上地址
#define USERDEFAULTS [NSUserDefaults standardUserDefaults]
#define KEY_EXPERT_INDUSTRY @"expertIndustryKey" //行业
#define KEY_EXPERT_QUALIFIED @"expertQualifiedKey" //资质
#define KEY_EXPERT_SKILLED @"expertSkilledKey" //擅长领域
/// 友盟 appkey
#define KUMeng_APPID @"5ad58c96f43e484c9c000270"
/// QQ分享
#define KQQLOGIN_APPID @"101470265"
#define KQQLOGIN_APPKEY @"585c6148875db4892f7ca20b7c6a1885"
/// 微信
#define KWEICHAT_APPID @"wx8d9ac9748812ef16"
#define KWEICHAT_SECRET @"5938ef5e29efb33abb6324d05adc8eba"
/// 微博
#define KWEIBOLOGIN_APPID @"2496248294"
#define KWEIBOLOGIN_APPSECRET @"4b147fd49ecf3352b96fa8a58be1e6e4"
//软件版本
#define KSOFTVERSION [[[NSBundle mainBundle] infoDictionary]objectForKey:@"CFBundleShortVersionString"]
////行业
//#define USERDEFAULT_EXPERT_INDUSTRY @"expertIndustryUserDefault"
////资质
//#define USERDEFAULT_EXPERT_QUALIFIED @"expertQualifiedUserDefault"
////擅长领域
//#define USERDEFAULT_EXPERT_SKILLED @"expertSkilledUserDefault"
#define KPayResultKey @"payresult"
#endif /* Global_h */
| 26.509091 | 114 | 0.764746 |
d185d1d2c474bd944faf0e43f7fac97f7cf728a9 | 495 | h | C | Sources/Batch/Webservices/Query/BAQueryWebserviceClientDelegate.h | BatchLabs/Batch-iOS-SDK | 17644488872e62ff09a9106592aecbf79c04e6e7 | [
"MIT"
] | 10 | 2020-12-03T17:08:02.000Z | 2022-03-16T16:22:45.000Z | Sources/Batch/Webservices/Query/BAQueryWebserviceClientDelegate.h | BatchLabs/Batch-iOS-SDK | 17644488872e62ff09a9106592aecbf79c04e6e7 | [
"MIT"
] | 6 | 2020-10-15T12:56:22.000Z | 2022-02-18T14:12:49.000Z | Sources/Batch/Webservices/Query/BAQueryWebserviceClientDelegate.h | BatchLabs/Batch-iOS-SDK | 17644488872e62ff09a9106592aecbf79c04e6e7 | [
"MIT"
] | 3 | 2020-12-16T16:15:11.000Z | 2021-12-22T15:03:00.000Z | //
// BAQueryWebserviceClientDelegate.h
// Batch
//
// Copyright © Batch.com. All rights reserved.
//
#import <Batch/BAWSResponse.h>
@class BAQueryWebserviceClient;
NS_ASSUME_NONNULL_BEGIN
@protocol BAQueryWebserviceClientDelegate
@required
- (void)webserviceClient:(BAQueryWebserviceClient*)client didFailWithError:(NSError *)error;
- (void)webserviceClient:(BAQueryWebserviceClient*)client didSucceedWithResponses:(NSArray<id<BAWSResponse>> *)responses;
@end
NS_ASSUME_NONNULL_END
| 19.8 | 121 | 0.8 |
d1879675a8c4f2206af64e20bea93f061569f09e | 2,646 | c | C | src/libmmalloc.c | InnovAnon-Inc/MultiMalloc | 03da4f42ce8538f663140db61610d476d39bbdfa | [
"Unlicense"
] | null | null | null | src/libmmalloc.c | InnovAnon-Inc/MultiMalloc | 03da4f42ce8538f663140db61610d476d39bbdfa | [
"Unlicense"
] | null | null | null | src/libmmalloc.c | InnovAnon-Inc/MultiMalloc | 03da4f42ce8538f663140db61610d476d39bbdfa | [
"Unlicense"
] | null | null | null | #if HAVE_CONFIG_H
#include <config.h>
#endif
#define _POSIX_C_SOURCE 200112L
#define __STDC_VERSION__ 200112L
#include <assert.h>
#include <stdlib.h>
#include <mmalloc.h>
__attribute__ ((leaf, nonnull (1, 2), nothrow, warn_unused_result))
int mmalloc_naive (void /*const*/ *restrict dests[],
size_t const eszs[], size_t n) {
size_t i, j;
#pragma GCC ivdep
for (i = 0; i != n; i++) {
dests[i] = (void /*const*/ *restrict) malloc (eszs[i]);
error_check (dests[i] != NULL) {
for (j = 0; j != i; j++) free (dests[j]);
return -1;
}
}
return 0;
}
__attribute__ ((leaf, nonnull (1), nothrow))
void mfree_naive (void /*const*/ *restrict dests[], size_t n) {
size_t i;
#pragma GCC ivdep
for (i = 0; i != n; i++)
free (dests[i]);
}
__attribute__ ((leaf, nonnull (1, 2), nothrow, warn_unused_result))
int mmalloc (void /*const*/ *restrict dests[],
size_t const eszs[], size_t sumsz, size_t n) {
size_t i, cumsum;
char /*const*/ *restrict tmp;
tmp = (char /*const*/ *restrict) malloc (sumsz);
error_check (tmp == NULL) return -1;
for (i = cumsum = 0; i != n; cumsum += eszs[i], i++)
dests[i] = (void /*const*/ *restrict) (tmp + cumsum);
assert (sumsz == cumsum);
return 0;
}
__attribute__ ((leaf, nonnull (1, 2), nothrow, warn_unused_result))
int mmalloc2 (void *restrict *restrict dests[],
size_t const eszs[], size_t sumsz, size_t n) {
size_t i, cumsum;
char /*const*/ *restrict tmp;
tmp = (char /*const*/ *restrict) malloc (sumsz);
error_check (tmp == NULL) return -1;
for (i = cumsum = 0; i != n; cumsum += eszs[i], i++)
*(dests[i]) = (void /*const*/ *restrict) (tmp + cumsum);
assert (sumsz == cumsum);
return 0;
}
__attribute__ ((leaf, nonnull (1), nothrow))
void mfree (void /*const*/ *restrict dests0[]) {
free (*dests0);
}
__attribute__ ((leaf, nonnull (1), nothrow))
void mfree2 (void /*const*/ *restrict dests0) {
free (dests0);
}
__attribute__ ((leaf, nonnull (1), nothrow, pure, warn_unused_result))
size_t sum_size_t (size_t const x[], size_t n) {
size_t i, sum;
for (i = sum = 0; i != n; i++)
sum += x[i];
return sum;
}
__attribute__ ((nonnull (1, 2), nothrow, warn_unused_result))
int ez_mmalloc (void /*const*/ *restrict dests[],
size_t const eszs[], size_t n) {
size_t sumsz = sum_size_t (eszs, n);
return mmalloc (dests, eszs, sumsz, n);
}
__attribute__ ((leaf, nonnull (1, 3, 4), nothrow, warn_unused_result))
int ezmalloc (alloc_t do_alloc, void const *restrict alloc_args,
stdcb_t cb, free_t do_free) {
void *restrict ds = do_alloc (alloc_args);
error_check (ds == NULL) return -1;
error_check (cb (ds) != 0) return -2;
do_free (ds);
return 0;
}
| 25.68932 | 70 | 0.644747 |
d188620cf517f95b07d93c49041642a9ed8d5048 | 635 | c | C | zigzag-conversion.c | copperteal/leetcode-solutions | 7962b30f105b7dc429b115c7b9d1ad981f594530 | [
"MIT"
] | null | null | null | zigzag-conversion.c | copperteal/leetcode-solutions | 7962b30f105b7dc429b115c7b9d1ad981f594530 | [
"MIT"
] | null | null | null | zigzag-conversion.c | copperteal/leetcode-solutions | 7962b30f105b7dc429b115c7b9d1ad981f594530 | [
"MIT"
] | null | null | null | /* 0 ms
* 100.00%
* 5.60%
*/
#include <stdlib.h>
#include <string.h>
/* left step, right step */
char *
convert(char * s, int numRows)
{
if (numRows < 2) {
return s;
}
int L = strlen(s);
char *out = (char *)calloc(L+1, sizeof(char));
int i, j, row, lstep, rstep;
int gap = 2*numRows-2;
i = 0;
for (row = 0; row < numRows; row++) {
j = row;
rstep = 2*row;
lstep = gap - rstep;
while (i < L && j < L) {
if (row != numRows-1) {
out[i++] = s[j];
j += lstep;
}
if (row && i < L && j < L) {
out[i++] = s[j];
j += rstep;
}
}
if (i == L) {
break;
}
}
out[L] = '\0';
return out;
}
| 15.119048 | 47 | 0.469291 |
d189c405c92e719095554ecefc085740819f553c | 862 | c | C | tests/thrdtest.c | chenwei-tw/mapreduce | cbd1a8e01bf28387e63e79bf7c6e33e346f5882b | [
"BSD-2-Clause"
] | null | null | null | tests/thrdtest.c | chenwei-tw/mapreduce | cbd1a8e01bf28387e63e79bf7c6e33e346f5882b | [
"BSD-2-Clause"
] | null | null | null | tests/thrdtest.c | chenwei-tw/mapreduce | cbd1a8e01bf28387e63e79bf7c6e33e346f5882b | [
"BSD-2-Clause"
] | null | null | null | #define THREAD 32
#define QUEUE 256
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include <stdatomic.h>
#include "threadpool.h"
int tasks = 0, done = 0;
void dummy_task(void *arg)
{
usleep(10000);
atomic_fetch_sub(&done, 1);
}
int main(int argc, char **argv)
{
void *pool;
int tmp_done;
assert((pool = tpool_init(THREAD)) != NULL);
fprintf(stderr, "Pool started with %d threads and "
"queue size of %d\n", THREAD, QUEUE);
while(tpool_add_work(pool, &dummy_task, NULL) == 0) {
tasks++;
}
fprintf(stderr, "Added %d tasks\n", tasks);
atomic_store(&tmp_done, done);
while((tasks / 2) > tmp_done) {
usleep(10000);
atomic_store(&tmp_done, done);
}
tpool_destroy(pool, 0);
fprintf(stderr, "Did %d tasks\n", done);
return 0;
}
| 18.73913 | 57 | 0.606729 |
d1921d60dd0da3c0673d58d10639cc79cd64d96c | 3,728 | h | C | firmware/cube/ccube.h | nitacku/LEDcube | 0206c0a58cf57f1c71d7749609791f2f77a5d8c1 | [
"MIT"
] | null | null | null | firmware/cube/ccube.h | nitacku/LEDcube | 0206c0a58cf57f1c71d7749609791f2f77a5d8c1 | [
"MIT"
] | null | null | null | firmware/cube/ccube.h | nitacku/LEDcube | 0206c0a58cf57f1c71d7749609791f2f77a5d8c1 | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2014 nitacku
*
* 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.
*
* @file cube.h
* @summary 8x8x8 Mono-color LED Cube
* @version 1.3
* @author nitacku
* @data 31 March 2014
*/
#ifndef _CUBE_H_
#define _CUBE_H_
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include "voxel.h"
const uint16_t DELAY_CONSTANT_C = 1750;
#if defined(__AVR__)
extern "C" {
void* memcpy_fast(void* dst, const void* src, uint16_t num) __attribute__ ((noinline));
}
#else
#define memcpy_fast memcpy
#endif
class CCube
{
public:
enum class State : uint8_t
{
OFF,
ON,
INV,
};
enum class Polarity : uint8_t
{
POSITIVE,
NEGATIVE,
};
enum class Axis : uint8_t
{
X,
Y,
Z,
};
typedef struct FCdStruct
{
float x;
float y;
float z;
} FCd;
typedef struct VCdStruct
{
uint8_t x;
uint8_t y;
uint8_t z;
} VCd;
//#define type_voxel(x, y, z) (VCd){x, y, z}
//typedef VCd type_voxel;
typedef CVoxel<uint8_t> type_voxel;
typedef FCd type_float_cd;
typedef uint8_t type_cube[8][8];
type_cube cube;
public:
// Defualt constructor
CCube(void);
// Transition Functions
void TransitionShift(const Axis axis, const Polarity polarity, const uint8_t delay);
void TransitionScroll(const Axis axis, const Polarity polarity, const uint8_t delay);
void TransitionPlane(const Axis axis, const Polarity polarity, const State state, const uint8_t delay);
// Translate Functions
void TranslateScroll(const Axis axis, int8_t value);
void TranslateShift(const Axis axis, const int8_t value);
// Draw Functions
void SetVoxel(const type_voxel &voxel, const State state);
void SetLine(type_voxel v0, type_voxel v1, const State state);
void SetPlane(const Axis axis, const uint8_t index, const State state);
//void set_character(const Axis axis, const uint8_t index, const char character);
void SetCube(const uint8_t pattern);
void SetWireframeBox(const type_voxel &v0, const type_voxel &v1, const State state);
void SetCircle(const type_float_cd &fcd, float radius, const State state);
void SetSphere(const type_float_cd &fcd, float radius, const State state);
void SetCuboid(type_voxel v0, type_voxel v1, const State state);
void SetWireframe(const type_voxel &v0, const type_voxel &v1, const State state);
// Utility Functions
State GetVoxel(const type_voxel &voxel);
void Copy(CCube& buffer);
private:
void DelayMS(uint16_t x);
uint8_t CoordinateInRange(const type_voxel &voxel);
void CoordinateOrder(type_voxel &v0, type_voxel &v1);
};
#endif
| 28.458015 | 105 | 0.712983 |
d19278912cd3b9ba696a60478e0e95dd84d1adae | 362 | h | C | FriedText/LMTokenAttachmentCell.h | luckymarmot/FriedText | 7ed7761cb75671cac5f5a5d7edaa134d8052532a | [
"MIT"
] | 25 | 2015-01-03T20:52:53.000Z | 2021-04-12T10:59:55.000Z | FriedText/LMTokenAttachmentCell.h | uchuugaka/FriedText | 7ed7761cb75671cac5f5a5d7edaa134d8052532a | [
"MIT"
] | null | null | null | FriedText/LMTokenAttachmentCell.h | uchuugaka/FriedText | 7ed7761cb75671cac5f5a5d7edaa134d8052532a | [
"MIT"
] | 7 | 2015-03-24T11:56:11.000Z | 2017-09-18T08:17:10.000Z | //
// LMTokenAttachmentCell.h
// LMTextView
//
// Created by Micha Mazaheri on 4/6/13.
// Copyright (c) 2013 Lucky Marmot. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "LMTextAttachmentCell.h"
@interface LMTokenAttachmentCell : NSTextAttachmentCell <LMTextAttachmentCell>
+ (NSTextAttachment*)tokenAttachmentWithString:(NSString*)string;
@end
| 21.294118 | 78 | 0.756906 |
d19644c778f0237ec8aa858d41b13a7be4f83950 | 887 | h | C | cpp/invoice.h | new-zelind/DeviceManager | ab48db63cca03548134a3356cf99d21ecec679b6 | [
"MIT"
] | null | null | null | cpp/invoice.h | new-zelind/DeviceManager | ab48db63cca03548134a3356cf99d21ecec679b6 | [
"MIT"
] | null | null | null | cpp/invoice.h | new-zelind/DeviceManager | ab48db63cca03548134a3356cf99d21ecec679b6 | [
"MIT"
] | null | null | null | //Header file to track an instance of an invoice
#ifndef INVOICE_H
#define INVOICE_H
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
class Invoice{
private:
//Invoice Number
string ID;
//Reason for invoice
string message;
//Affected device
string deviceAssetNum;
//Date issued
string dateIssued;
//Person charged
string recipient;
//Recipient's email
string email;
//Invoice amount
float charge;
//Has the invoice been paid off?
bool isPaid;
public:
//Default constructor
Invoice();
//Constructor to be used
Invoice(string message, string asset, string recipient, string email,
float charge);
//Destructor
~Invoice();
//Check to see if the invoice has been paid off
bool hasBeenPaid();
//Set paid status
void setPaidStatus(bool isPaid);
}
#endif
| 15.293103 | 72 | 0.67531 |
d1967bff4e2a30eb2f6c61f439703d489d36938f | 83 | c | C | musl-1.1.18/src/complex/creal.c | h7ga40/azure_iot_hub | e255088c4b2afe5e86cae820e8e3fb747f28b35b | [
"curl",
"Apache-2.0",
"MIT"
] | null | null | null | musl-1.1.18/src/complex/creal.c | h7ga40/azure_iot_hub | e255088c4b2afe5e86cae820e8e3fb747f28b35b | [
"curl",
"Apache-2.0",
"MIT"
] | null | null | null | musl-1.1.18/src/complex/creal.c | h7ga40/azure_iot_hub | e255088c4b2afe5e86cae820e8e3fb747f28b35b | [
"curl",
"Apache-2.0",
"MIT"
] | 1 | 2019-09-27T10:22:23.000Z | 2019-09-27T10:22:23.000Z | #include <complex.h>
double (creal)(double complex z)
{
return creal(z);
}
| 11.857143 | 33 | 0.626506 |
d196b263a26c50625f7c8260d1be31d789962181 | 88 | h | C | Settings/NUADetailedTextCell.h | Shade-Zepheri/Nougat | 2cb7dd244a1a39918b484a99101808266d366b9d | [
"Apache-2.0"
] | 46 | 2018-02-26T03:01:45.000Z | 2022-02-13T03:37:52.000Z | Settings/NUADetailedTextCell.h | Mighel881/Nougat | ad7d16084c44ddac436861cb8d77525a0a340f80 | [
"Apache-2.0"
] | 12 | 2018-08-09T05:38:00.000Z | 2021-04-11T14:14:31.000Z | Settings/NUADetailedTextCell.h | Mighel881/Nougat | ad7d16084c44ddac436861cb8d77525a0a340f80 | [
"Apache-2.0"
] | 13 | 2018-08-11T06:10:27.000Z | 2021-12-29T08:45:38.000Z | #import <Preferences/PSTableCell.h>
@interface NUADetailedTextCell : PSTableCell
@end
| 14.666667 | 44 | 0.806818 |
d198bd28ffc293d2662d1b5ef6b6dac3c77d2dd2 | 218 | h | C | WeiboDemo/Classes/Main/Controller/MYZTabBarController.h | MA806P/WeiboDemo | b6a03574076bed322662fd17a6a962e18c2673ee | [
"Apache-2.0"
] | 1 | 2016-10-13T13:02:19.000Z | 2016-10-13T13:02:19.000Z | WeiboDemo/Classes/Main/Controller/MYZTabBarController.h | MA806P/WeiboDemo | b6a03574076bed322662fd17a6a962e18c2673ee | [
"Apache-2.0"
] | null | null | null | WeiboDemo/Classes/Main/Controller/MYZTabBarController.h | MA806P/WeiboDemo | b6a03574076bed322662fd17a6a962e18c2673ee | [
"Apache-2.0"
] | null | null | null | //
// MYZTabBarController.h
// WeiboDemo
//
// Created by MA806P on 16/9/25.
// Copyright © 2016年 MA806P. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MYZTabBarController : UITabBarController
@end
| 15.571429 | 51 | 0.706422 |
d198da84a3c5ea70fedf0c03b82669ac1536cc95 | 3,555 | c | C | lean/pkgs/c32sat/src/test/test_logging.c | uw-unsat/exoverifier | da64f040db04614be81d9d465179fa3e0e2cd0c4 | [
"Apache-2.0"
] | 5 | 2021-09-23T16:06:19.000Z | 2022-02-17T18:08:25.000Z | lean/pkgs/c32sat/src/test/test_logging.c | uw-unsat/exoverifier | da64f040db04614be81d9d465179fa3e0e2cd0c4 | [
"Apache-2.0"
] | null | null | null | lean/pkgs/c32sat/src/test/test_logging.c | uw-unsat/exoverifier | da64f040db04614be81d9d465179fa3e0e2cd0c4 | [
"Apache-2.0"
] | 1 | 2021-11-05T23:35:03.000Z | 2021-11-05T23:35:03.000Z | /*
Institute for Formal Models and Verification (FMV),
Johannes Kepler University Linz, Austria
Copyright (c) 2006, Robert Daniel Brummayer
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 FMV 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include "test_logging.h"
#include "file_comparison.h"
static const char *bash_green = "\e[1;32m";
static const char *bash_blue = "\e[1;34m";
static const char *bash_red = "\e[1;31m";
static const char *bash_default = "\e[0;39m";
int g_bash;
int g_num_tests;
int g_outputs_compared;
int g_outputs_failed;
void
init_test_logging (int bash)
{
g_bash = bash;
g_num_tests = 0;
g_outputs_compared = 0;
g_outputs_failed = 0;
}
void
run_test_case (void (*funcp) (), char *name)
{
g_num_tests++;
printf (" Running %s ...", name);
fflush (stdout);
funcp ();
if (g_bash)
{
printf (" %s[ %sOK %s]%s\n", bash_blue, bash_green, bash_blue,
bash_default);
}
else
{
printf (" [ OK ]\n");
}
}
void
check_output (char *expected, char *output)
{
FilesEqualResult eq_result = equal_files (expected, output);
g_outputs_compared++;
printf (" Comparing output ...");
if (eq_result == fer_equal)
{
if (g_bash)
{
printf (" %s[ %sOK %s]%s\n", bash_blue, bash_green, bash_blue,
bash_default);
}
else
{
printf (" [ OK ]\n");
}
}
else
{
g_outputs_failed++;
if (eq_result == fer_not_equal)
{
if (g_bash)
{
printf (" %sFAILED!!!%s\n", bash_red, bash_default);
}
else
{
printf (" FAILED!!!\n");
}
}
else
{
if (g_bash)
{
printf (" %sIO ERROR!!!%s\n", bash_red, bash_default);
}
else
{
printf (" IO ERROR!!!\n");
}
}
}
}
int
get_num_tests ()
{
return g_num_tests;
}
int
get_outputs_compared ()
{
return g_outputs_compared;
}
int
get_outputs_failed ()
{
return g_outputs_failed;
}
| 26.139706 | 79 | 0.643882 |
d198df6c1a8a79b7b6ecff385069160c6c782df0 | 288 | h | C | share/theme.h | pphilippos/Neverball-for-micro-bit | 64e67e2dcc073548e805136995a0e2601285f5cd | [
"RSA-MD"
] | null | null | null | share/theme.h | pphilippos/Neverball-for-micro-bit | 64e67e2dcc073548e805136995a0e2601285f5cd | [
"RSA-MD"
] | null | null | null | share/theme.h | pphilippos/Neverball-for-micro-bit | 64e67e2dcc073548e805136995a0e2601285f5cd | [
"RSA-MD"
] | 1 | 2015-04-28T11:21:31.000Z | 2015-04-28T11:21:31.000Z | #ifndef THEME_H
#define THEME_H
#include "base_config.h"
#include "glext.h"
#define THEME_IMAGES_MAX 4
struct theme
{
GLuint tex[THEME_IMAGES_MAX];
GLfloat t[4];
GLfloat s[4];
};
int theme_load(struct theme *, const char *name);
void theme_free(struct theme *);
#endif
| 13.714286 | 50 | 0.701389 |
d199aa110fee46482d70f16fde2e776a7d943109 | 1,725 | h | C | student-distrib/keyboard.h | Shivam2501/ECE391 | a6414d303b9defc12e36a0aaaeccd40d237817c5 | [
"Apache-2.0"
] | null | null | null | student-distrib/keyboard.h | Shivam2501/ECE391 | a6414d303b9defc12e36a0aaaeccd40d237817c5 | [
"Apache-2.0"
] | null | null | null | student-distrib/keyboard.h | Shivam2501/ECE391 | a6414d303b9defc12e36a0aaaeccd40d237817c5 | [
"Apache-2.0"
] | null | null | null | /* keyboard.h - Defines for keyboard handler
* vim:ts=4 noexpandtab
*/
#define BUFFER_SIZE 0x80
#ifndef _KEYBOARD_H
#define _KEYBOARD_H
#include "types.h"
#include "i8259.h"
#include "lib.h"
#include "test.h"
#include "syscalls.h"
#include "task.h"
#define KEYBOARD_IRQ 0x01
#define KEYBOARD_DATA_PORT 0x60
#define KEYBOARD_STATUS_PORT 0x64
/* Scan code for Keys */
#define CAPS_LOCK_PRESSED 0x3A
#define CAPS_LOCK_RELEASED 0xBA
#define RIGHT_SHIFT_LOCK_PRESSED 0x36
#define RIGHT_SHIFT_LOCK_RELEASED 0xB6
#define LEFT_SHIFT_LOCK_PRESSED 0x2A
#define LEFT_SHIFT_LOCK_RELEASED 0xAA
#define CTRL_LOCK_PRESSED 0x1D
#define CTRL_LOCK_RELEASED 0x9D
#define ALT_LOCK_PRESSED 0x38
#define ALT_LOCK_RELEASED 0xB8
#define KEYCODES_COUNT 0x3D
#define CAPSLOCK_BIT 0x80
#define MAP_SIZE 0x4
#define CAPSLOCK_ON 0x01
#define SHIFT_ON 0x02
#define CTRL_ON 0x04
#define ALT_ON 0x08
#define SCANCODE_L 0x26
#define SCANCODE_C 0x2E
#define SCANCODE_ENTER 0x1C
#define SCANCODE_BACKSPACE 0x0E
#define SCANCODE_F1 0x3B
#define SCANCODE_F2 0x3C
#define SCANCODE_F3 0x3D
/* Initialise the Keyboard */
void keyboard_init();
/* Toogle the Capslock */
void toggle_capslock();
/* Toogle the Shift */
void toggle_shift();
/* Toogle the Ctrl */
void toggle_ctrl();
/*Toggle the Alt */
void toggle_alt();
//buffer to store the keryboard input
extern volatile int ctrl_c_ready;
/* Keyboard Interrupt Handler */
extern void keyboard_handler();
/* Scan the code and Echo the string */
void process_code(uint8_t scancode);
/* Clear the buffer */
void clear_buffer();
void clear_buffer_scheduler();
#endif /* _KEYBOARD_H */
| 19.827586 | 44 | 0.732754 |
d199c9f635cea24bfde1dff69723dd51dc5850f7 | 431 | h | C | ImageAnalysisKit/ImageAnalysisKit.h | rmenke/ImageAnalysisKit | fc3ec39a09033c0486b65c220f97d1f87cf934e3 | [
"MIT"
] | null | null | null | ImageAnalysisKit/ImageAnalysisKit.h | rmenke/ImageAnalysisKit | fc3ec39a09033c0486b65c220f97d1f87cf934e3 | [
"MIT"
] | null | null | null | ImageAnalysisKit/ImageAnalysisKit.h | rmenke/ImageAnalysisKit | fc3ec39a09033c0486b65c220f97d1f87cf934e3 | [
"MIT"
] | null | null | null | //
// ImageAnalysisKit.h
// ImageAnalysisKit
//
// Created by Rob Menke on 4/16/19.
// Copyright © 2019 Rob Menke. All rights reserved.
//
@import Foundation;
//! Project version number for ImageAnalysisKit.
FOUNDATION_EXPORT double ImageAnalysisKitVersionNumber;
//! Project version string for ImageAnalysisKit.
FOUNDATION_EXPORT const unsigned char ImageAnalysisKitVersionString[];
#import <ImageAnalysisKit/IABuffer.h>
| 22.684211 | 70 | 0.777262 |
d19af042377d364981adc392d46c59815eb9c341 | 2,480 | h | C | src/linalg/diagonalize.h | jerinphilip/parallel-svd-ish-stuff | a8e837e2311a3cbb8fc7cdeb2c9ee7045b355856 | [
"MIT"
] | 1 | 2018-04-17T16:10:51.000Z | 2018-04-17T16:10:51.000Z | src/linalg/diagonalize.h | jerinphilip/parallel-svd-ish-stuff | a8e837e2311a3cbb8fc7cdeb2c9ee7045b355856 | [
"MIT"
] | 1 | 2018-04-18T10:26:07.000Z | 2020-12-05T21:26:20.000Z | src/linalg/diagonalize.h | jerinphilip/parallel-svd-ish-stuff | a8e837e2311a3cbb8fc7cdeb2c9ee7045b355856 | [
"MIT"
] | null | null | null | #include "linalg.h"
#include "utils/utils.h"
template <class _Tensor>
std::tuple<_Tensor, _Tensor, _Tensor> diagonalize(_Tensor B) {
_Tensor X_t(B.rows, B.rows);
_Tensor sigma(B.rows, B.cols);
_Tensor Y(B.cols, B.cols);
_Tensor x(0, 0);
_Tensor y(0, 0);
_Tensor G(0, 0);
_Tensor subX_t(0, 0);
_Tensor subB(0, 0);
_Tensor subY(0, 0);
X_t = identity(X_t);
Y = identity(Y);
/* find length of upper diagonal */
int udiag;
if (B.rows < B.cols) {
udiag = B.rows;
} else {
udiag = B.cols-1;
}
int iterations = 0;
while(!B.is_diagonal()) {
/* iterate for each pair of diagonal and upper diagonal elements to
eliminate the upper diagonal element */
for(int i = 0; i < udiag; i++) {
/* slice the row pair to be rotated out of B */
block pair1 = block(i, i+1)(i, i+2);
x = slice(B, pair1);
/* do givens rotation based on x */
G = givens(x.transpose(), i, B.cols);
block rel = block(0, B.rows)(i, i+2);
subB = slice(B, rel);
subB = subB*G.transpose();
set_slice(B, rel, subB);
block rel2 = block(0, Y.rows)(i, i+2);
subY = slice(Y, rel2);
subY = subY*G.transpose();
set_slice(Y, rel2, subY);
/* slice the col pair to be rotated out of B */
block pair2 = block(i, i+2)(i, i+1);
y = slice(B, pair2);
/* do givens rotation based on y */
G = givens(y, i, B.rows);
block rel3 = block(i, i+2)(0, B.cols);
subB = slice(B, rel3);
subB = G*subB;
set_slice(B, rel3, subB);
//std::cout << "B set\n";
block rel4 = block(i, i+2)(0, X_t.cols);
subX_t = slice(X_t, rel4);
subX_t = G*subX_t;
set_slice(X_t, rel4, subX_t);
// std::cout << "X_t set\n";
// B = check_zeros(B);
if(B.is_diagonal()) {
break;
}
}
iterations += 1;
}
std:: cout << iterations << " iterations complete.\n";
sigma = B;
auto products = std::make_tuple(X_t, sigma, Y);
return products;
}
| 28.505747 | 80 | 0.45 |
d19b87ad282df8a74dda9b120a17ec8693b5ff69 | 1,277 | h | C | axle-sysroot/usr/i686-axle/include/drivers/ata/ata_driver_messages.h | codyd51/axle | 2547432215c0e53e25bf47df5c7f9cce4d7ef4cb | [
"MIT"
] | 453 | 2016-07-29T23:26:30.000Z | 2022-02-21T01:09:13.000Z | axle-sysroot/usr/i686-axle/include/drivers/ata/ata_driver_messages.h | codyd51/axle | 2547432215c0e53e25bf47df5c7f9cce4d7ef4cb | [
"MIT"
] | 22 | 2016-07-31T23:24:56.000Z | 2022-01-09T00:15:45.000Z | programs/ata_driver/ata_driver_messages.h | codyd51/axle | 2547432215c0e53e25bf47df5c7f9cce4d7ef4cb | [
"MIT"
] | 57 | 2016-07-29T23:34:09.000Z | 2021-07-13T18:17:02.000Z | #ifndef ATA_DRIVER_MESSAGES_H
#define ATA_DRIVER_MESSAGES_H
#include <stdint.h>
#define ATA_DRIVER_SERVICE_NAME "com.axle.ata"
typedef enum ata_drive {
ATA_DRIVE_MASTER = 0,
ATA_DRIVE_SLAVE = 1
} ata_drive_t;
typedef struct ata_message_base {
uint32_t event;
} ata_message_base_t;
// Sent from clients to the ATA driver
// PT: Chosen to not conflict with file_manager messages
#define ATA_READ_REQUEST 300
typedef struct ata_read_sector_request {
uint32_t event; // ATA_READ_REQUEST
ata_drive_t drive_desc;
uint32_t sector;
} ata_read_sector_request_t;
// Sent from the ATA driver to clients
#define ATA_READ_RESPONSE 300
typedef struct ata_read_sector_response {
uint32_t event; // ATA_READ_RESPONSE
ata_drive_t drive_desc;
uint32_t sector;
uint32_t sector_size;
uint8_t sector_data[];
} ata_read_sector_response_t;
// Sent from clients to the ATA driver
#define ATA_WRITE_REQUEST 301
typedef struct ata_write_sector_request {
uint32_t event; // ATA_WRITE_REQUEST
ata_drive_t drive_desc;
uint32_t sector;
uint8_t sector_data[];
} ata_write_sector_request_t;
typedef union ata_message {
ata_message_base_t base;
ata_read_sector_request_t read;
ata_write_sector_request_t write;
} ata_message_t;
#endif
| 24.557692 | 56 | 0.782302 |
d19d953a4073ad07a787bdd51a1d473c995dbb74 | 547 | h | C | SimpleRoulette/SimpleRoulette.h | fummicc1/SimpleRoulette | 1318054aa2e762b0cf9bbd6711be61436250f280 | [
"MIT"
] | 16 | 2020-06-01T13:31:06.000Z | 2022-03-27T02:13:15.000Z | SimpleRoulette/SimpleRoulette.h | fummicc1/SimpleRoulette | 1318054aa2e762b0cf9bbd6711be61436250f280 | [
"MIT"
] | 14 | 2020-06-02T20:25:19.000Z | 2022-03-27T10:45:16.000Z | SimpleRoulette/SimpleRoulette.h | fummicc1/SimpleRoulette | 1318054aa2e762b0cf9bbd6711be61436250f280 | [
"MIT"
] | 1 | 2021-08-09T22:08:17.000Z | 2021-08-09T22:08:17.000Z | //
// SimpleRoulette.h
// SimpleRoulette
//
// Created by Fumiya Tanaka on 2020/05/29.
// Copyright © 2020 Fumiya Tanaka. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for SimpleRoulette.
FOUNDATION_EXPORT double SimpleRouletteVersionNumber;
//! Project version string for SimpleRoulette.
FOUNDATION_EXPORT const unsigned char SimpleRouletteVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <SimpleRoulette/PublicHeader.h>
| 27.35 | 139 | 0.780622 |
d19fbb919dcf8dfb88e25767bd6ceab900115d7d | 1,194 | h | C | src/type.h | SkyLLine/compiler | 9b0cd988da219f0253b64162a6e823ace2f95ffb | [
"MIT"
] | null | null | null | src/type.h | SkyLLine/compiler | 9b0cd988da219f0253b64162a6e823ace2f95ffb | [
"MIT"
] | null | null | null | src/type.h | SkyLLine/compiler | 9b0cd988da219f0253b64162a6e823ace2f95ffb | [
"MIT"
] | null | null | null | #ifndef TYPESYSTEM_H
#define TYPESYSTEM_H
#include "./pch.h"
using namespace std;
enum ValueType
{
VALUE_BOOL = 1,
VALUE_INT,
VALUE_CHAR,
VALUE_VOID,
VALUE_STRING,
VALUE_STRUCT,
VALUE_INT_POINTER,
VALUE_CHAR_POINTER,
VALUE_WRONG,
COMPOSE_STRUCT,
COMPOSE_UNION,
COMPOSE_FUNCTION
};
class Type
{
public:
ValueType type;
Type(ValueType valueType);
public:
ValueType* childType; // for union or struct
ValueType* paramType, retType; // for function
void addChild(Type* t);
void addParam(Type* t);
void addRet(Type* t);
public:
ValueType* sibling;
public:
string getTypeInfo();
};
// 设置几个常量Type,可以节省空间开销
static Type* TYPE_INT = new Type(VALUE_INT);
static Type* TYPE_CHAR = new Type(VALUE_CHAR);
static Type* TYPE_BOOL = new Type(VALUE_BOOL);
static Type* TYPE_VOID = new Type(VALUE_VOID);
static Type* TYPE_STRUCT = new Type(VALUE_STRUCT);
static Type* TYPE_STRING = new Type(VALUE_STRING);
static Type* TYPE_INT_POINTER = new Type(VALUE_INT_POINTER);
static Type* TYPE_CHAR_POINTER = new Type(VALUE_CHAR_POINTER);
static Type* TYPE_WRONG = new Type(VALUE_WRONG);
int getSize(Type* type);
#endif | 21.709091 | 62 | 0.714405 |
d1a33cb8da471185155bf50406f59e9f98b54eb2 | 8,932 | h | C | openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_lut/lut_llr2CnProcBuf_BG1_Z4_R13.h | danghoaison91/openairinterface | ca28acccb2dfe85a0644d5fd6d379928d89f72a6 | [
"Apache-2.0"
] | null | null | null | openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_lut/lut_llr2CnProcBuf_BG1_Z4_R13.h | danghoaison91/openairinterface | ca28acccb2dfe85a0644d5fd6d379928d89f72a6 | [
"Apache-2.0"
] | null | null | null | openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_lut/lut_llr2CnProcBuf_BG1_Z4_R13.h | danghoaison91/openairinterface | ca28acccb2dfe85a0644d5fd6d379928d89f72a6 | [
"Apache-2.0"
] | null | null | null | static const uint32_t lut_llr2CnProcBuf_BG1_Z4_R13[1264] = {92162, 92166, 92170, 92175, 3, 75267, 81409, 61824, 88320, 81413, 75271, 61832, 43395, 61838, 61840, 43401, 43408, 43413, 8832, 43420, 8845, 8848, 8856, 8867, 8873, 8883, 8885, 1163, 1167, 8901, 92163, 92167, 92171, 92172, 0, 75264, 81410, 61825, 88321, 81414, 75268, 61833, 43392, 61839, 61841, 43402, 43409, 43414, 8833, 43421, 8846, 8849, 8857, 8864, 8874, 8880, 8886, 1160, 1164, 8902, 92160, 92164, 92168, 92173, 1, 75265, 81411, 61826, 88322, 81415, 75269, 61834, 43393, 61836, 61842, 43403, 43410, 43415, 8834, 43422, 8847, 8850, 8858, 8865, 8875, 8881, 8887, 1161, 1165, 8903, 92161, 92165, 92169, 92174, 2, 75266, 81408, 61827, 88323, 81412, 75270, 61835, 43394, 61837, 61843, 43400, 43411, 43412, 8835, 43423, 8844, 8851, 8859, 8866, 8872, 8882, 8884, 1162, 1166, 8900, 93699, 93705, 93711, 386, 76032, 63744, 88704, 82182, 61830, 76039, 63754, 63760, 43396, 43406, 46483, 43419, 8836, 8841, 1155, 8854, 8861, 8870, 8879, 1158, 8891, 8893, 8897, 1171, 93696, 93706, 93708, 387, 76033, 63745, 88705, 82183, 61831, 76036, 63755, 63761, 43397, 43407, 46480, 43416, 8837, 8842, 1152, 8855, 8862, 8871, 8876, 1159, 8888, 8894, 8898, 1168, 93697, 93707, 93709, 384, 76034, 63746, 88706, 82180, 61828, 76037, 63752, 63762, 43398, 43404, 46481, 43417, 8838, 8843, 1153, 8852, 8863, 8868, 8877, 1156, 8889, 8895, 8899, 1169, 93698, 93704, 93710, 385, 76035, 63747, 88707, 82181, 61829, 76038, 63753, 63763, 43399, 43405, 46482, 43418, 8839, 8840, 1154, 8853, 8860, 8869, 8878, 1157, 8890, 8892, 8896, 1170, 95234, 93701, 95243, 63751, 15749, 15757, 15781, 95235, 93702, 95240, 63748, 15750, 15758, 15782, 95232, 93703, 95241, 63749, 15751, 15759, 15783, 95233, 93700, 95242, 63750, 15748, 15756, 15780, 96769, 95239, 95244, 76802, 89089, 46464, 46471, 46486, 46494, 15801, 15807, 96770, 95236, 95245, 76803, 89090, 46465, 46468, 46487, 46495, 15802, 15804, 96771, 95237, 95246, 76800, 89091, 46466, 46469, 46484, 46492, 15803, 15805, 96768, 95238, 95247, 76801, 89088, 46467, 46470, 46485, 46493, 15800, 15806, 96772, 96777, 96780, 65665, 65669, 49564, 22669, 15763, 3087, 96773, 96778, 96781, 65666, 65670, 49565, 22670, 15760, 3084, 96774, 96779, 96782, 65667, 65671, 49566, 22671, 15761, 3085, 96775, 96776, 96783, 65664, 65668, 49567, 22668, 15762, 3086, 98304, 98309, 98315, 46491, 98305, 98310, 98312, 46488, 98306, 98311, 98313, 46489, 98307, 98308, 98314, 46490, 99842, 99851, 98318, 82178, 15752, 3072, 15791, 3089, 99843, 99848, 98319, 82179, 15753, 3073, 15788, 3090, 99840, 99849, 98316, 82176, 15754, 3074, 15789, 3091, 99841, 99850, 98317, 82177, 15755, 3075, 15790, 3088, 99846, 101387, 99853, 67585, 67588, 49537, 49552, 22664, 15775, 15785, 22715, 15815, 99847, 101384, 99854, 67586, 67589, 49538, 49553, 22665, 15772, 15786, 22712, 15812, 99844, 101385, 99855, 67587, 67590, 49539, 49554, 22666, 15773, 15787, 22713, 15813, 99845, 101386, 99852, 67584, 67591, 49536, 49555, 22667, 15774, 15784, 22714, 15814, 101380, 102923, 101389, 69505, 69511, 52625, 4994, 3083, 101381, 102920, 101390, 69506, 69508, 52626, 4995, 3080, 101382, 102921, 101391, 69507, 69509, 52627, 4992, 3081, 101383, 102922, 101388, 69504, 69510, 52624, 4993, 3082, 101377, 102919, 104457, 49559, 15797, 22717, 22725, 101378, 102916, 104458, 49556, 15798, 22718, 22726, 101379, 102917, 104459, 49557, 15799, 22719, 22727, 101376, 102918, 104456, 49558, 15796, 22716, 22724, 102915, 105993, 102924, 82944, 82951, 65675, 65683, 55696, 22662, 15771, 22711, 5009, 102912, 105994, 102925, 82945, 82948, 65672, 65680, 55697, 22663, 15768, 22708, 5010, 102913, 105995, 102926, 82946, 82949, 65673, 65681, 55698, 22660, 15769, 22709, 5011, 102914, 105992, 102927, 82947, 82950, 65674, 65682, 55699, 22661, 15770, 22710, 5008, 104450, 104452, 104462, 83713, 83719, 67592, 49543, 52629, 52636, 22695, 104451, 104453, 104463, 83714, 83716, 67593, 49540, 52630, 52637, 22692, 104448, 104454, 104460, 83715, 83717, 67594, 49541, 52631, 52638, 22693, 104449, 104455, 104461, 83712, 83718, 67595, 49542, 52628, 52639, 22694, 105985, 105990, 105998, 77569, 89473, 76805, 63757, 46479, 15746, 15776, 22701, 29621, 105986, 105991, 105999, 77570, 89474, 76806, 63758, 46476, 15747, 15777, 22702, 29622, 105987, 105988, 105996, 77571, 89475, 76807, 63759, 46477, 15744, 15778, 22703, 29623, 105984, 105989, 105997, 77568, 89472, 76804, 63756, 46478, 15745, 15779, 22700, 29620, 107523, 107530, 107533, 84480, 84486, 69514, 67601, 49548, 22656, 22680, 3076, 107520, 107531, 107534, 84481, 84487, 69515, 67602, 49549, 22657, 22681, 3077, 107521, 107528, 107535, 84482, 84484, 69512, 67603, 49550, 22658, 22682, 3078, 107522, 107529, 107532, 84483, 84485, 69513, 67600, 49551, 22659, 22683, 3079, 107527, 109067, 109069, 71424, 71430, 46472, 29578, 15764, 22689, 15795, 107524, 109064, 109070, 71425, 71431, 46473, 29579, 15765, 22690, 15792, 107525, 109065, 109071, 71426, 71428, 46474, 29576, 15766, 22691, 15793, 107526, 109066, 109068, 71427, 71429, 46475, 29577, 15767, 22688, 15794, 109057, 109060, 110603, 65678, 29583, 22696, 22705, 109058, 109061, 110600, 65679, 29580, 22697, 22706, 109059, 109062, 110601, 65676, 29581, 22698, 22707, 109056, 109063, 110602, 65677, 29582, 22699, 22704, 110593, 110598, 110604, 78336, 89858, 77574, 67597, 49545, 49563, 15809, 110594, 110599, 110605, 78337, 89859, 77575, 67598, 49546, 49560, 15810, 110595, 110596, 110606, 78338, 89856, 77572, 67599, 49547, 49561, 15811, 110592, 110597, 110607, 78339, 89857, 77573, 67596, 49544, 49562, 15808, 112133, 112139, 112140, 85249, 85254, 69516, 52619, 29570, 29609, 5003, 112134, 112136, 112141, 85250, 85255, 69517, 52616, 29571, 29610, 5000, 112135, 112137, 112142, 85251, 85252, 69518, 52617, 29568, 29611, 5001, 112132, 112138, 112143, 85248, 85253, 69519, 52618, 29569, 29608, 5002, 112130, 113675, 113676, 86019, 86023, 71433, 69521, 52621, 29572, 22676, 29616, 29629, 22723, 112131, 113672, 113677, 86016, 86020, 71434, 69522, 52622, 29573, 22677, 29617, 29630, 22720, 112128, 113673, 113678, 86017, 86021, 71435, 69523, 52623, 29574, 22678, 29618, 29631, 22721, 112129, 113674, 113679, 86018, 86022, 71432, 69520, 52620, 29575, 22679, 29619, 29628, 22722, 113665, 113669, 115209, 90240, 55693, 22675, 29624, 113666, 113670, 115210, 90241, 55694, 22672, 29625, 113667, 113671, 115211, 90242, 55695, 22673, 29626, 113664, 113668, 115208, 90243, 55692, 22674, 29627, 115201, 116747, 115212, 86785, 86788, 52611, 52613, 52633, 115202, 116744, 115213, 86786, 86789, 52608, 52614, 52634, 115203, 116745, 115214, 86787, 86790, 52609, 52615, 52635, 115200, 116746, 115215, 86784, 86791, 52610, 52612, 52632, 116737, 115204, 116748, 79105, 90627, 78342, 71439, 55688, 55705, 29585, 29605, 116738, 115205, 116749, 79106, 90624, 78343, 71436, 55689, 55706, 29586, 29606, 116739, 115206, 116750, 79107, 90625, 78340, 71437, 55690, 55707, 29587, 29607, 116736, 115207, 116751, 79104, 90626, 78341, 71438, 55691, 55704, 29584, 29604, 118275, 116740, 118287, 79873, 91011, 79108, 55686, 55700, 55710, 22684, 29613, 29639, 118272, 116741, 118284, 79874, 91008, 79109, 55687, 55701, 55711, 22685, 29614, 29636, 118273, 116742, 118285, 79875, 91009, 79110, 55684, 55702, 55708, 22686, 29615, 29637, 118274, 116743, 118286, 79872, 91010, 79111, 55685, 55703, 55709, 22687, 29612, 29638, 119808, 118276, 79878, 55682, 4998, 119809, 118277, 79879, 55683, 4999, 119810, 118278, 79876, 55680, 4996, 119811, 118279, 79877, 55681, 4997, 119812, 118280, 91394, 29595, 29603, 5007, 119813, 118281, 91395, 29592, 29600, 5004, 119814, 118282, 91392, 29593, 29601, 5005, 119815, 118283, 91393, 29594, 29602, 5006, 119816, 119820, 71441, 29590, 29599, 29633, 119817, 119821, 71442, 29591, 29596, 29634, 119818, 119822, 71443, 29588, 29597, 29635, 119819, 119823, 71440, 29589, 29598, 29632, 768, 769, 770, 771, 80640, 80641, 80642, 80643, 87552, 87553, 87554, 87555, 73344, 73345, 73346, 73347, 91776, 91777, 91778, 91779, 87556, 87557, 87558, 87559, 73348, 73349, 73350, 73351, 80644, 80645, 80646, 80647, 73352, 73353, 73354, 73355, 58752, 58753, 58754, 58755, 73356, 73357, 73358, 73359, 73360, 73361, 73362, 73363, 58756, 58757, 58758, 58759, 58760, 58761, 58762, 58763, 58764, 58765, 58766, 58767, 58768, 58769, 58770, 58771, 58772, 58773, 58774, 58775, 58776, 58777, 58778, 58779, 36480, 36481, 36482, 36483, 36484, 36485, 36486, 36487, 58780, 58781, 58782, 58783, 36488, 36489, 36490, 36491, 36492, 36493, 36494, 36495, 6912, 6913, 6914, 6915, 36496, 36497, 36498, 36499, 36500, 36501, 36502, 36503, 36504, 36505, 36506, 36507, 36508, 36509, 36510, 36511, 36512, 36513, 36514, 36515, 36516, 36517, 36518, 36519, 36520, 36521, 36522, 36523, 36524, 36525, 36526, 36527, 36528, 36529, 36530, 36531, 6916, 6917, 6918, 6919, 36532, 36533, 36534, 36535, 36536, 36537, 36538, 36539, 6920, 6921, 6922, 6923, 36540, 36541, 36542, 36543, 6924, 6925, 6926, 6927, 36544, 36545, 36546, 36547, 36548, 36549, 36550, 36551, 6928, 6929, 6930, 6931}; | 8,932 | 8,932 | 0.715965 |
d1a3b180412ef40c6e03551cb93b709833aaa7cf | 12,759 | c | C | src/cortexm/cortexm_rtos_nuttx.c | Syncena/Maven-firmware | 1f441c69e448eb3325601a92e4f72e0c892ef021 | [
"BSD-3-Clause"
] | null | null | null | src/cortexm/cortexm_rtos_nuttx.c | Syncena/Maven-firmware | 1f441c69e448eb3325601a92e4f72e0c892ef021 | [
"BSD-3-Clause"
] | null | null | null | src/cortexm/cortexm_rtos_nuttx.c | Syncena/Maven-firmware | 1f441c69e448eb3325601a92e4f72e0c892ef021 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2022, Steve C. Woodford.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "cortexm.h"
#include "cortexm_regs.h"
#include "cortexm_txml.h"
#include "cortexm_rtos.h"
#include "cortexm_rtos_nuttx.h"
#include "zone_alloc.h"
//#define DEBUG_FLAG_INIT 1
#include "debug.h"
/*
* First entry in the NuttX core register set is the SP value *before* the
* exception, without taking into account xPSR[9]. It's of no use to us
* so we simply ignore it.
*
* The second entry is normally PRIMASK, but could in fact be BASEPRI on
* V7m or V8m cores if CONFIG_ARMV7M_USEBASEPRI/CONFIG_ARMV8M_USEBASEPRI are
* defined.
*
* EXC_LR is always stored in the core frame on V7m/V8m.
* On V6m cores, EXC_LR is stored if CONFIG_BUILD_PROTECTED is defined.
* We don't need EXC_LR on V6m, but we still need to grok the layout.
*
* On V8m, PSPLIM or MSPLIM is stored after EXC_LR in the core frame, but
* only if CONFIG_ARMV8M_STACKCHECK_HARDWARE is defined. Which one is stored
* depends on which SP was active before the exception.
*
* I'm sure there's a reason for the complexity...
*/
#define CORTEXM_FRAME_NUTTX_CORE(base) \
{CORTEXM_REG_PRIMASK, (base) + 0x00}, \
{CORTEXM_REG_R4, (base) + 0x04}, \
{CORTEXM_REG_R5, (base) + 0x08}, \
{CORTEXM_REG_R6, (base) + 0x0c}, \
{CORTEXM_REG_R7, (base) + 0x10}, \
{CORTEXM_REG_R8, (base) + 0x14}, \
{CORTEXM_REG_R9, (base) + 0x18}, \
{CORTEXM_REG_R10, (base) + 0x1c}, \
{CORTEXM_REG_R11, (base) + 0x20}
#define CORTEXM_FRAME_NUTTX_EXC_LR 0x24
#define CORTEXM_FRAME_NUTTX_V6_CORE_LEN 0x24
#define CORTEXM_FRAME_NUTTX_CORE_LEN 0x28
/*
* The V8m layout. Used only if NuttX is built with the
* CONFIG_ARMV8M_STACKCHECK_HARDWARE option.
* Largely the same as CORTEXM_FRAME_NUTTX_CORE(), but with either
* MSPLIM or PSPLIM following EXC_LR. Which one is stored depends which
* stack was active before the exception. Hence EXC_LR will need to
* be consulted. We will default to PSPLIM and fix-up the correct
* register enum at runtime.
*
* Note that CORTEXM_REG_PSPLIM_S and CORTEXM_REG_PSPLIM_NS *must* be
* the first two elements of CORTEXM_FRAME_NUTTX_V8_CORE().
*/
#define CORTEXM_FRAME_NUTTX_V8_CORE(base) \
{CORTEXM_REG_PSPLIM_S, (base) + CORTEXM_FRAME_NUTTX_CORE_LEN}, \
{CORTEXM_REG_PSPLIM_NS, (base) + CORTEXM_FRAME_NUTTX_CORE_LEN}, \
CORTEXM_FRAME_NUTTX_CORE(base)
#define CORTEXM_FRAME_NUTTX_V8_CORE_LEN (CORTEXM_FRAME_NUTTX_CORE_LEN + 4)
#define CORTEXM_FRAME_NUTTX_FP(base) \
{CORTEXM_REG_VFP_D8, (base) + 0x00}, \
{CORTEXM_REG_VFP_D9, (base) + 0x08}, \
{CORTEXM_REG_VFP_D10, (base) + 0x10}, \
{CORTEXM_REG_VFP_D11, (base) + 0x18}, \
{CORTEXM_REG_VFP_D12, (base) + 0x20}, \
{CORTEXM_REG_VFP_D13, (base) + 0x28}, \
{CORTEXM_REG_VFP_D14, (base) + 0x30}, \
{CORTEXM_REG_VFP_D15, (base) + 0x38}
#define CORTEXM_FRAME_NUTTX_FP_LEN 0x40
/*
* Used for V6m if CONFIG_BUILD_PROTECTED is *not* defined.
*/
static const struct cortexm_txml_regframe cortexm_rtos_nuttx_v6m[] = {
CORTEXM_FRAME_NUTTX_CORE(0x00),
CORTEXM_FRAME_CPU(CORTEXM_FRAME_NUTTX_V6_CORE_LEN),
{CORTEXM_REG_SP, CORTEXM_FRAME_NUTTX_V6_CORE_LEN +
CORTEXM_FRAME_CPU_LEN}
};
#define CORTEXM_RTOS_NUTTX_V6M_COUNT \
(sizeof(cortexm_rtos_nuttx_v6m) / sizeof(cortexm_rtos_nuttx_v6m[0]))
/*
* - Used for V6m if CONFIG_BUILD_PROTECTED is defined
* - Used for V7m with no FPU available/used
* - Used for V8m with no FPU available/used and
* CONFIG_ARMV8M_STACKCHECK_HARDWARE is not defined.
*/
static const struct cortexm_txml_regframe cortexm_rtos_nuttx_no_fp[] = {
CORTEXM_FRAME_NUTTX_CORE(0x00),
CORTEXM_FRAME_CPU(CORTEXM_FRAME_NUTTX_CORE_LEN),
{CORTEXM_REG_SP, CORTEXM_FRAME_NUTTX_CORE_LEN +
CORTEXM_FRAME_CPU_LEN}
};
#define CORTEXM_RTOS_NUTTX_NO_FP_COUNT \
(sizeof(cortexm_rtos_nuttx_no_fp) / sizeof(cortexm_rtos_nuttx_no_fp[0]))
/*
* FPU used in non-lazy mode.
*
* - Used for V7m.
* - Used for V8m when CONFIG_ARMV8M_STACKCHECK_HARDWARE is not defined.
*/
static const struct cortexm_txml_regframe cortexm_rtos_nuttx_fp[] = {
CORTEXM_FRAME_NUTTX_CORE(0x00),
CORTEXM_FRAME_NUTTX_FP(CORTEXM_FRAME_NUTTX_CORE_LEN),
CORTEXM_FRAME_EXT(CORTEXM_FRAME_NUTTX_CORE_LEN +
CORTEXM_FRAME_NUTTX_FP_LEN),
{CORTEXM_REG_SP, CORTEXM_FRAME_NUTTX_CORE_LEN +
CORTEXM_FRAME_NUTTX_FP_LEN +
CORTEXM_FRAME_EXT_LEN}
};
/*
* FPU used in lazy-save mode.
*
* - Used for V7m.
* - Used for V8m when CONFIG_ARMV8M_STACKCHECK_HARDWARE is not defined.
*/
static const struct cortexm_txml_regframe cortexm_rtos_nuttx_lazyfp[] = {
CORTEXM_FRAME_NUTTX_CORE(0x00),
CORTEXM_FRAME_NUTTX_FP(CORTEXM_FRAME_NUTTX_CORE_LEN),
CORTEXM_FRAME_EXT_LAZY(CORTEXM_FRAME_NUTTX_CORE_LEN +
CORTEXM_FRAME_NUTTX_FP_LEN),
{CORTEXM_REG_SP, CORTEXM_FRAME_NUTTX_CORE_LEN +
CORTEXM_FRAME_NUTTX_FP_LEN +
CORTEXM_FRAME_EXT_LEN}
};
static_assert(sizeof(cortexm_rtos_nuttx_fp) ==
sizeof(cortexm_rtos_nuttx_lazyfp),
"FP regframe size mismatch");
#define CORTEXM_RTOS_NUTTX_FP_COUNT \
(sizeof(cortexm_rtos_nuttx_fp) / sizeof(cortexm_rtos_nuttx_fp[0]))
/*
* Used for V8m with no FPU available/used and
* CONFIG_ARMV8M_STACKCHECK_HARDWARE is defined.
*/
static const struct cortexm_txml_regframe cortexm_rtos_nuttx_v8m_no_fp[] = {
CORTEXM_FRAME_NUTTX_V8_CORE(0x00),
CORTEXM_FRAME_CPU(CORTEXM_FRAME_NUTTX_V8_CORE_LEN),
{CORTEXM_REG_SP, CORTEXM_FRAME_NUTTX_V8_CORE_LEN +
CORTEXM_FRAME_CPU_LEN}
};
#define CORTEXM_RTOS_NUTTX_V8M_NO_FP_COUNT \
(sizeof(cortexm_rtos_nuttx_v8m_no_fp) / \
sizeof(cortexm_rtos_nuttx_v8m_no_fp[0]))
/*
* V8m CONFIG_ARMV8M_STACKCHECK_HARDWARE defined, FPU used in non-lazy mode.
*/
static const struct cortexm_txml_regframe cortexm_rtos_nuttx_v8m_fp[] = {
CORTEXM_FRAME_NUTTX_V8_CORE(0x00),
CORTEXM_FRAME_NUTTX_FP(CORTEXM_FRAME_NUTTX_V8_CORE_LEN),
CORTEXM_FRAME_EXT(CORTEXM_FRAME_NUTTX_V8_CORE_LEN +
CORTEXM_FRAME_NUTTX_FP_LEN),
{CORTEXM_REG_SP, CORTEXM_FRAME_NUTTX_V8_CORE_LEN +
CORTEXM_FRAME_NUTTX_FP_LEN +
CORTEXM_FRAME_EXT_LEN}
};
/*
* V8m CONFIG_ARMV8M_STACKCHECK_HARDWARE defined, FPU used in lazy-save mode.
*/
static const struct cortexm_txml_regframe cortexm_rtos_nuttx_v8m_lazyfp[] = {
CORTEXM_FRAME_NUTTX_V8_CORE(0x00),
CORTEXM_FRAME_NUTTX_FP(CORTEXM_FRAME_NUTTX_V8_CORE_LEN),
CORTEXM_FRAME_EXT_LAZY(CORTEXM_FRAME_NUTTX_V8_CORE_LEN +
CORTEXM_FRAME_NUTTX_FP_LEN),
{CORTEXM_REG_SP, CORTEXM_FRAME_NUTTX_V8_CORE_LEN +
CORTEXM_FRAME_NUTTX_FP_LEN +
CORTEXM_FRAME_EXT_LEN}
};
static_assert(sizeof(cortexm_rtos_nuttx_v8m_fp) ==
sizeof(cortexm_rtos_nuttx_v8m_lazyfp),
"V8M FP regframe size mismatch");
#define CORTEXM_RTOS_NUTTX_V8M_FP_COUNT \
(sizeof(cortexm_rtos_nuttx_v8m_fp) / \
sizeof(cortexm_rtos_nuttx_v8m_fp[0]))
static struct cortexm_txml_regframe *
cortexm_nuttx_copy_regframe(const struct cortexm_txml_regframe *src,
size_t size)
{
struct cortexm_txml_regframe *rf;
if ((rf = zone_malloc(size)) != NULL)
memcpy(rf, src, size);
return rf;
}
const struct cortexm_txml_regframe *
cortexm_nuttx_get_regframe(cortexm_t cm, const struct target_rtos *tr,
unsigned int *frame_count, bool *dynamic)
{
const struct cortexm_txml_regframe *rf = NULL;
struct cortexm_txml_regframe *new_rf;
bool has_fpu, ext_frame, state_valid, use_basepri;
struct target_mem_readwrite mr;
unsigned int count = 0;
gdb_rtos_params_t rp;
target_addr_t addr;
uint32_t exc_lr;
size_t rfsize;
/* Skip the SP saved at the start of the frame. */
addr = tr->tr_frame + 4;
cm->cm_rtos_frame_base = addr;
rp = tr->tr_params;
assert(rp != NULL);
has_fpu = cortexm_rtos_get_fp_status(cm,
addr + CORTEXM_FRAME_NUTTX_EXC_LR,
addr + CORTEXM_FRAME_NUTTX_CORE_LEN + CORTEXM_FRAME_NUTTX_FP_LEN,
&ext_frame, &state_valid);
/*
* Default to the lowest common denominator.
*/
count = CORTEXM_RTOS_NUTTX_NO_FP_COUNT;
rf = cortexm_rtos_nuttx_no_fp;
rfsize = sizeof(cortexm_rtos_nuttx_no_fp);
*dynamic = false;
use_basepri = rp->rp_val[GDB_RTOS_NUTTX_config_armv78m_usebasepri] != 0;
switch (CORTEXM_FLAG_ARCH(cm)) {
case CORTEXM_FLAG_ARCH_V6M:
if (!rp->rp_val[GDB_RTOS_NUTTX_config_build_protected]) {
count = CORTEXM_RTOS_NUTTX_V6M_COUNT;
rf = cortexm_rtos_nuttx_v6m;
}
break;
case CORTEXM_FLAG_ARCH_V7M:
normal_frame:
if (has_fpu && ext_frame) {
/* Extended frame. */
count = CORTEXM_RTOS_NUTTX_FP_COUNT;
if (state_valid) {
rf = cortexm_rtos_nuttx_fp;
rfsize = sizeof(cortexm_rtos_nuttx_fp);
} else {
/*
* FPU state was not saved, therefore the
* current FPU registers should be used.
*/
rf = cortexm_rtos_nuttx_lazyfp;
rfsize = sizeof(cortexm_rtos_nuttx_lazyfp);
}
}
if (use_basepri &&
(new_rf = cortexm_nuttx_copy_regframe(rf, rfsize)) != NULL){
*dynamic = true;
/* Change first item to BASEPRI. */
new_rf[0].rf_reg = CORTEXM_REG_BASEPRI;
rf = new_rf;
}
break;
case CORTEXM_FLAG_ARCH_V8M:
if (!rp->rp_val[GDB_RTOS_NUTTX_config_armv8m_stackcheck_hardware])
goto normal_frame;
count = CORTEXM_RTOS_NUTTX_V8M_NO_FP_COUNT;
rf = cortexm_rtos_nuttx_v8m_no_fp;
rfsize = sizeof(cortexm_rtos_nuttx_v8m_no_fp);
if (has_fpu && ext_frame) {
/* Extended frame. */
count = CORTEXM_RTOS_NUTTX_V8M_FP_COUNT;
if (state_valid) {
rf = cortexm_rtos_nuttx_v8m_fp;
rfsize = sizeof(cortexm_rtos_nuttx_v8m_fp);
} else {
/*
* FPU state was not saved, therefore the
* current FPU registers should be used.
*/
rf = cortexm_rtos_nuttx_v8m_lazyfp;
rfsize = sizeof(cortexm_rtos_nuttx_v8m_lazyfp);
}
}
/*
* Examine EXC_LR to determine if we need to change
* PSPLIM -> MSPLIM in the regframe.
*/
mr.mr_write = false;
mr.mr_target_addr = addr + CORTEXM_FRAME_NUTTX_EXC_LR;
mr.mr_length = sizeof(uint32_t);
mr.mr_dest = &exc_lr;
if (target_ctl(cm->cm_target, TARGET_CTL_MEM_READWRITE,
&mr) == 0 &&
((exc_lr & (1u << 2)) != 0 || use_basepri) &&
(new_rf = cortexm_nuttx_copy_regframe(rf, rfsize))!= NULL) {
if ((exc_lr & (1u << 2)) != 0) {
/* Need to change PSPLIM* to MSMLIM */
new_rf[0].rf_reg = CORTEXM_REG_MSPLIM_S;
new_rf[1].rf_reg = CORTEXM_REG_MSPLIM_NS;
}
if (use_basepri)
new_rf[2].rf_reg = CORTEXM_REG_BASEPRI;
*dynamic = true;
rf = new_rf;
}
break;
default:
return NULL;
}
*frame_count = count;
return rf;
}
int
cortexm_nuttx_load_params(cortexm_t cm,
const struct gdb_rtos_nuttx_target_params *tp)
{
struct gdb_rtos_nuttx_debugger_hints *hints = tp->tp_hints;
uint16_t u16;
(void) cm;
u16 = hints->sizeof_far_pointer;
if (u16 != 4) {
DBFPRINTF("Bad sizeof_far_pointer: %" PRIu16 "\n", u16);
return -1;
}
u16 = hints->offsetof_xcptcontext_regs;
if (u16 > 255) {
DBFPRINTF("Bad offsetof_xcptcontext_regs: %" PRIu16 "\n", u16);
return -1;
}
/* XXX: We should be able to nail this size perfectly... */
u16 = hints->sizeof_xcptcontext_regs;
if (u16 > 511) {
DBFPRINTF("Bad sizeof_xcptcontext_regs: %" PRIu16 "\n", u16);
return false;
}
return 0;
}
| 33.054404 | 79 | 0.739556 |
d1a6212bfe810cf1fa92097cec758fd2ce319e07 | 1,733 | c | C | test/ae/keccak1600.c | rofl0r/kripto | 786f953df7e9aefaddea73a9b34d13928d356bfb | [
"CC0-1.0"
] | 1 | 2018-07-31T15:00:14.000Z | 2018-07-31T15:00:14.000Z | test/ae/keccak1600.c | rofl0r/kripto | 786f953df7e9aefaddea73a9b34d13928d356bfb | [
"CC0-1.0"
] | null | null | null | test/ae/keccak1600.c | rofl0r/kripto | 786f953df7e9aefaddea73a9b34d13928d356bfb | [
"CC0-1.0"
] | 1 | 2019-12-02T22:08:26.000Z | 2019-12-02T22:08:26.000Z | /*
* Written in 2013 by Gregor Pintar <grpintar@gmail.com>
*
* To the extent possible under law, the author(s) have dedicated
* all copyright and related and neighboring rights to this software
* to the public domain worldwide.
*
* This software is distributed without any warranty.
*
* You should have received a copy of the CC0 Public Domain Dedication.
* If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <kripto/ae.h>
#include <kripto/ae/keccak1600.h>
int main(void)
{
kripto_ae *s;
uint8_t t[32];
const uint8_t pt[32] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
};
unsigned int i;
// 369e24e2f1153d9482b1d697a8f22fdac4e66e908fe9fe4ca9fa9700c8623d64
// 369e24e2f1157351d47f531b1f1809b872db51041f95e6640c5d9a4725f99002
/* create */
s = kripto_ae_create(kripto_ae_keccak1600, 0, pt, 16, pt, 16, 97);
if(!s) perror("error");
/* encrypt */
//kripto_ae_encrypt(s, pt, t, 32);
kripto_ae_encrypt(s, pt, t, 3);
kripto_ae_encrypt(s, pt + 3, t + 3, 29);
for(i = 0; i < 32; i++) printf("%.2x", pt[i]);
putchar('\n');
for(i = 0; i < 32; i++) printf("%.2x", t[i]);
putchar('\n');
/* recreate */
s = kripto_ae_recreate(s, 0, pt, 16, pt, 16, 97);
if(!s) perror("error");
/* decrypt */
//kripto_ae_decrypt(s, t, t, 32);
kripto_ae_decrypt(s, t, t, 17);
kripto_ae_decrypt(s, t + 17, t + 17, 15);
for(i = 0; i < 32; i++) printf("%.2x", t[i]);
putchar('\n');
if(memcmp(t, pt, 32)) puts("FAIL");
else puts("OK");
kripto_ae_destroy(s);
return 0;
}
| 24.408451 | 71 | 0.65378 |
d1aa49a50d9d9bc597a1033b1aa219250deb0ed3 | 775 | c | C | third_party/Phigs/PVT/PVT_c/LAYER/nschh.c | n1ckfg/Telidon | f4e2c693ec7d67245974b73a602d5d40df6a6d69 | [
"MIT"
] | 18 | 2017-07-08T02:34:02.000Z | 2022-01-08T03:42:48.000Z | third_party/Phigs/PVT/PVT_c/LAYER/nschh.c | n1ckfg/Telidon | f4e2c693ec7d67245974b73a602d5d40df6a6d69 | [
"MIT"
] | null | null | null | third_party/Phigs/PVT/PVT_c/LAYER/nschh.c | n1ckfg/Telidon | f4e2c693ec7d67245974b73a602d5d40df6a6d69 | [
"MIT"
] | 3 | 2018-02-03T04:44:00.000Z | 2020-08-05T15:31:18.000Z | #include <phigs.h>
#include "f2c.h"
/**************************************************************************
NAME
SET CHARACTER HEIGHT - create structure element to set
current character height attribute
FORTRAN Syntax
SUBROUTINE pschh ( CHH )
REAL CHH character height (TLC)
**************************************************************************/
#ifdef NO_PROTO
nschh (chh)
real *chh;
#else
nschh (real *chh)
#endif
{
/**************************************************************************
C Syntax
void
pset_char_ht ( height )
Pfloat height; character height
**************************************************************************/
pset_char_ht ((Pfloat) *chh);
}
| 25.833333 | 75 | 0.369032 |
d1ad6bd7de0276519ed7c1db82d631e7f7125ab5 | 760 | h | C | src/STE/Audio/SoundFunctions.h | silenttowergames/stonetowerenginw | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | 7 | 2020-08-20T17:02:01.000Z | 2022-03-25T13:50:40.000Z | src/STE/Audio/SoundFunctions.h | silenttowergames/stonetowerenginw | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | 23 | 2020-09-17T22:15:38.000Z | 2021-04-17T16:31:01.000Z | src/STE/Audio/SoundFunctions.h | silenttowergames/stonetowerengine | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | null | null | null | #pragma once
#include <flecs.h>
#include "Play.h"
#include "Sound.h"
Sound Sound_create_load(const char* key, Play play, SoundCategory category);
Sound Sound_create_speech(const char* key, const char* words, Play play, SoundCategory category);
Sound Sound_create_sfxr(const char* key, Play play, SoundCategory category);
SoundInstance* Sound_playFull(ApplicationState* app, Sound* sound, float volume, float pan, float sampleRate, float speed, bool loop);
SoundInstance* Sound_play(ApplicationState* app, Sound* sound);
void Sound_Free(Sound* sound);
#define soundPlay(key) Sound_play(app, *mapGet(app->assetManager.mapSound, key, Sound*))
#define soundPlayFull(key, ...) Sound_playFull(app, *mapGet(app->assetManager.mapSound, key, Sound*), __VA_ARGS__)
| 42.222222 | 134 | 0.778947 |
d1af5328e1ca54b599d66070cdc27d590df83011 | 152 | h | C | SchoolChatIOS/Bcrypt/crypt.h | lalkalol1907/SchoolChatIOS | 54b829e4633cd859aeba82a8faccea299b26d7da | [
"MIT"
] | null | null | null | SchoolChatIOS/Bcrypt/crypt.h | lalkalol1907/SchoolChatIOS | 54b829e4633cd859aeba82a8faccea299b26d7da | [
"MIT"
] | 18 | 2022-01-29T23:41:51.000Z | 2022-02-02T15:20:58.000Z | SchoolChatIOS/Bcrypt/crypt.h | lalkalol1907/SchoolChatIOS | 54b829e4633cd859aeba82a8faccea299b26d7da | [
"MIT"
] | 1 | 2022-01-29T13:30:27.000Z | 2022-01-29T13:30:27.000Z | #include <gnu-crypt.h>
#if defined(_OW_SOURCE) || defined(__USE_OW)
#define __SKIP_GNU
#undef __SKIP_OW
#include <ow-crypt.h>
#undef __SKIP_GNU
#endif
| 16.888889 | 44 | 0.756579 |
d1b336ce29ed0d3c30855759366c1ae8bd8e6808 | 12,900 | c | C | IF97_Region2.c | c4rnot/if97lib | 5fdc906c81be1c6edee71f4d617b1762f37c3482 | [
"BSL-1.0"
] | null | null | null | IF97_Region2.c | c4rnot/if97lib | 5fdc906c81be1c6edee71f4d617b1762f37c3482 | [
"BSL-1.0"
] | null | null | null | IF97_Region2.c | c4rnot/if97lib | 5fdc906c81be1c6edee71f4d617b1762f37c3482 | [
"BSL-1.0"
] | null | null | null | // Copyright Martin Lord 2014-2015.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// IAPWS-IF97 Region 2: Single phase vapour region equations
/* *********************************************************************
* ******* VALIDITY ************
*
* 273.15 K <= T <= 623.15 K 0 <= p <= Ps(T) (Eq 30 "Saturation Pressure basic Equation")
* 623.15 K <= T <= 863.15 K 0 <= p <= p(T) (Eq 5 "B23 Region 2 - 3 boundry equation")
* 863.15 K <= T <= 1073.15 K 0 <= p <= 100 MPa
*
* These functions also provide reasonable values for the metastable
* region above 10 MPa
*
* Note: for temperatures between 273.15 and 273.16 K, the part of the
* range of validity between the pressures on the saturation pressure
* line (Eq 30) and on the sublimation line corresponds to metastable
* states
* ****************************************************************** */
/* ********************************************************************
* COMPILE AND LINK INSTRUCTIONS (gcc) *
*
* This library uses math.h, so must have the -lm link flag
*
* The library is programmed to be able to use OpenMP multithreading
* use the -fopenmp complie flag to enable multithreadded code
*
* ****************************************************************** */
#include "IF97_common.h" //PSTAR TSTAR & sqr
#include "IF97_Region2.h"
#include "IF97_Region2bw.h"
#include <math.h> // for pow, log
/* #ifdef _OPENMP // multithreading via libgomp
# include <omp.h>
#endif
*/
#include <stdio.h> //used for debugging only
//***************************************************************
//****** REGION 2 GIBBS FREE ENERGY AND DERIVATIVES**************
// see Table 10
const typIF97Coeffs_Jn GIBBS_COEFFS_R2_O[] = {
{0, 0.0} //0 i starts at 1, so 0th i is not used
,{ 0 , -9.6927686500217 } // 1
,{ 1 , 10.086655968018 }
,{ -5 , -0.0056087911283 }
,{ -4 , 0.0714527380815 }
,{ -3 , -0.4071049822393 }
,{ -2 , 1.4240819171444 }
,{ -1 , -4.383951131945 }
,{ 2 , -0.2840863246077 }
,{ 3 , 0.0212684637533 } //9
};
const int MAX_GIBBS_COEFFS_R2_O = 9;
// ideal gas part of dimensionless gibbs free energy in Region2 : See Equation 16
// checked OK
double if97_r2_Gamma_o (double if97_pi, double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_O; i++) {
dblGammaSum += GIBBS_COEFFS_R2_O[i].ni * pow( if97_tau, GIBBS_COEFFS_R2_O[i].Ji);
}
return log(if97_pi) + dblGammaSum;
}
// See table 11
const typIF97Coeffs_IJn GIBBS_COEFFS_R2_R[] = {
{0, 0, 0.0} //0 i starts at 1, so 0th i is not used
,{1, 0, -1.7731742473213E-003}
,{1, 1, -1.7834862292358E-002}
,{1, 2, -4.5996013696365E-002}
,{1, 3, -5.7581259083432E-002}
,{1, 6, -5.0325278727930E-002}
,{2, 1, -3.3032641670203E-005}
,{2, 2, -1.8948987516315E-004}
,{2, 4, -3.9392777243355E-003}
,{2, 7, -4.3797295650573E-002}
,{2, 36, -2.6674547914087E-005}
,{3, 0, 2.0481737692309E-008}
,{3, 1, 4.3870667284435E-007}
,{3, 3, -3.2277677238570E-005}
,{3, 6, -1.5033924542148E-003}
,{3, 35, -4.0668253562649E-002}
,{4, 1, -7.8847309559367E-010}
,{4, 2, 1.2790717852285E-008}
,{4, 3, 4.8225372718507E-007}
,{5, 7, 2.2922076337661E-006}
,{6, 3, -1.6714766451061E-011}
,{6, 16, -2.1171472321355E-003}
,{6, 35, -2.3895741934104E+001}
,{7, 0, -5.9059564324270E-018}
,{7, 11, -1.2621808899101E-006}
,{7, 25, -3.8946842435739E-002}
,{8, 8, 1.1256211360459E-011}
,{8, 36, -8.2311340897998E+000}
,{9, 13, 1.9809712802088E-008}
,{10, 4, 1.0406965210174E-019}
,{10, 10, -1.0234747095929E-013}
,{10, 14, -1.0018179379511E-009}
,{16, 29, -8.0882908646985E-011}
,{16, 50, 1.0693031879409E-001}
,{18, 57, -3.3662250574171E-001}
,{20, 20, 8.9185845355421E-025}
,{20, 35, 3.0629316876232E-013}
,{20, 48, -4.2002467698208E-006}
,{21, 21, -5.9056029685639E-026}
,{22, 53, 3.7826947613457E-006}
,{23, 39, -1.2768608934681E-015}
,{24, 26, 7.3087610595061E-029}
,{24, 40, 5.5414715350778E-017}
,{24, 58, -9.4369707241210E-007} //43
};
const int MAX_GIBBS_COEFFS_R2_R = 43;
// residual part of dimensionless gibbs free energy in Region2 : See Equation 17
// Checked OK
double if97_r2_Gamma_r (double if97_pi, double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_R; i++) {
dblGammaSum += GIBBS_COEFFS_R2_R[i].ni * pow(if97_pi, GIBBS_COEFFS_R2_R[i].Ii)* pow((if97_tau - 0.5), GIBBS_COEFFS_R2_R[i].Ji) ;
}
return dblGammaSum;
}
// dimensionless gibbs free energy in Region 2 = g/RT: The fundamental equation of region 2. See Equation 15
double if97_r2_Gamma (double if97_pi, double if97_tau) {
return if97_r2_Gamma_o (if97_pi, if97_tau) + if97_r2_Gamma_r (if97_pi, if97_tau);
}
// [d gamma_o / d pi] keeping tau constant
double if97_r2_GammaPi_o (double if97_pi) {
double GammaPi_o = 1.0 / if97_pi;
return GammaPi_o;
}
// [d squared gamma_o / d pi squared] keeping tau constant
double if97_r2_GammaPiPi_o (double if97_pi) {
return -1.0 / sqr (if97_pi);
}
// [d gamma_o / d tau] keeping pi constant
// Checked OK
double if97_r2_GammaTau_o (double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_O; i++) {
dblGammaSum += GIBBS_COEFFS_R2_O[i].ni * GIBBS_COEFFS_R2_O[i].Ji * pow(if97_tau, ( GIBBS_COEFFS_R2_O[i].Ji - 1.0));
}
return dblGammaSum;
}
// [d squared gamma_o / d tau squared] keeping pi constant
double if97_r2_GammaTauTau_o (double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_O; i++) {
dblGammaSum += GIBBS_COEFFS_R2_O[i].ni * GIBBS_COEFFS_R2_O[i].Ji * ( GIBBS_COEFFS_R2_O[i].Ji - 1.0) * pow(if97_tau, ( GIBBS_COEFFS_R2_O[i].Ji - 2.0));
}
return dblGammaSum;
}
// [d squared gamma_o / d pi d tau]
const double if97_r2_GammaPiTau_o = 0.0;
// [d gamma_r / d pi] keeping tau constant
// Checked OK
double if97_r2_GammaPi_r (double if97_pi, double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_R; i++) {
dblGammaSum += GIBBS_COEFFS_R2_R[i].ni * GIBBS_COEFFS_R2_R[i].Ii
* pow( if97_pi, (GIBBS_COEFFS_R2_R[i].Ii - 1.0)) * pow((if97_tau - 0.5), GIBBS_COEFFS_R2_R[i].Ji);
}
return dblGammaSum;
}
// [d squared gamma_r / d pi squared] keeping tau constant
double if97_r2_GammaPiPi_r (double if97_pi, double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_R; i++) {
dblGammaSum += GIBBS_COEFFS_R2_R[i].ni * GIBBS_COEFFS_R2_R[i].Ii * (GIBBS_COEFFS_R2_R[i].Ii - 1.0)
* pow(if97_pi, (GIBBS_COEFFS_R2_R[i].Ii - 2.0)) * pow((if97_tau - 0.5), GIBBS_COEFFS_R2_R[i].Ji);
}
return dblGammaSum;
}
// [d gamma_r / d tau] keeping pi constant
// Checked OK
double if97_r2_GammaTau_r (double if97_pi, double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_R; i++) {
dblGammaSum += GIBBS_COEFFS_R2_R[i].ni * pow( if97_pi, GIBBS_COEFFS_R2_R[i].Ii)
* GIBBS_COEFFS_R2_R[i].Ji * pow((if97_tau - 0.5), (GIBBS_COEFFS_R2_R[i].Ji - 1.0));
}
return dblGammaSum;
}
// [d squared gamma_r / d tau squared] keeping pi constant
// Checked OK
double if97_r2_GammaTauTau_r (double if97_pi, double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_R; i++) {
dblGammaSum += GIBBS_COEFFS_R2_R[i].ni * pow( if97_pi, GIBBS_COEFFS_R2_R[i].Ii) * GIBBS_COEFFS_R2_R[i].Ji
* (GIBBS_COEFFS_R2_R[i].Ji - 1.0)*pow((if97_tau - 0.5), (GIBBS_COEFFS_R2_R[i].Ji - 2.0));
}
return dblGammaSum;
}
// [d squared gamma_r / d tau squared] keeping pi constant
double if97_r2_GammaPiTau_r (double if97_pi, double if97_tau) {
int i;
double dblGammaSum = 0.0;
#pragma omp parallel for reduction(+:dblGammaSum) //handle loop multithreaded
for (i=1; i <= MAX_GIBBS_COEFFS_R2_R; i++) {
dblGammaSum += GIBBS_COEFFS_R2_R[i].ni * GIBBS_COEFFS_R2_R[i].Ii * pow(if97_pi, (GIBBS_COEFFS_R2_R[i].Ii - 1.0))
* GIBBS_COEFFS_R2_R[i].Ji * pow((if97_tau - 0.5), ( GIBBS_COEFFS_R2_R[i].Ji - 1.0));
}
return dblGammaSum;
}
//**********************************************************
//********* REGION 2 PROPERTY EQUATIONS*********************
// specific Gibbs free energy in region 2 (kJ / kg)
double if97_r2_g (double p_MPa , double t_Kelvin) {
double if97pi = p_MPa / PSTAR_R2;
double if97tau = TSTAR_R2 / t_Kelvin;
return IF97_R * t_Kelvin * if97_r2_Gamma(if97pi, if97tau);
}
// specific volume in region 2 (metres cubed per kilogram)
// inputs need to convert to pure SI, hence the ´magic´ numbers
// Checked OK
double if97_r2_v (double p_MPa , double t_Kelvin ){
double if97pi = p_MPa / PSTAR_R2;
double if97tau = TSTAR_R2 / t_Kelvin;
return (IF97_R *1000 * t_Kelvin / (p_MPa * 1e6) ) * if97pi * ( if97_r2_GammaPi_o(if97pi) + if97_r2_GammaPi_r(if97pi, if97tau));
}
// specific internal energy in region 2 (KJ / Kg)
//Checked OK
double if97_r2_u (double p_MPa , double t_Kelvin ){
double if97pi = p_MPa / PSTAR_R2;
double if97tau = TSTAR_R2/t_Kelvin;
return (IF97_R* t_Kelvin ) * ((if97tau * (if97_r2_GammaTau_o(if97tau) + if97_r2_GammaTau_r(if97pi, if97tau)))
- (if97pi * (if97_r2_GammaPi_o(if97pi) + if97_r2_GammaPi_r(if97pi, if97tau)))
);
}
// specific entropy in region 2 (KJ / Kg.K)
// Checked OK
double if97_r2_s (double p_MPa , double t_Kelvin ){
double if97pi = p_MPa / PSTAR_R2;
double if97tau = TSTAR_R2/t_Kelvin;
return (IF97_R ) * (if97tau * (if97_r2_GammaTau_o(if97tau) + if97_r2_GammaTau_r(if97pi,if97tau)) - if97_r2_Gamma(if97pi, if97tau)) ;
}
// specific enthalpy in region 2 (KJ / Kg)
// Checked OK
double if97_r2_h (double p_MPa , double t_Kelvin ){
double if97pi = p_MPa / PSTAR_R2;
double if97tau = TSTAR_R2/t_Kelvin;
return IF97_R * t_Kelvin * if97tau * (if97_r2_GammaTau_o(if97tau) + if97_r2_GammaTau_r(if97pi, if97tau)) ;
}
// specific isobaric heat capacity in region 2 (KJ / Kg.K)
// Checked OK
double if97_r2_Cp (double p_MPa , double t_Kelvin ){
double if97pi = p_MPa / PSTAR_R2;
double if97tau = TSTAR_R2/t_Kelvin;
return (-IF97_R * sqr(if97tau) * (if97_r2_GammaTauTau_o(if97tau) + if97_r2_GammaTauTau_r(if97pi, if97tau))) ;
}
// specific isochoric heat capacity in region 2 (KJ / Kg.K)
double if97_r2_Cv (double p_MPa , double t_Kelvin ){
double if97pi = p_MPa / PSTAR_R2;
double if97tau = TSTAR_R2 / t_Kelvin;
return IF97_R * ((- sqr(if97tau) * (if97_r2_GammaTauTau_o(if97tau) + if97_r2_GammaTauTau_r(if97pi, if97tau))) - (
sqr ( 1.0 + if97pi * if97_r2_GammaPi_r(if97pi, if97tau) - if97tau * if97pi * if97_r2_GammaPiTau_r(if97pi, if97tau))
/ (1.0 - sqr(if97pi) * if97_r2_GammaPiPi_r (if97pi, if97tau)))
) ;
}
// speed of sound in region 2 (m/s)
// inputs need to convert to pure SI, hence the ´magic´ number 1000
double if97_r2_w (double p_MPa , double t_Kelvin ){
double if97pi = p_MPa / PSTAR_R2;
double if97tau = TSTAR_R2/t_Kelvin;
return sqrt( IF97_R * 1000 * t_Kelvin * ((1.0 + 2.0 * if97pi * if97_r2_GammaPi_r(if97pi, if97tau) + sqr(if97pi) * sqr(if97_r2_GammaPi_r(if97pi, if97tau))) /
((1.0 - sqr(if97pi) * if97_r2_GammaPiPi_r(if97pi, if97tau)) +
( sqr ( 1.0 + if97pi * if97_r2_GammaPi_r(if97pi, if97tau) - if97tau * if97pi * if97_r2_GammaPiTau_r(if97pi, if97tau)) /
( sqr(if97tau) * (if97_r2_GammaTauTau_o(if97tau) + if97_r2_GammaTauTau_r(if97pi, if97tau)))
)
)
)
);
}
| 30.210773 | 157 | 0.619767 |
d1b39686168c2807e46ab990159da181eb2a0807 | 209 | h | C | comm/comm_head.h | elfcoda/jhin | 55d80d8b60c0c3e2ef98aa36d7ff795ad9449303 | [
"Apache-2.0"
] | 4 | 2020-07-12T17:08:30.000Z | 2020-07-21T12:43:22.000Z | comm/comm_head.h | elfcoda/jhin | 55d80d8b60c0c3e2ef98aa36d7ff795ad9449303 | [
"Apache-2.0"
] | null | null | null | comm/comm_head.h | elfcoda/jhin | 55d80d8b60c0c3e2ef98aa36d7ff795ad9449303 | [
"Apache-2.0"
] | 2 | 2020-07-13T11:27:37.000Z | 2021-06-09T02:16:30.000Z | #ifndef __COMM_HEAD_H__
#define __COMM_HEAD_H__
#include <iostream>
#include <iomanip>
#include "debug_define.h"
namespace jhin
{
namespace comm
{
} /* namespace comm */
} /* namespace jhin */
#endif
| 11.611111 | 25 | 0.708134 |
d1bb74467d0317fada46246d3485e2e34bdf3f1a | 494 | h | C | aws-cpp-sdk-core/include/aws/core/utils/UnreferencedParam.h | lintonv/aws-sdk-cpp | 15e19c265ffce19d2046b18aa1b7307fc5377e58 | [
"Apache-2.0"
] | 32 | 2021-12-01T04:28:53.000Z | 2022-03-12T18:22:56.000Z | aws-cpp-sdk-core/include/aws/core/utils/UnreferencedParam.h | lintonv/aws-sdk-cpp | 15e19c265ffce19d2046b18aa1b7307fc5377e58 | [
"Apache-2.0"
] | 10 | 2021-12-01T18:35:26.000Z | 2022-02-15T00:32:00.000Z | aws-cpp-sdk-core/include/aws/core/utils/UnreferencedParam.h | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 10 | 2021-12-01T06:59:41.000Z | 2022-02-23T23:37:44.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
// taken from http://stackoverflow.com/questions/3020584/avoid-warning-unreferenced-formal-parameter, ugly but avoids having to #include the definition of an unreferenced struct/class
#if defined (_MSC_VER)
#define AWS_UNREFERENCED_PARAM(x) (&reinterpret_cast<const int &>(x))
#else
#define AWS_UNREFERENCED_PARAM(x) ((void)(x))
#endif // _MSC_VER
| 26 | 183 | 0.740891 |
d1bbca19204ba2cb2d49d757aa017360a213f5c5 | 552 | h | C | Postmates/Location.h | yondonfu/ios-postmates | 96f07f320432bba6f9e084ce48e4af814ec2c341 | [
"MIT"
] | 10 | 2015-10-11T00:08:48.000Z | 2021-08-21T21:36:13.000Z | Postmates/Location.h | yondonfu/ios-postmates | 96f07f320432bba6f9e084ce48e4af814ec2c341 | [
"MIT"
] | 3 | 2017-06-22T04:36:35.000Z | 2018-03-06T10:39:44.000Z | Postmates/Location.h | yondonfu/ios-postmates | 96f07f320432bba6f9e084ce48e4af814ec2c341 | [
"MIT"
] | 4 | 2015-10-11T03:43:23.000Z | 2017-07-14T00:28:00.000Z | //
// Location.h
// PostmatesiOS
//
// Created by Yondon Fu on 10/10/15.
// Copyright © 2015 Cal Hacks Squad. All rights reserved.
//
#import <Foundation/Foundation.h>
@import CoreLocation;
@interface Location : NSObject
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSString *address;
@property (strong, nonatomic) NSString *phoneNumber;
@property (strong, nonatomic) NSString *notes;
@property (assign, nonatomic) CLLocationCoordinate2D coordinates;
- (instancetype)initWithParams:(NSDictionary *)params;
@end
| 23 | 65 | 0.748188 |
d1bce493d007063054c71da5bbef801aa277605e | 775 | h | C | src/visualization/PerspectiveViewport.h | toeb/sine | 96bcde571218f89a2b0b3cc51c19ad2b7be89c13 | [
"MIT"
] | null | null | null | src/visualization/PerspectiveViewport.h | toeb/sine | 96bcde571218f89a2b0b3cc51c19ad2b7be89c13 | [
"MIT"
] | null | null | null | src/visualization/PerspectiveViewport.h | toeb/sine | 96bcde571218f89a2b0b3cc51c19ad2b7be89c13 | [
"MIT"
] | null | null | null | #pragma once
#include <visualization/Viewport.h>
namespace nspace{
class PerspectiveViewport : public virtual Viewport{
REFLECTABLE_OBJECT(PerspectiveViewport);
private:
PROPERTY(CoordinateSystem,Coordinates){}
REFERENCE(public,CoordinateSystem, Coordinates);
PROPERTY(Real, FieldOfViewAngle){}
REFERENCE(public,Real, FieldOfViewAngle);
PROPERTY(Real, NearCutOffPlane){}
REFERENCE(public,Real, NearCutOffPlane);
PROPERTY(Real, FarCutOffPlane){}
REFERENCE(public,Real, FarCutOffPlane);
PROPERTY(Real, ZoomFactor){}
REFERENCE(public,Real, ZoomFactor);
public:
PerspectiveViewport();
void onBeginRender(){viewportTransform();}
protected:
virtual void viewportTransform()=0;
};
} | 26.724138 | 55 | 0.710968 |
d1bdb268fc77c6ccb24022226735f5f2b45071dd | 749 | h | C | include/scgapi/Session.h | Syniverse-SCG/Messaging-C-Plus-Plus | 8b5b9ebc48a2a86664bbdf43255d08c033d3f6fe | [
"MIT"
] | 1 | 2019-12-05T08:42:03.000Z | 2019-12-05T08:42:03.000Z | include/scgapi/Session.h | Syniverse-SCG/Messaging-C-Plus-Plus | 8b5b9ebc48a2a86664bbdf43255d08c033d3f6fe | [
"MIT"
] | null | null | null | include/scgapi/Session.h | Syniverse-SCG/Messaging-C-Plus-Plus | 8b5b9ebc48a2a86664bbdf43255d08c033d3f6fe | [
"MIT"
] | 1 | 2022-02-22T17:15:35.000Z | 2022-02-22T17:15:35.000Z |
#pragma once
#ifndef SCGAIP_SESSION_H_
#define SCGAIP_SESSION_H_
#include <memory>
#include <string>
namespace scg_api {
class AuthInfo;
/*! Session handle for requests to the SCG API server.
*
*/
class Session {
protected:
Session() = default;
public:
Session(const Session&) = delete;
Session(const Session&&) = delete;
virtual ~Session() = default;
void operator = (const Session&) = delete;
void operator = (const Session&&) = delete;
virtual Scg& GetParent() = 0;
virtual const std::string& GetUrl() const = 0;
virtual std::string GetToken() const = 0;
virtual restc_cpp::Context& GetContext() = 0;
virtual AuthInfo& GetAuth() = 0;
};
} // namespace scg_api
#endif // SCGAIP_SESSION_H_
| 18.725 | 54 | 0.670227 |
d1bfc45965ea42b9d6f9eb0b05771fc8b29232eb | 6,105 | h | C | src/CMD.h | m5stack/UNIT_UHF_RFID | 5711c16e921a404ca01bb0ac106fd1db1f784679 | [
"MIT"
] | null | null | null | src/CMD.h | m5stack/UNIT_UHF_RFID | 5711c16e921a404ca01bb0ac106fd1db1f784679 | [
"MIT"
] | null | null | null | src/CMD.h | m5stack/UNIT_UHF_RFID | 5711c16e921a404ca01bb0ac106fd1db1f784679 | [
"MIT"
] | null | null | null |
//Hardware version 硬件版本
const uint8_t HARDWARE_VERSION_CMD[] = {0xBB, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x7E};
//Single polling instruction 单次轮询指令
const uint8_t POLLING_ONCE_CMD[] = {0xBB, 0x00, 0x22, 0x00, 0x00, 0x22, 0x7E};
//Multiple polling instructions 多次轮询指令
const uint8_t POLLING_MULTIPLE_CMD[] = {0xBB, 0x00, 0x27, 0x00, 0x03, 0x22, 0x27, 0x10, 0x83, 0x7E};
//Set the SELECT mode 设置Select模式
const uint8_t SET_SELECT_MODE_CMD[] = {0xBB, 0x00, 0x12, 0x00, 0x01, 0x01, 0x14, 0x7E};
//Set the SELECT parameter instruction 设置Select参数指令
const uint8_t SET_SELECT_PARAMETER_CMD[] = {0xBB, 0x00, 0x0C, 0x00, 0x13, 0x01, 0x00, 0x00, 0x00, 0x20,0x60, 0x00, 0x30, 0x75, 0x1F, 0xEB, 0x70, 0x5C, 0x59, 0x04, 0xE3, 0xD5, 0x0D, 0x70, 0xAD, 0x7E };
//SELECT OK RESPONSE 选中成功响应帧
const uint8_t SET_SELECT_OK[] = { 0xBB, 0x01, 0x0C, 0x00, 0x01, 0x00, 0x0E, 0x7E};
const uint8_t GET_SELECT_PARAMETER_CMD[] = {0xBB, 0x00, 0x0B, 0x00, 0x00, 0x0B, 0x7E};
const uint8_t READ_STORAGE_CMD[] = {0xBB, 0x00, 0x39, 0x00, 0x09, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x02, 0x45, 0x7E};
const uint8_t READ_STORAGE_ERROR[] = {0xBB, 0x01, 0xFF, 0x00, 0x01, 0x09, 0x0A, 0x7E};
const uint8_t WRITE_STORAGE_CMD[] = {0xBB, 0x00, 0x49, 0x00, 0x0D, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x02, 0x12, 0x34, 0x56, 0x78, 0x6D, 0x7E};
const uint8_t WRITE_STORAGE_ERROR[] = {0xBB, 0x01, 0xFF, 0x00, 0x01, 0x10, 0x0A, 0x7E};
//Set the transmitting power 设置发射功率
const uint8_t SET_TX_POWER[] = {0xBB, 0x00, 0xB6, 0x00, 0x02, 0x07, 0xD0, 0x8F, 0x7E};
// {0xBB, 0x00, 0x28, 0x00, 0x00, 0x28, 0x7E,}, //5. Stop multiple polling instructions 5.停止多次轮询指令
// { 0xBB, 0x00, 0x0C, 0x00, 0x13, 0x01, 0x00, 0x00, 0x00, 0x20,
// 0x60, 0x00, 0x30, 0x75, 0x1F, 0xEB, 0x70, 0x5C, 0x59, 0x04,
// 0xE3, 0xD5, 0x0D, 0x70, 0xAD, 0x7E,
// }, //6.
// {0xBB, 0x00, 0x0B, 0x00, 0x00, 0x0B, 0x7E,}, //7. Get the SELECT parameter 7.获取Select参数
// {0xBB, 0x00, 0x12, 0x00, 0x01, 0x01, 0x14, 0x7E,}, //8. Set the SELECT mode 8.设置Select模式
// { 0xBB, 0x00, 0x39, 0x00, 0x09, 0x00, 0x00, 0xFF, 0xFF, 0x03,
// 0x00, 0x00, 0x00, 0x02, 0x45, 0x7E,
// }, //9. Read label data storage area 9.读标签数据储存区
// { 0xBB, 0x00, 0x49, 0x00, 0x0D, 0x00, 0x00, 0xFF, 0xFF, 0x03,
// 0x00, 0x00, 0x00, 0x02, 0x12, 0x34, 0x56, 0x78, 0x6D, 0x7E,
// }, //10. Write the label data store 10.写标签数据存储区
// { 0xBB, 0x00, 0x82, 0x00, 0x07, 0x00, 0x00, 0xFF,
// 0xFF, 0x02, 0x00, 0x80, 0x09, 0x7E,
// }, //11. Lock the LOCK label data store 11.锁定Lock 标签数据存储区
// { 0xBB, 0x00, 0x65, 0x00, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x67,
// 0x7E,
// }, //12. Inactivate the kill tag 12.灭活kill标签
// {0xBB, 0x00, 0x11, 0x00, 0x02, 0x00, 0xC0, 0xD3, 0x7E,}, //13. Set communication baud rate 13.设置通信波特率
// {0xBB, 0x00, 0x0D, 0x00, 0x00, 0x0D, 0x7E,}, //14. Get parameters related to the Query command 14.获取Query命令相关参数
// {0xBB, 0x00, 0x0E, 0x00, 0x02, 0x10, 0x20, 0x40, 0x7E,}, //15. Set the Query parameter 15.设置Query参数
// {0xBB, 0x00, 0x07, 0x00, 0x01, 0x01, 0x09, 0x7E,}, //16. Set up work area 16.设置工作地区
// {0xBB, 0x00, 0x08, 0x00, 0x00, 0x08, 0x7E,}, //17. Acquire work locations 17.获取工作地区
// {0xBB, 0x00, 0xAB, 0x00, 0x01, 0x01, 0xAC, 0x7E,}, //18. Set up working channel 18.设置工作信道
// {0xBB, 0x00, 0xAA, 0x00, 0x00, 0xAA, 0x7E,}, //19. Get the working channel 19.获取工作信道
// {0xBB, 0x00, 0xAD, 0x00, 0x01, 0xFF, 0xAD, 0x7E,}, //20. Set to automatic frequency hopping mode 20.设置为自动跳频模式
// { 0xBB, 0x00, 0xA9, 0x00, 0x06, 0x05, 0x01, 0x02,
// 0x03, 0x04, 0x05, 0xC3, 0x7E,
// }, //21. Insert the working channel 21.插入工作信道
// {0xBB, 0x00, 0xB7, 0x00, 0x00, 0xB7, 0x7E,}, //22. Acquire transmitting power 22.获取发射功率
// {0xBB, 0x00, 0xB6, 0x00, 0x02, 0x07, 0xD0, 0x8F, 0x7E,}, //23. Set the transmitting power 23.设置发射功率
// {0xBB, 0x00, 0xB0, 0x00, 0x01, 0xFF, 0xB0, 0x7E,}, //24. Set up transmitting continuous carrier 24.设置发射连续载波
// {0xBB, 0x00, 0xF1, 0x00, 0x00, 0xF1, 0x7E,}, //25. Gets the receiving demodulator parameters 25.获取接收解调器参数
// {0xBB, 0x00, 0xF0, 0x00, 0x04, 0x03, 0x06, 0x01, 0xB0, 0xAE, 0x7E,}, //26. Set the receiving demodulator parameters 26.设置接收解调器参数
// {0xBB, 0x00, 0xF2, 0x00, 0x00, 0xF2, 0x7E,}, //27. Test the RF input block signal 27.测试射频输入端阻塞信号
// {0xBB, 0x00, 0xF3, 0x00, 0x00, 0xF3, 0x7E,}, //28. Test the RSSI signal at the RF input 28.测试射频输入端 RSSI 信号
// {0x00},
// {0xBB, 0x00, 0x17, 0x00, 0x00, 0x17, 0x7E,}, //30. Module hibernation 30.模块休眠
// {0xBB, 0x00, 0x1D, 0x00, 0x01, 0x02, 0x20, 0x7E,}, //31. Idle hibernation time of module 31.模块空闲休眠时间
// {0xBB, 0x00, 0x04, 0x00, 0x03, 0x01, 0x01, 0x03, 0x0C, 0x7E,}, //32. The IDLE mode 32. IDLE 模式
// {0xBB, 0x00, 0xE1, 0x00, 0x05, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xE4, 0x7E,}, //33.NXP G2X label supports ReadProtect/Reset ReadProtect command 33.NXP G2X 标签支持 ReadProtect/Reset ReadProtect 指令
// {0xBB, 0x00, 0xE3, 0x00, 0x05, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0xE7, 0x7E,}, //34. The NXP G2X label supports the CHANGE EAS directive 34.NXP G2X 标签支持 Change EAS 指令
// {0xBB, 0x00, 0xE4, 0x00, 0x00, 0xE4, 0x7E,}, //35. The NXP G2X tag supports the EAS_ALARM directive 35.NXP G2X 标签支持 EAS_Alarm 指令
// {0xBB, 0x00, 0xE0, 0x00, 0x06, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xE4, 0x7E,}, //36.NXP G2X label 16bits config-word 36.NXP G2X 标签的 16bits Config-Word
// { 0xBB, 0x00, 0xE5, 0x00, 0x08, 0x00, 0x00, 0xFF,
// 0xFF, 0x01, 0x01, 0x40, 0x00, 0x2D, 0x7E,
// }, //37.Impinj Monza 4 Qt tags support Qt instructions 37.Impinj Monza 4 QT 标签支持 QT 指令
// { 0xBB, 0x00, 0xD3, 0x00, 0x0B, 0x00, 0x00, 0xFF,
// 0xFF, 0x01, 0x03, 0x00, 0x00, 0x01, 0x07, 0x00, 0xE8, 0x7E,
// }, //38.The BlockPermalock directive permanently locks blocks of a user's Block 38.BlockPermalock 指令可以永久锁定用户区的某几个 Block
// };
| 77.278481 | 201 | 0.634562 |
d1c29914385ef4e5aec6e8de4ac64cff3123cce3 | 1,743 | h | C | sys/hp300/dev/acioctl.h | weiss/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | 114 | 2015-01-18T22:55:52.000Z | 2022-02-17T10:45:02.000Z | sys/hp300/dev/acioctl.h | JamesLinus/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | null | null | null | sys/hp300/dev/acioctl.h | JamesLinus/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | 29 | 2015-11-03T22:05:22.000Z | 2022-02-08T15:36:37.000Z | /*
* Copyright (c) 1991 University of Utah.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* %sccs.include.redist.c%
*
* from: Utah $Hdr: acioctl.h 1.1 91/06/19$
*
* @(#)acioctl.h 8.1 (Berkeley) 06/10/93
*/
struct acinfo {
short fmte; /* 1st medium transport elt (picker) */
short nmte; /* # medium transport elts */
short fse; /* 1st storage elt (slot) */
short nse; /* # storage elts */
short fiee; /* 1st import/export elt (mailslot) */
short niee; /* # import/export elts */
short fdte; /* 1st data transport elt (drive) */
short ndte; /* # data transport elts */
};
struct aceltstat {
short eaddr; /* element adress */
char type; /* type of element */
char flags; /* flags */
};
/* types */
#define AC_MTE 0x01 /* picker */
#define AC_SE 0x02 /* slot */
#define AC_IEE 0x03 /* mailslot */
#define AC_DTE 0x04 /* drive */
/* flags */
#define AC_FULL 0x01 /* media present */
#define AC_ERROR 0x04 /* error accessing element */
#define AC_ACCESS 0x08 /* element accessible */
#define AC_INVERT 0x80 /* media inverted prior to insertion */
struct acmove {
short srcelem;
short dstelem;
short flags;
};
struct acbuffer {
char *bufptr;
int buflen;
};
#define ACIOCINIT _IO('A', 0x1) /* init elt status */
#define ACIOCGINFO _IOR('A', 0x2, struct acinfo) /* mode sense */
#define ACIOCGSTAT _IOW('A', 0x3, struct acbuffer) /* read elem status */
#define ACIOCMOVE _IOW('A', 0x4, struct acmove) /* move elem */
#define ACIOCRAWES _IOW('A', 0x5, struct acbuffer) /* raw element stat */
| 28.57377 | 73 | 0.666093 |
d1c2b27ac9674e69a416a77dfaaa8dc1416dee15 | 1,508 | h | C | src/core/RTextLayout.h | ouxianghui/ezcam | 195fb402202442b6d035bd70853f2d8c3f615de1 | [
"MIT"
] | 12 | 2021-03-26T03:23:30.000Z | 2021-12-31T10:05:44.000Z | src/core/RTextLayout.h | 15831944/ezcam | 195fb402202442b6d035bd70853f2d8c3f615de1 | [
"MIT"
] | null | null | null | src/core/RTextLayout.h | 15831944/ezcam | 195fb402202442b6d035bd70853f2d8c3f615de1 | [
"MIT"
] | 9 | 2021-06-23T08:26:40.000Z | 2022-01-20T07:18:10.000Z | /**
* Copyright (c) 2011-2016 by Andrew Mustun. All rights reserved.
*
* This file is part of the QCAD project.
*
* QCAD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QCAD 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 QCAD.
*/
#ifndef RTEXTLAYOUT_H
#define RTEXTLAYOUT_H
#include "core_global.h"
#include <QTextLayout>
#include <QSharedPointer>
#include <QList>
#include <QTransform>
#include "RPainterPath.h"
class QCADCORE_EXPORT RTextLayout {
public:
RTextLayout() {}
RTextLayout(QSharedPointer<QTextLayout> layout, const QTransform& transform, const QColor& color) : layout(layout), transform(transform), color(color) {}
RTextLayout(const QList<RPainterPath>& pps, const QColor& color) : painterPaths(pps), color(color) {}
bool isEmpty() const {
return layout.isNull() && painterPaths.isEmpty();
}
QSharedPointer<QTextLayout> layout;
QTransform transform;
QList<RPainterPath> painterPaths;
QColor color;
};
Q_DECLARE_METATYPE(RTextLayout)
Q_DECLARE_METATYPE(RTextLayout*)
#endif
| 29 | 157 | 0.738064 |
d1c315f9bf812ec4cb48c52e92888d744882d7bb | 6,296 | h | C | src/nanovg_gl_utils.h | styluslabs/nanovgXC | 2a35299edd7412487ef5234a1856a8bedc457f8d | [
"Unlicense"
] | 51 | 2020-06-11T15:44:28.000Z | 2022-03-27T20:49:00.000Z | src/nanovg_gl_utils.h | styluslabs/nanovgXC | 2a35299edd7412487ef5234a1856a8bedc457f8d | [
"Unlicense"
] | 2 | 2021-06-02T20:38:18.000Z | 2022-02-10T09:46:58.000Z | src/nanovg_gl_utils.h | styluslabs/nanovgXC | 2a35299edd7412487ef5234a1856a8bedc457f8d | [
"Unlicense"
] | 3 | 2020-08-07T22:50:11.000Z | 2021-06-12T20:52:09.000Z | //
// Copyright (c) 2020 Stylus Labs - see LICENSE.txt
// based on nanovg:
// Copyright (c) 2013 Mikko Mononen memon@inside.org
//
#ifndef NANOVG_GL_UTILS_H
#define NANOVG_GL_UTILS_H
#ifdef IDE_INCLUDES
// defines and includes to make IDE useful
#include "../example/platform.h"
#define NANOVG_GLES3_IMPLEMENTATION
#include "nanovg_gl.h"
#endif
typedef struct NVGLUframebuffer NVGLUframebuffer;
// Helper function to create GL frame buffer to render to.
NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags);
int nvgluBindFramebuffer(NVGLUframebuffer* fb);
void nvgluSetFramebufferSRGB(int enable);
void nvgluSetFramebufferSize(NVGLUframebuffer* fb, int w, int h, int imageFlags);
void nvgluDeleteFramebuffer(NVGLUframebuffer* fb);
int nvgluGetImageHandle(NVGLUframebuffer* fb);
void nvgluBlitFramebuffer(NVGLUframebuffer* fb, int destFBO);
void nvgluReadPixels(NVGLUframebuffer* fb, void* dest);
// these are provided so that nanovg + nanovg_gl_utils can be used to draw w/o including GL headers
void nvgluBindFBO(int fbo);
void nvgluSetViewport(int x, int y, int w, int h);
void nvgluSetScissor(int x, int y, int w, int h);
void nvgluClear(NVGcolor color);
enum NVGimageFlagsGLU {
NVGLU_NO_NVG_IMAGE = 1<<24, // do not create a nanovg image for the texture
};
#endif // NANOVG_GL_UTILS_H
#ifdef NANOVG_GL_IMPLEMENTATION
struct NVGLUframebuffer {
NVGcontext* ctx;
GLuint fbo;
//GLuint rbo;
GLuint texture;
int image;
int width;
int height;
};
// we'll assume FBO functionality is available (as nanovg-2 doesn't work without it)
static const GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags)
{
GLint defaultFBO;
//GLint defaultRBO;
NVGLUframebuffer* fb = NULL;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO);
//glGetIntegerv(GL_RENDERBUFFER_BINDING, &defaultRBO);
fb = (NVGLUframebuffer*)malloc(sizeof(NVGLUframebuffer));
if (fb == NULL) return NULL;
memset(fb, 0, sizeof(NVGLUframebuffer));
fb->ctx = ctx;
// frame buffer object
glGenFramebuffers(1, &fb->fbo);
if (imageFlags | NVGLU_NO_NVG_IMAGE) {
fb->image = -1;
if (w <= 0 || h <= 0)
return fb;
glBindFramebuffer(GL_FRAMEBUFFER, fb->fbo);
nvgluSetFramebufferSize(fb, w, h, imageFlags);
} else {
glBindFramebuffer(GL_FRAMEBUFFER, fb->fbo);
fb->width = w;
fb->height = h;
fb->image = nvgCreateImageRGBA(ctx, w, h, imageFlags | NVG_IMAGE_FLIPY | NVG_IMAGE_PREMULTIPLIED, NULL);
fb->texture = nvglImageHandle(ctx, fb->image);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb->texture, 0);
}
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
nvgluDeleteFramebuffer(fb);
fb = NULL;
}
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
return fb;
}
// returns previously bound FBO
int nvgluBindFramebuffer(NVGLUframebuffer* fb)
{
int prevFBO = -1;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFBO);
glBindFramebuffer(GL_FRAMEBUFFER, fb->fbo);
return prevFBO;
}
// enable or disable automatic sRGB conversion *if* writing to sRGB framebuffer on desktop GL; for GLES,
// GL_FRAMEBUFFER_SRGB is not available and sRGB conversion is enabled iff framebuffer is sRGB
void nvgluSetFramebufferSRGB(int enable)
{
#if defined(NANOVG_GL2) || defined(NANOVG_GL3)
enable ? glEnable(GL_FRAMEBUFFER_SRGB) : glDisable(GL_FRAMEBUFFER_SRGB);
#endif
}
// assumes nvgluBindFramebuffer() has already been called on fb
void nvgluSetFramebufferSize(NVGLUframebuffer* fb, int w, int h, int imageFlags)
{
GLint internalfmt = imageFlags & NVG_IMAGE_SRGB ? GL_SRGB8_ALPHA8 : GL_RGBA8;
if(w <= 0 || h <= 0 || (w == fb->width && h == fb->height))
return;
if(fb->image >= 0) {
NVG_LOG("nvgluSetFramebufferSize() can only be used with framebuffer created with NVGLU_NO_NVG_IMAGE.");
return;
}
glDeleteTextures(1, &fb->texture);
glGenTextures(1, &fb->texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, fb->texture);
glTexImage2D(GL_TEXTURE_2D, 0, internalfmt, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, w, h, 0, GL_RGBA, GL_HALF_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb->texture, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
fb->width = w;
fb->height = h;
}
// assumes FBO (source) is already bound; destFBO is bounds on return
void nvgluBlitFramebuffer(NVGLUframebuffer* fb, int destFBO)
{
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, destFBO);
glBlitFramebuffer(0, 0, fb->width, fb->height, 0, 0, fb->width, fb->height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
//glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 1, drawBuffers);
glBindFramebuffer(GL_FRAMEBUFFER, destFBO);
}
void nvgluReadPixels(NVGLUframebuffer* fb, void* dest)
{
// for desktop GL, we could use glGetTexImage
glReadPixels(0, 0, fb->width, fb->height, GL_RGBA, GL_UNSIGNED_BYTE, dest);
}
void nvgluBindFBO(int fbo)
{
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
}
void nvgluSetViewport(int x, int y, int w, int h)
{
glViewport(x, y, w, h);
}
void nvgluSetScissor(int x, int y, int w, int h)
{
if(w <= 0 || h <= 0)
glDisable(GL_SCISSOR_TEST);
else {
glEnable(GL_SCISSOR_TEST);
glScissor(x, y, w, h);
}
}
void nvgluClear(NVGcolor color)
{
glClearColor(color.r/255.0f, color.g/255.0f, color.b/255.0f, color.a/255.0f);
glClear(GL_COLOR_BUFFER_BIT);
}
int nvgluGetImageHandle(NVGLUframebuffer* fb)
{
return fb->image;
}
void nvgluDeleteFramebuffer(NVGLUframebuffer* fb)
{
if (fb == NULL) return;
if (fb->fbo != 0)
glDeleteFramebuffers(1, &fb->fbo);
if (fb->image >= 0)
nvgDeleteImage(fb->ctx, fb->image);
else
glDeleteTextures(1, &fb->texture);
fb->ctx = NULL;
fb->fbo = 0;
fb->texture = 0;
fb->image = -1;
free(fb);
}
#endif // NANOVG_GL_IMPLEMENTATION
| 30.862745 | 111 | 0.738247 |
d1c520ba6951539c839adf7be7ee0bc99bfbe0bf | 1,444 | h | C | src/Systems/BulletLogicSystem.h | l-junpu/GAM300_PaperbackEngine | 0f49be9da22b364150f1f3cbf49ac01d25184343 | [
"MIT"
] | null | null | null | src/Systems/BulletLogicSystem.h | l-junpu/GAM300_PaperbackEngine | 0f49be9da22b364150f1f3cbf49ac01d25184343 | [
"MIT"
] | null | null | null | src/Systems/BulletLogicSystem.h | l-junpu/GAM300_PaperbackEngine | 0f49be9da22b364150f1f3cbf49ac01d25184343 | [
"MIT"
] | null | null | null | #pragma once
struct BulletLogicSystem : paperback::system::instance
{
constexpr static auto typedef_v = paperback::system::type::update
{
.m_pName = "BulletLogicSystem"
};
void operator()( paperback::component::entity& Entity, Transform& transform, Timer& timer, Bullet& bullet ) const noexcept
{
if (Entity.IsZombie()) return;
timer.m_Timer -= m_Coordinator.DeltaTime();
if (timer.m_Timer <= 0.0f)
{
m_Coordinator.DeleteEntity(Entity);
return;
}
// Check collisions
tools::query Query;
Query.m_Must.AddFromComponents<Transform>();
m_Coordinator.ForEach( m_Coordinator.Search(Query), [&]( paperback::component::entity& Dynamic_Entity, Transform& xform ) noexcept -> bool
{
assert(Entity.IsZombie() == false );
// Do not check against self
if ( ( &Entity == &Dynamic_Entity) || ( Dynamic_Entity.IsZombie() ) || ( bullet.m_Owner.m_GlobalIndex == Dynamic_Entity.m_GlobalIndex ) ) return false;
constexpr auto min_distance_v = 4;
if ((transform.m_Position - xform.m_Position).getLengthSquared() < min_distance_v * min_distance_v)
{
m_Coordinator.DeleteEntity( Entity );
m_Coordinator.DeleteEntity( Dynamic_Entity );
return true;
}
return false;
});
}
}; | 34.380952 | 163 | 0.599723 |
d1c61e5d896f420562b10527bd0f7e6dd3fa4966 | 3,262 | h | C | include/bb/cascades/resources/multiselecthandler.h | blackberry/BB10-UnitTestMocks | 8642d426a0d36fc7b0168c5ee26547355dfece4c | [
"Apache-2.0"
] | null | null | null | include/bb/cascades/resources/multiselecthandler.h | blackberry/BB10-UnitTestMocks | 8642d426a0d36fc7b0168c5ee26547355dfece4c | [
"Apache-2.0"
] | null | null | null | include/bb/cascades/resources/multiselecthandler.h | blackberry/BB10-UnitTestMocks | 8642d426a0d36fc7b0168c5ee26547355dfece4c | [
"Apache-2.0"
] | 2 | 2019-02-15T19:12:12.000Z | 2020-12-31T05:04:15.000Z | /*
Copyright 2013 Research In Motion Limited
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 cascades_multiselecthandler_h
#define cascades_multiselecthandler_h
#include "gmock/gmock.h"
#include <bb/cascades/bbcascades_global.h>
#include <bb/cascades/core/uiobject.h>
#include <bb/cascades/resources/actionitem.h>
namespace bb {
namespace cascades {
class MultiSelectActionItem;
class MultiSelectHandlerPrivate;
class VisualNode;
class MultiSelectHandler : public UIObject
{
public:
MultiSelectHandler(VisualNode* parent = 0);
virtual ~MultiSelectHandler();
MOCK_CONST_METHOD0(isActive, bool ());
MOCK_METHOD1(setActive, void (bool active));
MOCK_METHOD0(resetActive, void ());
MOCK_CONST_METHOD0(actionCount, int ());
MOCK_CONST_METHOD1(actionAt, bb::cascades::AbstractActionItem* (int index));
MOCK_METHOD1(addAction, void (bb::cascades::AbstractActionItem* action));
MOCK_METHOD1(removeAction, bool (bb::cascades::AbstractActionItem* action));
MOCK_METHOD0(removeAllActions, void ());
MOCK_CONST_METHOD0(status, QString ());
MOCK_METHOD1(setStatus, void (const QString& status));
MOCK_METHOD0(resetStatus, void ());
MOCK_METHOD1(activeChanged, void (bool active));
MOCK_METHOD1(actionAdded, void (bb::cascades::AbstractActionItem *action));
MOCK_METHOD1(actionRemoved, void (bb::cascades::AbstractActionItem *action));
MOCK_METHOD1(statusChanged, void (const QString& status));
MOCK_METHOD0(canceled, void ());
public:
typedef MultiSelectHandler ThisClass;
typedef UIObject BaseClass;
template <typename BuilderType, typename BuiltType>
class TBuilder : public BaseClass::TBuilder<BuilderType, BuiltType>
{
protected:
TBuilder(BuiltType* node) : BaseClass::TBuilder<BuilderType, BuiltType>(node) {}
public:
BuilderType& addAction(AbstractActionItem *action)
{
this->instance().addAction(action);
return this->builder();
}
BuilderType& status(const QString& status)
{
this->instance().setStatus(status);
return this->builder();
}
};
class Builder : public TBuilder<Builder, MultiSelectHandler>
{
public:
Builder(VisualNode* target) : TBuilder<Builder, MultiSelectHandler>(new MultiSelectHandler(target)) {}
};
static Builder create(VisualNode* target)
{
return Builder(target);
}
};
}
}
#endif
| 40.271605 | 115 | 0.651441 |
d1c9d34f7842a0ae419ac601083a34454c93a35a | 1,391 | h | C | Chaos2D/src/Chaos2D/Log.h | 2020wmarvil/Chaos2D | 1f327c867d8cc172785e87f4021894477834b998 | [
"MIT"
] | null | null | null | Chaos2D/src/Chaos2D/Log.h | 2020wmarvil/Chaos2D | 1f327c867d8cc172785e87f4021894477834b998 | [
"MIT"
] | null | null | null | Chaos2D/src/Chaos2D/Log.h | 2020wmarvil/Chaos2D | 1f327c867d8cc172785e87f4021894477834b998 | [
"MIT"
] | null | null | null | #pragma once
#include "Core.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/fmt/ostr.h"
namespace Chaos2D {
class CHAOS2D_API Log {
public:
static void Init();
inline static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
inline static std::shared_ptr<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
private:
static std::shared_ptr<spdlog::logger> s_CoreLogger;
static std::shared_ptr<spdlog::logger> s_ClientLogger;
};
}
// core log macros
#define CH2_CORE_TRACE(...) ::Chaos2D::Log::GetCoreLogger()->trace(__VA_ARGS__)
#define CH2_CORE_INFO(...) ::Chaos2D::Log::GetCoreLogger()->info(__VA_ARGS__)
#define CH2_CORE_WARN(...) ::Chaos2D::Log::GetCoreLogger()->warn(__VA_ARGS__)
#define CH2_CORE_ERROR(...) ::Chaos2D::Log::GetCoreLogger()->error(__VA_ARGS__)
#define CH2_CORE_FATAL(...) ::Chaos2D::Log::GetCoreLogger()->fatal(__VA_ARGS__)
// client log macros
#define CH2_TRACE(...) ::Chaos2D::Log::GetClientLogger()->trace(__VA_ARGS__)
#define CH2_INFO(...) ::Chaos2D::Log::GetClientLogger()->info(__VA_ARGS__)
#define CH2_WARN(...) ::Chaos2D::Log::GetClientLogger()->warn(__VA_ARGS__)
#define CH2_ERROR(...) ::Chaos2D::Log::GetClientLogger()->error(__VA_ARGS__)
#define CH2_FATAL(...) ::Chaos2D::Log::GetClientLogger()->fatal(__VA_ARGS__)
| 40.911765 | 93 | 0.708124 |
d1cafd318e2aeeff56622023cf3161670c2951de | 5,050 | h | C | src/analyzer.h | nonelse/nullarihyon | ff23cc1f0fd98e09197f3ca228871a1f12c49182 | [
"MIT"
] | null | null | null | src/analyzer.h | nonelse/nullarihyon | ff23cc1f0fd98e09197f3ca228871a1f12c49182 | [
"MIT"
] | null | null | null | src/analyzer.h | nonelse/nullarihyon | ff23cc1f0fd98e09197f3ca228871a1f12c49182 | [
"MIT"
] | null | null | null | #ifndef __ANALYZER_H__
#define __ANALYZER_H__
#include <unordered_map>
#include <set>
#include <clang/Frontend/FrontendActions.h>
#include <clang/AST/ASTConsumer.h>
#include <clang/AST/StmtVisitor.h>
#include <clang/AST/RecursiveASTVisitor.h>
#include "ExpressionNullabilityCalculator.h"
#include "FilteringClause.h"
using namespace clang;
class MethodUtility {
public:
std::set<const clang::ObjCContainerDecl *> enumerateContainers(const clang::ObjCMessageExpr *expr);
};
class NullabilityCheckContext {
const ObjCInterfaceDecl &InterfaceDecl;
const ObjCMethodDecl &MethodDecl;
const BlockExpr *BlockExpr;
public:
NullabilityCheckContext(const ObjCInterfaceDecl &interfaceDecl, const ObjCMethodDecl &methodDecl, const clang::BlockExpr *blockExpr)
: InterfaceDecl(interfaceDecl), MethodDecl(methodDecl), BlockExpr(blockExpr) {}
NullabilityCheckContext(const ObjCInterfaceDecl &interfaceDecl, const ObjCMethodDecl &methodDecl)
: InterfaceDecl(interfaceDecl), MethodDecl(methodDecl), BlockExpr(nullptr) {}
const ObjCInterfaceDecl &getInterfaceDecl() const {
return InterfaceDecl;
}
const ObjCMethodDecl &getMethodDecl() const {
return MethodDecl;
}
const clang::BlockExpr *getBlockExpr() const {
return BlockExpr;
}
QualType getReturnType() const;
NullabilityCheckContext newContextForBlock(const clang::BlockExpr *blockExpr) {
return NullabilityCheckContext(InterfaceDecl, MethodDecl, blockExpr);
}
};
class MethodBodyChecker : public RecursiveASTVisitor<MethodBodyChecker> {
protected:
ASTContext &_ASTContext;
NullabilityCheckContext &_CheckContext;
ExpressionNullabilityCalculator &_NullabilityCalculator;
std::shared_ptr<VariableNullabilityEnvironment> _VarEnv;
Filter &_Filter;
DiagnosticBuilder WarningReport(SourceLocation location, std::set<std::string> &subjects);
DiagnosticBuilder WarningReport(SourceLocation location, std::set<const clang::ObjCContainerDecl *> &subjects);
public:
explicit MethodBodyChecker(ASTContext &astContext,
NullabilityCheckContext &checkContext,
ExpressionNullabilityCalculator &nullabilityCalculator,
std::shared_ptr<VariableNullabilityEnvironment> &env,
Filter &filter)
: _ASTContext(astContext), _CheckContext(checkContext), _NullabilityCalculator(nullabilityCalculator), _VarEnv(env), _Filter(filter) {}
virtual ~MethodBodyChecker() {}
virtual bool VisitDeclStmt(DeclStmt *decl);
virtual bool VisitObjCMessageExpr(ObjCMessageExpr *callExpr);
virtual bool VisitBinAssign(BinaryOperator *assign);
virtual bool VisitReturnStmt(ReturnStmt *retStmt);
virtual bool VisitObjCArrayLiteral(ObjCArrayLiteral *literal);
virtual bool VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *literal);
virtual bool TraverseBlockExpr(BlockExpr *blockExpr);
virtual bool TraverseIfStmt(IfStmt *ifStmt);
virtual bool TraverseBinLAnd(BinaryOperator *land);
virtual bool VisitCStyleCastExpr(CStyleCastExpr *expr);
virtual bool VisitBinaryConditionalOperator(BinaryConditionalOperator *expr);
virtual bool TraverseBinLOr(BinaryOperator *lor) { return RecursiveASTVisitor::TraverseBinLOr(lor); };
virtual bool TraverseUnaryLNot(UnaryOperator *lnot) { return RecursiveASTVisitor::TraverseUnaryLNot(lnot); };
virtual ObjCContainerDecl *InterfaceForSelector(const Expr *receiver, const Selector selector);
virtual std::string MethodNameAsString(const ObjCMessageExpr &messageExpr);
virtual std::string MethodCallSubjectAsString(const ObjCMessageExpr &messageExpr);
virtual std::set<const ObjCContainerDecl *> subjectDecls(const Expr *expr);
};
class LAndExprChecker : public MethodBodyChecker {
public:
explicit LAndExprChecker(ASTContext &astContext,
NullabilityCheckContext &checkContext,
ExpressionNullabilityCalculator &nullabilityCalculator,
std::shared_ptr<VariableNullabilityEnvironment> &env,
Filter &filter)
: MethodBodyChecker(astContext, checkContext, nullabilityCalculator, env, filter) {}
virtual bool TraverseBinLAnd(BinaryOperator *land);
virtual bool TraverseBinLOr(BinaryOperator *lor);
virtual bool TraverseUnaryLNot(UnaryOperator *S);
};
class NullCheckAction : public clang::ASTFrontendAction {
public:
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &Compiler, clang::StringRef InFile);
explicit NullCheckAction() : clang::ASTFrontendAction(), Debug(false), _Filter(Filter()) {}
void setDebug(bool debug) {
Debug = debug;
}
void addFilterClause(std::shared_ptr<FilteringClause> clause) {
_Filter.addClause(clause);
}
private:
bool Debug;
Filter _Filter;
};
#endif
| 39.147287 | 139 | 0.731287 |
d1cc81764d748eb29ea8941a83bb770604ebf7f5 | 346 | c | C | TP2/trapez.c | samirjabbar7/LSD_C_LAB | 2576b48f6fd8a080198b7cb2866a969751a4802e | [
"MIT"
] | null | null | null | TP2/trapez.c | samirjabbar7/LSD_C_LAB | 2576b48f6fd8a080198b7cb2866a969751a4802e | [
"MIT"
] | null | null | null | TP2/trapez.c | samirjabbar7/LSD_C_LAB | 2576b48f6fd8a080198b7cb2866a969751a4802e | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
float fonction(float x)
{
return (x);
}
float trapez(float (*f)(float),float a, float b, int n)
{
float I=0.5*(f(a)+f(b));
float h=(b-a)/n;
float x=a+h;
for(int i=0;i<n-1;i++)
{
I+=f(x);
x+=h;
}
return h*I;
}
int main()
{
float s=trapez(fonction,0,5,1000);
printf("%f",s);
}
| 12.357143 | 55 | 0.537572 |
d1cf7315fbb838fccbc747002505c69a0b32c8f2 | 2,128 | h | C | src/Modules/SplashScreen/SplashScreenModel.h | eegeo/cardboard-vr-integration | 3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260 | [
"BSD-2-Clause"
] | 8 | 2017-07-02T01:14:29.000Z | 2021-06-19T07:14:38.000Z | src/Modules/SplashScreen/SplashScreenModel.h | eegeo/cardboard-vr-demo | 3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260 | [
"BSD-2-Clause"
] | null | null | null | src/Modules/SplashScreen/SplashScreenModel.h | eegeo/cardboard-vr-demo | 3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260 | [
"BSD-2-Clause"
] | 5 | 2018-02-07T07:43:51.000Z | 2020-01-24T12:29:25.000Z | // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
#pragma once
#include <vector>
#include "Types.h"
#include "SceneModel.h"
#include "SceneModelFactory.h"
#include "SceneModelMaterialResource.h"
#include "SceneModelRenderableFilter.h"
namespace Eegeo
{
namespace UI
{
namespace SplashScreen
{
typedef std::vector<Eegeo::Rendering::SceneModels::SceneModelMaterialResource*> TMaterialResources;
class SplashScreenModel : protected Eegeo::NonCopyable
{
private:
Eegeo::Rendering::Filters::SceneModelRenderableFilter& m_sceneModelRenderableFilter;
Rendering::SceneModels::SceneModel* m_pModel;
Eegeo::dv3 m_position;
float m_absoluteHeadingDegrees;
bool m_shouldDisplay;
float m_modelAlpha;
float m_fadeTransitionSpeed;
bool m_isRendering;
TMaterialResources m_materialResources;
void UpdateMaterials();
public:
SplashScreenModel(Eegeo::Rendering::Filters::SceneModelRenderableFilter& sceneModelRenderableFilter,
Rendering::SceneModels::SceneModel* pModel,
TMaterialResources& materialResources,
const Eegeo::dv3& position,
float absoluteHeadingDegrees);
~SplashScreenModel();
void Update(float dt);
const dv3& GetEcefPosition() const;
void SetEcefPosition(const dv3& ecefPosition);
void SetScale(float scale);
float GetAbsoluteHeadingDegrees() const;
void SetAbsoluteHeadingDegrees(float absoluteHeadingDegrees);
Rendering::SceneModels::SceneModel& GetSceneModel() const;
bool GetShouldDisplay() const;
void SetShouldDisplay(bool shouldDisplay);
void SetFadeTransitionSpeed(float speed);
};
}
}
}
| 30.4 | 116 | 0.584586 |
d1d09d2bbc5df99b58ddadeef8e8d8147b95c104 | 35,552 | h | C | Intra/Container/Sequential/String.h | gammaker/Intra | aed1647cd2cf1781ab0976c2809533d0f347e87e | [
"MIT"
] | 8 | 2017-05-22T12:55:40.000Z | 2018-11-11T22:36:56.000Z | Intra/Container/Sequential/String.h | gammaker/Intra | aed1647cd2cf1781ab0976c2809533d0f347e87e | [
"MIT"
] | 1 | 2020-03-14T11:26:17.000Z | 2020-03-14T12:31:11.000Z | Intra/Container/Sequential/String.h | devoln/Intra | aed1647cd2cf1781ab0976c2809533d0f347e87e | [
"MIT"
] | 1 | 2017-10-12T10:03:56.000Z | 2017-10-12T10:03:56.000Z | #pragma once
#include "Cpp/Features.h"
#include "Cpp/Warnings.h"
#include "Cpp/Intrinsics.h"
#include "Utils/Debug.h"
#include "Container/ForwardDecls.h"
#include "Container/Operations.hh"
#include "Concepts/Container.h"
#include "Utils/Span.h"
#include "Utils/StringView.h"
#include "Utils/ArrayAlgo.h"
#include "Memory/Memory.h"
#include "Memory/Allocator.hh"
#include "Range/Special/Unicode.h"
#include "Range/Mutation/Fill.h"
#include "Range/Mutation/Copy.h"
#include "Range/Mutation/ReplaceSubrange.h"
#include "Range/Decorators/TakeUntil.h"
#include "Range/Compositors/Zip.h"
#include "Data/Reflection.h"
#include "StringFormatter.h"
#include "Range/Output/Inserter.h"
INTRA_PUSH_DISABLE_REDUNDANT_WARNINGS
INTRA_WARNING_DISABLE_SIGN_CONVERSION
namespace Intra { namespace Container {
template<typename F, typename T> void Call(F&& f, T&& arg) {f(Cpp::Forward<T>(arg));}
template<typename Char> class GenericString
{
public:
GenericString(const Char* str):
GenericString(str, (str == null)? 0: Utils::CStringLength(str)) {}
forceinline GenericString(null_t=null) {m = {null, 0, SSO_CAPACITY_FIELD_FOR_EMPTY};}
forceinline static GenericString CreateReserve(size_t reservedCapacity)
{
GenericString result;
result.Reserve(reservedCapacity);
return result;
}
explicit GenericString(const Char* str, size_t strLength): GenericString(null)
{
SetLengthUninitialized(strLength);
C::memcpy(Data(), str, strLength*sizeof(Char));
}
explicit forceinline GenericString(const Char* startPtr, const Char* endPtr):
GenericString(startPtr, size_t(endPtr - startPtr)) {}
explicit forceinline GenericString(size_t initialLength, Char filler): GenericString(null)
{SetLength(initialLength, filler);}
template<typename R = StringView, typename AsR = Concepts::RangeOfType<R>,
typename = Meta::EnableIf<
Concepts::IsConsumableRangeOf<AsR, Char>::_ &&
Meta::IsCharType<Concepts::ValueTypeOf<AsR>>::_
>> forceinline GenericString(R&& rhs): GenericString(null)
{
SetLengthUninitialized(Range::Count(rhs));
Range::CopyTo(Range::Forward<R>(rhs), AsRange());
}
forceinline GenericString(const GenericString& rhs):
GenericString(rhs.Data(), rhs.Length()) {}
forceinline GenericString(GenericString&& rhs):
m(rhs.m) {rhs.m.Capacity = SSO_CAPACITY_FIELD_FOR_EMPTY;}
forceinline ~GenericString()
{
if(IsHeapAllocated()) freeLongData();
}
//! Получить диапазон из UTF-32 кодов символов
//UTF8 ByChar() const {return UTF8(Data(), Length());}
//! Получить подстроку, начиная с кодовой единицы с индексом start и заканчивая end.
forceinline GenericStringView<const Char> operator()(
size_t startIndex, size_t endIndex) const
{return View(startIndex, endIndex);}
//! Получить указатель на C-строку для передачи в различные C API.
/**
Полученный указатель временный и может стать некорректным при любой модификации или удалении этого экземпляра класса.
Эту функцию следует использовать осторожно с временными объектами:
const char* cstr = String("a").CStr(); //Ошибка: cstr - висячий указатель.
strcpy(dst, String("a").CStr()); //Ок: указатель до возврата strcpy корректен
**/
const Char* CStr()
{
size_t len = Length();
if(!IsHeapAllocated())
{
mBuffer[len] = '\0';
return mBuffer;
}
RequireSpace(1);
auto data = Data();
data[len] = '\0';
return data;
}
//! Возвращает диапазон символов строки.
//!@{
/**
Возвращаемый диапазон корректен только до тех пор, пока длина строки не изменится или экземпляр класса не будет удалён.
Эту функцию следует использовать осторожно с временными объектами:
auto range = String("a").AsRange(); //Ошибка: range содержит висячие указатели.
foo(String("a").AsRange()); //Ок: диапазон до возврата из foo корректен
**/
forceinline GenericStringView<Char> AsRange() {return {Data(), Length()};}
forceinline GenericStringView<const Char> AsRange() const {return {Data(), Length()};}
forceinline GenericStringView<const Char> AsConstRange() const {return {Data(), Length()};}
//!@}
//! Присваивание строк
//!@{
GenericString& operator=(GenericString&& rhs) noexcept
{
if(this == &rhs) return *this;
if(IsHeapAllocated()) freeLongData();
m = rhs.m;
rhs.m.Capacity = SSO_CAPACITY_FIELD_FOR_EMPTY;
return *this;
}
GenericString& operator=(GenericStringView<const Char> rhs)
{
if(sameRange(rhs)) return *this;
INTRA_DEBUG_ASSERT(!containsView(rhs));
SetLengthUninitialized(0);
SetLengthUninitialized(rhs.Length());
C::memcpy(Data(), rhs.Data(), rhs.Length()*sizeof(Char));
return *this;
}
forceinline GenericString& operator=(const GenericString& rhs)
{return operator=(rhs.AsConstRange());}
forceinline GenericString& operator=(const Char* rhs)
{return operator=(GenericStringView<const Char>(rhs));}
template<typename R> forceinline Meta::EnableIf<
Concepts::IsArrayClass<R>::_,
GenericString&> operator=(R&& rhs)
{return operator=(GenericStringView<const Char>(rhs));}
template<typename R> forceinline Meta::EnableIf<
!Concepts::IsArrayClass<R>::_ &&
Concepts::IsAsConsumableRangeOf<R, Char>::_,
GenericString&> operator=(R&& rhs)
{
SetLengthUninitialized(0);
SetLengthUninitialized(Range::Count(rhs));
Range::CopyTo(Range::Forward<R>(rhs), AsRange());
return *this;
}
GenericString& operator=(null_t)
{
if(IsHeapAllocated()) freeLongData();
resetToEmptySsoWithoutFreeing();
return *this;
}
//!@}
forceinline GenericString& operator+=(StringFormatter<GenericString>& rhs) {return operator+=(*rhs);}
forceinline GenericString& operator+=(Char rhs)
{
const size_t oldLen = Length();
const bool wasAllocated = IsHeapAllocated();
if(!wasAllocated && oldLen < SSO_BUFFER_CAPACITY_CHARS)
{
shortLenIncrement();
mBuffer[oldLen]=rhs;
}
else
{
if(!wasAllocated || getLongCapacity() == oldLen)
Reallocate(oldLen + 1 + oldLen/2);
m.Data[m.Len++] = rhs;
}
return *this;
}
forceinline bool operator==(null_t) const {return Empty();}
forceinline bool operator>(const GenericStringView<const Char>& rhs) const {return View()>rhs;}
forceinline bool operator<(const Char* rhs) const {return View()<rhs;}
forceinline bool operator<(const GenericStringView<const Char>& rhs) const {return View()<rhs;}
//! Убедиться, что буфер строки имеет достаточно свободного места для хранения minCapacity символов.
forceinline void Reserve(size_t minCapacity)
{
if(Capacity() < minCapacity)
Reallocate(minCapacity + Length()/2);
}
//! Изменить ёмкость строки, чтобы вместить newCapacity символов.
void Reallocate(size_t newCapacity)
{
const bool wasAllocated = IsHeapAllocated();
if(!wasAllocated && newCapacity <= SSO_BUFFER_CAPACITY_CHARS) return;
const size_t len = Length();
if(newCapacity < len) newCapacity = len;
Char* newData;
if(newCapacity > SSO_BUFFER_CAPACITY_CHARS)
{
size_t newCapacityInBytes = newCapacity*sizeof(Char);
newData = Memory::GlobalHeap.Allocate(newCapacityInBytes, INTRA_SOURCE_INFO);
newCapacity = newCapacityInBytes/sizeof(Char);
}
else
{
newData = mBuffer;
setShortLength(len);
}
Char* const oldData = m.Data;
const size_t oldLongCapacity = getLongCapacity();
C::memcpy(newData, Data(), len*sizeof(Char));
if(wasAllocated) Memory::GlobalHeap.Free(oldData, oldLongCapacity*sizeof(Char));
if(newData != mBuffer)
{
m.Data = newData;
setLongCapacity(newCapacity);
m.Len = len;
}
}
//! Если ёмкость буфера вмещает больше, чем длина строки более, чем на 20%, она уменьшается, чтобы совпадать с длиной.
forceinline void TrimExcessCapacity()
{if(Capacity() > Length() * 5/4) Reallocate(Length());}
//! Убедиться, что буфер строки имеет достаточно свободного места для добавления minSpace символов в конец.
forceinline void RequireSpace(size_t minSpace) {Reserve(Length() + minSpace);}
//! Установить длину строки в newLen.
//! Если newLen<Length(), то лишние символы отбрасываются.
//! Если newLen>Length(), то новые символы заполняются с помощью filler.
void SetLength(size_t newLen, Char filler='\0')
{
const size_t oldLength = Length();
SetLengthUninitialized(newLen);
if(newLen>oldLength) Range::Fill(View(oldLength, newLen), filler);
}
forceinline void SetCount(size_t newLen, Char filler='\0') {SetLength(newLen, filler);}
//! Установить длину строки в newLen.
//! Если newLen<Length(), то лишние символы отбрасываются.
//! Если newLen>Length(), то новые символы остаются неинициализированными.
forceinline void SetLengthUninitialized(size_t newLen)
{
Reserve(newLen);
if(IsHeapAllocated()) m.Len = newLen;
else setShortLength(newLen);
}
//! Установить длину строки в newLen.
//! Если newLen<Length(), то лишние символы отбрасываются.
//! Если newLen>Length(), то новые символы остаются неинициализированными.
forceinline void SetCountUninitialized(size_t newLen)
{SetLengthUninitialized(newLen);}
//! Количество символов, которое может уместить текущий буфер строки без перераспределения памяти.
forceinline size_t Capacity() const
{return IsHeapAllocated()? getLongCapacity(): SSO_BUFFER_CAPACITY_CHARS;}
forceinline Char* Data() {return IsHeapAllocated()? m.Data: mBuffer;}
forceinline const Char* Data() const {return IsHeapAllocated()? m.Data: mBuffer;}
forceinline Char* End() {return Data()+Length();}
forceinline const Char* End() const {return Data()+Length();}
forceinline Char& operator[](size_t index)
{
INTRA_DEBUG_ASSERT(index < Length());
return Data()[index];
}
forceinline const Char& operator[](size_t index) const
{
INTRA_DEBUG_ASSERT(index < Length());
return Data()[index];
}
forceinline char Get(size_t index, Char defaultChar='\0') const noexcept
{return index < Length()? Data()[index]: defaultChar;}
forceinline bool Empty() const
{return IsHeapAllocated()? m.Len==0: emptyShort();}
forceinline Char& First() {INTRA_DEBUG_ASSERT(!Empty()); return *Data();}
forceinline const Char& First() const {INTRA_DEBUG_ASSERT(!Empty()); return *Data();}
forceinline Char& Last() {INTRA_DEBUG_ASSERT(!Empty()); return Data()[Length()-1];}
forceinline const Char& Last() const {INTRA_DEBUG_ASSERT(!Empty()); return Data()[Length()-1];}
forceinline void PopLast()
{
INTRA_DEBUG_ASSERT(!Empty());
if(IsHeapAllocated()) m.Len--;
else shortLenDecrement();
}
forceinline size_t Length() const
{return IsHeapAllocated()? m.Len: getShortLength();}
forceinline GenericStringView<Char> TakeNone() noexcept {return {Data(), 0};}
forceinline GenericStringView<const Char> TakeNone() const noexcept {return {Data(), 0};}
forceinline GenericStringView<Char> Drop(size_t count=1) noexcept {return AsRange().Drop(count);}
forceinline GenericStringView<const Char> Drop(size_t count=1) const noexcept {return AsRange().Drop(count);}
forceinline GenericStringView<Char> DropLast(size_t count=1) noexcept {return AsRange().DropLast(count);}
forceinline GenericStringView<const Char> DropLast(size_t count=1) const noexcept {return AsRange().DropLast(count);}
forceinline GenericStringView<Char> Take(size_t count) noexcept {return AsRange().Take(count);}
forceinline GenericStringView<const Char> Take(size_t count) const noexcept {return AsRange().Take(count);}
forceinline GenericStringView<Char> Tail(size_t count) noexcept {return AsRange().Tail(count);}
forceinline GenericStringView<const Char> Tail(size_t count) const noexcept {return AsRange().Tail(count);}
//! Заменить все вхождения subStr на newSubStr
static GenericString ReplaceAll(GenericStringView<const Char> str,
GenericStringView<const Char> subStr, GenericStringView<const Char> newSubStr)
{
GenericString result;
Range::CountRange<Char> counter;
Range::MultiReplaceToAdvance(str, counter, RangeOf({Meta::TupleL(subStr, newSubStr)}));
result.SetLengthUninitialized(counter.Counter);
Range::MultiReplaceToAdvance(str, result.AsRange(), RangeOf({Meta::TupleL(subStr, newSubStr)}));
return result;
}
static GenericString ReplaceAll(GenericStringView<const Char> str, Char c, Char newc)
{
if(c==newc) return str;
GenericString result;
result.SetLengthUninitialized(str.Length());
for(size_t i = 0; i<str.Length(); i++)
result[i] = str[i]==c? newc: str[i];
return result;
}
static GenericString MultiReplace(GenericStringView<const Char> str,
CSpan<GenericStringView<const Char>> subStrs,
CSpan<GenericStringView<const Char>> newSubStrs)
{
GenericString result;
Range::CountRange<Char> counter;
Range::MultiReplaceToAdvance(str, counter, Range::Zip(subStrs, newSubStrs));
result.SetLengthUninitialized(counter.Counter);
Range::MultiReplaceTo(str, result, Range::Zip(subStrs, newSubStrs));
return result;
}
//! Повторить строку n раз
static GenericString Repeat(GenericStringView<const Char> str, size_t n)
{
if(str.Empty()) return null;
GenericString result;
result.SetLengthUninitialized(str.Length()*n);
Range::FillPattern(result, str);
return result;
}
forceinline void AddLast(Char c) {operator+=(c);}
//! @defgroup BList_STL_Interface STL-подобный интерфейс для BList
//! Этот интерфейс предназначен для совместимости с обобщённым контейнеро-независимым кодом.
//! Использовать напрямую этот интерфейс не рекомендуется.
//!@{
typedef char* iterator;
typedef const char* const_iterator;
typedef Char value_type;
forceinline Char* begin() {return Data();}
forceinline Char* end() {return Data()+Length();}
forceinline const Char* begin() const {return Data();}
forceinline const Char* end() const {return Data()+Length();}
forceinline void push_back(Char c) {operator+=(c);}
forceinline void reserve(size_t capacity) {Reserve(capacity);}
forceinline void resize(size_t newLength, Char filler='\0') {SetLength(newLength, filler);}
forceinline size_t size() const {return Length();}
forceinline size_t length() const {return Length();}
forceinline const Char* c_str() {return CStr();} //Не const, в отличие от STL
forceinline GenericString substr(size_t start, size_t count) const {return operator()(start, start+count);}
forceinline bool empty() const {return Empty();}
forceinline Char* data() {return Data();}
forceinline const Char* data() const {return Data();}
forceinline GenericString& append(const GenericString& str)
{*this += str.AsRange();}
forceinline GenericString& append(const GenericString& str, size_t subpos, size_t sublen)
{*this += str(subpos, subpos+sublen);}
forceinline GenericString& append(const Char* s)
{*this += GenericStringView<const Char>(s);}
forceinline GenericString& append(const Char* s, size_t n)
{*this += GenericStringView<const Char>(s, n);}
GenericString& append(size_t n, Char c)
{
size_t oldLen = Length();
SetLengthUninitialized(oldLen+n);
Range::Fill(View(oldLen, oldLen+n), c);
}
template<class InputIt> forceinline GenericString& append(InputIt firstIt, InputIt endIt)
{while(firstIt!=endIt) *this += *endIt++;}
forceinline void clear() {SetLengthUninitialized(0);}
//!@}
//! Форматирование строки
//! @param format Строка, содержащая метки <^>, в которые будут подставляться аргументы.
//! @param () Используйте скобки для передачи параметров и указания их форматирования
//! @return Прокси-объект для форматирования, неявно преобразующийся к String.
static forceinline StringFormatter<GenericString> Format(GenericStringView<const Char> format=null)
{return StringFormatter<GenericString>(format);}
//! Формирование строки как конкатенация строковых представлений аргугментов функции.
template<typename... Args> static forceinline GenericString Concat(Args&&... args)
{return StringFormatter<GenericString>(null).Arg(Cpp::Forward<Args>(args)...);}
template<typename Arg> GenericString& operator<<(Arg&& value)
{
const size_t maxLen = Range::MaxLengthOfToString(value);
SetLengthUninitialized(Length() + maxLen);
auto bufferRest = Tail(maxLen);
ToString(bufferRest, Cpp::Forward<Arg>(value));
SetLengthUninitialized(Length() - bufferRest.Length());
return *this;
}
forceinline GenericStringView<Char> View()
{return {Data(), Length()};}
forceinline GenericStringView<Char> View(size_t startIndex, size_t endIndex)
{
INTRA_DEBUG_ASSERT(startIndex <= endIndex);
INTRA_DEBUG_ASSERT(endIndex <= Length());
return {Data()+startIndex, Data()+endIndex};
}
forceinline GenericStringView<const Char> View() const
{return {Data(), Length()};}
forceinline GenericStringView<const Char> View(size_t startIndex, size_t endIndex) const
{
INTRA_DEBUG_ASSERT(startIndex <= endIndex);
INTRA_DEBUG_ASSERT(endIndex <= Length());
return {Data()+startIndex, Data()+endIndex};
}
forceinline bool IsHeapAllocated() const {return (m.Capacity & SSO_LONG_BIT_MASK)!=0;}
private:
struct M
{
mutable Char* Data;
size_t Len;
size_t Capacity;
};
union
{
M m;
Char mBuffer[sizeof(M)/sizeof(Char)];
};
enum: size_t
{
SSO_LE = INTRA_PLATFORM_ENDIANESS==INTRA_PLATFORM_ENDIANESS_LittleEndian,
SSO_LONG_BIT_MASK = SSO_LE? //Выбираем бит, который будет означать, выделена ли память в куче. Он должен находиться в последнем элементе mBuffer.
(size_t(1) << (sizeof(size_t)*8-1)): //В little-endian лучше всего подходит старший бит m.Capacity.
1, //В big-endian лучше всего подходит младший бит m.Capacity.
SSO_CAPACITY_MASK = ~SSO_LONG_BIT_MASK,
SSO_CAPACITY_RIGHT_SHIFT = 1-SSO_LE, //В little-endian сдвига нет, а в big-endian нужно убрать младший бит, не относящийся к ёмкости выделенного буфера
SSO_SHORT_SIZE_SHIFT = 1-SSO_LE, //Когда строка размещается в SSO, в последнем элементе mBuffer содержится обратная длина строки. Но в big-endian младший бит занят, поэтому нужен сдвиг
SSO_BUFFER_CAPACITY_CHARS = sizeof(M)/sizeof(Char)-1, //В режиме SSO используется все байты объекта кроме последнего, который может быть только терминирующим нулём
SSO_CAPACITY_FIELD_FOR_EMPTY = SSO_LE? //Значение m.Capacity, соответствующее пустой строке. Нужно для конструктора по уиолчанию
SSO_BUFFER_CAPACITY_CHARS << (sizeof(size_t)-sizeof(Char))*8:
SSO_BUFFER_CAPACITY_CHARS << 1
};
forceinline void setShortLength(size_t len) noexcept
{mBuffer[SSO_BUFFER_CAPACITY_CHARS] = Char((SSO_BUFFER_CAPACITY_CHARS - len) << SSO_SHORT_SIZE_SHIFT);}
forceinline size_t getShortLength() const noexcept
{return SSO_BUFFER_CAPACITY_CHARS - (mBuffer[SSO_BUFFER_CAPACITY_CHARS] >> SSO_SHORT_SIZE_SHIFT);}
forceinline void setLongCapacity(size_t newCapacity) noexcept
{m.Capacity = (newCapacity << SSO_CAPACITY_RIGHT_SHIFT)|SSO_LONG_BIT_MASK;}
forceinline size_t getLongCapacity() const noexcept
{return (m.Capacity & SSO_CAPACITY_MASK) >> SSO_CAPACITY_RIGHT_SHIFT;}
forceinline void shortLenDecrement()
{mBuffer[SSO_BUFFER_CAPACITY_CHARS] = Char(mBuffer[SSO_BUFFER_CAPACITY_CHARS] + (1 << SSO_SHORT_SIZE_SHIFT));}
forceinline void shortLenIncrement()
{mBuffer[SSO_BUFFER_CAPACITY_CHARS] = Char(mBuffer[SSO_BUFFER_CAPACITY_CHARS] - (1 << SSO_SHORT_SIZE_SHIFT));}
forceinline bool emptyShort() const noexcept
{return mBuffer[SSO_BUFFER_CAPACITY_CHARS] == Char(SSO_BUFFER_CAPACITY_CHARS << SSO_SHORT_SIZE_SHIFT);}
forceinline void resetToEmptySsoWithoutFreeing() noexcept
{m.Capacity = SSO_CAPACITY_FIELD_FOR_EMPTY;}
forceinline void freeLongData() noexcept
{Memory::GlobalHeap.Free(m.Data, getLongCapacity()*sizeof(Char));}
forceinline bool containsView(StringView rhs) const noexcept
{return Data() <= rhs.Data() && rhs.Data() < End();}
forceinline bool sameRange(StringView rhs) const noexcept
{return Data() == rhs.Data() && Length() == rhs.Length();}
};
template<typename Char> forceinline
GenericString<Char> operator+(GenericString<Char>&& lhs, GenericStringView<const Char> rhs)
{return Cpp::Move(lhs += rhs);}
template<typename R,
typename Char = Concepts::ValueTypeOfAs<R>
> forceinline Meta::EnableIf<
Concepts::IsArrayClass<R>::_ &&
!Meta::TypeEquals<R, GenericStringView<const Char>>::_,
GenericString<Char>> operator+(GenericString<Char>&& lhs, R&& rhs)
{return Cpp::Move(lhs+=GenericStringView<const Char>(rhs));}
template<typename Char> forceinline
GenericString<Char> operator+(GenericString<Char>&& lhs, Char rhs)
{return Cpp::Move(lhs += rhs);}
#ifdef INTRA_USER_DEFINED_LITERALS_SUPPORT
forceinline String operator ""_s(const char* str, size_t len)
{return String(str, len);}
forceinline WString operator ""_w(const wchar* str, size_t len)
{return WString(str, len);}
forceinline DString operator ""_d(const dchar* str, size_t len)
{return DString(str, len);}
#endif
template<typename T, typename... Args> forceinline String StringOfConsume(T&& value, Args&&... args)
{return String::Format()(Cpp::Forward<T>(value), Cpp::Forward<Args>(args)...);}
template<typename T, typename... Args> forceinline String StringOf(const T& value, Args&&... args)
{return String::Format()(value, Cpp::Forward<Args>(args)...);}
template<typename T, size_t N, typename... Args> forceinline String StringOf(T(&value)[N], Args&&... args)
{return String::Format()(value, Cpp::Forward<Args>(args)...);}
forceinline const String& StringOf(const String& value) {return value;}
forceinline StringView StringOf(const StringView& value) {return value;}
forceinline StringView StringOf(const char* value) {return StringView(value);}
template<size_t N> forceinline StringView StringOf(const char(&value)[N]) {return StringView(value);}
template<typename T, typename... Args> forceinline WString WStringOfConsume(T&& value, Args&&... args)
{return WString::Format()(Cpp::Forward<T>(value), Cpp::Forward<Args>(args)...);}
template<typename T, typename... Args> forceinline WString WStringOf(const T& value, Args&&... args)
{return WString::Format()(value, Cpp::Forward<Args>(args)...);}
forceinline const WString& WStringOf(const WString& value) {return value;}
forceinline WStringView WStringOf(const WStringView& value) {return value;}
forceinline WStringView WStringOf(const wchar* value) {return WStringView(value);}
template<size_t N> forceinline WStringView WStringOf(const wchar(&value)[N]) {return WStringView(value);}
template<typename T, typename... Args> forceinline DString DStringOfConsume(T&& value, Args&&... args)
{return DString::Format()(Cpp::Forward<T>(value), Cpp::Forward<Args>(args)...);}
template<typename T, typename... Args> forceinline DString DStringOf(const T& value, Args&&... args)
{return DString::Format()(value, Cpp::Forward<Args>(args)...);}
forceinline const DString& DStringOf(const DString& value) {return value;}
forceinline DStringView DStringOf(const DStringView& value) {return value;}
forceinline DStringView DStringOf(const dchar* value) {return DStringView(value);}
template<size_t N> forceinline DStringView DStringOf(const dchar(&value)[N]) {return DStringView(value);}
}
using Container::StringOf;
using Container::StringOfConsume;
using Container::WStringOf;
using Container::WStringOfConsume;
using Container::DStringOf;
using Container::DStringOfConsume;
namespace Meta {
template<typename Char>
struct IsTriviallyRelocatable<GenericString<Char>>: TrueType {};
namespace D {
template<typename Char> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>, GenericString<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>&, GenericString<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>&&, GenericString<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericStringView<Char>&, GenericString<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>, const GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>&, const GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<Char>&&, const GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericStringView<Char>&, const GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>, GenericStringView<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>, GenericStringView<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>, GenericStringView<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>, const GenericStringView<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&, GenericStringView<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&, GenericStringView<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&, GenericStringView<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&, const GenericStringView<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&&, GenericStringView<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&&, GenericStringView<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&&, GenericStringView<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&&, const GenericStringView<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericString<Char>&, GenericStringView<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericString<Char>&, GenericStringView<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericString<Char>&, GenericStringView<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericString<Char>&, const GenericStringView<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>, GenericString<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>&, GenericString<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>&&, GenericString<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericStringView<const Char>&, GenericString<Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>, GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>&, GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>&&, GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericStringView<const Char>&, GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>, GenericString<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>&, GenericString<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>&&, GenericString<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericStringView<const Char>&, GenericString<Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>, const GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>&, const GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericStringView<const Char>&&, const GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericStringView<const Char>&, const GenericString<Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>, GenericStringView<const Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>, GenericStringView<const Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>, GenericStringView<const Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>, const GenericStringView<const Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&, GenericStringView<const Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&, GenericStringView<const Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&, GenericStringView<const Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&, const GenericStringView<const Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&&, GenericStringView<const Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&&, GenericStringView<const Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&&, GenericStringView<const Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<GenericString<Char>&&, const GenericStringView<const Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericString<Char>&, GenericStringView<const Char>> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericString<Char>&, GenericStringView<const Char>&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericString<Char>&, GenericStringView<const Char>&&> { typedef GenericString<Char> _; };
template<typename Char> struct CommonTypeRef<const GenericString<Char>&, const GenericStringView<const Char>&> { typedef GenericString<Char> _; };
}
static_assert(TypeEquals<CommonTypeRef<String, StringView>, String>::_, "ERROR!");
static_assert(Concepts::IsSequentialContainer<String>::_, "ERROR!");
static_assert(Concepts::IsDynamicArrayContainer<String>::_, "ERROR!");
static_assert(Meta::IsTriviallySerializable<Concepts::ValueTypeOf<String>>::_, "ERROR!");
}
template<typename Char> GenericString<Char> operator+(GenericStringView<const Char> lhs, GenericStringView<const Char> rhs)
{
GenericString<Char> result;
result.Reserve(lhs.Length()+rhs.Length());
result += lhs;
result += rhs;
return result;
}
template<typename Char> GenericString<Char> operator+(GenericStringView<const Char> lhs, Char rhs)
{
GenericString<Char> result;
result.Reserve(lhs.Length()+1);
result += lhs;
result += rhs;
return result;
}
template<typename Char> GenericString<Char> operator+(Char lhs, GenericStringView<const Char> rhs)
{
GenericString<Char> result;
result.Reserve(1+rhs.Length());
result += lhs;
result += rhs;
return result;
}
template<typename S1, typename S2,
typename Char=Concepts::ElementTypeOfArray<S1>
> forceinline Meta::EnableIf<
Concepts::IsArrayClass<S1>::_ &&
Concepts::IsArrayClass<S2>::_ &&
(Concepts::HasData<S1>::_ ||
Concepts::HasData<S2>::_ ||
Concepts::IsInputRange<S1>::_ ||
Concepts::IsInputRange<S2>::_ ||
Meta::IsArrayType<Meta::RemoveReference<S1>>::_ ||
Meta::IsArrayType<Meta::RemoveReference<S2>>::_) && //Чтобы не конфликтовать с оператором из STL
Meta::TypeEquals<Char, Concepts::ElementTypeOfArray<S2>>::_,
GenericString<Char>> operator+(S1&& lhs, S2&& rhs)
{return GenericStringView<const Char>(lhs)+GenericStringView<const Char>(rhs);}
template<typename S1, typename S2,
typename AsS1 = Concepts::RangeOfType<S1>,
typename AsS2 = Concepts::RangeOfType<S2>,
typename Char = Concepts::ValueTypeOf<AsS1>>
Meta::EnableIf<
(Concepts::IsInputRange<AsS1>::_ ||
Concepts::IsInputRange<AsS2>::_) &&
Concepts::IsConsumableRange<AsS1>::_ &&
Concepts::IsConsumableRange<AsS2>::_ &&
(!Concepts::IsArrayClass<S1>::_ ||
!Concepts::IsArrayClass<S2>::_ ||
!Meta::TypeEquals<Char, Concepts::ElementTypeOfArray<AsS2>>::_),
GenericString<Char>> operator+(S1&& lhs, S2&& rhs)
{
GenericString<Char> result;
result.Reserve(Range::LengthOr0(lhs)+Range::LengthOr0(rhs));
Range::CopyTo(Range::Forward<S1>(lhs), LastAppender(result));
Range::CopyTo(Range::Forward<S2>(rhs), LastAppender(result));
return result;
}
template<typename R,
typename AsR = Concepts::RangeOfType<R>,
typename Char = Concepts::ValueTypeOf<AsR>
> Meta::EnableIf<
Concepts::IsConsumableRange<AsR>::_ &&
//Чтобы не конфликтовать с STL
(!Concepts::Has_data<R>::_ ||
Concepts::HasAsRangeMethod<R>::_ ||
Concepts::IsInputRange<R>::_) &&
Meta::IsCharType<Char>::_,
GenericString<Char>> operator+(R&& lhs, Char rhs)
{
GenericString<Char> result;
result.Reserve(Range::LengthOr0(lhs)+1);
result += Range::Forward<R>(lhs);
result += rhs;
return result;
}
template<typename R, typename Char,
typename Char2 = Concepts::ValueTypeOfAs<R>
> Meta::EnableIf<
Concepts::IsAsConsumableRange<R>::_ &&
//Чтобы не конфликтовать с STL
(!Concepts::Has_data<R>::_ ||
Concepts::HasAsRangeMethod<R>::_ ||
Concepts::IsInputRange<R>::_) &&
Meta::IsCharType<Char2>::_ &&
(Meta::IsCharType<Char>::_ ||
Meta::IsIntegralType<Char>::_),
GenericString<Char2>> operator+(Char lhs, R&& rhs)
{
GenericString<Char2> result;
result.Reserve(1 + Range::LengthOr0(rhs));
result += lhs;
result += Range::Forward<R>(rhs);
return result;
}
static_assert(Concepts::IsAsConsumableRange<String>::_, "ERROR!");
static_assert(Concepts::IsAsConsumableRange<const String>::_, "ERROR!");
static_assert(Concepts::IsSequentialContainer<String>::_, "ERROR!");
static_assert(Concepts::IsSequentialContainer<const String>::_, "ERROR!");
static_assert(Meta::TypeEquals<Concepts::RangeOfType<const String&>, StringView>::_, "ERROR!");
}
INTRA_WARNING_POP
| 42.628297 | 186 | 0.754866 |
d1d0e90a96ca7c302f0c223ffe3dbcd24a954cc2 | 150 | c | C | cil/test/small1/ssa-test2.c | petr-muller/abductor | 4c9199378e847e22660daab5e5843805d4035d0a | [
"Intel",
"Unlicense"
] | 266 | 2015-01-23T16:06:52.000Z | 2022-03-17T19:49:34.000Z | cil/test/small1/ssa-test2.c | petr-muller/abductor | 4c9199378e847e22660daab5e5843805d4035d0a | [
"Intel",
"Unlicense"
] | 93 | 2015-07-31T21:38:04.000Z | 2022-03-24T03:21:34.000Z | cil/test/small1/ssa-test2.c | petr-muller/abductor | 4c9199378e847e22660daab5e5843805d4035d0a | [
"Intel",
"Unlicense"
] | 73 | 2015-01-11T17:06:17.000Z | 2022-02-21T06:20:37.000Z | int g1, g2, g3;
int test2(int a) {
int b;
g1 = g1 + 7;
return b;
}
int test4() {
int a,b;
return test2(4);
}
int main() { return 0; }
| 9.375 | 24 | 0.506667 |
d1d17f08aa989004e49cfcc821db438388293f64 | 1,083 | h | C | thirdparty/jplayer/demuxer_ts.h | Houkime/echo | d115ca55faf3a140bea04feffeb2efdedb0e7f82 | [
"MIT"
] | 675 | 2019-02-07T01:23:19.000Z | 2022-03-28T05:45:10.000Z | thirdparty/jplayer/demuxer_ts.h | Houkime/echo | d115ca55faf3a140bea04feffeb2efdedb0e7f82 | [
"MIT"
] | 843 | 2019-01-25T01:06:46.000Z | 2022-03-16T11:15:53.000Z | thirdparty/jplayer/demuxer_ts.h | Houkime/echo | d115ca55faf3a140bea04feffeb2efdedb0e7f82 | [
"MIT"
] | 83 | 2019-02-20T06:18:46.000Z | 2022-03-20T09:36:09.000Z | #pragma once
#include <map>
#include "bit_buffer.h"
#include "decoder_base.h"
namespace cmpeg
{
class demuxer_ts
{
public:
static const uint8_t PACK_HEADER = 0xBA;
static const uint8_t SYSTEM_HEADER = 0xBB;
static const uint8_t PROGRAM_MAP = 0xBC;
static const uint8_t PRIVATE_1 = 0xBD;
static const uint8_t PADDING = 0xBE;
static const uint8_t PRIVATE_2 = 0xBF;
static const uint8_t AUDIO_1 = 0xC0;
static const uint8_t VIDEO_1 = 0xE0;
static const uint8_t DIRECTORY = 0xFF;
public:
demuxer_ts();
~demuxer_ts();
void connect(uint8_t stream_id, decoder_base* decoder);
void write(const std::vector<uint8_t>& data);
bool parse_packet();
bool resync();
void packet_complete(packet_info* pi);
void packet_start(packet_info* pi, int pts, int payloadlength);
bool packet_add_data(packet_info* pi, int start, int end);
public:
bit_buffer* m_bits;
std::map<int, int> m_pids_to_stream_ids;
std::map<int, packet_info*> m_pes_packet_info;
bool m_guess_video_frame_end;
int m_current_time;
int m_start_time;
};
} | 25.785714 | 65 | 0.724838 |
d1d21bfa62db196bcacd3256e07178ecc1a95924 | 668 | h | C | Wrapping/Python/Pybind11/CodeScraper/PythonUtils.h | v7t/SIMPL | 41c941ac957960ec17d067ffe5c566390c4a2553 | [
"NRL"
] | null | null | null | Wrapping/Python/Pybind11/CodeScraper/PythonUtils.h | v7t/SIMPL | 41c941ac957960ec17d067ffe5c566390c4a2553 | [
"NRL"
] | 2 | 2019-02-23T20:46:12.000Z | 2019-07-11T15:34:13.000Z | Wrapping/Python/Pybind11/CodeScraper/PythonUtils.h | v7t/SIMPL | 41c941ac957960ec17d067ffe5c566390c4a2553 | [
"NRL"
] | null | null | null | #pragma once
#include <QtCore/QString>
#include <QtCore/QRegularExpression>
namespace SIMPL
{
namespace Python
{
static QString fromCamelCase(const QString &s)
{
static QRegularExpression regExp1 {"(.)([A-Z][a-z]+)"};
static QRegularExpression regExp2 {"([a-z0-9])([A-Z])"};
QString result = s;
result.replace(regExp1, "\\1_\\2");
result.replace(regExp2, "\\1_\\2");
return result.toLower();
}
#if 0
static QString toCamelCase(const QString& s)
{
QStringList parts = s.split('_', QString::SkipEmptyParts);
for (int i=1; i<parts.size(); ++i)
{
parts[i].replace(0, 1, parts[i][0].toUpper());
}
return parts.join("");
}
#endif
}
}
| 17.128205 | 60 | 0.646707 |
d1d30894fbfdb911bdf0fa5acd84f9f445fa7d0f | 1,253 | c | C | dias-entre-datas/dias-entre-datas.c | danielsanfr/c-study | 65ee29023b4732bd04fcc67b74d4d69632bbdbb2 | [
"Unlicense"
] | 1 | 2018-01-24T10:36:30.000Z | 2018-01-24T10:36:30.000Z | dias-entre-datas/dias-entre-datas.c | danielsanfr/c-study | 65ee29023b4732bd04fcc67b74d4d69632bbdbb2 | [
"Unlicense"
] | null | null | null | dias-entre-datas/dias-entre-datas.c | danielsanfr/c-study | 65ee29023b4732bd04fcc67b74d4d69632bbdbb2 | [
"Unlicense"
] | null | null | null | #include <stdio.h>
struct _data
{
int dia;
int mes;
int ano;
};
typedef struct _data Data;
int dias_fev(int ano)
{
int x = ano;
if(ano % 100 == 0) x = ano/100;
if(x % 4 == 0) return 29;
else return 28;
}
int dias_ano(int ano)
{
int x = ano;
if(ano % 100 == 0) x = ano/100;
if(x % 4 == 0) return 366;
else return 365;
}
int main ()
{
int i, quant = 0, mes[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31};
int dias;
Data data1, data2;
scanf("%d/%d/%d", &data1.dia, &data1.mes, &data1.ano);
scanf("%d/%d/%d", &data2.dia, &data2.mes, &data2.ano);
if(data1.ano != data2.ano)
{
for(i = data1.ano+1 ; i < data2.ano ;++i)
{
dias = dias_ano(i);
quant += dias;
}
mes[1] = dias_fev(data1.ano);
for(i = data1.mes ; i < 12 ; ++i) quant += mes[i];
quant += (mes[data1.mes-1] - data1.dia);
mes[1] = dias_fev(data2.ano);
for(i = 0 ; i < data2.mes - 1 ; ++i) quant += mes[i];
quant += data2.dia;
printf("%d\n", quant);
}else{
if(data1.mes == data2.mes) printf("%d\n", data2.dia - data1.dia);
else
{
mes[1] = dias_fev(data1.ano);
for(i = data1.mes ; i < data2.mes - 1 ; ++i) quant += mes[i];
quant += mes[data1.mes - 1] - data1.dia;
quant += data2.dia;
printf("%d\n", quant);
}
}
return 0;
}
| 20.209677 | 75 | 0.54988 |
d1d5039e5795aacb6e214b9dfbc92a4b8a0249cf | 1,367 | h | C | NSFKitObjC/Classes/UIKit/UITableView/NSFTableViewHeaderFooterView.h | NSFish/NSFKitObjC | 279887ff0b175fb36b0f600f3e6756167c5ad307 | [
"MIT"
] | 1 | 2019-10-16T18:55:49.000Z | 2019-10-16T18:55:49.000Z | NSFKitObjC/Classes/UIKit/UITableView/NSFTableViewHeaderFooterView.h | NSFish/NSFKitObjC | 279887ff0b175fb36b0f600f3e6756167c5ad307 | [
"MIT"
] | null | null | null | NSFKitObjC/Classes/UIKit/UITableView/NSFTableViewHeaderFooterView.h | NSFish/NSFKitObjC | 279887ff0b175fb36b0f600f3e6756167c5ad307 | [
"MIT"
] | null | null | null | //
// NSFTableViewHeaderFooterView.h
// TQMall
//
// Created by NSFish on 2018/10/24.
// Copyright © 2018年 Hangzhou Xuanchao Technology Co. Ltd. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/**
修正 UITableViewHeaderFooterView 的各种 bug:
- 移除 UITableViewHeaderFooterView 偶现的 Autolayout 警告
- 设置 backgroundView = [UIView new],以保证 backgroundView.backgroundColor 有效
*/
@interface NSFTableViewHeaderFooterView : UITableViewHeaderFooterView
@property (nonatomic, strong, nullable, setter=nsf_setAccessoryView:) UIView *nsf_accessoryView;
/**
设置此 block 会 enable NSFTableViewHeaderFooterView 自带的 UITapGestureRecognizer. 相应地设为 nil 则会 disable UITapGestureRecognizer.
*/
@property (nonatomic, copy, nullable) dispatch_block_t contentViewTapped;
/**
UITableViewHeaderFooterView 会在 layoutSubviews 中修改 textLabelFont 的值导致外部设置无效
这里提供一个 placeholder,在 layoutSubviews 中再进行设置
*/
@property (nonatomic, copy, nullable) UIFont *nsf_textLabelFont;
@property (nonatomic, copy, nullable) UIColor *nsf_textLabelColor;
/**
用于强制指定 textLabel 的左偏移值,为 0 或小于 0 时不与使用。默认为 0。
*/
@property (nonatomic, assign) CGFloat textLabelX;
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END
| 29.717391 | 121 | 0.795903 |
d1d71d7482b76ed9d52339e92dafbbb05c656817 | 1,682 | h | C | apps/fxlab/app/src/main/cpp/effects/descrip/WhiteChorusDescription.h | move2edge/oboe | b920c8161b7aa762a5481a8607c088b1b824e95d | [
"Apache-2.0"
] | 3,008 | 2017-10-02T18:00:40.000Z | 2022-03-31T23:30:31.000Z | love/src/jni/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/WhiteChorusDescription.h | sohrab888000/love-android | fa4751e99a22c64bff51ee820e010f88c893c0e4 | [
"Apache-2.0"
] | 1,085 | 2017-10-23T17:04:22.000Z | 2022-03-31T23:10:19.000Z | love/src/jni/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/WhiteChorusDescription.h | sohrab888000/love-android | fa4751e99a22c64bff51ee820e010f88c893c0e4 | [
"Apache-2.0"
] | 510 | 2017-11-08T18:24:55.000Z | 2022-03-30T06:40:32.000Z | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_FXLAB_WHITECHORUSDESCRIPTION_H
#define ANDROID_FXLAB_WHITECHORUSDESCRIPTION_H
#include "EffectDescription.h"
#include "../WhiteChorusEffect.h"
namespace Effect {
class WhiteChorusDescription : public EffectDescription<WhiteChorusDescription, 3> {
public:
static constexpr std::string_view getName() {
return std::string_view("White Chorus");
}
static constexpr std::string_view getCategory() {
return std::string_view("Delay");
}
static constexpr std::array<ParamType, getNumParams()> getParams() {
return std::array<ParamType, getNumParams()> {
ParamType("Depth (ms)", 1, 30, 10),
ParamType("Delay (ms)", 1, 30, 10),
ParamType("Noise pass", 1, 10, 4),
};
}
template<class iter_type>
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
return _ef<iter_type> {
WhiteChorusEffect<iter_type>{paramArr[0], paramArr[1], paramArr[2]}
};
}
};
} //namespace Effect
#endif //ANDROID_FXLAB_WHITECHORUSDESCRIPTION_H
| 33.64 | 84 | 0.694411 |
d1da00079f3222ef7f735abda6b22b570e646a83 | 318 | h | C | Liquid/src/Liquid/EntryPoint.h | TheJSjostrom/Liquid | 81971d99115097c1565a99afeb6ba9f5255e5ee6 | [
"Apache-2.0"
] | null | null | null | Liquid/src/Liquid/EntryPoint.h | TheJSjostrom/Liquid | 81971d99115097c1565a99afeb6ba9f5255e5ee6 | [
"Apache-2.0"
] | null | null | null | Liquid/src/Liquid/EntryPoint.h | TheJSjostrom/Liquid | 81971d99115097c1565a99afeb6ba9f5255e5ee6 | [
"Apache-2.0"
] | null | null | null | #pragma once
#ifdef LQ_PLATFORM_WINDOWS
extern Liquid::Application* Liquid::CreateApplication();
int main(int argc, char** argv)
{
Liquid::Log::Init();
LQ_CORE_WARN("Initialized Log!");
int a = 2;
LQ_INFO("Hello! Var={0}", 0);
auto app = Liquid::CreateApplication();
app->Run();
delete app;
}
#endif | 14.454545 | 56 | 0.669811 |
d1da14996b5f5d42010f41765506fadb8ca1981c | 7,321 | c | C | cc/src/main.c | capsoid/hab | 9be7a461603adae357dc031b9d1d63d3ed7c46f4 | [
"Apache-2.0"
] | null | null | null | cc/src/main.c | capsoid/hab | 9be7a461603adae357dc031b9d1d63d3ed7c46f4 | [
"Apache-2.0"
] | 1 | 2020-03-05T08:42:50.000Z | 2020-03-05T08:42:50.000Z | cc/src/main.c | capsoid/hab | 9be7a461603adae357dc031b9d1d63d3ed7c46f4 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <kernel.h>
#include <device.h>
#include <misc/__assert.h>
#include <misc/printk.h>
#include <sensor.h>
#include <shell/shell.h>
#include <spi.h>
#include <i2c.h>
#include <stdio.h>
#include <stdlib.h>
#include "cc1101.h"
#include "ieee802154_cc1101.h"
#define PR(fmt, ...) \
shell_fprintf(shell, SHELL_NORMAL, fmt, ##__VA_ARGS__)
#define PR_ERROR(fmt, ...) \
shell_fprintf(shell, SHELL_ERROR, fmt, ##__VA_ARGS__)
#define PR_INFO(fmt, ...) \
shell_fprintf(shell, SHELL_INFO, fmt, ##__VA_ARGS__)
#define PR_WARNING(fmt, ...) \
shell_fprintf(shell, SHELL_WARNING, fmt, ##__VA_ARGS__)
struct device *bme280;
struct device *mpu6050;
struct device *cc1101;
void main(void)
{
int ret;
printk("[%s %s] Hello World from %s!\n", __DATE__, __TIME__, CONFIG_BOARD);
bme280 = device_get_binding("BME280");
if (!bme280)
{
printk("Failed to init BME280!\n");
}
mpu6050 = device_get_binding("MPU6050");
if (!mpu6050)
{
printk("Failed to init MPU6050!\n");
}
cc1101 = device_get_binding("CC1101");
if (!cc1101)
{
printk("Failed to init CC1101!\n");
}
else
{
ret = cc1101_start(cc1101); __ASSERT_NO_MSG(!ret);
ret = cc1101_set_txpower(cc1101, 10); __ASSERT_NO_MSG(!ret);
ret = cc1101_set_channel(cc1101, 0); __ASSERT_NO_MSG(!ret);
}
//__ASSERT(0, "fail\n");
while (1)
{
k_sleep(1000);
}
}
static int cmd_mpu6050_reset(const struct shell *shell, size_t argc, char **argv)
{
struct device *i2c = device_get_binding("I2C_1");
__ASSERT_NO_MSG(i2c);
if (i2c_reg_write_byte(i2c, 0x68, 0x6B, 0x80) < 0) {
printk("Failed to wake up chip.");
}
/*
k_busy_wait(100);
u8_t v;
if (i2c_reg_read_byte(i2c, 0x68, 0x6B, &v) < 0) {
printk("Failed to wake up chip.");
}
*/
k_sleep(10);
if (i2c_reg_write_byte(i2c, 0x68, 0x6B, 0x00) < 0) {
printk("Failed to wake up chip.");
}
return 0;
}
static int cmd_mpu6050_read(const struct shell *shell, size_t argc, char **argv)
{
__ASSERT_NO_MSG(mpu6050);
struct sensor_value temp[3];
if (sensor_sample_fetch(mpu6050))
{
printk("Failed to read data from mpu6050\n.");
}
sensor_channel_get(mpu6050, SENSOR_CHAN_ACCEL_XYZ, &temp[0]);
PR("A X: %d.%06d\n", temp[0].val1, abs(temp[0].val2));
PR("A Y: %d.%06d\n", temp[1].val1, abs(temp[1].val2));
PR("A Z: %d.%06d\n", temp[2].val1, abs(temp[2].val2));
sensor_channel_get(mpu6050, SENSOR_CHAN_GYRO_XYZ, &temp[0]);
PR("G X: %d.%06d\n", temp[0].val1, abs(temp[0].val2));
PR("G Y: %d.%06d\n", temp[1].val1, abs(temp[1].val2));
PR("G Z: %d.%06d\n", temp[2].val1, abs(temp[2].val2));
sensor_channel_get(mpu6050, SENSOR_CHAN_DIE_TEMP, &temp[0]);
PR("T: %d.%06d\n", temp[0].val1, abs(temp[0].val2));
return 0;
}
static int cmd_bme280_read(const struct shell *shell, size_t argc, char **argv)
{
__ASSERT_NO_MSG(bme280);
struct sensor_value temp, press, humidity;
sensor_sample_fetch(bme280);
if (sensor_sample_fetch(bme280))
{
printk("Failed to read data from bm280\n.");
}
sensor_channel_get(bme280, SENSOR_CHAN_AMBIENT_TEMP, &temp);
sensor_channel_get(bme280, SENSOR_CHAN_PRESS, &press);
sensor_channel_get(bme280, SENSOR_CHAN_HUMIDITY, &humidity);
PR("T: %d.%06d; press: %d.%06d; humidity: %d.%06d\n",
temp.val1, temp.val2, press.val1, press.val2,
humidity.val1, humidity.val2);
return 0;
}
static int cmd_cc1101_reset(const struct shell *shell, size_t argc, char **argv)
{
ARG_UNUSED(argc);
ARG_UNUSED(argv);
// cc1101_reset();
return 0;
}
static int cmd_cc1101_init(const struct shell *shell, size_t argc, char **argv)
{
ARG_UNUSED(argc);
ARG_UNUSED(argv);
// cc1101_init("SPI_1", "GPIOA", 3, 0, 2, 1);
return 0;
}
static int cmd_cc1101_rr(const struct shell *shell, size_t argc, char **argv)
{
__ASSERT(argc == 2, "wrong format");
/*
u8_t v;
u8_t reg = atoi(argv[1]);
cc1101_read_reg(reg, &v);
PR("reg %02x = %u\n", reg, v);
*/
return 0;
}
static int cmd_cc1101_tx(const struct shell *shell, size_t argc, char **argv)
{
ARG_UNUSED(argv);
__ASSERT_NO_MSG(cc1101);
cc1101_tx(cc1101, argv[1], strlen(argv[1]) + 1);
return 0;
}
static int cmd_cc1101_wr(const struct shell *shell, size_t argc, char **argv)
{
__ASSERT(argc == 2, "wrong format");
return 0;
}
static void rf_beacon(struct device *dev)
{
int i = 0;
char tmp[10] = {0};
while (1) {
snprintf(tmp, sizeof(tmp), "%d", i++);
printk("tx: '%s'\n", tmp);
cc1101_tx(dev, tmp, strlen(tmp));
k_sleep(1000);
}
}
static int cmd_cc1101_beacon(const struct shell *shell, size_t argc, char **argv)
{
if (argc != 2)
{
printk("wrong format\n");
return 0;
}
static struct beacon_ctx {
K_THREAD_STACK_MEMBER(beacon_stack, CFG_CC1101_RX_STACK_SIZE);
struct k_thread beacon_thread;
} b;
k_thread_create(&b.beacon_thread, b.beacon_stack,
1024,
(k_thread_entry_t)rf_beacon,
cc1101, NULL, NULL, K_PRIO_COOP(2), 0, 0);
k_thread_name_set(&b.beacon_thread, "rf_beacon");
return 0;
}
static int cmd_cc1101_pa(const struct shell *shell, size_t argc, char **argv)
{
if (argc != 2)
{
printk("wrong format\n");
return 0;
}
cc1101_set_txpower(cc1101, atoi(argv[1]));
return 0;
}
static int cmd_cc1101_channel(const struct shell *shell, size_t argc, char **argv)
{
if (argc != 2)
{
printk("wrong format\n");
return 0;
}
cc1101_set_channel(cc1101, atoi(argv[1]));
return 0;
}
SHELL_CREATE_STATIC_SUBCMD_SET(mpu6050_commands)
{
SHELL_CMD(read, NULL, "read mpu6050", cmd_mpu6050_read),
SHELL_CMD(reset, NULL, "reset mpu6050", cmd_mpu6050_reset),
SHELL_SUBCMD_SET_END
};
SHELL_CREATE_STATIC_SUBCMD_SET(bme280_commands)
{
SHELL_CMD(read, NULL, "read bme280", cmd_bme280_read),
SHELL_SUBCMD_SET_END
};
SHELL_CREATE_STATIC_SUBCMD_SET(cc1101_commands)
{
SHELL_CMD(reset, NULL, "reset RF", cmd_cc1101_reset),
SHELL_CMD(init, NULL, "init RF", cmd_cc1101_init),
SHELL_CMD(rr, NULL, "'cc1101 rr <reg>' reads cc1101 <reg> value", cmd_cc1101_rr),
SHELL_CMD(wr, NULL, "'cc1101 wr <reg> <val>' writes cc1101 <reg> with <val>", cmd_cc1101_wr),
SHELL_CMD(tx, NULL, "'cc1101 tx <string>' tx <string>", cmd_cc1101_tx),
SHELL_CMD(beacon, NULL, "'cc1101 beacon <start|stop>' start/stop RF beacon>", cmd_cc1101_beacon),
SHELL_CMD(pa, NULL, "'cc1101 pa <-30|-20|-15|-10|0|5|7|10>' set RT output power (dBm)>", cmd_cc1101_pa),
SHELL_CMD(pa, NULL, "'cc1101 channel <num>' set RF channel>", cmd_cc1101_channel),
SHELL_SUBCMD_SET_END
};
SHELL_CMD_REGISTER(bme280, &bme280_commands, "Control RF chip.", NULL);
SHELL_CMD_REGISTER(cc1101, &cc1101_commands, "Read pressure/temperature/humidity", NULL);
SHELL_CMD_REGISTER(mpu6050, &mpu6050_commands, "Read mpu6050", NULL);
| 25.420139 | 108 | 0.632017 |
d1da83289d8ac64738d8e7328ffb96e0862455d7 | 5,904 | c | C | Distancia/RafaelOliva/src/SerieRxTx.c | lchico/Ejercicios_2018 | 5371ba20bced206a996201140899157c3ed13886 | [
"BSD-3-Clause"
] | null | null | null | Distancia/RafaelOliva/src/SerieRxTx.c | lchico/Ejercicios_2018 | 5371ba20bced206a996201140899157c3ed13886 | [
"BSD-3-Clause"
] | null | null | null | Distancia/RafaelOliva/src/SerieRxTx.c | lchico/Ejercicios_2018 | 5371ba20bced206a996201140899157c3ed13886 | [
"BSD-3-Clause"
] | null | null | null | /*============================================================================
* Autor:R. Oliva
* Proyecto: Proy6 - TP5 CESE ProguP 18.4.2018
* Licencia:
* Fecha: 18.4.18
*===========================================================================*/
/*
* Practice only..
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*==================[inlcusiones]============================================*/
#include "sapi.h" // <= Biblioteca sAPI
#include "cooperativeOs_scheduler.h" //se usa para testear los botones
#include "SerieRxTx.h"
/*==================[macros and definitions]=================================*/
// ------ Private data type declarations ---------------------------
/*==================[declaraciones de funciones internas]====================*/
/*==================[definiciones de datos internos]=======================
*
*/
uint8_t RX_buffer [RX_BUFFER_LENGTH];
uint8_t Tran_buffer[TRAN_BUFFER_LENGTH];
// Punteros de buffers
static uint8_t RXIndex_lectura = 0;
static uint8_t RXIndex_escritura = 0;
static uint8_t TXindice_lectura = 0;
static uint8_t TXindice_escritura = 0;
static uint8_t Error_code = 0;
/*==================[declaraciones de funciones externas]====================*/
void SerieRxTxBufUpdTask(void){
{
uint8_t dato;
// Hay datos para mandar?
if (TXindice_lectura < TXindice_escritura)
{
// UART_USB, Sapi
// void uartWriteByte( uartMap_t uart, uint8_t byte );
uartWriteByte(UART_USB, Tran_buffer[TXindice_lectura]);
TXindice_lectura++;
}
else
{
// No data to send - just reset the buffer index
TXindice_lectura = 0;
TXindice_escritura = 0;
}
// Si se recibe algo..(Sapi)
// bool_t uartReadByte( uartMap_t uart, uint8_t* receivedByte );
if ( uartReadByte(UART_USB, &dato ) != FALSE)
{ // Byte recibido. Escribir byte en buffer de entrada
if (RXIndex_escritura < RX_BUFFER_LENGTH)
{
RX_buffer [ RXIndex_escritura ] = dato; // Guardar dato en buffer
RXIndex_escritura ++; // Inc sin desbordar buffer
}
else
Error_code = ERROR_UART_FULL_BUFF;
}
}
}
/* Funciones anexas de manejo serial.. */
void SerieRxTxBufInit(void){
RXIndex_lectura = 0;
RXIndex_escritura = 0;
TXindice_lectura = 0;
TXindice_escritura = 0;
Error_code = 0;
}
/*------------------------------------------------------------------*-
SerieRxTx_Write_Char_To_Buffer()
Guarda un caracter para transmision en el buffer TX
-*------------------------------------------------------------------*/
void SerieRxTx_Write_Char_To_Buffer(uint8_t txdato)
{
// Write to the buffer *only* if there is space
if (TXindice_escritura < TRAN_BUFFER_LENGTH)
{
Tran_buffer[TXindice_escritura] = txdato;
TXindice_escritura++;
}
else
{
//Buffer lleno
Error_code = ERROR_USART_WRITE_CHAR;
}
}
/*------------------------------------------------------------------*-
SerieRxTx_Write_String_To_Buffer()
Copia un string terminado en '0' al buffer..
-*------------------------------------------------------------------*/
void SerieRxTx_Write_String_To_Buffer(char* str)
{
while (*str != 0)
{
SerieRxTx_Write_Char_To_Buffer((uint8_t)*str);
str++;
}
}
/*------------------------------------------------------------------*-
SerieRxTx_Get_Char_From_Buffer()
Toma (si hay) un caracter del Buffer en software..
si no hay nada, devuelve 0..
-*------------------------------------------------------------------*/
uint8_t SerieRxTx_Get_Char_From_Buffer(uint8_t *ch)
{
/* Hay algo ? */
if (RXIndex_lectura < RXIndex_escritura)
{
*ch = RX_buffer [ RXIndex_lectura ];
RXIndex_lectura ++;
return 1; // Hay nuevo dato
}
else {
RXIndex_lectura=0;
RXIndex_escritura=0;
return 0; // No Hay
}
}
/*==================[definiciones de funciones internas]=====================*/
/*------------------------------------------------------------------*-
---- END OF FILE -------------------------------------------------
-*------------------------------------------------------------------*/
| 31.572193 | 80 | 0.544546 |
d1dc801fca222aa53095d4a122a85aee5422e565 | 1,171 | c | C | src/learn/select_input.c | yuhongye/credis | b97e1a4cc7ab1364b6acd1b085d7c0bf3d00d205 | [
"Apache-2.0"
] | null | null | null | src/learn/select_input.c | yuhongye/credis | b97e1a4cc7ab1364b6acd1b085d7c0bf3d00d205 | [
"Apache-2.0"
] | null | null | null | src/learn/select_input.c | yuhongye/credis | b97e1a4cc7ab1364b6acd1b085d7c0bf3d00d205 | [
"Apache-2.0"
] | null | null | null | #include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
int main() {
char buf[128];
fd_set inputs, testfds;
FD_ZERO(&inputs);
// 把要检测的句柄stdin(0)加入到集合中
FD_SET(0, &inputs);
struct timeval timeout;
int result;
int nread;
while (1) {
testfds = inputs;
timeout.tv_sec = 5;
timeout.tv_usec = 500 * 1000;
result = select(FD_SETSIZE, &testfds, (fd_set *)0, (fd_set *)0, &timeout);
switch (result){
case 0:
printf("timeout\n");
break;
case -1:
perror("select");
exit(1);
default:
if (FD_ISSET(0, &testfds)) {
// 获取从键盘输入的字符数,包括回车
ioctl(0, FIONREAD, &nread);
if (nread == 1) {
printf("keyboard done\n");
exit(0);
}
nread = read(0, buf, nread);
buf[nread] = '\0';
printf("read %d from keyboard: %s", nread, buf);
}
break;
}
}
return 0;
} | 23.897959 | 82 | 0.463706 |
d1dd3b47e12a24a1c2dc51a3a126c1717f3451bb | 2,548 | h | C | inc/evm/opcodes.h | newenclave/evm | 214f744910c0126e8dcb0f3292145a899bccb9a1 | [
"MIT"
] | null | null | null | inc/evm/opcodes.h | newenclave/evm | 214f744910c0126e8dcb0f3292145a899bccb9a1 | [
"MIT"
] | null | null | null | inc/evm/opcodes.h | newenclave/evm | 214f744910c0126e8dcb0f3292145a899bccb9a1 | [
"MIT"
] | null | null | null | #pragma once
#ifndef EVM_OPCODES_H
#define EVM_OPCODES_H
#include <cstdint>
/*
OPCODE TABLE:
00: reserved
01: ipush: push an integer value
02: fpush: push a float value
03: pop: pop the stack
05: iadd: stack[-1] + stack[-2]
06: fadd: floating point stack[-1] + stack[-2]
07: isub: stack[-1] - stack[-2]
08: fsub: floating point stack[-1] - stack[-2]
09: imul: stack[-1] * stack[-2]
0a: fmul: floating point stack[-1] * stack[-2]
0b: idiv: stack[-1] / stack[-2]
0c: fdiv: floating point stack[-1] / stack[-2]
0d: imod: stack[-1] % stack[-2]
c0: call addr, Num:
c1: ret Num:
c2: jmp Addr: set ip to address
c3: jz Addr: set ip to address if the top of the stack is zero
c4: jnz Addr: set ip to address if the top of the stack is not zero
10: loda: load value. stack[ap-value]
11: lodf: load value. stack[fp-value]
12: lods: load value. stack[sp-value]
FE: hlt: stops the machine
FF: reserved
*/
#define ADD_FIELD8(name, value) static const std::uint8_t name = value
namespace evm {
struct op {
ADD_FIELD8(IPSH, 0x01);
ADD_FIELD8(FPSH, 0x02);
ADD_FIELD8(POP, 0x03);
ADD_FIELD8(IADD, 0x05);
ADD_FIELD8(FADD, 0x06);
ADD_FIELD8(ISUB, 0x07);
ADD_FIELD8(FSUB, 0x08);
ADD_FIELD8(IMUL, 0x09);
ADD_FIELD8(FMUL, 0x0A);
ADD_FIELD8(IDIV, 0x0B);
ADD_FIELD8(FDIV, 0x0C);
ADD_FIELD8(IMOV, 0x0D);
ADD_FIELD8(CALL, 0xC0);
ADD_FIELD8(RET, 0xC1);
ADD_FIELD8(JMP, 0xC2);
ADD_FIELD8(JZ, 0xC3);
ADD_FIELD8(JNZ, 0xC4);
ADD_FIELD8(LODA, 0x10);
ADD_FIELD8(LODF, 0x11);
ADD_FIELD8(LODS, 0x12);
ADD_FIELD8(HLT, 0xFE);
};
class machine;
using opcode_call = void(*)(machine *);
inline void nop(machine *) {};
/*
Opcodes
*/
struct opcodes {
static void hlt(machine *M);
static void ipsh(machine *M);
static void fpsh(machine *M);
static void pop(machine *M);
static void iadd(machine *M);
static void isub(machine *M);
static void imul(machine *M);
static void idiv(machine *M);
static void imod(machine *M);
static void fadd(machine *M);
static void fsub(machine *M);
static void fmul(machine *M);
static void fdiv(machine *M);
static void loda(machine *M);
static void lodf(machine *M);
static void lods(machine *M);
static void cal(machine *M);
static void ret(machine *M);
static void jmp(machine *M);
static void jz(machine *M);
static void jnz(machine *M);
static opcode_call get(machine *M);
static std::uint8_t get_count(std::uint8_t);
static const char *get_name(std::uint8_t opcode);
};
}
#endif | 23.376147 | 70 | 0.666013 |
d1df447029ee75e98828ab0a1d9e682c7a7193b1 | 307 | h | C | digitalCurrency/Controllers/我的/viewController/Setting/HelpCenter/HelpCenterMoreViewController.h | CoderWeiLee/digitalCurrenc | 7feaac2306d756f264efa9d67231df13b3bd0125 | [
"Apache-2.0"
] | null | null | null | digitalCurrency/Controllers/我的/viewController/Setting/HelpCenter/HelpCenterMoreViewController.h | CoderWeiLee/digitalCurrenc | 7feaac2306d756f264efa9d67231df13b3bd0125 | [
"Apache-2.0"
] | null | null | null | digitalCurrency/Controllers/我的/viewController/Setting/HelpCenter/HelpCenterMoreViewController.h | CoderWeiLee/digitalCurrenc | 7feaac2306d756f264efa9d67231df13b3bd0125 | [
"Apache-2.0"
] | null | null | null | //
// HelpCenterMoreViewController.h
// digitalCurrency
//
// Created by chu on 2019/8/10.
// Copyright © 2019年 ABC. All rights reserved.
//
#import "BaseViewController.h"
@interface HelpCenterMoreViewController : BaseViewController
@property (nonatomic, strong) NSNumber *cate;
@end
| 19.1875 | 61 | 0.70684 |
d1df45562a91507c5bb9f10733aec58d4316763a | 1,669 | c | C | pktreceiver/src/module.c | luwangli/Agg-Evict | d07a2c5375800b6174557750f62a10d8e79e968c | [
"MIT"
] | 5 | 2019-05-05T06:59:20.000Z | 2020-09-06T06:32:21.000Z | pktreceiver/src/module.c | luwangli/Agg-Evict | d07a2c5375800b6174557750f62a10d8e79e968c | [
"MIT"
] | null | null | null | pktreceiver/src/module.c | luwangli/Agg-Evict | d07a2c5375800b6174557750f62a10d8e79e968c | [
"MIT"
] | 4 | 2019-01-12T22:13:02.000Z | 2021-01-26T06:46:54.000Z | #include <string.h>
#include "module.h"
struct ModuleList _all_modules;
void _module_register(
char const* name,
ModulePtr (*init) (ModuleConfigPtr),
void (*del)(ModulePtr),
void (*execute)(ModulePtr, PortPtr, struct rte_mbuf **, uint32_t),
void (*reset)(ModulePtr),
void (*stats)(ModulePtr, FILE*)) {
struct ModuleList *lst = malloc(sizeof(struct ModuleList));
lst->next = _all_modules.next;
lst->init = init;
lst->del = del;
lst->execute = execute;
lst->reset = reset;
lst->stats = stats;
strncpy(lst->name, name, 255);
// printf("register name = %s\n", name);
// fflush(stdout);
_all_modules.next = lst;
}
static struct ModuleList *module_get(char const *name) {
//printf("1\n");
struct ModuleList *ptr = &_all_modules;
//printf("2\n");
while (ptr) {
// printf("name = %s, ptr->name = %s\n", name, ptr->name);
// fflush(stdout);
if (strcasecmp(name, ptr->name) == 0)
return ptr;
ptr = ptr->next;
//printf("3\n");
}
//printf("4\n");
printf("Failed to find module: %s\n", name);
exit(EXIT_FAILURE);
return 0;
}
ModuleInit module_init_get(char const* name) {
// printf("9\n");fflush(stdout);
return module_get(name)->init;
}
ModuleDelete module_delete_get(char const* name) {
return module_get(name)->del;
}
ModuleExecute module_execute_get(char const* name) {
return module_get(name)->execute;
}
ModuleReset module_reset_get(char const* name) {
return module_get(name)->reset;
}
ModuleStats module_stats_get(char const* name) {
return module_get(name)->stats;
}
| 24.188406 | 74 | 0.619533 |
d1e655fe04a3e9cc714085023ff709ec613f3658 | 288 | h | C | sanfaust/BlinkTextAnimation.h | astagi/sanfaust.ino | 5bc76c81f1f702ff73a50f8aa628a12c3df81bb6 | [
"MIT"
] | 1 | 2016-02-15T00:14:54.000Z | 2016-02-15T00:14:54.000Z | sanfaust/BlinkTextAnimation.h | astagi/sanfaust.ino | 5bc76c81f1f702ff73a50f8aa628a12c3df81bb6 | [
"MIT"
] | null | null | null | sanfaust/BlinkTextAnimation.h | astagi/sanfaust.ino | 5bc76c81f1f702ff73a50f8aa628a12c3df81bb6 | [
"MIT"
] | null | null | null | #pragma once
#include "TextAnimation.h"
typedef unsigned char uint8_t;
class LiquidCrystal;
class BlinkTextAnimation : public TextAnimation {
protected:
void draw(LiquidCrystal &lcd);
public:
BlinkTextAnimation(uint8_t x, uint8_t y, const char *_text, uint8_t len);
};
| 16 | 77 | 0.743056 |
d1e99bc2324c881321c010f0838b668d51ae8b1e | 598 | h | C | ios/RNTipsView.h | yansaid/RNTipsView | e33e2a03a64d5189d5ebc551d6cc8bc1c22fbe4e | [
"MIT"
] | 5 | 2017-04-03T01:52:52.000Z | 2018-10-12T13:53:23.000Z | ios/RNTipsView.h | yansaid/RNTipsView | e33e2a03a64d5189d5ebc551d6cc8bc1c22fbe4e | [
"MIT"
] | null | null | null | ios/RNTipsView.h | yansaid/RNTipsView | e33e2a03a64d5189d5ebc551d6cc8bc1c22fbe4e | [
"MIT"
] | null | null | null | //
// RNTipsView.h
// RNTipsView
//
// Created by yan on 2017/3/24.
// Copyright © 2017年 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, ImageSaveType) {
ImageSaveTypeTemp,
ImageSaveTypeCache,
// Todo:
// save image to photos album
// ImageSaveTypePhoto
};
@interface RNTipsView : UIView
@property (nonatomic, assign) CGFloat lineWidth;
@property (nonatomic, strong) UIColor *lineColor;
@property (nonatomic, assign) ImageSaveType cacheType;
- (NSData *)exportWithRect:(CGRect)rect;
- (void)clear;
@end
| 19.933333 | 54 | 0.719064 |
d1ea9416071b29c6d281576a8038eab43e643863 | 301 | h | C | Example/Pods/DJBase/DJBase/Classes/ThirdParty/LBPhotoBrowser/LBLoadingView.h | yangshiyu666/DJMoudlePersonal | 8d368526e99987c22c929d5ed3f1a8b0a284b554 | [
"MIT"
] | 435 | 2017-09-05T08:43:49.000Z | 2021-11-09T12:13:39.000Z | DAudiobook/Vender(第三方)/LBPhotoBrowser/LBLoadingView.h | liuchangjun9343/DAudiobook | 0266c97b0597110e98bc6f3a6aea078cfac1bad3 | [
"MIT"
] | 33 | 2017-10-02T03:48:26.000Z | 2020-04-24T05:34:24.000Z | DAudiobook/Vender(第三方)/LBPhotoBrowser/LBLoadingView.h | liuchangjun9343/DAudiobook | 0266c97b0597110e98bc6f3a6aea078cfac1bad3 | [
"MIT"
] | 58 | 2017-09-05T09:03:45.000Z | 2021-03-02T08:30:12.000Z | //
// LLBLoadingView.h
// loadingView
//
// Created by llb on 16/10/5.
// Copyright © 2016年 llb. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LBLoadingView : UIView
+ (UILabel *)showText:(NSString *)text toView:(UIView *)superView dismissAfterSecond:(NSTimeInterval)second;
@end
| 18.8125 | 108 | 0.707641 |