hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
108
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
67k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7d57ea775a493ae0c3d98bd36ba96118ff0b9eb7
| 1,434
|
cpp
|
C++
|
code/engine.vc2008/xrGame/autosave_manager.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 7
|
2018-03-27T12:36:07.000Z
|
2020-06-26T11:31:52.000Z
|
code/engine.vc2008/xrGame/autosave_manager.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 2
|
2018-05-26T23:17:14.000Z
|
2019-04-14T18:33:27.000Z
|
code/engine.vc2008/xrGame/autosave_manager.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 5
|
2020-10-18T11:55:26.000Z
|
2022-03-28T07:21:35.000Z
|
////////////////////////////////////////////////////////////////////////////
// Module : autosave_manager.cpp
// Created : 04.11.2004
// Modified : 04.11.2004
// Author : Dmitriy Iassenev
// Description : Autosave manager
////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "autosave_manager.h"
#include "../xrEngine/date_time.h"
#include "ai_space.h"
#include "level.h"
#include "xrMessages.h"
#include "UIGame.h"
#include "Actor.h"
extern LPCSTR alife_section;
CAutosaveManager::CAutosaveManager()
{
u32 hours, minutes, seconds;
LPCSTR section = alife_section;
sscanf(pSettings->r_string(section, "autosave_interval"), "%d:%d:%d", &hours, &minutes, &seconds);
m_autosave_interval = (u32)generate_time(1, 1, 1, hours, minutes, seconds);
m_last_autosave_time = Device.dwTimeGlobal;
sscanf(pSettings->r_string(section, "delay_autosave_interval"), "%d:%d:%d", &hours, &minutes, &seconds);
m_delay_autosave_interval = (u32)generate_time(1, 1, 1, hours, minutes, seconds);
m_not_ready_count = 0;
shedule.t_min = 5000;
shedule.t_max = 5000;
shedule_register();
}
CAutosaveManager::~CAutosaveManager()
{
shedule_unregister();
}
float CAutosaveManager::shedule_Scale()
{
return (.5f);
}
void CAutosaveManager::shedule_Update(u32 dt)
{
inherited::shedule_Update(dt);
}
void CAutosaveManager::on_game_loaded()
{
m_last_autosave_time = Device.dwTimeGlobal;
}
| 25.157895
| 105
| 0.656206
|
Rikoshet-234
|
7d5a2e1d415c9db70ec9fbe0cbcce50dcf3b9933
| 12,540
|
cpp
|
C++
|
test/validators/validators_factory_test.cpp
|
itzaayush/jwt-cpp
|
d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763
|
[
"MIT"
] | 102
|
2016-09-02T03:57:05.000Z
|
2022-03-22T12:23:59.000Z
|
test/validators/validators_factory_test.cpp
|
itzaayush/jwt-cpp
|
d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763
|
[
"MIT"
] | 41
|
2017-01-26T14:57:40.000Z
|
2020-10-16T11:28:49.000Z
|
test/validators/validators_factory_test.cpp
|
itzaayush/jwt-cpp
|
d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763
|
[
"MIT"
] | 55
|
2017-02-11T22:27:14.000Z
|
2022-03-31T08:29:22.000Z
|
#include <fstream>
#include <memory>
#include <string>
#include "./constants.h"
#include "gtest/gtest.h"
#include "jwt/hmacvalidator.h"
#include "jwt/jwt.h"
#include "jwt/messagevalidatorfactory.h"
#include "jwt/nonevalidator.h"
#include "jwt/rsavalidator.h"
// Test for the various validators.
TEST(parse_test, proper_hmac) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << hmacs[i] << "\" : { \"secret\" : \"safe!\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.str().c_str(), valid->toJson().c_str());
EXPECT_STREQ(hmacs[i], valid->algorithm().c_str());
}
}
TEST(parse_signer_test, proper_hmac) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << hmacs[i] << "\" : { \"secret\" : \"safe!\" } }";
validator_ptr valid(MessageValidatorFactory::BuildSigner(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.str().c_str(), valid->toJson().c_str());
EXPECT_STREQ(hmacs[i], valid->algorithm().c_str());
}
}
TEST(parse_test, can_use_validator) {
std::string json = "{ \"HS256\" : { \"secret\" : \"secret\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json));
std::string strtoken =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
"eyJzdWIiOiJzdWJqZWN0IiwiZXhwIjoxNDM3NDMzMzk3fQ."
"VGPkHXap_i2zwUCxr7dsjBq7Nnx83h5dNGjzuifjpx8";
::json header, payload;
std::tie(header, payload) = JWT::Decode(strtoken, valid.get());
EXPECT_FALSE(header.empty());
EXPECT_FALSE(payload.empty());
}
// Test for the various validators.
TEST(parse_test, proper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
TEST(parse_signer_test, rsa_missing_file) {
std::string json =
"{ \"RS256\" : { \"public\" : { \"fromfile\" : null } } }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), nlohmann::json::type_error);
}
// Test for the various validators.
TEST(parse_signer_test, proper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\", \"private\" : \""
"-----BEGIN RSA PRIVATE KEY-----\\n"
"MIIEowIBAAKCAQEA4SWe3cgEULKiz2wP+"
"fYqN2TxEx6DiL4rvyqZfl0CFpVMH7wC\\n"
"ZqvglxOMtUzpdO7USdlFmyOEjtH1tioll9EAg6DMs0QrLgBj7U0XHRHeJcRrbYx"
"m\\n"
"HqtmtRxjEmLBpClJoYaJ2fEdeaVcV5D1+kWMIRLM1q3RNafb1Q62nwSyojgX09/"
"X\\n"
"+lWtkuX4NPwnn5NW13uhLyO96bANWMzPhYewwCsY7s7HCscNEhVTLQF0UmtYMgp"
"n\\n"
"kzrR9aibtmCZhf58ebn0VjtoYu3JzhzmvUK+"
"E3OZb0xp3e2f464owRIvWTlTte9h\\n"
"kDnkNKYoqY7fF/"
"adwb8xDNZEAeYAwE0jC2tE3QIDAQABAoIBAQCsLgATba5XJHW8\\n"
"GNETAL2CRXDThUdkIMMF3AcsiuZY7O4dasOPTyxffPTjhaEX6rlwjHdd0EjEjC7"
"T\\n"
"k+HR+2TgRO2mvqAi+utwg78EXTC9QzxAt9k05TGTmdTuL5YU+/"
"oyS9hKUsmOyPYY\\n"
"hWSHc/5ZIK6EEsNmvCszAaCJdadCxCF9r/jTkT2iWVtV1Zrh7+Z/"
"azX+wWSBIcEW\\n"
"Lbk6MGCt2z7mWGla4x7ToxhYWBhRdDxZ0R3VzG05e1Yjn1q2U5uxsSdBAPAISge"
"D\\n"
"7LpnwMs9NcjGnVO2cUHfK1fL7tLpMlqTsyflEyvFuN2+WatY7eaFeI/"
"jRBb3ezYF\\n"
"IcNZD8eBAoGBAPnhgL1ZhpDZRJ+M/CjV0KQmbzoMyt5B38cDJ0VNZG/"
"CObCMKwvI\\n"
"kMisBwFZEyS1oiV2Lt//8tLDnrlvxQrKQLmEzI5kCbuh3EUiG/tMF4VmKB4+JR/"
"2\\n"
"TNsHCqeNuKmVjy+"
"SYNkHDfO5MbdNBSSXaV4GuA1L3evzwTNOij39C8ThAoGBAOap\\n"
"D7XOigmuGMeOiFcivtGmCuOKfS8ZqTV2tKBcu3kv8F9CeqAFp/Qznxn/"
"M8oi91VN\\n"
"rdDwkH9aClXXSjaj2FpWHCU+hQJUbzucClOf0VgExYsdwNwEDaVrwRbo+"
"fCzt3Fy\\n"
"IdChwV7AO9sSggcGWbavbCU7F/h1g/BLHx/"
"njYN9AoGAdQIDJqclO+6BE7UQ3o5A\\n"
"hJz6uFQFKs3t22K+oNT8kth/6wu3nGzuXwkuvpLXQ/"
"lJVAFjMcDIE6lGSc7slYDf\\n"
"jf+BSavOYu4IFtdCAwo+eVi8sGypNa4/"
"jtBdTNgwADjoM353myiSf+3YOdz264t6\\n"
"62x6Ar/"
"jyvj5Hu1IDn7PZAECgYAdoYw+G8lJ0w6l3B6Rqwn+Xqk5b9oDCfXdw2ES\\n"
"1LbUq57ibeTY18EqstL2gP1DM1i4oaD5nV3CrmtzeZO0DzpE6Jj3A+"
"AMW5JqgvIk\\n"
"qfw3pW1HIMxctzyVipEkg0tQa5XeQf4sEguIQ4Os8eS4SE2QFVr8MWoz5czMOqp"
"F\\n"
"6/YW9QKBgERgOD3W9BcecygPNZfGZSZRVF0j5LT0PDgKr/"
"02CIPu2mo+2ej9GmBP\\n"
"PnLXbe/R9SG8p2+Yh2ZfXn7FlXfr9a7MkzQWR/rpmxlDyzAyaJaI/"
"vCBP+KknzPo\\n"
"zBJNQZl5S6qKrqr0ypYs6ekAQ5MEe3twWWyXG2y1QgeMIs3BTnJ1\\n"
"-----END RSA PRIVATE KEY-----"
"\" } }";
validator_ptr valid(MessageValidatorFactory::BuildSigner(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
// Test for the various validators.
TEST(parse_test, improper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJK3ZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json.str()),
std::logic_error);
}
}
// Test for the various validators.
TEST(parse_test, proper_rsa_from_file) {
std::ofstream out("/tmp/test.key");
out << "-----BEGIN PUBLIC KEY-----\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskObb\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\n"
"-----END PUBLIC KEY-----";
out.close();
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << rs[i]
<< "\" : { \"public\" : { \"fromfile\" : \"/tmp/test.key\" } } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
// Test for the various validators.
TEST(parse_test, parse_set) {
std::string json =
"{ \"set\" : [ "
"{ \"HS256\" : { \"secret\" : \"safe\" } }, "
"{ \"HS512\" : { \"secret\" : \"supersafe\" } }"
" ] }";
validator_ptr valid(MessageValidatorFactory::Build(json));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.c_str(), valid->toJson().c_str());
EXPECT_TRUE(valid->Accepts({{"alg", "HS256"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS384"}}));
EXPECT_TRUE(valid->Accepts({{"alg", "HS512"}}));
}
TEST(parse_test, parse_kid) {
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"HS256\" : { \"secret\" : \"key1\" } }, "
"\"key2\" : { \"HS256\" : { \"secret\" : \"key2\" } }, "
"\"key3\" : { \"HS256\" : { \"secret\" : \"key3\" } } "
"} }";
validator_ptr valid(MessageValidatorFactory::Build(json));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.c_str(), valid->toJson().c_str());
EXPECT_TRUE(valid->Accepts({{"alg", "HS256"}, {"kid", "key1"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS256"}, {"kid", "key5"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS256"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS512"}, {"kid", "key1"}}));
}
TEST(parse_test, accepts_multiple_types) {
// do not have to be of the same type..
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"HS256\" : { \"secret\" : \"key1\" } }, "
"\"key3\" : { \"HS512\" : { \"secret\" : \"key3\" } } "
"} }";
ASSERT_NO_THROW(std::unique_ptr<MessageValidator>(MessageValidatorFactory::Build(json)));
}
TEST(parse_test, rsa_not_in_pem_format) {
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"RS256\" : { \"public\" : \"key1\" } }, "
"\"key2\" : { \"RS256\" : { \"public\" : \"key2\" } }, "
"\"key3\" : { \"RS256\" : { \"public\" : \"key3\" } } "
"} }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, non_existing) {
std::string json = "{ \"HS253\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, too_many_properties) {
std::string json =
"{ \"HS256\" : { \"secret\" : \"safe!\" }, \"FOO\" : \"BAR\" }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_signer, too_many_properties) {
std::string json =
"{ \"HS256\" : { \"secret\" : \"safe!\" }, \"FOO\" : \"BAR\" }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), std::logic_error);
}
TEST(parse_signer, non_existing_signer) {
std::string json = "{ \"HS252\" : { \"secret\" : \"safe!\" }}";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), std::logic_error);
}
TEST(parse_test, non_secret) {
std::string json = "{ \"HS256\" : { \"without_secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, bad_json) {
std::string json = "{ { \"HS256\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), nlohmann::json::parse_error);
}
TEST(parse_signer_test, bad_json) {
std::string json = "{ { \"HS256\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), nlohmann::json::parse_error);
}
void roundtrip(MessageValidator *validator) {
std::string json = validator->toJson();
validator_ptr msg(MessageValidatorFactory::Build(json));
EXPECT_STREQ(json.c_str(), msg->toJson().c_str());
}
void roundtrip_signer(MessageSigner *signer) {
std::string json = signer->toJson();
validator_ptr msg(MessageValidatorFactory::BuildSigner(json));
EXPECT_STREQ(json.c_str(), msg->toJson().c_str());
}
TEST(parse, round_trip_none) {
NoneValidator msg;
roundtrip(&msg);
}
TEST(parse_signer, round_trip_none) {
NoneValidator msg;
roundtrip_signer(&msg);
}
TEST(parse, round_trip_hs256) {
HS256Validator msg("secret");
roundtrip(&msg);
}
TEST(parse, round_trip_hs384) {
HS384Validator msg("secret");
roundtrip(&msg);
}
TEST(parse, round_trip_hs512) {
HS512Validator msg("secret");
roundtrip(&msg);
}
TEST(parse_signer, round_trip_hs256) {
HS256Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_hs384) {
HS384Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_hs512) {
HS512Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse, round_trip_rs256) {
RS256Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse, round_trip_rs384) {
RS384Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse, round_trip_rs512) {
RS512Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse_signer, round_trip_rs256) {
RS256Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_rs384) {
RS384Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_rs512) {
RS512Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
| 35.625
| 93
| 0.589394
|
itzaayush
|
7d5d6898d50e1481b8849485887fa8d1a9f5aa9c
| 6,065
|
cpp
|
C++
|
tengine/tools/toyviewer.cpp
|
BSVino/Digitanks
|
1bd1ed115493bce22001ae6684b70b8fcf135db0
|
[
"BSD-4-Clause"
] | 5
|
2015-07-03T18:42:32.000Z
|
2017-08-25T10:28:12.000Z
|
tengine/tools/toyviewer.cpp
|
BSVino/Digitanks
|
1bd1ed115493bce22001ae6684b70b8fcf135db0
|
[
"BSD-4-Clause"
] | null | null | null |
tengine/tools/toyviewer.cpp
|
BSVino/Digitanks
|
1bd1ed115493bce22001ae6684b70b8fcf135db0
|
[
"BSD-4-Clause"
] | null | null | null |
#include "toyviewer.h"
#include <tinker_platform.h>
#include <files.h>
#include <glgui/rootpanel.h>
#include <glgui/menu.h>
#include <glgui/filedialog.h>
#include <glgui/checkbox.h>
#include <models/models.h>
#include <tinker/application.h>
#include <renderer/game_renderingcontext.h>
#include <renderer/game_renderer.h>
#include <game/gameserver.h>
#include <tinker/keys.h>
#include <ui/gamewindow.h>
#include <toys/toy.h>
#include "workbench.h"
REGISTER_WORKBENCH_TOOL(ToyViewer);
CToyPreviewPanel::CToyPreviewPanel()
{
SetBackgroundColor(Color(0, 0, 0, 150));
SetBorder(glgui::CPanel::BT_SOME);
m_pInfo = new glgui::CLabel("", "sans-serif", 16);
AddControl(m_pInfo);
m_pShowPhysicsLabel = new glgui::CLabel("Show physics:", "sans-serif", 10);
m_pShowPhysicsLabel->SetAlign(glgui::CLabel::TA_TOPLEFT);
AddControl(m_pShowPhysicsLabel);
m_pShowPhysics = new glgui::CCheckBox();
AddControl(m_pShowPhysics);
}
void CToyPreviewPanel::Layout()
{
float flWidth = glgui::CRootPanel::Get()->GetWidth();
float flHeight = glgui::CRootPanel::Get()->GetHeight();
float flMenuBarBottom = glgui::CRootPanel::Get()->GetMenuBar()->GetBottom();
float flCurrLeft = 20;
float flCurrTop = flMenuBarBottom + 10;
SetDimensions(flCurrLeft, flCurrTop, 200, flHeight-30-flMenuBarBottom);
tstring sFilename = ToyViewer()->GetToyPreview();
tstring sAbsoluteGamePath = FindAbsolutePath(".");
tstring sAbsoluteFilename = FindAbsolutePath(sFilename);
if (sAbsoluteFilename.find(sAbsoluteGamePath) == 0)
sFilename = ToForwardSlashes(sAbsoluteFilename.substr(sAbsoluteGamePath.length()));
m_pInfo->SetText(sFilename);
m_pInfo->SetPos(0, 15);
m_pInfo->SetSize(GetWidth(), 25);
m_pShowPhysicsLabel->Layout_AlignTop(m_pInfo);
m_pShowPhysicsLabel->SetWidth(10);
m_pShowPhysicsLabel->SetHeight(1);
m_pShowPhysicsLabel->EnsureTextFits();
m_pShowPhysicsLabel->Layout_FullWidth();
m_pShowPhysics->SetTop(m_pShowPhysicsLabel->GetTop()+12);
m_pShowPhysics->SetLeft(m_pShowPhysicsLabel->GetLeft());
BaseClass::Layout();
}
CToyViewer* CToyViewer::s_pToyViewer = nullptr;
CToyViewer::CToyViewer()
{
s_pToyViewer = this;
m_pToyPreviewPanel = new CToyPreviewPanel();
m_pToyPreviewPanel->SetVisible(false);
glgui::CRootPanel::Get()->AddControl(m_pToyPreviewPanel);
m_iToyPreview = ~0;
m_bRotatingPreview = false;
m_angPreview = EAngle(-20, 20, 0);
m_flPreviewDistance = 10;
}
CToyViewer::~CToyViewer()
{
}
void CToyViewer::Activate()
{
Layout();
if (!m_sToyPreview.length() || m_iToyPreview == ~0)
ChooseToyCallback("");
BaseClass::Activate();
}
void CToyViewer::Deactivate()
{
BaseClass::Deactivate();
m_pToyPreviewPanel->SetVisible(false);
}
void CToyViewer::Layout()
{
m_pToyPreviewPanel->SetVisible(false);
if (m_iToyPreview != ~0)
m_pToyPreviewPanel->SetVisible(true);
SetupMenu();
}
void CToyViewer::SetupMenu()
{
GetFileMenu()->ClearSubmenus();
GetFileMenu()->AddSubmenu("Open", this, ChooseToy);
}
void CToyViewer::RenderScene()
{
CModel* pModel = CModelLibrary::GetModel(m_iToyPreview);
if (m_iToyPreview != ~0)
{
TAssert(pModel);
if (!pModel)
m_iToyPreview = ~0;
}
GameServer()->GetRenderer()->SetRenderingTransparent(false);
if (m_iToyPreview != ~0 && pModel)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
if (!c.GetActiveFrameBuffer())
c.UseFrameBuffer(GameServer()->GetRenderer()->GetSceneBuffer());
c.SetColor(Color(255, 255, 255));
c.RenderModel(m_iToyPreview);
if (m_pToyPreviewPanel->m_pShowPhysics->GetState() && pModel->m_pToy)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.ClearDepth();
c.UseProgram("model");
c.SetUniform("bDiffuse", false);
c.SetColor(Color(0, 100, 155, (int)(255*0.3f)));
c.SetBlend(BLEND_ALPHA);
c.SetUniform("vecColor", Color(0, 100, 155, (char)(255*0.3f)));
for (size_t i = 0; i < pModel->m_pToy->GetPhysicsNumBoxes(); i++)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.Transform(pModel->m_pToy->GetPhysicsBox(i).GetMatrix4x4());
c.RenderWireBox(CToy::s_aabbBoxDimensions);
}
if (pModel->m_pToy->GetPhysicsNumTris())
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.BeginRenderVertexArray();
c.SetPositionBuffer(pModel->m_pToy->GetPhysicsVerts());
c.EndRenderVertexArrayTriangles(pModel->m_pToy->GetPhysicsNumTris(), pModel->m_pToy->GetPhysicsTris());
}
// Reset for other stuff.
c.SetUniform("bDiffuse", true);
c.SetUniform("vecColor", Color(255, 255, 255, 255));
}
}
}
void CToyViewer::ChooseToyCallback(const tstring& sArgs)
{
glgui::CFileDialog::ShowOpenDialog(".", ".toy", this, OpenToy);
}
void CToyViewer::OpenToyCallback(const tstring& sArgs)
{
tstring sGamePath = GetRelativePath(sArgs, ".");
CModelLibrary::ReleaseModel(m_iToyPreview);
m_iToyPreview = CModelLibrary::AddModel(sGamePath);
if (m_iToyPreview != ~0)
{
m_sToyPreview = sGamePath;
m_flPreviewDistance = CModelLibrary::GetModel(m_iToyPreview)->m_aabbVisBoundingBox.Size().Length()*2;
}
Layout();
}
bool CToyViewer::MouseInput(int iButton, tinker_mouse_state_t iState)
{
if (iButton == TINKER_KEY_MOUSE_LEFT)
{
m_bRotatingPreview = (iState == TINKER_MOUSE_PRESSED);
return true;
}
return false;
}
void CToyViewer::MouseMotion(int x, int y)
{
if (m_bRotatingPreview)
{
int lx, ly;
if (GameWindow()->GetLastMouse(lx, ly))
{
m_angPreview.y -= (float)(x-lx);
m_angPreview.p -= (float)(y-ly);
}
}
}
void CToyViewer::MouseWheel(int x, int y)
{
if (y > 0)
{
for (int i = 0; i < y; i++)
m_flPreviewDistance *= 0.9f;
}
else if (y < 0)
{
for (int i = 0; i < -y; i++)
m_flPreviewDistance *= 1.1f;
}
}
TVector CToyViewer::GetCameraPosition()
{
if (m_iToyPreview == ~0)
return TVector(0, 0, 0);
CModel* pMesh = CModelLibrary::GetModel(m_iToyPreview);
if (!pMesh)
return TVector(0, 0, 0);
return pMesh->m_aabbVisBoundingBox.Center() - AngleVector(m_angPreview)*m_flPreviewDistance;
}
Vector CToyViewer::GetCameraDirection()
{
return AngleVector(m_angPreview);
}
| 23.060837
| 107
| 0.716076
|
BSVino
|
7d5f50a48f7e26b4301ed55a2c8703c9ffafe22b
| 2,428
|
cpp
|
C++
|
SiteData.cpp
|
RCjig/pw_manager
|
ed4da0ebccb6ab20813598ecf5731f0411f274e6
|
[
"Apache-2.0"
] | null | null | null |
SiteData.cpp
|
RCjig/pw_manager
|
ed4da0ebccb6ab20813598ecf5731f0411f274e6
|
[
"Apache-2.0"
] | null | null | null |
SiteData.cpp
|
RCjig/pw_manager
|
ed4da0ebccb6ab20813598ecf5731f0411f274e6
|
[
"Apache-2.0"
] | null | null | null |
#include "SiteData.h"
#include <ios>
#include <iostream>
using namespace std;
static int callback(void * used, int argc, char ** argv, char ** szColName) {
// set pointer structs values
select_wrapper * encSelect = (select_wrapper *) used;
encSelect->password = string(argv[0]);
// get rid of warning
if (0 > 1)
cout << encSelect;
return 0;
}
string SiteData::getPassword(char key) {
// decrypt passowrd using XOR cipher backwards
string password = "";
for (unsigned int i = 0; i < encPass.size(); i++) {
password += encPass[i] ^ (int(key) + i) % 255;
}
return password;
}
string SiteData::encodePassword(string password, char key) {
// encrypt passowrd using XOR cipher
string encryptPW = "";
for (unsigned int i = 0; i < password.size(); i++) {
encryptPW += password[i] ^ (int(key) + i) % 255;
}
return encryptPW;
}
void SiteData::insertPass(sqlite3 * db) {
// check if database exists
if (!db) {
return;
}
// create prepared statement
sqlite3_stmt * stmt;
const char * pzTest;
const char * szSQL;
string insert = "INSERT INTO passwords (id, website, user, password) values (?, ?, ?, ?)";
szSQL = insert.c_str();
int rc = sqlite3_prepare(db, szSQL, strlen(szSQL), &stmt, &pzTest);
if (rc == SQLITE_OK) {
// prepare params and bind to prepared statement
const char * websiteStmt = site.c_str();
const char * userStmt = user.c_str();
const char * passwordStmt = encPass.c_str();
sqlite3_bind_null(stmt, 1);
sqlite3_bind_text(stmt, 2, websiteStmt, strlen(websiteStmt), 0);
sqlite3_bind_text(stmt, 3, userStmt, strlen(userStmt), 0);
sqlite3_bind_text(stmt, 4, passwordStmt, strlen(passwordStmt), 0);
// execute
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
}
void SiteData::selectPass(sqlite3 * db) {
// check if database exists
if (!db) {
return;
}
// create prepared statement
char * szErrMsg = 0;
const char * pSQL;
string select = "SELECT password FROM passwords WHERE website = '" + site +
"' AND user = '" + user + "'";
pSQL = select.c_str();
// use struct to obtain select data
select_wrapper result;
int rc = sqlite3_exec(db, pSQL, callback, &result, &szErrMsg);
// check for error else set encrypted password
if (rc != SQLITE_OK) {
cerr << "Error: " << szErrMsg << endl;
sqlite3_free(szErrMsg);
} else {
encPass = result.password;
}
}
| 25.291667
| 92
| 0.645387
|
RCjig
|
7d5f54a7c49337653bb4f4e20ceed3b0b7ae30ed
| 6,300
|
cpp
|
C++
|
src/orbital/graphics/Graphics.cpp
|
JohannesMP/orbital
|
9dca53deb6989fbe4c5171c4e9517c2e548ea3fa
|
[
"MIT"
] | null | null | null |
src/orbital/graphics/Graphics.cpp
|
JohannesMP/orbital
|
9dca53deb6989fbe4c5171c4e9517c2e548ea3fa
|
[
"MIT"
] | null | null | null |
src/orbital/graphics/Graphics.cpp
|
JohannesMP/orbital
|
9dca53deb6989fbe4c5171c4e9517c2e548ea3fa
|
[
"MIT"
] | 1
|
2018-10-23T23:53:00.000Z
|
2018-10-23T23:53:00.000Z
|
//
// Created by jim on 24.01.18.
//
#include "Graphics.h"
#include <glm/gtx/matrix_transform_2d.hpp>
#include <orbital/math/elementary.h>
#include <orbital/common/convert.h>
Graphics::Graphics(
size_t const rows,
size_t cols
)
{
if (0 == rows)
{
throw std::runtime_error{"graphics cannot have 0 rows"};
}
if (0 == cols)
{
cols = static_cast<size_t>(rows / charRatio());
}
mScanlines.resize(rows);
for (auto &scanline : mScanlines)
{
scanline.resize(cols);
}
clear();
// Span over whole viewport
mProjection = glm::scale(mat{1}, {cols / 2.0, rows / 2.0});
// Origin should sit in the center
mProjection = glm::translate(mProjection, {1, 1});
// Y-Axis should point upwards
mProjection = glm::scale(mProjection, {1, -1});
// Scale against viewport distort
mProjection = glm::scale(mProjection, {rows / static_cast<Decimal>(cols) / charRatio(), 1});
push();
updateTransform();
}
void
Graphics::clear()
{
for (auto &scanline : mScanlines)
{
std::fill(scanline.begin(), scanline.end(), ' ');
}
}
void
Graphics::pixel(
WorldVector const &worldVector,
char const c
)
{
FramebufferVector vec = mapToFramebuffer(worldVector);
if (!withinFramebufferBounds(vec))
{
return;
}
char &target = framebufferPixel(FramebufferLocation{vec});
if (mOverwrite || (!mOverwrite && ' ' == target))
{
target = c;
}
}
void
Graphics::label(
WorldVector const &worldVector,
std::string_view const &text
)
{
auto vec = mapToFramebuffer(worldVector);
if (!withinFramebufferBounds(vec))
{
return;
}
FramebufferLocation loc{vec};
// If text length exceeds scanline length from a given column,
// the text must be trimmed to a smaller size to avoid:
auto span = std::min(text.length(), columns() - loc.x);
if (mOverwrite)
{
// Simply copy the whole text into framebuffer:
std::copy(text.begin(), text.begin() + span, mScanlines[loc.y].begin() + loc.x);
}
else
{
for (int i = 0; i < span; i++)
{
char &target = framebufferPixel(loc);
if (' ' == target)
{
target = text[i];
}
}
}
}
FramebufferVector
Graphics::mapToFramebuffer(
WorldVector const &vec
)
{
return mTransform * vec3{vec, 1.0};
}
Graphics::WorldVector
Graphics::mapToWorld(
FramebufferVector const &vec
)
{
return glm::inverse(mTransform) * vec3{vec, 1.0};
}
void
Graphics::border()
{
for (std::string &scanline : mScanlines)
{
scanline.front() = scanline.back() = '|';
}
std::fill(mScanlines.front().begin() + 1, mScanlines.front().end() - 1, '-');
std::fill(mScanlines.back().begin() + 1, mScanlines.back().end() - 1, '-');
mScanlines.front().front() = '+';
mScanlines.front().back() = '+';
mScanlines.back().front() = '+';
mScanlines.back().back() = '+';
}
void
Graphics::translate(
WorldVector const &v
)
{
mTransformStack.back().translate(v);
updateTransform();
}
void
Graphics::scale(
Decimal const s
)
{
mTransformStack.back().scale(s);
updateTransform();
}
void
Graphics::rotate(
Radian<Decimal> const theta
)
{
mTransformStack.back().rotate(theta);
updateTransform();
}
void
Graphics::updateTransform()
{
mat view{1};
for (auto transform : mTransformStack)
{
view *= transform.transformation();
}
mTransform = mProjection * view;
}
std::size_t
Graphics::columns() const
{
return static_cast<int>(mScanlines[0].length());
}
void
Graphics::resetTransform()
{
mTransformStack.back().reset();
updateTransform();
}
void
Graphics::present()
{
for (auto &scanline : mScanlines)
{
std::cout << scanline << '\n';
}
std::cout << std::flush;
}
bool
Graphics::withinFramebufferBounds(
const FramebufferVector &v
) const
{
return v.y >= 0 && v.y < rows() && v.x >= 0 && v.x < columns();
}
void
Graphics::push()
{
mTransformStack.emplace_back();
}
void
Graphics::pop()
{
mTransformStack.pop_back();
updateTransform();
}
mat const &
Graphics::transformation()
{
return mTransform;
}
void
Graphics::ellipse(const Ellipse<Decimal> &ellipse)
{
// Skip ellipse rendering if the viewport is completely contained by the ellipse shape,
// i.e. no lines are visible anyway.
vec ll = mapToWorld({0, rows() - 1});
vec ur = mapToWorld({columns() - 1, 0});
if (ellipse.contains(Rectangle<Decimal>{ll, ur}))
{
return;
}
// Since the stepper calculates the pixel distance based on vector subtraction and *not* on ellipse arc length,
// the ellipse must be divided into 4 quarters
stepper(ellipse, 0_pi, 0.5_pi);
stepper(ellipse, 0.5_pi, 1_pi);
stepper(ellipse, 1_pi, 1.5_pi);
stepper(ellipse, 1.5_pi, 2_pi);
}
void
Graphics::stepper(
const Ellipse<Decimal> &ellipse,
Radian<Decimal> const ts,
Radian<Decimal> const te
)
{
// Calculate distance the painted pixels of the start and end arc would have within the framebuffer:
auto const vs = convert<WorldVector>(ellipse.point(ts));
auto const ve = convert<WorldVector>(ellipse.point(te));
Decimal const d = vectorDistance(mapToFramebuffer(ve), mapToFramebuffer(vs));
// 1.4142... is the distance between to diagonal pixels:
if (1.5 < d)
{
// Distance between painted pixels in framebuffers spans over at least one pixel,
// continue stepping in smaller steps:
Radian<Decimal> const ta = average(ts, te);
stepper(ellipse, ts, ta);
stepper(ellipse, ta, te);
}
else
{
// Paint pixel:
pixel(vs, '+');
}
}
void
Graphics::overwrite(
bool const b
)
{
mOverwrite = b;
}
std::size_t
Graphics::rows() const
{
return static_cast<int>(mScanlines.size());
}
char &
Graphics::framebufferPixel(
const FramebufferLocation &loc
)
{
return mScanlines.at(loc.y).at(loc.x);
}
char const &
Graphics::framebufferPixel(
FramebufferLocation const &loc
) const
{
return mScanlines.at(loc.y).at(loc.x);
}
| 20.257235
| 115
| 0.61
|
JohannesMP
|
7d661387415c9fd340937d5049995710e681adb0
| 2,017
|
inl
|
C++
|
Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl
|
liliilli/DianYing
|
6e19f67e5d932e346a0ce63a648bed1a04ef618e
|
[
"MIT"
] | 4
|
2019-03-17T19:46:54.000Z
|
2019-12-09T20:11:01.000Z
|
Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl
|
liliilli/DianYing
|
6e19f67e5d932e346a0ce63a648bed1a04ef618e
|
[
"MIT"
] | 11
|
2019-06-09T13:53:27.000Z
|
2020-02-09T09:47:28.000Z
|
Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl
|
liliilli/DianYing
|
6e19f67e5d932e346a0ce63a648bed1a04ef618e
|
[
"MIT"
] | 1
|
2019-06-04T15:20:18.000Z
|
2019-06-04T15:20:18.000Z
|
#pragma once
///
/// MIT License
/// Copyright (c) 2018-2019 Jongmin Yun
///
/// 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.
///
namespace dy::math
{
template <typename TLeft, typename TRight, typename = void>
struct GetBiggerType_T;
template <typename TLeft, typename TRight>
struct GetBiggerType_T<
TLeft, TRight,
std::enable_if_t<kCategoryOf<TLeft> == kCategoryOf<TRight>>> final
{
static constexpr auto kCategory = kCategoryOf<TLeft>;
static constexpr auto kLeftSize = sizeof(TLeft) * 8;
static constexpr auto kRightSize = sizeof(TRight) * 8;
static constexpr auto kBiggerSize = kLeftSize > kRightSize ? kLeftSize : kRightSize;
using Type = typename GetCoverableTypeOf<kCategory, kBiggerSize>::Type;
};
template <typename TLeftType, typename TRightType>
struct GetBiggerType_T<
TLeftType, TRightType,
std::enable_if_t<
(kCategoryOf<TLeftType> == EValueCategory::Real)
^ (kCategoryOf<TRightType> == EValueCategory::Real)>> final
{
static constexpr EValueCategory kLeftCategory = kCategoryOf<TLeftType>;
static constexpr EValueCategory kRightCategory = kCategoryOf<TRightType>;
static constexpr auto kLeftSize = sizeof(TLeftType) * 8;
static constexpr auto kRightSize = sizeof(TRightType) * 8;
static constexpr auto kBiggerSize = kLeftSize > kRightSize ? kLeftSize : kRightSize;
using Type = std::conditional_t<
kLeftCategory == EValueCategory::Real,
typename GetCoverableTypeOf<kLeftCategory, kBiggerSize>::Type,
typename GetCoverableTypeOf<kRightCategory, kBiggerSize>::Type>;
};
} /// ::dy::math namespace
| 38.056604
| 86
| 0.752603
|
liliilli
|
de094bae004ab2fc038364a3977bd8bbea023726
| 622
|
cpp
|
C++
|
Qt/EARC/app/EARC/App/draganddroplabel.cpp
|
argama147/zetprogratv
|
fbe0b7f4390df5ce581e11860d5f6142cdb3fdb7
|
[
"MIT"
] | 1
|
2022-03-22T17:46:39.000Z
|
2022-03-22T17:46:39.000Z
|
Qt/EARC/app/EARC/App/draganddroplabel.cpp
|
argama147/zetprogratv
|
fbe0b7f4390df5ce581e11860d5f6142cdb3fdb7
|
[
"MIT"
] | 15
|
2022-02-20T05:10:23.000Z
|
2022-03-26T23:49:32.000Z
|
Qt/EARC/app/EARC/App/draganddroplabel.cpp
|
argama147/zetprogratv
|
fbe0b7f4390df5ce581e11860d5f6142cdb3fdb7
|
[
"MIT"
] | null | null | null |
#include "draganddroplabel.h"
#include <QDropEvent>
#include <QMimeData>
DragAndDropLabel::DragAndDropLabel(QWidget *parent)
: QLabel(parent)
{
setAcceptDrops(true);
}
void DragAndDropLabel::dragEnterEvent(QDragEnterEvent *event)
{
Q_ASSERT(event);
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
}
void DragAndDropLabel::dropEvent(QDropEvent *event)
{
Q_ASSERT(event);
QStringList pathList;
for (auto &url : event->mimeData()->urls()) {
pathList << url.toLocalFile();
}
emit sendFilePathList(pathList);
setText(pathList.join("\n"));
}
| 20.064516
| 61
| 0.673633
|
argama147
|
de097b69e3439a94ca773bf913638ce2add4e97a
| 115,226
|
cpp
|
C++
|
Source/Decoda/Decoda/LuaInject/LuaDll.cpp
|
KoSukeWork/BabeLua
|
0904f8ba15174fcfe88d75e37349c4f4f15403ef
|
[
"MIT"
] | null | null | null |
Source/Decoda/Decoda/LuaInject/LuaDll.cpp
|
KoSukeWork/BabeLua
|
0904f8ba15174fcfe88d75e37349c4f4f15403ef
|
[
"MIT"
] | null | null | null |
Source/Decoda/Decoda/LuaInject/LuaDll.cpp
|
KoSukeWork/BabeLua
|
0904f8ba15174fcfe88d75e37349c4f4f15403ef
|
[
"MIT"
] | 1
|
2020-12-07T13:47:47.000Z
|
2020-12-07T13:47:47.000Z
|
/*
Decoda
Copyright (C) 2007-2013 Unknown Worlds Entertainment, Inc.
This file is part of Decoda.
Decoda 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.
Decoda 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 Decoda. If not, see <http://www.gnu.org/licenses/>.
*/
#include "LuaDll.h"
#include "Hook.h"
#include "DebugBackend.h"
#include "StdCall.h"
#include "CriticalSection.h"
#include "CriticalSectionLock.h"
#include "DebugHelp.h"
#include <windows.h>
#include <tlhelp32.h>
#include <psapi.h>
#include <windows.h>
#include <malloc.h>
#include <assert.h>
#include <set>
#include <hash_map>
#include <hash_set>
// Macro for convenient pointer addition.
// Essentially treats the last two parameters as DWORDs. The first
// parameter is used to typecast the result to the appropriate pointer type.
#define MAKE_PTR(cast, ptr, addValue ) (cast)( (DWORD)(ptr)+(DWORD)(addValue))
// When this is defined, additional information about what's going on will be
// output for debugging.
//#define VERBOSE
//#define LOG
typedef const char* (__stdcall *lua_Reader_stdcall) (lua_State*, void*, size_t*);
typedef void (__stdcall *lua_Hook_stdcall) (lua_State*, lua_Debug*);
typedef lua_State* (*lua_open_cdecl_t) (int stacksize);
typedef lua_State* (*lua_open_500_cdecl_t) ();
typedef lua_State* (*lua_newstate_cdecl_t) (lua_Alloc, void*);
typedef void (*lua_close_cdecl_t) (lua_State*);
typedef lua_State* (*lua_newthread_cdecl_t) (lua_State*);
typedef int (*lua_error_cdecl_t) (lua_State*);
typedef int (*lua_sethook_cdecl_t) (lua_State*, lua_Hook, int, int);
typedef int (*lua_gethookmask_cdecl_t) (lua_State*);
typedef int (*lua_getinfo_cdecl_t) (lua_State*, const char*, lua_Debug* ar);
typedef void (*lua_remove_cdecl_t) (lua_State*, int);
typedef void (*lua_settable_cdecl_t) (lua_State*, int);
typedef void (*lua_gettable_cdecl_t) (lua_State*, int);
typedef void (*lua_rawget_cdecl_t) (lua_State *L, int idx);
typedef void (*lua_rawgeti_cdecl_t) (lua_State *L, int idx, int n);
typedef void (*lua_rawset_cdecl_t) (lua_State *L, int idx);
typedef void (*lua_pushstring_cdecl_t) (lua_State*, const char*);
typedef void (*lua_pushlstring_cdecl_t) (lua_State*, const char*, size_t);
typedef int (*lua_type_cdecl_t) (lua_State*, int);
typedef const char* (*lua_typename_cdecl_t) (lua_State*, int);
typedef void (*lua_settop_cdecl_t) (lua_State*, int);
typedef const char* (*lua_getlocal_cdecl_t) (lua_State*, const lua_Debug*, int);
typedef const char* (*lua_setlocal_cdecl_t) (lua_State*, const lua_Debug*, int);
typedef int (*lua_getstack_cdecl_t) (lua_State*, int, lua_Debug*);
typedef void (*lua_insert_cdecl_t) (lua_State*, int);
typedef void (*lua_pushnil_cdecl_t) (lua_State*);
typedef void (*lua_pushcclosure_cdecl_t) (lua_State*, lua_CFunction, int);
typedef void (*lua_pushvalue_cdecl_t) (lua_State*, int);
typedef void (*lua_pushinteger_cdecl_t) (lua_State*, int);
typedef void (*lua_pushnumber_cdecl_t) (lua_State*, lua_Number);
typedef const char* (*lua_tostring_cdecl_t) (lua_State*, int);
typedef const char* (*lua_tolstring_cdecl_t) (lua_State*, int, size_t*);
typedef int (*lua_toboolean_cdecl_t) (lua_State*, int);
typedef int (*lua_tointeger_cdecl_t) (lua_State*, int);
typedef lua_Integer (*lua_tointegerx_cdecl_t) (lua_State*, int, int*);
typedef lua_CFunction (*lua_tocfunction_cdecl_t) (lua_State*, int);
typedef lua_Number (*lua_tonumber_cdecl_t) (lua_State*, int);
typedef lua_Number (*lua_tonumberx_cdecl_t) (lua_State*, int, int*);
typedef void* (*lua_touserdata_cdecl_t) (lua_State*, int);
typedef int (*lua_gettop_cdecl_t) (lua_State*);
typedef int (*lua_load_cdecl_t) (lua_State*, lua_Reader, void*, const char *chunkname);
typedef void (*lua_call_cdecl_t) (lua_State*, int, int);
typedef void (*lua_callk_cdecl_t) (lua_State*, int, int, int, lua_CFunction);
typedef int (*lua_pcall_cdecl_t) (lua_State*, int, int, int);
typedef int (*lua_pcallk_cdecl_t) (lua_State*, int, int, int, int, lua_CFunction);
typedef void (*lua_newtable_cdecl_t) (lua_State*);
typedef void (*lua_createtable_cdecl_t) (lua_State*, int, int);
typedef int (*lua_next_cdecl_t) (lua_State*, int);
typedef int (*lua_rawequal_cdecl_t) (lua_State *L, int idx1, int idx2);
typedef int (*lua_getmetatable_cdecl_t) (lua_State*, int objindex);
typedef int (*lua_setmetatable_cdecl_t) (lua_State*, int objindex);
typedef int (*luaL_ref_cdecl_t) (lua_State *L, int t);
typedef void (*luaL_unref_cdecl_t) (lua_State *L, int t, int ref);
typedef int (*luaL_newmetatable_cdecl_t) (lua_State *L, const char *tname);
typedef int (*luaL_loadbuffer_cdecl_t) (lua_State *L, const char *buff, size_t sz, const char *name);
typedef int (*luaL_loadfile_cdecl_t) (lua_State *L, const char *fileName);
typedef const lua_WChar* (*lua_towstring_cdecl_t) (lua_State *L, int index);
typedef int (*lua_iswstring_cdecl_t) (lua_State *L, int index);
typedef const char* (*lua_getupvalue_cdecl_t) (lua_State *L, int funcindex, int n);
typedef const char* (*lua_setupvalue_cdecl_t) (lua_State *L, int funcindex, int n);
typedef void (*lua_getfenv_cdecl_t) (lua_State *L, int index);
typedef int (*lua_setfenv_cdecl_t) (lua_State *L, int index);
typedef void (*lua_pushlightuserdata_cdecl_t)(lua_State *L, void *p);
typedef int (*lua_cpcall_cdecl_t) (lua_State *L, lua_CFunction func, void *ud);
typedef int (*lua_pushthread_cdecl_t) (lua_State *L);
typedef void * (*lua_newuserdata_cdecl_t) (lua_State *L, size_t size);
typedef lua_State* (*luaL_newstate_cdecl_t) ();
typedef int (*lua_checkstack_cdecl_t) (lua_State* L, int extra);
typedef lua_State* (__stdcall *lua_open_stdcall_t) (int stacksize);
typedef lua_State* (__stdcall *lua_open_500_stdcall_t) ();
typedef lua_State* (__stdcall *lua_newstate_stdcall_t) (lua_Alloc, void*);
typedef void (__stdcall *lua_close_stdcall_t) (lua_State*);
typedef lua_State* (__stdcall *lua_newthread_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_error_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_sethook_stdcall_t) (lua_State*, lua_Hook_stdcall, int, int);
typedef int (__stdcall *lua_gethookmaskstdcall_t) (lua_State*);
typedef int (__stdcall *lua_getinfo_stdcall_t) (lua_State*, const char*, lua_Debug* ar);
typedef void (__stdcall *lua_remove_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_settable_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_gettable_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_rawget_stdcall_t) (lua_State *L, int idx);
typedef void (__stdcall *lua_rawgeti_stdcall_t) (lua_State *L, int idx, int n);
typedef void (__stdcall *lua_rawset_stdcall_t) (lua_State *L, int idx);
typedef void (__stdcall *lua_pushstring_stdcall_t) (lua_State*, const char*);
typedef void (__stdcall *lua_pushlstring_stdcall_t) (lua_State*, const char*, size_t);
typedef int (__stdcall *lua_type_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_typename_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_settop_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_getlocal_stdcall_t) (lua_State*, const lua_Debug*, int);
typedef const char* (__stdcall *lua_setlocal_stdcall_t) (lua_State*, const lua_Debug*, int);
typedef int (__stdcall *lua_getstack_stdcall_t) (lua_State*, int, lua_Debug*);
typedef void (__stdcall *lua_insert_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushnil_stdcall_t) (lua_State*);
typedef void (__stdcall *lua_pushcclosure_stdcall_t) (lua_State*, lua_CFunction, int);
typedef void (__stdcall *lua_pushvalue_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushinteger_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushnumber_stdcall_t) (lua_State*, lua_Number);
typedef const char* (__stdcall *lua_tostring_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_tolstring_stdcall_t) (lua_State*, int, size_t*);
typedef int (__stdcall *lua_toboolean_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_tointeger_stdcall_t) (lua_State*, int);
typedef lua_Integer (__stdcall *lua_tointegerx_stdcall_t) (lua_State*, int, int*);
typedef lua_CFunction (__stdcall *lua_tocfunction_stdcall_t) (lua_State*, int);
typedef lua_Number (__stdcall *lua_tonumber_stdcall_t) (lua_State*, int);
typedef lua_Number (__stdcall *lua_tonumberx_stdcall_t) (lua_State*, int, int*);
typedef void* (__stdcall *lua_touserdata_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_gettop_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_load_stdcall_t) (lua_State*, lua_Reader_stdcall, void*, const char *chunkname);
typedef void (__stdcall *lua_call_stdcall_t) (lua_State*, int, int);
typedef void (__stdcall *lua_callk_stdcall_t) (lua_State*, int, int, int, lua_CFunction);
typedef int (__stdcall *lua_pcall_stdcall_t) (lua_State*, int, int, int);
typedef int (__stdcall *lua_pcallk_stdcall_t) (lua_State*, int, int, int, int, lua_CFunction);
typedef void (__stdcall *lua_newtable_stdcall_t) (lua_State*);
typedef void (__stdcall *lua_createtable_stdcall_t) (lua_State*, int, int);
typedef int (__stdcall *lua_next_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_rawequal_stdcall_t) (lua_State *L, int idx1, int idx2);
typedef int (__stdcall *lua_getmetatable_stdcall_t) (lua_State*, int objindex);
typedef int (__stdcall *lua_setmetatable_stdcall_t) (lua_State*, int objindex);
typedef int (__stdcall *luaL_ref_stdcall_t) (lua_State *L, int t);
typedef void (__stdcall *luaL_unref_stdcall_t) (lua_State *L, int t, int ref);
typedef int (__stdcall *luaL_newmetatable_stdcall_t) (lua_State *L, const char *tname);
typedef int (__stdcall *luaL_loadbuffer_stdcall_t) (lua_State *L, const char *buff, size_t sz, const char *name);
typedef int (__stdcall *luaL_loadfile_stdcall_t) (lua_State *L, const char *fileName);
typedef const lua_WChar* (__stdcall *lua_towstring_stdcall_t) (lua_State *L, int index);
typedef int (__stdcall *lua_iswstring_stdcall_t) (lua_State *L, int index);
typedef const char* (__stdcall *lua_getupvalue_stdcall_t) (lua_State *L, int funcindex, int n);
typedef const char* (__stdcall *lua_setupvalue_stdcall_t) (lua_State *L, int funcindex, int n);
typedef void (__stdcall *lua_getfenv_stdcall_t) (lua_State *L, int index);
typedef int (__stdcall *lua_setfenv_stdcall_t) (lua_State *L, int index);
typedef void (__stdcall *lua_pushlightuserdata_stdcall_t)(lua_State *L, void *p);
typedef int (__stdcall *lua_cpcall_stdcall_t) (lua_State *L, lua_CFunction func, void *ud);
typedef int (__stdcall *lua_pushthread_stdcall_t) (lua_State *L);
typedef void * (__stdcall *lua_newuserdata_stdcall_t) (lua_State *L, size_t size);
typedef lua_State* (__stdcall *luaL_newstate_stdcall_t) ();
typedef int (__stdcall *lua_checkstack_stdcall_t) (lua_State* L, int extra);
typedef HMODULE (WINAPI *LoadLibraryExW_t) (LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags);
typedef ULONG (WINAPI *LdrLockLoaderLock_t) (ULONG flags, PULONG disposition, PULONG cookie);
typedef LONG (WINAPI *LdrUnlockLoaderLock_t) (ULONG flags, ULONG cookie);
/**
* Structure that holds pointers to all of the Lua API functions.
*/
struct LuaInterface
{
int version; // One of 401, 500, 510
bool finishedLoading;
bool stdcall;
// Use these instead of the LUA_* constants in lua.h. The value of these
// change depending on the version of Lua we're using.
int registryIndex;
int globalsIndex;
// cdecl functions.
lua_open_cdecl_t lua_open_dll_cdecl;
lua_open_500_cdecl_t lua_open_500_dll_cdecl;
lua_newstate_cdecl_t lua_newstate_dll_cdecl;
lua_close_cdecl_t lua_close_dll_cdecl;
lua_newthread_cdecl_t lua_newthread_dll_cdecl;
lua_error_cdecl_t lua_error_dll_cdecl;
lua_gettop_cdecl_t lua_gettop_dll_cdecl;
lua_sethook_cdecl_t lua_sethook_dll_cdecl;
lua_gethookmask_cdecl_t lua_gethookmask_dll_cdecl;
lua_getinfo_cdecl_t lua_getinfo_dll_cdecl;
lua_remove_cdecl_t lua_remove_dll_cdecl;
lua_settable_cdecl_t lua_settable_dll_cdecl;
lua_gettable_cdecl_t lua_gettable_dll_cdecl;
lua_rawget_cdecl_t lua_rawget_dll_cdecl;
lua_rawgeti_cdecl_t lua_rawgeti_dll_cdecl;
lua_rawset_cdecl_t lua_rawset_dll_cdecl;
lua_pushstring_cdecl_t lua_pushstring_dll_cdecl;
lua_pushlstring_cdecl_t lua_pushlstring_dll_cdecl;
lua_type_cdecl_t lua_type_dll_cdecl;
lua_typename_cdecl_t lua_typename_dll_cdecl;
lua_settop_cdecl_t lua_settop_dll_cdecl;
lua_getlocal_cdecl_t lua_getlocal_dll_cdecl;
lua_setlocal_cdecl_t lua_setlocal_dll_cdecl;
lua_getstack_cdecl_t lua_getstack_dll_cdecl;
lua_insert_cdecl_t lua_insert_dll_cdecl;
lua_pushnil_cdecl_t lua_pushnil_dll_cdecl;
lua_pushvalue_cdecl_t lua_pushvalue_dll_cdecl;
lua_pushinteger_cdecl_t lua_pushinteger_dll_cdecl;
lua_pushnumber_cdecl_t lua_pushnumber_dll_cdecl;
lua_pushcclosure_cdecl_t lua_pushcclosure_dll_cdecl;
lua_tostring_cdecl_t lua_tostring_dll_cdecl;
lua_tolstring_cdecl_t lua_tolstring_dll_cdecl;
lua_toboolean_cdecl_t lua_toboolean_dll_cdecl;
lua_tointeger_cdecl_t lua_tointeger_dll_cdecl;
lua_tointegerx_cdecl_t lua_tointegerx_dll_cdecl;
lua_tocfunction_cdecl_t lua_tocfunction_dll_cdecl;
lua_tonumber_cdecl_t lua_tonumber_dll_cdecl;
lua_tonumberx_cdecl_t lua_tonumberx_dll_cdecl;
lua_touserdata_cdecl_t lua_touserdata_dll_cdecl;
lua_load_cdecl_t lua_load_dll_cdecl;
lua_call_cdecl_t lua_call_dll_cdecl;
lua_callk_cdecl_t lua_callk_dll_cdecl;
lua_pcall_cdecl_t lua_pcall_dll_cdecl;
lua_pcallk_cdecl_t lua_pcallk_dll_cdecl;
lua_newtable_cdecl_t lua_newtable_dll_cdecl;
lua_createtable_cdecl_t lua_createtable_dll_cdecl;
lua_next_cdecl_t lua_next_dll_cdecl;
lua_rawequal_cdecl_t lua_rawequal_dll_cdecl;
lua_getmetatable_cdecl_t lua_getmetatable_dll_cdecl;
lua_setmetatable_cdecl_t lua_setmetatable_dll_cdecl;
luaL_ref_cdecl_t luaL_ref_dll_cdecl;
luaL_unref_cdecl_t luaL_unref_dll_cdecl;
luaL_newmetatable_cdecl_t luaL_newmetatable_dll_cdecl;
luaL_loadbuffer_cdecl_t luaL_loadbuffer_dll_cdecl;
luaL_loadfile_cdecl_t luaL_loadfile_dll_cdecl;
lua_towstring_cdecl_t lua_towstring_dll_cdecl;
lua_iswstring_cdecl_t lua_iswstring_dll_cdecl;
lua_getupvalue_cdecl_t lua_getupvalue_dll_cdecl;
lua_setupvalue_cdecl_t lua_setupvalue_dll_cdecl;
lua_getfenv_cdecl_t lua_getfenv_dll_cdecl;
lua_setfenv_cdecl_t lua_setfenv_dll_cdecl;
lua_pushlightuserdata_cdecl_t lua_pushlightuserdata_dll_cdecl;
lua_cpcall_cdecl_t lua_cpcall_dll_cdecl;
lua_pushthread_cdecl_t lua_pushthread_dll_cdecl;
lua_newuserdata_cdecl_t lua_newuserdata_dll_cdecl;
luaL_newstate_cdecl_t luaL_newstate_dll_cdecl;
lua_checkstack_cdecl_t lua_checkstack_dll_cdecl;
// stdcall functions.
lua_open_stdcall_t lua_open_dll_stdcall;
lua_open_500_stdcall_t lua_open_500_dll_stdcall;
lua_newstate_stdcall_t lua_newstate_dll_stdcall;
lua_close_stdcall_t lua_close_dll_stdcall;
lua_newthread_stdcall_t lua_newthread_dll_stdcall;
lua_error_stdcall_t lua_error_dll_stdcall;
lua_gettop_stdcall_t lua_gettop_dll_stdcall;
lua_sethook_stdcall_t lua_sethook_dll_stdcall;
lua_gethookmaskstdcall_t lua_gethookmask_dll_stdcall;
lua_getinfo_stdcall_t lua_getinfo_dll_stdcall;
lua_remove_stdcall_t lua_remove_dll_stdcall;
lua_settable_stdcall_t lua_settable_dll_stdcall;
lua_gettable_stdcall_t lua_gettable_dll_stdcall;
lua_rawget_stdcall_t lua_rawget_dll_stdcall;
lua_rawgeti_stdcall_t lua_rawgeti_dll_stdcall;
lua_rawset_stdcall_t lua_rawset_dll_stdcall;
lua_pushstring_stdcall_t lua_pushstring_dll_stdcall;
lua_pushlstring_stdcall_t lua_pushlstring_dll_stdcall;
lua_type_stdcall_t lua_type_dll_stdcall;
lua_typename_stdcall_t lua_typename_dll_stdcall;
lua_settop_stdcall_t lua_settop_dll_stdcall;
lua_getlocal_stdcall_t lua_getlocal_dll_stdcall;
lua_setlocal_stdcall_t lua_setlocal_dll_stdcall;
lua_getstack_stdcall_t lua_getstack_dll_stdcall;
lua_insert_stdcall_t lua_insert_dll_stdcall;
lua_pushnil_stdcall_t lua_pushnil_dll_stdcall;
lua_pushvalue_stdcall_t lua_pushvalue_dll_stdcall;
lua_pushinteger_stdcall_t lua_pushinteger_dll_stdcall;
lua_pushnumber_stdcall_t lua_pushnumber_dll_stdcall;
lua_pushcclosure_stdcall_t lua_pushcclosure_dll_stdcall;
lua_tostring_stdcall_t lua_tostring_dll_stdcall;
lua_tolstring_stdcall_t lua_tolstring_dll_stdcall;
lua_toboolean_stdcall_t lua_toboolean_dll_stdcall;
lua_tointeger_stdcall_t lua_tointeger_dll_stdcall;
lua_tointegerx_stdcall_t lua_tointegerx_dll_stdcall;
lua_tocfunction_stdcall_t lua_tocfunction_dll_stdcall;
lua_tonumber_stdcall_t lua_tonumber_dll_stdcall;
lua_tonumberx_stdcall_t lua_tonumberx_dll_stdcall;
lua_touserdata_stdcall_t lua_touserdata_dll_stdcall;
lua_load_stdcall_t lua_load_dll_stdcall;
lua_call_stdcall_t lua_call_dll_stdcall;
lua_callk_stdcall_t lua_callk_dll_stdcall;
lua_pcall_stdcall_t lua_pcall_dll_stdcall;
lua_pcallk_stdcall_t lua_pcallk_dll_stdcall;
lua_newtable_stdcall_t lua_newtable_dll_stdcall;
lua_createtable_stdcall_t lua_createtable_dll_stdcall;
lua_next_stdcall_t lua_next_dll_stdcall;
lua_rawequal_stdcall_t lua_rawequal_dll_stdcall;
lua_getmetatable_stdcall_t lua_getmetatable_dll_stdcall;
lua_setmetatable_stdcall_t lua_setmetatable_dll_stdcall;
luaL_ref_stdcall_t luaL_ref_dll_stdcall;
luaL_unref_stdcall_t luaL_unref_dll_stdcall;
luaL_newmetatable_stdcall_t luaL_newmetatable_dll_stdcall;
luaL_loadbuffer_stdcall_t luaL_loadbuffer_dll_stdcall;
luaL_loadfile_stdcall_t luaL_loadfile_dll_stdcall;
lua_towstring_stdcall_t lua_towstring_dll_stdcall;
lua_iswstring_stdcall_t lua_iswstring_dll_stdcall;
lua_getupvalue_stdcall_t lua_getupvalue_dll_stdcall;
lua_setupvalue_stdcall_t lua_setupvalue_dll_stdcall;
lua_getfenv_stdcall_t lua_getfenv_dll_stdcall;
lua_setfenv_stdcall_t lua_setfenv_dll_stdcall;
lua_pushlightuserdata_stdcall_t lua_pushlightuserdata_dll_stdcall;
lua_cpcall_stdcall_t lua_cpcall_dll_stdcall;
lua_pushthread_stdcall_t lua_pushthread_dll_stdcall;
lua_newuserdata_stdcall_t lua_newuserdata_dll_stdcall;
luaL_newstate_stdcall_t luaL_newstate_dll_stdcall;
lua_checkstack_stdcall_t lua_checkstack_dll_stdcall;
lua_CFunction DecodaOutput;
lua_CFunction CPCallHandler;
lua_Hook HookHandler;
};
struct CPCallHandlerArgs
{
lua_CFunction_dll function;
void* data;
};
/**
* This macro outputs the prolog code for a naked intercept function. It
* should be the first code in the function.
*/
#define INTERCEPT_PROLOG() \
__asm \
{ \
__asm push ebp \
__asm mov ebp, esp \
__asm sub esp, __LOCAL_SIZE \
}
/**
* This macro outputs the epilog code for a naked intercept function. It
* should be the last code in the function. argsSize is the number of
* bytes for the argments to the function (not including the the api parameter).
* The return from the function should be stored in the "result" variable, and
* the "stdcall" bool variable determines if the function was called using the
* stdcall or cdecl calling convention.
*/
#define INTERCEPT_EPILOG(argsSize) \
__asm \
{ \
__asm mov eax, result \
__asm cmp stdcall, 0 \
__asm mov esp, ebp \
__asm pop ebp \
__asm jne stdcall_ret \
__asm ret 4 \
__asm stdcall_ret: \
__asm ret (4 + argsSize) \
}
/**
* This macro outputs the epilog code for a naked intercept function that doesn't
* have a return value. It should be the last code in the function. argsSize is the
* number of bytes for the argments to the function (not including the the api
* parameter). The "stdcall" bool variable determines if the function was called using
* the stdcall or cdecl calling convention.
*/
#define INTERCEPT_EPILOG_NO_RETURN(argsSize) \
__asm \
{ \
__asm cmp stdcall, 0 \
__asm mov esp, ebp \
__asm pop ebp \
__asm jne stdcall_ret \
__asm ret 4 \
__asm stdcall_ret: \
__asm ret (4 + argsSize) \
}
LoadLibraryExW_t LoadLibraryExW_dll = NULL;
LdrLockLoaderLock_t LdrLockLoaderLock_dll = NULL;
LdrUnlockLoaderLock_t LdrUnlockLoaderLock_dll = NULL;
bool g_loadedLuaFunctions = false;
std::set<std::string> g_loadedModules;
CriticalSection g_loadedModulesCriticalSection;
std::vector<LuaInterface> g_interfaces;
stdext::hash_map<void*, void*> g_hookedFunctionMap;
stdext::hash_set<std::string> g_warnedAboutLua; // Indivates that we've warned the module contains Lua functions but none were loaded.
stdext::hash_set<std::string> g_warnedAboutPdb; // Indicates that we've warned about a module having a mismatched PDB.
bool g_warnedAboutThreads = false;
bool g_warnedAboutJit = false;
std::string g_symbolsDirectory;
static DWORD g_disableInterceptIndex = 0;
bool g_initializedDebugHelp = false;
/**
* Function called after a library has been loaded by the host application.
* We use this to check for the Lua dll.
*/
void PostLoadLibrary(HMODULE hModule);
/**
* Data structure passed into the MemoryReader function.
*/
struct Memory
{
const char* buffer;
size_t size;
};
/**
* lua_Reader function used to read from a memory buffer.
*/
const char* MemoryReader_cdecl(lua_State* L, void* data, size_t* size)
{
Memory* memory = static_cast<Memory*>(data);
if (memory->size > 0)
{
*size = memory->size;
memory->size = 0;
return memory->buffer;
}
else
{
return NULL;
}
}
/**
* lua_Reader function used to read from a memory buffer.
*/
const char* __stdcall MemoryReader_stdcall(lua_State* L, void* data, size_t* size)
{
Memory* memory = static_cast<Memory*>(data);
if (memory->size > 0)
{
*size = memory->size;
memory->size = 0;
return memory->buffer;
}
else
{
return NULL;
}
}
#pragma auto_inline(off)
int DecodaOutputWorker(unsigned long api, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
const char* message = lua_tostring_dll(api, L, 1);
// DebugBackend::Get().Message(message);
std::string outputMessage = "[LUA print] ";
outputMessage += message;
DebugBackend::Get().Message(outputMessage.c_str());
return 0;
}
#pragma auto_inline()
__declspec(naked) int DecodaOutput(unsigned long api, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
result = DecodaOutputWorker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
#pragma auto_inline(off)
int CPCallHandlerWorker(unsigned long api, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
CPCallHandlerArgs args = *static_cast<CPCallHandlerArgs*>(lua_touserdata_dll(api, L, 1));
// Remove the old args and put the new one on the stack.
lua_pop_dll(api, L, 1);
lua_pushlightuserdata_dll(api, L, args.data);
return args.function(api, L);
}
#pragma auto_inline()
__declspec(naked) int CPCallHandler(unsigned long api, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
result = CPCallHandlerWorker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
int lua_cpcall_dll(unsigned long api, lua_State *L, lua_CFunction_dll func, void *udn)
{
CPCallHandlerArgs args;
args.function = func;
args.data = udn;
return lua_cpcall_dll(api, L, g_interfaces[api].CPCallHandler, &args);
}
#pragma auto_inline(off)
void HookHandlerWorker(unsigned long api, lua_State* L, lua_Debug* ar, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
return DebugBackend::Get().HookCallback(api, L, ar);
}
#pragma auto_inline()
__declspec(naked) void HookHandler(unsigned long api, lua_State* L, lua_Debug* ar)
{
bool stdcall;
INTERCEPT_PROLOG()
HookHandlerWorker(api, L, ar, stdcall);
INTERCEPT_EPILOG_NO_RETURN(8)
}
void SetHookMode(unsigned long api, lua_State* L, HookMode mode)
{
if(mode == HookMode_None)
{
lua_sethook_dll(api, L, NULL, 0, 0);
}
else
{
int mask;
switch (mode)
{
case HookMode_CallsOnly:
mask = LUA_MASKCALL;
break;
case HookMode_CallsAndReturns:
mask = LUA_MASKCALL|LUA_MASKRET;
break;
case HookMode_Full:
mask = LUA_MASKCALL|LUA_MASKRET|LUA_MASKLINE;
break;
}
lua_sethook_dll(api, L, g_interfaces[api].HookHandler, mask, 0);
}
}
int lua_gethookmask(unsigned long api, lua_State *L)
{
if (g_interfaces[api].lua_gethookmask_dll_cdecl != NULL)
{
return g_interfaces[api].lua_gethookmask_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_gethookmask_dll_stdcall(L);
}
}
HookMode GetHookMode(unsigned long api, lua_State* L)
{
int mask = lua_gethookmask(api, L);
if(mask == 0)
{
return HookMode_None;
}
else if(mask == (LUA_MASKCALL))
{
return HookMode_CallsOnly;
}
else if(mask == (LUA_MASKCALL|LUA_MASKRET))
{
return HookMode_CallsAndReturns;
}
else
{
return HookMode_Full;
}
}
bool lua_pushthread_dll(unsigned long api, lua_State *L)
{
// These structures are taken out of the Lua 5.0 source code.
union lua_Value_500
{
void* gc;
void* p;
lua_Number n;
int b;
};
struct lua_TObject_500
{
int tt;
lua_Value_500 value;
};
struct lua_State_500
{
void* next;
unsigned char tt;
unsigned char marked;
lua_TObject_500* top;
};
#pragma pack(1)
union lua_Value_500_pack1
{
void* gc;
void* p;
lua_Number n;
int b;
};
struct lua_TObject_500_pack1
{
int tt;
lua_Value_500_pack1 value;
};
struct lua_State_500_pack1
{
void* next;
unsigned char tt;
unsigned char marked;
lua_TObject_500_pack1* top;
};
#pragma pack()
if (g_interfaces[api].lua_pushthread_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushthread_dll_cdecl(L);
return true;
}
else if (g_interfaces[api].lua_pushthread_dll_stdcall != NULL)
{
g_interfaces[api].lua_pushthread_dll_stdcall(L);
return true;
}
else
{
// The actual push thread function doesn't exist (probably Lua 5.0), so
// emulate it. The lua_pushthread function just pushes the state onto the
// stack and sets the type to LUA_TTHREAD. We use the pushlightuserdata
// function which basically does the same thing, except we need to modify the
// type of the object on the top of the stack.
lua_pushlightuserdata_dll(api, L, L);
// Check that the thing we think is pointing to the top of the stack actually
// is so that we don't overwrite something in memory.
bool success = false;
// If the structures are laid out differently in the implementation of Lua
// we might get crashes, so we wrap the access in a try block.
__try
{
lua_State_500* S = reinterpret_cast<lua_State_500*>(L);
lua_TObject_500* top = S->top - 1;
if (top->tt == LUA_TLIGHTUSERDATA && top->value.p == L)
{
top->tt = LUA_TTHREAD;
top->value.gc = L;
success = true;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
if (!success)
{
// The unpacked version didn't work out right, so try the version with no alignment.
__try
{
lua_State_500_pack1* S = reinterpret_cast<lua_State_500_pack1*>(L);
lua_TObject_500_pack1* top = S->top - 1;
if (top->tt == LUA_TLIGHTUSERDATA && top->value.p == L)
{
top->tt = LUA_TTHREAD;
top->value.gc = L;
success = true;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
}
if (!success)
{
lua_pop_dll(api, L, 1);
if (!g_warnedAboutThreads)
{
DebugBackend::Get().Message("Warning 1006: lua_pushthread could not be emulated due to modifications to Lua. Coroutines may be unstable", MessageType_Warning);
g_warnedAboutThreads = true;
}
}
return success;
}
}
void* lua_newuserdata_dll(unsigned long api, lua_State *L, size_t size)
{
if (g_interfaces[api].lua_newuserdata_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newuserdata_dll_cdecl(L, size);
}
else
{
return g_interfaces[api].lua_newuserdata_dll_stdcall(L, size);
}
}
void EnableIntercepts(bool enableIntercepts)
{
int value = reinterpret_cast<int>(TlsGetValue(g_disableInterceptIndex));
if (enableIntercepts)
{
--value;
}
else
{
++value;
}
TlsSetValue(g_disableInterceptIndex, reinterpret_cast<LPVOID>(value));
}
bool GetAreInterceptsEnabled()
{
int value = reinterpret_cast<int>(TlsGetValue(g_disableInterceptIndex));
return value <= 0;
}
void RegisterDebugLibrary(unsigned long api, lua_State* L)
{
lua_register_dll(api, L, "decoda_output", g_interfaces[api].DecodaOutput);
}
int GetGlobalsIndex(unsigned long api)
{
return g_interfaces[api].globalsIndex;
}
int GetRegistryIndex(unsigned long api)
{
return g_interfaces[api].registryIndex;
}
int lua_abs_index_dll(unsigned long api, lua_State* L, int i)
{
if (i > 0 || i <= GetRegistryIndex(api))
{
return i;
}
else
{
return lua_gettop_dll(api, L) + i + 1;
}
}
int lua_upvalueindex_dll(unsigned long api, int i)
{
return GetGlobalsIndex(api) - i;
}
void lua_setglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_setfield_dll(api, L, GetGlobalsIndex(api), s);
}
void lua_getglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_getfield_dll(api, L, GetGlobalsIndex(api), s);
}
void lua_rawgetglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_pushstring_dll(api, L, s);
lua_rawget_dll(api, L, GetGlobalsIndex(api));
}
lua_State* lua_newstate_dll(unsigned long api, lua_Alloc f, void* ud)
{
if (g_interfaces[api].lua_newstate_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newstate_dll_cdecl(f, ud);
}
else if (g_interfaces[api].lua_newstate_dll_stdcall != NULL)
{
return g_interfaces[api].lua_newstate_dll_stdcall(f, ud);
}
// This is an older version of Lua that doesn't support lua_newstate, so emulate it
// with lua_open.
if (g_interfaces[api].lua_open_500_dll_cdecl != NULL)
{
return g_interfaces[api].lua_open_500_dll_cdecl();
}
else if (g_interfaces[api].lua_open_500_dll_stdcall != NULL)
{
return g_interfaces[api].lua_open_500_dll_stdcall();
}
else if (g_interfaces[api].lua_open_dll_cdecl != NULL)
{
return g_interfaces[api].lua_open_dll_cdecl(0);
}
else if (g_interfaces[api].lua_open_dll_stdcall != NULL)
{
return g_interfaces[api].lua_open_dll_stdcall(0);
}
assert(0);
return NULL;
}
void lua_close_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_close_dll_cdecl != NULL)
{
g_interfaces[api].lua_close_dll_cdecl(L);
}
else
{
g_interfaces[api].lua_close_dll_stdcall(L);
}
}
lua_State* lua_newthread_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_newthread_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newthread_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_newthread_dll_stdcall(L);
}
}
int lua_error_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_error_dll_cdecl != NULL)
{
return g_interfaces[api].lua_error_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_error_dll_stdcall(L);
}
}
int lua_sethook_dll(unsigned long api, lua_State* L, lua_Hook f, int mask, int count)
{
if (g_interfaces[api].lua_sethook_dll_cdecl != NULL)
{
return g_interfaces[api].lua_sethook_dll_cdecl(L, f, mask, count);
}
else
{
return g_interfaces[api].lua_sethook_dll_stdcall(L, (lua_Hook_stdcall)f, mask, count);
}
}
int lua_getinfo_dll(unsigned long api, lua_State* L, const char* what, lua_Debug* ar)
{
if (g_interfaces[api].lua_getinfo_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getinfo_dll_cdecl(L, what, ar);
}
else
{
return g_interfaces[api].lua_getinfo_dll_stdcall(L, what, ar);
}
}
void lua_remove_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_remove_dll_cdecl != NULL)
{
g_interfaces[api].lua_remove_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_remove_dll_stdcall(L, index);
}
}
void lua_settable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_settable_dll_cdecl != NULL)
{
g_interfaces[api].lua_settable_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_settable_dll_stdcall(L, index);
}
}
void lua_gettable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_gettable_dll_cdecl != NULL)
{
g_interfaces[api].lua_gettable_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_gettable_dll_stdcall(L, index);
}
}
void lua_rawget_dll(unsigned long api, lua_State* L, int idx)
{
if (g_interfaces[api].lua_rawget_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawget_dll_cdecl(L, idx);
}
else
{
g_interfaces[api].lua_rawget_dll_stdcall(L, idx);
}
}
void lua_rawgeti_dll(unsigned long api, lua_State *L, int idx, int n)
{
if (g_interfaces[api].lua_rawgeti_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawgeti_dll_cdecl(L, idx, n);
}
else
{
g_interfaces[api].lua_rawgeti_dll_stdcall(L, idx, n);
}
}
void lua_rawset_dll(unsigned long api, lua_State* L, int idx)
{
if (g_interfaces[api].lua_rawset_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawset_dll_cdecl(L, idx);
}
else
{
g_interfaces[api].lua_rawset_dll_stdcall(L, idx);
}
}
void lua_pushstring_dll(unsigned long api, lua_State* L, const char* s)
{
if (g_interfaces[api].lua_pushstring_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushstring_dll_cdecl(L, s);
}
else
{
g_interfaces[api].lua_pushstring_dll_stdcall(L, s);
}
}
void lua_pushlstring_dll(unsigned long api, lua_State* L, const char* s, size_t len)
{
if (g_interfaces[api].lua_pushlstring_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushlstring_dll_cdecl(L, s, len);
}
else
{
g_interfaces[api].lua_pushlstring_dll_stdcall(L, s, len);
}
}
int lua_type_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_type_dll_cdecl != NULL)
{
return g_interfaces[api].lua_type_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_type_dll_stdcall(L, index);
}
}
const char* lua_typename_dll(unsigned long api, lua_State* L, int type)
{
if (g_interfaces[api].lua_typename_dll_cdecl != NULL)
{
return g_interfaces[api].lua_typename_dll_cdecl(L, type);
}
else
{
return g_interfaces[api].lua_typename_dll_stdcall(L, type);
}
}
int lua_checkstack_dll(unsigned long api, lua_State* L, int extra)
{
if (g_interfaces[api].lua_checkstack_dll_cdecl != NULL)
{
return g_interfaces[api].lua_checkstack_dll_cdecl(L, extra);
}
else
{
return g_interfaces[api].lua_checkstack_dll_stdcall(L, extra);
}
}
void lua_getfield_dll(unsigned long api, lua_State* L, int index, const char* k)
{
// Since Lua 4.0 doesn't include lua_getfield, we just emulate its
// behavior for simplicity.
index = lua_abs_index_dll(api, L, index);
lua_pushstring_dll(api, L, k);
lua_gettable_dll(api, L, index);
}
void lua_setfield_dll(unsigned long api, lua_State* L, int index, const char* k)
{
// Since Lua 4.0 doesn't include lua_setfield, we just emulate its
// behavior for simplicity.
index = lua_abs_index_dll(api, L, index);
lua_pushstring_dll(api, L, k);
lua_insert_dll(api, L, -2);
lua_settable_dll(api, L, index);
}
void lua_settop_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_settop_dll_cdecl != NULL)
{
g_interfaces[api].lua_settop_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_settop_dll_stdcall(L, index);
}
}
const char* lua_getlocal_dll(unsigned long api, lua_State* L, const lua_Debug* ar, int n)
{
if (g_interfaces[api].lua_getlocal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getlocal_dll_cdecl(L, ar, n);
}
else
{
return g_interfaces[api].lua_getlocal_dll_stdcall(L, ar, n);
}
}
const char* lua_setlocal_dll(unsigned long api, lua_State* L, const lua_Debug* ar, int n)
{
if (g_interfaces[api].lua_setlocal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setlocal_dll_cdecl(L, ar, n);
}
else
{
return g_interfaces[api].lua_setlocal_dll_stdcall(L, ar, n);
}
}
int lua_getstack_dll(unsigned long api, lua_State* L, int level, lua_Debug* ar)
{
if (g_interfaces[api].lua_getstack_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getstack_dll_cdecl(L, level, ar);
}
else
{
return g_interfaces[api].lua_getstack_dll_stdcall(L, level, ar);
}
}
void lua_insert_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_insert_dll_cdecl != NULL)
{
g_interfaces[api].lua_insert_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_insert_dll_stdcall(L, index);
}
}
void lua_pushnil_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_pushnil_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushnil_dll_cdecl(L);
}
else
{
g_interfaces[api].lua_pushnil_dll_stdcall(L);
}
}
void lua_pushcclosure_dll(unsigned long api, lua_State* L, lua_CFunction fn, int n)
{
if (g_interfaces[api].lua_pushcclosure_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushcclosure_dll_cdecl(L, fn, n);
}
else
{
g_interfaces[api].lua_pushcclosure_dll_stdcall(L, fn, n);
}
}
void lua_pushvalue_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_pushvalue_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushvalue_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_pushvalue_dll_stdcall(L, index);
}
}
void lua_pushnumber_dll(unsigned long api, lua_State* L, lua_Number value)
{
if (g_interfaces[api].lua_pushnumber_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushnumber_dll_cdecl(L, value);
}
else
{
g_interfaces[api].lua_pushnumber_dll_stdcall(L, value);
}
}
void lua_pushinteger_dll(unsigned long api, lua_State* L, int value)
{
if (g_interfaces[api].lua_pushinteger_dll_cdecl != NULL ||
g_interfaces[api].lua_pushinteger_dll_stdcall != NULL)
{
// Lua 5.0 version.
if (g_interfaces[api].lua_pushinteger_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pushinteger_dll_cdecl(L, value);
}
else
{
return g_interfaces[api].lua_pushinteger_dll_stdcall(L, value);
}
}
else
{
// Fallback to lua_pushnumber on Lua 4.0.
lua_pushnumber_dll(api, L, static_cast<lua_Number>(value));
}
}
void lua_pushlightuserdata_dll(unsigned long api, lua_State* L, void* p)
{
if (g_interfaces[api].lua_pushlightuserdata_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushlightuserdata_dll_cdecl(L, p);
}
else
{
g_interfaces[api].lua_pushlightuserdata_dll_stdcall(L, p);
}
}
const char* lua_tostring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL ||
g_interfaces[api].lua_tostring_dll_stdcall != NULL)
{
// Lua 4.0 implementation.
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tostring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tostring_dll_stdcall(L, index);
}
}
else
{
// Lua 5.0 version.
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tolstring_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tolstring_dll_stdcall(L, index, NULL);
}
}
}
const char* lua_tolstring_dll(unsigned long api, lua_State* L, int index, size_t* len)
{
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL ||
g_interfaces[api].lua_tolstring_dll_stdcall != NULL)
{
// Lua 5.0 version.
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tolstring_dll_cdecl(L, index, len);
}
else
{
return g_interfaces[api].lua_tolstring_dll_stdcall(L, index, len);
}
}
else
{
// Lua 4.0 implementation. lua_tolstring doesn't exist, so we just use lua_tostring
// and compute the length ourself. This means strings with embedded zeros doesn't work
// in Lua 4.0.
const char* string = NULL;
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL)
{
string = g_interfaces[api].lua_tostring_dll_cdecl(L, index);
}
else
{
string = g_interfaces[api].lua_tostring_dll_stdcall(L, index);
}
if (len)
{
if (string)
{
*len = strlen(string);
}
else
{
*len = 0;
}
}
return string;
}
}
int lua_toboolean_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_toboolean_dll_cdecl != NULL)
{
return g_interfaces[api].lua_toboolean_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_toboolean_dll_stdcall(L, index);
}
}
int lua_tointeger_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tointegerx_dll_cdecl != NULL ||
g_interfaces[api].lua_tointegerx_dll_stdcall != NULL)
{
// Lua 5.2 implementation.
if (g_interfaces[api].lua_tointegerx_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tointegerx_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tointegerx_dll_stdcall(L, index, NULL);
}
}
if (g_interfaces[api].lua_tointeger_dll_cdecl != NULL ||
g_interfaces[api].lua_tointeger_dll_stdcall != NULL)
{
// Lua 5.0 implementation.
if (g_interfaces[api].lua_tointeger_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tointeger_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tointeger_dll_stdcall(L, index);
}
}
else
{
// On Lua 4.0 fallback to lua_tonumber.
return static_cast<int>(lua_tonumber_dll(api, L, index));
}
}
lua_CFunction lua_tocfunction_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tocfunction_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tocfunction_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tocfunction_dll_stdcall(L, index);
}
}
lua_Number lua_tonumber_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tonumberx_dll_cdecl != NULL ||
g_interfaces[api].lua_tonumberx_dll_stdcall != NULL)
{
// Lua 5.2 implementation.
if (g_interfaces[api].lua_tonumberx_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tonumberx_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tonumberx_dll_stdcall(L, index, NULL);
}
}
// Lua 5.0 and earlier.
if (g_interfaces[api].lua_tonumber_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tonumber_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tonumber_dll_stdcall(L, index);
}
}
void* lua_touserdata_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_touserdata_dll_cdecl != NULL)
{
return g_interfaces[api].lua_touserdata_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_touserdata_dll_stdcall(L, index);
}
}
int lua_gettop_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_gettop_dll_cdecl != NULL)
{
return g_interfaces[api].lua_gettop_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_gettop_dll_stdcall(L);
}
}
int lua_loadbuffer_dll(unsigned long api, lua_State* L, const char* buffer, size_t size, const char* chunkname)
{
Memory memory;
memory.buffer = buffer;
memory.size = size;
if (g_interfaces[api].lua_load_dll_cdecl != NULL)
{
return g_interfaces[api].lua_load_dll_cdecl(L, MemoryReader_cdecl, &memory, chunkname);
}
else
{
return g_interfaces[api].lua_load_dll_stdcall(L, MemoryReader_stdcall, &memory, chunkname);
}
}
void lua_call_dll(unsigned long api, lua_State* L, int nargs, int nresults)
{
if (g_interfaces[api].lua_call_dll_cdecl != NULL)
{
return g_interfaces[api].lua_call_dll_cdecl(L, nargs, nresults);
}
else
{
return g_interfaces[api].lua_call_dll_stdcall(L, nargs, nresults);
}
}
int lua_pcallk_dll(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k)
{
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pcallk_dll_cdecl(L, nargs, nresults, errfunc, ctx, k);
}
else
{
return g_interfaces[api].lua_pcallk_dll_stdcall(L, nargs, nresults, errfunc, ctx, k);
}
}
int lua_pcall_dll(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc)
{
// Lua 5.2.
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL ||
g_interfaces[api].lua_pcallk_dll_stdcall != NULL)
{
return lua_pcallk_dll(api, L, nargs, nresults, errfunc, 0, NULL);
}
// Lua 5.1 and earlier.
if (g_interfaces[api].lua_pcall_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pcall_dll_cdecl(L, nargs, nresults, errfunc);
}
else
{
return g_interfaces[api].lua_pcall_dll_stdcall(L, nargs, nresults, errfunc);
}
}
void lua_newtable_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_newtable_dll_cdecl != NULL ||
g_interfaces[api].lua_newtable_dll_stdcall != NULL)
{
// Lua 4.0 implementation.
if (g_interfaces[api].lua_newtable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newtable_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_newtable_dll_stdcall(L);
}
}
else
{
// Lua 5.0 version.
if (g_interfaces[api].lua_createtable_dll_cdecl != NULL)
{
g_interfaces[api].lua_createtable_dll_cdecl(L, 0, 0);
}
else
{
g_interfaces[api].lua_createtable_dll_stdcall(L, 0, 0);
}
}
}
int lua_next_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_next_dll_cdecl != NULL)
{
return g_interfaces[api].lua_next_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_next_dll_stdcall(L, index);
}
}
int lua_rawequal_dll(unsigned long api, lua_State *L, int idx1, int idx2)
{
if (g_interfaces[api].lua_rawequal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_rawequal_dll_cdecl(L, idx1, idx2);
}
else
{
return g_interfaces[api].lua_rawequal_dll_stdcall(L, idx1, idx2);
}
}
int lua_getmetatable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_getmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getmetatable_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_getmetatable_dll_stdcall(L, index);
}
}
int lua_setmetatable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_setmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setmetatable_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_setmetatable_dll_stdcall(L, index);
}
}
int luaL_ref_dll(unsigned long api, lua_State *L, int t)
{
if (g_interfaces[api].luaL_ref_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_ref_dll_cdecl(L, t);
}
else if (g_interfaces[api].luaL_ref_dll_stdcall != NULL)
{
return g_interfaces[api].luaL_ref_dll_stdcall(L, t);
}
// We don't require that luaL_ref be present, so provide a suitable
// implementation if it's not.
return LUA_NOREF;
}
void luaL_unref_dll(unsigned long api, lua_State *L, int t, int ref)
{
if (g_interfaces[api].luaL_unref_dll_cdecl != NULL)
{
g_interfaces[api].luaL_unref_dll_cdecl(L, t, ref);
}
else if (g_interfaces[api].luaL_ref_dll_stdcall != NULL)
{
g_interfaces[api].luaL_unref_dll_stdcall(L, t, ref);
}
}
int luaL_newmetatable_dll(unsigned long api, lua_State *L, const char *tname)
{
if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_newmetatable_dll_cdecl(L, tname);
}
else
{
return g_interfaces[api].luaL_newmetatable_dll_stdcall(L, tname);
}
}
int luaL_loadbuffer_dll(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name)
{
if (g_interfaces[api].luaL_loadbuffer_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_loadbuffer_dll_cdecl(L, buff, sz, name);
}
else
{
return g_interfaces[api].luaL_loadbuffer_dll_stdcall(L, buff, sz, name);
}
}
int luaL_loadfile_dll(unsigned long api, lua_State* L, const char* fileName)
{
if (g_interfaces[api].luaL_loadfile_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_loadfile_dll_cdecl(L, fileName);
}
else
{
return g_interfaces[api].luaL_loadfile_dll_stdcall(L, fileName);
}
}
lua_State* luaL_newstate_dll(unsigned long api)
{
if (g_interfaces[api].luaL_newstate_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_newstate_dll_cdecl();
}
else
{
return g_interfaces[api].luaL_newstate_dll_stdcall();
}
}
const lua_WChar* lua_towstring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_towstring_dll_cdecl != NULL ||
g_interfaces[api].lua_towstring_dll_stdcall != NULL)
{
if (g_interfaces[api].lua_towstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_towstring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_towstring_dll_stdcall(L, index);
}
}
else
{
// The application is not using LuaPlus, so just return NULL.
return NULL;
}
}
int lua_iswstring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_iswstring_dll_cdecl != NULL ||
g_interfaces[api].lua_iswstring_dll_stdcall != NULL)
{
if (g_interfaces[api].lua_iswstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_iswstring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_iswstring_dll_stdcall(L, index);
}
}
else
{
// The application is not using LuaPlus, so just return 0.
return 0;
}
}
const char* lua_getupvalue_dll(unsigned long api, lua_State *L, int funcindex, int n)
{
if (g_interfaces[api].lua_getupvalue_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getupvalue_dll_cdecl(L, funcindex, n);
}
else
{
return g_interfaces[api].lua_getupvalue_dll_stdcall(L, funcindex, n);
}
}
const char* lua_setupvalue_dll(unsigned long api, lua_State *L, int funcindex, int n)
{
if (g_interfaces[api].lua_setupvalue_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setupvalue_dll_cdecl(L, funcindex, n);
}
else
{
return g_interfaces[api].lua_setupvalue_dll_stdcall(L, funcindex, n);
}
}
void lua_getfenv_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_getfenv_dll_cdecl != NULL)
{
g_interfaces[api].lua_getfenv_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_getfenv_dll_stdcall(L, index);
}
}
int lua_setfenv_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_setfenv_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setfenv_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_setfenv_dll_stdcall(L, index);
}
}
int lua_cpcall_dll(unsigned long api, lua_State *L, lua_CFunction func, void *ud)
{
if (g_interfaces[api].lua_cpcall_dll_cdecl != NULL)
{
return g_interfaces[api].lua_cpcall_dll_cdecl(L, func, ud);
}
else
{
return g_interfaces[api].lua_cpcall_dll_stdcall(L, func, ud);
}
}
HMODULE WINAPI LoadLibraryExW_intercept(LPCWSTR fileName, HANDLE hFile, DWORD dwFlags)
{
// We have to call the loader lock (if it is available) so that we don't get deadlocks
// in the case where Dll initialization acquires the loader lock and calls LoadLibrary
// while another thread is inside PostLoadLibrary.
ULONG cookie;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrLockLoaderLock_dll(0, 0, &cookie);
}
HMODULE hModule = LoadLibraryExW_dll(fileName, hFile, dwFlags);
if (hModule != NULL)
{
PostLoadLibrary(hModule);
}
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return hModule;
}
void FinishLoadingLua(unsigned long api, bool stdcall)
{
#define SET_STDCALL(function) \
if ( g_interfaces[api].function##_dll_cdecl != NULL) { \
g_interfaces[api].function##_dll_stdcall = reinterpret_cast<function##_stdcall_t>(g_interfaces[api].function##_dll_cdecl); \
g_interfaces[api].function##_dll_cdecl = NULL; \
}
if (g_interfaces[api].finishedLoading)
{
return;
}
g_interfaces[api].stdcall = stdcall;
if (stdcall)
{
SET_STDCALL(lua_newstate);
SET_STDCALL(lua_open);
SET_STDCALL(lua_open_500);
SET_STDCALL(lua_newstate);
SET_STDCALL(lua_newthread);
SET_STDCALL(lua_close);
SET_STDCALL(lua_error);
SET_STDCALL(lua_sethook);
SET_STDCALL(lua_getinfo);
SET_STDCALL(lua_remove);
SET_STDCALL(lua_settable);
SET_STDCALL(lua_gettable);
SET_STDCALL(lua_rawget);
SET_STDCALL(lua_rawgeti);
SET_STDCALL(lua_rawset);
SET_STDCALL(lua_pushstring);
SET_STDCALL(lua_pushlstring);
SET_STDCALL(lua_type);
SET_STDCALL(lua_typename);
SET_STDCALL(lua_settop);
SET_STDCALL(lua_gettop);
SET_STDCALL(lua_getlocal);
SET_STDCALL(lua_setlocal);
SET_STDCALL(lua_getstack);
SET_STDCALL(lua_insert);
SET_STDCALL(lua_pushnil);
SET_STDCALL(lua_pushvalue);
SET_STDCALL(lua_pushinteger);
SET_STDCALL(lua_pushnumber);
SET_STDCALL(lua_pushcclosure);
SET_STDCALL(lua_pushlightuserdata);
SET_STDCALL(lua_tostring);
SET_STDCALL(lua_tolstring);
SET_STDCALL(lua_toboolean);
SET_STDCALL(lua_tointeger);
SET_STDCALL(lua_tointegerx);
SET_STDCALL(lua_tocfunction);
SET_STDCALL(lua_tonumber);
SET_STDCALL(lua_tonumberx);
SET_STDCALL(lua_touserdata);
SET_STDCALL(lua_call);
SET_STDCALL(lua_callk);
SET_STDCALL(lua_pcall);
SET_STDCALL(lua_pcallk);
SET_STDCALL(lua_newtable);
SET_STDCALL(lua_createtable);
SET_STDCALL(lua_load);
SET_STDCALL(lua_next);
SET_STDCALL(lua_rawequal);
SET_STDCALL(lua_getmetatable);
SET_STDCALL(lua_setmetatable);
SET_STDCALL(luaL_ref);
SET_STDCALL(luaL_unref);
SET_STDCALL(luaL_newmetatable);
SET_STDCALL(luaL_loadbuffer);
SET_STDCALL(luaL_loadfile);
SET_STDCALL(lua_getupvalue);
SET_STDCALL(lua_setupvalue);
SET_STDCALL(lua_getfenv);
SET_STDCALL(lua_setfenv);
SET_STDCALL(lua_cpcall);
SET_STDCALL(lua_pushthread);
SET_STDCALL(lua_newuserdata);
SET_STDCALL(lua_pushthread);
SET_STDCALL(lua_checkstack);
}
g_interfaces[api].finishedLoading = true;
DebugBackend::Get().CreateApi(api);
}
#pragma auto_inline(off)
void lua_call_worker(unsigned long api, lua_State* L, int nargs, int nresults, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
int result;
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_call_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_call_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_call_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_call called with too few arguments on the stack", MessageType_Warning);
}
if (DebugBackend::Get().Call(api, L, nargs, nresults, 0))
{
lua_error_dll(api, L);
}
}
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_call_intercept(unsigned long api, lua_State* L, int nargs, int nresults)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_call_worker(api, L, nargs, nresults, stdcall);
INTERCEPT_EPILOG_NO_RETURN(12)
}
#pragma auto_inline(off)
void lua_callk_worker(unsigned long api, lua_State* L, int nargs, int nresults, int ctk, lua_CFunction k, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
int result;
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_callk_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void*)ctk, (void*)k, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_callk_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_callk_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_call called with too few arguments on the stack", MessageType_Warning);
}
if (DebugBackend::Get().Call(api, L, nargs, nresults, 0))
{
lua_error_dll(api, L);
}
}
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_callk_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int ctx, lua_CFunction k)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_callk_worker(api, L, nargs, nresults, ctx, k, stdcall);
INTERCEPT_EPILOG_NO_RETURN(20)
}
#pragma auto_inline(off)
int lua_pcall_worker(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_pcall_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void*)errfunc, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_pcall_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_pcall_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_pcall called with too few arguments on the stack", MessageType_Warning);
}
if (GetAreInterceptsEnabled())
{
result = DebugBackend::Get().Call(api, L, nargs, nresults, errfunc);
}
else
{
result = lua_pcall_dll(api, L, nargs, nresults, errfunc);
}
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_pcall_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_pcall_worker(api, L, nargs, nresults, errfunc, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int lua_pcallk_worker(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_pcall_dll_cdecl, (void*)L, (void*)nargs,
(void*)nresults, (void*)errfunc, (void*)ctx, (void*)k, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_pcallk_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_pcallk called with too few arguments on the stack", MessageType_Warning);
}
if (GetAreInterceptsEnabled())
{
result = DebugBackend::Get().Call(api, L, nargs, nresults, errfunc);
}
else
{
result = lua_pcallk_dll(api, L, nargs, nresults, errfunc, ctx, k);
}
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_pcallk_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_pcallk_worker(api, L, nargs, nresults, errfunc, ctx, k, stdcall);
INTERCEPT_EPILOG(24)
}
#pragma auto_inline(off)
lua_State* lua_newstate_worker(unsigned long api, lua_Alloc f, void* ud, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_newstate_dll_cdecl, (void*)f, ud, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_newstate_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_newstate_dll_cdecl(f, ud);
stdcall = false;
}
else if (g_interfaces[api].lua_newstate_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_newstate_dll_stdcall(f, ud);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_newstate_intercept(unsigned long api, lua_Alloc f, void* ud)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_newstate_worker(api, f, ud, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
lua_State* lua_newthread_worker(unsigned long api, lua_State* L, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_newthread_dll_cdecl, L, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_newthread_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_newthread_dll_cdecl(L);
stdcall = false;
}
else if (g_interfaces[api].lua_newthread_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_newthread_dll_stdcall(L);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_newthread_intercept(unsigned long api, lua_State* L)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_newthread_worker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
#pragma auto_inline(off)
lua_State* lua_open_worker(unsigned long api, int stacksize, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_open_dll_cdecl, (void*)stacksize, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_open_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_open_dll_cdecl(stacksize);
stdcall = false;
}
else if (g_interfaces[api].lua_open_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_open_dll_stdcall(stacksize);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
#pragma auto_inline(off)
lua_State* lua_open_500_worker(unsigned long api, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
// We can't test stdcall with the Lua 5.0 lua_open function since it doesn't
// take any arguments. To do the test, we create a dummy state and destroy it
// using the lua_close function to do the test.
lua_State* L = g_interfaces[api].lua_open_500_dll_cdecl();
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_close_dll_cdecl, (void*)L, (void**)&result);
FinishLoadingLua(api, stdcall);
}
if (g_interfaces[api].lua_open_500_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_open_500_dll_cdecl();
stdcall = false;
}
else if (g_interfaces[api].lua_open_500_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_open_500_dll_stdcall();
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_open_intercept(unsigned long api, int stacksize)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_open_worker(api, stacksize, stdcall);
INTERCEPT_EPILOG(4)
}
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_open_500_intercept(unsigned long api)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_open_500_worker(api, stdcall);
INTERCEPT_EPILOG(0)
}
#pragma auto_inline(off)
int lua_load_worker(unsigned long api, lua_State* L, lua_Reader reader, void* data, const char* name, bool& stdcall)
{
// If we haven't finished loading yet this will be wrong, but we'll fix it up
// when we access the reader function.
stdcall = (g_interfaces[api].lua_load_dll_stdcall != NULL);
// Read all of the data out of the reader and into a big buffer.
std::vector<char> buffer;
const char* chunk;
size_t chunkSize;
do
{
if (!g_interfaces[api].finishedLoading)
{
// In this case we must have attached the debugger so we're intercepting a lua_load
// function before we've initialized.
stdcall = GetIsStdCallConvention(reader, L, data, &chunkSize, (void**)&chunk);
FinishLoadingLua(api, stdcall);
}
else if (stdcall)
{
// We assume that since the lua_load function is stdcall the reader function is as well.
chunk = reinterpret_cast<lua_Reader_stdcall>(reader)(L, data, &chunkSize);
}
else
{
// We assume that since the lua_load function is cdecl the reader function is as well.
chunk = reader(L, data, &chunkSize);
}
// We allow the reader to return 0 for the chunk size since Lua supports
// that, although according to the manual it should return NULL to signal
// the end of the data.
if (chunk != NULL && chunkSize > 0)
{
buffer.insert(buffer.end(), chunk, chunk + chunkSize);
}
}
while (chunk != NULL && chunkSize > 0);
const char* source = NULL;
if (!buffer.empty())
{
source = &buffer[0];
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
// Disables JIT compilation if LuaJIT is being used. Otherwise we won't get hooks for
// this chunk.
if (DebugBackend::Get().EnableJit(api, L, false))
{
if (!g_warnedAboutJit)
{
DebugBackend::Get().Message("Warning 1007: Just-in-time compilation of Lua code disabled to allow debugging", MessageType_Warning);
g_warnedAboutJit = true;
}
}
int result = lua_loadbuffer_dll(api, L, source, buffer.size(), name);
if (!buffer.empty())
{
result = DebugBackend::Get().PostLoadScript(api, result, L, source, buffer.size(), name);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_load_intercept(unsigned long api, lua_State* L, lua_Reader reader, void* data, const char* name)
{
bool stdcall;
int result;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_load_worker(api, L, reader, data, name, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
void lua_close_worker(unsigned long api, lua_State* L, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_close_dll_cdecl, L, NULL);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_close_dll_cdecl != NULL)
{
g_interfaces[api].lua_close_dll_cdecl(L);
stdcall = false;
}
else if (g_interfaces[api].lua_close_dll_stdcall != NULL)
{
g_interfaces[api].lua_close_dll_stdcall(L);
stdcall = true;
}
DebugBackend::Get().DetachState(api, L);
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_close_intercept(unsigned long api, lua_State* L)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_close_worker(api, L, stdcall);
INTERCEPT_EPILOG_NO_RETURN(4)
}
#pragma auto_inline(off)
int luaL_newmetatable_worker(unsigned long api, lua_State *L, const char* tname, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_newmetatable_dll_cdecl, L, (void*)tname, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_newmetatable_dll_cdecl(L, tname);
stdcall = false;
}
else if (g_interfaces[api].luaL_newmetatable_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_newmetatable_dll_stdcall(L, tname);
stdcall = true;
}
if (result != 0)
{
// Only register if we haven't seen this name before.
DebugBackend::Get().RegisterClassName(api, L, tname, lua_gettop_dll(api, L));
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_newmetatable_intercept(unsigned long api, lua_State* L, const char* tname)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_newmetatable_worker(api, L, tname, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
int lua_sethook_worker(unsigned long api, lua_State *L, lua_Hook f, int mask, int count, bool& stdcall)
{
// Currently we're using the hook and can't let anyone else use it.
// What we should do is implement the lua hook on top of our existing hook.
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_sethook_dll_cdecl, L, f, (void*)mask, (void*)count, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].luaL_newmetatable_dll_stdcall != NULL)
{
stdcall = true;
}
// Note, the lua_hook call is currently bypassed.
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_sethook_intercept(unsigned long api, lua_State *L, lua_Hook f, int mask, int count)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_sethook_worker(api, L, f, mask, count, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int luaL_loadbuffer_worker(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name, bool& stdcall)
{
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_loadbuffer_dll_cdecl, L, (void*)buff, (void*)sz, (void*)name, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_loadbuffer_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_loadbuffer_dll_cdecl(L, buff, sz, name);
stdcall = false;
}
else if (g_interfaces[api].luaL_loadbuffer_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_loadbuffer_dll_stdcall(L, buff, sz, name);
stdcall = true;
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
return DebugBackend::Get().PostLoadScript(api, result, L, buff, sz, name);
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_loadbuffer_intercept(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_loadbuffer_worker(api, L, buff, sz, name, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int luaL_loadfile_worker(unsigned long api, lua_State *L, const char *fileName, bool& stdcall)
{
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_loadfile_dll_cdecl, L, (void*)fileName, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_loadfile_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_loadfile_dll_cdecl(L, fileName);
stdcall = false;
}
else if (g_interfaces[api].luaL_loadfile_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_loadfile_dll_stdcall(L, fileName);
stdcall = true;
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
// Load the file.
FILE* file = fopen(fileName, "rb");
if (file != NULL)
{
std::string name = "@";
name += fileName;
fseek(file, 0, SEEK_END);
unsigned int length = ftell(file);
char* buffer = new char[length];
fseek(file, 0, SEEK_SET);
fread(buffer, 1, length, file);
fclose(file);
result = DebugBackend::Get().PostLoadScript(api, result, L, buffer, length, name.c_str());
delete [] buffer;
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_loadfile_intercept(unsigned long api, lua_State *L, const char *fileName)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_loadfile_worker(api, L, fileName, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
lua_State* luaL_newstate_worker(unsigned long api, bool& stdcall)
{
lua_State* result = NULL;
if (g_interfaces[api].luaL_newstate_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_newstate_dll_cdecl();
}
else if (g_interfaces[api].luaL_newstate_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_newstate_dll_stdcall();
}
// Since we couldn't test if luaL_newstate was stdcall or cdecl (since it
// doesn't have any arguments), call another function. lua_gettop is a good
// choice since it has no side effects.
if (!g_interfaces[api].finishedLoading && result != NULL)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_gettop_dll_cdecl, result, NULL);
FinishLoadingLua(api, stdcall);
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* luaL_newstate_intercept(unsigned long api)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_newstate_worker(api, stdcall);
INTERCEPT_EPILOG(0)
}
std::string GetEnvironmentVariable(const std::string& name)
{
DWORD size = ::GetEnvironmentVariable(name.c_str(), NULL, 0);
std::string result;
if (size > 0)
{
char* buffer = new char[size];
buffer[0] = 0;
GetEnvironmentVariable(name.c_str(), buffer, size);
result = buffer;
delete [] buffer;
}
return result;
}
std::string GetApplicationDirectory()
{
char fileName[_MAX_PATH];
GetModuleFileNameEx(GetCurrentProcess(), NULL, fileName, _MAX_PATH);
char* term = strrchr(fileName, '\\');
if (term != NULL)
{
*term = 0;
}
return fileName;
}
bool LoadLuaFunctions(const stdext::hash_map<std::string, DWORD64>& symbols, HANDLE hProcess)
{
#define GET_FUNCTION_OPTIONAL(function) \
{ \
stdext::hash_map<std::string, DWORD64>::const_iterator iterator = symbols.find(#function); \
if (iterator != symbols.end()) \
{ \
luaInterface.function##_dll_cdecl = reinterpret_cast<function##_cdecl_t>(iterator->second); \
} \
}
#define GET_FUNCTION(function) \
GET_FUNCTION_OPTIONAL(function) \
if (luaInterface.function##_dll_cdecl == NULL) \
{ \
if (report) \
{ \
DebugBackend::Get().Message("Warning 1004: Couldn't hook Lua function '" #function "'", MessageType_Warning); \
} \
return false; \
}
#define HOOK_FUNCTION(function) \
if (luaInterface.function##_dll_cdecl != NULL) \
{ \
void* original = luaInterface.function##_dll_cdecl; \
luaInterface.function##_dll_cdecl = (function##_cdecl_t)(HookFunction(original, function##_intercept, api)); \
}
LuaInterface luaInterface = { 0 };
luaInterface.finishedLoading = false;
luaInterface.stdcall = false;
unsigned long api = g_interfaces.size();
bool report = false;
// Check if the lua_tag function exists. This function is only in Lua 4.0 and not in Lua 5.0.
// This helps us differentiate between those two versions.
luaInterface.registryIndex = 0;
luaInterface.globalsIndex = 0;
if (symbols.find("lua_tag") != symbols.end())
{
luaInterface.version = 401;
}
else
{
if (symbols.find("lua_open") != symbols.end())
{
luaInterface.version = 500;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10001;
}
else if (symbols.find("lua_callk") != symbols.end())
{
luaInterface.version = 520;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10001;
}
else
{
luaInterface.version = 510;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10002;
}
}
// Only present in Lua 4.0 and Lua 5.0 (not 5.1)
GET_FUNCTION_OPTIONAL(lua_open);
if (luaInterface.lua_open_dll_cdecl == NULL)
{
GET_FUNCTION(lua_newstate);
}
// Start reporting errors about functions we couldn't hook.
report = true;
GET_FUNCTION(lua_newthread);
GET_FUNCTION(lua_close);
GET_FUNCTION(lua_error);
GET_FUNCTION(lua_sethook);
GET_FUNCTION(lua_getinfo);
GET_FUNCTION(lua_remove);
GET_FUNCTION(lua_settable);
GET_FUNCTION(lua_gettable);
GET_FUNCTION(lua_rawget);
GET_FUNCTION(lua_rawgeti);
GET_FUNCTION(lua_rawset);
GET_FUNCTION(lua_pushstring);
GET_FUNCTION(lua_pushlstring);
GET_FUNCTION(lua_type);
GET_FUNCTION(lua_typename);
GET_FUNCTION(lua_settop);
GET_FUNCTION(lua_gettop);
GET_FUNCTION(lua_getlocal);
GET_FUNCTION(lua_setlocal);
GET_FUNCTION(lua_getstack);
GET_FUNCTION(lua_insert);
GET_FUNCTION(lua_pushnil);
GET_FUNCTION(lua_pushvalue);
GET_FUNCTION(lua_pushcclosure);
GET_FUNCTION(lua_pushnumber);
GET_FUNCTION(lua_pushlightuserdata);
GET_FUNCTION(lua_checkstack);
GET_FUNCTION(lua_gethookmask);
// Only present in Lua 5.1 (*number funtions used in Lua 4.0)
GET_FUNCTION_OPTIONAL(lua_pushinteger);
GET_FUNCTION_OPTIONAL(lua_tointeger);
GET_FUNCTION_OPTIONAL(lua_tointegerx);
// Only present in Lua 4.0 and 5.0 (exists as a macro in Lua 5.1)
GET_FUNCTION_OPTIONAL(lua_tostring);
if (luaInterface.lua_tostring_dll_cdecl == NULL)
{
GET_FUNCTION(lua_tolstring);
}
GET_FUNCTION_OPTIONAL(lua_tonumberx);
if (luaInterface.lua_tonumberx_dll_cdecl == NULL)
{
// If the Lua 5.2 tonumber isn't present, require the previous version.
GET_FUNCTION(lua_tonumber);
}
GET_FUNCTION(lua_toboolean);
GET_FUNCTION(lua_tocfunction);
GET_FUNCTION(lua_touserdata);
// Exists as a macro in Lua 5.2
GET_FUNCTION_OPTIONAL(lua_callk);
if (luaInterface.lua_callk_dll_cdecl == NULL)
{
GET_FUNCTION(lua_call);
}
// Exists as a macro in Lua 5.2
GET_FUNCTION_OPTIONAL(lua_pcallk);
if (luaInterface.lua_pcallk_dll_cdecl == NULL)
{
GET_FUNCTION(lua_pcall);
}
// Only present in Lua 4.0 and 5.0 (exists as a macro in Lua 5.1)
GET_FUNCTION_OPTIONAL(lua_newtable);
if (luaInterface.lua_newtable_dll_cdecl == NULL)
{
GET_FUNCTION(lua_createtable);
}
GET_FUNCTION(lua_load);
GET_FUNCTION(lua_next);
GET_FUNCTION(lua_rawequal);
GET_FUNCTION(lua_getmetatable);
GET_FUNCTION(lua_setmetatable);
GET_FUNCTION_OPTIONAL(luaL_ref);
GET_FUNCTION_OPTIONAL(luaL_unref);
GET_FUNCTION(luaL_newmetatable);
GET_FUNCTION(lua_getupvalue);
GET_FUNCTION(lua_setupvalue);
// We don't currently need these.
GET_FUNCTION_OPTIONAL(lua_getfenv);
GET_FUNCTION_OPTIONAL(lua_setfenv);
GET_FUNCTION_OPTIONAL(lua_cpcall);
if (luaInterface.version >= 510)
{
GET_FUNCTION(lua_pushthread);
}
else
{
// This function doesn't exist in Lua 5.0, so make it optional.
GET_FUNCTION_OPTIONAL(lua_pushthread);
}
GET_FUNCTION(lua_newuserdata);
// This function isn't strictly necessary. We only hook it
// in case the base function was inlined.
GET_FUNCTION_OPTIONAL(luaL_newstate);
GET_FUNCTION_OPTIONAL(luaL_loadbuffer);
GET_FUNCTION_OPTIONAL(luaL_loadfile);
// These functions only exists in LuaPlus.
GET_FUNCTION_OPTIONAL(lua_towstring);
GET_FUNCTION_OPTIONAL(lua_iswstring);
// Hook the functions we need to intercept calls to.
if (luaInterface.version == 500)
{
luaInterface.lua_open_500_dll_cdecl = reinterpret_cast<lua_open_500_cdecl_t>(luaInterface.lua_open_dll_cdecl);
luaInterface.lua_open_dll_cdecl = NULL;
}
HOOK_FUNCTION(lua_open);
HOOK_FUNCTION(lua_open_500);
HOOK_FUNCTION(lua_newstate);
HOOK_FUNCTION(lua_close);
HOOK_FUNCTION(lua_newthread);
HOOK_FUNCTION(lua_pcall);
HOOK_FUNCTION(lua_pcallk);
HOOK_FUNCTION(lua_call);
HOOK_FUNCTION(lua_callk);
HOOK_FUNCTION(lua_load);
HOOK_FUNCTION(luaL_newmetatable);
HOOK_FUNCTION(lua_sethook);
HOOK_FUNCTION(luaL_loadbuffer);
HOOK_FUNCTION(luaL_loadfile);
HOOK_FUNCTION(luaL_newstate);
#ifdef VERBOSE
DebugBackend::Get().Message("Found all necessary Lua functions");
#endif
// Setup our API.
luaInterface.DecodaOutput = (lua_CFunction)InstanceFunction(DecodaOutput, api);
luaInterface.CPCallHandler = (lua_CFunction)InstanceFunction(CPCallHandler, api);
luaInterface.HookHandler = (lua_Hook)InstanceFunction(HookHandler, api);
g_interfaces.push_back( luaInterface );
if (!g_loadedLuaFunctions)
{
DebugBackend::Get().Message("Debugger attached to process");
g_loadedLuaFunctions = true;
}
return true;
}
static PIMAGE_NT_HEADERS PEHeaderFromHModule(HMODULE hModule)
{
PIMAGE_NT_HEADERS pNTHeader = 0;
__try
{
if ( PIMAGE_DOS_HEADER(hModule)->e_magic != IMAGE_DOS_SIGNATURE )
__leave;
pNTHeader = PIMAGE_NT_HEADERS(PBYTE(hModule)
+ PIMAGE_DOS_HEADER(hModule)->e_lfanew);
if ( pNTHeader->Signature != IMAGE_NT_SIGNATURE )
pNTHeader = 0;
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
}
return pNTHeader;
}
/**
* Gets a list of the files that are imported by a module.
*/
bool GetModuleImports(HANDLE hProcess, HMODULE hModule, std::vector<std::string>& imports)
{
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule( hModule );
if ( !pExeNTHdr )
{
return false;
}
DWORD importRVA = pExeNTHdr->OptionalHeader.DataDirectory
[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
if ( !importRVA )
{
return false;
}
// Convert imports RVA to a usable pointer
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = MAKE_PTR( PIMAGE_IMPORT_DESCRIPTOR,
hModule, importRVA );
// Iterate through each import descriptor, and redirect if appropriate
while ( pImportDesc->FirstThunk )
{
PSTR pszImportModuleName = MAKE_PTR( PSTR, hModule, pImportDesc->Name);
imports.push_back(pszImportModuleName);
pImportDesc++; // Advance to next import descriptor
}
return true;
}
bool GetFileExists(const char* fileName)
{
return GetFileAttributes(fileName) != INVALID_FILE_ATTRIBUTES;
}
void ReplaceExtension(char fileName[_MAX_PATH], const char* extension)
{
char* start = strrchr(fileName, '.');
if (start == NULL)
{
strcat(fileName, extension);
}
else
{
strcpy(start + 1, extension);
}
}
void GetFileTitle(const char* fileName, char fileTitle[_MAX_PATH])
{
const char* slash1 = strrchr(fileName, '\\');
const char* slash2 = strrchr(fileName, '/');
const char* pathEnd = max(slash1, slash2);
if (pathEnd == NULL)
{
// There's no path so the whole thing is the file title.
strcpy(fileTitle, fileName);
}
else
{
strcpy(fileTitle, pathEnd + 1);
}
}
void GetFilePath(const char* fileName, char path[_MAX_PATH])
{
const char* slash1 = strrchr(fileName, '\\');
const char* slash2 = strrchr(fileName, '/');
const char* pathEnd = max(slash1, slash2);
if (pathEnd == NULL)
{
// There's no path on the file name.
path[0] = 0;
}
else
{
size_t length = pathEnd - fileName + 1;
memcpy(path, fileName, length);
path[length] = 0;
}
}
bool LocateSymbolFile(const IMAGEHLP_MODULE64& moduleInfo, char fileName[_MAX_PATH])
{
// The search order for symbol files is described here:
// http://msdn2.microsoft.com/en-us/library/ms680689.aspx
// This function doesn't currently support the full spec.
const char* imageFileName = moduleInfo.LoadedImageName;
// First check the absolute path specified in the CodeView data.
if (GetFileExists(moduleInfo.CVData))
{
strncpy(fileName, moduleInfo.CVData, _MAX_PATH);
return true;
}
char symbolTitle[_MAX_PATH];
GetFileTitle(moduleInfo.CVData, symbolTitle);
// Now check in the same directory as the image.
char imagePath[_MAX_PATH];
GetFilePath(imageFileName, imagePath);
strcat(imagePath, symbolTitle);
if (GetFileExists(imagePath))
{
strncpy(fileName, imagePath, _MAX_PATH);
return true;
}
return false;
}
BOOL CALLBACK GatherSymbolsCallback(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
stdext::hash_map<std::string, DWORD64>* symbols = reinterpret_cast<stdext::hash_map<std::string, DWORD64>*>(UserContext);
if (pSymInfo != NULL && pSymInfo->Name != NULL)
{
symbols->insert(std::make_pair(pSymInfo->Name, pSymInfo->Address));
}
return TRUE;
}
BOOL CALLBACK FindSymbolsCallback(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
bool* found = reinterpret_cast<bool*>(UserContext);
*found = true;
return FALSE;
}
bool ScanForSignature(DWORD64 start, DWORD64 length, const char* signature)
{
unsigned int signatureLength = strlen(signature);
for (DWORD64 i = start; i < start + length - signatureLength; ++i)
{
void* p = reinterpret_cast<void*>(i);
// Check that we have read access to the data. For some reason under Windows
// Vista part of the DLL is not accessible (possibly some sort of new delay
// loading mechanism for DLLs?)
if (IsBadReadPtr(reinterpret_cast<LPCSTR>(p), signatureLength))
{
break;
}
if (memcmp(p, signature, signatureLength) == 0)
{
return true;
}
}
return false;
}
void LoadSymbolsRecursively(std::set<std::string>& loadedModules, stdext::hash_map<std::string, DWORD64>& symbols, HANDLE hProcess, HMODULE hModule)
{
assert(hModule != NULL);
char moduleName[_MAX_PATH];
GetModuleBaseName(hProcess, hModule, moduleName, _MAX_PATH);
if (loadedModules.find(moduleName) == loadedModules.end())
{
// Record that we've loaded this module so that we don't
// try to load it again.
loadedModules.insert(moduleName);
MODULEINFO moduleInfo = { 0 };
GetModuleInformation(hProcess, hModule, &moduleInfo, sizeof(moduleInfo));
char moduleFileName[_MAX_PATH];
GetModuleFileNameEx(hProcess, hModule, moduleFileName, _MAX_PATH);
DWORD64 base = SymLoadModule64_dll(hProcess, NULL, moduleFileName, moduleName, (DWORD64)moduleInfo.lpBaseOfDll, moduleInfo.SizeOfImage);
#ifdef VERBOSE
char message[1024];
_snprintf(message, 1024, "Examining '%s' %s\n", moduleName, base ? "(symbols loaded)" : "");
DebugBackend::Get().Log(message);
#endif
// Check to see if there was a symbol file we failed to load (usually
// becase it didn't match the version of the module).
IMAGEHLP_MODULE64 module;
memset(&module, 0, sizeof(module));
module.SizeOfStruct = sizeof(module);
BOOL result = SymGetModuleInfo64_dll(hProcess, base, &module);
if (result && module.SymType == SymNone)
{
// No symbols were found. Check to see if the module file name + ".pdb"
// exists, since the symbol file and/or module names may have been renamed.
char pdbFileName[_MAX_PATH];
strcpy(pdbFileName, moduleFileName);
ReplaceExtension(pdbFileName, "pdb");
if (GetFileExists(pdbFileName))
{
SymUnloadModule64_dll(hProcess, base);
base = SymLoadModule64_dll(hProcess, NULL, pdbFileName, moduleName, (DWORD64)moduleInfo.lpBaseOfDll, moduleInfo.SizeOfImage);
if (base != 0)
{
result = SymGetModuleInfo64_dll(hProcess, base, &module);
}
else
{
result = FALSE;
}
}
}
if (result)
{
// Check to see if we've already warned about this module.
if (g_warnedAboutPdb.find(moduleFileName) == g_warnedAboutPdb.end())
{
if (strlen(module.CVData) > 0 && (module.SymType == SymExport || module.SymType == SymNone))
{
char symbolFileName[_MAX_PATH];
if (LocateSymbolFile(module, symbolFileName))
{
char message[1024];
_snprintf(message, 1024, "Warning 1002: Symbol file '%s' located but it does not match module '%s'", symbolFileName, moduleFileName);
DebugBackend::Get().Message(message, MessageType_Warning);
}
// Remember that we've checked on this file, so no need to check again.
g_warnedAboutPdb.insert(moduleFileName);
}
}
}
if (base != 0)
{
// SymFromName is really slow, so we gather up our own list of the symbols that we
// can index much faster.
SymEnumSymbols_dll(hProcess, base, "lua*", GatherSymbolsCallback, reinterpret_cast<PVOID>(&symbols));
}
// Check to see if the module contains the Lua signature but we didn't find any Lua functions.
if (g_warnedAboutLua.find(moduleFileName) == g_warnedAboutLua.end())
{
// Check to see if this module contains any Lua functions loaded from the symbols.
bool foundLuaFunctions = false;
if (base != 0)
{
SymEnumSymbols_dll(hProcess, base, "lua_*", FindSymbolsCallback, &foundLuaFunctions);
}
if (!foundLuaFunctions)
{
// Check to see if this module contains a string from the Lua source code. If it's there, it probably
// means this module has Lua compiled into it.
bool luaFile = ScanForSignature((DWORD64)hModule, moduleInfo.SizeOfImage, "$Lua:");
if (luaFile)
{
char message[1024];
_snprintf(message, 1024, "Warning 1001: '%s' appears to contain Lua functions however no Lua functions could located with the symbolic information", moduleFileName);
DebugBackend::Get().Message(message, MessageType_Warning);
}
}
// Remember that we've checked on this file, so no need to check again.
g_warnedAboutLua.insert(moduleFileName);
}
// Get the imports for the module. These are loaded before we're able to hook
// LoadLibrary for the module.
std::vector<std::string> imports;
GetModuleImports(hProcess, hModule, imports);
for (unsigned int i = 0; i < imports.size(); ++i)
{
HMODULE hImportModule = GetModuleHandle(imports[i].c_str());
// Sometimes the import module comes back NULL, which means that for some reason
// it wasn't loaded. Perhaps these are delay loaded and we'll catch them later?
if (hImportModule != NULL)
{
LoadSymbolsRecursively(loadedModules, symbols, hProcess, hImportModule);
}
}
}
}
BOOL CALLBACK SymbolCallbackFunction(HANDLE hProcess, ULONG code, ULONG64 data, ULONG64 UserContext)
{
if (code == CBA_DEBUG_INFO)
{
DebugBackend::Get().Message(reinterpret_cast<char*>(data));
}
return TRUE;
}
void PostLoadLibrary(HMODULE hModule)
{
extern HINSTANCE g_hInstance;
if (hModule == g_hInstance)
{
// Don't investigate ourself.
return;
}
HANDLE hProcess = GetCurrentProcess();
char moduleName[_MAX_PATH];
GetModuleBaseName(hProcess, hModule, moduleName, _MAX_PATH);
CriticalSectionLock lock(g_loadedModulesCriticalSection);
if (g_loadedModules.find(moduleName) == g_loadedModules.end())
{
// Record that we've loaded this module so that we don't
// try to load it again.
g_loadedModules.insert(moduleName);
if (!g_initializedDebugHelp)
{
if (!SymInitialize_dll(hProcess, g_symbolsDirectory.c_str(), FALSE))
{
return;
}
g_initializedDebugHelp = true;
}
//SymSetOptions(SYMOPT_DEBUG);
std::set<std::string> loadedModules;
stdext::hash_map<std::string, DWORD64> symbols;
LoadSymbolsRecursively(loadedModules, symbols, hProcess, hModule);
LoadLuaFunctions(symbols, hProcess);
//SymCleanup_dll(hProcess);
//hProcess = NULL;
}
}
void HookLoadLibrary()
{
HMODULE hModuleKernel = GetModuleHandle("kernel32.dll");
if (hModuleKernel != NULL)
{
// LoadLibraryExW is called by the other LoadLibrary functions, so we
// only need to hook it.
LoadLibraryExW_dll = (LoadLibraryExW_t) HookFunction( GetProcAddress(hModuleKernel, "LoadLibraryExW"), LoadLibraryExW_intercept);
}
// These NTDLL functions are undocumented and don't exist in Windows 2000.
HMODULE hModuleNt = GetModuleHandle("ntdll.dll");
if (hModuleNt != NULL)
{
LdrLockLoaderLock_dll = (LdrLockLoaderLock_t) GetProcAddress(hModuleNt, "LdrLockLoaderLock");
LdrUnlockLoaderLock_dll = (LdrUnlockLoaderLock_t) GetProcAddress(hModuleNt, "LdrUnlockLoaderLock");
}
}
bool InstallLuaHooker(HINSTANCE hInstance, const char* symbolsDirectory)
{
// Load the dbghelp functions. We have to do this dynamically since the
// older version of dbghelp that ships with Windows doesn't successfully
// load the symbols from PDBs. We can't simply include our new DLL since
// it needs to be in the directory for the application we're *debugging*
// since this DLL is injected.
if (!LoadDebugHelp(hInstance))
{
return false;
}
g_symbolsDirectory = symbolsDirectory;
// Add the "standard" stuff to the symbols directory search path.
g_symbolsDirectory += ";" + GetApplicationDirectory();
g_symbolsDirectory += ";" + GetEnvironmentVariable("_NT_SYMBOL_PATH");
g_symbolsDirectory += ";" + GetEnvironmentVariable("_NT_ALTERNATE_SYMBOL_PATH");
// Hook LoadLibrary* functions so that we can intercept those calls and search
// for Lua functions.
HookLoadLibrary();
// Avoid deadlock if a new DLL is loaded during this function.
ULONG cookie;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrLockLoaderLock_dll(0, 0, &cookie);
}
// Process all of the loaded modules.
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);
if (hSnapshot == NULL)
{
// If for some reason we couldn't take a snapshot, just load the
// main module. This shouldn't ever happen, but we do it just in
// case.
HMODULE hModule = GetModuleHandle(NULL);
PostLoadLibrary(hModule);
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return true;
}
MODULEENTRY32 module;
module.dwSize = sizeof(MODULEENTRY32);
BOOL moreModules = Module32First(hSnapshot, &module);
while (moreModules)
{
PostLoadLibrary(module.hModule);
moreModules = Module32Next(hSnapshot, &module);
}
CloseHandle(hSnapshot);
hSnapshot = NULL;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return true;
}
bool GetIsLuaLoaded()
{
return g_loadedLuaFunctions;
}
bool GetIsStdCall(unsigned long api)
{
return g_interfaces[api].stdcall;
}
struct CFunctionArgs
{
unsigned long api;
lua_CFunction_dll function;
};
#pragma auto_inline(off)
int CFunctionHandlerWorker(CFunctionArgs* args, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[args->api].stdcall;
return args->function(args->api, L);
}
#pragma auto_inline()
__declspec(naked) int CFunctionHandler(CFunctionArgs* args, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
stdcall = false;
result = CFunctionHandlerWorker(args, L, stdcall);
INTERCEPT_EPILOG(4)
}
lua_CFunction CreateCFunction(unsigned long api, lua_CFunction_dll function)
{
// This is never deallocated, but it doesn't really matter since we never
// destroy these functions.
CFunctionArgs* args = new CFunctionArgs;
args->api = api;
args->function = function;
return (lua_CFunction)InstanceFunction(CFunctionHandler, reinterpret_cast<unsigned long>(args));
}
| 31.534209
| 185
| 0.63523
|
KoSukeWork
|
de0b01b7a122dc6a5665f7aa8c2ea7043f687258
| 1,065
|
cpp
|
C++
|
backends/mysql/factory.cpp
|
staticlibs/lookaside_soci
|
b3326cff7d4cf2dc122179eb8b988f2521944550
|
[
"BSL-1.0"
] | null | null | null |
backends/mysql/factory.cpp
|
staticlibs/lookaside_soci
|
b3326cff7d4cf2dc122179eb8b988f2521944550
|
[
"BSL-1.0"
] | null | null | null |
backends/mysql/factory.cpp
|
staticlibs/lookaside_soci
|
b3326cff7d4cf2dc122179eb8b988f2521944550
|
[
"BSL-1.0"
] | null | null | null |
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// MySQL backend copyright (C) 2006 Pawel Aleksander Fedorynski
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_MYSQL_SOURCE
#include "soci-mysql.h"
#include <backend-loader.h>
#include <ciso646>
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace soci;
using namespace soci::details;
// concrete factory for MySQL concrete strategies
mysql_session_backend * mysql_backend_factory::make_session(
connection_parameters const & parameters) const
{
return new mysql_session_backend(parameters);
}
mysql_backend_factory const soci::mysql;
extern "C"
{
// for dynamic backend loading
SOCI_MYSQL_DECL backend_factory const * factory_mysql()
{
return &soci::mysql;
}
SOCI_MYSQL_DECL void register_factory_mysql()
{
soci::dynamic_backends::register_backend("mysql", soci::mysql);
}
} // extern "C"
| 23.152174
| 68
| 0.728638
|
staticlibs
|
de12667519ef6601b38b263514b401342e376889
| 384
|
cpp
|
C++
|
CP-Algorithms/Algebra/3_Number-theoretic functions/N_2_spoj_DIVSUM - Divisor Summation.cpp
|
Sowmik23/All-Codes
|
212ef0d940fa84624bb2972a257768a830a709a3
|
[
"MIT"
] | 5
|
2021-02-14T17:48:21.000Z
|
2022-01-24T14:29:44.000Z
|
CP-Algorithms/Algebra/3_Number-theoretic functions/N_2_spoj_DIVSUM - Divisor Summation.cpp
|
Sowmik23/All-Codes
|
212ef0d940fa84624bb2972a257768a830a709a3
|
[
"MIT"
] | null | null | null |
CP-Algorithms/Algebra/3_Number-theoretic functions/N_2_spoj_DIVSUM - Divisor Summation.cpp
|
Sowmik23/All-Codes
|
212ef0d940fa84624bb2972a257768a830a709a3
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mx = 5e6+1;
ll ans[mx];
void D(int n){
ll sum = 0;
for(int i=1;i*i<=n;i++){
if(n%i==0){
sum+=i;
if(n/i!=i) sum+=(n/i);
}
}
ans[n] =sum;
}
int main(){
int t, n;
scanf("%d", &t);
while(t--){
scanf("%d", &n);
if(ans[n]==0) D(n);
printf("%lld\n", ans[n]-n);
}
return 0;
}
| 10.666667
| 29
| 0.484375
|
Sowmik23
|
de1512531606f78f11f625dbbea6669b2579e2e4
| 1,843
|
cpp
|
C++
|
CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp
|
Zemurin/CK2ToEU4
|
f28971fb877497cc4117689d1600a8721466c365
|
[
"MIT"
] | 3
|
2020-05-06T21:50:00.000Z
|
2022-03-15T19:16:19.000Z
|
CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp
|
Zemurin/CK2ToEU4
|
f28971fb877497cc4117689d1600a8721466c365
|
[
"MIT"
] | 3
|
2022-02-01T19:35:02.000Z
|
2022-03-02T17:34:16.000Z
|
CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp
|
Zemurin/CK2ToEU4
|
f28971fb877497cc4117689d1600a8721466c365
|
[
"MIT"
] | 1
|
2020-05-06T21:50:04.000Z
|
2020-05-06T21:50:04.000Z
|
#include "BuildTriggerBuilder.h"
#include "CommonRegexes.h"
#include "ParserHelpers.h"
#include <iomanip>
mappers::BuildTriggerBuilder::BuildTriggerBuilder()
{
registerKeys();
clearRegisteredKeywords();
}
mappers::BuildTriggerBuilder::BuildTriggerBuilder(std::istream& theStream)
{
registerKeys();
parseStream(theStream);
clearRegisteredKeywords();
buildTrigger += "\n\t}";
}
void mappers::BuildTriggerBuilder::registerKeys()
{
registerKeyword("religious_groups", [this](const std::string& mods, std::istream& theStream) {
const auto& groups = commonItems::stringList(theStream).getStrings();
for (auto& group: groups)
{
buildTrigger += ("AND = {\n\t\t\t\treligion_group = " + group + "\n\t\t\t\thas_owner_religion = yes\n\t\t\t}\n\t\t");
}
});
registerKeyword("cultural_groups", [this](const std::string& mods, std::istream& theStream) {
const auto& groups = commonItems::stringList(theStream).getStrings();
for (auto& group: groups)
{
buildTrigger += ("AND = {\n\t\t\t\tculture_group = " + group + "\n\t\t\t\thas_owner_culture = yes\n\t\t\t}\n\t\t");
}
});
registerKeyword("cultural", [this](const std::string& mods, std::istream& theStream) {
cultural = commonItems::getString(theStream).find("yes") != std::string::npos;
});
registerKeyword("religious", [this](const std::string& mods, std::istream& theStream) {
religious = commonItems::getString(theStream).find("yes") != std::string::npos;
});
registerKeyword("other", [this](const std::string& mods, std::istream& theStream) {
auto tempInput = commonItems::stringOfItem(theStream).getString();
tempInput = tempInput.substr(tempInput.find('{') + 1, tempInput.length());
tempInput = tempInput.substr(0, tempInput.find_last_of('}'));
buildTrigger += tempInput;
});
registerRegex(commonItems::catchallRegex, commonItems::ignoreItem);
}
| 37.612245
| 120
| 0.708627
|
Zemurin
|
de1762591476a9ae30810597e9db0c6e6f0d2d72
| 3,001
|
hpp
|
C++
|
include/paal/greedy/knapsack_unbounded_two_app.hpp
|
Kommeren/AA
|
e537b58d50e93d4a72709821b9ea413008970c6b
|
[
"BSL-1.0"
] | null | null | null |
include/paal/greedy/knapsack_unbounded_two_app.hpp
|
Kommeren/AA
|
e537b58d50e93d4a72709821b9ea413008970c6b
|
[
"BSL-1.0"
] | null | null | null |
include/paal/greedy/knapsack_unbounded_two_app.hpp
|
Kommeren/AA
|
e537b58d50e93d4a72709821b9ea413008970c6b
|
[
"BSL-1.0"
] | 1
|
2021-02-24T06:23:56.000Z
|
2021-02-24T06:23:56.000Z
|
//=======================================================================
// Copyright (c) 2013 Piotr Wygocki
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
/**
* @file knapsack_unbounded_two_app.hpp
* @brief
* @author Piotr Wygocki
* @version 1.0
* @date 2013-10-07
*/
#ifndef PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
#define PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
#include "paal/utils/accumulate_functors.hpp"
#include "paal/utils/type_functions.hpp"
#include "paal/greedy/knapsack/knapsack_greedy.hpp"
#include <boost/iterator/counting_iterator.hpp>
#include <boost/iterator/filter_iterator.hpp>
#include <type_traits>
#include <utility>
namespace paal {
namespace detail {
template <typename KnapsackData,
typename ObjectIter = typename KnapsackData::object_iter,
typename Size = typename KnapsackData::size,
typename Value = typename KnapsackData::value>
std::tuple<Value, Size,
std::pair<ObjectIter, unsigned>>
get_greedy_fill(KnapsackData knap_data, unbounded_tag) {
auto density = knap_data.get_density();
auto most_dense_iter = max_element_functor(
knap_data.get_objects(), density).base();
unsigned nr = knap_data.get_capacity() / knap_data.get_size(*most_dense_iter);
Value value_sum = Value(nr) * knap_data.get_value(*most_dense_iter);
Size size_sum = Size (nr) * knap_data.get_size (*most_dense_iter);
return std::make_tuple(value_sum, size_sum,
std::make_pair(most_dense_iter, nr));
}
template <typename ObjectsIterAndNr, typename OutputIter>
void greedy_to_output(ObjectsIterAndNr most_dense_iter_and_nr, OutputIter & out,
unbounded_tag) {
auto nr = most_dense_iter_and_nr.second;
auto most_dense_iter = most_dense_iter_and_nr.first;
for (unsigned i = 0; i < nr; ++i) {
*out = *most_dense_iter;
++out;
}
}
} //! detail
///this version of algorithm might permute, the input range
template <typename OutputIterator, typename Objects,
typename ObjectSizeFunctor, typename ObjectValueFunctor,
//this enable if assures that range can be permuted
typename std::enable_if<!detail::is_range_const<Objects>::value>::type * = nullptr>
typename detail::knapsack_base<Objects, ObjectSizeFunctor,
ObjectValueFunctor>::return_type
knapsack_unbounded_two_app(
Objects && objects,
typename detail::FunctorOnRangePValue<ObjectSizeFunctor, Objects> capacity,
OutputIterator out, ObjectValueFunctor value, ObjectSizeFunctor size) {
return detail::knapsack_general_two_app(
detail::make_knapsack_data(std::forward<Objects>(objects), capacity, size, value, out),
detail::unbounded_tag{});
}
} //! paal
#endif // PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
| 37.049383
| 99
| 0.682439
|
Kommeren
|
de186757d5f211e9eefcc8284dab4f7f0f29630d
| 1,920
|
hpp
|
C++
|
include/clotho/cuda/sampling/random_sample_sequence.hpp
|
putnampp/clotho
|
6dbfd82ef37b4265381cd78888cd6da8c61c68c2
|
[
"ECL-2.0",
"Apache-2.0"
] | 3
|
2015-06-16T21:27:57.000Z
|
2022-01-25T23:26:54.000Z
|
include/clotho/cuda/sampling/random_sample_sequence.hpp
|
putnampp/clotho
|
6dbfd82ef37b4265381cd78888cd6da8c61c68c2
|
[
"ECL-2.0",
"Apache-2.0"
] | 3
|
2015-06-16T21:12:42.000Z
|
2015-06-23T12:41:00.000Z
|
include/clotho/cuda/sampling/random_sample_sequence.hpp
|
putnampp/clotho
|
6dbfd82ef37b4265381cd78888cd6da8c61c68c2
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
// Copyright 2015 Patrick Putnam
//
// 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 RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
#define RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
#include "clotho/cuda/sampling/random_sample_def.hpp"
#include "clotho/cuda/data_spaces/sequence_space/device_sequence_space.hpp"
#include "clotho/cuda/data_spaces/basic_data_space.hpp"
template < class StateType, class IntType, class IntType2 = unsigned int >
__global__ void random_sample( StateType * states
, device_sequence_space< IntType > * src
, unsigned int N
, basic_data_space< IntType2 > * index_space ) {
typedef StateType state_type;
unsigned int tid = threadIdx.y * blockDim.x + threadIdx.x;
state_type local_state = states[ tid ];
IntType2 M = src->seq_count;
if( tid == 0 ) {
_resize_space_impl( index_space, N );
}
__syncthreads();
unsigned int i = tid;
unsigned int * ids = index_space->data;
unsigned int tpb = blockDim.x * blockDim.y;
while( i < N ) {
float x = curand_uniform( &local_state );
IntType2 pidx = (IntType2)(x * M);
pidx = ((pidx >= M) ? 0 : pidx); // wrap around indexes
ids[ i ] = pidx;
i += tpb;
}
states[tid] = local_state;
}
#endif // RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
| 32.542373
| 80
| 0.657292
|
putnampp
|
de1b873ac8cff20111a6c634b943f4765b8106c7
| 1,964
|
hpp
|
C++
|
modules/trustchain/include/Tanker/Trustchain/Actions/UserGroupAddition.hpp
|
TankerHQ/sdk-native
|
5d9eb7c2048fdefae230590a3110e583f08c2c49
|
[
"Apache-2.0"
] | 19
|
2018-12-05T12:18:02.000Z
|
2021-07-13T07:33:22.000Z
|
modules/trustchain/include/Tanker/Trustchain/Actions/UserGroupAddition.hpp
|
TankerHQ/sdk-native
|
5d9eb7c2048fdefae230590a3110e583f08c2c49
|
[
"Apache-2.0"
] | 3
|
2020-03-16T15:52:06.000Z
|
2020-08-01T11:14:30.000Z
|
modules/trustchain/include/Tanker/Trustchain/Actions/UserGroupAddition.hpp
|
TankerHQ/sdk-native
|
5d9eb7c2048fdefae230590a3110e583f08c2c49
|
[
"Apache-2.0"
] | 3
|
2020-01-07T09:55:32.000Z
|
2020-08-01T01:29:28.000Z
|
#pragma once
#include <Tanker/Crypto/Hash.hpp>
#include <Tanker/Crypto/PrivateSignatureKey.hpp>
#include <Tanker/Crypto/Signature.hpp>
#include <Tanker/Serialization/SerializedSource.hpp>
#include <Tanker/Trustchain/Actions/Nature.hpp>
#include <Tanker/Trustchain/Actions/UserGroupAddition/v1.hpp>
#include <Tanker/Trustchain/Actions/UserGroupAddition/v2.hpp>
#include <Tanker/Trustchain/Actions/UserGroupAddition/v3.hpp>
#include <Tanker/Trustchain/GroupId.hpp>
#include <Tanker/Trustchain/Preprocessor/Actions/Json.hpp>
#include <Tanker/Trustchain/Preprocessor/Actions/Serialization.hpp>
#include <Tanker/Trustchain/Preprocessor/Actions/VariantImplementation.hpp>
#include <Tanker/Trustchain/UserId.hpp>
#include <boost/variant2/variant.hpp>
#include <nlohmann/json_fwd.hpp>
#include <cstddef>
#include <cstdint>
#include <utility>
#include <vector>
namespace Tanker
{
namespace Trustchain
{
namespace Actions
{
#define TANKER_TRUSTCHAIN_ACTIONS_USER_GROUP_ADDITION_ATTRIBUTES \
(trustchainId, TrustchainId), (groupId, GroupId), \
(previousGroupBlockHash, Crypto::Hash), \
(selfSignature, Crypto::Signature), (author, Crypto::Hash), \
(signature, Crypto::Signature)
class UserGroupAddition
{
TANKER_TRUSTCHAIN_ACTION_VARIANT_IMPLEMENTATION(
UserGroupAddition,
(UserGroupAddition1, UserGroupAddition2, UserGroupAddition3),
TANKER_TRUSTCHAIN_ACTIONS_USER_GROUP_ADDITION_ATTRIBUTES)
public:
using v1 = UserGroupAddition1;
using v2 = UserGroupAddition2;
using v3 = UserGroupAddition3;
Nature nature() const;
std::vector<std::uint8_t> signatureData() const;
};
// The nature is not present in the wired payload.
// Therefore there is no from_serialized overload for UserGroupAddition.
std::uint8_t* to_serialized(std::uint8_t*, UserGroupAddition const&);
std::size_t serialized_size(UserGroupAddition const&);
void to_json(nlohmann::json&, UserGroupAddition const&);
}
}
}
| 31.677419
| 75
| 0.775458
|
TankerHQ
|
de1bc3d98cf3febde5e05f2ab8b3ce6f4fabfdc4
| 2,739
|
cpp
|
C++
|
src/ssd/NVM_Transaction_Flash.cpp
|
rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference
|
61546ccbae3ecd4312757cb54ac9af5a0d01e9ae
|
[
"MIT"
] | null | null | null |
src/ssd/NVM_Transaction_Flash.cpp
|
rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference
|
61546ccbae3ecd4312757cb54ac9af5a0d01e9ae
|
[
"MIT"
] | null | null | null |
src/ssd/NVM_Transaction_Flash.cpp
|
rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference
|
61546ccbae3ecd4312757cb54ac9af5a0d01e9ae
|
[
"MIT"
] | null | null | null |
#include "NVM_Transaction_Flash.h"
#include "assert.h"
namespace SSD_Components
{
NVM_Transaction_Flash::NVM_Transaction_Flash(
Transaction_Source_Type source,
Transaction_Type type,
stream_id_type stream_id,
unsigned int data_size_in_byte,
LPA_type lpa,
PPA_type ppa,
User_Request* user_request):
NVM_Transaction(
stream_id,
source,
type,
user_request),
Data_and_metadata_size_in_byte(data_size_in_byte),
Physical_address_determined(false),
FLIN_Barrier(false)
{
LPAs.push_back (lpa);
PPAs.push_back (ppa);
}
NVM_Transaction_Flash::NVM_Transaction_Flash(
Transaction_Source_Type source,
Transaction_Type type,
stream_id_type stream_id,
unsigned int data_size_in_byte,
LPA_type lpa,
PPA_type ppa,
const NVM::FlashMemory::Physical_Page_Address& address,
User_Request* user_request) :
NVM_Transaction(
stream_id,
source,
type,
user_request),
Data_and_metadata_size_in_byte(data_size_in_byte),
Address(address),
Physical_address_determined(false)
{
LPAs.push_back (lpa);
PPAs.push_back (ppa);
}
//FGM - LPAs
unsigned int NVM_Transaction_Flash::num_lpas ()
{
return LPAs.size ();
}
LPA_type NVM_Transaction_Flash::get_lpa ()
{
if (!LPAs.empty()) return LPAs[0];
}
LPA_type NVM_Transaction_Flash::get_lpa (int idx)
{
if (!LPAs.empty()) return LPAs[idx];
}
void NVM_Transaction_Flash::set_lpa (LPA_type lpa)
{
if (!LPAs.empty()) LPAs.push_back (lpa);
else LPAs[0] = lpa;
}
void NVM_Transaction_Flash::set_lpa (LPA_type lpa, int idx)
{
assert(LPAs.size() >= idx);
if (LPAs.empty()) LPAs.push_back(lpa);
else LPAs[idx] = lpa;
}
//FGM - PPAs
unsigned int NVM_Transaction_Flash::num_ppas ()
{
return PPAs.size ();
}
PPA_type NVM_Transaction_Flash::get_ppa ()
{
if (!PPAs.empty()) return PPAs[0];
}
PPA_type NVM_Transaction_Flash::get_ppa (int idx)
{
if (!PPAs.empty()) return PPAs[idx];
}
void NVM_Transaction_Flash::set_ppa (PPA_type ppa)
{
if (!PPAs.empty()) PPAs.push_back (ppa);
else PPAs[0] = ppa;
}
void NVM_Transaction_Flash::set_ppa (PPA_type ppa, int idx)
{
assert(PPAs.size() >= idx);
if (PPAs.empty()) PPAs.push_back (ppa);
else PPAs[idx] = ppa;
}
//FGM - LPAs for GC
void NVM_Transaction_Flash::replace_lpa(LPA_type lpa, int idx, int i)
{
assert(!LPAs.empty());
LPAs.erase ( LPAs.begin() + idx );
LPAs.insert( LPAs.begin()+ idx, lpa);
Waiting_LPAs.erase( Waiting_LPAs.begin() + i );
}
void NVM_Transaction_Flash:: set_waiting_lpas (LPA_type lpa)
{
Waiting_LPAs.push_back(lpa);
}
LPA_type NVM_Transaction_Flash:: get_waiting_lpas (int idx)
{
assert(!Waiting_LPAs.empty());
return Waiting_LPAs[idx];
}
}
| 22.08871
| 70
| 0.700256
|
rakeshnadig
|
de1cad88979b70e2929438d25bd08990d0b61807
| 571
|
cpp
|
C++
|
Hackerrank/Ice Cream Parlor.cpp
|
SurgicalSteel/Competitive-Programming
|
3662b676de94796f717b25dc8d1b93c6851fb274
|
[
"MIT"
] | 14
|
2016-02-11T09:26:13.000Z
|
2022-03-27T01:14:29.000Z
|
Hackerrank/Ice Cream Parlor.cpp
|
SurgicalSteel/Competitive-Programming
|
3662b676de94796f717b25dc8d1b93c6851fb274
|
[
"MIT"
] | null | null | null |
Hackerrank/Ice Cream Parlor.cpp
|
SurgicalSteel/Competitive-Programming
|
3662b676de94796f717b25dc8d1b93c6851fb274
|
[
"MIT"
] | 7
|
2016-10-25T19:29:35.000Z
|
2021-12-05T18:31:39.000Z
|
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int tc,m,n,temp;
scanf("%d",&tc);
for(int i=0;i<tc;i++)
{
vector<int> v;
cin>>m>>n;
for(int x=0;x<n;x++)
{
cin>>temp;
v.push_back(temp);
}
for(int x=0;x<v.size();x++)
{
for(int y=x+1;y<v.size();y++)
{
if(v[x]+v[y]==m)
printf("%d %d\n",x+1,y+1);
}
}
}
return 0;
}
| 19.033333
| 42
| 0.401051
|
SurgicalSteel
|
de1d06e0de9697325f3340fbd3fbeb80b7bd7893
| 499
|
cpp
|
C++
|
app/src/main/cpp/src/meshes/sphere.cpp
|
danielesteban/GLTest
|
62f9e45adc1073d3d8ad5072266dc8a353f6e421
|
[
"MIT"
] | 3
|
2018-01-01T14:27:29.000Z
|
2019-01-20T03:14:41.000Z
|
app/src/main/cpp/src/meshes/sphere.cpp
|
danielesteban/GLTest
|
62f9e45adc1073d3d8ad5072266dc8a353f6e421
|
[
"MIT"
] | null | null | null |
app/src/main/cpp/src/meshes/sphere.cpp
|
danielesteban/GLTest
|
62f9e45adc1073d3d8ad5072266dc8a353f6e421
|
[
"MIT"
] | null | null | null |
#include "sphere.hpp"
void Sphere::init(btDiscreteDynamicsWorld *world, Model *model, const btVector3 position) {
Mesh::init(world, model, position, btQuaternion(0.0f, 0.0f, 0.0f, 1.0f), btScalar(5.0f));
albedo = glm::vec4(
(float) rand() / (float) RAND_MAX,
(float) rand() / (float) RAND_MAX,
(float) rand() / (float) RAND_MAX,
1.0f
);
}
void Sphere::render(const Camera *camera) {
glUniform4fv(model->shader->albedo, 1, glm::value_ptr(albedo));
Mesh::render(camera);
}
| 29.352941
| 91
| 0.661323
|
danielesteban
|
de20076bcede28ced3262762f5efb7d754b21b9f
| 2,441
|
cpp
|
C++
|
ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp
|
emengdeath/acmcode
|
cc1b0e067464e754d125856004a991d6eb92a2cd
|
[
"MIT"
] | null | null | null |
ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp
|
emengdeath/acmcode
|
cc1b0e067464e754d125856004a991d6eb92a2cd
|
[
"MIT"
] | null | null | null |
ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp
|
emengdeath/acmcode
|
cc1b0e067464e754d125856004a991d6eb92a2cd
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<algorithm>
#include<cstdio>
#define N 1000000
using namespace std;
int f[N][2],size[N];
int n,tot;
int g[N],d[N],a[N][4],fa[N],b[N];
struct node{
int x,l,r;
}c[N];
int sum;
void ins(int x,int y){
a[++sum][0]=y,a[sum][1]=g[x],g[x]=sum;
}
void dfs(int x){
size[x]=1;
for (int i=g[x];i;i=a[i][1])
dfs(a[i][0]),size[x]+=size[a[i][0]];
d[0]=0;
for (int i=g[x];i;i=a[i][1])
d[++d[0]]=i;
f[x][0]=f[x][1]=0;
while (d[0]){
int v=f[x][0];
int i=d[d[0]--];
if (f[a[i][0]][0]>=f[a[i][0]][1])a[i][2]=0;
else
a[i][2]=1;
f[x][0]=f[x][0]+max(f[a[i][0]][0],f[a[i][0]][1]);
if (f[x][1]+max(f[a[i][0]][0],f[a[i][0]][1])>=v+f[a[i][0]][0]+1){
if (f[a[i][0]][0]>=f[a[i][0]][1])
a[i][3]=0;
else
a[i][3]=1;
}else
a[i][3]=2;
f[x][1]=max(f[x][1]+max(f[a[i][0]][0],f[a[i][0]][1]),v+f[a[i][0]][0]+1);
}
}
void dfs1(int x,int y){
if (!g[x])return;
for (int i=g[x];i;i=a[i][1]){
if (y){
if (a[i][3]==0){
b[++b[0]]=a[i][0],dfs1(a[i][0],0);
}else
if (a[i][3]==1){
dfs1(a[i][0],1);
}else
y=0,dfs1(a[i][0],0);
}else{
if (a[i][2]==0)b[++b[0]]=a[i][0],dfs1(a[i][0],0);
else
dfs1(a[i][0],1);
}
}
}
bool cmp(const node&a,const node&b){
return a.r-a.l>b.r-b.l;
}
void update(int x,int y){
ins(x,y);
fa[y]=x;
}
int main(){
freopen("hidden.in","r",stdin);
freopen("hidden.out","w",stdout);
scanf("%d",&n);
for (int i=2;i<=n;i++){
scanf("%d",&fa[i]);
if (fa[i])
ins(fa[i],i);
}
c[++tot].x=1;
c[tot].l=b[0]+1;
dfs(1);
if (f[1][0]>=f[1][1])b[++b[0]]=1,dfs1(1,0);
else
dfs1(1,1);
c[tot].r=b[0];
for (int i=2;i<=n;i++)
if (!fa[i]){
dfs(i);
if (f[i][1]*2==size[i]){
update(1,i);
continue;
}
c[++tot].x=i;
c[tot].l=b[0]+1;
b[++b[0]]=i;
for (int j=g[i];j;j=a[j][1]){
dfs(a[j][0]);
if (f[a[j][0]][0]>=f[a[j][0]][1])b[++b[0]]=a[j][0],dfs1(a[j][0],0);
else
dfs1(a[j][0],1);
}
c[tot].r=b[0];
}
sort(c+2,c+tot+1,cmp);
int l=1;
d[0]=0;
for (int i=c[1].l;i<=c[1].r;i++)
d[++d[0]]=b[i];
for (int i=2;i<=tot;i++){
if (l<=d[0]){
update(d[l],c[i].x);
l++;
for (int j=c[i].l+1;j<=c[i].r;j++)
d[++d[0]]=b[j];
}else{
update(1,c[i].x);
d[++d[0]]=c[i].x;
swap(d[l],d[d[0]]);
for (int j=c[i].l+1;j<=c[i].r;j++)
d[++d[0]]=b[j];
}
}
dfs(1);
printf("%d\n",max(f[1][1],f[1][0]));
printf("%d",fa[2]);
for (int i=3;i<=n;i++)
printf(" %d",fa[i]);
return 0;
}
| 19.373016
| 74
| 0.436706
|
emengdeath
|
de24e400710212eb9a22f123a370205a326213a9
| 1,424
|
cpp
|
C++
|
src/States/Menu/MainMenu.cpp
|
BertilBraun/MyClone
|
9573084e9a561b91995683ba016088174414a545
|
[
"MIT"
] | 4
|
2019-01-10T18:39:53.000Z
|
2022-01-15T21:38:28.000Z
|
src/States/Menu/MainMenu.cpp
|
BOTOrtwin/MyClone
|
9573084e9a561b91995683ba016088174414a545
|
[
"MIT"
] | 14
|
2018-09-30T21:48:35.000Z
|
2018-10-05T08:46:40.000Z
|
src/States/Menu/MainMenu.cpp
|
BOTOrtwin/MyClone
|
9573084e9a561b91995683ba016088174414a545
|
[
"MIT"
] | 1
|
2019-12-23T19:35:54.000Z
|
2019-12-23T19:35:54.000Z
|
#include "MainMenu.h"
#include "Utils/ToggleKey.h"
#include "Application.h"
#include "MenuWorldSelect.h"
MainMenu::MainMenu(Application& applic) :
StateBase(applic),
background(glm::vec2(0.5f, 0.5f), glm::vec2(1, 1), "GUI/background.jpg", (*app->getWindow()))
{
buttons.emplace_back(glm::vec2(0.5f, 0.4f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "PLAY", (*app->getWindow()), [&] { app->pushState<MenuWorldSelect>(*app); });
buttons.emplace_back(glm::vec2(0.5f, 0.5f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "OPTIONS NA", (*app->getWindow()));
buttons.emplace_back(glm::vec2(0.5f, 0.6f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "QUIT", (*app->getWindow()), [&] { app->popState(); });
}
MainMenu::~MainMenu()
{
}
void MainMenu::handleInput(float deltaTime, const Camera & camera)
{
}
void MainMenu::update(float deltaTime) {
for (Button& button : buttons)
button.pressed((*app->getWindow()));
}
void MainMenu::render(MasterRenderer & renderer) {
background.draw(renderer);
for (Button& button : buttons)
button.draw(renderer);
}
void MainMenu::onOpen() {
const sf::RenderWindow& window = (*app->getWindow());
sf::Mouse::setPosition(sf::Vector2i(sf::Vector2f(window.getSize()) / 2.0f), window);
app->turnOnMouse();
updateCamera = false;
}
void MainMenu::onResume() {
app->turnOnMouse();
updateCamera = false;
for (Button& button : buttons)
button.resetButton();
}
| 27.921569
| 172
| 0.67486
|
BertilBraun
|
de27a6c8f9bbc73849ed220220a0e518f1332b0c
| 10,225
|
cpp
|
C++
|
OpenGL3DRendering/src/Renderer/Renderer.cpp
|
Sarius587/OpenGL3DRendering
|
fb87593a2c36c473ae5665fba6f16cfb55461b21
|
[
"Apache-2.0"
] | 1
|
2020-06-01T06:35:39.000Z
|
2020-06-01T06:35:39.000Z
|
OpenGL3DRendering/src/Renderer/Renderer.cpp
|
Sarius587/OpenGL3DRendering
|
fb87593a2c36c473ae5665fba6f16cfb55461b21
|
[
"Apache-2.0"
] | null | null | null |
OpenGL3DRendering/src/Renderer/Renderer.cpp
|
Sarius587/OpenGL3DRendering
|
fb87593a2c36c473ae5665fba6f16cfb55461b21
|
[
"Apache-2.0"
] | null | null | null |
#include "oglpch.h"
#include "Renderer.h"
#include "RendererAPI.h"
#include "Framebuffer.h"
namespace OpenGLRendering {
struct MeshInfo
{
Ref<VertexArray> VertexArray;
Ref<Material> Material;
glm::mat4 ModelMatrix;
};
struct RendererData
{
Ref<Camera> Camera;
Ref<Cubemap> Cubemap;
Ref<Shader> PBRShaderTextured;
Ref<Shader> PBRShader;
Ref<Shader> CubemapShader;
Ref<Shader> ColorGradingShader;
Ref<Shader> InvertColorShader;
Ref<Framebuffer> MultisampleFramebuffer;
Ref<Framebuffer> IntermediateFramebuffer;
Ref<Framebuffer> FinalFramebuffer;
std::vector<MeshInfo> Meshes;
LightInfo LightInfo;
Ref<VertexArray> QuadVertexArray;
bool RenderedToFinalBuffer;
RendererStats Stats;
};
static RendererData s_RendererData;
void Renderer::Init()
{
s_RendererData.PBRShaderTextured = CreateRef<Shader>("src/Resources/ShaderSource/PBR/vertex_textured_pbr.glsl", "src/Resources/ShaderSource/PBR/fragment_textured_pbr.glsl");
s_RendererData.PBRShader = CreateRef<Shader>("src/Resources/ShaderSource/PBR/vertex_static_pbr.glsl", "src/Resources/ShaderSource/PBR/fragment_static_pbr.glsl");
s_RendererData.CubemapShader = CreateRef<Shader>("src/Resources/ShaderSource/Cubemap/background_vertex.glsl", "src/Resources/ShaderSource/Cubemap/background_fragment.glsl");
s_RendererData.ColorGradingShader = CreateRef<Shader>("src/Resources/ShaderSource/PostProcessing/color_grading_vertex.glsl", "src/Resources/ShaderSource/PostProcessing/color_grading_fragment.glsl");
s_RendererData.InvertColorShader = CreateRef<Shader>("src/Resources/ShaderSource/PostProcessing/color_invert_vertex.glsl", "src/Resources/ShaderSource/PostProcessing/color_invert_fragment.glsl");
float quadVertices[] =
{
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
};
uint32_t quadIndices[] =
{
0, 1, 2,
0, 2, 3,
};
s_RendererData.QuadVertexArray = CreateRef<VertexArray>();
Ref<VertexBuffer> vb = CreateRef<VertexBuffer>(quadVertices, 5 * 4 * 4);
vb->SetLayout(
{
{ ShaderDataType::Float3, "a_Position" },
{ ShaderDataType::Float2, "a_TexCoords" },
});
Ref<IndexBuffer> ib = CreateRef<IndexBuffer>(quadIndices, 6);
s_RendererData.QuadVertexArray->AddVertexBuffer(vb);
s_RendererData.QuadVertexArray->SetIndexBuffer(ib);
FramebufferSettings settings = { 1920, 1080, true, true, 8 };
s_RendererData.MultisampleFramebuffer = CreateRef<Framebuffer>(settings);
settings = { 1920, 1080 };
s_RendererData.IntermediateFramebuffer = CreateRef<Framebuffer>(settings);
s_RendererData.FinalFramebuffer = CreateRef<Framebuffer>(settings);
}
void Renderer::OnResize(uint32_t width, uint32_t height)
{
s_RendererData.MultisampleFramebuffer->Resize(width, height);
s_RendererData.IntermediateFramebuffer->Resize(width, height);
s_RendererData.FinalFramebuffer->Resize(width, height);
}
void Renderer::BeginScene(Ref<Camera>& camera, Ref<Cubemap>& cubemap, const LightInfo& lightInfo)
{
s_RendererData.Camera = camera;
s_RendererData.Cubemap = cubemap;
s_RendererData.LightInfo = lightInfo;
s_RendererData.Stats.VertexCount = 0;
s_RendererData.Stats.FaceCount = 0;
s_RendererData.Stats.DrawCalls = 0;
s_RendererData.RenderedToFinalBuffer = false;
}
void Renderer::EndScene()
{
s_RendererData.MultisampleFramebuffer->Bind();
RendererAPI::Clear();
s_RendererData.Cubemap->BindIrradianceMap(0);
s_RendererData.Cubemap->BindPrefilterMap(1);
s_RendererData.Cubemap->BindBrdfLutTexture(2);
for (const MeshInfo& mesh : s_RendererData.Meshes)
{
if (mesh.Material->IsUsingTextures())
{
s_RendererData.PBRShaderTextured->Bind();
s_RendererData.PBRShaderTextured->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.PBRShaderTextured->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.PBRShaderTextured->SetMat4("u_Model", mesh.ModelMatrix);
s_RendererData.PBRShaderTextured->SetFloat3("u_LightPos", s_RendererData.LightInfo.LightPos);
s_RendererData.PBRShaderTextured->SetFloat3("u_LightColor", s_RendererData.LightInfo.LightColor);
s_RendererData.PBRShaderTextured->SetFloat3("u_CameraPos", s_RendererData.Camera->GetPosition());
s_RendererData.PBRShaderTextured->SetInt("u_IrradianceMap", 0);
s_RendererData.PBRShaderTextured->SetInt("u_PrefilterMap", 1);
s_RendererData.PBRShaderTextured->SetInt("u_BrdfLutTexture", 2);
const std::unordered_map<TextureType, Ref<Texture2D>>& textures = mesh.Material->GetTextures();
if (textures.find(TextureType::ALBEDO) != textures.end())
{
textures.at(TextureType::ALBEDO)->Bind(3);
s_RendererData.PBRShaderTextured->SetInt("u_TextureAlbedo", 3);
}
if (textures.find(TextureType::NORMAL) != textures.end())
{
textures.at(TextureType::NORMAL)->Bind(4);
s_RendererData.PBRShaderTextured->SetInt("u_TextureNormal", 4);
}
if (textures.find(TextureType::METALLIC_SMOOTHNESS) != textures.end())
{
textures.at(TextureType::METALLIC_SMOOTHNESS)->Bind(5);
s_RendererData.PBRShaderTextured->SetInt("u_TextureMetallicSmooth", 5);
}
if (textures.find(TextureType::AMBIENT_OCCLUSION) != textures.end())
{
textures.at(TextureType::AMBIENT_OCCLUSION)->Bind(6);
s_RendererData.PBRShaderTextured->SetInt("u_TextureAmbient", 6);
}
RendererAPI::DrawIndexed(mesh.VertexArray, 0);
s_RendererData.Stats.DrawCalls += 1;
}
else
{
s_RendererData.PBRShader->Bind();
s_RendererData.PBRShader->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.PBRShader->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.PBRShader->SetMat4("u_Model", mesh.ModelMatrix);
s_RendererData.PBRShader->SetFloat3("u_LightPos", s_RendererData.LightInfo.LightPos);
s_RendererData.PBRShader->SetFloat3("u_LightColor", s_RendererData.LightInfo.LightColor);
s_RendererData.PBRShader->SetFloat3("u_CameraPos", s_RendererData.Camera->GetPosition());
s_RendererData.PBRShader->SetInt("u_IrradianceMap", 0);
s_RendererData.PBRShader->SetInt("u_PrefilterMap", 1);
s_RendererData.PBRShader->SetInt("u_BrdfLutTexture", 2);
s_RendererData.PBRShader->SetFloat3("u_Albedo", mesh.Material->GetAlbedo());
s_RendererData.PBRShader->SetFloat("u_Roughness", mesh.Material->GetRoughness());
s_RendererData.PBRShader->SetFloat("u_Metallic", mesh.Material->GetMetallic());
s_RendererData.PBRShader->SetFloat("u_Ambient", mesh.Material->GetAmbientOcclusion());
RendererAPI::DrawIndexed(mesh.VertexArray, 0);
s_RendererData.Stats.DrawCalls += 1;
}
}
s_RendererData.Cubemap->BindEnvironmentMap(0);
s_RendererData.CubemapShader->Bind();
s_RendererData.CubemapShader->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.CubemapShader->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.CubemapShader->SetInt("u_EnvironmentMap", 0);
RendererAPI::DrawIndexed(s_RendererData.Cubemap->GetVertexArray(), 0);
s_RendererData.Stats.DrawCalls += 1;
s_RendererData.Meshes.clear();
RendererAPI::BlitFramebuffer(s_RendererData.MultisampleFramebuffer, s_RendererData.IntermediateFramebuffer);
}
void Renderer::Submit(Ref<Mesh>& mesh, const glm::mat4& modelMatrix)
{
s_RendererData.Meshes.push_back({ mesh->GetVertexArray(), mesh->GetMaterial(), modelMatrix });
s_RendererData.Stats.VertexCount += mesh->GetVertexCount();
s_RendererData.Stats.FaceCount += mesh->GetFaceCount();
}
void Renderer::Submit(Ref<Model>& model, uint16_t lod, uint16_t meshesPerLod)
{
for (unsigned int i = lod * meshesPerLod; i < (lod + 1) * meshesPerLod && i < model->GetMeshes().size(); i++)
{
const Mesh& mesh = model->GetMeshes()[i];
s_RendererData.Meshes.push_back({ mesh.GetVertexArray(), mesh.GetMaterial(), model->GetModelMatrix() });
s_RendererData.Stats.VertexCount += mesh.GetVertexCount();
s_RendererData.Stats.FaceCount += mesh.GetFaceCount();
}
}
void Renderer::Submit(Ref<Model>& model)
{
for (const Mesh& mesh : model->GetMeshes())
{
s_RendererData.Meshes.push_back({ mesh.GetVertexArray(), mesh.GetMaterial(), model->GetModelMatrix() });
s_RendererData.Stats.VertexCount += mesh.GetVertexCount();
s_RendererData.Stats.FaceCount += mesh.GetFaceCount();
}
}
void Renderer::ColorGrade(const glm::vec4& color)
{
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.IntermediateFramebuffer->Bind();
else
s_RendererData.FinalFramebuffer->Bind();
RendererAPI::Clear();
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.FinalFramebuffer->BindColorTexture(0);
else
s_RendererData.IntermediateFramebuffer->BindColorTexture(0);
s_RendererData.ColorGradingShader->Bind();
s_RendererData.ColorGradingShader->SetInt("u_Frame", 0);
s_RendererData.ColorGradingShader->SetFloat4("u_GradingColor", color);
RendererAPI::DrawIndexed(s_RendererData.QuadVertexArray, 0);
s_RendererData.RenderedToFinalBuffer = !s_RendererData.RenderedToFinalBuffer;
s_RendererData.FinalFramebuffer->Unbind();
}
void Renderer::InvertColor()
{
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.IntermediateFramebuffer->Bind();
else
s_RendererData.FinalFramebuffer->Bind();
RendererAPI::Clear();
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.FinalFramebuffer->BindColorTexture(0);
else
s_RendererData.IntermediateFramebuffer->BindColorTexture(0);
s_RendererData.InvertColorShader->Bind();
s_RendererData.InvertColorShader->SetInt("u_Frame", 0);
RendererAPI::DrawIndexed(s_RendererData.QuadVertexArray, 0);
s_RendererData.RenderedToFinalBuffer = !s_RendererData.RenderedToFinalBuffer;
s_RendererData.FinalFramebuffer->Unbind();
}
const RendererStats& Renderer::GetStatistics()
{
return s_RendererData.Stats;
}
uint32_t Renderer::GetFrameTextureId()
{
return s_RendererData.RenderedToFinalBuffer ? s_RendererData.FinalFramebuffer->GetColorTextureId() : s_RendererData.IntermediateFramebuffer->GetColorTextureId();
}
}
| 36.3879
| 200
| 0.757653
|
Sarius587
|
de2e81e9973c5234f6acbefde666cdf584e596e1
| 6,211
|
cc
|
C++
|
src/STP.cc
|
VadimNvr/SDN_RunOS
|
74df09f78f8672f144a283823b24de3106f8e419
|
[
"Apache-2.0"
] | null | null | null |
src/STP.cc
|
VadimNvr/SDN_RunOS
|
74df09f78f8672f144a283823b24de3106f8e419
|
[
"Apache-2.0"
] | null | null | null |
src/STP.cc
|
VadimNvr/SDN_RunOS
|
74df09f78f8672f144a283823b24de3106f8e419
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright 2015 Applied Research Center for Computer Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "STP.hh"
#include "Topology.hh"
REGISTER_APPLICATION(STP, {"switch-manager", "link-discovery", "topology", ""})
void SwitchSTP::computeSTP()
{
parent->computePathForSwitch(this->sw->id());
}
void SwitchSTP::resetBroadcast()
{
for (auto port : ports) {
if (port.second->to_switch)
unsetBroadcast(port.second->port_no);
}
}
void SwitchSTP::setSwitchPort(uint32_t port_no, uint64_t dpid)
{
ports.at(port_no)->to_switch = true;
ports.at(port_no)->nextSwitch = parent->switch_list[dpid];
}
void STP::init(Loader* loader, const Config& config)
{
QObject* ld = ILinkDiscovery::get(loader);
connect(ld, SIGNAL(linkDiscovered(switch_and_port, switch_and_port)),
this, SLOT(onLinkDiscovered(switch_and_port, switch_and_port)));
connect(ld, SIGNAL(linkBroken(switch_and_port, switch_and_port)),
this, SLOT(onLinkBroken(switch_and_port, switch_and_port)));
SwitchManager* sw = SwitchManager::get(loader);
connect(sw, &SwitchManager::switchDiscovered, this, &STP::onSwitchDiscovered);
connect(sw, &SwitchManager::switchDown, this, &STP::onSwitchDown);
topo = Topology::get(loader);
}
STPPorts STP::getSTP(uint64_t dpid)
{
std::vector<uint32_t> ports;
if (switch_list.count(dpid) == 0) {
return ports;
}
SwitchSTP* sw = switch_list[dpid];
if (!sw->computed) {
return ports;
}
for (auto port : sw->ports) {
if (port.second->broadcast)
ports.push_back(port.second->port_no);
}
return ports;
}
void STP::onLinkDiscovered(switch_and_port from, switch_and_port to)
{
if (switch_list.count(from.dpid) == 0)
return;
if (switch_list.count(to.dpid) == 0)
return;
SwitchSTP* sw = switch_list[from.dpid];
if (!sw->existsPort(from.port)) {
Port* port = new Port(from.port);
sw->ports[from.port] = port;
}
if (!sw->root)
sw->unsetBroadcast(from.port);
sw->setSwitchPort(from.port, to.dpid);
sw = switch_list[to.dpid];
if (!sw->existsPort(to.port)) {
Port* port = new Port(to.port);
sw->ports[to.port] = port;
}
if (!sw->root)
sw->unsetBroadcast(to.port);
sw->setSwitchPort(to.port, from.dpid);
// recompute pathes for all switches
for (auto ss : switch_list) {
if (!ss.second->root)
ss.second->computed = false;
}
}
void STP::onLinkBroken(switch_and_port from, switch_and_port to)
{
// recompute pathes for all switches
for (auto ss : switch_list) {
if (!ss.second->root)
ss.second->computed = false;
}
}
void STP::onSwitchDiscovered(Switch* dp)
{
SwitchSTP* sw;
if (switch_list.empty())
sw = new SwitchSTP(dp, this, true, true);
else
sw = new SwitchSTP(dp, this);
switch_list[dp->id()] = sw;
connect(dp, &Switch::portUp, this, &STP::onPortUp);
connect(sw->timer, SIGNAL(timeout()), sw, SLOT(computeSTP()));
sw->timer->start(POLL_TIMEOUT * 1000);
}
void STP::onSwitchDown(Switch* dp)
{
if (switch_list.count(dp->id()) > 0) {
SwitchSTP* sw = switch_list[dp->id()];
sw->timer->stop();
switch_list.erase(dp->id());
delete sw;
}
}
void STP::onPortUp(Switch *dp, of13::Port port)
{
if (switch_list.count(dp->id()) > 0) {
SwitchSTP* sw = switch_list[dp->id()];
if ( !sw->existsPort(port.port_no()) && port.port_no() < of13::OFPP_MAX ) {
Port* p = new Port(port.port_no());
sw->ports[port.port_no()] = p;
}
}
}
SwitchSTP* STP::findRoot()
{
for (auto it : switch_list) {
if (it.second->root)
return it.second;
}
return nullptr;
}
void STP::computePathForSwitch(uint64_t dpid)
{
static std::mutex compute;
if (!switch_list[dpid]->computed) {
SwitchSTP* root = findRoot();
if (root == nullptr) {
LOG(ERROR) << "Root switch not found!";
SwitchSTP* sw = switch_list[dpid];
sw->root = true;
sw->computed = true;
return;
}
SwitchSTP* sw = switch_list[dpid];
std::vector<uint32_t> old_broadcast = getSTP(dpid);
compute.lock();
sw->resetBroadcast();
data_link_route route = topo->computeRoute(dpid, root->sw->id());
if (route.size() > 0) {
uint32_t broadcast_port = route[0].port;
if (sw->existsPort(broadcast_port))
sw->setBroadcast(broadcast_port);
sw->nextSwitchToRoot = switch_list[route[1].dpid];
// getting broadcast port on second switch
data_link_route r_route = topo->computeRoute(route[1].dpid, dpid);
SwitchSTP* r_sw = switch_list[r_route[0].dpid];
uint32_t r_broadcast_port = r_route[0].port;
if (r_sw->existsPort(r_broadcast_port))
r_sw->setBroadcast(r_broadcast_port);
for (auto port : sw->ports) {
if (port.second->to_switch) {
if (port.second->nextSwitch->nextSwitchToRoot == sw) {
sw->setBroadcast(port.second->port_no);
}
}
}
if (getSTP(dpid).size() == old_broadcast.size())
sw->computed = true;
} else {
LOG(WARNING) << "Path between " << FORMAT_DPID << dpid
<< " and root switch " << FORMAT_DPID << root->sw->id() << " not found";
}
compute.unlock();
}
}
| 28.62212
| 88
| 0.596844
|
VadimNvr
|
de31df2261416a611d50658fdd5be19ba732839f
| 30,008
|
hpp
|
C++
|
src/libraries/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.hpp
|
MrAwesomeRocks/caelus-cml
|
55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7
|
[
"mpich2"
] | null | null | null |
src/libraries/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.hpp
|
MrAwesomeRocks/caelus-cml
|
55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7
|
[
"mpich2"
] | null | null | null |
src/libraries/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.hpp
|
MrAwesomeRocks/caelus-cml
|
55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7
|
[
"mpich2"
] | null | null | null |
/*---------------------------------------------------------------------------*\
Copyright (C) 2014 Applied CCM
Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of CAELUS.
CAELUS 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.
CAELUS 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 CAELUS. If not, see <http://www.gnu.org/licenses/>.
Class
CML::InjectionModel
Description
Templated injection model class.
The injection model nominally describes the parcel:
- position
- diameter
- velocity
In this case, the fullyDescribed() flag should be set to 0 (false). When
the parcel is then added to the cloud, the remaining properties are
populated using values supplied in the constant properties.
If, however, all of a parcel's properties are described in the model, the
fullDescribed() flag should be set to 1 (true).
\*---------------------------------------------------------------------------*/
#ifndef InjectionModel_H
#define InjectionModel_H
#include "IOdictionary.hpp"
#include "autoPtr.hpp"
#include "runTimeSelectionTables.hpp"
#include "CloudSubModelBase.hpp"
#include "vector.hpp"
#include "TimeDataEntry.hpp"
#include "mathematicalConstants.hpp"
#include "meshTools.hpp"
#include "volFields.hpp"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace CML
{
/*---------------------------------------------------------------------------*\
Class InjectionModel Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class InjectionModel
:
public CloudSubModelBase<CloudType>
{
public:
//- Convenience typedef for parcelType
typedef typename CloudType::parcelType parcelType;
// Enumerations
//- Parcel basis representation options
// i.e constant number of particles OR constant mass per parcel
enum parcelBasis
{
pbNumber,
pbMass,
pbFixed
};
protected:
// Protected data
// Global injection properties
//- Start of injection [s]
scalar SOI_;
//- Total volume of particles introduced by this injector [m^3]
// - scaled to ensure massTotal is achieved
scalar volumeTotal_;
//- Total mass to inject [kg]
scalar massTotal_;
//- Mass flow rate profile for steady calculations
TimeDataEntry<scalar> massFlowRate_;
//- Total mass injected to date [kg]
scalar massInjected_;
// Counters
//- Number of injections counter
label nInjections_;
//- Running counter of total number of parcels added
label parcelsAddedTotal_;
// Injection properties per Lagrangian time step
//- Parcel basis enumeration
parcelBasis parcelBasis_;
//- nParticle to assign to parcels when the 'fixed' basis
// is selected
scalar nParticleFixed_;
//- Continuous phase time at start of injection time step [s]
scalar time0_;
//- Time at start of injection time step [s]
scalar timeStep0_;
// Protected Member Functions
//- Additional flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI) = 0;
//- Determine properties for next time step/injection interval
virtual bool prepareForNextTimeStep
(
const scalar time,
label& newParcels,
scalar& newVolumeFraction
);
//- Find the cell that contains the supplied position
// Will modify position slightly towards the owner cell centroid to
// ensure that it lies in a cell and not edge/face
virtual bool findCellAtPosition
(
label& celli,
label& tetFacei,
label& tetPti,
vector& position,
bool errorOnNotFound = true
);
//- Set number of particles to inject given parcel properties
virtual scalar setNumberOfParticles
(
const label parcels,
const scalar volumeFraction,
const scalar diameter,
const scalar rho
);
//- Post injection checks
virtual void postInjectCheck
(
const label parcelsAdded,
const scalar massAdded
);
public:
//- Runtime type information
TypeName("injectionModel");
//- Declare runtime constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
InjectionModel,
dictionary,
(
const dictionary& dict,
CloudType& owner,
const word& modelType
),
(dict, owner, modelType)
);
// Constructors
//- Construct null from owner
InjectionModel(CloudType& owner);
//- Construct from dictionary
InjectionModel
(
const dictionary& dict,
CloudType& owner,
const word& modelName,
const word& modelType
);
//- Construct copy
InjectionModel(const InjectionModel<CloudType>& im);
//- Construct and return a clone
virtual autoPtr<InjectionModel<CloudType> > clone() const = 0;
//- Destructor
virtual ~InjectionModel();
// Selectors
//- Selector with lookup from dictionary
static autoPtr<InjectionModel<CloudType> > New
(
const dictionary& dict,
CloudType& owner
);
//- Selector with name and type
static autoPtr<InjectionModel<CloudType> > New
(
const dictionary& dict,
const word& modelName,
const word& modelType,
CloudType& owner
);
// Member Functions
// Mapping
//- Update mesh
virtual void updateMesh();
// Global information
//- Return the start-of-injection time
inline scalar timeStart() const;
//- Return the total volume to be injected across the event
inline scalar volumeTotal() const;
//- Return mass of particles to introduce
inline scalar massTotal() const;
//- Return mass of particles injected (cumulative)
inline scalar massInjected() const;
//- Return the end-of-injection time
virtual scalar timeEnd() const = 0;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject
(
const scalar time0,
const scalar time1
) = 0;
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject
(
const scalar time0,
const scalar time1
) = 0;
//- Return the average parcel mass over the injection period
virtual scalar averageParcelMass();
// Counters
//- Return the number of injections
inline label nInjections() const;
//- Return the total number parcels added
inline label parcelsAddedTotal() const;
// Per-injection event functions
//- Main injection loop
template<class TrackCloudType>
void inject
(
TrackCloudType& cloud,
typename CloudType::parcelType::trackingData& td
);
//- Main injection loop - steady-state
template<class TrackCloudType>
void injectSteadyState
(
TrackCloudType& cloud,
typename CloudType::parcelType::trackingData& td,
const scalar trackTime
);
// Injection geometry
//- Set the injection position and owner cell, tetFace and tetPt
virtual void setPositionAndCell
(
const label parcelI,
const label nParcels,
const scalar time,
vector& position,
label& cellOwner,
label& tetFacei,
label& tetPti
) = 0;
//- Set the parcel properties
virtual void setProperties
(
const label parcelI,
const label nParcels,
const scalar time,
parcelType& parcel
) = 0;
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const = 0;
// I-O
//- Write injection info to stream
virtual void info(Ostream& os);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace CML
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeInjectionModel(CloudType) \
\
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
InjectionModel<kinematicCloudType>, \
0 \
); \
\
defineTemplateRunTimeSelectionTable \
( \
InjectionModel<kinematicCloudType>, \
dictionary \
);
#define makeInjectionModelType(SS, CloudType) \
\
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<kinematicCloudType>, 0); \
\
CML::InjectionModel<kinematicCloudType>:: \
adddictionaryConstructorToTable<SS<kinematicCloudType> > \
add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::timeStart() const
{
return SOI_;
}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::volumeTotal() const
{
return volumeTotal_;
}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::massTotal() const
{
return massTotal_;
}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::massInjected() const
{
return massInjected_;
}
template<class CloudType>
CML::label CML::InjectionModel<CloudType>::nInjections() const
{
return nInjections_;
}
template<class CloudType>
CML::label CML::InjectionModel<CloudType>::parcelsAddedTotal() const
{
return parcelsAddedTotal_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace CML::constant::mathematical;
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class CloudType>
bool CML::InjectionModel<CloudType>::prepareForNextTimeStep
(
const scalar time,
label& newParcels,
scalar& newVolumeFraction
)
{
// Initialise values
newParcels = 0;
newVolumeFraction = 0.0;
bool validInjection = false;
// Return if not started injection event
if (time < SOI_)
{
timeStep0_ = time;
return validInjection;
}
// Make times relative to SOI
scalar t0 = timeStep0_ - SOI_;
scalar t1 = time - SOI_;
// Number of parcels to inject
newParcels = this->parcelsToInject(t0, t1);
// Volume of parcels to inject
newVolumeFraction =
this->volumeToInject(t0, t1)
/(volumeTotal_ + ROOTVSMALL);
if (newVolumeFraction > 0)
{
if (newParcels > 0)
{
timeStep0_ = time;
validInjection = true;
}
else
{
// Injection should have started, but not sufficient volume to
// produce (at least) 1 parcel - hold value of timeStep0_
validInjection = false;
}
}
else
{
timeStep0_ = time;
validInjection = false;
}
return validInjection;
}
template<class CloudType>
bool CML::InjectionModel<CloudType>::findCellAtPosition
(
label& celli,
label& tetFacei,
label& tetPti,
vector& position,
bool errorOnNotFound
)
{
const volVectorField& cellCentres = this->owner().mesh().C();
const vector p0 = position;
this->owner().mesh().findCellFacePt
(
position,
celli,
tetFacei,
tetPti
);
label proci = -1;
if (celli >= 0)
{
proci = Pstream::myProcNo();
}
reduce(proci, maxOp<label>());
// Ensure that only one processor attempts to insert this Parcel
if (proci != Pstream::myProcNo())
{
celli = -1;
tetFacei = -1;
tetPti = -1;
}
// Last chance - find nearest cell and try that one - the point is
// probably on an edge
if (proci == -1)
{
celli = this->owner().mesh().findNearestCell(position);
if (celli >= 0)
{
position += SMALL*(cellCentres[celli] - position);
this->owner().mesh().findCellFacePt
(
position,
celli,
tetFacei,
tetPti
);
if (celli > 0)
{
proci = Pstream::myProcNo();
}
}
reduce(proci, maxOp<label>());
if (proci != Pstream::myProcNo())
{
celli = -1;
tetFacei = -1;
tetPti = -1;
}
}
if (proci == -1)
{
if (errorOnNotFound)
{
FatalErrorInFunction
<< "Cannot find parcel injection cell. "
<< "Parcel position = " << p0 << nl
<< abort(FatalError);
}
else
{
return false;
}
}
return true;
}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::setNumberOfParticles
(
const label parcels,
const scalar volumeFraction,
const scalar diameter,
const scalar rho
)
{
scalar nP = 0.0;
switch (parcelBasis_)
{
case pbMass:
{
scalar volumep = pi/6.0*pow3(diameter);
scalar volumeTot = massTotal_/rho;
nP = volumeFraction*volumeTot/(parcels*volumep);
break;
}
case pbNumber:
{
nP = massTotal_/(rho*volumeTotal_);
break;
}
case pbFixed:
{
nP = nParticleFixed_;
break;
}
default:
{
nP = 0.0;
FatalErrorInFunction
<< "Unknown parcelBasis type" << nl
<< exit(FatalError);
}
}
return nP;
}
template<class CloudType>
void CML::InjectionModel<CloudType>::postInjectCheck
(
const label parcelsAdded,
const scalar massAdded
)
{
const label allParcelsAdded = returnReduce(parcelsAdded, sumOp<label>());
if (allParcelsAdded > 0)
{
Info<< nl
<< "Cloud: " << this->owner().name()
<< " injector: " << this->modelName() << nl
<< " Added " << allParcelsAdded << " new parcels" << nl << endl;
}
// Increment total number of parcels added
parcelsAddedTotal_ += allParcelsAdded;
// Increment total mass injected
massInjected_ += returnReduce(massAdded, sumOp<scalar>());
// Update time for start of next injection
time0_ = this->owner().db().time().value();
// Increment number of injections
nInjections_++;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
CML::InjectionModel<CloudType>::InjectionModel(CloudType& owner)
:
CloudSubModelBase<CloudType>(owner),
SOI_(0.0),
volumeTotal_(0.0),
massTotal_(0.0),
massFlowRate_(owner.db().time(), "massFlowRate"),
massInjected_(this->template getModelProperty<scalar>("massInjected")),
nInjections_(this->template getModelProperty<label>("nInjections")),
parcelsAddedTotal_
(
this->template getModelProperty<scalar>("parcelsAddedTotal")
),
parcelBasis_(pbNumber),
nParticleFixed_(0.0),
time0_(0.0),
timeStep0_(this->template getModelProperty<scalar>("timeStep0"))
{}
template<class CloudType>
CML::InjectionModel<CloudType>::InjectionModel
(
const dictionary& dict,
CloudType& owner,
const word& modelName,
const word& modelType
)
:
CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, modelType),
SOI_(0.0),
volumeTotal_(0.0),
massTotal_(0.0),
massFlowRate_(owner.db().time(), "massFlowRate"),
massInjected_(this->template getModelProperty<scalar>("massInjected")),
nInjections_(this->template getModelProperty<scalar>("nInjections")),
parcelsAddedTotal_
(
this->template getModelProperty<scalar>("parcelsAddedTotal")
),
parcelBasis_(pbNumber),
nParticleFixed_(0.0),
time0_(owner.db().time().value()),
timeStep0_(this->template getModelProperty<scalar>("timeStep0"))
{
// Provide some info
// - also serves to initialise mesh dimensions - needed for parallel runs
// due to lazy evaluation of valid mesh dimensions
Info<< " Constructing " << owner.mesh().nGeometricD() << "-D injection"
<< endl;
if (owner.solution().transient())
{
this->coeffDict().lookup("massTotal") >> massTotal_;
this->coeffDict().lookup("SOI") >> SOI_;
SOI_ = owner.db().time().userTimeToTime(SOI_);
}
else
{
massFlowRate_.reset(this->coeffDict());
massTotal_ = massFlowRate_.value(owner.db().time().value());
}
const word parcelBasisType = this->coeffDict().lookup("parcelBasisType");
if (parcelBasisType == "mass")
{
parcelBasis_ = pbMass;
}
else if (parcelBasisType == "number")
{
parcelBasis_ = pbNumber;
}
else if (parcelBasisType == "fixed")
{
parcelBasis_ = pbFixed;
Info<< " Choosing nParticle to be a fixed value, massTotal "
<< "variable now does not determine anything."
<< endl;
nParticleFixed_ = readScalar(this->coeffDict().lookup("nParticle"));
}
else
{
FatalErrorInFunction
<< "parcelBasisType must be either 'number', 'mass' or 'fixed'"
<< nl << exit(FatalError);
}
}
template<class CloudType>
CML::InjectionModel<CloudType>::InjectionModel
(
const InjectionModel<CloudType>& im
)
:
CloudSubModelBase<CloudType>(im),
SOI_(im.SOI_),
volumeTotal_(im.volumeTotal_),
massTotal_(im.massTotal_),
massFlowRate_(im.massFlowRate_),
massInjected_(im.massInjected_),
nInjections_(im.nInjections_),
parcelsAddedTotal_(im.parcelsAddedTotal_),
parcelBasis_(im.parcelBasis_),
nParticleFixed_(im.nParticleFixed_),
time0_(im.time0_),
timeStep0_(im.timeStep0_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
CML::InjectionModel<CloudType>::~InjectionModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void CML::InjectionModel<CloudType>::updateMesh()
{}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::averageParcelMass()
{
label nTotal = 0.0;
if (this->owner().solution().transient())
{
nTotal = parcelsToInject(0.0, timeEnd() - timeStart());
}
else
{
nTotal = parcelsToInject(0.0, 1.0);
}
return massTotal_/nTotal;
}
template<class CloudType>
template<class TrackCloudType>
void CML::InjectionModel<CloudType>::inject
(
TrackCloudType& cloud,
typename CloudType::parcelType::trackingData& td
)
{
if (!this->active())
{
return;
}
const scalar time = this->owner().db().time().value();
// Prepare for next time step
label parcelsAdded = 0;
scalar massAdded = 0.0;
label newParcels = 0;
scalar newVolumeFraction = 0.0;
if (prepareForNextTimeStep(time, newParcels, newVolumeFraction))
{
const scalar trackTime = this->owner().solution().trackTime();
const polyMesh& mesh = this->owner().mesh();
// Duration of injection period during this timestep
const scalar deltaT =
max(0.0, min(trackTime, min(time - SOI_, timeEnd() - time0_)));
// Pad injection time if injection starts during this timestep
const scalar padTime = max(0.0, SOI_ - time0_);
// Introduce new parcels linearly across carrier phase timestep
for (label parcelI = 0; parcelI < newParcels; parcelI++)
{
if (validInjection(parcelI))
{
// Calculate the pseudo time of injection for parcel 'parcelI'
scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels;
// Determine the injection position and owner cell,
// tetFace and tetPt
label celli = -1;
label tetFacei = -1;
label tetPti = -1;
vector pos = Zero;
setPositionAndCell
(
parcelI,
newParcels,
timeInj,
pos,
celli,
tetFacei,
tetPti
);
if (celli > -1)
{
// Lagrangian timestep
const scalar dt = time - timeInj;
// Apply corrections to position for 2-D cases
meshTools::constrainToMeshCentre(mesh, pos);
// Create a new parcel
parcelType* pPtr = new parcelType(mesh, pos, celli);
// Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr, dt);
// Assign new parcel properties in injection model
setProperties(parcelI, newParcels, timeInj, *pPtr);
// Check/set new parcel injection properties
cloud.checkParcelProperties(*pPtr, dt, fullyDescribed());
// Apply correction to velocity for 2-D cases
meshTools::constrainDirection
(
mesh,
mesh.solutionD(),
pPtr->U()
);
// Number of particles per parcel
pPtr->nParticle() =
setNumberOfParticles
(
newParcels,
newVolumeFraction,
pPtr->d(),
pPtr->rho()
);
parcelsAdded ++;
massAdded += pPtr->nParticle()*pPtr->mass();
if (pPtr->move(cloud, td, dt))
{
cloud.addParticle(pPtr);
}
else
{
delete pPtr;
}
}
}
}
}
postInjectCheck(parcelsAdded, massAdded);
}
template<class CloudType>
template<class TrackCloudType>
void CML::InjectionModel<CloudType>::injectSteadyState
(
TrackCloudType& cloud,
typename CloudType::parcelType::trackingData& td,
const scalar trackTime
)
{
if (!this->active())
{
return;
}
const polyMesh& mesh = this->owner().mesh();
massTotal_ = massFlowRate_.value(mesh.time().value());
// Reset counters
time0_ = 0.0;
label parcelsAdded = 0;
scalar massAdded = 0.0;
// Set number of new parcels to inject based on first second of injection
label newParcels = parcelsToInject(0.0, 1.0);
// Inject new parcels
for (label parcelI = 0; parcelI < newParcels; parcelI++)
{
// Volume to inject is split equally amongst all parcel streams
scalar newVolumeFraction = 1.0/scalar(newParcels);
// Determine the injection position and owner cell,
// tetFace and tetPt
label celli = -1;
label tetFacei = -1;
label tetPti = -1;
vector pos = Zero;
setPositionAndCell
(
parcelI,
newParcels,
0.0,
pos,
celli,
tetFacei,
tetPti
);
if (celli > -1)
{
// Apply corrections to position for 2-D cases
meshTools::constrainToMeshCentre(mesh, pos);
// Create a new parcel
parcelType* pPtr = new parcelType(mesh, pos, celli);
// Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr, 0.0);
// Assign new parcel properties in injection model
setProperties(parcelI, newParcels, 0.0, *pPtr);
// Check/set new parcel injection properties
cloud.checkParcelProperties(*pPtr, 0.0, fullyDescribed());
// Apply correction to velocity for 2-D cases
meshTools::constrainDirection(mesh, mesh.solutionD(), pPtr->U());
// Number of particles per parcel
pPtr->nParticle() =
setNumberOfParticles
(
1,
newVolumeFraction,
pPtr->d(),
pPtr->rho()
);
// Add the new parcel
cloud.addParticle(pPtr);
massAdded += pPtr->nParticle()*pPtr->mass();
parcelsAdded++;
}
}
postInjectCheck(parcelsAdded, massAdded);
}
template<class CloudType>
void CML::InjectionModel<CloudType>::info(Ostream& os)
{
os << " " << this->modelName() << ":" << nl
<< " number of parcels added = " << parcelsAddedTotal_ << nl
<< " mass introduced = " << massInjected_ << nl;
if (this->writeTime())
{
this->setModelProperty("massInjected", massInjected_);
this->setModelProperty("nInjections", nInjections_);
this->setModelProperty("parcelsAddedTotal", parcelsAddedTotal_);
this->setModelProperty("timeStep0", timeStep0_);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class CloudType>
CML::autoPtr<CML::InjectionModel<CloudType> >
CML::InjectionModel<CloudType>::New
(
const dictionary& dict,
CloudType& owner
)
{
const word modelType(dict.lookup("injectionModel"));
Info<< "Selecting injection model " << modelType << endl;
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown injection model type "
<< modelType << nl << nl
<< "Valid injection model types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError);
}
return autoPtr<InjectionModel<CloudType>>(cstrIter()(dict, owner));
}
template<class CloudType>
CML::autoPtr<CML::InjectionModel<CloudType> >
CML::InjectionModel<CloudType>::New
(
const dictionary& dict,
const word& modelName,
const word& modelType,
CloudType& owner
)
{
Info<< "Selecting injection model " << modelType << endl;
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown injection model type "
<< modelType << nl << nl
<< "Valid injection model types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError);
}
return
autoPtr<InjectionModel<CloudType> >
(
cstrIter()
(
dict,
owner,
modelName
)
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
| 27.304823
| 80
| 0.532391
|
MrAwesomeRocks
|
de3396e97f0d814930a807af6bb63b9a8a60cd56
| 427
|
cpp
|
C++
|
notes/examples/chapter09/indirectionOperator.cpp
|
jay3ss/co-sci-140
|
2751bd12bcd8a24bf15fba656e086f1b0615b4a9
|
[
"BSD-3-Clause"
] | null | null | null |
notes/examples/chapter09/indirectionOperator.cpp
|
jay3ss/co-sci-140
|
2751bd12bcd8a24bf15fba656e086f1b0615b4a9
|
[
"BSD-3-Clause"
] | 1
|
2019-03-02T06:10:13.000Z
|
2019-03-06T19:17:14.000Z
|
notes/examples/chapter09/indirectionOperator.cpp
|
jay3ss/co-sci-140
|
2751bd12bcd8a24bf15fba656e086f1b0615b4a9
|
[
"BSD-3-Clause"
] | null | null | null |
#include <iostream>
int main()
{
int x = 25;
int *ptr = nullptr;
ptr = &x;
std::cout << "Here is the value in x, printed twice:\n"
<< x << std::endl
<< *ptr << std::endl;
*ptr = 100;
std::cout << "Once again, here is the value in x:\n"
<< x << std::endl
<< *ptr << std::endl;
return 0;
}
| 20.333333
| 60
| 0.386417
|
jay3ss
|
de34ff8b488ff7be459e0a16654816f1a8d561ff
| 4,147
|
cc
|
C++
|
vos/gui/sub/gui/si_save/SiSaveAsCmd.cc
|
NASA-AMMOS/VICAR
|
4504c1f558855d9c6eaef89f4460217aa4909f8e
|
[
"BSD-3-Clause"
] | 16
|
2020-10-21T05:56:26.000Z
|
2022-03-31T10:02:01.000Z
|
vos/gui/sub/gui/si_save/SiSaveAsCmd.cc
|
NASA-AMMOS/VICAR
|
4504c1f558855d9c6eaef89f4460217aa4909f8e
|
[
"BSD-3-Clause"
] | null | null | null |
vos/gui/sub/gui/si_save/SiSaveAsCmd.cc
|
NASA-AMMOS/VICAR
|
4504c1f558855d9c6eaef89f4460217aa4909f8e
|
[
"BSD-3-Clause"
] | 2
|
2021-03-09T01:51:08.000Z
|
2021-03-23T00:23:24.000Z
|
////////////////////////////////////////////////////////////
// SiSaveAsCmd.h: Saves the image according to the SiSaveCmdValue
// CmdValue passed in.
//
//!!!! NOTE: THIS IS A HACK CURRENTLY! The command derives from
//!!!! SiRunStretchScriptCmd, adding the SiSaveCmdValue parameters to
//!!!! the file, then running an *external* script to implement the
//!!!! save. It should be done internally, via save hooks in ImageData.
//
// In adition to the information included by SiRunStretchScriptCmd, the
// following information is passed:
//
// scriptVersion=1.2 replaces 1.1 from base class
// saveFilename="string" see below
// saveImageExtent=file how much to save: display, file, roi
// saveLutType=stretch whether to use stretch/pseudo tables
// (same values as lutType in parent)
// saveAsByte=1 0=retain data type (no stretch unless byte)
// 1=convert to byte (stretch/pseudo allowed)
// saveFileFormat="VICAR" file format to save in, currently VICAR or TIFF
//
// saveFilename follows the same rules as filename in SiRunScriptCmd,
// except that band numbers (in parens) are not allowed.
///////////////////////////////////////////////////////////
#include "SiSaveAsCmd.h"
#include "SiSaveCmdValue.h"
#include "XvicImage.h"
#include "ImageToReloadGlue.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
SiSaveAsCmd::SiSaveAsCmd(const char *name, int active, Widget xiw,
ImageData *image, const char *script,
Lut *sR, Lut *sG, Lut *sB, Lut *pR, Lut *pG, Lut *pB)
: SiRunStretchScriptCmd(name, active, xiw, image, script,
sR, sG, sB, pR, pG, pB)
{
// Empty
}
////////////////////////////////////////////////////////////
// Print the version string to the temp file. This function
// should be overridden by subclasses.
////////////////////////////////////////////////////////////
void SiSaveAsCmd::printVersionString(FILE *tfp)
{
fprintf(tfp, "scriptVersion=1.2\n");
}
////////////////////////////////////////////////////////////
// Print the contents to the temp file. This function could
// be overridden by subclasses, which should call this specific
// version to output the basic info.
////////////////////////////////////////////////////////////
void SiSaveAsCmd::printContents(FILE *tfp)
{
// Print basic values
SiRunStretchScriptCmd::printContents(tfp);
// Get extra values from CmdValue
SiSaveCmdValue *value = (SiSaveCmdValue *)_value;
if (value == NULL) {
fprintf(stderr, "No SiSaveCmdValue, internal error, file not saved!\n");
return;
}
if (strlen(value->filename_grn) == 0 && strlen(value->filename_blu) == 0)
fprintf(tfp, "saveFilename=\"%s\"\n", value->filename_red);
else
fprintf(tfp, "saveFilename=(\"%s\",\"%s\",\"%s\")\n",
value->filename_red, value->filename_grn, value->filename_blu);
switch (value->imageExtent) {
case SaveDisplayOnly:
fprintf(tfp, "saveImageExtent=display\n");
break;
case SaveEntireFile:
fprintf(tfp, "saveImageExtent=file\n");
break;
case SaveROI: // Not Implemented!!!!
fprintf(tfp, "saveImageExtent=roi\n");
break;
default:
break;
}
switch (value->lutType) {
case XvicRAW:
fprintf(tfp, "saveLutType=raw\n");
break;
case XvicSTRETCH:
fprintf(tfp, "saveLutType=stretch\n");
break;
case XvicPSEUDO:
fprintf(tfp, "saveLutType=pseudo\n");
break;
case XvicPSEUDO_ONLY:
fprintf(tfp, "saveLutType=pseudo_only\n");
break;
default:
break;
}
fprintf(tfp, "saveAsByte=%d\n", value->asByte ? 1 : 0);
fprintf(tfp, "saveFileFormat=%s\n", value->fileFormat);
}
////////////////////////////////////////////////////////////
// Delete the CmdValue object
////////////////////////////////////////////////////////////
void SiSaveAsCmd::freeValue(CmdValue value)
{
if (value)
delete (SiSaveCmdValue *)value;
}
| 31.9
| 78
| 0.565228
|
NASA-AMMOS
|
de373ff000311a4e3f0865cd47eb9259491d7c0b
| 557
|
hpp
|
C++
|
src/view/cogbutton.hpp
|
severin-lemaignan/boxology
|
08b592b315c0e7960ed5d7f8385f2702c0443013
|
[
"MIT"
] | 9
|
2015-11-03T11:46:01.000Z
|
2021-11-18T08:38:30.000Z
|
src/view/cogbutton.hpp
|
severin-lemaignan/boxology
|
08b592b315c0e7960ed5d7f8385f2702c0443013
|
[
"MIT"
] | 2
|
2016-04-11T16:24:23.000Z
|
2017-04-06T14:19:31.000Z
|
src/view/cogbutton.hpp
|
severin-lemaignan/boxology
|
08b592b315c0e7960ed5d7f8385f2702c0443013
|
[
"MIT"
] | 4
|
2015-10-23T08:24:27.000Z
|
2018-06-27T19:09:44.000Z
|
#ifndef LABEL_BUTTON_HPP
#define LABEL_BUTTON_HPP
#include <string>
#include <QPushButton>
#include <QMouseEvent>
#include <QColor>
#include "../label.hpp"
class CogButton : public QPushButton {
Q_OBJECT
public:
CogButton() = delete;
CogButton(Label label, QWidget *parent = 0);
// QColor color() const {return _color;}
// private slots:
void mousePressEvent(QMouseEvent *e);
signals:
void triggered(Label label);
private:
void setColor(const QColor &color);
Label _label;
};
#endif // LABEL_BUTTON_HPP
| 16.382353
| 48
| 0.685817
|
severin-lemaignan
|
de3d806a2ca4d876c343358a63de74ae59c8d1e9
| 1,096
|
hpp
|
C++
|
Octree/OctreeLeaf.hpp
|
kashinoleg/Octree
|
3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5
|
[
"ICU"
] | null | null | null |
Octree/OctreeLeaf.hpp
|
kashinoleg/Octree
|
3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5
|
[
"ICU"
] | null | null | null |
Octree/OctreeLeaf.hpp
|
kashinoleg/Octree
|
3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5
|
[
"ICU"
] | null | null | null |
#pragma once
#include "OctreeArray.hpp"
#include "OctreeCell.hpp"
#include "OctreeBranch.hpp"
/**
* outer node implementation of an octree cell.stores pointers to items.
*/
namespace hxa {
class OctreeLeaf : public OctreeCell {
private:
OctreeArray<const void*> items_m;
public:
OctreeLeaf();
OctreeLeaf(const OctreeLeaf*const leafs[8]);
private:
explicit OctreeLeaf(const void* pItem);
public:
virtual ~OctreeLeaf();
OctreeLeaf(const OctreeLeaf&);
OctreeLeaf& operator=(const OctreeLeaf&);
virtual void insertItem(const OctreeData& thisData, OctreeCell*& pThis, const void* pItem, const OctreeAgentV& agent);
virtual bool removeItem(OctreeCell*& pThis, const void* pItem,
const int maxItemsPerCell, int& itemCount);
virtual void visit(const OctreeData& thisData, OctreeVisitorV& visitor) const;
virtual OctreeCell* clone() const;
virtual void getInfo(int& byteSize, int& leafCount, int& itemCount, int& maxDepth) const;
static void insertItemMaybeCreate(const OctreeData& cellData, OctreeCell*& pCell, const void* pItem, const OctreeAgentV& agent);
};
}
| 34.25
| 130
| 0.75365
|
kashinoleg
|
de432f1072702f047a9ff38adc61b3285afe52ba
| 412
|
hpp
|
C++
|
src/Generator.hpp
|
ageorgiev97/yat
|
293adda152025d7c7bfbb2e982aa9d2ff5a461d9
|
[
"Apache-2.0"
] | 1
|
2019-12-11T21:50:13.000Z
|
2019-12-11T21:50:13.000Z
|
src/Generator.hpp
|
ageorgiev97/yat
|
293adda152025d7c7bfbb2e982aa9d2ff5a461d9
|
[
"Apache-2.0"
] | 4
|
2019-11-30T21:55:18.000Z
|
2019-11-30T23:00:08.000Z
|
src/Generator.hpp
|
ageorgiev97/yat
|
293adda152025d7c7bfbb2e982aa9d2ff5a461d9
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
#include <memory>
#include <unordered_map>
#include "Llvm.hpp"
#include "Expressions.hpp"
#include "Statements.hpp"
#include "Scope.hpp"
#include "Function.hpp"
namespace yat
{
extern llvm::LLVMContext GlobalContext;
extern std::unique_ptr<llvm::Module> GlobalModule;
extern std::unordered_map<std::string, Function> functions;
void GenerateCode(Statement const& expression);
}
| 19.619048
| 63
| 0.742718
|
ageorgiev97
|
de43e22d76b73a49cbfe76e8f08efcf00e7cedbe
| 3,766
|
cpp
|
C++
|
python/src/distance/edge_edge.cpp
|
ipc-sim/ipc-toolk
|
81873d0288810e30166d871419da4104329860e3
|
[
"MIT"
] | 61
|
2020-08-04T21:08:25.000Z
|
2022-02-25T02:24:31.000Z
|
python/src/distance/edge_edge.cpp
|
dbelgrod/ipc-toolkit
|
0b7ca9b5f867db63bd68dd02ce54a9d00b0fc337
|
[
"MIT"
] | 2
|
2020-10-12T05:54:40.000Z
|
2021-10-10T18:39:30.000Z
|
python/src/distance/edge_edge.cpp
|
dbelgrod/ipc-toolkit
|
0b7ca9b5f867db63bd68dd02ce54a9d00b0fc337
|
[
"MIT"
] | 7
|
2020-11-26T12:47:38.000Z
|
2022-03-25T04:55:49.000Z
|
#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>
#include <ipc/distance/distance_type.hpp>
#include <ipc/distance/edge_edge.hpp>
#include "../utils.hpp"
namespace py = pybind11;
using namespace ipc;
void define_edge_edge_distance_functions(py::module_& m)
{
m.def(
"edge_edge_distance",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
if (dtype == nullptr) {
return edge_edge_distance(ea0, ea1, eb0, eb1);
} else {
return edge_edge_distance(ea0, ea1, eb0, eb1, *dtype);
}
},
R"ipc_Qu8mg5v7(
Compute the distance between a two lines segments in 3D.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) edge-edge distance type to compute
Returns:
The distance between the two edges.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
m.def(
"edge_edge_distance_gradient",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
Vector<double, 12> grad;
if (dtype == nullptr) {
edge_edge_distance_gradient(ea0, ea1, eb0, eb1, grad);
} else {
edge_edge_distance_gradient(ea0, ea1, eb0, eb1, *dtype, grad);
}
return grad;
},
R"ipc_Qu8mg5v7(
Compute the gradient of the distance between a two lines segments.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) point edge distance type to compute
Returns:
The gradient of the distance wrt ea0, ea1, eb0, and eb1.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
m.def(
"edge_edge_distance_hessian",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
Eigen::Matrix<double, 12, 12> hess;
if (dtype == nullptr) {
edge_edge_distance_hessian(ea0, ea1, eb0, eb1, hess);
} else {
edge_edge_distance_hessian(ea0, ea1, eb0, eb1, *dtype, hess);
}
return hess;
},
R"ipc_Qu8mg5v7(
Compute the hessian of the distance between a two lines segments.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) point edge distance type to compute
Returns:
The hessian of the distance wrt ea0, ea1, eb0, and eb1.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
}
| 34.87037
| 78
| 0.568508
|
ipc-sim
|
de453dff328feddf3b3e01648695ad3c1c04d789
| 8,250
|
cc
|
C++
|
tests/unit/bcache_test.cc
|
pombredanne/forestdb
|
37c787a7a6947a876d8609a3f70840b5da19b728
|
[
"Apache-2.0"
] | 992
|
2015-02-28T11:55:28.000Z
|
2022-03-28T03:17:50.000Z
|
tests/unit/bcache_test.cc
|
pombredanne/forestdb
|
37c787a7a6947a876d8609a3f70840b5da19b728
|
[
"Apache-2.0"
] | 16
|
2015-04-07T19:35:52.000Z
|
2022-02-21T22:40:58.000Z
|
tests/unit/bcache_test.cc
|
pombredanne/forestdb
|
37c787a7a6947a876d8609a3f70840b5da19b728
|
[
"Apache-2.0"
] | 173
|
2015-03-04T13:17:41.000Z
|
2022-03-28T13:17:55.000Z
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2010 Couchbase, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "test.h"
#include "blockcache.h"
#include "filemgr.h"
#include "filemgr_ops.h"
#include "crc32.h"
#include "memleak.h"
void basic_test()
{
TEST_INIT();
FileMgr *file;
FileMgrConfig config(4096, 5, 1048576, 0, 0, FILEMGR_CREATE,
FDB_SEQTREE_NOT_USE, 0, 8, 0, FDB_ENCRYPTION_NONE,
0x00, 0, 0);
int i;
uint8_t buf[4096];
std::string fname("./bcache_testfile");
filemgr_open_result result = FileMgr::open(fname, get_filemgr_ops(),
&config, NULL);
file = result.file;
for (i=0;i<5;++i) {
file->alloc_FileMgr(NULL);
file->write_FileMgr(i, buf, NULL);
}
file->commit_FileMgr(true, NULL);
for (i=5;i<10;++i) {
file->alloc_FileMgr(NULL);
file->write_FileMgr(i, buf, NULL);
}
file->commit_FileMgr(true, NULL);
file->read_FileMgr(8, buf, NULL, true);
file->read_FileMgr(9, buf, NULL, true);
file->read_FileMgr(1, buf, NULL, true);
file->read_FileMgr(2, buf, NULL, true);
file->read_FileMgr(3, buf, NULL, true);
file->read_FileMgr(7, buf, NULL, true);
file->read_FileMgr(1, buf, NULL, true);
file->read_FileMgr(9, buf, NULL, true);
file->alloc_FileMgr(NULL);
file->write_FileMgr(10, buf, NULL);
TEST_RESULT("basic test");
}
void basic_test2()
{
TEST_INIT();
FileMgr *file;
FileMgrConfig config(4096, 5, 1048576, 0x0, 0, FILEMGR_CREATE,
FDB_SEQTREE_NOT_USE, 0, 8, 0, FDB_ENCRYPTION_NONE,
0x00, 0, 0);
int i;
uint8_t buf[4096];
std::string fname("./bcache_testfile");
int r;
r = system(SHELL_DEL " bcache_testfile");
(void)r;
filemgr_open_result result = FileMgr::open(fname, get_filemgr_ops(),
&config, NULL);
file = result.file;
for (i=0;i<5;++i) {
file->alloc_FileMgr(NULL);
file->write_FileMgr(i, buf, NULL);
}
for (i=5;i<10;++i) {
file->alloc_FileMgr(NULL);
file->write_FileMgr(i, buf, NULL);
}
file->commit_FileMgr(true, NULL);
FileMgr::close(file, true, NULL, NULL);
FileMgr::shutdown();
TEST_RESULT("basic test");
}
struct worker_args{
size_t n;
FileMgr *file;
size_t writer;
size_t nblocks;
size_t time_sec;
};
void * worker(void *voidargs)
{
uint8_t *buf = (uint8_t *)malloc(4096);
struct worker_args *args = (struct worker_args*)voidargs;
struct timeval ts_begin, ts_cur, ts_gap;
ssize_t ret;
bid_t bid;
uint32_t crc, crc_file;
uint64_t i, c, run_count=0;
TEST_INIT();
memset(buf, 0, 4096);
gettimeofday(&ts_begin, NULL);
while(1) {
bid = rand() % args->nblocks;
ret = BlockCacheManager::getInstance()->read(args->file, bid, buf);
if (ret <= 0) {
ret = args->file->getOps()->pread(args->file->getFopsHandle(), buf,
args->file->getBlockSize(),
bid * args->file->getBlockSize());
TEST_CHK(ret == (ssize_t)args->file->getBlockSize());
ret = BlockCacheManager::getInstance()->write(args->file, bid, buf,
BCACHE_REQ_CLEAN, false);
TEST_CHK(ret == (ssize_t)args->file->getBlockSize());
}
crc_file = crc32_8(buf, sizeof(uint64_t)*2, 0);
(void)crc_file;
memcpy(&i, buf, sizeof(i));
memcpy(&crc, buf + sizeof(uint64_t)*2, sizeof(crc));
// Disable checking the CRC value at this time as pread and pwrite are
// not thread-safe.
// TEST_CHK(crc == crc_file && i==bid);
//DBG("%d %d %d %x %x\n", (int)args->n, (int)i, (int)bid, (int)crc, (int)crc_file);
if (args->writer) {
memcpy(&c, buf+sizeof(i), sizeof(c));
c++;
memcpy(buf+sizeof(i), &c, sizeof(c));
crc = crc32_8(buf, sizeof(uint64_t)*2, 0);
memcpy(buf + sizeof(uint64_t)*2, &crc, sizeof(crc));
ret = BlockCacheManager::getInstance()->write(args->file, bid, buf,
BCACHE_REQ_DIRTY, true);
TEST_CHK(ret == (ssize_t)args->file->getBlockSize());
} else { // have some of the reader threads flush dirty immutable blocks
if (bid <= args->nblocks / 4) { // 25% probability
args->file->flushImmutable(NULL);
}
}
gettimeofday(&ts_cur, NULL);
ts_gap = _utime_gap(ts_begin, ts_cur);
if ((size_t)ts_gap.tv_sec >= args->time_sec) break;
run_count++;
}
free(buf);
thread_exit(0);
return NULL;
}
void multi_thread_test(int nblocks, int cachesize,
int blocksize, int time_sec,
int nwriters, int nreaders)
{
TEST_INIT();
FileMgr *file;
FileMgrConfig config(blocksize, cachesize, 1048576, 0x0, 0,
FILEMGR_CREATE, FDB_SEQTREE_NOT_USE, 0, 8, 0,
FDB_ENCRYPTION_NONE, 0x00, 0, 0);
int n = nwriters + nreaders;
uint64_t i, j;
uint32_t crc;
uint8_t *buf;
int r;
std::string fname("./bcache_testfile");
thread_t *tid = alca(thread_t, n);
struct worker_args *args = alca(struct worker_args, n);
void **ret = alca(void *, n);
r = system(SHELL_DEL " bcache_testfile");
(void)r;
memleak_start();
buf = (uint8_t *)malloc(4096);
memset(buf, 0, 4096);
filemgr_open_result result = FileMgr::open(fname, get_filemgr_ops(),
&config, NULL);
file = result.file;
for (i=0;i<(uint64_t)nblocks;++i) {
memcpy(buf, &i, sizeof(i));
j = 0;
memcpy(buf + sizeof(i), &j, sizeof(j));
crc = crc32_8(buf, sizeof(i) + sizeof(j), 0);
memcpy(buf + sizeof(i) + sizeof(j), &crc, sizeof(crc));
BlockCacheManager::getInstance()->write(file, (bid_t)i, buf,
BCACHE_REQ_DIRTY, false);
}
for (i=0;i<(uint64_t)n;++i){
args[i].n = i;
args[i].file = file;
args[i].writer = ((i<(uint64_t)nwriters)?(1):(0));
args[i].nblocks = nblocks;
args[i].time_sec = time_sec;
thread_create(&tid[i], worker, &args[i]);
}
DBG("wait for %d seconds..\n", time_sec);
for (i=0;i<(uint64_t)n;++i){
thread_join(tid[i], &ret[i]);
}
file->commit_FileMgr(true, NULL);
FileMgr::close(file, true, NULL, NULL);
FileMgr::shutdown();
free(buf);
memleak_end();
TEST_RESULT("multi thread test");
}
int main()
{
basic_test2();
#if !defined(THREAD_SANITIZER)
/**
* The following tests will be disabled when the code is run with
* thread sanitizer, because they point out a data race in writing/
* reading from a dirty block which will not happen in reality.
*
* The bcache partition lock is release iff a given dirty block has
* already been marked as immutable. These unit tests attempt to
* write to the same immutable block again causing this race. In
* reality, this won't happen as these operations go through
* FileMgr::read() and FileMgr::write().
*/
multi_thread_test(4, 1, 32, 20, 1, 7);
multi_thread_test(100, 1, 32, 10, 1, 7);
#endif
return 0;
}
| 30.783582
| 91
| 0.567879
|
pombredanne
|
de482e891dd8980943bd4795b5fc8ae7b524f6ad
| 3,105
|
cpp
|
C++
|
integ/sync-interop/syncps-ind.cpp
|
yoursunny/ndn-ts
|
1b8163ac43b2c2754a62e0724350ddb67714f095
|
[
"0BSD"
] | null | null | null |
integ/sync-interop/syncps-ind.cpp
|
yoursunny/ndn-ts
|
1b8163ac43b2c2754a62e0724350ddb67714f095
|
[
"0BSD"
] | null | null | null |
integ/sync-interop/syncps-ind.cpp
|
yoursunny/ndn-ts
|
1b8163ac43b2c2754a62e0724350ddb67714f095
|
[
"0BSD"
] | null | null | null |
#include "syncps.hpp"
#include <iostream>
/** @brief Timestamp naming convention (rev3). */
namespace Timestamp {
using TlvType = std::integral_constant<int, 0x38>;
inline uint64_t
now()
{
::timespec tp;
::clock_gettime(CLOCK_REALTIME, &tp);
return static_cast<uint64_t>(tp.tv_sec) * 1000000 + static_cast<uint64_t>(tp.tv_nsec) / 1000;
}
inline ndn::Name::Component
create(uint64_t v = now())
{
return ndn::Name::Component::fromNumber(v, ndn_NameComponentType_OTHER_CODE, TlvType::value);
}
inline uint64_t
parse(const ndn::Name::Component& comp)
{
if (comp.getType() == ndn_NameComponentType_OTHER_CODE &&
comp.getOtherTypeCode() == TlvType::value) {
return comp.toNumber();
}
return 0;
}
} // namespace Timestamp
int
main(int argc, char** argv)
{
INIT_LOGGERS();
log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getTrace());
// ndn::WireFormat::setDefaultWireFormat(ndn::Tlv0_3WireFormat::get());
if (argc != 4) {
std::cerr << "./demo SYNC-PREFIX SUB-PREFIX PUB-PREFIX" << std::endl;
return 2;
}
ndn::Name syncPrefix(argv[1]);
ndn::Name subPrefix(argv[2]);
ndn::Name pubPrefix(argv[3]);
ndn::KeyChain keyChain;
try {
keyChain.getDefaultCertificateName();
} catch (const ndn::Pib::Error&) {
keyChain.createIdentityV2("/operator");
}
ndn::ThreadsafeFace face;
face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
syncps::SyncPubsub sync(
face, syncPrefix,
[](const syncps::Publication& data) {
auto d = std::chrono::microseconds(
static_cast<int64_t>(Timestamp::now() - Timestamp::parse(data.getName()[-1])));
return d >= syncps::maxPubLifetime + syncps::maxClockSkew || d <= -syncps::maxClockSkew;
},
[](syncps::VPubPtr& ours, syncps::VPubPtr& others) mutable {
if (ours.empty()) {
return ours;
}
static const auto cmp = [](const syncps::PubPtr& a, const syncps::PubPtr& b) {
return Timestamp::parse(a->getName()[-1]) > Timestamp::parse(b->getName()[-1]);
};
std::sort(ours.begin(), ours.end(), cmp);
std::sort(others.begin(), others.end(), cmp);
std::copy(others.begin(), others.end(), std::back_inserter(ours));
return ours;
});
sync.subscribeTo(subPrefix, [](const syncps::Publication& data) {
std::cerr << "UPDATE " << data.getName() << std::endl;
});
ndn::scheduler::Scheduler sched(face.getIoService());
int seqNum = 0;
ndn::scheduler::EventCallback publish = [&]() {
ndn::Name name = pubPrefix;
name.append(std::to_string(++seqNum));
name.append(Timestamp::create());
std::cerr << "PUBLISH " << name << std::endl;
ndn::Data publication(name);
sync.publish(std::move(publication), [](const ndn::Data& pub, bool confirmed) {
std::cerr << (confirmed ? "CONFIRM " : "LOST ") << pub.getName() << std::endl;
});
float randTime = 0.0;
ndn::CryptoLite::generateRandomFloat(randTime);
sched.schedule(std::chrono::milliseconds(500 + static_cast<int>(200 * randTime)), publish);
};
publish();
face.getIoService().run();
}
| 30.441176
| 95
| 0.649919
|
yoursunny
|
de49013ba0bb5819c9de5d827f8a9f5731b10d95
| 1,843
|
cpp
|
C++
|
SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp
|
phoenixzz/VoronoiMapGen
|
5afd852f8bb0212baba9d849178eb135f62df903
|
[
"MIT"
] | 11
|
2017-03-03T03:31:15.000Z
|
2019-03-01T17:09:12.000Z
|
SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp
|
phoenixzz/VoronoiMapGen
|
5afd852f8bb0212baba9d849178eb135f62df903
|
[
"MIT"
] | null | null | null |
SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp
|
phoenixzz/VoronoiMapGen
|
5afd852f8bb0212baba9d849178eb135f62df903
|
[
"MIT"
] | 2
|
2017-03-03T03:31:17.000Z
|
2021-05-27T21:50:43.000Z
|
Emitter::Emitter() : Registerable(), Transformable(),
zone( &getDefaultZone() ),
full(true),
tank(-1),
flow(0.0f),
forceMin(0.0f),
forceMax(0.0f),
fraction( random(0.0f,1.0f) ),
active(true)
{}
Zone& Emitter::getDefaultZone()
{
static PointZone defaultZone;
return defaultZone;
}
void Emitter::registerChildren(bool registerAll)
{
Registerable::registerChildren(registerAll);
registerChild(zone, registerAll);
}
void Emitter::copyChildren(const Registerable& object, bool createBase)
{
const Emitter& emitter = dynamic_cast<const Emitter&>(object);
Registerable::copyChildren(emitter, createBase);
zone = dynamic_cast<Zone*>(copyChild(emitter.zone, createBase));
}
void Emitter::destroyChildren(bool keepChildren)
{
destroyChild(zone, keepChildren);
Registerable::destroyChildren(keepChildren);
}
Registerable* Emitter::findByName(const String& name)
{
Registerable* object = Registerable::findByName(name);
if (object != NULL)
return object;
return zone->findByName(name);
}
void Emitter::changeTank(int32 deltaTank)
{
if(tank >= 0)
{
tank += deltaTank;
if(tank < 0)
tank = 0;
}
}
void Emitter::changeFlow(float deltaFlow)
{
if(flow >= 0.0f)
{
flow += deltaFlow;
if(flow < 0.0f)
flow = 0.0f;
}
}
void Emitter::setZone(Zone* _zone, bool full)
{
decrementChildReference(this->zone);
incrementChildReference(_zone);
if(_zone == NULL)
_zone = &getDefaultZone();
this->zone = _zone;
this->full = full;
}
uint32 Emitter::updateNumber(float deltaTime)
{
int32 nbBorn;
if(flow < 0.0f)
{
nbBorn = jmax(0, tank);
tank = 0;
}
else if(tank != 0)
{
fraction += flow * deltaTime;
nbBorn = static_cast<int>(fraction);
if(tank >= 0)
{
nbBorn = jmin(tank, nbBorn);
tank -= nbBorn;
}
fraction -= nbBorn;
}
else
nbBorn = 0;
return static_cast<uint32>(nbBorn);
}
| 17.721154
| 71
| 0.689094
|
phoenixzz
|
de4b3c28b3615706104c07e23521a23d4b51738b
| 15,008
|
cc
|
C++
|
mysql-server/router/tests/helpers/router_test_helpers.cc
|
silenc3502/MYSQL-Arch-Doc-Summary
|
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
|
[
"MIT"
] | null | null | null |
mysql-server/router/tests/helpers/router_test_helpers.cc
|
silenc3502/MYSQL-Arch-Doc-Summary
|
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
|
[
"MIT"
] | null | null | null |
mysql-server/router/tests/helpers/router_test_helpers.cc
|
silenc3502/MYSQL-Arch-Doc-Summary
|
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
|
[
"MIT"
] | null | null | null |
/*
Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
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, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "router_test_helpers.h"
#include <cassert>
#include <cerrno>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <regex>
#include <stdexcept>
#include <thread>
#ifndef _WIN32
#include <sys/socket.h>
#include <unistd.h>
#else
#include <direct.h>
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#define getcwd _getcwd
#endif
#include "keyring/keyring_manager.h"
#include "my_inttypes.h" // ssize_t
#include "mysql/harness/filesystem.h"
#include "mysqlrouter/mysql_session.h"
#include "mysqlrouter/utils.h"
using mysql_harness::Path;
using namespace std::chrono_literals;
Path get_cmake_source_dir() {
Path result;
// PB2 specific source location
char *env_pb2workdir = std::getenv("PB2WORKDIR");
char *env_sourcename = std::getenv("SOURCENAME");
char *env_tmpdir = std::getenv("TMPDIR");
if ((env_pb2workdir && env_sourcename && env_tmpdir) &&
(strlen(env_pb2workdir) && strlen(env_tmpdir) &&
strlen(env_sourcename))) {
result = Path(env_tmpdir);
result.append(Path(env_sourcename));
if (result.exists()) {
return result;
}
}
char *env_value = std::getenv("CMAKE_SOURCE_DIR");
if (env_value == nullptr) {
// try a few places
result = Path(get_cwd()).join("..");
result = Path(result).real_path();
} else {
result = Path(env_value).real_path();
}
if (!result.join("src")
.join("router")
.join("src")
.join("router_app.cc")
.is_regular()) {
throw std::runtime_error(
"Source directory not available. Use CMAKE_SOURCE_DIR environment "
"variable; was " +
result.str());
}
return result;
}
Path get_envvar_path(const std::string &envvar, Path alternative = Path()) {
char *env_value = std::getenv(envvar.c_str());
Path result;
if (env_value == nullptr) {
result = alternative;
} else {
result = Path(env_value).real_path();
}
return result;
}
const std::string get_cwd() {
char buffer[FILENAME_MAX];
if (!getcwd(buffer, FILENAME_MAX)) {
throw std::runtime_error("getcwd failed: " + std::string(strerror(errno)));
}
return std::string(buffer);
}
const std::string change_cwd(std::string &dir) {
auto cwd = get_cwd();
#ifndef _WIN32
if (chdir(dir.c_str()) == -1) {
#else
if (!SetCurrentDirectory(dir.c_str())) {
#endif
throw std::runtime_error("chdir failed: " + mysqlrouter::get_last_error());
}
return cwd;
}
size_t read_bytes_with_timeout(int sockfd, void *buffer, size_t n_bytes,
uint64_t timeout_in_ms) {
// returns epoch time (aka unix time, etc), expressed in milliseconds
auto get_epoch_in_ms = []() -> uint64_t {
using namespace std::chrono;
time_point<system_clock> now = system_clock::now();
return static_cast<uint64_t>(
duration_cast<milliseconds>(now.time_since_epoch()).count());
};
// calculate deadline time
uint64_t now_in_ms = get_epoch_in_ms();
uint64_t deadline_epoch_in_ms = now_in_ms + timeout_in_ms;
// read until 1 of 3 things happen: enough bytes were read, we time out or
// read() fails
size_t bytes_read = 0;
while (true) {
#ifndef _WIN32
ssize_t res = read(sockfd, static_cast<char *>(buffer) + bytes_read,
n_bytes - bytes_read);
#else
WSASetLastError(0);
ssize_t res = recv(sockfd, static_cast<char *>(buffer) + bytes_read,
n_bytes - bytes_read, 0);
#endif
if (res == 0) { // reached EOF?
return bytes_read;
}
if (get_epoch_in_ms() > deadline_epoch_in_ms) {
throw std::runtime_error("read() timed out");
}
if (res == -1) {
#ifndef _WIN32
if (errno != EAGAIN) {
throw std::runtime_error(std::string("read() failed: ") +
strerror(errno));
}
#else
int err_code = WSAGetLastError();
if (err_code != 0) {
throw std::runtime_error("recv() failed with error: " +
get_last_error(err_code));
}
#endif
} else {
bytes_read += static_cast<size_t>(res);
if (bytes_read >= n_bytes) {
assert(bytes_read == n_bytes);
return bytes_read;
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
#ifdef _WIN32
std::string get_last_error(int err_code) {
char message[512];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_ALLOCATE_BUFFER,
nullptr, err_code, LANG_NEUTRAL, message, sizeof(message),
nullptr);
return std::string(message);
}
#endif
void init_windows_sockets() {
#ifdef _WIN32
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != 0) {
std::cerr << "WSAStartup() failed\n";
exit(1);
}
#endif
}
bool pattern_found(const std::string &s, const std::string &pattern) {
bool result = false;
try {
std::smatch m;
std::regex r(pattern);
result = std::regex_search(s, m, r);
} catch (const std::regex_error &e) {
std::cerr << ">" << e.what();
}
return result;
}
namespace {
#ifndef _WIN32
int close_socket(int sock) {
::shutdown(sock, SHUT_RDWR);
return close(sock);
}
#else
int close_socket(SOCKET sock) {
::shutdown(sock, SD_BOTH);
return closesocket(sock);
}
#endif
} // namespace
bool wait_for_port_ready(uint16_t port, std::chrono::milliseconds timeout,
const std::string &hostname) {
struct addrinfo hints, *ainfo;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
auto step_ms = 10ms;
// Valgrind needs way more time
if (getenv("WITH_VALGRIND")) {
timeout *= 10;
step_ms *= 10;
}
int status = getaddrinfo(hostname.c_str(), std::to_string(port).c_str(),
&hints, &ainfo);
if (status != 0) {
throw std::runtime_error(
std::string("wait_for_port_ready(): getaddrinfo() failed: ") +
gai_strerror(status));
}
std::shared_ptr<void> exit_freeaddrinfo(nullptr,
[&](void *) { freeaddrinfo(ainfo); });
const auto started = std::chrono::steady_clock::now();
do {
auto sock_id =
socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol);
if (sock_id < 0) {
throw std::runtime_error("wait_for_port_ready(): socket() failed: " +
std::to_string(mysqlrouter::get_socket_errno()));
}
std::shared_ptr<void> exit_close_socket(
nullptr, [&](void *) { close_socket(sock_id); });
#ifdef _WIN32
// On Windows if the port is not ready yet when we try the connect() first
// time it will block for 500ms (depends on the OS wide configuration) and
// retry again internally. Here we sleep for 100ms but will save this 500ms
// for most of the cases which is still a good deal
std::this_thread::sleep_for(100ms);
#endif
status = connect(sock_id, ainfo->ai_addr, ainfo->ai_addrlen);
if (status < 0) {
// if the address is not available, it is a client side problem.
#ifdef _WIN32
if (WSAGetLastError() == WSAEADDRNOTAVAIL) {
throw std::system_error(mysqlrouter::get_socket_errno(),
std::system_category());
}
#else
if (errno == EADDRNOTAVAIL) {
throw std::system_error(mysqlrouter::get_socket_errno(),
std::generic_category());
}
#endif
const auto step = std::min(timeout, step_ms);
std::this_thread::sleep_for(std::chrono::milliseconds(step));
timeout -= step;
}
} while (status < 0 && timeout > std::chrono::steady_clock::now() - started);
return status >= 0;
}
void init_keyring(std::map<std::string, std::string> &default_section,
const std::string &keyring_dir,
const std::string &user /*= "mysql_router1_user"*/,
const std::string &password /*= "root"*/) {
// init keyring
const std::string masterkey_file = Path(keyring_dir).join("master.key").str();
const std::string keyring_file = Path(keyring_dir).join("keyring").str();
mysql_harness::init_keyring(keyring_file, masterkey_file, true);
mysql_harness::Keyring *keyring = mysql_harness::get_keyring();
keyring->store(user, "password", password);
mysql_harness::flush_keyring();
mysql_harness::reset_keyring();
// add relevant config settings to [DEFAULT] section
default_section["keyring_path"] = keyring_file;
default_section["master_key_path"] = masterkey_file;
}
namespace {
bool real_find_in_file(
const std::string &file_path,
const std::function<bool(const std::string &)> &predicate,
std::ifstream &in_file, std::streampos &cur_pos) {
if (!in_file.is_open()) {
in_file.clear();
Path file(file_path);
in_file.open(file.c_str(), std::ifstream::in);
if (!in_file) {
throw std::runtime_error("Error opening file " + file.str());
}
cur_pos = in_file.tellg(); // initialize properly
} else {
// set current position to the end of what was already read
in_file.clear();
in_file.seekg(cur_pos);
}
std::string line;
while (std::getline(in_file, line)) {
cur_pos = in_file.tellg();
if (predicate(line)) {
return true;
}
}
return false;
}
} // namespace
bool find_in_file(const std::string &file_path,
const std::function<bool(const std::string &)> &predicate,
std::chrono::milliseconds sleep_time) {
const auto STEP = std::chrono::milliseconds(100);
std::ifstream in_file;
std::streampos cur_pos;
do {
try {
// This is proxy function to account for the fact that I/O can sometimes
// be slow.
if (real_find_in_file(file_path, predicate, in_file, cur_pos))
return true;
} catch (const std::runtime_error &) {
// report I/O error only on the last attempt
if (sleep_time == std::chrono::milliseconds(0)) {
std::cerr << " find_in_file() failed, giving up." << std::endl;
throw;
}
}
const auto sleep_for = std::min(STEP, sleep_time);
std::this_thread::sleep_for(sleep_for);
sleep_time -= sleep_for;
} while (sleep_time > std::chrono::milliseconds(0));
return false;
}
std::string get_file_output(const std::string &file_name,
const std::string &file_path,
bool throw_on_error /*=false*/) {
return get_file_output(file_path + "/" + file_name, throw_on_error);
}
std::string get_file_output(const std::string &file_name,
bool throw_on_error /*=false*/) {
Path file(file_name);
std::ifstream in_file;
in_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try {
in_file.open(file.c_str(), std::ifstream::in);
} catch (const std::exception &e) {
const std::string msg =
"Could not open file '" + file.str() + "' for reading: ";
if (throw_on_error)
throw std::runtime_error(msg + e.what());
else
return "<THIS ERROR COMES FROM TEST FRAMEWORK'S get_file_output(), IT IS "
"NOT PART OF PROCESS OUTPUT: " +
msg + e.what() + ">";
}
assert(in_file);
std::string result;
try {
result.assign((std::istreambuf_iterator<char>(in_file)),
std::istreambuf_iterator<char>());
} catch (const std::exception &e) {
const std::string msg = "Reading file '" + file.str() + "' failed: ";
if (throw_on_error)
throw std::runtime_error(msg + e.what());
else
return "<THIS ERROR COMES FROM TEST FRAMEWORK'S get_file_output(), IT IS "
"NOT PART OF PROCESS OUTPUT: " +
msg + e.what() + ">";
}
return result;
}
bool add_line_to_config_file(const std::string &config_path,
const std::string §ion_name,
const std::string &key, const std::string &value) {
std::ifstream config_stream{config_path};
if (!config_stream) return false;
std::vector<std::string> config;
std::string line;
bool found{false};
while (std::getline(config_stream, line)) {
config.push_back(line);
if (line == "[" + section_name + "]") {
config.push_back(key + "=" + value);
found = true;
}
}
config_stream.close();
if (!found) return false;
std::ofstream out_stream{config_path};
if (!out_stream) return false;
std::copy(std::begin(config), std::end(config),
std::ostream_iterator<std::string>(out_stream, "\n"));
out_stream.close();
return true;
}
void connect_client_and_query_port(unsigned router_port, std::string &out_port,
bool should_fail) {
using mysqlrouter::MySQLSession;
MySQLSession client;
if (should_fail) {
try {
client.connect("127.0.0.1", router_port, "username", "password", "", "");
} catch (const std::exception &exc) {
if (std::string(exc.what()).find("Error connecting to MySQL server") !=
std::string::npos) {
out_port = "";
return;
} else
throw;
}
throw std::runtime_error(
"connect_client_and_query_port: did not fail as expected");
} else {
client.connect("127.0.0.1", router_port, "username", "password", "", "");
}
std::unique_ptr<MySQLSession::ResultRow> result{
client.query_one("select @@port")};
if (nullptr == result.get()) {
throw std::runtime_error(
"connect_client_and_query_port: error querying the port");
}
if (1u != result->size()) {
throw std::runtime_error(
"connect_client_and_query_port: wrong number of columns returned " +
std::to_string(result->size()));
}
out_port = std::string((*result)[0]);
}
| 30.566191
| 80
| 0.63666
|
silenc3502
|
de4bb4c00d0cac29cdc3be2ad9870fa1e1ae63dc
| 1,414
|
hpp
|
C++
|
src/meshInfo/geometry.hpp
|
guhanfeng/HSF
|
d2f091e990bb5a18473db0443872e37de6b6a83f
|
[
"Apache-2.0"
] | null | null | null |
src/meshInfo/geometry.hpp
|
guhanfeng/HSF
|
d2f091e990bb5a18473db0443872e37de6b6a83f
|
[
"Apache-2.0"
] | null | null | null |
src/meshInfo/geometry.hpp
|
guhanfeng/HSF
|
d2f091e990bb5a18473db0443872e37de6b6a83f
|
[
"Apache-2.0"
] | null | null | null |
/**
* @file: compute.hpp
* @author: Liu Hongbin
* @brief:
* @date: 2019-11-28 10:39:09
* @last Modified by: lenovo
* @last Modified time: 2019-11-28 16:13:43
*/
#ifndef GEOMETRY_HPP
#define GEOMETRY_HPP
#include <cmath>
#include "utilities.hpp"
namespace HSF
{
// face area
scalar calculateQUADArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
scalar calculateTRIArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
scalar calculateFaceArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes);
// face normal vector
void calculateQUADNormVec(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, scalar* normVec);
void calculateFaceNormVec(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* normVec);
// face center coordinate
void calculateFaceCenter(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* center);
// cell volume
scalar calculateCellVol(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes);
scalar calculateHEXAVol(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
// cell center coordinate
void calculateCellCenter(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* center);
}
#endif
| 27.72549
| 73
| 0.729137
|
guhanfeng
|
de4c177e70eb47fb3e186b53997edc25947c1045
| 3,455
|
cpp
|
C++
|
Laburi/Lab12/p2/lab11p2.cpp
|
teodutu/PA
|
9abaf9f0ebbce8beac274edd672473a17575fe03
|
[
"MIT"
] | 7
|
2019-02-12T15:14:12.000Z
|
2020-05-05T13:48:52.000Z
|
Laburi/Lab12/p2/lab11p2.cpp
|
teodutu/PA
|
9abaf9f0ebbce8beac274edd672473a17575fe03
|
[
"MIT"
] | null | null | null |
Laburi/Lab12/p2/lab11p2.cpp
|
teodutu/PA
|
9abaf9f0ebbce8beac274edd672473a17575fe03
|
[
"MIT"
] | 7
|
2020-03-22T09:46:19.000Z
|
2021-03-11T20:53:19.000Z
|
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <set>
#include <queue>
#include <vector>
#include "State2.h"
class StateComparator {
public:
/* Determina algoritmul folosit. */
enum Algorithm {
AStar,
};
StateComparator(Algorithm algorithm)
: algorithm_(algorithm) { }
int f(State2* state) const{
/* f(n) = g(n) + h(n) */
/* g(n) = numarul de mutari din pozitia initiala */
switch(algorithm_) {
case AStar:
return state->distance() + state->approx_distance();
}
return 0;
}
bool operator() (State2* State1, State2* State2) const {
return f(State1) > f(State2);
}
private:
const Algorithm algorithm_;
};
bool is_explored(std::vector<State2*>& closed, State2& state) {
for (std::vector<State2*>::const_iterator it = closed.begin();
it != closed.end();
++it) {
if (state.has_same_state(**it)) {
return true;
}
}
return false;
}
void remove_state(std::vector<State2*>& closed, State2* state) {
auto it = std::find_if(closed.begin(), closed.end(), [state](State2* s) {
return state->has_same_state(*s);
});
if (it != closed.end()) {
closed.erase(it);
}
}
int main() {
State2* initial_State = new State2();
State2* solution_State = new State2();
initial_State->m_e = 3;
initial_State->m_v = 0;
initial_State->c_e = 3;
initial_State->c_v = 0;
initial_State->position = State2::E;
solution_State->m_e = 0;
solution_State->m_v = 3;
solution_State->c_e = 0;
solution_State->c_v = 3;
solution_State->position = State2::V;
std::cout << "initial point " << *initial_State << std::endl;
std::cout << "final point " << *solution_State << std::endl;
/* Pentru nodurile in curs de explorare, implementate ca o coada de
* prioritati. */
std::priority_queue<State2*, std::vector<State2*>, StateComparator> open(
StateComparator(StateComparator::AStar));
/* Initial doar nodul de start este in curs de explorare. */
initial_State->set_distance(0);
initial_State->set_parent(NULL);
open.push(initial_State);
/* Pentru nodurile care au fost deja expandate. */
std::vector<State2*> closed;
std::vector<State2*> next_states;
State2* crt_state;
/* Numar de pasi pana la solutie */
int steps = 0;
/*TODO: A* */
closed.emplace_back(initial_State);
open.emplace(initial_State);
while (!open.empty()) {
crt_state = open.top();
open.pop();
next_states.clear();
if (crt_state->has_same_state(*solution_State)) {
crt_state->print_path();
break;
}
crt_state->expand(next_states);
closed.emplace_back(crt_state);
for (State2* next_state : next_states) {
if (!is_explored(closed, *next_state)) {
// closed.emplace_back(next_state);
next_state->set_distance(crt_state->distance() + 1);
next_state->set_parent(crt_state);
open.emplace(next_state);
} else if (crt_state->distance() + 1 > next_state->distance()) {
remove_state(closed, next_state);
next_state->set_distance(crt_state->distance() + 1);
next_state->set_parent(crt_state);
open.emplace(next_state);
}
}
}
std::cout << "Numarul de pasi pana la solutie: " << steps << std::endl;
return 0;
}
| 25.592593
| 77
| 0.611288
|
teodutu
|
de4dc80505f378ad0c688b4bd30bc1c4e8f56282
| 21,265
|
cpp
|
C++
|
hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp
|
RivuletStudio/vaa3d_tools
|
58c267d4731df9a71e596200c45e9634aea8491c
|
[
"MIT"
] | null | null | null |
hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp
|
RivuletStudio/vaa3d_tools
|
58c267d4731df9a71e596200c45e9634aea8491c
|
[
"MIT"
] | 1
|
2016-12-03T05:33:13.000Z
|
2016-12-03T05:33:13.000Z
|
hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp
|
RivuletStudio/vaa3d_tools
|
58c267d4731df9a71e596200c45e9634aea8491c
|
[
"MIT"
] | null | null | null |
/* mapping3D_swc_plugin.cpp
* This is a test plugin, you can use it as a demo.
* 2015-6-25 : by Zhi Zhou
*/
#include "v3d_message.h"
#include <vector>
#include "mapping3D_swc_plugin.h"
#include "openSWCDialog.h"
#include "../neurontracing_mip/my_surf_objs.h"
#include "../neurontracing_mip/smooth_curve.h"
#include "../neurontracing_mip/fastmarching_linker.h"
#include "../APP2_large_scale/readRawfile_func.h"
using namespace std;
Q_EXPORT_PLUGIN2(mapping3D_swc, mapping3D_swc);
QStringList mapping3D_swc::menulist() const
{
return QStringList()
<<tr("mapping")
<<tr("about");
}
QStringList mapping3D_swc::funclist() const
{
return QStringList()
<<tr("func1")
<<tr("help");
}
struct Point;
struct Point
{
double x,y,z,r;
V3DLONG type;
Point* p;
V3DLONG childNum;
};
typedef vector<Point*> Segment;
typedef vector<Point*> Tree;
bool map3Dfunc(NeuronTree nt,unsigned char * &data1d, V3DLONG N, V3DLONG M,V3DLONG P,vector<MyMarker*> & outswc_final);
bool map3Dfunc_raw(NeuronTree nt,string &image_name,vector<MyMarker*> & outswc_final);
void mapping3D_swc::domenu(const QString &menu_name, V3DPluginCallback2 &callback, QWidget *parent)
{
if (menu_name == tr("mapping"))
{
v3dhandle curwin = callback.currentImageWindow();
if (!curwin)
{
QMessageBox::information(0, "", "You don't have any image open in the main window.");
return;
}
Image4DSimple* p4DImage = callback.getImage(curwin);
if (!p4DImage)
{
QMessageBox::information(0, "", "The image pointer is invalid. Ensure your data is valid and try again!");
return;
}
unsigned char* data1d = p4DImage->getRawData();
V3DLONG pagesz = p4DImage->getTotalUnitNumberPerChannel();
QString image_name = callback.getImageName(curwin);
V3DLONG N = p4DImage->getXDim();
V3DLONG M = p4DImage->getYDim();
V3DLONG P = p4DImage->getZDim();
V3DLONG sc = p4DImage->getCDim();
// int mip_plane = 0;
OpenSWCDialog * openDlg = new OpenSWCDialog(0, &callback);
if (!openDlg->exec())
return;
NeuronTree nt = openDlg->nt;
vector<MyMarker*> outswc_final;
if(map3Dfunc(nt, data1d, N,M,P,outswc_final))
{
QString final_swc = openDlg->file_name + "_3D.swc"; ;
saveSWC_file(final_swc.toStdString(), outswc_final);
v3d_msg(QString("Now you can drag and drop the generated swc fle [%1] into Vaa3D.").arg(final_swc.toStdString().c_str()));
}
}
// V3DLONG siz = nt.listNeuron.size();
// Tree tree;
// for (V3DLONG i=0;i<siz;i++)
// {
// NeuronSWC s = nt.listNeuron[i];
// Point* pt = new Point;
// pt->x = s.x;
// pt->y = s.y;
// pt->z = s.z;
// pt->r = s.r;
// pt ->type = s.type;
// pt->p = NULL;
// pt->childNum = 0;
// tree.push_back(pt);
// }
// for (V3DLONG i=0;i<siz;i++)
// {
// if (nt.listNeuron[i].pn<0) continue;
// V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
// tree[i]->p = tree[pid];
// tree[pid]->childNum++;
// }
// vector<Segment*> seg_list;
// for (V3DLONG i=0;i<siz;i++)
// {
// if (tree[i]->childNum!=1)//tip or branch point
// {
// Segment* seg = new Segment;
// Point* cur = tree[i];
// do
// {
// seg->push_back(cur);
// cur = cur->p;
// }
// while(cur && cur->childNum==1);
// seg_list.push_back(seg);
// }
// }
// vector<MyMarker*> outswc;
// vector<MyMarker*> outswc_final;
// for (V3DLONG i=0;i<seg_list.size();i++)
// {
// vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
// nearpos_vec.clear();
// farpos_vec.clear();
// if(seg_list[i]->size() > 2)
// {
// for (V3DLONG j=0;j<seg_list[i]->size();j++)
// {
// Point* node = seg_list[i]->at(j);
// XYZ loc0_t, loc1_t;
// loc0_t = XYZ(node->x, node->y, node->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node->x, node->y, P-1); break;
// case 1: loc1_t = XYZ(node->x, M-1, node->z); break;
// case 2: loc1_t = XYZ(N-1, node->y, node->z); break;
// default:
// return;
// }
// XYZ loc0 = loc0_t;
// XYZ loc1 = loc1_t;
// nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
// farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
// }
// fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
// smooth_curve(outswc,5);
// for(V3DLONG d = 0; d <outswc.size(); d++)
// {
// outswc[d]->radius = 2;
// outswc[d]->type = 2;
// outswc_final.push_back(outswc[d]);
// }
// outswc.clear();
// }
// else if(seg_list[i]->size() == 2)
// {
// Point* node1 = seg_list[i]->at(0);
// Point* node2 = seg_list[i]->at(1);
// for (V3DLONG j=0;j<3;j++)
// {
// XYZ loc0_t, loc1_t;
// if(j ==0)
// {
// loc0_t = XYZ(node1->x, node1->y, node1->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node1->x, node1->y, P-1); break;
// case 1: loc1_t = XYZ(node1->x, M-1, node1->z); break;
// case 2: loc1_t = XYZ(N-1, node1->y, node1->z); break;
// default:
// return;
// }
// }
// else if(j ==1)
// {
// loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1); break;
// case 1: loc1_t = XYZ(0.5*(node1->x + node2->x), M-1, 0.5*(node1->z + node2->z)); break;
// case 2: loc1_t = XYZ(N-1, 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z)); break;
// default:
// return;
// }
// }
// else
// {
// loc0_t = XYZ(node2->x, node2->y, node2->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node2->x, node2->y, P-1); break;
// case 1: loc1_t = XYZ(node2->x, M-1, node2->z); break;
// case 2: loc1_t = XYZ(N-1, node2->y, node2->z); break;
// default:
// return;
// } }
// XYZ loc0 = loc0_t;
// XYZ loc1 = loc1_t;
// nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
// farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
// }
// fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
// smooth_curve(outswc,5);
// for(V3DLONG d = 0; d <outswc.size(); d++)
// {
// outswc[d]->radius = 2;
// outswc[d]->type = 2;
// outswc_final.push_back(outswc[d]);
// }
// outswc.clear();
// }
// }
else
{
v3d_msg(tr("This is a plugin to map 2D tracing back to 3D locations based on 3D image content..."
"Developed by Zhi Zhou, 2015-6-25"));
}
}
bool mapping3D_swc::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent)
{
vector<char*> infiles, inparas, outfiles;
if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p);
if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p);
if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p);
if (func_name == tr("mapping"))
{
if(infiles.size() != 2 && infiles.size() != 3)
{
cerr<<"Invalid input"<<endl;
return false;
}
string inimg_file = infiles[0];
string inswc_file = infiles[1];
string outswc_file = (infiles.size() == 3) ? infiles[2] : "";
if(outswc_file == "") outswc_file = inswc_file + "_3D.swc";
cout<<"inimg_file = "<<inimg_file<<endl;
cout<<"inswc_file = "<<inswc_file<<endl;
cout<<"outswc_file = "<<outswc_file<<endl;
// unsigned char * inimg1d = 0;
// V3DLONG in_sz[4];
// int datatype;
// simple_loadimage_wrapper(callback,const_cast<char *>(inimg_file.c_str()), inimg1d, in_sz, datatype);
// V3DLONG N = in_sz[0];
// V3DLONG M = in_sz[1];
// V3DLONG P = in_sz[2];
NeuronTree nt = readSWC_file(QString(inswc_file.c_str()));
vector<MyMarker*> outswc_final;
//if(map3Dfunc(nt, inimg1d, N,M,P,outswc_final))
if(map3Dfunc_raw(nt, inimg_file,outswc_final))
{
saveSWC_file(outswc_file, outswc_final);
v3d_msg(QString("Now you can drag and drop the generated swc fle [%1] into Vaa3D.").arg(outswc_file.c_str()),0);
}
// if(inimg1d) {delete []inimg1d; inimg1d=0;}
return true;
}
else if (func_name == tr("help"))
{
v3d_msg("To be implemented.");
}
else return false;
return true;
}
bool map3Dfunc(NeuronTree nt,unsigned char * &data1d, V3DLONG N, V3DLONG M,V3DLONG P,vector<MyMarker*> & outswc_final)
{
int mip_plane = 0;
V3DLONG siz = nt.listNeuron.size();
Tree tree;
for (V3DLONG i=0;i<siz;i++)
{
NeuronSWC s = nt.listNeuron[i];
Point* pt = new Point;
pt->x = s.x;
pt->y = s.y;
pt->z = s.z;
pt->r = s.r;
pt ->type = s.type;
pt->p = NULL;
pt->childNum = 0;
tree.push_back(pt);
}
for (V3DLONG i=0;i<siz;i++)
{
if (nt.listNeuron[i].pn<0) continue;
V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
tree[i]->p = tree[pid];
tree[pid]->childNum++;
}
vector<Segment*> seg_list;
for (V3DLONG i=0;i<siz;i++)
{
if (tree[i]->childNum!=1)//tip or branch point
{
Segment* seg = new Segment;
Point* cur = tree[i];
do
{
seg->push_back(cur);
cur = cur->p;
}
while(cur && cur->childNum==1);
seg_list.push_back(seg);
}
}
vector<MyMarker*> outswc;
for (V3DLONG i=0;i<seg_list.size();i++)
{
vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
nearpos_vec.clear();
farpos_vec.clear();
if(seg_list[i]->size() > 2)
{
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
XYZ loc0_t, loc1_t;
loc0_t = XYZ(node->x, node->y, node->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node->x, node->y, P-1); break;
case 1: loc1_t = XYZ(node->x, M-1, node->z); break;
case 2: loc1_t = XYZ(N-1, node->y, node->z); break;
default:
return false;
}
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc_final.push_back(outswc[d]);
}
outswc.clear();
}
else if(seg_list[i]->size() == 2)
{
Point* node1 = seg_list[i]->at(0);
Point* node2 = seg_list[i]->at(1);
for (V3DLONG j=0;j<3;j++)
{
XYZ loc0_t, loc1_t;
if(j ==0)
{
loc0_t = XYZ(node1->x, node1->y, node1->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node1->x, node1->y, P-1); break;
case 1: loc1_t = XYZ(node1->x, M-1, node1->z); break;
case 2: loc1_t = XYZ(N-1, node1->y, node1->z); break;
default:
return false;
}
}
else if(j ==1)
{
loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
switch (mip_plane)
{
case 0: loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1); break;
case 1: loc1_t = XYZ(0.5*(node1->x + node2->x), M-1, 0.5*(node1->z + node2->z)); break;
case 2: loc1_t = XYZ(N-1, 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z)); break;
default:
return false;
}
}
else
{
loc0_t = XYZ(node2->x, node2->y, node2->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node2->x, node2->y, P-1); break;
case 1: loc1_t = XYZ(node2->x, M-1, node2->z); break;
case 2: loc1_t = XYZ(N-1, node2->y, node2->z); break;
default:
return false;
} }
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc_final.push_back(outswc[d]);
}
outswc.clear();
}
}
return true;
}
bool map3Dfunc_raw(NeuronTree nt,string &image_name,vector<MyMarker*> & outswc_final)
{
V3DLONG siz = nt.listNeuron.size();
Tree tree;
for (V3DLONG i=0;i<siz;i++)
{
NeuronSWC s = nt.listNeuron[i];
Point* pt = new Point;
pt->x = s.x;
pt->y = s.y;
pt->z = s.z;
pt->r = s.r;
pt ->type = s.type;
pt->p = NULL;
pt->childNum = 0;
tree.push_back(pt);
}
for (V3DLONG i=0;i<siz;i++)
{
if (nt.listNeuron[i].pn<0) continue;
V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
tree[i]->p = tree[pid];
tree[pid]->childNum++;
}
vector<Segment*> seg_list;
for (V3DLONG i=0;i<siz;i++)
{
if (tree[i]->childNum!=1)//tip or branch point
{
Segment* seg = new Segment;
Point* cur = tree[i];
do
{
seg->push_back(cur);
cur = cur->p;
}
while(cur && cur->childNum==1);
seg_list.push_back(seg);
}
}
vector<MyMarker*> outswc;
unsigned char * data1d = 0;
V3DLONG *im3D_zz = 0;
V3DLONG *im3D_sz = 0;
int datatype;
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,0,0,0,1,1,1))
{
return false;
}
if(data1d) {delete []data1d; data1d = 0;}
V3DLONG N = im3D_zz[0];
V3DLONG M = im3D_zz[1];
V3DLONG P = im3D_zz[2];
for (V3DLONG i=0;i<seg_list.size();i++)
{
V3DLONG xb = N-1;
V3DLONG xe = 0;
V3DLONG yb = M-1;
V3DLONG ye = 0;
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
if(node->x < xb) xb = node->x;
if(node->x > xe) xe = node->x;
if(node->y < yb) yb = node->y;
if(node->y > ye) ye = node->y;
}
vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
nearpos_vec.clear();
farpos_vec.clear();
if(seg_list[i]->size() > 2)
{
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
XYZ loc0_t, loc1_t;
loc0_t = XYZ(node->x, node->y, node->z);
loc1_t = XYZ(node->x, node->y, P-1);
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x - xb, loc0.y - yb, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x - xb, loc1.y - yb, loc1.z));
}
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,xb,yb,0,xe+1,ye+1,P))
{
printf("can not load the region");
if(data1d) {delete []data1d; data1d = 0;}
return false;
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, xe-xb+1,ye-yb+1,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc[d]->x = outswc[d]->x + xb;
outswc[d]->y = outswc[d]->y + yb;
outswc_final.push_back(outswc[d]);
}
if(data1d) {delete []data1d; data1d = 0;}
outswc.clear();
}
else if(seg_list[i]->size() == 2)
{
Point* node1 = seg_list[i]->at(0);
Point* node2 = seg_list[i]->at(1);
for (V3DLONG j=0;j<3;j++)
{
XYZ loc0_t, loc1_t;
if(j ==0)
{
loc0_t = XYZ(node1->x, node1->y, node1->z);
loc1_t = XYZ(node1->x, node1->y, P-1);
}
else if(j ==1)
{
loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1);
}
else
{
loc0_t = XYZ(node2->x, node2->y, node2->z);
loc1_t = XYZ(node2->x, node2->y, P-1);
}
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x - xb, loc0.y - yb, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x - xb, loc1.y - yb, loc1.z));
}
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,xb,yb,0,xe+1,ye+1,P))
{
printf("can not load the region");
if(data1d) {delete []data1d; data1d = 0;}
return false;
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, xe-xb+1,ye-yb+1,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc[d]->x = outswc[d]->x + xb;
outswc[d]->y = outswc[d]->y + yb;
outswc_final.push_back(outswc[d]);
}
if(data1d) {delete []data1d; data1d = 0;}
outswc.clear();
}
}
return true;
}
| 33.541009
| 162
| 0.452104
|
RivuletStudio
|
de4df49971dab4e1d1dcbad2f659886611e8b928
| 4,998
|
cpp
|
C++
|
libs/numeric/interval/examples/io.cpp
|
cpp-pm/boost
|
38c6c8c07f2fcc42d573b10807fef27ec14930f8
|
[
"BSL-1.0"
] | 12,278
|
2015-01-29T17:11:33.000Z
|
2022-03-31T21:12:00.000Z
|
libs/numeric/interval/examples/io.cpp
|
cpp-pm/boost
|
38c6c8c07f2fcc42d573b10807fef27ec14930f8
|
[
"BSL-1.0"
] | 9,469
|
2015-01-30T05:33:07.000Z
|
2022-03-31T16:17:21.000Z
|
libs/numeric/interval/examples/io.cpp
|
cpp-pm/boost
|
38c6c8c07f2fcc42d573b10807fef27ec14930f8
|
[
"BSL-1.0"
] | 1,343
|
2017-12-08T19:47:19.000Z
|
2022-03-26T11:31:36.000Z
|
/* Boost examples/io.cpp
* show some exampleso of i/o operators
* thanks to all the people who commented on this point, particularly on
* the Boost mailing-list
*
* Copyright 2003 Guillaume Melquiond
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or
* copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/numeric/interval.hpp>
#include <boost/io/ios_state.hpp>
#include <cmath>
#include <cassert>
namespace io_std {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "[]";
} else {
return stream << '[' << lower(value) << ',' << upper(value) << ']';
}
}
} // namespace io_std
namespace io_sngl {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "[]";
} else if (singleton(value)) {
return stream << '[' << lower(value) << ']';
} else {
return stream << '[' << lower(value) << ',' << upper(value) << ']';
}
}
} // namespace io_sngl
namespace io_wdth {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "nothing";
} else {
return stream << median(value) << " ± " << width(value) / 2;
}
}
} // namespace io_wdth
namespace io_prec {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "nothing";
} else if (singleton(value)) {
boost::io::ios_precision_saver state(stream, std::numeric_limits<T>::digits10);
return stream << lower(value);
} else if (zero_in(value)) {
return stream << "0~";
} else {
const T rel = width(value) / norm(value);
int range = - (int)std::log10(rel);
boost::io::ios_precision_saver state(stream, range);
return stream << median(value);
}
}
} // namespace io_prec
namespace io_wide {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "nothing";
} else if (singleton(value)) {
boost::io::ios_precision_saver state(stream, std::numeric_limits<T>::digits10);
return stream << lower(value);
} else if (zero_in(value)) {
return stream << "0~";
} else {
std::streamsize p = stream.precision();
// FIXME poor man's power of 10, only up to 1E-15
p = (p > 15) ? 15 : p - 1;
double eps = 1.0; for(; p > 0; --p) { eps /= 10; }
T eps2 = static_cast<T>(eps / 2) * norm(value);
boost::numeric::interval<T, Policies> r = widen(value, eps2);
return stream << '[' << lower(r) << ',' << upper(r) << ']';
}
}
} // namespace io_wide
template<class T, class Policies, class CharType, class CharTraits> inline
std::basic_istream<CharType, CharTraits> &operator>>
(std::basic_istream<CharType, CharTraits> &stream,
boost::numeric::interval<T, Policies> &value)
{
T l, u;
char c = 0;
stream >> c;
if (c == '[') {
stream >> l >> c;
if (c == ',') stream >> u >> c; else u = l;
if (c != ']') stream.setstate(stream.failbit);
} else {
stream.putback(c);
stream >> l;
u = l;
}
if (stream)
value.assign(l, u);
else
value = boost::numeric::interval<T, Policies>::empty();
return stream;
}
// Test program
#include <iostream>
int main()
{
using namespace boost;
using namespace numeric;
using namespace interval_lib;
typedef interval<double,
policies<rounded_math<double>,
checking_base<double> > > I;
I tab[] = { I::empty(), I(1,1), I(1,2), I(-1,1), I(12.34,12.35),
I(1234.56,1234.57), I(123456.78, 123456.79), I::empty() };
unsigned int len = sizeof(tab) / sizeof(I);
std::cout << "Enter an interval: (it will be the last shown)\n";
std::cin >> tab[len - 1];
for(unsigned int i = 0; i < len; ++i) {
{ using namespace io_std; std::cout << tab[i] << '\n'; }
{ using namespace io_sngl; std::cout << tab[i] << '\n'; }
{ using namespace io_wdth; std::cout << tab[i] << '\n'; }
{ using namespace io_prec; std::cout << tab[i] << '\n'; }
{ using namespace io_wide; std::cout << tab[i] << '\n'; }
std::cout << '\n';
}
}
| 28.890173
| 83
| 0.627251
|
cpp-pm
|
de4f2c08e0ce27edb82f5bf71f7a60466fea9d61
| 3,530
|
cpp
|
C++
|
android-31/java/security/cert/CertificateFactory.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 12
|
2020-03-26T02:38:56.000Z
|
2022-03-14T08:17:26.000Z
|
android-31/java/security/cert/CertificateFactory.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 1
|
2021-01-27T06:07:45.000Z
|
2021-11-13T19:19:43.000Z
|
android-29/java/security/cert/CertificateFactory.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 3
|
2021-02-02T12:34:55.000Z
|
2022-03-08T07:45:57.000Z
|
#include "../../io/InputStream.hpp"
#include "../../../JString.hpp"
#include "../Provider.hpp"
#include "./CRL.hpp"
#include "./CertPath.hpp"
#include "./Certificate.hpp"
#include "./CertificateFactorySpi.hpp"
#include "./CertificateFactory.hpp"
namespace java::security::cert
{
// Fields
// QJniObject forward
CertificateFactory::CertificateFactory(QJniObject obj) : JObject(obj) {}
// Constructors
// Methods
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>()
);
}
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0, JString arg1)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>(),
arg1.object<jstring>()
);
}
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0, java::security::Provider arg1)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;Ljava/security/Provider;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>(),
arg1.object()
);
}
java::security::cert::CRL CertificateFactory::generateCRL(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCRL",
"(Ljava/io/InputStream;)Ljava/security/cert/CRL;",
arg0.object()
);
}
JObject CertificateFactory::generateCRLs(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCRLs",
"(Ljava/io/InputStream;)Ljava/util/Collection;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/io/InputStream;)Ljava/security/cert/CertPath;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(JObject arg0) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/util/List;)Ljava/security/cert/CertPath;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(java::io::InputStream arg0, JString arg1) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/io/InputStream;Ljava/lang/String;)Ljava/security/cert/CertPath;",
arg0.object(),
arg1.object<jstring>()
);
}
java::security::cert::Certificate CertificateFactory::generateCertificate(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertificate",
"(Ljava/io/InputStream;)Ljava/security/cert/Certificate;",
arg0.object()
);
}
JObject CertificateFactory::generateCertificates(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertificates",
"(Ljava/io/InputStream;)Ljava/util/Collection;",
arg0.object()
);
}
JObject CertificateFactory::getCertPathEncodings() const
{
return callObjectMethod(
"getCertPathEncodings",
"()Ljava/util/Iterator;"
);
}
java::security::Provider CertificateFactory::getProvider() const
{
return callObjectMethod(
"getProvider",
"()Ljava/security/Provider;"
);
}
JString CertificateFactory::getType() const
{
return callObjectMethod(
"getType",
"()Ljava/lang/String;"
);
}
} // namespace java::security::cert
| 27.364341
| 118
| 0.724363
|
YJBeetle
|
de53b158c280826d87aad3d27c95fcec1b745b1a
| 4,999
|
cc
|
C++
|
modules/canbus/vehicle/wey/protocol/fail_241.cc
|
Shokoofeh/apollo
|
71d6ea753b4595eb38cc54d6650c8de677b173df
|
[
"Apache-2.0"
] | 2
|
2019-02-21T05:52:59.000Z
|
2019-07-27T03:24:16.000Z
|
modules/canbus/vehicle/wey/protocol/fail_241.cc
|
Shokoofeh/apollo
|
71d6ea753b4595eb38cc54d6650c8de677b173df
|
[
"Apache-2.0"
] | null | null | null |
modules/canbus/vehicle/wey/protocol/fail_241.cc
|
Shokoofeh/apollo
|
71d6ea753b4595eb38cc54d6650c8de677b173df
|
[
"Apache-2.0"
] | 1
|
2021-12-03T23:30:00.000Z
|
2021-12-03T23:30:00.000Z
|
/******************************************************************************
* Copyright 2019 The Apollo Authors. 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.
*****************************************************************************/
#include "modules/canbus/vehicle/wey/protocol/fail_241.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"
namespace apollo {
namespace canbus {
namespace wey {
using ::apollo::drivers::canbus::Byte;
Fail241::Fail241() {}
const int32_t Fail241::ID = 0x241;
void Fail241::Parse(const std::uint8_t* bytes, int32_t length,
ChassisDetail* chassis) const {
chassis->mutable_wey()->mutable_fail_241()->
set_engfail(engfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_espfail(espfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_epbfail(epbfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_shiftfail(shiftfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_epsfail(epsfail(bytes, length));
}
// config detail: {'description': 'Engine Fail status', 'enum': {0:
// 'ENGFAIL_NO_FAIL', 1: 'ENGFAIL_FAIL'}, 'precision': 1.0, 'len': 1, 'name':
// 'engfail', 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]',
// 'bit': 7, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EngfailType Fail241::engfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(7, 1);
Fail_241::EngfailType ret = static_cast<Fail_241::EngfailType>(x);
return ret;
}
// config detail: {'description': 'ESP fault', 'enum': {0:'ESPFAIL_NO_FAILURE',
// 1: 'ESPFAIL_FAILURE'}, 'precision': 1.0, 'len': 1, 'name': 'espfail',
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 14,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EspfailType Fail241::espfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(6, 1);
Fail_241::EspfailType ret = static_cast<Fail_241::EspfailType>(x);
return ret;
}
// config detail: {'description': 'error indication of EPB system', 'enum': {0:
// 'EPBFAIL_UNDEFINED', 1: 'EPBFAIL_NO_ERROR', 2: 'EPBFAIL_ERROR', 3:
// 'EPBFAIL_DIAGNOSIS'}, 'precision': 1.0, 'len': 2, 'name': 'epbfail',
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]', 'bit': 35,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EpbfailType Fail241::epbfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(2, 2);
Fail_241::EpbfailType ret = static_cast<Fail_241::EpbfailType>(x);
return ret;
}
// config detail: {'description': 'Driver display failure messages', 'enum': {0:
// 'SHIFTFAIL_NO_FAIL', 1: 'SHIFTFAIL_TRANSMISSION_MALFUNCTION', 2:
// 'SHIFTFAIL_TRANSMISSION_P_ENGAGEMENT_FAULT', 3:
// 'SHIFTFAIL_TRANSMISSION_P_DISENGAGEMENT_FAULT', 4: 'SHIFTFAIL_RESERVED',
// 15: 'SHIFTFAIL_TRANSMISSION_LIMIT_FUNCTION'}, 'precision': 1.0, 'len': 4,
// 'name': 'shiftfail', 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|15]', 'bit': 31, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Fail_241::ShiftfailType Fail241::shiftfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 3);
int32_t x = t0.get_byte(4, 4);
Fail_241::ShiftfailType ret = static_cast<Fail_241::ShiftfailType>(x);
return ret;
}
// config detail: {'description': 'Electrical steering fail status', 'enum':
// {0: 'EPSFAIL_NO_FAULT', 1: 'EPSFAIL_FAULT'}, 'precision': 1.0, 'len': 1,
// 'name': 'epsfail', 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 21, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Fail_241::EpsfailType Fail241::epsfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(5, 1);
Fail_241::EpsfailType ret = static_cast<Fail_241::EpsfailType>(x);
return ret;
}
} // namespace wey
} // namespace canbus
} // namespace apollo
| 41.658333
| 80
| 0.625925
|
Shokoofeh
|
de576798f01f3efa2af2b716f5add56391ca2b8f
| 951
|
cpp
|
C++
|
accelerator/stats/test/MonitorTest.cpp
|
Yeolar/accelerator
|
04d36eac69490df9ae71c7cfd71481d83ca51914
|
[
"Apache-2.0"
] | 2
|
2019-05-13T02:34:51.000Z
|
2019-11-14T06:52:44.000Z
|
accelerator/stats/test/MonitorTest.cpp
|
Yeolar/accelerator
|
04d36eac69490df9ae71c7cfd71481d83ca51914
|
[
"Apache-2.0"
] | null | null | null |
accelerator/stats/test/MonitorTest.cpp
|
Yeolar/accelerator
|
04d36eac69490df9ae71c7cfd71481d83ca51914
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright 2018 Yeolar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include "accelerator/stats/test/MonitorTest.h"
using namespace acc;
TEST(monitor, all) {
setupMonitor<TestMonitorKey>("", [](const MonitorBase::Data&) {});
ACCMON_CNT(TestMonitorKey, kTestCnt);
ACCMON_CNT(TestMonitorKey, kTestCnt);
ACCMON_ADD(TestMonitorKey, kTestAvg, 10);
ACCMON_ADD(TestMonitorKey, kTestAvg, 20);
}
| 28.818182
| 75
| 0.737119
|
Yeolar
|
de584d8d2205e07aa38d7dcf7a51f33f803960b8
| 4,690
|
cpp
|
C++
|
drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp
|
houtbrion/AusEx
|
fd74cbab4281da6ba4f285412f2d1f53f40206c9
|
[
"Apache-1.1"
] | null | null | null |
drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp
|
houtbrion/AusEx
|
fd74cbab4281da6ba4f285412f2d1f53f40206c9
|
[
"Apache-1.1"
] | null | null | null |
drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp
|
houtbrion/AusEx
|
fd74cbab4281da6ba4f285412f2d1f53f40206c9
|
[
"Apache-1.1"
] | null | null | null |
#include "AusExGroveI2cTouchSensor.h"
/*
*
*/
AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS(TwoWire *theWire, int32_t sensorID ){
_i2c_if=theWire;
_sensorID=sensorID;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::begin(uint32_t addr){
_i2c_addr=addr;
_i2c_if->begin();
mpr121Setup();
return true;
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::mpr121Setup() {
// Section A - Controls filtering when data is > baseline.
write(MHD_R, 0x01);
write(NHD_R, 0x01);
write(NCL_R, 0x00);
write(FDL_R, 0x00);
// Section B - Controls filtering when data is < baseline.
write(MHD_F, 0x01);
write(NHD_F, 0x01);
write(NCL_F, 0xFF);
write(FDL_F, 0x02);
// Section C - Sets touch and release thresholds for each electrode
write(ELE0_T, TOU_THRESH);
write(ELE0_R, REL_THRESH);
write(ELE1_T, TOU_THRESH);
write(ELE1_R, REL_THRESH);
write(ELE2_T, TOU_THRESH);
write(ELE2_R, REL_THRESH);
write(ELE3_T, TOU_THRESH);
write(ELE3_R, REL_THRESH);
write(ELE4_T, TOU_THRESH);
write(ELE4_R, REL_THRESH);
write(ELE5_T, TOU_THRESH);
write(ELE5_R, REL_THRESH);
write(ELE6_T, TOU_THRESH);
write(ELE6_R, REL_THRESH);
write(ELE7_T, TOU_THRESH);
write(ELE7_R, REL_THRESH);
write(ELE8_T, TOU_THRESH);
write(ELE8_R, REL_THRESH);
write(ELE9_T, TOU_THRESH);
write(ELE9_R, REL_THRESH);
write(ELE10_T, TOU_THRESH);
write(ELE10_R, REL_THRESH);
write(ELE11_T, TOU_THRESH);
write(ELE11_R, REL_THRESH);
// Section D
// Set the Filter Configuration
// Set ESI2
write(FIL_CFG, 0x04);
//set_register(0x5A,ATO_CFGU, 0xC9); // USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V mpr121Write(ATO_CFGL, 0x82); // LSL = 0.65*USL = 0x82 @3.3V
//set_register(0x5A,ATO_CFGL, 0x82); // Target = 0.9*USL = 0xB5 @3.3V
//set_register(0x5A,ATO_CFGT,0xb5);
//set_register(0x5A,ATO_CFG0, 0x1B);
// Section E
// Electrode Configuration
// Set ELE_CFG to 0x00 to return to standby mode
write(ELE_CFG, 0x0C); // Enables all 12 Electrodes
// Section F
// Enable Auto Config and auto Reconfig
//write(ATO_CFG0, 0x0B);
//write(ATO_CFGU, 0xC9); // USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V
//write(ATO_CFGL, 0x82); // LSL = 0.65*USL = 0x82 @3.3V
//write(ATO_CFGT, 0xB5); // Target = 0.9*USL = 0xB5 @3.3V
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::write(uint8_t _register, uint8_t _data)
{
//_i2c_addr->begin();
_i2c_if->beginTransmission(_i2c_addr);
_i2c_if->write(_register);
_i2c_if->write(_data);
_i2c_if->endTransmission();
}
int8_t AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::read(uint8_t _register)
{
int8_t data;
_i2c_if->beginTransmission(_i2c_addr);
_i2c_if->write(_register);
_i2c_if->endTransmission();
_i2c_if->requestFrom(_i2c_addr, 1);
if(_i2c_if->available() > 0){
data = _i2c_if->read();
}
_i2c_if->endTransmission();
return data;
}
int16_t AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::readLong()
{
uint8_t l,h;
_i2c_if->requestFrom(_i2c_addr, 2);
l = _i2c_if->read();
h = _i2c_if->read();
return (h << 8) | l;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getEvent(sensors_event_t* event){
/* Clear the event */
memset(event, 0, sizeof(sensors_event_t));
event->size = sizeof(sensors_event_t);
event->sensor_id = _sensorID;
event->type = AUSEX_GROVE_I2C_TOUCH_SENSOR_TYPE;
event->timestamp = millis();
/* Calculate the actual lux value */
event->AUSEX_GROVE_I2C_TOUCH_SENSOR_RETURN_VALUE = readLong();
return true;
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getSensor(sensor_t* sensor){
/* Clear the sensor_t object */
memset(sensor, 0, sizeof(sensor_t));
/* Insert the sensor name in the fixed length char array */
strncpy (sensor->name, AUSEX_GROVE_I2C_TOUCH_SENSOR_NAME , sizeof(sensor->name) - 1);
sensor->name[sizeof(sensor->name)- 1] = 0;
sensor->version = AUSEX_GROVE_I2C_TOUCH_SENSOR_LIBRARY_VERSION;
sensor->sensor_id = _sensorID;
sensor->type = AUSEX_GROVE_I2C_TOUCH_SENSOR_TYPE;
sensor->min_value = AUSEX_GROVE_I2C_TOUCH_SENSOR_MIN_VALUE;
sensor->max_value = AUSEX_GROVE_I2C_TOUCH_SENSOR_MAX_VALUE;
sensor->resolution = AUSEX_GROVE_I2C_TOUCH_SENSOR_RESOLUTION;
sensor->min_delay = AUSEX_GROVE_I2C_TOUCH_SENSOR_MIN_DELAY;
sensor->init_delay = AUSEX_GROVE_I2C_TOUCH_SENSOR_INIT_DELAY;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::enableAutoRange(bool enabled) {
return false;
}
int AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::setMode(int mode) {
return -1;
}
int AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getMode(void) {
return -1;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getTouchState(AUSEX_GROVE_I2C_TOUCH_SENSOR_VALUE_TYPE val, uint8_t num){
if(val & (1<<num)) return true;
return false;
}
| 30.258065
| 142
| 0.724733
|
houtbrion
|
de5b72aaeb5f997dd3537633617d4e1a3bcdc334
| 533
|
hpp
|
C++
|
src/include/XESystem.hpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 11
|
2017-01-17T15:02:25.000Z
|
2020-11-27T16:54:42.000Z
|
src/include/XESystem.hpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 9
|
2016-10-23T20:15:38.000Z
|
2018-02-06T11:23:17.000Z
|
src/include/XESystem.hpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 2
|
2019-08-29T10:23:51.000Z
|
2020-04-03T06:08:34.000Z
|
#ifndef XE_INTERFACE_SYSTEM_HPP
#define XE_INTERFACE_SYSTEM_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
//#include <XESystem/gkDebugger.h>
#include <XESystem/SystemConfig.hpp>
//#include <ThirdParty/plog/Log.h>
//
//INITIALIZE_EASYLOGGINGPP
#endif // XE_INTERFACE_SYSTEM_HPP
////////////////////////////////////////////////////////////
/// \defgroup system System module
///
////////////////////////////////////////////////////////////
| 28.052632
| 60
| 0.420263
|
devxkh
|
de5c5a7736c29df104cb288dff1dc23cc7a93454
| 1,294
|
cpp
|
C++
|
webrtc-jni/src/main/cpp/src/api/DataBufferFactory.cpp
|
hhgyu/webrtc-java
|
572c3814c94a407cfacdee1e2bc898522063731f
|
[
"Apache-2.0"
] | 110
|
2019-12-25T11:54:02.000Z
|
2022-03-16T06:27:05.000Z
|
webrtc-jni/src/main/cpp/src/api/DataBufferFactory.cpp
|
hhgyu/webrtc-java
|
572c3814c94a407cfacdee1e2bc898522063731f
|
[
"Apache-2.0"
] | 54
|
2020-04-09T06:57:10.000Z
|
2022-03-28T16:29:39.000Z
|
webrtc-jni/src/main/cpp/src/api/DataBufferFactory.cpp
|
internet-of-presence/webrtc-java
|
26ab2091f962533288e2267a16980008d7008528
|
[
"Apache-2.0"
] | 37
|
2019-12-26T10:12:11.000Z
|
2022-03-10T18:06:23.000Z
|
/*
* Copyright 2019 Alex Andres
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "api/DataBufferFactory.h"
#include "JavaUtils.h"
#include "JNI_WebRTC.h"
namespace jni
{
DataBufferFactory::DataBufferFactory(JNIEnv * env, const char * className) :
JavaFactory(env, className, "(" BYTE_BUFFER_SIG "Z)V")
{
}
JavaLocalRef<jobject> DataBufferFactory::create(JNIEnv * env, const webrtc::DataBuffer * dataBuffer)
{
jobject directBuffer = env->NewDirectByteBuffer(const_cast<char *>(dataBuffer->data.data<char>()), dataBuffer->data.size());
const jboolean isBinary = static_cast<jboolean>(dataBuffer->binary);
jobject object = env->NewObject(javaClass, javaCtor, directBuffer, isBinary);
ExceptionCheck(env);
return JavaLocalRef<jobject>(env, object);
}
}
| 34.052632
| 126
| 0.742658
|
hhgyu
|
de5ce2395e0a1a352fadf0042b3eec426822b9f2
| 1,106
|
hh
|
C++
|
nel/src/memory.hh
|
jwebb68/nel
|
a5bfe9038921448da52cdeeba45984a54d79423c
|
[
"MIT"
] | null | null | null |
nel/src/memory.hh
|
jwebb68/nel
|
a5bfe9038921448da52cdeeba45984a54d79423c
|
[
"MIT"
] | null | null | null |
nel/src/memory.hh
|
jwebb68/nel
|
a5bfe9038921448da52cdeeba45984a54d79423c
|
[
"MIT"
] | null | null | null |
#ifndef NEL_MEMORY_HH
#define NEL_MEMORY_HH
#include <cstdint> // uint8_t
#include <cstddef> // size_t
#include <utility> // std::move, std::swap
namespace nel {
void memcpy(uint8_t *const d, uint8_t const *const s, size_t const n) noexcept;
void memset(uint8_t *const d, uint8_t const s, size_t const n) noexcept;
void memmove(uint8_t *const d, uint8_t *const s, size_t const n) noexcept;
void memswap(uint8_t *const d, uint8_t *const s, size_t const n) noexcept;
template<typename T>
void memmove(T *d, T *s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = std::move(s[i]);
}
}
template<typename T>
void memcpy(T *const d, T const *const s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = s[i];
}
}
template<typename T>
void memset(T *const d, T const &s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = s;
}
}
template<typename T>
void memswap(T *const d, T *const s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
std::swap(*d, *s);
}
}
} // namespace nel
#endif//NEL_MEMORY_HH
| 20.109091
| 79
| 0.618445
|
jwebb68
|
de60633e2d2eb8f8099ed123e45c1e17d7d1892b
| 227
|
hpp
|
C++
|
CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp
|
Electrux/CCPP-Code
|
3c5e5b866cf050c11bced9651b112eb31dd2465d
|
[
"BSD-3-Clause"
] | 6
|
2019-08-29T23:31:17.000Z
|
2021-11-14T20:35:47.000Z
|
CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp
|
Electrux/CCPP-Code
|
3c5e5b866cf050c11bced9651b112eb31dd2465d
|
[
"BSD-3-Clause"
] | null | null | null |
CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp
|
Electrux/CCPP-Code
|
3c5e5b866cf050c11bced9651b112eb31dd2465d
|
[
"BSD-3-Clause"
] | 1
|
2019-09-01T12:22:58.000Z
|
2019-09-01T12:22:58.000Z
|
#ifndef PROJECTFILEGENERATOR_HPP
#define PROJECTFILEGENERATOR_HPP
#include "ProjectData.hpp"
#include "FSFuncs.hpp"
#include "ConfigMgr.hpp"
int GenerateProjectFiles( ProjectData & data );
#endif // PROJECTFILEGENERATOR_HPP
| 20.636364
| 47
| 0.810573
|
Electrux
|
de6207b4dcb7fcfddaae34e792c0b597dfc72b3a
| 3,378
|
hpp
|
C++
|
include/RaZ/Math/MathUtils.hpp
|
Sausty/RaZ
|
211cc1c0c4a7374520a3141fc069b7717e2e5e0f
|
[
"MIT"
] | null | null | null |
include/RaZ/Math/MathUtils.hpp
|
Sausty/RaZ
|
211cc1c0c4a7374520a3141fc069b7717e2e5e0f
|
[
"MIT"
] | null | null | null |
include/RaZ/Math/MathUtils.hpp
|
Sausty/RaZ
|
211cc1c0c4a7374520a3141fc069b7717e2e5e0f
|
[
"MIT"
] | null | null | null |
#pragma once
#ifndef RAZ_MATHUTILS_HPP
#define RAZ_MATHUTILS_HPP
#include <algorithm>
#include <cassert>
#include <type_traits>
namespace Raz::MathUtils {
/// Computes the linear interpolation between two values, according to a coefficient.
/// \tparam T Type to compute the interpolation with.
/// \param min Minimum value (lower bound).
/// \param max Maximum value (upper bound).
/// \param coeff Coefficient between 0 (returns `min`) and 1 (returns `max`).
/// \return Computed linear interpolation between `min` and `max`.
template <typename T>
constexpr T interpolate(T min, T max, T coeff) noexcept {
static_assert(std::is_floating_point_v<T>, "Error: Interpolation type must be floating point.");
assert("Error: The interpolation coefficient must be between 0 & 1." && (coeff >= 0 && coeff <= 1));
return min * (1 - coeff) + max * coeff;
}
/// Computes the [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation) between two thresholds.
///
/// Any value below `minThresh` will return 0, and any above `maxThresh` will return 1. Between both thresholds, a smooth interpolation is performed.
///
/// 1.0 | |___
/// | .-~"|
/// | ,^ |
/// | / |
/// | / |
/// | / |
/// | ,v |
/// 0.0 ___|,.-" |
/// ^ ^
/// minThresh maxThresh
///
/// This is equivalent to [GLSL's smoothstep function](http://docs.gl/sl4/smoothstep).
/// \tparam T Type to compute the interpolation with.
/// \param minThresh Minimum threshold value.
/// \param maxThresh Maximum threshold value.
/// \param value Value to be interpolated.
/// \return 0 if `value` is lower than `minThresh`.
/// \return 1 if `value` is greater than `maxThresh`.
/// \return The interpolated value (between 0 & 1) otherwise.
template <typename T>
constexpr T smoothstep(T minThresh, T maxThresh, T value) noexcept {
assert("Error: The smoothstep's maximum threshold must be greater than the minimum one." && maxThresh > minThresh);
const T clampedVal = std::clamp((value - minThresh) / (maxThresh - minThresh), static_cast<T>(0), static_cast<T>(1));
return clampedVal * clampedVal * (3 - 2 * clampedVal);
}
/// Computes the [smootherstep](https://en.wikipedia.org/wiki/Smoothstep#Variations) between two thresholds.
/// This is Ken Perlin's smoothstep variation, which produces a slightly smoother smoothstep.
/// \tparam T Type to compute the interpolation with.
/// \param minThresh Minimum threshold value.
/// \param maxThresh Maximum threshold value.
/// \param value Value to be interpolated.
/// \return 0 if `value` is lower than `minThresh`.
/// \return 1 if `value` is greater than `maxThresh`.
/// \return The interpolated value (between 0 & 1) otherwise.
template <typename T>
constexpr T smootherstep(T minThresh, T maxThresh, T value) noexcept {
assert("Error: The smootherstep's maximum threshold must be greater than the minimum one." && maxThresh > minThresh);
const T clampedVal = std::clamp((value - minThresh) / (maxThresh - minThresh), static_cast<T>(0), static_cast<T>(1));
return clampedVal * clampedVal * clampedVal * (clampedVal * (clampedVal * 6 - 15) + 10);
}
} // namespace Raz::MathUtils
#endif // RAZ_MATHUTILS_HPP
| 43.87013
| 149
| 0.65897
|
Sausty
|
de62423217435b714daacef3ad51497d1a4d690a
| 3,286
|
hpp
|
C++
|
Axis.CommonLibrary/domain/elements/DoF.hpp
|
renato-yuzup/axis-fem
|
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
|
[
"MIT"
] | 2
|
2021-07-23T08:49:54.000Z
|
2021-07-29T22:07:30.000Z
|
Axis.CommonLibrary/domain/elements/DoF.hpp
|
renato-yuzup/axis-fem
|
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
|
[
"MIT"
] | null | null | null |
Axis.CommonLibrary/domain/elements/DoF.hpp
|
renato-yuzup/axis-fem
|
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
|
[
"MIT"
] | null | null | null |
/// <summary>
/// Contains the definition for the class axis::domain::elements::DoF.
/// </summary>
/// <author>Renato T. Yamassaki</author>
#pragma once
#include "foundation/Axis.CommonLibrary.hpp"
#include "foundation/memory/pointer.hpp"
#include "nocopy.hpp"
namespace axis { namespace domain {
namespace boundary_conditions {
// a prototype
class AXISCOMMONLIBRARY_API BoundaryCondition;
}
namespace elements {
// another prototype
class AXISCOMMONLIBRARY_API Node;
/// <summary>
/// Represents a degree-of-freedom (DoF) that a node has. In other words, one possible
/// direction of movement of a node.
/// </summary>
class AXISCOMMONLIBRARY_API DoF
{
public:
typedef long id_type;
/**********************************************************************************************//**
* @fn :::DoF(id_type id, int localIndex, Node& node);
*
* @brief Creates a new degree-of-freedom.
*
* @author Renato T. Yamassaki
* @date 12 jun 2012
*
* @param id Numerical identifier which relates this
* dof with its position in a global matrix.
* @param localIndex Zero-based index of the dof in the node.
* @param [in,out] node The node to which this dof belongs.
**************************************************************************************************/
DoF(id_type id, int localIndex, const axis::foundation::memory::RelativePointer& node);
/// <summary>
/// Destroys this object.
/// </summary>
~DoF(void);
/// <summary>
/// Destroys this object.
/// </summary>
void Destroy(void) const;
/// <summary>
/// Returns the numerical identifier of this dof.
/// </summary>
id_type GetId(void) const;
int GetLocalIndex(void) const;
Node& GetParentNode(void);
const Node& GetParentNode(void) const;
/// <summary>
/// Returns if there is boundary condition applied to this dof.
/// </summary>
bool HasBoundaryConditionApplied(void) const;
/// <summary>
/// Return the boundary condition applied to this dof.
/// </summary>
axis::domain::boundary_conditions::BoundaryCondition& GetBoundaryCondition(void) const;
/// <summary>
/// Sets a new boundary condition applied to this dof.
/// </summary>
/// <param name="condition">The boundary condition to be applied to this dof.</param>
void SetBoundaryCondition(axis::domain::boundary_conditions::BoundaryCondition& condition);
/// <summary>
/// Sets a new boundary condition to this dof removing any applied before.
/// </summary>
/// <param name="condition">The boundary condition to be applied to this dof.</param>
void ReplaceBoundaryCondition(axis::domain::boundary_conditions::BoundaryCondition& condition);
/// <summary>
/// Removes any boundary condition applied to this dof.
/// </summary>
void RemoveBoundaryCondition(void);
static axis::foundation::memory::RelativePointer Create(
id_type id, int localIndex, const axis::foundation::memory::RelativePointer& node);
void *operator new(size_t bytes);
void operator delete(void *ptr);
void *operator new(size_t bytes, void *ptr);
void operator delete(void *, void *);
private:
id_type _id;
int _localIndex;
axis::domain::boundary_conditions::BoundaryCondition *_condition;
axis::foundation::memory::RelativePointer _parentNode;
DISALLOW_COPY_AND_ASSIGN(DoF);
};
} } }
| 30.146789
| 101
| 0.673767
|
renato-yuzup
|
de62e7a84d0185142b4b94cd7fa40b3d72c289f3
| 677
|
cpp
|
C++
|
model/mosesdecoder/moses/Syntax/S2T/PChart.cpp
|
saeedesm/UNMT_AH
|
cc171bf66933b5c0ad8a0ab87e57f7364312a7df
|
[
"Apache-2.0"
] | 3
|
2020-02-28T21:42:44.000Z
|
2021-03-12T13:56:16.000Z
|
tools/mosesdecoder-master/moses/Syntax/S2T/PChart.cpp
|
Pangeamt/nectm
|
6b84f048698f2530b9fdbb30695f2e2217c3fbfe
|
[
"Apache-2.0"
] | 2
|
2020-11-06T14:40:10.000Z
|
2020-12-29T19:03:11.000Z
|
tools/mosesdecoder-master/moses/Syntax/S2T/PChart.cpp
|
Pangeamt/nectm
|
6b84f048698f2530b9fdbb30695f2e2217c3fbfe
|
[
"Apache-2.0"
] | 2
|
2019-11-26T05:27:16.000Z
|
2019-12-17T01:53:43.000Z
|
#include "PChart.h"
#include "moses/FactorCollection.h"
namespace Moses
{
namespace Syntax
{
namespace S2T
{
PChart::PChart(std::size_t width, bool maintainCompressedChart)
{
m_cells.resize(width);
for (std::size_t i = 0; i < width; ++i) {
m_cells[i].resize(width);
}
if (maintainCompressedChart) {
m_compressedChart = new CompressedChart(width);
for (CompressedChart::iterator p = m_compressedChart->begin();
p != m_compressedChart->end(); ++p) {
p->resize(FactorCollection::Instance().GetNumNonTerminals());
}
}
}
PChart::~PChart()
{
delete m_compressedChart;
}
} // namespace S2T
} // namespace Syntax
} // namespace Moses
| 19.342857
| 67
| 0.67356
|
saeedesm
|
de654ee37cfebeb17bfec97b1a696cd8a99c9e97
| 473
|
cpp
|
C++
|
cpp/zigzag_conversion.cpp
|
jieyaren/hello-world
|
9fbc7d117b9aee98d748669646dd200c25a4122f
|
[
"WTFPL"
] | 3
|
2021-11-12T09:20:21.000Z
|
2022-02-18T11:34:33.000Z
|
cpp/zigzag_conversion.cpp
|
jieyaren/hello-world
|
9fbc7d117b9aee98d748669646dd200c25a4122f
|
[
"WTFPL"
] | 1
|
2019-05-15T10:55:59.000Z
|
2019-05-15T10:56:31.000Z
|
cpp/zigzag_conversion.cpp
|
jieyaren/hello-world
|
9fbc7d117b9aee98d748669646dd200c25a4122f
|
[
"WTFPL"
] | null | null | null |
class Solution
{
public:
string convert(string s, int nRows)
{
if (nRows <= 1 || s.size() <= 1) return s;
string result;
for (int i = 0; i < nRows; i++)
{
for (int j = 0, index = i; index < s.size();j++, index = (2 * nRows - 2) * j + i)
{
result.append(1, s[index]);
if (i == 0 || i == nRows - 1) continue;
if (index + (nRows - i - 1) * 2 < s.size())
result.append(1, s[index + (nRows - i - 1) * 2]);
}
}
return result;
}
};
| 23.65
| 85
| 0.488372
|
jieyaren
|
de6621476f54d243bfc11625bbc9c7bc8ebcd59b
| 95,558
|
cc
|
C++
|
fbench/src/grpcclient/third_party/googleapis/gens/google/actions/sdk/v2/interactionmodel/prompt/static_prompt.pb.cc
|
kashiish/vespa
|
307de4bb24463d0f36cd8391a7b8df75bd0949b2
|
[
"Apache-2.0"
] | null | null | null |
fbench/src/grpcclient/third_party/googleapis/gens/google/actions/sdk/v2/interactionmodel/prompt/static_prompt.pb.cc
|
kashiish/vespa
|
307de4bb24463d0f36cd8391a7b8df75bd0949b2
|
[
"Apache-2.0"
] | null | null | null |
fbench/src/grpcclient/third_party/googleapis/gens/google/actions/sdk/v2/interactionmodel/prompt/static_prompt.pb.cc
|
kashiish/vespa
|
307de4bb24463d0f36cd8391a7b8df75bd0949b2
|
[
"Apache-2.0"
] | null | null | null |
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/actions/sdk/v2/interactionmodel/prompt/static_prompt.proto
#include "google/actions/sdk/v2/interactionmodel/prompt/static_prompt.pb.h"
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcanvas_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_StaticCanvasPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcanvas_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcontent_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<7> scc_info_StaticContentPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcontent_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5flink_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_StaticLinkPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5flink_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<2> scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<5> scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fsimple_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_StaticSimplePrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fsimple_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsuggestion_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_Suggestion_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsuggestion_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsurface_5fcapabilities_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_SurfaceCapabilities_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsurface_5fcapabilities_2eproto;
namespace google {
namespace actions {
namespace sdk {
namespace v2 {
namespace interactionmodel {
namespace prompt {
class StaticPrompt_StaticPromptCandidate_StaticPromptResponseDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StaticPrompt_StaticPromptCandidate_StaticPromptResponse> _instance;
} _StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_;
class StaticPrompt_StaticPromptCandidateDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StaticPrompt_StaticPromptCandidate> _instance;
} _StaticPrompt_StaticPromptCandidate_default_instance_;
class StaticPrompt_SelectorDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StaticPrompt_Selector> _instance;
} _StaticPrompt_Selector_default_instance_;
class StaticPromptDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StaticPrompt> _instance;
} _StaticPrompt_default_instance_;
} // namespace prompt
} // namespace interactionmodel
} // namespace v2
} // namespace sdk
} // namespace actions
} // namespace google
static void InitDefaultsStaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_;
new (ptr) ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<5> scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 5, InitDefaultsStaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto}, {
&scc_info_StaticSimplePrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fsimple_5fprompt_2eproto.base,
&scc_info_StaticContentPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcontent_5fprompt_2eproto.base,
&scc_info_Suggestion_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsuggestion_2eproto.base,
&scc_info_StaticLinkPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5flink_5fprompt_2eproto.base,
&scc_info_StaticCanvasPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcanvas_5fprompt_2eproto.base,}};
static void InitDefaultsStaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_default_instance_;
new (ptr) ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<2> scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsStaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto}, {
&scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base,
&scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base,}};
static void InitDefaultsStaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_Selector_default_instance_;
new (ptr) ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<1> scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsStaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto}, {
&scc_info_SurfaceCapabilities_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsurface_5fcapabilities_2eproto.base,}};
static void InitDefaultsStaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_default_instance_;
new (ptr) ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<1> scc_info_StaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsStaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto}, {
&scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base,}};
void InitDefaults_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
::google::protobuf::internal::InitSCC(&scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::google::protobuf::internal::InitSCC(&scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::google::protobuf::internal::InitSCC(&scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::google::protobuf::internal::InitSCC(&scc_info_StaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
}
::google::protobuf::Metadata file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[4];
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = nullptr;
const ::google::protobuf::uint32 TableStruct_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, first_simple_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, content_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, last_simple_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, suggestions_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, link_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, override_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, canvas_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate, selector_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate, prompt_response_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector, surface_capabilities_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt, candidates_),
};
static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse)},
{ 12, -1, sizeof(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate)},
{ 19, -1, sizeof(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector)},
{ 25, -1, sizeof(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt)},
};
static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_Selector_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_default_instance_),
};
::google::protobuf::internal::AssignDescriptorsTable assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = {
{}, AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, "google/actions/sdk/v2/interactionmodel/prompt/static_prompt.proto", schemas,
file_default_instances, TableStruct_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto::offsets,
file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, 4, file_level_enum_descriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, file_level_service_descriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto,
};
const char descriptor_table_protodef_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[] =
"\nAgoogle/actions/sdk/v2/interactionmodel"
"/prompt/static_prompt.proto\022-google.acti"
"ons.sdk.v2.interactionmodel.prompt\032Pgoog"
"le/actions/sdk/v2/interactionmodel/promp"
"t/content/static_canvas_prompt.proto\032Qgo"
"ogle/actions/sdk/v2/interactionmodel/pro"
"mpt/content/static_content_prompt.proto\032"
"Ngoogle/actions/sdk/v2/interactionmodel/"
"prompt/content/static_link_prompt.proto\032"
"Hgoogle/actions/sdk/v2/interactionmodel/"
"prompt/static_simple_prompt.proto\032>googl"
"e/actions/sdk/v2/interactionmodel/prompt"
"/suggestion.proto\032Hgoogle/actions/sdk/v2"
"/interactionmodel/prompt/surface_capabil"
"ities.proto\032\037google/api/field_behavior.p"
"roto\"\234\010\n\014StaticPrompt\022e\n\ncandidates\030\001 \003("
"\0132Q.google.actions.sdk.v2.interactionmod"
"el.prompt.StaticPrompt.StaticPromptCandi"
"date\032\266\006\n\025StaticPromptCandidate\022[\n\010select"
"or\030\001 \001(\0132D.google.actions.sdk.v2.interac"
"tionmodel.prompt.StaticPrompt.SelectorB\003"
"\340A\001\022\177\n\017prompt_response\030\002 \001(\0132f.google.ac"
"tions.sdk.v2.interactionmodel.prompt.Sta"
"ticPrompt.StaticPromptCandidate.StaticPr"
"omptResponse\032\276\004\n\024StaticPromptResponse\022\\\n"
"\014first_simple\030\002 \001(\0132A.google.actions.sdk"
".v2.interactionmodel.prompt.StaticSimple"
"PromptB\003\340A\001\022X\n\007content\030\003 \001(\0132B.google.ac"
"tions.sdk.v2.interactionmodel.prompt.Sta"
"ticContentPromptB\003\340A\001\022[\n\013last_simple\030\004 \001"
"(\0132A.google.actions.sdk.v2.interactionmo"
"del.prompt.StaticSimplePromptB\003\340A\001\022S\n\013su"
"ggestions\030\005 \003(\01329.google.actions.sdk.v2."
"interactionmodel.prompt.SuggestionB\003\340A\001\022"
"R\n\004link\030\006 \001(\0132\?.google.actions.sdk.v2.in"
"teractionmodel.prompt.StaticLinkPromptB\003"
"\340A\001\022\025\n\010override\030\007 \001(\010B\003\340A\001\022Q\n\006canvas\030\010 \001"
"(\0132A.google.actions.sdk.v2.interactionmo"
"del.prompt.StaticCanvasPrompt\032l\n\010Selecto"
"r\022`\n\024surface_capabilities\030\001 \001(\0132B.google"
".actions.sdk.v2.interactionmodel.prompt."
"SurfaceCapabilitiesB\235\001\n1com.google.actio"
"ns.sdk.v2.interactionmodel.promptB\021Stati"
"cPromptProtoP\001ZSgoogle.golang.org/genpro"
"to/googleapis/actions/sdk/v2/interaction"
"model/prompt;promptb\006proto3"
;
::google::protobuf::internal::DescriptorTable descriptor_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = {
false, InitDefaults_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto,
descriptor_table_protodef_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto,
"google/actions/sdk/v2/interactionmodel/prompt/static_prompt.proto", &assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, 1827,
};
void AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
static constexpr ::google::protobuf::internal::InitFunc deps[7] =
{
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcanvas_5fprompt_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcontent_5fprompt_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5flink_5fprompt_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fsimple_5fprompt_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsuggestion_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsurface_5fcapabilities_2eproto,
::AddDescriptors_google_2fapi_2ffield_5fbehavior_2eproto,
};
::google::protobuf::internal::AddDescriptors(&descriptor_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, deps, 7);
}
// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = []() { AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto(); return true; }();
namespace google {
namespace actions {
namespace sdk {
namespace v2 {
namespace interactionmodel {
namespace prompt {
// ===================================================================
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::InitAsDefaultInstance() {
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->first_simple_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->content_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->last_simple_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->link_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->canvas_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt::internal_default_instance());
}
class StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters {
public:
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt& first_simple(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt& content(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt& last_simple(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt& link(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt& canvas(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
};
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::first_simple(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->first_simple_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::content(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->content_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::last_simple(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->last_simple_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::link(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->link_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::canvas(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->canvas_;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_first_simple() {
if (GetArenaNoVirtual() == nullptr && first_simple_ != nullptr) {
delete first_simple_;
}
first_simple_ = nullptr;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_content() {
if (GetArenaNoVirtual() == nullptr && content_ != nullptr) {
delete content_;
}
content_ = nullptr;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_last_simple() {
if (GetArenaNoVirtual() == nullptr && last_simple_ != nullptr) {
delete last_simple_;
}
last_simple_ = nullptr;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_suggestions() {
suggestions_.Clear();
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_link() {
if (GetArenaNoVirtual() == nullptr && link_ != nullptr) {
delete link_;
}
link_ = nullptr;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_canvas() {
if (GetArenaNoVirtual() == nullptr && canvas_ != nullptr) {
delete canvas_;
}
canvas_ = nullptr;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kFirstSimpleFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kContentFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kLastSimpleFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kSuggestionsFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kLinkFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kOverrideFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kCanvasFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::StaticPrompt_StaticPromptCandidate_StaticPromptResponse()
: ::google::protobuf::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
}
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::StaticPrompt_StaticPromptCandidate_StaticPromptResponse(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse& from)
: ::google::protobuf::Message(),
_internal_metadata_(nullptr),
suggestions_(from.suggestions_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.has_first_simple()) {
first_simple_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt(*from.first_simple_);
} else {
first_simple_ = nullptr;
}
if (from.has_content()) {
content_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt(*from.content_);
} else {
content_ = nullptr;
}
if (from.has_last_simple()) {
last_simple_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt(*from.last_simple_);
} else {
last_simple_ = nullptr;
}
if (from.has_link()) {
link_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt(*from.link_);
} else {
link_ = nullptr;
}
if (from.has_canvas()) {
canvas_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt(*from.canvas_);
} else {
canvas_ = nullptr;
}
override_ = from.override_;
// @@protoc_insertion_point(copy_constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::SharedCtor() {
::google::protobuf::internal::InitSCC(
&scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::memset(&first_simple_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&override_) -
reinterpret_cast<char*>(&first_simple_)) + sizeof(override_));
}
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::~StaticPrompt_StaticPromptCandidate_StaticPromptResponse() {
// @@protoc_insertion_point(destructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
SharedDtor();
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::SharedDtor() {
if (this != internal_default_instance()) delete first_simple_;
if (this != internal_default_instance()) delete content_;
if (this != internal_default_instance()) delete last_simple_;
if (this != internal_default_instance()) delete link_;
if (this != internal_default_instance()) delete canvas_;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const StaticPrompt_StaticPromptCandidate_StaticPromptResponse& StaticPrompt_StaticPromptCandidate_StaticPromptResponse::default_instance() {
::google::protobuf::internal::InitSCC(&::scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
return *internal_default_instance();
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::Clear() {
// @@protoc_insertion_point(message_clear_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
suggestions_.Clear();
if (GetArenaNoVirtual() == nullptr && first_simple_ != nullptr) {
delete first_simple_;
}
first_simple_ = nullptr;
if (GetArenaNoVirtual() == nullptr && content_ != nullptr) {
delete content_;
}
content_ = nullptr;
if (GetArenaNoVirtual() == nullptr && last_simple_ != nullptr) {
delete last_simple_;
}
last_simple_ = nullptr;
if (GetArenaNoVirtual() == nullptr && link_ != nullptr) {
delete link_;
}
link_ = nullptr;
if (GetArenaNoVirtual() == nullptr && canvas_ != nullptr) {
delete canvas_;
}
canvas_ = nullptr;
override_ = false;
_internal_metadata_.Clear();
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* StaticPrompt_StaticPromptCandidate_StaticPromptResponse::_InternalParse(const char* begin, const char* end, void* object,
::google::protobuf::internal::ParseContext* ctx) {
auto msg = static_cast<StaticPrompt_StaticPromptCandidate_StaticPromptResponse*>(object);
::google::protobuf::int32 size; (void)size;
int depth; (void)depth;
::google::protobuf::uint32 tag;
::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
auto ptr = begin;
while (ptr < end) {
ptr = ::google::protobuf::io::Parse32(ptr, &tag);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::_InternalParse;
object = msg->mutable_first_simple();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt::_InternalParse;
object = msg->mutable_content();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::_InternalParse;
object = msg->mutable_last_simple();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
do {
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::Suggestion::_InternalParse;
object = msg->add_suggestions();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 42 && (ptr += 1));
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt::_InternalParse;
object = msg->mutable_link();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
msg->set_override(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
case 8: {
if (static_cast<::google::protobuf::uint8>(tag) != 66) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt::_InternalParse;
object = msg->mutable_canvas();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->EndGroup(tag);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
ptr = res.first;
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
if (res.second) return ptr;
}
} // switch
} // while
return ptr;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
}
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StaticPrompt_StaticPromptCandidate_StaticPromptResponse::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) == (18 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_first_simple()));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) == (26 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_content()));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) == (34 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_last_simple()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) == (42 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, add_suggestions()));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) == (50 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_link()));
} else {
goto handle_unusual;
}
break;
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) == (56 & 0xFF)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &override_)));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
case 8: {
if (static_cast< ::google::protobuf::uint8>(tag) == (66 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_canvas()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
return false;
#undef DO_
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_first_simple()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, HasBitSetters::first_simple(this), output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_content()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
3, HasBitSetters::content(this), output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_last_simple()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, HasBitSetters::last_simple(this), output);
}
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->suggestions_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
5,
this->suggestions(static_cast<int>(i)),
output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_link()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
6, HasBitSetters::link(this), output);
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
if (this->override() != 0) {
::google::protobuf::internal::WireFormatLite::WriteBool(7, this->override(), output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
if (this->has_canvas()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
8, HasBitSetters::canvas(this), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
}
::google::protobuf::uint8* StaticPrompt_StaticPromptCandidate_StaticPromptResponse::InternalSerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_first_simple()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
2, HasBitSetters::first_simple(this), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_content()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
3, HasBitSetters::content(this), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_last_simple()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
4, HasBitSetters::last_simple(this), target);
}
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->suggestions_size()); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
5, this->suggestions(static_cast<int>(i)), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_link()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
6, HasBitSetters::link(this), target);
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
if (this->override() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->override(), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
if (this->has_canvas()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
8, HasBitSetters::canvas(this), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
return target;
}
size_t StaticPrompt_StaticPromptCandidate_StaticPromptResponse::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
{
unsigned int count = static_cast<unsigned int>(this->suggestions_size());
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSize(
this->suggestions(static_cast<int>(i)));
}
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_first_simple()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*first_simple_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_content()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*content_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_last_simple()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*last_simple_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_link()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*link_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
if (this->has_canvas()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*canvas_);
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
if (this->override() != 0) {
total_size += 1 + 1;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
GOOGLE_DCHECK_NE(&from, this);
const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* source =
::google::protobuf::DynamicCastToGenerated<StaticPrompt_StaticPromptCandidate_StaticPromptResponse>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
MergeFrom(*source);
}
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::MergeFrom(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
suggestions_.MergeFrom(from.suggestions_);
if (from.has_first_simple()) {
mutable_first_simple()->::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::MergeFrom(from.first_simple());
}
if (from.has_content()) {
mutable_content()->::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt::MergeFrom(from.content());
}
if (from.has_last_simple()) {
mutable_last_simple()->::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::MergeFrom(from.last_simple());
}
if (from.has_link()) {
mutable_link()->::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt::MergeFrom(from.link());
}
if (from.has_canvas()) {
mutable_canvas()->::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt::MergeFrom(from.canvas());
}
if (from.override() != 0) {
set_override(from.override());
}
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::CopyFrom(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StaticPrompt_StaticPromptCandidate_StaticPromptResponse::IsInitialized() const {
return true;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::Swap(StaticPrompt_StaticPromptCandidate_StaticPromptResponse* other) {
if (other == this) return;
InternalSwap(other);
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::InternalSwap(StaticPrompt_StaticPromptCandidate_StaticPromptResponse* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
CastToBase(&suggestions_)->InternalSwap(CastToBase(&other->suggestions_));
swap(first_simple_, other->first_simple_);
swap(content_, other->content_);
swap(last_simple_, other->last_simple_);
swap(link_, other->link_);
swap(canvas_, other->canvas_);
swap(override_, other->override_);
}
::google::protobuf::Metadata StaticPrompt_StaticPromptCandidate_StaticPromptResponse::GetMetadata() const {
::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto);
return ::file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[kIndexInFileMessages];
}
// ===================================================================
void StaticPrompt_StaticPromptCandidate::InitAsDefaultInstance() {
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_default_instance_._instance.get_mutable()->selector_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_default_instance_._instance.get_mutable()->prompt_response_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse::internal_default_instance());
}
class StaticPrompt_StaticPromptCandidate::HasBitSetters {
public:
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector& selector(const StaticPrompt_StaticPromptCandidate* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse& prompt_response(const StaticPrompt_StaticPromptCandidate* msg);
};
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector&
StaticPrompt_StaticPromptCandidate::HasBitSetters::selector(const StaticPrompt_StaticPromptCandidate* msg) {
return *msg->selector_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse&
StaticPrompt_StaticPromptCandidate::HasBitSetters::prompt_response(const StaticPrompt_StaticPromptCandidate* msg) {
return *msg->prompt_response_;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StaticPrompt_StaticPromptCandidate::kSelectorFieldNumber;
const int StaticPrompt_StaticPromptCandidate::kPromptResponseFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StaticPrompt_StaticPromptCandidate::StaticPrompt_StaticPromptCandidate()
: ::google::protobuf::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
}
StaticPrompt_StaticPromptCandidate::StaticPrompt_StaticPromptCandidate(const StaticPrompt_StaticPromptCandidate& from)
: ::google::protobuf::Message(),
_internal_metadata_(nullptr) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.has_selector()) {
selector_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector(*from.selector_);
} else {
selector_ = nullptr;
}
if (from.has_prompt_response()) {
prompt_response_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse(*from.prompt_response_);
} else {
prompt_response_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
}
void StaticPrompt_StaticPromptCandidate::SharedCtor() {
::google::protobuf::internal::InitSCC(
&scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::memset(&selector_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&prompt_response_) -
reinterpret_cast<char*>(&selector_)) + sizeof(prompt_response_));
}
StaticPrompt_StaticPromptCandidate::~StaticPrompt_StaticPromptCandidate() {
// @@protoc_insertion_point(destructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
SharedDtor();
}
void StaticPrompt_StaticPromptCandidate::SharedDtor() {
if (this != internal_default_instance()) delete selector_;
if (this != internal_default_instance()) delete prompt_response_;
}
void StaticPrompt_StaticPromptCandidate::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const StaticPrompt_StaticPromptCandidate& StaticPrompt_StaticPromptCandidate::default_instance() {
::google::protobuf::internal::InitSCC(&::scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
return *internal_default_instance();
}
void StaticPrompt_StaticPromptCandidate::Clear() {
// @@protoc_insertion_point(message_clear_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
if (GetArenaNoVirtual() == nullptr && selector_ != nullptr) {
delete selector_;
}
selector_ = nullptr;
if (GetArenaNoVirtual() == nullptr && prompt_response_ != nullptr) {
delete prompt_response_;
}
prompt_response_ = nullptr;
_internal_metadata_.Clear();
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* StaticPrompt_StaticPromptCandidate::_InternalParse(const char* begin, const char* end, void* object,
::google::protobuf::internal::ParseContext* ctx) {
auto msg = static_cast<StaticPrompt_StaticPromptCandidate*>(object);
::google::protobuf::int32 size; (void)size;
int depth; (void)depth;
::google::protobuf::uint32 tag;
::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
auto ptr = begin;
while (ptr < end) {
ptr = ::google::protobuf::io::Parse32(ptr, &tag);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector::_InternalParse;
object = msg->mutable_selector();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse::_InternalParse;
object = msg->mutable_prompt_response();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->EndGroup(tag);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
ptr = res.first;
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
if (res.second) return ptr;
}
} // switch
} // while
return ptr;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
}
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StaticPrompt_StaticPromptCandidate::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) == (10 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_selector()));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) == (18 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_prompt_response()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
return false;
#undef DO_
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void StaticPrompt_StaticPromptCandidate::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_selector()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, HasBitSetters::selector(this), output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
if (this->has_prompt_response()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, HasBitSetters::prompt_response(this), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
}
::google::protobuf::uint8* StaticPrompt_StaticPromptCandidate::InternalSerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_selector()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
1, HasBitSetters::selector(this), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
if (this->has_prompt_response()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
2, HasBitSetters::prompt_response(this), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
return target;
}
size_t StaticPrompt_StaticPromptCandidate::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_selector()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*selector_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
if (this->has_prompt_response()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*prompt_response_);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StaticPrompt_StaticPromptCandidate::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
GOOGLE_DCHECK_NE(&from, this);
const StaticPrompt_StaticPromptCandidate* source =
::google::protobuf::DynamicCastToGenerated<StaticPrompt_StaticPromptCandidate>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
MergeFrom(*source);
}
}
void StaticPrompt_StaticPromptCandidate::MergeFrom(const StaticPrompt_StaticPromptCandidate& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.has_selector()) {
mutable_selector()->::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector::MergeFrom(from.selector());
}
if (from.has_prompt_response()) {
mutable_prompt_response()->::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse::MergeFrom(from.prompt_response());
}
}
void StaticPrompt_StaticPromptCandidate::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StaticPrompt_StaticPromptCandidate::CopyFrom(const StaticPrompt_StaticPromptCandidate& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StaticPrompt_StaticPromptCandidate::IsInitialized() const {
return true;
}
void StaticPrompt_StaticPromptCandidate::Swap(StaticPrompt_StaticPromptCandidate* other) {
if (other == this) return;
InternalSwap(other);
}
void StaticPrompt_StaticPromptCandidate::InternalSwap(StaticPrompt_StaticPromptCandidate* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(selector_, other->selector_);
swap(prompt_response_, other->prompt_response_);
}
::google::protobuf::Metadata StaticPrompt_StaticPromptCandidate::GetMetadata() const {
::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto);
return ::file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[kIndexInFileMessages];
}
// ===================================================================
void StaticPrompt_Selector::InitAsDefaultInstance() {
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_Selector_default_instance_._instance.get_mutable()->surface_capabilities_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities*>(
::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities::internal_default_instance());
}
class StaticPrompt_Selector::HasBitSetters {
public:
static const ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities& surface_capabilities(const StaticPrompt_Selector* msg);
};
const ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities&
StaticPrompt_Selector::HasBitSetters::surface_capabilities(const StaticPrompt_Selector* msg) {
return *msg->surface_capabilities_;
}
void StaticPrompt_Selector::clear_surface_capabilities() {
if (GetArenaNoVirtual() == nullptr && surface_capabilities_ != nullptr) {
delete surface_capabilities_;
}
surface_capabilities_ = nullptr;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StaticPrompt_Selector::kSurfaceCapabilitiesFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StaticPrompt_Selector::StaticPrompt_Selector()
: ::google::protobuf::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
}
StaticPrompt_Selector::StaticPrompt_Selector(const StaticPrompt_Selector& from)
: ::google::protobuf::Message(),
_internal_metadata_(nullptr) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.has_surface_capabilities()) {
surface_capabilities_ = new ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities(*from.surface_capabilities_);
} else {
surface_capabilities_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
}
void StaticPrompt_Selector::SharedCtor() {
::google::protobuf::internal::InitSCC(
&scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
surface_capabilities_ = nullptr;
}
StaticPrompt_Selector::~StaticPrompt_Selector() {
// @@protoc_insertion_point(destructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
SharedDtor();
}
void StaticPrompt_Selector::SharedDtor() {
if (this != internal_default_instance()) delete surface_capabilities_;
}
void StaticPrompt_Selector::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const StaticPrompt_Selector& StaticPrompt_Selector::default_instance() {
::google::protobuf::internal::InitSCC(&::scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
return *internal_default_instance();
}
void StaticPrompt_Selector::Clear() {
// @@protoc_insertion_point(message_clear_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
if (GetArenaNoVirtual() == nullptr && surface_capabilities_ != nullptr) {
delete surface_capabilities_;
}
surface_capabilities_ = nullptr;
_internal_metadata_.Clear();
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* StaticPrompt_Selector::_InternalParse(const char* begin, const char* end, void* object,
::google::protobuf::internal::ParseContext* ctx) {
auto msg = static_cast<StaticPrompt_Selector*>(object);
::google::protobuf::int32 size; (void)size;
int depth; (void)depth;
::google::protobuf::uint32 tag;
::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
auto ptr = begin;
while (ptr < end) {
ptr = ::google::protobuf::io::Parse32(ptr, &tag);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities::_InternalParse;
object = msg->mutable_surface_capabilities();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->EndGroup(tag);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
ptr = res.first;
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
if (res.second) return ptr;
}
} // switch
} // while
return ptr;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
}
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StaticPrompt_Selector::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) == (10 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_surface_capabilities()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
return false;
#undef DO_
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void StaticPrompt_Selector::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
if (this->has_surface_capabilities()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, HasBitSetters::surface_capabilities(this), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
}
::google::protobuf::uint8* StaticPrompt_Selector::InternalSerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
if (this->has_surface_capabilities()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
1, HasBitSetters::surface_capabilities(this), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
return target;
}
size_t StaticPrompt_Selector::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
if (this->has_surface_capabilities()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*surface_capabilities_);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StaticPrompt_Selector::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
GOOGLE_DCHECK_NE(&from, this);
const StaticPrompt_Selector* source =
::google::protobuf::DynamicCastToGenerated<StaticPrompt_Selector>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
MergeFrom(*source);
}
}
void StaticPrompt_Selector::MergeFrom(const StaticPrompt_Selector& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.has_surface_capabilities()) {
mutable_surface_capabilities()->::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities::MergeFrom(from.surface_capabilities());
}
}
void StaticPrompt_Selector::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StaticPrompt_Selector::CopyFrom(const StaticPrompt_Selector& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StaticPrompt_Selector::IsInitialized() const {
return true;
}
void StaticPrompt_Selector::Swap(StaticPrompt_Selector* other) {
if (other == this) return;
InternalSwap(other);
}
void StaticPrompt_Selector::InternalSwap(StaticPrompt_Selector* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(surface_capabilities_, other->surface_capabilities_);
}
::google::protobuf::Metadata StaticPrompt_Selector::GetMetadata() const {
::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto);
return ::file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[kIndexInFileMessages];
}
// ===================================================================
void StaticPrompt::InitAsDefaultInstance() {
}
class StaticPrompt::HasBitSetters {
public:
};
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StaticPrompt::kCandidatesFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StaticPrompt::StaticPrompt()
: ::google::protobuf::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
}
StaticPrompt::StaticPrompt(const StaticPrompt& from)
: ::google::protobuf::Message(),
_internal_metadata_(nullptr),
candidates_(from.candidates_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
}
void StaticPrompt::SharedCtor() {
::google::protobuf::internal::InitSCC(
&scc_info_StaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
}
StaticPrompt::~StaticPrompt() {
// @@protoc_insertion_point(destructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
SharedDtor();
}
void StaticPrompt::SharedDtor() {
}
void StaticPrompt::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const StaticPrompt& StaticPrompt::default_instance() {
::google::protobuf::internal::InitSCC(&::scc_info_StaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
return *internal_default_instance();
}
void StaticPrompt::Clear() {
// @@protoc_insertion_point(message_clear_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
candidates_.Clear();
_internal_metadata_.Clear();
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* StaticPrompt::_InternalParse(const char* begin, const char* end, void* object,
::google::protobuf::internal::ParseContext* ctx) {
auto msg = static_cast<StaticPrompt*>(object);
::google::protobuf::int32 size; (void)size;
int depth; (void)depth;
::google::protobuf::uint32 tag;
::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
auto ptr = begin;
while (ptr < end) {
ptr = ::google::protobuf::io::Parse32(ptr, &tag);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate::_InternalParse;
object = msg->add_candidates();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->EndGroup(tag);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
ptr = res.first;
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
if (res.second) return ptr;
}
} // switch
} // while
return ptr;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
}
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StaticPrompt::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) == (10 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, add_candidates()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
return false;
#undef DO_
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void StaticPrompt::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->candidates_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1,
this->candidates(static_cast<int>(i)),
output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
}
::google::protobuf::uint8* StaticPrompt::InternalSerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->candidates_size()); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
1, this->candidates(static_cast<int>(i)), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
return target;
}
size_t StaticPrompt::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
{
unsigned int count = static_cast<unsigned int>(this->candidates_size());
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSize(
this->candidates(static_cast<int>(i)));
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StaticPrompt::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
GOOGLE_DCHECK_NE(&from, this);
const StaticPrompt* source =
::google::protobuf::DynamicCastToGenerated<StaticPrompt>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
MergeFrom(*source);
}
}
void StaticPrompt::MergeFrom(const StaticPrompt& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
candidates_.MergeFrom(from.candidates_);
}
void StaticPrompt::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StaticPrompt::CopyFrom(const StaticPrompt& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StaticPrompt::IsInitialized() const {
return true;
}
void StaticPrompt::Swap(StaticPrompt* other) {
if (other == this) return;
InternalSwap(other);
}
void StaticPrompt::InternalSwap(StaticPrompt* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
CastToBase(&candidates_)->InternalSwap(CastToBase(&other->candidates_));
}
::google::protobuf::Metadata StaticPrompt::GetMetadata() const {
::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto);
return ::file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[kIndexInFileMessages];
}
// @@protoc_insertion_point(namespace_scope)
} // namespace prompt
} // namespace interactionmodel
} // namespace v2
} // namespace sdk
} // namespace actions
} // namespace google
namespace google {
namespace protobuf {
template<> PROTOBUF_NOINLINE ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse* Arena::CreateMaybeMessage< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse >(Arena* arena) {
return Arena::CreateInternal< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse >(arena);
}
template<> PROTOBUF_NOINLINE ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate* Arena::CreateMaybeMessage< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate >(Arena* arena) {
return Arena::CreateInternal< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate >(arena);
}
template<> PROTOBUF_NOINLINE ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector* Arena::CreateMaybeMessage< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector >(Arena* arena) {
return Arena::CreateInternal< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector >(arena);
}
template<> PROTOBUF_NOINLINE ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt* Arena::CreateMaybeMessage< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt >(Arena* arena) {
return Arena::CreateInternal< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 50.188025
| 332
| 0.761757
|
kashiish
|
de66df5d745f37310b3cd581a149e17024a1f60e
| 8,355
|
cpp
|
C++
|
net/ias/policy/dll_bld/request.cpp
|
npocmaka/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 17
|
2020-11-13T13:42:52.000Z
|
2021-09-16T09:13:13.000Z
|
net/ias/policy/dll_bld/request.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 2
|
2020-10-19T08:02:06.000Z
|
2020-10-19T08:23:18.000Z
|
net/ias/policy/dll_bld/request.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 14
|
2020-11-14T09:43:20.000Z
|
2021-08-28T08:59:57.000Z
|
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation.
//
// SYNOPSIS
//
// Defines the class Request.
//
///////////////////////////////////////////////////////////////////////////////
#include <polcypch.h>
#include <iasattr.h>
#include <sdoias.h>
#include <request.h>
#include <new>
PIASATTRIBUTE Request::findFirst(DWORD id) const throw ()
{
for (PIASATTRIBUTE* a = begin; a != end; ++a)
{
if ((*a)->dwId == id) { return *a; }
}
return NULL;
}
Request* Request::narrow(IUnknown* pUnk) throw ()
{
Request* request = NULL;
if (pUnk)
{
HRESULT hr = pUnk->QueryInterface(
__uuidof(Request),
(PVOID*)&request
);
if (SUCCEEDED(hr))
{
request->GetUnknown()->Release();
}
}
return request;
}
STDMETHODIMP Request::get_Source(IRequestSource** pVal)
{
if (*pVal = source) { source->AddRef(); }
return S_OK;
}
STDMETHODIMP Request::put_Source(IRequestSource* newVal)
{
if (source) { source->Release(); }
if (source = newVal) { source->AddRef(); }
return S_OK;
}
STDMETHODIMP Request::get_Protocol(IASPROTOCOL *pVal)
{
*pVal = protocol;
return S_OK;
}
STDMETHODIMP Request::put_Protocol(IASPROTOCOL newVal)
{
protocol = newVal;
return S_OK;
}
STDMETHODIMP Request::get_Request(LONG *pVal)
{
*pVal = (LONG)request;
return S_OK;
}
STDMETHODIMP Request::put_Request(LONG newVal)
{
request = (IASREQUEST)newVal;
return S_OK;
}
STDMETHODIMP Request::get_Response(LONG *pVal)
{
*pVal = (LONG)response;
return S_OK;
}
STDMETHODIMP Request::get_Reason(LONG *pVal)
{
*pVal = (LONG)reason;
return S_OK;
}
STDMETHODIMP Request::SetResponse(IASRESPONSE eResponse, LONG lReason)
{
response = eResponse;
reason = (IASREASON)lReason;
return S_OK;
}
STDMETHODIMP Request::ReturnToSource(IASREQUESTSTATUS eStatus)
{
return source ? source->OnRequestComplete(this, eStatus) : S_OK;
}
HRESULT Request::AddAttributes(
DWORD dwPosCount,
PATTRIBUTEPOSITION pPositions
)
{
if (!reserve(size() + dwPosCount))
{
return E_OUTOFMEMORY;
}
for ( ; dwPosCount; --dwPosCount, ++pPositions)
{
IASAttributeAddRef(pPositions->pAttribute);
*end++ = pPositions->pAttribute;
}
return S_OK;
}
HRESULT Request::RemoveAttributes(
DWORD dwPosCount,
PATTRIBUTEPOSITION pPositions
)
{
for ( ; dwPosCount; --dwPosCount, ++pPositions)
{
PIASATTRIBUTE* pos = find(pPositions->pAttribute);
if (pos != 0)
{
IASAttributeRelease(*pos);
--end;
memmove(pos, pos + 1, (end - pos) * sizeof(PIASATTRIBUTE));
}
}
return S_OK;
}
HRESULT Request::RemoveAttributesByType(
DWORD dwAttrIDCount,
DWORD *lpdwAttrIDs
)
{
for ( ; dwAttrIDCount; ++lpdwAttrIDs, --dwAttrIDCount)
{
for (PIASATTRIBUTE* i = begin; i != end; )
{
if ((*i)->dwId == *lpdwAttrIDs)
{
IASAttributeRelease(*i);
--end;
memmove(i, i + 1, (end - i) * sizeof(PIASATTRIBUTE));
}
else
{
++i;
}
}
}
return S_OK;
}
HRESULT Request::GetAttributeCount(
DWORD *lpdwCount
)
{
*lpdwCount = size();
return S_OK;
}
HRESULT Request::GetAttributes(
DWORD *lpdwPosCount,
PATTRIBUTEPOSITION pPositions,
DWORD dwAttrIDCount,
DWORD *lpdwAttrIDs
)
{
HRESULT hr = S_OK;
DWORD count = 0;
// End of the caller supplied array.
PATTRIBUTEPOSITION stop = pPositions + *lpdwPosCount;
// Next struct to be filled.
PATTRIBUTEPOSITION next = pPositions;
// Force at least one iteration of the for loop.
if (!lpdwAttrIDs) { dwAttrIDCount = 1; }
// Iterate through the desired attribute IDs.
for ( ; dwAttrIDCount; ++lpdwAttrIDs, --dwAttrIDCount)
{
// Iterate through the request's attribute collection.
for (PIASATTRIBUTE* i = begin; i != end; ++i)
{
// Did the caller ask for all the attributes ?
// If not, is this a match for one of the requested IDs ?
if (!lpdwAttrIDs || (*i)->dwId == *lpdwAttrIDs)
{
if (next)
{
if (next == stop)
{
*lpdwPosCount = count;
return HRESULT_FROM_WIN32(ERROR_MORE_DATA);
}
IASAttributeAddRef(next->pAttribute = *i);
++next;
}
++count;
}
}
}
*lpdwPosCount = count;
return hr;
}
STDMETHODIMP Request::InsertBefore(
PATTRIBUTEPOSITION newAttr,
PATTRIBUTEPOSITION refAttr
)
{
// Reserve space for the new attribute.
if (!reserve(size() + 1))
{
return E_OUTOFMEMORY;
}
// Find the position; if it doesn't exist we'll do a simple add.
PIASATTRIBUTE* pos = find(refAttr->pAttribute);
if (pos == 0)
{
return AddAttributes(1, newAttr);
}
// Move the existing attribute out of the way.
memmove(pos + 1, pos, (end - pos) * sizeof(PIASATTRIBUTE));
++end;
// Store the new attribute.
*pos = newAttr->pAttribute;
IASAttributeAddRef(*pos);
return S_OK;
}
STDMETHODIMP Request::Push(
ULONG64 State
)
{
const PULONG64 END_STATE = state + sizeof(state)/sizeof(state[0]);
if (topOfStack != END_STATE)
{
*topOfStack = State;
++topOfStack;
return S_OK;
}
return E_OUTOFMEMORY;
}
STDMETHODIMP Request::Pop(
ULONG64* pState
)
{
if (topOfStack != state)
{
--topOfStack;
*pState = *topOfStack;
return S_OK;
}
return E_FAIL;
}
STDMETHODIMP Request::Top(
ULONG64* pState
)
{
if (topOfStack != state)
{
*pState = *(topOfStack - 1);
return S_OK;
}
return E_FAIL;
}
Request::Request() throw ()
: source(NULL),
protocol(IAS_PROTOCOL_RADIUS),
request(IAS_REQUEST_ACCESS_REQUEST),
response(IAS_RESPONSE_INVALID),
reason(IAS_SUCCESS),
begin(NULL),
end(NULL),
capacity(NULL),
topOfStack(&state[0])
{
topOfStack = state;
}
Request::~Request() throw ()
{
for (PIASATTRIBUTE* i = begin; i != end; ++i)
{
IASAttributeRelease(*i);
}
delete[] begin;
if (source) { source->Release(); }
}
inline size_t Request::size() const throw ()
{
return end - begin;
}
bool Request::reserve(size_t newCapacity) throw ()
{
if (newCapacity <= capacity)
{
return true;
}
// Increase the capacity by at least 50% and never less than 32.
size_t minCapacity = (capacity > 21) ? (capacity * 3 / 2): 32;
// Is the requested capacity less than the minimum resize?
if (newCapacity < minCapacity)
{
newCapacity = minCapacity;
}
// Allocate the new array.
PIASATTRIBUTE* newArray = new (std::nothrow) PIASATTRIBUTE[newCapacity];
if (newArray == 0)
{
return false;
}
// Save the values in the old array.
memcpy(newArray, begin, size() * sizeof(PIASATTRIBUTE));
// Delete the old array.
delete[] begin;
// Update our pointers.
end = newArray + size();
begin = newArray;
capacity = newCapacity;
return true;
}
PIASATTRIBUTE* Request::find(IASATTRIBUTE* key) const throw ()
{
for (PIASATTRIBUTE* i = begin; i != end; ++i)
{
if (*i == key)
{
return i;
}
}
return 0;
}
| 21.589147
| 80
| 0.520766
|
npocmaka
|
de69117248769fece90923ed8a531e23e9866066
| 316
|
cpp
|
C++
|
atcoder/abc116/A.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | 1
|
2019-08-03T13:42:16.000Z
|
2019-08-03T13:42:16.000Z
|
atcoder/abc116/A.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | null | null | null |
atcoder/abc116/A.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;
int main() {
vector<int> nums(3);
for (int i = 0; i < 3; ++i) {
cin >> nums[i];
}
sort(nums.begin(), nums.end());
cout << nums[0] * nums[1] / 2 << endl;
return 0;
}
| 18.588235
| 42
| 0.53481
|
SashiRin
|
de69d155868cb9b451780809dc5173551ad2facf
| 1,188
|
cpp
|
C++
|
洛谷/模拟/P1042.cpp
|
codehuanglei/-
|
933a55b5c5a49163f12e0c39b4edfa9c4f01678f
|
[
"MIT"
] | null | null | null |
洛谷/模拟/P1042.cpp
|
codehuanglei/-
|
933a55b5c5a49163f12e0c39b4edfa9c4f01678f
|
[
"MIT"
] | null | null | null |
洛谷/模拟/P1042.cpp
|
codehuanglei/-
|
933a55b5c5a49163f12e0c39b4edfa9c4f01678f
|
[
"MIT"
] | null | null | null |
#include<bits/stdc++.h>
using namespace std;
const int MAX = 65535;
int arr[MAX] = {0};
char ch;
int main(){
for(int i = 1;cin >> ch && ch != 'E'; i++){
if(ch == 'W'){
arr[i] = 1;
}
if(ch == 'L'){
arr[i] = 2;
}
}
int w = 0, l = 0;
for(int i = 1; 1; i++){
if(arr[i] == 1){
w++;
}
if(arr[i] == 2){
l++;
}
if(arr[i] == 0){
cout<< w << ":" << l<<endl;
break;
}
if(w - l >= 2 || l - w >= 2){
if(w >= 11 || l >= 11){
cout<< w << ":"<< l << endl;
w = 0;
l = 0;
}
}
}
cout<< endl;
w = l = 0;
for(int i = 1; 1; i++){
if(arr[i] == 1){
w++;
}
if(arr[i] == 2){
l++;
}
if(arr[i] == 0){
cout<< w << ":" << l<<endl;
break;
}
if(w - l >= 2 || l - w >= 2){
if(w >= 21 || l >= 21){
cout<< w << ":"<< l << endl;
w = 0;
l = 0;
}
}
}
return 0;
}
| 20.842105
| 47
| 0.244108
|
codehuanglei
|
de6a14af5c852ebfe2b51977061ef15749adf264
| 1,662
|
hpp
|
C++
|
Source/wali/include/wali/LongestSaturatingPathSemiring.hpp
|
jusito/WALi-OpenNWA
|
2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99
|
[
"MIT"
] | 15
|
2015-03-07T17:25:57.000Z
|
2022-02-04T20:17:00.000Z
|
Source/wali/include/wali/LongestSaturatingPathSemiring.hpp
|
jusito/WALi-OpenNWA
|
2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99
|
[
"MIT"
] | 1
|
2018-03-03T05:58:55.000Z
|
2018-03-03T12:26:10.000Z
|
Source/wali/include/wali/LongestSaturatingPathSemiring.hpp
|
jusito/WALi-OpenNWA
|
2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99
|
[
"MIT"
] | 15
|
2015-09-25T17:44:35.000Z
|
2021-07-18T18:25:38.000Z
|
#ifndef WALI_LONGESTSATURATING_PATH_SEMIRING_HPP
#define WALI_LONGESTSATURATING_PATH_SEMIRING_HPP
#include "wali/SemElem.hpp"
#include "wali/MergeFn.hpp"
#include "wali/ref_ptr.hpp"
#include "wali/Key.hpp"
#include <set>
namespace wali {
/// This is a funny domain. But maybe it'll be useful? I just use it for
/// testing.
///
/// The domain is {0, 1, 2, ...., big, bottom} for some 'big' (given in the
/// constructor). Extend is saturating addition strictly evaluated, combine
/// is maximum, semiring zero is bottom, and semiring one is distance 0.
class LongestSaturatingPathSemiring : public wali::SemElem
{
public:
//-----------------------------
// semiring one and zero
//-----------------------------
sem_elem_t one() const;
sem_elem_t zero() const;
//---------------------------------
// semiring operations
//---------------------------------
sem_elem_t extend( SemElem* rhs );
sem_elem_t combine( SemElem* rhs );
bool equal(SemElem *rhs) const;
bool containerLessThan(SemElem const * rhs) const;
//------------------------------------
// output
//------------------------------------
std::ostream & print(std::ostream &out) const;
unsigned int getNum() const;
size_t hash() const;
private:
unsigned int v;
unsigned int biggest;
public:
//---------------------
// Constructors
//---------------------
LongestSaturatingPathSemiring(unsigned int big) : v(0), biggest(big) { }
LongestSaturatingPathSemiring(unsigned int _v, unsigned int big) : v(_v), biggest(big) {}
};
}
#endif // REACH_SEMIRING
| 24.086957
| 93
| 0.561372
|
jusito
|
de6b176e78f826c786378659d8757f9f98fae5fa
| 560
|
cpp
|
C++
|
Chapter_9/overloading_variadic_non-template.cpp
|
wagnerhsu/packt-CPP-Templates-Up-and-Running
|
2dcede8bb155d609a1b8d9765bfd4167e3a57289
|
[
"MIT"
] | null | null | null |
Chapter_9/overloading_variadic_non-template.cpp
|
wagnerhsu/packt-CPP-Templates-Up-and-Running
|
2dcede8bb155d609a1b8d9765bfd4167e3a57289
|
[
"MIT"
] | null | null | null |
Chapter_9/overloading_variadic_non-template.cpp
|
wagnerhsu/packt-CPP-Templates-Up-and-Running
|
2dcede8bb155d609a1b8d9765bfd4167e3a57289
|
[
"MIT"
] | null | null | null |
#include <iostream>
void foo(int val1, int val2)
{
std::cout << "From non-template" << std::endl;
std::cout << val1 << " " << val2 << std::endl;
}
template<typename T>
void foo(T val1, T val2)
{
std::cout << "From non-variadic" << std::endl;
std::cout << val1 << " " << val2 << std::endl;
}
template<typename T, typename... rest>
void foo(T val, rest... argPack)
{
std::cout << "From variadic" << std::endl;
std::cout << val << std::endl;
foo(argPack...);
}
int main()
{
foo(10, 20);
foo(10, 20, 30, 40);
return 0;
}
| 19.310345
| 50
| 0.55
|
wagnerhsu
|
de6bec73380ead55000e692d1463d900d1472f4a
| 12,254
|
cc
|
C++
|
src/trace_processor/args_table_unittest.cc
|
zakerinasab/perfetto
|
7f86589d1522ce8bfc59f6b569ca52496a53eb79
|
[
"Apache-2.0"
] | null | null | null |
src/trace_processor/args_table_unittest.cc
|
zakerinasab/perfetto
|
7f86589d1522ce8bfc59f6b569ca52496a53eb79
|
[
"Apache-2.0"
] | null | null | null |
src/trace_processor/args_table_unittest.cc
|
zakerinasab/perfetto
|
7f86589d1522ce8bfc59f6b569ca52496a53eb79
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "src/trace_processor/args_table.h"
#include "src/trace_processor/sqlite/scoped_db.h"
#include "src/trace_processor/trace_processor_context.h"
#include "src/trace_processor/trace_storage.h"
#include "test/gtest_and_gmock.h"
namespace perfetto {
namespace trace_processor {
namespace {
class ArgsTableUnittest : public ::testing::Test {
public:
ArgsTableUnittest() {
sqlite3* db = nullptr;
PERFETTO_CHECK(sqlite3_initialize() == SQLITE_OK);
PERFETTO_CHECK(sqlite3_open(":memory:", &db) == SQLITE_OK);
db_.reset(db);
context_.storage.reset(new TraceStorage());
ArgsTable::RegisterTable(db_.get(), context_.storage.get());
}
void PrepareValidStatement(const std::string& sql) {
int size = static_cast<int>(sql.size());
sqlite3_stmt* stmt;
ASSERT_EQ(sqlite3_prepare_v2(*db_, sql.c_str(), size, &stmt, nullptr),
SQLITE_OK);
stmt_.reset(stmt);
}
const char* GetColumnAsText(int colId) {
return reinterpret_cast<const char*>(sqlite3_column_text(*stmt_, colId));
}
void AssertArgRowValues(int arg_set_id,
const char* flat_key,
const char* key,
base::Optional<int64_t> int_value,
base::Optional<const char*> string_value,
base::Optional<double> real_value);
protected:
TraceProcessorContext context_;
ScopedDb db_;
ScopedStmt stmt_;
};
// Test helper.
void ArgsTableUnittest::AssertArgRowValues(
int arg_set_id,
const char* flat_key,
const char* key,
base::Optional<int64_t> int_value,
base::Optional<const char*> string_value,
base::Optional<double> real_value) {
ASSERT_EQ(sqlite3_column_int(*stmt_, 0), arg_set_id);
ASSERT_STREQ(GetColumnAsText(1), flat_key);
ASSERT_STREQ(GetColumnAsText(2), key);
if (int_value.has_value()) {
ASSERT_EQ(sqlite3_column_int64(*stmt_, 3), int_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 3), SQLITE_NULL);
}
if (string_value.has_value()) {
ASSERT_STREQ(GetColumnAsText(4), string_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 4), SQLITE_NULL);
}
if (real_value.has_value()) {
ASSERT_DOUBLE_EQ(sqlite3_column_double(*stmt_, 5), real_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 5), SQLITE_NULL);
}
}
TEST_F(ArgsTableUnittest, IntValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const int kValue = 123;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Integer(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, kValue, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, StringValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const char kValue[] = "123";
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::String(context_.storage->InternString(kValue));
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, kValue, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, RealValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const double kValue = 0.123;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Real(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, base::nullopt, kValue);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, BoolValueTreatedAsInt) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const bool kValue = true;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Boolean(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
// Boolean returned in the "int_value" column, and is comparable to an integer
// literal.
PrepareValidStatement("SELECT * FROM args WHERE int_value = 1");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, kValue, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, PointerValueTreatedAsInt) {
static const uint64_t kSmallValue = 1ull << 30;
static const uint64_t kTopBitSetValue = 1ull << 63;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString("flat_key_small");
arg.key = context_.storage->InternString("key_small");
arg.value = Variadic::Pointer(kSmallValue);
TraceStorage::Args::Arg arg2;
arg2.flat_key = context_.storage->InternString("flat_key_large");
arg2.key = context_.storage->InternString("key_large");
arg2.value = Variadic::Pointer(kTopBitSetValue);
context_.storage->mutable_args()->AddArgSet({arg, arg2}, 0, 2);
// Pointer returned in the "int_value" column, as a signed 64 bit. And is
// comparable to an integer literal.
static const int64_t kExpectedSmallValue = static_cast<int64_t>(kSmallValue);
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedSmallValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_small", "key_small", kExpectedSmallValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
static const int64_t kExpectedTopBitSetValue =
static_cast<int64_t>(kTopBitSetValue); // negative
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedTopBitSetValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_large", "key_large", kExpectedTopBitSetValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, UintValueTreatedAsInt) {
static const uint64_t kSmallValue = 1ull << 30;
static const uint64_t kTopBitSetValue = 1ull << 63;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString("flat_key_small");
arg.key = context_.storage->InternString("key_small");
arg.value = Variadic::UnsignedInteger(kSmallValue);
TraceStorage::Args::Arg arg2;
arg2.flat_key = context_.storage->InternString("flat_key_large");
arg2.key = context_.storage->InternString("key_large");
arg2.value = Variadic::UnsignedInteger(kTopBitSetValue);
context_.storage->mutable_args()->AddArgSet({arg, arg2}, 0, 2);
// Unsigned returned in the "int_value" column, as a signed 64 bit. And is
// comparable to an integer literal.
static const int64_t kExpectedSmallValue = static_cast<int64_t>(kSmallValue);
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedSmallValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_small", "key_small", kExpectedSmallValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
static const int64_t kExpectedTopBitSetValue =
static_cast<int64_t>(kTopBitSetValue); // negative
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedTopBitSetValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_large", "key_large", kExpectedTopBitSetValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, IntegerLikeValuesSortByIntRepresentation) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
TraceStorage::Args::Arg bool_arg_true;
bool_arg_true.flat_key = context_.storage->InternString(kFlatKey);
bool_arg_true.key = context_.storage->InternString(kKey);
bool_arg_true.value = Variadic::Boolean(true);
TraceStorage::Args::Arg bool_arg_false;
bool_arg_false.flat_key = context_.storage->InternString(kFlatKey);
bool_arg_false.key = context_.storage->InternString(kKey);
bool_arg_false.value = Variadic::Boolean(false);
TraceStorage::Args::Arg pointer_arg_42;
pointer_arg_42.flat_key = context_.storage->InternString(kFlatKey);
pointer_arg_42.key = context_.storage->InternString(kKey);
pointer_arg_42.value = Variadic::Pointer(42);
TraceStorage::Args::Arg unsigned_arg_10;
unsigned_arg_10.flat_key = context_.storage->InternString(kFlatKey);
unsigned_arg_10.key = context_.storage->InternString(kKey);
unsigned_arg_10.value = Variadic::UnsignedInteger(10);
// treated as null by the int_value column
TraceStorage::Args::Arg string_arg;
string_arg.flat_key = context_.storage->InternString(kFlatKey);
string_arg.key = context_.storage->InternString(kKey);
string_arg.value =
Variadic::String(context_.storage->InternString("string_content"));
context_.storage->mutable_args()->AddArgSet(
{bool_arg_true, bool_arg_false, pointer_arg_42, unsigned_arg_10,
string_arg},
0, 5);
// Ascending sort by int representations:
// { null (string), 0 (false), 1 (true), 10, 42 }
PrepareValidStatement("SELECT * FROM args ORDER BY int_value ASC");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, "string_content",
base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 0, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 1, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 10, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 42, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
// Desceding order.
PrepareValidStatement("SELECT * FROM args ORDER BY int_value DESC");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 42, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 10, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 1, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 0, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, "string_content",
base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
} // namespace
} // namespace trace_processor
} // namespace perfetto
| 39.025478
| 80
| 0.71952
|
zakerinasab
|
de6d301d3637b7189e571f714ed564941bae1ff9
| 127,143
|
cpp
|
C++
|
src/plugProjectKandoU/vsGameSection.cpp
|
projectPiki/pikmin2
|
a431d992acde856d092889a515ecca0e07a3ea7c
|
[
"Unlicense"
] | 33
|
2021-12-08T11:10:59.000Z
|
2022-03-26T19:59:37.000Z
|
src/plugProjectKandoU/vsGameSection.cpp
|
projectPiki/pikmin2
|
a431d992acde856d092889a515ecca0e07a3ea7c
|
[
"Unlicense"
] | 6
|
2021-12-22T17:54:31.000Z
|
2022-01-07T21:43:18.000Z
|
src/plugProjectKandoU/vsGameSection.cpp
|
projectPiki/pikmin2
|
a431d992acde856d092889a515ecca0e07a3ea7c
|
[
"Unlicense"
] | 2
|
2022-01-04T06:00:49.000Z
|
2022-01-26T07:27:28.000Z
|
#include "Game/VsGameSection.h"
#include "types.h"
/*
Generated from dpostproc
.section .ctors, "wa" # 0x80472F00 - 0x804732C0
.4byte __sinit_vsGameSection_cpp
.section .rodata # 0x804732E0 - 0x8049E220
.global lbl_8047FF98
lbl_8047FF98:
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x56734761
.4byte 0x6D655365
.4byte 0x6374696F
.4byte 0x6E000000
.4byte 0x50534761
.4byte 0x6D652E68
.4byte 0x00000000
.global lbl_8047FFC0
lbl_8047FFC0:
.asciz "P2Assert"
.skip 3
.4byte 0x50535363
.4byte 0x656E652E
.4byte 0x68000000
.global lbl_8047FFD8
lbl_8047FFD8:
.4byte 0x63617665
.4byte 0x696E666F
.4byte 0x2E747874
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.global lbl_8047FFF4
lbl_8047FFF4:
.4byte 0x76734761
.4byte 0x6D655365
.4byte 0x6374696F
.4byte 0x6E2E6370
.4byte 0x70000000
.global lbl_80480008
lbl_80480008:
.4byte 0x7A616E6E
.4byte 0x656E6E0A
.4byte 0x00000000
.global lbl_80480014
lbl_80480014:
.4byte 0x2F757365
.4byte 0x722F4D61
.4byte 0x746F6261
.4byte 0x2F636861
.4byte 0x6C6C656E
.4byte 0x67652F6B
.4byte 0x6665732D
.4byte 0x73746167
.4byte 0x65732E74
.4byte 0x78740000
.global lbl_8048003C
lbl_8048003C:
.4byte 0x2F757365
.4byte 0x722F4D61
.4byte 0x746F6261
.4byte 0x2F636861
.4byte 0x6C6C656E
.4byte 0x67652F73
.4byte 0x74616765
.4byte 0x732E7478
.4byte 0x74000000
.global lbl_80480060
lbl_80480060:
.4byte 0x2F757365
.4byte 0x722F6162
.4byte 0x652F7673
.4byte 0x2F737461
.4byte 0x6765732E
.4byte 0x74787400
.global lbl_80480078
lbl_80480078:
.4byte 0x6F702D63
.4byte 0x2D6D6F72
.4byte 0x65000000
.4byte 0x6D6F7265
.4byte 0x2D796573
.4byte 0x00000000
.4byte 0x6D6F7265
.4byte 0x2D7A656E
.4byte 0x6B616900
.4byte 0x7330435F
.4byte 0x63765F65
.4byte 0x73636170
.4byte 0x65000000
.global lbl_804800AC
lbl_804800AC:
.4byte 0x7330335F
.4byte 0x6F72696D
.4byte 0x61646F77
.4byte 0x6E000000
.global lbl_804800BC
lbl_804800BC:
.4byte 0x63726561
.4byte 0x74654661
.4byte 0x6C6C5069
.4byte 0x6B6D696E
.4byte 0x73000000
.global lbl_804800D0
lbl_804800D0:
.4byte 0x6E6F2073
.4byte 0x70616365
.4byte 0x20666F72
.4byte 0x206E6577
.4byte 0x2079656C
.4byte 0x6C6F770A
.4byte 0x00000000
.global lbl_804800EC
lbl_804800EC:
.4byte 0x6E6F2065
.4byte 0x6E747279
.4byte 0x20666F72
.4byte 0x2070656C
.4byte 0x6C65740A
.4byte 0x00000000
.4byte 0x62697274
.4byte 0x68206661
.4byte 0x696C6564
.4byte 0x20210A00
.4byte 0x6F6F7375
.4byte 0x67692025
.4byte 0x640A0000
.4byte 0x25642070
.4byte 0x6C617965
.4byte 0x7249440A
.4byte 0x00000000
.4byte 0x25642074
.4byte 0x79706549
.4byte 0x440A0000
.4byte 0x41726745
.4byte 0x6E656D79
.4byte 0x54797065
.4byte 0x00000000
.4byte 0x50696B69
.4byte 0x496E6974
.4byte 0x41726700
.4byte 0x50656C6C
.4byte 0x6574496E
.4byte 0x69744172
.4byte 0x67000000
.section .data, "wa" # 0x8049E220 - 0x804EFC20
.global lbl_804B60E8
lbl_804B60E8:
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.global __vt__Q24Game20GameMessageVsUseCard
__vt__Q24Game20GameMessageVsUseCard:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game20GameMessageVsUseCardFPQ24Game13VsGameSection
.global __vt__Q24Game20GameMessageVsGotCard
__vt__Q24Game20GameMessageVsGotCard:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game20GameMessageVsGotCardFPQ24Game13VsGameSection
.global __vt__Q24Game23GameMessageVsPikminDead
__vt__Q24Game23GameMessageVsPikminDead:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game23GameMessageVsPikminDeadFPQ24Game13VsGameSection
.global __vt__Q24Game30GameMessageVsBirthTekiTreasure
__vt__Q24Game30GameMessageVsBirthTekiTreasure:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game30GameMessageVsBirthTekiTreasureFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessagePelletDead
__vt__Q24Game21GameMessagePelletDead:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessagePelletDeadFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessagePelletBorn
__vt__Q24Game21GameMessagePelletBorn:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessagePelletBornFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessageVsAddEnemy
__vt__Q24Game21GameMessageVsAddEnemy:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessageVsAddEnemyFPQ24Game13VsGameSection
.global __vt__Q24Game23GameMessageVsGetOtakara
__vt__Q24Game23GameMessageVsGetOtakara:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game23GameMessageVsGetOtakaraFPQ24Game13VsGameSection
.global __vt__Q24Game27GameMessageVsRedOrSuckStart
__vt__Q24Game27GameMessageVsRedOrSuckStart:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game27GameMessageVsRedOrSuckStartFPQ24Game13VsGameSection .global
__vt__Q24Game27GameMessageVsBattleFinished
__vt__Q24Game27GameMessageVsBattleFinished:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game27GameMessageVsBattleFinishedFPQ24Game13VsGameSection .global
__vt__Q24Game22GameMessageVsGetDoping
__vt__Q24Game22GameMessageVsGetDoping:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game22GameMessageVsGetDopingFPQ24Game13VsGameSection
.global "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"
"__vt__Q24Game36StateMachine<Q24Game13VsGameSection>":
.4byte 0
.4byte 0
.4byte
"init__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
"start__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.4byte
"exec__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
"transit__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.global __vt__Q24Game13VsGameSection
__vt__Q24Game13VsGameSection:
.4byte 0
.4byte 0
.4byte __dt__Q24Game13VsGameSectionFv
.4byte run__7SectionFv
.4byte update__7SectionFv
.4byte draw__7SectionFR8Graphics
.4byte init__Q24Game15BaseGameSectionFv
.4byte drawInit__7SectionFR8Graphics
.4byte
drawInit__Q24Game15BaseGameSectionFR8GraphicsQ27Section13EDrawInitMode .4byte
doExit__7SectionFv .4byte forceFinish__Q24Game15BaseGameSectionFv .4byte
forceReset__7SectionFv .4byte getCurrentSection__7SectionFv .4byte
doLoadingStart__7SectionFv .4byte doLoading__7SectionFv .4byte
doUpdate__Q24Game13VsGameSectionFv .4byte
doDraw__Q24Game13VsGameSectionFR8Graphics .4byte isFinishable__7SectionFv
.4byte initHIO__Q24Game14BaseHIOSectionFPQ24Game11HIORootNode
.4byte refreshHIO__Q24Game14BaseHIOSectionFv
.4byte sendMessage__Q24Game13VsGameSectionFRQ24Game11GameMessage
.4byte pre2dDraw__Q24Game13VsGameSectionFR8Graphics
.4byte getCurrFloor__Q24Game13VsGameSectionFv
.4byte isDevelopSection__Q24Game15BaseGameSectionFv
.4byte addChallengeScore__Q24Game13VsGameSectionFi
.4byte startMainBgm__Q24Game13VsGameSectionFv
.4byte section_fadeout__Q24Game13VsGameSectionFv
.4byte goNextFloor__Q24Game13VsGameSectionFPQ34Game8ItemHole4Item
.4byte goCave__Q24Game15BaseGameSectionFPQ34Game8ItemCave4Item
.4byte
goMainMap__Q24Game15BaseGameSectionFPQ34Game15ItemBigFountain4Item .4byte
getCaveID__Q24Game15BaseGameSectionFv .4byte
getCurrentCourseInfo__Q24Game15BaseGameSectionFv .4byte
challengeDisablePelplant__Q24Game13VsGameSectionFv .4byte
getCaveFilename__Q24Game13VsGameSectionFv .4byte
getEditorFilename__Q24Game13VsGameSectionFv .4byte
getVsEditNumber__Q24Game13VsGameSectionFv .4byte
openContainerWindow__Q24Game15BaseGameSectionFv .4byte
closeContainerWindow__Q24Game15BaseGameSectionFv .4byte
playMovie_firstexperience__Q24Game15BaseGameSectionFiPQ24Game8Creature .4byte
playMovie_bootup__Q24Game15BaseGameSectionFPQ24Game5Onyon .4byte
playMovie_helloPikmin__Q24Game15BaseGameSectionFPQ24Game4Piki .4byte
enableTimer__Q24Game15BaseGameSectionFfUl .4byte
disableTimer__Q24Game15BaseGameSectionFUl .4byte
getTimerType__Q24Game15BaseGameSectionFv .4byte
onMovieStart__Q24Game13VsGameSectionFPQ24Game11MovieConfigUlUl .4byte
onMovieDone__Q24Game13VsGameSectionFPQ24Game11MovieConfigUlUl .4byte
onMovieCommand__Q24Game15BaseGameSectionFi .4byte
startFadeout__Q24Game15BaseGameSectionFf .4byte
startFadein__Q24Game15BaseGameSectionFf .4byte
startFadeoutin__Q24Game15BaseGameSectionFf .4byte
startFadeblack__Q24Game15BaseGameSectionFv .4byte
startFadewhite__Q24Game15BaseGameSectionFv .4byte
gmOrimaDown__Q24Game13VsGameSectionFi .4byte
gmPikminZero__Q24Game13VsGameSectionFv .4byte
openCaveInMenu__Q24Game15BaseGameSectionFPQ34Game8ItemCave4Itemi .4byte
openCaveMoreMenu__Q24Game13VsGameSectionFPQ34Game8ItemHole4ItemP10Controller
.4byte
openKanketuMenu__Q24Game13VsGameSectionFPQ34Game15ItemBigFountain4ItemP10Controller
.4byte on_setCamController__Q24Game15BaseGameSectionFi
.4byte onTogglePlayer__Q24Game15BaseGameSectionFv
.4byte onPlayerJoin__Q24Game15BaseGameSectionFv
.4byte onInit__Q24Game13VsGameSectionFv
.4byte onUpdate__Q24Game15BaseGameSectionFv
.4byte initJ3D__Q24Game15BaseGameSectionFv
.4byte initViewports__Q24Game15BaseGameSectionFR8Graphics
.4byte initResources__Q24Game15BaseGameSectionFv
.4byte initGenerators__Q24Game15BaseGameSectionFv
.4byte initLights__Q24Game15BaseGameSectionFv
.4byte draw3D__Q24Game15BaseGameSectionFR8Graphics
.4byte draw2D__Q24Game15BaseGameSectionFR8Graphics
.4byte drawParticle__Q24Game15BaseGameSectionFR8Graphicsi
.4byte draw_Ogawa2D__Q24Game15BaseGameSectionFR8Graphics
.4byte do_drawOtakaraWindow__Q24Game15BaseGameSectionFR8Graphics
.4byte onSetupFloatMemory__Q24Game13VsGameSectionFv
.4byte postSetupFloatMemory__Q24Game13VsGameSectionFv
.4byte onSetSoundScene__Q24Game13VsGameSectionFv
.4byte onStartHeap__Q24Game15BaseGameSectionFv
.4byte onClearHeap__Q24Game13VsGameSectionFv
.4byte player2enabled__Q24Game13VsGameSectionFv
.global __vt__Q34Game6VsGame3FSM
__vt__Q34Game6VsGame3FSM:
.4byte 0
.4byte 0
.4byte init__Q34Game6VsGame3FSMFPQ24Game13VsGameSection
.4byte
"start__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.4byte
"exec__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
transit__Q34Game6VsGame3FSMFPQ24Game13VsGameSectioniPQ24Game8StateArg
.section .sbss # 0x80514D80 - 0x80516360
.global lbl_80515A88
lbl_80515A88:
.skip 0x4
.global lbl_80515A8C
lbl_80515A8C:
.skip 0x4
.global mRedWinCount__Q24Game13VsGameSection
mRedWinCount__Q24Game13VsGameSection:
.skip 0x4
.global mBlueWinCount__Q24Game13VsGameSection
mBlueWinCount__Q24Game13VsGameSection:
.skip 0x4
.global mDrawCount__Q24Game13VsGameSection
mDrawCount__Q24Game13VsGameSection:
.skip 0x8
.section .sdata2, "a" # 0x80516360 - 0x80520E40
.global lbl_805194A8
lbl_805194A8:
.4byte 0x00000000
.global lbl_805194AC
lbl_805194AC:
.float 0.5
.global lbl_805194B0
lbl_805194B0:
.4byte 0x72616E64
.4byte 0x6F6D0000
.global lbl_805194B8
lbl_805194B8:
.float 1.0
.4byte 0x00000000
.global lbl_805194C0
lbl_805194C0:
.4byte 0x40490000
.4byte 0x00000000
.global lbl_805194C8
lbl_805194C8:
.4byte 0x43300000
.4byte 0x80000000
.global lbl_805194D0
lbl_805194D0:
.4byte 0x6F702D6B
.4byte 0x6B000000
.global lbl_805194D8
lbl_805194D8:
.4byte 0x6D6F7265
.4byte 0x2D6E6F00
.global lbl_805194E0
lbl_805194E0:
.4byte 0x6B6B2D79
.4byte 0x65730000
.global lbl_805194E8
lbl_805194E8:
.4byte 0x6B6B2D6E
.4byte 0x6F000000
.global lbl_805194F0
lbl_805194F0:
.4byte 0x47000000
.global lbl_805194F4
lbl_805194F4:
.4byte 0x41700000
.global lbl_805194F8
lbl_805194F8:
.4byte 0x41F00000
.global lbl_805194FC
lbl_805194FC:
.4byte 0x40C90FDB
.global lbl_80519500
lbl_80519500:
.4byte 0x44408000
.global lbl_80519504
lbl_80519504:
.4byte 0x44548000
.global lbl_80519508
lbl_80519508:
.4byte 0x42F00000
.global lbl_8051950C
lbl_8051950C:
.4byte 0x43A2F983
.global lbl_80519510
lbl_80519510:
.4byte 0xC3A2F983
.global lbl_80519514
lbl_80519514:
.4byte 0x4528C000
.global lbl_80519518
lbl_80519518:
.4byte 0x43160000
.global lbl_8051951C
lbl_8051951C:
.4byte 0x41200000
.global lbl_80519520
lbl_80519520:
.4byte 0x41A00000
.global lbl_80519524
lbl_80519524:
.4byte 0x3E4CCCCD
.global lbl_80519528
lbl_80519528:
.4byte 0x3F4CCCCD
.global lbl_8051952C
lbl_8051952C:
.float 0.1
.global lbl_80519530
lbl_80519530:
.4byte 0xBDCCCCCD
.global lbl_80519534
lbl_80519534:
.4byte 0xBF000000
.global lbl_80519538
lbl_80519538:
.4byte 0xBF4CCCCD
.global lbl_8051953C
lbl_8051953C:
.4byte 0x3D50E560
.global lbl_80519540
lbl_80519540:
.4byte 0x3C23D70A
.global lbl_80519544
lbl_80519544:
.4byte 0x41C80000
.global lbl_80519548
lbl_80519548:
.4byte 0x3ECCCCCD
.global lbl_8051954C
lbl_8051954C:
.4byte 0x3F19999A
.global lbl_80519550
lbl_80519550:
.float 0.3
.global lbl_80519554
lbl_80519554:
.4byte 0x3F0CCCCD
.global lbl_80519558
lbl_80519558:
.4byte 0x3F666666
.global lbl_8051955C
lbl_8051955C:
.4byte 0x40000000
.global lbl_80519560
lbl_80519560:
.4byte 0x40400000
.4byte 0x00000000
.global lbl_80519568
lbl_80519568:
.4byte 0x43300000
.4byte 0x00000000
.global lbl_80519570
lbl_80519570:
.4byte 0x430C0000
.global lbl_80519574
lbl_80519574:
.4byte 0xC1200000
.global lbl_80519578
lbl_80519578:
.4byte 0xBF800000
.global lbl_8051957C
lbl_8051957C:
.4byte 0x40800000
.global lbl_80519580
lbl_80519580:
.float 0.25
.4byte 0x00000000
.section .sbss2, "", @nobits # 0x80520e40 - 0x80520ED8
.global lbl_80520E68
lbl_80520E68:
.skip 0x4
.global lbl_80520E6C
lbl_80520E6C:
.skip 0x4
.global lbl_80520E70
lbl_80520E70:
.skip 0x4
.global lbl_80520E74
lbl_80520E74:
.skip 0x4
.global lbl_80520E78
lbl_80520E78:
.skip 0x4
.global lbl_80520E7C
lbl_80520E7C:
.skip 0x4
*/
namespace Game {
/*
* --INFO--
* Address: 801C0DF8
* Size: 0000D0
*/
void VsGame::FSM::init(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
li r4, 5
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r3
bl "create__Q24Game36StateMachine<Q24Game13VsGameSection>Fi"
li r3, 0x44
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E2C
bl __ct__Q34Game6VsGame10TitleStateFv
mr r4, r3
lbl_801C0E2C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0xa4
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E4C
bl __ct__Q34Game6VsGame9LoadStateFv
mr r4, r3
lbl_801C0E4C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x28
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E6C
bl __ct__Q34Game6VsGame9GameStateFv
mr r4, r3
lbl_801C0E6C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x28
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E8C
bl __ct__Q34Game6VsGame7VSStateFv
mr r4, r3
lbl_801C0E8C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x3c
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0EAC
bl __ct__Q34Game6VsGame11ResultStateFv
mr r4, r3
lbl_801C0EAC:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 000038
*/
void VsGame::FSM::draw(Game::VsGameSection*, Graphics&)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C0EC8
* Size: 000004
*/
void VsGame::State::draw(Game::VsGameSection*, Graphics&) { }
/*
* --INFO--
* Address: 801C0ECC
* Size: 000020
*/
void VsGame::FSM::transit(Game::VsGameSection*, int, Game::StateArg*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
bl
"transit__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C0EEC
* Size: 0000FC
*/
VsGameSection::VsGameSection(JKRHeap*, bool)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r5
stw r30, 8(r1)
mr r30, r3
bl __ct__Q24Game15BaseGameSectionFP7JKRHeap
lis r4, __vt__Q24Game13VsGameSection@ha
addi r3, r30, 0x184
addi r0, r4, __vt__Q24Game13VsGameSection@l
stw r0, 0(r30)
bl __ct__16DvdThreadCommandFv
li r0, 0
addi r3, r30, 0x214
stb r0, 0x1f8(r30)
bl __ct__Q24Game13PikiContainerFv
addi r3, r30, 0x21c
bl __ct__Q24Game13PikiContainerFv
stb r31, 0x174(r30)
li r0, 1
lis r3, gGameConfig__4Game@ha
li r6, 0
stb r0, 0x205(r30)
li r5, -1
li r4, 2
li r0, -2
stw r6, 0x338(r30)
addi r3, r3, gGameConfig__4Game@l
stw r6, 0x340(r30)
stw r5, 0x34c(r30)
stw r4, 0x348(r30)
stw r4, 0x344(r30)
stw r6, 0x3d8(r30)
stw r6, 0x3d4(r30)
stw r6, 0x3e0(r30)
stw r6, 0x3dc(r30)
stw r0, 0x328(r30)
stw r6, 0x178(r30)
lwz r0, 0x278(r3)
cmpwi r0, 0
ble lbl_801C0FCC
slwi r31, r0, 0xa
li r3, 0x1c
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C0FB4
mr r4, r31
bl __ct__6VSFifoFUl
mr r0, r3
lbl_801C0FB4:
stw r0, 0x178(r30)
lwz r3, 0x178(r30)
bl becomeCurrent__6VSFifoFv
lwz r3, 0x178(r30)
lwz r3, 4(r3)
bl GXSetGPFifo
lbl_801C0FCC:
lwz r0, 0x14(r1)
mr r3, r30
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C0FE8
* Size: 0000CC
*/
VsGameSection::~VsGameSection(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
or. r30, r3, r3
beq lbl_801C1098
lis r3, __vt__Q24Game13VsGameSection@ha
addi r0, r3, __vt__Q24Game13VsGameSection@l
stw r0, 0(r30)
lwz r3, 0x178(r30)
cmplwi r3, 0
beq lbl_801C1064
lwz r3, 4(r3)
bl GXSaveCPUFifo
lbl_801C1028:
bl isGPActive__6VSFifoFv
clrlwi. r0, r3, 0x18
bne lbl_801C1028
bl GXDrawDone
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r4, 8(r3)
lwz r3, 4(r3)
mr r5, r4
bl GXInitFifoPtrs
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r3, 4(r3)
bl GXSetCPUFifo
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r3, 4(r3)
bl GXSetGPFifo
lbl_801C1064:
addic. r0, r30, 0x184
beq lbl_801C107C
addic. r3, r30, 0x1e0
beq lbl_801C107C
li r4, 0
bl __dt__10JSUPtrLinkFv
lbl_801C107C:
mr r3, r30
li r4, 0
bl __dt__Q24Game15BaseGameSectionFv
extsh. r0, r31
ble lbl_801C1098
mr r3, r30
bl __dl__FPv
lbl_801C1098:
lwz r0, 0x14(r1)
mr r3, r30
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
} // namespace Game
/*
* --INFO--
* Address: 801C10B4
* Size: 00005C
*/
void VSFifo::isGPActive()
{
/*
stwu r1, -0x10(r1)
mflr r0
addi r4, r13, mGpStatus__6VSFifo@sda21
addi r6, r13, mGpStatus__6VSFifo@sda21
stw r0, 0x14(r1)
addi r7, r13, mGpStatus__6VSFifo@sda21
addi r3, r13, mGpStatus__6VSFifo@sda21
addi r4, r4, 1
stw r31, 0xc(r1)
addi r31, r13, mGpStatus__6VSFifo@sda21
addi r31, r31, 2
addi r6, r6, 3
mr r5, r31
addi r7, r7, 4
bl GXGetGPStatus
lbz r0, 0(r31)
lwz r31, 0xc(r1)
cntlzw r0, r0
srwi r3, r0, 5
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
namespace Game {
/*
* --INFO--
* Address: 801C1110
* Size: 000034
*/
void VsGameSection::section_fadeout(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r4, r3
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x38(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1144
* Size: 000004
*/
void VsGame::State::on_section_fadeout(Game::VsGameSection*) { }
/*
* --INFO--
* Address: 801C1148
* Size: 000090
*/
void VsGameSection::startMainBgm(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
lis r3, lbl_8047FF98@ha
stw r0, 0x14(r1)
stw r31, 0xc(r1)
addi r31, r3, lbl_8047FF98@l
stw r30, 8(r1)
lwz r0, spSceneMgr__8PSSystem@sda21(r13)
cmplwi r0, 0
bne lbl_801C1184
addi r3, r31, 0x1c
addi r5, r31, 0x28
li r4, 0x1d3
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C1184:
lwz r30, spSceneMgr__8PSSystem@sda21(r13)
lwz r0, 4(r30)
cmplwi r0, 0
bne lbl_801C11A8
addi r3, r31, 0x34
addi r5, r31, 0x28
li r4, 0xc7
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C11A8:
lwz r3, 4(r30)
lwz r3, 4(r3)
lwz r12, 0(r3)
lwz r12, 0x1c(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C11D8
* Size: 00020C
*/
void VsGameSection::onInit(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
lfs f1, lbl_805194A8@sda21(r2)
stw r0, 0x14(r1)
lfs f0, lbl_805194AC@sda21(r2)
stw r31, 0xc(r1)
mr r31, r3
stfs f1, 0x350(r3)
stfs f0, 0x354(r3)
stfs f1, 0x1f4(r3)
stfs f1, 0x1f0(r3)
bl clearGetDopeCount__Q24Game13VsGameSectionFv
mr r3, r31
bl clearGetCherryCount__Q24Game13VsGameSectionFv
lbz r0, 0x174(r31)
cmplwi r0, 0
beq lbl_801C122C
lwz r3, gameSystem__4Game@sda21(r13)
li r0, 1
stw r0, 0x44(r3)
b lbl_801C1238
lbl_801C122C:
lwz r3, gameSystem__4Game@sda21(r13)
li r0, 2
stw r0, 0x44(r3)
lbl_801C1238:
lwz r4, gameSystem__4Game@sda21(r13)
li r5, 1
li r0, 0
lis r3, lbl_8047FFD8@ha
stb r5, 0x48(r4)
addi r4, r3, lbl_8047FFD8@l
addi r3, r31, 0x224
stb r0, 0x11c(r31)
stw r0, 0x1fc(r31)
stw r0, 0x3bc(r31)
stb r0, 0x204(r31)
crclr 6
bl sprintf
addi r3, r31, 0x2a4
addi r4, r2, lbl_805194B0@sda21
crclr 6
bl sprintf
mr r3, r31
bl setupFixMemory__Q24Game15BaseGameSectionFv
li r3, 0x94
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C129C
bl __ct__Q34Game13ChallengeGame9StageListFv
mr r0, r3
lbl_801C129C:
stw r0, 0x20c(r31)
mr r3, r31
lwz r4, 0x20c(r31)
bl addGenNode__Q24Game14BaseHIOSectionFP5CNode
li r3, 0xcc
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C12C4
bl __ct__Q34Game6VsGame9StageListFv
mr r0, r3
lbl_801C12C4:
stw r0, 0x210(r31)
mr r3, r31
lwz r4, 0x210(r31)
bl addGenNode__Q24Game14BaseHIOSectionFP5CNode
mr r3, r31
bl loadChallengeStageList__Q24Game13VsGameSectionFv
mr r3, r31
bl loadVsStageList__Q24Game13VsGameSectionFv
li r3, 0x1c
bl __nw__FUl
cmplwi r3, 0
beq lbl_801C1314
lis r5, "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"@ha
lis r4, __vt__Q34Game6VsGame3FSM@ha
addi r0, r5, "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"@l
li r5, -1
stw r0, 0(r3)
addi r0, r4, __vt__Q34Game6VsGame3FSM@l
stw r5, 0x18(r3)
stw r0, 0(r3)
lbl_801C1314:
stw r3, 0x17c(r31)
mr r4, r31
lwz r3, 0x17c(r31)
lwz r12, 0(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
mr r3, r31
bl initPlayData__Q24Game13VsGameSectionFv
lwz r3, 0x17c(r31)
mr r4, r31
li r5, 0
li r6, 0
lwz r12, 0(r3)
lwz r12, 0xc(r12)
mtctr r12
bctrl
li r0, 0
lfs f0, lbl_805194A8@sda21(r2)
stw r0, 0x324(r31)
li r3, 0x5c
stfs f0, 0x35c(r31)
stfs f0, 0x358(r31)
stfs f0, 0x374(r31)
stfs f0, 0x370(r31)
stfs f0, 0x364(r31)
stfs f0, 0x360(r31)
stfs f0, 0x36c(r31)
stfs f0, 0x368(r31)
stfs f0, 0x37c(r31)
stfs f0, 0x378(r31)
stw r0, 0x384(r31)
stw r0, 0x380(r31)
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C13AC
bl __ct__Q25Radar3MgrFv
mr r0, r3
lbl_801C13AC:
stw r0, mgr__5Radar@sda21(r13)
li r0, 0
stw r0, 0x388(r31)
stw r0, 0x38c(r31)
stw r0, 0x390(r31)
stw r0, 0x394(r31)
stw r0, 0x398(r31)
stw r0, 0x39c(r31)
stw r0, 0x3a0(r31)
lwz r31, 0xc(r1)
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C13E4
* Size: 000034
*/
void start__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSectioniPQ24Game8StateArg(void)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
li r0, 0
stw r0, 0x180(r4)
lwz r12, 0x0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1418
* Size: 000008
*/
void VsGameSection::getCurrFloor(void)
{
/*
lwz r3, 0x324(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C1420
* Size: 0001B8
*/
void VsGameSection::doUpdate(void)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stfd f31, 0x30(r1)
psq_st f31, 56(r1), 0, qr0
stw r31, 0x2c(r1)
stw r30, 0x28(r1)
stw r29, 0x24(r1)
mr r29, r3
lbz r0, 0x204(r3)
cmplwi r0, 0
beq lbl_801C1460
li r0, 0
li r3, 0
stb r0, 0x34(r29)
b lbl_801C15B4
lbl_801C1460:
lwz r3, 0x17c(r29)
mr r4, r29
lwz r12, 0(r3)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lwz r3, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r3)
cmpwi r0, 1
bne lbl_801C15B0
li r3, 1
bl getMapPikmins__Q24Game8GameStatFi
lwz r4, 0x344(r29)
addi r0, r4, -3
subf r31, r0, r3
li r3, 0
bl getMapPikmins__Q24Game8GameStatFi
lwz r4, 0x348(r29)
cmpwi r31, 0
addi r0, r4, -3
subf r30, r0, r3
bge lbl_801C14BC
li r31, 1
lbl_801C14BC:
cmpwi r30, 0
bge lbl_801C14C8
li r30, 1
lbl_801C14C8:
cmpwi r31, 0
beq lbl_801C14D8
cmpwi r30, 0
bne lbl_801C1500
lbl_801C14D8:
cmpwi r31, 0
bne lbl_801C14EC
lfs f0, lbl_805194B8@sda21(r2)
stfs f0, 0x354(r29)
b lbl_801C15B0
lbl_801C14EC:
cmpwi r30, 0
bne lbl_801C15B0
lfs f0, lbl_805194A8@sda21(r2)
stfs f0, 0x354(r29)
b lbl_801C15B0
lbl_801C1500:
cmpw r30, r31
ble lbl_801C1544
lis r3, 0x4330
xoris r4, r30, 0x8000
xoris r0, r31, 0x8000
stw r4, 0xc(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r3, 8(r1)
lfd f0, 8(r1)
stw r0, 0x14(r1)
fsubs f1, f0, f2
stw r3, 0x10(r1)
lfd f0, 0x10(r1)
fsubs f0, f0, f2
fdivs f0, f1, f0
stfs f0, 0x350(r29)
b lbl_801C157C
lbl_801C1544:
lis r3, 0x4330
xoris r4, r31, 0x8000
xoris r0, r30, 0x8000
stw r4, 0x14(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r3, 0x10(r1)
lfd f0, 0x10(r1)
stw r0, 0xc(r1)
fsubs f1, f0, f2
stw r3, 8(r1)
lfd f0, 8(r1)
fsubs f0, f0, f2
fdivs f0, f1, f0
stfs f0, 0x350(r29)
lbl_801C157C:
lfd f1, lbl_805194C0@sda21(r2)
bl log10
frsp f31, f1
lfs f1, 0x350(r29)
bl log10
frsp f0, f1
cmpw r31, r30
fdivs f0, f0, f31
stfs f0, 0x354(r29)
bge lbl_801C15B0
lfs f0, 0x354(r29)
fneg f0, f0
stfs f0, 0x354(r29)
lbl_801C15B0:
lbz r3, 0x34(r29)
lbl_801C15B4:
psq_l f31, 56(r1), 0, qr0
lwz r0, 0x44(r1)
lfd f31, 0x30(r1)
lwz r31, 0x2c(r1)
lwz r30, 0x28(r1)
lwz r29, 0x24(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C15D8
* Size: 00003C
*/
void VsGameSection::pre2dDraw(Graphics&)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
cmplwi r3, 0
beq lbl_801C1604
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lbl_801C1604:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1614
* Size: 000004
*/
void VsGame::State::pre2dDraw(Graphics&, Game::VsGameSection*) { }
/*
* --INFO--
* Address: 801C1618
* Size: 000050
*/
void VsGameSection::doDraw(Graphics&)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
lbz r0, 0x204(r3)
cmplwi r0, 0
bne lbl_801C1658
lwz r3, 0x180(r6)
cmplwi r3, 0
beq lbl_801C1658
lwz r12, 0(r3)
mr r4, r6
lwz r12, 0x20(r12)
mtctr r12
bctrl
lbl_801C1658:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1668
* Size: 0001DC
*/
void VsGameSection::onSetSoundScene(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r4, lbl_8047FF98@ha
stw r0, 0x64(r1)
stw r31, 0x5c(r1)
addi r31, r4, lbl_8047FF98@l
stw r30, 0x58(r1)
mr r30, r3
addi r3, r1, 8
bl __ct__Q26PSGame9SceneInfoFv
lis r5, __vt__Q26PSGame13CaveFloorInfo@ha
lis r3, 0x0000FFFF@ha
li r4, 0
li r0, 0xff
addi r5, r5, __vt__Q26PSGame13CaveFloorInfo@l
addi r3, r3, 0x0000FFFF@l
stw r5, 8(r1)
lwz r5, gameSystem__4Game@sda21(r13)
stw r4, 0x40(r1)
stw r4, 0x44(r1)
stb r4, 0x48(r1)
stw r3, 0x4c(r1)
stb r0, 0x50(r1)
stb r0, 0x51(r1)
lwz r0, 0x44(r5)
cmpwi r0, 2
beq lbl_801C16DC
cmpwi r0, 3
bne lbl_801C16E0
lbl_801C16DC:
li r4, 1
lbl_801C16E0:
clrlwi. r0, r4, 0x18
beq lbl_801C1714
li r0, 6
mr r3, r30
stb r0, 0xe(r1)
lwz r12, 0(r30)
lwz r12, 0x58(r12)
mtctr r12
bctrl
stb r3, 0x48(r1)
lwz r0, 0x338(r30)
stb r0, 0x51(r1)
b lbl_801C1724
lbl_801C1714:
li r0, 7
stb r0, 0xe(r1)
lwz r0, 0x340(r30)
stb r0, 0x48(r1)
lbl_801C1724:
lwz r4, mapMgr__4Game@sda21(r13)
li r3, 0
lwz r5, gameSystem__4Game@sda21(r13)
lwz r4, 0x2c(r4)
lwz r0, 0x22c(r4)
stw r0, 0x40(r1)
stw r3, 0x44(r1)
lwz r0, 0x44(r5)
cmpwi r0, 1
beq lbl_801C1754
cmpwi r0, 3
bne lbl_801C1758
lbl_801C1754:
li r3, 1
lbl_801C1758:
clrlwi. r0, r3, 0x18
bne lbl_801C1774
addi r3, r1, 8
li r4, 0
li r5, 1
bl
setStageFlag__Q26PSGame9SceneInfoFQ36PSGame9SceneInfo7FlagDefQ36PSGame9SceneInfo12FlagBitShift
b lbl_801C1784
lbl_801C1774:
addi r3, r1, 8
li r4, 1
li r5, 1
bl
setStageFlag__Q26PSGame9SceneInfoFQ36PSGame9SceneInfo7FlagDefQ36PSGame9SceneInfo12FlagBitShift
lbl_801C1784:
mr r3, r30
addi r4, r1, 8
bl setDefaultPSSceneInfo__Q24Game15BaseGameSectionFRQ26PSGame9SceneInfo lwz
r0, spSceneMgr__8PSSystem@sda21(r13) cmplwi r0, 0 bne lbl_801C17B0 addi
r3, r31, 0x1c addi r5, r31, 0x28 li r4, 0x1d3 crclr 6 bl
panic_f__12JUTExceptionFPCciPCce
lbl_801C17B0:
lwz r3, spSceneMgr__8PSSystem@sda21(r13)
addi r4, r1, 8
lwz r12, 0(r3)
lwz r12, 0xc(r12)
mtctr r12
bctrl
lwz r0, spSceneMgr__8PSSystem@sda21(r13)
cmplwi r0, 0
bne lbl_801C17E8
addi r3, r31, 0x1c
addi r5, r31, 0x28
li r4, 0x1d3
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C17E8:
lwz r30, spSceneMgr__8PSSystem@sda21(r13)
lwz r0, 4(r30)
cmplwi r0, 0
bne lbl_801C180C
addi r3, r31, 0x34
addi r5, r31, 0x28
li r4, 0xc7
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C180C:
lwz r3, 4(r30)
lwz r3, 4(r3)
lwz r12, 0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
lwz r3, naviMgr__4Game@sda21(r13)
bl createPSMDirectorUpdator__Q24Game7NaviMgrFv
lwz r0, 0x64(r1)
lwz r31, 0x5c(r1)
lwz r30, 0x58(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C1844
* Size: 00005C
*/
void VsGameSection::initPlayData(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r3, playData__4Game@sda21(r13)
bl reset__Q24Game8PlayDataFv
lwz r3, playData__4Game@sda21(r13)
li r4, 1
li r5, 1
bl setDevelopSetting__Q24Game8PlayDataFbb
lwz r4, naviMgr__4Game@sda21(r13)
lwz r3, playData__4Game@sda21(r13)
lwz r4, 0xc8(r4)
lfs f0, 0x9d0(r4)
stfs f0, 0x24(r3)
lwz r4, naviMgr__4Game@sda21(r13)
lwz r3, playData__4Game@sda21(r13)
lwz r4, 0xc8(r4)
lfs f0, 0x9d0(r4)
stfs f0, 0x28(r3)
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C18A0
* Size: 000168
*/
void VsGameSection::onSetupFloatMemory(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r4, lbl_8047FF98@ha
stw r0, 0x64(r1)
li r0, 0
stmw r26, 0x48(r1)
mr r26, r3
addi r31, r4, lbl_8047FF98@l
li r3, 0x28
stw r0, farmMgr__Q24Game4Farm@sda21(r13)
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C18DC
bl __ct__Q34Game6VsGame7TekiMgrFv
mr r0, r3
lbl_801C18DC:
stw r0, 0x32c(r26)
li r3, 0x114
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C1900
lwz r5, 0x32c(r26)
mr r4, r26
bl
__ct__Q34Game6VsGame7CardMgrFPQ24Game13VsGameSectionPQ34Game6VsGame7TekiMgr mr
r0, r3
lbl_801C1900:
stw r0, 0x330(r26)
lwz r3, 0x330(r26)
bl loadResource__Q34Game6VsGame7CardMgrFv
lwz r6, 0x50(r31)
lis r4, __vt__Q24Game15CreatureInitArg@ha
lwz r5, 0x54(r31)
lis r3, __vt__Q24Game13PelletInitArg@ha
lwz r0, 0x58(r31)
addi r30, r1, 0xc
stw r6, 0xc(r1)
addi r27, r4, __vt__Q24Game15CreatureInitArg@l
lwz r4, cBedamaRed__13VsOtakaraName@sda21(r13)
addi r28, r3, __vt__Q24Game13PelletInitArg@l
stw r5, 0x10(r1)
li r26, 0
lwz r3, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r0, 0x14(r1)
lwz r0, cBedamaYellow__13VsOtakaraName@sda21(r13)
stw r4, 0xc(r1)
stw r3, 0x10(r1)
stw r0, 0x14(r1)
lbl_801C1954:
stw r27, 0x18(r1)
li r7, 0
li r0, -1
li r6, 0xff
li r5, 1
stw r28, 0x18(r1)
lwz r3, 0(r30)
addi r4, r1, 8
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C19C0
addi r3, r31, 0x5c
addi r5, r31, 0x70
li r4, 0x388
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C19C0:
lha r3, 0x258(r29)
addi r4, r1, 0x18
lwz r0, 8(r1)
stw r3, 0x28(r1)
lwz r3, pelletMgr__4Game@sda21(r13)
lwz r5, 0x40(r29)
stw r5, 0x20(r1)
stb r0, 0x2e(r1)
bl setUse__Q24Game9PelletMgrFPQ24Game13PelletInitArg
addi r26, r26, 1
addi r30, r30, 4
cmpwi r26, 3
blt lbl_801C1954
lmw r26, 0x48(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C1A08
* Size: 0000A0
*/
void VsGameSection::postSetupFloatMemory(void)
{
/*
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
stw r31, 0x1c(r1)
mr r31, r3
lwz r4, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r4)
cmpwi r0, 1
bne lbl_801C1A8C
lfs f0, lbl_805194A8@sda21(r2)
li r0, 0
addi r4, r1, 8
stfs f0, 0x35c(r31)
stfs f0, 0x358(r31)
stw r0, 0x384(r31)
stw r0, 0x380(r31)
stfs f0, 8(r1)
stfs f0, 0xc(r1)
stfs f0, 0x10(r1)
bl "createRedBlueBedamas__Q24Game13VsGameSectionFR10Vector3<f>"
li r0, 0
mr r3, r31
stw r0, 0x388(r31)
li r4, 7
stw r0, 0x38c(r31)
stw r0, 0x390(r31)
stw r0, 0x394(r31)
stw r0, 0x398(r31)
stw r0, 0x39c(r31)
stw r0, 0x3a0(r31)
bl createYellowBedamas__Q24Game13VsGameSectionFi
mr r3, r31
bl initCardPellets__Q24Game13VsGameSectionFv
lbl_801C1A8C:
mr r3, r31
bl postSetupFloatMemory__Q24Game15BaseGameSectionFv
lwz r0, 0x24(r1)
lwz r31, 0x1c(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C1AA8
* Size: 000020
*/
void VsGameSection::onClearHeap(void)
{
/*
lwz r4, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r4)
cmpwi r0, 1
bnelr
li r0, 0
stw r0, 0x3d0(r3)
stw r0, 0x3cc(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C1AC8
* Size: 0000B0
*/
void VsGameSection::loadChallengeStageList(void)
{
/*
stwu r1, -0x440(r1)
mflr r0
lis r4, gGameConfig__4Game@ha
stw r0, 0x444(r1)
addi r5, r4, gGameConfig__4Game@l
li r0, 0
lis r4, lbl_8048003C@ha
stw r31, 0x43c(r1)
mr r31, r3
addi r3, r4, lbl_8048003C@l
stw r0, 8(r1)
lwz r0, 0x228(r5)
cmpwi r0, 0
beq lbl_801C1B08
lis r3, lbl_80480014@ha
addi r3, r3, lbl_80480014@l
lbl_801C1B08:
li r4, 0
li r5, 0
li r6, 0
li r7, 0
li r8, 2
li r9, 0
li r10, 0
bl
loadToMainRAM__12JKRDvdRipperFPCcPUc15JKRExpandSwitchUlP7JKRHeapQ212JKRDvdRipper15EAllocDirectionUlPiPUl
cmplwi r3, 0
beq lbl_801C1B64
mr r4, r3
addi r3, r1, 0x10
li r5, -1
bl __ct__9RamStreamFPvi
li r0, 1
cmpwi r0, 1
stw r0, 0x1c(r1)
bne lbl_801C1B58
li r0, 0
stw r0, 0x424(r1)
lbl_801C1B58:
lwz r3, 0x20c(r31)
addi r4, r1, 0x10
bl read__Q34Game13ChallengeGame9StageListFR6Stream
lbl_801C1B64:
lwz r0, 0x444(r1)
lwz r31, 0x43c(r1)
mtlr r0
addi r1, r1, 0x440
blr
*/
}
/*
* --INFO--
* Address: 801C1B78
* Size: 000098
*/
void VsGameSection::loadVsStageList(void)
{
/*
stwu r1, -0x440(r1)
mflr r0
lis r4, lbl_80480060@ha
li r5, 0
stw r0, 0x444(r1)
li r0, 0
li r6, 0
li r7, 0
stw r31, 0x43c(r1)
mr r31, r3
li r8, 2
li r9, 0
stw r0, 8(r1)
addi r0, r4, lbl_80480060@l
li r4, 0
li r10, 0
mr r3, r0
bl
loadToMainRAM__12JKRDvdRipperFPCcPUc15JKRExpandSwitchUlP7JKRHeapQ212JKRDvdRipper15EAllocDirectionUlPiPUl
cmplwi r3, 0
beq lbl_801C1BFC
mr r4, r3
addi r3, r1, 0x10
li r5, -1
bl __ct__9RamStreamFPvi
li r0, 1
cmpwi r0, 1
stw r0, 0x1c(r1)
bne lbl_801C1BF0
li r0, 0
stw r0, 0x424(r1)
lbl_801C1BF0:
lwz r3, 0x210(r31)
addi r4, r1, 0x10
bl read__Q34Game6VsGame9StageListFR6Stream
lbl_801C1BFC:
lwz r0, 0x444(r1)
lwz r31, 0x43c(r1)
mtlr r0
addi r1, r1, 0x440
blr
*/
}
/*
* --INFO--
* Address: 801C1C10
* Size: 000044
*/
void VsGameSection::gmOrimaDown(int)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
cmplwi r3, 0
beq lbl_801C1C44
lwz r12, 0(r3)
mr r4, r6
lwz r12, 0x28(r12)
mtctr r12
bctrl
lbl_801C1C44:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1C54
* Size: 000004
*/
void VsGame::State::onOrimaDown(Game::VsGameSection*, int) { }
/*
* --INFO--
* Address: 801C1C58
* Size: 000004
*/
void VsGameSection::gmPikminZero(void) { }
/*
* --INFO--
* Address: 801C1C5C
* Size: 00003C
*/
void VsGameSection::goNextFloor(Game::ItemHole::Item*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
mr r4, r6
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x34(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1C98
* Size: 000004
*/
void VsGame::State::onNextFloor(Game::VsGameSection*, Game::ItemHole::Item*) { }
/*
* --INFO--
* Address: 801C1C9C
* Size: 0001D8
*/
void VsGameSection::openCaveMoreMenu(Game::ItemHole::Item*, Controller*)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stw r31, 0x3c(r1)
mr r31, r4
stw r30, 0x38(r1)
mr r30, r3
mr r4, r30
stw r29, 0x34(r1)
mr r29, r5
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x3c(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C1E58
lwz r4, gameSystem__4Game@sda21(r13)
li r3, 0
lwz r0, 0x44(r4)
cmpwi r0, 1
beq lbl_801C1CFC
cmpwi r0, 3
bne lbl_801C1D00
lbl_801C1CFC:
li r3, 1
lbl_801C1D00:
clrlwi. r0, r3, 0x18
beq lbl_801C1D20
cmplwi r29, 0
beq lbl_801C1D20
lwz r3, gGame2DMgr__6Screen@sda21(r13)
mr r4, r29
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
b lbl_801C1D2C
lbl_801C1D20:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
lwz r4, 0x10c(r30)
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
lbl_801C1D2C:
lis r3, __vt__Q32og6Screen14DispMemberBase@ha
li r11, 0
addi r0, r3, __vt__Q32og6Screen14DispMemberBase@l
li r8, 1
lis r3, 0x745F3031@ha
lis r6, __vt__Q32og6Screen17DispMemberAnaDemo@ha
addi r7, r3, 0x745F3031@l
stw r0, 8(r1)
li r10, 0x18
li r9, 0x45
addi r0, r6, __vt__Q32og6Screen17DispMemberAnaDemo@l
stw r11, 0x28(r1)
lis r5, __vt__Q32og6Screen18DispMemberCaveMore@ha
lis r4, 0x32705F63@ha
stw r0, 8(r1)
addi r6, r5, __vt__Q32og6Screen18DispMemberCaveMore@l
addi r0, r4, 0x32705F63@l
li r5, 4
stw r10, 0x10(r1)
li r4, 0xa
lis r3, mePikis__Q24Game8GameStat@ha
stw r9, 0x14(r1)
stw r8, 0x18(r1)
stw r7, 0x20(r1)
stw r11, 0xc(r1)
stb r8, 0x27(r1)
stw r8, 0x1c(r1)
stb r11, 0x24(r1)
stb r11, 0x25(r1)
stw r6, 8(r1)
stb r11, 0x2c(r1)
stb r11, 0x2d(r1)
stw r11, 0x28(r1)
stw r5, 0x10(r1)
stw r5, 0x14(r1)
stw r4, 0x18(r1)
stw r0, 0x20(r1)
lwzu r12, mePikis__Q24Game8GameStat@l(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
or. r29, r3, r3
ble lbl_801C1E08
li r0, 1
li r3, -1
stb r0, 0x2c(r1)
bl getMapPikmins__Q24Game8GameStatFi
cmpw r29, r3
bne lbl_801C1DFC
li r0, 1
stb r0, 0x2d(r1)
b lbl_801C1E14
lbl_801C1DFC:
li r0, 0
stb r0, 0x2d(r1)
b lbl_801C1E14
lbl_801C1E08:
li r0, 0
stb r0, 0x2d(r1)
stb r0, 0x2c(r1)
lbl_801C1E14:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
addi r4, r1, 8
bl open_CaveMoreMenu__Q26Screen9Game2DMgrFRQ32og6Screen18DispMemberCaveMore
clrlwi. r0, r3, 0x18
beq lbl_801C1E58
stw r31, 0x1fc(r30)
lis r3, lbl_80480078@ha
addi r5, r3, lbl_80480078@l
li r4, 1
lwz r3, gameSystem__4Game@sda21(r13)
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lis r4, lbl_80480078@ha
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r4, lbl_80480078@l
li r4, 1
bl setMoviePause__Q24Game10GameSystemFbPc
lbl_801C1E58:
lwz r0, 0x44(r1)
lwz r31, 0x3c(r1)
lwz r30, 0x38(r1)
lwz r29, 0x34(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C1E74
* Size: 000008
*/
u32 VsGame::State::goingToCave(Game::VsGameSection*) { return 0x0; }
/*
* --INFO--
* Address: 801C1E7C
* Size: 0001B0
*/
void VsGameSection::openKanketuMenu(Game::ItemBigFountain::Item*, Controller*)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stw r31, 0x3c(r1)
mr r31, r4
stw r30, 0x38(r1)
mr r30, r3
li r3, 0
stw r29, 0x34(r1)
lwz r6, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r6)
cmpwi r0, 1
beq lbl_801C1EB8
cmpwi r0, 3
bne lbl_801C1EBC
lbl_801C1EB8:
li r3, 1
lbl_801C1EBC:
clrlwi. r0, r3, 0x18
beq lbl_801C1EDC
cmplwi r5, 0
beq lbl_801C1EDC
lwz r3, gGame2DMgr__6Screen@sda21(r13)
mr r4, r5
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
b lbl_801C1EE8
lbl_801C1EDC:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
lwz r4, 0x10c(r30)
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
lbl_801C1EE8:
lis r3, __vt__Q32og6Screen14DispMemberBase@ha
li r9, 0
addi r0, r3, __vt__Q32og6Screen14DispMemberBase@l
li r7, 1
lis r3, __vt__Q32og6Screen17DispMemberAnaDemo@ha
stw r0, 8(r1)
addi r5, r3, __vt__Q32og6Screen17DispMemberAnaDemo@l
li r0, 0x18
li r8, 0x45
stw r9, 0x28(r1)
lis r3, 0x745F3031@ha
lis r4, __vt__Q32og6Screen21DispMemberKanketuMenu@ha
addi r6, r3, 0x745F3031@l
stw r5, 8(r1)
addi r5, r4, __vt__Q32og6Screen21DispMemberKanketuMenu@l
li r4, 4
stw r0, 0x10(r1)
li r0, 0xa
lis r3, mePikis__Q24Game8GameStat@ha
stw r8, 0x14(r1)
stw r7, 0x18(r1)
stw r9, 0xc(r1)
stb r7, 0x27(r1)
stw r7, 0x1c(r1)
stw r6, 0x20(r1)
stb r9, 0x24(r1)
stb r9, 0x25(r1)
stw r5, 8(r1)
stb r9, 0x2c(r1)
stb r9, 0x2d(r1)
stb r9, 0x2e(r1)
stw r9, 0x28(r1)
stw r4, 0x10(r1)
stw r4, 0x14(r1)
stw r0, 0x18(r1)
lwzu r12, mePikis__Q24Game8GameStat@l(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
or. r29, r3, r3
ble lbl_801C1FBC
li r0, 1
li r3, -1
stb r0, 0x2c(r1)
bl getMapPikmins__Q24Game8GameStatFi
cmpw r29, r3
bne lbl_801C1FB0
li r0, 1
stb r0, 0x2d(r1)
b lbl_801C1FC8
lbl_801C1FB0:
li r0, 0
stb r0, 0x2d(r1)
b lbl_801C1FC8
lbl_801C1FBC:
li r0, 0
stb r0, 0x2d(r1)
stb r0, 0x2c(r1)
lbl_801C1FC8:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
addi r4, r1, 8
bl
open_ChallengeKanketuMenu__Q26Screen9Game2DMgrFRQ32og6Screen21DispMemberKanketuMenu
clrlwi. r0, r3, 0x18
beq lbl_801C2010
stw r31, 0x200(r30)
li r4, 1
addi r5, r2, lbl_805194D0@sda21
li r6, 3
lbz r0, 0x1f8(r30)
ori r0, r0, 4
stb r0, 0x1f8(r30)
lwz r3, gameSystem__4Game@sda21(r13)
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 1
addi r5, r2, lbl_805194D0@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbl_801C2010:
lwz r0, 0x44(r1)
lwz r31, 0x3c(r1)
lwz r30, 0x38(r1)
lwz r29, 0x34(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C202C
* Size: 000014
*/
void VsGameSection::clearCaveMenus(void)
{
/*
li r0, 0
stb r0, 0x1f8(r3)
stw r0, 0x1fc(r3)
stw r0, 0x200(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C2040
* Size: 0002A8
*/
void VsGameSection::updateCaveMenus(void)
{
/*
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stw r31, 0x4c(r1)
mr r31, r3
lis r3, lbl_8047FF98@ha
stw r30, 0x48(r1)
addi r30, r3, lbl_8047FF98@l
lbz r4, 0x1f8(r31)
rlwinm. r0, r4, 0, 0x1e, 0x1e
beq lbl_801C217C
lwz r3, gGame2DMgr__6Screen@sda21(r13)
bl check_CaveMoreMenu__Q26Screen9Game2DMgrFv
cmpwi r3, 2
beq lbl_801C2134
bge lbl_801C2090
cmpwi r3, 0
beq lbl_801C22CC
bge lbl_801C209C
b lbl_801C22CC
lbl_801C2090:
cmpwi r3, 4
bge lbl_801C22CC
b lbl_801C2168
lbl_801C209C:
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lfs f0, 0x2a0(r3)
li r4, 1
lwz r3, playData__4Game@sda21(r13)
stfs f0, 0x24(r3)
lwz r3, naviMgr__4Game@sda21(r13)
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lfs f0, 0x2a0(r3)
addi r5, r30, 0xec
lwz r3, playData__4Game@sda21(r13)
li r4, 0
li r6, 3
stfs f0, 0x28(r3)
lwz r3, gameSystem__4Game@sda21(r13)
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r30, 0xec
li r4, 0
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
mr r3, r31
rlwinm r0, r0, 0, 0x1f, 0x1d
stb r0, 0x1f8(r31)
lwz r12, 0(r31)
lwz r4, 0x1fc(r31)
lwz r12, 0x6c(r12)
mtctr r12
bctrl
li r3, 1
b lbl_801C22D0
lbl_801C2134:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194D8@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194D8@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
rlwinm r0, r0, 0, 0x1f, 0x1d
stb r0, 0x1f8(r31)
b lbl_801C22CC
lbl_801C2168:
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r30, 0xf8
li r4, 0
bl setMoviePause__Q24Game10GameSystemFbPc
b lbl_801C22CC
lbl_801C217C:
rlwinm. r0, r4, 0, 0x1d, 0x1d
beq lbl_801C22CC
lwz r3, gGame2DMgr__6Screen@sda21(r13)
bl check_KanketuMenu__Q26Screen9Game2DMgrFv
cmpwi r3, 2
beq lbl_801C229C
bge lbl_801C22CC
cmpwi r3, 0
beq lbl_801C22CC
bge lbl_801C21AC
b lbl_801C22CC
b lbl_801C22CC
lbl_801C21AC:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E0@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E0@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r3, 0x1f8(r31)
addi r4, r30, 0x104
lfs f0, lbl_805194A8@sda21(r2)
li r0, 0
rlwinm r5, r3, 0, 0x1e, 0x1c
addi r3, r1, 8
stb r5, 0x1f8(r31)
lwz r5, 0xc8(r31)
stw r4, 0x14(r1)
stw r0, 0x18(r1)
stw r5, 0x20(r1)
stfs f0, 0x2c(r1)
stfs f0, 0x30(r1)
stfs f0, 0x34(r1)
stfs f0, 0x38(r1)
stw r0, 0x3c(r1)
stw r0, 0x24(r1)
stw r0, 0x1c(r1)
stw r0, 0x40(r1)
stw r0, 0x28(r1)
stw r0, 0x44(r1)
lwz r4, 0x200(r31)
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f2, 8(r1)
lfs f1, 0xc(r1)
lfs f0, 0x10(r1)
stfs f2, 0x2c(r1)
stfs f1, 0x30(r1)
stfs f0, 0x34(r1)
lwz r3, 0x200(r31)
lwz r12, 0(r3)
lwz r12, 0x64(r12)
mtctr r12
bctrl
stfs f1, 0x38(r1)
li r4, 0
lwz r0, 0xcc(r31)
stw r0, 0x24(r1)
lwz r3, 0x200(r31)
bl movie_begin__Q24Game8CreatureFb
lwz r0, 0x200(r31)
addi r4, r1, 0x14
lwz r3, moviePlayer__4Game@sda21(r13)
stw r0, 0x194(r3)
lwz r3, moviePlayer__4Game@sda21(r13)
bl play__Q24Game11MoviePlayerFRQ24Game12MoviePlayArg
li r3, 1
b lbl_801C22D0
lbl_801C229C:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E8@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E8@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
rlwinm r0, r0, 0, 0x1e, 0x1c
stb r0, 0x1f8(r31)
lbl_801C22CC:
li r3, 0
lbl_801C22D0:
lwz r0, 0x54(r1)
lwz r31, 0x4c(r1)
lwz r30, 0x48(r1)
mtlr r0
addi r1, r1, 0x50
blr
*/
}
/*
* --INFO--
* Address: 801C22E8
* Size: 000008
*/
void ItemBigFountain::Item::getFaceDir(void)
{
/*
lfs f1, 0x1ec(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C22F0
* Size: 0000DC
*/
void VsGameSection::onMovieStart(Game::MovieConfig*, unsigned long, unsigned long)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
lis r7, 0x8048
stw r0, 0x24(r1)
stw r31, 0x1C(r1)
mr r31, r6
stw r30, 0x18(r1)
mr r30, r5
stw r29, 0x14(r1)
mr r29, r4
addi r4, r7, 0xAC
stw r28, 0x10(r1)
mr r28, r3
mr r3, r29
bl 0x26F5A4
lwz r4, -0x6C18(r13)
li r3, 0
lwz r0, 0x44(r4)
cmpwi r0, 0x1
beq- .loc_0x58
cmpwi r0, 0x3
bne- .loc_0x5C
.loc_0x58:
li r3, 0x1
.loc_0x5C:
rlwinm. r0,r3,0,24,31
beq- .loc_0x88
cmplwi r31, 0x1
bne- .loc_0x7C
mr r3, r28
li r4, 0x1
bl -0x74A4C
b .loc_0x88
.loc_0x7C:
mr r3, r28
li r4, 0
bl -0x74A5C
.loc_0x88:
mr r3, r28
bl -0x745F4
lwz r3, 0x180(r28)
cmplwi r3, 0
beq- .loc_0xBC
lwz r12, 0x0(r3)
mr r4, r28
mr r5, r29
mr r6, r30
lwz r12, 0x2C(r12)
mr r7, r31
mtctr r12
bctrl
.loc_0xBC:
lwz r0, 0x24(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C23CC
* Size: 000004
*/
void VsGame::State::onMovieStart(Game::VsGameSection*, Game::MovieConfig*, unsigned long, unsigned long) { }
/*
* --INFO--
* Address: 801C23D0
* Size: 000054
*/
void VsGameSection::onMovieDone(Game::MovieConfig*, unsigned long, unsigned long)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
mr r9, r3
mr r8, r4
stw r0, 0x14(r1)
mr r0, r5
mr r7, r6
lwz r3, 0x180(r3)
cmplwi r3, 0
beq- .loc_0x44
lwz r12, 0x0(r3)
mr r4, r9
mr r5, r8
mr r6, r0
lwz r12, 0x30(r12)
mtctr r12
bctrl
.loc_0x44:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2424
* Size: 000004
*/
void VsGame::State::onMovieDone(Game::VsGameSection*, Game::MovieConfig*, unsigned long, unsigned long) { }
/*
* --INFO--
* Address: 801C2428
* Size: 000434
*/
void VsGameSection::createFallPikmins(Game::PikiContainer&, int)
{
/*
stwu r1, -0x160(r1)
mflr r0
stw r0, 0x164(r1)
stfd f31, 0x150(r1)
psq_st f31, 344(r1), 0, qr0
stfd f30, 0x140(r1)
psq_st f30, 328(r1), 0, qr0
stfd f29, 0x130(r1)
psq_st f29, 312(r1), 0, qr0
stfd f28, 0x120(r1)
psq_st f28, 296(r1), 0, qr0
stfd f27, 0x110(r1)
psq_st f27, 280(r1), 0, qr0
stfd f26, 0x100(r1)
psq_st f26, 264(r1), 0, qr0
stfd f25, 0xf0(r1)
psq_st f25, 248(r1), 0, qr0
stfd f24, 0xe0(r1)
psq_st f24, 232(r1), 0, qr0
stfd f23, 0xd0(r1)
psq_st f23, 216(r1), 0, qr0
stfd f22, 0xc0(r1)
psq_st f22, 200(r1), 0, qr0
stfd f21, 0xb0(r1)
psq_st f21, 184(r1), 0, qr0
stfd f20, 0xa0(r1)
psq_st f20, 168(r1), 0, qr0
stmw r25, 0x84(r1)
lwz r3, mapMgr__4Game@sda21(r13)
mr r26, r4
addi r4, r1, 0x38
lwz r12, 4(r3)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lis r4, lbl_804800BC@ha
mr r3, r26
addi r4, r4, lbl_804800BC@l
bl dump__Q24Game13PikiContainerFPc
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
mr r0, r3
addi r3, r1, 8
mr r4, r0
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f2, 8(r1)
addi r4, r1, 0x38
lfs f1, 0xc(r1)
lfs f0, 0x10(r1)
stfs f2, 0x38(r1)
lwz r3, mapMgr__4Game@sda21(r13)
stfs f1, 0x3c(r1)
stfs f0, 0x40(r1)
lwz r12, 4(r3)
lwz r12, 0x28(r12)
mtctr r12
bctrl
lis r3, sincosTable___5JMath@ha
stfs f1, 0x3c(r1)
lfd f22, lbl_805194C8@sda21(r2)
addi r31, r3, sincosTable___5JMath@l
lfs f23, lbl_805194F0@sda21(r2)
li r29, 0
lfs f24, lbl_805194F8@sda21(r2)
lis r30, 0x4330
lfs f25, lbl_805194F4@sda21(r2)
lfs f26, lbl_805194FC@sda21(r2)
lfs f27, lbl_80519500@sda21(r2)
lfs f28, lbl_80519508@sda21(r2)
lfs f29, lbl_80519504@sda21(r2)
lfs f30, lbl_805194A8@sda21(r2)
lfs f31, lbl_8051950C@sda21(r2)
lbl_801C2564:
li r28, 0
lbl_801C2568:
li r27, 0
b lbl_801C27AC
lbl_801C2570:
bl rand
xoris r0, r3, 0x8000
stw r30, 0x48(r1)
stw r0, 0x4c(r1)
lfd f0, 0x48(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmadds f21, f24, f0, f25
bl rand
xoris r0, r3, 0x8000
stw r30, 0x50(r1)
stw r0, 0x54(r1)
lfd f0, 0x50(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmuls f20, f26, f0
bl rand
xoris r0, r3, 0x8000
stw r30, 0x58(r1)
fmr f1, f20
stw r0, 0x5c(r1)
fcmpo cr0, f20, f30
lfd f0, 0x58(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmadds f0, f28, f0, f29
fadds f2, f27, f0
bge lbl_801C25E4
fneg f1, f20
lbl_801C25E4:
fmuls f0, f1, f31
fcmpo cr0, f20, f30
fctiwz f0, f0
stfd f0, 0x60(r1)
lwz r0, 0x64(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r31, r0
lfs f0, 4(r3)
fmuls f1, f21, f0
bge lbl_801C2638
lfs f0, lbl_80519510@sda21(r2)
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fmuls f0, f20, f0
fctiwz f0, f0
stfd f0, 0x68(r1)
lwz r0, 0x6c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
fneg f0, f0
b lbl_801C2658
lbl_801C2638:
fmuls f0, f20, f31
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fctiwz f0, f0
stfd f0, 0x70(r1)
lwz r0, 0x74(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
lbl_801C2658:
fmuls f0, f21, f0
stfs f2, 0x30(r1)
lwz r3, pikiMgr__4Game@sda21(r13)
stfs f1, 0x34(r1)
stfs f0, 0x2c(r1)
lwz r12, 0(r3)
lwz r12, 0x7c(r12)
mtctr r12
bctrl
lfs f1, 0x2c(r1)
or. r25, r3, r3
lfs f0, 0x38(r1)
lfs f3, 0x30(r1)
fadds f4, f1, f0
lfs f2, 0x3c(r1)
lfs f1, 0x34(r1)
lfs f0, 0x40(r1)
fadds f2, f3, f2
stfs f4, 0x2c(r1)
fadds f0, f1, f0
stfs f2, 0x30(r1)
stfs f0, 0x34(r1)
beq lbl_801C27A8
lis r5, __vt__Q24Game15CreatureInitArg@ha
lis r4, __vt__Q24Game11PikiInitArg@ha
addi r0, r5, __vt__Q24Game15CreatureInitArg@l
li r5, 0xf
stw r0, 0x20(r1)
addi r6, r4, __vt__Q24Game11PikiInitArg@l
li r0, 0
addi r4, r1, 0x20
stw r6, 0x20(r1)
stw r5, 0x24(r1)
stw r0, 0x28(r1)
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x74(r1)
mr r3, r25
lfd f3, lbl_805194C8@sda21(r2)
addi r4, r1, 0x2c
stw r0, 0x70(r1)
li r5, 0
lfs f1, lbl_805194F0@sda21(r2)
lfd f2, 0x70(r1)
lfs f0, lbl_805194FC@sda21(r2)
fsubs f2, f2, f3
fdivs f1, f2, f1
fmuls f0, f0, f1
stfs f0, 0x1fc(r25)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
mr r3, r25
mr r4, r29
bl changeShape__Q24Game4PikiFi
mr r3, r25
mr r4, r28
bl changeHappa__Q24Game4PikiFi
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x6c(r1)
mr r3, r25
lfs f2, lbl_805194A8@sda21(r2)
addi r4, r1, 0x14
stw r0, 0x68(r1)
lfd f1, lbl_805194C8@sda21(r2)
lfd f0, 0x68(r1)
lfs f3, lbl_805194F0@sda21(r2)
fsubs f4, f0, f1
lfs f1, lbl_80519518@sda21(r2)
lfs f0, lbl_80519514@sda21(r2)
stfs f2, 0x14(r1)
fdivs f3, f4, f3
stfs f2, 0x1c(r1)
fnmadds f0, f1, f3, f0
stfs f0, 0x18(r1)
lwz r12, 0(r25)
lwz r12, 0x68(r12)
mtctr r12
bctrl
mr r3, r25
li r4, 0
bl movie_begin__Q24Game8CreatureFb
lbl_801C27A8:
addi r27, r27, 1
lbl_801C27AC:
mr r3, r26
mr r4, r29
mr r5, r28
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0(r3)
cmpw r27, r0
blt lbl_801C2570
addi r28, r28, 1
cmpwi r28, 3
blt lbl_801C2568
addi r29, r29, 1
cmpwi r29, 7
blt lbl_801C2564
mr r3, r26
bl clear__Q24Game13PikiContainerFv
psq_l f31, 344(r1), 0, qr0
lfd f31, 0x150(r1)
psq_l f30, 328(r1), 0, qr0
lfd f30, 0x140(r1)
psq_l f29, 312(r1), 0, qr0
lfd f29, 0x130(r1)
psq_l f28, 296(r1), 0, qr0
lfd f28, 0x120(r1)
psq_l f27, 280(r1), 0, qr0
lfd f27, 0x110(r1)
psq_l f26, 264(r1), 0, qr0
lfd f26, 0x100(r1)
psq_l f25, 248(r1), 0, qr0
lfd f25, 0xf0(r1)
psq_l f24, 232(r1), 0, qr0
lfd f24, 0xe0(r1)
psq_l f23, 216(r1), 0, qr0
lfd f23, 0xd0(r1)
psq_l f22, 200(r1), 0, qr0
lfd f22, 0xc0(r1)
psq_l f21, 184(r1), 0, qr0
lfd f21, 0xb0(r1)
psq_l f20, 168(r1), 0, qr0
lfd f20, 0xa0(r1)
lmw r25, 0x84(r1)
lwz r0, 0x164(r1)
mtlr r0
addi r1, r1, 0x160
blr
*/
}
/*
* --INFO--
* Address: 801C285C
* Size: 000564
*/
void VsGameSection::createVsPikmins(void)
{
/*
stwu r1, -0x1b0(r1)
mflr r0
stw r0, 0x1b4(r1)
stfd f31, 0x1a0(r1)
psq_st f31, 424(r1), 0, qr0
stfd f30, 0x190(r1)
psq_st f30, 408(r1), 0, qr0
stfd f29, 0x180(r1)
psq_st f29, 392(r1), 0, qr0
stfd f28, 0x170(r1)
psq_st f28, 376(r1), 0, qr0
stfd f27, 0x160(r1)
psq_st f27, 360(r1), 0, qr0
stfd f26, 0x150(r1)
psq_st f26, 344(r1), 0, qr0
stfd f25, 0x140(r1)
psq_st f25, 328(r1), 0, qr0
stfd f24, 0x130(r1)
psq_st f24, 312(r1), 0, qr0
stfd f23, 0x120(r1)
psq_st f23, 296(r1), 0, qr0
stfd f22, 0x110(r1)
psq_st f22, 280(r1), 0, qr0
stfd f21, 0x100(r1)
psq_st f21, 264(r1), 0, qr0
stfd f20, 0xf0(r1)
psq_st f20, 248(r1), 0, qr0
stfd f19, 0xe0(r1)
psq_st f19, 232(r1), 0, qr0
stfd f18, 0xd0(r1)
psq_st f18, 216(r1), 0, qr0
stfd f17, 0xc0(r1)
psq_st f17, 200(r1), 0, qr0
stfd f16, 0xb0(r1)
psq_st f16, 184(r1), 0, qr0
stmw r24, 0x90(r1)
mr r25, r3
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
li r4, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
or. r26, r3, r3
bne lbl_801C2920
lis r3, lbl_8047FFF4@ha
lis r5, lbl_8047FFC0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x545
addi r5, r5, lbl_8047FFC0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C2920:
mr r4, r26
addi r3, r1, 0x28
lwz r12, 0(r26)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f25, 0x28(r1)
li r4, 0
lfs f24, 0x2c(r1)
lfs f23, 0x30(r1)
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
bl getOnyon__Q34Game9ItemOnyon3MgrFi
or. r26, r3, r3
bne lbl_801C2974
lis r3, lbl_8047FFF4@ha
lis r5, lbl_8047FFC0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x54a
addi r5, r5, lbl_8047FFC0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C2974:
mr r4, r26
addi r3, r1, 0x1c
lwz r12, 0(r26)
lwz r12, 8(r12)
mtctr r12
bctrl
addi r29, r25, 0x214
lfs f22, 0x1c(r1)
lfs f21, 0x20(r1)
mr r3, r29
lfs f20, 0x24(r1)
bl clear__Q24Game13PikiContainerFv
mr r3, r29
li r4, 1
li r5, 0
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0x344(r25)
li r4, 0
li r5, 0
mulli r0, r0, 5
stw r0, 0(r3)
mr r3, r29
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0x348(r25)
li r28, 0
mulli r0, r0, 5
stw r0, 0(r3)
lbl_801C29E0:
cmpwi r28, 1
bne lbl_801C29F8
fmr f19, f25
fmr f18, f24
fmr f17, f23
b lbl_801C2A0C
lbl_801C29F8:
cmpwi r28, 0
bne lbl_801C2BD4
fmr f19, f22
fmr f18, f21
fmr f17, f20
lbl_801C2A0C:
lis r3, sincosTable___5JMath@ha
lfd f26, lbl_805194C8@sda21(r2)
lfs f27, lbl_805194F0@sda21(r2)
addi r31, r3, sincosTable___5JMath@l
lfs f28, lbl_8051951C@sda21(r2)
li r27, 0
lfs f29, lbl_805194FC@sda21(r2)
lis r30, 0x4330
lfs f30, lbl_805194A8@sda21(r2)
lfs f31, lbl_8051950C@sda21(r2)
lbl_801C2A34:
li r26, 0
b lbl_801C2BAC
lbl_801C2A3C:
bl rand
xoris r0, r3, 0x8000
stw r30, 0x68(r1)
stw r0, 0x6c(r1)
lfd f0, 0x68(r1)
fsubs f0, f0, f26
fdivs f0, f0, f27
fmuls f16, f28, f0
bl rand
xoris r0, r3, 0x8000
stw r30, 0x70(r1)
stw r0, 0x74(r1)
lfd f0, 0x70(r1)
fsubs f0, f0, f26
fdivs f0, f0, f27
fmuls f2, f29, f0
fmr f0, f2
fcmpo cr0, f2, f30
bge lbl_801C2A8C
fneg f0, f2
lbl_801C2A8C:
fmuls f0, f0, f31
fcmpo cr0, f2, f30
fctiwz f0, f0
stfd f0, 0x78(r1)
lwz r0, 0x7c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r31, r0
lfs f0, 4(r3)
fmuls f1, f16, f0
bge lbl_801C2AE0
lfs f0, lbl_80519510@sda21(r2)
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fmuls f0, f2, f0
fctiwz f0, f0
stfd f0, 0x80(r1)
lwz r0, 0x84(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
fneg f0, f0
b lbl_801C2B00
lbl_801C2AE0:
fmuls f0, f2, f31
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fctiwz f0, f0
stfd f0, 0x88(r1)
lwz r0, 0x8c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
lbl_801C2B00:
fmuls f0, f16, f0
stfs f30, 0x60(r1)
lwz r3, pikiMgr__4Game@sda21(r13)
stfs f1, 0x64(r1)
stfs f0, 0x5c(r1)
lwz r12, 0(r3)
lwz r12, 0x7c(r12)
mtctr r12
bctrl
lfs f2, 0x5c(r1)
or. r24, r3, r3
lfs f1, 0x60(r1)
lfs f0, 0x64(r1)
fadds f2, f2, f19
fadds f1, f1, f18
fadds f0, f0, f17
stfs f2, 0x5c(r1)
stfs f1, 0x60(r1)
stfs f0, 0x64(r1)
beq lbl_801C2BA8
lis r5, __vt__Q24Game15CreatureInitArg@ha
lis r4, __vt__Q24Game11PikiInitArg@ha
addi r0, r5, __vt__Q24Game15CreatureInitArg@l
li r5, -1
stw r0, 0x50(r1)
addi r6, r4, __vt__Q24Game11PikiInitArg@l
li r0, 0
addi r4, r1, 0x50
stw r6, 0x50(r1)
stw r5, 0x54(r1)
stw r0, 0x58(r1)
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
mr r3, r24
addi r4, r1, 0x5c
li r5, 0
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
mr r3, r24
mr r4, r28
bl changeShape__Q24Game4PikiFi
mr r3, r24
mr r4, r27
bl changeHappa__Q24Game4PikiFi
lbl_801C2BA8:
addi r26, r26, 1
lbl_801C2BAC:
mr r3, r29
mr r4, r28
mr r5, r27
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0(r3)
cmpw r26, r0
blt lbl_801C2A3C
addi r27, r27, 1
cmpwi r27, 3
blt lbl_801C2A34
lbl_801C2BD4:
addi r28, r28, 1
cmpwi r28, 7
blt lbl_801C29E0
lwz r3, lbl_80520E68@sda21(r2)
addi r26, r1, 8
lwz r0, lbl_80520E6C@sda21(r2)
li r24, 0
stw r3, 8(r1)
lwz r3, cBedamaRed__13VsOtakaraName@sda21(r13)
stw r0, 0xc(r1)
lwz r0, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r3, 8(r1)
stw r0, 0xc(r1)
lbl_801C2C08:
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
subfic r4, r24, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
mr r0, r3
addi r3, r1, 0x40
mr r27, r0
bl __ct__Q24Game14PelletIteratorFv
addi r3, r1, 0x40
bl first__Q24Game14PelletIteratorFv
b lbl_801C2CAC
lbl_801C2C30:
addi r3, r1, 0x40
bl __ml__Q24Game14PelletIteratorFv
mr r0, r3
lwz r3, 0(r26)
mr r28, r0
lwz r4, 0x35c(r28)
lwz r4, 0x40(r4)
bl strcmp
cmpwi r3, 0
bne lbl_801C2CA4
mr r4, r27
addi r3, r1, 0x10
bl getFlagSetPos__Q24Game5OnyonFv
lfs f2, 0x10(r1)
mr r3, r28
lfs f1, 0x14(r1)
lfs f0, 0x18(r1)
stfs f2, 0x34(r1)
stfs f1, 0x38(r1)
stfs f0, 0x3c(r1)
bl getCylinderHeight__Q24Game6PelletFv
lfs f2, lbl_805194AC@sda21(r2)
mr r3, r28
lfs f0, 0x38(r1)
addi r4, r1, 0x34
li r5, 0
fmadds f0, f2, f1, f0
stfs f0, 0x38(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lbl_801C2CA4:
addi r3, r1, 0x40
bl next__Q24Game14PelletIteratorFv
lbl_801C2CAC:
addi r3, r1, 0x40
bl isDone__Q24Game14PelletIteratorFv
clrlwi. r0, r3, 0x18
beq lbl_801C2C30
addi r24, r24, 1
addi r26, r26, 4
cmpwi r24, 2
blt lbl_801C2C08
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lwz r5, 0x33c(r25)
li r4, 1
lwz r0, 0x68(r5)
stw r0, 0x25c(r3)
lwz r5, 0x33c(r25)
lwz r0, 0x64(r5)
stw r0, 0x260(r3)
lwz r3, naviMgr__4Game@sda21(r13)
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lwz r4, 0x33c(r25)
lwz r0, 0x68(r4)
stw r0, 0x25c(r3)
lwz r4, 0x33c(r25)
lwz r0, 0x64(r4)
stw r0, 0x260(r3)
psq_l f31, 424(r1), 0, qr0
lfd f31, 0x1a0(r1)
psq_l f30, 408(r1), 0, qr0
lfd f30, 0x190(r1)
psq_l f29, 392(r1), 0, qr0
lfd f29, 0x180(r1)
psq_l f28, 376(r1), 0, qr0
lfd f28, 0x170(r1)
psq_l f27, 360(r1), 0, qr0
lfd f27, 0x160(r1)
psq_l f26, 344(r1), 0, qr0
lfd f26, 0x150(r1)
psq_l f25, 328(r1), 0, qr0
lfd f25, 0x140(r1)
psq_l f24, 312(r1), 0, qr0
lfd f24, 0x130(r1)
psq_l f23, 296(r1), 0, qr0
lfd f23, 0x120(r1)
psq_l f22, 280(r1), 0, qr0
lfd f22, 0x110(r1)
psq_l f21, 264(r1), 0, qr0
lfd f21, 0x100(r1)
psq_l f20, 248(r1), 0, qr0
lfd f20, 0xf0(r1)
psq_l f19, 232(r1), 0, qr0
lfd f19, 0xe0(r1)
psq_l f18, 216(r1), 0, qr0
lfd f18, 0xd0(r1)
psq_l f17, 200(r1), 0, qr0
lfd f17, 0xc0(r1)
psq_l f16, 184(r1), 0, qr0
lfd f16, 0xb0(r1)
lmw r24, 0x90(r1)
lwz r0, 0x1b4(r1)
mtlr r0
addi r1, r1, 0x1b0
blr
*/
}
/*
* --INFO--
* Address: 801C2DC0
* Size: 000010
*/
void VsGameSection::addChallengeScore(int)
{
/*
lwz r0, 0x3bc(r3)
add r0, r0, r4
stw r0, 0x3bc(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C2DD0
* Size: 00006C
*/
void VsGameSection::sendMessage(Game::GameMessage&)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
mr r3, r31
lwz r12, 0(r31)
mr r4, r30
lwz r12, 8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C2E24
mr r3, r31
mr r4, r30
lwz r12, 0(r31)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lbl_801C2E24:
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2E3C
* Size: 000040
*/
void GameMessageVsGetDoping::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
mr r3, r4
stw r0, 0x14(r1)
lwz r4, 4(r5)
lwz r5, 8(r5)
bl getGetDopeCount__Q24Game13VsGameSectionFii
lwz r4, 0(r3)
addi r0, r4, 1
stw r0, 0(r3)
li r3, 1
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2E7C
* Size: 00004C
*/
void GameMessageVsBattleFinished::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2EB4
mr r3, r0
lwz r5, 4(r5)
lwz r12, 0(r3)
li r6, 0
lwz r12, 0x40(r12)
mtctr r12
bctrl
lbl_801C2EB4:
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2EC8
* Size: 000004
*/
void VsGame::State::onBattleFinished(Game::VsGameSection*, int, bool) { }
/*
* --INFO--
* Address: 801C2ECC
* Size: 00004C
*/
void GameMessageVsRedOrSuckStart::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
stw r0, 0x14(r1)
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2F04
mr r3, r0
lwz r5, 4(r6)
lwz r12, 0(r3)
lbz r6, 8(r6)
lwz r12, 0x44(r12)
mtctr r12
bctrl
lbl_801C2F04:
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2F18
* Size: 000004
*/
void VsGame::State::onRedOrBlueSuckStart(Game::VsGameSection*, int, bool) { }
/*
* --INFO--
* Address: 801C2F1C
* Size: 0000B8
*/
void GameMessageVsGetOtakara::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2FB8
lwz r0, 4(r30)
slwi r0, r0, 2
add r4, r31, r0
lwz r3, 0x3d4(r4)
addi r0, r3, 1
stw r0, 0x3d4(r4)
lwz r3, 4(r30)
slwi r0, r3, 2
cntlzw r4, r3
add r3, r31, r0
lwz r0, 0x3d4(r3)
srwi r3, r4, 5
subfic r0, r0, 3
cntlzw r0, r0
srwi r4, r0, 5
bl PSSetLastBeedamaDirection__Fbb
lwz r5, 4(r30)
slwi r0, r5, 2
add r3, r31, r0
lwz r0, 0x3d4(r3)
cmpwi r0, 4
blt lbl_801C2FB8
lwz r3, 0x180(r31)
mr r4, r31
li r6, 1
lwz r12, 0(r3)
lwz r12, 0x40(r12)
mtctr r12
bctrl
lbl_801C2FB8:
lwz r0, 0x14(r1)
li r3, 1
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2FD4
* Size: 000034
*/
void GameMessageVsAddEnemy::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r3, 0x32c(r4)
lwz r4, 4(r5)
lwz r5, 8(r5)
bl entry__Q34Game6VsGame7TekiMgrFQ34Game11EnemyTypeID12EEnemyTypeIDi
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 0000A4
*/
void GameMessageVsBirthTeki::actVs(Game::VsGameSection*)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C3008
* Size: 000118
*/
void GameMessagePelletBorn::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r5, 4(r3)
lbz r0, 0x32c(r5)
cmplwi r0, 6
bne lbl_801C310C
lwz r0, 0x388(r4)
cmplw r0, r5
bne lbl_801C3038
li r3, 0
b lbl_801C3110
lbl_801C3038:
lwz r0, 0x38c(r4)
cmplw r0, r5
bne lbl_801C304C
li r3, 0
b lbl_801C3110
lbl_801C304C:
addi r3, r4, 8
lwz r0, 0x390(r4)
cmplw r0, r5
bne lbl_801C3064
li r3, 0
b lbl_801C3110
lbl_801C3064:
lwz r0, 0x38c(r3)
cmplw r0, r5
bne lbl_801C3078
li r3, 0
b lbl_801C3110
lbl_801C3078:
lwz r0, 0x390(r3)
cmplw r0, r5
bne lbl_801C308C
li r3, 0
b lbl_801C3110
lbl_801C308C:
lwz r0, 0x394(r3)
cmplw r0, r5
bne lbl_801C30A0
li r3, 0
b lbl_801C3110
lbl_801C30A0:
lwz r0, 0x398(r3)
cmplw r0, r5
bne lbl_801C30B4
li r3, 0
b lbl_801C3110
lbl_801C30B4:
li r0, 7
mr r3, r4
li r6, 0
mtctr r0
lbl_801C30C4:
lwz r0, 0x388(r3)
cmplwi r0, 0
bne lbl_801C30E4
slwi r0, r6, 2
li r3, 1
add r4, r4, r0
stw r5, 0x388(r4)
b lbl_801C3110
lbl_801C30E4:
addi r3, r3, 4
addi r6, r6, 1
bdnz lbl_801C30C4
lis r3, lbl_8047FFF4@ha
lis r5, lbl_804800D0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x638
addi r5, r5, lbl_804800D0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C310C:
li r3, 0
lbl_801C3110:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C3120
* Size: 00008C
*/
void GameMessagePelletDead::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r5, 4(r3)
lbz r0, 0x32c(r5)
cmplwi r0, 6
bne lbl_801C3198
li r0, 7
mr r3, r4
li r6, 0
mtctr r0
lbl_801C314C:
lwz r0, 0x388(r3)
cmplw r0, r5
bne lbl_801C3170
slwi r0, r6, 2
li r5, 0
add r4, r4, r0
li r3, 1
stw r5, 0x388(r4)
b lbl_801C319C
lbl_801C3170:
addi r3, r3, 4
addi r6, r6, 1
bdnz lbl_801C314C
lis r3, lbl_8047FFF4@ha
lis r5, lbl_804800EC@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x651
addi r5, r5, lbl_804800EC@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3198:
li r3, 0
lbl_801C319C:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C31AC
* Size: 000228
*/
void GameMessageVsBirthTekiTreasure::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0xb0(r1)
mflr r0
stw r0, 0xb4(r1)
stfd f31, 0xa0(r1)
psq_st f31, 168(r1), 0, qr0
stmw r26, 0x88(r1)
mr r30, r3
mr r31, r4
lfs f1, 4(r3)
addi r3, r1, 0x18
lfs f0, lbl_80519520@sda21(r2)
addi r4, r1, 8
stfs f1, 8(r1)
li r29, 0
li r28, 0
li r27, 0
lfs f1, 8(r30)
stfs f1, 0xc(r1)
lfs f1, 0xc(r30)
stfs f1, 0x10(r1)
stfs f0, 0x14(r1)
bl __ct__Q24Game15CellIteratorArgFRQ23Sys6Sphere
addi r3, r1, 0x38
addi r4, r1, 0x18
bl __ct__Q24Game12CellIteratorFRQ24Game15CellIteratorArg
addi r3, r1, 0x38
bl first__Q24Game12CellIteratorFv
b lbl_801C3284
lbl_801C321C:
addi r3, r1, 0x38
bl __ml__Q24Game12CellIteratorFv
lwz r12, 0(r3)
mr r26, r3
lwz r12, 0x18(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C327C
mr r3, r26
lwz r12, 0(r26)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C327C
lbz r0, 0x2b8(r26)
cmpwi r0, 1
bne lbl_801C3270
addi r28, r28, 1
b lbl_801C327C
lbl_801C3270:
cmpwi r0, 0
bne lbl_801C327C
addi r27, r27, 1
lbl_801C327C:
addi r3, r1, 0x38
bl next__Q24Game12CellIteratorFv
lbl_801C3284:
addi r3, r1, 0x38
bl isDone__Q24Game12CellIteratorFv
clrlwi. r0, r3, 0x18
beq lbl_801C321C
cmpw r27, r28
ble lbl_801C32A0
li r29, 1
lbl_801C32A0:
subfic r0, r29, 1
slwi r3, r29, 2
slwi r0, r0, 2
lfs f0, lbl_80519528@sda21(r2)
add r4, r31, r3
lfs f31, lbl_80519524@sda21(r2)
add r3, r31, r0
lfs f2, 0x370(r4)
lfs f1, 0x370(r3)
fsubs f2, f2, f1
fcmpo cr0, f2, f0
ble lbl_801C32E4
lwz r3, 0x10(r30)
fmr f31, f0
addi r0, r3, 2
stw r0, 0x10(r30)
b lbl_801C334C
lbl_801C32E4:
lfs f0, lbl_805194AC@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3304
lwz r3, 0x10(r30)
fmr f31, f0
addi r0, r3, 1
stw r0, 0x10(r30)
b lbl_801C334C
lbl_801C3304:
lfs f1, lbl_8051952C@sda21(r2)
fcmpo cr0, f2, f1
ble lbl_801C3314
b lbl_801C334C
lbl_801C3314:
lfs f0, lbl_80519530@sda21(r2)
fcmpo cr0, f2, f0
bgt lbl_801C334C
lfs f0, lbl_80519534@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3334
fmr f31, f1
b lbl_801C334C
lbl_801C3334:
lfs f0, lbl_80519538@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3348
lfs f31, lbl_8051953C@sda21(r2)
b lbl_801C334C
lbl_801C3348:
lfs f31, lbl_80519540@sda21(r2)
lbl_801C334C:
bl rand
xoris r4, r3, 0x8000
lis r0, 0x4330
stw r4, 0x84(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r0, 0x80(r1)
lfs f0, lbl_805194F0@sda21(r2)
lfd f1, 0x80(r1)
fsubs f1, f1, f2
fdivs f0, f1, f0
fcmpo cr0, f0, f31
bgt lbl_801C33B8
lwz r3, 0x32c(r31)
li r27, 0
lwz r3, 0x24(r3)
addi r26, r3, -1
b lbl_801C33A8
lbl_801C3390:
lwz r3, 0x32c(r31)
mr r4, r26
lbz r6, 0x14(r30)
addi r5, r30, 4
bl "birth__Q34Game6VsGame7TekiMgrFiR10Vector3<f>b"
addi r27, r27, 1
lbl_801C33A8:
lwz r0, 0x10(r30)
cmpw r27, r0
blt lbl_801C3390
li r3, 1
lbl_801C33B8:
psq_l f31, 168(r1), 0, qr0
lfd f31, 0xa0(r1)
lmw r26, 0x88(r1)
lwz r0, 0xb4(r1)
mtlr r0
addi r1, r1, 0xb0
blr
*/
}
/*
* --INFO--
* Address: 801C33D4
* Size: 00001C
*/
void GameMessageVsPikminDead::actVs(Game::VsGameSection*)
{
/*
li r0, 0
li r3, 1
stb r0, 0x205(r4)
lwz r5, 0x208(r4)
addi r0, r5, 1
stw r0, 0x208(r4)
blr
*/
}
/*
* --INFO--
* Address: 801C33F0
* Size: 00007C
*/
void GameMessageVsGotCard::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r0, 4(r3)
lwz r4, 0x330(r4)
mulli r3, r0, 0x70
addi r3, r3, 0x18
add r3, r4, r3
lbz r0, 0x18(r3)
cmplwi r0, 0
bne lbl_801C3444
lwz r3, 0x58(r3)
addis r0, r3, 0
cmplwi r0, 0xffff
beq lbl_801C3444
mr r3, r31
bl useCard__Q24Game13VsGameSectionFv
lbl_801C3444:
lwz r3, 0x330(r31)
lwz r4, 4(r30)
bl gotPlayerCard__Q34Game6VsGame7CardMgrFi
lwz r0, 0x14(r1)
li r3, 1
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C346C
* Size: 0000A8
*/
void GameMessageVsUseCard::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r3, 0x180(r4)
cmplwi r3, 0
beq lbl_801C34B4
lwz r12, 0(r3)
lwz r12, 0x48(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C34B4
li r3, 0
b lbl_801C34FC
lbl_801C34B4:
lis r3, gGameConfig__4Game@ha
addi r3, r3, gGameConfig__4Game@l
lwz r0, 0x1b8(r3)
cmpwi r0, 0
bne lbl_801C34EC
lwz r3, 0x330(r31)
lwz r4, 4(r30)
lwz r5, 0x32c(r31)
bl usePlayerCard__Q34Game6VsGame7CardMgrFiPQ34Game6VsGame7TekiMgr
clrlwi. r0, r3, 0x18
beq lbl_801C34F8
mr r3, r31
bl useCard__Q24Game13VsGameSectionFv
b lbl_801C34F8
lbl_801C34EC:
lwz r3, 0x330(r31)
lwz r4, 4(r30)
bl stopSlot__Q34Game6VsGame7CardMgrFi
lbl_801C34F8:
li r3, 1
lbl_801C34FC:
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C3514
* Size: 000008
*/
u32 VsGame::State::isCardUsable(Game::VsGameSection*) { return 0x0; }
/*
* --INFO--
* Address: ........
* Size: 000170
*/
void VsGameSection::createCardPellet(void)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C351C
* Size: 000010
*/
void setComeAlive__Q24Game49FixedSizePelletMgr<Game::PelletOtakara::Object> Fi(void)
{
/*
.loc_0x0:
lwz r3, 0x9C(r3)
li r0, 0
stbx r0, r3, r4
blr
*/
}
/*
* --INFO--
* Address: 801C352C
* Size: 000190
*/
void VsGameSection::initCardPellets(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
stw r0, 0x64(r1)
li r0, 0xa
stmw r27, 0x4c(r1)
mr r30, r3
stw r0, 0x3cc(r3)
lis r3, lbl_8047FF98@ha
addi r31, r3, lbl_8047FF98@l
lwz r0, 0x3cc(r30)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x3d0(r30)
lis r3, __vt__Q24Game15CreatureInitArg@ha
addi r0, r3, __vt__Q24Game15CreatureInitArg@l
li r7, 0
lis r3, __vt__Q24Game13PelletInitArg@ha
stw r0, 0x18(r1)
li r0, -1
li r6, 0xff
addi r3, r3, __vt__Q24Game13PelletInitArg@l
li r5, 1
stw r3, 0x18(r1)
addi r4, r1, 8
lwz r3, cCoin__13VsOtakaraName@sda21(r13)
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C35DC
addi r3, r31, 0x5c
addi r5, r31, 0x70
li r4, 0x704
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C35DC:
lha r4, 0x258(r29)
li r0, 1
lwz r3, 8(r1)
li r27, 0
stw r4, 0x28(r1)
li r28, 0
lwz r4, 0x40(r29)
stw r4, 0x20(r1)
stb r3, 0x2e(r1)
stw r0, 0x38(r1)
stw r0, 0x3c(r1)
b lbl_801C366C
lbl_801C360C:
lwz r3, pelletMgr__4Game@sda21(r13)
addi r4, r1, 0x18
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
or. r29, r3, r3
beq lbl_801C3650
lfs f0, lbl_805194A8@sda21(r2)
addi r4, r1, 0xc
li r5, 0
stfs f0, 0xc(r1)
stfs f0, 0x10(r1)
stfs f0, 0x14(r1)
lwz r6, 0x3d0(r30)
stwx r29, r6, r28
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lwz r3, 0x3d0(r30)
stwx r29, r3, r28
b lbl_801C3664
lbl_801C3650:
addi r3, r31, 0x5c
addi r5, r31, 0x16c
li r4, 0x715
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3664:
addi r28, r28, 4
addi r27, r27, 1
lbl_801C366C:
lwz r0, 0x3cc(r30)
cmpw r27, r0
blt lbl_801C360C
li r27, 0
li r28, 0
b lbl_801C369C
lbl_801C3684:
lwz r3, 0x3d0(r30)
li r4, 0
lwzx r3, r3, r28
bl kill__Q24Game8CreatureFPQ24Game15CreatureKillArg
addi r28, r28, 4
addi r27, r27, 1
lbl_801C369C:
lwz r0, 0x3cc(r30)
cmpw r27, r0
blt lbl_801C3684
lmw r27, 0x4c(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C36BC
* Size: 000014
*/
void VsGameSection::initCardGeneration(void)
{
/*
li r0, 0
lfs f0, lbl_80519544@sda21(r2)
stw r0, 0x3c4(r3)
stfs f0, 0x3c8(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C36D0
* Size: 0002D8
*/
void VsGameSection::updateCardGeneration(void)
{
/*
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stfd f31, 0x40(r1)
psq_st f31, 72(r1), 0, qr0
stfd f30, 0x30(r1)
psq_st f30, 56(r1), 0, qr0
stmw r27, 0x1c(r1)
mr r29, r3
lfs f4, lbl_80519524@sda21(r2)
lfs f3, 0x378(r3)
li r31, 0
lfs f2, 0x37c(r3)
li r30, 5
lfs f1, 0x370(r3)
lfs f0, 0x374(r3)
fsubs f2, f3, f2
lfs f31, lbl_80519548@sda21(r2)
fsubs f0, f1, f0
lfs f30, lbl_8051954C@sda21(r2)
fsubs f6, f2, f0
fabs f0, f6
frsp f5, f0
fcmpo cr0, f5, f4
blt lbl_801C37D8
fcmpo cr0, f4, f5
cror 2, 0, 2
mfcr r0
lis r3, 0x4330
rlwinm r0, r0, 3, 0x1f, 0x1f
stw r3, 0x10(r1)
lfd f3, lbl_80519568@sda21(r2)
stw r0, 0x14(r1)
lfd f0, 0x10(r1)
fsubs f0, f0, f3
fcmpo cr0, f0, f31
bge lbl_801C3778
lfs f31, lbl_80519550@sda21(r2)
li r30, 5
lfs f30, lbl_805194AC@sda21(r2)
li r31, 1
b lbl_801C37D8
lbl_801C3778:
fcmpo cr0, f31, f5
fmr f2, f31
cror 2, 0, 2
mfcr r0
stw r3, 0x10(r1)
rlwinm r0, r0, 3, 0x1f, 0x1f
lfs f0, lbl_80519528@sda21(r2)
stw r0, 0x14(r1)
lfd f1, 0x10(r1)
fsubs f1, f1, f3
fcmpo cr0, f1, f0
bge lbl_801C37BC
fmr f31, f4
li r30, 6
fmr f30, f2
li r31, 1
b lbl_801C37D8
lbl_801C37BC:
fcmpo cr0, f0, f5
cror 2, 0, 2
bne lbl_801C37D8
fmr f31, f4
li r30, 7
fmr f30, f2
li r31, 1
lbl_801C37D8:
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f6, f0
bge lbl_801C37F4
fmr f1, f31
lfs f0, lbl_805194B8@sda21(r2)
fsubs f31, f0, f30
fsubs f30, f0, f1
lbl_801C37F4:
clrlwi. r0, r31, 0x18
bne lbl_801C3894
lfs f2, 0x364(r29)
lfs f0, 0x360(r29)
lfs f1, lbl_805194AC@sda21(r2)
fsubs f3, f2, f0
lfs f0, lbl_8051952C@sda21(r2)
fmuls f3, f3, f1
fabs f2, f3
frsp f2, f2
fcmpo cr0, f2, f0
cror 2, 0, 2
beq lbl_801C3894
lfs f0, lbl_80519524@sda21(r2)
fcmpo cr0, f2, f0
bge lbl_801C3840
lfs f31, lbl_80519548@sda21(r2)
lfs f30, lbl_80519554@sda21(r2)
b lbl_801C3878
lbl_801C3840:
fcmpo cr0, f2, f1
bge lbl_801C3854
fmr f30, f1
lfs f31, lbl_80519548@sda21(r2)
b lbl_801C3878
lbl_801C3854:
lfs f0, lbl_805194B8@sda21(r2)
fcmpo cr0, f2, f0
bge lbl_801C3878
lfs f0, lbl_80519558@sda21(r2)
fmr f30, f1
lfs f31, lbl_80519550@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3878
li r30, 5
lbl_801C3878:
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f3, f0
bge lbl_801C3894
fmr f1, f31
lfs f0, lbl_805194B8@sda21(r2)
fsubs f31, f0, f30
fsubs f30, f0, f1
lbl_801C3894:
li r28, 0
li r27, 0
stw r28, 0x3c4(r29)
b lbl_801C38D8
lbl_801C38A4:
lwz r3, 0x3d0(r29)
lwzx r3, r3, r28
lwz r12, 0(r3)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C38D0
lwz r3, 0x3c4(r29)
addi r0, r3, 1
stw r0, 0x3c4(r29)
lbl_801C38D0:
addi r28, r28, 4
addi r27, r27, 1
lbl_801C38D8:
lwz r0, 0x3cc(r29)
cmpw r27, r0
blt lbl_801C38A4
lwz r3, 0x3c4(r29)
cmpwi r3, 4
blt lbl_801C3900
clrlwi. r0, r31, 0x18
beq lbl_801C3984
cmpw r3, r30
bge lbl_801C3984
lbl_801C3900:
lwz r3, sys@sda21(r13)
clrlwi. r0, r31, 0x18
lfs f2, 0x54(r3)
beq lbl_801C3918
lfs f0, lbl_8051955C@sda21(r2)
fmuls f2, f2, f0
lbl_801C3918:
lfs f1, 0x3c8(r29)
lfs f0, lbl_805194A8@sda21(r2)
fsubs f1, f1, f2
stfs f1, 0x3c8(r29)
lfs f1, 0x3c8(r29)
fcmpo cr0, f1, f0
cror 2, 0, 2
bne lbl_801C3984
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x14(r1)
mr r3, r29
lfd f3, lbl_805194C8@sda21(r2)
addi r4, r1, 8
stw r0, 0x10(r1)
lfs f2, lbl_805194F0@sda21(r2)
lfd f0, 0x10(r1)
lfs f1, lbl_80519560@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_8051951C@sda21(r2)
fdivs f2, f3, f2
fmadds f0, f1, f2, f0
stfs f0, 0x3c8(r29)
stfs f31, 8(r1)
stfs f30, 0xc(r1)
bl dropCard__Q24Game13VsGameSectionFRQ34Game13VsGameSection11DropCardArg
lbl_801C3984:
psq_l f31, 72(r1), 0, qr0
lfd f31, 0x40(r1)
psq_l f30, 56(r1), 0, qr0
lfd f30, 0x30(r1)
lmw r27, 0x1c(r1)
lwz r0, 0x54(r1)
mtlr r0
addi r1, r1, 0x50
blr
*/
}
/*
* --INFO--
* Address: 801C39A8
* Size: 000018
*/
void VsGameSection::useCard(void)
{
/*
lwz r4, 0x3c4(r3)
cmpwi r4, 0
blelr
addi r0, r4, -1
stw r0, 0x3c4(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C39C0
* Size: 0003F4
*/
void VsGameSection::dropCard(Game::VsGameSection::DropCardArg&)
{
/*
stwu r1, -0xf0(r1)
mflr r0
stw r0, 0xf4(r1)
stfd f31, 0xe0(r1)
psq_st f31, 232(r1), 0, qr0
stw r31, 0xdc(r1)
stw r30, 0xd8(r1)
stw r29, 0xd4(r1)
stw r28, 0xd0(r1)
mr r5, r4
mr r30, r3
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
addi r4, r1, 0x28
lfs f1, 0(r5)
lfs f2, 4(r5)
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFR10Vector3<f>ff"
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xac(r1)
lfd f3, lbl_805194C8@sda21(r2)
stw r0, 0xa8(r1)
lfs f1, lbl_805194F0@sda21(r2)
lfd f2, 0xa8(r1)
lfs f0, lbl_80519520@sda21(r2)
fsubs f2, f2, f3
fdivs f1, f2, f1
fmuls f31, f0, f1
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xb4(r1)
lfd f3, lbl_805194C8@sda21(r2)
stw r0, 0xb0(r1)
lfs f2, lbl_805194F0@sda21(r2)
lfd f0, 0xb0(r1)
lfs f1, lbl_805194FC@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_805194A8@sda21(r2)
fdivs f2, f3, f2
fmuls f3, f1, f2
fmr f1, f3
fcmpo cr0, f3, f0
bge lbl_801C3A74
fneg f1, f3
lbl_801C3A74:
lfs f2, lbl_8051950C@sda21(r2)
lis r3, sincosTable___5JMath@ha
lfs f0, lbl_805194A8@sda21(r2)
addi r4, r3, sincosTable___5JMath@l
fmuls f1, f1, f2
lfs f4, 0x28(r1)
fcmpo cr0, f3, f0
fctiwz f0, f1
stfd f0, 0xb8(r1)
lwz r0, 0xbc(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r4, r0
lfs f0, 4(r3)
fmuls f5, f31, f0
bge lbl_801C3AD4
lfs f0, lbl_80519510@sda21(r2)
fmuls f0, f3, f0
fctiwz f0, f0
stfd f0, 0xc0(r1)
lwz r0, 0xc4(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r4, r0
fneg f0, f0
b lbl_801C3AEC
lbl_801C3AD4:
fmuls f0, f3, f2
fctiwz f0, f0
stfd f0, 0xc8(r1)
lwz r0, 0xcc(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r4, r0
lbl_801C3AEC:
fmuls f3, f31, f0
li r7, 0
lfs f0, 0x30(r1)
li r0, -1
lis r3, __vt__Q24Game15CreatureInitArg@ha
lfs f2, 0x2c(r1)
lfs f1, lbl_805194A8@sda21(r2)
fadds f3, f4, f3
fadds f0, f0, f5
addi r4, r3, __vt__Q24Game15CreatureInitArg@l
fadds f1, f2, f1
lis r3, __vt__Q24Game13PelletInitArg@ha
li r6, 0xff
li r5, 1
stw r4, 0x4c(r1)
addi r8, r3, __vt__Q24Game13PelletInitArg@l
lwz r3, cCoin__13VsOtakaraName@sda21(r13)
addi r4, r1, 8
stfs f3, 0x28(r1)
stfs f1, 0x2c(r1)
stfs f0, 0x30(r1)
stw r8, 0x4c(r1)
stb r7, 0x68(r1)
sth r7, 0x60(r1)
stb r6, 0x62(r1)
stw r7, 0x64(r1)
stb r7, 0x63(r1)
stb r5, 0x50(r1)
stb r7, 0x69(r1)
stw r0, 0x70(r1)
stw r0, 0x6c(r1)
stb r7, 0x6a(r1)
stb r7, 0x6b(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r31, r3, r3
bne lbl_801C3B98
lis r3, lbl_8047FFF4@ha
lis r5, lbl_80480008@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x6df
addi r5, r5, lbl_80480008@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3B98:
lha r4, 0x258(r31)
li r29, 0
lwz r3, 8(r1)
li r0, 1
stw r4, 0x5c(r1)
mr r28, r29
lwz r4, 0x40(r31)
stw r4, 0x54(r1)
stb r3, 0x62(r1)
stb r0, 0x68(r1)
stw r0, 0x6c(r1)
stw r0, 0x70(r1)
b lbl_801C3C30
lbl_801C3BCC:
lwz r3, 0x3d0(r30)
lwzx r31, r3, r28
mr r3, r31
lwz r12, 0(r31)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C3C28
mr r3, r31
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C3C28
lwz r3, mgr__Q24Game13PelletOtakara@sda21(r13)
lwz r4, 0x440(r31)
lwz r12, 0(r3)
lwz r12, 0x4c(r12)
mtctr r12
bctrl
mr r3, r31
addi r4, r1, 0x4c
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
b lbl_801C3C40
lbl_801C3C28:
addi r28, r28, 4
addi r29, r29, 1
lbl_801C3C30:
lwz r0, 0x3cc(r30)
cmpw r29, r0
blt lbl_801C3BCC
li r31, 0
lbl_801C3C40:
cmplwi r31, 0
beq lbl_801C3D54
lfs f1, 0x2c(r1)
mr r3, r31
lfs f0, lbl_80519570@sda21(r2)
addi r4, r1, 0x28
li r5, 0
fadds f0, f1, f0
stfs f0, 0x2c(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lwz r5, 0x28(r1)
lis r6, __vt__Q23efx5TBase@ha
lwz r0, 0x2c(r1)
lis r3, __vt__Q23efx3Arg@ha
lwz r4, 0x30(r1)
addi r8, r6, __vt__Q23efx5TBase@l
stw r5, 0x10(r1)
addi r6, r3, __vt__Q23efx3Arg@l
lfs f0, lbl_805194B8@sda21(r2)
lis r5, __vt__Q23efx13TEnemyApsmoke@ha
stw r0, 0x14(r1)
lis r3, __vt__Q23efx12ArgEnemyType@ha
lfs f3, 0x10(r1)
li r0, 1
stw r4, 0x18(r1)
addi r7, r5, __vt__Q23efx13TEnemyApsmoke@l
lfs f2, 0x14(r1)
addi r5, r3, __vt__Q23efx12ArgEnemyType@l
stw r8, 0xc(r1)
addi r3, r1, 0xc
lfs f1, 0x18(r1)
addi r4, r1, 0x34
stw r6, 0x34(r1)
stw r7, 0xc(r1)
stfs f3, 0x38(r1)
stfs f2, 0x3c(r1)
stfs f1, 0x40(r1)
stw r5, 0x34(r1)
stw r0, 0x44(r1)
stfs f0, 0x48(r1)
bl create__Q23efx13TEnemyApsmokeFPQ23efx3Arg
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xcc(r1)
lis r3, "zero__10Vector3<f>"@ha
lfs f1, lbl_805194A8@sda21(r2)
addi r4, r3, "zero__10Vector3<f>"@l
stw r0, 0xc8(r1)
addi r3, r1, 0x74
lfd f3, lbl_805194C8@sda21(r2)
addi r5, r1, 0x1c
lfd f0, 0xc8(r1)
lfs f2, lbl_805194F0@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_805194FC@sda21(r2)
stfs f1, 0x1c(r1)
fdivs f2, f3, f2
stfs f1, 0x24(r1)
fmuls f0, f0, f2
stfs f0, 0x20(r1)
bl "makeTR__7MatrixfFR10Vector3<f>R10Vector3<f>"
mr r3, r31
addi r4, r1, 0x74
bl setOrientation__Q24Game6PelletFR7Matrixf
lwz r3, 0x3c4(r30)
addi r0, r3, 1
stw r0, 0x3c4(r30)
b lbl_801C3D8C
lbl_801C3D54:
li r29, 0
li r28, 0
b lbl_801C3D80
lbl_801C3D60:
lwz r3, 0x3d0(r30)
lwzx r3, r3, r28
lwz r12, 0(r3)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
addi r28, r28, 4
addi r29, r29, 1
lbl_801C3D80:
lwz r0, 0x3cc(r30)
cmpw r29, r0
blt lbl_801C3D60
lbl_801C3D8C:
psq_l f31, 232(r1), 0, qr0
lwz r0, 0xf4(r1)
lfd f31, 0xe0(r1)
lwz r31, 0xdc(r1)
lwz r30, 0xd8(r1)
lwz r29, 0xd4(r1)
lwz r28, 0xd0(r1)
mtlr r0
addi r1, r1, 0xf0
blr
*/
}
/*
* --INFO--
* Address: 801C3DB4
* Size: 0001AC
*/
void VsGameSection::createYellowBedamas(int)
{
/*
stwu r1, -0x2b0(r1)
mflr r0
stw r0, 0x2b4(r1)
stmw r27, 0x29c(r1)
mr r30, r3
lis r3, lbl_8047FF98@ha
mr r31, r4
addi r28, r3, lbl_8047FF98@l
lwz r5, 0x33c(r30)
cmplwi r5, 0
beq lbl_801C3DF8
lwz r31, 0xb0(r5)
cmpwi r31, 0
beq lbl_801C3F4C
cmpwi r31, 7
blt lbl_801C3DF8
li r31, 7
lbl_801C3DF8:
lis r3, __vt__Q24Game15CreatureInitArg@ha
li r7, 0
addi r4, r3, __vt__Q24Game15CreatureInitArg@l
li r0, -1
lis r3, __vt__Q24Game13PelletInitArg@ha
stw r4, 0x18(r1)
addi r3, r3, __vt__Q24Game13PelletInitArg@l
li r6, 0xff
li r5, 1
stw r3, 0x18(r1)
lwz r3, cBedamaYellow__13VsOtakaraName@sda21(r13)
addi r4, r1, 8
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C3E74
addi r3, r28, 0x5c
addi r5, r28, 0x70
li r4, 0x86a
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3E74:
lha r0, 0x258(r29)
cmpwi r31, 0x32
lwz r4, 8(r1)
li r3, 1
stw r0, 0x28(r1)
li r0, 8
lwz r5, 0x40(r29)
stw r5, 0x20(r1)
stb r4, 0x2e(r1)
stw r3, 0x38(r1)
stw r0, 0x3c(r1)
ble lbl_801C3EBC
mr r6, r31
addi r3, r28, 0x5c
addi r5, r28, 0x17c
li r4, 0x873
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3EBC:
lis r4, "__ct__10Vector3<f>Fv"@ha
addi r3, r1, 0x40
addi r4, r4, "__ct__10Vector3<f>Fv"@l
li r5, 0
li r6, 0xc
li r7, 0x32
bl __construct_array
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
mr r5, r31
lfs f1, lbl_80519548@sda21(r2)
addi r4, r1, 0x40
lfs f2, lbl_8051954C@sda21(r2)
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFP10Vector3<f>iff"
mr r29, r30
addi r28, r1, 0x40
li r27, 0
b lbl_801C3F44
lbl_801C3F00:
lwz r3, pelletMgr__4Game@sda21(r13)
addi r4, r1, 0x18
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
lfs f2, 0(r28)
mr r30, r3
lfs f1, 4(r28)
addi r4, r1, 0xc
lfs f0, 8(r28)
li r5, 0
stfs f2, 0xc(r1)
stfs f1, 0x10(r1)
stfs f0, 0x14(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
stw r30, 0x388(r29)
addi r28, r28, 0xc
addi r29, r29, 4
addi r27, r27, 1
lbl_801C3F44:
cmpw r27, r31
blt lbl_801C3F00
lbl_801C3F4C:
lmw r27, 0x29c(r1)
lwz r0, 0x2b4(r1)
mtlr r0
addi r1, r1, 0x2b0
blr
*/
}
} // namespace Game
/*
* --INFO--
* Address: 801C3F60
* Size: 00014C
*/
void createRedBlueBedamas__Q24Game13VsGameSectionFR10Vector3f(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r5, __vt__Q24Game15CreatureInitArg@ha
stw r0, 0x64(r1)
stmw r26, 0x48(r1)
mr r28, r3
addi r29, r1, 0xc
addi r30, r5, __vt__Q24Game15CreatureInitArg@l
li r27, 0
lwz r4, lbl_80520E70@sda21(r2)
lwz r0, lbl_80520E74@sda21(r2)
stw r4, 0xc(r1)
lis r4, __vt__Q24Game13PelletInitArg@ha
lwz r6, cBedamaRed__13VsOtakaraName@sda21(r13)
addi r31, r4, __vt__Q24Game13PelletInitArg@l
stw r0, 0x10(r1)
lwz r0, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r6, 0xc(r1)
stw r0, 0x10(r1)
lbl_801C3FAC:
stw r30, 0x20(r1)
li r7, 0
li r0, -1
li r6, 0xff
li r5, 1
stw r31, 0x20(r1)
lwz r3, 0(r29)
addi r4, r1, 8
stb r7, 0x3c(r1)
sth r7, 0x34(r1)
stb r6, 0x36(r1)
stw r7, 0x38(r1)
stb r7, 0x37(r1)
stb r5, 0x24(r1)
stb r7, 0x3d(r1)
stw r0, 0x44(r1)
stw r0, 0x40(r1)
stb r7, 0x3e(r1)
stb r7, 0x3f(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r26, r3, r3
bne lbl_801C4020
lis r3, lbl_8047FFF4@ha
lis r5, lbl_80480008@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x8a3
addi r5, r5, lbl_80480008@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C4020:
lha r3, 0x258(r26)
li r5, 1
lwz r6, 8(r1)
li r0, 8
stw r3, 0x30(r1)
addi r4, r1, 0x20
lwz r3, pelletMgr__4Game@sda21(r13)
lwz r7, 0x40(r26)
stw r7, 0x28(r1)
stb r6, 0x36(r1)
stw r5, 0x40(r1)
stw r0, 0x44(r1)
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
mr r0, r3
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
lfs f1, lbl_80519524@sda21(r2)
mr r26, r0
lfs f2, lbl_80519528@sda21(r2)
addi r4, r1, 0x14
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFR10Vector3<f>ff"
mr r3, r26
addi r4, r1, 0x14
li r5, 0
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
addi r27, r27, 1
stw r26, 0x380(r28)
cmpwi r27, 2
addi r29, r29, 4
addi r28, r28, 4
blt lbl_801C3FAC
lmw r26, 0x48(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
namespace Game {
/*
* --INFO--
* Address: 801C40AC
* Size: 000814
*/
void VsGameSection::calcVsScores(void)
{
/*
stwu r1, -0x180(r1)
mflr r0
stw r0, 0x184(r1)
stfd f31, 0x170(r1)
psq_st f31, 376(r1), 0, qr0
stfd f30, 0x160(r1)
psq_st f30, 360(r1), 0, qr0
stfd f29, 0x150(r1)
psq_st f29, 344(r1), 0, qr0
stmw r22, 0x128(r1)
mr r29, r3
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
li r4, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
stw r3, 0x18(r1)
li r4, 0
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
bl getOnyon__Q34Game9ItemOnyon3MgrFi
addi r31, r1, 0xa8
addi r30, r1, 0x8c
stw r3, 0x1c(r1)
mr r28, r29
mr r27, r31
mr r26, r30
mr r25, r3
li r24, 0
lbl_801C4114:
lwz r23, 0x388(r28)
cmplwi r23, 0
beq lbl_801C4308
mr r3, r23
lwz r12, 0(r23)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C4308
mr r3, r23
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C4308
mr r3, r23
li r22, -1
lwz r12, 0(r23)
lwz r12, 0x204(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C4194
lwz r0, 0x3d4(r23)
cmpwi r0, 1
beq lbl_801C4188
bge lbl_801C4194
cmpwi r0, 0
bge lbl_801C4190
b lbl_801C4194
lbl_801C4188:
li r22, 0
b lbl_801C4194
lbl_801C4190:
li r22, 1
lbl_801C4194:
mr r4, r23
addi r3, r1, 0x80
lwz r12, 0(r23)
lwz r12, 8(r12)
mtctr r12
bctrl
lwz r4, 0x18(r1)
addi r3, r1, 0x74
lfs f30, 0x80(r1)
lwz r12, 0(r4)
lfs f29, 0x88(r1)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x7c(r1)
lfs f1, 0x74(r1)
fsubs f3, f29, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f30, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4200
ble lbl_801C4204
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4204
lbl_801C4200:
fmr f31, f0
lbl_801C4204:
mr r4, r25
addi r3, r1, 0x68
lwz r12, 0(r25)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x70(r1)
lfs f1, 0x68(r1)
fsubs f3, f29, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f30, f1
fmuls f1, f3, f3
fmadds f3, f2, f2, f1
fcmpo cr0, f3, f0
ble lbl_801C4250
ble lbl_801C4254
frsqrte f0, f3
fmuls f3, f0, f3
b lbl_801C4254
lbl_801C4250:
fmr f3, f0
lbl_801C4254:
fadds f1, f31, f3
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f3, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
lwz r0, 0xb8(r23)
li r3, 0
fadds f0, f1, f0
cmplwi r0, 0
fdivs f3, f1, f0
beq lbl_801C4294
li r3, 1
lbl_801C4294:
clrlwi. r0, r3, 0x18
bne lbl_801C42E8
cmpwi r22, -1
bne lbl_801C42B8
lfs f0, lbl_805194B8@sda21(r2)
stfs f3, 0(r27)
fsubs f0, f0, f3
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42B8:
cmpwi r22, 0
bne lbl_801C42D0
lfs f0, lbl_805194A8@sda21(r2)
stfs f3, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42D0:
lfs f0, lbl_805194B8@sda21(r2)
lfs f1, lbl_805194A8@sda21(r2)
fsubs f0, f0, f3
stfs f1, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42E8:
lfs f0, lbl_805194B8@sda21(r2)
lfs f2, lbl_8051952C@sda21(r2)
fsubs f0, f0, f3
fmuls f1, f2, f3
fmuls f0, f2, f0
stfs f1, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C4308:
lfs f0, lbl_80519578@sda21(r2)
stfs f0, 0(r27)
stfs f0, 0(r26)
lbl_801C4314:
addi r24, r24, 1
addi r27, r27, 4
cmpwi r24, 7
addi r26, r26, 4
addi r28, r28, 4
blt lbl_801C4114
lfs f3, lbl_805194A8@sda21(r2)
mr r7, r29
lfd f4, lbl_805194C8@sda21(r2)
addi r8, r1, 0x10
lfs f2, lbl_8051957C@sda21(r2)
li r9, 0
lfs f1, lbl_80519580@sda21(r2)
lis r3, 0x4330
lbl_801C434C:
lwz r4, 0x3dc(r7)
li r0, 7
stw r3, 0x118(r1)
mr r5, r31
xoris r4, r4, 0x8000
mr r6, r30
stw r4, 0x11c(r1)
lfd f0, 0x118(r1)
fsubs f5, f0, f4
mtctr r0
lbl_801C4374:
cmpwi r9, 0
bne lbl_801C4390
lfs f0, 0(r5)
fcmpo cr0, f0, f3
cror 2, 1, 2
bne lbl_801C4390
fadds f5, f5, f0
lbl_801C4390:
cmpwi r9, 1
bne lbl_801C43AC
lfs f0, 0(r6)
fcmpo cr0, f0, f3
cror 2, 1, 2
bne lbl_801C43AC
fadds f5, f5, f0
lbl_801C43AC:
addi r5, r5, 4
addi r6, r6, 4
bdnz lbl_801C4374
fcmpo cr0, f5, f2
cror 2, 1, 2
bne lbl_801C43C8
fmr f5, f2
lbl_801C43C8:
fmuls f5, f5, f1
addi r9, r9, 1
cmpwi r9, 2
stfs f5, 0(r8)
lfs f0, 0(r8)
addi r8, r8, 4
stfs f0, 0x370(r7)
addi r7, r7, 4
blt lbl_801C434C
lwz r3, lbl_80520E78@sda21(r2)
mr r25, r29
lwz r0, lbl_80520E7C@sda21(r2)
addi r26, r1, 0x18
stw r3, 8(r1)
addi r27, r1, 8
li r22, 0
stw r0, 0xc(r1)
lbl_801C440C:
lwz r4, 0x380(r25)
lwz r23, 0(r26)
cmplwi r4, 0
beq lbl_801C451C
lwz r12, 0(r4)
addi r3, r1, 0x5c
lwz r12, 8(r12)
mtctr r12
bctrl
mr r4, r23
addi r3, r1, 0x50
lwz r12, 0(r23)
lfs f29, 0x5c(r1)
lwz r12, 8(r12)
lfs f30, 0x64(r1)
mtctr r12
bctrl
lfs f0, 0x58(r1)
lfs f1, 0x50(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4484
ble lbl_801C4488
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4488
lbl_801C4484:
fmr f31, f0
lbl_801C4488:
subfic r0, r22, 1
addi r4, r1, 0x18
slwi r0, r0, 2
addi r3, r1, 0x44
lwzx r4, r4, r0
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x4c(r1)
lfs f1, 0x44(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f1, f2, f2, f1
fcmpo cr0, f1, f0
ble lbl_801C44E0
ble lbl_801C44E4
frsqrte f0, f1
fmuls f1, f0, f1
b lbl_801C44E4
lbl_801C44E0:
fmr f1, f0
lbl_801C44E4:
fadds f1, f31, f1
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f31, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
fadds f0, f1, f0
fdivs f0, f1, f0
stfs f0, 0(r27)
lfs f0, 0(r27)
stfs f0, 0x378(r25)
lbl_801C451C:
addi r22, r22, 1
addi r26, r26, 4
cmpwi r22, 2
addi r27, r27, 4
addi r25, r25, 4
blt lbl_801C440C
lfs f3, 0x10(r1)
addi r28, r1, 0xec
lfs f0, 0x14(r1)
addi r30, r1, 0xc4
lfs f2, 8(r1)
mr r26, r28
fsubs f1, f3, f0
lfs f4, 0xc(r1)
fsubs f0, f0, f3
mr r27, r30
li r22, 0
li r25, 0
fsubs f1, f1, f2
fsubs f0, f0, f4
fadds f1, f4, f1
fadds f0, f2, f0
stfs f1, 0x358(r29)
stfs f0, 0x35c(r29)
lbl_801C457C:
lwz r3, 0x3d0(r29)
lwzx r23, r3, r25
mr r3, r23
lwz r12, 0(r23)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C476C
mr r3, r23
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C476C
mr r3, r23
li r24, -1
lwz r12, 0(r23)
lwz r12, 0x204(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C45F8
lwz r0, 0x3d4(r23)
cmpwi r0, 1
beq lbl_801C45EC
bge lbl_801C45F8
cmpwi r0, 0
bge lbl_801C45F4
b lbl_801C45F8
lbl_801C45EC:
li r24, 0
b lbl_801C45F8
lbl_801C45F4:
li r24, 1
lbl_801C45F8:
mr r4, r23
addi r3, r1, 0x38
lwz r12, 0(r23)
lwz r12, 8(r12)
mtctr r12
bctrl
lwz r4, 0x18(r1)
addi r3, r1, 0x2c
lfs f29, 0x38(r1)
lwz r12, 0(r4)
lfs f30, 0x40(r1)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x34(r1)
lfs f1, 0x2c(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4664
ble lbl_801C4668
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4668
lbl_801C4664:
fmr f31, f0
lbl_801C4668:
lwz r4, 0x1c(r1)
addi r3, r1, 0x20
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x28(r1)
lfs f1, 0x20(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f3, f2, f2, f1
fcmpo cr0, f3, f0
ble lbl_801C46B4
ble lbl_801C46B8
frsqrte f0, f3
fmuls f3, f0, f3
b lbl_801C46B8
lbl_801C46B4:
fmr f3, f0
lbl_801C46B8:
fadds f1, f31, f3
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f3, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
lwz r0, 0xb8(r23)
li r3, 0
fadds f0, f1, f0
cmplwi r0, 0
fdivs f3, f1, f0
beq lbl_801C46F8
li r3, 1
lbl_801C46F8:
clrlwi. r0, r3, 0x18
bne lbl_801C474C
cmpwi r24, -1
bne lbl_801C471C
lfs f0, lbl_805194B8@sda21(r2)
stfs f3, 0(r26)
fsubs f0, f0, f3
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C471C:
cmpwi r24, 0
bne lbl_801C4734
lfs f0, lbl_805194A8@sda21(r2)
stfs f3, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C4734:
lfs f0, lbl_805194B8@sda21(r2)
lfs f1, lbl_805194A8@sda21(r2)
fsubs f0, f0, f3
stfs f1, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C474C:
lfs f0, lbl_805194B8@sda21(r2)
lfs f2, lbl_8051952C@sda21(r2)
fsubs f0, f0, f3
fmuls f1, f2, f3
fmuls f0, f2, f0
stfs f1, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C476C:
lfs f0, lbl_80519578@sda21(r2)
stfs f0, 0(r26)
stfs f0, 0(r27)
lbl_801C4778:
addi r22, r22, 1
addi r26, r26, 4
cmpwi r22, 0xa
addi r27, r27, 4
addi r25, r25, 4
blt lbl_801C457C
lfs f1, lbl_805194A8@sda21(r2)
mr r5, r29
li r6, 0
lbl_801C479C:
fmr f3, f1
li r0, 5
mr r3, r28
mr r4, r30
stfs f1, 0x368(r5)
li r7, 0
mtctr r0
lbl_801C47B8:
cmpwi r6, 0
lfs f4, lbl_805194A8@sda21(r2)
bne lbl_801C47DC
lfs f0, 0(r3)
fcmpo cr0, f0, f4
cror 2, 1, 2
bne lbl_801C47DC
fadds f3, f3, f0
fmr f4, f0
lbl_801C47DC:
cmpwi r6, 1
bne lbl_801C4800
lfs f2, 0(r4)
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f2, f0
cror 2, 1, 2
bne lbl_801C4800
fadds f3, f3, f2
fmr f4, f2
lbl_801C4800:
lfs f0, 0x368(r5)
fcmpo cr0, f0, f4
cror 2, 0, 2
bne lbl_801C4814
stfs f4, 0x368(r5)
lbl_801C4814:
cmpwi r6, 0
lfs f4, lbl_805194A8@sda21(r2)
bne lbl_801C4838
lfs f0, 4(r3)
fcmpo cr0, f0, f4
cror 2, 1, 2
bne lbl_801C4838
fadds f3, f3, f0
fmr f4, f0
lbl_801C4838:
cmpwi r6, 1
bne lbl_801C485C
lfs f2, 4(r4)
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f2, f0
cror 2, 1, 2
bne lbl_801C485C
fadds f3, f3, f2
fmr f4, f2
lbl_801C485C:
lfs f0, 0x368(r5)
fcmpo cr0, f0, f4
cror 2, 0, 2
bne lbl_801C4870
stfs f4, 0x368(r5)
lbl_801C4870:
addi r3, r3, 8
addi r4, r4, 8
addi r7, r7, 1
bdnz lbl_801C47B8
addi r6, r6, 1
stfs f3, 0x360(r5)
cmpwi r6, 2
addi r5, r5, 4
blt lbl_801C479C
psq_l f31, 376(r1), 0, qr0
lfd f31, 0x170(r1)
psq_l f30, 360(r1), 0, qr0
lfd f30, 0x160(r1)
psq_l f29, 344(r1), 0, qr0
lfd f29, 0x150(r1)
lmw r22, 0x128(r1)
lwz r0, 0x184(r1)
mtlr r0
addi r1, r1, 0x180
blr
*/
}
/*
* --INFO--
* Address: 801C48C0
* Size: 000018
*/
void VsGameSection::clearGetDopeCount(void)
{
/*
li r0, 0
stw r0, 0x3b0(r3)
stw r0, 0x3ac(r3)
stw r0, 0x3a8(r3)
stw r0, 0x3a4(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C48D8
* Size: 0000D0
*/
void VsGameSection::getGetDopeCount(int, int)
{
/*
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
li r0, 0
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
mr r30, r5
stw r29, 0x14(r1)
or. r29, r4, r4
lis r4, lbl_8047FF98@ha
stw r28, 0x10(r1)
mr r28, r3
addi r31, r4, lbl_8047FF98@l
blt lbl_801C491C
cmpwi r29, 1
bgt lbl_801C491C
li r0, 1
lbl_801C491C:
clrlwi. r0, r0, 0x18
bne lbl_801C493C
mr r6, r29
addi r3, r31, 0x5c
addi r5, r31, 0x188
li r4, 0xa07
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C493C:
cmpwi r30, 0
li r0, 0
blt lbl_801C4954
cmpwi r30, 1
bgt lbl_801C4954
li r0, 1
lbl_801C4954:
clrlwi. r0, r0, 0x18
bne lbl_801C4974
mr r6, r30
addi r3, r31, 0x5c
addi r5, r31, 0x198
li r4, 0xa08
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C4974:
slwi r3, r29, 3
slwi r0, r30, 2
add r3, r3, r0
addi r3, r3, 0x3a4
add r3, r28, r3
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C49A8
* Size: 000010
*/
void VsGameSection::clearGetCherryCount(void)
{
/*
li r0, 0
stw r0, 0x3b8(r3)
stw r0, 0x3b4(r3)
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 00007C
*/
u32 VsGameSection::getGetCherryCount(int playerIndex)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C49B8
* Size: 000008
*/
bool VsGameSection::challengeDisablePelplant(void) { return false; }
/*
* --INFO--
* Address: 801C49C0
* Size: 000008
*/
bool VsGameSection::player2enabled(void) { return true; }
/*
* --INFO--
* Address: 801C49C8
* Size: 000008
*/
char* VsGameSection::getCaveFilename(void)
{
/*
addi r3, r3, 0x224
blr
*/
}
/*
* --INFO--
* Address: 801C49D0
* Size: 000008
*/
void VsGameSection::getEditorFilename(void)
{
/*
addi r3, r3, 0x2a4
blr
*/
}
/*
* --INFO--
* Address: 801C49D8
* Size: 000008
*/
void VsGameSection::getVsEditNumber(void)
{
/*
lwz r3, 0x328(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C49E0
* Size: 000004
*/
void init__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
} // namespace Game
/*
* --INFO--
* Address: 801C49E4
* Size: 000064
*/
void create__Q24Game36StateMachine<Game::VsGameSection> Fi(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
li r0, 0
stw r31, 0xc(r1)
mr r31, r3
stw r4, 0xc(r3)
stw r0, 8(r3)
lwz r0, 0xc(r3)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 4(r31)
lwz r0, 0xc(r31)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x10(r31)
lwz r0, 0xc(r31)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x14(r31)
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C4A48
* Size: 00009C
*/
void transit__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSectioniPQ24Game8StateArg(void)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
rlwinm r0,r5,2,0,29
stmw r27, 0xC(r1)
mr r27, r3
mr r28, r4
mr r29, r6
lwz r30, 0x180(r4)
lwz r3, 0x14(r3)
cmplwi r30, 0
lwzx r31, r3, r0
beq- .loc_0x50
mr r3, r30
lwz r12, 0x0(r30)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lwz r0, 0x4(r30)
stw r0, 0x18(r27)
.loc_0x50:
lwz r0, 0xC(r27)
cmpw r31, r0
blt- .loc_0x60
.loc_0x5C:
b .loc_0x5C
.loc_0x60:
lwz r3, 0x4(r27)
rlwinm r0,r31,2,0,29
mr r4, r28
mr r5, r29
lwzx r3, r3, r0
stw r3, 0x180(r28)
lwz r12, 0x0(r3)
lwz r12, 0x8(r12)
mtctr r12
bctrl
lmw r27, 0xC(r1)
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C4AE4
* Size: 000004
*/
void init__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSectionPQ24Game8StateArg(void) { }
/*
* --INFO--
* Address: 801C4AE8
* Size: 000004
*/
void cleanup__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
/*
* --INFO--
* Address: 801C4AEC
* Size: 000084
*/
void registerState__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game32FSMState<Game::VsGameSection>(void)
{
/*
.loc_0x0:
lwz r6, 0x8(r3)
lwz r0, 0xC(r3)
cmpw r6, r0
bgelr-
lwz r5, 0x4(r3)
rlwinm r0,r6,2,0,29
stwx r4, r5, r0
lwz r5, 0x4(r4)
cmpwi r5, 0
blt- .loc_0x34
lwz r0, 0xC(r3)
cmpw r5, r0
blt- .loc_0x3C
.loc_0x34:
li r0, 0
b .loc_0x40
.loc_0x3C:
li r0, 0x1
.loc_0x40:
rlwinm. r0,r0,0,24,31
beqlr-
stw r3, 0x8(r4)
lwz r0, 0x8(r3)
lwz r6, 0x4(r4)
lwz r5, 0x10(r3)
rlwinm r0,r0,2,0,29
stwx r6, r5, r0
lwz r0, 0x4(r4)
lwz r5, 0x8(r3)
lwz r4, 0x14(r3)
rlwinm r0,r0,2,0,29
stwx r5, r4, r0
lwz r4, 0x8(r3)
addi r0, r4, 0x1
stw r0, 0x8(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C4B70
* Size: 000038
*/
void exec__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSection(void)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r3, 0x180(r4)
cmplwi r3, 0
beq- .loc_0x28
lwz r12, 0x0(r3)
lwz r12, 0xC(r12)
mtctr r12
bctrl
.loc_0x28:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C4BA8
* Size: 000004
*/
void exec__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
/*
* --INFO--
* Address: 801C4BAC
* Size: 000028
*/
void __sinit_vsGameSection_cpp(void)
{
/*
lis r4, __float_nan@ha
li r0, -1
lfs f0, __float_nan@l(r4)
lis r3, lbl_804B60E8@ha
stw r0, lbl_80515A88@sda21(r13)
stfsu f0, lbl_804B60E8@l(r3)
stfs f0, lbl_80515A8C@sda21(r13)
stfs f0, 4(r3)
stfs f0, 8(r3)
blr
*/
}
| 21.726418
| 109
| 0.596313
|
projectPiki
|
de6d3617beacfb1559a28d796d311db01954a766
| 687
|
cpp
|
C++
|
CastleDoctrine/gameSource/sharedServerSecret.cpp
|
PhilipLudington/CastleDoctrine
|
443f2b6b0215a6d71515c8887c99b4322965622e
|
[
"Unlicense"
] | 1
|
2020-01-16T00:07:11.000Z
|
2020-01-16T00:07:11.000Z
|
CastleDoctrine/gameSource/sharedServerSecret.cpp
|
PhilipLudington/CastleDoctrine
|
443f2b6b0215a6d71515c8887c99b4322965622e
|
[
"Unlicense"
] | null | null | null |
CastleDoctrine/gameSource/sharedServerSecret.cpp
|
PhilipLudington/CastleDoctrine
|
443f2b6b0215a6d71515c8887c99b4322965622e
|
[
"Unlicense"
] | 2
|
2019-09-17T12:08:20.000Z
|
2020-09-26T00:54:48.000Z
|
// you can replace this string before building the client in order to
// match the shared secret that the server is expecting.
// Please don't abuse your power to do this.
// Remember that this is an indie game made entirely by one guy and being
// run on a shoestring budget server. Making a truly "secure" game, where
// every move happens on the server, would exceed the resources that I had
// available.
// If any mod that you're building might give you a questionable advantage,
// please don't connect to the main server with that mod.
const char *sharedServerSecret = "This is an example secret. You probably cannot connect to the main server without replacing this.";
| 36.157895
| 134
| 0.755459
|
PhilipLudington
|
de70f85d4eeb1240a8026a6a5965668e45e018c7
| 4,633
|
cpp
|
C++
|
Samples/Simple.cpp
|
QtExcel/QSimpleXlsxWriter
|
da96975bfd089fcb779fd871c9075e097a8373c0
|
[
"MIT"
] | 13
|
2019-02-15T06:16:30.000Z
|
2022-02-17T04:58:49.000Z
|
Samples/Simple.cpp
|
umaysahan/QSimpleXlsxWriter
|
da96975bfd089fcb779fd871c9075e097a8373c0
|
[
"MIT"
] | 1
|
2019-01-13T07:12:26.000Z
|
2019-01-13T09:58:27.000Z
|
Samples/Simple.cpp
|
umaysahan/QSimpleXlsxWriter
|
da96975bfd089fcb779fd871c9075e097a8373c0
|
[
"MIT"
] | 6
|
2019-07-19T01:45:48.000Z
|
2021-03-17T09:57:59.000Z
|
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <vector>
#include <Xlsx/Workbook.h>
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef QT_CORE_LIB
#include <QDateTime>
#endif
using namespace SimpleXlsx;
int main()
{
setlocale( LC_ALL, "" );
time_t CurTime = time( NULL );
CWorkbook book( "Incognito" );
std::vector<ColumnWidth> ColWidth;
ColWidth.push_back( ColumnWidth( 0, 3, 25 ) );
CWorksheet & Sheet = book.AddSheet( "Unicode", ColWidth );
Style style;
style.horizAlign = ALIGN_H_CENTER;
style.font.attributes = FONT_BOLD;
const size_t CenterStyleIndex = book.AddStyle( style );
Sheet.BeginRow();
Sheet.AddCell( "Common test of Unicode support", CenterStyleIndex );
Sheet.MergeCells( CellCoord( 1, 0 ), CellCoord( 1, 3 ) );
Sheet.EndRow();
Font TmpFont = book.GetFonts().front();
TmpFont.attributes = FONT_ITALIC;
Comment Com;
Com.x = 300;
Com.y = 100;
Com.width = 100;
Com.height = 30;
Com.cellRef = CellCoord( 8, 1 );
Com.isHidden = false;
Com.AddContent( TmpFont, "Comment with custom style" );
Sheet.AddComment( Com );
Sheet.BeginRow().AddCell( "English language" ).AddCell( "English language" ).EndRow();
Sheet.BeginRow().AddCell( "Russian language" ).AddCell( L"Русский язык" ).EndRow();
Sheet.BeginRow().AddCell( "Chinese language" ).AddCell( L"中文" ).EndRow();
Sheet.BeginRow().AddCell( "French language" ).AddCell( L"le français" ).EndRow();
Sheet.BeginRow().AddCell( "Arabic language" ).AddCell( L"العَرَبِيَّة" ).EndRow();
Sheet.AddEmptyRow();
style.fill.patternType = PATTERN_NONE;
style.font.theme = true;
style.horizAlign = ALIGN_H_RIGHT;
style.vertAlign = ALIGN_V_CENTER;
style.numFormat.numberStyle = NUMSTYLE_MONEY;
const size_t MoneyStyleIndex = book.AddStyle( style );
Sheet.BeginRow().AddCell( "Money symbol" ).AddCell( 123.45, MoneyStyleIndex ).EndRow();
Style stPanel;
stPanel.border.top.style = BORDER_THIN;
stPanel.border.bottom.color = "FF000000";
stPanel.fill.patternType = PATTERN_SOLID;
stPanel.fill.fgColor = "FFCCCCFF";
const size_t PanelStyleIndex = book.AddStyle( stPanel );
Sheet.AddEmptyRow().BeginRow();
Sheet.AddCell( "Cells with border", PanelStyleIndex );
Sheet.AddCell( "", PanelStyleIndex ).AddCell( "", PanelStyleIndex ).AddCell( "", PanelStyleIndex );
Sheet.EndRow();
style.numFormat.numberStyle = NUMSTYLE_DATETIME;
style.font.attributes = FONT_NORMAL;
style.horizAlign = ALIGN_H_LEFT;
const size_t DateTimeStyleIndex = book.AddStyle( style );
Sheet.AddEmptyRow().AddSimpleRow( "time_t", CenterStyleIndex );
Sheet.AddSimpleRow( CellDataTime( CurTime, DateTimeStyleIndex ) );
Style stRotated;
stRotated.horizAlign = EAlignHoriz::ALIGN_H_CENTER;
stRotated.vertAlign = EAlignVert::ALIGN_V_CENTER;
stRotated.textRotation = 45;
const size_t RotatedStyleIndex = book.AddStyle( stRotated );
Sheet.AddSimpleRow( "Rotated text", RotatedStyleIndex, 3, 20 );
Sheet.MergeCells( CellCoord( 14, 3 ), CellCoord( 19, 3 ) );
/* Be careful with the style of date and time.
* If milliseconds are specified, then the style used should take them into account.
* Otherwise, Excel will round milliseconds and may change seconds.
* See example below. */
style.numFormat.formatString = "yyyy.mm.dd hh:mm:ss.000";
const size_t CustomDateTimeStyleIndex = book.AddStyle( style );
Sheet.AddSimpleRow( "Direct date and time", CenterStyleIndex );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 500, CustomDateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 500, DateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 499, CustomDateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 499, DateTimeStyleIndex ) );
#ifdef _WIN32
Sheet.AddEmptyRow().AddSimpleRow( "Windows SYSTEMTIME", CenterStyleIndex );
SYSTEMTIME lt;
GetLocalTime( & lt );
Sheet.AddSimpleRow( CellDataTime( lt, CustomDateTimeStyleIndex ) );
#endif
#if defined( QT_VERSION ) && ( QT_VERSION >= 0x040000 )
Sheet.AddEmptyRow().AddSimpleRow( "Qt QDateTime", CenterStyleIndex );
const QDateTime CurDT = QDateTime::currentDateTime();
Sheet.AddSimpleRow( CellDataTime( CurDT, CustomDateTimeStyleIndex ) );
#endif
if( book.Save( "Simple.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
else std::cout << "The book saving has been failed" << std::endl;
return 0;
}
| 37.666667
| 103
| 0.690481
|
QtExcel
|
de73b5485234ba8ed43297cd580bd6f40f60d4bd
| 572
|
cc
|
C++
|
atcoder/arc/007/b_maigo_no_cd_case.cc
|
boobam0618/competitive-programming
|
0341bd8bb240b1ed0d84cc60db91508242fc867b
|
[
"MIT"
] | null | null | null |
atcoder/arc/007/b_maigo_no_cd_case.cc
|
boobam0618/competitive-programming
|
0341bd8bb240b1ed0d84cc60db91508242fc867b
|
[
"MIT"
] | 32
|
2019-08-15T09:16:48.000Z
|
2020-02-09T16:23:30.000Z
|
atcoder/arc/007/b_maigo_no_cd_case.cc
|
boobam0618/competitive-programming
|
0341bd8bb240b1ed0d84cc60db91508242fc867b
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
int main() {
int cd_case_num, listen_cd_num;
std::cin >> cd_case_num >> listen_cd_num;
std::vector<int> cds(cd_case_num);
for (int i = 0; i < cd_case_num; ++i) {
cds.at(i) = i + 1;
}
int current = 0;
for (int i = 0; i < listen_cd_num; ++i) {
int listen_cd;
std::cin >> listen_cd;
for (int j = 0; j < cd_case_num; ++j) {
if (cds.at(j) == listen_cd) {
std::swap(current, cds.at(j));
}
}
}
for (int i = 0; i < cd_case_num; ++i) {
std::cout << cds.at(i) << std::endl;
}
}
| 22
| 43
| 0.536713
|
boobam0618
|
de742378fbcc59e333009e743335a1b22585d443
| 2,594
|
cpp
|
C++
|
outdated/tests/io_copy.cpp
|
pjsaksa/x0
|
96b69e5a54b006e3d929b9934c2708f7967371bb
|
[
"MIT"
] | 24
|
2016-07-10T08:05:11.000Z
|
2021-11-16T10:53:48.000Z
|
outdated/tests/io_copy.cpp
|
pjsaksa/x0
|
96b69e5a54b006e3d929b9934c2708f7967371bb
|
[
"MIT"
] | 14
|
2015-04-12T10:45:26.000Z
|
2016-06-28T22:27:50.000Z
|
outdated/tests/io_copy.cpp
|
pjsaksa/x0
|
96b69e5a54b006e3d929b9934c2708f7967371bb
|
[
"MIT"
] | 4
|
2016-10-05T17:51:38.000Z
|
2020-04-20T07:45:23.000Z
|
// This file is part of the "x0" project, http://xzero.io/
// (c) 2009-2018 Christian Parpart <christian@parpart.family>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT
#include <x0/io/source.hpp>
#include <x0/io/fd_source.hpp>
#include <x0/io/file_source.hpp>
#include <x0/io/sink.hpp>
#include <x0/io/file_sink.hpp>
#include <x0/io/filter.hpp>
#include <x0/io/null_filter.hpp>
#include <x0/io/uppercase_filter.hpp>
#include <x0/io/CompressFilter.h>
#include <x0/io/chain_filter.hpp>
#include <x0/io/pump.hpp>
#include <iostream>
#include <memory>
#include <getopt.h>
inline x0::file_ptr getfile(const std::string ifname) {
return x0::file_ptr(new x0::File(x0::FileInfoPtr(new x0::FileInfo(ifname))));
}
int main(int argc, char *argv[]) {
struct option options[] = {{"input", required_argument, 0, 'i'},
{"output", required_argument, 0, 'o'},
{"gzip", no_argument, 0, 'c'},
{"uppercase", no_argument, 0, 'U'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}};
std::string ifname("-");
std::string ofname("-");
x0::chain_filter cf;
for (bool done = false; !done;) {
int index = 0;
int rv = (getopt_long(argc, argv, "i:o:hUc", options, &index));
switch (rv) {
case 'i':
ifname = optarg;
break;
case 'o':
ofname = optarg;
break;
case 'U':
cf.push_back(x0::filter_ptr(new x0::uppercase_filter()));
break;
case 'c':
cf.push_back(x0::filter_ptr(new x0::CompressFilter()));
break;
case 'h':
std::cerr << "usage: " << argv[0] << " INPUT OUTPUT [-u]" << std::endl
<< " where INPUT and OUTPUT can be '-' to be interpreted as "
"stdin/stdout respectively." << std::endl;
return 0;
case 0:
break;
case -1:
done = true;
break;
default:
std::cerr << "syntax error: "
<< "(" << rv << ")" << std::endl;
return 1;
}
}
x0::source_ptr input(ifname == "-" ? new x0::fd_source(STDIN_FILENO)
: new x0::file_source(getfile(ifname)));
x0::sink_ptr output(ofname == "-" ? new x0::fd_sink(STDOUT_FILENO)
: new x0::file_sink(ofname));
pump(*input, *output, cf);
return 0;
}
| 30.162791
| 80
| 0.543562
|
pjsaksa
|
de779371a7cf848da1afcdcfd9208f0abfc7a65d
| 1,931
|
cc
|
C++
|
runtime/vm/datastream.cc
|
wennyyustalim/sdk
|
e6ffc0b285fb393ba04c4afa35f9a7eae0e05793
|
[
"BSD-3-Clause"
] | 3
|
2020-04-20T00:11:34.000Z
|
2022-01-24T20:43:43.000Z
|
runtime/vm/datastream.cc
|
wennyyustalim/sdk
|
e6ffc0b285fb393ba04c4afa35f9a7eae0e05793
|
[
"BSD-3-Clause"
] | 4
|
2020-04-20T11:16:42.000Z
|
2020-04-20T11:18:30.000Z
|
runtime/vm/datastream.cc
|
wennyyustalim/sdk
|
e6ffc0b285fb393ba04c4afa35f9a7eae0e05793
|
[
"BSD-3-Clause"
] | 3
|
2020-02-13T02:08:04.000Z
|
2020-08-09T07:49:55.000Z
|
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/datastream.h"
namespace dart {
StreamingWriteStream::StreamingWriteStream(intptr_t initial_capacity,
Dart_StreamingWriteCallback callback,
void* callback_data)
: flushed_size_(0), callback_(callback), callback_data_(callback_data) {
buffer_ = reinterpret_cast<uint8_t*>(malloc(initial_capacity));
if (buffer_ == NULL) {
OUT_OF_MEMORY();
}
cursor_ = buffer_;
limit_ = buffer_ + initial_capacity;
}
StreamingWriteStream::~StreamingWriteStream() {
Flush();
free(buffer_);
}
void StreamingWriteStream::VPrint(const char* format, va_list args) {
// Measure.
va_list measure_args;
va_copy(measure_args, args);
intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args);
va_end(measure_args);
// Alloc.
EnsureAvailable(len + 1);
// Print.
va_list print_args;
va_copy(print_args, args);
Utils::VSNPrint(reinterpret_cast<char*>(cursor_), len + 1, format,
print_args);
va_end(print_args);
cursor_ += len; // Not len + 1 to swallow the terminating NUL.
}
void StreamingWriteStream::EnsureAvailableSlowPath(intptr_t needed) {
Flush();
intptr_t available = limit_ - cursor_;
if (available >= needed) return;
intptr_t new_capacity = Utils::RoundUp(needed, 64 * KB);
free(buffer_);
buffer_ = reinterpret_cast<uint8_t*>(malloc(new_capacity));
if (buffer_ == NULL) {
OUT_OF_MEMORY();
}
cursor_ = buffer_;
limit_ = buffer_ + new_capacity;
}
void StreamingWriteStream::Flush() {
intptr_t size = cursor_ - buffer_;
callback_(callback_data_, buffer_, size);
flushed_size_ += size;
cursor_ = buffer_;
}
} // namespace dart
| 27.985507
| 80
| 0.683584
|
wennyyustalim
|
de77a51807f0b0b0d4e3577cd24d13557acf9458
| 324
|
cpp
|
C++
|
pgf+/src/reader/Expr.cpp
|
egladil/mscthesis
|
d6f0c9b1b1e73b749894405372f2edf01e746920
|
[
"BSD-2-Clause"
] | 1
|
2019-05-03T18:00:39.000Z
|
2019-05-03T18:00:39.000Z
|
pgf+/src/reader/Expr.cpp
|
egladil/mscthesis
|
d6f0c9b1b1e73b749894405372f2edf01e746920
|
[
"BSD-2-Clause"
] | null | null | null |
pgf+/src/reader/Expr.cpp
|
egladil/mscthesis
|
d6f0c9b1b1e73b749894405372f2edf01e746920
|
[
"BSD-2-Clause"
] | null | null | null |
//
// Expr.cpp
// pgf+
//
// Created by Emil Djupfeldt on 2012-06-26.
// Copyright (c) 2012 Chalmers University of Technology. All rights reserved.
//
#include <gf/reader/Expr.h>
namespace gf {
namespace reader {
Expr::Expr() {
}
Expr::~Expr() {
}
}
}
| 15.428571
| 78
| 0.509259
|
egladil
|
de7b08cf91b5e5aaed7f68e56832ea58dac9d4de
| 6,995
|
cpp
|
C++
|
src/Ainur/AinurState1.cpp
|
g1257/PsimagLite
|
1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010
|
[
"Unlicense"
] | 8
|
2015-08-19T16:06:52.000Z
|
2021-12-05T02:37:47.000Z
|
src/Ainur/AinurState1.cpp
|
g1257/PsimagLite
|
1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010
|
[
"Unlicense"
] | 5
|
2016-02-02T20:28:21.000Z
|
2019-07-08T22:56:12.000Z
|
src/Ainur/AinurState1.cpp
|
g1257/PsimagLite
|
1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010
|
[
"Unlicense"
] | 5
|
2016-04-29T17:28:00.000Z
|
2019-11-22T03:33:19.000Z
|
#include "AinurState.h"
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include "AinurDoubleOrFloat.h"
namespace PsimagLite {
struct MyProxyFor {
static void convert(long unsigned int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(unsigned int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(long int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(double& t, std::string str)
{
t = PsimagLite::atof(str);
}
static void convert(float& t, std::string str)
{
t = PsimagLite::atof(str);
}
template<typename T>
static void convert(std::complex<T>& t, std::string str)
{
t = toComplex<T>(str);
}
static void convert(String& t, std::string str)
{
t = str;
}
template<typename T>
static void convert(T& t, std::string str)
{
String msg("Unknown type ");
throw RuntimeError("convert(): " + msg + typeid(t).name() + " for " + str + "\n");
}
private:
template<typename RealType>
static std::complex<RealType> toComplex(std::string str)
{
typedef std::complex<RealType> ComplexType;
String buffer;
bool flag = false;
const SizeType n = str.length();
RealType real1 = 0;
for (SizeType i = 0; i < n; ++i) {
bool isSqrtMinus1 = (str[i] == 'i');
if (isSqrtMinus1 && flag)
throw RuntimeError("Error parsing number " + str + "\n");
if (isSqrtMinus1) {
flag = true;
real1 = atof(buffer.c_str());
buffer = "";
continue;
}
buffer += str[i];
}
return (flag) ? ComplexType(real1, atof(buffer.c_str())) :
ComplexType(atof(buffer.c_str()), 0);
}
};
//---------
boost::spirit::qi::rule<std::string::iterator,
std::vector<std::string>(),
boost::spirit::qi::space_type>
ruleRows()
{
boost::spirit::qi::rule<std::string::iterator,
std::vector<std::string>(),
boost::spirit::qi::space_type> myrule = "[" >> (+~boost::spirit::qi::char_(",[]"))
% ',' >> "]";
return myrule;
}
//---------
void AinurState::assign(String k, String v)
{
int x = storageIndexByName(k);
if (x < 0)
err(errLabel(ERR_PARSE_UNDECLARED, k));
assert(static_cast<SizeType>(x) < values_.size());
//if (values_[x] != "")
// std::cerr<<"Overwriting label "<<k<<" with "<<v<<"\n";
values_[x] = v;
}
//---------
template <typename T>
template <typename A, typename ContextType>
void AinurState::ActionMatrix<T>::operator()(A& attr,
ContextType&,
bool&) const
{
SizeType rows = attr.size();
if (rows == 0) return;
SizeType cols = attr[0].size();
t_.resize(rows, cols);
for (SizeType i = 0; i < rows; ++i) {
if (attr[i].size() != cols)
err("Ainur: Problem reading matrix\n");
for (SizeType j = 0; j < cols; ++j)
MyProxyFor::convert(t_(i, j), attr[i][j]);
}
}
//---------
template <typename T>
template <typename A, typename ContextType>
void AinurState::Action<T>::operator()(A& attr,
ContextType&,
bool&) const
{
const SizeType n = attr.size();
if (n == 2 && attr[1] == "...") {
const SizeType m = t_.size();
if (m == 0)
err("Cannot use ellipsis for vector of unknown size\n");
MyProxyFor::convert(t_[0], attr[0]);
for (SizeType i = 1; i < m; ++i)
t_[i] = t_[0];
return;
}
if (n == 2 && attr[1].length() > 4 && attr[1].substr(0, 4) == "...x") {
const SizeType m = t_.size();
const SizeType l = attr[1].length();
const SizeType mm = PsimagLite::atoi(attr[1].substr(4, l - 4));
if (m != 0)
std::cout<<"Resizing vector to "<<mm<<"\n";
t_.resize(mm);
MyProxyFor::convert(t_[0], attr[0]);
for (SizeType i = 1; i < mm; ++i)
t_[i] = t_[0];
return;
}
t_.resize(n);
for (SizeType i = 0; i < n; ++i)
MyProxyFor::convert(t_[i], attr[i]);
}
//---------
template<typename T>
void AinurState::convertInternal(Matrix<T>& t,
String value) const
{
namespace qi = boost::spirit::qi;
typedef std::string::iterator IteratorType;
typedef std::vector<std::string> VectorStringType;
typedef std::vector<VectorStringType> VectorVectorVectorType;
IteratorType it = value.begin();
qi::rule<IteratorType, VectorStringType(), qi::space_type> ruRows = ruleRows();
qi::rule<IteratorType, VectorVectorVectorType(), qi::space_type> full =
"[" >> -(ruRows % ",") >> "]";
ActionMatrix<T> actionMatrix("matrix", t);
bool r = qi::phrase_parse(it,
value.end(),
full [actionMatrix],
qi::space);
//check if we have a match
if (!r) {
err("matrix parsing failed near " +
stringContext(it, value.begin(), value.end())
+ "\n");
}
if (it != value.end())
std::cerr << "matrix parsing: unmatched part exists\n";
}
template<typename T>
void AinurState::convertInternal(std::vector<T>& t,
String value,
typename EnableIf<Loki::TypeTraits<T>::isArith ||
IsComplexNumber<T>::True ||
TypesEqual<T, String>::True,
int>::Type) const
{
namespace qi = boost::spirit::qi;
typedef std::string::iterator IteratorType;
typedef std::vector<std::string> VectorStringType;
IteratorType it = value.begin();
qi::rule<IteratorType, VectorStringType(), qi::space_type> ruRows = ruleRows();
Action<T> actionRows("rows", t);
bool r = qi::phrase_parse(it,
value.end(),
ruRows [actionRows],
qi::space);
//check if we have a match
if (!r)
err("vector parsing failed near " + stringContext(it, value.begin(), value.end()) + "\n");
if (it != value.end()) {
std::cerr << "vector parsing: unmatched part exists near ";
std::cerr << stringContext(it, value.begin(), value.end())<<"\n";
}
}
//---------
template void AinurState::convertInternal(Matrix<DoubleOrFloatType>&,String) const;
template void AinurState::convertInternal(Matrix<std::complex<DoubleOrFloatType> >&,
String) const;
template void AinurState::convertInternal(Matrix<String>&, String) const;
template void AinurState::convertInternal(std::vector<DoubleOrFloatType>&, String, int) const;
template void AinurState::convertInternal(std::vector<std::complex<DoubleOrFloatType> >&,
String,
int) const;
template void AinurState::convertInternal(std::vector<SizeType>&, String, int) const;
template void AinurState::convertInternal(std::vector<int>&, String, int) const;
template void AinurState::convertInternal(std::vector<String>&, String, int) const;
} // namespace PsimagLite
| 26.396226
| 94
| 0.59371
|
g1257
|
de7e28964c63dffd7045225e1a0544cf61653e85
| 1,539
|
cpp
|
C++
|
Algorithms/Search/SherlockandArray/Solution.cpp
|
4ngelica/HackerRank
|
61c4269168a9b35c98840e40637fe87c9735356c
|
[
"MIT"
] | 1,122
|
2017-03-22T03:52:28.000Z
|
2022-03-31T06:01:39.000Z
|
Algorithms/Search/SherlockandArray/Solution.cpp
|
4ngelica/HackerRank
|
61c4269168a9b35c98840e40637fe87c9735356c
|
[
"MIT"
] | 100
|
2017-03-15T20:01:28.000Z
|
2021-07-12T14:42:21.000Z
|
Algorithms/Search/SherlockandArray/Solution.cpp
|
4ngelica/HackerRank
|
61c4269168a9b35c98840e40637fe87c9735356c
|
[
"MIT"
] | 799
|
2017-03-19T21:28:30.000Z
|
2022-03-26T16:58:54.000Z
|
/*
Problem : https://www.hackerrank.com/challenges/sherlock-and-array
C++ 14
Approach :
This is quite a straight forward problem. All elements of the input array is
set to the sum of all the elements upto that point of the input array, i.e.
arr[i] = Sum(arr[j]) for 0 <= j <=i < n
Then in an other loop we compare arr[i] and arr[n-1] - arr[i] , which will
turn the answer to be YES, otherwise it is NO.
Time Complexity : O( n ) for each test case.
Overall Time Complexity : O( t*n ) for entire input file.
Space Complextiy : O( n ) for entire input file.
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int test; cin>>test;
int n=100000, i=0, temp=0;
unsigned long long arr[n], sum=0;
while(test--){
for(i=0; i<=100000; i++){
arr[i]=0;
}
cin>>n;
for(i=0; i<n; i++){
cin>>temp;
sum+=temp;
arr[i]=sum;
temp=0;
}
if(n==1){
cout<<"YES\n";
sum=0;
continue;
}
for(i=1; i<n; i++){
if(arr[i-1]==(arr[n-1]-arr[i])){
cout<<"YES\n";
break;
}
else
continue;
}
if(i==n)
cout<<"NO\n";
sum=0;
}
return 0;
}
| 27
| 84
| 0.492528
|
4ngelica
|
de80f917f17f259dc54dffe14f6d3605eb249fb5
| 17,753
|
cpp
|
C++
|
src/drivers/liberatr.cpp
|
gameblabla/mame_nspire
|
83dfe1606aba906bd28608f2cb8f0754492ac3da
|
[
"Unlicense"
] | 33
|
2015-08-10T11:13:47.000Z
|
2021-08-30T10:00:46.000Z
|
src/drivers/liberatr.cpp
|
gameblabla/mame_nspire
|
83dfe1606aba906bd28608f2cb8f0754492ac3da
|
[
"Unlicense"
] | 13
|
2015-08-25T03:53:08.000Z
|
2022-03-30T18:02:35.000Z
|
src/drivers/liberatr.cpp
|
gameblabla/mame_nspire
|
83dfe1606aba906bd28608f2cb8f0754492ac3da
|
[
"Unlicense"
] | 40
|
2015-08-25T05:09:21.000Z
|
2022-02-08T05:02:30.000Z
|
#include "../vidhrdw/liberatr.cpp"
/***************************************************************************
Liberator Memory Map (for the main set, the other one is rearranged)
(from the schematics/manual)
HEX R/W D7 D6 D5 D4 D3 D2 D2 D0 function
---------+-----+------------------------+------------------------
0000 D D D D D D D D XCOORD
0001 D D D D D D D D YCOORD
0002 D D D BIT MODE DATA
---------+-----+------------------------+------------------------
0003-033F D D D D D D D D Working RAM
0340-3D3F D D D D D D D D Screen RAM
3D40-3FFF D D D D D D D D Working RAM
---------+-----+------------------------+------------------------
4000-403F R D D D D D D D D EARD* read from non-volatile memory
---------+-----+------------------------+------------------------
5000 R D coin AUX (CTRLD* set low)
5000 R D coin LEFT (CTRLD* set low)
5000 R D coin RIGHT (CTRLD* set low)
5000 R D SLAM (CTRLD* set low)
5000 R D SPARE (CTRLD* set low)
5000 R D SPARE (CTRLD* set low)
5000 R D COCKTAIL (CTRLD* set low)
5000 R D SELF-TEST (CTRLD* set low)
5000 R D D D D HDIR (CTRLD* set high)
5000 R D D D D VDIR (CTRLD* set high)
---------+-----+------------------------+------------------------
5001 R D SHIELD 2
5001 R D SHIELD 1
5001 R D FIRE 2
5001 R D FIRE 1
5001 R D SPARE (CTRLD* set low)
5001 R D START 2
5001 R D START 1
5001 R D VBLANK
---------+-----+------------------------+------------------------
6000-600F W D D D D base_ram*
6200-621F W D D D D D D D D COLORAM*
6400 W INTACK*
6600 W D D D D EARCON
6800 W D D D D D D D D STARTLG (planet frame)
6A00 W WDOG*
---------+-----+------------------------+------------------------
6C00 W D START LED 1
6C01 W D START LED 2
6C02 W D TBSWP*
6C03 W D SPARE
6C04 W D CTRLD*
6C05 W D COINCNTRR
6C06 W D COINCNTRL
6C07 W D PLANET
---------+-----+------------------------+------------------------
6E00-6E3F W D D D D D D D D EARWR*
7000-701F D D D D D D D D IOS2* (Pokey 2)
7800-781F D D D D D D D D IOS1* (Pokey 1)
8000-EFFF R D D D D D D D D ROM
-----------------------------------------------------------------
Dip switches at D4 on the PCB for play options: (IN2)
LSB D1 D2 D3 D4 D5 D6 MSB
SW8 SW7 SW6 SW5 SW4 SW3 SW2 SW1 Option
-------------------------------------------------------------------------------------
Off Off 4 ships per game <-
On Off 5 ships per game
Off On 6 ships per game
On On 8 ships per game
-------------------------------------------------------------------------------------
Off Off Bonus ship every 15000 points
On Off Bonus ship every 20000 points <-
Off On Bonus ship every 25000 points
On On Bonus ship every 30000 points
-------------------------------------------------------------------------------------
On Off Easy game play
Off Off Normal game play <-
Off On Hard game play
-------------------------------------------------------------------------------------
X X Not used
-------------------------------------------------------------------------------------
Dip switches at A4 on the PCB for price options: (IN3)
LSB D1 D2 D3 D4 D5 D6 MSB
SW8 SW7 SW6 SW5 SW4 SW3 SW2 SW1 Option
-------------------------------------------------------------------------------------
Off Off Free play
On Off 1 coin for 2 credits
Off On 1 coin for 1 credit <-
On On 2 coins for 1 credit
-------------------------------------------------------------------------------------
Off Off Right coin mech X 1 <-
On Off Right coin mech X 4
Off On Right coin mech X 5
On On Right coin mech X 6
-------------------------------------------------------------------------------------
Off Left coin mech X 1 <-
On Left coin mech X 2
-------------------------------------------------------------------------------------
Off Off Off No bonus coins <-
Off On Off For every 4 coins inserted, game logic
adds 1 more coin
On On Off For every 4 coins inserted, game logic
adds 2 more coin
Off Off On For every 5 coins inserted, game logic
adds 1 more coin
On Off On For every 3 coins inserted, game logic
adds 1 more coin
X On On No bonus coins
-------------------------------------------------------------------------------------
<- = Manufacturer's suggested settings
Note:
----
The loop at $cf60 should count down from Y=0 instead of Y=0xff. Because of this the first
four leftmost pixels of each row are not cleared. This bug is masked by the visible area
covering up the offending pixels.
******************************************************************************************/
#include "driver.h"
#include "machine/atari_vg.h"
extern UINT8 *liberatr_base_ram;
extern UINT8 *liberatr_planet_frame;
extern UINT8 *liberatr_planet_select;
extern UINT8 *liberatr_x;
extern UINT8 *liberatr_y;
/* in vidhrdw */
extern unsigned char *liberatr_bitmapram;
int liberatr_vh_start(void);
void liberatr_vh_stop(void);
void liberatr_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
WRITE_HANDLER( liberatr_colorram_w ) ;
WRITE_HANDLER( liberatr_bitmap_w );
READ_HANDLER( liberatr_bitmap_xy_r );
WRITE_HANDLER( liberatr_bitmap_xy_w );
static UINT8 *liberatr_ctrld;
static WRITE_HANDLER( liberatr_led_w )
{
osd_led_w(offset, (data >> 4) & 0x01);
}
static WRITE_HANDLER( liberatr_coin_counter_w )
{
coin_counter_w(offset ^ 0x01, data);
}
static READ_HANDLER( liberatr_input_port_0_r )
{
int res ;
int xdelta, ydelta;
/* CTRLD selects whether we're reading the stick or the coins,
see memory map */
if(*liberatr_ctrld)
{
/* mouse support */
xdelta = input_port_4_r(0);
ydelta = input_port_5_r(0);
res = ( ((ydelta << 4) & 0xf0) | (xdelta & 0x0f) );
}
else
{
res = input_port_0_r(offset);
}
return res;
}
static struct MemoryReadAddress liberatr_readmem[] =
{
{ 0x0002, 0x0002, liberatr_bitmap_xy_r },
{ 0x0000, 0x3fff, MRA_RAM }, /* overlapping for my convenience */
{ 0x4000, 0x403f, atari_vg_earom_r },
{ 0x5000, 0x5000, liberatr_input_port_0_r },
{ 0x5001, 0x5001, input_port_1_r },
{ 0x7000, 0x701f, pokey2_r },
{ 0x7800, 0x781f, pokey1_r },
{ 0x8000, 0xefff, MRA_ROM },
{ 0xfffa, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
static struct MemoryReadAddress liberat2_readmem[] =
{
{ 0x0002, 0x0002, liberatr_bitmap_xy_r },
{ 0x0000, 0x3fff, MRA_RAM }, /* overlapping for my convenience */
{ 0x4000, 0x4000, liberatr_input_port_0_r },
{ 0x4001, 0x4001, input_port_1_r },
{ 0x4800, 0x483f, atari_vg_earom_r },
{ 0x5000, 0x501f, pokey2_r },
{ 0x5800, 0x581f, pokey1_r },
{ 0x6000, 0xbfff, MRA_ROM },
{ 0xfffa, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress liberatr_writemem[] =
{
{ 0x0002, 0x0002, liberatr_bitmap_xy_w },
{ 0x0000, 0x3fff, liberatr_bitmap_w, &liberatr_bitmapram }, /* overlapping for my convenience */
{ 0x6000, 0x600f, MWA_RAM, &liberatr_base_ram },
{ 0x6200, 0x621f, liberatr_colorram_w },
{ 0x6400, 0x6400, MWA_NOP },
{ 0x6600, 0x6600, atari_vg_earom_ctrl_w },
{ 0x6800, 0x6800, MWA_RAM, &liberatr_planet_frame },
{ 0x6a00, 0x6a00, watchdog_reset_w },
{ 0x6c00, 0x6c01, liberatr_led_w },
{ 0x6c04, 0x6c04, MWA_RAM, &liberatr_ctrld },
{ 0x6c05, 0x6c06, liberatr_coin_counter_w },
{ 0x6c07, 0x6c07, MWA_RAM, &liberatr_planet_select },
{ 0x6e00, 0x6e3f, atari_vg_earom_w },
{ 0x7000, 0x701f, pokey2_w },
{ 0x7800, 0x781f, pokey1_w },
{ 0x8000, 0xefff, MWA_ROM },
{ 0xfffa, 0xffff, MWA_ROM },
{ 0x0000, 0x0000, MWA_RAM, &liberatr_x }, /* just here to assign pointer */
{ 0x0001, 0x0001, MWA_RAM, &liberatr_y }, /* just here to assign pointer */
{ -1 } /* end of table */
};
static struct MemoryWriteAddress liberat2_writemem[] =
{
{ 0x0002, 0x0002, liberatr_bitmap_xy_w },
{ 0x0000, 0x3fff, liberatr_bitmap_w, &liberatr_bitmapram }, /* overlapping for my convenience */
{ 0x4000, 0x400f, MWA_RAM, &liberatr_base_ram },
{ 0x4200, 0x421f, liberatr_colorram_w },
{ 0x4400, 0x4400, MWA_NOP },
{ 0x4600, 0x4600, atari_vg_earom_ctrl_w },
{ 0x4800, 0x4800, MWA_RAM, &liberatr_planet_frame },
{ 0x4a00, 0x4a00, watchdog_reset_w },
{ 0x4c00, 0x4c01, liberatr_led_w },
{ 0x4c04, 0x4c04, MWA_RAM, &liberatr_ctrld },
{ 0x4c05, 0x4c06, liberatr_coin_counter_w },
{ 0x4c07, 0x4c07, MWA_RAM, &liberatr_planet_select },
{ 0x4e00, 0x4e3f, atari_vg_earom_w },
{ 0x5000, 0x501f, pokey2_w },
{ 0x5800, 0x581f, pokey1_w },
//{ 0x6000, 0x601f, pokey1_w }, /* bug ??? */
{ 0x6000, 0xbfff, MWA_ROM },
{ 0xfffa, 0xffff, MWA_ROM },
{ 0x0000, 0x0000, MWA_RAM, &liberatr_x }, /* just here to assign pointer */
{ 0x0001, 0x0001, MWA_RAM, &liberatr_y }, /* just here to assign pointer */
{ -1 } /* end of table */
};
INPUT_PORTS_START( liberatr )
PORT_START /* IN0 - $5000 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) )
PORT_DIPSETTING( 0x40, DEF_STR( Upright ) )
PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) )
PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
PORT_START /* IN1 - $5001 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH,IPT_VBLANK )
PORT_START /* IN2 - Game Option switches DSW @ D4 on PCB */
PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )
PORT_DIPSETTING( 0x00, "4" )
PORT_DIPSETTING( 0x01, "5" )
PORT_DIPSETTING( 0x02, "6" )
PORT_DIPSETTING( 0x03, "8" )
PORT_DIPNAME( 0x0C, 0x04, DEF_STR( Bonus_Life ) )
PORT_DIPSETTING( 0x00, "15000" )
PORT_DIPSETTING( 0x04, "20000" )
PORT_DIPSETTING( 0x08, "25000" )
PORT_DIPSETTING( 0x0C, "30000" )
PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ) )
PORT_DIPSETTING( 0x10, "Easy" )
PORT_DIPSETTING( 0x00, "Normal" )
PORT_DIPSETTING( 0x20, "Hard" )
PORT_DIPSETTING( 0x30, "???" )
PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START /* IN3 - Pricing Option switches DSW @ A4 on PCB */
PORT_DIPNAME( 0x03, 0x02, DEF_STR( Coinage ) )
PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x02, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )
PORT_DIPNAME( 0x0c, 0x00, "Right Coin" )
PORT_DIPSETTING ( 0x00, "*1" )
PORT_DIPSETTING ( 0x04, "*4" )
PORT_DIPSETTING ( 0x08, "*5" )
PORT_DIPSETTING ( 0x0c, "*6" )
PORT_DIPNAME( 0x10, 0x00, "Left Coin" )
PORT_DIPSETTING ( 0x00, "*1" )
PORT_DIPSETTING ( 0x10, "*2" )
/* TODO: verify the following settings */
PORT_DIPNAME( 0xe0, 0x00, "Bonus Coins" )
PORT_DIPSETTING ( 0x00, "None" )
PORT_DIPSETTING ( 0x80, "1 each 5" )
PORT_DIPSETTING ( 0x40, "1 each 4 (+Demo)" )
PORT_DIPSETTING ( 0xa0, "1 each 3" )
PORT_DIPSETTING ( 0x60, "2 each 4 (+Demo)" )
PORT_DIPSETTING ( 0x20, "1 each 2" )
PORT_DIPSETTING ( 0xc0, "Freeze Mode" )
PORT_DIPSETTING ( 0xe0, "Freeze Mode" )
PORT_START /* IN4 - FAKE - overlaps IN0 in the HW */
PORT_ANALOG( 0x0f, 0x0, IPT_TRACKBALL_X, 30, 10, 0, 0 )
PORT_START /* IN5 - FAKE - overlaps IN0 in the HW */
PORT_ANALOG( 0x0f, 0x0, IPT_TRACKBALL_Y, 30, 10, 0, 0 )
INPUT_PORTS_END
static struct POKEYinterface pokey_interface =
{
2, /* 2 chips */
FREQ_17_APPROX, /* 1.7 Mhz */
{ 50, 50 },
/* The 8 pot handlers */
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
/* The allpot handler */
{ input_port_3_r, input_port_2_r }
};
#define MACHINE_DRIVER(NAME) \
static struct MachineDriver machine_driver_##NAME = \
{ \
/* basic machine hardware */ \
{ \
{ \
CPU_M6502, \
1250000, /* 1.25 Mhz */ \
NAME##_readmem,NAME##_writemem,0,0, \
interrupt, 4 \
} \
}, \
60, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */ \
1, /* single CPU, no need for interleaving */ \
0, \
\
/* video hardware */ \
256, 256, { 8, 247, 13, 244 }, \
0, /* no gfxdecodeinfo - bitmapped display */ \
32, 0, \
0, \
\
VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE, \
0, \
liberatr_vh_start, \
liberatr_vh_stop, \
liberatr_vh_screenrefresh, \
\
/* sound hardware */ \
0,0,0,0, \
{ \
{ \
SOUND_POKEY, \
&pokey_interface \
} \
}, \
\
atari_vg_earom_handler \
};
MACHINE_DRIVER(liberatr)
MACHINE_DRIVER(liberat2)
/***************************************************************************
Game driver(s)
***************************************************************************/
ROM_START( liberatr )
ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code and data */
ROM_LOAD( "136012.206", 0x8000, 0x1000, 0x1a0cb4a0 )
ROM_LOAD( "136012.205", 0x9000, 0x1000, 0x2f071920 )
ROM_LOAD( "136012.204", 0xa000, 0x1000, 0xbcc91827 )
ROM_LOAD( "136012.203", 0xb000, 0x1000, 0xb558c3d4 )
ROM_LOAD( "136012.202", 0xc000, 0x1000, 0x569ba7ea )
ROM_LOAD( "136012.201", 0xd000, 0x1000, 0xd12cd6d0 )
ROM_LOAD( "136012.200", 0xe000, 0x1000, 0x1e98d21a )
ROM_RELOAD( 0xf000, 0x1000 ) /* for interrupt/reset vectors */
ROM_REGION( 0x4000, REGION_GFX1 ) /* planet image, used at runtime */
ROM_LOAD( "136012.110", 0x0000, 0x1000, 0x6eb11221 )
ROM_LOAD( "136012.107", 0x1000, 0x1000, 0x8a616a63 )
ROM_LOAD( "136012.108", 0x2000, 0x1000, 0x3f8e4cf6 )
ROM_LOAD( "136012.109", 0x3000, 0x1000, 0xdda0c0ef )
ROM_END
ROM_START( liberat2 )
ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code and data */
ROM_LOAD( "l6.bin", 0x6000, 0x1000, 0x78093d06 )
ROM_LOAD( "l5.bin", 0x7000, 0x1000, 0x988db636 )
ROM_LOAD( "l4.bin", 0x8000, 0x1000, 0xec114540 )
ROM_LOAD( "l3.bin", 0x9000, 0x1000, 0x184c751f )
ROM_LOAD( "l2.bin", 0xa000, 0x1000, 0xc3f61f88 )
ROM_LOAD( "l1.bin", 0xb000, 0x1000, 0xef6e9f9e )
ROM_RELOAD( 0xf000, 0x1000 ) /* for interrupt/reset vectors */
ROM_REGION( 0x4000, REGION_GFX1 ) /* planet image, used at runtime */
ROM_LOAD( "136012.110", 0x0000, 0x1000, 0x6eb11221 )
ROM_LOAD( "136012.107", 0x1000, 0x1000, 0x8a616a63 )
ROM_LOAD( "136012.108", 0x2000, 0x1000, 0x3f8e4cf6 )
ROM_LOAD( "136012.109", 0x3000, 0x1000, 0xdda0c0ef )
ROM_END
GAMEX( 1982, liberatr, 0, liberatr, liberatr, 0, ROT0, "Atari", "Liberator (set 1)", GAME_NO_COCKTAIL )
GAMEX( 1982, liberat2, liberatr, liberat2, liberatr, 0, ROT0, "Atari", "Liberator (set 2)", GAME_NOT_WORKING | GAME_NO_COCKTAIL )
| 38.260776
| 129
| 0.506788
|
gameblabla
|
de84b2b4c1ef18125a077ec4c9571b8af9eef504
| 2,453
|
cpp
|
C++
|
parallel-libs/acxxel/examples/opencl_example.cpp
|
medismailben/llvm-project
|
e334a839032fe500c3bba22bf976ab7af13ce1c1
|
[
"Apache-2.0"
] | 2,338
|
2018-06-19T17:34:51.000Z
|
2022-03-31T11:00:37.000Z
|
parallel-libs/acxxel/examples/opencl_example.cpp
|
medismailben/llvm-project
|
e334a839032fe500c3bba22bf976ab7af13ce1c1
|
[
"Apache-2.0"
] | 3,740
|
2019-01-23T15:36:48.000Z
|
2022-03-31T22:01:13.000Z
|
parallel-libs/acxxel/examples/opencl_example.cpp
|
medismailben/llvm-project
|
e334a839032fe500c3bba22bf976ab7af13ce1c1
|
[
"Apache-2.0"
] | 500
|
2019-01-23T07:49:22.000Z
|
2022-03-30T02:59:37.000Z
|
//===--- opencl_example.cpp - Example of using Acxxel with OpenCL ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// This file is an example of using OpenCL with Acxxel.
///
//===----------------------------------------------------------------------===//
#include "acxxel.h"
#include <array>
#include <cstdio>
#include <cstring>
static const char *SaxpyKernelSource = R"(
__kernel void saxpyKernel(float A, __global float *X, __global float *Y, int N) {
int I = get_global_id(0);
if (I < N)
X[I] = A * X[I] + Y[I];
}
)";
template <size_t N>
void saxpy(float A, std::array<float, N> &X, const std::array<float, N> &Y) {
acxxel::Platform *OpenCL = acxxel::getOpenCLPlatform().getValue();
acxxel::Stream Stream = OpenCL->createStream().takeValue();
auto DeviceX = OpenCL->mallocD<float>(N).takeValue();
auto DeviceY = OpenCL->mallocD<float>(N).takeValue();
Stream.syncCopyHToD(X, DeviceX).syncCopyHToD(Y, DeviceY);
acxxel::Program Program =
OpenCL
->createProgramFromSource(acxxel::Span<const char>(
SaxpyKernelSource, std::strlen(SaxpyKernelSource)))
.takeValue();
acxxel::Kernel Kernel = Program.createKernel("saxpyKernel").takeValue();
float *RawX = static_cast<float *>(DeviceX);
float *RawY = static_cast<float *>(DeviceY);
int IntLength = N;
void *Arguments[] = {&A, &RawX, &RawY, &IntLength};
size_t ArgumentSizes[] = {sizeof(float), sizeof(float *), sizeof(float *),
sizeof(int)};
acxxel::Status Status =
Stream.asyncKernelLaunch(Kernel, N, Arguments, ArgumentSizes)
.syncCopyDToH(DeviceX, X)
.sync();
if (Status.isError()) {
std::fprintf(stderr, "Error during saxpy: %s\n",
Status.getMessage().c_str());
std::exit(EXIT_FAILURE);
}
}
int main() {
float A = 2.f;
std::array<float, 3> X{{0.f, 1.f, 2.f}};
std::array<float, 3> Y{{3.f, 4.f, 5.f}};
std::array<float, 3> Expected{{3.f, 6.f, 9.f}};
saxpy(A, X, Y);
for (int I = 0; I < 3; ++I)
if (X[I] != Expected[I]) {
std::fprintf(stderr, "Mismatch at position %d, %f != %f\n", I, X[I],
Expected[I]);
std::exit(EXIT_FAILURE);
}
}
| 35.042857
| 81
| 0.578475
|
medismailben
|
de8502cf617a9e2c2736d3751817269a7292a8a9
| 12,174
|
cpp
|
C++
|
PeerIOSerialControl.cpp
|
TGit-Tech/PeerIOSerialControl
|
cdb79f906e359fbc7fab934b918cb54dc61b1810
|
[
"MIT"
] | null | null | null |
PeerIOSerialControl.cpp
|
TGit-Tech/PeerIOSerialControl
|
cdb79f906e359fbc7fab934b918cb54dc61b1810
|
[
"MIT"
] | null | null | null |
PeerIOSerialControl.cpp
|
TGit-Tech/PeerIOSerialControl
|
cdb79f906e359fbc7fab934b918cb54dc61b1810
|
[
"MIT"
] | null | null | null |
/************************************************************************//**
* @file PeerIOSerialControl.cpp
* @brief Arduino Peer IO-Control through Serial Port Communications.
* @authors
* tgit23 1/2017 Original
******************************************************************************/
#include "PeerIOSerialControl.h"
#define ID_MASK 0x0F // Bytes[0] [0000 1111] ArduinoID ( 0-15 )
#define REPLY_BIT 4 // Bytes[0] [0001 0000] Reply-1, Send-0
#define RW_BIT 5 // Bytes[0] [0010 0000] Read-1, Write-0
#define DA_BIT 6 // Bytes[0] [0100 0000] Digital-1, Analog-0
#define DPIN_MASK 0x3F // Bytes[1] [0011 1111] Digital Pins ( 0 - 63 )
#define APIN_MASK 0x7F // Bytes[1] [0111 1111] Analog Pins ( 0 - 127 )
#define HL_BIT 6 // Bytes[1] [0100 0000] High-1, Low-0
#define END_BIT 7 // Bytes[?} [1000 0000] Any set 8th bit flags END-OF-PACKET
//-----------------------------------------------------------------------------------------------------
// Initializer
//-----------------------------------------------------------------------------------------------------
PeerIOSerialControl::PeerIOSerialControl(int ThisArduinoID, Stream &CommunicationPort, Stream &DebugPort) {
ArduinoID = ThisArduinoID;
COMPort = &CommunicationPort;
DBPort = &DebugPort;
}
void PeerIOSerialControl::digitalWriteB(uint8_t Pin, uint8_t Value) {
int packetID = SendPacket(DIGITAL,WRITE,Pin,Value);
unsigned long Start = millis();
do {
if ( Available() ) break;
} while ( (millis() - Start) < BlockingTimeoutMS );
}
int PeerIOSerialControl::digitalReadB(uint8_t Pin) {
int packetID = SendPacket(DIGITAL,READ,Pin);
unsigned long Start = millis();
do {
if ( Available() ) return GetReply(packetID);
} while ( (millis() - Start) < BlockingTimeoutMS );
return -1;
}
int PeerIOSerialControl::analogReadB(uint8_t Pin) {
int packetID = SendPacket(ANALOG,READ,Pin);
unsigned long Start = millis();
do {
if ( Available() ) return GetReply(packetID);
} while ( (millis() - Start) < BlockingTimeoutMS );
return -1;
}
void PeerIOSerialControl::analogWriteB(uint8_t Pin, int Value) {
int packetID = SendPacket(ANALOG,WRITE,Pin,Value);
unsigned long Start = millis();
do {
if ( Available() ) break;
} while ( (millis() - Start) < BlockingTimeoutMS );
}
int PeerIOSerialControl::digitalWriteNB(uint8_t Pin, uint8_t Value) {
return SendPacket(DIGITAL,WRITE,Pin,Value);
}
int PeerIOSerialControl::digitalReadNB(uint8_t Pin) {
return SendPacket(DIGITAL,READ,Pin);
}
int PeerIOSerialControl::analogReadNB(uint8_t Pin) {
return SendPacket(ANALOG,READ,Pin);
}
int PeerIOSerialControl::analogWriteNB(uint8_t Pin, int Value) {
return SendPacket(ANALOG,WRITE,Pin,Value);
}
void PeerIOSerialControl::TargetArduinoID(int ID) {
iTargetArduinoID = ID;
}
int PeerIOSerialControl::TargetArduinoID() {
return iTargetArduinoID;
}
void PeerIOSerialControl::Timeout(int milliseconds) {
BlockingTimeoutMS = milliseconds;
}
int PeerIOSerialControl::Timeout() {
return BlockingTimeoutMS;
}
void PeerIOSerialControl::VirtualPin(int Pin, int Value) {
if ( Pin > 63 && Pin < 128 ) iVirtualPin[Pin-64] = Value;
}
int PeerIOSerialControl::VirtualPin(int Pin) {
if ( Pin > 63 && Pin < 128 ) return iVirtualPin[Pin-64];
}
//-----------------------------------------------------------------------------------------------------
// SendPacket()
//-----------------------------------------------------------------------------------------------------
int PeerIOSerialControl::SendPacket(bool DA, bool RW, byte Pin, int Value) {
DBL(("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"));
DBL(("SendPacket()"));
byte SBytes[4] = { 0,0,0,0 };
if ( DA ) bitSet(SBytes[0],DA_BIT);
if ( RW ) bitSet(SBytes[0],RW_BIT);
SBytes[0] = SBytes[0] | (iTargetArduinoID & ID_MASK);
if ( DA == DIGITAL ) {
SBytes[1] = (Pin & DPIN_MASK); // 6-bit Pin for Digital
if ( RW != READ ) bitWrite(SBytes[1],HL_BIT,(Value>0)); // Digital Write - Set H/L Bit
bitSet(SBytes[1],END_BIT); // Digital only uses 2-Bytes
} else {
SBytes[1] = (Pin & APIN_MASK); // 7-bit Pin for Analog
if ( Value > -1 ) {
Value = ValueTo7bits(Value); // Conversion marks the END_BIT
SBytes[2] = lowByte(Value);
SBytes[3] = highByte(Value);
} else {
bitSet(SBytes[1],END_BIT); // Set END_BIT if not sending Value
}
}
DB(("SendBytes( "));
COMPort->write(SBytes[0]);
COMPort->write(SBytes[1]);
if ( SBytes[2] != 0 ) COMPort->write(SBytes[2]);
if ( SBytes[3] != 0 ) COMPort->write(SBytes[3]);
DB((SBytes[0],HEX));DBC;DB((SBytes[1],HEX));DBC;DB((SBytes[2],HEX));DBC;DB((SBytes[3],HEX));DBL((" )"));
return ( SBytes[1] << 8 ) | SBytes[0]; // Return Bytes 0, 1 for tracking
}
//-----------------------------------------------------------------------------------------------------
// GetReply()
//-----------------------------------------------------------------------------------------------------
int PeerIOSerialControl::GetReply(int packetID) {
DB(("GetReply("));DB((packetID,HEX));DBL((")"));
int UseRBI = RBI - 1;
if ( UseRBI < 1 ) UseRBI = 0;
// Find the Reply for this Command
if ( packetID != -1 ) {
byte Byte0 = lowByte(packetID);
byte Byte1 = highByte(packetID);
int i = UseRBI; UseRBI = -1;
do {
DB(("\tRBytes["));DB((i));DB(("][0] = "));DBL((RBytes[i][0],HEX));
DB(("\tRBytes["));DB((i));DB(("][1] = "));DBL((RBytes[i][1],HEX));
if ( (Byte0 & 0xEF) == (RBytes[i][0] & 0xEF) &&
(Byte1 & 0x3F) == (RBytes[i][1] & 0x3F) ) {
UseRBI = i;
break;
}
i--; if ( i < 0 ) i = 9;
} while ( i != RBI );
}
if ( UseRBI < 0 ) return -1;
if ( bitRead(RBytes[UseRBI][0],RW_BIT) == WRITE ) {
return 0; // Okay Status for a WRITE COMMAND
} else {
if ( bitRead(RBytes[UseRBI][0],DA_BIT) == DIGITAL ) { // Value of the Reply
return bitRead(RBytes[UseRBI][1],HL_BIT);
} else {
return ValueTo8bits(RBytes[UseRBI][2],RBytes[UseRBI][3]);
}
}
}
//-----------------------------------------------------------------------------------------------------
// ValueTo8bits() ValueTo7bits()
// - Encodes / Decodes numeric values into (2)7-bit bytes for the 14-bit 'AV' (Analog Value) Bytes
// - This function automatically attaches the END_BIT at the appropriate location.
//-----------------------------------------------------------------------------------------------------
int PeerIOSerialControl::ValueTo8bits(byte lByte, byte hByte) {
bitClear(hByte,7); // Clear any End-Of-Packet flag
bitWrite(lByte,7,bitRead(hByte,0)); // Transfer hByte<0> onto lByte<7>
return (hByte<<7) | lByte; // Left shift 7 overwrites lByte<7>
}
int PeerIOSerialControl::ValueTo7bits(int From8BitValue) {
byte lByte = lowByte(From8BitValue);
byte hByte = highByte(From8BitValue);
if ( From8BitValue > 0x3FFF ) return -1; // Value is too big for a 14-bit Value
hByte = hByte << 1; // Make Room on hByte for bit-7 of lByte
bitWrite(hByte,0,bitRead(lByte,7)); // Transfer lByte<7> onto hByte<0>
if ( From8BitValue > 0x7F ) {
bitSet(hByte,7); // Value > 7-bits so Set 'END_BIT' @ hByte
bitClear(lByte,7);
} else {
bitSet(lByte,7); // Value <= 7-bits so Set 'END_BIT' @ lByte
bitClear(hByte,7);
}
return (hByte<<8) | lByte;
}
//-----------------------------------------------------------------------------------------------------
// DecodePacket()
//-----------------------------------------------------------------------------------------------------
void PeerIOSerialControl::DecodePacket(long lPacket) {
byte Byte0; byte Byte1; byte Byte2; byte Byte3;
if ( lPacket = -1 ) {
Byte0=Bytes[0];Byte1=Bytes[1];Byte2=Bytes[2];Byte3=Bytes[3];
} else {
Byte0 = ( lPacket >> 24 ) & 0xFF;
Byte1 = ( lPacket >> 16 ) & 0xFF;
Byte2 = ( lPacket >> 8 ) & 0xFF;
Byte3 = lPacket & 0xFF;
}
DB(("D/A Flag = "));if ( bitRead(Byte0,DA_BIT) ) { DBL(("DIGITAL")); } else { DBL(("ANALOG")); }
DB(("R/W Flag = "));if ( bitRead(Byte0,RW_BIT) ) { DBL(("READ")); } else { DBL(("WRITE")); }
DB(("S/R Flag = "));if ( bitRead(Byte0,REPLY_BIT) ) { DBL(("REPLY")); } else { DBL(("SEND")); }
DB(("Arduino ID = "));DBL(( (Byte0 & ID_MASK) ));
if ( bitRead(Byte0,DA_BIT) ) {
DB(("H/L Flag = "));
if ( bitRead(Byte0,HL_BIT) ) { DBL(("HIGH")); } else { DBL(("LOW")); }
DB(("PIN = "));DBL(( (Byte1 & DPIN_MASK) ));
} else {
DB(("Value = "));DBL(( ValueTo8bits(Byte2, Byte3) ));
DB(("PIN = "));DBL(( (Byte1 & APIN_MASK) ));
}
}
//-----------------------------------------------------------------------------------------------------
// ProcessPacket()
//-----------------------------------------------------------------------------------------------------
void PeerIOSerialControl::ProcessPacket() {
DB(("ProcessPacket( "));
DB((Bytes[0],HEX));DBC;DB((Bytes[1],HEX));DBC;DB((Bytes[2],HEX));DBC;DB((Bytes[3],HEX));
DB((" ) - "));
// REPLY PACKET RECEIVED
if ( bitRead(Bytes[0],REPLY_BIT) ) {
DBL(("Packet Type REPLY"));
for ( int i=0;i<4;i++ ) RBytes[RBI][i] = Bytes[i]; // Put Replies in RBytes Buffer
#if defined(DEBUG)
#if DEBUG>0
DecodePacket();
#endif
#endif
// COMMAND PACKET RECEIVED
} else if ( (Bytes[0] & ID_MASK) == ArduinoID ) {
DBL(("Packet Type SEND"));
// DIGITAL
if ( bitRead(Bytes[0],DA_BIT) == DIGITAL ) {
int pin = Bytes[1] & DPIN_MASK;
if ( bitRead(Bytes[0],RW_BIT) == READ ) {
DB(("digitalRead("));DB((pin));DBL((")"));
bitWrite(Bytes[1],HL_BIT,digitalRead(pin));
} else {
DB(("digitalWrite("));DB((pin));DB((","));DB((bitRead(Bytes[1],HL_BIT)));DBL((")"));
digitalWrite(pin,bitRead(Bytes[1],HL_BIT));
}
bitSet(Bytes[1],END_BIT);
// ANALOG
} else {
int pin = Bytes[1] & APIN_MASK;
int val = 0;
if ( bitRead(Bytes[0],RW_BIT) == READ ) {
DB(("analogRead("));DB((pin));DBL((")"));
if ( pin > 63 && pin < 128 ) {
val = ValueTo7bits(iVirtualPin[pin-64]);
} else {
val = ValueTo7bits(analogRead(pin));
}
Bytes[2] = lowByte(val);
Bytes[3] = highByte(val);
} else {
DB(("analogWrite("));DB((pin));DB((","));DB((ValueTo8bits(Bytes[2],Bytes[3])));DBL((")"));
if ( pin > 63 && pin < 128 ) {
iVirtualPin[pin-64] = ValueTo8bits(Bytes[2],Bytes[3]);
} else {
analogWrite(pin,ValueTo8bits(Bytes[2],Bytes[3]));
}
}
}
// Send out the Reply Packet
bitSet(Bytes[0],REPLY_BIT); // Set the Reply Bit
DB(("SendBytes( "));
COMPort->write(Bytes[0]);
COMPort->write(Bytes[1]);
if ( Bytes[2] != 0 ) COMPort->write(Bytes[2]);
if ( Bytes[3] != 0 ) COMPort->write(Bytes[3]);
DB((Bytes[0],HEX));DBC;DB((Bytes[1],HEX));DBC;DB((Bytes[2],HEX));DBC;DB((Bytes[3],HEX));DBL((" )"));
}
}
//-----------------------------------------------------------------------------------------------------
// Available()
//-----------------------------------------------------------------------------------------------------
bool PeerIOSerialControl::Available() {
// Receive Bytes
while(COMPort->available() > 0) {
Bytes[idx] = COMPort->read();
if ( Bytes[idx] != -1 ) {
//DBL((Bytes[idx],HEX));
if ( bitRead(Bytes[idx],END_BIT) ) {
DBL(("-----------------------------------------------------------"));
DB(("Packet Received @ Size: "));DBL((idx+1));
bitClear(Bytes[idx],END_BIT); // Clear the END_BIT
for(int i=(idx+1);i<4;i++) Bytes[i]=0; // Clear unused bytes
idx = 0;
ProcessPacket();
return true;
} else {
idx++;
}
}
}
}
| 38.894569
| 107
| 0.496632
|
TGit-Tech
|
de8726d230ba89163f05f0b03924340a6d8bb824
| 23,188
|
cc
|
C++
|
Source/Util/sort.cc
|
AryaFaramarzi/CS220-dmfb-synthesis-skeleton
|
6b592516025f6c2838f269dcf2ca1696d9de5ab8
|
[
"MIT"
] | 3
|
2018-11-03T06:17:08.000Z
|
2020-08-12T05:26:47.000Z
|
Source/Util/sort.cc
|
AryaFaramarzi/CS220-dmfb-synthesis-skeleton
|
6b592516025f6c2838f269dcf2ca1696d9de5ab8
|
[
"MIT"
] | null | null | null |
Source/Util/sort.cc
|
AryaFaramarzi/CS220-dmfb-synthesis-skeleton
|
6b592516025f6c2838f269dcf2ca1696d9de5ab8
|
[
"MIT"
] | 6
|
2019-09-03T23:58:04.000Z
|
2021-07-09T02:33:47.000Z
|
/*------------------------------------------------------------------------------*
* (c)2016, All Rights Reserved. *
* ___ ___ ___ *
* /__/\ / /\ / /\ *
* \ \:\ / /:/ / /::\ *
* \ \:\ / /:/ / /:/\:\ *
* ___ \ \:\ / /:/ ___ / /:/~/:/ *
* /__/\ \__\:\ /__/:/ / /\ /__/:/ /:/___ UCR DMFB Synthesis Framework *
* \ \:\ / /:/ \ \:\ / /:/ \ \:\/:::::/ www.microfluidics.cs.ucr.edu *
* \ \:\ /:/ \ \:\ /:/ \ \::/~~~~ *
* \ \:\/:/ \ \:\/:/ \ \:\ *
* \ \::/ \ \::/ \ \:\ *
* \__\/ \__\/ \__\/ *
*-----------------------------------------------------------------------------*/
/*---------------------------Implementation Details-----------------------------*
* Source: sort.cc *
* Original Code Author(s): Dan Grissom *
* Original Completion/Release Date: October 7, 2012 *
* *
* Details: N/A *
* *
* Revision History: *
* WHO WHEN WHAT *
* --- ---- ---- *
* FML MM/DD/YY One-line description *
*-----------------------------------------------------------------------------*/
#include "sort.h"
#include "wire_router.h" // DTG
///////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////
Sort::Sort() {}
///////////////////////////////////////////////////////////////////////////////////
// Deconstructor
///////////////////////////////////////////////////////////////////////////////////
Sort::~Sort(){}
/////////////////////////////////////////////////////////////////
// Sorts nodes by starting time-step, from least to greatest
/////////////////////////////////////////////////////////////////
bool sNodesByStartTS(AssayNode *a1, AssayNode *a2) { return (a1->GetStartTS() < a2->GetStartTS()); }
bool sNodesByStartThenEndTS(AssayNode *a1, AssayNode *a2)
{
if (a1->GetStartTS() == a2->GetStartTS())
return (a1->GetEndTS() < a2->GetEndTS());
else
return (a1->GetStartTS() < a2->GetStartTS());
}
bool sPathNodesByStartTS(AssayPathNode *a1, AssayPathNode *a2) { return (a1->startTS < a2->startTS); }
/////////////////////////////////////////////////////////////////
// Sorts nodes by length, from shortest to longest
/////////////////////////////////////////////////////////////////
bool sNodesByLength(AssayNode *a1, AssayNode *a2) { return (a1->GetEndTS() - a1->GetStartTS() < a2->GetEndTS() - a2->GetStartTS()); }
/////////////////////////////////////////////////////////////////
// Sorts integers at derefrenced address in decreasing order
/////////////////////////////////////////////////////////////////
bool sDecreasingInts(int *i1, int *i2) { return ((*i1) > (*i2)); }
/////////////////////////////////////////////////////////////////
// Sorts by starting TS. If a tie, puts the storage-holders
// first.
/////////////////////////////////////////////////////////////////
bool sNodesByStartTSThenStorageFirst(AssayNode *a1, AssayNode *a2)
{
if (a1->GetStartTS() == a2->GetStartTS())
{
if (a1->GetType() == STORAGE_HOLDER && a2->GetType() != STORAGE_HOLDER)
return true;
else
return false;
}
else
return (a1->GetStartTS() < a2->GetStartTS());
}
/////////////////////////////////////////////////////////////////
// Sorts nodes by reconfig. module, and then by starting time-step,
// from least to greatest
/////////////////////////////////////////////////////////////////
bool sNodesByModuleThenStartTS(AssayNode *a1, AssayNode *a2)
{
//if (a1->GetReconfigMod() != a2->GetReconfigMod())
// return (a1->GetReconfigMod() < a2->GetReconfigMod());
//else
// return (a1->GetStartTS() < a2->GetStartTS());
//;return true;
if (a1->GetReconfigMod()->getId() == a2->GetReconfigMod()->getId())
return (a1->GetStartTS() < a2->GetStartTS());
else
return (a1->GetReconfigMod()->getId() < a2->GetReconfigMod()->getId());
}
/////////////////////////////////////////////////////////////////
// Sorts nodes by priority, but puts outputs at the very front
// b/c they can ALWAYS go and free up system resources...not matter
// what their priority is. HiFirst puts the higher numbers in front,
// while LoFirst puts the lower numbers first
/////////////////////////////////////////////////////////////////
bool sNodesByPriorityHiFirst(AssayNode *a1, AssayNode *a2)
{
if (a1->GetType() == OUTPUT && a2->GetType() != OUTPUT)
return true;
else if (a1->GetType() != OUTPUT && a2->GetType() == OUTPUT)
return false;
return (a1->GetPriority() > a2->GetPriority());
}
bool sNodesByPriorityLoFirst(AssayNode *a1, AssayNode *a2)
{
if (a1->GetType() == OUTPUT && a2->GetType() != OUTPUT)
return true;
else if (a1->GetType() != OUTPUT && a2->GetType() == OUTPUT)
return false;
return (a1->GetPriority() < a2->GetPriority());
}
///////////////////////////////////////////////////////////////
// Sort heat and detects to front of list b/c they have more
// stringent resource demands and should be processed first
///////////////////////////////////////////////////////////////
bool sNodesByLimitedResources(AssayNode *a1, AssayNode *a2)
{
if ((a1->GetType() == HEAT || a1->GetType() == DETECT) && !(a2->GetType() == HEAT || a2->GetType() == DETECT))
return true;
else
return false;
}
///////////////////////////////////////////////////////////////
// Shortest id first
///////////////////////////////////////////////////////////////
bool sNodesById(AssayNode *a1, AssayNode *a2) { return (a1->getId() < a2->getId()); }
///////////////////////////////////////////////////////////////
// Longest routes first
///////////////////////////////////////////////////////////////
bool sRoutesByLength(vector<RoutePoint *> *r1, vector<RoutePoint *> *r2)
{
return r1->size() > r2->size();
}
///////////////////////////////////////////////////////////////
// Latest ending time-steps first, then sort the storage nodes
// to the end.
// ***** original latestTS then storage copy
///////////////////////////////////////////////////////////////
bool sNodesByLatestTSAndStorage(AssayNode *a1, AssayNode *a2)
{
if (a1->GetType() == STORAGE && a2->GetType() != STORAGE)
return true;
else if ((a1->GetType() == DETECT || a1->GetType() == HEAT) && !(a2->GetType() == DETECT || a2->GetType() == HEAT))
return true;
else if (a1->GetEndTS() != a2->GetEndTS())
return a1->GetEndTS() > a2->GetEndTS();
else
return true;
}
///////////////////////////////////////////////////////////////
// Latest ending time-steps first, then sort the storage nodes
// to the end.
// *****Changed to:
// If is a storage node and not changing modules from parent
// node's module, then sorted to front
///////////////////////////////////////////////////////////////
bool sNodesByLatestTSThenStorage(AssayNode *a1, AssayNode *a2)
{
if (a1->GetType() == STORAGE && a2->GetType() != STORAGE)
return true;
else if (a1->GetType() != STORAGE && a2->GetType() == STORAGE)
return false;
else if (a1->GetType() == STORAGE && a2->GetType() == STORAGE)
{
ReconfigModule *rm1 = a1->GetReconfigMod();
ReconfigModule *rm2 = a2->GetReconfigMod();
if (rm1->getTY() == rm2->getTY() && rm1->getLX() == rm2->getLX())
return true;
else
return false;
}
else // Non-storage nodes
return false;
/*if (a1->GetEndTS() != a2->GetEndTS())
return a1->GetEndTS() > a2->GetEndTS();
else if (a1->GetType() == STORAGE && a2->GetType() != STORAGE)
return false;
else
return true;*/
}
/////////////////////////////////////////////////////////////////
// Sorts reconfigurable modules by starting time-step, and then
// by ending time-step, from least to greatest
/////////////////////////////////////////////////////////////////
bool sReconfigModsByStartThenEndTS(ReconfigModule *r1, ReconfigModule *r2)
{
if (r1->getStartTS() == r2->getStartTS())
return (r1->getEndTS() < r2->getEndTS());
else
return (r1->getStartTS() < r2->getStartTS());
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts paths based on shared pin size...least to greatest.
///////////////////////////////////////////////////////////////////////////////////
bool sPathsBySharedPinSize(Path *p1, Path *p2)
{
return p1->sharedPinsSize() < p2->sharedPinsSize();
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts pin groups based on their average minimum distance to an edge of the DMFB.
///////////////////////////////////////////////////////////////////////////////////
bool sPinGroupsByAvgMinDistToEdge(vector<WireRouteNode *> *pg1, vector<WireRouteNode *> *pg2)
{
// Get arch and return if either group is empty
DmfbArch *a = NULL;
if (!pg1->empty() && !pg2->empty())
a = pg1->front()->arch;
else if (pg1->empty())
return true;
else
return false;
// Get edge extremes
int wgXMax = a->getWireRouter()->getModel()->getWireGridXSize()-1;
int wgYMax = a->getWireRouter()->getModel()->getWireGridYSize()-1;
// Compute Averages
double avg1 = 0;
for (unsigned i = 0; i < pg1->size(); i++)
{
WireRouteNode *p = pg1->at(i);
avg1 += min( min(p->wgX, p->wgY), min(wgXMax - p->wgX, wgYMax - p->wgY) );
}
avg1 = avg1 / (double)pg1->size();
double avg2 = 0;
for (unsigned i = 0; i < pg2->size(); i++)
{
WireRouteNode *p = pg2->at(i);
avg2 += min( min(p->wgX, p->wgY), min(wgXMax - p->wgX, wgYMax - p->wgY) );
}
avg2 = avg2 / (double)pg2->size();
// Output comparison
if (avg1 == avg2)
return pg1->front()->originalPinNum < pg2->front()->originalPinNum; // If same, order by pin number
return (avg1 < avg2); // Else, order by smallest distance first
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts pin groups based on their number of pins being shared. Least number of
// pins in a group is sorted toward the front.
///////////////////////////////////////////////////////////////////////////////////
bool sPinGroupsByPinGroupSize(vector<WireRouteNode *> *pg1, vector<WireRouteNode *> *pg2)
{
return pg1->size() < pg2->size();
}
///////////////////////////////////////////////////////////////////////////////////
// Sort pin groups based on their area (bounding box).
///////////////////////////////////////////////////////////////////////////////////
bool sPinGroupsByPinGroupArea(vector<WireRouteNode *> *pg1, vector<WireRouteNode *> *pg2)
{
// Get arch and return if either group is empty
DmfbArch *a = NULL;
if (!pg1->empty() && !pg2->empty())
a = pg1->front()->arch;
else if (pg1->empty())
return true;
else
return false;
// Get edge extremes
int wgXMax = a->getWireRouter()->getModel()->getWireGridXSize()-1;
int wgYMax = a->getWireRouter()->getModel()->getWireGridYSize()-1;
int xMin1 = -1;
int xMax1 = -1;
int yMin1 = -1;
int yMax1 = -1;
int xMin2 = -1;
int xMax2 = -1;
int yMin2 = -1;
int yMax2 = -1;
int area1 = -1;
int area2 = -1;
// Compute Averages and extreme points
double avg1 = 0;
for (unsigned i = 0; i < pg1->size(); i++)
{
WireRouteNode *p = pg1->at(i);
avg1 += min( min(p->wgX, p->wgY), min(wgXMax - p->wgX, wgYMax - p->wgY) );
if (xMin1 == -1 || p->wgX < xMin1)
xMin1 = p->wgX;
if (xMax1 == -1 || p->wgX > xMax1)
xMax1 = p->wgX;
if (yMin1 == -1 || p->wgY < yMin1)
yMin1 = p->wgX;
if (yMax1 == -1 || p->wgY > yMax1)
yMax1 = p->wgX;
}
avg1 = avg1 / (double)pg1->size();
area1 = (xMax1 - xMin1 + 1) * (yMax1 - yMin1 + 1);
double avg2 = 0;
for (unsigned i = 0; i < pg2->size(); i++)
{
WireRouteNode *p = pg2->at(i);
avg2 += min( min(p->wgX, p->wgY), min(wgXMax - p->wgX, wgYMax - p->wgY) );
if (xMin2 == -1 || p->wgX < xMin2)
xMin2 = p->wgX;
if (xMax2 == -1 || p->wgX > xMax2)
xMax2 = p->wgX;
if (yMin2 == -1 || p->wgY < yMin2)
yMin2 = p->wgX;
if (yMax2 == -1 || p->wgY > yMax2)
yMax2 = p->wgX;
}
avg2 = avg2 / (double)pg2->size();
area2 = (xMax2 - xMin2 + 1) * (yMax2 - yMin2 + 1);
// Output comparison
if (area1 == area2)
return (avg1 < avg2); // If same area, order by smallest distance first
else
return area1 < area2; // Do ones that take up least amount of space first
//if (avg1 == avg2)
// return pg1->front()->originalPinNum < pg2->front()->originalPinNum; // If same, order by pin number
//return (avg1 < avg2); // Else, order by smallest distance first
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts the fixed modules based on their location on the DMFB, from top to bottom.
// In event of tie (same height), choose one of left.
///////////////////////////////////////////////////////////////////////////////////
bool sFixedModulesFromTopToBottom(FixedModule *fm1, FixedModule *fm2)
{
if (fm1->getTY() == fm2->getTY())
return fm1->getLX() < fm2->getLX();
else
return fm1->getTY() < fm2->getTY();
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts the modules based on their location on the DMFB, from top to bottom.
// In event of tie (same height), choose one of left.
///////////////////////////////////////////////////////////////////////////////////
bool sModulesFromTopToBot(ReconfigModule *rm1, ReconfigModule *rm2)
{
if (rm1->getTY() == rm2->getTY())
return rm1->getLX() < rm2->getLX();
else
return rm1->getTY() < rm2->getTY();
}
bool sModulesFromBotToTop(ReconfigModule *rm1, ReconfigModule *rm2)
{
if (rm1->getTY() == rm2->getTY())
return rm1->getLX() < rm2->getLX();
else
return rm1->getTY() > rm2->getTY();
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts the ports by DMFB side and then position.
///////////////////////////////////////////////////////////////////////////////////
bool sPortsNtoSthenPos(IoPort *p1, IoPort *p2)
{
if (p1->getSide() == p2->getSide())
return p1->getPosXY() < p2->getPosXY();
else
return p1->getSide() < p2->getSide();
}
bool sPortsStoNthenPos(IoPort *p1, IoPort *p2)
{
if (p1->getSide() == p2->getSide())
return p1->getPosXY() < p2->getPosXY();
else
return p1->getSide() > p2->getSide();
}
///////////////////////////////////////////////////////////////////////////////////
// This function assumes an FPPC architecture is being used sorts nodes in
// decreasing routing distance from source. This is specifically designed for the
// FPPC2 (and it's a quick, non-comprehensive optimization), but shouldn't break
// on the original FPPC layout.
///////////////////////////////////////////////////////////////////////////////////
bool sFppcNodesInIncreasingRouteDistance(AssayNode *n1, AssayNode *n2)
{
// Get a reconfigurable module....
ReconfigModule *rm;
if (n1->GetReconfigMod())
rm = n1->GetReconfigMod();
else if (n2->GetReconfigMod())
rm = n2->GetReconfigMod();
else if (n1->GetChildren().at(0)->GetReconfigMod())
rm = n1->GetChildren().at(0)->GetReconfigMod();
else if (n2->GetChildren().at(0)->GetReconfigMod())
rm = n2->GetChildren().at(0)->GetReconfigMod();
else
claim(false, "Could not find a suitable module in sFppcNodesInDecreasingRouteDistance to compute the central routing column index.");
//...and then compute the central routing channel location
int crcIndex = 0; // central routing column index
if (rm->getResourceType() == SSD_RES)
crcIndex = rm->getLX() - 2;
else if (rm->getResourceType() == BASIC_RES)
crcIndex = rm->getRX() + 2;
else
claim(false, "Unknown module type in sFppcNodesInDecreasingRouteDistance.");
int d1 = 0;
int d2 = 0;
int x = 0;
int y = 0;
int ioPenalty = 500; // I/Os should be routed last, let things in modules be routed first
// Only looking at N/S...E/W for original FPPC not supported
if (n1->GetType() == DISPENSE)
{
AssayNode *c = n1->GetChildren().front();
if (n1->GetIoPort()->getSide() == NORTH || n1->GetIoPort()->getSide() == SOUTH)
x = n1->GetIoPort()->getPosXY();
d1 = abs(crcIndex-x) + ioPenalty;
}
else
{
rm = n1->GetReconfigMod();
AssayNode *c = n1->GetChildren().front();
ReconfigModule *crm = c->GetReconfigMod();
d1 = abs(crm->getBY());
}
if (n2->GetType() == DISPENSE)
{
AssayNode *c = n2->GetChildren().front();
if (n2->GetIoPort()->getSide() == NORTH || n2->GetIoPort()->getSide() == SOUTH)
x = n2->GetIoPort()->getPosXY();
d2 = abs(crcIndex-x) + ioPenalty;
}
else
{
rm = n2->GetReconfigMod();
AssayNode *c = n2->GetChildren().front();
ReconfigModule *crm = c->GetReconfigMod();
d2 = abs(crm->getBY());
}
return d1 < d2;
}
/////////////////////////////////////////////////////////////////
// Sorts Conditions by their internal order
/////////////////////////////////////////////////////////////////
bool sConditionsByOrder(Condition *c1, Condition *c2) { return (c1->order < c2->order); }
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Wrapper functions for sorts
/////////////////////////////////////////////////////////////////
void Sort::sortNodesByStartTS(list<AssayNode*>* l) { l->sort(sNodesByStartTS); }
void Sort::sortNodesByStartTS(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByStartTS); }
void Sort::sortNodesByStartTSThenStorageFirst(list<AssayNode*>* l) { l->sort(sNodesByStartTSThenStorageFirst); }
void Sort::sortNodesByStartTSThenStorageFirst(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByStartTSThenStorageFirst); }
void Sort::sortNodesByPriorityHiFirst(list<AssayNode*>* l) { l->sort(sNodesByPriorityHiFirst); }
void Sort::sortNodesByPriorityHiFirst(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByPriorityHiFirst); }
void Sort::sortNodesByPriorityLoFirst(list<AssayNode*>* l) { l->sort(sNodesByPriorityLoFirst); }
void Sort::sortNodesByPriorityLoFirst(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByPriorityLoFirst); }
void Sort::sortNodesByLimitedResources(list<AssayNode*>* l) { l->sort(sNodesByLimitedResources); }
void Sort::sortNodesByLimitedResources(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByLimitedResources); }
void Sort::sortNodesById(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesById); }
void Sort::sortNodesByModuleThenStartTS(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByModuleThenStartTS); }
void Sort::sortNodesByStartThenEndTS(vector<AssayNode *>* v) { sort(v->begin(), v->end(), sNodesByStartThenEndTS); }
void Sort::sortNodesByLatestTSThenStorage(vector<AssayNode *> *v) { sort(v->begin(), v->end(), sNodesByLatestTSThenStorage); }
void Sort::sortNodesByLatestTSAndStorage(vector<AssayNode *> *v) { sort(v->begin(), v->end(), sNodesByLatestTSAndStorage); }
void Sort::sortPathNodesByStartTS(list<AssayPathNode*>* l) { l->sort(sPathNodesByStartTS); }
void Sort::sortNodesByLength(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByLength); }
void Sort::sortReconfigModsByStartThenEndTS(vector<ReconfigModule *>* v) { sort(v->begin(), v->end(), sReconfigModsByStartThenEndTS); }
void Sort::sortPathsBySharedPinSize(vector<Path *> *v) { sort(v->begin(), v->end(), sPathsBySharedPinSize); }
void Sort::sortPinGroupsByAvgMinDistToEdge(vector<vector<WireRouteNode*>* > *v) { sort(v->begin(), v->end(), sPinGroupsByAvgMinDistToEdge); }
void Sort::sortPinGroupsByPinGroupSize(vector<vector<WireRouteNode*>* > *v) { sort(v->begin(), v->end(), sPinGroupsByPinGroupSize); }
void Sort::sortPinGroupsByPinGroupArea(vector<vector<WireRouteNode*>* > *v) { sort(v->begin(), v->end(), sPinGroupsByPinGroupArea); }
void Sort::sortFixedModulesFromTopToBottom(vector<FixedModule*> *v) { sort(v->begin(), v->end(), sFixedModulesFromTopToBottom); }
void Sort::sortPortsNtoSthenPos(vector<IoPort *> *v) { sort(v->begin(), v->end(), sPortsNtoSthenPos); }
void Sort::sortPortsStoNthenPos(vector<IoPort *> *v) { sort(v->begin(), v->end(), sPortsStoNthenPos); }
void Sort::sortModulesFromTopToBot(vector<ReconfigModule *> *v) { sort(v->begin(), v->end(), sModulesFromTopToBot); }
void Sort::sortModulesFromBotToTop(vector<ReconfigModule *> *v) { sort(v->begin(), v->end(), sModulesFromTopToBot); }
void Sort::sortFppcNodesInIncreasingRouteDistance(vector<AssayNode *> *v) { sort(v->begin(), v->end(), sFppcNodesInIncreasingRouteDistance); }
void Sort::sortConditionsByOrder(vector<Condition*>* v) { sort(v->begin(), v->end(), sConditionsByOrder); }
void Sort::sortRoutesByLength(vector<vector<RoutePoint *> *> * v, vector<Droplet *> *vd)
{
map<vector<RoutePoint *> *, Droplet *> link;
for (unsigned i = 0; i < v->size(); i++)
link[v->at(i)] = vd->at(i);
sort(v->begin(), v->end(), sRoutesByLength);
vd->clear();
for (unsigned i = 0; i < v->size(); i++)
vd->push_back(link[v->at(i)]);
}
void Sort::sortPopBySchedTimes(vector< map<AssayNode*, unsigned> *> *pop, vector<unsigned> * times)
{
map<unsigned *, map<AssayNode*, unsigned> *> link;
for (unsigned i = 0; i < pop->size(); i++)
link[&(times->at(i))] = pop->at(i);
for (unsigned i = 0; i < times->size(); i++)
cout << times->at(i) << "(" << pop->at(i) << ")-";
cout << endl;
sort(times->begin(), times->end());
pop->clear();
for (unsigned i = 0; i < times->size(); i++)
pop->push_back(link[&(times->at(i))]);
for (unsigned i = 0; i < times->size(); i++)
cout << times->at(i) << "(" << pop->at(i) << ")-";
cout << endl;
exit(1);
}
///////////////////////////////////////////////////////////////////////////////////////
// Sorts routingThisTS in decreasing order, based on the manhattan distance between
// the corresponding source and target cells.
///////////////////////////////////////////////////////////////////////////////////////
void Sort::sortDropletsInDecManhattanDist(vector<Droplet *> *routingThisTS, map<Droplet *, SoukupCell *> *sourceCells, map<Droplet *, SoukupCell *> *targetCells)
{
vector<int *> distances;
map<int *, Droplet *> link;
for (unsigned i = 0; i < routingThisTS->size(); i++)
{
SoukupCell *s = sourceCells->at(routingThisTS->at(i));
SoukupCell *t = targetCells->at(routingThisTS->at(i));
int *manhattanDist = new int();
*manhattanDist = abs(s->x - t->x) + abs(s->y - t->y);
distances.push_back(manhattanDist);
link[manhattanDist] = routingThisTS->at(i);
}
//for (int i = 0; i < routingThisTS->size(); i++)
// cout << "D" << routingThisTS->at(i)->getId() << ": " << *distances.at(i) << endl;
sort(distances.begin(), distances.end(), sDecreasingInts);
routingThisTS->clear();
for (unsigned i = 0; i < distances.size(); i++)
routingThisTS->push_back(link[distances.at(i)]);
//for (int i = 0; i < routingThisTS->size(); i++)
// cout << "D" << routingThisTS->at(i)->getId() << ": " << *distances.at(i) << endl;
while (!distances.empty())
{
int *i = distances.back();
distances.pop_back();
delete i;
}
}
| 40.048359
| 161
| 0.522684
|
AryaFaramarzi
|
de881f7d037ca8a76ffc7fc942e14eab26df3e32
| 1,996
|
hpp
|
C++
|
src/backend/vm/value_type.hpp
|
korelang/kore
|
9fc06176406c2de2524382dff7e0d7d8e619c457
|
[
"BSD-3-Clause"
] | null | null | null |
src/backend/vm/value_type.hpp
|
korelang/kore
|
9fc06176406c2de2524382dff7e0d7d8e619c457
|
[
"BSD-3-Clause"
] | null | null | null |
src/backend/vm/value_type.hpp
|
korelang/kore
|
9fc06176406c2de2524382dff7e0d7d8e619c457
|
[
"BSD-3-Clause"
] | null | null | null |
#ifndef KORE_VALUE_TYPE_HPP
#define KORE_VALUE_TYPE_HPP
#include <ostream>
#include "frontend/internal_value_types.hpp"
namespace kore {
enum class ValueTag {
Bool,
I32,
I64,
F32,
F64,
Str,
};
/// The types for the vm's runtime values implemented
/// as a tagged union
struct Value {
ValueTag tag;
union _Value {
bool _bool;
i32 _i32;
i64 _i64;
f32 _f32;
f64 _f64;
} value;
inline bool as_bool() {
#if KORE_VM_DEBUG
if (tag != ValueTag::Bool) {
throw std::runtime_error("Not a boolean value");
}
#endif
return value._bool;
}
inline i32 as_i32() {
#if KORE_VM_DEBUG
if (tag != ValueTag::I32) {
throw std::runtime_error("Not an i32 value");
}
#endif
return value._i32;
}
inline i64 as_i64() {
#if KORE_VM_DEBUG
if (tag != ValueTag::I64) {
throw std::runtime_error("Not an i64 value");
}
#endif
return value._i64;
}
inline f32 as_f32() {
#if KORE_VM_DEBUG
if (tag != ValueTag::f32) {
throw std::runtime_error("Not an f32 value");
}
#endif
return value._f32;
}
inline f64 as_f64() {
#if KORE_VM_DEBUG
if (tag != ValueTag::f64) {
throw std::runtime_error("Not an f64 value");
}
#endif
return value._f64;
}
};
Value from_bool(bool value);
Value from_i32(i32 value);
Value from_i64(i64 value);
Value from_f32(f32 value);
Value from_f64(f64 value);
std::ostream& operator<<(std::ostream& out, const Value& value);
}
#endif // KORE_VALUE_TYPE_HPP
| 21.695652
| 68
| 0.483467
|
korelang
|
de88adce28026525092d49cd981443c7d9361375
| 3,707
|
cpp
|
C++
|
printscan/faxsrv/service/rpc/configtest/outboxdlg.cpp
|
npocmaka/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 17
|
2020-11-13T13:42:52.000Z
|
2021-09-16T09:13:13.000Z
|
printscan/faxsrv/service/rpc/configtest/outboxdlg.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 2
|
2020-10-19T08:02:06.000Z
|
2020-10-19T08:23:18.000Z
|
printscan/faxsrv/service/rpc/configtest/outboxdlg.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 14
|
2020-11-14T09:43:20.000Z
|
2021-08-28T08:59:57.000Z
|
// OutboxDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ConfigTest.h"
#include "OutboxDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
typedef unsigned long ULONG_PTR, *PULONG_PTR;
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
#include "..\..\..\inc\fxsapip.h"
/////////////////////////////////////////////////////////////////////////////
// COutboxDlg dialog
COutboxDlg::COutboxDlg(HANDLE hFax, CWnd* pParent /*=NULL*/)
: CDialog(COutboxDlg::IDD, pParent), m_hFax (hFax)
{
//{{AFX_DATA_INIT(COutboxDlg)
m_bBranding = FALSE;
m_dwAgeLimit = 0;
m_dwEndHour = 0;
m_dwEndMinute = 0;
m_bPersonalCP = FALSE;
m_dwRetries = 0;
m_dwRetryDelay = 0;
m_dwStartHour = 0;
m_dwStartMinute = 0;
m_bUseDeviceTsid = FALSE;
//}}AFX_DATA_INIT
}
void COutboxDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COutboxDlg)
DDX_Check(pDX, IDC_BRANDING, m_bBranding);
DDX_Text(pDX, IDC_AGELIMIT, m_dwAgeLimit);
DDX_Text(pDX, IDC_ENDH, m_dwEndHour);
DDV_MinMaxUInt(pDX, m_dwEndHour, 0, 23);
DDX_Text(pDX, IDC_ENDM, m_dwEndMinute);
DDV_MinMaxUInt(pDX, m_dwEndMinute, 0, 59);
DDX_Check(pDX, IDC_PERSONALCP, m_bPersonalCP);
DDX_Text(pDX, IDC_RETRIES, m_dwRetries);
DDX_Text(pDX, IDC_RETRYDELAY, m_dwRetryDelay);
DDX_Text(pDX, IDC_STARTH, m_dwStartHour);
DDV_MinMaxUInt(pDX, m_dwStartHour, 0, 23);
DDX_Text(pDX, IDC_STARTM, m_dwStartMinute);
DDV_MinMaxUInt(pDX, m_dwStartMinute, 0, 59);
DDX_Check(pDX, IDC_USERDEVICETSID, m_bUseDeviceTsid);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COutboxDlg, CDialog)
//{{AFX_MSG_MAP(COutboxDlg)
ON_BN_CLICKED(IDC_READ, OnRead)
ON_BN_CLICKED(IDC_WRITE, OnWrite)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutboxDlg message handlers
void COutboxDlg::OnRead()
{
PFAX_OUTBOX_CONFIG pCfg;
if (!FaxGetOutboxConfiguration (m_hFax, &pCfg))
{
CString cs;
cs.Format ("Failed while calling FaxGetOutboxConfiguration (%ld)", GetLastError());
AfxMessageBox (cs, MB_OK | MB_ICONHAND);
return;
}
m_bPersonalCP = pCfg->bAllowPersonalCP;
m_bUseDeviceTsid = pCfg->bUseDeviceTSID;
m_dwRetries = pCfg->dwRetries;
m_dwRetryDelay = pCfg->dwRetryDelay;
m_dwStartHour = pCfg->dtDiscountStart.Hour;
m_dwStartMinute = pCfg->dtDiscountStart.Minute;
m_dwEndHour = pCfg->dtDiscountEnd.Hour;
m_dwEndMinute = pCfg->dtDiscountEnd.Minute;
m_dwAgeLimit = pCfg->dwAgeLimit;
m_bBranding = pCfg->bBranding;
UpdateData (FALSE);
FaxFreeBuffer (LPVOID(pCfg));
}
void COutboxDlg::OnWrite()
{
UpdateData ();
FAX_OUTBOX_CONFIG cfg;
cfg.dwSizeOfStruct = sizeof (FAX_OUTBOX_CONFIG);
cfg.bAllowPersonalCP = m_bPersonalCP;
cfg.bUseDeviceTSID = m_bUseDeviceTsid;
cfg.dwRetries = m_dwRetries;
cfg.dwRetryDelay = m_dwRetryDelay;
cfg.dtDiscountStart.Hour = m_dwStartHour;
cfg.dtDiscountStart.Minute = m_dwStartMinute;
cfg.dtDiscountEnd.Hour = m_dwEndHour;
cfg.dtDiscountEnd.Minute = m_dwEndMinute;
cfg.dwAgeLimit = m_dwAgeLimit;
cfg.bBranding = m_bBranding;
if (!FaxSetOutboxConfiguration (m_hFax, &cfg))
{
CString cs;
cs.Format ("Failed while calling FaxSetOutboxConfiguration (%ld)", GetLastError());
AfxMessageBox (cs, MB_OK | MB_ICONHAND);
return;
}
}
| 30.891667
| 92
| 0.639601
|
npocmaka
|
de8b7b339304acb3c0cc2938b1ed2a592a83c50b
| 1,010
|
cpp
|
C++
|
HackerBlocks/Recursion and Backtracking/RatInAMaze/main.cpp
|
Ashwanigupta9125/code-DS-ALGO
|
49f6cf7d0c682da669db23619aef3f80697b352b
|
[
"MIT"
] | 36
|
2019-12-27T08:23:08.000Z
|
2022-01-24T20:35:47.000Z
|
HackerBlocks/Recursion and Backtracking/RatInAMaze/main.cpp
|
Ashwanigupta9125/code-DS-ALGO
|
49f6cf7d0c682da669db23619aef3f80697b352b
|
[
"MIT"
] | 10
|
2019-11-13T02:55:18.000Z
|
2021-10-13T23:28:09.000Z
|
HackerBlocks/Recursion and Backtracking/RatInAMaze/main.cpp
|
Ashwanigupta9125/code-DS-ALGO
|
49f6cf7d0c682da669db23619aef3f80697b352b
|
[
"MIT"
] | 53
|
2020-08-15T11:08:40.000Z
|
2021-10-09T15:51:38.000Z
|
#include <bits/stdc++.h>
using namespace std;
bool ratInAMaze(char maze[1001][1001],bool path[1001][1001], int n, int m,int i, int j){
if(i==n-1 && j==m-1){
path[i][j]=1;
return true;
}
if(maze[i][j]=='X')
return false;
if(i>=n || j>=m){
return false;
}
path[i][j]=1;
bool rightsucess = ratInAMaze(maze,path,n,m,i,j+1);
if(!rightsucess){
bool downsucess = ratInAMaze(maze,path,n,m,i+1,j);
if(!downsucess){
path[i][j]=0;
return false;
}
}
return true;
}
int main() {
int n,m;
cin>>n>>m;
char maze[1001][1001];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>maze[i][j];
}
}
bool path[1001][1001]={0};
bool sucess = ratInAMaze(maze,path,n,m,0,0);
if(sucess){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<path[i][j]<<" ";
}
cout<<endl;
}
}
else
cout<<-1;
return 0;
}
| 18.035714
| 88
| 0.464356
|
Ashwanigupta9125
|
de8c886e2035c324bea7a1866f17e9a904d69b14
| 1,252
|
cpp
|
C++
|
Sources/Plugins/RenderSystem_GL/GLSLShaderSystem.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
Sources/Plugins/RenderSystem_GL/GLSLShaderSystem.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
Sources/Plugins/RenderSystem_GL/GLSLShaderSystem.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
/*=============================================================================
GLSLShaderSystem.cpp
Project: Sonata Engine
Author: Julien Delezenne
=============================================================================*/
#include "GLSLShaderSystem.h"
#include "GLSLShaderProgram.h"
namespace SE_GL
{
GLSLShaderSystem::GLSLShaderSystem() :
ShaderSystem()
{
}
GLSLShaderSystem::~GLSLShaderSystem()
{
}
bool GLSLShaderSystem::Create()
{
return true;
}
void GLSLShaderSystem::Destroy()
{
}
void GLSLShaderSystem::Update(real64 elapsed)
{
}
ShaderProgram* GLSLShaderSystem::CreateShaderProgram(ShaderProgramType type)
{
ShaderProgram* program;
if (type == ShaderProgramType_Vertex)
{
program = new GLSLVertexShaderProgram(this);
}
else if (type == ShaderProgramType_Pixel)
{
program = new GLSLPixelShaderProgram(this);
}
else
{
return NULL;
}
return program;
}
void GLSLShaderSystem::DestroyShaderProgram(ShaderProgram* program)
{
if (program == NULL)
return;
delete program;
}
bool GLSLShaderSystem::SetShaderProgram(ShaderProgram* program)
{
if (program == NULL)
return false;
return program->Bind();
}
bool GLSLShaderSystem::DisableShaderProgram(ShaderProgram* program)
{
return program->Unbind();
}
}
| 16.25974
| 79
| 0.654952
|
jdelezenne
|
de8e04438ca08bec9df7cb3a061fa0504539a8dc
| 166
|
hxx
|
C++
|
src/Providers/UNIXProviders/PolicyRepositoryInPolicyRepository/UNIX_PolicyRepositoryInPolicyRepository_FREEBSD.hxx
|
brunolauze/openpegasus-providers-old
|
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
|
[
"MIT"
] | 1
|
2020-10-12T09:00:09.000Z
|
2020-10-12T09:00:09.000Z
|
src/Providers/UNIXProviders/PolicyRepositoryInPolicyRepository/UNIX_PolicyRepositoryInPolicyRepository_FREEBSD.hxx
|
brunolauze/openpegasus-providers-old
|
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
|
[
"MIT"
] | null | null | null |
src/Providers/UNIXProviders/PolicyRepositoryInPolicyRepository/UNIX_PolicyRepositoryInPolicyRepository_FREEBSD.hxx
|
brunolauze/openpegasus-providers-old
|
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
|
[
"MIT"
] | null | null | null |
#ifdef PEGASUS_OS_FREEBSD
#ifndef __UNIX_POLICYREPOSITORYINPOLICYREPOSITORY_PRIVATE_H
#define __UNIX_POLICYREPOSITORYINPOLICYREPOSITORY_PRIVATE_H
#endif
#endif
| 13.833333
| 59
| 0.885542
|
brunolauze
|
de8eef4f62e1f6780b1848fb0668b12182336276
| 2,211
|
hpp
|
C++
|
source/LibFgBase/src/FgPlatform.hpp
|
denim2x/FaceGenBaseLibrary
|
52317cf96984a47d7f2d0c5471230d689404101c
|
[
"MIT"
] | null | null | null |
source/LibFgBase/src/FgPlatform.hpp
|
denim2x/FaceGenBaseLibrary
|
52317cf96984a47d7f2d0c5471230d689404101c
|
[
"MIT"
] | null | null | null |
source/LibFgBase/src/FgPlatform.hpp
|
denim2x/FaceGenBaseLibrary
|
52317cf96984a47d7f2d0c5471230d689404101c
|
[
"MIT"
] | null | null | null |
//
// Copyright (c) 2019 Singular Inversions Inc. (facegen.com)
// Use, modification and distribution is subject to the MIT License,
// see accompanying file LICENSE.txt or facegen.com/base_library_license.txt
//
// Compile target platform and compiler specific definitions.
//
// ANSI defines:
// _DATE_
// _FILE_
// _LINE_
// _TIMESTAMP_
// NDEBUG Controls expression of ANSI 'assert'.
//
// MSVC defines:
// _WIN32 Compiling for windows (32 or 64 bit)
// _WIN64 Targeting 64-bit ISA
// _DEBUG Defined automatically by MSVC (/MTd or /MDd). We define for gcc/clang.
// _MSC_VER :
// 1800 : VS2013 12.0
// 1900 : VS2015 14.0
// 1910-1916 : VS2017 14.1
// 1920-1923 : VS2019 16
// _M_AMD64 Targeting Intel/AMD 64-bit ISA
// gcc,clang,icpc defines:
// __GNUC__ Compiler is gcc, clang or icpc
// __clang__ clang compiler
// __INTEL_COMPILER Intel's icc and icpc compilers
// _LP64 LP64 paradigm
// __x86_64__ Intel/AMD 64 bit ISA
// __ppc64__ PowerPC 64 bit ISA
// __APPLE__ Defined on all apple platform compilers (along with __MACH__)
// __ANDROID__
//
#ifndef FGPLATFORM_HPP
#define FGPLATFORM_HPP
#include "FgStdLibs.hpp"
// FaceGen defines:
// FG_64 Targeting 64-bit ISA (there is no cross-compiler standard for this)
#ifdef _WIN64
#define FG_64
#elif __x86_64__
#define FG_64
#endif
// FG_SANDBOX Targeting a sandboxed platform (eg. Android, iOS, WebAssembly). No system() calls etc.
#ifdef __ANDROID__
#define FG_SANDBOX
#endif
#if defined(__APPLE__) && defined(ENABLE_BITCODE)
// Including "TargetConditionals.h" and testing TARGET_OS_IPHONE does not work because this file
// is in sysroot/usr/include/ which doesn't compile with C++ (C only):
#define FG_SANDBOX
#endif
namespace Fg {
// Is current binary 64 bit (avoid 'conditional expression is constant') ?
bool
fgIs64bit();
// As above
bool
fgIsDebug();
// Returns "32 if the current executable is 32-bit, "64" if 64-bit.
std::string
fgBitsString();
}
#endif
| 28.346154
| 107
| 0.645862
|
denim2x
|
de91c2e73247de3d5093113de661c21b50f7cb2f
| 3,937
|
cpp
|
C++
|
core/sql/common/ComExtents.cpp
|
CoderSong2015/Apache-Trafodion
|
889631aae9cdcd38fca92418d633f2dedc0be619
|
[
"Apache-2.0"
] | 148
|
2015-06-18T21:26:04.000Z
|
2017-12-25T01:47:01.000Z
|
core/sql/common/ComExtents.cpp
|
CoderSong2015/Apache-Trafodion
|
889631aae9cdcd38fca92418d633f2dedc0be619
|
[
"Apache-2.0"
] | 1,352
|
2015-06-20T03:05:01.000Z
|
2017-12-25T14:13:18.000Z
|
core/sql/common/ComExtents.cpp
|
CoderSong2015/Apache-Trafodion
|
889631aae9cdcd38fca92418d633f2dedc0be619
|
[
"Apache-2.0"
] | 166
|
2015-06-19T18:52:10.000Z
|
2017-12-27T06:19:32.000Z
|
/* -*-C++-*-
*****************************************************************************
*
* File: ComExtents.C
* Description: Provides conversion functions to convert Maxsize and Allocate
* attributes to primary-extents, secondary-extents and max-extents
*
* Created: 11/28/94
* Language: C++
*
*
// @@@ START COPYRIGHT @@@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.
//
// @@@ END COPYRIGHT @@@
*
*
*****************************************************************************
*/
#include "ComExtents.h"
#include "Int64.h"
#include "ComASSERT.h"
ComExtents::ComExtents (Int64 maxSize,
ComUnits units)
: maxSize_(maxSize)
, units_(units)
{
// ---------------------------------------------------------------------
// Calculate the extent size:
//
// maxFileSize = MAX(maxSizeInBytes, 20MB)
//
// maxFileSize = MIN(maxFileSize, 2gbytes) -- make sure this size
// does not go over 2gbytes (largest supported by NSK)
//
// Extent sizes are no longer calculated because DP2 decides on
// the extent sizes to use.
// ---------------------------------------------------------------------
const Int64 maxSizeInBytes = getSizeInBytes ( maxSize_
, units_
);
Int64 maxFileSize = maxSizeInBytes;
// If maxSize_ is too small, set it to the minimum allowed (in bytes).
if (maxFileSize < COM_MIN_PART_SIZE_IN_BYTES)
{
maxSize_ = COM_MIN_PART_SIZE_IN_BYTES;
units_ = COM_BYTES;
}
// If maxSize_ is too large, set it to the maximum allowed (in bytes).
else if (maxFileSize > COM_MAX_PART_SIZE_IN_BYTES)
{
maxSize_ = COM_MAX_PART_SIZE_IN_BYTES;
units_ = COM_BYTES;
}
// If maxSize_ is within the allowed range, leave it and units_ unchanged.
};
ComExtents::ComExtents (Int64 maxSize)
: maxSize_(maxSize)
{
// Since units_ was unspecified, maxSize is bytes.
units_ = COM_BYTES;
// If maxSize_ is too small, set it to the minimum allowed.
if (maxSize < COM_MIN_PART_SIZE_IN_BYTES)
maxSize_ = COM_MIN_PART_SIZE_IN_BYTES;
// If maxSize_ is too large, set it to the maximum allowed.
else if (maxSize > COM_MAX_PART_SIZE_IN_BYTES)
maxSize_ = COM_MAX_PART_SIZE_IN_BYTES;
};
// -----------------------------------------------------------------------
// getSizeInBytes:
//
// This function calculates the size of the input parameter in bytes
// -----------------------------------------------------------------------
Int64 ComExtents::getSizeInBytes ( Int64 sizeToConvert
, ComUnits units
)
{
Int64 convertedSize = 0;
switch (units)
{
case COM_BYTES:
convertedSize = (sizeToConvert);
break;
case COM_KBYTES:
convertedSize = (sizeToConvert * 1024);
break;
case COM_MBYTES:
convertedSize = (sizeToConvert * 1024 * 1024);
break;
case COM_GBYTES:
convertedSize = (sizeToConvert * (1024 * 1024 * 1024));
break;
default:
ComASSERT( FALSE ); // raise an exception
break;
};
return convertedSize;
};
| 31.496
| 81
| 0.583947
|
CoderSong2015
|
de93720a3eeb3d97501c06306f636429ddda6bfa
| 1,743
|
cpp
|
C++
|
utils/logging.cpp
|
XMrVertigoX/xXx_CPP
|
550f04ccb2ff772e5c8cd632c9a748a001533077
|
[
"MIT"
] | null | null | null |
utils/logging.cpp
|
XMrVertigoX/xXx_CPP
|
550f04ccb2ff772e5c8cd632c9a748a001533077
|
[
"MIT"
] | null | null | null |
utils/logging.cpp
|
XMrVertigoX/xXx_CPP
|
550f04ccb2ff772e5c8cd632c9a748a001533077
|
[
"MIT"
] | null | null | null |
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <FreeRTOS.h>
#include <task.h>
#include "logging.hpp"
static const size_t bytesPerLine = 16;
static inline uint32_t ticks2ms(TickType_t ticks) {
return (ticks * portTICK_PERIOD_MS);
}
static inline uint32_t getSeconds(TickType_t ticks) {
return (ticks2ms(ticks) / 1000);
}
static inline uint32_t getMilliseconds(TickType_t ticks) {
return (ticks2ms(ticks) % 1000);
}
static inline void printTime() {
TickType_t ticks = xTaskGetTickCount();
uint32_t seconds = getSeconds(ticks);
uint32_t milliseconds = getMilliseconds(ticks);
printf("[%5lu.%03lu] ", seconds, milliseconds);
}
namespace xXx {
void hexdump(const void *bytes, size_t numBytes) {
for (size_t i = 0; i < numBytes; i += bytesPerLine) {
printf("0x%08x:", i);
for (size_t j = i; j < (i + bytesPerLine); j++) {
char c;
if (j < numBytes) {
c = static_cast<const char *>(bytes)[j];
printf(" %02x", c);
} else {
printf(" ");
}
}
putchar(' ');
for (size_t j = i; j < (i + bytesPerLine); j++) {
char c;
if (j < numBytes) {
c = static_cast<const char *>(bytes)[j];
if (not isprint(c)) {
c = '.';
}
} else {
c = ' ';
}
putchar(c);
}
putchar('\n');
}
}
void log(const char *format, ...) {
printTime();
va_list arguments;
va_start(arguments, format);
vprintf(format, arguments);
va_end(arguments);
}
} /* namespace xXx */
| 21.256098
| 58
| 0.526104
|
XMrVertigoX
|
de93d083a1eae37fafb327e120403acd2775ec90
| 2,004
|
cpp
|
C++
|
blast/src/dbapi/err_handler.cpp
|
mycolab/ncbi-blast
|
e59746cec78044d2bf6d65de644717c42f80b098
|
[
"Apache-2.0"
] | 31
|
2016-12-09T04:56:59.000Z
|
2021-12-31T17:19:10.000Z
|
blast/src/dbapi/err_handler.cpp
|
mycolab/ncbi-blast
|
e59746cec78044d2bf6d65de644717c42f80b098
|
[
"Apache-2.0"
] | 6
|
2017-03-10T17:25:13.000Z
|
2021-09-22T15:49:49.000Z
|
blast/src/dbapi/err_handler.cpp
|
mycolab/ncbi-blast
|
e59746cec78044d2bf6d65de644717c42f80b098
|
[
"Apache-2.0"
] | 20
|
2015-01-04T02:15:17.000Z
|
2021-12-03T02:31:43.000Z
|
/* $Id: err_handler.cpp 343796 2011-11-09 18:12:57Z ivanovp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* File Name: $Id: err_handler.cpp 343796 2011-11-09 18:12:57Z ivanovp $
*
* Author: Michael Kholodov
*
* File Description: DataSource implementation
*/
#include <ncbi_pch.hpp>
#include "err_handler.hpp"
BEGIN_NCBI_SCOPE
CToMultiExHandler::CToMultiExHandler()
: m_ex( new CDB_MultiEx( DIAG_COMPILE_INFO, 0 ) )
{
}
CToMultiExHandler::~CToMultiExHandler()
{
}
bool CToMultiExHandler::HandleIt(CDB_Exception* ex)
{
m_ex->Push(*ex);
_TRACE("CToMultiExHandler::HandleIt(): exception received");
return true;
}
bool CToMultiExHandler::HandleAll(const TExceptions& exceptions)
{
ITERATE(TExceptions, it, exceptions) {
m_ex->Push(**it);
}
return true;
}
END_NCBI_SCOPE
| 31.3125
| 77
| 0.673154
|
mycolab
|
de98e12d8bc29f2ed4f60ea0119381148c43614b
| 2,249
|
cpp
|
C++
|
libi3/get_colorpixel.cpp
|
andreatulimiero/i3pp
|
3e1268ec690bce1821d47df11a985145c289573c
|
[
"BSD-3-Clause"
] | null | null | null |
libi3/get_colorpixel.cpp
|
andreatulimiero/i3pp
|
3e1268ec690bce1821d47df11a985145c289573c
|
[
"BSD-3-Clause"
] | null | null | null |
libi3/get_colorpixel.cpp
|
andreatulimiero/i3pp
|
3e1268ec690bce1821d47df11a985145c289573c
|
[
"BSD-3-Clause"
] | null | null | null |
/*
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
* © 2009 Michael Stapelberg and contributors (see also: LICENSE)
*
*/
#include "libi3.hpp"
#include "queue.hpp"
#include "memory.hpp"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
struct Colorpixel {
char hex[8];
uint32_t pixel;
SLIST_ENTRY(Colorpixel) colorpixels;
};
SLIST_HEAD(colorpixel_head, Colorpixel) colorpixels;
/*
* Returns the colorpixel to use for the given hex color (think of HTML).
*
* The hex_color has to start with #, for example #FF00FF.
*
* NOTE that get_colorpixel() does _NOT_ check the given color code for validity.
* This has to be done by the caller.
*
*/
uint32_t get_colorpixel(const char *hex) {
char strgroups[3][3] = {
{hex[1], hex[2], '\0'},
{hex[3], hex[4], '\0'},
{hex[5], hex[6], '\0'}};
uint8_t r = strtol(strgroups[0], NULL, 16);
uint8_t g = strtol(strgroups[1], NULL, 16);
uint8_t b = strtol(strgroups[2], NULL, 16);
/* Shortcut: if our screen is true color, no need to do a roundtrip to X11 */
if (root_screen == NULL || root_screen->root_depth == 24 || root_screen->root_depth == 32) {
return (0xFFUL << 24) | (r << 16 | g << 8 | b);
}
/* Lookup this colorpixel in the cache */
struct Colorpixel *colorpixel;
SLIST_FOREACH (colorpixel, &(colorpixels), colorpixels) {
if (strcmp(colorpixel->hex, hex) == 0)
return colorpixel->pixel;
}
#define RGB_8_TO_16(i) (65535 * ((i)&0xFF) / 255)
int r16 = RGB_8_TO_16(r);
int g16 = RGB_8_TO_16(g);
int b16 = RGB_8_TO_16(b);
xcb_alloc_color_reply_t *reply;
reply = xcb_alloc_color_reply(conn, xcb_alloc_color(conn, root_screen->default_colormap, r16, g16, b16),
NULL);
if (!reply) {
LOG("Could not allocate color\n");
exit(1);
}
uint32_t pixel = reply->pixel;
free(reply);
/* Store the result in the cache */
auto cache_pixel = create_struct<Colorpixel>();
strncpy(cache_pixel->hex, hex, 7);
cache_pixel->hex[7] = '\0';
cache_pixel->pixel = pixel;
SLIST_INSERT_HEAD(&(colorpixels), cache_pixel, colorpixels);
return pixel;
}
| 26.77381
| 108
| 0.623833
|
andreatulimiero
|
de9e74434fd6c5d27832ea6734411238fe56fa67
| 3,741
|
cpp
|
C++
|
src/lib/adatafield.cpp
|
leaderit/ananas-qt4
|
6830bf5074b316582a38f6bed147a1186dd7cc95
|
[
"MIT"
] | 1
|
2021-03-16T21:47:41.000Z
|
2021-03-16T21:47:41.000Z
|
src/lib/adatafield.cpp
|
leaderit/ananas-qt4
|
6830bf5074b316582a38f6bed147a1186dd7cc95
|
[
"MIT"
] | null | null | null |
src/lib/adatafield.cpp
|
leaderit/ananas-qt4
|
6830bf5074b316582a38f6bed147a1186dd7cc95
|
[
"MIT"
] | null | null | null |
/****************************************************************************
** $Id: adatafield.cpp,v 1.1 2008/11/05 21:16:28 leader Exp $
**
** Code file of the Ananas database field of Ananas
** Designer and Engine applications
**
** Created : 20031201
**
** Copyright (C) 2003-2004 Leader InfoTech. All rights reserved.
**
** This file is part of the Library of the Ananas
** automation accounting system.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru
** See http://www.leaderit.ru/gpl/ for GPL licensing information.
**
** Contact org@leaderit.ru if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
//#include <qobject.h>
//#include "acfg.h"
#include "adatafield.h"
/*!
Create Ananas database field contaner.
*/
/*
aDataField::aDataField(aCfg *newmd, aCfgItem newcontext )
:QObject( 0, "aField" ) // name )
{
md = newmd;
context = newcontext;
// fType = type;
fTName = "";
// field = new QSqlField( fTName );
fSys = false;
}
*/
/*!
* Create Ananas field contaner.
*/
aDataField::aDataField( QObject *parent, const QString &name, const QString &type )
:QObject( parent, "aField" )
{
init( name, type );
}
/*!
* Create Ananas field contaner.
*/
aDataField::aDataField(const QString &name, const QString &type )
:QObject( 0, "aField" )
{
init( name, type );
}
aDataField::aDataField( const aDataField &field )
:QObject( 0, "aField" )
{
init( field.fieldName(), field.fType );
}
/*!
* Destroy object.
*/
aDataField::~aDataField()
{
// delete field;
}
aDataField&
aDataField::operator=( const aDataField& other )
{
Type = other.Type;
context = other.context;
id = other.id;;
md = other.md;
fSys = other.fSys;
Width = other.Width;
Dec = other.Dec;
Name = other.Name;
fType = other.fType;
aType = other.aType;
fieldData = other.fieldData;
return *this;
}
bool
aDataField::operator==( const aDataField& other ) const
{
return (
fSys == other.fSys &&
Name == other.Name &&
fType == other.fType &&
id == other.id &&
context == other.context
);
}
bool
aDataField::operator!=( const aDataField& other ) const
{
return !( other == *this );
}
void
aDataField::init( const QString &name, const QString &type )
{
QString t;
fSys = true;
Name = name;
fType = type;
Type = QVariant::Invalid;
if ( !type.isNull() ) {
aType = ( (const char *) type.section(" ",0,0).upper() )[0];
Width = type.section(" ",1,1).toInt();
Dec = type.section(" ",2,2).toInt();
switch ( aType ){
case 'C':
Type = QVariant::String;
fieldData = QString("");
break;
case 'N':
Type = QVariant::Double;
fieldData = ( double ) 0.0;
default:
Type = QVariant::Invalid;
}
}
}
/*!
Return pointer to asociated sql field.
*/
//QSqlField *
//aField::sqlField(){
// return field;
//}
/*!
*
*/
QVariant
aDataField::internalValue()
{
return fieldData;
}
/*!
*
*/
void
aDataField::setInternalValue( const QVariant &value)
{
fieldData = value;
}
/*!
* Возвращает значение поля данных.
*/
QVariant
aDataField::value()
{
return fieldData;
}
/*!
* Устанавливает значение поля данных.
*/
void
aDataField::setValue( const QVariant &value)
{
fieldData = value;
}
/*!
*
*/
int
aDataField::ObjectType()
{
return oType;
}
QString
aDataField::fieldName() const
{
return Name;
}
| 17.481308
| 83
| 0.636995
|
leaderit
|
dea3383bbe1211dcd2b00cfdb3f8141f81f6f04d
| 1,841
|
cpp
|
C++
|
src/r3.endlesss/endlesss/toolkit.exchange.cpp
|
Unbundlesss/OUROVEON
|
34dda511eda2a28b8522a724cfc9500a7914ea03
|
[
"MIT"
] | 6
|
2022-01-27T20:33:17.000Z
|
2022-02-16T18:29:43.000Z
|
src/r3.endlesss/endlesss/toolkit.exchange.cpp
|
Unbundlesss/OUROVEON
|
34dda511eda2a28b8522a724cfc9500a7914ea03
|
[
"MIT"
] | 4
|
2022-01-30T16:16:53.000Z
|
2022-02-20T20:07:25.000Z
|
src/r3.endlesss/endlesss/toolkit.exchange.cpp
|
Unbundlesss/OUROVEON
|
34dda511eda2a28b8522a724cfc9500a7914ea03
|
[
"MIT"
] | null | null | null |
// _______ _______ ______ _______ ___ ___ _______ _______ _______
// | | | | __ \ | | | ___| | | |
// | - | | | < - | | | ___| - | |
// |_______|_______|___|__|_______|\_____/|_______|_______|__|____|
// ishani.org 2022 e.t.c. MIT License
//
//
//
#include "pch.h"
#include "endlesss/toolkit.exchange.h"
#include "endlesss/live.riff.h"
#include "endlesss/live.stem.h"
namespace endlesss {
void Exchange::fillDetailsFromRiff( Exchange& data, const live::RiffPtr& riff, const char* jamName )
{
const auto* currentRiff = riff.get();
if ( currentRiff != nullptr )
{
data.m_dataflags |= DataFlags_Riff;
}
else
{
data.m_dataflags = DataFlags_Empty;
return;
}
strncpy(
data.m_jamName,
jamName,
endlesss::Exchange::MaxJamName - 1 );
const uint64_t currentRiffHash = currentRiff->getCIDHash().getID();
data.m_riffHash = currentRiffHash;
{
data.m_riffTimestamp = currentRiff->m_stTimestamp.time_since_epoch().count();
data.m_riffRoot = currentRiff->m_riffData.riff.root;
data.m_riffScale = currentRiff->m_riffData.riff.scale;
data.m_riffBPM = currentRiff->m_timingDetails.m_bpm;
data.m_riffBeatSegmentCount = currentRiff->m_timingDetails.m_quarterBeats;
}
for ( size_t sI = 0; sI < 8; sI++ )
{
const endlesss::live::Stem* stem = currentRiff->m_stemPtrs[sI];
if ( stem != nullptr )
{
data.m_stemColour[sI] = stem->m_colourU32;
data.m_stemGain[sI] = currentRiff->m_stemGains[sI];
data.setJammerName( sI, stem->m_data.user.c_str() );
}
}
}
} // namespace endlesss
| 30.180328
| 100
| 0.568169
|
Unbundlesss
|
dea4093891cf1c0ad10fac75f2675e11f486d4f5
| 596
|
cpp
|
C++
|
src/src/clonetest.cpp
|
yangkaioppen/imgpp
|
2212e8c80fc770a9bb24fed396ca43031de9e10f
|
[
"MIT"
] | 1
|
2020-05-12T07:35:39.000Z
|
2020-05-12T07:35:39.000Z
|
src/src/clonetest.cpp
|
yangkaioppen/imgpp
|
2212e8c80fc770a9bb24fed396ca43031de9e10f
|
[
"MIT"
] | 2
|
2020-04-22T05:27:47.000Z
|
2020-12-26T07:38:45.000Z
|
src/src/clonetest.cpp
|
yangkaioppen/imgpp
|
2212e8c80fc770a9bb24fed396ca43031de9e10f
|
[
"MIT"
] | 2
|
2020-04-20T05:55:12.000Z
|
2020-05-25T16:41:16.000Z
|
#include <imgpp/imgpp.hpp>
int main() {
// Test clone
{
imgpp::Img image(2, 2, 1, 1, 32, true, true, 1);
image.ROI().At<float>(0, 0) = 1.0f;
image.ROI().At<float>(0, 1) = 2.0f;
image.ROI().At<float>(1, 0) = 3.0f;
image.ROI().At<float>(1, 1) = 4.0f;
imgpp::Img clone = image.Clone();
// Make sure this is a deep copy.
if (image.Data().GetBuffer() == clone.Data().GetBuffer()) {
return 1;
}
// Check data.
if (std::memcmp(image.Data().GetBuffer(), clone.Data().GetBuffer(), image.Data().GetLength())) {
return 1;
}
}
return 0;
}
| 25.913043
| 100
| 0.541946
|
yangkaioppen
|
dea758c747e2934278a76f5efd5c994b144cad92
| 7,613
|
cpp
|
C++
|
svntrunk/src/bgfe/obsolete_pk/bgl/test/torusdevloop.cpp
|
Bhaskers-Blu-Org1/BlueMatter
|
1ab2c41af870c19e2e1b1095edd1d5c85eeb9b5e
|
[
"BSD-2-Clause"
] | 7
|
2020-02-25T15:46:18.000Z
|
2022-02-25T07:04:47.000Z
|
svntrunk/src/pk/bgl/test/torusdevloop.cpp
|
IBM/BlueMatter
|
5243c0ef119e599fc3e9b7c4213ecfe837de59f3
|
[
"BSD-2-Clause"
] | null | null | null |
svntrunk/src/pk/bgl/test/torusdevloop.cpp
|
IBM/BlueMatter
|
5243c0ef119e599fc3e9b7c4213ecfe837de59f3
|
[
"BSD-2-Clause"
] | 5
|
2019-06-06T16:30:21.000Z
|
2020-11-16T19:43:01.000Z
|
/* Copyright 2001, 2019 IBM Corporation
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "standalone.h"
#include "bgltoruspacket.h"
//#include "bglmemmap.h"
#include "assert.h"
void X_packet_dump(BGLTorusPacket *packet);
void X_packet_initrand (BGLTorusPacket *packet);
int X_packet_compare (BGLTorusPacket *packet0, BGLTorusPacket *packet1);
void _start()
{
BGLTorusPacket packet0, packet1, packet2, packet3,
packet4, packet5, packet6, packet7, packetr;
BGLTorusDevice torusa, torusb, torusc;
BGLDeviceStatus o;
int x, y, z ;
unsigned i;
unsigned long long t1, t2, elapsed;
t1 = s_timebase();
/* --------------------------------- */
/* initialize the torus */
/* --------------------------------- */
BGLTorus_Initialize (0, 0, 0, 1, 1, 1);
BGLTorus_nodeAddress (&x, &y, &z);
sim_printf("Torus initialized. I am torus element %d,%d,%d\n", x, y, z);
/* --------------------------------- */
/* initialize the device */
/* --------------------------------- */
BGLTorusDevice_Init (&torusa, BGLTorusDevice_General0, (void *)0 );
BGLTorusDevice_Init (&torusb, BGLTorusDevice_General1, (void *)0 );
BGLTorusDevice_Init (&torusc, BGLTorusDevice_All, (void *)0 );
sim_printf("Torus Device(s) initialized.\n");
/* --------------------------------- */
/* initialize the packets */
/* --------------------------------- */
BGLTorusPacketHeader_Init (&packet0.header, 0, 0, 0, (void *)0, 0);
BGLTorusPacketHeader_Init (&packet1.header, 0, 0, 0, (void *)0, 0);
BGLTorusPacketHeader_Init (&packet2.header, 0, 0, 0, (void *)0, 0);
BGLTorusPacketHeader_Init (&packet3.header, 0, 0, 0, (void *)0, 0);
BGLTorusPacketHeader_Init (&packet4.header, 0, 0, 0, (void *)0, 0);
BGLTorusPacketHeader_Init (&packet5.header, 0, 0, 0, (void *)0, 0);
BGLTorusPacketHeader_Init (&packet6.header, 0, 0, 0, (void *)0, 0);
BGLTorusPacketHeader_Init (&packet7.header, 0, 0, 0, (void *)0, 0);
packet0.header.hh.size = 0;
packet1.header.hh.size = 1;
packet2.header.hh.size = 2;
packet3.header.hh.size = 3;
packet4.header.hh.size = 4;
packet5.header.hh.size = 5;
packet6.header.hh.size = 6;
packet7.header.hh.size = 7;
X_packet_initrand(&packet0);
X_packet_initrand(&packet1);
X_packet_initrand(&packet2);
X_packet_initrand(&packet3);
X_packet_initrand(&packet4);
X_packet_initrand(&packet5);
X_packet_initrand(&packet6);
X_packet_initrand(&packet7);
sim_printf("Packets initialized.\n");
/* --------------------------------- */
/* send the packet(s) */
/* --------------------------------- */
o = BGLTorusDevice_send(&torusa, (BGLQuad *)&packet0);
sim_printf("Packet 0 sent\n", o);
o = BGLTorusDevice_send(&torusb, (BGLQuad *)&packet1);
sim_printf("Packet 1 sent\n", o);
o = BGLTorusDevice_send(&torusa, (BGLQuad *)&packet2);
sim_printf("Packet 2 sent\n", o);
o = BGLTorusDevice_send(&torusb, (BGLQuad *)&packet3);
sim_printf("Packet 3 sent\n", o);
o = BGLTorusDevice_send(&torusa, (BGLQuad *)&packet4);
sim_printf("Packet 4 sent\n", o);
o = BGLTorusDevice_send(&torusb, (BGLQuad *)&packet5);
sim_printf("Packet 5 sent\n", o);
o = BGLTorusDevice_send(&torusa, (BGLQuad *)&packet6);
sim_printf("Packet 6 sent\n", o);
o = BGLTorusDevice_send(&torusb, (BGLQuad *)&packet7);
sim_printf("Packet 7 sent\n", o);
/* --------------------------------- */
/* wait for packets to come back */
/* --------------------------------- */
for (i=0;i<8;i++)
{
while (BGLTorusDevice_recv(&torusc, &packetr)!=BGLDeviceStatus_OK)
sim_printf("*");
if (X_packet_compare(&packet0, &packetr)) sim_printf("Pkt 0 OK\n");
else if (X_packet_compare(&packet1, &packetr)) sim_printf("Pkt 1 OK\n");
else if (X_packet_compare(&packet2, &packetr)) sim_printf("Pkt 2 OK\n");
else if (X_packet_compare(&packet3, &packetr)) sim_printf("Pkt 3 OK\n");
else if (X_packet_compare(&packet4, &packetr)) sim_printf("Pkt 4 OK\n");
else if (X_packet_compare(&packet5, &packetr)) sim_printf("Pkt 5 OK\n");
else if (X_packet_compare(&packet6, &packetr)) sim_printf("Pkt 6 OK\n");
else if (X_packet_compare(&packet7, &packetr)) sim_printf("Pkt 7 OK\n");
else sim_printf("Broken Packet\n");
}
t2 = s_timebase();
elapsed = t2 - t1;
sim_printf("TorusDevTest timing: %ld\n", (unsigned) elapsed);
/* --------------------------------- */
/* that's it */
/* --------------------------------- */
sim_stop(0x1234);
}
void X_dump_header (BGLTorusPacketHeader *header)
{
char xhint = header->hh.hintXPlus?'+':(header->hh.hintXMinus?'-':' ');
char yhint = header->hh.hintYPlus?'+':(header->hh.hintYMinus?'-':' ');
char zhint = header->hh.hintZPlus?'+':(header->hh.hintZMinus?'-':' ');
sim_printf("Header (%d%c,%d%c,%d%c) size(%d) AF=%x ARG=%x\n",
header->hh.destX,xhint,
header->hh.destY,yhint,
header->hh.destZ,zhint,
header->hh.size,
header->sh.fcn,
header->sh.arg);
}
void X_packet_dump(BGLTorusPacket *packet)
{
int i;
char *p = (char *)packet->data;
X_dump_header(&packet->header);
for (i=0; i<((1+packet->header.hh.size)<<5)-16; i++)
{
sim_printf("0x%02x ", p[i]);
if ((i%16)==15) sim_printf("\n");
}
sim_printf("\n");
}
unsigned long long X_random_gen ()
{
static unsigned long long mask = 0x7FFFFFFFULL; /* 2^31 - 1 */
static unsigned long long a = 1103515245ULL;
static unsigned long long c = 12345ULL;
static unsigned long long ran = 99ULL;
ran = ((a * ran + c) & mask);
return ran;
}
void X_packet_initrand (BGLTorusPacket *packet)
{
int i;
char *p;
assert (packet != (BGLTorusPacket *)0);
p = (char *)packet->data;
for (i=0; i<((1+packet->header.hh.size)<<5)-16; i++)
{
p[i] = (X_random_gen() & 0xFF00) >> 8;
}
}
int X_packet_compare (BGLTorusPacket *packet0, BGLTorusPacket *packet1)
{
int size0, size1, i;
char *p, *q;
assert (packet0 != 0 && packet1 != 0);
size0 = packet0->header.hh.size;
size1 = packet1->header.hh.size;
if (size0 != size1) return 0;
p = (char *)packet0->data;
q = (char *)packet1->data;
for (i=0; i<((1+packet0->header.hh.size)<<5)-16; i++)
if (p[i] != q[i]) return 0;
return 1;
}
| 34.139013
| 118
| 0.6217
|
Bhaskers-Blu-Org1
|
dea7bc77e719900abb506b3e47c937bd055b51e0
| 791
|
cpp
|
C++
|
9/969. Pancake Sorting.cpp
|
eagleoflqj/LeetCode
|
ca5dd06cad4c7fe5bf679cca7ee60f4348b316e9
|
[
"MIT"
] | null | null | null |
9/969. Pancake Sorting.cpp
|
eagleoflqj/LeetCode
|
ca5dd06cad4c7fe5bf679cca7ee60f4348b316e9
|
[
"MIT"
] | 1
|
2021-12-25T10:33:23.000Z
|
2022-02-16T00:34:05.000Z
|
9/969. Pancake Sorting.cpp
|
eagleoflqj/LeetCode
|
ca5dd06cad4c7fe5bf679cca7ee60f4348b316e9
|
[
"MIT"
] | null | null | null |
class Solution {
public:
vector<int> pancakeSort(vector<int>& arr) {
int n = arr.size();
vector<int> index(n), ret;
for(int i = 0; i < n; ++i)
index[arr[i] - 1] = i;
for(int i = n - 1; i > 0; --i)
if(index[i] != i) { // AxBy
ret.push_back(index[i] + 1); // xA'By
ret.push_back(i + 1); // yB'Ax
int d = i - index[i];
ret.push_back(d--); // ByAx
if(d)
ret.push_back(d); // B'yAx
ret.push_back(i); // A'yBx
if(index[i])
ret.push_back(index[i]); // AyBx
arr[index[i]] = arr[i];
index[arr[i] - 1] = index[i];
}
return ret;
}
};
| 31.64
| 53
| 0.380531
|
eagleoflqj
|
dea890b1088b8e9d87cf6f932a9ff74797b5ec5a
| 11,237
|
cc
|
C++
|
vos/gui/sub/gui/sg_components/SgAxisView.cc
|
NASA-AMMOS/VICAR
|
4504c1f558855d9c6eaef89f4460217aa4909f8e
|
[
"BSD-3-Clause"
] | 16
|
2020-10-21T05:56:26.000Z
|
2022-03-31T10:02:01.000Z
|
vos/gui/sub/gui/sg_components/SgAxisView.cc
|
NASA-AMMOS/VICAR
|
4504c1f558855d9c6eaef89f4460217aa4909f8e
|
[
"BSD-3-Clause"
] | null | null | null |
vos/gui/sub/gui/sg_components/SgAxisView.cc
|
NASA-AMMOS/VICAR
|
4504c1f558855d9c6eaef89f4460217aa4909f8e
|
[
"BSD-3-Clause"
] | 2
|
2021-03-09T01:51:08.000Z
|
2021-03-23T00:23:24.000Z
|
///////////////////////////////////////////////////////
// SgAxisView.C: A component class to show a plot axis.
////////////////////////////////////////////////////////
#include "SgAxisView.h"
#include "ErrorManager.h"
#include <Xm/DrawingA.h>
#include <Xm/Form.h>
#include <iostream>
using namespace std;
#include <assert.h>
#include <stdio.h>
#include <ctype.h>
// Resources for this class
XtResource SgAxisView::_resources [ ] = {
{
(char *)"min",
(char *)"Min",
XmRFloat,
sizeof ( float ),
XtOffset ( SgAxisView *, _min ),
XmRString,
( XtPointer ) "0",
},
{
(char *)"max",
(char *)"Max",
XmRFloat,
sizeof ( float ),
XtOffset ( SgAxisView *, _max ),
XmRString,
( XtPointer ) "255",
},
{
(char *)"drawTicksOnly",
(char *)"DrawTicksOnly",
XmRBoolean,
sizeof ( Boolean ),
XtOffset ( SgAxisView *, _ticksOnly ),
XmRString,
( XtPointer ) "FALSE",
},
{
(char *)"intRange",
(char *)"IntRange",
XmRBoolean,
sizeof ( Boolean ),
XtOffset ( SgAxisView *, _intRange ),
XmRString,
( XtPointer ) "TRUE",
},
{
(char *)"fontList",
(char *)"FontList",
XmRString,
sizeof ( String ),
XtOffset ( SgAxisView *, _fontname ),
XmRImmediate,
( XtPointer ) "6x10",
},
{
(char *)"drawOffset",
(char *)"DrawOffset",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _drawOffset ),
XmRImmediate,
( XtPointer ) 3,
},
{
(char *)"fistTickMargin",
(char *)"FistTickMargin",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _fistTickMargin ),
XmRImmediate,
( XtPointer ) 0,
},
{
(char *)"lastTickMargin",
(char *)"LastTickMargin",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _lastTickMargin ),
XmRImmediate,
( XtPointer ) 0,
},
{
(char *)"tickThickness",
(char *)"TickThickness",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _tickThickness ),
XmRImmediate,
( XtPointer ) 1,
},
{
(char *)"longTickLength",
(char *)"LongTickLength",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _longTickLength ),
XmRImmediate,
( XtPointer ) 8,
},
{
(char *)"shortTickLength",
(char *)"ShortTickLength",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _shortTickLength ),
XmRImmediate,
( XtPointer ) 5,
},
{
(char *)"strOffset",
(char *)"StrOffset",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _strOffset ),
XmRImmediate,
( XtPointer ) 3,
},
{
(char *)"twoTicks",
(char *)"TwoTicks",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _twoTicks ),
XmRImmediate,
( XtPointer ) 100,
},
{
(char *)"fourTicks",
(char *)"FourTicks",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _fourTicks ),
XmRImmediate,
( XtPointer ) 200,
},
{
(char *)"eightTicks",
(char *)"EightTicks",
XmRDimension,
sizeof ( Dimension ),
XtOffset ( SgAxisView *, _eightTicks ),
XmRImmediate,
( XtPointer ) 300,
},
};
String SgAxisView::_defaults[] = {
(char *)"*height: 256",
(char *)"*width: 40",
NULL,
};
SgAxisView::SgAxisView ( Widget parent, const char *name, Boolean vertical )
: UIComponent (name)
{
_vertical = vertical;
_ascending = TRUE;
setDefaultResources ( parent, _defaults );
_w = XtVaCreateWidget ( _name,
xmDrawingAreaWidgetClass, parent,
NULL );
installDestroyHandler();
getResources ( _resources, XtNumber ( _resources ) );
XtAddCallback ( _w, XmNexposeCallback,
&SgAxisView::displayCallback,
( XtPointer ) this );
// Allocate private GC
_gc = XCreateGC ( XtDisplay ( _w ),
RootWindowOfScreen ( XtScreen ( _w ) ),
0L, NULL );
// Modify GC, setting foreground, line attributes, and font
Pixel pixel;
XtVaGetValues ( _w, XmNforeground, &pixel, NULL );
XSetForeground ( XtDisplay ( _w ), _gc, pixel );
XSetLineAttributes ( XtDisplay(_w), _gc, _tickThickness,
LineSolid, CapButt, JoinMiter );
_fontStruct = XLoadQueryFont ( XtDisplay(_w), _fontname );
if ( _fontStruct == NULL ) {
theErrorManager->process ( Error, "axis", "No such font", _fontname);
_fontStruct = XQueryFont ( XtDisplay(_w), XGContextFromGC(_gc) );
}
else {
XSetFont ( XtDisplay(_w), _gc, _fontStruct->fid );
}
}
SgAxisView::~SgAxisView()
{
if ( _w && _gc )
XFreeGC ( XtDisplay ( _w ), _gc );
if ( _w && _fontStruct )
XFreeFont ( XtDisplay ( _w ), _fontStruct );
}
void SgAxisView::displayCallback ( Widget, XtPointer clientData, XtPointer )
{
SgAxisView *obj = ( SgAxisView * ) clientData;
obj->display();
}
void SgAxisView::display()
{
if ( !XtIsRealized ( _w ) )
return;
// Make any resize cause expose event (see vol. 6A, p.346-7)
XSetWindowAttributes attrs;
attrs.bit_gravity = ForgetGravity;
XChangeWindowAttributes ( XtDisplay ( _w ), XtWindow ( _w ),
CWBitGravity, &attrs );
// Get current size
Dimension width, height;
XtVaGetValues ( _w,
XmNwidth, &width,
XmNheight, &height,
NULL );
// Always clear window before start drawing
XClearWindow ( XtDisplay(_w), XtWindow(_w) );
// Draw the ticks and the labels
if ( _vertical == TRUE )
drawVertical ( height, width );
else
drawHorizontal ( width );
}
void SgAxisView::drawVertical ( Dimension height, Dimension width )
{
Dimension drawHeight = height - _fistTickMargin - _lastTickMargin;
// Draw a long line from side to side
if ( _ticksOnly == FALSE )
XDrawLine ( XtDisplay(_w), XtWindow(_w), _gc,
width - _drawOffset,
_fistTickMargin,
width - _drawOffset,
_fistTickMargin + drawHeight );
// Calculate how many ticks we need at this screen width
int numTicks = getNumTicks ( drawHeight );
// Calculate distance between ticks, double precision
double step = (double)drawHeight / (double)(numTicks-1);
int i;
for ( i = 0; i < numTicks - 1; i+=2 ) {
// Draw a long tick
XDrawLine ( XtDisplay(_w), XtWindow(_w), _gc,
width - _drawOffset - _longTickLength,
(int)(_fistTickMargin + (double)i * step),
width - _drawOffset,
(int)(_fistTickMargin + (double)i * step) );
}
for ( i = 1; i < numTicks - 1; i+=2 ) {
// Draw a short tick
XDrawLine ( XtDisplay(_w), XtWindow(_w), _gc,
width - _drawOffset - _shortTickLength,
(int)(_fistTickMargin + (double)i * step),
width - _drawOffset,
(int)(_fistTickMargin + (double)i * step) );
}
// Draw the last tick
XDrawLine ( XtDisplay(_w), XtWindow(_w), _gc,
width - _drawOffset - _longTickLength,
height - _lastTickMargin - 1,
width - _drawOffset,
height - _lastTickMargin - 1 );
// Draw label to every other tick
double lbl;
char buf [16];
for ( i = 0; i < numTicks; i+=2 ) {
lbl = _min + (double(_max - _min) / (double)(numTicks-1) ) * (double)i;
if ( _ascending )
lbl = (_max + _min) - lbl;
if ( _intRange )
sprintf ( buf, "%d", (int)lbl );
else
sprintf ( buf, "%.3g", lbl );
Dimension strWidth = XTextWidth ( _fontStruct, buf, strlen(buf) );
Dimension strHeight = Dimension ( _fontStruct->ascent );
// First and last ticks are special cases
if ( i > 0 && i < numTicks - 1 )
strHeight /= 2;
else if ( i == numTicks - 1 )
strHeight = 0;
XDrawString ( XtDisplay ( _w ), XtWindow ( _w ), _gc,
width - _drawOffset - _longTickLength - _strOffset - strWidth,
(int)(_fistTickMargin + (double)i * step + strHeight),
buf, strlen(buf) );
}
}
void SgAxisView::drawHorizontal ( Dimension width )
{
Dimension drawWidth = width - _fistTickMargin - _lastTickMargin;
// Draw a long line (a ruler?) from side to side
if ( _ticksOnly == FALSE )
XDrawLine ( XtDisplay(_w), XtWindow(_w), _gc,
_fistTickMargin,
_drawOffset,
width - _lastTickMargin,
_drawOffset );
// Calculate how many ticks we need at this screen width
int numTicks = getNumTicks ( drawWidth );
// Calculate distance between ticks, double precision
double step = (double)drawWidth / (double)(numTicks-1);
int i;
for ( i = 0; i < numTicks - 1; i+=2 ) {
// Draw a long tick
XDrawLine ( XtDisplay(_w), XtWindow(_w), _gc,
(int)(_fistTickMargin + (double)i * step),
_drawOffset,
(int)(_fistTickMargin + (double)i * step),
_drawOffset + _longTickLength );
}
for ( i = 1; i < numTicks - 1; i+=2 ) {
// Draw a short tick
XDrawLine ( XtDisplay(_w), XtWindow(_w), _gc,
(int)(_fistTickMargin + (double)i * step),
_drawOffset,
(int)(_fistTickMargin + (double)i * step),
_drawOffset + _shortTickLength );
}
// Draw the last tick
XDrawLine ( XtDisplay(_w), XtWindow(_w), _gc,
width - _lastTickMargin - 1,
_drawOffset,
width - _lastTickMargin - 1,
_drawOffset + _longTickLength );
// Draw label to every other tick
double lbl;
char buf [16];
for ( i = 0; i < numTicks; i+=2 ) {
lbl = _min + (double(_max - _min) / (double)(numTicks-1) ) * (double)i;
if ( _intRange )
sprintf ( buf, "%d", (int)lbl );
else
sprintf ( buf, "%.3g", lbl );
Dimension strWidth = XTextWidth ( _fontStruct, buf, strlen(buf) );
Dimension strHeight = Dimension ( _fontStruct->ascent );
// First and last ticks are special cases
if ( i == 0 )
strWidth = 0;
else if ( i != numTicks - 1 )
strWidth /= 2;
XDrawString (XtDisplay(_w), XtWindow(_w), _gc,
(int)(_fistTickMargin + (double)i * step - strWidth),
_drawOffset + _longTickLength + _strOffset + strHeight,
buf, strlen(buf) );
}
}
int SgAxisView::getNumTicks ( Dimension drawWidth )
{
if ( drawWidth < _twoTicks )
return 3;
else if ( drawWidth < _fourTicks )
return 5;
else if ( drawWidth < _eightTicks )
return 9;
else
return 17;
}
void SgAxisView::setLimits ( int min, int max )
{
assert ( min <= max );
_min = (float)min;
_max = (float)max;
}
void SgAxisView::setLimits ( float min, float max )
{
assert ( min <= max );
_min = min;
_max = max;
display();
}
void SgAxisView::setIntRange ( Boolean intRange )
{
if ( _intRange == intRange )
return;
else
_intRange = intRange;
display();
}
void SgAxisView::setVertical ( Boolean vertical )
{
if ( _vertical == vertical )
return;
else
_vertical = vertical;
Dimension width;
if ( _vertical ) {
XtVaGetValues ( _w,
XmNheight, &width,
NULL);
XtVaSetValues ( _w,
XmNwidth, width,
NULL);
}
else {
XtVaGetValues ( _w,
XmNwidth, &width,
NULL);
XtVaSetValues ( _w,
XmNheight, width,
NULL);
}
display();
}
void SgAxisView::setAscending ( Boolean ascending )
{
if ( _ascending == ascending )
return;
else
_ascending = ascending;
display();
}
| 22.70101
| 79
| 0.595444
|
NASA-AMMOS
|
dea90f86cda37aa2bb0754da13db164130a9c547
| 8,776
|
cpp
|
C++
|
PhysX_3.4/Source/PhysX/src/buffering/ScbMetaData.cpp
|
RyanTorant/simple-physx
|
a065a9c734c134074c63c80a9109a398b22d040c
|
[
"Unlicense"
] | 1
|
2019-12-09T16:03:55.000Z
|
2019-12-09T16:03:55.000Z
|
PhysX_3.4/Source/PhysX/src/buffering/ScbMetaData.cpp
|
RyanTorant/simple-physx
|
a065a9c734c134074c63c80a9109a398b22d040c
|
[
"Unlicense"
] | null | null | null |
PhysX_3.4/Source/PhysX/src/buffering/ScbMetaData.cpp
|
RyanTorant/simple-physx
|
a065a9c734c134074c63c80a9109a398b22d040c
|
[
"Unlicense"
] | null | null | null |
// This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxIO.h"
#include "ScbShape.h"
#include "ScbBody.h"
#include "ScbRigidStatic.h"
#include "ScbConstraint.h"
#include "ScbArticulation.h"
#include "ScbArticulationJoint.h"
#include "ScbAggregate.h"
#include "ScbCloth.h"
#include "ScbParticleSystem.h"
using namespace physx;
///////////////////////////////////////////////////////////////////////////////
void Scb::Base::getBinaryMetaData(PxOutputStream& stream)
{
// 28 => 12 bytes
PX_DEF_BIN_METADATA_TYPEDEF(stream, ScbType::Enum, PxU32)
PX_DEF_BIN_METADATA_CLASS(stream, Scb::Base)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Base, Scb::Scene, mScene, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Base, PxU32, mControlState, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Base, PxU8*, mStreamPtr, PxMetaDataFlag::ePTR)
}
///////////////////////////////////////////////////////////////////////////////
void Scb::Shape::getBinaryMetaData(PxOutputStream& stream)
{
// 176 => 160 bytes
PX_DEF_BIN_METADATA_CLASS(stream, Scb::Shape)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::Shape, Scb::Base)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Shape, ShapeCore, mShape, 0)
}
///////////////////////////////////////////////////////////////////////////////
void Scb::Actor::getBinaryMetaData(PxOutputStream& stream)
{
PX_DEF_BIN_METADATA_CLASS(stream, Scb::Actor)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::Actor, Scb::Base)
}
///////////////////////////////////////////////////////////////////////////////
void Scb::RigidObject::getBinaryMetaData(PxOutputStream& stream)
{
PX_DEF_BIN_METADATA_CLASS(stream, Scb::RigidObject)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::RigidObject, Scb::Actor)
}
///////////////////////////////////////////////////////////////////////////////
void Scb::Body::getBinaryMetaData(PxOutputStream& stream)
{
// 240 => 224 bytes
PX_DEF_BIN_METADATA_CLASS(stream, Scb::Body)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::Body, Scb::RigidObject)
#ifdef EXPLICIT_PADDING_METADATA
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Body, PxU32, mPaddingScbBody1, PxMetaDataFlag::ePADDING)
#endif
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Body, Sc::BodyCore, mBodyCore, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Body, PxTransform, mBufferedBody2World, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Body, PxVec3, mBufferedLinVelocity, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Body, PxVec3, mBufferedAngVelocity, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Body, PxReal, mBufferedWakeCounter, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Body, PxU32, mBufferedIsSleeping, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Body, PxU32, mBodyBufferFlags, 0)
}
///////////////////////////////////////////////////////////////////////////////
void Scb::RigidStatic::getBinaryMetaData(PxOutputStream& stream)
{
PX_DEF_BIN_METADATA_CLASS(stream, Scb::RigidStatic)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::RigidStatic, Scb::RigidObject)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::RigidStatic, Sc::StaticCore, mStatic, 0)
}
///////////////////////////////////////////////////////////////////////////////
void Scb::Articulation::getBinaryMetaData(PxOutputStream& stream)
{
PX_DEF_BIN_METADATA_CLASS(stream, Scb::Articulation)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::Articulation, Scb::Base)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Articulation, ArticulationCore, mArticulation, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Articulation, PxReal, mBufferedWakeCounter, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Articulation, PxU8, mBufferedIsSleeping, 0)
}
///////////////////////////////////////////////////////////////////////////////
void Scb::ArticulationJoint::getBinaryMetaData(PxOutputStream& stream)
{
PX_DEF_BIN_METADATA_CLASS(stream, Scb::ArticulationJoint)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::ArticulationJoint, Scb::Base)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::ArticulationJoint, ArticulationJointCore, mJoint, 0)
}
///////////////////////////////////////////////////////////////////////////////
void Scb::Constraint::getBinaryMetaData(PxOutputStream& stream)
{
// 120 => 108 bytes
PX_DEF_BIN_METADATA_CLASS(stream, Scb::Constraint)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::Constraint, Scb::Base)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Constraint, ConstraintCore, mConstraint, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Constraint, PxVec3, mBufferedForce, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Constraint, PxVec3, mBufferedTorque, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Constraint, PxConstraintFlags, mBrokenFlag, 0)
#ifdef EXPLICIT_PADDING_METADATA
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Constraint, PxU16, mPaddingFromBrokenFlags, PxMetaDataFlag::ePADDING)
#endif
}
///////////////////////////////////////////////////////////////////////////////
void Scb::Aggregate::getBinaryMetaData(PxOutputStream& stream)
{
PX_DEF_BIN_METADATA_CLASS(stream, Scb::Aggregate)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::Aggregate, Scb::Base)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Aggregate, PxAggregate,mPxAggregate, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Aggregate, PxU32, mAggregateID, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Aggregate, PxU32, mMaxNbActors, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Aggregate, bool, mSelfCollide, 0)
#ifdef EXPLICIT_PADDING_METADATA
PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Scb::Aggregate, bool, mPaddingFromBool, PxMetaDataFlag::ePADDING)
#endif
}
///////////////////////////////////////////////////////////////////////////////
#if PX_USE_CLOTH_API
void Scb::Cloth::getBinaryMetaData(PxOutputStream& stream)
{
PX_DEF_BIN_METADATA_CLASS(stream, Scb::Cloth)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::Cloth, Scb::Actor)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::Cloth, Sc::ClothCore, mCloth, 0)
}
#endif
///////////////////////////////////////////////////////////////////////////////
#if PX_USE_PARTICLE_SYSTEM_API
void Scb::ParticleSystem::getBinaryMetaData(PxOutputStream& stream)
{
PX_DEF_BIN_METADATA_CLASS(stream, ForceUpdates)
PX_DEF_BIN_METADATA_ITEM(stream, ForceUpdates, BitMap, map, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, ForceUpdates, PxVec3, values, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, ForceUpdates, bool, hasUpdates, 0)
PX_DEF_BIN_METADATA_CLASS(stream, Scb::ParticleSystem)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, Scb::ParticleSystem, Scb::Actor)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::ParticleSystem, Sc::ParticleSystemCore, mParticleSystem, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::ParticleSystem, NpParticleFluidReadData, mReadParticleFluidData, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::ParticleSystem, ForceUpdates, mForceUpdatesAcc, 0)
PX_DEF_BIN_METADATA_ITEM(stream, Scb::ParticleSystem, ForceUpdates, mForceUpdatesVel, 0)
}
#endif
///////////////////////////////////////////////////////////////////////////////
| 43.231527
| 126
| 0.697015
|
RyanTorant
|
deacc28df8e4bcbba836c34c03bcf73c69eb7f6c
| 12,706
|
cpp
|
C++
|
src/Device/VertexProcessor.cpp
|
opersys/bbb-platform_external_swiftshader
|
54561baf5b7bd68e572326bf99a0c7ae1ecd76a2
|
[
"Apache-2.0"
] | null | null | null |
src/Device/VertexProcessor.cpp
|
opersys/bbb-platform_external_swiftshader
|
54561baf5b7bd68e572326bf99a0c7ae1ecd76a2
|
[
"Apache-2.0"
] | null | null | null |
src/Device/VertexProcessor.cpp
|
opersys/bbb-platform_external_swiftshader
|
54561baf5b7bd68e572326bf99a0c7ae1ecd76a2
|
[
"Apache-2.0"
] | null | null | null |
// Copyright 2016 The SwiftShader Authors. 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.
#include "VertexProcessor.hpp"
#include "Pipeline/VertexProgram.hpp"
#include "Pipeline/VertexShader.hpp"
#include "Pipeline/PixelShader.hpp"
#include "Pipeline/Constants.hpp"
#include "System/Math.hpp"
#include "Vulkan/VkDebug.hpp"
#include <string.h>
namespace sw
{
bool precacheVertex = false;
void VertexCache::clear()
{
for(int i = 0; i < 16; i++)
{
tag[i] = 0x80000000;
}
}
unsigned int VertexProcessor::States::computeHash()
{
unsigned int *state = (unsigned int*)this;
unsigned int hash = 0;
for(unsigned int i = 0; i < sizeof(States) / 4; i++)
{
hash ^= state[i];
}
return hash;
}
VertexProcessor::State::State()
{
memset(this, 0, sizeof(State));
}
bool VertexProcessor::State::operator==(const State &state) const
{
if(hash != state.hash)
{
return false;
}
return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0;
}
VertexProcessor::TransformFeedbackInfo::TransformFeedbackInfo()
{
buffer = nullptr;
offset = 0;
reg = 0;
row = 0;
col = 0;
stride = 0;
}
VertexProcessor::UniformBufferInfo::UniformBufferInfo()
{
buffer = nullptr;
offset = 0;
}
VertexProcessor::VertexProcessor(Context *context) : context(context)
{
routineCache = nullptr;
setRoutineCacheSize(1024);
}
VertexProcessor::~VertexProcessor()
{
delete routineCache;
routineCache = nullptr;
}
void VertexProcessor::setInputStream(int index, const Stream &stream)
{
context->input[index] = stream;
}
void VertexProcessor::resetInputStreams()
{
for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{
context->input[i].defaults();
}
}
void VertexProcessor::setFloatConstant(unsigned int index, const float value[4])
{
if(index < VERTEX_UNIFORM_VECTORS)
{
c[index][0] = value[0];
c[index][1] = value[1];
c[index][2] = value[2];
c[index][3] = value[3];
}
else ASSERT(false);
}
void VertexProcessor::setIntegerConstant(unsigned int index, const int integer[4])
{
if(index < 16)
{
i[index][0] = integer[0];
i[index][1] = integer[1];
i[index][2] = integer[2];
i[index][3] = integer[3];
}
else ASSERT(false);
}
void VertexProcessor::setBooleanConstant(unsigned int index, int boolean)
{
if(index < 16)
{
b[index] = boolean != 0;
}
else ASSERT(false);
}
void VertexProcessor::setUniformBuffer(int index, sw::Resource* buffer, int offset)
{
uniformBufferInfo[index].buffer = buffer;
uniformBufferInfo[index].offset = offset;
}
void VertexProcessor::lockUniformBuffers(byte** u, sw::Resource* uniformBuffers[])
{
for(int i = 0; i < MAX_UNIFORM_BUFFER_BINDINGS; ++i)
{
u[i] = uniformBufferInfo[i].buffer ? static_cast<byte*>(uniformBufferInfo[i].buffer->lock(PUBLIC, PRIVATE)) + uniformBufferInfo[i].offset : nullptr;
uniformBuffers[i] = uniformBufferInfo[i].buffer;
}
}
void VertexProcessor::setTransformFeedbackBuffer(int index, sw::Resource* buffer, int offset, unsigned int reg, unsigned int row, unsigned int col, unsigned int stride)
{
transformFeedbackInfo[index].buffer = buffer;
transformFeedbackInfo[index].offset = offset;
transformFeedbackInfo[index].reg = reg;
transformFeedbackInfo[index].row = row;
transformFeedbackInfo[index].col = col;
transformFeedbackInfo[index].stride = stride;
}
void VertexProcessor::lockTransformFeedbackBuffers(byte** t, unsigned int* v, unsigned int* r, unsigned int* c, unsigned int* s, sw::Resource* transformFeedbackBuffers[])
{
for(int i = 0; i < MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS; ++i)
{
t[i] = transformFeedbackInfo[i].buffer ? static_cast<byte*>(transformFeedbackInfo[i].buffer->lock(PUBLIC, PRIVATE)) + transformFeedbackInfo[i].offset : nullptr;
transformFeedbackBuffers[i] = transformFeedbackInfo[i].buffer;
v[i] = transformFeedbackInfo[i].reg;
r[i] = transformFeedbackInfo[i].row;
c[i] = transformFeedbackInfo[i].col;
s[i] = transformFeedbackInfo[i].stride;
}
}
void VertexProcessor::setInstanceID(int instanceID)
{
context->instanceID = instanceID;
}
void VertexProcessor::setTextureFilter(unsigned int sampler, FilterType textureFilter)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setTextureFilter(textureFilter);
}
else ASSERT(false);
}
void VertexProcessor::setMipmapFilter(unsigned int sampler, MipmapType mipmapFilter)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMipmapFilter(mipmapFilter);
}
else ASSERT(false);
}
void VertexProcessor::setGatherEnable(unsigned int sampler, bool enable)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setGatherEnable(enable);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeU(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeU(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeV(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeV(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeW(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeW(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setReadSRGB(unsigned int sampler, bool sRGB)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setReadSRGB(sRGB);
}
else ASSERT(false);
}
void VertexProcessor::setMipmapLOD(unsigned int sampler, float bias)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMipmapLOD(bias);
}
else ASSERT(false);
}
void VertexProcessor::setBorderColor(unsigned int sampler, const Color<float> &borderColor)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setBorderColor(borderColor);
}
else ASSERT(false);
}
void VertexProcessor::setMaxAnisotropy(unsigned int sampler, float maxAnisotropy)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMaxAnisotropy(maxAnisotropy);
}
else ASSERT(false);
}
void VertexProcessor::setHighPrecisionFiltering(unsigned int sampler, bool highPrecisionFiltering)
{
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setHighPrecisionFiltering(highPrecisionFiltering);
}
else ASSERT(false);
}
void VertexProcessor::setSwizzleR(unsigned int sampler, SwizzleType swizzleR)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setSwizzleR(swizzleR);
}
else ASSERT(false);
}
void VertexProcessor::setSwizzleG(unsigned int sampler, SwizzleType swizzleG)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setSwizzleG(swizzleG);
}
else ASSERT(false);
}
void VertexProcessor::setSwizzleB(unsigned int sampler, SwizzleType swizzleB)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setSwizzleB(swizzleB);
}
else ASSERT(false);
}
void VertexProcessor::setSwizzleA(unsigned int sampler, SwizzleType swizzleA)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setSwizzleA(swizzleA);
}
else ASSERT(false);
}
void VertexProcessor::setCompareFunc(unsigned int sampler, CompareFunc compFunc)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setCompareFunc(compFunc);
}
else ASSERT(false);
}
void VertexProcessor::setBaseLevel(unsigned int sampler, int baseLevel)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setBaseLevel(baseLevel);
}
else ASSERT(false);
}
void VertexProcessor::setMaxLevel(unsigned int sampler, int maxLevel)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMaxLevel(maxLevel);
}
else ASSERT(false);
}
void VertexProcessor::setMinLod(unsigned int sampler, float minLod)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMinLod(minLod);
}
else ASSERT(false);
}
void VertexProcessor::setMaxLod(unsigned int sampler, float maxLod)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMaxLod(maxLod);
}
else ASSERT(false);
}
void VertexProcessor::setPointSizeMin(float pointSizeMin)
{
this->pointSizeMin = pointSizeMin;
}
void VertexProcessor::setPointSizeMax(float pointSizeMax)
{
this->pointSizeMax = pointSizeMax;
}
void VertexProcessor::setTransformFeedbackQueryEnabled(bool enable)
{
context->transformFeedbackQueryEnabled = enable;
}
void VertexProcessor::enableTransformFeedback(uint64_t enable)
{
context->transformFeedbackEnabled = enable;
}
void VertexProcessor::setRoutineCacheSize(int cacheSize)
{
delete routineCache;
routineCache = new RoutineCache<State>(clamp(cacheSize, 1, 65536), precacheVertex ? "sw-vertex" : 0);
}
const VertexProcessor::State VertexProcessor::update(DrawType drawType)
{
State state;
state.shaderID = context->vertexShader->getSerialID();
state.fixedFunction = !context->vertexShader && context->pixelShaderModel() < 0x0300;
state.textureSampling = context->vertexShader ? context->vertexShader->containsTextureSampling() : false;
state.positionRegister = context->vertexShader ? context->vertexShader->getPositionRegister() : Pos;
state.pointSizeRegister = context->vertexShader ? context->vertexShader->getPointSizeRegister() : Pts;
state.multiSampling = context->getMultiSampleCount() > 1;
state.transformFeedbackQueryEnabled = context->transformFeedbackQueryEnabled;
state.transformFeedbackEnabled = context->transformFeedbackEnabled;
// Note: Quads aren't handled for verticesPerPrimitive, but verticesPerPrimitive is used for transform feedback,
// which is an OpenGL ES 3.0 feature, and OpenGL ES 3.0 doesn't support quads as a primitive type.
DrawType type = static_cast<DrawType>(static_cast<unsigned int>(drawType) & 0xF);
state.verticesPerPrimitive = 1 + (type >= DRAW_LINELIST) + (type >= DRAW_TRIANGLELIST);
for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{
state.input[i].type = context->input[i].type;
state.input[i].count = context->input[i].count;
state.input[i].normalized = context->input[i].normalized;
state.input[i].attribType = context->vertexShader ? context->vertexShader->getAttribType(i) : SpirvShader::ATTRIBTYPE_FLOAT;
}
for(unsigned int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++)
{
if(context->vertexShader->usesSampler(i))
{
state.sampler[i] = context->sampler[TEXTURE_IMAGE_UNITS + i].samplerState();
}
}
if(context->vertexShader) // FIXME: Also when pre-transformed?
{
for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{
state.output[i].xWrite = context->vertexShader->getOutput(i, 0).active();
state.output[i].yWrite = context->vertexShader->getOutput(i, 1).active();
state.output[i].zWrite = context->vertexShader->getOutput(i, 2).active();
state.output[i].wWrite = context->vertexShader->getOutput(i, 3).active();
}
}
state.hash = state.computeHash();
return state;
}
Routine *VertexProcessor::routine(const State &state)
{
Routine *routine = routineCache->query(state);
if(!routine) // Create one
{
VertexRoutine *generator = new VertexProgram(state, context->vertexShader);
generator->generate();
routine = (*generator)("VertexRoutine_%0.8X", state.shaderID);
delete generator;
routineCache->add(state, routine);
}
return routine;
}
}
| 27.681917
| 171
| 0.730364
|
opersys
|
deaf554618da92450e0202f4888b0d80121c7d80
| 8,133
|
cpp
|
C++
|
PlanetaMatchMakerServer/source/message/message_handlers/connection_test_request_message_handler.cpp
|
CdecPGL/PlanetaMatchMaker
|
59ade243cc3fab23a88edd10e2ef6d6238dcfcbe
|
[
"MIT"
] | 6
|
2019-08-15T09:48:55.000Z
|
2021-07-25T14:40:59.000Z
|
PlanetaMatchMakerServer/source/message/message_handlers/connection_test_request_message_handler.cpp
|
CdecPGL/PlanetaMatchMaker
|
59ade243cc3fab23a88edd10e2ef6d6238dcfcbe
|
[
"MIT"
] | 43
|
2019-12-25T14:54:52.000Z
|
2022-02-24T17:22:48.000Z
|
PlanetaMatchMakerServer/source/message/message_handlers/connection_test_request_message_handler.cpp
|
CdecPGL/PlanetaMatchMaker
|
59ade243cc3fab23a88edd10e2ef6d6238dcfcbe
|
[
"MIT"
] | 2
|
2020-05-06T20:14:44.000Z
|
2020-06-02T21:21:10.000Z
|
#include <vector>
#include <boost/asio.hpp>
#include "server/server_setting.hpp"
#include "session/session_data.hpp"
#include "logger/log.hpp"
#include "../message_parameter_validator.hpp"
#include "connection_test_request_message_handler.hpp"
using namespace std;
using namespace boost;
namespace pgl {
bool test_connection_tcp(message_handle_parameter& param, const asio::ip::tcp::endpoint& target_endpoint,
const std::string& test_text) {
const auto time_out_seconds = std::chrono::seconds(
param.server_setting.connection_test.connection_check_tcp_time_out_seconds);
// Try to establish TCP connection
asio::ip::tcp::socket socket(param.socket.get_executor());
execute_socket_timed_async_operation(socket, time_out_seconds,
[¶m, &socket, &target_endpoint]() { socket.async_connect(target_endpoint, param.yield); });
// Send test Text
execute_socket_timed_async_operation(socket, time_out_seconds,
[¶m, &socket, &test_text]() { async_write(socket, asio::buffer(test_text), param.yield); });
// Receive reply
std::string result_text;
execute_socket_timed_async_operation(socket, time_out_seconds,
[¶m, &socket, &test_text, &result_text]() {
asio::streambuf buffer;
async_read(socket, buffer, asio::transfer_exactly(test_text.length()), param.yield);
result_text = asio::buffer_cast<const char*>(buffer.data());
});
socket.close();
// Check the reply matches test text
if (result_text != test_text) {
log_with_endpoint(log_level::info, param.socket.remote_endpoint(), "Connect to ", target_endpoint,
" successfully, but target endpoint replied reply wrong message:\n expected message is \"", test_text,
"\", but received \"", result_text, "\".");
return false;
}
log_with_endpoint(log_level::info, param.socket.remote_endpoint(), "Connect to ",
target_endpoint, " successfully");
return true;
}
bool test_connection_udp(message_handle_parameter& param, const asio::ip::tcp::endpoint& target_endpoint,
const std::string& test_text) {
const auto time_out_seconds = std::chrono::seconds(
param.server_setting.connection_test.connection_check_udp_time_out_seconds);
const auto try_count = param.server_setting.connection_test.connection_check_udp_try_count;
// Try to send data by UDP and check if the reply is returned
asio::ip::udp::socket socket(param.socket.get_executor());
socket.open(param.socket.local_endpoint().protocol() == asio::ip::tcp::v4()
? asio::ip::udp::v4()
: asio::ip::udp::v6());
// Try several time because it is possible that data lost occurs in UDP
auto is_succeeded = true;
for (auto i = 0; i < try_count; ++i) {
try {
// Send test Text and receive reply
std::string result_text;
execute_socket_timed_async_operation(socket, time_out_seconds,
[¶m, &socket, &target_endpoint, &test_text, &result_text]() {
auto target_endpoint_udp = asio::ip::udp::endpoint(target_endpoint.address(),
target_endpoint.port());
socket.async_send_to(asio::buffer(test_text), target_endpoint_udp, param.yield);
// std::string::length() returns the length of a string without null character '\0' while the data sent and received includes '\0'.
// So We need to add 1 byte to std::string::length().
// Additionally, it is possible to receive data whose end character is not '\0' in UDP (data reception from unexpected host, data corruption in transporting, etc.)
// In such case, '\0' disappears and we can't determine the end of the string.
// To avoid unexpected behavior caused by this, we allocate more 1 byte to the buffer and overwrite the extra byte to '\0' after we receive data.
// Therefore, we set the length of buffer test_text.length() + 2.
//
// send: |---test_text.length()---|0| <- '\0' is included.
// receive: |----------data---------------...| <- it is possible to receive unexpected data in UDP.
// buffer: |---test_text.length()---|?|?| <- the buffer is overwritten by the received data and it is possible that '\0' doesn't exist.
// buffer: |---test_text.length()---|?|0| <- By putting '\0' to the end of the buffer, we avoid lack of null character.
std::vector<char> buffer_data(test_text.length() + 2);
const auto buffer = asio::buffer(buffer_data);
socket.async_receive_from(buffer, target_endpoint_udp, param.yield);
buffer_data[buffer_data.size() - 1] = '\0';
result_text = reinterpret_cast<const char*>(buffer_data.data());
});
// Check the reply matches test text
if (result_text != test_text) {
log_with_endpoint(log_level::info, param.socket.remote_endpoint(), "Connect to ", target_endpoint,
" successfully, but target endpoint replied reply wrong message:\n expected message is \"",
test_text, "\", but received \"", result_text, "\". (", i + 1, "/", try_count, " attempts)");
is_succeeded = false;
}
else {
is_succeeded = true;
break;
}
}
catch (const system::system_error& e) {
if (e.code() != asio::error::operation_aborted) { throw; }
is_succeeded = false;
log_with_endpoint(log_level::info, param.socket.remote_endpoint(), "Timed out to connect to ",
target_endpoint, ". (", i + 1, "/", try_count, " attempts)");
}
}
socket.close();
if (is_succeeded) {
log_with_endpoint(log_level::info, param.socket.remote_endpoint(), "Connect to ",
target_endpoint, " successfully");
}
else {
log_with_endpoint(log_level::info, param.socket.remote_endpoint(), "Failed to connect to ",
target_endpoint, ".");
}
return is_succeeded;
}
void connection_test_request_message_handler::handle_message(const connection_test_request_message& message,
std::shared_ptr<message_handle_parameter> param) {
const message_parameter_validator_with_reply<message_type::connection_test_reply, connection_test_reply_message>
parameter_validator(param);
// Check port number is valid
parameter_validator.validate_port_number(message.port_number);
connection_test_reply_message reply{
true
};
const auto target_endpoint = asio::ip::tcp::endpoint(
param->session_data.remote_endpoint().to_boost_endpoint().address(), message.port_number);
log_with_endpoint(log_level::info, param->socket.remote_endpoint(), "Start ", message.protocol,
" connectable test to ", target_endpoint, " with setting timeout ",
message.protocol == transport_protocol::tcp
? param->server_setting.connection_test.connection_check_tcp_time_out_seconds
: param->server_setting.connection_test.connection_check_udp_time_out_seconds, " seconds.");
try {
const std::string test_text = u8"Hello. This is PMMS.";
switch (message.protocol) {
case transport_protocol::tcp:
reply.succeed = test_connection_tcp(*param, target_endpoint, test_text);
break;
case transport_protocol::udp:
reply.succeed = test_connection_udp(*param, target_endpoint, test_text);
break;
default:
reply_message_header header{
message_type::connection_test_reply,
message_error_code::request_parameter_wrong
};
reply.succeed = false;
send(param, header, reply);
const auto error_message = minimal_serializer::generate_string("Indicated protocol \"",
static_cast<underlying_type_t<transport_protocol>>(message.protocol), "\" is invalid.");
throw server_session_error(server_session_error_code::continuable_error, error_message);
}
}
catch (const system::system_error& e) {
// disconnection by client is expected behavior (asio::error::eof)
if (e.code() != asio::error::eof) {
reply.succeed = false;
log_with_endpoint(log_level::info, param->socket.remote_endpoint(), "Failed to connect to ",
target_endpoint, ": ", e, "");
}
}
reply_message_header header{
message_type::connection_test_reply,
message_error_code::ok
};
log_with_endpoint(log_level::info, param->socket.remote_endpoint(), "Reply ",
message_type::connection_test_request, " message.");
send(param, header, reply);
}
}
| 43.491979
| 169
| 0.708595
|
CdecPGL
|
deafa692f4c074bed1d56cb11e90a761f0a6982f
| 8,569
|
hpp
|
C++
|
InstructionSets/M50740/Instruction.hpp
|
laurentd75/CLK
|
55dbeefeb2539541409265391ba9f7d70d89449e
|
[
"MIT"
] | 674
|
2016-05-05T18:47:48.000Z
|
2022-03-30T01:48:53.000Z
|
InstructionSets/M50740/Instruction.hpp
|
laurentd75/CLK
|
55dbeefeb2539541409265391ba9f7d70d89449e
|
[
"MIT"
] | 223
|
2016-05-11T13:45:11.000Z
|
2022-03-27T08:20:26.000Z
|
InstructionSets/M50740/Instruction.hpp
|
laurentd75/CLK
|
55dbeefeb2539541409265391ba9f7d70d89449e
|
[
"MIT"
] | 36
|
2017-11-24T18:07:52.000Z
|
2022-03-17T23:30:14.000Z
|
//
// Instruction.hpp
// Clock Signal
//
// Created by Thomas Harte on 15/01/21.
// Copyright © 2021 Thomas Harte. All rights reserved.
//
#ifndef InstructionSets_M50740_Instruction_h
#define InstructionSets_M50740_Instruction_h
#include <cstdint>
#include <iomanip>
#include <string>
#include <sstream>
#include "../AccessType.hpp"
namespace InstructionSet {
namespace M50740 {
enum class AddressingMode {
Implied, Accumulator, Immediate,
Absolute, AbsoluteX, AbsoluteY,
ZeroPage, ZeroPageX, ZeroPageY,
XIndirect, IndirectY,
Relative,
AbsoluteIndirect, ZeroPageIndirect,
SpecialPage,
ImmediateZeroPage,
AccumulatorRelative, ZeroPageRelative
};
static constexpr auto MaxAddressingMode = int(AddressingMode::ZeroPageRelative);
static constexpr auto MinAddressingMode = int(AddressingMode::Implied);
constexpr int size(AddressingMode mode) {
// This is coupled to the AddressingMode list above; be careful!
constexpr int sizes[] = {
0, 0, 1,
2, 2, 2,
1, 1, 1,
1, 1,
1,
2, 1,
1,
2,
1, 2
};
static_assert(sizeof(sizes)/sizeof(*sizes) == int(MaxAddressingMode) + 1);
return sizes[int(mode)];
}
enum class Operation: uint8_t {
Invalid,
// Operations that don't access memory.
BBC0, BBC1, BBC2, BBC3, BBC4, BBC5, BBC6, BBC7,
BBS0, BBS1, BBS2, BBS3, BBS4, BBS5, BBS6, BBS7,
BCC, BCS,
BEQ, BMI, BNE, BPL,
BVC, BVS, BRA, BRK,
JMP, JSR,
RTI, RTS,
CLC, CLD, CLI, CLT, CLV,
SEC, SED, SEI, SET,
INX, INY, DEX, DEY,
FST, SLW,
NOP,
PHA, PHP, PLA, PLP,
STP,
TAX, TAY, TSX, TXA,
TXS, TYA,
// Read operations.
ADC, SBC,
AND, ORA, EOR, BIT,
CMP, CPX, CPY,
LDA, LDX, LDY,
TST,
// Read-modify-write operations.
ASL, LSR,
CLB0, CLB1, CLB2, CLB3, CLB4, CLB5, CLB6, CLB7,
SEB0, SEB1, SEB2, SEB3, SEB4, SEB5, SEB6, SEB7,
COM,
DEC, INC,
ROL, ROR, RRF,
// Write operations.
LDM,
STA, STX, STY,
};
static constexpr auto MaxOperation = int(Operation::STY);
static constexpr auto MinOperation = int(Operation::BBC0);
constexpr AccessType access_type(Operation operation) {
if(operation < Operation::ADC) return AccessType::None;
if(operation < Operation::ASL) return AccessType::Read;
if(operation < Operation::LDM) return AccessType::ReadModifyWrite;
return AccessType::Write;
}
constexpr bool uses_index_mode(Operation operation) {
return
operation == Operation::ADC || operation == Operation::AND ||
operation == Operation::CMP || operation == Operation::EOR ||
operation == Operation::LDA || operation == Operation::ORA ||
operation == Operation::SBC;
}
/*!
@returns The name of @c operation.
*/
inline constexpr const char *operation_name(Operation operation) {
#define MAP(x) case Operation::x: return #x;
switch(operation) {
default: break;
MAP(BBC0); MAP(BBC1); MAP(BBC2); MAP(BBC3); MAP(BBC4); MAP(BBC5); MAP(BBC6); MAP(BBC7);
MAP(BBS0); MAP(BBS1); MAP(BBS2); MAP(BBS3); MAP(BBS4); MAP(BBS5); MAP(BBS6); MAP(BBS7);
MAP(BCC); MAP(BCS); MAP(BEQ); MAP(BMI); MAP(BNE); MAP(BPL); MAP(BVC); MAP(BVS);
MAP(BRA); MAP(BRK); MAP(JMP); MAP(JSR); MAP(RTI); MAP(RTS); MAP(CLC); MAP(CLD);
MAP(CLI); MAP(CLT); MAP(CLV); MAP(SEC); MAP(SED); MAP(SEI); MAP(SET); MAP(INX);
MAP(INY); MAP(DEX); MAP(DEY); MAP(FST); MAP(SLW); MAP(NOP); MAP(PHA); MAP(PHP);
MAP(PLA); MAP(PLP); MAP(STP); MAP(TAX); MAP(TAY); MAP(TSX); MAP(TXA); MAP(TXS);
MAP(TYA); MAP(ADC); MAP(SBC); MAP(AND); MAP(ORA); MAP(EOR); MAP(BIT); MAP(CMP);
MAP(CPX); MAP(CPY); MAP(LDA); MAP(LDX); MAP(LDY); MAP(TST); MAP(ASL); MAP(LSR);
MAP(CLB0); MAP(CLB1); MAP(CLB2); MAP(CLB3); MAP(CLB4); MAP(CLB5); MAP(CLB6); MAP(CLB7);
MAP(SEB0); MAP(SEB1); MAP(SEB2); MAP(SEB3); MAP(SEB4); MAP(SEB5); MAP(SEB6); MAP(SEB7);
MAP(COM); MAP(DEC); MAP(INC); MAP(ROL); MAP(ROR); MAP(RRF); MAP(LDM); MAP(STA);
MAP(STX); MAP(STY);
}
#undef MAP
return "???";
}
inline std::ostream &operator <<(std::ostream &stream, Operation operation) {
stream << operation_name(operation);
return stream;
}
/*!
@returns The name of @c addressing_mode.
*/
inline constexpr const char *addressing_mode_name(AddressingMode addressing_mode) {
switch(addressing_mode) {
default: break;
case AddressingMode::Implied: return "";
case AddressingMode::Accumulator: return "A";
case AddressingMode::Immediate: return "#";
case AddressingMode::Absolute: return "abs";
case AddressingMode::AbsoluteX: return "abs, x";
case AddressingMode::AbsoluteY: return "abs, y";
case AddressingMode::ZeroPage: return "zp";
case AddressingMode::ZeroPageX: return "zp, x";
case AddressingMode::ZeroPageY: return "zp, y";
case AddressingMode::XIndirect: return "((zp, x))";
case AddressingMode::IndirectY: return "((zp), y)";
case AddressingMode::Relative: return "rel";
case AddressingMode::AbsoluteIndirect: return "(abs)";
case AddressingMode::ZeroPageIndirect: return "(zp)";
case AddressingMode::SpecialPage: return "\\sp";
case AddressingMode::ImmediateZeroPage: return "#, zp";
case AddressingMode::AccumulatorRelative: return "A, rel";
case AddressingMode::ZeroPageRelative: return "zp, rel";
}
return "???";
}
inline std::ostream &operator <<(std::ostream &stream, AddressingMode mode) {
stream << addressing_mode_name(mode);
return stream;
}
/*!
@returns The way that the address for an operation with @c addressing_mode and encoded starting from @c operation
would appear in an assembler. E.g. '$5a' for that zero page address, or '$5a, x' for zero-page indexed from $5a. This function
may access up to three bytes from @c operation onwards.
*/
inline std::string address(AddressingMode addressing_mode, const uint8_t *operation, uint16_t program_counter) {
std::stringstream output;
output << std::hex;
#define NUM(x) std::setfill('0') << std::setw(2) << int(x)
#define NUM4(x) std::setfill('0') << std::setw(4) << int(x)
switch(addressing_mode) {
default: return "???";
case AddressingMode::Implied: return "";
case AddressingMode::Accumulator: return "A ";
case AddressingMode::Immediate: output << "#$" << NUM(operation[1]); break;
case AddressingMode::Absolute: output << "$" << NUM(operation[2]) << NUM(operation[1]); break;
case AddressingMode::AbsoluteX: output << "$" << NUM(operation[2]) << NUM(operation[1]) << ", x"; break;
case AddressingMode::AbsoluteY: output << "$" << NUM(operation[2]) << NUM(operation[1]) << ", y"; break;
case AddressingMode::ZeroPage: output << "$" << NUM(operation[1]); break;
case AddressingMode::ZeroPageX: output << "$" << NUM(operation[1]) << ", x"; break;
case AddressingMode::ZeroPageY: output << "$" << NUM(operation[1]) << ", y"; break;
case AddressingMode::XIndirect: output << "(($" << NUM(operation[1]) << ", x))"; break;
case AddressingMode::IndirectY: output << "(($" << NUM(operation[1]) << "), y)"; break;
case AddressingMode::Relative: output << "#$" << NUM4(2 + program_counter + int8_t(operation[1])); break;
case AddressingMode::AbsoluteIndirect: output << "($" << NUM(operation[2]) << NUM(operation[1]) << ") "; break;
case AddressingMode::ZeroPageIndirect: output << "($" << NUM(operation[1]) << ")"; break;
case AddressingMode::SpecialPage: output << "$1f" << NUM(operation[1]); break;
case AddressingMode::ImmediateZeroPage: output << "#$" << NUM(operation[1]) << ", $" << NUM(operation[2]); break;
case AddressingMode::AccumulatorRelative: output << "A, $" << NUM4(2 + program_counter + int8_t(operation[1])); break;
case AddressingMode::ZeroPageRelative:
output << "$" << NUM(operation[1]) << ", $" << NUM4(3 + program_counter + int8_t(operation[2]));
break;
}
#undef NUM4
#undef NUM
return output.str();
}
/*!
Models a complete M50740-style instruction, including its operation, addressing mode and opcode.
*/
struct Instruction {
Operation operation = Operation::Invalid;
AddressingMode addressing_mode = AddressingMode::Implied;
uint8_t opcode = 0;
Instruction(Operation operation, AddressingMode addressing_mode, uint8_t opcode) : operation(operation), addressing_mode(addressing_mode), opcode(opcode) {}
Instruction(uint8_t opcode) : opcode(opcode) {}
Instruction() {}
};
/*!
Outputs a description of @c instruction to @c stream.
*/
inline std::ostream &operator <<(std::ostream &stream, const Instruction &instruction) {
stream << operation_name(instruction.operation) << " " << addressing_mode_name(instruction.addressing_mode);
return stream;
}
}
}
#endif /* InstructionSets_M50740_Instruction_h */
| 35.263374
| 157
| 0.672541
|
laurentd75
|
deafac069c99f42491d0e3ac4d2d6c262a1bdb97
| 1,985
|
cpp
|
C++
|
lte/gateway/c/oai/lib/n11/SmfServiceClient.cpp
|
nitinneet/test23
|
c44df1a3290195cd3fc59d3483ef640ca8aaeb1e
|
[
"BSD-3-Clause"
] | 1
|
2021-08-08T15:49:05.000Z
|
2021-08-08T15:49:05.000Z
|
lte/gateway/c/oai/lib/n11/SmfServiceClient.cpp
|
nitinneet/test23
|
c44df1a3290195cd3fc59d3483ef640ca8aaeb1e
|
[
"BSD-3-Clause"
] | 151
|
2020-09-03T20:44:13.000Z
|
2022-03-31T20:28:52.000Z
|
lte/gateway/c/oai/lib/n11/SmfServiceClient.cpp
|
nitinneet/test23
|
c44df1a3290195cd3fc59d3483ef640ca8aaeb1e
|
[
"BSD-3-Clause"
] | 2
|
2021-05-27T18:15:16.000Z
|
2021-05-27T18:41:39.000Z
|
/**
* Copyright 2020 The Magma Authors.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "SmfServiceClient.h"
#include "ServiceRegistrySingleton.h"
#include <google/protobuf/util/time_util.h>
using grpc::Status;
namespace {
void SetAmfSessionContextRpcCallback(
grpc::Status status, magma::lte::SmContextVoid response) {
if (!status.ok()) {
std::cout << "AsyncSetAmfSessionContext fails with code "
<< status.error_code() << ", msg: " << status.error_message()
<< std::endl;
}
}
} // namespace
using namespace magma::lte;
namespace magma5g {
AsyncSmfServiceClient::AsyncSmfServiceClient(
std::shared_ptr<grpc::Channel> smf_srv_channel)
: stub_(AmfPduSessionSmContext::NewStub(smf_srv_channel)) {}
AsyncSmfServiceClient::AsyncSmfServiceClient()
: AsyncSmfServiceClient(
magma::ServiceRegistrySingleton::Instance()->GetGrpcChannel(
"sessiond", magma::ServiceRegistrySingleton::LOCAL)) {}
bool AsyncSmfServiceClient::set_smf_session(
const SetSMSessionContext& request) {
set_smf_session_rpc(request, SetAmfSessionContextRpcCallback);
return true;
}
void AsyncSmfServiceClient::set_smf_session_rpc(
const SetSMSessionContext& request,
std::function<void(Status, SmContextVoid)> callback) {
auto local_resp = new magma::AsyncLocalResponse<SmContextVoid>(
std::move(callback), RESPONSE_TIMEOUT);
local_resp->set_response_reader(std::move(stub_->AsyncSetAmfSessionContext(
local_resp->get_context(), request, &queue_)));
}
} // namespace magma5g
| 32.540984
| 77
| 0.738035
|
nitinneet
|
deb01d3a6b355ab470ed94ce35a2df080e5f3df1
| 160
|
cpp
|
C++
|
system/system.cpp
|
firngrod/firnlibs
|
a8fbdd22ec3b0a9497b809e8b86092e0affea995
|
[
"MIT"
] | null | null | null |
system/system.cpp
|
firngrod/firnlibs
|
a8fbdd22ec3b0a9497b809e8b86092e0affea995
|
[
"MIT"
] | null | null | null |
system/system.cpp
|
firngrod/firnlibs
|
a8fbdd22ec3b0a9497b809e8b86092e0affea995
|
[
"MIT"
] | null | null | null |
#include "system.hpp"
#include <thread>
namespace FirnLibs{ namespace System{
int GetProcessorCount()
{
return std::thread::hardware_concurrency();
}
}}
| 11.428571
| 45
| 0.725
|
firngrod
|
deb21c7ff38d279093e60fc31fdf79e46e950c16
| 7,714
|
cpp
|
C++
|
media_driver/agnostic/common/codec/hal/codechal_mmc_decode_vp8.cpp
|
xinfengz/media-driver
|
310104a4693c476a215de13e7e9fabdf2afbad0a
|
[
"Intel",
"BSD-3-Clause",
"MIT"
] | 1
|
2019-09-26T23:48:34.000Z
|
2019-09-26T23:48:34.000Z
|
media_driver/agnostic/common/codec/hal/codechal_mmc_decode_vp8.cpp
|
xinfengz/media-driver
|
310104a4693c476a215de13e7e9fabdf2afbad0a
|
[
"Intel",
"BSD-3-Clause",
"MIT"
] | null | null | null |
media_driver/agnostic/common/codec/hal/codechal_mmc_decode_vp8.cpp
|
xinfengz/media-driver
|
310104a4693c476a215de13e7e9fabdf2afbad0a
|
[
"Intel",
"BSD-3-Clause",
"MIT"
] | 1
|
2017-12-11T03:28:35.000Z
|
2017-12-11T03:28:35.000Z
|
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file codechal_mmc_decode_vp8.cpp
//! \brief Impelements the public interface for CodecHal Media Memory Compression
//!
#include "codechal_mmc_decode_vp8.h"
CodechalMmcDecodeVp8::CodechalMmcDecodeVp8(
CodechalHwInterface *hwInterface,
void *standardState):
CodecHalMmcState(hwInterface)
{
CODECHAL_DECODE_FUNCTION_ENTER;
m_vp8State = (CodechalDecodeVp8 *)standardState;
CODECHAL_HW_ASSERT(m_vp8State);
CODECHAL_HW_ASSERT(hwInterface);
CODECHAL_HW_ASSERT(hwInterface->GetSkuTable());
if (MEDIA_IS_SKU(hwInterface->GetSkuTable(), FtrMemoryCompression))
{
MOS_USER_FEATURE_VALUE_DATA userFeatureData;
MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
userFeatureData.i32Data = m_mmcEnabled;
userFeatureData.i32DataFlag = MOS_USER_FEATURE_VALUE_DATA_FLAG_CUSTOM_DEFAULT_VALUE_TYPE;
CodecHal_UserFeature_ReadValue(
nullptr,
__MEDIA_USER_FEATURE_VALUE_DECODE_MMC_ENABLE_ID,
&userFeatureData);
m_mmcEnabled = (userFeatureData.i32Data) ? true : false;
MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData;
MOS_ZeroMemory(&userFeatureWriteData, sizeof(userFeatureWriteData));
userFeatureWriteData.Value.i32Data = m_mmcEnabled;
userFeatureWriteData.ValueID = __MEDIA_USER_FEATURE_VALUE_DECODE_MMC_IN_USE_ID;
CodecHal_UserFeature_WriteValue(nullptr, &userFeatureWriteData);
}
#if (_DEBUG || _RELEASE_INTERNAL)
m_compressibleId = __MEDIA_USER_FEATURE_VALUE_MMC_DEC_RT_COMPRESSIBLE_ID;
m_compressModeId = __MEDIA_USER_FEATURE_VALUE_MMC_DEC_RT_COMPRESSMODE_ID;
#endif
}
MOS_STATUS CodechalMmcDecodeVp8::SetPipeBufAddr(
PMHW_VDBOX_PIPE_BUF_ADDR_PARAMS pipeBufAddrParams,
PMOS_COMMAND_BUFFER cmdBuffer)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
CODECHAL_DECODE_FUNCTION_ENTER;
// MMC is only enabled for frame decoding and no interlaced support in VP8
// So no need to check frame/field type here.
if (m_mmcEnabled && m_vp8State->sDestSurface.bCompressible)
{
if (m_vp8State->bDeblockingEnabled)
{
pipeBufAddrParams->PostDeblockSurfMmcState = MOS_MEMCOMP_HORIZONTAL;
}
else
{
pipeBufAddrParams->PreDeblockSurfMmcState = MOS_MEMCOMP_VERTICAL;
}
}
CODECHAL_DEBUG_TOOL(
m_vp8State->sDestSurface.MmcState = m_vp8State->bDeblockingEnabled ?
pipeBufAddrParams->PostDeblockSurfMmcState : pipeBufAddrParams->PreDeblockSurfMmcState;
)
return eStatus;
}
MOS_STATUS CodechalMmcDecodeVp8::SetRefrenceSync(
bool disableDecodeSyncLock,
bool disableLockForTranscode)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
CODECHAL_DECODE_FUNCTION_ENTER;
// Check if reference surface needs to be synchronized in MMC case
if (m_mmcEnabled)
{
MOS_SYNC_PARAMS syncParams = g_cInitSyncParams;
syncParams.GpuContext = m_vp8State->GetVideoContext();
syncParams.bDisableDecodeSyncLock = disableDecodeSyncLock;
syncParams.bDisableLockForTranscode = disableLockForTranscode;
if (m_vp8State->presLastRefSurface)
{
syncParams.presSyncResource = m_vp8State->presLastRefSurface;
syncParams.bReadOnly = true;
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnPerformOverlaySync(m_osInterface, &syncParams));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnResourceWait(m_osInterface, &syncParams));
m_osInterface->pfnSetResourceSyncTag(m_osInterface, &syncParams);
}
if (m_vp8State->presGoldenRefSurface)
{
syncParams.presSyncResource = m_vp8State->presGoldenRefSurface;
syncParams.bReadOnly = true;
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnPerformOverlaySync(m_osInterface, &syncParams));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnResourceWait(m_osInterface, &syncParams));
m_osInterface->pfnSetResourceSyncTag(m_osInterface, &syncParams);
}
if (m_vp8State->presAltRefSurface)
{
syncParams.presSyncResource = m_vp8State->presAltRefSurface;
syncParams.bReadOnly = true;
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnPerformOverlaySync(m_osInterface, &syncParams));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnResourceWait(m_osInterface, &syncParams));
m_osInterface->pfnSetResourceSyncTag(m_osInterface, &syncParams);
}
}
return eStatus;
}
MOS_STATUS CodechalMmcDecodeVp8::CheckReferenceList(
PMHW_VDBOX_PIPE_BUF_ADDR_PARAMS pipeBufAddrParams)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
CODECHAL_DECODE_FUNCTION_ENTER;
CODECHAL_DECODE_CHK_NULL_RETURN(pipeBufAddrParams);
CODECHAL_DECODE_CHK_NULL_RETURN(m_vp8State->pVp8PicParams);
// Disable MMC if self-reference is dectected for P/B frames (mainly for error concealment)
if ((pipeBufAddrParams->PostDeblockSurfMmcState != MOS_MEMCOMP_DISABLED ||
pipeBufAddrParams->PreDeblockSurfMmcState != MOS_MEMCOMP_DISABLED) &&
m_vp8State->pVp8PicParams->key_frame != I_TYPE)
{
bool selfReference = false;
if ((m_vp8State->pVp8PicParams->ucCurrPicIndex == m_vp8State->pVp8PicParams->ucLastRefPicIndex) ||
(m_vp8State->pVp8PicParams->ucCurrPicIndex == m_vp8State->pVp8PicParams->ucGoldenRefPicIndex) ||
(m_vp8State->pVp8PicParams->ucCurrPicIndex == m_vp8State->pVp8PicParams->ucAltRefPicIndex)
)
{
selfReference = true;
}
if (selfReference)
{
pipeBufAddrParams->PostDeblockSurfMmcState = MOS_MEMCOMP_DISABLED;
pipeBufAddrParams->PreDeblockSurfMmcState = MOS_MEMCOMP_DISABLED;
CODECHAL_DECODE_ASSERTMESSAGE("Self-reference is detected for P/B frames!");
// Decompress current frame to avoid green corruptions in this error handling case
MOS_MEMCOMP_STATE mmcMode;
CODECHAL_DECODE_CHK_STATUS_RETURN(
m_osInterface->pfnGetMemoryCompressionMode(
m_osInterface,
&m_vp8State->sDestSurface.OsResource,
&mmcMode));
if (mmcMode != MOS_MEMCOMP_DISABLED)
{
m_osInterface->pfnDecompResource(
m_osInterface,
&m_vp8State->sDestSurface.OsResource);
}
}
}
return eStatus;
}
| 39.558974
| 112
| 0.717267
|
xinfengz
|
deb2487da9f4648a10b685865133c036e41c6b66
| 2,191
|
cpp
|
C++
|
src/application_item.cpp
|
haiziyan/mayo
|
330099948bb8626a56d138c62509d85f7f0e1d94
|
[
"BSD-2-Clause"
] | null | null | null |
src/application_item.cpp
|
haiziyan/mayo
|
330099948bb8626a56d138c62509d85f7f0e1d94
|
[
"BSD-2-Clause"
] | null | null | null |
src/application_item.cpp
|
haiziyan/mayo
|
330099948bb8626a56d138c62509d85f7f0e1d94
|
[
"BSD-2-Clause"
] | 1
|
2022-03-10T03:28:53.000Z
|
2022-03-10T03:28:53.000Z
|
/****************************************************************************
** Copyright (c) 2019, Fougue Ltd. <http://www.fougue.pro>
** All rights reserved.
** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt
****************************************************************************/
#include "application_item.h"
namespace Mayo {
ApplicationItem::ApplicationItem(Document *doc)
: m_doc(doc),
m_docItem(nullptr),
m_docItemNode(DocumentItemNode::null())
{ }
ApplicationItem::ApplicationItem(DocumentItem *docItem)
: m_doc(nullptr),
m_docItem(docItem),
m_docItemNode(DocumentItemNode::null())
{ }
ApplicationItem::ApplicationItem(const DocumentItemNode &node)
: m_doc(nullptr),
m_docItem(nullptr),
m_docItemNode(node)
{ }
bool ApplicationItem::isValid() const {
return this->isDocument()
|| this->isDocumentItem()
|| this->isDocumentItemNode();
}
bool ApplicationItem::isDocument() const {
return m_doc != nullptr;
}
bool ApplicationItem::isDocumentItem() const {
return m_docItem != nullptr;
}
bool ApplicationItem::isDocumentItemNode() const {
return m_docItemNode.isValid();
}
Document* ApplicationItem::document() const
{
if (this->isDocument())
return m_doc;
else if (this->isDocumentItem())
return m_docItem->document();
else if (this->isDocumentItemNode())
return m_docItemNode.documentItem->document();
return nullptr;
}
DocumentItem* ApplicationItem::documentItem() const
{
if (this->isDocumentItem())
return m_docItem;
else if (this->isDocumentItemNode())
return m_docItemNode.documentItem;
return nullptr;
}
const DocumentItemNode& ApplicationItem::documentItemNode() const
{
return this->isDocumentItemNode() ?
m_docItemNode : DocumentItemNode::null();
}
bool ApplicationItem::operator==(const ApplicationItem &other) const
{
return m_doc == other.m_doc
&& m_docItem == other.m_docItem
&& m_docItemNode.documentItem == other.m_docItemNode.documentItem
&& m_docItemNode.id == other.m_docItemNode.id;
}
} // namespace Mayo
| 26.083333
| 77
| 0.63487
|
haiziyan
|
deb3ad230da2eba329dbd4910d6daf30c08d8689
| 2,017
|
cc
|
C++
|
StRoot/StMcEvent/StMcIstLadderHitCollection.cc
|
xiaohaijin/RHIC-STAR
|
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
|
[
"MIT"
] | 2
|
2018-12-24T19:37:00.000Z
|
2022-02-28T06:57:20.000Z
|
StRoot/StMcEvent/StMcIstLadderHitCollection.cc
|
xiaohaijin/RHIC-STAR
|
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
|
[
"MIT"
] | null | null | null |
StRoot/StMcEvent/StMcIstLadderHitCollection.cc
|
xiaohaijin/RHIC-STAR
|
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
|
[
"MIT"
] | null | null | null |
/***************************************************************************
*
*
* Author: Amilkar Quintero, Feb 2015
***************************************************************************
*
* Description: Monte Carlo Ist Ladder Hit Collection class
*
***************************************************************************
*
*
**************************************************************************/
#include "TBrowser.h"
#include "StMcIstLadderHitCollection.hh"
#include "StMcIstHit.hh"
static const char rcsid[] = "$Id: StMcIstLadderHitCollection.cc,v 2.1 2015/03/12 23:23:43 perev Exp $";
ClassImp(StMcIstLadderHitCollection)
//_____________________________________________________________________________
StMcIstLadderHitCollection::StMcIstLadderHitCollection() { /* noop */ }
//_____________________________________________________________________________
StMcIstLadderHitCollection::~StMcIstLadderHitCollection(){ Clear(); }
//_____________________________________________________________________________
void StMcIstLadderHitCollection::Clear(const char*)
{
/*for (int i=0; i<(int)mSensors.size(); i++)
{
delete mSensors[i]; mSensors[i] = 0;
}*/
//mSensors.clear();
}
//_____________________________________________________________________________
StMcIstSensorHitCollection* StMcIstLadderHitCollection::sensor(unsigned int i)
{
if (i < numberOfSensors())
return &(mSensors[i]);
else
return 0;
}
//_____________________________________________________________________________
const StMcIstSensorHitCollection* StMcIstLadderHitCollection::sensor(unsigned int i) const {
if (i < numberOfSensors())
return &(mSensors[i]);
else
return 0;
}
//_____________________________________________________________________________
unsigned long StMcIstLadderHitCollection::numberOfHits() const
{
unsigned long sum = 0;
for (unsigned int j=0; j<numberOfSensors(); j++) {
sum += mSensors[j].hits().size();
}
return sum;
}
| 34.186441
| 103
| 0.648488
|
xiaohaijin
|
deb3f64aa62ff8b78015a35cd2871c9c185f0ac7
| 250
|
inl
|
C++
|
node_modules/lzz-gyp/lzz-source/util_GetIdent.inl
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | 3
|
2019-09-18T16:44:33.000Z
|
2021-03-29T13:45:27.000Z
|
node_modules/lzz-gyp/lzz-source/util_GetIdent.inl
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | null | null | null |
node_modules/lzz-gyp/lzz-source/util_GetIdent.inl
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | 2
|
2019-03-29T01:06:38.000Z
|
2019-09-18T16:44:34.000Z
|
// util_GetIdent.inl
//
#ifdef LZZ_ENABLE_INLINE
#define LZZ_INLINE inline
#else
#define LZZ_INLINE
#endif
namespace util
{
LZZ_INLINE util::Ident getIdent (util::String const & str)
{
return getIdent (str.c_str ());
}
}
#undef LZZ_INLINE
| 14.705882
| 60
| 0.72
|
SuperDizor
|
630c2a572b4cfece5fbe93d893400196dc33c44d
| 870
|
cpp
|
C++
|
Chapter10/chapter10-7.cpp
|
kozborn/programing-principles-and-practise-using-cpp
|
7fefba8765e26af83f138e660861fe5b90adcda4
|
[
"MIT"
] | null | null | null |
Chapter10/chapter10-7.cpp
|
kozborn/programing-principles-and-practise-using-cpp
|
7fefba8765e26af83f138e660861fe5b90adcda4
|
[
"MIT"
] | null | null | null |
Chapter10/chapter10-7.cpp
|
kozborn/programing-principles-and-practise-using-cpp
|
7fefba8765e26af83f138e660861fe5b90adcda4
|
[
"MIT"
] | null | null | null |
#include "../std_lib_facilities.h"
void skip_to_int() {
if (cin.fail())
{
cin.clear();
char ch;
while (cin >> ch && !isdigit(ch));
if (!cin) error("Brak danych");
cin.unget();
}
}
int get_int() {
int n = 0;
while(true) {
if(cin >> n) return n;
cout << "That was not a number, please try again" << endl;
skip_to_int();
}
}
int get_int(int min, int max) {
int i = 0;
while(true) {
i = get_int();
if(min <= i && i <= max) return i;
cout << "Sorry, but " << i << " doesn't belong to [" << min << ", " << max << "]" << endl;
}
}
int main() {
try {
int i = 0;
cout << "Provide a number between 1 and 10" << endl;
while(true) {
i = get_int(1, 10);
}
} catch(...) {
cerr << "Something went wrong" << endl;
return 1;
}
return 0;
}
| 19.333333
| 95
| 0.472414
|
kozborn
|
630c477e15b064e58df18997b45b2ffc5d52c4b4
| 5,703
|
cpp
|
C++
|
main.cpp
|
SirDifferential/minimal_movidius
|
73dc436c6151c022963108fb82b9262a838b0d95
|
[
"MIT"
] | 1
|
2017-10-02T17:32:32.000Z
|
2017-10-02T17:32:32.000Z
|
main.cpp
|
SirDifferential/minimal_movidius
|
73dc436c6151c022963108fb82b9262a838b0d95
|
[
"MIT"
] | null | null | null |
main.cpp
|
SirDifferential/minimal_movidius
|
73dc436c6151c022963108fb82b9262a838b0d95
|
[
"MIT"
] | null | null | null |
#include <mvnc.h>
#include <vector>
#include <stdio.h>
#include <string>
#include <chrono>
#include <unistd.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include "movidiusdevice.h"
const int req_width = 227;
const int req_height = 227;
const bool show_perfs = false;
const bool show_results = false;
int runNetwork(const std::vector<std::string>& fnames,
const std::vector<unsigned char*>& images,
movidius_device* movidius_dev,
const std::string& networkPath)
{
std::chrono::high_resolution_clock::time_point t1;
std::chrono::high_resolution_clock::time_point t2;
std::chrono::high_resolution_clock::time_point t3;
strcpy(movidius_dev->networkPath, networkPath.c_str());
int ret = movidius_uploadNetwork(movidius_dev);
if (ret != 0)
{
fprintf(stderr, "Failed allocating graph: %d\n", ret);
return 1;
}
float* results = NULL;
if (movidius_dev->numCategories == 0)
{
fprintf(stderr, "no categories after loading network\n");
return 1;
}
results = new float[movidius_dev->numCategories];
memset(results, 0, sizeof(float) * movidius_dev->numCategories);
for (int c = 0; c < fnames.size(); c++)
{
t1 = std::chrono::high_resolution_clock::now();
if (movidius_convertImage((movidius_RGB*)images.at(c), req_width,req_height, movidius_dev) != 0)
{
fprintf(stderr, "failed converting image to 16bit float format\n");
return 1;
}
t2 = std::chrono::high_resolution_clock::now();
int ret = movidius_runInference(movidius_dev, results);
t3 = std::chrono::high_resolution_clock::now();
if (ret != 0)
{
fprintf(stderr, "runinference failure: %d for image %s\n", ret, fnames.at(c).c_str());
return 1;
}
auto dur1 = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1).count();
auto dur2 = std::chrono::duration_cast<std::chrono::microseconds>(t3 - t2).count();
if (show_perfs)
{
fprintf(stderr, "convertImage(): %d us\n", dur1);
fprintf(stderr, "runInference(): %d us\n", dur2);
}
if (show_results)
{
for (int cat = 0; cat < movidius_dev->numCategories; cat++)
{
fprintf(stderr, "category %d (%s): %f\n", cat, movidius_dev->categories[cat], results[cat]);
}
}
}
ret = movidius_deallocateGraph(movidius_dev);
if (ret != 0)
{
fprintf(stderr, "Failed deallocating graph: %d\n", ret);
return 1;
}
delete[] results;
results = NULL;
return 0;
}
int main(int argc, char** argv)
{
movidius_device movidius_dev;
memset(&movidius_dev, 0, sizeof(movidius_device));
if (movidius_openDevice(&movidius_dev) != 0)
return 1;
std::vector<unsigned char*> images;
std::vector<std::string> fnames;
fnames.push_back("./sample_1505732941144.png");
fnames.push_back("./sample_1505732942167.png");
fnames.push_back("./sample_1505732945220.png");
fnames.push_back("./sample_1505732946240.png");
fnames.push_back("./sample_1505732947259.png");
fnames.push_back("./sample_1505732948277.png");
fnames.push_back("./sample_1505732949297.png");
fnames.push_back("./sample_1505732952353.png");
// load images from disk
for (int c = 0; c < fnames.size(); c++)
{
int width, height, cp;
width = height = cp = 0;
unsigned char* img = stbi_load(fnames.at(c).c_str(), &width, &height, &cp, 3);
if (img == NULL)
{
fprintf(stderr, "The image %s could not be loaded\n", fnames.at(c).c_str());
return 1;
}
if (width != req_width || height != req_height)
{
fprintf(stderr, "Invalid size for image %s. Expected %d x %d, got %d x %d\n",
fnames.at(c).c_str(), width, height, req_width, req_height);
return 1;
}
images.push_back(img);
}
int loops = 0;
int loops_total = 4;
int ret = 0;
// run networks a few times
while (loops < loops_total)
{
loops++;
ret = runNetwork(fnames, images, &movidius_dev, "./network/Age");
if (ret != 0)
{
fprintf(stderr, "Age network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Gender");
if (ret != 0)
{
fprintf(stderr, "Gender network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Age");
if (ret != 0)
{
fprintf(stderr, "Age network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Gender");
if (ret != 0)
{
fprintf(stderr, "Gender network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Age");
if (ret != 0)
{
fprintf(stderr, "Age network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Gender");
if (ret != 0)
{
fprintf(stderr, "Gender network failed: %d\n", ret);
break;
}
fprintf(stderr, "Done with loop %d / %d\n", loops, loops_total);
}
for (int c = 0; c < images.size(); c++)
free(images.at(c));
images.clear();
movidius_closeDevice(&movidius_dev, false);
return ret;
}
| 28.373134
| 108
| 0.568122
|
SirDifferential
|
630ccbb7fa7933f8ff764374dfe0fcdd3e185951
| 866
|
cpp
|
C++
|
algorithms/cpp/328.cpp
|
viing937/leetcode
|
e21ca52c98bddf59e43522c0aace5e8cf84350eb
|
[
"MIT"
] | 3
|
2016-10-01T10:15:09.000Z
|
2017-07-09T02:53:36.000Z
|
algorithms/cpp/328.cpp
|
viing937/leetcode
|
e21ca52c98bddf59e43522c0aace5e8cf84350eb
|
[
"MIT"
] | null | null | null |
algorithms/cpp/328.cpp
|
viing937/leetcode
|
e21ca52c98bddf59e43522c0aace5e8cf84350eb
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
struct ListNode
{
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution
{
public:
ListNode* oddEvenList(ListNode* head)
{
if ( !head )
return head;
ListNode *even = NULL, *tail = NULL;
ListNode *curr = head;
int cnt = 0;
while ( curr->next )
{
cnt += 1;
if ( cnt%2 )
{
if ( !even )
even = tail = curr->next;
else
tail = tail->next = curr->next;
curr->next = curr->next->next;
}
else
curr = curr->next;
}
if ( tail )
tail->next = NULL;
curr->next = even;
return head;
}
};
int main()
{
return 0;
}
| 18.826087
| 51
| 0.415704
|
viing937
|
630dd83cf0445f77c13c3331f0456ccd41b83ff1
| 22,529
|
cpp
|
C++
|
src/tests/servers/app/newerClipping/drawing/AccelerantHWInterface.cpp
|
Kirishikesan/haiku
|
835565c55830f2dab01e6e332cc7e2d9c015b51e
|
[
"MIT"
] | 1,338
|
2015-01-03T20:06:56.000Z
|
2022-03-26T13:49:54.000Z
|
src/tests/servers/app/newerClipping/drawing/AccelerantHWInterface.cpp
|
Kirishikesan/haiku
|
835565c55830f2dab01e6e332cc7e2d9c015b51e
|
[
"MIT"
] | 15
|
2015-01-17T22:19:32.000Z
|
2021-12-20T12:35:00.000Z
|
src/tests/servers/app/newerClipping/drawing/AccelerantHWInterface.cpp
|
Kirishikesan/haiku
|
835565c55830f2dab01e6e332cc7e2d9c015b51e
|
[
"MIT"
] | 350
|
2015-01-08T14:15:27.000Z
|
2022-03-21T18:14:35.000Z
|
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Michael Lotz <mmlr@mlotz.ch>
* DarkWyrm <bpmagic@columbus.rr.com>
* Stephan Aßmus <superstippi@gmx.de>
*/
/** Accelerant based HWInterface implementation */
#include <new>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <Cursor.h>
#include <graphic_driver.h>
#include <FindDirectory.h>
#include <image.h>
#include <dirent.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "AccelerantHWInterface.h"
//#include "AccelerantBuffer.h"
//#include "MallocBuffer.h"
using std::nothrow;
#define DEBUG_DRIVER_MODULE
#ifdef DEBUG_DRIVER_MODULE
# include <stdio.h>
# define ATRACE(x) printf x
#else
# define ATRACE(x) ;
#endif
// constructor
AccelerantHWInterface::AccelerantHWInterface()
: //HWInterface(),
fCardFD(-1),
fAccelerantImage(-1),
fAccelerantHook(NULL),
fEngineToken(NULL),
fSyncToken(),
// required hooks
fAccAcquireEngine(NULL),
fAccReleaseEngine(NULL),
fAccSyncToToken(NULL),
fAccGetModeCount(NULL),
fAccGetModeList(NULL),
fAccGetFrameBufferConfig(NULL),
fAccSetDisplayMode(NULL),
fAccGetDisplayMode(NULL),
fAccGetPixelClockLimits(NULL),
// optional accelerant hooks
fAccGetTimingConstraints(NULL),
fAccProposeDisplayMode(NULL),
fAccFillRect(NULL),
fAccInvertRect(NULL),
fAccScreenBlit(NULL),
fAccSetCursorShape(NULL),
fAccMoveCursor(NULL),
fAccShowCursor(NULL)//,
// dpms hooks
/* fAccDPMSCapabilities(NULL),
fAccDPMSMode(NULL),
fAccSetDPMSMode(NULL),
fModeCount(0),
fModeList(NULL),*/
// fBackBuffer(NULL),
// fFrontBuffer(new(nothrow) AccelerantBuffer())
{
/* fDisplayMode.virtual_width = 640;
fDisplayMode.virtual_height = 480;
fDisplayMode.space = B_RGB32;*/
// NOTE: I have no clue what I'm doing here.
// fSyncToken.counter = 0;
// fSyncToken.engine_id = 0;
memset(&fSyncToken, 0, sizeof(sync_token));
}
// destructor
AccelerantHWInterface::~AccelerantHWInterface()
{
// delete fBackBuffer;
// delete fFrontBuffer;
// delete[] fModeList;
}
/*!
\brief Opens the first available graphics device and initializes it
\return B_OK on success or an appropriate error message on failure.
*/
status_t
AccelerantHWInterface::Initialize()
{
status_t ret = B_OK;//HWInterface::Initialize();
if (ret >= B_OK) {
for (int32 i = 1; fCardFD != B_ENTRY_NOT_FOUND; i++) {
fCardFD = _OpenGraphicsDevice(i);
if (fCardFD < 0) {
ATRACE(("Failed to open graphics device\n"));
continue;
}
if (_OpenAccelerant(fCardFD) == B_OK)
break;
close(fCardFD);
// _OpenAccelerant() failed, try to open next graphics card
}
return fCardFD >= 0 ? B_OK : fCardFD;
}
return ret;
}
/*!
\brief Opens a graphics device for read-write access
\param deviceNumber Number identifying which graphics card to open (1 for first card)
\return The file descriptor for the opened graphics device
The deviceNumber is relative to the number of graphics devices that can be successfully
opened. One represents the first card that can be successfully opened (not necessarily
the first one listed in the directory).
Graphics drivers must be able to be opened more than once, so we really get
the first working entry.
*/
int
AccelerantHWInterface::_OpenGraphicsDevice(int deviceNumber)
{
DIR *directory = opendir("/dev/graphics");
if (!directory)
return -1;
// ToDo: the former R5 "stub" driver is called "vesa" under Haiku; however,
// we do not need to avoid this driver this way when is has been ported
// to the new driver architecture - the special case here can then be
// removed.
int count = 0;
struct dirent *entry;
int current_card_fd = -1;
char path[PATH_MAX];
while (count < deviceNumber && (entry = readdir(directory)) != NULL) {
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..") ||
!strcmp(entry->d_name, "stub") || !strcmp(entry->d_name, "vesa"))
continue;
if (current_card_fd >= 0) {
close(current_card_fd);
current_card_fd = -1;
}
sprintf(path, "/dev/graphics/%s", entry->d_name);
current_card_fd = open(path, B_READ_WRITE);
if (current_card_fd >= 0)
count++;
}
// Open VESA driver if we were not able to get a better one
if (count < deviceNumber) {
if (deviceNumber == 1) {
sprintf(path, "/dev/graphics/vesa");
current_card_fd = open(path, B_READ_WRITE);
} else {
close(current_card_fd);
current_card_fd = B_ENTRY_NOT_FOUND;
}
}
fCardNameInDevFS = entry->d_name;
return current_card_fd;
}
status_t
AccelerantHWInterface::_OpenAccelerant(int device)
{
char signature[1024];
if (ioctl(device, B_GET_ACCELERANT_SIGNATURE,
&signature, sizeof(signature)) != B_OK)
return B_ERROR;
ATRACE(("accelerant signature is: %s\n", signature));
struct stat accelerant_stat;
const static directory_which dirs[] = {
B_USER_NONPACKAGED_ADDONS_DIRECTORY,
B_USER_ADDONS_DIRECTORY,
B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
B_SYSTEM_ADDONS_DIRECTORY
};
fAccelerantImage = -1;
for (int32 i = 0; i < sizeof(dirs) / sizeof(directory_which); i++) {
char path[PATH_MAX];
if (find_directory(dirs[i], -1, false, path, PATH_MAX) != B_OK)
continue;
strcat(path, "/accelerants/");
strcat(path, signature);
if (stat(path, &accelerant_stat) != 0)
continue;
fAccelerantImage = load_add_on(path);
if (fAccelerantImage >= 0) {
if (get_image_symbol(fAccelerantImage, B_ACCELERANT_ENTRY_POINT,
B_SYMBOL_TYPE_ANY, (void**)(&fAccelerantHook)) != B_OK ) {
ATRACE(("unable to get B_ACCELERANT_ENTRY_POINT\n"));
unload_add_on(fAccelerantImage);
fAccelerantImage = -1;
return B_ERROR;
}
accelerant_clone_info_size cloneInfoSize;
cloneInfoSize = (accelerant_clone_info_size)fAccelerantHook(B_ACCELERANT_CLONE_INFO_SIZE, NULL);
if (!cloneInfoSize) {
ATRACE(("unable to get B_ACCELERANT_CLONE_INFO_SIZE (%s)\n", path));
unload_add_on(fAccelerantImage);
fAccelerantImage = -1;
return B_ERROR;
}
ssize_t cloneSize = cloneInfoSize();
void* cloneInfoData = malloc(cloneSize);
// get_accelerant_clone_info getCloneInfo;
// getCloneInfo = (get_accelerant_clone_info)fAccelerantHook(B_GET_ACCELERANT_CLONE_INFO, NULL);
// if (!getCloneInfo) {
// ATRACE(("unable to get B_GET_ACCELERANT_CLONE_INFO (%s)\n", path));
// unload_add_on(fAccelerantImage);
// fAccelerantImage = -1;
// return B_ERROR;
// }
// printf("getCloneInfo: %p\n", getCloneInfo);
//
// getCloneInfo(cloneInfoData);
// TODO: this is what works for the ATI Radeon driver...
sprintf((char*)cloneInfoData, "graphics/%s", fCardNameInDevFS.String());
clone_accelerant cloneAccelerant;
cloneAccelerant = (clone_accelerant)fAccelerantHook(B_CLONE_ACCELERANT, NULL);
if (!cloneAccelerant) {
ATRACE(("unable to get B_CLONE_ACCELERANT\n"));
unload_add_on(fAccelerantImage);
fAccelerantImage = -1;
return B_ERROR;
}
status_t ret = cloneAccelerant(cloneInfoData);
if (ret != B_OK) {
ATRACE(("Cloning accelerant unsuccessful: %s\n", strerror(ret)));
unload_add_on(fAccelerantImage);
fAccelerantImage = -1;
return B_ERROR;
}
break;
}
}
if (fAccelerantImage < B_OK)
return B_ERROR;
if (_SetupDefaultHooks() != B_OK) {
ATRACE(("cannot setup default hooks\n"));
uninit_accelerant uninitAccelerant = (uninit_accelerant)
fAccelerantHook(B_UNINIT_ACCELERANT, NULL);
if (uninitAccelerant != NULL)
uninitAccelerant();
unload_add_on(fAccelerantImage);
return B_ERROR;
}
return B_OK;
}
status_t
AccelerantHWInterface::_SetupDefaultHooks()
{
// required
fAccAcquireEngine = (acquire_engine)fAccelerantHook(B_ACQUIRE_ENGINE, NULL);
fAccReleaseEngine = (release_engine)fAccelerantHook(B_RELEASE_ENGINE, NULL);
fAccSyncToToken = (sync_to_token)fAccelerantHook(B_SYNC_TO_TOKEN, NULL);
fAccGetModeCount = (accelerant_mode_count)fAccelerantHook(B_ACCELERANT_MODE_COUNT, NULL);
fAccGetModeList = (get_mode_list)fAccelerantHook(B_GET_MODE_LIST, NULL);
fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(B_GET_FRAME_BUFFER_CONFIG, NULL);
fAccSetDisplayMode = (set_display_mode)fAccelerantHook(B_SET_DISPLAY_MODE, NULL);
fAccGetDisplayMode = (get_display_mode)fAccelerantHook(B_GET_DISPLAY_MODE, NULL);
fAccGetPixelClockLimits = (get_pixel_clock_limits)fAccelerantHook(B_GET_PIXEL_CLOCK_LIMITS, NULL);
if (!fAccAcquireEngine || !fAccReleaseEngine || !fAccGetFrameBufferConfig
|| !fAccGetModeCount || !fAccGetModeList || !fAccSetDisplayMode
|| !fAccGetDisplayMode || !fAccGetPixelClockLimits) {
return B_ERROR;
}
// optional
fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(B_GET_TIMING_CONSTRAINTS, NULL);
fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(B_PROPOSE_DISPLAY_MODE, NULL);
// cursor
fAccSetCursorShape = (set_cursor_shape)fAccelerantHook(B_SET_CURSOR_SHAPE, NULL);
fAccMoveCursor = (move_cursor)fAccelerantHook(B_MOVE_CURSOR, NULL);
fAccShowCursor = (show_cursor)fAccelerantHook(B_SHOW_CURSOR, NULL);
// dpms
// fAccDPMSCapabilities = (dpms_capabilities)fAccelerantHook(B_DPMS_CAPABILITIES, NULL);
// fAccDPMSMode = (dpms_mode)fAccelerantHook(B_DPMS_MODE, NULL);
// fAccSetDPMSMode = (set_dpms_mode)fAccelerantHook(B_SET_DPMS_MODE, NULL);
// update acceleration hooks
// TODO: would actually have to pass a valid display_mode!
fAccFillRect = (fill_rectangle)fAccelerantHook(B_FILL_RECTANGLE, NULL);
fAccInvertRect = (invert_rectangle)fAccelerantHook(B_INVERT_RECTANGLE, NULL);
fAccScreenBlit = (screen_to_screen_blit)fAccelerantHook(B_SCREEN_TO_SCREEN_BLIT, NULL);
return B_OK;
}
// Shutdown
status_t
AccelerantHWInterface::Shutdown()
{
if (fAccelerantHook) {
uninit_accelerant UninitAccelerant = (uninit_accelerant)fAccelerantHook(B_UNINIT_ACCELERANT, NULL);
if (UninitAccelerant)
UninitAccelerant();
}
if (fAccelerantImage >= 0)
unload_add_on(fAccelerantImage);
if (fCardFD >= 0)
close(fCardFD);
return B_OK;
}
/*
// SetMode
status_t
AccelerantHWInterface::SetMode(const display_mode &mode)
{
AutoWriteLocker _(this);
// TODO: There are places this function can fail,
// maybe it needs to roll back changes in case of an
// error.
// prevent from doing the unnecessary
if (fModeCount > 0 && fBackBuffer && fFrontBuffer
&& fDisplayMode == mode) {
// TODO: better comparison of display modes
return B_OK;
}
// just try to set the mode - we let the graphics driver
// approve or deny the request, as it should know best
fDisplayMode = mode;
if (fAccSetDisplayMode(&fDisplayMode) != B_OK) {
ATRACE(("setting display mode failed\n"));
fAccGetDisplayMode(&fDisplayMode);
// We just keep the current mode and continue.
// Note, on startup, this may be different from
// what we think is the current display mode
}
// update frontbuffer
fFrontBuffer->SetDisplayMode(fDisplayMode);
if (_UpdateFrameBufferConfig() != B_OK)
return B_ERROR;
// Update the frame buffer used by the on-screen KDL
#ifdef __HAIKU__
uint32 depth = (fFrameBufferConfig.bytes_per_row / fDisplayMode.virtual_width) << 3;
if (fDisplayMode.space == B_RGB15)
depth = 15;
_kern_frame_buffer_update(fFrameBufferConfig.frame_buffer,
fDisplayMode.virtual_width, fDisplayMode.virtual_height,
depth, fFrameBufferConfig.bytes_per_row);
#endif
// update backbuffer if neccessary
if (!fBackBuffer || fBackBuffer->Width() != fDisplayMode.virtual_width
|| fBackBuffer->Height() != fDisplayMode.virtual_height) {
// NOTE: backbuffer is always B_RGBA32, this simplifies the
// drawing backend implementation tremendously for the time
// being. The color space conversion is handled in CopyBackToFront()
delete fBackBuffer;
fBackBuffer = NULL;
// TODO: Above not true anymore for single buffered mode!!!
// -> fall back to double buffer for fDisplayMode.space != B_RGB32
// as intermediate solution...
bool doubleBuffered = HWInterface::IsDoubleBuffered();
if ((color_space)fDisplayMode.space != B_RGB32 &&
(color_space)fDisplayMode.space != B_RGBA32)
doubleBuffered = true;
if (doubleBuffered) {
fBackBuffer = new(nothrow) MallocBuffer(fDisplayMode.virtual_width,
fDisplayMode.virtual_height);
status_t ret = fBackBuffer ? fBackBuffer->InitCheck() : B_NO_MEMORY;
if (ret < B_OK) {
delete fBackBuffer;
fBackBuffer = NULL;
return ret;
}
// clear out backbuffer, alpha is 255 this way
memset(fBackBuffer->Bits(), 255, fBackBuffer->BitsLength());
}
}
// update acceleration hooks
fAccFillRect = (fill_rectangle)fAccelerantHook(B_FILL_RECTANGLE, (void *)&fDisplayMode);
fAccInvertRect = (invert_rectangle)fAccelerantHook(B_INVERT_RECTANGLE,
(void *)&fDisplayMode);
fAccScreenBlit = (screen_to_screen_blit)fAccelerantHook(B_SCREEN_TO_SCREEN_BLIT,
(void *)&fDisplayMode);
return B_OK;
}
void
AccelerantHWInterface::GetMode(display_mode *mode)
{
if (mode && ReadLock()) {
*mode = fDisplayMode;
ReadUnlock();
}
}
status_t
AccelerantHWInterface::_UpdateModeList()
{
fModeCount = fAccGetModeCount();
if (fModeCount <= 0)
return B_ERROR;
delete[] fModeList;
fModeList = new(nothrow) display_mode[fModeCount];
if (!fModeList)
return B_NO_MEMORY;
if (fAccGetModeList(fModeList) != B_OK) {
ATRACE(("unable to get mode list\n"));
return B_ERROR;
}
return B_OK;
}
status_t
AccelerantHWInterface::_UpdateFrameBufferConfig()
{
if (fAccGetFrameBufferConfig(&fFrameBufferConfig) != B_OK) {
ATRACE(("unable to get frame buffer config\n"));
return B_ERROR;
}
fFrontBuffer->SetFrameBufferConfig(fFrameBufferConfig);
return B_OK;
}
status_t
AccelerantHWInterface::GetDeviceInfo(accelerant_device_info *info)
{
get_accelerant_device_info GetAccelerantDeviceInfo = (get_accelerant_device_info)fAccelerantHook(B_GET_ACCELERANT_DEVICE_INFO, NULL);
if (!GetAccelerantDeviceInfo) {
ATRACE(("No B_GET_ACCELERANT_DEVICE_INFO hook found\n"));
return B_UNSUPPORTED;
}
return GetAccelerantDeviceInfo(info);
}
status_t
AccelerantHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
{
config = fFrameBufferConfig;
return B_OK;
}
status_t
AccelerantHWInterface::GetModeList(display_mode** modes, uint32 *count)
{
AutoReadLocker _(this);
if (!count || !modes)
return B_BAD_VALUE;
status_t ret = fModeList ? B_OK : _UpdateModeList();
if (ret >= B_OK) {
*modes = new(nothrow) display_mode[fModeCount];
if (*modes) {
*count = fModeCount;
memcpy(*modes, fModeList, sizeof(display_mode) * fModeCount);
} else {
*count = 0;
ret = B_NO_MEMORY;
}
}
return ret;
}
status_t
AccelerantHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high)
{
AutoReadLocker _(this);
if (!mode || !low || !high)
return B_BAD_VALUE;
return fAccGetPixelClockLimits(mode, low, high);
}
status_t
AccelerantHWInterface::GetTimingConstraints(display_timing_constraints *dtc)
{
AutoReadLocker _(this);
if (!dtc)
return B_BAD_VALUE;
if (fAccGetTimingConstraints)
return fAccGetTimingConstraints(dtc);
return B_UNSUPPORTED;
}
status_t
AccelerantHWInterface::ProposeMode(display_mode *candidate, const display_mode *low, const display_mode *high)
{
AutoReadLocker _(this);
if (!candidate || !low || !high)
return B_BAD_VALUE;
if (!fAccProposeDisplayMode)
return B_UNSUPPORTED;
// avoid const issues
display_mode this_high, this_low;
this_high = *high;
this_low = *low;
return fAccProposeDisplayMode(candidate, &this_low, &this_high);
}
// RetraceSemaphore
sem_id
AccelerantHWInterface::RetraceSemaphore()
{
accelerant_retrace_semaphore AccelerantRetraceSemaphore = (accelerant_retrace_semaphore)fAccelerantHook(B_ACCELERANT_RETRACE_SEMAPHORE, NULL);
if (!AccelerantRetraceSemaphore)
return B_UNSUPPORTED;
return AccelerantRetraceSemaphore();
}
// WaitForRetrace
status_t
AccelerantHWInterface::WaitForRetrace(bigtime_t timeout)
{
AutoReadLocker _(this);
accelerant_retrace_semaphore AccelerantRetraceSemaphore = (accelerant_retrace_semaphore)fAccelerantHook(B_ACCELERANT_RETRACE_SEMAPHORE, NULL);
if (!AccelerantRetraceSemaphore)
return B_UNSUPPORTED;
sem_id sem = AccelerantRetraceSemaphore();
if (sem < 0)
return B_ERROR;
return acquire_sem_etc(sem, 1, B_RELATIVE_TIMEOUT, timeout);
}
// SetDPMSMode
status_t
AccelerantHWInterface::SetDPMSMode(const uint32 &state)
{
AutoWriteLocker _(this);
if (!fAccSetDPMSMode)
return B_UNSUPPORTED;
return fAccSetDPMSMode(state);
}
// DPMSMode
uint32
AccelerantHWInterface::DPMSMode()
{
AutoReadLocker _(this);
if (!fAccDPMSMode)
return B_UNSUPPORTED;
return fAccDPMSMode();
}
// DPMSCapabilities
uint32
AccelerantHWInterface::DPMSCapabilities()
{
AutoReadLocker _(this);
if (!fAccDPMSCapabilities)
return B_UNSUPPORTED;
return fAccDPMSCapabilities();
}
*/
// AvailableHardwareAcceleration
uint32
AccelerantHWInterface::AvailableHWAcceleration() const
{
uint32 flags = 0;
/* if (!IsDoubleBuffered()) {
if (fAccScreenBlit)
flags |= HW_ACC_COPY_REGION;
if (fAccFillRect)
flags |= HW_ACC_FILL_REGION;
if (fAccInvertRect)
flags |= HW_ACC_INVERT_REGION;
}*/
return flags;
}
// CopyRegion
void
AccelerantHWInterface::CopyRegion(const clipping_rect* sortedRectList,
uint32 count, int32 xOffset, int32 yOffset)
{
if (fAccScreenBlit && fAccAcquireEngine) {
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) {
// convert the rects
blit_params* params = new blit_params[count];
for (uint32 i = 0; i < count; i++) {
params[i].src_left = (uint16)sortedRectList[i].left;
params[i].src_top = (uint16)sortedRectList[i].top;
params[i].dest_left = (uint16)sortedRectList[i].left + xOffset;
params[i].dest_top = (uint16)sortedRectList[i].top + yOffset;
// NOTE: width and height are expressed as distance, not pixel count!
params[i].width = (uint16)(sortedRectList[i].right - sortedRectList[i].left);
params[i].height = (uint16)(sortedRectList[i].bottom - sortedRectList[i].top);
}
// go
fAccScreenBlit(fEngineToken, params, count);
// done
if (fAccReleaseEngine)
fAccReleaseEngine(fEngineToken, &fSyncToken);
// sync
if (fAccSyncToToken)
fAccSyncToToken(&fSyncToken);
delete[] params;
}
}
}
// FillRegion
void
AccelerantHWInterface::FillRegion(/*const*/ BRegion& region, const rgb_color& color)
{
if (fAccFillRect && fAccAcquireEngine) {
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) {
// convert the region
uint32 count;
fill_rect_params* fillParams;
_RegionToRectParams(®ion, &fillParams, &count);
// go
fAccFillRect(fEngineToken, _NativeColor(color), fillParams, count);
// done
if (fAccReleaseEngine)
fAccReleaseEngine(fEngineToken, &fSyncToken);
// sync
if (fAccSyncToToken)
fAccSyncToToken(&fSyncToken);
delete[] fillParams;
}
}
}
// InvertRegion
void
AccelerantHWInterface::InvertRegion(/*const*/ BRegion& region)
{
if (fAccInvertRect && fAccAcquireEngine) {
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) {
// convert the region
uint32 count;
fill_rect_params* fillParams;
_RegionToRectParams(®ion, &fillParams, &count);
// go
fAccInvertRect(fEngineToken, fillParams, count);
// done
if (fAccReleaseEngine)
fAccReleaseEngine(fEngineToken, &fSyncToken);
// sync
if (fAccSyncToToken)
fAccSyncToToken(&fSyncToken);
delete[] fillParams;
} else {
fprintf(stderr, "AcquireEngine failed!\n");
}
} else {
fprintf(stderr, "AccelerantHWInterface::InvertRegion() called, but hook not available!\n");
}
}
/*
// SetCursor
void
AccelerantHWInterface::SetCursor(ServerCursor* cursor)
{
HWInterface::SetCursor(cursor);
// if (WriteLock()) {
// TODO: implement setting the hard ware cursor
// NOTE: cursor should be always B_RGBA32
// NOTE: The HWInterface implementation should
// still be called, since it takes ownership of
// the cursor.
// WriteUnlock();
// }
}
// SetCursorVisible
void
AccelerantHWInterface::SetCursorVisible(bool visible)
{
HWInterface::SetCursorVisible(visible);
// if (WriteLock()) {
// TODO: update graphics hardware
// WriteUnlock();
// }
}
// MoveCursorTo
void
AccelerantHWInterface::MoveCursorTo(const float& x, const float& y)
{
HWInterface::MoveCursorTo(x, y);
// if (WriteLock()) {
// TODO: update graphics hardware
// WriteUnlock();
// }
}
// FrontBuffer
RenderingBuffer *
AccelerantHWInterface::FrontBuffer() const
{
if (!fModeList)
return NULL;
return fFrontBuffer;
}
// BackBuffer
RenderingBuffer *
AccelerantHWInterface::BackBuffer() const
{
if (!fModeList)
return NULL;
return fBackBuffer;
}
// IsDoubleBuffered
bool
AccelerantHWInterface::IsDoubleBuffered() const
{
if (fModeList)
return fBackBuffer != NULL;
return HWInterface::IsDoubleBuffered();
}
// _DrawCursor
void
AccelerantHWInterface::_DrawCursor(BRect area) const
{
// use the default implementation for now,
// until we have a hardware cursor
HWInterface::_DrawCursor(area);
// TODO: this would only be called, if we don't have
// a hardware cursor for some reason
}
*/
// _RegionToRectParams
void
AccelerantHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
fill_rect_params** params,
uint32* count) const
{
*count = region->CountRects();
*params = new fill_rect_params[*count];
for (uint32 i = 0; i < *count; i++) {
clipping_rect r = region->RectAtInt(i);
(*params)[i].left = (uint16)r.left;
(*params)[i].top = (uint16)r.top;
(*params)[i].right = (uint16)r.right;
(*params)[i].bottom = (uint16)r.bottom;
}
}
// _NativeColor
uint32
AccelerantHWInterface::_NativeColor(const rgb_color& c) const
{
// NOTE: This functions looks somehow suspicios to me.
// It assumes that all graphics cards have the same native endianess, no?
/* switch (fDisplayMode.space) {
case B_CMAP8:
case B_GRAY8:
return color.GetColor8();
case B_RGB15_BIG:
case B_RGBA15_BIG:
case B_RGB15_LITTLE:
case B_RGBA15_LITTLE:
return color.GetColor15();
case B_RGB16_BIG:
case B_RGB16_LITTLE:
return color.GetColor16();
case B_RGB32_BIG:
case B_RGBA32_BIG:
case B_RGB32_LITTLE:
case B_RGBA32_LITTLE: {
rgb_color c = color.GetColor32();
uint32 native = (c.alpha << 24) |
(c.red << 16) |
(c.green << 8) |
(c.blue);
return native;
}
}
return 0;*/
uint32 native = (c.alpha << 24) | (c.red << 16) | (c.green << 8) | (c.blue);
return native;
}
| 25.256726
| 143
| 0.731502
|
Kirishikesan
|
63142be5ffcd345413fc26a2e08c6b0ada98a8dd
| 2,474
|
hpp
|
C++
|
expression.hpp
|
910JQK/EasyCalculator
|
412904f6a28e10f409f723061638718941412919
|
[
"MIT"
] | null | null | null |
expression.hpp
|
910JQK/EasyCalculator
|
412904f6a28e10f409f723061638718941412919
|
[
"MIT"
] | null | null | null |
expression.hpp
|
910JQK/EasyCalculator
|
412904f6a28e10f409f723061638718941412919
|
[
"MIT"
] | null | null | null |
#ifndef EASY_CALCULATOR_EXPRESSION_PARSER_HPP
#define EASY_CALCULATOR_EXPRESSION_PARSER_HPP
#include <regex>
#include <string>
#include <vector>
#include <unordered_map>
namespace Expr {
extern const std::regex BLANK;
enum Associativity {
L, R
};
template <class T>
struct Operator {
Associativity assoc;
int priority;
bool unary;
union {
T (*exec)(const T &operand_left, const T &operand_right);
T (*exec_unary)(const T &operand);
};
Operator();
Operator(Associativity assoc_init, int priority_init, T (*exec_init)(const T &operand_left, const T &operand_right));
Operator(Associativity assoc_init, int priority_init, T (*exec_init)(const T &operand));
};
struct FunctionExpression {
std::string expr_condition;
std::string expr_value;
FunctionExpression(std::string condition, std::string value) {
expr_condition = condition;
expr_value = value;
}
};
template <class T>
struct Function {
int argc;
bool builtin;
T (*exec)(const std::vector<T> &argv);
std::vector<FunctionExpression> expr;
Function();
Function(T (*exec_function)(const std::vector<T> &argv), int num_args);
Function(const std::vector<FunctionExpression> &expressions, const std::vector<std::string> &args);
};
template <class T>
class Parser {
protected:
std::vector<T> empty_vector;
public:
Parser(T (*convert_function)(const std::string &str), std::string operator_chars_str_add = "");
~Parser();
std::unordered_map<std::string, Operator<T>> operators;
std::unordered_map<std::string, T> constants;
std::unordered_map<std::string, T> variables;
std::unordered_map<std::string, Function<T>> functions;
std::string operator_chars;
bool is_operator_char(char c);
T (*convert)(const std::string &str);
bool is_id_available(const std::string &id);
void set_const(const std::string &id, T value);
void set_var(const std::string &id, T value);
void set_function(const std::string &id, const std::vector<std::string> &conditions, const std::vector<std::string> &expressions, const std::vector<std::string> &arguments);
void unset(const std::string &id);
bool scientific_notation_enabled;
bool decimal_point_enabled;
bool blank_recheck_enabled;
T parse(const std::string &str);
T parse(std::string str, std::vector<T> &local_variables);
};
}
#endif /* EASY_CALCULATOR_EXPRESSION_PARSER_HPP */
| 33.432432
| 177
| 0.694422
|
910JQK
|
63167cdbb65ffc9ba73e31706bb4da5db6ed509d
| 360
|
hpp
|
C++
|
include/uitsl/mpi/MpiGuard.hpp
|
perryk12/conduit
|
3ea055312598353afd465536c8e04cdec1111c8c
|
[
"MIT"
] | null | null | null |
include/uitsl/mpi/MpiGuard.hpp
|
perryk12/conduit
|
3ea055312598353afd465536c8e04cdec1111c8c
|
[
"MIT"
] | 1
|
2020-10-22T20:41:05.000Z
|
2020-10-22T20:41:05.000Z
|
include/uitsl/mpi/MpiGuard.hpp
|
perryk12/conduit
|
3ea055312598353afd465536c8e04cdec1111c8c
|
[
"MIT"
] | null | null | null |
#pragma once
#ifndef UITSL_MPI_MPIGUARD_HPP_INCLUDE
#define UITSL_MPI_MPIGUARD_HPP_INCLUDE
#include <functional>
#include "audited_routines.hpp"
#include "mpi_utils.hpp"
namespace uitsl {
struct MpiGuard {
MpiGuard() { uitsl::mpi_init(); }
~MpiGuard() { UITSL_Finalize(); }
};
} // namespace uitsl
#endif // #ifndef UITSL_MPI_MPIGUARD_HPP_INCLUDE
| 15.652174
| 48
| 0.75
|
perryk12
|