OdinEvent::OdinEvent(const j::json &full_msg) : OdinEvent() { if (full_msg.is_object()) { auto v= full_msg["type"]; if (v.is_number()) { _type = SCAST(MType, JS_INT(v)); } v= full_msg["code"]; if (v.is_number()) { _code = SCAST(EType, JS_INT(v)); } v= full_msg["source"]; if (v.is_object()) { _doco =v; } } }
EngineTimer::Convert::Convert(): _toS(0), _toMs(0), _toMu(0), _toNs(0) { auto frequency = QueryFrequency(); auto toSeconds = 1.0/(SCAST(f64, frequency)); _toS = toSeconds; _toMs = MsFromSec*toSeconds; _toMu = MuFromSec*toSeconds; _toNs = NsFromSec*toSeconds; }
// reads number of bytes from current file pos into buffer // returns number of bytes read s32 FileReader::ReadFile(c08* buffer, s32 numBytes) { if(!m_file || buffer == nullptr || numBytes <= 0) return 0; m_file.read(buffer, numBytes); return SCAST(s32, m_file.gcount()); }
f64 EngineTimer::GetFrameRunningTime(f64 conversionRate) const { return SCAST(f64, _thisFrame - _lastFrame)*conversionRate; }
f64 EngineTimer::GetTotalRunningTime(f64 conversionRate) const { return SCAST(f64, _thisFrame - _startTime)*conversionRate; }
#include <catch/catch.hpp> #define HEADER "typedef double scalar;\n" #define VARS "scalar a = 10.0; scalar aa = 10.5; scalar ab = 11.0;\n" #define START_CODE "void container() {\nint res = 0.0;\n" #define END_CODE "\n};\n" #define MAKE_CODE(stmt) HEADER VARS START_CODE stmt ";" END_CODE #define SCAST_T(TYPE, CODE) "static_cast<" TYPE ">(" CODE ")" #define SCAST(CODE) MAKE_CODE("res = " SCAST_T("int", CODE)) #define SCAST_SCALAR(CODE) MAKE_CODE("res = " SCAST_T("scalar", CODE)) #define SCAST_TYPE(TYPE, CODE) MAKE_CODE("res = " SCAST_T(TYPE, CODE)) #define SCAST_S(CODE) SCAST_T("int", CODE) KICKOFF_TEST(opov::module::ExplicitCast(), SCAST("a"), SCAST_S("a")) #define _TYPE_ "scalar" SCENARIO("Explicit casts. Module produces one match for type " _TYPE_, "[" _TYPE_ "_match]") { GIVEN("The 'ExplicitCast' module with type: " _TYPE_) { opov::test::TestApp app(conf); app.init(); app.addModule(new opov::module::ExplicitCast()); #include "tests/ExplicitCastMatchSet.inl" } } SCENARIO("Explicit casts. Module produces no match for type " _TYPE_, "[" _TYPE_ "_nmatch]") { GIVEN("The 'ExplicitCast' module with type: " _TYPE_) { opov::test::TestApp app(conf); app.init(); app.addModule(new opov::module::ExplicitCast());
int retlog; sigset_t *sigs; /* Allocate heap for download request * struct request stores all the information that might be * of interest */ req = (struct request *)calloc(1, sizeof(struct request)); /* Only some signals will be emitted */ /* signal_set: initialization while single-threaded */ sigs = malloc(sizeof *sigs); sigemptyset(sigs); sigaddset(sigs, SIGINT); sigaddset(sigs, SIGALRM); signal_set = SCAST(sigs); /* Block out all signals */ pthread_sigmask(SIG_BLOCK, signal_set, NULL); while (!error && (c = getopt(argc,argv,"p:l:n:hfv")) != -1) { switch(c) { case 'p': req->port = atoi(optarg); break; case 'f': fsuggested = 1; break; case 'l': strncpy(req->lfile, optarg, MAXBUFSIZ); break;