blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8b9c6006aa1046f69c8000e30fb44a2792102c1b | 7d6aeb845b46acb61297618bb48964ee1e30a898 | /src/net.cpp | 68fd2cd726d81020bc3cf54d9f2c6b6020d72a31 | [
"MIT"
] | permissive | cactusbob/servx | 4955e7bedd98caa40636c668954016614a435c17 | 3c55a94452d60e2a74be226c8007c06ac121a12a | refs/heads/master | 2021-01-15T08:14:57.289691 | 2014-09-05T16:41:03 | 2014-09-05T16:41:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 64,522 | cpp | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "db.h"
#include "net.h"
#include "init.h"
#include "addrman.h"
#include "ui_interface.h"
#include "script.h"
#ifdef WIN32
#include <string.h>
#endif
#ifdef USE_UPNP
#include <miniupnpc/miniwget.h>
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#include <miniupnpc/upnperrors.h>
#endif
// Dump addresses to peers.dat every 15 minutes (900s)
#define DUMP_ADDRESSES_INTERVAL 900
using namespace std;
using namespace boost;
static const int MAX_OUTBOUND_CONNECTIONS = 8;
bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);
struct LocalServiceInfo {
int nScore;
int nPort;
};
//
// Global state variables
//
bool fDiscover = true;
uint64 nLocalServices = NODE_NETWORK;
static CCriticalSection cs_mapLocalHost;
static map<CNetAddr, LocalServiceInfo> mapLocalHost;
static bool vfReachable[NET_MAX] = {};
static bool vfLimited[NET_MAX] = {};
static CNode* pnodeLocalHost = NULL;
static CNode* pnodeSync = NULL;
uint64 nLocalHostNonce = 0;
static std::vector<SOCKET> vhListenSocket;
CAddrMan addrman;
int nMaxConnections = 125;
vector<CNode*> vNodes;
CCriticalSection cs_vNodes;
map<CInv, CDataStream> mapRelay;
deque<pair<int64, CInv> > vRelayExpiration;
CCriticalSection cs_mapRelay;
limitedmap<CInv, int64> mapAlreadyAskedFor(MAX_INV_SZ);
static deque<string> vOneShots;
CCriticalSection cs_vOneShots;
set<CNetAddr> setservAddNodeAddresses;
CCriticalSection cs_setservAddNodeAddresses;
vector<std::string> vAddedNodes;
CCriticalSection cs_vAddedNodes;
static CSemaphore *semOutbound = NULL;
void AddOneShot(string strDest)
{
LOCK(cs_vOneShots);
vOneShots.push_back(strDest);
}
unsigned short GetListenPort()
{
return (unsigned short)(GetArg("-port", GetDefaultPort()));
}
void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd)
{
// Filter out duplicate requests
if (pindexBegin == pindexLastGetBlocksBegin && hashEnd == hashLastGetBlocksEnd)
return;
pindexLastGetBlocksBegin = pindexBegin;
hashLastGetBlocksEnd = hashEnd;
PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd);
}
// find 'best' local address for a particular peer
bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
{
if (fNoListen)
return false;
int nBestScore = -1;
int nBestReachability = -1;
{
LOCK(cs_mapLocalHost);
for (map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++)
{
int nScore = (*it).second.nScore;
int nReachability = (*it).first.GetReachabilityFrom(paddrPeer);
if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
{
addr = CService((*it).first, (*it).second.nPort);
nBestReachability = nReachability;
nBestScore = nScore;
}
}
}
return nBestScore >= 0;
}
// get best local address for a particular peer as a CAddress
CAddress GetLocalAddress(const CNetAddr *paddrPeer)
{
CAddress ret(CService("0.0.0.0",0),0);
CService addr;
if (GetLocal(addr, paddrPeer))
{
ret = CAddress(addr);
ret.nServices = nLocalServices;
ret.nTime = GetAdjustedTime();
}
return ret;
}
bool RecvLine(SOCKET hSocket, string& strLine)
{
strLine = "";
loop
{
char c;
int nBytes = recv(hSocket, &c, 1, 0);
if (nBytes > 0)
{
if (c == '\n')
continue;
if (c == '\r')
return true;
strLine += c;
if (strLine.size() >= 9000)
return true;
}
else if (nBytes <= 0)
{
boost::this_thread::interruption_point();
if (nBytes < 0)
{
int nErr = WSAGetLastError();
if (nErr == WSAEMSGSIZE)
continue;
if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS)
{
MilliSleep(10);
continue;
}
}
if (!strLine.empty())
return true;
if (nBytes == 0)
{
// socket closed
printf("socket closed\n");
return false;
}
else
{
// socket error
int nErr = WSAGetLastError();
printf("recv failed: %d\n", nErr);
return false;
}
}
}
}
// used when scores of local addresses may have changed
// pushes better local address to peers
void static AdvertizeLocal()
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
if (pnode->fSuccessfullyConnected)
{
CAddress addrLocal = GetLocalAddress(&pnode->addr);
if (addrLocal.IsRoutable() && (CService)addrLocal != (CService)pnode->addrLocal)
{
pnode->PushAddress(addrLocal);
pnode->addrLocal = addrLocal;
}
}
}
}
void SetReachable(enum Network net, bool fFlag)
{
LOCK(cs_mapLocalHost);
vfReachable[net] = fFlag;
if (net == NET_IPV6 && fFlag)
vfReachable[NET_IPV4] = true;
}
// learn a new local address
bool AddLocal(const CService& addr, int nScore)
{
if (!addr.IsRoutable())
return false;
if (!fDiscover && nScore < LOCAL_MANUAL)
return false;
if (IsLimited(addr))
return false;
printf("AddLocal(%s,%i)\n", addr.ToString().c_str(), nScore);
{
LOCK(cs_mapLocalHost);
bool fAlready = mapLocalHost.count(addr) > 0;
LocalServiceInfo &info = mapLocalHost[addr];
if (!fAlready || nScore >= info.nScore) {
info.nScore = nScore + (fAlready ? 1 : 0);
info.nPort = addr.GetPort();
}
SetReachable(addr.GetNetwork());
}
AdvertizeLocal();
return true;
}
bool AddLocal(const CNetAddr &addr, int nScore)
{
return AddLocal(CService(addr, GetListenPort()), nScore);
}
/** Make a particular network entirely off-limits (no automatic connects to it) */
void SetLimited(enum Network net, bool fLimited)
{
if (net == NET_UNROUTABLE)
return;
LOCK(cs_mapLocalHost);
vfLimited[net] = fLimited;
}
bool IsLimited(enum Network net)
{
LOCK(cs_mapLocalHost);
return vfLimited[net];
}
bool IsLimited(const CNetAddr &addr)
{
return IsLimited(addr.GetNetwork());
}
/** vote for a local address */
bool SeenLocal(const CService& addr)
{
{
LOCK(cs_mapLocalHost);
if (mapLocalHost.count(addr) == 0)
return false;
mapLocalHost[addr].nScore++;
}
AdvertizeLocal();
return true;
}
/** check whether a given address is potentially local */
bool IsLocal(const CService& addr)
{
LOCK(cs_mapLocalHost);
return mapLocalHost.count(addr) > 0;
}
/** check whether a given address is in a network we can probably connect to */
bool IsReachable(const CNetAddr& addr)
{
LOCK(cs_mapLocalHost);
enum Network net = addr.GetNetwork();
return vfReachable[net] && !vfLimited[net];
}
bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const char* pszKeyword, CNetAddr& ipRet)
{
SOCKET hSocket;
if (!ConnectSocket(addrConnect, hSocket))
return error("GetMyExternalIP() : connection to %s failed", addrConnect.ToString().c_str());
send(hSocket, pszGet, strlen(pszGet), MSG_NOSIGNAL);
string strLine;
while (RecvLine(hSocket, strLine))
{
if (strLine.empty()) // HTTP response is separated from headers by blank line
{
loop
{
if (!RecvLine(hSocket, strLine))
{
closesocket(hSocket);
return false;
}
if (pszKeyword == NULL)
break;
if (strLine.find(pszKeyword) != string::npos)
{
strLine = strLine.substr(strLine.find(pszKeyword) + strlen(pszKeyword));
break;
}
}
closesocket(hSocket);
if (strLine.find("<") != string::npos)
strLine = strLine.substr(0, strLine.find("<"));
strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r"));
while (strLine.size() > 0 && isspace(strLine[strLine.size()-1]))
strLine.resize(strLine.size()-1);
CService addr(strLine,0,true);
printf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str());
if (!addr.IsValid() || !addr.IsRoutable())
return false;
ipRet.SetIP(addr);
return true;
}
}
closesocket(hSocket);
return error("GetMyExternalIP() : connection closed");
}
bool GetMyExternalIP(CNetAddr& ipRet)
{
CService addrConnect;
const char* pszGet;
const char* pszKeyword;
for (int nLookup = 0; nLookup <= 1; nLookup++)
for (int nHost = 1; nHost <= 2; nHost++)
{
// We should be phasing out our use of sites like these. If we need
// replacements, we should ask for volunteers to put this simple
// php file on their web server that prints the client IP:
// <?php echo $_SERVER["REMOTE_ADDR"]; ?>
if (nHost == 1)
{
addrConnect = CService("91.198.22.70", 80); // checkip.dyndns.org
if (nLookup == 1)
{
CService addrIP("checkip.dyndns.org", 80, true);
if (addrIP.IsValid())
addrConnect = addrIP;
}
pszGet = "GET / HTTP/1.1\r\n"
"Host: checkip.dyndns.org\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n"
"Connection: close\r\n"
"\r\n";
pszKeyword = "Address:";
}
else if (nHost == 2)
{
addrConnect = CService("74.208.43.192", 80); // www.showmyip.com
if (nLookup == 1)
{
CService addrIP("www.showmyip.com", 80, true);
if (addrIP.IsValid())
addrConnect = addrIP;
}
pszGet = "GET /simple/ HTTP/1.1\r\n"
"Host: www.showmyip.com\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n"
"Connection: close\r\n"
"\r\n";
pszKeyword = NULL; // Returns just IP address
}
if (GetMyExternalIP2(addrConnect, pszGet, pszKeyword, ipRet))
return true;
}
return false;
}
void ThreadGetMyExternalIP(void* parg)
{
// Make this thread recognisable as the external IP detection thread
RenameThread("bitcoin-ext-ip");
CNetAddr addrLocalHost;
if (GetMyExternalIP(addrLocalHost))
{
printf("GetMyExternalIP() returned %s\n", addrLocalHost.ToStringIP().c_str());
AddLocal(addrLocalHost, LOCAL_HTTP);
}
}
void AddressCurrentlyConnected(const CService& addr)
{
addrman.Connected(addr);
}
CNode* FindNode(const CNetAddr& ip)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
if ((CNetAddr)pnode->addr == ip)
return (pnode);
return NULL;
}
CNode* FindNode(std::string addrName)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
if (pnode->addrName == addrName)
return (pnode);
return NULL;
}
CNode* FindNode(const CService& addr)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
if ((CService)pnode->addr == addr)
return (pnode);
return NULL;
}
CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
{
if (pszDest == NULL) {
if (IsLocal(addrConnect))
return NULL;
// Look for an existing connection
CNode* pnode = FindNode((CService)addrConnect);
if (pnode)
{
pnode->AddRef();
return pnode;
}
}
/// debug print
printf("trying connection %s lastseen=%.1fhrs\n",
pszDest ? pszDest : addrConnect.ToString().c_str(),
pszDest ? 0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0);
// Connect
SOCKET hSocket;
if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, GetDefaultPort()) : ConnectSocket(addrConnect, hSocket))
{
addrman.Attempt(addrConnect);
/// debug print
printf("connected %s\n", pszDest ? pszDest : addrConnect.ToString().c_str());
// Set to non-blocking
#ifdef WIN32
u_long nOne = 1;
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR)
printf("ConnectSocket() : ioctlsocket non-blocking setting failed, error %d\n", WSAGetLastError());
#else
if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
printf("ConnectSocket() : fcntl non-blocking setting failed, error %d\n", errno);
#endif
// Add node
CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false);
pnode->AddRef();
{
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}
pnode->nTimeConnected = GetTime();
return pnode;
}
else
{
return NULL;
}
}
void CNode::CloseSocketDisconnect()
{
fDisconnect = true;
if (hSocket != INVALID_SOCKET)
{
printf("disconnecting node %s\n", addrName.c_str());
closesocket(hSocket);
hSocket = INVALID_SOCKET;
}
// in case this fails, we'll empty the recv buffer when the CNode is deleted
TRY_LOCK(cs_vRecvMsg, lockRecv);
if (lockRecv)
vRecvMsg.clear();
// if this was the sync node, we'll need a new one
if (this == pnodeSync)
pnodeSync = NULL;
}
void CNode::Cleanup()
{
}
void CNode::PushVersion()
{
/// when NTP implemented, change to just nTime = GetAdjustedTime()
int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
CAddress addrMe = GetLocalAddress(&addr);
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
printf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), addr.ToString().c_str());
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight);
}
std::map<CNetAddr, int64> CNode::setBanned;
CCriticalSection CNode::cs_setBanned;
void CNode::ClearBanned()
{
setBanned.clear();
}
bool CNode::IsBanned(CNetAddr ip)
{
bool fResult = false;
{
LOCK(cs_setBanned);
std::map<CNetAddr, int64>::iterator i = setBanned.find(ip);
if (i != setBanned.end())
{
int64 t = (*i).second;
if (GetTime() < t)
fResult = true;
}
}
return fResult;
}
bool CNode::Misbehaving(int howmuch)
{
if (addr.IsLocal())
{
printf("Warning: Local node %s misbehaving (delta: %d)!\n", addrName.c_str(), howmuch);
return false;
}
nMisbehavior += howmuch;
if (nMisbehavior >= GetArg("-banscore", 100))
{
int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
printf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
{
LOCK(cs_setBanned);
if (setBanned[addr] < banTime)
setBanned[addr] = banTime;
}
CloseSocketDisconnect();
return true;
} else
printf("Misbehaving: %s (%d -> %d)\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
return false;
}
#undef X
#define X(name) stats.name = name
void CNode::copyStats(CNodeStats &stats)
{
X(nServices);
X(nLastSend);
X(nLastRecv);
X(nTimeConnected);
X(addrName);
X(nVersion);
X(cleanSubVer);
X(fInbound);
X(nStartingHeight);
X(nMisbehavior);
X(nSendBytes);
X(nRecvBytes);
X(nBlocksRequested);
stats.fSyncNode = (this == pnodeSync);
}
#undef X
// requires LOCK(cs_vRecvMsg)
bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
{
while (nBytes > 0) {
// get current incomplete message, or create a new one
if (vRecvMsg.empty() ||
vRecvMsg.back().complete())
vRecvMsg.push_back(CNetMessage(SER_NETWORK, nRecvVersion));
CNetMessage& msg = vRecvMsg.back();
// absorb network data
int handled;
if (!msg.in_data)
handled = msg.readHeader(pch, nBytes);
else
handled = msg.readData(pch, nBytes);
if (handled < 0)
return false;
pch += handled;
nBytes -= handled;
}
return true;
}
int CNetMessage::readHeader(const char *pch, unsigned int nBytes)
{
// copy data to temporary parsing buffer
unsigned int nRemaining = 24 - nHdrPos;
unsigned int nCopy = std::min(nRemaining, nBytes);
memcpy(&hdrbuf[nHdrPos], pch, nCopy);
nHdrPos += nCopy;
// if header incomplete, exit
if (nHdrPos < 24)
return nCopy;
// deserialize to CMessageHeader
try {
hdrbuf >> hdr;
}
catch (std::exception &e) {
return -1;
}
// reject messages larger than MAX_SIZE
if (hdr.nMessageSize > MAX_SIZE)
return -1;
// switch state to reading message data
in_data = true;
vRecv.resize(hdr.nMessageSize);
return nCopy;
}
int CNetMessage::readData(const char *pch, unsigned int nBytes)
{
unsigned int nRemaining = hdr.nMessageSize - nDataPos;
unsigned int nCopy = std::min(nRemaining, nBytes);
memcpy(&vRecv[nDataPos], pch, nCopy);
nDataPos += nCopy;
return nCopy;
}
// requires LOCK(cs_vSend)
void SocketSendData(CNode *pnode)
{
std::deque<CSerializeData>::iterator it = pnode->vSendMsg.begin();
while (it != pnode->vSendMsg.end()) {
const CSerializeData &data = *it;
assert(data.size() > pnode->nSendOffset);
int nBytes = send(pnode->hSocket, &data[pnode->nSendOffset], data.size() - pnode->nSendOffset, MSG_NOSIGNAL | MSG_DONTWAIT);
if (nBytes > 0) {
pnode->nLastSend = GetTime();
pnode->nSendBytes += nBytes;
pnode->nSendOffset += nBytes;
if (pnode->nSendOffset == data.size()) {
pnode->nSendOffset = 0;
pnode->nSendSize -= data.size();
it++;
} else {
// could not send full message; stop sending more
break;
}
} else {
if (nBytes < 0) {
// error
int nErr = WSAGetLastError();
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
{
printf("socket send error %d\n", nErr);
pnode->CloseSocketDisconnect();
}
}
// couldn't send anything at all
break;
}
}
if (it == pnode->vSendMsg.end()) {
assert(pnode->nSendOffset == 0);
assert(pnode->nSendSize == 0);
}
pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it);
}
static list<CNode*> vNodesDisconnected;
void ThreadSocketHandler()
{
unsigned int nPrevNodeCount = 0;
loop
{
//
// Disconnect nodes
//
{
LOCK(cs_vNodes);
// Disconnect unused nodes
vector<CNode*> vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy)
{
if (pnode->fDisconnect ||
(pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty()))
{
// remove from vNodes
vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end());
// release outbound grant (if any)
pnode->grantOutbound.Release();
// close socket and cleanup
pnode->CloseSocketDisconnect();
pnode->Cleanup();
// hold in disconnected pool until all refs are released
if (pnode->fNetworkNode || pnode->fInbound)
pnode->Release();
vNodesDisconnected.push_back(pnode);
}
}
// Delete disconnected nodes
list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;
BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy)
{
// wait until threads are done using it
if (pnode->GetRefCount() <= 0)
{
bool fDelete = false;
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend)
{
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
if (lockRecv)
{
TRY_LOCK(pnode->cs_inventory, lockInv);
if (lockInv)
fDelete = true;
}
}
}
if (fDelete)
{
vNodesDisconnected.remove(pnode);
delete pnode;
}
}
}
}
if (vNodes.size() != nPrevNodeCount)
{
nPrevNodeCount = vNodes.size();
uiInterface.NotifyNumConnectionsChanged(vNodes.size());
}
//
// Find which sockets have data to receive
//
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 50000; // frequency to poll pnode->vSend
fd_set fdsetRecv;
fd_set fdsetSend;
fd_set fdsetError;
FD_ZERO(&fdsetRecv);
FD_ZERO(&fdsetSend);
FD_ZERO(&fdsetError);
SOCKET hSocketMax = 0;
bool have_fds = false;
BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) {
FD_SET(hListenSocket, &fdsetRecv);
hSocketMax = max(hSocketMax, hListenSocket);
have_fds = true;
}
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
if (pnode->hSocket == INVALID_SOCKET)
continue;
FD_SET(pnode->hSocket, &fdsetError);
hSocketMax = max(hSocketMax, pnode->hSocket);
have_fds = true;
// Implement the following logic:
// * If there is data to send, select() for sending data. As this only
// happens when optimistic write failed, we choose to first drain the
// write buffer in this case before receiving more. This avoids
// needlessly queueing received data, if the remote peer is not themselves
// receiving data. This means properly utilizing TCP flow control signalling.
// * Otherwise, if there is no (complete) message in the receive buffer,
// or there is space left in the buffer, select() for receiving data.
// * (if neither of the above applies, there is certainly one message
// in the receiver buffer ready to be processed).
// Together, that means that at least one of the following is always possible,
// so we don't deadlock:
// * We send some data.
// * We wait for data to be received (and disconnect after timeout).
// * We process a message in the buffer (message handler thread).
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend && !pnode->vSendMsg.empty()) {
FD_SET(pnode->hSocket, &fdsetSend);
continue;
}
}
{
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
if (lockRecv && (
pnode->vRecvMsg.empty() || !pnode->vRecvMsg.front().complete() ||
pnode->GetTotalRecvSize() <= ReceiveFloodSize()))
FD_SET(pnode->hSocket, &fdsetRecv);
}
}
}
int nSelect = select(have_fds ? hSocketMax + 1 : 0,
&fdsetRecv, &fdsetSend, &fdsetError, &timeout);
boost::this_thread::interruption_point();
if (nSelect == SOCKET_ERROR)
{
if (have_fds)
{
int nErr = WSAGetLastError();
printf("socket select error %d\n", nErr);
for (unsigned int i = 0; i <= hSocketMax; i++)
FD_SET(i, &fdsetRecv);
}
FD_ZERO(&fdsetSend);
FD_ZERO(&fdsetError);
MilliSleep(timeout.tv_usec/1000);
}
//
// Accept new connections
//
BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket)
if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv))
{
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
#else
struct sockaddr sockaddr;
#endif
socklen_t len = sizeof(sockaddr);
SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len);
CAddress addr;
int nInbound = 0;
if (hSocket != INVALID_SOCKET)
if (!addr.SetSockAddr((const struct sockaddr*)&sockaddr))
printf("Warning: Unknown socket family\n");
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
if (pnode->fInbound)
nInbound++;
}
if (hSocket == INVALID_SOCKET)
{
int nErr = WSAGetLastError();
if (nErr != WSAEWOULDBLOCK)
printf("socket error accept failed: %d\n", nErr);
}
else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS)
{
{
LOCK(cs_setservAddNodeAddresses);
if (!setservAddNodeAddresses.count(addr))
closesocket(hSocket);
}
}
else if (CNode::IsBanned(addr))
{
printf("connection from %s dropped (banned)\n", addr.ToString().c_str());
closesocket(hSocket);
}
else
{
printf("accepted connection %s\n", addr.ToString().c_str());
CNode* pnode = new CNode(hSocket, addr, "", true);
pnode->AddRef();
{
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}
}
}
//
// Service each socket
//
vector<CNode*> vNodesCopy;
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->AddRef();
}
BOOST_FOREACH(CNode* pnode, vNodesCopy)
{
boost::this_thread::interruption_point();
//
// Receive
//
if (pnode->hSocket == INVALID_SOCKET)
continue;
if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError))
{
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
if (lockRecv)
{
{
// typical socket buffer is 8K-64K
char pchBuf[0x10000];
int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);
if (nBytes > 0)
{
if (!pnode->ReceiveMsgBytes(pchBuf, nBytes))
pnode->CloseSocketDisconnect();
pnode->nLastRecv = GetTime();
pnode->nRecvBytes += nBytes;
}
else if (nBytes == 0)
{
// socket closed gracefully
if (!pnode->fDisconnect)
printf("socket closed\n");
pnode->CloseSocketDisconnect();
}
else if (nBytes < 0)
{
// error
int nErr = WSAGetLastError();
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
{
if (!pnode->fDisconnect)
printf("socket recv error %d\n", nErr);
pnode->CloseSocketDisconnect();
}
}
}
}
}
//
// Send
//
if (pnode->hSocket == INVALID_SOCKET)
continue;
if (FD_ISSET(pnode->hSocket, &fdsetSend))
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend)
SocketSendData(pnode);
}
//
// Inactivity checking
//
if (pnode->vSendMsg.empty())
pnode->nLastSendEmpty = GetTime();
if (GetTime() - pnode->nTimeConnected > 60)
{
if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
{
printf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0);
pnode->fDisconnect = true;
}
else if (GetTime() - pnode->nLastSend > 90*60 && GetTime() - pnode->nLastSendEmpty > 90*60)
{
printf("socket not sending\n");
pnode->fDisconnect = true;
}
else if (GetTime() - pnode->nLastRecv > 90*60)
{
printf("socket inactivity timeout\n");
pnode->fDisconnect = true;
}
}
}
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->Release();
}
MilliSleep(10);
}
}
#ifdef USE_UPNP
void ThreadMapPort()
{
std::string port = strprintf("%u", GetListenPort());
const char * multicastif = 0;
const char * minissdpdpath = 0;
struct UPNPDev * devlist = 0;
char lanaddr[64];
#ifndef UPNPDISCOVER_SUCCESS
/* miniupnpc 1.5 */
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0);
#else
/* miniupnpc 1.6 */
int error = 0;
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error);
#endif
struct UPNPUrls urls;
struct IGDdatas data;
int r;
r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
if (r == 1)
{
if (fDiscover) {
char externalIPAddress[40];
r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress);
if(r != UPNPCOMMAND_SUCCESS)
printf("UPnP: GetExternalIPAddress() returned %d\n", r);
else
{
if(externalIPAddress[0])
{
printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress);
AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP);
}
else
printf("UPnP: GetExternalIPAddress failed.\n");
}
}
string strDesc = "Servx " + FormatFullVersion();
try {
loop {
#ifndef UPNPDISCOVER_SUCCESS
/* miniupnpc 1.5 */
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0);
#else
/* miniupnpc 1.6 */
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0");
#endif
if(r!=UPNPCOMMAND_SUCCESS)
printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
port.c_str(), port.c_str(), lanaddr, r, strupnperror(r));
else
printf("UPnP Port Mapping successful.\n");;
MilliSleep(20*60*1000); // Refresh every 20 minutes
}
}
catch (boost::thread_interrupted)
{
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
printf("UPNP_DeletePortMapping() returned : %d\n", r);
freeUPNPDevlist(devlist); devlist = 0;
FreeUPNPUrls(&urls);
throw;
}
} else {
printf("No valid UPnP IGDs found\n");
freeUPNPDevlist(devlist); devlist = 0;
if (r != 0)
FreeUPNPUrls(&urls);
}
}
void MapPort(bool fUseUPnP)
{
static boost::thread* upnp_thread = NULL;
if (fUseUPnP)
{
if (upnp_thread) {
upnp_thread->interrupt();
upnp_thread->join();
delete upnp_thread;
}
upnp_thread = new boost::thread(boost::bind(&TraceThread<boost::function<void()> >, "upnp", &ThreadMapPort));
}
else if (upnp_thread) {
upnp_thread->interrupt();
upnp_thread->join();
delete upnp_thread;
upnp_thread = NULL;
}
}
#else
void MapPort(bool)
{
// Intentionally left blank.
}
#endif
// DNS seeds
// Each pair gives a source name and a seed name.
// The first name is used as information source for addrman.
// The second name should resolve to a list of seed addresses.
static const char *strMainNetDNSSeed[][2] = {
{"104.131.231.201", " 104.131.231.201"},
{NULL, NULL}
};
static const char *strTestNetDNSSeed[][2] = {
{NULL, NULL}
};
void ThreadDNSAddressSeed()
{
static const char *(*strDNSSeed)[2] = fTestNet ? strTestNetDNSSeed : strMainNetDNSSeed;
int found = 0;
printf("Loading addresses from DNS seeds (could take a while)\n");
for (unsigned int seed_idx = 0; strDNSSeed[seed_idx][0] != NULL; seed_idx++) {
if (HaveNameProxy()) {
AddOneShot(strDNSSeed[seed_idx][1]);
} else {
vector<CNetAddr> vaddr;
vector<CAddress> vAdd;
if (LookupHost(strDNSSeed[seed_idx][1], vaddr))
{
BOOST_FOREACH(CNetAddr& ip, vaddr)
{
int nOneDay = 24*3600;
CAddress addr = CAddress(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old
vAdd.push_back(addr);
found++;
}
}
addrman.Add(vAdd, CNetAddr(strDNSSeed[seed_idx][0], true));
}
}
printf("%d addresses found from DNS seeds\n", found);
}
unsigned int pnSeed[] =
{
0x6ab5368e, 0x63109859, 0x6c47bb25, 0x87d888c1, 0x1d9b2e48, 0x63a6c545, 0xf3ca1a48, 0x23b6b242,
0x8a67c7c6, 0x70a6f1c0, 0xc585c96d, 0x5cc4fd36, 0x239be836, 0x6660dc36, 0x2664cb36, 0xa602cd36,
0xb83dfc36, 0x70a2fe18, 0x2c589d55, 0xf969ec2e, 0x702ab643, 0x6a97e655, 0xad9751ce, 0x57e5025a,
0x9d065643, 0xe7b5ff60, 0x959d0d5a, 0x9667a318, 0xeba0c118, 0xb380d418, 0x170ccdde, 0x3548d9a2,
0x3261ff53, 0x42df0676, 0x9d7445ae, 0x1db3e953, 0xafc0b1b7, 0x1648934b, 0x535ee644, 0x4b89b64f,
0x56ed3060, 0x0810a15f, 0x03590ccf, 0x80752452, 0x0cc87162, 0xfec159d5, 0xcf0df618, 0x48865456,
0xdec8e55a, 0x91e6ee5b, 0xc4739518, 0x24d45453, 0xd5e5be44, 0xdafcff57, 0x0e73ca18, 0x83c4d148,
0x5a51ee53, 0x367e1c56, 0x2d651f54, 0x5eb4be43, 0x621589b2, 0x81dddedd, 0xd7499f56, 0xa48a694c,
0xd408c762, 0x88d36144, 0x6891772e, 0x38e89c73, 0x8ce3a856, 0x52fa1fb0, 0xd9d5796d, 0x27318945,
0x2e680452, 0x619bc445, 0xd0dc092e, 0x7192c962, 0xc2c9e405, 0xb9e3e747, 0xe459c9c1, 0x9d043b25,
0xe2b235c6, 0xed2dcf18, 0xb3d03cae, 0x3d2dafb8, 0xd46a0e45, 0x4a32f1d8, 0x350be560, 0xab0a648a,
0x87b6bc43, 0x6745629b, 0x72b9c362, 0x03a91c05, 0x7320bd3b, 0x32920b18, 0xbc2ca162, 0x216c4f7d,
0x64151a4e, 0x4b63e20c, 0xe703c3be, 0xc2d5fab2, 0x2b28b762, 0xde47b0ba, 0xf2e19dd9, 0x99044fad,
0x8252a5c0, 0x6e8be597, 0x4f0bb56c, 0xfaa52252, 0x8f764b52, 0xe5b21cad, 0x020cab4d, 0xc8e8f763,
0x2eaacc6d, 0x2ce4dd4e, 0xfe27345c, 0xb21f09b0, 0x8b4199d9, 0x6b53c248, 0x42a8966d, 0xd5387145,
0xc091c257, 0x2fe06751, 0xecf66552, 0x37dd0418, 0x8073c57c, 0x5471d54e, 0x56953360, 0x0d1ffcdf,
0xb4554318, 0x16cb54c6, 0xa064d05e, 0x2b0fa93a, 0xec26d162, 0x9ca91b42, 0xdcfa4457, 0x1b5c0a7a,
0x4561a17c, 0xcc52a662, 0xf9d47ad9, 0xfa418cb2, 0x88085618, 0x007aa55f, 0xfa2e4d4d, 0x8516a843,
0x634ac658, 0x2c36f62e, 0x3f0cbe5e, 0xd0e87257, 0x37d5e6bc, 0x5941c1c7, 0x5ee001ae, 0xc2791e6c,
0x0c6220b2, 0xab1ba258, 0x4719c076, 0xabb6a942, 0x6e588b52, 0x101a4352, 0x9604b362, 0x16607fc7,
0x4a687d45, 0xc217feb2, 0xaebb6b18, 0x4439412e, 0x41330360, 0xca23946d, 0x1c699d76, 0xcd302344,
0x4683afad, 0xad3c644f, 0x95ab4f05, 0xb34ec562, 0x57e3ff50, 0xcb950847, 0x743ced60, 0xb6734347,
0x6237a2b2, 0x1517e244, 0xfd0b128b, 0xb7eb605f, 0x6a9717ad, 0x7e8d65ae, 0xdddc4cad, 0xc63530a6,
0xfcd78559, 0xc779e25e, 0xf683de58, 0x7cd1ff50, 0x6e0931ad, 0x7c1b46ad, 0x9f4b4252, 0xf421482e,
0xeca7e697, 0xfe466544, 0x46fa2240, 0xd33328bc, 0x7be6d7bd, 0xc205c27b, 0xa04c07d8, 0x5bcdb350,
0x847bc74a, 0x14967f45, 0x59b341ad, 0x9ce4d783, 0xc38300c0, 0x4f1b4aad, 0x018daa32, 0x95d7f854,
0x4bd58543, 0xfe8446ad, 0xc3288f18, 0xcda2e253, 0x662e4852, 0x9338e24e, 0xc2fd1218, 0xa7198252,
0x481858b8, 0x55b74374, 0xbd458d5e, 0xb2cc6d54, 0x2ca11b4e, 0x62d1be58, 0xf0637fbc, 0xd9943950,
0x0f6f4a47, 0x188a6144, 0x768ea0d8, 0xd2c31c54, 0x29462ed5, 0x2b546ad5, 0x8ba12d6c, 0x1a3f7255,
0xa836e23c, 0xdcde0552, 0xda5b3945, 0x7e3720b2, 0x8c098018, 0x42cddd50, 0x0c52a65f, 0x8cce175e,
0x96554242, 0x7309c779, 0xcb2537ca, 0xecfb70d9, 0x19c0b259, 0x7b559ed8, 0x2f03ae44, 0x1b2b0f05,
0x9e72165e, 0x4ac7413e, 0xa22cbb6a, 0x9fc7624d, 0xbb101a54, 0xfdb0c23e, 0x84a65a47, 0x1efded62,
0x1f47f554, 0xe5c16ad2, 0x76b62332, 0xe4613d46, 0xd74f6ec1, 0x3d0e2b32, 0x6725fe5e, 0xb62a8729,
0x922e9925, 0x7efc2544, 0x12af60d4, 0x5e042f44, 0x5fcaff54, 0x144a3493, 0x5788ec47, 0x729175b2,
0x493b316c, 0x949d4542, 0x4ffc8856, 0x18a95b61, 0xdaabc547, 0xc879d855, 0x7d8488c1, 0x3cb7b052,
0xbe8ade6f, 0x6ef6a555, 0x737e5247, 0x7368e252, 0x5fbe1056, 0xb848e217, 0x44a44105, 0xb7610150,
0x3c2eed62, 0x2b0c9e6d, 0x2a1698b4, 0x4e6fa443, 0xb6c3fe4d, 0xd86c8a43, 0x48b27125, 0x9d9c60cb,
0x349a6d4c, 0xae336259, 0x81d7976d, 0x8e9fe2c0, 0x5f20c2dd, 0x6f289e52, 0xe954cf51, 0xc96eb248,
0x1c29f562, 0xb01e3842, 0x119511b9, 0x4811856d, 0x172ff854, 0x7dab5451, 0x52520752, 0xc414ed52,
0x368f4105, 0x7767b047, 0x1c459f32, 0x05b5e697, 0xb5273160, 0x99eaec69, 0x0cd7a951, 0x36e1f13e,
0xee815148, 0x5773e8bc, 0xf61f35ad, 0xa0b903ae, 0x2d811660, 0x98aec3be, 0x851afa59, 0xce25a518,
0xfcaaf2a2, 0x90bde760, 0x04cb16ad, 0x70a30432, 0xa6cd3e47, 0x0ccac672, 0xb238a018, 0xf7db8156,
0xed1e0331, 0xe2590ccf, 0x0cde9e56, 0x5cc39744, 0x4e3c957c, 0xc57e67d3, 0x6b547662, 0x073cd243,
0x670d9a18, 0x4666ae58, 0x661abd59, 0x64c94732, 0x8371cc82, 0x2f460843, 0x03bcfa45, 0xa23cac70,
0x1fa47b46, 0xec86b4ad, 0x183e3105, 0x6dea2446, 0x0331bcd1, 0x2673cf18, 0x5ccbdaac, 0xa0483850,
0x9b28c34a, 0xc69b9b62, 0xac944946, 0x3723b456, 0x4a53485d, 0x365fa8bc, 0x3adfbd5e, 0xdefbb143,
0x6ca64746, 0xadea802e, 0x89c0bbad, 0xefcc854f, 0x38cca5bc, 0xacc61e5e, 0x5bc43ab8, 0x3003795b,
0x391c2352, 0xe410f6ad, 0x3fa6f957, 0xd6b095d4, 0xeb00ba43, 0xf92f174c, 0xb45c0644, 0x6b299c53,
0xff0cf172, 0xaafe4a4c, 0xeb4aea5c, 0xb61dae43, 0x22115347, 0xfd510e6c, 0xe037fc50, 0xa5498e3d,
0xd36b8118, 0x0b6a0250, 0xd3260c5e, 0xe540424b, 0xbb630732, 0xa5cca46d, 0xdbb27a47, 0x5874ba6a,
0x581d4342, 0xa68b7125, 0x0b3b9f58, 0x2b8a8d18, 0x3155e763, 0x455e6951, 0xe79c0260, 0x683a474b,
0xfcabe697, 0xf3d1e13c, 0x8c0eb57c, 0x34a9e155, 0xc51d1e4c, 0x26fc8748, 0x3817ba6a, 0xbc36225f,
0x8dc42e5a, 0x51676c4e, 0x0f77a843, 0xf45ebebc, 0x2dc05874, 0x9be1ac5f, 0x1471595c, 0xa6d260d8,
0x3e2a008e, 0x0a2ff462, 0xfbe632c6, 0xf701af5d, 0x6cca155c, 0xf2e2af51, 0xb5c47a47, 0x322968d5,
0xfe651b4e, 0x11bccecd, 0xc2140418, 0xa741a465, 0xc8f45f48, 0x0400b0b4, 0x0e36c14e, 0x1f028cb2,
0x221db552, 0x4876ced5, 0x8e7c4abc, 0xd4b4734c, 0xce4b79d9, 0xf2879056, 0xa761794d, 0xc89c96b2,
0xd042af44, 0xd5f63418, 0x744731ad, 0xa94e7cae, 0x52b85b4d, 0x01978932, 0xa6abd1d3, 0xd4fae247,
0x71cd9344, 0xde60bb6a, 0xec358489, 0x6e054cdc, 0xc92728bc, 0x231ea8bc, 0x74a5a2bc, 0x6d6f135d,
0x26dd6596, 0x9d5386d1, 0x268bf232, 0x3867324a, 0x315e5353, 0x1ed2a443, 0xd79a9d51, 0x39dfe550,
0x3f1ef181, 0x2f65fe79, 0xf6caf04d, 0x3fd33644, 0xd9abf043, 0x1a84c94e, 0x61618445, 0x7bd81318,
0xb4f8764c, 0x8c6ae963, 0x7d659c5c, 0x9f294257, 0x5711be58, 0x3ac6b247, 0xe4f07d60, 0xe6bf7162,
0x96742752, 0x23329cca, 0xc219cd5c, 0xa6f23418, 0xf4908053, 0x63130652, 0xf68fc948, 0x028fb54b,
0x83ec1a18, 0xe88b4e8b, 0xf057ffcf, 0x4b3efe60, 0x359fff60, 0xba675642, 0xd5fe664c, 0xc8a2b862,
0x4f8f576d, 0xb7827462, 0x1cc0c954, 0x6655aa7c, 0x9bc71451, 0x1039b456, 0x91d5e37c, 0x1ccb6c53,
0x2e36313e, 0x6afd5251, 0xee91107c, 0xe9c0844b, 0xf133e347, 0xc1cd1b41, 0x3a0ab052, 0x30dee25a,
0xa75bd152, 0x319da1b8, 0xd8f97561, 0x2fa794d5, 0x92a70d6c, 0xd6b470d5, 0xb524c90e, 0x109a64ae,
0x7038af89, 0x3205e418, 0x313a015e, 0xd2d3175e, 0xc07593b8, 0x179ee97a, 0x78fdec47, 0x775d6d3a,
0xccc93a40, 0xdbbbd9ad, 0x803c6f12, 0xfd4bc14a, 0x8ed15250, 0x19c65958, 0xc8300c5e, 0x87757db2,
0x82fe0444, 0x3ce0035e, 0x19f0e762, 0x160c4c57, 0x069b0418, 0x9c6e4356, 0xa10df12e, 0x1936654d,
0xd30b2848, 0x464aa5b2, 0xbb0b1b55, 0x03f3d318, 0x0431e06c, 0x0d94f15b, 0xabc2ed47, 0xf23a00c2,
0x3bee4954, 0xd1e72a52, 0xd464d054, 0xcf141118, 0xf57f4bc8, 0xd8b1ac6c, 0x136ea959, 0x63275d4a,
0x391e8c18, 0xd4dd4832, 0x96610b6d, 0x9cfb5153, 0x4a80ee48, 0x345e7cbc, 0xde810b59, 0x134a4c90,
0x4544ed5e, 0xdc801956, 0x9d6b3ac6, 0x0a037786, 0xdcaafd62, 0xd65ee05a, 0x158b754c, 0x53427dd5,
0xa32774bc, 0xa22af3a2, 0x0c1f7157, 0xa0b58429, 0x349f3156, 0x9cd6a34d, 0x67eb1c56, 0x20b5e597,
0xd40f7162, 0xa4cb0379, 0x0e1efc53, 0xe5c8e554, 0x3ebf8052, 0x6ee00847, 0x99206883, 0xc851767d
};
void DumpAddresses()
{
int64 nStart = GetTimeMillis();
CAddrDB adb;
adb.Write(addrman);
printf("Flushed %d addresses to peers.dat %"PRI64d"ms\n",
addrman.size(), GetTimeMillis() - nStart);
}
void static ProcessOneShot()
{
string strDest;
{
LOCK(cs_vOneShots);
if (vOneShots.empty())
return;
strDest = vOneShots.front();
vOneShots.pop_front();
}
CAddress addr;
CSemaphoreGrant grant(*semOutbound, true);
if (grant) {
if (!OpenNetworkConnection(addr, &grant, strDest.c_str(), true))
AddOneShot(strDest);
}
}
void ThreadOpenConnections()
{
// Connect to specific addresses
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0)
{
for (int64 nLoop = 0;; nLoop++)
{
ProcessOneShot();
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
{
CAddress addr;
OpenNetworkConnection(addr, NULL, strAddr.c_str());
for (int i = 0; i < 10 && i < nLoop; i++)
{
MilliSleep(500);
}
}
MilliSleep(500);
}
}
// Initiate network connections
int64 nStart = GetTime();
loop
{
ProcessOneShot();
MilliSleep(500);
CSemaphoreGrant grant(*semOutbound);
boost::this_thread::interruption_point();
// Add seed nodes if IRC isn't working
if (addrman.size()==0 && (GetTime() - nStart > 60) && !fTestNet)
{
std::vector<CAddress> vAdd;
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time' of between one and two
// weeks ago.
const int64 nOneWeek = 7*24*60*60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
vAdd.push_back(addr);
}
addrman.Add(vAdd, CNetAddr("127.0.0.1"));
}
//
// Choose an address to connect to based on most recently seen
//
CAddress addrConnect;
// Only connect out to one peer per network group (/16 for IPv4).
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
int nOutbound = 0;
set<vector<unsigned char> > setConnected;
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes) {
if (!pnode->fInbound) {
setConnected.insert(pnode->addr.GetGroup());
nOutbound++;
}
}
}
int64 nANow = GetAdjustedTime();
int nTries = 0;
loop
{
// use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections)
CAddress addr = addrman.Select(10 + min(nOutbound,8)*10);
// if we selected an invalid address, restart
if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr))
break;
// If we didn't find an appropriate destination after trying 100 addresses fetched from addrman,
// stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates
// already-connected network ranges, ...) before trying new addrman addresses.
nTries++;
if (nTries > 100)
break;
if (IsLimited(addr))
continue;
// only consider very recently tried nodes after 30 failed attempts
if (nANow - addr.nLastTry < 600 && nTries < 30)
continue;
// do not allow non-default ports, unless after 50 invalid addresses selected already
if (addr.GetPort() != GetDefaultPort() && nTries < 50)
continue;
addrConnect = addr;
break;
}
if (addrConnect.IsValid())
OpenNetworkConnection(addrConnect, &grant);
}
}
void ThreadOpenAddedConnections()
{
{
LOCK(cs_vAddedNodes);
vAddedNodes = mapMultiArgs["-addnode"];
}
if (HaveNameProxy()) {
while(true) {
list<string> lAddresses(0);
{
LOCK(cs_vAddedNodes);
BOOST_FOREACH(string& strAddNode, vAddedNodes)
lAddresses.push_back(strAddNode);
}
BOOST_FOREACH(string& strAddNode, lAddresses) {
CAddress addr;
CSemaphoreGrant grant(*semOutbound);
OpenNetworkConnection(addr, &grant, strAddNode.c_str());
MilliSleep(500);
}
MilliSleep(120000); // Retry every 2 minutes
}
}
for (unsigned int i = 0; true; i++)
{
list<string> lAddresses(0);
{
LOCK(cs_vAddedNodes);
BOOST_FOREACH(string& strAddNode, vAddedNodes)
lAddresses.push_back(strAddNode);
}
list<vector<CService> > lservAddressesToAdd(0);
BOOST_FOREACH(string& strAddNode, lAddresses)
{
vector<CService> vservNode(0);
if(Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0))
{
lservAddressesToAdd.push_back(vservNode);
{
LOCK(cs_setservAddNodeAddresses);
BOOST_FOREACH(CService& serv, vservNode)
setservAddNodeAddresses.insert(serv);
}
}
}
// Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry
// (keeping in mind that addnode entries can have many IPs if fNameLookup)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++)
BOOST_FOREACH(CService& addrNode, *(it))
if (pnode->addr == addrNode)
{
it = lservAddressesToAdd.erase(it);
it--;
break;
}
}
BOOST_FOREACH(vector<CService>& vserv, lservAddressesToAdd)
{
CSemaphoreGrant grant(*semOutbound);
OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant);
MilliSleep(500);
}
MilliSleep(120000); // Retry every 2 minutes
}
}
// if successful, this moves the passed grant to the constructed node
bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound, const char *strDest, bool fOneShot)
{
//
// Initiate outbound network connection
//
boost::this_thread::interruption_point();
if (!strDest)
if (IsLocal(addrConnect) ||
FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) ||
FindNode(addrConnect.ToStringIPPort().c_str()))
return false;
if (strDest && FindNode(strDest))
return false;
CNode* pnode = ConnectNode(addrConnect, strDest);
boost::this_thread::interruption_point();
if (!pnode)
return false;
if (grantOutbound)
grantOutbound->MoveTo(pnode->grantOutbound);
pnode->fNetworkNode = true;
if (fOneShot)
pnode->fOneShot = true;
return true;
}
// for now, use a very simple selection metric: the node from which we received
// most recently
double static NodeSyncScore(const CNode *pnode) {
return -pnode->nLastRecv;
}
void static StartSync(const vector<CNode*> &vNodes) {
CNode *pnodeNewSync = NULL;
double dBestScore = 0;
// fImporting and fReindex are accessed out of cs_main here, but only
// as an optimization - they are checked again in SendMessages.
if (fImporting || fReindex)
return;
// Iterate over all nodes
BOOST_FOREACH(CNode* pnode, vNodes) {
// check preconditions for allowing a sync
if (!pnode->fClient && !pnode->fOneShot &&
!pnode->fDisconnect && pnode->fSuccessfullyConnected &&
(pnode->nStartingHeight > (nBestHeight - 144)) &&
(pnode->nVersion < NOBLKS_VERSION_START || pnode->nVersion >= NOBLKS_VERSION_END)) {
// if ok, compare node's score with the best so far
double dScore = NodeSyncScore(pnode);
if (pnodeNewSync == NULL || dScore > dBestScore) {
pnodeNewSync = pnode;
dBestScore = dScore;
}
}
}
// if a new sync candidate was found, start sync!
if (pnodeNewSync) {
pnodeNewSync->fStartSync = true;
pnodeSync = pnodeNewSync;
}
}
void ThreadMessageHandler()
{
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
while (true)
{
bool fHaveSyncNode = false;
vector<CNode*> vNodesCopy;
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy) {
pnode->AddRef();
if (pnode == pnodeSync)
fHaveSyncNode = true;
}
}
if (!fHaveSyncNode)
StartSync(vNodesCopy);
// Poll the connected nodes for messages
CNode* pnodeTrickle = NULL;
if (!vNodesCopy.empty())
pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())];
bool fSleep = true;
BOOST_FOREACH(CNode* pnode, vNodesCopy)
{
if (pnode->fDisconnect)
continue;
// Receive messages
{
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
if (lockRecv)
{
if (!ProcessMessages(pnode))
pnode->CloseSocketDisconnect();
if (pnode->nSendSize < SendBufferSize())
{
if (!pnode->vRecvGetData.empty() || (!pnode->vRecvMsg.empty() && pnode->vRecvMsg[0].complete()))
{
fSleep = false;
}
}
}
}
boost::this_thread::interruption_point();
// Send messages
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend)
SendMessages(pnode, pnode == pnodeTrickle);
}
boost::this_thread::interruption_point();
}
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->Release();
}
if (fSleep)
MilliSleep(100);
}
}
bool BindListenPort(const CService &addrBind, string& strError)
{
strError = "";
int nOne = 1;
// Create socket for listening for incoming connections
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
#else
struct sockaddr sockaddr;
#endif
socklen_t len = sizeof(sockaddr);
if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len))
{
strError = strprintf("Error: bind address family for %s not supported", addrBind.ToString().c_str());
printf("%s\n", strError.c_str());
return false;
}
SOCKET hListenSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP);
if (hListenSocket == INVALID_SOCKET)
{
strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %d)", WSAGetLastError());
printf("%s\n", strError.c_str());
return false;
}
#ifdef SO_NOSIGPIPE
// Different way of disabling SIGPIPE on BSD
setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
#endif
#ifndef WIN32
// Allow binding if the port is still in TIME_WAIT state after
// the program was closed and restarted. Not an issue on windows.
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));
#endif
#ifdef WIN32
// Set to non-blocking, incoming connections will also inherit this
if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR)
#else
if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
#endif
{
strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError());
printf("%s\n", strError.c_str());
return false;
}
#ifdef USE_IPV6
// some systems don't have IPV6_V6ONLY but are always v6only; others do have the option
// and enable it by default or not. Try to enable it, if possible.
if (addrBind.IsIPv6()) {
#ifdef IPV6_V6ONLY
#ifdef WIN32
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int));
#else
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
#endif
#endif
#ifdef WIN32
int nProtLevel = 10 /* PROTECTION_LEVEL_UNRESTRICTED */;
int nParameterId = 23 /* IPV6_PROTECTION_LEVEl */;
// this call is allowed to fail
setsockopt(hListenSocket, IPPROTO_IPV6, nParameterId, (const char*)&nProtLevel, sizeof(int));
#endif
}
#endif
if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR)
{
int nErr = WSAGetLastError();
if (nErr == WSAEADDRINUSE)
strError = strprintf(_("Unable to bind to %s on this computer. Servx is probably already running."), addrBind.ToString().c_str());
else
strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %d, %s)"), addrBind.ToString().c_str(), nErr, strerror(nErr));
printf("%s\n", strError.c_str());
return false;
}
printf("Bound to %s\n", addrBind.ToString().c_str());
// Listen for incoming connections
if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)
{
strError = strprintf("Error: Listening for incoming connections failed (listen returned error %d)", WSAGetLastError());
printf("%s\n", strError.c_str());
return false;
}
vhListenSocket.push_back(hListenSocket);
if (addrBind.IsRoutable() && fDiscover)
AddLocal(addrBind, LOCAL_BIND);
return true;
}
void static Discover()
{
if (!fDiscover)
return;
#ifdef WIN32
// Get local host IP
char pszHostName[1000] = "";
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
{
vector<CNetAddr> vaddr;
if (LookupHost(pszHostName, vaddr))
{
BOOST_FOREACH (const CNetAddr &addr, vaddr)
{
AddLocal(addr, LOCAL_IF);
}
}
}
#else
// Get local host ip
struct ifaddrs* myaddrs;
if (getifaddrs(&myaddrs) == 0)
{
for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next)
{
if (ifa->ifa_addr == NULL) continue;
if ((ifa->ifa_flags & IFF_UP) == 0) continue;
if (strcmp(ifa->ifa_name, "lo") == 0) continue;
if (strcmp(ifa->ifa_name, "lo0") == 0) continue;
if (ifa->ifa_addr->sa_family == AF_INET)
{
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
CNetAddr addr(s4->sin_addr);
if (AddLocal(addr, LOCAL_IF))
printf("IPv4 %s: %s\n", ifa->ifa_name, addr.ToString().c_str());
}
#ifdef USE_IPV6
else if (ifa->ifa_addr->sa_family == AF_INET6)
{
struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr);
CNetAddr addr(s6->sin6_addr);
if (AddLocal(addr, LOCAL_IF))
printf("IPv6 %s: %s\n", ifa->ifa_name, addr.ToString().c_str());
}
#endif
}
freeifaddrs(myaddrs);
}
#endif
// Don't use external IPv4 discovery, when -onlynet="IPv6"
if (!IsLimited(NET_IPV4))
NewThread(ThreadGetMyExternalIP, NULL);
}
void StartNode(boost::thread_group& threadGroup)
{
if (semOutbound == NULL) {
// initialize semaphore
int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
semOutbound = new CSemaphore(nMaxOutbound);
}
if (pnodeLocalHost == NULL)
pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices));
Discover();
//
// Start threads
//
if (!GetBoolArg("-dnsseed", true))
printf("DNS seeding disabled\n");
else
threadGroup.create_thread(boost::bind(&TraceThread<boost::function<void()> >, "dnsseed", &ThreadDNSAddressSeed));
#ifdef USE_UPNP
// Map ports with UPnP
MapPort(GetBoolArg("-upnp", USE_UPNP));
#endif
// Send and receive from sockets, accept connections
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "net", &ThreadSocketHandler));
// Initiate outbound connections from -addnode
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "addcon", &ThreadOpenAddedConnections));
// Initiate outbound connections
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "opencon", &ThreadOpenConnections));
// Process messages
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "msghand", &ThreadMessageHandler));
// Dump network addresses
threadGroup.create_thread(boost::bind(&LoopForever<void (*)()>, "dumpaddr", &DumpAddresses, DUMP_ADDRESSES_INTERVAL * 1000));
}
bool StopNode()
{
printf("StopNode()\n");
GenerateBitcoins(false, NULL);
MapPort(false);
nTransactionsUpdated++;
if (semOutbound)
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
semOutbound->post();
MilliSleep(50);
DumpAddresses();
return true;
}
class CNetCleanup
{
public:
CNetCleanup()
{
}
~CNetCleanup()
{
// Close sockets
BOOST_FOREACH(CNode* pnode, vNodes)
if (pnode->hSocket != INVALID_SOCKET)
closesocket(pnode->hSocket);
BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket)
if (hListenSocket != INVALID_SOCKET)
if (closesocket(hListenSocket) == SOCKET_ERROR)
printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
// clean up some globals (to help leak detection)
BOOST_FOREACH(CNode *pnode, vNodes)
delete pnode;
BOOST_FOREACH(CNode *pnode, vNodesDisconnected)
delete pnode;
vNodes.clear();
vNodesDisconnected.clear();
delete semOutbound;
semOutbound = NULL;
delete pnodeLocalHost;
pnodeLocalHost = NULL;
#ifdef WIN32
// Shutdown Windows Sockets
WSACleanup();
#endif
}
}
instance_of_cnetcleanup;
void RelayTransaction(const CTransaction& tx, const uint256& hash)
{
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(10000);
ss << tx;
RelayTransaction(tx, hash, ss);
}
void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss)
{
CInv inv(MSG_TX, hash);
{
LOCK(cs_mapRelay);
// Expire old relay messages
while (!vRelayExpiration.empty() && vRelayExpiration.front().first < GetTime())
{
mapRelay.erase(vRelayExpiration.front().second);
vRelayExpiration.pop_front();
}
// Save original serialized message so newer versions are preserved
mapRelay.insert(std::make_pair(inv, ss));
vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
}
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
if(!pnode->fRelayTxes)
continue;
LOCK(pnode->cs_filter);
if (pnode->pfilter)
{
if (pnode->pfilter->IsRelevantAndUpdate(tx, hash))
pnode->PushInventory(inv);
} else
pnode->PushInventory(inv);
}
}
| [
"servxdev@gmail.com"
] | servxdev@gmail.com |
6e2251da220021297c4bac385af19eae7286bb45 | 24ce7a1264cb0c4bbf7b7ab904a5dc98ccc1be4e | /remove-duplicates-from-sorted-array.cpp | 24e4db2483dfa89117c5b0de01d633aa4a365097 | [] | no_license | winniez/myleetcode | 1a61019e0e254fa290faa3c85dd20019ff3c9824 | befb7ed11398e8a0ed8cd021db95bf368242a415 | refs/heads/master | 2016-09-05T20:34:17.779538 | 2014-04-06T21:42:33 | 2014-04-06T21:42:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,292 | cpp | /*
Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
For example,
Given input array A = [1,1,2],
Your function should return length = 2, and A is now [1,2].
*/
/*
JAN 21 2014
Note how index is updated, as follower cells are already moved.
*/
class Solution {
public:
int removeDuplicates(int A[], int n) {
int len = n;
int index = 0;
int next = index+1;
int start, end, gap;
bool duplicate;
while (next < len)
{
duplicate = false;
while(A[index] == A[next])
{
duplicate = true;
next++;
if (next == len) break;
}
if (duplicate)
{
start = index+1;
end = next - 1;
gap = next - index - 1;
for (int i = index + 1; i < len-gap; i++)
{
A[i] = A[i+gap];
}
len -= gap;
}
index = index + 1;
next = index + 1;
}
return len;
}
};
| [
"xinyingzengvy@gmail.com"
] | xinyingzengvy@gmail.com |
e731b94bbdf7ed8d1c09ab1893c8184d150d4c30 | 325fae56f508c58240dd3c048bf30cbd3ead770a | /알고리즘스터디1/크레인 인형뽑기 게임.cpp | f15e3d598d7769f58cb5c080ddb76a40fa6a0d9a | [] | no_license | LeeJongbokz/algorithmstudy | be283ce06a3b41da8064d84ecf855fc8e7562892 | c61f5db9f322d5692056727b417c1bc0d1f54c91 | refs/heads/master | 2021-07-17T09:51:24.417282 | 2020-10-20T15:03:18 | 2020-10-20T15:03:18 | 222,414,013 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 995 | cpp | // 20분
#include <string>
#include <vector>
#include <stack>
using namespace std;
int solution(vector<vector<int>> board, vector<int> moves) {
int answer = 0;
stack<int> stk;
int len = board.size();
for(int i=0; i<moves.size(); i++){
int pos = moves[i];
for(int j=0; j<len; j++){
if(board[j][pos-1] == 0){
continue;
}else{
int num = board[j][pos-1];
if(stk.empty()){
stk.push(num);
}else{
int topNum = stk.top();
if(num == topNum){
stk.pop();
answer += 2;
}else{
stk.push(num);
}
}
board[j][pos-1] = 0;
break;
}
}
}
return answer;
}
| [
"noreply@github.com"
] | noreply@github.com |
a61a11917cff719594afa117f9411279a6165df8 | 160c7994b8c6fbd0c08428d5cc4f8ab41fb1e9d9 | /AlgTheory1/Assignment1/insint.cpp | 6df6c85ae581152f3052682845ed879528c984a9 | [] | no_license | CPlummer35/Fall2020 | a64c4a12357fd203142034601de4d83d64090aea | 6c34b03ad7d8f628c21dde9e5a3105ef6f1ffe49 | refs/heads/master | 2022-12-27T01:37:32.325450 | 2020-10-09T23:37:07 | 2020-10-09T23:37:07 | 293,879,007 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,828 | cpp | #include "IntIndColl.h"
#include <iostream>
#include <chrono>
using namespace std;
IntIndColl::IntIndColl(int sz)
{
size = sz;
collection = new int [sz];
}
IntIndColl::~IntIndColl()
{
delete [] collection;
}
void IntIndColl::store(int index, int value)
{
if((index < 0) || (index > size-1))
{
cerr << "\nERROR: index out of range\n";
exit(1);
}
collection[index] = value;
}
int IntIndColl::retrieve(int index) const
{
if ((index < 0) || (index > size - 1))
{
cerr << "\nERRROR: index out of range \n";
exit(1);
}
return collection[index];
}
int& IntIndColl::operator[](int index)
{
if((index < 0) || (index > size-1))
{
cerr << "\nError: index is out of range";
exit(1);
}
return collection[index];
}
IntIndColl::IntIndColl(IntIndColl& source)
{
size = source.size;
collection = new int[size];
for(int i = 0; i < source.size; i++)
{
collection[i] = source.collection[i];
}
}
int main()
{
int size, capacity, i, data;
cout << "Enter Array Size: ";
cin >> size;
IntIndColl array(size);
cout << "how much of the array is occupied?: ";
cin >> capacity;
for(i = 0; i < capacity; i++)
{
array[i] = rand() % capacity +1;
}
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
int key, j;
for (int i = 1; i < size; i++)
{
key = array[i];
j = i;
while(j > 0 && array[j-1] > key)
{
array[j] = array[j-1];
j--;
}
array[j] = key;
}
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
cout << elapsed_seconds.count() << "s\n";
}
| [
"caidenplummer@caidens-mbp.home"
] | caidenplummer@caidens-mbp.home |
36651fef876914b18cbf1f441839819f3e1bd6ce | df7ae7e3ee327a42a5a14bc74c5ff6e3ebd80c4d | /test/Hh_test.cpp | e52279a7d1def585df2222e24f7e9e73b0d109f2 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | MichaelZhou-New/Mesh-processing-library | 246dcaf801dc787d34fe5a2a1b90b5326564b709 | aa8c952fbbb00774008060767650b821bf72fa10 | refs/heads/master | 2023-08-25T07:32:31.031032 | 2021-10-29T01:18:54 | 2021-10-29T01:18:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,851 | cpp | // -*- C++ -*- Copyright (c) Microsoft Corporation; see license.txt
#include "libHh/Hh.h"
#if defined(_WIN32)
#include <process.h> // _spawnvp()
#endif
#include "libHh/Advanced.h"
#include "libHh/Array.h"
#include "libHh/FileIO.h"
#include "libHh/Geometry.h"
#include "libHh/Random.h"
#include "libHh/RangeOp.h" // reverse(), sort()
#include "libHh/StringOp.h"
using namespace hh;
namespace {
const string tmpf = "v.Hh_test.txt";
void try_it(const string& stest) {
if (0) SHOW(stest);
for_int(method, 2) { // csh, sh, cmd
if (0) SHOW(method);
string s1 = quote_arg_for_sh(stest); // stronger than quote_arg_for_shell()
if (0) SHOW(s1);
if (0) {
string s2 = "echo " + s1 + " >" + tmpf;
// Array<string> sargv = {"csh", "-c", s2}; // works always also
// Array<string> sargv = {"sh", "-c", s2}; // fails
// Array<string> sargv = {"bash", "-c", s2}; // fails too
// Going to a Cygwin process -- ouch!
// Array<string> sargv = {"sh", "-v", "-c", s2};
// stest = hh1 "a' b.txt" "a' b.txt" "a' b.txt" |
// s1 = hh1\ \"a\'\ b\.txt\"\ \"a\'\ b\.txt\"\ \"a\'\ b\.txt\"\ \|
// echo hh1\ \a\"\" b"\".txt"\""\"""\" "\""\""a"\"
Array<string> sargv = {"c:/mingw/msys/1.0/bin/sh", "-v", "-c", s2};
// Array<string> sargv = {"csh", "-v", "-c", s2};
// stest = hh1 "a' b.txt" "a' b.txt" "a' b.txt" |
// s1 = hh1\ \"a\'\ b\.txt\"\ \"a\'\ b\.txt\"\ \"a\'\ b\.txt\"\ \|
// echo hh1\ \"a\'\ b\.txt\"\ \"a\'\ b\.txt\"\ \"a\'\ b\.txt\"\ \| > v.Hh_test.txt
assertx(!my_spawn(sargv, true));
} else if (method == 0) { // works always
string s2 = "echo " + s1 + " >" + tmpf;
Array<string> largv = {"csh", "-c", s2}; // or "-vc"
assertx(!my_spawn(largv, true));
} else if (0 && method == 1) { // equivalent to the one below
string s2 = "echo " + s1 + " >" + tmpf;
// Array<string> largv = {"c:/cygwin/bin/bash", "-c", s2}; // or "-vc"
Array<string> largv = {"sh", "-c", s2}; // or "-vc"
assertx(!my_spawn(largv, true));
} else if (1 && method == 1) {
string s2 = "echo " + s1 + " >" + tmpf;
assertx(!my_sh(s2));
} else if (method == 2) { // I give up on this.
string s1cmd = '"' + stest + '"';
// string s1cmd = windows_spawn_quote(stest);
// string s2 = "echo " + s1cmd + " >" + tmpf; // DOS eol; extra space at eol; echo ignores quotes
// string s2 = "/cygwin/bin/echo " + s1cmd + " >" + tmpf; // cygwin quote parsing is poor
string s2 = "/mingw/msys/1.0/bin/echo " + s1cmd + " >" + tmpf; // still does not handle double-quotes
string sbu = getenv_string("FORCE_CMD"); // "" if undefined
my_setenv("FORCE_CMD", "1");
assertx(!my_sh(s2));
my_setenv("FORCE_CMD", sbu);
}
RFile fi(tmpf);
string sline;
assertx(my_getline(fi(), sline));
// SHOW(sline);
// Here I once saw the error "method=1 stest=a b c sline=a\ b\ c"; it was due to a setting of env
// variable CYGWIN="noglob nodosfilewarning" likely set during an interrupted Emacs grep -- since fixed.
if (sline != stest) SHOW(method, stest, sline);
assertx(sline == stest);
}
}
void test_spawn() {
{
try_it(R"(abc)");
try_it(R"(a b c)");
try_it(R"('a b' c)");
try_it(R"("a b" c)");
try_it(R"(hh1 "a' b.txt" "a' b.txt" "a' b.txt" |)");
try_it(R"(hh1 "a' \ b.txt" "a' b.txt" "a' b.txt" |)");
try_it("hh1 \"a' \" b");
try_it(R"(hh1 "a' " b.txt" "a' )");
try_it("\"|");
try_it(R"(hh1 "a' " b.txt" "a' b.txt" "a' b.txt" |)");
try_it(R"(hh1 "a' " b.txt" "a' b.txt" "a' b.txt" &)");
try_it(R"(hh1 "a' | & " b.txt" "a' b.txt" "a' b.txt" &)");
try_it(R"(hh1 "a' | & " b.txt" "a' b.txt" "a' b.txt" &~!@#$%^&*()`[]{};:,.<>/?-_=\+)");
try_it(R"(%^&*()`[]{};:,.<>/?-_=\+)");
try_it(R"(%^&*())");
}
{
const string arcands = R"(abcdefgh `~!@#$%^&*()-_=+[{]}\|;:'"",<.>/?)"; // double '"' frequency
for_int(itry, 10) { // tried up to 10000
const int len = 20;
string str(len, ' ');
for_int(i, len) str[i] = arcands[Random::G.get_unsigned(narrow_cast<unsigned>(arcands.size()))];
try_it(str);
}
}
assertx(remove_file(tmpf));
}
void test_spawn2() {
#if defined(_WIN32)
#define E(str) \
s = str; \
SHOW("*", s); \
SHOW(_spawnvp(P_WAIT, shell0, V(shell, "-c", s, nullptr).data())) // or "-vc"
// echo 'a'\''b' // a'b
// csh -c 'echo '\''a'\''\'\'''\''b'\''' // a'b
// sh -c 'echo '\''a'\''\'\'''\''b'\''' // a'b
const char* s;
const char* shell;
const char* shell0;
if (0) {
// csh parses command using double-quotes with "\"" for inner double quotes;
// it does not recognize single-quotes. (due to crt/stdargv.c : parse_cmdline())
shell = "csh";
shell0 = shell;
SHOW("**", shell, shell0);
if (0) shell0 = "sh"; // Then it behaves differently; it parses args more like cygwin bash!
//
E(R"(echo a b)"); // echo null
E(R"('echo a b')"); // 'echo Unmatched '.
E(R"("echo a b")"); // echo a b a b
E(R"("echo 'a b'")"); // echo 'a b' a b
E(R"('echo "a b"')"); // 'echo Unmatched '.
E(R"(echo\ \'a b\')"); // Argument for -c ends in backslash.
E(R"(echo" "\"a b\")"); // echo "a Unmatched ".
E(R"('echo \"a b\"')"); // 'echo Unmatched '.
// The outer double quotes (parsed by Windows) allow backslash of inner double quotes, just like csh/tcsh.
E(R"("echo \\\"a b\\\"")"); // echo \"a b\" "a b"
E(R"("echo \'a b\'")"); // echo \'a b\' 'a b'
// The outer single quotes (parsed by Windows) prefer backslash of inner single quotes (\')
// whereas the inner single quotes (parsed by sh/csh) require exiting to backslash inner quote ('\'').
E(R"('echo '\''a'\''\'\'''\''b'\''')"); // 'echo Unmatched '.
E(R"('echo \''a'\''\'\'''\''b'\''')"); // 'echo Unmatched '.
E(R"('echo \'a\'\\\'\'b\'')"); // 'echo Unmatched '.
// Try using double-quotes with "\"" for inner double quotes
E(R"("echo "\""a b"\""")"); // echo "a b" a b
// echo\ \"a\ b\"
E(R"("echo"\\" "\\""\""a"\\" b"\\""\\"")"); // echo\ \"a\ b\\ echo "a b\: Command not found.
}
if (1) {
// cygwin sh does not use windows crt, so has its own scheme for parsing command
shell = "sh";
shell0 = shell;
SHOW("**", shell, shell0);
E(R"(echo a b)"); // echo null
E(R"('echo a b')"); // echo a b a b
E(R"("echo a b")"); // echo a b a b
E(R"("echo 'a b'")"); // echo 'a b' a b
E(R"('echo "a b"')"); // echo "a b" a b
E(R"(echo\ \'a b\')"); // echo\ null
E(R"(echo" "\"a b\")"); // echo \a b" err
E(R"('echo \"a b\"')"); // echo \"a b\" "a b"
// The outer double quotes (parsed by Windows) allow backslash of inner double quotes, just like csh/tcsh.
E(R"("echo \\\"a b\\\"")"); // echo \"a b\" "a b"
E(R"("echo \'a b\'")"); // echo \'a b\' 'a b'
// The outer single quotes (parsed by Windows) prefer backslash of inner single quotes (\')
// whereas the inner single quotes (parsed by sh/csh) require exiting to backslash inner quote ('\'').
E(R"('echo '\''a'\''\'\'''\''b'\''')"); // echo a'\''b' a\b unexpected
E(R"('echo \''a'\''\'\'''\''b'\''')"); // echo 'a'\''b' a'b enexpected; works
E(R"('echo \'a\'\\\'\'b\'')"); // echo 'a'\''b' a'b unexpected; works
// Try using double-quotes with "\"" for inner double quotes
E(R"("echo "\""a b"\""")"); // echo a a unexpected
// Instead backslash inner double quotes
E(R"("echo \"a b\"")"); // echo "a b" a b works
E(R"("echo \"a b\"")"); // echo "a b" a b works (just backslash inner double-quotes)
E(R"("echo '\"'")"); // echo '"' " works
E(R"("echo \\\"")"); // echo \" " works
}
#undef E
#endif
}
void test_implicit_default_virtual_destructor() {
struct A {
~A() { SHOW("~A()"); }
};
struct Base {
virtual ~Base() = default;
};
struct Derived : Base {
A _a;
};
{ Derived derived; }
{
Base* p = make_unique<Derived>().release();
delete p;
}
}
// This does not do shortcut evaluation! "const T&" gives wrong results on VS2013.
template <typename T, typename... Args> T first_of(T a1, Args... args);
template <typename T> T first_of(T a1) { return a1; }
template <typename T, typename... Args> T first_of(T a1, Args... args) { return a1 ? a1 : first_of(args...); }
void func1(uchar c1, uchar c2, uchar c3, uchar c4) { SHOW(int(c1), int(c2), int(c3), int(c4)); }
void func2() { throw std::runtime_error("func2_err"); }
void func3() {
struct S {
explicit S(string s) : _s(std::move(s)) { SHOW("start " + _s); }
~S() { SHOW("end " + _s); }
string _s;
};
S s0("s0");
struct SS {
SS() : _s1("s1"), _s2("s2"), _s3((func2(), "s3")), _s4("s4") { SHOW("SS never"); }
~SS() { SHOW("~SS never"); }
S _s1, _s2, _s3, _s4;
};
SS ss;
}
void func4() {
struct S {
S() { SHOW("default constructor"); }
// S(string s) : _s(s) { SHOW("start " + _s); }
~S() { SHOW("end " + _s); }
string _s;
};
struct SS {
SS() {
// see if _s1 and _s2 are destructed; yes they are.
_s1._s = "s1";
_s2._s = "s2";
func2();
}
~SS() { SHOW("~SS never"); }
S _s1, _s2, _s3, _s4;
};
SS ss;
}
void test_exceptions() {
SHOW("test func3");
try {
func3();
} catch (const std::exception& ex) {
SHOW("catch3", ex.what());
}
SHOW("test func4");
try {
func4();
} catch (const std::exception& ex) {
SHOW("catch4", ex.what());
}
if (0) {
throw std::runtime_error("err2"); // exercise my_terminate() or my_top_level_exception_filter()
// instead use "HTest -exception"
}
}
} // namespace
int main() {
if (1) {
{
Array<int> ar;
for (int e : range(2)) ar.push(e);
assertx(ar == V(0, 1).view());
}
{
Array<int> ar;
for (int e : range(1, 4)) ar.push(e);
assertx(ar == V(1, 2, 3).view());
}
{
Array<int> ar;
for (int e : range(0)) ar.push(e);
assertx(ar.num() == 0);
}
{
Array<int> ar;
for (int e : range(-1)) ar.push(e);
assertx(ar.num() == 0);
}
{
Array<int> ar;
for (int e : range(-2, 0)) ar.push(e);
assertx(ar == V(-2, -1).view());
}
{
Array<int> ar;
for (int e : range(-2, -2)) ar.push(e);
assertx(ar.num() == 0);
}
{
Array<int> ar;
for (int e : range(0, 0)) ar.push(e);
assertx(ar.num() == 0);
}
{
Array<int> ar;
for (int e : range(2, 0)) ar.push(e);
assertx(ar.num() == 0);
}
{
Array<uchar> ar;
for (uchar e : range(uchar{4}, uchar{6})) ar.push(e);
assertx(ar == V(uchar{4}, uchar{5}).view());
}
{
Array<uint8_t> ar;
for (uint8_t e : range(uint8_t{4}, uint8_t{6})) ar.push(e);
assertx(ar == V(uint8_t{4}, uint8_t{5}).view());
}
{
Array<short> ar;
for (short e : range<short>(-2, 2)) ar.push(e);
assertx(ar == convert<short>(V(-2, -1, 0, 1)).view());
}
{
Array<uint64_t> ar;
for (uint64_t e : range(uint64_t{3})) ar.push(e);
assertx(ar == V<uint64_t>(0u, 1u, 2u).view());
}
}
if (0) {
test_spawn2();
return 0;
}
if (1) {
test_spawn();
if (0) return 0;
}
{
assertx(!getenv("ZZ"));
assertx(!getenv_bool("ZZ"));
assertx(getenv_int("ZZ") == 0);
assertx(getenv_float("ZZ", 4.f) == 4.f);
assertx(getenv_string("ZZ") == "");
const Array<const char*> strings = {"ABC", "LONG_WORD", "MIX8WORD", "OTHER"};
for_int(i, 100) {
const char* s = strings[Random::G.get_unsigned(strings.num())];
if (Random::G.unif() < .5f) {
my_setenv(s, "1");
assertx(getenv(s));
assertx(getenv(s) == string("1"));
assertx(getenv_bool(s));
assertx(getenv_int(s) == 1);
assertx(getenv_float(s, 4.f) == 1.f);
assertx(getenv_string(s) == "1");
} else {
my_setenv(s, "");
assertx(!getenv(s));
assertx(!getenv_bool(s));
assertx(getenv_int(s) == 0);
assertx(getenv_float(s, 4.f) == 4.f);
assertx(getenv_string(s) == "");
}
}
for_int(i, 11) Warning("Should occur 11 times");
for_int(i, 3) {
if (!assertw(i < 0)) Warning("Should occur 3 times");
}
Warning("A is chronologically earliest");
Warning("z is chronologically last");
}
{ // test SHOW
{
Array<int> ar;
for_int(i, 8) ar.push(i);
SHOW(ar);
}
{
Array<Point> ar;
for_int(i, 8) ar.push(Point(float(i), 0.f, 0.f));
SHOW(ar);
}
{
Point p(1.f, 2.f, 3.f);
Vector v(4.f, 5.f, 6.f);
SHOW(1);
SHOW(p);
SHOW(v);
SHOW(p + v);
SHOW(2.f * v);
}
SHOW(1.f / 3.f);
SHOW_PRECISE(1.f / 3.f);
SHOW(1.f / 3.f, "string", 4.f / 7.f);
SHOW_PRECISE(1.f / 3.f, "string", 4.f / 7.f);
}
test_implicit_default_virtual_destructor();
{
string s1 = R"(ab"!''""'&cdefg)";
string s2 = R"(hh1 "a' | & " b.txt" "a' b.txt" "a' b.txt" &~!@#$%^&*()`[]{};:,.<>/?-_=\+)";
SHOW(quote_arg_for_sh(s1));
SHOW(quote_arg_for_sh(s2));
}
{
std::cout << sform("%d %d\n", 37, 29);
string s;
for_int(i, 30) {
ssform(s, "%d", (1 << i));
SHOW(s);
}
}
{
SHOW(first_of(0, 0, 2, 1));
SHOW(first_of(2));
SHOW(first_of(0));
SHOW(first_of(0, 2));
SHOW(first_of(2, 0));
}
{
// raw string literal examples
string s0 = R"(new literal\t string)";
string s1 = R"(line 1
line2)";
string s2 = R"(it indents ok)";
SHOW(s0);
SHOW(s1);
SHOW(s2);
}
{
Array<int> ar{3, 2, 1, 4, 5};
SHOW(ar);
SHOW(reverse(clone(ar)));
SHOW(ar);
SHOW(reverse(ar));
SHOW(ar);
SHOW(sort(clone(ar)));
SHOW(ar);
SHOW(sort(ar));
SHOW(ar);
#if 0
ArrayView<int> arv(ar);
auto arv2 = clone(arv);
dummy_use(arv2); // correctly fails static_assert
#endif
}
{
struct A {
A() { SHOW("A default construct"); }
A(const A& /*unused*/) { SHOW("A copy construct"); }
A(A&& /*unused*/) noexcept { SHOW("A move construct"); }
~A() { SHOW("A destruct"); }
};
SHOW("1");
{ A a; }
SHOW("2");
{ A(); }
SHOW("3");
{
A a;
A a2(a);
}
SHOW("4");
{ clone(A()); }
SHOW("5");
{
A a;
clone(a);
}
SHOW("6");
}
{
SHOW(type_name<sum_type_t<float>>());
SHOW(type_name<sum_type_t<double>>());
SHOW(type_name<sum_type_t<signed char>>()); // sign of regular char is platform-dependent
SHOW(type_name<sum_type_t<uchar>>());
SHOW(type_name<sum_type_t<uint8_t>>());
SHOW(type_name<sum_type_t<short>>());
SHOW(type_name<sum_type_t<ushort>>());
SHOW(type_name<sum_type_t<int>>());
SHOW(type_name<sum_type_t<unsigned>>());
SHOW(type_name<sum_type_t<char*>>());
}
{
constexpr auto vsign = sign(-TAU);
SHOW(vsign, type_name<decltype(vsign)>());
constexpr auto vsignz = signz(-TAU);
SHOW(vsignz, type_name<decltype(vsignz)>());
constexpr auto vsignd = sign(-D_TAU);
SHOW(vsignd, type_name<decltype(vsignd)>());
constexpr auto vsignzd = signz(-D_TAU);
SHOW(vsignzd, type_name<decltype(vsignzd)>());
constexpr auto vsquare5 = square(5);
SHOW(vsquare5);
constexpr auto vclamped10 = clamp(-11, 10, 20);
SHOW(vclamped10);
const auto vclamped30 = general_clamp(30, 10, 20);
SHOW(vclamped30);
const int v5mod3 = mod3(5);
SHOW(v5mod3);
constexpr int vint33 = assert_narrow_cast<int>(33ll);
SHOW(vint33);
}
{
Array<uchar> buf(10);
SHOW(sizeof(buf[0]));
}
{
Array<ushort> buf(0);
SHOW(sizeof(buf[0]));
}
{
#define F_EACH(x) (2 * (x))
#define F(...) HH_APPLY((F_EACH, __VA_ARGS__))
float a = pow(F(1.f, 2.f));
SHOW(a);
float b[] = {F(1.f, 2.f)};
SHOW(b[0]);
SHOW(b[1]);
#undef F
#undef F_EACH
}
{
int n;
n = HH_NUM_ARGS(1);
SHOW(n);
n = HH_NUM_ARGS(1, 2);
SHOW(n);
n = HH_NUM_ARGS(1, 2, 3);
SHOW(n);
n = HH_NUM_ARGS(1, 2, 3, 4);
SHOW(n);
n = HH_NUM_ARGS(1, 2, 3, 4, 5);
SHOW(n);
SHOW(HH_NUM_ARGS(a, b, c, d, e, f));
}
{
// SHOW(HH_NUM_ARGS());
SHOW(HH_NUM_ARGS(1));
SHOW(HH_NUM_ARGS(1, 2));
SHOW(HH_NUM_ARGS(1, 2, 3));
//
SHOW(HH_GT1_ARGS(1));
SHOW(HH_GT1_ARGS(1, 2));
SHOW(HH_GT1_ARGS(1, 2, 3));
}
{
float a = 16.f;
int n = 5;
auto b = V(2.f, 4.f);
SHOW(a);
SHOW(a, n, a);
SHOW(1, 2, 3, 4, 5);
SHOW(1, 2, 3, 4, 5, 6);
SHOW(1, 2, 3, 4, 5, 6, 7);
SHOW(1, 2, 3, 4, 5, 6, 7, 8);
SHOW(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
SHOW(a, b[0], b[1], n, a, a, a);
SHOW(n, a, b[0], b[1], a, n);
}
{
#define E(...) #__VA_ARGS__
SHOW(E(1, 2, 3));
SHOW(E(1));
#undef E
}
{
for (int i : {std::numeric_limits<int>::min(), std::numeric_limits<int>::min() + 1, -257, -256, -255, -1, 0, 1, 2,
127, 254, 255, 256, 257, std::numeric_limits<int>::max()}) {
SHOW(i, int(clamp_to_uint8(i)));
}
}
{
SHOW("This is string1.");
SHOW("status", 9 - 5);
SHOW("", 9 - 3, "string1", 3 + 1, "", 4 - 1);
SHOW("");
SHOW(9 - 3);
SHOW("string");
SHOW("");
SHOW("done");
}
{
unsigned col = 12345 + g_unoptimized_zero;
func1( // uint8_t(col >> 0), Run-Time Check Failure #1 - A cast to a smaller data type has caused a loss of data.
uint8_t((col >> 0) & 0xFF), uint8_t((col >> 8) & 0xFF), uint8_t((col >> 16) & 0xFF), uint8_t((col >> 24)));
}
test_exceptions();
if (1) {
const int len = 5000;
string format = string(len, 'H') + "%d%s"; // a long format specifier
string str = sform_nonliteral(format.c_str(), 123, "hello");
assertx(str.size() == len + 3 + 5);
assertx(ends_with(str, "HHHHHHHHHH123hello"));
//
// str.resize(17);
// ssform(str, format.c_str(), 123, "hello");
// assertx(str.size() == len + 3 + 5);
// assertx(ends_with(str, "HHHHHHHHHH123hello"));
}
if (1) {
string str;
for_int(len, 1000) {
string sref;
for_int(i, len) sref += '0' + (i % 10);
const string& str2 = ssform(str, "%s", sref.c_str());
if (str2 != sref) {
SHOW(sref, str2);
assertx(str2 == sref);
}
}
}
if (1) {
RFile fi("echo ' abc' |"); // test to verify that we read the first space using getline
string sline;
assertx(my_getline(fi(), sline));
assertx(sline == " abc");
}
{
// test std::forward in assertx()
constexpr int i = assertx(55);
assertx(i == 55);
int j = 56;
const int& j2 = assertx(j);
assertx(&j2 == &j);
assertx(j2 == 56);
int& j3 = assertx(j);
assertx(&j3 == &j);
assertx(j3 == 56);
auto p = make_unique<int>(57);
unique_ptr<int> p2 = std::move(assertx(p));
assertx(*p2 == 57 && !p);
unique_ptr<int> p3 = assertx(std::move(p2));
assertx(*p3 == 57 && !p2);
}
if (0) {
SHOW(alignof(ArrayView<char>)); // 8 on win, mingw
SHOW(sizeof(ArrayView<char>)); // 16 on win, mingw
SHOW(alignof(Array<char>)); // 8 on win, mingw
SHOW(sizeof(Array<char>)); // 24 on win; 16 on mingw (pleasant surprise), 12 on clang (32-bit)
// see ~/git/hh_src/test/native/bug_size.cpp
}
}
| [
"hhoppe@gmail.com"
] | hhoppe@gmail.com |
0c774c3c074ce0cf7545d96da41fa18077db459d | 5fccc73aa011640d86b6f1f2aeba3780bdcdffa3 | /lc237_delete_node_in_a_linked_list.cpp | 8641885b72e8195e884b64284d2a130da484022b | [] | no_license | akankshapatel/competitive_programming | e0436b7bfec9698a3dc65d9e9a0e1d7c2da56f1a | 1e38470b3c700a79522efa4efcdec617b685a98a | refs/heads/master | 2020-04-01T15:29:53.061764 | 2018-11-01T11:25:53 | 2018-11-01T11:25:53 | 153,339,472 | 0 | 0 | null | 2018-11-29T12:32:11 | 2018-10-16T19:05:32 | C++ | UTF-8 | C++ | false | false | 353 | cpp | /***
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
void deleteNode(ListNode* node) {
ListNode *n = node;
n->val = n->next->val;
n->next = n->next->next;
node = NULL;
}
};
| [
"90akankshapatel@gmail.com"
] | 90akankshapatel@gmail.com |
836569e062e17b551d177f41a3b77487bb464f39 | 67bb53bfc7bd0dcb23e26c37ba42f6f1236ec7de | /dependencies/TinyTest/TinyAssert.cpp | 7d81c3e0e55b0056b4168eaad4719ba1d6b8cb61 | [
"MIT",
"Unlicense"
] | permissive | anylee2021/xo | f633629a790e52942dd66a3352e7166a3b80255c | 575429591c166cc70db60385d2a6563d0f9bc9ed | refs/heads/master | 2022-03-28T00:08:51.689420 | 2018-07-04T07:31:31 | 2018-07-04T07:31:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,312 | cpp | #include <stdio.h>
TT_UNIVERSAL_FUNC bool TTIsRunningUnderMaster()
{
#ifdef _WIN32
#ifdef _UNICODE
OutputDebugString(GetCommandLine());
//printf( "IsRunningUnderMaster? %d\n", wcsstr( GetCommandLine(), L" test =" ) != nullptr );
return wcsstr(GetCommandLineW(), L" test =") != nullptr;
#else
return strstr(GetCommandLine(), " test =") != nullptr;
#endif
#else
bool result = true;
FILE* f = fopen("/proc/self/cmdline", "r");
if (f != nullptr)
{
char buf[1024];
int len = fread(buf, 1, 1023, f);
buf[len] = 0;
result = strstr(buf, " test =") != nullptr;
fclose(f);
}
return result;
#endif
}
TT_UNIVERSAL_FUNC void TTAssertFailed(const char* exp, const char* filename, int line_number, bool die)
{
printf("Test Failed:\nExpression: %s\nFile: %s\nLine: %d", exp, filename, line_number);
fflush(stdout);
fflush(stderr);
if (TTIsRunningUnderMaster())
{
#ifdef _WIN32
// Use TerminateProcess instead of exit(), because we don't want any C++ cleanup, or CRT cleanup code to run.
// Such "at-exit" functions are prone to popping up message boxes about resources that haven't been cleaned up, but
// at this stage, that is merely noise.
TerminateProcess(GetCurrentProcess(), 1);
#else
_exit(1);
#endif
}
else
{
#ifdef _WIN32
__debugbreak();
#else
__builtin_trap();
#endif
}
}
| [
"rogojin@gmail.com"
] | rogojin@gmail.com |
960a8d252560aca25cc1863fbe03af5b96675ec7 | b1d5436bae6f8d85e2700d762a06b0e53f3905fe | /hackerearth/DP/vaitowers.cpp | 25d0aeb37d4cbfce2c9bd1eb5c49104b59e49a90 | [] | no_license | Hrithvik-Alex/competitive-programming-problems | 23044103ed935c6f62cb9e317f108e0fe1d19a45 | 34e3138df8a2375355af9ba5c5594291c9d6a402 | refs/heads/master | 2021-07-14T22:37:12.544771 | 2020-08-25T07:43:59 | 2020-08-25T07:43:59 | 163,223,233 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,036 | cpp | #include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <climits>
#include <cmath>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#define pb push_back
#define mp make_pair
#define ii pair<int, int>
#define ll long long
#define forn(i, a, b) for(int i = (int)a; i <(int)b;i++)
using namespace std;
int A[100001];
int main(){
int t,n;
cin >> t;
while(t--){
cin >> n;
int negs = 0;
int pos = 0;
forn(i,0,n) {
cin >> A[i];
if(A[i] < 0) negs++;
else pos++;
}
if(negs == 0 || pos == 0) {
cout << 1 << endl;
continue;
}
int minchange = INT_MAX;
int posbf = 0;
forn(i,0,n){
minchange = min(minchange, negs+posbf);
if(A[i]>0){
posbf++;
} else {
negs--;
}
}
cout << minchange << endl;
}
} | [
"halex623@gmail.com"
] | halex623@gmail.com |
e5c3bec580c9a7ec6bf1eddc7b76d721b87e5e5e | cbd7f17ec8e983e3f302aa3c9a4c5bd676789bef | /code/steps/source/model/model_var_table_test.cpp | 69feb38205cb1b706d666182fe0d13fe23503ff5 | [
"MIT"
] | permissive | yuanzy97/steps | 477bce28a11c8e5890f27bb56490f3b80b343048 | 139193a9c84ad15e342f632ac29afac909802b78 | refs/heads/master | 2023-04-29T10:00:13.987075 | 2022-04-13T13:08:17 | 2022-04-13T13:08:17 | 256,682,978 | 0 | 0 | MIT | 2020-04-18T06:13:20 | 2020-04-18T06:13:20 | null | UTF-8 | C++ | false | false | 1,958 | cpp | #include "header/basic/test_macro.h"
#include "header/model/model_var_table_test.h"
#include "header/basic/utility.h"
#ifdef ENABLE_STEPS_TEST
using namespace std;
MODEL_VAR_TABLE_TEST::MODEL_VAR_TABLE_TEST()
{
TEST_ADD(MODEL_VAR_TABLE_TEST::test_clear);
TEST_ADD(MODEL_VAR_TABLE_TEST::test_add_get_variable_name_index_pair);
}
void MODEL_VAR_TABLE_TEST::setup()
{
table = new MODEL_VAR_TABLE;
}
void MODEL_VAR_TABLE_TEST::tear_down()
{
delete table;
show_test_end_information();
}
void MODEL_VAR_TABLE_TEST::test_clear()
{
show_test_information_for_function_of_class(__FUNCTION__,"MODEL_VAR_TABLE_TEST");
table->add_variable_name_index_pair("abc", 0);
TEST_ASSERT((*table)["abc"]==0);
TEST_ASSERT((*table)[0]=="ABC");
table->clear();
TEST_ASSERT((*table)["abc"]==INDEX_NOT_EXIST);
}
void MODEL_VAR_TABLE_TEST::test_add_get_variable_name_index_pair()
{
show_test_information_for_function_of_class(__FUNCTION__,"MODEL_VAR_TABLE_TEST");
table->add_variable_name_index_pair("abc", 0);
TEST_ASSERT((*table)["abc"]==0);
TEST_ASSERT((*table)[0]=="ABC");
TEST_ASSERT((*table).size()==1);
table->add_variable_name_index_pair("def", 1);
TEST_ASSERT((*table)["abc"]==0);
TEST_ASSERT((*table)[0]=="ABC");
TEST_ASSERT((*table)["def"]==1);
TEST_ASSERT((*table)[1]=="DEF");
TEST_ASSERT((*table).size()==2);
table->add_variable_name_index_pair("def", 2);
TEST_ASSERT((*table)["abc"]==0);
TEST_ASSERT((*table)[0]=="ABC");
TEST_ASSERT((*table)["def"]==1);
TEST_ASSERT((*table)[1]=="DEF");
TEST_ASSERT((*table)[2]=="");
TEST_ASSERT((*table).size()==3);
table->add_variable_name_index_pair("acf", 0);
TEST_ASSERT((*table)["abc"]==0);
TEST_ASSERT((*table)[0]=="ABC");
TEST_ASSERT((*table)["def"]==1);
TEST_ASSERT((*table)[1]=="DEF");
TEST_ASSERT((*table).size()==3);
TEST_ASSERT((*table)["acf"]==INDEX_NOT_EXIST);
}
#endif
| [
"lichgang@sdu.edu.cn"
] | lichgang@sdu.edu.cn |
3c40e9e32ca5b5716eb6aaf999d188d7e552b4de | 7fe3e44cf771a7a811890a7d2ac78ed6708ddedf | /Engine/source/lighting/common/blobShadow.cpp | dd19df091e15d4e536ab1846716a8f4c45a6fb3a | [] | no_license | konradkiss/meshloop | 988ee721fb6463fbfece183c70f678c047215dd5 | 25b98ce223d21e232593a6c4dc2d6d863aace02c | refs/heads/master | 2021-03-19T13:36:21.104735 | 2015-05-21T13:00:55 | 2015-05-21T13:00:55 | 36,012,137 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,399 | cpp | //-----------------------------------------------------------------------------
// Torque 3D
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "lighting/common/blobShadow.h"
#include "gfx/primBuilder.h"
#include "gfx/gfxTextureManager.h"
#include "gfx/bitmap/gBitmap.h"
#include "math/mathUtils.h"
#include "lighting/lightInfo.h"
#include "lighting/lightingInterfaces.h"
#include "T3D/shapeBase.h"
#include "sceneGraph/sceneGraph.h"
#include "lighting/lightManager.h"
#include "ts/tsMesh.h"
DepthSortList BlobShadow::smDepthSortList;
GFXTexHandle BlobShadow::smGenericShadowTexture = NULL;
S32 BlobShadow::smGenericShadowDim = 32;
U32 BlobShadow::smShadowMask = TerrainObjectType | InteriorObjectType;
F32 BlobShadow::smGenericRadiusSkew = 0.4f; // shrink radius of shape when it always uses generic shadow...
Box3F gBlobShadowBox;
SphereF gBlobShadowSphere;
Point3F gBlobShadowPoly[4];
//--------------------------------------------------------------
BlobShadow::BlobShadow(SceneObject* parentObject, LightInfo* light, TSShapeInstance* shapeInstance)
{
mParentObject = parentObject;
mShapeBase = dynamic_cast<ShapeBase*>(parentObject);
mParentLight = light;
mShapeInstance = shapeInstance;
mRadius = 0.0f;
mLastRenderTime = 0;
mDepthBias = -0.0002f;
generateGenericShadowBitmap(smGenericShadowDim);
setupStateBlocks();
}
void BlobShadow::setupStateBlocks()
{
GFXStateBlockDesc sh;
sh.cullDefined = true;
sh.cullMode = GFXCullNone;
sh.zDefined = true;
sh.zEnable = true;
sh.zWriteEnable = false;
sh.zBias = mDepthBias;
sh.blendDefined = true;
sh.blendEnable = true;
sh.blendSrc = GFXBlendSrcAlpha;
sh.blendDest = GFXBlendInvSrcAlpha;
sh.alphaDefined = true;
sh.alphaTestEnable = true;
sh.alphaTestFunc = GFXCmpGreater;
sh.alphaTestRef = 0;
sh.samplersDefined = true;
sh.samplers[0] = GFXSamplerStateDesc::getClampLinear();
mShadowSB = GFX->createStateBlock(sh);
}
BlobShadow::~BlobShadow()
{
mShadowBuffer = NULL;
}
bool BlobShadow::shouldRender(F32 camDist)
{
Point3F lightDir;
if (mShapeBase && mShapeBase->getFadeVal() < TSMesh::VISIBILITY_EPSILON)
return false;
F32 shadowLen = 10.0f * mShapeInstance->getShape()->radius;
Point3F pos = mShapeInstance->getShape()->center;
// this is a bit of a hack...move generic shadows towards feet/base of shape
pos *= 0.5f;
pos.convolve(mParentObject->getScale());
mParentObject->getRenderTransform().mulP(pos);
if(mParentLight->getType() == LightInfo::Vector)
{
lightDir = mParentLight->getDirection();
}
else
{
lightDir = pos - mParentLight->getPosition();
lightDir.normalize();
}
// pos is where shadow will be centered (in world space)
setRadius(mShapeInstance, mParentObject->getScale());
bool render = prepare(pos, lightDir, shadowLen);
return render;
}
void BlobShadow::generateGenericShadowBitmap(S32 dim)
{
if(smGenericShadowTexture)
return;
GBitmap * bitmap = new GBitmap(dim,dim,false,GFXFormatR8G8B8A8);
U8 * bits = bitmap->getWritableBits();
dMemset(bits, 0, dim*dim*4);
S32 center = dim >> 1;
F32 invRadiusSq = 1.0f / (F32)(center*center);
F32 tmpF;
for (S32 i=0; i<dim; i++)
{
for (S32 j=0; j<dim; j++)
{
tmpF = (F32)((i-center)*(i-center)+(j-center)*(j-center)) * invRadiusSq;
U8 val = tmpF>0.99f ? 0 : (U8)(180.0f*(1.0f-tmpF)); // 180 out of 255 max
bits[(i*dim*4)+(j*4)+3] = val;
}
}
smGenericShadowTexture.set( bitmap, &GFXDefaultStaticDiffuseProfile, true, "BlobShadow" );
}
//--------------------------------------------------------------
void BlobShadow::setLightMatrices(const Point3F & lightDir, const Point3F & pos)
{
AssertFatal(mDot(lightDir,lightDir)>0.0001f,"BlobShadow::setLightDir: light direction must be a non-zero vector.");
// construct light matrix
Point3F x,z;
if (mFabs(lightDir.z)>0.001f)
{
// mCross(Point3F(1,0,0),lightDir,&z);
z.x = 0.0f;
z.y = lightDir.z;
z.z = -lightDir.y;
z.normalize();
mCross(lightDir,z,&x);
}
else
{
mCross(lightDir,Point3F(0,0,1),&x);
x.normalize();
mCross(x,lightDir,&z);
}
mLightToWorld.identity();
mLightToWorld.setColumn(0,x);
mLightToWorld.setColumn(1,lightDir);
mLightToWorld.setColumn(2,z);
mLightToWorld.setColumn(3,pos);
mWorldToLight = mLightToWorld;
mWorldToLight.inverse();
}
void BlobShadow::setRadius(F32 radius)
{
mRadius = radius;
}
void BlobShadow::setRadius(TSShapeInstance * shapeInstance, const Point3F & scale)
{
const Box3F & bounds = shapeInstance->getShape()->bounds;
F32 dx = 0.5f * (bounds.maxExtents.x-bounds.minExtents.x) * scale.x;
F32 dy = 0.5f * (bounds.maxExtents.y-bounds.minExtents.y) * scale.y;
F32 dz = 0.5f * (bounds.maxExtents.z-bounds.minExtents.z) * scale.z;
mRadius = mSqrt(dx*dx+dy*dy+dz*dz);
}
//--------------------------------------------------------------
bool BlobShadow::prepare(const Point3F & pos, Point3F lightDir, F32 shadowLen)
{
if (mPartition.empty())
{
// --------------------------------------
// 1.
F32 dirMult = (1.0f) * (1.0f);
if (dirMult < 0.99f)
{
lightDir.z *= dirMult;
lightDir.z -= 1.0f - dirMult;
}
lightDir.normalize();
shadowLen *= (1.0f) * (1.0f);
// --------------------------------------
// 2. get polys
F32 radius = mRadius;
radius *= smGenericRadiusSkew;
buildPartition(pos,lightDir,radius,shadowLen);
}
if (mPartition.empty())
// no need to draw shadow if nothing to cast it onto
return false;
return true;
}
//--------------------------------------------------------------
void BlobShadow::buildPartition(const Point3F & p, const Point3F & lightDir, F32 radius, F32 shadowLen)
{
setLightMatrices(lightDir,p);
Point3F extent(2.0f*radius,shadowLen,2.0f*radius);
smDepthSortList.clear();
smDepthSortList.set(mWorldToLight,extent);
smDepthSortList.setInterestNormal(lightDir);
if (shadowLen<1.0f)
// no point in even this short of a shadow...
shadowLen = 1.0f;
mInvShadowDistance = 1.0f / shadowLen;
// build world space box and sphere around shadow
Point3F x,y,z;
mLightToWorld.getColumn(0,&x);
mLightToWorld.getColumn(1,&y);
mLightToWorld.getColumn(2,&z);
x *= radius;
y *= shadowLen;
z *= radius;
gBlobShadowBox.maxExtents.set(mFabs(x.x)+mFabs(y.x)+mFabs(z.x),
mFabs(x.y)+mFabs(y.y)+mFabs(z.y),
mFabs(x.z)+mFabs(y.z)+mFabs(z.z));
y *= 0.5f;
gBlobShadowSphere.radius = gBlobShadowBox.maxExtents.len();
gBlobShadowSphere.center = p + y;
gBlobShadowBox.minExtents = y + p - gBlobShadowBox.maxExtents;
gBlobShadowBox.maxExtents += y + p;
// get polys
gClientContainer.findObjects(STATIC_COLLISION_MASK, BlobShadow::collisionCallback, this);
// setup partition list
gBlobShadowPoly[0].set(-radius,0,-radius);
gBlobShadowPoly[1].set(-radius,0, radius);
gBlobShadowPoly[2].set( radius,0, radius);
gBlobShadowPoly[3].set( radius,0,-radius);
mPartition.clear();
mPartitionVerts.clear();
smDepthSortList.depthPartition(gBlobShadowPoly,4,mPartition,mPartitionVerts);
if(mPartitionVerts.empty())
return;
// Find the rough distance of the shadow verts
// from the object position and use that to scale
// the visibleAlpha so that the shadow fades out
// the further away from you it gets
F32 dist = 0.0f;
// Calculate the center of the partition verts
Point3F shadowCenter(0.0f, 0.0f, 0.0f);
for (U32 i = 0; i < mPartitionVerts.size(); i++)
shadowCenter += mPartitionVerts[i];
shadowCenter /= mPartitionVerts.size();
mLightToWorld.mulP(shadowCenter);
dist = (p - shadowCenter).len();
// now set up tverts & colors
mShadowBuffer.set(GFX, mPartitionVerts.size(), GFXBufferTypeVolatile);
mShadowBuffer.lock();
F32 visibleAlpha = 255.0f;
if (mShapeBase && mShapeBase->getFadeVal())
visibleAlpha = mClampF(255.0f * mShapeBase->getFadeVal(), 0, 255);
visibleAlpha *= 1.0f - (dist / gBlobShadowSphere.radius);
F32 invRadius = 1.0f / radius;
for (S32 i=0; i<mPartitionVerts.size(); i++)
{
Point3F vert = mPartitionVerts[i];
mShadowBuffer[i].point.set(vert);
mShadowBuffer[i].color.set(255, 255, 255, visibleAlpha);
mShadowBuffer[i].texCoord.set(0.5f + 0.5f * mPartitionVerts[i].x * invRadius, 0.5f + 0.5f * mPartitionVerts[i].z * invRadius);
};
mShadowBuffer.unlock();
}
//--------------------------------------------------------------
void BlobShadow::collisionCallback(SceneObject * obj, void* thisPtr)
{
if (obj->getWorldBox().isOverlapped(gBlobShadowBox))
{
// only interiors clip...
ClippedPolyList::allowClipping = (obj->getTypeMask() & gClientSceneGraph->getLightManager()->getSceneLightingInterface()->mClippingMask) != 0;
obj->buildPolyList(&smDepthSortList,gBlobShadowBox,gBlobShadowSphere);
ClippedPolyList::allowClipping = true;
}
}
//--------------------------------------------------------------
void BlobShadow::render( F32 camDist, const TSRenderState &rdata )
{
mLastRenderTime = Platform::getRealMilliseconds();
GFX->pushWorldMatrix();
MatrixF world = GFX->getWorldMatrix();
world.mul(mLightToWorld);
GFX->setWorldMatrix(world);
GFX->disableShaders();
GFX->setStateBlock(mShadowSB);
GFX->setTexture(0, smGenericShadowTexture);
GFX->setVertexBuffer(mShadowBuffer);
for(U32 p=0; p<mPartition.size(); p++)
GFX->drawPrimitive(GFXTriangleFan, mPartition[p].vertexStart, (mPartition[p].vertexCount - 2));
// This is a bad nasty hack which forces the shadow to reconstruct itself every frame.
mPartition.clear();
GFX->popWorldMatrix();
}
void BlobShadow::deleteGenericShadowBitmap()
{
smGenericShadowTexture = NULL;
}
| [
"konrad@konradkiss.com"
] | konrad@konradkiss.com |
da6d8edef83c6966a23ecd82a956cbd0202de251 | 9dc0fa3d2fb4cafe03f2c37993296ccfc00a9f10 | /多进程Cookie共享调研/HookCookieTest/HookCookieTest.h | 330d926e95314b39939d2509eb97e71ed04df54a | [] | no_license | 15831944/OtherCode | 129a4510a1deb829a3200b0e2950e59515bb4eb6 | 531041387408d0cf4d7f16f7455d2bc458e9749a | refs/heads/master | 2021-05-30T10:30:53.182541 | 2016-01-17T13:36:19 | 2016-01-17T13:36:19 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 566 | h |
// HookCookieTest.h : HookCookieTest 应用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
#endif
#include "resource.h" // 主符号
// CHookCookieTestApp:
// 有关此类的实现,请参阅 HookCookieTest.cpp
//
class CHookCookieTestApp : public CWinApp
{
public:
CHookCookieTestApp();
// 重写
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// 实现
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
};
extern CHookCookieTestApp theApp;
| [
"cugxiangzhenwei@sina.cn"
] | cugxiangzhenwei@sina.cn |
9bdaec23ebbec23068b9d3dad20b4071a2eeced5 | d02b0e249d0bc953882d636d199bbdaad7e58784 | /lab2_oop_ispravlenie/lab2_oop_ispravlenie/lab2_oop_ispravlenie.cpp | 74375023d4d142a1da3e88b994c9f613fa628757 | [] | no_license | nikolasj/lab_C2 | a89f65361db4567c748d211799c2de4ff0a5440e | bce278f784b6f444f5f23ebd0261c0b9f7ba82ee | refs/heads/master | 2021-01-22T17:33:41.265699 | 2016-05-28T15:05:29 | 2016-05-28T15:05:29 | 59,892,762 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 14,756 | cpp | #include <iostream>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <vector>
using namespace std;
class SuppBase
{
public:
virtual int Get() = 0;
};
class SuppFile :public SuppBase
{
FILE *fp;
public:
SuppFile(char* filename)
{
fopen_s(&fp, filename, "r");
}
~SuppFile()
{
fclose(fp);
}
int Get()
{
int chislo = 0;
while (fscanf_s(fp, "%i", &chislo))
{
cout << chislo << endl;
return chislo;
}
return -1;
}
};
class SuppKbrd :public SuppBase
{
public:
int Get()
{
int chislo = 0;
cin >> chislo;
return chislo;
}
};
class Freq
{
protected:
map<int, int> massiv;
int n;
public:
//friend ostream& operator << (ostream& out, Freq& a);
void Calc(SuppBase* p)
{
int i = 0;
int number;
number = p->Get();
do
{
if (number > 0)
{
massiv[number]++;
i++;
}
} while (number > 0);
n = i;
}
map<int, int> GetArrayFreq()
{
return massiv;
}
int GetN()
{
return n;
}
};
class Diap :public Freq
{
int sum, min, max;
public:
Diap()
{
sum = 0;
min = 0;
max = 0;
}
//friend ostream& operator << (ostream& out, Diap& a);
void Calc(SuppBase*p)
{
Freq* t;
int i = 0;
int number;
number = p->Get();
min = number;
max = number;
while (number > 0)
{
sum +=number;
if (number < min) min = number;
if (number > max) max = number;
number = p->Get();
i++;
}
}
int GetSum()
{
return sum;
}
int GetMin()
{
return min;
}
int GetMax()
{
return max;
}
//friend ostream& operator << (ostream& out, Freq& a);
};
ostream& operator << (ostream& out, Diap* a)//через friend-функцию сделать
{
out << "Max=" << a->GetMax() << endl << "Min=" << a->GetMin() << endl << "Sum=" << a->GetSum() << endl;
return out;
}
ostream& operator << (ostream& out, Freq* a)//через friend-функцию сделать
{
map<int, int> array = a->GetArrayFreq();
std::map<int, int>::iterator it = array.begin();
for (it = array.begin(); it != array.end(); it++)
out << (*it).first << " " << (*it).second << endl;
return out;
}
int main()
{
setlocale(LC_ALL, "rus");
char l; int vvod;
SuppBase *p;
SuppKbrd a;// если файл, то нужно чтобы вводил пользователь файл, так как будет конструктор же
cout << "Введите 2 для ввода чисел с клавиатуры или 1 для чтения чисел из файла " << endl;
cin >> vvod;
if (vvod != 1)
p = &a;
else
{
SuppFile b("file.txt");
p = &b;
}
Freq *freq = new Freq();
cout << "Обрабатываем массив" << endl;
freq->Calc(p);
cout << freq << endl;
if (vvod != 1)
{
cout << "Обрабатываем массив 2" << endl;
Diap* diap = new Diap();
diap->Calc(p);
cout << diap << endl;
}
else
{
SuppFile c("file.txt");
p = &c;
cout << "Обрабатываем массив 2" << endl;
Diap* diap = new Diap();
diap->Calc(p);
cout << diap << endl;
}
cin >> l;
return 0;
}
//}
//using namespace std;
//class SuppBase
//{
//public:
// virtual int Get() = 0;
// //virtual void Close() = 0;
//};
//class SuppFile :public SuppBase
//{
// FILE *fp;
//public:
// SuppFile(char* filename)
// {
// fopen_s(&fp, filename, "r");
// }//конструктор, здесь нужнооткрывать файл, проверки здесь делать
// ~SuppFile()
// {
// fclose(fp);
// }
// int Get()//диструктор, нужно закрывать файл
// {
// int chislo = 0;
// //если открытие файла прошло корректно, то
//
// while (fscanf_s(fp, "%i", &chislo))
// {
// //cout << chislo << endl;
// return chislo;
// }
//
// return -1;
// }
// /*void Close()
// {
// fclose(fp);
// }*/
//
//};
//class SuppKbrd :public SuppBase
//{
//public:
// int Get()
// {
// int chislo = 0;
// cin >> chislo;
// return chislo;
// }
// /*void Close()
// {
//
// }*/
//};
//class Freq
//{
//protected:
// map<int, int> massiv;
// int n;
//public:
// //friend ostream& operator << (ostream& out, Freq& a);
// void Calc(SuppBase* p)// в цикле Get пока не отрицательное, но лучше конец церез Ctrl+Z
// {
// int i = 0;
// int number;
// do
// {
// number = p->Get();
// if (number > 0)
// {
// massiv[number]++;
// i++;
// }
// } while (number > 0);
// n = i;
// //p->Close();
// }
// map<int, int> GetArrayFreq()
// {
// return massiv;
// }
// int GetN()
// {
// return n;
// }
//};
//class Diap :public Freq
//{
// int sum, min, max;
//public:
// Diap()
// {
// sum = 0;
// min = 0;
// max = 0;
// }
// //friend ostream& operator << (ostream& out, Diap& a);
// void Calc(SuppBase*p)
// {
// /* if (p->GetN() == 0)
// cout « "Error";
// else
// {*/
// Freq* t;
//
// int i = 0;
// int number;
// number = p->Get();
// min = number;
// max = number;
//
// while (number > 0)
// {
// sum += number;
// if (number < min) min = number;
// if (number > max) max = number;
// number = p->Get();
// i++;
// }
// //p->Close();
// }
// int GetSum()
// {
// return sum;
// }
// int GetMin()
// {
// return min;
// }
// int GetMax()
// {
// return max;
// }
// //friend ostream& operator << (ostream& out, Freq& a);
//};
//ostream& operator << (ostream& out, Diap* a)//через friend-функцию сделать
//{
// out << "Max=" << a->GetMax() << endl << "Min=" << a->GetMin() << endl << "Sum=" << a->GetSum() << endl;
// return out;
//}
//ostream& operator << (ostream& out, Freq* a)//через friend-функцию сделать
//{
// map<int, int> array = a->GetArrayFreq();
// std::map<int, int>::iterator it = array.begin();
// for (it = array.begin(); it != array.end(); it++)
// out << (*it).first << " " << (*it).second << endl;
// return out;
//}
//int main()
//{
// setlocale(LC_ALL, "rus");
// char l; int vvod; string name2;
// SuppBase *p;
// SuppKbrd a;// если файл, то нужно чтобы вводил пользователь файл, так как будет конструктор же
// cout << "Введите 2 для ввода чисел с клавиатуры или 1 для чтения чисел из файла " << endl;
// cin >> vvod;
// if (vvod != 1)
// p = &a;
// else
// {
// cout << "Введите имя файла" << endl;
// cin >> name2;
// char* name = new char[name2.length() + 1];
// strcpy(name, name2.c_str());
// SuppFile b(name);
// p = &b;
// }
// Freq *freq = new Freq();
// cout << "Обрабатываем массив" << endl;
// freq->Calc(p);
// cout << freq << endl;
// if (vvod != 1)
// {
// cout << "Обрабатываем массив 2" << endl;
// Diap* diap = new Diap();
// diap->Calc(p);
// cout << diap << endl;
// }
// else
// {
// SuppFile c("file.txt");
// p = &c;
// cout << "Обрабатываем массив 2" << endl;
// Diap* diap = new Diap();
// diap->Calc(p);
// cout << diap << endl;
// }
// cin >> l;
// return 0;
//}
//#include <iostream>
//#include <fstream>
//#include <iomanip>
//#include <stdlib.h>
//#include <stdio.h>
//#include <string>
//#include <map>
//#include <vector>
//
//using namespace std;
//class SuppBase
//{
//public:
// virtual int Get() = 0;
// //virtual void Close() = 0;
//};
//class SuppFile :public SuppBase
//{
// FILE *fp;
//public:
// SuppFile(char* filename)
// {
// fopen_s(&fp, filename, "r");
// }//конструктор, здесь нужнооткрывать файл, проверки здесь делать
// ~SuppFile()
// {
// fclose(fp);
// }
// int Get()//диструктор, нужно закрывать файл
// {
// int chislo = 0;
// //если открытие файла прошло корректно, то
//
// while (fscanf_s(fp, "%i", &chislo))
// {
// //cout << chislo << endl;
// return chislo;
// }
//
// return -1;
// }
// /*void Close()
// {
// fclose(fp);
// }*/
//
//};
//class SuppKbrd :public SuppBase
//{
//public:
// int Get()
// {
// int chislo = 0;
// cin >> chislo;
// return chislo;
// }
// /*void Close()
// {
//
// }*/
//};
//class Freq
//{
//protected:
// map<int, int> massiv;
// int n;
//public:
// //friend ostream& operator << (ostream& out, Freq& a);
// void Calc(SuppBase* p)// в цикле Get пока не отрицательное, но лучше конец церез Ctrl+Z
// {
// int i = 0;
// int number;
// do
// {
// number = p->Get();
// if (number > 0)
// {
// massiv[number]++;
// i++;
// }
// } while (number > 0);
// n = i;
// //p->Close();
// }
// map<int, int> GetArrayFreq()
// {
// return massiv;
// }
// int GetN()
// {
// return n;
// }
//};
//class Diap :public Freq
//{
// int sum, min, max;
//public:
// Diap()
// {
// sum = 0;
// min = 0;
// max = 0;
// }
// //friend ostream& operator << (ostream& out, Diap& a);
// void Calc(SuppBase*p)
// {
// /* if (p->GetN() == 0)
// cout « "Error";
// else
// {*/
// Freq* t;
//
// int i = 0;
// int number;
// number = p->Get();
// min = number;
// max = number;
//
// while (number > 0)
// {
// sum += number;
// if (number < min) min = number;
// if (number > max) max = number;
// number = p->Get();
// i++;
// }
// //p->Close();
// }
// int GetSum()
// {
// return sum;
// }
// int GetMin()
// {
// return min;
// }
// int GetMax()
// {
// return max;
// }
// //friend ostream& operator << (ostream& out, Freq& a);
//};
//ostream& operator << (ostream& out, Diap* a)//через friend-функцию сделать
//{
// out << "Max=" << a->GetMax() << endl << "Min=" << a->GetMin() << endl << "Sum=" << a->GetSum() << endl;
// return out;
//}
//ostream& operator << (ostream& out, Freq* a)//через friend-функцию сделать
//{
// map<int, int> array = a->GetArrayFreq();
// std::map<int, int>::iterator it = array.begin();
// for (it = array.begin(); it != array.end(); it++)
// out << (*it).first << " " << (*it).second << endl;
// return out;
//}
//int main()
//{
// setlocale(LC_ALL, "rus");
// char l; int vvod; string name2;
// SuppBase *p;
// SuppKbrd a;// если файл, то нужно чтобы вводил пользователь файл, так как будет конструктор же
// cout << "Введите 2 для ввода чисел с клавиатуры или 1 для чтения чисел из файла " << endl;
// cin >> vvod;
// if (vvod != 1)
// p = &a;
// else
// {
// cout << "Введите имя файла" << endl;
// cin >> name2;
// char* name = new char[name2.length() + 1];
// strcpy(name, name2.c_str());
// SuppFile b(name);
// p = &b;
// }
// Freq *freq = new Freq();
// cout << "Обрабатываем массив" << endl;
// freq->Calc(p);
// cout << freq << endl;
// if (vvod != 1)
// {
// cout << "Обрабатываем массив 2" << endl;
// Diap* diap = new Diap();
// diap->Calc(p);
// cout << diap << endl;
// }
// else
// {
// SuppFile c("file.txt");
// p = &c;
// cout << "Обрабатываем массив 2" << endl;
// Diap* diap = new Diap();
// diap->Calc(p);
// cout << diap << endl;
// }
// cin >> l;
// return 0;
//}
///*
//#include <iostream>
//#include <fstream>
//#include <iomanip>
//#include <stdlib.h>
//#include <stdio.h>
//#include <string>
//#include <map>
//#include <vector>
//
//using namespace std;
//class SuppBase
//{
//public:
//virtual int Get() = 0;
//virtual void Close() = 0;
//};
//class SuppFile :public SuppBase
//{
//FILE *fp;
//public:
//SuppFile(char* filename)
//{
//fopen_s(&fp, filename, "r");
//}//конструктор, здесь нужнооткрывать файл, проверки здесь делать
//~SuppFile()
//{
//fclose(fp);
//}
//int Get()//диструктор, нужно закрывать файл
//{
//int chislo = 0;
////если открытие файла прошло корректно, то
//
//while (fscanf_s(fp, "%i", &chislo))
//{
//cout << chislo << endl;
//return chislo;
//}
//
//return -1;
//}
//void Close()
//{
//fclose(fp);
//}
//
//};
//class SuppKbrd :public SuppBase
//{
//public:
//int Get()
//{
//int chislo = 0;
//cin >> chislo;
//return chislo;
//}
//void Close()
//{
//
//}
//};
//class Freq
//{
//protected:
//map<int, int> massiv;
//int n;
//public:
//void Calc(SuppBase* p)// в цикле Get пока не отрицательное, но лучше конец церез Ctrl+Z
//{
//int i = 0;
//int number;
//do
//{
//number = p->Get();
//if (number > 0)
//{
//massiv[number]++;
//i++;
//}
//} while (number > 0);
//n = i;
//p->Close();
//}
//map<int, int> GetArrayFreq()
//{
//return massiv;
//}
//int GetN()
//{
//return n;
//}
//};
//class Diap :public Freq
//{
//int sum, min, max;
//public:
//Diap()
//{
//sum = 0;
//min = 0;
//max = 0;
//}
//void Calc(SuppBase*p)
//{
///* if (p->GetN() == 0)
//cout « "Error";
//else
//{*/
//Freq* t;
//
//int i = 0;
//int number;
//number = p->Get();
//min = number;
//max = number;
//
//while (number > 0)
//{
// sum += sum + number;
// if (number < min) min = number;
// if (number > max) max = number;
// number = p->Get();
// i++;
//}
//p->Close();
// }
// int GetSum()
// {
// return sum;
// }
// int GetMin()
// {
// return min;
// }
// int GetMax()
// {
// return max;
// }
//};
//ostream& operator << (ostream& out, Diap* a)//через friend-функцию сделать
//{
// out << "Max=" << a->GetMax() << endl << "Min=" << a->GetMin() << endl << "Sum=" << a->GetSum() << endl;
// return out;
//}
//ostream& operator << (ostream& out, Freq* a)//через friend-функцию сделать
//{
// map<int, int> array = a->GetArrayFreq();
// std::map<int, int>::iterator it = array.begin();
// for (it = array.begin(); it != array.end(); it++)
// out << (*it).first << " " << (*it).second << endl;
// return out;
//}
//int main()
//{
// setlocale(LC_ALL, "rus");
// char l; int vvod; string name;
// SuppBase *p;
// SuppKbrd a;// если файл, то нужно чтобы вводил пользователь файл, так как будет конструктор же
//
// SuppFile b("file.txt");
// cout << "Введите 2 для ввода чисел с клавиатуры или 1 для чтения чисел из файла " << endl;
// cin >> vvod;
// if (vvod != 1)
// p = &a;
// else
// p = &b;
//
// Freq *freq = new Freq();
// cout << "Обрабатываем массив" << endl;
// freq->Calc(p);
// cout << freq << endl;
//
// SuppFile c("file.txt");
// p = &c;
// cout << "Обрабатываем массив 2" << endl;
// Diap* diap = new Diap();
// diap->Calc(p);
// cout << diap << endl;
//
// cin >> l;
// return 0;
//}
//
//*/ | [
"nicolas_jusev1989@mail.ru"
] | nicolas_jusev1989@mail.ru |
81b6a5434dfa1b0be107c2b564cc23b0a8f5ed04 | 673766b4d72a4cbf4a2ad565170e0b1c4deed34c | /CGL/build-assign-b3-Desktop-Debug/moc_mainwindow.cpp | 761f8f25448dcef96d4d3a3ea3b74df535ea60e3 | [] | no_license | anuraagshankar/21340 | dedcbbd5aae6710cc6033aaf85f5e1149e9fa659 | 964ebc6bdfebea0732484bb16f988f87157f484e | refs/heads/master | 2021-05-17T03:50:17.800334 | 2020-03-11T10:15:01 | 2020-03-11T10:15:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,945 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'mainwindow.h'
**
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.6)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../assign-b3/mainwindow.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'mainwindow.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.6. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_MainWindow[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: signature, parameters, type, tag, flags
12, 11, 11, 11, 0x08,
38, 36, 11, 11, 0x08,
0 // eod
};
static const char qt_meta_stringdata_MainWindow[] = {
"MainWindow\0\0on_pushButton_clicked()\0"
"m\0mousePressEvent(QMouseEvent*)\0"
};
void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
MainWindow *_t = static_cast<MainWindow *>(_o);
switch (_id) {
case 0: _t->on_pushButton_clicked(); break;
case 1: _t->mousePressEvent((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break;
default: ;
}
}
}
const QMetaObjectExtraData MainWindow::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject MainWindow::staticMetaObject = {
{ &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow,
qt_meta_data_MainWindow, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &MainWindow::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *MainWindow::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *MainWindow::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_MainWindow))
return static_cast<void*>(const_cast< MainWindow*>(this));
return QMainWindow::qt_metacast(_clname);
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
}
return _id;
}
QT_END_MOC_NAMESPACE
| [
"mufaddal.d.786@gmail.com"
] | mufaddal.d.786@gmail.com |
515c0fc268b7b3b40f9d299804d2fe37533f8f8d | fb4055c793b34c73aa8c549b622fe223ec2d25f8 | /zhang/ShortestPath/main.cpp | 73cd1c91f0f1ac254511bc7b4cb54e907e38a0ba | [] | no_license | HapCoderWei/DataStructure | 5df23cc9b7529adfd6b835841fcb788c2bfd1eaa | 8e59189426af80f17d98849e057f0d60acd48ce4 | refs/heads/master | 2021-01-15T11:40:52.482167 | 2015-07-27T05:22:52 | 2015-07-27T05:22:52 | 38,225,956 | 2 | 1 | null | null | null | null | GB18030 | C++ | false | false | 5,918 | cpp | /*****************************************************/
/* 产生迷宫,并找到迷宫的最短出路长度
/* 输入:迷宫的规模,以房间数限定。现
/* 在程序只能支持规模Row,Col <= 4的迷
/* 宫,若超过,将无法得到结果。
/*****************************************************/
#include "Cie2DGraph.h"
using namespace Cie2DGraph;
#include <stdio.h>
#include <stdlib.h>
#define MAX_VERTEX_NUM 20
#define INFINITY 32768
typedef struct VertexData
{
int x;
int y;
char id;
//int id;
} VertexType;
#include "AdjacencyMatrix.h"
#include "GetMaze.h"
MGraph G;
char vStart = 'A', vEnd = 'P';
int RQ[MAX_VERTEX_NUM];
int g_len=0;
int g_step=0;
int P[MAX_VERTEX_NUM][MAX_VERTEX_NUM];
int D[MAX_VERTEX_NUM];
//Dijkstra算法求从v0到其余顶点v的最短路径P[v]及带权长度D[v]。
//若P[v][w]为1,则w是从v0到v当前求得最短路径上的顶点。
//final[v]为1当且仅当v∈S, 即已经求得从v0到v的最短路径
void ShortestPathDijkstra(MGraph G,char vStart)
{
int v0, v,w,i,j,min;
int final[MAX_VERTEX_NUM];
v0 = LocateVex(G, vStart);
if(v0==-1) return;
for(v=0; v<G.vexnum; ++v)
{
final[v]=0;
D[v]=G.arcs[v0][v];
for(w=0; w<G.vexnum; ++w) P[v][w]=-2; // 设空路径
if(D[v]<INFINITY)
{
P[v][v0]=v;
P[v][v]=-1;
}
}
D[v0]=0;
final[v0]=1; // 初始化,v0顶点属于S集
for(i=1; i<G.vexnum; ++i) // 其余G.vexnum-1个顶点
{
// 开始主循环,每次求得v0到某个v顶点的最短路径,并加v到S集
min=INFINITY; // 当前所知离v0顶点的最近距离
for(w=0; w<G.vexnum; ++w)
if(!final[w]) // w顶点在V-S中
if(D[w]<min)
{
v=w;
min=D[w];
} // w顶点离v0顶点更近
final[v]=1; // 离v0顶点最近的v加入S集
for(w=0; w<G.vexnum; ++w) // 更新当前最短路径及距离
{
if(!final[w]&&min<INFINITY
&&G.arcs[v][w]<INFINITY
&&(min+G.arcs[v][w]<D[w]))
{
// 修改D[w]和P[w],w∈V-S
D[w]=min+G.arcs[v][w];
for(j=0; j<G.vexnum; ++j)
{
if(P[v][j]==-1)
P[w][j]=w;
else
P[w][j]=P[v][j];
}
P[w][w]=-1;
}
}
}
i = LocateVex(G, vEnd);
if(i==-1) return;
v=v0;
while (v!=-1 && P[i][v]!=-2)
{
RQ[g_len++]=v;
v = P[i][v];
}
}
void DrawGraph(MGraph G)
{
char str[32];
int i, j, x0, y0, x, y;
float radius = 30;
SetLineWidth(3);
for(i=0; i<G.vexnum; i++)
{
for(j=0; j<G.vexnum; j++)
{
if(G.arcs[i][j]!=INFINITY)
{
x0 = G.vexs[i].x;
y0 = G.vexs[i].y;
x = G.vexs[j].x;
y = G.vexs[j].y;
SetPenColorHex(0x008800);
DrawArrowLine(x0,y0, x, y, radius, radius);
SetPenColorHex(0x0000FF);
sprintf(str, "%d", G.arcs[i][j]);
DrawText2D(helv18, (x+x0)/2, (y+y0)/2, str);
}
}
}
for(i=0; i<G.vexnum; ++i)
{
x = G.vexs[i].x;
y = G.vexs[i].y;
SetPenColorHex(0xFF6010);
if(i==LocateVex(G, vStart)) SetPenColorHex(0x00CC44);
if(i==LocateVex(G, vEnd)) SetPenColorHex(0x0044CC);
DrawFillCircle(x, y, radius);
SetPenColorHex(0x000000);
DrawCircle(x, y, radius);
str[0] = G.vexs[i].id;
str[1]='\0';
DrawText2D(helv18, x-5, y-5, str);
}
SetLineWidth(1);
}
void DrawShortestPath(MGraph G)
{
int i, j, k, x, y, xNext, yNext;
SetLineWidth(8);
for(k=0; k<g_step; ++k)
{
i = RQ[k];
x = G.vexs[i].x;
y = G.vexs[i].y;
j = RQ[k+1];
xNext = G.vexs[j].x;
yNext = G.vexs[j].y;
SetPenColorHex(0x000000);
DrawLine(x,y, xNext, yNext);
}
SetLineWidth(1);
}
void display(void)
{
DrawShortestPath(G);
DrawGraph(G);
}
void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 27 :
case 'q':
exit(0);
break;
case ' ':
if(g_step<(g_len-1))
g_step++;
else
g_step=0;
break;
case 'i':
break;
default:
break;
}
}
/*G1
6 10
A 343 513 B 551 348 C 303 131 D 138 201 E 551 130 F 136 349
B A 56 B C 17 B E 26 C D 6 C E 52 D F 23 E A 10 F A 130 F B 24 F C 10
*/
/*G2
6
10
A 400 520 B 200 400 C 400 300 D 600 400 E 280 140 F 520 140
A B 6 A C 1 A D 5 B C 5 B E 3 C D 5 C E 6 C F 4 D F 2 E F 6
*/
int main()
{
GetMaze();
vEnd = 65+Row*Col-1;
//CreateGraph(G);
CreatMgraph(&G);
SaveAdjMatrix(G); //输出迷宫得到的邻接矩阵,保存在路径d:/text2中
Show(G);
ShortestPathDijkstra(G,vStart);//// v0为源点
printf("Path matrix:\n");
for(int i=0; i<G.vexnum; ++i)
{
for(int j=0; j<G.vexnum; ++j)
printf("%4d",P[i][j]);
printf("\n");
}
//打印入口到所有顶点的最短距离
printf("The shortest path starting from V%c: \n",vStart);
for(int k=0; k<G.vexnum; ++k)
if(k!=LocateVex(G, vStart))
printf("V%c->V%c: %d\n", vStart, G.vexs[k].id, D[k]);
//只打印入口到出口的最短距离
//printf("V%c->V%c: %d\n", vStart, G.vexs[G.vexnum-1].id, D[G.vexnum-1]);
InitGraphics();
return 0;
}
| [
"taihengw@gmail.com"
] | taihengw@gmail.com |
09c48475153d25da4c5936a1d153e7fbd6be9c0b | be83e928018e705067ae1ad379ed74c52c5c63ba | /string类/string子串.cpp | 3e22fb5e0e5946851b7eb8c584493016e8f42bb8 | [] | no_license | concurs-program/C-plus-material | 461838e43c1357d4321e4f672d39e07ef15da36c | df4984c1a2b1db70ce8dbf4bcdb8fc1a8f4f2209 | refs/heads/main | 2023-06-17T19:10:03.646663 | 2021-07-10T04:36:34 | 2021-07-10T04:36:34 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 732 | cpp | //string子串
//功能描述:
//从字符串中获取想要的子串
//函数原型:
//string substr(int pos = 0 , int n = npos)const;//返回由pos开始的n个字符组成的字符串
//总结:
//灵活地运用求子串功能,可以在实际开发中获取有效的信息
#include<iostream>
using namespace std;
#include<string>
void test01()
{
string str = "abcdef";
string substr = str.substr(1, 3);
cout << "sub str = " << substr << endl;
}
void test02()
{
string email = "Asuna@sina.com";
//从邮件地址中 获取 用户信息
int pos = email.find("@");
string substrName = email.substr(0,pos);
cout << substrName << endl;
}
int main()
{
//test01();
test02();
} | [
"noreply@github.com"
] | noreply@github.com |
17359755203c15e59dc8c4f43cb20ba6bb3968a8 | 469d3bf96df9abdd50a7c2cafbcc312610da16a5 | /C语言/实验/程序/1161.字符串长度(指针).cpp | a56d61621d016411a9dd282c6acc2d0af2acce7f | [] | no_license | myqcxy/Freshman | f104b0158ff2fa1248b6e5cf34cfdd37fce122a7 | c998b2e49a51784e5254afa280c1350497edfc0b | refs/heads/master | 2020-03-16T02:59:29.457006 | 2018-05-07T15:11:27 | 2018-05-07T15:11:27 | 132,477,767 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 268 | cpp | #include<stdio.h>
int main()
{
int len(char *sp);
char a[100];
int i;
for(i=0;a[i-1]!='\n';i++)
{
a[i]=getchar();
}
printf("%d", len(a));
return 0;
}
int len(char *sp)
{
int i=0, d=0;
while(sp[i]!='\n')
{
if(sp[i]!=' ')
d++;
i++;
}
return d;
}
| [
"1123668642@qq.com"
] | 1123668642@qq.com |
03dfde2219605454f06d18ae5160a6e6b166d254 | 6f25c6660e770db7aa6c917834fa87ff3c784af3 | /cocos2d/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h | c049eebd660b721097a88a3ff5694a0571bdb71e | [
"MIT"
] | permissive | lfeng1420/BrickGame | 7c6808f7212211ad7dc12592063e505c95fdfadb | e4961a7454ae1adece6845c64a6ba8ac59856d68 | refs/heads/master | 2020-12-11T08:50:19.812761 | 2019-10-11T15:06:59 | 2019-10-11T15:06:59 | 49,433,572 | 42 | 14 | null | null | null | null | UTF-8 | C++ | false | false | 8,254 | h | /****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCFRAME_H__
#define __CCFRAME_H__
#include "cocos2d.h"
#include "CCTimelineMacro.h"
NS_TIMELINE_BEGIN
class Timeline;
class Frame : public cocos2d::Ref
{
public:
virtual void setFrameIndex(unsigned int frameIndex) { _frameIndex = frameIndex; }
virtual unsigned int getFrameIndex() const { return _frameIndex; }
virtual void setTimeline(Timeline* timeline) { _timeline = timeline; }
virtual Timeline* getTimeline() const { return _timeline; }
virtual void setNode(cocos2d::Node* node) { _node = node; }
virtual cocos2d::Node* getNode() const { return _node; }
virtual void setTween(bool tween) { _tween = tween; }
virtual bool isTween() const { return _tween; }
virtual void onEnter(Frame *nextFrame) = 0;
virtual void apply(float percent) {}
virtual Frame* clone() = 0;
protected:
Frame();
virtual ~Frame();
virtual void emitEvent();
virtual void cloneProperty(Frame* frame);
protected:
unsigned int _frameIndex;
bool _tween;
Timeline* _timeline;
cocos2d::Node* _node;
};
class VisibleFrame : public Frame
{
public:
static VisibleFrame* create();
VisibleFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setVisible(bool visible) { _visible = visible;}
inline bool isVisible() const { return _visible; }
protected:
bool _visible;
};
class TextureFrame : public Frame
{
public:
static TextureFrame* create();
TextureFrame();
virtual void setNode(cocos2d::Node* node);
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setTextureName(std::string textureName) { _textureName = textureName;}
inline std::string getTextureName() const { return _textureName; }
protected:
cocos2d::Sprite* _sprite;
std::string _textureName;
};
class RotationFrame : public Frame
{
public:
static RotationFrame* create();
RotationFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setRotation(float rotation) { _rotation = rotation; }
inline float getRotation() const { return _rotation; }
protected:
float _rotation;
float _betwennRotation;
};
class SkewFrame : public Frame
{
public:
static SkewFrame* create();
SkewFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setSkewX(float skewx) { _skewX = skewx; }
inline float getSkewX() const { return _skewX; }
inline void setSkewY(float skewy) { _skewY = skewy; }
inline float getSkewY() const { return _skewY; }
protected:
float _skewX;
float _skewY;
float _betweenSkewX;
float _betweenSkewY;
};
class RotationSkewFrame : public SkewFrame
{
public:
static RotationSkewFrame* create();
RotationSkewFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
};
class PositionFrame : public Frame
{
public:
static PositionFrame* create();
PositionFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setPosition(const cocos2d::Point& position) { _position = position; }
inline cocos2d::Point getPosition() const { return _position; }
inline void setX(float x) { _position.x = x; }
inline void setY(float y) { _position.y = y; }
inline float getX() const { return _position.x; }
inline float getY() const { return _position.y; }
protected:
cocos2d::Point _position;
float _betweenX;
float _betweenY;
};
class ScaleFrame : public Frame
{
public:
static ScaleFrame* create();
ScaleFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setScale(float scale) { _scaleX = scale; _scaleY = scale; }
inline void setScaleX(float scaleX) { _scaleX = scaleX; }
inline float getScaleX() const { return _scaleX; }
inline void setScaleY(float scaleY) { _scaleY = scaleY;}
inline float getScaleY() const { return _scaleY; }
protected:
float _scaleX;
float _scaleY;
float _betweenScaleX;
float _betweenScaleY;
};
class AnchorPointFrame : public Frame
{
public:
static AnchorPointFrame* create();
AnchorPointFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setAnchorPoint(const cocos2d::Point& point) { _anchorPoint = point; }
inline cocos2d::Point getAnchorPoint() const { return _anchorPoint; }
protected:
cocos2d::Point _anchorPoint;
};
enum InnerActionType
{
LoopAction,
NoLoopAction,
SingleFrame
};
class InnerActionFrame : public Frame
{
public:
static InnerActionFrame* create();
InnerActionFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setInnerActionType(InnerActionType type) { _innerActionType = type; }
inline InnerActionType getInnerActionType() const { return _innerActionType; }
inline void setStartFrameIndex(int frameIndex) { _startFrameIndex = frameIndex; }
inline int getStartFrameIndex() const { return _startFrameIndex; }
protected:
InnerActionType _innerActionType;
int _startFrameIndex;
};
class ColorFrame : public Frame
{
public:
static ColorFrame* create();
ColorFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
inline GLubyte getAlpha() const { return _alpha; }
inline void setColor(const cocos2d::Color3B& color) { _color = color; }
inline cocos2d::Color3B getColor() const { return _color; }
protected:
GLubyte _alpha;
cocos2d::Color3B _color;
int _betweenAlpha;
int _betweenRed;
int _betweenGreen;
int _betweenBlue;
};
class EventFrame : public Frame
{
public:
static EventFrame* create();
EventFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setEvent(std::string event) { _event = event;}
inline std::string getEvent() const { return _event; }
protected:
std::string _event;
};
class ZOrderFrame : public Frame
{
public:
static ZOrderFrame* create();
ZOrderFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setZOrder(int zorder) { _zorder = zorder;}
inline int getZOrder() const { return _zorder; }
protected:
int _zorder;
};
NS_TIMELINE_END
#endif /*__CCFRAME_H__*/
| [
"lfeng1420@hotmail.com"
] | lfeng1420@hotmail.com |
e890ece4121e8d44baaa9b3144dffd3352349a82 | 2ba9766e217d52050c6886b90f376d99fb9f720a | /lib/Script.cpp | 118f12a908a753ea05278d8f5917f68a83896c77 | [] | no_license | agkn/HydroLib2 | 58df941a88f7a5cd18bdb885f294b3d7737e7eda | 12744190c67f0c573cc661ca2cab7c51db16d136 | refs/heads/master | 2020-05-17T14:04:13.797295 | 2019-05-18T22:45:42 | 2019-05-18T22:45:42 | 183,754,397 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,788 | cpp | //
// Created by Andrey on 17.04.2019.
//
#include "Script.h"
#include "Operation.h"
Script::Script(Context &mContext) : mContext(mContext) {}
bool Script::execute() {
mOpQueue.reset();
while(mOpQueue.prepareStatement()) {
mStack.clear();
while(mOpQueue.inStatement()) {
auto op = mOpQueue.pop<op_id_t>();
op_func_t func = OPS2[op];
op_result_t res = func(mContext, mOpQueue, mStack);
if (Operation::RESULT_SKIP == res) {
mOpQueue.skip();
}
}
}
return false;
}
void Script::addSetInt(var_id_t aVarRef) {
mOpQueue.add(Operation::OP_SetInt);
mOpQueue.add(aVarRef);
}
void Script::addGetInt(var_id_t aVarRef) {
mOpQueue.add(Operation::OP_GetInt);
mOpQueue.add(aVarRef);
}
void Script::addIfEvent(event_id_t aEventId) {
mOpQueue.add(Operation::OP_IfEvent);
mOpQueue.add(aEventId);
}
Script &Script::addOperation(op_id_t aOpId) {
mOpQueue.add(aOpId);
return *this;
}
Script &Script::endStatement() {
mOpQueue.end();
return *this;
}
Script &Script::addInt(int aData) {
mOpQueue.add(Operation::OP_ArgInt);
mOpQueue.add(aData);
return *this;
}
Script &Script::addUint8(uint8_t aData) {
// uint8 and int8 has the same size;
mOpQueue.add(Operation::OP_ArgInt8);
mOpQueue.add(aData);
return *this;
}
Script & Script::addEvent(event_id_t aEventId) {
mOpQueue.add(Operation::OP_ArgInt8);
mOpQueue.add(aEventId);
return *this;
}
Script & Script::addVarId(uint8_t aVarId) {
mOpQueue.add(Operation::OP_ArgInt8);
mOpQueue.add(aVarId);
return *this;
}
Script Script::addSetObj(var_id_t aVarRef) {
return *this;
}
Script Script::addGetObj(var_id_t aVarRef) {
return *this;
}
| [
"nsgithub@agk.nnov.ru"
] | nsgithub@agk.nnov.ru |
08854aea06133629b47af907e92007c60e4b94ee | c609db73f771d2eebaa8342e7521cac21941e01f | /LBFGSB.cpp | bbab08b8efb640b9a67e09a6bbbcb1b7a6a2e077 | [
"Apache-2.0"
] | permissive | CJZheng91/L-BFGS-B | c6da57cece09c5fe0d4c2bd4b42a5c98018e12d2 | 570aae5eede74199449044e62917f5035c4390d6 | refs/heads/master | 2020-03-09T07:58:14.191483 | 2018-04-08T20:09:00 | 2018-04-08T20:09:00 | 128,677,726 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,598 | cpp | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <Eigen/Dense>
#include <iomanip>
#include <cmath>
#include <math.h>
#include <float.h>
#include <algorithm>
#include "ANN.cpp"
using namespace Eigen;
MatrixXd getTril(MatrixXd& mat) {
MatrixXd tril = mat.triangularView<Lower>();
for (int i = 0; i < tril.rows(); i++)
tril(i,i) = 0;
return tril;
}
void appendVec2Mat(MatrixXd& mat, VectorXd vec) {
mat.conservativeResize(mat.rows(), mat.cols()+1);
mat.col(mat.cols()-1) = vec;
}
VectorXd StdVec2Eigen(std::vector <double> vec){
VectorXd outvec(vec.size());
for(int i=0;i<vec.size();i++)
outvec(i)=vec[i];
return outvec;
}
std::vector <double> EigenVec2Std(VectorXd vec){
std::vector <double> outvec(vec.rows(),0.0);
for(int i=0;i<vec.rows();i++)
outvec[i]=vec(i);
return outvec;
}
class ObjFunc{
public:
void init(ANN& input) {
nnet = input;
target = VectorXd::Constant(20,0);
}
void setTarget(VectorXd input) {
for (int i = 0; i < 10; i++) {
target(2*i) = input(i);
target(2*i + 1) = input(i);
}
}
// VectorXd evalANN(VectorXd input){
// std::vector<double> temperature = nnet.ComputeANN(EigenVec2Std(input));
// VectorXd output(10);
// for(int i=0;i<10;i++){
// output(i)= 0.5*(0.15*temperature[3*i] +
// 0.85*temperature[3*i+1] +
// 0.85*temperature[3*i+2] +
// 0.15*temperature[3*i+3]);
// }
// return output;
// }
VectorXd evalANN(VectorXd input){
std::vector<double> temperature = nnet.ComputeANN(EigenVec2Std(input));
VectorXd output(20);
for(int i=0;i<10;i++){
output(2 * i) = (temperature[3*i] + temperature[3*i + 1]) * 0.015 / 2 +
(1.5 * temperature[3*i + 1] + 0.5 * temperature[3*i + 2]) * 0.035 / 2;
output(2 * i) /= 0.05;
output(2 * i + 1) = (temperature[3*i + 2] + temperature[3*i + 3]) * 0.015 / 2 +
(0.5 * temperature[3*i + 1] + 1.5 * temperature[3*i + 2]) * 0.035 / 2;
output(2*i + 1) /= 0.05;
}
return output;
}
void eval(double& f, VectorXd& g, VectorXd input){
VectorXd output = evalANN(input);
// std::cout << output << std::endl;
int n = input.rows();
f = (output - target).dot(output - target);
VectorXd gradient = VectorXd::Constant(n,0.0);
double delta = 0.01;
// std::cout << "BP\n";
for (int i = 0; i < n; i++) {
VectorXd d_input = VectorXd::Constant(n,0.0);
d_input(i) = delta;
VectorXd temp_output1 = evalANN(input + d_input);
VectorXd temp_output2 = evalANN(input - d_input);
gradient(i) = (temp_output1 - target).dot(temp_output1 - target) -
(temp_output2 - target).dot(temp_output2 - target);
gradient(i) /= 2*delta;
}
g = gradient;
}
private:
ANN nnet;
VectorXd target;
};
void quickSort(std::vector<double>& arr, std::vector<int>& indices, int left, int right) {
int i = left, j = right;
double pivot = arr[(left + right) / 2];
/*partition*/
while (i <= j) {
while (arr[i] < pivot)
i++;
while (arr[j] > pivot)
j--;
if (i <= j) {
double tmp_v = arr[i];
int tmp_i = indices[i];
arr[i] = arr[j];
indices[i] = indices[j];
arr[j] = tmp_v;
indices[j] = tmp_i;
i++;
j--;
}
}
/*recursion*/
if (left < j)
quickSort(arr, indices, left, j);
if (i < right)
quickSort(arr, indices, i, right);
}
struct LBFGSBParam{
int m;
int max_iters;
double tol;
bool display;
bool xhistory;
};
struct BPOutput{
VectorXd t;
VectorXd d;
std::vector<int> F;
};
struct CauchyOutput{
VectorXd xc;
VectorXd c;
};
struct SubspaceMinOutput{
VectorXd xbar;
bool line_search_flag;
};
struct LBFGSB_Output {
VectorXd x;
double obj;
};
class LBFGSB{
public:
LBFGSBParam param;
LBFGSB_Output solve(ObjFunc& obj, VectorXd x0, VectorXd l, VectorXd u, LBFGSBParam params);
private:
double f;
VectorXd g;
double getOptimality(VectorXd x, VectorXd g, VectorXd l, VectorXd u);
BPOutput getBreakpoints(VectorXd x, VectorXd g, VectorXd l, VectorXd u);
CauchyOutput getCauchyPoint(VectorXd x, VectorXd g, VectorXd l, VectorXd u,
double theta, MatrixXd W, MatrixXd M);
double findAlpha(VectorXd l, VectorXd u, VectorXd xc, VectorXd du,
std::vector<int> free_vars_idx);
SubspaceMinOutput subspaceMin(VectorXd x, VectorXd g, VectorXd l, VectorXd u,
VectorXd xc, VectorXd c, double theta, MatrixXd W, MatrixXd M);
double strongWolfe(ObjFunc& obj, VectorXd x0, double f0, VectorXd g0, VectorXd p);
double alphaZoom(ObjFunc& obj, VectorXd x0, double f0, VectorXd g0, VectorXd p,
double alpha_lo, double alpha_hi);
};
double LBFGSB::getOptimality(VectorXd x, VectorXd g, VectorXd l, VectorXd u){
VectorXd projected_g = x - g;
for(int i = 0; i < x.rows(); i++) {
if (projected_g(i) < l(i))
projected_g(i) = l(i);
else if (projected_g(i) > u(i))
projected_g(i) = u(i);
}
projected_g = projected_g - x;
return projected_g.cwiseAbs().maxCoeff();
}
BPOutput LBFGSB::getBreakpoints(VectorXd x, VectorXd g, VectorXd l, VectorXd u){
int nn = x.rows();
VectorXd t = VectorXd::Constant(nn,0.0);
VectorXd d = -g;
for (int i = 0; i < nn; i++) {
if (g(i) < 0)
t(i) = (x(i) - u(i)) / g(i);
else if (g(i) > 0)
t(i) = (x(i) - l(i)) / g(i);
else
t(i) = DBL_MAX;
if (t(i) < DBL_EPSILON)
d(i) = 0.0;
}
// Sort elements of t and store indices in F
std::vector<int> Fvec(nn, 0);
std::vector<double> tvec(nn,0.0);
for (int i = 0; i < nn; i++){
tvec[i] = t(i);
Fvec[i] = i;
// std::cout << tvec[i] << " " << Fvec[i] <<std::endl;
}
//std::cout<<nn<<std::endl;
// std::cout<<"BP_quicksort\n";
quickSort(tvec, Fvec, 0, nn-1);
// std::cout<<"BP_after_quicksort\n";
BPOutput bpout;
bpout.t = t;
bpout.d = d;
bpout.F = Fvec;
return bpout;
}
CauchyOutput LBFGSB::getCauchyPoint(VectorXd x, VectorXd g, VectorXd l, VectorXd u,
double theta, MatrixXd W, MatrixXd M){
//std::cout << "BP0" << std::endl;
BPOutput bpout = getBreakpoints(x, g, l, u);
// std::cout << "t = " << std::endl << bpout.t << std::endl;
// std::cout << "d = " << std::endl << bpout.d << std::endl;
// std::cout << "F = " << std::endl;
// for (int i = 0; i < bpout.F.size(); i++) {
// std::cout << bpout.F[i] << std::endl;
// }
VectorXd xc = x;
//std::cout << "BP01" << std::endl;
VectorXd p = W.transpose() * bpout.d;
VectorXd c = VectorXd::Constant(W.cols(), 0.0);
double fp = - bpout.d.transpose() * bpout.d;
double fpp = -theta * fp - p.dot(M * p);
double fpp0 = -theta * fp;
double dt_min = -fp / fpp;
double t_old = 0;
int i;
//std::cout << "BP1" << std::endl;
for (int j = 0; j < x.rows(); j++) {
i = j;
if (bpout.F[i] > 0)
break;
}
int b = bpout.F[i];
double t = bpout.t(b);
double dt = t - t_old;
//std::cout << "BP2" << std::endl;
while ( (dt_min > dt) && (i < x.rows()) ) {
if (bpout.d(b) > 0)
xc(b) = u(b);
else if (bpout.d(b) < 0)
xc(b) = l(b);
//std::cout << "BP3" << std::endl;
double zb = xc(b) - x(b);
c = c + dt * p;
double gb = g(b);
VectorXd wbt = W.row(b);
fp += dt * fpp + gb * gb + theta * gb * zb - gb * wbt.dot(M * c);
fpp -= theta * gb * gb - 2.0 * gb * wbt.dot(M * p) - gb * gb * wbt.dot(M * wbt);
fpp = std::max(DBL_EPSILON * fpp0, fpp);
p += gb * wbt;
bpout.d(b) = 0.0;
dt_min = -fp / fpp;
t_old = t;
i++;
if (i < x.rows()){
b = bpout.F[i];
t = bpout.t(b);
dt = t - t_old;
}
}
// Perform final updates
dt_min = std::max(dt_min, 0.0);
t_old = t_old + dt_min;
for (int j = 0; j < xc.rows(); j++) {
int idx = bpout.F[j];
xc(idx) += t_old * bpout.d(idx);
}
c += dt_min * p;
CauchyOutput cpout;
cpout.c = c;
cpout.xc = xc;
return cpout;
}
double LBFGSB::findAlpha(VectorXd l, VectorXd u, VectorXd xc, VectorXd du,
std::vector<int> free_vars_idx) {
// INPUTS:
// l: [n,1] lower bound constraint vector.
// u: [n,1] upper bound constraint vector.
// xc: [n,1] generalized Cauchy point.
// du: [num_free_vars,1] solution of unconstrained minimization.
// OUTPUTS:
// alpha_star: positive scaling parameter.
double alpha_star = 1;
int n = free_vars_idx.size();
for (int i = 0; i < n; i++) {
int idx = free_vars_idx[i];
if (du(i) > 0)
alpha_star = std::min(alpha_star, (u(idx) - xc(idx)) / du(i));
else
alpha_star = std::min(alpha_star, (l(idx) - xc(idx)) / du(i));
}
return alpha_star;
}
SubspaceMinOutput LBFGSB::subspaceMin(VectorXd x, VectorXd g, VectorXd l, VectorXd u,
VectorXd xc, VectorXd c, double theta, MatrixXd W, MatrixXd M){
SubspaceMinOutput subminout;
subminout.line_search_flag = true;
int n = x.rows();
std::vector<int> free_vars_idx;
std::vector<VectorXd> Z;
for (int i = 0; i < xc.rows(); i++) {
if ((xc(i) != u(i)) && (xc(i) != l(i))) {
free_vars_idx.push_back(i);
VectorXd unit = VectorXd::Constant(n,0);
unit(i) = 1;
Z.push_back(unit);
}
}
int num_free_vars = free_vars_idx.size();
if (num_free_vars == 0) {
subminout.xbar = xc;
subminout.line_search_flag = false;
return subminout;
}
MatrixXd ZZ = MatrixXd::Zero(n, num_free_vars);
for (int i = 0; i < num_free_vars; i++)
ZZ.col(i) = Z[i];
// compute the reduced gradient of mk restricted to free variables
MatrixXd WTZ = W.transpose() * ZZ;
VectorXd rr = g + theta * (xc - x) - W*M*c;
VectorXd r = VectorXd::Constant(num_free_vars, 0.0);
for (int i = 0; i < num_free_vars; i++)
r(i) = rr(free_vars_idx[i]);
// form intermediate variables
double invtheata = 1.0 / theta;
VectorXd v = M * WTZ * r;
MatrixXd N = invtheata * WTZ * WTZ.transpose();
int N_size = N.rows();
N = MatrixXd::Identity(N_size, N_size) - M * N;
v = N.inverse() * v;
VectorXd du = -invtheata * r - invtheata * invtheata * WTZ.transpose()*v;
// find alpha star
double alpha_star = findAlpha(l, u, xc, du, free_vars_idx);
VectorXd d_star = alpha_star * du;
subminout.xbar = xc;
for (int i = 0; i < num_free_vars; i++) {
int idx = free_vars_idx[i];
subminout.xbar(idx) += d_star(i);
}
return subminout;
}
double LBFGSB::strongWolfe(ObjFunc& obj, VectorXd x0, double f0, VectorXd g0, VectorXd p){
double alpha; // return value;
double c1 = 1e-4;
double c2 = 0.9;
double alpha_max = 2.5;
double alpha_im1 = 0;
double alpha_i = 1;
double f_im1 = f0;
double dphi0 = g0.dot(p);
int i = 0;
int max_iters = 20;
VectorXd x;
double f_i;
VectorXd g_i;
// search for alpha that satisfies strong Wolfe conditions
while (true) {
x = x0 + alpha_i * p;
obj.eval(f_i, g_i, x);
if ((f_i > f0 + c1 * dphi0) || ( (i > 1) && (f_i >= f_im1) )) {
alpha = alphaZoom(obj, x0, f0, g0, p, alpha_im1, alpha_i);
break;
}
double dphi = g_i.dot(p);
if (fabs(dphi) <= -c2 * dphi0) {
alpha = alpha_i;
break;
}
if (dphi >= 0) {
alpha = alphaZoom(obj, x0, f0, g0, p, alpha_i, alpha_im1);
break;
}
// update
alpha_im1 = alpha_i;
f_im1 = f_i;
alpha_i += 0.8 * (alpha_max - alpha_i);
if (i > max_iters) {
alpha = alpha_i;
break;
}
i++;
}
return alpha;
}
double LBFGSB::alphaZoom(ObjFunc& obj, VectorXd x0, double f0, VectorXd g0, VectorXd p,
double alpha_lo, double alpha_hi) {
double alpha; // return value
double c1 = 1e-4;
double c2 = 0.9;
int i = 0;
int max_iters = 20;
double dphi0 = g0.dot(p);
double alpha_i;
VectorXd x;
double f_i;
VectorXd g_i;
while (true) {
alpha_i = 0.5 * (alpha_lo + alpha_hi);
alpha = alpha_i;
x = x0 + alpha_lo * p;
obj.eval(f_i, g_i, x);
VectorXd x_lo = x0 + alpha_lo * p;
double f_lo;
VectorXd dummy_g;
obj.eval(f_lo, dummy_g, x_lo);
if ( (f_i > f0 + c1 * alpha_i * dphi0) || (f_i >= f_lo) )
alpha_hi = alpha_i;
else {
double dphi = g_i.dot(p);
if (fabs(dphi) <= -c2 * dphi0) {
alpha = alpha_i;
break;
}
if (dphi * (alpha_hi - alpha_lo) >= 0) {
alpha_hi = alpha_lo;
}
alpha_lo = alpha_i;
}
i++;
if (i > max_iters) {
alpha = alpha_i;
break;
}
}
return alpha;
}
LBFGSB_Output LBFGSB::solve(ObjFunc& obj, VectorXd x0, VectorXd l,
VectorXd u, LBFGSBParam params) {
int rank=0;
rank=MPI::COMM_WORLD.Get_rank();
int n = x0.rows();
MatrixXd Y(n,0);
MatrixXd S(n,0);
MatrixXd W = MatrixXd::Zero(n,1);
MatrixXd M = MatrixXd::Zero(1,1);
double theta = 1;
// initialize obj vars
VectorXd x = x0;
double f;
VectorXd g;
obj.eval(f, g, x);
int k = 0;
double opt;
if (params.display && rank == 0) {
std::cout << "iter\t\tf(x)\t\toptimality\n";
std::cout << "-------------------------------------\n";
opt = getOptimality(x, g, l, u);
std::cout << k << "\t\t" << f << "\t\t" << opt << "\t\t" << std::endl;
}
MatrixXd xhist(n,0);
//std::cout << "BP0" << std::endl;
if (params.xhistory) {
appendVec2Mat(xhist, x0);
}
VectorXd x_old;
VectorXd g_old;
VectorXd y;
VectorXd s;
while ((getOptimality(x, g, l, u) > params.tol) && (k < params.max_iters) ) {
x_old = x;
g_old = g;
//std::cout << "BP01" << std::endl;
CauchyOutput cpout = getCauchyPoint(x, g, l, u, theta, W, M);
VectorXd xc = cpout.xc;
VectorXd c = cpout.c;
// std::cout << "xc = " << std::endl;
// std::cout << xc << std::endl;
// std::cout << "c = " << std::endl;
// std::cout << c << std::endl;
// std::cout << "BP1" << std::endl;
SubspaceMinOutput subminout = subspaceMin(x, g, l, u, xc, c, theta, W, M);
//std::cout << "BP2" << std::endl;
VectorXd xbar = subminout.xbar;
bool line_search_flag = subminout.line_search_flag;
double alpha = 1.0;
if (line_search_flag) {
alpha = strongWolfe(obj, x, f, g, xbar - x);
}
x += alpha * (xbar - x);
//std::cout << "BP3" << std::endl;
// update LBFGS data structures
obj.eval(f, g, x);
y = g - g_old;
s = x - x_old;
double curv = fabs(s.dot(y));
if (curv < DBL_EPSILON) {
if (params.display && rank == 0) {
std::cout << (" warning: negative curvature detected\n");
std::cout << (" skipping L-BFGS update\n");
}
k++;
continue;
}
if (Y.cols() < params.m) {
appendVec2Mat(Y, y);
appendVec2Mat(S, s);
} else {
Y.block(0, 0, n, params.m - 1) = Y.block(0, 1, n, params.m - 1);
S.block(0, 0, n, params.m - 1) = S.block(0, 1, n, params.m - 1);
Y.col(params.m - 1) = y;
S.col(params.m - 1) = s;
}
//std::cout << "BP4" << std::endl;
theta = y.dot(y) / y.dot(s);
//std::cout << "BP401" << std::endl;
MatrixXd temp = Y;
//std::cout << "BP402" << std::endl;
temp.conservativeResize(temp.rows(), temp.cols()+S.cols());
temp.block(0, Y.cols(), S.rows(), S.cols()) = theta * S;
//std::cout << "BP403" << std::endl;
W = temp;
//std::cout << W << std::endl;
//std::cout << "BP41" << std::endl;
MatrixXd A = S.transpose() * Y;
MatrixXd L = getTril(A);
MatrixXd D = -1 * A.diagonal().asDiagonal();
int D_size = D.rows();
int L_size = L.rows();
//std::cout << "BP42" << std::endl;
MatrixXd MM(D_size + L_size, D_size + L_size);
MM.block(0, 0, D_size, D_size) = D;
MM.block(0, D_size, D_size, L_size) = L.transpose();
MM.block(D_size, 0, L_size, D_size) = L;
MM.block(D_size, D_size, L_size, L_size) = theta * S.transpose() * S;
//std::cout << "BP43" << std::endl;
M = MM.inverse();
//std::cout << "BP5" << std::endl;
// update the iteration
k++;
if (params.xhistory) {
appendVec2Mat(xhist, x);
}
if (params.display && rank == 0) {
opt = getOptimality(x, g, l, u);
std::cout << k << "\t\t" << f << "\t\t" << opt << "\t\t" << std::endl;
}
}
if (k == params.max_iters && params.display && rank == 0) {
std::cout << " warning: maximum number of iterations reached\n";
}
if (getOptimality(x,g,l,u) < params.tol && params.display && rank == 0) {
std::cout << " stopping because convergence tolerance met!\n";
}
LBFGSB_Output out;
out.x = x;
out.obj = f;
return out;
}
//705.023 701.723 697.852 691.804 692.91 667.241 667.139 672.044 674.512 680.647
// int main(int argc, char** argv){
// VectorXd x(10);
// x = VectorXd::Constant(10,150);
// VectorXd l = VectorXd::Constant(10,0.0);
// VectorXd u = VectorXd::Constant(10,420.0);
// LBFGSBParam params;
// params.m = 10;
// params.tol = 1e-2;
// params.max_iters = 50;
// params.display = true;
// params.xhistory = false;
// ObjFunc obj;
// obj.init();
// VectorXd base = VectorXd::Constant(10,673);
// VectorXd increment(10);
// increment << 40, 40, 40, 40, 40, 20, 20, 20, 20, 20;
// obj.setTarget(base + increment);
// // obj.target << 50, 30, 60, 50, 60, 70, 1, 90, 50, 50;
// LBFGSB opt;
// std::cout << "starting to solve\n";
// x = opt.solve(obj, x, l, u, params);
// std::cout << x.transpose() << std::endl;
// VectorXd output = obj.evalANN(x);
// std::cout << (output - base).transpose() << std::endl;
// // LBFGSB optimizer;
// // // double opt = optimizer.getOptimality(x,g,l,u);
// // // BPOutput bpout = optimizer.getBreakpoints(x,g,l,u);
// // // std::cout<<bpout.t.transpose()<<std::endl;
// // // std::cout<<bpout.d.transpose()<<std::endl;
// // // for (int i = 0; i < bpout.F.size(); i++)
// // // std::cout<<bpout.F[i]<<" ";
// // // std::cout<<std::endl;
// // MatrixXd W = MatrixXd::Random(10,20);
// // MatrixXd M = MatrixXd::Identity(20,20);
// // VectorXd row = M.row(10);
// // std::cout<<row<<std::endl;
// // CauchyOutput cpout = optimizer.getCauchyPoint(x,g,l,u, 0.1, W, M);
// // std::cout<<cpout.xc.transpose()<<std::endl;
// // std::cout<<cpout.c.transpose()<<std::endl;
// // using namespace std;
// // MatrixXd mat(2,0);
// // VectorXd vec(2);
// // vec << 1, 1;
// // cout << mat.rows() << " " << mat.cols() << endl;
// // mat.conservativeResize(mat.rows(), mat.cols()+1);
// // mat.col(mat.cols()-1) = vec;
// // cout << mat << endl;
// return 0;
// } | [
"noreply@github.com"
] | noreply@github.com |
6284605a9444c1b224f10f69934e10d957ef10e6 | a6d17a948329dae44d5041d57d7220f9c8a4a2f5 | /src/qt/bitcoin.cpp | b32cc2bb884a8492a8735f044c148b263b181b96 | [
"MIT"
] | permissive | azadbharti32/azadcoin | cc5dae233f12c6d7130b7c101210f6252d6c15e7 | 4f83f8c4d5573c4099b4c03771964f2afafde605 | refs/heads/master | 2020-03-12T22:06:03.477123 | 2018-04-24T11:15:42 | 2018-04-24T11:15:42 | 130,840,848 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,782 | cpp | // Copyright (c) 2011-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <QApplication>
#include "bitcoingui.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "optionsmodel.h"
#include "guiutil.h"
#include "guiconstants.h"
#include "init.h"
#include "util.h"
#include "ui_interface.h"
#include "paymentserver.h"
#include "splashscreen.h"
#include <QMessageBox>
#if QT_VERSION < 0x050000
#include <QTextCodec>
#endif
#include <QLocale>
#include <QTimer>
#include <QTranslator>
#include <QLibraryInfo>
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
#endif
#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
// Declare meta types used for QMetaObject::invokeMethod
Q_DECLARE_METATYPE(bool*)
// Need a global reference for the notifications to find the GUI
static BitcoinGUI *guiref;
static SplashScreen *splashref;
static bool ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
{
// Message from network thread
if(guiref)
{
bool modal = (style & CClientUIInterface::MODAL);
bool ret = false;
// In case of modal message, use blocking connection to wait for user to click a button
QMetaObject::invokeMethod(guiref, "message",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(unsigned int, style),
Q_ARG(bool*, &ret));
return ret;
}
else
{
printf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
return false;
}
}
static bool ThreadSafeAskFee(int64 nFeeRequired)
{
if(!guiref)
return false;
if(nFeeRequired < CTransaction::nMinTxFee || 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 InitMessage(const std::string &message)
{
if(splashref)
{
splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(55,55,55));
qApp->processEvents();
}
printf("init message: %s\n", message.c_str());
}
/*
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. Azadcoin 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[])
{
// Command-line options take precedence:
ParseParameters(argc, argv);
#if QT_VERSION < 0x050000
// Internal string conversion is all UTF-8
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
#endif
Q_INIT_RESOURCE(bitcoin);
QApplication app(argc, argv);
// Register meta types used for QMetaObject::invokeMethod
qRegisterMetaType< bool* >();
// Do this early as we don't want to bother initializing if we are just calling IPC
// ... but do it after creating app, so QCoreApplication::arguments is initialized:
if (PaymentServer::ipcSendCommandLine())
exit(0);
PaymentServer* paymentServer = new PaymentServer(&app);
// Install global event filter that makes sure that long tooltips can be word-wrapped
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
// ... 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, "Azadcoin",
QString("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
return 1;
}
ReadConfigFile(mapArgs, mapMultiArgs);
// Application identification (must be set before OptionsModel is initialized,
// as it is used to locate QSettings)
QApplication::setOrganizationName("Azadcoin");
QApplication::setOrganizationDomain("azadcoin.org");
if(GetBoolArg("-testnet")) // Separate UI settings for testnet
QApplication::setApplicationName("Azadcoin-Qt-testnet");
else
QApplication::setApplicationName("Azadcoin-Qt");
// ... then GUI settings:
OptionsModel optionsModel;
// 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('_'));
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
// 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);
// Subscribe to global signals from core
uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox);
uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee);
uiInterface.InitMessage.connect(InitMessage);
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;
}
#ifdef Q_OS_MAC
// on mac, also change the icon now because it would look strange to have a testnet splash (green) and a std app icon (orange)
if(GetBoolArg("-testnet")) {
MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
}
#endif
SplashScreen splash(QPixmap(), 0);
if (GetBoolArg("-splash", true) && !GetBoolArg("-min"))
{
splash.show();
splash.setAutoFillBackground(true);
splashref = &splash;
}
app.processEvents();
app.setQuitOnLastWindowClosed(false);
try
{
#ifndef Q_OS_MAC
// Regenerate startup link, to fix links to old versions
// OSX: makes no sense on mac and might also scan/mount external (and sleeping) volumes (can take up some secs)
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(true);
#endif
boost::thread_group threadGroup;
BitcoinGUI window;
guiref = &window;
QTimer* pollShutdownTimer = new QTimer(guiref);
QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown()));
pollShutdownTimer->start(200);
if(AppInit2(threadGroup))
{
{
// 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 = 0;
if(pwalletMain)
walletModel = new WalletModel(pwalletMain, &optionsModel);
window.setClientModel(&clientModel);
if(walletModel)
{
window.addWallet("~Default", walletModel);
window.setCurrentWallet("~Default");
}
// If -min option passed, start window minimized.
if(GetBoolArg("-min"))
{
window.showMinimized();
}
else
{
window.show();
}
// Now that initialization/startup is done, process any command-line
// bitcoin: URIs
QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString)));
QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
app.exec();
window.hide();
window.setClientModel(0);
window.removeAllWallets();
guiref = 0;
delete walletModel;
}
// Shutdown the core and its threads, but don't exit Bitcoin-Qt here
threadGroup.interrupt_all();
threadGroup.join_all();
Shutdown();
}
else
{
threadGroup.interrupt_all();
threadGroup.join_all();
Shutdown();
return 1;
}
} catch (std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(NULL);
}
return 0;
}
#endif // BITCOIN_QT_TEST
| [
"azadbharti32@gmail.com"
] | azadbharti32@gmail.com |
8d981436aff02b65b29ccef4d5f8c23afdccd956 | 74c3b02b5baed311cc5cb8cbe59edcb140885b06 | /2.DataStructure/8.Graph/1.DFS/findTheMotherVertex.cpp | 33db4289035466ee9b2f13827c83a939ced4d86d | [] | no_license | paresh113/CodeIsLifeOrLifeIsCode | 4810c8ba953d1c763a8240693e182b6e5155d641 | 0f2bfb43f7393b812b147370c0b83aa70533f418 | refs/heads/master | 2023-01-20T14:36:19.745624 | 2020-11-30T14:05:07 | 2020-11-30T14:05:07 | 314,968,660 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 524 | cpp |
#include<bits/stdc++.h>
using namespace std;
int vis[100];
vector < int > v[100];
/// my approach (I don't know it is right or wrong )
int main() {
int n,e; cin >> n >> e;
memset(vis, 0 , sizeof(vis));
for(int i =0; i < e; i++){
int x,y; cin >> x >> y;
v[x].push_back(y);
vis[y] = 1;
}
for(int i = 0; i < n; i++){
if(vis[i] == 0){
cout << "Mother vertex = "<<i << endl;
break;
}
}
}
/*
n e
7 8
0 1
0 2
1 3
4 1
6 4
5 6
5 2
6 0
*/
| [
"31143249+paresh113@users.noreply.github.com"
] | 31143249+paresh113@users.noreply.github.com |
a2dd443639d6356a25e33ea04f7b3d05ea3d9f88 | b4e078e6689b51f16ccc3acbdbecc24f9f97453f | /MEKD/src/MEKD.cpp | 9a66c98185de15467a622688689f8ebaafeb86cc | [] | no_license | clemencia/HiggsAnalysis-ZZMatrixElement | 1d54a75f7fcd8b13e974f3cf9efc9e7650d8d789 | 0d57a9f2579aa42f7b38c666347b6be7263b86d0 | refs/heads/master | 2020-12-25T17:03:53.782312 | 2015-01-19T19:55:22 | 2015-01-19T19:55:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 39,341 | cpp | /*************************************************************************
* Authors: MEKD fans
* More info: http://mekd.ihepa.ufl.edu
* Contact: mekd@phys.ufl.edu
*************************************************************************/
#ifndef MEKD_MEKD_cpp
#define MEKD_MEKD_cpp
/// MEKD header
#include "../interface/MEKD.h"
using namespace std;
//////////////////////////////////////////////////////////////////////////
/// MEKD class member implementation
///
/// Provides necessary interface to the MadGraph-based ME calculator
/// and computes MEs and KDs for the process specified by the user.
///
//////////////////////////////////////////////////////////////////////////
///------------------------------------------------------------------------
/// MEKD::MEKD - a default constructor
///------------------------------------------------------------------------
MEKD::MEKD(double collisionEnergy, string PDFName)
{
m_collisionEnergy = collisionEnergy;
m_PDFName = PDFName;
MEKD_MG_Calc.Sqrt_s = m_collisionEnergy*1000; // translate TeV to GeV
m_Mixing_Coefficients_Spin0 = MEKD_MG_Calc.Mixing_Coefficients_Spin0;
m_Mixing_Coefficients_Spin1 = MEKD_MG_Calc.Mixing_Coefficients_Spin1;
m_Mixing_Coefficients_Spin2 = MEKD_MG_Calc.Mixing_Coefficients_Spin2;
ME_ZZ = 0;
ME_Spin0PSMH = 0;
ME_Spin0Ph = 0;
ME_Spin0M = 0;
ME_Spin1P = 0;
ME_Spin1M = 0;
ME_ggSpin2Pm = 0;
ME_qqSpin2Pm = 0;
four_particle_IDs_i.resize( 4, 0 );
four_particle_Ps_i.resize( 4, NULL );
}
///------------------------------------------------------------------------
/// MEKD::processParameters - sanity check for internal parameters
///------------------------------------------------------------------------
/// Might be merged to the constructor if these flags are not used as is(was)
///------------------------------------------------------------------------
int MEKD::processParameters()
{
/// Check if the PDF name is supported and set PDF flag
if (m_PDFName!="CTEQ6L" && m_PDFName!="" && m_PDFName!="no PDFs") return ERR_PDFS;
m_usePDF = (m_PDFName=="CTEQ6L");
MEKD_MG_Calc.Use_PDF_w_pT0 = m_usePDF;
/// Check if sqrt(s) is 7 or 8 TeV
if (m_collisionEnergy!=7 && m_collisionEnergy!=8) cerr << "WARNING! You have set energy to be " << m_collisionEnergy << " TeV\n";
return 0;
}
///------------------------------------------------------------------------
/// MEKD::setProcessName - sanity check and setting of process names
///------------------------------------------------------------------------
int MEKD::setProcessName(string process)
{
/// Check if process is supported, translation of namings
if( process=="Custom" ) {m_process="Custom"; } // Parameter-card-defined model
else if( process=="qqZZ" || process=="ZZ" ) {m_process="qqZZ"; } // "Background"
else if( process=="qqDY" ) {m_process="qqDY"; } // "Background"
else if( process=="DY" ) {m_process="DY"; }
else if( process=="Higgs" || process=="SMHiggs" || process=="ggSpin0Pm" ) {m_process="ggSpin0Pm"; } // Spin-0 models
else if( process== "Spin0Pm" ) {m_process= "Spin0Pm"; }
else if( process=="CP-odd" || process=="Higgs0M" || process=="ggSpin0M" ) {m_process="ggSpin0M"; }
else if( process== "Spin0M" ) {m_process= "Spin0M"; }
else if( process=="ggSpin0PH" || process=="ggSpin0Ph" ) {m_process="ggSpin0Ph"; }
else if( process== "Spin0Ph" ) {m_process= "Spin0Ph";}
else if( process=="ggSpin0" ) {m_process="ggSpin0"; }
else if( process== "Spin0" ) {m_process= "Spin0"; }
else if( process=="qqSpin1P" ) {m_process="qqSpin1P"; } // Spin-1 models
else if( process== "Spin1P" ) {m_process= "Spin1P"; }
else if( process=="qqSpin1M" ) {m_process="qqSpin1M"; }
else if( process== "Spin1M" ) {m_process= "Spin1M"; }
else if( process=="qqSpin1" ) {m_process="qqSpin1"; }
else if( process== "Spin1" ) {m_process= "Spin1"; }
else if( process=="ggSpin2PM" || process=="Graviton2PM" ||
process=="ggSpin2Pm" ) {m_process="ggSpin2Pm"; } // Spin-2 models
else if( process=="qqSpin2PM" || process=="qqGraviton2PM" ||
process=="qqSpin2Pm" ) {m_process="qqSpin2Pm"; }
else if( process== "Spin2Pm" ) {m_process= "Spin2Pm"; }
else if( process=="ggSpin2Ph" ) {m_process="ggSpin2Ph"; }
else if( process=="qqSpin2Ph" ) {m_process="qqSpin2Ph"; }
else if( process== "Spin2Ph" ) {m_process= "Spin2Ph"; }
else if( process=="ggSpin2Mh" ) {m_process="ggSpin2Mh"; }
else if( process=="qqSpin2Mh" ) {m_process="qqSpin2Mh"; }
else if( process== "Spin2Mh" ) {m_process= "Spin2Mh"; }
else if( process=="ggSpin2Pb" ) {m_process="ggSpin2Pb"; }
else if( process=="qqSpin2Pb" ) {m_process="qqSpin2Pb"; }
else if( process== "Spin2Pb" ) {m_process= "Spin2Pb"; }
else if( process=="ggSpin2Ph2" ) {m_process="ggSpin2Ph2"; }
else if( process=="qqSpin2Ph2" ) {m_process="qqSpin2Ph2"; }
else if( process== "Spin2Ph2" ) {m_process= "Spin2Ph2"; }
else if( process=="ggSpin2Ph3" ) {m_process="ggSpin2Ph3"; }
else if( process=="qqSpin2Ph3" ) {m_process="qqSpin2Ph3"; }
else if( process== "Spin2Ph3" ) {m_process= "Spin2Ph3"; }
else if( process=="ggSpin2Ph6" ) {m_process="ggSpin2Ph6"; }
else if( process=="qqSpin2Ph6" ) {m_process="qqSpin2Ph6"; }
else if( process== "Spin2Ph6" ) {m_process= "Spin2Ph6"; }
else if( process=="ggSpin2Ph7" ) {m_process="ggSpin2Ph7"; }
else if( process=="qqSpin2Ph7" ) {m_process="qqSpin2Ph7"; }
else if( process== "Spin2Ph7" ) {m_process= "Spin2Ph7"; }
else if( process=="ggSpin2Mh9" ) {m_process="ggSpin2Mh9"; }
else if( process=="qqSpin2Mh9" ) {m_process="qqSpin2Mh9"; }
else if( process== "Spin2Mh9" ) {m_process= "Spin2Mh9"; }
else if( process=="ggSpin2Mh10" ) {m_process="ggSpin2Mh10"; }
else if( process=="qqSpin2Mh10" ) {m_process="qqSpin2Mh10"; }
else if( process== "Spin2Mh10" ) {m_process= "Spin2Mh10"; }
else if( process=="ggSpin2" ) {m_process="ggSpin2"; }
else if( process=="qqSpin2" ) {m_process="qqSpin2"; }
else if( process== "Spin2" ) {m_process= "Spin2"; }
else if( process=="ggSpin0Pm_2f" ) {m_process="ggSpin0Pm_2f"; } // Spin-0-to-2-leptons models
else if( process== "Spin0Pm_2f" ) {m_process= "Spin0Pm_2f"; }
else if( process=="ggSpin0M_2f" ) {m_process="ggSpin0M_2f"; }
else if( process== "Spin0M_2f" ) {m_process= "Spin0M_2f"; }
// else if( process=="ggSpin0_2f" ) {m_process="ggSpin0_2f"; }
// else if( process== "Spin0_2f" ) {m_process= "Spin0_2f"; }
else if( process=="qqSpin1P_2f" ) {m_process="qqSpin1P_2f"; } // Spin-1-to-2-leptons models
else if( process== "Spin1P_2f" ) {m_process= "Spin1P_2f"; }
else if( process=="qqSpin1M_2f" ) {m_process="qqSpin1M_2f"; }
else if( process== "Spin1M_2f" ) {m_process= "Spin1M_2f"; }
// else if( process=="qqSpin1_2f" ) {m_process="qqSpin1_2f"; }
// else if( process== "Spin1_2f" ) {m_process= "Spin1_2f"; }
else if( process=="ggSpin2Pm_2f" ) {m_process="ggSpin2Pm_2f"; } // Spin-2-to-2-leptons models
else if( process=="qqSpin2Pm_2f" ) {m_process="qqSpin2Pm_2f"; }
else if( process== "Spin2Pm_2f" ) {m_process= "Spin2Pm_2f"; }
// else if( process=="ggSpin2_2f" ) {m_process="ggSpin2_2f"; }
// else if( process=="qqSpin2_2f" ) {m_process="qqSpin2_2f"; }
// else if( process== "Spin2_2f" ) {m_process= "Spin2_2f"; }
else if( process=="qqZ4l_Background" ) {m_process="qqZ4l_Background"; } // Z->4l models
else if( process=="qqZ4l_Signal" ) {m_process="qqZ4l_Signal"; }
else return ERR_PROCESS;
return 0;
}
///------------------------------------------------------------------------
/// MEKD::setProcessNames - sanity check and setting of process names
///------------------------------------------------------------------------
int MEKD::setProcessNames(string processA, string processB) {
/// processes A and B should be different
if( processA == processB ) return ERR_PROCESS;
/// check if processA is supported, translation of namings
if( processA=="Custom" ) {m_processA="Custom"; } // Parameter-card-defined model
else if( processA=="qqZZ" || processA=="ZZ" ) {m_processA="qqZZ"; } // "Background"
else if( processA=="qqDY" ) {m_processA="qqDY"; } // "Background"
else if( processA=="DY" ) {m_processA="DY"; }
else if( processA=="Higgs" || processA=="SMHiggs" || processA=="ggSpin0Pm" ) {m_processA="ggSpin0Pm"; } // Spin-0 models
else if( processA== "Spin0Pm" ) {m_processA= "Spin0Pm"; }
else if( processA=="CP-odd" || processA=="Higgs0M" || processA=="ggSpin0M" ) {m_processA="ggSpin0M"; }
else if( processA== "Spin0M" ) {m_processA= "Spin0M"; }
else if( processA=="ggSpin0PH" || processA=="ggSpin0Ph" ) {m_processA="ggSpin0Ph"; }
else if( processA== "Spin0Ph" ) {m_processA= "Spin0Ph";}
else if( processA=="ggSpin0" ) {m_processA="ggSpin0"; }
else if( processA== "Spin0" ) {m_processA= "Spin0"; }
else if( processA=="qqSpin1P" ) {m_processA="qqSpin1P"; } // Spin-1 models
else if( processA== "Spin1P" ) {m_processA= "Spin1P"; }
else if( processA=="qqSpin1M" ) {m_processA="qqSpin1M"; }
else if( processA== "Spin1M" ) {m_processA= "Spin1M"; }
else if( processA=="qqSpin1" ) {m_processA="qqSpin1"; }
else if( processA== "Spin1" ) {m_processA= "Spin1"; }
else if( processA=="ggSpin2PM" || processA=="Graviton2PM" ||
processA=="ggSpin2Pm" ) {m_processA="ggSpin2Pm"; } // Spin-2 models
else if( processA=="qqSpin2PM" || processA=="qqGraviton2PM" ||
processA=="qqSpin2Pm" ) {m_processA="qqSpin2Pm"; }
else if( processA== "Spin2Pm" ) {m_processA= "Spin2Pm"; }
else if( processA=="ggSpin2Ph" ) {m_processA="ggSpin2Ph"; }
else if( processA=="qqSpin2Ph" ) {m_processA="qqSpin2Ph"; }
else if( processA== "Spin2Ph" ) {m_processA= "Spin2Ph"; }
else if( processA=="ggSpin2Mh" ) {m_processA="ggSpin2Mh"; }
else if( processA=="qqSpin2Mh" ) {m_processA="qqSpin2Mh"; }
else if( processA== "Spin2Mh" ) {m_processA= "Spin2Mh"; }
else if( processA=="ggSpin2Pb" ) {m_processA="ggSpin2Pb"; }
else if( processA=="qqSpin2Pb" ) {m_processA="qqSpin2Pb"; }
else if( processA== "Spin2Pb" ) {m_processA= "Spin2Pb"; }
else if( processA=="ggSpin2Ph2" ) {m_processA="ggSpin2Ph2"; }
else if( processA=="qqSpin2Ph2" ) {m_processA="qqSpin2Ph2"; }
else if( processA== "Spin2Ph2" ) {m_processA= "Spin2Ph2"; }
else if( processA=="ggSpin2Ph3" ) {m_processA="ggSpin2Ph3"; }
else if( processA=="qqSpin2Ph3" ) {m_processA="qqSpin2Ph3"; }
else if( processA== "Spin2Ph3" ) {m_processA= "Spin2Ph3"; }
else if( processA=="ggSpin2Ph6" ) {m_processA="ggSpin2Ph6"; }
else if( processA=="qqSpin2Ph6" ) {m_processA="qqSpin2Ph6"; }
else if( processA== "Spin2Ph6" ) {m_processA= "Spin2Ph6"; }
else if( processA=="ggSpin2Ph7" ) {m_processA="ggSpin2Ph7"; }
else if( processA=="qqSpin2Ph7" ) {m_processA="qqSpin2Ph7"; }
else if( processA== "Spin2Ph7" ) {m_processA= "Spin2Ph7"; }
else if( processA=="ggSpin2Mh9" ) {m_processA="ggSpin2Mh9"; }
else if( processA=="qqSpin2Mh9" ) {m_processA="qqSpin2Mh9"; }
else if( processA== "Spin2Mh9" ) {m_processA= "Spin2Mh9"; }
else if( processA=="ggSpin2Mh10" ) {m_processA="ggSpin2Mh10"; }
else if( processA=="qqSpin2Mh10" ) {m_processA="qqSpin2Mh10"; }
else if( processA== "Spin2Mh10" ) {m_processA= "Spin2Mh10"; }
else if( processA=="ggSpin2" ) {m_processA="ggSpin2"; }
else if( processA=="qqSpin2" ) {m_processA="qqSpin2"; }
else if( processA== "Spin2" ) {m_processA= "Spin2"; }
else if( processA=="ggSpin0Pm_2f" ) {m_processA="ggSpin0Pm_2f"; } // Spin-0-to-2-leptons models
else if( processA== "Spin0Pm_2f" ) {m_processA= "Spin0Pm_2f"; }
else if( processA=="ggSpin0M_2f" ) {m_processA="ggSpin0M_2f"; }
else if( processA== "Spin0M_2f" ) {m_processA= "Spin0M_2f"; }
// else if( processA=="ggSpin0_2f" ) {m_processA="ggSpin0_2f"; }
// else if( processA== "Spin0_2f" ) {m_processA= "Spin0_2f"; }
else if( processA=="qqSpin1P_2f" ) {m_processA="qqSpin1P_2f"; } // Spin-1-to-2-leptons models
else if( processA== "Spin1P_2f" ) {m_processA= "Spin1P_2f"; }
else if( processA=="qqSpin1M_2f" ) {m_processA="qqSpin1M_2f"; }
else if( processA== "Spin1M_2f" ) {m_processA= "Spin1M_2f"; }
// else if( processA=="qqSpin1_2f" ) {m_processA="qqSpin1_2f"; }
// else if( processA== "Spin1_2f" ) {m_processA= "Spin1_2f"; }
else if( processA=="ggSpin2Pm_2f" ) {m_processA="ggSpin2Pm_2f"; } // Spin-2-to-2-leptons models
else if( processA=="qqSpin2Pm_2f" ) {m_processA="qqSpin2Pm_2f"; }
else if( processA== "Spin2Pm_2f" ) {m_processA= "Spin2Pm_2f"; }
// else if( processA=="ggSpin2_2f" ) {m_processA="ggSpin2_2f"; }
// else if( processA=="qqSpin2_2f" ) {m_processA="qqSpin2_2f"; }
// else if( processA== "Spin2_2f" ) {m_processA= "Spin2_2f"; }
else if( processA=="qqZ4l_Background" ) {m_processA="qqZ4l_Background"; } // Z->4l models
else if( processA=="qqZ4l_Signal" ) {m_processA="qqZ4l_Signal"; }
else return ERR_PROCESS;
/// check if processB is supported, translation of namings
if( processB=="Custom" ) {m_processB="Custom"; } // Parameter-card-defined model
else if( processB=="qqZZ" || processB=="ZZ" ) {m_processB="qqZZ"; } // "Background"
else if( processB=="qqDY" ) {m_processB="qqDY"; } // "Background"
else if( processB=="DY" ) {m_processB="DY"; }
else if( processB=="Higgs" || processB=="SMHiggs" || processB=="ggSpin0Pm" ) {m_processB="ggSpin0Pm"; } // Spin-0 models
else if( processB== "Spin0Pm" ) {m_processB= "Spin0Pm"; }
else if( processB=="CP-odd" || processB=="Higgs0M" || processB=="ggSpin0M" ) {m_processB="ggSpin0M"; }
else if( processB== "Spin0M" ) {m_processB= "Spin0M"; }
else if( processB=="ggSpin0PH" || processB=="ggSpin0Ph" ) {m_processB="ggSpin0Ph"; }
else if( processB== "Spin0Ph" ) {m_processB= "Spin0Ph";}
else if( processB=="ggSpin0" ) {m_processB="ggSpin0"; }
else if( processB== "Spin0" ) {m_processB= "Spin0"; }
else if( processB=="qqSpin1P" ) {m_processB="qqSpin1P"; } // Spin-1 models
else if( processB== "Spin1P" ) {m_processB= "Spin1P"; }
else if( processB=="qqSpin1M" ) {m_processB="qqSpin1M"; }
else if( processB== "Spin1M" ) {m_processB= "Spin1M"; }
else if( processB=="qqSpin1" ) {m_processB="qqSpin1"; }
else if( processB== "Spin1" ) {m_processB= "Spin1"; }
else if( processB=="ggSpin2PM" || processB=="Graviton2PM" ||
processB=="ggSpin2Pm" ) {m_processB="ggSpin2Pm"; } // Spin-2 models
else if( processB=="qqSpin2PM" || processB=="qqGraviton2PM" ||
processB=="qqSpin2Pm" ) {m_processB="qqSpin2Pm"; }
else if( processB== "Spin2Pm" ) {m_processB= "Spin2Pm"; }
else if( processB=="ggSpin2Ph" ) {m_processB="ggSpin2Ph"; }
else if( processB=="qqSpin2Ph" ) {m_processB="qqSpin2Ph"; }
else if( processB== "Spin2Ph" ) {m_processB= "Spin2Ph"; }
else if( processB=="ggSpin2Mh" ) {m_processB="ggSpin2Mh"; }
else if( processB=="qqSpin2Mh" ) {m_processB="qqSpin2Mh"; }
else if( processB== "Spin2Mh" ) {m_processB= "Spin2Mh"; }
else if( processB=="ggSpin2Pb" ) {m_processB="ggSpin2Pb"; }
else if( processB=="qqSpin2Pb" ) {m_processB="qqSpin2Pb"; }
else if( processB== "Spin2Pb" ) {m_processB= "Spin2Pb"; }
else if( processB=="ggSpin2Ph2" ) {m_processB="ggSpin2Ph2"; }
else if( processB=="qqSpin2Ph2" ) {m_processB="qqSpin2Ph2"; }
else if( processB== "Spin2Ph2" ) {m_processB= "Spin2Ph2"; }
else if( processB=="ggSpin2Ph3" ) {m_processB="ggSpin2Ph3"; }
else if( processB=="qqSpin2Ph3" ) {m_processB="qqSpin2Ph3"; }
else if( processB== "Spin2Ph3" ) {m_processB= "Spin2Ph3"; }
else if( processB=="ggSpin2Ph6" ) {m_processB="ggSpin2Ph6"; }
else if( processB=="qqSpin2Ph6" ) {m_processB="qqSpin2Ph6"; }
else if( processB== "Spin2Ph6" ) {m_processB= "Spin2Ph6"; }
else if( processB=="ggSpin2Ph7" ) {m_processB="ggSpin2Ph7"; }
else if( processB=="qqSpin2Ph7" ) {m_processB="qqSpin2Ph7"; }
else if( processB== "Spin2Ph7" ) {m_processB= "Spin2Ph7"; }
else if( processB=="ggSpin2Mh9" ) {m_processB="ggSpin2Mh9"; }
else if( processB=="qqSpin2Mh9" ) {m_processB="qqSpin2Mh9"; }
else if( processB== "Spin2Mh9" ) {m_processB= "Spin2Mh9"; }
else if( processB=="ggSpin2Mh10" ) {m_processB="ggSpin2Mh10"; }
else if( processB=="qqSpin2Mh10" ) {m_processB="qqSpin2Mh10"; }
else if( processB== "Spin2Mh10" ) {m_processB= "Spin2Mh10"; }
else if( processB=="ggSpin2" ) {m_processB="ggSpin2"; }
else if( processB=="qqSpin2" ) {m_processB="qqSpin2"; }
else if( processB== "Spin2" ) {m_processB= "Spin2"; }
else if( processB=="ggSpin0Pm_2f" ) {m_processB="ggSpin0Pm_2f"; } // Spin-0-to-2-leptons models
else if( processB== "Spin0Pm_2f" ) {m_processB= "Spin0Pm_2f"; }
else if( processB=="ggSpin0M_2f" ) {m_processB="ggSpin0M_2f"; }
else if( processB== "Spin0M_2f" ) {m_processB= "Spin0M_2f"; }
// else if( processB=="ggSpin0_2f" ) {m_processB="ggSpin0_2f"; }
// else if( processB== "Spin0_2f" ) {m_processB= "Spin0_2f"; }
else if( processB=="qqSpin1P_2f" ) {m_processB="qqSpin1P_2f"; } // Spin-1-to-2-leptons models
else if( processB== "Spin1P_2f" ) {m_processB= "Spin1P_2f"; }
else if( processB=="qqSpin1M_2f" ) {m_processB="qqSpin1M_2f"; }
else if( processB== "Spin1M_2f" ) {m_processB= "Spin1M_2f"; }
// else if( processB=="qqSpin1_2f" ) {m_processB="qqSpin1_2f"; }
// else if( processB== "Spin1_2f" ) {m_processB= "Spin1_2f"; }
else if( processB=="ggSpin2Pm_2f" ) {m_processB="ggSpin2Pm_2f"; } // Spin-2-to-2-leptons models
else if( processB=="qqSpin2Pm_2f" ) {m_processB="qqSpin2Pm_2f"; }
else if( processB== "Spin2Pm_2f" ) {m_processB= "Spin2Pm_2f"; }
// else if( processB=="ggSpin2_2f" ) {m_processB="ggSpin2_2f"; }
// else if( processB=="qqSpin2_2f" ) {m_processB="qqSpin2_2f"; }
// else if( processB== "Spin2_2f" ) {m_processB= "Spin2_2f"; }
else if( processB=="qqZ4l_Background" ) {m_processB="qqZ4l_Background"; } // Z->4l models
else if( processB=="qqZ4l_Signal" ) {m_processB="qqZ4l_Signal"; }
else return ERR_PROCESS;
return 0;
}
///------------------------------------------------------------------------
/// MEKD::computeKD - compute KD from precalculated MEs for input prcesses A and B
///------------------------------------------------------------------------
int MEKD::computeKD( string processA, string processB,
double& kd,
double& me2processA,
double& me2processB )
{
/// Sanity check for input process names
if( (buffer_int=setProcessNames(processA, processB)) != 0 ) return buffer_int;
/// Looking for the precalculated MEs
if( ME_ZZ == 0 ) { cerr << "ERROR! The requested process has not been precalculated.\n" ; return ERR_PROCESS; }
else if( m_processA=="ZZ" ) me2processA = ME_ZZ;
else if( m_processA=="ggSpin0Pm" ) me2processA = ME_Spin0PSMH;
else if( m_processA=="ggSpin0M" ) me2processA = ME_Spin0M;
else if( m_processA=="ggSpin0Ph" ) me2processA = ME_Spin0Ph;
else if( m_processA=="qqSpin1P" ) me2processA = ME_Spin1P;
else if( m_processA=="qqSpin1M" ) me2processA = ME_Spin1M;
else if( m_processA=="ggSpin2Pm" ) me2processA = ME_ggSpin2Pm;
else if( m_processA=="qqSpin2Pm" ) me2processA = ME_qqSpin2Pm;
else { cerr << "ERROR! The requested process has not been precalculated.\n" ; return ERR_PROCESS; }
/// Looking for the precalculated MEs
if( ME_ZZ == 0 ) { cerr << "ERROR! The requested process has not been precalculated.\n" ; return ERR_PROCESS; }
else if( m_processB=="ZZ" ) me2processB = ME_ZZ;
else if( m_processB=="ggSpin0Pm" ) me2processB = ME_Spin0PSMH;
else if( m_processB=="ggSpin0M" ) me2processB = ME_Spin0M;
else if( m_processB=="ggSpin0Ph" ) me2processB = ME_Spin0Ph;
else if( m_processB=="qqSpin1P" ) me2processB = ME_Spin1P;
else if( m_processB=="qqSpin1M" ) me2processB = ME_Spin1M;
else if( m_processB=="ggSpin2Pm" ) me2processB = ME_ggSpin2Pm;
else if( m_processB=="qqSpin2Pm" ) me2processB = ME_qqSpin2Pm;
else { cerr << "ERROR! The requested process has not been precalculated.\n" ; return ERR_PROCESS; }
/// Build Kinematic Discriminant (KD) as a ratio of logs of MEs
kd = log(me2processA / me2processB);
return 0;
}
///------------------------------------------------------------------------
/// MEKD::computeKD - compute KD and MEs for input prcesses A and B
///------------------------------------------------------------------------
int MEKD::computeKD( string processA, string processB,
double lept1P[], int lept1Id, double lept2P[], int lept2Id,
double lept3P[], int lept3Id, double lept4P[], int lept4Id,
double& kd, double& me2processA, double& me2processB )
{
/// Load internal containers
four_particle_Ps_i[0] = lept1P;
four_particle_Ps_i[1] = lept2P;
four_particle_Ps_i[2] = lept3P;
four_particle_Ps_i[3] = lept4P;
four_particle_IDs_i[0] = lept1Id;
four_particle_IDs_i[1] = lept2Id;
four_particle_IDs_i[2] = lept3Id;
four_particle_IDs_i[3] = lept4Id;
return computeKD( processA, processB, four_particle_Ps_i, four_particle_IDs_i, kd, me2processA, me2processB );
}
///------------------------------------------------------------------------
/// MEKD::computeKD - compute KD and MEs for the input processes A and B
///------------------------------------------------------------------------
int MEKD::computeKD( string processA, string processB,
vector<double*> input_Ps, vector<int> input_IDs,
double& kd, double& me2processA, double& me2processB )
{
/// Checks input for compatibility
if( input_Ps.size() != input_IDs.size() ) return ERR_INPUT;
if( input_Ps.size() < 2 || input_Ps.size() > 5 ) return ERR_INPUT;
/// Set an expected resonance decay mode
if( input_Ps.size() == 2 || input_Ps.size() == 3 ) MEKD_MG_Calc.Resonance_decay_mode="2mu";
else MEKD_MG_Calc.Resonance_decay_mode="ZZ";
/// Sanity check for input process names and internal parameters
if( (buffer_int=setProcessNames(processA, processB)) != 0 ) return buffer_int;
if( (buffer_int=processParameters()) != 0 ) return buffer_int;
/// Set input-particle kinematics
MEKD_MG_Calc.p1 = input_Ps[0];
MEKD_MG_Calc.id1 = input_IDs[0];
MEKD_MG_Calc.p2 = input_Ps[1];
MEKD_MG_Calc.id2 = input_IDs[1];
if( input_IDs.size() >= 3 )
{
MEKD_MG_Calc.p3 = input_Ps[2];
MEKD_MG_Calc.id3 = input_IDs[2];
}
else MEKD_MG_Calc.id3 = 0;
if( input_IDs.size() >= 4 )
{
MEKD_MG_Calc.p4 = input_Ps[3];
MEKD_MG_Calc.id4 = input_IDs[3];
}
else MEKD_MG_Calc.id4 = 0;
if( input_IDs.size() >= 5 )
{
MEKD_MG_Calc.p5 = input_Ps[4];
MEKD_MG_Calc.id5 = input_IDs[4];
}
else MEKD_MG_Calc.id5 = 0;
/// Compute ME for process A only (e.g. signal 1)
buffer_int = MEKD_MG_Calc.Run_MEKD_MG( m_processA );
/// Get ME for process A
me2processA = MEKD_MG_Calc.Signal_ME;
/// Compute ME for process B only (e.g. signal 2 or background)
buffer_int = MEKD_MG_Calc.Run_MEKD_MG( m_processB );
/// Get ME for process B
me2processB = MEKD_MG_Calc.Signal_ME;
/// Build Kinematic Discriminant (KD) as a ratio of logs of MEs
kd = log(me2processA / me2processB);
return buffer_int;
}
///------------------------------------------------------------------------
/// MEKD::computeME - compute ME for the input process
///------------------------------------------------------------------------
int MEKD::computeME( string processName,
vector<double*> input_Ps, vector<int> input_IDs,
double& me2process )
{
/// Checks input for compatibility
if( input_Ps.size() != input_IDs.size() ) return ERR_INPUT;
if( input_Ps.size() < 2 || input_Ps.size() > 5 ) return ERR_INPUT;
/// Set an expected resonance decay mode
if( input_Ps.size() == 2 || input_Ps.size() == 3 ) MEKD_MG_Calc.Resonance_decay_mode="2mu";
else MEKD_MG_Calc.Resonance_decay_mode="ZZ";
/// Sanity check for input process names and internal parameters
if( (buffer_int=setProcessName(processName)) != 0 ) return buffer_int;
if( (buffer_int=processParameters()) != 0 ) return buffer_int;
/// Set input-particle kinematics
MEKD_MG_Calc.p1 = input_Ps[0];
MEKD_MG_Calc.id1 = input_IDs[0];
MEKD_MG_Calc.p2 = input_Ps[1];
MEKD_MG_Calc.id2 = input_IDs[1];
if( input_IDs.size() >= 3 )
{
MEKD_MG_Calc.p3 = input_Ps[2];
MEKD_MG_Calc.id3 = input_IDs[2];
}
else MEKD_MG_Calc.id3 = 0;
if( input_IDs.size() >= 4 )
{
MEKD_MG_Calc.p4 = input_Ps[3];
MEKD_MG_Calc.id4 = input_IDs[3];
}
else MEKD_MG_Calc.id4 = 0;
if( input_IDs.size() >= 5 )
{
MEKD_MG_Calc.p5 = input_Ps[4];
MEKD_MG_Calc.id5 = input_IDs[4];
}
else MEKD_MG_Calc.id5 = 0;
/// Compute ME for the process (e.g. signal 1)
buffer_int = MEKD_MG_Calc.Run_MEKD_MG( m_process );
/// Get ME for the process
me2process = MEKD_MG_Calc.Signal_ME;
return buffer_int;
}
///------------------------------------------------------------------------
/// MEKD::computeMEs - compute MEs for a multiple reuse
///------------------------------------------------------------------------
int MEKD::computeMEs( double lept1P[], int lept1Id, double lept2P[], int lept2Id,
double lept3P[], int lept3Id, double lept4P[], int lept4Id )
{
/// Load internal containers
four_particle_Ps_i[0] = lept1P;
four_particle_Ps_i[1] = lept2P;
four_particle_Ps_i[2] = lept3P;
four_particle_Ps_i[3] = lept4P;
four_particle_IDs_i[0] = lept1Id;
four_particle_IDs_i[1] = lept2Id;
four_particle_IDs_i[2] = lept3Id;
four_particle_IDs_i[3] = lept4Id;
return computeMEs( four_particle_Ps_i, four_particle_IDs_i );
}
///------------------------------------------------------------------------
/// MEKD::computeMEs - compute MEs for a multiple reuse
///------------------------------------------------------------------------
int MEKD::computeMEs( vector<double*> input_Ps, vector<int> input_IDs )
{
/// Checks input for compatibility
if( input_Ps.size() != input_IDs.size() ) return ERR_INPUT;
if( input_Ps.size() < 2 || input_Ps.size() > 5 ) return ERR_INPUT;
/// Set an expected resonance decay mode
if( input_Ps.size() == 2 || input_Ps.size() == 3 ) MEKD_MG_Calc.Resonance_decay_mode="2mu";
else MEKD_MG_Calc.Resonance_decay_mode="ZZ";
/// Sanity check for internal parameters
if( (buffer_int=processParameters()) != 0 ) return buffer_int;
/// Parameterize MEKD_MG_Calc
if( MEKD_MG_Calc.Test_Models.size()==0 ) // Fills in intersting models to compute only once
{
MEKD_MG_Calc.Test_Models.push_back( "ZZ" );
MEKD_MG_Calc.Test_Models.push_back( "ggSpin0Pm" );
MEKD_MG_Calc.Test_Models.push_back( "ggSpin0M" );
MEKD_MG_Calc.Test_Models.push_back( "ggSpin0Ph" );
MEKD_MG_Calc.Test_Models.push_back( "qqSpin1P" );
MEKD_MG_Calc.Test_Models.push_back( "qqSpin1M" );
MEKD_MG_Calc.Test_Models.push_back( "ggSpin2Pm" );
MEKD_MG_Calc.Test_Models.push_back( "qqSpin2Pm" );
}
else if( MEKD_MG_Calc.Test_Models.size()!=4 ) return ERR_PROCESS;
/// Set input-particle kinematics
MEKD_MG_Calc.p1 = input_Ps[0];
MEKD_MG_Calc.id1 = input_IDs[0];
MEKD_MG_Calc.p2 = input_Ps[1];
MEKD_MG_Calc.id2 = input_IDs[1];
if( input_IDs.size() >= 3 )
{
MEKD_MG_Calc.p3 = input_Ps[2];
MEKD_MG_Calc.id3 = input_IDs[2];
}
else MEKD_MG_Calc.id3 = 0;
if( input_IDs.size() >= 4 )
{
MEKD_MG_Calc.p4 = input_Ps[3];
MEKD_MG_Calc.id4 = input_IDs[3];
}
else MEKD_MG_Calc.id4 = 0;
if( input_IDs.size() >= 5 )
{
MEKD_MG_Calc.p5 = input_Ps[4];
MEKD_MG_Calc.id5 = input_IDs[4];
}
else MEKD_MG_Calc.id5 = 0;
/// Compute MEs
buffer_int = MEKD_MG_Calc.Run_MEKD_MG();
/// ME value readouts
ME_ZZ = MEKD_MG_Calc.Signal_MEs[0];
ME_Spin0PSMH = MEKD_MG_Calc.Signal_MEs[1];
ME_Spin0M = MEKD_MG_Calc.Signal_MEs[2];
ME_Spin0Ph = MEKD_MG_Calc.Signal_MEs[3];
ME_Spin1P = MEKD_MG_Calc.Signal_MEs[4];
ME_Spin1M = MEKD_MG_Calc.Signal_MEs[5];
ME_ggSpin2Pm = MEKD_MG_Calc.Signal_MEs[6];
ME_qqSpin2Pm = MEKD_MG_Calc.Signal_MEs[7];
return buffer_int;
}
///------------------------------------------------------------------------
/// Mixed-state ME mixer of production like qqSpin1M, qqSpin1P, exotic, exotic pseudo, and decay like Spin1M, Spin1P states, corresponding couplings rhoQ11, rhoQ12, rhoQ13, rhoQ14, b1z/rhomu11, b2z/rhomu12, rhomu13, rhomu14.
///------------------------------------------------------------------------
int MEKD::Mix_Spin0( complex<double> Spin0Pm_relamp, complex<double> Spin0Ph_relamp, complex<double> Spin0Phexo_relamp, complex<double> Spin0M_relamp )
{
m_Mixing_Coefficients_Spin0[0] = Spin0Pm_relamp;
m_Mixing_Coefficients_Spin0[1] = Spin0Ph_relamp;
m_Mixing_Coefficients_Spin0[2] = Spin0Phexo_relamp;
m_Mixing_Coefficients_Spin0[3] = Spin0M_relamp;
if( m_Mixing_Coefficients_Spin0 == NULL ) return ERR_OTHER;
return 0;
}
///------------------------------------------------------------------------
/// Mixed-state ME mixer of production like qqSpin1M, qqSpin1P, exotic, exotic pseudo, and decay like Spin1M, Spin1P states, corresponding couplings rhoQ11, rhoQ12, rhoQ13, rhoQ14, b1z/rhomu11, b2z/rhomu12, rhomu13, rhomu14.
///------------------------------------------------------------------------
int MEKD::Mix_Spin1( complex<double> prod_Spin1M_relamp, complex<double> prod_Spin1P_relamp, complex<double> prod_Spin1Mexo_relamp, complex<double> prod_Spin1Pexo_relamp, complex<double> dec_Spin1M_relamp, complex<double> dec_Spin1P_relamp, complex<double> dec_Spin1_rhomu13_relamp, complex<double> dec_Spin1_rhomu14_relamp )
{
m_Mixing_Coefficients_Spin1[0] = prod_Spin1M_relamp;
m_Mixing_Coefficients_Spin1[1] = prod_Spin1P_relamp;
m_Mixing_Coefficients_Spin1[2] = prod_Spin1Mexo_relamp;
m_Mixing_Coefficients_Spin1[3] = prod_Spin1Pexo_relamp;
m_Mixing_Coefficients_Spin1[4] = dec_Spin1M_relamp;
m_Mixing_Coefficients_Spin1[5] = dec_Spin1M_relamp;
m_Mixing_Coefficients_Spin1[6] = dec_Spin1_rhomu13_relamp;
m_Mixing_Coefficients_Spin1[7] = dec_Spin1_rhomu14_relamp;
if( m_Mixing_Coefficients_Spin1 == NULL ) return ERR_OTHER;
return 0;
}
///------------------------------------------------------------------------
/// Mixed-state ME mixer of Spin-2 states. Production couplings: k1g/rhoQ21, ..., k4g/rhoQ24, ..., k10g, decay couplings: k1z/rhomu21, k4z/rhomu24, ..., k10z.
///------------------------------------------------------------------------
int MEKD::Mix_Spin2( complex<double> *prod_Spin2_relamp, complex<double> *dec_Spin2_relamp )
{
for( buffer_uint=0; buffer_uint<10; buffer_uint++)
m_Mixing_Coefficients_Spin2[buffer_uint] = prod_Spin2_relamp[buffer_uint];
for( buffer_uint=10; buffer_uint<20; buffer_uint++)
m_Mixing_Coefficients_Spin2[buffer_uint] = dec_Spin2_relamp[buffer_uint];
if( m_Mixing_Coefficients_Spin2 == NULL ) return ERR_OTHER;
return 0;
}
#if (defined(MEKD_STANDALONE) && defined(MEKD_with_ROOT)) || !(defined(MEKD_STANDALONE))
///------------------------------------------------------------------------
/// (ROOT-compatabile overloads)
///------------------------------------------------------------------------
///------------------------------------------------------------------------
/// MEKD::computeKD - compute KD and MEs for the input processes A and B
///------------------------------------------------------------------------
int MEKD::computeKD( TString processA, TString processB,
TLorentzVector lept1P, int lept1Id, TLorentzVector lept2P, int lept2Id,
TLorentzVector lept3P, int lept3Id, TLorentzVector lept4P, int lept4Id,
double& kd, double& me2processA, double& me2processB )
{
/// Prepare 4-momenta in the required format
lept1P_i[0] = lept1P.E();
lept1P_i[1] = lept1P.Px();
lept1P_i[2] = lept1P.Py();
lept1P_i[3] = lept1P.Pz();
lept2P_i[0] = lept2P.E();
lept2P_i[1] = lept2P.Px();
lept2P_i[2] = lept2P.Py();
lept2P_i[3] = lept2P.Pz();
lept3P_i[0] = lept3P.E();
lept3P_i[1] = lept3P.Px();
lept3P_i[2] = lept3P.Py();
lept3P_i[3] = lept3P.Pz();
lept4P_i[0] = lept4P.E();
lept4P_i[1] = lept4P.Px();
lept4P_i[2] = lept4P.Py();
lept4P_i[3] = lept4P.Pz();
/// Load internal containers
four_particle_Ps_i[0] = lept1P_i;
four_particle_Ps_i[1] = lept2P_i;
four_particle_Ps_i[2] = lept3P_i;
four_particle_Ps_i[3] = lept4P_i;
four_particle_IDs_i[0] = lept1Id;
four_particle_IDs_i[1] = lept2Id;
four_particle_IDs_i[2] = lept3Id;
four_particle_IDs_i[3] = lept4Id;
return computeKD( (string) processA.Data(), (string) processB.Data(), four_particle_Ps_i, four_particle_IDs_i, kd, me2processA, me2processB );
}
///------------------------------------------------------------------------
/// MEKD::computeKD - compute KD and MEs for the input processes A and B
///------------------------------------------------------------------------
int MEKD::computeKD( TString processA, TString processB,
vector<TLorentzVector> input_Ps, vector<int> input_IDs,
double& kd, double& me2processA, double& me2processB )
{
/// Resize internal vector<double*> if needed
if( input_Ps_i.size() != input_Ps.size() )
{
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ ) { delete input_Ps_i[buffer_uint]; input_Ps_i[buffer_uint]=NULL; }
input_Ps_i.resize( input_Ps.size(), NULL );
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ ) { input_Ps_i[buffer_uint]=new double[4]; }
}
/// Put vector<TLorentzVector> into internal containers
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ )
{
input_Ps_i[buffer_uint][0] = input_Ps[buffer_uint].E();
input_Ps_i[buffer_uint][1] = input_Ps[buffer_uint].Px();
input_Ps_i[buffer_uint][2] = input_Ps[buffer_uint].Py();
input_Ps_i[buffer_uint][3] = input_Ps[buffer_uint].Pz();
}
return computeKD( (string) processA.Data(), (string) processB.Data(), input_Ps_i, input_IDs, kd, me2processA, me2processB );
}
///------------------------------------------------------------------------
/// MEKD::computeME - compute ME for the input process
///------------------------------------------------------------------------
int MEKD::computeME( TString processName,
vector<TLorentzVector> input_Ps, vector<int> input_IDs,
double& me2process )
{
/// Resize internal vector<double*> if needed
if( input_Ps_i.size() != input_Ps.size() )
{
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ ) { delete input_Ps_i[buffer_uint]; input_Ps_i[buffer_uint]=NULL; }
input_Ps_i.resize( input_Ps.size(), NULL );
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ ) { input_Ps_i[buffer_uint]=new double[4]; }
}
/// Put vector<TLorentzVector> into internal containers
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ )
{
input_Ps_i[buffer_uint][0] = input_Ps[buffer_uint].E();
input_Ps_i[buffer_uint][1] = input_Ps[buffer_uint].Px();
input_Ps_i[buffer_uint][2] = input_Ps[buffer_uint].Py();
input_Ps_i[buffer_uint][3] = input_Ps[buffer_uint].Pz();
}
return computeME( (string) processName.Data(), input_Ps_i, input_IDs, me2process );
}
///------------------------------------------------------------------------
/// MEKD::computeMEs - compute MEs for a multiple reuse
///------------------------------------------------------------------------
int MEKD::computeMEs( TLorentzVector lept1P, int lept1Id, TLorentzVector lept2P, int lept2Id,
TLorentzVector lept3P, int lept3Id, TLorentzVector lept4P, int lept4Id )
{
/// Prepare 4-momenta in the required format
lept1P_i[0] = lept1P.E();
lept1P_i[1] = lept1P.Px();
lept1P_i[2] = lept1P.Py();
lept1P_i[3] = lept1P.Pz();
lept2P_i[0] = lept2P.E();
lept2P_i[1] = lept2P.Px();
lept2P_i[2] = lept2P.Py();
lept2P_i[3] = lept2P.Pz();
lept3P_i[0] = lept3P.E();
lept3P_i[1] = lept3P.Px();
lept3P_i[2] = lept3P.Py();
lept3P_i[3] = lept3P.Pz();
lept4P_i[0] = lept4P.E();
lept4P_i[1] = lept4P.Px();
lept4P_i[2] = lept4P.Py();
lept4P_i[3] = lept4P.Pz();
/// Load internal containers
four_particle_Ps_i[0] = lept1P_i;
four_particle_Ps_i[1] = lept2P_i;
four_particle_Ps_i[2] = lept3P_i;
four_particle_Ps_i[3] = lept4P_i;
four_particle_IDs_i[0] = lept1Id;
four_particle_IDs_i[1] = lept2Id;
four_particle_IDs_i[2] = lept3Id;
four_particle_IDs_i[3] = lept4Id;
return computeMEs( four_particle_Ps_i, four_particle_IDs_i );
}
///------------------------------------------------------------------------
/// MEKD::computeMEs - compute MEs for a multiple reuse
///------------------------------------------------------------------------
int MEKD::computeMEs( vector<TLorentzVector> input_Ps, vector<int> input_IDs )
{
/// Resize internal vector<double*> if needed
if( input_Ps_i.size() != input_Ps.size() )
{
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ ) { delete input_Ps_i[buffer_uint]; input_Ps_i[buffer_uint]=NULL; }
input_Ps_i.resize( input_Ps.size(), NULL );
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ ) { input_Ps_i[buffer_uint]=new double[4]; }
}
/// Put vector<TLorentzVector> into internal containers
for( buffer_uint=0; buffer_uint < input_Ps_i.size(); buffer_uint++ )
{
input_Ps_i[buffer_uint][0] = input_Ps[buffer_uint].E();
input_Ps_i[buffer_uint][1] = input_Ps[buffer_uint].Px();
input_Ps_i[buffer_uint][2] = input_Ps[buffer_uint].Py();
input_Ps_i[buffer_uint][3] = input_Ps[buffer_uint].Pz();
}
return computeMEs( input_Ps_i, input_IDs );
}
//////////////////////////////////////////////////////////////////////////
#endif // end of (defined(MEKD_STANDALONE) && defined(MEKD_with_ROOT)) || !(defined(MEKD_STANDALONE))
#endif // end of MEKD_MEKD_cpp
| [
"odysei@gmail.com"
] | odysei@gmail.com |
2816746772e1c0ad2596a6b2692c05abbc308be4 | 9cfe1a3a1a9405381007ee35ac2e94c06f129a36 | /cses/Graph/panetandkingdoms.cpp | eed206228bfe2a3cb0640bf5014ef59d61a58f61 | [] | no_license | Sameer-Mann/codes | dffac04cd525eb38e0f07e148973442105152662 | 6d4a3199cf520f26dcbd5b47b292e3764d2e3514 | refs/heads/master | 2021-06-19T08:38:01.734014 | 2021-06-17T10:22:35 | 2021-06-17T10:22:35 | 211,327,200 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,100 | cpp | #include <bits/stdc++.h>
using namespace std;
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {for(auto v : V) os << v << " ";return os<<"";}
template<class T> ostream& operator<<(ostream &os, set<T> S){os << "{ ";for(auto s:S) os<<s<<" ";return os<<"}";}
template<class T> ostream& operator<<(ostream &os, unordered_set<T> S){os << "{ ";for(auto s:S) os<<s<<" ";return os<<"}";}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){os << "{ ";for(auto s:S) os<<s<<" ";return os<<"}";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {os << "{ ";for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") ";return os<<"}";}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {os << "{ ";for(auto m:M) os<<"("<<m.fi<<":"<<m.se<<") ";return os<<"}";}
template<typename T>
void print(T t){cout<<(t);cout<<'\n';}
template<typename T, typename... Args>
void print(T t, Args... args){cout << (t) <<' ';print(args...);}
int n,m,scc;
vector<vector<int>>g,gr;
vector<int>vis,ordering,compscc;
void dfs(int node){
vis[node]=1;
for(auto nbr:g[node]){
if(!vis[nbr])
dfs(nbr);
}
ordering.push_back(node);
}
void dfs2(int node){
vis[node]=1;
compscc[node]=scc;
for(auto nbr:gr[node]){
if(!vis[nbr])
dfs2(nbr);
}
}
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
g=vector<vector<int>>(n);
gr=vector<vector<int>>(n);
compscc=vector<int>(n);
vis=vector<int>(n,0);
for (int i = 0; i < m; ++i)
{
int u,v;cin>>u>>v;
u--,v--;
g[u].push_back(v);
gr[v].push_back(u);
}
for (int i = 0; i < n; ++i)
{
if(!vis[i])dfs(i);
}
reverse(ordering.begin(), ordering.end());
vis.assign(n,0);
scc=1;
for(auto x:ordering)
{
if(!vis[x])dfs2(x),scc++;
}
print(scc-1);
print(compscc);
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
57a31bb2bf8e0e3714676223884c675b08ab4160 | b99807bb82a1470131179288bb48013e33b4fc52 | /pages/campage.cpp | 8849a422a6259955cafc39b2380a792f7a1e97ae | [] | no_license | Abbath/P | d4a11cec7811f279bfafa803ca2524f3eb34cb40 | 06e241f3c839c82afb94e4404f60471b86a309fb | refs/heads/master | 2021-01-13T00:42:44.328434 | 2015-10-30T11:05:02 | 2015-10-30T11:05:02 | 45,244,126 | 0 | 1 | null | 2015-10-30T11:05:02 | 2015-10-30T10:17:32 | C++ | UTF-8 | C++ | false | false | 827 | cpp | #include "campage.hpp"
#include "ui_campage.h"
#include "../modelingwizard.hpp"
/*!
* \brief CamPage::CamPage
* \param parent
*/
CamPage::CamPage(QWidget *parent) :
QWizardPage(parent),
ui(new Ui::CamPage)
{
ui->setupUi(this);
setTitle("Set camera angles");
registerField("CamX", ui->camx);
}
/*!
* \brief CamPage::~CamPage
*/
CamPage::~CamPage()
{
delete ui;
}
/*!
* \brief CamPage::nextId
* \return
*/
int CamPage::nextId() const
{
ModelingWizard * mw = dynamic_cast<ModelingWizard*>(wizard());
mw->getDataRef().setCamx(ui->camx->value() / 57.3);
mw->getDataRef().setCamy(ui->camy->value() / 57.3);
if(ui->groupBox->isChecked()){
mw->getDataRef().setX_angle(ui->x->value() / 57.3);
mw->getDataRef().setY_angle(ui->y->value() / 57.3);
}
return -1;
}
| [
"pitongogi@gmail.com"
] | pitongogi@gmail.com |
132b979b32f7c5ae0f2aa419719537bdaaa307a3 | af542fcd4b2e2651186cb85fc4a33002754d4f17 | /Sorts/main.cpp | cccf52ede61e91f01fc6bc38bcebc110ef7f4dfb | [] | no_license | adamplansky/EFA | 9b435185f7b6243703e6572163e12c1307ac6595 | b48ed0cf49e3822a51a1d4c9f12f44f517dad918 | refs/heads/master | 2021-01-10T21:59:39.263579 | 2013-10-30T14:10:33 | 2013-10-30T14:10:33 | 13,339,901 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,171 | cpp | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
//created by Adam Plánský
//mail: adamplansky@gmail.com / plansada@fit.cvut.cz
using namespace std;
static void Merge(int * A, int * B, int low, int high, int half) {
int i, j, k;
k = i = low;
j = half + 1;
while (1) {
if (i > half) {
while(j<=high)
B[k++] = A[j++];
break;
}
if (j > high) {
while(i <= half){
B[k++] = A[i++];
}
break;
}
if (A[i] <= A[j]) {
B[k++] = A[i++];
continue;
}
if (A[i] > A[j]) {
B[k++] = A[j++];
continue;
}
}
i = low;
for (; i <= high; i++) {
A[i] = B[i];
}
}
static void MergeSort(int * A, int * B, int low, int high) {
if (low < high) {
int half = (low + high) / 2;
MergeSort(A, B, low, half);
MergeSort(A, B, half + 1, high);
Merge(A, B, low, high, half);
}
}
static void swap(int * arr, int left, int right) {
int tmp = arr[left];
arr[left] = arr[right];
arr[right] = tmp;
}
static void swap1(int * arr, int left, int right) {
arr[left] = arr[left] + arr[right];
arr[right] = arr[left] - arr[right];
arr[left] = arr[left] - arr[right];
}
static void swap2(int * arr, int left, int right){
arr[left] = arr[left] ^ arr[right];
arr[right] = arr[left] ^ arr[right];
arr[left] = arr[left] ^ arr[right];
}
static void QuickSort(int * arr, int left, int right) {
int i = left;
int j = right;
int pivot = arr[(i + j) / 2];
while (i <= j) {
while (arr[i] < pivot)
i++;
while (arr[j] > pivot)
j--;
if (i <= j) {
swap(arr, i++, j--);
// i++;
// j--;
}
}
if (left < j)
QuickSort(arr, left, j);
if (i < right)
QuickSort(arr, i, right);
}
//return position
static int binarySearch(int * arr, int key, int left, int right){
int mid = 0;
while(left <= right)
{
mid = (left+right)/2;
if(arr[mid] < key) {
left = arr[mid+1];
} else if(arr[mid] > key){
right = arr[mid-1];
} else {
return mid;
}
}
}
int main(int argc, char** argv) {
int A[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
int B[] = {1, 2, 3, 4};
int C[] = {1, 2, 3, -1};
int D[4];
int key = 1;
cout << binarySearch(A,key,0,19) << endl << endl;
MergeSort(C, D, 0, 3);
for (int a = 0; a < 4; a++) {
cout << a << ": " << C[a] << endl;
}
// QuickSort(C, 0, 3);
//
// for (int a = 0; a < 4; a++) {
// cout << a << ": " << C[a] << endl;
// }
//
// cout << "----------------------" << endl;
// int E[2] = {1, 2};
// for (int a = 0; a < 2; a++) {
// cout << a << ": " << E[a] << endl;
// }
// swap2(E, 0, 1);
// for (int a = 0; a < 2; a++) {
// cout << a << ": " << E[a] << endl;
// }
return 0;
}
| [
"adamplansky@gmail.com"
] | adamplansky@gmail.com |
ec2492d0ae73dec2bcfd9c9d0b8410ac5a80b145 | 86335b6931191122dfbffd7bb5b2c534feae9cc9 | /drake/systems/feedback_system.h | 92a9cace38dc78d32ccc91441af0b5a40a0a0feb | [
"BSD-3-Clause"
] | permissive | mit-gfx/drake | c3c5ac6b98be4a368a4b1ea14a88d1e2615e287c | 12f125d490196af581cf54f2787dd76350f8e95a | refs/heads/master | 2021-01-14T12:56:54.192325 | 2016-04-08T04:23:30 | 2016-04-08T04:23:30 | 53,687,538 | 0 | 1 | null | 2016-03-24T20:59:30 | 2016-03-11T18:18:28 | C++ | UTF-8 | C++ | false | false | 5,402 | h | #ifndef DRAKE_SYSTEMS_FEEDBACK_SYSTEM_H_
#define DRAKE_SYSTEMS_FEEDBACK_SYSTEM_H_
#include <memory>
#include "drake/core/Core.h"
#include "drake/systems/System.h"
namespace Drake {
/** FeedbackSystem<System1,System2>
* @brief Builds a new system from the feedback connection of two simpler
* systems
* @concept{system_concept}
*
* 
*
*/
template <class System1, class System2>
class FeedbackSystem {
public:
template <typename ScalarType>
using StateVector1 = typename System1::template StateVector<ScalarType>;
template <typename ScalarType>
using StateVector2 = typename System2::template StateVector<ScalarType>;
template <typename ScalarType>
using StateVector = typename CombinedVectorUtil<
System1::template StateVector,
System2::template StateVector>::template type<ScalarType>;
template <typename ScalarType>
using InputVector = typename System1::template InputVector<ScalarType>;
template <typename ScalarType>
using OutputVector = typename System1::template OutputVector<ScalarType>;
typedef CombinedVectorUtil<StateVector1, StateVector2> util;
typedef std::shared_ptr<System1> System1Ptr;
typedef std::shared_ptr<System2> System2Ptr;
static_assert(
std::is_same<typename System1::template OutputVector<double>,
typename System2::template InputVector<double>>::value,
"System 2 input vector must match System 1 output vector");
static_assert(
std::is_same<typename System2::template OutputVector<double>,
typename System1::template InputVector<double>>::value,
"System 1 input vector must match System 2 output vector");
FeedbackSystem(const System1Ptr& _sys1, const System2Ptr& _sys2)
: sys1(_sys1), sys2(_sys2) {}
template <typename ScalarType>
StateVector<ScalarType> dynamics(const ScalarType& t,
const StateVector<ScalarType>& x,
const InputVector<ScalarType>& u) const {
OutputVector<ScalarType> y1;
InputVector<ScalarType> y2;
auto x1 = util::first(x);
auto x2 = util::second(x);
subsystemOutputs(t, x1, x2, u, &y1, &y2);
StateVector<ScalarType> xdot = util::combine(
sys1->dynamics(t, x1, static_cast<InputVector<ScalarType>>(toEigen(y2) +
toEigen(u))),
sys2->dynamics(t, x2, y1));
return xdot;
}
template <typename ScalarType>
OutputVector<ScalarType> output(const ScalarType& t,
const StateVector<ScalarType>& x,
const InputVector<ScalarType>& u) const {
OutputVector<ScalarType> y1;
auto x1 = util::first(x);
if (!sys1->isDirectFeedthrough()) {
y1 = sys1->output(t, x1,
u); // then don't need u+y2 here, u will be ignored
} else {
InputVector<ScalarType> y2;
auto x2 = util::second(x);
y2 = sys2->output(
t, x2, y1); // y1 might be uninitialized junk, but has to be ok
y1 = sys1->output(t, x1, static_cast<InputVector<ScalarType>>(
toEigen(y2) + toEigen(u)));
}
return y1;
}
bool isTimeVarying() const {
return sys1->isTimeVarying() || sys2->isTimeVarying();
}
bool isDirectFeedthrough() const { return sys1->isDirectFeedthrough(); }
size_t getNumStates() const {
return Drake::getNumStates(*sys1) + Drake::getNumStates(*sys2);
}
size_t getNumInputs() const { return Drake::getNumInputs(*sys1); }
size_t getNumOutputs() const { return Drake::getNumOutputs(*sys1); }
const System1Ptr& getSys1() const { return sys1; }
const System2Ptr& getSys2() const { return sys2; }
friend StateVector<double> getInitialState(
const FeedbackSystem<System1, System2>& sys) {
return util::combine(getInitialState(*(sys.sys1)),
getInitialState(*(sys.sys2)));
}
private:
template <typename ScalarType>
void subsystemOutputs(const ScalarType& t, const StateVector1<ScalarType>& x1,
const StateVector2<ScalarType>& x2,
const InputVector<ScalarType>& u,
OutputVector<ScalarType>* y1,
InputVector<ScalarType>* y2) const {
if (!sys1->isDirectFeedthrough()) {
*y1 = sys1->output(t, x1, u); // output does not depend on u (so it's ok
// that we're not passing u+y2)
*y2 = sys2->output(t, x2, *y1);
} else {
*y2 = sys2->output(
t, x2, *y1); // y1 might be uninitialized junk, but has to be ok
*y1 = sys1->output(t, x1, static_cast<InputVector<ScalarType>>(
toEigen(*y2) + toEigen(u)));
}
}
System1Ptr sys1;
System2Ptr sys2;
};
/** feedback(sys1, sys2)
* @brief Convenience method to create a feedback combination of two systems
* @ingroup modeling
*/
template <typename System1, typename System2>
std::shared_ptr<FeedbackSystem<System1, System2>> feedback(
const std::shared_ptr<System1>& sys1,
const std::shared_ptr<System2>& sys2) {
return std::make_shared<FeedbackSystem<System1, System2>>(sys1, sys2);
}
} // namespace Drake
#endif // DRAKE_SYSTEMS_FEEDBACK_SYSTEM_H_
| [
"david.german@tri.global"
] | david.german@tri.global |
91f3a592db9b273f91eefc096baa6dd1d3e08117 | 8cc308764bf49ce8fc79f968e0cb9f9f4a65d28d | /FALL 2020/CSE 201/src/inheritence/inheritence_II/Shape.h | 8bc833d8863386616507457875242a978bd5d78b | [] | no_license | SatyakiDas/ulab_course_materials | 3ca19497bee4c8ee4b34f7daf83553d476e5c076 | 9a2d3bcc05affcdf0bfccb6a9e8ba544e4d91d11 | refs/heads/master | 2021-06-26T00:48:35.290102 | 2021-03-10T19:47:30 | 2021-03-10T19:47:30 | 219,327,714 | 1 | 1 | null | 2020-02-12T16:01:54 | 2019-11-03T16:08:43 | C | UTF-8 | C++ | false | false | 259 | h | #ifndef SHAPE_H
#define SHAPE_H
class Shape
{
public:
void setWidth(int w)
{
width = w;
}
void setHeight(int h)
{
height = h;
}
protected:
int width;
int height;
};
#endif // SHAPE_H
| [
"satyakidaslesnar@gmail.com"
] | satyakidaslesnar@gmail.com |
06bc9318877e240a0fe3803b2fbeb187d1a3de70 | 54712055a7718fce947a5436733f7c38a4ed0edd | /sources/OpenDialog/OpenFileState.cpp | 3d8786d233c4f84b503dfb478b993e5ab0480677 | [
"MIT"
] | permissive | podgorskiy/TinyFEM | 05e5b4e771c1d9488a750219b811d8b8c15d3d61 | c1a5fedf21e6306fc11fa19afdaf48dab1b6740f | refs/heads/master | 2016-09-08T01:38:44.224860 | 2015-10-27T12:16:53 | 2015-10-27T12:16:53 | 39,758,930 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 896 | cpp | #include "OpenFileState.h"
#include "OpenDialog.h"
OpenFileState::OpenFileState(){};
void OpenFileState::SaveFile(bool as)
{
if (IsSomeFileOpened() && !as)
{
//save file
}
else
{
OpenSaveFileDialog od;
od.CreateOpenFileDialog("Input file (*.inp)|*.inp||", true);
if (od.OpenSucceeded())
{
m_openedFile = od.GetFileName();
printf("Saving file: %s\n", od.GetFileName().c_str());
}
}
}
bool OpenFileState::OpenFile()
{
OpenSaveFileDialog od;
od.CreateOpenFileDialog("Input file (*.inp)|*.inp||", false);
if (od.OpenSucceeded())
{
m_openedFile = od.GetFileName();
printf("Opening file: %s\n", od.GetFileName().c_str());
return true;
}
return false;
}
void OpenFileState::CloseFile()
{
//close
m_openedFile = "";
}
std::string OpenFileState::GetFileName()
{
return m_openedFile;
}
bool OpenFileState::IsSomeFileOpened()
{
return !(m_openedFile == "");
}
| [
"stanislav@podgorskiy.com"
] | stanislav@podgorskiy.com |
994d6134e3bae3c95d37d2b682a9a078c0b10ba8 | c4675ff57cc727fd4dfdb56759a14a9fb8cf040b | /myzoomer.cpp | b81a5dd842a67e3af761ab169d3195d725914a66 | [] | no_license | sanlav89/signalmonitor | f5caa03574e42e5c819ae8e7d94c981dd4e7afb4 | 3c46e20ee329746461f8a82d8fac8a38a99a95b9 | refs/heads/master | 2023-08-22T17:06:15.473806 | 2021-10-18T12:59:52 | 2021-10-18T12:59:52 | 416,745,806 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,229 | cpp | #include "myzoomer.h"
#include <qwt_plot.h>
#include <qwt_scale_div.h>
MyZoomer::MyZoomer(
QWidget *canvas,
bool doReplot
) :
QwtPlotZoomer(canvas, doReplot)
{
}
void MyZoomer::rescale()
{
QwtPlot *plt = plot();
if ( !plt ) {
return;
}
const QRectF &rect = zoomStack()[zoomRectIndex()];
if ( rect != scaleRect() ) {
const bool doReplot = plt->autoReplot();
plt->setAutoReplot( false );
double xmin = plt->axisScaleDiv(QwtPlot::xBottom).lowerBound();
double xmax = plt->axisScaleDiv(QwtPlot::xBottom).upperBound();
double x1 = rect.left();
double x2 = rect.right();
if (x1 < xmin) {
x1 = xmin;
}
if (x2 > xmax) {
x2 = xmax;
}
if ( !plt->axisScaleDiv( xAxis() ).isIncreasing() ) {
qSwap( x1, x2 );
}
plt->setAxisScale( xAxis(), x1, x2 );
double y1 = rect.top();
double y2 = rect.bottom();
if ( !plt->axisScaleDiv( yAxis() ).isIncreasing() ) {
qSwap( y1, y2 );
}
plt->setAxisScale( yAxis(), y1, y2 );
plt->setAutoReplot( doReplot );
plt->replot();
}
}
| [
"sanlav89@mail.ru"
] | sanlav89@mail.ru |
5a0b38e3aa3081850c378be00a60c4eac41b2809 | 49f88ff91aa582e1a9d5ae5a7014f5c07eab7503 | /gen/services/device/public/mojom/wake_lock_provider.mojom-shared.h | 0f3fe366dcd3926373618b5fcf04c43eedb93ea9 | [] | no_license | AoEiuV020/kiwibrowser-arm64 | b6c719b5f35d65906ae08503ec32f6775c9bb048 | ae7383776e0978b945e85e54242b4e3f7b930284 | refs/heads/main | 2023-06-01T21:09:33.928929 | 2021-06-22T15:56:53 | 2021-06-22T15:56:53 | 379,186,747 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,357 | h | // Copyright 2016 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 SERVICES_DEVICE_PUBLIC_MOJOM_WAKE_LOCK_PROVIDER_MOJOM_SHARED_H_
#define SERVICES_DEVICE_PUBLIC_MOJOM_WAKE_LOCK_PROVIDER_MOJOM_SHARED_H_
#include <stdint.h>
#include <functional>
#include <ostream>
#include <type_traits>
#include <utility>
#include "base/compiler_specific.h"
#include "base/containers/flat_map.h"
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/interface_data_view.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "services/device/public/mojom/wake_lock_provider.mojom-shared-internal.h"
#include "services/device/public/mojom/wake_lock_context.mojom-shared.h"
#include "services/device/public/mojom/wake_lock.mojom-shared.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization.h"
#include "mojo/public/cpp/bindings/native_enum.h"
#include "mojo/public/cpp/bindings/lib/native_struct_serialization.h"
namespace device {
namespace mojom {
} // namespace mojom
} // namespace device
namespace mojo {
namespace internal {
} // namespace internal
} // namespace mojo
namespace device {
namespace mojom {
// Interface base classes. They are used for type safety check.
class WakeLockProviderInterfaceBase {};
using WakeLockProviderPtrDataView =
mojo::InterfacePtrDataView<WakeLockProviderInterfaceBase>;
using WakeLockProviderRequestDataView =
mojo::InterfaceRequestDataView<WakeLockProviderInterfaceBase>;
using WakeLockProviderAssociatedPtrInfoDataView =
mojo::AssociatedInterfacePtrInfoDataView<WakeLockProviderInterfaceBase>;
using WakeLockProviderAssociatedRequestDataView =
mojo::AssociatedInterfaceRequestDataView<WakeLockProviderInterfaceBase>;
class WakeLockProvider_GetWakeLockContextForID_ParamsDataView {
public:
WakeLockProvider_GetWakeLockContextForID_ParamsDataView() {}
WakeLockProvider_GetWakeLockContextForID_ParamsDataView(
internal::WakeLockProvider_GetWakeLockContextForID_Params_Data* data,
mojo::internal::SerializationContext* context)
: data_(data), context_(context) {}
bool is_null() const { return !data_; }
int32_t context_id() const {
return data_->context_id;
}
template <typename UserType>
UserType TakeContext() {
UserType result;
bool ret =
mojo::internal::Deserialize<::device::mojom::WakeLockContextRequestDataView>(
&data_->context, &result, context_);
DCHECK(ret);
return result;
}
private:
internal::WakeLockProvider_GetWakeLockContextForID_Params_Data* data_ = nullptr;
mojo::internal::SerializationContext* context_ = nullptr;
};
class WakeLockProvider_GetWakeLockWithoutContext_ParamsDataView {
public:
WakeLockProvider_GetWakeLockWithoutContext_ParamsDataView() {}
WakeLockProvider_GetWakeLockWithoutContext_ParamsDataView(
internal::WakeLockProvider_GetWakeLockWithoutContext_Params_Data* data,
mojo::internal::SerializationContext* context)
: data_(data), context_(context) {}
bool is_null() const { return !data_; }
template <typename UserType>
WARN_UNUSED_RESULT bool ReadType(UserType* output) const {
auto data_value = data_->type;
return mojo::internal::Deserialize<::device::mojom::WakeLockType>(
data_value, output);
}
::device::mojom::WakeLockType type() const {
return static_cast<::device::mojom::WakeLockType>(data_->type);
}
template <typename UserType>
WARN_UNUSED_RESULT bool ReadReason(UserType* output) const {
auto data_value = data_->reason;
return mojo::internal::Deserialize<::device::mojom::WakeLockReason>(
data_value, output);
}
::device::mojom::WakeLockReason reason() const {
return static_cast<::device::mojom::WakeLockReason>(data_->reason);
}
inline void GetDescriptionDataView(
mojo::StringDataView* output);
template <typename UserType>
WARN_UNUSED_RESULT bool ReadDescription(UserType* output) {
auto* pointer = data_->description.Get();
return mojo::internal::Deserialize<mojo::StringDataView>(
pointer, output, context_);
}
template <typename UserType>
UserType TakeWakeLock() {
UserType result;
bool ret =
mojo::internal::Deserialize<::device::mojom::WakeLockRequestDataView>(
&data_->wake_lock, &result, context_);
DCHECK(ret);
return result;
}
private:
internal::WakeLockProvider_GetWakeLockWithoutContext_Params_Data* data_ = nullptr;
mojo::internal::SerializationContext* context_ = nullptr;
};
} // namespace mojom
} // namespace device
namespace std {
} // namespace std
namespace mojo {
} // namespace mojo
namespace device {
namespace mojom {
inline void WakeLockProvider_GetWakeLockWithoutContext_ParamsDataView::GetDescriptionDataView(
mojo::StringDataView* output) {
auto pointer = data_->description.Get();
*output = mojo::StringDataView(pointer, context_);
}
} // namespace mojom
} // namespace device
#endif // SERVICES_DEVICE_PUBLIC_MOJOM_WAKE_LOCK_PROVIDER_MOJOM_SHARED_H_
| [
"aoeiuv020@gmail.com"
] | aoeiuv020@gmail.com |
6cffe80fadced82ef75c1f15db668bf180dd93b1 | 3df3cb75557e76fec1e12eb4e9ba3432be335131 | /example/zsummer_server/header.h | b8da361d9b047a6ee6866444ae737edae8c1e3ce | [
"MIT"
] | permissive | byteman/zsummer | 8fa5ed0229fadea3a48fb8b930b68d2c612b470e | c29b198b7465aa72b234ffdd03a9a280695b9825 | refs/heads/master | 2021-01-17T14:28:23.977588 | 2013-10-19T17:32:49 | 2013-10-19T17:32:49 | 14,034,918 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,635 | h | /*
* ZSUMMER License
* -----------
*
* ZSUMMER is licensed under the terms of the MIT license reproduced below.
* This means that ZSUMMER is free software and can be used for both academic
* and commercial purposes at absolutely no cost.
*
*
* ===============================================================================
*
* Copyright (C) 2010-2013 YaweiZhang <yawei_zhang@foxmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* ===============================================================================
*
* (end of COPYRIGHT)
*/
//! zsummer的测试服务模块(对应zsummer底层网络封装的上层设计测试服务) 可视为服务端架构中的 gateway服务/agent服务/前端服务, 特点是高并发高吞吐量
//! 公共头文件
#ifndef ZSUMMER_HEADER_H_
#define ZSUMMER_HEADER_H_
#include "../../utility/utility.h"
#include "../../depends/thread4z/thread.h"
#include "../../depends/log4z/log4z.h"
#include "../../network/SocketInterface.h"
#include "../../depends/protocol4z/protocol4z.h"
#include <iostream>
#include <queue>
#include <iomanip>
#include <string.h>
#include <signal.h>
using namespace std;
using namespace zsummer::utility;
using namespace zsummer::thread4z;
using namespace zsummer::network;
//! 消息包缓冲区大小
#define _MSG_BUF_LEN (8*1024)
//! 消息包
struct Packet
{
unsigned short _len;
char _orgdata[_MSG_BUF_LEN];
};
//! 服务端总连入连接数和总关闭连接数
extern int g_nTotalLinked;
extern int g_nTotalCloesed; //! 多线程下使用 所有写操作必须为原子操作
#endif
| [
"yawei_zhang@foxmail.com"
] | yawei_zhang@foxmail.com |
0b94b8fe680805d52ed25bd1205e9487144681b8 | 98467a490e745fbf6d49c8427954e6c4481e32da | /include/io.h | 6495828e405d5c4bbf7389158c5bf1738dec1f59 | [] | no_license | elucent/collections | a6d62ed3d57f7900c1f53bebe6342cc17d9d210d | 18f6ebbe48244cf2bdc6f6fa3d1be4332491c42e | refs/heads/master | 2022-11-23T20:11:16.744196 | 2020-07-27T08:48:57 | 2020-07-27T08:48:57 | 282,843,196 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,910 | h | #ifndef BASIL_IO_H
#define BASIL_IO_H
#include "defs.h"
#include "stdio.h"
class stream {
public:
virtual void write(u8 c) = 0;
virtual u8 read() = 0;
virtual u8 peek() const = 0;
virtual void unget(u8 c) = 0;
virtual operator bool() const = 0;
};
bool exists(const char* path);
class file : public stream {
FILE* f;
bool done;
public:
file(const char* fname, const char* flags);
file(FILE* f_in);
~file();
file(const file& other) = delete;
file& operator=(const file& other) = delete;
void write(u8 c) override;
u8 read() override;
u8 peek() const override;
void unget(u8 c) override;
operator bool() const override;
};
class buffer : public stream {
u8* data;
u32 _start, _end, _capacity;
u8 buf[8];
void init(u32 size);
void free();
void copy(u8* other, u32 size, u32 start, u32 end);
void grow();
public:
buffer();
~buffer();
buffer(const buffer& other);
buffer& operator=(const buffer& other);
void write(u8 c) override;
u8 read() override;
u8 peek() const override;
void unget(u8 c) override;
u32 size() const;
u32 capacity() const;
operator bool() const override;
u8* begin();
const u8* begin() const;
u8* end();
const u8* end() const;
};
extern stream &_stdin, &_stdout;
void setprecision(u32 p);
void write(stream& io, u8 c);
void write(stream& io, u16 n);
void write(stream& io, u32 n);
void write(stream& io, u64 n);
void write(stream& io, i8 c);
void write(stream& io, i16 n);
void write(stream& io, i32 n);
void write(stream& io, i64 n);
void write(stream& io, float f);
void write(stream& io, double d);
void write(stream& io, char c);
void write(stream& io, bool b);
void write(stream& io, const u8* s);
void write(stream& io, const char* s);
void write(stream& io, const buffer& b);
template<typename... Args>
void print(const Args&... args) {
write(_stdout, args...);
}
template<typename T, typename... Args>
void write(stream& s, const T& t, const Args&... args) {
write(s, t);
write(s, args...);
}
template<typename... Args>
void println(const Args&... args) {
writeln(_stdout, args...);
}
template<typename... Args>
void writeln(stream& s, const Args&... args) {
write(s, args...);
write(s, '\n');
}
bool isspace(u8 c);
void read(stream& io, u8& c);
void read(stream& io, u16& n);
void read(stream& io, u32& n);
void read(stream& io, u64& n);
void read(stream& io, i8& c);
void read(stream& io, i16& n);
void read(stream& io, i32& n);
void read(stream& io, i64& n);
void read(stream& io, float& f);
void read(stream& io, double& d);
void read(stream& io, char& c);
void read(stream& io, bool& b);
void read(stream& io, u8* s);
void read(stream& io, char* s);
template<typename T, typename... Args>
void read(stream& io, T& t, Args&... args) {
read(io, t);
read(io, args...);
}
#endif | [
"elucent@users.noreply.github.com"
] | elucent@users.noreply.github.com |
d7ccf6df9696cadf180b816229849e7033b3aa82 | ca4692eb630702ec3ff206c82d0578e55bd43428 | /Algorithms_DataCollection.h | 66bb991bb488509c499da32d11fc3b46c9b43230 | [] | no_license | kejjon/all-sort-of-operation-with-matrices | 9c5bdfc9e8a931fb27b35a4cea90e92d316db2c1 | 4d93caf1efcbcc5c40e5a20e0506a40feaeaed51 | refs/heads/master | 2020-04-24T20:49:41.048568 | 2019-02-23T20:09:22 | 2019-02-23T20:09:22 | 172,257,128 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,665 | h | #ifndef _ALGORITHMS_h_
#define _ALGORITHMS_h_
// Header for all algorithms used to manipulate the data.
#include "Matrix.h"
#include "SquareMatrix.h"
#include "DiagnalMatrix.h"
#include <iostream>
#include <cassert>
#include <climits>
#include <vector>
#include <string>
using namespace std;
//-------------------------------------------------------------
// MergeSort Algorithm used to sort the Squarematrices in the vector by their determinant value.
//-------------------------------------------------------------
void merge(vector<SquareMatrix<int>*>& D_Collect, vector<SquareMatrix<int>*>& tmpArray, int leftPos, int rightPos, int rightEnd)
{
int leftEnd = rightPos - 1;
int tmpPos = leftPos;
int numElements = rightEnd - leftPos + 1;
while (leftPos <= leftEnd && rightPos <= rightEnd) // Main loop
if (D_Collect[leftPos]->determinant() <= D_Collect[rightPos]->determinant())
tmpArray[tmpPos++] = D_Collect[leftPos++];
else
tmpArray[tmpPos++] = D_Collect[rightPos++];
while (leftPos <= leftEnd) // Copy rest of first half
tmpArray[tmpPos++] = D_Collect[leftPos++];
while (rightPos <= rightEnd) // Copy rest of right half
tmpArray[tmpPos++] = D_Collect[rightPos++];
for (int i = 0; i < numElements; i++, rightEnd--) // Copy tmpArray back
D_Collect[rightEnd] = tmpArray[rightEnd];
}
void mergeSort(vector<SquareMatrix<int>*>& D_Collect, vector<SquareMatrix<int>*>& tmpArray, int left, int right)
{
if (left < right) {
int center = (left + right) / 2;
mergeSort(D_Collect, tmpArray, left, center);
mergeSort(D_Collect, tmpArray, center + 1, right);
merge(D_Collect, tmpArray, left, center + 1, right);
}
}
void mergeSort(vector<SquareMatrix<int>*>& D_Collect)
{
vector<SquareMatrix<int>*> tmpArray(D_Collect.size());
mergeSort(D_Collect, tmpArray, 0, D_Collect.size() - 1);
}
void output_sorting(vector<SquareMatrix<int>*>& a) {
for (int i = 0; i < a.size(); i++)
{
cout << i + 1 << ". " << a[i]->getname() << " ---> " << a[i]->determinant() << endl;
}
cout << endl;
}
//-------------------------------------------------------------
// Quick sort used to order the elements of a matrix(stored in a vector) in ascending order.
//-------------------------------------------------------------
void Quick_Sort(vector <int> & Sample_Vector, int left, int right)
{
if (left >= right)
return;
int pivotValue = Sample_Vector[left], index = left;
swap(Sample_Vector[left], Sample_Vector[right]);
for (int i = left; i < right; i++)
{
if (Sample_Vector[i] < pivotValue)
{
swap(Sample_Vector[i], Sample_Vector[index]);
index += 1;
}
}
swap(Sample_Vector[right], Sample_Vector[index]);
Quick_Sort(Sample_Vector, left, index - 1);
Quick_Sort(Sample_Vector, index + 1, right);
}
void Quick_Sort(vector <int> & Sample_Vector)
{
Quick_Sort(Sample_Vector, 0, Sample_Vector.size() - 1);
}
//-------------------------------------------------------------
// Binary Search is used find a value or entry in a matrix.
//-------------------------------------------------------------
int binary_search(vector <int> & Sample_Vector, int first, int last, int search_key)
{
int index;
if (first > last)
index = -1;
else
{
int mid = (first + last) / 2;
if (search_key == Sample_Vector[mid])
index = mid;
else
if (search_key < Sample_Vector[mid])
index = binary_search(Sample_Vector, first, mid - 1, search_key);
else
index = binary_search(Sample_Vector, mid + 1, last, search_key);
} // end if
return index;
}// end binarySearch
int binary_search(vector <int> & Sample_Vector, int key) {
return binary_search(Sample_Vector, 0, Sample_Vector.size() - 1, key);
}
#endif //Algorithms
| [
"kejsi.rona@gmail.com"
] | kejsi.rona@gmail.com |
ba56d8de6b65986cf8c34f25113710a1e6b38093 | 03c2b8fe97f7b2cf14e6392288bbff4ec8f973c9 | /Lab/Lab08/src/LocationContent.h | bb0b48f6c6f95d51afc90979a00e6283d82bf501 | [] | no_license | Chuncheonian/DataStructure | c6e69d6a05f6def688b1b8d2e3c308de2902b3af | 63467b6ffe2a8e5b392b50c64fdc83df179bdebb | refs/heads/main | 2023-01-23T19:27:08.304820 | 2020-12-04T11:25:11 | 2020-12-04T11:25:11 | 301,158,430 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,101 | h | #pragma once
#include <iostream>
#include <string>
using namespace std;
#include "MultimediaContent.h"
#include "SortedList.h"
#include "SortedSinglyLinkedList.h"
#include "BinarySearchTree.h"
/**
* Location information class.
*/
class LocationContent{
protected:
string m_location; // Location Name (Primary KEY)
int m_numOfCreateTime; // Number of CreateTime with same location name.
SortedSinglyLinkedList<string> m_createTimeList; // createTime(Primary Key of MC) List with same location.
public:
/**
* default constructor.
*/
LocationContent() {
m_location = "";
m_numOfCreateTime = 0;
}
/**
* default destructor.
*/
~LocationContent() {
}
/**
* @brief Get location name.
* @pre Location name is set.
* @post None.
* @return Location name.
*/
string GetName() { return m_location; }
/**
* @brief Get number of CreateTime.
* @pre Number of CreateTime.
* @post None.
* @return Number of CreateTime.
*/
int GetCount() { return m_numOfCreateTime; }
/**
* @brief Set location name.
* @pre None.
* @post Location name is set.
* @param _location Location name.
*/
void SetName(string _location) { m_location = _location; }
/**
* @brief Set number of CreateTime.
* @pre None.
* @post Number of CreateTime.
* @param _numOfCreateTime Number of CreateTime.
*/
void SetCount(int _numOfCreateTime) { m_numOfCreateTime = _numOfCreateTime; }
/**
* @brief Set location record.
* @pre None.
* @post Location record is set.
* @param _location location name.
* @param _numOfCreateTime Number of CreateTime.
*/
void SetRecord(string _location, int _numOfCreateTime) {
SetName(_location);
SetCount(_numOfCreateTime);
}
/**
* @brief Display location name on screen.
* @pre Location name is set.
* @post Location name is on screen.
*/
void DisplayNameOnScreen() { cout << "\tName : " << m_location; }
/**
* @brief Display number of CreateTime.
* @pre Number of CreateTime is set.
* @post Number of CreateTime is on screen.
*/
void DisplayCountOnScreen() { cout << "\tNumber of CreateTime with same location : " << m_numOfCreateTime; }
/**
* @brief Display an location record on screen.
* @pre Location record is set.
* @post Location record is on screen.
*/
void DisplayRecordOnScreen() {
DisplayNameOnScreen();
DisplayCountOnScreen();
DisplayAllCreateTime();
cout << endl;
}
/**
* @brief Set location name from keyboard.
* @pre None.
* @post Location name is set.
*/
void SetNameFromKB();
/**
* @brief Set number of CreateTime.
* @pre None.
* @post Number of CreateTime.
*/
void SetCountFromKB();
/**
* @brief Set location record from keyboard.
* @pre None.
* @post location record is set.
*/
void SetRecordFromKB();
/**
* @brief Add new CreateTime into list.
* @pre List should be initialized.
* @post New record is added into the list and Number of CreateTime increases by one.
*/
void AddCreateTime(string _createTime);
/**
* @brief Delete CreateTime into list.
* @pre List should be not empty.
* @post Record is deleted into the list. and Number of CreateTime decreases by one.
* @return 1 if this function works well, otherwise 0.
*/
int DeleteCreateTime(string _createTime);
/**
* @brief Display all elements in the CreateTime List on screen.
* @pre None.
* @post None.
*/
void DisplayAllCreateTime();
/**
* @brief Bring masterlist as pass by reference and Display detail MultimediaContent records.
* @pre Exist location name.
* @post None.
*/
void SearchAtMasterList(BinarySearchTree<MultimediaContent>& _masterList);
/**
* @brief Compare two LocationContent by location name.
* @pre Two LocationContent should be initialized.
* @param _location target location for comparing.
* @return return 1 if this.location > data.location, 0 if not.
*/
bool operator>(LocationContent& _location);
/**
* @brief Compare two LocationContent by location name.
* @pre Two LocationContent should be initialized.
* @param _location target location for comparing.
* @return return 1 if this.location < data.location, 0 if not.
*/
bool operator<(LocationContent& _location);
/**
* @brief Compare two LocationContent by location name.
* @pre Two LocationContent should be initialized.
* @param _location target location for comparing.
* @return return 1 if this.location == data.location, 0 if not.
*/
bool operator==(LocationContent& _location);
/**
* @brief Print record.
* @pre LocationContent class should be initialized.
* @post content record is on screen.
* @param cout ostream instance
* @param _event target LocationContent for printing.
*/
friend ostream& operator<<(ostream& cout, LocationContent& _location) {
cout << "\t[ Location name: " << _location.m_location;
cout << ", Number of CreateTime with same character: " << _location.m_numOfCreateTime;
cout << ", ";
_location.DisplayAllCreateTime();
cout << "]";
return cout;
}
}; | [
"ehddud2468@khu.ac.kr"
] | ehddud2468@khu.ac.kr |
26537c9c37583a5f7ebd8c19c9eb820a84fdfe7d | 4b0a48044ebc997336c4782ac2eb263515362d52 | /network/wlan/WDI/PLATFORM/NDIS6/new.cpp | 5b7eaf2ba85304538bc652084661cb9c52ea3619 | [
"MS-PL"
] | permissive | girishpattabiraman/Windows-driver-samples | 9aadb39ce58eac479a37d7842b98705b67250a32 | 95d7bd3a57d1ff88351e1c5a55847d65c86d5686 | refs/heads/master | 2021-07-04T04:39:46.192881 | 2021-06-03T18:06:34 | 2021-06-03T18:06:34 | 79,270,183 | 2 | 0 | MS-PL | 2018-11-14T22:45:15 | 2017-01-17T20:46:11 | C | UTF-8 | C++ | false | false | 1,166 | cpp | /*++
Copyright (c) Microsoft Corporation. All rights reserved.
Microsoft Confidential
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.
Module Name:
new.cpp
Abstract:
Test only stub WDI driver (C++ portions)
Environment:
Kernel mode
Author:
--*/
#include "MP_Precomp.h"
#define POOL_TAG ((ULONG) '++CS')
void* __cdecl operator new(
size_t Size,
ULONG_PTR AllocationContext
)
/*++
Override C++ allocation operator. (for use by TLV Parser/Generator)
--*/
{
PVOID pData = ExAllocatePoolWithTag( NonPagedPoolNx, Size, POOL_TAG );
UNREFERENCED_PARAMETER( AllocationContext );
NT_ASSERT( AllocationContext == 0 );
if ( pData != NULL )
{
RtlZeroMemory( pData, Size );
}
return pData;
}
void __cdecl operator delete(
void* pData )
/*++
Override C++ delete operator. (for use by TLV Parser/Generator)
--*/
{
if ( pData != NULL )
{
ExFreePoolWithTag( pData, POOL_TAG );
}
}
| [
"daih@microsoft.com"
] | daih@microsoft.com |
e6bb3b9d3b44c41050652ace0bd819c0665a0085 | 667e6b125e49d9ed12ac200f8c0acc291ac8c182 | /src/objects-inl.h | 12a5741c731217f4e65b166dbf056241348631f2 | [
"bzip2-1.0.6",
"BSD-3-Clause",
"SunPro"
] | permissive | lioshi/v8 | a167435e7e7bcf9946347f9f7a660df4834d76d8 | 247b0d38b2977b998bbdf995d42325072317141d | refs/heads/master | 2021-07-05T04:51:42.688258 | 2017-09-12T12:48:23 | 2017-09-12T13:08:41 | 103,269,303 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 197,914 | 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.
//
// Review notes:
//
// - The use of macros in these inline functions may seem superfluous
// but it is absolutely needed to make sure gcc generates optimal
// code. gcc is not happy when attempting to inline too deep.
//
#ifndef V8_OBJECTS_INL_H_
#define V8_OBJECTS_INL_H_
#include "src/base/atomicops.h"
#include "src/base/bits.h"
#include "src/base/tsan.h"
#include "src/builtins/builtins.h"
#include "src/contexts-inl.h"
#include "src/conversions-inl.h"
#include "src/factory.h"
#include "src/feedback-vector-inl.h"
#include "src/field-index-inl.h"
#include "src/field-type.h"
#include "src/handles-inl.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap.h"
#include "src/isolate-inl.h"
#include "src/isolate.h"
#include "src/keys.h"
#include "src/layout-descriptor-inl.h"
#include "src/lookup-cache-inl.h"
#include "src/lookup.h"
#include "src/objects.h"
#include "src/objects/arguments-inl.h"
#include "src/objects/bigint-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/hash-table.h"
#include "src/objects/literal-objects.h"
#include "src/objects/module-inl.h"
#include "src/objects/regexp-match-info.h"
#include "src/objects/scope-info.h"
#include "src/property.h"
#include "src/prototype.h"
#include "src/transitions-inl.h"
#include "src/v8memory.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
PropertyDetails::PropertyDetails(Smi* smi) {
value_ = smi->value();
}
Smi* PropertyDetails::AsSmi() const {
// Ensure the upper 2 bits have the same value by sign extending it. This is
// necessary to be able to use the 31st bit of the property details.
int value = value_ << 1;
return Smi::FromInt(value >> 1);
}
int PropertyDetails::field_width_in_words() const {
DCHECK(location() == kField);
if (!FLAG_unbox_double_fields) return 1;
if (kDoubleSize == kPointerSize) return 1;
return representation().IsDouble() ? kDoubleSize / kPointerSize : 1;
}
TYPE_CHECKER(BreakPoint, TUPLE2_TYPE)
TYPE_CHECKER(BreakPointInfo, TUPLE2_TYPE)
TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE)
TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE)
TYPE_CHECKER(CallHandlerInfo, TUPLE2_TYPE)
TYPE_CHECKER(Cell, CELL_TYPE)
TYPE_CHECKER(Code, CODE_TYPE)
TYPE_CHECKER(ConstantElementsPair, TUPLE2_TYPE)
TYPE_CHECKER(CoverageInfo, FIXED_ARRAY_TYPE)
TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE)
TYPE_CHECKER(Foreign, FOREIGN_TYPE)
TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE)
TYPE_CHECKER(HashTable, HASH_TABLE_TYPE)
TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
TYPE_CHECKER(JSArrayBuffer, JS_ARRAY_BUFFER_TYPE)
TYPE_CHECKER(JSArray, JS_ARRAY_TYPE)
TYPE_CHECKER(JSAsyncFromSyncIterator, JS_ASYNC_FROM_SYNC_ITERATOR_TYPE)
TYPE_CHECKER(JSAsyncGeneratorObject, JS_ASYNC_GENERATOR_OBJECT_TYPE)
TYPE_CHECKER(JSBoundFunction, JS_BOUND_FUNCTION_TYPE)
TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE)
TYPE_CHECKER(JSDataView, JS_DATA_VIEW_TYPE)
TYPE_CHECKER(JSDate, JS_DATE_TYPE)
TYPE_CHECKER(JSError, JS_ERROR_TYPE)
TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE)
TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE)
TYPE_CHECKER(JSMap, JS_MAP_TYPE)
TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE)
TYPE_CHECKER(JSPromise, JS_PROMISE_TYPE)
TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE)
TYPE_CHECKER(JSSet, JS_SET_TYPE)
TYPE_CHECKER(JSStringIterator, JS_STRING_ITERATOR_TYPE)
TYPE_CHECKER(JSTypedArray, JS_TYPED_ARRAY_TYPE)
TYPE_CHECKER(JSValue, JS_VALUE_TYPE)
TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE)
TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE)
TYPE_CHECKER(Map, MAP_TYPE)
TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE)
TYPE_CHECKER(Oddball, ODDBALL_TYPE)
TYPE_CHECKER(PreParsedScopeData, TUPLE2_TYPE)
TYPE_CHECKER(PropertyArray, PROPERTY_ARRAY_TYPE)
TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE)
TYPE_CHECKER(SmallOrderedHashMap, SMALL_ORDERED_HASH_MAP_TYPE)
TYPE_CHECKER(SmallOrderedHashSet, SMALL_ORDERED_HASH_SET_TYPE)
TYPE_CHECKER(SourcePositionTableWithFrameCache, TUPLE2_TYPE)
TYPE_CHECKER(TransitionArray, TRANSITION_ARRAY_TYPE)
TYPE_CHECKER(TypeFeedbackInfo, TUPLE3_TYPE)
TYPE_CHECKER(WasmInstanceObject, WASM_INSTANCE_TYPE)
TYPE_CHECKER(WasmMemoryObject, WASM_MEMORY_TYPE)
TYPE_CHECKER(WasmModuleObject, WASM_MODULE_TYPE)
TYPE_CHECKER(WasmTableObject, WASM_TABLE_TYPE)
TYPE_CHECKER(WeakCell, WEAK_CELL_TYPE)
TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE)
#define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \
TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE)
TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER)
#undef TYPED_ARRAY_TYPE_CHECKER
bool HeapObject::IsFixedArrayBase() const {
return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
}
bool HeapObject::IsFixedArray() const {
InstanceType instance_type = map()->instance_type();
return instance_type == FIXED_ARRAY_TYPE || instance_type == HASH_TABLE_TYPE;
}
bool HeapObject::IsSloppyArgumentsElements() const { return IsFixedArray(); }
bool HeapObject::IsJSSloppyArgumentsObject() const {
return IsJSArgumentsObject();
}
bool HeapObject::IsJSGeneratorObject() const {
return map()->instance_type() == JS_GENERATOR_OBJECT_TYPE ||
IsJSAsyncGeneratorObject();
}
bool HeapObject::IsBoilerplateDescription() const { return IsFixedArray(); }
bool HeapObject::IsExternal() const {
return map()->FindRootMap() == GetHeap()->external_map();
}
#define IS_TYPE_FUNCTION_DEF(type_) \
bool Object::Is##type_() const { \
return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \
}
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF)
#undef IS_TYPE_FUNCTION_DEF
#define IS_TYPE_FUNCTION_DEF(Type, Value) \
bool Object::Is##Type(Isolate* isolate) const { \
return this == isolate->heap()->Value(); \
} \
bool HeapObject::Is##Type(Isolate* isolate) const { \
return this == isolate->heap()->Value(); \
}
ODDBALL_LIST(IS_TYPE_FUNCTION_DEF)
#undef IS_TYPE_FUNCTION_DEF
bool Object::IsNullOrUndefined(Isolate* isolate) const {
Heap* heap = isolate->heap();
return this == heap->null_value() || this == heap->undefined_value();
}
bool HeapObject::IsNullOrUndefined(Isolate* isolate) const {
Heap* heap = isolate->heap();
return this == heap->null_value() || this == heap->undefined_value();
}
bool HeapObject::IsString() const {
return map()->instance_type() < FIRST_NONSTRING_TYPE;
}
bool HeapObject::IsName() const {
return map()->instance_type() <= LAST_NAME_TYPE;
}
bool HeapObject::IsUniqueName() const {
return IsInternalizedString() || IsSymbol();
}
bool HeapObject::IsFunction() const {
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
return map()->instance_type() >= FIRST_FUNCTION_TYPE;
}
bool HeapObject::IsCallable() const { return map()->is_callable(); }
bool HeapObject::IsConstructor() const { return map()->is_constructor(); }
bool HeapObject::IsTemplateInfo() const {
return IsObjectTemplateInfo() || IsFunctionTemplateInfo();
}
bool HeapObject::IsInternalizedString() const {
uint32_t type = map()->instance_type();
STATIC_ASSERT(kNotInternalizedTag != 0);
return (type & (kIsNotStringMask | kIsNotInternalizedMask)) ==
(kStringTag | kInternalizedTag);
}
bool HeapObject::IsConsString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsCons();
}
bool HeapObject::IsThinString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsThin();
}
bool HeapObject::IsSlicedString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsSliced();
}
bool HeapObject::IsSeqString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsSequential();
}
bool HeapObject::IsSeqOneByteString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsSequential() &&
String::cast(this)->IsOneByteRepresentation();
}
bool HeapObject::IsSeqTwoByteString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsSequential() &&
String::cast(this)->IsTwoByteRepresentation();
}
bool HeapObject::IsExternalString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsExternal();
}
bool HeapObject::IsExternalOneByteString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsExternal() &&
String::cast(this)->IsOneByteRepresentation();
}
bool HeapObject::IsExternalTwoByteString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsExternal() &&
String::cast(this)->IsTwoByteRepresentation();
}
bool Object::IsNumber() const { return IsSmi() || IsHeapNumber(); }
bool HeapObject::IsFiller() const {
InstanceType instance_type = map()->instance_type();
return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
}
bool HeapObject::IsFixedTypedArrayBase() const {
InstanceType instance_type = map()->instance_type();
return (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE &&
instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE);
}
bool HeapObject::IsJSReceiver() const {
STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
return map()->instance_type() >= FIRST_JS_RECEIVER_TYPE;
}
bool HeapObject::IsJSObject() const {
STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
return map()->IsJSObjectMap();
}
bool HeapObject::IsJSProxy() const { return map()->IsJSProxyMap(); }
bool HeapObject::IsJSMapIterator() const {
InstanceType instance_type = map()->instance_type();
return (instance_type >= JS_MAP_KEY_ITERATOR_TYPE &&
instance_type <= JS_MAP_VALUE_ITERATOR_TYPE);
}
bool HeapObject::IsJSSetIterator() const {
InstanceType instance_type = map()->instance_type();
return (instance_type == JS_SET_VALUE_ITERATOR_TYPE ||
instance_type == JS_SET_KEY_VALUE_ITERATOR_TYPE);
}
bool HeapObject::IsJSArrayIterator() const {
InstanceType instance_type = map()->instance_type();
return (instance_type >= FIRST_ARRAY_ITERATOR_TYPE &&
instance_type <= LAST_ARRAY_ITERATOR_TYPE);
}
bool HeapObject::IsJSWeakCollection() const {
return IsJSWeakMap() || IsJSWeakSet();
}
bool HeapObject::IsJSCollection() const { return IsJSMap() || IsJSSet(); }
bool HeapObject::IsDescriptorArray() const { return IsFixedArray(); }
bool HeapObject::IsEnumCache() const { return IsTuple2(); }
bool HeapObject::IsFrameArray() const { return IsFixedArray(); }
bool HeapObject::IsArrayList() const { return IsFixedArray(); }
bool HeapObject::IsRegExpMatchInfo() const { return IsFixedArray(); }
bool Object::IsLayoutDescriptor() const { return IsSmi() || IsByteArray(); }
bool HeapObject::IsFeedbackVector() const {
return map() == GetHeap()->feedback_vector_map();
}
bool HeapObject::IsFeedbackMetadata() const { return IsFixedArray(); }
bool HeapObject::IsDeoptimizationInputData() const {
// Must be a fixed array.
if (!IsFixedArray()) return false;
// There's no sure way to detect the difference between a fixed array and
// a deoptimization data array. Since this is used for asserts we can
// check that the length is zero or else the fixed size plus a multiple of
// the entry size.
int length = FixedArray::cast(this)->length();
if (length == 0) return true;
length -= DeoptimizationInputData::kFirstDeoptEntryIndex;
return length >= 0 && length % DeoptimizationInputData::kDeoptEntrySize == 0;
}
bool HeapObject::IsHandlerTable() const {
if (!IsFixedArray()) return false;
// There's actually no way to see the difference between a fixed array and
// a handler table array.
return true;
}
bool HeapObject::IsTemplateList() const {
if (!IsFixedArray()) return false;
// There's actually no way to see the difference between a fixed array and
// a template list.
if (FixedArray::cast(this)->length() < 1) return false;
return true;
}
bool HeapObject::IsDependentCode() const {
if (!IsFixedArray()) return false;
// There's actually no way to see the difference between a fixed array and
// a dependent codes array.
return true;
}
bool HeapObject::IsContext() const {
Map* map = this->map();
Heap* heap = GetHeap();
return (
map == heap->function_context_map() || map == heap->catch_context_map() ||
map == heap->with_context_map() || map == heap->native_context_map() ||
map == heap->block_context_map() || map == heap->module_context_map() ||
map == heap->eval_context_map() || map == heap->script_context_map() ||
map == heap->debug_evaluate_context_map());
}
bool HeapObject::IsNativeContext() const {
return map() == GetHeap()->native_context_map();
}
bool HeapObject::IsScriptContextTable() const {
return map() == GetHeap()->script_context_table_map();
}
bool HeapObject::IsScopeInfo() const {
return map() == GetHeap()->scope_info_map();
}
template <>
inline bool Is<JSFunction>(Object* obj) {
return obj->IsJSFunction();
}
bool HeapObject::IsAbstractCode() const {
return IsBytecodeArray() || IsCode();
}
bool HeapObject::IsStringWrapper() const {
return IsJSValue() && JSValue::cast(this)->value()->IsString();
}
bool HeapObject::IsBoolean() const {
return IsOddball() &&
((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0);
}
bool HeapObject::IsJSArrayBufferView() const {
return IsJSDataView() || IsJSTypedArray();
}
template <>
inline bool Is<JSArray>(Object* obj) {
return obj->IsJSArray();
}
bool HeapObject::IsWeakHashTable() const { return IsHashTable(); }
bool HeapObject::IsDictionary() const {
return IsHashTable() && this != GetHeap()->string_table();
}
bool Object::IsNameDictionary() const { return IsDictionary(); }
bool Object::IsGlobalDictionary() const { return IsDictionary(); }
bool Object::IsSeededNumberDictionary() const { return IsDictionary(); }
bool HeapObject::IsUnseededNumberDictionary() const {
return map() == GetHeap()->unseeded_number_dictionary_map();
}
bool HeapObject::IsStringTable() const { return IsHashTable(); }
bool HeapObject::IsStringSet() const { return IsHashTable(); }
bool HeapObject::IsObjectHashSet() const { return IsHashTable(); }
bool HeapObject::IsNormalizedMapCache() const {
return NormalizedMapCache::IsNormalizedMapCache(this);
}
bool HeapObject::IsCompilationCacheTable() const { return IsHashTable(); }
bool HeapObject::IsCodeCacheHashTable() const { return IsHashTable(); }
bool HeapObject::IsMapCache() const { return IsHashTable(); }
bool HeapObject::IsObjectHashTable() const { return IsHashTable(); }
bool HeapObject::IsOrderedHashTable() const {
return map() == GetHeap()->ordered_hash_table_map();
}
bool Object::IsOrderedHashSet() const { return IsOrderedHashTable(); }
bool Object::IsOrderedHashMap() const { return IsOrderedHashTable(); }
bool Object::IsSmallOrderedHashTable() const {
return IsSmallOrderedHashSet() || IsSmallOrderedHashMap();
}
bool Object::IsPrimitive() const {
return IsSmi() || HeapObject::cast(this)->map()->IsPrimitiveMap();
}
// static
Maybe<bool> Object::IsArray(Handle<Object> object) {
if (object->IsSmi()) return Just(false);
Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object);
if (heap_object->IsJSArray()) return Just(true);
if (!heap_object->IsJSProxy()) return Just(false);
return JSProxy::IsArray(Handle<JSProxy>::cast(object));
}
bool HeapObject::IsJSGlobalProxy() const {
bool result = map()->instance_type() == JS_GLOBAL_PROXY_TYPE;
DCHECK(!result || map()->is_access_check_needed());
return result;
}
bool HeapObject::IsUndetectable() const { return map()->is_undetectable(); }
bool HeapObject::IsAccessCheckNeeded() const {
if (IsJSGlobalProxy()) {
const JSGlobalProxy* proxy = JSGlobalProxy::cast(this);
JSGlobalObject* global = proxy->GetIsolate()->context()->global_object();
return proxy->IsDetachedFrom(global);
}
return map()->is_access_check_needed();
}
bool HeapObject::IsStruct() const {
switch (map()->instance_type()) {
#define MAKE_STRUCT_CASE(NAME, Name, name) \
case NAME##_TYPE: \
return true;
STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE
default:
return false;
}
}
#define MAKE_STRUCT_PREDICATE(NAME, Name, name) \
bool Object::Is##Name() const { \
return IsHeapObject() && HeapObject::cast(this)->Is##Name(); \
} \
bool HeapObject::Is##Name() const { \
return map()->instance_type() == NAME##_TYPE; \
}
STRUCT_LIST(MAKE_STRUCT_PREDICATE)
#undef MAKE_STRUCT_PREDICATE
double Object::Number() const {
DCHECK(IsNumber());
return IsSmi()
? static_cast<double>(reinterpret_cast<const Smi*>(this)->value())
: reinterpret_cast<const HeapNumber*>(this)->value();
}
bool Object::IsNaN() const {
return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value());
}
bool Object::IsMinusZero() const {
return this->IsHeapNumber() &&
i::IsMinusZero(HeapNumber::cast(this)->value());
}
// ------------------------------------
// Cast operations
CAST_ACCESSOR(AbstractCode)
CAST_ACCESSOR(AccessCheckInfo)
CAST_ACCESSOR(AccessorInfo)
CAST_ACCESSOR(AccessorPair)
CAST_ACCESSOR(AllocationMemento)
CAST_ACCESSOR(AllocationSite)
CAST_ACCESSOR(ArrayList)
CAST_ACCESSOR(AsyncGeneratorRequest)
CAST_ACCESSOR(BigInt)
CAST_ACCESSOR(BoilerplateDescription)
CAST_ACCESSOR(ByteArray)
CAST_ACCESSOR(BytecodeArray)
CAST_ACCESSOR(CallHandlerInfo)
CAST_ACCESSOR(Cell)
CAST_ACCESSOR(Code)
CAST_ACCESSOR(ConstantElementsPair)
CAST_ACCESSOR(ContextExtension)
CAST_ACCESSOR(DeoptimizationInputData)
CAST_ACCESSOR(DependentCode)
CAST_ACCESSOR(DescriptorArray)
CAST_ACCESSOR(EnumCache)
CAST_ACCESSOR(FixedArray)
CAST_ACCESSOR(FixedArrayBase)
CAST_ACCESSOR(FixedDoubleArray)
CAST_ACCESSOR(FixedTypedArrayBase)
CAST_ACCESSOR(Foreign)
CAST_ACCESSOR(FunctionTemplateInfo)
CAST_ACCESSOR(GlobalDictionary)
CAST_ACCESSOR(HandlerTable)
CAST_ACCESSOR(HeapObject)
CAST_ACCESSOR(InterceptorInfo)
CAST_ACCESSOR(JSArray)
CAST_ACCESSOR(JSArrayBuffer)
CAST_ACCESSOR(JSArrayBufferView)
CAST_ACCESSOR(JSArrayIterator)
CAST_ACCESSOR(JSAsyncFromSyncIterator)
CAST_ACCESSOR(JSAsyncGeneratorObject)
CAST_ACCESSOR(JSBoundFunction)
CAST_ACCESSOR(JSDataView)
CAST_ACCESSOR(JSDate)
CAST_ACCESSOR(JSFunction)
CAST_ACCESSOR(JSGeneratorObject)
CAST_ACCESSOR(JSGlobalObject)
CAST_ACCESSOR(JSGlobalProxy)
CAST_ACCESSOR(JSMap)
CAST_ACCESSOR(JSMapIterator)
CAST_ACCESSOR(JSMessageObject)
CAST_ACCESSOR(JSObject)
CAST_ACCESSOR(JSPromise)
CAST_ACCESSOR(JSProxy)
CAST_ACCESSOR(JSReceiver)
CAST_ACCESSOR(JSRegExp)
CAST_ACCESSOR(JSSet)
CAST_ACCESSOR(JSSetIterator)
CAST_ACCESSOR(JSStringIterator)
CAST_ACCESSOR(JSTypedArray)
CAST_ACCESSOR(JSValue)
CAST_ACCESSOR(JSWeakCollection)
CAST_ACCESSOR(JSWeakMap)
CAST_ACCESSOR(JSWeakSet)
CAST_ACCESSOR(LayoutDescriptor)
CAST_ACCESSOR(NameDictionary)
CAST_ACCESSOR(NormalizedMapCache)
CAST_ACCESSOR(Object)
CAST_ACCESSOR(ObjectHashSet)
CAST_ACCESSOR(ObjectHashTable)
CAST_ACCESSOR(ObjectTemplateInfo)
CAST_ACCESSOR(Oddball)
CAST_ACCESSOR(OrderedHashMap)
CAST_ACCESSOR(OrderedHashSet)
CAST_ACCESSOR(PromiseCapability)
CAST_ACCESSOR(PromiseReactionJobInfo)
CAST_ACCESSOR(PromiseResolveThenableJobInfo)
CAST_ACCESSOR(PropertyArray)
CAST_ACCESSOR(PropertyCell)
CAST_ACCESSOR(PrototypeInfo)
CAST_ACCESSOR(RegExpMatchInfo)
CAST_ACCESSOR(ScopeInfo)
CAST_ACCESSOR(SeededNumberDictionary)
CAST_ACCESSOR(SmallOrderedHashMap)
CAST_ACCESSOR(SmallOrderedHashSet)
CAST_ACCESSOR(Smi)
CAST_ACCESSOR(SourcePositionTableWithFrameCache)
CAST_ACCESSOR(StackFrameInfo)
CAST_ACCESSOR(StringSet)
CAST_ACCESSOR(StringTable)
CAST_ACCESSOR(Struct)
CAST_ACCESSOR(TemplateInfo)
CAST_ACCESSOR(TemplateList)
CAST_ACCESSOR(Tuple2)
CAST_ACCESSOR(Tuple3)
CAST_ACCESSOR(TypeFeedbackInfo)
CAST_ACCESSOR(UnseededNumberDictionary)
CAST_ACCESSOR(WeakCell)
CAST_ACCESSOR(WeakFixedArray)
CAST_ACCESSOR(WeakHashTable)
bool Object::HasValidElements() {
// Dictionary is covered under FixedArray.
return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
}
bool Object::KeyEquals(Object* second) {
Object* first = this;
if (second->IsNumber()) {
if (first->IsNumber()) return first->Number() == second->Number();
Object* temp = first;
first = second;
second = temp;
}
if (first->IsNumber()) {
DCHECK_LE(0, first->Number());
uint32_t expected = static_cast<uint32_t>(first->Number());
uint32_t index;
return Name::cast(second)->AsArrayIndex(&index) && index == expected;
}
return Name::cast(first)->Equals(Name::cast(second));
}
bool Object::FilterKey(PropertyFilter filter) {
DCHECK(!IsPropertyCell());
if (IsSymbol()) {
if (filter & SKIP_SYMBOLS) return true;
if (Symbol::cast(this)->is_private()) return true;
} else {
if (filter & SKIP_STRINGS) return true;
}
return false;
}
Handle<Object> Object::NewStorageFor(Isolate* isolate, Handle<Object> object,
Representation representation) {
if (!representation.IsDouble()) return object;
Handle<HeapNumber> result = isolate->factory()->NewHeapNumber(MUTABLE);
if (object->IsUninitialized(isolate)) {
result->set_value_as_bits(kHoleNanInt64);
} else if (object->IsMutableHeapNumber()) {
// Ensure that all bits of the double value are preserved.
result->set_value_as_bits(HeapNumber::cast(*object)->value_as_bits());
} else {
result->set_value(object->Number());
}
return result;
}
Handle<Object> Object::WrapForRead(Isolate* isolate, Handle<Object> object,
Representation representation) {
DCHECK(!object->IsUninitialized(isolate));
if (!representation.IsDouble()) {
DCHECK(object->FitsRepresentation(representation));
return object;
}
return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value());
}
Representation Object::OptimalRepresentation() {
if (!FLAG_track_fields) return Representation::Tagged();
if (IsSmi()) {
return Representation::Smi();
} else if (FLAG_track_double_fields && IsHeapNumber()) {
return Representation::Double();
} else if (FLAG_track_computed_fields &&
IsUninitialized(HeapObject::cast(this)->GetIsolate())) {
return Representation::None();
} else if (FLAG_track_heap_object_fields) {
DCHECK(IsHeapObject());
return Representation::HeapObject();
} else {
return Representation::Tagged();
}
}
ElementsKind Object::OptimalElementsKind() {
if (IsSmi()) return PACKED_SMI_ELEMENTS;
if (IsNumber()) return PACKED_DOUBLE_ELEMENTS;
return PACKED_ELEMENTS;
}
bool Object::FitsRepresentation(Representation representation) {
if (FLAG_track_fields && representation.IsSmi()) {
return IsSmi();
} else if (FLAG_track_double_fields && representation.IsDouble()) {
return IsMutableHeapNumber() || IsNumber();
} else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) {
return IsHeapObject();
} else if (FLAG_track_fields && representation.IsNone()) {
return false;
}
return true;
}
bool Object::ToUint32(uint32_t* value) const {
if (IsSmi()) {
int num = Smi::ToInt(this);
if (num < 0) return false;
*value = static_cast<uint32_t>(num);
return true;
}
if (IsHeapNumber()) {
double num = HeapNumber::cast(this)->value();
return DoubleToUint32IfEqualToSelf(num, value);
}
return false;
}
// static
MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
Handle<Object> object,
const char* method_name) {
if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
return ToObject(isolate, object, isolate->native_context(), method_name);
}
// static
MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) {
if (input->IsName()) return Handle<Name>::cast(input);
return ConvertToName(isolate, input);
}
// static
MaybeHandle<Object> Object::ToPropertyKey(Isolate* isolate,
Handle<Object> value) {
if (value->IsSmi() || HeapObject::cast(*value)->IsName()) return value;
return ConvertToPropertyKey(isolate, value);
}
// static
MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input,
ToPrimitiveHint hint) {
if (input->IsPrimitive()) return input;
return JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), hint);
}
// static
MaybeHandle<Object> Object::ToNumber(Handle<Object> input) {
if (input->IsNumber()) return input;
return ConvertToNumber(HeapObject::cast(*input)->GetIsolate(), input);
}
// static
MaybeHandle<Object> Object::ToInteger(Isolate* isolate, Handle<Object> input) {
if (input->IsSmi()) return input;
return ConvertToInteger(isolate, input);
}
// static
MaybeHandle<Object> Object::ToInt32(Isolate* isolate, Handle<Object> input) {
if (input->IsSmi()) return input;
return ConvertToInt32(isolate, input);
}
// static
MaybeHandle<Object> Object::ToUint32(Isolate* isolate, Handle<Object> input) {
if (input->IsSmi()) return handle(Smi::cast(*input)->ToUint32Smi(), isolate);
return ConvertToUint32(isolate, input);
}
// static
MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) {
if (input->IsString()) return Handle<String>::cast(input);
return ConvertToString(isolate, input);
}
// static
MaybeHandle<Object> Object::ToLength(Isolate* isolate, Handle<Object> input) {
if (input->IsSmi()) {
int value = std::max(Smi::ToInt(*input), 0);
return handle(Smi::FromInt(value), isolate);
}
return ConvertToLength(isolate, input);
}
// static
MaybeHandle<Object> Object::ToIndex(Isolate* isolate, Handle<Object> input,
MessageTemplate::Template error_index) {
if (input->IsSmi() && Smi::ToInt(*input) >= 0) return input;
return ConvertToIndex(isolate, input, error_index);
}
bool Object::HasSpecificClassOf(String* name) {
return this->IsJSObject() && (JSObject::cast(this)->class_name() == name);
}
MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
Handle<Name> name) {
LookupIterator it(object, name);
if (!it.IsFound()) return it.factory()->undefined_value();
return GetProperty(&it);
}
MaybeHandle<Object> JSReceiver::GetProperty(Handle<JSReceiver> receiver,
Handle<Name> name) {
LookupIterator it(receiver, name, receiver);
if (!it.IsFound()) return it.factory()->undefined_value();
return Object::GetProperty(&it);
}
MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object,
uint32_t index) {
LookupIterator it(isolate, object, index);
if (!it.IsFound()) return it.factory()->undefined_value();
return GetProperty(&it);
}
MaybeHandle<Object> JSReceiver::GetElement(Isolate* isolate,
Handle<JSReceiver> receiver,
uint32_t index) {
LookupIterator it(isolate, receiver, index, receiver);
if (!it.IsFound()) return it.factory()->undefined_value();
return Object::GetProperty(&it);
}
Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
Handle<Name> name) {
LookupIterator it(object, name, object,
LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
if (!it.IsFound()) return it.factory()->undefined_value();
return GetDataProperty(&it);
}
MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object,
uint32_t index, Handle<Object> value,
LanguageMode language_mode) {
LookupIterator it(isolate, object, index);
MAYBE_RETURN_NULL(
SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED));
return value;
}
MaybeHandle<Object> JSReceiver::GetPrototype(Isolate* isolate,
Handle<JSReceiver> receiver) {
// We don't expect access checks to be needed on JSProxy objects.
DCHECK(!receiver->IsAccessCheckNeeded() || receiver->IsJSObject());
PrototypeIterator iter(isolate, receiver, kStartAtReceiver,
PrototypeIterator::END_AT_NON_HIDDEN);
do {
if (!iter.AdvanceFollowingProxies()) return MaybeHandle<Object>();
} while (!iter.IsAtEnd());
return PrototypeIterator::GetCurrent(iter);
}
MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
Handle<JSReceiver> receiver,
const char* name) {
Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
return GetProperty(receiver, str);
}
// static
MUST_USE_RESULT MaybeHandle<FixedArray> JSReceiver::OwnPropertyKeys(
Handle<JSReceiver> object) {
return KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly,
ALL_PROPERTIES,
GetKeysConversion::kConvertToString);
}
bool JSObject::PrototypeHasNoElements(Isolate* isolate, JSObject* object) {
DisallowHeapAllocation no_gc;
HeapObject* prototype = HeapObject::cast(object->map()->prototype());
HeapObject* null = isolate->heap()->null_value();
HeapObject* empty_fixed_array = isolate->heap()->empty_fixed_array();
HeapObject* empty_slow_element_dictionary =
isolate->heap()->empty_slow_element_dictionary();
while (prototype != null) {
Map* map = prototype->map();
if (map->instance_type() <= LAST_CUSTOM_ELEMENTS_RECEIVER) return false;
HeapObject* elements = JSObject::cast(prototype)->elements();
if (elements != empty_fixed_array &&
elements != empty_slow_element_dictionary) {
return false;
}
prototype = HeapObject::cast(map->prototype());
}
return true;
}
Object** HeapObject::RawField(HeapObject* obj, int byte_offset) {
return reinterpret_cast<Object**>(FIELD_ADDR(obj, byte_offset));
}
int Smi::ToInt(const Object* object) { return Smi::cast(object)->value(); }
MapWord MapWord::FromMap(const Map* map) {
return MapWord(reinterpret_cast<uintptr_t>(map));
}
Map* MapWord::ToMap() const { return reinterpret_cast<Map*>(value_); }
bool MapWord::IsForwardingAddress() const {
return HAS_SMI_TAG(reinterpret_cast<Object*>(value_));
}
MapWord MapWord::FromForwardingAddress(HeapObject* object) {
Address raw = reinterpret_cast<Address>(object) - kHeapObjectTag;
return MapWord(reinterpret_cast<uintptr_t>(raw));
}
HeapObject* MapWord::ToForwardingAddress() {
DCHECK(IsForwardingAddress());
return HeapObject::FromAddress(reinterpret_cast<Address>(value_));
}
#ifdef VERIFY_HEAP
void HeapObject::VerifyObjectField(int offset) {
VerifyPointer(READ_FIELD(this, offset));
}
void HeapObject::VerifySmiField(int offset) {
CHECK(READ_FIELD(this, offset)->IsSmi());
}
#endif
Heap* HeapObject::GetHeap() const {
Heap* heap = MemoryChunk::FromAddress(
reinterpret_cast<Address>(const_cast<HeapObject*>(this)))
->heap();
SLOW_DCHECK(heap != NULL);
return heap;
}
Isolate* HeapObject::GetIsolate() const {
return GetHeap()->isolate();
}
Map* HeapObject::map() const {
return map_word().ToMap();
}
void HeapObject::set_map(Map* value) {
if (value != nullptr) {
#ifdef VERIFY_HEAP
value->GetHeap()->VerifyObjectLayoutChange(this, value);
#endif
}
set_map_word(MapWord::FromMap(value));
if (value != nullptr) {
// TODO(1600) We are passing NULL as a slot because maps can never be on
// evacuation candidate.
value->GetHeap()->incremental_marking()->RecordWrite(this, nullptr, value);
}
}
Map* HeapObject::synchronized_map() const {
return synchronized_map_word().ToMap();
}
void HeapObject::synchronized_set_map(Map* value) {
if (value != nullptr) {
#ifdef VERIFY_HEAP
value->GetHeap()->VerifyObjectLayoutChange(this, value);
#endif
}
synchronized_set_map_word(MapWord::FromMap(value));
if (value != nullptr) {
// TODO(1600) We are passing NULL as a slot because maps can never be on
// evacuation candidate.
value->GetHeap()->incremental_marking()->RecordWrite(this, nullptr, value);
}
}
// Unsafe accessor omitting write barrier.
void HeapObject::set_map_no_write_barrier(Map* value) {
if (value != nullptr) {
#ifdef VERIFY_HEAP
value->GetHeap()->VerifyObjectLayoutChange(this, value);
#endif
}
set_map_word(MapWord::FromMap(value));
}
void HeapObject::set_map_after_allocation(Map* value, WriteBarrierMode mode) {
set_map_word(MapWord::FromMap(value));
if (mode != SKIP_WRITE_BARRIER) {
DCHECK(value != nullptr);
// TODO(1600) We are passing NULL as a slot because maps can never be on
// evacuation candidate.
value->GetHeap()->incremental_marking()->RecordWrite(this, nullptr, value);
}
}
HeapObject** HeapObject::map_slot() {
return reinterpret_cast<HeapObject**>(FIELD_ADDR(this, kMapOffset));
}
MapWord HeapObject::map_word() const {
return MapWord(
reinterpret_cast<uintptr_t>(RELAXED_READ_FIELD(this, kMapOffset)));
}
void HeapObject::set_map_word(MapWord map_word) {
RELAXED_WRITE_FIELD(this, kMapOffset,
reinterpret_cast<Object*>(map_word.value_));
}
MapWord HeapObject::synchronized_map_word() const {
return MapWord(
reinterpret_cast<uintptr_t>(ACQUIRE_READ_FIELD(this, kMapOffset)));
}
void HeapObject::synchronized_set_map_word(MapWord map_word) {
RELEASE_WRITE_FIELD(
this, kMapOffset, reinterpret_cast<Object*>(map_word.value_));
}
int HeapObject::Size() const { return SizeFromMap(map()); }
double HeapNumber::value() const {
return READ_DOUBLE_FIELD(this, kValueOffset);
}
void HeapNumber::set_value(double value) {
WRITE_DOUBLE_FIELD(this, kValueOffset, value);
}
uint64_t HeapNumber::value_as_bits() const {
return READ_UINT64_FIELD(this, kValueOffset);
}
void HeapNumber::set_value_as_bits(uint64_t bits) {
WRITE_UINT64_FIELD(this, kValueOffset, bits);
}
int HeapNumber::get_exponent() {
return ((READ_INT_FIELD(this, kExponentOffset) & kExponentMask) >>
kExponentShift) - kExponentBias;
}
int HeapNumber::get_sign() {
return READ_INT_FIELD(this, kExponentOffset) & kSignMask;
}
inline Object* OrderedHashMap::ValueAt(int entry) {
DCHECK_LT(entry, this->UsedCapacity());
return get(EntryToIndex(entry) + kValueOffset);
}
ACCESSORS(JSReceiver, raw_properties_or_hash, Object, kPropertiesOrHashOffset)
Object** FixedArray::GetFirstElementAddress() {
return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0)));
}
bool FixedArray::ContainsOnlySmisOrHoles() {
Object* the_hole = GetHeap()->the_hole_value();
Object** current = GetFirstElementAddress();
for (int i = 0; i < length(); ++i) {
Object* candidate = *current++;
if (!candidate->IsSmi() && candidate != the_hole) return false;
}
return true;
}
FixedArrayBase* JSObject::elements() const {
Object* array = READ_FIELD(this, kElementsOffset);
return static_cast<FixedArrayBase*>(array);
}
void AllocationSite::Initialize() {
set_transition_info_or_boilerplate(Smi::kZero);
SetElementsKind(GetInitialFastElementsKind());
set_nested_site(Smi::kZero);
set_pretenure_data(0);
set_pretenure_create_count(0);
set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()),
SKIP_WRITE_BARRIER);
}
bool AllocationSite::IsZombie() const {
return pretenure_decision() == kZombie;
}
bool AllocationSite::IsMaybeTenure() const {
return pretenure_decision() == kMaybeTenure;
}
bool AllocationSite::PretenuringDecisionMade() const {
return pretenure_decision() != kUndecided;
}
void AllocationSite::MarkZombie() {
DCHECK(!IsZombie());
Initialize();
set_pretenure_decision(kZombie);
}
ElementsKind AllocationSite::GetElementsKind() const {
return ElementsKindBits::decode(transition_info());
}
void AllocationSite::SetElementsKind(ElementsKind kind) {
set_transition_info(ElementsKindBits::update(transition_info(), kind));
}
bool AllocationSite::CanInlineCall() const {
return DoNotInlineBit::decode(transition_info()) == 0;
}
void AllocationSite::SetDoNotInlineCall() {
set_transition_info(DoNotInlineBit::update(transition_info(), true));
}
bool AllocationSite::PointsToLiteral() const {
Object* raw_value = transition_info_or_boilerplate();
DCHECK_EQ(!raw_value->IsSmi(),
raw_value->IsJSArray() || raw_value->IsJSObject());
return !raw_value->IsSmi();
}
// Heuristic: We only need to create allocation site info if the boilerplate
// elements kind is the initial elements kind.
bool AllocationSite::ShouldTrack(ElementsKind boilerplate_elements_kind) {
return IsSmiElementsKind(boilerplate_elements_kind);
}
inline bool AllocationSite::CanTrack(InstanceType type) {
if (FLAG_allocation_site_pretenuring) {
// TurboFan doesn't care at all about String pretenuring feedback,
// so don't bother even trying to track that.
return type == JS_ARRAY_TYPE || type == JS_OBJECT_TYPE;
}
return type == JS_ARRAY_TYPE;
}
AllocationSite::PretenureDecision AllocationSite::pretenure_decision() const {
return PretenureDecisionBits::decode(pretenure_data());
}
void AllocationSite::set_pretenure_decision(PretenureDecision decision) {
int value = pretenure_data();
set_pretenure_data(PretenureDecisionBits::update(value, decision));
}
bool AllocationSite::deopt_dependent_code() const {
return DeoptDependentCodeBit::decode(pretenure_data());
}
void AllocationSite::set_deopt_dependent_code(bool deopt) {
int value = pretenure_data();
set_pretenure_data(DeoptDependentCodeBit::update(value, deopt));
}
int AllocationSite::memento_found_count() const {
return MementoFoundCountBits::decode(pretenure_data());
}
inline void AllocationSite::set_memento_found_count(int count) {
int value = pretenure_data();
// Verify that we can count more mementos than we can possibly find in one
// new space collection.
DCHECK((GetHeap()->MaxSemiSpaceSize() /
(Heap::kMinObjectSizeInWords * kPointerSize +
AllocationMemento::kSize)) < MementoFoundCountBits::kMax);
DCHECK(count < MementoFoundCountBits::kMax);
set_pretenure_data(MementoFoundCountBits::update(value, count));
}
int AllocationSite::memento_create_count() const {
return pretenure_create_count();
}
void AllocationSite::set_memento_create_count(int count) {
set_pretenure_create_count(count);
}
bool AllocationSite::IncrementMementoFoundCount(int increment) {
if (IsZombie()) return false;
int value = memento_found_count();
set_memento_found_count(value + increment);
return memento_found_count() >= kPretenureMinimumCreated;
}
inline void AllocationSite::IncrementMementoCreateCount() {
DCHECK(FLAG_allocation_site_pretenuring);
int value = memento_create_count();
set_memento_create_count(value + 1);
}
bool AllocationMemento::IsValid() const {
return allocation_site()->IsAllocationSite() &&
!AllocationSite::cast(allocation_site())->IsZombie();
}
AllocationSite* AllocationMemento::GetAllocationSite() const {
DCHECK(IsValid());
return AllocationSite::cast(allocation_site());
}
Address AllocationMemento::GetAllocationSiteUnchecked() const {
return reinterpret_cast<Address>(allocation_site());
}
void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
JSObject::ValidateElements(*object);
ElementsKind elements_kind = object->map()->elements_kind();
if (!IsObjectElementsKind(elements_kind)) {
if (IsHoleyElementsKind(elements_kind)) {
TransitionElementsKind(object, HOLEY_ELEMENTS);
} else {
TransitionElementsKind(object, PACKED_ELEMENTS);
}
}
}
void JSObject::EnsureCanContainElements(Handle<JSObject> object,
Object** objects,
uint32_t count,
EnsureElementsMode mode) {
ElementsKind current_kind = object->GetElementsKind();
ElementsKind target_kind = current_kind;
{
DisallowHeapAllocation no_allocation;
DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS);
bool is_holey = IsHoleyElementsKind(current_kind);
if (current_kind == HOLEY_ELEMENTS) return;
Object* the_hole = object->GetHeap()->the_hole_value();
for (uint32_t i = 0; i < count; ++i) {
Object* current = *objects++;
if (current == the_hole) {
is_holey = true;
target_kind = GetHoleyElementsKind(target_kind);
} else if (!current->IsSmi()) {
if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) {
if (IsSmiElementsKind(target_kind)) {
if (is_holey) {
target_kind = HOLEY_DOUBLE_ELEMENTS;
} else {
target_kind = PACKED_DOUBLE_ELEMENTS;
}
}
} else if (is_holey) {
target_kind = HOLEY_ELEMENTS;
break;
} else {
target_kind = PACKED_ELEMENTS;
}
}
}
}
if (target_kind != current_kind) {
TransitionElementsKind(object, target_kind);
}
}
void JSObject::EnsureCanContainElements(Handle<JSObject> object,
Handle<FixedArrayBase> elements,
uint32_t length,
EnsureElementsMode mode) {
Heap* heap = object->GetHeap();
if (elements->map() != heap->fixed_double_array_map()) {
DCHECK(elements->map() == heap->fixed_array_map() ||
elements->map() == heap->fixed_cow_array_map());
if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) {
mode = DONT_ALLOW_DOUBLE_ELEMENTS;
}
Object** objects =
Handle<FixedArray>::cast(elements)->GetFirstElementAddress();
EnsureCanContainElements(object, objects, length, mode);
return;
}
DCHECK(mode == ALLOW_COPIED_DOUBLE_ELEMENTS);
if (object->GetElementsKind() == HOLEY_SMI_ELEMENTS) {
TransitionElementsKind(object, HOLEY_DOUBLE_ELEMENTS);
} else if (object->GetElementsKind() == PACKED_SMI_ELEMENTS) {
Handle<FixedDoubleArray> double_array =
Handle<FixedDoubleArray>::cast(elements);
for (uint32_t i = 0; i < length; ++i) {
if (double_array->is_the_hole(i)) {
TransitionElementsKind(object, HOLEY_DOUBLE_ELEMENTS);
return;
}
}
TransitionElementsKind(object, PACKED_DOUBLE_ELEMENTS);
}
}
void JSObject::SetMapAndElements(Handle<JSObject> object,
Handle<Map> new_map,
Handle<FixedArrayBase> value) {
JSObject::MigrateToMap(object, new_map);
DCHECK((object->map()->has_fast_smi_or_object_elements() ||
(*value == object->GetHeap()->empty_fixed_array()) ||
object->map()->has_fast_string_wrapper_elements()) ==
(value->map() == object->GetHeap()->fixed_array_map() ||
value->map() == object->GetHeap()->fixed_cow_array_map()));
DCHECK((*value == object->GetHeap()->empty_fixed_array()) ||
(object->map()->has_fast_double_elements() ==
value->IsFixedDoubleArray()));
object->set_elements(*value);
}
void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) {
WRITE_FIELD(this, kElementsOffset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, value, mode);
}
void JSObject::initialize_elements() {
FixedArrayBase* elements = map()->GetInitialElements();
WRITE_FIELD(this, kElementsOffset, elements);
}
InterceptorInfo* JSObject::GetIndexedInterceptor() {
return map()->GetIndexedInterceptor();
}
InterceptorInfo* JSObject::GetNamedInterceptor() {
return map()->GetNamedInterceptor();
}
double Oddball::to_number_raw() const {
return READ_DOUBLE_FIELD(this, kToNumberRawOffset);
}
void Oddball::set_to_number_raw(double value) {
WRITE_DOUBLE_FIELD(this, kToNumberRawOffset, value);
}
void Oddball::set_to_number_raw_as_bits(uint64_t bits) {
WRITE_UINT64_FIELD(this, kToNumberRawOffset, bits);
}
ACCESSORS(Oddball, to_string, String, kToStringOffset)
ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
ACCESSORS(Oddball, type_of, String, kTypeOfOffset)
byte Oddball::kind() const { return Smi::ToInt(READ_FIELD(this, kKindOffset)); }
void Oddball::set_kind(byte value) {
WRITE_FIELD(this, kKindOffset, Smi::FromInt(value));
}
// static
Handle<Object> Oddball::ToNumber(Handle<Oddball> input) {
return handle(input->to_number(), input->GetIsolate());
}
ACCESSORS(Cell, value, Object, kValueOffset)
ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset)
ACCESSORS(PropertyCell, name, Name, kNameOffset)
ACCESSORS(PropertyCell, value, Object, kValueOffset)
ACCESSORS(PropertyCell, property_details_raw, Object, kDetailsOffset)
PropertyDetails PropertyCell::property_details() {
return PropertyDetails(Smi::cast(property_details_raw()));
}
void PropertyCell::set_property_details(PropertyDetails details) {
set_property_details_raw(details.AsSmi());
}
Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); }
void WeakCell::clear() {
// Either the garbage collector is clearing the cell or we are simply
// initializing the root empty weak cell.
DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT ||
this == GetHeap()->empty_weak_cell());
WRITE_FIELD(this, kValueOffset, Smi::kZero);
}
void WeakCell::initialize(HeapObject* val) {
WRITE_FIELD(this, kValueOffset, val);
// We just have to execute the generational barrier here because we never
// mark through a weak cell and collect evacuation candidates when we process
// all weak cells.
Heap* heap = val->GetHeap();
WriteBarrierMode mode =
heap->incremental_marking()->marking_state()->IsBlack(this)
? UPDATE_WRITE_BARRIER
: UPDATE_WEAK_WRITE_BARRIER;
CONDITIONAL_WRITE_BARRIER(heap, this, kValueOffset, val, mode);
}
bool WeakCell::cleared() const { return value() == Smi::kZero; }
int JSObject::GetHeaderSize() {
// Check for the most common kind of JavaScript object before
// falling into the generic switch. This speeds up the internal
// field operations considerably on average.
InstanceType type = map()->instance_type();
return type == JS_OBJECT_TYPE ? JSObject::kHeaderSize : GetHeaderSize(type);
}
inline bool IsSpecialReceiverInstanceType(InstanceType instance_type) {
return instance_type <= LAST_SPECIAL_RECEIVER_TYPE;
}
// static
int JSObject::GetEmbedderFieldCount(const Map* map) {
int instance_size = map->instance_size();
if (instance_size == kVariableSizeSentinel) return 0;
InstanceType instance_type = map->instance_type();
return ((instance_size - GetHeaderSize(instance_type)) >> kPointerSizeLog2) -
map->GetInObjectProperties();
}
int JSObject::GetEmbedderFieldCount() const {
return GetEmbedderFieldCount(map());
}
int JSObject::GetEmbedderFieldOffset(int index) {
DCHECK(index < GetEmbedderFieldCount() && index >= 0);
return GetHeaderSize() + (kPointerSize * index);
}
Object* JSObject::GetEmbedderField(int index) {
DCHECK(index < GetEmbedderFieldCount() && index >= 0);
// Internal objects do follow immediately after the header, whereas in-object
// properties are at the end of the object. Therefore there is no need
// to adjust the index here.
return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index));
}
void JSObject::SetEmbedderField(int index, Object* value) {
DCHECK(index < GetEmbedderFieldCount() && index >= 0);
// Internal objects do follow immediately after the header, whereas in-object
// properties are at the end of the object. Therefore there is no need
// to adjust the index here.
int offset = GetHeaderSize() + (kPointerSize * index);
WRITE_FIELD(this, offset, value);
WRITE_BARRIER(GetHeap(), this, offset, value);
}
void JSObject::SetEmbedderField(int index, Smi* value) {
DCHECK(index < GetEmbedderFieldCount() && index >= 0);
// Internal objects do follow immediately after the header, whereas in-object
// properties are at the end of the object. Therefore there is no need
// to adjust the index here.
int offset = GetHeaderSize() + (kPointerSize * index);
WRITE_FIELD(this, offset, value);
}
bool JSObject::IsUnboxedDoubleField(FieldIndex index) {
if (!FLAG_unbox_double_fields) return false;
return map()->IsUnboxedDoubleField(index);
}
bool Map::IsUnboxedDoubleField(FieldIndex index) const {
if (!FLAG_unbox_double_fields) return false;
if (index.is_hidden_field() || !index.is_inobject()) return false;
return !layout_descriptor()->IsTagged(index.property_index());
}
// Access fast-case object properties at index. The use of these routines
// is needed to correctly distinguish between properties stored in-object and
// properties stored in the properties array.
Object* JSObject::RawFastPropertyAt(FieldIndex index) {
DCHECK(!IsUnboxedDoubleField(index));
if (index.is_inobject()) {
return READ_FIELD(this, index.offset());
} else {
return property_array()->get(index.outobject_array_index());
}
}
double JSObject::RawFastDoublePropertyAt(FieldIndex index) {
DCHECK(IsUnboxedDoubleField(index));
return READ_DOUBLE_FIELD(this, index.offset());
}
uint64_t JSObject::RawFastDoublePropertyAsBitsAt(FieldIndex index) {
DCHECK(IsUnboxedDoubleField(index));
return READ_UINT64_FIELD(this, index.offset());
}
void JSObject::RawFastPropertyAtPut(FieldIndex index, Object* value) {
if (index.is_inobject()) {
int offset = index.offset();
WRITE_FIELD(this, offset, value);
WRITE_BARRIER(GetHeap(), this, offset, value);
} else {
property_array()->set(index.outobject_array_index(), value);
}
}
void JSObject::RawFastDoublePropertyAsBitsAtPut(FieldIndex index,
uint64_t bits) {
// Double unboxing is enabled only on 64-bit platforms.
DCHECK_EQ(kDoubleSize, kPointerSize);
Address field_addr = FIELD_ADDR(this, index.offset());
base::Relaxed_Store(reinterpret_cast<base::AtomicWord*>(field_addr),
static_cast<base::AtomicWord>(bits));
}
void JSObject::FastPropertyAtPut(FieldIndex index, Object* value) {
if (IsUnboxedDoubleField(index)) {
DCHECK(value->IsMutableHeapNumber());
// Ensure that all bits of the double value are preserved.
RawFastDoublePropertyAsBitsAtPut(index,
HeapNumber::cast(value)->value_as_bits());
} else {
RawFastPropertyAtPut(index, value);
}
}
void JSObject::WriteToField(int descriptor, PropertyDetails details,
Object* value) {
DCHECK_EQ(kField, details.location());
DCHECK_EQ(kData, details.kind());
DisallowHeapAllocation no_gc;
FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor);
if (details.representation().IsDouble()) {
// Nothing more to be done.
if (value->IsUninitialized(this->GetIsolate())) {
return;
}
// Manipulating the signaling NaN used for the hole and uninitialized
// double field sentinel in C++, e.g. with bit_cast or value()/set_value(),
// will change its value on ia32 (the x87 stack is used to return values
// and stores to the stack silently clear the signalling bit).
uint64_t bits;
if (value->IsSmi()) {
bits = bit_cast<uint64_t>(static_cast<double>(Smi::ToInt(value)));
} else {
DCHECK(value->IsHeapNumber());
bits = HeapNumber::cast(value)->value_as_bits();
}
if (IsUnboxedDoubleField(index)) {
RawFastDoublePropertyAsBitsAtPut(index, bits);
} else {
HeapNumber* box = HeapNumber::cast(RawFastPropertyAt(index));
DCHECK(box->IsMutableHeapNumber());
box->set_value_as_bits(bits);
}
} else {
RawFastPropertyAtPut(index, value);
}
}
int JSObject::GetInObjectPropertyOffset(int index) {
return map()->GetInObjectPropertyOffset(index);
}
Object* JSObject::InObjectPropertyAt(int index) {
int offset = GetInObjectPropertyOffset(index);
return READ_FIELD(this, offset);
}
Object* JSObject::InObjectPropertyAtPut(int index,
Object* value,
WriteBarrierMode mode) {
// Adjust for the number of properties stored in the object.
int offset = GetInObjectPropertyOffset(index);
WRITE_FIELD(this, offset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);
return value;
}
void JSObject::InitializeBody(Map* map, int start_offset,
Object* pre_allocated_value,
Object* filler_value) {
DCHECK(!filler_value->IsHeapObject() ||
!GetHeap()->InNewSpace(filler_value));
DCHECK(!pre_allocated_value->IsHeapObject() ||
!GetHeap()->InNewSpace(pre_allocated_value));
int size = map->instance_size();
int offset = start_offset;
if (filler_value != pre_allocated_value) {
int end_of_pre_allocated_offset =
size - (map->unused_property_fields() * kPointerSize);
DCHECK_LE(kHeaderSize, end_of_pre_allocated_offset);
while (offset < end_of_pre_allocated_offset) {
WRITE_FIELD(this, offset, pre_allocated_value);
offset += kPointerSize;
}
}
while (offset < size) {
WRITE_FIELD(this, offset, filler_value);
offset += kPointerSize;
}
}
bool Map::TooManyFastProperties(StoreFromKeyed store_mode) const {
if (unused_property_fields() != 0) return false;
if (is_prototype_map()) return false;
int minimum = store_mode == CERTAINLY_NOT_STORE_FROM_KEYED ? 128 : 12;
int limit = Max(minimum, GetInObjectProperties());
int external = NumberOfFields() - GetInObjectProperties();
return external > limit;
}
void Struct::InitializeBody(int object_size) {
Object* value = GetHeap()->undefined_value();
for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
WRITE_FIELD(this, offset, value);
}
}
bool Object::ToArrayLength(uint32_t* index) const {
return Object::ToUint32(index);
}
bool Object::ToArrayIndex(uint32_t* index) const {
return Object::ToUint32(index) && *index != kMaxUInt32;
}
void Object::VerifyApiCallResultType() {
#if DEBUG
if (IsSmi()) return;
DCHECK(IsHeapObject());
Isolate* isolate = HeapObject::cast(this)->GetIsolate();
if (!(IsString() || IsSymbol() || IsJSReceiver() || IsHeapNumber() ||
IsUndefined(isolate) || IsTrue(isolate) || IsFalse(isolate) ||
IsNull(isolate))) {
FATAL("API call returned invalid object");
}
#endif // DEBUG
}
Object* FixedArray::get(int index) const {
SLOW_DCHECK(index >= 0 && index < this->length());
return RELAXED_READ_FIELD(this, kHeaderSize + index * kPointerSize);
}
Object* PropertyArray::get(int index) const {
DCHECK_GE(index, 0);
DCHECK_LE(index, this->length());
return RELAXED_READ_FIELD(this, kHeaderSize + index * kPointerSize);
}
Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) {
return handle(array->get(index), isolate);
}
template <class T>
MaybeHandle<T> FixedArray::GetValue(Isolate* isolate, int index) const {
Object* obj = get(index);
if (obj->IsUndefined(isolate)) return MaybeHandle<T>();
return Handle<T>(T::cast(obj), isolate);
}
template <class T>
Handle<T> FixedArray::GetValueChecked(Isolate* isolate, int index) const {
Object* obj = get(index);
CHECK(!obj->IsUndefined(isolate));
return Handle<T>(T::cast(obj), isolate);
}
bool FixedArray::is_the_hole(Isolate* isolate, int index) {
return get(index)->IsTheHole(isolate);
}
void FixedArray::set(int index, Smi* value) {
DCHECK_NE(map(), GetHeap()->fixed_cow_array_map());
DCHECK_LT(index, this->length());
DCHECK(reinterpret_cast<Object*>(value)->IsSmi());
int offset = kHeaderSize + index * kPointerSize;
RELAXED_WRITE_FIELD(this, offset, value);
}
void FixedArray::set(int index, Object* value) {
DCHECK_NE(GetHeap()->fixed_cow_array_map(), map());
DCHECK(IsFixedArray() || IsTransitionArray());
DCHECK_GE(index, 0);
DCHECK_LT(index, this->length());
int offset = kHeaderSize + index * kPointerSize;
RELAXED_WRITE_FIELD(this, offset, value);
WRITE_BARRIER(GetHeap(), this, offset, value);
}
void PropertyArray::set(int index, Object* value) {
DCHECK(IsPropertyArray());
DCHECK_GE(index, 0);
DCHECK_LT(index, this->length());
int offset = kHeaderSize + index * kPointerSize;
RELAXED_WRITE_FIELD(this, offset, value);
WRITE_BARRIER(GetHeap(), this, offset, value);
}
double FixedDoubleArray::get_scalar(int index) {
DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
map() != GetHeap()->fixed_array_map());
DCHECK(index >= 0 && index < this->length());
DCHECK(!is_the_hole(index));
return READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize);
}
uint64_t FixedDoubleArray::get_representation(int index) {
DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
map() != GetHeap()->fixed_array_map());
DCHECK(index >= 0 && index < this->length());
int offset = kHeaderSize + index * kDoubleSize;
return READ_UINT64_FIELD(this, offset);
}
Handle<Object> FixedDoubleArray::get(FixedDoubleArray* array, int index,
Isolate* isolate) {
if (array->is_the_hole(index)) {
return isolate->factory()->the_hole_value();
} else {
return isolate->factory()->NewNumber(array->get_scalar(index));
}
}
void FixedDoubleArray::set(int index, double value) {
DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
map() != GetHeap()->fixed_array_map());
int offset = kHeaderSize + index * kDoubleSize;
if (std::isnan(value)) {
WRITE_DOUBLE_FIELD(this, offset, std::numeric_limits<double>::quiet_NaN());
} else {
WRITE_DOUBLE_FIELD(this, offset, value);
}
DCHECK(!is_the_hole(index));
}
void FixedDoubleArray::set_the_hole(Isolate* isolate, int index) {
set_the_hole(index);
}
void FixedDoubleArray::set_the_hole(int index) {
DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
map() != GetHeap()->fixed_array_map());
int offset = kHeaderSize + index * kDoubleSize;
WRITE_UINT64_FIELD(this, offset, kHoleNanInt64);
}
bool FixedDoubleArray::is_the_hole(Isolate* isolate, int index) {
return is_the_hole(index);
}
bool FixedDoubleArray::is_the_hole(int index) {
return get_representation(index) == kHoleNanInt64;
}
double* FixedDoubleArray::data_start() {
return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize));
}
void FixedDoubleArray::FillWithHoles(int from, int to) {
for (int i = from; i < to; i++) {
set_the_hole(i);
}
}
Object* WeakFixedArray::Get(int index) const {
Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
if (raw->IsSmi()) return raw;
DCHECK(raw->IsWeakCell());
return WeakCell::cast(raw)->value();
}
bool WeakFixedArray::IsEmptySlot(int index) const {
DCHECK(index < Length());
return Get(index)->IsSmi();
}
void WeakFixedArray::Clear(int index) {
FixedArray::cast(this)->set(index + kFirstIndex, Smi::kZero);
}
int WeakFixedArray::Length() const {
return FixedArray::cast(this)->length() - kFirstIndex;
}
int WeakFixedArray::last_used_index() const {
return Smi::ToInt(FixedArray::cast(this)->get(kLastUsedIndexIndex));
}
void WeakFixedArray::set_last_used_index(int index) {
FixedArray::cast(this)->set(kLastUsedIndexIndex, Smi::FromInt(index));
}
template <class T>
T* WeakFixedArray::Iterator::Next() {
if (list_ != NULL) {
// Assert that list did not change during iteration.
DCHECK_EQ(last_used_index_, list_->last_used_index());
while (index_ < list_->Length()) {
Object* item = list_->Get(index_++);
if (item != Empty()) return T::cast(item);
}
list_ = NULL;
}
return NULL;
}
int ArrayList::Length() const {
if (FixedArray::cast(this)->length() == 0) return 0;
return Smi::ToInt(FixedArray::cast(this)->get(kLengthIndex));
}
void ArrayList::SetLength(int length) {
return FixedArray::cast(this)->set(kLengthIndex, Smi::FromInt(length));
}
Object* ArrayList::Get(int index) const {
return FixedArray::cast(this)->get(kFirstIndex + index);
}
Object** ArrayList::Slot(int index) {
return data_start() + kFirstIndex + index;
}
void ArrayList::Set(int index, Object* obj, WriteBarrierMode mode) {
FixedArray::cast(this)->set(kFirstIndex + index, obj, mode);
}
void ArrayList::Clear(int index, Object* undefined) {
DCHECK(undefined->IsUndefined(GetIsolate()));
FixedArray::cast(this)
->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER);
}
int RegExpMatchInfo::NumberOfCaptureRegisters() {
DCHECK_GE(length(), kLastMatchOverhead);
Object* obj = get(kNumberOfCapturesIndex);
return Smi::ToInt(obj);
}
void RegExpMatchInfo::SetNumberOfCaptureRegisters(int value) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kNumberOfCapturesIndex, Smi::FromInt(value));
}
String* RegExpMatchInfo::LastSubject() {
DCHECK_GE(length(), kLastMatchOverhead);
Object* obj = get(kLastSubjectIndex);
return String::cast(obj);
}
void RegExpMatchInfo::SetLastSubject(String* value) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kLastSubjectIndex, value);
}
Object* RegExpMatchInfo::LastInput() {
DCHECK_GE(length(), kLastMatchOverhead);
return get(kLastInputIndex);
}
void RegExpMatchInfo::SetLastInput(Object* value) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kLastInputIndex, value);
}
int RegExpMatchInfo::Capture(int i) {
DCHECK_LT(i, NumberOfCaptureRegisters());
Object* obj = get(kFirstCaptureIndex + i);
return Smi::ToInt(obj);
}
void RegExpMatchInfo::SetCapture(int i, int value) {
DCHECK_LT(i, NumberOfCaptureRegisters());
set(kFirstCaptureIndex + i, Smi::FromInt(value));
}
WriteBarrierMode HeapObject::GetWriteBarrierMode(
const DisallowHeapAllocation& promise) {
Heap* heap = GetHeap();
if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
return UPDATE_WRITE_BARRIER;
}
AllocationAlignment HeapObject::RequiredAlignment() const {
#ifdef V8_HOST_ARCH_32_BIT
if ((IsFixedFloat64Array() || IsFixedDoubleArray()) &&
FixedArrayBase::cast(this)->length() != 0) {
return kDoubleAligned;
}
if (IsHeapNumber()) return kDoubleUnaligned;
#endif // V8_HOST_ARCH_32_BIT
return kWordAligned;
}
void FixedArray::set(int index,
Object* value,
WriteBarrierMode mode) {
DCHECK_NE(map(), GetHeap()->fixed_cow_array_map());
DCHECK_GE(index, 0);
DCHECK_LT(index, this->length());
int offset = kHeaderSize + index * kPointerSize;
RELAXED_WRITE_FIELD(this, offset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);
}
void PropertyArray::set(int index, Object* value, WriteBarrierMode mode) {
DCHECK_GE(index, 0);
DCHECK_LT(index, this->length());
int offset = kHeaderSize + index * kPointerSize;
RELAXED_WRITE_FIELD(this, offset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);
}
void FixedArray::NoWriteBarrierSet(FixedArray* array,
int index,
Object* value) {
DCHECK_NE(array->map(), array->GetHeap()->fixed_cow_array_map());
DCHECK_GE(index, 0);
DCHECK_LT(index, array->length());
DCHECK(!array->GetHeap()->InNewSpace(value));
RELAXED_WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value);
}
void FixedArray::set_undefined(int index) {
set_undefined(GetIsolate(), index);
}
void FixedArray::set_undefined(Isolate* isolate, int index) {
FixedArray::NoWriteBarrierSet(this, index,
isolate->heap()->undefined_value());
}
void FixedArray::set_null(int index) { set_null(GetIsolate(), index); }
void FixedArray::set_null(Isolate* isolate, int index) {
FixedArray::NoWriteBarrierSet(this, index, isolate->heap()->null_value());
}
void FixedArray::set_the_hole(int index) { set_the_hole(GetIsolate(), index); }
void FixedArray::set_the_hole(Isolate* isolate, int index) {
FixedArray::NoWriteBarrierSet(this, index, isolate->heap()->the_hole_value());
}
void FixedArray::FillWithHoles(int from, int to) {
Isolate* isolate = GetIsolate();
for (int i = from; i < to; i++) {
set_the_hole(isolate, i);
}
}
Object** FixedArray::data_start() {
return HeapObject::RawField(this, kHeaderSize);
}
Object** PropertyArray::data_start() {
return HeapObject::RawField(this, kHeaderSize);
}
Object** FixedArray::RawFieldOfElementAt(int index) {
return HeapObject::RawField(this, OffsetOfElementAt(index));
}
ACCESSORS(EnumCache, keys, FixedArray, kKeysOffset)
ACCESSORS(EnumCache, indices, FixedArray, kIndicesOffset)
int DescriptorArray::number_of_descriptors() {
return Smi::ToInt(get(kDescriptorLengthIndex));
}
int DescriptorArray::number_of_descriptors_storage() {
return (length() - kFirstIndex) / kEntrySize;
}
int DescriptorArray::NumberOfSlackDescriptors() {
return number_of_descriptors_storage() - number_of_descriptors();
}
void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) {
set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors));
}
inline int DescriptorArray::number_of_entries() {
return number_of_descriptors();
}
void DescriptorArray::CopyEnumCacheFrom(DescriptorArray* array) {
set(kEnumCacheIndex, array->get(kEnumCacheIndex));
}
EnumCache* DescriptorArray::GetEnumCache() {
return EnumCache::cast(get(kEnumCacheIndex));
}
// Perform a binary search in a fixed array.
template <SearchMode search_mode, typename T>
int BinarySearch(T* array, Name* name, int valid_entries,
int* out_insertion_index) {
DCHECK(search_mode == ALL_ENTRIES || out_insertion_index == NULL);
int low = 0;
int high = array->number_of_entries() - 1;
uint32_t hash = name->hash_field();
int limit = high;
DCHECK(low <= high);
while (low != high) {
int mid = low + (high - low) / 2;
Name* mid_name = array->GetSortedKey(mid);
uint32_t mid_hash = mid_name->hash_field();
if (mid_hash >= hash) {
high = mid;
} else {
low = mid + 1;
}
}
for (; low <= limit; ++low) {
int sort_index = array->GetSortedKeyIndex(low);
Name* entry = array->GetKey(sort_index);
uint32_t current_hash = entry->hash_field();
if (current_hash != hash) {
if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
*out_insertion_index = sort_index + (current_hash > hash ? 0 : 1);
}
return T::kNotFound;
}
if (entry == name) {
if (search_mode == ALL_ENTRIES || sort_index < valid_entries) {
return sort_index;
}
return T::kNotFound;
}
}
if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
*out_insertion_index = limit + 1;
}
return T::kNotFound;
}
// Perform a linear search in this fixed array. len is the number of entry
// indices that are valid.
template <SearchMode search_mode, typename T>
int LinearSearch(T* array, Name* name, int valid_entries,
int* out_insertion_index) {
if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
uint32_t hash = name->hash_field();
int len = array->number_of_entries();
for (int number = 0; number < len; number++) {
int sorted_index = array->GetSortedKeyIndex(number);
Name* entry = array->GetKey(sorted_index);
uint32_t current_hash = entry->hash_field();
if (current_hash > hash) {
*out_insertion_index = sorted_index;
return T::kNotFound;
}
if (entry == name) return sorted_index;
}
*out_insertion_index = len;
return T::kNotFound;
} else {
DCHECK_LE(valid_entries, array->number_of_entries());
DCHECK_NULL(out_insertion_index); // Not supported here.
for (int number = 0; number < valid_entries; number++) {
if (array->GetKey(number) == name) return number;
}
return T::kNotFound;
}
}
template <SearchMode search_mode, typename T>
int Search(T* array, Name* name, int valid_entries, int* out_insertion_index) {
SLOW_DCHECK(array->IsSortedNoDuplicates());
if (valid_entries == 0) {
if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
*out_insertion_index = 0;
}
return T::kNotFound;
}
// Fast case: do linear search for small arrays.
const int kMaxElementsForLinearSearch = 8;
if (valid_entries <= kMaxElementsForLinearSearch) {
return LinearSearch<search_mode>(array, name, valid_entries,
out_insertion_index);
}
// Slow case: perform binary search.
return BinarySearch<search_mode>(array, name, valid_entries,
out_insertion_index);
}
int DescriptorArray::Search(Name* name, int valid_descriptors) {
DCHECK(name->IsUniqueName());
return internal::Search<VALID_ENTRIES>(this, name, valid_descriptors, NULL);
}
int DescriptorArray::SearchWithCache(Isolate* isolate, Name* name, Map* map) {
DCHECK(name->IsUniqueName());
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
if (number_of_own_descriptors == 0) return kNotFound;
DescriptorLookupCache* cache = isolate->descriptor_lookup_cache();
int number = cache->Lookup(map, name);
if (number == DescriptorLookupCache::kAbsent) {
number = Search(name, number_of_own_descriptors);
cache->Update(map, name, number);
}
return number;
}
PropertyDetails Map::GetLastDescriptorDetails() const {
return instance_descriptors()->GetDetails(LastAdded());
}
int Map::LastAdded() const {
int number_of_own_descriptors = NumberOfOwnDescriptors();
DCHECK(number_of_own_descriptors > 0);
return number_of_own_descriptors - 1;
}
int Map::NumberOfOwnDescriptors() const {
return NumberOfOwnDescriptorsBits::decode(bit_field3());
}
void Map::SetNumberOfOwnDescriptors(int number) {
DCHECK(number <= instance_descriptors()->number_of_descriptors());
set_bit_field3(NumberOfOwnDescriptorsBits::update(bit_field3(), number));
}
int Map::EnumLength() const { return EnumLengthBits::decode(bit_field3()); }
void Map::SetEnumLength(int length) {
if (length != kInvalidEnumCacheSentinel) {
DCHECK(length >= 0);
DCHECK(length <= NumberOfOwnDescriptors());
}
set_bit_field3(EnumLengthBits::update(bit_field3(), length));
}
FixedArrayBase* Map::GetInitialElements() const {
FixedArrayBase* result = nullptr;
if (has_fast_elements() || has_fast_string_wrapper_elements()) {
result = GetHeap()->empty_fixed_array();
} else if (has_fast_sloppy_arguments_elements()) {
result = GetHeap()->empty_sloppy_arguments_elements();
} else if (has_fixed_typed_array_elements()) {
result = GetHeap()->EmptyFixedTypedArrayForMap(this);
} else if (has_dictionary_elements()) {
result = GetHeap()->empty_slow_element_dictionary();
} else {
UNREACHABLE();
}
DCHECK(!GetHeap()->InNewSpace(result));
return result;
}
Object** DescriptorArray::GetKeySlot(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
return RawFieldOfElementAt(ToKeyIndex(descriptor_number));
}
Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) {
return GetKeySlot(descriptor_number);
}
Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) {
return GetValueSlot(descriptor_number - 1) + 1;
}
Name* DescriptorArray::GetKey(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
return Name::cast(get(ToKeyIndex(descriptor_number)));
}
int DescriptorArray::GetSortedKeyIndex(int descriptor_number) {
return GetDetails(descriptor_number).pointer();
}
Name* DescriptorArray::GetSortedKey(int descriptor_number) {
return GetKey(GetSortedKeyIndex(descriptor_number));
}
void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) {
PropertyDetails details = GetDetails(descriptor_index);
set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi());
}
Object** DescriptorArray::GetValueSlot(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
return RawFieldOfElementAt(ToValueIndex(descriptor_number));
}
int DescriptorArray::GetValueOffset(int descriptor_number) {
return OffsetOfElementAt(ToValueIndex(descriptor_number));
}
Object* DescriptorArray::GetValue(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
return get(ToValueIndex(descriptor_number));
}
void DescriptorArray::SetValue(int descriptor_index, Object* value) {
set(ToValueIndex(descriptor_index), value);
}
PropertyDetails DescriptorArray::GetDetails(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
Object* details = get(ToDetailsIndex(descriptor_number));
return PropertyDetails(Smi::cast(details));
}
int DescriptorArray::GetFieldIndex(int descriptor_number) {
DCHECK(GetDetails(descriptor_number).location() == kField);
return GetDetails(descriptor_number).field_index();
}
FieldType* DescriptorArray::GetFieldType(int descriptor_number) {
DCHECK(GetDetails(descriptor_number).location() == kField);
Object* wrapped_type = GetValue(descriptor_number);
return Map::UnwrapFieldType(wrapped_type);
}
void DescriptorArray::Get(int descriptor_number, Descriptor* desc) {
desc->Init(handle(GetKey(descriptor_number), GetIsolate()),
handle(GetValue(descriptor_number), GetIsolate()),
GetDetails(descriptor_number));
}
void DescriptorArray::Set(int descriptor_number, Name* key, Object* value,
PropertyDetails details) {
// Range check.
DCHECK(descriptor_number < number_of_descriptors());
set(ToKeyIndex(descriptor_number), key);
set(ToValueIndex(descriptor_number), value);
set(ToDetailsIndex(descriptor_number), details.AsSmi());
}
void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
Name* key = *desc->GetKey();
Object* value = *desc->GetValue();
Set(descriptor_number, key, value, desc->GetDetails());
}
void DescriptorArray::Append(Descriptor* desc) {
DisallowHeapAllocation no_gc;
int descriptor_number = number_of_descriptors();
SetNumberOfDescriptors(descriptor_number + 1);
Set(descriptor_number, desc);
uint32_t hash = desc->GetKey()->Hash();
int insertion;
for (insertion = descriptor_number; insertion > 0; --insertion) {
Name* key = GetSortedKey(insertion - 1);
if (key->Hash() <= hash) break;
SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1));
}
SetSortedKey(insertion, descriptor_number);
}
void DescriptorArray::SwapSortedKeys(int first, int second) {
int first_key = GetSortedKeyIndex(first);
SetSortedKey(first, GetSortedKeyIndex(second));
SetSortedKey(second, first_key);
}
int HashTableBase::NumberOfElements() const {
return Smi::ToInt(get(kNumberOfElementsIndex));
}
int HashTableBase::NumberOfDeletedElements() const {
return Smi::ToInt(get(kNumberOfDeletedElementsIndex));
}
int HashTableBase::Capacity() const { return Smi::ToInt(get(kCapacityIndex)); }
void HashTableBase::ElementAdded() {
SetNumberOfElements(NumberOfElements() + 1);
}
void HashTableBase::ElementRemoved() {
SetNumberOfElements(NumberOfElements() - 1);
SetNumberOfDeletedElements(NumberOfDeletedElements() + 1);
}
void HashTableBase::ElementsRemoved(int n) {
SetNumberOfElements(NumberOfElements() - n);
SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
}
// static
int HashTableBase::ComputeCapacity(int at_least_space_for) {
// Add 50% slack to make slot collisions sufficiently unlikely.
// See matching computation in HashTable::HasSufficientCapacityToAdd().
// Must be kept in sync with CodeStubAssembler::HashTableComputeCapacity().
int raw_cap = at_least_space_for + (at_least_space_for >> 1);
int capacity = base::bits::RoundUpToPowerOfTwo32(raw_cap);
return Max(capacity, kMinCapacity);
}
void HashTableBase::SetNumberOfElements(int nof) {
set(kNumberOfElementsIndex, Smi::FromInt(nof));
}
void HashTableBase::SetNumberOfDeletedElements(int nod) {
set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod));
}
template <typename Key>
Map* BaseShape<Key>::GetMap(Isolate* isolate) {
return isolate->heap()->hash_table_map();
}
template <typename Derived, typename Shape>
int HashTable<Derived, Shape>::FindEntry(Key key) {
return FindEntry(GetIsolate(), key);
}
template <typename Derived, typename Shape>
int HashTable<Derived, Shape>::FindEntry(Isolate* isolate, Key key) {
return FindEntry(isolate, key, Shape::Hash(isolate, key));
}
// Find entry for key otherwise return kNotFound.
template <typename Derived, typename Shape>
int HashTable<Derived, Shape>::FindEntry(Isolate* isolate, Key key,
int32_t hash) {
uint32_t capacity = Capacity();
uint32_t entry = FirstProbe(hash, capacity);
uint32_t count = 1;
// EnsureCapacity will guarantee the hash table is never full.
Object* undefined = isolate->heap()->undefined_value();
Object* the_hole = isolate->heap()->the_hole_value();
USE(the_hole);
while (true) {
Object* element = KeyAt(entry);
// Empty entry. Uses raw unchecked accessors because it is called by the
// string table during bootstrapping.
if (element == undefined) break;
if (!(Shape::kNeedsHoleCheck && the_hole == element)) {
if (Shape::IsMatch(key, element)) return entry;
}
entry = NextProbe(entry, count++, capacity);
}
return kNotFound;
}
bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key, int32_t hash) {
return FindEntry(isolate, key, hash) != kNotFound;
}
bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key) {
Object* hash = key->GetHash();
if (!hash->IsSmi()) return false;
return FindEntry(isolate, key, Smi::ToInt(hash)) != kNotFound;
}
bool StringSetShape::IsMatch(String* key, Object* value) {
DCHECK(value->IsString());
return key->Equals(String::cast(value));
}
uint32_t StringSetShape::Hash(Isolate* isolate, String* key) {
return key->Hash();
}
uint32_t StringSetShape::HashForObject(Isolate* isolate, Object* object) {
return String::cast(object)->Hash();
}
StringTableKey::StringTableKey(uint32_t hash_field)
: HashTableKey(hash_field >> Name::kHashShift), hash_field_(hash_field) {}
void StringTableKey::set_hash_field(uint32_t hash_field) {
hash_field_ = hash_field;
set_hash(hash_field >> Name::kHashShift);
}
Handle<Object> StringTableShape::AsHandle(Isolate* isolate,
StringTableKey* key) {
return key->AsHandle(isolate);
}
uint32_t StringTableShape::HashForObject(Isolate* isolate, Object* object) {
return String::cast(object)->Hash();
}
bool SeededNumberDictionary::requires_slow_elements() {
Object* max_index_object = get(kMaxNumberKeyIndex);
if (!max_index_object->IsSmi()) return false;
return 0 != (Smi::ToInt(max_index_object) & kRequiresSlowElementsMask);
}
uint32_t SeededNumberDictionary::max_number_key() {
DCHECK(!requires_slow_elements());
Object* max_index_object = get(kMaxNumberKeyIndex);
if (!max_index_object->IsSmi()) return 0;
uint32_t value = static_cast<uint32_t>(Smi::ToInt(max_index_object));
return value >> kRequiresSlowElementsTagSize;
}
void SeededNumberDictionary::set_requires_slow_elements() {
set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask));
}
template <class T>
PodArray<T>* PodArray<T>::cast(Object* object) {
SLOW_DCHECK(object->IsByteArray());
return reinterpret_cast<PodArray<T>*>(object);
}
template <class T>
const PodArray<T>* PodArray<T>::cast(const Object* object) {
SLOW_DCHECK(object->IsByteArray());
return reinterpret_cast<const PodArray<T>*>(object);
}
// static
template <class T>
Handle<PodArray<T>> PodArray<T>::New(Isolate* isolate, int length,
PretenureFlag pretenure) {
return Handle<PodArray<T>>::cast(
isolate->factory()->NewByteArray(length * sizeof(T), pretenure));
}
// static
template <class Traits>
STATIC_CONST_MEMBER_DEFINITION const InstanceType
FixedTypedArray<Traits>::kInstanceType;
template <class Traits>
FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) {
SLOW_DCHECK(object->IsHeapObject() &&
HeapObject::cast(object)->map()->instance_type() ==
Traits::kInstanceType);
return reinterpret_cast<FixedTypedArray<Traits>*>(object);
}
template <class Traits>
const FixedTypedArray<Traits>*
FixedTypedArray<Traits>::cast(const Object* object) {
SLOW_DCHECK(object->IsHeapObject() &&
HeapObject::cast(object)->map()->instance_type() ==
Traits::kInstanceType);
return reinterpret_cast<FixedTypedArray<Traits>*>(object);
}
DEFINE_DEOPT_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray)
DEFINE_DEOPT_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi)
DEFINE_DEOPT_ELEMENT_ACCESSORS(LiteralArray, FixedArray)
DEFINE_DEOPT_ELEMENT_ACCESSORS(OsrBytecodeOffset, Smi)
DEFINE_DEOPT_ELEMENT_ACCESSORS(OsrPcOffset, Smi)
DEFINE_DEOPT_ELEMENT_ACCESSORS(OptimizationId, Smi)
DEFINE_DEOPT_ELEMENT_ACCESSORS(WeakCellCache, Object)
DEFINE_DEOPT_ELEMENT_ACCESSORS(InliningPositions, PodArray<InliningPosition>)
DEFINE_DEOPT_ENTRY_ACCESSORS(BytecodeOffsetRaw, Smi)
DEFINE_DEOPT_ENTRY_ACCESSORS(TranslationIndex, Smi)
DEFINE_DEOPT_ENTRY_ACCESSORS(Pc, Smi)
BailoutId DeoptimizationInputData::BytecodeOffset(int i) {
return BailoutId(BytecodeOffsetRaw(i)->value());
}
void DeoptimizationInputData::SetBytecodeOffset(int i, BailoutId value) {
SetBytecodeOffsetRaw(i, Smi::FromInt(value.ToInt()));
}
int DeoptimizationInputData::DeoptCount() {
return (length() - kFirstDeoptEntryIndex) / kDeoptEntrySize;
}
int HandlerTable::GetRangeStart(int index) const {
return Smi::ToInt(get(index * kRangeEntrySize + kRangeStartIndex));
}
int HandlerTable::GetRangeEnd(int index) const {
return Smi::ToInt(get(index * kRangeEntrySize + kRangeEndIndex));
}
int HandlerTable::GetRangeHandler(int index) const {
return HandlerOffsetField::decode(
Smi::ToInt(get(index * kRangeEntrySize + kRangeHandlerIndex)));
}
int HandlerTable::GetRangeData(int index) const {
return Smi::ToInt(get(index * kRangeEntrySize + kRangeDataIndex));
}
void HandlerTable::SetRangeStart(int index, int value) {
set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value));
}
void HandlerTable::SetRangeEnd(int index, int value) {
set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value));
}
void HandlerTable::SetRangeHandler(int index, int offset,
CatchPrediction prediction) {
int value = HandlerOffsetField::encode(offset) |
HandlerPredictionField::encode(prediction);
set(index * kRangeEntrySize + kRangeHandlerIndex, Smi::FromInt(value));
}
void HandlerTable::SetRangeData(int index, int value) {
set(index * kRangeEntrySize + kRangeDataIndex, Smi::FromInt(value));
}
void HandlerTable::SetReturnOffset(int index, int value) {
set(index * kReturnEntrySize + kReturnOffsetIndex, Smi::FromInt(value));
}
void HandlerTable::SetReturnHandler(int index, int offset) {
int value = HandlerOffsetField::encode(offset);
set(index * kReturnEntrySize + kReturnHandlerIndex, Smi::FromInt(value));
}
int HandlerTable::NumberOfRangeEntries() const {
return length() / kRangeEntrySize;
}
template <typename Derived, typename Shape>
HashTable<Derived, Shape>* HashTable<Derived, Shape>::cast(Object* obj) {
SLOW_DCHECK(obj->IsHashTable());
return reinterpret_cast<HashTable*>(obj);
}
template <typename Derived, typename Shape>
const HashTable<Derived, Shape>* HashTable<Derived, Shape>::cast(
const Object* obj) {
SLOW_DCHECK(obj->IsHashTable());
return reinterpret_cast<const HashTable*>(obj);
}
SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
int PropertyArray::length() const {
Object* value_obj = READ_FIELD(this, kLengthAndHashOffset);
int value = Smi::ToInt(value_obj);
return value & kLengthMask;
}
void PropertyArray::initialize_length(int len) {
SLOW_DCHECK(len >= 0);
SLOW_DCHECK(len < kMaxLength);
WRITE_FIELD(this, kLengthAndHashOffset, Smi::FromInt(len));
}
int PropertyArray::synchronized_length() const {
Object* value_obj = ACQUIRE_READ_FIELD(this, kLengthAndHashOffset);
int value = Smi::ToInt(value_obj);
return value & kLengthMask;
}
int PropertyArray::Hash() const {
Object* value_obj = READ_FIELD(this, kLengthAndHashOffset);
int value = Smi::ToInt(value_obj);
int hash = value & kHashMask;
return hash;
}
void PropertyArray::SetHash(int masked_hash) {
DCHECK_EQ(masked_hash & JSReceiver::kHashMask, masked_hash);
Object* value_obj = READ_FIELD(this, kLengthAndHashOffset);
int value = Smi::ToInt(value_obj);
value = (value & kLengthMask) | masked_hash;
WRITE_FIELD(this, kLengthAndHashOffset, Smi::FromInt(value));
}
SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
RELAXED_SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
int FreeSpace::Size() { return size(); }
FreeSpace* FreeSpace::next() {
DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
(!GetHeap()->deserialization_complete() && map() == NULL));
DCHECK_LE(kNextOffset + kPointerSize, relaxed_read_size());
return reinterpret_cast<FreeSpace*>(
Memory::Address_at(address() + kNextOffset));
}
void FreeSpace::set_next(FreeSpace* next) {
DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
(!GetHeap()->deserialization_complete() && map() == NULL));
DCHECK_LE(kNextOffset + kPointerSize, relaxed_read_size());
base::Relaxed_Store(
reinterpret_cast<base::AtomicWord*>(address() + kNextOffset),
reinterpret_cast<base::AtomicWord>(next));
}
FreeSpace* FreeSpace::cast(HeapObject* o) {
SLOW_DCHECK(!o->GetHeap()->deserialization_complete() || o->IsFreeSpace());
return reinterpret_cast<FreeSpace*>(o);
}
int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kPointerSize); }
byte ByteArray::get(int index) const {
DCHECK(index >= 0 && index < this->length());
return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
}
void ByteArray::set(int index, byte value) {
DCHECK(index >= 0 && index < this->length());
WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value);
}
void ByteArray::copy_in(int index, const byte* buffer, int length) {
DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
index + length <= this->length());
byte* dst_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize);
memcpy(dst_addr, buffer, length);
}
void ByteArray::copy_out(int index, byte* buffer, int length) {
DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
index + length <= this->length());
const byte* src_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize);
memcpy(buffer, src_addr, length);
}
int ByteArray::get_int(int index) const {
DCHECK(index >= 0 && index < this->length() / kIntSize);
return READ_INT_FIELD(this, kHeaderSize + index * kIntSize);
}
void ByteArray::set_int(int index, int value) {
DCHECK(index >= 0 && index < this->length() / kIntSize);
WRITE_INT_FIELD(this, kHeaderSize + index * kIntSize, value);
}
uint32_t ByteArray::get_uint32(int index) const {
DCHECK(index >= 0 && index < this->length() / kUInt32Size);
return READ_UINT32_FIELD(this, kHeaderSize + index * kUInt32Size);
}
void ByteArray::set_uint32(int index, uint32_t value) {
DCHECK(index >= 0 && index < this->length() / kUInt32Size);
WRITE_UINT32_FIELD(this, kHeaderSize + index * kUInt32Size, value);
}
void ByteArray::clear_padding() {
int data_size = length() + kHeaderSize;
memset(address() + data_size, 0, Size() - data_size);
}
ByteArray* ByteArray::FromDataStartAddress(Address address) {
DCHECK_TAG_ALIGNED(address);
return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag);
}
int ByteArray::DataSize() const { return RoundUp(length(), kPointerSize); }
int ByteArray::ByteArraySize() { return SizeFor(this->length()); }
Address ByteArray::GetDataStartAddress() {
return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
}
byte BytecodeArray::get(int index) {
DCHECK(index >= 0 && index < this->length());
return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
}
void BytecodeArray::set(int index, byte value) {
DCHECK(index >= 0 && index < this->length());
WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value);
}
void BytecodeArray::set_frame_size(int frame_size) {
DCHECK_GE(frame_size, 0);
DCHECK(IsAligned(frame_size, static_cast<unsigned>(kPointerSize)));
WRITE_INT_FIELD(this, kFrameSizeOffset, frame_size);
}
int BytecodeArray::frame_size() const {
return READ_INT_FIELD(this, kFrameSizeOffset);
}
int BytecodeArray::register_count() const {
return frame_size() / kPointerSize;
}
void BytecodeArray::set_parameter_count(int number_of_parameters) {
DCHECK_GE(number_of_parameters, 0);
// Parameter count is stored as the size on stack of the parameters to allow
// it to be used directly by generated code.
WRITE_INT_FIELD(this, kParameterSizeOffset,
(number_of_parameters << kPointerSizeLog2));
}
interpreter::Register BytecodeArray::incoming_new_target_or_generator_register()
const {
int register_operand =
READ_INT_FIELD(this, kIncomingNewTargetOrGeneratorRegisterOffset);
if (register_operand == 0) {
return interpreter::Register::invalid_value();
} else {
return interpreter::Register::FromOperand(register_operand);
}
}
void BytecodeArray::set_incoming_new_target_or_generator_register(
interpreter::Register incoming_new_target_or_generator_register) {
if (!incoming_new_target_or_generator_register.is_valid()) {
WRITE_INT_FIELD(this, kIncomingNewTargetOrGeneratorRegisterOffset, 0);
} else {
DCHECK(incoming_new_target_or_generator_register.index() <
register_count());
DCHECK_NE(0, incoming_new_target_or_generator_register.ToOperand());
WRITE_INT_FIELD(this, kIncomingNewTargetOrGeneratorRegisterOffset,
incoming_new_target_or_generator_register.ToOperand());
}
}
int BytecodeArray::interrupt_budget() const {
return READ_INT_FIELD(this, kInterruptBudgetOffset);
}
void BytecodeArray::set_interrupt_budget(int interrupt_budget) {
DCHECK_GE(interrupt_budget, 0);
WRITE_INT_FIELD(this, kInterruptBudgetOffset, interrupt_budget);
}
int BytecodeArray::osr_loop_nesting_level() const {
return READ_INT8_FIELD(this, kOSRNestingLevelOffset);
}
void BytecodeArray::set_osr_loop_nesting_level(int depth) {
DCHECK(0 <= depth && depth <= AbstractCode::kMaxLoopNestingMarker);
STATIC_ASSERT(AbstractCode::kMaxLoopNestingMarker < kMaxInt8);
WRITE_INT8_FIELD(this, kOSRNestingLevelOffset, depth);
}
BytecodeArray::Age BytecodeArray::bytecode_age() const {
// Bytecode is aged by the concurrent marker.
return static_cast<Age>(RELAXED_READ_INT8_FIELD(this, kBytecodeAgeOffset));
}
void BytecodeArray::set_bytecode_age(BytecodeArray::Age age) {
DCHECK_GE(age, kFirstBytecodeAge);
DCHECK_LE(age, kLastBytecodeAge);
STATIC_ASSERT(kLastBytecodeAge <= kMaxInt8);
// Bytecode is aged by the concurrent marker.
RELAXED_WRITE_INT8_FIELD(this, kBytecodeAgeOffset, static_cast<int8_t>(age));
}
int BytecodeArray::parameter_count() const {
// Parameter count is stored as the size on stack of the parameters to allow
// it to be used directly by generated code.
return READ_INT_FIELD(this, kParameterSizeOffset) >> kPointerSizeLog2;
}
ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset)
ACCESSORS(BytecodeArray, handler_table, FixedArray, kHandlerTableOffset)
ACCESSORS(BytecodeArray, source_position_table, Object,
kSourcePositionTableOffset)
void BytecodeArray::clear_padding() {
int data_size = kHeaderSize + length();
memset(address() + data_size, 0, SizeFor(length()) - data_size);
}
Address BytecodeArray::GetFirstBytecodeAddress() {
return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
}
ByteArray* BytecodeArray::SourcePositionTable() {
Object* maybe_table = source_position_table();
if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table);
DCHECK(maybe_table->IsSourcePositionTableWithFrameCache());
return SourcePositionTableWithFrameCache::cast(maybe_table)
->source_position_table();
}
int BytecodeArray::BytecodeArraySize() { return SizeFor(this->length()); }
int BytecodeArray::SizeIncludingMetadata() {
int size = BytecodeArraySize();
size += constant_pool()->Size();
size += handler_table()->Size();
size += SourcePositionTable()->Size();
return size;
}
ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset)
void* FixedTypedArrayBase::external_pointer() const {
intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
return reinterpret_cast<void*>(ptr);
}
void FixedTypedArrayBase::set_external_pointer(void* value,
WriteBarrierMode mode) {
intptr_t ptr = reinterpret_cast<intptr_t>(value);
WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr);
}
void* FixedTypedArrayBase::DataPtr() {
return reinterpret_cast<void*>(
reinterpret_cast<intptr_t>(base_pointer()) +
reinterpret_cast<intptr_t>(external_pointer()));
}
int FixedTypedArrayBase::ElementSize(InstanceType type) {
int element_size;
switch (type) {
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case FIXED_##TYPE##_ARRAY_TYPE: \
element_size = size; \
break;
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
default:
UNREACHABLE();
}
return element_size;
}
int FixedTypedArrayBase::DataSize(InstanceType type) const {
if (base_pointer() == Smi::kZero) return 0;
return length() * ElementSize(type);
}
int FixedTypedArrayBase::DataSize() const {
return DataSize(map()->instance_type());
}
size_t FixedTypedArrayBase::ByteLength() const {
return static_cast<size_t>(length()) *
static_cast<size_t>(ElementSize(map()->instance_type()));
}
int FixedTypedArrayBase::size() const {
return OBJECT_POINTER_ALIGN(kDataOffset + DataSize());
}
int FixedTypedArrayBase::TypedArraySize(InstanceType type) const {
return OBJECT_POINTER_ALIGN(kDataOffset + DataSize(type));
}
// static
int FixedTypedArrayBase::TypedArraySize(InstanceType type, int length) {
return OBJECT_POINTER_ALIGN(kDataOffset + length * ElementSize(type));
}
uint8_t Uint8ArrayTraits::defaultValue() { return 0; }
uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; }
int8_t Int8ArrayTraits::defaultValue() { return 0; }
uint16_t Uint16ArrayTraits::defaultValue() { return 0; }
int16_t Int16ArrayTraits::defaultValue() { return 0; }
uint32_t Uint32ArrayTraits::defaultValue() { return 0; }
int32_t Int32ArrayTraits::defaultValue() { return 0; }
float Float32ArrayTraits::defaultValue() {
return std::numeric_limits<float>::quiet_NaN();
}
double Float64ArrayTraits::defaultValue() {
return std::numeric_limits<double>::quiet_NaN();
}
template <class Traits>
typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) {
DCHECK((index >= 0) && (index < this->length()));
// The JavaScript memory model allows for racy reads and writes to a
// SharedArrayBuffer's backing store, which will always be a FixedTypedArray.
// ThreadSanitizer will catch these racy accesses and warn about them, so we
// disable TSAN for these reads and writes using annotations.
//
// We don't use relaxed atomics here, as it is not a requirement of the
// JavaScript memory model to have tear-free reads of overlapping accesses,
// and using relaxed atomics may introduce overhead.
auto* ptr = reinterpret_cast<ElementType*>(DataPtr());
TSAN_ANNOTATE_IGNORE_READS_BEGIN;
auto result = ptr[index];
TSAN_ANNOTATE_IGNORE_READS_END;
return result;
}
template <class Traits>
void FixedTypedArray<Traits>::set(int index, ElementType value) {
CHECK((index >= 0) && (index < this->length()));
// See the comment in FixedTypedArray<Traits>::get_scalar.
auto* ptr = reinterpret_cast<ElementType*>(DataPtr());
TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
ptr[index] = value;
TSAN_ANNOTATE_IGNORE_WRITES_END;
}
template <class Traits>
typename Traits::ElementType FixedTypedArray<Traits>::from(int value) {
return static_cast<ElementType>(value);
}
template <>
inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(int value) {
if (value < 0) return 0;
if (value > 0xFF) return 0xFF;
return static_cast<uint8_t>(value);
}
template <class Traits>
typename Traits::ElementType FixedTypedArray<Traits>::from(uint32_t value) {
return static_cast<ElementType>(value);
}
template <>
inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(uint32_t value) {
// We need this special case for Uint32 -> Uint8Clamped, because the highest
// Uint32 values will be negative as an int, clamping to 0, rather than 255.
if (value > 0xFF) return 0xFF;
return static_cast<uint8_t>(value);
}
template <class Traits>
typename Traits::ElementType FixedTypedArray<Traits>::from(double value) {
return static_cast<ElementType>(DoubleToInt32(value));
}
template <>
inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(double value) {
// Handle NaNs and less than zero values which clamp to zero.
if (!(value > 0)) return 0;
if (value > 0xFF) return 0xFF;
return static_cast<uint8_t>(lrint(value));
}
template <>
inline float FixedTypedArray<Float32ArrayTraits>::from(double value) {
return static_cast<float>(value);
}
template <>
inline double FixedTypedArray<Float64ArrayTraits>::from(double value) {
return value;
}
template <class Traits>
Handle<Object> FixedTypedArray<Traits>::get(FixedTypedArray<Traits>* array,
int index) {
return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index));
}
template <class Traits>
void FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) {
ElementType cast_value = Traits::defaultValue();
if (value->IsSmi()) {
int int_value = Smi::ToInt(value);
cast_value = from(int_value);
} else if (value->IsHeapNumber()) {
double double_value = HeapNumber::cast(value)->value();
cast_value = from(double_value);
} else {
// Clamp undefined to the default value. All other types have been
// converted to a number type further up in the call chain.
DCHECK(value->IsUndefined(GetIsolate()));
}
set(index, cast_value);
}
Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) {
return handle(Smi::FromInt(scalar), isolate);
}
Handle<Object> Uint8ClampedArrayTraits::ToHandle(Isolate* isolate,
uint8_t scalar) {
return handle(Smi::FromInt(scalar), isolate);
}
Handle<Object> Int8ArrayTraits::ToHandle(Isolate* isolate, int8_t scalar) {
return handle(Smi::FromInt(scalar), isolate);
}
Handle<Object> Uint16ArrayTraits::ToHandle(Isolate* isolate, uint16_t scalar) {
return handle(Smi::FromInt(scalar), isolate);
}
Handle<Object> Int16ArrayTraits::ToHandle(Isolate* isolate, int16_t scalar) {
return handle(Smi::FromInt(scalar), isolate);
}
Handle<Object> Uint32ArrayTraits::ToHandle(Isolate* isolate, uint32_t scalar) {
return isolate->factory()->NewNumberFromUint(scalar);
}
Handle<Object> Int32ArrayTraits::ToHandle(Isolate* isolate, int32_t scalar) {
return isolate->factory()->NewNumberFromInt(scalar);
}
Handle<Object> Float32ArrayTraits::ToHandle(Isolate* isolate, float scalar) {
return isolate->factory()->NewNumber(scalar);
}
Handle<Object> Float64ArrayTraits::ToHandle(Isolate* isolate, double scalar) {
return isolate->factory()->NewNumber(scalar);
}
int Map::visitor_id() const { return READ_BYTE_FIELD(this, kVisitorIdOffset); }
void Map::set_visitor_id(int id) {
DCHECK_LE(0, id);
DCHECK_LT(id, 256);
WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id));
}
int Map::instance_size() const {
return RELAXED_READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2;
}
int Map::inobject_properties_or_constructor_function_index() const {
return RELAXED_READ_BYTE_FIELD(
this, kInObjectPropertiesOrConstructorFunctionIndexOffset);
}
void Map::set_inobject_properties_or_constructor_function_index(int value) {
DCHECK_LE(0, value);
DCHECK_LT(value, 256);
RELAXED_WRITE_BYTE_FIELD(this,
kInObjectPropertiesOrConstructorFunctionIndexOffset,
static_cast<byte>(value));
}
int Map::GetInObjectProperties() const {
DCHECK(IsJSObjectMap());
return inobject_properties_or_constructor_function_index();
}
void Map::SetInObjectProperties(int value) {
DCHECK(IsJSObjectMap());
set_inobject_properties_or_constructor_function_index(value);
}
int Map::GetConstructorFunctionIndex() const {
DCHECK(IsPrimitiveMap());
return inobject_properties_or_constructor_function_index();
}
void Map::SetConstructorFunctionIndex(int value) {
DCHECK(IsPrimitiveMap());
set_inobject_properties_or_constructor_function_index(value);
}
int Map::GetInObjectPropertyOffset(int index) const {
// Adjust for the number of properties stored in the object.
index -= GetInObjectProperties();
DCHECK(index <= 0);
return instance_size() + (index * kPointerSize);
}
Handle<Map> Map::AddMissingTransitionsForTesting(
Handle<Map> split_map, Handle<DescriptorArray> descriptors,
Handle<LayoutDescriptor> full_layout_descriptor) {
return AddMissingTransitions(split_map, descriptors, full_layout_descriptor);
}
int HeapObject::SizeFromMap(Map* map) const {
int instance_size = map->instance_size();
if (instance_size != kVariableSizeSentinel) return instance_size;
// Only inline the most frequent cases.
InstanceType instance_type = map->instance_type();
if (instance_type == FIXED_ARRAY_TYPE || instance_type == HASH_TABLE_TYPE ||
instance_type == TRANSITION_ARRAY_TYPE) {
return FixedArray::SizeFor(
reinterpret_cast<const FixedArray*>(this)->synchronized_length());
}
if (instance_type == ONE_BYTE_STRING_TYPE ||
instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) {
// Strings may get concurrently truncated, hence we have to access its
// length synchronized.
return SeqOneByteString::SizeFor(
reinterpret_cast<const SeqOneByteString*>(this)->synchronized_length());
}
if (instance_type == BYTE_ARRAY_TYPE) {
return ByteArray::SizeFor(
reinterpret_cast<const ByteArray*>(this)->synchronized_length());
}
if (instance_type == BYTECODE_ARRAY_TYPE) {
return BytecodeArray::SizeFor(
reinterpret_cast<const BytecodeArray*>(this)->synchronized_length());
}
if (instance_type == FREE_SPACE_TYPE) {
return reinterpret_cast<const FreeSpace*>(this)->relaxed_read_size();
}
if (instance_type == STRING_TYPE ||
instance_type == INTERNALIZED_STRING_TYPE) {
// Strings may get concurrently truncated, hence we have to access its
// length synchronized.
return SeqTwoByteString::SizeFor(
reinterpret_cast<const SeqTwoByteString*>(this)->synchronized_length());
}
if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
return FixedDoubleArray::SizeFor(
reinterpret_cast<const FixedDoubleArray*>(this)->synchronized_length());
}
if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE &&
instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) {
return reinterpret_cast<const FixedTypedArrayBase*>(this)->TypedArraySize(
instance_type);
}
if (instance_type == SMALL_ORDERED_HASH_SET_TYPE) {
return reinterpret_cast<const SmallOrderedHashSet*>(this)->Size();
}
if (instance_type == PROPERTY_ARRAY_TYPE) {
return PropertyArray::SizeFor(
reinterpret_cast<const PropertyArray*>(this)->synchronized_length());
}
if (instance_type == SMALL_ORDERED_HASH_MAP_TYPE) {
return reinterpret_cast<const SmallOrderedHashMap*>(this)->Size();
}
if (instance_type == FEEDBACK_VECTOR_TYPE) {
return FeedbackVector::SizeFor(
reinterpret_cast<const FeedbackVector*>(this)->length());
}
DCHECK(instance_type == CODE_TYPE);
return reinterpret_cast<const Code*>(this)->CodeSize();
}
void Map::set_instance_size(int value) {
DCHECK_EQ(0, value & (kPointerSize - 1));
value >>= kPointerSizeLog2;
DCHECK(0 <= value && value < 256);
RELAXED_WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value));
}
void Map::clear_unused() { WRITE_BYTE_FIELD(this, kUnusedOffset, 0); }
InstanceType Map::instance_type() const {
return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset));
}
void Map::set_instance_type(InstanceType value) {
WRITE_BYTE_FIELD(this, kInstanceTypeOffset, value);
}
int Map::unused_property_fields() const {
return READ_BYTE_FIELD(this, kUnusedPropertyFieldsOffset);
}
void Map::set_unused_property_fields(int value) {
WRITE_BYTE_FIELD(this, kUnusedPropertyFieldsOffset, Min(value, 255));
}
byte Map::bit_field() const { return READ_BYTE_FIELD(this, kBitFieldOffset); }
void Map::set_bit_field(byte value) {
WRITE_BYTE_FIELD(this, kBitFieldOffset, value);
}
byte Map::bit_field2() const { return READ_BYTE_FIELD(this, kBitField2Offset); }
void Map::set_bit_field2(byte value) {
WRITE_BYTE_FIELD(this, kBitField2Offset, value);
}
void Map::set_non_instance_prototype(bool value) {
if (value) {
set_bit_field(bit_field() | (1 << kHasNonInstancePrototype));
} else {
set_bit_field(bit_field() & ~(1 << kHasNonInstancePrototype));
}
}
bool Map::has_non_instance_prototype() const {
return ((1 << kHasNonInstancePrototype) & bit_field()) != 0;
}
void Map::set_is_constructor(bool value) {
if (value) {
set_bit_field(bit_field() | (1 << kIsConstructor));
} else {
set_bit_field(bit_field() & ~(1 << kIsConstructor));
}
}
bool Map::is_constructor() const {
return ((1 << kIsConstructor) & bit_field()) != 0;
}
void Map::set_has_hidden_prototype(bool value) {
set_bit_field3(HasHiddenPrototype::update(bit_field3(), value));
}
bool Map::has_hidden_prototype() const {
return HasHiddenPrototype::decode(bit_field3());
}
void Map::set_has_indexed_interceptor() {
set_bit_field(bit_field() | (1 << kHasIndexedInterceptor));
}
bool Map::has_indexed_interceptor() const {
return ((1 << kHasIndexedInterceptor) & bit_field()) != 0;
}
void Map::set_is_undetectable() {
set_bit_field(bit_field() | (1 << kIsUndetectable));
}
bool Map::is_undetectable() const {
return ((1 << kIsUndetectable) & bit_field()) != 0;
}
void Map::set_has_named_interceptor() {
set_bit_field(bit_field() | (1 << kHasNamedInterceptor));
}
bool Map::has_named_interceptor() const {
return ((1 << kHasNamedInterceptor) & bit_field()) != 0;
}
void Map::set_is_access_check_needed(bool access_check_needed) {
if (access_check_needed) {
set_bit_field(bit_field() | (1 << kIsAccessCheckNeeded));
} else {
set_bit_field(bit_field() & ~(1 << kIsAccessCheckNeeded));
}
}
bool Map::is_access_check_needed() const {
return ((1 << kIsAccessCheckNeeded) & bit_field()) != 0;
}
void Map::set_is_extensible(bool value) {
if (value) {
set_bit_field2(bit_field2() | (1 << kIsExtensible));
} else {
set_bit_field2(bit_field2() & ~(1 << kIsExtensible));
}
}
bool Map::is_extensible() const {
return ((1 << kIsExtensible) & bit_field2()) != 0;
}
void Map::set_is_prototype_map(bool value) {
set_bit_field2(IsPrototypeMapBits::update(bit_field2(), value));
}
bool Map::is_prototype_map() const {
return IsPrototypeMapBits::decode(bit_field2());
}
bool Map::is_abandoned_prototype_map() const {
return is_prototype_map() && !owns_descriptors();
}
bool Map::should_be_fast_prototype_map() const {
if (!prototype_info()->IsPrototypeInfo()) return false;
return PrototypeInfo::cast(prototype_info())->should_be_fast_map();
}
void Map::set_elements_kind(ElementsKind elements_kind) {
DCHECK(static_cast<int>(elements_kind) < kElementsKindCount);
DCHECK(kElementsKindCount <= (1 << Map::ElementsKindBits::kSize));
set_bit_field2(Map::ElementsKindBits::update(bit_field2(), elements_kind));
DCHECK(this->elements_kind() == elements_kind);
}
ElementsKind Map::elements_kind() const {
return Map::ElementsKindBits::decode(bit_field2());
}
bool Map::has_fast_smi_elements() const {
return IsSmiElementsKind(elements_kind());
}
bool Map::has_fast_object_elements() const {
return IsObjectElementsKind(elements_kind());
}
bool Map::has_fast_smi_or_object_elements() const {
return IsSmiOrObjectElementsKind(elements_kind());
}
bool Map::has_fast_double_elements() const {
return IsDoubleElementsKind(elements_kind());
}
bool Map::has_fast_elements() const {
return IsFastElementsKind(elements_kind());
}
bool Map::has_sloppy_arguments_elements() const {
return IsSloppyArgumentsElementsKind(elements_kind());
}
bool Map::has_fast_sloppy_arguments_elements() const {
return elements_kind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS;
}
bool Map::has_fast_string_wrapper_elements() const {
return elements_kind() == FAST_STRING_WRAPPER_ELEMENTS;
}
bool Map::has_fixed_typed_array_elements() const {
return IsFixedTypedArrayElementsKind(elements_kind());
}
bool Map::has_dictionary_elements() const {
return IsDictionaryElementsKind(elements_kind());
}
void Map::set_dictionary_map(bool value) {
uint32_t new_bit_field3 = DictionaryMap::update(bit_field3(), value);
new_bit_field3 = IsUnstable::update(new_bit_field3, value);
set_bit_field3(new_bit_field3);
}
bool Map::is_dictionary_map() const {
return DictionaryMap::decode(bit_field3());
}
Code::Flags Code::flags() const {
return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset));
}
void Map::set_owns_descriptors(bool owns_descriptors) {
set_bit_field3(OwnsDescriptors::update(bit_field3(), owns_descriptors));
}
bool Map::owns_descriptors() const {
return OwnsDescriptors::decode(bit_field3());
}
void Map::set_is_callable() { set_bit_field(bit_field() | (1 << kIsCallable)); }
bool Map::is_callable() const {
return ((1 << kIsCallable) & bit_field()) != 0;
}
void Map::deprecate() {
set_bit_field3(Deprecated::update(bit_field3(), true));
}
bool Map::is_deprecated() const { return Deprecated::decode(bit_field3()); }
void Map::set_migration_target(bool value) {
set_bit_field3(IsMigrationTarget::update(bit_field3(), value));
}
bool Map::is_migration_target() const {
return IsMigrationTarget::decode(bit_field3());
}
void Map::set_immutable_proto(bool value) {
set_bit_field3(ImmutablePrototype::update(bit_field3(), value));
}
bool Map::is_immutable_proto() const {
return ImmutablePrototype::decode(bit_field3());
}
void Map::set_new_target_is_base(bool value) {
set_bit_field3(NewTargetIsBase::update(bit_field3(), value));
}
bool Map::new_target_is_base() const {
return NewTargetIsBase::decode(bit_field3());
}
void Map::set_may_have_interesting_symbols(bool value) {
set_bit_field3(MayHaveInterestingSymbols::update(bit_field3(), value));
}
bool Map::may_have_interesting_symbols() const {
return MayHaveInterestingSymbols::decode(bit_field3());
}
void Map::set_construction_counter(int value) {
set_bit_field3(ConstructionCounter::update(bit_field3(), value));
}
int Map::construction_counter() const {
return ConstructionCounter::decode(bit_field3());
}
void Map::mark_unstable() {
set_bit_field3(IsUnstable::update(bit_field3(), true));
}
bool Map::is_stable() const { return !IsUnstable::decode(bit_field3()); }
bool Map::CanBeDeprecated() const {
int descriptor = LastAdded();
for (int i = 0; i <= descriptor; i++) {
PropertyDetails details = instance_descriptors()->GetDetails(i);
if (details.representation().IsNone()) return true;
if (details.representation().IsSmi()) return true;
if (details.representation().IsDouble()) return true;
if (details.representation().IsHeapObject()) return true;
if (details.kind() == kData && details.location() == kDescriptor) {
return true;
}
}
return false;
}
void Map::NotifyLeafMapLayoutChange() {
if (is_stable()) {
mark_unstable();
dependent_code()->DeoptimizeDependentCodeGroup(
GetIsolate(),
DependentCode::kPrototypeCheckGroup);
}
}
bool Map::CanTransition() const {
// Only JSObject and subtypes have map transitions and back pointers.
STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
return instance_type() >= FIRST_JS_OBJECT_TYPE;
}
bool Map::IsBooleanMap() const { return this == GetHeap()->boolean_map(); }
bool Map::IsPrimitiveMap() const {
STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE);
return instance_type() <= LAST_PRIMITIVE_TYPE;
}
bool Map::IsJSReceiverMap() const {
STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
return instance_type() >= FIRST_JS_RECEIVER_TYPE;
}
bool Map::IsJSObjectMap() const {
STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
return instance_type() >= FIRST_JS_OBJECT_TYPE;
}
bool Map::IsJSArrayMap() const { return instance_type() == JS_ARRAY_TYPE; }
bool Map::IsJSFunctionMap() const {
return instance_type() == JS_FUNCTION_TYPE;
}
bool Map::IsStringMap() const { return instance_type() < FIRST_NONSTRING_TYPE; }
bool Map::IsJSProxyMap() const { return instance_type() == JS_PROXY_TYPE; }
bool Map::IsJSGlobalProxyMap() const {
return instance_type() == JS_GLOBAL_PROXY_TYPE;
}
bool Map::IsJSGlobalObjectMap() const {
return instance_type() == JS_GLOBAL_OBJECT_TYPE;
}
bool Map::IsJSTypedArrayMap() const {
return instance_type() == JS_TYPED_ARRAY_TYPE;
}
bool Map::IsJSDataViewMap() const {
return instance_type() == JS_DATA_VIEW_TYPE;
}
bool Map::IsSpecialReceiverMap() const {
bool result = IsSpecialReceiverInstanceType(instance_type());
DCHECK_IMPLIES(!result,
!has_named_interceptor() && !is_access_check_needed());
return result;
}
DependentCode* DependentCode::next_link() {
return DependentCode::cast(get(kNextLinkIndex));
}
void DependentCode::set_next_link(DependentCode* next) {
set(kNextLinkIndex, next);
}
int DependentCode::flags() { return Smi::ToInt(get(kFlagsIndex)); }
void DependentCode::set_flags(int flags) {
set(kFlagsIndex, Smi::FromInt(flags));
}
int DependentCode::count() { return CountField::decode(flags()); }
void DependentCode::set_count(int value) {
set_flags(CountField::update(flags(), value));
}
DependentCode::DependencyGroup DependentCode::group() {
return static_cast<DependencyGroup>(GroupField::decode(flags()));
}
void DependentCode::set_group(DependentCode::DependencyGroup group) {
set_flags(GroupField::update(flags(), static_cast<int>(group)));
}
void DependentCode::set_object_at(int i, Object* object) {
set(kCodesStartIndex + i, object);
}
Object* DependentCode::object_at(int i) {
return get(kCodesStartIndex + i);
}
void DependentCode::clear_at(int i) {
set_undefined(kCodesStartIndex + i);
}
void DependentCode::copy(int from, int to) {
set(kCodesStartIndex + to, get(kCodesStartIndex + from));
}
void Code::set_flags(Code::Flags flags) {
STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1);
WRITE_INT_FIELD(this, kFlagsOffset, flags);
}
Code::Kind Code::kind() const { return ExtractKindFromFlags(flags()); }
bool Code::IsCodeStubOrIC() const {
switch (kind()) {
case STUB:
case HANDLER:
#define CASE_KIND(kind) case kind:
IC_KIND_LIST(CASE_KIND)
#undef CASE_KIND
return true;
default:
return false;
}
}
// For initialization.
void Code::set_raw_kind_specific_flags1(int value) {
WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value);
}
void Code::set_raw_kind_specific_flags2(int value) {
WRITE_INT_FIELD(this, kKindSpecificFlags2Offset, value);
}
inline bool Code::is_interpreter_trampoline_builtin() const {
Builtins* builtins = GetIsolate()->builtins();
bool is_interpreter_trampoline =
(this == builtins->builtin(Builtins::kInterpreterEntryTrampoline) ||
this == builtins->builtin(Builtins::kInterpreterEnterBytecodeAdvance) ||
this == builtins->builtin(Builtins::kInterpreterEnterBytecodeDispatch));
DCHECK_IMPLIES(is_interpreter_trampoline, !Builtins::IsLazy(builtin_index()));
return is_interpreter_trampoline;
}
inline bool Code::checks_optimization_marker() const {
Builtins* builtins = GetIsolate()->builtins();
bool checks_marker =
(this == builtins->builtin(Builtins::kCompileLazy) ||
this == builtins->builtin(Builtins::kInterpreterEntryTrampoline) ||
this == builtins->builtin(Builtins::kCheckOptimizationMarker));
DCHECK_IMPLIES(checks_marker, !Builtins::IsLazy(builtin_index()));
return checks_marker ||
(kind() == OPTIMIZED_FUNCTION && marked_for_deoptimization());
}
inline bool Code::has_unwinding_info() const {
return HasUnwindingInfoField::decode(READ_UINT32_FIELD(this, kFlagsOffset));
}
inline void Code::set_has_unwinding_info(bool state) {
uint32_t previous = READ_UINT32_FIELD(this, kFlagsOffset);
uint32_t updated_value = HasUnwindingInfoField::update(previous, state);
WRITE_UINT32_FIELD(this, kFlagsOffset, updated_value);
}
inline bool Code::has_tagged_params() const {
int flags = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
return HasTaggedStackField::decode(flags);
}
inline void Code::set_has_tagged_params(bool value) {
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
int updated = HasTaggedStackField::update(previous, value);
WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
}
inline bool Code::is_turbofanned() const {
return IsTurbofannedField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
}
inline void Code::set_is_turbofanned(bool value) {
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
int updated = IsTurbofannedField::update(previous, value);
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
inline bool Code::can_have_weak_objects() const {
DCHECK(kind() == OPTIMIZED_FUNCTION);
return CanHaveWeakObjectsField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
}
inline void Code::set_can_have_weak_objects(bool value) {
DCHECK(kind() == OPTIMIZED_FUNCTION);
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
int updated = CanHaveWeakObjectsField::update(previous, value);
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
inline bool Code::is_construct_stub() const {
DCHECK(kind() == BUILTIN);
return IsConstructStubField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
}
inline void Code::set_is_construct_stub(bool value) {
DCHECK(kind() == BUILTIN);
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
int updated = IsConstructStubField::update(previous, value);
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
inline bool Code::is_promise_rejection() const {
DCHECK(kind() == BUILTIN);
return IsPromiseRejectionField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
}
inline void Code::set_is_promise_rejection(bool value) {
DCHECK(kind() == BUILTIN);
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
int updated = IsPromiseRejectionField::update(previous, value);
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
inline bool Code::is_exception_caught() const {
DCHECK(kind() == BUILTIN);
return IsExceptionCaughtField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
}
inline void Code::set_is_exception_caught(bool value) {
DCHECK(kind() == BUILTIN);
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
int updated = IsExceptionCaughtField::update(previous, value);
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
inline HandlerTable::CatchPrediction Code::GetBuiltinCatchPrediction() {
if (is_promise_rejection()) return HandlerTable::PROMISE;
if (is_exception_caught()) return HandlerTable::CAUGHT;
return HandlerTable::UNCAUGHT;
}
int Code::builtin_index() const {
int index = READ_INT_FIELD(this, kBuiltinIndexOffset);
DCHECK(index == -1 || Builtins::IsBuiltinId(index));
return index;
}
void Code::set_builtin_index(int index) {
DCHECK(index == -1 || Builtins::IsBuiltinId(index));
WRITE_INT_FIELD(this, kBuiltinIndexOffset, index);
}
bool Code::is_builtin() const { return builtin_index() != -1; }
unsigned Code::stack_slots() const {
DCHECK(is_turbofanned());
return StackSlotsField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
}
void Code::set_stack_slots(unsigned slots) {
CHECK(slots <= (1 << kStackSlotsBitCount));
DCHECK(is_turbofanned());
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
int updated = StackSlotsField::update(previous, slots);
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
unsigned Code::safepoint_table_offset() const {
DCHECK(is_turbofanned());
return SafepointTableOffsetField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags2Offset));
}
void Code::set_safepoint_table_offset(unsigned offset) {
CHECK(offset <= (1 << kSafepointTableOffsetBitCount));
DCHECK(is_turbofanned());
DCHECK(IsAligned(offset, static_cast<unsigned>(kIntSize)));
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
int updated = SafepointTableOffsetField::update(previous, offset);
WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
}
bool Code::marked_for_deoptimization() const {
DCHECK(kind() == OPTIMIZED_FUNCTION);
return MarkedForDeoptimizationField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
}
void Code::set_marked_for_deoptimization(bool flag) {
DCHECK(kind() == OPTIMIZED_FUNCTION);
DCHECK_IMPLIES(flag, AllowDeoptimization::IsAllowed(GetIsolate()));
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
int updated = MarkedForDeoptimizationField::update(previous, flag);
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
bool Code::deopt_already_counted() const {
DCHECK(kind() == OPTIMIZED_FUNCTION);
return DeoptAlreadyCountedField::decode(
READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
}
void Code::set_deopt_already_counted(bool flag) {
DCHECK(kind() == OPTIMIZED_FUNCTION);
DCHECK_IMPLIES(flag, AllowDeoptimization::IsAllowed(GetIsolate()));
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
int updated = DeoptAlreadyCountedField::update(previous, flag);
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
bool Code::is_inline_cache_stub() const {
Kind kind = this->kind();
switch (kind) {
#define CASE(name) case name: return true;
IC_KIND_LIST(CASE)
#undef CASE
default: return false;
}
}
bool Code::is_handler() const { return kind() == HANDLER; }
bool Code::is_stub() const { return kind() == STUB; }
bool Code::is_optimized_code() const { return kind() == OPTIMIZED_FUNCTION; }
bool Code::is_wasm_code() const { return kind() == WASM_FUNCTION; }
Address Code::constant_pool() {
Address constant_pool = NULL;
if (FLAG_enable_embedded_constant_pool) {
int offset = constant_pool_offset();
if (offset < instruction_size()) {
constant_pool = FIELD_ADDR(this, kHeaderSize + offset);
}
}
return constant_pool;
}
Code::Flags Code::ComputeFlags(Kind kind, ExtraICState extra_ic_state) {
// Compute the bit mask.
unsigned int bits =
KindField::encode(kind) | ExtraICStateField::encode(extra_ic_state);
return static_cast<Flags>(bits);
}
Code::Flags Code::ComputeHandlerFlags(Kind handler_kind) {
return ComputeFlags(Code::HANDLER, handler_kind);
}
Code::Kind Code::ExtractKindFromFlags(Flags flags) {
return KindField::decode(flags);
}
ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) {
return ExtraICStateField::decode(flags);
}
Code* Code::GetCodeFromTargetAddress(Address address) {
HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize);
// GetCodeFromTargetAddress might be called when marking objects during mark
// sweep. reinterpret_cast is therefore used instead of the more appropriate
// Code::cast. Code::cast does not work when the object's map is
// marked.
Code* result = reinterpret_cast<Code*>(code);
return result;
}
Object* Code::GetObjectFromCodeEntry(Address code_entry) {
return HeapObject::FromAddress(code_entry - Code::kHeaderSize);
}
Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
return GetObjectFromCodeEntry(Memory::Address_at(location_of_address));
}
bool Code::CanContainWeakObjects() {
return is_optimized_code() && can_have_weak_objects();
}
bool Code::IsWeakObject(Object* object) {
return (CanContainWeakObjects() && IsWeakObjectInOptimizedCode(object));
}
bool Code::IsWeakObjectInOptimizedCode(Object* object) {
if (object->IsMap()) {
return Map::cast(object)->CanTransition();
}
if (object->IsCell()) {
object = Cell::cast(object)->value();
} else if (object->IsPropertyCell()) {
object = PropertyCell::cast(object)->value();
}
if (object->IsJSReceiver() || object->IsContext()) {
return true;
}
return false;
}
int AbstractCode::instruction_size() {
if (IsCode()) {
return GetCode()->instruction_size();
} else {
return GetBytecodeArray()->length();
}
}
ByteArray* AbstractCode::source_position_table() {
if (IsCode()) {
return GetCode()->SourcePositionTable();
} else {
return GetBytecodeArray()->SourcePositionTable();
}
}
void AbstractCode::set_source_position_table(ByteArray* source_position_table) {
if (IsCode()) {
GetCode()->set_source_position_table(source_position_table);
} else {
GetBytecodeArray()->set_source_position_table(source_position_table);
}
}
Object* AbstractCode::stack_frame_cache() {
Object* maybe_table;
if (IsCode()) {
maybe_table = GetCode()->source_position_table();
} else {
maybe_table = GetBytecodeArray()->source_position_table();
}
if (maybe_table->IsSourcePositionTableWithFrameCache()) {
return SourcePositionTableWithFrameCache::cast(maybe_table)
->stack_frame_cache();
}
return Smi::kZero;
}
int AbstractCode::SizeIncludingMetadata() {
if (IsCode()) {
return GetCode()->SizeIncludingMetadata();
} else {
return GetBytecodeArray()->SizeIncludingMetadata();
}
}
int AbstractCode::ExecutableSize() {
if (IsCode()) {
return GetCode()->ExecutableSize();
} else {
return GetBytecodeArray()->BytecodeArraySize();
}
}
Address AbstractCode::instruction_start() {
if (IsCode()) {
return GetCode()->instruction_start();
} else {
return GetBytecodeArray()->GetFirstBytecodeAddress();
}
}
Address AbstractCode::instruction_end() {
if (IsCode()) {
return GetCode()->instruction_end();
} else {
return GetBytecodeArray()->GetFirstBytecodeAddress() +
GetBytecodeArray()->length();
}
}
bool AbstractCode::contains(byte* inner_pointer) {
return (address() <= inner_pointer) && (inner_pointer <= address() + Size());
}
AbstractCode::Kind AbstractCode::kind() {
if (IsCode()) {
return static_cast<AbstractCode::Kind>(GetCode()->kind());
} else {
return INTERPRETED_FUNCTION;
}
}
Code* AbstractCode::GetCode() { return Code::cast(this); }
BytecodeArray* AbstractCode::GetBytecodeArray() {
return BytecodeArray::cast(this);
}
Object* Map::prototype() const {
return READ_FIELD(this, kPrototypeOffset);
}
void Map::set_prototype(Object* value, WriteBarrierMode mode) {
DCHECK(value->IsNull(GetIsolate()) || value->IsJSReceiver());
WRITE_FIELD(this, kPrototypeOffset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode);
}
LayoutDescriptor* Map::layout_descriptor_gc_safe() const {
Object* layout_desc = RELAXED_READ_FIELD(this, kLayoutDescriptorOffset);
return LayoutDescriptor::cast_gc_safe(layout_desc);
}
bool Map::HasFastPointerLayout() const {
Object* layout_desc = RELAXED_READ_FIELD(this, kLayoutDescriptorOffset);
return LayoutDescriptor::IsFastPointerLayout(layout_desc);
}
void Map::UpdateDescriptors(DescriptorArray* descriptors,
LayoutDescriptor* layout_desc) {
set_instance_descriptors(descriptors);
if (FLAG_unbox_double_fields) {
if (layout_descriptor()->IsSlowLayout()) {
set_layout_descriptor(layout_desc);
}
#ifdef VERIFY_HEAP
// TODO(ishell): remove these checks from VERIFY_HEAP mode.
if (FLAG_verify_heap) {
CHECK(layout_descriptor()->IsConsistentWithMap(this));
CHECK(visitor_id() == Map::GetVisitorId(this));
}
#else
SLOW_DCHECK(layout_descriptor()->IsConsistentWithMap(this));
DCHECK(visitor_id() == Map::GetVisitorId(this));
#endif
}
}
void Map::InitializeDescriptors(DescriptorArray* descriptors,
LayoutDescriptor* layout_desc) {
int len = descriptors->number_of_descriptors();
set_instance_descriptors(descriptors);
SetNumberOfOwnDescriptors(len);
if (FLAG_unbox_double_fields) {
set_layout_descriptor(layout_desc);
#ifdef VERIFY_HEAP
// TODO(ishell): remove these checks from VERIFY_HEAP mode.
if (FLAG_verify_heap) {
CHECK(layout_descriptor()->IsConsistentWithMap(this));
}
#else
SLOW_DCHECK(layout_descriptor()->IsConsistentWithMap(this));
#endif
set_visitor_id(Map::GetVisitorId(this));
}
}
ACCESSORS(Map, instance_descriptors, DescriptorArray, kDescriptorsOffset)
ACCESSORS(Map, layout_descriptor, LayoutDescriptor, kLayoutDescriptorOffset)
void Map::set_bit_field3(uint32_t bits) {
if (kInt32Size != kPointerSize) {
WRITE_UINT32_FIELD(this, kBitField3Offset + kInt32Size, 0);
}
WRITE_UINT32_FIELD(this, kBitField3Offset, bits);
}
uint32_t Map::bit_field3() const {
return READ_UINT32_FIELD(this, kBitField3Offset);
}
LayoutDescriptor* Map::GetLayoutDescriptor() const {
return FLAG_unbox_double_fields ? layout_descriptor()
: LayoutDescriptor::FastPointerLayout();
}
void Map::AppendDescriptor(Descriptor* desc) {
DescriptorArray* descriptors = instance_descriptors();
int number_of_own_descriptors = NumberOfOwnDescriptors();
DCHECK(descriptors->number_of_descriptors() == number_of_own_descriptors);
descriptors->Append(desc);
SetNumberOfOwnDescriptors(number_of_own_descriptors + 1);
// Properly mark the map if the {desc} is an "interesting symbol".
if (desc->GetKey()->IsInterestingSymbol()) {
set_may_have_interesting_symbols(true);
}
// This function does not support appending double field descriptors and
// it should never try to (otherwise, layout descriptor must be updated too).
#ifdef DEBUG
PropertyDetails details = desc->GetDetails();
CHECK(details.location() != kField || !details.representation().IsDouble());
#endif
}
Object* Map::GetBackPointer() const {
Object* object = constructor_or_backpointer();
if (object->IsMap()) {
return object;
}
return GetIsolate()->heap()->undefined_value();
}
Map* Map::ElementsTransitionMap() {
DisallowHeapAllocation no_gc;
return TransitionsAccessor(this, &no_gc)
.SearchSpecial(GetHeap()->elements_transition_symbol());
}
ACCESSORS(Map, raw_transitions, Object, kTransitionsOrPrototypeInfoOffset)
Object* Map::prototype_info() const {
DCHECK(is_prototype_map());
return READ_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset);
}
void Map::set_prototype_info(Object* value, WriteBarrierMode mode) {
DCHECK(is_prototype_map());
WRITE_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset, value);
CONDITIONAL_WRITE_BARRIER(
GetHeap(), this, Map::kTransitionsOrPrototypeInfoOffset, value, mode);
}
void Map::SetBackPointer(Object* value, WriteBarrierMode mode) {
DCHECK(instance_type() >= FIRST_JS_RECEIVER_TYPE);
DCHECK(value->IsMap());
DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
DCHECK(!value->IsMap() ||
Map::cast(value)->GetConstructor() == constructor_or_backpointer());
set_constructor_or_backpointer(value, mode);
}
ACCESSORS(Map, code_cache, FixedArray, kCodeCacheOffset)
ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset)
ACCESSORS(Map, weak_cell_cache, Object, kWeakCellCacheOffset)
ACCESSORS(Map, constructor_or_backpointer, Object,
kConstructorOrBackPointerOffset)
Object* Map::GetConstructor() const {
Object* maybe_constructor = constructor_or_backpointer();
// Follow any back pointers.
while (maybe_constructor->IsMap()) {
maybe_constructor =
Map::cast(maybe_constructor)->constructor_or_backpointer();
}
return maybe_constructor;
}
FunctionTemplateInfo* Map::GetFunctionTemplateInfo() const {
Object* constructor = GetConstructor();
if (constructor->IsJSFunction()) {
DCHECK(JSFunction::cast(constructor)->shared()->IsApiFunction());
return JSFunction::cast(constructor)->shared()->get_api_func_data();
}
DCHECK(constructor->IsFunctionTemplateInfo());
return FunctionTemplateInfo::cast(constructor);
}
void Map::SetConstructor(Object* constructor, WriteBarrierMode mode) {
// Never overwrite a back pointer with a constructor.
DCHECK(!constructor_or_backpointer()->IsMap());
set_constructor_or_backpointer(constructor, mode);
}
Handle<Map> Map::CopyInitialMap(Handle<Map> map) {
return CopyInitialMap(map, map->instance_size(), map->GetInObjectProperties(),
map->unused_property_fields());
}
Object* JSBoundFunction::raw_bound_target_function() const {
return READ_FIELD(this, kBoundTargetFunctionOffset);
}
ACCESSORS(JSBoundFunction, bound_target_function, JSReceiver,
kBoundTargetFunctionOffset)
ACCESSORS(JSBoundFunction, bound_this, Object, kBoundThisOffset)
ACCESSORS(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset)
ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
ACCESSORS(JSFunction, feedback_vector_cell, Cell, kFeedbackVectorOffset)
ACCESSORS(JSGlobalObject, native_context, Context, kNativeContextOffset)
ACCESSORS(JSGlobalObject, global_proxy, JSObject, kGlobalProxyOffset)
ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset)
ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset)
ACCESSORS(AccessorInfo, name, Object, kNameOffset)
SMI_ACCESSORS(AccessorInfo, flag, kFlagOffset)
ACCESSORS(AccessorInfo, expected_receiver_type, Object,
kExpectedReceiverTypeOffset)
ACCESSORS(AccessorInfo, getter, Object, kGetterOffset)
ACCESSORS(AccessorInfo, setter, Object, kSetterOffset)
ACCESSORS(AccessorInfo, js_getter, Object, kJsGetterOffset)
ACCESSORS(AccessorInfo, data, Object, kDataOffset)
ACCESSORS(PromiseResolveThenableJobInfo, thenable, JSReceiver, kThenableOffset)
ACCESSORS(PromiseResolveThenableJobInfo, then, JSReceiver, kThenOffset)
ACCESSORS(PromiseResolveThenableJobInfo, resolve, JSFunction, kResolveOffset)
ACCESSORS(PromiseResolveThenableJobInfo, reject, JSFunction, kRejectOffset)
ACCESSORS(PromiseResolveThenableJobInfo, context, Context, kContextOffset);
ACCESSORS(PromiseReactionJobInfo, value, Object, kValueOffset);
ACCESSORS(PromiseReactionJobInfo, tasks, Object, kTasksOffset);
ACCESSORS(PromiseReactionJobInfo, deferred_promise, Object,
kDeferredPromiseOffset);
ACCESSORS(PromiseReactionJobInfo, deferred_on_resolve, Object,
kDeferredOnResolveOffset);
ACCESSORS(PromiseReactionJobInfo, deferred_on_reject, Object,
kDeferredOnRejectOffset);
ACCESSORS(PromiseReactionJobInfo, context, Context, kContextOffset);
ACCESSORS(AsyncGeneratorRequest, next, Object, kNextOffset)
SMI_ACCESSORS(AsyncGeneratorRequest, resume_mode, kResumeModeOffset)
ACCESSORS(AsyncGeneratorRequest, value, Object, kValueOffset)
ACCESSORS(AsyncGeneratorRequest, promise, Object, kPromiseOffset)
Map* PrototypeInfo::ObjectCreateMap() {
return Map::cast(WeakCell::cast(object_create_map())->value());
}
// static
void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
Handle<Map> map) {
Handle<WeakCell> cell = Map::WeakCellForMap(map);
info->set_object_create_map(*cell);
}
bool PrototypeInfo::HasObjectCreateMap() {
Object* cache = object_create_map();
return cache->IsWeakCell() && !WeakCell::cast(cache)->cleared();
}
bool FunctionTemplateInfo::instantiated() {
return shared_function_info()->IsSharedFunctionInfo();
}
FunctionTemplateInfo* FunctionTemplateInfo::GetParent(Isolate* isolate) {
Object* parent = parent_template();
return parent->IsUndefined(isolate) ? nullptr
: FunctionTemplateInfo::cast(parent);
}
ObjectTemplateInfo* ObjectTemplateInfo::GetParent(Isolate* isolate) {
Object* maybe_ctor = constructor();
if (maybe_ctor->IsUndefined(isolate)) return nullptr;
FunctionTemplateInfo* constructor = FunctionTemplateInfo::cast(maybe_ctor);
while (true) {
constructor = constructor->GetParent(isolate);
if (constructor == nullptr) return nullptr;
Object* maybe_obj = constructor->instance_template();
if (!maybe_obj->IsUndefined(isolate)) {
return ObjectTemplateInfo::cast(maybe_obj);
}
}
return nullptr;
}
ACCESSORS(PrototypeInfo, weak_cell, Object, kWeakCellOffset)
ACCESSORS(PrototypeInfo, prototype_users, Object, kPrototypeUsersOffset)
ACCESSORS(PrototypeInfo, object_create_map, Object, kObjectCreateMap)
SMI_ACCESSORS(PrototypeInfo, registry_slot, kRegistrySlotOffset)
ACCESSORS(PrototypeInfo, validity_cell, Object, kValidityCellOffset)
SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset)
BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit)
ACCESSORS(Tuple2, value1, Object, kValue1Offset)
ACCESSORS(Tuple2, value2, Object, kValue2Offset)
ACCESSORS(Tuple3, value3, Object, kValue3Offset)
ACCESSORS(ContextExtension, scope_info, ScopeInfo, kScopeInfoOffset)
ACCESSORS(ContextExtension, extension, Object, kExtensionOffset)
SMI_ACCESSORS(ConstantElementsPair, elements_kind, kElementsKindOffset)
ACCESSORS(ConstantElementsPair, constant_values, FixedArrayBase,
kConstantValuesOffset)
bool ConstantElementsPair::is_empty() const {
return constant_values()->length() == 0;
}
ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
ACCESSORS(AccessorPair, setter, Object, kSetterOffset)
ACCESSORS(AccessCheckInfo, callback, Object, kCallbackOffset)
ACCESSORS(AccessCheckInfo, named_interceptor, Object, kNamedInterceptorOffset)
ACCESSORS(AccessCheckInfo, indexed_interceptor, Object,
kIndexedInterceptorOffset)
ACCESSORS(AccessCheckInfo, data, Object, kDataOffset)
ACCESSORS(InterceptorInfo, getter, Object, kGetterOffset)
ACCESSORS(InterceptorInfo, setter, Object, kSetterOffset)
ACCESSORS(InterceptorInfo, query, Object, kQueryOffset)
ACCESSORS(InterceptorInfo, descriptor, Object, kDescriptorOffset)
ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset)
ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset)
ACCESSORS(InterceptorInfo, definer, Object, kDefinerOffset)
ACCESSORS(InterceptorInfo, data, Object, kDataOffset)
SMI_ACCESSORS(InterceptorInfo, flags, kFlagsOffset)
BOOL_ACCESSORS(InterceptorInfo, flags, can_intercept_symbols,
kCanInterceptSymbolsBit)
BOOL_ACCESSORS(InterceptorInfo, flags, all_can_read, kAllCanReadBit)
BOOL_ACCESSORS(InterceptorInfo, flags, non_masking, kNonMasking)
ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)
ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)
ACCESSORS(TemplateInfo, tag, Object, kTagOffset)
ACCESSORS(TemplateInfo, serial_number, Object, kSerialNumberOffset)
SMI_ACCESSORS(TemplateInfo, number_of_properties, kNumberOfProperties)
ACCESSORS(TemplateInfo, property_list, Object, kPropertyListOffset)
ACCESSORS(TemplateInfo, property_accessors, Object, kPropertyAccessorsOffset)
ACCESSORS(FunctionTemplateInfo, call_code, Object, kCallCodeOffset)
ACCESSORS(FunctionTemplateInfo, prototype_template, Object,
kPrototypeTemplateOffset)
ACCESSORS(FunctionTemplateInfo, prototype_provider_template, Object,
kPrototypeProviderTemplateOffset)
ACCESSORS(FunctionTemplateInfo, parent_template, Object, kParentTemplateOffset)
ACCESSORS(FunctionTemplateInfo, named_property_handler, Object,
kNamedPropertyHandlerOffset)
ACCESSORS(FunctionTemplateInfo, indexed_property_handler, Object,
kIndexedPropertyHandlerOffset)
ACCESSORS(FunctionTemplateInfo, instance_template, Object,
kInstanceTemplateOffset)
ACCESSORS(FunctionTemplateInfo, class_name, Object, kClassNameOffset)
ACCESSORS(FunctionTemplateInfo, signature, Object, kSignatureOffset)
ACCESSORS(FunctionTemplateInfo, instance_call_handler, Object,
kInstanceCallHandlerOffset)
ACCESSORS(FunctionTemplateInfo, access_check_info, Object,
kAccessCheckInfoOffset)
ACCESSORS(FunctionTemplateInfo, shared_function_info, Object,
kSharedFunctionInfoOffset)
ACCESSORS(FunctionTemplateInfo, cached_property_name, Object,
kCachedPropertyNameOffset)
SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset)
ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset)
ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset)
int ObjectTemplateInfo::embedder_field_count() const {
Object* value = data();
DCHECK(value->IsSmi());
return EmbedderFieldCount::decode(Smi::ToInt(value));
}
void ObjectTemplateInfo::set_embedder_field_count(int count) {
return set_data(
Smi::FromInt(EmbedderFieldCount::update(Smi::ToInt(data()), count)));
}
bool ObjectTemplateInfo::immutable_proto() const {
Object* value = data();
DCHECK(value->IsSmi());
return IsImmutablePrototype::decode(Smi::ToInt(value));
}
void ObjectTemplateInfo::set_immutable_proto(bool immutable) {
return set_data(Smi::FromInt(
IsImmutablePrototype::update(Smi::ToInt(data()), immutable)));
}
int TemplateList::length() const {
return Smi::ToInt(FixedArray::cast(this)->get(kLengthIndex));
}
Object* TemplateList::get(int index) const {
return FixedArray::cast(this)->get(kFirstElementIndex + index);
}
void TemplateList::set(int index, Object* value) {
FixedArray::cast(this)->set(kFirstElementIndex + index, value);
}
ACCESSORS(AllocationSite, transition_info_or_boilerplate, Object,
kTransitionInfoOrBoilerplateOffset)
JSObject* AllocationSite::boilerplate() const {
DCHECK(PointsToLiteral());
return JSObject::cast(transition_info_or_boilerplate());
}
void AllocationSite::set_boilerplate(JSObject* object, WriteBarrierMode mode) {
set_transition_info_or_boilerplate(object, mode);
}
int AllocationSite::transition_info() const {
DCHECK(!PointsToLiteral());
return Smi::cast(transition_info_or_boilerplate())->value();
}
void AllocationSite::set_transition_info(int value) {
DCHECK(!PointsToLiteral());
set_transition_info_or_boilerplate(Smi::FromInt(value), SKIP_WRITE_BARRIER);
}
ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset)
SMI_ACCESSORS(AllocationSite, pretenure_data, kPretenureDataOffset)
SMI_ACCESSORS(AllocationSite, pretenure_create_count,
kPretenureCreateCountOffset)
ACCESSORS(AllocationSite, dependent_code, DependentCode,
kDependentCodeOffset)
ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset)
ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset)
SMI_ACCESSORS(StackFrameInfo, line_number, kLineNumberIndex)
SMI_ACCESSORS(StackFrameInfo, column_number, kColumnNumberIndex)
SMI_ACCESSORS(StackFrameInfo, script_id, kScriptIdIndex)
ACCESSORS(StackFrameInfo, script_name, Object, kScriptNameIndex)
ACCESSORS(StackFrameInfo, script_name_or_source_url, Object,
kScriptNameOrSourceUrlIndex)
ACCESSORS(StackFrameInfo, function_name, Object, kFunctionNameIndex)
SMI_ACCESSORS(StackFrameInfo, flag, kFlagIndex)
BOOL_ACCESSORS(StackFrameInfo, flag, is_eval, kIsEvalBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_constructor, kIsConstructorBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_wasm, kIsWasmBit)
SMI_ACCESSORS(StackFrameInfo, id, kIdIndex)
ACCESSORS(SourcePositionTableWithFrameCache, source_position_table, ByteArray,
kSourcePositionTableIndex)
ACCESSORS(SourcePositionTableWithFrameCache, stack_frame_cache,
UnseededNumberDictionary, kStackFrameCacheIndex)
SMI_ACCESSORS(FunctionTemplateInfo, length, kLengthOffset)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype,
kHiddenPrototypeBit)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check,
kNeedsAccessCheckBit)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, read_only_prototype,
kReadOnlyPrototypeBit)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, remove_prototype,
kRemovePrototypeBit)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache,
kDoNotCacheBit)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, accept_any_receiver,
kAcceptAnyReceiver)
FeedbackVector* JSFunction::feedback_vector() const {
DCHECK(feedback_vector_cell()->value()->IsFeedbackVector());
return FeedbackVector::cast(feedback_vector_cell()->value());
}
// Code objects that are marked for deoptimization are not considered to be
// optimized. This is because the JSFunction might have been already
// deoptimized but its code() still needs to be unlinked, which will happen on
// its next activation.
// TODO(jupvfranco): rename this function. Maybe RunOptimizedCode,
// or IsValidOptimizedCode.
bool JSFunction::IsOptimized() {
return code()->kind() == Code::OPTIMIZED_FUNCTION &&
!code()->marked_for_deoptimization();
}
bool JSFunction::HasOptimizedCode() {
return IsOptimized() ||
(has_feedback_vector() && feedback_vector()->has_optimized_code() &&
!feedback_vector()->optimized_code()->marked_for_deoptimization());
}
bool JSFunction::HasOptimizationMarker() {
return has_feedback_vector() && feedback_vector()->has_optimization_marker();
}
void JSFunction::ClearOptimizationMarker() {
DCHECK(has_feedback_vector());
DCHECK(!feedback_vector()->has_optimized_code());
feedback_vector()->SetOptimizationMarker(OptimizationMarker::kNone);
}
bool JSFunction::IsInterpreted() {
return code()->is_interpreter_trampoline_builtin();
}
bool JSFunction::ChecksOptimizationMarker() {
return code()->checks_optimization_marker();
}
bool JSFunction::IsMarkedForOptimization() {
return has_feedback_vector() && feedback_vector()->optimization_marker() ==
OptimizationMarker::kCompileOptimized;
}
bool JSFunction::IsMarkedForConcurrentOptimization() {
return has_feedback_vector() &&
feedback_vector()->optimization_marker() ==
OptimizationMarker::kCompileOptimizedConcurrent;
}
bool JSFunction::IsInOptimizationQueue() {
return has_feedback_vector() && feedback_vector()->optimization_marker() ==
OptimizationMarker::kInOptimizationQueue;
}
void JSFunction::CompleteInobjectSlackTrackingIfActive() {
if (has_initial_map() && initial_map()->IsInobjectSlackTrackingInProgress()) {
initial_map()->CompleteInobjectSlackTracking();
}
}
bool Map::IsInobjectSlackTrackingInProgress() const {
return construction_counter() != Map::kNoSlackTracking;
}
void Map::InobjectSlackTrackingStep() {
if (!IsInobjectSlackTrackingInProgress()) return;
int counter = construction_counter();
set_construction_counter(counter - 1);
if (counter == kSlackTrackingCounterEnd) {
CompleteInobjectSlackTracking();
}
}
AbstractCode* JSFunction::abstract_code() {
if (IsInterpreted()) {
return AbstractCode::cast(shared()->bytecode_array());
} else {
return AbstractCode::cast(code());
}
}
Code* JSFunction::code() { return Code::cast(READ_FIELD(this, kCodeOffset)); }
void JSFunction::set_code(Code* value) {
DCHECK(!GetHeap()->InNewSpace(value));
WRITE_FIELD(this, kCodeOffset, value);
GetHeap()->incremental_marking()->RecordWrite(
this, HeapObject::RawField(this, kCodeOffset), value);
}
void JSFunction::set_code_no_write_barrier(Code* value) {
DCHECK(!GetHeap()->InNewSpace(value));
WRITE_FIELD(this, kCodeOffset, value);
}
void JSFunction::ClearOptimizedCodeSlot(const char* reason) {
if (has_feedback_vector() && feedback_vector()->has_optimized_code()) {
if (FLAG_trace_opt) {
PrintF("[evicting entry from optimizing code feedback slot (%s) for ",
reason);
ShortPrint();
PrintF("]\n");
}
feedback_vector()->ClearOptimizedCode();
}
}
void JSFunction::SetOptimizationMarker(OptimizationMarker marker) {
DCHECK(has_feedback_vector());
DCHECK(ChecksOptimizationMarker());
DCHECK(!HasOptimizedCode());
feedback_vector()->SetOptimizationMarker(marker);
}
// TODO(jupvfranco): Get rid of this function and use set_code instead.
void JSFunction::ReplaceCode(Code* code) {
set_code(code);
}
bool JSFunction::has_feedback_vector() const {
return !feedback_vector_cell()->value()->IsUndefined(GetIsolate());
}
JSFunction::FeedbackVectorState JSFunction::GetFeedbackVectorState(
Isolate* isolate) const {
Cell* cell = feedback_vector_cell();
if (cell == isolate->heap()->undefined_cell()) {
return TOP_LEVEL_SCRIPT_NEEDS_VECTOR;
} else if (cell->value() == isolate->heap()->undefined_value() ||
!has_feedback_vector()) {
return NEEDS_VECTOR;
}
return HAS_VECTOR;
}
Context* JSFunction::context() {
return Context::cast(READ_FIELD(this, kContextOffset));
}
bool JSFunction::has_context() const {
return READ_FIELD(this, kContextOffset)->IsContext();
}
JSObject* JSFunction::global_proxy() {
return context()->global_proxy();
}
Context* JSFunction::native_context() { return context()->native_context(); }
void JSFunction::set_context(Object* value) {
DCHECK(value->IsUndefined(GetIsolate()) || value->IsContext());
WRITE_FIELD(this, kContextOffset, value);
WRITE_BARRIER(GetHeap(), this, kContextOffset, value);
}
ACCESSORS(JSFunction, prototype_or_initial_map, Object,
kPrototypeOrInitialMapOffset)
Map* JSFunction::initial_map() {
return Map::cast(prototype_or_initial_map());
}
bool JSFunction::has_initial_map() {
return prototype_or_initial_map()->IsMap();
}
bool JSFunction::has_instance_prototype() {
return has_initial_map() ||
!prototype_or_initial_map()->IsTheHole(GetIsolate());
}
bool JSFunction::has_prototype() {
return map()->has_non_instance_prototype() || has_instance_prototype();
}
Object* JSFunction::instance_prototype() {
DCHECK(has_instance_prototype());
if (has_initial_map()) return initial_map()->prototype();
// When there is no initial map and the prototype is a JSObject, the
// initial map field is used for the prototype field.
return prototype_or_initial_map();
}
Object* JSFunction::prototype() {
DCHECK(has_prototype());
// If the function's prototype property has been set to a non-JSObject
// value, that value is stored in the constructor field of the map.
if (map()->has_non_instance_prototype()) {
Object* prototype = map()->GetConstructor();
// The map must have a prototype in that field, not a back pointer.
DCHECK(!prototype->IsMap());
DCHECK(!prototype->IsFunctionTemplateInfo());
return prototype;
}
return instance_prototype();
}
bool JSFunction::is_compiled() {
Builtins* builtins = GetIsolate()->builtins();
return code() != builtins->builtin(Builtins::kCompileLazy);
}
ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset)
ACCESSORS(JSProxy, handler, Object, kHandlerOffset)
ACCESSORS(JSProxy, hash, Object, kHashOffset)
bool JSProxy::IsRevoked() const { return !handler()->IsJSReceiver(); }
ACCESSORS(JSCollection, table, Object, kTableOffset)
ACCESSORS(JSCollectionIterator, table, Object, kTableOffset)
ACCESSORS(JSCollectionIterator, index, Object, kIndexOffset)
ACCESSORS(JSWeakCollection, table, Object, kTableOffset)
ACCESSORS(JSWeakCollection, next, Object, kNextOffset)
Address Foreign::foreign_address() {
return AddressFrom<Address>(READ_INTPTR_FIELD(this, kForeignAddressOffset));
}
void Foreign::set_foreign_address(Address value) {
WRITE_INTPTR_FIELD(this, kForeignAddressOffset, OffsetFrom(value));
}
template <class Derived>
void SmallOrderedHashTable<Derived>::SetDataEntry(int entry, int relative_index,
Object* value) {
int entry_offset = GetDataEntryOffset(entry, relative_index);
RELAXED_WRITE_FIELD(this, entry_offset, value);
WRITE_BARRIER(GetHeap(), this, entry_offset, value);
}
ACCESSORS(JSGeneratorObject, function, JSFunction, kFunctionOffset)
ACCESSORS(JSGeneratorObject, context, Context, kContextOffset)
ACCESSORS(JSGeneratorObject, receiver, Object, kReceiverOffset)
ACCESSORS(JSGeneratorObject, input_or_debug_pos, Object, kInputOrDebugPosOffset)
SMI_ACCESSORS(JSGeneratorObject, resume_mode, kResumeModeOffset)
SMI_ACCESSORS(JSGeneratorObject, continuation, kContinuationOffset)
ACCESSORS(JSGeneratorObject, register_file, FixedArray, kRegisterFileOffset)
bool JSGeneratorObject::is_suspended() const {
DCHECK_LT(kGeneratorExecuting, 0);
DCHECK_LT(kGeneratorClosed, 0);
return continuation() >= 0;
}
bool JSGeneratorObject::is_closed() const {
return continuation() == kGeneratorClosed;
}
bool JSGeneratorObject::is_executing() const {
return continuation() == kGeneratorExecuting;
}
ACCESSORS(JSAsyncGeneratorObject, queue, HeapObject, kQueueOffset)
ACCESSORS(JSAsyncGeneratorObject, awaited_promise, HeapObject,
kAwaitedPromiseOffset)
ACCESSORS(JSValue, value, Object, kValueOffset)
HeapNumber* HeapNumber::cast(Object* object) {
SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber());
return reinterpret_cast<HeapNumber*>(object);
}
const HeapNumber* HeapNumber::cast(const Object* object) {
SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber());
return reinterpret_cast<const HeapNumber*>(object);
}
ACCESSORS(JSDate, value, Object, kValueOffset)
ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset)
ACCESSORS(JSDate, year, Object, kYearOffset)
ACCESSORS(JSDate, month, Object, kMonthOffset)
ACCESSORS(JSDate, day, Object, kDayOffset)
ACCESSORS(JSDate, weekday, Object, kWeekdayOffset)
ACCESSORS(JSDate, hour, Object, kHourOffset)
ACCESSORS(JSDate, min, Object, kMinOffset)
ACCESSORS(JSDate, sec, Object, kSecOffset)
SMI_ACCESSORS(JSMessageObject, type, kTypeOffset)
ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset)
ACCESSORS(JSMessageObject, script, Object, kScriptOffset)
ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset)
SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset)
SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset)
SMI_ACCESSORS(JSMessageObject, error_level, kErrorLevelOffset)
INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset)
INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset)
#define CODE_ACCESSORS(name, type, offset) \
ACCESSORS_CHECKED2(Code, name, type, offset, true, \
!GetHeap()->InNewSpace(value))
CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset)
CODE_ACCESSORS(handler_table, FixedArray, kHandlerTableOffset)
CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset)
CODE_ACCESSORS(source_position_table, Object, kSourcePositionTableOffset)
CODE_ACCESSORS(trap_handler_index, Smi, kTrapHandlerIndex)
CODE_ACCESSORS(raw_type_feedback_info, Object, kTypeFeedbackInfoOffset)
CODE_ACCESSORS(next_code_link, Object, kNextCodeLinkOffset)
#undef CODE_ACCESSORS
void Code::WipeOutHeader() {
WRITE_FIELD(this, kRelocationInfoOffset, nullptr);
WRITE_FIELD(this, kHandlerTableOffset, nullptr);
WRITE_FIELD(this, kDeoptimizationDataOffset, nullptr);
WRITE_FIELD(this, kSourcePositionTableOffset, nullptr);
// Do not wipe out major/minor keys on a code stub or IC
if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) {
WRITE_FIELD(this, kTypeFeedbackInfoOffset, nullptr);
}
WRITE_FIELD(this, kNextCodeLinkOffset, nullptr);
}
void Code::clear_padding() {
memset(address() + kHeaderPaddingStart, 0, kHeaderSize - kHeaderPaddingStart);
Address data_end =
has_unwinding_info() ? unwinding_info_end() : instruction_end();
memset(data_end, 0, CodeSize() - (data_end - address()));
}
ByteArray* Code::SourcePositionTable() const {
Object* maybe_table = source_position_table();
if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table);
DCHECK(maybe_table->IsSourcePositionTableWithFrameCache());
return SourcePositionTableWithFrameCache::cast(maybe_table)
->source_position_table();
}
uint32_t Code::stub_key() const {
DCHECK(IsCodeStubOrIC());
Smi* smi_key = Smi::cast(raw_type_feedback_info());
return static_cast<uint32_t>(smi_key->value());
}
void Code::set_stub_key(uint32_t key) {
DCHECK(IsCodeStubOrIC());
set_raw_type_feedback_info(Smi::FromInt(key));
}
byte* Code::instruction_start() const {
return const_cast<byte*>(FIELD_ADDR_CONST(this, kHeaderSize));
}
byte* Code::instruction_end() const {
return instruction_start() + instruction_size();
}
int Code::GetUnwindingInfoSizeOffset() const {
DCHECK(has_unwinding_info());
return RoundUp(kHeaderSize + instruction_size(), kInt64Size);
}
int Code::unwinding_info_size() const {
DCHECK(has_unwinding_info());
return static_cast<int>(
READ_UINT64_FIELD(this, GetUnwindingInfoSizeOffset()));
}
void Code::set_unwinding_info_size(int value) {
DCHECK(has_unwinding_info());
WRITE_UINT64_FIELD(this, GetUnwindingInfoSizeOffset(), value);
}
byte* Code::unwinding_info_start() const {
DCHECK(has_unwinding_info());
return const_cast<byte*>(
FIELD_ADDR_CONST(this, GetUnwindingInfoSizeOffset())) +
kInt64Size;
}
byte* Code::unwinding_info_end() const {
DCHECK(has_unwinding_info());
return unwinding_info_start() + unwinding_info_size();
}
int Code::body_size() const {
int unpadded_body_size =
has_unwinding_info()
? static_cast<int>(unwinding_info_end() - instruction_start())
: instruction_size();
return RoundUp(unpadded_body_size, kObjectAlignment);
}
int Code::SizeIncludingMetadata() const {
int size = CodeSize();
size += relocation_info()->Size();
size += deoptimization_data()->Size();
size += handler_table()->Size();
return size;
}
ByteArray* Code::unchecked_relocation_info() const {
return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset));
}
byte* Code::relocation_start() const {
return unchecked_relocation_info()->GetDataStartAddress();
}
int Code::relocation_size() const {
return unchecked_relocation_info()->length();
}
byte* Code::entry() const { return instruction_start(); }
bool Code::contains(byte* inner_pointer) {
return (address() <= inner_pointer) && (inner_pointer <= address() + Size());
}
int Code::ExecutableSize() const {
// Check that the assumptions about the layout of the code object holds.
DCHECK_EQ(static_cast<int>(instruction_start() - address()),
Code::kHeaderSize);
return instruction_size() + Code::kHeaderSize;
}
int Code::CodeSize() const { return SizeFor(body_size()); }
ACCESSORS(JSArray, length, Object, kLengthOffset)
void* JSArrayBuffer::backing_store() const {
intptr_t ptr = READ_INTPTR_FIELD(this, kBackingStoreOffset);
return reinterpret_cast<void*>(ptr);
}
void JSArrayBuffer::set_backing_store(void* value, WriteBarrierMode mode) {
intptr_t ptr = reinterpret_cast<intptr_t>(value);
WRITE_INTPTR_FIELD(this, kBackingStoreOffset, ptr);
}
ACCESSORS(JSArrayBuffer, byte_length, Object, kByteLengthOffset)
void* JSArrayBuffer::allocation_base() const {
intptr_t ptr = READ_INTPTR_FIELD(this, kAllocationBaseOffset);
return reinterpret_cast<void*>(ptr);
}
void JSArrayBuffer::set_allocation_base(void* value, WriteBarrierMode mode) {
intptr_t ptr = reinterpret_cast<intptr_t>(value);
WRITE_INTPTR_FIELD(this, kAllocationBaseOffset, ptr);
}
size_t JSArrayBuffer::allocation_length() const {
return *reinterpret_cast<const size_t*>(
FIELD_ADDR_CONST(this, kAllocationLengthOffset));
}
void JSArrayBuffer::set_allocation_length(size_t value) {
(*reinterpret_cast<size_t*>(FIELD_ADDR(this, kAllocationLengthOffset))) =
value;
}
ArrayBuffer::Allocator::AllocationMode JSArrayBuffer::allocation_mode() const {
using AllocationMode = ArrayBuffer::Allocator::AllocationMode;
return has_guard_region() ? AllocationMode::kReservation
: AllocationMode::kNormal;
}
void JSArrayBuffer::set_bit_field(uint32_t bits) {
if (kInt32Size != kPointerSize) {
#if V8_TARGET_LITTLE_ENDIAN
WRITE_UINT32_FIELD(this, kBitFieldSlot + kInt32Size, 0);
#else
WRITE_UINT32_FIELD(this, kBitFieldSlot, 0);
#endif
}
WRITE_UINT32_FIELD(this, kBitFieldOffset, bits);
}
uint32_t JSArrayBuffer::bit_field() const {
return READ_UINT32_FIELD(this, kBitFieldOffset);
}
bool JSArrayBuffer::is_external() { return IsExternal::decode(bit_field()); }
void JSArrayBuffer::set_is_external(bool value) {
set_bit_field(IsExternal::update(bit_field(), value));
}
bool JSArrayBuffer::is_neuterable() {
return IsNeuterable::decode(bit_field());
}
void JSArrayBuffer::set_is_neuterable(bool value) {
set_bit_field(IsNeuterable::update(bit_field(), value));
}
bool JSArrayBuffer::was_neutered() { return WasNeutered::decode(bit_field()); }
void JSArrayBuffer::set_was_neutered(bool value) {
set_bit_field(WasNeutered::update(bit_field(), value));
}
bool JSArrayBuffer::is_shared() { return IsShared::decode(bit_field()); }
void JSArrayBuffer::set_is_shared(bool value) {
set_bit_field(IsShared::update(bit_field(), value));
}
bool JSArrayBuffer::has_guard_region() const {
return HasGuardRegion::decode(bit_field());
}
void JSArrayBuffer::set_has_guard_region(bool value) {
set_bit_field(HasGuardRegion::update(bit_field(), value));
}
bool JSArrayBuffer::is_wasm_buffer() {
return IsWasmBuffer::decode(bit_field());
}
void JSArrayBuffer::set_is_wasm_buffer(bool value) {
set_bit_field(IsWasmBuffer::update(bit_field(), value));
}
Object* JSArrayBufferView::byte_offset() const {
if (WasNeutered()) return Smi::kZero;
return Object::cast(READ_FIELD(this, kByteOffsetOffset));
}
void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) {
WRITE_FIELD(this, kByteOffsetOffset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode);
}
Object* JSArrayBufferView::byte_length() const {
if (WasNeutered()) return Smi::kZero;
return Object::cast(READ_FIELD(this, kByteLengthOffset));
}
void JSArrayBufferView::set_byte_length(Object* value, WriteBarrierMode mode) {
WRITE_FIELD(this, kByteLengthOffset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteLengthOffset, value, mode);
}
ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset)
#ifdef VERIFY_HEAP
ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset)
ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset)
#endif
bool JSArrayBufferView::WasNeutered() const {
return JSArrayBuffer::cast(buffer())->was_neutered();
}
Object* JSTypedArray::length() const {
if (WasNeutered()) return Smi::kZero;
return Object::cast(READ_FIELD(this, kLengthOffset));
}
uint32_t JSTypedArray::length_value() const {
if (WasNeutered()) return 0;
uint32_t index = 0;
CHECK(Object::cast(READ_FIELD(this, kLengthOffset))->ToArrayLength(&index));
return index;
}
void JSTypedArray::set_length(Object* value, WriteBarrierMode mode) {
WRITE_FIELD(this, kLengthOffset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode);
}
// static
MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate,
Handle<Object> receiver,
const char* method_name) {
if (V8_UNLIKELY(!receiver->IsJSTypedArray())) {
const MessageTemplate::Template message = MessageTemplate::kNotTypedArray;
THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray);
}
Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver);
if (V8_UNLIKELY(array->WasNeutered())) {
const MessageTemplate::Template message =
MessageTemplate::kDetachedOperation;
Handle<String> operation =
isolate->factory()->NewStringFromAsciiChecked(method_name);
THROW_NEW_ERROR(isolate, NewTypeError(message, operation), JSTypedArray);
}
// spec describes to return `buffer`, but it may disrupt current
// implementations, and it's much useful to return array for now.
return array;
}
#ifdef VERIFY_HEAP
ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset)
#endif
ACCESSORS(PromiseCapability, promise, Object, kPromiseOffset)
ACCESSORS(PromiseCapability, resolve, Object, kResolveOffset)
ACCESSORS(PromiseCapability, reject, Object, kRejectOffset)
ACCESSORS(JSPromise, result, Object, kResultOffset)
ACCESSORS(JSPromise, deferred_promise, Object, kDeferredPromiseOffset)
ACCESSORS(JSPromise, deferred_on_resolve, Object, kDeferredOnResolveOffset)
ACCESSORS(JSPromise, deferred_on_reject, Object, kDeferredOnRejectOffset)
ACCESSORS(JSPromise, fulfill_reactions, Object, kFulfillReactionsOffset)
ACCESSORS(JSPromise, reject_reactions, Object, kRejectReactionsOffset)
SMI_ACCESSORS(JSPromise, flags, kFlagsOffset)
BOOL_ACCESSORS(JSPromise, flags, has_handler, kHasHandlerBit)
BOOL_ACCESSORS(JSPromise, flags, handled_hint, kHandledHintBit)
ACCESSORS(JSRegExp, data, Object, kDataOffset)
ACCESSORS(JSRegExp, flags, Object, kFlagsOffset)
ACCESSORS(JSRegExp, source, Object, kSourceOffset)
ACCESSORS(JSRegExp, last_index, Object, kLastIndexOffset)
JSRegExp::Type JSRegExp::TypeTag() {
Object* data = this->data();
if (data->IsUndefined(GetIsolate())) return JSRegExp::NOT_COMPILED;
Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
return static_cast<JSRegExp::Type>(smi->value());
}
int JSRegExp::CaptureCount() {
switch (TypeTag()) {
case ATOM:
return 0;
case IRREGEXP:
return Smi::ToInt(DataAt(kIrregexpCaptureCountIndex));
default:
UNREACHABLE();
}
}
JSRegExp::Flags JSRegExp::GetFlags() {
DCHECK(this->data()->IsFixedArray());
Object* data = this->data();
Smi* smi = Smi::cast(FixedArray::cast(data)->get(kFlagsIndex));
return Flags(smi->value());
}
String* JSRegExp::Pattern() {
DCHECK(this->data()->IsFixedArray());
Object* data = this->data();
String* pattern = String::cast(FixedArray::cast(data)->get(kSourceIndex));
return pattern;
}
Object* JSRegExp::CaptureNameMap() {
DCHECK(this->data()->IsFixedArray());
DCHECK_EQ(TypeTag(), IRREGEXP);
Object* value = DataAt(kIrregexpCaptureNameMapIndex);
DCHECK_NE(value, Smi::FromInt(JSRegExp::kUninitializedValue));
return value;
}
Object* JSRegExp::DataAt(int index) {
DCHECK(TypeTag() != NOT_COMPILED);
return FixedArray::cast(data())->get(index);
}
void JSRegExp::SetDataAt(int index, Object* value) {
DCHECK(TypeTag() != NOT_COMPILED);
DCHECK(index >= kDataIndex); // Only implementation data can be set this way.
FixedArray::cast(data())->set(index, value);
}
ElementsKind JSObject::GetElementsKind() {
ElementsKind kind = map()->elements_kind();
#if VERIFY_HEAP && DEBUG
FixedArrayBase* fixed_array =
reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset));
// If a GC was caused while constructing this object, the elements
// pointer may point to a one pointer filler map.
if (ElementsAreSafeToExamine()) {
Map* map = fixed_array->map();
if (IsSmiOrObjectElementsKind(kind)) {
DCHECK(map == GetHeap()->fixed_array_map() ||
map == GetHeap()->fixed_cow_array_map());
} else if (IsDoubleElementsKind(kind)) {
DCHECK(fixed_array->IsFixedDoubleArray() ||
fixed_array == GetHeap()->empty_fixed_array());
} else if (kind == DICTIONARY_ELEMENTS) {
DCHECK(fixed_array->IsFixedArray());
DCHECK(fixed_array->IsDictionary());
} else {
DCHECK(kind > DICTIONARY_ELEMENTS);
}
DCHECK(!IsSloppyArgumentsElementsKind(kind) ||
(elements()->IsFixedArray() && elements()->length() >= 2));
}
#endif
return kind;
}
bool JSObject::HasObjectElements() {
return IsObjectElementsKind(GetElementsKind());
}
bool JSObject::HasSmiElements() { return IsSmiElementsKind(GetElementsKind()); }
bool JSObject::HasSmiOrObjectElements() {
return IsSmiOrObjectElementsKind(GetElementsKind());
}
bool JSObject::HasDoubleElements() {
return IsDoubleElementsKind(GetElementsKind());
}
bool JSObject::HasHoleyElements() {
return IsHoleyElementsKind(GetElementsKind());
}
bool JSObject::HasFastElements() {
return IsFastElementsKind(GetElementsKind());
}
bool JSObject::HasDictionaryElements() {
return GetElementsKind() == DICTIONARY_ELEMENTS;
}
bool JSObject::HasFastArgumentsElements() {
return GetElementsKind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS;
}
bool JSObject::HasSlowArgumentsElements() {
return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS;
}
bool JSObject::HasSloppyArgumentsElements() {
return IsSloppyArgumentsElementsKind(GetElementsKind());
}
bool JSObject::HasStringWrapperElements() {
return IsStringWrapperElementsKind(GetElementsKind());
}
bool JSObject::HasFastStringWrapperElements() {
return GetElementsKind() == FAST_STRING_WRAPPER_ELEMENTS;
}
bool JSObject::HasSlowStringWrapperElements() {
return GetElementsKind() == SLOW_STRING_WRAPPER_ELEMENTS;
}
bool JSObject::HasFixedTypedArrayElements() {
DCHECK_NOT_NULL(elements());
return map()->has_fixed_typed_array_elements();
}
#define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \
bool JSObject::HasFixed##Type##Elements() { \
HeapObject* array = elements(); \
DCHECK(array != NULL); \
if (!array->IsHeapObject()) return false; \
return array->map()->instance_type() == FIXED_##TYPE##_ARRAY_TYPE; \
}
TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK)
#undef FIXED_TYPED_ELEMENTS_CHECK
bool JSObject::HasNamedInterceptor() {
return map()->has_named_interceptor();
}
bool JSObject::HasIndexedInterceptor() {
return map()->has_indexed_interceptor();
}
void JSGlobalObject::set_global_dictionary(GlobalDictionary* dictionary) {
DCHECK(IsJSGlobalObject());
set_raw_properties_or_hash(dictionary);
}
GlobalDictionary* JSGlobalObject::global_dictionary() {
DCHECK(!HasFastProperties());
DCHECK(IsJSGlobalObject());
return GlobalDictionary::cast(raw_properties_or_hash());
}
SeededNumberDictionary* JSObject::element_dictionary() {
DCHECK(HasDictionaryElements() || HasSlowStringWrapperElements());
return SeededNumberDictionary::cast(elements());
}
// static
Maybe<bool> Object::GreaterThan(Handle<Object> x, Handle<Object> y) {
Maybe<ComparisonResult> result = Compare(x, y);
if (result.IsJust()) {
switch (result.FromJust()) {
case ComparisonResult::kGreaterThan:
return Just(true);
case ComparisonResult::kLessThan:
case ComparisonResult::kEqual:
case ComparisonResult::kUndefined:
return Just(false);
}
}
return Nothing<bool>();
}
// static
Maybe<bool> Object::GreaterThanOrEqual(Handle<Object> x, Handle<Object> y) {
Maybe<ComparisonResult> result = Compare(x, y);
if (result.IsJust()) {
switch (result.FromJust()) {
case ComparisonResult::kEqual:
case ComparisonResult::kGreaterThan:
return Just(true);
case ComparisonResult::kLessThan:
case ComparisonResult::kUndefined:
return Just(false);
}
}
return Nothing<bool>();
}
// static
Maybe<bool> Object::LessThan(Handle<Object> x, Handle<Object> y) {
Maybe<ComparisonResult> result = Compare(x, y);
if (result.IsJust()) {
switch (result.FromJust()) {
case ComparisonResult::kLessThan:
return Just(true);
case ComparisonResult::kEqual:
case ComparisonResult::kGreaterThan:
case ComparisonResult::kUndefined:
return Just(false);
}
}
return Nothing<bool>();
}
// static
Maybe<bool> Object::LessThanOrEqual(Handle<Object> x, Handle<Object> y) {
Maybe<ComparisonResult> result = Compare(x, y);
if (result.IsJust()) {
switch (result.FromJust()) {
case ComparisonResult::kEqual:
case ComparisonResult::kLessThan:
return Just(true);
case ComparisonResult::kGreaterThan:
case ComparisonResult::kUndefined:
return Just(false);
}
}
return Nothing<bool>();
}
MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
Handle<Name> name) {
LookupIterator it =
LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
return GetProperty(&it);
}
MaybeHandle<Object> Object::SetPropertyOrElement(Handle<Object> object,
Handle<Name> name,
Handle<Object> value,
LanguageMode language_mode,
StoreFromKeyed store_mode) {
LookupIterator it =
LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_mode));
return value;
}
MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> receiver,
Handle<Name> name,
Handle<JSReceiver> holder) {
LookupIterator it = LookupIterator::PropertyOrElement(
name->GetIsolate(), receiver, name, holder);
return GetProperty(&it);
}
void JSReceiver::initialize_properties() {
DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_property_dictionary()));
if (map()->is_dictionary_map()) {
WRITE_FIELD(this, kPropertiesOrHashOffset,
GetHeap()->empty_property_dictionary());
} else {
WRITE_FIELD(this, kPropertiesOrHashOffset, GetHeap()->empty_fixed_array());
}
}
bool JSReceiver::HasFastProperties() const {
DCHECK_EQ(raw_properties_or_hash()->IsDictionary(),
map()->is_dictionary_map());
return !map()->is_dictionary_map();
}
NameDictionary* JSReceiver::property_dictionary() const {
DCHECK(!IsJSGlobalObject());
DCHECK(!HasFastProperties());
Object* prop = raw_properties_or_hash();
if (prop->IsSmi()) {
return GetHeap()->empty_property_dictionary();
}
return NameDictionary::cast(prop);
}
// TODO(gsathya): Pass isolate directly to this function and access
// the heap from this.
PropertyArray* JSReceiver::property_array() const {
DCHECK(HasFastProperties());
Object* prop = raw_properties_or_hash();
if (prop->IsSmi() || prop == GetHeap()->empty_fixed_array()) {
return GetHeap()->empty_property_array();
}
return PropertyArray::cast(prop);
}
Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
Handle<Name> name) {
LookupIterator it = LookupIterator::PropertyOrElement(object->GetIsolate(),
object, name, object);
return HasProperty(&it);
}
Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
uint32_t index) {
if (object->IsJSModuleNamespace()) return Just(false);
if (object->IsJSObject()) { // Shortcut.
LookupIterator it(object->GetIsolate(), object, index, object,
LookupIterator::OWN);
return HasProperty(&it);
}
Maybe<PropertyAttributes> attributes =
JSReceiver::GetOwnPropertyAttributes(object, index);
MAYBE_RETURN(attributes, Nothing<bool>());
return Just(attributes.FromJust() != ABSENT);
}
Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
Handle<JSReceiver> object, Handle<Name> name) {
LookupIterator it = LookupIterator::PropertyOrElement(name->GetIsolate(),
object, name, object);
return GetPropertyAttributes(&it);
}
Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
Handle<JSReceiver> object, Handle<Name> name) {
LookupIterator it = LookupIterator::PropertyOrElement(
name->GetIsolate(), object, name, object, LookupIterator::OWN);
return GetPropertyAttributes(&it);
}
Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
Handle<JSReceiver> object, uint32_t index) {
LookupIterator it(object->GetIsolate(), object, index, object,
LookupIterator::OWN);
return GetPropertyAttributes(&it);
}
Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
LookupIterator it(object->GetIsolate(), object, index, object);
return HasProperty(&it);
}
Maybe<PropertyAttributes> JSReceiver::GetElementAttributes(
Handle<JSReceiver> object, uint32_t index) {
Isolate* isolate = object->GetIsolate();
LookupIterator it(isolate, object, index, object);
return GetPropertyAttributes(&it);
}
Maybe<PropertyAttributes> JSReceiver::GetOwnElementAttributes(
Handle<JSReceiver> object, uint32_t index) {
Isolate* isolate = object->GetIsolate();
LookupIterator it(isolate, object, index, object, LookupIterator::OWN);
return GetPropertyAttributes(&it);
}
bool JSGlobalObject::IsDetached() {
return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this);
}
bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject* global) const {
const PrototypeIterator iter(this->GetIsolate(),
const_cast<JSGlobalProxy*>(this));
return iter.GetCurrent() != global;
}
inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) {
DCHECK_GE(embedder_field_count, 0);
return kSize + embedder_field_count * kPointerSize;
}
Smi* JSReceiver::GetOrCreateIdentityHash(Isolate* isolate) {
return IsJSProxy() ? JSProxy::cast(this)->GetOrCreateIdentityHash(isolate)
: JSObject::cast(this)->GetOrCreateIdentityHash(isolate);
}
Object* JSReceiver::GetIdentityHash(Isolate* isolate) {
return IsJSProxy() ? JSProxy::cast(this)->GetIdentityHash()
: JSObject::cast(this)->GetIdentityHash(isolate);
}
bool AccessorInfo::all_can_read() {
return BooleanBit::get(flag(), kAllCanReadBit);
}
void AccessorInfo::set_all_can_read(bool value) {
set_flag(BooleanBit::set(flag(), kAllCanReadBit, value));
}
bool AccessorInfo::all_can_write() {
return BooleanBit::get(flag(), kAllCanWriteBit);
}
void AccessorInfo::set_all_can_write(bool value) {
set_flag(BooleanBit::set(flag(), kAllCanWriteBit, value));
}
bool AccessorInfo::is_special_data_property() {
return BooleanBit::get(flag(), kSpecialDataProperty);
}
void AccessorInfo::set_is_special_data_property(bool value) {
set_flag(BooleanBit::set(flag(), kSpecialDataProperty, value));
}
bool AccessorInfo::replace_on_access() {
return BooleanBit::get(flag(), kReplaceOnAccess);
}
void AccessorInfo::set_replace_on_access(bool value) {
set_flag(BooleanBit::set(flag(), kReplaceOnAccess, value));
}
bool AccessorInfo::is_sloppy() { return BooleanBit::get(flag(), kIsSloppy); }
void AccessorInfo::set_is_sloppy(bool value) {
set_flag(BooleanBit::set(flag(), kIsSloppy, value));
}
PropertyAttributes AccessorInfo::property_attributes() {
return AttributesField::decode(static_cast<uint32_t>(flag()));
}
void AccessorInfo::set_property_attributes(PropertyAttributes attributes) {
set_flag(AttributesField::update(flag(), attributes));
}
bool FunctionTemplateInfo::IsTemplateFor(JSObject* object) {
return IsTemplateFor(object->map());
}
bool AccessorInfo::IsCompatibleReceiver(Object* receiver) {
if (!HasExpectedReceiverType()) return true;
if (!receiver->IsJSObject()) return false;
return FunctionTemplateInfo::cast(expected_receiver_type())
->IsTemplateFor(JSObject::cast(receiver)->map());
}
bool AccessorInfo::HasExpectedReceiverType() {
return expected_receiver_type()->IsFunctionTemplateInfo();
}
Object* AccessorPair::get(AccessorComponent component) {
return component == ACCESSOR_GETTER ? getter() : setter();
}
void AccessorPair::set(AccessorComponent component, Object* value) {
if (component == ACCESSOR_GETTER) {
set_getter(value);
} else {
set_setter(value);
}
}
void AccessorPair::SetComponents(Object* getter, Object* setter) {
Isolate* isolate = GetIsolate();
if (!getter->IsNull(isolate)) set_getter(getter);
if (!setter->IsNull(isolate)) set_setter(setter);
}
bool AccessorPair::Equals(AccessorPair* pair) {
return (this == pair) || pair->Equals(getter(), setter());
}
bool AccessorPair::Equals(Object* getter_value, Object* setter_value) {
return (getter() == getter_value) && (setter() == setter_value);
}
bool AccessorPair::ContainsAccessor() {
return IsJSAccessor(getter()) || IsJSAccessor(setter());
}
bool AccessorPair::IsJSAccessor(Object* obj) {
return obj->IsCallable() || obj->IsUndefined(GetIsolate());
}
template <typename Derived, typename Shape>
void Dictionary<Derived, Shape>::ClearEntry(int entry) {
Object* the_hole = this->GetHeap()->the_hole_value();
PropertyDetails details = PropertyDetails::Empty();
Derived::cast(this)->SetEntry(entry, the_hole, the_hole, details);
}
template <typename Derived, typename Shape>
void Dictionary<Derived, Shape>::SetEntry(int entry, Object* key, Object* value,
PropertyDetails details) {
DCHECK(Dictionary::kEntrySize == 2 || Dictionary::kEntrySize == 3);
DCHECK(!key->IsName() || details.dictionary_index() > 0);
int index = DerivedHashTable::EntryToIndex(entry);
DisallowHeapAllocation no_gc;
WriteBarrierMode mode = this->GetWriteBarrierMode(no_gc);
this->set(index + Derived::kEntryKeyIndex, key, mode);
this->set(index + Derived::kEntryValueIndex, value, mode);
if (Shape::kHasDetails) DetailsAtPut(entry, details);
}
Object* GlobalDictionaryShape::Unwrap(Object* object) {
return PropertyCell::cast(object)->name();
}
Name* NameDictionary::NameAt(int entry) { return Name::cast(KeyAt(entry)); }
PropertyCell* GlobalDictionary::CellAt(int entry) {
DCHECK(KeyAt(entry)->IsPropertyCell());
return PropertyCell::cast(KeyAt(entry));
}
bool GlobalDictionaryShape::IsLive(Isolate* isolate, Object* k) {
Heap* heap = isolate->heap();
DCHECK_NE(heap->the_hole_value(), k);
return k != heap->undefined_value();
}
bool GlobalDictionaryShape::IsKey(Isolate* isolate, Object* k) {
return IsLive(isolate, k) &&
!PropertyCell::cast(k)->value()->IsTheHole(isolate);
}
Name* GlobalDictionary::NameAt(int entry) { return CellAt(entry)->name(); }
Object* GlobalDictionary::ValueAt(int entry) { return CellAt(entry)->value(); }
void GlobalDictionary::SetEntry(int entry, Object* key, Object* value,
PropertyDetails details) {
DCHECK_EQ(key, PropertyCell::cast(value)->name());
set(EntryToIndex(entry) + kEntryKeyIndex, value);
DetailsAtPut(entry, details);
}
void GlobalDictionary::ValueAtPut(int entry, Object* value) {
set(EntryToIndex(entry), value);
}
bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
DCHECK(other->IsNumber());
return key == static_cast<uint32_t>(other->Number());
}
uint32_t UnseededNumberDictionaryShape::Hash(Isolate* isolate, uint32_t key) {
return ComputeIntegerHash(key);
}
uint32_t UnseededNumberDictionaryShape::HashForObject(Isolate* isolate,
Object* other) {
DCHECK(other->IsNumber());
return ComputeIntegerHash(static_cast<uint32_t>(other->Number()));
}
Map* UnseededNumberDictionaryShape::GetMap(Isolate* isolate) {
return isolate->heap()->unseeded_number_dictionary_map();
}
uint32_t SeededNumberDictionaryShape::Hash(Isolate* isolate, uint32_t key) {
return ComputeIntegerHash(key, isolate->heap()->HashSeed());
}
uint32_t SeededNumberDictionaryShape::HashForObject(Isolate* isolate,
Object* other) {
DCHECK(other->IsNumber());
return ComputeIntegerHash(static_cast<uint32_t>(other->Number()),
isolate->heap()->HashSeed());
}
Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) {
return isolate->factory()->NewNumberFromUint(key);
}
bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) {
DCHECK(other->IsTheHole(key->GetIsolate()) ||
Name::cast(other)->IsUniqueName());
DCHECK(key->IsUniqueName());
return *key == other;
}
uint32_t NameDictionaryShape::Hash(Isolate* isolate, Handle<Name> key) {
return key->Hash();
}
uint32_t NameDictionaryShape::HashForObject(Isolate* isolate, Object* other) {
return Name::cast(other)->Hash();
}
bool GlobalDictionaryShape::IsMatch(Handle<Name> key, Object* other) {
DCHECK(PropertyCell::cast(other)->name()->IsUniqueName());
return *key == PropertyCell::cast(other)->name();
}
uint32_t GlobalDictionaryShape::HashForObject(Isolate* isolate, Object* other) {
return PropertyCell::cast(other)->name()->Hash();
}
Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate,
Handle<Name> key) {
DCHECK(key->IsUniqueName());
return key;
}
template <typename Dictionary>
PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary* dict, int entry) {
DCHECK_LE(0, entry); // Not found is -1, which is not caught by get().
return dict->CellAt(entry)->property_details();
}
template <typename Dictionary>
void GlobalDictionaryShape::DetailsAtPut(Dictionary* dict, int entry,
PropertyDetails value) {
DCHECK_LE(0, entry); // Not found is -1, which is not caught by get().
PropertyCell* cell = dict->CellAt(entry);
if (cell->property_details().IsReadOnly() != value.IsReadOnly()) {
cell->dependent_code()->DeoptimizeDependentCodeGroup(
cell->GetIsolate(), DependentCode::kPropertyCellChangedGroup);
}
cell->set_property_details(value);
}
bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
return key->SameValue(other);
}
uint32_t ObjectHashTableShape::Hash(Isolate* isolate, Handle<Object> key) {
return Smi::ToInt(key->GetHash());
}
uint32_t ObjectHashTableShape::HashForObject(Isolate* isolate, Object* other) {
return Smi::ToInt(other->GetHash());
}
Handle<Object> ObjectHashTableShape::AsHandle(Isolate* isolate,
Handle<Object> key) {
return key;
}
Handle<ObjectHashTable> ObjectHashTable::Shrink(Handle<ObjectHashTable> table) {
return DerivedHashTable::Shrink(table);
}
template <int entrysize>
bool WeakHashTableShape<entrysize>::IsMatch(Handle<Object> key, Object* other) {
if (other->IsWeakCell()) other = WeakCell::cast(other)->value();
return key->IsWeakCell() ? WeakCell::cast(*key)->value() == other
: *key == other;
}
template <int entrysize>
uint32_t WeakHashTableShape<entrysize>::Hash(Isolate* isolate,
Handle<Object> key) {
intptr_t hash =
key->IsWeakCell()
? reinterpret_cast<intptr_t>(WeakCell::cast(*key)->value())
: reinterpret_cast<intptr_t>(*key);
return (uint32_t)(hash & 0xFFFFFFFF);
}
template <int entrysize>
uint32_t WeakHashTableShape<entrysize>::HashForObject(Isolate* isolate,
Object* other) {
if (other->IsWeakCell()) other = WeakCell::cast(other)->value();
intptr_t hash = reinterpret_cast<intptr_t>(other);
return (uint32_t)(hash & 0xFFFFFFFF);
}
template <int entrysize>
Handle<Object> WeakHashTableShape<entrysize>::AsHandle(Isolate* isolate,
Handle<Object> key) {
return key;
}
void Map::ClearCodeCache(Heap* heap) {
// No write barrier is needed since empty_fixed_array is not in new space.
// Please note this function is used during marking:
// - MarkCompactCollector::MarkUnmarkedObject
// - IncrementalMarking::Step
WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array());
}
int Map::SlackForArraySize(int old_size, int size_limit) {
const int max_slack = size_limit - old_size;
CHECK_LE(0, max_slack);
if (old_size < 4) {
DCHECK_LE(1, max_slack);
return 1;
}
return Min(max_slack, old_size / 4);
}
void JSArray::set_length(Smi* length) {
// Don't need a write barrier for a Smi.
set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER);
}
bool JSArray::SetLengthWouldNormalize(Heap* heap, uint32_t new_length) {
return new_length > kMaxFastArrayLength;
}
bool JSArray::AllowsSetLength() {
bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
DCHECK(result == !HasFixedTypedArrayElements());
return result;
}
void JSArray::SetContent(Handle<JSArray> array,
Handle<FixedArrayBase> storage) {
EnsureCanContainElements(array, storage, storage->length(),
ALLOW_COPIED_DOUBLE_ELEMENTS);
DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() &&
IsDoubleElementsKind(array->GetElementsKind())) ||
((storage->map() != array->GetHeap()->fixed_double_array_map()) &&
(IsObjectElementsKind(array->GetElementsKind()) ||
(IsSmiElementsKind(array->GetElementsKind()) &&
Handle<FixedArray>::cast(storage)->ContainsOnlySmisOrHoles()))));
array->set_elements(*storage);
array->set_length(Smi::FromInt(storage->length()));
}
bool JSArray::HasArrayPrototype(Isolate* isolate) {
return map()->prototype() == *isolate->initial_array_prototype();
}
int TypeFeedbackInfo::ic_total_count() {
int current = Smi::ToInt(READ_FIELD(this, kStorage1Offset));
return ICTotalCountField::decode(current);
}
void TypeFeedbackInfo::set_ic_total_count(int count) {
int value = Smi::ToInt(READ_FIELD(this, kStorage1Offset));
value = ICTotalCountField::update(value,
ICTotalCountField::decode(count));
WRITE_FIELD(this, kStorage1Offset, Smi::FromInt(value));
}
int TypeFeedbackInfo::ic_with_type_info_count() {
int current = Smi::ToInt(READ_FIELD(this, kStorage2Offset));
return ICsWithTypeInfoCountField::decode(current);
}
void TypeFeedbackInfo::change_ic_with_type_info_count(int delta) {
if (delta == 0) return;
int value = Smi::ToInt(READ_FIELD(this, kStorage2Offset));
int new_count = ICsWithTypeInfoCountField::decode(value) + delta;
// We can get negative count here when the type-feedback info is
// shared between two code objects. The can only happen when
// the debugger made a shallow copy of code object (see Heap::CopyCode).
// Since we do not optimize when the debugger is active, we can skip
// this counter update.
if (new_count >= 0) {
new_count &= ICsWithTypeInfoCountField::kMask;
value = ICsWithTypeInfoCountField::update(value, new_count);
WRITE_FIELD(this, kStorage2Offset, Smi::FromInt(value));
}
}
int TypeFeedbackInfo::ic_generic_count() {
return Smi::ToInt(READ_FIELD(this, kStorage3Offset));
}
void TypeFeedbackInfo::change_ic_generic_count(int delta) {
if (delta == 0) return;
int new_count = ic_generic_count() + delta;
if (new_count >= 0) {
new_count &= ~Smi::kMinValue;
WRITE_FIELD(this, kStorage3Offset, Smi::FromInt(new_count));
}
}
void TypeFeedbackInfo::initialize_storage() {
WRITE_FIELD(this, kStorage1Offset, Smi::kZero);
WRITE_FIELD(this, kStorage2Offset, Smi::kZero);
WRITE_FIELD(this, kStorage3Offset, Smi::kZero);
}
void TypeFeedbackInfo::change_own_type_change_checksum() {
int value = Smi::ToInt(READ_FIELD(this, kStorage1Offset));
int checksum = OwnTypeChangeChecksum::decode(value);
checksum = (checksum + 1) % (1 << kTypeChangeChecksumBits);
value = OwnTypeChangeChecksum::update(value, checksum);
// Ensure packed bit field is in Smi range.
if (value > Smi::kMaxValue) value |= Smi::kMinValue;
if (value < Smi::kMinValue) value &= ~Smi::kMinValue;
WRITE_FIELD(this, kStorage1Offset, Smi::FromInt(value));
}
void TypeFeedbackInfo::set_inlined_type_change_checksum(int checksum) {
int value = Smi::ToInt(READ_FIELD(this, kStorage2Offset));
int mask = (1 << kTypeChangeChecksumBits) - 1;
value = InlinedTypeChangeChecksum::update(value, checksum & mask);
// Ensure packed bit field is in Smi range.
if (value > Smi::kMaxValue) value |= Smi::kMinValue;
if (value < Smi::kMinValue) value &= ~Smi::kMinValue;
WRITE_FIELD(this, kStorage2Offset, Smi::FromInt(value));
}
int TypeFeedbackInfo::own_type_change_checksum() {
int value = Smi::ToInt(READ_FIELD(this, kStorage1Offset));
return OwnTypeChangeChecksum::decode(value);
}
bool TypeFeedbackInfo::matches_inlined_type_change_checksum(int checksum) {
int value = Smi::ToInt(READ_FIELD(this, kStorage2Offset));
int mask = (1 << kTypeChangeChecksumBits) - 1;
return InlinedTypeChangeChecksum::decode(value) == (checksum & mask);
}
Relocatable::Relocatable(Isolate* isolate) {
isolate_ = isolate;
prev_ = isolate->relocatable_top();
isolate->set_relocatable_top(this);
}
Relocatable::~Relocatable() {
DCHECK_EQ(isolate_->relocatable_top(), this);
isolate_->set_relocatable_top(prev_);
}
template<class Derived, class TableType>
Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
TableType* table(TableType::cast(this->table()));
int index = Smi::ToInt(this->index());
Object* key = table->KeyAt(index);
DCHECK(!key->IsTheHole(table->GetIsolate()));
return key;
}
Object* JSMapIterator::CurrentValue() {
OrderedHashMap* table(OrderedHashMap::cast(this->table()));
int index = Smi::ToInt(this->index());
Object* value = table->ValueAt(index);
DCHECK(!value->IsTheHole(table->GetIsolate()));
return value;
}
// Predictably converts HeapObject* or Address to uint32 by calculating
// offset of the address in respective MemoryChunk.
static inline uint32_t ObjectAddressForHashing(void* object) {
uint32_t value = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(object));
return value & MemoryChunk::kAlignmentMask;
}
static inline Handle<Object> MakeEntryPair(Isolate* isolate, uint32_t index,
Handle<Object> value) {
Handle<Object> key = isolate->factory()->Uint32ToString(index);
Handle<FixedArray> entry_storage =
isolate->factory()->NewUninitializedFixedArray(2);
{
entry_storage->set(0, *key, SKIP_WRITE_BARRIER);
entry_storage->set(1, *value, SKIP_WRITE_BARRIER);
}
return isolate->factory()->NewJSArrayWithElements(entry_storage,
PACKED_ELEMENTS, 2);
}
static inline Handle<Object> MakeEntryPair(Isolate* isolate, Handle<Object> key,
Handle<Object> value) {
Handle<FixedArray> entry_storage =
isolate->factory()->NewUninitializedFixedArray(2);
{
entry_storage->set(0, *key, SKIP_WRITE_BARRIER);
entry_storage->set(1, *value, SKIP_WRITE_BARRIER);
}
return isolate->factory()->NewJSArrayWithElements(entry_storage,
PACKED_ELEMENTS, 2);
}
ACCESSORS(JSIteratorResult, value, Object, kValueOffset)
ACCESSORS(JSIteratorResult, done, Object, kDoneOffset)
ACCESSORS(JSArrayIterator, object, Object, kIteratedObjectOffset)
ACCESSORS(JSArrayIterator, index, Object, kNextIndexOffset)
ACCESSORS(JSArrayIterator, object_map, Object, kIteratedObjectMapOffset)
ACCESSORS(JSAsyncFromSyncIterator, sync_iterator, JSReceiver,
kSyncIteratorOffset)
ACCESSORS(JSStringIterator, string, String, kStringOffset)
SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
bool ScopeInfo::IsAsmModule() { return AsmModuleField::decode(Flags()); }
bool ScopeInfo::HasSimpleParameters() {
return HasSimpleParametersField::decode(Flags());
}
#define FIELD_ACCESSORS(name) \
void ScopeInfo::Set##name(int value) { set(k##name, Smi::FromInt(value)); } \
int ScopeInfo::name() { \
if (length() > 0) { \
return Smi::ToInt(get(k##name)); \
} else { \
return 0; \
} \
}
FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(FIELD_ACCESSORS)
#undef FIELD_ACCESSORS
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_INL_H_
| [
"lionel.fenneteau@gmail.com"
] | lionel.fenneteau@gmail.com |
28e234ec461f9d6bfa0bd0bee1442bf00057ec61 | 06612d1391a80ab69726ff491e49b7a0b9439b10 | /utils/TableGen/InstrEnumEmitter.h | b39fef2d433c9e4db86809fc6e13b5206033924d | [
"NCSA"
] | permissive | bratsche/llvm | 1bc649a078dfb8c61c579dc3b373eab5dcd94024 | 7c3ddf82afd4c74e76dfa9c938d290b3e2574f3f | refs/heads/master | 2021-01-22T12:02:26.956654 | 2009-04-16T05:52:18 | 2009-04-16T05:52:18 | 179,517 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 906 | h | //===- InstrEnumEmitter.h - Generate Instruction Set Enums ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This tablegen backend is responsible for emitting enums for each machine
// instruction.
//
//===----------------------------------------------------------------------===//
#ifndef INSTRENUM_EMITTER_H
#define INSTRENUM_EMITTER_H
#include "TableGenBackend.h"
namespace llvm {
class InstrEnumEmitter : public TableGenBackend {
RecordKeeper &Records;
public:
InstrEnumEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the instruction set description, returning true on failure.
void run(std::ostream &OS);
};
} // End llvm namespace
#endif
| [
"sabre@nondot.org"
] | sabre@nondot.org |
542c68a38199958e8988b9dcbbde3ab02ee7e500 | c2ed59929163fd6952085b327b12fbb2b9255fc0 | /C++_Object_Oriented/Inheritance/files/computercourse.h | c32e6181b7db6226a3224b8146172f513ae61445 | [] | no_license | wrdecurtins/Coursework | 76ef4c9f7cd93842bbe24456f1f3f7670cba3aa7 | 2d14af97ce6a106e118a20d03048e640ac58bf13 | refs/heads/main | 2023-05-04T12:55:36.961399 | 2021-05-19T03:07:43 | 2021-05-19T03:07:43 | 328,815,794 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,755 | h | //*********************INCLUDE GUARD*********************//
#ifndef __COMPUTER_COURSE_H__
#define __COMPUTER_COURSE_H__
//*********************INCLUDE GUARD*********************//
//*********************REQUIRED INCLUDES*********************//
#include <string>
#include "course.h"
//*********************REQUIRED INCLUDES*********************//
using namespace std;
//*********************START CLASS ComputerCourse DEFINITION*********************//
class ComputerCourse : public Course {
public:
ComputerCourse(void);
/* {
this->instructorName = "Alex Wollman";
this->classroomNumber = 107;
this->building = "Beacom";
this->programs[0] = "Ubuntu";
this->programs[1] = "g++";
this->programs[2] = "make";
};
*/
ComputerCourse(string paramInstructorName, int paramClassroomNumber, string paramBuilding, string paramPrograms[3]);
/* {
this->instructorName = paramInstructorName;
this->classroomNumber = paramClassroomNumber;
this->building = paramBuilding;
for ( int i = 0; i < 3; i++ )
if (paramPrograms[i] != NULL)
this->programs[i] = paramPrograms[i];
};
*/
~ComputerCourse(void);
void virtual printAll()
{
cout<< "Instructor Name : " << this->getinstructorName() << "\n";
cout<< "Classroom Number : " << this->getclassroomNumber() << "\n";
cout<< "Building Name : " << this->getbuilding() << "\n";
if (!this->programs[0].empty())
cout<< "Programs Used : ";
for ( int i = 0; i < 3; i++ )
{
if (!this->programs[i].empty())
{
cout<< this->programs[i] << " ";
}
}
}
private:
string programs[3];
};
//*********************END CLASS ComputerCourse DEFINITION*********************
#endif
| [
"will@PC.localdomain"
] | will@PC.localdomain |
beae9f224dd19c85bc3a4e14f76aae18d003a96d | e75db8d5c7e76f25c8a5b0c309062061e0298b69 | /Temp/il2cppOutput/il2cppOutput/Bulk_Assembly-CSharp_0.cpp | a0592989fc5fab675a8a633744e0ffaa4decdd49 | [] | no_license | lucasfutch/day1_shooter | 4cc148c32c1faf83471b5c7109fdab34ee4632cf | 6c000ac62ad11d36123ca17db0849bb772c1b27a | refs/heads/master | 2020-06-27T11:33:53.206627 | 2017-07-24T23:08:20 | 2017-07-24T23:08:20 | 97,052,068 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 315,796 | cpp | #include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <limits>
#include <assert.h>
#include "class-internals.h"
#include "codegen/il2cpp-codegen.h"
#include "mscorlib_System_Array3829468939.h"
#include "AssemblyU2DCSharp_U3CModuleU3E3783534214.h"
#include "AssemblyU2DCSharp_AgentScript536016518.h"
#include "mscorlib_System_Void1841601450.h"
#include "UnityEngine_UnityEngine_RaycastHit87180320.h"
#include "UnityEngine_UnityEngine_MonoBehaviour1158329972.h"
#include "UnityEngine_UnityEngine_AI_NavMeshAgent2761625415.h"
#include "UnityEngine_UnityEngine_Component3819376471.h"
#include "UnityEngine_UnityEngine_Animator69676727.h"
#include "UnityEngine_UnityEngine_Vector32243707580.h"
#include "UnityEngine_UnityEngine_Ray2469606224.h"
#include "mscorlib_System_String2029220233.h"
#include "mscorlib_System_Object2689449295.h"
#include "mscorlib_System_Boolean3825574718.h"
#include "mscorlib_System_Int322071877448.h"
#include "UnityEngine_UnityEngine_Camera189460977.h"
#include "UnityEngine_UnityEngine_Collider3497673348.h"
#include "mscorlib_System_Single2076509932.h"
#include "AssemblyU2DCSharp_changeMenuScript586204708.h"
#include "UnityEngine_UnityEngine_SceneManagement_LoadSceneM2981886439.h"
#include "AssemblyU2DCSharp_ColorChangedEvent2990895397.h"
#include "UnityEngine_UnityEngine_Events_UnityEvent_1_gen2058742090.h"
#include "AssemblyU2DCSharp_ColorImage3157136356.h"
#include "mscorlib_System_IntPtr2504060609.h"
#include "UnityEngine_UI_UnityEngine_UI_Image2042527209.h"
#include "AssemblyU2DCSharp_ColorPicker3035206225.h"
#include "UnityEngine_UnityEngine_Color2020392075.h"
#include "UnityEngine_UnityEngine_Events_UnityAction_1_gen3386977826.h"
#include "UnityEngine_UI_UnityEngine_UI_Graphic2426225576.h"
#include "AssemblyU2DCSharp_ColorLabel1884607337.h"
#include "UnityEngine_UI_UnityEngine_UI_Text356221433.h"
#include "UnityEngine_UnityEngine_Object1021602117.h"
#include "AssemblyU2DCSharp_HSVChangedEvent1170297569.h"
#include "UnityEngine_UnityEngine_Events_UnityAction_3_gen235051313.h"
#include "UnityEngine_UnityEngine_Events_UnityEvent_3_gen4197061729.h"
#include "AssemblyU2DCSharp_ColorValues3063098635.h"
#include "AssemblyU2DCSharp_HsvColor1057062332.h"
#include "mscorlib_System_Double4078015681.h"
#include "mscorlib_System_NotImplementedException2785117854.h"
#include "AssemblyU2DCSharp_ColorPickerTester1006114474.h"
#include "UnityEngine_UnityEngine_Renderer257310565.h"
#include "UnityEngine_UnityEngine_Material193706927.h"
#include "AssemblyU2DCSharp_ColorPresets4120623669.h"
#include "UnityEngine_UnityEngine_GameObject1756533147.h"
#include "AssemblyU2DCSharp_ColorSlider2729134766.h"
#include "UnityEngine_UI_UnityEngine_UI_Slider297367283.h"
#include "UnityEngine_UI_UnityEngine_UI_Slider_SliderEvent2111116400.h"
#include "UnityEngine_UnityEngine_Events_UnityAction_1_gen3443095683.h"
#include "UnityEngine_UnityEngine_Events_UnityEvent_1_gen2114859947.h"
#include "AssemblyU2DCSharp_ColorSliderImage376502149.h"
#include "UnityEngine_UnityEngine_RectTransform3349966182.h"
#include "UnityEngine_UnityEngine_Transform3275118058.h"
#include "UnityEngine_UI_UnityEngine_UI_RawImage2749640213.h"
#include "UnityEngine_UnityEngine_Texture2243626319.h"
#include "UnityEngine_UnityEngine_Color32874517518.h"
#include "UnityEngine_UnityEngine_HideFlags1434274199.h"
#include "UnityEngine_UnityEngine_Rect3681755626.h"
#include "UnityEngine_UnityEngine_Texture2D3542995729.h"
#include "mscorlib_System_Byte3683104436.h"
#include "UnityEngine_UI_UnityEngine_UI_Slider_Direction1525323322.h"
#include "AssemblyU2DCSharp_destructor1745712409.h"
#include "AssemblyU2DCSharp_disappearOnFall3898622429.h"
#include "UnityEngine_UnityEngine_Collision2876846408.h"
#include "AssemblyU2DCSharp_HexColorField4192118964.h"
#include "UnityEngine_UI_UnityEngine_UI_InputField1631627530.h"
#include "UnityEngine_UI_UnityEngine_UI_InputField_SubmitEven907918422.h"
#include "UnityEngine_UnityEngine_Events_UnityAction_1_gen3395805984.h"
#include "UnityEngine_UnityEngine_Events_UnityEvent_1_gen2067570248.h"
#include "UnityEngine_UI_UnityEngine_UI_InputField_OnChangeE2863344003.h"
#include "mscorlib_System_Globalization_NumberStyles3408984435.h"
#include "mscorlib_System_Char3454481338.h"
#include "AssemblyU2DCSharp_HSVUtil3885028383.h"
#include "AssemblyU2DCSharp_MenuScript1134262648.h"
#include "AssemblyU2DCSharp_MenuScript_MenuStates1873875456.h"
#include "AssemblyU2DCSharp_musicControl2891809704.h"
#include "UnityEngine_UnityEngine_Touch407273883.h"
#include "UnityEngine_UnityEngine_Vector22243707579.h"
#include "UnityEngine_UnityEngine_RaycastHit2D4063908774.h"
#include "UnityEngine_UnityEngine_Collider2D646061738.h"
#include "UnityEngine_UnityEngine_AudioSource1135106623.h"
#include "AssemblyU2DCSharp_ParticlePainter1073897267.h"
#include "AssemblyU2DCSharpU2Dfirstpass_UnityEngine_XR_iOS_Un496507918.h"
#include "UnityEngine_UnityEngine_ParticleSystem3394631041.h"
#include "AssemblyU2DCSharpU2Dfirstpass_UnityEngine_XR_iOS_U4198559457.h"
#include "mscorlib_System_Collections_Generic_List_1_gen1612828712.h"
#include "mscorlib_System_Collections_Generic_List_1_gen2763752173.h"
#include "UnityEngine_UnityEngine_Matrix4x42933234003.h"
#include "UnityEngine_UnityEngine_Vector42243707581.h"
#include "AssemblyU2DCSharpU2Dfirstpass_UnityEngine_XR_iOS_Un100931615.h"
#include "mscorlib_System_Collections_Generic_List_1_Enumera1147558386.h"
#include "UnityEngine_UnityEngine_ParticleSystem_Particle250075699.h"
#include "AssemblyU2DCSharp_playMusic1960384527.h"
#include "AssemblyU2DCSharp_selectBox2744202403.h"
#include "UnityEngine_UnityEngine_TouchPhase2458120420.h"
#include "AssemblyU2DCSharp_Shooting3467275689.h"
#include "UnityEngine_UI_UnityEngine_UI_Toggle3976754468.h"
#include "UnityEngine_UnityEngine_Quaternion4030073918.h"
#include "UnityEngine_UnityEngine_Rigidbody4233889191.h"
#include "AssemblyU2DCSharp_SVBoxSlider1173082351.h"
#include "AssemblyU2DCSharp_UnityEngine_UI_BoxSlider1871650694.h"
#include "AssemblyU2DCSharp_UnityEngine_UI_BoxSlider_BoxSlid1774115848.h"
#include "UnityEngine_UnityEngine_Events_UnityAction_2_gen134459182.h"
#include "UnityEngine_UnityEngine_Events_UnityEvent_2_gen2016657100.h"
#include "AssemblyU2DCSharp_TiltWindow1839185375.h"
#include "UnityEngine_UI_UnityEngine_UI_Selectable1490392188.h"
#include "UnityEngine_UI_UnityEngine_UI_CanvasUpdate1528800019.h"
#include "UnityEngine_UnityEngine_DrivenRectTransformTracker154385424.h"
#include "UnityEngine_UI_UnityEngine_EventSystems_UIBehaviou3960014691.h"
#include "UnityEngine_UnityEngine_DrivenTransformProperties2488747555.h"
#include "UnityEngine_UI_UnityEngine_EventSystems_PointerEve1599784723.h"
#include "UnityEngine_UI_UnityEngine_EventSystems_PointerEve2981963041.h"
#include "AssemblyU2DCSharp_UnityEngine_UI_BoxSlider_Axis3966514019.h"
#include "AssemblyU2DCSharp_UnityEngine_UI_BoxSlider_Directi1632189177.h"
#include "AssemblyU2DCSharp_UnityEngine_XR_iOS_UnityARAmbient680084560.h"
#include "UnityEngine_UnityEngine_Light494725636.h"
#include "AssemblyU2DCSharpU2Dfirstpass_UnityEngine_XR_iOS_U1130867170.h"
// AgentScript
struct AgentScript_t536016518;
// UnityEngine.MonoBehaviour
struct MonoBehaviour_t1158329972;
// UnityEngine.Component
struct Component_t3819376471;
// UnityEngine.AI.NavMeshAgent
struct NavMeshAgent_t2761625415;
// System.Object
struct Il2CppObject;
// UnityEngine.Animator
struct Animator_t69676727;
// UnityEngine.Camera
struct Camera_t189460977;
// UnityEngine.Collider
struct Collider_t3497673348;
// System.String
struct String_t;
// changeMenuScript
struct changeMenuScript_t586204708;
// ColorChangedEvent
struct ColorChangedEvent_t2990895397;
// UnityEngine.Events.UnityEvent`1<UnityEngine.Color>
struct UnityEvent_1_t2058742090;
// ColorImage
struct ColorImage_t3157136356;
// UnityEngine.UI.Image
struct Image_t2042527209;
// UnityEngine.Events.UnityAction`1<UnityEngine.Color>
struct UnityAction_1_t3386977826;
// ColorLabel
struct ColorLabel_t1884607337;
// UnityEngine.UI.Text
struct Text_t356221433;
// UnityEngine.Object
struct Object_t1021602117;
// UnityEngine.Events.UnityAction`3<System.Single,System.Single,System.Single>
struct UnityAction_3_t235051313;
// UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>
struct UnityEvent_3_t4197061729;
// ColorPicker
struct ColorPicker_t3035206225;
// HSVChangedEvent
struct HSVChangedEvent_t1170297569;
// System.NotImplementedException
struct NotImplementedException_t2785117854;
// ColorPickerTester
struct ColorPickerTester_t1006114474;
// UnityEngine.Renderer
struct Renderer_t257310565;
// UnityEngine.Material
struct Material_t193706927;
// ColorPresets
struct ColorPresets_t4120623669;
// UnityEngine.GameObject
struct GameObject_t1756533147;
// ColorSlider
struct ColorSlider_t2729134766;
// UnityEngine.UI.Slider
struct Slider_t297367283;
// UnityEngine.UI.Slider/SliderEvent
struct SliderEvent_t2111116400;
// UnityEngine.Events.UnityAction`1<System.Single>
struct UnityAction_1_t3443095683;
// UnityEngine.Events.UnityEvent`1<System.Single>
struct UnityEvent_1_t2114859947;
// ColorSliderImage
struct ColorSliderImage_t376502149;
// UnityEngine.RectTransform
struct RectTransform_t3349966182;
// UnityEngine.Transform
struct Transform_t3275118058;
// UnityEngine.UI.RawImage
struct RawImage_t2749640213;
// UnityEngine.Texture
struct Texture_t2243626319;
// UnityEngine.Texture2D
struct Texture2D_t3542995729;
// UnityEngine.Color32[]
struct Color32U5BU5D_t30278651;
// destructor
struct destructor_t1745712409;
// disappearOnFall
struct disappearOnFall_t3898622429;
// UnityEngine.Collision
struct Collision_t2876846408;
// HexColorField
struct HexColorField_t4192118964;
// UnityEngine.UI.InputField
struct InputField_t1631627530;
// UnityEngine.UI.InputField/SubmitEvent
struct SubmitEvent_t907918422;
// UnityEngine.Events.UnityAction`1<System.String>
struct UnityAction_1_t3395805984;
// UnityEngine.Events.UnityAction`1<System.Object>
struct UnityAction_1_t4056035046;
// UnityEngine.Events.UnityEvent`1<System.String>
struct UnityEvent_1_t2067570248;
// UnityEngine.Events.UnityEvent`1<System.Object>
struct UnityEvent_1_t2727799310;
// UnityEngine.UI.InputField/OnChangeEvent
struct OnChangeEvent_t2863344003;
// System.Object[]
struct ObjectU5BU5D_t3614634134;
// System.String[]
struct StringU5BU5D_t1642385972;
// MenuScript
struct MenuScript_t1134262648;
// musicControl
struct musicControl_t2891809704;
// UnityEngine.Collider2D
struct Collider2D_t646061738;
// UnityEngine.AudioSource
struct AudioSource_t1135106623;
// ParticlePainter
struct ParticlePainter_t1073897267;
// UnityEngine.XR.iOS.UnityARSessionNativeInterface/ARFrameUpdate
struct ARFrameUpdate_t496507918;
// UnityEngine.ParticleSystem
struct ParticleSystem_t3394631041;
// System.Collections.Generic.List`1<UnityEngine.Vector3>
struct List_1_t1612828712;
// System.Collections.Generic.List`1<UnityEngine.ParticleSystem>
struct List_1_t2763752173;
// System.Collections.Generic.List`1<System.Object>
struct List_1_t2058570427;
// UnityEngine.ParticleSystem/Particle[]
struct ParticleU5BU5D_t574222242;
// playMusic
struct playMusic_t1960384527;
// selectBox
struct selectBox_t2744202403;
// Shooting
struct Shooting_t3467275689;
// UnityEngine.UI.Toggle
struct Toggle_t3976754468;
// UnityEngine.Rigidbody
struct Rigidbody_t4233889191;
// SVBoxSlider
struct SVBoxSlider_t1173082351;
// UnityEngine.UI.BoxSlider
struct BoxSlider_t1871650694;
// UnityEngine.UI.BoxSlider/BoxSliderEvent
struct BoxSliderEvent_t1774115848;
// UnityEngine.Events.UnityAction`2<System.Single,System.Single>
struct UnityAction_2_t134459182;
// UnityEngine.Events.UnityEvent`2<System.Single,System.Single>
struct UnityEvent_2_t2016657100;
// TiltWindow
struct TiltWindow_t1839185375;
// UnityEngine.UI.Selectable
struct Selectable_t1490392188;
// UnityEngine.EventSystems.UIBehaviour
struct UIBehaviour_t3960014691;
// UnityEngine.EventSystems.PointerEventData
struct PointerEventData_t1599784723;
// UnityEngine.XR.iOS.UnityARAmbient
struct UnityARAmbient_t680084560;
// UnityEngine.Light
struct Light_t494725636;
// UnityEngine.XR.iOS.UnityARSessionNativeInterface
struct UnityARSessionNativeInterface_t1130867170;
extern Il2CppClass* RaycastHit_t87180320_il2cpp_TypeInfo_var;
extern const uint32_t AgentScript__ctor_m2829665649_MetadataUsageId;
extern const MethodInfo* Component_GetComponent_TisNavMeshAgent_t2761625415_m3828941945_MethodInfo_var;
extern const MethodInfo* Component_GetComponent_TisAnimator_t69676727_m475627522_MethodInfo_var;
extern const uint32_t AgentScript_Start_m3621949025_MetadataUsageId;
extern Il2CppClass* Input_t1785128008_il2cpp_TypeInfo_var;
extern Il2CppClass* Debug_t1368543263_il2cpp_TypeInfo_var;
extern Il2CppCodeGenString* _stringLiteral1776456860;
extern Il2CppCodeGenString* _stringLiteral1071510377;
extern Il2CppCodeGenString* _stringLiteral1492391884;
extern Il2CppCodeGenString* _stringLiteral551762609;
extern const uint32_t AgentScript_Update_m198097924_MetadataUsageId;
extern const MethodInfo* UnityEvent_1__ctor_m117795578_MethodInfo_var;
extern const uint32_t ColorChangedEvent__ctor_m3710136698_MetadataUsageId;
extern Il2CppClass* UnityAction_1_t3386977826_il2cpp_TypeInfo_var;
extern const MethodInfo* Component_GetComponent_TisImage_t2042527209_m2189462422_MethodInfo_var;
extern const MethodInfo* ColorImage_ColorChanged_m2780022934_MethodInfo_var;
extern const MethodInfo* UnityAction_1__ctor_m3329809356_MethodInfo_var;
extern const MethodInfo* UnityEvent_1_AddListener_m903508446_MethodInfo_var;
extern const uint32_t ColorImage_Awake_m1432153760_MetadataUsageId;
extern const MethodInfo* UnityEvent_1_RemoveListener_m1138414664_MethodInfo_var;
extern const uint32_t ColorImage_OnDestroy_m537617202_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral2880467378;
extern const uint32_t ColorLabel__ctor_m3361268158_MetadataUsageId;
extern const MethodInfo* Component_GetComponent_TisText_t356221433_m1342661039_MethodInfo_var;
extern const uint32_t ColorLabel_Awake_m1477595641_MetadataUsageId;
extern Il2CppClass* Object_t1021602117_il2cpp_TypeInfo_var;
extern Il2CppClass* UnityAction_3_t235051313_il2cpp_TypeInfo_var;
extern const MethodInfo* ColorLabel_ColorChanged_m35916549_MethodInfo_var;
extern const MethodInfo* ColorLabel_HSVChanged_m3658710332_MethodInfo_var;
extern const MethodInfo* UnityAction_3__ctor_m3626891334_MethodInfo_var;
extern const MethodInfo* UnityEvent_3_AddListener_m3608966849_MethodInfo_var;
extern const uint32_t ColorLabel_OnEnable_m3391994902_MetadataUsageId;
extern const MethodInfo* UnityEvent_3_RemoveListener_m2407167912_MethodInfo_var;
extern const uint32_t ColorLabel_OnDestroy_m648294215_MetadataUsageId;
extern Il2CppClass* String_t_il2cpp_TypeInfo_var;
extern Il2CppCodeGenString* _stringLiteral372029313;
extern const uint32_t ColorLabel_UpdateValue_m3108932048_MetadataUsageId;
extern Il2CppClass* Int32_t2071877448_il2cpp_TypeInfo_var;
extern Il2CppClass* Mathf_t2336485820_il2cpp_TypeInfo_var;
extern Il2CppCodeGenString* _stringLiteral811305532;
extern const uint32_t ColorLabel_ConvertToDisplayString_m1654160419_MetadataUsageId;
extern Il2CppClass* ColorChangedEvent_t2990895397_il2cpp_TypeInfo_var;
extern Il2CppClass* HSVChangedEvent_t1170297569_il2cpp_TypeInfo_var;
extern const uint32_t ColorPicker__ctor_m1239957560_MetadataUsageId;
extern const MethodInfo* UnityEvent_1_Invoke_m2213115825_MethodInfo_var;
extern const MethodInfo* UnityEvent_3_Invoke_m2734200716_MethodInfo_var;
extern const uint32_t ColorPicker_SendChangedEvent_m2880248376_MetadataUsageId;
extern Il2CppClass* NotImplementedException_t2785117854_il2cpp_TypeInfo_var;
extern const uint32_t ColorPicker_GetValue_m1991475278_MetadataUsageId;
extern const MethodInfo* ColorPickerTester_U3CStartU3Em__0_m540941732_MethodInfo_var;
extern const uint32_t ColorPickerTester_Start_m2707422277_MetadataUsageId;
extern const MethodInfo* ColorPresets_ColorChanged_m578093369_MethodInfo_var;
extern const uint32_t ColorPresets_Awake_m2912318885_MetadataUsageId;
extern const MethodInfo* GameObject_GetComponent_TisImage_t2042527209_m4162535761_MethodInfo_var;
extern const uint32_t ColorPresets_CreatePresetButton_m19834235_MetadataUsageId;
extern Il2CppClass* UnityAction_1_t3443095683_il2cpp_TypeInfo_var;
extern const MethodInfo* Component_GetComponent_TisSlider_t297367283_m1462559763_MethodInfo_var;
extern const MethodInfo* ColorSlider_ColorChanged_m742523788_MethodInfo_var;
extern const MethodInfo* ColorSlider_HSVChanged_m3304896453_MethodInfo_var;
extern const MethodInfo* ColorSlider_SliderChanged_m1758874829_MethodInfo_var;
extern const MethodInfo* UnityAction_1__ctor_m2172708761_MethodInfo_var;
extern const MethodInfo* UnityEvent_1_AddListener_m2377847221_MethodInfo_var;
extern const uint32_t ColorSlider_Awake_m2035409562_MetadataUsageId;
extern const MethodInfo* UnityEvent_1_RemoveListener_m2564825698_MethodInfo_var;
extern const uint32_t ColorSlider_OnDestroy_m1119776176_MetadataUsageId;
extern Il2CppClass* RectTransform_t3349966182_il2cpp_TypeInfo_var;
extern const uint32_t ColorSliderImage_get_rectTransform_m3308471489_MetadataUsageId;
extern const MethodInfo* Component_GetComponent_TisRawImage_t2749640213_m1817787565_MethodInfo_var;
extern const uint32_t ColorSliderImage_Awake_m834120629_MetadataUsageId;
extern const MethodInfo* ColorSliderImage_ColorChanged_m3679980033_MethodInfo_var;
extern const MethodInfo* ColorSliderImage_HSVChanged_m1936863288_MethodInfo_var;
extern const uint32_t ColorSliderImage_OnEnable_m1531418098_MetadataUsageId;
extern const uint32_t ColorSliderImage_OnDisable_m2944825581_MetadataUsageId;
extern const uint32_t ColorSliderImage_OnDestroy_m2738933995_MetadataUsageId;
extern Il2CppClass* Texture2D_t3542995729_il2cpp_TypeInfo_var;
extern Il2CppClass* Color32U5BU5D_t30278651_il2cpp_TypeInfo_var;
extern const uint32_t ColorSliderImage_RegenerateTexture_m1461909699_MetadataUsageId;
extern const uint32_t destructor_Update_m1495026301_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral3318161334;
extern Il2CppCodeGenString* _stringLiteral1671082892;
extern const uint32_t disappearOnFall_OnCollisionEnter_m3509228570_MetadataUsageId;
extern Il2CppClass* UnityAction_1_t3395805984_il2cpp_TypeInfo_var;
extern const MethodInfo* Component_GetComponent_TisInputField_t1631627530_m1177654614_MethodInfo_var;
extern const MethodInfo* HexColorField_UpdateColor_m4189307031_MethodInfo_var;
extern const MethodInfo* UnityAction_1__ctor_m2212746417_MethodInfo_var;
extern const MethodInfo* UnityEvent_1_AddListener_m2046140989_MethodInfo_var;
extern const MethodInfo* HexColorField_UpdateHex_m1796725051_MethodInfo_var;
extern const uint32_t HexColorField_Awake_m306535424_MetadataUsageId;
extern const MethodInfo* UnityEvent_1_RemoveListener_m2236604102_MethodInfo_var;
extern const uint32_t HexColorField_OnDestroy_m4113204650_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral3567086134;
extern const uint32_t HexColorField_UpdateColor_m4189307031_MetadataUsageId;
extern Il2CppClass* ObjectU5BU5D_t3614634134_il2cpp_TypeInfo_var;
extern Il2CppClass* Byte_t3683104436_il2cpp_TypeInfo_var;
extern Il2CppCodeGenString* _stringLiteral3554759231;
extern Il2CppCodeGenString* _stringLiteral2608826782;
extern const uint32_t HexColorField_ColorToHex_m410116926_MetadataUsageId;
extern Il2CppClass* Regex_t1803876613_il2cpp_TypeInfo_var;
extern Il2CppClass* Char_t3454481338_il2cpp_TypeInfo_var;
extern Il2CppClass* Color32_t874517518_il2cpp_TypeInfo_var;
extern Il2CppCodeGenString* _stringLiteral4264548006;
extern Il2CppCodeGenString* _stringLiteral372029311;
extern const uint32_t HexColorField_HexToColor_m3970770477_MetadataUsageId;
extern const MethodInfo* UnityEvent_3__ctor_m3100550874_MethodInfo_var;
extern const uint32_t HSVChangedEvent__ctor_m3043072144_MetadataUsageId;
extern Il2CppClass* StringU5BU5D_t1642385972_il2cpp_TypeInfo_var;
extern Il2CppCodeGenString* _stringLiteral372029399;
extern Il2CppCodeGenString* _stringLiteral3231012694;
extern Il2CppCodeGenString* _stringLiteral372029314;
extern Il2CppCodeGenString* _stringLiteral372029393;
extern const uint32_t HsvColor_ToString_m1590809902_MetadataUsageId;
extern Il2CppClass* HsvColor_t1057062332_il2cpp_TypeInfo_var;
extern const uint32_t HSVUtil_ConvertRgbToHsv_m2238362913_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral3382319821;
extern const uint32_t MenuScript_GameOneStart_m1316928961_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral2389305449;
extern const uint32_t MenuScript_GameTwoStart_m2899916685_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral2462317915;
extern const uint32_t MenuScript_GameThreeStart_m248778275_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral2155432071;
extern const uint32_t MenuScript_BackToMenu_m2371239854_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral1225323859;
extern const uint32_t MenuScript_BackToGame_m4083340633_MetadataUsageId;
extern Il2CppClass* Physics2D_t2540166467_il2cpp_TypeInfo_var;
extern const MethodInfo* GameObject_GetComponent_TisAudioSource_t1135106623_m1072053017_MethodInfo_var;
extern const uint32_t musicControl_Update_m223845942_MetadataUsageId;
extern Il2CppClass* ARFrameUpdate_t496507918_il2cpp_TypeInfo_var;
extern Il2CppClass* UnityARSessionNativeInterface_t1130867170_il2cpp_TypeInfo_var;
extern Il2CppClass* List_1_t1612828712_il2cpp_TypeInfo_var;
extern Il2CppClass* List_1_t2763752173_il2cpp_TypeInfo_var;
extern const MethodInfo* ParticlePainter_ARFrameUpdated_m3328436002_MethodInfo_var;
extern const MethodInfo* Object_Instantiate_TisParticleSystem_t3394631041_m4293040502_MethodInfo_var;
extern const MethodInfo* List_1__ctor_m347461442_MethodInfo_var;
extern const MethodInfo* List_1__ctor_m3416249727_MethodInfo_var;
extern const MethodInfo* ParticlePainter_U3CStartU3Em__0_m3078015875_MethodInfo_var;
extern const uint32_t ParticlePainter_Start_m240231480_MetadataUsageId;
extern Il2CppClass* Matrix4x4_t2933234003_il2cpp_TypeInfo_var;
extern const MethodInfo* List_1_Add_m2338641291_MethodInfo_var;
extern const uint32_t ParticlePainter_ARFrameUpdated_m3328436002_MetadataUsageId;
extern Il2CppClass* GUI_t4082743951_il2cpp_TypeInfo_var;
extern Il2CppCodeGenString* _stringLiteral1999992571;
extern Il2CppCodeGenString* _stringLiteral1972506681;
extern Il2CppCodeGenString* _stringLiteral1077864602;
extern const uint32_t ParticlePainter_OnGUI_m1331574968_MetadataUsageId;
extern const MethodInfo* List_1_Add_m4197260563_MethodInfo_var;
extern const uint32_t ParticlePainter_RestartPainting_m3645394903_MetadataUsageId;
extern Il2CppClass* ParticleU5BU5D_t574222242_il2cpp_TypeInfo_var;
extern const MethodInfo* List_1_get_Count_m4027941115_MethodInfo_var;
extern const MethodInfo* List_1_GetEnumerator_m940839541_MethodInfo_var;
extern const MethodInfo* Enumerator_get_Current_m857008049_MethodInfo_var;
extern const MethodInfo* Enumerator_MoveNext_m2007266881_MethodInfo_var;
extern const MethodInfo* Enumerator_Dispose_m3215924523_MethodInfo_var;
extern const uint32_t ParticlePainter_Update_m3500146815_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral1809839953;
extern const uint32_t playMusic_PlayMusicFunc_m2741615981_MetadataUsageId;
extern const uint32_t playMusic_StopPlayMusicFunc_m1382748181_MetadataUsageId;
extern const MethodInfo* GameObject_GetComponent_TisplayMusic_t1960384527_m1033848332_MethodInfo_var;
extern Il2CppCodeGenString* _stringLiteral2736962493;
extern Il2CppCodeGenString* _stringLiteral489976614;
extern Il2CppCodeGenString* _stringLiteral2799618682;
extern const uint32_t selectBox_Update_m1011808971_MetadataUsageId;
extern Il2CppCodeGenString* _stringLiteral2571969280;
extern const uint32_t Shooting_Update_m1217253073_MetadataUsageId;
extern const MethodInfo* GameObject_GetComponent_TisToggle_t3976754468_m4141321564_MethodInfo_var;
extern const uint32_t Shooting_changeToggle_m2373192642_MetadataUsageId;
extern const MethodInfo* Object_Instantiate_TisGameObject_t1756533147_m3186302158_MethodInfo_var;
extern const MethodInfo* GameObject_GetComponent_TisRigidbody_t4233889191_m1060888193_MethodInfo_var;
extern Il2CppCodeGenString* _stringLiteral2965611210;
extern Il2CppCodeGenString* _stringLiteral3542231828;
extern Il2CppCodeGenString* _stringLiteral1777526720;
extern const uint32_t Shooting_Shoot_m2001385207_MetadataUsageId;
extern const uint32_t SVBoxSlider_get_rectTransform_m3427717911_MetadataUsageId;
extern const MethodInfo* Component_GetComponent_TisBoxSlider_t1871650694_m3168588160_MethodInfo_var;
extern const uint32_t SVBoxSlider_Awake_m1174811035_MetadataUsageId;
extern Il2CppClass* UnityAction_2_t134459182_il2cpp_TypeInfo_var;
extern const MethodInfo* SVBoxSlider_SliderChanged_m3739635521_MethodInfo_var;
extern const MethodInfo* UnityAction_2__ctor_m2891411084_MethodInfo_var;
extern const MethodInfo* UnityEvent_2_AddListener_m297354571_MethodInfo_var;
extern const MethodInfo* SVBoxSlider_HSVChanged_m3533720340_MethodInfo_var;
extern const uint32_t SVBoxSlider_OnEnable_m542656758_MetadataUsageId;
extern const MethodInfo* UnityEvent_2_RemoveListener_m491466926_MethodInfo_var;
extern const uint32_t SVBoxSlider_OnDisable_m2237433047_MetadataUsageId;
extern const uint32_t SVBoxSlider_OnDestroy_m1087675145_MetadataUsageId;
extern const uint32_t SVBoxSlider_RegenerateSVTexture_m4094171080_MetadataUsageId;
extern const uint32_t TiltWindow_Update_m460467911_MetadataUsageId;
extern Il2CppClass* BoxSliderEvent_t1774115848_il2cpp_TypeInfo_var;
extern Il2CppClass* Selectable_t1490392188_il2cpp_TypeInfo_var;
extern const uint32_t BoxSlider__ctor_m1006728114_MetadataUsageId;
extern const MethodInfo* BoxSlider_SetClass_TisRectTransform_t3349966182_m272479997_MethodInfo_var;
extern const uint32_t BoxSlider_set_handleRect_m168119168_MetadataUsageId;
extern const MethodInfo* BoxSlider_SetStruct_TisSingle_t2076509932_m2710312218_MethodInfo_var;
extern const uint32_t BoxSlider_set_minValue_m1004770411_MetadataUsageId;
extern const uint32_t BoxSlider_set_maxValue_m1702472861_MetadataUsageId;
extern const MethodInfo* BoxSlider_SetStruct_TisBoolean_t3825574718_m1967921404_MethodInfo_var;
extern const uint32_t BoxSlider_set_wholeNumbers_m2694006389_MetadataUsageId;
extern const uint32_t BoxSlider_get_value_m2439160562_MetadataUsageId;
extern const uint32_t BoxSlider_get_normalizedValue_m911068691_MetadataUsageId;
extern const uint32_t BoxSlider_set_normalizedValue_m2010660092_MetadataUsageId;
extern const uint32_t BoxSlider_get_valueY_m2581533163_MetadataUsageId;
extern const uint32_t BoxSlider_get_normalizedValueY_m3976688554_MetadataUsageId;
extern const uint32_t BoxSlider_set_normalizedValueY_m851020601_MetadataUsageId;
extern const MethodInfo* Component_GetComponent_TisRectTransform_t3349966182_m1310250299_MethodInfo_var;
extern const uint32_t BoxSlider_UpdateCachedReferences_m3248150675_MetadataUsageId;
extern const MethodInfo* UnityEvent_2_Invoke_m4237217379_MethodInfo_var;
extern const uint32_t BoxSlider_Set_m1512577286_MetadataUsageId;
extern const uint32_t BoxSlider_SetY_m956310887_MetadataUsageId;
extern const uint32_t BoxSlider_UpdateVisuals_m495585056_MetadataUsageId;
extern Il2CppClass* RectTransformUtility_t2941082270_il2cpp_TypeInfo_var;
extern const uint32_t BoxSlider_UpdateDrag_m1281607389_MetadataUsageId;
extern const uint32_t BoxSlider_OnPointerDown_m523869696_MetadataUsageId;
extern const MethodInfo* UnityEvent_2__ctor_m731674732_MethodInfo_var;
extern const uint32_t BoxSliderEvent__ctor_m304261805_MetadataUsageId;
extern const MethodInfo* Component_GetComponent_TisLight_t494725636_m2604108526_MethodInfo_var;
extern const uint32_t UnityARAmbient_Start_m303369171_MetadataUsageId;
// UnityEngine.GameObject[]
struct GameObjectU5BU5D_t3057952154 : public Il2CppArray
{
public:
ALIGN_FIELD (8) GameObject_t1756533147 * m_Items[1];
public:
inline GameObject_t1756533147 * GetAt(il2cpp_array_size_t index) const
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items[index];
}
inline GameObject_t1756533147 ** GetAddressAt(il2cpp_array_size_t index)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items + index;
}
inline void SetAt(il2cpp_array_size_t index, GameObject_t1756533147 * value)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
m_Items[index] = value;
Il2CppCodeGenWriteBarrier(m_Items + index, value);
}
inline GameObject_t1756533147 * GetAtUnchecked(il2cpp_array_size_t index) const
{
return m_Items[index];
}
inline GameObject_t1756533147 ** GetAddressAtUnchecked(il2cpp_array_size_t index)
{
return m_Items + index;
}
inline void SetAtUnchecked(il2cpp_array_size_t index, GameObject_t1756533147 * value)
{
m_Items[index] = value;
Il2CppCodeGenWriteBarrier(m_Items + index, value);
}
};
// UnityEngine.Color32[]
struct Color32U5BU5D_t30278651 : public Il2CppArray
{
public:
ALIGN_FIELD (8) Color32_t874517518 m_Items[1];
public:
inline Color32_t874517518 GetAt(il2cpp_array_size_t index) const
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items[index];
}
inline Color32_t874517518 * GetAddressAt(il2cpp_array_size_t index)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items + index;
}
inline void SetAt(il2cpp_array_size_t index, Color32_t874517518 value)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
m_Items[index] = value;
}
inline Color32_t874517518 GetAtUnchecked(il2cpp_array_size_t index) const
{
return m_Items[index];
}
inline Color32_t874517518 * GetAddressAtUnchecked(il2cpp_array_size_t index)
{
return m_Items + index;
}
inline void SetAtUnchecked(il2cpp_array_size_t index, Color32_t874517518 value)
{
m_Items[index] = value;
}
};
// System.Object[]
struct ObjectU5BU5D_t3614634134 : public Il2CppArray
{
public:
ALIGN_FIELD (8) Il2CppObject * m_Items[1];
public:
inline Il2CppObject * GetAt(il2cpp_array_size_t index) const
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items[index];
}
inline Il2CppObject ** GetAddressAt(il2cpp_array_size_t index)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items + index;
}
inline void SetAt(il2cpp_array_size_t index, Il2CppObject * value)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
m_Items[index] = value;
Il2CppCodeGenWriteBarrier(m_Items + index, value);
}
inline Il2CppObject * GetAtUnchecked(il2cpp_array_size_t index) const
{
return m_Items[index];
}
inline Il2CppObject ** GetAddressAtUnchecked(il2cpp_array_size_t index)
{
return m_Items + index;
}
inline void SetAtUnchecked(il2cpp_array_size_t index, Il2CppObject * value)
{
m_Items[index] = value;
Il2CppCodeGenWriteBarrier(m_Items + index, value);
}
};
// System.String[]
struct StringU5BU5D_t1642385972 : public Il2CppArray
{
public:
ALIGN_FIELD (8) String_t* m_Items[1];
public:
inline String_t* GetAt(il2cpp_array_size_t index) const
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items[index];
}
inline String_t** GetAddressAt(il2cpp_array_size_t index)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items + index;
}
inline void SetAt(il2cpp_array_size_t index, String_t* value)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
m_Items[index] = value;
Il2CppCodeGenWriteBarrier(m_Items + index, value);
}
inline String_t* GetAtUnchecked(il2cpp_array_size_t index) const
{
return m_Items[index];
}
inline String_t** GetAddressAtUnchecked(il2cpp_array_size_t index)
{
return m_Items + index;
}
inline void SetAtUnchecked(il2cpp_array_size_t index, String_t* value)
{
m_Items[index] = value;
Il2CppCodeGenWriteBarrier(m_Items + index, value);
}
};
// UnityEngine.ParticleSystem/Particle[]
struct ParticleU5BU5D_t574222242 : public Il2CppArray
{
public:
ALIGN_FIELD (8) Particle_t250075699 m_Items[1];
public:
inline Particle_t250075699 GetAt(il2cpp_array_size_t index) const
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items[index];
}
inline Particle_t250075699 * GetAddressAt(il2cpp_array_size_t index)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items + index;
}
inline void SetAt(il2cpp_array_size_t index, Particle_t250075699 value)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
m_Items[index] = value;
}
inline Particle_t250075699 GetAtUnchecked(il2cpp_array_size_t index) const
{
return m_Items[index];
}
inline Particle_t250075699 * GetAddressAtUnchecked(il2cpp_array_size_t index)
{
return m_Items + index;
}
inline void SetAtUnchecked(il2cpp_array_size_t index, Particle_t250075699 value)
{
m_Items[index] = value;
}
};
// !!0 UnityEngine.Component::GetComponent<System.Object>()
extern "C" Il2CppObject * Component_GetComponent_TisIl2CppObject_m4109961936_gshared (Component_t3819376471 * __this, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`1<UnityEngine.Color>::.ctor()
extern "C" void UnityEvent_1__ctor_m117795578_gshared (UnityEvent_1_t2058742090 * __this, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityAction`1<UnityEngine.Color>::.ctor(System.Object,System.IntPtr)
extern "C" void UnityAction_1__ctor_m3329809356_gshared (UnityAction_1_t3386977826 * __this, Il2CppObject * p0, IntPtr_t p1, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`1<UnityEngine.Color>::AddListener(UnityEngine.Events.UnityAction`1<!0>)
extern "C" void UnityEvent_1_AddListener_m903508446_gshared (UnityEvent_1_t2058742090 * __this, UnityAction_1_t3386977826 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`1<UnityEngine.Color>::RemoveListener(UnityEngine.Events.UnityAction`1<!0>)
extern "C" void UnityEvent_1_RemoveListener_m1138414664_gshared (UnityEvent_1_t2058742090 * __this, UnityAction_1_t3386977826 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityAction`3<System.Single,System.Single,System.Single>::.ctor(System.Object,System.IntPtr)
extern "C" void UnityAction_3__ctor_m3626891334_gshared (UnityAction_3_t235051313 * __this, Il2CppObject * p0, IntPtr_t p1, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>::AddListener(UnityEngine.Events.UnityAction`3<!0,!1,!2>)
extern "C" void UnityEvent_3_AddListener_m3608966849_gshared (UnityEvent_3_t4197061729 * __this, UnityAction_3_t235051313 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>::RemoveListener(UnityEngine.Events.UnityAction`3<!0,!1,!2>)
extern "C" void UnityEvent_3_RemoveListener_m2407167912_gshared (UnityEvent_3_t4197061729 * __this, UnityAction_3_t235051313 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`1<UnityEngine.Color>::Invoke(!0)
extern "C" void UnityEvent_1_Invoke_m2213115825_gshared (UnityEvent_1_t2058742090 * __this, Color_t2020392075 p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>::Invoke(!0,!1,!2)
extern "C" void UnityEvent_3_Invoke_m2734200716_gshared (UnityEvent_3_t4197061729 * __this, float p0, float p1, float p2, const MethodInfo* method);
// !!0 UnityEngine.GameObject::GetComponent<System.Object>()
extern "C" Il2CppObject * GameObject_GetComponent_TisIl2CppObject_m2812611596_gshared (GameObject_t1756533147 * __this, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityAction`1<System.Single>::.ctor(System.Object,System.IntPtr)
extern "C" void UnityAction_1__ctor_m2172708761_gshared (UnityAction_1_t3443095683 * __this, Il2CppObject * p0, IntPtr_t p1, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`1<System.Single>::AddListener(UnityEngine.Events.UnityAction`1<!0>)
extern "C" void UnityEvent_1_AddListener_m2377847221_gshared (UnityEvent_1_t2114859947 * __this, UnityAction_1_t3443095683 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`1<System.Single>::RemoveListener(UnityEngine.Events.UnityAction`1<!0>)
extern "C" void UnityEvent_1_RemoveListener_m2564825698_gshared (UnityEvent_1_t2114859947 * __this, UnityAction_1_t3443095683 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityAction`1<System.Object>::.ctor(System.Object,System.IntPtr)
extern "C" void UnityAction_1__ctor_m2836997866_gshared (UnityAction_1_t4056035046 * __this, Il2CppObject * p0, IntPtr_t p1, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`1<System.Object>::AddListener(UnityEngine.Events.UnityAction`1<!0>)
extern "C" void UnityEvent_1_AddListener_m1977283804_gshared (UnityEvent_1_t2727799310 * __this, UnityAction_1_t4056035046 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`1<System.Object>::RemoveListener(UnityEngine.Events.UnityAction`1<!0>)
extern "C" void UnityEvent_1_RemoveListener_m4278263803_gshared (UnityEvent_1_t2727799310 * __this, UnityAction_1_t4056035046 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>::.ctor()
extern "C" void UnityEvent_3__ctor_m3100550874_gshared (UnityEvent_3_t4197061729 * __this, const MethodInfo* method);
// !!0 UnityEngine.Object::Instantiate<System.Object>(!!0)
extern "C" Il2CppObject * Object_Instantiate_TisIl2CppObject_m447919519_gshared (Il2CppObject * __this /* static, unused */, Il2CppObject * p0, const MethodInfo* method);
// System.Void System.Collections.Generic.List`1<UnityEngine.Vector3>::.ctor()
extern "C" void List_1__ctor_m347461442_gshared (List_1_t1612828712 * __this, const MethodInfo* method);
// System.Void System.Collections.Generic.List`1<System.Object>::.ctor()
extern "C" void List_1__ctor_m310736118_gshared (List_1_t2058570427 * __this, const MethodInfo* method);
// System.Void System.Collections.Generic.List`1<UnityEngine.Vector3>::Add(!0)
extern "C" void List_1_Add_m2338641291_gshared (List_1_t1612828712 * __this, Vector3_t2243707580 p0, const MethodInfo* method);
// System.Void System.Collections.Generic.List`1<System.Object>::Add(!0)
extern "C" void List_1_Add_m4157722533_gshared (List_1_t2058570427 * __this, Il2CppObject * p0, const MethodInfo* method);
// System.Int32 System.Collections.Generic.List`1<UnityEngine.Vector3>::get_Count()
extern "C" int32_t List_1_get_Count_m4027941115_gshared (List_1_t1612828712 * __this, const MethodInfo* method);
// System.Collections.Generic.List`1/Enumerator<!0> System.Collections.Generic.List`1<UnityEngine.Vector3>::GetEnumerator()
extern "C" Enumerator_t1147558386 List_1_GetEnumerator_m940839541_gshared (List_1_t1612828712 * __this, const MethodInfo* method);
// !0 System.Collections.Generic.List`1/Enumerator<UnityEngine.Vector3>::get_Current()
extern "C" Vector3_t2243707580 Enumerator_get_Current_m857008049_gshared (Enumerator_t1147558386 * __this, const MethodInfo* method);
// System.Boolean System.Collections.Generic.List`1/Enumerator<UnityEngine.Vector3>::MoveNext()
extern "C" bool Enumerator_MoveNext_m2007266881_gshared (Enumerator_t1147558386 * __this, const MethodInfo* method);
// System.Void System.Collections.Generic.List`1/Enumerator<UnityEngine.Vector3>::Dispose()
extern "C" void Enumerator_Dispose_m3215924523_gshared (Enumerator_t1147558386 * __this, const MethodInfo* method);
// !!0 UnityEngine.Object::Instantiate<System.Object>(!!0,UnityEngine.Vector3,UnityEngine.Quaternion)
extern "C" Il2CppObject * Object_Instantiate_TisIl2CppObject_m3692334404_gshared (Il2CppObject * __this /* static, unused */, Il2CppObject * p0, Vector3_t2243707580 p1, Quaternion_t4030073918 p2, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityAction`2<System.Single,System.Single>::.ctor(System.Object,System.IntPtr)
extern "C" void UnityAction_2__ctor_m2891411084_gshared (UnityAction_2_t134459182 * __this, Il2CppObject * p0, IntPtr_t p1, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`2<System.Single,System.Single>::AddListener(UnityEngine.Events.UnityAction`2<!0,!1>)
extern "C" void UnityEvent_2_AddListener_m297354571_gshared (UnityEvent_2_t2016657100 * __this, UnityAction_2_t134459182 * p0, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`2<System.Single,System.Single>::RemoveListener(UnityEngine.Events.UnityAction`2<!0,!1>)
extern "C" void UnityEvent_2_RemoveListener_m491466926_gshared (UnityEvent_2_t2016657100 * __this, UnityAction_2_t134459182 * p0, const MethodInfo* method);
// System.Boolean UnityEngine.UI.BoxSlider::SetClass<System.Object>(T&,T)
extern "C" bool BoxSlider_SetClass_TisIl2CppObject_m1811500378_gshared (Il2CppObject * __this /* static, unused */, Il2CppObject ** ___currentValue0, Il2CppObject * ___newValue1, const MethodInfo* method);
// System.Boolean UnityEngine.UI.BoxSlider::SetStruct<System.Single>(T&,T)
extern "C" bool BoxSlider_SetStruct_TisSingle_t2076509932_m2710312218_gshared (Il2CppObject * __this /* static, unused */, float* ___currentValue0, float ___newValue1, const MethodInfo* method);
// System.Boolean UnityEngine.UI.BoxSlider::SetStruct<System.Boolean>(T&,T)
extern "C" bool BoxSlider_SetStruct_TisBoolean_t3825574718_m1967921404_gshared (Il2CppObject * __this /* static, unused */, bool* ___currentValue0, bool ___newValue1, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`2<System.Single,System.Single>::Invoke(!0,!1)
extern "C" void UnityEvent_2_Invoke_m4237217379_gshared (UnityEvent_2_t2016657100 * __this, float p0, float p1, const MethodInfo* method);
// System.Void UnityEngine.Events.UnityEvent`2<System.Single,System.Single>::.ctor()
extern "C" void UnityEvent_2__ctor_m731674732_gshared (UnityEvent_2_t2016657100 * __this, const MethodInfo* method);
// System.Void UnityEngine.MonoBehaviour::.ctor()
extern "C" void MonoBehaviour__ctor_m2464341955 (MonoBehaviour_t1158329972 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.Component::GetComponent<UnityEngine.AI.NavMeshAgent>()
#define Component_GetComponent_TisNavMeshAgent_t2761625415_m3828941945(__this, method) (( NavMeshAgent_t2761625415 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// !!0 UnityEngine.Component::GetComponent<UnityEngine.Animator>()
#define Component_GetComponent_TisAnimator_t69676727_m475627522(__this, method) (( Animator_t69676727 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// System.Boolean UnityEngine.Input::GetMouseButtonDown(System.Int32)
extern "C" bool Input_GetMouseButtonDown_m47917805 (Il2CppObject * __this /* static, unused */, int32_t p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Camera UnityEngine.Camera::get_main()
extern "C" Camera_t189460977 * Camera_get_main_m475173995 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Input::get_mousePosition()
extern "C" Vector3_t2243707580 Input_get_mousePosition_m146923508 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Ray UnityEngine.Camera::ScreenPointToRay(UnityEngine.Vector3)
extern "C" Ray_t2469606224 Camera_ScreenPointToRay_m614889538 (Camera_t189460977 * __this, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Ray::get_origin()
extern "C" Vector3_t2243707580 Ray_get_origin_m3339262500 (Ray_t2469606224 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Ray::get_direction()
extern "C" Vector3_t2243707580 Ray_get_direction_m4059191533 (Ray_t2469606224 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Physics::Raycast(UnityEngine.Vector3,UnityEngine.Vector3,UnityEngine.RaycastHit&)
extern "C" bool Physics_Raycast_m4027183840 (Il2CppObject * __this /* static, unused */, Vector3_t2243707580 p0, Vector3_t2243707580 p1, RaycastHit_t87180320 * p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Collider UnityEngine.RaycastHit::get_collider()
extern "C" Collider_t3497673348 * RaycastHit_get_collider_m301198172 (RaycastHit_t87180320 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Component::CompareTag(System.String)
extern "C" bool Component_CompareTag_m3443292365 (Component_t3819376471 * __this, String_t* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Debug::Log(System.Object)
extern "C" void Debug_Log_m920475918 (Il2CppObject * __this /* static, unused */, Il2CppObject * p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.RaycastHit::get_point()
extern "C" Vector3_t2243707580 RaycastHit_get_point_m326143462 (RaycastHit_t87180320 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.AI.NavMeshAgent::SetDestination(UnityEngine.Vector3)
extern "C" bool NavMeshAgent_SetDestination_m1354616139 (NavMeshAgent_t2761625415 * __this, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.AI.NavMeshAgent::get_remainingDistance()
extern "C" float NavMeshAgent_get_remainingDistance_m2699477664 (NavMeshAgent_t2761625415 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Animator::SetTrigger(System.String)
extern "C" void Animator_SetTrigger_m3418492570 (Animator_t69676727 * __this, String_t* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.SceneManagement.SceneManager::LoadScene(System.String,UnityEngine.SceneManagement.LoadSceneMode)
extern "C" void SceneManager_LoadScene_m1386820036 (Il2CppObject * __this /* static, unused */, String_t* p0, int32_t p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityEvent`1<UnityEngine.Color>::.ctor()
#define UnityEvent_1__ctor_m117795578(__this, method) (( void (*) (UnityEvent_1_t2058742090 *, const MethodInfo*))UnityEvent_1__ctor_m117795578_gshared)(__this, method)
// !!0 UnityEngine.Component::GetComponent<UnityEngine.UI.Image>()
#define Component_GetComponent_TisImage_t2042527209_m2189462422(__this, method) (( Image_t2042527209 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// System.Void UnityEngine.Events.UnityAction`1<UnityEngine.Color>::.ctor(System.Object,System.IntPtr)
#define UnityAction_1__ctor_m3329809356(__this, p0, p1, method) (( void (*) (UnityAction_1_t3386977826 *, Il2CppObject *, IntPtr_t, const MethodInfo*))UnityAction_1__ctor_m3329809356_gshared)(__this, p0, p1, method)
// System.Void UnityEngine.Events.UnityEvent`1<UnityEngine.Color>::AddListener(UnityEngine.Events.UnityAction`1<!0>)
#define UnityEvent_1_AddListener_m903508446(__this, p0, method) (( void (*) (UnityEvent_1_t2058742090 *, UnityAction_1_t3386977826 *, const MethodInfo*))UnityEvent_1_AddListener_m903508446_gshared)(__this, p0, method)
// System.Void UnityEngine.Events.UnityEvent`1<UnityEngine.Color>::RemoveListener(UnityEngine.Events.UnityAction`1<!0>)
#define UnityEvent_1_RemoveListener_m1138414664(__this, p0, method) (( void (*) (UnityEvent_1_t2058742090 *, UnityAction_1_t3386977826 *, const MethodInfo*))UnityEvent_1_RemoveListener_m1138414664_gshared)(__this, p0, method)
// !!0 UnityEngine.Component::GetComponent<UnityEngine.UI.Text>()
#define Component_GetComponent_TisText_t356221433_m1342661039(__this, method) (( Text_t356221433 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// System.Boolean UnityEngine.Application::get_isPlaying()
extern "C" bool Application_get_isPlaying_m4091950718 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Object::op_Inequality(UnityEngine.Object,UnityEngine.Object)
extern "C" bool Object_op_Inequality_m2402264703 (Il2CppObject * __this /* static, unused */, Object_t1021602117 * p0, Object_t1021602117 * p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityAction`3<System.Single,System.Single,System.Single>::.ctor(System.Object,System.IntPtr)
#define UnityAction_3__ctor_m3626891334(__this, p0, p1, method) (( void (*) (UnityAction_3_t235051313 *, Il2CppObject *, IntPtr_t, const MethodInfo*))UnityAction_3__ctor_m3626891334_gshared)(__this, p0, p1, method)
// System.Void UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>::AddListener(UnityEngine.Events.UnityAction`3<!0,!1,!2>)
#define UnityEvent_3_AddListener_m3608966849(__this, p0, method) (( void (*) (UnityEvent_3_t4197061729 *, UnityAction_3_t235051313 *, const MethodInfo*))UnityEvent_3_AddListener_m3608966849_gshared)(__this, p0, method)
// System.Void UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>::RemoveListener(UnityEngine.Events.UnityAction`3<!0,!1,!2>)
#define UnityEvent_3_RemoveListener_m2407167912(__this, p0, method) (( void (*) (UnityEvent_3_t4197061729 *, UnityAction_3_t235051313 *, const MethodInfo*))UnityEvent_3_RemoveListener_m2407167912_gshared)(__this, p0, method)
// System.Void ColorLabel::UpdateValue()
extern "C" void ColorLabel_UpdateValue_m3108932048 (ColorLabel_t1884607337 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Object::op_Equality(UnityEngine.Object,UnityEngine.Object)
extern "C" bool Object_op_Equality_m3764089466 (Il2CppObject * __this /* static, unused */, Object_t1021602117 * p0, Object_t1021602117 * p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.String::Concat(System.String,System.String)
extern "C" String_t* String_Concat_m2596409543 (Il2CppObject * __this /* static, unused */, String_t* p0, String_t* p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single ColorPicker::GetValue(ColorValues)
extern "C" float ColorPicker_GetValue_m1991475278 (ColorPicker_t3035206225 * __this, int32_t ___type0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String ColorLabel::ConvertToDisplayString(System.Single)
extern "C" String_t* ColorLabel_ConvertToDisplayString_m1654160419 (ColorLabel_t1884607337 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.String::Concat(System.Object,System.Object)
extern "C" String_t* String_Concat_m56707527 (Il2CppObject * __this /* static, unused */, Il2CppObject * p0, Il2CppObject * p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.Single::ToString(System.String)
extern "C" String_t* Single_ToString_m2359963436 (float* __this, String_t* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Int32 UnityEngine.Mathf::FloorToInt(System.Single)
extern "C" int32_t Mathf_FloorToInt_m4005035722 (Il2CppObject * __this /* static, unused */, float p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.Int32::ToString()
extern "C" String_t* Int32_ToString_m2960866144 (int32_t* __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorChangedEvent::.ctor()
extern "C" void ColorChangedEvent__ctor_m3710136698 (ColorChangedEvent_t2990895397 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void HSVChangedEvent::.ctor()
extern "C" void HSVChangedEvent__ctor_m3043072144 (HSVChangedEvent_t1170297569 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Color::.ctor(System.Single,System.Single,System.Single,System.Single)
extern "C" void Color__ctor_m1909920690 (Color_t2020392075 * __this, float p0, float p1, float p2, float p3, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Color ColorPicker::get_CurrentColor()
extern "C" Color_t2020392075 ColorPicker_get_CurrentColor_m3166096170 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Color::op_Equality(UnityEngine.Color,UnityEngine.Color)
extern "C" bool Color_op_Equality_m3156451394 (Il2CppObject * __this /* static, unused */, Color_t2020392075 p0, Color_t2020392075 p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::RGBChanged()
extern "C" void ColorPicker_RGBChanged_m2442023581 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::SendChangedEvent()
extern "C" void ColorPicker_SendChangedEvent_m2880248376 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::HSVChanged()
extern "C" void ColorPicker_HSVChanged_m3054464207 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// HsvColor HSVUtil::ConvertRgbToHsv(UnityEngine.Color)
extern "C" HsvColor_t1057062332 HSVUtil_ConvertRgbToHsv_m4088715697 (Il2CppObject * __this /* static, unused */, Color_t2020392075 ___color0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single HsvColor::get_normalizedH()
extern "C" float HsvColor_get_normalizedH_m3607787917 (HsvColor_t1057062332 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single HsvColor::get_normalizedS()
extern "C" float HsvColor_get_normalizedS_m3607786980 (HsvColor_t1057062332 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single HsvColor::get_normalizedV()
extern "C" float HsvColor_get_normalizedV_m3607786943 (HsvColor_t1057062332 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Color HSVUtil::ConvertHsvToRgb(System.Double,System.Double,System.Double,System.Single)
extern "C" Color_t2020392075 HSVUtil_ConvertHsvToRgb_m2339284600 (Il2CppObject * __this /* static, unused */, double ___h0, double ___s1, double ___v2, float ___alpha3, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityEvent`1<UnityEngine.Color>::Invoke(!0)
#define UnityEvent_1_Invoke_m2213115825(__this, p0, method) (( void (*) (UnityEvent_1_t2058742090 *, Color_t2020392075 , const MethodInfo*))UnityEvent_1_Invoke_m2213115825_gshared)(__this, p0, method)
// System.Void UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>::Invoke(!0,!1,!2)
#define UnityEvent_3_Invoke_m2734200716(__this, p0, p1, p2, method) (( void (*) (UnityEvent_3_t4197061729 *, float, float, float, const MethodInfo*))UnityEvent_3_Invoke_m2734200716_gshared)(__this, p0, p1, p2, method)
// System.Void ColorPicker::set_R(System.Single)
extern "C" void ColorPicker_set_R_m350597694 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::set_G(System.Single)
extern "C" void ColorPicker_set_G_m2188343591 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::set_B(System.Single)
extern "C" void ColorPicker_set_B_m26090126 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::set_A(System.Single)
extern "C" void ColorPicker_set_A_m1839123465 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::set_H(System.Single)
extern "C" void ColorPicker_set_H_m2725867100 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::set_S(System.Single)
extern "C" void ColorPicker_set_S_m985865155 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::set_V(System.Single)
extern "C" void ColorPicker_set_V_m1877583698 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single ColorPicker::get_R()
extern "C" float ColorPicker_get_R_m3995379697 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single ColorPicker::get_G()
extern "C" float ColorPicker_get_G_m755548720 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single ColorPicker::get_B()
extern "C" float ColorPicker_get_B_m1736779681 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single ColorPicker::get_A()
extern "C" float ColorPicker_get_A_m473223718 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single ColorPicker::get_H()
extern "C" float ColorPicker_get_H_m3860865411 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single ColorPicker::get_S()
extern "C" float ColorPicker_get_S_m2449498732 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single ColorPicker::get_V()
extern "C" float ColorPicker_get_V_m265062405 (ColorPicker_t3035206225 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void System.NotImplementedException::.ctor(System.String)
extern "C" void NotImplementedException__ctor_m1795163961 (NotImplementedException_t2785117854 * __this, String_t* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Material UnityEngine.Renderer::get_material()
extern "C" Material_t193706927 * Renderer_get_material_m2553789785 (Renderer_t257310565 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Material::set_color(UnityEngine.Color)
extern "C" void Material_set_color_m577844242 (Material_t193706927 * __this, Color_t2020392075 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.GameObject::get_activeSelf()
extern "C" bool GameObject_get_activeSelf_m313590879 (GameObject_t1756533147 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.GameObject::SetActive(System.Boolean)
extern "C" void GameObject_SetActive_m2887581199 (GameObject_t1756533147 * __this, bool p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.GameObject::GetComponent<UnityEngine.UI.Image>()
#define GameObject_GetComponent_TisImage_t2042527209_m4162535761(__this, method) (( Image_t2042527209 * (*) (GameObject_t1756533147 *, const MethodInfo*))GameObject_GetComponent_TisIl2CppObject_m2812611596_gshared)(__this, method)
// System.Void ColorPicker::set_CurrentColor(UnityEngine.Color)
extern "C" void ColorPicker_set_CurrentColor_m2125228471 (ColorPicker_t3035206225 * __this, Color_t2020392075 ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.Component::GetComponent<UnityEngine.UI.Slider>()
#define Component_GetComponent_TisSlider_t297367283_m1462559763(__this, method) (( Slider_t297367283 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// UnityEngine.UI.Slider/SliderEvent UnityEngine.UI.Slider::get_onValueChanged()
extern "C" SliderEvent_t2111116400 * Slider_get_onValueChanged_m4261003214 (Slider_t297367283 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityAction`1<System.Single>::.ctor(System.Object,System.IntPtr)
#define UnityAction_1__ctor_m2172708761(__this, p0, p1, method) (( void (*) (UnityAction_1_t3443095683 *, Il2CppObject *, IntPtr_t, const MethodInfo*))UnityAction_1__ctor_m2172708761_gshared)(__this, p0, p1, method)
// System.Void UnityEngine.Events.UnityEvent`1<System.Single>::AddListener(UnityEngine.Events.UnityAction`1<!0>)
#define UnityEvent_1_AddListener_m2377847221(__this, p0, method) (( void (*) (UnityEvent_1_t2114859947 *, UnityAction_1_t3443095683 *, const MethodInfo*))UnityEvent_1_AddListener_m2377847221_gshared)(__this, p0, method)
// System.Void UnityEngine.Events.UnityEvent`1<System.Single>::RemoveListener(UnityEngine.Events.UnityAction`1<!0>)
#define UnityEvent_1_RemoveListener_m2564825698(__this, p0, method) (( void (*) (UnityEvent_1_t2114859947 *, UnityAction_1_t3443095683 *, const MethodInfo*))UnityEvent_1_RemoveListener_m2564825698_gshared)(__this, p0, method)
// System.Void UnityEngine.UI.Slider::set_normalizedValue(System.Single)
extern "C" void Slider_set_normalizedValue_m3093868078 (Slider_t297367283 * __this, float p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.UI.Slider::get_normalizedValue()
extern "C" float Slider_get_normalizedValue_m4164062921 (Slider_t297367283 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ColorPicker::AssignColor(ColorValues,System.Single)
extern "C" void ColorPicker_AssignColor_m579716850 (ColorPicker_t3035206225 * __this, int32_t ___type0, float ___value1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Transform UnityEngine.Component::get_transform()
extern "C" Transform_t3275118058 * Component_get_transform_m2697483695 (Component_t3819376471 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.Component::GetComponent<UnityEngine.UI.RawImage>()
#define Component_GetComponent_TisRawImage_t2749640213_m1817787565(__this, method) (( RawImage_t2749640213 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// System.Void ColorSliderImage::RegenerateTexture()
extern "C" void ColorSliderImage_RegenerateTexture_m1461909699 (ColorSliderImage_t376502149 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Texture UnityEngine.UI.RawImage::get_texture()
extern "C" Texture_t2243626319 * RawImage_get_texture_m2258734143 (RawImage_t2749640213 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Object::DestroyImmediate(UnityEngine.Object)
extern "C" void Object_DestroyImmediate_m95027445 (Il2CppObject * __this /* static, unused */, Object_t1021602117 * p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Color UnityEngine.Color::get_black()
extern "C" Color_t2020392075 Color_get_black_m2650940523 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Color32 UnityEngine.Color32::op_Implicit(UnityEngine.Color)
extern "C" Color32_t874517518 Color32_op_Implicit_m624191464 (Il2CppObject * __this /* static, unused */, Color_t2020392075 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Texture2D::.ctor(System.Int32,System.Int32)
extern "C" void Texture2D__ctor_m3598323350 (Texture2D_t3542995729 * __this, int32_t p0, int32_t p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Object::set_hideFlags(UnityEngine.HideFlags)
extern "C" void Object_set_hideFlags_m2204253440 (Object_t1021602117 * __this, int32_t p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Color32::.ctor(System.Byte,System.Byte,System.Byte,System.Byte)
extern "C" void Color32__ctor_m1932627809 (Color32_t874517518 * __this, uint8_t p0, uint8_t p1, uint8_t p2, uint8_t p3, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Texture2D::SetPixels32(UnityEngine.Color32[])
extern "C" void Texture2D_SetPixels32_m2480505405 (Texture2D_t3542995729 * __this, Color32U5BU5D_t30278651* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Texture2D::Apply()
extern "C" void Texture2D_Apply_m3543341930 (Texture2D_t3542995729 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.RawImage::set_texture(UnityEngine.Texture)
extern "C" void RawImage_set_texture_m2400157626 (RawImage_t2749640213 * __this, Texture_t2243626319 * p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Rect::.ctor(System.Single,System.Single,System.Single,System.Single)
extern "C" void Rect__ctor_m1220545469 (Rect_t3681755626 * __this, float p0, float p1, float p2, float p3, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.RawImage::set_uvRect(UnityEngine.Rect)
extern "C" void RawImage_set_uvRect_m3807597783 (RawImage_t2749640213 * __this, Rect_t3681755626 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.GameObject UnityEngine.Component::get_gameObject()
extern "C" GameObject_t1756533147 * Component_get_gameObject_m3105766835 (Component_t3819376471 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Object::Destroy(UnityEngine.Object)
extern "C" void Object_Destroy_m4145850038 (Il2CppObject * __this /* static, unused */, Object_t1021602117 * p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.Time::get_deltaTime()
extern "C" float Time_get_deltaTime_m2233168104 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Transform UnityEngine.Collision::get_transform()
extern "C" Transform_t3275118058 * Collision_get_transform_m4132935520 (Collision_t2876846408 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Transform UnityEngine.Transform::get_parent()
extern "C" Transform_t3275118058 * Transform_get_parent_m147407266 (Transform_t3275118058 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Object::Destroy(UnityEngine.Object,System.Single)
extern "C" void Object_Destroy_m4279412553 (Il2CppObject * __this /* static, unused */, Object_t1021602117 * p0, float p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.Component::GetComponent<UnityEngine.UI.InputField>()
#define Component_GetComponent_TisInputField_t1631627530_m1177654614(__this, method) (( InputField_t1631627530 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// UnityEngine.UI.InputField/SubmitEvent UnityEngine.UI.InputField::get_onEndEdit()
extern "C" SubmitEvent_t907918422 * InputField_get_onEndEdit_m1618380883 (InputField_t1631627530 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityAction`1<System.String>::.ctor(System.Object,System.IntPtr)
#define UnityAction_1__ctor_m2212746417(__this, p0, p1, method) (( void (*) (UnityAction_1_t3395805984 *, Il2CppObject *, IntPtr_t, const MethodInfo*))UnityAction_1__ctor_m2836997866_gshared)(__this, p0, p1, method)
// System.Void UnityEngine.Events.UnityEvent`1<System.String>::AddListener(UnityEngine.Events.UnityAction`1<!0>)
#define UnityEvent_1_AddListener_m2046140989(__this, p0, method) (( void (*) (UnityEvent_1_t2067570248 *, UnityAction_1_t3395805984 *, const MethodInfo*))UnityEvent_1_AddListener_m1977283804_gshared)(__this, p0, method)
// UnityEngine.UI.InputField/OnChangeEvent UnityEngine.UI.InputField::get_onValueChanged()
extern "C" OnChangeEvent_t2863344003 * InputField_get_onValueChanged_m2097858642 (InputField_t1631627530 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityEvent`1<System.String>::RemoveListener(UnityEngine.Events.UnityAction`1<!0>)
#define UnityEvent_1_RemoveListener_m2236604102(__this, p0, method) (( void (*) (UnityEvent_1_t2067570248 *, UnityAction_1_t3395805984 *, const MethodInfo*))UnityEvent_1_RemoveListener_m4278263803_gshared)(__this, p0, method)
// System.String HexColorField::ColorToHex(UnityEngine.Color32)
extern "C" String_t* HexColorField_ColorToHex_m410116926 (HexColorField_t4192118964 * __this, Color32_t874517518 ___color0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.InputField::set_text(System.String)
extern "C" void InputField_set_text_m114077119 (InputField_t1631627530 * __this, String_t* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean HexColorField::HexToColor(System.String,UnityEngine.Color32&)
extern "C" bool HexColorField_HexToColor_m3970770477 (Il2CppObject * __this /* static, unused */, String_t* ___hex0, Color32_t874517518 * ___color1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Color UnityEngine.Color32::op_Implicit(UnityEngine.Color32)
extern "C" Color_t2020392075 Color32_op_Implicit_m889975790 (Il2CppObject * __this /* static, unused */, Color32_t874517518 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.String::Format(System.String,System.Object[])
extern "C" String_t* String_Format_m1263743648 (Il2CppObject * __this /* static, unused */, String_t* p0, ObjectU5BU5D_t3614634134* p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.String::Format(System.String,System.Object,System.Object,System.Object)
extern "C" String_t* String_Format_m4262916296 (Il2CppObject * __this /* static, unused */, String_t* p0, Il2CppObject * p1, Il2CppObject * p2, Il2CppObject * p3, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean System.Text.RegularExpressions.Regex::IsMatch(System.String,System.String)
extern "C" bool Regex_IsMatch_m2218618503 (Il2CppObject * __this /* static, unused */, String_t* p0, String_t* p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean System.String::StartsWith(System.String)
extern "C" bool String_StartsWith_m1841920685 (String_t* __this, String_t* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Int32 System.String::get_Length()
extern "C" int32_t String_get_Length_m1606060069 (String_t* __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.String::Substring(System.Int32,System.Int32)
extern "C" String_t* String_Substring_m12482732 (String_t* __this, int32_t p0, int32_t p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Byte System.Byte::Parse(System.String,System.Globalization.NumberStyles)
extern "C" uint8_t Byte_Parse_m4137294155 (Il2CppObject * __this /* static, unused */, String_t* p0, int32_t p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Char System.String::get_Chars(System.Int32)
extern "C" Il2CppChar String_get_Chars_m4230566705 (String_t* __this, int32_t p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.String::Concat(System.Object,System.Object,System.Object)
extern "C" String_t* String_Concat_m2000667605 (Il2CppObject * __this /* static, unused */, Il2CppObject * p0, Il2CppObject * p1, Il2CppObject * p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityEvent`3<System.Single,System.Single,System.Single>::.ctor()
#define UnityEvent_3__ctor_m3100550874(__this, method) (( void (*) (UnityEvent_3_t4197061729 *, const MethodInfo*))UnityEvent_3__ctor_m3100550874_gshared)(__this, method)
// System.Void HsvColor::.ctor(System.Double,System.Double,System.Double)
extern "C" void HsvColor__ctor_m2096855601 (HsvColor_t1057062332 * __this, double ___h0, double ___s1, double ___v2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void HsvColor::set_normalizedH(System.Single)
extern "C" void HsvColor_set_normalizedH_m2139074108 (HsvColor_t1057062332 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void HsvColor::set_normalizedS(System.Single)
extern "C" void HsvColor_set_normalizedS_m413849441 (HsvColor_t1057062332 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void HsvColor::set_normalizedV(System.Single)
extern "C" void HsvColor_set_normalizedV_m460463238 (HsvColor_t1057062332 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.Double::ToString(System.String)
extern "C" String_t* Double_ToString_m2210043919 (double* __this, String_t* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String System.String::Concat(System.String[])
extern "C" String_t* String_Concat_m626692867 (Il2CppObject * __this /* static, unused */, StringU5BU5D_t1642385972* p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String HsvColor::ToString()
extern "C" String_t* HsvColor_ToString_m1590809902 (HsvColor_t1057062332 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// HsvColor HSVUtil::ConvertRgbToHsv(System.Double,System.Double,System.Double)
extern "C" HsvColor_t1057062332 HSVUtil_ConvertRgbToHsv_m2238362913 (Il2CppObject * __this /* static, unused */, double ___r0, double ___b1, double ___g2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Double System.Math::Min(System.Double,System.Double)
extern "C" double Math_Min_m2551484304 (Il2CppObject * __this /* static, unused */, double p0, double p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Double System.Math::Max(System.Double,System.Double)
extern "C" double Math_Max_m3248989870 (Il2CppObject * __this /* static, unused */, double p0, double p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Touch UnityEngine.Input::GetTouch(System.Int32)
extern "C" Touch_t407273883 Input_GetTouch_m1463942798 (Il2CppObject * __this /* static, unused */, int32_t p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.Touch::get_position()
extern "C" Vector2_t2243707579 Touch_get_position_m2079703643 (Touch_t407273883 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Vector2::op_Implicit(UnityEngine.Vector2)
extern "C" Vector3_t2243707580 Vector2_op_Implicit_m176791411 (Il2CppObject * __this /* static, unused */, Vector2_t2243707579 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Camera::ScreenToWorldPoint(UnityEngine.Vector3)
extern "C" Vector3_t2243707580 Camera_ScreenToWorldPoint_m929392728 (Camera_t189460977 * __this, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Vector3::.ctor(System.Single,System.Single,System.Single)
extern "C" void Vector3__ctor_m2638739322 (Vector3_t2243707580 * __this, float p0, float p1, float p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.Vector2::op_Implicit(UnityEngine.Vector3)
extern "C" Vector2_t2243707579 Vector2_op_Implicit_m1064335535 (Il2CppObject * __this /* static, unused */, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Transform::get_forward()
extern "C" Vector3_t2243707580 Transform_get_forward_m1833488937 (Transform_t3275118058 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.RaycastHit2D UnityEngine.Physics2D::Raycast(UnityEngine.Vector2,UnityEngine.Vector2)
extern "C" RaycastHit2D_t4063908774 Physics2D_Raycast_m2560154475 (Il2CppObject * __this /* static, unused */, Vector2_t2243707579 p0, Vector2_t2243707579 p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Collider2D UnityEngine.RaycastHit2D::get_collider()
extern "C" Collider2D_t646061738 * RaycastHit2D_get_collider_m2568504212 (RaycastHit2D_t4063908774 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Transform UnityEngine.RaycastHit2D::get_transform()
extern "C" Transform_t3275118058 * RaycastHit2D_get_transform_m747355930 (RaycastHit2D_t4063908774 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Transform UnityEngine.GameObject::get_transform()
extern "C" Transform_t3275118058 * GameObject_get_transform_m909382139 (GameObject_t1756533147 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Transform::get_localScale()
extern "C" Vector3_t2243707580 Transform_get_localScale_m3074381503 (Transform_t3275118058 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Vector3::op_Addition(UnityEngine.Vector3,UnityEngine.Vector3)
extern "C" Vector3_t2243707580 Vector3_op_Addition_m3146764857 (Il2CppObject * __this /* static, unused */, Vector3_t2243707580 p0, Vector3_t2243707580 p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Transform::set_localScale(UnityEngine.Vector3)
extern "C" void Transform_set_localScale_m2325460848 (Transform_t3275118058 * __this, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.GameObject::GetComponent<UnityEngine.AudioSource>()
#define GameObject_GetComponent_TisAudioSource_t1135106623_m1072053017(__this, method) (( AudioSource_t1135106623 * (*) (GameObject_t1756533147 *, const MethodInfo*))GameObject_GetComponent_TisIl2CppObject_m2812611596_gshared)(__this, method)
// System.Void UnityEngine.AudioSource::Play()
extern "C" void AudioSource_Play_m353744792 (AudioSource_t1135106623 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Vector3::get_zero()
extern "C" Vector3_t2243707580 Vector3_get_zero_m1527993324 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Color UnityEngine.Color::get_white()
extern "C" Color_t2020392075 Color_get_white_m3987539815 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.XR.iOS.UnityARSessionNativeInterface/ARFrameUpdate::.ctor(System.Object,System.IntPtr)
extern "C" void ARFrameUpdate__ctor_m1399217559 (ARFrameUpdate_t496507918 * __this, Il2CppObject * p0, IntPtr_t p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.XR.iOS.UnityARSessionNativeInterface::add_ARFrameUpdatedEvent(UnityEngine.XR.iOS.UnityARSessionNativeInterface/ARFrameUpdate)
extern "C" void UnityARSessionNativeInterface_add_ARFrameUpdatedEvent_m2850773202 (Il2CppObject * __this /* static, unused */, ARFrameUpdate_t496507918 * p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.Object::Instantiate<UnityEngine.ParticleSystem>(!!0)
#define Object_Instantiate_TisParticleSystem_t3394631041_m4293040502(__this /* static, unused */, p0, method) (( ParticleSystem_t3394631041 * (*) (Il2CppObject * /* static, unused */, ParticleSystem_t3394631041 *, const MethodInfo*))Object_Instantiate_TisIl2CppObject_m447919519_gshared)(__this /* static, unused */, p0, method)
// System.Void System.Collections.Generic.List`1<UnityEngine.Vector3>::.ctor()
#define List_1__ctor_m347461442(__this, method) (( void (*) (List_1_t1612828712 *, const MethodInfo*))List_1__ctor_m347461442_gshared)(__this, method)
// System.Void System.Collections.Generic.List`1<UnityEngine.ParticleSystem>::.ctor()
#define List_1__ctor_m3416249727(__this, method) (( void (*) (List_1_t2763752173 *, const MethodInfo*))List_1__ctor_m310736118_gshared)(__this, method)
// System.Void UnityEngine.Matrix4x4::SetColumn(System.Int32,UnityEngine.Vector4)
extern "C" void Matrix4x4_SetColumn_m3120649749 (Matrix4x4_t2933234003 * __this, int32_t p0, Vector4_t2243707581 p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.XR.iOS.UnityARMatrixOps::GetPosition(UnityEngine.Matrix4x4)
extern "C" Vector3_t2243707580 UnityARMatrixOps_GetPosition_m1153858439 (Il2CppObject * __this /* static, unused */, Matrix4x4_t2933234003 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Vector3::op_Multiply(UnityEngine.Vector3,System.Single)
extern "C" Vector3_t2243707580 Vector3_op_Multiply_m1351554733 (Il2CppObject * __this /* static, unused */, Vector3_t2243707580 p0, float p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.Vector3::Distance(UnityEngine.Vector3,UnityEngine.Vector3)
extern "C" float Vector3_Distance_m1859670022 (Il2CppObject * __this /* static, unused */, Vector3_t2243707580 p0, Vector3_t2243707580 p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void System.Collections.Generic.List`1<UnityEngine.Vector3>::Add(!0)
#define List_1_Add_m2338641291(__this, p0, method) (( void (*) (List_1_t1612828712 *, Vector3_t2243707580 , const MethodInfo*))List_1_Add_m2338641291_gshared)(__this, p0, method)
// System.Int32 UnityEngine.Screen::get_width()
extern "C" int32_t Screen_get_width_m41137238 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.GUI::Button(UnityEngine.Rect,System.String)
extern "C" bool GUI_Button_m3054448581 (Il2CppObject * __this /* static, unused */, Rect_t3681755626 p0, String_t* p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void ParticlePainter::RestartPainting()
extern "C" void ParticlePainter_RestartPainting_m3645394903 (ParticlePainter_t1073897267 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void System.Collections.Generic.List`1<UnityEngine.ParticleSystem>::Add(!0)
#define List_1_Add_m4197260563(__this, p0, method) (( void (*) (List_1_t2763752173 *, ParticleSystem_t3394631041 *, const MethodInfo*))List_1_Add_m4157722533_gshared)(__this, p0, method)
// System.Int32 System.Collections.Generic.List`1<UnityEngine.Vector3>::get_Count()
#define List_1_get_Count_m4027941115(__this, method) (( int32_t (*) (List_1_t1612828712 *, const MethodInfo*))List_1_get_Count_m4027941115_gshared)(__this, method)
// System.Collections.Generic.List`1/Enumerator<!0> System.Collections.Generic.List`1<UnityEngine.Vector3>::GetEnumerator()
#define List_1_GetEnumerator_m940839541(__this, method) (( Enumerator_t1147558386 (*) (List_1_t1612828712 *, const MethodInfo*))List_1_GetEnumerator_m940839541_gshared)(__this, method)
// !0 System.Collections.Generic.List`1/Enumerator<UnityEngine.Vector3>::get_Current()
#define Enumerator_get_Current_m857008049(__this, method) (( Vector3_t2243707580 (*) (Enumerator_t1147558386 *, const MethodInfo*))Enumerator_get_Current_m857008049_gshared)(__this, method)
// System.Void UnityEngine.ParticleSystem/Particle::set_position(UnityEngine.Vector3)
extern "C" void Particle_set_position_m3680513126 (Particle_t250075699 * __this, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.ParticleSystem/Particle::set_startColor(UnityEngine.Color32)
extern "C" void Particle_set_startColor_m3936512348 (Particle_t250075699 * __this, Color32_t874517518 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.ParticleSystem/Particle::set_startSize(System.Single)
extern "C" void Particle_set_startSize_m2457836830 (Particle_t250075699 * __this, float p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean System.Collections.Generic.List`1/Enumerator<UnityEngine.Vector3>::MoveNext()
#define Enumerator_MoveNext_m2007266881(__this, method) (( bool (*) (Enumerator_t1147558386 *, const MethodInfo*))Enumerator_MoveNext_m2007266881_gshared)(__this, method)
// System.Void System.Collections.Generic.List`1/Enumerator<UnityEngine.Vector3>::Dispose()
#define Enumerator_Dispose_m3215924523(__this, method) (( void (*) (Enumerator_t1147558386 *, const MethodInfo*))Enumerator_Dispose_m3215924523_gshared)(__this, method)
// System.Void UnityEngine.ParticleSystem::SetParticles(UnityEngine.ParticleSystem/Particle[],System.Int32)
extern "C" void ParticleSystem_SetParticles_m3035584975 (ParticleSystem_t3394631041 * __this, ParticleU5BU5D_t574222242* p0, int32_t p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.Vector3::op_Subtraction(UnityEngine.Vector3,UnityEngine.Vector3)
extern "C" Vector3_t2243707580 Vector3_op_Subtraction_m2407545601 (Il2CppObject * __this /* static, unused */, Vector3_t2243707580 p0, Vector3_t2243707580 p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.AudioSource::Stop()
extern "C" void AudioSource_Stop_m3452679614 (AudioSource_t1135106623 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Int32 UnityEngine.Input::get_touchCount()
extern "C" int32_t Input_get_touchCount_m2050827666 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.TouchPhase UnityEngine.Touch::get_phase()
extern "C" int32_t Touch_get_phase_m196706494 (Touch_t407273883 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Physics::Raycast(UnityEngine.Ray,UnityEngine.RaycastHit&)
extern "C" bool Physics_Raycast_m2736931691 (Il2CppObject * __this /* static, unused */, Ray_t2469606224 p0, RaycastHit_t87180320 * p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.GameObject::GetComponent<playMusic>()
#define GameObject_GetComponent_TisplayMusic_t1960384527_m1033848332(__this, method) (( playMusic_t1960384527 * (*) (GameObject_t1756533147 *, const MethodInfo*))GameObject_GetComponent_TisIl2CppObject_m2812611596_gshared)(__this, method)
// System.Void playMusic::StopPlayMusicFunc()
extern "C" void playMusic_StopPlayMusicFunc_m1382748181 (playMusic_t1960384527 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void playMusic::PlayMusicFunc()
extern "C" void playMusic_PlayMusicFunc_m2741615981 (playMusic_t1960384527 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void Shooting::changeToggle()
extern "C" void Shooting_changeToggle_m2373192642 (Shooting_t3467275689 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.GameObject::GetComponent<UnityEngine.UI.Toggle>()
#define GameObject_GetComponent_TisToggle_t3976754468_m4141321564(__this, method) (( Toggle_t3976754468 * (*) (GameObject_t1756533147 *, const MethodInfo*))GameObject_GetComponent_TisIl2CppObject_m2812611596_gshared)(__this, method)
// System.Boolean UnityEngine.UI.Toggle::get_isOn()
extern "C" bool Toggle_get_isOn_m366838229 (Toggle_t3976754468 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Ray UnityEngine.Camera::ViewportPointToRay(UnityEngine.Vector3)
extern "C" Ray_t2469606224 Camera_ViewportPointToRay_m1799506792 (Camera_t189460977 * __this, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Physics::Raycast(UnityEngine.Ray,UnityEngine.RaycastHit&,System.Single)
extern "C" bool Physics_Raycast_m2308457076 (Il2CppObject * __this /* static, unused */, Ray_t2469606224 p0, RaycastHit_t87180320 * p1, float p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.String UnityEngine.Object::get_name()
extern "C" String_t* Object_get_name_m2079638459 (Object_t1021602117 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector3 UnityEngine.RaycastHit::get_normal()
extern "C" Vector3_t2243707580 RaycastHit_get_normal_m817665579 (RaycastHit_t87180320 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Quaternion UnityEngine.Quaternion::Euler(UnityEngine.Vector3)
extern "C" Quaternion_t4030073918 Quaternion_Euler_m3586339259 (Il2CppObject * __this /* static, unused */, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.Object::Instantiate<UnityEngine.GameObject>(!!0,UnityEngine.Vector3,UnityEngine.Quaternion)
#define Object_Instantiate_TisGameObject_t1756533147_m3186302158(__this /* static, unused */, p0, p1, p2, method) (( GameObject_t1756533147 * (*) (Il2CppObject * /* static, unused */, GameObject_t1756533147 *, Vector3_t2243707580 , Quaternion_t4030073918 , const MethodInfo*))Object_Instantiate_TisIl2CppObject_m3692334404_gshared)(__this /* static, unused */, p0, p1, p2, method)
// UnityEngine.Vector3 UnityEngine.Camera::ViewportToWorldPoint(UnityEngine.Vector3)
extern "C" Vector3_t2243707580 Camera_ViewportToWorldPoint_m3841010930 (Camera_t189460977 * __this, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Quaternion UnityEngine.Quaternion::get_identity()
extern "C" Quaternion_t4030073918 Quaternion_get_identity_m1561886418 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.GameObject::GetComponent<UnityEngine.Rigidbody>()
#define GameObject_GetComponent_TisRigidbody_t4233889191_m1060888193(__this, method) (( Rigidbody_t4233889191 * (*) (GameObject_t1756533147 *, const MethodInfo*))GameObject_GetComponent_TisIl2CppObject_m2812611596_gshared)(__this, method)
// System.Void UnityEngine.Rigidbody::AddForce(UnityEngine.Vector3)
extern "C" void Rigidbody_AddForce_m2836187433 (Rigidbody_t4233889191 * __this, Vector3_t2243707580 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.Component::GetComponent<UnityEngine.UI.BoxSlider>()
#define Component_GetComponent_TisBoxSlider_t1871650694_m3168588160(__this, method) (( BoxSlider_t1871650694 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// System.Void SVBoxSlider::RegenerateSVTexture()
extern "C" void SVBoxSlider_RegenerateSVTexture_m4094171080 (SVBoxSlider_t1173082351 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.UI.BoxSlider/BoxSliderEvent UnityEngine.UI.BoxSlider::get_onValueChanged()
extern "C" BoxSliderEvent_t1774115848 * BoxSlider_get_onValueChanged_m1694276966 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityAction`2<System.Single,System.Single>::.ctor(System.Object,System.IntPtr)
#define UnityAction_2__ctor_m2891411084(__this, p0, p1, method) (( void (*) (UnityAction_2_t134459182 *, Il2CppObject *, IntPtr_t, const MethodInfo*))UnityAction_2__ctor_m2891411084_gshared)(__this, p0, p1, method)
// System.Void UnityEngine.Events.UnityEvent`2<System.Single,System.Single>::AddListener(UnityEngine.Events.UnityAction`2<!0,!1>)
#define UnityEvent_2_AddListener_m297354571(__this, p0, method) (( void (*) (UnityEvent_2_t2016657100 *, UnityAction_2_t134459182 *, const MethodInfo*))UnityEvent_2_AddListener_m297354571_gshared)(__this, p0, method)
// System.Void UnityEngine.Events.UnityEvent`2<System.Single,System.Single>::RemoveListener(UnityEngine.Events.UnityAction`2<!0,!1>)
#define UnityEvent_2_RemoveListener_m491466926(__this, p0, method) (( void (*) (UnityEvent_2_t2016657100 *, UnityAction_2_t134459182 *, const MethodInfo*))UnityEvent_2_RemoveListener_m491466926_gshared)(__this, p0, method)
// System.Single UnityEngine.UI.BoxSlider::get_normalizedValue()
extern "C" float BoxSlider_get_normalizedValue_m911068691 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::set_normalizedValue(System.Single)
extern "C" void BoxSlider_set_normalizedValue_m2010660092 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.UI.BoxSlider::get_normalizedValueY()
extern "C" float BoxSlider_get_normalizedValueY_m3976688554 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::set_normalizedValueY(System.Single)
extern "C" void BoxSlider_set_normalizedValueY_m851020601 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Texture2D::SetPixels32(System.Int32,System.Int32,System.Int32,System.Int32,UnityEngine.Color32[])
extern "C" void Texture2D_SetPixels32_m1440518781 (Texture2D_t3542995729 * __this, int32_t p0, int32_t p1, int32_t p2, int32_t p3, Color32U5BU5D_t30278651* p4, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Vector2::.ctor(System.Single,System.Single)
extern "C" void Vector2__ctor_m3067419446 (Vector2_t2243707579 * __this, float p0, float p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.Vector2::get_zero()
extern "C" Vector2_t2243707579 Vector2_get_zero_m3966848876 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Quaternion UnityEngine.Transform::get_localRotation()
extern "C" Quaternion_t4030073918 Transform_get_localRotation_m4001487205 (Transform_t3275118058 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Int32 UnityEngine.Screen::get_height()
extern "C" int32_t Screen_get_height_m1051800773 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.Mathf::Clamp(System.Single,System.Single,System.Single)
extern "C" float Mathf_Clamp_m2354025655 (Il2CppObject * __this /* static, unused */, float p0, float p1, float p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.Vector2::Lerp(UnityEngine.Vector2,UnityEngine.Vector2,System.Single)
extern "C" Vector2_t2243707579 Vector2_Lerp_m1511850087 (Il2CppObject * __this /* static, unused */, Vector2_t2243707579 p0, Vector2_t2243707579 p1, float p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Quaternion UnityEngine.Quaternion::Euler(System.Single,System.Single,System.Single)
extern "C" Quaternion_t4030073918 Quaternion_Euler_m2887458175 (Il2CppObject * __this /* static, unused */, float p0, float p1, float p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Quaternion UnityEngine.Quaternion::op_Multiply(UnityEngine.Quaternion,UnityEngine.Quaternion)
extern "C" Quaternion_t4030073918 Quaternion_op_Multiply_m2426727589 (Il2CppObject * __this /* static, unused */, Quaternion_t4030073918 p0, Quaternion_t4030073918 p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Transform::set_localRotation(UnityEngine.Quaternion)
extern "C" void Transform_set_localRotation_m2055111962 (Transform_t3275118058 * __this, Quaternion_t4030073918 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider/BoxSliderEvent::.ctor()
extern "C" void BoxSliderEvent__ctor_m304261805 (BoxSliderEvent_t1774115848 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.Selectable::.ctor()
extern "C" void Selectable__ctor_m1440593935 (Selectable_t1490392188 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.UI.BoxSlider::SetClass<UnityEngine.RectTransform>(T&,T)
#define BoxSlider_SetClass_TisRectTransform_t3349966182_m272479997(__this /* static, unused */, ___currentValue0, ___newValue1, method) (( bool (*) (Il2CppObject * /* static, unused */, RectTransform_t3349966182 **, RectTransform_t3349966182 *, const MethodInfo*))BoxSlider_SetClass_TisIl2CppObject_m1811500378_gshared)(__this /* static, unused */, ___currentValue0, ___newValue1, method)
// System.Void UnityEngine.UI.BoxSlider::UpdateCachedReferences()
extern "C" void BoxSlider_UpdateCachedReferences_m3248150675 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::UpdateVisuals()
extern "C" void BoxSlider_UpdateVisuals_m495585056 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.UI.BoxSlider::SetStruct<System.Single>(T&,T)
#define BoxSlider_SetStruct_TisSingle_t2076509932_m2710312218(__this /* static, unused */, ___currentValue0, ___newValue1, method) (( bool (*) (Il2CppObject * /* static, unused */, float*, float, const MethodInfo*))BoxSlider_SetStruct_TisSingle_t2076509932_m2710312218_gshared)(__this /* static, unused */, ___currentValue0, ___newValue1, method)
// System.Void UnityEngine.UI.BoxSlider::Set(System.Single)
extern "C" void BoxSlider_Set_m3989333985 (BoxSlider_t1871650694 * __this, float ___input0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::SetY(System.Single)
extern "C" void BoxSlider_SetY_m1241843396 (BoxSlider_t1871650694 * __this, float ___input0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.UI.BoxSlider::SetStruct<System.Boolean>(T&,T)
#define BoxSlider_SetStruct_TisBoolean_t3825574718_m1967921404(__this /* static, unused */, ___currentValue0, ___newValue1, method) (( bool (*) (Il2CppObject * /* static, unused */, bool*, bool, const MethodInfo*))BoxSlider_SetStruct_TisBoolean_t3825574718_m1967921404_gshared)(__this /* static, unused */, ___currentValue0, ___newValue1, method)
// System.Boolean UnityEngine.UI.BoxSlider::get_wholeNumbers()
extern "C" bool BoxSlider_get_wholeNumbers_m627638124 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.UI.BoxSlider::get_minValue()
extern "C" float BoxSlider_get_minValue_m3041624170 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.UI.BoxSlider::get_maxValue()
extern "C" float BoxSlider_get_maxValue_m1317285860 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Mathf::Approximately(System.Single,System.Single)
extern "C" bool Mathf_Approximately_m1064446634 (Il2CppObject * __this /* static, unused */, float p0, float p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.UI.BoxSlider::get_value()
extern "C" float BoxSlider_get_value_m2439160562 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.Mathf::InverseLerp(System.Single,System.Single,System.Single)
extern "C" float Mathf_InverseLerp_m55890283 (Il2CppObject * __this /* static, unused */, float p0, float p1, float p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.Mathf::Lerp(System.Single,System.Single,System.Single)
extern "C" float Mathf_Lerp_m1686556575 (Il2CppObject * __this /* static, unused */, float p0, float p1, float p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::set_value(System.Single)
extern "C" void BoxSlider_set_value_m3164710557 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.UI.BoxSlider::get_valueY()
extern "C" float BoxSlider_get_valueY_m2581533163 (BoxSlider_t1871650694 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::set_valueY(System.Single)
extern "C" void BoxSlider_set_valueY_m2217414554 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.Selectable::OnEnable()
extern "C" void Selectable_OnEnable_m3825327683 (Selectable_t1490392188 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::Set(System.Single,System.Boolean)
extern "C" void BoxSlider_Set_m1512577286 (BoxSlider_t1871650694 * __this, float ___input0, bool ___sendCallback1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::SetY(System.Single,System.Boolean)
extern "C" void BoxSlider_SetY_m956310887 (BoxSlider_t1871650694 * __this, float ___input0, bool ___sendCallback1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.DrivenRectTransformTracker::Clear()
extern "C" void DrivenRectTransformTracker_Clear_m864483440 (DrivenRectTransformTracker_t154385424 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.Selectable::OnDisable()
extern "C" void Selectable_OnDisable_m2660228016 (Selectable_t1490392188 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Object::op_Implicit(UnityEngine.Object)
extern "C" bool Object_op_Implicit_m2856731593 (Il2CppObject * __this /* static, unused */, Object_t1021602117 * p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// !!0 UnityEngine.Component::GetComponent<UnityEngine.RectTransform>()
#define Component_GetComponent_TisRectTransform_t3349966182_m1310250299(__this, method) (( RectTransform_t3349966182 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// System.Void UnityEngine.Events.UnityEvent`2<System.Single,System.Single>::Invoke(!0,!1)
#define UnityEvent_2_Invoke_m4237217379(__this, p0, p1, method) (( void (*) (UnityEvent_2_t2016657100 *, float, float, const MethodInfo*))UnityEvent_2_Invoke_m4237217379_gshared)(__this, p0, p1, method)
// System.Void UnityEngine.EventSystems.UIBehaviour::OnRectTransformDimensionsChange()
extern "C" void UIBehaviour_OnRectTransformDimensionsChange_m2743105076 (UIBehaviour_t3960014691 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.DrivenRectTransformTracker::Add(UnityEngine.Object,UnityEngine.RectTransform,UnityEngine.DrivenTransformProperties)
extern "C" void DrivenRectTransformTracker_Add_m310530075 (DrivenRectTransformTracker_t154385424 * __this, Object_t1021602117 * p0, RectTransform_t3349966182 * p1, int32_t p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.Vector2::get_one()
extern "C" Vector2_t2243707579 Vector2_get_one_m3174311904 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Vector2::set_Item(System.Int32,System.Single)
extern "C" void Vector2_set_Item_m3881967114 (Vector2_t2243707579 * __this, int32_t p0, float p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.RectTransform::set_anchorMin(UnityEngine.Vector2)
extern "C" void RectTransform_set_anchorMin_m4247668187 (RectTransform_t3349966182 * __this, Vector2_t2243707579 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.RectTransform::set_anchorMax(UnityEngine.Vector2)
extern "C" void RectTransform_set_anchorMax_m2955899993 (RectTransform_t3349966182 * __this, Vector2_t2243707579 p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Rect UnityEngine.RectTransform::get_rect()
extern "C" Rect_t3681755626 RectTransform_get_rect_m73954734 (RectTransform_t3349966182 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.Rect::get_size()
extern "C" Vector2_t2243707579 Rect_get_size_m3833121112 (Rect_t3681755626 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.Vector2::get_Item(System.Int32)
extern "C" float Vector2_get_Item_m2792130561 (Vector2_t2243707579 * __this, int32_t p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.EventSystems.PointerEventData::get_position()
extern "C" Vector2_t2243707579 PointerEventData_get_position_m2131765015 (PointerEventData_t1599784723 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.RectTransformUtility::ScreenPointToLocalPointInRectangle(UnityEngine.RectTransform,UnityEngine.Vector2,UnityEngine.Camera,UnityEngine.Vector2&)
extern "C" bool RectTransformUtility_ScreenPointToLocalPointInRectangle_m2398565080 (Il2CppObject * __this /* static, unused */, RectTransform_t3349966182 * p0, Vector2_t2243707579 p1, Camera_t189460977 * p2, Vector2_t2243707579 * p3, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.Rect::get_position()
extern "C" Vector2_t2243707579 Rect_get_position_m24550734 (Rect_t3681755626 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Vector2 UnityEngine.Vector2::op_Subtraction(UnityEngine.Vector2,UnityEngine.Vector2)
extern "C" Vector2_t2243707579 Vector2_op_Subtraction_m1984215297 (Il2CppObject * __this /* static, unused */, Vector2_t2243707579 p0, Vector2_t2243707579 p1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.Mathf::Clamp01(System.Single)
extern "C" float Mathf_Clamp01_m3888954684 (Il2CppObject * __this /* static, unused */, float p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.EventSystems.PointerEventData/InputButton UnityEngine.EventSystems.PointerEventData::get_button()
extern "C" int32_t PointerEventData_get_button_m2339189303 (PointerEventData_t1599784723 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.UI.BoxSlider::MayDrag(UnityEngine.EventSystems.PointerEventData)
extern "C" bool BoxSlider_MayDrag_m1941009447 (BoxSlider_t1871650694 * __this, PointerEventData_t1599784723 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.Selectable::OnPointerDown(UnityEngine.EventSystems.PointerEventData)
extern "C" void Selectable_OnPointerDown_m3110480835 (Selectable_t1490392188 * __this, PointerEventData_t1599784723 * p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Camera UnityEngine.EventSystems.PointerEventData::get_enterEventCamera()
extern "C" Camera_t189460977 * PointerEventData_get_enterEventCamera_m1539996745 (PointerEventData_t1599784723 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.RectTransformUtility::RectangleContainsScreenPoint(UnityEngine.RectTransform,UnityEngine.Vector2,UnityEngine.Camera)
extern "C" bool RectTransformUtility_RectangleContainsScreenPoint_m1244853728 (Il2CppObject * __this /* static, unused */, RectTransform_t3349966182 * p0, Vector2_t2243707579 p1, Camera_t189460977 * p2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Camera UnityEngine.EventSystems.PointerEventData::get_pressEventCamera()
extern "C" Camera_t189460977 * PointerEventData_get_pressEventCamera_m724559964 (PointerEventData_t1599784723 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.UI.BoxSlider::UpdateDrag(UnityEngine.EventSystems.PointerEventData,UnityEngine.Camera)
extern "C" void BoxSlider_UpdateDrag_m1281607389 (BoxSlider_t1871650694 * __this, PointerEventData_t1599784723 * ___eventData0, Camera_t189460977 * ___cam1, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.EventSystems.PointerEventData::set_useDragThreshold(System.Boolean)
extern "C" void PointerEventData_set_useDragThreshold_m2778439880 (PointerEventData_t1599784723 * __this, bool p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.EventSystems.UIBehaviour::IsDestroyed()
extern "C" bool UIBehaviour_IsDestroyed_m3809050211 (UIBehaviour_t3960014691 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Events.UnityEvent`2<System.Single,System.Single>::.ctor()
#define UnityEvent_2__ctor_m731674732(__this, method) (( void (*) (UnityEvent_2_t2016657100 *, const MethodInfo*))UnityEvent_2__ctor_m731674732_gshared)(__this, method)
// !!0 UnityEngine.Component::GetComponent<UnityEngine.Light>()
#define Component_GetComponent_TisLight_t494725636_m2604108526(__this, method) (( Light_t494725636 * (*) (Component_t3819376471 *, const MethodInfo*))Component_GetComponent_TisIl2CppObject_m4109961936_gshared)(__this, method)
// UnityEngine.XR.iOS.UnityARSessionNativeInterface UnityEngine.XR.iOS.UnityARSessionNativeInterface::GetARSessionNativeInterface()
extern "C" UnityARSessionNativeInterface_t1130867170 * UnityARSessionNativeInterface_GetARSessionNativeInterface_m3174488657 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Single UnityEngine.XR.iOS.UnityARSessionNativeInterface::GetARAmbientIntensity()
extern "C" float UnityARSessionNativeInterface_GetARAmbientIntensity_m3261179343 (UnityARSessionNativeInterface_t1130867170 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Light::set_intensity(System.Single)
extern "C" void Light_set_intensity_m1790590300 (Light_t494725636 * __this, float p0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void AgentScript::.ctor()
extern "C" void AgentScript__ctor_m2829665649 (AgentScript_t536016518 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (AgentScript__ctor_m2829665649_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
RaycastHit_t87180320 V_0;
memset(&V_0, 0, sizeof(V_0));
{
Initobj (RaycastHit_t87180320_il2cpp_TypeInfo_var, (&V_0));
RaycastHit_t87180320 L_0 = V_0;
__this->set_hitInfo_5(L_0);
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void AgentScript::Start()
extern "C" void AgentScript_Start_m3621949025 (AgentScript_t536016518 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (AgentScript_Start_m3621949025_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
NavMeshAgent_t2761625415 * L_0 = Component_GetComponent_TisNavMeshAgent_t2761625415_m3828941945(__this, /*hidden argument*/Component_GetComponent_TisNavMeshAgent_t2761625415_m3828941945_MethodInfo_var);
__this->set_agent_3(L_0);
Animator_t69676727 * L_1 = Component_GetComponent_TisAnimator_t69676727_m475627522(__this, /*hidden argument*/Component_GetComponent_TisAnimator_t69676727_m475627522_MethodInfo_var);
__this->set_animator_2(L_1);
return;
}
}
// System.Void AgentScript::Update()
extern "C" void AgentScript_Update_m198097924 (AgentScript_t536016518 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (AgentScript_Update_m198097924_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Ray_t2469606224 V_0;
memset(&V_0, 0, sizeof(V_0));
{
IL2CPP_RUNTIME_CLASS_INIT(Input_t1785128008_il2cpp_TypeInfo_var);
bool L_0 = Input_GetMouseButtonDown_m47917805(NULL /*static, unused*/, 0, /*hidden argument*/NULL);
if (!L_0)
{
goto IL_007b;
}
}
{
Camera_t189460977 * L_1 = Camera_get_main_m475173995(NULL /*static, unused*/, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Input_t1785128008_il2cpp_TypeInfo_var);
Vector3_t2243707580 L_2 = Input_get_mousePosition_m146923508(NULL /*static, unused*/, /*hidden argument*/NULL);
NullCheck(L_1);
Ray_t2469606224 L_3 = Camera_ScreenPointToRay_m614889538(L_1, L_2, /*hidden argument*/NULL);
V_0 = L_3;
Vector3_t2243707580 L_4 = Ray_get_origin_m3339262500((&V_0), /*hidden argument*/NULL);
Vector3_t2243707580 L_5 = Ray_get_direction_m4059191533((&V_0), /*hidden argument*/NULL);
RaycastHit_t87180320 * L_6 = __this->get_address_of_hitInfo_5();
bool L_7 = Physics_Raycast_m4027183840(NULL /*static, unused*/, L_4, L_5, L_6, /*hidden argument*/NULL);
if (!L_7)
{
goto IL_007b;
}
}
{
RaycastHit_t87180320 * L_8 = __this->get_address_of_hitInfo_5();
Collider_t3497673348 * L_9 = RaycastHit_get_collider_m301198172(L_8, /*hidden argument*/NULL);
NullCheck(L_9);
bool L_10 = Component_CompareTag_m3443292365(L_9, _stringLiteral1776456860, /*hidden argument*/NULL);
if (!L_10)
{
goto IL_007b;
}
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral1071510377, /*hidden argument*/NULL);
NavMeshAgent_t2761625415 * L_11 = __this->get_agent_3();
RaycastHit_t87180320 * L_12 = __this->get_address_of_hitInfo_5();
Vector3_t2243707580 L_13 = RaycastHit_get_point_m326143462(L_12, /*hidden argument*/NULL);
NullCheck(L_11);
NavMeshAgent_SetDestination_m1354616139(L_11, L_13, /*hidden argument*/NULL);
__this->set_aiActive_6((bool)1);
}
IL_007b:
{
NavMeshAgent_t2761625415 * L_14 = __this->get_agent_3();
NullCheck(L_14);
float L_15 = NavMeshAgent_get_remainingDistance_m2699477664(L_14, /*hidden argument*/NULL);
if ((!(((float)L_15) <= ((float)(0.0f)))))
{
goto IL_00b2;
}
}
{
bool L_16 = __this->get_aiFinished_7();
if (L_16)
{
goto IL_00b2;
}
}
{
Animator_t69676727 * L_17 = __this->get_animator_2();
NullCheck(L_17);
Animator_SetTrigger_m3418492570(L_17, _stringLiteral1492391884, /*hidden argument*/NULL);
__this->set_aiFinished_7((bool)1);
}
IL_00b2:
{
bool L_18 = __this->get_aiActive_6();
if (!L_18)
{
goto IL_00db;
}
}
{
Animator_t69676727 * L_19 = __this->get_animator_2();
NullCheck(L_19);
Animator_SetTrigger_m3418492570(L_19, _stringLiteral551762609, /*hidden argument*/NULL);
__this->set_aiActive_6((bool)0);
__this->set_aiFinished_7((bool)0);
}
IL_00db:
{
return;
}
}
// System.Void changeMenuScript::.ctor()
extern "C" void changeMenuScript__ctor_m3665229309 (changeMenuScript_t586204708 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void changeMenuScript::changeScene(System.String)
extern "C" void changeMenuScript_changeScene_m645723023 (changeMenuScript_t586204708 * __this, String_t* ___sceneName0, const MethodInfo* method)
{
{
String_t* L_0 = ___sceneName0;
SceneManager_LoadScene_m1386820036(NULL /*static, unused*/, L_0, 0, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorChangedEvent::.ctor()
extern "C" void ColorChangedEvent__ctor_m3710136698 (ColorChangedEvent_t2990895397 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorChangedEvent__ctor_m3710136698_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
UnityEvent_1__ctor_m117795578(__this, /*hidden argument*/UnityEvent_1__ctor_m117795578_MethodInfo_var);
return;
}
}
// System.Void ColorImage::.ctor()
extern "C" void ColorImage__ctor_m797732221 (ColorImage_t3157136356 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorImage::Awake()
extern "C" void ColorImage_Awake_m1432153760 (ColorImage_t3157136356 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorImage_Awake_m1432153760_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Image_t2042527209 * L_0 = Component_GetComponent_TisImage_t2042527209_m2189462422(__this, /*hidden argument*/Component_GetComponent_TisImage_t2042527209_m2189462422_MethodInfo_var);
__this->set_image_3(L_0);
ColorPicker_t3035206225 * L_1 = __this->get_picker_2();
NullCheck(L_1);
ColorChangedEvent_t2990895397 * L_2 = L_1->get_onValueChanged_9();
IntPtr_t L_3;
L_3.set_m_value_0((void*)(void*)ColorImage_ColorChanged_m2780022934_MethodInfo_var);
UnityAction_1_t3386977826 * L_4 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_4, __this, L_3, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_2);
UnityEvent_1_AddListener_m903508446(L_2, L_4, /*hidden argument*/UnityEvent_1_AddListener_m903508446_MethodInfo_var);
return;
}
}
// System.Void ColorImage::OnDestroy()
extern "C" void ColorImage_OnDestroy_m537617202 (ColorImage_t3157136356 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorImage_OnDestroy_m537617202_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
NullCheck(L_0);
ColorChangedEvent_t2990895397 * L_1 = L_0->get_onValueChanged_9();
IntPtr_t L_2;
L_2.set_m_value_0((void*)(void*)ColorImage_ColorChanged_m2780022934_MethodInfo_var);
UnityAction_1_t3386977826 * L_3 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_3, __this, L_2, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_1);
UnityEvent_1_RemoveListener_m1138414664(L_1, L_3, /*hidden argument*/UnityEvent_1_RemoveListener_m1138414664_MethodInfo_var);
return;
}
}
// System.Void ColorImage::ColorChanged(UnityEngine.Color)
extern "C" void ColorImage_ColorChanged_m2780022934 (ColorImage_t3157136356 * __this, Color_t2020392075 ___newColor0, const MethodInfo* method)
{
{
Image_t2042527209 * L_0 = __this->get_image_3();
Color_t2020392075 L_1 = ___newColor0;
NullCheck(L_0);
VirtActionInvoker1< Color_t2020392075 >::Invoke(23 /* System.Void UnityEngine.UI.Graphic::set_color(UnityEngine.Color) */, L_0, L_1);
return;
}
}
// System.Void ColorLabel::.ctor()
extern "C" void ColorLabel__ctor_m3361268158 (ColorLabel_t1884607337 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorLabel__ctor_m3361268158_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
__this->set_prefix_4(_stringLiteral2880467378);
__this->set_maxValue_6((255.0f));
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorLabel::Awake()
extern "C" void ColorLabel_Awake_m1477595641 (ColorLabel_t1884607337 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorLabel_Awake_m1477595641_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Text_t356221433 * L_0 = Component_GetComponent_TisText_t356221433_m1342661039(__this, /*hidden argument*/Component_GetComponent_TisText_t356221433_m1342661039_MethodInfo_var);
__this->set_label_8(L_0);
return;
}
}
// System.Void ColorLabel::OnEnable()
extern "C" void ColorLabel_OnEnable_m3391994902 (ColorLabel_t1884607337 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorLabel_OnEnable_m3391994902_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
bool L_0 = Application_get_isPlaying_m4091950718(NULL /*static, unused*/, /*hidden argument*/NULL);
if (!L_0)
{
goto IL_0053;
}
}
{
ColorPicker_t3035206225 * L_1 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_2 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_1, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0053;
}
}
{
ColorPicker_t3035206225 * L_3 = __this->get_picker_2();
NullCheck(L_3);
ColorChangedEvent_t2990895397 * L_4 = L_3->get_onValueChanged_9();
IntPtr_t L_5;
L_5.set_m_value_0((void*)(void*)ColorLabel_ColorChanged_m35916549_MethodInfo_var);
UnityAction_1_t3386977826 * L_6 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_6, __this, L_5, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_4);
UnityEvent_1_AddListener_m903508446(L_4, L_6, /*hidden argument*/UnityEvent_1_AddListener_m903508446_MethodInfo_var);
ColorPicker_t3035206225 * L_7 = __this->get_picker_2();
NullCheck(L_7);
HSVChangedEvent_t1170297569 * L_8 = L_7->get_onHSVChanged_10();
IntPtr_t L_9;
L_9.set_m_value_0((void*)(void*)ColorLabel_HSVChanged_m3658710332_MethodInfo_var);
UnityAction_3_t235051313 * L_10 = (UnityAction_3_t235051313 *)il2cpp_codegen_object_new(UnityAction_3_t235051313_il2cpp_TypeInfo_var);
UnityAction_3__ctor_m3626891334(L_10, __this, L_9, /*hidden argument*/UnityAction_3__ctor_m3626891334_MethodInfo_var);
NullCheck(L_8);
UnityEvent_3_AddListener_m3608966849(L_8, L_10, /*hidden argument*/UnityEvent_3_AddListener_m3608966849_MethodInfo_var);
}
IL_0053:
{
return;
}
}
// System.Void ColorLabel::OnDestroy()
extern "C" void ColorLabel_OnDestroy_m648294215 (ColorLabel_t1884607337 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorLabel_OnDestroy_m648294215_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_0, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0049;
}
}
{
ColorPicker_t3035206225 * L_2 = __this->get_picker_2();
NullCheck(L_2);
ColorChangedEvent_t2990895397 * L_3 = L_2->get_onValueChanged_9();
IntPtr_t L_4;
L_4.set_m_value_0((void*)(void*)ColorLabel_ColorChanged_m35916549_MethodInfo_var);
UnityAction_1_t3386977826 * L_5 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_5, __this, L_4, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_3);
UnityEvent_1_RemoveListener_m1138414664(L_3, L_5, /*hidden argument*/UnityEvent_1_RemoveListener_m1138414664_MethodInfo_var);
ColorPicker_t3035206225 * L_6 = __this->get_picker_2();
NullCheck(L_6);
HSVChangedEvent_t1170297569 * L_7 = L_6->get_onHSVChanged_10();
IntPtr_t L_8;
L_8.set_m_value_0((void*)(void*)ColorLabel_HSVChanged_m3658710332_MethodInfo_var);
UnityAction_3_t235051313 * L_9 = (UnityAction_3_t235051313 *)il2cpp_codegen_object_new(UnityAction_3_t235051313_il2cpp_TypeInfo_var);
UnityAction_3__ctor_m3626891334(L_9, __this, L_8, /*hidden argument*/UnityAction_3__ctor_m3626891334_MethodInfo_var);
NullCheck(L_7);
UnityEvent_3_RemoveListener_m2407167912(L_7, L_9, /*hidden argument*/UnityEvent_3_RemoveListener_m2407167912_MethodInfo_var);
}
IL_0049:
{
return;
}
}
// System.Void ColorLabel::ColorChanged(UnityEngine.Color)
extern "C" void ColorLabel_ColorChanged_m35916549 (ColorLabel_t1884607337 * __this, Color_t2020392075 ___color0, const MethodInfo* method)
{
{
ColorLabel_UpdateValue_m3108932048(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorLabel::HSVChanged(System.Single,System.Single,System.Single)
extern "C" void ColorLabel_HSVChanged_m3658710332 (ColorLabel_t1884607337 * __this, float ___hue0, float ___sateration1, float ___value2, const MethodInfo* method)
{
{
ColorLabel_UpdateValue_m3108932048(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorLabel::UpdateValue()
extern "C" void ColorLabel_UpdateValue_m3108932048 (ColorLabel_t1884607337 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorLabel_UpdateValue_m3108932048_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
float V_0 = 0.0f;
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Equality_m3764089466(NULL /*static, unused*/, L_0, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0031;
}
}
{
Text_t356221433 * L_2 = __this->get_label_8();
String_t* L_3 = __this->get_prefix_4();
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_4 = String_Concat_m2596409543(NULL /*static, unused*/, L_3, _stringLiteral372029313, /*hidden argument*/NULL);
NullCheck(L_2);
VirtActionInvoker1< String_t* >::Invoke(72 /* System.Void UnityEngine.UI.Text::set_text(System.String) */, L_2, L_4);
goto IL_0075;
}
IL_0031:
{
float L_5 = __this->get_minValue_5();
ColorPicker_t3035206225 * L_6 = __this->get_picker_2();
int32_t L_7 = __this->get_type_3();
NullCheck(L_6);
float L_8 = ColorPicker_GetValue_m1991475278(L_6, L_7, /*hidden argument*/NULL);
float L_9 = __this->get_maxValue_6();
float L_10 = __this->get_minValue_5();
V_0 = ((float)((float)L_5+(float)((float)((float)L_8*(float)((float)((float)L_9-(float)L_10))))));
Text_t356221433 * L_11 = __this->get_label_8();
String_t* L_12 = __this->get_prefix_4();
float L_13 = V_0;
String_t* L_14 = ColorLabel_ConvertToDisplayString_m1654160419(__this, L_13, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_15 = String_Concat_m2596409543(NULL /*static, unused*/, L_12, L_14, /*hidden argument*/NULL);
NullCheck(L_11);
VirtActionInvoker1< String_t* >::Invoke(72 /* System.Void UnityEngine.UI.Text::set_text(System.String) */, L_11, L_15);
}
IL_0075:
{
return;
}
}
// System.String ColorLabel::ConvertToDisplayString(System.Single)
extern "C" String_t* ColorLabel_ConvertToDisplayString_m1654160419 (ColorLabel_t1884607337 * __this, float ___value0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorLabel_ConvertToDisplayString_m1654160419_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
int32_t V_0 = 0;
{
int32_t L_0 = __this->get_precision_7();
if ((((int32_t)L_0) <= ((int32_t)0)))
{
goto IL_0029;
}
}
{
int32_t L_1 = __this->get_precision_7();
int32_t L_2 = L_1;
Il2CppObject * L_3 = Box(Int32_t2071877448_il2cpp_TypeInfo_var, &L_2);
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_4 = String_Concat_m56707527(NULL /*static, unused*/, _stringLiteral811305532, L_3, /*hidden argument*/NULL);
String_t* L_5 = Single_ToString_m2359963436((&___value0), L_4, /*hidden argument*/NULL);
return L_5;
}
IL_0029:
{
float L_6 = ___value0;
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
int32_t L_7 = Mathf_FloorToInt_m4005035722(NULL /*static, unused*/, L_6, /*hidden argument*/NULL);
V_0 = L_7;
String_t* L_8 = Int32_ToString_m2960866144((&V_0), /*hidden argument*/NULL);
return L_8;
}
}
// System.Void ColorPicker::.ctor()
extern "C" void ColorPicker__ctor_m1239957560 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorPicker__ctor_m1239957560_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
__this->set__alpha_8((1.0f));
ColorChangedEvent_t2990895397 * L_0 = (ColorChangedEvent_t2990895397 *)il2cpp_codegen_object_new(ColorChangedEvent_t2990895397_il2cpp_TypeInfo_var);
ColorChangedEvent__ctor_m3710136698(L_0, /*hidden argument*/NULL);
__this->set_onValueChanged_9(L_0);
HSVChangedEvent_t1170297569 * L_1 = (HSVChangedEvent_t1170297569 *)il2cpp_codegen_object_new(HSVChangedEvent_t1170297569_il2cpp_TypeInfo_var);
HSVChangedEvent__ctor_m3043072144(L_1, /*hidden argument*/NULL);
__this->set_onHSVChanged_10(L_1);
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// UnityEngine.Color ColorPicker::get_CurrentColor()
extern "C" Color_t2020392075 ColorPicker_get_CurrentColor_m3166096170 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get__red_5();
float L_1 = __this->get__green_6();
float L_2 = __this->get__blue_7();
float L_3 = __this->get__alpha_8();
Color_t2020392075 L_4;
memset(&L_4, 0, sizeof(L_4));
Color__ctor_m1909920690(&L_4, L_0, L_1, L_2, L_3, /*hidden argument*/NULL);
return L_4;
}
}
// System.Void ColorPicker::set_CurrentColor(UnityEngine.Color)
extern "C" void ColorPicker_set_CurrentColor_m2125228471 (ColorPicker_t3035206225 * __this, Color_t2020392075 ___value0, const MethodInfo* method)
{
{
Color_t2020392075 L_0 = ColorPicker_get_CurrentColor_m3166096170(__this, /*hidden argument*/NULL);
Color_t2020392075 L_1 = ___value0;
bool L_2 = Color_op_Equality_m3156451394(NULL /*static, unused*/, L_0, L_1, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0012;
}
}
{
return;
}
IL_0012:
{
float L_3 = (&___value0)->get_r_0();
__this->set__red_5(L_3);
float L_4 = (&___value0)->get_g_1();
__this->set__green_6(L_4);
float L_5 = (&___value0)->get_b_2();
__this->set__blue_7(L_5);
float L_6 = (&___value0)->get_a_3();
__this->set__alpha_8(L_6);
ColorPicker_RGBChanged_m2442023581(__this, /*hidden argument*/NULL);
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorPicker::Start()
extern "C" void ColorPicker_Start_m1519077976 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Single ColorPicker::get_H()
extern "C" float ColorPicker_get_H_m3860865411 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get__hue_2();
return L_0;
}
}
// System.Void ColorPicker::set_H(System.Single)
extern "C" void ColorPicker_set_H_m2725867100 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = __this->get__hue_2();
float L_1 = ___value0;
if ((!(((float)L_0) == ((float)L_1))))
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
float L_2 = ___value0;
__this->set__hue_2(L_2);
ColorPicker_HSVChanged_m3054464207(__this, /*hidden argument*/NULL);
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Single ColorPicker::get_S()
extern "C" float ColorPicker_get_S_m2449498732 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get__saturation_3();
return L_0;
}
}
// System.Void ColorPicker::set_S(System.Single)
extern "C" void ColorPicker_set_S_m985865155 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = __this->get__saturation_3();
float L_1 = ___value0;
if ((!(((float)L_0) == ((float)L_1))))
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
float L_2 = ___value0;
__this->set__saturation_3(L_2);
ColorPicker_HSVChanged_m3054464207(__this, /*hidden argument*/NULL);
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Single ColorPicker::get_V()
extern "C" float ColorPicker_get_V_m265062405 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get__brightness_4();
return L_0;
}
}
// System.Void ColorPicker::set_V(System.Single)
extern "C" void ColorPicker_set_V_m1877583698 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = __this->get__brightness_4();
float L_1 = ___value0;
if ((!(((float)L_0) == ((float)L_1))))
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
float L_2 = ___value0;
__this->set__brightness_4(L_2);
ColorPicker_HSVChanged_m3054464207(__this, /*hidden argument*/NULL);
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Single ColorPicker::get_R()
extern "C" float ColorPicker_get_R_m3995379697 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get__red_5();
return L_0;
}
}
// System.Void ColorPicker::set_R(System.Single)
extern "C" void ColorPicker_set_R_m350597694 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = __this->get__red_5();
float L_1 = ___value0;
if ((!(((float)L_0) == ((float)L_1))))
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
float L_2 = ___value0;
__this->set__red_5(L_2);
ColorPicker_RGBChanged_m2442023581(__this, /*hidden argument*/NULL);
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Single ColorPicker::get_G()
extern "C" float ColorPicker_get_G_m755548720 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get__green_6();
return L_0;
}
}
// System.Void ColorPicker::set_G(System.Single)
extern "C" void ColorPicker_set_G_m2188343591 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = __this->get__green_6();
float L_1 = ___value0;
if ((!(((float)L_0) == ((float)L_1))))
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
float L_2 = ___value0;
__this->set__green_6(L_2);
ColorPicker_RGBChanged_m2442023581(__this, /*hidden argument*/NULL);
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Single ColorPicker::get_B()
extern "C" float ColorPicker_get_B_m1736779681 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get__blue_7();
return L_0;
}
}
// System.Void ColorPicker::set_B(System.Single)
extern "C" void ColorPicker_set_B_m26090126 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = __this->get__blue_7();
float L_1 = ___value0;
if ((!(((float)L_0) == ((float)L_1))))
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
float L_2 = ___value0;
__this->set__blue_7(L_2);
ColorPicker_RGBChanged_m2442023581(__this, /*hidden argument*/NULL);
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Single ColorPicker::get_A()
extern "C" float ColorPicker_get_A_m473223718 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get__alpha_8();
return L_0;
}
}
// System.Void ColorPicker::set_A(System.Single)
extern "C" void ColorPicker_set_A_m1839123465 (ColorPicker_t3035206225 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = __this->get__alpha_8();
float L_1 = ___value0;
if ((!(((float)L_0) == ((float)L_1))))
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
float L_2 = ___value0;
__this->set__alpha_8(L_2);
ColorPicker_SendChangedEvent_m2880248376(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorPicker::RGBChanged()
extern "C" void ColorPicker_RGBChanged_m2442023581 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
HsvColor_t1057062332 V_0;
memset(&V_0, 0, sizeof(V_0));
{
Color_t2020392075 L_0 = ColorPicker_get_CurrentColor_m3166096170(__this, /*hidden argument*/NULL);
HsvColor_t1057062332 L_1 = HSVUtil_ConvertRgbToHsv_m4088715697(NULL /*static, unused*/, L_0, /*hidden argument*/NULL);
V_0 = L_1;
float L_2 = HsvColor_get_normalizedH_m3607787917((&V_0), /*hidden argument*/NULL);
__this->set__hue_2(L_2);
float L_3 = HsvColor_get_normalizedS_m3607786980((&V_0), /*hidden argument*/NULL);
__this->set__saturation_3(L_3);
float L_4 = HsvColor_get_normalizedV_m3607786943((&V_0), /*hidden argument*/NULL);
__this->set__brightness_4(L_4);
return;
}
}
// System.Void ColorPicker::HSVChanged()
extern "C" void ColorPicker_HSVChanged_m3054464207 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
Color_t2020392075 V_0;
memset(&V_0, 0, sizeof(V_0));
{
float L_0 = __this->get__hue_2();
float L_1 = __this->get__saturation_3();
float L_2 = __this->get__brightness_4();
float L_3 = __this->get__alpha_8();
Color_t2020392075 L_4 = HSVUtil_ConvertHsvToRgb_m2339284600(NULL /*static, unused*/, (((double)((double)((float)((float)L_0*(float)(360.0f)))))), (((double)((double)L_1))), (((double)((double)L_2))), L_3, /*hidden argument*/NULL);
V_0 = L_4;
float L_5 = (&V_0)->get_r_0();
__this->set__red_5(L_5);
float L_6 = (&V_0)->get_g_1();
__this->set__green_6(L_6);
float L_7 = (&V_0)->get_b_2();
__this->set__blue_7(L_7);
return;
}
}
// System.Void ColorPicker::SendChangedEvent()
extern "C" void ColorPicker_SendChangedEvent_m2880248376 (ColorPicker_t3035206225 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorPicker_SendChangedEvent_m2880248376_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorChangedEvent_t2990895397 * L_0 = __this->get_onValueChanged_9();
Color_t2020392075 L_1 = ColorPicker_get_CurrentColor_m3166096170(__this, /*hidden argument*/NULL);
NullCheck(L_0);
UnityEvent_1_Invoke_m2213115825(L_0, L_1, /*hidden argument*/UnityEvent_1_Invoke_m2213115825_MethodInfo_var);
HSVChangedEvent_t1170297569 * L_2 = __this->get_onHSVChanged_10();
float L_3 = __this->get__hue_2();
float L_4 = __this->get__saturation_3();
float L_5 = __this->get__brightness_4();
NullCheck(L_2);
UnityEvent_3_Invoke_m2734200716(L_2, L_3, L_4, L_5, /*hidden argument*/UnityEvent_3_Invoke_m2734200716_MethodInfo_var);
return;
}
}
// System.Void ColorPicker::AssignColor(ColorValues,System.Single)
extern "C" void ColorPicker_AssignColor_m579716850 (ColorPicker_t3035206225 * __this, int32_t ___type0, float ___value1, const MethodInfo* method)
{
{
int32_t L_0 = ___type0;
switch (L_0)
{
case 0:
{
goto IL_0027;
}
case 1:
{
goto IL_0033;
}
case 2:
{
goto IL_003f;
}
case 3:
{
goto IL_004b;
}
case 4:
{
goto IL_0057;
}
case 5:
{
goto IL_0063;
}
case 6:
{
goto IL_006f;
}
}
}
{
goto IL_007b;
}
IL_0027:
{
float L_1 = ___value1;
ColorPicker_set_R_m350597694(__this, L_1, /*hidden argument*/NULL);
goto IL_0080;
}
IL_0033:
{
float L_2 = ___value1;
ColorPicker_set_G_m2188343591(__this, L_2, /*hidden argument*/NULL);
goto IL_0080;
}
IL_003f:
{
float L_3 = ___value1;
ColorPicker_set_B_m26090126(__this, L_3, /*hidden argument*/NULL);
goto IL_0080;
}
IL_004b:
{
float L_4 = ___value1;
ColorPicker_set_A_m1839123465(__this, L_4, /*hidden argument*/NULL);
goto IL_0080;
}
IL_0057:
{
float L_5 = ___value1;
ColorPicker_set_H_m2725867100(__this, L_5, /*hidden argument*/NULL);
goto IL_0080;
}
IL_0063:
{
float L_6 = ___value1;
ColorPicker_set_S_m985865155(__this, L_6, /*hidden argument*/NULL);
goto IL_0080;
}
IL_006f:
{
float L_7 = ___value1;
ColorPicker_set_V_m1877583698(__this, L_7, /*hidden argument*/NULL);
goto IL_0080;
}
IL_007b:
{
goto IL_0080;
}
IL_0080:
{
return;
}
}
// System.Single ColorPicker::GetValue(ColorValues)
extern "C" float ColorPicker_GetValue_m1991475278 (ColorPicker_t3035206225 * __this, int32_t ___type0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorPicker_GetValue_m1991475278_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
int32_t L_0 = ___type0;
switch (L_0)
{
case 0:
{
goto IL_0027;
}
case 1:
{
goto IL_002e;
}
case 2:
{
goto IL_0035;
}
case 3:
{
goto IL_003c;
}
case 4:
{
goto IL_0043;
}
case 5:
{
goto IL_004a;
}
case 6:
{
goto IL_0051;
}
}
}
{
goto IL_0058;
}
IL_0027:
{
float L_1 = ColorPicker_get_R_m3995379697(__this, /*hidden argument*/NULL);
return L_1;
}
IL_002e:
{
float L_2 = ColorPicker_get_G_m755548720(__this, /*hidden argument*/NULL);
return L_2;
}
IL_0035:
{
float L_3 = ColorPicker_get_B_m1736779681(__this, /*hidden argument*/NULL);
return L_3;
}
IL_003c:
{
float L_4 = ColorPicker_get_A_m473223718(__this, /*hidden argument*/NULL);
return L_4;
}
IL_0043:
{
float L_5 = ColorPicker_get_H_m3860865411(__this, /*hidden argument*/NULL);
return L_5;
}
IL_004a:
{
float L_6 = ColorPicker_get_S_m2449498732(__this, /*hidden argument*/NULL);
return L_6;
}
IL_0051:
{
float L_7 = ColorPicker_get_V_m265062405(__this, /*hidden argument*/NULL);
return L_7;
}
IL_0058:
{
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_8 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
NotImplementedException_t2785117854 * L_9 = (NotImplementedException_t2785117854 *)il2cpp_codegen_object_new(NotImplementedException_t2785117854_il2cpp_TypeInfo_var);
NotImplementedException__ctor_m1795163961(L_9, L_8, /*hidden argument*/NULL);
IL2CPP_RAISE_MANAGED_EXCEPTION(L_9);
}
}
// System.Void ColorPickerTester::.ctor()
extern "C" void ColorPickerTester__ctor_m185493325 (ColorPickerTester_t1006114474 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorPickerTester::Start()
extern "C" void ColorPickerTester_Start_m2707422277 (ColorPickerTester_t1006114474 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorPickerTester_Start_m2707422277_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_3();
NullCheck(L_0);
ColorChangedEvent_t2990895397 * L_1 = L_0->get_onValueChanged_9();
IntPtr_t L_2;
L_2.set_m_value_0((void*)(void*)ColorPickerTester_U3CStartU3Em__0_m540941732_MethodInfo_var);
UnityAction_1_t3386977826 * L_3 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_3, __this, L_2, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_1);
UnityEvent_1_AddListener_m903508446(L_1, L_3, /*hidden argument*/UnityEvent_1_AddListener_m903508446_MethodInfo_var);
Renderer_t257310565 * L_4 = __this->get_renderer_2();
NullCheck(L_4);
Material_t193706927 * L_5 = Renderer_get_material_m2553789785(L_4, /*hidden argument*/NULL);
ColorPicker_t3035206225 * L_6 = __this->get_picker_3();
NullCheck(L_6);
Color_t2020392075 L_7 = ColorPicker_get_CurrentColor_m3166096170(L_6, /*hidden argument*/NULL);
NullCheck(L_5);
Material_set_color_m577844242(L_5, L_7, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorPickerTester::Update()
extern "C" void ColorPickerTester_Update_m85289384 (ColorPickerTester_t1006114474 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void ColorPickerTester::<Start>m__0(UnityEngine.Color)
extern "C" void ColorPickerTester_U3CStartU3Em__0_m540941732 (ColorPickerTester_t1006114474 * __this, Color_t2020392075 ___color0, const MethodInfo* method)
{
{
Renderer_t257310565 * L_0 = __this->get_renderer_2();
NullCheck(L_0);
Material_t193706927 * L_1 = Renderer_get_material_m2553789785(L_0, /*hidden argument*/NULL);
Color_t2020392075 L_2 = ___color0;
NullCheck(L_1);
Material_set_color_m577844242(L_1, L_2, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorPresets::.ctor()
extern "C" void ColorPresets__ctor_m508027560 (ColorPresets_t4120623669 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorPresets::Awake()
extern "C" void ColorPresets_Awake_m2912318885 (ColorPresets_t4120623669 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorPresets_Awake_m2912318885_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
NullCheck(L_0);
ColorChangedEvent_t2990895397 * L_1 = L_0->get_onValueChanged_9();
IntPtr_t L_2;
L_2.set_m_value_0((void*)(void*)ColorPresets_ColorChanged_m578093369_MethodInfo_var);
UnityAction_1_t3386977826 * L_3 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_3, __this, L_2, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_1);
UnityEvent_1_AddListener_m903508446(L_1, L_3, /*hidden argument*/UnityEvent_1_AddListener_m903508446_MethodInfo_var);
return;
}
}
// System.Void ColorPresets::CreatePresetButton()
extern "C" void ColorPresets_CreatePresetButton_m19834235 (ColorPresets_t4120623669 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorPresets_CreatePresetButton_m19834235_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
int32_t V_0 = 0;
{
V_0 = 0;
goto IL_004d;
}
IL_0007:
{
GameObjectU5BU5D_t3057952154* L_0 = __this->get_presets_3();
int32_t L_1 = V_0;
NullCheck(L_0);
int32_t L_2 = L_1;
GameObject_t1756533147 * L_3 = (L_0)->GetAt(static_cast<il2cpp_array_size_t>(L_2));
NullCheck(L_3);
bool L_4 = GameObject_get_activeSelf_m313590879(L_3, /*hidden argument*/NULL);
if (L_4)
{
goto IL_0049;
}
}
{
GameObjectU5BU5D_t3057952154* L_5 = __this->get_presets_3();
int32_t L_6 = V_0;
NullCheck(L_5);
int32_t L_7 = L_6;
GameObject_t1756533147 * L_8 = (L_5)->GetAt(static_cast<il2cpp_array_size_t>(L_7));
NullCheck(L_8);
GameObject_SetActive_m2887581199(L_8, (bool)1, /*hidden argument*/NULL);
GameObjectU5BU5D_t3057952154* L_9 = __this->get_presets_3();
int32_t L_10 = V_0;
NullCheck(L_9);
int32_t L_11 = L_10;
GameObject_t1756533147 * L_12 = (L_9)->GetAt(static_cast<il2cpp_array_size_t>(L_11));
NullCheck(L_12);
Image_t2042527209 * L_13 = GameObject_GetComponent_TisImage_t2042527209_m4162535761(L_12, /*hidden argument*/GameObject_GetComponent_TisImage_t2042527209_m4162535761_MethodInfo_var);
ColorPicker_t3035206225 * L_14 = __this->get_picker_2();
NullCheck(L_14);
Color_t2020392075 L_15 = ColorPicker_get_CurrentColor_m3166096170(L_14, /*hidden argument*/NULL);
NullCheck(L_13);
VirtActionInvoker1< Color_t2020392075 >::Invoke(23 /* System.Void UnityEngine.UI.Graphic::set_color(UnityEngine.Color) */, L_13, L_15);
goto IL_005b;
}
IL_0049:
{
int32_t L_16 = V_0;
V_0 = ((int32_t)((int32_t)L_16+(int32_t)1));
}
IL_004d:
{
int32_t L_17 = V_0;
GameObjectU5BU5D_t3057952154* L_18 = __this->get_presets_3();
NullCheck(L_18);
if ((((int32_t)L_17) < ((int32_t)(((int32_t)((int32_t)(((Il2CppArray *)L_18)->max_length)))))))
{
goto IL_0007;
}
}
IL_005b:
{
return;
}
}
// System.Void ColorPresets::PresetSelect(UnityEngine.UI.Image)
extern "C" void ColorPresets_PresetSelect_m1727594879 (ColorPresets_t4120623669 * __this, Image_t2042527209 * ___sender0, const MethodInfo* method)
{
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
Image_t2042527209 * L_1 = ___sender0;
NullCheck(L_1);
Color_t2020392075 L_2 = VirtFuncInvoker0< Color_t2020392075 >::Invoke(22 /* UnityEngine.Color UnityEngine.UI.Graphic::get_color() */, L_1);
NullCheck(L_0);
ColorPicker_set_CurrentColor_m2125228471(L_0, L_2, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorPresets::ColorChanged(UnityEngine.Color)
extern "C" void ColorPresets_ColorChanged_m578093369 (ColorPresets_t4120623669 * __this, Color_t2020392075 ___color0, const MethodInfo* method)
{
{
Image_t2042527209 * L_0 = __this->get_createPresetImage_4();
Color_t2020392075 L_1 = ___color0;
NullCheck(L_0);
VirtActionInvoker1< Color_t2020392075 >::Invoke(23 /* System.Void UnityEngine.UI.Graphic::set_color(UnityEngine.Color) */, L_0, L_1);
return;
}
}
// System.Void ColorSlider::.ctor()
extern "C" void ColorSlider__ctor_m3582912827 (ColorSlider_t2729134766 * __this, const MethodInfo* method)
{
{
__this->set_listen_5((bool)1);
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorSlider::Awake()
extern "C" void ColorSlider_Awake_m2035409562 (ColorSlider_t2729134766 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorSlider_Awake_m2035409562_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Slider_t297367283 * L_0 = Component_GetComponent_TisSlider_t297367283_m1462559763(__this, /*hidden argument*/Component_GetComponent_TisSlider_t297367283_m1462559763_MethodInfo_var);
__this->set_slider_4(L_0);
ColorPicker_t3035206225 * L_1 = __this->get_hsvpicker_2();
NullCheck(L_1);
ColorChangedEvent_t2990895397 * L_2 = L_1->get_onValueChanged_9();
IntPtr_t L_3;
L_3.set_m_value_0((void*)(void*)ColorSlider_ColorChanged_m742523788_MethodInfo_var);
UnityAction_1_t3386977826 * L_4 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_4, __this, L_3, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_2);
UnityEvent_1_AddListener_m903508446(L_2, L_4, /*hidden argument*/UnityEvent_1_AddListener_m903508446_MethodInfo_var);
ColorPicker_t3035206225 * L_5 = __this->get_hsvpicker_2();
NullCheck(L_5);
HSVChangedEvent_t1170297569 * L_6 = L_5->get_onHSVChanged_10();
IntPtr_t L_7;
L_7.set_m_value_0((void*)(void*)ColorSlider_HSVChanged_m3304896453_MethodInfo_var);
UnityAction_3_t235051313 * L_8 = (UnityAction_3_t235051313 *)il2cpp_codegen_object_new(UnityAction_3_t235051313_il2cpp_TypeInfo_var);
UnityAction_3__ctor_m3626891334(L_8, __this, L_7, /*hidden argument*/UnityAction_3__ctor_m3626891334_MethodInfo_var);
NullCheck(L_6);
UnityEvent_3_AddListener_m3608966849(L_6, L_8, /*hidden argument*/UnityEvent_3_AddListener_m3608966849_MethodInfo_var);
Slider_t297367283 * L_9 = __this->get_slider_4();
NullCheck(L_9);
SliderEvent_t2111116400 * L_10 = Slider_get_onValueChanged_m4261003214(L_9, /*hidden argument*/NULL);
IntPtr_t L_11;
L_11.set_m_value_0((void*)(void*)ColorSlider_SliderChanged_m1758874829_MethodInfo_var);
UnityAction_1_t3443095683 * L_12 = (UnityAction_1_t3443095683 *)il2cpp_codegen_object_new(UnityAction_1_t3443095683_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m2172708761(L_12, __this, L_11, /*hidden argument*/UnityAction_1__ctor_m2172708761_MethodInfo_var);
NullCheck(L_10);
UnityEvent_1_AddListener_m2377847221(L_10, L_12, /*hidden argument*/UnityEvent_1_AddListener_m2377847221_MethodInfo_var);
return;
}
}
// System.Void ColorSlider::OnDestroy()
extern "C" void ColorSlider_OnDestroy_m1119776176 (ColorSlider_t2729134766 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorSlider_OnDestroy_m1119776176_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorPicker_t3035206225 * L_0 = __this->get_hsvpicker_2();
NullCheck(L_0);
ColorChangedEvent_t2990895397 * L_1 = L_0->get_onValueChanged_9();
IntPtr_t L_2;
L_2.set_m_value_0((void*)(void*)ColorSlider_ColorChanged_m742523788_MethodInfo_var);
UnityAction_1_t3386977826 * L_3 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_3, __this, L_2, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_1);
UnityEvent_1_RemoveListener_m1138414664(L_1, L_3, /*hidden argument*/UnityEvent_1_RemoveListener_m1138414664_MethodInfo_var);
ColorPicker_t3035206225 * L_4 = __this->get_hsvpicker_2();
NullCheck(L_4);
HSVChangedEvent_t1170297569 * L_5 = L_4->get_onHSVChanged_10();
IntPtr_t L_6;
L_6.set_m_value_0((void*)(void*)ColorSlider_HSVChanged_m3304896453_MethodInfo_var);
UnityAction_3_t235051313 * L_7 = (UnityAction_3_t235051313 *)il2cpp_codegen_object_new(UnityAction_3_t235051313_il2cpp_TypeInfo_var);
UnityAction_3__ctor_m3626891334(L_7, __this, L_6, /*hidden argument*/UnityAction_3__ctor_m3626891334_MethodInfo_var);
NullCheck(L_5);
UnityEvent_3_RemoveListener_m2407167912(L_5, L_7, /*hidden argument*/UnityEvent_3_RemoveListener_m2407167912_MethodInfo_var);
Slider_t297367283 * L_8 = __this->get_slider_4();
NullCheck(L_8);
SliderEvent_t2111116400 * L_9 = Slider_get_onValueChanged_m4261003214(L_8, /*hidden argument*/NULL);
IntPtr_t L_10;
L_10.set_m_value_0((void*)(void*)ColorSlider_SliderChanged_m1758874829_MethodInfo_var);
UnityAction_1_t3443095683 * L_11 = (UnityAction_1_t3443095683 *)il2cpp_codegen_object_new(UnityAction_1_t3443095683_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m2172708761(L_11, __this, L_10, /*hidden argument*/UnityAction_1__ctor_m2172708761_MethodInfo_var);
NullCheck(L_9);
UnityEvent_1_RemoveListener_m2564825698(L_9, L_11, /*hidden argument*/UnityEvent_1_RemoveListener_m2564825698_MethodInfo_var);
return;
}
}
// System.Void ColorSlider::ColorChanged(UnityEngine.Color)
extern "C" void ColorSlider_ColorChanged_m742523788 (ColorSlider_t2729134766 * __this, Color_t2020392075 ___newColor0, const MethodInfo* method)
{
int32_t V_0 = 0;
{
__this->set_listen_5((bool)0);
int32_t L_0 = __this->get_type_3();
V_0 = L_0;
int32_t L_1 = V_0;
switch (L_1)
{
case 0:
{
goto IL_0029;
}
case 1:
{
goto IL_0040;
}
case 2:
{
goto IL_0057;
}
case 3:
{
goto IL_006e;
}
}
}
{
goto IL_0085;
}
IL_0029:
{
Slider_t297367283 * L_2 = __this->get_slider_4();
float L_3 = (&___newColor0)->get_r_0();
NullCheck(L_2);
Slider_set_normalizedValue_m3093868078(L_2, L_3, /*hidden argument*/NULL);
goto IL_008a;
}
IL_0040:
{
Slider_t297367283 * L_4 = __this->get_slider_4();
float L_5 = (&___newColor0)->get_g_1();
NullCheck(L_4);
Slider_set_normalizedValue_m3093868078(L_4, L_5, /*hidden argument*/NULL);
goto IL_008a;
}
IL_0057:
{
Slider_t297367283 * L_6 = __this->get_slider_4();
float L_7 = (&___newColor0)->get_b_2();
NullCheck(L_6);
Slider_set_normalizedValue_m3093868078(L_6, L_7, /*hidden argument*/NULL);
goto IL_008a;
}
IL_006e:
{
Slider_t297367283 * L_8 = __this->get_slider_4();
float L_9 = (&___newColor0)->get_a_3();
NullCheck(L_8);
Slider_set_normalizedValue_m3093868078(L_8, L_9, /*hidden argument*/NULL);
goto IL_008a;
}
IL_0085:
{
goto IL_008a;
}
IL_008a:
{
return;
}
}
// System.Void ColorSlider::HSVChanged(System.Single,System.Single,System.Single)
extern "C" void ColorSlider_HSVChanged_m3304896453 (ColorSlider_t2729134766 * __this, float ___hue0, float ___saturation1, float ___value2, const MethodInfo* method)
{
int32_t V_0 = 0;
{
__this->set_listen_5((bool)0);
int32_t L_0 = __this->get_type_3();
V_0 = L_0;
int32_t L_1 = V_0;
switch (((int32_t)((int32_t)L_1-(int32_t)4)))
{
case 0:
{
goto IL_0027;
}
case 1:
{
goto IL_0038;
}
case 2:
{
goto IL_0049;
}
}
}
{
goto IL_005a;
}
IL_0027:
{
Slider_t297367283 * L_2 = __this->get_slider_4();
float L_3 = ___hue0;
NullCheck(L_2);
Slider_set_normalizedValue_m3093868078(L_2, L_3, /*hidden argument*/NULL);
goto IL_005f;
}
IL_0038:
{
Slider_t297367283 * L_4 = __this->get_slider_4();
float L_5 = ___saturation1;
NullCheck(L_4);
Slider_set_normalizedValue_m3093868078(L_4, L_5, /*hidden argument*/NULL);
goto IL_005f;
}
IL_0049:
{
Slider_t297367283 * L_6 = __this->get_slider_4();
float L_7 = ___value2;
NullCheck(L_6);
Slider_set_normalizedValue_m3093868078(L_6, L_7, /*hidden argument*/NULL);
goto IL_005f;
}
IL_005a:
{
goto IL_005f;
}
IL_005f:
{
return;
}
}
// System.Void ColorSlider::SliderChanged(System.Single)
extern "C" void ColorSlider_SliderChanged_m1758874829 (ColorSlider_t2729134766 * __this, float ___newValue0, const MethodInfo* method)
{
{
bool L_0 = __this->get_listen_5();
if (!L_0)
{
goto IL_002a;
}
}
{
Slider_t297367283 * L_1 = __this->get_slider_4();
NullCheck(L_1);
float L_2 = Slider_get_normalizedValue_m4164062921(L_1, /*hidden argument*/NULL);
___newValue0 = L_2;
ColorPicker_t3035206225 * L_3 = __this->get_hsvpicker_2();
int32_t L_4 = __this->get_type_3();
float L_5 = ___newValue0;
NullCheck(L_3);
ColorPicker_AssignColor_m579716850(L_3, L_4, L_5, /*hidden argument*/NULL);
}
IL_002a:
{
__this->set_listen_5((bool)1);
return;
}
}
// System.Void ColorSliderImage::.ctor()
extern "C" void ColorSliderImage__ctor_m1463450338 (ColorSliderImage_t376502149 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// UnityEngine.RectTransform ColorSliderImage::get_rectTransform()
extern "C" RectTransform_t3349966182 * ColorSliderImage_get_rectTransform_m3308471489 (ColorSliderImage_t376502149 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorSliderImage_get_rectTransform_m3308471489_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Transform_t3275118058 * L_0 = Component_get_transform_m2697483695(__this, /*hidden argument*/NULL);
return ((RectTransform_t3349966182 *)IsInstSealed(L_0, RectTransform_t3349966182_il2cpp_TypeInfo_var));
}
}
// System.Void ColorSliderImage::Awake()
extern "C" void ColorSliderImage_Awake_m834120629 (ColorSliderImage_t376502149 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorSliderImage_Awake_m834120629_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
RawImage_t2749640213 * L_0 = Component_GetComponent_TisRawImage_t2749640213_m1817787565(__this, /*hidden argument*/Component_GetComponent_TisRawImage_t2749640213_m1817787565_MethodInfo_var);
__this->set_image_5(L_0);
ColorSliderImage_RegenerateTexture_m1461909699(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ColorSliderImage::OnEnable()
extern "C" void ColorSliderImage_OnEnable_m1531418098 (ColorSliderImage_t376502149 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorSliderImage_OnEnable_m1531418098_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_0, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0053;
}
}
{
bool L_2 = Application_get_isPlaying_m4091950718(NULL /*static, unused*/, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0053;
}
}
{
ColorPicker_t3035206225 * L_3 = __this->get_picker_2();
NullCheck(L_3);
ColorChangedEvent_t2990895397 * L_4 = L_3->get_onValueChanged_9();
IntPtr_t L_5;
L_5.set_m_value_0((void*)(void*)ColorSliderImage_ColorChanged_m3679980033_MethodInfo_var);
UnityAction_1_t3386977826 * L_6 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_6, __this, L_5, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_4);
UnityEvent_1_AddListener_m903508446(L_4, L_6, /*hidden argument*/UnityEvent_1_AddListener_m903508446_MethodInfo_var);
ColorPicker_t3035206225 * L_7 = __this->get_picker_2();
NullCheck(L_7);
HSVChangedEvent_t1170297569 * L_8 = L_7->get_onHSVChanged_10();
IntPtr_t L_9;
L_9.set_m_value_0((void*)(void*)ColorSliderImage_HSVChanged_m1936863288_MethodInfo_var);
UnityAction_3_t235051313 * L_10 = (UnityAction_3_t235051313 *)il2cpp_codegen_object_new(UnityAction_3_t235051313_il2cpp_TypeInfo_var);
UnityAction_3__ctor_m3626891334(L_10, __this, L_9, /*hidden argument*/UnityAction_3__ctor_m3626891334_MethodInfo_var);
NullCheck(L_8);
UnityEvent_3_AddListener_m3608966849(L_8, L_10, /*hidden argument*/UnityEvent_3_AddListener_m3608966849_MethodInfo_var);
}
IL_0053:
{
return;
}
}
// System.Void ColorSliderImage::OnDisable()
extern "C" void ColorSliderImage_OnDisable_m2944825581 (ColorSliderImage_t376502149 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorSliderImage_OnDisable_m2944825581_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_0, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0049;
}
}
{
ColorPicker_t3035206225 * L_2 = __this->get_picker_2();
NullCheck(L_2);
ColorChangedEvent_t2990895397 * L_3 = L_2->get_onValueChanged_9();
IntPtr_t L_4;
L_4.set_m_value_0((void*)(void*)ColorSliderImage_ColorChanged_m3679980033_MethodInfo_var);
UnityAction_1_t3386977826 * L_5 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_5, __this, L_4, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_3);
UnityEvent_1_RemoveListener_m1138414664(L_3, L_5, /*hidden argument*/UnityEvent_1_RemoveListener_m1138414664_MethodInfo_var);
ColorPicker_t3035206225 * L_6 = __this->get_picker_2();
NullCheck(L_6);
HSVChangedEvent_t1170297569 * L_7 = L_6->get_onHSVChanged_10();
IntPtr_t L_8;
L_8.set_m_value_0((void*)(void*)ColorSliderImage_HSVChanged_m1936863288_MethodInfo_var);
UnityAction_3_t235051313 * L_9 = (UnityAction_3_t235051313 *)il2cpp_codegen_object_new(UnityAction_3_t235051313_il2cpp_TypeInfo_var);
UnityAction_3__ctor_m3626891334(L_9, __this, L_8, /*hidden argument*/UnityAction_3__ctor_m3626891334_MethodInfo_var);
NullCheck(L_7);
UnityEvent_3_RemoveListener_m2407167912(L_7, L_9, /*hidden argument*/UnityEvent_3_RemoveListener_m2407167912_MethodInfo_var);
}
IL_0049:
{
return;
}
}
// System.Void ColorSliderImage::OnDestroy()
extern "C" void ColorSliderImage_OnDestroy_m2738933995 (ColorSliderImage_t376502149 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorSliderImage_OnDestroy_m2738933995_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
RawImage_t2749640213 * L_0 = __this->get_image_5();
NullCheck(L_0);
Texture_t2243626319 * L_1 = RawImage_get_texture_m2258734143(L_0, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_2 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_1, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0026;
}
}
{
RawImage_t2749640213 * L_3 = __this->get_image_5();
NullCheck(L_3);
Texture_t2243626319 * L_4 = RawImage_get_texture_m2258734143(L_3, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
Object_DestroyImmediate_m95027445(NULL /*static, unused*/, L_4, /*hidden argument*/NULL);
}
IL_0026:
{
return;
}
}
// System.Void ColorSliderImage::ColorChanged(UnityEngine.Color)
extern "C" void ColorSliderImage_ColorChanged_m3679980033 (ColorSliderImage_t376502149 * __this, Color_t2020392075 ___newColor0, const MethodInfo* method)
{
int32_t V_0 = 0;
{
int32_t L_0 = __this->get_type_3();
V_0 = L_0;
int32_t L_1 = V_0;
switch (L_1)
{
case 0:
{
goto IL_002e;
}
case 1:
{
goto IL_002e;
}
case 2:
{
goto IL_002e;
}
case 3:
{
goto IL_0039;
}
case 4:
{
goto IL_0039;
}
case 5:
{
goto IL_002e;
}
case 6:
{
goto IL_002e;
}
}
}
{
goto IL_0039;
}
IL_002e:
{
ColorSliderImage_RegenerateTexture_m1461909699(__this, /*hidden argument*/NULL);
goto IL_003e;
}
IL_0039:
{
goto IL_003e;
}
IL_003e:
{
return;
}
}
// System.Void ColorSliderImage::HSVChanged(System.Single,System.Single,System.Single)
extern "C" void ColorSliderImage_HSVChanged_m1936863288 (ColorSliderImage_t376502149 * __this, float ___hue0, float ___saturation1, float ___value2, const MethodInfo* method)
{
int32_t V_0 = 0;
{
int32_t L_0 = __this->get_type_3();
V_0 = L_0;
int32_t L_1 = V_0;
switch (L_1)
{
case 0:
{
goto IL_002e;
}
case 1:
{
goto IL_002e;
}
case 2:
{
goto IL_002e;
}
case 3:
{
goto IL_0039;
}
case 4:
{
goto IL_0039;
}
case 5:
{
goto IL_002e;
}
case 6:
{
goto IL_002e;
}
}
}
{
goto IL_0039;
}
IL_002e:
{
ColorSliderImage_RegenerateTexture_m1461909699(__this, /*hidden argument*/NULL);
goto IL_003e;
}
IL_0039:
{
goto IL_003e;
}
IL_003e:
{
return;
}
}
// System.Void ColorSliderImage::RegenerateTexture()
extern "C" void ColorSliderImage_RegenerateTexture_m1461909699 (ColorSliderImage_t376502149 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ColorSliderImage_RegenerateTexture_m1461909699_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Color32_t874517518 V_0;
memset(&V_0, 0, sizeof(V_0));
float V_1 = 0.0f;
float V_2 = 0.0f;
float V_3 = 0.0f;
Texture2D_t3542995729 * V_4 = NULL;
Color32U5BU5D_t30278651* V_5 = NULL;
bool V_6 = false;
bool V_7 = false;
int32_t V_8 = 0;
int32_t V_9 = 0;
int32_t V_10 = 0;
uint8_t V_11 = 0x0;
uint8_t V_12 = 0x0;
uint8_t V_13 = 0x0;
uint8_t V_14 = 0x0;
int32_t V_15 = 0;
int32_t V_16 = 0;
int32_t V_17 = 0;
int32_t V_18 = 0;
Color_t2020392075 G_B3_0;
memset(&G_B3_0, 0, sizeof(G_B3_0));
float G_B6_0 = 0.0f;
float G_B9_0 = 0.0f;
float G_B12_0 = 0.0f;
int32_t G_B15_0 = 0;
int32_t G_B18_0 = 0;
Color32U5BU5D_t30278651* G_B32_0 = NULL;
Color32U5BU5D_t30278651* G_B31_0 = NULL;
int32_t G_B33_0 = 0;
Color32U5BU5D_t30278651* G_B33_1 = NULL;
Color32U5BU5D_t30278651* G_B39_0 = NULL;
Color32U5BU5D_t30278651* G_B38_0 = NULL;
int32_t G_B40_0 = 0;
Color32U5BU5D_t30278651* G_B40_1 = NULL;
Color32U5BU5D_t30278651* G_B46_0 = NULL;
Color32U5BU5D_t30278651* G_B45_0 = NULL;
int32_t G_B47_0 = 0;
Color32U5BU5D_t30278651* G_B47_1 = NULL;
Color32U5BU5D_t30278651* G_B53_0 = NULL;
Color32U5BU5D_t30278651* G_B52_0 = NULL;
int32_t G_B54_0 = 0;
Color32U5BU5D_t30278651* G_B54_1 = NULL;
Color32U5BU5D_t30278651* G_B60_0 = NULL;
Color32U5BU5D_t30278651* G_B59_0 = NULL;
int32_t G_B61_0 = 0;
Color32U5BU5D_t30278651* G_B61_1 = NULL;
Color32U5BU5D_t30278651* G_B67_0 = NULL;
Color32U5BU5D_t30278651* G_B66_0 = NULL;
int32_t G_B68_0 = 0;
Color32U5BU5D_t30278651* G_B68_1 = NULL;
Color32U5BU5D_t30278651* G_B74_0 = NULL;
Color32U5BU5D_t30278651* G_B73_0 = NULL;
int32_t G_B75_0 = 0;
Color32U5BU5D_t30278651* G_B75_1 = NULL;
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_0, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0021;
}
}
{
ColorPicker_t3035206225 * L_2 = __this->get_picker_2();
NullCheck(L_2);
Color_t2020392075 L_3 = ColorPicker_get_CurrentColor_m3166096170(L_2, /*hidden argument*/NULL);
G_B3_0 = L_3;
goto IL_0026;
}
IL_0021:
{
Color_t2020392075 L_4 = Color_get_black_m2650940523(NULL /*static, unused*/, /*hidden argument*/NULL);
G_B3_0 = L_4;
}
IL_0026:
{
Color32_t874517518 L_5 = Color32_op_Implicit_m624191464(NULL /*static, unused*/, G_B3_0, /*hidden argument*/NULL);
V_0 = L_5;
ColorPicker_t3035206225 * L_6 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_7 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_6, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_7)
{
goto IL_004d;
}
}
{
ColorPicker_t3035206225 * L_8 = __this->get_picker_2();
NullCheck(L_8);
float L_9 = ColorPicker_get_H_m3860865411(L_8, /*hidden argument*/NULL);
G_B6_0 = L_9;
goto IL_0052;
}
IL_004d:
{
G_B6_0 = (0.0f);
}
IL_0052:
{
V_1 = G_B6_0;
ColorPicker_t3035206225 * L_10 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_11 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_10, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_11)
{
goto IL_0074;
}
}
{
ColorPicker_t3035206225 * L_12 = __this->get_picker_2();
NullCheck(L_12);
float L_13 = ColorPicker_get_S_m2449498732(L_12, /*hidden argument*/NULL);
G_B9_0 = L_13;
goto IL_0079;
}
IL_0074:
{
G_B9_0 = (0.0f);
}
IL_0079:
{
V_2 = G_B9_0;
ColorPicker_t3035206225 * L_14 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_15 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_14, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_15)
{
goto IL_009b;
}
}
{
ColorPicker_t3035206225 * L_16 = __this->get_picker_2();
NullCheck(L_16);
float L_17 = ColorPicker_get_V_m265062405(L_16, /*hidden argument*/NULL);
G_B12_0 = L_17;
goto IL_00a0;
}
IL_009b:
{
G_B12_0 = (0.0f);
}
IL_00a0:
{
V_3 = G_B12_0;
int32_t L_18 = __this->get_direction_4();
if ((((int32_t)L_18) == ((int32_t)2)))
{
goto IL_00b8;
}
}
{
int32_t L_19 = __this->get_direction_4();
G_B15_0 = ((((int32_t)L_19) == ((int32_t)3))? 1 : 0);
goto IL_00b9;
}
IL_00b8:
{
G_B15_0 = 1;
}
IL_00b9:
{
V_6 = (bool)G_B15_0;
int32_t L_20 = __this->get_direction_4();
if ((((int32_t)L_20) == ((int32_t)3)))
{
goto IL_00d2;
}
}
{
int32_t L_21 = __this->get_direction_4();
G_B18_0 = ((((int32_t)L_21) == ((int32_t)1))? 1 : 0);
goto IL_00d3;
}
IL_00d2:
{
G_B18_0 = 1;
}
IL_00d3:
{
V_7 = (bool)G_B18_0;
int32_t L_22 = __this->get_type_3();
V_9 = L_22;
int32_t L_23 = V_9;
switch (L_23)
{
case 0:
{
goto IL_0105;
}
case 1:
{
goto IL_0105;
}
case 2:
{
goto IL_0105;
}
case 3:
{
goto IL_0105;
}
case 4:
{
goto IL_0111;
}
case 5:
{
goto IL_011d;
}
case 6:
{
goto IL_011d;
}
}
}
{
goto IL_0126;
}
IL_0105:
{
V_8 = ((int32_t)255);
goto IL_0131;
}
IL_0111:
{
V_8 = ((int32_t)360);
goto IL_0131;
}
IL_011d:
{
V_8 = ((int32_t)100);
goto IL_0131;
}
IL_0126:
{
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_24 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
NotImplementedException_t2785117854 * L_25 = (NotImplementedException_t2785117854 *)il2cpp_codegen_object_new(NotImplementedException_t2785117854_il2cpp_TypeInfo_var);
NotImplementedException__ctor_m1795163961(L_25, L_24, /*hidden argument*/NULL);
IL2CPP_RAISE_MANAGED_EXCEPTION(L_25);
}
IL_0131:
{
bool L_26 = V_6;
if (!L_26)
{
goto IL_0147;
}
}
{
int32_t L_27 = V_8;
Texture2D_t3542995729 * L_28 = (Texture2D_t3542995729 *)il2cpp_codegen_object_new(Texture2D_t3542995729_il2cpp_TypeInfo_var);
Texture2D__ctor_m3598323350(L_28, 1, L_27, /*hidden argument*/NULL);
V_4 = L_28;
goto IL_0151;
}
IL_0147:
{
int32_t L_29 = V_8;
Texture2D_t3542995729 * L_30 = (Texture2D_t3542995729 *)il2cpp_codegen_object_new(Texture2D_t3542995729_il2cpp_TypeInfo_var);
Texture2D__ctor_m3598323350(L_30, L_29, 1, /*hidden argument*/NULL);
V_4 = L_30;
}
IL_0151:
{
Texture2D_t3542995729 * L_31 = V_4;
NullCheck(L_31);
Object_set_hideFlags_m2204253440(L_31, ((int32_t)52), /*hidden argument*/NULL);
int32_t L_32 = V_8;
V_5 = ((Color32U5BU5D_t30278651*)SZArrayNew(Color32U5BU5D_t30278651_il2cpp_TypeInfo_var, (uint32_t)L_32));
int32_t L_33 = __this->get_type_3();
V_10 = L_33;
int32_t L_34 = V_10;
switch (L_34)
{
case 0:
{
goto IL_0193;
}
case 1:
{
goto IL_01eb;
}
case 2:
{
goto IL_0243;
}
case 3:
{
goto IL_029b;
}
case 4:
{
goto IL_02e9;
}
case 5:
{
goto IL_034a;
}
case 6:
{
goto IL_03a8;
}
}
}
{
goto IL_0406;
}
IL_0193:
{
V_11 = (uint8_t)0;
goto IL_01dd;
}
IL_019b:
{
Color32U5BU5D_t30278651* L_35 = V_5;
bool L_36 = V_7;
G_B31_0 = L_35;
if (!L_36)
{
G_B32_0 = L_35;
goto IL_01b0;
}
}
{
int32_t L_37 = V_8;
uint8_t L_38 = V_11;
G_B33_0 = ((int32_t)((int32_t)((int32_t)((int32_t)L_37-(int32_t)1))-(int32_t)L_38));
G_B33_1 = G_B31_0;
goto IL_01b2;
}
IL_01b0:
{
uint8_t L_39 = V_11;
G_B33_0 = ((int32_t)(L_39));
G_B33_1 = G_B32_0;
}
IL_01b2:
{
NullCheck(G_B33_1);
uint8_t L_40 = V_11;
uint8_t L_41 = (&V_0)->get_g_1();
uint8_t L_42 = (&V_0)->get_b_2();
Color32_t874517518 L_43;
memset(&L_43, 0, sizeof(L_43));
Color32__ctor_m1932627809(&L_43, L_40, L_41, L_42, (uint8_t)((int32_t)255), /*hidden argument*/NULL);
(*(Color32_t874517518 *)((G_B33_1)->GetAddressAt(static_cast<il2cpp_array_size_t>(G_B33_0)))) = L_43;
uint8_t L_44 = V_11;
V_11 = (uint8_t)(((int32_t)((uint8_t)((int32_t)((int32_t)L_44+(int32_t)1)))));
}
IL_01dd:
{
uint8_t L_45 = V_11;
int32_t L_46 = V_8;
if ((((int32_t)L_45) < ((int32_t)L_46)))
{
goto IL_019b;
}
}
{
goto IL_0411;
}
IL_01eb:
{
V_12 = (uint8_t)0;
goto IL_0235;
}
IL_01f3:
{
Color32U5BU5D_t30278651* L_47 = V_5;
bool L_48 = V_7;
G_B38_0 = L_47;
if (!L_48)
{
G_B39_0 = L_47;
goto IL_0208;
}
}
{
int32_t L_49 = V_8;
uint8_t L_50 = V_12;
G_B40_0 = ((int32_t)((int32_t)((int32_t)((int32_t)L_49-(int32_t)1))-(int32_t)L_50));
G_B40_1 = G_B38_0;
goto IL_020a;
}
IL_0208:
{
uint8_t L_51 = V_12;
G_B40_0 = ((int32_t)(L_51));
G_B40_1 = G_B39_0;
}
IL_020a:
{
NullCheck(G_B40_1);
uint8_t L_52 = (&V_0)->get_r_0();
uint8_t L_53 = V_12;
uint8_t L_54 = (&V_0)->get_b_2();
Color32_t874517518 L_55;
memset(&L_55, 0, sizeof(L_55));
Color32__ctor_m1932627809(&L_55, L_52, L_53, L_54, (uint8_t)((int32_t)255), /*hidden argument*/NULL);
(*(Color32_t874517518 *)((G_B40_1)->GetAddressAt(static_cast<il2cpp_array_size_t>(G_B40_0)))) = L_55;
uint8_t L_56 = V_12;
V_12 = (uint8_t)(((int32_t)((uint8_t)((int32_t)((int32_t)L_56+(int32_t)1)))));
}
IL_0235:
{
uint8_t L_57 = V_12;
int32_t L_58 = V_8;
if ((((int32_t)L_57) < ((int32_t)L_58)))
{
goto IL_01f3;
}
}
{
goto IL_0411;
}
IL_0243:
{
V_13 = (uint8_t)0;
goto IL_028d;
}
IL_024b:
{
Color32U5BU5D_t30278651* L_59 = V_5;
bool L_60 = V_7;
G_B45_0 = L_59;
if (!L_60)
{
G_B46_0 = L_59;
goto IL_0260;
}
}
{
int32_t L_61 = V_8;
uint8_t L_62 = V_13;
G_B47_0 = ((int32_t)((int32_t)((int32_t)((int32_t)L_61-(int32_t)1))-(int32_t)L_62));
G_B47_1 = G_B45_0;
goto IL_0262;
}
IL_0260:
{
uint8_t L_63 = V_13;
G_B47_0 = ((int32_t)(L_63));
G_B47_1 = G_B46_0;
}
IL_0262:
{
NullCheck(G_B47_1);
uint8_t L_64 = (&V_0)->get_r_0();
uint8_t L_65 = (&V_0)->get_g_1();
uint8_t L_66 = V_13;
Color32_t874517518 L_67;
memset(&L_67, 0, sizeof(L_67));
Color32__ctor_m1932627809(&L_67, L_64, L_65, L_66, (uint8_t)((int32_t)255), /*hidden argument*/NULL);
(*(Color32_t874517518 *)((G_B47_1)->GetAddressAt(static_cast<il2cpp_array_size_t>(G_B47_0)))) = L_67;
uint8_t L_68 = V_13;
V_13 = (uint8_t)(((int32_t)((uint8_t)((int32_t)((int32_t)L_68+(int32_t)1)))));
}
IL_028d:
{
uint8_t L_69 = V_13;
int32_t L_70 = V_8;
if ((((int32_t)L_69) < ((int32_t)L_70)))
{
goto IL_024b;
}
}
{
goto IL_0411;
}
IL_029b:
{
V_14 = (uint8_t)0;
goto IL_02db;
}
IL_02a3:
{
Color32U5BU5D_t30278651* L_71 = V_5;
bool L_72 = V_7;
G_B52_0 = L_71;
if (!L_72)
{
G_B53_0 = L_71;
goto IL_02b8;
}
}
{
int32_t L_73 = V_8;
uint8_t L_74 = V_14;
G_B54_0 = ((int32_t)((int32_t)((int32_t)((int32_t)L_73-(int32_t)1))-(int32_t)L_74));
G_B54_1 = G_B52_0;
goto IL_02ba;
}
IL_02b8:
{
uint8_t L_75 = V_14;
G_B54_0 = ((int32_t)(L_75));
G_B54_1 = G_B53_0;
}
IL_02ba:
{
NullCheck(G_B54_1);
uint8_t L_76 = V_14;
uint8_t L_77 = V_14;
uint8_t L_78 = V_14;
Color32_t874517518 L_79;
memset(&L_79, 0, sizeof(L_79));
Color32__ctor_m1932627809(&L_79, L_76, L_77, L_78, (uint8_t)((int32_t)255), /*hidden argument*/NULL);
(*(Color32_t874517518 *)((G_B54_1)->GetAddressAt(static_cast<il2cpp_array_size_t>(G_B54_0)))) = L_79;
uint8_t L_80 = V_14;
V_14 = (uint8_t)(((int32_t)((uint8_t)((int32_t)((int32_t)L_80+(int32_t)1)))));
}
IL_02db:
{
uint8_t L_81 = V_14;
int32_t L_82 = V_8;
if ((((int32_t)L_81) < ((int32_t)L_82)))
{
goto IL_02a3;
}
}
{
goto IL_0411;
}
IL_02e9:
{
V_15 = 0;
goto IL_033c;
}
IL_02f1:
{
Color32U5BU5D_t30278651* L_83 = V_5;
bool L_84 = V_7;
G_B59_0 = L_83;
if (!L_84)
{
G_B60_0 = L_83;
goto IL_0306;
}
}
{
int32_t L_85 = V_8;
int32_t L_86 = V_15;
G_B61_0 = ((int32_t)((int32_t)((int32_t)((int32_t)L_85-(int32_t)1))-(int32_t)L_86));
G_B61_1 = G_B59_0;
goto IL_0308;
}
IL_0306:
{
int32_t L_87 = V_15;
G_B61_0 = L_87;
G_B61_1 = G_B60_0;
}
IL_0308:
{
NullCheck(G_B61_1);
int32_t L_88 = V_15;
Color_t2020392075 L_89 = HSVUtil_ConvertHsvToRgb_m2339284600(NULL /*static, unused*/, (((double)((double)L_88))), (1.0), (1.0), (1.0f), /*hidden argument*/NULL);
Color32_t874517518 L_90 = Color32_op_Implicit_m624191464(NULL /*static, unused*/, L_89, /*hidden argument*/NULL);
(*(Color32_t874517518 *)((G_B61_1)->GetAddressAt(static_cast<il2cpp_array_size_t>(G_B61_0)))) = L_90;
int32_t L_91 = V_15;
V_15 = ((int32_t)((int32_t)L_91+(int32_t)1));
}
IL_033c:
{
int32_t L_92 = V_15;
int32_t L_93 = V_8;
if ((((int32_t)L_92) < ((int32_t)L_93)))
{
goto IL_02f1;
}
}
{
goto IL_0411;
}
IL_034a:
{
V_16 = 0;
goto IL_039a;
}
IL_0352:
{
Color32U5BU5D_t30278651* L_94 = V_5;
bool L_95 = V_7;
G_B66_0 = L_94;
if (!L_95)
{
G_B67_0 = L_94;
goto IL_0367;
}
}
{
int32_t L_96 = V_8;
int32_t L_97 = V_16;
G_B68_0 = ((int32_t)((int32_t)((int32_t)((int32_t)L_96-(int32_t)1))-(int32_t)L_97));
G_B68_1 = G_B66_0;
goto IL_0369;
}
IL_0367:
{
int32_t L_98 = V_16;
G_B68_0 = L_98;
G_B68_1 = G_B67_0;
}
IL_0369:
{
NullCheck(G_B68_1);
float L_99 = V_1;
int32_t L_100 = V_16;
int32_t L_101 = V_8;
float L_102 = V_3;
Color_t2020392075 L_103 = HSVUtil_ConvertHsvToRgb_m2339284600(NULL /*static, unused*/, (((double)((double)((float)((float)L_99*(float)(360.0f)))))), (((double)((double)((float)((float)(((float)((float)L_100)))/(float)(((float)((float)L_101)))))))), (((double)((double)L_102))), (1.0f), /*hidden argument*/NULL);
Color32_t874517518 L_104 = Color32_op_Implicit_m624191464(NULL /*static, unused*/, L_103, /*hidden argument*/NULL);
(*(Color32_t874517518 *)((G_B68_1)->GetAddressAt(static_cast<il2cpp_array_size_t>(G_B68_0)))) = L_104;
int32_t L_105 = V_16;
V_16 = ((int32_t)((int32_t)L_105+(int32_t)1));
}
IL_039a:
{
int32_t L_106 = V_16;
int32_t L_107 = V_8;
if ((((int32_t)L_106) < ((int32_t)L_107)))
{
goto IL_0352;
}
}
{
goto IL_0411;
}
IL_03a8:
{
V_17 = 0;
goto IL_03f8;
}
IL_03b0:
{
Color32U5BU5D_t30278651* L_108 = V_5;
bool L_109 = V_7;
G_B73_0 = L_108;
if (!L_109)
{
G_B74_0 = L_108;
goto IL_03c5;
}
}
{
int32_t L_110 = V_8;
int32_t L_111 = V_17;
G_B75_0 = ((int32_t)((int32_t)((int32_t)((int32_t)L_110-(int32_t)1))-(int32_t)L_111));
G_B75_1 = G_B73_0;
goto IL_03c7;
}
IL_03c5:
{
int32_t L_112 = V_17;
G_B75_0 = L_112;
G_B75_1 = G_B74_0;
}
IL_03c7:
{
NullCheck(G_B75_1);
float L_113 = V_1;
float L_114 = V_2;
int32_t L_115 = V_17;
int32_t L_116 = V_8;
Color_t2020392075 L_117 = HSVUtil_ConvertHsvToRgb_m2339284600(NULL /*static, unused*/, (((double)((double)((float)((float)L_113*(float)(360.0f)))))), (((double)((double)L_114))), (((double)((double)((float)((float)(((float)((float)L_115)))/(float)(((float)((float)L_116)))))))), (1.0f), /*hidden argument*/NULL);
Color32_t874517518 L_118 = Color32_op_Implicit_m624191464(NULL /*static, unused*/, L_117, /*hidden argument*/NULL);
(*(Color32_t874517518 *)((G_B75_1)->GetAddressAt(static_cast<il2cpp_array_size_t>(G_B75_0)))) = L_118;
int32_t L_119 = V_17;
V_17 = ((int32_t)((int32_t)L_119+(int32_t)1));
}
IL_03f8:
{
int32_t L_120 = V_17;
int32_t L_121 = V_8;
if ((((int32_t)L_120) < ((int32_t)L_121)))
{
goto IL_03b0;
}
}
{
goto IL_0411;
}
IL_0406:
{
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_122 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
NotImplementedException_t2785117854 * L_123 = (NotImplementedException_t2785117854 *)il2cpp_codegen_object_new(NotImplementedException_t2785117854_il2cpp_TypeInfo_var);
NotImplementedException__ctor_m1795163961(L_123, L_122, /*hidden argument*/NULL);
IL2CPP_RAISE_MANAGED_EXCEPTION(L_123);
}
IL_0411:
{
Texture2D_t3542995729 * L_124 = V_4;
Color32U5BU5D_t30278651* L_125 = V_5;
NullCheck(L_124);
Texture2D_SetPixels32_m2480505405(L_124, L_125, /*hidden argument*/NULL);
Texture2D_t3542995729 * L_126 = V_4;
NullCheck(L_126);
Texture2D_Apply_m3543341930(L_126, /*hidden argument*/NULL);
RawImage_t2749640213 * L_127 = __this->get_image_5();
NullCheck(L_127);
Texture_t2243626319 * L_128 = RawImage_get_texture_m2258734143(L_127, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_129 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_128, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_129)
{
goto IL_0447;
}
}
{
RawImage_t2749640213 * L_130 = __this->get_image_5();
NullCheck(L_130);
Texture_t2243626319 * L_131 = RawImage_get_texture_m2258734143(L_130, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
Object_DestroyImmediate_m95027445(NULL /*static, unused*/, L_131, /*hidden argument*/NULL);
}
IL_0447:
{
RawImage_t2749640213 * L_132 = __this->get_image_5();
Texture2D_t3542995729 * L_133 = V_4;
NullCheck(L_132);
RawImage_set_texture_m2400157626(L_132, L_133, /*hidden argument*/NULL);
int32_t L_134 = __this->get_direction_4();
V_18 = L_134;
int32_t L_135 = V_18;
switch (L_135)
{
case 0:
{
goto IL_04a1;
}
case 1:
{
goto IL_04a1;
}
case 2:
{
goto IL_0478;
}
case 3:
{
goto IL_0478;
}
}
}
{
goto IL_04ca;
}
IL_0478:
{
RawImage_t2749640213 * L_136 = __this->get_image_5();
Rect_t3681755626 L_137;
memset(&L_137, 0, sizeof(L_137));
Rect__ctor_m1220545469(&L_137, (0.0f), (0.0f), (2.0f), (1.0f), /*hidden argument*/NULL);
NullCheck(L_136);
RawImage_set_uvRect_m3807597783(L_136, L_137, /*hidden argument*/NULL);
goto IL_04cf;
}
IL_04a1:
{
RawImage_t2749640213 * L_138 = __this->get_image_5();
Rect_t3681755626 L_139;
memset(&L_139, 0, sizeof(L_139));
Rect__ctor_m1220545469(&L_139, (0.0f), (0.0f), (1.0f), (2.0f), /*hidden argument*/NULL);
NullCheck(L_138);
RawImage_set_uvRect_m3807597783(L_138, L_139, /*hidden argument*/NULL);
goto IL_04cf;
}
IL_04ca:
{
goto IL_04cf;
}
IL_04cf:
{
return;
}
}
// System.Void destructor::.ctor()
extern "C" void destructor__ctor_m1866859374 (destructor_t1745712409 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void destructor::Start()
extern "C" void destructor_Start_m3245637350 (destructor_t1745712409 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void destructor::Update()
extern "C" void destructor_Update_m1495026301 (destructor_t1745712409 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (destructor_Update_m1495026301_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
float L_0 = __this->get_timeElapsed_2();
float L_1 = __this->get_timeForDest_3();
if ((!(((float)L_0) > ((float)L_1))))
{
goto IL_0021;
}
}
{
GameObject_t1756533147 * L_2 = Component_get_gameObject_m3105766835(__this, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
Object_Destroy_m4145850038(NULL /*static, unused*/, L_2, /*hidden argument*/NULL);
goto IL_0033;
}
IL_0021:
{
float L_3 = __this->get_timeElapsed_2();
float L_4 = Time_get_deltaTime_m2233168104(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_timeElapsed_2(((float)((float)L_3+(float)L_4)));
}
IL_0033:
{
return;
}
}
// System.Void disappearOnFall::.ctor()
extern "C" void disappearOnFall__ctor_m2492825728 (disappearOnFall_t3898622429 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void disappearOnFall::Start()
extern "C" void disappearOnFall_Start_m3841120952 (disappearOnFall_t3898622429 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void disappearOnFall::Update()
extern "C" void disappearOnFall_Update_m2270025117 (disappearOnFall_t3898622429 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void disappearOnFall::OnCollisionEnter(UnityEngine.Collision)
extern "C" void disappearOnFall_OnCollisionEnter_m3509228570 (disappearOnFall_t3898622429 * __this, Collision_t2876846408 * ___collision0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (disappearOnFall_OnCollisionEnter_m3509228570_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Collision_t2876846408 * L_0 = ___collision0;
NullCheck(L_0);
Transform_t3275118058 * L_1 = Collision_get_transform_m4132935520(L_0, /*hidden argument*/NULL);
NullCheck(L_1);
bool L_2 = Component_CompareTag_m3443292365(L_1, _stringLiteral3318161334, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0039;
}
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral1671082892, /*hidden argument*/NULL);
Transform_t3275118058 * L_3 = Component_get_transform_m2697483695(__this, /*hidden argument*/NULL);
NullCheck(L_3);
Transform_t3275118058 * L_4 = Transform_get_parent_m147407266(L_3, /*hidden argument*/NULL);
NullCheck(L_4);
GameObject_t1756533147 * L_5 = Component_get_gameObject_m3105766835(L_4, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
Object_Destroy_m4279412553(NULL /*static, unused*/, L_5, (1.0f), /*hidden argument*/NULL);
}
IL_0039:
{
return;
}
}
// System.Void HexColorField::.ctor()
extern "C" void HexColorField__ctor_m2851903553 (HexColorField_t4192118964 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void HexColorField::Awake()
extern "C" void HexColorField_Awake_m306535424 (HexColorField_t4192118964 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (HexColorField_Awake_m306535424_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
InputField_t1631627530 * L_0 = Component_GetComponent_TisInputField_t1631627530_m1177654614(__this, /*hidden argument*/Component_GetComponent_TisInputField_t1631627530_m1177654614_MethodInfo_var);
__this->set_hexInputField_4(L_0);
InputField_t1631627530 * L_1 = __this->get_hexInputField_4();
NullCheck(L_1);
SubmitEvent_t907918422 * L_2 = InputField_get_onEndEdit_m1618380883(L_1, /*hidden argument*/NULL);
IntPtr_t L_3;
L_3.set_m_value_0((void*)(void*)HexColorField_UpdateColor_m4189307031_MethodInfo_var);
UnityAction_1_t3395805984 * L_4 = (UnityAction_1_t3395805984 *)il2cpp_codegen_object_new(UnityAction_1_t3395805984_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m2212746417(L_4, __this, L_3, /*hidden argument*/UnityAction_1__ctor_m2212746417_MethodInfo_var);
NullCheck(L_2);
UnityEvent_1_AddListener_m2046140989(L_2, L_4, /*hidden argument*/UnityEvent_1_AddListener_m2046140989_MethodInfo_var);
ColorPicker_t3035206225 * L_5 = __this->get_hsvpicker_2();
NullCheck(L_5);
ColorChangedEvent_t2990895397 * L_6 = L_5->get_onValueChanged_9();
IntPtr_t L_7;
L_7.set_m_value_0((void*)(void*)HexColorField_UpdateHex_m1796725051_MethodInfo_var);
UnityAction_1_t3386977826 * L_8 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_8, __this, L_7, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_6);
UnityEvent_1_AddListener_m903508446(L_6, L_8, /*hidden argument*/UnityEvent_1_AddListener_m903508446_MethodInfo_var);
return;
}
}
// System.Void HexColorField::OnDestroy()
extern "C" void HexColorField_OnDestroy_m4113204650 (HexColorField_t4192118964 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (HexColorField_OnDestroy_m4113204650_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
InputField_t1631627530 * L_0 = __this->get_hexInputField_4();
NullCheck(L_0);
OnChangeEvent_t2863344003 * L_1 = InputField_get_onValueChanged_m2097858642(L_0, /*hidden argument*/NULL);
IntPtr_t L_2;
L_2.set_m_value_0((void*)(void*)HexColorField_UpdateColor_m4189307031_MethodInfo_var);
UnityAction_1_t3395805984 * L_3 = (UnityAction_1_t3395805984 *)il2cpp_codegen_object_new(UnityAction_1_t3395805984_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m2212746417(L_3, __this, L_2, /*hidden argument*/UnityAction_1__ctor_m2212746417_MethodInfo_var);
NullCheck(L_1);
UnityEvent_1_RemoveListener_m2236604102(L_1, L_3, /*hidden argument*/UnityEvent_1_RemoveListener_m2236604102_MethodInfo_var);
ColorPicker_t3035206225 * L_4 = __this->get_hsvpicker_2();
NullCheck(L_4);
ColorChangedEvent_t2990895397 * L_5 = L_4->get_onValueChanged_9();
IntPtr_t L_6;
L_6.set_m_value_0((void*)(void*)HexColorField_UpdateHex_m1796725051_MethodInfo_var);
UnityAction_1_t3386977826 * L_7 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_7, __this, L_6, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_5);
UnityEvent_1_RemoveListener_m1138414664(L_5, L_7, /*hidden argument*/UnityEvent_1_RemoveListener_m1138414664_MethodInfo_var);
return;
}
}
// System.Void HexColorField::UpdateHex(UnityEngine.Color)
extern "C" void HexColorField_UpdateHex_m1796725051 (HexColorField_t4192118964 * __this, Color_t2020392075 ___newColor0, const MethodInfo* method)
{
{
InputField_t1631627530 * L_0 = __this->get_hexInputField_4();
Color_t2020392075 L_1 = ___newColor0;
Color32_t874517518 L_2 = Color32_op_Implicit_m624191464(NULL /*static, unused*/, L_1, /*hidden argument*/NULL);
String_t* L_3 = HexColorField_ColorToHex_m410116926(__this, L_2, /*hidden argument*/NULL);
NullCheck(L_0);
InputField_set_text_m114077119(L_0, L_3, /*hidden argument*/NULL);
return;
}
}
// System.Void HexColorField::UpdateColor(System.String)
extern "C" void HexColorField_UpdateColor_m4189307031 (HexColorField_t4192118964 * __this, String_t* ___newHex0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (HexColorField_UpdateColor_m4189307031_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Color32_t874517518 V_0;
memset(&V_0, 0, sizeof(V_0));
{
String_t* L_0 = ___newHex0;
bool L_1 = HexColorField_HexToColor_m3970770477(NULL /*static, unused*/, L_0, (&V_0), /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0023;
}
}
{
ColorPicker_t3035206225 * L_2 = __this->get_hsvpicker_2();
Color32_t874517518 L_3 = V_0;
Color_t2020392075 L_4 = Color32_op_Implicit_m889975790(NULL /*static, unused*/, L_3, /*hidden argument*/NULL);
NullCheck(L_2);
ColorPicker_set_CurrentColor_m2125228471(L_2, L_4, /*hidden argument*/NULL);
goto IL_002d;
}
IL_0023:
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral3567086134, /*hidden argument*/NULL);
}
IL_002d:
{
return;
}
}
// System.String HexColorField::ColorToHex(UnityEngine.Color32)
extern "C" String_t* HexColorField_ColorToHex_m410116926 (HexColorField_t4192118964 * __this, Color32_t874517518 ___color0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (HexColorField_ColorToHex_m410116926_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
bool L_0 = __this->get_displayAlpha_3();
if (!L_0)
{
goto IL_0058;
}
}
{
ObjectU5BU5D_t3614634134* L_1 = ((ObjectU5BU5D_t3614634134*)SZArrayNew(ObjectU5BU5D_t3614634134_il2cpp_TypeInfo_var, (uint32_t)4));
uint8_t L_2 = (&___color0)->get_r_0();
uint8_t L_3 = L_2;
Il2CppObject * L_4 = Box(Byte_t3683104436_il2cpp_TypeInfo_var, &L_3);
NullCheck(L_1);
ArrayElementTypeCheck (L_1, L_4);
(L_1)->SetAt(static_cast<il2cpp_array_size_t>(0), (Il2CppObject *)L_4);
ObjectU5BU5D_t3614634134* L_5 = L_1;
uint8_t L_6 = (&___color0)->get_g_1();
uint8_t L_7 = L_6;
Il2CppObject * L_8 = Box(Byte_t3683104436_il2cpp_TypeInfo_var, &L_7);
NullCheck(L_5);
ArrayElementTypeCheck (L_5, L_8);
(L_5)->SetAt(static_cast<il2cpp_array_size_t>(1), (Il2CppObject *)L_8);
ObjectU5BU5D_t3614634134* L_9 = L_5;
uint8_t L_10 = (&___color0)->get_b_2();
uint8_t L_11 = L_10;
Il2CppObject * L_12 = Box(Byte_t3683104436_il2cpp_TypeInfo_var, &L_11);
NullCheck(L_9);
ArrayElementTypeCheck (L_9, L_12);
(L_9)->SetAt(static_cast<il2cpp_array_size_t>(2), (Il2CppObject *)L_12);
ObjectU5BU5D_t3614634134* L_13 = L_9;
uint8_t L_14 = (&___color0)->get_a_3();
uint8_t L_15 = L_14;
Il2CppObject * L_16 = Box(Byte_t3683104436_il2cpp_TypeInfo_var, &L_15);
NullCheck(L_13);
ArrayElementTypeCheck (L_13, L_16);
(L_13)->SetAt(static_cast<il2cpp_array_size_t>(3), (Il2CppObject *)L_16);
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_17 = String_Format_m1263743648(NULL /*static, unused*/, _stringLiteral3554759231, L_13, /*hidden argument*/NULL);
return L_17;
}
IL_0058:
{
uint8_t L_18 = (&___color0)->get_r_0();
uint8_t L_19 = L_18;
Il2CppObject * L_20 = Box(Byte_t3683104436_il2cpp_TypeInfo_var, &L_19);
uint8_t L_21 = (&___color0)->get_g_1();
uint8_t L_22 = L_21;
Il2CppObject * L_23 = Box(Byte_t3683104436_il2cpp_TypeInfo_var, &L_22);
uint8_t L_24 = (&___color0)->get_b_2();
uint8_t L_25 = L_24;
Il2CppObject * L_26 = Box(Byte_t3683104436_il2cpp_TypeInfo_var, &L_25);
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_27 = String_Format_m4262916296(NULL /*static, unused*/, _stringLiteral2608826782, L_20, L_23, L_26, /*hidden argument*/NULL);
return L_27;
}
}
// System.Boolean HexColorField::HexToColor(System.String,UnityEngine.Color32&)
extern "C" bool HexColorField_HexToColor_m3970770477 (Il2CppObject * __this /* static, unused */, String_t* ___hex0, Color32_t874517518 * ___color1, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (HexColorField_HexToColor_m3970770477_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
int32_t V_0 = 0;
int32_t G_B4_0 = 0;
{
String_t* L_0 = ___hex0;
IL2CPP_RUNTIME_CLASS_INIT(Regex_t1803876613_il2cpp_TypeInfo_var);
bool L_1 = Regex_IsMatch_m2218618503(NULL /*static, unused*/, L_0, _stringLiteral4264548006, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0255;
}
}
{
String_t* L_2 = ___hex0;
NullCheck(L_2);
bool L_3 = String_StartsWith_m1841920685(L_2, _stringLiteral372029311, /*hidden argument*/NULL);
if (!L_3)
{
goto IL_0026;
}
}
{
G_B4_0 = 1;
goto IL_0027;
}
IL_0026:
{
G_B4_0 = 0;
}
IL_0027:
{
V_0 = G_B4_0;
String_t* L_4 = ___hex0;
NullCheck(L_4);
int32_t L_5 = String_get_Length_m1606060069(L_4, /*hidden argument*/NULL);
int32_t L_6 = V_0;
if ((!(((uint32_t)L_5) == ((uint32_t)((int32_t)((int32_t)L_6+(int32_t)8))))))
{
goto IL_008f;
}
}
{
Color32_t874517518 * L_7 = ___color1;
String_t* L_8 = ___hex0;
int32_t L_9 = V_0;
NullCheck(L_8);
String_t* L_10 = String_Substring_m12482732(L_8, L_9, 2, /*hidden argument*/NULL);
uint8_t L_11 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_10, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_12 = ___hex0;
int32_t L_13 = V_0;
NullCheck(L_12);
String_t* L_14 = String_Substring_m12482732(L_12, ((int32_t)((int32_t)L_13+(int32_t)2)), 2, /*hidden argument*/NULL);
uint8_t L_15 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_14, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_16 = ___hex0;
int32_t L_17 = V_0;
NullCheck(L_16);
String_t* L_18 = String_Substring_m12482732(L_16, ((int32_t)((int32_t)L_17+(int32_t)4)), 2, /*hidden argument*/NULL);
uint8_t L_19 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_18, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_20 = ___hex0;
int32_t L_21 = V_0;
NullCheck(L_20);
String_t* L_22 = String_Substring_m12482732(L_20, ((int32_t)((int32_t)L_21+(int32_t)6)), 2, /*hidden argument*/NULL);
uint8_t L_23 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_22, ((int32_t)512), /*hidden argument*/NULL);
Color32__ctor_m1932627809(L_7, L_11, L_15, L_19, L_23, /*hidden argument*/NULL);
goto IL_0253;
}
IL_008f:
{
String_t* L_24 = ___hex0;
NullCheck(L_24);
int32_t L_25 = String_get_Length_m1606060069(L_24, /*hidden argument*/NULL);
int32_t L_26 = V_0;
if ((!(((uint32_t)L_25) == ((uint32_t)((int32_t)((int32_t)L_26+(int32_t)6))))))
{
goto IL_00e7;
}
}
{
Color32_t874517518 * L_27 = ___color1;
String_t* L_28 = ___hex0;
int32_t L_29 = V_0;
NullCheck(L_28);
String_t* L_30 = String_Substring_m12482732(L_28, L_29, 2, /*hidden argument*/NULL);
uint8_t L_31 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_30, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_32 = ___hex0;
int32_t L_33 = V_0;
NullCheck(L_32);
String_t* L_34 = String_Substring_m12482732(L_32, ((int32_t)((int32_t)L_33+(int32_t)2)), 2, /*hidden argument*/NULL);
uint8_t L_35 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_34, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_36 = ___hex0;
int32_t L_37 = V_0;
NullCheck(L_36);
String_t* L_38 = String_Substring_m12482732(L_36, ((int32_t)((int32_t)L_37+(int32_t)4)), 2, /*hidden argument*/NULL);
uint8_t L_39 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_38, ((int32_t)512), /*hidden argument*/NULL);
Color32__ctor_m1932627809(L_27, L_31, L_35, L_39, (uint8_t)((int32_t)255), /*hidden argument*/NULL);
goto IL_0253;
}
IL_00e7:
{
String_t* L_40 = ___hex0;
NullCheck(L_40);
int32_t L_41 = String_get_Length_m1606060069(L_40, /*hidden argument*/NULL);
int32_t L_42 = V_0;
if ((!(((uint32_t)L_41) == ((uint32_t)((int32_t)((int32_t)L_42+(int32_t)4))))))
{
goto IL_01bc;
}
}
{
Color32_t874517518 * L_43 = ___color1;
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_44 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
String_t* L_45 = ___hex0;
int32_t L_46 = V_0;
NullCheck(L_45);
Il2CppChar L_47 = String_get_Chars_m4230566705(L_45, L_46, /*hidden argument*/NULL);
Il2CppChar L_48 = L_47;
Il2CppObject * L_49 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_48);
String_t* L_50 = ___hex0;
int32_t L_51 = V_0;
NullCheck(L_50);
Il2CppChar L_52 = String_get_Chars_m4230566705(L_50, L_51, /*hidden argument*/NULL);
Il2CppChar L_53 = L_52;
Il2CppObject * L_54 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_53);
String_t* L_55 = String_Concat_m2000667605(NULL /*static, unused*/, L_44, L_49, L_54, /*hidden argument*/NULL);
uint8_t L_56 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_55, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_57 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
String_t* L_58 = ___hex0;
int32_t L_59 = V_0;
NullCheck(L_58);
Il2CppChar L_60 = String_get_Chars_m4230566705(L_58, ((int32_t)((int32_t)L_59+(int32_t)1)), /*hidden argument*/NULL);
Il2CppChar L_61 = L_60;
Il2CppObject * L_62 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_61);
String_t* L_63 = ___hex0;
int32_t L_64 = V_0;
NullCheck(L_63);
Il2CppChar L_65 = String_get_Chars_m4230566705(L_63, ((int32_t)((int32_t)L_64+(int32_t)1)), /*hidden argument*/NULL);
Il2CppChar L_66 = L_65;
Il2CppObject * L_67 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_66);
String_t* L_68 = String_Concat_m2000667605(NULL /*static, unused*/, L_57, L_62, L_67, /*hidden argument*/NULL);
uint8_t L_69 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_68, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_70 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
String_t* L_71 = ___hex0;
int32_t L_72 = V_0;
NullCheck(L_71);
Il2CppChar L_73 = String_get_Chars_m4230566705(L_71, ((int32_t)((int32_t)L_72+(int32_t)2)), /*hidden argument*/NULL);
Il2CppChar L_74 = L_73;
Il2CppObject * L_75 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_74);
String_t* L_76 = ___hex0;
int32_t L_77 = V_0;
NullCheck(L_76);
Il2CppChar L_78 = String_get_Chars_m4230566705(L_76, ((int32_t)((int32_t)L_77+(int32_t)2)), /*hidden argument*/NULL);
Il2CppChar L_79 = L_78;
Il2CppObject * L_80 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_79);
String_t* L_81 = String_Concat_m2000667605(NULL /*static, unused*/, L_70, L_75, L_80, /*hidden argument*/NULL);
uint8_t L_82 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_81, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_83 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
String_t* L_84 = ___hex0;
int32_t L_85 = V_0;
NullCheck(L_84);
Il2CppChar L_86 = String_get_Chars_m4230566705(L_84, ((int32_t)((int32_t)L_85+(int32_t)3)), /*hidden argument*/NULL);
Il2CppChar L_87 = L_86;
Il2CppObject * L_88 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_87);
String_t* L_89 = ___hex0;
int32_t L_90 = V_0;
NullCheck(L_89);
Il2CppChar L_91 = String_get_Chars_m4230566705(L_89, ((int32_t)((int32_t)L_90+(int32_t)3)), /*hidden argument*/NULL);
Il2CppChar L_92 = L_91;
Il2CppObject * L_93 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_92);
String_t* L_94 = String_Concat_m2000667605(NULL /*static, unused*/, L_83, L_88, L_93, /*hidden argument*/NULL);
uint8_t L_95 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_94, ((int32_t)512), /*hidden argument*/NULL);
Color32__ctor_m1932627809(L_43, L_56, L_69, L_82, L_95, /*hidden argument*/NULL);
goto IL_0253;
}
IL_01bc:
{
Color32_t874517518 * L_96 = ___color1;
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_97 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
String_t* L_98 = ___hex0;
int32_t L_99 = V_0;
NullCheck(L_98);
Il2CppChar L_100 = String_get_Chars_m4230566705(L_98, L_99, /*hidden argument*/NULL);
Il2CppChar L_101 = L_100;
Il2CppObject * L_102 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_101);
String_t* L_103 = ___hex0;
int32_t L_104 = V_0;
NullCheck(L_103);
Il2CppChar L_105 = String_get_Chars_m4230566705(L_103, L_104, /*hidden argument*/NULL);
Il2CppChar L_106 = L_105;
Il2CppObject * L_107 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_106);
String_t* L_108 = String_Concat_m2000667605(NULL /*static, unused*/, L_97, L_102, L_107, /*hidden argument*/NULL);
uint8_t L_109 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_108, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_110 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
String_t* L_111 = ___hex0;
int32_t L_112 = V_0;
NullCheck(L_111);
Il2CppChar L_113 = String_get_Chars_m4230566705(L_111, ((int32_t)((int32_t)L_112+(int32_t)1)), /*hidden argument*/NULL);
Il2CppChar L_114 = L_113;
Il2CppObject * L_115 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_114);
String_t* L_116 = ___hex0;
int32_t L_117 = V_0;
NullCheck(L_116);
Il2CppChar L_118 = String_get_Chars_m4230566705(L_116, ((int32_t)((int32_t)L_117+(int32_t)1)), /*hidden argument*/NULL);
Il2CppChar L_119 = L_118;
Il2CppObject * L_120 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_119);
String_t* L_121 = String_Concat_m2000667605(NULL /*static, unused*/, L_110, L_115, L_120, /*hidden argument*/NULL);
uint8_t L_122 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_121, ((int32_t)512), /*hidden argument*/NULL);
String_t* L_123 = ((String_t_StaticFields*)String_t_il2cpp_TypeInfo_var->static_fields)->get_Empty_2();
String_t* L_124 = ___hex0;
int32_t L_125 = V_0;
NullCheck(L_124);
Il2CppChar L_126 = String_get_Chars_m4230566705(L_124, ((int32_t)((int32_t)L_125+(int32_t)2)), /*hidden argument*/NULL);
Il2CppChar L_127 = L_126;
Il2CppObject * L_128 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_127);
String_t* L_129 = ___hex0;
int32_t L_130 = V_0;
NullCheck(L_129);
Il2CppChar L_131 = String_get_Chars_m4230566705(L_129, ((int32_t)((int32_t)L_130+(int32_t)2)), /*hidden argument*/NULL);
Il2CppChar L_132 = L_131;
Il2CppObject * L_133 = Box(Char_t3454481338_il2cpp_TypeInfo_var, &L_132);
String_t* L_134 = String_Concat_m2000667605(NULL /*static, unused*/, L_123, L_128, L_133, /*hidden argument*/NULL);
uint8_t L_135 = Byte_Parse_m4137294155(NULL /*static, unused*/, L_134, ((int32_t)512), /*hidden argument*/NULL);
Color32__ctor_m1932627809(L_96, L_109, L_122, L_135, (uint8_t)((int32_t)255), /*hidden argument*/NULL);
}
IL_0253:
{
return (bool)1;
}
IL_0255:
{
Color32_t874517518 * L_136 = ___color1;
Initobj (Color32_t874517518_il2cpp_TypeInfo_var, L_136);
return (bool)0;
}
}
// System.Void HSVChangedEvent::.ctor()
extern "C" void HSVChangedEvent__ctor_m3043072144 (HSVChangedEvent_t1170297569 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (HSVChangedEvent__ctor_m3043072144_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
UnityEvent_3__ctor_m3100550874(__this, /*hidden argument*/UnityEvent_3__ctor_m3100550874_MethodInfo_var);
return;
}
}
// System.Void HsvColor::.ctor(System.Double,System.Double,System.Double)
extern "C" void HsvColor__ctor_m2096855601 (HsvColor_t1057062332 * __this, double ___h0, double ___s1, double ___v2, const MethodInfo* method)
{
{
double L_0 = ___h0;
__this->set_H_0(L_0);
double L_1 = ___s1;
__this->set_S_1(L_1);
double L_2 = ___v2;
__this->set_V_2(L_2);
return;
}
}
extern "C" void HsvColor__ctor_m2096855601_AdjustorThunk (Il2CppObject * __this, double ___h0, double ___s1, double ___v2, const MethodInfo* method)
{
HsvColor_t1057062332 * _thisAdjusted = reinterpret_cast<HsvColor_t1057062332 *>(__this + 1);
HsvColor__ctor_m2096855601(_thisAdjusted, ___h0, ___s1, ___v2, method);
}
// System.Single HsvColor::get_normalizedH()
extern "C" float HsvColor_get_normalizedH_m3607787917 (HsvColor_t1057062332 * __this, const MethodInfo* method)
{
{
double L_0 = __this->get_H_0();
return ((float)((float)(((float)((float)L_0)))/(float)(360.0f)));
}
}
extern "C" float HsvColor_get_normalizedH_m3607787917_AdjustorThunk (Il2CppObject * __this, const MethodInfo* method)
{
HsvColor_t1057062332 * _thisAdjusted = reinterpret_cast<HsvColor_t1057062332 *>(__this + 1);
return HsvColor_get_normalizedH_m3607787917(_thisAdjusted, method);
}
// System.Void HsvColor::set_normalizedH(System.Single)
extern "C" void HsvColor_set_normalizedH_m2139074108 (HsvColor_t1057062332 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = ___value0;
__this->set_H_0(((double)((double)(((double)((double)L_0)))*(double)(360.0))));
return;
}
}
extern "C" void HsvColor_set_normalizedH_m2139074108_AdjustorThunk (Il2CppObject * __this, float ___value0, const MethodInfo* method)
{
HsvColor_t1057062332 * _thisAdjusted = reinterpret_cast<HsvColor_t1057062332 *>(__this + 1);
HsvColor_set_normalizedH_m2139074108(_thisAdjusted, ___value0, method);
}
// System.Single HsvColor::get_normalizedS()
extern "C" float HsvColor_get_normalizedS_m3607786980 (HsvColor_t1057062332 * __this, const MethodInfo* method)
{
{
double L_0 = __this->get_S_1();
return (((float)((float)L_0)));
}
}
extern "C" float HsvColor_get_normalizedS_m3607786980_AdjustorThunk (Il2CppObject * __this, const MethodInfo* method)
{
HsvColor_t1057062332 * _thisAdjusted = reinterpret_cast<HsvColor_t1057062332 *>(__this + 1);
return HsvColor_get_normalizedS_m3607786980(_thisAdjusted, method);
}
// System.Void HsvColor::set_normalizedS(System.Single)
extern "C" void HsvColor_set_normalizedS_m413849441 (HsvColor_t1057062332 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = ___value0;
__this->set_S_1((((double)((double)L_0))));
return;
}
}
extern "C" void HsvColor_set_normalizedS_m413849441_AdjustorThunk (Il2CppObject * __this, float ___value0, const MethodInfo* method)
{
HsvColor_t1057062332 * _thisAdjusted = reinterpret_cast<HsvColor_t1057062332 *>(__this + 1);
HsvColor_set_normalizedS_m413849441(_thisAdjusted, ___value0, method);
}
// System.Single HsvColor::get_normalizedV()
extern "C" float HsvColor_get_normalizedV_m3607786943 (HsvColor_t1057062332 * __this, const MethodInfo* method)
{
{
double L_0 = __this->get_V_2();
return (((float)((float)L_0)));
}
}
extern "C" float HsvColor_get_normalizedV_m3607786943_AdjustorThunk (Il2CppObject * __this, const MethodInfo* method)
{
HsvColor_t1057062332 * _thisAdjusted = reinterpret_cast<HsvColor_t1057062332 *>(__this + 1);
return HsvColor_get_normalizedV_m3607786943(_thisAdjusted, method);
}
// System.Void HsvColor::set_normalizedV(System.Single)
extern "C" void HsvColor_set_normalizedV_m460463238 (HsvColor_t1057062332 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = ___value0;
__this->set_V_2((((double)((double)L_0))));
return;
}
}
extern "C" void HsvColor_set_normalizedV_m460463238_AdjustorThunk (Il2CppObject * __this, float ___value0, const MethodInfo* method)
{
HsvColor_t1057062332 * _thisAdjusted = reinterpret_cast<HsvColor_t1057062332 *>(__this + 1);
HsvColor_set_normalizedV_m460463238(_thisAdjusted, ___value0, method);
}
// System.String HsvColor::ToString()
extern "C" String_t* HsvColor_ToString_m1590809902 (HsvColor_t1057062332 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (HsvColor_ToString_m1590809902_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
StringU5BU5D_t1642385972* L_0 = ((StringU5BU5D_t1642385972*)SZArrayNew(StringU5BU5D_t1642385972_il2cpp_TypeInfo_var, (uint32_t)7));
NullCheck(L_0);
ArrayElementTypeCheck (L_0, _stringLiteral372029399);
(L_0)->SetAt(static_cast<il2cpp_array_size_t>(0), (String_t*)_stringLiteral372029399);
StringU5BU5D_t1642385972* L_1 = L_0;
double* L_2 = __this->get_address_of_H_0();
String_t* L_3 = Double_ToString_m2210043919(L_2, _stringLiteral3231012694, /*hidden argument*/NULL);
NullCheck(L_1);
ArrayElementTypeCheck (L_1, L_3);
(L_1)->SetAt(static_cast<il2cpp_array_size_t>(1), (String_t*)L_3);
StringU5BU5D_t1642385972* L_4 = L_1;
NullCheck(L_4);
ArrayElementTypeCheck (L_4, _stringLiteral372029314);
(L_4)->SetAt(static_cast<il2cpp_array_size_t>(2), (String_t*)_stringLiteral372029314);
StringU5BU5D_t1642385972* L_5 = L_4;
double* L_6 = __this->get_address_of_S_1();
String_t* L_7 = Double_ToString_m2210043919(L_6, _stringLiteral3231012694, /*hidden argument*/NULL);
NullCheck(L_5);
ArrayElementTypeCheck (L_5, L_7);
(L_5)->SetAt(static_cast<il2cpp_array_size_t>(3), (String_t*)L_7);
StringU5BU5D_t1642385972* L_8 = L_5;
NullCheck(L_8);
ArrayElementTypeCheck (L_8, _stringLiteral372029314);
(L_8)->SetAt(static_cast<il2cpp_array_size_t>(4), (String_t*)_stringLiteral372029314);
StringU5BU5D_t1642385972* L_9 = L_8;
double* L_10 = __this->get_address_of_V_2();
String_t* L_11 = Double_ToString_m2210043919(L_10, _stringLiteral3231012694, /*hidden argument*/NULL);
NullCheck(L_9);
ArrayElementTypeCheck (L_9, L_11);
(L_9)->SetAt(static_cast<il2cpp_array_size_t>(5), (String_t*)L_11);
StringU5BU5D_t1642385972* L_12 = L_9;
NullCheck(L_12);
ArrayElementTypeCheck (L_12, _stringLiteral372029393);
(L_12)->SetAt(static_cast<il2cpp_array_size_t>(6), (String_t*)_stringLiteral372029393);
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
String_t* L_13 = String_Concat_m626692867(NULL /*static, unused*/, L_12, /*hidden argument*/NULL);
return L_13;
}
}
extern "C" String_t* HsvColor_ToString_m1590809902_AdjustorThunk (Il2CppObject * __this, const MethodInfo* method)
{
HsvColor_t1057062332 * _thisAdjusted = reinterpret_cast<HsvColor_t1057062332 *>(__this + 1);
return HsvColor_ToString_m1590809902(_thisAdjusted, method);
}
// HsvColor HSVUtil::ConvertRgbToHsv(UnityEngine.Color)
extern "C" HsvColor_t1057062332 HSVUtil_ConvertRgbToHsv_m4088715697 (Il2CppObject * __this /* static, unused */, Color_t2020392075 ___color0, const MethodInfo* method)
{
{
float L_0 = (&___color0)->get_r_0();
float L_1 = (&___color0)->get_g_1();
float L_2 = (&___color0)->get_b_2();
HsvColor_t1057062332 L_3 = HSVUtil_ConvertRgbToHsv_m2238362913(NULL /*static, unused*/, (((double)((double)(((int32_t)((int32_t)((float)((float)L_0*(float)(255.0f))))))))), (((double)((double)(((int32_t)((int32_t)((float)((float)L_1*(float)(255.0f))))))))), (((double)((double)(((int32_t)((int32_t)((float)((float)L_2*(float)(255.0f))))))))), /*hidden argument*/NULL);
return L_3;
}
}
// HsvColor HSVUtil::ConvertRgbToHsv(System.Double,System.Double,System.Double)
extern "C" HsvColor_t1057062332 HSVUtil_ConvertRgbToHsv_m2238362913 (Il2CppObject * __this /* static, unused */, double ___r0, double ___b1, double ___g2, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (HSVUtil_ConvertRgbToHsv_m2238362913_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
double V_0 = 0.0;
double V_1 = 0.0;
double V_2 = 0.0;
double V_3 = 0.0;
double V_4 = 0.0;
HsvColor_t1057062332 V_5;
memset(&V_5, 0, sizeof(V_5));
{
V_2 = (0.0);
double L_0 = ___r0;
double L_1 = ___g2;
double L_2 = Math_Min_m2551484304(NULL /*static, unused*/, L_0, L_1, /*hidden argument*/NULL);
double L_3 = ___b1;
double L_4 = Math_Min_m2551484304(NULL /*static, unused*/, L_2, L_3, /*hidden argument*/NULL);
V_1 = L_4;
double L_5 = ___r0;
double L_6 = ___g2;
double L_7 = Math_Max_m3248989870(NULL /*static, unused*/, L_5, L_6, /*hidden argument*/NULL);
double L_8 = ___b1;
double L_9 = Math_Max_m3248989870(NULL /*static, unused*/, L_7, L_8, /*hidden argument*/NULL);
V_4 = L_9;
double L_10 = V_4;
double L_11 = V_1;
V_0 = ((double)((double)L_10-(double)L_11));
double L_12 = V_4;
if ((!(((double)L_12) == ((double)(0.0)))))
{
goto IL_004b;
}
}
{
V_3 = (0.0);
goto IL_0050;
}
IL_004b:
{
double L_13 = V_0;
double L_14 = V_4;
V_3 = ((double)((double)L_13/(double)L_14));
}
IL_0050:
{
double L_15 = V_3;
if ((!(((double)L_15) == ((double)(0.0)))))
{
goto IL_006e;
}
}
{
V_2 = (360.0);
goto IL_00dd;
}
IL_006e:
{
double L_16 = ___r0;
double L_17 = V_4;
if ((!(((double)L_16) == ((double)L_17))))
{
goto IL_0081;
}
}
{
double L_18 = ___g2;
double L_19 = ___b1;
double L_20 = V_0;
V_2 = ((double)((double)((double)((double)L_18-(double)L_19))/(double)L_20));
goto IL_00b6;
}
IL_0081:
{
double L_21 = ___g2;
double L_22 = V_4;
if ((!(((double)L_21) == ((double)L_22))))
{
goto IL_009e;
}
}
{
double L_23 = ___b1;
double L_24 = ___r0;
double L_25 = V_0;
V_2 = ((double)((double)(2.0)+(double)((double)((double)((double)((double)L_23-(double)L_24))/(double)L_25))));
goto IL_00b6;
}
IL_009e:
{
double L_26 = ___b1;
double L_27 = V_4;
if ((!(((double)L_26) == ((double)L_27))))
{
goto IL_00b6;
}
}
{
double L_28 = ___r0;
double L_29 = ___g2;
double L_30 = V_0;
V_2 = ((double)((double)(4.0)+(double)((double)((double)((double)((double)L_28-(double)L_29))/(double)L_30))));
}
IL_00b6:
{
double L_31 = V_2;
V_2 = ((double)((double)L_31*(double)(60.0)));
double L_32 = V_2;
if ((!(((double)L_32) <= ((double)(0.0)))))
{
goto IL_00dd;
}
}
{
double L_33 = V_2;
V_2 = ((double)((double)L_33+(double)(360.0)));
}
IL_00dd:
{
Initobj (HsvColor_t1057062332_il2cpp_TypeInfo_var, (&V_5));
double L_34 = V_2;
(&V_5)->set_H_0(((double)((double)(360.0)-(double)L_34)));
double L_35 = V_3;
(&V_5)->set_S_1(L_35);
double L_36 = V_4;
(&V_5)->set_V_2(((double)((double)L_36/(double)(255.0))));
HsvColor_t1057062332 L_37 = V_5;
return L_37;
}
}
// UnityEngine.Color HSVUtil::ConvertHsvToRgb(System.Double,System.Double,System.Double,System.Single)
extern "C" Color_t2020392075 HSVUtil_ConvertHsvToRgb_m2339284600 (Il2CppObject * __this /* static, unused */, double ___h0, double ___s1, double ___v2, float ___alpha3, const MethodInfo* method)
{
double V_0 = 0.0;
double V_1 = 0.0;
double V_2 = 0.0;
int32_t V_3 = 0;
double V_4 = 0.0;
double V_5 = 0.0;
double V_6 = 0.0;
double V_7 = 0.0;
{
V_0 = (0.0);
V_1 = (0.0);
V_2 = (0.0);
double L_0 = ___s1;
if ((!(((double)L_0) == ((double)(0.0)))))
{
goto IL_0038;
}
}
{
double L_1 = ___v2;
V_0 = L_1;
double L_2 = ___v2;
V_1 = L_2;
double L_3 = ___v2;
V_2 = L_3;
goto IL_0117;
}
IL_0038:
{
double L_4 = ___h0;
if ((!(((double)L_4) == ((double)(360.0)))))
{
goto IL_0057;
}
}
{
___h0 = (0.0);
goto IL_0064;
}
IL_0057:
{
double L_5 = ___h0;
___h0 = ((double)((double)L_5/(double)(60.0)));
}
IL_0064:
{
double L_6 = ___h0;
V_3 = (((int32_t)((int32_t)L_6)));
double L_7 = ___h0;
int32_t L_8 = V_3;
V_4 = ((double)((double)L_7-(double)(((double)((double)L_8)))));
double L_9 = ___v2;
double L_10 = ___s1;
V_5 = ((double)((double)L_9*(double)((double)((double)(1.0)-(double)L_10))));
double L_11 = ___v2;
double L_12 = ___s1;
double L_13 = V_4;
V_6 = ((double)((double)L_11*(double)((double)((double)(1.0)-(double)((double)((double)L_12*(double)L_13))))));
double L_14 = ___v2;
double L_15 = ___s1;
double L_16 = V_4;
V_7 = ((double)((double)L_14*(double)((double)((double)(1.0)-(double)((double)((double)L_15*(double)((double)((double)(1.0)-(double)L_16))))))));
int32_t L_17 = V_3;
switch (L_17)
{
case 0:
{
goto IL_00c9;
}
case 1:
{
goto IL_00d6;
}
case 2:
{
goto IL_00e3;
}
case 3:
{
goto IL_00f0;
}
case 4:
{
goto IL_00fd;
}
}
}
{
goto IL_010a;
}
IL_00c9:
{
double L_18 = ___v2;
V_0 = L_18;
double L_19 = V_7;
V_1 = L_19;
double L_20 = V_5;
V_2 = L_20;
goto IL_0117;
}
IL_00d6:
{
double L_21 = V_6;
V_0 = L_21;
double L_22 = ___v2;
V_1 = L_22;
double L_23 = V_5;
V_2 = L_23;
goto IL_0117;
}
IL_00e3:
{
double L_24 = V_5;
V_0 = L_24;
double L_25 = ___v2;
V_1 = L_25;
double L_26 = V_7;
V_2 = L_26;
goto IL_0117;
}
IL_00f0:
{
double L_27 = V_5;
V_0 = L_27;
double L_28 = V_6;
V_1 = L_28;
double L_29 = ___v2;
V_2 = L_29;
goto IL_0117;
}
IL_00fd:
{
double L_30 = V_7;
V_0 = L_30;
double L_31 = V_5;
V_1 = L_31;
double L_32 = ___v2;
V_2 = L_32;
goto IL_0117;
}
IL_010a:
{
double L_33 = ___v2;
V_0 = L_33;
double L_34 = V_5;
V_1 = L_34;
double L_35 = V_6;
V_2 = L_35;
goto IL_0117;
}
IL_0117:
{
double L_36 = V_0;
double L_37 = V_1;
double L_38 = V_2;
float L_39 = ___alpha3;
Color_t2020392075 L_40;
memset(&L_40, 0, sizeof(L_40));
Color__ctor_m1909920690(&L_40, (((float)((float)L_36))), (((float)((float)L_37))), (((float)((float)L_38))), L_39, /*hidden argument*/NULL);
return L_40;
}
}
// System.Void MenuScript::.ctor()
extern "C" void MenuScript__ctor_m1194384423 (MenuScript_t1134262648 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void MenuScript::Awake()
extern "C" void MenuScript_Awake_m1828322644 (MenuScript_t1134262648 * __this, const MethodInfo* method)
{
{
__this->set_currentState_2(0);
return;
}
}
// System.Void MenuScript::Update()
extern "C" void MenuScript_Update_m2405570102 (MenuScript_t1134262648 * __this, const MethodInfo* method)
{
int32_t V_0 = 0;
{
int32_t L_0 = __this->get_currentState_2();
V_0 = L_0;
int32_t L_1 = V_0;
if (!L_1)
{
goto IL_0019;
}
}
{
int32_t L_2 = V_0;
if ((((int32_t)L_2) == ((int32_t)1)))
{
goto IL_0036;
}
}
{
goto IL_0053;
}
IL_0019:
{
GameObject_t1756533147 * L_3 = __this->get_mainMenu_3();
NullCheck(L_3);
GameObject_SetActive_m2887581199(L_3, (bool)1, /*hidden argument*/NULL);
GameObject_t1756533147 * L_4 = __this->get_returnMenu_4();
NullCheck(L_4);
GameObject_SetActive_m2887581199(L_4, (bool)0, /*hidden argument*/NULL);
goto IL_0053;
}
IL_0036:
{
GameObject_t1756533147 * L_5 = __this->get_mainMenu_3();
NullCheck(L_5);
GameObject_SetActive_m2887581199(L_5, (bool)0, /*hidden argument*/NULL);
GameObject_t1756533147 * L_6 = __this->get_returnMenu_4();
NullCheck(L_6);
GameObject_SetActive_m2887581199(L_6, (bool)1, /*hidden argument*/NULL);
goto IL_0053;
}
IL_0053:
{
return;
}
}
// System.Void MenuScript::GameOneStart()
extern "C" void MenuScript_GameOneStart_m1316928961 (MenuScript_t1134262648 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (MenuScript_GameOneStart_m1316928961_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral3382319821, /*hidden argument*/NULL);
__this->set_currentState_2(1);
return;
}
}
// System.Void MenuScript::GameTwoStart()
extern "C" void MenuScript_GameTwoStart_m2899916685 (MenuScript_t1134262648 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (MenuScript_GameTwoStart_m2899916685_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral2389305449, /*hidden argument*/NULL);
__this->set_currentState_2(1);
return;
}
}
// System.Void MenuScript::GameThreeStart()
extern "C" void MenuScript_GameThreeStart_m248778275 (MenuScript_t1134262648 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (MenuScript_GameThreeStart_m248778275_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral2462317915, /*hidden argument*/NULL);
__this->set_currentState_2(1);
return;
}
}
// System.Void MenuScript::BackToMenu()
extern "C" void MenuScript_BackToMenu_m2371239854 (MenuScript_t1134262648 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (MenuScript_BackToMenu_m2371239854_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral2155432071, /*hidden argument*/NULL);
__this->set_currentState_2(0);
return;
}
}
// System.Void MenuScript::BackToGame()
extern "C" void MenuScript_BackToGame_m4083340633 (MenuScript_t1134262648 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (MenuScript_BackToGame_m4083340633_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral1225323859, /*hidden argument*/NULL);
__this->set_currentState_2(0);
return;
}
}
// System.Void musicControl::.ctor()
extern "C" void musicControl__ctor_m3012070573 (musicControl_t2891809704 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void musicControl::Start()
extern "C" void musicControl_Start_m481717685 (musicControl_t2891809704 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void musicControl::Update()
extern "C" void musicControl_Update_m223845942 (musicControl_t2891809704 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (musicControl_Update_m223845942_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Touch_t407273883 V_0;
memset(&V_0, 0, sizeof(V_0));
Vector3_t2243707580 V_1;
memset(&V_1, 0, sizeof(V_1));
RaycastHit2D_t4063908774 V_2;
memset(&V_2, 0, sizeof(V_2));
GameObject_t1756533147 * V_3 = NULL;
{
Camera_t189460977 * L_0 = Camera_get_main_m475173995(NULL /*static, unused*/, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Input_t1785128008_il2cpp_TypeInfo_var);
Touch_t407273883 L_1 = Input_GetTouch_m1463942798(NULL /*static, unused*/, 0, /*hidden argument*/NULL);
V_0 = L_1;
Vector2_t2243707579 L_2 = Touch_get_position_m2079703643((&V_0), /*hidden argument*/NULL);
Vector3_t2243707580 L_3 = Vector2_op_Implicit_m176791411(NULL /*static, unused*/, L_2, /*hidden argument*/NULL);
NullCheck(L_0);
Vector3_t2243707580 L_4 = Camera_ScreenToWorldPoint_m929392728(L_0, L_3, /*hidden argument*/NULL);
__this->set_touchPosWorld_4(L_4);
Vector3_t2243707580 * L_5 = __this->get_address_of_touchPosWorld_4();
float L_6 = L_5->get_x_1();
Vector3_t2243707580 * L_7 = __this->get_address_of_touchPosWorld_4();
float L_8 = L_7->get_y_2();
Vector3_t2243707580 * L_9 = __this->get_address_of_touchPosWorld_4();
float L_10 = L_9->get_z_3();
Vector3__ctor_m2638739322((&V_1), L_6, L_8, L_10, /*hidden argument*/NULL);
Vector3_t2243707580 L_11 = V_1;
Vector2_t2243707579 L_12 = Vector2_op_Implicit_m1064335535(NULL /*static, unused*/, L_11, /*hidden argument*/NULL);
Camera_t189460977 * L_13 = Camera_get_main_m475173995(NULL /*static, unused*/, /*hidden argument*/NULL);
NullCheck(L_13);
Transform_t3275118058 * L_14 = Component_get_transform_m2697483695(L_13, /*hidden argument*/NULL);
NullCheck(L_14);
Vector3_t2243707580 L_15 = Transform_get_forward_m1833488937(L_14, /*hidden argument*/NULL);
Vector2_t2243707579 L_16 = Vector2_op_Implicit_m1064335535(NULL /*static, unused*/, L_15, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Physics2D_t2540166467_il2cpp_TypeInfo_var);
RaycastHit2D_t4063908774 L_17 = Physics2D_Raycast_m2560154475(NULL /*static, unused*/, L_12, L_16, /*hidden argument*/NULL);
V_2 = L_17;
Collider2D_t646061738 * L_18 = RaycastHit2D_get_collider_m2568504212((&V_2), /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_19 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_18, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_19)
{
goto IL_00cb;
}
}
{
Transform_t3275118058 * L_20 = RaycastHit2D_get_transform_m747355930((&V_2), /*hidden argument*/NULL);
NullCheck(L_20);
GameObject_t1756533147 * L_21 = Component_get_gameObject_m3105766835(L_20, /*hidden argument*/NULL);
V_3 = L_21;
GameObject_t1756533147 * L_22 = V_3;
NullCheck(L_22);
Transform_t3275118058 * L_23 = GameObject_get_transform_m909382139(L_22, /*hidden argument*/NULL);
Transform_t3275118058 * L_24 = L_23;
NullCheck(L_24);
Vector3_t2243707580 L_25 = Transform_get_localScale_m3074381503(L_24, /*hidden argument*/NULL);
Vector3_t2243707580 L_26;
memset(&L_26, 0, sizeof(L_26));
Vector3__ctor_m2638739322(&L_26, (1.0f), (1.0f), (1.0f), /*hidden argument*/NULL);
Vector3_t2243707580 L_27 = Vector3_op_Addition_m3146764857(NULL /*static, unused*/, L_25, L_26, /*hidden argument*/NULL);
NullCheck(L_24);
Transform_set_localScale_m2325460848(L_24, L_27, /*hidden argument*/NULL);
GameObject_t1756533147 * L_28 = V_3;
NullCheck(L_28);
AudioSource_t1135106623 * L_29 = GameObject_GetComponent_TisAudioSource_t1135106623_m1072053017(L_28, /*hidden argument*/GameObject_GetComponent_TisAudioSource_t1135106623_m1072053017_MethodInfo_var);
__this->set_boxMusic_3(L_29);
AudioSource_t1135106623 * L_30 = __this->get_boxMusic_3();
NullCheck(L_30);
AudioSource_Play_m353744792(L_30, /*hidden argument*/NULL);
}
IL_00cb:
{
return;
}
}
// System.Void ParticlePainter::.ctor()
extern "C" void ParticlePainter__ctor_m3797515404 (ParticlePainter_t1073897267 * __this, const MethodInfo* method)
{
{
__this->set_particleSize_6((0.1f));
__this->set_penDistance_7((0.2f));
Vector3_t2243707580 L_0 = Vector3_get_zero_m1527993324(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_previousPosition_11(L_0);
Color_t2020392075 L_1 = Color_get_white_m3987539815(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_currentColor_13(L_1);
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void ParticlePainter::Start()
extern "C" void ParticlePainter_Start_m240231480 (ParticlePainter_t1073897267 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ParticlePainter_Start_m240231480_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
IntPtr_t L_0;
L_0.set_m_value_0((void*)(void*)ParticlePainter_ARFrameUpdated_m3328436002_MethodInfo_var);
ARFrameUpdate_t496507918 * L_1 = (ARFrameUpdate_t496507918 *)il2cpp_codegen_object_new(ARFrameUpdate_t496507918_il2cpp_TypeInfo_var);
ARFrameUpdate__ctor_m1399217559(L_1, __this, L_0, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(UnityARSessionNativeInterface_t1130867170_il2cpp_TypeInfo_var);
UnityARSessionNativeInterface_add_ARFrameUpdatedEvent_m2850773202(NULL /*static, unused*/, L_1, /*hidden argument*/NULL);
ParticleSystem_t3394631041 * L_2 = __this->get_painterParticlePrefab_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
ParticleSystem_t3394631041 * L_3 = Object_Instantiate_TisParticleSystem_t3394631041_m4293040502(NULL /*static, unused*/, L_2, /*hidden argument*/Object_Instantiate_TisParticleSystem_t3394631041_m4293040502_MethodInfo_var);
__this->set_currentPS_9(L_3);
List_1_t1612828712 * L_4 = (List_1_t1612828712 *)il2cpp_codegen_object_new(List_1_t1612828712_il2cpp_TypeInfo_var);
List_1__ctor_m347461442(L_4, /*hidden argument*/List_1__ctor_m347461442_MethodInfo_var);
__this->set_currentPaintVertices_12(L_4);
List_1_t2763752173 * L_5 = (List_1_t2763752173 *)il2cpp_codegen_object_new(List_1_t2763752173_il2cpp_TypeInfo_var);
List_1__ctor_m3416249727(L_5, /*hidden argument*/List_1__ctor_m3416249727_MethodInfo_var);
__this->set_paintSystems_14(L_5);
__this->set_frameUpdated_5((bool)0);
ColorPicker_t3035206225 * L_6 = __this->get_colorPicker_8();
NullCheck(L_6);
ColorChangedEvent_t2990895397 * L_7 = L_6->get_onValueChanged_9();
IntPtr_t L_8;
L_8.set_m_value_0((void*)(void*)ParticlePainter_U3CStartU3Em__0_m3078015875_MethodInfo_var);
UnityAction_1_t3386977826 * L_9 = (UnityAction_1_t3386977826 *)il2cpp_codegen_object_new(UnityAction_1_t3386977826_il2cpp_TypeInfo_var);
UnityAction_1__ctor_m3329809356(L_9, __this, L_8, /*hidden argument*/UnityAction_1__ctor_m3329809356_MethodInfo_var);
NullCheck(L_7);
UnityEvent_1_AddListener_m903508446(L_7, L_9, /*hidden argument*/UnityEvent_1_AddListener_m903508446_MethodInfo_var);
ColorPicker_t3035206225 * L_10 = __this->get_colorPicker_8();
NullCheck(L_10);
GameObject_t1756533147 * L_11 = Component_get_gameObject_m3105766835(L_10, /*hidden argument*/NULL);
NullCheck(L_11);
GameObject_SetActive_m2887581199(L_11, (bool)0, /*hidden argument*/NULL);
return;
}
}
// System.Void ParticlePainter::ARFrameUpdated(UnityEngine.XR.iOS.UnityARCamera)
extern "C" void ParticlePainter_ARFrameUpdated_m3328436002 (ParticlePainter_t1073897267 * __this, UnityARCamera_t4198559457 ___camera0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ParticlePainter_ARFrameUpdated_m3328436002_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Matrix4x4_t2933234003 V_0;
memset(&V_0, 0, sizeof(V_0));
Vector3_t2243707580 V_1;
memset(&V_1, 0, sizeof(V_1));
{
Initobj (Matrix4x4_t2933234003_il2cpp_TypeInfo_var, (&V_0));
UnityARMatrix4x4_t100931615 * L_0 = (&___camera0)->get_address_of_worldTransform_0();
Vector4_t2243707581 L_1 = L_0->get_column3_3();
Matrix4x4_SetColumn_m3120649749((&V_0), 3, L_1, /*hidden argument*/NULL);
Matrix4x4_t2933234003 L_2 = V_0;
Vector3_t2243707580 L_3 = UnityARMatrixOps_GetPosition_m1153858439(NULL /*static, unused*/, L_2, /*hidden argument*/NULL);
Camera_t189460977 * L_4 = Camera_get_main_m475173995(NULL /*static, unused*/, /*hidden argument*/NULL);
NullCheck(L_4);
Transform_t3275118058 * L_5 = Component_get_transform_m2697483695(L_4, /*hidden argument*/NULL);
NullCheck(L_5);
Vector3_t2243707580 L_6 = Transform_get_forward_m1833488937(L_5, /*hidden argument*/NULL);
float L_7 = __this->get_penDistance_7();
Vector3_t2243707580 L_8 = Vector3_op_Multiply_m1351554733(NULL /*static, unused*/, L_6, L_7, /*hidden argument*/NULL);
Vector3_t2243707580 L_9 = Vector3_op_Addition_m3146764857(NULL /*static, unused*/, L_3, L_8, /*hidden argument*/NULL);
V_1 = L_9;
Vector3_t2243707580 L_10 = V_1;
Vector3_t2243707580 L_11 = __this->get_previousPosition_11();
float L_12 = Vector3_Distance_m1859670022(NULL /*static, unused*/, L_10, L_11, /*hidden argument*/NULL);
float L_13 = __this->get_minDistanceThreshold_3();
if ((!(((float)L_12) > ((float)L_13))))
{
goto IL_007f;
}
}
{
int32_t L_14 = __this->get_paintMode_15();
if ((!(((uint32_t)L_14) == ((uint32_t)2))))
{
goto IL_0071;
}
}
{
List_1_t1612828712 * L_15 = __this->get_currentPaintVertices_12();
Vector3_t2243707580 L_16 = V_1;
NullCheck(L_15);
List_1_Add_m2338641291(L_15, L_16, /*hidden argument*/List_1_Add_m2338641291_MethodInfo_var);
}
IL_0071:
{
__this->set_frameUpdated_5((bool)1);
Vector3_t2243707580 L_17 = V_1;
__this->set_previousPosition_11(L_17);
}
IL_007f:
{
return;
}
}
// System.Void ParticlePainter::OnGUI()
extern "C" void ParticlePainter_OnGUI_m1331574968 (ParticlePainter_t1073897267 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ParticlePainter_OnGUI_m1331574968_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
String_t* V_0 = NULL;
String_t* G_B5_0 = NULL;
{
int32_t L_0 = __this->get_paintMode_15();
if (L_0)
{
goto IL_0015;
}
}
{
G_B5_0 = _stringLiteral1999992571;
goto IL_0030;
}
IL_0015:
{
int32_t L_1 = __this->get_paintMode_15();
if ((!(((uint32_t)L_1) == ((uint32_t)1))))
{
goto IL_002b;
}
}
{
G_B5_0 = _stringLiteral1972506681;
goto IL_0030;
}
IL_002b:
{
G_B5_0 = _stringLiteral1077864602;
}
IL_0030:
{
V_0 = G_B5_0;
int32_t L_2 = Screen_get_width_m41137238(NULL /*static, unused*/, /*hidden argument*/NULL);
Rect_t3681755626 L_3;
memset(&L_3, 0, sizeof(L_3));
Rect__ctor_m1220545469(&L_3, ((float)((float)(((float)((float)L_2)))-(float)(100.0f))), (0.0f), (100.0f), (50.0f), /*hidden argument*/NULL);
String_t* L_4 = V_0;
IL2CPP_RUNTIME_CLASS_INIT(GUI_t4082743951_il2cpp_TypeInfo_var);
bool L_5 = GUI_Button_m3054448581(NULL /*static, unused*/, L_3, L_4, /*hidden argument*/NULL);
if (!L_5)
{
goto IL_0097;
}
}
{
int32_t L_6 = __this->get_paintMode_15();
__this->set_paintMode_15(((int32_t)((int32_t)((int32_t)((int32_t)L_6+(int32_t)1))%(int32_t)3)));
ColorPicker_t3035206225 * L_7 = __this->get_colorPicker_8();
NullCheck(L_7);
GameObject_t1756533147 * L_8 = Component_get_gameObject_m3105766835(L_7, /*hidden argument*/NULL);
int32_t L_9 = __this->get_paintMode_15();
NullCheck(L_8);
GameObject_SetActive_m2887581199(L_8, (bool)((((int32_t)L_9) == ((int32_t)1))? 1 : 0), /*hidden argument*/NULL);
int32_t L_10 = __this->get_paintMode_15();
if ((!(((uint32_t)L_10) == ((uint32_t)2))))
{
goto IL_0097;
}
}
{
ParticlePainter_RestartPainting_m3645394903(__this, /*hidden argument*/NULL);
}
IL_0097:
{
return;
}
}
// System.Void ParticlePainter::RestartPainting()
extern "C" void ParticlePainter_RestartPainting_m3645394903 (ParticlePainter_t1073897267 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ParticlePainter_RestartPainting_m3645394903_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
List_1_t2763752173 * L_0 = __this->get_paintSystems_14();
ParticleSystem_t3394631041 * L_1 = __this->get_currentPS_9();
NullCheck(L_0);
List_1_Add_m4197260563(L_0, L_1, /*hidden argument*/List_1_Add_m4197260563_MethodInfo_var);
ParticleSystem_t3394631041 * L_2 = __this->get_painterParticlePrefab_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
ParticleSystem_t3394631041 * L_3 = Object_Instantiate_TisParticleSystem_t3394631041_m4293040502(NULL /*static, unused*/, L_2, /*hidden argument*/Object_Instantiate_TisParticleSystem_t3394631041_m4293040502_MethodInfo_var);
__this->set_currentPS_9(L_3);
List_1_t1612828712 * L_4 = (List_1_t1612828712 *)il2cpp_codegen_object_new(List_1_t1612828712_il2cpp_TypeInfo_var);
List_1__ctor_m347461442(L_4, /*hidden argument*/List_1__ctor_m347461442_MethodInfo_var);
__this->set_currentPaintVertices_12(L_4);
return;
}
}
// System.Void ParticlePainter::Update()
extern "C" void ParticlePainter_Update_m3500146815 (ParticlePainter_t1073897267 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ParticlePainter_Update_m3500146815_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
int32_t V_0 = 0;
ParticleU5BU5D_t574222242* V_1 = NULL;
int32_t V_2 = 0;
Vector3_t2243707580 V_3;
memset(&V_3, 0, sizeof(V_3));
Enumerator_t1147558386 V_4;
memset(&V_4, 0, sizeof(V_4));
ParticleU5BU5D_t574222242* V_5 = NULL;
Exception_t1927440687 * __last_unhandled_exception = 0;
NO_UNUSED_WARNING (__last_unhandled_exception);
Exception_t1927440687 * __exception_local = 0;
NO_UNUSED_WARNING (__exception_local);
int32_t __leave_target = 0;
NO_UNUSED_WARNING (__leave_target);
{
bool L_0 = __this->get_frameUpdated_5();
if (!L_0)
{
goto IL_00f1;
}
}
{
int32_t L_1 = __this->get_paintMode_15();
if ((!(((uint32_t)L_1) == ((uint32_t)2))))
{
goto IL_00f1;
}
}
{
List_1_t1612828712 * L_2 = __this->get_currentPaintVertices_12();
NullCheck(L_2);
int32_t L_3 = List_1_get_Count_m4027941115(L_2, /*hidden argument*/List_1_get_Count_m4027941115_MethodInfo_var);
if ((((int32_t)L_3) <= ((int32_t)0)))
{
goto IL_00c2;
}
}
{
List_1_t1612828712 * L_4 = __this->get_currentPaintVertices_12();
NullCheck(L_4);
int32_t L_5 = List_1_get_Count_m4027941115(L_4, /*hidden argument*/List_1_get_Count_m4027941115_MethodInfo_var);
V_0 = L_5;
int32_t L_6 = V_0;
V_1 = ((ParticleU5BU5D_t574222242*)SZArrayNew(ParticleU5BU5D_t574222242_il2cpp_TypeInfo_var, (uint32_t)L_6));
V_2 = 0;
List_1_t1612828712 * L_7 = __this->get_currentPaintVertices_12();
NullCheck(L_7);
Enumerator_t1147558386 L_8 = List_1_GetEnumerator_m940839541(L_7, /*hidden argument*/List_1_GetEnumerator_m940839541_MethodInfo_var);
V_4 = L_8;
}
IL_004a:
try
{ // begin try (depth: 1)
{
goto IL_0091;
}
IL_004f:
{
Vector3_t2243707580 L_9 = Enumerator_get_Current_m857008049((&V_4), /*hidden argument*/Enumerator_get_Current_m857008049_MethodInfo_var);
V_3 = L_9;
ParticleU5BU5D_t574222242* L_10 = V_1;
int32_t L_11 = V_2;
NullCheck(L_10);
Vector3_t2243707580 L_12 = V_3;
Particle_set_position_m3680513126(((L_10)->GetAddressAt(static_cast<il2cpp_array_size_t>(L_11))), L_12, /*hidden argument*/NULL);
ParticleU5BU5D_t574222242* L_13 = V_1;
int32_t L_14 = V_2;
NullCheck(L_13);
Color_t2020392075 L_15 = __this->get_currentColor_13();
Color32_t874517518 L_16 = Color32_op_Implicit_m624191464(NULL /*static, unused*/, L_15, /*hidden argument*/NULL);
Particle_set_startColor_m3936512348(((L_13)->GetAddressAt(static_cast<il2cpp_array_size_t>(L_14))), L_16, /*hidden argument*/NULL);
ParticleU5BU5D_t574222242* L_17 = V_1;
int32_t L_18 = V_2;
NullCheck(L_17);
float L_19 = __this->get_particleSize_6();
Particle_set_startSize_m2457836830(((L_17)->GetAddressAt(static_cast<il2cpp_array_size_t>(L_18))), L_19, /*hidden argument*/NULL);
int32_t L_20 = V_2;
V_2 = ((int32_t)((int32_t)L_20+(int32_t)1));
}
IL_0091:
{
bool L_21 = Enumerator_MoveNext_m2007266881((&V_4), /*hidden argument*/Enumerator_MoveNext_m2007266881_MethodInfo_var);
if (L_21)
{
goto IL_004f;
}
}
IL_009d:
{
IL2CPP_LEAVE(0xB0, FINALLY_00a2);
}
} // end try (depth: 1)
catch(Il2CppExceptionWrapper& e)
{
__last_unhandled_exception = (Exception_t1927440687 *)e.ex;
goto FINALLY_00a2;
}
FINALLY_00a2:
{ // begin finally (depth: 1)
Enumerator_Dispose_m3215924523((&V_4), /*hidden argument*/Enumerator_Dispose_m3215924523_MethodInfo_var);
IL2CPP_END_FINALLY(162)
} // end finally (depth: 1)
IL2CPP_CLEANUP(162)
{
IL2CPP_JUMP_TBL(0xB0, IL_00b0)
IL2CPP_RETHROW_IF_UNHANDLED(Exception_t1927440687 *)
}
IL_00b0:
{
ParticleSystem_t3394631041 * L_22 = __this->get_currentPS_9();
ParticleU5BU5D_t574222242* L_23 = V_1;
int32_t L_24 = V_0;
NullCheck(L_22);
ParticleSystem_SetParticles_m3035584975(L_22, L_23, L_24, /*hidden argument*/NULL);
goto IL_00ea;
}
IL_00c2:
{
V_5 = ((ParticleU5BU5D_t574222242*)SZArrayNew(ParticleU5BU5D_t574222242_il2cpp_TypeInfo_var, (uint32_t)1));
ParticleU5BU5D_t574222242* L_25 = V_5;
NullCheck(L_25);
Particle_set_startSize_m2457836830(((L_25)->GetAddressAt(static_cast<il2cpp_array_size_t>(0))), (0.0f), /*hidden argument*/NULL);
ParticleSystem_t3394631041 * L_26 = __this->get_currentPS_9();
ParticleU5BU5D_t574222242* L_27 = V_5;
NullCheck(L_26);
ParticleSystem_SetParticles_m3035584975(L_26, L_27, 1, /*hidden argument*/NULL);
}
IL_00ea:
{
__this->set_frameUpdated_5((bool)0);
}
IL_00f1:
{
return;
}
}
// System.Void ParticlePainter::<Start>m__0(UnityEngine.Color)
extern "C" void ParticlePainter_U3CStartU3Em__0_m3078015875 (ParticlePainter_t1073897267 * __this, Color_t2020392075 ___newColor0, const MethodInfo* method)
{
{
Color_t2020392075 L_0 = ___newColor0;
__this->set_currentColor_13(L_0);
return;
}
}
// System.Void playMusic::.ctor()
extern "C" void playMusic__ctor_m3666129064 (playMusic_t1960384527 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void playMusic::Start()
extern "C" void playMusic_Start_m2858405716 (playMusic_t1960384527 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void playMusic::Update()
extern "C" void playMusic_Update_m363225915 (playMusic_t1960384527 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void playMusic::PlayMusicFunc()
extern "C" void playMusic_PlayMusicFunc_m2741615981 (playMusic_t1960384527 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (playMusic_PlayMusicFunc_m2741615981_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
AudioSource_t1135106623 * V_0 = NULL;
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral1809839953, /*hidden argument*/NULL);
GameObject_t1756533147 * L_0 = Component_get_gameObject_m3105766835(__this, /*hidden argument*/NULL);
NullCheck(L_0);
Transform_t3275118058 * L_1 = GameObject_get_transform_m909382139(L_0, /*hidden argument*/NULL);
Transform_t3275118058 * L_2 = L_1;
NullCheck(L_2);
Vector3_t2243707580 L_3 = Transform_get_localScale_m3074381503(L_2, /*hidden argument*/NULL);
Vector3_t2243707580 L_4;
memset(&L_4, 0, sizeof(L_4));
Vector3__ctor_m2638739322(&L_4, (1.0f), (1.0f), (1.0f), /*hidden argument*/NULL);
Vector3_t2243707580 L_5 = Vector3_op_Addition_m3146764857(NULL /*static, unused*/, L_3, L_4, /*hidden argument*/NULL);
NullCheck(L_2);
Transform_set_localScale_m2325460848(L_2, L_5, /*hidden argument*/NULL);
GameObject_t1756533147 * L_6 = Component_get_gameObject_m3105766835(__this, /*hidden argument*/NULL);
NullCheck(L_6);
AudioSource_t1135106623 * L_7 = GameObject_GetComponent_TisAudioSource_t1135106623_m1072053017(L_6, /*hidden argument*/GameObject_GetComponent_TisAudioSource_t1135106623_m1072053017_MethodInfo_var);
V_0 = L_7;
AudioSource_t1135106623 * L_8 = V_0;
NullCheck(L_8);
AudioSource_Play_m353744792(L_8, /*hidden argument*/NULL);
return;
}
}
// System.Void playMusic::StopPlayMusicFunc()
extern "C" void playMusic_StopPlayMusicFunc_m1382748181 (playMusic_t1960384527 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (playMusic_StopPlayMusicFunc_m1382748181_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
AudioSource_t1135106623 * V_0 = NULL;
{
GameObject_t1756533147 * L_0 = Component_get_gameObject_m3105766835(__this, /*hidden argument*/NULL);
NullCheck(L_0);
Transform_t3275118058 * L_1 = GameObject_get_transform_m909382139(L_0, /*hidden argument*/NULL);
Transform_t3275118058 * L_2 = L_1;
NullCheck(L_2);
Vector3_t2243707580 L_3 = Transform_get_localScale_m3074381503(L_2, /*hidden argument*/NULL);
Vector3_t2243707580 L_4;
memset(&L_4, 0, sizeof(L_4));
Vector3__ctor_m2638739322(&L_4, (1.0f), (1.0f), (1.0f), /*hidden argument*/NULL);
Vector3_t2243707580 L_5 = Vector3_op_Subtraction_m2407545601(NULL /*static, unused*/, L_3, L_4, /*hidden argument*/NULL);
NullCheck(L_2);
Transform_set_localScale_m2325460848(L_2, L_5, /*hidden argument*/NULL);
GameObject_t1756533147 * L_6 = Component_get_gameObject_m3105766835(__this, /*hidden argument*/NULL);
NullCheck(L_6);
AudioSource_t1135106623 * L_7 = GameObject_GetComponent_TisAudioSource_t1135106623_m1072053017(L_6, /*hidden argument*/GameObject_GetComponent_TisAudioSource_t1135106623_m1072053017_MethodInfo_var);
V_0 = L_7;
AudioSource_t1135106623 * L_8 = V_0;
NullCheck(L_8);
AudioSource_Stop_m3452679614(L_8, /*hidden argument*/NULL);
return;
}
}
// System.Void selectBox::.ctor()
extern "C" void selectBox__ctor_m2584253960 (selectBox_t2744202403 * __this, const MethodInfo* method)
{
{
__this->set_firstTime_2((bool)1);
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void selectBox::Start()
extern "C" void selectBox_Start_m1918360084 (selectBox_t2744202403 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void selectBox::Update()
extern "C" void selectBox_Update_m1011808971 (selectBox_t2744202403 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (selectBox_Update_m1011808971_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Touch_t407273883 V_0;
memset(&V_0, 0, sizeof(V_0));
Ray_t2469606224 V_1;
memset(&V_1, 0, sizeof(V_1));
Touch_t407273883 V_2;
memset(&V_2, 0, sizeof(V_2));
{
IL2CPP_RUNTIME_CLASS_INIT(Input_t1785128008_il2cpp_TypeInfo_var);
int32_t L_0 = Input_get_touchCount_m2050827666(NULL /*static, unused*/, /*hidden argument*/NULL);
if ((((int32_t)L_0) <= ((int32_t)0)))
{
goto IL_00cd;
}
}
{
IL2CPP_RUNTIME_CLASS_INIT(Input_t1785128008_il2cpp_TypeInfo_var);
Touch_t407273883 L_1 = Input_GetTouch_m1463942798(NULL /*static, unused*/, 0, /*hidden argument*/NULL);
V_0 = L_1;
int32_t L_2 = Touch_get_phase_m196706494((&V_0), /*hidden argument*/NULL);
if (L_2)
{
goto IL_00cd;
}
}
{
Camera_t189460977 * L_3 = Camera_get_main_m475173995(NULL /*static, unused*/, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Input_t1785128008_il2cpp_TypeInfo_var);
Touch_t407273883 L_4 = Input_GetTouch_m1463942798(NULL /*static, unused*/, 0, /*hidden argument*/NULL);
V_2 = L_4;
Vector2_t2243707579 L_5 = Touch_get_position_m2079703643((&V_2), /*hidden argument*/NULL);
Vector3_t2243707580 L_6 = Vector2_op_Implicit_m176791411(NULL /*static, unused*/, L_5, /*hidden argument*/NULL);
NullCheck(L_3);
Ray_t2469606224 L_7 = Camera_ScreenPointToRay_m614889538(L_3, L_6, /*hidden argument*/NULL);
V_1 = L_7;
Ray_t2469606224 L_8 = V_1;
RaycastHit_t87180320 * L_9 = __this->get_address_of_raycastHit_3();
bool L_10 = Physics_Raycast_m2736931691(NULL /*static, unused*/, L_8, L_9, /*hidden argument*/NULL);
if (!L_10)
{
goto IL_00cd;
}
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral2736962493, /*hidden argument*/NULL);
RaycastHit_t87180320 * L_11 = __this->get_address_of_raycastHit_3();
Collider_t3497673348 * L_12 = RaycastHit_get_collider_m301198172(L_11, /*hidden argument*/NULL);
NullCheck(L_12);
bool L_13 = Component_CompareTag_m3443292365(L_12, _stringLiteral489976614, /*hidden argument*/NULL);
if (!L_13)
{
goto IL_00cd;
}
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral2799618682, /*hidden argument*/NULL);
bool L_14 = __this->get_firstTime_2();
if (L_14)
{
goto IL_00a0;
}
}
{
RaycastHit_t87180320 * L_15 = __this->get_address_of_raycastHitPrev_4();
Collider_t3497673348 * L_16 = RaycastHit_get_collider_m301198172(L_15, /*hidden argument*/NULL);
NullCheck(L_16);
GameObject_t1756533147 * L_17 = Component_get_gameObject_m3105766835(L_16, /*hidden argument*/NULL);
NullCheck(L_17);
playMusic_t1960384527 * L_18 = GameObject_GetComponent_TisplayMusic_t1960384527_m1033848332(L_17, /*hidden argument*/GameObject_GetComponent_TisplayMusic_t1960384527_m1033848332_MethodInfo_var);
NullCheck(L_18);
playMusic_StopPlayMusicFunc_m1382748181(L_18, /*hidden argument*/NULL);
}
IL_00a0:
{
__this->set_firstTime_2((bool)0);
RaycastHit_t87180320 L_19 = __this->get_raycastHit_3();
__this->set_raycastHitPrev_4(L_19);
RaycastHit_t87180320 * L_20 = __this->get_address_of_raycastHit_3();
Collider_t3497673348 * L_21 = RaycastHit_get_collider_m301198172(L_20, /*hidden argument*/NULL);
NullCheck(L_21);
GameObject_t1756533147 * L_22 = Component_get_gameObject_m3105766835(L_21, /*hidden argument*/NULL);
NullCheck(L_22);
playMusic_t1960384527 * L_23 = GameObject_GetComponent_TisplayMusic_t1960384527_m1033848332(L_22, /*hidden argument*/GameObject_GetComponent_TisplayMusic_t1960384527_m1033848332_MethodInfo_var);
NullCheck(L_23);
playMusic_PlayMusicFunc_m2741615981(L_23, /*hidden argument*/NULL);
}
IL_00cd:
{
return;
}
}
// System.Void Shooting::.ctor()
extern "C" void Shooting__ctor_m2748436320 (Shooting_t3467275689 * __this, const MethodInfo* method)
{
{
__this->set_muzzleFlashTimer_9((0.3f));
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void Shooting::Start()
extern "C" void Shooting_Start_m1677191848 (Shooting_t3467275689 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get_muzzleFlashTimer_9();
__this->set_muzzleFlashTimerStart_10(L_0);
return;
}
}
// System.Void Shooting::Update()
extern "C" void Shooting_Update_m1217253073 (Shooting_t3467275689 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (Shooting_Update_m1217253073_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Shooting_changeToggle_m2373192642(__this, /*hidden argument*/NULL);
float L_0 = __this->get_timeElapsed_14();
if ((!(((float)L_0) > ((float)(1.0f)))))
{
goto IL_002d;
}
}
{
__this->set_canShoot_12((bool)1);
__this->set_timeElapsed_14((0.0f));
goto IL_003f;
}
IL_002d:
{
float L_1 = __this->get_timeElapsed_14();
float L_2 = Time_get_deltaTime_m2233168104(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_timeElapsed_14(((float)((float)L_1+(float)L_2)));
}
IL_003f:
{
bool L_3 = __this->get_muzzleFlashEnabled_11();
if (!L_3)
{
goto IL_007d;
}
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral2571969280, /*hidden argument*/NULL);
AudioSource_t1135106623 * L_4 = __this->get_bulletSound_7();
NullCheck(L_4);
AudioSource_Play_m353744792(L_4, /*hidden argument*/NULL);
GameObject_t1756533147 * L_5 = __this->get_muzzleFlashObject_8();
NullCheck(L_5);
GameObject_SetActive_m2887581199(L_5, (bool)1, /*hidden argument*/NULL);
float L_6 = __this->get_muzzleFlashTimer_9();
float L_7 = Time_get_deltaTime_m2233168104(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_muzzleFlashTimer_9(((float)((float)L_6-(float)L_7)));
}
IL_007d:
{
float L_8 = __this->get_muzzleFlashTimer_9();
if ((!(((float)L_8) <= ((float)(0.0f)))))
{
goto IL_00ac;
}
}
{
GameObject_t1756533147 * L_9 = __this->get_muzzleFlashObject_8();
NullCheck(L_9);
GameObject_SetActive_m2887581199(L_9, (bool)0, /*hidden argument*/NULL);
__this->set_muzzleFlashEnabled_11((bool)0);
float L_10 = __this->get_muzzleFlashTimerStart_10();
__this->set_muzzleFlashTimer_9(L_10);
}
IL_00ac:
{
return;
}
}
// System.Void Shooting::changeToggle()
extern "C" void Shooting_changeToggle_m2373192642 (Shooting_t3467275689 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (Shooting_changeToggle_m2373192642_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
GameObject_t1756533147 * L_0 = __this->get_toggleButton_4();
NullCheck(L_0);
Toggle_t3976754468 * L_1 = GameObject_GetComponent_TisToggle_t3976754468_m4141321564(L_0, /*hidden argument*/GameObject_GetComponent_TisToggle_t3976754468_m4141321564_MethodInfo_var);
NullCheck(L_1);
bool L_2 = Toggle_get_isOn_m366838229(L_1, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0021;
}
}
{
__this->set_toggled_13((bool)1);
goto IL_0028;
}
IL_0021:
{
__this->set_toggled_13((bool)0);
}
IL_0028:
{
return;
}
}
// System.Void Shooting::Shoot()
extern "C" void Shooting_Shoot_m2001385207 (Shooting_t3467275689 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (Shooting_Shoot_m2001385207_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
RaycastHit_t87180320 V_0;
memset(&V_0, 0, sizeof(V_0));
GameObject_t1756533147 * V_1 = NULL;
{
bool L_0 = __this->get_toggled_13();
if (!L_0)
{
goto IL_00bc;
}
}
{
bool L_1 = __this->get_canShoot_12();
if (!L_1)
{
goto IL_00b7;
}
}
{
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral2965611210, /*hidden argument*/NULL);
__this->set_muzzleFlashEnabled_11((bool)1);
__this->set_canShoot_12((bool)0);
Camera_t189460977 * L_2 = Camera_get_main_m475173995(NULL /*static, unused*/, /*hidden argument*/NULL);
Vector3_t2243707580 L_3;
memset(&L_3, 0, sizeof(L_3));
Vector3__ctor_m2638739322(&L_3, (0.5f), (0.5f), (0.0f), /*hidden argument*/NULL);
NullCheck(L_2);
Ray_t2469606224 L_4 = Camera_ViewportPointToRay_m1799506792(L_2, L_3, /*hidden argument*/NULL);
bool L_5 = Physics_Raycast_m2308457076(NULL /*static, unused*/, L_4, (&V_0), (std::numeric_limits<float>::infinity()), /*hidden argument*/NULL);
if (!L_5)
{
goto IL_00b7;
}
}
{
Collider_t3497673348 * L_6 = RaycastHit_get_collider_m301198172((&V_0), /*hidden argument*/NULL);
NullCheck(L_6);
String_t* L_7 = Object_get_name_m2079638459(L_6, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, L_7, /*hidden argument*/NULL);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral3542231828, /*hidden argument*/NULL);
Collider_t3497673348 * L_8 = RaycastHit_get_collider_m301198172((&V_0), /*hidden argument*/NULL);
NullCheck(L_8);
GameObject_t1756533147 * L_9 = Component_get_gameObject_m3105766835(L_8, /*hidden argument*/NULL);
NullCheck(L_9);
Transform_t3275118058 * L_10 = GameObject_get_transform_m909382139(L_9, /*hidden argument*/NULL);
NullCheck(L_10);
Transform_t3275118058 * L_11 = Transform_get_parent_m147407266(L_10, /*hidden argument*/NULL);
NullCheck(L_11);
GameObject_t1756533147 * L_12 = Component_get_gameObject_m3105766835(L_11, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
Object_Destroy_m4145850038(NULL /*static, unused*/, L_12, /*hidden argument*/NULL);
GameObject_t1756533147 * L_13 = __this->get_particleEffect_3();
Vector3_t2243707580 L_14 = RaycastHit_get_point_m326143462((&V_0), /*hidden argument*/NULL);
Vector3_t2243707580 L_15 = RaycastHit_get_normal_m817665579((&V_0), /*hidden argument*/NULL);
Quaternion_t4030073918 L_16 = Quaternion_Euler_m3586339259(NULL /*static, unused*/, L_15, /*hidden argument*/NULL);
Object_Instantiate_TisGameObject_t1756533147_m3186302158(NULL /*static, unused*/, L_13, L_14, L_16, /*hidden argument*/Object_Instantiate_TisGameObject_t1756533147_m3186302158_MethodInfo_var);
}
IL_00b7:
{
goto IL_0132;
}
IL_00bc:
{
bool L_17 = __this->get_canShoot_12();
if (!L_17)
{
goto IL_0132;
}
}
{
__this->set_canShoot_12((bool)0);
__this->set_muzzleFlashEnabled_11((bool)1);
IL2CPP_RUNTIME_CLASS_INIT(Debug_t1368543263_il2cpp_TypeInfo_var);
Debug_Log_m920475918(NULL /*static, unused*/, _stringLiteral1777526720, /*hidden argument*/NULL);
GameObject_t1756533147 * L_18 = __this->get_bullet_6();
Camera_t189460977 * L_19 = Camera_get_main_m475173995(NULL /*static, unused*/, /*hidden argument*/NULL);
Vector3_t2243707580 L_20;
memset(&L_20, 0, sizeof(L_20));
Vector3__ctor_m2638739322(&L_20, (0.5f), (0.25f), (0.0f), /*hidden argument*/NULL);
NullCheck(L_19);
Vector3_t2243707580 L_21 = Camera_ViewportToWorldPoint_m3841010930(L_19, L_20, /*hidden argument*/NULL);
Quaternion_t4030073918 L_22 = Quaternion_get_identity_m1561886418(NULL /*static, unused*/, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
GameObject_t1756533147 * L_23 = Object_Instantiate_TisGameObject_t1756533147_m3186302158(NULL /*static, unused*/, L_18, L_21, L_22, /*hidden argument*/Object_Instantiate_TisGameObject_t1756533147_m3186302158_MethodInfo_var);
V_1 = L_23;
GameObject_t1756533147 * L_24 = V_1;
NullCheck(L_24);
Rigidbody_t4233889191 * L_25 = GameObject_GetComponent_TisRigidbody_t4233889191_m1060888193(L_24, /*hidden argument*/GameObject_GetComponent_TisRigidbody_t4233889191_m1060888193_MethodInfo_var);
Camera_t189460977 * L_26 = Camera_get_main_m475173995(NULL /*static, unused*/, /*hidden argument*/NULL);
NullCheck(L_26);
Transform_t3275118058 * L_27 = Component_get_transform_m2697483695(L_26, /*hidden argument*/NULL);
NullCheck(L_27);
Vector3_t2243707580 L_28 = Transform_get_forward_m1833488937(L_27, /*hidden argument*/NULL);
Vector3_t2243707580 L_29 = Vector3_op_Multiply_m1351554733(NULL /*static, unused*/, L_28, (1000.0f), /*hidden argument*/NULL);
NullCheck(L_25);
Rigidbody_AddForce_m2836187433(L_25, L_29, /*hidden argument*/NULL);
}
IL_0132:
{
return;
}
}
// System.Void SVBoxSlider::.ctor()
extern "C" void SVBoxSlider__ctor_m2623596066 (SVBoxSlider_t1173082351 * __this, const MethodInfo* method)
{
{
__this->set_lastH_5((-1.0f));
__this->set_listen_6((bool)1);
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// UnityEngine.RectTransform SVBoxSlider::get_rectTransform()
extern "C" RectTransform_t3349966182 * SVBoxSlider_get_rectTransform_m3427717911 (SVBoxSlider_t1173082351 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (SVBoxSlider_get_rectTransform_m3427717911_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Transform_t3275118058 * L_0 = Component_get_transform_m2697483695(__this, /*hidden argument*/NULL);
return ((RectTransform_t3349966182 *)IsInstSealed(L_0, RectTransform_t3349966182_il2cpp_TypeInfo_var));
}
}
// System.Void SVBoxSlider::Awake()
extern "C" void SVBoxSlider_Awake_m1174811035 (SVBoxSlider_t1173082351 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (SVBoxSlider_Awake_m1174811035_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
BoxSlider_t1871650694 * L_0 = Component_GetComponent_TisBoxSlider_t1871650694_m3168588160(__this, /*hidden argument*/Component_GetComponent_TisBoxSlider_t1871650694_m3168588160_MethodInfo_var);
__this->set_slider_3(L_0);
RawImage_t2749640213 * L_1 = Component_GetComponent_TisRawImage_t2749640213_m1817787565(__this, /*hidden argument*/Component_GetComponent_TisRawImage_t2749640213_m1817787565_MethodInfo_var);
__this->set_image_4(L_1);
SVBoxSlider_RegenerateSVTexture_m4094171080(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void SVBoxSlider::OnEnable()
extern "C" void SVBoxSlider_OnEnable_m542656758 (SVBoxSlider_t1173082351 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (SVBoxSlider_OnEnable_m542656758_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
bool L_0 = Application_get_isPlaying_m4091950718(NULL /*static, unused*/, /*hidden argument*/NULL);
if (!L_0)
{
goto IL_0053;
}
}
{
ColorPicker_t3035206225 * L_1 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_2 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_1, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0053;
}
}
{
BoxSlider_t1871650694 * L_3 = __this->get_slider_3();
NullCheck(L_3);
BoxSliderEvent_t1774115848 * L_4 = BoxSlider_get_onValueChanged_m1694276966(L_3, /*hidden argument*/NULL);
IntPtr_t L_5;
L_5.set_m_value_0((void*)(void*)SVBoxSlider_SliderChanged_m3739635521_MethodInfo_var);
UnityAction_2_t134459182 * L_6 = (UnityAction_2_t134459182 *)il2cpp_codegen_object_new(UnityAction_2_t134459182_il2cpp_TypeInfo_var);
UnityAction_2__ctor_m2891411084(L_6, __this, L_5, /*hidden argument*/UnityAction_2__ctor_m2891411084_MethodInfo_var);
NullCheck(L_4);
UnityEvent_2_AddListener_m297354571(L_4, L_6, /*hidden argument*/UnityEvent_2_AddListener_m297354571_MethodInfo_var);
ColorPicker_t3035206225 * L_7 = __this->get_picker_2();
NullCheck(L_7);
HSVChangedEvent_t1170297569 * L_8 = L_7->get_onHSVChanged_10();
IntPtr_t L_9;
L_9.set_m_value_0((void*)(void*)SVBoxSlider_HSVChanged_m3533720340_MethodInfo_var);
UnityAction_3_t235051313 * L_10 = (UnityAction_3_t235051313 *)il2cpp_codegen_object_new(UnityAction_3_t235051313_il2cpp_TypeInfo_var);
UnityAction_3__ctor_m3626891334(L_10, __this, L_9, /*hidden argument*/UnityAction_3__ctor_m3626891334_MethodInfo_var);
NullCheck(L_8);
UnityEvent_3_AddListener_m3608966849(L_8, L_10, /*hidden argument*/UnityEvent_3_AddListener_m3608966849_MethodInfo_var);
}
IL_0053:
{
return;
}
}
// System.Void SVBoxSlider::OnDisable()
extern "C" void SVBoxSlider_OnDisable_m2237433047 (SVBoxSlider_t1173082351 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (SVBoxSlider_OnDisable_m2237433047_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_0, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0049;
}
}
{
BoxSlider_t1871650694 * L_2 = __this->get_slider_3();
NullCheck(L_2);
BoxSliderEvent_t1774115848 * L_3 = BoxSlider_get_onValueChanged_m1694276966(L_2, /*hidden argument*/NULL);
IntPtr_t L_4;
L_4.set_m_value_0((void*)(void*)SVBoxSlider_SliderChanged_m3739635521_MethodInfo_var);
UnityAction_2_t134459182 * L_5 = (UnityAction_2_t134459182 *)il2cpp_codegen_object_new(UnityAction_2_t134459182_il2cpp_TypeInfo_var);
UnityAction_2__ctor_m2891411084(L_5, __this, L_4, /*hidden argument*/UnityAction_2__ctor_m2891411084_MethodInfo_var);
NullCheck(L_3);
UnityEvent_2_RemoveListener_m491466926(L_3, L_5, /*hidden argument*/UnityEvent_2_RemoveListener_m491466926_MethodInfo_var);
ColorPicker_t3035206225 * L_6 = __this->get_picker_2();
NullCheck(L_6);
HSVChangedEvent_t1170297569 * L_7 = L_6->get_onHSVChanged_10();
IntPtr_t L_8;
L_8.set_m_value_0((void*)(void*)SVBoxSlider_HSVChanged_m3533720340_MethodInfo_var);
UnityAction_3_t235051313 * L_9 = (UnityAction_3_t235051313 *)il2cpp_codegen_object_new(UnityAction_3_t235051313_il2cpp_TypeInfo_var);
UnityAction_3__ctor_m3626891334(L_9, __this, L_8, /*hidden argument*/UnityAction_3__ctor_m3626891334_MethodInfo_var);
NullCheck(L_7);
UnityEvent_3_RemoveListener_m2407167912(L_7, L_9, /*hidden argument*/UnityEvent_3_RemoveListener_m2407167912_MethodInfo_var);
}
IL_0049:
{
return;
}
}
// System.Void SVBoxSlider::OnDestroy()
extern "C" void SVBoxSlider_OnDestroy_m1087675145 (SVBoxSlider_t1173082351 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (SVBoxSlider_OnDestroy_m1087675145_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
RawImage_t2749640213 * L_0 = __this->get_image_4();
NullCheck(L_0);
Texture_t2243626319 * L_1 = RawImage_get_texture_m2258734143(L_0, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_2 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_1, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0026;
}
}
{
RawImage_t2749640213 * L_3 = __this->get_image_4();
NullCheck(L_3);
Texture_t2243626319 * L_4 = RawImage_get_texture_m2258734143(L_3, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
Object_DestroyImmediate_m95027445(NULL /*static, unused*/, L_4, /*hidden argument*/NULL);
}
IL_0026:
{
return;
}
}
// System.Void SVBoxSlider::SliderChanged(System.Single,System.Single)
extern "C" void SVBoxSlider_SliderChanged_m3739635521 (SVBoxSlider_t1173082351 * __this, float ___saturation0, float ___value1, const MethodInfo* method)
{
{
bool L_0 = __this->get_listen_6();
if (!L_0)
{
goto IL_0025;
}
}
{
ColorPicker_t3035206225 * L_1 = __this->get_picker_2();
float L_2 = ___saturation0;
NullCheck(L_1);
ColorPicker_AssignColor_m579716850(L_1, 5, L_2, /*hidden argument*/NULL);
ColorPicker_t3035206225 * L_3 = __this->get_picker_2();
float L_4 = ___value1;
NullCheck(L_3);
ColorPicker_AssignColor_m579716850(L_3, 6, L_4, /*hidden argument*/NULL);
}
IL_0025:
{
__this->set_listen_6((bool)1);
return;
}
}
// System.Void SVBoxSlider::HSVChanged(System.Single,System.Single,System.Single)
extern "C" void SVBoxSlider_HSVChanged_m3533720340 (SVBoxSlider_t1173082351 * __this, float ___h0, float ___s1, float ___v2, const MethodInfo* method)
{
{
float L_0 = __this->get_lastH_5();
float L_1 = ___h0;
if ((((float)L_0) == ((float)L_1)))
{
goto IL_0019;
}
}
{
float L_2 = ___h0;
__this->set_lastH_5(L_2);
SVBoxSlider_RegenerateSVTexture_m4094171080(__this, /*hidden argument*/NULL);
}
IL_0019:
{
float L_3 = ___s1;
BoxSlider_t1871650694 * L_4 = __this->get_slider_3();
NullCheck(L_4);
float L_5 = BoxSlider_get_normalizedValue_m911068691(L_4, /*hidden argument*/NULL);
if ((((float)L_3) == ((float)L_5)))
{
goto IL_003d;
}
}
{
__this->set_listen_6((bool)0);
BoxSlider_t1871650694 * L_6 = __this->get_slider_3();
float L_7 = ___s1;
NullCheck(L_6);
BoxSlider_set_normalizedValue_m2010660092(L_6, L_7, /*hidden argument*/NULL);
}
IL_003d:
{
float L_8 = ___v2;
BoxSlider_t1871650694 * L_9 = __this->get_slider_3();
NullCheck(L_9);
float L_10 = BoxSlider_get_normalizedValueY_m3976688554(L_9, /*hidden argument*/NULL);
if ((((float)L_8) == ((float)L_10)))
{
goto IL_0061;
}
}
{
__this->set_listen_6((bool)0);
BoxSlider_t1871650694 * L_11 = __this->get_slider_3();
float L_12 = ___v2;
NullCheck(L_11);
BoxSlider_set_normalizedValueY_m851020601(L_11, L_12, /*hidden argument*/NULL);
}
IL_0061:
{
return;
}
}
// System.Void SVBoxSlider::RegenerateSVTexture()
extern "C" void SVBoxSlider_RegenerateSVTexture_m4094171080 (SVBoxSlider_t1173082351 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (SVBoxSlider_RegenerateSVTexture_m4094171080_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
double V_0 = 0.0;
Texture2D_t3542995729 * V_1 = NULL;
int32_t V_2 = 0;
Color32U5BU5D_t30278651* V_3 = NULL;
int32_t V_4 = 0;
float G_B3_0 = 0.0f;
{
ColorPicker_t3035206225 * L_0 = __this->get_picker_2();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_0, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0027;
}
}
{
ColorPicker_t3035206225 * L_2 = __this->get_picker_2();
NullCheck(L_2);
float L_3 = ColorPicker_get_H_m3860865411(L_2, /*hidden argument*/NULL);
G_B3_0 = ((float)((float)L_3*(float)(360.0f)));
goto IL_002c;
}
IL_0027:
{
G_B3_0 = (0.0f);
}
IL_002c:
{
V_0 = (((double)((double)G_B3_0)));
RawImage_t2749640213 * L_4 = __this->get_image_4();
NullCheck(L_4);
Texture_t2243626319 * L_5 = RawImage_get_texture_m2258734143(L_4, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_6 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_5, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_6)
{
goto IL_0054;
}
}
{
RawImage_t2749640213 * L_7 = __this->get_image_4();
NullCheck(L_7);
Texture_t2243626319 * L_8 = RawImage_get_texture_m2258734143(L_7, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
Object_DestroyImmediate_m95027445(NULL /*static, unused*/, L_8, /*hidden argument*/NULL);
}
IL_0054:
{
Texture2D_t3542995729 * L_9 = (Texture2D_t3542995729 *)il2cpp_codegen_object_new(Texture2D_t3542995729_il2cpp_TypeInfo_var);
Texture2D__ctor_m3598323350(L_9, ((int32_t)100), ((int32_t)100), /*hidden argument*/NULL);
V_1 = L_9;
Texture2D_t3542995729 * L_10 = V_1;
NullCheck(L_10);
Object_set_hideFlags_m2204253440(L_10, ((int32_t)52), /*hidden argument*/NULL);
V_2 = 0;
goto IL_00cc;
}
IL_006d:
{
V_3 = ((Color32U5BU5D_t30278651*)SZArrayNew(Color32U5BU5D_t30278651_il2cpp_TypeInfo_var, (uint32_t)((int32_t)100)));
V_4 = 0;
goto IL_00b3;
}
IL_007d:
{
Color32U5BU5D_t30278651* L_11 = V_3;
int32_t L_12 = V_4;
NullCheck(L_11);
double L_13 = V_0;
int32_t L_14 = V_2;
int32_t L_15 = V_4;
Color_t2020392075 L_16 = HSVUtil_ConvertHsvToRgb_m2339284600(NULL /*static, unused*/, L_13, (((double)((double)((float)((float)(((float)((float)L_14)))/(float)(100.0f)))))), (((double)((double)((float)((float)(((float)((float)L_15)))/(float)(100.0f)))))), (1.0f), /*hidden argument*/NULL);
Color32_t874517518 L_17 = Color32_op_Implicit_m624191464(NULL /*static, unused*/, L_16, /*hidden argument*/NULL);
(*(Color32_t874517518 *)((L_11)->GetAddressAt(static_cast<il2cpp_array_size_t>(L_12)))) = L_17;
int32_t L_18 = V_4;
V_4 = ((int32_t)((int32_t)L_18+(int32_t)1));
}
IL_00b3:
{
int32_t L_19 = V_4;
if ((((int32_t)L_19) < ((int32_t)((int32_t)100))))
{
goto IL_007d;
}
}
{
Texture2D_t3542995729 * L_20 = V_1;
int32_t L_21 = V_2;
Color32U5BU5D_t30278651* L_22 = V_3;
NullCheck(L_20);
Texture2D_SetPixels32_m1440518781(L_20, L_21, 0, 1, ((int32_t)100), L_22, /*hidden argument*/NULL);
int32_t L_23 = V_2;
V_2 = ((int32_t)((int32_t)L_23+(int32_t)1));
}
IL_00cc:
{
int32_t L_24 = V_2;
if ((((int32_t)L_24) < ((int32_t)((int32_t)100))))
{
goto IL_006d;
}
}
{
Texture2D_t3542995729 * L_25 = V_1;
NullCheck(L_25);
Texture2D_Apply_m3543341930(L_25, /*hidden argument*/NULL);
RawImage_t2749640213 * L_26 = __this->get_image_4();
Texture2D_t3542995729 * L_27 = V_1;
NullCheck(L_26);
RawImage_set_texture_m2400157626(L_26, L_27, /*hidden argument*/NULL);
return;
}
}
// System.Void TiltWindow::.ctor()
extern "C" void TiltWindow__ctor_m3071582230 (TiltWindow_t1839185375 * __this, const MethodInfo* method)
{
{
Vector2_t2243707579 L_0;
memset(&L_0, 0, sizeof(L_0));
Vector2__ctor_m3067419446(&L_0, (5.0f), (3.0f), /*hidden argument*/NULL);
__this->set_range_2(L_0);
Vector2_t2243707579 L_1 = Vector2_get_zero_m3966848876(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_mRot_5(L_1);
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void TiltWindow::Start()
extern "C" void TiltWindow_Start_m3112429194 (TiltWindow_t1839185375 * __this, const MethodInfo* method)
{
{
Transform_t3275118058 * L_0 = Component_get_transform_m2697483695(__this, /*hidden argument*/NULL);
__this->set_mTrans_3(L_0);
Transform_t3275118058 * L_1 = __this->get_mTrans_3();
NullCheck(L_1);
Quaternion_t4030073918 L_2 = Transform_get_localRotation_m4001487205(L_1, /*hidden argument*/NULL);
__this->set_mStart_4(L_2);
return;
}
}
// System.Void TiltWindow::Update()
extern "C" void TiltWindow_Update_m460467911 (TiltWindow_t1839185375 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (TiltWindow_Update_m460467911_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Vector3_t2243707580 V_0;
memset(&V_0, 0, sizeof(V_0));
float V_1 = 0.0f;
float V_2 = 0.0f;
float V_3 = 0.0f;
float V_4 = 0.0f;
{
IL2CPP_RUNTIME_CLASS_INIT(Input_t1785128008_il2cpp_TypeInfo_var);
Vector3_t2243707580 L_0 = Input_get_mousePosition_m146923508(NULL /*static, unused*/, /*hidden argument*/NULL);
V_0 = L_0;
int32_t L_1 = Screen_get_width_m41137238(NULL /*static, unused*/, /*hidden argument*/NULL);
V_1 = ((float)((float)(((float)((float)L_1)))*(float)(0.5f)));
int32_t L_2 = Screen_get_height_m1051800773(NULL /*static, unused*/, /*hidden argument*/NULL);
V_2 = ((float)((float)(((float)((float)L_2)))*(float)(0.5f)));
float L_3 = (&V_0)->get_x_1();
float L_4 = V_1;
float L_5 = V_1;
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_6 = Mathf_Clamp_m2354025655(NULL /*static, unused*/, ((float)((float)((float)((float)L_3-(float)L_4))/(float)L_5)), (-1.0f), (1.0f), /*hidden argument*/NULL);
V_3 = L_6;
float L_7 = (&V_0)->get_y_2();
float L_8 = V_2;
float L_9 = V_2;
float L_10 = Mathf_Clamp_m2354025655(NULL /*static, unused*/, ((float)((float)((float)((float)L_7-(float)L_8))/(float)L_9)), (-1.0f), (1.0f), /*hidden argument*/NULL);
V_4 = L_10;
Vector2_t2243707579 L_11 = __this->get_mRot_5();
float L_12 = V_3;
float L_13 = V_4;
Vector2_t2243707579 L_14;
memset(&L_14, 0, sizeof(L_14));
Vector2__ctor_m3067419446(&L_14, L_12, L_13, /*hidden argument*/NULL);
float L_15 = Time_get_deltaTime_m2233168104(NULL /*static, unused*/, /*hidden argument*/NULL);
Vector2_t2243707579 L_16 = Vector2_Lerp_m1511850087(NULL /*static, unused*/, L_11, L_14, ((float)((float)L_15*(float)(5.0f))), /*hidden argument*/NULL);
__this->set_mRot_5(L_16);
Transform_t3275118058 * L_17 = __this->get_mTrans_3();
Quaternion_t4030073918 L_18 = __this->get_mStart_4();
Vector2_t2243707579 * L_19 = __this->get_address_of_mRot_5();
float L_20 = L_19->get_y_1();
Vector2_t2243707579 * L_21 = __this->get_address_of_range_2();
float L_22 = L_21->get_y_1();
Vector2_t2243707579 * L_23 = __this->get_address_of_mRot_5();
float L_24 = L_23->get_x_0();
Vector2_t2243707579 * L_25 = __this->get_address_of_range_2();
float L_26 = L_25->get_x_0();
Quaternion_t4030073918 L_27 = Quaternion_Euler_m2887458175(NULL /*static, unused*/, ((float)((float)((-L_20))*(float)L_22)), ((float)((float)L_24*(float)L_26)), (0.0f), /*hidden argument*/NULL);
Quaternion_t4030073918 L_28 = Quaternion_op_Multiply_m2426727589(NULL /*static, unused*/, L_18, L_27, /*hidden argument*/NULL);
NullCheck(L_17);
Transform_set_localRotation_m2055111962(L_17, L_28, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::.ctor()
extern "C" void BoxSlider__ctor_m1006728114 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider__ctor_m1006728114_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
__this->set_m_MaxValue_18((1.0f));
__this->set_m_Value_20((1.0f));
__this->set_m_ValueY_21((1.0f));
BoxSliderEvent_t1774115848 * L_0 = (BoxSliderEvent_t1774115848 *)il2cpp_codegen_object_new(BoxSliderEvent_t1774115848_il2cpp_TypeInfo_var);
BoxSliderEvent__ctor_m304261805(L_0, /*hidden argument*/NULL);
__this->set_m_OnValueChanged_22(L_0);
Vector2_t2243707579 L_1 = Vector2_get_zero_m3966848876(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_m_Offset_25(L_1);
IL2CPP_RUNTIME_CLASS_INIT(Selectable_t1490392188_il2cpp_TypeInfo_var);
Selectable__ctor_m1440593935(__this, /*hidden argument*/NULL);
return;
}
}
// UnityEngine.RectTransform UnityEngine.UI.BoxSlider::get_handleRect()
extern "C" RectTransform_t3349966182 * BoxSlider_get_handleRect_m2621304777 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
RectTransform_t3349966182 * L_0 = __this->get_m_HandleRect_16();
return L_0;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_handleRect(UnityEngine.RectTransform)
extern "C" void BoxSlider_set_handleRect_m168119168 (BoxSlider_t1871650694 * __this, RectTransform_t3349966182 * ___value0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_set_handleRect_m168119168_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
RectTransform_t3349966182 ** L_0 = __this->get_address_of_m_HandleRect_16();
RectTransform_t3349966182 * L_1 = ___value0;
bool L_2 = BoxSlider_SetClass_TisRectTransform_t3349966182_m272479997(NULL /*static, unused*/, L_0, L_1, /*hidden argument*/BoxSlider_SetClass_TisRectTransform_t3349966182_m272479997_MethodInfo_var);
if (!L_2)
{
goto IL_001d;
}
}
{
BoxSlider_UpdateCachedReferences_m3248150675(__this, /*hidden argument*/NULL);
BoxSlider_UpdateVisuals_m495585056(__this, /*hidden argument*/NULL);
}
IL_001d:
{
return;
}
}
// System.Single UnityEngine.UI.BoxSlider::get_minValue()
extern "C" float BoxSlider_get_minValue_m3041624170 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get_m_MinValue_17();
return L_0;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_minValue(System.Single)
extern "C" void BoxSlider_set_minValue_m1004770411 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_set_minValue_m1004770411_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
float* L_0 = __this->get_address_of_m_MinValue_17();
float L_1 = ___value0;
bool L_2 = BoxSlider_SetStruct_TisSingle_t2076509932_m2710312218(NULL /*static, unused*/, L_0, L_1, /*hidden argument*/BoxSlider_SetStruct_TisSingle_t2076509932_m2710312218_MethodInfo_var);
if (!L_2)
{
goto IL_002f;
}
}
{
float L_3 = __this->get_m_Value_20();
BoxSlider_Set_m3989333985(__this, L_3, /*hidden argument*/NULL);
float L_4 = __this->get_m_ValueY_21();
BoxSlider_SetY_m1241843396(__this, L_4, /*hidden argument*/NULL);
BoxSlider_UpdateVisuals_m495585056(__this, /*hidden argument*/NULL);
}
IL_002f:
{
return;
}
}
// System.Single UnityEngine.UI.BoxSlider::get_maxValue()
extern "C" float BoxSlider_get_maxValue_m1317285860 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
float L_0 = __this->get_m_MaxValue_18();
return L_0;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_maxValue(System.Single)
extern "C" void BoxSlider_set_maxValue_m1702472861 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_set_maxValue_m1702472861_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
float* L_0 = __this->get_address_of_m_MaxValue_18();
float L_1 = ___value0;
bool L_2 = BoxSlider_SetStruct_TisSingle_t2076509932_m2710312218(NULL /*static, unused*/, L_0, L_1, /*hidden argument*/BoxSlider_SetStruct_TisSingle_t2076509932_m2710312218_MethodInfo_var);
if (!L_2)
{
goto IL_002f;
}
}
{
float L_3 = __this->get_m_Value_20();
BoxSlider_Set_m3989333985(__this, L_3, /*hidden argument*/NULL);
float L_4 = __this->get_m_ValueY_21();
BoxSlider_SetY_m1241843396(__this, L_4, /*hidden argument*/NULL);
BoxSlider_UpdateVisuals_m495585056(__this, /*hidden argument*/NULL);
}
IL_002f:
{
return;
}
}
// System.Boolean UnityEngine.UI.BoxSlider::get_wholeNumbers()
extern "C" bool BoxSlider_get_wholeNumbers_m627638124 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
bool L_0 = __this->get_m_WholeNumbers_19();
return L_0;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_wholeNumbers(System.Boolean)
extern "C" void BoxSlider_set_wholeNumbers_m2694006389 (BoxSlider_t1871650694 * __this, bool ___value0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_set_wholeNumbers_m2694006389_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
bool* L_0 = __this->get_address_of_m_WholeNumbers_19();
bool L_1 = ___value0;
bool L_2 = BoxSlider_SetStruct_TisBoolean_t3825574718_m1967921404(NULL /*static, unused*/, L_0, L_1, /*hidden argument*/BoxSlider_SetStruct_TisBoolean_t3825574718_m1967921404_MethodInfo_var);
if (!L_2)
{
goto IL_002f;
}
}
{
float L_3 = __this->get_m_Value_20();
BoxSlider_Set_m3989333985(__this, L_3, /*hidden argument*/NULL);
float L_4 = __this->get_m_ValueY_21();
BoxSlider_SetY_m1241843396(__this, L_4, /*hidden argument*/NULL);
BoxSlider_UpdateVisuals_m495585056(__this, /*hidden argument*/NULL);
}
IL_002f:
{
return;
}
}
// System.Single UnityEngine.UI.BoxSlider::get_value()
extern "C" float BoxSlider_get_value_m2439160562 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_get_value_m2439160562_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
bool L_0 = BoxSlider_get_wholeNumbers_m627638124(__this, /*hidden argument*/NULL);
if (!L_0)
{
goto IL_0017;
}
}
{
float L_1 = __this->get_m_Value_20();
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_2 = bankers_roundf(L_1);
return L_2;
}
IL_0017:
{
float L_3 = __this->get_m_Value_20();
return L_3;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_value(System.Single)
extern "C" void BoxSlider_set_value_m3164710557 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = ___value0;
BoxSlider_Set_m3989333985(__this, L_0, /*hidden argument*/NULL);
return;
}
}
// System.Single UnityEngine.UI.BoxSlider::get_normalizedValue()
extern "C" float BoxSlider_get_normalizedValue_m911068691 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_get_normalizedValue_m911068691_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
float L_0 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
float L_1 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
bool L_2 = Mathf_Approximately_m1064446634(NULL /*static, unused*/, L_0, L_1, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_001c;
}
}
{
return (0.0f);
}
IL_001c:
{
float L_3 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
float L_4 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
float L_5 = BoxSlider_get_value_m2439160562(__this, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_6 = Mathf_InverseLerp_m55890283(NULL /*static, unused*/, L_3, L_4, L_5, /*hidden argument*/NULL);
return L_6;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_normalizedValue(System.Single)
extern "C" void BoxSlider_set_normalizedValue_m2010660092 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_set_normalizedValue_m2010660092_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
float L_0 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
float L_1 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
float L_2 = ___value0;
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_3 = Mathf_Lerp_m1686556575(NULL /*static, unused*/, L_0, L_1, L_2, /*hidden argument*/NULL);
BoxSlider_set_value_m3164710557(__this, L_3, /*hidden argument*/NULL);
return;
}
}
// System.Single UnityEngine.UI.BoxSlider::get_valueY()
extern "C" float BoxSlider_get_valueY_m2581533163 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_get_valueY_m2581533163_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
bool L_0 = BoxSlider_get_wholeNumbers_m627638124(__this, /*hidden argument*/NULL);
if (!L_0)
{
goto IL_0017;
}
}
{
float L_1 = __this->get_m_ValueY_21();
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_2 = bankers_roundf(L_1);
return L_2;
}
IL_0017:
{
float L_3 = __this->get_m_ValueY_21();
return L_3;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_valueY(System.Single)
extern "C" void BoxSlider_set_valueY_m2217414554 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method)
{
{
float L_0 = ___value0;
BoxSlider_SetY_m1241843396(__this, L_0, /*hidden argument*/NULL);
return;
}
}
// System.Single UnityEngine.UI.BoxSlider::get_normalizedValueY()
extern "C" float BoxSlider_get_normalizedValueY_m3976688554 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_get_normalizedValueY_m3976688554_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
float L_0 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
float L_1 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
bool L_2 = Mathf_Approximately_m1064446634(NULL /*static, unused*/, L_0, L_1, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_001c;
}
}
{
return (0.0f);
}
IL_001c:
{
float L_3 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
float L_4 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
float L_5 = BoxSlider_get_valueY_m2581533163(__this, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_6 = Mathf_InverseLerp_m55890283(NULL /*static, unused*/, L_3, L_4, L_5, /*hidden argument*/NULL);
return L_6;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_normalizedValueY(System.Single)
extern "C" void BoxSlider_set_normalizedValueY_m851020601 (BoxSlider_t1871650694 * __this, float ___value0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_set_normalizedValueY_m851020601_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
float L_0 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
float L_1 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
float L_2 = ___value0;
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_3 = Mathf_Lerp_m1686556575(NULL /*static, unused*/, L_0, L_1, L_2, /*hidden argument*/NULL);
BoxSlider_set_valueY_m2217414554(__this, L_3, /*hidden argument*/NULL);
return;
}
}
// UnityEngine.UI.BoxSlider/BoxSliderEvent UnityEngine.UI.BoxSlider::get_onValueChanged()
extern "C" BoxSliderEvent_t1774115848 * BoxSlider_get_onValueChanged_m1694276966 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
BoxSliderEvent_t1774115848 * L_0 = __this->get_m_OnValueChanged_22();
return L_0;
}
}
// System.Void UnityEngine.UI.BoxSlider::set_onValueChanged(UnityEngine.UI.BoxSlider/BoxSliderEvent)
extern "C" void BoxSlider_set_onValueChanged_m1579271121 (BoxSlider_t1871650694 * __this, BoxSliderEvent_t1774115848 * ___value0, const MethodInfo* method)
{
{
BoxSliderEvent_t1774115848 * L_0 = ___value0;
__this->set_m_OnValueChanged_22(L_0);
return;
}
}
// System.Single UnityEngine.UI.BoxSlider::get_stepSize()
extern "C" float BoxSlider_get_stepSize_m1073340932 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
float G_B3_0 = 0.0f;
{
bool L_0 = BoxSlider_get_wholeNumbers_m627638124(__this, /*hidden argument*/NULL);
if (!L_0)
{
goto IL_0015;
}
}
{
G_B3_0 = (1.0f);
goto IL_0028;
}
IL_0015:
{
float L_1 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
float L_2 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
G_B3_0 = ((float)((float)((float)((float)L_1-(float)L_2))*(float)(0.1f)));
}
IL_0028:
{
return G_B3_0;
}
}
// System.Void UnityEngine.UI.BoxSlider::Rebuild(UnityEngine.UI.CanvasUpdate)
extern "C" void BoxSlider_Rebuild_m3577117895 (BoxSlider_t1871650694 * __this, int32_t ___executing0, const MethodInfo* method)
{
{
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::LayoutComplete()
extern "C" void BoxSlider_LayoutComplete_m2656874525 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::GraphicUpdateComplete()
extern "C" void BoxSlider_GraphicUpdateComplete_m2980925808 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::OnEnable()
extern "C" void BoxSlider_OnEnable_m2230558070 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
Selectable_OnEnable_m3825327683(__this, /*hidden argument*/NULL);
BoxSlider_UpdateCachedReferences_m3248150675(__this, /*hidden argument*/NULL);
float L_0 = __this->get_m_Value_20();
BoxSlider_Set_m1512577286(__this, L_0, (bool)0, /*hidden argument*/NULL);
float L_1 = __this->get_m_ValueY_21();
BoxSlider_SetY_m956310887(__this, L_1, (bool)0, /*hidden argument*/NULL);
BoxSlider_UpdateVisuals_m495585056(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::OnDisable()
extern "C" void BoxSlider_OnDisable_m3760522835 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
DrivenRectTransformTracker_t154385424 * L_0 = __this->get_address_of_m_Tracker_26();
DrivenRectTransformTracker_Clear_m864483440(L_0, /*hidden argument*/NULL);
Selectable_OnDisable_m2660228016(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::UpdateCachedReferences()
extern "C" void BoxSlider_UpdateCachedReferences_m3248150675 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_UpdateCachedReferences_m3248150675_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
RectTransform_t3349966182 * L_0 = __this->get_m_HandleRect_16();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Implicit_m2856731593(NULL /*static, unused*/, L_0, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0052;
}
}
{
RectTransform_t3349966182 * L_2 = __this->get_m_HandleRect_16();
NullCheck(L_2);
Transform_t3275118058 * L_3 = Component_get_transform_m2697483695(L_2, /*hidden argument*/NULL);
__this->set_m_HandleTransform_23(L_3);
Transform_t3275118058 * L_4 = __this->get_m_HandleTransform_23();
NullCheck(L_4);
Transform_t3275118058 * L_5 = Transform_get_parent_m147407266(L_4, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_6 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_5, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_6)
{
goto IL_004d;
}
}
{
Transform_t3275118058 * L_7 = __this->get_m_HandleTransform_23();
NullCheck(L_7);
Transform_t3275118058 * L_8 = Transform_get_parent_m147407266(L_7, /*hidden argument*/NULL);
NullCheck(L_8);
RectTransform_t3349966182 * L_9 = Component_GetComponent_TisRectTransform_t3349966182_m1310250299(L_8, /*hidden argument*/Component_GetComponent_TisRectTransform_t3349966182_m1310250299_MethodInfo_var);
__this->set_m_HandleContainerRect_24(L_9);
}
IL_004d:
{
goto IL_0059;
}
IL_0052:
{
__this->set_m_HandleContainerRect_24((RectTransform_t3349966182 *)NULL);
}
IL_0059:
{
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::Set(System.Single)
extern "C" void BoxSlider_Set_m3989333985 (BoxSlider_t1871650694 * __this, float ___input0, const MethodInfo* method)
{
{
float L_0 = ___input0;
BoxSlider_Set_m1512577286(__this, L_0, (bool)1, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::Set(System.Single,System.Boolean)
extern "C" void BoxSlider_Set_m1512577286 (BoxSlider_t1871650694 * __this, float ___input0, bool ___sendCallback1, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_Set_m1512577286_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
float V_0 = 0.0f;
{
float L_0 = ___input0;
float L_1 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
float L_2 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_3 = Mathf_Clamp_m2354025655(NULL /*static, unused*/, L_0, L_1, L_2, /*hidden argument*/NULL);
V_0 = L_3;
bool L_4 = BoxSlider_get_wholeNumbers_m627638124(__this, /*hidden argument*/NULL);
if (!L_4)
{
goto IL_0025;
}
}
{
float L_5 = V_0;
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_6 = bankers_roundf(L_5);
V_0 = L_6;
}
IL_0025:
{
float L_7 = __this->get_m_Value_20();
float L_8 = V_0;
if ((!(((float)L_7) == ((float)L_8))))
{
goto IL_0032;
}
}
{
return;
}
IL_0032:
{
float L_9 = V_0;
__this->set_m_Value_20(L_9);
BoxSlider_UpdateVisuals_m495585056(__this, /*hidden argument*/NULL);
bool L_10 = ___sendCallback1;
if (!L_10)
{
goto IL_0057;
}
}
{
BoxSliderEvent_t1774115848 * L_11 = __this->get_m_OnValueChanged_22();
float L_12 = V_0;
float L_13 = BoxSlider_get_valueY_m2581533163(__this, /*hidden argument*/NULL);
NullCheck(L_11);
UnityEvent_2_Invoke_m4237217379(L_11, L_12, L_13, /*hidden argument*/UnityEvent_2_Invoke_m4237217379_MethodInfo_var);
}
IL_0057:
{
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::SetY(System.Single)
extern "C" void BoxSlider_SetY_m1241843396 (BoxSlider_t1871650694 * __this, float ___input0, const MethodInfo* method)
{
{
float L_0 = ___input0;
BoxSlider_SetY_m956310887(__this, L_0, (bool)1, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::SetY(System.Single,System.Boolean)
extern "C" void BoxSlider_SetY_m956310887 (BoxSlider_t1871650694 * __this, float ___input0, bool ___sendCallback1, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_SetY_m956310887_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
float V_0 = 0.0f;
{
float L_0 = ___input0;
float L_1 = BoxSlider_get_minValue_m3041624170(__this, /*hidden argument*/NULL);
float L_2 = BoxSlider_get_maxValue_m1317285860(__this, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_3 = Mathf_Clamp_m2354025655(NULL /*static, unused*/, L_0, L_1, L_2, /*hidden argument*/NULL);
V_0 = L_3;
bool L_4 = BoxSlider_get_wholeNumbers_m627638124(__this, /*hidden argument*/NULL);
if (!L_4)
{
goto IL_0025;
}
}
{
float L_5 = V_0;
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_6 = bankers_roundf(L_5);
V_0 = L_6;
}
IL_0025:
{
float L_7 = __this->get_m_ValueY_21();
float L_8 = V_0;
if ((!(((float)L_7) == ((float)L_8))))
{
goto IL_0032;
}
}
{
return;
}
IL_0032:
{
float L_9 = V_0;
__this->set_m_ValueY_21(L_9);
BoxSlider_UpdateVisuals_m495585056(__this, /*hidden argument*/NULL);
bool L_10 = ___sendCallback1;
if (!L_10)
{
goto IL_0057;
}
}
{
BoxSliderEvent_t1774115848 * L_11 = __this->get_m_OnValueChanged_22();
float L_12 = BoxSlider_get_value_m2439160562(__this, /*hidden argument*/NULL);
float L_13 = V_0;
NullCheck(L_11);
UnityEvent_2_Invoke_m4237217379(L_11, L_12, L_13, /*hidden argument*/UnityEvent_2_Invoke_m4237217379_MethodInfo_var);
}
IL_0057:
{
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::OnRectTransformDimensionsChange()
extern "C" void BoxSlider_OnRectTransformDimensionsChange_m1273303486 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
UIBehaviour_OnRectTransformDimensionsChange_m2743105076(__this, /*hidden argument*/NULL);
BoxSlider_UpdateVisuals_m495585056(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::UpdateVisuals()
extern "C" void BoxSlider_UpdateVisuals_m495585056 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_UpdateVisuals_m495585056_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Vector2_t2243707579 V_0;
memset(&V_0, 0, sizeof(V_0));
Vector2_t2243707579 V_1;
memset(&V_1, 0, sizeof(V_1));
float V_2 = 0.0f;
{
DrivenRectTransformTracker_t154385424 * L_0 = __this->get_address_of_m_Tracker_26();
DrivenRectTransformTracker_Clear_m864483440(L_0, /*hidden argument*/NULL);
RectTransform_t3349966182 * L_1 = __this->get_m_HandleContainerRect_24();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_2 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_1, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_0089;
}
}
{
DrivenRectTransformTracker_t154385424 * L_3 = __this->get_address_of_m_Tracker_26();
RectTransform_t3349966182 * L_4 = __this->get_m_HandleRect_16();
DrivenRectTransformTracker_Add_m310530075(L_3, __this, L_4, ((int32_t)3840), /*hidden argument*/NULL);
Vector2_t2243707579 L_5 = Vector2_get_zero_m3966848876(NULL /*static, unused*/, /*hidden argument*/NULL);
V_0 = L_5;
Vector2_t2243707579 L_6 = Vector2_get_one_m3174311904(NULL /*static, unused*/, /*hidden argument*/NULL);
V_1 = L_6;
float L_7 = BoxSlider_get_normalizedValue_m911068691(__this, /*hidden argument*/NULL);
V_2 = L_7;
float L_8 = V_2;
Vector2_set_Item_m3881967114((&V_1), 0, L_8, /*hidden argument*/NULL);
float L_9 = V_2;
Vector2_set_Item_m3881967114((&V_0), 0, L_9, /*hidden argument*/NULL);
float L_10 = BoxSlider_get_normalizedValueY_m3976688554(__this, /*hidden argument*/NULL);
V_2 = L_10;
float L_11 = V_2;
Vector2_set_Item_m3881967114((&V_1), 1, L_11, /*hidden argument*/NULL);
float L_12 = V_2;
Vector2_set_Item_m3881967114((&V_0), 1, L_12, /*hidden argument*/NULL);
RectTransform_t3349966182 * L_13 = __this->get_m_HandleRect_16();
Vector2_t2243707579 L_14 = V_0;
NullCheck(L_13);
RectTransform_set_anchorMin_m4247668187(L_13, L_14, /*hidden argument*/NULL);
RectTransform_t3349966182 * L_15 = __this->get_m_HandleRect_16();
Vector2_t2243707579 L_16 = V_1;
NullCheck(L_15);
RectTransform_set_anchorMax_m2955899993(L_15, L_16, /*hidden argument*/NULL);
}
IL_0089:
{
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::UpdateDrag(UnityEngine.EventSystems.PointerEventData,UnityEngine.Camera)
extern "C" void BoxSlider_UpdateDrag_m1281607389 (BoxSlider_t1871650694 * __this, PointerEventData_t1599784723 * ___eventData0, Camera_t189460977 * ___cam1, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_UpdateDrag_m1281607389_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
RectTransform_t3349966182 * V_0 = NULL;
Rect_t3681755626 V_1;
memset(&V_1, 0, sizeof(V_1));
Vector2_t2243707579 V_2;
memset(&V_2, 0, sizeof(V_2));
Vector2_t2243707579 V_3;
memset(&V_3, 0, sizeof(V_3));
Rect_t3681755626 V_4;
memset(&V_4, 0, sizeof(V_4));
float V_5 = 0.0f;
Vector2_t2243707579 V_6;
memset(&V_6, 0, sizeof(V_6));
Rect_t3681755626 V_7;
memset(&V_7, 0, sizeof(V_7));
Vector2_t2243707579 V_8;
memset(&V_8, 0, sizeof(V_8));
float V_9 = 0.0f;
Vector2_t2243707579 V_10;
memset(&V_10, 0, sizeof(V_10));
Rect_t3681755626 V_11;
memset(&V_11, 0, sizeof(V_11));
Vector2_t2243707579 V_12;
memset(&V_12, 0, sizeof(V_12));
{
RectTransform_t3349966182 * L_0 = __this->get_m_HandleContainerRect_24();
V_0 = L_0;
RectTransform_t3349966182 * L_1 = V_0;
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_2 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_1, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_2)
{
goto IL_00dd;
}
}
{
RectTransform_t3349966182 * L_3 = V_0;
NullCheck(L_3);
Rect_t3681755626 L_4 = RectTransform_get_rect_m73954734(L_3, /*hidden argument*/NULL);
V_1 = L_4;
Vector2_t2243707579 L_5 = Rect_get_size_m3833121112((&V_1), /*hidden argument*/NULL);
V_2 = L_5;
float L_6 = Vector2_get_Item_m2792130561((&V_2), 0, /*hidden argument*/NULL);
if ((!(((float)L_6) > ((float)(0.0f)))))
{
goto IL_00dd;
}
}
{
RectTransform_t3349966182 * L_7 = V_0;
PointerEventData_t1599784723 * L_8 = ___eventData0;
NullCheck(L_8);
Vector2_t2243707579 L_9 = PointerEventData_get_position_m2131765015(L_8, /*hidden argument*/NULL);
Camera_t189460977 * L_10 = ___cam1;
IL2CPP_RUNTIME_CLASS_INIT(RectTransformUtility_t2941082270_il2cpp_TypeInfo_var);
bool L_11 = RectTransformUtility_ScreenPointToLocalPointInRectangle_m2398565080(NULL /*static, unused*/, L_7, L_9, L_10, (&V_3), /*hidden argument*/NULL);
if (L_11)
{
goto IL_0049;
}
}
{
return;
}
IL_0049:
{
Vector2_t2243707579 L_12 = V_3;
RectTransform_t3349966182 * L_13 = V_0;
NullCheck(L_13);
Rect_t3681755626 L_14 = RectTransform_get_rect_m73954734(L_13, /*hidden argument*/NULL);
V_4 = L_14;
Vector2_t2243707579 L_15 = Rect_get_position_m24550734((&V_4), /*hidden argument*/NULL);
Vector2_t2243707579 L_16 = Vector2_op_Subtraction_m1984215297(NULL /*static, unused*/, L_12, L_15, /*hidden argument*/NULL);
V_3 = L_16;
Vector2_t2243707579 L_17 = V_3;
Vector2_t2243707579 L_18 = __this->get_m_Offset_25();
Vector2_t2243707579 L_19 = Vector2_op_Subtraction_m1984215297(NULL /*static, unused*/, L_17, L_18, /*hidden argument*/NULL);
V_6 = L_19;
float L_20 = Vector2_get_Item_m2792130561((&V_6), 0, /*hidden argument*/NULL);
RectTransform_t3349966182 * L_21 = V_0;
NullCheck(L_21);
Rect_t3681755626 L_22 = RectTransform_get_rect_m73954734(L_21, /*hidden argument*/NULL);
V_7 = L_22;
Vector2_t2243707579 L_23 = Rect_get_size_m3833121112((&V_7), /*hidden argument*/NULL);
V_8 = L_23;
float L_24 = Vector2_get_Item_m2792130561((&V_8), 0, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Mathf_t2336485820_il2cpp_TypeInfo_var);
float L_25 = Mathf_Clamp01_m3888954684(NULL /*static, unused*/, ((float)((float)L_20/(float)L_24)), /*hidden argument*/NULL);
V_5 = L_25;
float L_26 = V_5;
BoxSlider_set_normalizedValue_m2010660092(__this, L_26, /*hidden argument*/NULL);
Vector2_t2243707579 L_27 = V_3;
Vector2_t2243707579 L_28 = __this->get_m_Offset_25();
Vector2_t2243707579 L_29 = Vector2_op_Subtraction_m1984215297(NULL /*static, unused*/, L_27, L_28, /*hidden argument*/NULL);
V_10 = L_29;
float L_30 = Vector2_get_Item_m2792130561((&V_10), 1, /*hidden argument*/NULL);
RectTransform_t3349966182 * L_31 = V_0;
NullCheck(L_31);
Rect_t3681755626 L_32 = RectTransform_get_rect_m73954734(L_31, /*hidden argument*/NULL);
V_11 = L_32;
Vector2_t2243707579 L_33 = Rect_get_size_m3833121112((&V_11), /*hidden argument*/NULL);
V_12 = L_33;
float L_34 = Vector2_get_Item_m2792130561((&V_12), 1, /*hidden argument*/NULL);
float L_35 = Mathf_Clamp01_m3888954684(NULL /*static, unused*/, ((float)((float)L_30/(float)L_34)), /*hidden argument*/NULL);
V_9 = L_35;
float L_36 = V_9;
BoxSlider_set_normalizedValueY_m851020601(__this, L_36, /*hidden argument*/NULL);
}
IL_00dd:
{
return;
}
}
// System.Boolean UnityEngine.UI.BoxSlider::MayDrag(UnityEngine.EventSystems.PointerEventData)
extern "C" bool BoxSlider_MayDrag_m1941009447 (BoxSlider_t1871650694 * __this, PointerEventData_t1599784723 * ___eventData0, const MethodInfo* method)
{
int32_t G_B4_0 = 0;
{
bool L_0 = VirtFuncInvoker0< bool >::Invoke(9 /* System.Boolean UnityEngine.EventSystems.UIBehaviour::IsActive() */, __this);
if (!L_0)
{
goto IL_0021;
}
}
{
bool L_1 = VirtFuncInvoker0< bool >::Invoke(24 /* System.Boolean UnityEngine.UI.Selectable::IsInteractable() */, __this);
if (!L_1)
{
goto IL_0021;
}
}
{
PointerEventData_t1599784723 * L_2 = ___eventData0;
NullCheck(L_2);
int32_t L_3 = PointerEventData_get_button_m2339189303(L_2, /*hidden argument*/NULL);
G_B4_0 = ((((int32_t)L_3) == ((int32_t)0))? 1 : 0);
goto IL_0022;
}
IL_0021:
{
G_B4_0 = 0;
}
IL_0022:
{
return (bool)G_B4_0;
}
}
// System.Void UnityEngine.UI.BoxSlider::OnPointerDown(UnityEngine.EventSystems.PointerEventData)
extern "C" void BoxSlider_OnPointerDown_m523869696 (BoxSlider_t1871650694 * __this, PointerEventData_t1599784723 * ___eventData0, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSlider_OnPointerDown_m523869696_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Vector2_t2243707579 V_0;
memset(&V_0, 0, sizeof(V_0));
{
PointerEventData_t1599784723 * L_0 = ___eventData0;
bool L_1 = BoxSlider_MayDrag_m1941009447(__this, L_0, /*hidden argument*/NULL);
if (L_1)
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
PointerEventData_t1599784723 * L_2 = ___eventData0;
Selectable_OnPointerDown_m3110480835(__this, L_2, /*hidden argument*/NULL);
Vector2_t2243707579 L_3 = Vector2_get_zero_m3966848876(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_m_Offset_25(L_3);
RectTransform_t3349966182 * L_4 = __this->get_m_HandleContainerRect_24();
IL2CPP_RUNTIME_CLASS_INIT(Object_t1021602117_il2cpp_TypeInfo_var);
bool L_5 = Object_op_Inequality_m2402264703(NULL /*static, unused*/, L_4, (Object_t1021602117 *)NULL, /*hidden argument*/NULL);
if (!L_5)
{
goto IL_008d;
}
}
{
RectTransform_t3349966182 * L_6 = __this->get_m_HandleRect_16();
PointerEventData_t1599784723 * L_7 = ___eventData0;
NullCheck(L_7);
Vector2_t2243707579 L_8 = PointerEventData_get_position_m2131765015(L_7, /*hidden argument*/NULL);
PointerEventData_t1599784723 * L_9 = ___eventData0;
NullCheck(L_9);
Camera_t189460977 * L_10 = PointerEventData_get_enterEventCamera_m1539996745(L_9, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(RectTransformUtility_t2941082270_il2cpp_TypeInfo_var);
bool L_11 = RectTransformUtility_RectangleContainsScreenPoint_m1244853728(NULL /*static, unused*/, L_6, L_8, L_10, /*hidden argument*/NULL);
if (!L_11)
{
goto IL_008d;
}
}
{
RectTransform_t3349966182 * L_12 = __this->get_m_HandleRect_16();
PointerEventData_t1599784723 * L_13 = ___eventData0;
NullCheck(L_13);
Vector2_t2243707579 L_14 = PointerEventData_get_position_m2131765015(L_13, /*hidden argument*/NULL);
PointerEventData_t1599784723 * L_15 = ___eventData0;
NullCheck(L_15);
Camera_t189460977 * L_16 = PointerEventData_get_pressEventCamera_m724559964(L_15, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(RectTransformUtility_t2941082270_il2cpp_TypeInfo_var);
bool L_17 = RectTransformUtility_ScreenPointToLocalPointInRectangle_m2398565080(NULL /*static, unused*/, L_12, L_14, L_16, (&V_0), /*hidden argument*/NULL);
if (!L_17)
{
goto IL_0071;
}
}
{
Vector2_t2243707579 L_18 = V_0;
__this->set_m_Offset_25(L_18);
}
IL_0071:
{
Vector2_t2243707579 * L_19 = __this->get_address_of_m_Offset_25();
Vector2_t2243707579 * L_20 = __this->get_address_of_m_Offset_25();
float L_21 = L_20->get_y_1();
L_19->set_y_1(((-L_21)));
goto IL_009a;
}
IL_008d:
{
PointerEventData_t1599784723 * L_22 = ___eventData0;
PointerEventData_t1599784723 * L_23 = ___eventData0;
NullCheck(L_23);
Camera_t189460977 * L_24 = PointerEventData_get_pressEventCamera_m724559964(L_23, /*hidden argument*/NULL);
BoxSlider_UpdateDrag_m1281607389(__this, L_22, L_24, /*hidden argument*/NULL);
}
IL_009a:
{
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::OnDrag(UnityEngine.EventSystems.PointerEventData)
extern "C" void BoxSlider_OnDrag_m2506766611 (BoxSlider_t1871650694 * __this, PointerEventData_t1599784723 * ___eventData0, const MethodInfo* method)
{
{
PointerEventData_t1599784723 * L_0 = ___eventData0;
bool L_1 = BoxSlider_MayDrag_m1941009447(__this, L_0, /*hidden argument*/NULL);
if (L_1)
{
goto IL_000d;
}
}
{
return;
}
IL_000d:
{
PointerEventData_t1599784723 * L_2 = ___eventData0;
PointerEventData_t1599784723 * L_3 = ___eventData0;
NullCheck(L_3);
Camera_t189460977 * L_4 = PointerEventData_get_pressEventCamera_m724559964(L_3, /*hidden argument*/NULL);
BoxSlider_UpdateDrag_m1281607389(__this, L_2, L_4, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.UI.BoxSlider::OnInitializePotentialDrag(UnityEngine.EventSystems.PointerEventData)
extern "C" void BoxSlider_OnInitializePotentialDrag_m2830850663 (BoxSlider_t1871650694 * __this, PointerEventData_t1599784723 * ___eventData0, const MethodInfo* method)
{
{
PointerEventData_t1599784723 * L_0 = ___eventData0;
NullCheck(L_0);
PointerEventData_set_useDragThreshold_m2778439880(L_0, (bool)0, /*hidden argument*/NULL);
return;
}
}
// UnityEngine.Transform UnityEngine.UI.BoxSlider::UnityEngine.UI.ICanvasElement.get_transform()
extern "C" Transform_t3275118058 * BoxSlider_UnityEngine_UI_ICanvasElement_get_transform_m3600860139 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
Transform_t3275118058 * L_0 = Component_get_transform_m2697483695(__this, /*hidden argument*/NULL);
return L_0;
}
}
// System.Boolean UnityEngine.UI.BoxSlider::UnityEngine.UI.ICanvasElement.IsDestroyed()
extern "C" bool BoxSlider_UnityEngine_UI_ICanvasElement_IsDestroyed_m2151284327 (BoxSlider_t1871650694 * __this, const MethodInfo* method)
{
{
bool L_0 = UIBehaviour_IsDestroyed_m3809050211(__this, /*hidden argument*/NULL);
return L_0;
}
}
// System.Void UnityEngine.UI.BoxSlider/BoxSliderEvent::.ctor()
extern "C" void BoxSliderEvent__ctor_m304261805 (BoxSliderEvent_t1774115848 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (BoxSliderEvent__ctor_m304261805_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
UnityEvent_2__ctor_m731674732(__this, /*hidden argument*/UnityEvent_2__ctor_m731674732_MethodInfo_var);
return;
}
}
// System.Void UnityEngine.XR.iOS.UnityARAmbient::.ctor()
extern "C" void UnityARAmbient__ctor_m3700524047 (UnityARAmbient_t680084560 * __this, const MethodInfo* method)
{
{
MonoBehaviour__ctor_m2464341955(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.XR.iOS.UnityARAmbient::Start()
extern "C" void UnityARAmbient_Start_m303369171 (UnityARAmbient_t680084560 * __this, const MethodInfo* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (UnityARAmbient_Start_m303369171_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Light_t494725636 * L_0 = Component_GetComponent_TisLight_t494725636_m2604108526(__this, /*hidden argument*/Component_GetComponent_TisLight_t494725636_m2604108526_MethodInfo_var);
__this->set_l_2(L_0);
IL2CPP_RUNTIME_CLASS_INIT(UnityARSessionNativeInterface_t1130867170_il2cpp_TypeInfo_var);
UnityARSessionNativeInterface_t1130867170 * L_1 = UnityARSessionNativeInterface_GetARSessionNativeInterface_m3174488657(NULL /*static, unused*/, /*hidden argument*/NULL);
__this->set_m_Session_3(L_1);
return;
}
}
// System.Void UnityEngine.XR.iOS.UnityARAmbient::Update()
extern "C" void UnityARAmbient_Update_m2066148092 (UnityARAmbient_t680084560 * __this, const MethodInfo* method)
{
float V_0 = 0.0f;
{
UnityARSessionNativeInterface_t1130867170 * L_0 = __this->get_m_Session_3();
NullCheck(L_0);
float L_1 = UnityARSessionNativeInterface_GetARAmbientIntensity_m3261179343(L_0, /*hidden argument*/NULL);
V_0 = L_1;
Light_t494725636 * L_2 = __this->get_l_2();
float L_3 = V_0;
NullCheck(L_2);
Light_set_intensity_m1790590300(L_2, ((float)((float)L_3/(float)(1000.0f))), /*hidden argument*/NULL);
return;
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"lucasfutch@gmail.com"
] | lucasfutch@gmail.com |
b97283a1b929f807b4ea81dd48252a4eb99313db | 07cbe159795612509c2e7e59eb9c8ff6c6ed6b0d | /partitioned/RayleighBenard/consistencyTest/Ra_1e+05_multiFluidFoam_X1_Y50_constThetaBC/tStep0.0001_0.005/thetaf.stable | 37e987822876127c6350609f4c5e76b605e69842 | [] | no_license | AtmosFOAM/danRun | aacaaf8a22e47d1eb6390190cb98fbe846001e7a | 94d19c4992053d7bd860923e9605c0cbb77ca8a2 | refs/heads/master | 2021-03-22T04:32:10.679600 | 2020-12-03T21:09:40 | 2020-12-03T21:09:40 | 118,792,506 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,399 | stable | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class surfaceScalarField;
location "0.005";
object thetaf.stable;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField nonuniform List<scalar>
49
(
328.808127777
327.608120304
326.399970399
325.191693819
323.990312873
322.791690568
321.599829276
320.406585303
319.199817216
317.991682524
316.790311971
315.591700132
314.399981771
313.208125329
312.008128349
310.800120658
309.593221698
308.398460754
307.198455899
305.993212658
304.799979662
303.606594285
302.399815869
301.19167069
299.990147829
298.790006722
297.590149159
296.391678719
295.199828403
294.006594799
292.799978975
291.593374283
290.400143679
289.208146117
288.008282059
286.801671091
285.601677656
284.408298133
283.208282491
282.001518977
280.800137672
279.599996656
278.399996958
277.200140057
276.001537182
274.808432937
273.609680845
272.408425326
271.201521257
)
;
boundaryField
{
ground
{
type calculated;
value uniform 330;
}
top
{
type calculated;
value uniform 270;
}
left
{
type cyclic;
value nonuniform List<scalar>
50
(
329.406880518
328.209375036
327.006865573
325.793075225
324.590312412
323.390313334
322.193067802
321.00659075
319.806579857
318.593054575
317.390310474
316.190313468
314.993086796
313.806876745
312.609373913
311.406882785
310.193358531
308.993084866
307.803836641
306.593075156
305.39335016
304.206609165
303.006579406
301.793052333
300.590289046
299.390006612
298.190006832
296.990291485
295.793065953
294.606590853
293.406598746
292.193359203
290.993389363
289.806897994
288.60939424
287.407169879
286.196172303
285.007183009
283.809413256
282.607151725
281.395886229
280.204389115
278.995604198
277.804389718
276.595890396
275.407183969
274.209681904
273.009679786
271.807170867
270.595871647
)
;
}
right
{
type cyclic;
value nonuniform List<scalar>
50
(
329.406880518
328.209375036
327.006865573
325.793075225
324.590312412
323.390313334
322.193067802
321.00659075
319.806579857
318.593054575
317.390310474
316.190313468
314.993086796
313.806876745
312.609373913
311.406882785
310.193358531
308.993084866
307.803836641
306.593075156
305.39335016
304.206609165
303.006579406
301.793052333
300.590289046
299.390006612
298.190006832
296.990291485
295.793065953
294.606590853
293.406598746
292.193359203
290.993389363
289.806897994
288.60939424
287.407169879
286.196172303
285.007183009
283.809413256
282.607151725
281.395886229
280.204389115
278.995604198
277.804389718
276.595890396
275.407183969
274.209681904
273.009679786
271.807170867
270.595871647
)
;
}
frontAndBack
{
type empty;
value nonuniform 0();
}
}
// ************************************************************************* //
| [
"d.shipley.1341@gmail.com"
] | d.shipley.1341@gmail.com |
1bd1c0649d732478f45454a3f2b7d5fe7f902a9e | 8010df1fef10ddfd83bf07966cbf7e2e4b0d7ee9 | /include/winsdk/cppwinrt/winrt/impl/Windows.ApplicationModel.AppService.0.h | a6194b19a76352d3fb3bf14e1624965c6484aeb4 | [
"MIT"
] | permissive | light-tech/MSCpp | a23ab987b7e12329ab2d418b06b6b8055bde5ca2 | 012631b58c402ceec73c73d2bda443078bc151ef | refs/heads/master | 2022-12-26T23:51:21.686396 | 2020-10-15T13:40:34 | 2020-10-15T13:40:34 | 188,921,341 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 30,898 | h | // C++/WinRT v2.0.190620.2
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef WINRT_Windows_ApplicationModel_AppService_0_H
#define WINRT_Windows_ApplicationModel_AppService_0_H
namespace winrt::Windows::Foundation
{
struct EventRegistrationToken;
template <typename TSender, typename TResult> struct TypedEventHandler;
}
namespace winrt::Windows::Foundation::Collections
{
struct ValueSet;
}
namespace winrt::Windows::System
{
struct User;
}
namespace winrt::Windows::System::RemoteSystems
{
struct RemoteSystemConnectionRequest;
}
namespace winrt::Windows::ApplicationModel::AppService
{
enum class AppServiceClosedStatus : int32_t
{
Completed = 0,
Canceled = 1,
ResourceLimitsExceeded = 2,
Unknown = 3,
};
enum class AppServiceConnectionStatus : int32_t
{
Success = 0,
AppNotInstalled = 1,
AppUnavailable = 2,
AppServiceUnavailable = 3,
Unknown = 4,
RemoteSystemUnavailable = 5,
RemoteSystemNotSupportedByApp = 6,
NotAuthorized = 7,
AuthenticationError = 8,
NetworkNotAvailable = 9,
DisabledByPolicy = 10,
WebServiceUnavailable = 11,
};
enum class AppServiceResponseStatus : int32_t
{
Success = 0,
Failure = 1,
ResourceLimitsExceeded = 2,
Unknown = 3,
RemoteSystemUnavailable = 4,
MessageSizeTooLarge = 5,
AppUnavailable = 6,
AuthenticationError = 7,
NetworkNotAvailable = 8,
DisabledByPolicy = 9,
WebServiceUnavailable = 10,
};
enum class StatelessAppServiceResponseStatus : int32_t
{
Success = 0,
AppNotInstalled = 1,
AppUnavailable = 2,
AppServiceUnavailable = 3,
RemoteSystemUnavailable = 4,
RemoteSystemNotSupportedByApp = 5,
NotAuthorized = 6,
ResourceLimitsExceeded = 7,
MessageSizeTooLarge = 8,
Failure = 9,
Unknown = 10,
AuthenticationError = 11,
NetworkNotAvailable = 12,
DisabledByPolicy = 13,
WebServiceUnavailable = 14,
};
struct IAppServiceCatalogStatics;
struct IAppServiceClosedEventArgs;
struct IAppServiceConnection;
struct IAppServiceConnection2;
struct IAppServiceConnectionStatics;
struct IAppServiceDeferral;
struct IAppServiceRequest;
struct IAppServiceRequestReceivedEventArgs;
struct IAppServiceResponse;
struct IAppServiceTriggerDetails;
struct IAppServiceTriggerDetails2;
struct IAppServiceTriggerDetails3;
struct IAppServiceTriggerDetails4;
struct IStatelessAppServiceResponse;
struct AppServiceCatalog;
struct AppServiceClosedEventArgs;
struct AppServiceConnection;
struct AppServiceDeferral;
struct AppServiceRequest;
struct AppServiceRequestReceivedEventArgs;
struct AppServiceResponse;
struct AppServiceTriggerDetails;
struct StatelessAppServiceResponse;
}
namespace winrt::impl
{
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceCatalogStatics>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceClosedEventArgs>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceConnection>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceConnection2>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceConnectionStatics>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceDeferral>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceRequest>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceRequestReceivedEventArgs>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceResponse>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails2>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails3>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails4>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::IStatelessAppServiceResponse>
{
using type = interface_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceCatalog>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceClosedEventArgs>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceConnection>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceDeferral>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceRequest>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceResponse>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceTriggerDetails>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::StatelessAppServiceResponse>
{
using type = class_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceClosedStatus>
{
using type = enum_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceConnectionStatus>
{
using type = enum_category;
};
template <> struct category<Windows::ApplicationModel::AppService::AppServiceResponseStatus>
{
using type = enum_category;
};
template <> struct category<Windows::ApplicationModel::AppService::StatelessAppServiceResponseStatus>
{
using type = enum_category;
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceCatalogStatics>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceCatalogStatics" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceClosedEventArgs>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceClosedEventArgs" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceConnection>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceConnection" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceConnection2>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceConnection2" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceConnectionStatics>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceConnectionStatics" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceDeferral>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceDeferral" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceRequest>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceRequest" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceRequestReceivedEventArgs>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceRequestReceivedEventArgs" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceResponse>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceResponse" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceTriggerDetails" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails2>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceTriggerDetails2" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails3>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceTriggerDetails3" };
};
template <> struct name<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails4>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IAppServiceTriggerDetails4" };
};
template <> struct name<Windows::ApplicationModel::AppService::IStatelessAppServiceResponse>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.IStatelessAppServiceResponse" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceCatalog>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceCatalog" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceClosedEventArgs>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceClosedEventArgs" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceConnection>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceConnection" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceDeferral>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceDeferral" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceRequest>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceRequest" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceRequestReceivedEventArgs" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceResponse>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceResponse" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceTriggerDetails>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceTriggerDetails" };
};
template <> struct name<Windows::ApplicationModel::AppService::StatelessAppServiceResponse>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.StatelessAppServiceResponse" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceClosedStatus>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceClosedStatus" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceConnectionStatus>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceConnectionStatus" };
};
template <> struct name<Windows::ApplicationModel::AppService::AppServiceResponseStatus>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.AppServiceResponseStatus" };
};
template <> struct name<Windows::ApplicationModel::AppService::StatelessAppServiceResponseStatus>
{
static constexpr auto & value{ L"Windows.ApplicationModel.AppService.StatelessAppServiceResponseStatus" };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceCatalogStatics>
{
static constexpr guid value{ 0xEF0D2507,0xD132,0x4C85,{ 0x83,0x95,0x3C,0x31,0xD5,0xA1,0xE9,0x41 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceClosedEventArgs>
{
static constexpr guid value{ 0xDE6016F6,0xCB03,0x4D35,{ 0xAC,0x8D,0xCC,0x63,0x03,0x23,0x97,0x31 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceConnection>
{
static constexpr guid value{ 0x9DD474A2,0x871F,0x4D52,{ 0x89,0xA9,0x9E,0x09,0x05,0x31,0xBD,0x27 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceConnection2>
{
static constexpr guid value{ 0x8BDFCD5F,0x2302,0x4FBD,{ 0x80,0x61,0x52,0x51,0x1C,0x2F,0x8B,0xF9 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceConnectionStatics>
{
static constexpr guid value{ 0xADC56CE9,0xD408,0x5673,{ 0x86,0x37,0x82,0x7A,0x4B,0x27,0x41,0x68 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceDeferral>
{
static constexpr guid value{ 0x7E1B5322,0xEAB0,0x4248,{ 0xAE,0x04,0xFD,0xF9,0x38,0x38,0xE4,0x72 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceRequest>
{
static constexpr guid value{ 0x20E58D9D,0x18DE,0x4B01,{ 0x80,0xBA,0x90,0xA7,0x62,0x04,0xE3,0xC8 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceRequestReceivedEventArgs>
{
static constexpr guid value{ 0x6E122360,0xFF65,0x44AE,{ 0x9E,0x45,0x85,0x7F,0xE4,0x18,0x06,0x81 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceResponse>
{
static constexpr guid value{ 0x8D503CEC,0x9AA3,0x4E68,{ 0x95,0x59,0x9D,0xE6,0x3E,0x37,0x2C,0xE4 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails>
{
static constexpr guid value{ 0x88A2DCAC,0xAD28,0x41B8,{ 0x80,0xBB,0xBD,0xF1,0xB2,0x16,0x9E,0x19 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails2>
{
static constexpr guid value{ 0xE83D54B2,0x28CC,0x43F2,{ 0xB4,0x65,0xC0,0x48,0x2E,0x59,0xE2,0xDC } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails3>
{
static constexpr guid value{ 0xFBD71E21,0x7939,0x4E68,{ 0x9E,0x3C,0x77,0x80,0x14,0x7A,0xAB,0xB6 } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails4>
{
static constexpr guid value{ 0x1185B180,0x8861,0x5E30,{ 0xAB,0x55,0x1C,0xF4,0xD0,0x8B,0xBF,0x6D } };
};
template <> struct guid_storage<Windows::ApplicationModel::AppService::IStatelessAppServiceResponse>
{
static constexpr guid value{ 0x43754AF7,0xA9EC,0x52FE,{ 0x82,0xE7,0x93,0x9B,0x68,0xDC,0x93,0x88 } };
};
template <> struct default_interface<Windows::ApplicationModel::AppService::AppServiceClosedEventArgs>
{
using type = Windows::ApplicationModel::AppService::IAppServiceClosedEventArgs;
};
template <> struct default_interface<Windows::ApplicationModel::AppService::AppServiceConnection>
{
using type = Windows::ApplicationModel::AppService::IAppServiceConnection;
};
template <> struct default_interface<Windows::ApplicationModel::AppService::AppServiceDeferral>
{
using type = Windows::ApplicationModel::AppService::IAppServiceDeferral;
};
template <> struct default_interface<Windows::ApplicationModel::AppService::AppServiceRequest>
{
using type = Windows::ApplicationModel::AppService::IAppServiceRequest;
};
template <> struct default_interface<Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs>
{
using type = Windows::ApplicationModel::AppService::IAppServiceRequestReceivedEventArgs;
};
template <> struct default_interface<Windows::ApplicationModel::AppService::AppServiceResponse>
{
using type = Windows::ApplicationModel::AppService::IAppServiceResponse;
};
template <> struct default_interface<Windows::ApplicationModel::AppService::AppServiceTriggerDetails>
{
using type = Windows::ApplicationModel::AppService::IAppServiceTriggerDetails;
};
template <> struct default_interface<Windows::ApplicationModel::AppService::StatelessAppServiceResponse>
{
using type = Windows::ApplicationModel::AppService::IStatelessAppServiceResponse;
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceCatalogStatics>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall FindAppServiceProvidersAsync(void*, void**) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceClosedEventArgs>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_Status(int32_t*) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceConnection>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_AppServiceName(void**) noexcept = 0;
virtual int32_t __stdcall put_AppServiceName(void*) noexcept = 0;
virtual int32_t __stdcall get_PackageFamilyName(void**) noexcept = 0;
virtual int32_t __stdcall put_PackageFamilyName(void*) noexcept = 0;
virtual int32_t __stdcall OpenAsync(void**) noexcept = 0;
virtual int32_t __stdcall SendMessageAsync(void*, void**) noexcept = 0;
virtual int32_t __stdcall add_RequestReceived(void*, winrt::event_token*) noexcept = 0;
virtual int32_t __stdcall remove_RequestReceived(winrt::event_token) noexcept = 0;
virtual int32_t __stdcall add_ServiceClosed(void*, winrt::event_token*) noexcept = 0;
virtual int32_t __stdcall remove_ServiceClosed(winrt::event_token) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceConnection2>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall OpenRemoteAsync(void*, void**) noexcept = 0;
virtual int32_t __stdcall get_User(void**) noexcept = 0;
virtual int32_t __stdcall put_User(void*) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceConnectionStatics>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall SendStatelessMessageAsync(void*, void*, void*, void**) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceDeferral>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall Complete() noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceRequest>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_Message(void**) noexcept = 0;
virtual int32_t __stdcall SendResponseAsync(void*, void**) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceRequestReceivedEventArgs>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_Request(void**) noexcept = 0;
virtual int32_t __stdcall GetDeferral(void**) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceResponse>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_Message(void**) noexcept = 0;
virtual int32_t __stdcall get_Status(int32_t*) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_Name(void**) noexcept = 0;
virtual int32_t __stdcall get_CallerPackageFamilyName(void**) noexcept = 0;
virtual int32_t __stdcall get_AppServiceConnection(void**) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails2>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_IsRemoteSystemConnection(bool*) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails3>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall CheckCallerForCapabilityAsync(void*, void**) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails4>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_CallerRemoteConnectionToken(void**) noexcept = 0;
};
};
template <> struct abi<Windows::ApplicationModel::AppService::IStatelessAppServiceResponse>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall get_Message(void**) noexcept = 0;
virtual int32_t __stdcall get_Status(int32_t*) noexcept = 0;
};
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceCatalogStatics
{
auto FindAppServiceProvidersAsync(param::hstring const& appServiceName) const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceCatalogStatics>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceCatalogStatics<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceClosedEventArgs
{
[[nodiscard]] auto Status() const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceClosedEventArgs>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceClosedEventArgs<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceConnection
{
[[nodiscard]] auto AppServiceName() const;
auto AppServiceName(param::hstring const& value) const;
[[nodiscard]] auto PackageFamilyName() const;
auto PackageFamilyName(param::hstring const& value) const;
auto OpenAsync() const;
auto SendMessageAsync(Windows::Foundation::Collections::ValueSet const& message) const;
auto RequestReceived(Windows::Foundation::TypedEventHandler<Windows::ApplicationModel::AppService::AppServiceConnection, Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs> const& handler) const;
using RequestReceived_revoker = impl::event_revoker<Windows::ApplicationModel::AppService::IAppServiceConnection, &impl::abi_t<Windows::ApplicationModel::AppService::IAppServiceConnection>::remove_RequestReceived>;
RequestReceived_revoker RequestReceived(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::ApplicationModel::AppService::AppServiceConnection, Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs> const& handler) const;
auto RequestReceived(winrt::event_token const& token) const noexcept;
auto ServiceClosed(Windows::Foundation::TypedEventHandler<Windows::ApplicationModel::AppService::AppServiceConnection, Windows::ApplicationModel::AppService::AppServiceClosedEventArgs> const& handler) const;
using ServiceClosed_revoker = impl::event_revoker<Windows::ApplicationModel::AppService::IAppServiceConnection, &impl::abi_t<Windows::ApplicationModel::AppService::IAppServiceConnection>::remove_ServiceClosed>;
ServiceClosed_revoker ServiceClosed(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::ApplicationModel::AppService::AppServiceConnection, Windows::ApplicationModel::AppService::AppServiceClosedEventArgs> const& handler) const;
auto ServiceClosed(winrt::event_token const& token) const noexcept;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceConnection>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceConnection<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceConnection2
{
auto OpenRemoteAsync(Windows::System::RemoteSystems::RemoteSystemConnectionRequest const& remoteSystemConnectionRequest) const;
[[nodiscard]] auto User() const;
auto User(Windows::System::User const& value) const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceConnection2>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceConnection2<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceConnectionStatics
{
auto SendStatelessMessageAsync(Windows::ApplicationModel::AppService::AppServiceConnection const& connection, Windows::System::RemoteSystems::RemoteSystemConnectionRequest const& connectionRequest, Windows::Foundation::Collections::ValueSet const& message) const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceConnectionStatics>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceConnectionStatics<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceDeferral
{
auto Complete() const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceDeferral>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceDeferral<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceRequest
{
[[nodiscard]] auto Message() const;
auto SendResponseAsync(Windows::Foundation::Collections::ValueSet const& message) const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceRequest>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceRequest<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceRequestReceivedEventArgs
{
[[nodiscard]] auto Request() const;
auto GetDeferral() const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceRequestReceivedEventArgs>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceRequestReceivedEventArgs<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceResponse
{
[[nodiscard]] auto Message() const;
[[nodiscard]] auto Status() const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceResponse>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceResponse<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceTriggerDetails
{
[[nodiscard]] auto Name() const;
[[nodiscard]] auto CallerPackageFamilyName() const;
[[nodiscard]] auto AppServiceConnection() const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceTriggerDetails<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceTriggerDetails2
{
[[nodiscard]] auto IsRemoteSystemConnection() const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails2>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceTriggerDetails2<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceTriggerDetails3
{
auto CheckCallerForCapabilityAsync(param::hstring const& capabilityName) const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails3>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceTriggerDetails3<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IAppServiceTriggerDetails4
{
[[nodiscard]] auto CallerRemoteConnectionToken() const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IAppServiceTriggerDetails4>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IAppServiceTriggerDetails4<D>;
};
template <typename D>
struct consume_Windows_ApplicationModel_AppService_IStatelessAppServiceResponse
{
[[nodiscard]] auto Message() const;
[[nodiscard]] auto Status() const;
};
template <> struct consume<Windows::ApplicationModel::AppService::IStatelessAppServiceResponse>
{
template <typename D> using type = consume_Windows_ApplicationModel_AppService_IStatelessAppServiceResponse<D>;
};
}
#endif
| [
"lightech@outlook.com"
] | lightech@outlook.com |
2e487378ef770c57a576798ed141923d5ababcb9 | 7d1a96565a1b46eaa38770bc592f0f508ba659b3 | /PzSummer2016WarsawU/I.cpp | 846d9485795f899dc77f14d957bc0f28c5bf2f59 | [] | no_license | RubenAshughyan/Programming-olympiads | f09dff286677d65da19f0ba4c288aa6e97ba9fd5 | 2bc85f5e6dc6879105353d90e8417b73c0be2389 | refs/heads/master | 2021-09-26T17:18:47.100625 | 2021-09-13T09:58:41 | 2021-09-13T09:58:41 | 73,565,659 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,199 | cpp | #pragma GCC optimize "-O1"
#pragma GCC optimize "-O2"
#pragma GCC optimize "-O3"
#include<bits/stdc++.h>
//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define ull unsigned long long
#define vc vector
#define SQ(j) (j)*(j)
//#define i first
//#define j second
//#define ld long double
#define dbl double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp
//#define printf(...) (0)
#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;
using namespace std;
const int N = (1 << 16) + 5;
typedef bitset<N+1> BS;
int n;
vc<int> input[9];
vc<pii > a, b, c;
vc<BS> A, B, C;
ll solve(int I, int J, int K) {
// loop(i, n) {
// a[input[I][i]] = {input[J][i], input[I][i]};
// b[input[I][i]] = {input[K][i], input[I][i]};
// }
// orig_a = a;
// orig_b = b;
// for(auto p:orig_a) cout << p.first << ' '; cout << endl;
// for(auto p:orig_b) cout << p.first << ' '; cout << endl;
A.clear();
B.clear();
C.clear();
loop(i,n){
a[i] = {input[I][i], i};
b[i] = {input[J][i], i};
c[i] = {input[K][i], i};
}
A.push_back(BS());
B.push_back(BS());
C.push_back(BS());
sort(all(a));
for (auto p: a) {
int index = p.second;
A.push_back(A.back());
A.back()[index] = 1;
}
sort(all(b));
for (auto p: b) {
int index = p.second;
B.push_back(B.back());
B.back()[index] = 1;
}
sort(all(c));
for (auto p: c) {
int index = p.second;
C.push_back(C.back());
C.back()[index] = 1;
}
ll ans = 0;
loop(j, n) {
int add = (A[input[I][j]] & B[input[J][j]] & C[input[K][j]]).count();
db(add);
ans += add;
}
return ans;
}
int main() {
scanf("%d", &n);
a.resize(n);
b.resize(n);
c.resize(n);
loop(i, 9) {
loop(j, n) {
int e;
scanf("%d", &e);
e--;
input[i].push_back(e);
}
}
int I, J, K;
ll bestAns = 1e17;
solve(3-1,7-1,8-1);
exit(0);
for (int i = 0; i < 9; i++) {
for (int j = i + 1; j < 9; j++) {
for (int k = j + 1; k < 9; k++) {
ll curAns = solve(i, j, k);
cout << endl;
printf("%d %d %d\n", i + 1, j + 1, k + 1);
db(curAns);
if (curAns < bestAns) {
bestAns = curAns;
I = i;
J = j;
K = k;
}
}
}
}
printf("%d %d %d\n", I + 1, J + 1, K + 1);
return 0;
}
/*
7
1 2 3 4 5 6 7
1 2 4 5 3 7 6
1 3 2 5 7 6 4
1 2 3 4 5 7 6
1 2 3 4 5 6 7
2 1 3 4 5 6 7
7 1 2 3 4 5 6
5 4 1 3 6 7 2
1 2 4 5 3 6 7
7
1 3 2 5 7 6 4
7 1 2 3 4 5 6
5 4 1 3 6 7 2
1 2
1 3
1 6
3 6
5 6
*/ | [
"ruben.ashughyan@gmail.com"
] | ruben.ashughyan@gmail.com |
35e8ab1ade08ef163ae7f9e32445b8947a03bbe1 | 2a7e43850e79e3b3b1ad1a0b10f4e49014c15d71 | /26_substructureOfaTree.cpp | a35b7967b0f9db94fd88deda47d9efcbea2c0341 | [] | no_license | CharlieXuJk/findingJob | ccc40761bfe169ef8f2d3773ebc39ddf2121fd27 | 186cb851aeae2cc44b8d38d917b4b8a02de14501 | refs/heads/master | 2023-07-03T04:13:21.773198 | 2021-08-17T18:45:20 | 2021-08-17T18:45:20 | 384,851,011 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,107 | cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
bool hasSamePart(TreeNode* r1, TreeNode* r2){
if(r1 == nullptr && r2 == nullptr){
return true;
}else if(r1 == nullptr && r2 != nullptr){
return false;
}else if(r1 != nullptr && r2 == nullptr){
return true;
}else if(r1->val != r2->val){
return false;
}else if(r1->val == r2->val){
return hasSamePart(r1->left, r2->left) && hasSamePart(r1->right, r2->right);
}
}
bool dfs(TreeNode*r1, TreeNode* r2){
if(r1 == nullptr){
return false;
}else if (hasSamePart(r1,r2)){
return true;
}else{
return dfs(r1->left, r2) || dfs(r1->right, r2);
}
}
bool hasSubtree(TreeNode* pRoot1, TreeNode* pRoot2) {
if(pRoot2 == nullptr) return false;
return dfs(pRoot1, pRoot2);
}
}; | [
"hans040515@gmail.com"
] | hans040515@gmail.com |
e600a1ac47eef009f4078eeb8da44651a0764b42 | b682d77cfd5874b1bd857868505c6328520fd89b | /Arduino/SerialEditMicroscopyArduino/SerialEditMicroscopyArduino.ino | d91ca120fdbde58d2a4b5c00b8fff027e5b74ec5 | [] | no_license | StephenThornquist/FruitFly | ca383e9f981571968e1bedeef319e9d96561b89c | 8699d104128b47a8801b506060251c91862bf155 | refs/heads/master | 2021-01-17T13:33:51.726005 | 2016-07-02T22:31:40 | 2016-07-02T22:31:40 | 20,900,337 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,811 | ino | /* Write an array of firing frequencies and pulse widths and change them with a computer
For the below code, the following convention is used:
Frequencies are in Hz
Pulse widths are in milliseconds
The LED array is indexed as follows:
-----------------
|| 1 2 3 ||
|| ||
|| 4 5 6 ||
|| ||
|| 7 8 9 ||
||----------------||
NOTE: The Buckpuck interpets a high control voltage as
off and a low control voltage as on. It's stupid, but it
probably made life easier for the guy who designed it. Oh
well. Anyways, that explains why the digital write commands
seem backwards.
Stephen Thornquist March 22, 2015
*/
// indicator is the pin corresponding to the indicator LED
const int indicator = 1;
const int numPins = 12;
// This line is to map the schematized well number above onto the right entry in the pin array
// wellMap's nth entry is the index of Well #n in the array pin. It basically
// exists to make up for my sloppy wiring job. When I make a PCB I can fix this
// to make it better.
//int wellMap[numPins+1] = {0 ,1, 2,3 ,4,5,6, 7,8,9,10,11,12};
//int wellMap[numPins+1] = { 12,10,1,11,4,8,5, 9,2,6,3 ,7 ,0};
int wellMap[numPins+1] = {12,10,8,2,4,6,0,11,5,7,1 ,3 ,9};//
int pin[numPins] = {24,24,24,24,24,24,24,24,24,24,24,24};
// Timescale says how many of our selected timescale are in a second
// so if we use microseconds, we should switch this to 1000000
const int timescale = 1000;
// startTime is how long until it should start
unsigned long startTime = 00000;
// duration is how long the Arduino should run its protocol.
unsigned long duration = 12000000; // 200 minutes
// endOfDays is when the protocol should end
unsigned long endOfDays = startTime + duration;
// This block is for single wells with ongoing frequenices
// Array of frequencies desired (in Hz)
// To tell a controller to be constantly off, input 0 for frequency
double freq[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
// Array of pulse widths desired (in milliseconds)
// You don't need to worry about pulse width for constant
// LEDs.
double pulseWidth[numPins] = {90,80,70,60,50,40,30,20,10,90,80,70};
// This next block is for paired pulses:
// an array indicating at what time you gave the signal to count down from the delay
unsigned long pinInit[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
// Delay until start (minutes)
double del[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
// Gap between pulses (seconds)
double gap[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
// Array of pulse widths desired (in milliseconds)
// You don't need to worry about pulse width for constant
// LEDs.
// First pulse
double p1[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
// Second pulse
double p2[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
// This section is for block stimuli
int blockDur[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
int blockTime[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
unsigned long blockOn[numPins] = {0,0,0,0,0,0,0,0,0,0,0,0};
// Last on info for light flashing
unsigned long lastOn[numPins]={0,0,0,0,0,0,0,0,0,0,0,0};
int hasStarted = 0;
String mode = "";
char charBuffer;
/* Load setup and initialize every pin as an output.
Further, if the pin is set to be constant, initialize that.
*/
void setup() {
Serial.begin(9600);
for(int k = 0; k < numPins; k++){
pinMode(pin[k],OUTPUT);
digitalWrite(pin[k],HIGH);
}
// give the mode information time to be written to the serial port
delay(1000);
while(Serial.available()){
char buffer = Serial.read();
mode.concat(buffer);
}
if(mode == "") {
Serial.write("ERROR: No mode selected!");
delay(100000);
}
hasStarted = 0;
pinMode(indicator,OUTPUT);
Serial.print("Arduino on");
Serial.print(mode);
}
// Run this loop ad electrical nauseum
void loop() {
unsigned long currentTime = millis();
// Check to see if it's time to start or not and then turn on the light
if((currentTime > startTime) && hasStarted == 0) {
hasStarted = 1;
Serial.write("Starting expt!");
}
// single well with consistent stim mode
if(mode=="singleWells") {
if(currentTime > startTime && currentTime<endOfDays ) {
// Step through each pin, indexed from 0
for(int pinScan = 0; pinScan < numPins; pinScan++){
// See if this pin is supposed to be constantly on
if(freq[pinScan]!=0) {
// Now make sure the pin is supposed to be on (not yet implemented, was buggy)
// If it has been the pulse width since the last time the LED
// was turned on, turn it off.
if((currentTime-lastOn[pinScan]) > pulseWidth[pinScan]) {
if(pinScan == 0) {
digitalWrite(indicator,LOW);
}
digitalWrite(pin[pinScan], HIGH);
}
// If it's been timescale/frequency units of time since the LED
// was last turned on, turn it on again. Then annotate
// having done so by updating the lastOn array.
if((double(currentTime - lastOn[pinScan])*freq[pinScan])>=timescale){
if(pinScan == 0) {
digitalWrite(indicator,HIGH);
}
digitalWrite(pin[pinScan], LOW);
lastOn[pinScan] = currentTime;
}
}
else {
digitalWrite(pin[pinScan],HIGH);
}
}
}
}
// paired pulse mode
if(mode=="pairedPulse"){
if(currentTime > startTime && currentTime<endOfDays ) {
// Step through each pin, indexed from 0
for(int pinScan = 0; pinScan < numPins; pinScan++){
// See if time delay has passed since the signal was given
if((currentTime - pinInit[pinScan]) > del[pinScan]) {
// Are we in the regime of p1? If so, turn on the light
if((currentTime - pinInit[pinScan] - del[pinScan]) < p1[pinScan]) {
digitalWrite(pin[pinScan],LOW);
}
// Are we in the gap? If so, light off!
else if((currentTime - pinInit[pinScan] - del[pinScan]-p1[pinScan]) < gap[pinScan]) {
digitalWrite(pin[pinScan],HIGH);
}
// Are we in p2? Turn it back on
else if((currentTime - pinInit[pinScan] - del[pinScan]-p1[pinScan]-gap[pinScan]) < p2[pinScan]) {
digitalWrite(pin[pinScan],LOW);
}
else {
digitalWrite(pin[pinScan],HIGH);
}
}
else {
digitalWrite(pin[pinScan],HIGH);
}
}
}
}
// blocks of stim mode
if (mode == "blocks") {
if(currentTime > startTime && currentTime<endOfDays) {
// Step through each pin, indexed from 0
for(int pinScan = 0; pinScan < numPins; pinScan++){
// See if this pin is supposed to be constantly off
if(freq[pinScan]!=0) {
// Now make sure the pin is supposed to be on
// If it has been the pulse width since the last time the LED
// was turned on, turn it off. Likewise, if it's been more than blockTime
// since the block started, turn the light off (but only if blockDur isn't set to 0).
if((currentTime-lastOn[pinScan]) > pulseWidth[pinScan] || ((((currentTime-startTime) - blockOn[pinScan]) > blockDur[pinScan]) && blockDur[pinScan] != 0)) {
if(pinScan == 0) {
digitalWrite(indicator,LOW);
}
digitalWrite(pin[pinScan], HIGH);
}
// If it's been timescale/frequency units of time since the LED
// was last turned on, turn it on again. Then annotate
// having done so by updating the lastOn array.
if((double(currentTime - lastOn[pinScan])*freq[pinScan])>=timescale && ((currentTime-startTime) - blockOn[pinScan]) < blockDur[pinScan]){
if(pinScan == 0) {
digitalWrite(indicator,HIGH);
}
digitalWrite(pin[pinScan], LOW);
lastOn[pinScan] = currentTime;
}
// Update the blockOn
if (((currentTime-startTime) - blockOn[pinScan]) > blockTime[pinScan]) {
blockOn[pinScan] = currentTime;
}
}
}
}
}
if(currentTime > endOfDays) {
digitalWrite(indicator, LOW);
for(int pinScan = 0; pinScan < numPins; pinScan++) {
digitalWrite(pin[pinScan], HIGH);
}
}
}
// For when something gets written to serial port
void serialEvent() {
/* Freeze wells in the off state */
for(int k = 0; k < numPins; k++){
digitalWrite(pin[k],HIGH);
}
if (mode == "singleWells") {
int inWell = Serial.parseInt();
float inFreq = Serial.parseFloat();
int inPW = Serial.parseInt();
// Translate the well request into which pin to modify
int pinInd = wellMap[inWell];
freq[pinInd] = inFreq;
pulseWidth[pinInd] = inPW;
}
if (mode=="pairedPulse") {
unsigned long timeNow = millis();
int inWell = Serial.parseInt();
double inDelay = Serial.parseFloat();
float inP1 = Serial.parseFloat();
double inGap = Serial.parseFloat();
int inP2 = Serial.parseInt();
// Translate the well request into which pin to modify
int pinInd = wellMap[inWell];
pinInit[pinInd] = timeNow;
del[pinInd] = inDelay*60000;
gap[pinInd] = inGap*1000;
p1[pinInd] = inP1;
p2[pinInd] = inP2;
}
if (mode == "blocks") {
int inWell = Serial.parseInt();
float inFreq = Serial.parseFloat();
int inPW = Serial.parseInt();
int bd = Serial.parseInt();
int br = Serial.parseInt();
int pinInd = wellMap[inWell];
freq[pinInd] = inFreq;
pulseWidth[pinInd] = inPW;
blockDur[pinInd] = bd;
blockTime[pinInd] = br;
}
while(Serial.available()) {
Serial.read();
}
}
| [
"thornquist@fas.harvard.edu"
] | thornquist@fas.harvard.edu |
5085b61126816863d0d72234a99a7ac3869aed45 | 6e4aa50e275048cdedef07b79f5d51bd29a7bef1 | /IPST_2016_apr/apio/merchant.cpp | 3e38caffda8550e59f3e608c8b4e9187d6523995 | [] | no_license | KorlaMarch/competitive-programming | 4b0790b8aed4286cdd65cf6e4584e61376a2615e | fa8d650938ad5f158c8299199a3d3c370f298a32 | refs/heads/master | 2021-03-27T12:31:10.145264 | 2019-03-03T02:30:51 | 2019-03-03T02:30:51 | 34,978,427 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,474 | cpp | #include "stdio.h"
#include "algorithm"
#define INF 200000000000LL
int n,m,k,v,w,t;
int bi[105][1005],si[105][1005];
long long maxP[105][105];
long long dis[105][105];
long long dyn[105][105][205];
bool isSub1,isSub2;
int main(){
isSub1 = true;
isSub2 = true;
scanf("%d%d%d",&n,&m,&k);
for(int i = 1; i <= n; i++){
for(int j = 0; j < k; j++){
scanf("%d%d",&bi[i][j],&si[i][j]);
if(i!=1&&bi[i][j]!=-1){
isSub1 = false;
}
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
dis[i][j] = INF;
}
dis[i][i] = 0;
}
for(int i = 0; i < m; i++){
scanf("%d%d%d",&v,&w,&t);
dis[v][w] = t;
if(t!=1) isSub2 = false;
}
for(int v = 1; v <= n; v++){
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(dis[i][v]+dis[v][j]<dis[i][j]){
dis[i][j] = dis[i][v]+dis[v][j];
}
}
}
}
//cal maxProfit
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
maxP[i][j] = 0;
for(int x = 0; x < k; x++){
if(si[j][x]!=-1&&bi[i][x]!=-1){
maxP[i][j] = std::max(maxP[i][j],(long long)si[j][x]-bi[i][x]);
}
}
//printf("DIS %d %d : %lld : %lld\n",i,j,dis[i][j],maxP[i][j]);
}
}
if(isSub1){
//subtask 1
long long ans = 0;
for(int i = 2; i <= n; i++){
if(dis[1][i]!=INF&&dis[i][1]!=INF){
ans = std::max(ans,maxP[1][i]/(dis[1][i]+dis[i][1]));
}
}
printf("%lld\n",ans);
}else{
//subtask 2
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
for(int t = 0; t < dis[i][j] && t <= n+1; t++){
dyn[i][j][t] = -INF;
}
if(dis[i][j]!=INF){
for(int t = dis[i][j]; t <= n+1; t++){
dyn[i][j][t] = maxP[i][j];
}
}
}
}
for(int t = 1; t <= n+1; t++){
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
// dyn[i][j][t] = std::max(dyn[i][j][t],dyn[i][j][t-1]);
for(int v = 1; v <= n; v++){
for(int x = 1; x < t; x++){
if(dyn[i][v][x]!=-INF&&dyn[v][j][t-x]!=-INF){
dyn[i][j][t] = std::max(dyn[i][j][t],dyn[i][v][x]+dyn[v][j][t-x]);
}
}
}
}
}
}
long long ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
for(int x = 0; x <= n+1; x++){
//printf("DYN %d %d %d : %lld\n",i,j,x,dyn[i][j][x]);
for(int y = 0; y <= n+1; y++){
if(dyn[i][j][x]!=-INF&&dyn[j][i][y]!=-INF&&x+y!=0){
ans = std::max(ans,(dyn[i][j][x]+dyn[j][i][y])/(x+y));
}
}
}
}
}
printf("%lld\n",ans);
}
//return -1;
} | [
"korla.march@gmail.com"
] | korla.march@gmail.com |
dc1c852bad214b72ff5288ba495b3037a676a1ae | c0e0138bff95c2eac038349772e36754887a10ae | /mdk_release_18.08.10_general_purpose/tools/18.06.6/common/moviCompile/include/c++/cstdlib | fe59753954f9ed7fcf59e787b7af56255463a187 | [
"MIT",
"NCSA"
] | permissive | elfmedy/vvdn_tofa | f24d2e1adc617db5f2b1aef85f478998aa1840c9 | ce514e0506738a50c0e3f098d8363f206503a311 | refs/heads/master | 2020-04-13T17:52:19.490921 | 2018-09-25T12:01:21 | 2018-09-25T12:01:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,800 | // -*- C++ -*-
//===--------------------------- cstdlib ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSTDLIB
#define _LIBCPP_CSTDLIB
/*
cstdlib synopsis
Macros:
EXIT_FAILURE
EXIT_SUCCESS
MB_CUR_MAX
NULL
RAND_MAX
namespace std
{
Types:
size_t
div_t
ldiv_t
lldiv_t // C99
double atof (const char* nptr);
int atoi (const char* nptr);
long atol (const char* nptr);
long long atoll(const char* nptr); // C99
double strtod (const char* restrict nptr, char** restrict endptr);
float strtof (const char* restrict nptr, char** restrict endptr); // C99
long double strtold (const char* restrict nptr, char** restrict endptr); // C99
long strtol (const char* restrict nptr, char** restrict endptr, int base);
long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
int rand(void);
void srand(unsigned int seed);
void* calloc(size_t nmemb, size_t size);
void free(void* ptr);
void* malloc(size_t size);
void* realloc(void* ptr, size_t size);
void abort(void);
int atexit(void (*func)(void));
void exit(int status);
void _Exit(int status);
char* getenv(const char* name);
int system(const char* string);
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
void qsort(void* base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
int abs( int j);
long abs( long j);
long long abs(long long j); // C++0X
long labs( long j);
long long llabs(long long j); // C99
div_t div( int numer, int denom);
ldiv_t div( long numer, long denom);
lldiv_t div(long long numer, long long denom); // C++0X
ldiv_t ldiv( long numer, long denom);
lldiv_t lldiv(long long numer, long long denom); // C99
int mblen(const char* s, size_t n);
int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
int wctomb(char* s, wchar_t wchar);
size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
int at_quick_exit(void (*func)(void)) // C++11
void quick_exit(int status); // C++11
void *aligned_alloc(size_t alignment, size_t size); // C11
} // std
*/
#include <__config>
#define _LIBCPP_INCLUDING_STDC_HEADER
#include <stdlib.h>
#undef _LIBCPP_INCLUDING_STDC_HEADER
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#ifdef __GNUC__
#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
#else
#define _LIBCPP_UNREACHABLE() _VSTD::abort()
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
using ::size_t;
using ::div_t;
using ::ldiv_t;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
using ::lldiv_t;
#endif // _LIBCPP_HAS_NO_LONG_LONG
using ::atof;
using ::atoi;
using ::atol;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
using ::atoll;
#endif // _LIBCPP_HAS_NO_LONG_LONG
using ::strtod;
using ::strtof;
using ::strtold;
using ::strtol;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
using ::strtoll;
#endif // _LIBCPP_HAS_NO_LONG_LONG
using ::strtoul;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
using ::strtoull;
#endif // _LIBCPP_HAS_NO_LONG_LONG
using ::rand;
using ::srand;
using ::calloc;
using ::free;
using ::malloc;
using ::realloc;
using ::abort;
using ::atexit;
using ::exit;
using ::_Exit;
#ifndef _LIBCPP_WINDOWS_STORE_APP
using ::getenv;
using ::system;
#endif
using ::bsearch;
using ::qsort;
using ::abs;
using ::labs;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
using ::llabs;
#endif // _LIBCPP_HAS_NO_LONG_LONG
using ::div;
using ::ldiv;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
using ::lldiv;
#endif // _LIBCPP_HAS_NO_LONG_LONG
using ::mblen;
using ::mbtowc;
using ::wctomb;
using ::mbstowcs;
using ::wcstombs;
#ifdef _LIBCPP_HAS_QUICK_EXIT
using ::at_quick_exit;
using ::quick_exit;
#endif
#ifdef _LIBCPP_HAS_C11_FEATURES
using ::aligned_alloc;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTDLIB
| [
"palani.andavan@vvdntech.com"
] | palani.andavan@vvdntech.com | |
09953a38c61824a10ff60a14db19c14aa3a6558b | 457f7179c9bac639a10ca06fa449577bb392e36d | /Source/MainComponent.cpp | 0e410e471bd2d47559c1519b87cc36a91ec9abc0 | [] | no_license | samparkewolfe/Freeverb-Modification | 9f01ab9833caa5b15209a4ec72662cdc0f59e155 | a90aedd1cb780988d753b8b112dae117b3d2f4e5 | refs/heads/master | 2020-03-16T23:31:21.546618 | 2018-05-11T19:32:20 | 2018-05-11T19:32:20 | 133,080,953 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,253 | cpp | /*
==============================================================================
This file was auto-generated!
==============================================================================
*/
#include "MainComponent.h"
MainContentComponent::MainContentComponent()
{
setSize (400, 400);
// specify the number of input and output channels that we want to open
setAudioChannels (2, 2);
//Add the gui of medel to this component.
addAndMakeVisible(&model);
//Initialise all the other guis for front end.
addAndMakeVisible(&group);
group.setText("Reverb Front End");
group.setColour(GroupComponent::outlineColourId, Colours::grey);
group.toFront(false);
addAndMakeVisible(&modeToggle);
modeToggle.addListener(this);
modeToggle.setButtonText("Freeze");
addAndMakeVisible(&roomSizeSlider);
roomSizeSlider.addListener(this);
roomSizeSlider.setSliderStyle(Slider::LinearBarVertical);
roomSizeSlider.setRange(0.0, 1.0);
roomSizeSlider.setValue(0.5);
addAndMakeVisible(&dampSlider);
dampSlider.addListener(this);
dampSlider.setSliderStyle(Slider::LinearBarVertical);
dampSlider.setRange(0.0, 1.0);
dampSlider.setValue(0.5);
addAndMakeVisible(&wetSlider);
wetSlider.addListener(this);
wetSlider.setSliderStyle(Slider::LinearBarVertical);
wetSlider.setRange(0.0, 1.0);
wetSlider.setValue(0.5);
addAndMakeVisible(&drySlider);
drySlider.addListener(this);
drySlider.setSliderStyle(Slider::LinearBarVertical);
drySlider.setRange(0.0, 1.0);
drySlider.setValue(0.5);
addAndMakeVisible(&widthSlider);
widthSlider.addListener(this);
widthSlider.setSliderStyle(Slider::LinearBarVertical);
widthSlider.setRange(0.0, 1.0);
widthSlider.setValue(0.5);
addAndMakeVisible(&roomSizeLabel);
roomSizeLabel.setText("Room Size", dontSendNotification);
roomSizeLabel.attachToComponent (&roomSizeSlider, false);
addAndMakeVisible(&dampLabel);
dampLabel.setText("Damp", dontSendNotification);
dampLabel.attachToComponent (&dampSlider, false);
addAndMakeVisible(&wetLabel);
wetLabel.setText("Wet", dontSendNotification);
wetLabel.attachToComponent (&wetSlider, false);
addAndMakeVisible(&dryLabel);
dryLabel.setText("Dry", dontSendNotification);
dryLabel.attachToComponent (&drySlider, false);
addAndMakeVisible(&widthLabel);
widthLabel.setText("Stereo Mix", dontSendNotification);
widthLabel.attachToComponent (&widthSlider, false);
}
MainContentComponent::~MainContentComponent()
{
shutdownAudio();
}
void MainContentComponent::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
{
}
void MainContentComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
//Send the buffers to the reveb unit.
float** inputs = bufferToFill.buffer->getArrayOfWritePointers();
float** outputs = bufferToFill.buffer->getArrayOfWritePointers();
model.processreplace(inputs[0],inputs[1],outputs[0],outputs[1],bufferToFill.numSamples,1);
}
void MainContentComponent::releaseResources()
{
}
void MainContentComponent::paint (Graphics& g)
{
}
void MainContentComponent::resized()
{
//Draw the back end of the reverb.
Rectangle<int> areaModel(getLocalBounds());
areaModel.removeFromBottom(getHeight()/3);
areaModel.reduce(10, 10);
model.setBounds(areaModel);
//Draw the front end of the reverb.
Rectangle<int> areaSliders(getLocalBounds());
areaSliders.removeFromTop(2*getHeight()/3);
areaSliders.reduce(10, 10);
group.setBounds(areaSliders);
areaSliders.reduce(10, 10);
areaSliders.removeFromTop(30);
int sliderGap = 10;
int sliderWidth = areaSliders.getWidth()/6 - 10;
modeToggle.setBounds(areaSliders.removeFromLeft(sliderWidth));
areaSliders.removeFromLeft(sliderGap);
roomSizeSlider.setBounds(areaSliders.removeFromLeft(sliderWidth));
areaSliders.removeFromLeft(sliderGap);
dampSlider.setBounds(areaSliders.removeFromLeft(sliderWidth));
areaSliders.removeFromLeft(sliderGap);
wetSlider.setBounds(areaSliders.removeFromLeft(sliderWidth));
areaSliders.removeFromLeft(sliderGap);
drySlider.setBounds(areaSliders.removeFromLeft(sliderWidth));
areaSliders.removeFromLeft(sliderGap);
widthSlider.setBounds(areaSliders.removeFromLeft(sliderWidth));
}
void MainContentComponent::buttonClicked(juce::Button *button)
{
//Updating the button.
if(button == &modeToggle) model.setmode(button->getToggleState());
}
void MainContentComponent::sliderValueChanged(juce::Slider *slider)
{
//Updating the sliders.
if(slider == & roomSizeSlider) model.setroomsize(slider->getValue());
if(slider == & dampSlider) model.setdamp(slider->getValue());
if(slider == & wetSlider) model.setwet(slider->getValue());
if(slider == & drySlider) model.setdry(slider->getValue());
if(slider == & widthSlider) model.setwidth(slider->getValue());
}
| [
"spark041@gold.ac.uk"
] | spark041@gold.ac.uk |
211bd017c2b4de8daa21d48caf34943a2ce7578b | bd13d50be2150b24e0789774d934655511cab429 | /main.cpp | 3bfc44c768a4defba18294e52bb203e589a97e90 | [] | no_license | Centimo/Equirectangular_shader | 1319d2d03cbc14cbb45050ef9126856b4dc55468 | 582efaeeee1b1c58842fb1fcf90e127c100a3908 | refs/heads/master | 2022-02-24T17:14:58.541042 | 2019-10-03T10:02:53 | 2019-10-03T10:02:53 | 212,475,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,148 | cpp | #include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlEngine>
#include <QQmlContext>
#include <QtCore/QStandardPaths>
#include <QtCore/QStringList>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
const QUrl appPath(QUrl::fromLocalFile(app.applicationDirPath()));
const QStringList picturesLocation = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
const QUrl imagePath = picturesLocation.isEmpty() ? appPath : QUrl::fromLocalFile(picturesLocation.first());
engine.rootContext()->setContextProperty("imagePath", imagePath);
engine.load(url);
QMetaObject::invokeMethod(engine.rootObjects().first(), "init", Qt::QueuedConnection);
return app.exec();
}
| [
"mohenti@gmail.com"
] | mohenti@gmail.com |
bd7b05cd5674978563843e2e792b926080ec0eaf | 6bf03623fbe8c90c32ba101f9d6f110f3c654ce3 | /CodingTest/Google Qualification Round 2020/2.cpp | e0fa6f09509a2ca6ba8d47e7c8f7e3906a14d974 | [] | no_license | yoogle96/algorithm | 6d6a6360c0b2aae2b5a0735f7e0200b6fc37544e | bcc3232c705adc53a563681eeefd89e5b706566f | refs/heads/master | 2022-12-27T05:15:04.388117 | 2020-10-09T14:48:58 | 2020-10-09T14:48:58 | 177,144,251 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,139 | cpp | #include <bits/stdc++.h>
using namespace std;
int t;
int main() {
cin >> t;
for(int c = 1; c <= t; c++) {
string s;
cin >> s;
stack<char> stk;
char fToken = s[0];
int fTmpNum = s[0] - '0';
for(int j = 0; j < fTmpNum; j++) {
stk.push('(');
}
stk.push(s[0]);
for(int j = 0; j < fTmpNum; j++) {
stk.push(')');
}
int prv = fTmpNum;
for(int i = 1; i < s.size(); i++) {
char token = s[i];
int tmpNum = s[i] - '0';
if(tmpNum == 0) {
stk.push(token);
prv = tmpNum;
continue;
}
if(prv == 0) {
for(int j = 0; j < tmpNum; j++) {
stk.push('(');
}
stk.push(token);
for(int j = 0; j < tmpNum; j++) {
stk.push(')');
}
prv = tmpNum;
continue;
}
if(prv > tmpNum) {
for(int j = 0; j < tmpNum; j++) {
stk.pop();
}
stk.push(token);
for(int j = 0; j < tmpNum; j++) {
stk.push(')');
}
}else if(prv < tmpNum) {
stk.pop();
for(int j = 0; j < tmpNum - 1; j++) {
stk.push('(');
}
stk.push(token);
for(int j = 0; j < tmpNum; j++) {
stk.push(')');
}
}else {
for(int j = 0; j < tmpNum; j++) {
stk.pop();
}
stk.push(token);
for(int j = 0; j < tmpNum; j++) {
stk.push(')');
}
}
prv = tmpNum;
}
string ans;
while(!stk.empty()) {
ans += (stk.top());
stk.pop();
}
reverse(ans.begin(), ans.end());
cout << "Case #" << c << ": " << ans << "\n";
}
return 0;
} | [
"dmltjs851@gmail.com"
] | dmltjs851@gmail.com |
2ed13f5c45471ff7ad4e18210553342ca8baf178 | 0e9fe7b68d17c979396f31e733b44e4a9fe6535d | /Ground.cpp | 6f8bb622aa941f7db724dba627d04ee2531ba537 | [] | no_license | dylanswiggett/GroundSim | 7c7a33f24b2d2cb345f48f5f34d52ad884e0aa2e | 691bf13face9e2b9b578d5993006c6687693e276 | refs/heads/master | 2021-01-19T12:59:24.167746 | 2015-11-03T22:33:33 | 2015-11-03T22:33:33 | 37,783,566 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,327 | cpp | #include <iostream>
#include "Ground.hpp"
using namespace std;
Ground::Ground()
{
x = y = 0;
forceUp = forceDown = 0;
mass = 1;
active = true;
falling = false;
}
Ground::~Ground()
{
// Nada! (yet)
}
void Ground::setP(int newX, int newY)
{
// TODO: Update neighbor info?
x = newX;
y = newY;
}
void Ground::updateF(Ground ***map, int w, int h)
{
// TODO
addF(0, GRAVITY);
Ground *below = getAt(map, 0, -1, w, h);
Ground *above = getAt(map, 0, 1, w, h);
Ground *left = getAt(map, -1, 0, w, h);
Ground *right = getAt(map, 1, 0, w, h);
float f_lu, f_ru, f_uu, f_du,
f_ld, f_rd, f_ud, f_dd;
f_lu = f_ru = f_uu = f_du = f_ld = f_rd = f_ud = f_dd = 0;
if (below) {
f_dd += 1;
}
if (above) {
f_uu += 1;
f_ud += .8;
}
if (left) {
f_ld += .3;
f_lu += .3;
}
if (right) {
f_rd += .3;
f_ru += .3;
}
float total_u = f_lu + f_ru + f_uu + f_du;
float total_d = f_ld + f_rd + f_ud + f_dd;
if (total_u > 1) {
f_lu /= total_u;
f_ru /= total_u;
f_du /= total_u;
f_uu /= total_u;
total_u = 1;
}
if (total_d > 1) {
f_ld /= total_d;
f_rd /= total_d;
f_dd /= total_d;
f_ud /= total_d;
total_d = 1;
}
float damping = .97;
float fu = forceUp * damping;
float fd = forceDown * damping;
if (above) above->addF(fu * f_uu, fd * f_ud);
if (below) below->addF(fu * f_du, fd * f_dd);
if (left) left->addF(fu * f_lu, fd * f_ld);
if (right) right->addF(fu * f_ru, fd * f_rd);
addF(-forceUp * total_u, -forceDown * total_d);
if (falling && forceDown > FALL_THRESH)
forceDown = FALL_THRESH;
/*
float subtract = 0;
if (below != NULL) {
below->addF(0, forceDown);
addF(0, -forceDown);
} else if (y == 0) {
addF(2 * forceDown, 0);
}
if (left != NULL) {
subtract += .31;
left->addF(forceUp * .3, forceDown * .3);
}
if (right != NULL) {
subtract += .31;
right->addF(forceUp * .3, forceDown * .3);
}
addF(forceUp * -subtract, forceDown * -subtract);
if (above != NULL) {
above->addF(forceUp, 0);
addF(-forceUp, 0);
} else {
addF(-forceUp, 0);
}
*/
}
void Ground::addF(float upF, float downF)
{
forceUp += upF;
forceDown += downF;
}
Ground *Ground::getAt(Ground ***map, int dx, int dy, int w, int h)
{
if (y + dy >= 0 && x + dx >= 0 && x + dx < w && y + dy < h)
return map[x + dx][y + dy];
return NULL;
}
bool Ground::tryMoveTo(Ground ***map, int dx, int dy)
{
if (map[x + dx][y + dy] != NULL)
return false;
map[x + dx][y + dy] = this;
map[x][y] = NULL;
x += dx;
y += dy;
return true;
}
void Ground::updateP(Ground ***map, int w, int h)
{
if (forceUp > forceDown) {
forceUp -= forceDown;
forceDown = 0;
} else if (forceDown > forceUp) {
forceDown -= forceUp;
forceUp = 0;
}
if (forceDown > 255)
forceDown = 255;
if (y == 0 || getAt(map, 0, -1, w, h) != NULL)
falling = false;
else if (forceDown > FALL_THRESH)
falling = true;
if (falling)
tryMoveTo(map, 0, -1);
}
void Ground::getP(int *x_out, int *y_out)
{
*x_out = x;
*y_out = y;
}
float Ground::getForceUp()
{
return forceUp;
}
float Ground::getForceDown()
{
return forceDown;
}
bool Ground::isActive()
{
return active;
}
bool Ground::isFalling()
{
return falling;
}
| [
"dylanswiggett@gmail.com"
] | dylanswiggett@gmail.com |
6ee5275a6cdc6caa592c59b64efd300316c0c072 | b3f6798a798ea55bdd556853e9ab56a33ae8495d | /Cpp-learning_record/C++提高编程/STL/仿函数/一元谓词.cpp | 5a04162c189bafce035a0b60d30fae8f58a7a296 | [] | no_license | rongkai-zhang/Cpp-Learning-Record | 45ded879f2eeb54b8b434a1bf196e63d72940105 | 15c8e49f32a576d42751f808e5e6afb8981da721 | refs/heads/master | 2022-12-06T15:40:44.590206 | 2020-09-05T02:05:31 | 2020-09-05T02:05:31 | 288,056,130 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 828 | cpp | #include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
//仿函数返回值类型是bool数据类型 ,称为谓词
//一元谓词
class GreaterFive
{
public:
bool operator()(int val) //有一个参数就叫一元谓词
{
return val>5;
}
};
void test01()
{
vector<int> v;
for(int i = 0; i < 10; i++)
{
v.push_back(i);
}
//查找容器中有没有大于5的数字
//GreatFive() 匿名的函数对象
vector<int>::iterator it = find_if(v.begin(),v.end(),GreaterFive()); //find_if 按条件的方式来查找 三个参数 begin end 谓词
if(it == v.end())
{
cout<<"未找到"<<endl;
}
else
{
cout<<"找到了大于5的数字为:"<< *it<<endl;
}
}
int main()
{
test01();
return 0;
} | [
"1508839152@qq.com"
] | 1508839152@qq.com |
af71e9b3c5489495d84964415aef0ccf348ccd45 | 32cecae39d0914e5db2428c6cb9a072b6dbb256c | /include/player.h | 7bf2a3739e5fecef3d39b22c67889db141f28c1e | [] | no_license | 4rChon/pong | c4ae2f57c20039d77cc0506c12587be7c74b9e0c | 484cc08ade258217414ebe7f166d29627ab3fbe8 | refs/heads/master | 2016-09-05T17:05:01.799300 | 2015-07-21T23:52:50 | 2015-07-21T23:52:50 | 38,660,776 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 755 | h | #pragma once
#include <texture.h>
#include <string>
class Player
{
private:
int id;
double x;
double y;
int width;
int height;
double velocity;
Texture* texture;
public:
Player(int id, double x, double y);
Player(int id, double x, double y, int width, int height);
void move();
void draw();
void set_x(double x);
void set_y(double y);
void set_velocity(double velocity);
void set_texture(Texture* texture);
double get_x() const;
double get_y() const;
int get_width() const;
int get_height() const;
double get_velocity() const;
std::string to_string() const;
};
| [
"bendbug+git@gmail.com"
] | bendbug+git@gmail.com |
69af0a80e463a294d014e603f45551c1d9e5d8cb | c19710dae66be631d380337f7fad09b73bad5a7b | /my_sort.cpp | 288359af836d618f0e83c281878c76884960f75a | [] | no_license | mengbin92/sort | 9b4707142f6fa51721d52092eb1d2332faaf1b19 | 42db8206013f91d3257b376e2e2333c2953769d4 | refs/heads/master | 2022-03-10T22:06:54.126258 | 2017-10-10T13:14:54 | 2017-10-10T13:14:54 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,631 | cpp | #include "my_sort.h"
void swap(int & a, int & b)
{
int tmp = a;
a = b;
b = tmp;
}
void swap(int arr[], int i, int j)
{
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
//选择排序
void selectSort(int arr[], int arrSize)
{
int min = 0;//初始时最小值位置
for (int i = 0; i < arrSize - 1; ++i)
{
min = i;
for (int j = i + 1; j < arrSize; ++j)
if (arr[min] > arr[j])
min = j;
if (min != i)
swap(arr[min], arr[i]);
}
}
//插入排序
void insertSort(int arr[], int arrSize)
{
int i, j;
for (i = 1; i < arrSize; ++i)
{
int tmp = arr[i];
for (j = i; j > 0 && tmp<arr[j-1]; --j)
{
arr[j] = arr[j - 1];
}
arr[j] = tmp;
}
}
//冒泡排序
void bubbleSort(int arr[], int arrSize)
{
for (int i = 0; i < arrSize; ++i)
{
for (int j = 1; j < arrSize - i; ++j)
{
if (arr[j] < arr[j - 1])
swap(arr[j], arr[j - 1]);
}
}
}
//希尔排序
void shellSort(int arr[], int arrSize)
{
int step = arrSize / 2;//设置步长
int i, j;
int tmp;
while (step >= 1)
{
for (i = step; i < arrSize; ++i)
{
tmp = arr[i];
j = i - step;
while (j > 0 && arr[j] > tmp)
{
arr[j + step] = arr[j];
j -= step;
}
arr[j + step] = tmp;
}
step /= 2;
}
}
//快速排序
void quickSort(int arr[], int start, int end)
{
if (start >= end)
return;
int i = start;//起始位置
int j = end;//最后一个元素的位置
//基准值
int tmp = arr[start];//以起始位置为基准
while (i < j)
{
while (i < j&&arr[j] >= tmp)
j--;
if (i < j)
{
arr[i] = arr[j];
i++;
}
while (i < j&&arr[i] < tmp)
i++;
if (i < j)
{
arr[j] = arr[i];
j--;
}
}
arr[i] = tmp;
quickSort(arr, start, i - 1);
quickSort(arr, i + 1, end);
}
//将两个有序数列a[first...mid]和a[mid+1...last]合并。
void mergeArray(int a[], int first, int mid, int last, int temp[])
{
int i = first; // 第一个有序序列的开始下标
int j = mid + 1; // 第2个有序序列的开始下标
int length = 0;
// 合并两个有序序列
while (i <= mid && j <= last)
{
// 找二者中比较小的数
if (a[i] < a[j])
{
temp[length] = a[i];
i++;
}
else
{
temp[length] = a[j];
j++;
}
length++;
}
// 还剩下一个有序序列中有数据
while (i <= mid)
{
temp[length] = a[i];
i++;
length++;
}
while (j <= last)
{
temp[length++] = a[j++];
}
// 覆盖原来位置的无序序列
for (int i = 0; i < length; ++i)
{
// 找到原来 的第一个有序序列的开始位置 - 开始覆盖
a[first + i] = temp[i];
}
}
//归并排序
void mergeSort(int a[], int first, int last, int temp[])
{
// 递归结束的条件
if (first == last)
{
return;
}
// 从中间位置拆分
int mid = (first + last) / 2;
// 拆分
// 左半边
mergeSort(a, first, mid, temp);
// 右半边
mergeSort(a, mid + 1, last, temp);
// 合并两个有序序列
mergeArray(a, first, mid, last, temp);
}
//堆排序
void heapSort(int arr[], int arrSize)
{
int heapSize = buildHeap(arr, arrSize);
while (heapSize > 1)
{
swap(arr, 0, --heapSize);
heap(arr, 0, heapSize);
}
}
//建堆
int buildHeap(int arr[], int arrSize)
{
int heapSize = arrSize;
for (int i = heapSize / 2 - 1; i >= 0; i--)
heap(arr, i, heapSize);
return heapSize;
}
//从指定节点开始向下进行堆调整
void heap(int arr[], int i, int size)
{
int leftChild = 2 * i + 1;
int rightChild = 2 * i + 1;
int max = i;
if (leftChild<size&&arr[leftChild]>arr[max])
max = leftChild;
if (rightChild<size&&arr[rightChild]>arr[max])
max = rightChild;
if (max != i)
{
swap(arr, i, max);
heap(arr, max, size);
}
} | [
"mengbin1992@outlook.com"
] | mengbin1992@outlook.com |
c610ceca0cc36ddeda9c3a389d3aca3ee60a8f82 | 11cddfab71a7e3d98183b7299132b5493bc6d58c | /third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.cc | e2c183601dbf38f37a15fd44acec30741d10da40 | [
"BSD-3-Clause",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"BSD-2-Clause",
"LGPL-2.1-only",
"LGPL-2.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-2.0-only",
"LicenseRef-scancode-other-copyleft"
] | permissive | bathepawan/chromium | 41aa3da80ad748e0d38fe2688013365335797f1f | 53f2426666b7273b2b4af35527b0f507d1512e64 | refs/heads/master | 2022-12-20T11:22:16.319857 | 2020-02-14T14:10:10 | 2020-02-14T14:10:10 | 240,524,190 | 1 | 0 | BSD-3-Clause | 2020-02-14T14:17:38 | 2020-02-14T14:17:37 | null | UTF-8 | C++ | false | false | 17,850 | cc | // Copyright 2019 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 "third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.h"
#include "third_party/blink/renderer/core/editing/inline_box_traversal.h"
#include "third_party/blink/renderer/core/editing/position_with_affinity.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_caret_position.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_fragment_items_builder.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_item.h"
#include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h"
namespace blink {
NGFragmentItem::NGFragmentItem(const NGPhysicalTextFragment& text)
: layout_object_(text.GetLayoutObject()),
text_({text.TextShapeResult(), text.TextOffset()}),
rect_({PhysicalOffset(), text.Size()}),
type_(kText),
sub_type_(static_cast<unsigned>(text.TextType())),
style_variant_(static_cast<unsigned>(text.StyleVariant())),
is_generated_text_(text.IsGeneratedText()),
is_hidden_for_paint_(text.IsHiddenForPaint()),
text_direction_(static_cast<unsigned>(text.ResolvedDirection())),
ink_overflow_computed_(false) {
#if DCHECK_IS_ON()
if (text_.shape_result) {
DCHECK_EQ(text_.shape_result->StartIndex(), StartOffset());
DCHECK_EQ(text_.shape_result->EndIndex(), EndOffset());
}
#endif
if (text.TextType() == NGPhysicalTextFragment::kGeneratedText) {
type_ = kGeneratedText;
// Note: Because of |text_| and |generated_text_| are in same union and
// we initialize |text_| instead of |generated_text_|, we should construct
// |generated_text_.text_| instead copying, |generated_text_.text = ...|.
new (&generated_text_.text) String(text.Text().ToString());
}
}
NGFragmentItem::NGFragmentItem(const NGPhysicalLineBoxFragment& line,
wtf_size_t item_count)
: layout_object_(line.ContainerLayoutObject()),
line_({&line, item_count}),
rect_({PhysicalOffset(), line.Size()}),
type_(kLine),
sub_type_(static_cast<unsigned>(line.LineBoxType())),
style_variant_(static_cast<unsigned>(line.StyleVariant())),
is_hidden_for_paint_(false),
text_direction_(static_cast<unsigned>(line.BaseDirection())),
ink_overflow_computed_(false) {}
NGFragmentItem::NGFragmentItem(const NGPhysicalBoxFragment& box,
TextDirection resolved_direction)
: layout_object_(box.GetLayoutObject()),
box_({&box, 1}),
rect_({PhysicalOffset(), box.Size()}),
type_(kBox),
style_variant_(static_cast<unsigned>(box.StyleVariant())),
is_hidden_for_paint_(box.IsHiddenForPaint()),
text_direction_(static_cast<unsigned>(resolved_direction)),
ink_overflow_computed_(false) {}
NGFragmentItem::NGFragmentItem(const NGInlineItem& inline_item,
const PhysicalSize& size)
: layout_object_(inline_item.GetLayoutObject()),
box_({nullptr, 1}),
rect_({PhysicalOffset(), size}),
type_(kBox),
style_variant_(static_cast<unsigned>(inline_item.StyleVariant())),
is_hidden_for_paint_(false),
text_direction_(static_cast<unsigned>(TextDirection::kLtr)),
ink_overflow_computed_(false) {
DCHECK_EQ(inline_item.Type(), NGInlineItem::kOpenTag);
DCHECK(layout_object_);
DCHECK(layout_object_->IsLayoutInline());
}
NGFragmentItem::~NGFragmentItem() {
switch (Type()) {
case kText:
text_.~TextItem();
break;
case kGeneratedText:
generated_text_.~GeneratedTextItem();
break;
case kLine:
line_.~LineItem();
break;
case kBox:
box_.~BoxItem();
break;
}
}
bool NGFragmentItem::IsSiblingOf(const NGFragmentItem& other) const {
if (!GetLayoutObject())
return !other.GetLayoutObject();
if (!other.GetLayoutObject())
return false;
if (GetLayoutObject()->Parent() == other.GetLayoutObject()->Parent())
return true;
// To traverse list marker and line box of <li> with |MoveToNextSibling()|,
// we think list marker and <li> are sibling.
// See hittesting/culled-inline-crash.html (skip list marker)
// See fast/events/onclick-list-marker.html (hit on list marker)
if (IsListMarker())
return GetLayoutObject()->Parent() == other.GetLayoutObject();
if (other.IsListMarker())
return other.GetLayoutObject()->Parent() == GetLayoutObject();
return false;
}
bool NGFragmentItem::IsInlineBox() const {
if (Type() == kBox) {
if (const NGPhysicalBoxFragment* box = BoxFragment())
return box->IsInlineBox();
DCHECK(GetLayoutObject()->IsLayoutInline());
return true;
}
return false;
}
bool NGFragmentItem::IsAtomicInline() const {
if (Type() != kBox)
return false;
if (const NGPhysicalBoxFragment* box = BoxFragment())
return box->IsAtomicInline();
return false;
}
bool NGFragmentItem::IsFloating() const {
if (const NGPhysicalBoxFragment* box = BoxFragment())
return box->IsFloating();
return false;
}
bool NGFragmentItem::IsEmptyLineBox() const {
return LineBoxType() == NGLineBoxType::kEmptyLineBox;
}
bool NGFragmentItem::IsGeneratedText() const {
if (Type() == kText || Type() == kGeneratedText)
return is_generated_text_;
NOTREACHED();
return false;
}
bool NGFragmentItem::IsListMarker() const {
return layout_object_ && layout_object_->IsLayoutNGListMarker();
}
bool NGFragmentItem::HasOverflowClip() const {
if (const NGPhysicalBoxFragment* fragment = BoxFragment())
return fragment->HasOverflowClip();
return false;
}
bool NGFragmentItem::HasSelfPaintingLayer() const {
if (const NGPhysicalBoxFragment* fragment = BoxFragment())
return fragment->HasSelfPaintingLayer();
return false;
}
inline const LayoutBox* NGFragmentItem::InkOverflowOwnerBox() const {
if (Type() == kBox)
return ToLayoutBoxOrNull(GetLayoutObject());
return nullptr;
}
inline LayoutBox* NGFragmentItem::MutableInkOverflowOwnerBox() {
if (Type() == kBox)
return ToLayoutBoxOrNull(const_cast<LayoutObject*>(layout_object_));
return nullptr;
}
PhysicalRect NGFragmentItem::SelfInkOverflow() const {
if (const LayoutBox* box = InkOverflowOwnerBox())
return box->PhysicalSelfVisualOverflowRect();
if (!ink_overflow_)
return LocalRect();
return ink_overflow_->self_ink_overflow;
}
PhysicalRect NGFragmentItem::InkOverflow() const {
if (const LayoutBox* box = InkOverflowOwnerBox())
return box->PhysicalVisualOverflowRect();
if (!ink_overflow_)
return LocalRect();
if (!IsContainer() || HasOverflowClip())
return ink_overflow_->self_ink_overflow;
const NGContainerInkOverflow& container_ink_overflow =
static_cast<NGContainerInkOverflow&>(*ink_overflow_);
return container_ink_overflow.SelfAndContentsInkOverflow();
}
const ShapeResultView* NGFragmentItem::TextShapeResult() const {
if (Type() == kText)
return text_.shape_result.get();
if (Type() == kGeneratedText)
return generated_text_.shape_result.get();
NOTREACHED();
return nullptr;
}
NGTextOffset NGFragmentItem::TextOffset() const {
if (Type() == kText)
return text_.text_offset;
if (Type() == kGeneratedText)
return {0, generated_text_.text.length()};
NOTREACHED();
return {};
}
StringView NGFragmentItem::Text(const NGFragmentItems& items) const {
if (Type() == kText) {
return StringView(items.Text(UsesFirstLineStyle()), text_.text_offset.start,
text_.text_offset.Length());
}
if (Type() == kGeneratedText)
return GeneratedText();
NOTREACHED();
return StringView();
}
NGTextFragmentPaintInfo NGFragmentItem::TextPaintInfo(
const NGFragmentItems& items) const {
if (Type() == kText) {
return {items.Text(UsesFirstLineStyle()), text_.text_offset.start,
text_.text_offset.end, text_.shape_result.get()};
}
if (Type() == kGeneratedText) {
return {generated_text_.text, 0, generated_text_.text.length(),
generated_text_.shape_result.get()};
}
NOTREACHED();
return {};
}
TextDirection NGFragmentItem::BaseDirection() const {
DCHECK_EQ(Type(), kLine);
return static_cast<TextDirection>(text_direction_);
}
TextDirection NGFragmentItem::ResolvedDirection() const {
DCHECK(Type() == kText || Type() == kGeneratedText || IsAtomicInline());
return static_cast<TextDirection>(text_direction_);
}
String NGFragmentItem::DebugName() const {
// TODO(yosin): Once |NGPaintFragment| is removed, we should get rid of
// following if-statements.
// For ease of rebasing, we use same |DebugName()| as |NGPaintFrgment|.
if (Type() == NGFragmentItem::kBox) {
StringBuilder name;
name.Append("NGPhysicalBoxFragment ");
name.Append(layout_object_->DebugName());
return name.ToString();
}
if (Type() == NGFragmentItem::kText) {
StringBuilder name;
name.Append("NGPhysicalTextFragment '");
name.Append(Text(*layout_object_->ContainingBlockFlowFragment()->Items()));
name.Append('\'');
return name.ToString();
}
if (Type() == NGFragmentItem::kLine)
return "NGPhysicalLineBoxFragment";
return "NGFragmentItem";
}
IntRect NGFragmentItem::VisualRect() const {
// TODO(kojii): Need to reconsider the storage of |VisualRect|, to integrate
// better with |FragmentData| and to avoid dependency to |LayoutObject|.
DCHECK(GetLayoutObject());
return GetLayoutObject()->VisualRectForInlineBox();
}
IntRect NGFragmentItem::PartialInvalidationVisualRect() const {
// TODO(yosin): Need to reconsider the storage of |VisualRect|, to integrate
// better with |FragmentData| and to avoid dependency to |LayoutObject|.
DCHECK(GetLayoutObject());
return GetLayoutObject()->PartialInvalidationVisualRectForInlineBox();
}
PhysicalRect NGFragmentItem::LocalVisualRectFor(
const LayoutObject& layout_object) {
DCHECK(RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled());
DCHECK(layout_object.IsInLayoutNGInlineFormattingContext());
PhysicalRect visual_rect;
NGInlineCursor cursor;
for (cursor.MoveTo(layout_object); cursor;
cursor.MoveToNextForSameLayoutObject()) {
DCHECK(cursor.Current().Item());
const NGFragmentItem& item = *cursor.Current().Item();
if (UNLIKELY(item.IsHiddenForPaint()))
continue;
PhysicalRect child_visual_rect = item.SelfInkOverflow();
child_visual_rect.offset += item.OffsetInContainerBlock();
visual_rect.Unite(child_visual_rect);
}
return visual_rect;
}
PhysicalRect NGFragmentItem::RecalcInkOverflowForCursor(
NGInlineCursor* cursor) {
DCHECK(cursor);
PhysicalRect contents_ink_overflow;
while (*cursor) {
const NGFragmentItem* item = cursor->CurrentItem();
DCHECK(item);
PhysicalRect child_rect;
item->GetMutableForPainting().RecalcInkOverflow(cursor, &child_rect);
if (item->HasSelfPaintingLayer())
continue;
if (!child_rect.IsEmpty()) {
child_rect.offset += item->OffsetInContainerBlock();
contents_ink_overflow.Unite(child_rect);
}
}
return contents_ink_overflow;
}
void NGFragmentItem::RecalcInkOverflow(
NGInlineCursor* cursor,
PhysicalRect* self_and_contents_rect_out) {
DCHECK_EQ(this, cursor->CurrentItem());
if (IsText()) {
cursor->MoveToNext();
// Re-computing text item is not necessary, because all changes that needs
// to re-compute ink overflow invalidate layout.
if (ink_overflow_computed_) {
*self_and_contents_rect_out = SelfInkOverflow();
return;
}
ink_overflow_computed_ = true;
NGTextFragmentPaintInfo paint_info = TextPaintInfo(cursor->Items());
if (paint_info.shape_result) {
NGInkOverflow::ComputeTextInkOverflow(paint_info, Style(), Size(),
&ink_overflow_);
*self_and_contents_rect_out =
ink_overflow_ ? ink_overflow_->self_ink_overflow : LocalRect();
return;
}
DCHECK(!ink_overflow_);
*self_and_contents_rect_out = LocalRect();
return;
}
// If this item has an owner |LayoutBox|, let it compute. It will call back NG
// to compute and store the result to |LayoutBox|. Pre-paint requires ink
// overflow to be stored in |LayoutBox|.
if (LayoutBox* owner_box = MutableInkOverflowOwnerBox()) {
DCHECK(!HasChildren());
cursor->MoveToNextSibling();
owner_box->RecalcNormalFlowChildVisualOverflowIfNeeded();
*self_and_contents_rect_out = owner_box->PhysicalVisualOverflowRect();
return;
}
// Re-compute descendants, then compute the contents ink overflow from them.
NGInlineCursor descendants_cursor = cursor->CursorForDescendants();
cursor->MoveToNextSibling();
PhysicalRect contents_rect = RecalcInkOverflowForCursor(&descendants_cursor);
// |contents_rect| is relative to the inline formatting context. Make it
// relative to |this|.
contents_rect.offset -= OffsetInContainerBlock();
// Compute the self ink overflow.
PhysicalRect self_rect;
if (Type() == kLine) {
// Line boxes don't have self overflow. Compute content overflow only.
*self_and_contents_rect_out = contents_rect;
} else if (Type() == kBox) {
if (const NGPhysicalBoxFragment* box_fragment = BoxFragment()) {
DCHECK(box_fragment->IsInlineBox());
self_rect = box_fragment->ComputeSelfInkOverflow();
} else {
self_rect = LocalRect();
}
*self_and_contents_rect_out = UnionRect(self_rect, contents_rect);
} else {
NOTREACHED();
}
SECURITY_CHECK(IsContainer());
if (LocalRect().Contains(*self_and_contents_rect_out)) {
ink_overflow_ = nullptr;
} else if (!ink_overflow_) {
ink_overflow_ =
std::make_unique<NGContainerInkOverflow>(self_rect, contents_rect);
} else {
NGContainerInkOverflow* ink_overflow =
static_cast<NGContainerInkOverflow*>(ink_overflow_.get());
ink_overflow->self_ink_overflow = self_rect;
ink_overflow->contents_ink_overflow = contents_rect;
}
}
void NGFragmentItem::SetDeltaToNextForSameLayoutObject(wtf_size_t delta) {
DCHECK_NE(delta, 0u);
delta_to_next_for_same_layout_object_ = delta;
}
PositionWithAffinity NGFragmentItem::PositionForPointInText(
const PhysicalOffset& point,
const NGInlineCursor& cursor) const {
DCHECK_EQ(Type(), kText);
DCHECK_EQ(cursor.CurrentItem(), this);
const unsigned text_offset = TextOffsetForPoint(point, cursor.Items());
const NGCaretPosition unadjusted_position{
cursor, NGCaretPositionType::kAtTextOffset, text_offset};
if (RuntimeEnabledFeatures::BidiCaretAffinityEnabled())
return unadjusted_position.ToPositionInDOMTreeWithAffinity();
if (text_offset > StartOffset() && text_offset < EndOffset())
return unadjusted_position.ToPositionInDOMTreeWithAffinity();
return BidiAdjustment::AdjustForHitTest(unadjusted_position)
.ToPositionInDOMTreeWithAffinity();
}
unsigned NGFragmentItem::TextOffsetForPoint(
const PhysicalOffset& point,
const NGFragmentItems& items) const {
DCHECK_EQ(Type(), kText);
const ComputedStyle& style = Style();
const LayoutUnit& point_in_line_direction =
style.IsHorizontalWritingMode() ? point.left : point.top;
if (const ShapeResultView* shape_result = TextShapeResult()) {
// TODO(layout-dev): Move caret logic out of ShapeResult into separate
// support class for code health and to avoid this copy.
return shape_result->CreateShapeResult()->CaretOffsetForHitTest(
point_in_line_direction.ToFloat(), Text(items), BreakGlyphs) +
StartOffset();
}
// Flow control fragments such as forced line break, tabulation, soft-wrap
// opportunities, etc. do not have ShapeResult.
DCHECK(IsFlowControl());
// Zero-inline-size objects such as newline always return the start offset.
LogicalSize size = Size().ConvertToLogical(style.GetWritingMode());
if (!size.inline_size)
return StartOffset();
// Sized objects such as tabulation returns the next offset if the given point
// is on the right half.
LayoutUnit inline_offset = IsLtr(ResolvedDirection())
? point_in_line_direction
: size.inline_size - point_in_line_direction;
DCHECK_EQ(1u, TextLength());
return inline_offset <= size.inline_size / 2 ? StartOffset() : EndOffset();
}
std::ostream& operator<<(std::ostream& ostream, const NGFragmentItem& item) {
ostream << "{";
switch (item.Type()) {
case NGFragmentItem::kText:
ostream << "Text " << item.StartOffset() << "-" << item.EndOffset() << " "
<< (IsLtr(item.ResolvedDirection()) ? "LTR" : "RTL");
break;
case NGFragmentItem::kGeneratedText:
ostream << "GeneratedText \"" << item.GeneratedText() << "\"";
break;
case NGFragmentItem::kLine:
ostream << "Line #descendants=" << item.DescendantsCount() << " "
<< (IsLtr(item.BaseDirection()) ? "LTR" : "RTL");
break;
case NGFragmentItem::kBox:
ostream << "Box #descendants=" << item.DescendantsCount();
if (item.IsAtomicInline()) {
ostream << " AtomicInline"
<< (IsLtr(item.ResolvedDirection()) ? "LTR" : "RTL");
}
break;
}
ostream << " ";
switch (item.StyleVariant()) {
case NGStyleVariant::kStandard:
ostream << "Standard";
break;
case NGStyleVariant::kFirstLine:
ostream << "FirstLine";
break;
case NGStyleVariant::kEllipsis:
ostream << "Ellipsis";
break;
}
return ostream << "}";
}
std::ostream& operator<<(std::ostream& ostream, const NGFragmentItem* item) {
if (!item)
return ostream << "<null>";
return ostream << *item;
}
} // namespace blink
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
02a2d41490a3dfcd2b09bbca888a7a6baddf83ca | 0edccce062bc5ff3dfaa121c05eee48938144563 | /P4/parser.cpp | 24b65fcb56ca2f2666a11c02ba3e27494191cb76 | [] | no_license | bkedge/FS16-to-ASM-Compiler | 569eb96452fc4b0d1a717ad999a89065372ab49b | f2173bd0912fb80070e33ac5eaf4dd68e341c30d | refs/heads/master | 2021-01-12T08:27:16.690288 | 2017-04-15T21:22:18 | 2017-04-15T21:22:18 | 76,584,981 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,581 | cpp | #include "token.h"
#include "scanner.h"
#include "parser.h"
#include "node.h"
#include "treePrint.h"
using namespace std;
FILE *fp = NULL;
token tk;
int linenumber = 1;
node_t *makeNode(string label, int level)
{
node_t *node = new node_t;
node->label = label;
node->level = level;
//node->nodeToken = NULL;
//node->tempToken = NULL;
node->child1 = NULL;
node->child2 = NULL;
node->child3 = NULL;
node->child4 = NULL;
return node;
}
//Outputs error message and exits
void error(string errorString)
{
cout << "ERROR: " << errorString << " at line: " << tk.lineNum << endl;
exit(1);
}
//Main parsing call
node_t *parser()
{
cout << "Working\n";
node_t *node;
tk = scan(fp, linenumber);
node = program();
if(tk.tokenID == EOF_Tk)
{
cout << "Parse OK" << endl;
}
else
{
error("parser(): Got token " + tk.instance + ", expected EOF");
}
return node;
//cout << "Line number: " << tk.lineNum << ", " << "Token ID: " << tokenNames[tk.tokenID] << ", " << "Instance: " << tk.instance << endl;
}
// <program> -> <vars> <block>
node_t *program()
{
int level = 0;
node_t *node = makeNode("<program>", level);
node->child1 = vars(level);
node->child2 = block(level);
return node;
}
// <vars> -> empty | Var Identifier <mvars>
node_t *vars(int level)
{
level++;
node_t *node = makeNode("<vars>", level);
if(tk.tokenID == VAR_Tk)
{
tk = scan(fp, linenumber); //Consume Var token
if(tk.tokenID == ID_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber); //Consume ID Token
node->child1 = mvars(level);
return node;
}
else
{
error("vars(): Got token " + tk.instance + ", expected ID_Tk");
}
}
return NULL;
}
// <block> -> Begin <vars> <stats> End
node_t *block(int level)
{
level++;
node_t *node = makeNode("<block>", level);
if(tk.tokenID == BEGIN_Tk)
{
tk = scan(fp, linenumber); //Consume Begin token
node->child1 = vars(level);
node->child2 = stats(level);
if(tk.tokenID == END_Tk)
{
tk = scan(fp, linenumber); //Consume End token
return node;
}
else
{
error("block(): Got token " + tk.instance + ", expected END_Tk");
}
}
else
{
error("block(): Got token " + tk.instance + ", expected BEGIN_Tk");
}
}
// <mvars> -> empty | : : Identifier <mvars>
node_t *mvars(int level)
{
level++;
node_t *node = makeNode("<mvars>", level);
if(tk.tokenID == Colon_Tk)
{
tk = scan(fp, linenumber); //Consume Colon token
if(tk.tokenID == Colon_Tk)
{
tk = scan(fp, linenumber); //Consume Colon token
if(tk.tokenID == ID_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber); //Consume ID token
node->child1 = mvars(level);
return node;
}
else
{
error("mvars(): Got token " + tk.instance + ", expected ID_Tk");
}
}
else
{
error("mvars(): Got token " + tk.instance + ", expected Colon_Tk");
}
}
return NULL; //empty
}
// <expr> -> <M> + <expr> | <M>
node_t *expr(int level)
{
level++;
node_t *node = makeNode("<expr>", level);
node->child1 = M(level); //<M>
if(tk.tokenID == Plus_Tk) // Predict +
{
node->nodeToken = tk;
tk = scan(fp, linenumber); //Consume +
node->child2 = expr(level);
return node;
}
return node;
}
// <M> -> <T> - <M> | <T>
node_t *M(int level)
{
level++;
node_t *node = makeNode("<M>", level);
node->child1 = T(level);
if(tk.tokenID == Minus_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber); //Consume -
node->child2 = M(level);
return node;
}
return node;
}
// <T> -> <F> * <T> | <F> / <T> | <F>
node_t *T(int level)
{
level++;
node_t *node = makeNode("<T>", level);
node->child1 = F(level);
if(tk.tokenID == Asterisk_Tk)
{
node->nodeToken = tk; //Put asterisk in instance
tk = scan(fp, linenumber);
node->child2 = T(level);
return node;
}
else if(tk.tokenID == Slash_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
node->child2 = T(level);
return node;
}
return node;
}
node_t *F(int level)
{
level++;
node_t *node = makeNode("<F>", level);
if(tk.tokenID == Minus_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
node->child1 = F(level);
return node;
}
else
{
node->child1 = R(level);
}
return node;
}
//NEXT
node_t *R(int level)
{
level++;
node_t *node = makeNode("<R>", level);
if(tk.tokenID == LeftBracket_Tk)
{
tk = scan(fp, linenumber);
node ->child1 = expr(level);
if(tk.tokenID == RightBracket_Tk)
{
tk = scan(fp, linenumber);
return node;
}
else
{
error("R(): Got token " + tk.instance + ", expected RightBracket_Tk");
}
}
else if(tk.tokenID == ID_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
return node;
}
else if(tk.tokenID == NUM_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
return node;
}
else
{
error("R(): Got token " + tk.instance + ", expected LeftBracket_Tk");
}
}
node_t *stats(int level)
{
level++;
node_t *node = makeNode("<stats>", level);
node->child1 = stat(level);
node->child2 = mStat(level);
return node;
}
node_t *mStat(int level)
{
level++;
node_t *node = makeNode("<mStat>", level);
if(tk.tokenID == SCAN_Tk || tk.tokenID == PRINT_Tk || tk.tokenID == BEGIN_Tk || tk.tokenID == LeftBracket_Tk || tk.tokenID == LOOP_Tk || tk.tokenID == ID_Tk)
{
node->child1 = stat(level);
node->child2 = mStat(level);
return node;
}
else
{
return NULL;
}
}
node_t *stat(int level)
{
level++;
node_t *node = makeNode("<stat>", level);
if(tk.tokenID == SCAN_Tk)
{
node->child1 = in(level);
return node;
}
else if(tk.tokenID == PRINT_Tk)
{
node->child1 = out(level);
return node;
}
else if(tk.tokenID == BEGIN_Tk)
{
node->child1 = block(level);
return node;
}
else if(tk.tokenID == LeftBracket_Tk)
{
node->child1 = ifFunction(level);
return node;
}
else if(tk.tokenID == LOOP_Tk)
{
node->child1 = loopFunction(level);
return node;
}
else if(tk.tokenID == ID_Tk)
{
node->child1 = assignFunction(level);
return node;
}
else
{
error("stat(): Got token " + tk.instance + ", expected SCAN_Tk or PRINT_Tk or BEGIN_Tk or LeftBracket_Tk or LOOP_Tk or ID_Tk");
}
}
node_t *in(int level)
{
level++;
node_t *node = makeNode("<in>", level);
if(tk.tokenID == SCAN_Tk)
{
tk = scan(fp, linenumber);
if(tk.tokenID == Colon_Tk)
{
tk = scan(fp, linenumber);
if(tk.tokenID == ID_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
if(tk.tokenID == Period_Tk)
{
tk = scan(fp, linenumber);
return node;
}
else
{
error("in(): Got token " + tk.instance + ", expected Period_Tk");
}
}
else
{
error("in(): Got token " + tk.instance + ", expected ID_Tk");
}
}
else
{
error("in(): Got token " + tk.instance + ", expected Colon_Tk");
}
}
else
{
error("in(): Got token " + tk.instance + ", expected SCAN_Tk");
}
}
node_t *out(int level)
{
level++;
node_t *node = makeNode("<out>", level);
if(tk.tokenID == PRINT_Tk)
{
tk = scan(fp, linenumber);
if(tk.tokenID == LeftBracket_Tk)
{
tk = scan(fp, linenumber);
node->child1 = expr(level);
if(tk.tokenID == RightBracket_Tk)
{
tk = scan(fp, linenumber);
if(tk.tokenID == Period_Tk)
{
tk = scan(fp, linenumber);
return node;
}
else
{
error("out(): Got token " + tk.instance + ", expected Period_Tk");
}
}
else
{
error("out(): Got token " + tk.instance + ", expected RightBracket_Tk");
}
}
else
{
error("out(): Got token " + tk.instance + ", expected LeftBracket_Tk");
}
}
else
{
error("out(): Got token " + tk.instance + ", expected PRINT_Tk");
}
}
node_t *ifFunction(int level)
{
level++;
node_t *node = makeNode("<if>", level);
if(tk.tokenID == LeftBracket_Tk)
{
tk = scan(fp, linenumber);
node->child1 = expr(level);
node->child2 = RO(level);
node->child3 = expr(level);
if(tk.tokenID == RightBracket_Tk)
{
tk = scan(fp, linenumber);
if(tk.tokenID == IFF_Tk)
{
tk = scan(fp, linenumber);
node->child4 = block(level);
return node;
}
else
{
error("ifFunction(): Got token " + tk.instance + ", expected IFF_Tk");
}
}
else
{
error("ifFunction(): Got token " + tk.instance + ", expected RightBracket_Tk");
}
}
else
{
error("ifFunction(): Got token " + tk.instance + ", expected LeftBracket_Tk");
}
}
node_t *loopFunction(int level)
{
level++;
node_t *node = makeNode("<loop>", level);
if(tk.tokenID == LOOP_Tk)
{
tk = scan(fp, linenumber);
if(tk.tokenID == LeftBracket_Tk)
{
tk = scan(fp, linenumber);
node->child1 = expr(level);
node->child2 = RO(level);
node->child3 = expr(level);
if(tk.tokenID == RightBracket_Tk)
{
tk = scan(fp, linenumber);
node->child4 = block(level);
return node;
}
else
{
error("loopFunction(): Got token " + tk.instance + ", expected RightBracket_Tk");
}
}
else
{
error("loopFunction(): Got token " + tk.instance + ", expected LeftBracket_Tk");
}
}
else
{
error("loopFunction(): Got token " + tk.instance + ", expected LOOP_Tk");
}
}
node_t *assignFunction(int level)
{
level++;
node_t *node = makeNode("<assign>", level);
if(tk.tokenID == ID_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
if(tk.tokenID == DoubleEquals_Tk)
{
node->tempToken = tk; //Put == in Node
tk = scan(fp, linenumber);
node->child1 = expr(level);
if(tk.tokenID == Period_Tk)
{
tk = scan(fp, linenumber);
return node;
}
else
{
error("assignFunction(): Got token " + tk.instance + ", expected Period_Tk");
}
}
else
{
error("assignFunction(): Got token " + tk.instance + ", expected DoubleEquals_Tk");
}
}
else
{
error("assignFunction(): Got token " + tk.instance + ", expected ID_Tk");
}
}
node_t *RO(int level)
{
level++;
node_t *node = makeNode("<RO>", level);
if(tk.tokenID == GreaterThanEqual_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
return node;
}
else if(tk.tokenID == LessThanEqual_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
return node;
}
else if(tk.tokenID == EQUAL_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
return node;
}
else if(tk.tokenID == GreaterThan_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
return node;
}
else if(tk.tokenID == LessThan_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
return node;
}
else if(tk.tokenID == EqualBangEqual_Tk)
{
node->nodeToken = tk;
tk = scan(fp, linenumber);
return node;
}
else
{
error("RO(): Got token " + tk.instance + ", expected GreaterThanEqual_Tk or LessThanEqual_Tk or EQUAL_Tk or GreaterThan_Tk or LessThan_Tk or EqualBangEqual_Tk");
}
}
| [
"bradykedge@gmail.com"
] | bradykedge@gmail.com |
5064b1e7a167a6df558b72570741d56dbaf8ff57 | 5fe10289a7f8b0130e9782ce66a62ca13534227e | /arduino_sketch/arduino_sketch.ino | 7af7ceba13df0f53931b338760cc54046f19e40d | [] | no_license | abdulmajeed90/mcp3901 | 23e74e87f6c4d8eb6f21be17e92a082c0854bd18 | 7be78a91a4c06b39cc7363b95c7ca40776d3bfa2 | refs/heads/master | 2021-01-17T05:19:50.780196 | 2012-05-05T22:51:10 | 2012-05-05T22:51:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,813 | ino | /*
MCP3901 Test Read
Frank Maker
04/28/12
This example controls an Microchip MCP3901 16-bit ADC
The MCP3901 has a SPI interface with the following settings:
* MSB first
* CPOL = 0, CPHA = 0 (MODE = 0)
- SCK low when idle
- Latch on rising edge
-------------------------------------
| A6 | A5 | A4 | A3 | A2 | A1 | R/W |
-------------------------------------
| | | |
| Device | Register Address | R/W |
Arduino Mega -> MCP3901 Evaluation Board connections:
* RESET -> 48
* SDO -> 50
* SDI -> 51
* SCK -> 52
* CS -> 53
NOTE: These settings are defaults so no configuration is necessary
Both ADC channels can be read back continously by setting
the STATUS/COM register
* READ<1:0> = 0b10 // Loops on register types (just ADCs)
* DRMODE<1:0> = 0b00 // DR signal when both ADCs are done
*/
#include <SPI.h>
#include <math.h>
/* Arduino */
#define RESET 48
#define CS 53
#define CHAR_BIT 8
/* MCP3901 */
#define BIT_16 0xFFFF
#define NUM_CHAN 2
#define WIDTH 2
#define VREF 2.37F
#define BITS 16
#define GAIN 1
#define SINC_ORDER 3
/* Global */
float volt_per_cnt;
void setup()
{
// Setup serial
Serial.begin(9600);
Serial.println("MCP3901 Test v0.1");
// Setup reset
pinMode(RESET, OUTPUT);
digitalWrite(RESET, LOW);
digitalWrite(RESET, HIGH);
// Setup SPI
pinMode(CS, OUTPUT);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(SPI_CLOCK_DIV128); /* Slowest clock for testing */
SPI.begin();
volt_per_cnt = 2.37F / (pow(2,BITS-1)) / GAIN / SINC_ORDER;
Serial.println(volt_per_cnt);
};
float convert(int counts)
{
return counts * volt_per_cnt;
}
void print_chans(float ch0, unsigned int ch0_cnts, float ch1, unsigned int ch1_cnts)
{
Serial.print("CH0:");
Serial.print(ch0);
Serial.print(" (");
Serial.print(ch0_cnts, DEC);
Serial.print(") ");
Serial.print("CH1:");
Serial.print(ch1);
Serial.print(" (");
Serial.print(ch1_cnts, DEC);
Serial.print(") ");
Serial.print('\r');
}
void loop()
{
int i, j;
float ch0, ch1;
unsigned int ch0_cnts, ch1_cnts;
/* Activate SPI device */
digitalWrite(CS, LOW);
/* Send device 0, read command for address 0x0 */
SPI.transfer(0x1);
while (1) {
for(i=0; i<NUM_CHAN; i++){
float value;
unsigned int cnts = 0;
for(j=0; j<WIDTH; j++){
byte ret;
ret = SPI.transfer(0x0);
cnts += ret;
cnts <<= (WIDTH - 1 - j) * CHAR_BIT;
}
value = convert(cnts);
switch(i){
case 0:
ch0 = value;
ch0_cnts = cnts;
break;
case 1:
ch1 = value;
ch1_cnts = cnts;
break;
}
}
print_chans(ch0, ch0_cnts, ch1, ch1_cnts);
delay(100);
}
/* Deactivate SPI device */
digitalWrite(CS, HIGH);
};
| [
"frank.maker@gmail.com"
] | frank.maker@gmail.com |
2036b2d57482c2aba024e8d1abfcb88d94dce778 | 80611edad5cb7908aeaa87713fca1267a513d123 | /3-2(3-2).cpp | 1d791f3cea08ff770660f3f74d97b05734e70d1e | [] | no_license | zxf501/501 | 8f89aed239bc569fcc8c4bf914f5d1a46cdfb1d0 | 25e111a3f2c67a2cc6a94a650dbcfc2555617be9 | refs/heads/main | 2023-02-17T21:30:27.495026 | 2021-01-18T13:14:11 | 2021-01-18T13:14:11 | 304,785,221 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 199 | cpp |
#include <stdio.h>
int main(void)
{
int a;
scanf("%d",&a);
if(a == 0)
puts("a为0");
else if(a < 0 )
puts("a为负数");
else if(a > 0 )
puts("a为正数");
return 0;
}
| [
"1191626820@qq.com"
] | 1191626820@qq.com |
c43b33bb72e0529323fda14cbd4e4970e319a4a8 | 674f269f6ca90298d22452d24656cedb45f1fc95 | /gazebo/math/Vector2i_TEST.cc | 0dee03ab71ee6ae19656a0d7373d101d8cdda8eb | [
"Apache-2.0"
] | permissive | mingfeisun/gazebo | f4187a5214cafd3fab6921e3cc62f4dadddf14ea | f3eae789c738f040b8fb27c2dc16dc4c06f2495c | refs/heads/master | 2021-07-07T05:19:48.545813 | 2019-01-11T12:35:31 | 2019-01-11T12:35:31 | 132,331,071 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,753 | cc | /*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <gtest/gtest.h>
#include "gazebo/math/Vector2i.hh"
#ifndef _WIN32
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
using namespace gazebo;
class Vector2iTest : public ::testing::Test { };
TEST_F(Vector2iTest, Vector2i)
{
{
math::Vector2i v;
EXPECT_EQ(0, v.x);
EXPECT_EQ(0, v.y);
}
// Constructor
math::Vector2i v(1, 2);
EXPECT_EQ(1, v.x);
EXPECT_EQ(2, v.y);
// ::Distance
EXPECT_EQ(2, v.Distance(math::Vector2i(0, 0)));
// ::Normalize
v.Normalize();
EXPECT_TRUE(v == math::Vector2i(0, 1));
// ::Set
v.Set(4, 5);
EXPECT_TRUE(v == math::Vector2i(4, 5));
// ::operator=
v = math::Vector2i(6, 7);
EXPECT_TRUE(v == math::Vector2i(6, 7));
// ::operator= int
v = 5;
EXPECT_TRUE(v == math::Vector2i(5, 5));
// ::operator+
v = v + math::Vector2i(1, 2);
EXPECT_TRUE(v == math::Vector2i(6, 7));
// ::operator +=
v += math::Vector2i(5, 6);
EXPECT_TRUE(v == math::Vector2i(11, 13));
// ::operator -
v = v - math::Vector2i(2, 4);
EXPECT_TRUE(v == math::Vector2i(9, 9));
// ::operator -=
v.Set(2, 4);
v -= math::Vector2i(1, 6);
EXPECT_TRUE(v == math::Vector2i(1, -2));
// ::operator /
v.Set(10, 6);
v = v / math::Vector2i(2, 3);
EXPECT_TRUE(v == math::Vector2i(5, 2));
// ::operator /=
v.Set(10, 6);
v /= math::Vector2i(2, 3);
EXPECT_TRUE(v == math::Vector2i(5, 2));
// ::operator / int
v.Set(10, 6);
v = v / 2;
EXPECT_TRUE(v == math::Vector2i(5, 3));
// ::operator /= int
v.Set(10, 6);
v /= 2;
EXPECT_TRUE(v == math::Vector2i(5, 3));
// ::operator * int
v.Set(10, 6);
v = v * 2;
EXPECT_TRUE(v == math::Vector2i(20, 12));
// ::operator * int
v.Set(10, 6);
v *= 2;
EXPECT_TRUE(v == math::Vector2i(20, 12));
// ::operator * vector2i
v.Set(10, 6);
v = v * math::Vector2i(2, 4);
EXPECT_TRUE(v == math::Vector2i(20, 24));
// ::operator *= vector2i
v.Set(10, 6);
v *= math::Vector2i(2, 4);
EXPECT_TRUE(v == math::Vector2i(20, 24));
// ::IsFinite
EXPECT_TRUE(v.IsFinite());
// ::operator[]
v.Set(6, 7);
EXPECT_EQ(6, v[0]);
EXPECT_EQ(7, v[1]);
}
| [
"mingfei.sun.hk@gmail.com"
] | mingfei.sun.hk@gmail.com |
46e8c985a8603651f4ae781ff31313762ceecf6b | ace6943f9290f4befadcbaf6996dcd36a63eaea3 | /Lab3Exempluu.cpp | 1fb28fb7fa2c6add0498c1e9e078b0837c951562 | [] | no_license | AlbertJunior/GPC | 64b5a88fcefb24c0679ff191d24ce7408a5449d6 | 37eeaf6025a44f67d7f39b67838646e683d23b45 | refs/heads/main | 2023-07-17T14:05:20.449678 | 2021-09-04T20:08:34 | 2021-09-04T20:08:34 | 403,146,195 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,316 | cpp | // Lab3Exempluu.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "pch.h"
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <cfloat>
#include <cstring>
#include "glut.h"
#include <iostream>
#include <vector>
using namespace std;
// dimensiunea ferestrei in pixeli
#define dim 300
// numarul maxim de iteratii pentru testarea apartenentei la mult.Julia-Fatou
#define NRITER_JF 5000
#define NRITER_MDB 5000
// modulul maxim pentru testarea apartenentei la mult.Julia-Fatou
#define MODMAX_JF 10000000
#define MODMAX_MDB 2
// ratii ptr. CJuliaFatou
#define RX_JF 0.01
#define RY_JF 0.01
#define RX_MDB 0.01
#define RY_MDB 0.01
unsigned char prevKey;
class Color {
public:
Color(double r, double g, double b) {
this->r = r;
this->g = g;
this->b = b;
}
double getR() {
return r;
}
double getG() {
return g;
}
double getB() {
return b;
}
private:
double r;
double g;
double b;
};
vector<Color*> colors;
void createColors(int numberOfColors) {
double stepsPerColor = numberOfColors / 3.0;
int stepsPerColorInt = stepsPerColor + 0.5;
int step = 1;
double r = 0.0;
double g = 0.0;
double b = 0.0;
while (step < stepsPerColorInt)
{
colors.push_back(new Color(r, g, b));
r += 1.0 / stepsPerColorInt;
step++;
}
r = 0.5;
step = 0;
while (step < stepsPerColorInt)
{
colors.push_back(new Color(r, g, b));
g += 1.0 / stepsPerColorInt;
step++;
}
r = 0.1;
g = 0.1;
step = 0;
while (step < stepsPerColorInt)
{
colors.push_back(new Color(r, g, b));
b += 1.0 / stepsPerColorInt;
step++;
}
}
class CComplex {
public:
CComplex() : re(0.0), im(0.0) {}
CComplex(double re1, double im1) : re(re1 * 1.0), im(im1 * 1.0) {}
CComplex(const CComplex &c) : re(c.re), im(c.im) {}
~CComplex() {}
CComplex &operator=(CComplex &c)
{
re = c.re;
im = c.im;
return *this;
}
double getRe() { return re; }
void setRe(double re1) { re = re1; }
double getIm() { return im; }
void setIm(double im1) { im = im1; }
double getModul() { return sqrt(re * re + im * im); }
int operator==(CComplex &c1)
{
return ((re == c1.re) && (im == c1.im));
}
CComplex pow2()
{
CComplex rez;
rez.re = powl(re * 1.0, 2) - powl(im * 1.0, 2);
rez.im = 2.0 * re * im;
return rez;
}
friend CComplex& operator+(CComplex &c1, CComplex &c2);
friend CComplex& operator*(CComplex &c1, CComplex &c2);
void print(FILE *f)
{
fprintf(f, "%.20f%+.20f i", re, im);
}
private:
double re, im;
};
CComplex& operator +(CComplex &c1, CComplex &c2)
{
CComplex *rez = new CComplex(c1.re + c2.re, c1.im + c2.im);
return *rez;
}
CComplex& operator*(CComplex &c1, CComplex &c2)
{
CComplex *rez = new CComplex(c1.re * c2.re - c1.im * c2.im,
c1.re * c2.im + c1.im * c2.re);
return *rez;
}
class CJuliaFatou {
public:
CJuliaFatou()
{
// m.c se initializeaza implicit cu 0+0i
m.nriter = NRITER_JF;
m.modmax = MODMAX_JF;
}
CJuliaFatou(CComplex &c)
{
m.c = c;
m.nriter = NRITER_JF;
m.modmax = MODMAX_JF;
}
~CJuliaFatou() {}
void setmodmax(double v) { assert(v <= MODMAX_JF); m.modmax = v; }
double getmodmax() { return m.modmax; }
void setnriter(int v) { assert(v <= NRITER_JF); m.nriter = v; }
int getnriter() { return m.nriter; }
// testeaza daca x apartine multimii Julia-Fatou Jc
// returneaza 0 daca apartine, -1 daca converge finit, +1 daca converge infinit
int isIn(CComplex &x)
{
int rez = 0;
// tablou in care vor fi memorate valorile procesului iterativ z_n+1 = z_n * z_n + c
CComplex z0, z1;
z0 = x;
for (int i = 1; i < m.nriter; i++)
{
z1 = z0 * z0 + m.c;
if (z1 == z0)
{
// x nu apartine m.J-F deoarece procesul iterativ converge finit
rez = -1;
break;
}
else if (z1.getModul() > m.modmax)
{
// x nu apartine m.J-F deoarece procesul iterativ converge la infinit
rez = 1;
break;
}
z0 = z1;
}
return rez;
}
// afisarea multimii J-F care intersecteaza multimea argument
void display(double xmin, double ymin, double xmax, double ymax)
{
glPushMatrix();
glLoadIdentity();
// glTranslated((xmin + xmax) * 1.0 / (xmin - xmax), (ymin + ymax) * 1.0 / (ymin - ymax), 0);
// glScaled(1.0 / (xmax - xmin), 1.0 / (ymax - ymin), 1);
// afisarea propriu-zisa
glBegin(GL_POINTS);
for (double x = xmin; x <= xmax; x += RX_JF)
for (double y = ymin; y <= ymax; y += RY_JF)
{
CComplex z(x, y);
int r = isIn(z);
// z.print(stdout);
if (r == 0)
{
// fprintf(stdout, " \n");
glVertex3d(x, y, 0);
}
else if (r == -1)
{
// fprintf(stdout, " converge finit\n");
}
else if (r == 1)
{
// fprintf(stdout, " converge infinit\n");
}
}
fprintf(stdout, "STOP\n");
glEnd();
glPopMatrix();
}
private:
struct SDate {
CComplex c;
// nr. de iteratii
int nriter;
// modulul maxim
double modmax;
} m;
};
// multimea Julia-Fatou pentru z0 = 0 si c = -0.12375+0.056805i
void Display1() {
CComplex c(-0.12375, 0.056805);
CJuliaFatou cjf(c);
glColor3f(1.0, 0.1, 0.1);
cjf.setnriter(30);
cjf.display(-0.8, -0.4, 0.8, 0.4);
}
// multimea Julia-Fatou pentru z0 = 0 si c = -0.012+0.74i
void Display2() {
CComplex c(-0.012, 0.74);
CJuliaFatou cjf(c);
glColor3f(1.0, 0.1, 0.1);
cjf.setnriter(30);
cjf.display(-1, -1, 1, 1);
}
class Mandelbrot {
public:
Mandelbrot()
{
m.nriter = NRITER_MDB;
m.modmax = MODMAX_MDB;
}
~Mandelbrot() {}
void setmodmax(double v) { assert(v <= MODMAX_MDB); m.modmax = v; }
double getmodmax() { return m.modmax; }
void setnriter(int v) { assert(v <= NRITER_MDB); m.nriter = v; }
int getnriter() { return m.nriter; }
// testeaza daca x apartine multimii Julia-Fatou Jc
// returneaza 0 daca apartine, -1 daca converge finit, +1 daca converge infinit
int isIn(CComplex &x)
{
int rez = 0;
int steps =0;
// tablou in care vor fi memorate valorile procesului iterativ z_n+1 = z_n * z_n + c
CComplex z1, z2;
z1 = x;
for (int i = 2; i < m.nriter; i++)
{
steps++;
z2 = z1 * z1 + x;
if (z1.getModul() > m.modmax)
{
// x nu apartine m.J-F deoarece procesul iterativ converge la infinit
rez = steps;
break;
}
z1 = z2;
}
return rez;
}
void display(double xmin, double ymin, double xmax, double ymax)
{
int numberOfColors = 10;
glPushMatrix();
glLoadIdentity();
glTranslated((xmin + xmax) * 2.0 / (xmin - xmax),
(ymin + ymax) * 2.0 / (ymin - ymax), 0);
glScaled(2.0 / (xmax - xmin), 2.0 / (ymax - ymin), 1);
// afisarea propriu-zisa
glBegin(GL_POINTS);
createColors(m.nriter);
createColors(m.nriter);
createColors(m.nriter);
fprintf(stdout, "%d\n", colors.size());
int rmax = 0;
for (double x = xmin; x <= xmax; x += RX_MDB)
for (double y = ymin; y <= ymax; y += RY_MDB)
{
CComplex z(x, y);
int r = isIn(z);
glColor3f(1.0, 0.1, 0.1);
if (r == 0)
{
glColor3f(colors[0]->getR(), colors[0]->getG(), colors[0]->getB());
glVertex3d(x, y, 0);
}
else
{
//fprintf(stdout, " %d\n", r);
double value = double(r * colors.size())/ double(m.nriter);
int intValue = value;
//fprintf(stdout, " %d\n", intValue);
//fprintf(stdout, " %lf\n", value);
glColor3f(colors[intValue]->getR(), colors[intValue]->getG(), colors[intValue]->getB());
//glColor3f(1.0, (1-value)*(1-value), 1.0);
glVertex3d(x, y, 1);
}
}
fprintf(stdout, "STOP\n");
fprintf(stdout, "%d\n", rmax);
glEnd();
glPopMatrix();
}
private:
struct SDate {
// nr. de iteratii
int nriter;
// modulul maxim
double modmax;
} m;
};
void Display3() {
Mandelbrot* mdb = new Mandelbrot();
//glColor3f(1.0, 0.1, 0.1);
mdb->setnriter(50);
mdb->display(-2, -2, 2, 2);
}
void Init(void) {
glClearColor(1.0, 1.0, 1.0, 1.0);
glLineWidth(1);
// glPointSize(3);
glPolygonMode(GL_FRONT, GL_LINE);
}
void Display(void) {
switch (prevKey) {
case '1':
glClear(GL_COLOR_BUFFER_BIT);
Display1();
break;
case '2':
glClear(GL_COLOR_BUFFER_BIT);
Display2();
break;
case '3':
glClear(GL_COLOR_BUFFER_BIT);
Display3();
break;
default:
break;
}
glFlush();
}
void Reshape(int w, int h) {
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
}
void KeyboardFunc(unsigned char key, int x, int y) {
prevKey = key;
if (key == 27) // escape
exit(0);
glutPostRedisplay();
}
void MouseFunc(int button, int state, int x, int y) {
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitWindowSize(dim, dim);
glutInitWindowPosition(100, 100);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow(argv[0]);
Init();
glutReshapeFunc(Reshape);
glutKeyboardFunc(KeyboardFunc);
glutMouseFunc(MouseFunc);
glutDisplayFunc(Display);
glutMainLoop();
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
e580a3abd798b990bdacf93acf3592d51893a66f | d2d6aae454fd2042c39127e65fce4362aba67d97 | /build/Android/Preview/app/src/main/include/Uno.Time.OffsetDateTime.h | 838292dd8f1c0a30a1370fd6ab7aae027cffe4b4 | [] | no_license | Medbeji/Eventy | de88386ff9826b411b243d7719b22ff5493f18f5 | 521261bca5b00ba879e14a2992e6980b225c50d4 | refs/heads/master | 2021-01-23T00:34:16.273411 | 2017-09-24T21:16:34 | 2017-09-24T21:16:34 | 92,812,809 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,492 | h | // This file was generated based on '/Users/medbeji/Library/Application Support/Fusetools/Packages/UnoCore/0.47.13/source/uno/time/$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.Object.h>
#include <Uno.Time.Offset.h>
namespace g{namespace Uno{namespace Time{struct LocalDateTime;}}}
namespace g{namespace Uno{namespace Time{struct OffsetDateTime;}}}
namespace g{
namespace Uno{
namespace Time{
// public sealed class OffsetDateTime :1726
// {
uType* OffsetDateTime_typeof();
void OffsetDateTime__ctor__fn(OffsetDateTime* __this, ::g::Uno::Time::LocalDateTime* localDateTime, ::g::Uno::Time::Offset* offset);
void OffsetDateTime__get_Day_fn(OffsetDateTime* __this, int* __retval);
void OffsetDateTime__Equals_fn(OffsetDateTime* __this, uObject* obj, bool* __retval);
void OffsetDateTime__Equals2_fn(OffsetDateTime* __this, OffsetDateTime* other, bool* __retval);
void OffsetDateTime__GetHashCode_fn(OffsetDateTime* __this, int* __retval);
void OffsetDateTime__get_Hour_fn(OffsetDateTime* __this, int* __retval);
void OffsetDateTime__get_Millisecond_fn(OffsetDateTime* __this, int* __retval);
void OffsetDateTime__get_Minute_fn(OffsetDateTime* __this, int* __retval);
void OffsetDateTime__get_Month_fn(OffsetDateTime* __this, int* __retval);
void OffsetDateTime__New1_fn(::g::Uno::Time::LocalDateTime* localDateTime, ::g::Uno::Time::Offset* offset, OffsetDateTime** __retval);
void OffsetDateTime__get_Offset_fn(OffsetDateTime* __this, ::g::Uno::Time::Offset* __retval);
void OffsetDateTime__op_Equality_fn(OffsetDateTime* left, OffsetDateTime* right, bool* __retval);
void OffsetDateTime__get_Second_fn(OffsetDateTime* __this, int* __retval);
void OffsetDateTime__ToString_fn(OffsetDateTime* __this, uString** __retval);
void OffsetDateTime__get_Year_fn(OffsetDateTime* __this, int* __retval);
struct OffsetDateTime : uObject
{
uStrong< ::g::Uno::Time::LocalDateTime*> _localDateTime;
::g::Uno::Time::Offset _offset;
void ctor_(::g::Uno::Time::LocalDateTime* localDateTime, ::g::Uno::Time::Offset offset);
int Day();
bool Equals2(OffsetDateTime* other);
int Hour();
int Millisecond();
int Minute();
int Month();
::g::Uno::Time::Offset Offset();
int Second();
int Year();
static OffsetDateTime* New1(::g::Uno::Time::LocalDateTime* localDateTime, ::g::Uno::Time::Offset offset);
static bool op_Equality(OffsetDateTime* left, OffsetDateTime* right);
};
// }
}}} // ::g::Uno::Time
| [
"medbeji@MacBook-Pro-de-MedBeji.local"
] | medbeji@MacBook-Pro-de-MedBeji.local |
df3513a6985c903d653280bff98a0f78bcb67f54 | b0c5aee821edea5f04459b209f531b7cc36d31aa | /tests/newtestclass.h | 5337c253bbbaddad8f9fc7adb436d0dd8653d311 | [] | no_license | 8Observer8/AcmpAlg_03_Palindrome | 3a231f4a548be04cc76cb6f8acba64fe18aada12 | 879bfb104b5fa37dd8a0e4b775ffca9b8b756f30 | refs/heads/master | 2020-03-30T00:10:40.814841 | 2013-11-01T14:48:45 | 2013-11-01T14:48:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 803 | h | /*
* File: newtestclass.h
* Author: Ivan
*
* Created on Nov 1, 2013, 4:27:17 PM
*/
#ifndef NEWTESTCLASS_H
#define NEWTESTCLASS_H
#include <cppunit/extensions/HelperMacros.h>
class newtestclass : public CPPUNIT_NS::TestFixture {
CPPUNIT_TEST_SUITE(newtestclass);
CPPUNIT_TEST(testIsPalindrome_01);
CPPUNIT_TEST(testIsPalindrome_02);
CPPUNIT_TEST(testIsPalindrome_03);
CPPUNIT_TEST(testIsPalindrome_04);
CPPUNIT_TEST(testIsPalindrome_05);
CPPUNIT_TEST_SUITE_END();
public:
newtestclass();
virtual ~newtestclass();
void setUp();
void tearDown();
private:
void testIsPalindrome_01();
void testIsPalindrome_02();
void testIsPalindrome_03();
void testIsPalindrome_04();
void testIsPalindrome_05();
};
#endif /* NEWTESTCLASS_H */
| [
"8observer8@gmail.com"
] | 8observer8@gmail.com |
d4777befac209db81c4a8e57f9c7e60fff59972b | 2727072679f44891d3340803b52b189e7dfb9f35 | /source/QtLocation/QPlaceManagerSlots.h | 91618019ab592c66cbe1e63e8a4ac6ef0631d92b | [
"MIT"
] | permissive | MahmoudFayed/Qt5xHb | 2a4b11df293986cfcd90df572ee24cf017593cd0 | 0b60965b06b3d91da665974f5b39edb34758bca7 | refs/heads/master | 2020-03-22T21:27:02.532270 | 2018-07-10T16:08:30 | 2018-07-10T16:08:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,797 | h | /*
Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
*/
/*
DO NOT EDIT THIS FILE - the content was created using a source code generator
*/
#ifndef QPLACEMANAGERSLOTS_H
#define QPLACEMANAGERSLOTS_H
#include <QObject>
#include <QCoreApplication>
#include <QString>
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
#include <QPlaceManager>
#endif
#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_signals.h"
class QPlaceManagerSlots: public QObject
{
Q_OBJECT
public:
QPlaceManagerSlots(QObject *parent = 0);
~QPlaceManagerSlots();
public slots:
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void finished( QPlaceReply * reply );
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void error( QPlaceReply * reply, QPlaceReply::Error error, const QString & errorString = QString() );
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void placeAdded( const QString & placeId );
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void placeUpdated( const QString & placeId );
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void placeRemoved( const QString & placeId );
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void categoryAdded( const QPlaceCategory & category, const QString & parentId );
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void categoryUpdated( const QPlaceCategory & category, const QString & parentId );
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void categoryRemoved( const QString & categoryId, const QString & parentId );
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
void dataChanged();
#endif
};
#endif /* QPLACEMANAGERSLOTS_H */
| [
"5998677+marcosgambeta@users.noreply.github.com"
] | 5998677+marcosgambeta@users.noreply.github.com |
c42277e85d255f9589948c0601e3df42cf652e8a | 1f34a5354422748d547791b3439b1ae7a0fd9414 | /parser.h | 5cd152e7c0b9a99f89e7f109b9c121f6b087f48c | [] | no_license | twelvefish/POSDhw | f76b3041003a151389dc4216605cc411a9f488af | 8f09aa7ad987f1c4aad48a8aa2774088fd68907a | refs/heads/master | 2021-09-03T01:00:29.604693 | 2018-01-04T11:45:46 | 2018-01-04T11:45:46 | 103,518,563 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,701 | h | #ifndef PARSER_H
#define PARSER_H
#include <gtest/gtest.h>
#include <vector>
#include <string>
#include <stack>
#include "list.h"
#include "atom.h"
#include "variable.h"
#include "scanner.h"
#include "struct.h"
#include "number.h"
#include "exp.h"
using namespace std;
class Parser
{
public:
Parser(Scanner scanner) : _scanner(scanner), _terms(){}
Term* createTerm(){
int token = _scanner.nextToken();
_currentToken = token;
if(token == VAR){
for (int i = 0; i < table.size(); i++){
if (symtable[_scanner.tokenValue()].first == table[i]->symbol()){
return table[i];
}
}
Variable *variable = new Variable(symtable[_scanner.tokenValue()].first);
table.push_back(variable);
return variable;
}else if(token == NUMBER){
return new Number(_scanner.tokenValue());
}else if(token == ATOM || token == ATOMSC){
Atom* atom = new Atom(symtable[_scanner.tokenValue()].first);
if(_scanner.currentChar() == '(' ) {
return structure();
}
else
return atom;
}
else if(token == '['){
return list();
}
return nullptr;
}
Term * structure() {
Atom structName = Atom(symtable[_scanner.tokenValue()].first);
int startIndexOfStructArgs = _terms.size();
_scanner.nextToken();
createTerms();
if(_currentToken == ')')
{
vector<Term *> args(_terms.begin() + startIndexOfStructArgs, _terms.end());
_terms.erase(_terms.begin() + startIndexOfStructArgs, _terms.end());
return new Struct(structName, args);
}else if (_currentToken == ';'){
throw string("Unbalanced operator");
}else{
throw string("unexpected token");
}
}
Term * list() {
int startIndexOfListArgs = _terms.size();
createTerms();
if(_currentToken == ']')
{
vector<Term *> args(_terms.begin() + startIndexOfListArgs, _terms.end());
_terms.erase(_terms.begin() + startIndexOfListArgs, _terms.end());
if(args.size()==0){
return new Atom("[]");
}
return new List(args);
}else if (_currentToken == ';'){
throw string("Unbalanced operator");
}else{
throw string("unexpected token");
}
}
Exp *buildExpression()
{
if (!_scanner.getCase().find(";.")){
throw string("Unexpected ';' before '.'");
}
if (!_scanner.getCase().find(",.")){
throw string("Unexpected ',' before '.'");
}
disjunctionMatch();
restDisjunctionMatch();
if (createTerm() != nullptr || _currentToken != '.')
throw string("Missing token '.'");
return _expStack.top();
}
void restDisjunctionMatch() {
if (_scanner.currentChar() == ';') {
table.clear();
createTerm();
disjunctionMatch();
Exp *right = _expStack.top();
_expStack.pop();
Exp *left = _expStack.top();
_expStack.pop();
_expStack.push(new DisjExp(left, right));
restDisjunctionMatch();
}
}
void disjunctionMatch() {
conjunctionMatch();
restConjunctionMatch();
}
void restConjunctionMatch() {
if (_scanner.currentChar() == ',') {
createTerm();
conjunctionMatch();
Exp *right = _expStack.top();
_expStack.pop();
Exp *left = _expStack.top();
_expStack.pop();
_expStack.push(new ConjExp(left, right));
restConjunctionMatch();
}
}
void conjunctionMatch() {
Term * left = createTerm();
if (createTerm() == nullptr && _currentToken == '=') {
Term * right = createTerm();
_expStack.push(new MatchExp(left, right));
}
else if(_currentToken=='.')
{
throw string(left->symbol()+" does never get assignment");
}else if(_currentToken==',')
{
throw string("Unexpected ',' before '.'");
}else if(_currentToken==';')
{
throw string("Unexpected ';' before '.'");
}
else if(_currentToken != '=')
{
throw string ("Unexpected ',' before '.'");
}
}
Exp *getExpressionTree() {
return _expStack.top();
}
// vector<Term *> &getTerms() { return _terms; }
private:
FRIEND_TEST(ParserTest, createArgs);
FRIEND_TEST(ParserTest,ListOfTermsEmpty);
FRIEND_TEST(ParserTest,listofTermsTwoNumber);
FRIEND_TEST(ParserTest, createTerm_nestedStruct3);
FRIEND_TEST(ParserTest, createTerms);
void createTerms() {
Term* term = createTerm();
if(term!=nullptr)
{
_terms.push_back(term);
while((_currentToken = _scanner.nextToken()) == ',') {
_terms.push_back(createTerm());
}
}
}
vector<Term *> _terms;
Scanner _scanner;
int _currentToken;
stack<Exp *> _expStack;
vector<Variable *> table;
int index;
};
#endif | [
"amingo08131@gmail.com"
] | amingo08131@gmail.com |
72c842aec26c01642889f7217e0bd2f4a12c32eb | 1bc6f280fc035356fb337b62ff7af5e7bf57e171 | /Matrix.cc | f2f1c60544a30127fb8a3d69301a6aabc99c6446 | [] | no_license | Jon-KG-Uy/Algorithms-Fib-Matrix | f7dec94d0d582c7888439d961e47b93c014c779b | 6132fd52a997b8ef5e364194ef3be2a12630f14f | refs/heads/master | 2020-04-23T18:43:24.279989 | 2019-02-19T00:44:51 | 2019-02-19T00:44:51 | 171,377,848 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,435 | cc | /*
* Implementation file for Matrix and Vector classes
*
* @author Jonathan Uy
* @date 7 Oct. 2018
* @file Matrix.cc
*/
#include "Matrix.h"
Matrix::Matrix(int a, int b, int c, int d)
{
data[0][0] = a;
data[0][1] = b;
data[1][0] = c;
data[1][1] = d;
}
//resmat uses += to emulate dot product value of matrix multiplication
//cycle through k, then j, then i to ensure all the items in mat1 and mat2 are
//successfully multiplied
//result matrix is of size four
Matrix operator*(const Matrix& mat1, const Matrix& mat2)
{
Matrix resmat;
for(int i = 0; i < 2; ++i)
for(int j = 0; j < 2; ++j)
for(int k = 0; k < 2; ++k)
resmat.data[i][j] += mat1.data[i][k] * mat2.data[k][j];
return resmat;
}
// stub version, must refine
// recursive multiplication?
Matrix power(const Matrix& mat, unsigned int n)
{
Matrix resmat;
//if n == 1, matrix stays the same
//if n is even, ((x)^y/2)^2
//if n is odd, ((x)^y/2)^2
if(n == 1)
return mat;
else if(n % 2)
return mat * power(mat, n-1);
resmat = power(mat, n/2);
resmat = resmat * resmat;
return resmat;
}
Vector::Vector(int x, int y)
{
data[0] = x;
data[1] = y;
};
// return type == vector struct...
// F(n) is vector.data[0] according to text
Vector operator*(const Matrix& mat, const Vector& b)
{
Vector resvec;
for(int i = 0; i < 2; ++i)
for(int j = 0; j < 2; ++j)
resvec.data[i] += mat.data[i][j] * b.data[j];
return resvec;
}
| [
"noreply@github.com"
] | noreply@github.com |
b4e1ec32a3cd00cee64aeb5b83984c6a3ff1d9a7 | 62510fa67d0ca78082109a861b6948206252c885 | /hihope_neptune-oh_hid/00_src/v0.1/test/developertest/examples/calculator/test/unittest/phone/calculator_mul_test.cpp | 931a48d5cb7e4d6862e598c6a9c97e2387157230 | [
"Apache-2.0"
] | permissive | dawmlight/vendor_oh_fun | a869e7efb761e54a62f509b25921e019e237219b | bc9fb50920f06cd4c27399f60076f5793043c77d | refs/heads/master | 2023-08-05T09:25:33.485332 | 2021-09-10T10:57:48 | 2021-09-10T10:57:48 | 406,236,565 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,678 | cpp | /*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 "calculator.h"
#include <gtest/gtest.h>
using namespace testing::ext;
class CalculatorMulTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
};
void CalculatorMulTest::SetUpTestCase(void)
{
// step 2: input testsuit setup step
}
void CalculatorMulTest::TearDownTestCase(void)
{
// step 2: input testsuit teardown step
}
void CalculatorMulTest::SetUp(void)
{
// step 3: input testcase setup step
}
void CalculatorMulTest::TearDown(void)
{
// step 3: input testcase teardown step
}
/**
* @tc.name: integer_mul_001
* @tc.desc: Verify the mul function.
* @tc.type: FUNC
* @tc.require: AR00000000 SR00000000
*/
HWTEST_F(CalculatorMulTest, integer_mul_001, TestSize.Level1)
{
EXPECT_EQ(0, Mul(4, 0));
}
/**
* @tc.name: integer_mul_002
* @tc.desc: Verify the mul function.
* @tc.type: FUNC
* @tc.require: AR00000000 SR00000000
*/
HWTEST_F(CalculatorMulTest, integer_mul_002, TestSize.Level3)
{
EXPECT_EQ(35, Mul(5, 7));
}
| [
"liu_xiyao@hoperun.com"
] | liu_xiyao@hoperun.com |
61c287e6cb07921caf6662e6b0a0c4a5d434d04b | 259b7102b986d48e7280058ba09c45c9d35d7a55 | /c++/HeapManager/BlockDescriptor.cpp | 5a3b190db0c316863a4ecca7d145ef595880be8e | [] | no_license | greenstack/portfolio | fb8b17b8317611b57324fd04812454f129c7c0f2 | 8b94a3d4ad01bd0d8d4d8325ba1798ea8dc8fd71 | refs/heads/master | 2021-07-10T10:24:21.118344 | 2021-03-18T22:13:53 | 2021-03-18T22:13:53 | 237,520,396 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 334 | cpp | #pragma once
#include "BlockDescriptor.h"
namespace Origin {
namespace Memory {
void BlockDescriptor::insertBefore(BlockDescriptor* after) {
previous = after->previous;
if (after->previous) {
after->previous->next = this;
}
next = after->next;
if (after->next) {
after->next->previous = this;
}
}
}
}
| [
"paradoxbuilder@gmail.com"
] | paradoxbuilder@gmail.com |
53b85737cc768216f7b2037e73c35b9c533bcecd | 210ca7e2fdb9dc5680d488dcee0123fdb2d1cf34 | /CS194/openCL-intro_assignment4/vvadd.cpp | bbc6f10a639769b54029bb46b9e7f72d8630e89c | [] | no_license | kevin1chun/random | b5b9f0eee59b6b85f11d1d14939fc62cd85ad118 | af415e18a5a00d71e084d17561bdc1e0f3caa0ef | refs/heads/master | 2021-01-18T01:52:46.377646 | 2015-05-04T11:38:15 | 2015-05-04T11:38:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,223 | cpp | #include <cstring>
#include <cstdio>
#include <cstdlib>
#include <string>
#include "clhelp.h"
int main(int argc, char *argv[])
{
std::string vvadd_kernel_str;
/* Provide names of the OpenCL kernels
* and cl file that they're kept in */
std::string vvadd_name_str =
std::string("vvadd");
std::string vvadd_kernel_file =
std::string("vvadd.cl");
cl_vars_t cv;
cl_kernel vvadd;
/* Read OpenCL file into STL string */
readFile(vvadd_kernel_file,
vvadd_kernel_str);
/* Initialize the OpenCL runtime
* Source in clhelp.cpp */
initialize_ocl(cv);
/* Compile all OpenCL kernels */
compile_ocl_program(vvadd, cv, vvadd_kernel_str.c_str(),
vvadd_name_str.c_str());
/* Arrays on the host (CPU) */
float *h_A, *h_B, *h_Y;
/* Arrays on the device (GPU) */
cl_mem g_A, g_B, g_Y;
/* Allocate arrays on the host
* and fill with random data */
int n = (1<<20);
h_A = new float[n];
h_B = new float[n];
h_Y = new float[n];
bzero(h_Y, sizeof(float)*n);
for(int i = 0; i < n; i++)
{
h_A[i] = (float)drand48();
h_B[i] = (float)drand48();
}
/* CS194: Allocate memory for arrays on
* the GPU */
cl_int err = CL_SUCCESS;
/* CS194: Create input and output buffers on GPU */
g_A = clCreateBuffer(cv.context,CL_MEM_READ_WRITE,sizeof(float)*n,NULL,&err);
CHK_ERR(err);
g_B = clCreateBuffer(cv.context,CL_MEM_READ_WRITE,sizeof(float)*n,NULL,&err);
CHK_ERR(err);
g_Y = clCreateBuffer(cv.context,CL_MEM_READ_WRITE,sizeof(float)*n,NULL,&err);
CHK_ERR(err);
/* CS194: Copy data from host CPU to GPU */
err = clEnqueueWriteBuffer(cv.commands, g_A, true, 0, sizeof(float)*n,
h_A, 0, NULL, NULL);
CHK_ERR(err);
err = clEnqueueWriteBuffer(cv.commands, g_B, true, 0, sizeof(float)*n,
h_B, 0, NULL, NULL);
CHK_ERR(err);
/* CS194: Define the global and local workgroup sizes */
size_t global_work_size[1] = {n};
size_t local_work_size[1] = {128};
/* CS194: Set Kernel Arguments */
err = clSetKernelArg(vvadd, 1, sizeof(cl_mem), &g_A);
CHK_ERR(err);
err = clSetKernelArg(vvadd, 2, sizeof(cl_mem), &g_B);
CHK_ERR(err);
err = clSetKernelArg(vvadd, 0, sizeof(cl_mem), &g_Y);
CHK_ERR(err);
err = clSetKernelArg(vvadd, 3, sizeof(int), &n);
CHK_ERR(err);
/* CS194: Call kernel on the GPU */
err = clEnqueueNDRangeKernel(cv.commands,
vvadd,
1,//work_dim,
NULL, //global_work_offset
global_work_size, //global_work_size
local_work_size, //local_work_size
0, //num_events_in_wait_list
NULL, //event_wait_list
NULL //
);
CHK_ERR(err);
/* Read result of GPU on host CPU */
err = clEnqueueReadBuffer(cv.commands, g_Y, true, 0, sizeof(float)*n,
h_Y, 0, NULL, NULL);
CHK_ERR(err);
/* Check answer */
for(int i = 0; i < n; i++)
{
float d = h_A[i] + h_B[i];
if(h_Y[i] != d)
{
printf("error at %d :(\n", i);
break;
}
}
printf("Done\n");
/* Shut down the OpenCL runtime */
uninitialize_ocl(cv);
delete [] h_A;
delete [] h_B;
delete [] h_Y;
clReleaseMemObject(g_A);
clReleaseMemObject(g_B);
clReleaseMemObject(g_Y);
return 0;
}
| [
"marcojoemontagna@gmail.com"
] | marcojoemontagna@gmail.com |
a06e1c6b5bc76a012d17e6a7bb9ec85a09427299 | 652fb51f5682a24e8ca4aeaaca0b93ff93e5f5fa | /SmartPlantfinal.ino | f04ea4e25959a4b7eaface7a8f47a9ede273b301 | [] | no_license | acherian18/SIT107 | f1e0f23acf071f07a43c730cb7c9d5220570e5ac | be336be32da85f473b7a49cb0b86d84e39a403c7 | refs/heads/master | 2020-06-20T12:53:20.239257 | 2019-09-26T23:15:11 | 2019-09-26T23:15:11 | 197,128,650 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,963 | ino | //Libraries
#include "SD.h"
#include <Wire.h>
#include "RTClib.h"
#define LOG_INTERVAL 1000 // mills between entries.
// how many milliseconds before writing the logged data permanently to disk
// set it to the LOG_INTERVAL to write each time (safest)
// set it to 10*LOG_INTERVAL to write all data every 10 datareads, you could lose up to
// the last 10 reads if power is lost but it uses less power and is much faster!
#define SYNC_INTERVAL 1000 // mills between calls to flush() - to write data to the card
uint32_t syncTime = 0; // time of last sync()
int sensorPin = A0;
int sensorValue;
int limit = 300;
#define ECHO_TO_SERIAL 1 // echo data to serial port.
//Variables
char activeMotion [] = "Active";
char inactiveMotion [] = "Inactive";
char* state ;
RTC_PCF8523 RTC; // define the Real Time Clock object
// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;
// the logging file
File logfile;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
initSDcard();
createFile();
initRTC();
logfile.println("millis,stamp,datetime,motion");
#if ECHO_TO_SERIAL
Serial.println("millis,stamp,datetime,motion");
#endif
pinMode(6, INPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.println("Analog Value : ");
Serial.println(sensorValue);
if (sensorValue<limit)
{
digitalWrite(13, HIGH);
Serial.println("LED ON");
}
else
{
digitalWrite(13, LOW);
Serial.println("LED OFF");
}
delay(1000*5);
DateTime now;
delay((LOG_INTERVAL - 1) - (millis() % LOG_INTERVAL));
uint32_t m = millis();
logfile.print(m);
logfile.print(", ");
#if ECHO_TO_SERIAL
Serial.print(m);
Serial.print(", ");
#endif
// fetch the time
now = RTC.now();
// log time
logfile.print(now.unixtime()); // seconds since 2000
logfile.print(", ");
logfile.print(now.year(), DEC);
logfile.print("/");
logfile.print(now.month(), DEC);
logfile.print("/");
logfile.print(now.day(), DEC);
logfile.print(" ");
logfile.print(now.hour(), DEC);
logfile.print(":");
logfile.print(now.minute(), DEC);
logfile.print(":");
logfile.print(now.second(), DEC);
#if ECHO_TO_SERIAL
Serial.print(now.unixtime()); // seconds since 2000
Serial.print(", ");
Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);
#endif
if ((millis() - syncTime) < SYNC_INTERVAL) return;
syncTime = millis();
logfile.flush();
}
void error(char const *str)
{
Serial.print("error: ");
Serial.println(str);
while (1);
}
void initSDcard()
{
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(10, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
}
void createFile()
{
//file name must be in 8.3 format (name length at most 8 characters, follwed by a '.' and then a three character extension.
char filename[] = "MLOG00.CSV";
for (uint8_t i = 0; i < 100; i++) {
filename[4] = i / 10 + '0';
filename[5] = i % 10 + '0';
if (! SD.exists(filename)) {
// only open a new file if it doesn't exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}
if (! logfile) {
error("couldnt create file");
}
Serial.print("Logging to: ");
Serial.println(filename);
}
void initRTC()
{
Wire.begin();
if (!RTC.begin()) {
logfile.println("RTC failed");
#if ECHO_TO_SERIAL
Serial.println("RTC failed");
#endif
}
}
| [
"noreply@github.com"
] | noreply@github.com |
ab620d27eac276f7f8b2bdb4786c46e37affc42e | d52d5fdbcd848334c6b7799cad7b3dfd2f1f33e4 | /workspace/c/a.cpp | 5d233c915be0979749008421c7dbc31efc738e47 | [] | no_license | zhiliaoniu/toolhub | 4109c2a488b3679e291ae83cdac92b52c72bc592 | 39a3810ac67604e8fa621c69f7ca6df1b35576de | refs/heads/master | 2022-12-10T23:17:26.541731 | 2020-07-18T03:33:48 | 2020-07-18T03:33:48 | 125,298,974 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,109 | cpp | #include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
//int f(char* a) {
// std::cout << a << std::endl;
// int i = 1;
// return 3==2?3:4;
//}
enum e {
LL = 1<<30
};
std::unordered_set<std::string> audio_exts{"wav", "mp3", "m4a", "ogg", "amr", "aac"};
int main() {
//char a[10];
//int i = 1000000000;
//while (i--) {
// f(a);
//}
//std::cout << f(a) << std::endl;
//int b = -1620649632;
//unsigned int c = b;
//std::cout << c << std::endl;
//
std::string ext_name = "WAV";
std::cout << "ext_name: " << ext_name << std::endl;
std::transform(ext_name.begin(), ext_name.end(), ext_name.begin(), ::tolower);
std::cout << "ext_name: " << ext_name << std::endl;
std::vector<int> v = {1, 3, 5, 7, 9, 8,6, 4, 2, 0};
for (auto& i : v) {
std::cout << i << std::endl;
i += 1;
}
std::cout << "-----------" << std::endl;
for (auto& i : v) {
std::cout << i << std::endl;
i += 1;
}
int r = int(LL) & int(1);
std::cout << r << std::endl;
return 0;
}
| [
"yangshengzhi1@bigo.sg"
] | yangshengzhi1@bigo.sg |
83defcf5c4e50b7f10f3b215d809626b3a036337 | 8cd6ae1e38a71602145cd1207ac317be36ccc9f9 | /Collide_Article1.ino | 5c3f83f7911b8825a1be9c90e99c0593e116c073 | [] | no_license | filmote/Collide_Article1 | 08b76a26c2953f79bff3a4d984402f8ddb26f409 | 9f0c78f8538967b768e0bd671ab8d3e694dc44d8 | refs/heads/master | 2021-01-01T05:52:37.539128 | 2017-07-15T05:47:06 | 2017-07-15T05:47:06 | 97,295,120 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,377 | ino | #include <Arduboy2.h>
#include "Images.h"
Arduboy2 arduboy;
Sprites sprites;
int16_t xA = -16, yA = 12, xB = 128, yB = 24;
int16_t frame;
void setup() {
arduboy.begin();
}
void loop() {
arduboy.clear();
Serial.println("------------------------");
Serial.print("A collides with circle : ");
Serial.println(arduboy.collide( (Rect){xA, yA, 16, 16}, (Rect){24, 4, 16, 16} ));
Serial.print("A collides with B : ");
Serial.println(arduboy.collide( (Rect){xA, yA, 16, 16}, (Rect){xB, yB, 16, 16} ));
Serial.print("A collides with dot : ");
Serial.println(arduboy.collide( (Point){64, 20}, (Rect){xA, yA, 16, 16} ));
Serial.print("B collides with square : ");
Serial.println(arduboy.collide( (Rect){xB, yB, 16, 16}, (Rect){96, 32, 16, 16} ));
Serial.print("B collides with dot : ");
Serial.println(arduboy.collide( (Point){64, 32}, (Rect){xB, yB, 16, 16} ));
arduboy.drawCircle(32, 12, 8, WHITE);
arduboy.drawRect(96, 32, 16, 16, WHITE);
arduboy.drawPixel(64, 20, WHITE);
arduboy.drawPixel(64, 32, WHITE);
sprites.drawOverwrite(xA, yA, squareA, frame);
sprites.drawOverwrite(xB, yB, squareB, frame);
xA++; if (xA >= 128) { xA = 0; }
xB--; if (xB < -16) { xB = 128; }
arduboy.display();
arduboy.delayShort(10);
while (true) {
if (arduboy.pressed(A_BUTTON)) { break; }
arduboy.delayShort(20);
}
}
| [
"simon@bloggingadeadhorse.com"
] | simon@bloggingadeadhorse.com |
f23a12992411fbfcb9f0dac4de9f6ea466a404b3 | d5dac84197b38dd012e7a10da7e768ace5bae1df | /quadtree.cpp | 5d1649b9e2c69869ecf647e85aeaed15133ac4dd | [] | no_license | adhadda/CS221-PA3-and-PA4 | dc9f2cf7a05bc7eaf07efac199002fb8586375ac | 58ac1976f39bb8b50939b172fc7419965e2dbad0 | refs/heads/master | 2021-09-06T05:39:39.886062 | 2018-02-02T19:37:31 | 2018-02-02T19:37:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,528 | cpp | /**
* @file quadtree.cpp
* Quadtree class implementation.
*/
#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
#include "quadtree.h"
#include "png.h"
// Quadtree
// - parameters: none
// - constructor for the Quadtree class; makes an empty tree
Quadtree::Quadtree()
{
root = NULL;
res = 0;
}
// Quadtree
// - parameters: PNG const & source - reference to a const PNG
// object, from which the Quadtree will be built
// int resolution - resolution of the portion of source
// from which this tree will be built
// - constructor for the Quadtree class; creates a Quadtree representing
// the resolution by resolution block in the upper-left corner of
// source
Quadtree::Quadtree(PNG const& source, int setresolution)
{
root = NULL;
buildTree(source, setresolution);
}
// Quadtree
// - parameters: Quadtree const & other - reference to a const Quadtree
// object, which the current Quadtree will be a copy of
// - copy constructor for the Quadtree class
Quadtree::Quadtree(Quadtree const& other)
{
if(other.root == NULL){
root = NULL;
return;
}
else {
root = copy(other.root);
res = other.res;
}
}
// ~Quadtree
// - parameters: none
// - destructor for the Quadtree class
Quadtree::~Quadtree()
{
clear(root);
res = 0;
}
// operator=
// - parameters: Quadtree const & other - reference to a const Quadtree
// object, which the current Quadtree will be a copy of
// - return value: a const reference to the current Quadtree
// - assignment operator for the Quadtree class
Quadtree const& Quadtree::operator=(Quadtree const& other)
{
//check for self-assignment
if (root == other.root){
return *this;
}
clear(root);
root = copy(other.root);
res = other.res;
return *this;
}
// buildTree (public interface)
// - parameters: PNG const & source - reference to a const PNG
// object, from which the Quadtree will be built
// int resolution - resolution of the portion of source
// from which this tree will be built
// - transforms the current Quadtree into a Quadtree representing
// the resolution by resolution block in the upper-left corner of
// source
void Quadtree::buildTree(PNG const& source, int setresolution)
{
// we should clear the Quadtree and build a Quadtree that has enough elements for the source
// set the resolution of the quadtree to the given one
// recursive call on the root quadtreenode using btHelper
clear(root);
res = setresolution;
btHelper(source, 0, 0, setresolution, root);
}
// getPixel (public interface)
// - parameters: int x, int y - coordinates of the pixel to be retrieved
// - return value: an RGBAPixel representing the desired pixel of the
// underlying bitmap
// - retrieves and returns the pixel at coordinates (x, y) in the
// underlying bitmap
RGBAPixel Quadtree::getPixel(int x, int y) const
{
// need the default pixel for the out-of-bounds cases
RGBAPixel pixel;
// if the picture doesn't exist, return the default pixel
if( res == 0 )
return pixel;
// if the coordinates are outside of the picture, return the default pixel
else if( (x >= res) || (y >= res) )
return pixel;
// if the coordinates are vaild, return the pixel, or its deepest ancestor
else {
QuadtreeNode* leafNode = findNode(root, x, y, res-1);
return leafNode->element;
}
}
// decompress (public interface)
// - parameters: none
// - return value: a PNG object representing this quadtree's underlying
// bitmap
// - constructs and returns this quadtree's underlying bitmap
PNG Quadtree::decompress() const
{
// create a new PNG object using the default constructor
PNG image;
// if the quadtree is empty, return the default PNG
if(res == 0)
return image;
// if the quadtree isn't empty, resize image to res
image.resize( (size_t)res, (size_t)res );
// for each pixel of image get the pixel from the quadtree
for(int x = 0; x < res; x++) {
for(int y = 0; y < res; y++) {
*image(x,y) = getPixel(x,y);
}
}
return image;
}
// clockwiseRotate (public interface)
// - parameters: none
// - transforms this quadtree into a quadtree representing the same
// bitmap, rotated 90 degrees clockwise
void Quadtree::clockwiseRotate()
{
clockwiseShift(root);
}
// prune (public interface)
// - parameters: int tolerance - an integer representing the maximum
// "distance" which we will permit between a node's color
// (i.e. the average of its descendant leaves' colors)
// and the color of each of that node's descendant leaves
// - for each node in the quadtree, if the "distance" between the average
// of that node's descendant leaves' colors and the color of each of
// that node's descendant leaves is at most tolerance, this function
// deletes the subtrees beneath that node; we will let the node's
// color "stand in for" the colors of all (deleted) leaves beneath it
void Quadtree::prune(int tolerance)
{
// recPrune and it's helper functions do all the work for prune
recPrune(root, tolerance);
return;
}
// pruneSize (public interface)
// - parameters: int tolerance - an integer representing the maximum
// "distance" which we will permit between a node's color
// (i.e. the average of its descendant leaves' colors)
// and the color of each of that node's descendant leaves
// - returns the number of leaves which this quadtree would contain if it
// was pruned using the given tolerance; does not actually modify the
// tree
int Quadtree::pruneSize(int tolerance) const
{
return recPruneSize(root, tolerance);
}
// idealPrune (public interface)
// - parameters: int numLeaves - an integer representing the number of
// leaves we wish the quadtree to have, after pruning
// - returns the minimum tolerance such that pruning with that tolerance
// would yield a tree with at most numLeaves leaves
int Quadtree::idealPrune(int numLeaves) const
{
int min = 0;
int max = 255*255*3; // maximum differences: (255-0)^2 + (255-0)^2 + (255-0)^2
return idealPrune(min, max, numLeaves);
}
// QuadtreeNode
// - parameters: none
// - constructor for the QuadtreeNode class; creates an empty
// QuadtreeNode, with all child pointers NULL
Quadtree::QuadtreeNode::QuadtreeNode()
{
neChild = seChild = nwChild = swChild = NULL;
}
// QuadtreeNode
// - parameters: RGBAPixel const & elem - reference to a const
// RGBAPixel which we want to store in this node
// - constructor for the QuadtreeNode class; creates a QuadtreeNode
// with element elem and all child pointers NULL
Quadtree::QuadtreeNode::QuadtreeNode(RGBAPixel const& elem)
{
element = elem;
neChild = seChild = nwChild = swChild = NULL;
}
//////////////////////
// helper functions //
//////////////////////
// priveate helper method for finding a node at a given index or finding its
// deepest ancestor
// - parameters: int x, int y - coordinates of the pixel(node) to be retrieved
// int middle - pass in the size of the square to check, middle is
// calculated inside
// QuadtreeNode* node - node of the tree. Pass in the root
// - return: QuadtreeNode* - return a pointer to the node at the end of the
// traversal
Quadtree::QuadtreeNode* Quadtree::findNode(QuadtreeNode* node, int x, int y, int middle) const
{
while( (node->nwChild != NULL) || (node->neChild != NULL) || (node->swChild != NULL) || (node->seChild != NULL) ) {
// calculate the node which is right before the middle of the coordinate.
// For example, take a square image of 16x16 pixels. The value of middle passed
// in when called from getPixel would be 15 (res-1). The next middle value would be
// 7, after that 3, then 1, then 0.
middle = middle / 2;
if( y > middle ) {
// in this case the child node would be in the Southeastern region
if( x > middle ) {
// if the southeastern child is null, return the current node as it is
// the deepest ancestor
if( node->seChild == NULL )
return node;
else {
// if the child is valid, node becomes it. x and y are adjusted accordingly
// and then the function is recursively called
node = node->seChild;
x -= middle+1;
y -= middle+1;
}
}
// in this case the child node would be in the Southwestern region
else {
if( node->swChild == NULL )
return node;
else {
node = node->swChild;
y -= middle+1;
}
}
}
// in either of these cases the child node would be in the Northern region
else {
// Northeastern region
if( x > middle ) {
if( node->neChild == NULL )
return node;
else {
node = node->neChild;
x -= middle+1;
}
}
// Northwestern region
else {
if( node->nwChild == NULL )
return node;
else {
node = node->nwChild;
}
}
}
}
return node;
}
// This is a recursive helper method for clockwiseRotate().
// It does the actual rotations.
// - parameters: QuadtreeNode * &node - the root of a tree
// - return: nothing
void Quadtree::clockwiseShift(QuadtreeNode* &node)
{
// if the node has no children theres nothing to shift/rotate
if( (node->nwChild == NULL) && (node->neChild == NULL) &&
(node->swChild == NULL) && (node->seChild == NULL) ) {
return;
}
// shift all the nodes over by one position clockwise
// For example: A B -> C A
// C D D B
QuadtreeNode* temp = node->swChild;
node->swChild = node->seChild;
node->seChild = node->neChild;
node->neChild = node->nwChild;
node->nwChild = temp;
// call clockwiseShift on the children of the current node
clockwiseShift(node->swChild);
clockwiseShift(node->seChild);
clockwiseShift(node->neChild);
clockwiseShift(node->nwChild);
}
// helper function for Quadtree copy constructor
// takes a copyRoot if it is NULL return NULL
// If not, create the new QuadtreeNode using its element and copy every child
// then return the copy
Quadtree::QuadtreeNode *Quadtree::copy(QuadtreeNode *cRoot) {
if(cRoot == NULL){
return NULL;
}
QuadtreeNode *out = new Quadtree::QuadtreeNode(cRoot->element);
out->nwChild = copy(cRoot->nwChild);
out->neChild = copy(cRoot->neChild);
out->seChild = copy(cRoot->seChild);
out->swChild = copy(cRoot->swChild);
return out;
}
// helper function for Quadtree destructor
void Quadtree::clear(QuadtreeNode *& subroot){
// base case
if (subroot == NULL){
return;
}
// clear all nodes recursively
clear(subroot->neChild);
clear(subroot->nwChild);
clear(subroot->swChild);
clear(subroot->seChild);
delete subroot;
subroot = NULL;
}
// Helper method for prune, which recursively prunes all the nodes it needs to
// - parameter: QuadtreeNode* &subroot - the starting point of the pruning
// - parameter: int tolerance - if the difference in color between a node and
// each of its children is less than tolerance,
// pruning is done
// - returns: nothing
void Quadtree::recPrune(QuadtreeNode* &subroot, int tolerance)
{
// If the subroot has no children, return as we have reached the end of
// this path down the tree
if( (subroot->nwChild == NULL) && (subroot->neChild == NULL) &&
(subroot->swChild == NULL) && (subroot->seChild == NULL) ) {
return;
}
// vector for containing all the leaves of this subroot
std::vector<QuadtreeNode*> leaves;
// get the leaves
getLeaves(subroot, leaves);
// if all of the leaves are within the tolerance, then clear the four children
// of this subroot
if( checkLeaves(subroot, leaves, tolerance) ) {
clear(subroot->nwChild);
clear(subroot->neChild);
clear(subroot->swChild);
clear(subroot->seChild);
}
// else try to prune the subroot's childen
else {
recPrune(subroot->nwChild, tolerance);
recPrune(subroot->neChild, tolerance);
recPrune(subroot->swChild, tolerance);
recPrune(subroot->seChild, tolerance);
}
return;
}
// Helper method for pruneSize, which, using recursion, returns the number of leaves
// this quadtree would have if it were pruned. This function does not actually prune
// the tree
// - parameter: QuadtreeNode* subroot - the starting point of the pruning
// - parameter: int tolerance - if the difference in color between a node and
// each of its children is less than tolerance,
// pruning is done
// - returns: number of leaves a quadtree would have, after it is pruned
int Quadtree::recPruneSize(QuadtreeNode* subroot, int tolerance) const
{
// If the subroot has no children, we have reached the end of this path
// down the tree. Return 1 because this is a leaf of the tree
if( (subroot->nwChild == NULL) && (subroot->neChild == NULL) &&
(subroot->swChild == NULL) && (subroot->seChild == NULL) ) {
return 1;
}
// vector for containing all the leaves of this subroot
std::vector<QuadtreeNode*> leaves;
// get the leaves
getLeaves(subroot, leaves);
// if all the leaves of this subroot are within the tolerance, then return 1
// because the children and their subtrees would be deleted; this subroot
// would be pruned
if( checkLeaves(subroot, leaves, tolerance) ) {
return 1;
}
// else call redPruneSize on this subroot's children and return the sum of
// their return values
else {
return recPruneSize(subroot->nwChild, tolerance) +
recPruneSize(subroot->neChild, tolerance) +
recPruneSize(subroot->swChild, tolerance) +
recPruneSize(subroot->seChild, tolerance);
}
}
// Helper function for recPrune that gets all the leaves of a particular subroot
// - parameter: QuadtreeNode* subroot - all of the children of this subroot will be found
// - parameter: vector<QuadtreeNode*> &leaves - a vector containing all of the leaves of the subroot
// - returns: nothing
void Quadtree::getLeaves(QuadtreeNode* subroot, vector<QuadtreeNode*> &leaves) const
{
// if subroot has no children, then it is a leaf and must be added to leaves
if( (subroot->nwChild == NULL) && (subroot->neChild == NULL) &&
(subroot->swChild == NULL) && (subroot->seChild == NULL) ) {
leaves.push_back(subroot);
return;
}
// else get the leaves of its children
getLeaves(subroot->nwChild, leaves);
getLeaves(subroot->neChild, leaves);
getLeaves(subroot->swChild, leaves);
getLeaves(subroot->seChild, leaves);
}
// Helper method for recPrune that checks all of the leaves of a subroot against the tolerance
// to see if the subroot should be pruned
// - parameter: QuadtreeNode* subroot - the subroot
// - parameter: vector<QuadtreeNode*> leaves - the leaves of the subroot
// - parameter: int tolerance - the tolerance of the difference
// - return: bool - true if all the leaves are within the tolerance, false otherwise
bool Quadtree::checkLeaves(QuadtreeNode* subroot, vector<QuadtreeNode*> leaves, int tolerance) const
{
// declare an iterator for leaves
std::vector<QuadtreeNode*>::iterator it;
// iterating through leaves, if the difference between any of the leaves and subroot is
// greater than tolerance, return false
for(it = leaves.begin(); it != leaves.end(); it++)
if( calcDifference(subroot, *it) > tolerance )
return false;
// if the iterator goes through the entire vector, then the tolerance was met for
// every leaf, so return true
return true;
}
// Helper function for redPrune which calculates the difference between two RGB colors
// - parameter: QuadtreeNode* subrot - pointer to a subroot in a Quadtree object
// - parameter: QuadtreeNode* child - pointer to one of the four children of the subroot
// - return: the integer value of the differnce between the two colors
int Quadtree::calcDifference(QuadtreeNode* subroot, QuadtreeNode* child) const
{
return pow( (subroot->element.red - child->element.red), 2 ) +
pow( (subroot->element.green - child->element.green), 2) +
pow( (subroot->element.blue - child->element.blue), 2);
}
// Helper function for idealPrune using the Binary Search
// - parameters: int min - minimum difference
// - parameters: int max - maximum difference
// - parameters: int numLeaves - the number of leaves you want to remain in the tree
// - return the minimum tolerance that would yield a tree with at most numLeaves leaves
int Quadtree::idealPrune(int min, int max, int numLeaves) const
{
int leaves;
// base case, If it can't find the numLeaves then just return the minimum tolerance we have
if (min > max){
return min;
}
// start from the middle
leaves = pruneSize( (min+max)/2 );
// if the midpoint is exactly equal to the numLeaves we wish for, we should do a double check
// with the element right before midpoint just in case there is a smaller value that we want
if (leaves == numLeaves){
if(numLeaves == pruneSize(((min+max)/2) - 1)){
return idealPrune(0, (((min+max)/2) - 1), numLeaves);
}
// if not equal just return midpoint as the minimum tolerance
return (min+max)/2;
}
// if the leaves is less than the required numLeaves, which means our tolerance is too high
// we just reassign our max to be one element before midpoint
if (leaves < numLeaves){
return idealPrune(min, ((min+max)/2)-1, numLeaves);
}
// if the leaves is greater than the required numLeaves, which means our tolerance is too low,
// we will reassign our min value to be one element after the midpoint
else return idealPrune(((min+max)/2)+1, max, numLeaves);
}
// btHelper helper function for buildTree
void Quadtree::btHelper(PNG const &source, int xcoord, int ycoord, int resolution, QuadtreeNode *&subroot) {
// Create QuadtreeNode (need to fix)
subroot = new QuadtreeNode();
// base case when resolution == 1
if (resolution == 1){
subroot->element = *source(xcoord,ycoord);
return;
}
//recursively build tree
btHelper(source, (xcoord + resolution/2), ycoord, resolution/2, subroot->neChild);
btHelper(source, xcoord, ycoord, resolution/2, subroot->nwChild);
btHelper(source, xcoord, (ycoord + resolution/2), resolution/2, subroot->swChild);
btHelper(source, (xcoord + resolution/2), (ycoord + resolution/2), resolution/2, subroot->seChild);
//color pixels
subroot->element.red = (subroot->neChild->element.red + subroot->nwChild->element.red + subroot->swChild->element.red + subroot->seChild->element.red)/4;
subroot->element.green = (subroot->neChild->element.green + subroot->nwChild->element.green + subroot->swChild->element.green + subroot->seChild->element.green)/4;
subroot->element.blue = (subroot->neChild->element.blue + subroot->nwChild->element.blue + subroot->swChild->element.blue + subroot->seChild->element.blue)/4;
subroot->element.alpha = (subroot->neChild->element.alpha + subroot->nwChild->element.alpha + subroot->swChild->element.alpha + subroot->seChild->element.alpha)/4;
} | [
"arjundhadda236@gmail.com"
] | arjundhadda236@gmail.com |
86565edd3a010164bbf64761ec97b484566f5bb5 | 3f41ff4599446c60d1b2006c4188ba0f0deb3a4a | /InsertSort.cpp | 41d0e194a44981320e983c9e1bc81ff91b0caf9f | [] | no_license | 912679520/Mycodes | 6e9f3e40b9a298d8d77d3b8c3a8ea8bd820dafa3 | ecd4c8e53af0cc07e51d28625f336a1b62fbf00e | refs/heads/master | 2023-06-11T15:18:26.799209 | 2021-07-06T14:13:07 | 2021-07-06T14:13:07 | 307,394,975 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 357 | cpp |
#include"sort.h"
/*
时间复杂度:O(n^2)
空间复杂度:O(1)
稳定性:稳定
*/
void InsertSort(int* arr, int len)
{
for (int i = 1; i < len;++i)//i负责遍历无序数据段
{
int tmp = arr[i];
int j = i - 1;
for (; j >= 0; --j)
{
if (arr[j] <= tmp)
{
break;
}
arr[j + 1] = arr[j];
}
arr[j + 1] = tmp;
}
} | [
"72492583+912679520@users.noreply.github.com"
] | 72492583+912679520@users.noreply.github.com |
b827c92a1c3ad4e868693fd9a5f2e518184d9a1c | 74f23cf7d94bfc6912189981efcd70c9873a1f3f | /mapEditor/src/scene/controller/sounds/soundshape/SoundSphereShapeWidget.cpp | 98a04e666c4792d646dd3e7b65cfa73cadfc6835 | [
"MIT"
] | permissive | dujingui/UrchinEngine | 9291a316f8c48282d793998831924cc7425f7cb3 | e0fe218dc79ce70b3bd606d46f08a52ddd909b35 | refs/heads/master | 2021-02-09T19:06:46.296888 | 2020-02-25T20:50:08 | 2020-02-25T20:50:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,147 | cpp | #include <QtWidgets/QLabel>
#include <QtWidgets/QHBoxLayout>
#include "SoundSphereShapeWidget.h"
#include "support/SpinBoxStyleHelper.h"
namespace urchin
{
SoundSphereShapeWidget::SoundSphereShapeWidget(const SceneSound *sceneSound) :
SoundShapeWidget(sceneSound)
{
auto *positionLabel = new QLabel("Position:");
mainLayout->addWidget(positionLabel, 1, 0);
auto *positionLayout = new QHBoxLayout();
mainLayout->addLayout(positionLayout, 1, 1);
positionX = new QDoubleSpinBox();
positionLayout->addWidget(positionX);
SpinBoxStyleHelper::applyDefaultStyleOn(positionX);
connect(positionX, SIGNAL(valueChanged(double)), this, SLOT(updateSoundShape()));
positionY = new QDoubleSpinBox();
positionLayout->addWidget(positionY);
SpinBoxStyleHelper::applyDefaultStyleOn(positionY);
connect(positionY, SIGNAL(valueChanged(double)), this, SLOT(updateSoundShape()));
positionZ = new QDoubleSpinBox();
positionLayout->addWidget(positionZ);
SpinBoxStyleHelper::applyDefaultStyleOn(positionZ);
connect(positionZ, SIGNAL(valueChanged(double)), this, SLOT(updateSoundShape()));
auto *radiusLabel = new QLabel("Radius:");
mainLayout->addWidget(radiusLabel, 2, 0);
radius = new QDoubleSpinBox();
mainLayout->addWidget(radius, 2, 1);
SpinBoxStyleHelper::applyDefaultStyleOn(radius);
radius->setMinimum(0.0);
connect(radius, SIGNAL(valueChanged(double)), this, SLOT(updateSoundShape()));
}
std::string SoundSphereShapeWidget::getSoundShapeName() const
{
return SPHERE_SHAPE_LABEL;
}
void SoundSphereShapeWidget::doSetupShapePropertiesFrom(const SoundShape *shape)
{
const auto *sphereShape = dynamic_cast<const SoundSphere *>(shape);
positionX->setValue(sphereShape->getPosition().X);
positionY->setValue(sphereShape->getPosition().Y);
positionZ->setValue(sphereShape->getPosition().Z);
radius->setValue(sphereShape->getRadius());
}
const SoundShape *SoundSphereShapeWidget::createSoundShape() const
{
Point3<float> position(positionX->value(), positionY->value(), positionZ->value());
return new SoundSphere((float)radius->value(), position, getMarginValue());
}
}
| [
"petitg1987@gmail.com"
] | petitg1987@gmail.com |
c947e2e936113624f0a1c073fef984aeb5bafdd3 | c54bc79adb40be4fa16ab5589ecefb5fd5489912 | /c++/08.cc | 3d37908688cc524cc7f1abdff507c106d5002fa1 | [] | no_license | CWFrost/ProjectEuler | f03440da600ee91b56a755bdb03f383242731ac1 | 5437787c5677cf1fcac275f19b9c19ce657351e1 | refs/heads/master | 2021-09-07T21:07:04.117580 | 2018-03-01T05:41:12 | 2018-03-01T05:41:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 558 | cc | #include<iostream>
#include<fstream>
#include<string>
#include<cstdint>
using namespace std;
int main(){
string number;
uint64_t result = 0;
ifstream infile("08.dat");
if(infile.is_open()){
getline(infile, number);
}
for (int i=0; i < number.length()-12; i++)
{
uint64_t temp = 0;
temp = ((int) number[i] - 48);
for (int j=i+1; j<i+13; j++)
temp *= ((int) number[j] - 48);
if (result <= temp) result = temp;
}
cout << result << endl;
return 0;
}
//23514624000
| [
"ChristopherWFrost@gmail.com"
] | ChristopherWFrost@gmail.com |
d8c10b0596fbfba51a0c2524dcc3fa7a76d30776 | 84161e06a39ed7357647ebfbed0cf2ef8f2f841a | /newcoder/13134.cpp | 3eb73cd12307b775ae15dde9aa5329518be15c7b | [] | no_license | chachabai/cf | 7dee0a989c19a7abe96b439032c1ba898790fb80 | 069fad31f2e2a5bad250fe44bb982220d651b74a | refs/heads/master | 2022-12-30T09:16:30.876496 | 2020-10-20T06:39:15 | 2020-10-20T06:39:15 | 293,874,493 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 856 | cpp | #include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;
int main() {
//freopen("in","r",stdin);
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
int a[n], pre[n] = {1}, dp[n] = {1};
for (int i = 0; i < n; ++i) std::cin >> a[i];
for (int i = 1; i < n; ++i) {
if (a[i] > a[i-1]) pre[i] = pre[i - 1] + 1;
else pre[i] = 1;
}
int r = 1;
for (int i = 1; i < n; ++i) {
if (a[i] > a[i - 1]) {
if (i > 1 && a[i - 2] > a[i] - 1) {
dp[i] = std::max(dp[i - 1] + 1, pre[i - 2] + 2);
} else {
dp[i] = dp[i - 1] + 1
}
}
else {
dp[i] = 1 + pre[i - 1];
if (i > 1 && a[i] > a[i - 2] + 1) {
dp[i] = std::max(dp[i], 2 + pre[i - 2]);
}
}
r = std::max(r, dp[i]);
}
print(r);
return 0;
} | [
"dna049@outlook.com"
] | dna049@outlook.com |
3c2e833af0548778cae7a89f45827a935ec7f871 | 706a6f1d3b2165c6f0faf8bc8dc3403181c1271d | /src/RcppExports.cpp | 3b299c86d81958c974a80fe82d6621e764f0cf38 | [
"MIT"
] | permissive | ethan-alt/rstanglm | 05610acc5e795804e8cf5e272c6d72d9e1b489e9 | 65288134ab629775e12d99450d9a9a44e84b37cd | refs/heads/master | 2023-03-31T10:19:25.580426 | 2021-03-31T13:32:47 | 2021-03-31T13:32:47 | 343,257,765 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,270 | cpp | // Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppEigen.h>
#include <Rcpp.h>
using namespace Rcpp;
RcppExport SEXP _rcpp_module_boot_stan_fit4sample_fixedDispersion_mod();
RcppExport SEXP _rcpp_module_boot_stan_fit4sample_hierarchical_binomial_mod();
RcppExport SEXP _rcpp_module_boot_stan_fit4sample_hierarchical_poisson_mod();
RcppExport SEXP _rcpp_module_boot_stan_fit4sample_randomDispersion_mod();
static const R_CallMethodDef CallEntries[] = {
{"_rcpp_module_boot_stan_fit4sample_fixedDispersion_mod", (DL_FUNC) &_rcpp_module_boot_stan_fit4sample_fixedDispersion_mod, 0},
{"_rcpp_module_boot_stan_fit4sample_hierarchical_binomial_mod", (DL_FUNC) &_rcpp_module_boot_stan_fit4sample_hierarchical_binomial_mod, 0},
{"_rcpp_module_boot_stan_fit4sample_hierarchical_poisson_mod", (DL_FUNC) &_rcpp_module_boot_stan_fit4sample_hierarchical_poisson_mod, 0},
{"_rcpp_module_boot_stan_fit4sample_randomDispersion_mod", (DL_FUNC) &_rcpp_module_boot_stan_fit4sample_randomDispersion_mod, 0},
{NULL, NULL, 0}
};
RcppExport void R_init_rstanglm(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
| [
"ethanalt@live.unc.edu"
] | ethanalt@live.unc.edu |
0d6dc6c82df8a707b0186a395e0086ee403c5ef2 | 440f814f122cfec91152f7889f1f72e2865686ce | /robot/src/protocol/scene_item_types.cpp | 042b08862a5ac3d1fe4c8912cfab7421ac670f87 | [] | no_license | hackerlank/buzz-server | af329efc839634d19686be2fbeb700b6562493b9 | f76de1d9718b31c95c0627fd728aba89c641eb1c | refs/heads/master | 2020-06-12T11:56:06.469620 | 2015-12-05T08:03:25 | 2015-12-05T08:03:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 3,109 | cpp | /**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#include "scene_item_types.h"
#include <algorithm>
namespace entity {
int _kSceneItemAoiFieldsValues[] = {
SceneItemAoiFields::AOI_BEGIN,
SceneItemAoiFields::TYPE,
SceneItemAoiFields::TEMPLATE,
SceneItemAoiFields::BIND,
SceneItemAoiFields::NUMBER,
SceneItemAoiFields::AOI_END
};
const char* _kSceneItemAoiFieldsNames[] = {
"AOI_BEGIN",
"TYPE",
"TEMPLATE",
"BIND",
"NUMBER",
"AOI_END"
};
const std::map<int, const char*> _SceneItemAoiFields_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(6, _kSceneItemAoiFieldsValues, _kSceneItemAoiFieldsNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
const char* SceneItemAoiField::ascii_fingerprint = "46A703A33337BED2F62F386FC66B2A5F";
const uint8_t SceneItemAoiField::binary_fingerprint[16] = {0x46,0xA7,0x03,0xA3,0x33,0x37,0xBE,0xD2,0xF6,0x2F,0x38,0x6F,0xC6,0x6B,0x2A,0x5F};
uint32_t SceneItemAoiField::read(::apache::thrift::protocol::TProtocol* iprot) {
uint32_t xfer = 0;
std::string fname;
::apache::thrift::protocol::TType ftype;
int16_t fid;
xfer += iprot->readStructBegin(fname);
using ::apache::thrift::protocol::TProtocolException;
bool isset_field_ = false;
bool isset_value_ = false;
while (true)
{
xfer += iprot->readFieldBegin(fname, ftype, fid);
if (ftype == ::apache::thrift::protocol::T_STOP) {
break;
}
switch (fid)
{
case 1:
if (ftype == ::apache::thrift::protocol::T_I32) {
int32_t ecast0;
xfer += iprot->readI32(ecast0);
this->field_ = (SceneItemAoiFields::type)ecast0;
isset_field_ = true;
} else {
xfer += iprot->skip(ftype);
}
break;
case 2:
if (ftype == ::apache::thrift::protocol::T_I32) {
xfer += iprot->readI32(this->value_);
isset_value_ = true;
} else {
xfer += iprot->skip(ftype);
}
break;
default:
xfer += iprot->skip(ftype);
break;
}
xfer += iprot->readFieldEnd();
}
xfer += iprot->readStructEnd();
if (!isset_field_)
throw TProtocolException(TProtocolException::INVALID_DATA);
if (!isset_value_)
throw TProtocolException(TProtocolException::INVALID_DATA);
return xfer;
}
uint32_t SceneItemAoiField::write(::apache::thrift::protocol::TProtocol* oprot) const {
uint32_t xfer = 0;
xfer += oprot->writeStructBegin("SceneItemAoiField");
xfer += oprot->writeFieldBegin("field_", ::apache::thrift::protocol::T_I32, 1);
xfer += oprot->writeI32((int32_t)this->field_);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("value_", ::apache::thrift::protocol::T_I32, 2);
xfer += oprot->writeI32(this->value_);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
xfer += oprot->writeStructEnd();
return xfer;
}
void swap(SceneItemAoiField &a, SceneItemAoiField &b) {
using ::std::swap;
swap(a.field_, b.field_);
swap(a.value_, b.value_);
}
} // namespace
| [
"251729465@qq.com"
] | 251729465@qq.com |
96e3828fa35fcc9e25cd9829a8b70c36c74a2768 | 4d22f318f8de87b2cf2dcc2193021eb7f28060f2 | /HackerRank/Dynamic Programming/XOR & Sum.cpp | 157df97de86b6ba27eaad9f815b5062b530cf5c2 | [] | no_license | krishnateja-nanduri/MyCodePractice | f97f710a684c6098d6f52b3bbcce9a8ca0dbad80 | de6b9f19fb694c54ce847153d3ce14279e1b60fc | refs/heads/master | 2021-09-07T03:54:08.583326 | 2018-02-16T23:30:21 | 2018-02-16T23:30:21 | 104,292,690 | 1 | 1 | null | 2018-02-08T22:14:12 | 2017-09-21T02:39:22 | C++ | UTF-8 | C++ | false | false | 1,206 | cpp | //https://www.hackerrank.com/challenges/xor-and-sum/problem
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define MOD 1000000007
string sa, sb;
int a[500000], b[500000];
int cnt[500000][2];
int main()
{
cin >> sa;
cin >> sb;
int la = sa.size(), lb = sb.size();
for (int i = 0; i < la; i++)
a[la - i - 1] = sa[i] - '0';
for (int i = 0; i < lb; i++)
b[lb - i - 1] = sb[i] - '0';
cnt[0][0] = (b[0] == 0);
cnt[0][1] = (b[0] == 1);
for (int i = 1; i < lb + 314159; i++)
{
cnt[i][0] = cnt[i - 1][0] + (b[i] == 0);
cnt[i][1] = cnt[i - 1][1] + (b[i] == 1);
}
long long ret = 0, cur = 0;
for (int i = 0; i < lb + 314159; i++)
{
int cnt0, cnt1;
if (i < 314159)
{
cnt0 = cnt[i][0] + 314159 - i;
cnt1 = cnt[i][1];
}
else
{
cnt0 = 314159 + cnt[lb - 1][0] - cnt[i - 314159 - 1][0];
cnt1 = cnt[lb - 1][1] - cnt[i - 314159 - 1][1];
}
long long sum_0 = a[i] * cnt0;
long long sum_1 = (a[i] ^ 1) * cnt1;
long long sum = sum_0 + sum_1;
if (i == 0) cur = 1;
else cur = (cur * 2) % MOD;
long long tmp = (cur * sum) % MOD;
ret = (ret + tmp) % MOD;
}
cout << ret << endl;
return 0;
}
| [
"krishnateja.nanduri@gmail.com"
] | krishnateja.nanduri@gmail.com |
5ea69c2d1e49fc7b55c7ea41f6b5895f0c021818 | fe413f8747ddddc011f4dd6783cc084881da870a | /Code/application/PlugInUtilities/RasterUtilities.cpp | a377077830c1fe1152bb06497d49f4518547e1d9 | [] | no_license | GRSEB9S/opticks-cmake | f070b7ee32e5fff03de673c178cd6894113bc50b | 497f89ccbcbf50c83304606eb586302eec3e6651 | refs/heads/master | 2021-05-27T08:16:26.027755 | 2011-08-13T06:03:04 | 2011-08-13T06:03:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 51,735 | cpp | /*
* The information in this file is
* Copyright(c) 2007 Ball Aerospace & Technologies Corporation
* and is subject to the terms and conditions of the
* GNU Lesser General Public License Version 2.1
* The license text is available from
* http://www.gnu.org/licenses/lgpl.html
*/
#include "AppVerify.h"
#include "DataAccessor.h"
#include "DataAccessorImpl.h"
#include "DataRequest.h"
#include "DataVariant.h"
#include "DimensionDescriptor.h"
#include "DynamicObject.h"
#include "Endian.h"
#include "Int64.h"
#include "ObjectResource.h"
#include "Progress.h"
#include "RasterDataDescriptor.h"
#include "RasterElement.h"
#include "RasterFileDescriptor.h"
#include "RasterLayer.h"
#include "RasterUtilities.h"
#include "SpecialMetadata.h"
#include "switchOnEncoding.h"
#include "UInt64.h"
#include "Wavelengths.h"
#include <algorithm>
#include <boost/bind.hpp>
#include <sstream>
namespace
{
void calculateNewPoints(Opticks::PixelLocation point0,
Opticks::PixelLocation point1,
std::vector<Opticks::PixelLocation>& endPoints)
{
endPoints.clear();
bool steep = abs(point1.mY - point0.mY) > abs(point1.mX - point0.mX);
if (steep)
{
std::swap(point0.mX, point0.mY);
std::swap(point1.mX, point1.mY);
}
bool swapped = (point0.mX > point1.mX);
if (swapped)
{
std::swap(point0, point1);
}
int deltax = point1.mX - point0.mX;
int deltay = abs(point1.mY - point0.mY);
int error = deltax / 2;
int ystep = (point0.mY < point1.mY) ? 1 : -1;
int y = point0.mY;
for (int x = point0.mX; x <= point1.mX; ++x)
{
endPoints.push_back(steep ? Opticks::PixelLocation(y, x) : Opticks::PixelLocation(x, y));
error -= deltay;
if (error < 0)
{
y += ystep;
error += deltax;
}
}
if (swapped)
{
std::reverse(endPoints.begin(), endPoints.end());
}
}
template<typename T>
void setPixel(T* pPixel, int defaultValue, unsigned int numValues)
{
memset(pPixel, defaultValue, sizeof(T) * numValues);
}
template<>
void setPixel<IntegerComplex>(IntegerComplex* pPixel, int defaultValue, unsigned int numValues)
{
memset(pPixel, defaultValue, sizeof(IntegerComplex) * numValues);
}
template<>
void setPixel<FloatComplex>(FloatComplex* pPixel, int defaultValue, unsigned int numValues)
{
memset(pPixel, defaultValue, sizeof(FloatComplex) * numValues);
}
}
std::vector<DimensionDescriptor> RasterUtilities::generateDimensionVector(unsigned int count,
bool setOriginalNumbers, bool setActiveNumbers, bool setOnDiskNumbers)
{
std::vector<DimensionDescriptor> retval(count);
for (size_t i = 0; i < count; ++i)
{
if (setOriginalNumbers)
{
retval[i].setOriginalNumber(i);
}
if (setActiveNumbers)
{
retval[i].setActiveNumber(i);
}
if (setOnDiskNumbers)
{
retval[i].setOnDiskNumber(i);
}
}
return retval;
}
bool RasterUtilities::determineSkipFactor(const std::vector<DimensionDescriptor>& values, unsigned int& skipFactor)
{
unsigned int calcSkipFactor = 1;
for (std::vector<DimensionDescriptor>::size_type count = 0; count != values.size(); ++count)
{
if (!values[count].isOnDiskNumberValid())
{
return false;
}
if (count > 0)
{
//determine skip factor on second iteration
int curSkipFactor = values[count].getOnDiskNumber() - values[count-1].getOnDiskNumber();
if (curSkipFactor < 1)
{
return false;
}
if (count > 1)
{
//on any iteration after second, verify skip factor remains the same
if (curSkipFactor != calcSkipFactor)
{
return false;
}
}
calcSkipFactor = curSkipFactor;
}
}
skipFactor = calcSkipFactor - 1;
return true;
}
bool RasterUtilities::determineExportSkipFactor(const std::vector<DimensionDescriptor>&values, unsigned int& skipFactor)
{
unsigned int calcSkipFactor = 1;
for (std::vector<DimensionDescriptor>::size_type count = 0; count != values.size(); ++count)
{
if (!values[count].isActiveNumberValid())
{
return false;
}
if (count > 0)
{
//determine skip factor on second iteration
int curSkipFactor = values[count].getActiveNumber() - values[count-1].getActiveNumber();
if (curSkipFactor < 1)
{
return false;
}
if (count > 1)
{
//on any iteration after second, verify skip factor remains the same
if (curSkipFactor != calcSkipFactor)
{
return false;
}
}
calcSkipFactor = curSkipFactor;
}
}
skipFactor = calcSkipFactor - 1;
return true;
}
std::vector<DimensionDescriptor> RasterUtilities::subsetDimensionVector(
const std::vector<DimensionDescriptor>& origValues,
const DimensionDescriptor& start,
const DimensionDescriptor& stop,
unsigned int skipFactor)
{
unsigned int theStartValue = 0;
if (start.isOriginalNumberValid())
{
theStartValue = start.getOriginalNumber();
}
else if (origValues.empty() == false)
{
theStartValue = origValues.front().getOriginalNumber();
}
unsigned int theEndValue = 0;
if (stop.isOriginalNumberValid())
{
theEndValue = stop.getOriginalNumber();
}
else if (origValues.empty() == false)
{
theEndValue = origValues.back().getOriginalNumber();
}
std::vector<DimensionDescriptor> newValues;
newValues.reserve(origValues.size() / (skipFactor + 1));
for (unsigned int i = 0; i < origValues.size(); ++i)
{
DimensionDescriptor dim = origValues[i];
unsigned int originalNumber = dim.getOriginalNumber();
if ((originalNumber >= theStartValue) && (originalNumber <= theEndValue))
{
newValues.push_back(dim);
i += skipFactor;
}
}
return newValues;
}
namespace
{
class SetOnDiskNumber
{
public:
SetOnDiskNumber() : mCurrent(0)
{
}
DimensionDescriptor operator()(const DimensionDescriptor& dim)
{
DimensionDescriptor temp = dim;
temp.setOnDiskNumber(mCurrent++);
return temp;
}
private:
unsigned int mCurrent;
};
}
namespace
{
void setFileDescriptor(DataDescriptor *pDd, FileDescriptor* pFd,
const std::string &filename, const std::string &datasetLocation, EndianType endian)
{
// Populate the file descriptor
pFd->setFilename(filename);
pFd->setDatasetLocation(datasetLocation);
pFd->setEndian(endian);
RasterDataDescriptor* pRasterDd = dynamic_cast<RasterDataDescriptor*>(pDd);
if (pRasterDd != NULL)
{
RasterFileDescriptor* pRasterFd = dynamic_cast<RasterFileDescriptor*>(pFd);
VERIFYNRV(pRasterFd != NULL);
unsigned int bitsPerElement = RasterUtilities::bytesInEncoding(pRasterDd->getDataType()) * 8;
pRasterFd->setBitsPerElement(bitsPerElement);
std::vector<DimensionDescriptor> cols = pRasterDd->getColumns();
std::transform(cols.begin(), cols.end(), cols.begin(), SetOnDiskNumber());
pRasterFd->setColumns(cols);
pRasterDd->setColumns(cols);
std::vector<DimensionDescriptor> rows = pRasterDd->getRows();
std::transform(rows.begin(), rows.end(), rows.begin(), SetOnDiskNumber());
pRasterFd->setRows(rows);
pRasterDd->setRows(rows);
std::vector<DimensionDescriptor> bands = pRasterDd->getBands();
std::transform(bands.begin(), bands.end(), bands.begin(), SetOnDiskNumber());
pRasterFd->setBands(bands);
pRasterDd->setBands(bands);
pRasterFd->setUnits(pRasterDd->getUnits());
pRasterFd->setXPixelSize(pRasterDd->getXPixelSize());
pRasterFd->setYPixelSize(pRasterDd->getYPixelSize());
pRasterFd->setInterleaveFormat(pRasterDd->getInterleaveFormat());
}
}
template<typename T>
inline size_t sizeofType(const T *pType)
{
return sizeof(T);
}
std::string getBandName(const std::vector<std::string>* pBandNames,
const std::string* pBandPrefix,
const DimensionDescriptor& band)
{
if (!band.isActiveNumberValid() || !band.isOriginalNumberValid())
{
return "";
}
unsigned int activeNumber = band.getActiveNumber();
if (pBandNames != NULL)
{
if ((activeNumber >= 0) && (activeNumber < pBandNames->size()))
{
return pBandNames->at(activeNumber);
}
}
std::ostringstream formatter;
std::string bandPrefix = "Band";
if (pBandPrefix != NULL)
{
bandPrefix = *pBandPrefix;
}
unsigned int originalNumber = band.getOriginalNumber() + 1;
formatter << bandPrefix << " " << originalNumber;
return formatter.str();
}
};
FileDescriptor *RasterUtilities::generateFileDescriptor(DataDescriptor *pDd,
const std::string &filename, const std::string &datasetLocation, EndianType endian)
{
const RasterDataDescriptor* pRasterDd = dynamic_cast<const RasterDataDescriptor*>(pDd);
// Create the file descriptor
FileDescriptor* pFd = NULL;
if (pRasterDd != NULL)
{
FactoryResource<RasterFileDescriptor> pRasterFd;
pFd = pRasterFd.release();
}
else
{
FactoryResource<FileDescriptor> pStdFd;
pFd = pStdFd.release();
}
VERIFYRV(pFd != NULL, NULL);
setFileDescriptor(pDd, pFd, filename, datasetLocation, endian);
return pFd;
}
FileDescriptor *RasterUtilities::generateAndSetFileDescriptor(DataDescriptor *pDd,
const std::string &filename, const std::string &datasetLocation, EndianType endian)
{
VERIFYRV(pDd != NULL, NULL);
const RasterDataDescriptor* pRasterDd = dynamic_cast<const RasterDataDescriptor*>(pDd);
// Create the file descriptor
if (pRasterDd != NULL)
{
FactoryResource<RasterFileDescriptor> pFd;
pDd->setFileDescriptor(pFd.get());
}
else
{
FactoryResource<FileDescriptor> pFd;
pDd->setFileDescriptor(pFd.get());
}
FileDescriptor* pCopy = pDd->getFileDescriptor();
VERIFYRV(pCopy != NULL, NULL);
setFileDescriptor(pDd, pCopy, filename, datasetLocation, endian);
return pCopy;
}
FileDescriptor* RasterUtilities::generateFileDescriptorForExport(const DataDescriptor* pDd,
const std::string &filename)
{
DimensionDescriptor emptyDesc;
std::vector<DimensionDescriptor> emptyVector;
return generateFileDescriptorForExport(pDd, filename, emptyDesc, emptyDesc, 0,
emptyDesc, emptyDesc, 0, emptyVector);
}
FileDescriptor* RasterUtilities::generateFileDescriptorForExport(const DataDescriptor* pDd,
const std::string &filename, const DimensionDescriptor& startRow,
const DimensionDescriptor& stopRow,
unsigned int rowSkipFactor,
const DimensionDescriptor& startCol,
const DimensionDescriptor& stopCol,
unsigned int colSkipFactor,
const std::vector<DimensionDescriptor>& subsetBands)
{
const RasterDataDescriptor* pRasterDd = dynamic_cast<const RasterDataDescriptor*>(pDd);
// Create the file descriptor
FileDescriptor* pFd = NULL;
if (pRasterDd != NULL)
{
FactoryResource<RasterFileDescriptor> pRasterFd;
pFd = pRasterFd.release();
}
else
{
FactoryResource<FileDescriptor> pStdFd;
pFd = pStdFd.release();
}
VERIFYRV(pFd != NULL, NULL);
pFd->setFilename(filename);
EndianType endian = Endian::getSystemEndian();
pFd->setEndian(endian);
/*
#convert CreateExportFileDescriptor wizard to use this code
*/
if (pRasterDd != NULL)
{
RasterFileDescriptor* pRasterFd = dynamic_cast<RasterFileDescriptor*>(pFd);
VERIFY(pRasterFd != NULL);
unsigned int bitsPerElement = RasterUtilities::bytesInEncoding(pRasterDd->getDataType()) * 8;
pRasterFd->setBitsPerElement(bitsPerElement);
// Rows
std::vector<DimensionDescriptor> rows =
subsetDimensionVector(pRasterDd->getRows(), startRow, stopRow, rowSkipFactor);
std::transform(rows.begin(), rows.end(), rows.begin(), SetOnDiskNumber());
pRasterFd->setRows(rows);
// Columns
std::vector<DimensionDescriptor> columns =
subsetDimensionVector(pRasterDd->getColumns(), startCol, stopCol, colSkipFactor);
std::transform(columns.begin(), columns.end(), columns.begin(), SetOnDiskNumber());
pRasterFd->setColumns(columns);
pRasterFd->setUnits(pRasterDd->getUnits());
pRasterFd->setXPixelSize(pRasterDd->getXPixelSize());
pRasterFd->setYPixelSize(pRasterDd->getYPixelSize());
// Bands
std::vector<DimensionDescriptor> bands = pRasterDd->getBands();
const std::vector<DimensionDescriptor>& origBands = pRasterDd->getBands();
std::vector<DimensionDescriptor>::const_iterator foundBand;
if (!subsetBands.empty())
{
bands.clear();
for (unsigned int count = 0; count < subsetBands.size(); count++)
{
foundBand = std::find(origBands.begin(), origBands.end(), subsetBands[count]);
if (foundBand != origBands.end())
{
DimensionDescriptor bandDim = subsetBands[count];
bandDim.setOnDiskNumber(count);
bands.push_back(bandDim);
}
}
}
else
{
std::transform(bands.begin(), bands.end(), bands.begin(), SetOnDiskNumber());
}
pRasterFd->setBands(bands);
pRasterFd->setInterleaveFormat(pRasterDd->getInterleaveFormat());
}
return pFd;
}
FileDescriptor* RasterUtilities::generateFileDescriptorForExport(const DataDescriptor* pDd,
const std::string &filename, const DimensionDescriptor& startRow,
const DimensionDescriptor& stopRow,
unsigned int rowSkipFactor,
const DimensionDescriptor& startCol,
const DimensionDescriptor& stopCol,
unsigned int colSkipFactor,
const DimensionDescriptor& startBand,
const DimensionDescriptor& stopBand,
unsigned int bandSkipFactor)
{
const RasterDataDescriptor* pRasterDd = dynamic_cast<const RasterDataDescriptor*>(pDd);
if (pRasterDd != NULL)
{
// Bands
std::vector<DimensionDescriptor> bands =
subsetDimensionVector(pRasterDd->getBands(), startBand, stopBand, bandSkipFactor);
return generateFileDescriptorForExport(pDd, filename, startRow, stopRow,
rowSkipFactor, startCol, stopCol, colSkipFactor, bands);
}
return NULL;
}
size_t RasterUtilities::bytesInEncoding(EncodingType encoding)
{
switchOnComplexEncoding(encoding, return ::sizeofType, NULL);
return 0;
}
RasterDataDescriptor* RasterUtilities::generateRasterDataDescriptor(const std::string& name, DataElement* pParent,
unsigned int rows, unsigned int columns,
EncodingType encoding, ProcessingLocation location)
{
return generateRasterDataDescriptor(name, pParent, rows, columns, 1, BIP, encoding, location);
}
RasterDataDescriptor* RasterUtilities::generateRasterDataDescriptor(const std::string& name, DataElement* pParent,
unsigned int rows, unsigned int columns,
unsigned int bands, InterleaveFormatType interleave,
EncodingType encoding, ProcessingLocation location)
{
Service<ModelServices> pModel;
RasterDataDescriptor* pDd = dynamic_cast<RasterDataDescriptor*>(
pModel->createDataDescriptor(name, "RasterElement", pParent));
if (pDd == NULL)
{
return NULL;
}
std::vector<DimensionDescriptor> rowDims = generateDimensionVector(rows);
pDd->setRows(rowDims);
std::vector<DimensionDescriptor> colDims = generateDimensionVector(columns);
pDd->setColumns(colDims);
std::vector<DimensionDescriptor> bandDims = generateDimensionVector(bands);
pDd->setBands(bandDims);
pDd->setInterleaveFormat(interleave);
pDd->setDataType(encoding);
pDd->setProcessingLocation(location);
return pDd;
}
void RasterUtilities::subsetDataDescriptor(DataDescriptor* pDd,
const DimensionDescriptor& startRow,
const DimensionDescriptor& stopRow,
unsigned int rowSkipFactor,
const DimensionDescriptor& startCol,
const DimensionDescriptor& stopCol,
unsigned int colSkipFactor,
const std::vector<DimensionDescriptor>& subsetBands)
{
RasterDataDescriptor* pRasterDd = dynamic_cast<RasterDataDescriptor*>(pDd);
if (pRasterDd != NULL)
{
// Rows
std::vector<DimensionDescriptor> rows =
subsetDimensionVector(pRasterDd->getRows(), startRow, stopRow, rowSkipFactor);
pRasterDd->setRows(rows);
// Columns
std::vector<DimensionDescriptor> columns =
subsetDimensionVector(pRasterDd->getColumns(), startCol, stopCol, colSkipFactor);
pRasterDd->setColumns(columns);
// Bands
std::vector<DimensionDescriptor> bands = pRasterDd->getBands();
const std::vector<DimensionDescriptor>& origBands = pRasterDd->getBands();
std::vector<DimensionDescriptor>::const_iterator foundBand;
if (!subsetBands.empty())
{
bands.clear();
for (unsigned int count = 0; count < subsetBands.size(); count++)
{
foundBand = std::find(origBands.begin(), origBands.end(), subsetBands[count]);
if (foundBand != origBands.end())
{
DimensionDescriptor bandDim = subsetBands[count];
bands.push_back(bandDim);
}
}
}
pRasterDd->setBands(bands);
}
}
void RasterUtilities::subsetDataDescriptor(DataDescriptor* pDd,
const DimensionDescriptor& startRow,
const DimensionDescriptor& stopRow,
unsigned int rowSkipFactor,
const DimensionDescriptor& startCol,
const DimensionDescriptor& stopCol,
unsigned int colSkipFactor,
const DimensionDescriptor& startBand,
const DimensionDescriptor& stopBand,
unsigned int bandSkipFactor)
{
RasterDataDescriptor* pRasterDd = dynamic_cast<RasterDataDescriptor*>(pDd);
if (pRasterDd != NULL)
{
// Bands
std::vector<DimensionDescriptor> bands =
subsetDimensionVector(pRasterDd->getBands(), startBand, stopBand, bandSkipFactor);
subsetDataDescriptor(pDd, startRow, stopRow,
rowSkipFactor, startCol, stopCol, colSkipFactor, bands);
}
}
RasterElement* RasterUtilities::createRasterElement(const std::string& name, unsigned int rows, unsigned int columns,
unsigned int bands, EncodingType encoding, InterleaveFormatType interleave, bool inMemory,
DataElement* pParent)
{
RasterDataDescriptor* pDd = generateRasterDataDescriptor(name, pParent, rows, columns,
bands, interleave, encoding, (inMemory ? IN_MEMORY : ON_DISK));
ModelResource<RasterElement> pRasterElement(pDd);
if (pRasterElement.get() == NULL)
{
return NULL;
}
if (pRasterElement->createDefaultPager())
{
return pRasterElement.release();
}
return NULL;
}
RasterElement* RasterUtilities::createRasterElement(const std::string& name, unsigned int rows, unsigned int columns,
EncodingType encoding, bool inMemory, DataElement* pParent)
{
return createRasterElement(name, rows, columns, 1, encoding, BIP, inMemory, pParent);
}
RasterDataDescriptor *RasterUtilities::generateUnchippedRasterDataDescriptor(
const RasterElement *pOrigElement)
{
if (pOrigElement == NULL)
{
return NULL;
}
const RasterDataDescriptor* pOrigDescriptor = dynamic_cast<const RasterDataDescriptor*>(
pOrigElement->getDataDescriptor());
if (pOrigDescriptor == NULL)
{
return NULL;
}
const RasterFileDescriptor* pOrigFileDescriptor = dynamic_cast<const RasterFileDescriptor*>(
pOrigDescriptor->getFileDescriptor());
if (pOrigFileDescriptor == NULL)
{
return NULL;
}
std::vector<DimensionDescriptor> rows = pOrigFileDescriptor->getRows();
std::vector<DimensionDescriptor> columns = pOrigFileDescriptor->getColumns();
std::vector<DimensionDescriptor> bands = pOrigFileDescriptor->getBands();
std::for_each(rows.begin(), rows.end(),
boost::bind(&DimensionDescriptor::setActiveNumberValid, _1, false));
std::for_each(columns.begin(), columns.end(),
boost::bind(&DimensionDescriptor::setActiveNumberValid, _1, false));
std::for_each(bands.begin(), bands.end(),
boost::bind(&DimensionDescriptor::setActiveNumberValid, _1, false));
DataDescriptorResource<RasterDataDescriptor> pNewDescriptor("TempImport", "RasterElement",
const_cast<RasterElement*>(pOrigElement));
VERIFY(pNewDescriptor.get() != NULL);
pNewDescriptor->setRows(rows);
pNewDescriptor->setColumns(columns);
pNewDescriptor->setBands(bands);
pNewDescriptor->setInterleaveFormat(pOrigFileDescriptor->getInterleaveFormat());
pNewDescriptor->setDataType(pOrigDescriptor->getDataType());
pNewDescriptor->setValidDataTypes(pOrigDescriptor->getValidDataTypes());
pNewDescriptor->setProcessingLocation(ON_DISK_READ_ONLY);
FactoryResource<RasterFileDescriptor> pNewFileDescriptor(
dynamic_cast<RasterFileDescriptor*>(pOrigFileDescriptor->copy()));
pNewFileDescriptor->setRows(rows);
pNewFileDescriptor->setColumns(columns);
pNewFileDescriptor->setBands(bands);
pNewDescriptor->setFileDescriptor(pNewFileDescriptor.get());
return pNewDescriptor.release();
}
std::vector<std::string> RasterUtilities::getBandNames(const RasterDataDescriptor* pDescriptor)
{
std::vector<std::string> foundBandNames;
if (pDescriptor == NULL)
{
return foundBandNames;
}
const DynamicObject* pMetadata = pDescriptor->getMetadata();
if (pMetadata == NULL)
{
return foundBandNames;
}
std::string pNamesPath[] = { SPECIAL_METADATA_NAME, BAND_METADATA_NAME, NAMES_METADATA_NAME, END_METADATA_NAME };
const std::vector<std::string>* pBandNames =
dv_cast<std::vector<std::string> >(&pMetadata->getAttributeByPath(pNamesPath));
std::string pPrefixPath[] = { SPECIAL_METADATA_NAME, BAND_NAME_PREFIX_METADATA_NAME, END_METADATA_NAME };
const std::string* pBandPrefix = dv_cast<std::string>(&pMetadata->getAttributeByPath(pPrefixPath));
const std::vector<DimensionDescriptor>& activeBands = pDescriptor->getBands();
for (unsigned int i = 0; i < activeBands.size(); ++i)
{
const DimensionDescriptor& bandDim = activeBands[i];
std::string bandName = ::getBandName(pBandNames, pBandPrefix, bandDim);
if (bandName.empty())
{
return std::vector<std::string>();
}
foundBandNames.push_back(bandName);
}
return foundBandNames;
}
std::string RasterUtilities::getBandName(const RasterDataDescriptor* pDescriptor, DimensionDescriptor band)
{
if (pDescriptor == NULL)
{
return "";
}
const DynamicObject* pMetadata = pDescriptor->getMetadata();
if (pMetadata == NULL)
{
return "";
}
std::string pNamesPath[] = { SPECIAL_METADATA_NAME, BAND_METADATA_NAME, NAMES_METADATA_NAME, END_METADATA_NAME };
const std::vector<std::string>* pBandNames =
dv_cast<std::vector<std::string> >(&pMetadata->getAttributeByPath(pNamesPath));
std::string pPrefixPath[] = { SPECIAL_METADATA_NAME, BAND_NAME_PREFIX_METADATA_NAME, END_METADATA_NAME };
const std::string* pBandPrefix = dv_cast<std::string>(&pMetadata->getAttributeByPath(pPrefixPath));
return ::getBandName(pBandNames, pBandPrefix, band);
}
bool RasterUtilities::findColorCompositeDimensionDescriptors(const RasterDataDescriptor* pDescriptor,
const std::string& name, DimensionDescriptor& redBand, DimensionDescriptor& greenBand, DimensionDescriptor& blueBand)
{
redBand = DimensionDescriptor();
greenBand = DimensionDescriptor();
blueBand = DimensionDescriptor();
const DynamicObject* pColorComposites = RasterLayer::getSettingColorComposites();
if (pDescriptor == NULL || pColorComposites == NULL)
{
return false;
}
try
{
// Get the ColorComposite from ConfigurationSettings based on the name.
const DynamicObject* const pObject = dv_cast<DynamicObject>(&pColorComposites->getAttribute(name));
if (pObject == NULL)
{
return false;
}
// Red
const double redLower = dv_cast<double>(pObject->getAttribute("redLower"));
const double redUpper = dv_cast<double>(pObject->getAttribute("redUpper"));
redBand = findBandWavelengthMatch(redLower, redUpper, pDescriptor);
if (redBand.isValid() == false)
{
unsigned int redBandOnesBasedIndex = dv_cast<unsigned int>(pObject->getAttribute("redBand"));
if (redBandOnesBasedIndex != 0)
{
redBand = pDescriptor->getOriginalBand(redBandOnesBasedIndex - 1);
}
}
// Green
const double greenLower = dv_cast<double>(pObject->getAttribute("greenLower"));
const double greenUpper = dv_cast<double>(pObject->getAttribute("greenUpper"));
greenBand = findBandWavelengthMatch(greenLower, greenUpper, pDescriptor);
if (greenBand.isValid() == false)
{
unsigned int greenBandOnesBasedIndex = dv_cast<unsigned int>(pObject->getAttribute("greenBand"));
if (greenBandOnesBasedIndex != 0)
{
greenBand = pDescriptor->getOriginalBand(greenBandOnesBasedIndex - 1);
}
}
// Blue
const double blueLower = dv_cast<double>(pObject->getAttribute("blueLower"));
const double blueUpper = dv_cast<double>(pObject->getAttribute("blueUpper"));
blueBand = findBandWavelengthMatch(blueLower, blueUpper, pDescriptor);
if (blueBand.isValid() == false)
{
unsigned int blueBandOnesBasedIndex = dv_cast<unsigned int>(pObject->getAttribute("blueBand"));
if (blueBandOnesBasedIndex != 0)
{
blueBand = pDescriptor->getOriginalBand(blueBandOnesBasedIndex - 1);
}
}
}
catch (const std::bad_cast&)
{}
return redBand.isValid() && greenBand.isValid() && blueBand.isValid();
}
int RasterUtilities::findBandWavelengthMatch(double lowTarget, double highTarget,
const std::vector<double>& lowWavelengths, const std::vector<double>& highWavelengths, bool allowPartialMatch)
{
std::vector<unsigned int> matches =
findBandWavelengthMatches(lowTarget, highTarget, lowWavelengths, highWavelengths, allowPartialMatch);
if (matches.empty() || matches[matches.size() / 2] < 0)
{
return -1;
}
return static_cast<int>(matches[matches.size() / 2]);
}
std::vector<unsigned int> RasterUtilities::findBandWavelengthMatches(double lowTarget, double highTarget,
const std::vector<double>& lowWavelengths, const std::vector<double>& highWavelengths, bool allowPartialMatch)
{
if (!highWavelengths.empty() && highWavelengths.size() != lowWavelengths.size())
{
return std::vector<unsigned int>();
}
// Filter wavelength data and select appropriate band
typedef std::pair<std::pair<double, double>, unsigned int> wavelength_item;
std::vector<wavelength_item> candidateBands;
// Secondary list of candidate bands for partial matches, to differentiate between full and partial matches.
std::vector<wavelength_item> candidatePartialBands;
for (unsigned int bandNumber = 0; bandNumber < lowWavelengths.size(); ++bandNumber)
{
if (highWavelengths.empty())
{
// Check center wavelength and if it's in range, add it as a candidate.
if (lowWavelengths[bandNumber] >= lowTarget && lowWavelengths[bandNumber] <= highTarget)
{
candidateBands.push_back(std::make_pair(
std::make_pair(lowWavelengths[bandNumber], lowWavelengths[bandNumber]), bandNumber));
}
}
else if ((lowWavelengths[bandNumber] >= lowTarget && highWavelengths[bandNumber] <= highTarget) ||
(lowWavelengths[bandNumber] < lowTarget && highWavelengths[bandNumber] > highTarget))
{
// If the entire band is in range, add it as a candidate
// Likewise, if the entire band encompasses the desired range, add it as
// a candidate.
candidateBands.push_back(std::make_pair(
std::make_pair(lowWavelengths[bandNumber], highWavelengths[bandNumber]), bandNumber));
}
else if (allowPartialMatch)
{
// Check for any overlap and if in range, add it as a candidate.
if ((lowWavelengths[bandNumber] >= lowTarget && lowWavelengths[bandNumber] <= highTarget) ||
(highWavelengths[bandNumber] >= lowTarget && highWavelengths[bandNumber] <= highTarget) ||
(lowWavelengths[bandNumber] <= lowTarget && highWavelengths[bandNumber] >= lowTarget) ||
(lowWavelengths[bandNumber] <= highTarget && highWavelengths[bandNumber] >= highTarget))
{
candidatePartialBands.push_back(std::make_pair(
std::make_pair(lowWavelengths[bandNumber], highWavelengths[bandNumber]), bandNumber));
}
}
}
// Don't return partial matches if full matches were found.
if (!candidateBands.empty())
{
// Sort by low band range
std::stable_sort(candidateBands.begin(), candidateBands.end());
// Build the vector for return
std::vector<unsigned int> bands(candidateBands.size());
for (unsigned int band = 0; band < candidateBands.size(); ++band)
{
bands[band] = candidateBands[band].second;
}
return bands;
}
// If no full matches were found, return the partial matches. This will be empty
// if allowPartialMatch = false;
else if (!candidatePartialBands.empty())
{
std::stable_sort(candidatePartialBands.begin(), candidatePartialBands.end());
std::vector<unsigned int> bands(candidatePartialBands.size());
for (unsigned int band = 0; band < candidatePartialBands.size(); ++band)
{
bands[band] = candidatePartialBands[band].second;
}
return bands;
}
// No bands fall in range.
return std::vector<unsigned int>();
}
namespace
{
class OriginalBandChecker
{
public:
OriginalBandChecker(const RasterDataDescriptor* pDescriptor) :
mpDescriptor(pDescriptor)
{}
bool operator()(unsigned int band)
{
return (mpDescriptor->getOriginalBand(band).isValid() == false);
}
private:
const RasterDataDescriptor* mpDescriptor;
};
}
DimensionDescriptor RasterUtilities::findBandWavelengthMatch(double lowTarget, double highTarget,
const RasterDataDescriptor* pDescriptor, bool allowPartialMatch)
{
if (pDescriptor == NULL)
{
return DimensionDescriptor();
}
const DynamicObject* pMetadata = pDescriptor->getMetadata();
if (pMetadata == NULL)
{
return DimensionDescriptor();
}
FactoryResource<Wavelengths> pWavelengths;
if (pWavelengths->initializeFromDynamicObject(pMetadata, false) == false)
{
return DimensionDescriptor();
}
if (pWavelengths->isEmpty() == true)
{
return DimensionDescriptor();
}
const std::vector<double>& startWavelengths = pWavelengths->getStartValues();
const std::vector<double>& centerWavelengths = pWavelengths->getCenterValues();
const std::vector<double>& endWavelengths = pWavelengths->getEndValues();
bool useOriginalNumbers = false;
std::vector<unsigned int> bands;
if ((startWavelengths.empty() == false) && (endWavelengths.empty() == false))
{
// Start and end wavelengths available. Use those as the targets.
bands = findBandWavelengthMatches(lowTarget, highTarget, startWavelengths, endWavelengths, allowPartialMatch);
useOriginalNumbers = startWavelengths.size() != pDescriptor->getBandCount();
}
else if (centerWavelengths.empty() == false)
{
// Centers are available so we use those as the targets.
bands = findBandWavelengthMatches(lowTarget, highTarget, centerWavelengths, centerWavelengths, allowPartialMatch);
useOriginalNumbers = centerWavelengths.size() != pDescriptor->getBandCount();
}
else if (startWavelengths.empty() == false)
{
// Only start wavelengths are available, so use those as the targets.
bands = findBandWavelengthMatches(lowTarget, highTarget, startWavelengths, startWavelengths, allowPartialMatch);
useOriginalNumbers = startWavelengths.size() != pDescriptor->getBandCount();
}
else if (endWavelengths.empty() == false)
{
// Only end wavelengths are available, so use those as the targets.
bands = findBandWavelengthMatches(lowTarget, highTarget, endWavelengths, endWavelengths, allowPartialMatch);
useOriginalNumbers = endWavelengths.size() != pDescriptor->getBandCount();
}
if (useOriginalNumbers)
{
std::vector<unsigned int>::iterator iter =
std::remove_if(bands.begin(), bands.end(), OriginalBandChecker(pDescriptor));
if (iter != bands.end())
{
bands.erase(iter, bands.end());
}
}
if (bands.empty())
{
return DimensionDescriptor();
}
if (useOriginalNumbers)
{
return pDescriptor->getOriginalBand(bands[bands.size() / 2]);
}
return pDescriptor->getActiveBand(bands[bands.size() / 2]);
}
int RasterUtilities::findBestMatch(const std::vector<double> &values, double value,
double tolerance, int startAt)
{
int numValues = values.size();
if (numValues < 1)
{
return -1;
}
int bestMatch(-1);
double leastDiff(tolerance);
double diff;
for (int i = startAt; i < numValues; ++i)
{
diff = fabs(value - values[i]);
if (diff < leastDiff)
{
bestMatch = i;
leastDiff = diff;
}
}
return bestMatch;
}
std::vector<RasterChannelType> RasterUtilities::getVisibleRasterChannels()
{
std::vector<RasterChannelType> channels;
channels.push_back(GRAY);
channels.push_back(RED);
channels.push_back(GREEN);
channels.push_back(BLUE);
return channels;
}
namespace
{
template<typename T>
bool chipMetadataDimTemplate(DataVariant &dimMetadataVariant, const std::vector<DimensionDescriptor> &selectedDims)
{
std::vector<T> *pVec = dimMetadataVariant.getPointerToValue<std::vector<T> >();
if (pVec != NULL)
{
std::vector<T> &dimMetadataVector = *pVec;
std::vector<T> newDimMetadata;
newDimMetadata.reserve(selectedDims.size());
std::vector<DimensionDescriptor>::const_iterator selectedDimIter = selectedDims.begin();
for (size_t i = 0; i < dimMetadataVector.size() && selectedDimIter != selectedDims.end(); ++i)
{
VERIFY(selectedDimIter->isActiveNumberValid());
if (i == selectedDimIter->getActiveNumber())
{
newDimMetadata.push_back(dimMetadataVector[i]);
++selectedDimIter;
}
}
dimMetadataVector.swap(newDimMetadata);
return true;
}
return false;
}
void chipMetadataDim(DynamicObject *pMetadata, const std::vector<DimensionDescriptor> &selectedDims)
{
VERIFYNRV(pMetadata != NULL);
std::vector<std::string> attributeNames;
pMetadata->getAttributeNames(attributeNames);
for (std::vector<std::string>::const_iterator iter = attributeNames.begin();
iter != attributeNames.end(); ++iter)
{
DataVariant& dimMetadataVariant = pMetadata->getAttribute(*iter);
if (dimMetadataVariant.getTypeName() == "DynamicObject")
{
DynamicObject* pChildMetadata = dv_cast<DynamicObject>(&dimMetadataVariant);
if (pChildMetadata != NULL)
{
chipMetadataDim(pChildMetadata, selectedDims);
}
}
if (chipMetadataDimTemplate<char>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<unsigned char>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<short>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<unsigned short>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<int>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<unsigned int>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<long>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<unsigned long>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<int64_t>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<uint64_t>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<Int64>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<UInt64>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<float>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<double>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<bool>(dimMetadataVariant, selectedDims))
{
continue;
}
if (chipMetadataDimTemplate<std::string>(dimMetadataVariant, selectedDims))
{
continue;
}
}
return;
}
}
bool RasterUtilities::chipMetadata(DynamicObject* pMetadata, const std::vector<DimensionDescriptor>& selectedRows,
const std::vector<DimensionDescriptor>& selectedColumns,
const std::vector<DimensionDescriptor>& selectedBands)
{
if (pMetadata != NULL)
{
DynamicObject* pAppMetadata = pMetadata->getAttribute(SPECIAL_METADATA_NAME).getPointerToValue<DynamicObject>();
if (pAppMetadata != NULL)
{
DynamicObject* pRowMetadata = pAppMetadata->getAttribute(ROW_METADATA_NAME).getPointerToValue<DynamicObject>();
if (pRowMetadata != NULL)
{
chipMetadataDim(pRowMetadata, selectedRows);
}
DynamicObject* pColumnMetadata =
pAppMetadata->getAttribute(COLUMN_METADATA_NAME).getPointerToValue<DynamicObject>();
if (pColumnMetadata != NULL)
{
chipMetadataDim(pColumnMetadata, selectedColumns);
}
DynamicObject* pBandMetadata =
pAppMetadata->getAttribute(BAND_METADATA_NAME).getPointerToValue<DynamicObject>();
if (pBandMetadata != NULL)
{
chipMetadataDim(pBandMetadata, selectedBands);
}
}
}
return true;
}
bool RasterUtilities::isSubcube(const RasterDataDescriptor* pDescriptor, bool checkBands)
{
if (pDescriptor == NULL)
{
return false;
}
const RasterFileDescriptor* pFileDescriptor =
dynamic_cast<const RasterFileDescriptor*>(pDescriptor->getFileDescriptor());
if (pFileDescriptor == NULL)
{
return false;
}
if (checkBands == true)
{
if (pDescriptor->getRows() == pFileDescriptor->getRows() &&
pDescriptor->getColumns() == pFileDescriptor->getColumns() &&
pDescriptor->getBands() == pFileDescriptor->getBands())
{
return false;
}
}
else
{
if (pDescriptor->getRows() == pFileDescriptor->getRows() &&
pDescriptor->getColumns() == pFileDescriptor->getColumns())
{
return false;
}
}
return true;
}
int64_t RasterUtilities::calculateFileSize(const RasterFileDescriptor* pDescriptor)
{
int64_t fileSize(-1);
if (pDescriptor == NULL)
{
return fileSize;
}
uint64_t numRows = pDescriptor->getRowCount();
uint64_t numColumns = pDescriptor->getColumnCount();
uint64_t numBands = pDescriptor->getBandCount();
uint64_t bitsPerElement = pDescriptor->getBitsPerElement();
uint64_t headerBytes = pDescriptor->getHeaderBytes();
uint64_t prelineBytes = pDescriptor->getPrelineBytes();
uint64_t postlineBytes = pDescriptor->getPostlineBytes();
uint64_t prebandBytes = pDescriptor->getPrebandBytes();
uint64_t postbandBytes = pDescriptor->getPostbandBytes();
uint64_t trailerBytes = pDescriptor->getTrailerBytes();
InterleaveFormatType interleave = pDescriptor->getInterleaveFormat();
// File size calculation
/*
The total number of pre-line, post-line, pre-band and post-band bytes depends
on the interleave format. Symbols: B1 = Band 1, R1 = Row 1, C1 = Column 1
BSQ BIL BIP
------- ------- -------
Header Header Header
Preband Preline Preline
Preline R1 B1 C1 R1 C1 B1
B1 R1 C1 ... ...
... R1 B1 Cn R1 C1 Bn
B1 R1 Cn ... ...
Postline R1 Bn C1 R1 Cn Bn
... ... Postline
Preline R1 Bn Cn ...
B1 Rn C1 Postline Preline
... ... Rn C1 B1
B1 Rn Cn Preline ...
Postline Rn B1 C1 Rn Cn Bn
Postband ... Postline
... Rn Bn Cn Trailer
Preband Postline
Preline Trailer
Bn Rn C1
...
Bn Rn Cn
Postline
Postband
Trailer
NOTE:
Pre/Post Band bytes are not used with BIL & BIP data - it would be a tremendous waste of space.
*/
switch (interleave)
{
case BSQ:
{
const std::vector<const Filename*>& bandFiles = pDescriptor->getBandFiles();
if (bandFiles.empty() == false) // then data in multiple files
{
numBands = 1; // one band per file
}
uint64_t rowSize = prelineBytes + (numColumns * bitsPerElement / 8) + postlineBytes;
uint64_t bandSize = prebandBytes + (numRows * rowSize) + postbandBytes;
fileSize = static_cast<int64_t>(headerBytes + (numBands * bandSize) + trailerBytes);
}
break;
case BIL: // Fall through
case BIP:
{
uint64_t rowSize = prelineBytes + (numBands * numColumns * bitsPerElement / 8) + postlineBytes;
fileSize = static_cast<int64_t>(headerBytes + (numRows * rowSize) + trailerBytes);
}
break;
default:
break;
}
return fileSize;
}
bool RasterUtilities::rotate(RasterElement* pDst, const RasterElement* pSrc, double angle, int defaultValue,
RasterUtilities::InterpolationType interp, Progress* pProgress, bool* pAbort)
{
if (pDst == NULL || pSrc == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Invalid cube", 0, ERRORS);
}
return false;
}
const RasterDataDescriptor* pSrcDesc = static_cast<const RasterDataDescriptor*>(pSrc->getDataDescriptor());
RasterDataDescriptor* pDstDesc = static_cast<RasterDataDescriptor*>(pDst->getDataDescriptor());
std::vector<int> bvalues = pDstDesc->getBadValues();
if (std::find(bvalues.begin(), bvalues.end(), defaultValue) == bvalues.end())
{
bvalues.push_back(defaultValue);
pDstDesc->setBadValues(bvalues);
}
unsigned int numRows = pSrcDesc->getRowCount();
unsigned int numCols = pSrcDesc->getColumnCount();
unsigned int numBands = pSrcDesc->getBandCount();
bool isBip = (pSrcDesc->getInterleaveFormat() == BIP);
if (numRows != pDstDesc->getRowCount() ||
numCols != pDstDesc->getColumnCount() ||
numBands != pDstDesc->getBandCount() ||
isBip != (pDstDesc->getInterleaveFormat() == BIP))
{
if (pProgress != NULL)
{
pProgress->updateProgress("Desitnation cube is not compatible with source cube.", 0, ERRORS);
}
return false;
}
// calculate the rotation of the four corners
int x1 = numCols / 2;
int y1 = numRows / 2;
int x0 = -(static_cast<int>(numCols) - x1 - 1);
int y0 = -(static_cast<int>(numRows) - y1 - 1);
Opticks::PixelLocation ul(x0, y0);
Opticks::PixelLocation ur(x1, y0);
Opticks::PixelLocation ll(x0, y1);
Opticks::PixelLocation lr(x1, y1);
double cosA = cos(angle);
double sinA = sin(angle);
Opticks::PixelLocation ulPrime(static_cast<int>(ul.mX * cosA - ul.mY * sinA + 0.5),
static_cast<int>(ul.mX * sinA + ul.mY * cosA + 0.5));
Opticks::PixelLocation urPrime(static_cast<int>(ur.mX * cosA - ur.mY * sinA + 0.5),
static_cast<int>(ur.mX * sinA + ur.mY * cosA + 0.5));
Opticks::PixelLocation llPrime(static_cast<int>(ll.mX * cosA - ll.mY * sinA + 0.5),
static_cast<int>(ll.mX * sinA + ll.mY * cosA + 0.5));
Opticks::PixelLocation lrPrime(static_cast<int>(lr.mX * cosA - lr.mY * sinA + 0.5),
static_cast<int>(lr.mX * sinA + lr.mY * cosA + 0.5));
// use Bresenham's to calculate the start and end coordinates of each row
std::vector<Opticks::PixelLocation> newRowStartPre;
calculateNewPoints(ulPrime, llPrime, newRowStartPre);
std::vector<Opticks::PixelLocation> newRowEndPre;
calculateNewPoints(urPrime, lrPrime, newRowEndPre);
// interpolate so we have the proper number of points
std::vector<Opticks::PixelLocation> newRowStart;
std::vector<Opticks::PixelLocation> newRowEnd;
newRowStart.reserve(numRows);
newRowEnd.reserve(numRows);
double startMult = newRowStartPre.size() / static_cast<double>(numRows);
double endMult = newRowEndPre.size() / static_cast<double>(numRows);
for (unsigned int row = 0; row < numRows; ++row)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Calculating row shifts.", row * 100 / numRows, NORMAL);
}
switch(interp)
{
case NEAREST_NEIGHBOR:
{
unsigned int preStartRow = static_cast<int>(startMult * row + 0.5);
unsigned int preEndRow = static_cast<int>(endMult * row + 0.5);
newRowStart.push_back(newRowStartPre[preStartRow]);
newRowEnd.push_back(newRowEndPre[preEndRow]);
break;
}
case BILINEAR:
case BICUBIC:
default:
if (pProgress != NULL)
{
pProgress->updateProgress("Invalid or unsupported interpolation method.", 0, ERRORS);
}
return false;
}
}
if (newRowStart.size() != numRows || newRowEnd.size() != numRows)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Error calculating new row positions.", 0, ERRORS);
}
return false;
}
unsigned int outBandLoop = isBip ? 1 : numBands;
unsigned int inBandLoop = isBip ? numBands : 1;
for (unsigned int outBand = 0; outBand < outBandLoop; ++outBand)
{
FactoryResource<DataRequest> pSrcRequest;
FactoryResource<DataRequest> pDstRequest;
VERIFY(pSrcRequest.get() && pDstRequest.get());
pSrcRequest->setRows(DimensionDescriptor(), DimensionDescriptor(), 1);
pDstRequest->setRows(DimensionDescriptor(), DimensionDescriptor(), 1);
pSrcRequest->setColumns(DimensionDescriptor(), DimensionDescriptor(), numCols);
pDstRequest->setColumns(DimensionDescriptor(), DimensionDescriptor(), numCols);
if (!isBip)
{
pSrcRequest->setBands(pSrcDesc->getActiveBand(outBand), pSrcDesc->getActiveBand(outBand), 1);
pDstRequest->setBands(pDstDesc->getActiveBand(outBand), pDstDesc->getActiveBand(outBand), 1);
}
pDstRequest->setWritable(true);
DataAccessor pSrcAcc = pSrc->getDataAccessor(pSrcRequest.release());
DataAccessor pDstAcc = pDst->getDataAccessor(pDstRequest.release());
for (unsigned int row = 0; row < numRows; ++row)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Warping rows.", row * 100 / numRows, NORMAL);
}
if (pAbort != NULL && *pAbort)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Aborted by user.", 0, ABORT);
}
return false;
}
if (!pDstAcc.isValid())
{
if (pProgress != NULL)
{
pProgress->updateProgress("Error copying data.", 0, ERRORS);
}
return false;
}
// initialize the row...this is faster than checking validity at each
// pixel and setting the default value at that pixel
switchOnComplexEncoding(pDstDesc->getDataType(), setPixel,
pDstAcc->getRow(), defaultValue, inBandLoop*numCols);
// use Bresenham's to calculate the column coordinates
std::vector<Opticks::PixelLocation> newColPre;
calculateNewPoints(newRowStart[row], newRowEnd[row], newColPre);
// interpolate so we have the proper number of points
double mult = newColPre.size() / static_cast<double>(numCols);
for (unsigned int col = 0; col < numCols; ++col)
{
if (!pDstAcc.isValid())
{
if (pProgress != NULL)
{
pProgress->updateProgress("Error copying data.", 0, ERRORS);
}
return false;
}
Opticks::PixelLocation sourcePixel;
switch(interp)
{
case NEAREST_NEIGHBOR:
{
unsigned int preCol = static_cast<int>(mult * col + 0.5);
sourcePixel = newColPre[preCol];
break;
}
case BILINEAR:
case BICUBIC:
default:
if (pProgress != NULL)
{
pProgress->updateProgress("Invalid or unsupported interpolation method.", 0, ERRORS);
}
return false;
}
sourcePixel -= Opticks::PixelLocation(x0, y0);
if (sourcePixel.mX >= 0 && sourcePixel.mX < static_cast<int>(numCols) &&
sourcePixel.mY >= 0 && sourcePixel.mY < static_cast<int>(numRows))
{
pSrcAcc->toPixel(sourcePixel.mY, sourcePixel.mX);
if (!pSrcAcc.isValid())
{
if (pProgress != NULL)
{
pProgress->updateProgress("Error reading source cube.", 0, ERRORS);
}
return false;
}
memcpy(pDstAcc->getColumn(), pSrcAcc->getColumn(), pDstDesc->getBytesPerElement() * inBandLoop);
}
pDstAcc->nextColumn();
}
pDstAcc->nextRow();
}
}
pDst->updateData();
return true;
}
| [
"wzssyqa@gmail.com"
] | wzssyqa@gmail.com |
5884ea3a54cda963591bd25426d5e268d615710a | a484e85687e5b6101c2dcabd76a2dce189d9dd6d | /LzsSTL/uninitailized.h | e94f66ac24e1ef552c92d54785e8b4f366cf76f4 | [] | no_license | Rango-lzs/LzsSTL | c4195ac8bc45acaf46356ebb4209d7ac32defc6d | 67d6984439aeb266112b3a62d6c8b534bfc61b42 | refs/heads/main | 2023-06-09T00:07:55.037683 | 2021-07-01T09:22:08 | 2021-07-05T00:55:51 | 379,435,272 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,002 | h | #ifndef UNINITIALIZED_HH
#define UNINITIALIZED_HH
#include <cstring>
#include "allocator.h"
#include "algobase.h"
// 未初始化容器的 copy fill fill_n操作
// iterator ->trits: value_type copy(f,l,r)->value_type _copy(f,l,r,value_type)
// value_type ->trats: is_Pod_type _copy(f,l,r,value_type)->_copy_aux(f,l,r,pod || not_pod) ,overload
template<class InputIterator ,class ForwardIterator>
inline ForwardIterator
uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result)
{
return __uninitialized_copy(first, last, result, value_type(result));
}
template<class InputIterator, class ForwardIterator, class T>
inline ForwardIterator
__uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result,T*)
{
typedef typename __type_traits<T>::is_POD_type POD_type;
return __uninitialized_copy_aux(first, last, result, POD_type());
}
template<class InputIterator, class ForwardIterator>
inline ForwardIterator
__uninitialized_copy_aux(InputIterator first, InputIterator last, ForwardIterator result, __true_type)
{
return ::copy(first, last, result);
//return nullptr;
}
template<class InputIterator, class ForwardIterator>
inline ForwardIterator
__uninitialized_copy_aux(InputIterator first, InputIterator last, ForwardIterator result, __false_type)
{
for (; first != last; ++first,++result)
{
construct(result, *first);
}
return result;
}
//函数是不支持偏特化的
inline char* uninitialized_copy(const char* first, const char* last, char* des)
{
memmove(des, first, sizeof(char)*(last - first));
return des + (last - first);
}
inline wchar_t* uninitialized_copy(const wchar_t* first, const wchar_t* last, wchar_t* des)
{
memmove(des, first, sizeof(wchar_t)*(last - first));
return des + (last - first);
}
//************ fill **************
template<class ForwardIterator,class T>
inline void
uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& value)
{
__uninitialized_fill(first, last, value,value_type(first));
}
// 为什么不直接通过T 来获取是否是pod 类型 ,是因为只有迭代器才定义了is_pod??
template<class ForwardIterator, class T>
inline void
__uninitialized_fill(ForwardIterator first, ForwardIterator last,const T&value, T*)
{
typedef typename __type_traits<T>::is_POD_type POD_type;
__uninitialized_fill_aux(first, last, value, POD_type());
}
template< class ForwardIterator, class T>
inline void
__uninitialized_fill_aux(ForwardIterator first, ForwardIterator last, const T& value, __true_type)
{
::fill(first, last, value);
}
template<class ForwardIterator, class T>
inline void
__uninitialized_fill_aux(ForwardIterator first, ForwardIterator last, const T& value, __false_type)
{
for (; first != last; ++first)
{
construct(first, value);
}
}
//************ fill_n **************
template<class ForwardIterator, class T>
inline ForwardIterator
uninitialized_fill_n(ForwardIterator first,size_t n, const T& value)
{
return __uninitialized_fill_n(first, n, value, value_type(first));
}
// 为什么不直接通过T 来获取是否是pod 类型 ,是因为只有迭代器才定义了is_pod??
template<class ForwardIterator, class T>
inline ForwardIterator
__uninitialized_fill_n(ForwardIterator first,size_t n, const T&value, T*)
{
typedef typename __type_traits<T>::is_POD_type POD_type;
return __uninitialized_fill_n_aux(first, n, value, POD_type());
}
template< class ForwardIterator, class T>
inline ForwardIterator
__uninitialized_fill_n_aux(ForwardIterator first,size_t n, const T& value, __true_type)
{
::fill_n(first, n, value);
return first + n;
}
template<class ForwardIterator, class T>
inline void
__uninitialized_fill_n_aux(ForwardIterator first, size_t n, const T& value, __false_type)
{
for (; n>0;--n, ++first)
{
construct(first, value);
}
return first + n;
}
template<class Iterator, class T>
inline void
fill_n(Iterator pos, size_t n, const T& value)
{
for (; n > 0; n--, pos++)
*pos = value;
}
#endif | [
"1191472748@qq.com"
] | 1191472748@qq.com |
6b45302bcb7d0f96f9e215ff4d8464147ba54cc4 | f321954248d2d188438c49320a20babb71830954 | /framework/src/node.cpp | f042980be998cd0fd817da98c1758c8ed53cf29c | [] | no_license | PouceHeure/lightweight_simulator_robot | 89f63df3dfc3d3e809577883c062fe72372cba1f | 18ff1159fa763c1e609a78b6b9aadd1a0c6f61f9 | refs/heads/master | 2022-03-02T15:35:45.530185 | 2019-11-12T21:13:25 | 2019-11-12T21:13:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 205 | cpp | #include "graph/node.hpp"
Node::Node():id(Node::COUNTER){
Node::COUNTER++;
};
void Node::attachNode(Node *node){
//billateral connection
node->attachNode(this);
nodes.push_back(node);
} | [
"hugo.pousseur@gmail.com"
] | hugo.pousseur@gmail.com |
99b4a7da225086eb41901f51616da77281fe4e73 | 4a2cde8c4f3420c2e024e4e516c3daecf622c9cc | /Maze.cpp | 9f45791564276b014d0d769410a7db2c4c77414d | [] | no_license | faatehsultan/MazeApp | f19a560b554ae04b3ed835a1b03dbe2e3f44415d | 15b40bdf603be616d92a349171772926939f95c6 | refs/heads/master | 2021-05-18T01:00:43.996875 | 2020-03-29T13:30:53 | 2020-03-29T13:30:53 | 251,037,348 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,941 | cpp | #include "Maze.h"
/*when source and destination not given in constructor,
first cell wil be considered source and last cell will
be considered destination. Initially, curPos will be
at source point.*/
bool Maze::setCurrentPos(const Point cur)
{
if (cur.col >= 0 && cur.row >= 0 &&
cur.col < noOfCols && cur.row < noOfRows &&
testPoint(cur))
{
curPos = cur;
return true;
}
return false;
}
Maze::Maze(const int _noOfRows, const int _noOfCols) :noOfRows(_noOfRows),
noOfCols(_noOfCols), source(-1, -1), destination(-1, -1),
curPos(source),maze(nullptr)
{
if (_noOfCols <= 0 || _noOfRows <= 0)
return;
maze = new int* [noOfRows];
for (int i = 0; i < noOfRows; i++)
maze[i] = new int[noOfCols];
resetMaze();
}
Maze::Maze(const int _noOfRows, const int _noOfCols,
const Point src, const Point dest) :
Maze(_noOfRows, _noOfCols)
{
if (_noOfCols <= 0 || _noOfRows <= 0)
return;
setSource(src);
setDestination(dest);
}
Maze::Maze(const Maze& ref) :
Maze(ref.noOfRows, ref.noOfCols)
{
for (int i = 0; i < noOfRows; i++)
{
for (int j = 0; j < noOfCols; j++)
maze[i][j] = ref.maze[i][j];
}
setSource(ref.source);
setCurrentPos(ref.curPos);
setDestination(ref.destination);
}
Maze::~Maze()
{
for (int i = 0; i < noOfRows; i++)
delete[] maze[i];
delete[]maze;
}
void Maze::setMaze(int** srcMaze)
{
for (int i = 0; i < noOfRows; i++)
{
for (int j = 0; j < noOfCols; j++)
maze[i][j] = srcMaze[i][j];
}
//default setting of source, destination and curPos
bool set = false;
for (int i = 0; i < noOfRows && !set; i++)
{
for (int j = 0; j < noOfCols && !set; j++)
{
if (maze[i][j])
{
setSource({ i, j });
setCurrentPos({ i, j });
set = true;
}
}
}
set = false;
for (int i = noOfRows - 1; i >= 0 && !set; i--)
{
for (int j = noOfCols - 1; j >= 0 && !set; j--)
{
if (maze[i][j])
{
setDestination({ i, j });
set = true;
}
}
}
}
void Maze::resetMaze()
{
for (int i = 0; i < noOfRows; i++)
{
for (int j = 0; j < noOfCols; j++)
maze[i][j] = 0;
}
}
bool Maze::setSource(const Point src)
{
if (testPoint(src))
{
source = src;
curPos = src; //current position will also restart
return true;
}
return false;
}
bool Maze::setDestination(const Point dest)
{
if (testPoint(dest))
{
destination = dest;
return true;
}
return false;
}
Point Maze::getSource()
{
return source;
}
Point Maze::getDestination()
{
return destination;
}
Point Maze::getCurrentPos()
{
return curPos;
}
bool Maze::up()
{
if (testPoint({ curPos.row - 1, curPos.col }))
{
curPos.row--;
return true;
}
return false;
}
bool Maze::down()
{
if (testPoint({ curPos.row + 1, curPos.col }))
{
curPos.row++;
return true;
}
return false;
}
bool Maze::right()
{
if (testPoint({ curPos.row, curPos.col + 1 }))
{
curPos.col++;
return true;
}
return false;
}
bool Maze::left()
{
if (testPoint({ curPos.row, curPos.col - 1 }))
{
curPos.col--;
return true;
}
return false;
}
void Maze::displayMaze()
{
for (int i = 0; i < noOfRows; i++)
{
//during display, S means source, D means
//destination and [] will show current position
for (int j = 0; j < noOfCols; j++)
{
Point cur(i, j);
if (source == cur || destination == cur)
{
cout << ((curPos == cur) ? '[' : '\"')
<< ((source == cur) ? 'S' : 'D')
<< ((curPos == cur) ? ']' : '\"');
}
else
{
cout << ((curPos == cur) ? '[' : ' ')
<< (bool)(maze[i][j])
<< ((curPos == cur) ? ']' : ' ');
}
}
cout << "\n\n";
}
}
int& Maze::operator[](const Point p)
{
return maze[p.row][p.col];
}
bool Maze::testPoint(Point p)
{
return (p.col >= 0 && p.row >= 0 && p.col < noOfCols &&
p.row < noOfRows && maze[p.row][p.col] == 1);
}
| [
"noreply@github.com"
] | noreply@github.com |
7fbc60b42193591663ffdcc5921954b47d4f332a | 93b24e6296dade8306b88395648377e1b2a7bc8c | /client/wxWidgets/wx/palmos/setup0.h | 042c5a0ad9701213edd4bcf62fb6405923e976fa | [] | no_license | dahahua/pap_wclinet | 79c5ac068cd93cbacca5b3d0b92e6c9cba11a893 | d0cde48be4d63df4c4072d4fde2e3ded28c5040f | refs/heads/master | 2022-01-19T21:41:22.000190 | 2013-10-12T04:27:59 | 2013-10-12T04:27:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 37,329 | h | /////////////////////////////////////////////////////////////////////////////
// Name: wx/palmos/setup.h
// Purpose: Configuration for the library
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: setup0.h,v 1.21 2005/05/31 09:18:43 JS Exp $
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SETUP_H_
#define _WX_SETUP_H_
// ----------------------------------------------------------------------------
// global settings
// ----------------------------------------------------------------------------
// define this to 0 when building wxBase library - this can also be done from
// makefile/project file overriding the value here
#ifndef wxUSE_GUI
#define wxUSE_GUI 1
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// compatibility settings
// ----------------------------------------------------------------------------
// This setting determines the compatibility with 2.2 API: set it to 1 to
// enable it but please consider updating your code instead.
//
// Default is 0
//
// Recommended setting: 0 (please update your code)
#define WXWIN_COMPATIBILITY_2_2 0
// This setting determines the compatibility with 2.4 API: set it to 0 to
// flag all cases of using deprecated functions.
//
// Default is 1 but please try building your code with 0 as the default will
// change to 0 in the next version and the deprecated functions will disappear
// in the version after it completely.
//
// Recommended setting: 0 (please update your code)
#define WXWIN_COMPATIBILITY_2_4 0
// Set to 0 for accurate dialog units, else 1 to be as per 2.1.16 and before.
// If migrating between versions, your dialogs may seem to shrink.
//
// Default is 1
//
// Recommended setting: 0 (the new calculations are more correct!)
#define wxDIALOG_UNIT_COMPATIBILITY 1
// ----------------------------------------------------------------------------
// debugging settings
// ----------------------------------------------------------------------------
// Generic comment about debugging settings: they are very useful if you don't
// use any other memory leak detection tools such as Purify/BoundsChecker, but
// are probably redundant otherwise. Also, Visual C++ CRT has the same features
// as wxWidgets memory debugging subsystem built in since version 5.0 and you
// may prefer to use it instead of built in memory debugging code because it is
// faster and more fool proof.
//
// Using VC++ CRT memory debugging is enabled by default in debug mode
// (__WXDEBUG__) if wxUSE_GLOBAL_MEMORY_OPERATORS is *not* enabled (i.e. is 0)
// and if __NO_VC_CRTDBG__ is not defined.
// If 1, enables wxDebugContext, for writing error messages to file, etc. If
// __WXDEBUG__ is not defined, will still use the normal memory operators.
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_DEBUG_CONTEXT 0
// If 1, enables debugging versions of wxObject::new and wxObject::delete *IF*
// __WXDEBUG__ is also defined.
//
// WARNING: this code may not work with all architectures, especially if
// alignment is an issue. This switch is currently ignored for mingw / cygwin
//
// Default is 0
//
// Recommended setting: 1 if you are not using a memory debugging tool, else 0
#define wxUSE_MEMORY_TRACING 0
// In debug mode, cause new and delete to be redefined globally.
// If this causes problems (e.g. link errors which is a common problem
// especially if you use another library which also redefines the global new
// and delete), set this to 0.
// This switch is currently ignored for mingw / cygwin
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
// In debug mode, causes new to be defined to be WXDEBUG_NEW (see object.h). If
// this causes problems (e.g. link errors), set this to 0. You may need to set
// this to 0 if using templates (at least for VC++). This switch is currently
// ignored for mingw / cygwin / CodeWarrior
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_DEBUG_NEW_ALWAYS 0
// wxHandleFatalExceptions() may be used to catch the program faults at run
// time and, instead of terminating the program with a usual GPF message box,
// call the user-defined wxApp::OnFatalException() function. If you set
// wxUSE_ON_FATAL_EXCEPTION to 0, wxHandleFatalExceptions() will not work.
//
// This setting is for Win32 only and can only be enabled if your compiler
// supports Win32 structured exception handling (currently only VC++ does)
//
// Default is 1
//
// Recommended setting: 1 if your compiler supports it.
#if defined(_MSC_VER) || \
(defined(__BORLANDC__) && __BORLANDC__ >= 0x0550)
#define wxUSE_ON_FATAL_EXCEPTION 0
#else
#define wxUSE_ON_FATAL_EXCEPTION 0
#endif
// ----------------------------------------------------------------------------
// Unicode support
// ----------------------------------------------------------------------------
// Set wxUSE_UNICODE to 1 to compile wxWidgets in Unicode mode: wxChar will be
// defined as wchar_t, wxString will use Unicode internally. If you set this
// to 1, you must use wxT() macro for all literal strings in the program.
//
// Unicode is currently only fully supported under Windows NT/2000/XP
// (Windows 9x doesn't support it and the programs compiled in Unicode mode
// will not run under 9x -- but see wxUSE_UNICODE_MSLU below).
//
// Default is 0
//
// Recommended setting: 0 (unless you only plan to use Windows NT/2000/XP)
#ifndef wxUSE_UNICODE
#define wxUSE_UNICODE 0
#endif
// Set wxUSE_UNICODE_MSLU to 1 if you want to compile wxWidgets in Unicode mode
// and be able to run compiled apps under Windows 9x as well as NT/2000/XP.
// This setting enables use of unicows.dll from MSLU (MS Layer for Unicode, see
// http://www.microsoft.com/globaldev/handson/dev/mslu_announce.mspx). Note
// that you will have to modify the makefiles to include unicows.lib import
// library as the first library (see installation instructions in install.txt
// to learn how to do it when building the library or samples).
//
// If your compiler doesn't have unicows.lib, you can get a version of it at
// http://libunicows.sourceforge.net
//
// Default is 0
//
// Recommended setting: 0 (1 if you want to deploy Unicode apps on 9x systems)
#define wxUSE_UNICODE_MSLU 0
// Setting wxUSE_WCHAR_T to 1 gives you some degree of Unicode support without
// compiling the program in Unicode mode. More precisely, it will be possible
// to construct wxString from a wide (Unicode) string and convert any wxString
// to Unicode.
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_WCHAR_T 0
// ----------------------------------------------------------------------------
// global features
// ----------------------------------------------------------------------------
// Compile library in exception-safe mode? If set to 1, the library will try to
// behave correctly in presence of exceptions (even though it still will not
// use the exceptions itself) and notify the user code about any unhandled
// exceptions. If set to 0, propagation of the exceptions through the library
// code will lead to undefined behaviour -- but the code itself will be
// slightly smaller and faster.
//
// Default is 1
//
// Recommended setting: depends on whether you intend to use C++ exceptions
// in your own code (1 if you do, 0 if you don't)
#define wxUSE_EXCEPTIONS 1
// Set wxUSE_EXTENDED_RTTI to 1 to use extended RTTI
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_EXTENDED_RTTI 0
#if defined(__BORLANDC__)
#undef wxUSE_EXTENDED_RTTI
#define wxUSE_EXTENDED_RTTI 1
#endif
// Set wxUSE_STL to 1 to derive wxList(Foo) and wxArray(Foo) from
// std::list<Foo*> and std::vector<Foo*>, with a compatibility interface,
// and for wxHashMap to be implemented with templates.
//
// Default is 0
//
// Recommended setting: YMMV
#define wxUSE_STL 0
// Support for message/error logging. This includes wxLogXXX() functions and
// wxLog and derived classes. Don't set this to 0 unless you really know what
// you are doing.
//
// Default is 1
//
// Recommended setting: 1 (always)
#define wxUSE_LOG 0
// Recommended setting: 1
#define wxUSE_LOGWINDOW 0
// Recommended setting: 1
#define wxUSE_LOGGUI 0
// Recommended setting: 1
#define wxUSE_LOG_DIALOG 0
// Support for command line parsing using wxCmdLineParser class.
//
// Default is 1
//
// Recommended setting: 1 (can be set to 0 if you don't use the cmd line)
#define wxUSE_CMDLINE_PARSER 0
// Support for multithreaded applications: if 1, compile in thread classes
// (thread.h) and make the library a bit more thread safe. Although thread
// support is quite stable by now, you may still consider recompiling the
// library without it if you have no use for it - this will result in a
// somewhat smaller and faster operation.
//
// This is ignored under Win16, threads are only supported under Win32.
//
// Default is 1
//
// Recommended setting: 0 unless you do plan to develop MT applications
#define wxUSE_THREADS 0
// If enabled (1), compiles wxWidgets streams classes
#define wxUSE_STREAMS 0
// Use standard C++ streams if 1. If 0, use wxWin streams implementation.
#define wxUSE_STD_IOSTREAM 0
// ----------------------------------------------------------------------------
// non GUI features selection
// ----------------------------------------------------------------------------
// Set wxUSE_LONGLONG to 1 to compile the wxLongLong class. This is a 64 bit
// integer which is implemented in terms of native 64 bit integers if any or
// uses emulation otherwise.
//
// This class is required by wxDateTime and so you should enable it if you want
// to use wxDateTime. For most modern platforms, it will use the native 64 bit
// integers in which case (almost) all of its functions are inline and it
// almost does not take any space, so there should be no reason to switch it
// off.
//
// Recommended setting: 1
#define wxUSE_LONGLONG 1
// Set wxUSE_(F)FILE to 1 to compile wx(F)File classes. wxFile uses low level
// POSIX functions for file access, wxFFile uses ANSI C stdio.h functions.
//
// Default is 1
//
// Recommended setting: 1 (wxFile is highly recommended as it is required by
// i18n code, wxFileConfig and others)
#define wxUSE_FILE 0
#define wxUSE_FFILE 0
// Use wxFSVolume class providing access to the configured/active mount points
//
// Default is 1
//
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_FSVOLUME 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//
// Default is 1
//
// Recommended setting: 1 (may be disabled to save space, but not much)
#define wxUSE_STDPATHS 1
// use wxTextBuffer class: required by wxTextFile
#define wxUSE_TEXTBUFFER 0
// use wxTextFile class: requires wxFile and wxTextBuffer, required by
// wxFileConfig
#define wxUSE_TEXTFILE 0
// i18n support: _() macro, wxLocale class. Requires wxTextFile.
#define wxUSE_INTL 0
// Set wxUSE_DATETIME to 1 to compile the wxDateTime and related classes which
// allow to manipulate dates, times and time intervals. wxDateTime replaces the
// old wxTime and wxDate classes which are still provided for backwards
// compatibility (and implemented in terms of wxDateTime).
//
// Note that this class is relatively new and is still officially in alpha
// stage because some features are not yet (fully) implemented. It is already
// quite useful though and should only be disabled if you are aiming at
// absolutely minimal version of the library.
//
// Requires: wxUSE_LONGLONG
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_DATETIME 1
// Set wxUSE_TIMER to 1 to compile wxTimer class
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_TIMER 0
// Use wxStopWatch clas.
//
// Default is 1
//
// Recommended setting: 1 (needed by wxSocket)
#define wxUSE_STOPWATCH 0
// Setting wxUSE_CONFIG to 1 enables the use of wxConfig and related classes
// which allow the application to store its settings in the persistent
// storage. Setting this to 1 will also enable on-demand creation of the
// global config object in wxApp.
//
// See also wxUSE_CONFIG_NATIVE below.
//
// Recommended setting: 1
#define wxUSE_CONFIG 1
// If wxUSE_CONFIG is 1, you may choose to use either the native config
// classes under Windows (using .INI files under Win16 and the registry under
// Win32) or the portable text file format used by the config classes under
// Unix.
//
// Default is 1 to use native classes. Note that you may still use
// wxFileConfig even if you set this to 1 - just the config object created by
// default for the applications needs will be a wxRegConfig or wxIniConfig and
// not wxFileConfig.
//
// Recommended setting: 1
#define wxUSE_CONFIG_NATIVE 1
// If wxUSE_DIALUP_MANAGER is 1, compile in wxDialUpManager class which allows
// to connect/disconnect from the network and be notified whenever the dial-up
// network connection is established/terminated. Requires wxUSE_DYNAMIC_LOADER.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_DIALUP_MANAGER 0
// Compile in classes for run-time DLL loading and function calling.
// Required by wxUSE_DIALUP_MANAGER.
//
// This setting is for Win32 only
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_DYNLIB_CLASS 0
// experimental, don't use for now
#define wxUSE_DYNAMIC_LOADER 0
// Set to 1 to use socket classes
#define wxUSE_SOCKETS 0
// Set to 1 to enable virtual file systems (required by wxHTML)
#define wxUSE_FILESYSTEM 0
// Set to 1 to enable virtual ZIP filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_ZIP 0
// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_INET 0
// wxArchive classes for accessing archives such as zip and tar
#define wxUSE_ARCHIVE_STREAMS 0
// Set to 1 to compile wxZipInput/OutputStream classes.
#define wxUSE_ZIPSTREAM 0
// Set to 1 to compile wxZlibInput/OutputStream classes. Also required by
// wxUSE_LIBPNG
#define wxUSE_ZLIB 0
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
//
// Default is 1.
//
// Recommended setting: 1 unless you don't like the license terms (unlikely)
#define wxUSE_APPLE_IEEE 0
// Joystick support class
#define wxUSE_JOYSTICK 0
// wxFontMapper class
#define wxUSE_FONTMAP 0
// wxMimeTypesManager class
#define wxUSE_MIMETYPE 0
// wxProtocol and related classes: if you want to use either of wxFTP, wxHTTP
// or wxURL you need to set this to 1.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_PROTOCOL 0
// The settings for the individual URL schemes
#define wxUSE_PROTOCOL_FILE 0
#define wxUSE_PROTOCOL_FTP 0
#define wxUSE_PROTOCOL_HTTP 0
// Define this to use wxURL class.
#define wxUSE_URL 0
// Define this to use native platform url and protocol support.
// Currently valid only for MS-Windows.
// Note: if you set this to 1, you can open ftp/http/gopher sites
// and obtain a valid input stream for these sites
// even when you set wxUSE_PROTOCOL_FTP/HTTP to 0.
// Doing so reduces the code size.
//
// This code is experimental and subject to change.
#define wxUSE_URL_NATIVE 0
// Support for regular expression matching via wxRegEx class: enable this to
// use POSIX regular expressions in your code. You need to compile regex
// library from src/regex to use it under Windows.
//
// Default is 0
//
// Recommended setting: 1 if your compiler supports it, if it doesn't please
// contribute us a makefile for src/regex for it
#define wxUSE_REGEX 0
// wxSystemOptions class
#define wxUSE_SYSTEM_OPTIONS 0
// wxSound class
#define wxUSE_SOUND 0
#define wxUSE_MEDIACTRL 0
// Use wxWidget's XRC XML-based resource system. Recommended.
//
// Default is 1
//
// Recommended setting: 1 (requires wxUSE_XML)
#define wxUSE_XRC 0
// XML parsing classes. Note that their API will change in the future, so
// using wxXmlDocument and wxXmlNode in your app is not recommended.
//
// Default is 1
//
// Recommended setting: 1 (required by XRC)
#if wxUSE_XRC
# define wxUSE_XML 1
#else
# define wxUSE_XML 0
#endif
// ----------------------------------------------------------------------------
// Individual GUI controls
// ----------------------------------------------------------------------------
// You must set wxUSE_CONTROLS to 1 if you are using any controls at all
// (without it, wxControl class is not compiled)
//
// Default is 1
//
// Recommended setting: 1 (don't change except for very special programs)
#define wxUSE_CONTROLS 1
// wxPopupWindow class is a top level transient window. It is currently used
// to implement wxTipWindow
//
// Default is 1
//
// Recommended setting: 1 (may be set to 0 if you don't wxUSE_TIPWINDOW)
#define wxUSE_POPUPWIN 0
// wxTipWindow allows to implement the custom tooltips, it is used by the
// context help classes. Requires wxUSE_POPUPWIN.
//
// Default is 1
//
// Recommended setting: 1 (may be set to 0)
#define wxUSE_TIPWINDOW 0
// Each of the settings below corresponds to one wxWidgets control. They are
// all switched on by default but may be disabled if you are sure that your
// program (including any standard dialogs it can show!) doesn't need them and
// if you desperately want to save some space. If you use any of these you must
// set wxUSE_CONTROLS as well.
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_BUTTON 1 // wxButton
#define wxUSE_BMPBUTTON 0 // wxBitmapButton
#define wxUSE_CALENDARCTRL 0 // wxCalendarCtrl
#define wxUSE_CHECKBOX 1 // wxCheckBox
#define wxUSE_CHECKLISTBOX 0 // wxCheckListBox (requires wxUSE_OWNER_DRAWN)
#define wxUSE_CHOICE 0 // wxChoice
#define wxUSE_COMBOBOX 0 // wxComboBox
#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl
#define wxUSE_GAUGE 0 // wxGauge
#define wxUSE_LISTBOX 0 // wxListBox
#define wxUSE_LISTCTRL 0 // wxListCtrl
#define wxUSE_RADIOBOX 1 // wxRadioBox
#define wxUSE_RADIOBTN 1 // wxRadioButton
#define wxUSE_SCROLLBAR 0 // wxScrollBar
#define wxUSE_SLIDER 1 // wxSlider
#define wxUSE_SPINBTN 0 // wxSpinButton
#define wxUSE_SPINCTRL 0 // wxSpinCtrl
#define wxUSE_STATBOX 0 // wxStaticBox
#define wxUSE_STATLINE 0 // wxStaticLine
#define wxUSE_STATTEXT 1 // wxStaticText
#define wxUSE_STATBMP 0 // wxStaticBitmap
#define wxUSE_TEXTCTRL 0 // wxTextCtrl
#define wxUSE_TOGGLEBTN 1 // requires wxButton
#define wxUSE_TREECTRL 0 // wxTreeCtrl
// Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR
// below either wxStatusBarPalm or a generic wxStatusBar will be used.
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_STATUSBAR 1
// Two status bar implementations are available under PalmOS: the generic one
// or the wrapper around native status bar. For native look and feel the native
// version should be used.
//
// Default is 1.
//
// Recommended setting: 1 (there is no advantage in using the generic one)
#define wxUSE_NATIVE_STATUSBAR 1
// wxToolBar related settings: if wxUSE_TOOLBAR is 0, don't compile any toolbar
// classes at all. Otherwise, use the native toolbar class unless
// wxUSE_TOOLBAR_NATIVE is 0.
//
// Default is 1 for all settings.
//
// Recommended setting: 1 for wxUSE_TOOLBAR and wxUSE_TOOLBAR_NATIVE.
#define wxUSE_TOOLBAR 0
#define wxUSE_TOOLBAR_NATIVE 0
// wxNotebook is a control with several "tabs" located on one of its sides. It
// may be used ot logically organise the data presented to the user instead of
// putting everything in one huge dialog. It replaces wxTabControl and related
// classes of wxWin 1.6x.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_NOTEBOOK 0
// wxListbook control is similar to wxNotebook but uses wxListCtrl instead of
// the tabs
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_LISTBOOK 0
// wxChoicebook control is similar to wxNotebook but uses wxChoice instead of
// the tabs
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_CHOICEBOOK 0
// wxTabDialog is a generic version of wxNotebook but it is incompatible with
// the new class. It shouldn't be used in new code.
//
// Default is 0.
//
// Recommended setting: 0 (use wxNotebook)
#define wxUSE_TAB_DIALOG 0
// wxGrid class
//
// Default is 1 for both options.
//
// Recommended setting: 1
//
#define wxUSE_GRID 0
// ----------------------------------------------------------------------------
// Miscellaneous GUI stuff
// ----------------------------------------------------------------------------
// wxAcceleratorTable/Entry classes and support for them in wxMenu(Bar)
#define wxUSE_ACCEL 0
// Hotkey support (currently Windows only)
#define wxUSE_HOTKEY 0
// Use wxCaret: a class implementing a "cursor" in a text control (called caret
// under Windows).
//
// Default is 1.
//
// Recommended setting: 1 (can be safely set to 0, not used by the library)
#define wxUSE_CARET 0
// Use wxDisplay class: it allows enumerating all displays on a system and
// working with them.
//
// Default is 0 because it isn't yet implemented on all platforms
//
// Recommended setting: 1 if you need it, can be safely set to 0 otherwise
#define wxUSE_DISPLAY 0
// Miscellaneous geometry code: needed for Canvas library
#define wxUSE_GEOMETRY 0
// Use wxImageList. This class is needed by wxNotebook, wxTreeCtrl and
// wxListCtrl.
//
// Default is 1.
//
// Recommended setting: 1 (set it to 0 if you don't use any of the controls
// enumerated above, then this class is mostly useless too)
#define wxUSE_IMAGLIST 0
// Use wxMenu, wxMenuBar, wxMenuItem.
//
// Default is 1.
//
// Recommended setting: 1 (can't be disabled under MSW)
#define wxUSE_MENUS 1
// Use wxSashWindow class.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_SASH 0
// Use wxSplitterWindow class.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_SPLITTER 0
// Use wxToolTip and wxWindow::Set/GetToolTip() methods.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_TOOLTIPS 0
// wxValidator class and related methods
#define wxUSE_VALIDATORS 0
// wxDC cacheing implementation
#define wxUSE_DC_CACHEING 0
// Set this to 1 to enable the use of DIB's for wxBitmap to support
// bitmaps > 16MB on Win95/98/Me. Set to 0 to use DDB's only.
#define wxUSE_DIB_FOR_BITMAP 0
// Set this to 1 to enable wxDIB
#define wxUSE_WXDIB 0
// ----------------------------------------------------------------------------
// common dialogs
// ----------------------------------------------------------------------------
// On rare occasions (e.g. using DJGPP) may want to omit common dialogs (e.g.
// file selector, printer dialog). Switching this off also switches off the
// printing architecture and interactive wxPrinterDC.
//
// Default is 1
//
// Recommended setting: 1 (unless it really doesn't work)
#define wxUSE_COMMON_DIALOGS 0
// wxBusyInfo displays window with message when app is busy. Works in same way
// as wxBusyCursor
#define wxUSE_BUSYINFO 0
// Use single/multiple choice dialogs.
//
// Default is 1
//
// Recommended setting: 1 (used in the library itself)
#define wxUSE_CHOICEDLG 0
// Use colour picker dialog
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_COLOURDLG 1
// wxDirDlg class for getting a directory name from user
#define wxUSE_DIRDLG 0
// TODO: setting to choose the generic or native one
// Use file open/save dialogs.
//
// Default is 1
//
// Recommended setting: 1 (used in many places in the library itself)
#define wxUSE_FILEDLG 0
// Use find/replace dialogs.
//
// Default is 1
//
// Recommended setting: 1 (but may be safely set to 0)
#define wxUSE_FINDREPLDLG 0
// Use font picker dialog
//
// Default is 1
//
// Recommended setting: 1 (used in the library itself)
#define wxUSE_FONTDLG 0
// Use wxMessageDialog and wxMessageBox.
//
// Default is 1
//
// Recommended setting: 1 (used in the library itself)
#define wxUSE_MSGDLG 1
// progress dialog class for lengthy operations
#define wxUSE_PROGRESSDLG 1
// support for startup tips (wxShowTip &c)
#define wxUSE_STARTUP_TIPS 0
// text entry dialog and wxGetTextFromUser function
#define wxUSE_TEXTDLG 0
// number entry dialog
#define wxUSE_NUMBERDLG 0
// splash screen class
#define wxUSE_SPLASH 0
// wizards
#define wxUSE_WIZARDDLG 0
// ----------------------------------------------------------------------------
// Metafiles support
// ----------------------------------------------------------------------------
// Windows supports the graphics format known as metafile which is, though not
// portable, is widely used under Windows and so is supported by wxWin (under
// Windows only, of course). Win16 (Win3.1) used the so-called "Window
// MetaFiles" or WMFs which were replaced with "Enhanced MetaFiles" or EMFs in
// Win32 (Win9x, NT, 2000). Both of these are supported in wxWin and, by
// default, WMFs will be used under Win16 and EMFs under Win32. This may be
// changed by setting wxUSE_WIN_METAFILES_ALWAYS to 1 and/or setting
// wxUSE_ENH_METAFILE to 0. You may also set wxUSE_METAFILE to 0 to not compile
// in any metafile related classes at all.
//
// Default is 1 for wxUSE_ENH_METAFILE and 0 for wxUSE_WIN_METAFILES_ALWAYS.
//
// Recommended setting: default or 0 for everything for portable programs.
#define wxUSE_METAFILE 0
#define wxUSE_ENH_METAFILE 0
#define wxUSE_WIN_METAFILES_ALWAYS 0
// ----------------------------------------------------------------------------
// Big GUI components
// ----------------------------------------------------------------------------
// Set to 0 to disable MDI support.
//
// Requires wxUSE_NOTEBOOK under platforms other than MSW.
//
// Default is 1.
//
// Recommended setting: 1, can be safely set to 0.
#define wxUSE_MDI 0
// Set to 0 to disable document/view architecture
#define wxUSE_DOC_VIEW_ARCHITECTURE 0
// Set to 0 to disable MDI document/view architecture
//
// Requires wxUSE_MDI && wxUSE_DOC_VIEW_ARCHITECTURE
#define wxUSE_MDI_ARCHITECTURE 0
// Set to 0 to disable print/preview architecture code
#define wxUSE_PRINTING_ARCHITECTURE 0
// wxHTML sublibrary allows to display HTML in wxWindow programs and much,
// much more.
//
// Default is 1.
//
// Recommended setting: 1 (wxHTML is great!), set to 0 if you want compile a
// smaller library.
#define wxUSE_HTML 0
// Setting wxUSE_GLCANVAS to 1 enables OpenGL support. You need to have OpenGL
// headers and libraries to be able to compile the library with wxUSE_GLCANVAS
// set to 1. Note that for some compilers (notably Microsoft Visual C++) you
// will need to manually add opengl32.lib and glu32.lib to the list of
// libraries linked with your program if you use OpenGL.
//
// Default is 0.
//
// Recommended setting: 1 if you intend to use OpenGL, 0 otherwise
#define wxUSE_GLCANVAS 0
// ----------------------------------------------------------------------------
// Data transfer
// ----------------------------------------------------------------------------
// Use wxClipboard class for clipboard copy/paste.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_CLIPBOARD 0
// Use wxDataObject and related classes. Needed for clipboard and OLE drag and
// drop
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_DATAOBJ 0
// Use wxDropTarget and wxDropSource classes for drag and drop (this is
// different from "built in" drag and drop in wxTreeCtrl which is always
// available). Requires wxUSE_DATAOBJ.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_DRAG_AND_DROP 0
// Use wxAccessible for enhanced and customisable accessibility.
// Depends on wxUSE_OLE.
//
// Default is 0.
//
// Recommended setting (at present): 0
#define wxUSE_ACCESSIBILITY 0
// ----------------------------------------------------------------------------
// miscellaneous settings
// ----------------------------------------------------------------------------
// wxSingleInstanceChecker class allows to verify at startup if another program
// instance is running (it is only available under Win32)
//
// Default is 1
//
// Recommended setting: 1 (the class is tiny, disabling it won't save much
// space)
#define wxUSE_SNGLINST_CHECKER 0
#define wxUSE_DRAGIMAGE 0
#define wxUSE_IPC 0
// 0 for no interprocess comms
#define wxUSE_HELP 0
// 0 for no help facility
#define wxUSE_MS_HTML_HELP 0
// 0 for no MS HTML Help
// Use wxHTML-based help controller?
#define wxUSE_WXHTML_HELP 0
#define wxUSE_RESOURCES 0
// 0 for no wxGetResource/wxWriteResource
#define wxUSE_CONSTRAINTS 0
// 0 for no window layout constraint system
#define wxUSE_SPLINES 0
// 0 for no splines
#define wxUSE_MOUSEWHEEL 0
// Include mouse wheel support
// ----------------------------------------------------------------------------
// postscript support settings
// ----------------------------------------------------------------------------
// Set to 1 for PostScript device context.
#define wxUSE_POSTSCRIPT 0
// Set to 1 to use font metric files in GetTextExtent
#define wxUSE_AFM_FOR_POSTSCRIPT 0
// ----------------------------------------------------------------------------
// database classes
// ----------------------------------------------------------------------------
// Define 1 to use ODBC classes
#define wxUSE_ODBC 0
// For backward compatibility reasons, this parameter now only controls the
// default scrolling method used by cursors. This default behavior can be
// overriden by setting the second param of wxDB::wxDbGetConnection() or
// wxDb() constructor to indicate whether the connection (and any wxDbTable()s
// that use the connection) should support forward only scrolling of cursors,
// or both forward and backward support for backward scrolling cursors is
// dependent on the data source as well as the ODBC driver being used.
#define wxODBC_FWD_ONLY_CURSORS 0
// Default is 0. Set to 1 to use the deprecated classes, enum types, function,
// member variables. With a setting of 1, full backward compatibility with the
// 2.0.x release is possible. It is STRONGLY recommended that this be set to 0,
// as future development will be done only on the non-deprecated
// functions/classes/member variables/etc.
#define wxODBC_BACKWARD_COMPATABILITY 0
// ----------------------------------------------------------------------------
// other compiler (mis)features
// ----------------------------------------------------------------------------
// Set this to 0 if your compiler can't cope with omission of prototype
// parameters.
//
// Default is 1.
//
// Recommended setting: 1 (should never need to set this to 0)
#define REMOVE_UNUSED_ARG 1
// VC++ 4.2 and above allows <iostream> and <iostream.h> but you can't mix
// them. Set to 1 for <iostream.h>, 0 for <iostream>. Note that VC++ 7.1
// and later doesn't support wxUSE_IOSTREAMH == 1 and so <iostream> will be
// used anyhow.
//
// Default is 1.
//
// Recommended setting: whatever your compiler likes more
#define wxUSE_IOSTREAMH 1
// ----------------------------------------------------------------------------
// image format support
// ----------------------------------------------------------------------------
// wxImage supports many different image formats which can be configured at
// compile-time. BMP is always supported, others are optional and can be safely
// disabled if you don't plan to use images in such format sometimes saving
// substantial amount of code in the final library.
//
// Some formats require an extra library which is included in wxWin sources
// which is mentioned if it is the case.
// Set to 1 for wxImage support (recommended).
#define wxUSE_IMAGE 0
// Set to 1 for PNG format support (requires libpng). Also requires wxUSE_ZLIB.
#define wxUSE_LIBPNG 0
// Set to 1 for JPEG format support (requires libjpeg)
#define wxUSE_LIBJPEG 0
// Set to 1 for TIFF format support (requires libtiff)
#define wxUSE_LIBTIFF 0
// Set to 1 for GIF format support
#define wxUSE_GIF 0
// Set to 1 for PNM format support
#define wxUSE_PNM 0
// Set to 1 for PCX format support
#define wxUSE_PCX 0
// Set to 1 for IFF format support (Amiga format)
#define wxUSE_IFF 0
// Set to 1 for XPM format support
#define wxUSE_XPM 0
// Set to 1 for MS Icons and Cursors format support
#define wxUSE_ICO_CUR 0
// Set to 1 to compile in wxPalette class
#define wxUSE_PALETTE 0
// ----------------------------------------------------------------------------
// Windows-only settings
// ----------------------------------------------------------------------------
// Set this to 1 if you want to use wxWidgets and MFC in the same program. This
// will override some other settings (see below)
//
// Default is 0.
//
// Recommended setting: 0 unless you really have to use MFC
#define wxUSE_MFC 0
// Set this to 1 for generic OLE support: this is required for drag-and-drop,
// clipboard, OLE Automation. Only set it to 0 if your compiler is very old and
// can't compile/doesn't have the OLE headers.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_OLE 0
// Set to 0 to disable PostScript print/preview architecture code under Windows
// (just use Windows printing).
#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 0
// Define as 1 to use Microsoft's ItsyBitsy small title bar library, for
// wxMiniFrame. This setting is only used for Win3.1; Win9x and NT use native
// miniframes support instead.
//
// Default is 0 for (most) Win32 (systems), 1 for Win16
//
#define wxUSE_ITSY_BITSY 0
// Set this to 1 to use RICHEDIT controls for wxTextCtrl with style wxTE_RICH
// which allows to put more than ~32Kb of text in it even under Win9x (NT
// doesn't have such limitation).
//
// Default is 1 for compilers which support it
//
// Recommended setting: 1, only set it to 0 if your compiler doesn't have
// or can't compile <richedit.h>
#if defined(__WIN95__) && !defined(__WINE__) && !defined(__GNUWIN32_OLD__)
#define wxUSE_RICHEDIT 0
// TODO: This should be ifdef'ed for any compilers that don't support
// RichEdit 2.0 but do have RichEdit 1.0...
#define wxUSE_RICHEDIT2 0
#else
#define wxUSE_RICHEDIT 0
#define wxUSE_RICHEDIT2 0
#endif
// Set this to 1 to enable support for the owner-drawn menu and listboxes. This
// is required by wxUSE_CHECKLISTBOX.
//
// Default is 1.
//
// Recommended setting: 1, set to 0 for a small library size reduction
#define wxUSE_OWNER_DRAWN 0
// Set to 1 to compile MS Windows XP theme engine support
#define wxUSE_UXTHEME 0
// Set to 1 to auto-adapt to MS Windows XP themes where possible
// (notably, wxNotebook pages)
#define wxUSE_UXTHEME_AUTO 0
// ----------------------------------------------------------------------------
// obsolete settings
// ----------------------------------------------------------------------------
// NB: all settings in this section are obsolete and should not be used/changed
// at all, they will disappear
// Set to 1 to use PenWindows
#define wxUSE_PENWINDOWS 0
// Define 1 to use bitmap messages.
#define wxUSE_BITMAP_MESSAGE 0
// If 1, enables provision of run-time type information.
// NOW MANDATORY: don't change.
#define wxUSE_DYNAMIC_CLASSES 1
#endif
// _WX_SETUP_H_
| [
"viticm@126.com"
] | viticm@126.com |
d386007f8c4293728f3c086259ca24916bbca8ae | 420b6c11cf4927809ace20cb456cc8a014359690 | /Makefile_tutorial/multi/src_main/main.cpp | f5dc35edff5030549cebe3937da862ac748412ec | [] | no_license | Austin-Marks/Cpsc256 | c7c40121c8e32fede0e60a65e0ffcb8cb19b8440 | 361d58d5e7ddb851762515d87f5e3f24cfb1477b | refs/heads/main | 2023-09-03T13:07:17.733691 | 2021-11-03T03:20:10 | 2021-11-03T03:20:10 | 399,544,011 | 0 | 0 | null | 2021-09-08T12:06:10 | 2021-08-24T17:03:45 | Shell | UTF-8 | C++ | false | false | 175 | cpp | #include <iostream>
#include "functions.h"
using namespace std;
int main(){
print_hello();
cout << "The factorial of 5 is " << factorial(5) << endl;
return 0;
}
| [
"brash@jlab.org"
] | brash@jlab.org |
d22c19aaacfcb7028892d6d924edb5fd6db14b9f | d9975b97e09ae5f5225c04fac385746d44a6a374 | /pylucene-4.9.0-0/build/_lucene/org/apache/lucene/search/ConstantScoreAutoRewrite.h | 26e6bb2e80102c585e783fe9dff65fe97f1fe28a | [
"Apache-2.0"
] | permissive | Narabzad/elr_files | 20038214ef0c4f459b0dccba5df0f481183fd83a | 3e623c7d9c98a7d6e5b26e6e4a73f46ff5352614 | refs/heads/master | 2020-06-04T02:01:17.028827 | 2019-06-28T21:55:30 | 2019-06-28T21:55:30 | 191,825,485 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,207 | h | #ifndef org_apache_lucene_search_ConstantScoreAutoRewrite_H
#define org_apache_lucene_search_ConstantScoreAutoRewrite_H
#include "org/apache/lucene/search/TermCollectingRewrite.h"
namespace org {
namespace apache {
namespace lucene {
namespace index {
class IndexReader;
}
namespace search {
class MultiTermQuery;
class BooleanQuery;
class Query;
}
}
}
}
namespace java {
namespace lang {
class Object;
class Class;
}
namespace io {
class IOException;
}
}
template<class T> class JArray;
namespace org {
namespace apache {
namespace lucene {
namespace search {
class ConstantScoreAutoRewrite : public ::org::apache::lucene::search::TermCollectingRewrite {
public:
enum {
mid_equals_290588e2,
mid_getDocCountPercent_54c6a174,
mid_getTermCountCutoff_54c6a179,
mid_hashCode_54c6a179,
mid_rewrite_925c5bbc,
mid_setDocCountPercent_5d1c7645,
mid_setTermCountCutoff_39c7bd3c,
mid_addClause_82a56efb,
mid_getTopLevelQuery_6f9339e7,
max_mid
};
static ::java::lang::Class *class$;
static jmethodID *mids$;
static bool live$;
static jclass initializeClass(bool);
explicit ConstantScoreAutoRewrite(jobject obj) : ::org::apache::lucene::search::TermCollectingRewrite(obj) {
if (obj != NULL)
env->getClass(initializeClass);
}
ConstantScoreAutoRewrite(const ConstantScoreAutoRewrite& obj) : ::org::apache::lucene::search::TermCollectingRewrite(obj) {}
static jdouble DEFAULT_DOC_COUNT_PERCENT;
static jint DEFAULT_TERM_COUNT_CUTOFF;
jboolean equals(const ::java::lang::Object &) const;
jdouble getDocCountPercent() const;
jint getTermCountCutoff() const;
jint hashCode() const;
::org::apache::lucene::search::Query rewrite(const ::org::apache::lucene::index::IndexReader &, const ::org::apache::lucene::search::MultiTermQuery &) const;
void setDocCountPercent(jdouble) const;
void setTermCountCutoff(jint) const;
};
}
}
}
}
#include <Python.h>
namespace org {
namespace apache {
namespace lucene {
namespace search {
extern PyTypeObject PY_TYPE(ConstantScoreAutoRewrite);
class t_ConstantScoreAutoRewrite {
public:
PyObject_HEAD
ConstantScoreAutoRewrite object;
PyTypeObject *parameters[1];
static PyTypeObject **parameters_(t_ConstantScoreAutoRewrite *self)
{
return (PyTypeObject **) &(self->parameters);
}
static PyObject *wrap_Object(const ConstantScoreAutoRewrite&);
static PyObject *wrap_jobject(const jobject&);
static PyObject *wrap_Object(const ConstantScoreAutoRewrite&, PyTypeObject *);
static PyObject *wrap_jobject(const jobject&, PyTypeObject *);
static void install(PyObject *module);
static void initialize(PyObject *module);
};
}
}
}
}
#endif
| [
"43349991+Narabzad@users.noreply.github.com"
] | 43349991+Narabzad@users.noreply.github.com |
6b0b8ba45da9c7418b5a626c4e81e57a630a234e | 51121984f98e7a79f9b9cd844ebe0314fd0845f2 | /Voxilian/Src/Engine/Core/Core0/Tier1/Physics/Physics.cpp | 198af4b5ddd91f3cb248ea298895134c81418a2e | [] | no_license | Skareeg/voxilian | 584b7463ceeb1cd78cd39371b008a889126ddcb0 | bc24fa80c914855dbef96cc9cd82e5fc9edb0ac9 | refs/heads/master | 2020-04-14T16:53:32.521942 | 2014-04-02T02:05:06 | 2014-04-02T02:05:06 | 32,126,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 476 | cpp | #include "Physics.h"
CPhysics::CPhysics()
{
collisionconfiguration = nullptr;
dispatcher = nullptr;
overlappingpaircache = nullptr;
solver = nullptr;
}
void CPhysics::Init()
{
collisionconfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionconfiguration);
overlappingpaircache = new btDbvtBroadphase();
solver = new btSequentialImpulseConstraintSolver;
}
void CPhysics::Update()
{
}
CPhysics Physics; | [
"Killamanjara@gmail.com@825dd620-273b-aec8-ac3f-b42787872301"
] | Killamanjara@gmail.com@825dd620-273b-aec8-ac3f-b42787872301 |
f2de38d71ff08afe56e5673eaff0fa8cb265a17e | eceabcc60d357bfe54d7e47a242f28612449df71 | /MediaPlayer/AudioMediaPlayer/include/AudioMediaPlayer/FFmpegAttachmentInputController.h | f36b48905049357ee144f89d7ac1f600c3ac5815 | [] | no_license | sevencheng798/SoundAi | e6ce8b71b9c79dbdce8c01d643abc03b67e14732 | 81b52d8a5b17f06b9c52fc7656d0dbd2f78b1b01 | refs/heads/master | 2020-12-14T08:39:05.407042 | 2019-12-06T02:26:14 | 2019-12-06T02:26:14 | 234,688,125 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,505 | h | /*
* Copyright 2019 its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#ifndef __FFMPEG_ATTACHMENT_INPUTCONTROLLER_H_
#define __FFMPEG_ATTACHMENT_INPUTCONTROLLER_H_
#include <memory>
#include <Utils/Attachment/AttachmentReader.h>
#include <Utils/AudioFormat.h>
#include "FFmpegInputControllerInterface.h"
struct AVIOContext;
struct AVInputFormat;
struct AVDictionary;
namespace aisdk {
namespace mediaPlayer {
namespace ffmpeg {
/**
* This class provides the FFmpegDecoder input access to the content of an attachment reader.
*
* This class only support one media input and it cannot provide multiple tracks / repeat.
*/
class FFmpegAttachmentInputController : public FFmpegInputControllerInterface {
public:
/**
* Creates an input reader object.
*
* @param reader A pointer to the attachment reader.
* @param format The audio format to be used to interpret raw audio data. This can be @c nullptr.
* @return A pointer to the @c FFmpegAttachmentInputController if succeed; @c nullptr otherwise.
*/
static std::unique_ptr<FFmpegAttachmentInputController> create(
std::shared_ptr<utils::attachment::AttachmentReader> reader,
const utils::AudioFormat* format = nullptr);
/// @name FFmpegInputControllerInterface methods
/// @{
bool hasNext() const override;
bool next() override;
AVFormatContext* createNewFormatContext() override;
std::tuple<Result, std::shared_ptr<AVFormatContext>, std::chrono::milliseconds> getCurrentFormatContextOpen() override;
/// @}
/**
* Destructor.
*/
~FFmpegAttachmentInputController();
private:
/**
* Constructor. The @c inputFormat and @c inputOptions are used for raw input.
*
* @param reader A pointer to the attachment reader.
* @param inputFormat Optional parameter that can be used to force an input format.
* @param inputOptions Optional parameter that can be used to force an set codec options.
*/
FFmpegAttachmentInputController(
std::shared_ptr<utils::attachment::AttachmentReader> reader,
std::shared_ptr<AVInputFormat> inputFormat = nullptr,
std::shared_ptr<AVDictionary> inputOptions = nullptr);
/**
* Function used to provide input data to the decoder.
*
* @param buffer Buffer to copy the data to.
* @param bufferSize The buffer size in bytes.
* @return The size read if the @c read call succeeded or the AVError code.
*/
int read(uint8_t* buffer, int bufferSize);
/**
* Feed AvioBuffer with some data from the input controller.
*
* @param userData A pointer to the input controller instance used to read the encoded input.
* @param buffer Buffer to copy the data to.
* @param bufferSize The buffer size in bytes.
* @return The size read if the @c read call succeeded or the AVError code.
*/
static int feedBuffer(void* userData, uint8_t* buffer, int bufferSize);
/// Wait tryagain count.
/// pretry again duration is READ_TIMEOUT. so toal wait timeout is m_tryCount*tryagain.
int m_tryCount;
/**
* This flag indicates that at least one frame of vaild data has been detected.
* It will allow the task following the @c'avformat_open_input'function to
* continue executing, otherwise it will end the following task.
*/
bool m_hasProbedVaildData;
/// Pointer to the data input.
std::shared_ptr<utils::attachment::AttachmentReader> m_reader;
/// Optional input format that can be used to force a format. If nullptr, use ffmpeg auto detect.
std::shared_ptr<AVInputFormat> m_inputFormat;
/// Optional input format options that can be used to force some format parameters.
std::shared_ptr<AVDictionary> m_inputOptions;
/// Keep a pointer to the avioContext to avoid memory leaks.
std::shared_ptr<AVIOContext> m_ioContext;
/// The current format context original point @c AVFormatContext.
AVFormatContext* m_avFormatContext;
};
} // namespace ffmpeg
} // namespace mediaPlayer
} // namespace aisdk
#endif // __FFMPEG_ATTACHMENT_INPUTCONTROLLER_H_ | [
"djzheng@wisepool.com.cn"
] | djzheng@wisepool.com.cn |
e340c8b0a1d7438a62f243832b0fdbb8be7f64b2 | 4d2c5283bef40e54d023bae647a29c86c86336cb | /src/ral/raldsp/raldsp_mixer.hxx | 727283e8878c99e4df47fed784ef86e0a2bcc27b | [] | no_license | usrlocalben/cxl | ccd600d516c2fd59dc788a8e47f75f0ce02abbb3 | 3254f1a0098714fdeca2d68fc8bce9947187dca5 | refs/heads/master | 2020-04-23T05:51:26.318169 | 2020-01-17T15:11:44 | 2020-01-17T15:11:44 | 170,953,991 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,730 | hxx | #pragma once
#include <array>
#include <algorithm>
#include <stdexcept>
#include <vector>
#include "src/ral/raldsp/raldsp_distortion.hxx"
#include "src/ral/raldsp/raldsp_iaudiodevice.hxx"
#include "3rdparty/freeverb/freeverb.hxx"
namespace rqdq {
namespace raldsp {
template <typename CHANNEL_STRIP>
class BasicMixer : public IAudioDevice {
// IAudioDevice
public:
void Update(int tempo) override {
d_reverb.setroomsize(0.5);
d_reverb.setdamp(0.5);
d_reverb.setwidth(0.5); }
void Process(float* inputs, float* outputs) override {
std::array<float, 6> sums{};
for (int i=0; i<d_channels.size(); i++) {
std::array<float, 6> channelOut;
d_channels[i].Process(&(inputs[i]), channelOut.data());
for (int oi=0; oi<6; oi++) {
sums[oi] += channelOut[oi]; }}
// std::array<float, 2> fxOut;
// d_delay.Process(&sums[2], fxOut.data());
// sums[0] += fxOut[0];
// sums[1] += fxOut[1];
std::array<float, 2> tmp{};
d_reverb.processmix(&sums[4], &sums[5], &tmp[0], &tmp[1], 1, 0);
sums[0] += tmp[0];
sums[1] += tmp[1];
outputs[0] = sums[0];
outputs[1] = sums[1]; }
public:
void AddChannel() {
d_channels.emplace_back(); }
int GetNumChannels() const { return static_cast<int>(d_channels.size()); }
CHANNEL_STRIP& operator[](int ch) {
EnsureValidChannelId(ch);
return d_channels[ch]; }
const CHANNEL_STRIP& operator[](int ch) const {
EnsureValidChannelId(ch);
return d_channels[ch]; }
private:
void EnsureValidChannelId(int ch) const {
if (!(0<=ch && ch<GetNumChannels())) {
throw new std::runtime_error("invalid channel id"); }}
public:
std::vector<CHANNEL_STRIP> d_channels;
Freeverb d_reverb{}; };
} // close package namespace
} // close enterprise namespace
| [
"benjamin@rqdq.com"
] | benjamin@rqdq.com |
8e99d9b56751600bcc4fe7905f0752b9fe263130 | 90b749fca73df90a6b405c76d5cb5b8d04e73754 | /TTMedia/target/TTFFWriter.cpp | 78939a6257bc4cd5d4c51a1d64d653bfbce502e8 | [
"Apache-2.0"
] | permissive | betallcoffee/TTPlayer | ed7ea42808cf502c4dfbe898854ada9e336afbd8 | a83bdac3870326d97cb123ed7bad33dcd7f30713 | refs/heads/master | 2021-01-10T14:08:45.715416 | 2018-03-24T03:40:24 | 2018-03-24T03:40:24 | 45,773,320 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,058 | cpp | //
// TTFFWriter.cpp
// TTPlayerExample
//
// Created by liang on 10/3/18.
// Copyright © 2018年 tina. All rights reserved.
//
#include "easylogging++.h"
#include "TTFFWriter.hpp"
using namespace TT;
FFWriter::FFWriter() {
}
FFWriter::~FFWriter() {
}
bool FFWriter::start(std::shared_ptr<URL> url, AVCodecParameters *audioCodecParam, AVCodecParameters *videoCodecParam) {
_url = url;
_muxer = std::make_shared<FFMuxer>();
if (!_muxer->open(_url, audioCodecParam, videoCodecParam)) {
LOG(ERROR) << "Edit muxer open failed:" << _url;
_muxer->close();
_muxer = nullptr;
return false;
}
return true;
}
bool FFWriter::finish() {
if (_muxer) {
_muxer->close();
}
return true;
}
bool FFWriter::cancel() {
return finish();
}
void FFWriter::processPacket(std::shared_ptr<Packet> packet) {
if (_muxer) {
_muxer->write(packet);
}
}
void FFWriter::processFrame(std::shared_ptr<Frame> frame) {
}
void FFWriter::process(int64_t timestamp) {
}
| [
"liangliang0918@126.com"
] | liangliang0918@126.com |
276aea6c0ea246562d7d2a244de26aec2b6e4328 | de4ba05ade2ef91ef8e401df73194abee3c657d9 | /imam9ais/spoj/HUBULLU/HUBULLU-13197501.cpp | 5e9c936080c2fd0b711993bab89fe4d07827d209 | [] | no_license | IMAM9AIS/SPOJ_SOLUTIONS | bed576afb2b7cc0518162574f15bc2026ce75aa1 | d43481399696a8a7e4a52060a43b8d08f2272e41 | refs/heads/master | 2021-01-01T16:25:07.801813 | 2015-07-04T00:26:58 | 2015-07-04T00:26:58 | 38,515,348 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 221 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,k;
cin>>n>>k;
if(!k)
cout<<"Airborne wins."<<"\n";
else
cout<<"Pagfloyd wins."<<"\n";
}
return 0;
}
| [
"imamkhursheed@gmail.com"
] | imamkhursheed@gmail.com |
887fa0ff08b602347f6184acf6dd951cf4acd7b6 | e5292428482181499e59886ad2ee50c83a504f6e | /codeforces/MarcoandGCDSequence.cpp | e60b3dde13b11b90c70307798e2a52604dd58c5d | [] | no_license | pedrohenriqueos/maratona | fa01ebfe747d647cf4f88c486e1a798b3bcdbb3d | 5c9bffa2ec6a321a35c854d4800b4fe7931c1baf | refs/heads/master | 2020-03-22T06:35:23.879463 | 2020-02-27T20:15:53 | 2020-02-27T20:15:53 | 139,644,788 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 463 | cpp | #include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
return ((b==0)?a:gcd(b,a%b));
}
int main(){
int N;
cin >> N;
set<int> S;
int A[N];
for(int i=0;i<N;i++){
cin >> A[i];
if(i!=0){
int g=A[0];
for(int j=0;j<i;j++){
g=gcd(A[j+1],g);
}
if(g!=1)
S.insert(A[i]);
else
}
}
if(S.size()==0)
cout << "-1\n";
else
cout << S.size() << '\n';
for(set<int>::iterator it=S.begin();it!=S.end();it++)
cout << *it << " ";
}
| [
"pedro986@gmail.com"
] | pedro986@gmail.com |
8f7caefb502d1e656b0ae33b3c2c9a57417c5ba7 | 95a47b8ac4af508c4daa57ce2a1516e9bf632402 | /src/MEPlotting/Measure/MeasureAzimuth.h | e7979139ae3c25a3054e715c12b590dd949902bf | [] | no_license | RigelStudio/Rigel3D | 8a4ea2e1c9fe2576b02c08810822f7dd0f3398d2 | 5789e828328866b90386c4fc41f5b5adffae9dd8 | refs/heads/master | 2023-06-25T22:34:37.923398 | 2023-06-21T02:37:31 | 2023-06-21T02:37:31 | 90,935,801 | 13 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 394 | h | #include <MeasureTool/MeasureBase.h>
#include <Geometry/GeometryLine.h>
class MeasureAzimuth : public MeasureBase
{
public:
MeasureAzimuth(void);
~MeasureAzimuth(void);
void clickEvent(osg::Vec3 pos);
void moveEvent(osg::Vec3 pos);
float calcResult();
void endMeasure();
private:
void init();
private:
osg::ref_ptr<PlaceNode> m_pNText;
osg::ref_ptr<GeometryLine> m_pMainLine;
};
| [
"ya feng"
] | ya feng |
4949e7b524c768ea1940dc10d21911492ae38df1 | 1554f8f6b5252debb68b8c49099091e552a835e8 | /AnEngine/RenderCore.cpp | f5198102f5e108dbb8a83250f7d5de3c299ee95f | [
"MIT"
] | permissive | jcyongqin/AnEngine | dad6f9dcc520f9695b008ad118593c5175ae7fd2 | 19e2463705248d72fb64262f56690419d5a9cb3c | refs/heads/master | 2020-03-09T00:56:50.101570 | 2020-01-26T14:28:35 | 2020-01-26T14:28:35 | 128,500,996 | 0 | 0 | MIT | 2020-01-26T14:30:28 | 2018-04-07T05:56:57 | C++ | UTF-8 | C++ | false | false | 15,439 | cpp | #include "RenderCore.h"
#include "Screen.h"
#include "CommandContext.h"
#include "DescriptorHeap.hpp"
#include "Fence.h"
#include "ThreadPool.hpp"
#include "DTimer.h"
#include "DebugLog.h"
#include <dxgidebug.h>
#include "FenceContext.h"
// 检验是否有HDR输出功能
#define CONDITIONALLY_ENABLE_HDR_OUTPUT 1
using namespace std;
using namespace Microsoft::WRL;
using namespace AnEngine::RenderCore::Resource;
using namespace AnEngine::RenderCore::Heap;
using namespace AnEngine::RenderCore::UI;
using namespace AnEngine::Debug;
namespace AnEngine::RenderCore
{
ComPtr<IDXGIFactory4> r_dxgiFactory_cp;
vector<unique_ptr<GraphicsCard>> r_graphicsCard;
unique_ptr<UI::GraphicsCard2D> r_graphicsCard2D;
ComPtr<IDXGISwapChain3> r_swapChain_cp = nullptr;
Resource::ColorBuffer* r_displayPlane[r_SwapChainBufferCount_const];
bool r_enableHDROutput = false;
uint32_t r_frameIndex;
uint64_t r_frameCount;
//Fence* r_fenceForDisplayPlane;
//ComPtr<ID3D12Fence> r_fence;
//uint64_t r_fenceValueForDisplayPlane[r_SwapChainBufferCount_const];
//HANDLE r_fenceEvent;
// D2D
#ifdef _WIN32
HWND r_hwnd;
#endif // _WIN32
//bool rrrr_runningFlag;
function<void(void)> R_GetGpuError = [=]()
{
var hr = r_graphicsCard[0]->GetDevice()->GetDeviceRemovedReason();
};
namespace CommonState
{
D3D12_RESOURCE_BARRIER commonToRenderTarget;
D3D12_RESOURCE_BARRIER renderTargetToCommon;
D3D12_RESOURCE_BARRIER commonToResolveDest;
D3D12_RESOURCE_BARRIER resolveDestToCommon;
D3D12_RESOURCE_BARRIER renderTargetToResolveDest;
D3D12_RESOURCE_BARRIER resolveSourceToRenderTarget;
D3D12_RESOURCE_BARRIER presentToRenderTarget;
D3D12_RESOURCE_BARRIER renderTargetToPresent;
D3D12_RESOURCE_BARRIER renderTarget2ResolveSource;
D3D12_RESOURCE_BARRIER commonToResolveSource;
D3D12_RESOURCE_BARRIER resolveSourceToCommon;
D3D12_RESOURCE_BARRIER depthWrite2PsResource;
D3D12_RESOURCE_BARRIER psResource2DepthWrite;
}
void InitializeSwapChain(int width, int height, HWND hwnd, DXGI_FORMAT dxgiFormat = r_DefaultSwapChainFormat_const);
void WaitForGpu();
void CreateCommonState();
void InitializeRender(HWND hwnd, int graphicCardCount, bool isStable)
{
r_hwnd = hwnd;
uint32_t dxgiFactoryFlags = 0;
// 开启Debug模式
bool debugDxgi = false;
#if defined(DEBUG) || defined(_DEBUG)
ComPtr<ID3D12Debug> d3dDebugController;
if (D3D12GetDebugInterface(IID_PPV_ARGS(&d3dDebugController)))
{
d3dDebugController->EnableDebugLayer();
dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG;
}
/*ComPtr<IDXGIInfoQueue> dxgiInfoQueue;
if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&dxgiInfoQueue))))
{
debugDxgi = true;
ThrowIfFailed(CreateDXGIFactory2(DXGI_CREATE_FACTORY_DEBUG, IID_PPV_ARGS(&r_dxgiFactory_cp)));
dxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, true);
dxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, true);
}*/
#endif
if (!debugDxgi)
{
ThrowIfFailed(CreateDXGIFactory1(IID_PPV_ARGS(r_dxgiFactory_cp.GetAddressOf())), R_GetGpuError);
}
while (graphicCardCount--)
{
GraphicsCard* aRender = new GraphicsCard();
aRender->IsStable(isStable);
aRender->Initialize(r_dxgiFactory_cp.Get(), true);
r_graphicsCard.emplace_back(aRender);
}
r_graphicsCard2D.reset(new UI::GraphicsCard2D());
r_graphicsCard2D->Initialize();
DescriptorHeapAllocator::GetInstance();
InitializeSwapChain(Screen::GetInstance()->Width(), Screen::GetInstance()->Height(), r_hwnd);
CreateCommonState();
r_frameCount = 0;
}
void InitializeSwapChain(int width, int height, HWND hwnd, DXGI_FORMAT dxgiFormat)
{
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
swapChainDesc.BufferCount = r_SwapChainBufferCount_const;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
swapChainDesc.Width = width;
swapChainDesc.Height = height;
swapChainDesc.Format = dxgiFormat;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Scaling = DXGI_SCALING_NONE;
ComPtr<IDXGISwapChain1> swapChain1;
//Private::r_dxgiFactory_cp->Create
ThrowIfFailed(r_dxgiFactory_cp->CreateSwapChainForHwnd(r_graphicsCard[0]->GetCommandQueue(), hwnd, &swapChainDesc,
nullptr, nullptr, swapChain1.GetAddressOf()));
#ifdef _WIN32
r_dxgiFactory_cp->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_WINDOW_CHANGES);
#endif // _WIN32
ThrowIfFailed(swapChain1.As(&r_swapChain_cp));
#if !CONDITIONALLY_ENABLE_HDR_OUTPUT && defined(NTDDI_WIN10_RS2) && (NTDDI_VERSION >= NTDDI_WIN10_RS2)
{
IDXGISwapChain4* p_swapChain = static_cast<IDXGISwapChain4*>(r_swapChain_cp.Get());
ComPtr<IDXGIOutput> cp_output;
ComPtr<IDXGIOutput6> cp_output6;
DXGI_OUTPUT_DESC1 outputDesc;
uint32_t colorSpaceSupport;
if (SUCCEEDED(p_swapChain->GetContainingOutput(&cp_output)) &&
SUCCEEDED(cp_output.As(&cp_output6)) &&
SUCCEEDED(cp_output6->GetDesc1(&outputDesc)) &&
outputDesc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 &&
SUCCEEDED(p_swapChain->CheckColorSpaceSupport(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020, &colorSpaceSupport)) &&
(colorSpaceSupport & DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT) &&
SUCCEEDED(p_swapChain->SetColorSpace1(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020)))
{
r_enableHDROutput = true;
}
}
#endif
for (uint32_t i = 0; i < r_SwapChainBufferCount_const; ++i)
{
ComPtr<ID3D12Resource> displayPlane;
ThrowIfFailed(r_swapChain_cp->GetBuffer(i, IID_PPV_ARGS(&displayPlane)));
r_displayPlane[i] = new ColorBuffer(L"Primary SwapChain Buffer", displayPlane.Detach(),
DescriptorHeapAllocator::GetInstance()->Allocate(D3D12_DESCRIPTOR_HEAP_TYPE_RTV));
// 2D平面
D3D11_RESOURCE_FLAGS d3d11Flags = { D3D11_BIND_RENDER_TARGET };
ThrowIfFailed(r_graphicsCard2D->GetDevice11On12()->CreateWrappedResource(r_displayPlane[i]->GetResource(),
&d3d11Flags, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT,
IID_PPV_ARGS(&r_graphicsCard2D->m_wrappedBackBuffers[i])));
ComPtr<IDXGISurface> surface;
ThrowIfFailed(r_graphicsCard2D->m_wrappedBackBuffers[i].As(&surface));
ThrowIfFailed(r_graphicsCard2D->m_d2dContext->CreateBitmapFromDxgiSurface(surface.Get(),
&r_graphicsCard2D->m_bitmapProperties, &r_graphicsCard2D->m_d2dRenderTarget[i]));
}
r_frameIndex = r_swapChain_cp->GetCurrentBackBufferIndex();
}
void CreateCommonState()
{
using namespace CommonState;
commonToRenderTarget.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
commonToRenderTarget.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commonToRenderTarget.Transition.pResource = nullptr;
commonToRenderTarget.Transition.Subresource = 0;
commonToRenderTarget.Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON;
commonToRenderTarget.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
renderTargetToCommon.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
renderTargetToCommon.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
renderTargetToCommon.Transition.pResource = nullptr;
renderTargetToCommon.Transition.Subresource = 0;
renderTargetToCommon.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
renderTargetToCommon.Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;
commonToResolveDest.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
commonToResolveDest.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commonToResolveDest.Transition.pResource = nullptr;
commonToResolveDest.Transition.Subresource = 0;
commonToResolveDest.Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON;
commonToResolveDest.Transition.StateAfter = D3D12_RESOURCE_STATE_RESOLVE_DEST;
resolveDestToCommon.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
resolveDestToCommon.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
resolveDestToCommon.Transition.pResource = nullptr;
resolveDestToCommon.Transition.Subresource = 0;
resolveDestToCommon.Transition.StateBefore = D3D12_RESOURCE_STATE_RESOLVE_DEST;
resolveDestToCommon.Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;
renderTargetToResolveDest.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
renderTargetToResolveDest.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
renderTargetToResolveDest.Transition.pResource = nullptr;
renderTargetToResolveDest.Transition.Subresource = 0;
renderTargetToResolveDest.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
renderTargetToResolveDest.Transition.StateAfter = D3D12_RESOURCE_STATE_RESOLVE_DEST;
resolveSourceToRenderTarget.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
resolveSourceToRenderTarget.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
resolveSourceToRenderTarget.Transition.pResource = nullptr;
resolveSourceToRenderTarget.Transition.Subresource = 0;
resolveSourceToRenderTarget.Transition.StateBefore = D3D12_RESOURCE_STATE_RESOLVE_SOURCE;
resolveSourceToRenderTarget.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
presentToRenderTarget.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
presentToRenderTarget.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
presentToRenderTarget.Transition.pResource = nullptr;
presentToRenderTarget.Transition.Subresource = 0;
presentToRenderTarget.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
presentToRenderTarget.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
renderTargetToPresent.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
renderTargetToPresent.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
renderTargetToPresent.Transition.pResource = nullptr;
renderTargetToPresent.Transition.Subresource = 0;
renderTargetToPresent.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
renderTargetToPresent.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
renderTarget2ResolveSource.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
renderTarget2ResolveSource.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
renderTarget2ResolveSource.Transition.pResource = nullptr;
renderTarget2ResolveSource.Transition.Subresource = 0;
renderTarget2ResolveSource.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
renderTarget2ResolveSource.Transition.StateAfter = D3D12_RESOURCE_STATE_RESOLVE_SOURCE;
commonToResolveSource.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
commonToResolveSource.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commonToResolveSource.Transition.pResource = nullptr;
commonToResolveSource.Transition.Subresource = 0;
commonToResolveSource.Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON;
commonToResolveSource.Transition.StateAfter = D3D12_RESOURCE_STATE_RESOLVE_SOURCE;
resolveSourceToCommon.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
resolveSourceToCommon.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
resolveSourceToCommon.Transition.pResource = nullptr;
resolveSourceToCommon.Transition.Subresource = 0;
resolveSourceToCommon.Transition.StateBefore = D3D12_RESOURCE_STATE_RESOLVE_SOURCE;
resolveSourceToCommon.Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;
depthWrite2PsResource.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
depthWrite2PsResource.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
depthWrite2PsResource.Transition.pResource = nullptr;
depthWrite2PsResource.Transition.Subresource = 0;
depthWrite2PsResource.Transition.StateBefore = D3D12_RESOURCE_STATE_DEPTH_WRITE;
depthWrite2PsResource.Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
psResource2DepthWrite.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
psResource2DepthWrite.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
psResource2DepthWrite.Transition.pResource = nullptr;
psResource2DepthWrite.Transition.Subresource = 0;
psResource2DepthWrite.Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
psResource2DepthWrite.Transition.StateAfter = D3D12_RESOURCE_STATE_DEPTH_WRITE;
}
void RenderColorBuffer(ColorBuffer* dstColorBuffer)
{
//var commandList = GraphicsCommandContext::GetInstance()->GetOne();
//var commandAllocator = GraphicsCommandAllocator::GetInstance()->GetOne();
var[commandList, commandAllocator] = GraphicsContext::GetOne();
var iCommandList = commandList->GetCommandList();
var iCommandAllocator = commandAllocator->GetAllocator();
ThrowIfFailed(iCommandAllocator->Reset());
ThrowIfFailed(iCommandList->Reset(iCommandAllocator, nullptr));
var commonToRenderTarget = CommonState::commonToRenderTarget;
var renderTargetToCommon = CommonState::renderTargetToResolveDest;
commonToRenderTarget.Transition.pResource = dstColorBuffer->GetResource();
renderTargetToCommon.Transition.pResource = dstColorBuffer->GetResource();
//iList->ResourceBarrier(1, &commonToRenderTarget);
//var clearColorTemp = dstColorBuffer->GetClearColor();
float clearColor[4] = { 0.0f, 0.0f, 0.2f, 1.0f };
iCommandList->ClearRenderTargetView(dstColorBuffer->GetRtv(), clearColor, 0, nullptr);
iCommandList->Close();
ID3D12CommandList* ppcommandList[] = { iCommandList };
r_graphicsCard[0]->GetCommandQueue()->ExecuteCommandLists(_countof(ppcommandList), ppcommandList);
GraphicsContext::Push(commandList, commandAllocator);
}
void BlendBuffer(GpuResource* srcBuffer)
{
uint32_t frameIndex = r_frameIndex;
var frame = r_displayPlane[frameIndex]->GetResource();
var[commandList, commandAllocator] = GraphicsContext::GetOne();
var iList = commandList->GetCommandList();
var iCommandAllocator = commandAllocator->GetAllocator();
ThrowIfFailed(iCommandAllocator->Reset());
ThrowIfFailed(iList->Reset(iCommandAllocator, nullptr));
var commonToResolveSrc = CommonState::commonToResolveSource;
var commonToResolveDst = CommonState::commonToResolveDest;
var resolveSrcToCommon = CommonState::resolveSourceToCommon;
var resolveDstToCommon = CommonState::resolveDestToCommon;
commonToResolveSrc.Transition.pResource = srcBuffer->GetResource();
commonToResolveDst.Transition.pResource = frame;
resolveSrcToCommon.Transition.pResource = srcBuffer->GetResource();
resolveDstToCommon.Transition.pResource = frame;
var barrier1 = { commonToResolveSrc, commonToResolveDst };
var barrier2 = { resolveSrcToCommon ,resolveDstToCommon };
iList->ResourceBarrier(barrier1.size(), barrier1.begin());
float color[4] = { 0, 0, 0, 1 };
iList->ClearRenderTargetView(r_displayPlane[frameIndex]->GetRtv(), color, 0, nullptr);
iList->ResolveSubresource(frame, 0, srcBuffer->GetResource(), 0, DXGI_FORMAT_R8G8B8A8_UNORM);
iList->ResourceBarrier(barrier2.size(), barrier2.begin());
ThrowIfFailed(iList->Close(), R_GetGpuError);
#ifdef _DEBUG
if (frameIndex != r_frameIndex)
{
throw exception();
}
#endif // _DEBUG
GraphicsContext::Push(commandList, commandAllocator);
}
void R_Present()
{
ThrowIfFailed(r_swapChain_cp->Present(0, 0), R_GetGpuError);
r_frameIndex = r_swapChain_cp->GetCurrentBackBufferIndex();
WaitForGpu();
}
void WaitForGpu()
{
var[fence] = FenceContext::Instance()->GetOne();
var iFence = fence->GetFence();
uint64_t fenceValue = fence->GetFenceValue();
fenceValue++;
r_graphicsCard[0]->GetCommandQueue()->Signal(iFence, fenceValue);
fence->WaitForValue(fenceValue);
}
}
namespace AnEngine::RenderCore
{
GraphicsDevice::GraphicsDevice()
{
}
} | [
"MyGuanDY@outlook.com"
] | MyGuanDY@outlook.com |
9922a8414ca2cc3b4df23fece1788b1a2f3b98d8 | 6ba90d4b7ca7d3b42e33ebe87f6037e0456cdccd | /src/player/player.cpp | dd530afca3729aaa13e71a6ad7bc246be9b27747 | [] | no_license | rohandas36/DGaMe | 9bc241e6a6df4adf3fa7d09c340b02a7e69f98e1 | 623d809abf27d4ecf55deeff6b1fdb5ac6e8e852 | refs/heads/master | 2021-01-16T08:55:13.885253 | 2015-04-26T17:42:35 | 2015-04-26T17:42:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,200 | cpp | #include "player.h"
#include <iostream>
//gameplay is the game_Maps object
player::player()
{}
player::player(int ID,int gr_id,Vector3 pos,int n_lives,int n_kills,int g)
{
id=ID;
group_id=gr_id;
position=pos;
lives=n_lives;
last_hit=0;
health=100;
fwd=0;
tang=0;
weaponry.push_back(Weapon_set[0]);
g_locate=g;
active=true;
current_weapon=0;
//set mass and radius
mass=player_mass;
radius=player_radius;
}
// player::player(player &obj)
// {
// name = *obj.name;
// id = *obj.id;
// group_id = *obj.group_id;
// g_locate = *obj.g_locate;
// fwd = *obj.fwd;
// tang = *obj.tang;
// mass = *obj.mass;
// radius = *obj.radius;
// active = *obj.active;
// health = *obj.health;
// weaponry = *obj.weaponry;
// position = *obj.position;
// velocity = *obj.velocity;
// lives = *obj.lives;
// last_hit = *obj.last_hit;
// current_weapon = *obj.current_weapon;
// }
//respawn
void player::player_reset()
{
if(lives==0)
{
(gameplay->All_Players[id]).active=false;
for(int i=0;i<gameplay->Maps[g_locate].Players.size();i++)
{
if(gameplay->Maps[g_locate].Players[i] == id)
{
gameplay->Maps[g_locate].Players.erase(gameplay->Maps[g_locate].Players.begin()+i);
break;
}
}
return;
}
lives-=1;
health=100;
last_hit=0;
weaponry.clear();
weaponry.push_back(Weapon_set[0]);
fwd=0;
tang=0;
}
//max_lives and health_increase are global variables
void player::get_health_pack(int id)
{
//life pack
if((id==1)&&(lives<max_lives))
lives++;
//health increase
if(id==2){
if(health<100-25)
health+=25;
else
health=100;
}
}
void player::recovery()
{
if(last_hit>recovery_time)
health=(health<(100-health_recovery*DELTA_T))?(health+health_recovery*DELTA_T):100;
}
void player::get_weapon(int ID)
{
//ID -> corresponding to Weapon_set
int present=-1;
//check if weapon is present in weaponry
for(int i=0;i<weaponry.size();i++)
{
if(ID==(weaponry[i]).ID)
{
present=i;
break;
}
}
if(present!=-1)
(weaponry[present]).upgrade_weapon();
else
weaponry.push_back(Weapon_set[ID]);
current_weapon++;
}
void player::toggle_weapon()
{
if(current_weapon==weaponry.size()-1)
current_weapon=0;
else
current_weapon++;
}
void player::fire_weapon(int i)
{
// cout<<"command issued"<< "true" <<endl;
weaponry[current_weapon].shot_fired();
// cout<< "shot fired" <<endl;
Vector3 d;
Vector3 normal = gameplay->Maps[g_locate].normal;
// cout<<"normal set"<<endl;
switch(i)
{
case 0:
d=velocity.setlen(1);
break;
case 1:
d=(velocity.cross(normal)).setlen(1);
break;
case 2:
d=(velocity.setlen(1)).neg();
break;
case 3:
d=((velocity.cross(normal)).setlen(1)).neg();
break;
}
// cout<<"direction set"<<endl;
// cout<<"weapon size"<< weaponry.size()<<endl;
// cout<<"current weapon"<<current_weapon<<endl;
bullet* b=new bullet(id,group_id,weaponry[current_weapon].ID,position,d,g_locate,gameplay->Maps[g_locate].normal);
// cout << "player weapon id " << weaponry[current_weapon].ID << endl;
// cout<<"timespan1" << Weapon_set[0].timespan<<endl;
// cout<<"timespan2" << Weapon_set[b->weapon_ID].timespan<<endl;
gameplay->Bullets.push_back(*b);
(gameplay->Maps[g_locate].Bullets).push_back(*b);
// cout<<"grid set"<<endl;
if(weaponry[current_weapon].no_shots())
{
weaponry.erase(weaponry.begin()+current_weapon);
current_weapon--;
}
}
int player::Player_CheckCollision() //-1 if no collision,0 if collision in grid itself,(1,2,3,4)-collision in neighbour cells
{
int index=-1;
if(gameplay->Maps[g_locate].Players.size()>1)
index=8;
else
{
for(int i=0;i<8;i++)
{
int neighbour = gameplay->Maps[g_locate].neigh[i];
if(gameplay->Maps[(neighbour)].Players.size()>0)
{
index=i;
break;
}
}
}
return index;
}
int player::Bot_CheckCollision() //-1 if no collision,0 if collision in grid itself,(1,2,3,4)-collision in neighbour cells
{
int index=-1;
if(gameplay->Maps[g_locate].Bots.size()>0)
index=8;
else
{
for(int i=0;i<8;i++)
{
int neighbour = gameplay->Maps[g_locate].neigh[i];
if(gameplay->Maps[neighbour].Bots.size()>0)
{
index=i;
break;
}
}
}
return index;
}
// int player::CheckHit() //-1 if no collision,0 if collision in grid itself,(1,2,3,4)-collision in neighbour cells
// {
// int index=-1;
// for(int i=0;i<gameplay->Maps[g_locate].Bullets.size();i++)
// {
// if(gameplay->Maps[g_locate].Bullets[i].player_ID!=id)
// return 8;
// }
// else
// {
// for(int i=0;i<8;i++)
// {
// int neighbour = gameplay->Maps[g_locate].neigh[i];
// for(int j=0;j<gameplay->Maps[g_locate].Bullets.size();j++)
// {
// if(gameplay->Maps[g_locate].Bullets[i].player_ID!=id)
// {
// }
// }
// }
// }
// return index;
// }
void player::Player_SolveCollision()
{
int i=Player_CheckCollision();
int j;
player* p = new player();
if(i!=-1)
{
if(i!=8)
{
int neighbour = gameplay->Maps[g_locate].neigh[i];
*p= gameplay->All_Players[((gameplay->Maps[neighbour]).Players[j])];
}
else{
j=(gameplay->Maps[g_locate].Players[0]==id)?1:0;
*p= gameplay->All_Players[((gameplay->Maps[g_locate]).Players[j])];
}
/*solving collision*/
Vector3 del_R=(p->position).add(position.neg()).setlen(1);
Vector3 v1=del_R.setlen(velocity.dot(del_R)),
v2=del_R.setlen((p->velocity).dot(del_R));
if((v1.add(v2.neg()).dot(del_R)>0)&&(p->position).add(position.neg()).mod()<radius+p->radius)
{
Vector3 v1_=velocity.add(v1.neg()),
v1__=v1.mult((mass-p->mass)/(mass+p->mass)).add(p->velocity.mult((2*p->mass)/(mass+p->mass)));
velocity=v1__.add(v1_);
}
health=(health-collateral_damage<0)?0:(health-collateral_damage);
}
last_hit=0;
if(health==0)
player_reset();
}
void player::Bot_SolveCollision()
{
int i=Bot_CheckCollision();
int j;
bots* p = new bots();
if(i!=-1)
{
if(i!=8)
{
int neighbour = gameplay->Maps[g_locate].neigh[i];
*p= gameplay->All_Bots[(gameplay->Maps[neighbour].Bots[j])];
}
else{
*p= gameplay->All_Bots[(gameplay->Maps[g_locate].Bots[j])];
}
/*solving collision*/
Vector3 del_R=(p->position).add(position.neg()).setlen(1);
Vector3 v1=del_R.setlen(velocity.dot(del_R)),
v2=del_R.setlen((p->velocity).dot(del_R));
if((v1.add(v2.neg()).dot(del_R)>0)&&((p->position).add(position.neg()).mod()<radius+p->radius))
{
Vector3 v1_=velocity.add(v1.neg()),
v1__=v1.mult((mass-p->mass)/(mass+p->mass)).add(p->velocity.mult((2*p->mass)/(mass+p->mass)));
velocity=v1__.add(v1_);
}
health=(health-collateral_damage<0)?0:(health-collateral_damage);
}
last_hit=0;
if(health==0)
player_reset();
}
void player::OnHit()
{
int grid_index=-1;
int bullet_index = -1;
for(int i=0;i<gameplay->Maps[g_locate].Bullets.size();i++)
{
if(gameplay->Maps[g_locate].Bullets[i].player_ID!=id)
{
grid_index = 8;
bullet_index=i;
break;
}
}
if(grid_index!=8)
{
for(int i=0;i<8;i++)
{
int neighbour = gameplay->Maps[g_locate].neigh[i];
for(int j=0;j<gameplay->Maps[neighbour].Bullets.size();j++)
{
if(gameplay->Maps[neighbour].Bullets[j].player_ID!=id)
{
bullet_index = j;
grid_index = i;
break;
}
}
}
}
bullet* b = new bullet();
int neighbour;
if(grid_index!=-1)
{
if(grid_index!=8){
neighbour = (gameplay->Maps[g_locate]).neigh[grid_index];
*b= gameplay->Maps[neighbour].Bullets[bullet_index];
}
else{
neighbour = g_locate;
*b= gameplay->Maps[g_locate].Bullets[bullet_index];
}
health=(health-b->damage<0)?0:(health-b->damage);
//remove bullet from grid and game Maps
gameplay->Maps[neighbour].Bullets.erase(gameplay->Maps[neighbour].Bullets.begin()+bullet_index);
for(int k=0;k<gameplay->Bullets.size();k++)
{
if(gameplay->Bullets[k].bullet_id == b->bullet_id)
{
gameplay->Bullets.erase(gameplay->Bullets.begin()+k);
break;
}
}
//set last_hit to zero
last_hit=0;
if(health==0)
player_reset();
}
}
Vector3 player::set_velocity(int up,int right,int move_up,int move_right,Vector3 v)
{
Vector3 final;
Vector3 normal = gameplay->Maps[g_locate].normal;
// cout << "normal " << normal.x << " " << normal.y << " " << normal.z << endl;
if(v.mod()==0)
{
Vector3 index= gameplay->Maps[g_locate].normal;
if((index.x == 0 && index.y==0) || (index.x==0 && index.z==0))
v.set(0.000001,0.0,0.0);
else
v.set(0.0,0.000001,0.0);
}
final=v;
Vector3 changeAlong(v.setlen(0.1));
Vector3 changePerp((v.cross(normal.neg())).setlen(0.05));
// cout << "changePerp " << changePerp.x << " " << changePerp.y << " " << changePerp.z << endl;
if(move_up==-1)
final = final.mult(0.8);
else if(move_up==1)
final = final.add(changeAlong);
if(move_right==-1)
final = final.add(changePerp);
else if(move_right==1)
final = final.sub(changePerp);
if (move_up==0 && move_right==0)
final = final.mult(0.95);
if(final.mod()>max_speed)
final = final.setlen(max_speed);
// if(move_up!=up)
// {
// Vector3 along=(v.setlen(1.0)).mult((move_up-up)*DELTA_T);
// final=final.add(along);
// }
// if(move_right!=right)
// {
// Vector3 ta=((v.cross(normal)).setlen(1)).mult((move_right-right)*DELTA_T);
// final=final.add(ta);
// }
// if((up==move_up) && (right==move_right))
// {
// if(final.mod()<max_speed)
// {
// float factor = move_up*(-DELTA_T);
// Vector3 ta= ((v.cross(normal)).setlen(1)).mult(factor);
// Vector3 along= (v.setlen(1)).mult(factor);
// final=final.add(ta.add(along));
// }
// else
// final=final.setlen(max_speed);
// }
// if(move_up==up)
// if(final.mod()<max_speed)
// {
// Vector3 along=(v.setlen(1.0)).mult((move_up-up)*DELTA_T);
// final=final.add(along);
// }
// if(move_right==right)
// {
// if(final.mod()<max_speed)
// {
// Vector3 ta=(v.setlen(1.0)).mult((move_right-right)*DELTA_T);
// final=final.add(ta);
// }
// }
return final;
}
void player::surface_constraint()
{
float distance= gameplay->Maps[g_locate].distance_from_surface(position);
position=position.add(((gameplay->Maps[g_locate]).normal).mult(-distance));
bool a = gameplay->Maps[g_locate].point_in_plane(position);
// cout<< "surface " << a <<endl;
}
int player::new_location(int move_up,int move_right)
{
if(move_up==0 && move_right==1)
return 0;
else if(move_up==1 && move_right==1)
return 1;
else if(move_up==1 && move_right==0)
return 2;
else if(move_up==1 && move_right==-1)
return 3;
else if(move_up==0 && move_right==-1)
return 4;
else if(move_up==-1 && move_right==-1)
return 5;
else if(move_up==-1 && move_right==0)
return 6;
else if(move_up==-1 && move_right==1)
return 7;
else if(move_up==0 && move_right==0)
return 8;
}
void player::update(vector<int> keys_pressed)
{
// key_tap k; //for looping over vector<key_taps>
int k;
int move_up=0; //up movement parameter given by key taps
int move_right=0; //right movement parameter given by key taps
bool changed=false; //if player position/grid has changed?
bool shoot=false;
//recording keys_pressed and taking corresponding action
for(int i=0;i<keys_pressed.size();i++)
{
k=keys_pressed[i];
switch(k){
case 0:
move_up+=1; //up and right are class variables
break;
case 1:
move_right+=1;
break;
case 2:
move_up-=1;
break;
case 3:
move_right-=1;
break;
case 4:
if(!shoot)
{
fire_weapon(0);
shoot=true;
break;
}
case 5:
if(!shoot)
{
fire_weapon(1);
shoot=true;
break;
}
case 6:
if(!shoot)
{
fire_weapon(2);
shoot=true;
break;
}
case 7:
if(!shoot)
{
fire_weapon(3);
shoot=true;
break;
}
case 8:
toggle_weapon();
break;
default:
break;
}
}
/*Collisions*/
// Player_SolveCollision();
// Bot_SolveCollision();
// OnHit();
/*setting movement parameters*/
velocity=set_velocity(fwd,tang,move_up,move_right,velocity);
// cout<< "velocity x " <<velocity.x << "velocity y "<< velocity.y << "velocity z "<< velocity.z<<endl;
position=position.add(velocity.mult(DELTA_T));
// cout<< "position x " <<position.x << "position y "<< position.y << "position z "<< position.z<<endl;
fwd=move_up;
tang=move_right;
// cout<< "fwd "<< fwd<<endl;
// cout<< "tang "<< tang<<endl;
/*updating weaponry and health parameters*/
last_hit+=1;
for(int i=0;i<weaponry.size();i++)
{
weaponry[i].last_shot+=1;
}
/*if(new_location(up,right)!=8)
{
for(int i=0;i<gameplay->Maps[g_locate].Players.size();i++)
{
if(id==gameplay->All_Players[(gameplay->Maps[g_locate].Players[i])].id)
{
gameplay->Maps[g_locate].Players.erase(gameplay->Maps[g_locate].Players.begin()+i);
break;
}
}
g_locate=neigh[new_location(up,right)];
surface_constraint();
changed=true;
}*/
/*updating grids*/
int index= gameplay->Maps[g_locate].find_grid(position);
if(index<8)
{
/*remove player from present grid*/
for(int i=0;i<gameplay->Maps[g_locate].Players.size();i++)
{
if(id==(gameplay->Maps[g_locate].Players[i]))
{
gameplay->Maps[g_locate].Players.erase(gameplay->Maps[g_locate].Players.begin()+i);
break;
}
}
changed=true;
// cout<<"changed "<<changed<<endl;
Vector3 oldNormal = gameplay->Maps[g_locate].normal;
g_locate=gameplay->Maps[g_locate].neigh[index];
// Vector3 align = gameplay->Maps[g_locate].normal;
// Vector3 align2 = gameplay->Maps[g_locate].normal;
// float rad = (align.dot(align2))/((align.mod())*align2.mod());
// velocity = velocity.rotate(align2.cross(align),rad);
Vector3 newNormal= gameplay->Maps[g_locate].normal;
if (!newNormal.equal(oldNormal)){
if(newNormal.x==0 && newNormal.y==0){
if(velocity.x==0){
velocity.x = velocity.z;
velocity.z = 0;
if(velocity.dot(oldNormal)>0)
velocity.x = -velocity.x;
}
else if(velocity.y==0){
velocity.y = velocity.z;
velocity.z = 0;
if(velocity.dot(oldNormal)>0)
velocity.y = -velocity.y;
}
}
else if(newNormal.y==0 && newNormal.z==0){
if(velocity.y==0){
velocity.y = velocity.x;
velocity.x = 0;
if(velocity.dot(oldNormal)>0)
velocity.y = -velocity.y;
}
else if(velocity.z==0){
velocity.z = velocity.x;
velocity.x = 0;
if(velocity.dot(oldNormal)>0)
velocity.z = -velocity.z;
}
}
else if(newNormal.z==0 && newNormal.x==0){
if(velocity.z==0){
velocity.z = velocity.y;
velocity.y = 0;
if(velocity.dot(oldNormal)>0)
velocity.z = -velocity.z;
}
else if(velocity.x==0){
velocity.x = velocity.y;
velocity.y = 0;
if(velocity.dot(oldNormal)>0)
velocity.x = -velocity.x;
}
}
}
//add player to new grid
gameplay->Maps[g_locate].Players.push_back(id);
surface_constraint();
}
else if (index==9){
cout << "9 Assmpn not true" << endl;
}
/*obtain weapon if available*/
if(gameplay->Maps[g_locate].Armoury.size()!=0)
{
for(int i=0;i<gameplay->Maps[g_locate].Armoury.size();i++)
get_weapon(gameplay->Maps[g_locate].Armoury[i]);
}
/*obtain boost if available*/
if(gameplay->Maps[g_locate].Boosts.size()!=0)
{
for(int i=0;i<gameplay->Maps[g_locate].Boosts.size();i++)
get_health_pack(gameplay->Maps[g_locate].Boosts[i]);
}
/*health recovery*/
recovery();
/*update weapons*/
for(int i=0;i<weaponry.size();i++)
{
weaponry[i].last_shot+=1;
}
}
player::~player(){
}
| [
"dhruvangmakadia1@gmail.com"
] | dhruvangmakadia1@gmail.com |
efdf5e8c201a49c64f00a239c6ab8e526247b33c | 43a2fbc77f5cea2487c05c7679a30e15db9a3a50 | /Cpp/External (Offsets Only)/SDK/BP_CustomisableLadder_PointToPoint_functions.cpp | b3fa3075c1f823bf4f2134febaab2cab867f840d | [] | no_license | zH4x/SoT-Insider-SDK | 57e2e05ede34ca1fd90fc5904cf7a79f0259085c | 6bff738a1b701c34656546e333b7e59c98c63ad7 | refs/heads/main | 2023-06-09T23:10:32.929216 | 2021-07-07T01:34:27 | 2021-07-07T01:34:27 | 383,638,719 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,458 | cpp | // Name: SoT-Insider, Version: 1.102.2382.0
#include "../pch.h"
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
// Function BP_CustomisableLadder_PointToPoint.BP_CustomisableLadder_PointToPoint_C.Orientate Ladder
// (Public, BlueprintCallable, BlueprintEvent)
// Parameters:
// struct FVector Point_A (Parm, ZeroConstructor, IsPlainOldData, NoDestructor)
// struct FVector Point_B (Parm, ZeroConstructor, IsPlainOldData, NoDestructor)
void ABP_CustomisableLadder_PointToPoint_C::Orientate_Ladder(const struct FVector& Point_A, const struct FVector& Point_B)
{
static auto fn = UObject::FindObject<UFunction>("Function BP_CustomisableLadder_PointToPoint.BP_CustomisableLadder_PointToPoint_C.Orientate Ladder");
ABP_CustomisableLadder_PointToPoint_C_Orientate_Ladder_Params params;
params.Point_A = Point_A;
params.Point_B = Point_B;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function BP_CustomisableLadder_PointToPoint.BP_CustomisableLadder_PointToPoint_C.UserConstructionScript
// (Event, Public, HasDefaults, BlueprintCallable, BlueprintEvent)
void ABP_CustomisableLadder_PointToPoint_C::UserConstructionScript()
{
static auto fn = UObject::FindObject<UFunction>("Function BP_CustomisableLadder_PointToPoint.BP_CustomisableLadder_PointToPoint_C.UserConstructionScript");
ABP_CustomisableLadder_PointToPoint_C_UserConstructionScript_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function BP_CustomisableLadder_PointToPoint.BP_CustomisableLadder_PointToPoint_C.ReceiveBeginPlay
// (Event, Public, BlueprintEvent)
void ABP_CustomisableLadder_PointToPoint_C::ReceiveBeginPlay()
{
static auto fn = UObject::FindObject<UFunction>("Function BP_CustomisableLadder_PointToPoint.BP_CustomisableLadder_PointToPoint_C.ReceiveBeginPlay");
ABP_CustomisableLadder_PointToPoint_C_ReceiveBeginPlay_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function BP_CustomisableLadder_PointToPoint.BP_CustomisableLadder_PointToPoint_C.ExecuteUbergraph_BP_CustomisableLadder_PointToPoint
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData, NoDestructor)
void ABP_CustomisableLadder_PointToPoint_C::ExecuteUbergraph_BP_CustomisableLadder_PointToPoint(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function BP_CustomisableLadder_PointToPoint.BP_CustomisableLadder_PointToPoint_C.ExecuteUbergraph_BP_CustomisableLadder_PointToPoint");
ABP_CustomisableLadder_PointToPoint_C_ExecuteUbergraph_BP_CustomisableLadder_PointToPoint_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
void ABP_CustomisableLadder_PointToPoint_C::AfterRead()
{
ABP_CustomisableLadder_C::AfterRead();
}
void ABP_CustomisableLadder_PointToPoint_C::BeforeDelete()
{
ABP_CustomisableLadder_C::BeforeDelete();
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"Massimo.linker@gmail.com"
] | Massimo.linker@gmail.com |
a54e5ce1c238426f32abcf877cd174f665906bdd | 339fe744c05cfefa16f7d7a23a8b64c18f401282 | /producer.h | 186b4b6055b50877a3064763cf0d8032939a77de | [] | no_license | zllamy/Thread | 0427604c24e55a1752f35371a959b5510026eb88 | 0e4c155efb876826b42620e0bd0017126b3f6c99 | refs/heads/master | 2021-01-23T16:53:17.983665 | 2017-06-04T11:24:24 | 2017-06-04T11:24:24 | 93,308,800 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 177 | h | #ifndef PRODUCER_H
#define PRODUCER_H
#include <QObject>
#include <QThread>
class Producer : public QThread
{
public:
Producer();
void run();
};
#endif // PRODUCER_H
| [
"471888365@qq.com"
] | 471888365@qq.com |
0b4f01ed1e1b3b91a1f0a501a4de7df8097e9c54 | 263a50fb4ca9be07a5b229ac80047f068721f459 | /chrome/app/breakpad_posix.cc | f8c9521654af8c8255aac5e75c1f460d0566957c | [
"BSD-3-Clause"
] | permissive | talalbutt/clank | 8150b328294d0ac7406fa86e2d7f0b960098dc91 | d060a5fcce180009d2eb9257a809cfcb3515f997 | refs/heads/master | 2021-01-18T01:54:24.585184 | 2012-10-17T15:00:42 | 2012-10-17T15:00:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 37,680 | cc | // Copyright (c) 2012 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.
// For linux_syscall_support.h. This makes it safe to call embedded system
// calls when in seccomp mode.
#define SYS_SYSCALL_ENTRYPOINT "playground$syscallEntryPoint"
#include "chrome/app/breakpad_posix.h"
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <string>
#include "base/command_line.h"
#include "base/eintr_wrapper.h"
#include "base/file_path.h"
#include "base/global_descriptors_posix.h"
#include "base/posix_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "breakpad/src/client/linux/handler/exception_handler.h"
#include "breakpad/src/client/linux/minidump_writer/directory_reader.h"
#include "breakpad/src/common/linux/linux_libc_support.h"
#include "breakpad/src/common/memory.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info_posix.h"
#include "chrome/common/env_vars.h"
#include "content/common/chrome_descriptors.h"
#ifdef OS_ANDROID
#include <android/log.h>
#include <sys/stat.h>
#include "base/android/path_utils.h"
#include "base/android/build_info.h"
#include "third_party/lss/linux_syscall_support.h"
#else
#include "seccompsandbox/linux_syscall_support.h"
#endif
#ifndef PR_SET_PTRACER
#define PR_SET_PTRACER 0x59616d61
#endif
// Some versions of gcc are prone to warn about unused return values. In cases
// where we either a) know the call cannot fail, or b) there is nothing we
// can do when a call fails, we mark the return code as ignored. This avoids
// spurious compiler warnings.
#define IGNORE_RET(x) do { if (x); } while (0)
static const char kUploadURL[] =
"https://clients2.google.com/cr/report";
static bool is_crash_reporter_enabled = false;
static uint64_t process_start_time = 0;
static char* crash_log_path = NULL;
// Writes the value |v| as 16 hex characters to the memory pointed at by
// |output|.
static void write_uint64_hex(char* output, uint64_t v) {
static const char hextable[] = "0123456789abcdef";
for (int i = 15; i >= 0; --i) {
output[i] = hextable[v & 15];
v >>= 4;
}
}
// The following helper functions are for calculating uptime.
// Converts a struct timeval to milliseconds.
static uint64_t timeval_to_ms(struct timeval *tv) {
uint64_t ret = tv->tv_sec; // Avoid overflow by explicitly using a uint64_t.
ret *= 1000;
ret += tv->tv_usec / 1000;
return ret;
}
// Converts a struct timeval to milliseconds.
static uint64_t kernel_timeval_to_ms(struct kernel_timeval *tv) {
uint64_t ret = tv->tv_sec; // Avoid overflow by explicitly using a uint64_t.
ret *= 1000;
ret += tv->tv_usec / 1000;
return ret;
}
// uint64_t version of my_int_len() from
// breakpad/src/common/linux/linux_libc_support.h. Return the length of the
// given, non-negative integer when expressed in base 10.
static unsigned my_uint64_len(uint64_t i) {
if (!i)
return 1;
unsigned len = 0;
while (i) {
len++;
i /= 10;
}
return len;
}
// uint64_t version of my_itos() from
// breakpad/src/common/linux/linux_libc_support.h. Convert a non-negative
// integer to a string (not null-terminated).
static void my_uint64tos(char* output, uint64_t i, unsigned i_len) {
for (unsigned index = i_len; index; --index, i /= 10)
output[index - 1] = '0' + (i % 10);
}
namespace {
// MIME substrings.
static const char g_rn[] = "\r\n";
static const char g_form_data_msg[] = "Content-Disposition: form-data; name=\"";
static const char g_quote_msg[] = "\"";
static const char g_dashdash_msg[] = "--";
static const char g_dump_msg[] = "upload_file_minidump\"; filename=\"dump\"";
static const char g_content_type_msg[] =
"Content-Type: application/octet-stream";
// MimeWriter manages an iovec for writing MIMEs to a file.
class MimeWriter {
public:
static const int kIovCapacity = 30;
static const size_t kMaxCrashChunkSize = 64;
MimeWriter(int fd, const char* const mime_boundary);
~MimeWriter();
// Append boundary.
void AddBoundary();
// Append end of file boundary.
void AddEnd();
// Append key/value pair with specified sizes.
void AddPairData(const char* msg_type,
size_t msg_type_size,
const char* msg_data,
size_t msg_data_size);
// Append key/value pair.
void AddPairString(const char* msg_type,
const char* msg_data) {
AddPairData(msg_type, my_strlen(msg_type), msg_data, my_strlen(msg_data));
}
// Append key/value pair, splitting value into chunks no larger than
// |chunk_size|. |chunk_size| cannot be greater than |kMaxCrashChunkSize|.
// The msg_type string will have a counter suffix to distinguish each chunk.
void AddPairDataInChunks(const char* msg_type,
size_t msg_type_size,
const char* msg_data,
size_t msg_data_size,
size_t chunk_size,
bool strip_trailing_spaces);
// Add binary file dump. Currently this is only done once, so the name is
// fixed.
void AddFileDump(uint8_t* file_data,
size_t file_size);
// Flush any pending iovecs to the output file.
void Flush() {
IGNORE_RET(sys_writev(fd_, iov_, iov_index_));
iov_index_ = 0;
}
private:
void AddItem(const void* base, size_t size);
// Minor performance trade-off for easier-to-maintain code.
void AddString(const char* str) {
AddItem(str, my_strlen(str));
}
void AddItemWithoutTrailingSpaces(const void* base, size_t size);
struct kernel_iovec iov_[kIovCapacity];
int iov_index_;
// Output file descriptor.
int fd_;
const char* const mime_boundary_;
DISALLOW_COPY_AND_ASSIGN(MimeWriter);
};
MimeWriter::MimeWriter(int fd, const char* const mime_boundary)
: iov_index_(0),
fd_(fd),
mime_boundary_(mime_boundary) {
}
MimeWriter::~MimeWriter() {
}
void MimeWriter::AddBoundary() {
AddString(mime_boundary_);
AddString(g_rn);
}
void MimeWriter::AddEnd() {
AddString(mime_boundary_);
AddString(g_dashdash_msg);
AddString(g_rn);
}
void MimeWriter::AddPairData(const char* msg_type,
size_t msg_type_size,
const char* msg_data,
size_t msg_data_size) {
AddString(g_form_data_msg);
AddItem(msg_type, msg_type_size);
AddString(g_quote_msg);
AddString(g_rn);
AddString(g_rn);
AddItem(msg_data, msg_data_size);
AddString(g_rn);
}
void MimeWriter::AddPairDataInChunks(const char* msg_type,
size_t msg_type_size,
const char* msg_data,
size_t msg_data_size,
size_t chunk_size,
bool strip_trailing_spaces) {
if (chunk_size > kMaxCrashChunkSize)
return;
unsigned i = 0;
size_t done = 0, msg_length = msg_data_size;
while (msg_length) {
char num[16];
const unsigned num_len = my_int_len(++i);
my_itos(num, i, num_len);
size_t chunk_len = std::min(chunk_size, msg_length);
AddString(g_form_data_msg);
AddItem(msg_type, msg_type_size);
AddItem(num, num_len);
AddString(g_quote_msg);
AddString(g_rn);
AddString(g_rn);
if (strip_trailing_spaces) {
AddItemWithoutTrailingSpaces(msg_data + done, chunk_len);
} else {
AddItem(msg_data + done, chunk_len);
}
AddString(g_rn);
AddBoundary();
Flush();
done += chunk_len;
msg_length -= chunk_len;
}
}
void MimeWriter::AddFileDump(uint8_t* file_data,
size_t file_size) {
AddString(g_form_data_msg);
AddString(g_dump_msg);
AddString(g_rn);
AddString(g_content_type_msg);
AddString(g_rn);
AddString(g_rn);
AddItem(file_data, file_size);
AddString(g_rn);
}
void MimeWriter::AddItem(const void* base, size_t size) {
// Check if the iovec is full and needs to be flushed to output file.
if (iov_index_ == kIovCapacity) {
Flush();
}
iov_[iov_index_].iov_base = const_cast<void*>(base);
iov_[iov_index_].iov_len = size;
++iov_index_;
}
void MimeWriter::AddItemWithoutTrailingSpaces(const void* base, size_t size) {
while (size > 0) {
const char* c = static_cast<const char*>(base) + size - 1;
if (*c != ' ')
break;
size--;
}
AddItem(base, size);
}
} // namespace
pid_t HandleCrashDump(const BreakpadInfo& info) {
// WARNING: this code runs in a compromised context. It may not call into
// libc nor allocate memory normally.
const int dumpfd = sys_open(info.filename, O_RDONLY, 0);
if (dumpfd < 0) {
static const char msg[] = "Cannot upload crash dump: failed to open\n";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg));
#endif
return -1;
}
#if defined(OS_ANDROID)
struct stat st;
if (fstat(dumpfd, &st) != 0) {
#else
struct kernel_stat st;
if (sys_fstat(dumpfd, &st) != 0) {
#endif
static const char msg[] = "Cannot upload crash dump: stat failed\n";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg));
#endif
IGNORE_RET(sys_close(dumpfd));
return -1;
}
google_breakpad::PageAllocator allocator;
uint8_t* dump_data = reinterpret_cast<uint8_t*>(allocator.Alloc(st.st_size));
if (!dump_data) {
static const char msg[] = "Cannot upload crash dump: cannot alloc\n";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg));
#endif
IGNORE_RET(sys_close(dumpfd));
return -1;
}
sys_read(dumpfd, dump_data, st.st_size);
IGNORE_RET(sys_close(dumpfd));
// We need to build a MIME block for uploading to the server. Since we are
// going to fork and run wget, it needs to be written to a temp file.
const int ufd = sys_open("/dev/urandom", O_RDONLY, 0);
if (ufd < 0) {
static const char msg[] = "Cannot upload crash dump because /dev/urandom"
" is missing\n";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg) - 1);
#endif
return -1;
}
static const char temp_file_template[] =
"/tmp/chromium-upload-XXXXXXXXXXXXXXXX";
char temp_file[sizeof(temp_file_template)];
int fd = -1;
if (info.upload) {
memcpy(temp_file, temp_file_template, sizeof(temp_file_template));
for (unsigned i = 0; i < 10; ++i) {
uint64_t t;
sys_read(ufd, &t, sizeof(t));
write_uint64_hex(temp_file + sizeof(temp_file) - (16 + 1), t);
fd = sys_open(temp_file, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fd >= 0)
break;
}
if (fd < 0) {
static const char msg[] = "Failed to create temporary file in /tmp: "
"cannot upload crash dump\n";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg) - 1);
#endif
IGNORE_RET(sys_close(ufd));
return -1;
}
} else {
fd = sys_open(info.filename, O_WRONLY, 0600);
if (fd < 0) {
static const char msg[] = "Failed to save crash dump: failed to open\n";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg) - 1);
#endif
IGNORE_RET(sys_close(ufd));
return -1;
}
}
// The MIME boundary is 28 hyphens, followed by a 64-bit nonce and a NUL.
char mime_boundary[28 + 16 + 1];
my_memset(mime_boundary, '-', 28);
uint64_t boundary_rand;
sys_read(ufd, &boundary_rand, sizeof(boundary_rand));
write_uint64_hex(mime_boundary + 28, boundary_rand);
mime_boundary[28 + 16] = 0;
IGNORE_RET(sys_close(ufd));
// The MIME block looks like this:
// BOUNDARY \r\n
// Content-Disposition: form-data; name="prod" \r\n \r\n
// Chrome_Linux \r\n
// BOUNDARY \r\n
// Content-Disposition: form-data; name="ver" \r\n \r\n
// 1.2.3.4 \r\n
// BOUNDARY \r\n
// Content-Disposition: form-data; name="guid" \r\n \r\n
// 1.2.3.4 \r\n
// BOUNDARY \r\n
//
// zero or one:
// Content-Disposition: form-data; name="ptime" \r\n \r\n
// abcdef \r\n
// BOUNDARY \r\n
//
// zero or one:
// Content-Disposition: form-data; name="ptype" \r\n \r\n
// abcdef \r\n
// BOUNDARY \r\n
//
// zero or more gpu entries:
// Content-Disposition: form-data; name="gpu-xxxxx" \r\n \r\n
// <gpu-xxxxx> \r\n
// BOUNDARY \r\n
//
// zero or one:
// Content-Disposition: form-data; name="lsb-release" \r\n \r\n
// abcdef \r\n
// BOUNDARY \r\n
//
// zero or more:
// Content-Disposition: form-data; name="url-chunk-1" \r\n \r\n
// abcdef \r\n
// BOUNDARY \r\n
//
// zero or one:
// Content-Disposition: form-data; name="channel" \r\n \r\n
// beta \r\n
// BOUNDARY \r\n
//
// zero or one:
// Content-Disposition: form-data; name="num-views" \r\n \r\n
// 3 \r\n
// BOUNDARY \r\n
//
// zero or one:
// Content-Disposition: form-data; name="num-extensions" \r\n \r\n
// 5 \r\n
// BOUNDARY \r\n
//
// zero to 10:
// Content-Disposition: form-data; name="extension-1" \r\n \r\n
// abcdefghijklmnopqrstuvwxyzabcdef \r\n
// BOUNDARY \r\n
//
// zero or one:
// Content-Disposition: form-data; name="num-switches" \r\n \r\n
// 5 \r\n
// BOUNDARY \r\n
//
// zero to 15:
// Content-Disposition: form-data; name="switch-1" \r\n \r\n
// --foo \r\n
// BOUNDARY \r\n
//
// Content-Disposition: form-data; name="dump"; filename="dump" \r\n
// Content-Type: application/octet-stream \r\n \r\n
// <dump contents>
// \r\n BOUNDARY -- \r\n
MimeWriter writer(fd, mime_boundary);
{
#if defined(OS_CHROMEOS)
static const char chrome_product_msg[] = "Chrome_ChromeOS";
#elif defined(OS_ANDROID)
static const char chrome_product_msg[] = "Chrome_Android";
#else // OS_LINUX
static const char chrome_product_msg[] = "Chrome_Linux";
#endif
#if defined(OS_ANDROID)
const base::android::BuildInfo* android_build_info =
base::android::BuildInfo::GetInstance();
static const char* version_msg = android_build_info->package_version_code;
static const char android_build_id[] = "android_build_id";
static const char android_build_fp[] = "android_build_fp";
static const char device[] = "device";
static const char model[] = "model";
static const char brand[] = "brand";
static const char exception_info[] = "exception_info";
#else
static const char version_msg[] = PRODUCT_VERSION;
#endif
writer.AddBoundary();
writer.AddPairString("prod", chrome_product_msg);
writer.AddBoundary();
writer.AddPairString("ver", version_msg);
writer.AddBoundary();
if (info.pid_str != NULL) {
writer.AddPairString("pid", info.pid_str);
writer.AddBoundary();
}
writer.AddPairString("guid", info.guid);
writer.AddBoundary();
#if defined(OS_ANDROID)
// Addtional MIME blocks are added for logging on Android devices.
writer.AddPairString(android_build_id, android_build_info->android_build_id);
writer.AddBoundary();
writer.AddPairString(android_build_fp, android_build_info->android_build_fp);
writer.AddBoundary();
writer.AddPairString(device, android_build_info->device);
writer.AddBoundary();
writer.AddPairString(model, android_build_info->model);
writer.AddBoundary();
writer.AddPairString(brand, android_build_info->brand);
writer.AddBoundary();
if (android_build_info->java_exception_info != NULL) {
writer.AddPairString(exception_info,
android_build_info->java_exception_info);
writer.AddBoundary();
}
#endif
writer.Flush();
}
if (info.process_start_time > 0) {
struct kernel_timeval tv;
if (!sys_gettimeofday(&tv, NULL)) {
uint64_t time = kernel_timeval_to_ms(&tv);
if (time > info.process_start_time) {
time -= info.process_start_time;
char time_str[21];
const unsigned time_len = my_uint64_len(time);
my_uint64tos(time_str, time, time_len);
static const char process_time_msg[] = "ptime";
writer.AddPairData(process_time_msg, sizeof(process_time_msg) - 1,
time_str, time_len);
writer.AddBoundary();
writer.Flush();
}
}
}
if (info.process_type_length) {
writer.AddPairString("ptype", info.process_type);
writer.AddBoundary();
writer.Flush();
}
// If GPU info is known, send it.
unsigned gpu_vendor_len = my_strlen(child_process_logging::g_gpu_vendor_id);
if (gpu_vendor_len) {
static const char vendor_msg[] = "gpu-venid";
static const char device_msg[] = "gpu-devid";
static const char driver_msg[] = "gpu-driver";
static const char psver_msg[] = "gpu-psver";
static const char vsver_msg[] = "gpu-vsver";
writer.AddPairString(vendor_msg, child_process_logging::g_gpu_vendor_id);
writer.AddBoundary();
writer.AddPairString(device_msg, child_process_logging::g_gpu_device_id);
writer.AddBoundary();
writer.AddPairString(driver_msg, child_process_logging::g_gpu_driver_ver);
writer.AddBoundary();
writer.AddPairString(psver_msg, child_process_logging::g_gpu_ps_ver);
writer.AddBoundary();
writer.AddPairString(vsver_msg, child_process_logging::g_gpu_vs_ver);
writer.AddBoundary();
writer.Flush();
}
if (info.distro_length) {
static const char distro_msg[] = "lsb-release";
writer.AddPairString(distro_msg, info.distro);
writer.AddBoundary();
writer.Flush();
}
// For renderers and plugins.
if (info.crash_url_length) {
static const char url_chunk_msg[] = "url-chunk-";
static const unsigned kMaxUrlLength = 8 * MimeWriter::kMaxCrashChunkSize;
writer.AddPairDataInChunks(url_chunk_msg, sizeof(url_chunk_msg) - 1,
info.crash_url, std::min(info.crash_url_length, kMaxUrlLength),
MimeWriter::kMaxCrashChunkSize, false /* Don't strip whitespaces. */);
}
if (my_strlen(child_process_logging::g_channel)) {
writer.AddPairString("channel", child_process_logging::g_channel);
writer.AddBoundary();
writer.Flush();
}
if (my_strlen(child_process_logging::g_num_views)) {
writer.AddPairString("num-views", child_process_logging::g_num_views);
writer.AddBoundary();
writer.Flush();
}
if (my_strlen(child_process_logging::g_num_extensions)) {
writer.AddPairString("num-extensions",
child_process_logging::g_num_extensions);
writer.AddBoundary();
writer.Flush();
}
unsigned extension_ids_len =
my_strlen(child_process_logging::g_extension_ids);
if (extension_ids_len) {
static const char extension_msg[] = "extension-";
static const unsigned kMaxExtensionsLen =
kMaxReportedActiveExtensions * child_process_logging::kExtensionLen;
writer.AddPairDataInChunks(extension_msg, sizeof(extension_msg) - 1,
child_process_logging::g_extension_ids,
std::min(extension_ids_len, kMaxExtensionsLen),
child_process_logging::kExtensionLen,
false /* Don't strip whitespace. */);
}
if (my_strlen(child_process_logging::g_num_switches)) {
writer.AddPairString("num-switches",
child_process_logging::g_num_switches);
writer.AddBoundary();
writer.Flush();
}
unsigned switches_len =
my_strlen(child_process_logging::g_switches);
if (switches_len) {
static const char switch_msg[] = "switch-";
static const unsigned kMaxSwitchLen =
kMaxSwitches * child_process_logging::kSwitchLen;
writer.AddPairDataInChunks(switch_msg, sizeof(switch_msg) - 1,
child_process_logging::g_switches,
std::min(switches_len, kMaxSwitchLen),
child_process_logging::kSwitchLen,
true /* Strip whitespace since switches are padded to kSwitchLen. */);
}
writer.AddFileDump(dump_data, st.st_size);
writer.AddEnd();
writer.Flush();
IGNORE_RET(sys_close(fd));
#if defined(OS_ANDROID)
const char* output_msg = "Output crash dump file:";
__android_log_write(ANDROID_LOG_WARN, "chromium", output_msg);
__android_log_write(ANDROID_LOG_WARN, "chromium", info.filename);
// -1 because we won't need the null terminator on the original filename.
unsigned done_filename_len = info.filename_length -1 + info.pid_str_length;
char* done_filename = reinterpret_cast<char*>(
allocator.Alloc(done_filename_len));
// Rename the file such that the pid is the suffix in order signal to other
// processes that the minidump is complete. The advantage of using the pid as
// the suffix is that it is trivial to associate the minidump with the
// crashed process.
// Finally, note strncpy prevents null terminators from
// being copied. Pad the rest with 0's.
my_strncpy(done_filename, info.filename, done_filename_len);
// Append the suffix a null terminator should be added.
my_strncat(done_filename, info.pid_str, info.pid_str_length);
// Rename the minidump file to signal that it is complete.
if (rename(info.filename, done_filename)) {
__android_log_write(ANDROID_LOG_WARN, "chromium", "Failed to rename:");
__android_log_write(ANDROID_LOG_WARN, "chromium", info.filename);
__android_log_write(ANDROID_LOG_WARN, "chromium", "to");
__android_log_write(ANDROID_LOG_WARN, "chromium", done_filename);
}
#endif
if (!info.upload)
return 0;
// The --header argument to wget looks like:
// --header=Content-Type: multipart/form-data; boundary=XYZ
// where the boundary has two fewer leading '-' chars
static const char header_msg[] =
"--header=Content-Type: multipart/form-data; boundary=";
char* const header = reinterpret_cast<char*>(allocator.Alloc(
sizeof(header_msg) - 1 + sizeof(mime_boundary) - 2));
memcpy(header, header_msg, sizeof(header_msg) - 1);
memcpy(header + sizeof(header_msg) - 1, mime_boundary + 2,
sizeof(mime_boundary) - 2);
// We grab the NUL byte from the end of |mime_boundary|.
// The --post-file argument to wget looks like:
// --post-file=/tmp/...
static const char post_file_msg[] = "--post-file=";
char* const post_file = reinterpret_cast<char*>(allocator.Alloc(
sizeof(post_file_msg) - 1 + sizeof(temp_file)));
memcpy(post_file, post_file_msg, sizeof(post_file_msg) - 1);
memcpy(post_file + sizeof(post_file_msg) - 1, temp_file, sizeof(temp_file));
const pid_t child = sys_fork();
if (!child) {
// IN CHILD PROCESS
// This code is called both when a browser is crashing (in which case,
// nothing really matters any more) and when a renderer/plugin crashes, in
// which case we need to continue.
//
// Since we are a multithreaded app, if we were just to fork(), we might
// grab file descriptors which have just been created in another thread and
// hold them open for too long.
//
// Thus, we have to loop and try and close everything.
const int fd = sys_open("/proc/self/fd", O_DIRECTORY | O_RDONLY, 0);
if (fd < 0) {
for (unsigned i = 3; i < 8192; ++i)
IGNORE_RET(sys_close(i));
} else {
google_breakpad::DirectoryReader reader(fd);
const char* name;
while (reader.GetNextEntry(&name)) {
int i;
if (my_strtoui(&i, name) && i > 2 && i != fd)
IGNORE_RET(sys_close(i));
reader.PopEntry();
}
IGNORE_RET(sys_close(fd));
}
IGNORE_RET(sys_setsid());
// Leave one end of a pipe in the wget process and watch for it getting
// closed by the wget process exiting.
int fds[2]; // 0 is read, 1 is write.
IGNORE_RET(sys_pipe(fds));
const pid_t child = sys_fork();
if (child) {
// Child's child will skip this code.
IGNORE_RET(sys_close(fds[1]));
char id_buf[17];
const int len = HANDLE_EINTR(sys_read(fds[0], id_buf,
sizeof(id_buf) - 1));
if (len > 0) {
// Write crash dump id to stderr.
id_buf[len] = 0;
static const char msg[] = "\nCrash dump id: ";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
__android_log_write(ANDROID_LOG_WARN, "chromium", id_buf);
#else
sys_write(2, msg, sizeof(msg) - 1);
sys_write(2, id_buf, my_strlen(id_buf));
sys_write(2, "\n", 1);
#endif
// Write crash dump id to crash log as: seconds_since_epoch,crash_id
struct kernel_timeval tv;
if (crash_log_path && !sys_gettimeofday(&tv, NULL)) {
uint64_t time = kernel_timeval_to_ms(&tv) / 1000;
char time_str[21];
const unsigned time_len = my_uint64_len(time);
my_uint64tos(time_str, time, time_len);
int log_fd = sys_open(crash_log_path, O_CREAT | O_WRONLY | O_APPEND,
0600);
if (log_fd > 0) {
sys_write(log_fd, time_str, time_len);
sys_write(log_fd, ",", 1);
sys_write(log_fd, id_buf, my_strlen(id_buf));
sys_write(log_fd, "\n", 1);
IGNORE_RET(sys_close(log_fd));
}
}
}
IGNORE_RET(sys_unlink(info.filename));
IGNORE_RET(sys_unlink(temp_file));
sys__exit(0);
}
IGNORE_RET(sys_close(fds[0]));
IGNORE_RET(sys_dup2(fds[1], 3));
static const char* const kWgetBinary = "/usr/bin/wget";
const char* args[] = {
kWgetBinary,
header,
post_file,
kUploadURL,
"--timeout=10", // Set a timeout so we don't hang forever.
"--tries=1", // Don't retry if the upload fails.
"-O", // output reply to fd 3
"/dev/fd/3",
NULL,
};
execve(kWgetBinary, const_cast<char**>(args), environ);
static const char msg[] = "Cannot upload crash dump: cannot exec "
"/usr/bin/wget\n";
sys_write(2, msg, sizeof(msg) - 1);
sys__exit(1);
}
HANDLE_EINTR(sys_waitpid(child, NULL, 0));
return child;
}
static bool CrashDone(const char* dump_path,
const char* minidump_id,
const bool upload,
const bool succeeded) {
// WARNING: this code runs in a compromised context. It may not call into
// libc nor allocate memory normally.
if (!succeeded) {
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", "Crash dump failed.");
#endif
return false;
}
#if defined(OS_ANDROID)
else {
__android_log_write(ANDROID_LOG_INFO, "chromium",
"Initial Minidump data written: ");
__android_log_write(ANDROID_LOG_INFO, "chromium", dump_path);
}
#endif
google_breakpad::PageAllocator allocator;
const unsigned dump_path_len = my_strlen(dump_path);
const unsigned minidump_id_len = my_strlen(minidump_id);
const unsigned path_len =
dump_path_len + 1 /* '/' */ + minidump_id_len +
4 /* ".dmp" */ + 1 /* NUL */;
char* const path = reinterpret_cast<char*>(allocator.Alloc(path_len));
memcpy(path, dump_path, dump_path_len);
path[dump_path_len] = '/';
memcpy(path + dump_path_len + 1, minidump_id, minidump_id_len);
memcpy(path + dump_path_len + 1 + minidump_id_len, ".dmp", 4);
path[dump_path_len + 1 + minidump_id_len + 4] = 0;
BreakpadInfo info;
info.filename = path;
info.filename_length = path_len;
info.process_type = "browser";
info.process_type_length = 7;
info.crash_url = NULL;
info.crash_url_length = 0;
info.guid = child_process_logging::g_client_id;
info.guid_length = my_strlen(child_process_logging::g_client_id);
info.distro = base::g_linux_distro;
info.distro_length = my_strlen(base::g_linux_distro);
info.upload = upload;
info.process_start_time = process_start_time;
// Use 0 as a dummy pid signnalling a browser process crash.
info.pid_str = "0";
info.pid_str_length = 1;
HandleCrashDump(info);
return true;
}
// Wrapper script, do not add more code here.
static bool CrashDoneNoUpload(const char* dump_path,
const char* minidump_id,
void* context,
bool succeeded) {
return CrashDone(dump_path, minidump_id, false, succeeded);
}
#if !defined(OS_ANDROID)
// Wrapper script, do not add more code here.
static bool CrashDoneUpload(const char* dump_path,
const char* minidump_id,
void* context,
bool succeeded) {
return CrashDone(dump_path, minidump_id, true, succeeded);
}
#endif
void EnableCrashDumping(const bool unattended) {
is_crash_reporter_enabled = true;
FilePath tmp_path("/tmp");
PathService::Get(base::DIR_TEMP, &tmp_path);
FilePath dumps_path(tmp_path);
if (PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) {
FilePath logfile = dumps_path.AppendASCII("uploads.log");
std::string logfile_str = logfile.value();
const size_t crash_log_path_len = logfile_str.size() + 1;
crash_log_path = new char[crash_log_path_len];
strncpy(crash_log_path, logfile_str.c_str(), crash_log_path_len);
}
#if defined(OS_ANDROID)
LOG(INFO) << "Dump path: " << dumps_path.value();
// In Android we wait until the browser is restarted before we push data up to
// the crash server. This means that checks to see whether the broweser is
// unattended should be postponed until the browser is re-started.
new google_breakpad::ExceptionHandler(dumps_path.value().c_str(), NULL,
CrashDoneNoUpload, NULL,
true /* install handlers */);
#else
if (unattended) {
new google_breakpad::ExceptionHandler(dumps_path.value().c_str(), NULL,
CrashDoneNoUpload, NULL,
true /* install handlers */);
} else {
new google_breakpad::ExceptionHandler(tmp_path.value().c_str(), NULL,
CrashDoneUpload, NULL,
true /* install handlers */);
}
#endif
}
// Non-Browser = Extension, Gpu, Plugins, Ppapi and Renderer
static bool NonBrowserCrashHandler(const void* crash_context,
size_t crash_context_size,
void* context) {
const int fd = reinterpret_cast<intptr_t>(context);
int fds[2] = { -1, -1 };
if (sys_socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
static const char msg[] = "Failed to create socket for crash dumping.";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg));
#endif
return false;
}
// On kernels with ptrace protection, e.g. Ubuntu 10.10+, the browser cannot
// ptrace this crashing process and crash dumping will fail. When using the
// SUID sandbox, this crashing process is likely to be in its own PID
// namespace, and thus there is no way to permit only the browser process to
// ptrace it.
// The workaround is to allow all processes to ptrace this process if we
// reach this point, by passing -1 as the allowed PID. However, support for
// passing -1 as the PID won't reach kernels until around the Ubuntu 12.04
// timeframe.
sys_prctl(PR_SET_PTRACER, -1);
// Start constructing the message to send to the browser.
char guid[kGuidSize + 1] = {0};
char crash_url[kMaxActiveURLSize + 1] = {0};
char distro[kDistroSize + 1] = {0};
const size_t guid_len =
std::min(my_strlen(child_process_logging::g_client_id), kGuidSize);
const size_t crash_url_len =
std::min(my_strlen(child_process_logging::g_active_url),
kMaxActiveURLSize);
const size_t distro_len =
std::min(my_strlen(base::g_linux_distro), kDistroSize);
memcpy(guid, child_process_logging::g_client_id, guid_len);
memcpy(crash_url, child_process_logging::g_active_url, crash_url_len);
memcpy(distro, base::g_linux_distro, distro_len);
char b; // Dummy variable for sys_read below.
const char* b_addr = &b; // Get the address of |b| so we can create the
// expected /proc/[pid]/syscall content in the
// browser to convert namespace tids.
// The length of the control message:
static const unsigned kControlMsgSize = sizeof(fds);
static const unsigned kControlMsgSpaceSize = CMSG_SPACE(kControlMsgSize);
static const unsigned kControlMsgLenSize = CMSG_LEN(kControlMsgSize);
const size_t kIovSize = 7;
struct kernel_msghdr msg;
my_memset(&msg, 0, sizeof(struct kernel_msghdr));
struct kernel_iovec iov[kIovSize];
iov[0].iov_base = const_cast<void*>(crash_context);
iov[0].iov_len = crash_context_size;
iov[1].iov_base = guid;
iov[1].iov_len = kGuidSize + 1;
iov[2].iov_base = crash_url;
iov[2].iov_len = kMaxActiveURLSize + 1;
iov[3].iov_base = distro;
iov[3].iov_len = kDistroSize + 1;
iov[4].iov_base = &b_addr;
iov[4].iov_len = sizeof(b_addr);
iov[5].iov_base = &fds[0];
iov[5].iov_len = sizeof(fds[0]);
iov[6].iov_base = &process_start_time;
iov[6].iov_len = sizeof(process_start_time);
msg.msg_iov = iov;
msg.msg_iovlen = kIovSize;
char cmsg[kControlMsgSpaceSize];
my_memset(cmsg, 0, kControlMsgSpaceSize);
msg.msg_control = cmsg;
msg.msg_controllen = sizeof(cmsg);
struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg);
hdr->cmsg_level = SOL_SOCKET;
hdr->cmsg_type = SCM_RIGHTS;
hdr->cmsg_len = kControlMsgLenSize;
((int*) CMSG_DATA(hdr))[0] = fds[0];
((int*) CMSG_DATA(hdr))[1] = fds[1];
if (HANDLE_EINTR(sys_sendmsg(fd, &msg, 0)) < 0) {
static const char msg[] = "Failed to tell parent about crash.";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg));
#endif
IGNORE_RET(sys_close(fds[1]));
return false;
}
IGNORE_RET(sys_close(fds[1]));
if (HANDLE_EINTR(sys_read(fds[0], &b, 1)) != 1) {
static const char msg[] = "Parent failed to complete crash dump.";
#if defined(OS_ANDROID)
__android_log_write(ANDROID_LOG_WARN, "chromium", msg);
#else
sys_write(2, msg, sizeof(msg));
#endif
}
return true;
}
void EnableNonBrowserCrashDumping() {
const int fd = base::GlobalDescriptors::GetInstance()->Get(kCrashDumpSignal);
is_crash_reporter_enabled = true;
// We deliberately leak this object.
google_breakpad::ExceptionHandler* handler =
new google_breakpad::ExceptionHandler("" /* unused */, NULL, NULL,
reinterpret_cast<void*>(fd), true);
handler->set_crash_handler(NonBrowserCrashHandler);
}
void InitCrashReporter() {
#if defined(OS_ANDROID)
// This will guarantee that the BuildInfo has been initialized and subsequent
// calls will not require memory allocation.
base::android::BuildInfo::GetInstance();
#endif
// Determine the process type and take appropriate action.
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(switches::kDisableBreakpad))
return;
const std::string process_type =
parsed_command_line.GetSwitchValueASCII(switches::kProcessType);
if (process_type.empty()) {
EnableCrashDumping(getenv(env_vars::kHeadless) != NULL);
} else if (process_type == switches::kRendererProcess ||
process_type == switches::kPluginProcess ||
process_type == switches::kPpapiPluginProcess ||
process_type == switches::kZygoteProcess ||
process_type == switches::kGpuProcess) {
InitNonBrowserCrashReporter();
LOG(INFO) << "Non Browser crash dumping enabled for: " << process_type;
}
// Set the base process start time value.
struct timeval tv;
if (!gettimeofday(&tv, NULL))
process_start_time = timeval_to_ms(&tv);
else
process_start_time = 0;
}
void InitNonBrowserCrashReporter() {
#if defined(OS_ANDROID)
child_process_logging::SetClientId("Android");
#else
// We might be chrooted in a zygote or renderer process so we cannot call
// GetCollectStatsConsent because that needs access the the user's home
// dir. Instead, we set a command line flag for these processes.
// Even though plugins are not chrooted, we share the same code path for
// simplicity.
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (!parsed_command_line.HasSwitch(switches::kEnableCrashReporter))
return;
// Get the guid and linux distro from the command line switch.
std::string switch_value =
parsed_command_line.GetSwitchValueASCII(switches::kEnableCrashReporter);
size_t separator = switch_value.find(",");
if (separator != std::string::npos) {
child_process_logging::SetClientId(switch_value.substr(0, separator));
// The notion of a distro doesn't make sense in Android.
base::SetLinuxDistro(switch_value.substr(separator + 1));
} else {
child_process_logging::SetClientId(switch_value);
}
#endif
EnableNonBrowserCrashDumping();
}
bool IsCrashReporterEnabled() {
return is_crash_reporter_enabled;
}
| [
"plind@mips.com"
] | plind@mips.com |
d306ff41d744981fc1157dcefd44e710fe31192e | ccc963be136f377fc71c4431d13f32be435b5dc1 | /Cpp/cmake_version/Source/TurnTicketDispenser/include/TurnNumberSequence.h | da574b005dbdc0adabf4990d8301e584575760c8 | [
"MIT"
] | permissive | Promethivm/Racing-Car-Katas | 067fafc416d13d146837a391b9d44e446abc5f35 | b01dcf952e9c4b7b19386a846ca526140a51fc55 | refs/heads/master | 2020-03-14T17:27:37.074990 | 2018-03-08T14:27:56 | 2018-03-08T14:27:56 | 131,720,194 | 0 | 0 | MIT | 2018-05-01T14:06:22 | 2018-05-01T14:06:21 | null | UTF-8 | C++ | false | false | 127 | h | #pragma once
class TurnNumberSequence
{
static int s_turnNumber;
public:
static int getNextTurnNumber();
};
| [
"emily@bacheconsulting.com"
] | emily@bacheconsulting.com |
d606d9568202e3e519e417474fb133f882a0359a | a7545b0cba7a613f0128b7ac4c80bdbc8160f6a4 | /src/qt/guapcoin/focuseddialog.cpp | d1d0b9dd361e00ba6d3f54c0e903c8db56e5bc3c | [
"MIT"
] | permissive | nerdynerdnerdz/Guapcoin | b555fc57f791bafcbeb14058e344e3860122097c | 84fe2eef168ecc9042d5315a2ff471413a134971 | refs/heads/master | 2023-01-05T11:27:19.596120 | 2020-10-29T08:31:40 | 2020-10-29T08:31:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | cpp | // Copyright (c) 2020 The PIVX developers
// Copyright (c) 2020 The Guapcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "qt/guapcoin/focuseddialog.h"
#include <QKeyEvent>
FocusedDialog::FocusedDialog(QWidget *parent) :
QDialog(parent)
{}
void FocusedDialog::showEvent(QShowEvent *event)
{
setFocus();
}
void FocusedDialog::keyPressEvent(QKeyEvent *e)
{
if (e->type() == QEvent::KeyPress) {
QKeyEvent* ke = static_cast<QKeyEvent*>(e);
// Detect Enter key press
if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return) accept();
// Detect Esc key press
if (ke->key() == Qt::Key_Escape) reject();
}
}
FocusedDialog::~FocusedDialog()
{}
| [
"53179738+guapcrypto@users.noreply.github.com"
] | 53179738+guapcrypto@users.noreply.github.com |
b1d28c816b37a00d548aef8360e9a23f54c9cd31 | b003062fd3f8716b14f8c6a1f1f82e88167a1f7a | /surse/prob52.cpp | 734afbc361e17507b5c6170d532664af9d6f5fb2 | [] | no_license | adrgs/oopquiz | cbc297fbb3f286e9baf8d6f0e5a12f0ceb92455d | ca734f9d932a390f00c23703ab09d79c18ead6a9 | refs/heads/master | 2020-12-23T15:56:14.957425 | 2020-01-31T17:41:50 | 2020-01-31T17:41:50 | 237,197,399 | 9 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 494 | cpp | #include <iostream>
using namespace std;
class B
{ protected: static int x;
int i;
public: B() { x++; i=1; }
~B() { x--; cout << "b";}
int get_x() { return x; }
int get_i() { return i; } };
int B::x;
class D: public B
{ public: D() { x++; }
~D() { x--; cout << "d";} };
int f(B *q)
{ return (q->get_x())+1; }
int main()
{ B *p=new B[10];
cout<<f(p);
delete[] p;
p=new D;
cout<<f(p);
delete p;
cout<<D::get_x();
return 0;
} | [
"albastroiudragos@gmail.com"
] | albastroiudragos@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.