hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | 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:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | 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 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | 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:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
935cbab738baaf68e189183d1fa391dde825bb7d | 7,396 | h | C | tests/perf/test_switch.h | ported-pw/zf_log | 604dcbcd538007c912c615f906e92556ec9fbf06 | [
"MIT"
] | 180 | 2015-06-09T07:42:28.000Z | 2022-01-19T01:37:56.000Z | tests/perf/test_switch.h | ported-pw/zf_log | 604dcbcd538007c912c615f906e92556ec9fbf06 | [
"MIT"
] | 40 | 2015-12-04T18:52:21.000Z | 2020-09-26T04:35:57.000Z | tests/perf/test_switch.h | ported-pw/zf_log | 604dcbcd538007c912c615f906e92556ec9fbf06 | [
"MIT"
] | 52 | 2015-06-09T07:42:31.000Z | 2021-09-05T11:40:26.000Z | #pragma once
#define TEST_LIBRARY_ID_zf_log 1
#define TEST_LIBRARY_ID_spdlog 2
#define TEST_LIBRARY_ID_easylog 3
#define TEST_LIBRARY_ID_g3log 4
#define TEST_LIBRARY_ID_glog 5
#define _CONCAT(a, b) a##b
#define CONCAT(a, b) _CONCAT(a, b)
#if TEST_LIBRARY_ID_zf_log == CONCAT(TEST_LIBRARY_ID_, TEST_LIBRARY)
#define TEST_LIBRARY_ZF_LOG
#elif TEST_LIBRARY_ID_spdlog == CONCAT(TEST_LIBRARY_ID_, TEST_LIBRARY)
#define TEST_LIBRARY_SPDLOG
#elif TEST_LIBRARY_ID_easylog == CONCAT(TEST_LIBRARY_ID_, TEST_LIBRARY)
#define TEST_LIBRARY_EASYLOG
#elif TEST_LIBRARY_ID_g3log == CONCAT(TEST_LIBRARY_ID_, TEST_LIBRARY)
#define TEST_LIBRARY_G3LOG
#elif TEST_LIBRARY_ID_glog == CONCAT(TEST_LIBRARY_ID_, TEST_LIBRARY)
#define TEST_LIBRARY_GLOG
#else
#error Unknown test library name
#endif
#define XLOG_STRING_LITERAL "A random string"
#define XLOG_INT_LITERAL 42
/* It's important that values are not const. Otherwise compilers will be able
* to optimize out things that we care about.
*/
extern const char *XLOG_STRING_VALUE;
extern int XLOG_INT_VALUE;
#ifndef TEST_SWITCH_MODULE
const char *XLOG_STRING_VALUE = XLOG_STRING_LITERAL;
int XLOG_INT_VALUE = XLOG_INT_LITERAL;
#endif
#ifdef TEST_FORMAT_SLOW_FUNC
#include <chrono>
#include <thread>
static int XLOG_SLOW_FUNC()
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
return (int)std::hash<std::thread::id>()(std::this_thread::get_id());
}
#endif
#define XLOG_MESSAGE_STR_LITERAL_PRINTF XLOG_STRING_LITERAL
#define XLOG_MESSAGE_STR_LITERAL_CPPFMT XLOG_STRING_LITERAL
#define XLOG_MESSAGE_STR_LITERAL_STREAM XLOG_STRING_LITERAL
#define XLOG_MESSAGE_3INT_VALUES_PRINTF \
"vA: %i, vB: %i, vC: %i", \
XLOG_INT_VALUE, XLOG_INT_VALUE, XLOG_INT_VALUE
#define XLOG_MESSAGE_3INT_VALUES_CPPFMT \
"vA: {}, vB: {}, vC: {}", \
XLOG_INT_VALUE, XLOG_INT_VALUE, XLOG_INT_VALUE
#define XLOG_MESSAGE_3INT_VALUES_STREAM \
"vA: " << XLOG_INT_VALUE << ", vB: " << XLOG_INT_VALUE << \
", vC: " << XLOG_INT_VALUE
#define XLOG_MESSAGE_SLOW_FUNC_PRINTF "%i", XLOG_SLOW_FUNC()
#define XLOG_MESSAGE_SLOW_FUNC_CPPFMT "{}", XLOG_SLOW_FUNC()
#define XLOG_MESSAGE_SLOW_FUNC_STREAM XLOG_SLOW_FUNC()
#ifdef TEST_LIBRARY_ZF_LOG
#include <zf_log.h>
#ifdef TEST_NULL_SINK
#define _XLOG_INIT_SINK() \
zf_log_set_output_v(ZF_LOG_PUT_STD, 0, \
[](const zf_log_message *, void *){})
#else
#define _XLOG_INIT_SINK()
#endif
#ifdef TEST_LOG_OFF
#define _XLOG_INIT_LEVEL() \
zf_log_set_output_level(ZF_LOG_ERROR)
#else
#define _XLOG_INIT_LEVEL()
#endif
static void XLOG_INIT()
{
_XLOG_INIT_SINK();
_XLOG_INIT_LEVEL();
}
#if defined(TEST_FORMAT_INTS)
#define XLOG_STATEMENT() ZF_LOGI(XLOG_MESSAGE_3INT_VALUES_PRINTF)
#elif defined(TEST_FORMAT_SLOW_FUNC)
#define XLOG_STATEMENT() ZF_LOGI(XLOG_MESSAGE_SLOW_FUNC_PRINTF)
#else
#define XLOG_STATEMENT() ZF_LOGI(XLOG_MESSAGE_STR_LITERAL_PRINTF)
#endif
#endif
#ifdef TEST_LIBRARY_SPDLOG
#include <spdlog/spdlog.h>
extern const std::shared_ptr<spdlog::logger> g_logger;
#ifdef TEST_NULL_SINK
class null_sink: public spdlog::sinks::sink
{
public:
void log(const spdlog::details::log_msg &) override {}
void flush() override {}
};
#ifndef TEST_SWITCH_MODULE
const std::shared_ptr<spdlog::logger> g_logger = spdlog::create<null_sink>("null");
#endif
#else
#ifndef TEST_SWITCH_MODULE
const std::shared_ptr<spdlog::logger> g_logger = spdlog::stderr_logger_st("stderr");
#endif
#endif
#ifdef TEST_LOG_OFF
#define _XLOG_INIT_LEVEL() spdlog::set_level(spdlog::level::err)
#else
#define _XLOG_INIT_LEVEL()
#endif
static void XLOG_INIT()
{
_XLOG_INIT_LEVEL();
}
#if defined(TEST_FORMAT_INTS)
#define XLOG_STATEMENT() g_logger->info(XLOG_MESSAGE_3INT_VALUES_CPPFMT)
#elif defined(TEST_FORMAT_SLOW_FUNC)
#define XLOG_STATEMENT() g_logger->info(XLOG_MESSAGE_SLOW_FUNC_CPPFMT)
#else
#define XLOG_STATEMENT() g_logger->info(XLOG_MESSAGE_STR_LITERAL_CPPFMT)
#endif
#endif
#ifdef TEST_LIBRARY_EASYLOG
#ifdef TEST_NULL_SINK
class null_stream {
public:
template<typename T>
null_stream &operator<<(T) { return *this; }
null_stream &operator<<(std::ostream& (*)(std::ostream&)) { return *this; }
};
extern null_stream g_null;
#ifndef TEST_SWITCH_MODULE
null_stream g_null;
#endif
#define ELPP_CUSTOM_COUT g_null
#define _XLOG_INIT_SINK() \
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::ToFile, "false")
#else
#define _XLOG_INIT_SINK()
#endif
#ifdef TEST_LOG_OFF
#define _XLOG_INIT_LEVEL() \
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "false")
#else
#define _XLOG_INIT_LEVEL()
#endif
#define ELPP_THREAD_SAFE
#include <easylogging++.h>
#ifndef TEST_SWITCH_MODULE
INITIALIZE_EASYLOGGINGPP
#endif
static void XLOG_INIT()
{
_XLOG_INIT_SINK();
_XLOG_INIT_LEVEL();
}
#if defined(TEST_FORMAT_INTS)
#define XLOG_STATEMENT() LOG(INFO) << XLOG_MESSAGE_3INT_VALUES_STREAM
#elif defined(TEST_FORMAT_SLOW_FUNC)
#define XLOG_STATEMENT() LOG(INFO) << XLOG_MESSAGE_SLOW_FUNC_STREAM
#else
#define XLOG_STATEMENT() LOG(INFO) << XLOG_MESSAGE_STR_LITERAL_STREAM
#endif
#endif
#ifdef TEST_LIBRARY_G3LOG
#include <g3log/g3log.hpp>
#include <g3log/logworker.hpp>
#ifdef TEST_NULL_SINK
class null_sink
{
public:
void log(const std::string) {}
};
#define _XLOG_INIT_SINK() \
auto worker = g3::LogWorker::createLogWorker(); \
g3::initializeLogging(worker.get()); \
worker->addSink(std::unique_ptr<null_sink>(new null_sink), &null_sink::log);
#else
#define _XLOG_INIT_SINK() \
auto worker = g3::LogWorker::createLogWorker(); \
g3::initializeLogging(worker.get()); \
worker->addDefaultLogger("g3log", "g3log.log");
#endif
#ifdef TEST_LOG_OFF
#ifndef G3_DYNAMIC_LOGGING
#error g3log must be built with G3_DYNAMIC_LOGGING defined
#endif
#define _XLOG_INIT_LEVEL() \
g3::only_change_at_initialization::setLogLevel(INFO, false)
#else
#define _XLOG_INIT_LEVEL()
#endif
static void XLOG_INIT()
{
_XLOG_INIT_SINK();
_XLOG_INIT_LEVEL();
}
#if defined(TEST_FORMAT_INTS)
#define XLOG_STATEMENT() LOGF(INFO, XLOG_MESSAGE_3INT_VALUES_PRINTF)
#elif defined(TEST_FORMAT_SLOW_FUNC)
#define XLOG_STATEMENT() LOGF(INFO, XLOG_MESSAGE_SLOW_FUNC_PRINTF)
#else
#define XLOG_STATEMENT() LOGF(INFO, XLOG_MESSAGE_STR_LITERAL_PRINTF)
#endif
#endif
#ifdef TEST_LIBRARY_GLOG
#include <glog/logging.h>
#ifdef TEST_NULL_SINK
class null_sink: public google::LogSink
{
public:
void send(google::LogSeverity, const char *, const char *, int,
const struct ::tm *, const char *, size_t) override {}
void WaitTillSent() override {}
};
extern null_sink g_sink;
#ifndef TEST_SWITCH_MODULE
null_sink g_sink;
#endif
#define _XLOG_LOG(lvl) LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&g_sink, lvl)
#else
#define _XLOG_LOG(lvl) LOG(lvl)
#endif
#ifdef TEST_LOG_OFF
#define _XLOG_INIT_LEVEL() FLAGS_minloglevel = google::ERROR
#else
#define _XLOG_INIT_LEVEL()
#endif
static void XLOG_INIT()
{
google::InitGoogleLogging("glog");
_XLOG_INIT_LEVEL();
}
#if defined(TEST_FORMAT_INTS)
#define XLOG_STATEMENT() _XLOG_LOG(INFO) << XLOG_MESSAGE_3INT_VALUES_STREAM
#elif defined(TEST_FORMAT_SLOW_FUNC)
#define XLOG_STATEMENT() _XLOG_LOG(INFO) << XLOG_MESSAGE_SLOW_FUNC_STREAM
#else
#define XLOG_STATEMENT() _XLOG_LOG(INFO) << XLOG_MESSAGE_STR_LITERAL_STREAM
#endif
#endif
| 28.77821 | 87 | 0.761763 |
a2450d8aeeadc15124ec376a8ec369780cddb394 | 54,843 | c | C | testsuite/EXP_3/test787.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 34 | 2017-07-04T14:16:12.000Z | 2021-04-22T21:04:43.000Z | testsuite/EXP_3/test787.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 1 | 2017-07-06T03:43:44.000Z | 2017-07-06T03:43:44.000Z | testsuite/EXP_3/test787.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 6 | 2017-07-04T16:30:42.000Z | 2019-10-16T05:37:29.000Z |
/*
CF3
Copyright (c) 2015 ishiura-lab.
Released under the MIT license.
https://github.com/ishiura-compiler/CF3/MIT-LICENSE.md
*/
#include<stdio.h>
#include<stdint.h>
#include<stdlib.h>
#include"test1.h"
volatile int32_t t0 = -1;
int64_t x5 = 2125971270LL;
volatile int64_t x7 = -631LL;
volatile uint64_t x25 = 481187388061913316LLU;
int16_t x28 = INT16_MIN;
uint64_t x31 = UINT64_MAX;
int16_t x40 = -1;
int32_t x47 = 1893;
volatile int8_t x54 = INT8_MIN;
int64_t t14 = -2624LL;
volatile int64_t x64 = -19193251137LL;
int16_t x65 = -1;
uint64_t x67 = 15LLU;
uint8_t x68 = 17U;
int64_t x73 = 1374328123LL;
uint64_t t17 = 269503759LLU;
static volatile uint64_t t18 = 1LLU;
int32_t x92 = -1;
int16_t x106 = -26;
uint32_t x109 = UINT32_MAX;
uint32_t x110 = UINT32_MAX;
int32_t x116 = -1;
int32_t x121 = -8;
volatile int16_t x123 = INT16_MIN;
int32_t x138 = -1;
static uint64_t t31 = 63133735903LLU;
static int8_t x148 = INT8_MIN;
uint64_t x153 = 208421067402290351LLU;
static volatile int32_t x163 = INT32_MIN;
static uint32_t t35 = 8530682U;
volatile int32_t t37 = 0;
volatile uint64_t t38 = 184LLU;
volatile int16_t x181 = INT16_MIN;
int64_t x186 = 4481195146934231436LL;
static uint8_t x193 = 22U;
volatile int64_t t44 = -879LL;
static volatile int16_t x227 = 0;
static int8_t x230 = INT8_MAX;
uint16_t x232 = 1391U;
static uint32_t t48 = 24328885U;
volatile int64_t t49 = -586723501130497LL;
int16_t x240 = -6;
int64_t x243 = INT64_MIN;
int64_t x258 = -1LL;
int32_t x276 = -1;
uint64_t t57 = 24477LLU;
volatile uint32_t x277 = 241818U;
int8_t x278 = -1;
volatile uint64_t x281 = UINT64_MAX;
volatile uint64_t t59 = 9172402017979634417LLU;
uint8_t x286 = 0U;
int32_t x287 = INT32_MIN;
static int64_t t60 = 1884262500LL;
static int16_t x295 = -1;
volatile int64_t t62 = 1011878553LL;
int64_t x329 = -1LL;
int8_t x340 = 62;
uint32_t x342 = UINT32_MAX;
volatile int64_t x353 = -1LL;
int64_t t70 = 6958129223LL;
int16_t x363 = INT16_MAX;
volatile int32_t x368 = INT32_MIN;
int32_t t72 = 90900;
int16_t x371 = INT16_MAX;
static int32_t x376 = -1;
int64_t x389 = INT64_MIN;
volatile int64_t t76 = -2093392448LL;
int16_t x402 = -19;
uint32_t t78 = 31U;
uint32_t x405 = 226788U;
static uint16_t x415 = 18U;
int8_t x424 = -42;
uint64_t x435 = UINT64_MAX;
uint8_t x437 = 1U;
int64_t t86 = 33571711470LL;
volatile uint16_t x445 = 0U;
int64_t x454 = 100565565270LL;
int16_t x462 = 2648;
static int16_t x463 = 0;
uint16_t x465 = 114U;
volatile uint32_t x467 = 446U;
volatile uint32_t t92 = 13916769U;
int8_t x483 = 24;
int8_t x495 = INT8_MIN;
uint32_t x497 = 2U;
uint16_t x509 = 883U;
uint32_t t99 = 104234804U;
uint64_t t101 = 35338352146069270LLU;
volatile int32_t t102 = 605;
int64_t x530 = -1997085550835LL;
uint8_t x532 = 49U;
int16_t x536 = 242;
int32_t t104 = 25;
volatile int16_t x558 = 0;
static volatile int64_t x577 = -1831794537394374142LL;
int16_t x584 = INT16_MAX;
int64_t t112 = 2677LL;
int8_t x585 = -1;
static int8_t x586 = INT8_MIN;
int32_t x589 = INT32_MAX;
volatile int64_t t114 = -11LL;
volatile int64_t t115 = -3692479120190226LL;
volatile int64_t x598 = -1LL;
int16_t x600 = -3061;
volatile int32_t x602 = 738917;
volatile int8_t x611 = -1;
static uint32_t x614 = 39U;
static int32_t x619 = INT32_MIN;
int32_t t120 = -953;
uint32_t t121 = 1696U;
static int64_t x633 = INT64_MIN;
volatile int64_t x641 = -1LL;
volatile int16_t x660 = -1;
uint64_t x663 = 39LLU;
int64_t x669 = -1LL;
int64_t t129 = -63013LL;
volatile int32_t x678 = INT32_MIN;
int64_t x680 = INT64_MAX;
int32_t x681 = -1;
static uint32_t x682 = UINT32_MAX;
int64_t x710 = 799096259188959LL;
static int64_t x724 = INT64_MIN;
uint64_t x725 = 12600LLU;
int32_t x727 = INT32_MIN;
volatile int8_t x730 = INT8_MIN;
int64_t x735 = 663220131769LL;
static int64_t x739 = INT64_MIN;
int16_t x742 = -1;
int64_t x744 = INT64_MAX;
int64_t t144 = -15LL;
volatile int8_t x755 = INT8_MIN;
volatile int32_t x757 = INT32_MIN;
int64_t x758 = 1426969958642LL;
int16_t x774 = INT16_MAX;
int64_t t149 = -95LL;
uint64_t x779 = 107903407346021894LLU;
uint8_t x787 = UINT8_MAX;
static uint64_t x789 = 5172LLU;
volatile uint64_t x793 = 455692LLU;
int64_t x794 = 52745581520529LL;
int16_t x795 = INT16_MAX;
static volatile int32_t x802 = INT32_MIN;
int32_t x815 = INT32_MIN;
int64_t x816 = INT64_MIN;
uint8_t x821 = 32U;
uint64_t x822 = 1032632876944881628LLU;
int64_t x827 = -164210626219LL;
int64_t x833 = -27813773483624LL;
static uint16_t x841 = 28U;
volatile uint32_t t163 = 52U;
uint8_t x857 = UINT8_MAX;
uint32_t t165 = 84525731U;
static int8_t x870 = INT8_MAX;
int64_t x873 = INT64_MAX;
uint32_t t170 = 1524U;
int8_t x893 = 8;
static uint64_t x901 = UINT64_MAX;
static volatile uint64_t t175 = 1LLU;
volatile int64_t x905 = -1LL;
static uint64_t t176 = 15452930281284389LLU;
volatile uint64_t t177 = 434LLU;
int16_t x919 = INT16_MIN;
static int32_t x925 = INT32_MIN;
static int16_t x930 = 24;
uint16_t x931 = 14U;
int32_t x935 = -58769;
static int64_t x940 = INT64_MIN;
int32_t t184 = 50527072;
int64_t x947 = -1LL;
uint8_t x950 = UINT8_MAX;
volatile int64_t t186 = 56102910520719LL;
int64_t x956 = -1LL;
int8_t x965 = 0;
volatile uint32_t x966 = UINT32_MAX;
volatile uint32_t t188 = 331065U;
uint64_t x969 = UINT64_MAX;
int64_t x973 = INT64_MIN;
uint64_t x976 = 26540388531LLU;
uint32_t x984 = 4U;
volatile int64_t t192 = 307198939995070LL;
uint64_t t194 = 26412957636390345LLU;
static uint64_t t197 = 1414981611380LLU;
int16_t x1025 = INT16_MIN;
static volatile uint8_t x1026 = UINT8_MAX;
int64_t t199 = 238LL;
void f0(void) {
uint8_t x1 = 45U;
volatile int32_t x2 = INT32_MIN;
static int32_t x3 = -1;
volatile int8_t x4 = INT8_MIN;
t0 = ((x1+x2)*(x3%x4));
if (t0 != 2147483603) { NG(); } else { ; }
}
void f1(void) {
int8_t x6 = 1;
static uint32_t x8 = 284474U;
int64_t t1 = -34LL;
t1 = ((x5+x6)*(x7%x8));
if (t1 != -1341487872001LL) { NG(); } else { ; }
}
void f2(void) {
static int32_t x9 = INT32_MAX;
int32_t x10 = INT32_MIN;
int64_t x11 = INT64_MIN;
int32_t x12 = 109887;
int64_t t2 = -2113302518087490125LL;
t2 = ((x9+x10)*(x11%x12));
if (t2 != 94721LL) { NG(); } else { ; }
}
void f3(void) {
uint64_t x13 = 18730083345LLU;
int32_t x14 = -119186;
static volatile uint32_t x15 = 64603805U;
static int8_t x16 = -50;
uint64_t t3 = 0LLU;
t3 = ((x13+x14)*(x15%x16));
if (t3 != 1210026952185024995LLU) { NG(); } else { ; }
}
void f4(void) {
static int8_t x17 = INT8_MAX;
int64_t x18 = 55080LL;
static int8_t x19 = INT8_MAX;
int16_t x20 = -1;
static volatile int64_t t4 = 1211872752801725LL;
t4 = ((x17+x18)*(x19%x20));
if (t4 != 0LL) { NG(); } else { ; }
}
void f5(void) {
int32_t x21 = INT32_MAX;
int64_t x22 = INT64_MIN;
static volatile int64_t x23 = INT64_MIN;
int64_t x24 = INT64_MIN;
volatile int64_t t5 = 44109LL;
t5 = ((x21+x22)*(x23%x24));
if (t5 != 0LL) { NG(); } else { ; }
}
void f6(void) {
static int16_t x26 = -1;
int32_t x27 = INT32_MIN;
volatile uint64_t t6 = 2001269320LLU;
t6 = ((x25+x26)*(x27%x28));
if (t6 != 0LLU) { NG(); } else { ; }
}
void f7(void) {
uint8_t x29 = 2U;
static uint16_t x30 = 1755U;
uint32_t x32 = UINT32_MAX;
uint64_t t7 = 8309998LLU;
t7 = ((x29+x30)*(x31%x32));
if (t7 != 0LLU) { NG(); } else { ; }
}
void f8(void) {
int32_t x33 = -5;
static uint32_t x34 = 0U;
int64_t x35 = INT64_MAX;
volatile int16_t x36 = INT16_MIN;
static int64_t t8 = 2075LL;
t8 = ((x33+x34)*(x35%x36));
if (t8 != 140733193224197LL) { NG(); } else { ; }
}
void f9(void) {
uint8_t x37 = 11U;
int16_t x38 = -1;
uint8_t x39 = UINT8_MAX;
volatile int32_t t9 = -1083;
t9 = ((x37+x38)*(x39%x40));
if (t9 != 0) { NG(); } else { ; }
}
void f10(void) {
int8_t x41 = 11;
int64_t x42 = 228462023LL;
int32_t x43 = INT32_MIN;
volatile int32_t x44 = -1;
int64_t t10 = -2129705262LL;
t10 = ((x41+x42)*(x43%x44));
if (t10 != 0LL) { NG(); } else { ; }
}
void f11(void) {
static int8_t x45 = INT8_MAX;
static int8_t x46 = INT8_MAX;
int64_t x48 = -85208343LL;
int64_t t11 = 5310647089079LL;
t11 = ((x45+x46)*(x47%x48));
if (t11 != 480822LL) { NG(); } else { ; }
}
void f12(void) {
uint8_t x49 = 9U;
uint64_t x50 = UINT64_MAX;
uint32_t x51 = 267891U;
int16_t x52 = INT16_MIN;
uint64_t t12 = 168892996488861LLU;
t12 = ((x49+x50)*(x51%x52));
if (t12 != 2143128LLU) { NG(); } else { ; }
}
void f13(void) {
int8_t x53 = INT8_MAX;
int8_t x55 = INT8_MIN;
int64_t x56 = INT64_MIN;
int64_t t13 = 142402LL;
t13 = ((x53+x54)*(x55%x56));
if (t13 != 128LL) { NG(); } else { ; }
}
void f14(void) {
uint8_t x57 = 1U;
uint16_t x58 = 55U;
static int64_t x59 = INT64_MIN;
uint8_t x60 = UINT8_MAX;
t14 = ((x57+x58)*(x59%x60));
if (t14 != -7168LL) { NG(); } else { ; }
}
void f15(void) {
static uint64_t x61 = 60286LLU;
int16_t x62 = INT16_MIN;
static int8_t x63 = 1;
uint64_t t15 = 171LLU;
t15 = ((x61+x62)*(x63%x64));
if (t15 != 27518LLU) { NG(); } else { ; }
}
void f16(void) {
int16_t x66 = INT16_MAX;
uint64_t t16 = 491354480030LLU;
t16 = ((x65+x66)*(x67%x68));
if (t16 != 491490LLU) { NG(); } else { ; }
}
void f17(void) {
int32_t x74 = 155819547;
uint64_t x75 = 2LLU;
static volatile uint64_t x76 = UINT64_MAX;
t17 = ((x73+x74)*(x75%x76));
if (t17 != 3060295340LLU) { NG(); } else { ; }
}
void f18(void) {
int16_t x85 = INT16_MIN;
uint64_t x86 = 4185LLU;
volatile uint8_t x87 = UINT8_MAX;
static volatile int8_t x88 = -59;
t18 = ((x85+x86)*(x87%x88));
if (t18 != 18446744073709008539LLU) { NG(); } else { ; }
}
void f19(void) {
int32_t x89 = 338758;
uint64_t x90 = 28827204082186297LLU;
int8_t x91 = INT8_MIN;
uint64_t t19 = 3LLU;
t19 = ((x89+x90)*(x91%x92));
if (t19 != 0LLU) { NG(); } else { ; }
}
void f20(void) {
static int16_t x97 = 2884;
static int16_t x98 = INT16_MIN;
int16_t x99 = INT16_MAX;
static int8_t x100 = -1;
int32_t t20 = 40;
t20 = ((x97+x98)*(x99%x100));
if (t20 != 0) { NG(); } else { ; }
}
void f21(void) {
int32_t x101 = 8663;
int16_t x102 = INT16_MIN;
volatile uint32_t x103 = 44204313U;
volatile int16_t x104 = INT16_MAX;
uint32_t t21 = 44397U;
t21 = ((x101+x102)*(x103%x104));
if (t21 != 4255676146U) { NG(); } else { ; }
}
void f22(void) {
int32_t x105 = -1;
int8_t x107 = 5;
uint16_t x108 = UINT16_MAX;
volatile int32_t t22 = 1995360;
t22 = ((x105+x106)*(x107%x108));
if (t22 != -135) { NG(); } else { ; }
}
void f23(void) {
static int16_t x111 = INT16_MIN;
static int64_t x112 = 1081757948523122939LL;
volatile int64_t t23 = -34710225899508149LL;
t23 = ((x109+x110)*(x111%x112));
if (t23 != -140737488289792LL) { NG(); } else { ; }
}
void f24(void) {
int64_t x113 = -443282LL;
uint64_t x114 = UINT64_MAX;
volatile int32_t x115 = INT32_MIN;
uint64_t t24 = 5530417637910271LLU;
t24 = ((x113+x114)*(x115%x116));
if (t24 != 0LLU) { NG(); } else { ; }
}
void f25(void) {
uint32_t x117 = 4U;
int16_t x118 = -1;
volatile int32_t x119 = 793;
int16_t x120 = INT16_MIN;
uint32_t t25 = 12360U;
t25 = ((x117+x118)*(x119%x120));
if (t25 != 2379U) { NG(); } else { ; }
}
void f26(void) {
uint64_t x122 = UINT64_MAX;
uint64_t x124 = 37LLU;
static volatile uint64_t t26 = 231485LLU;
t26 = ((x121+x122)*(x123%x124));
if (t26 != 18446744073709551382LLU) { NG(); } else { ; }
}
void f27(void) {
static volatile uint32_t x125 = 38392U;
static volatile uint32_t x126 = UINT32_MAX;
uint8_t x127 = 69U;
uint8_t x128 = UINT8_MAX;
uint32_t t27 = 488853U;
t27 = ((x125+x126)*(x127%x128));
if (t27 != 2648979U) { NG(); } else { ; }
}
void f28(void) {
volatile int64_t x129 = -239767767LL;
static uint64_t x130 = 107230826059087LLU;
volatile int32_t x131 = INT32_MAX;
uint8_t x132 = 77U;
static volatile uint64_t t28 = 3LLU;
t28 = ((x129+x130)*(x131%x132));
if (t28 != 107230586291320LLU) { NG(); } else { ; }
}
void f29(void) {
volatile int16_t x133 = INT16_MIN;
int16_t x134 = -3;
uint32_t x135 = 3763048U;
static int16_t x136 = -407;
uint32_t t29 = 14040U;
t29 = ((x133+x134)*(x135%x136));
if (t29 != 1235205576U) { NG(); } else { ; }
}
void f30(void) {
int16_t x137 = -1;
uint32_t x139 = 21462358U;
uint32_t x140 = UINT32_MAX;
uint32_t t30 = 1053977279U;
t30 = ((x137+x138)*(x139%x140));
if (t30 != 4252042580U) { NG(); } else { ; }
}
void f31(void) {
int32_t x141 = -3;
static uint64_t x142 = 423892328372404LLU;
int32_t x143 = 38037315;
int16_t x144 = INT16_MAX;
t31 = ((x141+x142)*(x143%x144));
if (t31 != 11697308801436405595LLU) { NG(); } else { ; }
}
void f32(void) {
static uint32_t x145 = UINT32_MAX;
int32_t x146 = INT32_MAX;
uint16_t x147 = UINT16_MAX;
volatile uint32_t t32 = 12686911U;
t32 = ((x145+x146)*(x147%x148));
if (t32 != 2147483394U) { NG(); } else { ; }
}
void f33(void) {
volatile int32_t x154 = INT32_MIN;
static uint8_t x155 = UINT8_MAX;
uint64_t x156 = 8446892LLU;
uint64_t t33 = 213179192983875399LLU;
t33 = ((x153+x154)*(x155%x156));
if (t33 != 16253883492556606033LLU) { NG(); } else { ; }
}
void f34(void) {
volatile int8_t x157 = -21;
int16_t x158 = -1;
static uint64_t x159 = 8575361653LLU;
int16_t x160 = 196;
volatile uint64_t t34 = 1LLU;
t34 = ((x157+x158)*(x159%x160));
if (t34 != 18446744073709550890LLU) { NG(); } else { ; }
}
void f35(void) {
uint32_t x161 = 4U;
uint8_t x162 = 108U;
static int8_t x164 = INT8_MIN;
t35 = ((x161+x162)*(x163%x164));
if (t35 != 0U) { NG(); } else { ; }
}
void f36(void) {
volatile int16_t x165 = INT16_MIN;
uint32_t x166 = 61387663U;
int16_t x167 = INT16_MAX;
static int32_t x168 = -1;
uint32_t t36 = 6433U;
t36 = ((x165+x166)*(x167%x168));
if (t36 != 0U) { NG(); } else { ; }
}
void f37(void) {
int8_t x173 = INT8_MAX;
int8_t x174 = INT8_MIN;
volatile int8_t x175 = -1;
int8_t x176 = INT8_MIN;
t37 = ((x173+x174)*(x175%x176));
if (t37 != 1) { NG(); } else { ; }
}
void f38(void) {
int16_t x177 = INT16_MAX;
volatile int16_t x178 = INT16_MAX;
uint64_t x179 = 1205420LLU;
static int16_t x180 = INT16_MIN;
t38 = ((x177+x178)*(x179%x180));
if (t38 != 78995994280LLU) { NG(); } else { ; }
}
void f39(void) {
uint32_t x182 = 3981074U;
uint32_t x183 = UINT32_MAX;
uint64_t x184 = UINT64_MAX;
uint64_t t39 = 32053848624836553LLU;
t39 = ((x181+x182)*(x183%x184));
if (t39 != 16957845140652270LLU) { NG(); } else { ; }
}
void f40(void) {
volatile uint64_t x185 = 1070023460988937711LLU;
int64_t x187 = INT64_MIN;
uint16_t x188 = 1U;
uint64_t t40 = 475345691LLU;
t40 = ((x185+x186)*(x187%x188));
if (t40 != 0LLU) { NG(); } else { ; }
}
void f41(void) {
volatile uint16_t x189 = 37U;
static uint64_t x190 = 325270703246LLU;
static int64_t x191 = -1LL;
uint16_t x192 = UINT16_MAX;
uint64_t t41 = 6127LLU;
t41 = ((x189+x190)*(x191%x192));
if (t41 != 18446743748438848333LLU) { NG(); } else { ; }
}
void f42(void) {
uint8_t x194 = 12U;
uint16_t x195 = 43U;
volatile int16_t x196 = INT16_MAX;
static int32_t t42 = 11000755;
t42 = ((x193+x194)*(x195%x196));
if (t42 != 1462) { NG(); } else { ; }
}
void f43(void) {
volatile uint64_t x201 = 210352LLU;
volatile int64_t x202 = 45234865LL;
static volatile int8_t x203 = -1;
int8_t x204 = INT8_MAX;
static volatile uint64_t t43 = 138364197254218LLU;
t43 = ((x201+x202)*(x203%x204));
if (t43 != 18446744073664106399LLU) { NG(); } else { ; }
}
void f44(void) {
static int64_t x205 = -2394939963186LL;
uint8_t x206 = 48U;
uint8_t x207 = 21U;
int16_t x208 = -1;
t44 = ((x205+x206)*(x207%x208));
if (t44 != 0LL) { NG(); } else { ; }
}
void f45(void) {
int64_t x217 = -1LL;
int32_t x218 = INT32_MIN;
static volatile int16_t x219 = INT16_MIN;
uint64_t x220 = 470196377886LLU;
static volatile uint64_t t45 = 346061LLU;
t45 = ((x217+x218)*(x219%x220));
if (t45 != 5209276324330742498LLU) { NG(); } else { ; }
}
void f46(void) {
uint8_t x221 = UINT8_MAX;
int32_t x222 = 2;
uint8_t x223 = UINT8_MAX;
volatile int32_t x224 = INT32_MIN;
static int32_t t46 = 1464280;
t46 = ((x221+x222)*(x223%x224));
if (t46 != 65535) { NG(); } else { ; }
}
void f47(void) {
uint8_t x225 = 1U;
static int8_t x226 = INT8_MIN;
volatile uint64_t x228 = 5396883519987LLU;
volatile uint64_t t47 = 155895LLU;
t47 = ((x225+x226)*(x227%x228));
if (t47 != 0LLU) { NG(); } else { ; }
}
void f48(void) {
volatile int32_t x229 = -15330435;
volatile uint32_t x231 = 6134U;
t48 = ((x229+x230)*(x231%x232));
if (t48 != 4146626328U) { NG(); } else { ; }
}
void f49(void) {
volatile int16_t x233 = -1;
static uint32_t x234 = 998673278U;
int64_t x235 = INT64_MIN;
static int16_t x236 = -53;
t49 = ((x233+x234)*(x235%x236));
if (t49 != -33954891418LL) { NG(); } else { ; }
}
void f50(void) {
static int16_t x237 = INT16_MIN;
int16_t x238 = -1;
int16_t x239 = 0;
int32_t t50 = -439659896;
t50 = ((x237+x238)*(x239%x240));
if (t50 != 0) { NG(); } else { ; }
}
void f51(void) {
volatile int32_t x241 = INT32_MIN;
uint32_t x242 = UINT32_MAX;
int64_t x244 = INT64_MIN;
static int64_t t51 = -16655948343106LL;
t51 = ((x241+x242)*(x243%x244));
if (t51 != 0LL) { NG(); } else { ; }
}
void f52(void) {
int8_t x249 = -2;
int32_t x250 = -1;
volatile int8_t x251 = 1;
int64_t x252 = -1LL;
static int64_t t52 = -153LL;
t52 = ((x249+x250)*(x251%x252));
if (t52 != 0LL) { NG(); } else { ; }
}
void f53(void) {
int32_t x257 = 7677;
static volatile int64_t x259 = 144566970573920477LL;
volatile int32_t x260 = INT32_MIN;
volatile int64_t t53 = 563553LL;
t53 = ((x257+x258)*(x259%x260));
if (t53 != 10214064095884LL) { NG(); } else { ; }
}
void f54(void) {
uint8_t x261 = UINT8_MAX;
volatile uint8_t x262 = 4U;
volatile int64_t x263 = 12641071239LL;
int32_t x264 = INT32_MIN;
int64_t t54 = -1LL;
t54 = ((x261+x262)*(x263%x264));
if (t54 != 493046126741LL) { NG(); } else { ; }
}
void f55(void) {
int16_t x265 = INT16_MAX;
int16_t x266 = INT16_MIN;
int64_t x267 = 434079602441170057LL;
int32_t x268 = INT32_MAX;
volatile int64_t t55 = 63LL;
t55 = ((x265+x266)*(x267%x268));
if (t55 != -1204551355LL) { NG(); } else { ; }
}
void f56(void) {
static int8_t x269 = 15;
int16_t x270 = INT16_MIN;
static int16_t x271 = INT16_MIN;
uint16_t x272 = 291U;
volatile int32_t t56 = -309604337;
t56 = ((x269+x270)*(x271%x272));
if (t56 != 5764528) { NG(); } else { ; }
}
void f57(void) {
int16_t x273 = -1;
static volatile uint64_t x274 = 24172568547LLU;
uint32_t x275 = 6752U;
t57 = ((x273+x274)*(x275%x276));
if (t57 != 163213182822592LLU) { NG(); } else { ; }
}
void f58(void) {
static uint16_t x279 = UINT16_MAX;
int8_t x280 = -1;
volatile uint32_t t58 = 176U;
t58 = ((x277+x278)*(x279%x280));
if (t58 != 0U) { NG(); } else { ; }
}
void f59(void) {
static int32_t x282 = -2204;
int32_t x283 = -126;
int8_t x284 = INT8_MIN;
t59 = ((x281+x282)*(x283%x284));
if (t59 != 277830LLU) { NG(); } else { ; }
}
void f60(void) {
int32_t x285 = INT32_MAX;
int64_t x288 = INT64_MIN;
t60 = ((x285+x286)*(x287%x288));
if (t60 != -4611686016279904256LL) { NG(); } else { ; }
}
void f61(void) {
int16_t x293 = -1;
int8_t x294 = -1;
volatile int16_t x296 = INT16_MIN;
int32_t t61 = 4;
t61 = ((x293+x294)*(x295%x296));
if (t61 != 2) { NG(); } else { ; }
}
void f62(void) {
volatile int8_t x305 = INT8_MAX;
int32_t x306 = 735331345;
int8_t x307 = INT8_MIN;
int64_t x308 = INT64_MIN;
t62 = ((x305+x306)*(x307%x308));
if (t62 != -94122428416LL) { NG(); } else { ; }
}
void f63(void) {
int8_t x309 = INT8_MAX;
int32_t x310 = -1729;
static int32_t x311 = -1;
static int32_t x312 = -1;
static volatile int32_t t63 = -488491;
t63 = ((x309+x310)*(x311%x312));
if (t63 != 0) { NG(); } else { ; }
}
void f64(void) {
volatile int16_t x321 = INT16_MIN;
uint32_t x322 = UINT32_MAX;
int32_t x323 = -1;
volatile int8_t x324 = -4;
static volatile uint32_t t64 = 219U;
t64 = ((x321+x322)*(x323%x324));
if (t64 != 32769U) { NG(); } else { ; }
}
void f65(void) {
uint32_t x330 = UINT32_MAX;
int64_t x331 = -1LL;
uint64_t x332 = 7LLU;
volatile uint64_t t65 = 4445360LLU;
t65 = ((x329+x330)*(x331%x332));
if (t65 != 4294967294LLU) { NG(); } else { ; }
}
void f66(void) {
static int8_t x337 = INT8_MIN;
uint32_t x338 = 115430095U;
int32_t x339 = 1110463;
volatile uint32_t t66 = 51030092U;
t66 = ((x337+x338)*(x339%x340));
if (t66 != 668521285U) { NG(); } else { ; }
}
void f67(void) {
int16_t x341 = -1;
static uint8_t x343 = 102U;
int16_t x344 = INT16_MIN;
volatile uint32_t t67 = 200U;
t67 = ((x341+x342)*(x343%x344));
if (t67 != 4294967092U) { NG(); } else { ; }
}
void f68(void) {
static uint64_t x345 = 983020LLU;
volatile int8_t x346 = INT8_MIN;
uint8_t x347 = UINT8_MAX;
uint64_t x348 = UINT64_MAX;
uint64_t t68 = 28870LLU;
t68 = ((x345+x346)*(x347%x348));
if (t68 != 250637460LLU) { NG(); } else { ; }
}
void f69(void) {
static int64_t x349 = INT64_MAX;
int64_t x350 = INT64_MIN;
uint8_t x351 = 125U;
static int32_t x352 = -12;
volatile int64_t t69 = -936195126LL;
t69 = ((x349+x350)*(x351%x352));
if (t69 != -5LL) { NG(); } else { ; }
}
void f70(void) {
uint16_t x354 = 12U;
volatile int8_t x355 = INT8_MAX;
int32_t x356 = -8058625;
t70 = ((x353+x354)*(x355%x356));
if (t70 != 1397LL) { NG(); } else { ; }
}
void f71(void) {
volatile int32_t x361 = INT32_MAX;
static int64_t x362 = -928LL;
int32_t x364 = -704328;
static int64_t t71 = 20269507891565819LL;
t71 = ((x361+x362)*(x363%x364));
if (t71 != 70366566253473LL) { NG(); } else { ; }
}
void f72(void) {
volatile int16_t x365 = -91;
volatile uint16_t x366 = 10222U;
uint8_t x367 = UINT8_MAX;
t72 = ((x365+x366)*(x367%x368));
if (t72 != 2583405) { NG(); } else { ; }
}
void f73(void) {
static int32_t x369 = INT32_MIN;
int32_t x370 = 1;
volatile uint64_t x372 = UINT64_MAX;
uint64_t t73 = 233369564036LLU;
t73 = ((x369+x370)*(x371%x372));
if (t73 != 18446673707112890367LLU) { NG(); } else { ; }
}
void f74(void) {
static int32_t x373 = INT32_MIN;
int64_t x374 = -278LL;
uint8_t x375 = UINT8_MAX;
volatile int64_t t74 = -3024556161479633691LL;
t74 = ((x373+x374)*(x375%x376));
if (t74 != 0LL) { NG(); } else { ; }
}
void f75(void) {
int8_t x377 = INT8_MIN;
static int64_t x378 = -14816044650171LL;
uint16_t x379 = 22850U;
static volatile int16_t x380 = -731;
volatile int64_t t75 = -43367251020LL;
t75 = ((x377+x378)*(x379%x380));
if (t75 != -2800232438906511LL) { NG(); } else { ; }
}
void f76(void) {
volatile uint32_t x390 = 31U;
static int16_t x391 = 0;
volatile int8_t x392 = INT8_MAX;
t76 = ((x389+x390)*(x391%x392));
if (t76 != 0LL) { NG(); } else { ; }
}
void f77(void) {
volatile int16_t x397 = INT16_MAX;
int8_t x398 = INT8_MAX;
int32_t x399 = INT32_MIN;
int16_t x400 = INT16_MIN;
int32_t t77 = 33303729;
t77 = ((x397+x398)*(x399%x400));
if (t77 != 0) { NG(); } else { ; }
}
void f78(void) {
uint16_t x401 = UINT16_MAX;
static uint32_t x403 = 156U;
uint8_t x404 = 21U;
t78 = ((x401+x402)*(x403%x404));
if (t78 != 589644U) { NG(); } else { ; }
}
void f79(void) {
static uint16_t x406 = UINT16_MAX;
int8_t x407 = INT8_MAX;
int8_t x408 = INT8_MIN;
volatile uint32_t t79 = 221056U;
t79 = ((x405+x406)*(x407%x408));
if (t79 != 37125021U) { NG(); } else { ; }
}
void f80(void) {
volatile uint64_t x409 = 484LLU;
uint16_t x410 = 6377U;
int64_t x411 = INT64_MAX;
uint16_t x412 = UINT16_MAX;
uint64_t t80 = 824042295790LLU;
t80 = ((x409+x410)*(x411%x412));
if (t80 != 224814387LLU) { NG(); } else { ; }
}
void f81(void) {
uint32_t x413 = 6847U;
int8_t x414 = 12;
static int32_t x416 = INT32_MIN;
volatile uint32_t t81 = 0U;
t81 = ((x413+x414)*(x415%x416));
if (t81 != 123462U) { NG(); } else { ; }
}
void f82(void) {
uint64_t x421 = UINT64_MAX;
uint8_t x422 = 0U;
int16_t x423 = -13648;
volatile uint64_t t82 = 28359240LLU;
t82 = ((x421+x422)*(x423%x424));
if (t82 != 40LLU) { NG(); } else { ; }
}
void f83(void) {
uint64_t x429 = UINT64_MAX;
volatile int16_t x430 = -839;
int64_t x431 = -413LL;
static uint32_t x432 = 2320870U;
volatile uint64_t t83 = 1969319LLU;
t83 = ((x429+x430)*(x431%x432));
if (t83 != 346920LLU) { NG(); } else { ; }
}
void f84(void) {
int8_t x433 = INT8_MAX;
volatile int8_t x434 = INT8_MAX;
volatile uint32_t x436 = 12U;
volatile uint64_t t84 = 297050012481LLU;
t84 = ((x433+x434)*(x435%x436));
if (t84 != 762LLU) { NG(); } else { ; }
}
void f85(void) {
static int8_t x438 = INT8_MIN;
int32_t x439 = INT32_MIN;
int64_t x440 = -6758LL;
volatile int64_t t85 = 29913777LL;
t85 = ((x437+x438)*(x439%x440));
if (t85 != 94742LL) { NG(); } else { ; }
}
void f86(void) {
int16_t x441 = -833;
int64_t x442 = -1074725638030LL;
static int16_t x443 = INT16_MAX;
uint16_t x444 = 1U;
t86 = ((x441+x442)*(x443%x444));
if (t86 != 0LL) { NG(); } else { ; }
}
void f87(void) {
uint16_t x446 = UINT16_MAX;
volatile int16_t x447 = -1;
volatile int64_t x448 = -1LL;
static volatile int64_t t87 = 0LL;
t87 = ((x445+x446)*(x447%x448));
if (t87 != 0LL) { NG(); } else { ; }
}
void f88(void) {
int16_t x449 = -99;
int32_t x450 = -3513175;
int8_t x451 = INT8_MIN;
volatile int32_t x452 = 691;
int32_t t88 = -191687353;
t88 = ((x449+x450)*(x451%x452));
if (t88 != 449699072) { NG(); } else { ; }
}
void f89(void) {
int8_t x453 = INT8_MIN;
volatile int64_t x455 = INT64_MAX;
uint64_t x456 = UINT64_MAX;
static volatile uint64_t t89 = 635817371510492301LLU;
t89 = ((x453+x454)*(x455%x456));
if (t89 != 18446743973143986474LLU) { NG(); } else { ; }
}
void f90(void) {
static uint32_t x457 = UINT32_MAX;
int16_t x458 = INT16_MIN;
volatile int8_t x459 = INT8_MIN;
uint32_t x460 = UINT32_MAX;
static uint32_t t90 = 27U;
t90 = ((x457+x458)*(x459%x460));
if (t90 != 4194432U) { NG(); } else { ; }
}
void f91(void) {
static int32_t x461 = -1;
static int16_t x464 = 1;
int32_t t91 = -26312521;
t91 = ((x461+x462)*(x463%x464));
if (t91 != 0) { NG(); } else { ; }
}
void f92(void) {
int16_t x466 = -1;
uint32_t x468 = 350634U;
t92 = ((x465+x466)*(x467%x468));
if (t92 != 50398U) { NG(); } else { ; }
}
void f93(void) {
static int32_t x477 = -1;
int64_t x478 = -1LL;
int8_t x479 = -62;
int32_t x480 = -1;
int64_t t93 = 596903618LL;
t93 = ((x477+x478)*(x479%x480));
if (t93 != 0LL) { NG(); } else { ; }
}
void f94(void) {
int16_t x481 = 1;
volatile int8_t x482 = 0;
volatile uint64_t x484 = 21650019254125976LLU;
static volatile uint64_t t94 = 6402661934523LLU;
t94 = ((x481+x482)*(x483%x484));
if (t94 != 24LLU) { NG(); } else { ; }
}
void f95(void) {
int16_t x485 = -4996;
int16_t x486 = INT16_MIN;
int64_t x487 = INT64_MIN;
volatile uint64_t x488 = UINT64_MAX;
volatile uint64_t t95 = 3088207198LLU;
t95 = ((x485+x486)*(x487%x488));
if (t95 != 0LLU) { NG(); } else { ; }
}
void f96(void) {
volatile uint8_t x493 = 2U;
int16_t x494 = 2;
volatile uint64_t x496 = UINT64_MAX;
uint64_t t96 = 40LLU;
t96 = ((x493+x494)*(x495%x496));
if (t96 != 18446744073709551104LLU) { NG(); } else { ; }
}
void f97(void) {
uint8_t x498 = 0U;
static volatile int16_t x499 = INT16_MAX;
int16_t x500 = -1;
uint32_t t97 = 7U;
t97 = ((x497+x498)*(x499%x500));
if (t97 != 0U) { NG(); } else { ; }
}
void f98(void) {
int64_t x505 = -20787239527726LL;
uint8_t x506 = 26U;
int64_t x507 = 2833476969700681LL;
uint16_t x508 = UINT16_MAX;
volatile int64_t t98 = 481567124389195552LL;
t98 = ((x505+x506)*(x507%x508));
if (t98 != -609918394982245700LL) { NG(); } else { ; }
}
void f99(void) {
uint32_t x510 = UINT32_MAX;
uint16_t x511 = 619U;
int8_t x512 = INT8_MIN;
t99 = ((x509+x510)*(x511%x512));
if (t99 != 94374U) { NG(); } else { ; }
}
void f100(void) {
uint32_t x513 = 17423U;
volatile uint16_t x514 = 40U;
uint64_t x515 = 6361183271096175300LLU;
int32_t x516 = -1;
volatile uint64_t t100 = 120534509403LLU;
t100 = ((x513+x514)*(x515%x516));
if (t100 != 17497395347298983964LLU) { NG(); } else { ; }
}
void f101(void) {
uint64_t x517 = UINT64_MAX;
int16_t x518 = 0;
int64_t x519 = INT64_MIN;
int64_t x520 = INT64_MIN;
t101 = ((x517+x518)*(x519%x520));
if (t101 != 0LLU) { NG(); } else { ; }
}
void f102(void) {
int16_t x525 = 12894;
int16_t x526 = 13;
static uint8_t x527 = 0U;
int8_t x528 = INT8_MAX;
t102 = ((x525+x526)*(x527%x528));
if (t102 != 0) { NG(); } else { ; }
}
void f103(void) {
int8_t x529 = -1;
int64_t x531 = 51555LL;
int64_t t103 = -30973425344704273LL;
t103 = ((x529+x530)*(x531%x532));
if (t103 != -13979598855852LL) { NG(); } else { ; }
}
void f104(void) {
int8_t x533 = -23;
int16_t x534 = -1;
static int16_t x535 = INT16_MIN;
t104 = ((x533+x534)*(x535%x536));
if (t104 != 2352) { NG(); } else { ; }
}
void f105(void) {
int8_t x541 = 11;
static volatile int16_t x542 = INT16_MIN;
uint8_t x543 = 1U;
volatile int8_t x544 = -5;
volatile int32_t t105 = -13;
t105 = ((x541+x542)*(x543%x544));
if (t105 != -32757) { NG(); } else { ; }
}
void f106(void) {
int16_t x545 = INT16_MIN;
int8_t x546 = INT8_MAX;
uint16_t x547 = UINT16_MAX;
volatile int16_t x548 = -1;
static volatile int32_t t106 = -54818680;
t106 = ((x545+x546)*(x547%x548));
if (t106 != 0) { NG(); } else { ; }
}
void f107(void) {
int16_t x549 = -338;
static int64_t x550 = -1LL;
volatile int16_t x551 = INT16_MIN;
int16_t x552 = -1;
static int64_t t107 = 47079377LL;
t107 = ((x549+x550)*(x551%x552));
if (t107 != 0LL) { NG(); } else { ; }
}
void f108(void) {
static int32_t x557 = -1;
volatile int32_t x559 = INT32_MIN;
int64_t x560 = -1LL;
static volatile int64_t t108 = 69189LL;
t108 = ((x557+x558)*(x559%x560));
if (t108 != 0LL) { NG(); } else { ; }
}
void f109(void) {
static uint64_t x561 = UINT64_MAX;
int32_t x562 = INT32_MIN;
int32_t x563 = INT32_MIN;
int8_t x564 = -1;
static uint64_t t109 = 739064823LLU;
t109 = ((x561+x562)*(x563%x564));
if (t109 != 0LLU) { NG(); } else { ; }
}
void f110(void) {
static int64_t x569 = 16LL;
volatile int8_t x570 = INT8_MIN;
static int16_t x571 = -1;
int16_t x572 = INT16_MIN;
volatile int64_t t110 = 64656889113282LL;
t110 = ((x569+x570)*(x571%x572));
if (t110 != 112LL) { NG(); } else { ; }
}
void f111(void) {
uint64_t x578 = 148346930LLU;
uint16_t x579 = 841U;
uint8_t x580 = 2U;
static uint64_t t111 = 3357LLU;
t111 = ((x577+x578)*(x579%x580));
if (t111 != 16614949536463524404LLU) { NG(); } else { ; }
}
void f112(void) {
int8_t x581 = -1;
uint16_t x582 = 80U;
int64_t x583 = INT64_MAX;
t112 = ((x581+x582)*(x583%x584));
if (t112 != 553LL) { NG(); } else { ; }
}
void f113(void) {
volatile int64_t x587 = INT64_MIN;
static int8_t x588 = INT8_MIN;
volatile int64_t t113 = 110919893783LL;
t113 = ((x585+x586)*(x587%x588));
if (t113 != 0LL) { NG(); } else { ; }
}
void f114(void) {
int64_t x590 = INT64_MIN;
int8_t x591 = 10;
int8_t x592 = -1;
t114 = ((x589+x590)*(x591%x592));
if (t114 != 0LL) { NG(); } else { ; }
}
void f115(void) {
static int8_t x593 = -2;
int32_t x594 = -8;
volatile int64_t x595 = 18932269LL;
int32_t x596 = INT32_MIN;
t115 = ((x593+x594)*(x595%x596));
if (t115 != -189322690LL) { NG(); } else { ; }
}
void f116(void) {
uint64_t x597 = 43896406158LLU;
int16_t x599 = 7;
volatile uint64_t t116 = 12786LLU;
t116 = ((x597+x598)*(x599%x600));
if (t116 != 307274843099LLU) { NG(); } else { ; }
}
void f117(void) {
static uint32_t x601 = 6943U;
uint8_t x603 = 1U;
static volatile int32_t x604 = INT32_MAX;
static volatile uint32_t t117 = 815U;
t117 = ((x601+x602)*(x603%x604));
if (t117 != 745860U) { NG(); } else { ; }
}
void f118(void) {
volatile int8_t x609 = INT8_MIN;
int8_t x610 = -6;
static volatile uint8_t x612 = 19U;
static volatile int32_t t118 = 7773814;
t118 = ((x609+x610)*(x611%x612));
if (t118 != 134) { NG(); } else { ; }
}
void f119(void) {
uint16_t x613 = UINT16_MAX;
volatile uint8_t x615 = 19U;
uint64_t x616 = UINT64_MAX;
uint64_t t119 = 281326071095LLU;
t119 = ((x613+x614)*(x615%x616));
if (t119 != 1245906LLU) { NG(); } else { ; }
}
void f120(void) {
static volatile int8_t x617 = INT8_MAX;
int32_t x618 = -29244192;
volatile int8_t x620 = INT8_MAX;
t120 = ((x617+x618)*(x619%x620));
if (t120 != 233952520) { NG(); } else { ; }
}
void f121(void) {
int32_t x625 = -1;
int8_t x626 = INT8_MIN;
int8_t x627 = INT8_MAX;
uint32_t x628 = 159U;
t121 = ((x625+x626)*(x627%x628));
if (t121 != 4294950913U) { NG(); } else { ; }
}
void f122(void) {
int64_t x629 = -1LL;
volatile int32_t x630 = INT32_MIN;
int8_t x631 = -7;
static int64_t x632 = -100773LL;
volatile int64_t t122 = -71134452452085562LL;
t122 = ((x629+x630)*(x631%x632));
if (t122 != 15032385543LL) { NG(); } else { ; }
}
void f123(void) {
uint64_t x634 = 8489026942298440548LLU;
int64_t x635 = INT64_MAX;
volatile int16_t x636 = INT16_MAX;
uint64_t t123 = 263374LLU;
t123 = ((x633+x634)*(x635%x636));
if (t123 != 13306328411815204796LLU) { NG(); } else { ; }
}
void f124(void) {
uint16_t x642 = 17U;
int16_t x643 = INT16_MIN;
uint64_t x644 = 6267830392705647872LLU;
static uint64_t t124 = 215374LLU;
t124 = ((x641+x642)*(x643%x644));
if (t124 != 2343612244223811584LLU) { NG(); } else { ; }
}
void f125(void) {
uint64_t x649 = 580792141133054290LLU;
uint32_t x650 = 132755U;
int16_t x651 = -684;
int8_t x652 = -1;
volatile uint64_t t125 = 56799147863596973LLU;
t125 = ((x649+x650)*(x651%x652));
if (t125 != 0LLU) { NG(); } else { ; }
}
void f126(void) {
static int64_t x657 = -1LL;
static int16_t x658 = 484;
static int32_t x659 = INT32_MIN;
volatile int64_t t126 = 15018LL;
t126 = ((x657+x658)*(x659%x660));
if (t126 != 0LL) { NG(); } else { ; }
}
void f127(void) {
uint32_t x661 = 654532U;
static int32_t x662 = -1532136;
uint64_t x664 = 28448436089443LLU;
uint64_t t127 = 395248273LLU;
t127 = ((x661+x662)*(x663%x664));
if (t127 != 167469497988LLU) { NG(); } else { ; }
}
void f128(void) {
uint16_t x665 = 57U;
static uint32_t x666 = 78440U;
uint32_t x667 = UINT32_MAX;
static int8_t x668 = -19;
volatile uint32_t t128 = 3426371U;
t128 = ((x665+x666)*(x667%x668));
if (t128 != 1412946U) { NG(); } else { ; }
}
void f129(void) {
int16_t x670 = INT16_MAX;
static volatile int64_t x671 = -1LL;
int64_t x672 = INT64_MIN;
t129 = ((x669+x670)*(x671%x672));
if (t129 != -32766LL) { NG(); } else { ; }
}
void f130(void) {
int16_t x677 = 3;
volatile int16_t x679 = INT16_MIN;
int64_t t130 = 0LL;
t130 = ((x677+x678)*(x679%x680));
if (t130 != 70368744079360LL) { NG(); } else { ; }
}
void f131(void) {
int64_t x683 = -1LL;
static int64_t x684 = -1LL;
volatile int64_t t131 = 78006LL;
t131 = ((x681+x682)*(x683%x684));
if (t131 != 0LL) { NG(); } else { ; }
}
void f132(void) {
static uint16_t x693 = UINT16_MAX;
int16_t x694 = INT16_MIN;
volatile int32_t x695 = 17;
uint8_t x696 = 14U;
volatile int32_t t132 = -3797;
t132 = ((x693+x694)*(x695%x696));
if (t132 != 98301) { NG(); } else { ; }
}
void f133(void) {
volatile int8_t x697 = -1;
static int16_t x698 = -1;
int16_t x699 = 1;
int16_t x700 = -15719;
volatile int32_t t133 = -56069;
t133 = ((x697+x698)*(x699%x700));
if (t133 != -2) { NG(); } else { ; }
}
void f134(void) {
int16_t x701 = INT16_MIN;
uint64_t x702 = 1680473501605LLU;
uint16_t x703 = 3602U;
int64_t x704 = INT64_MIN;
uint64_t t134 = 781356265743744040LLU;
t134 = ((x701+x702)*(x703%x704));
if (t134 != 6053065434750874LLU) { NG(); } else { ; }
}
void f135(void) {
uint32_t x705 = 1713425193U;
volatile int16_t x706 = INT16_MAX;
int64_t x707 = -3216633LL;
static uint8_t x708 = 106U;
int64_t t135 = 15566291466LL;
t135 = ((x705+x706)*(x707%x708));
if (t135 != -107947851480LL) { NG(); } else { ; }
}
void f136(void) {
int32_t x709 = INT32_MIN;
int16_t x711 = INT16_MIN;
static int16_t x712 = INT16_MIN;
volatile int64_t t136 = 128784747260149LL;
t136 = ((x709+x710)*(x711%x712));
if (t136 != 0LL) { NG(); } else { ; }
}
void f137(void) {
int8_t x713 = 6;
int8_t x714 = INT8_MAX;
static int32_t x715 = -6490826;
volatile int64_t x716 = -1LL;
volatile int64_t t137 = -1863460034LL;
t137 = ((x713+x714)*(x715%x716));
if (t137 != 0LL) { NG(); } else { ; }
}
void f138(void) {
int8_t x717 = INT8_MIN;
static volatile uint16_t x718 = 1855U;
uint8_t x719 = 0U;
volatile int32_t x720 = INT32_MIN;
volatile int32_t t138 = -23947;
t138 = ((x717+x718)*(x719%x720));
if (t138 != 0) { NG(); } else { ; }
}
void f139(void) {
int64_t x721 = -1LL;
volatile int16_t x722 = INT16_MAX;
volatile uint8_t x723 = 12U;
static volatile int64_t t139 = 28342787LL;
t139 = ((x721+x722)*(x723%x724));
if (t139 != 393192LL) { NG(); } else { ; }
}
void f140(void) {
volatile int8_t x726 = -1;
static int16_t x728 = INT16_MIN;
static volatile uint64_t t140 = 912LLU;
t140 = ((x725+x726)*(x727%x728));
if (t140 != 0LLU) { NG(); } else { ; }
}
void f141(void) {
int32_t x729 = 1002;
static volatile uint64_t x731 = 262318284LLU;
uint64_t x732 = UINT64_MAX;
volatile uint64_t t141 = 114907724514754919LLU;
t141 = ((x729+x730)*(x731%x732));
if (t141 != 229266180216LLU) { NG(); } else { ; }
}
void f142(void) {
static int16_t x733 = INT16_MIN;
uint8_t x734 = UINT8_MAX;
int64_t x736 = INT64_MAX;
volatile int64_t t142 = -19938LL;
t142 = ((x733+x734)*(x735%x736));
if (t142 != -21563276144205497LL) { NG(); } else { ; }
}
void f143(void) {
uint64_t x737 = 7267015LLU;
static int16_t x738 = -291;
uint16_t x740 = 10002U;
volatile uint64_t t143 = 36641501447046392LLU;
t143 = ((x737+x738)*(x739%x740));
if (t143 != 18446744043872382872LLU) { NG(); } else { ; }
}
void f144(void) {
volatile uint32_t x741 = UINT32_MAX;
volatile int16_t x743 = INT16_MIN;
t144 = ((x741+x742)*(x743%x744));
if (t144 != -140737488289792LL) { NG(); } else { ; }
}
void f145(void) {
int16_t x749 = 4;
volatile int8_t x750 = INT8_MIN;
uint8_t x751 = 65U;
volatile int64_t x752 = INT64_MIN;
static int64_t t145 = 30089986039LL;
t145 = ((x749+x750)*(x751%x752));
if (t145 != -8060LL) { NG(); } else { ; }
}
void f146(void) {
uint16_t x753 = 1171U;
volatile uint32_t x754 = 1U;
int64_t x756 = -39701LL;
static int64_t t146 = 45LL;
t146 = ((x753+x754)*(x755%x756));
if (t146 != -150016LL) { NG(); } else { ; }
}
void f147(void) {
uint16_t x759 = UINT16_MAX;
uint64_t x760 = UINT64_MAX;
static uint64_t t147 = 3000LLU;
t147 = ((x757+x758)*(x759%x760));
if (t147 != 93375740898731790LLU) { NG(); } else { ; }
}
void f148(void) {
static uint32_t x761 = 885U;
int8_t x762 = 7;
uint32_t x763 = 131880507U;
volatile int8_t x764 = 1;
uint32_t t148 = 178U;
t148 = ((x761+x762)*(x763%x764));
if (t148 != 0U) { NG(); } else { ; }
}
void f149(void) {
int64_t x773 = -1023752077537569128LL;
volatile uint8_t x775 = 8U;
static int32_t x776 = 79;
t149 = ((x773+x774)*(x775%x776));
if (t149 != -8190016620300290888LL) { NG(); } else { ; }
}
void f150(void) {
int64_t x777 = INT64_MAX;
static int32_t x778 = INT32_MIN;
uint32_t x780 = 640621U;
uint64_t t150 = 2925958195913596348LLU;
t150 = ((x777+x778)*(x779%x780));
if (t150 != 18446176102939096798LLU) { NG(); } else { ; }
}
void f151(void) {
int32_t x785 = INT32_MIN;
volatile uint16_t x786 = UINT16_MAX;
int8_t x788 = -1;
int32_t t151 = -27;
t151 = ((x785+x786)*(x787%x788));
if (t151 != 0) { NG(); } else { ; }
}
void f152(void) {
static volatile int8_t x790 = INT8_MIN;
int32_t x791 = INT32_MAX;
static uint32_t x792 = 1376358U;
volatile uint64_t t152 = 995346645898999LLU;
t152 = ((x789+x790)*(x791%x792));
if (t152 != 1841902348LLU) { NG(); } else { ; }
}
void f153(void) {
int64_t x796 = INT64_MIN;
volatile uint64_t t153 = 13748038LLU;
t153 = ((x793+x794)*(x795%x796));
if (t153 != 1728314484614833507LLU) { NG(); } else { ; }
}
void f154(void) {
static int32_t x801 = 13602631;
volatile uint64_t x803 = 816318657930LLU;
int64_t x804 = INT64_MAX;
uint64_t t154 = 279562105491835385LLU;
t154 = ((x801+x802)*(x803%x804));
if (t154 != 10513799022663888710LLU) { NG(); } else { ; }
}
void f155(void) {
static uint16_t x805 = 112U;
uint16_t x806 = 3948U;
uint8_t x807 = 48U;
uint8_t x808 = UINT8_MAX;
volatile int32_t t155 = 7217013;
t155 = ((x805+x806)*(x807%x808));
if (t155 != 194880) { NG(); } else { ; }
}
void f156(void) {
int16_t x809 = -456;
volatile int16_t x810 = INT16_MIN;
int16_t x811 = INT16_MIN;
static volatile int64_t x812 = -19350872808LL;
int64_t t156 = -60LL;
t156 = ((x809+x810)*(x811%x812));
if (t156 != 1088684032LL) { NG(); } else { ; }
}
void f157(void) {
volatile int32_t x813 = INT32_MAX;
int16_t x814 = -1;
volatile int64_t t157 = -50364439957249LL;
t157 = ((x813+x814)*(x815%x816));
if (t157 != -4611686014132420608LL) { NG(); } else { ; }
}
void f158(void) {
int32_t x823 = INT32_MIN;
volatile int32_t x824 = -11595690;
volatile uint64_t t158 = 752985654LLU;
t158 = ((x821+x822)*(x823%x824));
if (t158 != 12776982377759598744LLU) { NG(); } else { ; }
}
void f159(void) {
static int64_t x825 = INT64_MAX;
volatile int64_t x826 = -28LL;
static uint64_t x828 = 2683LLU;
uint64_t t159 = 27727080LLU;
t159 = ((x825+x826)*(x827%x828));
if (t159 != 9223372036854730133LLU) { NG(); } else { ; }
}
void f160(void) {
int64_t x829 = -1LL;
static int64_t x830 = 0LL;
uint32_t x831 = 17770U;
int16_t x832 = -888;
int64_t t160 = -883354009524LL;
t160 = ((x829+x830)*(x831%x832));
if (t160 != -17770LL) { NG(); } else { ; }
}
void f161(void) {
static uint16_t x834 = 14U;
int64_t x835 = -1LL;
static uint32_t x836 = 60U;
int64_t t161 = -10027934864826LL;
t161 = ((x833+x834)*(x835%x836));
if (t161 != 27813773483610LL) { NG(); } else { ; }
}
void f162(void) {
uint64_t x837 = 1456619918LLU;
static uint64_t x838 = UINT64_MAX;
static int16_t x839 = 5;
uint8_t x840 = UINT8_MAX;
uint64_t t162 = 100404712LLU;
t162 = ((x837+x838)*(x839%x840));
if (t162 != 7283099585LLU) { NG(); } else { ; }
}
void f163(void) {
uint32_t x842 = UINT32_MAX;
int8_t x843 = INT8_MIN;
volatile int8_t x844 = 1;
t163 = ((x841+x842)*(x843%x844));
if (t163 != 0U) { NG(); } else { ; }
}
void f164(void) {
uint64_t x853 = UINT64_MAX;
uint8_t x854 = UINT8_MAX;
uint8_t x855 = UINT8_MAX;
uint32_t x856 = 2380420U;
uint64_t t164 = 7LLU;
t164 = ((x853+x854)*(x855%x856));
if (t164 != 64770LLU) { NG(); } else { ; }
}
void f165(void) {
volatile uint32_t x858 = UINT32_MAX;
static int16_t x859 = -1;
static uint8_t x860 = 42U;
t165 = ((x857+x858)*(x859%x860));
if (t165 != 4294967042U) { NG(); } else { ; }
}
void f166(void) {
static uint8_t x865 = 0U;
int8_t x866 = INT8_MIN;
static volatile int32_t x867 = INT32_MIN;
int32_t x868 = 15;
volatile int32_t t166 = -22;
t166 = ((x865+x866)*(x867%x868));
if (t166 != 1024) { NG(); } else { ; }
}
void f167(void) {
static volatile uint8_t x869 = 17U;
int8_t x871 = INT8_MIN;
static uint64_t x872 = 35LLU;
volatile uint64_t t167 = 16415889LLU;
t167 = ((x869+x870)*(x871%x872));
if (t167 != 4032LLU) { NG(); } else { ; }
}
void f168(void) {
int8_t x874 = 0;
volatile int8_t x875 = -1;
int64_t x876 = INT64_MIN;
int64_t t168 = -1LL;
t168 = ((x873+x874)*(x875%x876));
if (t168 != -9223372036854775807LL) { NG(); } else { ; }
}
void f169(void) {
uint64_t x877 = UINT64_MAX;
static int8_t x878 = INT8_MIN;
int16_t x879 = INT16_MIN;
int16_t x880 = -8705;
static volatile uint64_t t169 = 14759440LLU;
t169 = ((x877+x878)*(x879%x880));
if (t169 != 858237LLU) { NG(); } else { ; }
}
void f170(void) {
uint16_t x881 = 18U;
uint32_t x882 = 1U;
uint16_t x883 = UINT16_MAX;
static volatile uint8_t x884 = UINT8_MAX;
t170 = ((x881+x882)*(x883%x884));
if (t170 != 0U) { NG(); } else { ; }
}
void f171(void) {
uint8_t x885 = 1U;
int8_t x886 = -1;
static int64_t x887 = 254271LL;
volatile uint16_t x888 = 4U;
volatile int64_t t171 = -29739238608348077LL;
t171 = ((x885+x886)*(x887%x888));
if (t171 != 0LL) { NG(); } else { ; }
}
void f172(void) {
uint64_t x889 = UINT64_MAX;
uint64_t x890 = 31545519322369LLU;
volatile uint16_t x891 = 4U;
uint8_t x892 = UINT8_MAX;
volatile uint64_t t172 = 24099069LLU;
t172 = ((x889+x890)*(x891%x892));
if (t172 != 126182077289472LLU) { NG(); } else { ; }
}
void f173(void) {
uint16_t x894 = 225U;
int8_t x895 = 1;
static int32_t x896 = 376145;
volatile int32_t t173 = -8030;
t173 = ((x893+x894)*(x895%x896));
if (t173 != 233) { NG(); } else { ; }
}
void f174(void) {
int16_t x897 = 4901;
int64_t x898 = INT64_MIN;
volatile int16_t x899 = 0;
int64_t x900 = -1LL;
volatile int64_t t174 = 183LL;
t174 = ((x897+x898)*(x899%x900));
if (t174 != 0LL) { NG(); } else { ; }
}
void f175(void) {
static volatile uint16_t x902 = 46U;
volatile int64_t x903 = INT64_MIN;
int8_t x904 = INT8_MIN;
t175 = ((x901+x902)*(x903%x904));
if (t175 != 0LLU) { NG(); } else { ; }
}
void f176(void) {
static int16_t x906 = -1;
uint64_t x907 = UINT64_MAX;
uint32_t x908 = UINT32_MAX;
t176 = ((x905+x906)*(x907%x908));
if (t176 != 0LLU) { NG(); } else { ; }
}
void f177(void) {
volatile uint64_t x909 = 1078017809058621LLU;
int64_t x910 = -1LL;
int32_t x911 = 53873;
int8_t x912 = INT8_MIN;
t177 = ((x909+x910)*(x911%x912));
if (t177 != 121816012423624060LLU) { NG(); } else { ; }
}
void f178(void) {
volatile int8_t x917 = INT8_MIN;
uint32_t x918 = 197U;
int8_t x920 = INT8_MIN;
uint32_t t178 = 1609U;
t178 = ((x917+x918)*(x919%x920));
if (t178 != 0U) { NG(); } else { ; }
}
void f179(void) {
uint8_t x921 = UINT8_MAX;
int64_t x922 = INT64_MIN;
uint64_t x923 = 3237LLU;
int64_t x924 = INT64_MIN;
volatile uint64_t t179 = 157967591LLU;
t179 = ((x921+x922)*(x923%x924));
if (t179 != 9223372036855601243LLU) { NG(); } else { ; }
}
void f180(void) {
int16_t x926 = 1;
int8_t x927 = INT8_MIN;
static uint8_t x928 = 127U;
volatile int32_t t180 = INT32_MAX;
t180 = ((x925+x926)*(x927%x928));
if (t180 != INT32_MAX) { NG(); } else { ; }
}
void f181(void) {
static volatile int8_t x929 = -1;
uint32_t x932 = 18422501U;
uint32_t t181 = 315755817U;
t181 = ((x929+x930)*(x931%x932));
if (t181 != 322U) { NG(); } else { ; }
}
void f182(void) {
volatile int16_t x933 = INT16_MIN;
int8_t x934 = INT8_MIN;
int64_t x936 = INT64_MIN;
static volatile int64_t t182 = 2LL;
t182 = ((x933+x934)*(x935%x936));
if (t182 != 1933265024LL) { NG(); } else { ; }
}
void f183(void) {
static int32_t x937 = -348739;
int32_t x938 = INT32_MAX;
volatile uint64_t x939 = 1540LLU;
volatile uint64_t t183 = 40922LLU;
t183 = ((x937+x938)*(x939%x940));
if (t183 != 3306587758320LLU) { NG(); } else { ; }
}
void f184(void) {
static int32_t x941 = -1;
int8_t x942 = INT8_MAX;
static int16_t x943 = INT16_MAX;
static int8_t x944 = -7;
t184 = ((x941+x942)*(x943%x944));
if (t184 != 0) { NG(); } else { ; }
}
void f185(void) {
static volatile uint8_t x945 = UINT8_MAX;
int32_t x946 = 38807033;
uint64_t x948 = 9447226901732519LLU;
uint64_t t185 = 5790LLU;
t185 = ((x945+x946)*(x947%x948));
if (t185 != 11307990288959931400LLU) { NG(); } else { ; }
}
void f186(void) {
static uint16_t x949 = 4896U;
static uint32_t x951 = UINT32_MAX;
int64_t x952 = INT64_MIN;
t186 = ((x949+x950)*(x951%x952));
if (t186 != 22123376536545LL) { NG(); } else { ; }
}
void f187(void) {
uint32_t x953 = 1162U;
int32_t x954 = INT32_MIN;
volatile uint32_t x955 = UINT32_MAX;
static volatile int64_t t187 = -335LL;
t187 = ((x953+x954)*(x955%x956));
if (t187 != 0LL) { NG(); } else { ; }
}
void f188(void) {
volatile int16_t x967 = INT16_MAX;
int8_t x968 = INT8_MIN;
t188 = ((x965+x966)*(x967%x968));
if (t188 != 4294967169U) { NG(); } else { ; }
}
void f189(void) {
uint8_t x970 = UINT8_MAX;
uint8_t x971 = 55U;
volatile int64_t x972 = INT64_MIN;
static uint64_t t189 = 68758245798651LLU;
t189 = ((x969+x970)*(x971%x972));
if (t189 != 13970LLU) { NG(); } else { ; }
}
void f190(void) {
int32_t x974 = INT32_MAX;
uint32_t x975 = 67874U;
uint64_t t190 = 1439948970328LLU;
t190 = ((x973+x974)*(x975%x976));
if (t190 != 145758305056478LLU) { NG(); } else { ; }
}
void f191(void) {
static uint32_t x977 = 336186U;
int8_t x978 = INT8_MAX;
static volatile int16_t x979 = INT16_MIN;
uint32_t x980 = UINT32_MAX;
static volatile uint32_t t191 = 417266U;
t191 = ((x977+x978)*(x979%x980));
if (t191 != 1864597504U) { NG(); } else { ; }
}
void f192(void) {
volatile int64_t x981 = INT64_MIN;
volatile uint32_t x982 = UINT32_MAX;
static int64_t x983 = INT64_MIN;
t192 = ((x981+x982)*(x983%x984));
if (t192 != 0LL) { NG(); } else { ; }
}
void f193(void) {
static uint16_t x985 = 5237U;
volatile int16_t x986 = INT16_MAX;
int64_t x987 = -1LL;
int32_t x988 = 113401;
static int64_t t193 = 29167205692989LL;
t193 = ((x985+x986)*(x987%x988));
if (t193 != -38004LL) { NG(); } else { ; }
}
void f194(void) {
uint64_t x1005 = 2795497891410409296LLU;
uint32_t x1006 = UINT32_MAX;
uint8_t x1007 = 83U;
volatile int64_t x1008 = INT64_MIN;
t194 = ((x1005+x1006)*(x1007%x1008));
if (t194 != 10665396459031637661LLU) { NG(); } else { ; }
}
void f195(void) {
int8_t x1009 = -1;
volatile int8_t x1010 = INT8_MIN;
int64_t x1011 = INT64_MIN;
uint8_t x1012 = 5U;
volatile int64_t t195 = -21383771041LL;
t195 = ((x1009+x1010)*(x1011%x1012));
if (t195 != 387LL) { NG(); } else { ; }
}
void f196(void) {
static uint64_t x1013 = 1LLU;
static uint8_t x1014 = 11U;
static int32_t x1015 = -1423;
int64_t x1016 = INT64_MIN;
volatile uint64_t t196 = 3656LLU;
t196 = ((x1013+x1014)*(x1015%x1016));
if (t196 != 18446744073709534540LLU) { NG(); } else { ; }
}
void f197(void) {
static int64_t x1017 = INT64_MAX;
volatile int32_t x1018 = INT32_MIN;
static int32_t x1019 = INT32_MIN;
volatile uint64_t x1020 = UINT64_MAX;
t197 = ((x1017+x1018)*(x1019%x1020));
if (t197 != 4611686020574871552LLU) { NG(); } else { ; }
}
void f198(void) {
uint32_t x1021 = 45055U;
volatile int16_t x1022 = INT16_MAX;
volatile int8_t x1023 = 1;
int64_t x1024 = INT64_MIN;
static int64_t t198 = 63994646645679222LL;
t198 = ((x1021+x1022)*(x1023%x1024));
if (t198 != 77822LL) { NG(); } else { ; }
}
void f199(void) {
int32_t x1027 = -1;
static int64_t x1028 = 22734175510207196LL;
t199 = ((x1025+x1026)*(x1027%x1028));
if (t199 != 32513LL) { NG(); } else { ; }
}
int main(void) {
f0();
f1();
f2();
f3();
f4();
f5();
f6();
f7();
f8();
f9();
f10();
f11();
f12();
f13();
f14();
f15();
f16();
f17();
f18();
f19();
f20();
f21();
f22();
f23();
f24();
f25();
f26();
f27();
f28();
f29();
f30();
f31();
f32();
f33();
f34();
f35();
f36();
f37();
f38();
f39();
f40();
f41();
f42();
f43();
f44();
f45();
f46();
f47();
f48();
f49();
f50();
f51();
f52();
f53();
f54();
f55();
f56();
f57();
f58();
f59();
f60();
f61();
f62();
f63();
f64();
f65();
f66();
f67();
f68();
f69();
f70();
f71();
f72();
f73();
f74();
f75();
f76();
f77();
f78();
f79();
f80();
f81();
f82();
f83();
f84();
f85();
f86();
f87();
f88();
f89();
f90();
f91();
f92();
f93();
f94();
f95();
f96();
f97();
f98();
f99();
f100();
f101();
f102();
f103();
f104();
f105();
f106();
f107();
f108();
f109();
f110();
f111();
f112();
f113();
f114();
f115();
f116();
f117();
f118();
f119();
f120();
f121();
f122();
f123();
f124();
f125();
f126();
f127();
f128();
f129();
f130();
f131();
f132();
f133();
f134();
f135();
f136();
f137();
f138();
f139();
f140();
f141();
f142();
f143();
f144();
f145();
f146();
f147();
f148();
f149();
f150();
f151();
f152();
f153();
f154();
f155();
f156();
f157();
f158();
f159();
f160();
f161();
f162();
f163();
f164();
f165();
f166();
f167();
f168();
f169();
f170();
f171();
f172();
f173();
f174();
f175();
f176();
f177();
f178();
f179();
f180();
f181();
f182();
f183();
f184();
f185();
f186();
f187();
f188();
f189();
f190();
f191();
f192();
f193();
f194();
f195();
f196();
f197();
f198();
f199();
return 0;
}
| 19.420326 | 61 | 0.605328 |
2cfc136346054e4648c88d3ddab617bff11b95a3 | 1,116 | c | C | DeviceCode/Targets/OS/Toppers/hrp2/tecsgen/test/src/tKernel_templ.c | Sirokujira/MicroFrameworkPK_v4_3 | a0d80b4fd8eeda6dbdb58f6f7beb4f07f7ef563e | [
"Apache-2.0"
] | null | null | null | DeviceCode/Targets/OS/Toppers/hrp2/tecsgen/test/src/tKernel_templ.c | Sirokujira/MicroFrameworkPK_v4_3 | a0d80b4fd8eeda6dbdb58f6f7beb4f07f7ef563e | [
"Apache-2.0"
] | null | null | null | DeviceCode/Targets/OS/Toppers/hrp2/tecsgen/test/src/tKernel_templ.c | Sirokujira/MicroFrameworkPK_v4_3 | a0d80b4fd8eeda6dbdb58f6f7beb4f07f7ef563e | [
"Apache-2.0"
] | 1 | 2019-12-05T18:59:01.000Z | 2019-12-05T18:59:01.000Z | #include "tKernel_tecsgen.h"
/* 呼び口関数 */
/*
*/
/* 受け口関数 */
/*
* entry port: ka
* signature: sSyscall
*/
/*
* name: ka_cre_sem
* global_name: tKernel_ka_cre_sem
*/
ER_ID ka_cre_sem( tKernel_IDX idx)
{
struct tag_tKernel_CB *this;
if( VALID_IDX( idx ) ){
this = tKernel_GET_CELLCB(idx);
}else{
/* エラー処理コードをここに記述 */
}
}
/*
* name: ka_wai_sem
* global_name: tKernel_ka_wai_sem
*/
ER ka_wai_sem( tKernel_IDX idx, ID id)
{
struct tag_tKernel_CB *this;
if( VALID_IDX( idx ) ){
this = tKernel_GET_CELLCB(idx);
}else{
/* エラー処理コードをここに記述 */
}
}
/*
* name: ka_rel_sem
* global_name: tKernel_ka_rel_sem
*/
ER ka_rel_sem( tKernel_IDX idx, ID id)
{
struct tag_tKernel_CB *this;
if( VALID_IDX( idx ) ){
this = tKernel_GET_CELLCB(idx);
}else{
/* エラー処理コードをここに記述 */
}
}
/*
* name: ka_del_sem
* global_name: tKernel_ka_del_sem
*/
ER ka_del_sem( tKernel_IDX idx, ID id)
{
struct tag_tKernel_CB *this;
if( VALID_IDX( idx ) ){
this = tKernel_GET_CELLCB(idx);
}else{
/* エラー処理コードをここに記述 */
}
}
| 16.411765 | 44 | 0.605735 |
3207b02274d9532c035176868d06f809f4236833 | 4,847 | c | C | OpenEars/Dependencies/cmuclmtk/src/liblmest/compute_discount.c | yheng2/VoiceAssistance | 0161fdce9db02efbbeb141b647db511dac97c2ed | [
"MIT"
] | null | null | null | OpenEars/Dependencies/cmuclmtk/src/liblmest/compute_discount.c | yheng2/VoiceAssistance | 0161fdce9db02efbbeb141b647db511dac97c2ed | [
"MIT"
] | null | null | null | OpenEars/Dependencies/cmuclmtk/src/liblmest/compute_discount.c | yheng2/VoiceAssistance | 0161fdce9db02efbbeb141b647db511dac97c2ed | [
"MIT"
] | null | null | null | /* ====================================================================
* Copyright (c) 1999-2006 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* This work was supported in part by funding from the Defense Advanced
* Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED 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 CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES 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.
*
* ====================================================================
*
*/
/* Basically copied from version 1.
ARCHAN 20060331: Oh my gosh.
*/
#include "general.h" // from libs
#include "ngram.h"
#include "pc_general.h" // from libs
void compute_gt_discount(int n,
fof_t *freq_of_freq,
fof_sz_t fof_size,
unsigned short *disc_range,
int cutoff,
int verbosity,
disc_val_t **discounted_values);
void compute_gt_discount(int n,
fof_t *freq_of_freq,
fof_sz_t fof_size,
unsigned short *disc_range,
int cutoff,
int verbosity,
disc_val_t **discounted_values) {
/* Lots of this is lifted straight from V.1 */
flag done;
int r;
int K = 0;
double common_term;
double first_term;
double *D;
D = (double *) rr_calloc((*disc_range)+1,sizeof(double));
*discounted_values = D;
/* Trap standard things (taken from V.1) */
if (fof_size == 0)
return;
if (freq_of_freq[1] == 0) {
pc_message(verbosity,2,"Warning : %d-gram : f-of-f[1] = 0 --> %d-gram discounting is disabled.\n",n,n);
*disc_range=0;
return;
}
if (*disc_range + 1 > fof_size) {
pc_message(verbosity,2,"Warning : %d-gram : max. recorded f-o-f is only %d\n",n,fof_size);
pc_message(verbosity,2,"%d-gram discounting range is reset to %d.\n",fof_size,n,fof_size-1);
*disc_range = fof_size-1;
}
done = 0;
while (!done) {
if (*disc_range == 0) {
pc_message(verbosity,2,"Warning : %d-gram : Discounting is disabled.\n",n);
return;
}
if (*disc_range == 1) {
/* special treatment for 1gram if there is a zeroton count: */
if ((n==1) && freq_of_freq[0]>0) {
D[1] = freq_of_freq[1] / ((float) (freq_of_freq[1] + freq_of_freq[0]));
pc_message(verbosity,2,"Warning : %d-gram : Discounting range is 1; setting P(zeroton)=P(singleton).\nDiscounted value : %.2f\n",n,D[1]);
return;
}else
pc_message(verbosity,2,"Warning : %d-gram : Discounting range of 1 is equivalent to excluding \nsingletons.\n",n);
}
K = *disc_range;
common_term = ((double) (K+1) * freq_of_freq[K+1]) / freq_of_freq[1];
if (common_term<=0.0 || common_term>=1.0) {
pc_message(verbosity,2,"Warning : %d-gram : GT statistics are out of range; lowering cutoff to %d.\n",n,K-1);
(*disc_range)--;
}else {
for (r=1;r<=K;r++) {
first_term = ((double) ((r+1) * freq_of_freq[r+1]))
/ (r * freq_of_freq[r]);
D[r]=(first_term - common_term)/(1.0 - common_term);
}
pc_message(verbosity,3,"%d-gram : cutoff = %d, discounted values:",n,K);
for (r=1;r<=K;r++)
pc_message(verbosity,3," %.2f",D[r]);
pc_message(verbosity,3,"\n");
done = 1;
for (r=1; r<=K; r++) {
if (D[r]<0 || D[r]>1.0) {
pc_message(verbosity,2,"Warning : %d-gram : Some discount values are out of range;\nlowering discounting range to %d.\n",n,K-1);
(*disc_range)--;
r=K+1;
done = 0;
}
}
}
}
for (r=1; r<=MIN(cutoff,K); r++) D[r] = 0.0;
}
| 33.895105 | 138 | 0.620384 |
d62cc630eeaaf86aa550010b4072dfa77fead091 | 3,464 | h | C | Modules/breadwallet-core/Java/com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest.h | Electra-project/Electra-ios | 64ff42b328b85e085f6a13fcd665c60c25df0ea3 | [
"MIT"
] | 1 | 2019-10-22T23:08:08.000Z | 2019-10-22T23:08:08.000Z | Modules/breadwallet-core/Java/com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest.h | Electra-project/Electra-ios | 64ff42b328b85e085f6a13fcd665c60c25df0ea3 | [
"MIT"
] | null | null | null | Modules/breadwallet-core/Java/com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest.h | Electra-project/Electra-ios | 64ff42b328b85e085f6a13fcd665c60c25df0ea3 | [
"MIT"
] | 3 | 2020-01-06T08:54:25.000Z | 2020-12-06T12:45:06.000Z | /* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest */
#ifndef _Included_com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
#define _Included_com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: getSenderPublicKeyReference
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_getSenderPublicKeyReference
(JNIEnv *, jobject);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: getAmount
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_getAmount
(JNIEnv *, jobject);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: getPKIType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_getPKIType
(JNIEnv *, jobject);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: getPKIData
* Signature: ()[B
*/
JNIEXPORT jbyteArray JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_getPKIData
(JNIEnv *, jobject);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: getMemo
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_getMemo
(JNIEnv *, jobject);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: getNotifyURL
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_getNotifyURL
(JNIEnv *, jobject);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: getSignature
* Signature: ()[B
*/
JNIEXPORT jbyteArray JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_getSignature
(JNIEnv *, jobject);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: createPaymentProtocolInvoiceRequest
* Signature: ([B)J
*/
JNIEXPORT jlong JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_createPaymentProtocolInvoiceRequest
(JNIEnv *, jclass, jbyteArray);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: createPaymentProtocolInvoiceRequestFull
* Signature: (Lcom/electraproject/core/BRCoreKey;JLjava/lang/String;[BLjava/lang/String;Ljava/lang/String;[B)J
*/
JNIEXPORT jlong JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_createPaymentProtocolInvoiceRequestFull
(JNIEnv *, jclass, jobject, jlong, jstring, jbyteArray, jstring, jstring, jbyteArray);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: serialize
* Signature: ()[B
*/
JNIEXPORT jbyteArray JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_serialize
(JNIEnv *, jobject);
/*
* Class: com_breadwallet_core_BRCorePaymentProtocolInvoiceRequest
* Method: disposeNative
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_electraproject_core_BRCorePaymentProtocolInvoiceRequest_disposeNative
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
| 33.960784 | 128 | 0.814376 |
32623965c78d32afd9cd2490d8feaa9b5be3d45e | 24,018 | c | C | pargres/src/backend/access/index/indexam.c | mzym/thesis | 4099fbfc6ccf82acd86001aeb8202dafe8fb499f | [
"MIT"
] | null | null | null | pargres/src/backend/access/index/indexam.c | mzym/thesis | 4099fbfc6ccf82acd86001aeb8202dafe8fb499f | [
"MIT"
] | null | null | null | pargres/src/backend/access/index/indexam.c | mzym/thesis | 4099fbfc6ccf82acd86001aeb8202dafe8fb499f | [
"MIT"
] | null | null | null | /*-------------------------------------------------------------------------
*
* indexam.c
* general index access method routines
*
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.114 2009/06/11 14:48:54 momjian Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relation OID
* index_close - close an index relation
* index_beginscan - start a scan of an index with amgettuple
* index_beginscan_bitmap - start a scan of an index with amgetbitmap
* index_rescan - restart a scan of an index
* index_endscan - end a scan
* index_insert - insert an index tuple into a relation
* index_markpos - mark a scan position
* index_restrpos - restore a scan position
* index_getnext - get the next tuple from a scan
* index_getbitmap - get all tuples from a scan
* index_bulk_delete - bulk deletion of index tuples
* index_vacuum_cleanup - post-deletion cleanup of an index
* index_getprocid - get a support procedure OID
* index_getprocinfo - get a support procedure's lookup info
*
* NOTES
* This file contains the index_ routines which used
* to be a scattered collection of stuff in access/genam.
*
*
* old comments
* Scans are implemented as follows:
*
* `0' represents an invalid item pointer.
* `-' represents an unknown item pointer.
* `X' represents a known item pointers.
* `+' represents known or invalid item pointers.
* `*' represents any item pointers.
*
* State is represented by a triple of these symbols in the order of
* previous, current, next. Note that the case of reverse scans works
* identically.
*
* State Result
* (1) + + - + 0 0 (if the next item pointer is invalid)
* (2) + X - (otherwise)
* (3) * 0 0 * 0 0 (no change)
* (4) + X 0 X 0 0 (shift)
* (5) * + X + X - (shift, add unknown)
*
* All other states cannot occur.
*
* Note: It would be possible to cache the status of the previous and
* next item pointer using the flags.
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/relscan.h"
#include "access/transam.h"
#include "pgstat.h"
#include "storage/bufmgr.h"
#include "storage/lmgr.h"
#include "utils/relcache.h"
#include "utils/snapmgr.h"
#include "utils/tqual.h"
/* ----------------------------------------------------------------
* macros used in index_ routines
* ----------------------------------------------------------------
*/
#define RELATION_CHECKS \
( \
AssertMacro(RelationIsValid(indexRelation)), \
AssertMacro(PointerIsValid(indexRelation->rd_am)) \
)
#define SCAN_CHECKS \
( \
AssertMacro(IndexScanIsValid(scan)), \
AssertMacro(RelationIsValid(scan->indexRelation)), \
AssertMacro(PointerIsValid(scan->indexRelation->rd_am)) \
)
#define GET_REL_PROCEDURE(pname) \
do { \
procedure = &indexRelation->rd_aminfo->pname; \
if (!OidIsValid(procedure->fn_oid)) \
{ \
RegProcedure procOid = indexRelation->rd_am->pname; \
if (!RegProcedureIsValid(procOid)) \
elog(ERROR, "invalid %s regproc", CppAsString(pname)); \
fmgr_info_cxt(procOid, procedure, indexRelation->rd_indexcxt); \
} \
} while(0)
#define GET_SCAN_PROCEDURE(pname) \
do { \
procedure = &scan->indexRelation->rd_aminfo->pname; \
if (!OidIsValid(procedure->fn_oid)) \
{ \
RegProcedure procOid = scan->indexRelation->rd_am->pname; \
if (!RegProcedureIsValid(procOid)) \
elog(ERROR, "invalid %s regproc", CppAsString(pname)); \
fmgr_info_cxt(procOid, procedure, scan->indexRelation->rd_indexcxt); \
} \
} while(0)
static IndexScanDesc index_beginscan_internal(Relation indexRelation,
int nkeys, ScanKey key);
/* ----------------------------------------------------------------
* index_ interface functions
* ----------------------------------------------------------------
*/
/* ----------------
* index_open - open an index relation by relation OID
*
* If lockmode is not "NoLock", the specified kind of lock is
* obtained on the index. (Generally, NoLock should only be
* used if the caller knows it has some appropriate lock on the
* index already.)
*
* An error is raised if the index does not exist.
*
* This is a convenience routine adapted for indexscan use.
* Some callers may prefer to use relation_open directly.
* ----------------
*/
Relation
index_open(Oid relationId, LOCKMODE lockmode)
{
Relation r;
r = relation_open(relationId, lockmode);
if (r->rd_rel->relkind != RELKIND_INDEX)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an index",
RelationGetRelationName(r))));
return r;
}
/* ----------------
* index_close - close an index relation
*
* If lockmode is not "NoLock", we then release the specified lock.
*
* Note that it is often sensible to hold a lock beyond index_close;
* in that case, the lock is released automatically at xact end.
* ----------------
*/
void
index_close(Relation relation, LOCKMODE lockmode)
{
LockRelId relid = relation->rd_lockInfo.lockRelId;
Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
/* The relcache does the real work... */
RelationClose(relation);
if (lockmode != NoLock)
UnlockRelationId(&relid, lockmode);
}
/* ----------------
* index_insert - insert an index tuple into a relation
* ----------------
*/
bool
index_insert(Relation indexRelation,
Datum *values,
bool *isnull,
ItemPointer heap_t_ctid,
Relation heapRelation,
bool check_uniqueness)
{
FmgrInfo *procedure;
RELATION_CHECKS;
GET_REL_PROCEDURE(aminsert);
/*
* have the am's insert proc do all the work.
*/
return DatumGetBool(FunctionCall6(procedure,
PointerGetDatum(indexRelation),
PointerGetDatum(values),
PointerGetDatum(isnull),
PointerGetDatum(heap_t_ctid),
PointerGetDatum(heapRelation),
BoolGetDatum(check_uniqueness)));
}
/*
* index_beginscan - start a scan of an index with amgettuple
*
* Caller must be holding suitable locks on the heap and the index.
*/
IndexScanDesc
index_beginscan(Relation heapRelation,
Relation indexRelation,
Snapshot snapshot,
int nkeys, ScanKey key)
{
IndexScanDesc scan;
scan = index_beginscan_internal(indexRelation, nkeys, key);
/*
* Save additional parameters into the scandesc. Everything else was set
* up by RelationGetIndexScan.
*/
scan->heapRelation = heapRelation;
scan->xs_snapshot = snapshot;
return scan;
}
/*
* index_beginscan_bitmap - start a scan of an index with amgetbitmap
*
* As above, caller had better be holding some lock on the parent heap
* relation, even though it's not explicitly mentioned here.
*/
IndexScanDesc
index_beginscan_bitmap(Relation indexRelation,
Snapshot snapshot,
int nkeys, ScanKey key)
{
IndexScanDesc scan;
scan = index_beginscan_internal(indexRelation, nkeys, key);
/*
* Save additional parameters into the scandesc. Everything else was set
* up by RelationGetIndexScan.
*/
scan->xs_snapshot = snapshot;
return scan;
}
/*
* index_beginscan_internal --- common code for index_beginscan variants
*/
static IndexScanDesc
index_beginscan_internal(Relation indexRelation,
int nkeys, ScanKey key)
{
IndexScanDesc scan;
FmgrInfo *procedure;
RELATION_CHECKS;
GET_REL_PROCEDURE(ambeginscan);
/*
* We hold a reference count to the relcache entry throughout the scan.
*/
RelationIncrementReferenceCount(indexRelation);
/*
* Tell the AM to open a scan.
*/
scan = (IndexScanDesc)
DatumGetPointer(FunctionCall3(procedure,
PointerGetDatum(indexRelation),
Int32GetDatum(nkeys),
PointerGetDatum(key)));
return scan;
}
/* ----------------
* index_rescan - (re)start a scan of an index
*
* The caller may specify a new set of scankeys (but the number of keys
* cannot change). To restart the scan without changing keys, pass NULL
* for the key array.
*
* Note that this is also called when first starting an indexscan;
* see RelationGetIndexScan. Keys *must* be passed in that case,
* unless scan->numberOfKeys is zero.
* ----------------
*/
void
index_rescan(IndexScanDesc scan, ScanKey key)
{
FmgrInfo *procedure;
SCAN_CHECKS;
GET_SCAN_PROCEDURE(amrescan);
/* Release any held pin on a heap page */
if (BufferIsValid(scan->xs_cbuf))
{
ReleaseBuffer(scan->xs_cbuf);
scan->xs_cbuf = InvalidBuffer;
}
scan->xs_next_hot = InvalidOffsetNumber;
scan->kill_prior_tuple = false; /* for safety */
FunctionCall2(procedure,
PointerGetDatum(scan),
PointerGetDatum(key));
}
/* ----------------
* index_endscan - end a scan
* ----------------
*/
void
index_endscan(IndexScanDesc scan)
{
FmgrInfo *procedure;
SCAN_CHECKS;
GET_SCAN_PROCEDURE(amendscan);
/* Release any held pin on a heap page */
if (BufferIsValid(scan->xs_cbuf))
{
ReleaseBuffer(scan->xs_cbuf);
scan->xs_cbuf = InvalidBuffer;
}
/* End the AM's scan */
FunctionCall1(procedure, PointerGetDatum(scan));
/* Release index refcount acquired by index_beginscan */
RelationDecrementReferenceCount(scan->indexRelation);
/* Release the scan data structure itself */
IndexScanEnd(scan);
}
/* ----------------
* index_markpos - mark a scan position
* ----------------
*/
void
index_markpos(IndexScanDesc scan)
{
FmgrInfo *procedure;
SCAN_CHECKS;
GET_SCAN_PROCEDURE(ammarkpos);
FunctionCall1(procedure, PointerGetDatum(scan));
}
/* ----------------
* index_restrpos - restore a scan position
*
* NOTE: this only restores the internal scan state of the index AM.
* The current result tuple (scan->xs_ctup) doesn't change. See comments
* for ExecRestrPos().
*
* NOTE: in the presence of HOT chains, mark/restore only works correctly
* if the scan's snapshot is MVCC-safe; that ensures that there's at most one
* returnable tuple in each HOT chain, and so restoring the prior state at the
* granularity of the index AM is sufficient. Since the only current user
* of mark/restore functionality is nodeMergejoin.c, this effectively means
* that merge-join plans only work for MVCC snapshots. This could be fixed
* if necessary, but for now it seems unimportant.
* ----------------
*/
void
index_restrpos(IndexScanDesc scan)
{
FmgrInfo *procedure;
Assert(IsMVCCSnapshot(scan->xs_snapshot));
SCAN_CHECKS;
GET_SCAN_PROCEDURE(amrestrpos);
scan->xs_next_hot = InvalidOffsetNumber;
scan->kill_prior_tuple = false; /* for safety */
FunctionCall1(procedure, PointerGetDatum(scan));
}
/* ----------------
* index_getnext - get the next heap tuple from a scan
*
* The result is the next heap tuple satisfying the scan keys and the
* snapshot, or NULL if no more matching tuples exist. On success,
* the buffer containing the heap tuple is pinned (the pin will be dropped
* at the next index_getnext or index_endscan).
*
* Note: caller must check scan->xs_recheck, and perform rechecking of the
* scan keys if required. We do not do that here because we don't have
* enough information to do it efficiently in the general case.
* ----------------
*/
HeapTuple
index_getnext(IndexScanDesc scan, ScanDirection direction)
{
HeapTuple heapTuple = &scan->xs_ctup;
ItemPointer tid = &heapTuple->t_self;
FmgrInfo *procedure;
SCAN_CHECKS;
GET_SCAN_PROCEDURE(amgettuple);
Assert(TransactionIdIsValid(RecentGlobalXmin));
/*
* We always reset xs_hot_dead; if we are here then either we are just
* starting the scan, or we previously returned a visible tuple, and in
* either case it's inappropriate to kill the prior index entry.
*/
scan->xs_hot_dead = false;
for (;;)
{
OffsetNumber offnum;
bool at_chain_start;
Page dp;
if (scan->xs_next_hot != InvalidOffsetNumber)
{
/*
* We are resuming scan of a HOT chain after having returned an
* earlier member. Must still hold pin on current heap page.
*/
Assert(BufferIsValid(scan->xs_cbuf));
Assert(ItemPointerGetBlockNumber(tid) ==
BufferGetBlockNumber(scan->xs_cbuf));
Assert(TransactionIdIsValid(scan->xs_prev_xmax));
offnum = scan->xs_next_hot;
at_chain_start = false;
scan->xs_next_hot = InvalidOffsetNumber;
}
else
{
bool found;
Buffer prev_buf;
/*
* If we scanned a whole HOT chain and found only dead tuples,
* tell index AM to kill its entry for that TID.
*/
scan->kill_prior_tuple = scan->xs_hot_dead;
/*
* The AM's gettuple proc finds the next index entry matching the
* scan keys, and puts the TID in xs_ctup.t_self (ie, *tid). It
* should also set scan->xs_recheck, though we pay no attention to
* that here.
*/
found = DatumGetBool(FunctionCall2(procedure,
PointerGetDatum(scan),
Int32GetDatum(direction)));
/* Reset kill flag immediately for safety */
scan->kill_prior_tuple = false;
/* If we're out of index entries, break out of outer loop */
if (!found)
break;
pgstat_count_index_tuples(scan->indexRelation, 1);
/* Switch to correct buffer if we don't have it already */
prev_buf = scan->xs_cbuf;
scan->xs_cbuf = ReleaseAndReadBuffer(scan->xs_cbuf,
scan->heapRelation,
ItemPointerGetBlockNumber(tid));
/*
* Prune page, but only if we weren't already on this page
*/
if (prev_buf != scan->xs_cbuf)
heap_page_prune_opt(scan->heapRelation, scan->xs_cbuf,
RecentGlobalXmin);
/* Prepare to scan HOT chain starting at index-referenced offnum */
offnum = ItemPointerGetOffsetNumber(tid);
at_chain_start = true;
/* We don't know what the first tuple's xmin should be */
scan->xs_prev_xmax = InvalidTransactionId;
/* Initialize flag to detect if all entries are dead */
scan->xs_hot_dead = true;
}
/* Obtain share-lock on the buffer so we can examine visibility */
LockBuffer(scan->xs_cbuf, BUFFER_LOCK_SHARE);
dp = (Page) BufferGetPage(scan->xs_cbuf);
/* Scan through possible multiple members of HOT-chain */
for (;;)
{
ItemId lp;
ItemPointer ctid;
/* check for bogus TID */
if (offnum < FirstOffsetNumber ||
offnum > PageGetMaxOffsetNumber(dp))
break;
lp = PageGetItemId(dp, offnum);
/* check for unused, dead, or redirected items */
if (!ItemIdIsNormal(lp))
{
/* We should only see a redirect at start of chain */
if (ItemIdIsRedirected(lp) && at_chain_start)
{
/* Follow the redirect */
offnum = ItemIdGetRedirect(lp);
at_chain_start = false;
continue;
}
/* else must be end of chain */
break;
}
/*
* We must initialize all of *heapTuple (ie, scan->xs_ctup) since
* it is returned to the executor on success.
*/
heapTuple->t_data = (HeapTupleHeader) PageGetItem(dp, lp);
heapTuple->t_len = ItemIdGetLength(lp);
ItemPointerSetOffsetNumber(tid, offnum);
heapTuple->t_tableOid = RelationGetRelid(scan->heapRelation);
ctid = &heapTuple->t_data->t_ctid;
/*
* Shouldn't see a HEAP_ONLY tuple at chain start. (This test
* should be unnecessary, since the chain root can't be removed
* while we have pin on the index entry, but let's make it
* anyway.)
*/
if (at_chain_start && HeapTupleIsHeapOnly(heapTuple))
break;
/*
* The xmin should match the previous xmax value, else chain is
* broken. (Note: this test is not optional because it protects
* us against the case where the prior chain member's xmax aborted
* since we looked at it.)
*/
if (TransactionIdIsValid(scan->xs_prev_xmax) &&
!TransactionIdEquals(scan->xs_prev_xmax,
HeapTupleHeaderGetXmin(heapTuple->t_data)))
break;
/* If it's visible per the snapshot, we must return it */
if (HeapTupleSatisfiesVisibility(heapTuple, scan->xs_snapshot,
scan->xs_cbuf))
{
/*
* If the snapshot is MVCC, we know that it could accept at
* most one member of the HOT chain, so we can skip examining
* any more members. Otherwise, check for continuation of the
* HOT-chain, and set state for next time.
*/
if (IsMVCCSnapshot(scan->xs_snapshot))
scan->xs_next_hot = InvalidOffsetNumber;
else if (HeapTupleIsHotUpdated(heapTuple))
{
Assert(ItemPointerGetBlockNumber(ctid) ==
ItemPointerGetBlockNumber(tid));
scan->xs_next_hot = ItemPointerGetOffsetNumber(ctid);
scan->xs_prev_xmax = HeapTupleHeaderGetXmax(heapTuple->t_data);
}
else
scan->xs_next_hot = InvalidOffsetNumber;
LockBuffer(scan->xs_cbuf, BUFFER_LOCK_UNLOCK);
pgstat_count_heap_fetch(scan->indexRelation);
return heapTuple;
}
/*
* If we can't see it, maybe no one else can either. Check to see
* if the tuple is dead to all transactions. If we find that all
* the tuples in the HOT chain are dead, we'll signal the index AM
* to not return that TID on future indexscans.
*/
if (scan->xs_hot_dead &&
HeapTupleSatisfiesVacuum(heapTuple->t_data, RecentGlobalXmin,
scan->xs_cbuf) != HEAPTUPLE_DEAD)
scan->xs_hot_dead = false;
/*
* Check to see if HOT chain continues past this tuple; if so
* fetch the next offnum (we don't bother storing it into
* xs_next_hot, but must store xs_prev_xmax), and loop around.
*/
if (HeapTupleIsHotUpdated(heapTuple))
{
Assert(ItemPointerGetBlockNumber(ctid) ==
ItemPointerGetBlockNumber(tid));
offnum = ItemPointerGetOffsetNumber(ctid);
at_chain_start = false;
scan->xs_prev_xmax = HeapTupleHeaderGetXmax(heapTuple->t_data);
}
else
break; /* end of chain */
} /* loop over a single HOT chain */
LockBuffer(scan->xs_cbuf, BUFFER_LOCK_UNLOCK);
/* Loop around to ask index AM for another TID */
scan->xs_next_hot = InvalidOffsetNumber;
}
/* Release any held pin on a heap page */
if (BufferIsValid(scan->xs_cbuf))
{
ReleaseBuffer(scan->xs_cbuf);
scan->xs_cbuf = InvalidBuffer;
}
return NULL; /* failure exit */
}
/* ----------------
* index_getbitmap - get all tuples at once from an index scan
*
* Adds the TIDs of all heap tuples satisfying the scan keys to a bitmap.
* Since there's no interlock between the index scan and the eventual heap
* access, this is only safe to use with MVCC-based snapshots: the heap
* item slot could have been replaced by a newer tuple by the time we get
* to it.
*
* Returns the number of matching tuples found. (Note: this might be only
* approximate, so it should only be used for statistical purposes.)
* ----------------
*/
int64
index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
{
FmgrInfo *procedure;
int64 ntids;
Datum d;
SCAN_CHECKS;
GET_SCAN_PROCEDURE(amgetbitmap);
/* just make sure this is false... */
scan->kill_prior_tuple = false;
/*
* have the am's getbitmap proc do all the work.
*/
d = FunctionCall2(procedure,
PointerGetDatum(scan),
PointerGetDatum(bitmap));
ntids = DatumGetInt64(d);
/* If int8 is pass-by-ref, must free the result to avoid memory leak */
#ifndef USE_FLOAT8_BYVAL
pfree(DatumGetPointer(d));
#endif
pgstat_count_index_tuples(scan->indexRelation, ntids);
return ntids;
}
/* ----------------
* index_bulk_delete - do mass deletion of index entries
*
* callback routine tells whether a given main-heap tuple is
* to be deleted
*
* return value is an optional palloc'd struct of statistics
* ----------------
*/
IndexBulkDeleteResult *
index_bulk_delete(IndexVacuumInfo *info,
IndexBulkDeleteResult *stats,
IndexBulkDeleteCallback callback,
void *callback_state)
{
Relation indexRelation = info->index;
FmgrInfo *procedure;
IndexBulkDeleteResult *result;
RELATION_CHECKS;
GET_REL_PROCEDURE(ambulkdelete);
result = (IndexBulkDeleteResult *)
DatumGetPointer(FunctionCall4(procedure,
PointerGetDatum(info),
PointerGetDatum(stats),
PointerGetDatum((Pointer) callback),
PointerGetDatum(callback_state)));
return result;
}
/* ----------------
* index_vacuum_cleanup - do post-deletion cleanup of an index
*
* return value is an optional palloc'd struct of statistics
* ----------------
*/
IndexBulkDeleteResult *
index_vacuum_cleanup(IndexVacuumInfo *info,
IndexBulkDeleteResult *stats)
{
Relation indexRelation = info->index;
FmgrInfo *procedure;
IndexBulkDeleteResult *result;
RELATION_CHECKS;
GET_REL_PROCEDURE(amvacuumcleanup);
result = (IndexBulkDeleteResult *)
DatumGetPointer(FunctionCall2(procedure,
PointerGetDatum(info),
PointerGetDatum(stats)));
return result;
}
/* ----------------
* index_getprocid
*
* Index access methods typically require support routines that are
* not directly the implementation of any WHERE-clause query operator
* and so cannot be kept in pg_amop. Instead, such routines are kept
* in pg_amproc. These registered procedure OIDs are assigned numbers
* according to a convention established by the access method.
* The general index code doesn't know anything about the routines
* involved; it just builds an ordered list of them for
* each attribute on which an index is defined.
*
* As of Postgres 8.3, support routines within an operator family
* are further subdivided by the "left type" and "right type" of the
* query operator(s) that they support. The "default" functions for a
* particular indexed attribute are those with both types equal to
* the index opclass' opcintype (note that this is subtly different
* from the indexed attribute's own type: it may be a binary-compatible
* type instead). Only the default functions are stored in relcache
* entries --- access methods can use the syscache to look up non-default
* functions.
*
* This routine returns the requested default procedure OID for a
* particular indexed attribute.
* ----------------
*/
RegProcedure
index_getprocid(Relation irel,
AttrNumber attnum,
uint16 procnum)
{
RegProcedure *loc;
int nproc;
int procindex;
nproc = irel->rd_am->amsupport;
Assert(procnum > 0 && procnum <= (uint16) nproc);
procindex = (nproc * (attnum - 1)) + (procnum - 1);
loc = irel->rd_support;
Assert(loc != NULL);
return loc[procindex];
}
/* ----------------
* index_getprocinfo
*
* This routine allows index AMs to keep fmgr lookup info for
* support procs in the relcache. As above, only the "default"
* functions for any particular indexed attribute are cached.
*
* Note: the return value points into cached data that will be lost during
* any relcache rebuild! Therefore, either use the callinfo right away,
* or save it only after having acquired some type of lock on the index rel.
* ----------------
*/
FmgrInfo *
index_getprocinfo(Relation irel,
AttrNumber attnum,
uint16 procnum)
{
FmgrInfo *locinfo;
int nproc;
int procindex;
nproc = irel->rd_am->amsupport;
Assert(procnum > 0 && procnum <= (uint16) nproc);
procindex = (nproc * (attnum - 1)) + (procnum - 1);
locinfo = irel->rd_supportinfo;
Assert(locinfo != NULL);
locinfo += procindex;
/* Initialize the lookup info if first time through */
if (locinfo->fn_oid == InvalidOid)
{
RegProcedure *loc = irel->rd_support;
RegProcedure procId;
Assert(loc != NULL);
procId = loc[procindex];
/*
* Complain if function was not found during IndexSupportInitialize.
* This should not happen unless the system tables contain bogus
* entries for the index opclass. (If an AM wants to allow a support
* function to be optional, it can use index_getprocid.)
*/
if (!RegProcedureIsValid(procId))
elog(ERROR, "missing support function %d for attribute %d of index \"%s\"",
procnum, attnum, RelationGetRelationName(irel));
fmgr_info_cxt(procId, locinfo, irel->rd_indexcxt);
}
return locinfo;
}
| 28.289753 | 100 | 0.679657 |
d0f00a39f31a64d84398fac66b870c82bcce6562 | 1,966 | h | C | core/minute-ia/irq_handler.h | DHowett/fw-ectool | d5b5b5008d2f98400206deb182e8ce772b6df9df | [
"BSD-3-Clause"
] | 13 | 2021-12-26T06:48:29.000Z | 2022-03-13T10:21:14.000Z | core/minute-ia/irq_handler.h | DHowett/fw-ectool | d5b5b5008d2f98400206deb182e8ce772b6df9df | [
"BSD-3-Clause"
] | 1 | 2022-01-08T23:28:01.000Z | 2022-01-09T00:43:16.000Z | core/minute-ia/irq_handler.h | DHowett/fw-ectool | d5b5b5008d2f98400206deb182e8ce772b6df9df | [
"BSD-3-Clause"
] | 1 | 2022-01-09T07:48:44.000Z | 2022-01-09T07:48:44.000Z | /* Copyright 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Helper to declare IRQ handling routines */
#ifndef __CROS_EC_IRQ_HANDLER_H
#define __CROS_EC_IRQ_HANDLER_H
#include "registers.h"
#include "task.h"
#include "task_defs.h"
asm (".include \"core/minute-ia/irq_handler_common.S\"");
/* Helper macros to build the IRQ handler and priority struct names */
#define IRQ_HANDLER(irqname) CONCAT3(_irq_, irqname, _handler)
#define IRQ_PRIORITY(irqname) CONCAT2(prio_, irqname)
/*
* Macro to connect the interrupt handler "routine" to the irq number "irq" and
* ensure it is enabled in the interrupt controller with the right priority.
*
* Note: No 'naked' function support for x86, so function is implemented within
* __asm__
* Note: currently we don't allow nested irq handling
*/
#define DECLARE_IRQ(irq, routine) DECLARE_IRQ_(irq, routine, irq + 32 + 10)
/*
* Each irq has a irq_data structure placed in .rodata.irqs section,
* to be used for dynamically setting up interrupt gates
*/
#define DECLARE_IRQ_(irq_, routine_, vector) \
static void __attribute__((used)) routine_(void); \
void IRQ_HANDLER(irq_)(void); \
__asm__ (".section .rodata.irqs\n"); \
const struct irq_def __keep CONCAT4(__irq_, irq_, _, routine_) \
__attribute__((section(".rodata.irqs"))) = { \
.irq = irq_, \
.routine = routine_, \
.handler = IRQ_HANDLER(irq_) \
}; \
__asm__ ( \
".section .text._irq_" #irq_ "_handler\n" \
"_irq_" #irq_ "_handler:\n" \
"pusha\n" \
ASM_LOCK_PREFIX "addl $1, __in_isr\n" \
"irq_handler_common $0 $0 $" #irq_ "\n" \
"movl $"#vector ", " STRINGIFY(IOAPIC_EOI_REG_ADDR) "\n" \
"movl $0x00, " STRINGIFY(LAPIC_EOI_REG_ADDR) "\n" \
ASM_LOCK_PREFIX "subl $1, __in_isr\n" \
"popa\n" \
"iret\n" \
)
#endif /* __CROS_EC_IRQ_HANDLER_H */
| 35.107143 | 79 | 0.682604 |
d2a151f54078e538126490fd1eafad89022581e9 | 1,409 | h | C | src/qt/hashrategraphwidget.h | wizz13150/gapcoin-core | 424b36ac0f232583e51bbef0ba87f4b1a53fde70 | [
"MIT"
] | 5 | 2017-08-26T08:38:25.000Z | 2018-10-22T16:35:43.000Z | src/qt/hashrategraphwidget.h | wizz13150/gapcoin-core | 424b36ac0f232583e51bbef0ba87f4b1a53fde70 | [
"MIT"
] | 2 | 2021-04-20T12:10:49.000Z | 2021-05-09T09:36:08.000Z | src/qt/hashrategraphwidget.h | wizz13150/gapcoin-core | 424b36ac0f232583e51bbef0ba87f4b1a53fde70 | [
"MIT"
] | 3 | 2021-02-03T14:39:29.000Z | 2022-01-05T11:56:21.000Z | // Copyright (c) 2016-2019 Duality Blockchain Solutions Developers
// Copyright (c) 2011-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef QT_HASHRATEGRAPHWIDGET_H
#define QT_HASHRATEGRAPHWIDGET_H
#include <QQueue>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QPaintEvent;
class QTimer;
QT_END_NAMESPACE
class HashRateGraphWidget : public QWidget
{
Q_OBJECT
public:
explicit HashRateGraphWidget(QWidget *parent = 0);
enum GraphType {
MINER_HASHRATE = 0,
NETWORK_HASHRATE
};
enum SampleTime {
FIVE_MINUTES = 0,
TEN_MINUTES,
THIRTY_MINUTES,
ONE_HOUR,
EIGHT_HOURS,
TWELVE_HOURS,
ONE_DAY
};
GraphType graphType;
public Q_SLOTS:
void StopHashMeter();
void StartHashMeter();
void UpdateSampleTime(SampleTime time);
int64_t getHashRate();
void clear();
private:
void timerEvent(QTimerEvent *event);
void updateHashRateGraph();
void initGraph(QPainter& painter);
void drawHashRate(QPainter& painter);
void truncateSampleQueue();
unsigned int iDesiredSamples;
int64_t iMaxHashRate;
QQueue<int64_t> vSampleHashRate;
bool fPlotHashRate;
protected:
void paintEvent(QPaintEvent *);
};
#endif // QT_HASHRATEGRAPHWIDGET_H
| 21.676923 | 70 | 0.710433 |
9610e4a6cad976e825732eaaeef7e793e99fb356 | 1,409 | c | C | quickjs-lvgl-binding/lvgl-btn.c | lee88688/jerryscript-lvgl-binding | 24449e097b1145060742c978f350807090aeb510 | [
"MIT"
] | null | null | null | quickjs-lvgl-binding/lvgl-btn.c | lee88688/jerryscript-lvgl-binding | 24449e097b1145060742c978f350807090aeb510 | [
"MIT"
] | null | null | null | quickjs-lvgl-binding/lvgl-btn.c | lee88688/jerryscript-lvgl-binding | 24449e097b1145060742c978f350807090aeb510 | [
"MIT"
] | null | null | null | #include "lvgl.h"
#include "quickjs.h"
#include "cutils.h"
#include "lvgl-btn.h"
#include "lvgl-common.h"
static JSClassID js_lvgl_btn_class_id;
void js_lvgl_btn_finalizer(JSRuntime *rt, JSValue val) {
printf("delete btn\n");
lv_obj_t *obj = JS_GetOpaque(val, js_lvgl_btn_class_id);
lv_obj_del(obj);
}
static JSClassDef js_lvgl_btn_class = {
"LvglBtn",
.finalizer = js_lvgl_btn_finalizer,
// .call = js_lvgl_btn_constructor,
};
static const JSCFunctionListEntry js_lvgl_btn_proto_funcs[] = {
};
JSValue create_lvgl_btn(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) {
CREATE_COMMON_LVGL_OBJ("btn", lv_btn_create, lv_scr_act(), ctx, js_lvgl_btn_class_id, js_val);
return js_val;
}
int js_lvgl_btn_init(JSContext *ctx) {
JS_NewClassID(&js_lvgl_btn_class_id);
JS_NewClass(JS_GetRuntime(ctx), js_lvgl_btn_class_id, &js_lvgl_btn_class);
JSValue proto = JS_NewObjectClass(ctx, get_obj_class_id());
JS_SetPropertyFunctionList(ctx, proto, js_lvgl_btn_proto_funcs, countof(js_lvgl_btn_proto_funcs));
JS_SetPropertyStr(ctx, proto, "_class_id", JS_MKVAL(JS_TAG_INT, js_lvgl_btn_class_id));
JS_SetClassProto(ctx, js_lvgl_btn_class_id, proto);
JSValue global = JS_GetGlobalObject(ctx);
JS_SetPropertyStr(ctx, global, "createLvglBtn", JS_NewCFunction(ctx, create_lvgl_btn, "", 0));
JS_FreeValue(ctx, global);
return 0;
}
| 32.767442 | 102 | 0.753016 |
cf937ce5bf3232076f15e81a9e04db7d86354ff5 | 3,893 | h | C | src/balBifurcationParameters.h | danielelinaro/BAL | d735048d9962a0c424c29db93f774494c67b12a9 | [
"MIT"
] | 1 | 2020-02-02T22:30:37.000Z | 2020-02-02T22:30:37.000Z | src/balBifurcationParameters.h | danielelinaro/BAL | d735048d9962a0c424c29db93f774494c67b12a9 | [
"MIT"
] | null | null | null | src/balBifurcationParameters.h | danielelinaro/BAL | d735048d9962a0c424c29db93f774494c67b12a9 | [
"MIT"
] | null | null | null | /*=========================================================================
*
* Program: Bifurcation Analysis Library
* Module: balBifurcationParameters.h
*
* Copyright (C) 2009,2010 Daniele Linaro
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*=========================================================================*/
#ifndef _BALBIFURCATIONPARAMETERS_
#define _BALBIFURCATIONPARAMETERS_
#include <boost/shared_array.hpp>
#include "balParameters.h"
/**
* \file balBifurcationParameters.h
* \brief Definition of the class BifurcationParameters
*/
namespace bal {
/**
* \class BifurcationParameters
* \brief Class for storing the tuples of parameters required in the
* computation of a bifurcation diagram.
*
* This class is used by BifurcationDiagram to iterate over all the
* possible tuples of parameters needed to compute a bifurcation diagram.
* Suppose that the user wants to integrate a system that depends on four
* parameters: if they want to compute a bidimensional diagram, then it is
* sufficient to specify the upper and lower bounds of the 4 parameters.
* Those that do not change will have the same upper and lower bounds and
* a number of steps equal to one. The 2 parameters that have to change
* will have distinct values for the upper and lower bounds and a number of
* steps greater than one. If the number of steps along the two parameters
* is n1 and n2 respectively, then the total number of tuples given by
* BifurcationParameters will be n1*n2.
* An instance of BifurcationParameters stores internally the current
* tuple of parameters, so that a DynamicalSystem can use an instance of
* BifurcationParameters as if it were of type Parameters.
*
* \sa Parameters BifurcationDiagram DynamicalSystem
*/
class BifurcationParameters : public Parameters {
public:
BifurcationParameters(int np);
BifurcationParameters(const BifurcationParameters& bp);
~BifurcationParameters();
virtual Object* Clone() const;
void SetIthParameterLowerBound(int i, double p);
void SetIthParameter(int i, double p);
void SetIthParameterUpperBound(int i, double p);
void SetParameterBounds(const Parameters& lower, const Parameters& upper);
double GetIthParameterUpperBound(int i);
double GetIthParameter(int i);
double GetIthParameterLowerBound(int i);
bool SetNumberOfSteps(int i, int s);
void SetNumberOfSteps(const int *s);
int GetNumberOfSteps(int i) const;
void Reset();
int GetTotalNumberOfTuples() const;
bool Next();
bool HasTuples() const;
bool HasNext() const;
bool IsFirst() const;
bool IsLast() const;
protected:
void Setup();
private:
/** The lower bounds of the parameters. */
Parameters plower;
/** The upper bounds of the parameters. */
Parameters pupper;
/** The parameter steps for every parameter. */
boost::shared_array<double> steps;
/** The number of steps associated with every parameter. */
boost::shared_array<int> nsteps;
/** The current steps associated with every parameter. */
boost::shared_array<int> isteps;
/** The total number of steps, i.e. the product of the values contained
* in nsteps. */
int total;
/** The current parameters' tuple. */
int count;
};
} // namespace bal
#endif
| 35.072072 | 77 | 0.710506 |
65a568aec8102ff96d31b052a26a093b25e621e9 | 4,034 | h | C | System/Library/PrivateFrameworks/SpringBoard.framework/SBWidgetController.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | System/Library/PrivateFrameworks/SpringBoard.framework/SBWidgetController.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/SpringBoard.framework/SBWidgetController.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, September 27, 2020 at 11:44:57 AM Mountain Standard Time
* Operating System: Version 14.0 (Build 18A373)
* Image Source: /System/Library/PrivateFrameworks/SpringBoard.framework/SpringBoard
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <SpringBoard/SpringBoard-Structs.h>
#import <libobjc.A.dylib/WGWidgetDiscoveryControllerDelegate.h>
#import <libobjc.A.dylib/SBExtensionHandling.h>
#import <libobjc.A.dylib/SBHSidebarWidgetLearningObserver.h>
#import <libobjc.A.dylib/CSWidgetGroupViewControllerProviding.h>
@class WGWidgetDiscoveryController, SBHSidebarWidgetBootstrappingAdvisor, NSString;
@interface SBWidgetController : NSObject <WGWidgetDiscoveryControllerDelegate, SBExtensionHandling, SBHSidebarWidgetLearningObserver, CSWidgetGroupViewControllerProviding> {
WGWidgetDiscoveryController* _widgetDiscoveryController;
SBHSidebarWidgetBootstrappingAdvisor* _sidebarWidgetBootstrappingAdvisor;
}
@property (getter=_widgetDiscoveryController,nonatomic,retain) WGWidgetDiscoveryController * widgetDiscoveryController; //@synthesize widgetDiscoveryController=_widgetDiscoveryController - In the implementation block
@property (nonatomic,readonly) SBHSidebarWidgetBootstrappingAdvisor * sidebarWidgetBootstrappingAdvisor; //@synthesize sidebarWidgetBootstrappingAdvisor=_sidebarWidgetBootstrappingAdvisor - In the implementation block
@property (assign,nonatomic) BOOL bootstrapFavoriteWidgets;
@property (readonly) unsigned long long hash;
@property (readonly) Class superclass;
@property (copy,readonly) NSString * description;
@property (copy,readonly) NSString * debugDescription;
-(void)widgetDiscoveryController:(id)arg1 updateStatusBarAssertion:(id)arg2 withLegibilityStyle:(long long)arg3 ;
-(void)widgetDiscoveryController:(id)arg1 didChangeWidgetsPinning:(BOOL)arg2 ;
-(BOOL)shouldShowWidgetsPinningTeachingViewForWidgetDiscoveryController:(id)arg1 ;
-(void)widgetDiscoveryController:(id)arg1 requestUnlockWithCompletion:(/*^block*/id)arg2 ;
-(id)newWidgetGroupViewControllerWithSettings:(WGWidgetListSettings)arg1 ;
-(void)_updateFavoriteWidgetLearning;
-(id)statusBarAssertionForWidgetDiscoveryController:(id)arg1 legibilityStyle:(long long)arg2 ;
-(BOOL)shouldShowWidgetsPinButtonForWidgetDiscoveryController:(id)arg1 ;
-(SBHSidebarWidgetBootstrappingAdvisor *)sidebarWidgetBootstrappingAdvisor;
-(void)setWidgetDiscoveryController:(WGWidgetDiscoveryController *)arg1 ;
-(void)_homescreenSidebarVisibilityDidChange:(id)arg1 ;
-(void)_reloadWidgetPreferences;
-(id)init;
-(void)widgetDiscoveryController:(id)arg1 widgetWithBundleIdentifier:(id)arg2 didEncounterProblematicSnapshotAtURL:(id)arg3 ;
-(BOOL)bootstrapFavoriteWidgets;
-(BOOL)widgetDiscoveryControllerShouldIncludeInternalWidgets:(id)arg1 ;
-(void)setBootstrapFavoriteWidgets:(BOOL)arg1 ;
-(BOOL)didPurgeNonASTCSnapshotsForWidgetDiscoveryController:(id)arg1 ;
-(BOOL)_shouldUsePinnedWidgets;
-(id)newAvocadoWidgetListViewControllerWithSettings:(WGWidgetListSettings)arg1 ;
-(void)widgetDiscoveryControllerDidDismissWidgetsPinningTeachingView:(id)arg1 ;
-(void)widgetDiscoveryController:(id)arg1 didEndUsingStatusBarAssertion:(id)arg2 ;
-(BOOL)widgetDiscoveryController:(id)arg1 shouldPurgeArchivedSnapshotsForWidgetWithBundleIdentifier:(id)arg2 ;
-(id)todayWidgetIdentifiers;
-(void)sidebarWidgetLearningAdvisorDidUpdate:(id)arg1 ;
-(void)launchExtensionWithBundleID:(id)arg1 options:(id)arg2 completion:(/*^block*/id)arg3 ;
-(BOOL)widgetDiscoveryControllerShouldRespectFavorites:(id)arg1 ;
-(BOOL)areWidgetsPinnedForWidgetDiscoveryController:(id)arg1 ;
-(BOOL)didPurgeNonCAMLSnapshotsForWidgetDiscoveryController:(id)arg1 ;
-(id)_widgetDiscoveryController;
-(id)newWidgetListViewControllerWithSettings:(WGWidgetListSettings)arg1 ;
-(id)widgetDiscoveryController:(id)arg1 preferredViewControllerForPresentingFromViewController:(id)arg2 ;
-(void)removeWidgetIdentifiersFromToday:(id)arg1 ;
@end
| 61.121212 | 245 | 0.841844 |
d6b09cb1aa2c1e542de40c57328a13eb9bef0139 | 2,109 | c | C | kernel/linux-5.4/tools/testing/selftests/x86/syscall_numbering.c | josehu07/SplitFS | d7442fa67a17de7057664f91defbfdbf10dd7f4a | [
"Apache-2.0"
] | 31 | 2021-04-27T08:50:40.000Z | 2022-03-01T02:26:21.000Z | src/linux/tools/testing/selftests/x86/syscall_numbering.c | lukedsmalley/oo-kernel-hacking | 57161ae3e8a780a72b475b3c27fec8deef83b8e1 | [
"MIT"
] | 13 | 2021-07-10T04:36:17.000Z | 2022-03-03T10:50:05.000Z | src/linux/tools/testing/selftests/x86/syscall_numbering.c | lukedsmalley/oo-kernel-hacking | 57161ae3e8a780a72b475b3c27fec8deef83b8e1 | [
"MIT"
] | 12 | 2021-04-06T02:23:10.000Z | 2022-02-28T11:43:19.000Z | /* SPDX-License-Identifier: GPL-2.0 */
/*
* syscall_arg_fault.c - tests faults 32-bit fast syscall stack args
* Copyright (c) 2018 Andrew Lutomirski
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <unistd.h>
#include <syscall.h>
static int nerrs;
#define X32_BIT 0x40000000UL
static void check_enosys(unsigned long nr, bool *ok)
{
/* If this fails, a segfault is reasonably likely. */
fflush(stdout);
long ret = syscall(nr, 0, 0, 0, 0, 0, 0);
if (ret == 0) {
printf("[FAIL]\tsyscall %lu succeeded, but it should have failed\n", nr);
*ok = false;
} else if (errno != ENOSYS) {
printf("[FAIL]\tsyscall %lu had error code %d, but it should have reported ENOSYS\n", nr, errno);
*ok = false;
}
}
static void test_x32_without_x32_bit(void)
{
bool ok = true;
/*
* Syscalls 512-547 are "x32" syscalls. They are intended to be
* called with the x32 (0x40000000) bit set. Calling them without
* the x32 bit set is nonsense and should not work.
*/
printf("[RUN]\tChecking syscalls 512-547\n");
for (int i = 512; i <= 547; i++)
check_enosys(i, &ok);
/*
* Check that a handful of 64-bit-only syscalls are rejected if the x32
* bit is set.
*/
printf("[RUN]\tChecking some 64-bit syscalls in x32 range\n");
check_enosys(16 | X32_BIT, &ok); /* ioctl */
check_enosys(19 | X32_BIT, &ok); /* readv */
check_enosys(20 | X32_BIT, &ok); /* writev */
/*
* Check some syscalls with high bits set.
*/
printf("[RUN]\tChecking numbers above 2^32-1\n");
check_enosys((1UL << 32), &ok);
check_enosys(X32_BIT | (1UL << 32), &ok);
if (!ok)
nerrs++;
else
printf("[OK]\tThey all returned -ENOSYS\n");
}
int main()
{
/*
* Anyone diagnosing a failure will want to know whether the kernel
* supports x32. Tell them.
*/
printf("\tChecking for x32...");
fflush(stdout);
if (syscall(39 | X32_BIT, 0, 0, 0, 0, 0, 0) >= 0) {
printf(" supported\n");
} else if (errno == ENOSYS) {
printf(" not supported\n");
} else {
printf(" confused\n");
}
test_x32_without_x32_bit();
return nerrs ? 1 : 0;
}
| 23.433333 | 99 | 0.6477 |
65620363640d9771b6f724567a0ff39b8a4c791d | 2,848 | h | C | DataCollector/mozilla/xulrunner-sdk/include/nsSHEntryShared.h | andrasigneczi/TravelOptimiser | b08805f97f0823fd28975a36db67193386aceb22 | [
"Apache-2.0"
] | 1 | 2016-04-20T08:35:44.000Z | 2016-04-20T08:35:44.000Z | DataCollector/mozilla/xulrunner-sdk/include/nsSHEntryShared.h | andrasigneczi/TravelOptimiser | b08805f97f0823fd28975a36db67193386aceb22 | [
"Apache-2.0"
] | null | null | null | DataCollector/mozilla/xulrunner-sdk/include/nsSHEntryShared.h | andrasigneczi/TravelOptimiser | b08805f97f0823fd28975a36db67193386aceb22 | [
"Apache-2.0"
] | null | null | null | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsSHEntryShared_h__
#define nsSHEntryShared_h__
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsCOMArray.h"
#include "nsIBFCacheEntry.h"
#include "nsIMutationObserver.h"
#include "nsExpirationTracker.h"
#include "nsRect.h"
#include "nsString.h"
#include "mozilla/Attributes.h"
class nsSHEntry;
class nsISHEntry;
class nsIDocument;
class nsIContentViewer;
class nsIDocShellTreeItem;
class nsILayoutHistoryState;
class nsDocShellEditorData;
class nsISupportsArray;
// A document may have multiple SHEntries, either due to hash navigations or
// calls to history.pushState. SHEntries corresponding to the same document
// share many members; in particular, they share state related to the
// back/forward cache.
//
// nsSHEntryShared is the vehicle for this sharing.
class nsSHEntryShared final
: public nsIBFCacheEntry
, public nsIMutationObserver
{
public:
static void EnsureHistoryTracker();
static void Shutdown();
nsSHEntryShared();
NS_DECL_ISUPPORTS
NS_DECL_NSIMUTATIONOBSERVER
NS_DECL_NSIBFCACHEENTRY
private:
~nsSHEntryShared();
friend class nsSHEntry;
friend class HistoryTracker;
friend class nsExpirationTracker<nsSHEntryShared, 3>;
nsExpirationState *GetExpirationState() { return &mExpirationState; }
static already_AddRefed<nsSHEntryShared> Duplicate(nsSHEntryShared* aEntry);
void RemoveFromExpirationTracker();
void Expire();
nsresult SyncPresentationState();
void DropPresentationState();
nsresult SetContentViewer(nsIContentViewer* aViewer);
// See nsISHEntry.idl for an explanation of these members.
// These members are copied by nsSHEntryShared::Duplicate(). If you add a
// member here, be sure to update the Duplicate() implementation.
uint64_t mDocShellID;
nsCOMArray<nsIDocShellTreeItem> mChildShells;
nsCOMPtr<nsISupports> mOwner;
nsCString mContentType;
bool mIsFrameNavigation;
bool mSaveLayoutState;
bool mSticky;
bool mDynamicallyCreated;
nsCOMPtr<nsISupports> mCacheKey;
uint32_t mLastTouched;
// These members aren't copied by nsSHEntryShared::Duplicate() because
// they're specific to a particular content viewer.
uint64_t mID;
nsCOMPtr<nsIContentViewer> mContentViewer;
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
bool mExpired;
nsCOMPtr<nsISupports> mWindowState;
nsIntRect mViewerBounds;
nsCOMPtr<nsISupportsArray> mRefreshURIList;
nsExpirationState mExpirationState;
nsAutoPtr<nsDocShellEditorData> mEditorData;
};
#endif
| 29.360825 | 79 | 0.776334 |
aa98c7948b70455883bb9740b7b470e4a61f78e8 | 274 | h | C | Code/TJMWheelHouseDraftWsp/TJMWheelHouseDraftGeneralFrm/PublicInterfaces/TJMWheelHouseDraftGeneralM.h | msdos41/CATIA_CAA_V5 | bf831f7ecc3c4937b227782ee8bebf7c6675792a | [
"MIT"
] | 5 | 2019-11-14T05:42:38.000Z | 2022-03-12T12:51:46.000Z | Code/TJMWheelHouseDraftWsp/TJMWheelHouseDraftGeneralFrm/PublicInterfaces/TJMWheelHouseDraftGeneralM.h | msdos41/CATIA_CAA_V5 | bf831f7ecc3c4937b227782ee8bebf7c6675792a | [
"MIT"
] | null | null | null | Code/TJMWheelHouseDraftWsp/TJMWheelHouseDraftGeneralFrm/PublicInterfaces/TJMWheelHouseDraftGeneralM.h | msdos41/CATIA_CAA_V5 | bf831f7ecc3c4937b227782ee8bebf7c6675792a | [
"MIT"
] | 4 | 2020-01-02T13:48:07.000Z | 2022-01-05T04:23:30.000Z | #ifdef _WINDOWS_SOURCE
#ifdef __TJMWheelHouseDraftGeneralM
#define ExportedByTJMWheelHouseDraftGeneralM __declspec(dllexport)
#else
#define ExportedByTJMWheelHouseDraftGeneralM __declspec(dllimport)
#endif
#else
#define ExportedByTJMWheelHouseDraftGeneralM
#endif
| 27.4 | 70 | 0.857664 |
ecf76adeb069f20690b8e709d664586675eb717c | 1,656 | h | C | libs/np-syscall/include/SyscallEnums.h | dreamos82/northport | 2be1521b66164caeffe82948151b3cfe9c2b3c59 | [
"MIT"
] | 2 | 2022-03-25T20:44:01.000Z | 2022-03-28T20:43:54.000Z | libs/np-syscall/include/SyscallEnums.h | dreamos82/northport | 2be1521b66164caeffe82948151b3cfe9c2b3c59 | [
"MIT"
] | null | null | null | libs/np-syscall/include/SyscallEnums.h | dreamos82/northport | 2be1521b66164caeffe82948151b3cfe9c2b3c59 | [
"MIT"
] | null | null | null | #pragma once
#include <NativePtr.h>
namespace np::Syscall
{
constexpr NativeUInt SyscallSuccess = 0;
constexpr NativeUInt SyscallNotFound = 0x404;
enum class SyscallId : NativeUInt
{
LoopbackTest = 0x0,
MapMemory = 0x10,
UnmapMemory = 0x11,
ModifyMemoryFlags = 0x12,
MemoryMapFile = 0x13,
UnmapFile = 0x14,
FlushMappedFile = 0x15,
GetPrimaryDeviceInfo = 0x20,
GetDevicesOfType = 0x21,
GetDeviceInfo = 0x22,
GetFileInfo = 0x30,
OpenFile = 0x31,
CloseFile = 0x32,
ReadFromFile = 0x33,
WriteToFile = 0x34,
StartIpcStream = 0x40,
StopIpcStream = 0x41,
OpenIpcStream = 0x42,
CloseIpcStream = 0x43,
};
enum class MemoryMapFlags : NativeUInt
{
Writable = (1 << 0),
Executable = (1 << 1),
UserVisible = (1 << 2),
};
enum class DeviceType : NativeUInt
{
Framebuffer = 0,
GraphicsAdaptor = 1,
};
enum class DeviceError : NativeUInt
{
FeatureNotAvailable = 1,
NoPrimaryDevice = 2,
UnknownDeviceType = 3,
};
enum class FileError : NativeUInt
{
FileNotFound = 1,
NoResourceId = 2,
InvalidBufferRange = 3,
};
enum class IpcStreamFlags : NativeUInt
{
None = 0,
//if set, buffer is zero-copy, otherwise buffer is single copy (target->dest).
UseSharedMemory = (1 << 0),
};
enum class IpcError : NativeUInt
{
StreamStartFail = 1,
NoResourceId = 2,
InvalidBufferRange = 3,
};
}
| 21.230769 | 86 | 0.562198 |
e7581c7f6004d4b4e5ef0c28301266e80cbea7ca | 6,194 | c | C | test/sampleData/kubos/Example.c | polfeliu/cyanobyte | 94fb8b8ea6c226e7e5f2a42d39356c75693d4093 | [
"Apache-2.0"
] | 70 | 2019-03-15T03:38:00.000Z | 2022-03-16T20:31:10.000Z | test/sampleData/kubos/Example.c | polfeliu/cyanobyte | 94fb8b8ea6c226e7e5f2a42d39356c75693d4093 | [
"Apache-2.0"
] | 193 | 2019-03-15T21:33:40.000Z | 2021-06-04T22:19:02.000Z | test/sampleData/kubos/Example.c | polfeliu/cyanobyte | 94fb8b8ea6c226e7e5f2a42d39356c75693d4093 | [
"Apache-2.0"
] | 40 | 2019-03-15T21:41:51.000Z | 2021-06-18T14:56:33.000Z | /*
* Copyright (C) 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Auto-generated file for Example v0.1.0.
* Generated from peripherals/example.yaml using Cyanobyte Codegen v0.1.0
* Class for Example
* Example of a package
*/
#include "Example.h"
#define REGISTER_REGISTERA 0
#define REGISTER_REGISTERB 1
#define REGISTER_REGISTERC 2
#define REGISTER_REGISTERD 3
static int i2c_bus = 0; // Pointer to bus
// Provide `bus_name` based on application specifics.
// For example, you may pass in bus name "/dev/i2c-1"
static deviceAddress_t DEVICE_ADDRESS;
int example_init(deviceAddress_t address, char* bus_name) {
DEVICE_ADDRESS = address;
// Initialize bus
if (k_i2c_init(&bus_name, &i2c_bus) != I2C_OK) {
return -1;
}
example__lifecycle_begin();
}
void example_terminate() {
k_i2c_terminate(&i2c_bus);
}
int example_readRegisterA(uint8_t* val) {
if (val == NULL) {
return -1; // Need to provide a valid value pointer
}
if (k_i2c_read(i2c_bus, DEVICE_ADDRESS, val, 1) != I2C_OK) {
return -2;
}
return 0;
}
int example_writeRegisterA(uint8_t* data) {
// Put our data into uint8_t buffer
uint8_t buffer[2] = { (uint8_t) REGISTER_REGISTERA };
uint8_t buffer[1] = (data >> 8) & 0xFF;
// First write our register address
if (k_i2c_write(i2c_bus, DEVICE_ADDRESS, buffer, 2) != I2C_OK) {
return -1;
}
return 0;
}int example_readRegisterB(uint16_t* val) {
if (val == NULL) {
return -1; // Need to provide a valid value pointer
}
if (k_i2c_read(i2c_bus, DEVICE_ADDRESS, val, 2) != I2C_OK) {
return -2;
}
return 0;
}
int example_writeRegisterB(uint16_t* data) {
// Put our data into uint8_t buffer
uint8_t buffer[3] = { (uint8_t) REGISTER_REGISTERB };
uint8_t buffer[1] = (data >> 16) & 0xFF;
uint8_t buffer[2] = (data >> 8) & 0xFF;
// First write our register address
if (k_i2c_write(i2c_bus, DEVICE_ADDRESS, buffer, 3) != I2C_OK) {
return -1;
}
return 0;
}int example_readRegisterC(uint32_t* val) {
if (val == NULL) {
return -1; // Need to provide a valid value pointer
}
if (k_i2c_read(i2c_bus, DEVICE_ADDRESS, val, 4) != I2C_OK) {
return -2;
}
return 0;
}
int example_writeRegisterC(uint32_t* data) {
// Put our data into uint8_t buffer
uint8_t buffer[5] = { (uint8_t) REGISTER_REGISTERC };
uint8_t buffer[1] = (data >> 32) & 0xFF;
uint8_t buffer[2] = (data >> 24) & 0xFF;
uint8_t buffer[3] = (data >> 16) & 0xFF;
uint8_t buffer[4] = (data >> 8) & 0xFF;
// First write our register address
if (k_i2c_write(i2c_bus, DEVICE_ADDRESS, buffer, 5) != I2C_OK) {
return -1;
}
return 0;
}int example_readRegisterD(uint8_t* val) {
if (val == NULL) {
return -1; // Need to provide a valid value pointer
}
if (k_i2c_read(i2c_bus, DEVICE_ADDRESS, val, 0) != I2C_OK) {
return -2;
}
return 0;
}
int example_writeRegisterD() {
// Put our data into uint8_t buffer
uint8_t buffer[1] = { (uint8_t) REGISTER_REGISTERD };
// First write our register address
if (k_i2c_write(i2c_bus, DEVICE_ADDRESS, buffer, 1) != I2C_OK) {
return -1;
}
return 0;
}
int example_get_fielda(uint8_t* val) {
// Read register data
// '#/registers/RegisterA' > 'RegisterA'
int result = example_readRegisterA(val);
if (result != 0) {
return result;
}
// Mask register value
val = val & 0b0000000011110000;
// Bitshift value
val = val >> 4;
return 0;
}
int example_set_fieldb(uint8_t* data) {
// Bitshift value
data = data << 2;
// Read current register data
// '#/registers/RegisterA' > 'RegisterA'
uint8_t register_data;
int result = example_readRegisterA(®ister_data);
if (result != 0) {
return -1;
}
register_data = register_data | data;
result = example_writeRegisterA(®ister_data);
if (result != 0) {
return -2;
}
return 0;
}
int example_get_fieldc(uint8_t* val) {
// Read register data
// '#/registers/RegisterA' > 'RegisterA'
int result = example_readRegisterA(val);
if (result != 0) {
return result;
}
// Mask register value
val = val & 0b0000000000000010;
// Bitshift value
val = val >> 1;
return 0;
}
int example_set_fieldc(uint8_t* data) {
// Bitshift value
data = data << 1;
// Read current register data
// '#/registers/RegisterA' > 'RegisterA'
uint8_t register_data;
int result = example_readRegisterA(®ister_data);
if (result != 0) {
return -1;
}
register_data = register_data | data;
result = example_writeRegisterA(®ister_data);
if (result != 0) {
return -2;
}
return 0;
}
void example__lifecycle_begin(char* val) {
char output; // Variable declaration
output = 1
example_writeRegisterA(&output);
val = output;
}
void example__lifecycle_end(char* val) {
char output; // Variable declaration
output = 1
example_writeRegisterA(&output);
val = output;
}
void example_return_array(void* val) {
short summation; // Variable declaration
summation = (1024+1024);
example_writeRegisterA(&summation);
val = [summation, summation];
}
void example_return_number(short* val) {
short summation; // Variable declaration
summation = (1024+1024);
example_writeRegisterA(&summation);
val = summation;
}
void example_return_void() {
short summation; // Variable declaration
summation = (1024+1024);
example_writeRegisterA(&summation);
}
| 24.875502 | 74 | 0.646755 |
a11c22d0ddc4ee1d77e749fb4d761e8c36256745 | 2,891 | c | C | src/archiver_mvl.c | Jopnal/physfs | 73122834ba22e5e1edaa8ea6a188ba7134d447e2 | [
"Zlib"
] | 10 | 2017-02-26T15:53:26.000Z | 2021-11-08T03:44:40.000Z | src/archiver_mvl.c | Jopnal/physfs | 73122834ba22e5e1edaa8ea6a188ba7134d447e2 | [
"Zlib"
] | 3 | 2017-07-04T16:14:45.000Z | 2017-07-04T16:17:56.000Z | src/archiver_mvl.c | Jopnal/physfs | 73122834ba22e5e1edaa8ea6a188ba7134d447e2 | [
"Zlib"
] | 1 | 2020-07-18T01:36:49.000Z | 2020-07-18T01:36:49.000Z | /*
* MVL support routines for PhysicsFS.
*
* This driver handles Descent II Movielib archives.
*
* The file format of MVL is quite easy...
*
* //MVL File format - Written by Heiko Herrmann
* char sig[4] = {'D','M', 'V', 'L'}; // "DMVL"=Descent MoVie Library
*
* int num_files; // the number of files in this MVL
*
* struct {
* char file_name[13]; // Filename, padded to 13 bytes with 0s
* int file_size; // filesize in bytes
* }DIR_STRUCT[num_files];
*
* struct {
* char data[file_size]; // The file data
* }FILE_STRUCT[num_files];
*
* (That info is from http://www.descent2.com/ddn/specs/mvl/)
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Bradley Bell.
* Based on grp.c by Ryan C. Gordon.
*/
#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"
#if PHYSFS_SUPPORTS_MVL
static UNPKentry *mvlLoadEntries(PHYSFS_Io *io, PHYSFS_uint32 fileCount)
{
PHYSFS_uint32 location = 8; /* sizeof sig. */
UNPKentry *entries = NULL;
UNPKentry *entry = NULL;
entries = (UNPKentry *) allocator.Malloc(sizeof (UNPKentry) * fileCount);
BAIL_IF_MACRO(entries == NULL, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
location += (17 * fileCount);
for (entry = entries; fileCount > 0; fileCount--, entry++)
{
if (!__PHYSFS_readAll(io, &entry->name, 13)) goto failed;
if (!__PHYSFS_readAll(io, &entry->size, 4)) goto failed;
entry->size = PHYSFS_swapULE32(entry->size);
entry->startPos = location;
location += entry->size;
} /* for */
return entries;
failed:
allocator.Free(entries);
return NULL;
} /* mvlLoadEntries */
static void *MVL_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
{
PHYSFS_uint8 buf[4];
PHYSFS_uint32 count = 0;
UNPKentry *entries = NULL;
assert(io != NULL); /* shouldn't ever happen. */
BAIL_IF_MACRO(forWriting, PHYSFS_ERR_READ_ONLY, NULL);
BAIL_IF_MACRO(!__PHYSFS_readAll(io, buf, 4), ERRPASS, NULL);
BAIL_IF_MACRO(memcmp(buf, "DMVL", 4) != 0, PHYSFS_ERR_UNSUPPORTED, NULL);
BAIL_IF_MACRO(!__PHYSFS_readAll(io, &count, sizeof(count)), ERRPASS, NULL);
count = PHYSFS_swapULE32(count);
entries = mvlLoadEntries(io, count);
return (!entries) ? NULL : UNPK_openArchive(io, entries, count);
} /* MVL_openArchive */
const PHYSFS_Archiver __PHYSFS_Archiver_MVL =
{
CURRENT_PHYSFS_ARCHIVER_API_VERSION,
{
"MVL",
"Descent II Movielib format",
"Bradley Bell <btb@icculus.org>",
"https://icculus.org/physfs/",
0, /* supportsSymlinks */
},
MVL_openArchive,
UNPK_enumerateFiles,
UNPK_openRead,
UNPK_openWrite,
UNPK_openAppend,
UNPK_remove,
UNPK_mkdir,
UNPK_stat,
UNPK_closeArchive
};
#endif /* defined PHYSFS_SUPPORTS_MVL */
/* end of archiver_mvl.c ... */
| 27.273585 | 79 | 0.655483 |
c831e30411fa12c0e87714a09c9f6c1bf108fd38 | 37,367 | c | C | linux-4.14.90-dev/linux-4.14.90/drivers/scsi/aic94xx/aic94xx_sds.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | linux-4.14.90-dev/linux-4.14.90/drivers/scsi/aic94xx/aic94xx_sds.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 5 | 2020-04-04T09:24:09.000Z | 2020-04-19T12:33:55.000Z | linux-4.14.90-dev/linux-4.14.90/drivers/scsi/aic94xx/aic94xx_sds.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 30 | 2018-05-02T08:43:27.000Z | 2022-01-23T03:25:54.000Z | /*
* Aic94xx SAS/SATA driver access to shared data structures and memory
* maps.
*
* Copyright (C) 2005 Adaptec, Inc. All rights reserved.
* Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
*
* This file is licensed under GPLv2.
*
* This file is part of the aic94xx driver.
*
* The aic94xx driver 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; version 2 of the
* License.
*
* The aic94xx driver 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 the aic94xx driver; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include "aic94xx.h"
#include "aic94xx_reg.h"
#include "aic94xx_sds.h"
/* ---------- OCM stuff ---------- */
struct asd_ocm_dir_ent {
u8 type;
u8 offs[3];
u8 _r1;
u8 size[3];
} __attribute__ ((packed));
struct asd_ocm_dir {
char sig[2];
u8 _r1[2];
u8 major; /* 0 */
u8 minor; /* 0 */
u8 _r2;
u8 num_de;
struct asd_ocm_dir_ent entry[15];
} __attribute__ ((packed));
#define OCM_DE_OCM_DIR 0x00
#define OCM_DE_WIN_DRVR 0x01
#define OCM_DE_BIOS_CHIM 0x02
#define OCM_DE_RAID_ENGN 0x03
#define OCM_DE_BIOS_INTL 0x04
#define OCM_DE_BIOS_CHIM_OSM 0x05
#define OCM_DE_BIOS_CHIM_DYNAMIC 0x06
#define OCM_DE_ADDC2C_RES0 0x07
#define OCM_DE_ADDC2C_RES1 0x08
#define OCM_DE_ADDC2C_RES2 0x09
#define OCM_DE_ADDC2C_RES3 0x0A
#define OCM_INIT_DIR_ENTRIES 5
/***************************************************************************
* OCM directory default
***************************************************************************/
static struct asd_ocm_dir OCMDirInit =
{
.sig = {0x4D, 0x4F}, /* signature */
.num_de = OCM_INIT_DIR_ENTRIES, /* no. of directory entries */
};
/***************************************************************************
* OCM directory Entries default
***************************************************************************/
static struct asd_ocm_dir_ent OCMDirEntriesInit[OCM_INIT_DIR_ENTRIES] =
{
{
.type = (OCM_DE_ADDC2C_RES0), /* Entry type */
.offs = {128}, /* Offset */
.size = {0, 4}, /* size */
},
{
.type = (OCM_DE_ADDC2C_RES1), /* Entry type */
.offs = {128, 4}, /* Offset */
.size = {0, 4}, /* size */
},
{
.type = (OCM_DE_ADDC2C_RES2), /* Entry type */
.offs = {128, 8}, /* Offset */
.size = {0, 4}, /* size */
},
{
.type = (OCM_DE_ADDC2C_RES3), /* Entry type */
.offs = {128, 12}, /* Offset */
.size = {0, 4}, /* size */
},
{
.type = (OCM_DE_WIN_DRVR), /* Entry type */
.offs = {128, 16}, /* Offset */
.size = {128, 235, 1}, /* size */
},
};
struct asd_bios_chim_struct {
char sig[4];
u8 major; /* 1 */
u8 minor; /* 0 */
u8 bios_major;
u8 bios_minor;
__le32 bios_build;
u8 flags;
u8 pci_slot;
__le16 ue_num;
__le16 ue_size;
u8 _r[14];
/* The unit element array is right here.
*/
} __attribute__ ((packed));
/**
* asd_read_ocm_seg - read an on chip memory (OCM) segment
* @asd_ha: pointer to the host adapter structure
* @buffer: where to write the read data
* @offs: offset into OCM where to read from
* @size: how many bytes to read
*
* Return the number of bytes not read. Return 0 on success.
*/
static int asd_read_ocm_seg(struct asd_ha_struct *asd_ha, void *buffer,
u32 offs, int size)
{
u8 *p = buffer;
if (unlikely(asd_ha->iospace))
asd_read_reg_string(asd_ha, buffer, offs+OCM_BASE_ADDR, size);
else {
for ( ; size > 0; size--, offs++, p++)
*p = asd_read_ocm_byte(asd_ha, offs);
}
return size;
}
static int asd_read_ocm_dir(struct asd_ha_struct *asd_ha,
struct asd_ocm_dir *dir, u32 offs)
{
int err = asd_read_ocm_seg(asd_ha, dir, offs, sizeof(*dir));
if (err) {
ASD_DPRINTK("couldn't read ocm segment\n");
return err;
}
if (dir->sig[0] != 'M' || dir->sig[1] != 'O') {
ASD_DPRINTK("no valid dir signature(%c%c) at start of OCM\n",
dir->sig[0], dir->sig[1]);
return -ENOENT;
}
if (dir->major != 0) {
asd_printk("unsupported major version of ocm dir:0x%x\n",
dir->major);
return -ENOENT;
}
dir->num_de &= 0xf;
return 0;
}
/**
* asd_write_ocm_seg - write an on chip memory (OCM) segment
* @asd_ha: pointer to the host adapter structure
* @buffer: where to read the write data
* @offs: offset into OCM to write to
* @size: how many bytes to write
*
* Return the number of bytes not written. Return 0 on success.
*/
static void asd_write_ocm_seg(struct asd_ha_struct *asd_ha, void *buffer,
u32 offs, int size)
{
u8 *p = buffer;
if (unlikely(asd_ha->iospace))
asd_write_reg_string(asd_ha, buffer, offs+OCM_BASE_ADDR, size);
else {
for ( ; size > 0; size--, offs++, p++)
asd_write_ocm_byte(asd_ha, offs, *p);
}
return;
}
#define THREE_TO_NUM(X) ((X)[0] | ((X)[1] << 8) | ((X)[2] << 16))
static int asd_find_dir_entry(struct asd_ocm_dir *dir, u8 type,
u32 *offs, u32 *size)
{
int i;
struct asd_ocm_dir_ent *ent;
for (i = 0; i < dir->num_de; i++) {
if (dir->entry[i].type == type)
break;
}
if (i >= dir->num_de)
return -ENOENT;
ent = &dir->entry[i];
*offs = (u32) THREE_TO_NUM(ent->offs);
*size = (u32) THREE_TO_NUM(ent->size);
return 0;
}
#define OCM_BIOS_CHIM_DE 2
#define BC_BIOS_PRESENT 1
static int asd_get_bios_chim(struct asd_ha_struct *asd_ha,
struct asd_ocm_dir *dir)
{
int err;
struct asd_bios_chim_struct *bc_struct;
u32 offs, size;
err = asd_find_dir_entry(dir, OCM_BIOS_CHIM_DE, &offs, &size);
if (err) {
ASD_DPRINTK("couldn't find BIOS_CHIM dir ent\n");
goto out;
}
err = -ENOMEM;
bc_struct = kmalloc(sizeof(*bc_struct), GFP_KERNEL);
if (!bc_struct) {
asd_printk("no memory for bios_chim struct\n");
goto out;
}
err = asd_read_ocm_seg(asd_ha, (void *)bc_struct, offs,
sizeof(*bc_struct));
if (err) {
ASD_DPRINTK("couldn't read ocm segment\n");
goto out2;
}
if (strncmp(bc_struct->sig, "SOIB", 4)
&& strncmp(bc_struct->sig, "IPSA", 4)) {
ASD_DPRINTK("BIOS_CHIM entry has no valid sig(%c%c%c%c)\n",
bc_struct->sig[0], bc_struct->sig[1],
bc_struct->sig[2], bc_struct->sig[3]);
err = -ENOENT;
goto out2;
}
if (bc_struct->major != 1) {
asd_printk("BIOS_CHIM unsupported major version:0x%x\n",
bc_struct->major);
err = -ENOENT;
goto out2;
}
if (bc_struct->flags & BC_BIOS_PRESENT) {
asd_ha->hw_prof.bios.present = 1;
asd_ha->hw_prof.bios.maj = bc_struct->bios_major;
asd_ha->hw_prof.bios.min = bc_struct->bios_minor;
asd_ha->hw_prof.bios.bld = le32_to_cpu(bc_struct->bios_build);
ASD_DPRINTK("BIOS present (%d,%d), %d\n",
asd_ha->hw_prof.bios.maj,
asd_ha->hw_prof.bios.min,
asd_ha->hw_prof.bios.bld);
}
asd_ha->hw_prof.ue.num = le16_to_cpu(bc_struct->ue_num);
asd_ha->hw_prof.ue.size= le16_to_cpu(bc_struct->ue_size);
ASD_DPRINTK("ue num:%d, ue size:%d\n", asd_ha->hw_prof.ue.num,
asd_ha->hw_prof.ue.size);
size = asd_ha->hw_prof.ue.num * asd_ha->hw_prof.ue.size;
if (size > 0) {
err = -ENOMEM;
asd_ha->hw_prof.ue.area = kmalloc(size, GFP_KERNEL);
if (!asd_ha->hw_prof.ue.area)
goto out2;
err = asd_read_ocm_seg(asd_ha, (void *)asd_ha->hw_prof.ue.area,
offs + sizeof(*bc_struct), size);
if (err) {
kfree(asd_ha->hw_prof.ue.area);
asd_ha->hw_prof.ue.area = NULL;
asd_ha->hw_prof.ue.num = 0;
asd_ha->hw_prof.ue.size = 0;
ASD_DPRINTK("couldn't read ue entries(%d)\n", err);
}
}
out2:
kfree(bc_struct);
out:
return err;
}
static void
asd_hwi_initialize_ocm_dir (struct asd_ha_struct *asd_ha)
{
int i;
/* Zero OCM */
for (i = 0; i < OCM_MAX_SIZE; i += 4)
asd_write_ocm_dword(asd_ha, i, 0);
/* Write Dir */
asd_write_ocm_seg(asd_ha, &OCMDirInit, 0,
sizeof(struct asd_ocm_dir));
/* Write Dir Entries */
for (i = 0; i < OCM_INIT_DIR_ENTRIES; i++)
asd_write_ocm_seg(asd_ha, &OCMDirEntriesInit[i],
sizeof(struct asd_ocm_dir) +
(i * sizeof(struct asd_ocm_dir_ent))
, sizeof(struct asd_ocm_dir_ent));
}
static int
asd_hwi_check_ocm_access (struct asd_ha_struct *asd_ha)
{
struct pci_dev *pcidev = asd_ha->pcidev;
u32 reg;
int err = 0;
u32 v;
/* check if OCM has been initialized by BIOS */
reg = asd_read_reg_dword(asd_ha, EXSICNFGR);
if (!(reg & OCMINITIALIZED)) {
err = pci_read_config_dword(pcidev, PCIC_INTRPT_STAT, &v);
if (err) {
asd_printk("couldn't access PCIC_INTRPT_STAT of %s\n",
pci_name(pcidev));
goto out;
}
printk(KERN_INFO "OCM is not initialized by BIOS,"
"reinitialize it and ignore it, current IntrptStatus"
"is 0x%x\n", v);
if (v)
err = pci_write_config_dword(pcidev,
PCIC_INTRPT_STAT, v);
if (err) {
asd_printk("couldn't write PCIC_INTRPT_STAT of %s\n",
pci_name(pcidev));
goto out;
}
asd_hwi_initialize_ocm_dir(asd_ha);
}
out:
return err;
}
/**
* asd_read_ocm - read on chip memory (OCM)
* @asd_ha: pointer to the host adapter structure
*/
int asd_read_ocm(struct asd_ha_struct *asd_ha)
{
int err;
struct asd_ocm_dir *dir;
if (asd_hwi_check_ocm_access(asd_ha))
return -1;
dir = kmalloc(sizeof(*dir), GFP_KERNEL);
if (!dir) {
asd_printk("no memory for ocm dir\n");
return -ENOMEM;
}
err = asd_read_ocm_dir(asd_ha, dir, 0);
if (err)
goto out;
err = asd_get_bios_chim(asd_ha, dir);
out:
kfree(dir);
return err;
}
/* ---------- FLASH stuff ---------- */
#define FLASH_RESET 0xF0
#define ASD_FLASH_SIZE 0x200000
#define FLASH_DIR_COOKIE "*** ADAPTEC FLASH DIRECTORY *** "
#define FLASH_NEXT_ENTRY_OFFS 0x2000
#define FLASH_MAX_DIR_ENTRIES 32
#define FLASH_DE_TYPE_MASK 0x3FFFFFFF
#define FLASH_DE_MS 0x120
#define FLASH_DE_CTRL_A_USER 0xE0
struct asd_flash_de {
__le32 type;
__le32 offs;
__le32 pad_size;
__le32 image_size;
__le32 chksum;
u8 _r[12];
u8 version[32];
} __attribute__ ((packed));
struct asd_flash_dir {
u8 cookie[32];
__le32 rev; /* 2 */
__le32 chksum;
__le32 chksum_antidote;
__le32 bld;
u8 bld_id[32]; /* build id data */
u8 ver_data[32]; /* date and time of build */
__le32 ae_mask;
__le32 v_mask;
__le32 oc_mask;
u8 _r[20];
struct asd_flash_de dir_entry[FLASH_MAX_DIR_ENTRIES];
} __attribute__ ((packed));
struct asd_manuf_sec {
char sig[2]; /* 'S', 'M' */
u16 offs_next;
u8 maj; /* 0 */
u8 min; /* 0 */
u16 chksum;
u16 size;
u8 _r[6];
u8 sas_addr[SAS_ADDR_SIZE];
u8 pcba_sn[ASD_PCBA_SN_SIZE];
/* Here start the other segments */
u8 linked_list[0];
} __attribute__ ((packed));
struct asd_manuf_phy_desc {
u8 state; /* low 4 bits */
#define MS_PHY_STATE_ENABLED 0
#define MS_PHY_STATE_REPORTED 1
#define MS_PHY_STATE_HIDDEN 2
u8 phy_id;
u16 _r;
u8 phy_control_0; /* mode 5 reg 0x160 */
u8 phy_control_1; /* mode 5 reg 0x161 */
u8 phy_control_2; /* mode 5 reg 0x162 */
u8 phy_control_3; /* mode 5 reg 0x163 */
} __attribute__ ((packed));
struct asd_manuf_phy_param {
char sig[2]; /* 'P', 'M' */
u16 next;
u8 maj; /* 0 */
u8 min; /* 2 */
u8 num_phy_desc; /* 8 */
u8 phy_desc_size; /* 8 */
u8 _r[3];
u8 usage_model_id;
u32 _r2;
struct asd_manuf_phy_desc phy_desc[ASD_MAX_PHYS];
} __attribute__ ((packed));
#if 0
static const char *asd_sb_type[] = {
"unknown",
"SGPIO",
[2 ... 0x7F] = "unknown",
[0x80] = "ADPT_I2C",
[0x81 ... 0xFF] = "VENDOR_UNIQUExx"
};
#endif
struct asd_ms_sb_desc {
u8 type;
u8 node_desc_index;
u8 conn_desc_index;
u8 _recvd[0];
} __attribute__ ((packed));
#if 0
static const char *asd_conn_type[] = {
[0 ... 7] = "unknown",
"SFF8470",
"SFF8482",
"SFF8484",
[0x80] = "PCIX_DAUGHTER0",
[0x81] = "SAS_DAUGHTER0",
[0x82 ... 0xFF] = "VENDOR_UNIQUExx"
};
static const char *asd_conn_location[] = {
"unknown",
"internal",
"external",
"board_to_board",
};
#endif
struct asd_ms_conn_desc {
u8 type;
u8 location;
u8 num_sideband_desc;
u8 size_sideband_desc;
u32 _resvd;
u8 name[16];
struct asd_ms_sb_desc sb_desc[0];
} __attribute__ ((packed));
struct asd_nd_phy_desc {
u8 vp_attch_type;
u8 attch_specific[0];
} __attribute__ ((packed));
#if 0
static const char *asd_node_type[] = {
"IOP",
"IO_CONTROLLER",
"EXPANDER",
"PORT_MULTIPLIER",
"PORT_MULTIPLEXER",
"MULTI_DROP_I2C_BUS",
};
#endif
struct asd_ms_node_desc {
u8 type;
u8 num_phy_desc;
u8 size_phy_desc;
u8 _resvd;
u8 name[16];
struct asd_nd_phy_desc phy_desc[0];
} __attribute__ ((packed));
struct asd_ms_conn_map {
char sig[2]; /* 'M', 'C' */
__le16 next;
u8 maj; /* 0 */
u8 min; /* 0 */
__le16 cm_size; /* size of this struct */
u8 num_conn;
u8 conn_size;
u8 num_nodes;
u8 usage_model_id;
u32 _resvd;
struct asd_ms_conn_desc conn_desc[0];
struct asd_ms_node_desc node_desc[0];
} __attribute__ ((packed));
struct asd_ctrla_phy_entry {
u8 sas_addr[SAS_ADDR_SIZE];
u8 sas_link_rates; /* max in hi bits, min in low bits */
u8 flags;
u8 sata_link_rates;
u8 _r[5];
} __attribute__ ((packed));
struct asd_ctrla_phy_settings {
u8 id0; /* P'h'y */
u8 _r;
u16 next;
u8 num_phys; /* number of PHYs in the PCI function */
u8 _r2[3];
struct asd_ctrla_phy_entry phy_ent[ASD_MAX_PHYS];
} __attribute__ ((packed));
struct asd_ll_el {
u8 id0;
u8 id1;
__le16 next;
u8 something_here[0];
} __attribute__ ((packed));
static int asd_poll_flash(struct asd_ha_struct *asd_ha)
{
int c;
u8 d;
for (c = 5000; c > 0; c--) {
d = asd_read_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar);
d ^= asd_read_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar);
if (!d)
return 0;
udelay(5);
}
return -ENOENT;
}
static int asd_reset_flash(struct asd_ha_struct *asd_ha)
{
int err;
err = asd_poll_flash(asd_ha);
if (err)
return err;
asd_write_reg_byte(asd_ha, asd_ha->hw_prof.flash.bar, FLASH_RESET);
err = asd_poll_flash(asd_ha);
return err;
}
static int asd_read_flash_seg(struct asd_ha_struct *asd_ha,
void *buffer, u32 offs, int size)
{
asd_read_reg_string(asd_ha, buffer, asd_ha->hw_prof.flash.bar+offs,
size);
return 0;
}
/**
* asd_find_flash_dir - finds and reads the flash directory
* @asd_ha: pointer to the host adapter structure
* @flash_dir: pointer to flash directory structure
*
* If found, the flash directory segment will be copied to
* @flash_dir. Return 1 if found, 0 if not.
*/
static int asd_find_flash_dir(struct asd_ha_struct *asd_ha,
struct asd_flash_dir *flash_dir)
{
u32 v;
for (v = 0; v < ASD_FLASH_SIZE; v += FLASH_NEXT_ENTRY_OFFS) {
asd_read_flash_seg(asd_ha, flash_dir, v,
sizeof(FLASH_DIR_COOKIE)-1);
if (memcmp(flash_dir->cookie, FLASH_DIR_COOKIE,
sizeof(FLASH_DIR_COOKIE)-1) == 0) {
asd_ha->hw_prof.flash.dir_offs = v;
asd_read_flash_seg(asd_ha, flash_dir, v,
sizeof(*flash_dir));
return 1;
}
}
return 0;
}
static int asd_flash_getid(struct asd_ha_struct *asd_ha)
{
int err = 0;
u32 reg;
reg = asd_read_reg_dword(asd_ha, EXSICNFGR);
if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR,
&asd_ha->hw_prof.flash.bar)) {
asd_printk("couldn't read PCI_CONF_FLSH_BAR of %s\n",
pci_name(asd_ha->pcidev));
return -ENOENT;
}
asd_ha->hw_prof.flash.present = 1;
asd_ha->hw_prof.flash.wide = reg & FLASHW ? 1 : 0;
err = asd_reset_flash(asd_ha);
if (err) {
ASD_DPRINTK("couldn't reset flash(%d)\n", err);
return err;
}
return 0;
}
static u16 asd_calc_flash_chksum(u16 *p, int size)
{
u16 chksum = 0;
while (size-- > 0)
chksum += *p++;
return chksum;
}
static int asd_find_flash_de(struct asd_flash_dir *flash_dir, u32 entry_type,
u32 *offs, u32 *size)
{
int i;
struct asd_flash_de *de;
for (i = 0; i < FLASH_MAX_DIR_ENTRIES; i++) {
u32 type = le32_to_cpu(flash_dir->dir_entry[i].type);
type &= FLASH_DE_TYPE_MASK;
if (type == entry_type)
break;
}
if (i >= FLASH_MAX_DIR_ENTRIES)
return -ENOENT;
de = &flash_dir->dir_entry[i];
*offs = le32_to_cpu(de->offs);
*size = le32_to_cpu(de->pad_size);
return 0;
}
static int asd_validate_ms(struct asd_manuf_sec *ms)
{
if (ms->sig[0] != 'S' || ms->sig[1] != 'M') {
ASD_DPRINTK("manuf sec: no valid sig(%c%c)\n",
ms->sig[0], ms->sig[1]);
return -ENOENT;
}
if (ms->maj != 0) {
asd_printk("unsupported manuf. sector. major version:%x\n",
ms->maj);
return -ENOENT;
}
ms->offs_next = le16_to_cpu((__force __le16) ms->offs_next);
ms->chksum = le16_to_cpu((__force __le16) ms->chksum);
ms->size = le16_to_cpu((__force __le16) ms->size);
if (asd_calc_flash_chksum((u16 *)ms, ms->size/2)) {
asd_printk("failed manuf sector checksum\n");
}
return 0;
}
static int asd_ms_get_sas_addr(struct asd_ha_struct *asd_ha,
struct asd_manuf_sec *ms)
{
memcpy(asd_ha->hw_prof.sas_addr, ms->sas_addr, SAS_ADDR_SIZE);
return 0;
}
static int asd_ms_get_pcba_sn(struct asd_ha_struct *asd_ha,
struct asd_manuf_sec *ms)
{
memcpy(asd_ha->hw_prof.pcba_sn, ms->pcba_sn, ASD_PCBA_SN_SIZE);
asd_ha->hw_prof.pcba_sn[ASD_PCBA_SN_SIZE] = '\0';
return 0;
}
/**
* asd_find_ll_by_id - find a linked list entry by its id
* @start: void pointer to the first element in the linked list
* @id0: the first byte of the id (offs 0)
* @id1: the second byte of the id (offs 1)
*
* @start has to be the _base_ element start, since the
* linked list entries's offset is from this pointer.
* Some linked list entries use only the first id, in which case
* you can pass 0xFF for the second.
*/
static void *asd_find_ll_by_id(void * const start, const u8 id0, const u8 id1)
{
struct asd_ll_el *el = start;
do {
switch (id1) {
default:
if (el->id1 == id1)
case 0xFF:
if (el->id0 == id0)
return el;
}
el = start + le16_to_cpu(el->next);
} while (el != start);
return NULL;
}
/**
* asd_ms_get_phy_params - get phy parameters from the manufacturing sector
* @asd_ha: pointer to the host adapter structure
* @manuf_sec: pointer to the manufacturing sector
*
* The manufacturing sector contans also the linked list of sub-segments,
* since when it was read, its size was taken from the flash directory,
* not from the structure size.
*
* HIDDEN phys do not count in the total count. REPORTED phys cannot
* be enabled but are reported and counted towards the total.
* ENABLED phys are enabled by default and count towards the total.
* The absolute total phy number is ASD_MAX_PHYS. hw_prof->num_phys
* merely specifies the number of phys the host adapter decided to
* report. E.g., it is possible for phys 0, 1 and 2 to be HIDDEN,
* phys 3, 4 and 5 to be REPORTED and phys 6 and 7 to be ENABLED.
* In this case ASD_MAX_PHYS is 8, hw_prof->num_phys is 5, and only 2
* are actually enabled (enabled by default, max number of phys
* enableable in this case).
*/
static int asd_ms_get_phy_params(struct asd_ha_struct *asd_ha,
struct asd_manuf_sec *manuf_sec)
{
int i;
int en_phys = 0;
int rep_phys = 0;
struct asd_manuf_phy_param *phy_param;
struct asd_manuf_phy_param dflt_phy_param;
phy_param = asd_find_ll_by_id(manuf_sec, 'P', 'M');
if (!phy_param) {
ASD_DPRINTK("ms: no phy parameters found\n");
ASD_DPRINTK("ms: Creating default phy parameters\n");
dflt_phy_param.sig[0] = 'P';
dflt_phy_param.sig[1] = 'M';
dflt_phy_param.maj = 0;
dflt_phy_param.min = 2;
dflt_phy_param.num_phy_desc = 8;
dflt_phy_param.phy_desc_size = sizeof(struct asd_manuf_phy_desc);
for (i =0; i < ASD_MAX_PHYS; i++) {
dflt_phy_param.phy_desc[i].state = 0;
dflt_phy_param.phy_desc[i].phy_id = i;
dflt_phy_param.phy_desc[i].phy_control_0 = 0xf6;
dflt_phy_param.phy_desc[i].phy_control_1 = 0x10;
dflt_phy_param.phy_desc[i].phy_control_2 = 0x43;
dflt_phy_param.phy_desc[i].phy_control_3 = 0xeb;
}
phy_param = &dflt_phy_param;
}
if (phy_param->maj != 0) {
asd_printk("unsupported manuf. phy param major version:0x%x\n",
phy_param->maj);
return -ENOENT;
}
ASD_DPRINTK("ms: num_phy_desc: %d\n", phy_param->num_phy_desc);
asd_ha->hw_prof.enabled_phys = 0;
for (i = 0; i < phy_param->num_phy_desc; i++) {
struct asd_manuf_phy_desc *pd = &phy_param->phy_desc[i];
switch (pd->state & 0xF) {
case MS_PHY_STATE_HIDDEN:
ASD_DPRINTK("ms: phy%d: HIDDEN\n", i);
continue;
case MS_PHY_STATE_REPORTED:
ASD_DPRINTK("ms: phy%d: REPORTED\n", i);
asd_ha->hw_prof.enabled_phys &= ~(1 << i);
rep_phys++;
continue;
case MS_PHY_STATE_ENABLED:
ASD_DPRINTK("ms: phy%d: ENABLED\n", i);
asd_ha->hw_prof.enabled_phys |= (1 << i);
en_phys++;
break;
}
asd_ha->hw_prof.phy_desc[i].phy_control_0 = pd->phy_control_0;
asd_ha->hw_prof.phy_desc[i].phy_control_1 = pd->phy_control_1;
asd_ha->hw_prof.phy_desc[i].phy_control_2 = pd->phy_control_2;
asd_ha->hw_prof.phy_desc[i].phy_control_3 = pd->phy_control_3;
}
asd_ha->hw_prof.max_phys = rep_phys + en_phys;
asd_ha->hw_prof.num_phys = en_phys;
ASD_DPRINTK("ms: max_phys:0x%x, num_phys:0x%x\n",
asd_ha->hw_prof.max_phys, asd_ha->hw_prof.num_phys);
ASD_DPRINTK("ms: enabled_phys:0x%x\n", asd_ha->hw_prof.enabled_phys);
return 0;
}
static int asd_ms_get_connector_map(struct asd_ha_struct *asd_ha,
struct asd_manuf_sec *manuf_sec)
{
struct asd_ms_conn_map *cm;
cm = asd_find_ll_by_id(manuf_sec, 'M', 'C');
if (!cm) {
ASD_DPRINTK("ms: no connector map found\n");
return 0;
}
if (cm->maj != 0) {
ASD_DPRINTK("ms: unsupported: connector map major version 0x%x"
"\n", cm->maj);
return -ENOENT;
}
/* XXX */
return 0;
}
/**
* asd_process_ms - find and extract information from the manufacturing sector
* @asd_ha: pointer to the host adapter structure
* @flash_dir: pointer to the flash directory
*/
static int asd_process_ms(struct asd_ha_struct *asd_ha,
struct asd_flash_dir *flash_dir)
{
int err;
struct asd_manuf_sec *manuf_sec;
u32 offs, size;
err = asd_find_flash_de(flash_dir, FLASH_DE_MS, &offs, &size);
if (err) {
ASD_DPRINTK("Couldn't find the manuf. sector\n");
goto out;
}
if (size == 0)
goto out;
err = -ENOMEM;
manuf_sec = kmalloc(size, GFP_KERNEL);
if (!manuf_sec) {
ASD_DPRINTK("no mem for manuf sector\n");
goto out;
}
err = asd_read_flash_seg(asd_ha, (void *)manuf_sec, offs, size);
if (err) {
ASD_DPRINTK("couldn't read manuf sector at 0x%x, size 0x%x\n",
offs, size);
goto out2;
}
err = asd_validate_ms(manuf_sec);
if (err) {
ASD_DPRINTK("couldn't validate manuf sector\n");
goto out2;
}
err = asd_ms_get_sas_addr(asd_ha, manuf_sec);
if (err) {
ASD_DPRINTK("couldn't read the SAS_ADDR\n");
goto out2;
}
ASD_DPRINTK("manuf sect SAS_ADDR %llx\n",
SAS_ADDR(asd_ha->hw_prof.sas_addr));
err = asd_ms_get_pcba_sn(asd_ha, manuf_sec);
if (err) {
ASD_DPRINTK("couldn't read the PCBA SN\n");
goto out2;
}
ASD_DPRINTK("manuf sect PCBA SN %s\n", asd_ha->hw_prof.pcba_sn);
err = asd_ms_get_phy_params(asd_ha, manuf_sec);
if (err) {
ASD_DPRINTK("ms: couldn't get phy parameters\n");
goto out2;
}
err = asd_ms_get_connector_map(asd_ha, manuf_sec);
if (err) {
ASD_DPRINTK("ms: couldn't get connector map\n");
goto out2;
}
out2:
kfree(manuf_sec);
out:
return err;
}
static int asd_process_ctrla_phy_settings(struct asd_ha_struct *asd_ha,
struct asd_ctrla_phy_settings *ps)
{
int i;
for (i = 0; i < ps->num_phys; i++) {
struct asd_ctrla_phy_entry *pe = &ps->phy_ent[i];
if (!PHY_ENABLED(asd_ha, i))
continue;
if (*(u64 *)pe->sas_addr == 0) {
asd_ha->hw_prof.enabled_phys &= ~(1 << i);
continue;
}
/* This is the SAS address which should be sent in IDENTIFY. */
memcpy(asd_ha->hw_prof.phy_desc[i].sas_addr, pe->sas_addr,
SAS_ADDR_SIZE);
asd_ha->hw_prof.phy_desc[i].max_sas_lrate =
(pe->sas_link_rates & 0xF0) >> 4;
asd_ha->hw_prof.phy_desc[i].min_sas_lrate =
(pe->sas_link_rates & 0x0F);
asd_ha->hw_prof.phy_desc[i].max_sata_lrate =
(pe->sata_link_rates & 0xF0) >> 4;
asd_ha->hw_prof.phy_desc[i].min_sata_lrate =
(pe->sata_link_rates & 0x0F);
asd_ha->hw_prof.phy_desc[i].flags = pe->flags;
ASD_DPRINTK("ctrla: phy%d: sas_addr: %llx, sas rate:0x%x-0x%x,"
" sata rate:0x%x-0x%x, flags:0x%x\n",
i,
SAS_ADDR(asd_ha->hw_prof.phy_desc[i].sas_addr),
asd_ha->hw_prof.phy_desc[i].max_sas_lrate,
asd_ha->hw_prof.phy_desc[i].min_sas_lrate,
asd_ha->hw_prof.phy_desc[i].max_sata_lrate,
asd_ha->hw_prof.phy_desc[i].min_sata_lrate,
asd_ha->hw_prof.phy_desc[i].flags);
}
return 0;
}
/**
* asd_process_ctrl_a_user - process CTRL-A user settings
* @asd_ha: pointer to the host adapter structure
* @flash_dir: pointer to the flash directory
*/
static int asd_process_ctrl_a_user(struct asd_ha_struct *asd_ha,
struct asd_flash_dir *flash_dir)
{
int err, i;
u32 offs, size;
struct asd_ll_el *el = NULL;
struct asd_ctrla_phy_settings *ps;
struct asd_ctrla_phy_settings dflt_ps;
err = asd_find_flash_de(flash_dir, FLASH_DE_CTRL_A_USER, &offs, &size);
if (err) {
ASD_DPRINTK("couldn't find CTRL-A user settings section\n");
ASD_DPRINTK("Creating default CTRL-A user settings section\n");
dflt_ps.id0 = 'h';
dflt_ps.num_phys = 8;
for (i =0; i < ASD_MAX_PHYS; i++) {
memcpy(dflt_ps.phy_ent[i].sas_addr,
asd_ha->hw_prof.sas_addr, SAS_ADDR_SIZE);
dflt_ps.phy_ent[i].sas_link_rates = 0x98;
dflt_ps.phy_ent[i].flags = 0x0;
dflt_ps.phy_ent[i].sata_link_rates = 0x0;
}
size = sizeof(struct asd_ctrla_phy_settings);
ps = &dflt_ps;
goto out_process;
}
if (size == 0)
goto out;
err = -ENOMEM;
el = kmalloc(size, GFP_KERNEL);
if (!el) {
ASD_DPRINTK("no mem for ctrla user settings section\n");
goto out;
}
err = asd_read_flash_seg(asd_ha, (void *)el, offs, size);
if (err) {
ASD_DPRINTK("couldn't read ctrla phy settings section\n");
goto out2;
}
err = -ENOENT;
ps = asd_find_ll_by_id(el, 'h', 0xFF);
if (!ps) {
ASD_DPRINTK("couldn't find ctrla phy settings struct\n");
goto out2;
}
out_process:
err = asd_process_ctrla_phy_settings(asd_ha, ps);
if (err) {
ASD_DPRINTK("couldn't process ctrla phy settings\n");
goto out2;
}
out2:
kfree(el);
out:
return err;
}
/**
* asd_read_flash - read flash memory
* @asd_ha: pointer to the host adapter structure
*/
int asd_read_flash(struct asd_ha_struct *asd_ha)
{
int err;
struct asd_flash_dir *flash_dir;
err = asd_flash_getid(asd_ha);
if (err)
return err;
flash_dir = kmalloc(sizeof(*flash_dir), GFP_KERNEL);
if (!flash_dir)
return -ENOMEM;
err = -ENOENT;
if (!asd_find_flash_dir(asd_ha, flash_dir)) {
ASD_DPRINTK("couldn't find flash directory\n");
goto out;
}
if (le32_to_cpu(flash_dir->rev) != 2) {
asd_printk("unsupported flash dir version:0x%x\n",
le32_to_cpu(flash_dir->rev));
goto out;
}
err = asd_process_ms(asd_ha, flash_dir);
if (err) {
ASD_DPRINTK("couldn't process manuf sector settings\n");
goto out;
}
err = asd_process_ctrl_a_user(asd_ha, flash_dir);
if (err) {
ASD_DPRINTK("couldn't process CTRL-A user settings\n");
goto out;
}
out:
kfree(flash_dir);
return err;
}
/**
* asd_verify_flash_seg - verify data with flash memory
* @asd_ha: pointer to the host adapter structure
* @src: pointer to the source data to be verified
* @dest_offset: offset from flash memory
* @bytes_to_verify: total bytes to verify
*/
int asd_verify_flash_seg(struct asd_ha_struct *asd_ha,
const void *src, u32 dest_offset, u32 bytes_to_verify)
{
const u8 *src_buf;
u8 flash_char;
int err;
u32 nv_offset, reg, i;
reg = asd_ha->hw_prof.flash.bar;
src_buf = NULL;
err = FLASH_OK;
nv_offset = dest_offset;
src_buf = (const u8 *)src;
for (i = 0; i < bytes_to_verify; i++) {
flash_char = asd_read_reg_byte(asd_ha, reg + nv_offset + i);
if (flash_char != src_buf[i]) {
err = FAIL_VERIFY;
break;
}
}
return err;
}
/**
* asd_write_flash_seg - write data into flash memory
* @asd_ha: pointer to the host adapter structure
* @src: pointer to the source data to be written
* @dest_offset: offset from flash memory
* @bytes_to_write: total bytes to write
*/
int asd_write_flash_seg(struct asd_ha_struct *asd_ha,
const void *src, u32 dest_offset, u32 bytes_to_write)
{
const u8 *src_buf;
u32 nv_offset, reg, i;
int err;
reg = asd_ha->hw_prof.flash.bar;
src_buf = NULL;
err = asd_check_flash_type(asd_ha);
if (err) {
ASD_DPRINTK("couldn't find the type of flash. err=%d\n", err);
return err;
}
nv_offset = dest_offset;
err = asd_erase_nv_sector(asd_ha, nv_offset, bytes_to_write);
if (err) {
ASD_DPRINTK("Erase failed at offset:0x%x\n",
nv_offset);
return err;
}
err = asd_reset_flash(asd_ha);
if (err) {
ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
return err;
}
src_buf = (const u8 *)src;
for (i = 0; i < bytes_to_write; i++) {
/* Setup program command sequence */
switch (asd_ha->hw_prof.flash.method) {
case FLASH_METHOD_A:
{
asd_write_reg_byte(asd_ha,
(reg + 0xAAA), 0xAA);
asd_write_reg_byte(asd_ha,
(reg + 0x555), 0x55);
asd_write_reg_byte(asd_ha,
(reg + 0xAAA), 0xA0);
asd_write_reg_byte(asd_ha,
(reg + nv_offset + i),
(*(src_buf + i)));
break;
}
case FLASH_METHOD_B:
{
asd_write_reg_byte(asd_ha,
(reg + 0x555), 0xAA);
asd_write_reg_byte(asd_ha,
(reg + 0x2AA), 0x55);
asd_write_reg_byte(asd_ha,
(reg + 0x555), 0xA0);
asd_write_reg_byte(asd_ha,
(reg + nv_offset + i),
(*(src_buf + i)));
break;
}
default:
break;
}
if (asd_chk_write_status(asd_ha,
(nv_offset + i), 0) != 0) {
ASD_DPRINTK("aicx: Write failed at offset:0x%x\n",
reg + nv_offset + i);
return FAIL_WRITE_FLASH;
}
}
err = asd_reset_flash(asd_ha);
if (err) {
ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
return err;
}
return 0;
}
int asd_chk_write_status(struct asd_ha_struct *asd_ha,
u32 sector_addr, u8 erase_flag)
{
u32 reg;
u32 loop_cnt;
u8 nv_data1, nv_data2;
u8 toggle_bit1;
/*
* Read from DQ2 requires sector address
* while it's dont care for DQ6
*/
reg = asd_ha->hw_prof.flash.bar;
for (loop_cnt = 0; loop_cnt < 50000; loop_cnt++) {
nv_data1 = asd_read_reg_byte(asd_ha, reg);
nv_data2 = asd_read_reg_byte(asd_ha, reg);
toggle_bit1 = ((nv_data1 & FLASH_STATUS_BIT_MASK_DQ6)
^ (nv_data2 & FLASH_STATUS_BIT_MASK_DQ6));
if (toggle_bit1 == 0) {
return 0;
} else {
if (nv_data2 & FLASH_STATUS_BIT_MASK_DQ5) {
nv_data1 = asd_read_reg_byte(asd_ha,
reg);
nv_data2 = asd_read_reg_byte(asd_ha,
reg);
toggle_bit1 =
((nv_data1 & FLASH_STATUS_BIT_MASK_DQ6)
^ (nv_data2 & FLASH_STATUS_BIT_MASK_DQ6));
if (toggle_bit1 == 0)
return 0;
}
}
/*
* ERASE is a sector-by-sector operation and requires
* more time to finish while WRITE is byte-byte-byte
* operation and takes lesser time to finish.
*
* For some strange reason a reduced ERASE delay gives different
* behaviour across different spirit boards. Hence we set
* a optimum balance of 50mus for ERASE which works well
* across all boards.
*/
if (erase_flag) {
udelay(FLASH_STATUS_ERASE_DELAY_COUNT);
} else {
udelay(FLASH_STATUS_WRITE_DELAY_COUNT);
}
}
return -1;
}
/**
* asd_hwi_erase_nv_sector - Erase the flash memory sectors.
* @asd_ha: pointer to the host adapter structure
* @flash_addr: pointer to offset from flash memory
* @size: total bytes to erase.
*/
int asd_erase_nv_sector(struct asd_ha_struct *asd_ha, u32 flash_addr, u32 size)
{
u32 reg;
u32 sector_addr;
reg = asd_ha->hw_prof.flash.bar;
/* sector staring address */
sector_addr = flash_addr & FLASH_SECTOR_SIZE_MASK;
/*
* Erasing an flash sector needs to be done in six consecutive
* write cyles.
*/
while (sector_addr < flash_addr+size) {
switch (asd_ha->hw_prof.flash.method) {
case FLASH_METHOD_A:
asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA);
asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55);
asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0x80);
asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA);
asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55);
asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30);
break;
case FLASH_METHOD_B:
asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
asd_write_reg_byte(asd_ha, (reg + 0x555), 0x80);
asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30);
break;
default:
break;
}
if (asd_chk_write_status(asd_ha, sector_addr, 1) != 0)
return FAIL_ERASE_FLASH;
sector_addr += FLASH_SECTOR_SIZE;
}
return 0;
}
int asd_check_flash_type(struct asd_ha_struct *asd_ha)
{
u8 manuf_id;
u8 dev_id;
u8 sec_prot;
u32 inc;
u32 reg;
int err;
/* get Flash memory base address */
reg = asd_ha->hw_prof.flash.bar;
/* Determine flash info */
err = asd_reset_flash(asd_ha);
if (err) {
ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
return err;
}
asd_ha->hw_prof.flash.method = FLASH_METHOD_UNKNOWN;
asd_ha->hw_prof.flash.manuf = FLASH_MANUF_ID_UNKNOWN;
asd_ha->hw_prof.flash.dev_id = FLASH_DEV_ID_UNKNOWN;
/* Get flash info. This would most likely be AMD Am29LV family flash.
* First try the sequence for word mode. It is the same as for
* 008B (byte mode only), 160B (word mode) and 800D (word mode).
*/
inc = asd_ha->hw_prof.flash.wide ? 2 : 1;
asd_write_reg_byte(asd_ha, reg + 0xAAA, 0xAA);
asd_write_reg_byte(asd_ha, reg + 0x555, 0x55);
asd_write_reg_byte(asd_ha, reg + 0xAAA, 0x90);
manuf_id = asd_read_reg_byte(asd_ha, reg);
dev_id = asd_read_reg_byte(asd_ha, reg + inc);
sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc);
/* Get out of autoselect mode. */
err = asd_reset_flash(asd_ha);
if (err) {
ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
return err;
}
ASD_DPRINTK("Flash MethodA manuf_id(0x%x) dev_id(0x%x) "
"sec_prot(0x%x)\n", manuf_id, dev_id, sec_prot);
err = asd_reset_flash(asd_ha);
if (err != 0)
return err;
switch (manuf_id) {
case FLASH_MANUF_ID_AMD:
switch (sec_prot) {
case FLASH_DEV_ID_AM29LV800DT:
case FLASH_DEV_ID_AM29LV640MT:
case FLASH_DEV_ID_AM29F800B:
asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
break;
default:
break;
}
break;
case FLASH_MANUF_ID_ST:
switch (sec_prot) {
case FLASH_DEV_ID_STM29W800DT:
case FLASH_DEV_ID_STM29LV640:
asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
break;
default:
break;
}
break;
case FLASH_MANUF_ID_FUJITSU:
switch (sec_prot) {
case FLASH_DEV_ID_MBM29LV800TE:
case FLASH_DEV_ID_MBM29DL800TA:
asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
break;
}
break;
case FLASH_MANUF_ID_MACRONIX:
switch (sec_prot) {
case FLASH_DEV_ID_MX29LV800BT:
asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
break;
}
break;
}
if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN) {
err = asd_reset_flash(asd_ha);
if (err) {
ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
return err;
}
/* Issue Unlock sequence for AM29LV008BT */
asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
asd_write_reg_byte(asd_ha, (reg + 0x555), 0x90);
manuf_id = asd_read_reg_byte(asd_ha, reg);
dev_id = asd_read_reg_byte(asd_ha, reg + inc);
sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc);
ASD_DPRINTK("Flash MethodB manuf_id(0x%x) dev_id(0x%x) sec_prot"
"(0x%x)\n", manuf_id, dev_id, sec_prot);
err = asd_reset_flash(asd_ha);
if (err != 0) {
ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
return err;
}
switch (manuf_id) {
case FLASH_MANUF_ID_AMD:
switch (dev_id) {
case FLASH_DEV_ID_AM29LV008BT:
asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
break;
default:
break;
}
break;
case FLASH_MANUF_ID_ST:
switch (dev_id) {
case FLASH_DEV_ID_STM29008:
asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
break;
default:
break;
}
break;
case FLASH_MANUF_ID_FUJITSU:
switch (dev_id) {
case FLASH_DEV_ID_MBM29LV008TA:
asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
break;
}
break;
case FLASH_MANUF_ID_INTEL:
switch (dev_id) {
case FLASH_DEV_ID_I28LV00TAT:
asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
break;
}
break;
case FLASH_MANUF_ID_MACRONIX:
switch (dev_id) {
case FLASH_DEV_ID_I28LV00TAT:
asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
break;
}
break;
default:
return FAIL_FIND_FLASH_ID;
}
}
if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN)
return FAIL_FIND_FLASH_ID;
asd_ha->hw_prof.flash.manuf = manuf_id;
asd_ha->hw_prof.flash.dev_id = dev_id;
asd_ha->hw_prof.flash.sec_prot = sec_prot;
return 0;
}
| 25.299255 | 79 | 0.669602 |
4e2dfa474a7e6e8deaeb56ec2a9115345141ac58 | 343 | h | C | linux/include/net/ah.h | bradchesney79/illacceptanything | 4594ae4634fdb5e39263a6423dc255ed46c25208 | [
"MIT"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | linux/include/net/ah.h | bradchesney79/illacceptanything | 4594ae4634fdb5e39263a6423dc255ed46c25208 | [
"MIT"
] | 5 | 2020-04-04T09:24:09.000Z | 2020-04-19T12:33:55.000Z | linux/include/net/ah.h | bradchesney79/illacceptanything | 4594ae4634fdb5e39263a6423dc255ed46c25208 | [
"MIT"
] | 30 | 2018-05-02T08:43:27.000Z | 2022-01-23T03:25:54.000Z | #ifndef _NET_AH_H
#define _NET_AH_H
#include <linux/skbuff.h>
struct crypto_ahash;
struct ah_data {
int icv_full_len;
int icv_trunc_len;
struct crypto_ahash *ahash;
};
struct ip_auth_hdr;
static inline struct ip_auth_hdr *ip_auth_hdr(const struct sk_buff *skb)
{
return (struct ip_auth_hdr *)skb_transport_header(skb);
}
#endif
| 14.913043 | 72 | 0.766764 |
8392b1af5eadb9babbe9fd481580042675ad12af | 2,932 | h | C | cmake_targets/basic_simulator/enb/CMakeFiles/RRC_Rel14/RACH-ConfigCommon-v1250.h | kikikos/openairinterface5g | 54d541c22cdfcb774774089291c93e4e79294a1d | [
"Apache-2.0"
] | null | null | null | cmake_targets/basic_simulator/enb/CMakeFiles/RRC_Rel14/RACH-ConfigCommon-v1250.h | kikikos/openairinterface5g | 54d541c22cdfcb774774089291c93e4e79294a1d | [
"Apache-2.0"
] | null | null | null | cmake_targets/basic_simulator/enb/CMakeFiles/RRC_Rel14/RACH-ConfigCommon-v1250.h | kikikos/openairinterface5g | 54d541c22cdfcb774774089291c93e4e79294a1d | [
"Apache-2.0"
] | 1 | 2020-02-10T14:17:39.000Z | 2020-02-10T14:17:39.000Z | /*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "EUTRA-RRC-Definitions"
* found in "/home/user/openairinterface5g/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-14.7.0.asn1"
* `asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example -D /home/user/openairinterface5g/cmake_targets/basic_simulator/enb/CMakeFiles/RRC_Rel14`
*/
#ifndef _RACH_ConfigCommon_v1250_H_
#define _RACH_ConfigCommon_v1250_H_
#include <asn_application.h>
/* Including external dependencies */
#include <NativeEnumerated.h>
#include <NativeInteger.h>
#include <constr_SEQUENCE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailCount_r12 {
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailCount_r12_n1 = 0,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailCount_r12_n2 = 1,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailCount_r12_n3 = 2,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailCount_r12_n4 = 3
} e_RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailCount_r12;
typedef enum RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12 {
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12_s30 = 0,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12_s60 = 1,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12_s120 = 2,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12_s240 = 3,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12_s300 = 4,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12_s420 = 5,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12_s600 = 6,
RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12_s900 = 7
} e_RACH_ConfigCommon_v1250__txFailParams_r12__connEstFailOffsetValidity_r12;
/* RACH-ConfigCommon-v1250 */
typedef struct RACH_ConfigCommon_v1250 {
struct RACH_ConfigCommon_v1250__txFailParams_r12 {
long connEstFailCount_r12;
long connEstFailOffsetValidity_r12;
long *connEstFailOffset_r12; /* OPTIONAL */
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} txFailParams_r12;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} RACH_ConfigCommon_v1250_t;
/* Implementation */
/* extern asn_TYPE_descriptor_t asn_DEF_connEstFailCount_r12_3; // (Use -fall-defs-global to expose) */
/* extern asn_TYPE_descriptor_t asn_DEF_connEstFailOffsetValidity_r12_8; // (Use -fall-defs-global to expose) */
extern asn_TYPE_descriptor_t asn_DEF_RACH_ConfigCommon_v1250;
extern asn_SEQUENCE_specifics_t asn_SPC_RACH_ConfigCommon_v1250_specs_1;
extern asn_TYPE_member_t asn_MBR_RACH_ConfigCommon_v1250_1[1];
#ifdef __cplusplus
}
#endif
#endif /* _RACH_ConfigCommon_v1250_H_ */
#include <asn_internal.h>
| 42.492754 | 162 | 0.853001 |
03b259233dd022557ea8d24898469b2ab4f7acf2 | 3,015 | h | C | rdkPlugins/Networking/include/NetworkSetup.h | StefanosVorkas/Dobby | c865ce0cfb0bb45f872ab0b3c4fa03ace6811ba2 | [
"Apache-2.0"
] | null | null | null | rdkPlugins/Networking/include/NetworkSetup.h | StefanosVorkas/Dobby | c865ce0cfb0bb45f872ab0b3c4fa03ace6811ba2 | [
"Apache-2.0"
] | null | null | null | rdkPlugins/Networking/include/NetworkSetup.h | StefanosVorkas/Dobby | c865ce0cfb0bb45f872ab0b3c4fa03ace6811ba2 | [
"Apache-2.0"
] | null | null | null | /*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 Sky UK
*
* 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 NETWORKSETUP_H
#define NETWORKSETUP_H
#include "Netfilter.h"
#include "NetworkingHelper.h"
#include "rt_dobby_schema.h"
#include <DobbyRdkPluginProxy.h>
#include <DobbyRdkPluginUtils.h>
#include <arpa/inet.h>
#include <map>
#include <list>
#include <string>
#include <memory>
#include <mutex>
#include <vector>
// -----------------------------------------------------------------------------
/**
* @namespace NetworkSetup
*
* @brief Functions to set up networking for containers
*
*/
namespace NetworkSetup
{
bool setupBridgeDevice(const std::shared_ptr<DobbyRdkPluginUtils> &utils,
const std::shared_ptr<Netfilter> &netfilter,
const std::vector<std::string> &extIfaces);
bool createNetns(const std::string &containerId);
bool setupVeth(const std::shared_ptr<DobbyRdkPluginUtils> &utils,
const std::shared_ptr<Netfilter> &netfilter,
const std::shared_ptr<DobbyRdkPluginProxy> &dobbyProxy,
const std::shared_ptr<NetworkingHelper> &helper,
const std::string &rootfsPath,
const std::string &containerId,
const NetworkType networkType,
const std::string &hookStdin);
bool removeVethPair(const std::shared_ptr<Netfilter> &netfilter,
const std::shared_ptr<NetworkingHelper> &helper,
const std::string &vethName,
const NetworkType networkType,
const std::string &containerId);
bool removeBridgeDevice(const std::shared_ptr<Netfilter> &netfilter,
const std::vector<std::string> &extIfaces);
void addSysfsMount(const std::shared_ptr<DobbyRdkPluginUtils> &utils,
const std::shared_ptr<rt_dobby_schema> &cfg);
void addResolvMount(const std::shared_ptr<DobbyRdkPluginUtils> &utils,
const std::shared_ptr<rt_dobby_schema> &cfg);
void addNetworkNamespace(const std::shared_ptr<rt_dobby_schema> &cfg);
};
bool setupContainerNet(const std::shared_ptr<NetworkingHelper> &helper);
pid_t spawnNetnsOwner(const std::string &containerId);
void deleteNetns(const std::string &containerId);
#endif // !defined(NETWORKSETUP_H)
| 35.05814 | 80 | 0.65937 |
64067e47be7ce4da1f4ed0c4c89ab816e8b62808 | 5,996 | c | C | plugins/plg_nek0.c | plzombie/ne | 8721a981a1d4f4d2b2675eff95657a17df362e78 | [
"BSD-3-Clause"
] | null | null | null | plugins/plg_nek0.c | plzombie/ne | 8721a981a1d4f4d2b2675eff95657a17df362e78 | [
"BSD-3-Clause"
] | 1 | 2017-04-05T00:42:17.000Z | 2017-04-05T00:42:17.000Z | plugins/plg_nek0.c | plzombie/ne | 8721a981a1d4f4d2b2675eff95657a17df362e78 | [
"BSD-3-Clause"
] | null | null | null | /*
Файл : plg_nek0.c
Описание: Плагин для загрузки nek0
История : 15.09.12 Создан
*/
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "../extclib/_wcsicmp.h"
#include "../nyan/nyan_text.h"
#include "../nyan/nyan_log_publicapi.h"
#include "../nyan/nyan_filesys_publicapi.h"
#include "../nyan/nyan_mem_publicapi.h"
#include "../nyan/nyan_file_publicapi.h"
#include "../nyan/nyan_texformat_publicapi.h"
#include "../nyan/nyan_plgtypes_publicapi.h"
#include "../nyan_container/nyan_container_ne_helpers.h"
#include "plg_nek0.h"
#define NEK0_READERVERSION 0
typedef struct {
unsigned int sizex;
unsigned int sizey;
unsigned int datatype;
} nek0head_type;
typedef struct {
nek0head_type base;
int nglrowalignment; // Выравнивание строки
} nek0headext1_type;
bool N_APIENTRY plgNEK0SupportExt(const wchar_t *fname, const wchar_t *fext);
bool N_APIENTRY plgNEK0Load(const wchar_t *fname, nv_texture_type *tex);
nv_tex_plugin_type plgNEK0 = {sizeof(nv_tex_plugin_type), &plgNEK0SupportExt, &plgNEK0Load};
/*
Функция : plgNEK0SupportExt
Описание: Проверяет поддержку типа файла
История : 15.09.12 Создан
*/
bool N_APIENTRY plgNEK0SupportExt(const wchar_t *fname, const wchar_t *fext)
{
(void)fname; // Неиспользуемая переменная
if(_wcsicmp(fext,L"nek0") == 0) return true;
return false;
}
/*
Функция : plgNEK0Load
Описание: Загружает nek0 файл
История : 15.09.12 Создан
*/
bool N_APIENTRY plgNEK0Load(const wchar_t *fname, nv_texture_type *tex)
{
unsigned int f, ret;
nek0head_type *head;
unsigned int bpp;
uint64_t texsize;
nyan_filetype_type filetype; // Тип файла
nyan_chunkhead_type chunkhead; // Заголовок чанка
nlPrint(LOG_FDEBUGFORMAT7, F_PLGNEK0LOAD, N_FNAME, fname); nlAddTab(1);
f = nFileOpen(fname);
if(f == 0) {
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_FILENOTFOUNDED);
return false;
}
// Поиск и чтение чанка FILETYPE
ret = ncfReadAndCheckFiletypeChunk(f, &filetype, "NEK0", NEK0_READERVERSION);
switch(ret) {
case NCF_SUCCESS:
break;
case NCF_ERROR_WRONGFILETYPE:
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_WRONGFILETYPE);
nFileClose(f);
return false;
case NCF_ERROR_CANTFINDFILETYPE:
default:
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_CANTFINDFILETYPE);
nFileClose(f);
return false;
}
// Поиск и чтение чанка FILEHEAD
ret = ncfSeekForChunkAndCheckMinSize(f, &chunkhead, "FILEHEAD", sizeof(nek0head_type));
switch(ret) {
case NCF_SUCCESS:
if(chunkhead.csize > SIZE_MAX) {
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_FILEISTOOLARGE);
nFileClose(f);
return false;
}
head = malloc((size_t)(chunkhead.csize));
if(!head) {
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_WRONGFILEHEAD);
nFileClose(f);
return false;
}
nFileRead(f, head, (size_t)(chunkhead.csize));
switch(head->datatype) {
case NGL_COLORFORMAT_R8G8B8:
case NGL_COLORFORMAT_B8G8R8:
case NGL_COLORFORMAT_R8G8B8A8:
case NGL_COLORFORMAT_B8G8R8A8:
case NGL_COLORFORMAT_A8B8G8R8:
case NGL_COLORFORMAT_L8A8:
case NGL_COLORFORMAT_X1R5G5B5:
case NGL_COLORFORMAT_R5G6B5:
case NGL_COLORFORMAT_L8:
if(chunkhead.csize < sizeof(nek0headext1_type)) {
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT9, F_PLGNEK0LOAD, ERR_CANTALLOCMEM, (long long)chunkhead.csize);
free(head);
nFileClose(f);
return false;
}
}
break;
case NCF_ERROR_DAMAGEDFILE:
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_WRONGFILEHEAD);
nFileClose(f);
return false;
case NCF_ERROR_CANTFINDCHUNK:
default:
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_CANTFINDFILEHEAD);
nFileClose(f);
return false;
}
tex->sizex = head->sizex;
tex->sizey = head->sizey;
tex->nglrowalignment = ((nek0headext1_type *) head)->nglrowalignment;
switch(head->datatype) {
case NGL_COLORFORMAT_R8G8B8:
case NGL_COLORFORMAT_B8G8R8:
tex->nglcolorformat = head->datatype;
bpp = 3;
break;
case NGL_COLORFORMAT_R8G8B8A8:
case NGL_COLORFORMAT_B8G8R8A8:
case NGL_COLORFORMAT_A8B8G8R8:
tex->nglcolorformat = head->datatype;
bpp = 4;
break;
case NGL_COLORFORMAT_L8A8:
case NGL_COLORFORMAT_X1R5G5B5:
case NGL_COLORFORMAT_R5G6B5:
tex->nglcolorformat = head->datatype;
bpp = 2;
break;
case NGL_COLORFORMAT_L8:
tex->nglcolorformat = head->datatype;
bpp = 1;
break;
default:
free(head);
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_UNSUPPORTEDDATATYPE);
nFileClose(f);
return false;
}
free(head);
if(tex->nglrowalignment <= 0) {
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_FILEISDAMAGED);
nFileClose(f);
return false;
} else {
uint64_t rowsize;
rowsize = bpp*(uint64_t)tex->sizex;
if(rowsize%tex->nglrowalignment > 0)
rowsize += tex->nglrowalignment-(rowsize%tex->nglrowalignment);
texsize = tex->sizey*rowsize;
}
if(texsize > SIZE_MAX) {
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_FILEISTOOLARGE);
nFileClose(f);
return false;
}
// Поиск чанка FILEDATA
ret = ncfSeekForChunkAndCheckMinSize(f, &chunkhead, "FILEDATA", texsize);
switch(ret) {
case NCF_SUCCESS:
break;
case NCF_ERROR_DAMAGEDFILE:
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_WRONGFILEDATA);
nFileClose(f);
return false;
case NCF_ERROR_CANTFINDCHUNK:
default:
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, ERR_CANTFINDFILEDATA);
nFileClose(f);
return false;
}
// Чтение чанка FILEDATA
tex->buffer = nAllocMemory((size_t)texsize);
if(!tex->buffer) {
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT9, F_PLGNEK0LOAD, ERR_CANTALLOCMEM, (long long)texsize);
nFileClose(f);
return false;
}
nFileRead(f, tex->buffer, (size_t)texsize);
nFileSeek(f, chunkhead.csize-texsize, FILE_SEEK_CUR);
nFileClose(f);
nlAddTab(-1); nlPrint(LOG_FDEBUGFORMAT, F_PLGNEK0LOAD, N_OK);
return true;
}
| 25.299578 | 108 | 0.733155 |
c178ddb885115b5fffe94b5bd57794b4f1e0ae93 | 1,992 | h | C | lib/vas/include/vas_internal.h | BarrelfishOS/barrelfish-spacejmp | 1453082126e8b52bc5e1ba5aee431e6f06261980 | [
"MIT"
] | null | null | null | lib/vas/include/vas_internal.h | BarrelfishOS/barrelfish-spacejmp | 1453082126e8b52bc5e1ba5aee431e6f06261980 | [
"MIT"
] | null | null | null | lib/vas/include/vas_internal.h | BarrelfishOS/barrelfish-spacejmp | 1453082126e8b52bc5e1ba5aee431e6f06261980 | [
"MIT"
] | 1 | 2022-01-23T20:29:26.000Z | 2022-01-23T20:29:26.000Z | /*
* Copyright (c) 2015, ETH Zurich.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
* ETH Zurich D-INFK, Universitaetsstrasse 4, CH-8092 Zurich. Attn: Systems Group.
*/
#ifndef __VAS_INTERNAL_H_
#define __VAS_INTERNAL_H_ 1
#include <barrelfish/barrelfish.h>
#include <barrelfish/core_state_arch.h>
#include <vas/vas.h>
#include <vas/vas_segment.h>
#include <vas_debug.h>
static inline struct vas *vas_get_vas_pointer(vas_handle_t vashandle)
{
return (struct vas *)vashandle;
}
static inline vas_handle_t vas_get_handle(struct vas* vas)
{
return (vas_handle_t)vas;
}
#define VAS_ID_MASK 0x0000ffffffffffffUL
#define VAS_ID_TAG_MASK 0x0fff000000000000UL
#define VAS_ID_MASK 0x0000ffffffffffffUL
#define VAS_ID_MARK 0xA000000000000000UL
static inline uint16_t vas_id_extract_tag(vas_id_t id)
{
return (uint16_t)((id >> 48) & 0xfff);
}
static inline vas_id_t vas_id_insert_tag(vas_id_t id, uint16_t tag)
{
return ((id & ~VAS_ID_TAG_MASK) | (((vas_id_t)tag & 0xfff) << 48));
}
///< internal representation of the VAS
struct vas
{
vas_id_t id; ///< the vas id
uint16_t tag; ///< tag for the vas
vas_state_t state; ///< the state of the vas
vas_flags_t perms; ///< associated permissions
char name[VAS_NAME_MAX_LEN]; ///< name of the vas
struct vspace_state vspace_state; ///< vspace state
struct capref pagecn_cap; ///< cap of the page cn
struct cnoderef pagecn; ///< pagecn cap
struct capref vroot; ///< vroot
struct single_slot_allocator pagecn_slot_alloc;
};
struct vas_seg
{
vas_seg_id_t id;
char name [VAS_NAME_MAX_LEN];
vas_seg_type_t type;
vas_flags_t flags;
lvaddr_t vaddr;
size_t length;
struct capref frame;
};
#endif /* __VAS_INTERNAL_H_ */
| 27.287671 | 82 | 0.680221 |
1ebfd75f05d9bbd2215cf7aafb84ab897f962b6a | 684 | h | C | detector_core/common/maphelp.h | zhlongfj/cppdetector | 0907720cdb82661ae137e4883346fc33cb115794 | [
"MIT"
] | 2 | 2022-03-22T05:50:40.000Z | 2022-03-22T06:00:42.000Z | detector_core/common/maphelp.h | zhlongfj/cppdetector | 0907720cdb82661ae137e4883346fc33cb115794 | [
"MIT"
] | null | null | null | detector_core/common/maphelp.h | zhlongfj/cppdetector | 0907720cdb82661ae137e4883346fc33cb115794 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include <vector>
#include <functional>
using namespace std;
template<class T>
class MapHelp final {
public:
explicit MapHelp(const map<string, T>& elements) : m_elements(elements) {}
map<string, T> erase(const T& reference, function<bool(const T& element, const T& reference)> func)
{
for (auto iter = m_elements.begin(); iter != m_elements.end();)
{
if (func(iter->second, reference))
{
m_elements.erase(iter++);
}
else
{
++iter;
}
}
return m_elements;
}
private:
map<string, T> m_elements;
};
| 23.586207 | 103 | 0.548246 |
f018338f671a65d617be8d3f8594caebd8afbdbc | 1,327 | h | C | include/OrchestratorInterface.h | AlbinMartinsson/client-cpp | 42d5acc96b00b8b1396ad1fa5a4d8f2234a15718 | [
"Apache-2.0"
] | null | null | null | include/OrchestratorInterface.h | AlbinMartinsson/client-cpp | 42d5acc96b00b8b1396ad1fa5a4d8f2234a15718 | [
"Apache-2.0"
] | null | null | null | include/OrchestratorInterface.h | AlbinMartinsson/client-cpp | 42d5acc96b00b8b1396ad1fa5a4d8f2234a15718 | [
"Apache-2.0"
] | 1 | 2020-09-22T08:08:42.000Z | 2020-09-22T08:08:42.000Z | #pragma once
#include "HttpHandler.h"
#include "HttpsHandler.h"
#include "ArrowheadDataExt.h"
#include <json-c/json.h>
namespace arrowhead{
// TODO split http and https parts
class OrchestratorInterface : HttpHandler, HttpsHandler {
private:
std::string URI;
// help functions to clean up code
void jsonAddString(json_object* obj, std::string str, const char* name);
void jsonAddInt(json_object* obj, int nr, const char* name);
void jsonAddBool(json_object* obj, bool boolean, const char* name);
protected:
std::string target_uri;
std::string sConsumerID;
OrchestratorInterface();
~OrchestratorInterface();
// GET or POST
// to send/get msgs
void sendRequestToProvider(std::string data,
std::string provider_uri, std::string method);
// initialisation get a orchestration connection
bool getOrchetrationRequestForm(json_object *&request_form,
ArrowheadDataExt &config);
int sendOrchestrationRequest(std::string rResult, ArrowheadDataExt *config);
size_t callbackOrchestrationResponse(char *ptr, size_t size);
// callback path for GET
// @override
size_t callbackGETHttp(char *ptr, size_t size);
virtual size_t callbackRequest(const char *ptr, size_t size);
size_t httpResponseCallback(char *ptr, size_t size);
size_t httpsResponseCallback(char *ptr, size_t size);
};
}
| 25.519231 | 77 | 0.75584 |
1b537c384dc6f2682c79cf13ad8569f26a328974 | 1,019 | h | C | VENRemoteUserDefaultsManager/VENRemoteUserDefaultsManager.h | dasmer/VENRemoteUserDefaultsManager | d7a7916c764e7426fc5610da86ad99c4636eea22 | [
"MIT"
] | 1 | 2015-07-16T16:52:44.000Z | 2015-07-16T16:52:44.000Z | VENRemoteUserDefaultsManager/VENRemoteUserDefaultsManager.h | dasmer/VENRemoteUserDefaultsManager | d7a7916c764e7426fc5610da86ad99c4636eea22 | [
"MIT"
] | null | null | null | VENRemoteUserDefaultsManager/VENRemoteUserDefaultsManager.h | dasmer/VENRemoteUserDefaultsManager | d7a7916c764e7426fc5610da86ad99c4636eea22 | [
"MIT"
] | null | null | null | #import <Foundation/Foundation.h>
@interface VENRemoteUserDefaultsManager : NSObject
///The minimum number of seconds before requesting a location ping.
@property (nonatomic, assign) NSInteger minimumUpdateInterval;
/**
* Returns the shared manager responsible for updating userDefaults from the specified URL
* @return A VENRemoteUserDefaultsManager object.
*/
+ (instancetype)sharedManager;
/**
* Sets the URL of the remote plist of user defaults
*/
- (void)setPlistURL:(NSURL *)plistURL;
/**
* Updates the userDefaults in a background queue if the time since last update is greater than the minimumUpdateInterval.
*/
- (void)updateRemoteDefaults;
/**
* Updates the userDefaults in a background queue. The completion block will always be called. SUCCESS is NO if the time since last update is greater than the minimumUpdateInterval, or if the plist file is not a valid NSDictionary, and YES otherwise.
*/
- (void)updateRemoteDefaultsWithCompletionBlock:(void(^)(BOOL success))completionBlock;
@end
| 30.878788 | 250 | 0.777233 |
8878e40264840535900ac3bf2986a37d4fd23647 | 1,061 | h | C | System/Library/PrivateFrameworks/OfficeImport.framework/PMTableCellMapper.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 2 | 2021-11-02T09:23:27.000Z | 2022-03-28T08:21:57.000Z | System/Library/PrivateFrameworks/OfficeImport.framework/PMTableCellMapper.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/OfficeImport.framework/PMTableCellMapper.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 1 | 2022-03-28T08:21:59.000Z | 2022-03-28T08:21:59.000Z | /*
* This header is generated by classdump-dyld 1.5
* on Wednesday, October 27, 2021 at 3:22:40 PM Mountain Standard Time
* Operating System: Version 13.5.1 (Build 17F80)
* Image Source: /System/Library/PrivateFrameworks/OfficeImport.framework/OfficeImport
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
#import <OfficeImport/CMMapper.h>
@class OADTableCell, CMStyle;
@interface PMTableCellMapper : CMMapper {
OADTableCell* mCell;
CMStyle* mStyle;
int mColIndex;
unsigned long long mRowIndex;
float mWidth;
}
-(void)mapAt:(id)arg1 withState:(id)arg2 ;
-(id)tableMapper;
-(void)mapBordersWithState:(id)arg1 ;
-(void)mapCellPropertiesWithState:(id)arg1 textAnchor:(unsigned char)arg2 ;
-(id)initWithOadTableCell:(id)arg1 rowIndex:(unsigned long long)arg2 columnIndex:(int)arg3 parent:(id)arg4 ;
-(float)widthWithState:(id)arg1 ;
-(id)rowMapper;
@end
| 34.225806 | 130 | 0.667295 |
003cf331cc59f22dfa6fb01950e2df4b0b362cf6 | 147 | h | C | es-app/src/mqtt/paho/c/VersionInfo.h | AdoPi/custom-es-fork | 49d23b57173612531fdf0f1c996592fb161df779 | [
"MIT"
] | null | null | null | es-app/src/mqtt/paho/c/VersionInfo.h | AdoPi/custom-es-fork | 49d23b57173612531fdf0f1c996592fb161df779 | [
"MIT"
] | null | null | null | es-app/src/mqtt/paho/c/VersionInfo.h | AdoPi/custom-es-fork | 49d23b57173612531fdf0f1c996592fb161df779 | [
"MIT"
] | null | null | null | #ifndef VERSIONINFO_H
#define VERSIONINFO_H
#define BUILD_TIMESTAMP "now"
#define CLIENT_VERSION "recalbox-internal"
#endif /* VERSIONINFO_H */
| 18.375 | 43 | 0.789116 |
004cb813804f126a711fb2dc135888c63b51c4a5 | 543 | h | C | include/ArgumentParser.h | RicardoLuis0/Chip8-Emulator-RicardoLuis0 | c57d0d1df48b67f9e40c0c4af01a76b5877a4187 | [
"Unlicense"
] | null | null | null | include/ArgumentParser.h | RicardoLuis0/Chip8-Emulator-RicardoLuis0 | c57d0d1df48b67f9e40c0c4af01a76b5877a4187 | [
"Unlicense"
] | null | null | null | include/ArgumentParser.h | RicardoLuis0/Chip8-Emulator-RicardoLuis0 | c57d0d1df48b67f9e40c0c4af01a76b5877a4187 | [
"Unlicense"
] | null | null | null | #ifndef ARGUMENTPARSER_H
#define ARGUMENTPARSER_H
#include "Arguments.h"
/**
* Parses the arguments sent to the program, and splits it into options
*/
class ArgumentParser {
public:
/**
* parses argc,argv into and generates an Arguments object
* @param argc: number of arguments
* @param argv: list of arguments
* @return Arguments object created from inputs
*/
static Arguments parse(int argc,char ** argv,std::map<std::string,bool> exists);
};
#endif // ARGUMENTPARSER_H
| 25.857143 | 88 | 0.6593 |
1854932ee4879839e20f2e714625d16aa3cafab8 | 551 | h | C | Qlink/Manager/UserManage.h | QlcChainOrg/winq-ios | 21dc93068e2f4bfe14b1fa65a398a049782894c5 | [
"MIT"
] | 8 | 2018-07-11T12:31:20.000Z | 2019-08-14T03:38:45.000Z | Qlink/Manager/UserManage.h | QlcChainOrg/winq-ios | 21dc93068e2f4bfe14b1fa65a398a049782894c5 | [
"MIT"
] | 65 | 2020-03-29T08:17:07.000Z | 2021-01-14T22:41:10.000Z | Qlink/Manager/UserManage.h | QlcChainOrg/winq-ios | 21dc93068e2f4bfe14b1fa65a398a049782894c5 | [
"MIT"
] | 9 | 2018-07-11T10:37:19.000Z | 2019-08-03T10:33:14.000Z | //
// UserModel.h
// Qlink
//
// Created by Jelly Foo on 2018/4/18.
// Copyright © 2018年 pan. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface UserManage : NSObject
@property (nonatomic , strong) NSString *myQLC;
@property (nonatomic , strong) NSString *myGAS;
+ (instancetype)shareInstance;
//+ (BOOL)isExistHeadUrl;
//- (void)registerNoti;
+ (NSString *)getHeadUrl;
+ (NSString *)getWholeHeadUrl;
+ (void)setHeadUrl:(NSString *)url;
+ (void)requestGetHeadView;
- (NSString *)getRandomName;
+ (void)fetchUserInfo;
@end
| 19 | 47 | 0.705989 |
63ada17684c35728568a6c32a87de503b65a72ab | 794 | h | C | juniper/src/vespa/juniper/IJuniperProperties.h | Anlon-Burke/vespa | 5ecd989b36cc61716bf68f032a3482bf01fab726 | [
"Apache-2.0"
] | 4,054 | 2017-08-11T07:58:38.000Z | 2022-03-31T22:32:15.000Z | juniper/src/vespa/juniper/IJuniperProperties.h | Anlon-Burke/vespa | 5ecd989b36cc61716bf68f032a3482bf01fab726 | [
"Apache-2.0"
] | 4,854 | 2017-08-10T20:19:25.000Z | 2022-03-31T19:04:23.000Z | juniper/src/vespa/juniper/IJuniperProperties.h | Anlon-Burke/vespa | 5ecd989b36cc61716bf68f032a3482bf01fab726 | [
"Apache-2.0"
] | 541 | 2017-08-10T18:51:18.000Z | 2022-03-11T03:18:56.000Z | // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
/** An abstract interface to configuration file settings used by Juniper to process
* it's preconfigured parameter sets.
*/
class IJuniperProperties
{
public:
/** Get the value of a property
* @param name The textual representation of the property
* assumed to be on the form class.juniperpart.variable, such as for example
* juniper.dynsum.length
* @param def A default value for the property if not found in configuration
* @return The value of the property or @param def if no such property is set
*/
virtual const char* GetProperty(const char* name, const char* def = nullptr) = 0;
virtual ~IJuniperProperties() {};
};
| 36.090909 | 104 | 0.714106 |
4971ce8c626c8990cfdf314203045a1a9f2783de | 994 | c | C | lib/wizards/gynter/element/fire/6.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/gynter/element/fire/6.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/gynter/element/fire/6.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | inherit "room/room";
object demon, demon1, demon2, demon3;
reset(arg) {
/* Applying mobs */
if(!demon) {
demon = clone_object("/wizards/gynter/element/mobs/med_fire");
move_object(demon, this_object());
}
if (!demon1) {
demon1 = clone_object("/wizards/gynter/element/mobs/med_fire");
move_object(demon1, this_object());
}
if (!demon2) {
demon2 = clone_object("/wizards/gynter/element/mobs/med_fire");
move_object(demon2, this_object());
}
if(!demon3) {
demon3 = clone_object("/wizards/gynter/element/mobs/med_fire");
move_object(demon3, this_object());
}
/* Assigning exits */
add_exit("north","/wizards/gynter/element/fire/1");
add_exit("south","/wizards/gynter/element/fire/7");
/* setting desc */
short_desc = "A large hallway";
long_desc = "You are standing in a large hallway.\n"+
"The walls are made out of burning fires, and in the fires\n"+
"there are scenes from battles fought ages ago.\n";
}
| 32.064516 | 76 | 0.656942 |
9dc9872d6857926352208aafae648da67b19841b | 4,803 | c | C | pset2/caesar/caesar.c | lwaddle/cs50x-2021 | cd8bdc2436562873dff28916637a6e9643d104d1 | [
"MIT"
] | null | null | null | pset2/caesar/caesar.c | lwaddle/cs50x-2021 | cd8bdc2436562873dff28916637a6e9643d104d1 | [
"MIT"
] | null | null | null | pset2/caesar/caesar.c | lwaddle/cs50x-2021 | cd8bdc2436562873dff28916637a6e9643d104d1 | [
"MIT"
] | null | null | null | #include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void encipher(char *plaintext, int key);
int get_alphabetical_index(char c);
int get_valid_key(int argc, char *argv[]);
int main(int argc, char *argv[])
{
// Get key
int key = get_valid_key(argc, argv);
if (key == -1) // Invalid CL arg
{
return 1;
}
// Get plaintext
char *plaintext = get_string("plaintext: ");
// Encipher and print output
encipher(plaintext, key);
return 0;
}
/**
* This function enciphers (encrypts?) plaintext by offsetting the plaintext
* by 'key' positions. For example: plaintext 'ABC' with a key of 1 would
* equal 'BCD'. 'Z' with a key of 2 would equal 'B'. If the key ofsets the
* character over the boundaries of the English alphabet, they overflow back
* to the 0 index. The function also prints the output.
*/
void encipher(char *plaintext, int key)
{
/**
* The algorithm (i.e., cipher) encrypts messages by “rotating” each
* letter by k positions. More formally, if p is some plaintext
* (i.e., an unencrypted message), p sub i is the ith character in p, and
* k is a secret key (i.e., a non-negative integer), then each letter,
* c sub i, in the ciphertext, c, is computed as:
*
* c sub i = (p sub i + k) % 26
*/
const char ALPHABET[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
int plaintext_length = strlen(plaintext);
printf("ciphertext: ");
for (int i = 0; i < plaintext_length; i++)
{
if (isalpha(plaintext[i]))
{
// Handle upper/lower case events
if (isupper(plaintext[i])) // Uppercase detected
{
int alphabetical_index = get_alphabetical_index(plaintext[i]);
int cipher_index = (get_alphabetical_index(plaintext[i]) + key) % 26;
printf("%c", ALPHABET[cipher_index]);
}
else // Lowercase detected
{
int alphabetical_index = get_alphabetical_index(plaintext[i]);
int cipher_index = (get_alphabetical_index(plaintext[i]) + key) % 26;
printf("%c", tolower(ALPHABET[cipher_index]));
}
}
else // Not alpha
{
printf("%c", plaintext[i]);
}
}
printf("\n");
return;
}
/**
* Returns the alphabetical index of a character. For example: 'A' is index
* 0, 'B' is index 1, and 'Z' is index 25. If the function is supplied
* anything other than an English alphabet character, it will return an error
* code of -1.
*/
int get_alphabetical_index(char c)
{
const char ALPHABET[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
int index = -1;
for (int i = 0; i < 26; i++)
{
if (toupper(c) == ALPHABET[i])
{
index = i;
}
}
// Error handling
if (index == -1)
{
fprintf(stderr, "Error -1. Index out of English alphabet range.\n");
return index;
}
return index;
}
/**
* Returns the key from the user's command line argument. In the event that
* the argument is invalid, it will display a message providing instructions.
* An invalid argument will return a value of -1.
*/
int get_valid_key(int argc, char *argv[])
{
// Standard error message
char *error_message = "Usage: ./caesar key";
// Start by assuming the user's argument is valid
int valid_argument = 1;
// Did the user actually provide an argument?
if (argc != 2)
{
valid_argument = 0;
// No reason to continue
printf("%s\n", error_message);
return -1; // This is an error code
}
// Check that each character is a valid digit
for (int i = 0, length = strlen(argv[1]); i < length; i++)
{
if (!isdigit(argv[1][i]))
{
valid_argument = 0;
}
}
// Is the first element a negative sign? If so, invalid
if (argv[1][0] == '-')
{
valid_argument = 0;
}
// Ensure no leading zeros
if (valid_argument && (strlen(argv[1]) > 1) && argv[1][0] == '0')
{
valid_argument = 0;
}
// Convert valid argument to int
int key = 0;
if (valid_argument)
{
key = atoi(argv[1]);
return key;
}
else
{
printf("%s\n", error_message);
return -1; // This is an error code
}
}
| 27.763006 | 85 | 0.531126 |
6f3eb5f476857aca31501475d43208e417892705 | 297 | c | C | glibc-2.21/math/e_hypotl.c | LinuxUser404/smack-glibc | 75137ec47348317a8dbb431774b74dbb7bd2ec4f | [
"MIT"
] | 12 | 2018-09-18T19:51:27.000Z | 2022-01-18T15:31:41.000Z | glibc-2.21/math/e_hypotl.c | LinuxUser404/smack-glibc | 75137ec47348317a8dbb431774b74dbb7bd2ec4f | [
"MIT"
] | null | null | null | glibc-2.21/math/e_hypotl.c | LinuxUser404/smack-glibc | 75137ec47348317a8dbb431774b74dbb7bd2ec4f | [
"MIT"
] | 3 | 2019-06-12T19:38:54.000Z | 2020-03-05T19:17:23.000Z | #include <math.h>
#include <stdio.h>
#include <errno.h>
long double
__ieee754_hypotl (long double x, long double y)
{
fputs ("__ieee754_hypotl not implemented\n", stderr);
__set_errno (ENOSYS);
return 0.0;
}
strong_alias (__ieee754_hypotl, __hypotl_finite)
stub_warning (__ieee754_hypotl)
| 19.8 | 55 | 0.754209 |
c0b5fe15a4cec10b816639dafe156e2682bbe2c0 | 1,450 | c | C | sm64ex-nightly/src/game/behaviors/horizontal_grindel.inc.c | alex-free/sm64ex-creator | e7089df69fb43f266b2165078d94245b33b8e72a | [
"Intel",
"X11",
"Unlicense"
] | 2 | 2022-03-12T08:27:53.000Z | 2022-03-12T18:26:06.000Z | sm64ex-nightly/src/game/behaviors/horizontal_grindel.inc.c | alex-free/sm64ex-creator | e7089df69fb43f266b2165078d94245b33b8e72a | [
"Intel",
"X11",
"Unlicense"
] | null | null | null | sm64ex-nightly/src/game/behaviors/horizontal_grindel.inc.c | alex-free/sm64ex-creator | e7089df69fb43f266b2165078d94245b33b8e72a | [
"Intel",
"X11",
"Unlicense"
] | null | null | null |
void bhv_horizontal_grindel_init(void) {
o->oHorizontalGrindelTargetYaw = o->oMoveAngleYaw;
}
void bhv_horizontal_grindel_update(void) {
if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) {
if (!o->oHorizontalGrindelOnGround) {
cur_obj_play_sound_2(SOUND_OBJ_THWOMP);
o->oHorizontalGrindelOnGround = TRUE;
set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ);
o->oHorizontalGrindelDistToHome = cur_obj_lateral_dist_to_home();
o->oForwardVel = 0.0f;
o->oTimer = 0;
}
if (cur_obj_rotate_yaw_toward(o->oHorizontalGrindelTargetYaw, 0x400)) {
if (o->oTimer > 60) {
if (o->oHorizontalGrindelDistToHome > 300.0f) {
o->oHorizontalGrindelTargetYaw += 0x8000;
o->oHorizontalGrindelDistToHome = 0.0f;
} else {
cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB_JUMP);
o->oForwardVel = 11.0f;
o->oVelY = 70.0f;
o->oGravity = -4.0f;
o->oMoveFlags = 0;
}
}
} else {
o->oTimer = 0;
}
} else {
o->oHorizontalGrindelOnGround = FALSE;
if (o->oVelY < 0.0f) {
o->oGravity = -16.0f;
}
}
o->oFaceAngleYaw = o->oMoveAngleYaw + 0x4000;
cur_obj_move_standard(78);
}
| 32.954545 | 87 | 0.543448 |
53fd533fa875f31d5c22ca86138449d0ea1f9d72 | 2,208 | h | C | src/ModbusServerRTU.h | troky/eModbus | 1f16832ea9fdfe7b4c3e40dd88063592d6afa39d | [
"MIT"
] | null | null | null | src/ModbusServerRTU.h | troky/eModbus | 1f16832ea9fdfe7b4c3e40dd88063592d6afa39d | [
"MIT"
] | null | null | null | src/ModbusServerRTU.h | troky/eModbus | 1f16832ea9fdfe7b4c3e40dd88063592d6afa39d | [
"MIT"
] | null | null | null | // =================================================================================================
// eModbus: Copyright 2020 by Michael Harwerth, Bert Melis and the contributors to eModbus
// MIT license - see license.md for details
// =================================================================================================
#ifndef _MODBUS_SERVER_RTU_H
#define _MODBUS_SERVER_RTU_H
#include "options.h"
#if HAS_FREERTOS
#include <Arduino.h>
#include "HardwareSerial.h"
#include "ModbusServer.h"
#include "RTUutils.h"
extern "C" {
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
}
class ModbusServerRTU : public ModbusServer {
public:
// Constructor
ModbusServerRTU(HardwareSerial& serial, uint32_t timeout, int rtsPin = -1);
// Destructor
~ModbusServerRTU();
// start: create task with RTU server to accept requests
bool start(int coreID = -1);
// stop: kill server task
bool stop();
protected:
// Prevent copy construction and assignment
ModbusServerRTU(ModbusServerRTU& m) = delete;
ModbusServerRTU& operator=(ModbusServerRTU& m) = delete;
inline void isInstance() { } // Make class instantiable
static uint8_t instanceCounter; // Number of RTU servers created (for task names)
TaskHandle_t serverTask; // task of the started server
uint32_t serverTimeout; // given timeout for receive. Does not really
// matter for a server, but is needed in
// RTUutils. After timeout without any message
// the server will pause ~1ms and start
// receive again.
HardwareSerial& MSRserial; // The serial interface to use
uint32_t MSRinterval; // Bus quiet time between messages
uint32_t MSRlastMicros; // microsecond time stamp of last bus activity
uint32_t MSRrtsPin; // GPIO number of the RS485 module's RE/DE line
// serve: loop function for server task
static void serve(ModbusServerRTU *myself);
};
#endif // HAS_FREERTOS
#endif // INCLUDE GUARD
| 35.612903 | 100 | 0.580163 |
48f063d2d461de2113673d40c3a5490b7c194686 | 5,779 | h | C | UnitTests/Utils.h | sjohal21/Floating-Sandbox | 0170e3696ed4f012f5f17fdbbdaef1af4117f495 | [
"CC-BY-4.0"
] | 44 | 2018-07-08T16:44:53.000Z | 2022-02-06T14:07:30.000Z | UnitTests/Utils.h | sjohal21/Floating-Sandbox | 0170e3696ed4f012f5f17fdbbdaef1af4117f495 | [
"CC-BY-4.0"
] | 31 | 2019-03-24T16:00:38.000Z | 2022-02-24T20:23:18.000Z | UnitTests/Utils.h | sjohal21/Floating-Sandbox | 0170e3696ed4f012f5f17fdbbdaef1af4117f495 | [
"CC-BY-4.0"
] | 24 | 2018-11-08T21:58:53.000Z | 2022-01-12T12:04:42.000Z | #include <GameCore/FileSystem.h>
#include <GameCore/MemoryStreams.h>
#include <map>
#include <vector>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
::testing::AssertionResult ApproxEquals(float a, float b, float tolerance);
class TestFileSystem : public IFileSystem
{
public:
struct FileInfo
{
std::shared_ptr<memory_streambuf> StreamBuf;
std::filesystem::file_time_type LastModified;
};
using FileMap = std::map<std::filesystem::path, FileInfo>;
TestFileSystem()
: mFileMap()
{}
FileMap & GetFileMap()
{
return mFileMap;
}
void PrepareTestFile(
std::filesystem::path testFilePath,
std::string content = "",
std::filesystem::file_time_type lastModified = std::filesystem::file_time_type::clock::now())
{
auto & fileInfoEntry = mFileMap[testFilePath];
fileInfoEntry.StreamBuf = std::make_shared<memory_streambuf>(content);
fileInfoEntry.LastModified = lastModified;
}
std::string GetTestFileContent(std::filesystem::path testFilePath)
{
auto const it = mFileMap.find(testFilePath);
if (it == mFileMap.end())
{
throw std::logic_error("File path '" + testFilePath.string() + "' does not exist in test file system");
}
if (!it->second.StreamBuf)
{
throw std::logic_error("GetTestFileContents() invoked for file with no stream: " + testFilePath.string());
}
return std::string(
it->second.StreamBuf->data(),
it->second.StreamBuf->size());
}
///////////////////////////////////////////////////////////
// IFileSystem
///////////////////////////////////////////////////////////
bool Exists(std::filesystem::path const & path) override
{
auto it = mFileMap.find(path);
return (it != mFileMap.end());
}
std::filesystem::file_time_type GetLastModifiedTime(std::filesystem::path const & path) override
{
auto const it = mFileMap.find(path);
if (it == mFileMap.end())
{
throw std::logic_error("File path '" + path.string() + "' does not exist in test file system");
}
return it->second.LastModified;
}
void EnsureDirectoryExists(std::filesystem::path const & /*directoryPath*/) override
{
// Nop
}
std::shared_ptr<std::istream> OpenInputStream(std::filesystem::path const & filePath) override
{
auto it = mFileMap.find(filePath);
if (it != mFileMap.end())
{
it->second.StreamBuf->rewind();
return std::make_shared<std::istream>(it->second.StreamBuf.get());
}
else
{
return std::shared_ptr<std::istream>();
}
}
std::shared_ptr<std::ostream> OpenOutputStream(std::filesystem::path const & filePath) override
{
auto streamBuf = std::make_shared<memory_streambuf>();
mFileMap[filePath].StreamBuf = streamBuf;
mFileMap[filePath].LastModified = std::filesystem::file_time_type::clock::now();
return std::make_shared<std::ostream>(streamBuf.get());
}
std::vector<std::filesystem::path> ListFiles(std::filesystem::path const & directoryPath) override
{
std::vector<std::filesystem::path> filePaths;
for (auto const & kv : mFileMap)
{
if (IsParentOf(directoryPath, kv.first))
filePaths.push_back(kv.first);
}
return filePaths;
}
void DeleteFile(std::filesystem::path const & filePath) override
{
auto it = mFileMap.find(filePath);
if (it == mFileMap.end())
throw std::logic_error("File path '" + filePath.string() + "' does not exist in test file system");
mFileMap.erase(it);
}
void RenameFile(
std::filesystem::path const & oldFilePath,
std::filesystem::path const & newFilePath) override
{
auto oldIt = mFileMap.find(oldFilePath);
if (oldIt == mFileMap.end())
throw std::logic_error("File path '" + oldFilePath.string() + "' does not exist in test file system");
auto newIt = mFileMap.find(newFilePath);
if (newIt != mFileMap.end())
throw std::logic_error("File path '" + newFilePath.string() + "' already exists in test file system");
mFileMap[newFilePath] = oldIt->second;
mFileMap.erase(oldIt);
}
private:
static bool IsParentOf(
std::filesystem::path const & directoryPath,
std::filesystem::path const & childPath)
{
auto childIt = childPath.begin();
for (auto const & element : directoryPath)
{
if (childIt == childPath.end() || *childIt != element)
return false;
++childIt;
}
return true;
}
FileMap mFileMap;
};
class MockFileSystem : public IFileSystem
{
public:
MOCK_METHOD1(Exists, bool(std::filesystem::path const & path));
MOCK_METHOD1(GetLastModifiedTime, std::filesystem::file_time_type(std::filesystem::path const & path));
MOCK_METHOD1(EnsureDirectoryExists, void(std::filesystem::path const & directoryPath));
MOCK_METHOD1(OpenOutputStream, std::shared_ptr<std::ostream>(std::filesystem::path const & filePath));
MOCK_METHOD1(OpenInputStream, std::shared_ptr<std::istream>(std::filesystem::path const & filePath));
MOCK_METHOD1(ListFiles, std::vector<std::filesystem::path>(std::filesystem::path const & directoryPath));
MOCK_METHOD1(DeleteFile, void(std::filesystem::path const & filePath));
MOCK_METHOD2(RenameFile, void(std::filesystem::path const & oldFilePath, std::filesystem::path const & newFilePath));
};
float DivideByTwo(float value); | 31.579235 | 121 | 0.610659 |
3e8bd720a85ec4b1d20a353412f12d3ff47214a8 | 14,122 | h | C | common/source/common/net/message/NetMessageTypes.h | TomatoYoung/beegfs | edf287940175ecded493183209719d2d90d45374 | [
"BSD-3-Clause"
] | null | null | null | common/source/common/net/message/NetMessageTypes.h | TomatoYoung/beegfs | edf287940175ecded493183209719d2d90d45374 | [
"BSD-3-Clause"
] | null | null | null | common/source/common/net/message/NetMessageTypes.h | TomatoYoung/beegfs | edf287940175ecded493183209719d2d90d45374 | [
"BSD-3-Clause"
] | null | null | null | #ifndef NETMESSAGETYPES_H_
#define NETMESSAGETYPES_H_
/* This file MUST be kept in sync with the corresponding client file!
* See fhgfs_client/source/closed/common/net/message/NetMessageTypes.h
*
* Also do not forget to add net NetMessages to 'class NetMsgStrMapping'
*/
// invalid messages
#define NETMSGTYPE_Invalid 0
// nodes messages
#define NETMSGTYPE_RemoveNode 1013
#define NETMSGTYPE_RemoveNodeResp 1014
#define NETMSGTYPE_GetNodes 1017
#define NETMSGTYPE_GetNodesResp 1018
#define NETMSGTYPE_HeartbeatRequest 1019
#define NETMSGTYPE_Heartbeat 1020
#define NETMSGTYPE_GetNodeCapacityPools 1021
#define NETMSGTYPE_GetNodeCapacityPoolsResp 1022
#define NETMSGTYPE_MapTargets 1023
#define NETMSGTYPE_MapTargetsResp 1024
#define NETMSGTYPE_GetTargetMappings 1025
#define NETMSGTYPE_GetTargetMappingsResp 1026
#define NETMSGTYPE_UnmapTarget 1027
#define NETMSGTYPE_UnmapTargetResp 1028
#define NETMSGTYPE_GenericDebug 1029
#define NETMSGTYPE_GenericDebugResp 1030
#define NETMSGTYPE_GetClientStats 1031
#define NETMSGTYPE_GetClientStatsResp 1032
#define NETMSGTYPE_RefreshCapacityPools 1035
#define NETMSGTYPE_StorageBenchControlMsg 1037
#define NETMSGTYPE_StorageBenchControlMsgResp 1038
#define NETMSGTYPE_RegisterNode 1039
#define NETMSGTYPE_RegisterNodeResp 1040
#define NETMSGTYPE_RegisterTarget 1041
#define NETMSGTYPE_RegisterTargetResp 1042
#define NETMSGTYPE_SetMirrorBuddyGroup 1045
#define NETMSGTYPE_SetMirrorBuddyGroupResp 1046
#define NETMSGTYPE_GetMirrorBuddyGroups 1047
#define NETMSGTYPE_GetMirrorBuddyGroupsResp 1048
#define NETMSGTYPE_GetTargetStates 1049
#define NETMSGTYPE_GetTargetStatesResp 1050
#define NETMSGTYPE_RefreshTargetStates 1051
#define NETMSGTYPE_GetStatesAndBuddyGroups 1053
#define NETMSGTYPE_GetStatesAndBuddyGroupsResp 1054
#define NETMSGTYPE_SetTargetConsistencyStates 1055
#define NETMSGTYPE_SetTargetConsistencyStatesResp 1056
#define NETMSGTYPE_ChangeTargetConsistencyStates 1057
#define NETMSGTYPE_ChangeTargetConsistencyStatesResp 1058
#define NETMSGTYPE_PublishCapacities 1059
#define NETMSGTYPE_RemoveBuddyGroup 1060
#define NETMSGTYPE_RemoveBuddyGroupResp 1061
#define NETMSGTYPE_GetTargetConsistencyStates 1062
#define NETMSGTYPE_GetTargetConsistencyStatesResp 1063
#define NETMSGTYPE_AddStoragePool 1064
#define NETMSGTYPE_AddStoragePoolResp 1065
#define NETMSGTYPE_GetStoragePools 1066
#define NETMSGTYPE_GetStoragePoolsResp 1067
#define NETMSGTYPE_ModifyStoragePool 1068
#define NETMSGTYPE_ModifyStoragePoolResp 1069
#define NETMSGTYPE_RefreshStoragePools 1070
#define NETMSGTYPE_RemoveStoragePool 1071
#define NETMSGTYPE_RemoveStoragePoolResp 1072
// storage messages
#define NETMSGTYPE_MkDir 2001
#define NETMSGTYPE_MkDirResp 2002
#define NETMSGTYPE_RmDir 2003
#define NETMSGTYPE_RmDirResp 2004
#define NETMSGTYPE_MkFile 2005
#define NETMSGTYPE_MkFileResp 2006
#define NETMSGTYPE_UnlinkFile 2007
#define NETMSGTYPE_UnlinkFileResp 2008
#define NETMSGTYPE_UnlinkLocalFile 2011
#define NETMSGTYPE_UnlinkLocalFileResp 2012
#define NETMSGTYPE_Stat 2015
#define NETMSGTYPE_StatResp 2016
#define NETMSGTYPE_GetChunkFileAttribs 2017
#define NETMSGTYPE_GetChunkFileAttribsResp 2018
#define NETMSGTYPE_TruncFile 2019
#define NETMSGTYPE_TruncFileResp 2020
#define NETMSGTYPE_TruncLocalFile 2021
#define NETMSGTYPE_TruncLocalFileResp 2022
#define NETMSGTYPE_Rename 2023
#define NETMSGTYPE_RenameResp 2024
#define NETMSGTYPE_SetAttr 2025
#define NETMSGTYPE_SetAttrResp 2026
#define NETMSGTYPE_ListDirFromOffset 2029
#define NETMSGTYPE_ListDirFromOffsetResp 2030
#define NETMSGTYPE_StatStoragePath 2031
#define NETMSGTYPE_StatStoragePathResp 2032
#define NETMSGTYPE_SetLocalAttr 2033
#define NETMSGTYPE_SetLocalAttrResp 2034
#define NETMSGTYPE_FindOwner 2035
#define NETMSGTYPE_FindOwnerResp 2036
#define NETMSGTYPE_MkLocalDir 2037
#define NETMSGTYPE_MkLocalDirResp 2038
#define NETMSGTYPE_RmLocalDir 2039
#define NETMSGTYPE_RmLocalDirResp 2040
#define NETMSGTYPE_MovingFileInsert 2041
#define NETMSGTYPE_MovingFileInsertResp 2042
#define NETMSGTYPE_MovingDirInsert 2043
#define NETMSGTYPE_MovingDirInsertResp 2044
#define NETMSGTYPE_GetEntryInfo 2045
#define NETMSGTYPE_GetEntryInfoResp 2046
#define NETMSGTYPE_SetDirPattern 2047
#define NETMSGTYPE_SetDirPatternResp 2048
#define NETMSGTYPE_GetHighResStats 2051
#define NETMSGTYPE_GetHighResStatsResp 2052
#define NETMSGTYPE_MkFileWithPattern 2053
#define NETMSGTYPE_MkFileWithPatternResp 2054
#define NETMSGTYPE_RefreshEntryInfo 2055
#define NETMSGTYPE_RefreshEntryInfoResp 2056
#define NETMSGTYPE_RmDirEntry 2057
#define NETMSGTYPE_RmDirEntryResp 2058
#define NETMSGTYPE_LookupIntent 2059
#define NETMSGTYPE_LookupIntentResp 2060
#define NETMSGTYPE_FindLinkOwner 2063
#define NETMSGTYPE_FindLinkOwnerResp 2064
#define NETMSGTYPE_MirrorMetadata 2067
#define NETMSGTYPE_MirrorMetadataResp 2068
#define NETMSGTYPE_SetMetadataMirroring 2069
#define NETMSGTYPE_SetMetadataMirroringResp 2070
#define NETMSGTYPE_Hardlink 2071
#define NETMSGTYPE_HardlinkResp 2072
#define NETMSGTYPE_SetQuota 2075
#define NETMSGTYPE_SetQuotaResp 2076
#define NETMSGTYPE_SetExceededQuota 2077
#define NETMSGTYPE_SetExceededQuotaResp 2078
#define NETMSGTYPE_RequestExceededQuota 2079
#define NETMSGTYPE_RequestExceededQuotaResp 2080
#define NETMSGTYPE_UpdateDirParent 2081
#define NETMSGTYPE_UpdateDirParentResp 2082
#define NETMSGTYPE_ResyncLocalFile 2083
#define NETMSGTYPE_ResyncLocalFileResp 2084
#define NETMSGTYPE_StartStorageTargetResync 2085
#define NETMSGTYPE_StartStorageTargetResyncResp 2086
#define NETMSGTYPE_StorageResyncStarted 2087
#define NETMSGTYPE_StorageResyncStartedResp 2088
#define NETMSGTYPE_ListChunkDirIncremental 2089
#define NETMSGTYPE_ListChunkDirIncrementalResp 2090
#define NETMSGTYPE_RmChunkPaths 2091
#define NETMSGTYPE_RmChunkPathsResp 2092
#define NETMSGTYPE_GetStorageResyncStats 2093
#define NETMSGTYPE_GetStorageResyncStatsResp 2094
#define NETMSGTYPE_SetLastBuddyCommOverride 2095
#define NETMSGTYPE_SetLastBuddyCommOverrideResp 2096
#define NETMSGTYPE_GetQuotaInfo 2097
#define NETMSGTYPE_GetQuotaInfoResp 2098
#define NETMSGTYPE_SetStorageTargetInfo 2099
#define NETMSGTYPE_SetStorageTargetInfoResp 2100
#define NETMSGTYPE_ListXAttr 2101
#define NETMSGTYPE_ListXAttrResp 2102
#define NETMSGTYPE_GetXAttr 2103
#define NETMSGTYPE_GetXAttrResp 2104
#define NETMSGTYPE_RemoveXAttr 2105
#define NETMSGTYPE_RemoveXAttrResp 2106
#define NETMSGTYPE_SetXAttr 2107
#define NETMSGTYPE_SetXAttrResp 2108
#define NETMSGTYPE_GetDefaultQuota 2109
#define NETMSGTYPE_GetDefaultQuotaResp 2110
#define NETMSGTYPE_SetDefaultQuota 2111
#define NETMSGTYPE_SetDefaultQuotaResp 2112
#define NETMSGTYPE_ResyncSessionStore 2113
#define NETMSGTYPE_ResyncSessionStoreResp 2114
#define NETMSGTYPE_ResyncRawInodes 2115
#define NETMSGTYPE_ResyncRawInodesResp 2116
#define NETMSGTYPE_GetMetaResyncStats 2117
#define NETMSGTYPE_GetMetaResyncStatsResp 2118
// session messages
#define NETMSGTYPE_OpenFile 3001
#define NETMSGTYPE_OpenFileResp 3002
#define NETMSGTYPE_CloseFile 3003
#define NETMSGTYPE_CloseFileResp 3004
#define NETMSGTYPE_OpenLocalFile 3005
#define NETMSGTYPE_OpenLocalFileResp 3006
#define NETMSGTYPE_CloseChunkFile 3007
#define NETMSGTYPE_CloseChunkFileResp 3008
#define NETMSGTYPE_WriteLocalFile 3009
#define NETMSGTYPE_WriteLocalFileResp 3010
#define NETMSGTYPE_FSyncLocalFile 3013
#define NETMSGTYPE_FSyncLocalFileResp 3014
#define NETMSGTYPE_ReadLocalFileV2 3019
#define NETMSGTYPE_RefreshSession 3021
#define NETMSGTYPE_RefreshSessionResp 3022
#define NETMSGTYPE_LockGranted 3023
#define NETMSGTYPE_FLockEntry 3025
#define NETMSGTYPE_FLockEntryResp 3026
#define NETMSGTYPE_FLockRange 3027
#define NETMSGTYPE_FLockRangeResp 3028
#define NETMSGTYPE_FLockAppend 3029
#define NETMSGTYPE_FLockAppendResp 3030
#define NETMSGTYPE_AckNotify 3031
#define NETMSGTYPE_AckNotifyResp 3032
#define NETMSGTYPE_BumpFileVersion 3033
#define NETMSGTYPE_BumpFileVersionResp 3034
#define NETMSGTYPE_GetFileVersion 3035
#define NETMSGTYPE_GetFileVersionResp 3036
// control messages
#define NETMSGTYPE_SetChannelDirect 4001
#define NETMSGTYPE_Ack 4003
#define NETMSGTYPE_Dummy 4005
#define NETMSGTYPE_AuthenticateChannel 4007
#define NETMSGTYPE_GenericResponse 4009
#define NETMSGTYPE_PeerInfo 4011
// helperd messages
#define NETMSGTYPE_Log 5001
#define NETMSGTYPE_LogResp 5002
#define NETMSGTYPE_GetHostByName 5003
#define NETMSGTYPE_GetHostByNameResp 5004
// mon messages
#define NETMSGTYPE_GetNodesFromRootMetaNode 6001
#define NETMSGTYPE_SendNodesList 6002
#define NETMSGTYPE_RequestMetaData 6003
#define NETMSGTYPE_RequestStorageData 6004
#define NETMSGTYPE_RequestMetaDataResp 6005
#define NETMSGTYPE_RequestStorageDataResp 6006
// fsck messages
#define NETMSGTYPE_RetrieveDirEntries 7001
#define NETMSGTYPE_RetrieveDirEntriesResp 7002
#define NETMSGTYPE_RetrieveInodes 7003
#define NETMSGTYPE_RetrieveInodesResp 7004
#define NETMSGTYPE_RetrieveChunks 7005
#define NETMSGTYPE_RetrieveChunksResp 7006
#define NETMSGTYPE_RetrieveFsIDs 7007
#define NETMSGTYPE_RetrieveFsIDsResp 7008
#define NETMSGTYPE_DeleteDirEntries 7009
#define NETMSGTYPE_DeleteDirEntriesResp 7010
#define NETMSGTYPE_CreateDefDirInodes 7011
#define NETMSGTYPE_CreateDefDirInodesResp 7012
#define NETMSGTYPE_FixInodeOwnersInDentry 7013
#define NETMSGTYPE_FixInodeOwnersInDentryResp 7014
#define NETMSGTYPE_FixInodeOwners 7015
#define NETMSGTYPE_FixInodeOwnersResp 7016
#define NETMSGTYPE_LinkToLostAndFound 7017
#define NETMSGTYPE_LinkToLostAndFoundResp 7018
#define NETMSGTYPE_DeleteChunks 7019
#define NETMSGTYPE_DeleteChunksResp 7020
#define NETMSGTYPE_CreateEmptyContDirs 7021
#define NETMSGTYPE_CreateEmptyContDirsResp 7022
#define NETMSGTYPE_UpdateFileAttribs 7023
#define NETMSGTYPE_UpdateFileAttribsResp 7024
#define NETMSGTYPE_UpdateDirAttribs 7025
#define NETMSGTYPE_UpdateDirAttribsResp 7026
#define NETMSGTYPE_RemoveInodes 7027
#define NETMSGTYPE_RemoveInodesResp 7028
#define NETMSGTYPE_RecreateFsIDs 7031
#define NETMSGTYPE_RecreateFsIDsResp 7032
#define NETMSGTYPE_RecreateDentries 7033
#define NETMSGTYPE_RecreateDentriesResp 7034
#define NETMSGTYPE_FsckModificationEvent 7035
#define NETMSGTYPE_FsckSetEventLogging 7036
#define NETMSGTYPE_FsckSetEventLoggingResp 7037
#define NETMSGTYPE_FetchFsckChunkList 7038
#define NETMSGTYPE_FetchFsckChunkListResp 7039
#define NETMSGTYPE_AdjustChunkPermissions 7040
#define NETMSGTYPE_AdjustChunkPermissionsResp 7041
#define NETMSGTYPE_MoveChunkFile 7042
#define NETMSGTYPE_MoveChunkFileResp 7043
#endif /*NETMESSAGETYPES_H_*/
| 52.498141 | 72 | 0.663362 |
854b4fc4b634a1dc2d2599a45a5a4f3aa2d6e982 | 355 | h | C | Wangscape/noise/module/codecs/InvertWrapperCodec.h | cheukyin699/Wangscape | b01cb310f97e33394c1c0fac23a7f40c34f632cf | [
"MIT"
] | 60 | 2016-12-30T03:18:34.000Z | 2022-02-15T21:43:59.000Z | Wangscape/noise/module/codecs/InvertWrapperCodec.h | cheukyin699/Wangscape | b01cb310f97e33394c1c0fac23a7f40c34f632cf | [
"MIT"
] | 149 | 2016-12-29T19:38:36.000Z | 2017-10-29T18:19:51.000Z | Wangscape/noise/module/codecs/InvertWrapperCodec.h | cheukyin699/Wangscape | b01cb310f97e33394c1c0fac23a7f40c34f632cf | [
"MIT"
] | 16 | 2016-12-31T06:09:42.000Z | 2021-09-10T05:34:51.000Z | #pragma once
#include <spotify/json.hpp>
#include <noise/noise.h>
#include "noise/module/Wrapper.h"
namespace spotify
{
namespace json
{
template<>
struct default_codec_t<noise::module::Wrapper<noise::module::Invert>>
{
using InvertWrapper = noise::module::Wrapper<noise::module::Invert>;
static codec::object_t<InvertWrapper> codec();
};
}
}
| 16.904762 | 72 | 0.726761 |
8fa91dadfe1c1c99b92b98f367d57f175d1ea1cc | 14,918 | h | C | panda/src/gobj/geomVertexColumn.h | ethanlindley/panda3d | 2bc35287d1af4e2c5d2f8a3c58d62d35446ca6f7 | [
"PHP-3.0",
"PHP-3.01"
] | 3 | 2020-01-02T08:43:36.000Z | 2020-07-05T08:59:02.000Z | panda/src/gobj/geomVertexColumn.h | ethanlindley/panda3d | 2bc35287d1af4e2c5d2f8a3c58d62d35446ca6f7 | [
"PHP-3.0",
"PHP-3.01"
] | null | null | null | panda/src/gobj/geomVertexColumn.h | ethanlindley/panda3d | 2bc35287d1af4e2c5d2f8a3c58d62d35446ca6f7 | [
"PHP-3.0",
"PHP-3.01"
] | 1 | 2020-03-11T17:38:45.000Z | 2020-03-11T17:38:45.000Z | /**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file geomVertexColumn.h
* @author drose
* @date 2005-03-06
*/
#ifndef GEOMVERTEXCOLUMN_H
#define GEOMVERTEXCOLUMN_H
#include "pandabase.h"
#include "geomEnums.h"
#include "internalName.h"
#include "pointerTo.h"
#include "luse.h"
class TypedWritable;
class BamWriter;
class BamReader;
class Datagram;
class DatagramIterator;
class GeomVertexReader;
class GeomVertexWriter;
/**
* This defines how a single column is interleaved within a vertex array
* stored within a Geom. The GeomVertexArrayFormat class maintains a list of
* these to completely define a particular array structure.
*/
class EXPCL_PANDA_GOBJ GeomVertexColumn : public GeomEnums {
private:
INLINE GeomVertexColumn();
PUBLISHED:
INLINE GeomVertexColumn(CPT_InternalName name, int num_components,
NumericType numeric_type, Contents contents,
int start, int column_alignment = 0,
int num_elements = 0, int element_stride = 0);
INLINE GeomVertexColumn(const GeomVertexColumn ©);
void operator = (const GeomVertexColumn ©);
INLINE ~GeomVertexColumn();
INLINE const InternalName *get_name() const;
INLINE int get_num_components() const;
INLINE int get_num_values() const;
INLINE int get_num_elements() const;
INLINE NumericType get_numeric_type() const;
INLINE Contents get_contents() const;
INLINE int get_start() const;
INLINE int get_column_alignment() const;
INLINE int get_element_stride() const;
INLINE int get_component_bytes() const;
INLINE int get_total_bytes() const;
INLINE bool has_homogeneous_coord() const;
INLINE bool overlaps_with(int start_byte, int num_bytes) const;
INLINE bool is_bytewise_equivalent(const GeomVertexColumn &other) const;
void set_name(InternalName *name);
void set_num_components(int num_components);
void set_numeric_type(NumericType numeric_type);
void set_contents(Contents contents);
void set_start(int start);
void set_column_alignment(int column_alignment);
void output(ostream &out) const;
public:
INLINE bool is_packed_argb() const;
INLINE bool is_uint8_rgba() const;
INLINE int compare_to(const GeomVertexColumn &other) const;
INLINE bool operator == (const GeomVertexColumn &other) const;
INLINE bool operator != (const GeomVertexColumn &other) const;
INLINE bool operator < (const GeomVertexColumn &other) const;
private:
class Packer;
void setup();
Packer *make_packer() const;
public:
void write_datagram(BamWriter *manager, Datagram &dg);
int complete_pointers(TypedWritable **plist, BamReader *manager);
void fillin(DatagramIterator &scan, BamReader *manager);
private:
CPT_InternalName _name;
int _num_components;
int _num_values;
int _num_elements;
NumericType _numeric_type;
Contents _contents;
int _start;
int _column_alignment;
int _element_stride;
int _component_bytes;
int _total_bytes;
Packer *_packer;
// This nested class provides the implementation for packing and unpacking
// data in a very general way, but also provides the hooks for implementing
// the common, very direct code paths (for instance, 3-component float32 to
// LVecBase3f) as quickly as possible.
class Packer : public MemoryBase {
public:
virtual ~Packer();
virtual float get_data1f(const unsigned char *pointer);
virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual double get_data1d(const unsigned char *pointer);
virtual const LVecBase2d &get_data2d(const unsigned char *pointer);
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
virtual const LVecBase4d &get_data4d(const unsigned char *pointer);
virtual int get_data1i(const unsigned char *pointer);
virtual const LVecBase2i &get_data2i(const unsigned char *pointer);
virtual const LVecBase3i &get_data3i(const unsigned char *pointer);
virtual const LVecBase4i &get_data4i(const unsigned char *pointer);
virtual void set_data1f(unsigned char *pointer, float data);
virtual void set_data2f(unsigned char *pointer, const LVecBase2f &data);
virtual void set_data3f(unsigned char *pointer, const LVecBase3f &data);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &data);
virtual void set_data1d(unsigned char *pointer, double data);
virtual void set_data2d(unsigned char *pointer, const LVecBase2d &data);
virtual void set_data3d(unsigned char *pointer, const LVecBase3d &data);
virtual void set_data4d(unsigned char *pointer, const LVecBase4d &data);
virtual void set_data1i(unsigned char *pointer, int data);
virtual void set_data2i(unsigned char *pointer, const LVecBase2i &data);
virtual void set_data3i(unsigned char *pointer, const LVecBase3i &data);
virtual void set_data4i(unsigned char *pointer, const LVecBase4i &data);
virtual const char *get_name() const {
return "Packer";
}
const GeomVertexColumn *_column;
LVecBase2f _v2;
LVecBase3f _v3;
LVecBase4f _v4;
LVecBase2d _v2d;
LVecBase3d _v3d;
LVecBase4d _v4d;
LVecBase2i _v2i;
LVecBase3i _v3i;
LVecBase4i _v4i;
unsigned int _a, _b, _c, _d;
};
// This is a specialization on the generic Packer that handles points, which
// are special because the fourth component, if not present in the data, is
// implicitly 1.0; and if it is present, then any three-component or smaller
// return is implicitly divided by the fourth component.
class Packer_point : public Packer {
public:
virtual float get_data1f(const unsigned char *pointer);
virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual double get_data1d(const unsigned char *pointer);
virtual const LVecBase2d &get_data2d(const unsigned char *pointer);
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
virtual const LVecBase4d &get_data4d(const unsigned char *pointer);
virtual void set_data1f(unsigned char *pointer, float data);
virtual void set_data2f(unsigned char *pointer, const LVecBase2f &data);
virtual void set_data3f(unsigned char *pointer, const LVecBase3f &data);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &data);
virtual void set_data1d(unsigned char *pointer, double data);
virtual void set_data2d(unsigned char *pointer, const LVecBase2d &data);
virtual void set_data3d(unsigned char *pointer, const LVecBase3d &data);
virtual void set_data4d(unsigned char *pointer, const LVecBase4d &data);
virtual const char *get_name() const {
return "Packer_point";
}
};
// This is similar to Packer_point, in that the fourth component is
// implicitly 1.0 if it is not present in the data, but we never divide by
// alpha. It also transforms integer colors to the 0-1 range.
class Packer_color : public Packer {
public:
virtual float get_data1f(const unsigned char *pointer);
virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual double get_data1d(const unsigned char *pointer);
virtual const LVecBase2d &get_data2d(const unsigned char *pointer);
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
virtual const LVecBase4d &get_data4d(const unsigned char *pointer);
virtual void set_data1f(unsigned char *pointer, float data);
virtual void set_data2f(unsigned char *pointer, const LVecBase2f &data);
virtual void set_data3f(unsigned char *pointer, const LVecBase3f &data);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &data);
virtual void set_data1d(unsigned char *pointer, double data);
virtual void set_data2d(unsigned char *pointer, const LVecBase2d &data);
virtual void set_data3d(unsigned char *pointer, const LVecBase3d &data);
virtual void set_data4d(unsigned char *pointer, const LVecBase4d &data);
virtual const char *get_name() const {
return "Packer_color";
}
};
// These are the specializations on the generic Packer that handle the
// direct code paths.
class Packer_float32_3 : public Packer {
public:
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
virtual void set_data3f(unsigned char *pointer, const LVecBase3f &value);
virtual const char *get_name() const {
return "Packer_float32_3";
}
};
class Packer_point_float32_2 : public Packer_point {
public:
virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
virtual void set_data2f(unsigned char *pointer, const LVecBase2f &value);
virtual const char *get_name() const {
return "Packer_point_float32_2";
}
};
class Packer_point_float32_3 : public Packer_point {
public:
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
virtual void set_data3f(unsigned char *pointer, const LVecBase3f &value);
virtual const char *get_name() const {
return "Packer_point_float32_3";
}
};
class Packer_point_float32_4 : public Packer_point {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
virtual const char *get_name() const {
return "Packer_point_float32_4";
}
};
class Packer_nativefloat_3 : public Packer_float32_3 {
public:
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_nativefloat_3";
}
};
class Packer_point_nativefloat_2 : public Packer_point_float32_2 {
public:
virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_nativefloat_2";
}
};
class Packer_point_nativefloat_3 : public Packer_point_float32_3 {
public:
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_point_nativefloat_3";
}
};
class Packer_point_nativefloat_4 : public Packer_point_float32_4 {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_point_nativefloat_4";
}
};
class Packer_float64_3 : public Packer {
public:
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
virtual void set_data3d(unsigned char *pointer, const LVecBase3d &value);
virtual const char *get_name() const {
return "Packer_float64_3";
}
};
class Packer_point_float64_2 : public Packer_point {
public:
virtual const LVecBase2d &get_data2d(const unsigned char *pointer);
virtual void set_data2d(unsigned char *pointer, const LVecBase2d &value);
virtual const char *get_name() const {
return "Packer_point_float64_2";
}
};
class Packer_point_float64_3 : public Packer_point {
public:
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
virtual void set_data3d(unsigned char *pointer, const LVecBase3d &value);
virtual const char *get_name() const {
return "Packer_point_float64_3";
}
};
class Packer_point_float64_4 : public Packer_point {
public:
virtual const LVecBase4d &get_data4d(const unsigned char *pointer);
virtual void set_data4d(unsigned char *pointer, const LVecBase4d &value);
virtual const char *get_name() const {
return "Packer_point_float64_4";
}
};
class Packer_nativedouble_3 FINAL : public Packer_float64_3 {
public:
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_nativedouble_3";
}
};
class Packer_point_nativedouble_2 FINAL : public Packer_point_float64_2 {
public:
virtual const LVecBase2d &get_data2d(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_nativedouble_2";
}
};
class Packer_point_nativedouble_3 FINAL : public Packer_point_float64_3 {
public:
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_point_nativedouble_3";
}
};
class Packer_point_nativedouble_4 : public Packer_point_float64_4 {
public:
virtual const LVecBase4d &get_data4d(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_point_nativedouble_4";
}
};
class Packer_argb_packed FINAL : public Packer_color {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
virtual const char *get_name() const {
return "Packer_argb_packed";
}
};
class Packer_rgba_uint8_4 FINAL : public Packer_color {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
virtual const char *get_name() const {
return "Packer_rgba_uint8_4";
}
};
class Packer_rgba_float32_4 : public Packer_color {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
virtual const char *get_name() const {
return "Packer_rgba_float32_4";
}
};
class Packer_rgba_nativefloat_4 FINAL : public Packer_rgba_float32_4 {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual const char *get_name() const {
return "Packer_rgba_nativefloat_4";
}
};
class Packer_uint16_1 FINAL : public Packer {
public:
virtual int get_data1i(const unsigned char *pointer);
virtual void set_data1i(unsigned char *pointer, int value);
virtual const char *get_name() const {
return "Packer_uint16_1";
}
};
friend class GeomVertexArrayFormat;
friend class GeomVertexData;
friend class GeomVertexReader;
friend class GeomVertexWriter;
};
INLINE ostream &operator << (ostream &out, const GeomVertexColumn &obj);
#include "geomVertexColumn.I"
#endif
| 33.827664 | 78 | 0.737632 |
28e9990080f4d301b9dc05a7bc2bb091b8270e30 | 9,906 | h | C | src/utils/lua_utils.h | maxdebayser/SelfPortra | f2817e19d4e00d7a18075b8d876fc710390821eb | [
"MIT"
] | 5 | 2015-03-27T15:57:19.000Z | 2021-02-07T23:42:45.000Z | src/utils/lua_utils.h | maxdebayser/SelfPortra | f2817e19d4e00d7a18075b8d876fc710390821eb | [
"MIT"
] | null | null | null | src/utils/lua_utils.h | maxdebayser/SelfPortra | f2817e19d4e00d7a18075b8d876fc710390821eb | [
"MIT"
] | 2 | 2015-04-27T04:19:42.000Z | 2016-11-25T18:36:59.000Z | /******************************************************************************
* Copyright (C) 2012-2014 Maximilien de Bayser
*
* SelfPortrait API - http://github.com/maxdebayser/SelfPortrait
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************/
#ifndef LUA_UTILS_H
#define LUA_UTILS_H
#include <lua.hpp>
#include <string>
#include <tuple>
#include <list>
#include <map>
#include <unordered_map>
#include <vector>
#include <type_traits>
#include <stdexcept>
namespace LuaUtils {
bool isudata (lua_State *L, int ud, const char *tname);
void printType(lua_State* L, int i);
int stackDump(lua_State *L);
int pushTraceBack(lua_State *L);
void removeTraceBack(lua_State* L, int errIndex);
struct popper {
popper(lua_State* L, int size = 1) : m_L(L), m_size(size) {}
~popper() { if (m_size > 0) lua_pop(m_L, m_size); }
private:
lua_State* m_L;
int m_size;
};
template<typename T>
struct LuaValue;
template<class T>
struct LuaInteger {
static_assert( std::is_integral<T>::value, "type must be integral" );
static T getStackValue(lua_State* L, int pos) {
return luaL_checkinteger(L, pos);
}
static void pushValue(lua_State* L, T value) {
lua_pushinteger(L, value);
}
static int size() { return 1; }
};
template<> struct LuaValue<int> : public LuaInteger<int> {};
template<> struct LuaValue<char> : public LuaInteger<char> {};
template<> struct LuaValue<short> : public LuaInteger<short> {};
template<> struct LuaValue<long> : public LuaInteger<long> {};
template<> struct LuaValue<long long> : public LuaInteger<long long> {};
template<> struct LuaValue<unsigned int> : public LuaInteger<unsigned int> {};
template<> struct LuaValue<unsigned char> : public LuaInteger<unsigned char> {};
template<> struct LuaValue<unsigned short> : public LuaInteger<unsigned short> {};
template<> struct LuaValue<unsigned long> : public LuaInteger<unsigned long> {};
template<> struct LuaValue<unsigned long long> : public LuaInteger<unsigned long long> {};
template<class T> struct LuaFloatingPoint {
static_assert( std::is_floating_point<T>::value, "Type must be floating point number");
static T getStackValue(lua_State* L, int pos) {
return luaL_checknumber(L, pos);
}
static void pushValue(lua_State* L, T value) {
lua_pushnumber(L, value);
}
static int size() { return 1; }
};
template<> struct LuaValue<double> : public LuaFloatingPoint<double> {};
template<> struct LuaValue<long double> : public LuaFloatingPoint<long double> {};
template<> struct LuaValue<float> : public LuaFloatingPoint<float> {};
template<> struct LuaValue<bool> {
static bool getStackValue(lua_State* L, int pos) {
luaL_checktype(L, pos, LUA_TBOOLEAN);
return lua_toboolean(L, pos);
}
static void pushValue(lua_State* L, bool value) {
lua_pushboolean(L, value);
}
static int size() { return 1; }
};
template<> struct LuaValue<std::string> {
static std::string getStackValue(lua_State* L, int pos) {
return luaL_checkstring(L, pos);
}
static void pushValue(lua_State* L, const std::string& value) {
lua_pushstring(L, value.c_str());
}
static int size() { return 1; }
};
template<> struct LuaValue<const char*> {
static void pushValue(lua_State* L, const char* value) {
lua_pushstring(L, value);
}
static int size() { return 1; }
};
struct LuaNil {};
template<> struct LuaValue<LuaNil> {
static LuaNil getStackValue(lua_State* L, int pos) {
luaL_checktype(L, pos, LUA_TNIL);
return LuaNil();
}
static void pushValue(lua_State* L, LuaNil) {
lua_pushnil(L);
}
static int size() { return 1; }
};
template<> struct LuaValue<void> {
static void getStackValue(lua_State* L, int pos) {}
static int size() { return 0; }
};
template<class... T> struct LuaValue<std::tuple<T...> > {
template<class Tuple, int I, int N>
struct helper {
static void pushValue(lua_State* L, const Tuple& tuple) {
LuaValue< typename std::tuple_element< I, Tuple >::type >::pushValue(L, std::get<I>(tuple));
helper<Tuple, I+1, N>::pushValue(L, tuple);
}
static void getValue(lua_State* L, Tuple& tuple, int pos) {
std::get<I>(tuple) = LuaValue< typename std::tuple_element<I, Tuple>::type>::getStackValue(L, pos);
helper<Tuple, I+1, N>::getValue(L, tuple, ++pos);
}
};
template<class Tuple, int N>
struct helper<Tuple, N, N> {
static void pushValue(lua_State*, const Tuple&) {}
static void getValue(lua_State*, Tuple&, int) {}
};
typedef std::tuple<T...> TType;
static TType getStackValue(lua_State* L, int pos) {
TType ret;
helper<TType, 0, std::tuple_size<TType>::value>::getValue(L, ret, pos-size()+1);
return ret;
}
static void pushValue(lua_State* L, const TType& tuple) {
helper<TType, 0, std::tuple_size<TType>::value>::pushValue(L, tuple);
}
static int size() { return std::tuple_size<TType>::value; }
};
template<class C> struct LuaCollection {
typedef typename C::value_type value_type;
static C getStackValue(lua_State* L, int pos) {
C ret;
luaL_checktype(L, pos, LUA_TTABLE);
#ifdef LUA51
const int size = lua_objlen(L, pos);
#else
const int size = lua_rawlen(L, pos);
#endif
for (int i = 1; i <= size; ++i) {
lua_rawgeti(L, pos, i);
ret.emplace_back(LuaValue<value_type>::getStackValue(L, -1));
lua_pop(L, 1);
}
return std::move(ret);
}
static void pushValue(lua_State* L, const C& list) {
lua_createtable(L, list.size(), 0);
int i = 1;
for (const value_type& el: list) {
LuaValue<value_type>::pushValue(L, el);
lua_rawseti(L, -2, i++);
}
}
static int size() { return 1; }
};
template<class T> struct LuaValue<std::list<T>> : public LuaCollection<std::list<T>> {};
template<class T> struct LuaValue<std::vector<T>> : public LuaCollection<std::vector<T>> {};
template<class M> struct LuaAssociativeArray {
typedef typename M::key_type key_type;
typedef typename M::mapped_type mapped_type;
static M getStackValue(lua_State* L, int pos) {
const int ppos = (pos < 0) ? lua_gettop(L) + pos + 1 : pos;
luaL_checktype(L, ppos, LUA_TTABLE);
M ret;
lua_pushnil(L);
while (lua_next(L, ppos) != 0) {
ret[LuaValue<key_type>::getStackValue(L, -2)]
= LuaValue<mapped_type>::getStackValue(L, -1);
lua_pop(L, 1);
}
return std::move(ret);
}
static void pushValue(lua_State* L, const M& map) {
lua_createtable(L, 0, map.size());
for (auto el: map) {
LuaValue<key_type>::pushValue(L, el.first);
LuaValue<mapped_type>::pushValue(L, el.second);
lua_settable(L, -3);
}
}
static int size() { return 1; }
};
template<class K, class V> struct LuaValue<std::map<K,V>> : public LuaAssociativeArray<std::map<K,V>> {};
template<class K, class V> struct LuaValue<std::unordered_map<K,V>> : public LuaAssociativeArray<std::unordered_map<K,V>> {};
inline int pushArgs(lua_State* L) {
return 0;
}
template<class H, class... T>
inline int pushArgs(lua_State* L, const H& h, const T&... t) {
int size = LuaValue<H>::size();
LuaValue<H>::pushValue(L, h);
return size + pushArgs(L, t...);
}
template<class R, class... Args>
R callFuncPriv(lua_State* L, const std::string& name, const Args... args) {
const int funcPos = lua_gettop(L);
luaL_checktype(L, funcPos, LUA_TFUNCTION);
const int errIndex = LuaUtils::pushTraceBack(L);
lua_pushvalue(L, funcPos);
const int size = pushArgs(L, args...);
if (lua_pcall(L, size, LuaValue<R>::size(), errIndex) != 0) {
lua_pushfstring(L, "Error running function %s:\n", name.c_str());
lua_insert(L, -2);
lua_concat(L, 2);
lua_error(L);
}
popper p(L, LuaValue<R>::size()+1+(errIndex != 0));
return LuaValue<R>::getStackValue(L, -1);
}
template<class R, class... Args>
R callFunc(lua_State* L, const std::string& name, const Args... args) {
lua_getglobal(L, name.c_str());
return callFuncPriv<R, Args...>(L, name, args...);
}
template<class R, class... Args>
R callStackedFunc(lua_State* L, const Args... args) {
return callFuncPriv<R, Args...>(L, "anonymous", args...);
}
struct LuaStateHolder {
explicit LuaStateHolder(lua_State* L, const std::string& addLuaPath = "", const std::string& addCPath = "");
LuaStateHolder(const std::string& addLuaPath = "", const std::string& addCPath = "");
LuaStateHolder(const LuaStateHolder&) = delete;
LuaStateHolder(LuaStateHolder&& that) : m_L(that.m_L) { that.m_L = nullptr; }
~LuaStateHolder() {
if (m_L != nullptr) {
lua_close(m_L);
}
}
operator lua_State*() { return m_L; }
private:
lua_State* m_L = nullptr;
};
}
#endif /* LUA_UTILS_H */
| 32.372549 | 126 | 0.657985 |
3a7ef9db39583a563543f8ef9b7f1ba4c519bcab | 7,332 | c | C | keyboards/lets_split/keymaps/heartrobotninja/keymap.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | keyboards/lets_split/keymaps/heartrobotninja/keymap.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | keyboards/lets_split/keymaps/heartrobotninja/keymap.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | #include QMK_KEYBOARD_H
extern keymap_config_t keymap_config;
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _COLE 0
#define _LOWER 1
#define _RAISE 2
#define _AUX 16
/* Layers */
enum
{
COLE = 0,
LOWER, // right hand 10 key.
RAISE, // left hand Fn, right hand symbols.
AUX,
};
/* Tap Dancery */
enum
{
TD_BTK,
TD_TDE,
TD_LPRN,
TD_RPRN,
TD_MIN,
TD_USC,
};
bool time_travel = false;
// Fillers to make layering more clear
#define ____ KC_TRNS
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Colemak
* ,-----------------------------------------------------------------------------------.
* | ' " `| Q | W | F | P | G | J | L | U | Y | = + | ~ ; :|
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | ( [ {| A | R | S | T | D | H | N | E | I | O | ) ] }|
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | - , <| Z | X | C | V | B | K | M | ? | | | ^ | _ . >|
* |------+------+------+------+------+------+------+------+------+------+------+------|
* |Lower |Raise | Ctrl | Alt | Bksp | Spc |Enter |LShft | ESC | < | v | > |
* `-----------------------------------------------------------------------------------'
*/
[_COLE] = LAYOUT(
TD(TD_BTK), KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_EQL, TD(TD_TDE),
TD(TD_LPRN), KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, TD(TD_RPRN),
TD(TD_MIN), KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_SLSH, KC_BSLS, KC_UP, TD(TD_USC),
LOWER, RAISE, OSM(MOD_LCTL), OSM(MOD_LALT), KC_SPC, KC_BSPC, KC_ENT, OSM(MOD_LSFT), KC_ESC, KC_LEFT, KC_DOWN, KC_RGHT),
/* Lower
* ,-----------------------------------------------------------------------------------.
* | ---- | ---- | ---- | ---- | ---- | ---- | 7 | 8 | 9 | * | / | ^ |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | ---- | ---- | ---- | ---- | ---- | ---- | 4 | 5 | 6 | + | - | ---- |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | ---- | ---- | ---- | ---- | ---- | ---- | 1 | 2 | 3 | = | ---- | ---- |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | ---- | ---- | ---- | ---- | ---- | ---- | ---- | 0 | . | ---- | ---- | ---- |
* `-----------------------------------------------------------------------------------'
*/
[_LOWER] = LAYOUT(
____, ____, ____, ____, ____, ____, KC_7, KC_8, KC_9, KC_PAST, KC_PSLS, KC_CIRC,
____, ____, ____, ____, ____, ____, KC_4, KC_5, KC_6, KC_PPLS, KC_PMNS, ____,
____, ____, ____, ____, ____, ____, KC_1, KC_2, KC_3, KC_PEQL, ____, ____,
____, ____, ____, ____, ____, ____, ____, KC_0, KC_MNXT, ____, ____, ____),
/* Raise
* ,-----------------------------------------------------------------------------------.
* | F1 | F2 | F3 | F4 | F5 | F6 | ! | @ | # | $ | % | ` ~ |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | F7 | F8 | F9 | F10 | F11 | F12 | ^ | & | * | ( | ) | - _ |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | ____ | ____ | ____ | ____ | ____ | ____ | [ { | ] } | \ | | ; : | ' " | = + |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | ____ | ____ | ____ | ____ | ____ | ____ | ____ | ____ | ____ | , < | . > | / ? |
* `-----------------------------------------------------------------------------------'
*/
[_RAISE] = LAYOUT(
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_GRV,
KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_MINS,
KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_LBRC, KC_RBRC, KC_BSLS, KC_SCLN, KC_QUOT, KC_EQL,
____, ____, ____, ____, ____, ____, ____, ____, ____, KC_COMM, KC_DOT, KC_SLSH),
/* Adjust (Lower + Raise)
* ,-----------------------------------------------------------------------------------.
* | Reset| ____ | ____ | ____ | ____ | ____ | ____ | LOCK | ____ | ____ | ____ | VUP |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | ____ | ____ | RUN | ____ | ____ | ____ | ____ | ____ | ____ | ____ | ____ | VDWN |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | ____ | ____ | ____ | ____ | ____ | ____ | ____ | ____ | ____ | ____ | PGUP | MUTE |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | ____ | ____ | ____ | ____ | ____ | ____ | ____ | ____ | ____ | HOME | PGDN | END |
* `-----------------------------------------------------------------------------------'
*/
[_AUX] = LAYOUT(
RESET, ____, ____, ____, ____, ____, ____, LGUI(KC_L), ____, ____, ____, KC_VOLU,
____, ____, LGUI(KC_R), ____, ____, ____, ____, ____, ____, ____, ____, KC_VOLD,
____, ____, ____, ____, ____, ____, ____, ____, ____, ____, KC_PGUP, KC_MUTE,
____, ____, ____, ____, KC_TAB, KC_DEL, ____, ____, ____, KC_HOME, KC_PGDOWN, KC_END)
};
qk_tap_dance_action_t tap_dance_actions[] = {
[TD_BTK] = ACTION_TAP_DANCE_DOUBLE(KC_QUOT, KC_GRV),
[TD_TDE] = ACTION_TAP_DANCE_DOUBLE(KC_SCLN, KC_TILD),
[TD_LPRN] = ACTION_TAP_DANCE_DOUBLE(KC_LBRC, KC_LPRN),
[TD_RPRN] = ACTION_TAP_DANCE_DOUBLE(KC_RBRC, KC_RPRN),
[TD_MIN] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_MINS),
[TD_USC] = ACTION_TAP_DANCE_DOUBLE(KC_DOT, KC_UNDS)};
void persistent_default_layer_set(uint16_t default_layer)
{
eeconfig_update_default_layer(default_layer);
default_layer_set(default_layer);
};
void matrix_scan_user(void){};
void matrix_init_user(void){};
bool process_record_user(uint16_t keycode, keyrecord_t *record)
{
switch (keycode)
{
case COLE:
if (record->event.pressed)
{
persistent_default_layer_set(1UL << _COLE);
}
return false;
break;
case LOWER:
if (record->event.pressed)
{
layer_on(_LOWER);
update_tri_layer(_LOWER, _RAISE, _AUX);
}
else
{
layer_off(_LOWER);
update_tri_layer(_LOWER, _RAISE, _AUX);
}
return false;
break;
case RAISE:
if (record->event.pressed)
{
layer_on(_RAISE);
update_tri_layer(_LOWER, _RAISE, _AUX);
}
else
{
layer_off(_RAISE);
update_tri_layer(_LOWER, _RAISE, _AUX);
}
return false;
break;
case AUX:
if (record->event.pressed)
{
layer_on(_AUX);
}
else
{
layer_off(_AUX);
}
return false;
break;
}
return true;
}
| 40.508287 | 131 | 0.40521 |
580fd082e51a5417f05e0db26555a6852d5c6fee | 128 | c | C | Challenges/Questions/chal_q_0011/snippet3.c | saucec0de/sifu | 7924844e1737c7634016c677237bccd7e7651818 | [
"MIT"
] | 5 | 2021-03-26T08:19:43.000Z | 2021-12-18T18:04:04.000Z | Challenges/Questions/chal_q_0011/snippet3.c | saucec0de/sifu | 7924844e1737c7634016c677237bccd7e7651818 | [
"MIT"
] | null | null | null | Challenges/Questions/chal_q_0011/snippet3.c | saucec0de/sifu | 7924844e1737c7634016c677237bccd7e7651818 | [
"MIT"
] | null | null | null | int get_sum_of_squares(int x) {
int sum = 0;
for (int i = 0; i < x; i++) {
sum += i*i;
}
return sum;
}
| 14.222222 | 33 | 0.445313 |
55a41102dd16740fa781b09469b08e2b201ebd7e | 21,497 | h | C | source/D2Common/include/Units/Units.h | eezstreet/D2MOO | 28a30aecc69bf43c80e6757a94d533fb37634b68 | [
"MIT"
] | null | null | null | source/D2Common/include/Units/Units.h | eezstreet/D2MOO | 28a30aecc69bf43c80e6757a94d533fb37634b68 | [
"MIT"
] | null | null | null | source/D2Common/include/Units/Units.h | eezstreet/D2MOO | 28a30aecc69bf43c80e6757a94d533fb37634b68 | [
"MIT"
] | null | null | null | #pragma once
#include "CommonDefinitions.h"
#include "Item.h"
#include "Missile.h"
#include "Monster.h"
#include "Object.h"
#include "Player.h"
#pragma pack(1)
enum D2C_UnitTypes
{
UNIT_PLAYER,
UNIT_MONSTER,
UNIT_OBJECT,
UNIT_MISSILE,
UNIT_ITEM,
UNIT_TILE,
};
enum D2C_UnitFlags
{
UNITFLAG_DOUPDATE = 0x00000001, //tells to update the unit
UNITFLAG_TARGETABLE = 0x00000002, //whenever the unit can be selected or not
UNITFLAG_CANBEATTACKED = 0x00000004, //whenever the unit can be attacked
UNITFLAG_ISVALIDTARGET = 0x00000008, //used to check if unit is a valid target
UNITFLAG_INITSEEDSET = 0x00000010, //tells whenever the unit seed has been initialized
UNITFLAG_DRAWSHADOW = 0x00000020, //tells whenver to draw a shadow or not (client only)
UNITFLAG_SKSRVDOFUNC = 0x00000040, //set when skill srvdofunc is executed
UNITFLAG_OBJPREOPERATE = 0x00000080, //unknown, used by objects with pre-operate disabled
UNITFLAG_HASTXTMSG = 0x00000100, //whenever this unit has a text message attached to it
UNITFLAG_ISMERC = 0x00000200, //is mercenary unit
UNITFLAG_HASEVENTSOUND = 0x00000400, //does this unit have an event-sound attached to it (server)
UNITFLAG_SUMMONER = 0x00000800, //set for the summoner only
UNITFLAG_SENDREFRESHMSG = 0x00001000, //used by items to send a refresh message when it drops on ground
UNITFLAG_ISLINKREFRESHMSG = 0x00002000, //tells whenever this unit is linked to an update message chain
UNITFLAG_SQGFXCHANGE = 0x00004000, //tells whenever to load new anim for skill SQ
UNITFLAG_UPGRLIFENHITCLASS = 0x00008000, //updates life% and hitclass on client
UNITFLAG_ISDEAD = 0x00010000, //unit is dead
UNITFLAG_NOTC = 0x00020000, //disables treasureclass drops
UNITFLAG_MONMODEISCHANGING = 0x00080000, //set when monmode changes
UNITFLAG_PREDRAW = 0x00100000, //pre-draw this unit (like floor tiles, client only)
UNITFLAG_ISASYNC = 0x00200000, //is async unit (critters)
UNITFLAG_ISCLIENTUNIT = 0x00400000, //is client unit
UNITFLAG_ISINIT = 0x01000000, //set when unit has been initialized
UNITFLAG_ISRESURRECT = 0x02000000, //set for resurrected units and items on floor
UNITFLAG_NOXP = 0x04000000, //no xp gain from killing this unit
UNITFLAG_AUTOMAP = 0x10000000, //automap stuff
UNITFLAG_AUTOMAP2 = 0x20000000, //automap stuff
UNITFLAG_PETIGNORE = 0x40000000, //ignored by pets
UNITFLAG_ISREVIVE = 0x80000000 //is revived monster
};
enum D2C_UnitFlagsEx
{
UNITFLAGEX_HASINV = 0x00000001, //unit has inventory attached to it
UNITFLAGEX_UPDATEINV = 0x00000002, //tells to update inventory content
UNITFLAGEX_ISVENDORITEM = 0x00000004, //set for vendor shop items
UNITFLAGEX_ISSHAPESHIFTED = 0x00000008, //unit is shapeshifted
UNITFLAGEX_ITEMINIT = 0x00000010, //set for items, related to init
UNITFLAGEX_ISINLOS = 0x00000080, //unit is in client's line of sight
UNITFLAGEX_HASBEENDELETED = 0x00000100, //unit has been deleted but not free'd yet
UNITFLAGEX_STOREOWNERINFO = 0x00000400, //unit stores info about owner
UNITFLAGEX_ISCORPSE = 0x00001000, //unit is a corpse (use UNITFLAG_ISDEAD instead)
UNITFLAGEX_TELEPORTED = 0x00010000, //unit has been teleported, needs resync
UNITFLAGEX_STORELASTATTACKER = 0x00020000, //unit stores info about last attacker
UNITFLAGEX_NODRAW = 0x00040000, //don't draw this unit
UNITFLAGEX_ISEXPANSION = 0x02000000, //is expansion unit
UNITFLAGEX_SERVERUNIT = 0x04000000 //is server-side unit
};
//TODO: Redo Header defs when .cpp is done
struct D2UnitStrc
{
uint32_t dwUnitType; //0x00
int32_t dwClassId; //0x04
void* pMemoryPool; //0x08
uint32_t dwUnitId; //0x0C
union //0x10
{
uint32_t dwAnimMode; //Player, Monster, Object, Items
uint32_t dwCollideType; //Missiles
};
union //0x14
{
D2PlayerDataStrc* pPlayerData;
D2ItemDataStrc* pItemData;
D2MonsterDataStrc* pMonsterData;
D2ObjectDataStrc* pObjectData;
D2MissileDataStrc* pMissileData;
};
uint8_t nAct; //0x18
uint8_t unk0x19[3]; //0x19
D2DrlgActStrc* pDrlgAct; //0x1C
D2SeedStrc pSeed; //0x20
uint32_t dwInitSeed; //0x28
union //0x2C
{
D2DynamicPathStrc* pDynamicPath;
D2StaticPathStrc* pStaticPath;
};
D2AnimSeqStrc* pAnimSeq; //0x30
uint32_t dwSeqFrameCount; //0x34
uint32_t dwSeqFrame; //0x38
uint32_t dwAnimSpeed; //0x3C
uint32_t dwSeqMode; //0x40
uint32_t dwGFXcurrentFrame; //0x44
uint32_t dwFrameCount; //0x48
uint16_t wAnimSpeed; //0x4C
uint8_t nActionFrame; //0x4E
uint8_t unk0x4F; //0x4F
D2AnimDataRecordStrc* pAnimData; //0x50
D2GfxDataStrc* pGfxData; //0x54
D2GfxDataStrc* pGfxDataCopy; //0x58
D2StatListExStrc* pStatListEx; //0x5C
D2InventoryStrc* pInventory; //0x60
union
{
struct //Server Unit
{
uint32_t dwInteractGUID; //0x064
uint32_t dwInteractType; //0x068
uint16_t nInteract; //0x06C
uint16_t nUpdateType; //0x06E
D2UnitStrc* pUpdateUnit; //0x070
D2QuestChainStrc* pQuestEventList; //0x074
BOOL bSparkChest; //0x078
void* pTimerParams; //0x07C
D2GameStrc* pGame; //0x080
uint32_t __084[3]; //0x084
D2TimerStrc* pSrvTimerList; //0x090
};
struct //Client Unit
{
D2GfxLightStrc* pLight; //0x064
uint32_t dwStartLight; //0x068
int32_t nPaletteIndex; //0x06C
BOOL bUnitSfx; //0x070
uint32_t dwSfxMode; //0x074
void* pUnitSfxData; //0x078
uint32_t dwSfxTicks; //0x07C
uint32_t dwSfxAsyncTicks; //0x080
uint32_t dwSfxStepTicks; //0x084
BOOL bHasActiveSound; //0x088
uint16_t nLastClickX; //0x08C
uint16_t nLastClickY; //0x08E
D2EventListStrc* pCltTimerList; //0x090
};
};
uint32_t dwOwnerType; //0x94
uint32_t dwOwnerGUID; //0x98
uint32_t dwKillerType; //0x09C
uint32_t dwKillerGUID; //0x0A0
D2HoverTextStrc* pHoverText; //0xA4
D2SkillListStrc* pSkills; //0xA8
D2CombatStrc* pCombat; //0xAC
uint32_t dwLastHitClass; //0xB0
uint32_t unk0xB4; //0xB4
uint32_t dwDropItemCode; //0xB8
uint32_t unk0xBC[2]; //0xBC
uint32_t dwFlags; //0xC4
uint32_t dwFlagEx; //0xC8
void* pQuestData; //0xCC
//union //0xCC
//{
// D2QuestSrvStrc* pSrvQuestData; //Server pUnit
// D2QuestCltStrc* pCltQuestData; //Client pUnit
//};
uint32_t dwNodeIndex; //0xD0
uint32_t dwTickCount; //0xD4
union //0xD8
{
uint32_t dwSrvTickCount; //Server pUnit
D2PacketListStrc* pPacketList; //Client pUnit
};
D2TimerStrc* pTimer; //0xDC
D2UnitStrc* pChangeNextUnit; //0xE0
D2UnitStrc* pListNext; //0xE4
D2UnitStrc* pRoomNext; //0xE8
void* pMsgFirst; //0xEC
void* pMsgLast; //0xF0
};
#pragma pack()
//D2Common.0x6FDBD520 (#10457)
uint8_t __stdcall UNITS_GetDirection(D2UnitStrc* pUnit);
//D2Common.0x6FDBD570 (#10320)
D2SkillStrc* __stdcall UNITS_GetStartSkill(D2UnitStrc* pUnit);
//D2Common.0x6FDBD5B0 (#10321)
D2SkillStrc* __stdcall UNITS_GetGetLeftSkill(D2UnitStrc* pUnit);
//D2Common.0x6FDBD5F0 (#10322)
D2SkillStrc* __stdcall UNITS_GetRightSkill(D2UnitStrc* pUnit);
//D2Common.0x6FDBD630 (#10324)
void __stdcall UNITS_SetUsedSkill(D2UnitStrc* pUnit, D2SkillStrc* pUsedSkill);
//D2Common.0x6FDBD670 (#10323)
D2SkillStrc* __stdcall UNITS_GetUsedSkill(D2UnitStrc* pUnit);
//D2Common.0x6FDBD6B0 (#11259)
D2UnitStrc* __stdcall UNITS_AllocUnit(void* pMemPool, int nUnitType);
//D2Common.0x6FDBD720 (#11260)
void __stdcall UNITS_FreeUnit(D2UnitStrc* pUnit);
//D2Common.0x6FDBD780 (#10327)
int __stdcall UNITS_GetPrecisionX(D2UnitStrc* pUnit);
//D2Common.0x6FDBD7D0 (#10330)
int __stdcall UNITS_GetPrecisionY(D2UnitStrc* pUnit);
//D2Common.0x6FDBD820 (#10328)
void __stdcall UNITS_SetXForStaticUnit(D2UnitStrc* pUnit, int nX);
//D2Common.0x6FDBD890 (#10331)
void __stdcall UNITS_SetYForStaticUnit(D2UnitStrc* pUnit, int nY);
//D2Common.0x6FDBD900 (#10336)
int __stdcall UNITS_GetUnitSizeX(D2UnitStrc* pUnit);
//D2Common.0x6FDBDA00 (#10337)
int __stdcall UNITS_GetUnitSizeY(D2UnitStrc* pUnit);
//D2Common.0x6FDBDB10 (#10333)
int __stdcall UNITS_GetTargetX(D2UnitStrc* pUnit);
//D2Common.0x6FDBDB60 (#10334)
int __stdcall UNITS_GetTargetY(D2UnitStrc* pUnit);
//D2Common.0x6FDBDBB0 (#10411)
int __stdcall UNITS_GetAbsoluteXDistance(D2UnitStrc* pUnit1, D2UnitStrc* pUnit2);
//D2Common.0x6FDBDC20 (#10412)
int __stdcall UNITS_GetAbsoluteYDistance(D2UnitStrc* pUnit1, D2UnitStrc* pUnit2);
//D2Common.0x6FDBDC90 (#10340)
void __stdcall UNITS_SetTargetX(D2UnitStrc* pUnit, int nTargetX);
//D2Common.0x6FDBDCD0 (#10341)
void __stdcall UNITS_SetTargetY(D2UnitStrc* pUnit, int nTargetY);
//D2Common.0x6FDBDD10 (#10332)
void __stdcall UNITS_GetCoords(D2UnitStrc* pUnit, D2CoordStrc* pCoord);
//D2Common.0x6FDBDDA0 (#10335)
void __stdcall UNITS_GetTargetCoords(D2UnitStrc* pUnit, D2CoordStrc* pTargetCoords);
//D2Common.0x6FDBDE10 (#10338)
int __fastcall UNITS_GetCollisionType(D2UnitStrc* pUnit);
//D2Common.0x6FDBDEC0 (#10352)
void __stdcall UNITS_FreeCollisionPath(D2UnitStrc* pUnit);
//D2Common.0x6FDBE060 (#10351)
void __stdcall UNITS_BlockCollisionPath(D2UnitStrc* pUnit, D2RoomStrc* pRoom, int nX, int nY);
//D2Common.0x6FDBE1A0 (#10350)
void __stdcall UNITS_InitializeStaticPath(D2UnitStrc* pUnit, D2RoomStrc* pRoom, int nX, int nY);
//D2Common.0x6FDBE210 (#10343)
void __stdcall UNITS_ResetRoom(D2UnitStrc* pUnit);
//D2Common.0x6FDBE270 (#10342)
D2RoomStrc* __stdcall UNITS_GetRoom(D2UnitStrc* pUnit);
//D2Common.0x6FDBE2D0 (#10344)
void __stdcall UNITS_SetTargetUnitForDynamicUnit(D2UnitStrc* pUnit, D2UnitStrc* pTargetUnit);
//D2Common.0x6FDBE330 (#10345)
int __stdcall UNITS_GetTargetTypeFromDynamicUnit(D2UnitStrc* pUnit);
//D2Common.0x6FDBE3A0 (#10346)
int __stdcall UNITS_GetTargetGUIDFromDynamicUnit(D2UnitStrc* pUnit);
//D2Common.0x6FDBE410 (#10347)
void __stdcall UNITS_SetTargetUnitForPlayerOrMonster(D2UnitStrc* pUnit, D2UnitStrc* pTargetUnit);
//D2Common.0x6FDBE470 (#10354)
void __stdcall UNITS_GetRunAndWalkSpeedForPlayer(int nUnused, int nCharId, int* pWalkSpeed, int* pRunSpeed);
//D2Common.0x6FDBE4C0 (#10325)
void __stdcall UNITS_SetAnimData(D2UnitStrc* pUnit, int nUnitType, int nClassId, int nMode);
//D2Common.0x6FDBE510
void __stdcall UNITS_SetAnimStartFrame(D2UnitStrc* pUnit);
//D2Common.0x6FDBEA60 (#10348)
BOOL __stdcall UNITS_ChangeAnimMode(D2UnitStrc* pUnit, int nMode);
//D2Common.0x6FDBEAD0 (#10355)
int __stdcall D2Common_10355(D2UnitStrc* pUnit);
//D2Common.0x6FDBEB20 (#10356)
void __stdcall D2Common_10356(D2UnitStrc* pUnit, int a2);
//D2Common.0x6FDBEB80 (#10357)
void __stdcall UNITS_RefreshInventory(D2UnitStrc* pUnit, BOOL bSetFlag);
//D2Common.0x6FDBEBE0 (#10409)
int __stdcall UNITS_GetInventoryRecordId(D2UnitStrc* pUnit, int nInvPage, BOOL bLoD);
//D2Common.0x6FDBECD0 (#10383)
D2GfxLightStrc* __stdcall UNITS_GetLightMap(D2UnitStrc* pUnit);
//D2Common.0x6FDBED10 (#10369)
int __stdcall UNITS_GetAnimOrSeqMode(D2UnitStrc* pUnit);
//D2Common.0x6FDBED40 (#10370)
void __stdcall UNITS_SetAnimOrSeqMode(D2UnitStrc* pUnit, int nAnimMode);
//D2Common.0x6FDBED90 (#10371)
void __stdcall UNITS_InitializeSequence(D2UnitStrc* pUnit);
//D2Common.0x6FDBEE20 (#10372)
void __stdcall UNITS_SetAnimationFrame(D2UnitStrc* pUnit, int nFrame);
//D2Common.0x6FDBEE60 (#10373)
void __stdcall UNITS_StopSequence(D2UnitStrc* pUnit);
//D2Common.0x6FDBEFF0 (#10374)
void __stdcall UNITS_UpdateFrame(D2UnitStrc* pUnit);
//D2Common.0x6FDBF020 (#10375)
void __stdcall D2COMMON_10375_UNITS_SetFrameNonRate(D2UnitStrc* pUnit, int nRate, int nFailRate);
//D2Common.0x6FDBF050
void __stdcall D2COMMON_10376_UpdateAnimRateAndVelocity(D2UnitStrc* pUnit, char* szFile, int nLine);
//D2Common.0x6FDBF8D0 (#10377)
void __stdcall UNITS_SetAnimationSpeed(D2UnitStrc* pUnit, int nSpeed);
//D2Common.0x6FDBF910 (#10378)
int __stdcall UNITS_IsAtEndOfFrameCycle(D2UnitStrc* pUnit);
//D2Common.0x6FDBF970 (#10379)
void __stdcall UNITS_GetShiftedFrameMetrics(D2UnitStrc* pUnit, int* pFrameNo, int* pFrameCount);
//D2Common.0x6FDBF9E0 (#10380)
void __stdcall UNITS_GetFrameMetrics(D2UnitStrc* pUnit, int* pFrame, int* pFrameCount);
//D2Common.0x6FDBFA40 (#10381)
void __stdcall UNITS_SetAnimActionFrame(D2UnitStrc* pUnit, int nFrame);
//D2Common.0x6FDBFA90 (#10382)
int __stdcall UNITS_GetEventFrameInfo(D2UnitStrc* pUnit, int nFrame);
//D2Common.0x6FDBFB40 (#10410)
BOOL __stdcall UNITS_HasCollision(D2UnitStrc* pUnit);
//D2Common.0x6FDBFB70 (#10358)
D2SkillStrc* __stdcall UNITS_GetSkillFromSkillId(D2UnitStrc* pUnit, int nSkillId);
//D2Common.0x6FDBFC10 (#10392)
BOOL __stdcall UNITS_IsDoor(D2UnitStrc* pUnit);
//D2Common.0x6FDBFC50
bool __fastcall UNITS_CheckIfObjectOrientationIs1(D2UnitStrc* pUnit);
//D2Common.0x6FDBFC90 (#10393)
BOOL __stdcall UNITS_IsShrine(D2UnitStrc* pUnit);
//D2Common.0x6FDBFCB0 (#10394)
D2ObjectsTxt* __stdcall UNITS_GetObjectTxtRecordFromObject(D2UnitStrc* pUnit);
//D2Common.0x6FDBFD00 (#10395)
D2ShrinesTxt* __stdcall UNITS_GetShrineTxtRecordFromObject(D2UnitStrc* pUnit);
//D2Common.0x6FDBFD50 (#10396)
void __stdcall UNITS_SetShrineTxtRecordInObjectData(D2UnitStrc* pUnit, D2ShrinesTxt* pTxt);
//D2Common.0x6FDBFDB0 (#10413)
void __stdcall UNITS_UpdateDirectionAndSpeed(D2UnitStrc* pUnit, int nX, int nY);
//D2Common.0x6FDBFDD0 (#10414)
int __stdcall UNITS_GetNewDirection(D2UnitStrc* pUnit);
//D2Common.0x6FDBFF20 (#10416)
void __stdcall UNITS_StoreOwnerTypeAndGUID(D2UnitStrc* pUnit, int nOwnerType, int nOwnerId);
//D2Common.0x6FDBFF40
void __fastcall UNITS_StoreOwnerInfo(D2UnitStrc* pUnit, int nOwnerType, int nOwnerId);
//D2Common.0x6FDBFFE0 (#10415)
void __stdcall UNITS_StoreOwner(D2UnitStrc* pUnit, D2UnitStrc* pOwner);
//D2Common.0x6FDC0060 (#10417)
void __stdcall UNITS_StoreLastAttacker(D2UnitStrc* pUnit, D2UnitStrc* pKiller);
//D2Common.0x6FDC00E0 (#10418)
int __stdcall UNITS_GetDirectionToCoords(D2UnitStrc* pUnit, int nNewX, int nNewY);
//D2Common.0x6FDC0160 (#10437)
void __stdcall UNITS_SetOverlay(D2UnitStrc* pUnit, int nOverlay, int a3);
//D2Common.0x6FDC01F0 (#10367)
int __stdcall UNITS_GetBeltType(D2UnitStrc* pUnit);
//D2Common.0x6FDC0260 (#10368)
int __stdcall UNITS_GetCurrentLifePercentage(D2UnitStrc* pUnit);
//D2Common.0x6FDC02A0 (#10359)
BOOL __stdcall UNITS_IsSoftMonster(D2UnitStrc* pUnit);
//D2Common.0x6FDC0320 (#10420)
void __stdcall UNITS_AllocPlayerData(D2UnitStrc* pUnit);
//D2Common.0x6FDC03F0 (#10421)
void __stdcall UNITS_FreePlayerData(void* pMemPool, D2UnitStrc* pPlayer);
//D2Common.0x6FDC04A0 (#10422)
void __stdcall UNITS_SetNameInPlayerData(D2UnitStrc* pUnit, char* szName);
//D2Common.0x6FDC0530 (#10423)
char* __stdcall UNITS_GetPlayerName(D2UnitStrc* pUnit);
//D2Common.0x6FDC05B0 (#10424)
D2PlayerDataStrc* __stdcall UNITS_GetPlayerData(D2UnitStrc* pUnit);
//D2Common.0x6FDC0600 (#10425)
void __stdcall UNITS_SetPlayerPortalFlags(D2UnitStrc* pUnit, int a2);
//D2Common.0x6FDC0660 (#10426)
int __stdcall UNITS_GetPlayerPortalFlags(D2UnitStrc* pUnit);
//D2Common.0x6FDC06C0 (#10353)
uint32_t __stdcall UNITS_GetNameOffsetFromObject(D2UnitStrc* pUnit);
//D2Common.0x6FDC0700 (#10427)
uint8_t __stdcall UNITS_GetObjectPortalFlags(D2UnitStrc* pUnit);
//D2Common.0x6FDC0760 (#10428)
void __stdcall UNITS_SetObjectPortalFlags(D2UnitStrc* pUnit, uint8_t nPortalFlag);
//D2Common.0x6FDC07C0 (#10429)
BOOL __stdcall UNITS_CheckObjectPortalFlag(D2UnitStrc* pUnit, uint8_t nFlag);
//D2Common.0x6FDC0820 (#10430)
int __stdcall UNITS_GetOverlayHeight(D2UnitStrc* pUnit);
//D2Common.0x6FDC08B0 (#10431)
int __stdcall UNITS_GetDefense(D2UnitStrc* pUnit);
//D2Common.0x6FDC0AC0 (#10432)
int __stdcall UNITS_GetAttackRate(D2UnitStrc* pUnit);
//D2Common.0x6FDC0B60 (#10433)
int __stdcall UNITS_GetBlockRate(D2UnitStrc* pUnit, BOOL bExpansion);
//D2Common.0x6FDC0DA0 (#10434)
D2UnitStrc* __stdcall D2Common_10434(D2UnitStrc* pUnit, BOOL a2);
//D2Common.0x6FDC0F70 (#10435)
D2UnitStrc* __stdcall UNITS_GetEquippedWeaponFromMonster(D2UnitStrc* pUnit);
//D2Common.0x6FDC0FC0 (#10436)
int __stdcall UNITS_GetFrameBonus(D2UnitStrc* pUnit);
//D2Common.0x6FDC1120 (#10360)
int __stdcall UNITS_GetMeleeRange(D2UnitStrc* pUnit);
//D2Common.0x6FDC1230 (#10364)
BOOL __stdcall UNITS_TestCollisionByCoordinates(D2UnitStrc* pUnit, int nX, int nY, int nFlags);
//D2Common.0x6FDC13D0
BOOL __fastcall UNITS_TestCollision(int nX1, int nY1, int nSize1, int nX2, int nY2, int nSize2, D2RoomStrc* pRoom, int nCollisionType);
//D2Common.0x6FDC14C0 (#10362)
BOOL __stdcall UNITS_TestCollisionWithUnit(D2UnitStrc* pUnit1, D2UnitStrc* pUnit2, int nCollisionType);
//D2Common.0x6FDC1760
void __fastcall UNITS_ToggleUnitFlag(D2UnitStrc* pUnit, int nFlag, BOOL bSet);
//D2Common.0x6FDC1790 (#10363)
BOOL __stdcall UNITS_TestCollisionBetweenInteractingUnits(D2UnitStrc* pUnit1, D2UnitStrc* pUnit2, int nCollisionType);
//D2Common.0x6FDC1A70 (#10361)
BOOL __stdcall UNITS_IsInMeleeRange(D2UnitStrc* pUnit1, D2UnitStrc* pUnit2, int a3);
//D2Common.0x6FDC1B40 (#10318)
BOOL __stdcall UNITS_IsInMovingMode(D2UnitStrc* pUnit);
//D2Common.0x6FDC1C30 (#10319)
BOOL __stdcall UNITS_IsInMovingModeEx(D2UnitStrc* pUnit);
//D2Common.0x6FDC1C50 (#10365)
int __fastcall UNITS_GetHitClass(D2UnitStrc* pUnit);
//D2Common.0x6FDC1CE0 (#10366)
int __fastcall UNITS_GetWeaponClass(D2UnitStrc* pUnit);
//D2Common.0x6FDC1D00 (#10438)
unsigned int __stdcall UNITS_GetHealingCost(D2UnitStrc* pUnit);
//D2Common.0x6FDC1D90 (#10439)
unsigned int __stdcall UNITS_GetInventoryGoldLimit(D2UnitStrc* pUnit);
//D2Common.0x6FDC1DB0 (#10440)
void __stdcall UNITS_MergeDualWieldWeaponStatLists(D2UnitStrc* pUnit, int a2);
//D2Common.0x6FDC1EE0
D2MonStats2Txt* __fastcall UNITS_GetMonStats2TxtRecord(int nRecordId);
//D2Common.0x6FDC1F10 (#10442)
uint8_t __stdcall UNITS_GetItemComponentId(D2UnitStrc* pUnit, D2UnitStrc* pItem);
//D2Common.0x6FDC1FE0
D2MonStats2Txt* __fastcall UNITS_GetMonStats2TxtRecordFromMonsterId(int nMonsterId);
//D2Common.0x6FDC2030 (#10443)
void __stdcall UNITS_InitRightSkill(D2UnitStrc* pUnit);
//D2Common.0x6FDC20A0 (#10444)
void __stdcall UNITS_InitLeftSkill(D2UnitStrc* pUnit);
//D2Common.0x6FDC2110 (#10445)
void __stdcall UNITS_InitSwitchRightSkill(D2UnitStrc* pUnit);
//D2Common.0x6FDC2180 (#10446)
void __stdcall UNITS_InitSwitchLeftSkill(D2UnitStrc* pUnit);
//D2Common.0x6FDC21F0 (#10447)
void __stdcall UNITS_GetRightSkillData(D2UnitStrc* pUnit, int* pRightSkillId, int* pRightSkillFlags);
//D2Common.0x6FDC2250 (#10448)
void __stdcall UNITS_GetLeftSkillData(D2UnitStrc* pUnit, int* pLeftSkillId, int* pLeftSkillFlags);
//D2Common.0x6FDC22B0 (#10449)
void __stdcall UNITS_GetSwitchRightSkillDataResetRightSkill(D2UnitStrc* pUnit, int* pSwitchRightSkillId, int* pSwitchRightSkillFlags);
//D2Common.0x6FDC2330 (#10450)
void __stdcall UNITS_GetSwitchLeftSkillDataResetLeftSkill(D2UnitStrc* pUnit, int* pSwitchLeftSkillId, int* pSwitchLeftSkillFlags);
//D2Common.0x6FDC23B0 (#10451)
void __stdcall UNITS_GetSwitchLeftSkillData(D2UnitStrc* pUnit, int* pSwitchLeftSkillId, int* pSwitchLeftSkillFlags);
//D2Common.0x6FDC2420 (#10452)
void __stdcall UNITS_GetSwitchRightSkillData(D2UnitStrc* pUnit, int* pSwitchRightSkillId, int* pSwitchRightSkillFlags);
//D2Common.0x6FDC2490 (#10453)
void __stdcall UNITS_SetSwitchLeftSkill(D2UnitStrc* pUnit, int nSwitchLeftSkillId, int nSwitchLeftSkillFlags);
//D2Common.0x6FDC24E0 (#10454)
void __stdcall UNITS_SetSwitchRightSkill(D2UnitStrc* pUnit, int nSwitchRightSkillId, int nSwitchRightSkillFlags);
//D2Common.0x6FDC2530 (#10455)
void __stdcall UNITS_SetWeaponGUID(D2UnitStrc* pUnit, D2UnitStrc* pWeapon);
//D2Common.0x6FDC25B0 (#10456)
int __stdcall UNITS_GetWeaponGUID(D2UnitStrc* pUnit);
//D2Common.0x6FDC2630 (#10339)
unsigned int __stdcall UNITS_GetStashGoldLimit(D2UnitStrc* pUnit);
//D2Common.0x6FDC2680 (#10317)
BOOL __fastcall UNITS_CanSwitchAI(int nMonsterId);
//D2Common.0x6FDC2720 (#10458)
void __fastcall UNITS_SetTimerArg(D2UnitStrc* pUnit, D2TimerArgStrc* pTimerArg);
//D2Common.0x6FDC2750 (#10459)
D2TimerArgStrc* __fastcall UNITS_GetTimerArg(D2UnitStrc* pUnit);
//D2Common.0x6FDC2780 (#10460)
void __stdcall UNITS_AllocStaticPath(D2UnitStrc* pUnit);
//D2Common.0x6FDC27C0 (#10461)
void __stdcall UNITS_FreeStaticPath(D2UnitStrc* pUnit);
//D2Common.0x6FDC27F0 (#10462)
BOOL __stdcall UNITS_CanDualWield(D2UnitStrc* pUnit);
//D2Common.0x6FDC2860 (#11238)
BOOL __stdcall UNITS_IsCorpseUseable(D2UnitStrc* pUnit);
//D2Common.0x6FDC2910
BOOL __stdcall UNITS_IsObjectInInteractRange(D2UnitStrc* pUnit, D2UnitStrc* pObject);
//D2Common.0x6FDC2C80
struct D2CharStatsTxt* __fastcall UNITS_GetCharStatsTxtRecord(int nRecordId);
//D2Common.0x6FDC2CB0 (#10399)
int __stdcall D2Common_10399(D2UnitStrc* pUnit1, D2UnitStrc* pUnit2);
//D2Common.0x6FDC2E40 (#10397)
int __stdcall UNITS_GetDistanceToOtherUnit(D2UnitStrc* pUnit1, D2UnitStrc* pUnit2);
//D2Common.0x6FDC2F50 (#10398)
int __stdcall UNITS_GetDistanceToCoordinates(D2UnitStrc* pUnit, int nX, int nY);
//D2Common.0x6FDC2FF0 (#10400)
BOOL __stdcall UNITS_IsInRange(D2UnitStrc* pUnit, D2CoordStrc* pCoord, int nDistance);
//D2Common.0x6FDC3090 (#10406)
D2UnitStrc* __stdcall D2Common_10406(D2UnitStrc* pUnit, int(__fastcall* pCallback)(D2UnitStrc*, D2UnitStrc*), D2UnitStrc* a3);
//D2Common.0x6FDC33C0 (#10407)
D2UnitStrc* __stdcall D2Common_10407(D2RoomStrc* pRoom, int nX, int nY, int(__fastcall* pCallback)(D2UnitStrc*, D2UnitStrc*), D2UnitStrc* a5, int a6);
//D2Common.0x6FDC3680 (#10419)
void __fastcall UNITS_SetInteractData(D2UnitStrc* pUnit, int nSkillId, int nUnitType, int nUnitGUID);
| 45.641189 | 150 | 0.785226 |
0da0cca1770286e5dc11a9180090f3fb54ecbb2b | 620 | h | C | src/sound/arSoundTransformNode.h | IllinoisSimulatorLab/szg | b9f9a2380107450c2f181ac6372427a0112b5ffe | [
"BSD-3-Clause"
] | 2 | 2017-01-07T23:43:03.000Z | 2017-09-29T14:31:09.000Z | src/sound/arSoundTransformNode.h | IllinoisSimulatorLab/szg | b9f9a2380107450c2f181ac6372427a0112b5ffe | [
"BSD-3-Clause"
] | null | null | null | src/sound/arSoundTransformNode.h | IllinoisSimulatorLab/szg | b9f9a2380107450c2f181ac6372427a0112b5ffe | [
"BSD-3-Clause"
] | null | null | null | //********************************************************
// Syzygy is licensed under the BSD license v2
// see the file SZG_CREDITS for details
//********************************************************
#ifndef AR_SOUND_TRANSFORM_NODE_H
#define AR_SOUND_TRANSFORM_NODE_H
#include "arSoundNode.h"
#include "arSoundCalling.h"
// OpenGL-style transformation matrix in the scene graph for sound.
class SZG_CALL arSoundTransformNode : public arSoundNode{
public:
arSoundTransformNode();
~arSoundTransformNode() {}
bool render();
arStructuredData* dumpData();
bool receiveData(arStructuredData*);
};
#endif
| 24.8 | 67 | 0.629032 |
a83704e857e01fcb0a4229e7267fb1aeffe7ef79 | 1,950 | h | C | src/eckit/utils/RLE.h | wsmigaj/eckit | 1a44679243fde8907e760f9cc9eaca87efbd651a | [
"Apache-2.0"
] | null | null | null | src/eckit/utils/RLE.h | wsmigaj/eckit | 1a44679243fde8907e760f9cc9eaca87efbd651a | [
"Apache-2.0"
] | 14 | 2019-09-30T19:24:29.000Z | 2020-10-15T16:02:11.000Z | src/eckit/utils/RLE.h | wsmigaj/eckit | 1a44679243fde8907e760f9cc9eaca87efbd651a | [
"Apache-2.0"
] | 2 | 2019-10-17T13:52:08.000Z | 2019-11-25T14:53:52.000Z | /*
* (C) Copyright 1996- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation nor
* does it submit to any jurisdiction.
*/
// File RLE.h
// Baudouin Raoult - ECMWF Jun 96
#ifndef eckit_RLE_h
#define eckit_RLE_h
#include <iosfwd>
//-----------------------------------------------------------------------------
namespace eckit {
//-----------------------------------------------------------------------------
class Stream;
template <class InputIterator, class OutputIterator>
long long RLEencode2(InputIterator first, InputIterator last,
OutputIterator result,long long maxloop);
template <class InputIterator, class OutputIterator>
void RLEdecode2(InputIterator first, InputIterator last,
OutputIterator result);
template <class InputIterator>
void RLEprint(std::ostream&,InputIterator first, InputIterator last);
template<class InputIterator,class OutputIterator>
bool DIFFencode(InputIterator first,InputIterator last,OutputIterator result);
template<class InputIterator,class OutputIterator>
void DIFFdecode(InputIterator first,InputIterator last,OutputIterator result);
//==========================================================================
template<class InputIterator>
Stream& RLEwrite(Stream&,InputIterator,InputIterator,long long);
template<class OutputIterator,class T>
Stream& RLEread(Stream&,OutputIterator,T*);
template<class InputIterator>
Stream& RLEDIFFwrite(Stream&,InputIterator,InputIterator,long long);
template<class OutputIterator,class T>
Stream& RLEDIFFread(Stream&,OutputIterator,T*);
//-----------------------------------------------------------------------------
} // namespace eckit
#include "eckit/utils/RLE.cc"
#endif
| 27.464789 | 81 | 0.665641 |
cddc0200fb884bf0587a659a15579062b668efc9 | 5,019 | h | C | Simulators/Common/SimulatorBase.h | wwgfbz/SPlisHSPlasH | e305f41d6993c92357a451c627b28a2a95c76905 | [
"MIT"
] | null | null | null | Simulators/Common/SimulatorBase.h | wwgfbz/SPlisHSPlasH | e305f41d6993c92357a451c627b28a2a95c76905 | [
"MIT"
] | null | null | null | Simulators/Common/SimulatorBase.h | wwgfbz/SPlisHSPlasH | e305f41d6993c92357a451c627b28a2a95c76905 | [
"MIT"
] | 1 | 2020-06-25T20:18:55.000Z | 2020-06-25T20:18:55.000Z | #ifndef __SimulatorBase_h__
#define __SimulatorBase_h__
#include "SPlisHSPlasH/Common.h"
#include "SPlisHSPlasH/Utilities/SceneLoader.h"
#include "Visualization/Shader.h"
#include "SPlisHSPlasH/TimeStep.h"
#include "SPlisHSPlasH/FluidModel.h"
#include "extern/AntTweakBar/include/AntTweakBar.h"
#include "ParameterObject.h"
namespace SPH
{
class SimulatorBase : public GenParam::ParameterObject
{
public:
struct SimulationMethod
{
short simulationMethod = 0;
TimeStep *simulation = NULL;
FluidModel model;
};
protected:
unsigned int m_numberOfStepsPerRenderUpdate;
std::string m_exePath;
std::string m_dataPath;
std::string m_outputPath;
std::string m_sceneFile;
bool m_useParticleCaching;
Utilities::SceneLoader::Scene m_scene;
GLint m_context_major_version;
GLint m_context_minor_version;
Shader m_shader_vector;
Shader m_shader_scalar;
Shader m_shader_vector_map;
Shader m_shader_scalar_map;
Shader m_meshShader;
GLuint m_textureMap;
int m_renderWalls;
bool m_doPause;
Real m_pauseAt;
Real m_stopAt;
bool m_enablePartioExport;
unsigned int m_framesPerSecond;
std::string m_partioAttributes;
Vector3r m_oldMousePos;
std::vector<std::vector<unsigned int>> m_selectedParticles;
std::unique_ptr<Utilities::SceneLoader> m_sceneLoader;
Real m_nextFrameTime;
unsigned int m_frameCounter;
std::vector<std::string> m_colorField;
std::vector<int> m_colorMapType;
std::vector<Real> m_renderMaxValue;
std::vector<Real> m_renderMinValue;
float const* m_colorMapBuffer;
unsigned int m_colorMapLength;
#ifdef DL_OUTPUT
Real m_nextTiming;
#endif
virtual void initParameters();
void initShaders();
void initFluidData();
void createFluidBlocks(std::map<std::string, unsigned int> &fluidIDs, std::vector<std::vector<Vector3r>> &fluidParticles, std::vector<std::vector<Vector3r>> &fluidVelocities);
void createEmitters();
static void selection(const Eigen::Vector2i &start, const Eigen::Vector2i &end, void *clientData);
static void mouseMove(int x, int y, void *clientData);
void particleInfo();
public:
static int PAUSE;
static int PAUSE_AT;
static int STOP_AT;
static int NUM_STEPS_PER_RENDER;
static int PARTIO_EXPORT;
static int PARTIO_EXPORT_FPS;
static int PARTIO_EXPORT_ATTRIBUTES;
static int RENDER_WALLS;
static int ENUM_WALLS_NONE;
static int ENUM_WALLS_PARTICLES_ALL;
static int ENUM_WALLS_PARTICLES_NO_WALLS;
static int ENUM_WALLS_GEOMETRY_ALL;
static int ENUM_WALLS_GEOMETRY_NO_WALLS;
SimulatorBase();
virtual ~SimulatorBase();
void init(int argc, char **argv, const char *simName);
void buildModel();
void cleanup();
void renderFluid(const unsigned int fluidModelIndex, float *fluidColor);
void readParameters();
void partioExport();
void writeParticles(const std::string &fileName, FluidModel *model);
void step();
void reset();
Utilities::SceneLoader *getSceneLoader() { return m_sceneLoader.get(); }
const std::string& getExePath() const { return m_exePath; }
const std::string& getDataPath() const { return m_dataPath; }
const std::string& getSceneFile() const { return m_sceneFile; }
GLint getContextMajorVersion() const { return m_context_major_version; }
GLint getContextMinorVersion() const { return m_context_minor_version; }
Shader& getShaderVector() { return m_shader_vector; }
Shader& getShaderScalar() { return m_shader_scalar; }
Shader& getMeshShader() { return m_meshShader; }
void meshShaderBegin(const float *col);
void meshShaderEnd();
void pointShaderBegin(Shader *shader, const float *col, const Real minVal, const Real maxVal, const bool useTexture = false, float const* color_map = nullptr);
void pointShaderEnd(Shader *shader, const bool useTexture = false);
Utilities::SceneLoader::Scene& getScene() { return m_scene; }
std::vector<std::vector<unsigned int>>& getSelectedParticles() { return m_selectedParticles; }
bool getUseParticleCaching() const { return m_useParticleCaching; }
void setUseParticleCaching(bool val) { m_useParticleCaching = val; }
const std::string& getColorField(const unsigned int fluidModelIndex) { return m_colorField[fluidModelIndex]; }
void setColorField(const unsigned int fluidModelIndex, const std::string& fieldName) { m_colorField[fluidModelIndex] = fieldName; }
int getColorMapType(const unsigned int fluidModelIndex) const { return m_colorMapType[fluidModelIndex]; }
void setColorMapType(const unsigned int fluidModelIndex, int val) { m_colorMapType[fluidModelIndex] = val; }
Real getRenderMaxValue(const unsigned int fluidModelIndex) const { return m_renderMaxValue[fluidModelIndex]; }
void setRenderMaxValue(const unsigned int fluidModelIndex, Real val) { m_renderMaxValue[fluidModelIndex] = val; }
Real getRenderMinValue(const unsigned int fluidModelIndex) const { return m_renderMinValue[fluidModelIndex]; }
void setRenderMinValue(const unsigned int fluidModelIndex, Real val) { m_renderMinValue[fluidModelIndex] = val; }
};
}
#endif | 36.635036 | 177 | 0.773461 |
0799300150ccbcd3fc0a9778fc2e046958fe7d2f | 97 | h | C | src/imap_parser.h | brokenprogrammer/mnotify | 72a795270134ac084a117c55fd52f3c56f1fecd1 | [
"Unlicense"
] | 10 | 2022-01-07T18:06:52.000Z | 2022-03-06T12:12:05.000Z | src/imap_parser.h | brokenprogrammer/mnotify | 72a795270134ac084a117c55fd52f3c56f1fecd1 | [
"Unlicense"
] | null | null | null | src/imap_parser.h | brokenprogrammer/mnotify | 72a795270134ac084a117c55fd52f3c56f1fecd1 | [
"Unlicense"
] | null | null | null | typedef struct
{
BOOL HasError;
char Error[1024];
tokenizer Tokenizer;
} imap_parser; | 16.166667 | 24 | 0.690722 |
07999872ec518d2ca745b640c2998ed246bf235c | 13,475 | h | C | headers/private/graphics/neomagic/nm_macros.h | Kirishikesan/haiku | 835565c55830f2dab01e6e332cc7e2d9c015b51e | [
"MIT"
] | 1,338 | 2015-01-03T20:06:56.000Z | 2022-03-26T13:49:54.000Z | headers/private/graphics/neomagic/nm_macros.h | Kirishikesan/haiku | 835565c55830f2dab01e6e332cc7e2d9c015b51e | [
"MIT"
] | 15 | 2015-01-17T22:19:32.000Z | 2021-12-20T12:35:00.000Z | headers/private/graphics/neomagic/nm_macros.h | Kirishikesan/haiku | 835565c55830f2dab01e6e332cc7e2d9c015b51e | [
"MIT"
] | 350 | 2015-01-08T14:15:27.000Z | 2022-03-21T18:14:35.000Z | /* NM registers definitions and macros for access to */
/* PCI_config_space */
#define NMCFG_DEVID 0x00
#define NMCFG_DEVCTRL 0x04
#define NMCFG_CLASS 0x08
#define NMCFG_HEADER 0x0c
#define NMCFG_BASE1FB 0x10
#define NMCFG_BASE2REG1 0x14
#define NMCFG_BASE3REG2 0x18
#define NMCFG_BASE4 0x1c //unknown if used
#define NMCFG_BASE5 0x20 //unknown if used
#define NMCFG_BASE6 0x24 //unknown if used
#define NMCFG_BASE7 0x28 //unknown if used
#define NMCFG_SUBSYSID1 0x2c
#define NMCFG_ROMBASE 0x30
#define NMCFG_CAPPTR 0x34
#define NMCFG_CFG_1 0x38 //unknown if used
#define NMCFG_INTERRUPT 0x3c
#define NMCFG_CFG_3 0x40 //unknown if used
#define NMCFG_CFG_4 0x44 //unknown if used
#define NMCFG_CFG_5 0x48 //unknown if used
#define NMCFG_CFG_6 0x4c //unknown if used
#define NMCFG_CFG_7 0x50 //unknown if used
#define NMCFG_CFG_8 0x54 //unknown if used
#define NMCFG_CFG_9 0x58 //unknown if used
#define NMCFG_CFG_10 0x5c //unknown if used
#define NMCFG_CFG_11 0x60 //unknown if used
#define NMCFG_CFG_12 0x64 //unknown if used
#define NMCFG_CFG_13 0x68 //unknown if used
#define NMCFG_CFG_14 0x6c //unknown if used
#define NMCFG_CFG_15 0x70 //unknown if used
#define NMCFG_CFG_16 0x74 //unknown if used
#define NMCFG_CFG_17 0x78 //unknown if used
#define NMCFG_CFG_18 0x7c //unknown if used
#define NMCFG_CFG_19 0x80 //unknown if used
#define NMCFG_CFG_20 0x84 //unknown if used
#define NMCFG_CFG_21 0x88 //unknown if used
#define NMCFG_CFG_22 0x8c //unknown if used
#define NMCFG_CFG_23 0x90 //unknown if used
#define NMCFG_CFG_24 0x94 //unknown if used
#define NMCFG_CFG_25 0x98 //unknown if used
#define NMCFG_CFG_26 0x9c //unknown if used
#define NMCFG_CFG_27 0xa0 //unknown if used
#define NMCFG_CFG_28 0xa4 //unknown if used
#define NMCFG_CFG_29 0xa8 //unknown if used
#define NMCFG_CFG_30 0xac //unknown if used
#define NMCFG_CFG_31 0xb0 //unknown if used
#define NMCFG_CFG_32 0xb4 //unknown if used
#define NMCFG_CFG_33 0xb8 //unknown if used
#define NMCFG_CFG_34 0xbc //unknown if used
#define NMCFG_CFG_35 0xc0 //unknown if used
#define NMCFG_CFG_36 0xc4 //unknown if used
#define NMCFG_CFG_37 0xc8 //unknown if used
#define NMCFG_CFG_38 0xcc //unknown if used
#define NMCFG_CFG_39 0xd0 //unknown if used
#define NMCFG_CFG_40 0xd4 //unknown if used
#define NMCFG_CFG_41 0xd8 //unknown if used
#define NMCFG_CFG_42 0xdc //unknown if used
#define NMCFG_CFG_43 0xe0 //unknown if used
#define NMCFG_CFG_44 0xe4 //unknown if used
#define NMCFG_CFG_45 0xe8 //unknown if used
#define NMCFG_CFG_46 0xec //unknown if used
#define NMCFG_CFG_47 0xf0 //unknown if used
#define NMCFG_CFG_48 0xf4 //unknown if used
#define NMCFG_CFG_49 0xf8 //unknown if used
#define NMCFG_CFG_50 0xfc //unknown if used
/* neomagic ISA direct registers */
/* VGA standard registers: */
#define NMISA8_ATTRINDW 0x03c0
#define NMISA8_ATTRINDR 0x03c1
#define NMISA8_ATTRDATW 0x03c0
#define NMISA8_ATTRDATR 0x03c1
#define NMISA8_SEQIND 0x03c4
#define NMISA8_SEQDAT 0x03c5
#define NMISA16_SEQIND 0x03c4
#define NMISA8_CRTCIND 0x03d4
#define NMISA8_CRTCDAT 0x03d5
#define NMISA16_CRTCIND 0x03d4
#define NMISA8_GRPHIND 0x03ce
#define NMISA8_GRPHDAT 0x03cf
#define NMISA16_GRPHIND 0x03ce
/* neomagic PCI direct registers */
#define NM2PCI8_SEQIND 0x03c4
#define NM2PCI8_SEQDAT 0x03c5
#define NM2PCI16_SEQIND 0x03c4
#define NM2PCI8_GRPHIND 0x03ce
#define NM2PCI8_GRPHDAT 0x03cf
#define NM2PCI16_GRPHIND 0x03ce
/* neomagic ISA GENERAL direct registers */
/* VGA standard registers: */
#define NMISA8_MISCW 0x03c2
#define NMISA8_MISCR 0x03cc
#define NMISA8_INSTAT1 0x03da
/* neomagic ISA (DAC) COLOR direct registers (VGA palette RAM) */
/* VGA standard registers: */
#define NMISA8_PALMASK 0x03c6
#define NMISA8_PALINDR 0x03c7
#define NMISA8_PALINDW 0x03c8
#define NMISA8_PALDATA 0x03c9
/* neomagic ISA CRTC indexed registers */
/* VGA standard registers: */
#define NMCRTCX_HTOTAL 0x00
#define NMCRTCX_HDISPE 0x01
#define NMCRTCX_HBLANKS 0x02
#define NMCRTCX_HBLANKE 0x03
#define NMCRTCX_HSYNCS 0x04
#define NMCRTCX_HSYNCE 0x05
#define NMCRTCX_VTOTAL 0x06
#define NMCRTCX_OVERFLOW 0x07
#define NMCRTCX_PRROWSCN 0x08
#define NMCRTCX_MAXSCLIN 0x09
#define NMCRTCX_VGACURCTRL 0x0a
#define NMCRTCX_FBSTADDH 0x0c
#define NMCRTCX_FBSTADDL 0x0d
#define NMCRTCX_VSYNCS 0x10
#define NMCRTCX_VSYNCE 0x11
#define NMCRTCX_VDISPE 0x12
#define NMCRTCX_PITCHL 0x13
#define NMCRTCX_VBLANKS 0x15
#define NMCRTCX_VBLANKE 0x16
#define NMCRTCX_MODECTL 0x17
#define NMCRTCX_LINECOMP 0x18
/* NeoMagic specific registers: */
#define NMCRTCX_PANEL_0x40 0x40
#define NMCRTCX_PANEL_0x41 0x41
#define NMCRTCX_PANEL_0x42 0x42
#define NMCRTCX_PANEL_0x43 0x43
#define NMCRTCX_PANEL_0x44 0x44
#define NMCRTCX_PANEL_0x45 0x45
#define NMCRTCX_PANEL_0x46 0x46
#define NMCRTCX_PANEL_0x47 0x47
#define NMCRTCX_PANEL_0x48 0x48
#define NMCRTCX_PANEL_0x49 0x49
#define NMCRTCX_PANEL_0x4a 0x4a
#define NMCRTCX_PANEL_0x4b 0x4b
#define NMCRTCX_PANEL_0x4c 0x4c
#define NMCRTCX_PANEL_0x4d 0x4d
#define NMCRTCX_PANEL_0x4e 0x4e
#define NMCRTCX_PANEL_0x4f 0x4f
#define NMCRTCX_PANEL_0x50 0x50 /* >= NM2090 */
#define NMCRTCX_PANEL_0x51 0x51 /* >= NM2090 */
#define NMCRTCX_PANEL_0x52 0x52 /* >= NM2090 */
#define NMCRTCX_PANEL_0x53 0x53 /* >= NM2090 */
#define NMCRTCX_PANEL_0x54 0x54 /* >= NM2090 */
#define NMCRTCX_PANEL_0x55 0x55 /* >= NM2090 */
#define NMCRTCX_PANEL_0x56 0x56 /* >= NM2090 */
#define NMCRTCX_PANEL_0x57 0x57 /* >= NM2090 */
#define NMCRTCX_PANEL_0x58 0x58 /* >= NM2090 */
#define NMCRTCX_PANEL_0x59 0x59 /* >= NM2090 */
#define NMCRTCX_PANEL_0x60 0x60 /* >= NM2097(?) */
#define NMCRTCX_PANEL_0x61 0x61 /* >= NM2097(?) */
#define NMCRTCX_PANEL_0x62 0x62 /* >= NM2097(?) */
#define NMCRTCX_PANEL_0x63 0x63 /* >= NM2097(?) */
#define NMCRTCX_PANEL_0x64 0x64 /* >= NM2097(?) */
#define NMCRTCX_VEXT 0x70 /* >= NM2200 */
/* neomagic ISA SEQUENCER indexed registers */
/* VGA standard registers: */
#define NMSEQX_RESET 0x00
#define NMSEQX_CLKMODE 0x01
#define NMSEQX_MAPMASK 0x02
#define NMSEQX_MEMMODE 0x04
/* NeoMagic BES registers: (> NM2070) (accessible via mapped I/O: >= NM2097) */
#define NMSEQX_BESCTRL2 0x08
#define NMSEQX_0x09 0x09 //??
#define NMSEQX_ZVCAP_DSCAL 0x0a
#define NMSEQX_BUF2ORGL 0x0c
#define NMSEQX_BUF2ORGM 0x0d
#define NMSEQX_BUF2ORGH 0x0e
#define NMSEQX_VD2COORD1L 0x14 /* >= NM2200(?) */
#define NMSEQX_VD2COORD2L 0x15 /* >= NM2200(?) */
#define NMSEQX_VD2COORD21H 0x16 /* >= NM2200(?) */
#define NMSEQX_HD2COORD1L 0x17 /* >= NM2200(?) */
#define NMSEQX_HD2COORD2L 0x18 /* >= NM2200(?) */
#define NMSEQX_HD2COORD21H 0x19 /* >= NM2200(?) */
#define NMSEQX_BUF2PITCHL 0x1a
#define NMSEQX_BUF2PITCHH 0x1b
#define NMSEQX_0x1c 0x1c //??
#define NMSEQX_0x1d 0x1d //??
#define NMSEQX_0x1e 0x1e //??
#define NMSEQX_0x1f 0x1f //??
/* neomagic ISA ATTRIBUTE indexed registers */
/* VGA standard registers: */
#define NMATBX_MODECTL 0x10
#define NMATBX_OSCANCOLOR 0x11
#define NMATBX_COLPLANE_EN 0x12
#define NMATBX_HORPIXPAN 0x13
#define NMATBX_COLSEL 0x14
#define NMATBX_0x16 0x16
/* neomagic ISA GRAPHICS indexed registers */
/* VGA standard registers: */
#define NMGRPHX_ENSETRESET 0x01
#define NMGRPHX_DATAROTATE 0x03
#define NMGRPHX_READMAPSEL 0x04
#define NMGRPHX_MODE 0x05
#define NMGRPHX_MISC 0x06
#define NMGRPHX_BITMASK 0x08
/* NeoMagic specific registers: */
#define NMGRPHX_GRPHXLOCK 0x09
#define NMGRPHX_GENLOCK 0x0a
#define NMGRPHX_FBSTADDE 0x0e
#define NMGRPHX_CRTC_PITCHE 0x0f /* > NM2070 */
#define NMGRPHX_IFACECTRL1 0x10
#define NMGRPHX_IFACECTRL2 0x11
#define NMGRPHX_0x15 0x15
#define NMGRPHX_ACT_CLK_SAV 0x19 /* >= NM2200? auto-pwr-save.. (b2-0) */
#define NMGRPHX_PANELCTRL1 0x20
#define NMGRPHX_PANELTYPE 0x21
#define NMGRPHX_PANELCTRL2 0x25
#define NMGRPHX_PANELVCENT1 0x28
#define NMGRPHX_PANELVCENT2 0x29
#define NMGRPHX_PANELVCENT3 0x2a
#define NMGRPHX_PANELCTRL3 0x30 /* > NM2070 */
#define NMGRPHX_PANELVCENT4 0x32 /* > NM2070 */
#define NMGRPHX_PANELHCENT1 0x33 /* > NM2070 */
#define NMGRPHX_PANELHCENT2 0x34 /* > NM2070 */
#define NMGRPHX_PANELHCENT3 0x35 /* > NM2070 */
#define NMGRPHX_PANELHCENT4 0x36 /* >= NM2160 */
#define NMGRPHX_PANELVCENT5 0x37 /* >= NM2200 */
#define NMGRPHX_PANELHCENT5 0x38 /* >= NM2200 */
#define NMGRPHX_CURCTRL 0x82
#define NMGRPHX_COLDEPTH 0x90
/* mem or core PLL register??? */
#define NMGRPHX_SPEED 0x93
/* (NeoMagic pixelPLL set C registers) */
#define NMGRPHX_PLLC_NH 0x8f /* >= NM2200 */
#define NMGRPHX_PLLC_NL 0x9b
#define NMGRPHX_PLLC_M 0x9f
/* NeoMagic BES registers: (> NM2070) (accessible via mapped I/O: >= NM2097) */
#define NMGRPHX_BESCTRL1 0xb0
#define NMGRPHX_HD1COORD21H 0xb1
#define NMGRPHX_HD1COORD1L 0xb2
#define NMGRPHX_HD1COORD2L 0xb3
#define NMGRPHX_VD1COORD21H 0xb4
#define NMGRPHX_VD1COORD1L 0xb5
#define NMGRPHX_VD1COORD2L 0xb6
#define NMGRPHX_BUF1ORGH 0xb7
#define NMGRPHX_BUF1ORGM 0xb8
#define NMGRPHX_BUF1ORGL 0xb9
#define NMGRPHX_BUF1PITCHH 0xba
#define NMGRPHX_BUF1PITCHL 0xbb
#define NMGRPHX_0xbc 0xbc //??
#define NMGRPHX_0xbd 0xbd //??
#define NMGRPHX_0xbe 0xbe //??
#define NMGRPHX_0xbf 0xbf //??
#define NMGRPHX_XSCALEH 0xc0
#define NMGRPHX_XSCALEL 0xc1
#define NMGRPHX_YSCALEH 0xc2
#define NMGRPHX_YSCALEL 0xc3
#define NMGRPHX_BRIGHTNESS 0xc4
#define NMGRPHX_COLKEY_R 0xc5
#define NMGRPHX_COLKEY_G 0xc6
#define NMGRPHX_COLKEY_B 0xc7
/* NeoMagic specific PCI cursor registers < NM2200 */
#define NMCR1_CURCTRL 0x0100
#define NMCR1_CURX 0x0104
#define NMCR1_CURY 0x0108
#define NMCR1_CURBGCOLOR 0x010c
#define NMCR1_CURFGCOLOR 0x0110
#define NMCR1_CURADDRESS 0x0114
/* NeoMagic specific PCI cursor registers >= NM2200 */
#define NMCR1_22CURCTRL 0x1000
#define NMCR1_22CURX 0x1004
#define NMCR1_22CURY 0x1008
#define NMCR1_22CURBGCOLOR 0x100c
#define NMCR1_22CURFGCOLOR 0x1010
#define NMCR1_22CURADDRESS 0x1014
/* NeoMagic PCI acceleration registers */
/* all cards, but some registers only on 2090 and later; and some on 2200 and later */
#define NMACC_STATUS 0x0000
#define NMACC_CONTROL 0x0004
#define NMACC_FGCOLOR 0x000c
#define NMACC_2200_SRC_PITCH 0x0014
#define NMACC_2090_CLIPLT 0x0018
#define NMACC_2090_CLIPRB 0x001c
#define NMACC_SRCSTARTOFF 0x0024
#define NMACC_2090_DSTSTARTOFF 0x002c
#define NMACC_2090_XYEXT 0x0030
/* NM2070 only */
#define NMACC_2070_PLANEMASK 0x0014
#define NMACC_2070_XYEXT 0x0018
#define NMACC_2070_SRCPITCH 0x001c
#define NMACC_2070_SRCBITOFF 0x0020
#define NMACC_2070_DSTPITCH 0x0028
#define NMACC_2070_DSTBITOFF 0x002c
#define NMACC_2070_DSTSTARTOFF 0x0030
/* Macros for convenient accesses to the NM chips */
/* primary PCI register area */
#define NM_REG8(r_) ((vuint8 *)regs)[(r_)]
#define NM_REG16(r_) ((vuint16 *)regs)[(r_) >> 1]
#define NM_REG32(r_) ((vuint32 *)regs)[(r_) >> 2]
/* secondary PCI register area */
#define NM_2REG8(r_) ((vuint8 *)regs2)[(r_)]
#define NM_2REG16(r_) ((vuint16 *)regs2)[(r_) >> 1]
#define NM_2REG32(r_) ((vuint32 *)regs2)[(r_) >> 2]
/* read and write to PCI config space */
#define CFGR(A) (nm_pci_access.offset=NMCFG_##A, ioctl(fd,NM_GET_PCI, &nm_pci_access,sizeof(nm_pci_access)), nm_pci_access.value)
#define CFGW(A,B) (nm_pci_access.offset=NMCFG_##A, nm_pci_access.value = B, ioctl(fd,NM_SET_PCI,&nm_pci_access,sizeof(nm_pci_access)))
/* read and write from acceleration engine */
#define ACCR(A) (NM_REG32(NMACC_##A))
#define ACCW(A,B) (NM_REG32(NMACC_##A) = (B))
/* read and write from first CRTC (mapped) */
#define CR1R(A) (NM_REG32(NMCR1_##A))
#define CR1W(A,B) (NM_REG32(NMCR1_##A) = (B))
/* read and write from ISA I/O space */
#define ISAWB(A,B)(nm_isa_access.adress=NMISA8_##A, nm_isa_access.data = (uint8)B, nm_isa_access.size = 1, ioctl(fd,NM_ISA_OUT, &nm_isa_access,sizeof(nm_isa_access)))
#define ISAWW(A,B)(nm_isa_access.adress=NMISA16_##A, nm_isa_access.data = B, nm_isa_access.size = 2, ioctl(fd,NM_ISA_OUT, &nm_isa_access,sizeof(nm_isa_access)))
#define ISARB(A) (nm_isa_access.adress=NMISA8_##A, ioctl(fd,NM_ISA_IN, &nm_isa_access,sizeof(nm_isa_access)), (uint8)nm_isa_access.data)
#define ISARW(A) (nm_isa_access.adress=NMISA16_##A, ioctl(fd,NM_ISA_IN, &nm_isa_access,sizeof(nm_isa_access)), nm_isa_access.data)
/* read and write from ISA CRTC indexed registers */
#define ISACRTCW(A,B)(ISAWW(CRTCIND, ((NMCRTCX_##A) | ((B) << 8))))
#define ISACRTCR(A) (ISAWB(CRTCIND, (NMCRTCX_##A)), ISARB(CRTCDAT))
/* read and write from ISA GRAPHICS indexed registers */
#define ISAGRPHW(A,B)(ISAWW(GRPHIND, ((NMGRPHX_##A) | ((B) << 8))))
#define ISAGRPHR(A) (ISAWB(GRPHIND, (NMGRPHX_##A)), ISARB(GRPHDAT))
/* read and write from PCI GRAPHICS indexed registers (>= NM2097) */
#define PCIGRPHW(A,B)(NM_2REG16(NM2PCI16_GRPHIND) = ((NMGRPHX_##A) | ((B) << 8)))
#define PCIGRPHR(A) (NM_2REG8(NM2PCI8_GRPHIND) = (NMGRPHX_##A), NM_2REG8(NM2PCI8_GRPHDAT))
/* read and write from ISA SEQUENCER indexed registers */
#define ISASEQW(A,B)(ISAWW(SEQIND, ((NMSEQX_##A) | ((B) << 8))))
#define ISASEQR(A) (ISAWB(SEQIND, (NMSEQX_##A)), ISARB(SEQDAT))
/* read and write from PCI SEQUENCER indexed registers (>= NM2097) */
#define PCISEQW(A,B)(NM_2REG16(NM2PCI16_SEQIND) = ((NMSEQX_##A) | ((B) << 8)))
#define PCISEQR(A) (NM_2REG8(NM2PCI8_SEQIND) = (NMSEQX_##A), NM_2REG8(NM2PCI8_SEQDAT))
/* read and write from ISA ATTRIBUTE indexed registers */
#define ISAATBW(A,B)((void)ISARB(INSTAT1), ISAWB(ATTRINDW, ((NMATBX_##A) | 0x20)), ISAWB(ATTRDATW, (B)))
#define ISAATBR(A) ((void)ISARB(INSTAT1), ISAWB(ATTRINDW, ((NMATBX_##A) | 0x20)), ISARB(ATTRDATR))
| 38.390313 | 166 | 0.768905 |
07c92f235dd37a33d7c23304d9ebb34971a7b66c | 437 | c | C | LPS/Esercizi/18.05.2022_casa/C99.c | Giacomix02/esercitazioni-java | a2c1ffa073240d08ee50a4e0b6088165230f21bf | [
"MIT"
] | 3 | 2021-12-10T16:28:19.000Z | 2022-03-29T13:50:19.000Z | LPS/Esercizi/18.05.2022_casa/C99.c | Giacomix02/Codice-Univaq-Informatica | a2c1ffa073240d08ee50a4e0b6088165230f21bf | [
"MIT"
] | 1 | 2021-12-07T14:39:52.000Z | 2021-12-07T14:39:52.000Z | LPS/Esercizi/18.05.2022_casa/C99.c | Giacomix02/Codice-Univaq-Informatica | a2c1ffa073240d08ee50a4e0b6088165230f21bf | [
"MIT"
] | 4 | 2022-03-07T18:47:45.000Z | 2022-03-31T06:42:00.000Z | #include <stdio.h>
int a = 7, b = -5, *p_si;
short g, h, k = 43, *p1_ss, *p2_ss = &g;
unsigned char x, y = 31, z = 99, *p1_uc, *p2_uc;
int main(void)
{
p_si=&b;
*p_si+=1;
a = a - (*p_si);
p1_ss = &k;
*p2_ss=*p1_ss;
p1_ss = &h;
*p1_ss = k - 3;
p1_uc = &x;
p2_uc = &y;
*p2_uc = *p2_uc + 4;
*p1_uc = z + 1;
p2_uc = p1_uc;
*p1_uc = *p1_uc - y;
*p2_uc = *p2_uc + 5;
} | 18.208333 | 52 | 0.439359 |
6d9702cd07b1dce54cb4e9654ad066d004f9efdc | 947 | h | C | Telecomm/Telecomm/Lib/Componet/StockMarket/include/JFStockChartToolbar.h | telecommai/ios | 0dce4eeba342466ffe0db72fc0b77ba7d708d8cf | [
"BSD-3-Clause"
] | 1 | 2019-04-19T08:05:34.000Z | 2019-04-19T08:05:34.000Z | Telecomm/Telecomm/Lib/Componet/StockMarket/include/JFStockChartToolbar.h | telecommai/ios | 0dce4eeba342466ffe0db72fc0b77ba7d708d8cf | [
"BSD-3-Clause"
] | null | null | null | Telecomm/Telecomm/Lib/Componet/StockMarket/include/JFStockChartToolbar.h | telecommai/ios | 0dce4eeba342466ffe0db72fc0b77ba7d708d8cf | [
"BSD-3-Clause"
] | 1 | 2019-09-05T01:54:54.000Z | 2019-09-05T01:54:54.000Z | //
// JFStockChartToolbar.h
// WalletManager
//
// Created by YRH on 2018/11/9.
// Copyright © 2018 pansoft. All rights reserved.
//
/// 股市动态图表操作工具栏
#import <UIKit/UIKit.h>
#import "JFStockSegmentView.h"
#import "FinanceDetailViewConst.h"
#import "MJExtension/MJExtension.h"
@protocol JFStockChartToolbarDelegate <NSObject>
@optional
/// 改变k线数据
- (void)changeKlineData:(NSString *)code needSince:(BOOL)needSince xAxisShowHour:(BOOL)xAxisShowHour;
/// 横竖屏
- (void)somehowScreen;
/// 改变 指标
- (void)changeKlineTarget:(NSString *)title index:(NSInteger)index;
@end
@interface JFStockChartToolbar : UIView
@property (nonatomic, weak) id<JFStockChartToolbarDelegate> delegate;
@property (nonatomic, strong) JFStockSegmentBarItemModel *defaultSelectItemModel;
/// k线图改变了指标线
- (void)changedKlineIndex:(KLineIndexType)indexType;
/// 隐藏全屏按钮,调整布局
- (void)hiddenFullScreenButtonAdjustLayout;
/// 隐藏 指标 选项
- (void)hiddenSegmentIndexOption;
@end
| 22.023256 | 101 | 0.763464 |
ed06969f6276ee282aff1194a380e9aecb663f73 | 31,625 | c | C | src/ml_object.c | JohnathonNow/minilang | 44d2469dea8f25b9c81bcccffdaa7aca85ccb745 | [
"MIT"
] | null | null | null | src/ml_object.c | JohnathonNow/minilang | 44d2469dea8f25b9c81bcccffdaa7aca85ccb745 | [
"MIT"
] | null | null | null | src/ml_object.c | JohnathonNow/minilang | 44d2469dea8f25b9c81bcccffdaa7aca85ccb745 | [
"MIT"
] | null | null | null | #include <gc.h>
#include <string.h>
#include "minilang.h"
#include "ml_macros.h"
#include "ml_object.h"
typedef struct ml_class_t ml_class_t;
typedef struct ml_object_t ml_object_t;
struct ml_class_t {
ml_type_t Base;
ml_value_t *Initializer;
stringmap_t Fields[1];
};
typedef struct {
const ml_type_t *Type;
ml_value_t *Value;
} ml_field_t;
static ml_value_t *ml_field_deref(ml_field_t *Field) {
return Field->Value;
}
static ml_value_t *ml_field_assign(ml_field_t *Field, ml_value_t *Value) {
return Field->Value = Value;
}
static void ml_field_call(ml_state_t *Caller, ml_field_t *Field, int Count, ml_value_t **Args) {
return ml_call(Caller, Field->Value, Count, Args);
}
ML_TYPE(MLFieldT, (), "field",
//!internal
.deref = (void *)ml_field_deref,
.assign = (void *)ml_field_assign,
.call = (void *)ml_field_call
);
struct ml_object_t {
ml_class_t *Type;
ml_field_t Fields[];
};
ML_INTERFACE(MLObjectT, (), "object");
// Parent type of all object classes.
ML_METHOD("::", MLObjectT, MLStringT) {
//<Object
//<Field
//>field
// Retrieves the field :mini:`Field` from :mini:`Object`. Mainly intended for unpacking objects.
ml_object_t *Object = (ml_object_t *)Args[0];
const char *Name = ml_string_value(Args[1]);
uintptr_t Offset = (uintptr_t)stringmap_search(Object->Type->Fields, Name);
if (!Offset) return ml_error("NameError", "Type %s has no field %s", Object->Type->Base.Name, Name);
return (ml_value_t *)((char *)Object + Offset);
}
static void ml_class_call(ml_state_t *Caller, ml_type_t *Class, int Count, ml_value_t **Args) {
ml_value_t *Constructor = Class->Constructor;
return ml_call(Caller, Constructor, Count, Args);
}
extern ml_cfunctionx_t MLClass[];
ML_TYPE(MLClassT, (MLTypeT), "class",
//!object
// Type of all object classes.
.call = (void *)ml_class_call,
.Constructor = (ml_value_t *)MLClass
);
typedef struct {
ml_object_t *Object;
ml_stringbuffer_t Buffer[1];
int Comma;
} ml_object_stringer_t;
static int field_string(const char *Name, void *Offset, ml_object_stringer_t *Stringer) {
if (Stringer->Comma++) ml_stringbuffer_add(Stringer->Buffer, ", ", 2);
ml_stringbuffer_add(Stringer->Buffer, Name, strlen(Name));
ml_stringbuffer_add(Stringer->Buffer, " is ", 4);
ml_stringbuffer_append(Stringer->Buffer, ((ml_field_t *)((char *)Stringer->Object + (uintptr_t)Offset))->Value);
return 0;
}
ML_METHOD(MLStringT, MLObjectT) {
ml_object_t *Object = (ml_object_t *)Args[0];
ml_object_stringer_t Stringer = {Object, {ML_STRINGBUFFER_INIT}, 0};
ml_stringbuffer_addf(Stringer.Buffer, "%s(", Object->Type->Base.Name);
stringmap_foreach(Object->Type->Fields, &Stringer, (void *)field_string);
ml_stringbuffer_add(Stringer.Buffer, ")", 1);
return ml_stringbuffer_value(Stringer.Buffer);
}
ml_value_t *ml_field_fn(void *Data, int Count, ml_value_t **Args) {
ml_object_t *Object = (ml_object_t *)Args[0];
return (ml_value_t *)((char *)Object + (uintptr_t)Data);
}
typedef struct {
ml_state_t Base;
ml_value_t *Object;
ml_value_t *Args[];
} ml_init_state_t;
static void ml_init_state_run(ml_init_state_t *State, ml_value_t *Result) {
ml_state_t *Caller = State->Base.Caller;
if (ml_is_error(Result)) ML_RETURN(Result);
ML_RETURN(State->Object);
}
static void ml_object_constructor_fn(ml_state_t *Caller, ml_class_t *Class, int Count, ml_value_t **Args) {
int NumFields = Class->Fields->Size;
ml_object_t *Object = xnew(ml_object_t, NumFields, ml_field_t);
Object->Type = Class;
ml_field_t *Slot = Object->Fields;
for (int I = NumFields; --I >= 0; ++Slot) {
Slot->Type = MLFieldT;
Slot->Value = MLNil;
}
if (Class->Initializer) {
ml_init_state_t *State = xnew(ml_init_state_t, Count + 1, ml_value_t *);
State->Args[0] = (ml_value_t *)Object;
for (int I = 0; I < Count; ++I) State->Args[I + 1] = Args[I];
State->Base.run = (void *)ml_init_state_run;
State->Base.Caller = Caller;
State->Base.Context = Caller->Context;
State->Object = (ml_value_t *)Object;
return ml_call(State, Class->Initializer, Count + 1, State->Args);
}
for (int I = 0; I < Count; ++I) {
ml_value_t *Arg = ml_deref(Args[I]);
if (ml_is_error(Arg)) ML_RETURN(Arg);
if (ml_is(Arg, MLNamesT)) {
ML_NAMES_FOREACH(Args[I], Iter) {
++I;
const char *Name = ml_string_value(Iter->Value);
void *Offset = stringmap_search(Class->Fields, Name);
if (!Offset) {
ML_ERROR("ValueError", "Class %s does not have field %s", Class->Base.Name, Name);
}
ml_field_t *Field = (ml_field_t *)((char *)Object + (uintptr_t)Offset);
Field->Value = Arg;
}
break;
} else if (I > NumFields) {
break;
} else {
Object->Fields[I].Value = Arg;
}
}
ML_RETURN(Object);
}
typedef struct {
ml_type_t Base;
ml_type_t *Native;
ml_value_t *Constructor;
ml_value_t *Initializer;
} ml_named_type_t;
ML_TYPE(MLNamedTypeT, (MLTypeT), "named-type",
//!internal
.call = (void *)ml_class_call
);
typedef struct {
ml_state_t Base;
ml_value_t *Object;
ml_type_t *Old, *New;
ml_value_t *Init;
int Count;
ml_value_t *Args[];
} ml_named_init_state_t;
static void ml_named_init_state_run(ml_named_init_state_t *State, ml_value_t *Result) {
ml_type_t *Old = ml_typeof(Result);
if (Old == State->Old) {
Result->Type = State->New;
#ifdef ML_GENERICS
} else if (Old->Type == MLGenericTypeT && ml_generic_type_args(Old)[0] == State->Old) {
Result->Type = State->New;
#endif
} else {
ML_CONTINUE(State->Base.Caller, Result);
}
if (State->Init) {
State->Object = State->Args[0] = Result;
State->Base.run = (void *)ml_init_state_run;
return ml_call(State, State->Init, State->Count, State->Args);
}
ML_CONTINUE(State->Base.Caller, Result);
}
static void ml_named_constructor_fn(ml_state_t *Caller, ml_named_type_t *Class, int Count, ml_value_t **Args) {
ml_named_init_state_t *State = new(ml_named_init_state_t);
State->Base.run = (void *)ml_named_init_state_run;
State->Base.Caller = Caller;
State->Base.Context = Caller->Context;
State->Old = Class->Native;
State->New = (ml_type_t *)Class;
return ml_call(State, Class->Native->Constructor, Count, Args);
}
static void ml_named_initializer_fn(ml_state_t *Caller, ml_named_type_t *Class, int Count, ml_value_t **Args) {
ml_named_init_state_t *State = xnew(ml_named_init_state_t, Count + 1, ml_value_t *);
for (int I = 0; I < Count; ++I) State->Args[I + 1] = Args[I];
State->Base.run = (void *)ml_named_init_state_run;
State->Base.Caller = Caller;
State->Base.Context = Caller->Context;
State->Old = Class->Native;
State->New = (ml_type_t *)Class;
State->Init = Class->Initializer;
State->Count = Count + 1;
return ml_call(State, Class->Native->Constructor, 0, NULL);
}
static int add_field(const char *Name, void *Value, ml_class_t *Class) {
//printf("Adding field %s to class %s\n", Name, Class->Base.Name);
void **Slot = stringmap_slot(Class->Fields, Name);
if (!Slot[0]) Slot[0] = &((ml_object_t *)0)->Fields[Class->Fields->Size - 1];
return 0;
}
typedef struct {
ml_methods_t *Methods;
ml_value_t **FieldFns;
ml_class_t *Class;
} class_setup_t;
static int setup_field(const char *Name, char *Offset, class_setup_t *Setup) {
//printf("Adding method %s:%s\n", Setup->Class->Base.Name, Name);
int Index = (Offset - (char *)&((ml_object_t *)0)->Fields) / sizeof(ml_field_t);
ml_type_t *Types[1] = {(ml_type_t *)Setup->Class};
ml_method_t *Method = (ml_method_t *)ml_method(Name);
ml_method_insert(Setup->Methods, Method, Setup->FieldFns[Index], 1, 1, Types);
return 0;
}
static void setup_fields(ml_state_t *Caller, ml_class_t *Class) {
static ml_value_t **FieldFns = NULL;
static int NumFieldFns = 0;
int NumFields = Class->Fields->Size;
if (NumFields > NumFieldFns) {
ml_value_t **NewFieldFns = anew(ml_value_t *, NumFields);
memcpy(NewFieldFns, FieldFns, NumFieldFns * sizeof(ml_value_t *));
for (int I = NumFieldFns; I < NumFields; ++I) {
void *Offset = &((ml_object_t *)0)->Fields[I];
NewFieldFns[I] = ml_cfunction(Offset, ml_field_fn);
}
FieldFns = NewFieldFns;
NumFieldFns = NumFields;
}
class_setup_t Setup = {Caller->Context->Values[ML_METHODS_INDEX], FieldFns, Class};
stringmap_foreach(Class->Fields, &Setup, (void *)setup_field);
}
ML_FUNCTIONX(MLClass) {
//!object
//@class
//<Parents...:class
//<Fields...:method
//<Exports...:names
//>class
// Returns a new class inheriting from :mini:`Parents`, with fields :mini:`Fields` and exports :mini:`Exports`. The special exports :mini:`"of"` and :mini:`"init"` can be set to override the default conversion and initialization behaviour. The :mini:`"new"` export will *always* be set to the original constructor for this class.
int Rank = 0;
ml_type_t *NativeType = NULL;
for (int I = 0; I < Count; ++I) {
if (ml_typeof(Args[I]) == MLMethodT) {
} else if (ml_is(Args[I], MLClassT)) {
ml_class_t *Parent = (ml_class_t *)Args[I];
if (Rank < Parent->Base.Rank) Rank = Parent->Base.Rank;
} else if (ml_is(Args[I], MLNamedTypeT)) {
ml_named_type_t *Parent = (ml_named_type_t *)Args[I];
if (NativeType && NativeType != Parent->Native) {
ML_ERROR("TypeError", "Classes can not inherit from multiple native types");
}
NativeType = Parent->Native;
} else if (ml_is(Args[I], MLTypeT)) {
ml_type_t *Parent = (ml_type_t *)Args[I];
if (Parent->NoInherit) {
ML_ERROR("TypeError", "Classes can not inherit from <%s>", Parent->Name);
}
if (!Parent->Interface) {
if (NativeType && NativeType != Parent) {
ML_ERROR("TypeError", "Classes can not inherit from multiple native types");
}
NativeType = Parent;
}
if (Rank < Parent->Rank) Rank = Parent->Rank;
} else if (ml_is(Args[I], MLNamesT)) {
break;
} else {
ML_ERROR("TypeError", "Unexpected argument type: <%s>", ml_typeof(Args[I])->Name);
}
}
if (NativeType) {
ml_named_type_t *Class = new(ml_named_type_t);
Class->Base.Type = MLNamedTypeT;
asprintf((char **)&Class->Base.Name, "named-%s:%lx", NativeType->Name, (uintptr_t)Class);
Class->Base.hash = ml_default_hash;
Class->Base.call = ml_default_call;
Class->Base.deref = ml_default_deref;
Class->Base.assign = ml_default_assign;
Class->Base.Rank = Rank + 1;
Class->Native = NativeType;
ml_value_t *Constructor = ml_cfunctionx(Class, (void *)ml_named_constructor_fn);
Class->Base.Constructor = Constructor;
for (int I = 0; I < Count; ++I) {
if (ml_is(Args[I], MLTypeT)) {
ml_type_t *Parent = (ml_type_t *)Args[I];
ml_type_add_parent((ml_type_t *)Class, Parent);
} else if (ml_is(Args[I], MLNamesT)) {
ML_LIST_FOREACH(Args[I], Iter) {
ml_value_t *Key = Iter->Value;
const char *Name = ml_string_value(Key);
ml_value_t *Value = Args[++I];
stringmap_insert(Class->Base.Exports, Name, Value);
ml_value_set_name(Value, Name);
if (!strcmp(Name, "of")) {
Class->Base.Constructor = Value;
} else if (!strcmp(Name, "init")) {
Class->Initializer = Value;
Class->Base.Constructor = ml_cfunctionx(Class, (void *)ml_named_initializer_fn);
}
}
break;
}
}
stringmap_insert(Class->Base.Exports, "new", Constructor);
ML_RETURN(Class);
} else {
ml_class_t *Class = new(ml_class_t);
Class->Base.Type = MLClassT;
asprintf((char **)&Class->Base.Name, "object:%lx", (uintptr_t)Class);
Class->Base.hash = ml_default_hash;
Class->Base.call = ml_default_call;
Class->Base.deref = ml_default_deref;
Class->Base.assign = ml_default_assign;
Class->Base.Rank = Rank + 1;
ml_value_t *Constructor = ml_cfunctionx(Class, (void *)ml_object_constructor_fn);
Class->Base.Constructor = Constructor;
for (int I = 0; I < Count; ++I) {
if (ml_typeof(Args[I]) == MLMethodT) {
add_field(ml_method_name(Args[I]), NULL, Class);
} else if (ml_is(Args[I], MLClassT)) {
ml_class_t *Parent = (ml_class_t *)Args[I];
stringmap_foreach(Parent->Fields, Class, (void *)add_field);
ml_type_add_parent((ml_type_t *)Class, (ml_type_t *)Parent);
} else if (ml_is(Args[I], MLTypeT)) {
ml_type_t *Parent = (ml_type_t *)Args[I];
ml_type_add_parent((ml_type_t *)Class, Parent);
} else if (ml_is(Args[I], MLNamesT)) {
ML_LIST_FOREACH(Args[I], Iter) {
ml_value_t *Key = Iter->Value;
const char *Name = ml_string_value(Key);
ml_value_t *Value = Args[++I];
stringmap_insert(Class->Base.Exports, Name, Value);
ml_value_set_name(Value, Name);
if (!strcmp(Name, "of")) {
Class->Base.Constructor = Value;
} else if (!strcmp(Name, "init")) {
Class->Initializer = Value;
}
}
break;
}
}
ml_type_add_parent((ml_type_t *)Class, MLObjectT);
setup_fields(Caller, Class);
stringmap_insert(Class->Base.Exports, "new", Constructor);
ML_RETURN(Class);
}
}
static void ML_TYPED_FN(ml_value_set_name, MLClassT, ml_class_t *Class, const char *Name) {
Class->Base.Name = Name;
}
typedef struct ml_property_t {
const ml_type_t *Type;
ml_value_t *Get, *Set;
ml_result_state_t State[1];
} ml_property_t;
static ml_value_t *ml_property_deref(ml_property_t *Property) {
Property->State->Value = NULL;
ml_call(Property->State, Property->Get, 0, NULL);
return Property->State->Value ?: ml_error("StateError", "Property functions must not suspend");
}
static ml_value_t *ml_property_assign(ml_property_t *Property, ml_value_t *Value) {
Property->State->Value = NULL;
ml_call(Property->State, Property->Set, 1, &Value);
return Property->State->Value ?: ml_error("StateError", "Property functions must not suspend");
}
static void ml_property_call(ml_state_t *Caller, ml_property_t *Property, int Count, ml_value_t **Args) {
Property->State->Value = NULL;
ml_call(Property->State, Property->Get, 0, NULL);
return ml_call(Caller, Property->State->Value ?: MLNil, Count, Args);
}
extern ml_cfunctionx_t MLProperty[];
ML_TYPE(MLPropertyT, (), "property",
.deref = (void *)ml_property_deref,
.assign = (void *)ml_property_assign,
.call = (void *)ml_property_call,
.Constructor = (ml_value_t *)MLProperty
);
ML_FUNCTIONX(MLProperty) {
//@property
ML_CHECKX_ARG_COUNT(2);
ML_CHECKX_ARG_TYPE(0, MLFunctionT);
ML_CHECKX_ARG_TYPE(1, MLFunctionT);
ml_property_t *Property = new(ml_property_t);
Property->Type = MLPropertyT;
Property->Get = Args[0];
Property->Set = Args[1];
Property->State->Base.run = (ml_state_fn)ml_result_state_run;
Property->State->Base.Context = Caller->Context;
ML_RETURN(Property);
}
size_t ml_class_size(const ml_value_t *Value) {
return ((ml_class_t *)Value)->Fields->Size;
}
size_t ml_object_size(const ml_value_t *Value) {
return ((ml_class_t *)ml_typeof(Value))->Fields->Size;
}
ml_value_t *ml_object_field(const ml_value_t *Value, size_t Field) {
return ((ml_object_t *)Value)->Fields[Field].Value;
}
typedef struct {
ml_type_t Base;
ml_value_t *Values[];
} ml_enum_t;
typedef struct {
#ifdef ML_NANBOXING
ml_int64_t Base;
#else
ml_integer_t Base;
#endif
ml_value_t *Name;
} ml_enum_value_t;
extern ml_type_t MLEnumT[];
static long ml_enum_value_hash(ml_enum_value_t *Value, ml_hash_chain_t *Chain) {
return (long)Value->Base.Type + Value->Base.Value;
}
#ifdef ML_NANBOXING
ML_TYPE(MLEnumValueT, (MLInt64T), "enum-value");
//!internal
#else
ML_TYPE(MLEnumValueT, (MLIntegerT), "enum-value");
//!internal
#endif
ML_METHOD(MLStringT, MLEnumValueT) {
ml_enum_value_t *Value = (ml_enum_value_t *)Args[0];
return Value->Name;
}
ML_METHOD("append", MLStringBufferT, MLEnumValueT) {
ml_stringbuffer_t *Buffer = (ml_stringbuffer_t *)Args[0];
ml_enum_value_t *Value = (ml_enum_value_t *)Args[1];
ml_stringbuffer_add(Buffer, ml_string_value(Value->Name), ml_string_length(Value->Name));
return Args[0];
}
ML_FUNCTION(MLEnum) {
//@enum
//<Values...:string
//>enum
for (int I = 0; I < Count; ++I) ML_CHECK_ARG_TYPE(I, MLStringT);
ml_enum_t *Enum = xnew(ml_enum_t, Count, ml_value_t *);
Enum->Base.Type = MLEnumT;
asprintf((char **)&Enum->Base.Name, "enum:%lx", (uintptr_t)Enum);
Enum->Base.deref = ml_default_deref;
Enum->Base.assign = ml_default_assign;
Enum->Base.hash = (void *)ml_enum_value_hash;
Enum->Base.call = ml_default_call;
Enum->Base.Rank = 1;
ml_type_init((ml_type_t *)Enum, MLEnumValueT, NULL);
Enum->Base.Exports[0] = (stringmap_t)STRINGMAP_INIT;
for (int I = 0; I < Count; ++I) {
ml_enum_value_t *Value = new(ml_enum_value_t);
Value->Base.Type = (ml_type_t *)Enum;
Value->Name = Args[I];
Enum->Values[I] = (ml_value_t *)Value;
Value->Base.Value = I + 1;
stringmap_insert(Enum->Base.Exports, ml_string_value(Args[I]), Value);
}
return (ml_value_t *)Enum;
}
ml_type_t *ml_enum(const char *TypeName, ...) {
va_list Args;
int Size = 0;
va_start(Args, TypeName);
while (va_arg(Args, const char *)) ++Size;
va_end(Args);
ml_enum_t *Enum = xnew(ml_enum_t, Size, ml_value_t *);
Enum->Base.Type = MLEnumT;
Enum->Base.Name = TypeName;
Enum->Base.deref = ml_default_deref;
Enum->Base.assign = ml_default_assign;
Enum->Base.hash = (void *)ml_enum_value_hash;
Enum->Base.call = ml_default_call;
Enum->Base.Rank = 1;
ml_type_init((ml_type_t *)Enum, MLEnumValueT, NULL);
Enum->Base.Exports[0] = (stringmap_t)STRINGMAP_INIT;
int Index = 0;
va_start(Args, TypeName);
const char *String;
while ((String = va_arg(Args, const char *))) {
ml_value_t *Name = ml_cstring(String);
ml_enum_value_t *Value = new(ml_enum_value_t);
Value->Base.Type = (ml_type_t *)Enum;
Value->Name = Name;
Enum->Values[Index] = (ml_value_t *)Value;
Value->Base.Value = ++Index;
stringmap_insert(Enum->Base.Exports, String, Value);
}
return (ml_type_t *)Enum;
}
static void ML_TYPED_FN(ml_value_set_name, MLEnumT, ml_enum_t *Enum, const char *Name) {
Enum->Base.Name = Name;
}
uint64_t ml_enum_value(ml_value_t *Value) {
return (uint64_t)((ml_enum_value_t *)Value)->Base.Value;
}
static void ml_enum_call(ml_state_t *Caller, ml_enum_t *Enum, int Count, ml_value_t **Args) {
ML_CHECKX_ARG_COUNT(1);
if (ml_is(Args[0], MLStringT)) {
ml_value_t *Value = stringmap_search(Enum->Base.Exports, ml_string_value(Args[0]));
if (!Value) ML_ERROR("EnumError", "Invalid enum name");
ML_RETURN(Value);
} else if (ml_is(Args[0], MLIntegerT)) {
int Index = ml_integer_value_fast(Args[0]);
if (Index <= 0 || Index > Enum->Base.Exports->Size) ML_ERROR("EnumError", "Invalid enum index");
ML_RETURN(Enum->Values[Index - 1]);
} else {
ML_ERROR("TypeError", "Expected <integer> or <string> not <%s>", ml_typeof(Args[0])->Name);
}
}
ML_TYPE(MLEnumT, (MLTypeT, MLSequenceT), "enum",
.call = (void *)ml_enum_call,
.Constructor = (void *)MLEnum
);
typedef struct {
ml_value_t *Index;
uint64_t Value;
} ml_enum_case_t;
typedef struct {
ml_type_t *Type;
ml_enum_t *Enum;
ml_enum_case_t Cases[];
} ml_enum_switch_t;
static void ml_enum_switch(ml_state_t *Caller, ml_enum_switch_t *Switch, int Count, ml_value_t **Args) {
ML_CHECKX_ARG_COUNT(1);
ml_value_t *Arg = ml_deref(Args[0]);
if (!ml_is(Arg, (ml_type_t *)Switch->Enum)) {
ML_ERROR("TypeError", "expected %s for argument 1", Switch->Enum->Base.Name);
}
uint64_t Value = ml_enum_value(Arg);
for (ml_enum_case_t *Case = Switch->Cases;; ++Case) {
if (Case->Value == Value) ML_RETURN(Case->Index);
if (Case->Value == UINT64_MAX) ML_RETURN(Case->Index);
}
ML_RETURN(MLNil);
}
ML_TYPE(MLEnumSwitchT, (MLFunctionT), "enum-switch",
//!internal
.call = (void *)ml_enum_switch
);
ML_METHODVX(MLCompilerSwitch, MLEnumT) {
//!internal
ml_enum_t *Enum = (ml_enum_t *)Args[0];
int Total = 1;
for (int I = 1; I < Count; ++I) {
ML_CHECKX_ARG_TYPE(I, MLListT);
Total += ml_list_length(Args[I]);
}
ml_enum_switch_t *Switch = xnew(ml_enum_switch_t, Total, ml_enum_case_t);
Switch->Type = MLEnumSwitchT;
Switch->Enum = Enum;
ml_enum_case_t *Case = Switch->Cases;
for (int I = 1; I < Count; ++I) {
ML_LIST_FOREACH(Args[I], Iter) {
ml_value_t *Value = Iter->Value;
if (ml_is(Value, (ml_type_t *)Enum)) {
Case->Value = ml_enum_value(Value);
} else if (ml_is(Value, MLStringT)) {
ml_value_t *EnumValue = stringmap_search(Enum->Base.Exports, ml_string_value(Value));
if (!EnumValue) ML_ERROR("EnumError", "Invalid enum name");
Case->Value = ml_enum_value(EnumValue);
} else {
ML_ERROR("ValueError", "Unsupported value in enum case");
}
Case->Index = ml_integer(I - 1);
++Case;
}
}
Case->Value = UINT64_MAX;
Case->Index = ml_integer(Count - 1);
ML_RETURN(Switch);
}
ML_METHOD("count", MLEnumT) {
//<Enum
//>integer
ml_enum_t *Enum = (ml_enum_t *)Args[0];
return ml_integer(Enum->Base.Exports->Size);
}
typedef struct {
ml_type_t *Type;
ml_value_t **Values;
int Index, Size;
} ml_enum_iter_t;
ML_TYPE(MLEnumIterT, (), "enum-iter");
//!internal
static void ML_TYPED_FN(ml_iterate, MLEnumT, ml_state_t *Caller, ml_enum_t *Enum) {
int Size = Enum->Base.Exports->Size;
if (!Size) ML_RETURN(MLNil);
ml_enum_iter_t *Iter = new(ml_enum_iter_t);
Iter->Type = MLEnumIterT;
Iter->Values = Enum->Values;
Iter->Index = 0;
Iter->Size = Size;
ML_RETURN(Iter);
}
static void ML_TYPED_FN(ml_iter_next, MLEnumIterT, ml_state_t *Caller, ml_enum_iter_t *Iter) {
if (++Iter->Index == Iter->Size) ML_RETURN(MLNil);
ML_RETURN(Iter);
}
static void ML_TYPED_FN(ml_iter_key, MLEnumIterT, ml_state_t *Caller, ml_enum_iter_t *Iter) {
ML_RETURN(ml_integer(Iter->Index + 1));
}
static void ML_TYPED_FN(ml_iter_value, MLEnumIterT, ml_state_t *Caller, ml_enum_iter_t *Iter) {
ML_RETURN(Iter->Values[Iter->Index]);
}
typedef struct {
ml_type_t *Type;
ml_value_t **Current, **Base, **Limit;
int Index, Count;
} ml_enum_range_iter_t;
ML_TYPE(MLEnumRangeIterT, (), "enum-range-iter");
typedef struct {
ml_type_t *Type;
ml_enum_t *Enum;
int Min, Max;
} ml_enum_range_t;
ML_TYPE(MLEnumRangeT, (MLSequenceT), "enum-range");
ML_METHOD("..", MLEnumValueT, MLEnumValueT) {
ml_enum_value_t *ValueA = (ml_enum_value_t *)Args[0];
ml_enum_value_t *ValueB = (ml_enum_value_t *)Args[1];
if (ValueA->Base.Type != ValueB->Base.Type) {
return ml_error("TypeError", "Enum types do not match");
}
ml_enum_range_t *Range = new(ml_enum_range_t);
Range->Type = MLEnumRangeT;
Range->Enum = (ml_enum_t *)ValueA->Base.Type;
Range->Min = ValueA->Base.Value - 1;
Range->Max = ValueB->Base.Value - 1;
return (ml_value_t *)Range;
}
static void ML_TYPED_FN(ml_iterate, MLEnumRangeT, ml_state_t *Caller, ml_enum_range_t *Range) {
int Count = Range->Max - Range->Min;
if (Count == 0) ML_RETURN(MLNil);
int Size = Range->Enum->Base.Exports->Size;
if (Count < 0) Count += Size;
ml_enum_range_iter_t *Iter = new(ml_enum_range_iter_t);
Iter->Type = MLEnumRangeIterT;
Iter->Index = 1;
Iter->Count = Count + 1;
ml_value_t **Base = Iter->Base = Range->Enum->Values;
Iter->Current = Base + Range->Min;
Iter->Limit = Base + Size;
ML_RETURN(Iter);
}
static void ML_TYPED_FN(ml_iter_next, MLEnumRangeIterT, ml_state_t *Caller, ml_enum_range_iter_t *Iter) {
if (--Iter->Count) {
++Iter->Current;
if (Iter->Current == Iter->Limit) Iter->Current = Iter->Base;
++Iter->Index;
ML_RETURN(Iter);
} else {
ML_RETURN(MLNil);
}
}
static void ML_TYPED_FN(ml_iter_key, MLEnumRangeIterT, ml_state_t *Caller, ml_enum_range_iter_t *Iter) {
ML_RETURN(ml_integer(Iter->Index));
}
static void ML_TYPED_FN(ml_iter_value, MLEnumRangeIterT, ml_state_t *Caller, ml_enum_range_iter_t *Iter) {
ML_RETURN(Iter->Current[0]);
}
typedef struct {
ml_type_t Base;
ml_value_t *Names[];
} ml_flags_t;
#ifdef ML_NANBOXING
typedef ml_int64_t ml_flags_value_t;
#else
typedef ml_integer_t ml_flags_value_t;
#endif
extern ml_type_t MLFlagsT[];
static long ml_flag_value_hash(ml_flags_value_t *Value, ml_hash_chain_t *Chain) {
return (long)Value->Type + Value->Value;
}
#ifdef ML_NANBOXING
ML_TYPE(MLFlagsValueT, (MLInt64T), "flag-value");
//!internal
#else
ML_TYPE(MLFlagsValueT, (MLIntegerT), "flag-value");
//!internal
#endif
ML_METHOD(MLStringT, MLFlagsValueT) {
ml_flags_value_t *Value = (ml_flags_value_t *)Args[0];
ml_stringbuffer_t Buffer[1] = {ML_STRINGBUFFER_INIT};
uint64_t Flags = Value->Value;
ml_value_t **Names = ((ml_flags_t *)Value->Type)->Names;
while (Flags) {
if (Flags & 1) {
if (Buffer->Length) ml_stringbuffer_add(Buffer, "|", 1);
ml_stringbuffer_add(Buffer, ml_string_value(Names[0]), ml_string_length(Names[0]));
}
++Names;
Flags >>= 1;
}
return ml_stringbuffer_value(Buffer);
}
ML_FUNCTION(MLFlags) {
//@flags
//<Values...:string
//>flags
for (int I = 0; I < Count; ++I) ML_CHECK_ARG_TYPE(I, MLStringT);
ml_flags_t *Flags = xnew(ml_flags_t, Count, ml_value_t *);
Flags->Base.Type = MLFlagsT;
asprintf((char **)&Flags->Base.Name, "flags:%lx", (uintptr_t)Flags);
Flags->Base.deref = ml_default_deref;
Flags->Base.assign = ml_default_assign;
Flags->Base.hash = (void *)ml_flag_value_hash;
Flags->Base.call = ml_default_call;
Flags->Base.Rank = 1;
ml_type_init((ml_type_t *)Flags, MLFlagsValueT, NULL);
Flags->Base.Exports[0] = (stringmap_t)STRINGMAP_INIT;
uint64_t Flag = 1;
for (int I = 0; I < Count; ++I) {
ml_flags_value_t *Value = new(ml_flags_value_t);
Value->Type = (ml_type_t *)Flags;
Flags->Names[I] = Args[I];
Value->Value = Flag;
Flag <<= 1;
stringmap_insert(Flags->Base.Exports, ml_string_value(Args[I]), Value);
}
return (ml_value_t *)Flags;
}
ml_type_t *ml_flags(const char *TypeName, ...) {
va_list Args;
int Size = 0;
va_start(Args, TypeName);
while (va_arg(Args, const char *)) ++Size;
va_end(Args);
ml_flags_t *Flags = xnew(ml_flags_t, Size, ml_value_t *);
Flags->Base.Type = MLFlagsT;
Flags->Base.Name = TypeName;
Flags->Base.deref = ml_default_deref;
Flags->Base.assign = ml_default_assign;
Flags->Base.hash = (void *)ml_flag_value_hash;
Flags->Base.call = ml_default_call;
Flags->Base.Rank = 1;
ml_type_init((ml_type_t *)Flags, MLFlagsValueT, NULL);
Flags->Base.Exports[0] = (stringmap_t)STRINGMAP_INIT;
uint64_t Flag = 1;
int Index = 0;
va_start(Args, TypeName);
const char *String;
while ((String = va_arg(Args, const char *))) {
ml_value_t *Name = ml_cstring(String);
ml_flags_value_t *Value = new(ml_flags_value_t);
Value->Type = (ml_type_t *)Flags;
Flags->Names[Index++] = Name;
Value->Value = Flag;
Flag <<= 1;
stringmap_insert(Flags->Base.Exports, String, Value);
}
return (ml_type_t *)Flags;
}
static void ML_TYPED_FN(ml_value_set_name, MLFlagsT, ml_flags_t *Flags, const char *Name) {
Flags->Base.Name = Name;
}
uint64_t ml_flags_value(ml_value_t *Value) {
return (uint64_t)((ml_flags_value_t *)Value)->Value;
}
static void ml_flags_call(ml_state_t *Caller, ml_flags_t *Flags, int Count, ml_value_t **Args) {
ml_flags_value_t *Value = new(ml_flags_value_t);
Value->Type = (ml_type_t *)Flags;
for (int I = 0; I < Count; ++I) {
if (ml_is(Args[I], MLStringT)) {
ml_value_t *Flag = stringmap_search(Flags->Base.Exports, ml_string_value(Args[I]));
if (!Flag) ML_ERROR("FlagError", "Invalid flag name");
Value->Value |= ml_flags_value(Flag);
} else if (ml_is(Args[I], MLIntegerT)) {
uint64_t Flag = ml_integer_value_fast(Args[I]);
if (Flag >= (1L << Flags->Base.Exports->Size)) ML_ERROR("FlagError", "Invalid flags value");
Value->Value |= Flag;
} else {
ML_ERROR("TypeError", "Expected <integer> or <string> not <%s>", ml_typeof(Args[0])->Name);
}
}
ML_RETURN(Value);
}
ML_TYPE(MLFlagsT, (MLTypeT), "flags",
.call = (void *)ml_flags_call,
.Constructor = (void *)MLFlags
);
typedef struct {
ml_value_t *Index;
uint64_t Value;
} ml_flags_case_t;
typedef struct {
ml_type_t *Type;
ml_flags_t *Flags;
ml_flags_case_t Cases[];
} ml_flags_switch_t;
static void ml_flags_switch(ml_state_t *Caller, ml_flags_switch_t *Switch, int Count, ml_value_t **Args) {
ML_CHECKX_ARG_COUNT(1);
ml_value_t *Arg = ml_deref(Args[0]);
if (!ml_is(Arg, (ml_type_t *)Switch->Flags)) {
ML_ERROR("TypeError", "expected %s for argument 1", Switch->Flags->Base.Name);
}
uint64_t Value = ml_enum_value(Arg);
for (ml_flags_case_t *Case = Switch->Cases;; ++Case) {
if ((Case->Value & Value) == Case->Value) ML_RETURN(Case->Index);
}
ML_RETURN(MLNil);
}
ML_TYPE(MLFlagsSwitchT, (MLFunctionT), "flags-switch",
//!internal
.call = (void *)ml_flags_switch
);
ML_METHODVX(MLCompilerSwitch, MLFlagsT) {
//!internal
ml_flags_t *Flags = (ml_flags_t *)Args[0];
int Total = 1;
for (int I = 1; I < Count; ++I) {
ML_CHECKX_ARG_TYPE(I, MLListT);
Total += ml_list_length(Args[I]);
}
ml_flags_switch_t *Switch = xnew(ml_flags_switch_t, Total, ml_flags_case_t);
Switch->Type = MLFlagsSwitchT;
Switch->Flags = Flags;
ml_flags_case_t *Case = Switch->Cases;
for (int I = 1; I < Count; ++I) {
ML_LIST_FOREACH(Args[I], Iter) {
ml_value_t *Value = Iter->Value;
if (ml_is(Value, (ml_type_t *)Flags)) {
Case->Value = ml_flags_value(Value);
} else if (ml_is(Value, MLStringT)) {
ml_value_t *FlagsValue = stringmap_search(Flags->Base.Exports, ml_string_value(Value));
if (!FlagsValue) ML_ERROR("FlagsError", "Invalid flags name");
Case->Value = ml_flags_value(FlagsValue);
} else if (ml_is(Value, MLTupleT)) {
ml_tuple_t *Tuple = (ml_tuple_t *)Value;
for (int J = 0; J < Tuple->Size; ++J) {
ml_value_t *Value = Tuple->Values[J];
if (!ml_is(Value, MLStringT)) ML_ERROR("ValueError", "Unsupported value in flags case");
ml_value_t *FlagsValue = stringmap_search(Flags->Base.Exports, ml_string_value(Tuple->Values[J]));
if (!FlagsValue) ML_ERROR("FlagsError", "Invalid flags name");
Case->Value |= ml_flags_value(FlagsValue);
}
} else {
ML_ERROR("ValueError", "Unsupported value in flags case");
}
Case->Index = ml_integer(I - 1);
++Case;
}
}
Case->Value = 0;
Case->Index = ml_integer(Count - 1);
ML_RETURN(Switch);
}
ML_METHOD("+", MLFlagsValueT, MLFlagsValueT) {
ml_flags_value_t *A = (ml_flags_value_t *)Args[0];
ML_CHECK_ARG_TYPE(1, A->Type);
ml_flags_value_t *B = (ml_flags_value_t *)Args[1];
ml_flags_value_t *C = new(ml_flags_value_t);
C->Type = A->Type;
C->Value = A->Value | B->Value;
return (ml_value_t *)C;
}
ML_METHOD("-", MLFlagsValueT, MLFlagsValueT) {
ml_flags_value_t *A = (ml_flags_value_t *)Args[0];
ML_CHECK_ARG_TYPE(1, A->Type);
ml_flags_value_t *B = (ml_flags_value_t *)Args[1];
ml_flags_value_t *C = new(ml_flags_value_t);
C->Type = A->Type;
C->Value = A->Value & ~B->Value;
return (ml_value_t *)C;
}
ML_METHOD("<", MLFlagsValueT, MLFlagsValueT) {
ml_flags_value_t *A = (ml_flags_value_t *)Args[0];
ML_CHECK_ARG_TYPE(1, A->Type);
ml_flags_value_t *B = (ml_flags_value_t *)Args[1];
if ((A->Value & B->Value) == A->Value) {
return Args[1];
} else {
return MLNil;
}
}
ML_METHOD("<=", MLFlagsValueT, MLFlagsValueT) {
ml_flags_value_t *A = (ml_flags_value_t *)Args[0];
ML_CHECK_ARG_TYPE(1, A->Type);
ml_flags_value_t *B = (ml_flags_value_t *)Args[1];
if ((A->Value & B->Value) == A->Value) {
return Args[1];
} else {
return MLNil;
}
}
ML_METHOD(">", MLFlagsValueT, MLFlagsValueT) {
ml_flags_value_t *A = (ml_flags_value_t *)Args[0];
ML_CHECK_ARG_TYPE(1, A->Type);
ml_flags_value_t *B = (ml_flags_value_t *)Args[1];
if ((A->Value & B->Value) == B->Value) {
return Args[1];
} else {
return MLNil;
}
}
ML_METHOD(">=", MLFlagsValueT, MLFlagsValueT) {
ml_flags_value_t *A = (ml_flags_value_t *)Args[0];
ML_CHECK_ARG_TYPE(1, A->Type);
ml_flags_value_t *B = (ml_flags_value_t *)Args[1];
if ((A->Value & B->Value) == B->Value) {
return Args[1];
} else {
return MLNil;
}
}
void ml_object_init(stringmap_t *Globals) {
#include "ml_object_init.c"
if (Globals) {
stringmap_insert(Globals, "property", MLPropertyT);
stringmap_insert(Globals, "object", MLObjectT);
stringmap_insert(Globals, "class", MLClassT);
stringmap_insert(Globals, "enum", MLEnumT);
stringmap_insert(Globals, "flags", MLFlagsT);
}
}
| 31.28091 | 329 | 0.697834 |
4bc510c4afc6513635e07854da6526264618f9b5 | 235 | h | C | src/plane.h | jansedivy/opengl-game | 0b7c8a9313687d67ed96edc9f2fd34ea7363012e | [
"MIT"
] | 13 | 2015-10-27T22:43:19.000Z | 2022-01-07T14:44:56.000Z | src/plane.h | jansedivy/opengl-game | 0b7c8a9313687d67ed96edc9f2fd34ea7363012e | [
"MIT"
] | null | null | null | src/plane.h | jansedivy/opengl-game | 0b7c8a9313687d67ed96edc9f2fd34ea7363012e | [
"MIT"
] | 1 | 2022-01-07T14:45:15.000Z | 2022-01-07T14:45:15.000Z | #pragma once
struct Plane {
vec3 normal;
float distance;
};
struct Frustum {
Plane planes[6];
};
enum FrustumPlaneType {
LeftPlane = 0,
RightPlane = 1,
TopPlane = 2,
BottomPlane = 3,
NearPlane = 4,
FarPlane = 5
};
| 11.75 | 23 | 0.638298 |
4be3da8cf82b8dfe3185c9016bde4b3a53c286c5 | 17,614 | c | C | edk2-platforms/Silicon/Hisilicon/Hi1616/Pptt/Pptt.c | TheMindVirus/pftf-rpi4 | 6070b65a02e5ab3ad774d52620c1d136f17c5df3 | [
"BSD-2-Clause-Patent",
"MIT"
] | 1 | 2021-12-03T05:07:39.000Z | 2021-12-03T05:07:39.000Z | edk2-platforms/Silicon/Hisilicon/Hi1616/Pptt/Pptt.c | TheMindVirus/pftf-rpi4 | 6070b65a02e5ab3ad774d52620c1d136f17c5df3 | [
"BSD-2-Clause-Patent",
"MIT"
] | null | null | null | edk2-platforms/Silicon/Hisilicon/Hi1616/Pptt/Pptt.c | TheMindVirus/pftf-rpi4 | 6070b65a02e5ab3ad774d52620c1d136f17c5df3 | [
"BSD-2-Clause-Patent",
"MIT"
] | null | null | null | /** @file
*
* Copyright (c) 2018, Hisilicon Limited. All rights reserved.
* Copyright (c) 2018, Linaro Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
* Based on the files under Platform/ARM/JunoPkg/AcpiTables/
*
**/
#include "Pptt.h"
EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol = NULL;
EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol = NULL;
EFI_ACPI_DESCRIPTION_HEADER mPpttHeader =
ARM_ACPI_HEADER (
EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE,
EFI_ACPI_DESCRIPTION_HEADER,
EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_REVISION
);
EFI_ACPI_6_2_PPTT_STRUCTURE_ID mPpttSocketType2[PPTT_SOCKET_COMPONENT_NO] =
{
{2, sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_ID), {0, 0}, PPTT_VENDOR_ID, 0, 0, 0, 0, 0}
};
EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE mPpttCacheType1[PPTT_CACHE_NO];
STATIC
VOID
InitCacheInfo (
VOID
)
{
UINT8 Index;
EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE_ATTRIBUTES Type1Attributes;
CSSELR_DATA CsselrData;
CCSIDR_DATA CcsidrData;
for (Index = 0; Index < PPTT_CACHE_NO; Index++) {
CsselrData.Data = 0;
CcsidrData.Data = 0;
SetMem (
&Type1Attributes,
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE_ATTRIBUTES),
0
);
if (Index == 0) { //L1I
CsselrData.Bits.InD = 1;
CsselrData.Bits.Level = 0;
Type1Attributes.CacheType = 1;
} else if (Index == 1) {
Type1Attributes.CacheType = 0;
CsselrData.Bits.Level = Index - 1;
} else {
Type1Attributes.CacheType = 2;
CsselrData.Bits.Level = Index - 1;
}
CcsidrData.Data = ReadCCSIDR (CsselrData.Data);
if (CcsidrData.Bits.Wa == 1) {
Type1Attributes.AllocationType = EFI_ACPI_6_2_CACHE_ATTRIBUTES_ALLOCATION_WRITE;
if (CcsidrData.Bits.Ra == 1) {
Type1Attributes.AllocationType = EFI_ACPI_6_2_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE;
}
}
if (CcsidrData.Bits.Wt == 1) {
Type1Attributes.WritePolicy = 1;
}
DEBUG ((DEBUG_INFO,
"[Acpi PPTT] Level = %x!CcsidrData = %x!\n",
CsselrData.Bits.Level,
CcsidrData.Data));
mPpttCacheType1[Index].Type = EFI_ACPI_6_2_PPTT_TYPE_CACHE;
mPpttCacheType1[Index].Length = sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE);
mPpttCacheType1[Index].Reserved[0] = 0;
mPpttCacheType1[Index].Reserved[1] = 0;
mPpttCacheType1[Index].Flags.SizePropertyValid = 1;
mPpttCacheType1[Index].Flags.NumberOfSetsValid = 1;
mPpttCacheType1[Index].Flags.AssociativityValid = 1;
mPpttCacheType1[Index].Flags.AllocationTypeValid = 1;
mPpttCacheType1[Index].Flags.CacheTypeValid = 1;
mPpttCacheType1[Index].Flags.WritePolicyValid = 1;
mPpttCacheType1[Index].Flags.LineSizeValid = 1;
mPpttCacheType1[Index].Flags.Reserved = 0;
mPpttCacheType1[Index].NextLevelOfCache = 0;
if (Index != PPTT_CACHE_NO - 1) {
mPpttCacheType1[Index].NumberOfSets = (UINT16)CcsidrData.Bits.NumSets + 1;
mPpttCacheType1[Index].Associativity = (UINT16)CcsidrData.Bits.Associativity + 1;
mPpttCacheType1[Index].LineSize = (UINT16)( 1 << (CcsidrData.Bits.LineSize + 4));
mPpttCacheType1[Index].Size = mPpttCacheType1[Index].LineSize * \
mPpttCacheType1[Index].Associativity * \
mPpttCacheType1[Index].NumberOfSets;
CopyMem (
&mPpttCacheType1[Index].Attributes,
&Type1Attributes,
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE_ATTRIBUTES)
);
} else {
// L3 cache
mPpttCacheType1[Index].Size = 0x1000000; // 16m
mPpttCacheType1[Index].NumberOfSets = 0x2000;
mPpttCacheType1[Index].Associativity = 0x10; // CacheAssociativity16Way
SetMem (
&mPpttCacheType1[Index].Attributes,
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE_ATTRIBUTES),
0x0A
);
mPpttCacheType1[Index].LineSize = 0x80; // 128byte
}
}
}
STATIC
EFI_STATUS
AddCoreTable (
IN EFI_ACPI_DESCRIPTION_HEADER *PpttTable,
IN OUT UINT32 *PpttTableLengthRemain,
IN UINT32 Parent,
IN UINT32 ResourceNo,
IN UINT32 ProcessorId
)
{
EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR *PpttType0;
EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *PpttType1;
UINT32 *PrivateResource;
UINT8 Index;
if (*PpttTableLengthRemain <
(sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR) + ResourceNo * 4)) {
return EFI_OUT_OF_RESOURCES;
}
PpttType0 = (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR *)((UINT8 *)PpttTable +
PpttTable->Length);
PpttType0->Type = 0;
SetMem (&PpttType0->Flags, sizeof (PpttType0->Flags), 0);
PpttType0->Flags.AcpiProcessorIdValid = EFI_ACPI_6_2_PPTT_PROCESSOR_ID_VALID;
PpttType0->Parent= Parent;
PpttType0->AcpiProcessorId = ProcessorId;
PpttType0->NumberOfPrivateResources = ResourceNo;
PpttType0->Length = sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR) +
ResourceNo * 4;
*PpttTableLengthRemain -= (UINTN)PpttType0->Length;
PpttTable->Length += PpttType0->Length;
PrivateResource = (UINT32 *)((UINT8 *)PpttType0 +
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR));
// Add cache type structure
for (Index = 0; Index < ResourceNo; Index++, PrivateResource++) {
if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE)) {
return EFI_OUT_OF_RESOURCES;
}
*PrivateResource = PpttTable->Length;
PpttType1 = (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *)((UINT8 *)PpttTable +
PpttTable->Length);
gBS->CopyMem (
PpttType1,
&mPpttCacheType1[Index],
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE)
);
*PpttTableLengthRemain -= PpttType1->Length;
PpttTable->Length += PpttType1->Length;
}
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
AddClusterTable (
IN EFI_ACPI_DESCRIPTION_HEADER *PpttTable,
IN OUT UINT32 *PpttTableLengthRemain,
IN UINT32 Parent,
IN UINT32 ResourceNo
)
{
EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR *PpttType0;
EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *PpttType1;
UINT32 *PrivateResource;
if ((*PpttTableLengthRemain) <
(sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR) + ResourceNo * 4)) {
return EFI_OUT_OF_RESOURCES;
}
PpttType0 = (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR *)((UINT8 *)PpttTable +
PpttTable->Length);
PpttType0->Type = 0;
SetMem (&PpttType0->Flags, sizeof (PpttType0->Flags), 0);
PpttType0->Parent= Parent;
PpttType0->NumberOfPrivateResources = ResourceNo;
PpttType0->Length = sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR) +
ResourceNo * 4;
*PpttTableLengthRemain -= PpttType0->Length;
PpttTable->Length += PpttType0->Length;
PrivateResource = (UINT32 *)((UINT8 *)PpttType0 +
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR));
// Add cache type structure
if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE)) {
return EFI_OUT_OF_RESOURCES;
}
*PrivateResource = PpttTable->Length;
PpttType1 = (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *)((UINT8 *)PpttTable +
PpttTable->Length);
gBS->CopyMem (
PpttType1,
&mPpttCacheType1[2],
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE)
);
*PpttTableLengthRemain -= PpttType1->Length;
PpttTable->Length += PpttType1->Length;
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
AddScclTable (
IN EFI_ACPI_DESCRIPTION_HEADER *PpttTable,
IN OUT UINT32 *PpttTableLengthRemain,
IN UINT32 Parent,
IN UINT32 ResourceNo
)
{
EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR *PpttType0;
EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *PpttType1;
UINT32 *PrivateResource;
if (*PpttTableLengthRemain <
(sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR) + ResourceNo * 4)) {
return EFI_OUT_OF_RESOURCES;
}
PpttType0 = (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR *)((UINT8 *)PpttTable +
PpttTable->Length);
PpttType0->Type = 0;
SetMem (&PpttType0->Flags, sizeof (PpttType0->Flags), 0);
PpttType0->Parent= Parent;
PpttType0->NumberOfPrivateResources = ResourceNo;
PpttType0->Length = sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR) +
ResourceNo * 4;
*PpttTableLengthRemain -= PpttType0->Length;
PpttTable->Length += PpttType0->Length;
PrivateResource = (UINT32 *)((UINT8 *)PpttType0 +
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR));
// Add cache type structure
if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE)) {
return EFI_OUT_OF_RESOURCES;
}
*PrivateResource = PpttTable->Length;
PpttType1 = (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *)((UINT8 *)PpttTable +
PpttTable->Length);
gBS->CopyMem (
PpttType1,
&mPpttCacheType1[3],
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE)
);
*PpttTableLengthRemain -= PpttType1->Length;
PpttTable->Length += PpttType1->Length;
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
AddSocketTable (
IN EFI_ACPI_DESCRIPTION_HEADER *PpttTable,
IN OUT UINT32 *PpttTableLengthRemain,
IN UINT32 Parent,
IN UINT32 ResourceNo
)
{
EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR *PpttType0;
EFI_ACPI_6_2_PPTT_STRUCTURE_ID *PpttType2;
UINT32 *PrivateResource;
UINT8 Index;
if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR)) {
return EFI_OUT_OF_RESOURCES;
}
PpttType0 = (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR *)((UINT8 *)PpttTable +
PpttTable->Length);
PpttType0->Type = 0;
SetMem (&PpttType0->Flags, sizeof (PpttType0->Flags), 0);
PpttType0->Flags.PhysicalPackage = EFI_ACPI_6_2_PPTT_PROCESSOR_ID_VALID;
PpttType0->Parent= Parent;
PpttType0->NumberOfPrivateResources = ResourceNo;
PpttType0->Length = sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR) +
ResourceNo * 4;
PpttTable->Length += PpttType0->Length;
*PpttTableLengthRemain -= PpttType0->Length;
if (*PpttTableLengthRemain < ResourceNo * 4) {
return EFI_OUT_OF_RESOURCES;
}
PrivateResource = (UINT32 *)((UINT8 *)PpttType0 +
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_PROCESSOR));
DEBUG ((DEBUG_INFO,
"[Acpi PPTT] sizeof(EFI_ACPI_6_2_PPTT_STRUCTURE_ID) = %x!\n",
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_ID)));
for (Index = 0; Index < ResourceNo; Index++, PrivateResource++) {
if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_ID)) {
return EFI_OUT_OF_RESOURCES;
}
*PrivateResource = PpttTable->Length;
PpttType2 = (EFI_ACPI_6_2_PPTT_STRUCTURE_ID *)((UINT8 *)PpttTable +
PpttTable->Length);
gBS->CopyMem (
PpttType2,
&mPpttSocketType2[Index],
sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_ID)
);
*PpttTableLengthRemain -= PpttType2->Length;
PpttTable->Length += PpttType2->Length;
}
return EFI_SUCCESS;
}
STATIC
VOID
GetApic (
IN EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE *ApicTable,
IN OUT EFI_ACPI_DESCRIPTION_HEADER *PpttTable,
IN UINT32 PpttTableLengthRemain,
IN UINT32 Index1
)
{
UINT32 IndexSocket, IndexSccl, IndexCluster, IndexCore;
UINT32 SocketOffset, ScclOffset, ClusterOffset;
UINT32 Parent = 0;
UINT32 ResourceNo = 0;
// Get APIC data
for (IndexSocket = 0; IndexSocket < PPTT_SOCKET_NO; IndexSocket++) {
SocketOffset = 0;
for (IndexSccl = 0; IndexSccl < PPTT_SCCL_NO; IndexSccl++) {
ScclOffset = 0;
for (IndexCluster = 0; IndexCluster < PPTT_CLUSTER_NO; IndexCluster++) {
ClusterOffset = 0;
for (IndexCore = 0; IndexCore < PPTT_CORE_NO; IndexCore++) {
if (ApicTable->GicInterfaces[Index1].AcpiProcessorUid != Index1) {
// This processor is unusable
DEBUG ((DEBUG_ERROR, "[Acpi PPTT] Please check MADT table for UID!\n"));
return;
}
if ((ApicTable->GicInterfaces[Index1].Flags & BIT0) == 0) {
// This processor is unusable
Index1++;
continue;
}
if (SocketOffset == 0) {
// Add socket0 for type0 table
ResourceNo = PPTT_SOCKET_COMPONENT_NO;
SocketOffset = PpttTable->Length;
Parent = 0;
AddSocketTable (
PpttTable,
&PpttTableLengthRemain,
Parent,
ResourceNo
);
}
if (ScclOffset == 0) {
// Add socket0sccl0 for type0 table
ResourceNo = 1;
ScclOffset = PpttTable->Length;
Parent = SocketOffset;
AddScclTable (
PpttTable,
&PpttTableLengthRemain,
Parent,
ResourceNo
);
}
if (ClusterOffset == 0) {
// Add socket0sccl0ClusterId for type0 table
ResourceNo = 1;
ClusterOffset = PpttTable->Length ;
Parent = ScclOffset;
AddClusterTable (
PpttTable,
&PpttTableLengthRemain,
Parent,
ResourceNo
);
}
// Add socket0sccl0ClusterIdCoreId for type0 table
ResourceNo = 2;
Parent = ClusterOffset;
AddCoreTable (
PpttTable,
&PpttTableLengthRemain,
Parent,
ResourceNo,
Index1
);
Index1++;
}
}
}
}
return ;
}
STATIC
VOID
PpttSetAcpiTable (
IN EFI_EVENT Event,
IN VOID *Context
)
{
UINTN AcpiTableHandle;
EFI_STATUS Status;
UINT8 Checksum;
EFI_ACPI_SDT_HEADER *Table;
EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE *ApicTable;
EFI_ACPI_TABLE_VERSION TableVersion;
EFI_ACPI_DESCRIPTION_HEADER *PpttTable;
UINTN TableKey;
UINT32 Index0, Index1;
UINT32 PpttTableLengthRemain = 0;
gBS->CloseEvent (Event);
InitCacheInfo ();
PpttTable = (EFI_ACPI_DESCRIPTION_HEADER *)AllocateZeroPool (PPTT_TABLE_MAX_LEN);
gBS->CopyMem (
(VOID *)PpttTable,
&mPpttHeader,
sizeof (EFI_ACPI_DESCRIPTION_HEADER)
);
PpttTableLengthRemain = PPTT_TABLE_MAX_LEN - sizeof (EFI_ACPI_DESCRIPTION_HEADER);
for (Index0 = 0; Index0 < EFI_ACPI_MAX_NUM_TABLES; Index0++) {
Status = mAcpiSdtProtocol->GetAcpiTable (
Index0,
&Table,
&TableVersion,
&TableKey
);
if (EFI_ERROR (Status)) {
break;
}
// Find APIC table
if (Table->Signature == EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE) {
break;
}
}
if (!EFI_ERROR (Status) && (Index0 != EFI_ACPI_MAX_NUM_TABLES)) {
ApicTable = (EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE *)Table;
Index1 = 0;
GetApic (ApicTable, PpttTable, PpttTableLengthRemain, Index1);
Checksum = CalculateCheckSum8 ((UINT8 *)(PpttTable), PpttTable->Length);
PpttTable->Checksum = Checksum;
AcpiTableHandle = 0;
Status = mAcpiTableProtocol->InstallAcpiTable (
mAcpiTableProtocol,
PpttTable,
PpttTable->Length,
&AcpiTableHandle);
}
FreePool (PpttTable);
return ;
}
EFI_STATUS
EFIAPI
PpttEntryPoint(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_EVENT ReadyToBootEvent;
Status = gBS->LocateProtocol (
&gEfiAcpiTableProtocolGuid,
NULL,
(VOID **)&mAcpiTableProtocol);
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (
&gEfiAcpiSdtProtocolGuid,
NULL,
(VOID **)&mAcpiSdtProtocol);
ASSERT_EFI_ERROR (Status);
Status = EfiCreateEventReadyToBootEx (
TPL_NOTIFY,
PpttSetAcpiTable,
NULL,
&ReadyToBootEvent
);
ASSERT_EFI_ERROR (Status);
DEBUG ((DEBUG_INFO, "Acpi Pptt init done.\n"));
return Status;
}
| 33.614504 | 93 | 0.601056 |
895a3e1517009d4c46dc80f74ba98c88cc1acee7 | 676 | h | C | src/Network/mlp.h | wt-student-projects/computer-game-ai | 33eb9e5334f64a4290c1196b2a2709c71bc1917b | [
"Apache-2.0"
] | 1 | 2019-10-13T02:56:45.000Z | 2019-10-13T02:56:45.000Z | src/Network/mlp.h | bsc-william-taylor/computer-game-ai | 33eb9e5334f64a4290c1196b2a2709c71bc1917b | [
"Apache-2.0"
] | 1 | 2017-04-08T20:50:57.000Z | 2017-04-09T00:57:49.000Z | src/Network/mlp.h | wt-student-projects/computer-game-ai | 33eb9e5334f64a4290c1196b2a2709c71bc1917b | [
"Apache-2.0"
] | null | null | null |
#pragma once
#include "neural-network.h"
#include "Nodes.h"
#include "Graph.h"
class MLP : public NeuralNetwork
{
TrainingData trainingSet;
HiddenLayerMLP hiddenNeurons;
OutputLayer outputNeurons;
InputLayer inputNeurons;
double errorThreshold;
double learningRate;
public:
MLP();
virtual ~MLP();
int chooseInputPattern(int, std::vector<bool>& vec);
MLP* setOutputLayer(OutputLayer outputLayer);
MLP* setHiddenLayer(HiddenLayerMLP hiddenLayer);
MLP* setInputLayer(InputLayer inputLayer);
MLP* setTrainingSet(TrainingData trainingSet);
MLP* setErrorThreshold(double);
MLP* setLearningRate(double);
MLP* train(int);
double fx(double);
};
| 20.484848 | 56 | 0.752959 |
c7053efa1023bb8f487e40b8fa8e0f9248faeedd | 485 | h | C | VulkanSetup/CCDIKSolver.h | NEtuee/AnimationEngine | feb7d974edf9cb19725578cae1bcda35a0edc683 | [
"MIT"
] | null | null | null | VulkanSetup/CCDIKSolver.h | NEtuee/AnimationEngine | feb7d974edf9cb19725578cae1bcda35a0edc683 | [
"MIT"
] | null | null | null | VulkanSetup/CCDIKSolver.h | NEtuee/AnimationEngine | feb7d974edf9cb19725578cae1bcda35a0edc683 | [
"MIT"
] | null | null | null | #pragma once
#include "IKSolver.h"
#include "DirectXDefine.h"
#include <vector>
class TransformStructure;
class CCDIKSolver : public IKSolver
{
public:
virtual void createIKSolver(TransformStructure* effecter, TransformStructure* root, TransformStructure* target) override;
virtual void destroyIKSolver() override;
virtual void solve() override;
private:
std::vector<TransformStructure*> _joints;
float _completeLength;
float _deltaDistance;
int _iteration;
};
| 23.095238 | 123 | 0.773196 |
8159643692e5ea9e43af21b3c5360e262c7fa382 | 12,273 | h | C | src/nrnoc/section.h | nrnhines/nrntmp | f193941757a0fd1e7a343678c6d74e7930ce84bb | [
"BSD-3-Clause"
] | null | null | null | src/nrnoc/section.h | nrnhines/nrntmp | f193941757a0fd1e7a343678c6d74e7930ce84bb | [
"BSD-3-Clause"
] | null | null | null | src/nrnoc/section.h | nrnhines/nrntmp | f193941757a0fd1e7a343678c6d74e7930ce84bb | [
"BSD-3-Clause"
] | null | null | null | /* /local/src/master/nrn/src/nrnoc/section.h,v 1.4 1996/05/21 17:09:24 hines Exp */
#ifndef section_h
#define section_h
/* In order to support oc objects containing sections, instead of vector
of ordered sections, we now have a list (in the nmodl sense)
of unordered sections. The lesser efficiency is ok because the
number crunching is vectorized. ie only the user interface deals
with sections and that needs to be convenient
*/
/* Data structure for solving branching 1-D tree diffusion type equations.
Vector of ordered sections each of which points to a vector of nodes.
Each section must have at least one node. There may be 0 sections.
The order of last node to first node is used in triangularization.
First node to last is used in back substitution.
The first node of a section is connected to some node of a section
with lesser index.
*/
/* An equation is associated with each node. d and rhs are the diagonal and
right hand side respectively. a is the effect of this node on the parent
node's equation. b is the effect of the parent node on this node's
equation.
d is assumed to be non-zero.
d and rhs is calculated from the property list.
*/
#if defined(__cplusplus)
extern "C" {
#endif
#include "nrnredef.h"
#include "options.h"
#include "hoclist.h"
/*#define DEBUGSOLVE 1*/
#define xpop hoc_xpop
#define pc hoc_pc
#define spop hoc_spop
#define execerror hoc_execerror
#include "hocdec.h"
typedef struct Section {
int refcount; /* may be in more than one list */
short nnode; /* Number of nodes for ith section */
struct Section* parentsec; /* parent section of node 0 */
struct Section* child; /* root of the list of children
connected to this parent kept in
order of increasing x */
struct Section* sibling; /* used as list of sections that have same parent */
/* the parentnode is only valid when tree_changed = 0 */
struct Node* parentnode; /* parent node */
struct Node** pnode; /* Pointer to pointer vector of node structures */
int order; /* index of this in secorder vector */
short recalc_area_; /* NODEAREA, NODERINV, diam, L need recalculation */
short volatile_mark; /* for searching */
void* volatile_ptr; /* e.g. ShapeSection* */
#if DIAMLIST
short npt3d; /* number of 3-d points */
short pt3d_bsize; /* amount of allocated space for 3-d points */
struct Pt3d *pt3d; /* list of 3d points with diameter */
struct Pt3d *logical_connection; /* nil for legacy, otherwise specifies logical connection position (for translation) */
#endif
struct Prop *prop; /* eg. length, etc. */
} Section;
#if DIAMLIST
typedef struct Pt3d {
float x,y,z,d; /* 3d point, microns */
double arc;
} Pt3d;
#endif
#if METHOD3
typedef float NodeCoef;
typedef double NodeVal;
typedef struct Info3Coef {
NodeVal current; /* for use in next time step */
NodeVal djdv0;
NodeCoef coef0; /* 5dx/12 */
NodeCoef coefn; /* 1dx/12 */
NodeCoef coefjdot; /* dx^2*ra/12 */
NodeCoef coefdg; /* dx/12 */
NodeCoef coefj; /* 1/(ra*dx) */
struct Node* nd2; /* the node dx away in the opposite direction*/
/* note above implies that nodes next to branches cannot have point processes
and still be third order correct. Also nodes next to branches cannot themselves
be branch points */
} Info3Coef;
typedef struct Info3Val { /* storage to help build matrix efficiently */
NodeVal GC; /* doesn't include point processes */
NodeVal EC;
NodeCoef Cdt;
} Info3Val;
/*METHOD3*/
#endif
/* if any double is added after area then think about changing
the notify_free_val parameter in node_free in solve.c
*/
#define NODED(n) (*((n)->_d))
#define NODERHS(n) (*((n)->_rhs))
#undef NODEV /* sparc-sun-solaris2.9 */
#if CACHEVEC == 0
#define NODEA(n) ((n)->_a)
#define NODEB(n) ((n)->_b)
#define NODEV(n) ((n)->_v)
#define NODEAREA(n) ((n)->_area)
#else /* CACHEVEC */
#define NODEV(n) (*((n)->_v))
#define NODEAREA(n) ((n)->_area)
#define NODERINV(n) ((n)->_rinv)
#define VEC_A(i) (_nt->_actual_a[(i)])
#define VEC_B(i) (_nt->_actual_b[(i)])
#define VEC_D(i) (_nt->_actual_d[(i)])
#define VEC_RHS(i) (_nt->_actual_rhs[(i)])
#define VEC_V(i) (_nt->_actual_v[(i)])
#define VEC_AREA(i) (_nt->_actual_area[(i)])
#define NODEA(n) (VEC_A((n)->v_node_index))
#define NODEB(n) (VEC_B((n)->v_node_index))
#endif /* CACHEVEC */
extern int use_sparse13;
extern int use_cachevec;
typedef struct Node {
#if CACHEVEC == 0
double _v; /* membrane potential */
double _area; /* area in um^2 but see treesetup.c */
double _a; /* effect of node in parent equation */
double _b; /* effect of parent in node equation */
#else /* CACHEVEC */
double *_v; /* membrane potential */
double _area; /* area in um^2 but see treesetup.c */
double _rinv; /* conductance uS from node to parent */
double _v_temp; /* vile necessity til actual_v allocated */
#endif /* CACHEVEC */
double* _d; /* diagonal element in node equation */
double* _rhs; /* right hand side in node equation */
double* _a_matelm;
double* _b_matelm;
int eqn_index_; /* sparse13 matrix row/col index */
/* if no extnodes then = v_node_index +1*/
/* each extnode adds nlayer more equations after this */
struct Prop *prop; /* Points to beginning of property list */
Section* child; /* section connected to this node */
/* 0 means no other section connected */
Section* sec; /* section this node is in */
/* #if PARANEURON */
struct Node* _classical_parent; /* needed for multisplit */
struct NrnThread* _nt;
/* #endif */
#if EXTRACELLULAR
struct Extnode* extnode;
#endif
#if EXTRAEQN
struct Eqnblock *eqnblock; /* hook to other equations which
need to be solved at the same time as the membrane
potential. eg. fast changeing ionic concentrations */
#endif /*MOREEQN*/
#if DEBUGSOLVE
double savd;
double savrhs;
#endif /*DEBUGSOLVE*/
#if VECTORIZE
int v_node_index; /* only used to calculate parent_node_indices*/
#endif
int sec_node_index_; /* to calculate segment index from *Node */
#if METHOD3
Info3Coef toparent;
Info3Coef fromparent;
Info3Val thisnode;
#endif
} Node;
#if EXTRACELLULAR
/* pruned to only work with sparse13 */
#define nlayer (EXTRACELLULAR) /* first (0) layer is extracellular next to membrane */
/*
changing nlayer here means you have to change the explicit numbers
nlayer-1 in the mechanism structure in extcell.c
*/
typedef struct Extnode {
double *param; /* points to extracellular parameter vector */
/* v is membrane potential. so v internal = Node.v + Node.vext[0] */
/* However, the Node equation is for v internal. */
/* This is reconciled during update. */
double v[nlayer]; /* v external. */
double _a[nlayer];
double _b[nlayer];
double* _d[nlayer];
double* _rhs[nlayer]; /* d, rhs, a, and b are analogous to those in node */
double* _a_matelm[nlayer];
double* _b_matelm[nlayer];
double* _x12[nlayer]; /* effect of v[layer] on eqn layer-1 (or internal)*/
double* _x21[nlayer]; /* effect of v[layer-1 or internal] on eqn layer*/
} Extnode;
#endif
#if !INCLUDEHOCH
#include "hocdec.h" /* Prop needs Datum and Datum needs Symbol */
#endif
#define PROP_PY_INDEX 10
typedef struct Prop {
struct Prop *next; /* linked list of properties */
short type; /* type of membrane, e.g. passive, HH, etc. */
short unused1; /* gcc and borland need pairs of shorts to align the same.*/
int param_size; /* for notifying hoc_free_val_array */
double *param; /* vector of doubles for this property */
Datum *dparam; /* usually vector of pointers to doubles
of other properties but maybe other things as well
for example one cable section property is a
symbol */
long _alloc_seq; /* for cache efficiency */
Object* ob; /* nil if normal property, otherwise the object containing the data*/
} Prop;
extern double* nrn_prop_data_alloc(int type, int count, Prop* p);
extern Datum* nrn_prop_datum_alloc(int type, int count, Prop* p);
extern void nrn_prop_data_free(int type, double* pd);
extern void nrn_prop_datum_free(int type, Datum* ppd);
/* a point process is computed just like regular mechanisms. Ie it appears
in the property list whose type specifies which allocation, current, and
state functions to call. This means some nodes have more properties than
other nodes even in the same section. The Point_process structure allows
the interface to hoc variable names.
Each variable symbol u.rng->type refers to the point process mechanism.
The variable is treated as a vector
variable whose first index specifies "which one" of that mechanisms insertion
points we are talking about. Finally the variable u.rng->index tells us
where in the p-array to look. The number of point_process vectors is the
number of different point process types. This is different from the
mechanism type which enumerates all mechanisms including the point_processes.
It is the responsibility of create_point_process to set up the vectors and
fill in the symbol information. However only after the process is given
a location can the variables be set or accessed. This is because the
allocation function may have to connect to some ionic parameters and the
process exists primarily as a property of a node.
*/
typedef struct Point_process {
Section *sec; /* section and node location for the point mechanism*/
Node *node;
Prop *prop; /* pointer to the actual property linked to the
node property list */
Object* ob; /* object that owns this process */
void* presyn_; /* non-threshold presynapse for NetCon */
void* nvi_; /* NrnVarIntegrator (for local step method) */
void* _vnt; /* NrnThread* (for NET_RECEIVE and multicore) */
} Point_process;
#if EXTRAEQN
/*Blocks of equations can hang off each node of the current conservation
equations. These are equations which must be solved simultaneously
because they depend on the voltage and affect the voltage. An example
are fast changing ionic concentrations (or merely if we want to be
able to calculate steady states using a stable method).
*/
typedef struct Eqnblock {
struct Eqnblock *eqnblock_next; /* may be several such blocks */
Pfri eqnblock_triang; /* triangularization function */
Pfri eqnblock_bksub; /* back substitution function */
double *eqnblock_data;
#if 0
the solving functions know how to find the following info from
the eqnblock_data.
double *eqnblock_row; /* current conservation depends on states */
double *eqnblock_col; /* state equations depend on voltage */
double *eqnblock_matrix; /* state equations depend on states */
double *eqnblock_rhs:
the functions merely take a pointer to the node and this Eqnblock
in order to update the values of the diagonal, v, and the rhs
The interface with EXTRACELLULAR makes things a bit more subtle.
It seems clear that we will have to change the meaning of v to
be membrane potential so that the internal potential is v + vext.
This will avoid requiring two rows and two columns since
the state equations will depend only on v and not vext.
In fact, if vext did not have longitudinal relationships with
other vext the extracellular mechanism could be implemented in
this style.
#endif
} Eqnblock;
#endif /*EXTRAEQN*/
extern int nrn_global_ncell; /* note that for multiple threads all the rootnodes are no longer contiguous */
extern hoc_List* section_list; /* Where the Sections live */
extern Section* chk_access();
extern Section *sec_alloc(); /* Allocates a single section */
extern void node_alloc(Section*, short); /* Allocates node vectors in a section*/
extern double section_length(Section*), nrn_diameter(Node*);
extern double nrn_ghk(double, double, double, double);
extern Node* nrn_parent_node(Node*);
extern Section* nrn_section_alloc();
extern void nrn_section_free(Section*);
extern int nrn_is_valid_section_ptr(void*);
/* loop over sections. Must previously declare Item* qsec. Contains the {! */
#define ForAllSections(sec) \
ITERATE(qsec, section_list) { Section* sec = hocSEC(qsec);
#if METHOD3
extern int _method3;
#endif
#include <multicore.h>
extern int stoprun;
#define tstopbit (1 << 15)
#define tstopset stoprun |= tstopbit
#define tstopunset stoprun &= (~tstopbit)
/* cvode.event(tevent) sets this. Reset at beginning */
/* of any hoc call for integration and before returning to hoc */
#if defined(__cplusplus)
}
#endif
#include "nrn_ansi.h"
#endif
| 36.418398 | 121 | 0.73185 |
81a75969a945356301613db896add91e2baba57f | 2,572 | h | C | 3rdparty/WebRTC/android/include/webrtc/out/Debug/x64/gen/sdk/android/generated_video_jni/NV21Buffer_jni.h | VirgilSecurity/virgil-webrtc-qt-demo | 1c9ebe3893629ad396be6e187657df870b06322b | [
"BSD-3-Clause"
] | 5 | 2020-12-17T06:55:53.000Z | 2021-09-30T13:06:58.000Z | 3rdparty/WebRTC/android/include/webrtc/out/Debug/x64/gen/sdk/android/generated_video_jni/NV21Buffer_jni.h | VirgilSecurity/virgil-webrtc-qt-demo | 1c9ebe3893629ad396be6e187657df870b06322b | [
"BSD-3-Clause"
] | 1 | 2022-01-04T21:53:07.000Z | 2022-03-30T11:16:05.000Z | 3rdparty/WebRTC/android/include/webrtc/out/Debug/arm/gen/sdk/android/generated_video_jni/NV21Buffer_jni.h | VirgilSecurity/virgil-webrtc-qt-demo | 1c9ebe3893629ad396be6e187657df870b06322b | [
"BSD-3-Clause"
] | 8 | 2020-09-30T10:06:31.000Z | 2022-03-29T21:17:21.000Z | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is autogenerated by
// base/android/jni_generator/jni_generator.py
// For
// org/webrtc/NV21Buffer
#ifndef org_webrtc_NV21Buffer_JNI
#define org_webrtc_NV21Buffer_JNI
#include <jni.h>
#include "../../../../../../../sdk/android/src/jni/jni_generator_helper.h"
// Step 1: Forward declarations.
JNI_REGISTRATION_EXPORT extern const char kClassPath_org_webrtc_NV21Buffer[];
const char kClassPath_org_webrtc_NV21Buffer[] = "org/webrtc/NV21Buffer";
// Leaking this jclass as we cannot use LazyInstance from some threads.
JNI_REGISTRATION_EXPORT std::atomic<jclass> g_org_webrtc_NV21Buffer_clazz(nullptr);
#ifndef org_webrtc_NV21Buffer_clazz_defined
#define org_webrtc_NV21Buffer_clazz_defined
inline jclass org_webrtc_NV21Buffer_clazz(JNIEnv* env) {
return base::android::LazyGetClass(env, kClassPath_org_webrtc_NV21Buffer,
&g_org_webrtc_NV21Buffer_clazz);
}
#endif
// Step 2: Constants (optional).
// Step 3: Method stubs.
namespace webrtc {
namespace jni {
static void JNI_NV21Buffer_CropAndScale(JNIEnv* env, jint cropX,
jint cropY,
jint cropWidth,
jint cropHeight,
jint scaleWidth,
jint scaleHeight,
const base::android::JavaParamRef<jbyteArray>& src,
jint srcWidth,
jint srcHeight,
const base::android::JavaParamRef<jobject>& dstY,
jint dstStrideY,
const base::android::JavaParamRef<jobject>& dstU,
jint dstStrideU,
const base::android::JavaParamRef<jobject>& dstV,
jint dstStrideV);
JNI_GENERATOR_EXPORT void Java_org_webrtc_NV21Buffer_nativeCropAndScale(
JNIEnv* env,
jclass jcaller,
jint cropX,
jint cropY,
jint cropWidth,
jint cropHeight,
jint scaleWidth,
jint scaleHeight,
jbyteArray src,
jint srcWidth,
jint srcHeight,
jobject dstY,
jint dstStrideY,
jobject dstU,
jint dstStrideU,
jobject dstV,
jint dstStrideV) {
return JNI_NV21Buffer_CropAndScale(env, cropX, cropY, cropWidth, cropHeight, scaleWidth,
scaleHeight, base::android::JavaParamRef<jbyteArray>(env, src), srcWidth, srcHeight,
base::android::JavaParamRef<jobject>(env, dstY), dstStrideY,
base::android::JavaParamRef<jobject>(env, dstU), dstStrideU,
base::android::JavaParamRef<jobject>(env, dstV), dstStrideV);
}
} // namespace jni
} // namespace webrtc
// Step 4: Generated test functions (optional).
#endif // org_webrtc_NV21Buffer_JNI
| 28.577778 | 90 | 0.74028 |
88448cc6efcf951000b2c067040c6e1655f31122 | 420 | h | C | Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnrealRuntime/Public/DazToUnrealRuntime.h | qasim808/DazToRuntime | 18a041b86d9eb188df82bb5b1f9b33a86a3f2bfa | [
"Apache-2.0"
] | 74 | 2020-08-28T14:42:52.000Z | 2022-03-18T10:31:13.000Z | Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnrealRuntime/Public/DazToUnrealRuntime.h | qasim808/DazToRuntime | 18a041b86d9eb188df82bb5b1f9b33a86a3f2bfa | [
"Apache-2.0"
] | 25 | 2020-09-02T22:43:17.000Z | 2022-03-15T20:03:29.000Z | Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnrealRuntime/Public/DazToUnrealRuntime.h | qasim808/DazToRuntime | 18a041b86d9eb188df82bb5b1f9b33a86a3f2bfa | [
"Apache-2.0"
] | 20 | 2020-08-31T09:26:27.000Z | 2022-03-17T03:49:43.000Z | #pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
class FDazToUnrealRuntimeModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
static inline FDazToUnrealRuntimeModule& Get()
{
return FModuleManager::LoadModuleChecked< FDazToUnrealRuntimeModule >("DazToUnrealRuntime");
}
}; | 21 | 94 | 0.785714 |
32f4025f7eb254d783e1750ae19a41d350e753d3 | 2,800 | c | C | src/rb.c | janyman/wish-c99 | 3734e6b2de45c90adf863d7c4ef6709aa7b6a662 | [
"Apache-2.0"
] | 1 | 2018-09-05T08:41:02.000Z | 2018-09-05T08:41:02.000Z | src/rb.c | janyman/wish-c99 | 3734e6b2de45c90adf863d7c4ef6709aa7b6a662 | [
"Apache-2.0"
] | 1 | 2018-12-11T11:15:55.000Z | 2018-12-11T11:15:55.000Z | src/rb.c | janyman/wish-c99 | 3734e6b2de45c90adf863d7c4ef6709aa7b6a662 | [
"Apache-2.0"
] | 4 | 2018-08-07T16:02:38.000Z | 2018-11-12T08:42:20.000Z | /**
* Copyright (C) 2018, ControlThings Oy Ab
* Copyright (C) 2018, André Kaustell
* Copyright (C) 2018, Jan Nyman
* Copyright (C) 2018, Jepser Lökfors
*
* 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
*
* @license Apache-2.0
*/
#include <stdint.h>
#include "rb.h"
void ring_buffer_init(ring_buffer_t* buf, uint8_t* data, uint16_t len) {
buf->read = 0;
buf->data_len = 0;
buf->data = data;
buf->max_len = len;
buf->state = RINGBUFFER_STATE_WAIT;
}
uint8_t ring_buffer_is_full(ring_buffer_t* buf) {
if ( buf->data_len == buf->max_len ) {
return 1;
} else {
return 0;
}
}
uint8_t ring_buffer_is_empty(ring_buffer_t* buf) {
if ( buf->data_len == 0 ) {
return 1;
} else {
return 0;
}
}
uint16_t ring_buffer_length(ring_buffer_t* buf) {
return buf->data_len;
}
uint16_t ring_buffer_space(ring_buffer_t* buf) {
return buf->max_len - buf->data_len;
}
uint16_t ring_buffer_write(ring_buffer_t* buf, const uint8_t* data, uint16_t len) {
uint16_t wrote = 0;
uint16_t cursor = (buf->read+buf->data_len)%buf->max_len;
while (wrote<len) {
if ( ring_buffer_is_full(buf) ) {
return wrote;
} else {
buf->data[cursor] = data[wrote];
wrote++;
buf->data_len++;
cursor = (buf->read+buf->data_len)%buf->max_len;
}
}
return wrote;
}
uint16_t ring_buffer_read(ring_buffer_t* buf, uint8_t* data, uint16_t len) {
uint16_t read = 0;
uint16_t cursor = buf->read;
while (read<len) {
if ( ring_buffer_is_empty(buf) ) {
return read;
} else {
data[read] = buf->data[cursor];
read++;
buf->data_len--;
++buf->read;
buf->read %= buf->max_len;
cursor = buf->read;
}
}
return read;
}
uint16_t ring_buffer_skip(ring_buffer_t* buf, uint16_t len) {
uint16_t read = 0;
while (read<len) {
if ( ring_buffer_is_empty(buf) ) {
return read;
} else {
read++;
buf->data_len--;
++buf->read;
buf->read %= buf->max_len;
}
}
return read;
}
uint16_t ring_buffer_peek(ring_buffer_t* buf, uint8_t* data, uint16_t len) {
uint16_t read = 0;
uint16_t cursor = buf->read;
// Peek a maximum of data_len bytes
if ( buf->data_len < len ) {
len = buf->data_len;
}
while (read<len) {
data[read] = buf->data[cursor];
read++;
cursor++;
cursor %= buf->max_len;
}
return read;
}
| 23.728814 | 83 | 0.571786 |
b0305b1b5472060015504af5ccddadbd41054174 | 2,603 | c | C | nm/src/symbols_table_to_list.c | nsarno/nm-objdump | 3a98316f29265e2f8b1275f0df2e0f74a066226a | [
"MIT"
] | 14 | 2016-11-11T20:45:34.000Z | 2021-11-29T13:59:50.000Z | nm/src/symbols_table_to_list.c | Venatoral/nm-objdump | 3a98316f29265e2f8b1275f0df2e0f74a066226a | [
"MIT"
] | null | null | null | nm/src/symbols_table_to_list.c | Venatoral/nm-objdump | 3a98316f29265e2f8b1275f0df2e0f74a066226a | [
"MIT"
] | 14 | 2015-07-24T08:31:08.000Z | 2021-06-30T09:02:04.000Z | /*
** symbols_table_to_list.c for nm in /home/mesure_a/workspace/c/nm-objdump/nm
**
** Made by arnaud mesureur
** Login <mesure_a@epitech.net>
**
** Started on Sun Mar 13 17:36:13 2011 arnaud mesureur
** Last update Sun Mar 13 23:11:09 2011 arnaud mesureur
*/
#include <elf.h>
#include <stddef.h>
#include <string.h>
#include "nm.h"
/*
** no comments for you
** it was hard to write
** so it should be hard to read
*/
static int is_from_section(Elf64_Sym *symtab, t_elf *elf, const char *s)
{
return (!strcmp(&(elf->shstrtab)[elf->shtab[symtab->st_shndx].sh_name], s));
}
static char determine_st_flag_roftb(Elf64_Sym *symtab, Elf64_Addr value,
t_elf *elf)
{
if (ELF64_ST_BIND(symtab->st_info) == STB_WEAK)
{
if (!value)
return (ELF64_ST_TYPE(symtab->st_info) == STT_OBJECT ? 'v' : 'w');
return (ELF64_ST_TYPE(symtab->st_info) == STT_OBJECT ? 'V' : 'W');
}
else if (symtab->st_shndx == SHN_COMMON)
return ('C');
else if (symtab->st_shndx == SHN_UNDEF)
return ('U');
else if (is_from_section(symtab, elf, ".debug"))
return ('N');
return (0);
}
static char determine_st_flag(char *t, Elf64_Sym *symtab,
Elf64_Addr value, t_elf *elf)
{
if (symtab->st_shndx == SHN_ABS)
*t = 'a';
else if ((*t = determine_st_flag_roftb(symtab, value, elf)))
return (*t);
else if (is_from_section(symtab, elf, ".bss"))
*t = 'b';
else if (is_from_section(symtab, elf, ".text")
|| ELF64_ST_TYPE(symtab->st_info) == STT_FUNC)
*t = 't';
else if (is_from_section(symtab, elf, ".rodata"))
*t = 'r';
else if (ELF64_ST_TYPE(symtab->st_info) == STT_OBJECT
|| ELF64_ST_TYPE(symtab->st_info) == STT_NOTYPE
|| is_from_section(symtab, elf, ".data")
|| is_from_section(symtab, elf, ".data1"))
*t = 'd';
else
return ('?');
return (ELF64_ST_BIND(symtab->st_info) == STB_LOCAL ? *t : *t - 32);
}
static int isprintable(t_elf *elf, Elf64_Sym *st)
{
return (elf->strtab[st->st_name] && ELF64_ST_TYPE(st->st_info) != STT_FILE);
}
t_sym_list *symbols_table_to_list(t_sym_list *list,
Elf64_Shdr *symhdr,
Elf64_Sym *symtab,
t_elf *elf)
{
t_sym symbol;
size_t nentries;
size_t i;
i = 0;
nentries = symhdr->sh_size / symhdr->sh_entsize;
while (i < nentries)
{
if (isprintable(elf, &symtab[i]))
{
symbol.value = symtab[i].st_value;
symbol.name = &(elf->strtab[symtab[i].st_name]);
symbol.type = determine_st_flag(&symbol.type, &symtab[i],
symbol.value, elf);
list_add_front(list, &symbol, sizeof(symbol));
}
++i;
}
return (list);
}
| 26.292929 | 78 | 0.635805 |
fc380ff1f6d3069b2417547a56ec0efe81df4cd0 | 319 | h | C | MoBS/argos/source/faulttolerance/ColorUtil.h | BCLab-UNM/VolcanoSensing-LoCUS | 873cb982ffe1bf717491309828bac297d62ff613 | [
"MIT"
] | 1 | 2021-11-02T08:16:23.000Z | 2021-11-02T08:16:23.000Z | MoBS/argos/source/faulttolerance/ColorUtil.h | twinsburg/VolcanoSensing-LoCUS | 873cb982ffe1bf717491309828bac297d62ff613 | [
"MIT"
] | null | null | null | MoBS/argos/source/faulttolerance/ColorUtil.h | twinsburg/VolcanoSensing-LoCUS | 873cb982ffe1bf717491309828bac297d62ff613 | [
"MIT"
] | 1 | 2021-11-02T08:16:14.000Z | 2021-11-02T08:16:14.000Z | #ifndef GRADIENT_ARGOS_COLORUTIL_H
#define GRADIENT_ARGOS_COLORUTIL_H
#include <argos3/core/utility/datatypes/color.h>
#include <cmath>
using namespace argos;
using namespace std;
class ColorUtil {
public:
static CColor HSVtoRGB(float hue, float saturation, float value);
};
#endif //GRADIENT_ARGOS_COLORUTIL_H
| 17.722222 | 67 | 0.799373 |
fc3c9d4226cb2d4e631356f5b54eee31aa21dbcc | 566 | h | C | Code/CoreTextStudy/YLCoreText/YLCoreText/YLCTFrameParser.h | ApesTalk/Epub | ae227835d155b03b03eabb38371d9f68b17d2f33 | [
"MIT"
] | 17 | 2018-08-20T04:14:50.000Z | 2021-04-02T15:00:59.000Z | Code/CoreTextStudy/YLCoreText/YLCoreText/YLCTFrameParser.h | ApesTalk/Epub | ae227835d155b03b03eabb38371d9f68b17d2f33 | [
"MIT"
] | null | null | null | Code/CoreTextStudy/YLCoreText/YLCoreText/YLCTFrameParser.h | ApesTalk/Epub | ae227835d155b03b03eabb38371d9f68b17d2f33 | [
"MIT"
] | null | null | null | //
// YLCTFrameParser.h
// YLCoreText
//
// Created by ApesTalk on 16/7/21.
// Copyright © 2016年 https://github.com/ApesTalk. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "YLCoreTextData.h"
#import "YLCTFrameParserConfig.h"
@interface YLCTFrameParser : NSObject
+(YLCoreTextData *)parseContent:(NSString *)content
config:(YLCTFrameParserConfig *)config;
+(YLCoreTextData *)parseTemplateFile:(NSString *)path
config:(YLCTFrameParserConfig *)config;
@end
//用于生成最后绘制界面需要的CTFrameRef实例
| 24.608696 | 71 | 0.687279 |
ccdc3ef447f3b31fc47fc4b20131588d4e87dfed | 2,776 | c | C | libsrp/clitest.c | PierceLBrooks/stanford-srp | 578883f162dd831a2c53bc96696e5d21ccd9d09a | [
"X11",
"OpenSSL"
] | 8 | 2020-11-01T13:51:09.000Z | 2021-09-03T07:08:11.000Z | libsrp/clitest.c | PierceLBrooks/stanford-srp | 578883f162dd831a2c53bc96696e5d21ccd9d09a | [
"X11",
"OpenSSL"
] | null | null | null | libsrp/clitest.c | PierceLBrooks/stanford-srp | 578883f162dd831a2c53bc96696e5d21ccd9d09a | [
"X11",
"OpenSSL"
] | 7 | 2019-06-27T03:46:38.000Z | 2021-10-05T03:33:24.000Z | /*
* Copyright (c) 1997-2007 The Stanford SRP Authentication Project
* All Rights Reserved.
*
* 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" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
* THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Redistributions in source or binary form must retain an intact copy
* of this copyright notice.
*/
#include <stdio.h>
#include "srp_aux.h"
#include "t_pwd.h"
#include "t_client.h"
int
main()
{
struct t_client * tc;
struct t_num n;
struct t_num g;
struct t_num s;
struct t_num B;
char username[MAXUSERLEN];
char hexbuf[MAXHEXPARAMLEN];
char buf1[MAXPARAMLEN], buf2[MAXPARAMLEN], buf3[MAXSALTLEN];
struct t_num * A;
unsigned char * skey;
char pass[128];
printf("Enter username: ");
gets(username);
printf("Enter n (from server): ");
gets(hexbuf);
n.data = buf1;
n.len = t_fromb64(n.data, hexbuf);
printf("Enter g (from server): ");
gets(hexbuf);
g.data = buf2;
g.len = t_fromb64(g.data, hexbuf);
printf("Enter salt (from server): ");
gets(hexbuf);
s.data = buf3;
s.len = t_fromb64(s.data, hexbuf);
tc = t_clientopen(username, &n, &g, &s);
A = t_clientgenexp(tc);
printf("A (to server): %s\n", t_tob64(hexbuf, A->data, A->len));
t_getpass(pass, 128, "Enter password:");
t_clientpasswd(tc, pass);
printf("Enter B (from server): ");
gets(hexbuf);
B.data = buf1;
B.len = t_fromb64(B.data, hexbuf);
printf("Enter extra data (optional): ");
gets(hexbuf);
t_clientaddexdata(tc, hexbuf, strlen(hexbuf));
skey = t_clientgetkey(tc, &B);
printf("Session key: %s\n", t_tohex(hexbuf, skey, 40));
printf("Response (to server): %s\n",
t_tohex(hexbuf, t_clientresponse(tc), RESPONSE_LEN));
t_clientclose(tc);
return 0;
}
| 30.505495 | 75 | 0.70245 |
92bc22d7c9406537409a2476f5559356e2ca88f1 | 3,916 | h | C | include/base/debug/mip_debug.h | skei/MIP2 | 8ea0fa49da46a1d6256846cc71d413708b0709e1 | [
"MIT"
] | 5 | 2022-01-05T16:51:38.000Z | 2022-02-07T15:14:38.000Z | include/base/debug/mip_debug.h | skei/MIP2 | 8ea0fa49da46a1d6256846cc71d413708b0709e1 | [
"MIT"
] | null | null | null | include/base/debug/mip_debug.h | skei/MIP2 | 8ea0fa49da46a1d6256846cc71d413708b0709e1 | [
"MIT"
] | 1 | 2022-03-11T21:00:22.000Z | 2022-03-11T21:00:22.000Z | #ifndef mip_debug_included
#define mip_debug_included
//----------------------------------------------------------------------
#define MIP_DEBUG_ASSERT
#define MIP_DEBUG_CALLSTACK
#define MIP_DEBUG_CRASH_HANDLER
#define MIP_DEBUG_PRINT
//#define MIP_DEBUG_PRINT_THREAD
#define MIP_DEBUG_PRINT_TIME
//#define MIP_DEBUG_PRINT_SOCKET
#define MIP_DEBUG_WATCHES
//----------------------------------------------------------------------
#ifdef MIP_WIN32
#undef MIP_DEBUG
#endif
#ifndef MIP_DEBUG
#undef MIP_DEBUG_ASSER
#undef MIP_DEBUG_CALLSTACK
#undef MIP_DEBUG_CRASH_HANDLER
#undef MIP_DEBUG_MEMORY
#undef MIP_DEBUG_PRINT
#undef MIP_DEBUG_PRINT_SOCKET
#undef MIP_DEBUG_PRINT_THREAD
#undef MIP_DEBUG_PRINT_TIME
#endif // MIP_DEBUG
//----------------------------------------------------------------------
#include "base/debug/mip_debug_print.h"
#include "base/debug/mip_debug_assert.h"
#include "base/debug/mip_debug_watch.h"
#include "base/debug/mip_debug_callstack.h"
#include "base/debug/mip_debug_crash_handler.h"
#include "base/utils/mip_strutils.h"
#ifdef MIP_DEBUG_MEMORY
#include <list>
typedef struct {
void* addr = nullptr;
uint32_t size = 0;
char file[128] = {0};
char func[128] = {0};
uint32_t line = 0;
} MIP_DebugMemoryNode;
typedef std::list<MIP_DebugMemoryNode*> MIP_DebugMemoryNodes;
#endif // memory
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
#ifdef MIP_DEBUG
class MIP_GlobalDebug {
//------------------------------
private:
//------------------------------
#ifdef MIP_DEBUG_MEMORY
MIP_DebugMemoryNodes MMemoryNodes;
#endif
//------------------------------
public:
//------------------------------
MIP_GlobalDebug() {
#ifdef MIP_DEBUG_PRINT_TIME
_mip_debug_time_start();
#endif
#ifdef MIP_DEBUG_PRINT_SOCKET
_mip_debug_socket_init();
#endif
}
//----------
~MIP_GlobalDebug() {
//#ifdef MIP_DEBUG_PRINT_TIME
//#endif
#ifdef MIP_DEBUG_PRINT_SOCKET
_mip_debug_socket_close();
#endif
}
//------------------------------
public:
//------------------------------
#ifdef MIP_DEBUG_MEMORY
void addMemoryNode(void* AAddress, uint32_t ASize, const char* AFile, const char *AFunc, uint32_t ALine) {
MIP_DebugMemoryNode *info;
//if (!allocList) {
// allocList = new(MIP_DebugMemoryNodes);
//}
info = new(MIP_DebugMemoryNode);
info->addr = AAddress;
const char* filename = MIP_GetFilenameFromPath(AFile);
strncpy(info->file,filename,127);
strncpy(info->func,AFunc, 127);
info->line = ALine;
info->size = ASize;
MMemoryNodes.insert(MMemoryNodes.begin(), info);
};
//
void removeMemoryNode(void* AAddress) {
MIP_DebugMemoryNodes::iterator i;
//if (!allocList) return;
for (i = MMemoryNodes.begin(); i != MMemoryNodes.end(); i++) {
if ((*i)->addr == AAddress) {
MMemoryNodes.remove((*i));
break;
}
}
};
//----------
void dumpMemoryNodes() {
MIP_DebugMemoryNodes::iterator i;
uint32_t totalSize = 0;
for (i = MMemoryNodes.begin(); i != MMemoryNodes.end(); i++) {
MIP_DPrint("file:%s func:%s line:%i addr:0x%08p size: %i\n", (*i)->file, (*i)->func, (*i)->line, (*i)->addr, (*i)->size);
totalSize += (*i)->size;
}
MIP_DPrint("-----------------------------------------------------------\n");
MIP_Print("Total Unfreed: %d bytes\n", totalSize);
};
#endif // MIP_DEBUG_MEMORY
};
//----------
MIP_GlobalDebug MIP_GLOBAL_DEBUG;
#endif // MIP_DEBUG
//----------------------------------------------------------------------
#include "base/debug/mip_debug_memory.h"
//#include "base/debug/mip_debug_watch.h"
//----------------------------------------------------------------------
#endif
| 23.878049 | 127 | 0.542135 |
ddeffe572da76c7547b8c9837263797b298e28df | 1,553 | h | C | HappyTravelShow/HappyTravelShow/Classes/Scenes/ViewController/AroundVC/AdditionalVIews/XIButton.h | AmazingLW/SmoothTravelShow | aab9b05d4fa9171eb09ea9940623563a8e136637 | [
"MIT"
] | 1 | 2015-10-15T09:29:04.000Z | 2015-10-15T09:29:04.000Z | HappyTravelShow/HappyTravelShow/Classes/Scenes/ViewController/AroundVC/DropdownListView/XIButton.h | AmazingLW/HappyTravelShow | 6001a6116e9fc2e8c7c64f2a838fbb4b62a750f5 | [
"MIT"
] | null | null | null | HappyTravelShow/HappyTravelShow/Classes/Scenes/ViewController/AroundVC/DropdownListView/XIButton.h | AmazingLW/HappyTravelShow | 6001a6116e9fc2e8c7c64f2a838fbb4b62a750f5 | [
"MIT"
] | 1 | 2019-04-03T06:19:46.000Z | 2019-04-03T06:19:46.000Z |
#import <UIKit/UIKit.h>
typedef enum : NSUInteger {
XIContentAlignVertical,
XIContentAlignHorizontalCenter,
XIContentAlignHorizontalCenterImageRight,
XIContentAlignHorizontalLeft
} XIContentAlign;
@interface XIButton : UIButton
{
@protected
CGSize preferedImageSize;
UIFont *preferedFont;
UIColor *preferedColor;
UIColor *preferedHighlightedColor;
BOOL shouldChangeImageSize;
NSLayoutConstraint *imageWidthConstraint;
NSLayoutConstraint *imageHeightConstraint;
UIView *containerView;
UIImageView *proImageView;
UILabel *proLabel;
}
@property(nonatomic, assign) CGSize preferedImageSize;
@property(nonatomic, strong) UIFont *preferedFont;
@property(nonatomic, strong) UIColor *preferedColor;
@property(nonatomic, strong) UIColor *preferedHighlightedColor;
+ (instancetype)createItemButtonWithType:(XIContentAlign)type;
- (void)setImage:(UIImage *)image title:(NSString *)title controlState:(UIControlState)state;
- (NSString *)titleForNormalState;
@end
@interface XIContentAlignVerticalButton : XIButton
{
@private
NSLayoutConstraint *_imageConstraintCenterY;
BOOL needUpdateImageOffset;
}
@property(nonatomic, assign) CGSize imageOffsetSize;
@end
@interface XIContentAlignHorizontalButton : XIButton
@end
@interface XIContentAlignHorizontalLeftButton : XIContentAlignHorizontalButton
@end
@interface XIContentAlignHorizontalCenterImageRightButton : XIContentAlignHorizontalButton
@end
@interface XIContentAlignHorizontalCenterButton : XIContentAlignHorizontalButton
@end
| 27.732143 | 93 | 0.808113 |
594aa265b36f1764e362f339bb3df8de30c5033d | 16,483 | c | C | tests/check_skiplist.c | thodg/facts_db | 9db877f165df8f83df18545dce2ea5fdcb8f4be5 | [
"MIT"
] | 2 | 2020-11-11T12:41:43.000Z | 2021-09-03T10:50:44.000Z | tests/check_skiplist.c | thodg/facts_db | 9db877f165df8f83df18545dce2ea5fdcb8f4be5 | [
"MIT"
] | null | null | null | tests/check_skiplist.c | thodg/facts_db | 9db877f165df8f83df18545dce2ea5fdcb8f4be5 | [
"MIT"
] | 1 | 2022-01-15T00:33:51.000Z | 2022-01-15T00:33:51.000Z | /*
* facts_db - in-memory graph database
* Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <check.h>
#include <stdio.h>
#include <stdlib.h>
#include "../skiplist.h"
s_skiplist *g_sl = NULL;
START_TEST (test_skiplist_init_destroy)
{
unsigned long i;
unsigned long max_height = 4;
s_skiplist *sl = alloca(skiplist_size(max_height));
skiplist_init(sl, max_height, 2);
ck_assert(sl->length == 0);
ck_assert(sl->head);
for (i = 0; i < max_height; i++)
ck_assert(skiplist_node_next(sl->head, i) == NULL);
ck_assert(sl->max_height == max_height);
skiplist_destroy(sl);
}
END_TEST
START_TEST (test_skiplist_new_delete)
{
unsigned long i;
unsigned long max_height = 4;
s_skiplist *sl = new_skiplist(max_height, 2);
ck_assert(sl && sl->length == 0);
for (i = 0; i < max_height; i++)
ck_assert(skiplist_node_next(sl->head, i) == NULL);
delete_skiplist(sl);
}
END_TEST
void setup_inserts ()
{
g_sl = new_skiplist(4, 2);
}
void teardown_inserts ()
{
delete_skiplist(g_sl);
}
START_TEST (test_skiplist_insert_one)
{
skiplist_insert(g_sl, (void*) 1);
skiplist_insert(g_sl, (void*) 1);
ck_assert(g_sl->length == 1);
ck_assert(skiplist_find(g_sl, (void*) 1));
ck_assert(skiplist_find(g_sl, (void*) 2) == 0);
}
END_TEST
START_TEST (test_skiplist_insert_two)
{
skiplist_insert(g_sl, (void*) 1);
skiplist_insert(g_sl, (void*) 2);
skiplist_insert(g_sl, (void*) 1);
skiplist_insert(g_sl, (void*) 2);
ck_assert(g_sl->length == 2);
ck_assert(skiplist_find(g_sl, (void*) 1));
ck_assert(skiplist_find(g_sl, (void*) 2));
ck_assert(skiplist_find(g_sl, (void*) 3) == 0);
}
END_TEST
START_TEST (test_skiplist_insert_ten)
{
skiplist_insert(g_sl, (void*) 1);
skiplist_insert(g_sl, (void*) 2);
skiplist_insert(g_sl, (void*) 3);
skiplist_insert(g_sl, (void*) 4);
skiplist_insert(g_sl, (void*) 5);
skiplist_insert(g_sl, (void*) 6);
skiplist_insert(g_sl, (void*) 7);
skiplist_insert(g_sl, (void*) 8);
skiplist_insert(g_sl, (void*) 9);
skiplist_insert(g_sl, (void*) 10);
ck_assert(g_sl->length == 10);
ck_assert(skiplist_find(g_sl, (void*) 1));
ck_assert(skiplist_find(g_sl, (void*) 2));
ck_assert(skiplist_find(g_sl, (void*) 3));
ck_assert(skiplist_find(g_sl, (void*) 4));
ck_assert(skiplist_find(g_sl, (void*) 5));
ck_assert(skiplist_find(g_sl, (void*) 6));
ck_assert(skiplist_find(g_sl, (void*) 7));
ck_assert(skiplist_find(g_sl, (void*) 8));
ck_assert(skiplist_find(g_sl, (void*) 9));
ck_assert(skiplist_find(g_sl, (void*) 10));
ck_assert(skiplist_find(g_sl, (void*) 11) == 0);
}
END_TEST
void setup_pred ()
{
g_sl = new_skiplist(4, 2);
skiplist_insert(g_sl, (void*) 2);
skiplist_insert(g_sl, (void*) 3);
}
void teardown_pred ()
{
delete_skiplist(g_sl);
}
START_TEST (test_skiplist_pred_empty)
{
s_skiplist *sl = new_skiplist(4, 2);
s_skiplist_node *pred;
unsigned long level;
ck_assert(sl);
pred = skiplist_pred(sl, (void*) 1);
for (level = 0; level < pred->height; level++) {
ck_assert(skiplist_node_next(pred, level) == sl->head);
}
delete_skiplist_node(pred);
delete_skiplist(sl);
}
END_TEST
START_TEST (test_skiplist_pred_before_first)
{
s_skiplist_node *pred;
unsigned long level;
pred = skiplist_pred(g_sl, (void*) 1);
for (level = 0; level < pred->height; level++) {
ck_assert(skiplist_node_next(pred, level) == g_sl->head);
}
delete_skiplist_node(pred);
}
END_TEST
START_TEST (test_skiplist_pred_first)
{
s_skiplist_node *pred;
s_skiplist_node *p;
unsigned long level;
unsigned long height;
pred = skiplist_pred(g_sl, (void*) 2);
ck_assert(pred);
p = skiplist_node_next(g_sl->head, 0);
ck_assert(p);
ck_assert(p->value == (void*) 2);
height = p->height;
for (level = 0; level < height; level++) {
p = skiplist_node_next(pred, level);
ck_assert(p == g_sl->head);
ck_assert(skiplist_node_next(p, level));
ck_assert(skiplist_node_next(p, level)->value == (void*) 2);
}
delete_skiplist_node(pred);
}
END_TEST
START_TEST (test_skiplist_pred_last)
{
s_skiplist_node *pred;
s_skiplist_node *p;
unsigned long level;
unsigned long height;
pred = skiplist_pred(g_sl, (void*) 3);
ck_assert(pred);
p = skiplist_node_next(pred, 0);
ck_assert(p);
p = skiplist_node_next(p, 0);
ck_assert(p);
ck_assert(p->value == (void*) 3);
height = p->height;
for (level = 0; level < height; level++) {
p = skiplist_node_next(pred, level);
ck_assert(p);
ck_assert(skiplist_node_next(p, level));
ck_assert(skiplist_node_next(p, level)->value == (void*) 3);
}
delete_skiplist_node(pred);
}
END_TEST
START_TEST (test_skiplist_pred_after_last)
{
s_skiplist_node *pred;
s_skiplist_node *p;
unsigned long level;
unsigned long height;
pred = skiplist_pred(g_sl, (void*) 4);
ck_assert(pred);
p = skiplist_node_next(pred, 0);
ck_assert(p);
ck_assert(p->value == (void*) 3);
height = p->height;
for (level = 0; level < height; level++) {
p = skiplist_node_next(pred, level);
ck_assert(p);
ck_assert(p->value == (void*) 3);
ck_assert(skiplist_node_next(p, level) == 0);
}
delete_skiplist_node(pred);
}
END_TEST
void setup_remove ()
{
g_sl = new_skiplist(4, 2);
skiplist_insert(g_sl, (void*) 1);
skiplist_insert(g_sl, (void*) 2);
skiplist_insert(g_sl, (void*) 3);
skiplist_insert(g_sl, (void*) 4);
skiplist_insert(g_sl, (void*) 5);
skiplist_insert(g_sl, (void*) 6);
skiplist_insert(g_sl, (void*) 7);
skiplist_insert(g_sl, (void*) 8);
skiplist_insert(g_sl, (void*) 9);
skiplist_insert(g_sl, (void*) 10);
}
void teardown_remove ()
{
delete_skiplist(g_sl);
}
START_TEST (test_skiplist_remove_first)
{
ck_assert(g_sl->length == 10);
ck_assert((void*) 1 == skiplist_remove(g_sl, (void*) 1));
ck_assert(g_sl->length == 9);
}
END_TEST
START_TEST (test_skiplist_remove_nonexistent)
{
ck_assert(g_sl->length == 10);
ck_assert(NULL == skiplist_remove(g_sl, (void*) 1000));
ck_assert(g_sl->length == 10);
}
END_TEST
START_TEST (test_skiplist_remove_last)
{
ck_assert((void*) 10 == skiplist_remove(g_sl, (void*) 10));
ck_assert(g_sl->length == 9);
}
END_TEST
START_TEST (test_skiplist_remove_middle)
{
ck_assert((void*) 5 == skiplist_remove(g_sl, (void*) 5));
ck_assert(g_sl->length == 9);
}
END_TEST
START_TEST (test_skiplist_remove_all)
{
ck_assert((void*) 1 == skiplist_remove(g_sl, (void*) 1));
ck_assert((void*) 2 == skiplist_remove(g_sl, (void*) 2));
ck_assert((void*) 3 == skiplist_remove(g_sl, (void*) 3));
ck_assert((void*) 4 == skiplist_remove(g_sl, (void*) 4));
ck_assert((void*) 5 == skiplist_remove(g_sl, (void*) 5));
ck_assert((void*) 6 == skiplist_remove(g_sl, (void*) 6));
ck_assert((void*) 7 == skiplist_remove(g_sl, (void*) 7));
ck_assert((void*) 8 == skiplist_remove(g_sl, (void*) 8));
ck_assert((void*) 9 == skiplist_remove(g_sl, (void*) 9));
ck_assert((void*) 10 == skiplist_remove(g_sl, (void*) 10));
ck_assert(g_sl->length == 0);
}
END_TEST
void setup_cursor ()
{
g_sl = new_skiplist(4, 2);
skiplist_insert(g_sl, (void*) 2);
skiplist_insert(g_sl, (void*) 4);
skiplist_insert(g_sl, (void*) 6);
skiplist_insert(g_sl, (void*) 8);
skiplist_insert(g_sl, (void*) 10);
}
void teardown_cursor ()
{
delete_skiplist(g_sl);
}
START_TEST (test_skiplist_cursor_empty)
{
s_skiplist *sl = new_skiplist(4, 2);
ck_assert(sl);
ck_assert(sl->length == 0);
ck_assert(!skiplist_cursor(sl, (void*) 1));
delete_skiplist(sl);
}
END_TEST
START_TEST (test_skiplist_cursor_start)
{
s_skiplist_node *n;
n = skiplist_cursor(g_sl, (void*) 0);
ck_assert(n);
ck_assert(n->value == (void*) 2);
n = skiplist_cursor(g_sl, (void*) 1);
ck_assert(n);
ck_assert(n->value == (void*) 2);
n = skiplist_cursor(g_sl, (void*) 2);
ck_assert(n);
ck_assert(n->value == (void*) 2);
}
END_TEST
START_TEST (test_skiplist_cursor_middle)
{
s_skiplist_node *n;
n = skiplist_cursor(g_sl, (void*) 2);
ck_assert(n);
ck_assert(n->value == (void*) 2);
n = skiplist_cursor(g_sl, (void*) 3);
ck_assert(n);
ck_assert(n->value == (void*) 4);
n = skiplist_cursor(g_sl, (void*) 4);
ck_assert(n);
ck_assert(n->value == (void*) 4);
n = skiplist_cursor(g_sl, (void*) 5);
ck_assert(n);
ck_assert(n->value == (void*) 6);
n = skiplist_cursor(g_sl, (void*) 6);
ck_assert(n);
ck_assert(n->value == (void*) 6);
}
END_TEST
START_TEST (test_skiplist_cursor_end)
{
s_skiplist_node *n;
n = skiplist_cursor(g_sl, (void*) 9);
ck_assert(n);
ck_assert(n->value == (void*) 10);
n = skiplist_cursor(g_sl, (void*) 10);
ck_assert(n);
ck_assert(n->value == (void*) 10);
n = skiplist_cursor(g_sl, (void*) 11);
ck_assert(!n);
}
END_TEST
void setup_iter ()
{
g_sl = new_skiplist(4, 2);
skiplist_insert(g_sl, (void*) 2);
skiplist_insert(g_sl, (void*) 4);
skiplist_insert(g_sl, (void*) 6);
skiplist_insert(g_sl, (void*) 8);
skiplist_insert(g_sl, (void*) 10);
}
void teardown_iter ()
{
delete_skiplist(g_sl);
}
START_TEST (test_skiplist_iter_empty)
{
s_skiplist *sl = new_skiplist(4, 2);
s_skiplist_cursor c;
ck_assert(sl);
ck_assert(sl->length == 0);
skiplist_cursor_init(sl, &c, (void*) 1, NULL);
ck_assert(!skiplist_cursor_next(&c));
delete_skiplist(sl);
}
END_TEST
START_TEST (test_skiplist_iter_start)
{
s_skiplist_cursor c;
s_skiplist_node *n;
skiplist_cursor_init(g_sl, &c, (void*) 0, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 2);
skiplist_cursor_init(g_sl, &c, (void*) 1, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 2);
skiplist_cursor_init(g_sl, &c, (void*) 2, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 2);
skiplist_cursor_init(g_sl, &c, (void*) 2, (void*) 2);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 2);
n = skiplist_cursor_next(&c);
ck_assert(!n);
n = skiplist_cursor_next(&c);
ck_assert(!n);
}
END_TEST
START_TEST (test_skiplist_iter_middle)
{
s_skiplist_cursor c;
s_skiplist_node *n;
skiplist_cursor_init(g_sl, &c, (void*) 2, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 2);
skiplist_cursor_init(g_sl, &c, (void*) 3, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 4);
skiplist_cursor_init(g_sl, &c, (void*) 4, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 4);
skiplist_cursor_init(g_sl, &c, (void*) 5, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 6);
skiplist_cursor_init(g_sl, &c, (void*) 6, (void*) 6);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 6);
n = skiplist_cursor_next(&c);
ck_assert(!n);
n = skiplist_cursor_next(&c);
ck_assert(!n);
}
END_TEST
START_TEST (test_skiplist_iter_end)
{
s_skiplist_cursor c;
s_skiplist_node *n;
skiplist_cursor_init(g_sl, &c, (void*) 9, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 10);
skiplist_cursor_init(g_sl, &c, (void*) 10, NULL);
n = skiplist_cursor_next(&c);
ck_assert(n);
ck_assert(n->value == (void*) 10);
skiplist_cursor_init(g_sl, &c, (void*) 11, NULL);
n = skiplist_cursor_next(&c);
ck_assert(!n);
}
END_TEST
Suite * skiplist_suite(void)
{
Suite *s;
TCase *tc_core;
TCase *tc_inserts;
TCase *tc_pred;
TCase *tc_remove;
TCase *tc_cursor;
TCase *tc_iter;
s = suite_create("Skiplist");
tc_core = tcase_create("Core");
tcase_add_test(tc_core, test_skiplist_new_delete);
tcase_add_test(tc_core, test_skiplist_init_destroy);
suite_add_tcase(s, tc_core);
tc_inserts = tcase_create("Inserts");
tcase_add_checked_fixture(tc_inserts, setup_inserts, teardown_inserts);
tcase_add_test(tc_inserts, test_skiplist_insert_one);
tcase_add_test(tc_inserts, test_skiplist_insert_two);
tcase_add_test(tc_inserts, test_skiplist_insert_ten);
suite_add_tcase(s, tc_inserts);
tc_pred = tcase_create("Pred");
tcase_add_checked_fixture(tc_pred, setup_pred, teardown_pred);
tcase_add_test(tc_pred, test_skiplist_pred_empty);
tcase_add_test(tc_pred, test_skiplist_pred_before_first);
tcase_add_test(tc_pred, test_skiplist_pred_first);
tcase_add_test(tc_pred, test_skiplist_pred_last);
tcase_add_test(tc_pred, test_skiplist_pred_after_last);
suite_add_tcase(s, tc_pred);
tc_remove = tcase_create("Remove");
tcase_add_checked_fixture(tc_remove, setup_remove, teardown_remove);
tcase_add_test(tc_remove, test_skiplist_remove_nonexistent);
tcase_add_test(tc_remove, test_skiplist_remove_first);
tcase_add_test(tc_remove, test_skiplist_remove_last);
tcase_add_test(tc_remove, test_skiplist_remove_middle);
tcase_add_test(tc_remove, test_skiplist_remove_all);
suite_add_tcase(s, tc_remove);
tc_cursor = tcase_create("Cursor");
tcase_add_checked_fixture(tc_cursor, setup_cursor, teardown_cursor);
tcase_add_test(tc_cursor, test_skiplist_cursor_empty);
tcase_add_test(tc_cursor, test_skiplist_cursor_start);
tcase_add_test(tc_cursor, test_skiplist_cursor_middle);
tcase_add_test(tc_cursor, test_skiplist_cursor_end);
suite_add_tcase(s, tc_cursor);
tc_iter = tcase_create("Iter");
tcase_add_checked_fixture(tc_iter, setup_iter, teardown_iter);
tcase_add_test(tc_iter, test_skiplist_iter_empty);
tcase_add_test(tc_iter, test_skiplist_iter_start);
tcase_add_test(tc_iter, test_skiplist_iter_middle);
tcase_add_test(tc_iter, test_skiplist_iter_end);
suite_add_tcase(s, tc_iter);
return s;
}
int main(void)
{
int number_failed;
Suite *s;
SRunner *sr;
s = skiplist_suite();
sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
return (number_failed == 0) ? 0 : 1;
}
| 31.1 | 76 | 0.616817 |
c1d98daa79e7aab8d4a6e77e645f80345bdd5d95 | 870 | h | C | products/BGX13/demos/longrangedemo/fw/EFM8UB1_LongRangeDemo_BGX/inc/scanning.h | markltownsend/wireless-xpress | 6e1979e7cb995faef9097dae0d7d79d11576525e | [
"Apache-2.0"
] | 21 | 2019-01-09T04:19:30.000Z | 2022-02-16T15:57:08.000Z | products/BGX13/demos/longrangedemo/fw/EFM8UB1_LongRangeDemo_BGX/inc/scanning.h | markltownsend/wireless-xpress | 6e1979e7cb995faef9097dae0d7d79d11576525e | [
"Apache-2.0"
] | null | null | null | products/BGX13/demos/longrangedemo/fw/EFM8UB1_LongRangeDemo_BGX/inc/scanning.h | markltownsend/wireless-xpress | 6e1979e7cb995faef9097dae0d7d79d11576525e | [
"Apache-2.0"
] | 30 | 2018-11-08T03:07:27.000Z | 2021-11-07T10:47:08.000Z | /*****************************************************************************/
/* scanning.h */
/*****************************************************************************/
#ifndef SCANNING_H_
#define SCANNING_H_
/*****************************************************************************/
/* Function Prototypes */
/*****************************************************************************/
// Drawing functions
void Scanning_drawScanningScreen(void);
void Scanning_drawNoScanResultsScreen(void);
void Scanning_drawScanResultsScreen(void);
void Scanning_drawConnectedScreen(void);
void Scanning_drawInventoryInfo(uint8_t numCans);
// TODO
uint8_t Scanning_selectDevice(void);
// TODO
void Scanning_main(void);
#endif /* SCANNING_H_ */
| 33.461538 | 79 | 0.398851 |
ee2db74c1102ca59c3b9923c3589718800da5650 | 5,003 | h | C | include/fast_io_hosted/platforms/linux/riscv64.h | fastio-official/fast_io | c95a360c37bbe7e18af053771a23c08e6a2ca1f7 | [
"MIT"
] | 53 | 2022-02-19T18:28:36.000Z | 2022-03-29T06:54:03.000Z | include/fast_io_hosted/platforms/linux/riscv64.h | fastio-official/fast_io | c95a360c37bbe7e18af053771a23c08e6a2ca1f7 | [
"MIT"
] | 5 | 2022-03-05T14:10:29.000Z | 2022-03-28T02:43:16.000Z | include/fast_io_hosted/platforms/linux/riscv64.h | fastio-official/fast_io | c95a360c37bbe7e18af053771a23c08e6a2ca1f7 | [
"MIT"
] | 17 | 2022-02-19T20:16:18.000Z | 2022-03-29T20:50:49.000Z | #pragma once
/*
https://github.com/riscvarchive/riscv-musl/blob/develop/arch/riscv64/syscall_arch.h
Do we need to deal with big endian with extra code???
*/
namespace fast_io
{
template<std::uint_least64_t syscall_number,std::signed_integral return_value_type>
requires (1<sizeof(return_value_type))
inline return_value_type system_call() noexcept
{
register std::uint_least64_t a7 __asm__("a7") = syscall_number;
register std::uint_least64_t a0 __asm__("a0");
__asm__ __volatile__
("ecall"
: "+r" (a0)
: "r"(a7)
: "memory"
);
return static_cast<return_value_type>(a0);
}
template<std::uint_least64_t syscall_number,std::signed_integral return_value_type>
requires (1<sizeof(return_value_type))
inline return_value_type system_call(auto p1) noexcept
{
register std::uint_least64_t a7 __asm__("a7") = syscall_number;
register std::uint_least64_t a0 __asm__("a0") = (std::uint_least64_t)p1;
__asm__ __volatile__
("ecall"
: "+r" (a0)
: "r"(a7)
: "memory"
);
return static_cast<return_value_type>(a0);
}
template<std::uint_least64_t syscall_number>
inline void system_call_no_return(auto p1) noexcept
{
register std::uint_least64_t a7 __asm__("a7") = syscall_number;
register std::uint_least64_t a0 __asm__("a0") = (std::uint_least64_t)p1;
__asm__ __volatile__
("ecall"
: "+r" (a0)
: "r"(a7)
: "memory"
);
}
template<std::uint_least64_t syscall_number,std::signed_integral return_value_type>
requires (1<sizeof(return_value_type))
inline return_value_type system_call(auto p1,auto p2) noexcept
{
register std::uint_least64_t a7 __asm__("a7") = syscall_number;
register std::uint_least64_t a0 __asm__("a0") = (std::uint_least64_t)p1;
register std::uint_least64_t a1 __asm__("a1") = (std::uint_least64_t)p2;
__asm__ __volatile__
("ecall"
: "+r" (a0)
: "r"(a7), "r"(a1)
: "memory"
);
return static_cast<return_value_type>(a0);
}
template<std::uint_least64_t syscall_number,std::signed_integral return_value_type>
requires (1<sizeof(return_value_type))
inline return_value_type system_call(auto p1,auto p2,auto p3) noexcept
{
register std::uint_least64_t a7 __asm__("a7") = syscall_number;
register std::uint_least64_t a0 __asm__("a0") = (std::uint_least64_t)p1;
register std::uint_least64_t a1 __asm__("a1") = (std::uint_least64_t)p2;
register std::uint_least64_t a2 __asm__("a2") = (std::uint_least64_t)p3;
__asm__ __volatile__
("ecall"
: "+r" (a0)
: "r"(a7), "r"(a1), "r"(a2)
: "memory"
);
return static_cast<return_value_type>(a0);
}
template<std::uint_least64_t syscall_number,std::signed_integral return_value_type>
requires (1<sizeof(return_value_type))
inline return_value_type system_call(auto p1,auto p2,auto p3,auto p4) noexcept
{
register std::uint_least64_t a7 __asm__("a7") = syscall_number;
register std::uint_least64_t a0 __asm__("a0") = (std::uint_least64_t)p1;
register std::uint_least64_t a1 __asm__("a1") = (std::uint_least64_t)p2;
register std::uint_least64_t a2 __asm__("a2") = (std::uint_least64_t)p3;
register std::uint_least64_t a3 __asm__("a3") = (std::uint_least64_t)p4;
__asm__ __volatile__
("ecall"
: "+r" (a0)
: "r"(a7), "r"(a1), "r"(a2), "r"(a3)
: "memory"
);
return static_cast<return_value_type>(a0);
}
template<std::uint_least64_t syscall_number,std::signed_integral return_value_type>
requires (1<sizeof(return_value_type))
inline return_value_type system_call(auto p1,auto p2,auto p3,auto p4,auto p5) noexcept
{
register std::uint_least64_t a7 __asm__("a7") = syscall_number;
register std::uint_least64_t a0 __asm__("a0") = (std::uint_least64_t)p1;
register std::uint_least64_t a1 __asm__("a1") = (std::uint_least64_t)p2;
register std::uint_least64_t a2 __asm__("a2") = (std::uint_least64_t)p3;
register std::uint_least64_t a3 __asm__("a3") = (std::uint_least64_t)p4;
register std::uint_least64_t a4 __asm__("a4") = (std::uint_least64_t)p5;
__asm__ __volatile__
("ecall"
: "+r" (a0)
: "r"(a7), "r"(a1), "r"(a2), "r"(a3), "r"(a4)
: "memory"
);
return static_cast<return_value_type>(a0);
}
template<std::uint_least64_t syscall_number,std::signed_integral return_value_type>
requires (1<sizeof(return_value_type))
inline return_value_type system_call(auto p1,auto p2,auto p3,auto p4,auto p5,auto p6) noexcept
{
register std::uint_least64_t a7 __asm__("a7") = syscall_number;
register std::uint_least64_t a0 __asm__("a0") = (std::uint_least64_t)p1;
register std::uint_least64_t a1 __asm__("a1") = (std::uint_least64_t)p2;
register std::uint_least64_t a2 __asm__("a2") = (std::uint_least64_t)p3;
register std::uint_least64_t a3 __asm__("a3") = (std::uint_least64_t)p4;
register std::uint_least64_t a4 __asm__("a4") = (std::uint_least64_t)p5;
register std::uint_least64_t a5 __asm__("a5") = (std::uint_least64_t)p6;
__asm__ __volatile__
("ecall"
: "+r" (a0)
: "r"(a7), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5)
: "memory"
);
return static_cast<return_value_type>(a0);
}
template<std::integral I>
inline void fast_exit(I ret) noexcept
{
system_call_no_return<__NR_exit>(ret);
}
}
| 33.13245 | 94 | 0.738957 |
6e6d3606d29b00245b25243248aa176afe8f0600 | 253 | h | C | src/homework/01_variables/variables.h | acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-blacksea2003 | c3e3c7e5d08cd1b397346d209095f67714f76689 | [
"MIT"
] | null | null | null | src/homework/01_variables/variables.h | acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-blacksea2003 | c3e3c7e5d08cd1b397346d209095f67714f76689 | [
"MIT"
] | null | null | null | src/homework/01_variables/variables.h | acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-blacksea2003 | c3e3c7e5d08cd1b397346d209095f67714f76689 | [
"MIT"
] | null | null | null | //example
int xadd_numbers(int num1, int num2);
//write function prototype for multiply_numbers with two integer parameters num1, and num2
double xget_sales_tax_amount(double meal_amount);
double xget_tip_amount(double meal_amount,double tip_rate);
| 28.111111 | 90 | 0.822134 |
550424fab7978e576a31849cb9184f9b3ba399f9 | 632 | cshtml | C# | TournamentsMVC/Views/Chat/_UserMessage.cshtml | Krassimir-ILLIEV/TournamentsMVC | 1549a05a8be06f4648761bd75204956c86464858 | [
"MIT"
] | null | null | null | TournamentsMVC/Views/Chat/_UserMessage.cshtml | Krassimir-ILLIEV/TournamentsMVC | 1549a05a8be06f4648761bd75204956c86464858 | [
"MIT"
] | null | null | null | TournamentsMVC/Views/Chat/_UserMessage.cshtml | Krassimir-ILLIEV/TournamentsMVC | 1549a05a8be06f4648761bd75204956c86464858 | [
"MIT"
] | null | null | null |
<li class="right clearfix">
<span class="chat-img pull-right">
<img src="http://placehold.it/50/FA6F57/fff&text=ME" alt="User Avatar" class="img-circle" />
</span>
<div class="chat-body clearfix">
<div class="header">
<small class=" text-muted"><span class="glyphicon glyphicon-time"></span>13 mins ago</small>
<strong class="pull-right primary-font">Bhaumik Patel</strong>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare
dolor, quis ullamcorper ligula sodales.
</p>
</div>
</li>
| 37.176471 | 104 | 0.60443 |
2b7233d62e9c128eedfbdbe3e4d97ee605674cdb | 7,095 | cs | C# | Lpp.Dns.Portal/Areas/DataChecker/Controllers/MetaDataController.cs | Missouri-BMI/popmednet | f185092be45187f3db4966f67066e89bae30c4d6 | [
"Apache-2.0"
] | null | null | null | Lpp.Dns.Portal/Areas/DataChecker/Controllers/MetaDataController.cs | Missouri-BMI/popmednet | f185092be45187f3db4966f67066e89bae30c4d6 | [
"Apache-2.0"
] | null | null | null | Lpp.Dns.Portal/Areas/DataChecker/Controllers/MetaDataController.cs | Missouri-BMI/popmednet | f185092be45187f3db4966f67066e89bae30c4d6 | [
"Apache-2.0"
] | null | null | null | using Lpp.Dns.Portal.Root.Areas.DataChecker.Models;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Linq;
using System.Data;
using System.Linq.Expressions;
using System;
using Lpp.Dns.Data;
using Lpp.Dns.DTO.QueryComposer;
namespace Lpp.Dns.Portal.Root.Areas.DataChecker.Controllers
{
public class MetaDataController : BaseController
{
[HttpGet]
public ActionResult MetaDataResponse()
{
return View();
}
[HttpGet]
public JsonResult GetTermValues(Guid? requestID)
{
if (requestID == null)
{
return Json(null, JsonRequestBehavior.AllowGet);
}
using (var db = new DataContext())
{
var req = db.Requests.Find(requestID);
QueryComposerRequestDTO dto = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryComposerRequestDTO>(req.Query);
var criteria = dto.Where.Criteria.Where(c => c.Terms.Any(t => t.Type == Lpp.QueryComposer.ModelTermsFactory.DC_MetadataCompleteness)).FirstOrDefault();
var term = criteria.Terms.First(t => t.Type == Lpp.QueryComposer.ModelTermsFactory.DC_MetadataCompleteness);
var termValues = term.Values.First(p => p.Key == "Values");
MetadataCompletenessValues val = Newtonsoft.Json.JsonConvert.DeserializeObject<MetadataCompletenessValues>(termValues.Value.ToString());
return Json(val.MetadataCompletenesses.ToArray(), JsonRequestBehavior.AllowGet);
}
}
static DataTable CreateTable(IEnumerable<IDictionary<string, object>> records)
{
var table = new DataTable();
table.Columns.Add("DP", typeof(string));
table.Columns.Add("ETL", typeof(short));
table.Columns.Add("DIA_MIN", typeof(DateTime));
table.Columns.Add("DIA_MAX", typeof(DateTime));
table.Columns.Add("DIS_MIN", typeof(DateTime));
table.Columns.Add("DIS_MAX", typeof(DateTime));
table.Columns.Add("ENC_MIN", typeof(DateTime));
table.Columns.Add("ENC_MAX", typeof(DateTime));
table.Columns.Add("ENR_MIN", typeof(DateTime));
table.Columns.Add("ENR_MAX", typeof(DateTime));
table.Columns.Add("PRO_MIN", typeof(DateTime));
table.Columns.Add("PRO_MAX", typeof(DateTime));
table.Columns.Add("DP_MIN", typeof(DateTime));
table.Columns.Add("DP_MAX", typeof(DateTime));
table.Columns.Add("MSDD_MIN", typeof(DateTime));
table.Columns.Add("MSDD_MAX", typeof(DateTime));
foreach (var rawRow in records)
{
DataRow dr = table.NewRow();
foreach (var col in rawRow)
{
string key = col.Key;
if (key == "DataPartner")
{
key = "DP";
}
dr[key] = col.Value;
}
table.Rows.Add(dr);
}
return table;
}
[HttpGet]
public JsonResult ProcessMetricsByResponse(Guid responseID)
{
DataTable dt = null;
string json = string.Empty;
using (var db = new DataContext())
{
var document = db.Documents.Where(r => r.ItemID == responseID).FirstOrDefault();
if (document == null)
{
return null;
}
var serializationSettings = new Newtonsoft.Json.JsonSerializerSettings();
serializationSettings.Converters.Add(new DTO.QueryComposer.QueryComposerResponsePropertyDefinitionConverter());
var deserializer = Newtonsoft.Json.JsonSerializer.Create(serializationSettings);
Type queryComposerResponseDTOType = typeof(DTO.QueryComposer.QueryComposerResponseDTO);
Lpp.Dns.DTO.QueryComposer.QueryComposerResponseDTO rsp;
using (var documentStream = new Data.Documents.DocumentStream(db, document.ID))
using (var streamReader = new System.IO.StreamReader(documentStream))
{
rsp = (Lpp.Dns.DTO.QueryComposer.QueryComposerResponseDTO)deserializer.Deserialize(streamReader, queryComposerResponseDTOType);
}
dt = CreateTable(rsp.Results.First());
}
if (dt == null)
{
return null;
}
return GetMetrics(dt);
}
[HttpGet]
public override JsonResult ProcessMetrics(Guid documentId)
{
var ds = LoadResults(documentId);
return GetMetrics(ds.Tables[0]);
}
public JsonResult GetMetrics(DataTable dataTable)
{
IEnumerable<MetaDataItemData> rawResults = (from x in dataTable.AsEnumerable()
select new MetaDataItemData
{
DP = x.Field<string>("DP"),
ETL = x.Field<short?>("ETL"),
DIA_MIN = x.Field<DateTime?>("DIA_MIN"),
DIA_MAX = x.Field<DateTime?>("DIA_MAX"),
DIS_MIN = x.Field<DateTime?>("DIS_MIN"),
DIS_MAX = x.Field<DateTime?>("DIS_MAX"),
ENC_MIN = x.Field<DateTime?>("ENC_MIN"),
ENC_MAX = x.Field<DateTime?>("ENC_MAX"),
ENR_MIN = x.Field<DateTime?>("ENR_MIN"),
ENR_MAX = x.Field<DateTime?>("ENR_MAX"),
PRO_MIN = x.Field<DateTime?>("PRO_MIN"),
PRO_MAX = x.Field<DateTime?>("PRO_MAX"),
DP_MIN = x.Field<DateTime?>("DP_MIN"),
DP_MAX = x.Field<DateTime?>("DP_MAX"),
MSDD_MIN = x.Field<DateTime?>("MSDD_MIN"),
MSDD_MAX = x.Field<DateTime?>("MSDD_MAX"),
}).OrderBy(x => x.DP).ToArray();
return Json(new { Results = rawResults }, JsonRequestBehavior.AllowGet);
}
}
public class MetadataCompletenessValues
{
public MetadataCompletenessValues()
{
MetadataCompletenesses = new List<int>();
}
public IEnumerable<int> MetadataCompletenesses { get; set; }
}
}
| 43 | 167 | 0.504299 |
65c6739352d8ae22fdd83eff461b47db9c352e74 | 601 | cs | C# | CP77.CR2W/Types/cp77/questSetMetaQuestProgress_NodeType.cs | MasterScott/CP77Tools | c0c397ea57217451364c75acefc288ce93559296 | [
"MIT"
] | 1 | 2021-01-27T18:03:13.000Z | 2021-01-27T18:03:13.000Z | CP77.CR2W/Types/cp77/questSetMetaQuestProgress_NodeType.cs | MasterScott/CP77Tools | c0c397ea57217451364c75acefc288ce93559296 | [
"MIT"
] | null | null | null | CP77.CR2W/Types/cp77/questSetMetaQuestProgress_NodeType.cs | MasterScott/CP77Tools | c0c397ea57217451364c75acefc288ce93559296 | [
"MIT"
] | null | null | null | using System.IO;
using CP77.CR2W.Reflection;
using FastMember;
using static CP77.CR2W.Types.Enums;
namespace CP77.CR2W.Types
{
[REDMeta]
public class questSetMetaQuestProgress_NodeType : questIUIManagerNodeType
{
[Ordinal(0)] [RED("metaQuestId")] public CEnum<gamedataMetaQuest> MetaQuestId { get; set; }
[Ordinal(1)] [RED("percent")] public CUInt32 Percent { get; set; }
[Ordinal(2)] [RED("text")] public LocalizationString Text { get; set; }
public questSetMetaQuestProgress_NodeType(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, parent, name) { }
}
}
| 33.388889 | 121 | 0.718802 |
5aafc71405f13cc4d4c250a0cc0fe39156b9df48 | 1,611 | cs | C# | Telerik.Examples.Mvc/Telerik.Examples.Mvc/Controllers/Grid/AjaxBindingController.cs | pchenatwork/ui-for-aspnet-core-examples | f7d0e2ca8aad33d681fdf6941b27ef7671e5b443 | [
"MIT"
] | 68 | 2019-02-08T12:45:43.000Z | 2022-03-27T01:38:13.000Z | Telerik.Examples.Mvc/Telerik.Examples.Mvc/Controllers/Grid/AjaxBindingController.cs | pchenatwork/ui-for-aspnet-core-examples | f7d0e2ca8aad33d681fdf6941b27ef7671e5b443 | [
"MIT"
] | 11 | 2019-07-26T22:12:14.000Z | 2022-03-02T15:42:04.000Z | Telerik.Examples.Mvc/Telerik.Examples.Mvc/Controllers/Grid/AjaxBindingController.cs | pchenatwork/ui-for-aspnet-core-examples | f7d0e2ca8aad33d681fdf6941b27ef7671e5b443 | [
"MIT"
] | 38 | 2019-01-18T15:39:05.000Z | 2022-03-22T18:15:55.000Z | using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Telerik.Examples.Mvc.Models;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Microsoft.AspNetCore.Mvc;
namespace Telerik.Examples.Mvc.Controllers.Grid
{
public class AjaxBindingController : Controller
{
private static ICollection<Product> products;
public IActionResult AjaxBinding()
{
return View();
}
public AjaxBindingController()
{
if (products == null)
{
var random = new Random();
products = Enumerable.Range(1, 100).Select(x => new Product
{
Discontinued = x % 2 == 1,
ProductID = x,
ProductName = "Product " + x,
UnitPrice = random.Next(1, 1000),
UnitsInStock = random.Next(1, 1000),
UnitsOnOrder = random.Next(1, 1000)
}).ToList();
}
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return View();
}
public IActionResult Error()
{
return View();
}
public ActionResult Read([DataSourceRequest] DataSourceRequest request)
{
return Json(products.ToDataSourceResult(request));
}
}
} | 26.409836 | 79 | 0.529485 |
89c3c282f6ea988df567ac5a2c7a207390e896e5 | 478 | cs | C# | Assets/Mediapipe/Samples/UI/Scripts/ModalContents.cs | Restok/MediaPipeUnityPlugin | 7b75e1cf0f0a1a13488a86bf362a5430e07c7987 | [
"MIT"
] | 634 | 2020-10-06T16:16:09.000Z | 2022-03-31T13:01:57.000Z | Assets/Mediapipe/Samples/UI/Scripts/ModalContents.cs | Restok/MediaPipeUnityPlugin | 7b75e1cf0f0a1a13488a86bf362a5430e07c7987 | [
"MIT"
] | 453 | 2020-10-08T19:51:34.000Z | 2022-03-29T01:01:48.000Z | Assets/Mediapipe/Samples/UI/Scripts/ModalContents.cs | Restok/MediaPipeUnityPlugin | 7b75e1cf0f0a1a13488a86bf362a5430e07c7987 | [
"MIT"
] | 198 | 2020-10-25T11:31:11.000Z | 2022-03-31T04:07:26.000Z | // Copyright (c) 2021 homuler
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
using UnityEngine;
namespace Mediapipe.Unity.UI
{
public class ModalContents : MonoBehaviour
{
protected Modal GetModal()
{
return gameObject.transform.parent.gameObject.GetComponent<Modal>();
}
public virtual void Exit()
{
GetModal().Close();
}
}
}
| 19.916667 | 74 | 0.677824 |
d8e2df613899a04205791614fd194b39f487ec90 | 8,393 | cs | C# | Assets/Spine/Editor/spine-unity/Editor/AnimationReferenceAssetEditor.cs | hoonsyh/penrose | d5f957d384613d5767af2ddc725a33bee6476f96 | [
"MIT"
] | 1 | 2019-09-20T02:55:00.000Z | 2019-09-20T02:55:00.000Z | spine-unity/Assets/Spine/Editor/spine-unity/Editor/AnimationReferenceAssetEditor.cs | Kogarasi/spine-runtimes | 915b67bcc7b265953dc9336e03610d5de24b4754 | [
"RSA-MD"
] | null | null | null | spine-unity/Assets/Spine/Editor/spine-unity/Editor/AnimationReferenceAssetEditor.cs | Kogarasi/spine-runtimes | 915b67bcc7b265953dc9336e03610d5de24b4754 | [
"RSA-MD"
] | null | null | null | /******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) 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.
*****************************************************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
namespace Spine.Unity.Editor {
using Editor = UnityEditor.Editor;
[CustomEditor(typeof(AnimationReferenceAsset))]
public class AnimationReferenceAssetEditor : Editor {
const string InspectorHelpText = "This is a Spine-Unity Animation Reference Asset. It serializes a reference to a SkeletonDataAsset and an animationName. It does not contain actual animation data. At runtime, it stores a reference to a Spine.Animation.\n\n" +
"You can use this in your AnimationState calls instead of a string animation name or a Spine.Animation reference. Use its implicit conversion into Spine.Animation or its .Animation property.\n\n" +
"Use AnimationReferenceAssets as an alternative to storing strings or finding animations and caching per component. This only does the lookup by string once, and allows you to store and manage animations via asset references.";
readonly SkeletonInspectorPreview preview = new SkeletonInspectorPreview();
FieldInfo skeletonDataAssetField = typeof(AnimationReferenceAsset).GetField("skeletonDataAsset", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo nameField = typeof(AnimationReferenceAsset).GetField("animationName", BindingFlags.NonPublic | BindingFlags.Instance);
AnimationReferenceAsset ThisAnimationReferenceAsset { get { return target as AnimationReferenceAsset; } }
SkeletonDataAsset ThisSkeletonDataAsset { get { return skeletonDataAssetField.GetValue(ThisAnimationReferenceAsset) as SkeletonDataAsset; } }
string ThisAnimationName { get { return nameField.GetValue(ThisAnimationReferenceAsset) as string; } }
bool changeNextFrame = false;
SerializedProperty animationNameProperty;
SkeletonDataAsset lastSkeletonDataAsset;
SkeletonData lastSkeletonData;
void OnEnable () { HandleOnEnablePreview(); }
void OnDestroy () { HandleOnDestroyPreview(); }
public override void OnInspectorGUI () {
animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName");
string animationName = animationNameProperty.stringValue;
Animation animation = null;
if (ThisSkeletonDataAsset != null) {
var skeletonData = ThisSkeletonDataAsset.GetSkeletonData(true);
if (skeletonData != null) {
animation = skeletonData.FindAnimation(animationName);
}
}
bool animationNotFound = (animation == null);
if (changeNextFrame) {
changeNextFrame = false;
if (ThisSkeletonDataAsset != lastSkeletonDataAsset || ThisSkeletonDataAsset.GetSkeletonData(true) != lastSkeletonData) {
preview.Clear();
preview.Initialize(Repaint, ThisSkeletonDataAsset, LastSkinName);
if (animationNotFound) {
animationNameProperty.stringValue = "";
preview.ClearAnimationSetupPose();
}
}
preview.ClearAnimationSetupPose();
if (!string.IsNullOrEmpty(animationNameProperty.stringValue))
preview.PlayPauseAnimation(animationNameProperty.stringValue, true);
}
lastSkeletonDataAsset = ThisSkeletonDataAsset;
lastSkeletonData = ThisSkeletonDataAsset.GetSkeletonData(true);
//EditorGUILayout.HelpBox(AnimationReferenceAssetEditor.InspectorHelpText, MessageType.Info, true);
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
DrawDefaultInspector();
if (EditorGUI.EndChangeCheck()) {
changeNextFrame = true;
}
// Draw extra info below default inspector.
EditorGUILayout.Space();
if (ThisSkeletonDataAsset == null) {
EditorGUILayout.HelpBox("SkeletonDataAsset is missing.", MessageType.Error);
} else if (string.IsNullOrEmpty(animationName)) {
EditorGUILayout.HelpBox("No animation selected.", MessageType.Warning);
} else if (animationNotFound) {
EditorGUILayout.HelpBox(string.Format("Animation named {0} was not found for this Skeleton.", animationNameProperty.stringValue), MessageType.Warning);
} else {
using (new SpineInspectorUtility.BoxScope()) {
if (!string.Equals(SpineEditorUtilities.AssetUtility.GetPathSafeName(animationName), ThisAnimationReferenceAsset.name, System.StringComparison.OrdinalIgnoreCase))
EditorGUILayout.HelpBox("Animation name value does not match this asset's name. Inspectors using this asset may be misleading.", MessageType.None);
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(animationName, SpineEditorUtilities.Icons.animation));
if (animation != null) {
EditorGUILayout.LabelField(string.Format("Timelines: {0}", animation.Timelines.Count));
EditorGUILayout.LabelField(string.Format("Duration: {0} sec", animation.Duration));
}
}
}
}
#region Preview Handlers
string TargetAssetGUID { get { return AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(ThisSkeletonDataAsset)); } }
string LastSkinKey { get { return TargetAssetGUID + "_lastSkin"; } }
string LastSkinName { get { return EditorPrefs.GetString(LastSkinKey, ""); } }
void HandleOnEnablePreview () {
if (ThisSkeletonDataAsset != null && ThisSkeletonDataAsset.skeletonJSON == null)
return;
preview.Initialize(this.Repaint, ThisSkeletonDataAsset, LastSkinName);
preview.PlayPauseAnimation(ThisAnimationName, true);
preview.OnSkinChanged -= HandleOnSkinChanged;
preview.OnSkinChanged += HandleOnSkinChanged;
EditorApplication.update -= preview.HandleEditorUpdate;
EditorApplication.update += preview.HandleEditorUpdate;
}
private void HandleOnSkinChanged (string skinName) {
EditorPrefs.SetString(LastSkinKey, skinName);
preview.PlayPauseAnimation(ThisAnimationName, true);
}
void HandleOnDestroyPreview () {
EditorApplication.update -= preview.HandleEditorUpdate;
preview.OnDestroy();
}
override public bool HasPreviewGUI () {
if (serializedObject.isEditingMultipleObjects) return false;
return ThisSkeletonDataAsset != null && ThisSkeletonDataAsset.GetSkeletonData(true) != null;
}
override public void OnInteractivePreviewGUI (Rect r, GUIStyle background) {
preview.Initialize(this.Repaint, ThisSkeletonDataAsset);
preview.HandleInteractivePreviewGUI(r, background);
}
public override GUIContent GetPreviewTitle () { return SpineInspectorUtility.TempContent("Preview"); }
public override void OnPreviewSettings () { preview.HandleDrawSettings(); }
public override Texture2D RenderStaticPreview (string assetPath, UnityEngine.Object[] subAssets, int width, int height) { return preview.GetStaticPreview(width, height); }
#endregion
}
}
| 48.514451 | 261 | 0.759442 |
2b1cc3ddcf722d4c04baa6badba7b613d9dc295b | 1,040 | cs | C# | WindowsAzurePowershell/src/VhdManagement/Model/PlatformCode.cs | OctopusDeploy/azure-sdk-tools | f48be9846c047c7072cef282383e21b3235c0d4f | [
"Apache-2.0"
] | 1 | 2015-08-03T15:16:52.000Z | 2015-08-03T15:16:52.000Z | WindowsAzurePowershell/src/VhdManagement/Model/PlatformCode.cs | OctopusDeploy/azure-sdk-tools | f48be9846c047c7072cef282383e21b3235c0d4f | [
"Apache-2.0"
] | null | null | null | WindowsAzurePowershell/src/VhdManagement/Model/PlatformCode.cs | OctopusDeploy/azure-sdk-tools | f48be9846c047c7072cef282383e21b3235c0d4f | [
"Apache-2.0"
] | null | null | null | // ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// 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.
// ----------------------------------------------------------------------------------
namespace Microsoft.WindowsAzure.Management.Tools.Vhd.Model
{
public enum PlatformCode
{
None = 0x0,
Wi2R = 0x57693272,
Wi2K = 0x5769326B,
W2Ru = 0x57327275,
W2Ku = 0x57326B75,
Mac = 0x4D616320,
MacX = 0x4D616358
}
} | 38.518519 | 85 | 0.586538 |
d390f5ed570b6d6fd95aa976a1030426c517c41e | 1,210 | cs | C# | .Src/Extend.Testing/System.Collections.Generic.IEnumerable[T]/IEnumerable[T].Prepend.Test.cs | DaveSenn/PortableExtensions | 481aa12882d141468c5026ff1416790d21c74ece | [
"MIT"
] | 38 | 2015-08-05T09:09:09.000Z | 2020-09-25T17:55:24.000Z | .Src/Extend.Testing/System.Collections.Generic.IEnumerable[T]/IEnumerable[T].Prepend.Test.cs | DaveSenn/PortableExtensions | 481aa12882d141468c5026ff1416790d21c74ece | [
"MIT"
] | 6 | 2016-03-17T22:37:56.000Z | 2018-10-29T20:56:48.000Z | .Src/Extend.Testing/System.Collections.Generic.IEnumerable[T]/IEnumerable[T].Prepend.Test.cs | DaveSenn/PortableExtensions | 481aa12882d141468c5026ff1416790d21c74ece | [
"MIT"
] | 15 | 2016-02-12T10:26:59.000Z | 2022-01-02T10:22:53.000Z | #region Usings
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Xunit;
#endregion
namespace Extend.Testing
{
// ReSharper disable once InconsistentNaming
public partial class IEnumerableTExTest
{
[Fact]
public void PrependArgumentNullExceptionTest()
{
List<String> list = null;
// ReSharper disable once AssignNullToNotNullAttribute
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
Action test = () => list.Prepend( "d" );
Assert.Throws<ArgumentNullException>( test );
}
[Fact]
public void PrependTest()
{
var list = new List<String> { "a", "b", "c" };
var actual = list.Prepend( "d" );
list.Should()
.HaveCount( 3 );
// ReSharper disable once PossibleMultipleEnumeration
actual.Should()
.Contain( "d" );
// ReSharper disable once PossibleMultipleEnumeration
actual.ElementAt( 0 )
.Should()
.Be( "d" );
}
}
} | 27.5 | 71 | 0.540496 |
91414c17302c744416234fee12f15159f3bbe8d3 | 15,936 | cs | C# | src/Controls/src/Core/Layout/FlexLayout.cs | PureWeen/maui | 62e647ed697cab909b56ce5f890c03ed050fa73c | [
"MIT"
] | 1 | 2021-11-15T07:35:23.000Z | 2021-11-15T07:35:23.000Z | src/Controls/src/Core/Layout/FlexLayout.cs | L10Messi10/maui | fec9b4831c69a8cdb444cada1e014e0e350994c4 | [
"MIT"
] | null | null | null | src/Controls/src/Core/Layout/FlexLayout.cs | L10Messi10/maui | fec9b4831c69a8cdb444cada1e014e0e350994c4 | [
"MIT"
] | null | null | null | using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Layouts;
using Flex = Microsoft.Maui.Layouts.Flex;
// This is a temporary namespace until we rename everything and move the legacy layouts
namespace Microsoft.Maui.Controls.Layout2
{
[ContentProperty(nameof(Children))]
public class FlexLayout : Layout, IFlexLayout
{
Flex.Item _root;
public static readonly BindableProperty DirectionProperty =
BindableProperty.Create(nameof(Direction), typeof(FlexDirection), typeof(FlexLayout), FlexDirection.Row,
propertyChanged: OnDirectionPropertyChanged);
public static readonly BindableProperty JustifyContentProperty =
BindableProperty.Create(nameof(JustifyContent), typeof(FlexJustify), typeof(FlexLayout), FlexJustify.Start,
propertyChanged: OnJustifyContentPropertyChanged);
public static readonly BindableProperty AlignContentProperty =
BindableProperty.Create(nameof(AlignContent), typeof(FlexAlignContent), typeof(FlexLayout), FlexAlignContent.Stretch,
propertyChanged: OnAlignContentPropertyChanged);
public static readonly BindableProperty AlignItemsProperty =
BindableProperty.Create(nameof(AlignItems), typeof(FlexAlignItems), typeof(FlexLayout), FlexAlignItems.Stretch,
propertyChanged: OnAlignItemsPropertyChanged);
public static readonly BindableProperty PositionProperty =
BindableProperty.Create(nameof(Position), typeof(FlexPosition), typeof(FlexLayout), FlexPosition.Relative,
propertyChanged: OnPositionPropertyChanged);
public static readonly BindableProperty WrapProperty =
BindableProperty.Create(nameof(Wrap), typeof(FlexWrap), typeof(FlexLayout), FlexWrap.NoWrap,
propertyChanged: OnWrapPropertyChanged);
public static readonly BindableProperty OrderProperty =
BindableProperty.CreateAttached("Order", typeof(int), typeof(FlexLayout), default(int),
propertyChanged: OnOrderPropertyChanged);
public static readonly BindableProperty GrowProperty =
BindableProperty.CreateAttached("Grow", typeof(float), typeof(FlexLayout), default(float),
propertyChanged: OnGrowPropertyChanged, validateValue: (bindable, value) => (float)value >= 0);
public static readonly BindableProperty ShrinkProperty =
BindableProperty.CreateAttached("Shrink", typeof(float), typeof(FlexLayout), 1f,
propertyChanged: OnShrinkPropertyChanged, validateValue: (bindable, value) => (float)value >= 0);
public static readonly BindableProperty AlignSelfProperty =
BindableProperty.CreateAttached("AlignSelf", typeof(FlexAlignSelf), typeof(FlexLayout), FlexAlignSelf.Auto,
propertyChanged: OnAlignSelfPropertyChanged);
public static readonly BindableProperty BasisProperty =
BindableProperty.CreateAttached("Basis", typeof(FlexBasis), typeof(FlexLayout), FlexBasis.Auto,
propertyChanged: OnBasisPropertyChanged);
public FlexDirection Direction
{
get => (FlexDirection)GetValue(DirectionProperty);
set => SetValue(DirectionProperty, value);
}
public FlexJustify JustifyContent
{
get => (FlexJustify)GetValue(JustifyContentProperty);
set => SetValue(JustifyContentProperty, value);
}
public FlexAlignContent AlignContent
{
get => (FlexAlignContent)GetValue(AlignContentProperty);
set => SetValue(AlignContentProperty, value);
}
public FlexAlignItems AlignItems
{
get => (FlexAlignItems)GetValue(AlignItemsProperty);
set => SetValue(AlignItemsProperty, value);
}
public FlexPosition Position
{
get => (FlexPosition)GetValue(PositionProperty);
set => SetValue(PositionProperty, value);
}
public FlexWrap Wrap
{
get => (FlexWrap)GetValue(WrapProperty);
set => SetValue(WrapProperty, value);
}
public static int GetOrder(BindableObject bindable)
=> (int)bindable.GetValue(OrderProperty);
public static void SetOrder(BindableObject bindable, int value)
=> bindable.SetValue(OrderProperty, value);
public static float GetGrow(BindableObject bindable)
=> (float)bindable.GetValue(GrowProperty);
public static void SetGrow(BindableObject bindable, float value)
=> bindable.SetValue(GrowProperty, value);
public static float GetShrink(BindableObject bindable)
=> (float)bindable.GetValue(ShrinkProperty);
public static void SetShrink(BindableObject bindable, float value)
=> bindable.SetValue(ShrinkProperty, value);
public static FlexAlignSelf GetAlignSelf(BindableObject bindable)
=> (FlexAlignSelf)bindable.GetValue(AlignSelfProperty);
public static void SetAlignSelf(BindableObject bindable, FlexAlignSelf value)
=> bindable.SetValue(AlignSelfProperty, value);
public static FlexBasis GetBasis(BindableObject bindable)
=> (FlexBasis)bindable.GetValue(BasisProperty);
public static void SetBasis(BindableObject bindable, FlexBasis value)
=> bindable.SetValue(BasisProperty, value);
static readonly BindableProperty FlexItemProperty =
BindableProperty.CreateAttached("FlexItem", typeof(Flex.Item), typeof(FlexLayout), null);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static Flex.Item GetFlexItem(BindableObject bindable)
=> (Flex.Item)bindable.GetValue(FlexItemProperty);
static void OnOrderPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
if (!bindable.IsSet(FlexItemProperty))
return;
GetFlexItem(bindable).Order = (int)newValue;
((VisualElement)bindable).InvalidateMeasureInternal(InvalidationTrigger.Undefined);
}
static void OnGrowPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
if (!bindable.IsSet(FlexItemProperty))
return;
GetFlexItem(bindable).Grow = (float)newValue;
((VisualElement)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
}
static void OnShrinkPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
if (!bindable.IsSet(FlexItemProperty))
return;
GetFlexItem(bindable).Shrink = (float)newValue;
((VisualElement)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
}
static void OnAlignSelfPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
if (!bindable.IsSet(FlexItemProperty))
return;
GetFlexItem(bindable).AlignSelf = (Flex.AlignSelf)(FlexAlignSelf)newValue;
((VisualElement)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
}
static void OnBasisPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
if (!bindable.IsSet(FlexItemProperty))
return;
GetFlexItem(bindable).Basis = ((FlexBasis)newValue).ToFlexBasis();
((VisualElement)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
}
static void OnDirectionPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var flexLayout = bindable as FlexLayout;
if (flexLayout._root == null)
return;
flexLayout._root.Direction = (Flex.Direction)(FlexDirection)newValue;
flexLayout.InvalidateMeasure();
}
static void OnJustifyContentPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var flexLayout = bindable as FlexLayout;
if (flexLayout._root == null)
return;
flexLayout._root.JustifyContent = (Flex.Justify)(FlexJustify)newValue;
flexLayout.InvalidateMeasure();
}
static void OnAlignContentPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var flexLayout = bindable as FlexLayout;
if (flexLayout._root == null)
return;
flexLayout._root.AlignContent = (Flex.AlignContent)(FlexAlignContent)newValue;
flexLayout.InvalidateMeasure();
}
static void OnAlignItemsPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var flexLayout = (FlexLayout)bindable;
if (flexLayout._root == null)
return;
flexLayout._root.AlignItems = (Flex.AlignItems)(FlexAlignItems)newValue;
flexLayout.InvalidateMeasure();
}
static void OnPositionPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var flexLayout = (FlexLayout)bindable;
if (flexLayout._root == null)
return;
flexLayout._root.Position = (Flex.Position)(FlexPosition)newValue;
flexLayout.InvalidateMeasure();
}
static void OnWrapPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var flexLayout = bindable as FlexLayout;
if (flexLayout._root == null)
return;
flexLayout._root.Wrap = (Flex.Wrap)(FlexWrap)newValue;
flexLayout.InvalidateMeasure();
}
readonly Dictionary<IView, FlexInfo> _viewInfo = new();
class FlexInfo
{
public int Order { get; set; }
public float Grow { get; set; }
public float Shrink { get; set; }
public FlexAlignSelf AlignSelf { get; set; }
public FlexBasis Basis { get; set; }
public Flex.Item FlexItem { get; set; }
}
public int GetOrder(IView view)
{
return view switch
{
BindableObject bo => (int)bo.GetValue(OrderProperty),
_ => _viewInfo[view].Order,
};
}
public void SetOrder(IView view, int order)
{
switch (view)
{
case BindableObject bo:
bo.SetValue(OrderProperty, order);
break;
default:
_viewInfo[view].Order = order;
break;
}
}
public float GetGrow(IView view)
{
return view switch
{
BindableObject bo => (float)bo.GetValue(GrowProperty),
_ => _viewInfo[view].Grow,
};
}
public void SetGrow(IView view, float grow)
{
switch (view)
{
case BindableObject bo:
bo.SetValue(GrowProperty, grow);
break;
default:
_viewInfo[view].Grow = grow;
break;
}
}
public float GetShrink(IView view)
{
return view switch
{
BindableObject bo => (float)bo.GetValue(ShrinkProperty),
_ => _viewInfo[view].Shrink,
};
}
public void SetShrink(IView view, float shrink)
{
switch (view)
{
case BindableObject bo:
bo.SetValue(ShrinkProperty, shrink);
break;
default:
_viewInfo[view].Shrink = shrink;
break;
}
}
public FlexAlignSelf GetAlignSelf(IView view)
{
return view switch
{
BindableObject bo => (FlexAlignSelf)bo.GetValue(AlignSelfProperty),
_ => _viewInfo[view].AlignSelf,
};
}
public void SetAlignSelf(IView view, FlexAlignSelf alignSelf)
{
switch (view)
{
case BindableObject bo:
bo.SetValue(AlignSelfProperty, alignSelf);
break;
default:
_viewInfo[view].AlignSelf = alignSelf;
break;
}
}
public FlexBasis GetBasis(IView view)
{
return view switch
{
BindableObject bo => (FlexBasis)bo.GetValue(BasisProperty),
_ => _viewInfo[view].Basis,
};
}
public void SetBasis(IView view, FlexBasis basis)
{
switch (view)
{
case BindableObject bo:
bo.SetValue(BasisProperty, basis);
break;
default:
_viewInfo[view].Basis = basis;
break;
}
}
internal Flex.Item GetFlexItem(IView view)
{
return view switch
{
BindableObject bo => (Flex.Item)bo.GetValue(FlexItemProperty),
_ => _viewInfo[view].FlexItem,
};
}
void SetFlexItem(IView view, Flex.Item flexItem)
{
switch (view)
{
case BindableObject bo:
bo.SetValue(FlexItemProperty, flexItem);
break;
default:
_viewInfo[view].FlexItem = flexItem;
break;
}
}
Thickness GetMargin(IView view)
{
return view switch
{
BindableObject bo => (Thickness)bo.GetValue(MarginProperty),
_ => view.Margin
};
}
double GetWidth(IView view)
{
return view switch
{
BindableObject bo => (double)bo.GetValue(WidthRequestProperty),
_ => view.Width
};
}
double GetHeight(IView view)
{
return view switch
{
BindableObject bo => (double)bo.GetValue(HeightRequestProperty),
_ => view.Height
};
}
bool GetIsVisible(IView view)
{
return view switch
{
BindableObject bo => (bool)bo.GetValue(IsVisibleProperty),
_ => view.Visibility != Visibility.Collapsed
};
}
void InitItemProperties(IView view, Flex.Item item)
{
item.Order = GetOrder(view);
item.Grow = GetGrow(view);
item.Shrink = GetShrink(view);
item.Basis = GetBasis(view).ToFlexBasis();
item.AlignSelf = (Flex.AlignSelf)GetAlignSelf(view);
var (mleft, mtop, mright, mbottom) = GetMargin(view);
item.MarginLeft = (float)mleft;
item.MarginTop = (float)mtop;
item.MarginRight = (float)mright;
item.MarginBottom = (float)mbottom;
var width = GetWidth(view);
item.Width = width < 0 ? float.NaN : (float)width;
var height = GetHeight(view);
item.Height = height < 0 ? float.NaN : (float)height;
item.IsVisible = GetIsVisible(view);
// TODO ezhart The Core layout interfaces don't have the padding property yet; when that's available, we should add a check for it here
if (view is FlexLayout && view is Controls.Layout layout)
{
var (pleft, ptop, pright, pbottom) = (Thickness)layout.GetValue(Controls.Layout.PaddingProperty);
item.PaddingLeft = (float)pleft;
item.PaddingTop = (float)ptop;
item.PaddingRight = (float)pright;
item.PaddingBottom = (float)pbottom;
}
}
void AddFlexItem(IView child)
{
if (_root == null)
return;
var item = (child as FlexLayout)?._root ?? new Flex.Item();
InitItemProperties(child, item);
if (!(child is FlexLayout))
{ //inner layouts don't get measured
item.SelfSizing = (Flex.Item it, ref float w, ref float h) =>
{
var sizeConstraints = item.GetConstraints();
sizeConstraints.Width = (sizeConstraints.Width == 0) ? double.PositiveInfinity : sizeConstraints.Width;
sizeConstraints.Height = (sizeConstraints.Height == 0) ? double.PositiveInfinity : sizeConstraints.Height;
var request = child.Measure(sizeConstraints.Width, sizeConstraints.Height);
w = (float)request.Width;
h = (float)request.Height;
};
}
_root.InsertAt(Children.IndexOf(child), item);
SetFlexItem(child, item);
}
void RemoveFlexItem(IView child)
{
if (_root == null)
return;
var item = GetFlexItem(child);
_root.Remove(item);
switch (child)
{
case BindableObject bo:
bo.ClearValue(FlexItemProperty);
break;
default:
_viewInfo.Remove(child);
break;
}
}
protected override ILayoutManager CreateLayoutManager()
{
return new FlexLayoutManager(this);
}
public Graphics.Rectangle GetFlexFrame(IView view)
{
return view switch
{
BindableObject bo => ((Flex.Item)bo.GetValue(FlexItemProperty)).GetFrame(),
_ => _viewInfo[view].FlexItem.GetFrame(),
};
}
public void Layout(double width, double height)
{
if (_root.Parent != null) //Layout is only computed at root level
return;
_root.Width = !double.IsPositiveInfinity((width)) ? (float)width : 0;
_root.Height = !double.IsPositiveInfinity((height)) ? (float)height : 0;
_root.Layout();
}
protected override void OnParentSet()
{
base.OnParentSet();
if (Parent != null && _root == null)
PopulateLayout();
else if (Parent == null && _root != null)
ClearLayout();
}
void PopulateLayout()
{
InitLayoutProperties(_root = new Flex.Item());
foreach (var child in Children)
AddFlexItem(child);
}
void ClearLayout()
{
foreach (var child in Children)
RemoveFlexItem(child);
_root = null;
}
void InitLayoutProperties(Flex.Item item)
{
item.AlignContent = (Flex.AlignContent)(FlexAlignContent)GetValue(AlignContentProperty);
item.AlignItems = (Flex.AlignItems)(FlexAlignItems)GetValue(AlignItemsProperty);
item.Direction = (Flex.Direction)(FlexDirection)GetValue(DirectionProperty);
item.JustifyContent = (Flex.Justify)(FlexJustify)GetValue(JustifyContentProperty);
item.Wrap = (Flex.Wrap)(FlexWrap)GetValue(WrapProperty);
}
}
}
| 29.842697 | 138 | 0.721699 |
cb800dd6feae3611a1959cb0d68e5a8507253304 | 3,281 | cs | C# | src/Services/MASA.EShop.Services.Payment/Migrations/20211025035015_init.Designer.cs | MayueCif/MASA.EShop | 8872880d30a5f4b965f15b499c542552de5eadbb | [
"MIT"
] | 3 | 2021-11-05T12:10:54.000Z | 2021-11-05T12:10:58.000Z | src/Services/MASA.EShop.Services.Payment/Migrations/20211025035015_init.Designer.cs | dongfo/MASA.EShop | 682d453c78e760ef184d92e08e5ccacba64840f7 | [
"MIT"
] | null | null | null | src/Services/MASA.EShop.Services.Payment/Migrations/20211025035015_init.Designer.cs | dongfo/MASA.EShop | 682d453c78e760ef184d92e08e5ccacba64840f7 | [
"MIT"
] | null | null | null | // <auto-generated />
using System;
using MASA.EShop.Services.Payment.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace MASA.EShop.Services.Payment.Migrations
{
[DbContext(typeof(PaymentDbContext))]
[Migration("20211025035015_init")]
partial class init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0-rc.1.21452.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("MASA.BuildingBlocks.Dispatcher.IntegrationEvents.Logs.IntegrationEventLog", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid>("EventId")
.HasColumnType("uniqueidentifier");
b.Property<string>("EventTypeName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<int>("TimesSent")
.HasColumnType("int");
b.Property<Guid>("TransactionId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.ToTable("IntegrationEventLog", (string)null);
});
modelBuilder.Entity("MASA.EShop.Services.Payment.Domain.Aggregate.Payment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid>("Creator")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("ModificationTime")
.HasColumnType("datetime2");
b.Property<Guid>("Modifier")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("OrderId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("Succeeded")
.HasColumnType("bit");
b.HasKey("Id");
b.ToTable("Payments");
});
#pragma warning restore 612, 618
}
}
}
| 34.177083 | 113 | 0.522706 |
588a408f2c65486489e0358a1a986f6604bd4cdd | 3,664 | cs | C# | Ignite/FileProcessor.cs | Astherlaid/Ignite | 101450b7585413f59621ca92f1070e9d2b3fc5dd | [
"MIT"
] | 1 | 2020-01-17T15:55:13.000Z | 2020-01-17T15:55:13.000Z | Ignite/FileProcessor.cs | carlos-herasme/Ignite | 101450b7585413f59621ca92f1070e9d2b3fc5dd | [
"MIT"
] | null | null | null | Ignite/FileProcessor.cs | carlos-herasme/Ignite | 101450b7585413f59621ca92f1070e9d2b3fc5dd | [
"MIT"
] | null | null | null | using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using ExcelDataReader;
using IronXL;
using System.Linq;
using ClosedXML.Excel;
using System.Data;
namespace Ignite
{
internal class FileProcessor
{
Validator validator;
public FileProcessor() => validator = new Validator();
internal List<NumericInfo> ExtractDataFromFile(string file, string path)
{
if (validator.ValidateFileInfo(file, path).Result)
{
var fileDataRows = new List<NumericInfo>();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
using (var stream = File.Open($@"{path}\{file}", FileMode.Open, FileAccess.Read))
{
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
try
{
do
{
while (reader.Read())
{
fileDataRows.Add(new NumericInfo()
{
Value = reader.GetValue(0).ToString(),
SourceType = IdenfityNumericType(reader.GetValue(1).ToString()),
DestionationType = IdenfityNumericType(reader.GetValue(2).ToString()),
ConvertionValue = null
});
}
} while (reader.NextResult());
}
catch (Exception ex)
{
return null;
}
fileDataRows.RemoveAt(0);
}
}
return fileDataRows;
}
else
{
return null;
}
}
internal bool GenerateFileData(List<NumericInfo> numericInfo, string file, string path)
{
try
{
if (numericInfo.Count == 0)
return false;
var table = new DataTable();
table.Columns.AddRange(new DataColumn[4]
{
new DataColumn("Value", typeof(string)),
new DataColumn("Source Type", typeof(string)),
new DataColumn("Source Destination", typeof(string)),
new DataColumn("Convertion Value", typeof(string))
});
foreach (var convertedItem in numericInfo)
{
table.Rows.Add
(
convertedItem.Value,
convertedItem.SourceType,
convertedItem.DestionationType,
convertedItem.ConvertionValue
);
}
using (var wb = new XLWorkbook())
{
wb.Worksheets.Add(table, "Info");
wb.SaveAs($@"{path}\{file}.xlsx");
}
return true;
}
catch (Exception ex)
{
return false;
}
}
internal NumericType IdenfityNumericType(string type)
{
if (Enum.TryParse(type, out NumericType numericType))
return numericType;
return NumericType.None;
}
}
}
| 32.140351 | 110 | 0.420033 |
629d290484ace64ff45524960ce8bab130a03247 | 744 | cs | C# | Contra/Assets/Scenes/Scripts/Platform.cs | HectorPulido/Contra-Like-game-made-with-unity | c5bf4ef824dc4f26a090d60d4ccb35e51dabf124 | [
"MIT"
] | 7 | 2019-03-19T15:48:08.000Z | 2021-11-09T05:11:28.000Z | Contra/Assets/Scenes/Scripts/Platform.cs | HectorPulido/Contra-Like-game-made-with-unity | c5bf4ef824dc4f26a090d60d4ccb35e51dabf124 | [
"MIT"
] | null | null | null | Contra/Assets/Scenes/Scripts/Platform.cs | HectorPulido/Contra-Like-game-made-with-unity | c5bf4ef824dc4f26a090d60d4ccb35e51dabf124 | [
"MIT"
] | 1 | 2020-04-30T15:36:24.000Z | 2020-04-30T15:36:24.000Z | using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Platform : MonoBehaviour {
Transform player;
Collider2D col;
// Use this for initialization
void Start ()
{
player = GameObject.FindWithTag("Player").transform;
col = GetComponent<Collider2D>();
}
bool k;
void Update ()
{
if(k)
return;
var c = player.transform.position.y > transform.position.y;
if(InputManager.JumpButtonPressed && InputManager.VerticalAxis < 0)
{
k = true;
c = false;
StartCoroutine(DelayedEvents(()=>{
k = false;
c = true;
}, 0.2f));
}
col.isTrigger = !c;
}
IEnumerator DelayedEvents(System.Action ev, float time)
{
yield return new WaitForSeconds (time);
ev ();
}
}
| 18.6 | 69 | 0.670699 |
1ca76cdad463c50e375ac27f93fbd9041f109e1c | 850 | cshtml | C# | Padrao/Areas/Procedimento/Views/ProcedimentoAdm/TransportadorListaPartial.cshtml | shpsyte/Procediemento | 9e0f23e78fbae235f7e93c8842c0b2e0c9d1c9cb | [
"MIT"
] | 1 | 2018-10-24T18:48:22.000Z | 2018-10-24T18:48:22.000Z | Presentation/CRM/Procedimento/Areas/Procedimento/Views/ProcedimentoAdm/TransportadorListaPartial.cshtml | shpsyte/CRMFx | 03b6219c9c19d69cfb47707e148d3a233595f5f0 | [
"MIT"
] | null | null | null | Presentation/CRM/Procedimento/Areas/Procedimento/Views/ProcedimentoAdm/TransportadorListaPartial.cshtml | shpsyte/CRMFx | 03b6219c9c19d69cfb47707e148d3a233595f5f0 | [
"MIT"
] | null | null | null | @model IEnumerable<TRANSPORTADOR>
<table class="table table-hover" >
<tr>
<th>
@Html.DisplayNameFor(model => model.CD_CADASTRO)
</th>
<th>
@Html.DisplayNameFor(model => model.RAZAO)
</th>
<th>
@Html.DisplayNameFor(model => model.FANTASIA)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
<a href="#" onclick="SelecionaTransportador('@item.CD_CADASTRO','@item.RAZAO');">@item.CD_CADASTRO</a>
</td>
<td>
<a href="#" onclick="SelecionaTransportador('@item.CD_CADASTRO','@item.RAZAO');">@item.RAZAO</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.FANTASIA)
</td>
</tr>
}
</table>
| 27.419355 | 118 | 0.467059 |
1cb2f06244de0d724a053b3582fef493de63d6ae | 333 | cs | C# | Features/Scopes/ScopeConfiguration.cs | QuinntyneBrown/asp-net-identity-server-3-getting-started | f3aa4872a8d84099fa869f2ae3043fb1d4fb0b08 | [
"MIT"
] | null | null | null | Features/Scopes/ScopeConfiguration.cs | QuinntyneBrown/asp-net-identity-server-3-getting-started | f3aa4872a8d84099fa869f2ae3043fb1d4fb0b08 | [
"MIT"
] | null | null | null | Features/Scopes/ScopeConfiguration.cs | QuinntyneBrown/asp-net-identity-server-3-getting-started | f3aa4872a8d84099fa869f2ae3043fb1d4fb0b08 | [
"MIT"
] | null | null | null | using System.Data.Entity.Migrations;
using AspNetIdentityServerGettingStarted.Data;
namespace AspNetIdentityServerGettingStarted.Features.Scopes
{
public class ScopeConfiguration
{
public static void Seed(AspNetIdentityServerGettingStartedDataContext context) {
context.SaveChanges();
}
}
}
| 23.785714 | 88 | 0.750751 |
5c9cab2e8b67d1103b50273258ed1fb6eab4fc68 | 1,956 | cs | C# | YouCineUI/AddActorWindow.xaml.cs | SenonerK/YouCinema | 86267ed405b5802f2e59e87ed5f909aedaa3caa7 | [
"MIT"
] | 2 | 2019-05-13T19:12:41.000Z | 2019-06-18T14:35:28.000Z | YouCineUI/AddActorWindow.xaml.cs | SenonerK/YouCinema | 86267ed405b5802f2e59e87ed5f909aedaa3caa7 | [
"MIT"
] | null | null | null | YouCineUI/AddActorWindow.xaml.cs | SenonerK/YouCinema | 86267ed405b5802f2e59e87ed5f909aedaa3caa7 | [
"MIT"
] | null | null | null | using System.Windows;
using System.Windows.Input;
namespace YouCineUI
{
public partial class AddActorWindow : Window
{
public AddActorWindow()
{
InitializeComponent();
}
private void Button_Close_Click(object sender, RoutedEventArgs e) => Close();
private void Button_OK_Click(object sender, RoutedEventArgs e)
{
try
{
if (!string.IsNullOrEmpty(txt_fname.Text) && !string.IsNullOrWhiteSpace(txt_fname.Text)
&& !string.IsNullOrEmpty(txt_lname.Text) && !string.IsNullOrWhiteSpace(txt_lname.Text)
&& dp_birthday.SelectedDate != null
&& new System.Text.RegularExpressions.Regex("^[0-9]+,[0-9]+$").IsMatch(txt_rating.Text))
{
YouCineLibrary.Config.Cinema.Actors.Add(
YouCineLibrary.Config.Connection.CreateActor(
txt_fname.Text,
txt_lname.Text,
dp_birthday.SelectedDate.Value,
double.Parse(txt_rating.Text)));
DialogResult = true;
Close();
}
else
MessageBox.Show("Überprüfen Sie Ihre Eingaben", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Error);
}
catch { MessageBox.Show("Überprüfen Sie Ihre Eingaben", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Error); }
}
private void Text_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !(new System.Text.RegularExpressions.Regex("^[a-zA-Z ]+$").IsMatch(e.Text));
}
private void Number_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !(new System.Text.RegularExpressions.Regex("^[0-9,]+$").IsMatch(e.Text));
}
}
}
| 38.352941 | 125 | 0.558282 |
a815df89a08f7e0f60c3fe12121d5c6912ce3c8e | 6,782 | cs | C# | src/DotnetSpider/DataFlow/Storage/RelationalDatabaseEntityStorageBase.cs | toolgood/DotnetSpider | aeb665eb309a0687b639a2bc6e1886105a3c8a99 | [
"MIT"
] | 1 | 2021-02-22T18:11:14.000Z | 2021-02-22T18:11:14.000Z | src/DotnetSpider/DataFlow/Storage/RelationalDatabaseEntityStorageBase.cs | xchetan/SASAML | aeb665eb309a0687b639a2bc6e1886105a3c8a99 | [
"MIT"
] | null | null | null | src/DotnetSpider/DataFlow/Storage/RelationalDatabaseEntityStorageBase.cs | xchetan/SASAML | aeb665eb309a0687b639a2bc6e1886105a3c8a99 | [
"MIT"
] | 1 | 2020-09-16T17:50:54.000Z | 2020-09-16T17:50:54.000Z | using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Threading.Tasks;
using Dapper;
using DotnetSpider.Infrastructure;
using Microsoft.Extensions.Logging;
namespace DotnetSpider.DataFlow.Storage
{
/// <summary>
/// 关系型数据库保存实体解析结果
/// </summary>
public abstract class RelationalDatabaseEntityStorageBase : EntityStorageBase
{
private readonly ConcurrentDictionary<string, SqlStatements> _sqlStatementDict =
new ConcurrentDictionary<string, SqlStatements>();
private readonly ConcurrentDictionary<string, object> _executedCache =
new ConcurrentDictionary<string, object>();
private readonly ConcurrentDictionary<Type, TableMetadata> _tableMetadataDict =
new ConcurrentDictionary<Type, TableMetadata>();
protected const string BoolType = "Boolean";
protected const string DateTimeType = "DateTime";
protected const string DateTimeOffsetType = "DateTimeOffset";
protected const string DecimalType = "Decimal";
protected const string DoubleType = "Double";
protected const string FloatType = "Single";
protected const string IntType = "Int32";
protected const string LongType = "Int64";
protected const string ByteType = "Byte";
protected const string ShortType = "Short";
/// <summary>
/// 创建数据库连接接口
/// </summary>
/// <param name="connectString">连接字符串</param>
/// <returns></returns>
protected abstract IDbConnection CreateDbConnection(string connectString);
/// <summary>
/// 生成 SQL 语句
/// </summary>
/// <param name="tableMetadata">表元数据</param>
/// <returns></returns>
protected abstract SqlStatements GenerateSqlStatements(TableMetadata tableMetadata);
/// <summary>
/// 创建数据库和表
/// </summary>
/// <param name="conn">数据库连接</param>
/// <param name="sqlStatements">SQL 语句</param>
protected virtual void EnsureDatabaseAndTableCreated(IDbConnection conn,
SqlStatements sqlStatements)
{
if (!string.IsNullOrWhiteSpace(sqlStatements.CreateDatabaseSql))
{
conn.Execute(sqlStatements.CreateDatabaseSql);
}
conn.Execute(sqlStatements.CreateTableSql);
}
/// <summary>
/// 构造方法
/// </summary>
/// <param name="model">存储器类型</param>
/// <param name="connectionString">连接字符串</param>
protected RelationalDatabaseEntityStorageBase(StorageMode model, string connectionString)
{
connectionString.NotNullOrWhiteSpace(nameof(connectionString));
ConnectionString = connectionString;
Mode = model;
}
/// <summary>
/// 存储器类型
/// </summary>
public StorageMode Mode { get; set; }
/// <summary>
/// 数据库操作重试次数
/// </summary>
public int RetryTimes { get; set; } = 600;
/// <summary>
/// 连接字符串
/// </summary>
public string ConnectionString { get; }
/// <summary>
/// 是否使用事务操作。默认不使用。
/// </summary>
public bool UseTransaction { get; set; }
/// <summary>
/// 数据库忽略大小写
/// </summary>
public bool IgnoreCase { get; set; } = true;
protected override async Task StoreAsync(DataContext context, Dictionary<Type, List<dynamic>> dict)
{
using var conn = TryCreateDbConnection();
foreach (var kv in dict)
{
var list = (IList)kv.Value;
var tableMetadata = _tableMetadataDict.GetOrAdd(kv.Key,
type => ((IEntity)list[0]).GetTableMetadata());
var sqlStatements = GetSqlStatements(tableMetadata);
// 因为同一个存储器会收到不同的数据对象,因此不能使用 initAsync 来初始化数据库
_executedCache.GetOrAdd(sqlStatements.CreateTableSql, str =>
{
var conn1 = TryCreateDbConnection();
EnsureDatabaseAndTableCreated(conn1, sqlStatements);
return string.Empty;
});
for (var i = 0; i < RetryTimes; ++i)
{
IDbTransaction transaction = null;
try
{
if (UseTransaction)
{
transaction = conn.BeginTransaction();
}
switch (Mode)
{
case StorageMode.Insert:
{
await conn.ExecuteAsync(sqlStatements.InsertSql, list, transaction);
break;
}
case StorageMode.InsertIgnoreDuplicate:
{
await conn.ExecuteAsync(sqlStatements.InsertIgnoreDuplicateSql, list, transaction);
break;
}
case StorageMode.Update:
{
if (string.IsNullOrWhiteSpace(sqlStatements.UpdateSql))
{
throw new SpiderException("未能生成更新 SQL");
}
await conn.ExecuteAsync(sqlStatements.UpdateSql, list, transaction);
break;
}
case StorageMode.InsertAndUpdate:
{
await conn.ExecuteAsync(sqlStatements.InsertAndUpdateSql, list, transaction);
break;
}
}
transaction?.Commit();
break;
}
catch (Exception ex)
{
Logger.LogError($"尝试插入数据失败: {ex}");
// 网络异常需要重试,并且不需要 Rollback
var endOfStreamException = ex.InnerException as EndOfStreamException;
if (endOfStreamException == null)
{
try
{
transaction?.Rollback();
}
catch (Exception e)
{
Logger?.LogError($"数据库回滚失败: {e}");
}
break;
}
}
finally
{
transaction?.Dispose();
}
}
}
}
protected virtual string GetNameSql(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
return null;
}
return IgnoreCase ? name.ToLowerInvariant() : name;
}
protected virtual string GetTableName(TableMetadata tableMetadata)
{
var tableName = tableMetadata.Schema.Table;
switch (tableMetadata.Schema.TablePostfix)
{
case TablePostfix.Monday:
{
return $"{tableName}_{DateTime2.Monday:yyyyMMdd}";
}
case TablePostfix.Month:
{
return $"{tableName}_{DateTime2.FirstDayOfMonth:yyyyMMdd}";
}
case TablePostfix.Today:
{
return $"{tableName}_{DateTime2.Today:yyyyMMdd}";
}
default:
{
return tableName;
}
}
}
private SqlStatements GetSqlStatements(TableMetadata tableMetadata)
{
// 每天执行一次建表操作, 可以实现每天一个表的操作,或者按周分表可以在运行时创建新表。
var key = tableMetadata.TypeName;
if (tableMetadata.Schema.TablePostfix != TablePostfix.None)
{
key = $"{key}-{DateTimeOffset.Now:yyyyMMdd}";
}
return _sqlStatementDict.GetOrAdd(key, str => GenerateSqlStatements(tableMetadata));
}
private IDbConnection TryCreateDbConnection()
{
for (var i = 0; i < RetryTimes; ++i)
{
var conn = TryCreateDbConnection(ConnectionString);
if (conn != null)
{
return conn;
}
}
throw new SpiderException(
"无有效的数据库连接配置");
}
private IDbConnection TryCreateDbConnection(string connectionString)
{
try
{
var conn = CreateDbConnection(connectionString);
conn.Open();
return conn;
}
catch
{
Logger.LogError($"无法打开数据库连接: {connectionString}.");
}
return null;
}
}
}
| 24.483755 | 101 | 0.66529 |
5c1fdf7940169c6c617e99de5d8d86edf282c029 | 4,943 | cs | C# | Assets/2DDL/2DLight/Core/CasterCollider.cs | whoisfpc/BackLight | 8a9d23b4bd4ae8478e97cc2f0ef6eebd366c166f | [
"MIT"
] | 2 | 2019-12-04T23:28:57.000Z | 2019-12-15T03:54:58.000Z | Assets/2DDL/2DLight/Core/CasterCollider.cs | whoisfpc/BackLight | 8a9d23b4bd4ae8478e97cc2f0ef6eebd366c166f | [
"MIT"
] | null | null | null | Assets/2DDL/2DLight/Core/CasterCollider.cs | whoisfpc/BackLight | 8a9d23b4bd4ae8478e97cc2f0ef6eebd366c166f | [
"MIT"
] | 1 | 2018-07-07T05:40:51.000Z | 2018-07-07T05:40:51.000Z | using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CasterCollider{
public Collider2D collider;
public Vector2[] points;
public Transform transform;
public int TotalPointsCount;
public enum CasterType{
BoxCollider2d,
CircleCollider2d,
PolygonCollider2d,
EdgeCollider2d
};
public CasterType type;
internal float lastRadius;
internal float lastZRot;
internal CasterCollider(PolygonCollider2D coll){
collider = coll;
transform = coll.transform;
TotalPointsCount = coll.GetTotalPointCount();
//points = new Vector2[TotalPointsCount];
//points = coll.points;
type = CasterType.PolygonCollider2d;
List<Vector2> Lpoints = new List<Vector2>();
//coll.pathCount = 2;
for (int i = 0; i < coll.pathCount; i++)
Lpoints.AddRange(coll.GetPath(i));
for (int i = 0; i < Lpoints.Count; i++)
Lpoints[i] += coll.offset;
points = new Vector2[Lpoints.Count];
points = Lpoints.ToArray();
}
internal CasterCollider(BoxCollider2D coll, bool pointInLocalSpace = true){
collider = coll;
transform = coll.transform;
TotalPointsCount = 4;
points = new Vector2[TotalPointsCount];
points = getSquarePoints(pointInLocalSpace);
type = CasterType.BoxCollider2d;
}
internal CasterCollider(CircleCollider2D coll, Vector2 lightSource){
collider = coll;
transform = coll.transform;
TotalPointsCount = 2;
points = new Vector2[TotalPointsCount];
points = getCirclePoints(lightSource);
type = CasterType.CircleCollider2d;
}
internal CasterCollider(EdgeCollider2D coll){
collider = coll;
transform = coll.transform;
TotalPointsCount = coll.pointCount;
points = new Vector2[TotalPointsCount];
points = coll.points;
type = CasterType.EdgeCollider2d;
}
internal CasterCollider(Vector2[] vertices){
collider = new Collider2D();
transform = null;
TotalPointsCount = vertices.Length;
points = vertices;
}
internal Vector2[] getSquarePoints(bool inLocalSpace = true){
Collider2D thisBox = collider;
lastZRot = transform.eulerAngles.z;
if(lastZRot == 0)
lastZRot = 0.001f; // my Zero ref
if (lastZRot != 0.001f)
transform.eulerAngles = Vector3.zero;
Rect p = new Rect();
// NO ROTATION
p.x = thisBox.bounds.min.x;
p.y = thisBox.bounds.min.y;
p.width = thisBox.bounds.max.x ;
p.height = thisBox.bounds.max.y;
Vector2 []poly2DPoints = new Vector2[4];
poly2DPoints[0].x = p.x;
poly2DPoints[0].y = p.y;
poly2DPoints[1].x = p.width;
poly2DPoints[1].y = p.y;
poly2DPoints[2].x = p.width;
poly2DPoints[2].y = p.height;
poly2DPoints[3].x = p.x;
poly2DPoints[3].y = p.height;
if(inLocalSpace == true)
{
for (int i = 0; i < TotalPointsCount; i++){
// To local
poly2DPoints[i] = transform.InverseTransformPoint(poly2DPoints[i]);
}
}
transform.eulerAngles = new Vector3(0,0,lastZRot);
return poly2DPoints;
}
internal Vector2[] getCirclePoints(Vector2 lightSource){
CircleCollider2D thisCircle = (CircleCollider2D) collider;
// Vector2 center = thisCircle.center;
Vector2 finalCirclePos = (Vector2)transform.position + thisCircle.offset; //(Vector2) transform.TransformPoint(new Vector3(center.x, center.y, 0));
Vector2 lightToCircleDirection = finalCirclePos - lightSource;
float lightToCircleAngle = Mathf.Atan2(lightToCircleDirection.y, lightToCircleDirection.x);
float dist = lightToCircleDirection.magnitude;
float radius = thisCircle.radius * transform.localScale.x* (1.0001f + (dist/thisCircle.radius) *.00001f) ;
//Debug.Log("lightToCircleAngle " + lightToCircleAngle);
float theta = Mathf.Asin((radius / dist));
float finalTheta1 = lightToCircleAngle - theta;
float finalTheta2 = lightToCircleAngle + theta;
//calculate the tangential vector
//remember, the radial vector is (x, y)
//to get the tangential vector we flip those coordinates and negate one of them
Vector2 p1 = new Vector2(Mathf.Cos( finalTheta1), Mathf.Sin(finalTheta1));
p1.Normalize();
p1 *= dist;
p1 += lightSource;
//---Reverse pending --//
theta = lightToCircleAngle + theta;
Vector2 p2 = new Vector2(Mathf.Cos(finalTheta2), Mathf.Sin(finalTheta2));
p2.Normalize();
p2 *= dist;
p2 += lightSource;
//Vector2 rr = new Vector2(lightSource.x * p1.x, lightSource.y * p1.y);
//Debug.DrawLine(lightSource,p1,Color.red);
//Debug.DrawLine(lightSource,p2,Color.white);
Vector2 []poly2DPoints = new Vector2[2];
poly2DPoints[0] = (Vector2)transform.InverseTransformPoint((Vector3) p1);
poly2DPoints[1] = (Vector2)transform.InverseTransformPoint((Vector3) p2);
return poly2DPoints;
}
public void recalcTan(Vector2 source){
points = getCirclePoints(source);
}
public void recalcBox(){
points = getSquarePoints();
}
public int getTotalPointsCount(){
return TotalPointsCount;
}
}
| 23.764423 | 149 | 0.700789 |
367904f8dd3724f904f746faeb7d0a2e41f1de2c | 7,239 | cs | C# | src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs | Gerfaut/json-api-dotnet-core | 219ccfcae4a8df17206a6ea3d177795203cc90f4 | [
"MIT"
] | 1 | 2021-03-07T13:07:19.000Z | 2021-03-07T13:07:19.000Z | src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs | Gerfaut/json-api-dotnet-core | 219ccfcae4a8df17206a6ea3d177795203cc90f4 | [
"MIT"
] | null | null | null | src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs | Gerfaut/json-api-dotnet-core | 219ccfcae4a8df17206a6ea3d177795203cc90f4 | [
"MIT"
] | 1 | 2019-10-25T15:35:52.000Z | 2019-10-25T15:35:52.000Z | using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using JsonApiDotNetCore.Extensions;
using JsonApiDotNetCore.Internal;
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.EntityFrameworkCore;
namespace JsonApiDotNetCore.Serialization
{
public class JsonApiDeSerializer : IJsonApiDeSerializer
{
private readonly DbContext _dbContext;
private readonly IJsonApiContext _jsonApiContext;
private readonly IGenericProcessorFactory _genericProcessorFactor;
public JsonApiDeSerializer(DbContext dbContext,
IJsonApiContext jsonApiContext,
IGenericProcessorFactory genericProcessorFactory)
{
_dbContext = dbContext;
_jsonApiContext = jsonApiContext;
_genericProcessorFactor = genericProcessorFactory;
}
public object Deserialize(string requestBody)
{
var document = JsonConvert.DeserializeObject<Document>(requestBody);
var entity = DataToObject(document.Data);
return entity;
}
public object DeserializeRelationship(string requestBody)
{
var data = JToken.Parse(requestBody)["data"];
if(data is JArray)
return data.ToObject<List<DocumentData>>();
return new List<DocumentData> { data.ToObject<DocumentData>() };
}
public List<TEntity> DeserializeList<TEntity>(string requestBody)
{
var documents = JsonConvert.DeserializeObject<Documents>(requestBody);
var deserializedList = new List<TEntity>();
foreach (var data in documents.Data)
{
var entity = DataToObject(data);
deserializedList.Add((TEntity)entity);
}
return deserializedList;
}
private object DataToObject(DocumentData data)
{
var entityTypeName = data.Type.ToProperCase();
var contextEntity = _jsonApiContext.ContextGraph.GetContextEntity(entityTypeName);
_jsonApiContext.RequestEntity = contextEntity;
var entity = Activator.CreateInstance(contextEntity.EntityType);
entity = _setEntityAttributes(entity, contextEntity, data.Attributes);
entity = _setRelationships(entity, contextEntity, data.Relationships);
var identifiableEntity = (IIdentifiable)entity;
if (data.Id != null)
identifiableEntity.StringId = data.Id;
return identifiableEntity;
}
private object _setEntityAttributes(
object entity, ContextEntity contextEntity, Dictionary<string, object> attributeValues)
{
if (attributeValues == null || attributeValues.Count == 0)
return entity;
var entityProperties = entity.GetType().GetProperties();
foreach (var attr in contextEntity.Attributes)
{
var entityProperty = entityProperties.FirstOrDefault(p => p.Name == attr.InternalAttributeName);
if (entityProperty == null)
throw new ArgumentException($"{contextEntity.EntityType.Name} does not contain an attribute named {attr.InternalAttributeName}", nameof(entity));
object newValue;
if (attributeValues.TryGetValue(attr.PublicAttributeName.Dasherize(), out newValue))
{
var convertedValue = TypeHelper.ConvertType(newValue, entityProperty.PropertyType);
entityProperty.SetValue(entity, convertedValue);
}
}
return entity;
}
private object _setRelationships(
object entity,
ContextEntity contextEntity,
Dictionary<string, RelationshipData> relationships)
{
if (relationships == null || relationships.Count == 0)
return entity;
var entityProperties = entity.GetType().GetProperties();
foreach (var attr in contextEntity.Relationships)
{
if (attr.IsHasOne)
entity = _setHasOneRelationship(entity, entityProperties, attr, contextEntity, relationships);
else
entity = _setHasManyRelationship(entity, entityProperties, attr, contextEntity, relationships);
}
return entity;
}
private object _setHasOneRelationship(object entity,
PropertyInfo[] entityProperties,
RelationshipAttribute attr,
ContextEntity contextEntity,
Dictionary<string, RelationshipData> relationships)
{
var entityProperty = entityProperties.FirstOrDefault(p => p.Name == $"{attr.InternalRelationshipName}Id");
if (entityProperty == null)
throw new JsonApiException("400", $"{contextEntity.EntityType.Name} does not contain an relationsip named {attr.InternalRelationshipName}");
var relationshipName = attr.InternalRelationshipName.Dasherize();
if (relationships.TryGetValue(relationshipName, out RelationshipData relationshipData))
{
var relationshipAttr = _jsonApiContext.RequestEntity.Relationships
.SingleOrDefault(r => r.PublicRelationshipName == relationshipName);
var data = (Dictionary<string, string>)relationshipData.ExposedData;
if (data == null) return entity;
var newValue = data["id"];
var convertedValue = TypeHelper.ConvertType(newValue, entityProperty.PropertyType);
_jsonApiContext.RelationshipsToUpdate[relationshipAttr] = convertedValue;
entityProperty.SetValue(entity, convertedValue);
}
return entity;
}
private object _setHasManyRelationship(object entity,
PropertyInfo[] entityProperties,
RelationshipAttribute attr,
ContextEntity contextEntity,
Dictionary<string, RelationshipData> relationships)
{
var entityProperty = entityProperties.FirstOrDefault(p => p.Name == attr.InternalRelationshipName);
if (entityProperty == null)
throw new JsonApiException("400", $"{contextEntity.EntityType.Name} does not contain an relationsip named {attr.InternalRelationshipName}");
var relationshipName = attr.InternalRelationshipName.Dasherize();
if (relationships.TryGetValue(relationshipName, out RelationshipData relationshipData))
{
var data = (List<Dictionary<string, string>>)relationshipData.ExposedData;
if (data == null) return entity;
var genericProcessor = _genericProcessorFactor.GetProcessor(attr.Type);
var ids = relationshipData.ManyData.Select(r => r["id"]);
genericProcessor.SetRelationships(entity, attr, ids);
}
return entity;
}
}
}
| 38.1 | 165 | 0.631026 |
3695a310c259c5a9f5a9bb87323de2b3a2fececa | 1,402 | cs | C# | bledevice/PoweredUp/Devices/LPF2DeviceType.cs | windoze/blego | fb95102f9a765290f83ca9fdb4a57cdaef1ddd1d | [
"WTFPL"
] | null | null | null | bledevice/PoweredUp/Devices/LPF2DeviceType.cs | windoze/blego | fb95102f9a765290f83ca9fdb4a57cdaef1ddd1d | [
"WTFPL"
] | null | null | null | bledevice/PoweredUp/Devices/LPF2DeviceType.cs | windoze/blego | fb95102f9a765290f83ca9fdb4a57cdaef1ddd1d | [
"WTFPL"
] | null | null | null | namespace bledevice.PoweredUp.Devices
{
// ReSharper disable InconsistentNaming
public enum LPF2DeviceType
{
UNKNOWN = 0,
SIMPLE_MEDIUM_LINEAR_MOTOR = 1,
TRAIN_MOTOR = 2,
LIGHT = 8,
VOLTAGE_SENSOR = 20,
CURRENT_SENSOR = 21,
PIEZO_BUZZER = 22,
HUB_LED = 23,
TILT_SENSOR = 34,
MOTION_SENSOR = 35,
COLOR_DISTANCE_SENSOR = 37,
MEDIUM_LINEAR_MOTOR = 38,
MOVE_HUB_MEDIUM_LINEAR_MOTOR = 39,
MOVE_HUB_TILT_SENSOR = 40,
DUPLO_TRAIN_BASE_MOTOR = 41,
DUPLO_TRAIN_BASE_SPEAKER = 42,
DUPLO_TRAIN_BASE_COLOR_SENSOR = 43,
DUPLO_TRAIN_BASE_SPEEDOMETER = 44,
TECHNIC_LARGE_LINEAR_MOTOR = 46, // Technic Control+
TECHNIC_XLARGE_LINEAR_MOTOR = 47, // Technic Control+
TECHNIC_MEDIUM_ANGULAR_MOTOR = 48, // Spike Prime
TECHNIC_LARGE_ANGULAR_MOTOR = 49, // Spike Prime
TECHNIC_MEDIUM_HUB_GESTURE_SENSOR = 54,
REMOTE_CONTROL_BUTTON = 55,
REMOTE_CONTROL_RSSI = 56,
TECHNIC_MEDIUM_HUB_ACCELEROMETER = 57,
TECHNIC_MEDIUM_HUB_GYRO_SENSOR = 58,
TECHNIC_MEDIUM_HUB_TILT_SENSOR = 59,
TECHNIC_MEDIUM_HUB_TEMPERATURE_SENSOR = 60,
TECHNIC_COLOR_SENSOR = 61, // Spike Prime
TECHNIC_DISTANCE_SENSOR = 62, // Spike Prime
TECHNIC_FORCE_SENSOR = 63 // Spike Prime
}
} | 35.948718 | 61 | 0.651926 |
85d9ff4e2c6d87f4f195ee8b6b54f757344260be | 1,755 | cs | C# | src/MAD.IntegrationFramework.Pardot/Domain/VisitorActivity.cs | maitlandmarshall/MaitlandsInterfaceFramework | d6907f77f78f493f858d7eabd14bb463b9482fa2 | [
"MIT"
] | 2 | 2020-02-20T09:33:17.000Z | 2020-03-11T23:49:26.000Z | src/MAD.IntegrationFramework.Pardot/Domain/VisitorActivity.cs | maitlandmarshall/MaitlandsInterfaceFramework | d6907f77f78f493f858d7eabd14bb463b9482fa2 | [
"MIT"
] | null | null | null | src/MAD.IntegrationFramework.Pardot/Domain/VisitorActivity.cs | maitlandmarshall/MaitlandsInterfaceFramework | d6907f77f78f493f858d7eabd14bb463b9482fa2 | [
"MIT"
] | 3 | 2020-02-16T01:51:18.000Z | 2020-03-11T23:49:32.000Z | using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace MAD.IntegrationFramework.Pardot.Domain
{
public class VisitorActivity : IImmutableEntity
{
public int Id { get; set; }
[JsonProperty("prospect_id")]
public int? ProspectId { get; set; }
[JsonProperty("visitor_id")]
public int? VisitorId { get; set; }
public int Type { get; set; }
[JsonProperty("type_name")]
public string TypeName { get; set; }
public string Details { get; set; }
[JsonProperty("email_id")]
public int? EmailId { get; set; }
[JsonProperty("email_template_id")]
public int? EmailTemplateId { get; set; }
[JsonProperty("list_email_id")]
public int? ListEmailId { get; set; }
[JsonProperty("form_id")]
public int? FormId { get; set; }
[JsonProperty("form_handler_id")]
public int? FormHandlerId { get; set; }
[JsonProperty("site_search_query_id")]
public int? SiteSearchQueryId { get; set; }
[JsonProperty("landing_page_id")]
public int? LandingPageId { get; set; }
[JsonProperty("paid_search_ad_id")]
public int? PaidSearchAdId { get; set; }
[JsonProperty("multivariate_test_variation_id")]
public int? MultivariateTestVariationId { get; set; }
[JsonProperty("visitor_page_view_id")]
public int? VisitorPageViewId { get; set; }
[JsonProperty("file_id")]
public int? FileId { get; set; }
[JsonProperty("campaign_id")]
public int? CampaignId { get; set; }
[JsonProperty("created_at")]
public DateTime CreatedAt { get; set; }
}
}
| 27 | 61 | 0.611396 |
76b930e924a0a396b02ca31d0cdff59e77abf0eb | 1,287 | cs | C# | src/compiler/StarkPlatform.Compiler.Features/Diagnostics/DiagnosticArguments.cs | encrypt0r/stark | 1cd7c58d3e30208c84733e39aefad7ded7421580 | [
"BSD-2-Clause",
"MIT"
] | 218 | 2017-01-17T23:12:15.000Z | 2022-03-30T13:54:40.000Z | src/compiler/StarkPlatform.Compiler.Features/Diagnostics/DiagnosticArguments.cs | encrypt0r/stark | 1cd7c58d3e30208c84733e39aefad7ded7421580 | [
"BSD-2-Clause",
"MIT"
] | 5 | 2017-01-22T01:50:37.000Z | 2020-10-10T19:27:58.000Z | src/compiler/StarkPlatform.Compiler.Features/Diagnostics/DiagnosticArguments.cs | encrypt0r/stark | 1cd7c58d3e30208c84733e39aefad7ded7421580 | [
"BSD-2-Clause",
"MIT"
] | 11 | 2017-03-02T15:30:35.000Z | 2021-12-28T06:08:54.000Z | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace StarkPlatform.Compiler.Diagnostics
{
/// <summary>
/// helper type to package diagnostic arguments to pass around between remote hosts
/// </summary>
internal class DiagnosticArguments
{
public bool ForcedAnalysis;
public bool ReportSuppressedDiagnostics;
public bool LogAnalyzerExecutionTime;
public ProjectId ProjectId;
public Checksum OptionSetChecksum;
public string[] AnalyzerIds;
public DiagnosticArguments()
{
}
public DiagnosticArguments(
bool forcedAnalysis,
bool reportSuppressedDiagnostics,
bool logAnalyzerExecutionTime,
ProjectId projectId,
Checksum optionSetChecksum,
string[] analyzerIds)
{
ForcedAnalysis = forcedAnalysis;
ReportSuppressedDiagnostics = reportSuppressedDiagnostics;
LogAnalyzerExecutionTime = logAnalyzerExecutionTime;
ProjectId = projectId;
OptionSetChecksum = optionSetChecksum;
AnalyzerIds = analyzerIds;
}
}
}
| 32.175 | 161 | 0.655012 |
f661a9ec78c238ef2ef14f5d7a7621bbda5b50ac | 3,099 | cs | C# | RtspClientSharp/Rtcp/RtcpReceiverReportPacket.cs | KallynGowdy/RtspClientSharp | dd0e3a1ec2352fbdee59a15f6f2be42e21a9d67f | [
"MIT"
] | 468 | 2018-07-26T20:33:12.000Z | 2022-03-27T14:47:33.000Z | RtspClientSharp/Rtcp/RtcpReceiverReportPacket.cs | KallynGowdy/RtspClientSharp | dd0e3a1ec2352fbdee59a15f6f2be42e21a9d67f | [
"MIT"
] | 113 | 2018-08-02T06:52:47.000Z | 2022-03-27T14:02:31.000Z | RtspClientSharp/Rtcp/RtcpReceiverReportPacket.cs | KallynGowdy/RtspClientSharp | dd0e3a1ec2352fbdee59a15f6f2be42e21a9d67f | [
"MIT"
] | 231 | 2018-08-06T02:55:38.000Z | 2022-03-31T23:09:21.000Z | using System;
using System.Collections.Generic;
using System.IO;
namespace RtspClientSharp.Rtcp
{
class RtcpReceiverReportPacket : RtcpPacket, ISerializablePacket
{
public uint SyncSourceId { get; }
public IReadOnlyList<RtcpReportBlock> Reports { get; }
public RtcpReceiverReportPacket(uint syncSourceId, IReadOnlyList<RtcpReportBlock> reports)
{
SyncSourceId = syncSourceId;
Reports = reports;
PaddingFlag = false;
SourceCount = reports.Count;
PayloadType = 201;
DwordLength = (4 + reports.Count * RtcpReportBlock.Size) / 4;
Length = (DwordLength + 1) * 4;
}
protected override void FillFromByteSegment(ArraySegment<byte> byteSegment)
{
}
public new void Serialize(Stream stream)
{
base.Serialize(stream);
stream.WriteByte((byte) (SyncSourceId >> 24));
stream.WriteByte((byte) (SyncSourceId >> 16));
stream.WriteByte((byte) (SyncSourceId >> 8));
stream.WriteByte((byte) SyncSourceId);
foreach (var report in Reports)
{
stream.WriteByte((byte) (report.SyncSourceId >> 24));
stream.WriteByte((byte) (report.SyncSourceId >> 16));
stream.WriteByte((byte) (report.SyncSourceId >> 8));
stream.WriteByte((byte) report.SyncSourceId);
stream.WriteByte((byte) report.FractionLost);
stream.WriteByte((byte) (report.CumulativePacketLost >> 16));
stream.WriteByte((byte) (report.CumulativePacketLost >> 8));
stream.WriteByte((byte) report.CumulativePacketLost);
stream.WriteByte((byte) (report.ExtHighestSequenceNumberReceived >> 24));
stream.WriteByte((byte) (report.ExtHighestSequenceNumberReceived >> 16));
stream.WriteByte((byte) (report.ExtHighestSequenceNumberReceived >> 8));
stream.WriteByte((byte) report.ExtHighestSequenceNumberReceived);
stream.WriteByte((byte) (report.Jitter >> 24));
stream.WriteByte((byte) (report.Jitter >> 16));
stream.WriteByte((byte) (report.Jitter >> 8));
stream.WriteByte((byte) report.Jitter);
stream.WriteByte((byte) (report.LastNtpTimeSenderReportReceived >> 24));
stream.WriteByte((byte) (report.LastNtpTimeSenderReportReceived >> 16));
stream.WriteByte((byte) (report.LastNtpTimeSenderReportReceived >> 8));
stream.WriteByte((byte) report.LastNtpTimeSenderReportReceived);
stream.WriteByte((byte) (report.DelaySinceLastTimeSenderReportReceived >> 24));
stream.WriteByte((byte) (report.DelaySinceLastTimeSenderReportReceived >> 16));
stream.WriteByte((byte) (report.DelaySinceLastTimeSenderReportReceived >> 8));
stream.WriteByte((byte) report.DelaySinceLastTimeSenderReportReceived);
}
}
}
} | 43.041667 | 98 | 0.610842 |
b6b2003b7b96fbf7c7a4707a3aa0fb008cd468c9 | 738 | cs | C# | ClipboardService.cs | samfromlv/RESX-Unused-Finder | f8e0c32ce58c664ef7af02cc550389e4adfaf52f | [
"MIT"
] | 15 | 2016-09-14T13:37:48.000Z | 2019-04-23T13:19:04.000Z | ClipboardService.cs | samfromlv/RESX-Unused-Finder | f8e0c32ce58c664ef7af02cc550389e4adfaf52f | [
"MIT"
] | 2 | 2019-10-17T14:11:57.000Z | 2020-04-27T21:59:21.000Z | ClipboardService.cs | samfromlv/RESX-Unused-Finder | f8e0c32ce58c664ef7af02cc550389e4adfaf52f | [
"MIT"
] | 9 | 2019-11-04T03:24:35.000Z | 2021-06-09T18:13:15.000Z | using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace ResxUnusedFinder
{
public static class ClipboardService
{
public static bool SetText(string text)
{
for (int i = 0; i < 5; i++)
{
try
{
Clipboard.SetText(text);
return true;
}
catch (COMException)
{
// retry
}
}
MessageBox.Show("Unable to copy text. Please try again later.");
return false;
}
}
}
| 22.363636 | 76 | 0.49187 |
3c039130f53814a1b8ee1aa2355c6bb708514995 | 5,720 | cs | C# | src/RequestProcessing/OwinHttpListenerRequest.cs | jkells/Owin.Host.MonoHttpListener | d7324ebc45a49177b482f283f93bfa50dc326c26 | [
"Apache-2.0"
] | 4 | 2015-04-07T16:33:42.000Z | 2019-04-30T02:29:29.000Z | src/RequestProcessing/OwinHttpListenerRequest.cs | jkells/Owin.Host.MonoHttpListener | d7324ebc45a49177b482f283f93bfa50dc326c26 | [
"Apache-2.0"
] | null | null | null | src/RequestProcessing/OwinHttpListenerRequest.cs | jkells/Owin.Host.MonoHttpListener | d7324ebc45a49177b482f283f93bfa50dc326c26 | [
"Apache-2.0"
] | null | null | null | // <copyright file="OwinHttpListenerRequest.cs" company="Microsoft Open Technologies, Inc.">
// Copyright 2011-2013 Microsoft Open Technologies, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
using System;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using Mono.Net;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace Owin.Host.MonoHttpListener.RequestProcessing
{
/// <summary>
/// This wraps an HttpListenerRequest and exposes it as an OWIN environment IDictionary.
/// </summary>
internal class OwinHttpListenerRequest
{
private readonly CallEnvironment _environment;
private readonly HttpListenerRequest _request;
/// <summary>
/// Initializes a new instance of the <see cref="OwinHttpListenerRequest"/> class.
/// Uses the given request object to populate the OWIN standard keys in the environment IDictionary.
/// Most values are copied so that they can be mutable, but the headers collection is only wrapped.
/// </summary>
internal OwinHttpListenerRequest(HttpListenerRequest request, string basePath, string path, string query, CallEnvironment environment)
{
Contract.Requires(request != null);
_request = request;
_environment = environment;
_environment.RequestProtocol = GetProtocol(request.ProtocolVersion);
_environment.RequestScheme = request.Url.Scheme;
_environment.RequestMethod = request.HttpMethod;
_environment.RequestPathBase = basePath;
_environment.RequestPath = path;
_environment.RequestQueryString = query;
_environment.RequestHeaders = new RequestHeadersDictionary(request);
if (_request.IsSecureConnection)
{
// TODO: Add delay sync load for folks that directly access the client cert key
_environment.LoadClientCert = (Func<Task>)LoadClientCertAsync;
}
}
private static string GetProtocol(Version version)
{
if (version.Major == 1)
{
if (version.Minor == 1)
{
return "HTTP/1.1";
}
else if (version.Minor == 0)
{
return "HTTP/1.0";
}
}
return "HTTP/" + version.ToString(2);
}
internal bool TryGetClientCert(ref X509Certificate value, ref Exception errors)
{
if (!_request.IsSecureConnection)
{
return false;
}
try
{
value = _request.GetClientCertificate();
if (_request.ClientCertificateError != 0)
{
errors = new Win32Exception(_request.ClientCertificateError);
}
return value != null;
}
catch (HttpListenerException)
{
// TODO: LOG
return false;
}
}
private Task LoadClientCertAsync()
{
try
{
if (!_environment.ClientCertNeedsInit)
{
return TaskHelpers.Completed();
}
return _request.GetClientCertificateAsync()
.Then(cert =>
{
_environment.ClientCert = cert;
_environment.ClientCertErrors =
(_request.ClientCertificateError == 0) ? null
: new Win32Exception(_request.ClientCertificateError);
})
.Catch(errorInfo =>
{
_environment.ClientCert = null;
_environment.ClientCertErrors = null;
// TODO: LOG
return errorInfo.Handled();
});
}
catch (HttpListenerException)
{
_environment.ClientCert = null;
_environment.ClientCertErrors = null;
// TODO: LOG
return TaskHelpers.Completed();
}
}
internal Stream GetRequestBody()
{
return new HttpListenerStreamWrapper(_request.InputStream);
}
internal string GetRemoteIpAddress()
{
return _request.RemoteEndPoint.Address.ToString();
}
internal string GetRemotePort()
{
return _request.RemoteEndPoint.Port.ToString(CultureInfo.InvariantCulture);
}
internal string GetLocalIpAddress()
{
return _request.LocalEndPoint.Address.ToString();
}
internal string GetLocalPort()
{
return _request.LocalEndPoint.Port.ToString(CultureInfo.InvariantCulture);
}
internal bool GetIsLocal()
{
return _request.IsLocal;
}
}
}
| 34.047619 | 142 | 0.567832 |
2e71bbe12edad47843c523ffc255ade91bd59822 | 1,430 | cs | C# | BondConverter/Program.cs | devCareOtter/BondGenerator | 6224a772367996ee793cf8f74939fbec54428248 | [
"Apache-2.0"
] | null | null | null | BondConverter/Program.cs | devCareOtter/BondGenerator | 6224a772367996ee793cf8f74939fbec54428248 | [
"Apache-2.0"
] | null | null | null | BondConverter/Program.cs | devCareOtter/BondGenerator | 6224a772367996ee793cf8f74939fbec54428248 | [
"Apache-2.0"
] | null | null | null | using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace BondConverter
{
class Program
{
static void Main(string[] args)
{
string assemblyPath = "";
string outputPath = "";
IEnumerable<string> types = Enumerable.Empty<string>();
var argsQueue = new Queue<string>(args);
while (argsQueue.Any())
{
var cur = argsQueue.Dequeue();
switch (cur)
{
case "-AssemblyPath":
assemblyPath = argsQueue.Dequeue();
break;
case "-OutputPath":
outputPath = argsQueue.Dequeue();
break;
case "-Types":
types = argsQueue.Dequeue().Split(',');
break;
default:
Console.WriteLine($"Unknown arg: {cur}");
break;
}
}
Assembly assembly = Assembly.LoadFrom(assemblyPath);
var converter = new BondConverter(types.Select(x => assembly.GetType(x)));
var str = converter.GenerateBondFile("test");
File.WriteAllText(outputPath, str);
}
}
}
| 28.6 | 86 | 0.476224 |
184f42aa1b16fde9129de7ce3dc8af539d21f622 | 3,011 | cs | C# | Assets/Scripts/GameManagement/CampaignManager.cs | Arutsuyo/The-Final-Lock | dd3bff7ef1c71642e196d3e8ecf311bc6e9555bc | [
"MIT"
] | 1 | 2019-06-24T07:29:51.000Z | 2019-06-24T07:29:51.000Z | Assets/Scripts/GameManagement/CampaignManager.cs | Arutsuyo/The-Final-Lock | dd3bff7ef1c71642e196d3e8ecf311bc6e9555bc | [
"MIT"
] | null | null | null | Assets/Scripts/GameManagement/CampaignManager.cs | Arutsuyo/The-Final-Lock | dd3bff7ef1c71642e196d3e8ecf311bc6e9555bc | [
"MIT"
] | null | null | null | using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Linq;
using System.Xml;
using System;
using UnityEngine.SceneManagement;
public class CampaignManager : CampaignManagerMP
{
override public void QueryRooms()
{
TextAsset[] ss = Resources.LoadAll<TextAsset>(RoomSearchPath);
List<EscapeRoom> eerooms = new List<EscapeRoom>();
// Debug.Log(ss.Length);
foreach (TextAsset sss in ss)
{
try
{
XmlDocument xx = new XmlDocument();
Debug.Log(sss.text);
xx.LoadXml(sss.text);
EscapeRoom e = ParseFile(xx);
if (e != null)
{
if (e.isSP)
eerooms.Add(e);
}
}
catch (Exception e)
{
Debug.LogError("Malformed escape room file! " + e.StackTrace);
}
}
erooms = eerooms.ToArray<EscapeRoom>();
}
public new void Start()
{
HideUI();
DontDestroyOnLoad(this.gameObject);
}
public override void Go(int id)
{
foreach (Button bb in Campaigns)
bb.interactable = false;
//pm.GetNumber(GetPort, 1000, 65535, "Please enter the port for hosting:", "" + 25565);
ActiveID = id;
Port = -1;
instance = this;
// Now actually launch it.
Debug.Log("Launching campaign ID " + ActiveID + " in 3...2....1...JUMP");
PlayerAnimation.SetTrigger("GoToRoom");
doorAnimation.SetTrigger("Door");
holoAnimation.SetTrigger("ToDoor");
// Swap rooms....
// Actually, destroy the OTHER campaign manager :3
// the other will destroy this one...
Destroy(otherContestant.gameObject);
nm.StartSPServer(25565, this);
nm.net.ClientSceneChanged += this.SendServerReady;
// But actually you are hosting a single player world :D
RegisterListenersHere();
StartCoroutine(TransferRooms());
}
public IEnumerator TransferRooms()
{
yield return new WaitForSecondsRealtime(9.37f/.8f);
//AOP = SceneManager.LoadSceneAsync(1);
if (nm.net.isHost)
{
// Send all clients the room details
// Send all clients the room details
int rid = erooms[ActiveID].roomID;
string ssb = SceneUtility.GetScenePathByBuildIndex(rid);
string ss = Path.GetFileNameWithoutExtension(ssb);
Debug.Log(ss + " " + rid);
nm.net.ServerChangeScene(ss);
}
}
public override void UpdateCampaignUI(int id)
{
//Debug.Log("Clicked campaign " + id);
if (holo != null)
Destroy(holo);
holo = Instantiate(holoDeck[Array.FindIndex(holoDeckNames, w => w.Equals(erooms[id].holoname))], holoStorage.transform);
Debug.Log(erooms[id].holoname + " " + Array.FindIndex(holoDeckNames, w => w.Equals(erooms[id].holoname)));
StartBtn.gameObject.SetActive(true);
StartBtn.interactable = true;
StartBtn.onClick.RemoveAllListeners();
StartBtn.onClick.AddListener(() => Go(id));
}
} | 28.951923 | 123 | 0.627698 |
4b1db6641fe9b1da19d3c9a401730899844639ca | 425 | cs | C# | back-end/src/Summer.Application/Apis/Roles/GetRoleById/GetRoleByIdQuery.cs | xiajingren/summer | c7acd995e7e0639a527e5b1123da0ca58a63859f | [
"MIT"
] | 3 | 2021-11-01T11:57:20.000Z | 2022-02-04T16:10:42.000Z | back-end/src/Summer.Application/Apis/Roles/GetRoleById/GetRoleByIdQuery.cs | xiajingren/summer | c7acd995e7e0639a527e5b1123da0ca58a63859f | [
"MIT"
] | 2 | 2021-04-14T06:35:08.000Z | 2021-09-23T07:15:57.000Z | back-end/src/Summer.Application/Apis/Roles/GetRoleById/GetRoleByIdQuery.cs | xiajingren/summer | c7acd995e7e0639a527e5b1123da0ca58a63859f | [
"MIT"
] | null | null | null | using MediatR;
using Summer.Application.Constants;
using Summer.Application.Permissions;
namespace Summer.Application.Apis.Roles.GetRoleById
{
[Permission(nameof(GetRoleByIdQuery), "根据Id获取角色", PermissionConstants.RoleGroupName)]
public class GetRoleByIdQuery : IRequest<RoleResponse>
{
public int Id { get; set; }
public GetRoleByIdQuery(int id)
{
Id = id;
}
}
} | 25 | 89 | 0.68 |
4baec4e8edb7cd4f5d3ee927a8c9d41135f47987 | 1,695 | cshtml | C# | StrixIT.Platform.Modules.Membership.WebClient/Areas/Membership/Views/Shared/AccountLinks.cshtml | StrixIT/StrixIT.Platform.Modules.Membership | 76b0c647806c8224a5484d5aac77de72fb7ff495 | [
"Apache-2.0"
] | null | null | null | StrixIT.Platform.Modules.Membership.WebClient/Areas/Membership/Views/Shared/AccountLinks.cshtml | StrixIT/StrixIT.Platform.Modules.Membership | 76b0c647806c8224a5484d5aac77de72fb7ff495 | [
"Apache-2.0"
] | null | null | null | StrixIT.Platform.Modules.Membership.WebClient/Areas/Membership/Views/Shared/AccountLinks.cshtml | StrixIT/StrixIT.Platform.Modules.Membership | 76b0c647806c8224a5484d5aac77de72fb7ff495 | [
"Apache-2.0"
] | null | null | null | <!-- #region Apache License -->
@*
Copyright 2015 StrixIT. Author R.G. Schurgers MA MSc.
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.
*@
<!-- #endregion -->
@if (Request.IsAuthenticated)
{
<span id="username">
<i class="fa fa-user fa-lg fa-fw"></i>
@StrixPlatform.User.Name
</span>
<ul>
<li><i class="fa fa-user fa-lg fa-fw"></i>@Html.ActionLink(Interface.LogOff, "LogOff", MembershipConstants.ACCOUNT, new { area = MembershipConstants.MEMBERSHIP }, new { target = "_self" })</li>
<li><i class="fa fa-wrench fa-lg fa-fw"></i>@Html.ActionLink(Interface.AccountOverviewLink, "SetPassword", MembershipConstants.ACCOUNT, new { area = MembershipConstants.MEMBERSHIP }, new { target = "_self" })</li>
</ul>
}
else
{
<p class="loginlinks">
[ @Html.ActionLink(Interface.LogOn, "LogIn", MembershipConstants.ACCOUNT, new { area = MembershipConstants.MEMBERSHIP }, null)
@if (StrixMembership.Configuration.Registration.AllowUserRegistration)
{
@:| @Html.ActionLink(Interface.Register, "Register", MembershipConstants.ACCOUNT, new { area = MembershipConstants.MEMBERSHIP }, null)
}]
</p>
} | 43.461538 | 221 | 0.684366 |
e118e81f2485764ea636d02862f82f7fcc249f6d | 868 | cs | C# | PowerAppsTools.Powershell.Cmdlets/XrmOnlineManagementApi/GetBackupsCmdlet.cs | malaker/PowerAppsTools | e21f93e48ceb1a8f8c751537358a6e2b4a50a40d | [
"MIT"
] | null | null | null | PowerAppsTools.Powershell.Cmdlets/XrmOnlineManagementApi/GetBackupsCmdlet.cs | malaker/PowerAppsTools | e21f93e48ceb1a8f8c751537358a6e2b4a50a40d | [
"MIT"
] | null | null | null | PowerAppsTools.Powershell.Cmdlets/XrmOnlineManagementApi/GetBackupsCmdlet.cs | malaker/PowerAppsTools | e21f93e48ceb1a8f8c751537358a6e2b4a50a40d | [
"MIT"
] | null | null | null | using System.Management.Automation;
namespace Malaker.PowerAppsTools.Powershell.Cmdlets
{
using OnlineManagementApiClient.Requests;
using System.Threading;
using Malaker.PowerAppsTools.OnlineManagementApiClient;
using OnlineManagementApiClient.Models;
[Cmdlet(VerbsCommon.Get, "Backups")]
[OutputType(typeof(GetInstanceBackupsResponse))]
public class GetBackupsCmdlet : XrmOnlineManagementApiCmdlet
{
[Parameter(Mandatory = true)]
[Alias("TargetInstance")]
[ValidateNotNullOrEmpty()]
public string TargetInstance { get; set; }
protected override void ProcessRecord()
{
var result = _client.GetInstanceBackups(new GetInstanceBackups(TargetInstance), CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult();
WriteObject(result);
}
}
}
| 33.384615 | 163 | 0.715438 |
d2694f581c99c951f4347b0585c3a1b96e570b78 | 24,922 | cs | C# | src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/documents/RMPublishingDialog.Designer.cs | Mu-L/wpf | a539c26bb4c099acaf902077e03f787775b082fd | [
"MIT"
] | 5,937 | 2018-12-04T16:32:50.000Z | 2022-03-31T09:48:37.000Z | src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/documents/RMPublishingDialog.Designer.cs | Mu-L/wpf | a539c26bb4c099acaf902077e03f787775b082fd | [
"MIT"
] | 4,151 | 2018-12-04T16:38:19.000Z | 2022-03-31T18:41:14.000Z | src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/documents/RMPublishingDialog.Designer.cs | Mu-L/wpf | a539c26bb4c099acaf902077e03f787775b082fd | [
"MIT"
] | 1,084 | 2018-12-04T16:24:21.000Z | 2022-03-30T13:52:03.000Z | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace MS.Internal.Documents
{
partial class RMPublishingDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
protected override void InitializeComponent()
{
this.flowLayoutPanelMain = new System.Windows.Forms.FlowLayoutPanel();
this.radioButtonUnrestricted = new System.Windows.Forms.RadioButton();
this.radioButtonPermissions = new System.Windows.Forms.RadioButton();
this.radioButtonTemplate = new System.Windows.Forms.RadioButton();
this.groupBoxMainContent = new System.Windows.Forms.GroupBox();
this.flowLayoutPanelUnrestricted = new System.Windows.Forms.FlowLayoutPanel();
this.flowLayoutPanelPermissions = new System.Windows.Forms.FlowLayoutPanel();
this.flowLayoutPanelTemplate = new System.Windows.Forms.FlowLayoutPanel();
this.textBoxUnrestrictedText = new System.Windows.Forms.TextBox();
this.labelSelectTemplate = new System.Windows.Forms.Label();
this.comboBoxTemplates = new System.Windows.Forms.ComboBox();
this.flowLayoutPanelPeople = new System.Windows.Forms.FlowLayoutPanel();
this.buttonPeoplePicker = new System.Windows.Forms.Button();
this.textBoxUserName = new System.Windows.Forms.TextBox();
this.buttonAddUser = new System.Windows.Forms.Button();
this.buttonEveryone = new System.Windows.Forms.Button();
this.buttonRemoveUser = new System.Windows.Forms.Button();
this.rightsTable = new RightsTable();
this.flowLayoutPanelExpires = new System.Windows.Forms.FlowLayoutPanel();
this.checkBoxValidUntil = new System.Windows.Forms.CheckBox();
this.datePickerValidUntil = new System.Windows.Forms.DateTimePicker();
this.flowLayoutPanelContact = new System.Windows.Forms.FlowLayoutPanel();
this.checkBoxPermissionsContact = new System.Windows.Forms.CheckBox();
this.textBoxPermissionsContact = new System.Windows.Forms.TextBox();
this.flowLayoutPanelActions = new System.Windows.Forms.FlowLayoutPanel();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonSaveAs = new System.Windows.Forms.Button();
this.flowLayoutPanelMain.SuspendLayout();
this.groupBoxMainContent.SuspendLayout();
this.flowLayoutPanelUnrestricted.SuspendLayout();
this.flowLayoutPanelPermissions.SuspendLayout();
this.flowLayoutPanelTemplate.SuspendLayout();
this.flowLayoutPanelPeople.SuspendLayout();
this.flowLayoutPanelExpires.SuspendLayout();
this.flowLayoutPanelActions.SuspendLayout();
this.SuspendLayout();
//
// flowLayoutPanelMain
//
this.flowLayoutPanelMain.AutoSize = true;
this.flowLayoutPanelMain.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanelMain.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.flowLayoutPanelMain.Controls.Add(this.radioButtonUnrestricted);
this.flowLayoutPanelMain.Controls.Add(this.radioButtonPermissions);
this.flowLayoutPanelMain.Controls.Add(this.radioButtonTemplate);
this.flowLayoutPanelMain.Controls.Add(this.groupBoxMainContent);
this.flowLayoutPanelMain.Controls.Add(this.flowLayoutPanelActions);
this.flowLayoutPanelMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanelMain.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanelMain.Name = "flowLayoutPanelMain";
this.flowLayoutPanelMain.Padding = new System.Windows.Forms.Padding(8);
this.flowLayoutPanelMain.WrapContents = false;
//
// radioButtonUnrestricted
//
this.radioButtonUnrestricted.AutoSize = true;
this.radioButtonUnrestricted.Name = "radioButtonUnrestricted";
this.radioButtonUnrestricted.Size = new System.Drawing.Size(85, 17);
this.radioButtonUnrestricted.TabStop = true;
this.radioButtonUnrestricted.UseVisualStyleBackColor = true;
this.radioButtonUnrestricted.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
//
// radioButtonPermissions
//
this.radioButtonPermissions.AutoSize = true;
this.radioButtonPermissions.Name = "radioButtonPermissions";
this.radioButtonPermissions.Size = new System.Drawing.Size(85, 17);
this.radioButtonPermissions.TabStop = true;
this.radioButtonPermissions.UseVisualStyleBackColor = true;
this.radioButtonPermissions.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
//
// radioButtonTemplate
//
this.radioButtonTemplate.AutoSize = true;
this.radioButtonTemplate.Name = "radioButtonTemplate";
this.radioButtonTemplate.Size = new System.Drawing.Size(85, 17);
this.radioButtonTemplate.TabStop = true;
this.radioButtonTemplate.UseVisualStyleBackColor = true;
this.radioButtonTemplate.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
//
// groupBoxMainContent
//
this.groupBoxMainContent.BackColor = System.Drawing.Color.Transparent;
this.groupBoxMainContent.Controls.Add(this.flowLayoutPanelUnrestricted);
this.groupBoxMainContent.Controls.Add(this.flowLayoutPanelPermissions);
this.groupBoxMainContent.Controls.Add(this.flowLayoutPanelTemplate);
this.groupBoxMainContent.Margin = new System.Windows.Forms.Padding(5);
this.groupBoxMainContent.Name = "groupBoxMainContent";
this.groupBoxMainContent.Size = new System.Drawing.Size(650, 270);
this.groupBoxMainContent.TabStop = false;
//
// flowLayoutPanelUnrestricted
//
this.flowLayoutPanelUnrestricted.AutoSize = true;
this.flowLayoutPanelUnrestricted.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanelUnrestricted.Controls.Add(this.textBoxUnrestrictedText);
this.flowLayoutPanelUnrestricted.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanelUnrestricted.Name = "flowLayoutPanelUnrestricted";
this.flowLayoutPanelUnrestricted.Padding = new System.Windows.Forms.Padding(5, 18, 5, 5);
//
// flowLayoutPanelPermissions
//
this.flowLayoutPanelPermissions.AutoSize = true;
this.flowLayoutPanelPermissions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanelPermissions.Controls.Add(this.flowLayoutPanelPeople);
this.flowLayoutPanelPermissions.Controls.Add(this.rightsTable);
this.flowLayoutPanelPermissions.Controls.Add(this.flowLayoutPanelContact);
this.flowLayoutPanelPermissions.Controls.Add(this.flowLayoutPanelExpires);
this.flowLayoutPanelPermissions.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanelPermissions.Name = "flowLayoutPanelPermissions";
this.flowLayoutPanelPermissions.Padding = new System.Windows.Forms.Padding(5, 18, 5, 5);
this.flowLayoutPanelPermissions.Visible = false;
//
// flowLayoutPanelTemplate
//
this.flowLayoutPanelTemplate.Controls.Add(this.labelSelectTemplate);
this.flowLayoutPanelTemplate.Controls.Add(this.comboBoxTemplates);
this.flowLayoutPanelTemplate.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanelTemplate.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanelTemplate.Name = "flowLayoutPanelTemplate";
this.flowLayoutPanelTemplate.Padding = new System.Windows.Forms.Padding(5, 18, 5, 5);
this.flowLayoutPanelTemplate.Visible = false;
//
// labelUnrestrictedText
//
this.textBoxUnrestrictedText.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBoxUnrestrictedText.Multiline = true;
this.textBoxUnrestrictedText.Name = "textBoxUnrestrictedText";
this.textBoxUnrestrictedText.Padding = new System.Windows.Forms.Padding(3);
this.textBoxUnrestrictedText.Size = new System.Drawing.Size(625, 230);
this.textBoxUnrestrictedText.ReadOnly = true;
this.textBoxUnrestrictedText.WordWrap = true;
//
// labelSelectTemplate
//
this.labelSelectTemplate.AutoSize = true;
this.labelSelectTemplate.Name = "labelSelectTemplate";
this.labelSelectTemplate.Padding = new System.Windows.Forms.Padding(3);
//
// comboBoxTemplates
//
this.comboBoxTemplates.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTemplates.FormattingEnabled = true;
this.comboBoxTemplates.Margin = new System.Windows.Forms.Padding(13, 3, 3, 3);
this.comboBoxTemplates.Name = "comboBox1";
this.comboBoxTemplates.Size = new System.Drawing.Size(350, 21);
//
// flowLayoutPanelPeople
//
this.flowLayoutPanelPeople.AutoSize = true;
this.flowLayoutPanelPeople.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanelPeople.Controls.Add(this.buttonPeoplePicker);
this.flowLayoutPanelPeople.Controls.Add(this.textBoxUserName);
this.flowLayoutPanelPeople.Controls.Add(this.buttonAddUser);
this.flowLayoutPanelPeople.Controls.Add(this.buttonEveryone);
this.flowLayoutPanelPeople.Controls.Add(this.buttonRemoveUser);
this.flowLayoutPanelPeople.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight;
this.flowLayoutPanelPeople.Name = "flowLayoutPanelPeople";
this.flowLayoutPanelPeople.WrapContents = false;
//
// buttonPeoplePicker
//
this.buttonPeoplePicker.Name = "buttonPeoplePicker";
this.buttonPeoplePicker.Click += new System.EventHandler(this.buttonPeoplePicker_Click);
//
// textBoxUserName
//
this.textBoxUserName.Margin = new System.Windows.Forms.Padding(3, 6, 3, 3);
this.textBoxUserName.Name = "textBoxUserName";
this.textBoxUserName.MinimumSize = new System.Drawing.Size(326, 20);
this.textBoxUserName.GotFocus += new System.EventHandler(textBoxUserName_GotFocus);
this.textBoxUserName.LostFocus += new System.EventHandler(textBoxUserName_LostFocus);
//
// buttonAddUser
//
this.buttonAddUser.AutoSize = true;
this.buttonAddUser.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.buttonAddUser.Name = "buttonAddUser";
this.buttonAddUser.Click += new System.EventHandler(this.buttonAddUser_Click);
//
// buttonAnyone
//
this.buttonEveryone.Name = "buttonAnyone";
this.buttonEveryone.Click += new System.EventHandler(this.buttonEveryone_Click);
//
// buttonRemoveUser
//
this.buttonRemoveUser.Name = "buttonRemoveUser";
this.buttonRemoveUser.Click += new System.EventHandler(this.buttonRemoveUser_Click);
//
// rightsTable
//
this.rightsTable.AdvancedRowHeadersBorderStyle.Bottom = System.Windows.Forms.DataGridViewAdvancedCellBorderStyle.Single;
this.rightsTable.AllowDrop = false;
this.rightsTable.AllowUserToAddRows = false;
this.rightsTable.AllowUserToDeleteRows = false;
this.rightsTable.AllowUserToOrderColumns = false;
this.rightsTable.AllowUserToResizeColumns = false;
this.rightsTable.AllowUserToResizeRows = false;
this.rightsTable.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.rightsTable.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.rightsTable.MultiSelect = false;
this.rightsTable.Name = "rightsTable";
this.rightsTable.RowHeadersVisible = false;
this.rightsTable.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.rightsTable.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.rightsTable.Size = new System.Drawing.Size(635, 150);
this.rightsTable.SelectionChanged += new System.EventHandler(this.rightsTable_SelectionChanged);
//
// flowLayoutPanelContact
//
this.flowLayoutPanelContact.AutoSize = true;
this.flowLayoutPanelContact.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanelContact.Controls.Add(this.checkBoxPermissionsContact);
this.flowLayoutPanelContact.Controls.Add(this.textBoxPermissionsContact);
this.flowLayoutPanelContact.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanelContact.Name = "flowLayoutPanelContact";
this.flowLayoutPanelContact.WrapContents = true;
//
// checkBoxPermissionsContact
//
this.checkBoxPermissionsContact.AutoSize = true;
this.checkBoxPermissionsContact.Name = "checkBoxPermissionsContact";
this.checkBoxPermissionsContact.CheckedChanged += new System.EventHandler(this.checkBoxPermissionsContact_CheckedChanged);
//
// textBoxPermissionsContact
//
this.textBoxPermissionsContact.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBoxPermissionsContact.Enabled = false;
this.textBoxPermissionsContact.Margin = new System.Windows.Forms.Padding(23, 3, 3, 3);
this.textBoxPermissionsContact.Name = "textBoxPermissionsContact";
this.textBoxPermissionsContact.ReadOnly = true;
this.textBoxPermissionsContact.Size = new System.Drawing.Size(612, 20);
//
// flowLayoutPanelExpires
//
this.flowLayoutPanelExpires.AutoSize = true;
this.flowLayoutPanelExpires.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanelExpires.Controls.Add(this.checkBoxValidUntil);
this.flowLayoutPanelExpires.Controls.Add(this.datePickerValidUntil);
this.flowLayoutPanelExpires.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight;
this.flowLayoutPanelExpires.Name = "flowLayoutPanelExpires";
this.flowLayoutPanelExpires.WrapContents = false;
//
// checkBoxValidUntil
//
this.checkBoxValidUntil.AutoSize = true;
this.checkBoxValidUntil.Name = "checkBoxValidUntil";
this.checkBoxValidUntil.CheckedChanged += new System.EventHandler(this.checkBoxValidUntil_CheckedChanged);
//
// datePickerValidUntil
//
this.datePickerValidUntil.Enabled = false;
this.datePickerValidUntil.Format = System.Windows.Forms.DateTimePickerFormat.Long;
this.datePickerValidUntil.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
this.datePickerValidUntil.Name = "datePickerValidUntil";
// This mirrors the control if and only if the RightToLeft property (which is
// retrieved from the parent control) is also set to Yes.
this.datePickerValidUntil.RightToLeftLayout = true;
//
// flowLayoutPanelActions
//
this.flowLayoutPanelActions.AutoSize = true;
this.flowLayoutPanelActions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanelActions.Controls.Add(this.buttonCancel);
this.flowLayoutPanelActions.Controls.Add(this.buttonSave);
this.flowLayoutPanelActions.Controls.Add(this.buttonSaveAs);
this.flowLayoutPanelActions.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanelActions.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanelActions.Location = new System.Drawing.Point(6, 395);
this.flowLayoutPanelActions.Name = "flowLayoutPanelActions";
this.flowLayoutPanelActions.Size = new System.Drawing.Size(541, 29);
this.flowLayoutPanelActions.WrapContents = false;
//
// buttonCancel
//
this.buttonCancel.AutoSize = true;
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(463, 3);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
//
// buttonSave
//
this.buttonSave.AutoSize = true;
this.buttonSave.Location = new System.Drawing.Point(382, 3);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23);
//
// buttonSaveAs
//
this.buttonSaveAs.AutoSize = true;
this.buttonSaveAs.Location = new System.Drawing.Point(301, 3);
this.buttonSaveAs.Name = "buttonSaveAs";
this.buttonSaveAs.Size = new System.Drawing.Size(75, 23);
// Tab Definitions
// These are defined on all elements for consistency. To enable an
// actual tabstop ensure the control has TabStop=true.
this.flowLayoutPanelMain.TabIndex = 0;
this.radioButtonUnrestricted.TabIndex = 1;
this.radioButtonPermissions.TabIndex = 2;
this.radioButtonTemplate.TabIndex = 3;
this.groupBoxMainContent.TabIndex = 4;
this.flowLayoutPanelUnrestricted.TabIndex = 5;
this.flowLayoutPanelPermissions.TabIndex = 6;
this.flowLayoutPanelTemplate.TabIndex = 7;
this.textBoxUnrestrictedText.TabIndex = 8;
this.labelSelectTemplate.TabIndex = 9;
this.comboBoxTemplates.TabIndex = 10;
this.flowLayoutPanelPeople.TabIndex = 11;
this.buttonPeoplePicker.TabIndex = 12;
this.textBoxUserName.TabIndex = 13;
this.buttonAddUser.TabIndex = 14;
this.buttonEveryone.TabIndex = 15;
this.buttonRemoveUser.TabIndex = 16;
this.rightsTable.TabIndex = 17;
this.flowLayoutPanelContact.TabIndex = 18;
this.checkBoxPermissionsContact.TabIndex = 19;
this.textBoxPermissionsContact.TabIndex = 20;
this.flowLayoutPanelExpires.TabIndex = 21;
this.checkBoxValidUntil.TabIndex = 22;
this.datePickerValidUntil.TabIndex = 23;
this.flowLayoutPanelActions.TabIndex = 24;
this.buttonSaveAs.TabIndex = 25;
this.buttonSave.TabIndex = 26;
this.buttonCancel.TabIndex = 27;
//
// RMPublishing
//
this.AcceptButton = buttonSaveAs;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.CancelButton = buttonCancel;
this.ClientSize = new System.Drawing.Size(554, 431);
this.Controls.Add(this.flowLayoutPanelMain);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "RMPublishing";
this.flowLayoutPanelMain.ResumeLayout(false);
this.flowLayoutPanelMain.PerformLayout();
this.groupBoxMainContent.ResumeLayout(false);
this.groupBoxMainContent.PerformLayout();
this.flowLayoutPanelUnrestricted.ResumeLayout(false);
this.flowLayoutPanelUnrestricted.PerformLayout();
this.flowLayoutPanelPermissions.ResumeLayout(false);
this.flowLayoutPanelPermissions.PerformLayout();
this.flowLayoutPanelTemplate.ResumeLayout(false);
this.flowLayoutPanelTemplate.PerformLayout();
this.flowLayoutPanelPeople.ResumeLayout(false);
this.flowLayoutPanelPeople.PerformLayout();
this.flowLayoutPanelExpires.ResumeLayout(false);
this.flowLayoutPanelExpires.PerformLayout();
this.flowLayoutPanelActions.ResumeLayout(false);
this.flowLayoutPanelActions.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelMain;
private System.Windows.Forms.RadioButton radioButtonUnrestricted;
private System.Windows.Forms.RadioButton radioButtonPermissions;
private System.Windows.Forms.RadioButton radioButtonTemplate;
private System.Windows.Forms.GroupBox groupBoxMainContent;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelUnrestricted;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelPermissions;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelTemplate;
private System.Windows.Forms.TextBox textBoxUnrestrictedText;
private System.Windows.Forms.Label labelSelectTemplate;
private System.Windows.Forms.ComboBox comboBoxTemplates;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelPeople;
private System.Windows.Forms.Button buttonPeoplePicker;
private System.Windows.Forms.TextBox textBoxUserName;
private System.Windows.Forms.Button buttonEveryone;
private System.Windows.Forms.Button buttonAddUser;
private System.Windows.Forms.Button buttonRemoveUser;
private RightsTable rightsTable;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelExpires;
private System.Windows.Forms.CheckBox checkBoxValidUntil;
private System.Windows.Forms.DateTimePicker datePickerValidUntil;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelContact;
private System.Windows.Forms.CheckBox checkBoxPermissionsContact;
private System.Windows.Forms.TextBox textBoxPermissionsContact;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelActions;
private System.Windows.Forms.Button buttonSave;
private System.Windows.Forms.Button buttonSaveAs;
private System.Windows.Forms.Button buttonCancel;
}
} | 58.09324 | 136 | 0.661343 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.