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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7e56f57038a6757e1f053350b64f46fe4423dfec | d460fdbc7dfb05d76308cf0ac26bd0ebd2ba8382 | /lib/TaintAnalysis/Precision/PrecisionLossTracker.cpp | bf99943ada8253b6bded20fb506cfbbfc493b8f5 | [
"MIT"
] | permissive | grievejia/tpa | 5032f1db8fae037227a7efd003abd5d820cf5069 | 8a7aa4c7d41c266fcf3a5e2011ff324bcddf5816 | refs/heads/master | 2020-04-09T11:11:18.898040 | 2016-03-23T20:41:30 | 2016-03-23T20:41:30 | 30,267,261 | 22 | 8 | null | null | null | null | UTF-8 | C++ | false | false | 2,170 | cpp | #include "PointerAnalysis/Analysis/SemiSparsePointerAnalysis.h"
#include "TaintAnalysis/Engine/TaintGlobalState.h"
#include "TaintAnalysis/Precision/LocalTracker.h"
#include "TaintAnalysis/Precision/PrecisionLossTracker.h"
#include "TaintAnalysis/Precision/TrackerGlobalState.h"
#include "TaintAnalysis/Precision/TrackerTransferFunction.h"
#include "TaintAnalysis/Precision/TrackerWorkList.h"
#include <llvm/IR/CallSite.h>
#include <unordered_set>
namespace taint
{
void PrecisionLossTracker::initializeWorkList(TrackerWorkList& workList, const SinkViolationRecord& record)
{
auto const& ptrAnalysis = globalState.getPointerAnalysis();
for (auto const& mapping: record)
{
// We only care about imprecision
auto const& pp = mapping.first;
llvm::ImmutableCallSite cs(pp.getDefUseInstruction()->getInstruction());
assert(cs);
auto ctx = pp.getContext();
std::unordered_set<const llvm::Value*> trackedValues;
std::unordered_set<const tpa::MemoryObject*> trackedObjects;
for (auto const& violation: mapping.second)
{
if (violation.actualVal != TaintLattice::Either)
continue;
auto argVal = cs.getArgument(violation.argPos);
if (violation.what == annotation::TClass::ValueOnly)
{
trackedValues.insert(argVal);
}
else
{
auto pSet = ptrAnalysis.getPtsSet(ctx, argVal);
assert(!pSet.empty());
trackedObjects.insert(pSet.begin(), pSet.end());
}
}
LocalTracker tracker(workList);
tracker.trackValue(pp, trackedValues);
tracker.trackMemory(pp, trackedObjects);
}
}
ProgramPointSet PrecisionLossTracker::trackImprecision(const SinkViolationRecord& record)
{
ProgramPointSet ppSet;
// Prepare the tracker state
TrackerGlobalState trackerState(globalState.getDefUseModule(), globalState.getPointerAnalysis(), globalState.getExternalTaintTable(), globalState.getEnv(), globalState.getMemo(), globalState.getCallGraph(), ppSet);
// Prepare the tracker worklist
TrackerWorkList workList;
initializeWorkList(workList, record);
// The main analysis
while (!workList.empty())
{
auto pp = workList.dequeue();
TrackerTransferFunction(trackerState, workList).eval(pp);
}
return ppSet;
}
} | [
"grievejia@gmail.com"
] | grievejia@gmail.com |
54968cb039de0194db0d6ace09196c8db2b62888 | 1b0418ef45a7e8129e6c4ea43b407b9f8c44f2b5 | /sub-directory/Trial.cpp | 6ed88b22a9ed939e5dfac78572a9a3ee9f8b9492 | [] | no_license | anmol-sinha-coder/Competitive_Coding_Algorithms | 82dde7ceda5218589208e53e856ade299614078a | 2f4fa65c624b0f75e4890b305c6404eb2d012eee | refs/heads/master | 2021-08-26T01:19:40.731668 | 2021-08-09T11:50:58 | 2021-08-09T11:50:58 | 251,600,269 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 986 | cpp | #include<iostream>
#include<bits/stdc++.h>
using namespace std;
void combo(int C[],int lb,int n,int r);
void append(int C[],int);
void trunc(int C[]);
int *A=new int;
int n,r,limit,flag=0;
int main()
{
cin>>limit;
cin>>n;
for(int i=0;i<n;i++)
cin>>A[i];
for(int r=n;r>=1;r--)
{
int C[r];
combo(C,0,n,r);
if(flag)break;
}
delete A;
cout<<endl;
return 0;
}
static int k=0;
void append(int C[],int ch)
{
C[k]=ch;
k++;
}
void trunc(int C[])
{
k--;
}
static int ti=0,tlb=0;
void combo(int C[],int lb,int n,int r)
{
if(lb<=r)
{
for(int i=lb;i<=n;i++)
{
if((tlb<lb && ti<i) || (tlb>=lb && ti>=i))
{
append(C,n-1-i);
ti=i;tlb=lb;
combo(C,lb+1,n,r);
trunc(C);
}
}
}
else
{
int sum=0;
for(int i=0;i<r;i++)
sum+=A[C[i]];
if(sum<=limit)
{
cout<<r<<endl;
for(int i=r-1;i>=0;i--)cout<<C[i]<<" ";
cout<<endl;
flag=1;
exit(0);
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
62e55d4136d999086a97ed0cc5480a9b4f684c5f | 8e859efa45ad61f7fb018e1e946184e5114c760e | /math.cpp | ff5cabbf660d3e985cf2e78877c0ad9e23aa8ce9 | [] | no_license | SanyuktaSaha/data-structures | 63a143daa618de78391935f32c5d159b4dfd3539 | 70057cb166c606e4558c23747077fa8de9e9c004 | refs/heads/master | 2020-06-01T18:40:14.240127 | 2019-08-03T16:19:36 | 2019-08-03T16:19:36 | 190,886,411 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 769 | cpp | #include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t>0)
{
int n,sums=0,max=0;
cin>>n;
int crr[n];
for(int i=0;i<n;i++)
{
cin>>crr[i];
}
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
int ans = crr[i] * crr[j];
while(ans>0)
{
int dig = ans%10;
sums += dig;
ans /= 10;
}
if(sums>max)
{
max=sums;
}
sums=0;
}
}
cout<<max<<endl;
t--;
}
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
7e35ea6c5d4dd6f578d7af2cfdb052c20a19191b | 4fc3460cf6ba8b909ab702795d1a3edab3107fd0 | /ppate259_lab1/ppate259_lab1.ino | 8677cba02fb98d284fe59822821ad7ae740d14da | [] | no_license | priyam-patel/Arduino | 3e95d5ab5aaf0848b9fa27fe724741236625bfea | 10795d47c8969712000c7dc8e22330abcaf2e0f0 | refs/heads/master | 2021-07-04T12:31:40.908938 | 2017-09-25T16:33:06 | 2017-09-25T16:33:06 | 104,775,162 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,144 | ino | // Priyam Patel - 650675226
// Lab 1
// Description - Blink different LEDS at different times, and connect the board LED to pin 13
// I have made the assumption that these LEDs are naturally super bright because I only used a 220 resistor and they were still very bright
// References - Link posted on blackboard, arduino tutorials
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
// initialize pin 13 as an output.
pinMode(13, OUTPUT);
// initialize pin 3 as an output.
pinMode(3, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(300);
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
digitalWrite(10, HIGH); //now turn the pin associated with the RED LED ON
delay(300);
digitalWrite(10,LOW); //turn the red LED OFF
digitalWrite(3,HIGH); // turn the green LED ON
delay(300);
digitalWrite(3,LOW); //turn the green LED OFF
delay(300);
}
| [
"priyampatel@Priyams-MacBook-Pro.local"
] | priyampatel@Priyams-MacBook-Pro.local |
24bccb8a67aab3f181b9e82af4d9dfa3afaaa157 | 52ca17dca8c628bbabb0f04504332c8fdac8e7ea | /boost/spirit/home/classic/utility/grammar_def_fwd.hpp | d46550596b28d7e8f500efdc9345f4dfdd23dddf | [] | no_license | qinzuoyan/thirdparty | f610d43fe57133c832579e65ca46e71f1454f5c4 | bba9e68347ad0dbffb6fa350948672babc0fcb50 | refs/heads/master | 2021-01-16T17:47:57.121882 | 2015-04-21T06:59:19 | 2015-04-21T06:59:19 | 33,612,579 | 0 | 0 | null | 2015-04-08T14:39:51 | 2015-04-08T14:39:51 | null | UTF-8 | C++ | false | false | 89 | hpp | #include "thirdparty/boost_1_58_0/boost/spirit/home/classic/utility/grammar_def_fwd.hpp"
| [
"qinzuoyan@xiaomi.com"
] | qinzuoyan@xiaomi.com |
58d380052bb8a01f5813885b60d9e1d8bb9991f7 | c873eeeae6779ee6d4cd2f07821cd4741ed4cf60 | /pegasus/src/Pegasus/Server/EnumerationContextTable.cpp | 1f71dd63b968514faa4a735dd61cf7715cf1663b | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | rchateauneu/OpenPegasus | 46f026ed08f952064a8d8c31b9add3a9d496ac16 | cda54c82ef53fd00cd6be98b1d34518b51c823a4 | refs/heads/main | 2023-06-01T09:06:07.613096 | 2021-06-07T18:03:37 | 2021-06-07T18:03:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 33,281 | cpp | //%LICENSE////////////////////////////////////////////////////////////////
//
// Licensed to The Open Group (TOG) under one or more contributor license
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
// this work for additional information regarding copyright ownership.
// Each contributor licenses this file to you under the OpenPegasus Open
// Source License; you may not use this file except in compliance with the
// License.
//
// 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.
//
//////////////////////////////////////////////////////////////////////////
//
//%////////////////////////////////////////////////////////////////////////////
#include "EnumerationContextTable.h"
#include <Pegasus/Common/Mutex.h>
#include <Pegasus/Common/Time.h>
#include <Pegasus/Common/List.h>
#include <Pegasus/General/Guid.h>
#include <Pegasus/Common/CIMResponseData.h>
#include <Pegasus/Common/Condition.h>
#include <Pegasus/Common/Tracer.h>
#include <Pegasus/General/Stopwatch.h>
#include <Pegasus/Common/Thread.h>
#include <Pegasus/Server/EnumerationContext.h>
#include <Pegasus/Common/StringConversion.h>
#include <Pegasus/Common/IDFactory.h>
#include <Pegasus/Common/Constants.h>
#include <Pegasus/Config/ConfigManager.h>
// Used only for the single static function call to issueSavedResponses
#include <Pegasus/Server/CIMOperationRequestDispatcher.h>
#include <Pegasus/Server/CIMServer.h>
#include <Pegasus/ProviderManagerService/ProviderManagerService.h>
PEGASUS_USING_STD;
PEGASUS_NAMESPACE_BEGIN
// define conversion between sec and usec
#define PEG_MICROSEC 1000000
// General class to process various objects that are made up of Pegaus
// Strings back to the String and more directly to the const char* ...
// used for display. This can be used for
// String, CIMName, CIMNamespaceName, Exception, CIMDateTime, CIMObjectPath
// The same general class exists in several places in OpenPegasus.
// TODO: make this a general part of Pegasus so it is not duplicated in
// many different files.
class Str
{
public:
Str(const String& s) : _cstr(s.getCString()) { }
Str(const CIMName& n) : _cstr(n.getString().getCString()) { }
Str(const CIMNamespaceName& n) : _cstr(n.getString().getCString()) { }
Str(const Exception& e) : _cstr(e.getMessage().getCString()) { }
Str(const CIMDateTime& x) : _cstr(x.toString().getCString()) { }
Str(const CIMObjectPath& x) : _cstr(x.toString().getCString()) { }
const char* operator*() const { return (const char*)_cstr; }
operator const char*() const { return (const char*)_cstr; }
private:
CString _cstr;
};
// Definition of static variable that can be set by config manager
Uint32 EnumerationContextTable::_defaultOperationTimeoutSec =
PEGASUS_DEFAULT_PULL_OPERATION_TIMEOUT_SEC;
#ifndef PEGASUS_INTEGERS_BOUNDARY_ALIGNED
Mutex EnumerationContextTable::_defaultOperationTimeoutSecMutex;
#endif
// Define the table instance that will contain enumeration contexts for Open,
// Pull, Close, and countEnumeration operations. The default interoperation
// timeout and max cache size are set as part of creating the table.
//
// TODO FUTURE: There are several system parameters here that should be
// set globally. We need somewhere common to be able to define this and
// while it could be the config, it could also be a systemLimits file or
// something common.
#define PEGASUS_MAX_OPEN_ENUMERATE_CONTEXTS 256
// Define the maximum size for the response cache in each
// enumerationContext. As responses are returned from providers this is the
// maximum number that can be placed in the CIMResponseData cache waiting
// for pull operations to send them as responses before responses
// start backing up to the providers (i.e. delaying return from the provider
// deliver calls.
// FUTURE: As we develop more flexible resource management this value should
// be modified for each context creation in terms of the object sizes
// expected and the memory usage of the CIMServer. Thus, it would be
// logical to allow caching many more path responses than instance
// responses because they are probably much smaller.
// This variable is not externalized because we are not sure
// if that is logical.
#define PEGASUS_PULL_RESPONSE_CACHE_DEFAULT_MAX_SIZE 1000
Uint32 responseCacheDefaultMaximumSize =
PEGASUS_PULL_RESPONSE_CACHE_DEFAULT_MAX_SIZE;
EnumerationContextTable* EnumerationContextTable::pInstance = NULL;
// Thread execution function for timeoutThread(). This thread executes
// regular timeout tests on active contexts and closes them or marks them
// for close if timed out. This is required for those cases where a
// pull sequence is terminated without either completing or closing the
// sequence.
ThreadReturnType PEGASUS_THREAD_CDECL operationContextTimeoutThread(void* parm)
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,
"EnumerationContextTable::operationContextTimerThread");
Thread *myself = reinterpret_cast<Thread *>(parm);
EnumerationContextTable* et =
reinterpret_cast<EnumerationContextTable*>(myself->get_parm());
PEGASUS_DEBUG_ASSERT(et->valid());
Uint32 nextTimeoutMsec = et->getTimeoutIntervalMsec();
// execute loop at regular intervals until no more contexts or
// stop flag set
while (!et->_stopTimeoutThreadFlag.get() )
{
et->_timeoutThreadWaitSemaphore.time_wait(nextTimeoutMsec);
// true return indicates table empty which terminates loop.
if (et->processExpiredContexts())
{
break;
}
}
// reset the timeout value to indicate that the thread is quiting
et->_timeoutThreadRunningFlag = 0;
PEG_METHOD_EXIT();
return ThreadReturnType(0);
}
/************************************************************************
**
** Implementation of EnumerationContextTable Class
**
************************************************************************/
/*
Constructor. Note that the hashtable size is 1/2 the maximum number
of simultaneous open contexts. This was a guess based on notes in
the Hashtable code indicating that 1/3 might be logical choice.
*/
EnumerationContextTable::EnumerationContextTable()
:
_timeoutIntervalMsec(0),
// Defines the Context Hash table size as 1/2 the max number of entries
_enumContextTable(PEGASUS_MAX_OPEN_ENUMERATE_CONTEXTS / 2),
_operationContextTimeoutThread(operationContextTimeoutThread, this, true),
_responseCacheMaximumSize(PEGASUS_PULL_RESPONSE_CACHE_DEFAULT_MAX_SIZE),
_cacheHighWaterMark(0),
_responseObjectCountHighWaterMark(0),
_totalObjectsReturned(0),
_enumerationContextsOpened(0),
_enumerationsTimedOut(0),
_maxOpenContexts(0),
_maxOpenContextsLimit(PEGASUS_MAX_OPEN_ENUMERATE_CONTEXTS),
_highWaterRequestsPerSequence(0),
_totalRequestsPerSequence(0),
_sequencesClosed(0),
_requestedSize(0),
_requestCount(0),
_totalZeroLenDelayedResponses(0),
// Initial Value for ContextId counter. 500000 is arbitary
_contextIdCounter(500000)
{
// Setup the default value for the operation timeout value if the value
// received in a request is NULL. This is the server defined default.
ConfigManager* configManager = ConfigManager::getInstance();
_defaultOperationTimeoutSec = ConfigManager::parseUint32Value(
configManager->getCurrentValue("pullOperationsDefaultTimeout"));
}
// Create the singleton instance of the enumerationContextTable and return
// pointer to that instance. If created, return pointer to existing singleton
// instance
EnumerationContextTable* EnumerationContextTable::getInstance()
{
if (!pInstance)
{
pInstance = new EnumerationContextTable();
}
return pInstance;
}
/* Remove all contexts and delete them. Only used on system shutdown.
*/
EnumerationContextTable::~EnumerationContextTable()
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,
"EnumerationContextTable::~EnumerationContextTable");
_stopTimeoutThread();
// Show shutdown statistics for EnumerationContextTable
displayStatistics();
removeContextTable();
PEG_METHOD_EXIT();
}
/*
Create a new context entry and return it. This includes information
required to process the pull and close operations for the enumeration
sequence controlled by this context. The context instance will remain
active for the life of the enumeration sequence.
Returns pointer to the new context except if:
- Size exceeds system limit.
*/
EnumerationContext* EnumerationContextTable::createContext(
const CIMOpenOperationRequestMessage* request,
MessageType pullRequestType,
CIMResponseData::ResponseDataContent contentType)
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,"EnumerationContextTable::createContext");
AutoMutex autoMut(_tableLock);
// Test for Max Number of simultaneous contexts.
if (_enumContextTable.size() > _maxOpenContextsLimit)
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL1,
"Error EnumerationContext Table exceeded Max limit of %u",
_maxOpenContextsLimit));
return NULL;
}
// set the operation timeout to either the default or current
// value
Uint32 operationTimeout = (request->operationTimeout.isNull())?
_defaultOperationTimeoutSec
:
request->operationTimeout.getValue();
// Create new contextId
Uint32 rtnSize;
char scratchBuffer[22];
const char* contextId = Uint32ToString(scratchBuffer,
_getNextId(), rtnSize);
// Create new context, Context name is monolithically increasing counter.
EnumerationContext* en = new EnumerationContext(contextId,
request->nameSpace,
operationTimeout,
request->continueOnError,
pullRequestType,
contentType);
// Set the maximum size for the response Cache from the default
// value in the table. This is for future where we could adjust the
// size dynamically for each operation depending on resource utilization.
// or expected response sizes (ex. paths vs instances)
en->_responseCacheMaximumSize = _responseCacheMaximumSize;
// Pointer back to this object
en->_enumerationContextTable = this;
// insert new context into the table. Failure to insert is a
// system failure
if(!_enumContextTable.insert(contextId, en))
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL1,
"Error Creating Enumeration Context ContextId=%s. System Failed",
contextId ));
PEGASUS_ASSERT(false); // This is a system failure
}
_enumerationContextsOpened++;
// set new highwater mark for maxOpenContexts if necessary
if (_enumContextTable.size() >_maxOpenContexts )
{
_maxOpenContexts = _enumContextTable.size();
}
PEG_METHOD_EXIT();
return en;
}
void EnumerationContextTable::displayStatistics(bool clearStats)
{
// Show statistics for EnumerationContextTable
// Should add avg size of requests. Maybe some other info.
cout << buildStatistics(clearStats) << endl;
}
// build a string with the statistics info.
String EnumerationContextTable::buildStatistics(bool clearStats)
{
String str;
AutoMutex autoMut(_tableLock);
if (_enumerationContextsOpened != 0)
{
str.appendPrintf("EnumerationTable Statistics:"
"\n EnumerationCache highwater mark=%u"
"\n Max simultaneous enumerations=%u"
"\n Total enumerations opened=%llu",
_cacheHighWaterMark,
_maxOpenContexts,
_enumerationContextsOpened);
str.appendPrintf(
"\n Enumerations timed out=%u"
"\n Current open enumerations=%u"
"\n Avg request maxObjectCount=%u"
"\n Max objects/response=%u"
"\n Avg objects/response=%u"
"\n Avg requests/sequence=%u"
"\n Max requests/sequence=%u",
_enumerationsTimedOut,
size(),
_getAvgRequestSize(),
_responseObjectCountHighWaterMark,
_getAvgResponseSize(),
_getAvgRequestsPerSequence(),
_highWaterRequestsPerSequence);
str.appendPrintf(
"\n Total zero Length delayed responses=%llu",
_totalZeroLenDelayedResponses);
}
if (clearStats)
{
_cacheHighWaterMark = 0;
_maxOpenContexts = 0;
_enumerationContextsOpened = 0;
_enumerationsTimedOut = 0;
_requestCount = 0;
_requestedSize = 0;
_responseObjectCountHighWaterMark = 0;
_totalZeroLenDelayedResponses = 0;
_totalObjectsReturned = 0;
_totalRequestsPerSequence = 0;
_highWaterRequestsPerSequence = 0;
_sequencesClosed = 0;
}
return str;
}
void EnumerationContextTable::removeContextTable()
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,
"EnumerationContextTable::removeContextTable");
AutoMutex autoMut(_tableLock);
// Clear out any existing enumerations.
for (EnumContextTableType::Iterator i = _enumContextTable.start(); i; i++)
{
EnumerationContext* en = i.value();
PEG_TRACE(( TRC_ENUMCONTEXT, Tracer::LEVEL4,
"EnumerationTable Delete. "
" ContextId=%s. Existed for %llu milliseconds",
*Str(en->getContextId()),
((TimeValue::getCurrentTime().toMilliseconds()
- en->_startTimeUsec)/1000) ));
delete en;
}
_enumContextTable.clear();
PEG_METHOD_EXIT();
}
bool EnumerationContextTable::releaseContext(EnumerationContext* en)
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,"EnumerationContextTable::releaseContext");
AutoMutex autoMut(_tableLock);
PEGASUS_DEBUG_ASSERT(valid());
PEGASUS_DEBUG_ASSERT(en->valid());
String contextId = en->getContextId();
en->unlockContext();
// Check to assure that the context ID is in the table.
if (!find(contextId))
{
PEG_METHOD_EXIT();
return false;
}
_removeContext(en);
PEG_METHOD_EXIT();
return true;
}
// Private remove function with no lock protection. The _tableLock must
// be set before this function is called to protect the table. This
// removes the context from the context table.
// Boolean return: Returns false if attempt to remove context that is
// not closed and providers complete. However, for now it then asserts since
// this is really an internal failure.
bool EnumerationContextTable::_removeContext(EnumerationContext* en)
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,"EnumerationContextTable::_removeContext");
PEGASUS_DEBUG_ASSERT(en->valid());
// If context is valid and providers are complete, remove
// the enumerationContext. If providers not complete, only
// completion of provider deliveries can initiate removal of
// the enumeration context.
// Any functions that set _ClientClosed and _ProvidersComplete
// must insure that they block until finished with context.
if (en->_clientClosed && en->_providersComplete)
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL3,
"EnumerationContext Remove. ContextId=%s",
*Str(en->getContextId()) ));
//// KS_TODO Remove this trace output.
en->trace();
// Should never get here with _savedRequest NULL. Choice was to
// release or assert during tests.
PEGASUS_DEBUG_ASSERT(en->_savedRequest == NULL);
// test/set the highwater mark for the table
// KS_TODO confirm that statistics below always get accumulated
if (en->_cacheHighWaterMark > _cacheHighWaterMark)
{
_cacheHighWaterMark = en->_cacheHighWaterMark;
}
if (en->_responseObjectsCount > _responseObjectCountHighWaterMark)
{
_responseObjectCountHighWaterMark = en->_responseObjectsCount;
}
if (en->_requestCount > _highWaterRequestsPerSequence)
{
_highWaterRequestsPerSequence = en->_requestCount;
}
_totalObjectsReturned += en->_responseObjectsCount;
_totalZeroLenDelayedResponses+= en->_totalZeroLenObjectResponseCounter;
_totalRequestsPerSequence += en->_requestCount;
_sequencesClosed++;
_enumContextTable.remove(en->getContextId());
delete en;
PEG_METHOD_EXIT();
return true;
}
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL3,
"EnumerationContext Remove Ignored. ContextId=%s not complete.",
*Str(en->getContextId()) ));
en->trace();
// This assert is part of testing. KS_TODO Remove before release
PEGASUS_DEBUG_ASSERT(false);
PEG_METHOD_EXIT();
return false;
}
// Get the number of entries in the hash table of EnumerationContexts.
Uint32 EnumerationContextTable::size()
{
AutoMutex autoMut(_tableLock);
return(_enumContextTable.size());
}
// If context name found, return pointer to that context. Otherwise
// return 0
EnumerationContext* EnumerationContextTable::find(const String& contextId)
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT, "EnumerationContextTable::find");
AutoMutex autoMut(_tableLock);
EnumerationContext* en = 0;
if(_enumContextTable.lookup(contextId, en))
{
PEGASUS_DEBUG_ASSERT(en->valid());
}
// Return pointer or pointer = 0 if not found.
PEG_METHOD_EXIT();
return en;
}
/* Test all table entries and remove the ones timed out.
Returns true if the enumeration table is empty when finished.
*/
bool EnumerationContextTable::processExpiredContexts()
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,
"EnumerationContextTable::processExpiredContexts");
PEGASUS_DEBUG_ASSERT(valid());
if (size() == 0)
{
PEG_METHOD_EXIT();
return true;
}
//Timed out entry context Ids will be placed in one of these lists for
// processing so we do not remove entries from table while processing
// The cleanActiveList is also processed after the table lock is removed.
Array<String> removeList;
Array<String> cleanActiveList;
Uint64 currentTimeUsec = System::getCurrentTimeUsec();
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"processExpiredContexts Start table size=%u", size() ));
// Lock the EnumerationContextTable so no operations can be accepted
// during the scan process
{ /// Context for automutex
AutoMutex autoMut(_tableLock);
// Search enumeration table for entries timed out. Sets any entries
// that have timed out into a secondary lists for processing
for (EnumContextTableType::Iterator i = _enumContextTable.start();i;i++)
{
EnumerationContext* en = i.value();
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"Timeout Scan Processing ContextId=%s",
*Str(en->getContextId()) ));
//// KS_TODO temporary trace. Remove before release
en->trace();
PEGASUS_DEBUG_ASSERT(en->valid()); // diagnostic. KS_TEMP
if (en->valid())
{
if (en->_operationTimerUsec != 0)
{
// Only set lock if there is a chance the timer is active.
// redoes the above test after setting lock. Bypass this
// enumerationContext if locked
if (en->tryLockContext())
{
// test if entry is timed out
if (en->isTimedOut(currentTimeUsec))
{
en->stopTimer();
// if active wait for provider timeout then send
// saved response. This restarts timer
if (en->isProcessing())
{
// KS_TODO temp test. This should always
// be true.
PEGASUS_DEBUG_ASSERT(!en->isClientClosed());
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"Timeout while IsProcessing ContextId=%s",
*Str(en->getContextId()) ));
cleanActiveList.append(
en->getContextId());
}
// Otherwise this is the interoperation timer
// Close client and cleanup based on whether
// providers are complete
else
{
// set ClientClosed since there has been an
// interoperation timeout
en->setClientClosed();
// If providers are complete we can remove the
// context.
if (en->providersComplete())
{
PEG_TRACE((TRC_DISPATCHER, Tracer::LEVEL4,
"TimeoutProvidersComplete ContextId=%s",
*Str(en->getContextId())));
removeList.append(en->getContextId());
}
// Providers not complete but client is closed
// This kicks off cleanup effort as well as
// signal to be sure providers continue to
// deliver responses.
else
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"Timeout Providers NOTComplete "
"ContextId=%s",
*Str(en->getContextId()) ));
en->signalProviderWaitCondition();
cleanActiveList.append(en->getContextId());
}
}
}
else // not timed out
{
en->unlockContext();
}
} // end trylock
} // end timer != 0
} // en not valid
else
{
PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
"Invalid EnumerationContext discarded, ContextId=%s"
" Ignored", *Str(en->getContextId()) ));
// KS_TODO should we consider trying to remove the invalid
// entry?
}
} // end for loop
// remove any contexts in the remove list. This should be only
// contexts with client closed and providers complete
for (Uint32 i = 0; i < removeList.size(); i++)
{
// unlock before removing the context
EnumerationContext* en = find(removeList[i]);
PEGASUS_DEBUG_ASSERT(en->valid());
_enumerationsTimedOut++;
en->unlockContext();
_removeContext(en);
}
} // release the EnumerationContextTable lock
// Process entries in the cleanActiveList. At this point
// the table is unlocked but all contexts in this list are locked
// These are all entries for which the providers are incomplete
// but not responding.
// This may be either:
// - Client open Entries for which the zero len saved response is
// sent
// - Client closed entries where the provider chaing
// should be kicked or closed.
for (Uint32 i = 0; i < cleanActiveList.size(); i++)
{
// recheck by finding, validating and checking EnumerationContext
// state again
//
EnumerationContext* en = find(cleanActiveList[i]);
PEGASUS_DEBUG_ASSERT(en->valid());
// clean up one context
_cleanActiveContext(en);
}
PEG_METHOD_EXIT();
// Return true if table is now empty.
return (size() == 0);
}
// Attempt to clean up the enumerationContext provided.
// Assumes the context is locked when called.
// If client open, issue any saved response and test for consecutive
// retries that pass the defined limits.
// Consecutive resends of Zero Len responses >
// PEGASUS_MAX_CONSECUTIVE_WAITS_BEFORE_ERR
// results in setting the providers closed and issuing message.
//
// After 4 of these messages sent, just close the enumeration.
//
// If client closed, start timer and do the consecutive resend tests
// to see if the provider should just be closed.
void EnumerationContextTable::_cleanActiveContext(EnumerationContext* en)
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,
"EnumerationContextTable::cleanActiveContext");
// Increment the counter for sending zero length responses to the
// client. Used to determine when providers stuck incomplete
Uint32 ctr = en->incConsecutiveZeroLenObjectResponseCounter();
Uint32 targetCount = PEGASUS_MAX_CONSECUTIVE_WAITS_BEFORE_ERR;
Uint32 finalTargetCount = targetCount + 3;
// If past final target count, set providers complete so we issue
// next msg with EOS set. That closes the client. At this
// point we have given up completely on the providers but are trying
// to send the last message to the client
if (ctr >= finalTargetCount)
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"IssueSaveResponseList Set ProvidersComplete "
"ContextId=%s ctr=%u finalTargetCount=%u",
*Str(en->getContextId()), ctr, finalTargetCount));
en->setProvidersComplete();
// Set an error.
CIMException e = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
"Provider Responses Failed.");
// Force continueOnError to false since we
// really do want to close the client
en->setContinueOnError(false);
en->setErrorState(e);
}
// If client not closed, issue an empty response to the dispatcher.
// Otherwise just restart timer to timeout providers
// Set the count to zero so can issue with no responses in
// cache.
en->_savedOperationMaxObjectCount = 0;
if (!en->isClientClosed())
{
PEGASUS_DEBUG_ASSERT(en->isProcessing());
CIMOperationRequestDispatcher::issueSavedResponse(en);
}
else
{
if (!en->providersComplete())
{
// restart timer to time cleanup of providers
en->startTimer(PEGASUS_PULL_MAX_OPERATION_WAIT_SEC * PEG_MICROSEC);
}
}
// Repeat test after issuing saved response.
// If we have tried the clean up several times and it did not work,
// discard the enumeration context. We just picked the number 4
// as the number of retries for the cleanup before we close the
// whole thing as broken.
if (ctr >= finalTargetCount)
{
PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
"Enumeration Context removed after providers did not"
"respond for at least %u min. ContextId=%s",
((finalTargetCount * PEGASUS_PULL_MAX_OPERATION_WAIT_SEC)/60),
*Str(en->getContextId()) ));
en->setClientClosed();
en->unlockContext();
_removeContext(en);
PEG_METHOD_EXIT();
return;
}
// The initial test and cleanup. Started at targetCount and
// repeated at least 3 times before we discard the provider
// This calls the providerManager cleanup assuming that
// providers have stopped delivering without sending the
// complete flag.
if (ctr >= targetCount)
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"%u Consecutive 0 length responses issued for ContextId=%s"
" Issuing provider cleanup.",
ctr, *Str(en->getContextId()) ));
// send cleanup message to provider manager. Need pointer to
// this service.
CIMServer * cimserver = CIMServer::getInstance();
// Ignore false return
cimserver->_providerManager->enumerationContextCleanup(
en->getContextId());
en->unlockContext();
}
else
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"%u Consecutive 0 length responses issued for ContextId=%s",
ctr, *Str(en->getContextId()) ));
en->unlockContext();
}
PEG_METHOD_EXIT();
}
// Validate every entry in the table.This is a diagnostic that should only
// be used in testing changes during development.
#ifdef ENUMERATIONTABLE_DEBUG
void EnumerationContextTable::tableValidate()
{
AutoMutex autoMut(_tableLock);
for (EnumContextTableType::Iterator i = _enumContextTable.start(); i;
i++)
{
EnumerationContext* en = i.value();
if (!en->valid())
{
en->trace();
PEGASUS_DEBUG_ASSERT(en->valid());
}
}
}
#endif
// interval is the timeout for the current operation that
// initiated this call. It helps the timer thread decide how often
// to scan for timeouts.
void EnumerationContextTable::dispatchTimerThread()
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,
"EnumerationContextTable::dispatchTimerThread");
PEGASUS_DEBUG_ASSERT(valid());
AutoMutex autoMut(_tableLock);
// If timeout thread not running, start it
if (_timeoutThreadRunningFlag.get() == 0)
{
// convert second timer to milliseconds and set it for double
// the input defined interval. Set for the timer thread to
// loop through the table every PEGASUS_PULL_MAX_OPERATION_WAIT_SEC
// seconds.
_timeoutIntervalMsec = PEGASUS_PULL_MAX_OPERATION_WAIT_SEC*1000;
// Start the detached thread to execute the timeout tests.
// Thread runs until the timer is cleared or there are
// no more contexts.
if (_operationContextTimeoutThread.run() != PEGASUS_THREAD_OK)
{
MessageLoaderParms parms(
"Server.EnumerationContextTable.THREAD_ERROR",
"Failed to start pull operation timer thread.");
Logger::put_l(
Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
parms);
PEGASUS_DEBUG_ASSERT(false); // This is system failure
}
_timeoutThreadRunningFlag++;
}
PEG_METHOD_EXIT();
}
void EnumerationContextTable::_stopTimeoutThread()
{
PEG_METHOD_ENTER(TRC_ENUMCONTEXT,
"EnumerationContextTable::_stopTimeoutThread");
PEGASUS_DEBUG_ASSERT(valid());
if (_timeoutThreadRunningFlag.get() != 0)
{
_stopTimeoutThreadFlag++;
_timeoutThreadWaitSemaphore.signal();
while (_timeoutThreadRunningFlag.get())
{
Threads::yield();
Threads::sleep(PEGASUS_PULL_MAX_OPERATION_WAIT_SEC);
}
}
PEG_TRACE_CSTRING(TRC_ENUMCONTEXT, Tracer::LEVEL4,
"EnumerationContextTable timeout thread stopped");
PEG_METHOD_EXIT();
}
void EnumerationContextTable::setDefaultOperationTimeoutSec(Uint32 seconds)
{
#ifndef PEGASUS_INTEGERS_BOUNDARY_ALIGNED
AutoMutex lock(_defaultOperationTimeoutSecMutex);
#endif
_defaultOperationTimeoutSec = seconds;
}
void EnumerationContextTable::trace()
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"EnumerationContextTable Trace. size=%u", _enumContextTable.size()));
AutoMutex autoMut(_tableLock);
for (EnumContextTableType::Iterator i = _enumContextTable.start(); i; i++)
{
PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
"ContextTable Entry: key [%s]",
(const char*)i.key().getCString() ));
EnumerationContext* enumeration = i.value();
enumeration->trace();
}
}
PEGASUS_NAMESPACE_END
| [
"k.schopmeyer@swbell.net"
] | k.schopmeyer@swbell.net |
48a84d38501e3b267000f534b309e79d0aa91d53 | 6c3c2ec43e3a8210c275dc45abdfcaf606bba9c8 | /include/genreg_agent.hh | e7b66eba1c90ea69d6efcf23e1714997a67f9494 | [] | no_license | antoncrombach/gene-network-evolvability | a42aebdfca6c98c6af5d8292eecc24ca242de7e6 | 4d4c46e2bbdbb7802158372b24055eea200e695d | refs/heads/master | 2021-01-12T08:00:21.953630 | 2016-12-21T21:00:31 | 2016-12-21T21:00:31 | 77,085,667 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,924 | hh | //
// Interface of a simple agent with a genome and network.
//
// by Anton Crombach, A.B.M.Crombach at uu.nl
//
#ifndef _BLOWHOLE_GENREGAGENT_H_
#define _BLOWHOLE_GENREGAGENT_H_
#include "defs.hh"
#include "agent.hh"
#include "genome.hh"
#include "hop_graph.hh"
namespace blowhole {
/// \class GenRegAgent
/// \brief Slowly including genome and network.
class GenRegAgent : public Agent {
public:
struct ParentInfo {
int size_;
int distance_;
};
public:
/// Init
virtual void initialise();
/// Perform one timestep. It consists of checking whether the
/// agent dies or survives another timestep.
/*virtual void step( Population & );*/
/// Reproduce. The sibling has its age reset to zero.
/*virtual Agent* sibling();*/
/// Set the genome (rebuild network?)
void genome( Genome * );
/// Get the genome
const Genome* genome() const;
/// Get the network
const HopfieldGraph* network() const;
/// Get the score of a \c GenRegAgent
virtual double score() const;
/// Evaluate network and calculate new attractor
/*virtual void evaluate( const Environment & );*/
/// Get genotypical distance to target
int distance() const;
/// Write a text representation of the agent to an output stream.
/*virtual void writeXml( std::ostream & ) const;*/
/// Set if we read the thing from file
void readFromFile( bool );
/// Get a few mutation counters
std::vector< uint > nrMutations() const;
/// Get size difference with parent
int deltaSize() const;
/// Get genotype distance difference with parent
int deltaDistance() const;
protected:
/// Default ctor.
GenRegAgent();
/// Ctor.
GenRegAgent( uint );
/// Ctor.
GenRegAgent( uint, Genome *g );
/// Copy ctor.
GenRegAgent( const GenRegAgent & );
/// Destructor.
virtual ~GenRegAgent();
/// Cloning an agent.
/*virtual Agent* clone() const;*/
/// Copy the agent into \c this
virtual void copy( const Agent & );
public:
/// Set death rate of agent
static void deathRate( double );
/// Get death rate of agent
static double deathRate();
/// Set maximum distance
static void maxDistance( int );
/// Get maximum distance
static int maxDistance();
/// Set max genome size, after which a penalty is applied
static void maxGenomeSize( int );
/// Set max # retroposons, after which a penalty is applied
static void maxTposons( int );
/// Set penalty per unit over the max size/number
static void genomePenaltyRate( double );
/// Set penalty per retroposon too much
static void retroposonPenaltyRate( double );
/// Set initial state of network
static void initialState( const boost::dynamic_bitset<> & );
/// Set environmental sensor
static void sensor( int );
protected:
/// Score (birth rate) of a \c SimpleAgent.
double score_;
/// Raw score aka distance to attractor
int distance_;
/// Genome
Genome *genome_;
/// Regulatory network
HopfieldGraph *network_;
/// Parent info
ParentInfo parent_;
/// Flag for network init
bool read_from_file_;
protected:
/// Death rate
static double death_rate_;
/// Maximum distance we look at
static int max_dist_;
/// Penalty if genome size is greater
static int penalty_genome_;
/// Penalty if more retroposons than allowed
static int penalty_tposons_;
/// Penalty coefficient for genome
static double penalty_genome_rate_;
/// Penalty coefficient for retroposon
static double penalty_tposons_rate_;
/// Initial state of network
static boost::dynamic_bitset<> init_state_;
/// Environmental sensor
static int env_bit_;
};
inline const Genome* GenRegAgent::genome() const
{ return genome_; }
inline const HopfieldGraph* GenRegAgent::network() const
{ return network_; }
inline int GenRegAgent::distance() const
{ return distance_; }
inline int GenRegAgent::deltaDistance() const
{ return distance_ - parent_.distance_; }
inline int GenRegAgent::deltaSize() const
{ return genome_->length() - parent_.size_; }
inline std::vector< uint > GenRegAgent::nrMutations() const
{ return genome_->nrMutations(); }
inline void GenRegAgent::readFromFile( bool b )
{ read_from_file_ = b; }
}
#endif
| [
"anton.crombach@gmail.com"
] | anton.crombach@gmail.com |
10614f296448accf366daea36c5bb09509aa2bb9 | a1fbf16243026331187b6df903ed4f69e5e8c110 | /cs/sdk/3d_sdk/3dsmax/ver-6.0/samples/impexp/vrmlexp/anchorob.cpp | d9e0e669126cc853c8fb0719cb0e2c8afa040299 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | OpenXRay/xray-15 | ca0031cf1893616e0c9795c670d5d9f57ca9beff | 1390dfb08ed20997d7e8c95147ea8e8cb71f5e86 | refs/heads/xd_dev | 2023-07-17T23:42:14.693841 | 2021-09-01T23:25:34 | 2021-09-01T23:25:34 | 23,224,089 | 64 | 23 | NOASSERTION | 2019-04-03T17:50:18 | 2014-08-22T12:09:41 | C++ | UTF-8 | C++ | false | false | 21,207 | cpp | mesh.setNumVerts(86);
mesh.setNumFaces(133);
mesh.setVert(0, size * Point3(-0.707107,0.707107,0.000000));
mesh.setVert(1, size * Point3(0.000000,0.707107,0.000000));
mesh.setVert(2, size * Point3(0.707107,0.707107,0.000000));
mesh.setVert(3, size * Point3(-0.707107,-0.707107,0.000000));
mesh.setVert(4, size * Point3(0.000000,-0.707107,0.000000));
mesh.setVert(5, size * Point3(0.707107,-0.707107,0.000000));
mesh.setVert(6, size * Point3(0.707107,-0.000000,0.000000));
mesh.setVert(7, size * Point3(0.000000,0.000000,-0.669280));
mesh.setVert(8, size * Point3(-0.707107,-0.000000,0.000000));
mesh.setVert(9, size * Point3(0.000000,-0.000000,0.669281));
mesh.setVert(10, size * Point3(-0.067799,0.004578,0.179988));
mesh.setVert(11, size * Point3(-0.067799,0.004578,0.158638));
mesh.setVert(12, size * Point3(-0.067799,0.023067,0.190663));
mesh.setVert(13, size * Point3(-0.067799,-0.013912,0.190663));
mesh.setVert(14, size * Point3(0.060300,0.004578,0.158638));
mesh.setVert(15, size * Point3(0.060300,0.023067,0.190663));
mesh.setVert(16, size * Point3(0.060300,-0.013912,0.190663));
mesh.setVert(17, size * Point3(0.060300,0.004578,0.179988));
mesh.setVert(18, size * Point3(0.071282,0.004578,0.159154));
mesh.setVert(19, size * Point3(0.092632,0.004578,0.159154));
mesh.setVert(20, size * Point3(0.060607,0.023067,0.159154));
mesh.setVert(21, size * Point3(0.060607,-0.013912,0.159154));
mesh.setVert(22, size * Point3(0.092632,0.004578,0.287253));
mesh.setVert(23, size * Point3(0.060607,0.023067,0.287253));
mesh.setVert(24, size * Point3(0.060607,-0.013912,0.287253));
mesh.setVert(25, size * Point3(0.071282,0.004578,0.287253));
mesh.setVert(26, size * Point3(-0.089926,0.004578,0.159154));
mesh.setVert(27, size * Point3(-0.068576,0.004578,0.159154));
mesh.setVert(28, size * Point3(-0.100601,0.023067,0.159154));
mesh.setVert(29, size * Point3(-0.100601,-0.013912,0.159154));
mesh.setVert(30, size * Point3(-0.068576,0.004578,0.287253));
mesh.setVert(31, size * Point3(-0.100601,0.023067,0.287253));
mesh.setVert(32, size * Point3(-0.100601,-0.013912,0.287253));
mesh.setVert(33, size * Point3(-0.089926,0.004578,0.287253));
mesh.setVert(34, size * Point3(-0.067799,0.004578,0.276507));
mesh.setVert(35, size * Point3(-0.067799,0.004578,0.255158));
mesh.setVert(36, size * Point3(-0.067799,0.023067,0.287182));
mesh.setVert(37, size * Point3(-0.067799,-0.013912,0.287182));
mesh.setVert(38, size * Point3(0.060300,0.004578,0.255158));
mesh.setVert(39, size * Point3(0.060300,0.023067,0.287182));
mesh.setVert(40, size * Point3(0.060300,-0.013912,0.287182));
mesh.setVert(41, size * Point3(0.060300,0.004578,0.276507));
mesh.setVert(42, size * Point3(-0.139594,0.000763,-0.317768));
mesh.setVert(43, size * Point3(-0.162003,-0.024752,-0.363064));
mesh.setVert(44, size * Point3(-0.162006,0.026279,-0.362958));
mesh.setVert(45, size * Point3(0.131235,0.000763,-0.317768));
mesh.setVert(46, size * Point3(0.151744,-0.024752,-0.362591));
mesh.setVert(47, size * Point3(0.151751,0.026279,-0.362768));
mesh.setVert(48, size * Point3(0.291033,0.002180,-0.141779));
mesh.setVert(49, size * Point3(0.266898,0.002180,-0.124880));
mesh.setVert(50, size * Point3(0.303100,-0.023335,-0.150228));
mesh.setVert(51, size * Point3(0.303100,0.027696,-0.150228));
mesh.setVert(52, size * Point3(-0.298223,0.002180,-0.141779));
mesh.setVert(53, size * Point3(-0.274089,0.002180,-0.124880));
mesh.setVert(54, size * Point3(-0.310290,-0.023335,-0.150228));
mesh.setVert(55, size * Point3(-0.310290,0.027696,-0.150228));
mesh.setVert(56, size * Point3(0.332890,0.001836,-0.068190));
mesh.setVert(57, size * Point3(0.269500,0.002000,-0.114236));
mesh.setVert(58, size * Point3(0.311302,0.002000,-0.143506));
mesh.setVert(59, size * Point3(0.222103,0.137307,-0.226411));
mesh.setVert(60, size * Point3(0.186662,0.101105,-0.232541));
mesh.setVert(61, size * Point3(0.228464,0.101105,-0.261811));
mesh.setVert(62, size * Point3(0.212410,0.113172,-0.240254));
mesh.setVert(63, size * Point3(0.222190,-0.133634,-0.226286));
mesh.setVert(64, size * Point3(0.186750,-0.097432,-0.232415));
mesh.setVert(65, size * Point3(0.228552,-0.097432,-0.261686));
mesh.setVert(66, size * Point3(0.212497,-0.109499,-0.240129));
mesh.setVert(67, size * Point3(-0.340770,0.001836,-0.068190));
mesh.setVert(68, size * Point3(-0.277380,0.002000,-0.114236));
mesh.setVert(69, size * Point3(-0.319182,0.002000,-0.143506));
mesh.setVert(70, size * Point3(-0.229983,0.137307,-0.226411));
mesh.setVert(71, size * Point3(-0.194542,0.101105,-0.232541));
mesh.setVert(72, size * Point3(-0.236344,0.101105,-0.261811));
mesh.setVert(73, size * Point3(-0.220290,0.113172,-0.240254));
mesh.setVert(74, size * Point3(-0.230070,-0.133634,-0.226286));
mesh.setVert(75, size * Point3(-0.194630,-0.097432,-0.232415));
mesh.setVert(76, size * Point3(-0.236432,-0.097432,-0.261686));
mesh.setVert(77, size * Point3(-0.220377,-0.109499,-0.240129));
mesh.setVert(78, size * Point3(-0.008097,0.004578,-0.314628));
mesh.setVert(79, size * Point3(0.021366,0.004578,-0.314628));
mesh.setVert(80, size * Point3(-0.022829,0.030093,-0.314628));
mesh.setVert(81, size * Point3(-0.022829,-0.020938,-0.314628));
mesh.setVert(82, size * Point3(0.021366,0.004578,0.156776));
mesh.setVert(83, size * Point3(-0.022829,0.030093,0.156776));
mesh.setVert(84, size * Point3(-0.022829,-0.020938,0.156776));
mesh.setVert(85, size * Point3(-0.008097,0.004578,0.156776));
mesh.faces[0].setVerts(7,8,1);
mesh.faces[0].setEdgeVisFlags(1,1,1);
mesh.faces[0].setSmGroup(20);
mesh.faces[1].setVerts(7,6,4);
mesh.faces[1].setEdgeVisFlags(1,1,1);
mesh.faces[1].setSmGroup(20);
mesh.faces[2].setVerts(4,8,7);
mesh.faces[2].setEdgeVisFlags(1,1,1);
mesh.faces[2].setSmGroup(0);
mesh.faces[3].setVerts(6,7,4);
mesh.faces[3].setEdgeVisFlags(1,1,1);
mesh.faces[3].setSmGroup(0);
mesh.faces[4].setVerts(7,1,6);
mesh.faces[4].setEdgeVisFlags(1,1,1);
mesh.faces[4].setSmGroup(0);
mesh.faces[5].setVerts(8,7,1);
mesh.faces[5].setEdgeVisFlags(1,1,1);
mesh.faces[5].setSmGroup(0);
mesh.faces[6].setVerts(8,9,1);
mesh.faces[6].setEdgeVisFlags(1,1,0);
mesh.faces[6].setSmGroup(20);
mesh.faces[7].setVerts(6,9,4);
mesh.faces[7].setEdgeVisFlags(1,1,0);
mesh.faces[7].setSmGroup(20);
mesh.faces[8].setVerts(8,4,9);
mesh.faces[8].setEdgeVisFlags(1,1,1);
mesh.faces[8].setSmGroup(0);
mesh.faces[9].setVerts(6,9,4);
mesh.faces[9].setEdgeVisFlags(1,1,1);
mesh.faces[9].setSmGroup(0);
mesh.faces[10].setVerts(1,9,6);
mesh.faces[10].setEdgeVisFlags(1,1,1);
mesh.faces[10].setSmGroup(0);
mesh.faces[11].setVerts(8,9,1);
mesh.faces[11].setEdgeVisFlags(1,1,1);
mesh.faces[11].setSmGroup(0);
mesh.faces[12].setVerts(8,1,9);
mesh.faces[12].setEdgeVisFlags(1,1,1);
mesh.faces[12].setSmGroup(0);
mesh.faces[13].setVerts(10,12,11);
mesh.faces[13].setEdgeVisFlags(0,1,0);
mesh.faces[13].setSmGroup(1);
mesh.faces[14].setVerts(10,13,12);
mesh.faces[14].setEdgeVisFlags(0,1,0);
mesh.faces[14].setSmGroup(1);
mesh.faces[15].setVerts(10,11,13);
mesh.faces[15].setEdgeVisFlags(0,1,0);
mesh.faces[15].setSmGroup(1);
mesh.faces[16].setVerts(11,15,14);
mesh.faces[16].setEdgeVisFlags(0,1,1);
mesh.faces[16].setSmGroup(8);
mesh.faces[17].setVerts(11,12,15);
mesh.faces[17].setEdgeVisFlags(1,1,0);
mesh.faces[17].setSmGroup(8);
mesh.faces[18].setVerts(12,16,15);
mesh.faces[18].setEdgeVisFlags(0,1,1);
mesh.faces[18].setSmGroup(8);
mesh.faces[19].setVerts(12,13,16);
mesh.faces[19].setEdgeVisFlags(1,1,0);
mesh.faces[19].setSmGroup(8);
mesh.faces[20].setVerts(13,14,16);
mesh.faces[20].setEdgeVisFlags(0,1,1);
mesh.faces[20].setSmGroup(8);
mesh.faces[21].setVerts(13,11,14);
mesh.faces[21].setEdgeVisFlags(1,1,0);
mesh.faces[21].setSmGroup(8);
mesh.faces[22].setVerts(17,14,15);
mesh.faces[22].setEdgeVisFlags(0,1,0);
mesh.faces[22].setSmGroup(1);
mesh.faces[23].setVerts(17,15,16);
mesh.faces[23].setEdgeVisFlags(0,1,0);
mesh.faces[23].setSmGroup(1);
mesh.faces[24].setVerts(17,16,14);
mesh.faces[24].setEdgeVisFlags(0,1,0);
mesh.faces[24].setSmGroup(1);
mesh.faces[25].setVerts(18,20,19);
mesh.faces[25].setEdgeVisFlags(0,1,0);
mesh.faces[25].setSmGroup(1);
mesh.faces[26].setVerts(18,21,20);
mesh.faces[26].setEdgeVisFlags(0,1,0);
mesh.faces[26].setSmGroup(1);
mesh.faces[27].setVerts(18,19,21);
mesh.faces[27].setEdgeVisFlags(0,1,0);
mesh.faces[27].setSmGroup(1);
mesh.faces[28].setVerts(19,23,22);
mesh.faces[28].setEdgeVisFlags(0,1,1);
mesh.faces[28].setSmGroup(8);
mesh.faces[29].setVerts(19,20,23);
mesh.faces[29].setEdgeVisFlags(1,1,0);
mesh.faces[29].setSmGroup(8);
mesh.faces[30].setVerts(20,24,23);
mesh.faces[30].setEdgeVisFlags(0,1,1);
mesh.faces[30].setSmGroup(8);
mesh.faces[31].setVerts(20,21,24);
mesh.faces[31].setEdgeVisFlags(1,1,0);
mesh.faces[31].setSmGroup(8);
mesh.faces[32].setVerts(21,22,24);
mesh.faces[32].setEdgeVisFlags(0,1,1);
mesh.faces[32].setSmGroup(8);
mesh.faces[33].setVerts(21,19,22);
mesh.faces[33].setEdgeVisFlags(1,1,0);
mesh.faces[33].setSmGroup(8);
mesh.faces[34].setVerts(25,22,23);
mesh.faces[34].setEdgeVisFlags(0,1,0);
mesh.faces[34].setSmGroup(1);
mesh.faces[35].setVerts(25,23,24);
mesh.faces[35].setEdgeVisFlags(0,1,0);
mesh.faces[35].setSmGroup(1);
mesh.faces[36].setVerts(25,24,22);
mesh.faces[36].setEdgeVisFlags(0,1,0);
mesh.faces[36].setSmGroup(1);
mesh.faces[37].setVerts(26,28,27);
mesh.faces[37].setEdgeVisFlags(0,1,0);
mesh.faces[37].setSmGroup(1);
mesh.faces[38].setVerts(26,29,28);
mesh.faces[38].setEdgeVisFlags(0,1,0);
mesh.faces[38].setSmGroup(1);
mesh.faces[39].setVerts(26,27,29);
mesh.faces[39].setEdgeVisFlags(0,1,0);
mesh.faces[39].setSmGroup(1);
mesh.faces[40].setVerts(27,31,30);
mesh.faces[40].setEdgeVisFlags(0,1,1);
mesh.faces[40].setSmGroup(8);
mesh.faces[41].setVerts(27,28,31);
mesh.faces[41].setEdgeVisFlags(1,1,0);
mesh.faces[41].setSmGroup(8);
mesh.faces[42].setVerts(28,32,31);
mesh.faces[42].setEdgeVisFlags(0,1,1);
mesh.faces[42].setSmGroup(8);
mesh.faces[43].setVerts(28,29,32);
mesh.faces[43].setEdgeVisFlags(1,1,0);
mesh.faces[43].setSmGroup(8);
mesh.faces[44].setVerts(29,30,32);
mesh.faces[44].setEdgeVisFlags(0,1,1);
mesh.faces[44].setSmGroup(8);
mesh.faces[45].setVerts(29,27,30);
mesh.faces[45].setEdgeVisFlags(1,1,0);
mesh.faces[45].setSmGroup(8);
mesh.faces[46].setVerts(33,30,31);
mesh.faces[46].setEdgeVisFlags(0,1,0);
mesh.faces[46].setSmGroup(1);
mesh.faces[47].setVerts(33,31,32);
mesh.faces[47].setEdgeVisFlags(0,1,0);
mesh.faces[47].setSmGroup(1);
mesh.faces[48].setVerts(33,32,30);
mesh.faces[48].setEdgeVisFlags(0,1,0);
mesh.faces[48].setSmGroup(1);
mesh.faces[49].setVerts(34,36,35);
mesh.faces[49].setEdgeVisFlags(0,1,0);
mesh.faces[49].setSmGroup(1);
mesh.faces[50].setVerts(34,37,36);
mesh.faces[50].setEdgeVisFlags(0,1,0);
mesh.faces[50].setSmGroup(1);
mesh.faces[51].setVerts(34,35,37);
mesh.faces[51].setEdgeVisFlags(0,1,0);
mesh.faces[51].setSmGroup(1);
mesh.faces[52].setVerts(35,39,38);
mesh.faces[52].setEdgeVisFlags(0,1,1);
mesh.faces[52].setSmGroup(8);
mesh.faces[53].setVerts(35,36,39);
mesh.faces[53].setEdgeVisFlags(1,1,0);
mesh.faces[53].setSmGroup(8);
mesh.faces[54].setVerts(36,40,39);
mesh.faces[54].setEdgeVisFlags(0,1,1);
mesh.faces[54].setSmGroup(8);
mesh.faces[55].setVerts(36,37,40);
mesh.faces[55].setEdgeVisFlags(1,1,0);
mesh.faces[55].setSmGroup(8);
mesh.faces[56].setVerts(37,38,40);
mesh.faces[56].setEdgeVisFlags(0,1,1);
mesh.faces[56].setSmGroup(8);
mesh.faces[57].setVerts(37,35,38);
mesh.faces[57].setEdgeVisFlags(1,1,0);
mesh.faces[57].setSmGroup(8);
mesh.faces[58].setVerts(41,38,39);
mesh.faces[58].setEdgeVisFlags(0,1,0);
mesh.faces[58].setSmGroup(1);
mesh.faces[59].setVerts(41,39,40);
mesh.faces[59].setEdgeVisFlags(0,1,0);
mesh.faces[59].setSmGroup(1);
mesh.faces[60].setVerts(41,40,38);
mesh.faces[60].setEdgeVisFlags(0,1,0);
mesh.faces[60].setSmGroup(1);
mesh.faces[61].setVerts(42,46,45);
mesh.faces[61].setEdgeVisFlags(0,1,1);
mesh.faces[61].setSmGroup(8);
mesh.faces[62].setVerts(42,43,46);
mesh.faces[62].setEdgeVisFlags(1,1,0);
mesh.faces[62].setSmGroup(8);
mesh.faces[63].setVerts(43,47,46);
mesh.faces[63].setEdgeVisFlags(0,1,1);
mesh.faces[63].setSmGroup(8);
mesh.faces[64].setVerts(43,44,47);
mesh.faces[64].setEdgeVisFlags(1,1,0);
mesh.faces[64].setSmGroup(8);
mesh.faces[65].setVerts(44,45,47);
mesh.faces[65].setEdgeVisFlags(0,1,1);
mesh.faces[65].setSmGroup(8);
mesh.faces[66].setVerts(44,42,45);
mesh.faces[66].setEdgeVisFlags(1,1,0);
mesh.faces[66].setSmGroup(8);
mesh.faces[67].setVerts(50,48,49);
mesh.faces[67].setEdgeVisFlags(0,0,1);
mesh.faces[67].setSmGroup(1);
mesh.faces[68].setVerts(51,48,50);
mesh.faces[68].setEdgeVisFlags(0,0,1);
mesh.faces[68].setSmGroup(1);
mesh.faces[69].setVerts(49,48,51);
mesh.faces[69].setEdgeVisFlags(0,0,1);
mesh.faces[69].setSmGroup(1);
mesh.faces[70].setVerts(46,49,45);
mesh.faces[70].setEdgeVisFlags(0,1,1);
mesh.faces[70].setSmGroup(8);
mesh.faces[71].setVerts(50,49,46);
mesh.faces[71].setEdgeVisFlags(1,0,1);
mesh.faces[71].setSmGroup(8);
mesh.faces[72].setVerts(47,50,46);
mesh.faces[72].setEdgeVisFlags(0,1,1);
mesh.faces[72].setSmGroup(8);
mesh.faces[73].setVerts(51,50,47);
mesh.faces[73].setEdgeVisFlags(1,0,1);
mesh.faces[73].setSmGroup(8);
mesh.faces[74].setVerts(45,51,47);
mesh.faces[74].setEdgeVisFlags(0,1,1);
mesh.faces[74].setSmGroup(8);
mesh.faces[75].setVerts(49,51,45);
mesh.faces[75].setEdgeVisFlags(1,0,1);
mesh.faces[75].setSmGroup(8);
mesh.faces[76].setVerts(52,54,53);
mesh.faces[76].setEdgeVisFlags(0,1,0);
mesh.faces[76].setSmGroup(1);
mesh.faces[77].setVerts(52,55,54);
mesh.faces[77].setEdgeVisFlags(0,1,0);
mesh.faces[77].setSmGroup(1);
mesh.faces[78].setVerts(52,53,55);
mesh.faces[78].setEdgeVisFlags(0,1,0);
mesh.faces[78].setSmGroup(1);
mesh.faces[79].setVerts(53,43,42);
mesh.faces[79].setEdgeVisFlags(0,1,1);
mesh.faces[79].setSmGroup(8);
mesh.faces[80].setVerts(53,54,43);
mesh.faces[80].setEdgeVisFlags(1,1,0);
mesh.faces[80].setSmGroup(8);
mesh.faces[81].setVerts(54,44,43);
mesh.faces[81].setEdgeVisFlags(0,1,1);
mesh.faces[81].setSmGroup(8);
mesh.faces[82].setVerts(54,55,44);
mesh.faces[82].setEdgeVisFlags(1,1,0);
mesh.faces[82].setSmGroup(8);
mesh.faces[83].setVerts(55,42,44);
mesh.faces[83].setEdgeVisFlags(0,1,1);
mesh.faces[83].setSmGroup(8);
mesh.faces[84].setVerts(55,53,42);
mesh.faces[84].setEdgeVisFlags(1,1,0);
mesh.faces[84].setSmGroup(8);
mesh.faces[85].setVerts(60,56,59);
mesh.faces[85].setEdgeVisFlags(0,1,1);
mesh.faces[85].setSmGroup(8);
mesh.faces[86].setVerts(57,56,60);
mesh.faces[86].setEdgeVisFlags(1,0,1);
mesh.faces[86].setSmGroup(8);
mesh.faces[87].setVerts(61,57,60);
mesh.faces[87].setEdgeVisFlags(0,1,1);
mesh.faces[87].setSmGroup(8);
mesh.faces[88].setVerts(58,57,61);
mesh.faces[88].setEdgeVisFlags(1,0,1);
mesh.faces[88].setSmGroup(8);
mesh.faces[89].setVerts(59,58,61);
mesh.faces[89].setEdgeVisFlags(0,1,1);
mesh.faces[89].setSmGroup(8);
mesh.faces[90].setVerts(56,58,59);
mesh.faces[90].setEdgeVisFlags(1,0,1);
mesh.faces[90].setSmGroup(8);
mesh.faces[91].setVerts(59,62,60);
mesh.faces[91].setEdgeVisFlags(0,0,1);
mesh.faces[91].setSmGroup(1);
mesh.faces[92].setVerts(60,62,61);
mesh.faces[92].setEdgeVisFlags(0,0,1);
mesh.faces[92].setSmGroup(1);
mesh.faces[93].setVerts(61,62,59);
mesh.faces[93].setEdgeVisFlags(0,0,1);
mesh.faces[93].setSmGroup(1);
mesh.faces[94].setVerts(56,64,63);
mesh.faces[94].setEdgeVisFlags(0,1,1);
mesh.faces[94].setSmGroup(8);
mesh.faces[95].setVerts(56,57,64);
mesh.faces[95].setEdgeVisFlags(1,1,0);
mesh.faces[95].setSmGroup(8);
mesh.faces[96].setVerts(57,65,64);
mesh.faces[96].setEdgeVisFlags(0,1,1);
mesh.faces[96].setSmGroup(8);
mesh.faces[97].setVerts(57,58,65);
mesh.faces[97].setEdgeVisFlags(1,1,0);
mesh.faces[97].setSmGroup(8);
mesh.faces[98].setVerts(58,63,65);
mesh.faces[98].setEdgeVisFlags(0,1,1);
mesh.faces[98].setSmGroup(8);
mesh.faces[99].setVerts(58,56,63);
mesh.faces[99].setEdgeVisFlags(1,1,0);
mesh.faces[99].setSmGroup(8);
mesh.faces[100].setVerts(66,63,64);
mesh.faces[100].setEdgeVisFlags(0,1,0);
mesh.faces[100].setSmGroup(1);
mesh.faces[101].setVerts(66,64,65);
mesh.faces[101].setEdgeVisFlags(0,1,0);
mesh.faces[101].setSmGroup(1);
mesh.faces[102].setVerts(66,65,63);
mesh.faces[102].setEdgeVisFlags(0,1,0);
mesh.faces[102].setSmGroup(1);
mesh.faces[103].setVerts(67,71,70);
mesh.faces[103].setEdgeVisFlags(0,1,1);
mesh.faces[103].setSmGroup(8);
mesh.faces[104].setVerts(67,68,71);
mesh.faces[104].setEdgeVisFlags(1,1,0);
mesh.faces[104].setSmGroup(8);
mesh.faces[105].setVerts(68,72,71);
mesh.faces[105].setEdgeVisFlags(0,1,1);
mesh.faces[105].setSmGroup(8);
mesh.faces[106].setVerts(68,69,72);
mesh.faces[106].setEdgeVisFlags(1,1,0);
mesh.faces[106].setSmGroup(8);
mesh.faces[107].setVerts(69,70,72);
mesh.faces[107].setEdgeVisFlags(0,1,1);
mesh.faces[107].setSmGroup(8);
mesh.faces[108].setVerts(69,67,70);
mesh.faces[108].setEdgeVisFlags(1,1,0);
mesh.faces[108].setSmGroup(8);
mesh.faces[109].setVerts(73,70,71);
mesh.faces[109].setEdgeVisFlags(0,1,0);
mesh.faces[109].setSmGroup(1);
mesh.faces[110].setVerts(73,71,72);
mesh.faces[110].setEdgeVisFlags(0,1,0);
mesh.faces[110].setSmGroup(1);
mesh.faces[111].setVerts(73,72,70);
mesh.faces[111].setEdgeVisFlags(0,1,0);
mesh.faces[111].setSmGroup(1);
mesh.faces[112].setVerts(75,67,74);
mesh.faces[112].setEdgeVisFlags(0,1,1);
mesh.faces[112].setSmGroup(8);
mesh.faces[113].setVerts(68,67,75);
mesh.faces[113].setEdgeVisFlags(1,0,1);
mesh.faces[113].setSmGroup(8);
mesh.faces[114].setVerts(76,68,75);
mesh.faces[114].setEdgeVisFlags(0,1,1);
mesh.faces[114].setSmGroup(8);
mesh.faces[115].setVerts(69,68,76);
mesh.faces[115].setEdgeVisFlags(1,0,1);
mesh.faces[115].setSmGroup(8);
mesh.faces[116].setVerts(74,69,76);
mesh.faces[116].setEdgeVisFlags(0,1,1);
mesh.faces[116].setSmGroup(8);
mesh.faces[117].setVerts(67,69,74);
mesh.faces[117].setEdgeVisFlags(1,0,1);
mesh.faces[117].setSmGroup(8);
mesh.faces[118].setVerts(74,77,75);
mesh.faces[118].setEdgeVisFlags(0,0,1);
mesh.faces[118].setSmGroup(1);
mesh.faces[119].setVerts(75,77,76);
mesh.faces[119].setEdgeVisFlags(0,0,1);
mesh.faces[119].setSmGroup(1);
mesh.faces[120].setVerts(76,77,74);
mesh.faces[120].setEdgeVisFlags(0,0,1);
mesh.faces[120].setSmGroup(1);
mesh.faces[121].setVerts(78,80,79);
mesh.faces[121].setEdgeVisFlags(0,1,0);
mesh.faces[121].setSmGroup(1);
mesh.faces[122].setVerts(78,81,80);
mesh.faces[122].setEdgeVisFlags(0,1,0);
mesh.faces[122].setSmGroup(1);
mesh.faces[123].setVerts(78,79,81);
mesh.faces[123].setEdgeVisFlags(0,1,0);
mesh.faces[123].setSmGroup(1);
mesh.faces[124].setVerts(79,83,82);
mesh.faces[124].setEdgeVisFlags(0,1,1);
mesh.faces[124].setSmGroup(8);
mesh.faces[125].setVerts(79,80,83);
mesh.faces[125].setEdgeVisFlags(1,1,0);
mesh.faces[125].setSmGroup(8);
mesh.faces[126].setVerts(80,84,83);
mesh.faces[126].setEdgeVisFlags(0,1,1);
mesh.faces[126].setSmGroup(8);
mesh.faces[127].setVerts(80,81,84);
mesh.faces[127].setEdgeVisFlags(1,1,0);
mesh.faces[127].setSmGroup(8);
mesh.faces[128].setVerts(81,82,84);
mesh.faces[128].setEdgeVisFlags(0,1,1);
mesh.faces[128].setSmGroup(8);
mesh.faces[129].setVerts(81,79,82);
mesh.faces[129].setEdgeVisFlags(1,1,0);
mesh.faces[129].setSmGroup(8);
mesh.faces[130].setVerts(85,82,83);
mesh.faces[130].setEdgeVisFlags(0,1,0);
mesh.faces[130].setSmGroup(1);
mesh.faces[131].setVerts(85,83,84);
mesh.faces[131].setEdgeVisFlags(0,1,0);
mesh.faces[131].setSmGroup(1);
mesh.faces[132].setVerts(85,84,82);
mesh.faces[132].setEdgeVisFlags(0,1,0);
mesh.faces[132].setSmGroup(1);
| [
"paul-kv@yandex.ru"
] | paul-kv@yandex.ru |
14aba713410a00d7bf824ff98e5bfb579a48ddc8 | dffd7156da8b71f4a743ec77d05c8ba031988508 | /ac/abc145/abc145_d/9380609.cpp | 96854544d288827c3239530f2894df64f541870f | [] | no_license | e1810/kyopro | a3a9a2ee63bc178dfa110788745a208dead37da6 | 15cf27d9ecc70cf6d82212ca0c788e327371b2dd | refs/heads/master | 2021-11-10T16:53:23.246374 | 2021-02-06T16:29:09 | 2021-10-31T06:20:50 | 252,388,049 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 850 | cpp |
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAX = 10000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long COM(int n, int k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
ll x, y;
scanf("%lld %lld", &x, &y);
if((x+y)%3){
puts("0");
return 0;
}
COMinit();
ll n = (x+y)/3; ll k = (2*y-x)/3;
printf("%lld
", COM(n, k));
return 0;
}
| [
"v.iceele1810@gmail.com"
] | v.iceele1810@gmail.com |
64c141fbd6f720f9e923f854349897ea990e6fb1 | fd57ede0ba18642a730cc862c9e9059ec463320b | /minikin/libs/minikin/Measurement.cpp | a2c95ed6b71734c5b2e0e732da64e418d73753f7 | [] | no_license | kailaisi/android-29-framwork | a0c706fc104d62ea5951ca113f868021c6029cd2 | b7090eebdd77595e43b61294725b41310496ff04 | refs/heads/master | 2023-04-27T14:18:52.579620 | 2021-03-08T13:05:27 | 2021-03-08T13:05:27 | 254,380,637 | 1 | 1 | null | 2023-04-15T12:22:31 | 2020-04-09T13:35:49 | C++ | UTF-8 | C++ | false | false | 4,624 | cpp | /*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "minikin/Measurement.h"
#include <cfloat>
#include <cmath>
#include "minikin/GraphemeBreak.h"
namespace minikin {
// These could be considered helper methods of layout, but need only be loosely coupled, so
// are separate.
static float getRunAdvance(const float* advances, const uint16_t* buf, size_t layoutStart,
size_t start, size_t count, size_t offset) {
float advance = 0.0f;
size_t lastCluster = start;
float clusterWidth = 0.0f;
for (size_t i = start; i < offset; i++) {
float charAdvance = advances[i - layoutStart];
if (charAdvance != 0.0f) {
advance += charAdvance;
lastCluster = i;
clusterWidth = charAdvance;
}
}
if (offset < start + count && advances[offset - layoutStart] == 0.0f) {
// In the middle of a cluster, distribute width of cluster so that each grapheme cluster
// gets an equal share.
// TODO: get caret information out of font when that's available
size_t nextCluster;
for (nextCluster = offset + 1; nextCluster < start + count; nextCluster++) {
if (advances[nextCluster - layoutStart] != 0.0f) break;
}
int numGraphemeClusters = 0;
int numGraphemeClustersAfter = 0;
for (size_t i = lastCluster; i < nextCluster; i++) {
bool isAfter = i >= offset;
if (GraphemeBreak::isGraphemeBreak(advances + (start - layoutStart), buf, start, count,
i)) {
numGraphemeClusters++;
if (isAfter) {
numGraphemeClustersAfter++;
}
}
}
if (numGraphemeClusters > 0) {
advance -= clusterWidth * numGraphemeClustersAfter / numGraphemeClusters;
}
}
return advance;
}
float getRunAdvance(const float* advances, const uint16_t* buf, size_t start, size_t count,
size_t offset) {
return getRunAdvance(advances, buf, start, start, count, offset);
}
/**
* Essentially the inverse of getRunAdvance. Compute the value of offset for which the
* measured caret comes closest to the provided advance param, and which is on a grapheme
* cluster boundary.
*
* The actual implementation fast-forwards through clusters to get "close", then does a finer-grain
* search within the cluster and grapheme breaks.
*/
size_t getOffsetForAdvance(const float* advances, const uint16_t* buf, size_t start, size_t count,
float advance) {
float x = 0.0f, xLastClusterStart = 0.0f, xSearchStart = 0.0f;
size_t lastClusterStart = start, searchStart = start;
for (size_t i = start; i < start + count; i++) {
if (GraphemeBreak::isGraphemeBreak(advances, buf, start, count, i)) {
searchStart = lastClusterStart;
xSearchStart = xLastClusterStart;
}
float width = advances[i - start];
if (width != 0.0f) {
lastClusterStart = i;
xLastClusterStart = x;
x += width;
if (x > advance) {
break;
}
}
}
size_t best = searchStart;
float bestDist = FLT_MAX;
for (size_t i = searchStart; i <= start + count; i++) {
if (GraphemeBreak::isGraphemeBreak(advances, buf, start, count, i)) {
// "getRunAdvance(layout, buf, start, count, i) - advance" but more efficient
float delta = getRunAdvance(advances, buf, start, searchStart, count - searchStart, i)
+ xSearchStart - advance;
if (std::abs(delta) < bestDist) {
bestDist = std::abs(delta);
best = i;
}
if (delta >= 0.0f) {
break;
}
}
}
return best;
}
} // namespace minikin
| [
"541018378@qq.com"
] | 541018378@qq.com |
d5e01c2af6a27c32e3db785fc92939d32429cba5 | 52f62927bb096e6cbc01bd6e5625a119fb35c1c5 | /avt/Expressions/Derivations/avtTensorMaximumShearExpression.h | 6586a01265d6d7da3f93ba19344cc1b0b61f1267 | [] | no_license | HarinarayanKrishnan/VisIt27RC_Trunk | f42f82d1cb2492f6df1c2f5bb05bbb598fce99c3 | 16cdd647ac0ad5abfd66b252d31c8b833142145a | refs/heads/master | 2020-06-03T07:13:46.229264 | 2014-02-26T18:13:38 | 2014-02-26T18:13:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,829 | h | /*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtTensorMaximumShearExpression.h //
// ************************************************************************* //
#ifndef AVT_TENSOR_MAXIMUM_SHEAR_FILTER_H
#define AVT_TENSOR_MAXIMUM_SHEAR_FILTER_H
#include <avtUnaryMathExpression.h>
// ****************************************************************************
// Class: avtTensorMaximumShearExpression
//
// Purpose:
// Calculates the maximum shear for a tensor.
//
// Programmer: Hank Childs
// Creation: September 23, 2003
//
// Modifications:
//
// Hank Childs, Thu Feb 5 17:11:06 PST 2004
// Moved inlined constructor and destructor definitions to .C files
// because certain compilers have problems with them.
//
// ****************************************************************************
class EXPRESSION_API avtTensorMaximumShearExpression : public avtUnaryMathExpression
{
public:
avtTensorMaximumShearExpression();
virtual ~avtTensorMaximumShearExpression();
virtual const char *GetType(void)
{ return "avtTensorMaximumShearExpression"; };
virtual const char *GetDescription(void)
{ return "Calculating maximum shear"; };
protected:
virtual void DoOperation(vtkDataArray *in, vtkDataArray *out,
int ncomponents, int ntuples);
virtual int GetNumberOfComponentsInOutput(int) { return 1; };
};
#endif
| [
"brugger@18c085ea-50e0-402c-830e-de6fd14e8384"
] | brugger@18c085ea-50e0-402c-830e-de6fd14e8384 |
e691b915e7c2362457a05474bec1c13e5312e844 | 097120e8731f4d0167406d40a40d7b34ab10b866 | /CEntity/stuff/ragdoll_shared.cpp | 353c88436667fdcaf552151f99d9aafc670f9c3a | [] | no_license | raydan/npc-in-css | 98576df7da695cb9be17b22c9b0bb101083992b5 | 8953f3266274174e043c3a5fefa9f32ae15057f3 | refs/heads/master | 2021-09-10T05:38:59.306450 | 2018-03-21T06:17:12 | 2018-03-21T06:17:12 | 126,130,419 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 700 | cpp |
#include "CEntity.h"
#include "ragdoll_shared.h"
#include "bone_setup.h"
void RagdollApplyAnimationAsVelocity( ragdoll_t &ragdoll, const matrix3x4_t *pPrevBones, const matrix3x4_t *pCurrentBones, float dt )
{
for ( int i = 0; i < ragdoll.listCount; i++ )
{
Vector velocity;
AngularImpulse angVel;
int boneIndex = ragdoll.boneIndex[i];
CalcBoneDerivatives( velocity, angVel, pPrevBones[boneIndex], pCurrentBones[boneIndex], dt );
AngularImpulse localAngVelocity;
// Angular velocity is always applied in local space in vphysics
ragdoll.list[i].pObject->WorldToLocalVector( &localAngVelocity, angVel );
ragdoll.list[i].pObject->AddVelocity( &velocity, &localAngVelocity );
}
}
| [
"raykhyip@dimbuy.com"
] | raykhyip@dimbuy.com |
755dcb420501a554ab4b4a05dc35648a8a49f3e4 | b2139a7f5e04114c39faea797f0f619e69b8b4ae | /src/cognitiveArchitecture/src/laplacianOfGaussian/src/laplacianOfGaussianMain.cpp | c185cdfaed150c9f5c36e6ebd281da81767970c3 | [] | no_license | hychyc07/contrib_bk | 6b82391a965587603813f1553084a777fb54d9d7 | 6f3df0079b7ea52d5093042112f55a921c9ed14e | refs/heads/master | 2020-05-29T14:01:20.368837 | 2015-04-02T21:00:31 | 2015-04-02T21:00:31 | 33,312,790 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,470 | cpp | /*
* Copyright (C) 2011 RobotCub Consortium, European Commission FP6 Project IST-004370
* Authors: David Vernon
* email: david@vernon.eu
* website: www.vernon.eu
* Permission is granted to copy, distribute, and/or modify this program
* under the terms of the GNU General Public License, version 2 or any
* later version published by the Free Software Foundation.
*
* A copy of the license can be found at
* http://www.robotcub.org/icub/license/gpl.txt
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details
*/
/*
* Audit Trail
* -----------
* 30/03/11 First version validated DV
*/
#include "iCub/laplacianOfGaussian.h"
int main(int argc, char * argv[])
{
/* initialize yarp network */
Network yarp;
/* create your module */
LaplacianOfGaussian laplacianOfGaussian;
/* prepare and configure the resource finder */
ResourceFinder rf;
rf.setVerbose(true);
rf.setDefaultConfigFile("laplacianOfGaussian.ini"); //overridden by --from parameter
rf.setDefaultContext("laplacianOfGaussian/conf"); //overridden by --context parameter
rf.configure("ICUB_ROOT", argc, argv);
/* run the module: runModule() calls configure first and, if successful, it then runs */
laplacianOfGaussian.runModule(rf);
return 0;
}
| [
"hychyc07@cs.utexas.edu"
] | hychyc07@cs.utexas.edu |
6426660d482f32d646094755651c4f4832d5620b | 282baa0d0b9c9987503b81224894de6d2e816fa9 | /Lab/Lab2(Strings&Class)/q1_d.cpp | 64eadc984c6476e4109ad0676a3e9b3e414f511e | [] | no_license | sarthak815/DS_Manipal | 2b8d45efd6b6353e7bbf825594f4f9e4eda04318 | 6bd80567dffd674f7059b2d8dfe0d6f2ee794750 | refs/heads/master | 2023-02-24T17:54:25.539462 | 2021-01-26T18:01:08 | 2021-01-26T18:01:08 | 284,713,665 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 668 | cpp | #include<iostream>
#include <stdlib.h>
using namespace std;
int str_len(char *a){
int i=0;
while(a[i]!='\0'){
i++;
}
return i;
}
char* str_insert(char *a, char *b, int k){
int m = str_len(a);
int n =str_len(b);
for(int i=1;i<(m-k);i++){
a[m+n-i]=a[m-i];
}
a[m+n]='\0';
for(int j=0;j<n;j++){
a[n+j]=b[j];
}
return a;
}
int main(){
char str1[100],str2[100];
int n;
cout<<"Enter the string: ";
cin>>str1;
cout<<"Enter the substring: ";
cin>>str2;
cout<<"Enter position: ";
cin>>n;
cout<<"The new string is: "<<str_insert(str1,str2,n);
return 0;
} | [
"55555570+sarthak815@users.noreply.github.com"
] | 55555570+sarthak815@users.noreply.github.com |
5853962ad86bbd7ceff8843ba89bd7d00e7f40c2 | 1c31ca973a282e697b627ca72b083263e27bf792 | /arc_design_contest/2018/Smart_Power_Saving_System_of_3D_Remote_Interaction/Linux-skeleton/src/skeleton_markers/src/writeFtdi.cpp | 9f92edec1a232fcd78344f5d4bd0da5372ab15f0 | [] | no_license | foss-for-synopsys-dwc-arc-processors/embarc_applications | af932fa67110163980ded6b66604789095ad1c44 | 7a5b2fb40319d6a2ffeb439dcb64ab879c25f57f | refs/heads/master | 2023-04-15T11:11:29.185319 | 2023-04-10T02:08:55 | 2023-04-10T02:08:55 | 84,292,640 | 17 | 113 | null | 2023-04-10T02:08:56 | 2017-03-08T07:38:23 | C | UTF-8 | C++ | false | false | 3,426 | cpp | /* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : writeFtdi.cpp
* Purpose :
* Creation Date : 2018-05-12
* Last Modified : Thu 17 May 2018 09:00:14 PM CST
* Created By :
*_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.*/
#include <ros/ros.h>
#include <ftdi.h>
#include <skeleton_markers/Skeleton.h>
#include <vector>
struct ftdi_context *ftdi;
int vid = 0x403;
int pid = 0x6011;
int baudrate = 115200;
int interface = INTERFACE_A;
void cb_ftdi(const skeleton_markers::SkeletonConstPtr msg)
{
static int test_flag = 0;
static int print_flag = 0;
// std::cout << "entry ftdi callback" << std::endl;
float ftdi_sent[(3+4)*15];
// decode msg
// if user id is 1
// TODO reference confidence
if (test_flag%2 == 0)
{
for (int i = 0; i < 15; ++i)
{
// ftdi_sent[7*i+0] = msg->position.at(i).x;
// ftdi_sent[7*i+1] = msg->position.at(i).y;
// ftdi_sent[7*i+2] = msg->position.at(i).z;
// ftdi_sent[7*i+3] = msg->orientation.at(i).w;
// ftdi_sent[7*i+4] = msg->orientation.at(i).x;
// ftdi_sent[7*i+5] = msg->orientation.at(i).y;
// ftdi_sent[7*i+6] = msg->orientation.at(i).z;
ftdi_sent[7*i+0] = msg->position.at(i).x;
ftdi_sent[7*i+1] = msg->position.at(i).y;
ftdi_sent[7*i+2] = msg->position.at(i).z;
ftdi_sent[7*i+3] = msg->orientation.at(i).w;
ftdi_sent[7*i+4] = msg->orientation.at(i).x;
ftdi_sent[7*i+5] = msg->orientation.at(i).y;
ftdi_sent[7*i+6] = msg->orientation.at(i).z;
}
ftdi_write_data(ftdi, (unsigned char*)ftdi_sent, sizeof(ftdi_sent));
if (print_flag % 10 == 0) {
// fdti
std::cout << "sent size" << sizeof(ftdi_sent) << std::endl;
std::cout << "===========================================" << std::endl;
std::cout << "send msg index 0" << std::endl;
// std::cout << ftdi_sent[0] << " " << ftdi_sent[1] << " " << ftdi_sent[2] << std::endl;
std::cout << ftdi_sent[3] << " " << ftdi_sent[4] << " " << ftdi_sent[5] << " " << ftdi_sent[6] << std::endl;
std::cout << ftdi_sent[10] << " " << ftdi_sent[11] << " " << ftdi_sent[12] << " " << ftdi_sent[13] << std::endl;
std::cout << ftdi_sent[17] << " " << ftdi_sent[18] << " " << ftdi_sent[19] << " " << ftdi_sent[20] << std::endl;
// std::cout << ftdi_sent[98] << " " << ftdi_sent[99] << " " << ftdi_sent[100] << std::endl;
std::cout << ftdi_sent[101] << " " << ftdi_sent[102] << " " << ftdi_sent[103] << " " << ftdi_sent[104] << std::endl;
std::cout << "===========================================" << std::endl;
print_flag = 0;
}
test_flag = 0;
}
test_flag++;
print_flag++;
}
int main(int argc, char *argv[])
{
int f;
// ftdi init
if ((ftdi = ftdi_new()) == 0)
{
std::cout << "ftdi_new failed" << std::endl;
return -1;
}
ftdi_set_interface(ftdi, INTERFACE_A);
f = ftdi_usb_open_desc(ftdi, vid, pid, "vlsilab", NULL);
if (f < 0) {
std::cout << "error" << ftdi_get_error_string(ftdi) << std::endl;
return -1;
}
f = ftdi_set_baudrate(ftdi, baudrate);
if (f < 0) {
std::cout << "error" << ftdi_get_error_string(ftdi) << std::endl;
return -1;
}
// ros init
ros::init(argc, argv, "usb_ftdi");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/skeleton", 5, cb_ftdi);
ros::spin();
return 0;
}
| [
"dfl@vlsilab.ee.ncku.edu.tw"
] | dfl@vlsilab.ee.ncku.edu.tw |
5002ea71278f7422075dfd406e7621ff413e90a4 | 16414f587c69d5f75228763fc287bbb95d35910a | /MS3/src/Camera/Camera3D.cpp | c176ee2d086c2b832dcfaa9125545a7d841f28ce | [] | no_license | Jacob-Zackaria/Game-Engine | e12ccd9dc17ee9f405b1f298804f3cb24bd86e91 | dc0384f1b04d2808893d991799aa7c17fcf60f01 | refs/heads/main | 2023-07-05T13:28:54.810918 | 2021-08-07T10:58:05 | 2021-08-07T10:58:05 | 392,367,859 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,315 | cpp | #include "Camera3D.h"
namespace Azul
{
Camera3D::Camera3D()
:
Camera(Camera::Type::PERSPECTIVE_3D)
{
}
// critical informational knobs for the perspective matrix
// Field of View Y is in degrees (copying lame OpenGL)
void Camera3D::setPerspective(const float Fovy, const float Aspect, const float NearDist, const float FarDist)
{
this->aspectRatio = Aspect;
this->fovy = Fovy;
this->nearDist = NearDist;
this->farDist = FarDist;
}
// The projection matrix (note it's invertable)
void Camera3D::privUpdateProjectionMatrix(void)
{
this->projMatrix[m0] = 2.0f * this->nearDist / this->near_width;
this->projMatrix[m1] = 0.0f;
this->projMatrix[m2] = 0.0f;
this->projMatrix[m3] = 0.0f;
this->projMatrix[m4] = 0.0f;
this->projMatrix[m5] = 2.0f * this->nearDist / this->near_height;
this->projMatrix[m6] = 0.0f;
this->projMatrix[m7] = 0.0f;
this->projMatrix[m8] = 0.0f;
this->projMatrix[m9] = 0.0f;
this->projMatrix[m10] = (this->farDist + this->nearDist) / (this->nearDist - this->farDist);
this->projMatrix[m11] = -1.0f;
this->projMatrix[m12] = 0.0f;
this->projMatrix[m13] = 0.0f;
this->projMatrix[m14] = (2.0f * this->farDist * this->nearDist) / (this->nearDist - this->farDist);
this->projMatrix[m15] = 0.0f;
}
} | [
"noreply@github.com"
] | noreply@github.com |
6c022fa01240e8b642ad2f1e41fb97a824f28048 | ac6d9321826218698a438f1d8f5618813870f512 | /BOJ/Q5426.cpp | 5056e70fc5f4bbcbefed57664cdbb7b60549e51a | [] | no_license | pnm6054/Algorithm_exercise | f4e5f37c089e6f67659466126fae3157d88b3c72 | 6ee871ce535fc4bcc9ac5611bf0150d5735a2689 | refs/heads/master | 2020-12-10T15:14:13.020165 | 2020-04-21T14:36:10 | 2020-04-21T14:36:10 | 233,629,640 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 365 | cpp | #include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void)
{
int t, l, sl;
string s;
cin >> t;
while (t--)
{
cin >> s;
l = s.length();
sl = (int)sqrt(l);
for (int i = sl - 1; i >= 0; i--)
{
for (int j = 0; j < l; j += sl)
{
cout << s[i + j];
}
}
cout << endl;
}
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
dc84456468b867643e2a219081e1b60f5d87ccd2 | 2b43782fcdec8db2c0dbe1340753739db6a84f89 | /InterpreterProject/MainDriver/SymbolTable.h | b5cbdd43b5ade3b5c8dbcbea0a2eb1e044944ee8 | [] | no_license | dchang0413/InterpreterProject | a1636f9eedec355d8ca3d3176e98934f5de6945d | f4cad7204cdeb25f5fbad0bac7680d49fca96510 | refs/heads/master | 2020-04-16T09:12:45.136005 | 2019-01-13T02:04:54 | 2019-01-13T02:04:54 | 165,455,867 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,776 | h | #pragma once
#include <string>
#include <unordered_map>
#include "Absyn.h"
#include "Types.h"
using namespace std;
namespace symbol
{
struct SymTabEntry
{
int level; //at which level, the type/variable/function is defined
types::Type* info; //containing type information
const absyn::Absyn* node; //pointing back to the AST node of this entry
SymTabEntry(int l=0, types::Type* i=NULL, const absyn::Absyn * a=NULL)
: level(l), info(i), node(a)
{}
};
template <class Entry>
class SymbolTable
{
private:
//Define some macros for convenience
typedef unordered_map<string, Entry> HashTable;
typedef typename list<HashTable>::iterator Iterator;
//list of the symbol tables for nested scope levels
//The first hashtable is always for the current scope
//The last hashtable is always for the global scope
//in general, ith hashtable represents the parent scope of (i-1)th hashtable
list<HashTable> tables;
//tracing the level of types, variables, and functions
int level; //the level of current scope
string dumpinfo;
public:
//constructor: create the hashtable for the global scope
SymbolTable(void) : level(0), dumpinfo("")
{
//push the global scope
tables.push_back( unordered_map<string, Entry>() );
}
//check if a lexeme is contained in the symbol table list
//search from the tail to head
bool contains(string);
//similar to contains, but only search in the current scope
bool localContains(string);
//similar to contains, but only search in the global scope
bool globalContains(string);
//Retrieve the value associated with the given lexeme in the hashtable list
//search starts at the given level blevel and ends at the global level
//if blevel is -1, start the search from the current level
//an exception is thrown if the lexeme doesn't exist
Entry& lookup(string, int blevel=-1);
//Retrieve the value associated with the given lexeme in the global level only
//an exception is thrown if the lexeme doesn't exist
Entry& globalLookup(string);
//insert a lexeme and binder to the current scope, i.e. the last hashtable in the list
//if it exists, an exception will be thrown
void insert(string lexeme, const Entry value);
//create a new scope as the current scope
void beginScope();
//destroy the current scope, and its parent becomes the current scope
void endScope();
//get the level of current scope
int getLevel() const;
//dump the current scope
//It should be called at the beginning of the endScope function.
void dump();
//to remove all scopes from the hashtable list so that
//all remaining scopes will be dumped.
SymbolTable::~SymbolTable();
};
} //end of namespace Environment
#include "SymbolTable.cpp"
| [
"dchang0413@gmail.com"
] | dchang0413@gmail.com |
f6cbb58291424fd79288b450ae48ff5ec90a64df | 2c3d596da726a64759c6c27d131c87c33a4e0bf4 | /Src/VC/bcgcbpro/BCGPVisualManagerVS2012.cpp | 41599a72ef520e9c4374a8de8b5f87f12e6abc61 | [
"MIT"
] | permissive | iclosure/smartsoft | 8edd8e5471d0e51b81fc1f6c09239cd8722000c0 | 62eaed49efd8306642b928ef4f2d96e36aca6527 | refs/heads/master | 2021-09-03T01:11:29.778290 | 2018-01-04T12:09:25 | 2018-01-04T12:09:25 | 116,255,998 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 95,644 | cpp | //*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This is a part of BCGControlBar Library Professional Edition
// Copyright (C) 1998-2012 BCGSoft Ltd.
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions
// of the accompanying license agreement.
//*******************************************************************************
//
// BCGPVisualManagerVS2012.cpp: implementation of the CBCGPVisualManagerVS2012 class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "BCGPVisualManagerVS2012.h"
#include "BCGPToolbarMenuButton.h"
#include "BCGPDrawManager.h"
#include "BCGPTabWnd.h"
#include "BCGPAutoHideButton.h"
#include "BCGPColorBar.h"
#include "BCGPCalculator.h"
#include "BCGPCalendarBar.h"
#include "bcgpstyle.h"
#include "BCGPAutoHideDockBar.h"
#include "BCGPSlider.h"
#include "BCGPStatusBar.h"
#include "BCGPToolbarEditBoxButton.h"
#include "BCGPToolBox.h"
#include "BCGPPropList.h"
#include "BCGPOutlookButton.h"
#include "CustomizeButton.h"
#include "BCGPCustomizeMenuButton.h"
#include "BCGPToolbarComboBoxButton.h"
#include "BCGPGroup.h"
#include "BCGPReBar.h"
#include "BCGPGridCtrl.h"
#include "BCGPMiniFrameWnd.h"
#include "BCGPCaptionBar.h"
#include "BCGPURLLinkButton.h"
#include "BCGPPopupWindow.h"
#include "BCGPBreadcrumb.h"
#ifndef BCGP_EXCLUDE_PLANNER
#include "BCGPPlannerViewDay.h"
#include "BCGPPlannerViewMonth.h"
#include "BCGPPlannerViewMulti.h"
#endif
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNCREATE(CBCGPVisualManagerVS2012, CBCGPVisualManagerVS2010)
IMPLEMENT_DYNCREATE(CBCGPVisualManagerVS11, CBCGPVisualManagerVS2012) // Backward compatibility
BOOL CBCGPVisualManagerVS2012::m_bAutoGrayscaleImages = TRUE;
COLORREF CBCGPVisualManagerVS2012::m_clrAccent = RGB(19, 130, 206);
CBCGPVisualManagerVS2012::Style CBCGPVisualManagerVS2012::m_Style = CBCGPVisualManagerVS2012::VS2012_Light;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBCGPVisualManagerVS2012::CBCGPVisualManagerVS2012()
{
OnUpdateSystemColors ();
m_bConnectMenuToParent = TRUE;
}
//**************************************************************************************************************
CBCGPVisualManagerVS2012::~CBCGPVisualManagerVS2012()
{
}
//**************************************************************************************************************
void CBCGPVisualManagerVS2012::SetAccentColor(AccentColor color)
{
SetAccentColorRGB(AccentColorToRGB(color));
}
//**************************************************************************************************************
void CBCGPVisualManagerVS2012::SetAccentColorRGB(COLORREF color)
{
m_clrAccent = color;
CBCGPVisualManagerVS2012* pThis = DYNAMIC_DOWNCAST(CBCGPVisualManagerVS2012, CBCGPVisualManager::GetInstance ());
if (pThis != NULL)
{
pThis->OnUpdateSystemColors();
}
}
//**************************************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetAccentColorRGB()
{
return m_clrAccent;
}
//**************************************************************************************************************
void CBCGPVisualManagerVS2012::SetStyle(Style style)
{
m_Style = style;
CBCGPVisualManagerVS2012* pThis = DYNAMIC_DOWNCAST(CBCGPVisualManagerVS2012, CBCGPVisualManager::GetInstance ());
if (pThis != NULL)
{
pThis->OnUpdateSystemColors();
}
}
//**************************************************************************************************************
COLORREF CBCGPVisualManagerVS2012::AccentColorToRGB(AccentColor color)
{
switch (color)
{
case VS2012_Blue:
default:
return RGB(19, 130, 206);
case VS2012_Brown:
return RGB(160,80,0);
case VS2012_Green:
return RGB(51,153,51);
case VS2012_Lime:
return RGB(137, 164, 48);
case VS2012_Magenta:
return RGB(216,0,115);
case VS2012_Orange:
return RGB(240,150,9);
case VS2012_Pink:
return RGB(230,113,184);
case VS2012_Purple:
return RGB(162,0,255);
case VS2012_Red:
return RGB(229,20,0);
case VS2012_Teal:
return RGB(0,171,169);
}
}
//**************************************************************************************************************
void CBCGPVisualManagerVS2012::OnFillBarBackground (CDC* pDC, CBCGPBaseControlBar* pBar,
CRect rectClient, CRect rectClip,
BOOL bNCArea)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerXP::OnFillBarBackground (pDC, pBar, rectClient, rectClip, bNCArea);
return;
}
ASSERT_VALID(pBar);
ASSERT_VALID(pDC);
if (pBar->IsOnGlass ())
{
pDC->FillSolidRect (rectClient, RGB (0, 0, 0));
return;
}
if (DYNAMIC_DOWNCAST (CBCGPReBar, pBar) != NULL || DYNAMIC_DOWNCAST (CBCGPReBar, pBar->GetParent ()))
{
FillRebarPane (pDC, pBar, rectClient);
return;
}
if (DYNAMIC_DOWNCAST(CBCGPColorBar, pBar) != NULL)
{
if (pBar->IsDialogControl ())
{
pDC->FillRect(rectClient, &globalData.brBtnFace);
return;
}
else
{
if (DYNAMIC_DOWNCAST(CDialog, pBar->GetParent()) != NULL)
{
pDC->FillRect(rectClient, &GetDlgBackBrush(pBar->GetParent()));
return;
}
}
}
if (DYNAMIC_DOWNCAST(CBCGPPopupMenuBar, pBar) != NULL)
{
pDC->FillRect (rectClip, &m_brMenuLight);
return;
}
if (pBar->IsKindOf (RUNTIME_CLASS (CBCGPCaptionBar)))
{
pDC->FillRect(rectClip, &m_brMenuLight);
return;
}
#if !defined(BCGP_EXCLUDE_TOOLBOX) && !defined(BCGP_EXCLUDE_TASK_PANE)
if (pBar->IsKindOf (RUNTIME_CLASS (CBCGPToolBoxPage)) || pBar->IsKindOf (RUNTIME_CLASS (CBCGPToolBox)) || pBar->IsKindOf (RUNTIME_CLASS (CBCGPToolBoxEx)))
{
pDC->FillRect(rectClip, &m_brMenuLight);
return;
}
#endif
if (pBar->IsDialogControl ())
{
pDC->FillRect(rectClient, &globalData.brBtnFace);
return;
}
pDC->FillRect(rectClient, &globalData.brBarFace);
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnHighlightMenuItem (CDC* pDC, CBCGPToolbarMenuButton* pButton,
CRect rect, COLORREF& clrText)
{
if ((pButton->m_nStyle & TBBS_DISABLED) && globalData.m_nBitsPerPixel > 8 && !globalData.IsHighContastMode ())
{
rect.DeflateRect(1, 0);
pDC->Draw3dRect(rect, m_clrMenuSeparator, m_clrMenuSeparator);
return;
}
CBCGPVisualManagerXP::OnHighlightMenuItem (pDC, pButton, rect, clrText);
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnEraseTabsArea (CDC* pDC, CRect rect, const CBCGPBaseTabWnd* pTabWnd)
{
CBCGPVisualManagerXP::OnEraseTabsArea (pDC, rect, pTabWnd);
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnEraseTabsButton (CDC* pDC, CRect rect,
CBCGPButton* pButton,
CBCGPBaseTabWnd* pBaseTab)
{
CBCGPVisualManagerXP::OnEraseTabsButton (pDC, rect, pButton, pBaseTab);
}
//*********************************************************************************************************
BOOL CBCGPVisualManagerVS2012::OnEraseTabsFrame (CDC* pDC, CRect rect, const CBCGPBaseTabWnd* /*pTabWnd*/)
{
ASSERT_VALID (pDC);
pDC->FillRect(rect, &globalData.brBarFace);
return TRUE;
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawTabBorder(CDC* pDC, CBCGPTabWnd* pTabWnd, CRect rectBorder, COLORREF clrBorder,
CPen& penLine)
{
ASSERT_VALID (pDC);
ASSERT_VALID (pTabWnd);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
(pTabWnd->IsDialogControl () && !pTabWnd->IsPropertySheetTab()) || !pTabWnd->IsMDITab() ||
pTabWnd->IsFlatTab () || pTabWnd->IsOneNoteStyle () || pTabWnd->IsVS2005Style ())
{
CBCGPVisualManagerVS2010::OnDrawTabBorder(pDC, pTabWnd, rectBorder, clrBorder, penLine);
return;
}
COLORREF clrActiveTab = pTabWnd->GetTabBkColor (pTabWnd->GetActiveTab ());
if (clrActiveTab == (COLORREF)-1)
{
clrActiveTab = pTabWnd->IsMDIFocused() && pTabWnd->IsActiveInMDITabGroup() ? m_clrAccent : globalData.clrBarShadow;
}
CRect rectTop = rectBorder;
rectTop.DeflateRect(pTabWnd->GetTabBorderSize() + 1, 0);
rectTop.bottom = rectTop.top + pTabWnd->GetTabBorderSize();
rectTop.top++;
pDC->FillSolidRect(rectTop, pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM ? globalData.clrBarFace : clrActiveTab);
CRect rectBottom = rectBorder;
rectBottom.DeflateRect(pTabWnd->GetTabBorderSize() + 1, 0);
rectBottom.top = rectBottom.bottom - pTabWnd->GetTabBorderSize();
rectBottom.bottom--;
pDC->FillSolidRect(rectBottom, pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM ? clrActiveTab : globalData.clrBarFace);
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawTab (CDC* pDC, CRect rectTab,
int iTab, BOOL bIsActive, const CBCGPBaseTabWnd* pTabWnd)
{
ASSERT_VALID (pTabWnd);
ASSERT_VALID (pDC);
const BOOL bIsHighlight = (iTab == pTabWnd->GetHighlightedTab ());
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
(pTabWnd->IsDialogControl () && !pTabWnd->IsPropertySheetTab()) ||
pTabWnd->IsFlatTab () || pTabWnd->IsOneNoteStyle () || pTabWnd->IsVS2005Style () || pTabWnd->IsLeftRightRounded() ||
pTabWnd->GetTabBkColor(iTab) != (COLORREF)-1)
{
CBCGPVisualManagerVS2010::OnDrawTab (pDC, rectTab, iTab, bIsActive, pTabWnd);
return;
}
if (iTab != 0 && !pTabWnd->IsMDITab())
{
pDC->MoveTo(rectTab.left, rectTab.top + 1);
pDC->LineTo(rectTab.left, rectTab.bottom - 1);
rectTab.left++;
}
if (bIsActive || bIsHighlight)
{
CRect rectFill = rectTab;
COLORREF clrTab = pTabWnd->GetTabBkColor(iTab);
if (clrTab == (COLORREF)-1)
{
clrTab = globalData.clrBarLight;
if (bIsActive)
{
if (pTabWnd->IsMDITab())
{
if (pTabWnd->IsMDIFocused() && pTabWnd->IsActiveInMDITabGroup())
{
clrTab = m_clrAccent;
}
else
{
clrTab = globalData.clrBarShadow;
}
}
else
{
clrTab = m_clrHighlight;
}
}
else if (pTabWnd->IsMDITab())
{
clrTab = m_clrAccentLight;
}
}
if (pTabWnd->IsMDITab())
{
if (pTabWnd->GetLocation () == CBCGPBaseTabWnd::LOCATION_BOTTOM)
{
rectFill.top--;
}
else
{
rectFill.bottom++;
}
}
pDC->FillSolidRect(rectFill, clrTab);
}
COLORREF clrTabText = pTabWnd->GetTabTextColor(iTab);
if (clrTabText == (COLORREF)-1)
{
if (pTabWnd->IsMDITab())
{
if (bIsActive)
{
if (pTabWnd->IsMDIFocused() && pTabWnd->IsActiveInMDITabGroup())
{
clrTabText = RGB(255, 255, 255);
}
else
{
clrTabText = globalData.clrBarText;
}
}
else if (bIsHighlight)
{
clrTabText = RGB(255, 255, 255);
}
else
{
clrTabText = globalData.clrBarText;
}
}
else
{
clrTabText = (bIsActive || bIsHighlight) ? m_clrAccentText : globalData.clrBarText;
}
}
OnDrawTabContent(pDC, rectTab, iTab, bIsActive, pTabWnd, clrTabText);
}
//**********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawTabContent (CDC* pDC, CRect rectTab,
int iTab, BOOL bIsActive, const CBCGPBaseTabWnd* pTabWnd,
COLORREF clrText)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
(pTabWnd->IsDialogControl () && !pTabWnd->IsPropertySheetTab()) ||
pTabWnd->GetTabBkColor(iTab) != (COLORREF)-1 ||
clrText != (COLORREF)-1)
{
}
else
{
if (!bIsActive)
{
pDC->SetTextColor(globalData.clrBarText);
}
}
CBCGPVisualManagerVS2010::OnDrawTabContent (pDC, rectTab, iTab, bIsActive, pTabWnd, clrText);
}
//**********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawTabCloseButton (CDC* pDC, CRect rect,
const CBCGPBaseTabWnd* pTabWnd,
BOOL bIsHighlighted,
BOOL bIsPressed,
BOOL bIsDisabled)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
(pTabWnd->GetTabBkColor(m_nCurrDrawedTab) != (COLORREF)-1 && !bIsHighlighted && !bIsPressed) ||
((pTabWnd->IsOneNoteStyle () || pTabWnd->IsLeftRightRounded()) && m_nCurrDrawedTab == pTabWnd->GetActiveTab()))
{
CBCGPVisualManagerVS2010::OnDrawTabCloseButton (pDC, rect, pTabWnd, bIsHighlighted, bIsPressed, bIsDisabled);
return;
}
rect.DeflateRect(1, 0);
CBCGPMenuImages::IMAGE_STATE state = (bIsPressed && bIsHighlighted) || m_Style == VS2012_Dark ? CBCGPMenuImages::ImageWhite :
CBCGPMenuImages::ImageBlack;
if (pTabWnd->IsMDITab())
{
BOOL bActive = m_nCurrDrawedTab == pTabWnd->GetActiveTab() && pTabWnd->IsMDIFocused() && pTabWnd->IsActiveInMDITabGroup();
if (bActive)
{
state = CBCGPMenuImages::ImageWhite;
}
if (bIsPressed && bIsHighlighted)
{
if (bActive)
{
pDC->FillSolidRect (rect, m_clrAccentText);
}
else
{
pDC->FillRect(rect, &m_brAccent);
}
state = CBCGPMenuImages::ImageWhite;
}
else if (bIsHighlighted || bIsPressed)
{
pDC->FillRect (rect, &m_brAccentLight);
state = CBCGPMenuImages::ImageWhite;
}
}
else
{
if (bIsHighlighted)
{
pDC->FillSolidRect(rect, bIsPressed ? m_clrAccent : globalData.clrBarShadow);
}
if (pTabWnd->IsFlatTab() && !bIsHighlighted && m_nCurrDrawedTab == pTabWnd->GetActiveTab())
{
state = CBCGPMenuImages::ImageBlack;
}
}
CBCGPMenuImages::Draw (pDC, CBCGPMenuImages::IdClose, rect, state);
if (bIsHighlighted && !pTabWnd->IsMDITab())
{
pDC->Draw3dRect (rect, m_clrMenuItemBorder, m_clrMenuItemBorder);
}
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawAutoHideButtonBorder (CDC* pDC, CRect rect, CRect rectBorderSize, CBCGPAutoHideButton* pButton)
{
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawAutoHideButtonBorder (pDC, rect, rectBorderSize, pButton);
return;
}
DWORD dwAlign = (pButton->GetAlignment () & CBRS_ALIGN_ANY);
switch (dwAlign)
{
case CBRS_ALIGN_LEFT:
case CBRS_ALIGN_RIGHT:
rect.bottom--;
break;
case CBRS_ALIGN_TOP:
case CBRS_ALIGN_BOTTOM:
rect.right--;
break;
}
if (pButton->IsHighlighted ())
{
pDC->FillRect(rect, &m_brMenuLight);
}
}
//*********************************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetAutoHideButtonTextColor (CBCGPAutoHideButton* pButton)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetAutoHideButtonTextColor (pButton);
}
return pButton->IsHighlighted() ? m_clrAccentText : globalData.clrBarText;
}
//*********************************************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnDrawControlBarCaption (CDC* pDC, CBCGPDockingControlBar* pBar,
BOOL bActive, CRect rectCaption, CRect rectButtons)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnDrawControlBarCaption (pDC, pBar, bActive, rectCaption, rectButtons);
}
ASSERT_VALID (pDC);
rectCaption.bottom++;
if (bActive)
{
pDC->FillRect(rectCaption, &m_brAccent);
return RGB(255, 255, 255);
}
else
{
pDC->FillRect(rectCaption, &globalData.brBarFace);
return globalData.clrBarText;
}
}
//****************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawControlBarCaptionText (CDC* pDC, CBCGPDockingControlBar* pBar, BOOL bActive, const CString& strTitle, CRect& rectCaption)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawControlBarCaptionText(pDC, pBar, bActive, strTitle, rectCaption);
return;
}
ASSERT_VALID (pDC);
int nTextWidth = 0;
if (!strTitle.IsEmpty())
{
CRect rectText = rectCaption;
pDC->DrawText (strTitle, rectText, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);
CSize sizeText = pDC->GetTextExtent(strTitle);
nTextWidth = sizeText.cx + sizeText.cy / 2;
}
CRect rectGripper = rectCaption;
rectGripper.left += nTextWidth;
COLORREF clrGripper = m_clrGripper;
COLORREF clrGripperBk = m_clrGripperBk;
if (bActive)
{
m_clrGripper = RGB(255, 255, 255);
m_clrGripperBk = m_clrAccent;
}
OnDrawBarGripper (pDC, rectGripper, TRUE, pBar);
m_clrGripper = clrGripper;
m_clrGripperBk = clrGripperBk;
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawBarGripper (CDC* pDC, CRect rectGripper, BOOL bHorz, CBCGPBaseControlBar* pBar)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawBarGripper(pDC, rectGripper, bHorz, pBar);
return;
}
ASSERT_VALID (pDC);
COLORREF clrTextOld = pDC->SetTextColor (m_clrGripper);
COLORREF clrBkOld = pDC->SetBkColor (m_clrGripperBk);
CRect rectFill = rectGripper;
int nSize = 5;
CBCGPToolBar* pToolBar = DYNAMIC_DOWNCAST (CBCGPToolBar, pBar);
if (pToolBar != NULL)
{
if (bHorz)
{
int xCenter = rectFill.CenterPoint ().x;
rectFill.left = xCenter - 1;
rectFill.right = rectFill.left + nSize;
rectFill.DeflateRect (0, 2);
}
else
{
int yCenter = rectFill.CenterPoint ().y;
rectFill.top = yCenter - 1;
rectFill.bottom = rectFill.top + nSize;
rectFill.DeflateRect (2, 0);
}
}
else
{
rectFill.top = rectFill.CenterPoint().y - nSize / 2;
rectFill.bottom = rectFill.top + nSize;
}
pDC->FillRect (rectFill, bHorz ? &m_brGripperHorz : &m_brGripperVert);
pDC->SetTextColor (clrTextOld);
pDC->SetBkColor (clrBkOld);
}
//*********************************************************************************************************
BOOL CBCGPVisualManagerVS2012::IsAutoGrayscaleImages()
{
return m_bAutoGrayscaleImages && globalData.m_nBitsPerPixel > 8 && !globalData.m_bIsBlackHighContrast;
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::ModifyGlobalColors ()
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::ModifyGlobalColors();
return;
}
if (m_Style == VS2012_Light)
{
globalData.clrBarFace = RGB (239, 239, 242);
globalData.clrBarText = RGB (30, 30, 30);
globalData.clrBarShadow = RGB (203, 205, 218);
globalData.clrBarHilite = RGB (255, 255, 255);
globalData.clrBarDkShadow = RGB(162, 164, 165);
globalData.clrBarLight = RGB (252, 252, 252);
}
else
{
globalData.clrBarFace = RGB (58, 58, 58);
globalData.clrBarText = RGB (241, 241, 241);
globalData.clrBarShadow = RGB (120, 120, 120);
globalData.clrBarHilite = RGB (104, 104, 104);
globalData.clrBarDkShadow = RGB(190, 190, 190);
globalData.clrBarLight = RGB (90, 90, 90);
}
globalData.brBarFace.DeleteObject ();
globalData.brBarFace.CreateSolidBrush (globalData.clrBarFace);
}
//************************************************************************************
void CBCGPVisualManagerVS2012::OnUpdateSystemColors ()
{
CBCGPVisualManagerVS2010::OnUpdateSystemColors ();
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return;
}
m_dblGrayScaleLumRatio = (m_Style == VS2012_Light) ? 0.8 : 1.1;
CBCGPMenuImages::SetColor (CBCGPMenuImages::ImageWhite, RGB(255, 255, 255));
m_brAccent.DeleteObject();
m_brAccent.CreateSolidBrush(m_clrAccent);
m_clrAccentLight = CBCGPDrawManager::PixelAlpha(m_clrAccent, m_Style == VS2012_Light ? 140 : 75);
m_brAccentLight.DeleteObject();
m_brAccentLight.CreateSolidBrush(m_clrAccentLight);
m_clrAccentText = CBCGPDrawManager::PixelAlpha (m_clrAccent, m_Style == VS2012_Light ? 75 : 140);
m_clrGripper = m_Style == VS2012_Light ? RGB (90, 91, 93) : RGB(208, 210, 211);
m_clrTextDisabled = globalData.clrBarDkShadow;
m_clrMenuSeparator = globalData.clrBarShadow;
m_clrBarBkgnd = globalData.clrBarLight;
m_brBarBkgnd.DeleteObject();
m_brBarBkgnd.CreateSolidBrush (globalData.clrBarLight);
m_clrGripperBk = globalData.clrBarFace;
m_brTabs.DeleteObject();
m_brTabs.CreateSolidBrush((m_Style == VS2012_Light) ? globalData.clrBarShadow : globalData.clrBarLight);
m_clrHighlight = globalData.clrBarLight;
m_brHighlight.DeleteObject();
m_brHighlight.CreateSolidBrush(m_clrHighlight);
m_clrHighlightDn = m_clrAccent;
m_brHighlightDn.DeleteObject();
m_brHighlightDn.CreateSolidBrush(m_clrHighlightDn);
m_clrHighlightChecked = globalData.clrBarFace;
m_brHighlightChecked.DeleteObject();
m_brHighlightChecked.CreateSolidBrush(m_clrHighlightChecked);
m_clrHighlightMenuItem = globalData.clrBarHilite;
m_clrHighlightGradientLight = globalData.clrBarHilite;
m_clrHighlightGradientDark = globalData.clrBarHilite;
m_clrHighlightDnGradientDark = m_clrAccent;
m_clrHighlightDnGradientLight = m_clrAccent;
m_clrMenuLight = m_Style == VS2012_Light ? RGB(231, 232, 236) : RGB(27, 27, 27);
m_brMenuConnect.DeleteObject();
m_brMenuConnect.CreateSolidBrush(m_clrMenuLight);
m_clrPressedButtonBorder = m_clrMenuItemBorder = m_clrAccent;
m_clrMenuItemBorder = m_clrHighlight;
m_penMenuItemBorder.DeleteObject ();
m_penMenuItemBorder.CreatePen (PS_SOLID, 1, m_clrMenuItemBorder);
m_brMenuLight.DeleteObject ();
m_brMenuLight.CreateSolidBrush (m_clrMenuLight);
m_brTabBack.DeleteObject ();
m_brTabBack.CreateSolidBrush (globalData.clrBarFace);
m_brFace.DeleteObject ();
m_brFace.CreateSolidBrush (m_clrToolBarGradientLight);
m_clrToolbarDisabled = globalData.clrBarHilite;
m_penBottomLine.DeleteObject ();
m_penBottomLine.CreatePen (PS_SOLID, 1, m_clrToolBarBottomLine);
m_brMenuButtonDroppedDown.DeleteObject ();
m_brMenuButtonDroppedDown.CreateSolidBrush (m_clrBarBkgnd);
m_brMenuItemCheckedHighlight.DeleteObject ();
m_brMenuItemCheckedHighlight.CreateSolidBrush (globalData.clrBarLight);
m_penSeparator.DeleteObject ();
m_clrSeparator = globalData.clrBarDkShadow;
m_penSeparator.CreatePen (PS_SOLID, 1, m_clrSeparator);
m_clrMenuBorder = globalData.clrBarShadow;
m_clrMenuGutter = globalData.clrBarLight;
m_brMenuGutter.DeleteObject();
m_brMenuGutter.CreateSolidBrush(m_clrMenuGutter);
m_clrEditBoxBorder = m_clrSeparator;
m_clrCombo = globalData.clrBarLight;
m_clrComboDisabled = globalData.clrBarFace;
m_clrCaptionBarGradientDark = m_clrHighlight;
m_clrCaptionBarGradientLight = m_clrHighlight;
m_brDlgBackground.DeleteObject();
m_brDlgBackground.CreateSolidBrush(globalData.clrBarFace);
m_clrEditCtrlSelectionBkActive = CBCGPDrawManager::PixelAlpha(m_clrAccent, 150);
m_clrEditCtrlSelectionTextActive = RGB(0, 0, 0);
m_clrEditCtrlSelectionBkInactive = globalData.clrBarFace;
m_clrEditCtrlSelectionTextInactive = globalData.clrBarText;
m_clrGridSelectionTextActive = RGB(0, 0, 0);
m_clrGridSelectionTextInactive = RGB(0, 0, 0);
m_brGridSelectionBkActive.DeleteObject();
m_brGridSelectionBkActive.CreateSolidBrush(m_clrEditCtrlSelectionBkActive);
m_brGridSelectionBkInactive.DeleteObject();
m_brGridSelectionBkInactive.CreateSolidBrush(m_clrEditCtrlSelectionBkInactive);
m_clrReportGroupText = m_clrInactiveCaptionGradient1;
m_brAutohideButton.DeleteObject();
m_brAutohideButton.CreateSolidBrush(globalData.clrBarFace);
m_brDlgButtonsArea.DeleteObject ();
m_brDlgButtonsArea.CreateSolidBrush (globalData.clrBarShadow);
m_clrBarGradientDark = m_clrBarGradientLight = globalData.clrBarFace;
m_clrToolBarGradientDark = m_clrToolBarGradientLight = globalData.clrBarFace;
m_clrPlannerWork = globalData.clrBarFace;
m_clrPalennerLine = globalData.clrBarDkShadow;
m_clrPlannerTodayFill = m_clrAccent;
m_clrPlannerTodayLine = m_clrAccentText;
m_penPlannerTodayLine.DeleteObject ();
m_penPlannerTodayLine.CreatePen(PS_SOLID, 1, m_clrPlannerTodayLine);
m_brGripperHorz.DeleteObject();
m_brGripperVert.DeleteObject();
WORD bits[4] = {0xF0, 0xD0, 0xF0, 0x70};
CBitmap bm;
bm.CreateBitmap(4, 4, 1, 1, bits);
m_brGripperHorz.CreatePatternBrush(&bm);
m_brGripperVert.CreatePatternBrush(&bm);
}
//*********************************************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillCommandsListBackground (CDC* pDC, CRect rect, BOOL bIsSelected)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnFillCommandsListBackground (pDC, rect, bIsSelected);
}
ASSERT_VALID (this);
ASSERT_VALID (pDC);
rect.left = 0;
if (bIsSelected)
{
pDC->FillRect(rect, &m_brAccent);
pDC->Draw3dRect(rect, RGB(255, 255, 255), RGB(255, 255, 255));
return RGB(255, 255, 255);
}
else
{
pDC->FillRect (rect, &m_brMenuLight);
return globalData.clrBarText;
}
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::GetTabFrameColors (const CBCGPBaseTabWnd* pTabWnd,
COLORREF& clrDark,
COLORREF& clrBlack,
COLORREF& clrHighlight,
COLORREF& clrFace,
COLORREF& clrDarkShadow,
COLORREF& clrLight,
CBrush*& pbrFace,
CBrush*& pbrBlack)
{
ASSERT_VALID (pTabWnd);
CBCGPVisualManagerXP::GetTabFrameColors (pTabWnd,
clrDark, clrBlack,
clrHighlight, clrFace,
clrDarkShadow, clrLight,
pbrFace, pbrBlack);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || pTabWnd->IsDialogControl () ||
pTabWnd->IsFlatTab ())
{
return;
}
clrFace = clrBlack;
pbrFace = &m_brTabs;
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawTabResizeBar (CDC* pDC, CBCGPBaseTabWnd* pWndTab,
BOOL bIsVert, CRect rect,
CBrush* pbrFace, CPen* pPen)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || pWndTab->IsFlatTab ())
{
CBCGPVisualManagerVS2010::OnDrawTabResizeBar (pDC, pWndTab, bIsVert, rect, pbrFace, pPen);
return;
}
ASSERT_VALID (pDC);
pDC->FillRect(rect, &globalData.brBarFace);
}
//*********************************************************************************************************
BCGP_SMARTDOCK_THEME CBCGPVisualManagerVS2012::GetSmartDockingTheme ()
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !globalData.IsWindowsLayerSupportAvailable ())
{
return CBCGPVisualManagerVS2010::GetSmartDockingTheme ();
}
return BCGP_SDT_VS2005;
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawSlider (CDC* pDC, CBCGPSlider* pSlider, CRect rect, BOOL bAutoHideMode)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawSlider (pDC, pSlider, rect, bAutoHideMode);
return;
}
ASSERT_VALID (pDC);
pDC->FillRect(rect, &globalData.brBarFace);
}
//*********************************************************************************************************
int CBCGPVisualManagerVS2012::GetTabButtonState (CBCGPTabWnd* pTab, CBCGTabButton* pButton)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetTabButtonState (pTab, pButton);
}
return (int) (m_Style == VS2012_Dark ? CBCGPMenuImages::ImageWhite : CBCGPMenuImages::ImageBlack);
}
//*****************************************************************************
int CBCGPVisualManagerVS2012::GetMenuDownArrowState (CBCGPToolbarMenuButton* pButton, BOOL bHightlight, BOOL bPressed, BOOL bDisabled)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetMenuDownArrowState (pButton, bHightlight, bPressed, bDisabled);
}
CBCGPWnd* pWnd = DYNAMIC_DOWNCAST(CBCGPWnd, pButton->GetParentWnd());
if (pWnd != NULL && pWnd->IsOnGlass())
{
return CBCGPVisualManagerVS2010::GetMenuDownArrowState (pButton, bHightlight, bPressed, bDisabled);
}
if (pButton->IsDroppedDown())
{
return CBCGPMenuImages::ImageWhite;
}
return (int) ((m_Style == VS2012_Light) ? CBCGPMenuImages::ImageBlack : CBCGPMenuImages::ImageWhite);
}
//*****************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetStatusBarPaneTextColor (CBCGPStatusBar* pStatusBar, CBCGStatusBarPaneInfo* pPane)
{
ASSERT (pPane != NULL);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || pPane->clrText != (COLORREF)-1)
{
return CBCGPVisualManagerVS2010::GetStatusBarPaneTextColor (pStatusBar, pPane);
}
return (pPane->nStyle & SBPS_DISABLED) ? m_clrTextDisabled : globalData.clrBarText;
}
//*****************************************************************************
void CBCGPVisualManagerVS2012::OnDrawComboDropButton (CDC* pDC, CRect rect,
BOOL bDisabled,
BOOL bIsDropped,
BOOL bIsHighlighted,
CBCGPToolbarComboBoxButton* pButton)
{
ASSERT_VALID(pDC);
ASSERT_VALID (this);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPVisualManagerVS2010::OnDrawComboDropButton (pDC, rect, bDisabled, bIsDropped, bIsHighlighted, pButton);
return;
}
COLORREF clrFill = globalData.clrBarFace;
if (!bDisabled)
{
if (bIsDropped)
{
pDC->FillRect(rect, &m_brHighlightDn);
clrFill = m_clrHighlightDn;
}
else if (bIsHighlighted)
{
pDC->FillRect (rect, &m_brAccentLight);
clrFill = m_clrAccent;
}
else
{
pDC->FillRect (rect, &m_brBarBkgnd);
clrFill = m_clrBarBkgnd;
}
}
else
{
pDC->FillRect(rect, &globalData.brBarFace);
}
CBCGPMenuImages::DrawByColor(pDC, CBCGPMenuImages::IdArowDown, rect, clrFill);
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawComboBorder (CDC* pDC, CRect rect,
BOOL bDisabled,
BOOL bIsDropped,
BOOL bIsHighlighted,
CBCGPToolbarComboBoxButton* pButton)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPVisualManagerVS2010::OnDrawComboBorder (pDC, rect, bDisabled, bIsDropped, bIsHighlighted, pButton);
return;
}
if (bDisabled)
{
pDC->Draw3dRect(rect, m_clrTextDisabled, m_clrTextDisabled);
}
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawEditBorder (CDC* pDC, CRect rect,
BOOL bDisabled,
BOOL bIsHighlighted,
CBCGPToolbarEditBoxButton* pButton)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !CBCGPToolbarEditBoxButton::IsFlatMode () || CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPVisualManagerVS2010::OnDrawEditBorder (pDC, rect, bDisabled, bIsHighlighted, pButton);
return;
}
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::OnFillButtonInterior (CDC* pDC,
CBCGPToolbarButton* pButton, CRect rect, CBCGPVisualManager::BCGBUTTON_STATE state)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnFillButtonInterior(pDC, pButton, rect, state);
return;
}
CBCGPControlBar* pWnd = DYNAMIC_DOWNCAST(CBCGPControlBar, pButton->GetParentWnd());
if (pWnd != NULL && pWnd->IsDialogControl())
{
return;
}
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
CBCGPToolbarMenuButton* pMenuButton = DYNAMIC_DOWNCAST (CBCGPToolbarMenuButton, pButton);
CWnd* pWndParentMenu = (pMenuButton != NULL) ? pMenuButton->GetParentWnd() : NULL;
BOOL bIsPopupMenuButton = pWndParentMenu != NULL && pWndParentMenu->IsKindOf (RUNTIME_CLASS (CBCGPPopupMenuBar));
if (pMenuButton != NULL && !bIsPopupMenuButton && pMenuButton->IsDroppedDown ())
{
if (pWndParentMenu != NULL && pWndParentMenu->IsKindOf (RUNTIME_CLASS (CBCGPMenuBar)))
{
CRect rectFill = rect;
rectFill.DeflateRect(1, 1, 1, 0);
if (CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPDrawManager dm (*pDC);
dm.DrawRect (rect, (COLORREF)-1, m_clrMenuGutter);
dm.DrawRect (rectFill, m_clrMenuLight, (COLORREF)-1);
}
else
{
pDC->Draw3dRect(rect, m_clrMenuBorder, m_clrMenuBorder);
pDC->FillRect (rectFill, &m_brMenuLight);
}
}
else
{
rect.DeflateRect(1, 0);
if (CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPDrawManager dm (*pDC);
dm.DrawRect (rect, m_clrAccent, (COLORREF)-1);
}
else
{
pDC->FillRect (rect, &m_brAccent);
}
}
return;
}
CBCGPVisualManagerXP::OnFillButtonInterior (pDC, pButton, rect, state);
}
//***********************************************************************************
void CBCGPVisualManagerVS2012::OnFillHighlightedArea (CDC* pDC, CRect rect, CBrush* pBrush, CBCGPToolbarButton* pButton)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || pButton == NULL)
{
CBCGPVisualManagerVS2010::OnFillHighlightedArea (pDC, rect, pBrush, pButton);
return;
}
ASSERT_VALID (pDC);
ASSERT_VALID (pBrush);
ASSERT_VALID (pButton);
BOOL bIsPopupMenu = pButton->GetParentWnd () != NULL &&
pButton->GetParentWnd ()->IsKindOf (RUNTIME_CLASS (CBCGPPopupMenuBar));
CBCGPDrawManager dm (*pDC);
if (pBrush == &m_brHighlight)
{
dm.DrawRect(rect, bIsPopupMenu ? m_clrHighlightMenuItem : m_clrHighlight, (COLORREF)-1);
return;
}
else if (pBrush == &m_brHighlightDn)
{
dm.DrawRect(rect, (pButton->m_nStyle & TBBS_CHECKED) == 0 ? m_clrAccent : m_clrHighlight, (COLORREF)-1);
return;
}
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2012::OnHighlightRarelyUsedMenuItems (CDC* pDC, CRect rectRarelyUsed)
{
ASSERT_VALID (pDC);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnHighlightRarelyUsedMenuItems (pDC, rectRarelyUsed);
return;
}
rectRarelyUsed.left --;
rectRarelyUsed.right = rectRarelyUsed.left + CBCGPToolBar::GetMenuImageSize ().cx +
2 * GetMenuImageMargin () + 2;
pDC->FillRect (rectRarelyUsed, &m_brHighlight);
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawButtonBorder (CDC* pDC, CBCGPToolbarButton* pButton, CRect rect, BCGBUTTON_STATE state)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawButtonBorder (pDC, pButton, rect, state);
return;
}
CBCGPControlBar* pWnd = DYNAMIC_DOWNCAST(CBCGPControlBar, pButton->GetParentWnd());
if (pWnd != NULL && pWnd->IsDialogControl())
{
CBCGPVisualManager::OnDrawButtonBorder(pDC, pButton, rect, state);
return;
}
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
if (pButton->m_nStyle & TBBS_CHECKED)
{
COLORREF clrBorder = (!CBCGPToolBar::IsCustomizeMode () && (pButton->m_nStyle & TBBS_DISABLED)) ? globalData.clrBarShadow : m_clrAccent;
if (CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPDrawManager dm (*pDC);
dm.DrawRect (rect, (COLORREF)-1, clrBorder);
}
else
{
pDC->Draw3dRect(rect, clrBorder, clrBorder);
}
}
}
//*************************************************************************************
int CBCGPVisualManagerVS2012::GetTabExtraHeight(const CBCGPTabWnd* pTabWnd)
{
ASSERT_VALID(pTabWnd);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
(pTabWnd->IsDialogControl () && !pTabWnd->IsPropertySheetTab()) || !pTabWnd->IsMDITab() ||
pTabWnd->IsFlatTab () || pTabWnd->IsOneNoteStyle () || pTabWnd->IsVS2005Style ())
{
return CBCGPVisualManagerVS2010::GetTabExtraHeight(pTabWnd);
}
return 0;
}
//*************************************************************************************
BOOL CBCGPVisualManagerVS2012::OnEraseMDIClientArea (CDC* pDC, CRect rectClient)
{
if (globalData.m_nBitsPerPixel > 8 && !globalData.IsHighContastMode ())
{
CMDIFrameWnd* pMDIFrameWnd = DYNAMIC_DOWNCAST (CMDIFrameWnd, AfxGetMainWnd ());
if (pMDIFrameWnd != NULL)
{
pDC->FillRect(rectClient, &globalData.brBarFace);
return TRUE;
}
}
return CBCGPVisualManagerVS2010::OnEraseMDIClientArea (pDC, rectClient);
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::OnFillCombo (CDC* pDC, CRect rect,
BOOL bDisabled,
BOOL bIsDropped,
BOOL bIsHighlighted,
CBCGPToolbarComboBoxButton* pButton)
{
ASSERT_VALID (pDC);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPVisualManagerXP::OnFillCombo(pDC, rect, bDisabled, bIsDropped, bIsHighlighted, pButton);
return;
}
COLORREF clr = bDisabled ? m_clrComboDisabled : (bIsHighlighted || bIsDropped) ? globalData.clrBarHilite : m_clrCombo;
if (CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPDrawManager dm (*pDC);
dm.DrawRect (rect, clr, (COLORREF)-1);
}
else
{
pDC->FillSolidRect (rect, clr);
}
}
//************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetComboboxTextColor(CBCGPToolbarComboBoxButton* pButton,
BOOL bDisabled,
BOOL bIsDropped,
BOOL bIsHighlighted)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetComboboxTextColor(pButton, bDisabled, bIsDropped, bIsHighlighted);
}
return bDisabled ? globalData.clrGrayedText : globalData.clrBarText;
}
//************************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillMiniFrameCaption (CDC* pDC,
CRect rectCaption,
CBCGPMiniFrameWnd* pFrameWnd,
BOOL bActive)
{
ASSERT_VALID (pDC);
ASSERT_VALID (pFrameWnd);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnFillMiniFrameCaption (pDC, rectCaption, pFrameWnd, bActive);
}
if (DYNAMIC_DOWNCAST (CBCGPBaseToolBar, pFrameWnd->GetControlBar ()) != NULL)
{
bActive = FALSE;
}
if (bActive)
{
pDC->FillRect(rectCaption, &m_brAccent);
return RGB(255, 255, 255);
}
else
{
pDC->FillRect(rectCaption, &globalData.brBarFace);
return globalData.clrBarText;
}
}
//************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawMiniFrameBorder (
CDC* pDC, CBCGPMiniFrameWnd* pFrameWnd,
CRect rectBorder, CRect rectBorderSize)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawMiniFrameBorder (pDC, pFrameWnd, rectBorder, rectBorderSize);
return;
}
ASSERT_VALID (pDC);
CRect rectClip = rectBorder;
rectClip.DeflateRect(rectClip);
pDC->ExcludeClipRect(rectClip);
if (pFrameWnd->GetSafeHwnd() != NULL && pFrameWnd->IsActive())
{
pDC->FillRect(rectBorder, &m_brAccent);
}
else
{
CBrush br(globalData.clrBarDkShadow);
pDC->FillRect(rectBorder, &br);
}
pDC->SelectClipRgn (NULL);
}
//**************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetToolbarButtonTextColor (CBCGPToolbarButton* pButton, CBCGPVisualManager::BCGBUTTON_STATE state)
{
ASSERT_VALID (pButton);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || pButton->IsKindOf (RUNTIME_CLASS (CBCGPOutlookButton)))
{
return CBCGPVisualManagerVS2010::GetToolbarButtonTextColor (pButton, state);
}
if (pButton->GetParentWnd() != NULL && pButton->GetParentWnd()->IsKindOf (RUNTIME_CLASS (CBCGPReBar)))
{
return CBCGPVisualManagerVS2010::GetToolbarButtonTextColor (pButton, state);
}
BOOL bDisabled = (CBCGPToolBar::IsCustomizeMode () && !pButton->IsEditable ()) ||
(!CBCGPToolBar::IsCustomizeMode () && (pButton->m_nStyle & TBBS_DISABLED));
CBCGPControlBar* pWnd = DYNAMIC_DOWNCAST(CBCGPControlBar, pButton->GetParentWnd());
if (pWnd != NULL && pWnd->IsDialogControl())
{
return bDisabled ? globalData.clrGrayedText : globalData.clrBtnText;
}
BOOL bIsDroppedDownOnToolbar = pButton->IsDroppedDown();
if (bIsDroppedDownOnToolbar)
{
if (pButton->GetParentWnd() != NULL && pButton->GetParentWnd()->IsKindOf (RUNTIME_CLASS (CBCGPMenuBar)))
{
bIsDroppedDownOnToolbar = FALSE;
}
}
COLORREF clrLight = m_Style == VS2012_Light ? globalData.clrBarHilite : globalData.clrBarText;
return bDisabled ? m_clrTextDisabled : (bIsDroppedDownOnToolbar || state == ButtonsIsHighlighted && (pButton->m_nStyle & TBBS_PRESSED)) ? clrLight : globalData.clrBarText;
}
//**************************************************************************************
BOOL CBCGPVisualManagerVS2012::OnDrawPushButton (CDC* pDC, CRect rect, CBCGPButton* pButton, COLORREF& clrText)
{
ASSERT_VALID(pDC);
BOOL bOnGlass = pButton->GetSafeHwnd() != NULL && pButton->m_bOnGlass;
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || bOnGlass ||
m_brDlgBackground.GetSafeHandle () == NULL)
{
return CBCGPVisualManagerVS2010::OnDrawPushButton (pDC, rect, pButton, clrText);
}
ASSERT_VALID (pDC);
clrText = globalData.clrBarText;
globalData.DrawParentBackground (pButton, pDC);
BOOL bDefault = pButton->GetSafeHwnd() != NULL && pButton->IsDefaultButton () && pButton->IsWindowEnabled ();
CPen pen (PS_SOLID, 1, bDefault ? m_clrAccentText : globalData.clrBarDkShadow);
CPen* pOldPen = pDC->SelectObject (&pen);
CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&globalData.brBarFace);
if (pButton->GetSafeHwnd() != NULL && pButton->IsWindowEnabled ())
{
if (pButton->IsPressed ())
{
if (!pButton->GetCheck ())
{
pDC->SelectObject(&m_brHighlightDn);
if (m_Style == VS2012_Light)
{
clrText = globalData.clrBarHilite;
}
}
pDC->SelectObject(&m_penMenuItemBorder);
}
else if (pButton->IsHighlighted () || CWnd::GetFocus () == pButton || pButton->GetCheck ())
{
pDC->SelectObject(&m_brHighlight);
}
}
pDC->RoundRect(rect, CPoint(5, 5));
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
return TRUE;
}
//**************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetToolbarDisabledTextColor ()
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerXP::GetToolbarDisabledTextColor();
}
return m_clrTextDisabled;
}
#ifndef BCGP_EXCLUDE_PROP_LIST
COLORREF CBCGPVisualManagerVS2012::OnFillPropList(CDC* pDC, CBCGPPropList* pPropList, const CRect& rectClient, COLORREF& clrFill)
{
ASSERT_VALID (pPropList);
if (!pPropList->DrawControlBarColors() || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerXP::OnFillPropList(pDC, pPropList, rectClient, clrFill);
}
pDC->FillSolidRect(rectClient, globalData.clrBarLight);
clrFill = globalData.clrBarLight;
return globalData.clrBarText;
}
//****************************************************************************************
void CBCGPVisualManagerVS2012::OnFillPropListToolbarArea(CDC* pDC, CBCGPPropList* pPropList, const CRect& rectToolBar)
{
if ((pPropList != NULL && !pPropList->DrawControlBarColors()) || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerXP::OnFillPropListToolbarArea(pDC, pPropList, rectToolBar);
return;
}
pDC->FillRect(rectToolBar, &globalData.brBarFace);
}
//****************************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillPropertyListSelectedItem(CDC* pDC, CBCGPProp* pProp, CBCGPPropList* pWndList, const CRect& rectFill, BOOL bFocused)
{
ASSERT_VALID (pDC);
ASSERT_VALID(pProp);
if (!pWndList->DrawControlBarColors() || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerXP::OnFillPropertyListSelectedItem(pDC, pProp, pWndList, rectFill, bFocused);
}
if (bFocused)
{
pDC->FillRect (rectFill, &m_brAccent);
return pProp->IsEnabled() ? RGB(255, 255, 255) : globalData.clrBarLight;
}
else
{
pDC->FillSolidRect(rectFill, globalData.clrBarShadow);
return pProp->IsEnabled() ? globalData.clrBarText : globalData.clrBarDkShadow;
}
}
//****************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPropListGroupTextColor(CBCGPPropList* pPropList)
{
ASSERT_VALID (pPropList);
if (!pPropList->DrawControlBarColors () || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerXP::GetPropListGroupTextColor(pPropList);
}
return m_Style == VS2012_Light ? RGB(0, 0, 0) : globalData.clrBarText;
}
//***********************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillPropListDescriptionArea(CDC* pDC, CBCGPPropList* pList, const CRect& rect)
{
ASSERT_VALID(pDC);
ASSERT_VALID(pList);
if (!pList->DrawControlBarColors () || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerXP::OnFillPropListDescriptionArea(pDC, pList, rect);
}
pDC->FillSolidRect(rect, globalData.clrBarLight);
return globalData.clrBarFace;
}
//***********************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillPropListCommandsArea(CDC* pDC, CBCGPPropList* pList, const CRect& rect)
{
ASSERT_VALID(pDC);
ASSERT_VALID(pList);
if (!pList->DrawControlBarColors () || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerXP::OnFillPropListCommandsArea(pDC, pList, rect);
}
pDC->FillSolidRect(rect, globalData.clrBarLight);
return globalData.clrBarFace;
}
//***********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPropListCommandTextColor (CBCGPPropList* pPropList)
{
ASSERT_VALID (pPropList);
if (!pPropList->DrawControlBarColors () || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetPropListCommandTextColor (pPropList);
}
return m_clrAccentText;
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPropListDisabledTextColor(CBCGPPropList* pPropList)
{
if (!pPropList->DrawControlBarColors () || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetPropListDisabledTextColor(pPropList);
}
return globalData.clrBarDkShadow;
}
#endif
void CBCGPVisualManagerVS2012::OnDrawMenuBorder (CDC* pDC, CBCGPPopupMenu* pMenu, CRect rect)
{
CBCGPVisualManagerXP::OnDrawMenuBorder (pDC, pMenu, rect);
}
//*****************************************************************************
void CBCGPVisualManagerVS2012::OnDrawMenuCheck (CDC* pDC, CBCGPToolbarMenuButton* pButton, CRect rect, BOOL bHighlight, BOOL bIsRadio)
{
ASSERT_VALID (pButton);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawMenuCheck (pDC, pButton, rect, bHighlight, bIsRadio);
return;
}
int iImage = bIsRadio ? CBCGPMenuImages::IdRadio : CBCGPMenuImages::IdCheck;
rect.DeflateRect(0, 1);
CBCGPMenuImages::Draw (pDC, (CBCGPMenuImages::IMAGES_IDS) iImage,
rect,
(pButton->m_nStyle & TBBS_DISABLED) ? CBCGPMenuImages::ImageGray :
(m_Style == VS2012_Light) ? CBCGPMenuImages::ImageBlack : CBCGPMenuImages::ImageWhite);
}
//****************************************************************************************
void CBCGPVisualManagerVS2012::OnFillMenuImageRect (CDC* pDC, CBCGPToolbarButton* pButton, CRect rect, CBCGPVisualManager::BCGBUTTON_STATE state)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnFillMenuImageRect(pDC, pButton, rect, state);
}
}
//****************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawMenuImageRectBorder (CDC* pDC, CBCGPToolbarButton* pButton, CRect rect, CBCGPVisualManager::BCGBUTTON_STATE state)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawMenuImageRectBorder(pDC, pButton, rect, state);
return;
}
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
if (pButton->m_nStyle & TBBS_CHECKED)
{
if (!CBCGPToolBar::IsCustomizeMode () && (pButton->m_nStyle & TBBS_DISABLED))
{
pDC->Draw3dRect(rect, globalData.clrBarShadow, globalData.clrBarShadow);
}
else if (pButton->GetImage() < 0 || DYNAMIC_DOWNCAST(CBCGPCustomizeMenuButton, pButton) != NULL)
{
COLORREF clrFrame = m_Style == VS2012_Light ? RGB(0, 0, 0) : globalData.clrBarText;
rect.bottom++;
pDC->Draw3dRect(rect, clrFrame, clrFrame);
rect.DeflateRect(1, 1);
pDC->Draw3dRect(rect, clrFrame, clrFrame);
}
else
{
pDC->Draw3dRect(rect, m_clrAccent, m_clrAccent);
}
}
}
//**************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetMenuItemTextColor(CBCGPToolbarMenuButton* pButton, BOOL bHighlighted, BOOL bDisabled)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetMenuItemTextColor (pButton, bHighlighted, bDisabled);
}
return bDisabled ? m_clrTextDisabled : globalData.clrBarText;
}
//**************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawCaptionButton (CDC* pDC, CBCGPCaptionButton* pButton,
BOOL bActive, BOOL bHorz, BOOL bMaximized, BOOL bDisabled,
int nImageID /*= -1*/)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawCaptionButton (pDC, pButton, bActive, bHorz, bMaximized, bDisabled, nImageID);
return;
}
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
CRect rc = pButton->GetRect ();
const BOOL bHighlight = (pButton->m_bFocused || pButton->m_bDroppedDown) && !bDisabled;
if (pButton->m_bPushed && bHighlight)
{
if (bActive)
{
pDC->FillSolidRect (rc, m_clrAccentText);
}
else
{
pDC->FillRect(rc, &m_brAccent);
}
}
else if (bHighlight || pButton->m_bPushed)
{
if (bActive)
{
pDC->FillRect (rc, &m_brAccentLight);
}
else
{
pDC->FillSolidRect (rc, globalData.clrBarShadow);
}
}
CBCGPMenuImages::IMAGES_IDS id = (CBCGPMenuImages::IMAGES_IDS)-1;
if (nImageID != -1)
{
id = (CBCGPMenuImages::IMAGES_IDS)nImageID;
}
else
{
id = pButton->GetIconID (bHorz, bMaximized);
}
if (id != (CBCGPMenuImages::IMAGES_IDS)-1)
{
CSize sizeImage = CBCGPMenuImages::Size ();
CPoint ptImage (rc.left + (rc.Width () - sizeImage.cx) / 2,
rc.top + (rc.Height () - sizeImage.cy) / 2);
OnDrawCaptionButtonIcon (pDC, pButton, id, bActive, bDisabled, ptImage);
}
}
//**********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawCaptionButtonIcon (CDC* pDC,
CBCGPCaptionButton* pButton,
CBCGPMenuImages::IMAGES_IDS id,
BOOL bActive, BOOL bDisabled,
CPoint ptImage)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawCaptionButtonIcon (pDC, pButton, id, bActive, bDisabled, ptImage);
return;
}
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
CBCGPMenuImages::IMAGE_STATE imageState = (m_Style == VS2012_Dark ? CBCGPMenuImages::ImageLtGray : CBCGPMenuImages::ImageBlack);
if (bDisabled)
{
imageState = CBCGPMenuImages::ImageGray;
}
else if (bActive || ((pButton->m_bFocused && pButton->m_bPushed) && m_Style == VS2012_Light))
{
imageState = CBCGPMenuImages::ImageWhite;
}
CBCGPMenuImages::Draw (pDC, id, ptImage, imageState);
}
#ifndef BCGP_EXCLUDE_TOOLBOX
BOOL CBCGPVisualManagerVS2012::OnEraseToolBoxButton (CDC* pDC, CRect rect,
CBCGPToolBoxButton* pButton)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnEraseToolBoxButton(pDC, rect, pButton);
}
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
if (pButton->GetCheck ())
{
pDC->FillRect(rect, &m_brAccent);
}
else if (pButton->IsHighlighted ())
{
CBrush brFill(globalData.clrBarHilite);
pDC->FillRect(rect, &brFill);
}
return TRUE;
}
//**********************************************************************************
BOOL CBCGPVisualManagerVS2012::OnDrawToolBoxButtonBorder (CDC* pDC, CRect& rect,
CBCGPToolBoxButton* pButton, UINT uiState)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnDrawToolBoxButtonBorder(pDC, rect, pButton, uiState);
}
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
if (pButton->GetCheck ())
{
pDC->Draw3dRect(rect, globalData.clrBarHilite, globalData.clrBarHilite);
}
return TRUE;
}
//**********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetToolBoxButtonTextColor (CBCGPToolBoxButton* pButton)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetToolBoxButtonTextColor(pButton);
}
if (m_Style == VS2012_Dark)
{
return globalData.clrBarText;
}
ASSERT_VALID (pButton);
return pButton->m_bIsChecked ? globalData.clrBarHilite : globalData.clrBarText;
}
#endif // BCGP_EXCLUDE_TOOLBOX
#ifndef BCGP_EXCLUDE_TASK_PANE
void CBCGPVisualManagerVS2012::OnDrawTasksGroupCaption(CDC* pDC, CBCGPTasksGroup* pGroup,
BOOL bIsHighlighted, BOOL bIsSelected,
BOOL bCanCollapse)
{
#ifndef BCGP_EXCLUDE_TOOLBOX
BOOL bIsToolBox = pGroup->m_pPage->m_pTaskPane != NULL &&
(pGroup->m_pPage->m_pTaskPane->IsKindOf (RUNTIME_CLASS (CBCGPToolBoxEx)));
#else
BOOL bIsToolBox = FALSE;
#endif
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !bIsToolBox)
{
CBCGPVisualManagerXP::OnDrawTasksGroupCaption(
pDC, pGroup,
bIsHighlighted, bIsSelected, bCanCollapse);
return;
}
CRect rectGroup = pGroup->m_rect;
CRect rectFill = rectGroup;
rectFill.DeflateRect (1, 1);
pDC->FillRect(rectFill, &m_brDlgButtonsArea);
if (bCanCollapse)
{
//--------------------
// Draw expanding box:
//--------------------
int nBoxSize = 9;
int nBoxOffset = 6;
if (globalData.GetRibbonImageScale () != 1.)
{
nBoxSize = (int)(.5 + nBoxSize * globalData.GetRibbonImageScale ());
}
CRect rectButton = rectFill;
rectButton.left += nBoxOffset;
rectButton.right = rectButton.left + nBoxSize;
rectButton.top = rectButton.CenterPoint ().y - nBoxSize / 2;
rectButton.bottom = rectButton.top + nBoxSize;
OnDrawExpandingBox (pDC, rectButton, !pGroup->m_bIsCollapsed, globalData.clrBarText);
rectGroup.left = rectButton.right + nBoxOffset;
bCanCollapse = FALSE;
}
// -----------------------
// Draw group caption text
// -----------------------
CFont* pFontOld = pDC->SelectObject (&globalData.fontBold);
COLORREF clrTextOld = pDC->SetTextColor (globalData.clrBarText);
int nBkModeOld = pDC->SetBkMode(TRANSPARENT);
int nTaskPaneHOffset = pGroup->m_pPage->m_pTaskPane->GetGroupCaptionHorzOffset();
int nTaskPaneVOffset = pGroup->m_pPage->m_pTaskPane->GetGroupCaptionVertOffset();
int nCaptionHOffset = (nTaskPaneHOffset != -1 ? nTaskPaneHOffset : m_nGroupCaptionHorzOffset);
CRect rectText = rectGroup;
rectText.left += nCaptionHOffset;
rectText.top += (nTaskPaneVOffset != -1 ? nTaskPaneVOffset : m_nGroupCaptionVertOffset);
rectText.right = max(rectText.left,
rectText.right - (bCanCollapse ? rectGroup.Height() : nCaptionHOffset));
pDC->DrawText (pGroup->m_strName, rectText, DT_SINGLELINE | DT_VCENTER);
pDC->SetBkMode(nBkModeOld);
pDC->SelectObject (pFontOld);
pDC->SetTextColor (clrTextOld);
}
#endif
void CBCGPVisualManagerVS2012::OnFillOutlookPageButton (CDC* pDC, const CRect& rect,
BOOL bIsHighlighted, BOOL bIsPressed,
COLORREF& clrText)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnFillOutlookPageButton (pDC, rect,
bIsHighlighted, bIsPressed,
clrText);
return;
}
ASSERT_VALID (pDC);
clrText = globalData.clrBarText;
if (bIsPressed)
{
pDC->FillRect(rect, &m_brAccent);
clrText = RGB(255, 255, 255);
}
else if (bIsHighlighted)
{
pDC->FillRect(rect, &m_brMenuLight);
}
else
{
pDC->FillRect(rect, &globalData.brBarFace);
}
}
//****************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawOutlookPageButtonBorder (CDC* pDC,
CRect& rectBtn, BOOL bIsHighlighted, BOOL bIsPressed)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawOutlookPageButtonBorder (pDC,
rectBtn, bIsHighlighted, bIsPressed);
return;
}
ASSERT_VALID (pDC);
COLORREF clrFrame = bIsHighlighted && bIsPressed ? globalData.clrBarHilite : globalData.clrBarShadow;
pDC->Draw3dRect (rectBtn, clrFrame, clrFrame);
}
//****************************************************************************************
void CBCGPVisualManagerVS2012::OnFillOutlookBarCaption (CDC* pDC, CRect rectCaption, COLORREF& clrText)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnFillOutlookBarCaption (pDC, rectCaption, clrText);
return;
}
pDC->FillRect(rectCaption, &m_brMenuLight);
clrText = globalData.clrBarText;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetCaptionBarTextColor (CBCGPCaptionBar* pBar)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetCaptionBarTextColor(pBar);
}
return globalData.clrBarText;
}
//****************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawHeaderCtrlBorder (CBCGPHeaderCtrl* pCtrl, CDC* pDC, CRect& rect, BOOL bIsPressed, BOOL bIsHighlighted)
{
BOOL bIsVMStyle = (pCtrl == NULL || pCtrl->m_bVisualManagerStyle);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !bIsVMStyle)
{
CBCGPVisualManagerVS2010::OnDrawHeaderCtrlBorder (pCtrl, pDC, rect, bIsPressed, bIsHighlighted);
return;
}
COLORREF clrFill = globalData.clrBarFace;
COLORREF clrBorder = globalData.clrBarShadow;
if (bIsPressed)
{
clrFill = m_clrAccent;
clrBorder = RGB(255, 255, 255);
}
else if (bIsHighlighted)
{
clrFill = globalData.clrBarLight;
clrBorder = RGB(255, 255, 255);
}
{
CBCGPDrawManager dm (*pDC);
dm.DrawRect (rect, clrFill, (COLORREF)-1);
}
CPen pen (PS_SOLID, 0, clrBorder);
CPen* pOldPen = pDC->SelectObject (&pen);
if (bIsPressed || bIsHighlighted)
{
pDC->MoveTo (rect.right - 1, rect.top);
pDC->LineTo (rect.right - 1, rect.bottom - 1);
pDC->LineTo (rect.left, rect.bottom - 1);
pDC->LineTo (rect.left, rect.top - 1);
}
else
{
pDC->MoveTo (rect.right - 1, rect.top);
pDC->LineTo (rect.right - 1, rect.bottom - 1);
pDC->LineTo (rect.left - 1, rect.bottom - 1);
}
pDC->SelectObject (pOldPen);
}
//****************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetHeaderCtrlTextColor (CBCGPHeaderCtrl* pCtrl, BOOL bIsPressed, BOOL bIsHighlighted)
{
BOOL bIsVMStyle = (pCtrl == NULL || pCtrl->m_bVisualManagerStyle);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !bIsVMStyle)
{
return CBCGPVisualManagerVS2010::GetHeaderCtrlTextColor (pCtrl, bIsPressed, bIsHighlighted);
}
return globalData.clrBarText;
}
//****************************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetURLLinkColor (CBCGPURLLinkButton* pButton, BOOL bHover)
{
ASSERT_VALID (pButton);
if (!pButton->m_bVisualManagerStyle || pButton->m_bOnGlass || globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetURLLinkColor (pButton, bHover);
}
return bHover ? m_clrAccentText : m_clrAccent;
}
#ifndef BCGP_EXCLUDE_POPUP_WINDOW
void CBCGPVisualManagerVS2012::OnFillPopupWindowBackground (CDC* pDC, CRect rect)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerXP::OnFillPopupWindowBackground (pDC, rect);
return;
}
pDC->FillSolidRect(rect, m_Style == VS2012_Light ? globalData.clrBarFace : m_clrGripper);
}
//**********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawPopupWindowBorder (CDC* pDC, CRect rect)
{
ASSERT_VALID (pDC);
CBCGPVisualManagerXP::OnDrawPopupWindowBorder (pDC, rect);
}
//**********************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnDrawPopupWindowCaption (CDC* pDC, CRect rectCaption, CBCGPPopupWindow* pPopupWnd)
{
return CBCGPVisualManagerXP::OnDrawPopupWindowCaption (pDC, rectCaption, pPopupWnd);
}
//**********************************************************************************
void CBCGPVisualManagerVS2012::OnErasePopupWindowButton (CDC* pDC, CRect rc, CBCGPPopupWndButton* pButton)
{
if (pButton->IsPressed ())
{
CBrush br (m_clrHighlightDn);
pDC->FillRect (&rc, &br);
return;
}
else if (pButton->IsHighlighted () || pButton->IsPushed ())
{
CBrush br (globalData.clrBarShadow);
pDC->FillRect (&rc, &br);
return;
}
CBCGPVisualManagerXP::OnErasePopupWindowButton (pDC, rc, pButton);
}
//**********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawPopupWindowButtonBorder (CDC* pDC, CRect rc, CBCGPPopupWndButton* pButton)
{
CBCGPVisualManagerXP::OnDrawPopupWindowButtonBorder (pDC, rc, pButton);
}
#endif // BCGP_EXCLUDE_POPUP_WINDOW
COLORREF CBCGPVisualManagerVS2012::OnFillListBox(CDC* pDC, CBCGPListBox* pListBox, CRect rectClient)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnFillListBox(pDC, pListBox, rectClient);
}
ASSERT_VALID (pDC);
pDC->FillRect(rectClient, &m_brMenuLight);
return globalData.clrBarText;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillListBoxItem (CDC* pDC, CBCGPListBox* pListBox, int nItem, CRect rect, BOOL bIsHighlihted, BOOL bIsSelected)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnFillListBoxItem (pDC, pListBox, nItem, rect, bIsHighlihted, bIsSelected);
}
ASSERT_VALID (pDC);
COLORREF clrText = (COLORREF)-1;
if (bIsSelected)
{
pDC->FillRect (rect, &m_brAccent);
clrText = RGB(255, 255, 255);
}
if (bIsHighlihted)
{
pDC->Draw3dRect(rect, RGB(255, 255, 255), RGB(255, 255, 255));
}
return clrText;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillComboBoxItem (CDC* pDC, CBCGPComboBox* pComboBox, int nItem, CRect rect, BOOL bIsHighlihted, BOOL bIsSelected)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnFillComboBoxItem (pDC, pComboBox, nItem, rect, bIsHighlihted, bIsSelected);
}
ASSERT_VALID (pDC);
if (!bIsHighlihted && !bIsSelected)
{
pDC->FillRect(rect, &m_brMenuLight);
return globalData.clrBarText;
}
COLORREF clrText = (COLORREF)-1;
if (bIsSelected)
{
pDC->FillRect (rect, &m_brAccent);
clrText = RGB(255, 255, 255);
}
if (bIsHighlihted)
{
pDC->Draw3dRect(rect, RGB(255, 255, 255), RGB(255, 255, 255));
}
return clrText;
}
//*******************************************************************************
HBRUSH CBCGPVisualManagerVS2012::GetListControlFillBrush(CBCGPListCtrl* pListCtrl)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetListControlFillBrush(pListCtrl);
}
return m_brMenuLight;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetListControlTextColor(CBCGPListCtrl* pListCtrl)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetListControlTextColor(pListCtrl);
}
return m_Style == VS2012_Light ? RGB(0, 0, 0) : RGB(255, 255, 255);
}
//*****************************************************************************
void CBCGPVisualManagerVS2012::OnDrawShowAllMenuItems (CDC* pDC, CRect rect, CBCGPVisualManager::BCGBUTTON_STATE state)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawShowAllMenuItems (pDC, rect, state);
return;
}
CBCGPMenuImages::Draw (pDC, CBCGPMenuImages::IdArowShowAll, rect,
m_Style == VS2012_Dark ? CBCGPMenuImages::ImageWhite : CBCGPMenuImages::ImageBlack);
}
//*****************************************************************************
int CBCGPVisualManagerVS2012::GetShowAllMenuItemsHeight (CDC* pDC, const CSize& sizeDefault)
{
return CBCGPVisualManagerXP::GetShowAllMenuItemsHeight(pDC, sizeDefault);
}
//*****************************************************************************
void CBCGPVisualManagerVS2012::OnDrawSeparator (CDC* pDC, CBCGPBaseControlBar* pBar, CRect rect, BOOL bIsHoriz)
{
CBCGPVisualManagerXP::OnDrawSeparator(pDC, pBar, rect, bIsHoriz);
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::GetCalendarColors (const CBCGPCalendar* pCalendar, CBCGPCalendarColors& colors)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::GetCalendarColors(pCalendar, colors);
return;
}
colors.clrCaption = globalData.clrBarFace;
colors.clrCaptionText = globalData.clrBarText;
colors.clrSelected = m_clrAccent;
colors.clrSelectedText = RGB(255, 255, 255);
colors.clrTodayBorder = m_clrAccentText;
}
//**************************************************************************************
void CBCGPVisualManagerVS2012::OnDrawCaptionBarInfoArea (CDC* pDC, CBCGPCaptionBar* pBar, CRect rect)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || pBar->m_clrBarBackground != (COLORREF)-1)
{
CBCGPVisualManagerVS2010::OnDrawCaptionBarInfoArea (pDC, pBar, rect);
return;
}
pDC->FillRect(rect, &m_brMenuLight);
pDC->Draw3dRect(rect, m_clrMenuBorder, m_clrMenuBorder);
}
#ifndef BCGP_EXCLUDE_GRID_CTRL
COLORREF CBCGPVisualManagerVS2012::OnFillGridGroupByBoxBackground (CDC* pDC, CRect rect)
{
ASSERT_VALID (pDC);
CBrush br (globalData.clrBtnShadow);
pDC->FillRect (rect, &br);
return globalData.clrBtnText;
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillGridGroupByBoxTitleBackground (CDC* pDC, CRect rect)
{
return CBCGPVisualManagerXP::OnFillGridGroupByBoxTitleBackground(pDC, rect);
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetGridGroupByBoxLineColor () const
{
return globalData.clrBtnText;
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawGridGroupByBoxItemBorder (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rect)
{
CBCGPVisualManagerXP::OnDrawGridGroupByBoxItemBorder (pCtrl, pDC, rect);
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetGridLeftOffsetColor (CBCGPGridCtrl* pCtrl)
{
ASSERT_VALID(pCtrl);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !pCtrl->IsControlBarColors ())
{
return CBCGPVisualManagerXP::GetGridLeftOffsetColor (pCtrl);
}
return m_Style == VS2012_Dark ? globalData.clrBarDkShadow : m_clrHighlight;
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetGridItemSortedColor (CBCGPGridCtrl* pCtrl)
{
return CBCGPVisualManagerXP::GetGridItemSortedColor(pCtrl);
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnFillGridGroupBackground (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rectFill)
{
CBCGPVisualManagerXP::OnFillGridGroupBackground(pCtrl, pDC, rectFill);
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawGridGroupUnderline (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rectFill)
{
CBCGPVisualManagerXP::OnDrawGridGroupUnderline(pCtrl, pDC, rectFill);
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillGridRowBackground (CBCGPGridCtrl* pCtrl,
CDC* pDC, CRect rectFill, BOOL bSelected)
{
return CBCGPVisualManagerXP::OnFillGridRowBackground(pCtrl, pDC, rectFill, bSelected);
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillGridItem (CBCGPGridCtrl* pCtrl,
CDC* pDC, CRect rectFill,
BOOL bSelected, BOOL bActiveItem, BOOL bSortedColumn)
{
return CBCGPVisualManagerXP::OnFillGridItem(pCtrl, pDC, rectFill, bSelected, bActiveItem, bSortedColumn);
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawGridHeaderMenuButton (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rect,
BOOL bHighlighted, BOOL bPressed, BOOL bDisabled)
{
CBCGPVisualManagerXP::OnFillGridItem(pCtrl, pDC, rect, bHighlighted, bPressed, bDisabled);
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnDrawGridSelectionBorder (CBCGPGridCtrl* /*pCtrl*/, CDC* pDC, CRect rect)
{
ASSERT_VALID (pDC);
pDC->Draw3dRect (rect, globalData.clrBtnDkShadow, globalData.clrBtnDkShadow);
rect.DeflateRect (1, 1);
pDC->Draw3dRect (rect, globalData.clrBtnDkShadow, globalData.clrBtnDkShadow);
}
//********************************************************************************
BOOL CBCGPVisualManagerVS2012::OnSetGridColorTheme (CBCGPGridCtrl* pCtrl, BCGP_GRID_COLOR_DATA& theme)
{
BOOL bRes = CBCGPVisualManagerVS2010::OnSetGridColorTheme (pCtrl, theme);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return bRes;
}
theme.m_clrBackground = m_clrHighlight;
theme.m_clrText = globalData.clrBarText;
theme.m_clrHorzLine = theme.m_clrVertLine = globalData.clrBarShadow;
theme.m_EvenColors.m_clrBackground = CBCGPDrawManager::SmartMixColors(globalData.clrBarFace, globalData.clrBarHilite);
theme.m_EvenColors.m_clrGradient = (COLORREF)-1;
theme.m_EvenColors.m_clrText = globalData.clrBarText;
theme.m_OddColors.m_clrBackground = m_clrHighlight;
theme.m_OddColors.m_clrGradient = (COLORREF)-1;
theme.m_OddColors.m_clrText = globalData.clrBarText;
theme.m_SelColors.m_clrBackground = m_clrAccent;
theme.m_SelColors.m_clrGradient = (COLORREF)-1;
theme.m_SelColors.m_clrText = RGB(255, 255, 255);
theme.m_LeftOffsetColors.m_clrBackground = m_clrHighlight;
theme.m_LeftOffsetColors.m_clrGradient = (COLORREF)-1;
theme.m_LeftOffsetColors.m_clrBorder = globalData.clrBarShadow;
theme.m_LeftOffsetColors.m_clrText = globalData.clrBarText;
theme.m_HeaderColors.m_clrBackground = globalData.clrBarFace;
theme.m_HeaderColors.m_clrBorder = globalData.clrBarShadow;
theme.m_HeaderColors.m_clrGradient = (COLORREF)-1;
theme.m_HeaderColors.m_clrText = globalData.clrBarText;
theme.m_HeaderSelColors.m_clrBackground = m_clrAccent;
theme.m_HeaderSelColors.m_clrBorder = globalData.clrBarShadow;
theme.m_HeaderSelColors.m_clrGradient = (COLORREF)-1;
theme.m_HeaderSelColors.m_clrText = RGB(255, 255, 255);
theme.m_GroupColors.m_clrBorder = globalData.clrBarShadow;
theme.m_GroupColors.m_clrBackground = globalData.clrBarFace;
theme.m_GroupColors.m_clrGradient = (COLORREF)-1;
theme.m_GroupColors.m_clrText = globalData.clrBarText;
theme.m_GroupSelColors.m_clrBorder = globalData.clrBarShadow;
theme.m_GroupSelColors.m_clrBackground = m_clrAccent;
theme.m_GroupSelColors.m_clrGradient = (COLORREF)-1;
theme.m_GroupSelColors.m_clrText = RGB(255, 255, 255);
return TRUE;
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillReportCtrlRowBackground (CBCGPGridCtrl* pCtrl,
CDC* pDC, CRect rectFill,
BOOL bSelected, BOOL bGroup)
{
return CBCGPVisualManagerXP::OnFillReportCtrlRowBackground (pCtrl, pDC, rectFill, bSelected, bGroup);
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetReportCtrlGroupBackgoundColor ()
{
return CBCGPVisualManagerXP::GetReportCtrlGroupBackgoundColor ();
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnFillGridBackground (CDC* pDC, CRect rect)
{
CBCGPVisualManagerXP::OnFillGridBackground(pDC, rect);
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnFillGridHeaderBackground (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rect)
{
CBCGPVisualManagerXP::OnFillGridHeaderBackground(pCtrl, pDC, rect);
}
//********************************************************************************
BOOL CBCGPVisualManagerVS2012::OnDrawGridHeaderItemBorder (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rect, BOOL bPressed)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnDrawGridHeaderItemBorder(pCtrl, pDC, rect, bPressed);
}
CPen* pOldPen = pDC->SelectObject (&m_penSeparator);
pDC->MoveTo (rect.right - 1, rect.top);
pDC->LineTo (rect.right - 1, rect.bottom);
pDC->MoveTo (rect.left, rect.top);
pDC->LineTo (rect.right, rect.top);
pDC->MoveTo (rect.left, rect.bottom - 1);
pDC->LineTo (rect.right, rect.bottom - 1);
pDC->SelectObject (pOldPen);
return FALSE;
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnFillGridRowHeaderBackground (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rect)
{
CBCGPVisualManagerXP::OnFillGridRowHeaderBackground(pCtrl, pDC, rect);
}
//********************************************************************************
BOOL CBCGPVisualManagerVS2012::OnDrawGridRowHeaderItemBorder (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rect, BOOL bPressed)
{
return CBCGPVisualManagerXP::OnDrawGridRowHeaderItemBorder(pCtrl, pDC, rect, bPressed);
}
//********************************************************************************
void CBCGPVisualManagerVS2012::OnFillGridSelectAllAreaBackground (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rect, BOOL bPressed)
{
CBCGPVisualManagerXP::OnFillGridSelectAllAreaBackground(pCtrl, pDC, rect, bPressed);
}
//********************************************************************************
BOOL CBCGPVisualManagerVS2012::OnDrawGridSelectAllAreaBorder (CBCGPGridCtrl* pCtrl, CDC* pDC, CRect rect, BOOL bPressed)
{
return CBCGPVisualManagerXP::OnDrawGridSelectAllAreaBorder(pCtrl, pDC, rect, bPressed);
}
#endif // BCGP_EXCLUDE_GRID_CTRL
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetEditBackSidebarColor(CBCGPEditCtrl* pEdit)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetEditBackSidebarColor(pEdit);
}
return globalData.clrBarFace;
}
//********************************************************************************
HBRUSH CBCGPVisualManagerVS2012::GetEditBackgroundBrush(CBCGPEditCtrl* pEdit)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetEditBackgroundBrush(pEdit);
}
return m_Style == VS2012_Light ? m_brWhite : globalData.brBarFace;
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetEditTextColor(CBCGPEditCtrl* pEdit)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetEditTextColor(pEdit);
}
return globalData.clrBarText;
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetEditLineNumbersBarBackColor(CBCGPEditCtrl* pEdit)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetEditLineNumbersBarBackColor(pEdit);
}
return globalData.clrBarFace;
}
//********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetEditLineNumbersBarTextColor(CBCGPEditCtrl* pEdit)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetEditLineNumbersBarTextColor(pEdit);
}
return m_clrAccentText;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetEditOutlineColor(CBCGPEditCtrl* pEdit)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetEditOutlineColor(pEdit);
}
return globalData.clrBarDkShadow;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetTreeControlFillColor(CBCGPTreeCtrl* pTreeCtrl, BOOL bIsSelected, BOOL bIsFocused, BOOL bIsDisabled)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetTreeControlFillColor(pTreeCtrl, bIsSelected, bIsFocused, bIsDisabled);
}
if (bIsSelected)
{
return bIsFocused ? m_clrAccent : globalData.clrBarShadow;
}
return m_clrHighlight;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetTreeControlTextColor(CBCGPTreeCtrl* pTreeCtrl, BOOL bIsSelected, BOOL bIsFocused, BOOL bIsDisabled)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetTreeControlTextColor(pTreeCtrl, bIsSelected, bIsFocused, bIsDisabled);
}
if (bIsSelected)
{
return bIsFocused ? RGB(255, 255, 255) : globalData.clrBarText;
}
return globalData.clrBarText;
}
//*********************************************************************************
CBrush& CBCGPVisualManagerVS2012::GetEditCtrlBackgroundBrush(CBCGPEdit* pEdit)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetEditCtrlBackgroundBrush(pEdit);
}
return m_brMenuLight;
}
//*********************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetEditCtrlTextColor(CBCGPEdit* pEdit)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetEditCtrlTextColor(pEdit);
}
return globalData.clrBarText;
}
//*************************************************************************************
HBRUSH CBCGPVisualManagerVS2012::GetToolbarEditColors(CBCGPToolbarButton* pButton, COLORREF& clrText, COLORREF& clrBk)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetToolbarEditColors(pButton, clrText, clrBk);
}
clrText = globalData.clrBarText;
clrBk = m_clrHighlight;
return (HBRUSH) m_brHighlight.GetSafeHandle ();
}
//*************************************************************************************
COLORREF CBCGPVisualManagerVS2012::BreadcrumbFillBackground (CDC& dc, CBCGPBreadcrumb* pControl, CRect rectFill)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || !pControl->m_bVisualManagerStyle)
{
return CBCGPVisualManagerVS2010::BreadcrumbFillBackground(dc, pControl, rectFill);
}
dc.FillRect(&rectFill, &m_brMenuLight);
return pControl->IsWindowEnabled() ? globalData.clrBarText : m_clrTextDisabled;
}
#ifndef BCGP_EXCLUDE_RIBBON
void CBCGPVisualManagerVS2012::OnDrawRibbonProgressBar (CDC* pDC,
CBCGPRibbonProgressBar* pProgress,
CRect rectProgress, CRect rectChunk,
BOOL bInfiniteMode)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawRibbonProgressBar (pDC, pProgress,
rectProgress, rectChunk, bInfiniteMode);
return;
}
ASSERT_VALID (pDC);
if (CBCGPToolBarImages::m_bIsDrawOnGlass)
{
CBCGPDrawManager dm (*pDC);
if (!rectChunk.IsRectEmpty ())
{
dm.DrawRect (rectChunk, m_clrAccent, (COLORREF)-1);
}
dm.DrawRect (rectProgress, (COLORREF)-1, globalData.clrBarDkShadow);
}
else
{
if (!rectChunk.IsRectEmpty ())
{
pDC->FillRect (rectChunk, &m_brAccent);
}
pDC->Draw3dRect (rectProgress, globalData.clrBarDkShadow, globalData.clrBarDkShadow);
}
}
#endif
BOOL CBCGPVisualManagerVS2012::IsOwnerDrawScrollBar () const
{
return globalData.m_nBitsPerPixel > 8 && !globalData.IsHighContastMode ();
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::OnScrollBarDrawThumb (CDC* pDC, CBCGPScrollBar* /*pScrollBar*/, CRect rect,
BOOL bHorz, BOOL bHighlighted, BOOL bPressed, BOOL bDisabled)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return;
}
ASSERT_VALID(pDC);
if (bHorz)
{
rect.InflateRect(1, 0);
}
else
{
rect.InflateRect(0, 1);
}
CBCGPDrawManager dm (*pDC);
dm.DrawRect (rect,
bPressed ? m_clrAccent : bHighlighted ? globalData.clrBarHilite : globalData.clrBarFace,
bDisabled ? globalData.clrBarShadow : globalData.clrBarDkShadow);
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::OnScrollBarDrawButton (CDC* pDC, CBCGPScrollBar* /*pScrollBar*/, CRect rect,
BOOL bHorz, BOOL bHighlighted, BOOL bPressed, BOOL bFirst, BOOL bDisabled)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return;
}
COLORREF clrFill = bPressed ? m_clrAccent : bHighlighted ? m_clrHighlight : globalData.clrBarFace;
CBCGPDrawManager dm (*pDC);
dm.DrawRect (rect,
clrFill,
bDisabled ? globalData.clrBarShadow : globalData.clrBarDkShadow);
CBCGPMenuImages::IMAGES_IDS ids;
if (bHorz)
{
ids = bFirst ? CBCGPMenuImages::IdArowLeftTab3d : CBCGPMenuImages::IdArowRightTab3d;
}
else
{
ids = bFirst ? CBCGPMenuImages::IdArowUpLarge : CBCGPMenuImages::IdArowDownLarge;
}
CBCGPMenuImages::IMAGE_STATE state = bDisabled ? CBCGPMenuImages::ImageGray : CBCGPMenuImages::GetStateByColor(clrFill);
CBCGPMenuImages::Draw (pDC, ids, rect, state);
}
//*************************************************************************************
void CBCGPVisualManagerVS2012::OnScrollBarFillBackground (CDC* pDC, CBCGPScrollBar* /*pScrollBar*/, CRect rect,
BOOL /*bHorz*/, BOOL /*bHighlighted*/, BOOL bPressed, BOOL /*bFirst*/, BOOL /*bDisabled*/)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return;
}
CBCGPDrawManager dm (*pDC);
dm.DrawRect (rect, bPressed ? m_clrAccent : m_clrHighlight, globalData.clrBarDkShadow);
}
#ifndef BCGP_EXCLUDE_PLANNER
//*******************************************************************************
void CBCGPVisualManagerVS2012::OnFillPlanner (CDC* pDC, CBCGPPlannerView* pView,
CRect rect, BOOL bWorkingArea)
{
ASSERT_VALID (pDC);
ASSERT_VALID (pView);
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnFillPlanner (pDC, pView, rect, bWorkingArea);
return;
}
if (m_bPlannerBackItemSelected)
{
CBrush br (GetPlannerHourLineColor (pView, TRUE, FALSE));
pDC->FillRect (rect, &br);
}
else
{
CBCGPVisualManagerVS2010::OnFillPlanner (pDC, pView, rect, bWorkingArea);
}
if (m_bPlannerBackItemToday && DYNAMIC_DOWNCAST (CBCGPPlannerViewDay, pView) == NULL)
{
pDC->Draw3dRect (rect, m_clrAccentText, m_clrAccentText);
}
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillPlannerCaption (CDC* pDC,
CBCGPPlannerView* pView, CRect rect, BOOL bIsToday, BOOL bIsSelected,
BOOL bNoBorder/* = FALSE*/, BOOL bHorz /*= TRUE*/)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnFillPlannerCaption (pDC,
pView, rect, bIsToday, bIsSelected, bNoBorder, bHorz);
}
const BOOL bMonth = DYNAMIC_DOWNCAST(CBCGPPlannerViewMonth, pView) != NULL;
if (bMonth && m_bPlannerCaptionBackItemHeader)
{
return globalData.clrBarText;
}
ASSERT_VALID (pDC);
BOOL bDay = FALSE;
if (!bMonth)
{
bDay = pView->IsKindOf (RUNTIME_CLASS (CBCGPPlannerViewDay));
if (bDay)
{
if (!bIsToday)
{
if (pView->IsKindOf (RUNTIME_CLASS (CBCGPPlannerViewMulti)))
{
rect.top++;
rect.left++;
}
else
{
rect.left++;
}
}
}
}
else
{
if (!bIsToday)
{
rect.bottom--;
}
}
COLORREF clrText = globalData.clrBarText;
COLORREF clrBorder = CLR_DEFAULT;
if (bIsToday)
{
CBrush br (m_clrPlannerTodayFill);
pDC->FillRect (rect, &br);
clrText = RGB(255, 255, 255);
clrBorder = m_clrPlannerTodayLine;
}
else
{
pDC->FillRect (rect, &globalData.brBarFace);
}
if (bIsSelected && !bDay)
{
clrText = m_clrAccentText;
}
if (clrBorder != CLR_DEFAULT && !bNoBorder)
{
pDC->Draw3dRect (rect, clrBorder, clrBorder);
}
return clrText;
}
//*******************************************************************************
void CBCGPVisualManagerVS2012::OnDrawPlannerCaptionText (CDC* pDC,
CBCGPPlannerView* pView, CRect rect, const CString& strText,
COLORREF clrText, int nAlign, BOOL bHighlight)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawPlannerCaptionText (pDC,
pView, rect, strText, clrText, nAlign, bHighlight);
return;
}
const int nTextMargin = 2;
rect.DeflateRect (nTextMargin, 0);
COLORREF clrOld = pDC->SetTextColor (clrText);
pDC->DrawText (strText, rect, DT_SINGLELINE | DT_VCENTER | nAlign);
pDC->SetTextColor (clrOld);
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPlannerAppointmentTimeColor (CBCGPPlannerView* pView,
BOOL bSelected, BOOL bSimple, DWORD dwDrawFlags)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
(bSelected && (dwDrawFlags & BCGP_PLANNER_DRAW_APP_OVERRIDE_SELECTION) == 0))
{
return CBCGPVisualManagerVS2010::GetPlannerAppointmentTimeColor (pView,
bSelected, bSimple, dwDrawFlags);
}
return CLR_DEFAULT;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPlannerHourLineColor (CBCGPPlannerView* pView,
BOOL bWorkingHours, BOOL bHour)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
GetPlannerViewBackgroundColor (pView) != m_clrPlannerWork)
{
return CBCGPVisualManagerVS2010::GetPlannerHourLineColor (pView,
bWorkingHours, bHour);
}
COLORREF colorFill = m_clrPalennerLine;
if (!bHour)
{
if (CBCGPVisualManagerVS2012::GetStyle () == CBCGPVisualManagerVS2012::VS2012_Dark)
{
colorFill = globalData.clrBarShadow;
}
else
{
colorFill = bWorkingHours ? m_clrHighlight : globalData.clrBarShadow;
}
}
return colorFill;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPlannerViewWorkingColor (CBCGPPlannerView* pView)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
GetPlannerViewBackgroundColor (pView) != m_clrPlannerWork)
{
return CBCGPVisualManagerVS2010::GetPlannerViewWorkingColor (pView);
}
return m_clrHighlightMenuItem;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPlannerViewNonWorkingColor (CBCGPPlannerView* pView)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
GetPlannerViewBackgroundColor (pView) != m_clrPlannerWork)
{
return CBCGPVisualManagerVS2010::GetPlannerViewNonWorkingColor (pView);
}
return m_clrHighlight;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPlannerSelectionColor (CBCGPPlannerView* pView)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetPlannerSelectionColor (pView);
}
return m_clrAccent;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::GetPlannerSeparatorColor (CBCGPPlannerView* pView)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetPlannerSeparatorColor (pView);
}
return m_clrPalennerLine;
}
//*******************************************************************************
COLORREF CBCGPVisualManagerVS2012::OnFillPlannerTimeBar (CDC* pDC,
CBCGPPlannerView* pView, CRect rect, COLORREF& clrLine)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::OnFillPlannerTimeBar (pDC, pView, rect, clrLine);
}
ASSERT_VALID (pDC);
pDC->FillRect (rect, &globalData.brBarFace);
clrLine = m_clrPalennerLine;
return globalData.clrBarText;
}
//*******************************************************************************
void CBCGPVisualManagerVS2012::OnDrawPlannerTimeLine (CDC* pDC, CBCGPPlannerView* pView, CRect rect)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawPlannerTimeLine (pDC, pView, rect);
return;
}
ASSERT_VALID (pDC);
CBCGPDrawManager dm (*pDC);
dm.FillGradient (rect, m_clrPlannerTodayFill, globalData.clrBarFace, TRUE);
CPen* pOldPen = pDC->SelectObject (&m_penPlannerTodayLine);
pDC->MoveTo (rect.left, rect.bottom);
pDC->LineTo (rect.right, rect.bottom);
pDC->SelectObject (pOldPen);
}
//*******************************************************************************
void CBCGPVisualManagerVS2012::OnFillPlannerWeekBar (CDC* pDC,
CBCGPPlannerView* pView, CRect rect)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnFillPlannerWeekBar (pDC, pView, rect);
return;
}
ASSERT_VALID (pDC);
pDC->FillRect (rect, &m_brMenuLight);
}
//*******************************************************************************
void CBCGPVisualManagerVS2012::OnDrawPlannerHeader (CDC* pDC,
CBCGPPlannerView* pView, CRect rect)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawPlannerHeader (pDC, pView, rect);
return;
}
ASSERT_VALID (pDC);
COLORREF clr = GetPlannerSeparatorColor (pView);
if (DYNAMIC_DOWNCAST(CBCGPPlannerViewMonth, pView) != NULL)
{
clr = m_clrHighlight;
}
CBrush br (clr);
pDC->FillRect (rect, &br);
if (pView->IsKindOf (RUNTIME_CLASS (CBCGPPlannerViewDay)))
{
if (rect.left == pView->GetAppointmentsRect().left)
{
CRect rect1 (rect);
rect1.right = rect1.left + 1;
if (pView->IsKindOf (RUNTIME_CLASS (CBCGPPlannerViewMulti)))
{
rect1.top++;
}
pDC->FillRect (rect1, &globalData.brBarFace);
}
}
}
//*******************************************************************************
void CBCGPVisualManagerVS2012::OnDrawPlannerHeaderPane (CDC* pDC,
CBCGPPlannerView* pView, CRect rect)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawPlannerHeaderPane (pDC, pView, rect);
return;
}
if (DYNAMIC_DOWNCAST(CBCGPPlannerViewMonth, pView) != NULL)
{
pDC->Draw3dRect (rect.right - 1, rect.top - 2, 1, rect.Height () + 4,
m_clrPalennerLine, m_clrPalennerLine);
}
}
//*******************************************************************************
void CBCGPVisualManagerVS2012::OnFillPlannerHeaderAllDay (CDC* pDC,
CBCGPPlannerView* pView, CRect rect)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnFillPlannerHeaderAllDay (pDC, pView, rect);
return;
}
ASSERT_VALID (pDC);
pDC->FillRect (rect, &globalData.brBarFace);
}
//*******************************************************************************
void CBCGPVisualManagerVS2012::OnDrawPlannerHeaderAllDayItem (CDC* pDC,
CBCGPPlannerView* pView, CRect rect, BOOL bIsToday, BOOL bIsSelected)
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
CBCGPVisualManagerVS2010::OnDrawPlannerHeaderAllDayItem (pDC, pView, rect,
bIsToday, bIsSelected);
return;
}
ASSERT_VALID (pDC);
rect.left++;
if (bIsSelected)
{
CBrush br (GetPlannerSelectionColor (pView));
pDC->FillRect (rect, &br);
}
if (bIsToday)
{
rect.top--;
rect.left--;
rect.bottom++;
pDC->Draw3dRect (rect, m_clrPlannerTodayLine, m_clrPlannerTodayLine);
}
}
//*******************************************************************************
void CBCGPVisualManagerVS2012::PreparePlannerBackItem (BOOL bIsToday, BOOL bIsSelected)
{
m_bPlannerBackItemToday = bIsToday;
m_bPlannerBackItemSelected = bIsSelected;
}
//*******************************************************************************
DWORD CBCGPVisualManagerVS2012::GetPlannerDrawFlags () const
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetPlannerDrawFlags ();
}
return BCGP_PLANNER_DRAW_APP_OVERRIDE_SELECTION |
BCGP_PLANNER_DRAW_APP_NO_MULTIDAY_CLOCKS |
BCGP_PLANNER_DRAW_VIEW_WEEK_BAR |
BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_BOLD |
BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_COMPACT |
BCGP_PLANNER_DRAW_VIEW_DAYS_UPDOWN |
BCGP_PLANNER_DRAW_VIEW_DAYS_UPDOWN_VCENTER;
}
//*******************************************************************************
int CBCGPVisualManagerVS2012::GetPlannerRowExtraHeight () const
{
if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode ())
{
return CBCGPVisualManagerVS2010::GetPlannerRowExtraHeight ();
}
return 3;
}
#endif // BCGP_EXCLUDE_PLANNER
| [
"iclosure@163.com"
] | iclosure@163.com |
3255271de7f8e1733d0b59bb8515bea9424e4e0d | b7880e3193f43e1a2f67b254f16d76d485cf3f46 | /src/urn_jaus_jss_mobility_LocalVectorDriver_1_0/Messages/QueryTimeout.cpp | b4da6d97c0c036d9b4b695f7d412f8f946a609e2 | [] | no_license | davidhodo/libJAUS | 49e09c860c58f615c9b4cf88844caf2257e51d99 | b034c614555478540ac2565812af94db44b54aeb | refs/heads/master | 2020-05-15T17:44:55.910342 | 2012-01-18T20:33:41 | 2012-01-18T20:33:41 | 3,209,499 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,349 | cpp | #include "urn_jaus_jss_mobility_LocalVectorDriver_1_0/Messages/QueryTimeout.h"
namespace urn_jaus_jss_mobility_LocalVectorDriver_1_0
{
void QueryTimeout::AppHeader::HeaderRec::setParent(AppHeader* parent)
{
m_parent = parent;
}
void QueryTimeout::AppHeader::HeaderRec::setParentPresenceVector()
{
if(m_parent != NULL )
{
m_parent->setParentPresenceVector();
}
}
jUnsignedShortInteger QueryTimeout::AppHeader::HeaderRec::getMessageID()
{
return m_MessageID;
}
int QueryTimeout::AppHeader::HeaderRec::setMessageID(jUnsignedShortInteger value)
{
m_MessageID = value;
setParentPresenceVector();
return 0;
}
/**
* Returns the size of memory the used data members of the class occupies.
* This is not necessarily the same size of memory the class actually occupies.
* Eg. A union of an int and a double may occupy 8 bytes. However, if the data
* stored is an int, this function will return a size of 4 bytes.
*
* @return
*/
const unsigned int QueryTimeout::AppHeader::HeaderRec::getSize()
{
unsigned int size = 0;
size += sizeof(jUnsignedShortInteger);
return size;
}
void QueryTimeout::AppHeader::HeaderRec::encode(unsigned char *bytes)
{
if (bytes == NULL)
{
return;
}
int pos = 0;
jUnsignedShortInteger m_MessageIDTemp;
m_MessageIDTemp = JSIDL_v_1_0::correctEndianness(m_MessageID);
memcpy(bytes + pos, &m_MessageIDTemp, sizeof(jUnsignedShortInteger));
pos += sizeof(jUnsignedShortInteger);
}
void QueryTimeout::AppHeader::HeaderRec::decode(const unsigned char *bytes)
{
if (bytes == NULL)
{
return;
}
int pos = 0;
jUnsignedShortInteger m_MessageIDTemp;
memcpy(&m_MessageIDTemp, bytes + pos, sizeof(jUnsignedShortInteger));
m_MessageID = JSIDL_v_1_0::correctEndianness(m_MessageIDTemp);
pos += sizeof(jUnsignedShortInteger);
}
QueryTimeout::AppHeader::HeaderRec &QueryTimeout::AppHeader::HeaderRec::operator=(const HeaderRec &value)
{
m_MessageID = value.m_MessageID;
return *this;
}
bool QueryTimeout::AppHeader::HeaderRec::operator==(const HeaderRec &value) const
{
if (m_MessageID != value.m_MessageID)
{
return false;
}
return true;
}
bool QueryTimeout::AppHeader::HeaderRec::operator!=(const HeaderRec &value) const
{
return !((*this) == value);
}
QueryTimeout::AppHeader::HeaderRec::HeaderRec()
{
m_parent = NULL;
m_MessageID = 0x2003;
}
QueryTimeout::AppHeader::HeaderRec::HeaderRec(const HeaderRec &value)
{
/// Initiliaze the protected variables
m_parent = NULL;
m_MessageID = 0x2003;
/// Copy the values
m_MessageID = value.m_MessageID;
}
QueryTimeout::AppHeader::HeaderRec::~HeaderRec()
{
}
QueryTimeout::AppHeader::HeaderRec* const QueryTimeout::AppHeader::getHeaderRec()
{
return &m_HeaderRec;
}
int QueryTimeout::AppHeader::setHeaderRec(const HeaderRec &value)
{
m_HeaderRec = value;
setParentPresenceVector();
return 0;
}
void QueryTimeout::AppHeader::setParentPresenceVector()
{
// Nothing needed here, placeholder function
}
/**
* Returns the size of memory the used data members of the class occupies.
* This is not necessarily the same size of memory the class actually occupies.
* Eg. A union of an int and a double may occupy 8 bytes. However, if the data
* stored is an int, this function will return a size of 4 bytes.
*
* @return
*/
const unsigned int QueryTimeout::AppHeader::getSize()
{
unsigned int size = 0;
size += m_HeaderRec.getSize();
return size;
}
void QueryTimeout::AppHeader::encode(unsigned char *bytes)
{
if (bytes == NULL)
{
return;
}
int pos = 0;
m_HeaderRec.encode(bytes + pos);
pos += m_HeaderRec.getSize();
}
void QueryTimeout::AppHeader::decode(const unsigned char *bytes)
{
if (bytes == NULL)
{
return;
}
int pos = 0;
m_HeaderRec.decode(bytes + pos);
pos += m_HeaderRec.getSize();
}
QueryTimeout::AppHeader &QueryTimeout::AppHeader::operator=(const AppHeader &value)
{
m_HeaderRec = value.m_HeaderRec;
m_HeaderRec.setParent(this);
return *this;
}
bool QueryTimeout::AppHeader::operator==(const AppHeader &value) const
{
if (m_HeaderRec != value.m_HeaderRec)
{
return false;
}
return true;
}
bool QueryTimeout::AppHeader::operator!=(const AppHeader &value) const
{
return !((*this) == value);
}
QueryTimeout::AppHeader::AppHeader()
{
m_HeaderRec.setParent(this);
/// No Initialization of m_HeaderRec necessary.
}
QueryTimeout::AppHeader::AppHeader(const AppHeader &value)
{
/// Initiliaze the protected variables
m_HeaderRec.setParent(this);
/// No Initialization of m_HeaderRec necessary.
/// Copy the values
m_HeaderRec = value.m_HeaderRec;
m_HeaderRec.setParent(this);
}
QueryTimeout::AppHeader::~AppHeader()
{
}
QueryTimeout::AppHeader* const QueryTimeout::getAppHeader()
{
return &m_AppHeader;
}
int QueryTimeout::setAppHeader(const AppHeader &value)
{
m_AppHeader = value;
return 0;
}
/**
* Returns the size of memory the used data members of the class occupies.
* This is not necessarily the same size of memory the class actually occupies.
* Eg. A union of an int and a double may occupy 8 bytes. However, if the data
* stored is an int, this function will return a size of 4 bytes.
*
* @return
*/
const unsigned int QueryTimeout::getSize()
{
unsigned int size = 0;
size += m_AppHeader.getSize();
return size;
}
void QueryTimeout::encode(unsigned char *bytes)
{
if (bytes == NULL)
{
return;
}
int pos = 0;
m_AppHeader.encode(bytes + pos);
pos += m_AppHeader.getSize();
}
void QueryTimeout::decode(const unsigned char *bytes)
{
if (bytes == NULL)
{
return;
}
int pos = 0;
m_AppHeader.decode(bytes + pos);
pos += m_AppHeader.getSize();
}
QueryTimeout &QueryTimeout::operator=(const QueryTimeout &value)
{
m_AppHeader = value.m_AppHeader;
return *this;
}
bool QueryTimeout::operator==(const QueryTimeout &value) const
{
if (m_AppHeader != value.m_AppHeader)
{
return false;
}
return true;
}
bool QueryTimeout::operator!=(const QueryTimeout &value) const
{
return !((*this) == value);
}
QueryTimeout::QueryTimeout()
{
/// No Initialization of m_AppHeader necessary.
m_IsCommand = false;
}
QueryTimeout::QueryTimeout(const QueryTimeout &value)
{
/// Initiliaze the protected variables
/// No Initialization of m_AppHeader necessary.
m_IsCommand = false;
/// Copy the values
m_AppHeader = value.m_AppHeader;
}
QueryTimeout::~QueryTimeout()
{
}
}
| [
"david.hodo@gmail.com"
] | david.hodo@gmail.com |
01a767b7d7c8d1b2f7eae6188075e2add3ad453b | f81cb41e890fa9dc31483ac17fa7f80aed34f578 | /BitStreamParser/source/Synthesizer.cpp | 8d967e952d53236639d38c53cbf28db6c20d02ca | [] | no_license | nhoughto5/BitStreamParser | 3a20eee5aa9156c075da53f562809b61200a68b1 | 1bf03fcd61a4a2708709e0b11484676992858f78 | refs/heads/master | 2021-01-20T20:56:26.231576 | 2016-07-28T07:06:11 | 2016-07-28T07:06:11 | 60,478,914 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,302 | cpp | #include "stdafx.h"
#include "Synthesizer.h"
Synthesizer::Synthesizer()
{
}
Synthesizer::~Synthesizer()
{
}
bool Synthesizer::runTool(std::wstring FullPathToExe, std::wstring Parameters, size_t SecondsToWait) {
SECURITY_ATTRIBUTES sa;
printf("\n->Start of parent execution.\n");
// Set the bInheritHandle flag so pipe handles are inherited.
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
// Create a pipe for the child process's STDERR.
if (!CreatePipe(&g_hChildStd_ERR_Rd, &g_hChildStd_ERR_Wr, &sa, 0)) {
exit(1);
}
// Ensure the read handle to the pipe for STDERR is not inherited.
if (!SetHandleInformation(g_hChildStd_ERR_Rd, HANDLE_FLAG_INHERIT, 0)) {
exit(1);
}
// Create a pipe for the child process's STDOUT.
if (!CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &sa, 0)) {
exit(1);
}
// Ensure the read handle to the pipe for STDOUT is not inherited
if (!SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0)) {
exit(1);
}
// Create the child process.
PROCESS_INFORMATION piProcInfo = CreateChildProcess(FullPathToExe, Parameters, SecondsToWait);
// Read from pipe that is the standard output for child process.
printf("\n->Contents of child process STDOUT:\n\n");
ReadFromPipe(piProcInfo);
printf("\n->End of parent execution.\n");
// The remaining open handles are cleaned up when this process terminates.
// To avoid resource leaks in a larger application,
// close handles explicitly.
return 0;
}
// Create a child process that uses the previously created pipes
// for STDERR and STDOUT.
PROCESS_INFORMATION Synthesizer::CreateChildProcess(std::wstring FullPathToExe, std::wstring Parameters, size_t SecondsToWait) {
// Set the text I want to run
size_t iMyCounter = 0, iReturnVal = 0, iPos = 0;
PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;
bool bSuccess = FALSE;
// Set up members of the PROCESS_INFORMATION structure.
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
// Set up members of the STARTUPINFO structure.
// This structure specifies the STDERR and STDOUT handles for redirection.
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.hStdError = g_hChildStd_ERR_Wr;
siStartInfo.hStdOutput = g_hChildStd_OUT_Wr;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
//========= Modify Parameters ========//
std::wstring sTempStr = L"";
/* - NOTE - You should check here to see if the exe even exists */
/* Add a space to the beginning of the Parameters */
if (Parameters.size() != 0)
{
if (Parameters[0] != L' ')
{
Parameters.insert(0, L" ");
}
}
/* The first parameter needs to be the exe itself */
sTempStr = FullPathToExe;
iPos = sTempStr.find_last_of(L"\\");
sTempStr.erase(0, iPos + 1);
Parameters = sTempStr.append(Parameters);
/* CreateProcessW can modify Parameters thus we allocate needed memory */
wchar_t * pwszParam = new wchar_t[Parameters.size() + 1];
if (pwszParam == 0)
{
exit(1);
}
const wchar_t* pchrTemp = Parameters.c_str();
wcscpy_s(pwszParam, Parameters.size() + 1, pchrTemp);
//====================================//
bSuccess = CreateProcessW(
FullPathToExe.c_str(),
pwszParam,
0,
0,
false,
CREATE_DEFAULT_ERROR_MODE,
0,
pathToExecutable.c_str(),
&siStartInfo,
&piProcInfo);
CloseHandle(g_hChildStd_ERR_Wr);
CloseHandle(g_hChildStd_OUT_Wr);
// If an error occurs, exit the application.
if (!bSuccess) {
exit(1);
}
return piProcInfo;
}
// Read output from the child process's pipe for STDOUT
// and write to the parent process's pipe for STDOUT.
// Stop when there is no more data.
void Synthesizer::ReadFromPipe(PROCESS_INFORMATION piProcInfo) {
DWORD dwRead;
CHAR chBuf[BUFSIZE];
bool bSuccess = FALSE;
std::string out = "", err = "";
for (;;) {
bSuccess = ReadFile(g_hChildStd_OUT_Rd, chBuf, BUFSIZE, &dwRead, NULL);
if (!bSuccess || dwRead == 0) break;
std::string s(chBuf, dwRead);
out += s;
}
dwRead = 0;
for (;;) {
bSuccess = ReadFile(g_hChildStd_ERR_Rd, chBuf, BUFSIZE, &dwRead, NULL);
if (!bSuccess || dwRead == 0) break;
std::string s(chBuf, dwRead);
err += s;
}
std::cout << "stdout:" << out << std::endl;
std::cout << "stderr:" << err << std::endl;
} | [
"nhoughto5@gmail.com"
] | nhoughto5@gmail.com |
4f7111f107d5d15d9a9fe09d6e3387247c626369 | 13b14c9c75143bf2eda87cb4a41006a52dd6f02b | /AOJ/2030/2030.cpp | 2aaa78e9dde5c0f66ebb2585586f15d54a32e287 | [] | no_license | yutaka-watanobe/problem-solving | 2c311ac856c79c20aef631938140118eb3bc3835 | f0b92125494fbd3c8d203989ec9fef53f52ad4b4 | refs/heads/master | 2021-06-03T12:58:39.881107 | 2020-12-16T14:34:16 | 2020-12-16T14:34:16 | 94,963,754 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 690 | cpp | #include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
void compute(int a, int b ){
int mvalue = INT_MAX;
for ( int i = 1; i*i <= a; i++ ){
if ( a % i != 0 ) continue;
for ( int j = 1; j*j <= b; j++ ){
if ( b % j != 0 ) continue;
int v[4];
v[0] = i;
v[1] = a / i;
v[2] = j;
v[3] = b / j;
sort( v, v + 4 );
int sum = 0;
for ( int i = 1; i < 4; i++ ){
int d =v[i] - v[i-1] ;
sum += d*d;
}
mvalue = min(mvalue, sum);
}
}
cout << mvalue << endl;
}
int main(){
int a, b;
while( cin >> a >> b && a && b){
compute(a, b);
}
return 0;
}
| [
"y.watanobe@gmail.com"
] | y.watanobe@gmail.com |
416b8d9078b62a17bf76bffc95197ec679ad27fe | 0b5ef83fe2e9c34a01e51d6b0798241068c12e9e | /binarysearch.cpp | c86a9366acdd7f57603e5436148cc0ea2e432484 | [] | no_license | Shiva1405/C-_codes | cc3f8c1cdd88c3f58660ce01e1f814e5430ee9a1 | 44d65a9ebe1b4020a92a2cb9b20c3c798ae2f8ae | refs/heads/master | 2023-03-18T13:48:23.990136 | 2021-03-11T08:00:35 | 2021-03-11T08:00:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 687 | cpp | #include<stdio.h>
int binary(int a[],int j,int m,int item)
{
if(j<=m)
{
int mid=j+(m-1)/2;
if(a[mid]==item)
{
return mid;
}
if(a[mid]>item)
{
return binary(a,j,mid-1,item);
}
return binary(a,mid+1,m,item);
}
return -1;
}
int main()
{
int a[100],n,i,item,loc=0;
printf("enter the no. of elements");
scanf("%d",&n);
printf("enter the array elements in sorted order");
for(i=0;i<=n-1;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be searched for");
scanf("%d",&item);
loc=binary(a,0,n-1,item);
if(loc!=-1)
{
printf("The element %d is found at index %d and position %d",item,loc,loc+1);
}
else{
printf("The element %d is not found",item);
}
return 0;
}
| [
"71342542+Shiva1405@users.noreply.github.com"
] | 71342542+Shiva1405@users.noreply.github.com |
edb0ed09ed8e658bb4e397ab7e422d3e35ab554b | 6829d1caa6f867166bfa9a7f275e9e0783f63494 | /src/chapters/basic-intro.re | a51a45202dc3c43248cf2e92813b4173c65ee93d | [] | no_license | dtech-book/real-world-db | 827df990e6e92d75d58034ebbc8fc7ddafd03b20 | bde3e254d6944d6f563ec98bdd92ec77bbf47f53 | refs/heads/master | 2020-04-23T07:11:05.588014 | 2019-03-24T09:44:32 | 2019-03-24T09:44:32 | 170,998,904 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 302 | re | = DB設計の基本
ここは時間があるときに書く
* 設計の基本知識
* データ中心アプローチ
* ER IE IDEF1X
* 正規化
* 区分の扱い
* 諸口・雑コード
* NULL unique制約
* アンチパターン
* あやしい設計 (DB Refactoringにあるsmell)
| [
"nishio@densan-labs.net"
] | nishio@densan-labs.net |
92579e947ca542215389fe0a1e6e2dbca1d451c4 | 44ab57520bb1a9b48045cb1ee9baee8816b44a5b | /Assist/Code/Toolset/CoreTools/ExportTest/CoreTools/Detail/DelayCopyUnshared/ArtificialIntelligenceDelayCopyUnsharedMacroImpl.cpp | 67f078dcf11808b5ca25bbb2eb7e71331f56cb01 | [
"BSD-3-Clause"
] | permissive | WuyangPeng/Engine | d5d81fd4ec18795679ce99552ab9809f3b205409 | 738fde5660449e87ccd4f4878f7bf2a443ae9f1f | refs/heads/master | 2023-08-17T17:01:41.765963 | 2023-08-16T07:27:05 | 2023-08-16T07:27:05 | 246,266,843 | 10 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,113 | cpp | /// Copyright (c) 2010-2023
/// Threading Core Render Engine
///
/// 作者:彭武阳,彭晔恩,彭晔泽
/// 联系作者:94458936@qq.com
///
/// 标准:std:c++20
/// 版本:0.9.1.2 (2023/07/31 10:05)
#include "ArtificialIntelligence/ArtificialIntelligenceExport.h"
#include "ArtificialIntelligenceDelayCopyUnsharedMacroImpl.h"
#include "CoreTools/Helper/ClassInvariant/ArtificialIntelligenceClassInvariantMacro.h"
ArtificialIntelligence::ArtificialIntelligenceDelayCopyUnsharedMacroImpl::ArtificialIntelligenceDelayCopyUnsharedMacroImpl(int count) noexcept
: count{ count }
{
ARTIFICIAL_INTELLIGENCE_SELF_CLASS_IS_VALID_9;
}
CLASS_INVARIANT_STUB_DEFINE(ArtificialIntelligence, ArtificialIntelligenceDelayCopyUnsharedMacroImpl)
int ArtificialIntelligence::ArtificialIntelligenceDelayCopyUnsharedMacroImpl::GetCount() const noexcept
{
ARTIFICIAL_INTELLIGENCE_CLASS_IS_VALID_CONST_9;
return count;
}
void ArtificialIntelligence::ArtificialIntelligenceDelayCopyUnsharedMacroImpl::SetCount(int aCount) noexcept
{
ARTIFICIAL_INTELLIGENCE_CLASS_IS_VALID_9;
count = aCount;
} | [
"94458936@qq.com"
] | 94458936@qq.com |
767341c06b8d25a0f2f9246eec4181110aae2d6d | 060591cee2eca06aaef4e05dd8476d3692160d54 | /src/xrEngine/xrGame/ui/UI3tButton.h | bb507c2c4f68da8cddd916e042f22e5e8704d62f | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | Georgiy-Timoshin/X-Ray | 7c96c494803edbe4c9e03d4e3b8ebb46c02ff35e | 51dc8ddcfdde3167f3a025022d8420a94c5c1c43 | refs/heads/main | 2023-04-29T18:35:06.229863 | 2021-05-14T02:13:00 | 2021-05-14T02:13:00 | 367,538,251 | 0 | 2 | NOASSERTION | 2021-05-15T04:48:44 | 2021-05-15T04:23:35 | null | UTF-8 | C++ | false | false | 2,039 | h | // File: UI3tButton.cpp
// Description: Button with 3 texutres (for <enabled>, <disabled> and <touched> states)
// Created: 07.12.2004
// Author: Serhiy 0. Vynnychenk0
// Mail: narrator@gsc-game.kiev.ua
//
// copyright 2004 GSC Game World
//
#pragma once
#include "UIButton.h"
#include "UI_IB_Static.h"
class CUI3tButton : public CUIButton
{
friend class CUIXmlInit;
using CUIButton::SetTextColor;
public:
CUI3tButton ();
virtual ~CUI3tButton ();
// appearance
using CUIButton::Init;
virtual void Init (float x, float y, float width, float height);
virtual void InitTexture (LPCSTR tex_name);
virtual void InitTexture (LPCSTR tex_enabled, LPCSTR tex_disabled, LPCSTR tex_touched, LPCSTR tex_highlighted);
void SetTextColor (u32 color);
void SetTextColorH (u32 color);
void SetTextColorD (u32 color);
void SetTextColorT (u32 color);
virtual void SetTextureOffset (float x, float y);
virtual void SetWidth (float width);
virtual void SetHeight (float height);
void InitSoundH (LPCSTR sound_file);
void InitSoundT (LPCSTR sound_file);
virtual void OnClick ();
virtual void OnFocusReceive ();
virtual void OnFocusLost ();
// check button
bool GetCheck () {return m_eButtonState == BUTTON_PUSHED;}
void SetCheck (bool ch) {m_eButtonState = ch ? BUTTON_PUSHED : BUTTON_NORMAL;}
// behavior
virtual void DrawTexture ();
virtual void Update ();
//virtual void Enable(bool bEnable);
virtual bool OnMouse (float x, float y, EUIMessages mouse_action);
virtual bool OnMouseDown (int mouse_btn);
void SetCheckMode (bool mode) {m_bCheckMode = mode;}
virtual void SetStretchTexture (bool stretch_texture);
virtual void EnableHeading (bool b);
CUIStatic m_hint;
CUI_IB_Static m_background;
protected:
bool m_bCheckMode;
private:
void PlaySoundH ();
void PlaySoundT ();
ref_sound m_sound_h;
ref_sound m_sound_t;
}; | [
"53347567+xrModder@users.noreply.github.com"
] | 53347567+xrModder@users.noreply.github.com |
23de84ca89661f8bbccc14c8a8eaa75840aa0502 | 9866046bbf5a70e4373a7e3dcbfbc8f768452828 | /include/octoon/graphics/graphics_child.h | cebdf7c8046ac3965fedbb44843f7bedf10aebc0 | [
"MIT"
] | permissive | baixiaohub/octoon | 37764b844748e0ed4710e5761f3f6114acf76e3d | c8f09e1885cfa8aeef2b1ac1751dd5d172cf9ee9 | refs/heads/master | 2020-03-15T12:58:00.319194 | 2018-05-01T16:21:58 | 2018-05-01T16:21:58 | 132,155,638 | 1 | 0 | null | 2018-05-04T15:10:15 | 2018-05-04T15:10:14 | null | UTF-8 | C++ | false | false | 594 | h | #ifndef OCTOON_GRAPHICS_CHILD_H_
#define OCTOON_GRAPHICS_CHILD_H_
#include <octoon/graphics/graphics_types.h>
namespace octoon
{
namespace graphics
{
class OCTOON_EXPORT GraphicsChild : public runtime::RttiInterface
{
OctoonDeclareSubInterface(GraphicsChild, runtime::RttiInterface)
public:
GraphicsChild() noexcept = default;
virtual ~GraphicsChild() = default;
virtual GraphicsDevicePtr getDevice() noexcept = 0;
private:
GraphicsChild(const GraphicsChild&) noexcept = delete;
GraphicsChild& operator=(const GraphicsChild&) noexcept = delete;
};
}
}
#endif | [
"2221870259@qq.com"
] | 2221870259@qq.com |
0e4626506c174cc3576f88268562755eae62c0ff | d2249116413e870d8bf6cd133ae135bc52021208 | /Ultimate Toolbox/samples/graphics/ImageViewer/ImageViewerDoc.cpp | 018356152055242595db0073457988e6c21fd01f | [] | no_license | Unknow-man/mfc-4 | ecbdd79cc1836767ab4b4ca72734bc4fe9f5a0b5 | b58abf9eb4c6d90ef01b9f1203b174471293dfba | refs/heads/master | 2023-02-17T18:22:09.276673 | 2021-01-20T07:46:14 | 2021-01-20T07:46:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,732 | cpp | // ImageViewerDoc.cpp : implementation of the CImageViewerDoc class
//
#include "stdafx.h"
#include "ImageViewer.h"
#include "ImageViewerDoc.h"
#include "ImageViewerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CImageViewerDoc
IMPLEMENT_DYNCREATE(CImageViewerDoc, CDocument)
BEGIN_MESSAGE_MAP(CImageViewerDoc, CDocument)
//{{AFX_MSG_MAP(CImageViewerDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CImageViewerDoc construction/destruction
CImageViewerDoc::CImageViewerDoc()
{
// TODO: add one-time construction code here
}
CImageViewerDoc::~CImageViewerDoc()
{
}
BOOL CImageViewerDoc::OnNewDocument()
{
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// CImageViewerDoc serialization
void CImageViewerDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CImageViewerDoc diagnostics
#ifdef _DEBUG
void CImageViewerDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CImageViewerDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CImageViewerDoc commands
BOOL CImageViewerDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
POSITION pos=GetFirstViewPosition();
ASSERT(pos!=NULL);
CImageViewerView* pView=(CImageViewerView*)GetNextView(pos);
ASSERT(pView!=NULL);
#ifdef OXDIB_SUPPORTJPEG
if(!pView->GetImageViewer()->LoadJPEGFile(lpszPathName))
#endif // OXDIB_SUPPORTJPEG
pView->GetImageViewer()->LoadFile(lpszPathName);
return TRUE;
}
BOOL CImageViewerDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: Add your specialized code here and/or call the base class
POSITION pos=GetFirstViewPosition();
ASSERT(pos!=NULL);
CImageViewerView* pView=(CImageViewerView*)GetNextView(pos);
ASSERT(pView!=NULL);
#ifdef OXDIB_SUPPORTJPEG
return pView->GetImageViewer()->GetImage()->WriteJPEG(lpszPathName);
#else
return pView->GetImageViewer()->GetImage()->Write(lpszPathName);
#endif // OXDIB_SUPPORTJPEG
}
| [
"chenchao0632@163.com"
] | chenchao0632@163.com |
329e05adb3f60ac746dd9bb13612cf88630376b8 | 5a5f441184b209816dc97864ed94c299305771e3 | /src/common/omnetppscalarfilewriter.h | 5d8ebe25a3d0449ab29d5440aa0cbad686f23a5d | [] | no_license | msc-thesis/omnetpp | 8939556de14ae5f5a96913fa0761f4d0fefdcea9 | a758e343aee6e36f15f12e40369cf4da5b1e00bf | refs/heads/master | 2023-04-18T11:33:47.303022 | 2021-04-23T15:54:04 | 2021-04-28T14:25:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,959 | h | //==========================================================================
// OMNETPPSCALARFILEWRITER.H - part of
// OMNeT++/OMNEST
// Discrete System Simulation in C++
//
// Author: Andras Varga
//
//==========================================================================
/*--------------------------------------------------------------*
Copyright (C) 2015 OpenSim Ltd.
This file is distributed WITHOUT ANY WARRANTY. See the file
`license' for details on this and other legal matters.
*--------------------------------------------------------------*/
#ifndef __OMNETPP_COMMON_OMNETPPSCALARFILEWRITER_H
#define __OMNETPP_COMMON_OMNETPPSCALARFILEWRITER_H
#include <string>
#include <map>
#include <vector>
#include "statistics.h"
#include "histogram.h"
namespace omnetpp {
namespace common {
/**
* Class for writing text-based output scalar files.
*/
class COMMON_API OmnetppScalarFileWriter
{
public:
typedef std::map<std::string, std::string> StringMap;
typedef std::vector<std::pair<std::string, std::string>> OrderedKeyValueList;
protected:
std::string fname; // output file name
FILE *f = nullptr; // file ptr of output file; nullptr if closed (not yet opened, or after error)
int prec = 14; // number of significant digits when writing doubles
protected:
void check(int fprintfResult);
void writeAttributes(const StringMap& attributes);
void writeStatisticFields(const Statistics& statistic);
void writeStatisticField(const char *name, int64_t value);
void writeStatisticField(const char *name, double value);
void writeBin(double lowerEdge, double value);
public:
OmnetppScalarFileWriter() {}
virtual ~OmnetppScalarFileWriter();
void open(const char *filename); // append if file exists
void close();
bool isOpen() const {return f != nullptr;} // IMPORTANT: file will be closed when an error occurs
void setPrecision(int p) {prec = p;}
int getPrecision() const {return prec;}
void beginRecordingForRun(const std::string& runName, const StringMap& attributes, const StringMap& itervars, const OrderedKeyValueList& configEntries);
void endRecordingForRun();
void recordScalar(const std::string& componentFullPath, const std::string& name, double value, const StringMap& attributes);
void recordStatistic(const std::string& componentFullPath, const std::string& name, const Statistics& statistic, const StringMap& attributes);
void recordHistogram(const std::string& componentFullPath, const std::string& name, const Statistics& statistic, const Histogram& bins, const StringMap& attributes); //TODO should be done by recordStatistic; do recordWeightedStatistic instead!
void recordParameter(const std::string& componentFullPath, const std::string& name, const std::string& value, const StringMap& attributes);
void flush();
};
} // namespace common
} // namespace omnetpp
#endif
| [
"andras@omnetpp.org"
] | andras@omnetpp.org |
892d0bedf47cfff32558048b9d3575eaefeede64 | 6c2bc0da53a90447c097038f2e47ce6179ae4ad3 | /waveguide/linalg/matrix.hpp | cac90bef11bb8491b9e5c65847fda01ac776edf4 | [] | no_license | citrux/numeric-methods | 80306ab35b670bf543ff3e39634118fc8c210c5d | 9eaa48921d3aa62043d37f5700e16139fc049062 | refs/heads/master | 2020-06-04T18:02:45.659385 | 2015-05-21T07:38:41 | 2015-05-21T07:38:41 | 23,885,949 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 966 | hpp | #pragma once
#include "vector.hpp"
typedef vector<vec> mat;
struct srow // sparse row
{
vector<pair<size_t, double>> data;
double operator () (const size_t i);
double & operator [] (const size_t i);
};
typedef vector<srow> smat; // sparse matrix
srow & operator *= (srow & a, const double b);
srow & operator /= (srow & a, const double b);
srow & operator += (srow & a, const srow & b);
srow & operator -= (srow & a, const srow & b);
srow operator * (srow a, const double b);
srow operator / (srow a, const double b);
vec operator * (const smat & a, const vec & b);
smat operator * (smat a, const double b);
smat operator - (smat a);
mat operator - (mat a);
smat & operator += (smat & a, const smat & b);
smat & operator -= (smat & a, const smat & b);
smat operator + (smat a, const smat & b);
smat operator - (smat a, const smat & b);
smat I(const size_t n);
vec operator * (const mat & a, const vec & b);
mat operator * (mat a, const double b);
| [
"369565@gmail.com"
] | 369565@gmail.com |
89713012e1054466fc699bb238f2c93ddc633314 | ca0c17e84d2082db1097628393c4373696a425d3 | /src/parser/block_parsers/vsc_line_parser33.cpp | da076c1ca05f6aa698e1b4fc48cdf8a03d1d18ca | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | GridOPTICS/GridPACK | cc7475c427133987ef0e6ce1a050f83593a8d0dc | 8ba94936b204a3c0fbcdc97a10c8eebc1cc25609 | refs/heads/develop | 2023-09-03T13:24:53.364094 | 2023-08-28T16:19:20 | 2023-08-28T16:19:20 | 22,120,575 | 42 | 16 | null | 2023-09-05T14:55:21 | 2014-07-22T21:01:57 | C++ | UTF-8 | C++ | false | false | 1,755 | cpp | /*
* Copyright (c) 2013 Battelle Memorial Institute
* Licensed under modified BSD License. A copy of this license can be found
* in the LICENSE file in the top level directory of this distribution.
*
*
* vsc_line_parser33.cpp
* Created on: November 29, 2022
* Author: Bruce Palmer
*/
#include "vsc_line_parser33.hpp"
/**
* Constructor
* @param bus_map map indices in RAW file to internal indices
* @param name_map map name in RAW file to internal indices
* @param branch_map map bus index pair in RAW file to internal indices
*/
gridpack::parser::VSCLineParser33::VSCLineParser33(
std::map<int,int> *bus_map,
std::map<std::string,int> *name_map,
std::map<std::pair<int, int>, int> *branch_map) :
gridpack::parser::BaseBlockParser(
bus_map, name_map, branch_map)
{
}
/**
* Simple Destructor
*/
gridpack::parser::VSCLineParser33::~VSCLineParser33(void)
{
}
/**
* parse vsc line block. Currently does not store data
* @param stream input stream that feeds lines from RAW file
*/
void gridpack::parser::VSCLineParser33::parse(
gridpack::stream::InputStream &stream)
{
std::string line;
stream.nextLine(line); //this should be the first line of the block
while(test_end(line)) {
std::vector<std::string> split_line;
if (check_comment(line)) {
stream.nextLine(line);
continue;
}
this->cleanComment(line);
split_line = this->splitPSSELine(line);
int l_idx, o_idx;
o_idx = atoi(split_line[1].c_str());
std::map<int, int>::iterator it;
it = p_busMap->find(o_idx);
if (it != p_busMap->end()) {
l_idx = it->second;
} else {
stream.nextLine(line);
continue;
}
stream.nextLine(line);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
388996533dff73ad4eda933dc810693f0a294241 | 94f0d2dfd9e1bdb4d9055f716804308acc2d4b88 | /libraries/appbase/version.cpp | e2b94bed8e6d1243cb6cf63a19f3f413757d8fd0 | [] | no_license | Kennybll/telos-build | 4d70e6f240ddc6335487dc8ccb00a8773d00fecf | d29d81c01612a9bb793c22e0e17ebeb6c9d2dadd | refs/heads/master | 2020-04-20T10:12:31.251654 | 2019-02-02T02:15:24 | 2019-02-02T02:15:24 | 168,784,630 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 76 | cpp | namespace appbase {
const char* appbase_version_string = "oak-v1.4.5";
}
| [
"you@example.com"
] | you@example.com |
511f4f527fbd7d78b122046384ed3c5f46852839 | 4f69e8e790026e9d86bbcc6165739bac96b31bc0 | /ArduinoSketch/VidorNinaWifiTest/src/WiFiNINA/utility/spi_drv.cpp | 922f51388279475c47ea9780f1bbe046216f5973 | [] | no_license | zst123/Vidor-Music-Jukebox | 7fe52626a979b02155b36591c91d1f9e516972f9 | d4d054222adb6e2d6f711f3e0d8f7e3d41d33c90 | refs/heads/master | 2023-03-31T03:29:32.780562 | 2021-04-02T10:22:41 | 2021-04-02T10:22:41 | 353,982,841 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,424 | cpp | /*
spi_drv.cpp - Library for Arduino Wifi shield.
Copyright (c) 2018 Arduino SA. All rights reserved.
Copyright (c) 2011-2014 Arduino. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "Arduino.h"
#include <SPI.h>
#include "../utility/spi_drv.h"
#include "pins_arduino.h"
/*
#ifdef ARDUINO_SAMD_MKRVIDOR4000
// check if a bitstream is already included
#if __has_include(<VidorFPGA.h>)
// yes, so use the existing VidorFPGA include
#include <VidorFPGA.h>
#else
// otherwise, fallback to VidorPeripherals and it's bitstream
#include <VidorPeripherals.h>
#endif
#define NINA_GPIO0 FPGA_NINA_GPIO0
#define SPIWIFI_SS FPGA_SPIWIFI_SS
#define SPIWIFI_ACK FPGA_SPIWIFI_ACK
#define SPIWIFI_RESET FPGA_SPIWIFI_RESET
#define pinMode(pin, mode) FPGA.pinMode(pin, mode)
#define digitalRead(pin) FPGA.digitalRead(pin)
#define digitalWrite(pin, value) FPGA.digitalWrite(pin, value)
#endif
*/
// Modified by zst123
#include "../../../pinout.h"
#define NINA_GPIO0 FPGA_NINA_GPIO0
#define SPIWIFI_SS FPGA_SPIWIFI_SS
#define SPIWIFI_ACK FPGA_SPIWIFI_ACK
#define SPIWIFI_RESET FPGA_SPIWIFI_RESET
//#define _DEBUG_
extern "C" {
#include "../utility/debug.h"
}
static uint8_t SLAVESELECT = 10; // ss
static uint8_t SLAVEREADY = 7; // handshake pin
static uint8_t SLAVERESET = 5; // reset pin
static bool inverted_reset = false;
#define DELAY_TRANSFER()
#ifndef SPIWIFI
#define SPIWIFI SPI
#endif
bool SpiDrv::initialized = false;
void SpiDrv::begin()
{
/*
#ifdef ARDUINO_SAMD_MKRVIDOR4000
FPGA.begin();
#endif
*/
#ifdef SPIWIFI_SS
SLAVESELECT = SPIWIFI_SS;
#endif
#ifdef SPIWIFI_ACK
SLAVEREADY = SPIWIFI_ACK;
#endif
#ifdef SPIWIFI_RESET
SLAVERESET = (uint8_t)SPIWIFI_RESET;
#endif
#ifdef ARDUINO_SAMD_MKRVIDOR4000
inverted_reset = false;
#else
if (SLAVERESET > PINS_COUNT) {
inverted_reset = true;
SLAVERESET = ~SLAVERESET;
}
#endif
SPIWIFI.begin();
pinMode(SLAVESELECT, OUTPUT);
pinMode(SLAVEREADY, INPUT);
pinMode(SLAVERESET, OUTPUT);
pinMode(NINA_GPIO0, OUTPUT);
digitalWrite(NINA_GPIO0, HIGH);
digitalWrite(SLAVESELECT, HIGH);
digitalWrite(SLAVERESET, inverted_reset ? HIGH : LOW);
delay(10);
digitalWrite(SLAVERESET, inverted_reset ? LOW : HIGH);
delay(750);
digitalWrite(NINA_GPIO0, LOW);
pinMode(NINA_GPIO0, INPUT);
#ifdef _DEBUG_
INIT_TRIGGER()
#endif
initialized = true;
}
void SpiDrv::end() {
digitalWrite(SLAVERESET, inverted_reset ? HIGH : LOW);
pinMode(SLAVESELECT, INPUT);
SPIWIFI.end();
initialized = false;
}
void SpiDrv::spiSlaveSelect()
{
SPIWIFI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
digitalWrite(SLAVESELECT,LOW);
// wait for up to 5 ms for the NINA to indicate it is not ready for transfer
// the timeout is only needed for the case when the shield or module is not present
for (unsigned long start = millis(); (digitalRead(SLAVEREADY) != HIGH) && (millis() - start) < 5;);
}
void SpiDrv::spiSlaveDeselect()
{
digitalWrite(SLAVESELECT,HIGH);
SPIWIFI.endTransaction();
}
char SpiDrv::spiTransfer(volatile char data)
{
char result = SPIWIFI.transfer(data);
DELAY_TRANSFER();
return result; // return the received byte
}
int SpiDrv::waitSpiChar(unsigned char waitChar)
{
int timeout = TIMEOUT_CHAR;
unsigned char _readChar = 0;
do{
_readChar = readChar(); //get data byte
if (_readChar == ERR_CMD)
{
WARN("Err cmd received\n");
return -1;
}
}while((timeout-- > 0) && (_readChar != waitChar));
return (_readChar == waitChar);
}
int SpiDrv::readAndCheckChar(char checkChar, char* readChar)
{
getParam((uint8_t*)readChar);
return (*readChar == checkChar);
}
char SpiDrv::readChar()
{
uint8_t readChar = 0;
getParam(&readChar);
return readChar;
}
#define WAIT_START_CMD(x) waitSpiChar(START_CMD)
#define IF_CHECK_START_CMD(x) \
if (!WAIT_START_CMD(_data)) \
{ \
TOGGLE_TRIGGER() \
WARN("Error waiting START_CMD"); \
return 0; \
}else \
#define CHECK_DATA(check, x) \
if (!readAndCheckChar(check, &x)) \
{ \
TOGGLE_TRIGGER() \
WARN("Reply error"); \
INFO2(check, (uint8_t)x); \
return 0; \
}else \
#define waitSlaveReady() (digitalRead(SLAVEREADY) == LOW)
#define waitSlaveSign() (digitalRead(SLAVEREADY) == HIGH)
#define waitSlaveSignalH() while(digitalRead(SLAVEREADY) != HIGH){}
#define waitSlaveSignalL() while(digitalRead(SLAVEREADY) != LOW){}
void SpiDrv::waitForSlaveSign()
{
while (!waitSlaveSign());
}
void SpiDrv::waitForSlaveReady()
{
while (!waitSlaveReady());
}
void SpiDrv::getParam(uint8_t* param)
{
// Get Params data
*param = spiTransfer(DUMMY_DATA);
DELAY_TRANSFER();
}
int SpiDrv::waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len)
{
char _data = 0;
int ii = 0;
IF_CHECK_START_CMD(_data)
{
CHECK_DATA(cmd | REPLY_FLAG, _data){};
CHECK_DATA(numParam, _data)
{
readParamLen8(param_len);
for (ii=0; ii<(*param_len); ++ii)
{
// Get Params data
//param[ii] = spiTransfer(DUMMY_DATA);
getParam(¶m[ii]);
}
}
readAndCheckChar(END_CMD, &_data);
}
return 1;
}
/*
int SpiDrv::waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint16_t* param_len)
{
char _data = 0;
int i =0, ii = 0;
IF_CHECK_START_CMD(_data)
{
CHECK_DATA(cmd | REPLY_FLAG, _data){};
CHECK_DATA(numParam, _data);
{
readParamLen16(param_len);
for (ii=0; ii<(*param_len); ++ii)
{
// Get Params data
param[ii] = spiTransfer(DUMMY_DATA);
}
}
readAndCheckChar(END_CMD, &_data);
}
return 1;
}
*/
int SpiDrv::waitResponseData16(uint8_t cmd, uint8_t* param, uint16_t* param_len)
{
char _data = 0;
uint16_t ii = 0;
IF_CHECK_START_CMD(_data)
{
CHECK_DATA(cmd | REPLY_FLAG, _data){};
uint8_t numParam = readChar();
if (numParam != 0)
{
readParamLen16(param_len);
for (ii=0; ii<(*param_len); ++ii)
{
// Get Params data
param[ii] = spiTransfer(DUMMY_DATA);
}
}
readAndCheckChar(END_CMD, &_data);
}
return 1;
}
int SpiDrv::waitResponseData8(uint8_t cmd, uint8_t* param, uint8_t* param_len)
{
char _data = 0;
int ii = 0;
IF_CHECK_START_CMD(_data)
{
CHECK_DATA(cmd | REPLY_FLAG, _data){};
uint8_t numParam = readChar();
if (numParam != 0)
{
readParamLen8(param_len);
for (ii=0; ii<(*param_len); ++ii)
{
// Get Params data
param[ii] = spiTransfer(DUMMY_DATA);
}
}
readAndCheckChar(END_CMD, &_data);
}
return 1;
}
int SpiDrv::waitResponseParams(uint8_t cmd, uint8_t numParam, tParam* params)
{
char _data = 0;
int i =0, ii = 0;
IF_CHECK_START_CMD(_data)
{
CHECK_DATA(cmd | REPLY_FLAG, _data){};
uint8_t _numParam = readChar();
if (_numParam != 0)
{
for (i=0; i<_numParam; ++i)
{
params[i].paramLen = readParamLen8();
for (ii=0; ii<params[i].paramLen; ++ii)
{
// Get Params data
params[i].param[ii] = spiTransfer(DUMMY_DATA);
}
}
} else
{
WARN("Error numParam == 0");
return 0;
}
if (numParam != _numParam)
{
WARN("Mismatch numParam");
return 0;
}
readAndCheckChar(END_CMD, &_data);
}
return 1;
}
/*
int SpiDrv::waitResponse(uint8_t cmd, tParam* params, uint8_t* numParamRead, uint8_t maxNumParams)
{
char _data = 0;
int i =0, ii = 0;
IF_CHECK_START_CMD(_data)
{
CHECK_DATA(cmd | REPLY_FLAG, _data){};
uint8_t numParam = readChar();
if (numParam > maxNumParams)
{
numParam = maxNumParams;
}
*numParamRead = numParam;
if (numParam != 0)
{
for (i=0; i<numParam; ++i)
{
params[i].paramLen = readParamLen8();
for (ii=0; ii<params[i].paramLen; ++ii)
{
// Get Params data
params[i].param[ii] = spiTransfer(DUMMY_DATA);
}
}
} else
{
WARN("Error numParams == 0");
Serial.println(cmd, 16);
return 0;
}
readAndCheckChar(END_CMD, &_data);
}
return 1;
}
*/
int SpiDrv::waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, uint8_t maxNumParams)
{
char _data = 0;
int i =0, ii = 0;
char *index[WL_SSID_MAX_LENGTH];
for (i = 0 ; i < WL_NETWORKS_LIST_MAXNUM ; i++)
index[i] = (char *)params + WL_SSID_MAX_LENGTH*i;
IF_CHECK_START_CMD(_data)
{
CHECK_DATA(cmd | REPLY_FLAG, _data){};
uint8_t numParam = readChar();
if (numParam > maxNumParams)
{
numParam = maxNumParams;
}
*numParamRead = numParam;
if (numParam != 0)
{
for (i=0; i<numParam; ++i)
{
uint8_t paramLen = readParamLen8();
for (ii=0; ii<paramLen; ++ii)
{
//ssid[ii] = spiTransfer(DUMMY_DATA);
// Get Params data
index[i][ii] = (uint8_t)spiTransfer(DUMMY_DATA);
}
index[i][ii]=0;
}
} else
{
WARN("Error numParams == 0");
readAndCheckChar(END_CMD, &_data);
return 0;
}
readAndCheckChar(END_CMD, &_data);
}
return 1;
}
void SpiDrv::sendParamNoLen(uint8_t* param, size_t param_len, uint8_t lastParam)
{
size_t i = 0;
// Send Spi paramLen
sendParamLen8(0);
// Send Spi param data
for (i=0; i<param_len; ++i)
{
spiTransfer(param[i]);
}
// if lastParam==1 Send Spi END CMD
if (lastParam == 1)
spiTransfer(END_CMD);
}
void SpiDrv::sendParam(uint8_t* param, uint8_t param_len, uint8_t lastParam)
{
int i = 0;
// Send Spi paramLen
sendParamLen8(param_len);
// Send Spi param data
for (i=0; i<param_len; ++i)
{
spiTransfer(param[i]);
}
// if lastParam==1 Send Spi END CMD
if (lastParam == 1)
spiTransfer(END_CMD);
}
void SpiDrv::sendParamLen8(uint8_t param_len)
{
// Send Spi paramLen
spiTransfer(param_len);
}
void SpiDrv::sendParamLen16(uint16_t param_len)
{
// Send Spi paramLen
spiTransfer((uint8_t)((param_len & 0xff00)>>8));
spiTransfer((uint8_t)(param_len & 0xff));
}
uint8_t SpiDrv::readParamLen8(uint8_t* param_len)
{
uint8_t _param_len = spiTransfer(DUMMY_DATA);
if (param_len != NULL)
{
*param_len = _param_len;
}
return _param_len;
}
uint16_t SpiDrv::readParamLen16(uint16_t* param_len)
{
uint16_t _param_len = spiTransfer(DUMMY_DATA)<<8 | (spiTransfer(DUMMY_DATA)& 0xff);
if (param_len != NULL)
{
*param_len = _param_len;
}
return _param_len;
}
void SpiDrv::sendBuffer(uint8_t* param, uint16_t param_len, uint8_t lastParam)
{
uint16_t i = 0;
// Send Spi paramLen
sendParamLen16(param_len);
// Send Spi param data
for (i=0; i<param_len; ++i)
{
spiTransfer(param[i]);
}
// if lastParam==1 Send Spi END CMD
if (lastParam == 1)
spiTransfer(END_CMD);
}
void SpiDrv::sendParam(uint16_t param, uint8_t lastParam)
{
// Send Spi paramLen
sendParamLen8(2);
spiTransfer((uint8_t)((param & 0xff00)>>8));
spiTransfer((uint8_t)(param & 0xff));
// if lastParam==1 Send Spi END CMD
if (lastParam == 1)
spiTransfer(END_CMD);
}
/* Cmd Struct Message */
/* _________________________________________________________________________________ */
/*| START CMD | C/R | CMD |[TOT LEN]| N.PARAM | PARAM LEN | PARAM | .. | END CMD | */
/*|___________|______|______|_________|_________|___________|________|____|_________| */
/*| 8 bit | 1bit | 7bit | 8bit | 8bit | 8bit | nbytes | .. | 8bit | */
/*|___________|______|______|_________|_________|___________|________|____|_________| */
void SpiDrv::sendCmd(uint8_t cmd, uint8_t numParam)
{
// Send Spi START CMD
spiTransfer(START_CMD);
// Send Spi C + cmd
spiTransfer(cmd & ~(REPLY_FLAG));
// Send Spi totLen
//spiTransfer(totLen);
// Send Spi numParam
spiTransfer(numParam);
// If numParam == 0 send END CMD
if (numParam == 0)
spiTransfer(END_CMD);
}
int SpiDrv::available()
{
return (digitalRead(NINA_GPIO0) != LOW);
}
SpiDrv spiDrv;
| [
"zst123@users.noreply.github.com"
] | zst123@users.noreply.github.com |
02657e797ebace9aad73b8648a18707400fafc75 | 87b6bc4f92a5a4fd100cf8142d9e19b3f683d7d9 | /demo/cpp/src/solution.cpp | 6d7e879c44c672c2cda51b32f8a61f2e1abbf343 | [] | no_license | halibut735/leetcode | 9fc9746d55fb6fafe9fe29fc845a2603314955f0 | 8fd102c96ecec3790e336b3a7a999f5c7d1bf74c | refs/heads/master | 2021-06-18T21:32:47.859287 | 2017-04-12T07:36:59 | 2017-04-12T07:36:59 | 35,431,674 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 225 | cpp | #include <iostream>
#include "solution.h"
using namespace std;
int main()
{
ListNode *head;
ListNode aa(1);
head = &aa;
Solution sol;
sol.rotateRight(head, 1);
sol.print_list(head);
return 1;
}
| [
"827603830@qq.com"
] | 827603830@qq.com |
6672c1f99669e99ab150d86c47e34cb45bd774bd | fdccb70a06bb2584bb2e909dcc4053129fff9cee | /Classes/PersonalAudioEngine.h | b413acca8273daa2db4ef27da200b0cfd4131b3f | [
"MIT"
] | permissive | chenliangchao/FishingJoy | 8754375b1353f0774fa8b24dda28419a03048112 | 4f7914d8a589971aaa5576429b74ee7d2a0670a5 | refs/heads/master | 2021-09-01T21:05:51.811132 | 2017-12-28T15:53:38 | 2017-12-28T15:53:38 | 104,621,606 | 1 | 1 | null | null | null | null | GB18030 | C++ | false | false | 792 | h | #pragma once
#include "cocos2d.h"
#include "SimpleAudioEngine.h"
USING_NS_CC;
using namespace CocosDenshion;
typedef enum{
kEffectSwichCannon = 0,
kEffectShoot,
kEffectFishNet,
kEffectCoins
}EffectType;
class PersonalAudioEngine :
public SimpleAudioEngine
{
public:
PersonalAudioEngine(void);
~PersonalAudioEngine(void);
static PersonalAudioEngine* sharedEngine();
bool init();
//是否开启背景音乐
void setBackgroundMusic(bool isOn);
//是否开启音效
//void setEffects(bool isOn);
void playEffects(EffectType type);
void purge();
CC_SYNTHESIZE(unsigned int, _bgMusicId, BgMusicId);
CC_SYNTHESIZE(unsigned int, _netSoundId, NetSoundId);
CC_SYNTHESIZE(unsigned int, _fireSoundId, FireSoundId);
CC_SYNTHESIZE(unsigned int, _btnSoundId, BtnSoundId);
};
| [
"786542304@qq.com"
] | 786542304@qq.com |
cdb1e7ae57ba9da9adbb09608ec917ca77d30c7e | 72806e672ae44be1ad5d1365224b9b430d1fa721 | /pod/pinocchio/qap/GateZerop.h | 3e7e8dec18bee13c2ddfade9018366ac7c3de0fa | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | imtypist/BlockSense | 277814436a50c800625193d4c72982e326f9566a | 00a0336205c1f1049d978b07bcf078b8c85374b0 | refs/heads/master | 2023-05-27T13:42:32.715625 | 2023-05-15T09:53:58 | 2023-05-15T09:53:58 | 145,524,879 | 14 | 4 | null | 2020-07-18T04:56:06 | 2018-08-21T07:33:59 | C++ | UTF-8 | C++ | false | false | 900 | h | #pragma once
#include "Gate.h"
#include "Wire.h"
#include "QAP.h"
#include "SparsePolynomial.h"
#include <forward_list>
#include <list>
using namespace std;
class QAP;
class GateMul2;
class Circuit;
// The equals-zero gate
class GateZerop : public GateMul2 {
public:
GateZerop(Field * field);
virtual ~GateZerop();
void eval();
bool isMult(){return true;}
void updateModifer(Modifier*){}
#if 0
virtual CachedPolynomial* getCachedPolynomial();
virtual void cachePolynomial(CachedPolynomial* poly);
virtual void deleteCachedPolynomial(CachedPolynomial* poly);
#endif
virtual void generatePolys(QAP* qap, bool cachedBuild);
virtual void assignPolyCoeff(QAP* qap);
virtual int polyCount(){return 1;}
virtual list<GateZerop*> getPolyGeneratorList();
bool testAndSetReady();
GateZerop * next, *prev;
protected:
FieldElt zero, one, inv;
int r2;
CachedPolynomial* cachedPoly;
}; | [
"junqin.huang@qq.com"
] | junqin.huang@qq.com |
55d3907ff7fad2f5e6e91926e3c23edb65da773c | a2432a223e33f34fc71b78ac89e2c253be7eb32f | /05218/main.cpp | 1db3bedecfe576f9e868a28bebc91b8573fe5b73 | [] | no_license | lys8325/boj_study | 7354e5a31b4a11c2b3ae48ea5645dcba4098727f | 76ae4bdebdad3162e3576c51d3f7e2b8b31b9dba | refs/heads/master | 2021-06-22T00:40:17.708864 | 2021-04-27T14:41:43 | 2021-04-27T14:41:43 | 220,608,086 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 493 | cpp | #include <iostream>
#include <cstring>
using namespace std;
int main() {
int len,t;
char a[20],b[20];
cin>>t;
for(int i=0;i<t;++i){
cin>>a>>b;
len = strlen(a);
cout<<"Distances:";
for(int j=0;j<len;++j){
if(a[j] > b[j]){
cout<<" "<<(b[j] - 64 + 26) - (a[j] - 64 );
}
else{
cout<<" "<<(b[j] - 64) - (a[j] - 64);
}
}
cout<<endl;
}
return 0;
} | [
"lys8325@naver.com"
] | lys8325@naver.com |
dc3c2f6807f527a64303cd62d729218cc174c013 | a692fe17e0c96a713ccb89ad36f0348cbc4b361f | /osiris/nwx/setptr.h | dc4cfb5c529d06698d38bb16c95a1b9aa9144071 | [] | no_license | Rajesh35hsp/osiris | 9c249633745d0730c96132a58bfd95e0aeaa1148 | c9b22d74881472b43f2c0e5619aa53341c709d19 | refs/heads/master | 2023-08-27T00:50:03.242581 | 2021-11-05T13:26:29 | 2021-11-05T13:26:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,266 | h | /*
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* FileName: setptr.h
* Author: Douglas Hoffman
*
*/
#ifndef __SET_PTR_HPP__
#define __SET_PTR_HPP__
#include "nwx/stdb.h"
#include <set>
#include "nwx/stde.h"
template<class T, class S = std::less<T *> > class setptr :
public std::set<T *,S>
{
public:
setptr<T,S>() {;}
setptr<T,S>(const std::set<T *,S> &x)
{
copy(this,x);
}
virtual ~setptr<T,S>()
{
cleanup(this);
}
static bool IsEqual(
const std::set<T *,S> &x1,
const std::set<T *,S> &x2)
{
bool bRtn = false;
if(x1.size() == x2.size())
{
typename std::set<T *,S>::const_iterator itr1;
typename std::set<T *,S>::const_iterator itr2;
itr1 = x1.begin();
itr2 = x2.begin();
T *p1;
T *p2;
bRtn = true;
while(bRtn && (itr1 != x1.end()))
{
p1 = *itr1;
p2 = *itr2;
if(!( (*p1) == (*p2) ))
{
bRtn = false;
}
++itr1;
++itr2;
}
}
return bRtn;
}
public:
static void cleanup(std::set<T *,S> *p)
{
typename std::set<T *,S>::iterator itr;
T *px;
for(itr = p->begin();
itr != p->end();
itr = p->begin())
{
px = *itr;
delete (px);
p->erase(itr);
}
}
static void copy(std::set<T *,S> *pTo, const std::set<T *,S> &xFrom)
{
cleanup(pTo);
typename std::set<T *,S>::const_iterator itr;
for(itr = xFrom.begin(); itr != xFrom.end(); ++itr)
{
T *px = *itr;
T *pnew = new T(*px);
pTo->insert(pnew);
}
}
};
// copy/paste/edit of the above
template<class T, class S = std::less<T *> > class multisetptr :
public std::multiset<T *, S>
{
public:
multisetptr<T, S>() { ; }
multisetptr<T, S>(const std::multiset<T *, S> &x)
{
copy(this, x);
}
virtual ~multisetptr<T, S>()
{
cleanup(this);
}
static bool IsEqual(
const std::multiset<T *, S> &x1,
const std::multiset<T *, S> &x2)
{
bool bRtn = false;
if (x1.size() == x2.size())
{
typename std::multiset<T *, S>::const_iterator itr1;
typename std::multiset<T *, S>::const_iterator itr2;
itr1 = x1.begin();
itr2 = x2.begin();
T *p1;
T *p2;
bRtn = true;
while (bRtn && (itr1 != x1.end()))
{
p1 = *itr1;
p2 = *itr2;
if (!((*p1) == (*p2)))
{
bRtn = false;
}
++itr1;
++itr2;
}
}
return bRtn;
}
public:
static void cleanup(std::multiset<T *, S> *p)
{
typename std::multiset<T *, S>::iterator itr;
T *px;
for (itr = p->begin();
itr != p->end();
itr = p->begin())
{
px = *itr;
delete (px);
p->erase(itr);
}
}
static void copy(std::multiset<T *, S> *pTo, const std::multiset<T *, S> &xFrom)
{
cleanup(pTo);
typename std::multiset<T *, S>::const_iterator itr;
for (itr = xFrom.begin(); itr != xFrom.end(); ++itr)
{
T *px = *itr;
T *pnew = new T(*px);
pTo->insert(pnew);
}
}
};
#endif
| [
"hoffman@ncbi.nlm.nih.gov"
] | hoffman@ncbi.nlm.nih.gov |
5f1c7b44e6acc79bf704a30adf08d8e4df8126f5 | 04a540847c1333c987a1957fd8d31197c594f6bb | /BOJ/17825_1.cpp | 40c6884aa9525ea100db5b436eef3717a4dc3a13 | [] | no_license | k8440009/Algorithm | fd148269b264b580876c7426e19dbe2425ddc1ab | a48eba0ac5c9f2e10f3c509ce9d349c8a1dc3f0c | refs/heads/master | 2023-04-02T16:06:10.260768 | 2023-04-02T11:04:32 | 2023-04-02T11:04:32 | 200,506,643 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,323 | cpp | // 주사위 윷놀이
// https://www.acmicpc.net/problem/17825
#include <iostream>
#include <vector>
using namespace std;
#define END 32
int dice[10];
int board[33][6] = {
{0,1,2,3,4,5}, //0번자리
{2,2,3,4,5,9}, //1번자리
{4,3,4,5,9,10}, //2번자리
{6,4,5,9,10,11}, //3번자리
{8,5,9,10,11,12},//4번자리
{10,6,7,8,20,29},//5번자리
{13,7,8,20,29,30}, //6번자리
{16,8,20,29,30,31}, //7번자리
{19,20,29,30,31,32}, //8번자리
{12,10,11,12,13,14}, //9번자리
{14,11,12,13,14,15}, //10번자리
{16,12,13,14,15,16}, //11번자리
{18,13,14,15,16,17}, //12번자리
{20,18,19,20,29,30}, //13번자리
{22,15,16,17,24,25}, //14번자리
{24,16,17,24,25,26}, //15번자리
{26,17,24,25,26,27}, //16번자리
{28,24,25,26,27,28}, //17번자리
{22,19,20,29,30,31}, //18번자리
{24,20,29,30,31,32}, //19번자리
{25,29,30,31,32,32}, //20번자리
{26,20,29,30,31,32}, //21번자리
{27,21,20,29,30,31}, //22번자리
{28,22,21,20,29,30}, //23번자리
{30,23,22,21,20,29}, //24번자리
{32,26,27,28,31,32}, //25번자리
{34,27,28,31,32,32}, //26번자리
{36,28,31,32,32,32}, //27번자리
{38,31,32,32,32,32}, //28번자리
{30,30,31,32,32,32}, //29번자리
{35,31,32,32,32,32}, //30번자리
{40,32,32,32,32,32}, //31번자리
{0,32,32,32,32,32} //32번자리
};
| [
"k8440009@gmail.com"
] | k8440009@gmail.com |
b3a60d6f0850c04ce8420e2d3f3af16e21212664 | aa9f4bf9b9d52cd5734463e7f06381e4ec3c4c4a | /05_Class/src/CustomBox.h | 188d79184a6fc3d55be5a9bb4a3bc216f64d6baf | [] | no_license | sgnm/leaders_MArt_8th | f62f51266e1ceaa115a9ee5fa9b51d72ef8ea2fd | cf371a1fd9cd7b0db8e8621214fb4c9309e4539a | refs/heads/master | 2021-01-09T20:07:36.414006 | 2016-06-07T08:23:11 | 2016-06-07T08:23:11 | 60,595,660 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 355 | h | //
// CustomBox.h
// 05_Class
//
// Created by Shin on 6/7/16.
//
//
#ifndef ___5_Class__CustomBox__
#define ___5_Class__CustomBox__
#include "ofMain.h"
class CustomBox{
public:
void addBox();
void draw();
private:
vector<ofBoxPrimitive> boxes; //ボックス型が入るvectorを用意
};
#endif /* defined(___5_Class__CustomBox__) */
| [
"suga315shin@gmail.com"
] | suga315shin@gmail.com |
1fc5e9191cd27908e510646073be2f1846f49bd9 | d14b5d78b72711e4614808051c0364b7bd5d6d98 | /third_party/llvm-10.0/llvm/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.h | 902b61cb5b6c8b51a42af7a1d3057c191c458794 | [
"Apache-2.0"
] | permissive | google/swiftshader | 76659addb1c12eb1477050fded1e7d067f2ed25b | 5be49d4aef266ae6dcc95085e1e3011dad0e7eb7 | refs/heads/master | 2023-07-21T23:19:29.415159 | 2023-07-21T19:58:29 | 2023-07-21T20:50:19 | 62,297,898 | 1,981 | 306 | Apache-2.0 | 2023-07-05T21:29:34 | 2016-06-30T09:25:24 | C++ | UTF-8 | C++ | false | false | 648 | h | //===-- HexagonTargetInfo.h - Hexagon Target Implementation -----*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_TARGET_HEXAGON_TARGETINFO_HEXAGONTARGETINFO_H
#define LLVM_LIB_TARGET_HEXAGON_TARGETINFO_HEXAGONTARGETINFO_H
namespace llvm {
class Target;
Target &getTheHexagonTarget();
} // namespace llvm
#endif // LLVM_LIB_TARGET_HEXAGON_TARGETINFO_HEXAGONTARGETINFO_H
| [
"bclayton@google.com"
] | bclayton@google.com |
ad912bb2252f4ad87937b2ceef0491859589620a | d4ea4298517827d56b490b924c65c83c42f21cfc | /vw_jni/com_indeed_vw_wrapper_learner_VWProbLearner.cc | 95532ed049cdec84d40d139ee5c73cda8949d5be | [
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ljha-CS/vowpal-wabbit-java | 9a97d4c2f2d5f9de2e5a0fbeebc597cf91c18c5d | 98ab89be3f22304302de7c05e83c4503a5965398 | refs/heads/master | 2022-12-05T04:16:32.916053 | 2020-08-18T23:10:50 | 2020-08-18T23:10:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 688 | cc | #include "com_indeed_vw_wrapper_learner_VWProbLearner.h"
#include <vw.h>
#include "jni_base_learner.h"
jfloat prob_predictor(example* vec, JNIEnv *env) { return vec->pred.prob; }
JNIEXPORT jfloat JNICALL Java_com_indeed_vw_wrapper_learner_VWProbLearner_predict(JNIEnv *env, jobject obj, jstring example_string, jboolean learn, jlong vwPtr)
{ return base_predict<jfloat>(env, example_string, learn, vwPtr, prob_predictor);
}
JNIEXPORT jfloat JNICALL Java_com_indeed_vw_wrapper_learner_VWProbLearner_predictMultiline(JNIEnv *env, jobject obj, jobjectArray example_strings, jboolean learn, jlong vwPtr)
{ return base_predict<jfloat>(env, example_strings, learn, vwPtr, prob_predictor);
}
| [
"artem@indeed.com"
] | artem@indeed.com |
e9b7a5754ce0bc38f3220ad872d3806d6c2ef5fc | dba29afbd2bf7c9404b40c4f7821c69ee045fd24 | /thrift/CVRPTW.cpp | d0ffce264c06d43a0e758c023fe69c1b0ba00266 | [] | no_license | avan87/cvrptwmd | 686c24a13b88de910d55e77b92b8aa2e6fe82b58 | 64d94d201642272178f79967b16edfe21296b778 | refs/heads/master | 2020-12-25T11:06:16.067578 | 2016-08-18T19:02:06 | 2016-08-18T19:02:06 | 61,125,631 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 12,208 | cpp | /**
* Autogenerated by Thrift Compiler (0.9.3)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#include "CVRPTW.h"
CVRPTW_solveCVRPTW_args::~CVRPTW_solveCVRPTW_args() throw() {
}
uint32_t CVRPTW_solveCVRPTW_args::read(::apache::thrift::protocol::TProtocol* iprot) {
apache::thrift::protocol::TInputRecursionTracker tracker(*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;
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_STRUCT) {
xfer += this->data.read(iprot);
this->__isset.data = true;
} else {
xfer += iprot->skip(ftype);
}
break;
default:
xfer += iprot->skip(ftype);
break;
}
xfer += iprot->readFieldEnd();
}
xfer += iprot->readStructEnd();
return xfer;
}
uint32_t CVRPTW_solveCVRPTW_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
uint32_t xfer = 0;
apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
xfer += oprot->writeStructBegin("CVRPTW_solveCVRPTW_args");
xfer += oprot->writeFieldBegin("data", ::apache::thrift::protocol::T_STRUCT, 1);
xfer += this->data.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
xfer += oprot->writeStructEnd();
return xfer;
}
CVRPTW_solveCVRPTW_pargs::~CVRPTW_solveCVRPTW_pargs() throw() {
}
uint32_t CVRPTW_solveCVRPTW_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
uint32_t xfer = 0;
apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
xfer += oprot->writeStructBegin("CVRPTW_solveCVRPTW_pargs");
xfer += oprot->writeFieldBegin("data", ::apache::thrift::protocol::T_STRUCT, 1);
xfer += (*(this->data)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
xfer += oprot->writeStructEnd();
return xfer;
}
CVRPTW_solveCVRPTW_result::~CVRPTW_solveCVRPTW_result() throw() {
}
uint32_t CVRPTW_solveCVRPTW_result::read(::apache::thrift::protocol::TProtocol* iprot) {
apache::thrift::protocol::TInputRecursionTracker tracker(*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;
while (true)
{
xfer += iprot->readFieldBegin(fname, ftype, fid);
if (ftype == ::apache::thrift::protocol::T_STOP) {
break;
}
switch (fid)
{
case 0:
if (ftype == ::apache::thrift::protocol::T_STRUCT) {
xfer += this->success.read(iprot);
this->__isset.success = true;
} else {
xfer += iprot->skip(ftype);
}
break;
default:
xfer += iprot->skip(ftype);
break;
}
xfer += iprot->readFieldEnd();
}
xfer += iprot->readStructEnd();
return xfer;
}
uint32_t CVRPTW_solveCVRPTW_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
uint32_t xfer = 0;
xfer += oprot->writeStructBegin("CVRPTW_solveCVRPTW_result");
if (this->__isset.success) {
xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
xfer += this->success.write(oprot);
xfer += oprot->writeFieldEnd();
}
xfer += oprot->writeFieldStop();
xfer += oprot->writeStructEnd();
return xfer;
}
CVRPTW_solveCVRPTW_presult::~CVRPTW_solveCVRPTW_presult() throw() {
}
uint32_t CVRPTW_solveCVRPTW_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
apache::thrift::protocol::TInputRecursionTracker tracker(*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;
while (true)
{
xfer += iprot->readFieldBegin(fname, ftype, fid);
if (ftype == ::apache::thrift::protocol::T_STOP) {
break;
}
switch (fid)
{
case 0:
if (ftype == ::apache::thrift::protocol::T_STRUCT) {
xfer += (*(this->success)).read(iprot);
this->__isset.success = true;
} else {
xfer += iprot->skip(ftype);
}
break;
default:
xfer += iprot->skip(ftype);
break;
}
xfer += iprot->readFieldEnd();
}
xfer += iprot->readStructEnd();
return xfer;
}
void CVRPTWClient::solveCVRPTW(Result& _return, const CVRPTWData& data)
{
send_solveCVRPTW(data);
recv_solveCVRPTW(_return);
}
void CVRPTWClient::send_solveCVRPTW(const CVRPTWData& data)
{
int32_t cseqid = 0;
oprot_->writeMessageBegin("solveCVRPTW", ::apache::thrift::protocol::T_CALL, cseqid);
CVRPTW_solveCVRPTW_pargs args;
args.data = &data;
args.write(oprot_);
oprot_->writeMessageEnd();
oprot_->getTransport()->writeEnd();
oprot_->getTransport()->flush();
}
void CVRPTWClient::recv_solveCVRPTW(Result& _return)
{
int32_t rseqid = 0;
std::string fname;
::apache::thrift::protocol::TMessageType mtype;
iprot_->readMessageBegin(fname, mtype, rseqid);
if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
::apache::thrift::TApplicationException x;
x.read(iprot_);
iprot_->readMessageEnd();
iprot_->getTransport()->readEnd();
throw x;
}
if (mtype != ::apache::thrift::protocol::T_REPLY) {
iprot_->skip(::apache::thrift::protocol::T_STRUCT);
iprot_->readMessageEnd();
iprot_->getTransport()->readEnd();
}
if (fname.compare("solveCVRPTW") != 0) {
iprot_->skip(::apache::thrift::protocol::T_STRUCT);
iprot_->readMessageEnd();
iprot_->getTransport()->readEnd();
}
CVRPTW_solveCVRPTW_presult result;
result.success = &_return;
result.read(iprot_);
iprot_->readMessageEnd();
iprot_->getTransport()->readEnd();
if (result.__isset.success) {
// _return pointer has now been filled
return;
}
throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "solveCVRPTW failed: unknown result");
}
bool CVRPTWProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext) {
ProcessMap::iterator pfn;
pfn = processMap_.find(fname);
if (pfn == processMap_.end()) {
iprot->skip(::apache::thrift::protocol::T_STRUCT);
iprot->readMessageEnd();
iprot->getTransport()->readEnd();
::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'");
oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid);
x.write(oprot);
oprot->writeMessageEnd();
oprot->getTransport()->writeEnd();
oprot->getTransport()->flush();
return true;
}
(this->*(pfn->second))(seqid, iprot, oprot, callContext);
return true;
}
void CVRPTWProcessor::process_solveCVRPTW(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
{
void* ctx = NULL;
if (this->eventHandler_.get() != NULL) {
ctx = this->eventHandler_->getContext("CVRPTW.solveCVRPTW", callContext);
}
::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "CVRPTW.solveCVRPTW");
if (this->eventHandler_.get() != NULL) {
this->eventHandler_->preRead(ctx, "CVRPTW.solveCVRPTW");
}
CVRPTW_solveCVRPTW_args args;
args.read(iprot);
iprot->readMessageEnd();
uint32_t bytes = iprot->getTransport()->readEnd();
if (this->eventHandler_.get() != NULL) {
this->eventHandler_->postRead(ctx, "CVRPTW.solveCVRPTW", bytes);
}
CVRPTW_solveCVRPTW_result result;
try {
iface_->solveCVRPTW(result.success, args.data);
result.__isset.success = true;
} catch (const std::exception& e) {
if (this->eventHandler_.get() != NULL) {
this->eventHandler_->handlerError(ctx, "CVRPTW.solveCVRPTW");
}
::apache::thrift::TApplicationException x(e.what());
oprot->writeMessageBegin("solveCVRPTW", ::apache::thrift::protocol::T_EXCEPTION, seqid);
x.write(oprot);
oprot->writeMessageEnd();
oprot->getTransport()->writeEnd();
oprot->getTransport()->flush();
return;
}
if (this->eventHandler_.get() != NULL) {
this->eventHandler_->preWrite(ctx, "CVRPTW.solveCVRPTW");
}
oprot->writeMessageBegin("solveCVRPTW", ::apache::thrift::protocol::T_REPLY, seqid);
result.write(oprot);
oprot->writeMessageEnd();
bytes = oprot->getTransport()->writeEnd();
oprot->getTransport()->flush();
if (this->eventHandler_.get() != NULL) {
this->eventHandler_->postWrite(ctx, "CVRPTW.solveCVRPTW", bytes);
}
}
::boost::shared_ptr< ::apache::thrift::TProcessor > CVRPTWProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) {
::apache::thrift::ReleaseHandler< CVRPTWIfFactory > cleanup(handlerFactory_);
::boost::shared_ptr< CVRPTWIf > handler(handlerFactory_->getHandler(connInfo), cleanup);
::boost::shared_ptr< ::apache::thrift::TProcessor > processor(new CVRPTWProcessor(handler));
return processor;
}
void CVRPTWConcurrentClient::solveCVRPTW(Result& _return, const CVRPTWData& data)
{
int32_t seqid = send_solveCVRPTW(data);
recv_solveCVRPTW(_return, seqid);
}
int32_t CVRPTWConcurrentClient::send_solveCVRPTW(const CVRPTWData& data)
{
int32_t cseqid = this->sync_.generateSeqId();
::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_);
oprot_->writeMessageBegin("solveCVRPTW", ::apache::thrift::protocol::T_CALL, cseqid);
CVRPTW_solveCVRPTW_pargs args;
args.data = &data;
args.write(oprot_);
oprot_->writeMessageEnd();
oprot_->getTransport()->writeEnd();
oprot_->getTransport()->flush();
sentry.commit();
return cseqid;
}
void CVRPTWConcurrentClient::recv_solveCVRPTW(Result& _return, const int32_t seqid)
{
int32_t rseqid = 0;
std::string fname;
::apache::thrift::protocol::TMessageType mtype;
// the read mutex gets dropped and reacquired as part of waitForWork()
// The destructor of this sentry wakes up other clients
::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid);
while(true) {
if(!this->sync_.getPending(fname, mtype, rseqid)) {
iprot_->readMessageBegin(fname, mtype, rseqid);
}
if(seqid == rseqid) {
if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
::apache::thrift::TApplicationException x;
x.read(iprot_);
iprot_->readMessageEnd();
iprot_->getTransport()->readEnd();
sentry.commit();
throw x;
}
if (mtype != ::apache::thrift::protocol::T_REPLY) {
iprot_->skip(::apache::thrift::protocol::T_STRUCT);
iprot_->readMessageEnd();
iprot_->getTransport()->readEnd();
}
if (fname.compare("solveCVRPTW") != 0) {
iprot_->skip(::apache::thrift::protocol::T_STRUCT);
iprot_->readMessageEnd();
iprot_->getTransport()->readEnd();
// in a bad state, don't commit
using ::apache::thrift::protocol::TProtocolException;
throw TProtocolException(TProtocolException::INVALID_DATA);
}
CVRPTW_solveCVRPTW_presult result;
result.success = &_return;
result.read(iprot_);
iprot_->readMessageEnd();
iprot_->getTransport()->readEnd();
if (result.__isset.success) {
// _return pointer has now been filled
sentry.commit();
return;
}
// in a bad state, don't commit
throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "solveCVRPTW failed: unknown result");
}
// seqid != rseqid
this->sync_.updatePending(fname, mtype, rseqid);
// this will temporarily unlock the readMutex, and let other clients get work done
this->sync_.waitForWork(seqid);
} // end while(true)
}
| [
"avan87.vz@gmail.com"
] | avan87.vz@gmail.com |
973058f4b4d5fc6fd905cbe374c419ffe4d52a51 | a12e129adc058d844cb4a5b9b3cfc27f2be95ba5 | /template.cpp | 91befc98bd82fb03156eba5653892fc8aad4775a | [] | no_license | vishukamble/CPlusPlusPractice | 7b73ab5966a847bc2e7df41e83ddefa548c5dad5 | 588c192df98d17ae378a807bba65064685a470e1 | refs/heads/master | 2021-01-10T01:27:22.149071 | 2016-03-10T01:40:35 | 2016-03-10T01:40:35 | 48,306,228 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,088 | cpp | /*
Author: Vishwanath Kamble
Practice Session C++ Programs
Website: www.geekstarts.info , www.vishukamble.info
Date: 12/20/2015
Program: Template function
Desc: A simple template calss
*/
#include <iostream>
using namespace std;
template <class Calculate>
Calculate doSomething(Calculate a, Calculate b, int option)
{
Calculate ans;
switch(option)
{
case 1: ans = a+b;
break;
case 2: ans = a-b;
break;
case 3: ans = a*b;
break;
case 4: ans = a/b;
break;
}
return ans;
}
int main()
{
int num1, num2, opt;
double x,y;
cout<<"Enter two integers: ";
cin>>num1>>num2;
cout<<"What do you want to do?\n1. Add\t2. Subtract\t3. Multiple \t4. Divide"<<endl;
cin>>opt;
int ans = doSomething(num1, num2, opt);
cout<<endl<<ans<<endl;
opt = 0;
cout<<"Enter two double: ";
cin>>x>>y;
cout<<"What do you want to do?\n1. Add\t2. Subtract\t3. Multiple \t4. Divide"<<endl;
cin>>opt;
double tem = doSomething(x, y, opt);
cout<<endl<<tem<<endl;
return 0;
}
| [
"vishu.mb@gmail.com"
] | vishu.mb@gmail.com |
c92f4216aed6de05f1d068755a316f08b18159bc | d0c44dd3da2ef8c0ff835982a437946cbf4d2940 | /cmake-build-debug/programs_tiling/function14452/function14452_schedule_10/function14452_schedule_10.cpp | 77d8a8aebc95af900f38b2ad170197ca200e23af | [] | no_license | IsraMekki/tiramisu_code_generator | 8b3f1d63cff62ba9f5242c019058d5a3119184a3 | 5a259d8e244af452e5301126683fa4320c2047a3 | refs/heads/master | 2020-04-29T17:27:57.987172 | 2019-04-23T16:50:32 | 2019-04-23T16:50:32 | 176,297,755 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,205 | cpp | #include <tiramisu/tiramisu.h>
using namespace tiramisu;
int main(int argc, char **argv){
tiramisu::init("function14452_schedule_10");
constant c0("c0", 128), c1("c1", 64), c2("c2", 64), c3("c3", 64);
var i0("i0", 0, c0), i1("i1", 0, c1), i2("i2", 0, c2), i3("i3", 0, c3), i01("i01"), i02("i02"), i03("i03"), i04("i04");
input input00("input00", {i0, i3}, p_int32);
input input01("input01", {i1, i3}, p_int32);
input input02("input02", {i0, i3, i2}, p_int32);
computation comp0("comp0", {i0, i1, i2, i3}, input00(i0, i3) * input01(i1, i3) * input02(i0, i3, i2));
comp0.tile(i1, i2, 64, 64, i01, i02, i03, i04);
comp0.parallelize(i0);
buffer buf00("buf00", {128, 64}, p_int32, a_input);
buffer buf01("buf01", {64, 64}, p_int32, a_input);
buffer buf02("buf02", {128, 64, 64}, p_int32, a_input);
buffer buf0("buf0", {128, 64, 64, 64}, p_int32, a_output);
input00.store_in(&buf00);
input01.store_in(&buf01);
input02.store_in(&buf02);
comp0.store_in(&buf0);
tiramisu::codegen({&buf00, &buf01, &buf02, &buf0}, "../data/programs/function14452/function14452_schedule_10/function14452_schedule_10.o");
return 0;
} | [
"ei_mekki@esi.dz"
] | ei_mekki@esi.dz |
68d60c2b19f8d93f7ac973930b976da2be073e07 | 09bbbbca189b65d85fd6e189dad5541c73d37143 | /lib/geometry/objects/_segment.hpp | a18038083709f4e08e428b9b9a275919eec6d555 | [] | no_license | hyperpower/carpios | 44bdfba95776be17ee6b4c19cf0e8d86d88440d1 | 07369bea131ab72b7bc85ee7aa259aa77358b3f1 | refs/heads/master | 2020-09-09T09:42:16.461489 | 2017-11-01T09:41:25 | 2017-11-01T09:41:25 | 94,442,716 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,653 | hpp | #ifndef _SEGMENT_HPP_
#define _SEGMENT_HPP_
#include "../geometry_define.hpp"
#include "_point.hpp"
#include <array>
#include <type_traits>
#include <typeinfo>
#include "math.h"
namespace carpio {
struct TagSegment: public TagGeometry {
TagSegment() {
}
;
};
template<typename TYPE, St DIM>
class Segment_: public std::array< Point_<TYPE, DIM>, 2> {
public:
static const St Dim = DIM;
typedef TagSegment Tag;
typedef TYPE Vt;
typedef Vt& ref_Vt;
typedef const Vt& const_ref_Vt;
typedef Segment_<TYPE, DIM> Self;
typedef Segment_<TYPE, DIM>& ref_Self;
typedef const Segment_<TYPE, DIM>& const_ref_Self;
typedef Point_<TYPE, DIM> Point;
typedef Point* pPoint;
typedef Point& ref_Point;
typedef const Point& const_ref_Point;
typedef Box_<Vt, Dim> Box;
typedef Operation_<Vt, Dim> Op;
public:
Segment_() :
std::array<Point, 2>() {
_set_empty();
}
Segment_(const Point& s, const Point& e) {
ASSERT(s != e);
this->ps() = s;
this->pe() = e;
}
Segment_(const Vt& ax, const Vt& bx, //
const Vt& ay, const Vt& by, //
const Vt& az = 0, const Vt& bz = 0) {
Point s(ax, ay, az);
Point e(bx, by, bz);
reconstruct(s, e);
}
Segment_(const_ref_Self rhs) {
this->ps() = rhs.ps();
this->pe() = rhs.pe();
}
void reconstruct(const_ref_Self rhs) {
this->ps() = rhs.ps();
this->pe() = rhs.pe();
}
void reconstruct(const Point& s, const Point& e) {
ASSERT(s != e);
this->ps() = s;
this->pe() = e;
}
void reconstruct(const Vt& ax, const Vt& bx, //
const Vt& ay, const Vt& by, //
const Vt& az = 0, const Vt& bz = 0) {
Point s(ax, ay, az);
Point e(bx, by, bz);
reconstruct(s, e);
}
bool operator==(const_ref_Self rhs) const {
return (this->ps() == rhs.ps() && this->pe() == rhs.pe()) ? true : false;
}
Point& ps() {
return this->at(0);
}
const Point& ps() const {
return this->at(0);
}
Point& pe() {
return this->at(1);
}
const Point& pe() const {
return this->at(1);
}
Point pc() const {
return Point((pex() + psx()) * 0.5, (pey() + psy()) * 0.5,
(Dim == 3) ? ((pez() + psz()) * 0.5) : 0);
}
const_ref_Vt psx() const {
return this->ps().x();
}
const_ref_Vt pex() const {
return this->pe().x();
}
const_ref_Vt psy() const {
ASSERT(Dim >= 2);
return this->ps().y();
}
const_ref_Vt pey() const {
ASSERT(Dim >= 2);
return this->pe().y();
}
const_ref_Vt psz() const {
ASSERT(Dim >= 3);
return this->ps().z();
}
const_ref_Vt pez() const {
ASSERT(Dim >= 3);
return this->pe().z();
}
ref_Vt psx() {
return this->ps().x();
}
ref_Vt pex() {
return this->pe().x();
}
ref_Vt psy() {
ASSERT(Dim >= 2);
return this->ps().y();
}
ref_Vt pey() {
ASSERT(Dim >= 2);
return this->pe().y();
}
ref_Vt psz() {
ASSERT(Dim >= 3);
return this->ps().z();
}
ref_Vt pez() {
ASSERT(Dim >= 3);
return this->pe().z();
}
Vt dx() const {
return pex() - psx();
}
Vt dy() const {
return pey() - psy();
}
Vt dz() const {
return pez() - psz();
}
Vt length() const {
Vt len = 0.0;
len = sqrt(
double(
(psx() - pex()) * (psx() - pex())
+ (psy() - pey()) * (psy() - pey())));
return len;
}
Vt slope() const {
ASSERT(Dim == 2);
return (pey() - psy()) / (pex() - psx() + SMALL);
}
Box box() const {
Point min = Op::Min(ps(), pe());
Point max = Op::Max(ps(), pe());
return Box(min, max);
}
void scale(Vt xfactor, Vt yfactor, Vt zfactor = 1) {
this->ps().x() = psx() * xfactor;
this->ps().y() = psy() * yfactor;
if (Dim == 3) {
psz() = psz() * zfactor;
}
pex() = pex() * xfactor;
pey() = pey() * yfactor;
if (Dim == 3) {
pez() = pez() * zfactor;
}
if (pe() == ps()) {
_set_empty();
}
}
void transfer(Vt dx, Vt dy, Vt dz = 0.0) {
if (!empty()) {
psx() = psx() + dx;
psy() = psy() + dy;
pex() = pex() + dx;
pey() = pey() + dy;
}
if (Dim == 3) {
psz() = psz() + dz;
pez() = pez() + dz;
}
}
/** Set the beginning point */
void set_s(const Point& p) {
this->ps() = p;
}
/** Set the end point */
void set_e(const Point& p) {
this->pe() = p;
}
/** Change the segment orientation */
Self& change_orientation() {
Point tmp = this->ps();
this->ps() = this->pe();
this->pe() = tmp;
return *this;
}
bool empty() const {
if (psx() == 0.0 && psy() == 0.0 && pex() == 0.0 && pey() == 0.0
&& ((Dim == 3) ? (psz() == 0.0 && pez() == 0.0) : true)) {
return true;
} else {
return false;
}
}
void show() const {
std::cout.precision(4);
std::cout << "(" << psx() << ", " << psy();
if (Dim == 3) {
std::cout << ", " << psz();
} else {
std::cout << "";
}
std::cout << ")-->(" << this->pex() << ", " << pey();
if (Dim == 3) {
std::cout << ", " << pez();
} else {
std::cout << "";
}
std::cout << ")\n";
}
/*
* compare
*/
bool is_gt_x(const Vt& v) const { //>
return (this->pex() > v && this->psx() > v);
}
bool is_gt_y(const Vt& v) const { //>
return (this->pey() > v && this->psy() > v);
}
bool is_ge_x(const Vt& v) const { //>=
return (this->pex() >= v && this->psx() >= v);
}
bool is_ge_y(const Vt& v) const { //>=
return (this->pey() >= v && this->psy() >= v);
}
bool is_lt_x(const Vt& v) const { //<
return (this->pex() < v && this->psx() < v);
}
bool is_lt_y(const Vt& v) const { //<
return (this->pey() < v && this->psy() < v);
}
bool is_lt_z(const Vt& v) const { //<
ASSERT(Dim == 3);
return (this->pez() < v && this->psz() < v);
}
bool is_le_x(const Vt& v) const { //<=
return (this->pex() <= v && this->psx() <= v);
}
bool is_le_y(const Vt& v) const { //<=
return (this->pey() <= v && this->psy() <= v);
}
bool is_vertical() const {
ASSERT(!empty());
return psx() == pex();
}
bool is_horizontal() const {
ASSERT(!empty());
return psy() == pey();
}
bool is_in_box(const Point& pt) const {
ASSERT(!empty());
if (is_horizontal()) {
return (((psx() <= pt.x) && (pt.x <= pex()))
|| ((pex() <= pt.x) && (pt.x <= psx())));
}
if (is_vertical()) {
return (((psy() <= pt.y) && (pt.y <= pey()))
|| ((pey() <= pt.y) && (pt.y <= psy())));
}
return (((psx() <= pt.x) && (pt.x <= pex()))
|| ((pex() <= pt.x) && (pt.x <= psx())))
&& (((psy() <= pt.y) && (pt.y <= pey()))
|| ((pey() <= pt.y) && (pt.y <= psy())));
}
protected:
void _set_empty() {
ps().x() = 0.0;
pe().x() = 0.0;
ps().y() = 0.0;
pe().y() = 0.0;
if (Dim == 3) {
ps().z() = 0.0;
pe().z() = 0.0;
}
}
};
template<typename TYPE, St DIM>
inline std::ostream& operator<<(std::ostream& o, const Segment_<TYPE, DIM>& p) {
return o << p.ps() << "-->" << p.pe();
}
}
#endif
| [
"hyper__power@hotmail.com"
] | hyper__power@hotmail.com |
7aeb43c489095a2e7262a8a8e0b57b33172c327a | 1d928c3f90d4a0a9a3919a804597aa0a4aab19a3 | /c++/cm-compiler/2015/8/Targets.cpp | 2764b2ce7755d40c2d23f9cf526adfc987e96469 | [] | no_license | rosoareslv/SED99 | d8b2ff5811e7f0ffc59be066a5a0349a92cbb845 | a062c118f12b93172e31e8ca115ce3f871b64461 | refs/heads/main | 2023-02-22T21:59:02.703005 | 2021-01-28T19:40:51 | 2021-01-28T19:40:51 | 306,497,459 | 1 | 1 | null | 2020-11-24T20:56:18 | 2020-10-23T01:18:07 | null | UTF-8 | C++ | false | false | 245,088 | cpp | //===--- Targets.cpp - Implement target feature support -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements construction of a TargetInfo object from a
// target triple.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/MacroBuilder.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetOptions.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/TargetParser.h"
#include <algorithm>
#include <memory>
using namespace clang;
//===----------------------------------------------------------------------===//
// Common code shared among targets.
//===----------------------------------------------------------------------===//
/// DefineStd - Define a macro name and standard variants. For example if
/// MacroName is "unix", then this will define "__unix", "__unix__", and "unix"
/// when in GNU mode.
static void DefineStd(MacroBuilder &Builder, StringRef MacroName,
const LangOptions &Opts) {
assert(MacroName[0] != '_' && "Identifier should be in the user's namespace");
// If in GNU mode (e.g. -std=gnu99 but not -std=c99) define the raw identifier
// in the user's namespace.
if (Opts.GNUMode)
Builder.defineMacro(MacroName);
// Define __unix.
Builder.defineMacro("__" + MacroName);
// Define __unix__.
Builder.defineMacro("__" + MacroName + "__");
}
static void defineCPUMacros(MacroBuilder &Builder, StringRef CPUName,
bool Tuning = true) {
Builder.defineMacro("__" + CPUName);
Builder.defineMacro("__" + CPUName + "__");
if (Tuning)
Builder.defineMacro("__tune_" + CPUName + "__");
}
//===----------------------------------------------------------------------===//
// Defines specific to certain operating systems.
//===----------------------------------------------------------------------===//
namespace {
template<typename TgtInfo>
class OSTargetInfo : public TgtInfo {
protected:
virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const=0;
public:
OSTargetInfo(const llvm::Triple &Triple) : TgtInfo(Triple) {}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
TgtInfo::getTargetDefines(Opts, Builder);
getOSDefines(Opts, TgtInfo::getTriple(), Builder);
}
};
} // end anonymous namespace
static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
const llvm::Triple &Triple,
StringRef &PlatformName,
VersionTuple &PlatformMinVersion) {
Builder.defineMacro("__APPLE_CC__", "6000");
Builder.defineMacro("__APPLE__");
Builder.defineMacro("OBJC_NEW_PROPERTIES");
// AddressSanitizer doesn't play well with source fortification, which is on
// by default on Darwin.
if (Opts.Sanitize.has(SanitizerKind::Address))
Builder.defineMacro("_FORTIFY_SOURCE", "0");
if (!Opts.ObjCAutoRefCount) {
// __weak is always defined, for use in blocks and with objc pointers.
Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))");
// Darwin defines __strong even in C mode (just to nothing).
if (Opts.getGC() != LangOptions::NonGC)
Builder.defineMacro("__strong", "__attribute__((objc_gc(strong)))");
else
Builder.defineMacro("__strong", "");
// __unsafe_unretained is defined to nothing in non-ARC mode. We even
// allow this in C, since one might have block pointers in structs that
// are used in pure C code and in Objective-C ARC.
Builder.defineMacro("__unsafe_unretained", "");
}
if (Opts.Static)
Builder.defineMacro("__STATIC__");
else
Builder.defineMacro("__DYNAMIC__");
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
// Get the platform type and version number from the triple.
unsigned Maj, Min, Rev;
if (Triple.isMacOSX()) {
Triple.getMacOSXVersion(Maj, Min, Rev);
PlatformName = "macosx";
} else {
Triple.getOSVersion(Maj, Min, Rev);
PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());
}
// If -target arch-pc-win32-macho option specified, we're
// generating code for Win32 ABI. No need to emit
// __ENVIRONMENT_XX_OS_VERSION_MIN_REQUIRED__.
if (PlatformName == "win32") {
PlatformMinVersion = VersionTuple(Maj, Min, Rev);
return;
}
// Set the appropriate OS version define.
if (Triple.isiOS()) {
assert(Maj < 10 && Min < 100 && Rev < 100 && "Invalid version!");
char Str[6];
Str[0] = '0' + Maj;
Str[1] = '0' + (Min / 10);
Str[2] = '0' + (Min % 10);
Str[3] = '0' + (Rev / 10);
Str[4] = '0' + (Rev % 10);
Str[5] = '\0';
Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__",
Str);
} else if (Triple.isMacOSX()) {
// Note that the Driver allows versions which aren't representable in the
// define (because we only get a single digit for the minor and micro
// revision numbers). So, we limit them to the maximum representable
// version.
assert(Maj < 100 && Min < 100 && Rev < 100 && "Invalid version!");
char Str[7];
if (Maj < 10 || (Maj == 10 && Min < 10)) {
Str[0] = '0' + (Maj / 10);
Str[1] = '0' + (Maj % 10);
Str[2] = '0' + std::min(Min, 9U);
Str[3] = '0' + std::min(Rev, 9U);
Str[4] = '\0';
} else {
// Handle versions > 10.9.
Str[0] = '0' + (Maj / 10);
Str[1] = '0' + (Maj % 10);
Str[2] = '0' + (Min / 10);
Str[3] = '0' + (Min % 10);
Str[4] = '0' + (Rev / 10);
Str[5] = '0' + (Rev % 10);
Str[6] = '\0';
}
Builder.defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", Str);
}
// Tell users about the kernel if there is one.
if (Triple.isOSDarwin())
Builder.defineMacro("__MACH__");
PlatformMinVersion = VersionTuple(Maj, Min, Rev);
}
namespace {
// CloudABI Target
template <typename Target>
class CloudABITargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
Builder.defineMacro("__CloudABI__");
Builder.defineMacro("__ELF__");
// CloudABI uses ISO/IEC 10646:2012 for wchar_t, char16_t and char32_t.
Builder.defineMacro("__STDC_ISO_10646__", "201206L");
Builder.defineMacro("__STDC_UTF_16__");
Builder.defineMacro("__STDC_UTF_32__");
}
public:
CloudABITargetInfo(const llvm::Triple &Triple)
: OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
}
};
template<typename Target>
class DarwinTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
getDarwinDefines(Builder, Opts, Triple, this->PlatformName,
this->PlatformMinVersion);
}
public:
DarwinTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->TLSSupported = Triple.isMacOSX() && !Triple.isMacOSXVersionLT(10, 7);
this->MCountName = "\01mcount";
}
std::string isValidSectionSpecifier(StringRef SR) const override {
// Let MCSectionMachO validate this.
StringRef Segment, Section;
unsigned TAA, StubSize;
bool HasTAA;
return llvm::MCSectionMachO::ParseSectionSpecifier(SR, Segment, Section,
TAA, HasTAA, StubSize);
}
const char *getStaticInitSectionSpecifier() const override {
// FIXME: We should return 0 when building kexts.
return "__TEXT,__StaticInit,regular,pure_instructions";
}
/// Darwin does not support protected visibility. Darwin's "default"
/// is very similar to ELF's "protected"; Darwin requires a "weak"
/// attribute on declarations that can be dynamically replaced.
bool hasProtectedVisibility() const override {
return false;
}
};
// DragonFlyBSD Target
template<typename Target>
class DragonFlyBSDTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// DragonFly defines; list based off of gcc output
Builder.defineMacro("__DragonFly__");
Builder.defineMacro("__DragonFly_cc_version", "100001");
Builder.defineMacro("__ELF__");
Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
Builder.defineMacro("__tune_i386__");
DefineStd(Builder, "unix", Opts);
}
public:
DragonFlyBSDTargetInfo(const llvm::Triple &Triple)
: OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
switch (Triple.getArch()) {
default:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
this->MCountName = ".mcount";
break;
}
}
};
// FreeBSD Target
template<typename Target>
class FreeBSDTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// FreeBSD defines; list based off of gcc output
unsigned Release = Triple.getOSMajorVersion();
if (Release == 0U)
Release = 8;
Builder.defineMacro("__FreeBSD__", Twine(Release));
Builder.defineMacro("__FreeBSD_cc_version", Twine(Release * 100000U + 1U));
Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__ELF__");
// On FreeBSD, wchar_t contains the number of the code point as
// used by the character set of the locale. These character sets are
// not necessarily a superset of ASCII.
//
// FIXME: This is wrong; the macro refers to the numerical values
// of wchar_t *literals*, which are not locale-dependent. However,
// FreeBSD systems apparently depend on us getting this wrong, and
// setting this to 1 is conforming even if all the basic source
// character literals have the same encoding as char and wchar_t.
Builder.defineMacro("__STDC_MB_MIGHT_NEQ_WC__", "1");
}
public:
FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
switch (Triple.getArch()) {
default:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
this->MCountName = ".mcount";
break;
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
this->MCountName = "_mcount";
break;
case llvm::Triple::arm:
this->MCountName = "__mcount";
break;
}
}
};
// GNU/kFreeBSD Target
template<typename Target>
class KFreeBSDTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// GNU/kFreeBSD defines; list based off of gcc output
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__FreeBSD_kernel__");
Builder.defineMacro("__GLIBC__");
Builder.defineMacro("__ELF__");
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
}
public:
KFreeBSDTargetInfo(const llvm::Triple &Triple)
: OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
}
};
// Minix Target
template<typename Target>
class MinixTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// Minix defines
Builder.defineMacro("__minix", "3");
Builder.defineMacro("_EM_WSIZE", "4");
Builder.defineMacro("_EM_PSIZE", "4");
Builder.defineMacro("_EM_SSIZE", "2");
Builder.defineMacro("_EM_LSIZE", "4");
Builder.defineMacro("_EM_FSIZE", "4");
Builder.defineMacro("_EM_DSIZE", "8");
Builder.defineMacro("__ELF__");
DefineStd(Builder, "unix", Opts);
}
public:
MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
}
};
// Linux target
template<typename Target>
class LinuxTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// Linux defines; list based off of gcc output
DefineStd(Builder, "unix", Opts);
DefineStd(Builder, "linux", Opts);
Builder.defineMacro("__gnu_linux__");
Builder.defineMacro("__ELF__");
if (Triple.getEnvironment() == llvm::Triple::Android) {
Builder.defineMacro("__ANDROID__", "1");
unsigned Maj, Min, Rev;
Triple.getEnvironmentVersion(Maj, Min, Rev);
this->PlatformName = "android";
this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
}
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
}
public:
LinuxTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
this->WIntType = TargetInfo::UnsignedInt;
switch (Triple.getArch()) {
default:
break;
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
this->MCountName = "_mcount";
break;
}
}
const char *getStaticInitSectionSpecifier() const override {
return ".text.startup";
}
};
// NetBSD Target
template<typename Target>
class NetBSDTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// NetBSD defines; list based off of gcc output
Builder.defineMacro("__NetBSD__");
Builder.defineMacro("__unix__");
Builder.defineMacro("__ELF__");
if (Opts.POSIXThreads)
Builder.defineMacro("_POSIX_THREADS");
switch (Triple.getArch()) {
default:
break;
case llvm::Triple::arm:
case llvm::Triple::armeb:
case llvm::Triple::thumb:
case llvm::Triple::thumbeb:
Builder.defineMacro("__ARM_DWARF_EH__");
break;
}
}
public:
NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
this->MCountName = "_mcount";
}
};
// OpenBSD Target
template<typename Target>
class OpenBSDTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// OpenBSD defines; list based off of gcc output
Builder.defineMacro("__OpenBSD__");
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__ELF__");
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
}
public:
OpenBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
this->TLSSupported = false;
switch (Triple.getArch()) {
default:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
case llvm::Triple::arm:
case llvm::Triple::sparc:
this->MCountName = "__mcount";
break;
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
case llvm::Triple::ppc:
case llvm::Triple::sparcv9:
this->MCountName = "_mcount";
break;
}
}
};
// Bitrig Target
template<typename Target>
class BitrigTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// Bitrig defines; list based off of gcc output
Builder.defineMacro("__Bitrig__");
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__ELF__");
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
switch (Triple.getArch()) {
default:
break;
case llvm::Triple::arm:
case llvm::Triple::armeb:
case llvm::Triple::thumb:
case llvm::Triple::thumbeb:
Builder.defineMacro("__ARM_DWARF_EH__");
break;
}
}
public:
BitrigTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
this->MCountName = "__mcount";
}
};
// PSP Target
template<typename Target>
class PSPTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// PSP defines; list based on the output of the pspdev gcc toolchain.
Builder.defineMacro("PSP");
Builder.defineMacro("_PSP");
Builder.defineMacro("__psp__");
Builder.defineMacro("__ELF__");
}
public:
PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
}
};
// PS3 PPU Target
template<typename Target>
class PS3PPUTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// PS3 PPU defines.
Builder.defineMacro("__PPC__");
Builder.defineMacro("__PPU__");
Builder.defineMacro("__CELLOS_LV2__");
Builder.defineMacro("__ELF__");
Builder.defineMacro("__LP32__");
Builder.defineMacro("_ARCH_PPC64");
Builder.defineMacro("__powerpc64__");
}
public:
PS3PPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
this->LongWidth = this->LongAlign = 32;
this->PointerWidth = this->PointerAlign = 32;
this->IntMaxType = TargetInfo::SignedLongLong;
this->Int64Type = TargetInfo::SignedLongLong;
this->SizeType = TargetInfo::UnsignedInt;
this->DataLayoutString = "E-m:e-p:32:32-i64:64-n32:64";
}
};
template <typename Target>
class PS4OSTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
Builder.defineMacro("__FreeBSD__", "9");
Builder.defineMacro("__FreeBSD_cc_version", "900001");
Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__ELF__");
Builder.defineMacro("__PS4__");
}
public:
PS4OSTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->WCharType = this->UnsignedShort;
// On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
this->MaxTLSAlign = 256;
this->UserLabelPrefix = "";
switch (Triple.getArch()) {
default:
case llvm::Triple::x86_64:
this->MCountName = ".mcount";
break;
}
}
};
// Solaris target
template<typename Target>
class SolarisTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
DefineStd(Builder, "sun", Opts);
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__ELF__");
Builder.defineMacro("__svr4__");
Builder.defineMacro("__SVR4");
// Solaris headers require _XOPEN_SOURCE to be set to 600 for C99 and
// newer, but to 500 for everything else. feature_test.h has a check to
// ensure that you are not using C99 with an old version of X/Open or C89
// with a new version.
if (Opts.C99)
Builder.defineMacro("_XOPEN_SOURCE", "600");
else
Builder.defineMacro("_XOPEN_SOURCE", "500");
if (Opts.CPlusPlus)
Builder.defineMacro("__C99FEATURES__");
Builder.defineMacro("_LARGEFILE_SOURCE");
Builder.defineMacro("_LARGEFILE64_SOURCE");
Builder.defineMacro("__EXTENSIONS__");
Builder.defineMacro("_REENTRANT");
}
public:
SolarisTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
this->WCharType = this->SignedInt;
// FIXME: WIntType should be SignedLong
}
};
// Windows target
template<typename Target>
class WindowsTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
Builder.defineMacro("_WIN32");
}
void getVisualStudioDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
if (Opts.CPlusPlus) {
if (Opts.RTTIData)
Builder.defineMacro("_CPPRTTI");
if (Opts.CXXExceptions)
Builder.defineMacro("_CPPUNWIND");
}
if (Opts.Bool)
Builder.defineMacro("__BOOL_DEFINED");
if (!Opts.CharIsSigned)
Builder.defineMacro("_CHAR_UNSIGNED");
// FIXME: POSIXThreads isn't exactly the option this should be defined for,
// but it works for now.
if (Opts.POSIXThreads)
Builder.defineMacro("_MT");
if (Opts.MSCompatibilityVersion) {
Builder.defineMacro("_MSC_VER",
Twine(Opts.MSCompatibilityVersion / 100000));
Builder.defineMacro("_MSC_FULL_VER", Twine(Opts.MSCompatibilityVersion));
// FIXME We cannot encode the revision information into 32-bits
Builder.defineMacro("_MSC_BUILD", Twine(1));
if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(LangOptions::MSVC2015))
Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1));
}
if (Opts.MicrosoftExt) {
Builder.defineMacro("_MSC_EXTENSIONS");
if (Opts.CPlusPlus11) {
Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
}
}
Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
}
public:
WindowsTargetInfo(const llvm::Triple &Triple)
: OSTargetInfo<Target>(Triple) {}
};
template <typename Target>
class NaClTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__ELF__");
Builder.defineMacro("__native_client__");
}
public:
NaClTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
this->LongAlign = 32;
this->LongWidth = 32;
this->PointerAlign = 32;
this->PointerWidth = 32;
this->IntMaxType = TargetInfo::SignedLongLong;
this->Int64Type = TargetInfo::SignedLongLong;
this->DoubleAlign = 64;
this->LongDoubleWidth = 64;
this->LongDoubleAlign = 64;
this->LongLongWidth = 64;
this->LongLongAlign = 64;
this->SizeType = TargetInfo::UnsignedInt;
this->PtrDiffType = TargetInfo::SignedInt;
this->IntPtrType = TargetInfo::SignedInt;
// RegParmMax is inherited from the underlying architecture
this->LongDoubleFormat = &llvm::APFloat::IEEEdouble;
if (Triple.getArch() == llvm::Triple::arm) {
// Handled in ARM's setABI().
} else if (Triple.getArch() == llvm::Triple::x86) {
this->DataLayoutString = "e-m:e-p:32:32-i64:64-n8:16:32-S128";
} else if (Triple.getArch() == llvm::Triple::x86_64) {
this->DataLayoutString = "e-m:e-p:32:32-i64:64-n8:16:32:64-S128";
} else if (Triple.getArch() == llvm::Triple::mipsel) {
// Handled on mips' setDataLayoutString.
} else {
assert(Triple.getArch() == llvm::Triple::le32);
this->DataLayoutString = "e-p:32:32-i64:64";
}
}
};
//===----------------------------------------------------------------------===//
// Specific target implementations.
//===----------------------------------------------------------------------===//
// PPC abstract base class
class PPCTargetInfo : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
static const char * const GCCRegNames[];
static const TargetInfo::GCCRegAlias GCCRegAliases[];
std::string CPU;
// Target cpu features.
bool HasVSX;
bool HasP8Vector;
bool HasP8Crypto;
bool HasDirectMove;
bool HasQPX;
bool HasHTM;
bool HasBPERMD;
bool HasExtDiv;
protected:
std::string ABI;
public:
PPCTargetInfo(const llvm::Triple &Triple)
: TargetInfo(Triple), HasVSX(false), HasP8Vector(false),
HasP8Crypto(false), HasDirectMove(false), HasQPX(false), HasHTM(false),
HasBPERMD(false), HasExtDiv(false) {
BigEndian = (Triple.getArch() != llvm::Triple::ppc64le);
SimdDefaultAlign = 128;
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
}
/// \brief Flags for architecture specific defines.
typedef enum {
ArchDefineNone = 0,
ArchDefineName = 1 << 0, // <name> is substituted for arch name.
ArchDefinePpcgr = 1 << 1,
ArchDefinePpcsq = 1 << 2,
ArchDefine440 = 1 << 3,
ArchDefine603 = 1 << 4,
ArchDefine604 = 1 << 5,
ArchDefinePwr4 = 1 << 6,
ArchDefinePwr5 = 1 << 7,
ArchDefinePwr5x = 1 << 8,
ArchDefinePwr6 = 1 << 9,
ArchDefinePwr6x = 1 << 10,
ArchDefinePwr7 = 1 << 11,
ArchDefinePwr8 = 1 << 12,
ArchDefineA2 = 1 << 13,
ArchDefineA2q = 1 << 14
} ArchDefineTypes;
// Note: GCC recognizes the following additional cpus:
// 401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
// 821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,
// titan, rs64.
bool setCPU(const std::string &Name) override {
bool CPUKnown = llvm::StringSwitch<bool>(Name)
.Case("generic", true)
.Case("440", true)
.Case("450", true)
.Case("601", true)
.Case("602", true)
.Case("603", true)
.Case("603e", true)
.Case("603ev", true)
.Case("604", true)
.Case("604e", true)
.Case("620", true)
.Case("630", true)
.Case("g3", true)
.Case("7400", true)
.Case("g4", true)
.Case("7450", true)
.Case("g4+", true)
.Case("750", true)
.Case("970", true)
.Case("g5", true)
.Case("a2", true)
.Case("a2q", true)
.Case("e500mc", true)
.Case("e5500", true)
.Case("power3", true)
.Case("pwr3", true)
.Case("power4", true)
.Case("pwr4", true)
.Case("power5", true)
.Case("pwr5", true)
.Case("power5x", true)
.Case("pwr5x", true)
.Case("power6", true)
.Case("pwr6", true)
.Case("power6x", true)
.Case("pwr6x", true)
.Case("power7", true)
.Case("pwr7", true)
.Case("power8", true)
.Case("pwr8", true)
.Case("powerpc", true)
.Case("ppc", true)
.Case("powerpc64", true)
.Case("ppc64", true)
.Case("powerpc64le", true)
.Case("ppc64le", true)
.Default(false);
if (CPUKnown)
CPU = Name;
return CPUKnown;
}
StringRef getABI() const override { return ABI; }
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::PPC::LastTSBuiltin-Builtin::FirstTSBuiltin;
}
bool isCLZForZeroUndef() const override { return false; }
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
StringRef CPU,
std::vector<std::string> &FeaturesVec) const override;
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override;
bool hasFeature(StringRef Feature) const override;
void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
bool Enabled) const override;
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
switch (*Name) {
default: return false;
case 'O': // Zero
break;
case 'b': // Base register
case 'f': // Floating point register
Info.setAllowsRegister();
break;
// FIXME: The following are added to allow parsing.
// I just took a guess at what the actions should be.
// Also, is more specific checking needed? I.e. specific registers?
case 'd': // Floating point register (containing 64-bit value)
case 'v': // Altivec vector register
Info.setAllowsRegister();
break;
case 'w':
switch (Name[1]) {
case 'd':// VSX vector register to hold vector double data
case 'f':// VSX vector register to hold vector float data
case 's':// VSX vector register to hold scalar float data
case 'a':// Any VSX register
case 'c':// An individual CR bit
break;
default:
return false;
}
Info.setAllowsRegister();
Name++; // Skip over 'w'.
break;
case 'h': // `MQ', `CTR', or `LINK' register
case 'q': // `MQ' register
case 'c': // `CTR' register
case 'l': // `LINK' register
case 'x': // `CR' register (condition register) number 0
case 'y': // `CR' register (condition register)
case 'z': // `XER[CA]' carry bit (part of the XER register)
Info.setAllowsRegister();
break;
case 'I': // Signed 16-bit constant
case 'J': // Unsigned 16-bit constant shifted left 16 bits
// (use `L' instead for SImode constants)
case 'K': // Unsigned 16-bit constant
case 'L': // Signed 16-bit constant shifted left 16 bits
case 'M': // Constant larger than 31
case 'N': // Exact power of 2
case 'P': // Constant whose negation is a signed 16-bit constant
case 'G': // Floating point constant that can be loaded into a
// register with one instruction per word
case 'H': // Integer/Floating point constant that can be loaded
// into a register using three instructions
break;
case 'm': // Memory operand. Note that on PowerPC targets, m can
// include addresses that update the base register. It
// is therefore only safe to use `m' in an asm statement
// if that asm statement accesses the operand exactly once.
// The asm statement must also use `%U<opno>' as a
// placeholder for the "update" flag in the corresponding
// load or store instruction. For example:
// asm ("st%U0 %1,%0" : "=m" (mem) : "r" (val));
// is correct but:
// asm ("st %1,%0" : "=m" (mem) : "r" (val));
// is not. Use es rather than m if you don't want the base
// register to be updated.
case 'e':
if (Name[1] != 's')
return false;
// es: A "stable" memory operand; that is, one which does not
// include any automodification of the base register. Unlike
// `m', this constraint can be used in asm statements that
// might access the operand several times, or that might not
// access it at all.
Info.setAllowsMemory();
Name++; // Skip over 'e'.
break;
case 'Q': // Memory operand that is an offset from a register (it is
// usually better to use `m' or `es' in asm statements)
case 'Z': // Memory operand that is an indexed or indirect from a
// register (it is usually better to use `m' or `es' in
// asm statements)
Info.setAllowsMemory();
Info.setAllowsRegister();
break;
case 'R': // AIX TOC entry
case 'a': // Address operand that is an indexed or indirect from a
// register (`p' is preferable for asm statements)
case 'S': // Constant suitable as a 64-bit mask operand
case 'T': // Constant suitable as a 32-bit mask operand
case 'U': // System V Release 4 small data area reference
case 't': // AND masks that can be performed by two rldic{l, r}
// instructions
case 'W': // Vector constant that does not require memory
case 'j': // Vector constant that is all zeros.
break;
// End FIXME.
}
return true;
}
std::string convertConstraint(const char *&Constraint) const override {
std::string R;
switch (*Constraint) {
case 'e':
case 'w':
// Two-character constraint; add "^" hint for later parsing.
R = std::string("^") + std::string(Constraint, 2);
Constraint++;
break;
default:
return TargetInfo::convertConstraint(Constraint);
}
return R;
}
const char *getClobbers() const override {
return "";
}
int getEHDataRegisterNumber(unsigned RegNo) const override {
if (RegNo == 0) return 3;
if (RegNo == 1) return 4;
return -1;
}
bool hasSjLjLowering() const override {
return true;
}
bool useFloat128ManglingForLongDouble() const override {
return LongDoubleWidth == 128 &&
LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble &&
getTriple().isOSBinFormatELF();
}
};
const Builtin::Info PPCTargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
{ #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsPPC.def"
};
/// handleTargetFeatures - Perform initialization based on the user
/// configured set of features.
bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) {
for (const auto &Feature : Features) {
if (Feature == "+vsx") {
HasVSX = true;
} else if (Feature == "+bpermd") {
HasBPERMD = true;
} else if (Feature == "+extdiv") {
HasExtDiv = true;
} else if (Feature == "+power8-vector") {
HasP8Vector = true;
} else if (Feature == "+crypto") {
HasP8Crypto = true;
} else if (Feature == "+direct-move") {
HasDirectMove = true;
} else if (Feature == "+qpx") {
HasQPX = true;
} else if (Feature == "+htm") {
HasHTM = true;
}
// TODO: Finish this list and add an assert that we've handled them
// all.
}
return true;
}
/// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific
/// #defines that are not tied to a specific subtarget.
void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
// Target identification.
Builder.defineMacro("__ppc__");
Builder.defineMacro("__PPC__");
Builder.defineMacro("_ARCH_PPC");
Builder.defineMacro("__powerpc__");
Builder.defineMacro("__POWERPC__");
if (PointerWidth == 64) {
Builder.defineMacro("_ARCH_PPC64");
Builder.defineMacro("__powerpc64__");
Builder.defineMacro("__ppc64__");
Builder.defineMacro("__PPC64__");
}
// Target properties.
if (getTriple().getArch() == llvm::Triple::ppc64le) {
Builder.defineMacro("_LITTLE_ENDIAN");
} else {
if (getTriple().getOS() != llvm::Triple::NetBSD &&
getTriple().getOS() != llvm::Triple::OpenBSD)
Builder.defineMacro("_BIG_ENDIAN");
}
// ABI options.
if (ABI == "elfv1" || ABI == "elfv1-qpx")
Builder.defineMacro("_CALL_ELF", "1");
if (ABI == "elfv2")
Builder.defineMacro("_CALL_ELF", "2");
// Subtarget options.
Builder.defineMacro("__NATURAL_ALIGNMENT__");
Builder.defineMacro("__REGISTER_PREFIX__", "");
// FIXME: Should be controlled by command line option.
if (LongDoubleWidth == 128)
Builder.defineMacro("__LONG_DOUBLE_128__");
if (Opts.AltiVec) {
Builder.defineMacro("__VEC__", "10206");
Builder.defineMacro("__ALTIVEC__");
}
// CPU identification.
ArchDefineTypes defs = (ArchDefineTypes)llvm::StringSwitch<int>(CPU)
.Case("440", ArchDefineName)
.Case("450", ArchDefineName | ArchDefine440)
.Case("601", ArchDefineName)
.Case("602", ArchDefineName | ArchDefinePpcgr)
.Case("603", ArchDefineName | ArchDefinePpcgr)
.Case("603e", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
.Case("603ev", ArchDefineName | ArchDefine603 | ArchDefinePpcgr)
.Case("604", ArchDefineName | ArchDefinePpcgr)
.Case("604e", ArchDefineName | ArchDefine604 | ArchDefinePpcgr)
.Case("620", ArchDefineName | ArchDefinePpcgr)
.Case("630", ArchDefineName | ArchDefinePpcgr)
.Case("7400", ArchDefineName | ArchDefinePpcgr)
.Case("7450", ArchDefineName | ArchDefinePpcgr)
.Case("750", ArchDefineName | ArchDefinePpcgr)
.Case("970", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr
| ArchDefinePpcsq)
.Case("a2", ArchDefineA2)
.Case("a2q", ArchDefineName | ArchDefineA2 | ArchDefineA2q)
.Case("pwr3", ArchDefinePpcgr)
.Case("pwr4", ArchDefineName | ArchDefinePpcgr | ArchDefinePpcsq)
.Case("pwr5", ArchDefineName | ArchDefinePwr4 | ArchDefinePpcgr
| ArchDefinePpcsq)
.Case("pwr5x", ArchDefineName | ArchDefinePwr5 | ArchDefinePwr4
| ArchDefinePpcgr | ArchDefinePpcsq)
.Case("pwr6", ArchDefineName | ArchDefinePwr5x | ArchDefinePwr5
| ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
.Case("pwr6x", ArchDefineName | ArchDefinePwr6 | ArchDefinePwr5x
| ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr
| ArchDefinePpcsq)
.Case("pwr7", ArchDefineName | ArchDefinePwr6x | ArchDefinePwr6
| ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4
| ArchDefinePpcgr | ArchDefinePpcsq)
.Case("pwr8", ArchDefineName | ArchDefinePwr7 | ArchDefinePwr6x
| ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5
| ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
.Case("power3", ArchDefinePpcgr)
.Case("power4", ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
.Case("power5", ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr
| ArchDefinePpcsq)
.Case("power5x", ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4
| ArchDefinePpcgr | ArchDefinePpcsq)
.Case("power6", ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5
| ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
.Case("power6x", ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x
| ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr
| ArchDefinePpcsq)
.Case("power7", ArchDefinePwr7 | ArchDefinePwr6x | ArchDefinePwr6
| ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4
| ArchDefinePpcgr | ArchDefinePpcsq)
.Case("power8", ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6x
| ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5
| ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
.Default(ArchDefineNone);
if (defs & ArchDefineName)
Builder.defineMacro(Twine("_ARCH_", StringRef(CPU).upper()));
if (defs & ArchDefinePpcgr)
Builder.defineMacro("_ARCH_PPCGR");
if (defs & ArchDefinePpcsq)
Builder.defineMacro("_ARCH_PPCSQ");
if (defs & ArchDefine440)
Builder.defineMacro("_ARCH_440");
if (defs & ArchDefine603)
Builder.defineMacro("_ARCH_603");
if (defs & ArchDefine604)
Builder.defineMacro("_ARCH_604");
if (defs & ArchDefinePwr4)
Builder.defineMacro("_ARCH_PWR4");
if (defs & ArchDefinePwr5)
Builder.defineMacro("_ARCH_PWR5");
if (defs & ArchDefinePwr5x)
Builder.defineMacro("_ARCH_PWR5X");
if (defs & ArchDefinePwr6)
Builder.defineMacro("_ARCH_PWR6");
if (defs & ArchDefinePwr6x)
Builder.defineMacro("_ARCH_PWR6X");
if (defs & ArchDefinePwr7)
Builder.defineMacro("_ARCH_PWR7");
if (defs & ArchDefinePwr8)
Builder.defineMacro("_ARCH_PWR8");
if (defs & ArchDefineA2)
Builder.defineMacro("_ARCH_A2");
if (defs & ArchDefineA2q) {
Builder.defineMacro("_ARCH_A2Q");
Builder.defineMacro("_ARCH_QP");
}
if (getTriple().getVendor() == llvm::Triple::BGQ) {
Builder.defineMacro("__bg__");
Builder.defineMacro("__THW_BLUEGENE__");
Builder.defineMacro("__bgq__");
Builder.defineMacro("__TOS_BGQ__");
}
if (HasVSX)
Builder.defineMacro("__VSX__");
if (HasP8Vector)
Builder.defineMacro("__POWER8_VECTOR__");
if (HasP8Crypto)
Builder.defineMacro("__CRYPTO__");
if (HasHTM)
Builder.defineMacro("__HTM__");
if (getTriple().getArch() == llvm::Triple::ppc64le ||
(defs & ArchDefinePwr8) || (CPU == "pwr8")) {
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
if (PointerWidth == 64)
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
}
// FIXME: The following are not yet generated here by Clang, but are
// generated by GCC:
//
// _SOFT_FLOAT_
// __RECIP_PRECISION__
// __APPLE_ALTIVEC__
// __RECIP__
// __RECIPF__
// __RSQRTE__
// __RSQRTEF__
// _SOFT_DOUBLE_
// __NO_LWSYNC__
// __HAVE_BSWAP__
// __LONGDOUBLE128
// __CMODEL_MEDIUM__
// __CMODEL_LARGE__
// _CALL_SYSV
// _CALL_DARWIN
// __NO_FPRS__
}
bool PPCTargetInfo::initFeatureMap(
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
std::vector<std::string> &FeaturesVec) const {
Features["altivec"] = llvm::StringSwitch<bool>(CPU)
.Case("7400", true)
.Case("g4", true)
.Case("7450", true)
.Case("g4+", true)
.Case("970", true)
.Case("g5", true)
.Case("pwr6", true)
.Case("pwr7", true)
.Case("pwr8", true)
.Case("ppc64", true)
.Case("ppc64le", true)
.Default(false);
Features["qpx"] = (CPU == "a2q");
Features["crypto"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr8", true)
.Default(false);
Features["power8-vector"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr8", true)
.Default(false);
Features["bpermd"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr8", true)
.Case("pwr7", true)
.Default(false);
Features["extdiv"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr8", true)
.Case("pwr7", true)
.Default(false);
Features["direct-move"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr8", true)
.Default(false);
Features["vsx"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr8", true)
.Case("pwr7", true)
.Default(false);
// Handle explicit options being passed to the compiler here: if we've
// explicitly turned off vsx and turned on power8-vector or direct-move then
// go ahead and error since the customer has expressed a somewhat incompatible
// set of options.
if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "-vsx") !=
FeaturesVec.end()) {
if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+power8-vector") !=
FeaturesVec.end()) {
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector"
<< "-mno-vsx";
return false;
}
if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+direct-move") !=
FeaturesVec.end()) {
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move"
<< "-mno-vsx";
return false;
}
}
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
bool PPCTargetInfo::hasFeature(StringRef Feature) const {
return llvm::StringSwitch<bool>(Feature)
.Case("powerpc", true)
.Case("vsx", HasVSX)
.Case("power8-vector", HasP8Vector)
.Case("crypto", HasP8Crypto)
.Case("direct-move", HasDirectMove)
.Case("qpx", HasQPX)
.Case("htm", HasHTM)
.Case("bpermd", HasBPERMD)
.Case("extdiv", HasExtDiv)
.Default(false);
}
void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
StringRef Name, bool Enabled) const {
// If we're enabling direct-move or power8-vector go ahead and enable vsx
// as well. Do the inverse if we're disabling vsx. We'll diagnose any user
// incompatible options.
if (Enabled) {
if (Name == "vsx") {
Features[Name] = true;
} else if (Name == "direct-move") {
Features[Name] = Features["vsx"] = true;
} else if (Name == "power8-vector") {
Features[Name] = Features["vsx"] = true;
} else {
Features[Name] = true;
}
} else {
if (Name == "vsx") {
Features[Name] = Features["direct-move"] = Features["power8-vector"] =
false;
} else {
Features[Name] = false;
}
}
}
const char * const PPCTargetInfo::GCCRegNames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
"mq", "lr", "ctr", "ap",
"cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
"xer",
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
"v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
"v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
"v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
"vrsave", "vscr",
"spe_acc", "spefscr",
"sfp"
};
void PPCTargetInfo::getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
const TargetInfo::GCCRegAlias PPCTargetInfo::GCCRegAliases[] = {
// While some of these aliases do map to different registers
// they still share the same register name.
{ { "0" }, "r0" },
{ { "1"}, "r1" },
{ { "2" }, "r2" },
{ { "3" }, "r3" },
{ { "4" }, "r4" },
{ { "5" }, "r5" },
{ { "6" }, "r6" },
{ { "7" }, "r7" },
{ { "8" }, "r8" },
{ { "9" }, "r9" },
{ { "10" }, "r10" },
{ { "11" }, "r11" },
{ { "12" }, "r12" },
{ { "13" }, "r13" },
{ { "14" }, "r14" },
{ { "15" }, "r15" },
{ { "16" }, "r16" },
{ { "17" }, "r17" },
{ { "18" }, "r18" },
{ { "19" }, "r19" },
{ { "20" }, "r20" },
{ { "21" }, "r21" },
{ { "22" }, "r22" },
{ { "23" }, "r23" },
{ { "24" }, "r24" },
{ { "25" }, "r25" },
{ { "26" }, "r26" },
{ { "27" }, "r27" },
{ { "28" }, "r28" },
{ { "29" }, "r29" },
{ { "30" }, "r30" },
{ { "31" }, "r31" },
{ { "fr0" }, "f0" },
{ { "fr1" }, "f1" },
{ { "fr2" }, "f2" },
{ { "fr3" }, "f3" },
{ { "fr4" }, "f4" },
{ { "fr5" }, "f5" },
{ { "fr6" }, "f6" },
{ { "fr7" }, "f7" },
{ { "fr8" }, "f8" },
{ { "fr9" }, "f9" },
{ { "fr10" }, "f10" },
{ { "fr11" }, "f11" },
{ { "fr12" }, "f12" },
{ { "fr13" }, "f13" },
{ { "fr14" }, "f14" },
{ { "fr15" }, "f15" },
{ { "fr16" }, "f16" },
{ { "fr17" }, "f17" },
{ { "fr18" }, "f18" },
{ { "fr19" }, "f19" },
{ { "fr20" }, "f20" },
{ { "fr21" }, "f21" },
{ { "fr22" }, "f22" },
{ { "fr23" }, "f23" },
{ { "fr24" }, "f24" },
{ { "fr25" }, "f25" },
{ { "fr26" }, "f26" },
{ { "fr27" }, "f27" },
{ { "fr28" }, "f28" },
{ { "fr29" }, "f29" },
{ { "fr30" }, "f30" },
{ { "fr31" }, "f31" },
{ { "cc" }, "cr0" },
};
void PPCTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const {
Aliases = GCCRegAliases;
NumAliases = llvm::array_lengthof(GCCRegAliases);
}
class PPC32TargetInfo : public PPCTargetInfo {
public:
PPC32TargetInfo(const llvm::Triple &Triple) : PPCTargetInfo(Triple) {
DataLayoutString = "E-m:e-p:32:32-i64:64-n32";
switch (getTriple().getOS()) {
case llvm::Triple::Linux:
case llvm::Triple::FreeBSD:
case llvm::Triple::NetBSD:
SizeType = UnsignedInt;
PtrDiffType = SignedInt;
IntPtrType = SignedInt;
break;
default:
break;
}
if (getTriple().getOS() == llvm::Triple::FreeBSD) {
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
}
// PPC32 supports atomics up to 4 bytes.
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
// This is the ELF definition, and is overridden by the Darwin sub-target
return TargetInfo::PowerABIBuiltinVaList;
}
};
// Note: ABI differences may eventually require us to have a separate
// TargetInfo for little endian.
class PPC64TargetInfo : public PPCTargetInfo {
public:
PPC64TargetInfo(const llvm::Triple &Triple) : PPCTargetInfo(Triple) {
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
IntMaxType = SignedLong;
Int64Type = SignedLong;
if ((Triple.getArch() == llvm::Triple::ppc64le)) {
DataLayoutString = "e-m:e-i64:64-n32:64";
ABI = "elfv2";
} else {
DataLayoutString = "E-m:e-i64:64-n32:64";
ABI = "elfv1";
}
switch (getTriple().getOS()) {
case llvm::Triple::FreeBSD:
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
break;
case llvm::Triple::NetBSD:
IntMaxType = SignedLongLong;
Int64Type = SignedLongLong;
break;
default:
break;
}
// PPC64 supports atomics up to 8 bytes.
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
// PPC64 Linux-specific ABI options.
bool setABI(const std::string &Name) override {
if (Name == "elfv1" || Name == "elfv1-qpx" || Name == "elfv2") {
ABI = Name;
return true;
}
return false;
}
};
class DarwinPPC32TargetInfo :
public DarwinTargetInfo<PPC32TargetInfo> {
public:
DarwinPPC32TargetInfo(const llvm::Triple &Triple)
: DarwinTargetInfo<PPC32TargetInfo>(Triple) {
HasAlignMac68kSupport = true;
BoolWidth = BoolAlign = 32; //XXX support -mone-byte-bool?
PtrDiffType = SignedInt; // for http://llvm.org/bugs/show_bug.cgi?id=15726
LongLongAlign = 32;
SuitableAlign = 128;
DataLayoutString = "E-m:o-p:32:32-f64:32:64-n32";
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
};
class DarwinPPC64TargetInfo :
public DarwinTargetInfo<PPC64TargetInfo> {
public:
DarwinPPC64TargetInfo(const llvm::Triple &Triple)
: DarwinTargetInfo<PPC64TargetInfo>(Triple) {
HasAlignMac68kSupport = true;
SuitableAlign = 128;
DataLayoutString = "E-m:o-i64:64-n32:64";
}
};
static const unsigned NVPTXAddrSpaceMap[] = {
1, // opencl_global
3, // opencl_local
4, // opencl_constant
// FIXME: generic has to be added to the target
0, // opencl_generic
1, // cuda_device
4, // cuda_constant
3, // cuda_shared
};
class NVPTXTargetInfo : public TargetInfo {
static const char * const GCCRegNames[];
static const Builtin::Info BuiltinInfo[];
// The GPU profiles supported by the NVPTX backend
enum GPUKind {
GK_NONE,
GK_SM20,
GK_SM21,
GK_SM30,
GK_SM35,
GK_SM37,
} GPU;
public:
NVPTXTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
BigEndian = false;
TLSSupported = false;
LongWidth = LongAlign = 64;
AddrSpaceMap = &NVPTXAddrSpaceMap;
UseAddrSpaceMapMangling = true;
// Define available target features
// These must be defined in sorted order!
NoAsmVariants = true;
// Set the default GPU to sm20
GPU = GK_SM20;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__PTX__");
Builder.defineMacro("__NVPTX__");
if (Opts.CUDAIsDevice) {
// Set __CUDA_ARCH__ for the GPU specified.
std::string CUDAArchCode;
switch (GPU) {
case GK_SM20:
CUDAArchCode = "200";
break;
case GK_SM21:
CUDAArchCode = "210";
break;
case GK_SM30:
CUDAArchCode = "300";
break;
case GK_SM35:
CUDAArchCode = "350";
break;
case GK_SM37:
CUDAArchCode = "370";
break;
default:
llvm_unreachable("Unhandled target CPU");
}
Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
}
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::NVPTX::LastTSBuiltin-Builtin::FirstTSBuiltin;
}
bool hasFeature(StringRef Feature) const override {
return Feature == "ptx" || Feature == "nvptx";
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
// No aliases.
Aliases = nullptr;
NumAliases = 0;
}
bool
validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
switch (*Name) {
default: return false;
case 'c':
case 'h':
case 'r':
case 'l':
case 'f':
case 'd':
Info.setAllowsRegister();
return true;
}
}
const char *getClobbers() const override {
// FIXME: Is this really right?
return "";
}
BuiltinVaListKind getBuiltinVaListKind() const override {
// FIXME: implement
return TargetInfo::CharPtrBuiltinVaList;
}
bool setCPU(const std::string &Name) override {
GPU = llvm::StringSwitch<GPUKind>(Name)
.Case("sm_20", GK_SM20)
.Case("sm_21", GK_SM21)
.Case("sm_30", GK_SM30)
.Case("sm_35", GK_SM35)
.Case("sm_37", GK_SM37)
.Default(GK_NONE);
return GPU != GK_NONE;
}
};
const Builtin::Info NVPTXTargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
{ #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsNVPTX.def"
};
const char * const NVPTXTargetInfo::GCCRegNames[] = {
"r0"
};
void NVPTXTargetInfo::getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
class NVPTX32TargetInfo : public NVPTXTargetInfo {
public:
NVPTX32TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) {
PointerWidth = PointerAlign = 32;
SizeType = TargetInfo::UnsignedInt;
PtrDiffType = TargetInfo::SignedInt;
IntPtrType = TargetInfo::SignedInt;
DataLayoutString = "e-p:32:32-i64:64-v16:16-v32:32-n16:32:64";
}
};
class NVPTX64TargetInfo : public NVPTXTargetInfo {
public:
NVPTX64TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) {
PointerWidth = PointerAlign = 64;
SizeType = TargetInfo::UnsignedLong;
PtrDiffType = TargetInfo::SignedLong;
IntPtrType = TargetInfo::SignedLong;
DataLayoutString = "e-i64:64-v16:16-v32:32-n16:32:64";
}
};
static const unsigned AMDGPUAddrSpaceMap[] = {
1, // opencl_global
3, // opencl_local
2, // opencl_constant
4, // opencl_generic
1, // cuda_device
2, // cuda_constant
3 // cuda_shared
};
// If you edit the description strings, make sure you update
// getPointerWidthV().
static const char *DataLayoutStringR600 =
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
static const char *DataLayoutStringR600DoubleOps =
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
static const char *DataLayoutStringSI =
"e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64"
"-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
class AMDGPUTargetInfo : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
static const char * const GCCRegNames[];
/// \brief The GPU profiles supported by the AMDGPU target.
enum GPUKind {
GK_NONE,
GK_R600,
GK_R600_DOUBLE_OPS,
GK_R700,
GK_R700_DOUBLE_OPS,
GK_EVERGREEN,
GK_EVERGREEN_DOUBLE_OPS,
GK_NORTHERN_ISLANDS,
GK_CAYMAN,
GK_SOUTHERN_ISLANDS,
GK_SEA_ISLANDS,
GK_VOLCANIC_ISLANDS
} GPU;
bool hasFP64:1;
bool hasFMAF:1;
bool hasLDEXPF:1;
public:
AMDGPUTargetInfo(const llvm::Triple &Triple)
: TargetInfo(Triple) {
if (Triple.getArch() == llvm::Triple::amdgcn) {
DataLayoutString = DataLayoutStringSI;
GPU = GK_SOUTHERN_ISLANDS;
hasFP64 = true;
hasFMAF = true;
hasLDEXPF = true;
} else {
DataLayoutString = DataLayoutStringR600;
GPU = GK_R600;
hasFP64 = false;
hasFMAF = false;
hasLDEXPF = false;
}
AddrSpaceMap = &AMDGPUAddrSpaceMap;
UseAddrSpaceMapMangling = true;
}
uint64_t getPointerWidthV(unsigned AddrSpace) const override {
if (GPU <= GK_CAYMAN)
return 32;
switch(AddrSpace) {
default:
return 64;
case 0:
case 3:
case 5:
return 32;
}
}
const char * getClobbers() const override {
return "";
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
Aliases = nullptr;
NumAliases = 0;
}
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
return true;
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::AMDGPU::LastTSBuiltin - Builtin::FirstTSBuiltin;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__R600__");
if (hasFMAF)
Builder.defineMacro("__HAS_FMAF__");
if (hasLDEXPF)
Builder.defineMacro("__HAS_LDEXPF__");
if (hasFP64 && Opts.OpenCL)
Builder.defineMacro("cl_khr_fp64");
if (Opts.OpenCL) {
if (GPU >= GK_NORTHERN_ISLANDS) {
Builder.defineMacro("cl_khr_byte_addressable_store");
Builder.defineMacro("cl_khr_global_int32_base_atomics");
Builder.defineMacro("cl_khr_global_int32_extended_atomics");
Builder.defineMacro("cl_khr_local_int32_base_atomics");
Builder.defineMacro("cl_khr_local_int32_extended_atomics");
}
}
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
bool setCPU(const std::string &Name) override {
GPU = llvm::StringSwitch<GPUKind>(Name)
.Case("r600" , GK_R600)
.Case("rv610", GK_R600)
.Case("rv620", GK_R600)
.Case("rv630", GK_R600)
.Case("rv635", GK_R600)
.Case("rs780", GK_R600)
.Case("rs880", GK_R600)
.Case("rv670", GK_R600_DOUBLE_OPS)
.Case("rv710", GK_R700)
.Case("rv730", GK_R700)
.Case("rv740", GK_R700_DOUBLE_OPS)
.Case("rv770", GK_R700_DOUBLE_OPS)
.Case("palm", GK_EVERGREEN)
.Case("cedar", GK_EVERGREEN)
.Case("sumo", GK_EVERGREEN)
.Case("sumo2", GK_EVERGREEN)
.Case("redwood", GK_EVERGREEN)
.Case("juniper", GK_EVERGREEN)
.Case("hemlock", GK_EVERGREEN_DOUBLE_OPS)
.Case("cypress", GK_EVERGREEN_DOUBLE_OPS)
.Case("barts", GK_NORTHERN_ISLANDS)
.Case("turks", GK_NORTHERN_ISLANDS)
.Case("caicos", GK_NORTHERN_ISLANDS)
.Case("cayman", GK_CAYMAN)
.Case("aruba", GK_CAYMAN)
.Case("tahiti", GK_SOUTHERN_ISLANDS)
.Case("pitcairn", GK_SOUTHERN_ISLANDS)
.Case("verde", GK_SOUTHERN_ISLANDS)
.Case("oland", GK_SOUTHERN_ISLANDS)
.Case("hainan", GK_SOUTHERN_ISLANDS)
.Case("bonaire", GK_SEA_ISLANDS)
.Case("kabini", GK_SEA_ISLANDS)
.Case("kaveri", GK_SEA_ISLANDS)
.Case("hawaii", GK_SEA_ISLANDS)
.Case("mullins", GK_SEA_ISLANDS)
.Case("tonga", GK_VOLCANIC_ISLANDS)
.Case("iceland", GK_VOLCANIC_ISLANDS)
.Case("carrizo", GK_VOLCANIC_ISLANDS)
.Default(GK_NONE);
if (GPU == GK_NONE) {
return false;
}
// Set the correct data layout
switch (GPU) {
case GK_NONE:
case GK_R600:
case GK_R700:
case GK_EVERGREEN:
case GK_NORTHERN_ISLANDS:
DataLayoutString = DataLayoutStringR600;
hasFP64 = false;
hasFMAF = false;
hasLDEXPF = false;
break;
case GK_R600_DOUBLE_OPS:
case GK_R700_DOUBLE_OPS:
case GK_EVERGREEN_DOUBLE_OPS:
case GK_CAYMAN:
DataLayoutString = DataLayoutStringR600DoubleOps;
hasFP64 = true;
hasFMAF = true;
hasLDEXPF = false;
break;
case GK_SOUTHERN_ISLANDS:
case GK_SEA_ISLANDS:
case GK_VOLCANIC_ISLANDS:
DataLayoutString = DataLayoutStringSI;
hasFP64 = true;
hasFMAF = true;
hasLDEXPF = true;
break;
}
return true;
}
};
const Builtin::Info AMDGPUTargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsAMDGPU.def"
};
const char * const AMDGPUTargetInfo::GCCRegNames[] = {
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
"v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
"v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
"v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
"v32", "v33", "v34", "v35", "v36", "v37", "v38", "v39",
"v40", "v41", "v42", "v43", "v44", "v45", "v46", "v47",
"v48", "v49", "v50", "v51", "v52", "v53", "v54", "v55",
"v56", "v57", "v58", "v59", "v60", "v61", "v62", "v63",
"v64", "v65", "v66", "v67", "v68", "v69", "v70", "v71",
"v72", "v73", "v74", "v75", "v76", "v77", "v78", "v79",
"v80", "v81", "v82", "v83", "v84", "v85", "v86", "v87",
"v88", "v89", "v90", "v91", "v92", "v93", "v94", "v95",
"v96", "v97", "v98", "v99", "v100", "v101", "v102", "v103",
"v104", "v105", "v106", "v107", "v108", "v109", "v110", "v111",
"v112", "v113", "v114", "v115", "v116", "v117", "v118", "v119",
"v120", "v121", "v122", "v123", "v124", "v125", "v126", "v127",
"v128", "v129", "v130", "v131", "v132", "v133", "v134", "v135",
"v136", "v137", "v138", "v139", "v140", "v141", "v142", "v143",
"v144", "v145", "v146", "v147", "v148", "v149", "v150", "v151",
"v152", "v153", "v154", "v155", "v156", "v157", "v158", "v159",
"v160", "v161", "v162", "v163", "v164", "v165", "v166", "v167",
"v168", "v169", "v170", "v171", "v172", "v173", "v174", "v175",
"v176", "v177", "v178", "v179", "v180", "v181", "v182", "v183",
"v184", "v185", "v186", "v187", "v188", "v189", "v190", "v191",
"v192", "v193", "v194", "v195", "v196", "v197", "v198", "v199",
"v200", "v201", "v202", "v203", "v204", "v205", "v206", "v207",
"v208", "v209", "v210", "v211", "v212", "v213", "v214", "v215",
"v216", "v217", "v218", "v219", "v220", "v221", "v222", "v223",
"v224", "v225", "v226", "v227", "v228", "v229", "v230", "v231",
"v232", "v233", "v234", "v235", "v236", "v237", "v238", "v239",
"v240", "v241", "v242", "v243", "v244", "v245", "v246", "v247",
"v248", "v249", "v250", "v251", "v252", "v253", "v254", "v255",
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
"s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
"s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
"s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
"s32", "s33", "s34", "s35", "s36", "s37", "s38", "s39",
"s40", "s41", "s42", "s43", "s44", "s45", "s46", "s47",
"s48", "s49", "s50", "s51", "s52", "s53", "s54", "s55",
"s56", "s57", "s58", "s59", "s60", "s61", "s62", "s63",
"s64", "s65", "s66", "s67", "s68", "s69", "s70", "s71",
"s72", "s73", "s74", "s75", "s76", "s77", "s78", "s79",
"s80", "s81", "s82", "s83", "s84", "s85", "s86", "s87",
"s88", "s89", "s90", "s91", "s92", "s93", "s94", "s95",
"s96", "s97", "s98", "s99", "s100", "s101", "s102", "s103",
"s104", "s105", "s106", "s107", "s108", "s109", "s110", "s111",
"s112", "s113", "s114", "s115", "s116", "s117", "s118", "s119",
"s120", "s121", "s122", "s123", "s124", "s125", "s126", "s127"
"exec", "vcc", "scc", "m0", "flat_scr", "exec_lo", "exec_hi",
"vcc_lo", "vcc_hi", "flat_scr_lo", "flat_scr_hi"
};
void AMDGPUTargetInfo::getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
// Namespace for x86 abstract base class
const Builtin::Info BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
{ #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE },
#include "clang/Basic/BuiltinsX86.def"
};
static const char* const GCCRegNames[] = {
"ax", "dx", "cx", "bx", "si", "di", "bp", "sp",
"st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)",
"argp", "flags", "fpcr", "fpsr", "dirflag", "frame",
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
"mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15",
"ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7",
"ymm8", "ymm9", "ymm10", "ymm11", "ymm12", "ymm13", "ymm14", "ymm15",
};
const TargetInfo::AddlRegName AddlRegNames[] = {
{ { "al", "ah", "eax", "rax" }, 0 },
{ { "bl", "bh", "ebx", "rbx" }, 3 },
{ { "cl", "ch", "ecx", "rcx" }, 2 },
{ { "dl", "dh", "edx", "rdx" }, 1 },
{ { "esi", "rsi" }, 4 },
{ { "edi", "rdi" }, 5 },
{ { "esp", "rsp" }, 7 },
{ { "ebp", "rbp" }, 6 },
};
// X86 target abstract base class; x86-32 and x86-64 are very close, so
// most of the implementation can be shared.
class X86TargetInfo : public TargetInfo {
enum X86SSEEnum {
NoSSE, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2, AVX512F
} SSELevel;
enum MMX3DNowEnum {
NoMMX3DNow, MMX, AMD3DNow, AMD3DNowAthlon
} MMX3DNowLevel;
enum XOPEnum {
NoXOP,
SSE4A,
FMA4,
XOP
} XOPLevel;
bool HasAES;
bool HasPCLMUL;
bool HasLZCNT;
bool HasRDRND;
bool HasFSGSBASE;
bool HasBMI;
bool HasBMI2;
bool HasPOPCNT;
bool HasRTM;
bool HasPRFCHW;
bool HasRDSEED;
bool HasADX;
bool HasTBM;
bool HasFMA;
bool HasF16C;
bool HasAVX512CD, HasAVX512ER, HasAVX512PF, HasAVX512DQ, HasAVX512BW,
HasAVX512VL;
bool HasSHA;
bool HasCX16;
/// \brief Enumeration of all of the X86 CPUs supported by Clang.
///
/// Each enumeration represents a particular CPU supported by Clang. These
/// loosely correspond to the options passed to '-march' or '-mtune' flags.
enum CPUKind {
CK_Generic,
/// \name i386
/// i386-generation processors.
//@{
CK_i386,
//@}
/// \name i486
/// i486-generation processors.
//@{
CK_i486,
CK_WinChipC6,
CK_WinChip2,
CK_C3,
//@}
/// \name i586
/// i586-generation processors, P5 microarchitecture based.
//@{
CK_i586,
CK_Pentium,
CK_PentiumMMX,
//@}
/// \name i686
/// i686-generation processors, P6 / Pentium M microarchitecture based.
//@{
CK_i686,
CK_PentiumPro,
CK_Pentium2,
CK_Pentium3,
CK_Pentium3M,
CK_PentiumM,
CK_C3_2,
/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
/// Clang however has some logic to suport this.
// FIXME: Warn, deprecate, and potentially remove this.
CK_Yonah,
//@}
/// \name Netburst
/// Netburst microarchitecture based processors.
//@{
CK_Pentium4,
CK_Pentium4M,
CK_Prescott,
CK_Nocona,
//@}
/// \name Core
/// Core microarchitecture based processors.
//@{
CK_Core2,
/// This enumerator, like \see CK_Yonah, is a bit odd. It is another
/// codename which GCC no longer accepts as an option to -march, but Clang
/// has some logic for recognizing it.
// FIXME: Warn, deprecate, and potentially remove this.
CK_Penryn,
//@}
/// \name Atom
/// Atom processors
//@{
CK_Bonnell,
CK_Silvermont,
//@}
/// \name Nehalem
/// Nehalem microarchitecture based processors.
CK_Nehalem,
/// \name Westmere
/// Westmere microarchitecture based processors.
CK_Westmere,
/// \name Sandy Bridge
/// Sandy Bridge microarchitecture based processors.
CK_SandyBridge,
/// \name Ivy Bridge
/// Ivy Bridge microarchitecture based processors.
CK_IvyBridge,
/// \name Haswell
/// Haswell microarchitecture based processors.
CK_Haswell,
/// \name Broadwell
/// Broadwell microarchitecture based processors.
CK_Broadwell,
/// \name Skylake
/// Skylake microarchitecture based processors.
CK_Skylake,
/// \name Knights Landing
/// Knights Landing processor.
CK_KNL,
/// \name K6
/// K6 architecture processors.
//@{
CK_K6,
CK_K6_2,
CK_K6_3,
//@}
/// \name K7
/// K7 architecture processors.
//@{
CK_Athlon,
CK_AthlonThunderbird,
CK_Athlon4,
CK_AthlonXP,
CK_AthlonMP,
//@}
/// \name K8
/// K8 architecture processors.
//@{
CK_Athlon64,
CK_Athlon64SSE3,
CK_AthlonFX,
CK_K8,
CK_K8SSE3,
CK_Opteron,
CK_OpteronSSE3,
CK_AMDFAM10,
//@}
/// \name Bobcat
/// Bobcat architecture processors.
//@{
CK_BTVER1,
CK_BTVER2,
//@}
/// \name Bulldozer
/// Bulldozer architecture processors.
//@{
CK_BDVER1,
CK_BDVER2,
CK_BDVER3,
CK_BDVER4,
//@}
/// This specification is deprecated and will be removed in the future.
/// Users should prefer \see CK_K8.
// FIXME: Warn on this when the CPU is set to it.
//@{
CK_x86_64,
//@}
/// \name Geode
/// Geode processors.
//@{
CK_Geode
//@}
} CPU;
CPUKind getCPUKind(StringRef CPU) const {
return llvm::StringSwitch<CPUKind>(CPU)
.Case("i386", CK_i386)
.Case("i486", CK_i486)
.Case("winchip-c6", CK_WinChipC6)
.Case("winchip2", CK_WinChip2)
.Case("c3", CK_C3)
.Case("i586", CK_i586)
.Case("pentium", CK_Pentium)
.Case("pentium-mmx", CK_PentiumMMX)
.Case("i686", CK_i686)
.Case("pentiumpro", CK_PentiumPro)
.Case("pentium2", CK_Pentium2)
.Case("pentium3", CK_Pentium3)
.Case("pentium3m", CK_Pentium3M)
.Case("pentium-m", CK_PentiumM)
.Case("c3-2", CK_C3_2)
.Case("yonah", CK_Yonah)
.Case("pentium4", CK_Pentium4)
.Case("pentium4m", CK_Pentium4M)
.Case("prescott", CK_Prescott)
.Case("nocona", CK_Nocona)
.Case("core2", CK_Core2)
.Case("penryn", CK_Penryn)
.Case("bonnell", CK_Bonnell)
.Case("atom", CK_Bonnell) // Legacy name.
.Case("silvermont", CK_Silvermont)
.Case("slm", CK_Silvermont) // Legacy name.
.Case("nehalem", CK_Nehalem)
.Case("corei7", CK_Nehalem) // Legacy name.
.Case("westmere", CK_Westmere)
.Case("sandybridge", CK_SandyBridge)
.Case("corei7-avx", CK_SandyBridge) // Legacy name.
.Case("ivybridge", CK_IvyBridge)
.Case("core-avx-i", CK_IvyBridge) // Legacy name.
.Case("haswell", CK_Haswell)
.Case("core-avx2", CK_Haswell) // Legacy name.
.Case("broadwell", CK_Broadwell)
.Case("skylake", CK_Skylake)
.Case("skx", CK_Skylake) // Legacy name.
.Case("knl", CK_KNL)
.Case("k6", CK_K6)
.Case("k6-2", CK_K6_2)
.Case("k6-3", CK_K6_3)
.Case("athlon", CK_Athlon)
.Case("athlon-tbird", CK_AthlonThunderbird)
.Case("athlon-4", CK_Athlon4)
.Case("athlon-xp", CK_AthlonXP)
.Case("athlon-mp", CK_AthlonMP)
.Case("athlon64", CK_Athlon64)
.Case("athlon64-sse3", CK_Athlon64SSE3)
.Case("athlon-fx", CK_AthlonFX)
.Case("k8", CK_K8)
.Case("k8-sse3", CK_K8SSE3)
.Case("opteron", CK_Opteron)
.Case("opteron-sse3", CK_OpteronSSE3)
.Case("barcelona", CK_AMDFAM10)
.Case("amdfam10", CK_AMDFAM10)
.Case("btver1", CK_BTVER1)
.Case("btver2", CK_BTVER2)
.Case("bdver1", CK_BDVER1)
.Case("bdver2", CK_BDVER2)
.Case("bdver3", CK_BDVER3)
.Case("bdver4", CK_BDVER4)
.Case("x86-64", CK_x86_64)
.Case("geode", CK_Geode)
.Default(CK_Generic);
}
enum FPMathKind {
FP_Default,
FP_SSE,
FP_387
} FPMath;
public:
X86TargetInfo(const llvm::Triple &Triple)
: TargetInfo(Triple), SSELevel(NoSSE), MMX3DNowLevel(NoMMX3DNow),
XOPLevel(NoXOP), HasAES(false), HasPCLMUL(false), HasLZCNT(false),
HasRDRND(false), HasFSGSBASE(false), HasBMI(false), HasBMI2(false),
HasPOPCNT(false), HasRTM(false), HasPRFCHW(false), HasRDSEED(false),
HasADX(false), HasTBM(false), HasFMA(false), HasF16C(false),
HasAVX512CD(false), HasAVX512ER(false), HasAVX512PF(false),
HasAVX512DQ(false), HasAVX512BW(false), HasAVX512VL(false),
HasSHA(false), HasCX16(false), CPU(CK_Generic), FPMath(FP_Default) {
BigEndian = false;
LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
}
unsigned getFloatEvalMethod() const override {
// X87 evaluates with 80 bits "long double" precision.
return SSELevel == NoSSE ? 2 : 0;
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::X86::LastTSBuiltin-Builtin::FirstTSBuiltin;
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
Aliases = nullptr;
NumAliases = 0;
}
void getGCCAddlRegNames(const AddlRegName *&Names,
unsigned &NumNames) const override {
Names = AddlRegNames;
NumNames = llvm::array_lengthof(AddlRegNames);
}
bool validateCpuSupports(StringRef Name) const override;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override;
bool validateOutputSize(StringRef Constraint, unsigned Size) const override;
bool validateInputSize(StringRef Constraint, unsigned Size) const override;
virtual bool validateOperandSize(StringRef Constraint, unsigned Size) const;
std::string convertConstraint(const char *&Constraint) const override;
const char *getClobbers() const override {
return "~{dirflag},~{fpsr},~{flags}";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
static void setSSELevel(llvm::StringMap<bool> &Features, X86SSEEnum Level,
bool Enabled);
static void setMMXLevel(llvm::StringMap<bool> &Features, MMX3DNowEnum Level,
bool Enabled);
static void setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level,
bool Enabled);
void setFeatureEnabled(llvm::StringMap<bool> &Features,
StringRef Name, bool Enabled) const override {
setFeatureEnabledImpl(Features, Name, Enabled);
}
// This exists purely to cut down on the number of virtual calls in
// initFeatureMap which calls this repeatedly.
static void setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
StringRef Name, bool Enabled);
bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
StringRef CPU,
std::vector<std::string> &FeaturesVec) const override;
bool hasFeature(StringRef Feature) const override;
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override;
StringRef getABI() const override {
if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX512F)
return "avx512";
else if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX)
return "avx";
else if (getTriple().getArch() == llvm::Triple::x86 &&
MMX3DNowLevel == NoMMX3DNow)
return "no-mmx";
return "";
}
bool setCPU(const std::string &Name) override {
CPU = getCPUKind(Name);
// Perform any per-CPU checks necessary to determine if this CPU is
// acceptable.
// FIXME: This results in terrible diagnostics. Clang just says the CPU is
// invalid without explaining *why*.
switch (CPU) {
case CK_Generic:
// No processor selected!
return false;
case CK_i386:
case CK_i486:
case CK_WinChipC6:
case CK_WinChip2:
case CK_C3:
case CK_i586:
case CK_Pentium:
case CK_PentiumMMX:
case CK_i686:
case CK_PentiumPro:
case CK_Pentium2:
case CK_Pentium3:
case CK_Pentium3M:
case CK_PentiumM:
case CK_Yonah:
case CK_C3_2:
case CK_Pentium4:
case CK_Pentium4M:
case CK_Prescott:
case CK_K6:
case CK_K6_2:
case CK_K6_3:
case CK_Athlon:
case CK_AthlonThunderbird:
case CK_Athlon4:
case CK_AthlonXP:
case CK_AthlonMP:
case CK_Geode:
// Only accept certain architectures when compiling in 32-bit mode.
if (getTriple().getArch() != llvm::Triple::x86)
return false;
// Fallthrough
case CK_Nocona:
case CK_Core2:
case CK_Penryn:
case CK_Bonnell:
case CK_Silvermont:
case CK_Nehalem:
case CK_Westmere:
case CK_SandyBridge:
case CK_IvyBridge:
case CK_Haswell:
case CK_Broadwell:
case CK_Skylake:
case CK_KNL:
case CK_Athlon64:
case CK_Athlon64SSE3:
case CK_AthlonFX:
case CK_K8:
case CK_K8SSE3:
case CK_Opteron:
case CK_OpteronSSE3:
case CK_AMDFAM10:
case CK_BTVER1:
case CK_BTVER2:
case CK_BDVER1:
case CK_BDVER2:
case CK_BDVER3:
case CK_BDVER4:
case CK_x86_64:
return true;
}
llvm_unreachable("Unhandled CPU kind");
}
bool setFPMath(StringRef Name) override;
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
// We accept all non-ARM calling conventions
return (CC == CC_X86ThisCall ||
CC == CC_X86FastCall ||
CC == CC_X86StdCall ||
CC == CC_X86VectorCall ||
CC == CC_C ||
CC == CC_X86Pascal ||
CC == CC_IntelOclBicc) ? CCCR_OK : CCCR_Warning;
}
CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override {
return MT == CCMT_Member ? CC_X86ThisCall : CC_C;
}
bool hasSjLjLowering() const override {
return true;
}
};
bool X86TargetInfo::setFPMath(StringRef Name) {
if (Name == "387") {
FPMath = FP_387;
return true;
}
if (Name == "sse") {
FPMath = FP_SSE;
return true;
}
return false;
}
bool X86TargetInfo::initFeatureMap(
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
std::vector<std::string> &FeaturesVec) const {
// FIXME: This *really* should not be here.
// X86_64 always has SSE2.
if (getTriple().getArch() == llvm::Triple::x86_64)
setFeatureEnabledImpl(Features, "sse2", true);
switch (getCPUKind(CPU)) {
case CK_Generic:
case CK_i386:
case CK_i486:
case CK_i586:
case CK_Pentium:
case CK_i686:
case CK_PentiumPro:
break;
case CK_PentiumMMX:
case CK_Pentium2:
case CK_K6:
case CK_WinChipC6:
setFeatureEnabledImpl(Features, "mmx", true);
break;
case CK_Pentium3:
case CK_Pentium3M:
case CK_C3_2:
setFeatureEnabledImpl(Features, "sse", true);
break;
case CK_PentiumM:
case CK_Pentium4:
case CK_Pentium4M:
case CK_x86_64:
setFeatureEnabledImpl(Features, "sse2", true);
break;
case CK_Yonah:
case CK_Prescott:
case CK_Nocona:
setFeatureEnabledImpl(Features, "sse3", true);
setFeatureEnabledImpl(Features, "cx16", true);
break;
case CK_Core2:
case CK_Bonnell:
setFeatureEnabledImpl(Features, "ssse3", true);
setFeatureEnabledImpl(Features, "cx16", true);
break;
case CK_Penryn:
setFeatureEnabledImpl(Features, "sse4.1", true);
setFeatureEnabledImpl(Features, "cx16", true);
break;
case CK_Skylake:
setFeatureEnabledImpl(Features, "avx512f", true);
setFeatureEnabledImpl(Features, "avx512cd", true);
setFeatureEnabledImpl(Features, "avx512dq", true);
setFeatureEnabledImpl(Features, "avx512bw", true);
setFeatureEnabledImpl(Features, "avx512vl", true);
// FALLTHROUGH
case CK_Broadwell:
setFeatureEnabledImpl(Features, "rdseed", true);
setFeatureEnabledImpl(Features, "adx", true);
// FALLTHROUGH
case CK_Haswell:
setFeatureEnabledImpl(Features, "avx2", true);
setFeatureEnabledImpl(Features, "lzcnt", true);
setFeatureEnabledImpl(Features, "bmi", true);
setFeatureEnabledImpl(Features, "bmi2", true);
setFeatureEnabledImpl(Features, "rtm", true);
setFeatureEnabledImpl(Features, "fma", true);
// FALLTHROUGH
case CK_IvyBridge:
setFeatureEnabledImpl(Features, "rdrnd", true);
setFeatureEnabledImpl(Features, "f16c", true);
setFeatureEnabledImpl(Features, "fsgsbase", true);
// FALLTHROUGH
case CK_SandyBridge:
setFeatureEnabledImpl(Features, "avx", true);
// FALLTHROUGH
case CK_Westmere:
case CK_Silvermont:
setFeatureEnabledImpl(Features, "aes", true);
setFeatureEnabledImpl(Features, "pclmul", true);
// FALLTHROUGH
case CK_Nehalem:
setFeatureEnabledImpl(Features, "sse4.2", true);
setFeatureEnabledImpl(Features, "cx16", true);
break;
case CK_KNL:
setFeatureEnabledImpl(Features, "avx512f", true);
setFeatureEnabledImpl(Features, "avx512cd", true);
setFeatureEnabledImpl(Features, "avx512er", true);
setFeatureEnabledImpl(Features, "avx512pf", true);
setFeatureEnabledImpl(Features, "rdseed", true);
setFeatureEnabledImpl(Features, "adx", true);
setFeatureEnabledImpl(Features, "lzcnt", true);
setFeatureEnabledImpl(Features, "bmi", true);
setFeatureEnabledImpl(Features, "bmi2", true);
setFeatureEnabledImpl(Features, "rtm", true);
setFeatureEnabledImpl(Features, "fma", true);
setFeatureEnabledImpl(Features, "rdrnd", true);
setFeatureEnabledImpl(Features, "f16c", true);
setFeatureEnabledImpl(Features, "fsgsbase", true);
setFeatureEnabledImpl(Features, "aes", true);
setFeatureEnabledImpl(Features, "pclmul", true);
setFeatureEnabledImpl(Features, "cx16", true);
break;
case CK_K6_2:
case CK_K6_3:
case CK_WinChip2:
case CK_C3:
setFeatureEnabledImpl(Features, "3dnow", true);
break;
case CK_Athlon:
case CK_AthlonThunderbird:
case CK_Geode:
setFeatureEnabledImpl(Features, "3dnowa", true);
break;
case CK_Athlon4:
case CK_AthlonXP:
case CK_AthlonMP:
setFeatureEnabledImpl(Features, "sse", true);
setFeatureEnabledImpl(Features, "3dnowa", true);
break;
case CK_K8:
case CK_Opteron:
case CK_Athlon64:
case CK_AthlonFX:
setFeatureEnabledImpl(Features, "sse2", true);
setFeatureEnabledImpl(Features, "3dnowa", true);
break;
case CK_AMDFAM10:
setFeatureEnabledImpl(Features, "sse4a", true);
setFeatureEnabledImpl(Features, "lzcnt", true);
setFeatureEnabledImpl(Features, "popcnt", true);
// FALLTHROUGH
case CK_K8SSE3:
case CK_OpteronSSE3:
case CK_Athlon64SSE3:
setFeatureEnabledImpl(Features, "sse3", true);
setFeatureEnabledImpl(Features, "3dnowa", true);
break;
case CK_BTVER2:
setFeatureEnabledImpl(Features, "avx", true);
setFeatureEnabledImpl(Features, "aes", true);
setFeatureEnabledImpl(Features, "pclmul", true);
setFeatureEnabledImpl(Features, "bmi", true);
setFeatureEnabledImpl(Features, "f16c", true);
// FALLTHROUGH
case CK_BTVER1:
setFeatureEnabledImpl(Features, "ssse3", true);
setFeatureEnabledImpl(Features, "sse4a", true);
setFeatureEnabledImpl(Features, "lzcnt", true);
setFeatureEnabledImpl(Features, "popcnt", true);
setFeatureEnabledImpl(Features, "prfchw", true);
setFeatureEnabledImpl(Features, "cx16", true);
break;
case CK_BDVER4:
setFeatureEnabledImpl(Features, "avx2", true);
setFeatureEnabledImpl(Features, "bmi2", true);
// FALLTHROUGH
case CK_BDVER3:
setFeatureEnabledImpl(Features, "fsgsbase", true);
// FALLTHROUGH
case CK_BDVER2:
setFeatureEnabledImpl(Features, "bmi", true);
setFeatureEnabledImpl(Features, "fma", true);
setFeatureEnabledImpl(Features, "f16c", true);
setFeatureEnabledImpl(Features, "tbm", true);
// FALLTHROUGH
case CK_BDVER1:
// xop implies avx, sse4a and fma4.
setFeatureEnabledImpl(Features, "xop", true);
setFeatureEnabledImpl(Features, "lzcnt", true);
setFeatureEnabledImpl(Features, "aes", true);
setFeatureEnabledImpl(Features, "pclmul", true);
setFeatureEnabledImpl(Features, "prfchw", true);
setFeatureEnabledImpl(Features, "cx16", true);
break;
}
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
void X86TargetInfo::setSSELevel(llvm::StringMap<bool> &Features,
X86SSEEnum Level, bool Enabled) {
if (Enabled) {
switch (Level) {
case AVX512F:
Features["avx512f"] = true;
case AVX2:
Features["avx2"] = true;
case AVX:
Features["avx"] = true;
case SSE42:
Features["sse4.2"] = true;
case SSE41:
Features["sse4.1"] = true;
case SSSE3:
Features["ssse3"] = true;
case SSE3:
Features["sse3"] = true;
case SSE2:
Features["sse2"] = true;
case SSE1:
Features["sse"] = true;
case NoSSE:
break;
}
return;
}
switch (Level) {
case NoSSE:
case SSE1:
Features["sse"] = false;
case SSE2:
Features["sse2"] = Features["pclmul"] = Features["aes"] =
Features["sha"] = false;
case SSE3:
Features["sse3"] = false;
setXOPLevel(Features, NoXOP, false);
case SSSE3:
Features["ssse3"] = false;
case SSE41:
Features["sse4.1"] = false;
case SSE42:
Features["sse4.2"] = false;
case AVX:
Features["fma"] = Features["avx"] = Features["f16c"] = false;
setXOPLevel(Features, FMA4, false);
case AVX2:
Features["avx2"] = false;
case AVX512F:
Features["avx512f"] = Features["avx512cd"] = Features["avx512er"] =
Features["avx512pf"] = Features["avx512dq"] = Features["avx512bw"] =
Features["avx512vl"] = false;
}
}
void X86TargetInfo::setMMXLevel(llvm::StringMap<bool> &Features,
MMX3DNowEnum Level, bool Enabled) {
if (Enabled) {
switch (Level) {
case AMD3DNowAthlon:
Features["3dnowa"] = true;
case AMD3DNow:
Features["3dnow"] = true;
case MMX:
Features["mmx"] = true;
case NoMMX3DNow:
break;
}
return;
}
switch (Level) {
case NoMMX3DNow:
case MMX:
Features["mmx"] = false;
case AMD3DNow:
Features["3dnow"] = false;
case AMD3DNowAthlon:
Features["3dnowa"] = false;
}
}
void X86TargetInfo::setXOPLevel(llvm::StringMap<bool> &Features, XOPEnum Level,
bool Enabled) {
if (Enabled) {
switch (Level) {
case XOP:
Features["xop"] = true;
case FMA4:
Features["fma4"] = true;
setSSELevel(Features, AVX, true);
case SSE4A:
Features["sse4a"] = true;
setSSELevel(Features, SSE3, true);
case NoXOP:
break;
}
return;
}
switch (Level) {
case NoXOP:
case SSE4A:
Features["sse4a"] = false;
case FMA4:
Features["fma4"] = false;
case XOP:
Features["xop"] = false;
}
}
void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
StringRef Name, bool Enabled) {
// This is a bit of a hack to deal with the sse4 target feature when used
// as part of the target attribute. We handle sse4 correctly everywhere
// else. See below for more information on how we handle the sse4 options.
if (Name != "sse4")
Features[Name] = Enabled;
if (Name == "mmx") {
setMMXLevel(Features, MMX, Enabled);
} else if (Name == "sse") {
setSSELevel(Features, SSE1, Enabled);
} else if (Name == "sse2") {
setSSELevel(Features, SSE2, Enabled);
} else if (Name == "sse3") {
setSSELevel(Features, SSE3, Enabled);
} else if (Name == "ssse3") {
setSSELevel(Features, SSSE3, Enabled);
} else if (Name == "sse4.2") {
setSSELevel(Features, SSE42, Enabled);
} else if (Name == "sse4.1") {
setSSELevel(Features, SSE41, Enabled);
} else if (Name == "3dnow") {
setMMXLevel(Features, AMD3DNow, Enabled);
} else if (Name == "3dnowa") {
setMMXLevel(Features, AMD3DNowAthlon, Enabled);
} else if (Name == "aes") {
if (Enabled)
setSSELevel(Features, SSE2, Enabled);
} else if (Name == "pclmul") {
if (Enabled)
setSSELevel(Features, SSE2, Enabled);
} else if (Name == "avx") {
setSSELevel(Features, AVX, Enabled);
} else if (Name == "avx2") {
setSSELevel(Features, AVX2, Enabled);
} else if (Name == "avx512f") {
setSSELevel(Features, AVX512F, Enabled);
} else if (Name == "avx512cd" || Name == "avx512er" || Name == "avx512pf"
|| Name == "avx512dq" || Name == "avx512bw" || Name == "avx512vl") {
if (Enabled)
setSSELevel(Features, AVX512F, Enabled);
} else if (Name == "fma") {
if (Enabled)
setSSELevel(Features, AVX, Enabled);
} else if (Name == "fma4") {
setXOPLevel(Features, FMA4, Enabled);
} else if (Name == "xop") {
setXOPLevel(Features, XOP, Enabled);
} else if (Name == "sse4a") {
setXOPLevel(Features, SSE4A, Enabled);
} else if (Name == "f16c") {
if (Enabled)
setSSELevel(Features, AVX, Enabled);
} else if (Name == "sha") {
if (Enabled)
setSSELevel(Features, SSE2, Enabled);
} else if (Name == "sse4") {
// We can get here via the __target__ attribute since that's not controlled
// via the -msse4/-mno-sse4 command line alias. Handle this the same way
// here - turn on the sse4.2 if enabled, turn off the sse4.1 level if
// disabled.
if (Enabled)
setSSELevel(Features, SSE42, Enabled);
else
setSSELevel(Features, SSE41, Enabled);
}
}
/// handleTargetFeatures - Perform initialization based on the user
/// configured set of features.
bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) {
for (const auto &Feature : Features) {
if (Feature[0] != '+')
continue;
if (Feature == "+aes") {
HasAES = true;
} else if (Feature == "+pclmul") {
HasPCLMUL = true;
} else if (Feature == "+lzcnt") {
HasLZCNT = true;
} else if (Feature == "+rdrnd") {
HasRDRND = true;
} else if (Feature == "+fsgsbase") {
HasFSGSBASE = true;
} else if (Feature == "+bmi") {
HasBMI = true;
} else if (Feature == "+bmi2") {
HasBMI2 = true;
} else if (Feature == "+popcnt") {
HasPOPCNT = true;
} else if (Feature == "+rtm") {
HasRTM = true;
} else if (Feature == "+prfchw") {
HasPRFCHW = true;
} else if (Feature == "+rdseed") {
HasRDSEED = true;
} else if (Feature == "+adx") {
HasADX = true;
} else if (Feature == "+tbm") {
HasTBM = true;
} else if (Feature == "+fma") {
HasFMA = true;
} else if (Feature == "+f16c") {
HasF16C = true;
} else if (Feature == "+avx512cd") {
HasAVX512CD = true;
} else if (Feature == "+avx512er") {
HasAVX512ER = true;
} else if (Feature == "+avx512pf") {
HasAVX512PF = true;
} else if (Feature == "+avx512dq") {
HasAVX512DQ = true;
} else if (Feature == "+avx512bw") {
HasAVX512BW = true;
} else if (Feature == "+avx512vl") {
HasAVX512VL = true;
} else if (Feature == "+sha") {
HasSHA = true;
} else if (Feature == "+cx16") {
HasCX16 = true;
}
X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature)
.Case("+avx512f", AVX512F)
.Case("+avx2", AVX2)
.Case("+avx", AVX)
.Case("+sse4.2", SSE42)
.Case("+sse4.1", SSE41)
.Case("+ssse3", SSSE3)
.Case("+sse3", SSE3)
.Case("+sse2", SSE2)
.Case("+sse", SSE1)
.Default(NoSSE);
SSELevel = std::max(SSELevel, Level);
MMX3DNowEnum ThreeDNowLevel =
llvm::StringSwitch<MMX3DNowEnum>(Feature)
.Case("+3dnowa", AMD3DNowAthlon)
.Case("+3dnow", AMD3DNow)
.Case("+mmx", MMX)
.Default(NoMMX3DNow);
MMX3DNowLevel = std::max(MMX3DNowLevel, ThreeDNowLevel);
XOPEnum XLevel = llvm::StringSwitch<XOPEnum>(Feature)
.Case("+xop", XOP)
.Case("+fma4", FMA4)
.Case("+sse4a", SSE4A)
.Default(NoXOP);
XOPLevel = std::max(XOPLevel, XLevel);
}
// Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
// Can't do this earlier because we need to be able to explicitly enable
// popcnt and still disable sse4.2.
if (!HasPOPCNT && SSELevel >= SSE42 &&
std::find(Features.begin(), Features.end(), "-popcnt") == Features.end()){
HasPOPCNT = true;
Features.push_back("+popcnt");
}
// Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
if (!HasPRFCHW && MMX3DNowLevel >= AMD3DNow &&
std::find(Features.begin(), Features.end(), "-prfchw") == Features.end()){
HasPRFCHW = true;
Features.push_back("+prfchw");
}
// LLVM doesn't have a separate switch for fpmath, so only accept it if it
// matches the selected sse level.
if (FPMath == FP_SSE && SSELevel < SSE1) {
Diags.Report(diag::err_target_unsupported_fpmath) << "sse";
return false;
} else if (FPMath == FP_387 && SSELevel >= SSE1) {
Diags.Report(diag::err_target_unsupported_fpmath) << "387";
return false;
}
// Don't tell the backend if we're turning off mmx; it will end up disabling
// SSE, which we don't want.
// Additionally, if SSE is enabled and mmx is not explicitly disabled,
// then enable MMX.
std::vector<std::string>::iterator it;
it = std::find(Features.begin(), Features.end(), "-mmx");
if (it != Features.end())
Features.erase(it);
else if (SSELevel > NoSSE)
MMX3DNowLevel = std::max(MMX3DNowLevel, MMX);
SimdDefaultAlign =
hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
return true;
}
/// X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro
/// definitions for this particular subtarget.
void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
// Target identification.
if (getTriple().getArch() == llvm::Triple::x86_64) {
Builder.defineMacro("__amd64__");
Builder.defineMacro("__amd64");
Builder.defineMacro("__x86_64");
Builder.defineMacro("__x86_64__");
if (getTriple().getArchName() == "x86_64h") {
Builder.defineMacro("__x86_64h");
Builder.defineMacro("__x86_64h__");
}
} else {
DefineStd(Builder, "i386", Opts);
}
// Subtarget options.
// FIXME: We are hard-coding the tune parameters based on the CPU, but they
// truly should be based on -mtune options.
switch (CPU) {
case CK_Generic:
break;
case CK_i386:
// The rest are coming from the i386 define above.
Builder.defineMacro("__tune_i386__");
break;
case CK_i486:
case CK_WinChipC6:
case CK_WinChip2:
case CK_C3:
defineCPUMacros(Builder, "i486");
break;
case CK_PentiumMMX:
Builder.defineMacro("__pentium_mmx__");
Builder.defineMacro("__tune_pentium_mmx__");
// Fallthrough
case CK_i586:
case CK_Pentium:
defineCPUMacros(Builder, "i586");
defineCPUMacros(Builder, "pentium");
break;
case CK_Pentium3:
case CK_Pentium3M:
case CK_PentiumM:
Builder.defineMacro("__tune_pentium3__");
// Fallthrough
case CK_Pentium2:
case CK_C3_2:
Builder.defineMacro("__tune_pentium2__");
// Fallthrough
case CK_PentiumPro:
Builder.defineMacro("__tune_i686__");
Builder.defineMacro("__tune_pentiumpro__");
// Fallthrough
case CK_i686:
Builder.defineMacro("__i686");
Builder.defineMacro("__i686__");
// Strangely, __tune_i686__ isn't defined by GCC when CPU == i686.
Builder.defineMacro("__pentiumpro");
Builder.defineMacro("__pentiumpro__");
break;
case CK_Pentium4:
case CK_Pentium4M:
defineCPUMacros(Builder, "pentium4");
break;
case CK_Yonah:
case CK_Prescott:
case CK_Nocona:
defineCPUMacros(Builder, "nocona");
break;
case CK_Core2:
case CK_Penryn:
defineCPUMacros(Builder, "core2");
break;
case CK_Bonnell:
defineCPUMacros(Builder, "atom");
break;
case CK_Silvermont:
defineCPUMacros(Builder, "slm");
break;
case CK_Nehalem:
case CK_Westmere:
case CK_SandyBridge:
case CK_IvyBridge:
case CK_Haswell:
case CK_Broadwell:
// FIXME: Historically, we defined this legacy name, it would be nice to
// remove it at some point. We've never exposed fine-grained names for
// recent primary x86 CPUs, and we should keep it that way.
defineCPUMacros(Builder, "corei7");
break;
case CK_Skylake:
// FIXME: Historically, we defined this legacy name, it would be nice to
// remove it at some point. This is the only fine-grained CPU macro in the
// main intel CPU line, and it would be better to not have these and force
// people to use ISA macros.
defineCPUMacros(Builder, "skx");
break;
case CK_KNL:
defineCPUMacros(Builder, "knl");
break;
case CK_K6_2:
Builder.defineMacro("__k6_2__");
Builder.defineMacro("__tune_k6_2__");
// Fallthrough
case CK_K6_3:
if (CPU != CK_K6_2) { // In case of fallthrough
// FIXME: GCC may be enabling these in cases where some other k6
// architecture is specified but -m3dnow is explicitly provided. The
// exact semantics need to be determined and emulated here.
Builder.defineMacro("__k6_3__");
Builder.defineMacro("__tune_k6_3__");
}
// Fallthrough
case CK_K6:
defineCPUMacros(Builder, "k6");
break;
case CK_Athlon:
case CK_AthlonThunderbird:
case CK_Athlon4:
case CK_AthlonXP:
case CK_AthlonMP:
defineCPUMacros(Builder, "athlon");
if (SSELevel != NoSSE) {
Builder.defineMacro("__athlon_sse__");
Builder.defineMacro("__tune_athlon_sse__");
}
break;
case CK_K8:
case CK_K8SSE3:
case CK_x86_64:
case CK_Opteron:
case CK_OpteronSSE3:
case CK_Athlon64:
case CK_Athlon64SSE3:
case CK_AthlonFX:
defineCPUMacros(Builder, "k8");
break;
case CK_AMDFAM10:
defineCPUMacros(Builder, "amdfam10");
break;
case CK_BTVER1:
defineCPUMacros(Builder, "btver1");
break;
case CK_BTVER2:
defineCPUMacros(Builder, "btver2");
break;
case CK_BDVER1:
defineCPUMacros(Builder, "bdver1");
break;
case CK_BDVER2:
defineCPUMacros(Builder, "bdver2");
break;
case CK_BDVER3:
defineCPUMacros(Builder, "bdver3");
break;
case CK_BDVER4:
defineCPUMacros(Builder, "bdver4");
break;
case CK_Geode:
defineCPUMacros(Builder, "geode");
break;
}
// Target properties.
Builder.defineMacro("__REGISTER_PREFIX__", "");
// Define __NO_MATH_INLINES on linux/x86 so that we don't get inline
// functions in glibc header files that use FP Stack inline asm which the
// backend can't deal with (PR879).
Builder.defineMacro("__NO_MATH_INLINES");
if (HasAES)
Builder.defineMacro("__AES__");
if (HasPCLMUL)
Builder.defineMacro("__PCLMUL__");
if (HasLZCNT)
Builder.defineMacro("__LZCNT__");
if (HasRDRND)
Builder.defineMacro("__RDRND__");
if (HasFSGSBASE)
Builder.defineMacro("__FSGSBASE__");
if (HasBMI)
Builder.defineMacro("__BMI__");
if (HasBMI2)
Builder.defineMacro("__BMI2__");
if (HasPOPCNT)
Builder.defineMacro("__POPCNT__");
if (HasRTM)
Builder.defineMacro("__RTM__");
if (HasPRFCHW)
Builder.defineMacro("__PRFCHW__");
if (HasRDSEED)
Builder.defineMacro("__RDSEED__");
if (HasADX)
Builder.defineMacro("__ADX__");
if (HasTBM)
Builder.defineMacro("__TBM__");
switch (XOPLevel) {
case XOP:
Builder.defineMacro("__XOP__");
case FMA4:
Builder.defineMacro("__FMA4__");
case SSE4A:
Builder.defineMacro("__SSE4A__");
case NoXOP:
break;
}
if (HasFMA)
Builder.defineMacro("__FMA__");
if (HasF16C)
Builder.defineMacro("__F16C__");
if (HasAVX512CD)
Builder.defineMacro("__AVX512CD__");
if (HasAVX512ER)
Builder.defineMacro("__AVX512ER__");
if (HasAVX512PF)
Builder.defineMacro("__AVX512PF__");
if (HasAVX512DQ)
Builder.defineMacro("__AVX512DQ__");
if (HasAVX512BW)
Builder.defineMacro("__AVX512BW__");
if (HasAVX512VL)
Builder.defineMacro("__AVX512VL__");
if (HasSHA)
Builder.defineMacro("__SHA__");
if (HasCX16)
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
// Each case falls through to the previous one here.
switch (SSELevel) {
case AVX512F:
Builder.defineMacro("__AVX512F__");
case AVX2:
Builder.defineMacro("__AVX2__");
case AVX:
Builder.defineMacro("__AVX__");
case SSE42:
Builder.defineMacro("__SSE4_2__");
case SSE41:
Builder.defineMacro("__SSE4_1__");
case SSSE3:
Builder.defineMacro("__SSSE3__");
case SSE3:
Builder.defineMacro("__SSE3__");
case SSE2:
Builder.defineMacro("__SSE2__");
Builder.defineMacro("__SSE2_MATH__"); // -mfp-math=sse always implied.
case SSE1:
Builder.defineMacro("__SSE__");
Builder.defineMacro("__SSE_MATH__"); // -mfp-math=sse always implied.
case NoSSE:
break;
}
if (Opts.MicrosoftExt && getTriple().getArch() == llvm::Triple::x86) {
switch (SSELevel) {
case AVX512F:
case AVX2:
case AVX:
case SSE42:
case SSE41:
case SSSE3:
case SSE3:
case SSE2:
Builder.defineMacro("_M_IX86_FP", Twine(2));
break;
case SSE1:
Builder.defineMacro("_M_IX86_FP", Twine(1));
break;
default:
Builder.defineMacro("_M_IX86_FP", Twine(0));
}
}
// Each case falls through to the previous one here.
switch (MMX3DNowLevel) {
case AMD3DNowAthlon:
Builder.defineMacro("__3dNOW_A__");
case AMD3DNow:
Builder.defineMacro("__3dNOW__");
case MMX:
Builder.defineMacro("__MMX__");
case NoMMX3DNow:
break;
}
if (CPU >= CK_i486) {
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
}
if (CPU >= CK_i586)
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
}
bool X86TargetInfo::hasFeature(StringRef Feature) const {
return llvm::StringSwitch<bool>(Feature)
.Case("aes", HasAES)
.Case("avx", SSELevel >= AVX)
.Case("avx2", SSELevel >= AVX2)
.Case("avx512f", SSELevel >= AVX512F)
.Case("avx512cd", HasAVX512CD)
.Case("avx512er", HasAVX512ER)
.Case("avx512pf", HasAVX512PF)
.Case("avx512dq", HasAVX512DQ)
.Case("avx512bw", HasAVX512BW)
.Case("avx512vl", HasAVX512VL)
.Case("bmi", HasBMI)
.Case("bmi2", HasBMI2)
.Case("cx16", HasCX16)
.Case("f16c", HasF16C)
.Case("fma", HasFMA)
.Case("fma4", XOPLevel >= FMA4)
.Case("fsgsbase", HasFSGSBASE)
.Case("lzcnt", HasLZCNT)
.Case("mm3dnow", MMX3DNowLevel >= AMD3DNow)
.Case("mm3dnowa", MMX3DNowLevel >= AMD3DNowAthlon)
.Case("mmx", MMX3DNowLevel >= MMX)
.Case("pclmul", HasPCLMUL)
.Case("popcnt", HasPOPCNT)
.Case("prfchw", HasPRFCHW)
.Case("rdrnd", HasRDRND)
.Case("rdseed", HasRDSEED)
.Case("rtm", HasRTM)
.Case("sha", HasSHA)
.Case("sse", SSELevel >= SSE1)
.Case("sse2", SSELevel >= SSE2)
.Case("sse3", SSELevel >= SSE3)
.Case("ssse3", SSELevel >= SSSE3)
.Case("sse4.1", SSELevel >= SSE41)
.Case("sse4.2", SSELevel >= SSE42)
.Case("sse4a", XOPLevel >= SSE4A)
.Case("tbm", HasTBM)
.Case("x86", true)
.Case("x86_32", getTriple().getArch() == llvm::Triple::x86)
.Case("x86_64", getTriple().getArch() == llvm::Triple::x86_64)
.Case("xop", XOPLevel >= XOP)
.Default(false);
}
// We can't use a generic validation scheme for the features accepted here
// versus subtarget features accepted in the target attribute because the
// bitfield structure that's initialized in the runtime only supports the
// below currently rather than the full range of subtarget features. (See
// X86TargetInfo::hasFeature for a somewhat comprehensive list).
bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const {
return llvm::StringSwitch<bool>(FeatureStr)
.Case("cmov", true)
.Case("mmx", true)
.Case("popcnt", true)
.Case("sse", true)
.Case("sse2", true)
.Case("sse3", true)
.Case("sse4.1", true)
.Case("sse4.2", true)
.Case("avx", true)
.Case("avx2", true)
.Case("sse4a", true)
.Case("fma4", true)
.Case("xop", true)
.Case("fma", true)
.Case("avx512f", true)
.Case("bmi", true)
.Case("bmi2", true)
.Default(false);
}
bool
X86TargetInfo::validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const {
switch (*Name) {
default: return false;
// Constant constraints.
case 'e': // 32-bit signed integer constant for use with sign-extending x86_64
// instructions.
case 'Z': // 32-bit unsigned integer constant for use with zero-extending
// x86_64 instructions.
case 's':
Info.setRequiresImmediate();
return true;
case 'I':
Info.setRequiresImmediate(0, 31);
return true;
case 'J':
Info.setRequiresImmediate(0, 63);
return true;
case 'K':
Info.setRequiresImmediate(-128, 127);
return true;
case 'L':
Info.setRequiresImmediate({ int(0xff), int(0xffff), int(0xffffffff) });
return true;
case 'M':
Info.setRequiresImmediate(0, 3);
return true;
case 'N':
Info.setRequiresImmediate(0, 255);
return true;
case 'O':
Info.setRequiresImmediate(0, 127);
return true;
// Register constraints.
case 'Y': // 'Y' is the first character for several 2-character constraints.
// Shift the pointer to the second character of the constraint.
Name++;
switch (*Name) {
default:
return false;
case '0': // First SSE register.
case 't': // Any SSE register, when SSE2 is enabled.
case 'i': // Any SSE register, when SSE2 and inter-unit moves enabled.
case 'm': // Any MMX register, when inter-unit moves enabled.
Info.setAllowsRegister();
return true;
}
case 'f': // Any x87 floating point stack register.
// Constraint 'f' cannot be used for output operands.
if (Info.ConstraintStr[0] == '=')
return false;
Info.setAllowsRegister();
return true;
case 'a': // eax.
case 'b': // ebx.
case 'c': // ecx.
case 'd': // edx.
case 'S': // esi.
case 'D': // edi.
case 'A': // edx:eax.
case 't': // Top of floating point stack.
case 'u': // Second from top of floating point stack.
case 'q': // Any register accessible as [r]l: a, b, c, and d.
case 'y': // Any MMX register.
case 'x': // Any SSE register.
case 'Q': // Any register accessible as [r]h: a, b, c, and d.
case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
case 'l': // "Index" registers: any general register that can be used as an
// index in a base+index memory access.
Info.setAllowsRegister();
return true;
// Floating point constant constraints.
case 'C': // SSE floating point constant.
case 'G': // x87 floating point constant.
return true;
}
}
bool X86TargetInfo::validateOutputSize(StringRef Constraint,
unsigned Size) const {
// Strip off constraint modifiers.
while (Constraint[0] == '=' ||
Constraint[0] == '+' ||
Constraint[0] == '&')
Constraint = Constraint.substr(1);
return validateOperandSize(Constraint, Size);
}
bool X86TargetInfo::validateInputSize(StringRef Constraint,
unsigned Size) const {
return validateOperandSize(Constraint, Size);
}
bool X86TargetInfo::validateOperandSize(StringRef Constraint,
unsigned Size) const {
switch (Constraint[0]) {
default: break;
case 'y':
return Size <= 64;
case 'f':
case 't':
case 'u':
return Size <= 128;
case 'x':
if (SSELevel >= AVX512F)
// 512-bit zmm registers can be used if target supports AVX512F.
return Size <= 512U;
else if (SSELevel >= AVX)
// 256-bit ymm registers can be used if target supports AVX.
return Size <= 256U;
return Size <= 128U;
case 'Y':
// 'Y' is the first character for several 2-character constraints.
switch (Constraint[1]) {
default: break;
case 'm':
// 'Ym' is synonymous with 'y'.
return Size <= 64;
case 'i':
case 't':
// 'Yi' and 'Yt' are synonymous with 'x' when SSE2 is enabled.
if (SSELevel >= AVX512F)
return Size <= 512U;
else if (SSELevel >= AVX)
return Size <= 256U;
return SSELevel >= SSE2 && Size <= 128U;
}
}
return true;
}
std::string
X86TargetInfo::convertConstraint(const char *&Constraint) const {
switch (*Constraint) {
case 'a': return std::string("{ax}");
case 'b': return std::string("{bx}");
case 'c': return std::string("{cx}");
case 'd': return std::string("{dx}");
case 'S': return std::string("{si}");
case 'D': return std::string("{di}");
case 'p': // address
return std::string("im");
case 't': // top of floating point stack.
return std::string("{st}");
case 'u': // second from top of floating point stack.
return std::string("{st(1)}"); // second from top of floating point stack.
default:
return std::string(1, *Constraint);
}
}
// X86-32 generic target
class X86_32TargetInfo : public X86TargetInfo {
public:
X86_32TargetInfo(const llvm::Triple &Triple) : X86TargetInfo(Triple) {
DoubleAlign = LongLongAlign = 32;
LongDoubleWidth = 96;
LongDoubleAlign = 32;
SuitableAlign = 128;
DataLayoutString = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128";
SizeType = UnsignedInt;
PtrDiffType = SignedInt;
IntPtrType = SignedInt;
RegParmMax = 3;
// Use fpret for all types.
RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
(1 << TargetInfo::Double) |
(1 << TargetInfo::LongDouble));
// x86-32 has atomics up to 8 bytes
// FIXME: Check that we actually have cmpxchg8b before setting
// MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
int getEHDataRegisterNumber(unsigned RegNo) const override {
if (RegNo == 0) return 0;
if (RegNo == 1) return 2;
return -1;
}
bool validateOperandSize(StringRef Constraint,
unsigned Size) const override {
switch (Constraint[0]) {
default: break;
case 'R':
case 'q':
case 'Q':
case 'a':
case 'b':
case 'c':
case 'd':
case 'S':
case 'D':
return Size <= 32;
case 'A':
return Size <= 64;
}
return X86TargetInfo::validateOperandSize(Constraint, Size);
}
};
class NetBSDI386TargetInfo : public NetBSDTargetInfo<X86_32TargetInfo> {
public:
NetBSDI386TargetInfo(const llvm::Triple &Triple)
: NetBSDTargetInfo<X86_32TargetInfo>(Triple) {}
unsigned getFloatEvalMethod() const override {
unsigned Major, Minor, Micro;
getTriple().getOSVersion(Major, Minor, Micro);
// New NetBSD uses the default rounding mode.
if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 26) || Major == 0)
return X86_32TargetInfo::getFloatEvalMethod();
// NetBSD before 6.99.26 defaults to "double" rounding.
return 1;
}
};
class OpenBSDI386TargetInfo : public OpenBSDTargetInfo<X86_32TargetInfo> {
public:
OpenBSDI386TargetInfo(const llvm::Triple &Triple)
: OpenBSDTargetInfo<X86_32TargetInfo>(Triple) {
SizeType = UnsignedLong;
IntPtrType = SignedLong;
PtrDiffType = SignedLong;
}
};
class BitrigI386TargetInfo : public BitrigTargetInfo<X86_32TargetInfo> {
public:
BitrigI386TargetInfo(const llvm::Triple &Triple)
: BitrigTargetInfo<X86_32TargetInfo>(Triple) {
SizeType = UnsignedLong;
IntPtrType = SignedLong;
PtrDiffType = SignedLong;
}
};
class DarwinI386TargetInfo : public DarwinTargetInfo<X86_32TargetInfo> {
public:
DarwinI386TargetInfo(const llvm::Triple &Triple)
: DarwinTargetInfo<X86_32TargetInfo>(Triple) {
LongDoubleWidth = 128;
LongDoubleAlign = 128;
SuitableAlign = 128;
SizeType = UnsignedLong;
IntPtrType = SignedLong;
DataLayoutString = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128";
HasAlignMac68kSupport = true;
}
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
if (!DarwinTargetInfo<X86_32TargetInfo>::handleTargetFeatures(Features,
Diags))
return false;
// We now know the features we have: we can decide how to align vectors.
MaxVectorAlign =
hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
return true;
}
};
// x86-32 Windows target
class WindowsX86_32TargetInfo : public WindowsTargetInfo<X86_32TargetInfo> {
public:
WindowsX86_32TargetInfo(const llvm::Triple &Triple)
: WindowsTargetInfo<X86_32TargetInfo>(Triple) {
WCharType = UnsignedShort;
DoubleAlign = LongLongAlign = 64;
bool IsWinCOFF =
getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
DataLayoutString = IsWinCOFF
? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
: "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsTargetInfo<X86_32TargetInfo>::getTargetDefines(Opts, Builder);
}
};
// x86-32 Windows Visual Studio target
class MicrosoftX86_32TargetInfo : public WindowsX86_32TargetInfo {
public:
MicrosoftX86_32TargetInfo(const llvm::Triple &Triple)
: WindowsX86_32TargetInfo(Triple) {
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
WindowsX86_32TargetInfo::getVisualStudioDefines(Opts, Builder);
// The value of the following reflects processor type.
// 300=386, 400=486, 500=Pentium, 600=Blend (default)
// We lost the original triple, so we use the default.
Builder.defineMacro("_M_IX86", "600");
}
};
} // end anonymous namespace
static void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
// Mingw and cygwin define __declspec(a) to __attribute__((a)). Clang supports
// __declspec natively under -fms-extensions, but we define a no-op __declspec
// macro anyway for pre-processor compatibility.
if (Opts.MicrosoftExt)
Builder.defineMacro("__declspec", "__declspec");
else
Builder.defineMacro("__declspec(a)", "__attribute__((a))");
if (!Opts.MicrosoftExt) {
// Provide macros for all the calling convention keywords. Provide both
// single and double underscore prefixed variants. These are available on
// x64 as well as x86, even though they have no effect.
const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"};
for (const char *CC : CCs) {
std::string GCCSpelling = "__attribute__((__";
GCCSpelling += CC;
GCCSpelling += "__))";
Builder.defineMacro(Twine("_") + CC, GCCSpelling);
Builder.defineMacro(Twine("__") + CC, GCCSpelling);
}
}
}
static void addMinGWDefines(const LangOptions &Opts, MacroBuilder &Builder) {
Builder.defineMacro("__MSVCRT__");
Builder.defineMacro("__MINGW32__");
addCygMingDefines(Opts, Builder);
}
namespace {
// x86-32 MinGW target
class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo {
public:
MinGWX86_32TargetInfo(const llvm::Triple &Triple)
: WindowsX86_32TargetInfo(Triple) {}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
DefineStd(Builder, "WIN32", Opts);
DefineStd(Builder, "WINNT", Opts);
Builder.defineMacro("_X86_");
addMinGWDefines(Opts, Builder);
}
};
// x86-32 Cygwin target
class CygwinX86_32TargetInfo : public X86_32TargetInfo {
public:
CygwinX86_32TargetInfo(const llvm::Triple &Triple)
: X86_32TargetInfo(Triple) {
TLSSupported = false;
WCharType = UnsignedShort;
DoubleAlign = LongLongAlign = 64;
DataLayoutString = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
X86_32TargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("_X86_");
Builder.defineMacro("__CYGWIN__");
Builder.defineMacro("__CYGWIN32__");
addCygMingDefines(Opts, Builder);
DefineStd(Builder, "unix", Opts);
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
}
};
// x86-32 Haiku target
class HaikuX86_32TargetInfo : public X86_32TargetInfo {
public:
HaikuX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
SizeType = UnsignedLong;
IntPtrType = SignedLong;
PtrDiffType = SignedLong;
ProcessIDType = SignedLong;
this->UserLabelPrefix = "";
this->TLSSupported = false;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
X86_32TargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("__INTEL__");
Builder.defineMacro("__HAIKU__");
}
};
// RTEMS Target
template<typename Target>
class RTEMSTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
// RTEMS defines; list based off of gcc output
Builder.defineMacro("__rtems__");
Builder.defineMacro("__ELF__");
}
public:
RTEMSTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
switch (Triple.getArch()) {
default:
case llvm::Triple::x86:
// this->MCountName = ".mcount";
break;
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
// this->MCountName = "_mcount";
break;
case llvm::Triple::arm:
// this->MCountName = "__mcount";
break;
}
}
};
// x86-32 RTEMS target
class RTEMSX86_32TargetInfo : public X86_32TargetInfo {
public:
RTEMSX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
SizeType = UnsignedLong;
IntPtrType = SignedLong;
PtrDiffType = SignedLong;
this->UserLabelPrefix = "";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
X86_32TargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("__INTEL__");
Builder.defineMacro("__rtems__");
}
};
// x86-64 generic target
class X86_64TargetInfo : public X86TargetInfo {
public:
X86_64TargetInfo(const llvm::Triple &Triple) : X86TargetInfo(Triple) {
const bool IsX32 = getTriple().getEnvironment() == llvm::Triple::GNUX32;
bool IsWinCOFF =
getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 32 : 64;
LongDoubleWidth = 128;
LongDoubleAlign = 128;
LargeArrayMinWidth = 128;
LargeArrayAlign = 128;
SuitableAlign = 128;
SizeType = IsX32 ? UnsignedInt : UnsignedLong;
PtrDiffType = IsX32 ? SignedInt : SignedLong;
IntPtrType = IsX32 ? SignedInt : SignedLong;
IntMaxType = IsX32 ? SignedLongLong : SignedLong;
Int64Type = IsX32 ? SignedLongLong : SignedLong;
RegParmMax = 6;
// Pointers are 32-bit in x32.
DataLayoutString = IsX32 ? "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128"
: IsWinCOFF
? "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
: "e-m:e-i64:64-f80:128-n8:16:32:64-S128";
// Use fpret only for long double.
RealTypeUsesObjCFPRet = (1 << TargetInfo::LongDouble);
// Use fp2ret for _Complex long double.
ComplexLongDoubleUsesFP2Ret = true;
// x86-64 has atomics up to 16 bytes.
MaxAtomicPromoteWidth = 128;
MaxAtomicInlineWidth = 128;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::X86_64ABIBuiltinVaList;
}
int getEHDataRegisterNumber(unsigned RegNo) const override {
if (RegNo == 0) return 0;
if (RegNo == 1) return 1;
return -1;
}
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
return (CC == CC_C ||
CC == CC_X86VectorCall ||
CC == CC_IntelOclBicc ||
CC == CC_X86_64Win64) ? CCCR_OK : CCCR_Warning;
}
CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override {
return CC_C;
}
// for x32 we need it here explicitly
bool hasInt128Type() const override { return true; }
};
// x86-64 Windows target
class WindowsX86_64TargetInfo : public WindowsTargetInfo<X86_64TargetInfo> {
public:
WindowsX86_64TargetInfo(const llvm::Triple &Triple)
: WindowsTargetInfo<X86_64TargetInfo>(Triple) {
WCharType = UnsignedShort;
LongWidth = LongAlign = 32;
DoubleAlign = LongLongAlign = 64;
IntMaxType = SignedLongLong;
Int64Type = SignedLongLong;
SizeType = UnsignedLongLong;
PtrDiffType = SignedLongLong;
IntPtrType = SignedLongLong;
this->UserLabelPrefix = "";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsTargetInfo<X86_64TargetInfo>::getTargetDefines(Opts, Builder);
Builder.defineMacro("_WIN64");
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
switch (CC) {
case CC_X86StdCall:
case CC_X86ThisCall:
case CC_X86FastCall:
return CCCR_Ignore;
case CC_C:
case CC_X86VectorCall:
case CC_IntelOclBicc:
case CC_X86_64SysV:
return CCCR_OK;
default:
return CCCR_Warning;
}
}
};
// x86-64 Windows Visual Studio target
class MicrosoftX86_64TargetInfo : public WindowsX86_64TargetInfo {
public:
MicrosoftX86_64TargetInfo(const llvm::Triple &Triple)
: WindowsX86_64TargetInfo(Triple) {
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
WindowsX86_64TargetInfo::getVisualStudioDefines(Opts, Builder);
Builder.defineMacro("_M_X64", "100");
Builder.defineMacro("_M_AMD64", "100");
}
};
// x86-64 MinGW target
class MinGWX86_64TargetInfo : public WindowsX86_64TargetInfo {
public:
MinGWX86_64TargetInfo(const llvm::Triple &Triple)
: WindowsX86_64TargetInfo(Triple) {}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
DefineStd(Builder, "WIN64", Opts);
Builder.defineMacro("__MINGW64__");
addMinGWDefines(Opts, Builder);
// GCC defines this macro when it is using __gxx_personality_seh0.
if (!Opts.SjLjExceptions)
Builder.defineMacro("__SEH__");
}
};
// x86-64 Cygwin target
class CygwinX86_64TargetInfo : public X86_64TargetInfo {
public:
CygwinX86_64TargetInfo(const llvm::Triple &Triple)
: X86_64TargetInfo(Triple) {
TLSSupported = false;
WCharType = UnsignedShort;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
X86_64TargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("__x86_64__");
Builder.defineMacro("__CYGWIN__");
Builder.defineMacro("__CYGWIN64__");
addCygMingDefines(Opts, Builder);
DefineStd(Builder, "unix", Opts);
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
// GCC defines this macro when it is using __gxx_personality_seh0.
if (!Opts.SjLjExceptions)
Builder.defineMacro("__SEH__");
}
};
class DarwinX86_64TargetInfo : public DarwinTargetInfo<X86_64TargetInfo> {
public:
DarwinX86_64TargetInfo(const llvm::Triple &Triple)
: DarwinTargetInfo<X86_64TargetInfo>(Triple) {
Int64Type = SignedLongLong;
// The 64-bit iOS simulator uses the builtin bool type for Objective-C.
llvm::Triple T = llvm::Triple(Triple);
if (T.isiOS())
UseSignedCharForObjCBool = false;
DataLayoutString = "e-m:o-i64:64-f80:128-n8:16:32:64-S128";
}
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
if (!DarwinTargetInfo<X86_64TargetInfo>::handleTargetFeatures(Features,
Diags))
return false;
// We now know the features we have: we can decide how to align vectors.
MaxVectorAlign =
hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
return true;
}
};
class OpenBSDX86_64TargetInfo : public OpenBSDTargetInfo<X86_64TargetInfo> {
public:
OpenBSDX86_64TargetInfo(const llvm::Triple &Triple)
: OpenBSDTargetInfo<X86_64TargetInfo>(Triple) {
IntMaxType = SignedLongLong;
Int64Type = SignedLongLong;
}
};
class BitrigX86_64TargetInfo : public BitrigTargetInfo<X86_64TargetInfo> {
public:
BitrigX86_64TargetInfo(const llvm::Triple &Triple)
: BitrigTargetInfo<X86_64TargetInfo>(Triple) {
IntMaxType = SignedLongLong;
Int64Type = SignedLongLong;
}
};
class ARMTargetInfo : public TargetInfo {
// Possible FPU choices.
enum FPUMode {
VFP2FPU = (1 << 0),
VFP3FPU = (1 << 1),
VFP4FPU = (1 << 2),
NeonFPU = (1 << 3),
FPARMV8 = (1 << 4)
};
// Possible HWDiv features.
enum HWDivMode {
HWDivThumb = (1 << 0),
HWDivARM = (1 << 1)
};
static bool FPUModeIsVFP(FPUMode Mode) {
return Mode & (VFP2FPU | VFP3FPU | VFP4FPU | NeonFPU | FPARMV8);
}
static const TargetInfo::GCCRegAlias GCCRegAliases[];
static const char * const GCCRegNames[];
std::string ABI, CPU;
StringRef DefaultCPU;
StringRef CPUProfile;
StringRef CPUAttr;
enum {
FP_Default,
FP_VFP,
FP_Neon
} FPMath;
unsigned ArchISA;
unsigned ArchKind;
unsigned ArchProfile;
unsigned ArchVersion;
unsigned FPU : 5;
unsigned IsAAPCS : 1;
unsigned HWDiv : 2;
// Initialized via features.
unsigned SoftFloat : 1;
unsigned SoftFloatABI : 1;
unsigned CRC : 1;
unsigned Crypto : 1;
// ACLE 6.5.1 Hardware floating point
enum {
HW_FP_HP = (1 << 1), /// half (16-bit)
HW_FP_SP = (1 << 2), /// single (32-bit)
HW_FP_DP = (1 << 3), /// double (64-bit)
};
uint32_t HW_FP;
static const Builtin::Info BuiltinInfo[];
void setABIAAPCS() {
IsAAPCS = true;
DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
const llvm::Triple &T = getTriple();
// size_t is unsigned long on MachO-derived environments, NetBSD and Bitrig.
if (T.isOSBinFormatMachO() || T.getOS() == llvm::Triple::NetBSD ||
T.getOS() == llvm::Triple::Bitrig)
SizeType = UnsignedLong;
else
SizeType = UnsignedInt;
switch (T.getOS()) {
case llvm::Triple::NetBSD:
WCharType = SignedInt;
break;
case llvm::Triple::Win32:
WCharType = UnsignedShort;
break;
case llvm::Triple::Linux:
default:
// AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int.
WCharType = UnsignedInt;
break;
}
UseBitFieldTypeAlignment = true;
ZeroLengthBitfieldBoundary = 0;
// Thumb1 add sp, #imm requires the immediate value be multiple of 4,
// so set preferred for small types to 32.
if (T.isOSBinFormatMachO()) {
DataLayoutString =
BigEndian ? "E-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
: "e-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64";
} else if (T.isOSWindows()) {
assert(!BigEndian && "Windows on ARM does not support big endian");
DataLayoutString = "e"
"-m:w"
"-p:32:32"
"-i64:64"
"-v128:64:128"
"-a:0:32"
"-n32"
"-S64";
} else if (T.isOSNaCl()) {
assert(!BigEndian && "NaCl on ARM does not support big endian");
DataLayoutString = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S128";
} else {
DataLayoutString =
BigEndian ? "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64";
}
// FIXME: Enumerated types are variable width in straight AAPCS.
}
void setABIAPCS() {
const llvm::Triple &T = getTriple();
IsAAPCS = false;
DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32;
// size_t is unsigned int on FreeBSD.
if (T.getOS() == llvm::Triple::FreeBSD)
SizeType = UnsignedInt;
else
SizeType = UnsignedLong;
// Revert to using SignedInt on apcs-gnu to comply with existing behaviour.
WCharType = SignedInt;
// Do not respect the alignment of bit-field types when laying out
// structures. This corresponds to PCC_BITFIELD_TYPE_MATTERS in gcc.
UseBitFieldTypeAlignment = false;
/// gcc forces the alignment to 4 bytes, regardless of the type of the
/// zero length bitfield. This corresponds to EMPTY_FIELD_BOUNDARY in
/// gcc.
ZeroLengthBitfieldBoundary = 32;
if (T.isOSBinFormatMachO())
DataLayoutString =
BigEndian
? "E-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32";
else
DataLayoutString =
BigEndian
? "E-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
: "e-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32";
// FIXME: Override "preferred align" for double and long long.
}
void setArchInfo() {
StringRef ArchName = getTriple().getArchName();
ArchISA = llvm::ARM::parseArchISA(ArchName);
DefaultCPU = getDefaultCPU(ArchName);
unsigned ArchKind = llvm::ARM::parseArch(ArchName);
if (ArchKind == llvm::ARM::AK_INVALID)
// set arch of the CPU, either provided explicitly or hardcoded default
ArchKind = llvm::ARM::parseCPUArch(CPU);
setArchInfo(ArchKind);
}
void setArchInfo(unsigned Kind) {
StringRef SubArch;
// cache TargetParser info
ArchKind = Kind;
SubArch = llvm::ARM::getSubArch(ArchKind);
ArchProfile = llvm::ARM::parseArchProfile(SubArch);
ArchVersion = llvm::ARM::parseArchVersion(SubArch);
// cache CPU related strings
CPUAttr = getCPUAttr();
CPUProfile = getCPUProfile();
}
void setAtomic() {
// when triple does not specify a sub arch,
// then we are not using inline atomics
bool ShouldUseInlineAtomic = DefaultCPU.empty() ?
false :
(ArchISA == llvm::ARM::IK_ARM && ArchVersion >= 6) ||
(ArchISA == llvm::ARM::IK_THUMB && ArchVersion >= 7);
// Cortex M does not support 8 byte atomics, while general Thumb2 does.
if (ArchProfile == llvm::ARM::PK_M) {
MaxAtomicPromoteWidth = 32;
if (ShouldUseInlineAtomic)
MaxAtomicInlineWidth = 32;
}
else {
MaxAtomicPromoteWidth = 64;
if (ShouldUseInlineAtomic)
MaxAtomicInlineWidth = 64;
}
}
bool isThumb() const {
return (ArchISA == llvm::ARM::IK_THUMB);
}
bool supportsThumb() const {
return CPUAttr.count('T') || ArchVersion >= 6;
}
bool supportsThumb2() const {
return CPUAttr.equals("6T2") || ArchVersion >= 7;
}
StringRef getDefaultCPU(StringRef ArchName) const {
return llvm::ARM::getDefaultCPU(ArchName);
}
StringRef getCPUAttr() const {
// For most sub-arches, the build attribute CPU name is enough.
// For Cortex variants, it's slightly different.
switch(ArchKind) {
default:
return llvm::ARM::getCPUAttr(ArchKind);
case llvm::ARM::AK_ARMV6M:
case llvm::ARM::AK_ARMV6SM:
case llvm::ARM::AK_ARMV6HL:
return "6M";
case llvm::ARM::AK_ARMV7S:
return "7S";
case llvm::ARM::AK_ARMV7:
case llvm::ARM::AK_ARMV7A:
case llvm::ARM::AK_ARMV7L:
case llvm::ARM::AK_ARMV7HL:
return "7A";
case llvm::ARM::AK_ARMV7R:
return "7R";
case llvm::ARM::AK_ARMV7M:
return "7M";
case llvm::ARM::AK_ARMV7EM:
return "7EM";
case llvm::ARM::AK_ARMV8A:
return "8A";
case llvm::ARM::AK_ARMV8_1A:
return "8_1A";
}
}
StringRef getCPUProfile() const {
switch(ArchProfile) {
case llvm::ARM::PK_A:
return "A";
case llvm::ARM::PK_R:
return "R";
case llvm::ARM::PK_M:
return "M";
default:
return "";
}
}
public:
ARMTargetInfo(const llvm::Triple &Triple, bool IsBigEndian)
: TargetInfo(Triple), CPU("arm1136j-s"), FPMath(FP_Default),
IsAAPCS(true), HW_FP(0) {
BigEndian = IsBigEndian;
switch (getTriple().getOS()) {
case llvm::Triple::NetBSD:
PtrDiffType = SignedLong;
break;
default:
PtrDiffType = SignedInt;
break;
}
// cache arch related info
setArchInfo();
// {} in inline assembly are neon specifiers, not assembly variant
// specifiers.
NoAsmVariants = true;
// FIXME: This duplicates code from the driver that sets the -target-abi
// option - this code is used if -target-abi isn't passed and should
// be unified in some way.
if (Triple.isOSBinFormatMachO()) {
// The backend is hardwired to assume AAPCS for M-class processors, ensure
// the frontend matches that.
if (Triple.getEnvironment() == llvm::Triple::EABI ||
Triple.getOS() == llvm::Triple::UnknownOS ||
StringRef(CPU).startswith("cortex-m")) {
setABI("aapcs");
} else {
setABI("apcs-gnu");
}
} else if (Triple.isOSWindows()) {
// FIXME: this is invalid for WindowsCE
setABI("aapcs");
} else {
// Select the default based on the platform.
switch (Triple.getEnvironment()) {
case llvm::Triple::Android:
case llvm::Triple::GNUEABI:
case llvm::Triple::GNUEABIHF:
setABI("aapcs-linux");
break;
case llvm::Triple::EABIHF:
case llvm::Triple::EABI:
setABI("aapcs");
break;
case llvm::Triple::GNU:
setABI("apcs-gnu");
break;
default:
if (Triple.getOS() == llvm::Triple::NetBSD)
setABI("apcs-gnu");
else
setABI("aapcs");
break;
}
}
// ARM targets default to using the ARM C++ ABI.
TheCXXABI.set(TargetCXXABI::GenericARM);
// ARM has atomics up to 8 bytes
setAtomic();
// Do force alignment of members that follow zero length bitfields. If
// the alignment of the zero-length bitfield is greater than the member
// that follows it, `bar', `bar' will be aligned as the type of the
// zero length bitfield.
UseZeroLengthBitfieldAlignment = true;
}
StringRef getABI() const override { return ABI; }
bool setABI(const std::string &Name) override {
ABI = Name;
// The defaults (above) are for AAPCS, check if we need to change them.
//
// FIXME: We need support for -meabi... we could just mangle it into the
// name.
if (Name == "apcs-gnu") {
setABIAPCS();
return true;
}
if (Name == "aapcs" || Name == "aapcs-vfp" || Name == "aapcs-linux") {
setABIAAPCS();
return true;
}
return false;
}
// FIXME: This should be based on Arch attributes, not CPU names.
bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
StringRef CPU,
std::vector<std::string> &FeaturesVec) const override {
if (CPU == "arm1136jf-s" || CPU == "arm1176jzf-s" || CPU == "mpcore")
Features["vfp2"] = true;
else if (CPU == "cortex-a8" || CPU == "cortex-a9") {
Features["vfp3"] = true;
Features["neon"] = true;
}
else if (CPU == "cortex-a5") {
Features["vfp4"] = true;
Features["neon"] = true;
} else if (CPU == "swift" || CPU == "cortex-a7" ||
CPU == "cortex-a12" || CPU == "cortex-a15" ||
CPU == "cortex-a17" || CPU == "krait") {
Features["vfp4"] = true;
Features["neon"] = true;
Features["hwdiv"] = true;
Features["hwdiv-arm"] = true;
} else if (CPU == "cyclone" || CPU == "cortex-a53" || CPU == "cortex-a57" ||
CPU == "cortex-a72") {
Features["fp-armv8"] = true;
Features["neon"] = true;
Features["hwdiv"] = true;
Features["hwdiv-arm"] = true;
Features["crc"] = true;
Features["crypto"] = true;
} else if (CPU == "cortex-r5" || CPU == "cortex-r7" || ArchVersion == 8) {
Features["hwdiv"] = true;
Features["hwdiv-arm"] = true;
} else if (CPU == "cortex-m3" || CPU == "cortex-m4" || CPU == "cortex-m7" ||
CPU == "sc300" || CPU == "cortex-r4" || CPU == "cortex-r4f") {
Features["hwdiv"] = true;
}
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
FPU = 0;
CRC = 0;
Crypto = 0;
SoftFloat = SoftFloatABI = false;
HWDiv = 0;
// This does not diagnose illegal cases like having both
// "+vfpv2" and "+vfpv3" or having "+neon" and "+fp-only-sp".
uint32_t HW_FP_remove = 0;
for (const auto &Feature : Features) {
if (Feature == "+soft-float") {
SoftFloat = true;
} else if (Feature == "+soft-float-abi") {
SoftFloatABI = true;
} else if (Feature == "+vfp2") {
FPU |= VFP2FPU;
HW_FP |= HW_FP_SP | HW_FP_DP;
} else if (Feature == "+vfp3") {
FPU |= VFP3FPU;
HW_FP |= HW_FP_SP | HW_FP_DP;
} else if (Feature == "+vfp4") {
FPU |= VFP4FPU;
HW_FP |= HW_FP_SP | HW_FP_DP | HW_FP_HP;
} else if (Feature == "+fp-armv8") {
FPU |= FPARMV8;
HW_FP |= HW_FP_SP | HW_FP_DP | HW_FP_HP;
} else if (Feature == "+neon") {
FPU |= NeonFPU;
HW_FP |= HW_FP_SP | HW_FP_DP;
} else if (Feature == "+hwdiv") {
HWDiv |= HWDivThumb;
} else if (Feature == "+hwdiv-arm") {
HWDiv |= HWDivARM;
} else if (Feature == "+crc") {
CRC = 1;
} else if (Feature == "+crypto") {
Crypto = 1;
} else if (Feature == "+fp-only-sp") {
HW_FP_remove |= HW_FP_DP | HW_FP_HP;
}
}
HW_FP &= ~HW_FP_remove;
if (!(FPU & NeonFPU) && FPMath == FP_Neon) {
Diags.Report(diag::err_target_unsupported_fpmath) << "neon";
return false;
}
if (FPMath == FP_Neon)
Features.push_back("+neonfp");
else if (FPMath == FP_VFP)
Features.push_back("-neonfp");
// Remove front-end specific options which the backend handles differently.
auto Feature =
std::find(Features.begin(), Features.end(), "+soft-float-abi");
if (Feature != Features.end())
Features.erase(Feature);
return true;
}
bool hasFeature(StringRef Feature) const override {
return llvm::StringSwitch<bool>(Feature)
.Case("arm", true)
.Case("aarch32", true)
.Case("softfloat", SoftFloat)
.Case("thumb", isThumb())
.Case("neon", (FPU & NeonFPU) && !SoftFloat)
.Case("hwdiv", HWDiv & HWDivThumb)
.Case("hwdiv-arm", HWDiv & HWDivARM)
.Default(false);
}
bool setCPU(const std::string &Name) override {
if (Name != "generic")
setArchInfo(llvm::ARM::parseCPUArch(Name));
if (ArchKind == llvm::ARM::AK_INVALID)
return false;
setAtomic();
CPU = Name;
return true;
}
bool setFPMath(StringRef Name) override;
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
// Target identification.
Builder.defineMacro("__arm");
Builder.defineMacro("__arm__");
// Target properties.
Builder.defineMacro("__REGISTER_PREFIX__", "");
if (!CPUAttr.empty())
Builder.defineMacro("__ARM_ARCH_" + CPUAttr + "__");
// ACLE 6.4.1 ARM/Thumb instruction set architecture
// __ARM_ARCH is defined as an integer value indicating the current ARM ISA
Builder.defineMacro("__ARM_ARCH", llvm::utostr(ArchVersion));
if (ArchVersion >= 8) {
Builder.defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN");
Builder.defineMacro("__ARM_FEATURE_DIRECTED_ROUNDING");
}
// __ARM_ARCH_ISA_ARM is defined to 1 if the core supports the ARM ISA. It
// is not defined for the M-profile.
// NOTE that the deffault profile is assumed to be 'A'
if (CPUProfile.empty() || CPUProfile != "M")
Builder.defineMacro("__ARM_ARCH_ISA_ARM", "1");
// __ARM_ARCH_ISA_THUMB is defined to 1 if the core supporst the original
// Thumb ISA (including v6-M). It is set to 2 if the core supports the
// Thumb-2 ISA as found in the v6T2 architecture and all v7 architecture.
if (supportsThumb2())
Builder.defineMacro("__ARM_ARCH_ISA_THUMB", "2");
else if (supportsThumb())
Builder.defineMacro("__ARM_ARCH_ISA_THUMB", "1");
// __ARM_32BIT_STATE is defined to 1 if code is being generated for a 32-bit
// instruction set such as ARM or Thumb.
Builder.defineMacro("__ARM_32BIT_STATE", "1");
// ACLE 6.4.2 Architectural Profile (A, R, M or pre-Cortex)
// __ARM_ARCH_PROFILE is defined as 'A', 'R', 'M' or 'S', or unset.
if (!CPUProfile.empty())
Builder.defineMacro("__ARM_ARCH_PROFILE", "'" + CPUProfile + "'");
// ACLE 6.5.1 Hardware Floating Point
if (HW_FP)
Builder.defineMacro("__ARM_FP", "0x" + llvm::utohexstr(HW_FP));
// ACLE predefines.
Builder.defineMacro("__ARM_ACLE", "200");
// Subtarget options.
// FIXME: It's more complicated than this and we don't really support
// interworking.
// Windows on ARM does not "support" interworking
if (5 <= ArchVersion && ArchVersion <= 8 && !getTriple().isOSWindows())
Builder.defineMacro("__THUMB_INTERWORK__");
if (ABI == "aapcs" || ABI == "aapcs-linux" || ABI == "aapcs-vfp") {
// Embedded targets on Darwin follow AAPCS, but not EABI.
// Windows on ARM follows AAPCS VFP, but does not conform to EABI.
if (!getTriple().isOSDarwin() && !getTriple().isOSWindows())
Builder.defineMacro("__ARM_EABI__");
Builder.defineMacro("__ARM_PCS", "1");
if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp")
Builder.defineMacro("__ARM_PCS_VFP", "1");
}
if (SoftFloat)
Builder.defineMacro("__SOFTFP__");
if (CPU == "xscale")
Builder.defineMacro("__XSCALE__");
if (isThumb()) {
Builder.defineMacro("__THUMBEL__");
Builder.defineMacro("__thumb__");
if (supportsThumb2())
Builder.defineMacro("__thumb2__");
}
if (((HWDiv & HWDivThumb) && isThumb()) || ((HWDiv & HWDivARM) && !isThumb()))
Builder.defineMacro("__ARM_ARCH_EXT_IDIV__", "1");
// Note, this is always on in gcc, even though it doesn't make sense.
Builder.defineMacro("__APCS_32__");
if (FPUModeIsVFP((FPUMode) FPU)) {
Builder.defineMacro("__VFP_FP__");
if (FPU & VFP2FPU)
Builder.defineMacro("__ARM_VFPV2__");
if (FPU & VFP3FPU)
Builder.defineMacro("__ARM_VFPV3__");
if (FPU & VFP4FPU)
Builder.defineMacro("__ARM_VFPV4__");
}
// This only gets set when Neon instructions are actually available, unlike
// the VFP define, hence the soft float and arch check. This is subtly
// different from gcc, we follow the intent which was that it should be set
// when Neon instructions are actually available.
if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) {
Builder.defineMacro("__ARM_NEON");
Builder.defineMacro("__ARM_NEON__");
}
Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
Opts.ShortWChar ? "2" : "4");
Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
Opts.ShortEnums ? "1" : "4");
if (CRC)
Builder.defineMacro("__ARM_FEATURE_CRC32");
if (Crypto)
Builder.defineMacro("__ARM_FEATURE_CRYPTO");
if (ArchVersion >= 6 && CPUAttr != "6M") {
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
}
bool is5EOrAbove = (ArchVersion >= 6 ||
(ArchVersion == 5 && CPUAttr.count('E')));
// FIXME: We are not getting all 32-bit ARM architectures
bool is32Bit = (!isThumb() || supportsThumb2());
if (is5EOrAbove && is32Bit && (CPUProfile != "M" || CPUAttr == "7EM"))
Builder.defineMacro("__ARM_FEATURE_DSP");
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::ARM::LastTSBuiltin-Builtin::FirstTSBuiltin;
}
bool isCLZForZeroUndef() const override { return false; }
BuiltinVaListKind getBuiltinVaListKind() const override {
return IsAAPCS ? AAPCSABIBuiltinVaList : TargetInfo::VoidPtrBuiltinVaList;
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
switch (*Name) {
default: break;
case 'l': // r0-r7
case 'h': // r8-r15
case 'w': // VFP Floating point register single precision
case 'P': // VFP Floating point register double precision
Info.setAllowsRegister();
return true;
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
// FIXME
return true;
case 'Q': // A memory address that is a single base register.
Info.setAllowsMemory();
return true;
case 'U': // a memory reference...
switch (Name[1]) {
case 'q': // ...ARMV4 ldrsb
case 'v': // ...VFP load/store (reg+constant offset)
case 'y': // ...iWMMXt load/store
case 't': // address valid for load/store opaque types wider
// than 128-bits
case 'n': // valid address for Neon doubleword vector load/store
case 'm': // valid address for Neon element and structure load/store
case 's': // valid address for non-offset loads/stores of quad-word
// values in four ARM registers
Info.setAllowsMemory();
Name++;
return true;
}
}
return false;
}
std::string convertConstraint(const char *&Constraint) const override {
std::string R;
switch (*Constraint) {
case 'U': // Two-character constraint; add "^" hint for later parsing.
R = std::string("^") + std::string(Constraint, 2);
Constraint++;
break;
case 'p': // 'p' should be translated to 'r' by default.
R = std::string("r");
break;
default:
return std::string(1, *Constraint);
}
return R;
}
bool
validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
std::string &SuggestedModifier) const override {
bool isOutput = (Constraint[0] == '=');
bool isInOut = (Constraint[0] == '+');
// Strip off constraint modifiers.
while (Constraint[0] == '=' ||
Constraint[0] == '+' ||
Constraint[0] == '&')
Constraint = Constraint.substr(1);
switch (Constraint[0]) {
default: break;
case 'r': {
switch (Modifier) {
default:
return (isInOut || isOutput || Size <= 64);
case 'q':
// A register of size 32 cannot fit a vector type.
return false;
}
}
}
return true;
}
const char *getClobbers() const override {
// FIXME: Is this really right?
return "";
}
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
return (CC == CC_AAPCS || CC == CC_AAPCS_VFP) ? CCCR_OK : CCCR_Warning;
}
int getEHDataRegisterNumber(unsigned RegNo) const override {
if (RegNo == 0) return 0;
if (RegNo == 1) return 1;
return -1;
}
bool hasSjLjLowering() const override {
return true;
}
};
bool ARMTargetInfo::setFPMath(StringRef Name) {
if (Name == "neon") {
FPMath = FP_Neon;
return true;
} else if (Name == "vfp" || Name == "vfp2" || Name == "vfp3" ||
Name == "vfp4") {
FPMath = FP_VFP;
return true;
}
return false;
}
const char * const ARMTargetInfo::GCCRegNames[] = {
// Integer registers
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc",
// Float registers
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
"s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
"s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
"s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
// Double registers
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
"d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15",
"d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23",
"d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
// Quad registers
"q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7",
"q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15"
};
void ARMTargetInfo::getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
const TargetInfo::GCCRegAlias ARMTargetInfo::GCCRegAliases[] = {
{ { "a1" }, "r0" },
{ { "a2" }, "r1" },
{ { "a3" }, "r2" },
{ { "a4" }, "r3" },
{ { "v1" }, "r4" },
{ { "v2" }, "r5" },
{ { "v3" }, "r6" },
{ { "v4" }, "r7" },
{ { "v5" }, "r8" },
{ { "v6", "rfp" }, "r9" },
{ { "sl" }, "r10" },
{ { "fp" }, "r11" },
{ { "ip" }, "r12" },
{ { "r13" }, "sp" },
{ { "r14" }, "lr" },
{ { "r15" }, "pc" },
// The S, D and Q registers overlap, but aren't really aliases; we
// don't want to substitute one of these for a different-sized one.
};
void ARMTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const {
Aliases = GCCRegAliases;
NumAliases = llvm::array_lengthof(GCCRegAliases);
}
const Builtin::Info ARMTargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
{ #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsNEON.def"
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
{ #ID, TYPE, ATTRS, nullptr, LANG, nullptr},
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
{ #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsARM.def"
};
class ARMleTargetInfo : public ARMTargetInfo {
public:
ARMleTargetInfo(const llvm::Triple &Triple)
: ARMTargetInfo(Triple, false) { }
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__ARMEL__");
ARMTargetInfo::getTargetDefines(Opts, Builder);
}
};
class ARMbeTargetInfo : public ARMTargetInfo {
public:
ARMbeTargetInfo(const llvm::Triple &Triple)
: ARMTargetInfo(Triple, true) { }
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__ARMEB__");
Builder.defineMacro("__ARM_BIG_ENDIAN");
ARMTargetInfo::getTargetDefines(Opts, Builder);
}
};
class WindowsARMTargetInfo : public WindowsTargetInfo<ARMleTargetInfo> {
const llvm::Triple Triple;
public:
WindowsARMTargetInfo(const llvm::Triple &Triple)
: WindowsTargetInfo<ARMleTargetInfo>(Triple), Triple(Triple) {
TLSSupported = false;
WCharType = UnsignedShort;
SizeType = UnsignedInt;
UserLabelPrefix = "";
}
void getVisualStudioDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
WindowsTargetInfo<ARMleTargetInfo>::getVisualStudioDefines(Opts, Builder);
// FIXME: this is invalid for WindowsCE
Builder.defineMacro("_M_ARM_NT", "1");
Builder.defineMacro("_M_ARMT", "_M_ARM");
Builder.defineMacro("_M_THUMB", "_M_ARM");
assert((Triple.getArch() == llvm::Triple::arm ||
Triple.getArch() == llvm::Triple::thumb) &&
"invalid architecture for Windows ARM target info");
unsigned Offset = Triple.getArch() == llvm::Triple::arm ? 4 : 6;
Builder.defineMacro("_M_ARM", Triple.getArchName().substr(Offset));
// TODO map the complete set of values
// 31: VFPv3 40: VFPv4
Builder.defineMacro("_M_ARM_FP", "31");
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
switch (CC) {
case CC_X86StdCall:
case CC_X86ThisCall:
case CC_X86FastCall:
case CC_X86VectorCall:
return CCCR_Ignore;
case CC_C:
return CCCR_OK;
default:
return CCCR_Warning;
}
}
};
// Windows ARM + Itanium C++ ABI Target
class ItaniumWindowsARMleTargetInfo : public WindowsARMTargetInfo {
public:
ItaniumWindowsARMleTargetInfo(const llvm::Triple &Triple)
: WindowsARMTargetInfo(Triple) {
TheCXXABI.set(TargetCXXABI::GenericARM);
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsARMTargetInfo::getTargetDefines(Opts, Builder);
if (Opts.MSVCCompat)
WindowsARMTargetInfo::getVisualStudioDefines(Opts, Builder);
}
};
// Windows ARM, MS (C++) ABI
class MicrosoftARMleTargetInfo : public WindowsARMTargetInfo {
public:
MicrosoftARMleTargetInfo(const llvm::Triple &Triple)
: WindowsARMTargetInfo(Triple) {
TheCXXABI.set(TargetCXXABI::Microsoft);
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsARMTargetInfo::getTargetDefines(Opts, Builder);
WindowsARMTargetInfo::getVisualStudioDefines(Opts, Builder);
}
};
// ARM MinGW target
class MinGWARMTargetInfo : public WindowsARMTargetInfo {
public:
MinGWARMTargetInfo(const llvm::Triple &Triple)
: WindowsARMTargetInfo(Triple) {
TheCXXABI.set(TargetCXXABI::GenericARM);
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsARMTargetInfo::getTargetDefines(Opts, Builder);
DefineStd(Builder, "WIN32", Opts);
DefineStd(Builder, "WINNT", Opts);
Builder.defineMacro("_ARM_");
addMinGWDefines(Opts, Builder);
}
};
// ARM Cygwin target
class CygwinARMTargetInfo : public ARMleTargetInfo {
public:
CygwinARMTargetInfo(const llvm::Triple &Triple) : ARMleTargetInfo(Triple) {
TLSSupported = false;
WCharType = UnsignedShort;
DoubleAlign = LongLongAlign = 64;
DataLayoutString = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
ARMleTargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("_ARM_");
Builder.defineMacro("__CYGWIN__");
Builder.defineMacro("__CYGWIN32__");
DefineStd(Builder, "unix", Opts);
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
}
};
class DarwinARMTargetInfo :
public DarwinTargetInfo<ARMleTargetInfo> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
getDarwinDefines(Builder, Opts, Triple, PlatformName, PlatformMinVersion);
}
public:
DarwinARMTargetInfo(const llvm::Triple &Triple)
: DarwinTargetInfo<ARMleTargetInfo>(Triple) {
HasAlignMac68kSupport = true;
// iOS always has 64-bit atomic instructions.
// FIXME: This should be based off of the target features in
// ARMleTargetInfo.
MaxAtomicInlineWidth = 64;
// Darwin on iOS uses a variant of the ARM C++ ABI.
TheCXXABI.set(TargetCXXABI::iOS);
}
};
class AArch64TargetInfo : public TargetInfo {
virtual void setDataLayoutString() = 0;
static const TargetInfo::GCCRegAlias GCCRegAliases[];
static const char *const GCCRegNames[];
enum FPUModeEnum {
FPUMode,
NeonMode
};
unsigned FPU;
unsigned CRC;
unsigned Crypto;
static const Builtin::Info BuiltinInfo[];
std::string ABI;
public:
AArch64TargetInfo(const llvm::Triple &Triple)
: TargetInfo(Triple), ABI("aapcs") {
if (getTriple().getOS() == llvm::Triple::NetBSD) {
WCharType = SignedInt;
// NetBSD apparently prefers consistency across ARM targets to consistency
// across 64-bit targets.
Int64Type = SignedLongLong;
IntMaxType = SignedLongLong;
} else {
WCharType = UnsignedInt;
Int64Type = SignedLong;
IntMaxType = SignedLong;
}
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
MaxVectorAlign = 128;
MaxAtomicInlineWidth = 128;
MaxAtomicPromoteWidth = 128;
LongDoubleWidth = LongDoubleAlign = SuitableAlign = 128;
LongDoubleFormat = &llvm::APFloat::IEEEquad;
// {} in inline assembly are neon specifiers, not assembly variant
// specifiers.
NoAsmVariants = true;
// AAPCS gives rules for bitfields. 7.1.7 says: "The container type
// contributes to the alignment of the containing aggregate in the same way
// a plain (non bit-field) member of that type would, without exception for
// zero-sized or anonymous bit-fields."
UseBitFieldTypeAlignment = true;
UseZeroLengthBitfieldAlignment = true;
// AArch64 targets default to using the ARM C++ ABI.
TheCXXABI.set(TargetCXXABI::GenericAArch64);
}
StringRef getABI() const override { return ABI; }
bool setABI(const std::string &Name) override {
if (Name != "aapcs" && Name != "darwinpcs")
return false;
ABI = Name;
return true;
}
bool setCPU(const std::string &Name) override {
bool CPUKnown = llvm::StringSwitch<bool>(Name)
.Case("generic", true)
.Cases("cortex-a53", "cortex-a57", "cortex-a72", true)
.Case("cyclone", true)
.Default(false);
return CPUKnown;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
// Target identification.
Builder.defineMacro("__aarch64__");
// Target properties.
Builder.defineMacro("_LP64");
Builder.defineMacro("__LP64__");
// ACLE predefines. Many can only have one possible value on v8 AArch64.
Builder.defineMacro("__ARM_ACLE", "200");
Builder.defineMacro("__ARM_ARCH", "8");
Builder.defineMacro("__ARM_ARCH_PROFILE", "'A'");
Builder.defineMacro("__ARM_64BIT_STATE");
Builder.defineMacro("__ARM_PCS_AAPCS64");
Builder.defineMacro("__ARM_ARCH_ISA_A64");
Builder.defineMacro("__ARM_FEATURE_UNALIGNED");
Builder.defineMacro("__ARM_FEATURE_CLZ");
Builder.defineMacro("__ARM_FEATURE_FMA");
Builder.defineMacro("__ARM_FEATURE_DIV");
Builder.defineMacro("__ARM_FEATURE_IDIV"); // As specified in ACLE
Builder.defineMacro("__ARM_FEATURE_DIV"); // For backwards compatibility
Builder.defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN");
Builder.defineMacro("__ARM_FEATURE_DIRECTED_ROUNDING");
Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4");
// 0xe implies support for half, single and double precision operations.
Builder.defineMacro("__ARM_FP", "0xe");
// PCS specifies this for SysV variants, which is all we support. Other ABIs
// may choose __ARM_FP16_FORMAT_ALTERNATIVE.
Builder.defineMacro("__ARM_FP16_FORMAT_IEEE");
Builder.defineMacro("__ARM_FP16_ARGS");
if (Opts.FastMath || Opts.FiniteMathOnly)
Builder.defineMacro("__ARM_FP_FAST");
if (Opts.C99 && !Opts.Freestanding)
Builder.defineMacro("__ARM_FP_FENV_ROUNDING");
Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", Opts.ShortWChar ? "2" : "4");
Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
Opts.ShortEnums ? "1" : "4");
if (FPU == NeonMode) {
Builder.defineMacro("__ARM_NEON");
// 64-bit NEON supports half, single and double precision operations.
Builder.defineMacro("__ARM_NEON_FP", "0xe");
}
if (CRC)
Builder.defineMacro("__ARM_FEATURE_CRC32");
if (Crypto)
Builder.defineMacro("__ARM_FEATURE_CRYPTO");
// All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8) builtins work.
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::AArch64::LastTSBuiltin - Builtin::FirstTSBuiltin;
}
bool hasFeature(StringRef Feature) const override {
return Feature == "aarch64" ||
Feature == "arm64" ||
Feature == "arm" ||
(Feature == "neon" && FPU == NeonMode);
}
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
FPU = FPUMode;
CRC = 0;
Crypto = 0;
for (const auto &Feature : Features) {
if (Feature == "+neon")
FPU = NeonMode;
if (Feature == "+crc")
CRC = 1;
if (Feature == "+crypto")
Crypto = 1;
}
setDataLayoutString();
return true;
}
bool isCLZForZeroUndef() const override { return false; }
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::AArch64ABIBuiltinVaList;
}
void getGCCRegNames(const char *const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
switch (*Name) {
default:
return false;
case 'w': // Floating point and SIMD registers (V0-V31)
Info.setAllowsRegister();
return true;
case 'I': // Constant that can be used with an ADD instruction
case 'J': // Constant that can be used with a SUB instruction
case 'K': // Constant that can be used with a 32-bit logical instruction
case 'L': // Constant that can be used with a 64-bit logical instruction
case 'M': // Constant that can be used as a 32-bit MOV immediate
case 'N': // Constant that can be used as a 64-bit MOV immediate
case 'Y': // Floating point constant zero
case 'Z': // Integer constant zero
return true;
case 'Q': // A memory reference with base register and no offset
Info.setAllowsMemory();
return true;
case 'S': // A symbolic address
Info.setAllowsRegister();
return true;
case 'U':
// Ump: A memory address suitable for ldp/stp in SI, DI, SF and DF modes.
// Utf: A memory address suitable for ldp/stp in TF mode.
// Usa: An absolute symbolic address.
// Ush: The high part (bits 32:12) of a pc-relative symbolic address.
llvm_unreachable("FIXME: Unimplemented support for U* constraints.");
case 'z': // Zero register, wzr or xzr
Info.setAllowsRegister();
return true;
case 'x': // Floating point and SIMD registers (V0-V15)
Info.setAllowsRegister();
return true;
}
return false;
}
bool
validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
std::string &SuggestedModifier) const override {
// Strip off constraint modifiers.
while (Constraint[0] == '=' || Constraint[0] == '+' || Constraint[0] == '&')
Constraint = Constraint.substr(1);
switch (Constraint[0]) {
default:
return true;
case 'z':
case 'r': {
switch (Modifier) {
case 'x':
case 'w':
// For now assume that the person knows what they're
// doing with the modifier.
return true;
default:
// By default an 'r' constraint will be in the 'x'
// registers.
if (Size == 64)
return true;
SuggestedModifier = "w";
return false;
}
}
}
}
const char *getClobbers() const override { return ""; }
int getEHDataRegisterNumber(unsigned RegNo) const override {
if (RegNo == 0)
return 0;
if (RegNo == 1)
return 1;
return -1;
}
};
const char *const AArch64TargetInfo::GCCRegNames[] = {
// 32-bit Integer registers
"w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10",
"w11", "w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21",
"w22", "w23", "w24", "w25", "w26", "w27", "w28", "w29", "w30", "wsp",
// 64-bit Integer registers
"x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10",
"x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19", "x20", "x21",
"x22", "x23", "x24", "x25", "x26", "x27", "x28", "fp", "lr", "sp",
// 32-bit floating point regsisters
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10",
"s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21",
"s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
// 64-bit floating point regsisters
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10",
"d11", "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21",
"d22", "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
// Vector registers
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10",
"v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21",
"v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"
};
void AArch64TargetInfo::getGCCRegNames(const char *const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
const TargetInfo::GCCRegAlias AArch64TargetInfo::GCCRegAliases[] = {
{ { "w31" }, "wsp" },
{ { "x29" }, "fp" },
{ { "x30" }, "lr" },
{ { "x31" }, "sp" },
// The S/D/Q and W/X registers overlap, but aren't really aliases; we
// don't want to substitute one of these for a different-sized one.
};
void AArch64TargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const {
Aliases = GCCRegAliases;
NumAliases = llvm::array_lengthof(GCCRegAliases);
}
const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsNEON.def"
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsAArch64.def"
};
class AArch64leTargetInfo : public AArch64TargetInfo {
void setDataLayoutString() override {
if (getTriple().isOSBinFormatMachO())
DataLayoutString = "e-m:o-i64:64-i128:128-n32:64-S128";
else
DataLayoutString = "e-m:e-i64:64-i128:128-n32:64-S128";
}
public:
AArch64leTargetInfo(const llvm::Triple &Triple)
: AArch64TargetInfo(Triple) {
BigEndian = false;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__AARCH64EL__");
AArch64TargetInfo::getTargetDefines(Opts, Builder);
}
};
class AArch64beTargetInfo : public AArch64TargetInfo {
void setDataLayoutString() override {
assert(!getTriple().isOSBinFormatMachO());
DataLayoutString = "E-m:e-i64:64-i128:128-n32:64-S128";
}
public:
AArch64beTargetInfo(const llvm::Triple &Triple)
: AArch64TargetInfo(Triple) { }
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__AARCH64EB__");
Builder.defineMacro("__AARCH_BIG_ENDIAN");
Builder.defineMacro("__ARM_BIG_ENDIAN");
AArch64TargetInfo::getTargetDefines(Opts, Builder);
}
};
class DarwinAArch64TargetInfo : public DarwinTargetInfo<AArch64leTargetInfo> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
Builder.defineMacro("__AARCH64_SIMD__");
Builder.defineMacro("__ARM64_ARCH_8__");
Builder.defineMacro("__ARM_NEON__");
Builder.defineMacro("__LITTLE_ENDIAN__");
Builder.defineMacro("__REGISTER_PREFIX__", "");
Builder.defineMacro("__arm64", "1");
Builder.defineMacro("__arm64__", "1");
getDarwinDefines(Builder, Opts, Triple, PlatformName, PlatformMinVersion);
}
public:
DarwinAArch64TargetInfo(const llvm::Triple &Triple)
: DarwinTargetInfo<AArch64leTargetInfo>(Triple) {
Int64Type = SignedLongLong;
WCharType = SignedInt;
UseSignedCharForObjCBool = false;
LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
TheCXXABI.set(TargetCXXABI::iOS64);
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
};
// Hexagon abstract base class
class HexagonTargetInfo : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
static const char * const GCCRegNames[];
static const TargetInfo::GCCRegAlias GCCRegAliases[];
std::string CPU;
public:
HexagonTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
BigEndian = false;
DataLayoutString = "e-m:e-p:32:32-i1:32-i64:64-a:0-n32";
// {} in inline assembly are packet specifiers, not assembly variant
// specifiers.
NoAsmVariants = true;
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::Hexagon::LastTSBuiltin-Builtin::FirstTSBuiltin;
}
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
return true;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
bool hasFeature(StringRef Feature) const override {
return Feature == "hexagon";
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override;
const char *getClobbers() const override {
return "";
}
static const char *getHexagonCPUSuffix(StringRef Name) {
return llvm::StringSwitch<const char*>(Name)
.Case("hexagonv4", "4")
.Case("hexagonv5", "5")
.Default(nullptr);
}
bool setCPU(const std::string &Name) override {
if (!getHexagonCPUSuffix(Name))
return false;
CPU = Name;
return true;
}
};
void HexagonTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
Builder.defineMacro("qdsp6");
Builder.defineMacro("__qdsp6", "1");
Builder.defineMacro("__qdsp6__", "1");
Builder.defineMacro("hexagon");
Builder.defineMacro("__hexagon", "1");
Builder.defineMacro("__hexagon__", "1");
if(CPU == "hexagonv1") {
Builder.defineMacro("__HEXAGON_V1__");
Builder.defineMacro("__HEXAGON_ARCH__", "1");
if(Opts.HexagonQdsp6Compat) {
Builder.defineMacro("__QDSP6_V1__");
Builder.defineMacro("__QDSP6_ARCH__", "1");
}
}
else if(CPU == "hexagonv2") {
Builder.defineMacro("__HEXAGON_V2__");
Builder.defineMacro("__HEXAGON_ARCH__", "2");
if(Opts.HexagonQdsp6Compat) {
Builder.defineMacro("__QDSP6_V2__");
Builder.defineMacro("__QDSP6_ARCH__", "2");
}
}
else if(CPU == "hexagonv3") {
Builder.defineMacro("__HEXAGON_V3__");
Builder.defineMacro("__HEXAGON_ARCH__", "3");
if(Opts.HexagonQdsp6Compat) {
Builder.defineMacro("__QDSP6_V3__");
Builder.defineMacro("__QDSP6_ARCH__", "3");
}
}
else if(CPU == "hexagonv4") {
Builder.defineMacro("__HEXAGON_V4__");
Builder.defineMacro("__HEXAGON_ARCH__", "4");
if(Opts.HexagonQdsp6Compat) {
Builder.defineMacro("__QDSP6_V4__");
Builder.defineMacro("__QDSP6_ARCH__", "4");
}
}
else if(CPU == "hexagonv5") {
Builder.defineMacro("__HEXAGON_V5__");
Builder.defineMacro("__HEXAGON_ARCH__", "5");
if(Opts.HexagonQdsp6Compat) {
Builder.defineMacro("__QDSP6_V5__");
Builder.defineMacro("__QDSP6_ARCH__", "5");
}
}
}
const char * const HexagonTargetInfo::GCCRegNames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
"p0", "p1", "p2", "p3",
"sa0", "lc0", "sa1", "lc1", "m0", "m1", "usr", "ugp"
};
void HexagonTargetInfo::getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
const TargetInfo::GCCRegAlias HexagonTargetInfo::GCCRegAliases[] = {
{ { "sp" }, "r29" },
{ { "fp" }, "r30" },
{ { "lr" }, "r31" },
};
void HexagonTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const {
Aliases = GCCRegAliases;
NumAliases = llvm::array_lengthof(GCCRegAliases);
}
const Builtin::Info HexagonTargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
{ #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsHexagon.def"
};
// Shared base class for SPARC v8 (32-bit) and SPARC v9 (64-bit).
class SparcTargetInfo : public TargetInfo {
static const TargetInfo::GCCRegAlias GCCRegAliases[];
static const char * const GCCRegNames[];
bool SoftFloat;
public:
SparcTargetInfo(const llvm::Triple &Triple)
: TargetInfo(Triple), SoftFloat(false) {}
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
// The backend doesn't actually handle soft float yet, but in case someone
// is using the support for the front end continue to support it.
auto Feature = std::find(Features.begin(), Features.end(), "+soft-float");
if (Feature != Features.end()) {
SoftFloat = true;
Features.erase(Feature);
}
return true;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "sparc", Opts);
Builder.defineMacro("__REGISTER_PREFIX__", "");
if (SoftFloat)
Builder.defineMacro("SOFT_FLOAT", "1");
}
bool hasFeature(StringRef Feature) const override {
return llvm::StringSwitch<bool>(Feature)
.Case("softfloat", SoftFloat)
.Case("sparc", true)
.Default(false);
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
// FIXME: Implement!
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
// FIXME: Implement!
switch (*Name) {
case 'I': // Signed 13-bit constant
case 'J': // Zero
case 'K': // 32-bit constant with the low 12 bits clear
case 'L': // A constant in the range supported by movcc (11-bit signed imm)
case 'M': // A constant in the range supported by movrcc (19-bit signed imm)
case 'N': // Same as 'K' but zext (required for SIMode)
case 'O': // The constant 4096
return true;
}
return false;
}
const char *getClobbers() const override {
// FIXME: Implement!
return "";
}
};
const char * const SparcTargetInfo::GCCRegNames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
};
void SparcTargetInfo::getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
const TargetInfo::GCCRegAlias SparcTargetInfo::GCCRegAliases[] = {
{ { "g0" }, "r0" },
{ { "g1" }, "r1" },
{ { "g2" }, "r2" },
{ { "g3" }, "r3" },
{ { "g4" }, "r4" },
{ { "g5" }, "r5" },
{ { "g6" }, "r6" },
{ { "g7" }, "r7" },
{ { "o0" }, "r8" },
{ { "o1" }, "r9" },
{ { "o2" }, "r10" },
{ { "o3" }, "r11" },
{ { "o4" }, "r12" },
{ { "o5" }, "r13" },
{ { "o6", "sp" }, "r14" },
{ { "o7" }, "r15" },
{ { "l0" }, "r16" },
{ { "l1" }, "r17" },
{ { "l2" }, "r18" },
{ { "l3" }, "r19" },
{ { "l4" }, "r20" },
{ { "l5" }, "r21" },
{ { "l6" }, "r22" },
{ { "l7" }, "r23" },
{ { "i0" }, "r24" },
{ { "i1" }, "r25" },
{ { "i2" }, "r26" },
{ { "i3" }, "r27" },
{ { "i4" }, "r28" },
{ { "i5" }, "r29" },
{ { "i6", "fp" }, "r30" },
{ { "i7" }, "r31" },
};
void SparcTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const {
Aliases = GCCRegAliases;
NumAliases = llvm::array_lengthof(GCCRegAliases);
}
// SPARC v8 is the 32-bit mode selected by Triple::sparc.
class SparcV8TargetInfo : public SparcTargetInfo {
public:
SparcV8TargetInfo(const llvm::Triple &Triple) : SparcTargetInfo(Triple) {
DataLayoutString = "E-m:e-p:32:32-i64:64-f128:64-n32-S64";
// NetBSD / OpenBSD use long (same as llvm default); everyone else uses int.
switch (getTriple().getOS()) {
default:
SizeType = UnsignedInt;
IntPtrType = SignedInt;
PtrDiffType = SignedInt;
break;
case llvm::Triple::NetBSD:
case llvm::Triple::OpenBSD:
SizeType = UnsignedLong;
IntPtrType = SignedLong;
PtrDiffType = SignedLong;
break;
}
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
SparcTargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("__sparcv8");
}
};
// SPARCV8el is the 32-bit little-endian mode selected by Triple::sparcel.
class SparcV8elTargetInfo : public SparcV8TargetInfo {
public:
SparcV8elTargetInfo(const llvm::Triple &Triple) : SparcV8TargetInfo(Triple) {
DataLayoutString = "e-m:e-p:32:32-i64:64-f128:64-n32-S64";
BigEndian = false;
}
};
// SPARC v9 is the 64-bit mode selected by Triple::sparcv9.
class SparcV9TargetInfo : public SparcTargetInfo {
public:
SparcV9TargetInfo(const llvm::Triple &Triple) : SparcTargetInfo(Triple) {
// FIXME: Support Sparc quad-precision long double?
DataLayoutString = "E-m:e-i64:64-n32:64-S128";
// This is an LP64 platform.
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
// OpenBSD uses long long for int64_t and intmax_t.
if (getTriple().getOS() == llvm::Triple::OpenBSD)
IntMaxType = SignedLongLong;
else
IntMaxType = SignedLong;
Int64Type = IntMaxType;
// The SPARCv8 System V ABI has long double 128-bits in size, but 64-bit
// aligned. The SPARCv9 SCD 2.4.1 says 16-byte aligned.
LongDoubleWidth = 128;
LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::IEEEquad;
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
SparcTargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("__sparcv9");
Builder.defineMacro("__arch64__");
// Solaris doesn't need these variants, but the BSDs do.
if (getTriple().getOS() != llvm::Triple::Solaris) {
Builder.defineMacro("__sparc64__");
Builder.defineMacro("__sparc_v9__");
Builder.defineMacro("__sparcv9__");
}
}
bool setCPU(const std::string &Name) override {
bool CPUKnown = llvm::StringSwitch<bool>(Name)
.Case("v9", true)
.Case("ultrasparc", true)
.Case("ultrasparc3", true)
.Case("niagara", true)
.Case("niagara2", true)
.Case("niagara3", true)
.Case("niagara4", true)
.Default(false);
// No need to store the CPU yet. There aren't any CPU-specific
// macros to define.
return CPUKnown;
}
};
class SystemZTargetInfo : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
static const char *const GCCRegNames[];
std::string CPU;
bool HasTransactionalExecution;
bool HasVector;
public:
SystemZTargetInfo(const llvm::Triple &Triple)
: TargetInfo(Triple), CPU("z10"), HasTransactionalExecution(false), HasVector(false) {
IntMaxType = SignedLong;
Int64Type = SignedLong;
TLSSupported = true;
IntWidth = IntAlign = 32;
LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
PointerWidth = PointerAlign = 64;
LongDoubleWidth = 128;
LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEquad;
DefaultAlignForAttributeAligned = 64;
MinGlobalAlign = 16;
DataLayoutString = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64";
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__s390__");
Builder.defineMacro("__s390x__");
Builder.defineMacro("__zarch__");
Builder.defineMacro("__LONG_DOUBLE_128__");
if (HasTransactionalExecution)
Builder.defineMacro("__HTM__");
if (Opts.ZVector)
Builder.defineMacro("__VEC__", "10301");
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::SystemZ::LastTSBuiltin-Builtin::FirstTSBuiltin;
}
void getGCCRegNames(const char *const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
// No aliases.
Aliases = nullptr;
NumAliases = 0;
}
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override;
const char *getClobbers() const override {
// FIXME: Is this really right?
return "";
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::SystemZBuiltinVaList;
}
bool setCPU(const std::string &Name) override {
CPU = Name;
bool CPUKnown = llvm::StringSwitch<bool>(Name)
.Case("z10", true)
.Case("z196", true)
.Case("zEC12", true)
.Case("z13", true)
.Default(false);
return CPUKnown;
}
bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
StringRef CPU,
std::vector<std::string> &FeaturesVec) const override {
if (CPU == "zEC12")
Features["transactional-execution"] = true;
if (CPU == "z13") {
Features["transactional-execution"] = true;
Features["vector"] = true;
}
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
HasTransactionalExecution = false;
for (const auto &Feature : Features) {
if (Feature == "+transactional-execution")
HasTransactionalExecution = true;
else if (Feature == "+vector")
HasVector = true;
}
// If we use the vector ABI, vector types are 64-bit aligned.
if (HasVector) {
MaxVectorAlign = 64;
DataLayoutString = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
"-v128:64-a:8:16-n32:64";
}
return true;
}
bool hasFeature(StringRef Feature) const override {
return llvm::StringSwitch<bool>(Feature)
.Case("systemz", true)
.Case("htm", HasTransactionalExecution)
.Case("vx", HasVector)
.Default(false);
}
StringRef getABI() const override {
if (HasVector)
return "vector";
return "";
}
bool useFloat128ManglingForLongDouble() const override {
return true;
}
};
const Builtin::Info SystemZTargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsSystemZ.def"
};
const char *const SystemZTargetInfo::GCCRegNames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"f0", "f2", "f4", "f6", "f1", "f3", "f5", "f7",
"f8", "f10", "f12", "f14", "f9", "f11", "f13", "f15"
};
void SystemZTargetInfo::getGCCRegNames(const char *const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
bool SystemZTargetInfo::
validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const {
switch (*Name) {
default:
return false;
case 'a': // Address register
case 'd': // Data register (equivalent to 'r')
case 'f': // Floating-point register
Info.setAllowsRegister();
return true;
case 'I': // Unsigned 8-bit constant
case 'J': // Unsigned 12-bit constant
case 'K': // Signed 16-bit constant
case 'L': // Signed 20-bit displacement (on all targets we support)
case 'M': // 0x7fffffff
return true;
case 'Q': // Memory with base and unsigned 12-bit displacement
case 'R': // Likewise, plus an index
case 'S': // Memory with base and signed 20-bit displacement
case 'T': // Likewise, plus an index
Info.setAllowsMemory();
return true;
}
}
class MSP430TargetInfo : public TargetInfo {
static const char * const GCCRegNames[];
public:
MSP430TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
BigEndian = false;
TLSSupported = false;
IntWidth = 16; IntAlign = 16;
LongWidth = 32; LongLongWidth = 64;
LongAlign = LongLongAlign = 16;
PointerWidth = 16; PointerAlign = 16;
SuitableAlign = 16;
SizeType = UnsignedInt;
IntMaxType = SignedLongLong;
IntPtrType = SignedInt;
PtrDiffType = SignedInt;
SigAtomicType = SignedLong;
DataLayoutString = "e-m:e-p:16:16-i32:16:32-a:16-n8:16";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("MSP430");
Builder.defineMacro("__MSP430__");
// FIXME: defines for different 'flavours' of MCU
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
// FIXME: Implement.
Records = nullptr;
NumRecords = 0;
}
bool hasFeature(StringRef Feature) const override {
return Feature == "msp430";
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
// No aliases.
Aliases = nullptr;
NumAliases = 0;
}
bool
validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
// FIXME: implement
switch (*Name) {
case 'K': // the constant 1
case 'L': // constant -1^20 .. 1^19
case 'M': // constant 1-4:
return true;
}
// No target constraints for now.
return false;
}
const char *getClobbers() const override {
// FIXME: Is this really right?
return "";
}
BuiltinVaListKind getBuiltinVaListKind() const override {
// FIXME: implement
return TargetInfo::CharPtrBuiltinVaList;
}
};
const char * const MSP430TargetInfo::GCCRegNames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
};
void MSP430TargetInfo::getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const {
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
// LLVM and Clang cannot be used directly to output native binaries for
// target, but is used to compile C code to llvm bitcode with correct
// type and alignment information.
//
// TCE uses the llvm bitcode as input and uses it for generating customized
// target processor and program binary. TCE co-design environment is
// publicly available in http://tce.cs.tut.fi
static const unsigned TCEOpenCLAddrSpaceMap[] = {
3, // opencl_global
4, // opencl_local
5, // opencl_constant
// FIXME: generic has to be added to the target
0, // opencl_generic
0, // cuda_device
0, // cuda_constant
0 // cuda_shared
};
class TCETargetInfo : public TargetInfo{
public:
TCETargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
TLSSupported = false;
IntWidth = 32;
LongWidth = LongLongWidth = 32;
PointerWidth = 32;
IntAlign = 32;
LongAlign = LongLongAlign = 32;
PointerAlign = 32;
SuitableAlign = 32;
SizeType = UnsignedInt;
IntMaxType = SignedLong;
IntPtrType = SignedInt;
PtrDiffType = SignedInt;
FloatWidth = 32;
FloatAlign = 32;
DoubleWidth = 32;
DoubleAlign = 32;
LongDoubleWidth = 32;
LongDoubleAlign = 32;
FloatFormat = &llvm::APFloat::IEEEsingle;
DoubleFormat = &llvm::APFloat::IEEEsingle;
LongDoubleFormat = &llvm::APFloat::IEEEsingle;
DataLayoutString = "E-p:32:32-i8:8:32-i16:16:32-i64:32"
"-f64:32-v64:32-v128:32-a:0:32-n32";
AddrSpaceMap = &TCEOpenCLAddrSpaceMap;
UseAddrSpaceMapMangling = true;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "tce", Opts);
Builder.defineMacro("__TCE__");
Builder.defineMacro("__TCE_V1__");
}
bool hasFeature(StringRef Feature) const override {
return Feature == "tce";
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {}
const char *getClobbers() const override {
return "";
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override {}
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override{
return true;
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {}
};
class BPFTargetInfo : public TargetInfo {
public:
BPFTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
SizeType = UnsignedLong;
PtrDiffType = SignedLong;
IntPtrType = SignedLong;
IntMaxType = SignedLong;
Int64Type = SignedLong;
RegParmMax = 5;
if (Triple.getArch() == llvm::Triple::bpfeb) {
BigEndian = true;
DataLayoutString = "E-m:e-p:64:64-i64:64-n32:64-S128";
} else {
BigEndian = false;
DataLayoutString = "e-m:e-p:64:64-i64:64-n32:64-S128";
}
MaxAtomicPromoteWidth = 64;
MaxAtomicInlineWidth = 64;
TLSSupported = false;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "bpf", Opts);
Builder.defineMacro("__BPF__");
}
bool hasFeature(StringRef Feature) const override {
return Feature == "bpf";
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {}
const char *getClobbers() const override {
return "";
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override {
Names = nullptr;
NumNames = 0;
}
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
return true;
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
Aliases = nullptr;
NumAliases = 0;
}
};
class MipsTargetInfoBase : public TargetInfo {
virtual void setDataLayoutString() = 0;
static const Builtin::Info BuiltinInfo[];
std::string CPU;
bool IsMips16;
bool IsMicromips;
bool IsNan2008;
bool IsSingleFloat;
enum MipsFloatABI {
HardFloat, SoftFloat
} FloatABI;
enum DspRevEnum {
NoDSP, DSP1, DSP2
} DspRev;
bool HasMSA;
protected:
bool HasFP64;
std::string ABI;
public:
MipsTargetInfoBase(const llvm::Triple &Triple, const std::string &ABIStr,
const std::string &CPUStr)
: TargetInfo(Triple), CPU(CPUStr), IsMips16(false), IsMicromips(false),
IsNan2008(false), IsSingleFloat(false), FloatABI(HardFloat),
DspRev(NoDSP), HasMSA(false), HasFP64(false), ABI(ABIStr) {
TheCXXABI.set(TargetCXXABI::GenericMIPS);
}
bool isNaN2008Default() const {
return CPU == "mips32r6" || CPU == "mips64r6";
}
bool isFP64Default() const {
return CPU == "mips32r6" || ABI == "n32" || ABI == "n64" || ABI == "64";
}
bool isNan2008() const override {
return IsNan2008;
}
StringRef getABI() const override { return ABI; }
bool setCPU(const std::string &Name) override {
bool IsMips32 = getTriple().getArch() == llvm::Triple::mips ||
getTriple().getArch() == llvm::Triple::mipsel;
CPU = Name;
return llvm::StringSwitch<bool>(Name)
.Case("mips1", IsMips32)
.Case("mips2", IsMips32)
.Case("mips3", true)
.Case("mips4", true)
.Case("mips5", true)
.Case("mips32", IsMips32)
.Case("mips32r2", IsMips32)
.Case("mips32r3", IsMips32)
.Case("mips32r5", IsMips32)
.Case("mips32r6", IsMips32)
.Case("mips64", true)
.Case("mips64r2", true)
.Case("mips64r3", true)
.Case("mips64r5", true)
.Case("mips64r6", true)
.Case("octeon", true)
.Default(false);
}
const std::string& getCPU() const { return CPU; }
bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
StringRef CPU,
std::vector<std::string> &FeaturesVec) const override {
if (CPU == "octeon")
Features["mips64r2"] = Features["cnmips"] = true;
else
Features[CPU] = true;
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__mips__");
Builder.defineMacro("_mips");
if (Opts.GNUMode)
Builder.defineMacro("mips");
Builder.defineMacro("__REGISTER_PREFIX__", "");
switch (FloatABI) {
case HardFloat:
Builder.defineMacro("__mips_hard_float", Twine(1));
break;
case SoftFloat:
Builder.defineMacro("__mips_soft_float", Twine(1));
break;
}
if (IsSingleFloat)
Builder.defineMacro("__mips_single_float", Twine(1));
Builder.defineMacro("__mips_fpr", HasFP64 ? Twine(64) : Twine(32));
Builder.defineMacro("_MIPS_FPSET",
Twine(32 / (HasFP64 || IsSingleFloat ? 1 : 2)));
if (IsMips16)
Builder.defineMacro("__mips16", Twine(1));
if (IsMicromips)
Builder.defineMacro("__mips_micromips", Twine(1));
if (IsNan2008)
Builder.defineMacro("__mips_nan2008", Twine(1));
switch (DspRev) {
default:
break;
case DSP1:
Builder.defineMacro("__mips_dsp_rev", Twine(1));
Builder.defineMacro("__mips_dsp", Twine(1));
break;
case DSP2:
Builder.defineMacro("__mips_dsp_rev", Twine(2));
Builder.defineMacro("__mips_dspr2", Twine(1));
Builder.defineMacro("__mips_dsp", Twine(1));
break;
}
if (HasMSA)
Builder.defineMacro("__mips_msa", Twine(1));
Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
Builder.defineMacro("_MIPS_ARCH", "\"" + CPU + "\"");
Builder.defineMacro("_MIPS_ARCH_" + StringRef(CPU).upper());
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::Mips::LastTSBuiltin - Builtin::FirstTSBuiltin;
}
bool hasFeature(StringRef Feature) const override {
return llvm::StringSwitch<bool>(Feature)
.Case("mips", true)
.Case("fp64", HasFP64)
.Default(false);
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override {
static const char *const GCCRegNames[] = {
// CPU register names
// Must match second column of GCCRegAliases
"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7",
"$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15",
"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23",
"$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31",
// Floating point register names
"$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7",
"$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15",
"$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23",
"$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",
// Hi/lo and condition register names
"hi", "lo", "", "$fcc0","$fcc1","$fcc2","$fcc3","$fcc4",
"$fcc5","$fcc6","$fcc7",
// MSA register names
"$w0", "$w1", "$w2", "$w3", "$w4", "$w5", "$w6", "$w7",
"$w8", "$w9", "$w10", "$w11", "$w12", "$w13", "$w14", "$w15",
"$w16", "$w17", "$w18", "$w19", "$w20", "$w21", "$w22", "$w23",
"$w24", "$w25", "$w26", "$w27", "$w28", "$w29", "$w30", "$w31",
// MSA control register names
"$msair", "$msacsr", "$msaaccess", "$msasave", "$msamodify",
"$msarequest", "$msamap", "$msaunmap"
};
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override = 0;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
switch (*Name) {
default:
return false;
case 'r': // CPU registers.
case 'd': // Equivalent to "r" unless generating MIPS16 code.
case 'y': // Equivalent to "r", backward compatibility only.
case 'f': // floating-point registers.
case 'c': // $25 for indirect jumps
case 'l': // lo register
case 'x': // hilo register pair
Info.setAllowsRegister();
return true;
case 'I': // Signed 16-bit constant
case 'J': // Integer 0
case 'K': // Unsigned 16-bit constant
case 'L': // Signed 32-bit constant, lower 16-bit zeros (for lui)
case 'M': // Constants not loadable via lui, addiu, or ori
case 'N': // Constant -1 to -65535
case 'O': // A signed 15-bit constant
case 'P': // A constant between 1 go 65535
return true;
case 'R': // An address that can be used in a non-macro load or store
Info.setAllowsMemory();
return true;
case 'Z':
if (Name[1] == 'C') { // An address usable by ll, and sc.
Info.setAllowsMemory();
Name++; // Skip over 'Z'.
return true;
}
return false;
}
}
std::string convertConstraint(const char *&Constraint) const override {
std::string R;
switch (*Constraint) {
case 'Z': // Two-character constraint; add "^" hint for later parsing.
if (Constraint[1] == 'C') {
R = std::string("^") + std::string(Constraint, 2);
Constraint++;
return R;
}
break;
}
return TargetInfo::convertConstraint(Constraint);
}
const char *getClobbers() const override {
// In GCC, $1 is not widely used in generated code (it's used only in a few
// specific situations), so there is no real need for users to add it to
// the clobbers list if they want to use it in their inline assembly code.
//
// In LLVM, $1 is treated as a normal GPR and is always allocatable during
// code generation, so using it in inline assembly without adding it to the
// clobbers list can cause conflicts between the inline assembly code and
// the surrounding generated code.
//
// Another problem is that LLVM is allowed to choose $1 for inline assembly
// operands, which will conflict with the ".set at" assembler option (which
// we use only for inline assembly, in order to maintain compatibility with
// GCC) and will also conflict with the user's usage of $1.
//
// The easiest way to avoid these conflicts and keep $1 as an allocatable
// register for generated code is to automatically clobber $1 for all inline
// assembly code.
//
// FIXME: We should automatically clobber $1 only for inline assembly code
// which actually uses it. This would allow LLVM to use $1 for inline
// assembly operands if the user's assembly code doesn't use it.
return "~{$1}";
}
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
IsMips16 = false;
IsMicromips = false;
IsNan2008 = isNaN2008Default();
IsSingleFloat = false;
FloatABI = HardFloat;
DspRev = NoDSP;
HasFP64 = isFP64Default();
for (const auto &Feature : Features) {
if (Feature == "+single-float")
IsSingleFloat = true;
else if (Feature == "+soft-float")
FloatABI = SoftFloat;
else if (Feature == "+mips16")
IsMips16 = true;
else if (Feature == "+micromips")
IsMicromips = true;
else if (Feature == "+dsp")
DspRev = std::max(DspRev, DSP1);
else if (Feature == "+dspr2")
DspRev = std::max(DspRev, DSP2);
else if (Feature == "+msa")
HasMSA = true;
else if (Feature == "+fp64")
HasFP64 = true;
else if (Feature == "-fp64")
HasFP64 = false;
else if (Feature == "+nan2008")
IsNan2008 = true;
else if (Feature == "-nan2008")
IsNan2008 = false;
}
setDataLayoutString();
return true;
}
int getEHDataRegisterNumber(unsigned RegNo) const override {
if (RegNo == 0) return 4;
if (RegNo == 1) return 5;
return -1;
}
bool isCLZForZeroUndef() const override { return false; }
};
const Builtin::Info MipsTargetInfoBase::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
{ #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsMips.def"
};
class Mips32TargetInfoBase : public MipsTargetInfoBase {
public:
Mips32TargetInfoBase(const llvm::Triple &Triple)
: MipsTargetInfoBase(Triple, "o32", "mips32r2") {
SizeType = UnsignedInt;
PtrDiffType = SignedInt;
Int64Type = SignedLongLong;
IntMaxType = Int64Type;
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
}
bool setABI(const std::string &Name) override {
if (Name == "o32" || Name == "eabi") {
ABI = Name;
return true;
}
return false;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
MipsTargetInfoBase::getTargetDefines(Opts, Builder);
Builder.defineMacro("__mips", "32");
Builder.defineMacro("_MIPS_ISA", "_MIPS_ISA_MIPS32");
const std::string& CPUStr = getCPU();
if (CPUStr == "mips32")
Builder.defineMacro("__mips_isa_rev", "1");
else if (CPUStr == "mips32r2")
Builder.defineMacro("__mips_isa_rev", "2");
else if (CPUStr == "mips32r3")
Builder.defineMacro("__mips_isa_rev", "3");
else if (CPUStr == "mips32r5")
Builder.defineMacro("__mips_isa_rev", "5");
else if (CPUStr == "mips32r6")
Builder.defineMacro("__mips_isa_rev", "6");
if (ABI == "o32") {
Builder.defineMacro("__mips_o32");
Builder.defineMacro("_ABIO32", "1");
Builder.defineMacro("_MIPS_SIM", "_ABIO32");
}
else if (ABI == "eabi")
Builder.defineMacro("__mips_eabi");
else
llvm_unreachable("Invalid ABI for Mips32.");
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
{ { "at" }, "$1" },
{ { "v0" }, "$2" },
{ { "v1" }, "$3" },
{ { "a0" }, "$4" },
{ { "a1" }, "$5" },
{ { "a2" }, "$6" },
{ { "a3" }, "$7" },
{ { "t0" }, "$8" },
{ { "t1" }, "$9" },
{ { "t2" }, "$10" },
{ { "t3" }, "$11" },
{ { "t4" }, "$12" },
{ { "t5" }, "$13" },
{ { "t6" }, "$14" },
{ { "t7" }, "$15" },
{ { "s0" }, "$16" },
{ { "s1" }, "$17" },
{ { "s2" }, "$18" },
{ { "s3" }, "$19" },
{ { "s4" }, "$20" },
{ { "s5" }, "$21" },
{ { "s6" }, "$22" },
{ { "s7" }, "$23" },
{ { "t8" }, "$24" },
{ { "t9" }, "$25" },
{ { "k0" }, "$26" },
{ { "k1" }, "$27" },
{ { "gp" }, "$28" },
{ { "sp","$sp" }, "$29" },
{ { "fp","$fp" }, "$30" },
{ { "ra" }, "$31" }
};
Aliases = GCCRegAliases;
NumAliases = llvm::array_lengthof(GCCRegAliases);
}
};
class Mips32EBTargetInfo : public Mips32TargetInfoBase {
void setDataLayoutString() override {
DataLayoutString = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
}
public:
Mips32EBTargetInfo(const llvm::Triple &Triple)
: Mips32TargetInfoBase(Triple) {
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "MIPSEB", Opts);
Builder.defineMacro("_MIPSEB");
Mips32TargetInfoBase::getTargetDefines(Opts, Builder);
}
};
class Mips32ELTargetInfo : public Mips32TargetInfoBase {
void setDataLayoutString() override {
DataLayoutString = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
}
public:
Mips32ELTargetInfo(const llvm::Triple &Triple)
: Mips32TargetInfoBase(Triple) {
BigEndian = false;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "MIPSEL", Opts);
Builder.defineMacro("_MIPSEL");
Mips32TargetInfoBase::getTargetDefines(Opts, Builder);
}
};
class Mips64TargetInfoBase : public MipsTargetInfoBase {
public:
Mips64TargetInfoBase(const llvm::Triple &Triple)
: MipsTargetInfoBase(Triple, "n64", "mips64r2") {
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::IEEEquad;
if (getTriple().getOS() == llvm::Triple::FreeBSD) {
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
}
setN64ABITypes();
SuitableAlign = 128;
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
}
void setN64ABITypes() {
LongWidth = LongAlign = 64;
PointerWidth = PointerAlign = 64;
SizeType = UnsignedLong;
PtrDiffType = SignedLong;
Int64Type = SignedLong;
IntMaxType = Int64Type;
}
void setN32ABITypes() {
LongWidth = LongAlign = 32;
PointerWidth = PointerAlign = 32;
SizeType = UnsignedInt;
PtrDiffType = SignedInt;
Int64Type = SignedLongLong;
IntMaxType = Int64Type;
}
bool setABI(const std::string &Name) override {
if (Name == "n32") {
setN32ABITypes();
ABI = Name;
return true;
}
if (Name == "n64") {
setN64ABITypes();
ABI = Name;
return true;
}
return false;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
MipsTargetInfoBase::getTargetDefines(Opts, Builder);
Builder.defineMacro("__mips", "64");
Builder.defineMacro("__mips64");
Builder.defineMacro("__mips64__");
Builder.defineMacro("_MIPS_ISA", "_MIPS_ISA_MIPS64");
const std::string& CPUStr = getCPU();
if (CPUStr == "mips64")
Builder.defineMacro("__mips_isa_rev", "1");
else if (CPUStr == "mips64r2")
Builder.defineMacro("__mips_isa_rev", "2");
else if (CPUStr == "mips64r3")
Builder.defineMacro("__mips_isa_rev", "3");
else if (CPUStr == "mips64r5")
Builder.defineMacro("__mips_isa_rev", "5");
else if (CPUStr == "mips64r6")
Builder.defineMacro("__mips_isa_rev", "6");
if (ABI == "n32") {
Builder.defineMacro("__mips_n32");
Builder.defineMacro("_ABIN32", "2");
Builder.defineMacro("_MIPS_SIM", "_ABIN32");
}
else if (ABI == "n64") {
Builder.defineMacro("__mips_n64");
Builder.defineMacro("_ABI64", "3");
Builder.defineMacro("_MIPS_SIM", "_ABI64");
}
else
llvm_unreachable("Invalid ABI for Mips64.");
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
{ { "at" }, "$1" },
{ { "v0" }, "$2" },
{ { "v1" }, "$3" },
{ { "a0" }, "$4" },
{ { "a1" }, "$5" },
{ { "a2" }, "$6" },
{ { "a3" }, "$7" },
{ { "a4" }, "$8" },
{ { "a5" }, "$9" },
{ { "a6" }, "$10" },
{ { "a7" }, "$11" },
{ { "t0" }, "$12" },
{ { "t1" }, "$13" },
{ { "t2" }, "$14" },
{ { "t3" }, "$15" },
{ { "s0" }, "$16" },
{ { "s1" }, "$17" },
{ { "s2" }, "$18" },
{ { "s3" }, "$19" },
{ { "s4" }, "$20" },
{ { "s5" }, "$21" },
{ { "s6" }, "$22" },
{ { "s7" }, "$23" },
{ { "t8" }, "$24" },
{ { "t9" }, "$25" },
{ { "k0" }, "$26" },
{ { "k1" }, "$27" },
{ { "gp" }, "$28" },
{ { "sp","$sp" }, "$29" },
{ { "fp","$fp" }, "$30" },
{ { "ra" }, "$31" }
};
Aliases = GCCRegAliases;
NumAliases = llvm::array_lengthof(GCCRegAliases);
}
bool hasInt128Type() const override { return true; }
};
class Mips64EBTargetInfo : public Mips64TargetInfoBase {
void setDataLayoutString() override {
if (ABI == "n32")
DataLayoutString = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
else
DataLayoutString = "E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128";
}
public:
Mips64EBTargetInfo(const llvm::Triple &Triple)
: Mips64TargetInfoBase(Triple) {}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "MIPSEB", Opts);
Builder.defineMacro("_MIPSEB");
Mips64TargetInfoBase::getTargetDefines(Opts, Builder);
}
};
class Mips64ELTargetInfo : public Mips64TargetInfoBase {
void setDataLayoutString() override {
if (ABI == "n32")
DataLayoutString = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
else
DataLayoutString = "e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128";
}
public:
Mips64ELTargetInfo(const llvm::Triple &Triple)
: Mips64TargetInfoBase(Triple) {
// Default ABI is n64.
BigEndian = false;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "MIPSEL", Opts);
Builder.defineMacro("_MIPSEL");
Mips64TargetInfoBase::getTargetDefines(Opts, Builder);
}
};
class PNaClTargetInfo : public TargetInfo {
public:
PNaClTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
BigEndian = false;
this->UserLabelPrefix = "";
this->LongAlign = 32;
this->LongWidth = 32;
this->PointerAlign = 32;
this->PointerWidth = 32;
this->IntMaxType = TargetInfo::SignedLongLong;
this->Int64Type = TargetInfo::SignedLongLong;
this->DoubleAlign = 64;
this->LongDoubleWidth = 64;
this->LongDoubleAlign = 64;
this->SizeType = TargetInfo::UnsignedInt;
this->PtrDiffType = TargetInfo::SignedInt;
this->IntPtrType = TargetInfo::SignedInt;
this->RegParmMax = 0; // Disallow regparm
}
void getArchDefines(const LangOptions &Opts, MacroBuilder &Builder) const {
Builder.defineMacro("__le32__");
Builder.defineMacro("__pnacl__");
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
getArchDefines(Opts, Builder);
}
bool hasFeature(StringRef Feature) const override {
return Feature == "pnacl";
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::PNaClABIBuiltinVaList;
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override;
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
return false;
}
const char *getClobbers() const override {
return "";
}
};
void PNaClTargetInfo::getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const {
Names = nullptr;
NumNames = 0;
}
void PNaClTargetInfo::getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const {
Aliases = nullptr;
NumAliases = 0;
}
// We attempt to use PNaCl (le32) frontend and Mips32EL backend.
class NaClMips32ELTargetInfo : public Mips32ELTargetInfo {
public:
NaClMips32ELTargetInfo(const llvm::Triple &Triple) :
Mips32ELTargetInfo(Triple) {
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::PNaClABIBuiltinVaList;
}
};
class Le64TargetInfo : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
public:
Le64TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
BigEndian = false;
NoAsmVariants = true;
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
DataLayoutString = "e-m:e-v128:32-v16:16-v32:32-v96:32-n8:16:32:64-S128";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "unix", Opts);
defineCPUMacros(Builder, "le64", /*Tuning=*/false);
Builder.defineMacro("__ELF__");
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::Le64::LastTSBuiltin - Builtin::FirstTSBuiltin;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::PNaClABIBuiltinVaList;
}
const char *getClobbers() const override { return ""; }
void getGCCRegNames(const char *const *&Names,
unsigned &NumNames) const override {
Names = nullptr;
NumNames = 0;
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
Aliases = nullptr;
NumAliases = 0;
}
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
return false;
}
bool hasProtectedVisibility() const override { return false; }
};
} // end anonymous namespace.
const Builtin::Info Le64TargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsLe64.def"
};
namespace {
static const unsigned SPIRAddrSpaceMap[] = {
1, // opencl_global
3, // opencl_local
2, // opencl_constant
4, // opencl_generic
0, // cuda_device
0, // cuda_constant
0 // cuda_shared
};
class SPIRTargetInfo : public TargetInfo {
public:
SPIRTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
"SPIR target must use unknown OS");
assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
"SPIR target must use unknown environment type");
BigEndian = false;
TLSSupported = false;
LongWidth = LongAlign = 64;
AddrSpaceMap = &SPIRAddrSpaceMap;
UseAddrSpaceMapMangling = true;
// Define available target features
// These must be defined in sorted order!
NoAsmVariants = true;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "SPIR", Opts);
}
bool hasFeature(StringRef Feature) const override {
return Feature == "spir";
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {}
const char *getClobbers() const override {
return "";
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override {}
bool
validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
return true;
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
}
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
return (CC == CC_SpirFunction ||
CC == CC_SpirKernel) ? CCCR_OK : CCCR_Warning;
}
CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override {
return CC_SpirFunction;
}
};
class SPIR32TargetInfo : public SPIRTargetInfo {
public:
SPIR32TargetInfo(const llvm::Triple &Triple) : SPIRTargetInfo(Triple) {
PointerWidth = PointerAlign = 32;
SizeType = TargetInfo::UnsignedInt;
PtrDiffType = IntPtrType = TargetInfo::SignedInt;
DataLayoutString = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
"v96:128-v192:256-v256:256-v512:512-v1024:1024";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "SPIR32", Opts);
}
};
class SPIR64TargetInfo : public SPIRTargetInfo {
public:
SPIR64TargetInfo(const llvm::Triple &Triple) : SPIRTargetInfo(Triple) {
PointerWidth = PointerAlign = 64;
SizeType = TargetInfo::UnsignedLong;
PtrDiffType = IntPtrType = TargetInfo::SignedLong;
DataLayoutString = "e-i64:64-v16:16-v24:32-v32:32-v48:64-"
"v96:128-v192:256-v256:256-v512:512-v1024:1024";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
DefineStd(Builder, "SPIR64", Opts);
}
};
class XCoreTargetInfo : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
public:
XCoreTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
BigEndian = false;
NoAsmVariants = true;
LongLongAlign = 32;
SuitableAlign = 32;
DoubleAlign = LongDoubleAlign = 32;
SizeType = UnsignedInt;
PtrDiffType = SignedInt;
IntPtrType = SignedInt;
WCharType = UnsignedChar;
WIntType = UnsignedInt;
UseZeroLengthBitfieldAlignment = true;
DataLayoutString = "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32"
"-f64:32-a:0:32-n32";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Builder.defineMacro("__XS1B__");
}
void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const override {
Records = BuiltinInfo;
NumRecords = clang::XCore::LastTSBuiltin-Builtin::FirstTSBuiltin;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
}
const char *getClobbers() const override {
return "";
}
void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const override {
static const char * const GCCRegNames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "cp", "dp", "sp", "lr"
};
Names = GCCRegNames;
NumNames = llvm::array_lengthof(GCCRegNames);
}
void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const override {
Aliases = nullptr;
NumAliases = 0;
}
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
return false;
}
int getEHDataRegisterNumber(unsigned RegNo) const override {
// R0=ExceptionPointerRegister R1=ExceptionSelectorRegister
return (RegNo < 2)? RegNo : -1;
}
};
const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{ #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
{ #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
#include "clang/Basic/BuiltinsXCore.def"
};
} // end anonymous namespace.
namespace {
// x86_32 Android target
class AndroidX86_32TargetInfo : public LinuxTargetInfo<X86_32TargetInfo> {
public:
AndroidX86_32TargetInfo(const llvm::Triple &Triple)
: LinuxTargetInfo<X86_32TargetInfo>(Triple) {
SuitableAlign = 32;
LongDoubleWidth = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
}
};
} // end anonymous namespace
namespace {
// x86_64 Android target
class AndroidX86_64TargetInfo : public LinuxTargetInfo<X86_64TargetInfo> {
public:
AndroidX86_64TargetInfo(const llvm::Triple &Triple)
: LinuxTargetInfo<X86_64TargetInfo>(Triple) {
LongDoubleFormat = &llvm::APFloat::IEEEquad;
}
bool useFloat128ManglingForLongDouble() const override {
return true;
}
};
} // end anonymous namespace
//===----------------------------------------------------------------------===//
// Driver code
//===----------------------------------------------------------------------===//
static TargetInfo *AllocateTarget(const llvm::Triple &Triple) {
llvm::Triple::OSType os = Triple.getOS();
switch (Triple.getArch()) {
default:
return nullptr;
case llvm::Triple::xcore:
return new XCoreTargetInfo(Triple);
case llvm::Triple::hexagon:
return new HexagonTargetInfo(Triple);
case llvm::Triple::aarch64:
if (Triple.isOSDarwin())
return new DarwinAArch64TargetInfo(Triple);
switch (os) {
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<AArch64leTargetInfo>(Triple);
case llvm::Triple::Linux:
return new LinuxTargetInfo<AArch64leTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<AArch64leTargetInfo>(Triple);
default:
return new AArch64leTargetInfo(Triple);
}
case llvm::Triple::aarch64_be:
switch (os) {
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<AArch64beTargetInfo>(Triple);
case llvm::Triple::Linux:
return new LinuxTargetInfo<AArch64beTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<AArch64beTargetInfo>(Triple);
default:
return new AArch64beTargetInfo(Triple);
}
case llvm::Triple::arm:
case llvm::Triple::thumb:
if (Triple.isOSBinFormatMachO())
return new DarwinARMTargetInfo(Triple);
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<ARMleTargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<ARMleTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<ARMleTargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<ARMleTargetInfo>(Triple);
case llvm::Triple::Bitrig:
return new BitrigTargetInfo<ARMleTargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<ARMleTargetInfo>(Triple);
case llvm::Triple::NaCl:
return new NaClTargetInfo<ARMleTargetInfo>(Triple);
case llvm::Triple::Win32:
switch (Triple.getEnvironment()) {
case llvm::Triple::Cygnus:
return new CygwinARMTargetInfo(Triple);
case llvm::Triple::GNU:
return new MinGWARMTargetInfo(Triple);
case llvm::Triple::Itanium:
return new ItaniumWindowsARMleTargetInfo(Triple);
case llvm::Triple::MSVC:
default: // Assume MSVC for unknown environments
return new MicrosoftARMleTargetInfo(Triple);
}
default:
return new ARMleTargetInfo(Triple);
}
case llvm::Triple::armeb:
case llvm::Triple::thumbeb:
if (Triple.isOSDarwin())
return new DarwinARMTargetInfo(Triple);
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<ARMbeTargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<ARMbeTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<ARMbeTargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<ARMbeTargetInfo>(Triple);
case llvm::Triple::Bitrig:
return new BitrigTargetInfo<ARMbeTargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<ARMbeTargetInfo>(Triple);
case llvm::Triple::NaCl:
return new NaClTargetInfo<ARMbeTargetInfo>(Triple);
default:
return new ARMbeTargetInfo(Triple);
}
case llvm::Triple::bpfeb:
case llvm::Triple::bpfel:
return new BPFTargetInfo(Triple);
case llvm::Triple::msp430:
return new MSP430TargetInfo(Triple);
case llvm::Triple::mips:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<Mips32EBTargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<Mips32EBTargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<Mips32EBTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<Mips32EBTargetInfo>(Triple);
default:
return new Mips32EBTargetInfo(Triple);
}
case llvm::Triple::mipsel:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<Mips32ELTargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<Mips32ELTargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<Mips32ELTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<Mips32ELTargetInfo>(Triple);
case llvm::Triple::NaCl:
return new NaClTargetInfo<NaClMips32ELTargetInfo>(Triple);
default:
return new Mips32ELTargetInfo(Triple);
}
case llvm::Triple::mips64:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<Mips64EBTargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<Mips64EBTargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<Mips64EBTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<Mips64EBTargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<Mips64EBTargetInfo>(Triple);
default:
return new Mips64EBTargetInfo(Triple);
}
case llvm::Triple::mips64el:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<Mips64ELTargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<Mips64ELTargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<Mips64ELTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<Mips64ELTargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<Mips64ELTargetInfo>(Triple);
default:
return new Mips64ELTargetInfo(Triple);
}
case llvm::Triple::le32:
switch (os) {
case llvm::Triple::NaCl:
return new NaClTargetInfo<PNaClTargetInfo>(Triple);
default:
return nullptr;
}
case llvm::Triple::le64:
return new Le64TargetInfo(Triple);
case llvm::Triple::ppc:
if (Triple.isOSDarwin())
return new DarwinPPC32TargetInfo(Triple);
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<PPC32TargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<PPC32TargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<PPC32TargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<PPC32TargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<PPC32TargetInfo>(Triple);
default:
return new PPC32TargetInfo(Triple);
}
case llvm::Triple::ppc64:
if (Triple.isOSDarwin())
return new DarwinPPC64TargetInfo(Triple);
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<PPC64TargetInfo>(Triple);
case llvm::Triple::Lv2:
return new PS3PPUTargetInfo<PPC64TargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<PPC64TargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<PPC64TargetInfo>(Triple);
default:
return new PPC64TargetInfo(Triple);
}
case llvm::Triple::ppc64le:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<PPC64TargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<PPC64TargetInfo>(Triple);
default:
return new PPC64TargetInfo(Triple);
}
case llvm::Triple::nvptx:
return new NVPTX32TargetInfo(Triple);
case llvm::Triple::nvptx64:
return new NVPTX64TargetInfo(Triple);
case llvm::Triple::amdgcn:
case llvm::Triple::r600:
return new AMDGPUTargetInfo(Triple);
case llvm::Triple::sparc:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<SparcV8TargetInfo>(Triple);
case llvm::Triple::Solaris:
return new SolarisTargetInfo<SparcV8TargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<SparcV8TargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<SparcV8TargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<SparcV8TargetInfo>(Triple);
default:
return new SparcV8TargetInfo(Triple);
}
// The 'sparcel' architecture copies all the above cases except for Solaris.
case llvm::Triple::sparcel:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<SparcV8elTargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<SparcV8elTargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<SparcV8elTargetInfo>(Triple);
case llvm::Triple::RTEMS:
return new RTEMSTargetInfo<SparcV8elTargetInfo>(Triple);
default:
return new SparcV8elTargetInfo(Triple);
}
case llvm::Triple::sparcv9:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<SparcV9TargetInfo>(Triple);
case llvm::Triple::Solaris:
return new SolarisTargetInfo<SparcV9TargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<SparcV9TargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<SparcV9TargetInfo>(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<SparcV9TargetInfo>(Triple);
default:
return new SparcV9TargetInfo(Triple);
}
case llvm::Triple::systemz:
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<SystemZTargetInfo>(Triple);
default:
return new SystemZTargetInfo(Triple);
}
case llvm::Triple::tce:
return new TCETargetInfo(Triple);
case llvm::Triple::x86:
if (Triple.isOSDarwin())
return new DarwinI386TargetInfo(Triple);
switch (os) {
case llvm::Triple::CloudABI:
return new CloudABITargetInfo<X86_32TargetInfo>(Triple);
case llvm::Triple::Linux: {
switch (Triple.getEnvironment()) {
default:
return new LinuxTargetInfo<X86_32TargetInfo>(Triple);
case llvm::Triple::Android:
return new AndroidX86_32TargetInfo(Triple);
}
}
case llvm::Triple::DragonFly:
return new DragonFlyBSDTargetInfo<X86_32TargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDI386TargetInfo(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDI386TargetInfo(Triple);
case llvm::Triple::Bitrig:
return new BitrigI386TargetInfo(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<X86_32TargetInfo>(Triple);
case llvm::Triple::KFreeBSD:
return new KFreeBSDTargetInfo<X86_32TargetInfo>(Triple);
case llvm::Triple::Minix:
return new MinixTargetInfo<X86_32TargetInfo>(Triple);
case llvm::Triple::Solaris:
return new SolarisTargetInfo<X86_32TargetInfo>(Triple);
case llvm::Triple::Win32: {
switch (Triple.getEnvironment()) {
case llvm::Triple::Cygnus:
return new CygwinX86_32TargetInfo(Triple);
case llvm::Triple::GNU:
return new MinGWX86_32TargetInfo(Triple);
case llvm::Triple::Itanium:
case llvm::Triple::MSVC:
default: // Assume MSVC for unknown environments
return new MicrosoftX86_32TargetInfo(Triple);
}
}
case llvm::Triple::Haiku:
return new HaikuX86_32TargetInfo(Triple);
case llvm::Triple::RTEMS:
return new RTEMSX86_32TargetInfo(Triple);
case llvm::Triple::NaCl:
return new NaClTargetInfo<X86_32TargetInfo>(Triple);
default:
return new X86_32TargetInfo(Triple);
}
case llvm::Triple::x86_64:
if (Triple.isOSDarwin() || Triple.isOSBinFormatMachO())
return new DarwinX86_64TargetInfo(Triple);
switch (os) {
case llvm::Triple::CloudABI:
return new CloudABITargetInfo<X86_64TargetInfo>(Triple);
case llvm::Triple::Linux: {
switch (Triple.getEnvironment()) {
default:
return new LinuxTargetInfo<X86_64TargetInfo>(Triple);
case llvm::Triple::Android:
return new AndroidX86_64TargetInfo(Triple);
}
}
case llvm::Triple::DragonFly:
return new DragonFlyBSDTargetInfo<X86_64TargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<X86_64TargetInfo>(Triple);
case llvm::Triple::OpenBSD:
return new OpenBSDX86_64TargetInfo(Triple);
case llvm::Triple::Bitrig:
return new BitrigX86_64TargetInfo(Triple);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<X86_64TargetInfo>(Triple);
case llvm::Triple::KFreeBSD:
return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple);
case llvm::Triple::Solaris:
return new SolarisTargetInfo<X86_64TargetInfo>(Triple);
case llvm::Triple::Win32: {
switch (Triple.getEnvironment()) {
case llvm::Triple::Cygnus:
return new CygwinX86_64TargetInfo(Triple);
case llvm::Triple::GNU:
return new MinGWX86_64TargetInfo(Triple);
case llvm::Triple::MSVC:
default: // Assume MSVC for unknown environments
return new MicrosoftX86_64TargetInfo(Triple);
}
}
case llvm::Triple::NaCl:
return new NaClTargetInfo<X86_64TargetInfo>(Triple);
case llvm::Triple::PS4:
return new PS4OSTargetInfo<X86_64TargetInfo>(Triple);
default:
return new X86_64TargetInfo(Triple);
}
case llvm::Triple::spir: {
if (Triple.getOS() != llvm::Triple::UnknownOS ||
Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
return nullptr;
return new SPIR32TargetInfo(Triple);
}
case llvm::Triple::spir64: {
if (Triple.getOS() != llvm::Triple::UnknownOS ||
Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
return nullptr;
return new SPIR64TargetInfo(Triple);
}
}
}
/// CreateTargetInfo - Return the target info object for the specified target
/// options.
TargetInfo *
TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
const std::shared_ptr<TargetOptions> &Opts) {
llvm::Triple Triple(Opts->Triple);
// Construct the target
std::unique_ptr<TargetInfo> Target(AllocateTarget(Triple));
if (!Target) {
Diags.Report(diag::err_target_unknown_triple) << Triple.str();
return nullptr;
}
Target->TargetOpts = Opts;
// Set the target CPU if specified.
if (!Opts->CPU.empty() && !Target->setCPU(Opts->CPU)) {
Diags.Report(diag::err_target_unknown_cpu) << Opts->CPU;
return nullptr;
}
// Set the target ABI if specified.
if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) {
Diags.Report(diag::err_target_unknown_abi) << Opts->ABI;
return nullptr;
}
// Set the fp math unit.
if (!Opts->FPMath.empty() && !Target->setFPMath(Opts->FPMath)) {
Diags.Report(diag::err_target_unknown_fpmath) << Opts->FPMath;
return nullptr;
}
// Compute the default target features, we need the target to handle this
// because features may have dependencies on one another.
llvm::StringMap<bool> Features;
if (!Target->initFeatureMap(Features, Diags, Opts->CPU,
Opts->FeaturesAsWritten))
return nullptr;
// Add the features to the compile options.
Opts->Features.clear();
for (const auto &F : Features)
Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
if (!Target->handleTargetFeatures(Opts->Features, Diags))
return nullptr;
return Target.release();
}
| [
"rodrigosoaresilva@gmail.com"
] | rodrigosoaresilva@gmail.com |
3b7c6078669cb3e0f9cf611021e3ffb5f4383c04 | 777a75e6ed0934c193aece9de4421f8d8db01aac | /src/Providers/UNIXProviders/SystemBIOS/UNIX_SystemBIOS_LINUX.hxx | c4c5664d5934f3bc02093d690e5f912add8b3b86 | [
"MIT"
] | permissive | brunolauze/openpegasus-providers-old | 20fc13958016e35dc4d87f93d1999db0eae9010a | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | refs/heads/master | 2021-01-01T20:05:44.559362 | 2014-04-30T17:50:06 | 2014-04-30T17:50:06 | 19,132,738 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 116 | hxx | #ifdef PEGASUS_OS_LINUX
#ifndef __UNIX_SYSTEMBIOS_PRIVATE_H
#define __UNIX_SYSTEMBIOS_PRIVATE_H
#endif
#endif
| [
"brunolauze@msn.com"
] | brunolauze@msn.com |
60100558cd23ee9378cf647362c5b2282fa95be8 | eca445a6711eb91eaf82e07edd723ff1e59230be | /hw2/hw2_1.cpp | be733fb9c869460883ef16adf53358d617d905b9 | [] | no_license | guanrenchen/1051-Data-Structure | 04847663cab30c8e73d1f85564e80324387f15f6 | 4cda8cdb4907264bfab07e0e4d73351247be818b | refs/heads/master | 2022-12-08T23:24:30.712930 | 2020-09-06T08:39:42 | 2020-09-06T08:39:42 | 293,236,355 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,393 | cpp | #include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
using namespace std;
vector<int> matrixToArray(int n, int a, int b, int* matrix){
int i=a-1, j=0, end_i=n-b, end_j=n-1;
vector<int> e;
while(1){
e.push_back(matrix[i*n+j]);
if(i==end_i && j==end_j) break;
++i;
++j;
if(j>=n){
j=n-i+1;
i=0;
}else if(i>=n){
i=n-j-1;
j=0;
}
}
return e;
}
void printArray(int n, int a, int b, vector<int> e){
int i, j, index;
for(index=0, i=a-1, j=0; index<e.size(); ++index){
printf("e[%d] = %d\td(%d,%d)\n", index, e.at(index), i++, j++);
if(j>=n){
j=n-i+1;
i=0;
}else if(i>=n){
i=n-j-1;
j=0;
}
}
}
int main(int argc, char* argv[]){
string fileName;
fstream inFile;
cout << "Please input the file name: ";
cin >> fileName;
inFile.open(fileName.data(), ios::in);
if(!inFile){
cout << "File open failed" << endl;
return 0;
}
int n;
inFile >> n;
int i, matrix[n][n];
for(i=0; i<n*n; ++i)
inFile >> matrix[i/n][i%n];
int a, b;
cout << "a: ";
cin >> a;
cout << "b: ";
cin >> b;
vector<int> e = matrixToArray(n, a, b, *matrix);
printArray(n, a, b, e);
return 0;
}
| [
"jeremy851004@gmail.com"
] | jeremy851004@gmail.com |
954a59f2a04f0ee9f220bc1d648e6daa8ffbf55f | 20f4d6957b6b473459cffe7d438b22d823c2001b | /Neo/Neo.h | b51d857ffd92382a8e71d142abedf53eee562f02 | [] | no_license | jayesh212/CodeJ | 0ae95c4da56eb8764bb16bf767cd3d08b5bb09ec | e990c4b405944fe6108d778d2ce4e313bce959ac | refs/heads/master | 2022-09-13T12:19:26.478348 | 2020-05-26T01:21:41 | 2020-05-26T01:21:41 | 266,915,347 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,443 | h | #ifndef __$$__Neo_h
#define __$$__Neo_h 7
#define SFML_NO_DEPRECATED_WARNINGS
#include <stdio.h>
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <windows.h>
#include <cmath>
#include "String.hpp"
using namespace sf;
class Button // Abstract class for defining the key features of a button
{
public:
virtual int isClicked(sf::Event event, sf::Window &window) = 0;
virtual void setPos(int x, int y) = 0;
virtual void setText(JString string) = 0;
virtual void setTextSize(int textSize) = 0;
virtual void getPosition(int &posX, int &posY) = 0;
virtual void setFillColor(sf::Color color) = 0;
virtual void setTextColor(sf::Color color) = 0;
virtual void setFont(sf::Font &font) = 0;
virtual void draw(sf::RenderWindow &window) = 0;
};
class RectangleButton : public Button
{
private:
sf::RectangleShape buttonRect;
sf::Text text;
JString string;
int width;
int height;
int posX;
int posY;
sf::Color fillColor;
sf::Color textColor;
bool blink;
sf::Texture texture;
bool blinkRect;
bool tToggle;
public:
RectangleButton()
{
this->width = 0;
this->height = 0;
posX = 0;
posY = 0;
buttonRect.setPosition(posX, posY);
text.setString("");
text.setPosition(posX, posY);
this->blink = true;
this->tToggle = false;
this->blinkRect = false;
}
RectangleButton(int posX, int posY, sf::Color fillColor, int width, int height)
{
this->posX = posX;
this->posY = posY;
if (width < 0)
this->width = 0;
else
this->width = width;
if (height < 0)
this->height = 0;
else
this->height = height;
buttonRect.setPosition(this->posX, this->posY);
buttonRect.setSize(Vector2f(this->width, this->height));
buttonRect.setFillColor(fillColor);
this->fillColor = fillColor;
text.setString("");
text.setPosition(posX, posY);
this->blink = true;
this->tToggle = false;
this->blinkRect = false;
}
void blinkRectToggle(bool state)
{
this->blinkRect = state;
}
int isClicked(sf::Event event, sf::Window &window)
{
int x = Mouse::getPosition(window).x;
int y = Mouse::getPosition(window).y;
int pressed = 0;
if (event.type == Event::MouseButtonPressed)
{
switch (event.key.code)
{
case Mouse::Left:
pressed = 1;
break;
case Mouse::Right:
pressed = 2;
break;
default:
pressed = 0;
break;
}
}
if ((x > this->posX) && (x < this->posX + this->width) && (y > this->posY) && y < this->posY + this->height)
{
if (this->blink)
{
sf::Color color;
if (this->textColor.r > 195)
color.r = 255;
else
color.r = this->textColor.r + 60;
if (this->textColor.b > 195)
color.b = 255;
else
color.b = this->textColor.b + 60;
if (this->textColor.g > 195)
color.g = 255;
else
color.g = this->textColor.g + 60;
color.a = this->textColor.a;
text.setFillColor(color);
}
if (this->blinkRect)
{
sf::Color color;
if (this->fillColor.r > 195)
color.r = 255;
else
color.r = this->fillColor.r + 60;
if (this->fillColor.b > 195)
color.b = 255;
else
color.b = this->fillColor.b + 60;
if (this->fillColor.g > 195)
color.g = 255;
else
color.g = this->fillColor.g + 60;
if ((this->fillColor).a < 200)
color.a = this->fillColor.a + 40;
buttonRect.setFillColor(color);
}
if (pressed == 1)
return 1;
if (pressed == 2)
return 2;
}
else
{
if (!tToggle && this->blink)
text.setFillColor(this->textColor);
if (this->blinkRect)
buttonRect.setFillColor(this->fillColor);
}
return 0;
}
void setPos(int x, int y)
{
this->posX = x;
this->posY = y;
buttonRect.setPosition(Vector2f(x, y));
text.setPosition(posX, posY);
}
void setText(JString string)
{
int size = string.getSize();
char *charray = new char[size];
string.getString(charray);
text.setString(charray);
this->string = string;
}
void setTextSize(int textSize)
{
text.setCharacterSize(textSize);
Vector2f textPos;
textPos = text.findCharacterPos(string.getSize());
if (textPos.x < this->posX + width)
text.setPosition(this->posX, this->posY + this->height / 2 - textSize / 2);
else
text.setPosition(this->posX, this->posY + this->height / 2 - textSize / 2);
}
void setTextPos(int posX, int posY)
{
Vector2f textPos;
textPos.x = posX;
textPos.y = posY;
text.setPosition(textPos);
}
void getPosition(int &posX, int &posY)
{
posX = this->posX;
posY = this->posY;
}
void setFillColor(sf::Color color)
{
buttonRect.setFillColor(color);
this->fillColor = color;
}
void setTextColor(sf::Color color)
{
text.setFillColor(color);
this->tToggle = false;
this->textColor = color;
}
void setSize(int width, int height)
{
this->width = width;
this->height = height;
buttonRect.setSize(Vector2f(this->width, this->height));
text.setPosition(this->posX, this->posY + this->width / 2 - text.getCharacterSize() / 2);
}
void setFont(sf::Font &font)
{
text.setFont(font);
}
void draw(sf::RenderWindow &window)
{
window.draw(buttonRect);
window.draw(text);
}
void setBlink(bool state)
{
this->blink = state;
}
void setTexture(const char *filePath)
{
this->tToggle = true;
this->texture.loadFromFile(filePath);
buttonRect.setTexture(&this->texture);
buttonRect.setSize(Vector2f(this->width, this->height));
this->blink = false;
}
};
class CircleButton
{
private:
sf::CircleShape buttonCircle;
int radius;
int posX;
int posY;
int centerX, centerY;
sf::Color fillColor;
bool blink;
sf::Texture texture;
bool tToggle;
public:
CircleButton()
{
this->radius = 0;
posX = 0;
posY = 0;
buttonCircle.setPosition(posX, posY);
buttonCircle.setPointCount(30);
this->blink = true;
this->tToggle = false;
}
CircleButton(int posX, int posY, sf::Color fillColor, int radius)
{
this->tToggle = false;
this->posX = posX;
this->posY = posY;
if (radius < 0)
this->radius = 0;
else
this->radius = radius;
this->centerX = this->posX + this->radius;
this->centerY = this->posY + this->radius;
buttonCircle.setPosition(this->posX, this->posY);
buttonCircle.setRadius(this->radius);
buttonCircle.setFillColor(fillColor);
this->fillColor = fillColor;
buttonCircle.setPointCount(30);
this->blink = true;
}
int isClicked(sf::Event event, sf::Window &window)
{
int x = Mouse::getPosition(window).x;
int y = Mouse::getPosition(window).y;
int pressed = 0;
if (event.type == Event::MouseButtonPressed)
{
switch (event.key.code)
{
case Mouse::Left:
pressed = 1;
break;
case Mouse::Right:
pressed = 2;
break;
default:
pressed = 0;
break;
}
}
double distFromCenter = pow(x - this->centerX, 2) + pow(y - this->centerY, 2);
distFromCenter = sqrt(distFromCenter);
if (distFromCenter < this->radius)
{
if (this->blink)
{
sf::Color color;
color.r = this->fillColor.r + 60;
color.b = this->fillColor.b + 60;
color.g = this->fillColor.g + 60;
buttonCircle.setFillColor(color);
}
if (pressed == 1)
return 1;
if (pressed == 2)
return 2;
}
else
{
if (!tToggle)
buttonCircle.setFillColor(this->fillColor);
}
return 0;
}
void setPos(int x, int y)
{
this->posX = x;
this->posY = y;
this->centerX = this->posX + this->radius;
this->centerY = this->posY + this->radius;
buttonCircle.setPosition(Vector2f(x, y));
}
void setPointCount(int points)
{
buttonCircle.setPointCount(points);
}
void getPosition(int &posX, int &posY)
{
posX = this->posX;
posY = this->posY;
}
void setFillColor(sf::Color color)
{
buttonCircle.setFillColor(color);
this->tToggle = false;
this->fillColor = color;
}
void setSize(int radius)
{
this->radius = radius;
this->centerX = this->posX + this->radius;
this->centerY = this->posY + this->radius;
buttonCircle.setRadius(this->radius);
}
void draw(sf::RenderWindow &window)
{
window.draw(buttonCircle);
}
void setBlink(bool state)
{
this->blink = state;
}
void setTexture(const char *filePath)
{
(this->texture).loadFromFile(filePath);
buttonCircle.setTexture(&this->texture);
buttonCircle.setRadius(this->radius);
this->tToggle = true;
this->blink = false;
}
};
#endif | [
"56252903+jayesh212@users.noreply.github.com"
] | 56252903+jayesh212@users.noreply.github.com |
8cac21e9828bf3e42dcd0d0707db072debe558e5 | 2c055bde7981beac781a8afef05874021d350744 | /Assignment2/task2 - Histogram/forhistogram.cpp | 437707c280513e47de0b20edc17bc926d40bec8c | [] | no_license | devgonvarun/Parallel-Computing | a689c9e6db5676dd39491a2f0d9d5a23968d93c9 | 40ff453279dfea06e6c0457acd969040e20bc386 | refs/heads/master | 2022-12-29T15:51:48.360125 | 2020-10-13T19:13:43 | 2020-10-13T19:13:43 | 294,515,509 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,435 | cpp | #include <vector>
#include <iostream>
#include <random>
#include <chrono>
#include <numeric>
#include <ctime>
#include <omp.h>
using namespace std;
struct generator_config
{
generator_config(int max) : max(max) {}
int max;
};
struct generator
{
generator(const generator_config& cfg) : dist(0, cfg.max){}
int operator()()
{
engine.seed(chrono::system_clock::now().time_since_epoch().count());
return dist(engine);
}
private:
minstd_rand engine;
uniform_int_distribution<int> dist;
};
struct histogram
{
histogram(int count,int index) : data(count, vector<int> (index)), index(index), max(count)
{
}
void add(int i, int ind2)
{
++data[i][ind2];
}
void print()
{
int sum = 0;
for (int i = 0; i < data.size(); i++) {
for (int j = 0; j < data[i].size(); j++){
sum = sum + data[i][j];
}
cout<<i << ":" << sum<< endl;
sum = 0;
}
cout <<endl<<"total:" << accumulate(data.cbegin(), data.cend(), 0, [](auto lhs, const auto& rhs) {
return std::accumulate(rhs.cbegin(), rhs.cend(), lhs);
})<<endl;
}
private:
int max;
int index;
vector<vector<int>> data;
};
struct worker
{
worker(histogram &h, const generator_config& cfg, int index) : h(h), cfg(cfg), index(index){}
void operator()()
{
generator gen(cfg);
int next = gen();
h.add(next,index);
}
private:
int index;
histogram& h;
const generator_config& cfg;
};
int main()
{
int max = 10;
int repeats_to_do = 10000000;
histogram h(max+1,repeats_to_do);
generator_config cfg(max);
int num_threads = 16; // Change value here to change number of threads
omp_set_num_threads(num_threads);
auto t1 = omp_get_wtime();
//#pragma omp parallel for schedule(static)
//#pragma omp parallel for schedule(dynamic)
//#pragma omp parallel for schedule(guided)
//#pragma omp parallel for schedule(runtime)
#pragma omp parallel for schedule(auto)
for(int t=0;t<repeats_to_do;t++){
worker(h, cfg,t)();
}
auto t2 = omp_get_wtime();
cout << endl <<"Time in seconds = "<<chrono::duration<double>(t2 - t1).count() << endl<< endl;
h.print();
}
| [
"devgonvarun@gmail.com"
] | devgonvarun@gmail.com |
fa8f46c33dde643a99c71620d8ce3aab089549b2 | 3ccdeb22820ddab37baf4999369d44a75a207393 | /src/panorama_hand_widget.h | d1d5cb8e99997832c68b8cecc96944785e8ebb5f | [] | no_license | tianxiejack/pro_xzpj_360pano_qt | b43a10c07e6b1083db88d9a487097c3165f1f81e | fdb8961907ba76c9f840fa5538d486622929566c | refs/heads/master | 2020-04-18T00:58:39.009571 | 2019-01-22T05:43:39 | 2019-01-22T05:43:39 | 167,100,427 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 374 | h | #ifndef PANORAMA_HAND_WIDGET_H
#define PANORAMA_HAND_WIDGET_H
#include <QWidget>
#include <QPushButton>
class panorama_hand_widget : public QWidget
{
Q_OBJECT
public:
explicit panorama_hand_widget(QWidget *parent = nullptr);
QPushButton *panoramafresh;
private:
/*全景图手动控制界面*/
signals:
public slots:
};
#endif // PANORAMA_HAND_WIDGET_H
| [
"13270236670@163.com"
] | 13270236670@163.com |
c392ff1f570c1f584283487b79693e139cf70a3b | a7eca1d8e64511b40699b46224a02ebcfd8bfdfd | /Projet1/Projet1/m_graphique.cpp | ee9b3450e1766f411964b44e11848af1fdd919b3 | [] | no_license | seb3008/TIPITOU | 34031ab6c2b8f7d8f42a02552e3ca3f3d2adc080 | 5bc594ac72ba712b2181643f94b99e329feba9ef | refs/heads/master | 2021-01-13T08:49:14.402697 | 2016-11-23T05:02:15 | 2016-11-23T05:02:15 | 71,898,957 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 8,076 | cpp | /*
* Module qui permet la gestion d'une boîte électrique
* avec disjoncteurs.
*
* La boite doit d'abord être initialisée au nombre d'ampère voulu.
*
*/
#include <stdio.h>
#include <math.h>
#include "types_et_constantes_globaux.h"
#include "winBGIm.h"
#include "m_graphique.h"
#include "m_util_fonctions.h"
/*
* Fonction locale qui affiche le contour d'un disjoncteur
* avec les valeurs reçues.
*/
void afficher_contour_disjoncteur(double ampere,
int tension,
int puissance,
int gauche,
int haut,
int couleur){
// Contour du disjoncteur
setcolor(couleur);
char msg [TAILLE_MSG] = {0};
// Aide à la clarté de la lecture du code.
int droite = gauche + LARGEUR_DISJONCTEUR;
int bas = haut + HAUTEUR_DISJONCTEUR;
int gauche_dep = gauche;
//// Affiche ampère et tension
outtextxy(gauche, haut - TAILLE_CAR, double_a_chaine(ampere));
gauche+=strlen(double_a_chaine(ampere)) * TAILLE_CAR;
outtextxy(gauche, haut - TAILLE_CAR, "A/");
gauche+=strlen("A/") * TAILLE_CAR;
outtextxy(gauche, haut - TAILLE_CAR, itoa(tension, msg, 10));
gauche+=strlen(msg) * TAILLE_CAR;
outtextxy(gauche, haut - TAILLE_CAR, "V/");
gauche+=strlen("V/") * TAILLE_CAR;
outtextxy(gauche, haut - TAILLE_CAR, double_a_chaine(puissance * tension));
gauche+=strlen(double_a_chaine(puissance * tension)) * TAILLE_CAR;
outtextxy(gauche, haut - TAILLE_CAR, "W");
// Afficher le contour
rectangle(gauche_dep, haut, droite, bas);
}
// Affiche un carré COULEUR_ALLUME ou COULEUR_ETEINT selon l'état.
// La bonne position a été calculée préalablement.
void afficher_interrupteur(int etat,
int tension,
int gauche,
int haut){
// Calcul la position dans le disjoncteur selon son état.
gauche = (etat)
? gauche
: gauche + (LARGEUR_DISJONCTEUR / 2);
// Afficher l'état de l'interrupteur à l'aide du remplissage.
setfillstyle(1,
(etat)?COULEUR_ALLUME:COULEUR_ETEINT);
// Afficher l'interrupteur à l'aide de bar.
bar(gauche,
haut,
gauche + LARGEUR_DISJONCTEUR / 2,
haut + HAUTEUR_DISJONCTEUR);
}
// Effectue les calculs pour afficher le contour et l'interrupteur
// au bon endroit à l'écran.
void afficher_disjoncteur(const t_boite* boite,
int colonne,
int ligne,
int GAP_AUTOUR_X,
int GAP_AUTOUR_Y){
// Pout obtenir un disjoncteur non vide de la boîte.
t_disjoncteur* disjoncteur;
disjoncteur = boite->tab_disjoncteurs[ligne][colonne];
// Tiens compte du gap en x avant la boite.
int gauche = colonne *
(GAP_X + LARGEUR_DISJONCTEUR) + GAP_X + GAP_AUTOUR_X;
// Si c'est vide, on affiche un contour prévu pour les disjoncteurs vides,
// ampère et tension à 0.
if(disjoncteur == NULL){
// Tiens compte du gap en y avant la boite.
int haut = ligne *
(HAUTEUR_DISJONCTEUR + GAP_Y) + GAP_Y + GAP_AUTOUR_Y;
afficher_contour_disjoncteur(0, 0, 0,
gauche, haut, COULEUR_CONTOUR_DISJ_VIDE);
}
// Sinon, on affiche le disjoncteur selon son état.
else{
// Tiens compte du gap en y avant la boite.
int haut = ligne *
(HAUTEUR_DISJONCTEUR + GAP_Y) + GAP_Y + GAP_AUTOUR_Y;
afficher_contour_disjoncteur(disjoncteur->ampere,
disjoncteur->tension,
disjoncteur->demande_du_circuit,
gauche, haut, COULEUR_CONTOUR_DISJ);
afficher_interrupteur(disjoncteur->etat,
disjoncteur->tension,
gauche,
haut);
}
}
// Contour de la boîte qui s'adapte au nombre de disjoncteurs.
void afficher_cadre_autour(int largeur_boite,
int hauteur_boite,
int GAP_AUTOUR_X,
int GAP_AUTOUR_Y){
int droite = getmaxx() - GAP_AUTOUR_X;
int bas = GAP_AUTOUR_Y + hauteur_boite + GAP_Y;
setcolor(BLUE);
rectangle(GAP_AUTOUR_X, GAP_AUTOUR_Y, droite, bas);
}
/*
* Fonction locale pour afficher le temps UPS, l'ampérage de la boîte
* et la puissance totale consommée.
*/
void afficher_info_boite(const t_boite* boite,
int* hauteur_car, int* largeur_car){
// Gestion des saut de ligne selon la taille du texte.
int ligne;
setcolor(WHITE);
settextstyle(1,0,1);
*hauteur_car = textheight("a");
*largeur_car = textwidth("a");
ligne = POS_INFO_Y;
rectangle (POS_INFO_X,
POS_INFO_Y,
POS_INFO_X + *largeur_car * LARGEUR_BOX,
POS_INFO_Y + *hauteur_car * HAUTEUR_BOX);
char msg[TAILLE_MSG];
sprintf_s(msg, "Capacité : %4.0lf A", boite->nb_amperes);
outtextxy(POS_INFO_X + TAILLE_CAR, POS_INFO_Y + ligne, msg);
ligne+= *hauteur_car;
sprintf_s(msg, "Total consommée : %4.0lf W", consommation_totale(boite));
outtextxy(POS_INFO_X + TAILLE_CAR, POS_INFO_Y + ligne, msg);
ligne+= *hauteur_car;
sprintf_s(msg, "UPS : %4.2lf heure(s) disponible(s)", temps_ups(boite));
outtextxy(POS_INFO_X + TAILLE_CAR, POS_INFO_Y + ligne, msg);
ligne+= *hauteur_car;
sprintf_s(msg,
"Nombre de disjoncteurs %d V: %d",
TENSION_PHASE,
nb_disjoncteurs_tension(boite, TENSION_PHASE));
outtextxy(POS_INFO_X + TAILLE_CAR, POS_INFO_Y + ligne, msg);
ligne+= *hauteur_car;
sprintf_s(msg,
"Nombre de disjoncteurs %d V: %d",
TENSION_ENTREE,
nb_disjoncteurs_tension(boite, TENSION_ENTREE));
outtextxy(POS_INFO_X + TAILLE_CAR, POS_INFO_Y + ligne, msg);
}
// Affiche la boîte électrique
// et l'état de ses disjoncteurs
void afficher_boite(const t_boite* boite){
/*
* Stratégie : L'affichage a été découpé en plusieurs sous-=programmes.
* Ici, le travail consiste à obtenir les valeurs de l'écran pour afficher
* la boîte centrée avec tous ses disjoncteurs.
*/
int NB_COL = NB_COLONNES;
// Recevoir la taille des caractères après l'affichage des infos.
int hauteur_car;
int largeur_car;
int nb_disjoncteurs = nb_disjoncteurs_actuel(boite);
// Selon le nombre de colonnes à intervalles égaux.
int largeur_boite = (NB_COLONNES * LARGEUR_DISJONCTEUR +
(NB_COLONNES + 1) * GAP_X);
// Dépend du nombre de lignes de disjoncteurs (2 x ligne).
int hauteur_boite =
NB_LIGNES_MAX * (HAUTEUR_DISJONCTEUR + GAP_Y) + 2 * GAP_Y;
// Retient la taille des carcayères avant d'afficher les infos.
textsettingstype ts;
gettextsettings(&ts);
cleardevice();
afficher_info_boite(boite, &hauteur_car, &largeur_car);
// Remet les caractères à leur taille initiale.
settextstyle(ts.font,ts.direction,ts.charsize);
// Espace autour de la boite.
int GAP_AUTOUR_X = (getmaxx() - largeur_boite) / 2;
int GAP_AUTOUR_Y = HAUTEUR_BOX * hauteur_car + 2 * GAP_Y;
afficher_cadre_autour(largeur_boite,
hauteur_boite,
GAP_AUTOUR_X,
GAP_AUTOUR_Y);
// Affiche les disjoncteurs à l'intérieur de la boite.
for(int i = 0; i < NB_COLONNES; i++){
for(int j = 0; j < NB_LIGNES_MAX; j++){
afficher_disjoncteur(boite,
i, j,
GAP_AUTOUR_X,
GAP_AUTOUR_Y + GAP_Y);
}
}
} | [
"leveauxsebastien@gmail.com"
] | leveauxsebastien@gmail.com |
400e2b33ff03af2e7870a15c45ae3b289e2abcd1 | 808919b58aa7f63c5edea48944b647a6839675a7 | /Utilities/FrameworkCls.cpp | 60c12d3787ef92749522dbdc89ecf34bd425d11e | [] | no_license | alexfordc/Quan | 65d2905ef6232ecf9ab004408c36481281dc76fe | 6963940f6506145d1a2b40e66ce5e650ab47e048 | refs/heads/master | 2021-06-09T03:50:57.548736 | 2016-12-18T07:58:38 | 2016-12-18T07:58:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 922 | cpp | /****************************************************************************
**
** Copyright (C) 2009-2010 ECT. All rights reserved.
**
** This file is part of the Mini-Viewer.
**
** Licensees holding a valid license agreement ECT Trolltech or any of its
** authorized distributors may use this file in accordance with
** the License Agreement provided with the Licensed Software.
**
** See http://www.ectworks.com/pricing.html or email sales@ectworks.com for
** information about ECT's Commercial License Agreements.
**
** Contact info@ectworks.com if any conditions of this licensing are
** not clear to you.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include "FrameworkCls.h"
#include <algorithm>
namespace fmecls
{
} | [
"lwzwj@163.com"
] | lwzwj@163.com |
5204eaf7c8b20f20da048d3afef5d60638e77b10 | bcba9aaa4ad46d7050aa241ac547c529e520bd8d | /ABC045proBdup.cpp | 2ce2d058332b004ba694cea0e0c406e43fe6d239 | [] | no_license | mizuirorivi/kyopuro | d3a99a3d615d4f06706320eef608ad2a8d804c2b | 31762cd1d85e189baae700429d115fc0934e2472 | refs/heads/master | 2022-02-20T21:54:41.991261 | 2021-05-27T23:45:09 | 2021-05-27T23:45:09 | 192,044,762 | 0 | 3 | null | 2019-06-30T04:18:58 | 2019-06-15T06:24:10 | C++ | UTF-8 | C++ | false | false | 821 | cpp | #include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
string sa,sb,sc;cin >> sa >> sb >> sc;
queue<char> qa,qb,qc;
int i,j,k;
rep(i,sa.size()) qa.push(sa[i]);
rep(i,sb.size()) qb.push(sb[i]);
rep(i,sc.size()) qc.push(sc[i]);
char ans = 'a';
while(1){
if(ans=='a'){if(qa.empty()) break;ans=qa.front();qa.pop();}
if(ans=='b'){if(qb.empty()) break;ans=qb.front();qb.pop();}
if(ans=='c'){if(qc.empty()) break;ans=qc.front();qc.pop();}
}
cout << (char)(ans+'A'-'a') << endl;
}
| [
"onodaha@gmail.com"
] | onodaha@gmail.com |
a4fad5829a19b3c5beee490be6ba4f6432163d15 | ae33344a3ef74613c440bc5df0c585102d403b3b | /SDK/SOT_AD_FirstPerson_PlayerPirate_Female_Thin_classes.hpp | 4bc4947cd6140812d4aa8239d44ac5457e856845 | [] | no_license | ThePotato97/SoT-SDK | bd2d253e811359a429bd8cf0f5dfff73b25cecd9 | d1ff6182a2d09ca20e9e02476e5cb618e57726d3 | refs/heads/master | 2020-03-08T00:48:37.178980 | 2018-03-30T12:23:36 | 2018-03-30T12:23:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 820 | hpp | #pragma once
// SOT: Sea of Thieves (1.0) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x4)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass AD_FirstPerson_PlayerPirate_Female_Thin.AD_FirstPerson_PlayerPirate_Female_Thin_C
// 0x0000 (0x0310 - 0x0310)
class UAD_FirstPerson_PlayerPirate_Female_Thin_C : public UAD_FirstPerson_PlayerPirate_Female_Default_C
{
public:
static UClass* StaticClass()
{
static UClass* ptr = 0;
if(ptr == 0) { ptr = UObject::FindClass(_xor_("BlueprintGeneratedClass AD_FirstPerson_PlayerPirate_Female_Thin.AD_FirstPerson_PlayerPirate_Female_Thin_C")); }
return ptr;
}
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"antoniohermano@gmail.com"
] | antoniohermano@gmail.com |
ff76e712196f24d5df0cb094f91d92c5eb33d291 | 637e5ba215dc9ac05a7a0db50a46b8e948e07c6d | /src/innerprocess_communication/src/innerprocess_communication_node.cpp | 3adb908c6602c6bfd326c801b6f9db1b5d4ddc40 | [] | no_license | youssefmohamed552/amr_2018 | d5a479ce6ac4f6b84cc5ead552b33856edee4ed0 | b5e842fc7824267631cd71323e3c35d4e10c2261 | refs/heads/master | 2020-03-30T10:53:58.794433 | 2019-02-02T05:59:26 | 2019-02-02T05:59:26 | 151,142,311 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 537 | cpp | #include <iostream>
#include "ros/ros.h"
#include "innerprocess_communication/innerprocess_communication.h"
int
main(int argc, char* argv[]){
InnerprocessCommunication innerprocess_communication;
ros::init( argc, argv, "innerprocess_communication_node" );
ros::NodeHandle node_handle;
ros::Subscriber update_subscriber = node_handle.subscribe( "update" , 1, &InnerprocessCommunication::handle_update, &innerprocess_communication );
ros::Rate timer(1);
while(ros::ok()){
ros::spinOnce();
timer.sleep();
}
return 0;
}
| [
"youssefmohamed552@gmail.com"
] | youssefmohamed552@gmail.com |
f0d65dd51b68611b573fb1d97d2b2c175d5611b3 | 0dca3325c194509a48d0c4056909175d6c29f7bc | /qualitycheck/include/alibabacloud/qualitycheck/QualitycheckClient.h | 02817fa46a6927542f7f3c5caf017a9383ec961e | [
"Apache-2.0"
] | permissive | dingshiyu/aliyun-openapi-cpp-sdk | 3eebd9149c2e6a2b835aba9d746ef9e6bef9ad62 | 4edd799a79f9b94330d5705bb0789105b6d0bb44 | refs/heads/master | 2023-07-31T10:11:20.446221 | 2021-09-26T10:08:42 | 2021-09-26T10:08:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 67,152 | h | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_QUALITYCHECK_QUALITYCHECKCLIENT_H_
#define ALIBABACLOUD_QUALITYCHECK_QUALITYCHECKCLIENT_H_
#include <future>
#include <alibabacloud/core/AsyncCallerContext.h>
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RpcServiceClient.h>
#include "QualitycheckExport.h"
#include "model/AddBusinessCategoryRequest.h"
#include "model/AddBusinessCategoryResult.h"
#include "model/AddRuleCategoryRequest.h"
#include "model/AddRuleCategoryResult.h"
#include "model/AddThesaurusForApiRequest.h"
#include "model/AddThesaurusForApiResult.h"
#include "model/AssignReviewerRequest.h"
#include "model/AssignReviewerResult.h"
#include "model/CreateAsrVocabRequest.h"
#include "model/CreateAsrVocabResult.h"
#include "model/CreateSkillGroupConfigRequest.h"
#include "model/CreateSkillGroupConfigResult.h"
#include "model/CreateTaskAssignRuleRequest.h"
#include "model/CreateTaskAssignRuleResult.h"
#include "model/CreateUserRequest.h"
#include "model/CreateUserResult.h"
#include "model/CreateWarningConfigRequest.h"
#include "model/CreateWarningConfigResult.h"
#include "model/DelRuleCategoryRequest.h"
#include "model/DelRuleCategoryResult.h"
#include "model/DelThesaurusForApiRequest.h"
#include "model/DelThesaurusForApiResult.h"
#include "model/DeleteAsrVocabRequest.h"
#include "model/DeleteAsrVocabResult.h"
#include "model/DeleteBusinessCategoryRequest.h"
#include "model/DeleteBusinessCategoryResult.h"
#include "model/DeleteCustomizationConfigRequest.h"
#include "model/DeleteCustomizationConfigResult.h"
#include "model/DeleteDataSetRequest.h"
#include "model/DeleteDataSetResult.h"
#include "model/DeletePrecisionTaskRequest.h"
#include "model/DeletePrecisionTaskResult.h"
#include "model/DeleteScoreForApiRequest.h"
#include "model/DeleteScoreForApiResult.h"
#include "model/DeleteSkillGroupConfigRequest.h"
#include "model/DeleteSkillGroupConfigResult.h"
#include "model/DeleteSubScoreForApiRequest.h"
#include "model/DeleteSubScoreForApiResult.h"
#include "model/DeleteTaskAssignRuleRequest.h"
#include "model/DeleteTaskAssignRuleResult.h"
#include "model/DeleteUserRequest.h"
#include "model/DeleteUserResult.h"
#include "model/DeleteWarningConfigRequest.h"
#include "model/DeleteWarningConfigResult.h"
#include "model/EditThesaurusForApiRequest.h"
#include "model/EditThesaurusForApiResult.h"
#include "model/GetAsrVocabRequest.h"
#include "model/GetAsrVocabResult.h"
#include "model/GetBusinessCategoryListRequest.h"
#include "model/GetBusinessCategoryListResult.h"
#include "model/GetCustomizationConfigListRequest.h"
#include "model/GetCustomizationConfigListResult.h"
#include "model/GetHitResultRequest.h"
#include "model/GetHitResultResult.h"
#include "model/GetNextResultToVerifyRequest.h"
#include "model/GetNextResultToVerifyResult.h"
#include "model/GetPrecisionTaskRequest.h"
#include "model/GetPrecisionTaskResult.h"
#include "model/GetResultRequest.h"
#include "model/GetResultResult.h"
#include "model/GetResultCallbackRequest.h"
#include "model/GetResultCallbackResult.h"
#include "model/GetResultToReviewRequest.h"
#include "model/GetResultToReviewResult.h"
#include "model/GetRuleRequest.h"
#include "model/GetRuleResult.h"
#include "model/GetRuleCategoryRequest.h"
#include "model/GetRuleCategoryResult.h"
#include "model/GetRuleDetailRequest.h"
#include "model/GetRuleDetailResult.h"
#include "model/GetScoreInfoRequest.h"
#include "model/GetScoreInfoResult.h"
#include "model/GetSkillGroupConfigRequest.h"
#include "model/GetSkillGroupConfigResult.h"
#include "model/GetSyncResultRequest.h"
#include "model/GetSyncResultResult.h"
#include "model/GetThesaurusBySynonymForApiRequest.h"
#include "model/GetThesaurusBySynonymForApiResult.h"
#include "model/HandleComplaintRequest.h"
#include "model/HandleComplaintResult.h"
#include "model/InsertScoreForApiRequest.h"
#include "model/InsertScoreForApiResult.h"
#include "model/InsertSubScoreForApiRequest.h"
#include "model/InsertSubScoreForApiResult.h"
#include "model/InvalidRuleRequest.h"
#include "model/InvalidRuleResult.h"
#include "model/ListAsrVocabRequest.h"
#include "model/ListAsrVocabResult.h"
#include "model/ListHotWordsTasksRequest.h"
#include "model/ListHotWordsTasksResult.h"
#include "model/ListPrecisionTaskRequest.h"
#include "model/ListPrecisionTaskResult.h"
#include "model/ListRolesRequest.h"
#include "model/ListRolesResult.h"
#include "model/ListRulesRequest.h"
#include "model/ListRulesResult.h"
#include "model/ListSkillGroupConfigRequest.h"
#include "model/ListSkillGroupConfigResult.h"
#include "model/ListTaskAssignRulesRequest.h"
#include "model/ListTaskAssignRulesResult.h"
#include "model/ListUsersRequest.h"
#include "model/ListUsersResult.h"
#include "model/ListWarningConfigRequest.h"
#include "model/ListWarningConfigResult.h"
#include "model/RestartAsrTaskRequest.h"
#include "model/RestartAsrTaskResult.h"
#include "model/SaveConfigDataSetRequest.h"
#include "model/SaveConfigDataSetResult.h"
#include "model/SubmitComplaintRequest.h"
#include "model/SubmitComplaintResult.h"
#include "model/SubmitPrecisionTaskRequest.h"
#include "model/SubmitPrecisionTaskResult.h"
#include "model/SubmitQualityCheckTaskRequest.h"
#include "model/SubmitQualityCheckTaskResult.h"
#include "model/SubmitReviewInfoRequest.h"
#include "model/SubmitReviewInfoResult.h"
#include "model/SyncQualityCheckRequest.h"
#include "model/SyncQualityCheckResult.h"
#include "model/UpdateAsrVocabRequest.h"
#include "model/UpdateAsrVocabResult.h"
#include "model/UpdateRuleRequest.h"
#include "model/UpdateRuleResult.h"
#include "model/UpdateScoreForApiRequest.h"
#include "model/UpdateScoreForApiResult.h"
#include "model/UpdateSkillGroupConfigRequest.h"
#include "model/UpdateSkillGroupConfigResult.h"
#include "model/UpdateSubScoreForApiRequest.h"
#include "model/UpdateSubScoreForApiResult.h"
#include "model/UpdateSyncQualityCheckDataRequest.h"
#include "model/UpdateSyncQualityCheckDataResult.h"
#include "model/UpdateTaskAssignRuleRequest.h"
#include "model/UpdateTaskAssignRuleResult.h"
#include "model/UpdateUserRequest.h"
#include "model/UpdateUserResult.h"
#include "model/UpdateUserConfigRequest.h"
#include "model/UpdateUserConfigResult.h"
#include "model/UpdateWarningConfigRequest.h"
#include "model/UpdateWarningConfigResult.h"
#include "model/UploadAudioDataRequest.h"
#include "model/UploadAudioDataResult.h"
#include "model/UploadDataRequest.h"
#include "model/UploadDataResult.h"
#include "model/UploadDataSyncRequest.h"
#include "model/UploadDataSyncResult.h"
#include "model/UploadRuleRequest.h"
#include "model/UploadRuleResult.h"
#include "model/VerifyFileRequest.h"
#include "model/VerifyFileResult.h"
#include "model/VerifySentenceRequest.h"
#include "model/VerifySentenceResult.h"
namespace AlibabaCloud
{
namespace Qualitycheck
{
class ALIBABACLOUD_QUALITYCHECK_EXPORT QualitycheckClient : public RpcServiceClient
{
public:
typedef Outcome<Error, Model::AddBusinessCategoryResult> AddBusinessCategoryOutcome;
typedef std::future<AddBusinessCategoryOutcome> AddBusinessCategoryOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::AddBusinessCategoryRequest&, const AddBusinessCategoryOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> AddBusinessCategoryAsyncHandler;
typedef Outcome<Error, Model::AddRuleCategoryResult> AddRuleCategoryOutcome;
typedef std::future<AddRuleCategoryOutcome> AddRuleCategoryOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::AddRuleCategoryRequest&, const AddRuleCategoryOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> AddRuleCategoryAsyncHandler;
typedef Outcome<Error, Model::AddThesaurusForApiResult> AddThesaurusForApiOutcome;
typedef std::future<AddThesaurusForApiOutcome> AddThesaurusForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::AddThesaurusForApiRequest&, const AddThesaurusForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> AddThesaurusForApiAsyncHandler;
typedef Outcome<Error, Model::AssignReviewerResult> AssignReviewerOutcome;
typedef std::future<AssignReviewerOutcome> AssignReviewerOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::AssignReviewerRequest&, const AssignReviewerOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> AssignReviewerAsyncHandler;
typedef Outcome<Error, Model::CreateAsrVocabResult> CreateAsrVocabOutcome;
typedef std::future<CreateAsrVocabOutcome> CreateAsrVocabOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::CreateAsrVocabRequest&, const CreateAsrVocabOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateAsrVocabAsyncHandler;
typedef Outcome<Error, Model::CreateSkillGroupConfigResult> CreateSkillGroupConfigOutcome;
typedef std::future<CreateSkillGroupConfigOutcome> CreateSkillGroupConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::CreateSkillGroupConfigRequest&, const CreateSkillGroupConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateSkillGroupConfigAsyncHandler;
typedef Outcome<Error, Model::CreateTaskAssignRuleResult> CreateTaskAssignRuleOutcome;
typedef std::future<CreateTaskAssignRuleOutcome> CreateTaskAssignRuleOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::CreateTaskAssignRuleRequest&, const CreateTaskAssignRuleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateTaskAssignRuleAsyncHandler;
typedef Outcome<Error, Model::CreateUserResult> CreateUserOutcome;
typedef std::future<CreateUserOutcome> CreateUserOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::CreateUserRequest&, const CreateUserOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateUserAsyncHandler;
typedef Outcome<Error, Model::CreateWarningConfigResult> CreateWarningConfigOutcome;
typedef std::future<CreateWarningConfigOutcome> CreateWarningConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::CreateWarningConfigRequest&, const CreateWarningConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateWarningConfigAsyncHandler;
typedef Outcome<Error, Model::DelRuleCategoryResult> DelRuleCategoryOutcome;
typedef std::future<DelRuleCategoryOutcome> DelRuleCategoryOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DelRuleCategoryRequest&, const DelRuleCategoryOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DelRuleCategoryAsyncHandler;
typedef Outcome<Error, Model::DelThesaurusForApiResult> DelThesaurusForApiOutcome;
typedef std::future<DelThesaurusForApiOutcome> DelThesaurusForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DelThesaurusForApiRequest&, const DelThesaurusForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DelThesaurusForApiAsyncHandler;
typedef Outcome<Error, Model::DeleteAsrVocabResult> DeleteAsrVocabOutcome;
typedef std::future<DeleteAsrVocabOutcome> DeleteAsrVocabOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteAsrVocabRequest&, const DeleteAsrVocabOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteAsrVocabAsyncHandler;
typedef Outcome<Error, Model::DeleteBusinessCategoryResult> DeleteBusinessCategoryOutcome;
typedef std::future<DeleteBusinessCategoryOutcome> DeleteBusinessCategoryOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteBusinessCategoryRequest&, const DeleteBusinessCategoryOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteBusinessCategoryAsyncHandler;
typedef Outcome<Error, Model::DeleteCustomizationConfigResult> DeleteCustomizationConfigOutcome;
typedef std::future<DeleteCustomizationConfigOutcome> DeleteCustomizationConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteCustomizationConfigRequest&, const DeleteCustomizationConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteCustomizationConfigAsyncHandler;
typedef Outcome<Error, Model::DeleteDataSetResult> DeleteDataSetOutcome;
typedef std::future<DeleteDataSetOutcome> DeleteDataSetOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteDataSetRequest&, const DeleteDataSetOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteDataSetAsyncHandler;
typedef Outcome<Error, Model::DeletePrecisionTaskResult> DeletePrecisionTaskOutcome;
typedef std::future<DeletePrecisionTaskOutcome> DeletePrecisionTaskOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeletePrecisionTaskRequest&, const DeletePrecisionTaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeletePrecisionTaskAsyncHandler;
typedef Outcome<Error, Model::DeleteScoreForApiResult> DeleteScoreForApiOutcome;
typedef std::future<DeleteScoreForApiOutcome> DeleteScoreForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteScoreForApiRequest&, const DeleteScoreForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteScoreForApiAsyncHandler;
typedef Outcome<Error, Model::DeleteSkillGroupConfigResult> DeleteSkillGroupConfigOutcome;
typedef std::future<DeleteSkillGroupConfigOutcome> DeleteSkillGroupConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteSkillGroupConfigRequest&, const DeleteSkillGroupConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteSkillGroupConfigAsyncHandler;
typedef Outcome<Error, Model::DeleteSubScoreForApiResult> DeleteSubScoreForApiOutcome;
typedef std::future<DeleteSubScoreForApiOutcome> DeleteSubScoreForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteSubScoreForApiRequest&, const DeleteSubScoreForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteSubScoreForApiAsyncHandler;
typedef Outcome<Error, Model::DeleteTaskAssignRuleResult> DeleteTaskAssignRuleOutcome;
typedef std::future<DeleteTaskAssignRuleOutcome> DeleteTaskAssignRuleOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteTaskAssignRuleRequest&, const DeleteTaskAssignRuleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteTaskAssignRuleAsyncHandler;
typedef Outcome<Error, Model::DeleteUserResult> DeleteUserOutcome;
typedef std::future<DeleteUserOutcome> DeleteUserOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteUserRequest&, const DeleteUserOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteUserAsyncHandler;
typedef Outcome<Error, Model::DeleteWarningConfigResult> DeleteWarningConfigOutcome;
typedef std::future<DeleteWarningConfigOutcome> DeleteWarningConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::DeleteWarningConfigRequest&, const DeleteWarningConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteWarningConfigAsyncHandler;
typedef Outcome<Error, Model::EditThesaurusForApiResult> EditThesaurusForApiOutcome;
typedef std::future<EditThesaurusForApiOutcome> EditThesaurusForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::EditThesaurusForApiRequest&, const EditThesaurusForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> EditThesaurusForApiAsyncHandler;
typedef Outcome<Error, Model::GetAsrVocabResult> GetAsrVocabOutcome;
typedef std::future<GetAsrVocabOutcome> GetAsrVocabOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetAsrVocabRequest&, const GetAsrVocabOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetAsrVocabAsyncHandler;
typedef Outcome<Error, Model::GetBusinessCategoryListResult> GetBusinessCategoryListOutcome;
typedef std::future<GetBusinessCategoryListOutcome> GetBusinessCategoryListOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetBusinessCategoryListRequest&, const GetBusinessCategoryListOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetBusinessCategoryListAsyncHandler;
typedef Outcome<Error, Model::GetCustomizationConfigListResult> GetCustomizationConfigListOutcome;
typedef std::future<GetCustomizationConfigListOutcome> GetCustomizationConfigListOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetCustomizationConfigListRequest&, const GetCustomizationConfigListOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetCustomizationConfigListAsyncHandler;
typedef Outcome<Error, Model::GetHitResultResult> GetHitResultOutcome;
typedef std::future<GetHitResultOutcome> GetHitResultOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetHitResultRequest&, const GetHitResultOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetHitResultAsyncHandler;
typedef Outcome<Error, Model::GetNextResultToVerifyResult> GetNextResultToVerifyOutcome;
typedef std::future<GetNextResultToVerifyOutcome> GetNextResultToVerifyOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetNextResultToVerifyRequest&, const GetNextResultToVerifyOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetNextResultToVerifyAsyncHandler;
typedef Outcome<Error, Model::GetPrecisionTaskResult> GetPrecisionTaskOutcome;
typedef std::future<GetPrecisionTaskOutcome> GetPrecisionTaskOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetPrecisionTaskRequest&, const GetPrecisionTaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetPrecisionTaskAsyncHandler;
typedef Outcome<Error, Model::GetResultResult> GetResultOutcome;
typedef std::future<GetResultOutcome> GetResultOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetResultRequest&, const GetResultOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetResultAsyncHandler;
typedef Outcome<Error, Model::GetResultCallbackResult> GetResultCallbackOutcome;
typedef std::future<GetResultCallbackOutcome> GetResultCallbackOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetResultCallbackRequest&, const GetResultCallbackOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetResultCallbackAsyncHandler;
typedef Outcome<Error, Model::GetResultToReviewResult> GetResultToReviewOutcome;
typedef std::future<GetResultToReviewOutcome> GetResultToReviewOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetResultToReviewRequest&, const GetResultToReviewOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetResultToReviewAsyncHandler;
typedef Outcome<Error, Model::GetRuleResult> GetRuleOutcome;
typedef std::future<GetRuleOutcome> GetRuleOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetRuleRequest&, const GetRuleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetRuleAsyncHandler;
typedef Outcome<Error, Model::GetRuleCategoryResult> GetRuleCategoryOutcome;
typedef std::future<GetRuleCategoryOutcome> GetRuleCategoryOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetRuleCategoryRequest&, const GetRuleCategoryOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetRuleCategoryAsyncHandler;
typedef Outcome<Error, Model::GetRuleDetailResult> GetRuleDetailOutcome;
typedef std::future<GetRuleDetailOutcome> GetRuleDetailOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetRuleDetailRequest&, const GetRuleDetailOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetRuleDetailAsyncHandler;
typedef Outcome<Error, Model::GetScoreInfoResult> GetScoreInfoOutcome;
typedef std::future<GetScoreInfoOutcome> GetScoreInfoOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetScoreInfoRequest&, const GetScoreInfoOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetScoreInfoAsyncHandler;
typedef Outcome<Error, Model::GetSkillGroupConfigResult> GetSkillGroupConfigOutcome;
typedef std::future<GetSkillGroupConfigOutcome> GetSkillGroupConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetSkillGroupConfigRequest&, const GetSkillGroupConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetSkillGroupConfigAsyncHandler;
typedef Outcome<Error, Model::GetSyncResultResult> GetSyncResultOutcome;
typedef std::future<GetSyncResultOutcome> GetSyncResultOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetSyncResultRequest&, const GetSyncResultOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetSyncResultAsyncHandler;
typedef Outcome<Error, Model::GetThesaurusBySynonymForApiResult> GetThesaurusBySynonymForApiOutcome;
typedef std::future<GetThesaurusBySynonymForApiOutcome> GetThesaurusBySynonymForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::GetThesaurusBySynonymForApiRequest&, const GetThesaurusBySynonymForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetThesaurusBySynonymForApiAsyncHandler;
typedef Outcome<Error, Model::HandleComplaintResult> HandleComplaintOutcome;
typedef std::future<HandleComplaintOutcome> HandleComplaintOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::HandleComplaintRequest&, const HandleComplaintOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> HandleComplaintAsyncHandler;
typedef Outcome<Error, Model::InsertScoreForApiResult> InsertScoreForApiOutcome;
typedef std::future<InsertScoreForApiOutcome> InsertScoreForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::InsertScoreForApiRequest&, const InsertScoreForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> InsertScoreForApiAsyncHandler;
typedef Outcome<Error, Model::InsertSubScoreForApiResult> InsertSubScoreForApiOutcome;
typedef std::future<InsertSubScoreForApiOutcome> InsertSubScoreForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::InsertSubScoreForApiRequest&, const InsertSubScoreForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> InsertSubScoreForApiAsyncHandler;
typedef Outcome<Error, Model::InvalidRuleResult> InvalidRuleOutcome;
typedef std::future<InvalidRuleOutcome> InvalidRuleOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::InvalidRuleRequest&, const InvalidRuleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> InvalidRuleAsyncHandler;
typedef Outcome<Error, Model::ListAsrVocabResult> ListAsrVocabOutcome;
typedef std::future<ListAsrVocabOutcome> ListAsrVocabOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListAsrVocabRequest&, const ListAsrVocabOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListAsrVocabAsyncHandler;
typedef Outcome<Error, Model::ListHotWordsTasksResult> ListHotWordsTasksOutcome;
typedef std::future<ListHotWordsTasksOutcome> ListHotWordsTasksOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListHotWordsTasksRequest&, const ListHotWordsTasksOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListHotWordsTasksAsyncHandler;
typedef Outcome<Error, Model::ListPrecisionTaskResult> ListPrecisionTaskOutcome;
typedef std::future<ListPrecisionTaskOutcome> ListPrecisionTaskOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListPrecisionTaskRequest&, const ListPrecisionTaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListPrecisionTaskAsyncHandler;
typedef Outcome<Error, Model::ListRolesResult> ListRolesOutcome;
typedef std::future<ListRolesOutcome> ListRolesOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListRolesRequest&, const ListRolesOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListRolesAsyncHandler;
typedef Outcome<Error, Model::ListRulesResult> ListRulesOutcome;
typedef std::future<ListRulesOutcome> ListRulesOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListRulesRequest&, const ListRulesOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListRulesAsyncHandler;
typedef Outcome<Error, Model::ListSkillGroupConfigResult> ListSkillGroupConfigOutcome;
typedef std::future<ListSkillGroupConfigOutcome> ListSkillGroupConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListSkillGroupConfigRequest&, const ListSkillGroupConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListSkillGroupConfigAsyncHandler;
typedef Outcome<Error, Model::ListTaskAssignRulesResult> ListTaskAssignRulesOutcome;
typedef std::future<ListTaskAssignRulesOutcome> ListTaskAssignRulesOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListTaskAssignRulesRequest&, const ListTaskAssignRulesOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListTaskAssignRulesAsyncHandler;
typedef Outcome<Error, Model::ListUsersResult> ListUsersOutcome;
typedef std::future<ListUsersOutcome> ListUsersOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListUsersRequest&, const ListUsersOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListUsersAsyncHandler;
typedef Outcome<Error, Model::ListWarningConfigResult> ListWarningConfigOutcome;
typedef std::future<ListWarningConfigOutcome> ListWarningConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::ListWarningConfigRequest&, const ListWarningConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListWarningConfigAsyncHandler;
typedef Outcome<Error, Model::RestartAsrTaskResult> RestartAsrTaskOutcome;
typedef std::future<RestartAsrTaskOutcome> RestartAsrTaskOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::RestartAsrTaskRequest&, const RestartAsrTaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RestartAsrTaskAsyncHandler;
typedef Outcome<Error, Model::SaveConfigDataSetResult> SaveConfigDataSetOutcome;
typedef std::future<SaveConfigDataSetOutcome> SaveConfigDataSetOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::SaveConfigDataSetRequest&, const SaveConfigDataSetOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SaveConfigDataSetAsyncHandler;
typedef Outcome<Error, Model::SubmitComplaintResult> SubmitComplaintOutcome;
typedef std::future<SubmitComplaintOutcome> SubmitComplaintOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::SubmitComplaintRequest&, const SubmitComplaintOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SubmitComplaintAsyncHandler;
typedef Outcome<Error, Model::SubmitPrecisionTaskResult> SubmitPrecisionTaskOutcome;
typedef std::future<SubmitPrecisionTaskOutcome> SubmitPrecisionTaskOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::SubmitPrecisionTaskRequest&, const SubmitPrecisionTaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SubmitPrecisionTaskAsyncHandler;
typedef Outcome<Error, Model::SubmitQualityCheckTaskResult> SubmitQualityCheckTaskOutcome;
typedef std::future<SubmitQualityCheckTaskOutcome> SubmitQualityCheckTaskOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::SubmitQualityCheckTaskRequest&, const SubmitQualityCheckTaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SubmitQualityCheckTaskAsyncHandler;
typedef Outcome<Error, Model::SubmitReviewInfoResult> SubmitReviewInfoOutcome;
typedef std::future<SubmitReviewInfoOutcome> SubmitReviewInfoOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::SubmitReviewInfoRequest&, const SubmitReviewInfoOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SubmitReviewInfoAsyncHandler;
typedef Outcome<Error, Model::SyncQualityCheckResult> SyncQualityCheckOutcome;
typedef std::future<SyncQualityCheckOutcome> SyncQualityCheckOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::SyncQualityCheckRequest&, const SyncQualityCheckOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SyncQualityCheckAsyncHandler;
typedef Outcome<Error, Model::UpdateAsrVocabResult> UpdateAsrVocabOutcome;
typedef std::future<UpdateAsrVocabOutcome> UpdateAsrVocabOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateAsrVocabRequest&, const UpdateAsrVocabOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateAsrVocabAsyncHandler;
typedef Outcome<Error, Model::UpdateRuleResult> UpdateRuleOutcome;
typedef std::future<UpdateRuleOutcome> UpdateRuleOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateRuleRequest&, const UpdateRuleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateRuleAsyncHandler;
typedef Outcome<Error, Model::UpdateScoreForApiResult> UpdateScoreForApiOutcome;
typedef std::future<UpdateScoreForApiOutcome> UpdateScoreForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateScoreForApiRequest&, const UpdateScoreForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateScoreForApiAsyncHandler;
typedef Outcome<Error, Model::UpdateSkillGroupConfigResult> UpdateSkillGroupConfigOutcome;
typedef std::future<UpdateSkillGroupConfigOutcome> UpdateSkillGroupConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateSkillGroupConfigRequest&, const UpdateSkillGroupConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateSkillGroupConfigAsyncHandler;
typedef Outcome<Error, Model::UpdateSubScoreForApiResult> UpdateSubScoreForApiOutcome;
typedef std::future<UpdateSubScoreForApiOutcome> UpdateSubScoreForApiOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateSubScoreForApiRequest&, const UpdateSubScoreForApiOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateSubScoreForApiAsyncHandler;
typedef Outcome<Error, Model::UpdateSyncQualityCheckDataResult> UpdateSyncQualityCheckDataOutcome;
typedef std::future<UpdateSyncQualityCheckDataOutcome> UpdateSyncQualityCheckDataOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateSyncQualityCheckDataRequest&, const UpdateSyncQualityCheckDataOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateSyncQualityCheckDataAsyncHandler;
typedef Outcome<Error, Model::UpdateTaskAssignRuleResult> UpdateTaskAssignRuleOutcome;
typedef std::future<UpdateTaskAssignRuleOutcome> UpdateTaskAssignRuleOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateTaskAssignRuleRequest&, const UpdateTaskAssignRuleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateTaskAssignRuleAsyncHandler;
typedef Outcome<Error, Model::UpdateUserResult> UpdateUserOutcome;
typedef std::future<UpdateUserOutcome> UpdateUserOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateUserRequest&, const UpdateUserOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateUserAsyncHandler;
typedef Outcome<Error, Model::UpdateUserConfigResult> UpdateUserConfigOutcome;
typedef std::future<UpdateUserConfigOutcome> UpdateUserConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateUserConfigRequest&, const UpdateUserConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateUserConfigAsyncHandler;
typedef Outcome<Error, Model::UpdateWarningConfigResult> UpdateWarningConfigOutcome;
typedef std::future<UpdateWarningConfigOutcome> UpdateWarningConfigOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UpdateWarningConfigRequest&, const UpdateWarningConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateWarningConfigAsyncHandler;
typedef Outcome<Error, Model::UploadAudioDataResult> UploadAudioDataOutcome;
typedef std::future<UploadAudioDataOutcome> UploadAudioDataOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UploadAudioDataRequest&, const UploadAudioDataOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UploadAudioDataAsyncHandler;
typedef Outcome<Error, Model::UploadDataResult> UploadDataOutcome;
typedef std::future<UploadDataOutcome> UploadDataOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UploadDataRequest&, const UploadDataOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UploadDataAsyncHandler;
typedef Outcome<Error, Model::UploadDataSyncResult> UploadDataSyncOutcome;
typedef std::future<UploadDataSyncOutcome> UploadDataSyncOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UploadDataSyncRequest&, const UploadDataSyncOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UploadDataSyncAsyncHandler;
typedef Outcome<Error, Model::UploadRuleResult> UploadRuleOutcome;
typedef std::future<UploadRuleOutcome> UploadRuleOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::UploadRuleRequest&, const UploadRuleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UploadRuleAsyncHandler;
typedef Outcome<Error, Model::VerifyFileResult> VerifyFileOutcome;
typedef std::future<VerifyFileOutcome> VerifyFileOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::VerifyFileRequest&, const VerifyFileOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> VerifyFileAsyncHandler;
typedef Outcome<Error, Model::VerifySentenceResult> VerifySentenceOutcome;
typedef std::future<VerifySentenceOutcome> VerifySentenceOutcomeCallable;
typedef std::function<void(const QualitycheckClient*, const Model::VerifySentenceRequest&, const VerifySentenceOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> VerifySentenceAsyncHandler;
QualitycheckClient(const Credentials &credentials, const ClientConfiguration &configuration);
QualitycheckClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
QualitycheckClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
~QualitycheckClient();
AddBusinessCategoryOutcome addBusinessCategory(const Model::AddBusinessCategoryRequest &request)const;
void addBusinessCategoryAsync(const Model::AddBusinessCategoryRequest& request, const AddBusinessCategoryAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
AddBusinessCategoryOutcomeCallable addBusinessCategoryCallable(const Model::AddBusinessCategoryRequest& request) const;
AddRuleCategoryOutcome addRuleCategory(const Model::AddRuleCategoryRequest &request)const;
void addRuleCategoryAsync(const Model::AddRuleCategoryRequest& request, const AddRuleCategoryAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
AddRuleCategoryOutcomeCallable addRuleCategoryCallable(const Model::AddRuleCategoryRequest& request) const;
AddThesaurusForApiOutcome addThesaurusForApi(const Model::AddThesaurusForApiRequest &request)const;
void addThesaurusForApiAsync(const Model::AddThesaurusForApiRequest& request, const AddThesaurusForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
AddThesaurusForApiOutcomeCallable addThesaurusForApiCallable(const Model::AddThesaurusForApiRequest& request) const;
AssignReviewerOutcome assignReviewer(const Model::AssignReviewerRequest &request)const;
void assignReviewerAsync(const Model::AssignReviewerRequest& request, const AssignReviewerAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
AssignReviewerOutcomeCallable assignReviewerCallable(const Model::AssignReviewerRequest& request) const;
CreateAsrVocabOutcome createAsrVocab(const Model::CreateAsrVocabRequest &request)const;
void createAsrVocabAsync(const Model::CreateAsrVocabRequest& request, const CreateAsrVocabAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CreateAsrVocabOutcomeCallable createAsrVocabCallable(const Model::CreateAsrVocabRequest& request) const;
CreateSkillGroupConfigOutcome createSkillGroupConfig(const Model::CreateSkillGroupConfigRequest &request)const;
void createSkillGroupConfigAsync(const Model::CreateSkillGroupConfigRequest& request, const CreateSkillGroupConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CreateSkillGroupConfigOutcomeCallable createSkillGroupConfigCallable(const Model::CreateSkillGroupConfigRequest& request) const;
CreateTaskAssignRuleOutcome createTaskAssignRule(const Model::CreateTaskAssignRuleRequest &request)const;
void createTaskAssignRuleAsync(const Model::CreateTaskAssignRuleRequest& request, const CreateTaskAssignRuleAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CreateTaskAssignRuleOutcomeCallable createTaskAssignRuleCallable(const Model::CreateTaskAssignRuleRequest& request) const;
CreateUserOutcome createUser(const Model::CreateUserRequest &request)const;
void createUserAsync(const Model::CreateUserRequest& request, const CreateUserAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CreateUserOutcomeCallable createUserCallable(const Model::CreateUserRequest& request) const;
CreateWarningConfigOutcome createWarningConfig(const Model::CreateWarningConfigRequest &request)const;
void createWarningConfigAsync(const Model::CreateWarningConfigRequest& request, const CreateWarningConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CreateWarningConfigOutcomeCallable createWarningConfigCallable(const Model::CreateWarningConfigRequest& request) const;
DelRuleCategoryOutcome delRuleCategory(const Model::DelRuleCategoryRequest &request)const;
void delRuleCategoryAsync(const Model::DelRuleCategoryRequest& request, const DelRuleCategoryAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DelRuleCategoryOutcomeCallable delRuleCategoryCallable(const Model::DelRuleCategoryRequest& request) const;
DelThesaurusForApiOutcome delThesaurusForApi(const Model::DelThesaurusForApiRequest &request)const;
void delThesaurusForApiAsync(const Model::DelThesaurusForApiRequest& request, const DelThesaurusForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DelThesaurusForApiOutcomeCallable delThesaurusForApiCallable(const Model::DelThesaurusForApiRequest& request) const;
DeleteAsrVocabOutcome deleteAsrVocab(const Model::DeleteAsrVocabRequest &request)const;
void deleteAsrVocabAsync(const Model::DeleteAsrVocabRequest& request, const DeleteAsrVocabAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteAsrVocabOutcomeCallable deleteAsrVocabCallable(const Model::DeleteAsrVocabRequest& request) const;
DeleteBusinessCategoryOutcome deleteBusinessCategory(const Model::DeleteBusinessCategoryRequest &request)const;
void deleteBusinessCategoryAsync(const Model::DeleteBusinessCategoryRequest& request, const DeleteBusinessCategoryAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteBusinessCategoryOutcomeCallable deleteBusinessCategoryCallable(const Model::DeleteBusinessCategoryRequest& request) const;
DeleteCustomizationConfigOutcome deleteCustomizationConfig(const Model::DeleteCustomizationConfigRequest &request)const;
void deleteCustomizationConfigAsync(const Model::DeleteCustomizationConfigRequest& request, const DeleteCustomizationConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteCustomizationConfigOutcomeCallable deleteCustomizationConfigCallable(const Model::DeleteCustomizationConfigRequest& request) const;
DeleteDataSetOutcome deleteDataSet(const Model::DeleteDataSetRequest &request)const;
void deleteDataSetAsync(const Model::DeleteDataSetRequest& request, const DeleteDataSetAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteDataSetOutcomeCallable deleteDataSetCallable(const Model::DeleteDataSetRequest& request) const;
DeletePrecisionTaskOutcome deletePrecisionTask(const Model::DeletePrecisionTaskRequest &request)const;
void deletePrecisionTaskAsync(const Model::DeletePrecisionTaskRequest& request, const DeletePrecisionTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeletePrecisionTaskOutcomeCallable deletePrecisionTaskCallable(const Model::DeletePrecisionTaskRequest& request) const;
DeleteScoreForApiOutcome deleteScoreForApi(const Model::DeleteScoreForApiRequest &request)const;
void deleteScoreForApiAsync(const Model::DeleteScoreForApiRequest& request, const DeleteScoreForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteScoreForApiOutcomeCallable deleteScoreForApiCallable(const Model::DeleteScoreForApiRequest& request) const;
DeleteSkillGroupConfigOutcome deleteSkillGroupConfig(const Model::DeleteSkillGroupConfigRequest &request)const;
void deleteSkillGroupConfigAsync(const Model::DeleteSkillGroupConfigRequest& request, const DeleteSkillGroupConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteSkillGroupConfigOutcomeCallable deleteSkillGroupConfigCallable(const Model::DeleteSkillGroupConfigRequest& request) const;
DeleteSubScoreForApiOutcome deleteSubScoreForApi(const Model::DeleteSubScoreForApiRequest &request)const;
void deleteSubScoreForApiAsync(const Model::DeleteSubScoreForApiRequest& request, const DeleteSubScoreForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteSubScoreForApiOutcomeCallable deleteSubScoreForApiCallable(const Model::DeleteSubScoreForApiRequest& request) const;
DeleteTaskAssignRuleOutcome deleteTaskAssignRule(const Model::DeleteTaskAssignRuleRequest &request)const;
void deleteTaskAssignRuleAsync(const Model::DeleteTaskAssignRuleRequest& request, const DeleteTaskAssignRuleAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteTaskAssignRuleOutcomeCallable deleteTaskAssignRuleCallable(const Model::DeleteTaskAssignRuleRequest& request) const;
DeleteUserOutcome deleteUser(const Model::DeleteUserRequest &request)const;
void deleteUserAsync(const Model::DeleteUserRequest& request, const DeleteUserAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteUserOutcomeCallable deleteUserCallable(const Model::DeleteUserRequest& request) const;
DeleteWarningConfigOutcome deleteWarningConfig(const Model::DeleteWarningConfigRequest &request)const;
void deleteWarningConfigAsync(const Model::DeleteWarningConfigRequest& request, const DeleteWarningConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteWarningConfigOutcomeCallable deleteWarningConfigCallable(const Model::DeleteWarningConfigRequest& request) const;
EditThesaurusForApiOutcome editThesaurusForApi(const Model::EditThesaurusForApiRequest &request)const;
void editThesaurusForApiAsync(const Model::EditThesaurusForApiRequest& request, const EditThesaurusForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
EditThesaurusForApiOutcomeCallable editThesaurusForApiCallable(const Model::EditThesaurusForApiRequest& request) const;
GetAsrVocabOutcome getAsrVocab(const Model::GetAsrVocabRequest &request)const;
void getAsrVocabAsync(const Model::GetAsrVocabRequest& request, const GetAsrVocabAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetAsrVocabOutcomeCallable getAsrVocabCallable(const Model::GetAsrVocabRequest& request) const;
GetBusinessCategoryListOutcome getBusinessCategoryList(const Model::GetBusinessCategoryListRequest &request)const;
void getBusinessCategoryListAsync(const Model::GetBusinessCategoryListRequest& request, const GetBusinessCategoryListAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetBusinessCategoryListOutcomeCallable getBusinessCategoryListCallable(const Model::GetBusinessCategoryListRequest& request) const;
GetCustomizationConfigListOutcome getCustomizationConfigList(const Model::GetCustomizationConfigListRequest &request)const;
void getCustomizationConfigListAsync(const Model::GetCustomizationConfigListRequest& request, const GetCustomizationConfigListAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetCustomizationConfigListOutcomeCallable getCustomizationConfigListCallable(const Model::GetCustomizationConfigListRequest& request) const;
GetHitResultOutcome getHitResult(const Model::GetHitResultRequest &request)const;
void getHitResultAsync(const Model::GetHitResultRequest& request, const GetHitResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetHitResultOutcomeCallable getHitResultCallable(const Model::GetHitResultRequest& request) const;
GetNextResultToVerifyOutcome getNextResultToVerify(const Model::GetNextResultToVerifyRequest &request)const;
void getNextResultToVerifyAsync(const Model::GetNextResultToVerifyRequest& request, const GetNextResultToVerifyAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetNextResultToVerifyOutcomeCallable getNextResultToVerifyCallable(const Model::GetNextResultToVerifyRequest& request) const;
GetPrecisionTaskOutcome getPrecisionTask(const Model::GetPrecisionTaskRequest &request)const;
void getPrecisionTaskAsync(const Model::GetPrecisionTaskRequest& request, const GetPrecisionTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetPrecisionTaskOutcomeCallable getPrecisionTaskCallable(const Model::GetPrecisionTaskRequest& request) const;
GetResultOutcome getResult(const Model::GetResultRequest &request)const;
void getResultAsync(const Model::GetResultRequest& request, const GetResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetResultOutcomeCallable getResultCallable(const Model::GetResultRequest& request) const;
GetResultCallbackOutcome getResultCallback(const Model::GetResultCallbackRequest &request)const;
void getResultCallbackAsync(const Model::GetResultCallbackRequest& request, const GetResultCallbackAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetResultCallbackOutcomeCallable getResultCallbackCallable(const Model::GetResultCallbackRequest& request) const;
GetResultToReviewOutcome getResultToReview(const Model::GetResultToReviewRequest &request)const;
void getResultToReviewAsync(const Model::GetResultToReviewRequest& request, const GetResultToReviewAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetResultToReviewOutcomeCallable getResultToReviewCallable(const Model::GetResultToReviewRequest& request) const;
GetRuleOutcome getRule(const Model::GetRuleRequest &request)const;
void getRuleAsync(const Model::GetRuleRequest& request, const GetRuleAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetRuleOutcomeCallable getRuleCallable(const Model::GetRuleRequest& request) const;
GetRuleCategoryOutcome getRuleCategory(const Model::GetRuleCategoryRequest &request)const;
void getRuleCategoryAsync(const Model::GetRuleCategoryRequest& request, const GetRuleCategoryAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetRuleCategoryOutcomeCallable getRuleCategoryCallable(const Model::GetRuleCategoryRequest& request) const;
GetRuleDetailOutcome getRuleDetail(const Model::GetRuleDetailRequest &request)const;
void getRuleDetailAsync(const Model::GetRuleDetailRequest& request, const GetRuleDetailAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetRuleDetailOutcomeCallable getRuleDetailCallable(const Model::GetRuleDetailRequest& request) const;
GetScoreInfoOutcome getScoreInfo(const Model::GetScoreInfoRequest &request)const;
void getScoreInfoAsync(const Model::GetScoreInfoRequest& request, const GetScoreInfoAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetScoreInfoOutcomeCallable getScoreInfoCallable(const Model::GetScoreInfoRequest& request) const;
GetSkillGroupConfigOutcome getSkillGroupConfig(const Model::GetSkillGroupConfigRequest &request)const;
void getSkillGroupConfigAsync(const Model::GetSkillGroupConfigRequest& request, const GetSkillGroupConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetSkillGroupConfigOutcomeCallable getSkillGroupConfigCallable(const Model::GetSkillGroupConfigRequest& request) const;
GetSyncResultOutcome getSyncResult(const Model::GetSyncResultRequest &request)const;
void getSyncResultAsync(const Model::GetSyncResultRequest& request, const GetSyncResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetSyncResultOutcomeCallable getSyncResultCallable(const Model::GetSyncResultRequest& request) const;
GetThesaurusBySynonymForApiOutcome getThesaurusBySynonymForApi(const Model::GetThesaurusBySynonymForApiRequest &request)const;
void getThesaurusBySynonymForApiAsync(const Model::GetThesaurusBySynonymForApiRequest& request, const GetThesaurusBySynonymForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetThesaurusBySynonymForApiOutcomeCallable getThesaurusBySynonymForApiCallable(const Model::GetThesaurusBySynonymForApiRequest& request) const;
HandleComplaintOutcome handleComplaint(const Model::HandleComplaintRequest &request)const;
void handleComplaintAsync(const Model::HandleComplaintRequest& request, const HandleComplaintAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
HandleComplaintOutcomeCallable handleComplaintCallable(const Model::HandleComplaintRequest& request) const;
InsertScoreForApiOutcome insertScoreForApi(const Model::InsertScoreForApiRequest &request)const;
void insertScoreForApiAsync(const Model::InsertScoreForApiRequest& request, const InsertScoreForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
InsertScoreForApiOutcomeCallable insertScoreForApiCallable(const Model::InsertScoreForApiRequest& request) const;
InsertSubScoreForApiOutcome insertSubScoreForApi(const Model::InsertSubScoreForApiRequest &request)const;
void insertSubScoreForApiAsync(const Model::InsertSubScoreForApiRequest& request, const InsertSubScoreForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
InsertSubScoreForApiOutcomeCallable insertSubScoreForApiCallable(const Model::InsertSubScoreForApiRequest& request) const;
InvalidRuleOutcome invalidRule(const Model::InvalidRuleRequest &request)const;
void invalidRuleAsync(const Model::InvalidRuleRequest& request, const InvalidRuleAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
InvalidRuleOutcomeCallable invalidRuleCallable(const Model::InvalidRuleRequest& request) const;
ListAsrVocabOutcome listAsrVocab(const Model::ListAsrVocabRequest &request)const;
void listAsrVocabAsync(const Model::ListAsrVocabRequest& request, const ListAsrVocabAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListAsrVocabOutcomeCallable listAsrVocabCallable(const Model::ListAsrVocabRequest& request) const;
ListHotWordsTasksOutcome listHotWordsTasks(const Model::ListHotWordsTasksRequest &request)const;
void listHotWordsTasksAsync(const Model::ListHotWordsTasksRequest& request, const ListHotWordsTasksAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListHotWordsTasksOutcomeCallable listHotWordsTasksCallable(const Model::ListHotWordsTasksRequest& request) const;
ListPrecisionTaskOutcome listPrecisionTask(const Model::ListPrecisionTaskRequest &request)const;
void listPrecisionTaskAsync(const Model::ListPrecisionTaskRequest& request, const ListPrecisionTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListPrecisionTaskOutcomeCallable listPrecisionTaskCallable(const Model::ListPrecisionTaskRequest& request) const;
ListRolesOutcome listRoles(const Model::ListRolesRequest &request)const;
void listRolesAsync(const Model::ListRolesRequest& request, const ListRolesAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListRolesOutcomeCallable listRolesCallable(const Model::ListRolesRequest& request) const;
ListRulesOutcome listRules(const Model::ListRulesRequest &request)const;
void listRulesAsync(const Model::ListRulesRequest& request, const ListRulesAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListRulesOutcomeCallable listRulesCallable(const Model::ListRulesRequest& request) const;
ListSkillGroupConfigOutcome listSkillGroupConfig(const Model::ListSkillGroupConfigRequest &request)const;
void listSkillGroupConfigAsync(const Model::ListSkillGroupConfigRequest& request, const ListSkillGroupConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListSkillGroupConfigOutcomeCallable listSkillGroupConfigCallable(const Model::ListSkillGroupConfigRequest& request) const;
ListTaskAssignRulesOutcome listTaskAssignRules(const Model::ListTaskAssignRulesRequest &request)const;
void listTaskAssignRulesAsync(const Model::ListTaskAssignRulesRequest& request, const ListTaskAssignRulesAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListTaskAssignRulesOutcomeCallable listTaskAssignRulesCallable(const Model::ListTaskAssignRulesRequest& request) const;
ListUsersOutcome listUsers(const Model::ListUsersRequest &request)const;
void listUsersAsync(const Model::ListUsersRequest& request, const ListUsersAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListUsersOutcomeCallable listUsersCallable(const Model::ListUsersRequest& request) const;
ListWarningConfigOutcome listWarningConfig(const Model::ListWarningConfigRequest &request)const;
void listWarningConfigAsync(const Model::ListWarningConfigRequest& request, const ListWarningConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ListWarningConfigOutcomeCallable listWarningConfigCallable(const Model::ListWarningConfigRequest& request) const;
RestartAsrTaskOutcome restartAsrTask(const Model::RestartAsrTaskRequest &request)const;
void restartAsrTaskAsync(const Model::RestartAsrTaskRequest& request, const RestartAsrTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
RestartAsrTaskOutcomeCallable restartAsrTaskCallable(const Model::RestartAsrTaskRequest& request) const;
SaveConfigDataSetOutcome saveConfigDataSet(const Model::SaveConfigDataSetRequest &request)const;
void saveConfigDataSetAsync(const Model::SaveConfigDataSetRequest& request, const SaveConfigDataSetAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
SaveConfigDataSetOutcomeCallable saveConfigDataSetCallable(const Model::SaveConfigDataSetRequest& request) const;
SubmitComplaintOutcome submitComplaint(const Model::SubmitComplaintRequest &request)const;
void submitComplaintAsync(const Model::SubmitComplaintRequest& request, const SubmitComplaintAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
SubmitComplaintOutcomeCallable submitComplaintCallable(const Model::SubmitComplaintRequest& request) const;
SubmitPrecisionTaskOutcome submitPrecisionTask(const Model::SubmitPrecisionTaskRequest &request)const;
void submitPrecisionTaskAsync(const Model::SubmitPrecisionTaskRequest& request, const SubmitPrecisionTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
SubmitPrecisionTaskOutcomeCallable submitPrecisionTaskCallable(const Model::SubmitPrecisionTaskRequest& request) const;
SubmitQualityCheckTaskOutcome submitQualityCheckTask(const Model::SubmitQualityCheckTaskRequest &request)const;
void submitQualityCheckTaskAsync(const Model::SubmitQualityCheckTaskRequest& request, const SubmitQualityCheckTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
SubmitQualityCheckTaskOutcomeCallable submitQualityCheckTaskCallable(const Model::SubmitQualityCheckTaskRequest& request) const;
SubmitReviewInfoOutcome submitReviewInfo(const Model::SubmitReviewInfoRequest &request)const;
void submitReviewInfoAsync(const Model::SubmitReviewInfoRequest& request, const SubmitReviewInfoAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
SubmitReviewInfoOutcomeCallable submitReviewInfoCallable(const Model::SubmitReviewInfoRequest& request) const;
SyncQualityCheckOutcome syncQualityCheck(const Model::SyncQualityCheckRequest &request)const;
void syncQualityCheckAsync(const Model::SyncQualityCheckRequest& request, const SyncQualityCheckAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
SyncQualityCheckOutcomeCallable syncQualityCheckCallable(const Model::SyncQualityCheckRequest& request) const;
UpdateAsrVocabOutcome updateAsrVocab(const Model::UpdateAsrVocabRequest &request)const;
void updateAsrVocabAsync(const Model::UpdateAsrVocabRequest& request, const UpdateAsrVocabAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateAsrVocabOutcomeCallable updateAsrVocabCallable(const Model::UpdateAsrVocabRequest& request) const;
UpdateRuleOutcome updateRule(const Model::UpdateRuleRequest &request)const;
void updateRuleAsync(const Model::UpdateRuleRequest& request, const UpdateRuleAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateRuleOutcomeCallable updateRuleCallable(const Model::UpdateRuleRequest& request) const;
UpdateScoreForApiOutcome updateScoreForApi(const Model::UpdateScoreForApiRequest &request)const;
void updateScoreForApiAsync(const Model::UpdateScoreForApiRequest& request, const UpdateScoreForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateScoreForApiOutcomeCallable updateScoreForApiCallable(const Model::UpdateScoreForApiRequest& request) const;
UpdateSkillGroupConfigOutcome updateSkillGroupConfig(const Model::UpdateSkillGroupConfigRequest &request)const;
void updateSkillGroupConfigAsync(const Model::UpdateSkillGroupConfigRequest& request, const UpdateSkillGroupConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateSkillGroupConfigOutcomeCallable updateSkillGroupConfigCallable(const Model::UpdateSkillGroupConfigRequest& request) const;
UpdateSubScoreForApiOutcome updateSubScoreForApi(const Model::UpdateSubScoreForApiRequest &request)const;
void updateSubScoreForApiAsync(const Model::UpdateSubScoreForApiRequest& request, const UpdateSubScoreForApiAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateSubScoreForApiOutcomeCallable updateSubScoreForApiCallable(const Model::UpdateSubScoreForApiRequest& request) const;
UpdateSyncQualityCheckDataOutcome updateSyncQualityCheckData(const Model::UpdateSyncQualityCheckDataRequest &request)const;
void updateSyncQualityCheckDataAsync(const Model::UpdateSyncQualityCheckDataRequest& request, const UpdateSyncQualityCheckDataAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateSyncQualityCheckDataOutcomeCallable updateSyncQualityCheckDataCallable(const Model::UpdateSyncQualityCheckDataRequest& request) const;
UpdateTaskAssignRuleOutcome updateTaskAssignRule(const Model::UpdateTaskAssignRuleRequest &request)const;
void updateTaskAssignRuleAsync(const Model::UpdateTaskAssignRuleRequest& request, const UpdateTaskAssignRuleAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateTaskAssignRuleOutcomeCallable updateTaskAssignRuleCallable(const Model::UpdateTaskAssignRuleRequest& request) const;
UpdateUserOutcome updateUser(const Model::UpdateUserRequest &request)const;
void updateUserAsync(const Model::UpdateUserRequest& request, const UpdateUserAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateUserOutcomeCallable updateUserCallable(const Model::UpdateUserRequest& request) const;
UpdateUserConfigOutcome updateUserConfig(const Model::UpdateUserConfigRequest &request)const;
void updateUserConfigAsync(const Model::UpdateUserConfigRequest& request, const UpdateUserConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateUserConfigOutcomeCallable updateUserConfigCallable(const Model::UpdateUserConfigRequest& request) const;
UpdateWarningConfigOutcome updateWarningConfig(const Model::UpdateWarningConfigRequest &request)const;
void updateWarningConfigAsync(const Model::UpdateWarningConfigRequest& request, const UpdateWarningConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateWarningConfigOutcomeCallable updateWarningConfigCallable(const Model::UpdateWarningConfigRequest& request) const;
UploadAudioDataOutcome uploadAudioData(const Model::UploadAudioDataRequest &request)const;
void uploadAudioDataAsync(const Model::UploadAudioDataRequest& request, const UploadAudioDataAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UploadAudioDataOutcomeCallable uploadAudioDataCallable(const Model::UploadAudioDataRequest& request) const;
UploadDataOutcome uploadData(const Model::UploadDataRequest &request)const;
void uploadDataAsync(const Model::UploadDataRequest& request, const UploadDataAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UploadDataOutcomeCallable uploadDataCallable(const Model::UploadDataRequest& request) const;
UploadDataSyncOutcome uploadDataSync(const Model::UploadDataSyncRequest &request)const;
void uploadDataSyncAsync(const Model::UploadDataSyncRequest& request, const UploadDataSyncAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UploadDataSyncOutcomeCallable uploadDataSyncCallable(const Model::UploadDataSyncRequest& request) const;
UploadRuleOutcome uploadRule(const Model::UploadRuleRequest &request)const;
void uploadRuleAsync(const Model::UploadRuleRequest& request, const UploadRuleAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UploadRuleOutcomeCallable uploadRuleCallable(const Model::UploadRuleRequest& request) const;
VerifyFileOutcome verifyFile(const Model::VerifyFileRequest &request)const;
void verifyFileAsync(const Model::VerifyFileRequest& request, const VerifyFileAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
VerifyFileOutcomeCallable verifyFileCallable(const Model::VerifyFileRequest& request) const;
VerifySentenceOutcome verifySentence(const Model::VerifySentenceRequest &request)const;
void verifySentenceAsync(const Model::VerifySentenceRequest& request, const VerifySentenceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
VerifySentenceOutcomeCallable verifySentenceCallable(const Model::VerifySentenceRequest& request) const;
private:
std::shared_ptr<EndpointProvider> endpointProvider_;
};
}
}
#endif // !ALIBABACLOUD_QUALITYCHECK_QUALITYCHECKCLIENT_H_
| [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
2ace0b03d390e77ece83300dbfe19168c89c7aa5 | a3d36dc2df528e5d1d01b5dc8e15c5a3c13955da | /src/veil/zerocoin/precompute.h | e88c066ee28420f77b04ea1c1c968be58e658dc9 | [
"MIT"
] | permissive | AsaoluElijah/veil | 60cec9e9a1e22c8a938a12f7488f62c9c7aa7e99 | ef398897e6e5ff90e7d9c54031d41da39d531399 | refs/heads/master | 2020-05-07T14:09:47.213509 | 2019-04-09T18:12:17 | 2019-04-09T18:12:17 | 180,579,049 | 1 | 0 | MIT | 2019-06-06T12:11:21 | 2019-04-10T12:40:10 | C++ | UTF-8 | C++ | false | false | 1,060 | h | // Copyright (c) 2019 The Veil Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef VEIL_PRECOMPUTE_H
#define VEIL_PRECOMPUTE_H
#include "lrucache.h"
#include "boost/thread.hpp"
static const int DEFAULT_PRECOMPUTE_BPC = 100; // BPC = Blocks Per Cycle
static const int MIN_PRECOMPUTE_BPC = 100;
static const int MAX_PRECOMPUTE_BPC = 2000;
class Precompute
{
private:
int nBlocksPerCycle;
boost::thread_group* pthreadGroupPrecompute;
public:
LRUCache lru;
Precompute();
void SetNull();
boost::thread_group* GetThreadGroupPointer();
void SetThreadGroupPointer(void* threadGroup);
void SetThreadPointer();
bool StartPrecomputing(std::string& strStatus);
void StopPrecomputing();
void SetBlocksPerCycle(const int& nNewBlockPerCycle);
int GetBlocksPerCycle();
};
void ThreadPrecomputeSpends();
void LinkPrecomputeThreadGroup(void* pthreadgroup);
void DumpPrecomputes();
#endif //VEIL_PRECOMPUTE_H
| [
"jeremy.anderson.utah@gmail.com"
] | jeremy.anderson.utah@gmail.com |
d118e3696ccf00f8795ab6e54f746f906b0e210e | 17fb9dc6ff085444a2c59fe32971b45644fea3f7 | /h/bfs.h | cda13c2af4f28cbaf8f9ac69b4b545c9e261825d | [] | no_license | ali-ghazi78/AP-midterm-project | 422497aca3892d05b212e233b8e2aa8ee6e2a8b5 | 1932b9970082148597d0ea854f18d2dcf2b65e16 | refs/heads/master | 2023-02-08T18:50:39.683152 | 2020-12-31T15:41:27 | 2020-12-31T15:41:27 | 321,785,686 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,302 | h | #ifndef __BFS__
#define __BFS__
#include <iostream>
#include <vector>
#include <memory>
#include <queue>
#include <set>
class BFS
{
public:
class Node
{
public:
static size_t Node_no;
Node(const std::vector<int> & initial_state);
~Node();
std::shared_ptr<std::vector<int>> val;
Node* up;
Node* down;
Node* right;
Node* left;
Node* parent;
};
std::vector<int >desire_final_state;
BFS(std::vector<int> val);
BFS()=default;
~BFS();
std::queue<Node *> search_queue;
std::set<std::string> all_record;
std::vector<Node *> all_address_to_del;
std::vector<std::vector<int>> final_val;
Node *head;
Node *current_node;
bool randome_or_costume ;
void make_adjacent_nodes(const std::vector<int> ¤t_node);
void move_zero(std::vector<int> &vec1, int x, int y, int loc);
bool check_if_is_answer(const std::vector<int> &v);
bool search_for_answer(Node* cu_node);
bool is_solvable(const std::vector<int> &v);
void disp_in_menu(const std::vector<int> &v,const std::vector<int> &v2);
std::string make_str(const std::vector<int> &v);
size_t show_path(BFS::Node *n);
int loop();
};
#endif | [
"alighaziasgar75@gmail.com"
] | alighaziasgar75@gmail.com |
d067f4b305c548369341aa5dabccd23a2573704c | 9689bfc3a58135df06249bd6479533807d0fa56f | /examples/JsonHttpClient/JsonHttpClient.ino | 99bc2544a22445c2d2a1084154bf55c302501809 | [
"MIT"
] | permissive | asterapp-giuliano/ArduinoJson | c7ee22457080426455c529021daf5bae16174514 | 126f7ab8192af663071059cd6c5a75abf7069012 | refs/heads/master | 2021-08-12T01:39:02.391255 | 2017-11-13T14:47:26 | 2017-11-13T15:17:44 | 111,251,661 | 1 | 0 | null | 2017-11-19T00:36:21 | 2017-11-19T00:36:21 | null | UTF-8 | C++ | false | false | 2,270 | ino | // ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2017
// MIT License
//
// Example of an HTTP client parsing a JSON response.
//
// This program perform an HTTP GET of arduinojson.org/example.json
// Here is the expected response:
// {
// "sensor": "gps",
// "time": 1351824120,
// "data": [
// 48.756080,
// 2.302038
// ]
// }
// See http://arduinojson.org/assistant/ to compute the size of the buffer.
//
// Disclaimer: the code emphasize the communication between client and server,
// it doesn't claim to be a reference of good coding practices.
#include <ArduinoJson.h>
#include <Ethernet.h>
#include <SPI.h>
void setup() {
Serial.begin(9600);
while (!Serial);
echo("Initialize Ethernet library");
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
Ethernet.begin(mac) || die("Failed to configure Ethernet");
delay(1000);
echo("Connect to HTTP server");
EthernetClient client;
client.setTimeout(10000);
client.connect("arduinojson.org", 80) || die("Connection failed");
echo("Send HTTP request");
client.println("GET /example.json HTTP/1.0");
client.println("Host: arduinojson.org");
client.println("Connection: close");
client.println() || die("Failed to send request");
echo("Check HTTP status");
char status[32] = {0};
client.readBytesUntil('\r', status, sizeof(status));
if (strcmp(status, "HTTP/1.1 200 OK") != 0) {
echo(status);
die("Unexpected HTTP response");
}
echo("Skip HTTP headers");
char endOfHeaders[] = "\r\n\r\n";
client.find(endOfHeaders) || die("Invalid response");
echo("Allocate JsonBuffer");
const size_t BUFFER_SIZE = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60;
DynamicJsonBuffer jsonBuffer(BUFFER_SIZE);
echo("Parse JSON object");
JsonObject& root = jsonBuffer.parseObject(client);
if (!root.success()) die("Parsing failed!");
echo("Extract values");
echo(root["sensor"].as<char*>());
echo(root["time"].as<char*>());
echo(root["data"][0].as<char*>());
echo(root["data"][1].as<char*>());
echo("Disconnect");
client.stop();
}
void loop() {}
void echo(const char* message) {
Serial.println(message);
}
bool die(const char* message) {
Serial.println(message);
while (true); // loop forever
return false;
} | [
"github@benoitblanchon.fr"
] | github@benoitblanchon.fr |
e1ecc02f2dbd3aaf063ccb0ef5122e7a2efafc2b | 93bf3d52ca3bcf955a6cc559ea5cda9c1bd0418d | /src/ui/hkxclassesui/hkdataui.h | 85db10f3c271bc1edbcaaa7400d6bd94a38884b5 | [
"MIT"
] | permissive | Source-Scripts/Skyrim-Behavior-Editor- | f24b52b9b505ea21f8270d8bcaff38567b379140 | 7b7167cb18e28f435a64069acbf61eca49a07be3 | refs/heads/master | 2023-05-11T02:37:26.527654 | 2020-10-03T01:36:03 | 2020-10-03T01:36:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,881 | h | #ifndef HKDATAUI_H
#define HKDATAUI_H
#include <QGroupBox>
class BehaviorGraphView;
class AnimationsUI;
class QVBoxLayout;
class QHBoxLayout;
class QPushButton;
class QStackedLayout;
class HkxObject;
class QLabel;
class BSiStateTaggingGeneratorUI;
class ModifierGeneratorUI;
class ManualSelectorGeneratorUI;
class StateMachineUI;
class StateUI;
class TreeGraphicsItem;
class BehaviorVariablesUI;
class EventsUI;
class MainWindow;
class TransitionsUI;
class HkTransition;
class hkbStateMachineStateInfo;
class hkbStateMachine;
class GenericTableWidget;
class BlenderGeneratorUI;
class BehaviorGraphUI;
class BSLimbIKModifierUI;
class BSBoneSwitchGeneratorUI;
class BSOffsetAnimationGeneratorUI;
class BSCyclicBlendTransitionGeneratorUI;
class PoseMatchingGeneratorUI;
class ClipGeneratorUI;
class BSSynchronizedClipGeneratorUI;
class BehaviorReferenceGeneratorUI;
class BSDirectAtModifierUI;
class MoveCharacterModifierUI;
class RotateCharacterModifierUI;
class EvaluateExpressionModifierUI;
class ModifierListUI;
class EventDrivenModifierUI;
class GetHandleOnBoneModifierUI;
class EvaluateHandleModifierUI;
class SenseHandleModifierUI;
class BSDecomposeVectorModifierUI;
class BSIsActiveModifierUI;
class ComputeDirectionModifierUI;
class BSComputeAddBoneAnimModifierUI;
class BSDistTriggerModifierUI;
class BSInterpValueModifierUI;
class GetUpModifierUI;
class GetWorldFromModelModifierUI;
class TwistModifierUI;
class TimerModifierUI;
class DampingModifierUI;
class RigidBodyRagdollControlsModifierUI;
class PoweredRagdollControlsModifierUI;
class CombineTransformsModifierUI;
class ComputeRotationFromAxisAngleModifierUI;
class ComputeRotationToTargetModifierUI;
class TransformVectorModifierUI;
class LookAtModifierUI;
class KeyframeBonesModifierUI;
class FootIkControlsModifierUI;
class MirrorModifierUI;
class ExtractRagdollPoseModifierUI;
class BSTimerModifierUI;
class BSGetTimeStepModifierUI;
class DelayedModifierUI;
class BSRagdollContactListenerModifierUI;
class BSEventOnDeactivateModifierUI;
class BSSpeedSamplerModifierUI;
class BSPassByTargetTriggerModifierUI;
class BSLookAtModifierUI;
class DetectCloseToGroundModifierUI;
class BSEventEveryNEventsModifierUI;
class BSEventOnFalseToTrueModifierUI;
class BSModifyOnceModifierUI;
class HandIkControlsModifierUI;
class BSTweenerModifierUI;
class BGSGamebryoSequenceGeneratorUI;
class EventsFromRangeModifierUI;
class BlenderGeneratorChildUI;
class BSBoneSwitchGeneratorBoneDataUI;
class MainWindow;
/**
* To add support for a new class we need to add it to the "DATA_TYPE_LOADED" enum, add it to the stacked layout in the correct order,
* connect it's name change signal to this, deal with any variable event name changes, add it to the list of widgets to be loaded and
* add it to the set behavior view function if necessary.
*/
class HkDataUI final: public QGroupBox
{
Q_OBJECT
public:
HkDataUI(const QString & title);
HkDataUI& operator=(const HkDataUI&) = delete;
HkDataUI(const HkDataUI &) = delete;
~HkDataUI() = default;
public:
BehaviorGraphView * loadBehaviorView(BehaviorGraphView *view);
void setEventsVariablesAnimationsUI(EventsUI *events, BehaviorVariablesUI *variables, AnimationsUI *animations);
void unloadDataWidget();
public slots:
void connectToGeneratorTable();
void connectToModifierTable();
void disconnectTables();
void changeCurrentDataWidget(TreeGraphicsItem *icon);
void modifierAdded(const QString & name, const QString & type);
void modifierNameChanged(const QString & newName, int index);
void modifierRemoved(int index);
void generatorAdded(const QString & name, const QString & type);
void generatorNameChanged(const QString & newName, int index);
void generatorRemoved(int index);
void eventNameChanged(const QString & newName, int index);
void eventAdded(const QString & name);
void eventRemoved(int index);
//void animationNameChanged(const QString & newName, int index);
void animationAdded(const QString & name);
//void animationRemoved(int index);
void variableNameChanged(const QString & newName, int index);
void variableAdded(const QString & name, const QString & type);
void variableRemoved(int index);
private:
enum DATA_TYPE_LOADED{
NO_DATA_SELECTED,
BS_I_STATE_TAG_GEN,
MODIFIER_GENERATOR,
MANUAL_SELECTOR_GENERATOR,
STATE_MACHINE,
STATE,
BLENDER_GENERATOR,
BLENDER_GENERATOR_CHILD,
BEHAVIOR_GRAPH,
BS_LIMB_IK_MOD,
BS_BONE_SWITCH_GENERATOR,
BS_BONE_SWITCH_GENERATOR_CHILD,
BS_OFFSET_ANIMATION_GENERATOR,
BS_CYCLIC_BLEND_TRANSITION_GENERATOR,
POSE_MATCHING_GENERATOR,
CLIP_GENERATOR,
SYNCHRONIZED_CLIP_GENERATOR,
BEHAVIOR_REFERENCE_GENERATOR,
DIRECT_AT_MODIFIER,
MOVE_CHARACTER_MODIFIER,
ROTATE_CHARACTER_MODIFIER,
EVALUATE_EXPRESSION_MODIFIER,
MODIFIER_LIST,
EVENT_DRIVEN_MODIFIER,
GET_HANDLE_ON_BONE_MODIFIER,
EVALUATE_HANDLE_MODIFIER,
SENSE_HANDLE_MODIFIER,
BS_DECOMPOSE_VECTOR_MODIFIER,
BS_IS_ACTIVE_MODIFIER,
COMPUTE_DIRECTION_MODIFIER,
BS_COMPUTE_ADD_BONE_ANIM_MODIFIER,
BS_DIST_TRIGGER_MODIFER,
BS_INTERP_VALUE_MODIFIER,
GET_UP_MODIFIER,
GET_WORLD_FROM_MODEL_MODIFIER,
TWIST_MODIFIER,
TIMER_MODIFIER,
DAMPING_MODIFIER,
RIGID_BODY_RAGDOLL_CONTROLS_MODIFIER,
POWERED_RAGDOLL_CONTROLS_MODIFIER,
COMBINE_TRANSFORMS_MODIFIER,
COMPUTE_ROTATION_FROM_AXIS_ANGLE_MODIFIER,
COMPUTE_ROTATION_TO_TARGET_MODIFIER,
TRANSFORM_VECTOR_MODIFIER,
LOOK_AT_MODIFIER,
KEY_FRAME_BONES_MODIFIER,
FOOT_IK_CONTROLS_MODIFIER,
MIRROR_MODIFIER,
EXTRACT_RAGDOLL_POSE_MODIFIER,
BS_TIMER_MODIFIER,
BS_GET_TIME_STEP_MODIFIER,
DELAYED_MODIFIER,
BS_RAGDOLL_CONTACT_LISTENER_MODIFIER,
BS_EVENT_ON_DEACTIVATE_MODIFIER,
BS_SPEED_SAMPLER_MODIFIER,
BS_PASS_BY_TARGET_TRIGGER_MODIFIER,
BS_LOOK_AT_MODIFIER,
DETECT_CLOSE_TO_GROUND_MODIFIER,
BS_EVENT_EVERY_N_EVENTS_MODIFIER,
BS_EVENT_ON_FALSE_TO_TRUE_MODIFIER,
BS_MODIFY_ONCE_MODIFIER,
HAND_IK_CONTROLS_MODIFIER,
BS_TWEENER_MODIFIER,
BGS_GAMEBYRO_SEQUENCE_GENERATOR,
EVENTS_FROM_RANGE_MODIFIER
};
private:
template<typename UIWidget>
void changeWidget(HkDataUI::DATA_TYPE_LOADED type, HkxObject *olddata, UIWidget *uiwidget, GenericTableWidget *table1, GenericTableWidget *table2);
template<typename UIWidget>
void changeWidget(HkDataUI::DATA_TYPE_LOADED type, HkxObject *olddata, UIWidget *uiwidget, GenericTableWidget *table1, GenericTableWidget *table2, GenericTableWidget *table3);
template<typename UIWidget>
void changeWidget(HkDataUI::DATA_TYPE_LOADED type, HkxObject *olddata, UIWidget *uiwidget, GenericTableWidget *table1, GenericTableWidget *table2, GenericTableWidget *table3, GenericTableWidget *table4);
private:
static const QStringList generatorTypes;
static const QStringList modifierTypes;
static const QStringList variableTypes;
EventsUI *eventsUI;
BehaviorVariablesUI *variablesUI;
AnimationsUI *animationsUI;
BehaviorGraphView *behaviorView;
QVBoxLayout *verLyt;
QStackedLayout *stack;
HkxObject *loadedData;
GenericTableWidget *generatorsTable;
GenericTableWidget *modifiersTable;
GenericTableWidget *variablesTable;
GenericTableWidget *eventsTable;
GenericTableWidget *characterPropertiesTable;
GenericTableWidget *animationsTable;
GenericTableWidget *ragdollBonesTable;
QLabel *noDataL;
BSiStateTaggingGeneratorUI *iStateTagGenUI;
ModifierGeneratorUI *modGenUI;
ManualSelectorGeneratorUI *manSelGenUI;
StateMachineUI *stateMachineUI;
StateUI *stateUI;
BlenderGeneratorUI *blenderGeneratorUI;
BlenderGeneratorChildUI *blenderGeneratorChildUI;
BehaviorGraphUI *behaviorGraphUI;
BSLimbIKModifierUI *limbIKModUI;
BSBoneSwitchGeneratorUI *boneSwitchUI;
BSBoneSwitchGeneratorBoneDataUI *boneSwitchChildUI;
BSOffsetAnimationGeneratorUI *offsetAnimGenUI;
BSCyclicBlendTransitionGeneratorUI *cyclicBlendTransGenUI;
PoseMatchingGeneratorUI *poseMatchGenUI;
ClipGeneratorUI *clipGenUI;
BSSynchronizedClipGeneratorUI *syncClipGenUI;
BehaviorReferenceGeneratorUI *behaviorRefGenUI;
BSDirectAtModifierUI *directAtModUI;
MoveCharacterModifierUI *moveCharModUI;
RotateCharacterModifierUI *rotateCharModUI;
EvaluateExpressionModifierUI *evaluateExpModUI;
ModifierListUI *modListUI;
EventDrivenModifierUI *eventDrivenModUI;
GetHandleOnBoneModifierUI *getHandleOnBoneUI;
EvaluateHandleModifierUI *evaluateHandleModUI;
SenseHandleModifierUI *senseHandleModUI;
BSDecomposeVectorModifierUI *decomposeVectorModUI;
BSIsActiveModifierUI *isActiveModUI;
ComputeDirectionModifierUI *computeDirMod;
BSComputeAddBoneAnimModifierUI *computeAddAnimUI;
BSDistTriggerModifierUI *distTriggerModUI;
BSInterpValueModifierUI *interpValueModUI;
GetUpModifierUI *getUpModUI;
GetWorldFromModelModifierUI *getWorldFromModelModUI;
TwistModifierUI *twistModUI;
TimerModifierUI *timerModUI;
DampingModifierUI *dampingModUI;
RigidBodyRagdollControlsModifierUI *rigidRagdollControlsModUI;
PoweredRagdollControlsModifierUI *poweredRagdollControlsModUI;
CombineTransformsModifierUI *combineTransModUI;
ComputeRotationFromAxisAngleModifierUI *computeRotationAxisAngleModUI;
ComputeRotationToTargetModifierUI *computeRotationToTargetModUI;
TransformVectorModifierUI *transformVectorModUI;
LookAtModifierUI *lookAtModUI;
KeyframeBonesModifierUI *keyframeBonesModUI;
FootIkControlsModifierUI *footIKControlsModUI;
MirrorModifierUI *mirrorModUI;
ExtractRagdollPoseModifierUI *extractRagdollPoseModUI;
BSTimerModifierUI *bsTimerModUI;
BSGetTimeStepModifierUI *getTimeStepModUI;
DelayedModifierUI *delayedModUI;
BSRagdollContactListenerModifierUI *ragdollContactListenerModUI;
BSEventOnDeactivateModifierUI *eventOnDeactivateModUI;
BSSpeedSamplerModifierUI *speedSamplerModUI;
BSPassByTargetTriggerModifierUI *passByTargetTriggerModUI;
BSLookAtModifierUI *bsLookAtModUI;
DetectCloseToGroundModifierUI *detectCloseToGroundModUI;
BSEventEveryNEventsModifierUI *eventEveryNEventsModUI;
BSEventOnFalseToTrueModifierUI *eventOnFalseToTrueModUI;
BSModifyOnceModifierUI *modifyOnceModUI;
HandIkControlsModifierUI *handIKControlsModUI;
BSTweenerModifierUI *tweenerModUI;
BGSGamebryoSequenceGeneratorUI *gamebryoSequenceGenUI;
EventsFromRangeModifierUI *eventsFromRangeModUI;
};
#endif // HKDATAUI_H
| [
"waynek76@yahoo.co.uk"
] | waynek76@yahoo.co.uk |
ad973187fdda83062ef4be93ff23e5f159fc5251 | 70282305c2f82f6eea601dedb206c9e8d2a68bff | /abc147e.cpp | 24a3eb692e370c04447c20f14622611f2f68511b | [] | no_license | JonahEgashira/competitive-programming | e197fa7d709637081f134bc7f774711f595e2463 | 04900d0bac51ac86c79523615ced55c8c8414aee | refs/heads/master | 2023-05-29T15:11:53.759283 | 2021-06-18T16:03:33 | 2021-06-18T16:03:33 | 265,293,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 921 | cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const int D = 80 * 160 + 10;
const int D2 = D * 2;
typedef bitset<D2> bs;
bs dp[90][90];
int main() {
int h,w;
cin >> h >> w;
vector<vector<int>> diff(h, vector<int> (w));
rep(i, h) rep(j, w) cin >> diff[i][j];
rep(i, h) rep(j, w) {
int x;
cin >> x;
diff[i][j] -= x;
diff[i][j] = abs(diff[i][j]);
}
dp[0][0][D + diff[0][0]] = 1;
dp[0][0][D - diff[0][0]] = 1;
rep(i,h) rep(j,w) {
if(i > 0) {
dp[i][j] |= dp[i - 1][j] << diff[i][j];
dp[i][j] |= dp[i - 1][j] >> diff[i][j];
}
if(j > 0) {
dp[i][j] |= dp[i][j - 1] << diff[i][j];
dp[i][j] |= dp[i][j - 1] >> diff[i][j];
}
}
int ans = D2;
for (int i = 0; i < D2; i++) {
if(dp[h - 1][w - 1][i]) {
ans = min(ans, abs(D - i));
}
}
cout << ans << '\n';
}
| [
"jonahega@gmail.com"
] | jonahega@gmail.com |
eba9a8d3e9293676f7c95adab3498f3ffed1046f | c57819bebe1a3e1d305ae0cb869cdcc48c7181d1 | /src/qt/src/3rdparty/webkit/Source/WebCore/rendering/RenderTreeAsText.h | 4c8b145d5a055a1261f6eb9efdbce5c48c40fd97 | [
"BSD-2-Clause",
"LGPL-2.1-only",
"LGPL-2.0-only",
"Qt-LGPL-exception-1.1",
"LicenseRef-scancode-generic-exception",
"GPL-3.0-only",
"GPL-1.0-or-later",
"GFDL-1.3-only",
"BSD-3-Clause"
] | permissive | blowery/phantomjs | 255829570e90a28d1cd597192e20314578ef0276 | f929d2b04a29ff6c3c5b47cd08a8f741b1335c72 | refs/heads/master | 2023-04-08T01:22:35.426692 | 2012-10-11T17:43:24 | 2012-10-11T17:43:24 | 6,177,895 | 1 | 0 | BSD-3-Clause | 2023-04-03T23:09:40 | 2012-10-11T17:39:25 | C++ | UTF-8 | C++ | false | false | 3,995 | h | /*
* Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef RenderTreeAsText_h
#define RenderTreeAsText_h
#include "TextStream.h"
#include <wtf/Forward.h>
#include <wtf/MathExtras.h>
namespace WebCore {
class Element;
class FloatPoint;
class FloatSize;
class Frame;
class IntPoint;
class IntRect;
class RenderObject;
class TextStream;
enum RenderAsTextBehaviorFlags {
RenderAsTextBehaviorNormal = 0,
RenderAsTextShowAllLayers = 1 << 0, // Dump all layers, not just those that would paint.
RenderAsTextShowLayerNesting = 1 << 1, // Annotate the layer lists.
RenderAsTextShowCompositedLayers = 1 << 2, // Show which layers are composited.
RenderAsTextShowAddresses = 1 << 3, // Show layer and renderer addresses.
RenderAsTextShowIDAndClass = 1 << 4, // Show id and class attributes
RenderAsTextPrintingMode = 1 << 5, // Dump the tree in printing mode.
RenderAsTextDontUpdateLayout = 1 << 6, // Don't update layout, to make it safe to call showLayerTree() from the debugger inside layout or painting code.
RenderAsTextShowLayoutState = 1 << 7 // Print the various 'needs layout' bits on renderers.
};
typedef unsigned RenderAsTextBehavior;
// You don't need pageWidthInPixels if you don't specify RenderAsTextInPrintingMode.
String externalRepresentation(Frame*, RenderAsTextBehavior = RenderAsTextBehaviorNormal);
void write(TextStream&, const RenderObject&, int indent = 0, RenderAsTextBehavior = RenderAsTextBehaviorNormal);
void writeIndent(TextStream&, int indent);
class RenderTreeAsText {
// FIXME: This is a cheesy hack to allow easy access to RenderStyle colors. It won't be needed if we convert
// it to use visitedDependentColor instead. (This just involves rebaselining many results though, so for now it's
// not being done).
public:
static void writeRenderObject(TextStream& ts, const RenderObject& o, RenderAsTextBehavior behavior);
};
TextStream& operator<<(TextStream&, const IntPoint&);
TextStream& operator<<(TextStream&, const IntRect&);
TextStream& operator<<(TextStream&, const FloatPoint&);
TextStream& operator<<(TextStream&, const FloatSize&);
template<typename Item>
TextStream& operator<<(TextStream& ts, const Vector<Item>& vector)
{
ts << "[";
unsigned size = vector.size();
for (unsigned i = 0; i < size; ++i) {
ts << vector[i];
if (i < size - 1)
ts << ", ";
}
ts << "]";
return ts;
}
// Helper function shared with SVGRenderTreeAsText
String quoteAndEscapeNonPrintables(const String&);
String counterValueForElement(Element*);
String markerTextForListItem(Element*);
bool hasFractions(double val);
} // namespace WebCore
#endif // RenderTreeAsText_h
| [
"ariya.hidayat@gmail.com"
] | ariya.hidayat@gmail.com |
382d94282a2209e2b6766a30fc848794566b75c6 | 2b975352c222813160419d1c6428b17c876800e7 | /Include/NsGui/UserControl.h | a414806ed46b95aebe761da1c9c34a3149c4edb2 | [] | no_license | iomeone/NoesisGUI-NativeSDK-2.0.0f1 | b540203e26c6e8758be0eccebaf3304fde2530ac | 6ec3bc91ed64dd1dd2c0391de16e6a4978dc4e70 | refs/heads/master | 2021-06-13T03:53:42.867886 | 2017-03-24T13:56:13 | 2017-03-24T13:56:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,069 | h | ////////////////////////////////////////////////////////////////////////////////////////////////////
// Noesis Engine - http://www.noesisengine.com
// Copyright (c) 2009-2010 Noesis Technologies S.L. All Rights Reserved.
////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __GUI_USERCONTROL_H__
#define __GUI_USERCONTROL_H__
#include <Noesis.h>
#include <NsGui/ContentControl.h>
namespace Noesis
{
namespace Gui
{
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Provides a simple way to create a composition of controls.
///
/// http://msdn.microsoft.com/en-us/library/system.windows.forms.usercontrol.aspx
////////////////////////////////////////////////////////////////////////////////////////////////////
class NS_GUI_CORE_API UserControl: public ContentControl
{
protected:
/// From FrameworkElement
//@{
FrameworkElement* GetStateGroupsRoot() const;
//@}
NS_DECLARE_REFLECTION(UserControl, ContentControl)
};
}
}
#endif
| [
"bfp57867@users.noreply.github.com"
] | bfp57867@users.noreply.github.com |
fca5c0f8590992526501b0ef0d7af3f3b6485250 | 43334384ff8cc65b29301659bbd5a63f4bfae378 | /geobase/FairGeoSet.h | 163eaffd103c1f2880749464bf3cd36f1ba3dc62 | [] | no_license | yeleisun/SpiRITROOT | b11027e50cfe7e0c9017c24f8cec3db80e73b3a8 | c8717f19547a948400b687c070110c4d67a9ea2d | refs/heads/master | 2021-01-19T20:34:29.012437 | 2014-08-22T02:12:25 | 2014-08-22T02:12:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,774 | h | #ifndef FAIRGEOSET_H
#define FAIRGEOSET_H
#include "TNamed.h" // for TNamed
#include "Riosfwd.h" // for fstream
#include "Rtypes.h" // for Int_t, Bool_t, etc
#include "TList.h" // for TList
#include "TString.h" // for TString
#include <fstream> // for fstream
class FairGeoNode;
class FairGeoShapes;
class FairGeoMedia;
class FairGeoBuilder;
class FairGeoTransform;
class TArrayI;
/**
* Base class for geometry of detector parts
* @author Ilse koenig
*/
class FairGeoSet : public TNamed
{
protected:
Int_t hadesGeo;
class FairGeoCopyNode : public TNamed
{
public:
FairGeoNode* pNode;
FairGeoCopyNode(const char* name,FairGeoNode* node)
: TNamed(name,""), pNode(node) {}
// SetName(name);
//
// }
~FairGeoCopyNode() {}
private:
FairGeoCopyNode(const FairGeoCopyNode&);
FairGeoCopyNode& operator=(const FairGeoCopyNode&);
};
TList* volumes; /** list of volumes */
TList* masterNodes; /** pointer to list of mother volumes from other detector parts*/
Int_t maxSectors; /** maximum number of sectors (-1 for detectors outside any sector)*/
Int_t maxKeepinVolumes; /** maximum number of keepin volumes per sector*/
Int_t maxModules; /** maximum number of modules per sector*/
TArrayI* modules; /** Module's array.*/
FairGeoShapes* pShapes; /** pointer to the class FairGeoShapes*/
TString geoFile; /** name of geometry input file or Oracle*/
TString author; /** author of the media version*/
TString description; /** description of the version*/
FairGeoSet();
void readInout(fstream&);
void readTransform(fstream&,FairGeoTransform&);
Bool_t readVolumeParams(fstream&,FairGeoMedia*,FairGeoNode*,TList* l=0);
Bool_t readKeepIn(fstream&,FairGeoMedia*,TString&);
Bool_t readModule(fstream&,FairGeoMedia*,TString&,TString&,Bool_t a=kFALSE);
public :
virtual ~FairGeoSet();
void setShapes(FairGeoShapes* s) {pShapes=s;}
void setMasterNodes(TList* m) {masterNodes=m;}
void setGeomFile(const char* filename) {geoFile=filename;}
const char* getGeomFile() { return geoFile.Data(); }
Int_t getMaxSectors(void) {return maxSectors;}
Int_t getMaxModules(void) {return maxModules;}
Int_t getMaxKeepinVolumes(void) {return maxKeepinVolumes;}
void setModules(Int_t,Int_t*);
Int_t* getModules(void);
Int_t getModule(Int_t,Int_t);
FairGeoNode* getVolume(const char* name) {return (FairGeoNode*)volumes->FindObject(name);}
FairGeoNode* getMasterNode(const char* name) {return (FairGeoNode*)masterNodes->FindObject(name);}
TList* getListOfVolumes() {return volumes;}
FairGeoShapes* getShapes() {return pShapes;}
void setAuthor(TString& s) {author=s;}
void setDescription(TString& s) {description=s;}
TString& getAuthor() {return author;}
TString& getDescription() {return description;}
virtual const char* getKeepinName(Int_t,Int_t) {return 0;}
virtual const char* getModuleName(Int_t) {return 0;}
virtual const char* getEleName(Int_t) {return 0;}
virtual Int_t getSecNumInMod(const TString&) {return -1;}
virtual Int_t getModNumInMod(const TString&) {return 0;}
virtual Bool_t read(fstream&,FairGeoMedia*);
virtual void addRefNodes() {}
virtual void write(fstream&);
virtual void print();
virtual Bool_t create(FairGeoBuilder*);
void compare(FairGeoSet&);
ClassDef(FairGeoSet,0) //
private:
FairGeoSet(const FairGeoSet&);
FairGeoSet& operator=(const FairGeoSet&);
};
#endif /* !FAIRGEOSET_H */
| [
"geniejhang@majimak.com"
] | geniejhang@majimak.com |
82b4aaf0cd5852fb2167596d7ac2d05f76d0bafb | 5231f586d3665def14a6ce21bef9e70f29eaef28 | /lang/libcxx/patches/patch-src_support_solaris_xlocale.cpp | dac5e7f5be58f70c75a000a46b5ef28b6af4a22c | [] | no_license | drscream/pkgsrc | f35370f1525e8b60976f1d2c0ca70c968e1f6bdd | 0b7ac28528eb85402e83a97b8666274a0e405825 | refs/heads/trunk | 2022-03-11T02:11:35.144552 | 2022-01-10T10:08:36 | 2022-01-10T10:08:36 | 100,736,263 | 1 | 0 | null | 2021-10-17T18:55:13 | 2017-08-18T17:40:07 | null | UTF-8 | C++ | false | false | 688 | cpp | $NetBSD: patch-src_support_solaris_xlocale.cpp,v 1.1 2022/01/09 23:20:59 tnn Exp $
don't try to use sys/localedef.h on SunOS if nonexistent
OpenIndiana doesn't seem to ship the header.
Userland shouldn't use it, according to Garrett D'Amore:
https://illumos.topicbox.com/groups/developer/T6cfd2e6cd87f3485-M30dac0cb6fffae62ef45b9a8
--- src/support/solaris/xlocale.cpp.orig 2021-09-24 16:18:10.000000000 +0000
+++ src/support/solaris/xlocale.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#ifdef __sun__
+#if defined(__sun__) && __has_include(<sys/localedef.h>)
#include "__support/solaris/xlocale.h"
#include <stdarg.h>
| [
"tnn@pkgsrc.org"
] | tnn@pkgsrc.org |
799722d9392ed098504e4385ad2ead739a3429c8 | 6b40e9dccf2edc767c44df3acd9b626fcd586b4d | /NT/com/netfx/src/clr/classlibnative/nls/sortingtablefile.h | 60a971355ab8511218b3407e5d1b2fae5114d56e | [] | no_license | jjzhang166/WinNT5_src_20201004 | 712894fcf94fb82c49e5cd09d719da00740e0436 | b2db264153b80fbb91ef5fc9f57b387e223dbfc2 | refs/heads/Win2K3 | 2023-08-12T01:31:59.670176 | 2021-10-14T15:14:37 | 2021-10-14T15:14:37 | 586,134,273 | 1 | 0 | null | 2023-01-07T03:47:45 | 2023-01-07T03:47:44 | null | UTF-8 | C++ | false | false | 12,507 | h | // ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
#ifndef _SORTING_TABLE_FILE_H
#define _SORTING_TABLE_FILE_H
//This is the list of English locales which we currently understand.
//We should only do fast comparisons in one of these locales.
//@Consider: What non-English locales can we use?
//@Consider: Can we just look at the 0xnn09 to determine English? (This is limiting in the future, because
// it will bite us if we ever have install an English locale that has combining characters or
// a different sorting order for characters less than 0x80.
#define IS_FAST_COMPARE_LOCALE(loc) (((loc)==0x0409) /*USA*/ || ((loc)==0x0809) /*UK*/ ||\
((loc)==0x0C09) /*AUS*/ || ((loc)==0x1009) /*CANADA*/ ||\
((loc)==0x2809) /*Belize*/ || ((loc)==0x2409) /*Caribean*/ ||\
((loc)==0x1809) /*Ireland*/ || ((loc)==0x2009) /*Jamaica*/ ||\
((loc)==0x1409) /*NZ*/ || ((loc)==0x3409) /*Philippines*/ ||\
((loc)==0x2C09) /*Trinidad*/|| ((loc)==0x1c09) /*South Africa*/ ||\
((loc)==0x3009) /*Zimbabwe*/)
//
// Sortkey Structure.
//
typedef struct sortkey_s {
union {
struct sm_aw_s {
BYTE Alpha; // alphanumeric weight
BYTE Script; // script member
} SM_AW;
WORD Unicode; // unicode weight
} UW;
BYTE Diacritic; // diacritic weight
BYTE Case; // case weight (with COMP)
} SORTKEY, *PSORTKEY;
//
// Ideograph Lcid Exception Structure.
//
typedef struct ideograph_lcid_s {
DWORD Locale; // locale id
WORD pFileName[14]; // ptr to file name
} IDEOGRAPH_LCID, *PIDEOGRAPH_LCID;
//
// Expansion Structure.
//
typedef struct expand_s {
WCHAR UCP1; // Unicode code point 1
WCHAR UCP2; // Unicode code point 2
} EXPAND, *PEXPAND;
//
// Exception Header Structure.
// This is the header for the exception tables.
//
typedef struct except_hdr_s {
DWORD Locale; // locale id
DWORD Offset; // offset to exception nodes (words)
DWORD NumEntries; // number of entries for locale id
} EXCEPT_HDR, *PEXCEPT_HDR;
//
// Exception Structure.
//
// NOTE: May also be used for Ideograph Exceptions (4 column tables).
//
typedef struct except_s
{
WORD UCP; // unicode code point
WORD Unicode; // unicode weight
BYTE Diacritic; // diacritic weight
BYTE Case; // case weight
} EXCEPT, *PEXCEPT;
//
// Ideograph Exception Header Structure.
//
typedef struct ideograph_except_hdr_s
{
DWORD NumEntries; // number of entries in table
DWORD NumColumns; // number of columns in table (2 or 4)
} IDEOGRAPH_EXCEPT_HDR, *PIDEOGRAPH_EXCEPT_HDR;
//
// Ideograph Exception Structure.
//
typedef struct ideograph_except_s
{
WORD UCP; // unicode code point
WORD Unicode; // unicode weight
} IDEOGRAPH_EXCEPT, *PIDEOGRAPH_EXCEPT;
typedef DWORD REVERSE_DW; // reverse diacritic table
typedef REVERSE_DW *PREVERSE_DW; // ptr to reverse diacritic table
typedef DWORD DBL_COMPRESS; // double compression table
typedef DBL_COMPRESS *PDBL_COMPRESS; // ptr to double compression table
typedef LPWORD PCOMPRESS; // ptr to compression table (2 or 3)
//
// Extra Weight Structure.
//
typedef struct extra_wt_s {
BYTE Four; // weight 4
BYTE Five; // weight 5
BYTE Six; // weight 6
BYTE Seven; // weight 7
} EXTRA_WT, *PEXTRA_WT;
//
// Compression Header Structure.
// This is the header for the compression tables.
//
typedef struct compress_hdr_s {
DWORD Locale; // locale id
DWORD Offset; // offset (in words)
WORD Num2; // Number of 2 compressions
WORD Num3; // Number of 3 compressions
} COMPRESS_HDR, *PCOMPRESS_HDR;
//
// Compression 2 Structure.
// This is for a 2 code point compression - 2 code points
// compress to ONE weight.
//
typedef struct compress_2_s {
WCHAR UCP1; // Unicode code point 1
WCHAR UCP2; // Unicode code point 2
SORTKEY Weights; // sortkey weights
} COMPRESS_2, *PCOMPRESS_2;
//
// Compression 3 Structure.
// This is for a 3 code point compression - 3 code points
// compress to ONE weight.
//
typedef struct compress_3_s {
WCHAR UCP1; // Unicode code point 1
WCHAR UCP2; // Unicode code point 2
WCHAR UCP3; // Unicode code point 3
WCHAR Reserved; // dword alignment
SORTKEY Weights; // sortkey weights
} COMPRESS_3, *PCOMPRESS_3;
//
// Multiple Weight Structure.
//
typedef struct multiwt_s {
BYTE FirstSM; // value of first script member
BYTE NumSM; // number of script members in range
} MULTI_WT, *PMULTI_WT;
// Jamo Sequence Sorting Info:
typedef struct {
BYTE m_bOld; // Sequence occurs only in old Hangul flag
CHAR m_chLeadingIndex; // Indices used to locate the prior modern Hangul syllable
CHAR m_chVowelIndex;
CHAR m_chTrailingIndex;
BYTE m_ExtraWeight; // Extra weights that distinguish this from other old Hangul syllables,
// depending on the jamo, this can be a weight for leading jamo,
// vowel jamo, or trailing jamo.
} JAMO_SORT_INFO, *PJAMO_SORT_INFO;
// Jamo Index Table Entry:
typedef struct {
JAMO_SORT_INFO SortInfo; // Sequence sorting info
BYTE Index; // Index into the composition array.
BYTE TransitionCount; // Number of possible transitions from this state
BYTE Reserved; // Reserved byte. To make this structure aligned with WORD.
} JAMO_TABLE, *PJAMO_TABLE;
// Jamo Combination Table Entry:
// NOTENOTE: Make sure that this structure is aligned with WORD.
// Otherwise, code will fail in GetDefaultSortTable().
typedef struct {
WCHAR m_wcCodePoint; // Code point value that enters this state
JAMO_SORT_INFO m_SortInfo; // Sequence sorting info
BYTE m_bTransitionCount; // Number of possible transitions from this state
} JAMO_COMPOSE_STATE, *PJAMO_COMPOSE_STATE;
//
// Table Header Constants (all sizes in WORDS).
//
#define SORTKEY_HEADER 2 // size of SORTKEY table header
#define REV_DW_HEADER 2 // size of REVERSE DW table header
#define DBL_COMP_HEADER 2 // size of DOUBLE COMPRESS table header
#define IDEO_LCID_HEADER 2 // size of IDEOGRAPH LCID table header
#define EXPAND_HEADER 2 // size of EXPANSION table header
#define COMPRESS_HDR_OFFSET 2 // offset to COMPRESSION header
#define EXCEPT_HDR_OFFSET 2 // offset to EXCEPTION header
#define MULTI_WT_HEADER 1 // size of MULTIPLE WEIGHTS table header
#define JAMO_INDEX_HEADER 1 // size of Jamo Index table header
#define JAMO_COMPOSITION_HEADER 1 // size of Jamo Composition state machine table hader
#define NUM_SM 256 // total number of script members
#define LANG_ENGLISH_US 0x0409
class NativeCompareInfo;
typedef NativeCompareInfo* PNativeCompareInfo;
class SortingTable {
public:
SortingTable(NativeGlobalizationAssembly* pNativeGlobalizationAssembly);
~SortingTable();
NativeCompareInfo* InitializeNativeCompareInfo(INT32 nLcid);
#ifdef SHOULD_WE_CLEANUP
BOOL SortingTableShutdown();
#endif /* SHOULD_WE_CLEANUP */
NativeCompareInfo* GetNativeCompareInfo(int nLcid);
// Methods to be called by NativeCompareInfo.
PSORTKEY GetSortKey(int nLcid, HANDLE* phSortKey);
public:
// Information stored in sorting information table (sorttbls.nlp)
// These are accessed by NativeCompareInfo.
DWORD m_NumReverseDW; // number of REVERSE DIACRITICS
DWORD m_NumDblCompression; // number of DOUBLE COMPRESSION locales
DWORD m_NumIdeographLcid; // number of IDEOGRAPH LCIDs
DWORD m_NumExpansion; // number of EXPANSIONS
DWORD m_NumCompression; // number of COMPRESSION locales
DWORD m_NumException; // number of EXCEPTION locales
DWORD m_NumMultiWeight; // number of MULTIPLE WEIGHTS
DWORD m_NumJamoIndex; // Number of entires for Jamo Index Table
DWORD m_NumJamoComposition; // Number of entires for Jamo Composition Table
PREVERSE_DW m_pReverseDW; // ptr to reverse diacritic table
PDBL_COMPRESS m_pDblCompression; // ptr to double compression table
PIDEOGRAPH_LCID m_pIdeographLcid; // ptr to ideograph lcid table
PEXPAND m_pExpansion; // ptr to expansion table
PCOMPRESS_HDR m_pCompressHdr; // ptr to compression table header
PCOMPRESS m_pCompression; // ptr to compression tables
PEXCEPT_HDR m_pExceptHdr; // ptr to exception table header
PEXCEPT m_pException; // ptr to exception tables
PMULTI_WT m_pMultiWeight; // ptr to multiple weights table
BYTE m_SMWeight[NUM_SM]; // script member weights
PJAMO_TABLE m_pJamoIndex; // ptr ot Jamo Index table.
PJAMO_COMPOSE_STATE m_pJamoComposition; // ptr to Jamo Composition state machine table.
private:
void InitializeSortingCache();
void GetSortInformation();
PSORTKEY GetDefaultSortKeyTable(HANDLE *pMapHandle);
PSORTKEY GetExceptionSortKeyTable(
PEXCEPT_HDR pExceptHdr, // ptr to exception header
PEXCEPT pExceptTbl, // ptr to exception table
PVOID pIdeograph, // ptr to ideograph exception table
HANDLE * pMapHandle // ptr to handle map.
);
BOOL FindExceptionPointers(LCID nLcid, PEXCEPT_HDR *ppExceptHdr, PEXCEPT *ppExceptTbl, PVOID *ppIdeograph);
void CopyExceptionInfo(PSORTKEY pSortkey, PEXCEPT_HDR pExceptHdr, PEXCEPT pExceptTbl, PVOID pIdeograph);
void GetSortTablesFileInfo();
private:
static LPCSTR m_lpSortKeyFileName;
static LPCWSTR m_lpSortKeyMappingName;
static LPCSTR m_lpSortTableFileName;
static LPCWSTR m_lpSortTableMappingName;
private:
NativeGlobalizationAssembly* m_pNativeGlobalizationAssembly;
// File handle to the sorting information table "sorttbls.nlp" file.
HANDLE m_hSortTable;
// This is the number of supported language ID today.
static int m_nLangIDCount;
//The array is one larger than the count. Rather than always
//remembering this math, we'll create a variable for it.
static int m_nLangArraySize;
// This table maps the primary language ID to an offset in the m_ppSortingTableCache.
static BYTE m_SortingTableOffset[];
// This table caches the pointer to NativeCompareInfo for every supported lcid.
NativeCompareInfo** m_ppNativeCompareInfoCache;
PSORTKEY m_pDefaultSortKeyTable;
// This points to the sortkey table in sortkey.nlp.
LPWORD m_pSortTable;
};
#endif
| [
"seta7D5@protonmail.com"
] | seta7D5@protonmail.com |
ee74523590e65322202dff007d67a0e6aa0e9256 | 62869fe5152bbe07fbe9f0b61166be32e4f5016c | /3rdparty/CGAL/include/CGAL/Delaunay_triangulation_adaptation_traits_2.h | d7850f190d58dfde1dd739956faefbb43424d7fb | [
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-3.0-or-later",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-commercial-license",
"MIT"
] | permissive | daergoth/SubdivisionSandbox | aef65eab0e1ab3dfecb2f9254c36d26c71ecd4fd | d67386980eb978a552e5a98ba1c4b25cf5a9a328 | refs/heads/master | 2020-03-30T09:19:07.121847 | 2019-01-08T16:42:53 | 2019-01-08T16:42:53 | 151,070,972 | 0 | 0 | MIT | 2018-12-03T11:10:03 | 2018-10-01T10:26:28 | C++ | UTF-8 | C++ | false | false | 1,898 | h | // Copyright (c) 2006 Foundation for Research and Technology-Hellas (Greece).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Menelaos Karavelas <mkaravel@iacm.forth.gr>
#ifndef CGAL_DELAUNAY_TRIANGULATION_ADAPTATION_TRAITS_2_H
#define CGAL_DELAUNAY_TRIANGULATION_ADAPTATION_TRAITS_2_H 1
#include <CGAL/license/Voronoi_diagram_2.h>
#include <CGAL/Voronoi_diagram_2/basic.h>
#include <CGAL/Voronoi_diagram_2/Delaunay_triangulation_nearest_site_2.h>
#include <CGAL/Voronoi_diagram_2/Adaptation_traits_base_2.h>
#include <CGAL/Voronoi_diagram_2/Site_accessors.h>
#include <CGAL/Voronoi_diagram_2/Construct_dual_points.h>
#include <CGAL/Voronoi_diagram_2/Adaptation_traits_functors.h>
namespace CGAL {
template<class DT2>
struct Delaunay_triangulation_adaptation_traits_2
: public CGAL_VORONOI_DIAGRAM_2_INS::Adaptation_traits_base_2
<DT2,
CGAL_VORONOI_DIAGRAM_2_INS::Point_accessor
<typename DT2::Geom_traits::Point_2,DT2,Tag_true>,
CGAL_VORONOI_DIAGRAM_2_INS::Delaunay_triangulation_Voronoi_point_2<DT2>,
CGAL_VORONOI_DIAGRAM_2_INS::Delaunay_triangulation_nearest_site_2<DT2> >
{
typedef typename DT2::Geom_traits::Point_2 Point_2;
typedef Point_2 Site_2;
};
} //namespace CGAL
#endif // CGAL_DELAUNAY_TRIANGULATION_ADAPTATION_TRAITS_2_H
| [
"bodonyiandi94@gmail.com"
] | bodonyiandi94@gmail.com |
db243f48b6229ce2a67ee95c29d1d15aee16f872 | 27ebd7f3cf3bd1d483f8a1d27c3575c720f642e5 | /Think_in_C++/code/C02/Scopy.cpp | 04d772f8f93fc94334e9a3ac2616cc4c9b28f697 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | walte/resourcerepo | a6ad55e907c72811b7aec82be7bfd5c58edecf5c | b8450232a098077965e76eb7134eca894b0a38c6 | refs/heads/master | 2016-09-06T05:35:18.599888 | 2013-11-22T06:43:35 | 2013-11-22T06:43:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 523 | cpp | //: C02:Scopy.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Copy one file to another, a line at a time
#include <string>
#include <fstream>
using namespace std;
int main() {
ifstream in("Scopy.cpp"); // Open for reading
ofstream out("Scopy2.cpp"); // Open for writing
string s;
while(getline(in, s)) // Discards newline char
out << s << "\n"; // ... must add it back
} ///:~
| [
"walther.zhao@gmail.com"
] | walther.zhao@gmail.com |
02820742f6de6c66e19dc89b92539edebe9ebcac | 08017fe9d2506e086fb43693ceb7002ad47026e2 | /examples/sysc/2.3/sc_rvd/main.cpp | a4a53906676aa0b4c7c3f18d69e08b8a04fddcf8 | [
"Apache-2.0"
] | permissive | asr-cst/Parallel-SystemC-Kernel | 2a3af771b911f24c6e671af1a524539f6dfa51cc | 4fcf73fd661f1a2ad031aa9d84d64db44ca622d8 | refs/heads/master | 2020-05-09T13:02:21.035297 | 2019-04-13T06:56:50 | 2019-04-13T06:56:50 | 181,132,892 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,205 | cpp | /*****************************************************************************
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
more contributor license agreements. See the NOTICE file distributed
with this work for additional information regarding copyright ownership.
Accellera licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
*****************************************************************************/
/*****************************************************************************
main.cpp -- This example shows the use of the sc_rvd classes to demonstrate
a communication channel that uses a ready-valid handshake.
Original Author: Andy Goodrich, Forte Design Systems, Inc.
*****************************************************************************/
// $Log: main.cpp,v $
// Revision 1.2 2011/08/15 16:43:24 acg
// Torsten Maehne: changes to remove unused argument warnings.
//
// Revision 1.1 2011/06/14 21:25:39 acg
// Andy Goodrich: moved examples from 2.2.1 potential release.
//
// Revision 1.1 2010/08/20 14:14:01 acg
// Andy Goodrich: new example using a ready-valid handshake for communication.
//
#include "systemc.h"
#include <iomanip>
#include "sc_rvd.h"
#include <omp.h>
#include <iostream>
#include <thread>
using namespace std;
SC_MODULE(DUT0) {
SC_CTOR(DUT0) {
SC_METHOD(method1);
sensitive << e1;
dont_initialize();
SC_METHOD(method2);
sensitive << e2;
dont_initialize();
SC_METHOD(method3);
sensitive << e3;
dont_initialize();
SC_METHOD(method4);
sensitive << m_input4;
dont_initialize();
}
void method1() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m1 = m_input4.read();
m5 = m_input4.read();
}
}
void method2() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m2 = m_input4.read();
m5 = m_input4.read();
}
}
void method3() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
}
void method4() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m4 = m_input4.read();
m5 = m_input4.read();
}
e1.notify();
e2.notify();
e3.notify();
}
sc_in<sc_uint<32> > m_input4;
sc_uint<32> m1, m2, m3, m4, m5;
sc_event e1, e2, e3;
};
SC_MODULE(DUT1) {
SC_CTOR(DUT1) {
SC_METHOD(method1);
sensitive << e1;
dont_initialize();
SC_METHOD(method2);
sensitive << e2;
dont_initialize();
SC_METHOD(method3);
sensitive << e3;
dont_initialize();
SC_METHOD(method4);
sensitive << m_input4;
dont_initialize();
}
void method1() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m1 = m_input4.read();
m5 = m_input4.read();
}
}
void method2() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m2 = m_input4.read();
m5 = m_input4.read();
}
}
void method3() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
}
void method4() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m4 = m_input4.read();
m5 = m_input4.read();
}
e1.notify();
e2.notify();
e3.notify();
}
sc_in<sc_uint<32> > m_input4;
sc_uint<32> m1, m2, m3, m4, m5;
sc_event e1, e2, e3;
};
SC_MODULE(DUT2) {
SC_CTOR(DUT2) {
SC_METHOD(method1);
sensitive << e1;
dont_initialize();
SC_METHOD(method2);
sensitive << e2;
dont_initialize();
SC_METHOD(method3);
sensitive << e3;
dont_initialize();
SC_METHOD(method4);
sensitive << m_input4;
dont_initialize();
}
void method1() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m1 = m_input4.read();
m5 = m_input4.read();
}
}
void method2() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m2 = m_input4.read();
m5 = m_input4.read();
}
}
void method3() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
}
void method4() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m4 = m_input4.read();
m5 = m_input4.read();
}
e1.notify();
e2.notify();
e3.notify();
}
sc_in<sc_uint<32> > m_input4;
sc_uint<32> m1, m2, m3, m4, m5;
sc_event e1, e2, e3;
};
SC_MODULE(DUT3) {
SC_CTOR(DUT3) {
SC_METHOD(method1);
sensitive << e1;
dont_initialize();
SC_METHOD(method2);
sensitive << e2;
dont_initialize();
SC_METHOD(method3);
sensitive << e3;
dont_initialize();
SC_METHOD(method4);
sensitive << m_input4;
dont_initialize();
}
void method1() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m1 = m_input4.read();
m5 = m_input4.read();
}
}
void method2() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m2 = m_input4.read();
m5 = m_input4.read();
}
}
void method3() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
}
void method4() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m4 = m_input4.read();
m5 = m_input4.read();
}
e1.notify();
e2.notify();
e3.notify();
}
sc_in<sc_uint<32> > m_input4;
sc_uint<32> m1, m2, m3, m4, m5;
sc_event e1, e2, e3;
};
SC_MODULE(DUT4) {
SC_CTOR(DUT4) {
SC_METHOD(method1);
sensitive << e1;
dont_initialize();
SC_METHOD(method2);
sensitive << e2;
dont_initialize();
SC_METHOD(method3);
sensitive << e3;
dont_initialize();
SC_METHOD(method4);
sensitive << m_input4;
dont_initialize();
}
void method1() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m1 = m_input4.read();
m5 = m_input4.read();
}
}
void method2() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m2 = m_input4.read();
m5 = m_input4.read();
}
}
void method3() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
}
void method4() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m4 = m_input4.read();
m5 = m_input4.read();
}
e1.notify();
e2.notify();
e3.notify();
}
sc_in<sc_uint<32> > m_input4;
sc_uint<32> m1, m2, m3, m4, m5;
sc_event e1, e2, e3;
};
SC_MODULE(T2) {
SC_CTOR(T2) {
SC_METHOD(method1);
sensitive << e1;
dont_initialize();
SC_METHOD(method2);
sensitive << e2;
dont_initialize();
SC_METHOD(method3);
sensitive << e3;
dont_initialize();
SC_METHOD(method4);
sensitive << m_input4;
dont_initialize();
SC_METHOD(method5);
sensitive << e4;
dont_initialize();
SC_METHOD(method6);
sensitive << e5;
dont_initialize();
}
void method1() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m1 = m_input4.read();
m5 = m_input4.read();
}
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method2() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m2 = m_input4.read();
m5 = m_input4.read();
}
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method3() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method4() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m4 = m_input4.read();
m5 = m_input4.read();
}
e1.notify();
e2.notify();
e3.notify();
e4.notify();
e5.notify();
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method5() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method6() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
sc_in<sc_uint<32> > m_input4;
sc_uint<32> m1, m2, m3, m4, m5;
sc_event e1, e2, e3, e4, e5;
};
SC_MODULE(T3) {
SC_CTOR(T3) {
SC_METHOD(method1);
sensitive << e1;
dont_initialize();
SC_METHOD(method2);
sensitive << e2;
dont_initialize();
SC_METHOD(method3);
sensitive << e3;
dont_initialize();
SC_METHOD(method4);
sensitive << m_input4;
dont_initialize();
SC_METHOD(method5);
sensitive << e4;
dont_initialize();
SC_METHOD(method6);
sensitive << e5;
dont_initialize();
SC_METHOD(method7);
sensitive << e6;
dont_initialize();
}
void method1() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m1 = m_input4.read();
m5 = m_input4.read();
}
e4.notify();
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method2() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m2 = m_input4.read();
m5 = m_input4.read();
}
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method3() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
e1.notify();
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method4() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m4 = m_input4.read();
m5 = m_input4.read();
}
e2.notify();
e3.notify();
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method5() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
e5.notify();
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method6() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
e6.notify();
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
void method7() {
double prod = 1, sum = 1, sop = 1;
for (int i = 1; i < 20000000; i++) {
prod *= (double)i;
sum += (double)i;
sop *= (prod * sum);
sop = ((prod + sum + sop) * sop * sop) / sum;
m3 = m_input4.read();
m5 = m_input4.read();
}
//cout << "thread num in method : " << omp_get_thread_num() << endl;
}
sc_in<sc_uint<32> > m_input4;
sc_uint<32> m1, m2, m3, m4, m5;
sc_event e1, e2, e3, e4, e5, e6;
};
SC_MODULE(TB) {
SC_CTOR(TB) {
SC_METHOD(Method1);
SC_METHOD(Method2);
SC_METHOD(Method3);
}
void Method1() {
m_output1.write(1);
}
void Method2() {
m_output2.write(1);
}
void Method3() {
m_output3.write(1);
}
sc_out<sc_uint<32> >m_output1;
sc_out<sc_uint<32> >m_output2;
sc_out<sc_uint<32> >m_output3;
};
int sc_main(int , char* [])
{
DUT0 d0("d0");
DUT1 d1("d1");
DUT2 d2("d2");
DUT3 d3("d3");
DUT4 d4("d4");
sc_signal<sc_uint<32> > sig0;
sc_signal<sc_uint<32> > sig1;
sc_signal<sc_uint<32> > sig2;
TB tb("tb");
d0.m_input4(sig0);
d1.m_input4(sig0);
d2.m_input4(sig0);
d3.m_input4(sig0);
d4.m_input4(sig0);
tb.m_output1(sig0);
tb.m_output2(sig1);
tb.m_output3(sig2);
T2 t2("t2");
T3 t3("t3");
t2.m_input4(sig1);
t3.m_input4(sig2);
unsigned concurentThreadsSupported = std::thread::hardware_concurrency();
cout << "Number of core : " << omp_get_max_threads() << endl;
omp_set_num_threads(omp_get_max_threads() / 2);
double start_time, end_time;
start_time = omp_get_wtime();
sc_start();
end_time = omp_get_wtime();
cout << "Program completed" << endl;
cout << "Done, Run time : " << end_time - start_time << endl;
return 0;
}
| [
"asrathour1994@gmail.com"
] | asrathour1994@gmail.com |
e637e048c69bdfa5008588764048283927167ac4 | 27cfd532cdda68e5b220fb034d77bad4e0bc8893 | /first/path sum II.cpp | 16492fdd09d3d4af16386cd69ee415e84d8040b4 | [] | no_license | TylerzhangZC/leetcode-2 | ac620e9fd41de748ddda867af127d128e08dcc30 | da089015484d3a87ae3fbdc944c369992b692cbf | refs/heads/master | 2020-12-27T01:42:41.854795 | 2014-10-06T15:56:37 | 2014-10-06T15:56:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,152 | cpp | /**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<vector<int> > pathSum(TreeNode *root, int sum) {
vector<vector<int> > results;
if (root == NULL) {
return results;
}
vector<int> curr;
curr.push_back(root->val);
pathSumRecur(root, sum-root->val, results, curr);
return results;
}
void pathSumRecur(TreeNode *r, int sum, vector<vector<int> >& res, vector<int>& curr) {
if (r->left == NULL && r->right == NULL && sum == 0) {
res.push_back(curr);
} else {
if (r->left != NULL) {
curr.push_back(r->left->val);
pathSumRecur(r->left, sum - r->left->val, res, curr);
curr.pop_back();
}
if (r->right != NULL) {
curr.push_back(r->right->val);
pathSumRecur(r->right, sum - r->right->val, res, curr);
curr.pop_back();
}
}
}
};
| [
"3feng90@gmail.com"
] | 3feng90@gmail.com |
268fea90d0b2c12deea1c1ac01c9742af6b4738c | b45b27637c8e28e82e95111d3dbf455aa772d7b3 | /bin/Reapr_1.0.18/third_party/cmake-2.8.7/Source/CPack/cmCPackOSXX11Generator.cxx | 75ad640c0943bbe4d281b5683f176f3106d0c13e | [
"BSD-3-Clause",
"GPL-3.0-only"
] | permissive | Fu-Yilei/VALET | caa5e1cad5188cbb94418ad843ea32791e50974b | 8741d984056d499af2fd3585467067d1729c73c4 | refs/heads/master | 2020-08-09T12:17:34.989915 | 2019-10-10T05:10:12 | 2019-10-10T05:10:12 | 214,085,217 | 1 | 0 | MIT | 2019-10-10T04:18:34 | 2019-10-10T04:18:34 | null | UTF-8 | C++ | false | false | 11,057 | cxx | /*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "cmCPackOSXX11Generator.h"
#include "cmake.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmSystemTools.h"
#include "cmMakefile.h"
#include "cmGeneratedFileStream.h"
#include "cmCPackLog.h"
#include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx>
#include <sys/stat.h>
//----------------------------------------------------------------------
cmCPackOSXX11Generator::cmCPackOSXX11Generator()
{
}
//----------------------------------------------------------------------
cmCPackOSXX11Generator::~cmCPackOSXX11Generator()
{
}
//----------------------------------------------------------------------
int cmCPackOSXX11Generator::PackageFiles()
{
// TODO: Use toplevel ?
// It is used! Is this an obsolete comment?
const char* cpackPackageExecutables
= this->GetOption("CPACK_PACKAGE_EXECUTABLES");
if ( cpackPackageExecutables )
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
<< cpackPackageExecutables << "." << std::endl);
cmOStringStream str;
cmOStringStream deleteStr;
std::vector<std::string> cpackPackageExecutablesVector;
cmSystemTools::ExpandListArgument(cpackPackageExecutables,
cpackPackageExecutablesVector);
if ( cpackPackageExecutablesVector.size() % 2 != 0 )
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
"<icon name>." << std::endl);
return 0;
}
std::vector<std::string>::iterator it;
for ( it = cpackPackageExecutablesVector.begin();
it != cpackPackageExecutablesVector.end();
++it )
{
std::string cpackExecutableName = *it;
++ it;
this->SetOptionIfNotSet("CPACK_EXECUTABLE_NAME",
cpackExecutableName.c_str());
}
}
// Disk image directories
std::string diskImageDirectory = toplevel;
std::string diskImageBackgroundImageDir
= diskImageDirectory + "/.background";
// App bundle directories
std::string packageDirFileName = toplevel;
packageDirFileName += "/";
packageDirFileName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
packageDirFileName += ".app";
std::string contentsDirectory = packageDirFileName + "/Contents";
std::string resourcesDirectory = contentsDirectory + "/Resources";
std::string appDirectory = contentsDirectory + "/MacOS";
std::string scriptDirectory = resourcesDirectory + "/Scripts";
std::string resourceFileName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
resourceFileName += ".rsrc";
const char* dir = resourcesDirectory.c_str();
const char* appdir = appDirectory.c_str();
const char* scrDir = scriptDirectory.c_str();
const char* contDir = contentsDirectory.c_str();
const char* rsrcFile = resourceFileName.c_str();
const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
if ( iconFile )
{
std::string iconFileName = cmsys::SystemTools::GetFilenameName(
iconFile);
if ( !cmSystemTools::FileExists(iconFile) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: "
<< iconFile << ". Please check CPACK_PACKAGE_ICON setting."
<< std::endl);
return 0;
}
std::string destFileName = resourcesDirectory + "/" + iconFileName;
this->ConfigureFile(iconFile, destFileName.c_str(), true);
this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str());
}
std::string applicationsLinkName = diskImageDirectory + "/Applications";
cmSystemTools::CreateSymlink("/Applications", applicationsLinkName.c_str());
if (
!this->CopyResourcePlistFile("VolumeIcon.icns",
diskImageDirectory.c_str(),
".VolumeIcon.icns", true ) ||
!this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
".DS_Store", true ) ||
!this->CopyResourcePlistFile("background.png",
diskImageBackgroundImageDir.c_str(), "background.png", true ) ||
!this->CopyResourcePlistFile("RuntimeScript", dir) ||
!this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
"Info.plist" ) ||
!this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir,
"main.scpt", true ) ||
!this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir,
rsrcFile, true) ||
!this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
)
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
<< std::endl);
return 0;
}
// Two of the files need to have execute permission, so ensure they do:
std::string runTimeScript = dir;
runTimeScript += "/";
runTimeScript += "RuntimeScript";
std::string appScriptName = appdir;
appScriptName += "/";
appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
mode_t mode;
if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode))
{
mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
cmsys::SystemTools::SetPermissions(runTimeScript.c_str(), mode);
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << runTimeScript
<< " to permission: " << mode << std::endl);
}
if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode))
{
mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
cmsys::SystemTools::SetPermissions(appScriptName.c_str(), mode);
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << appScriptName
<< " to permission: " << mode << std::endl);
}
std::string output;
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/hdiutilOutput.log";
cmOStringStream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \""
<< diskImageDirectory.c_str()
<< "\" \"" << packageFileNames[0] << "\"";
int retVal = 1;
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Compress disk image using command: "
<< dmgCmd.str().c_str() << std::endl);
// since we get random dashboard failures with this one
// try running it more than once
int numTries = 4;
bool res = false;
while(numTries > 0)
{
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
&retVal, 0,
this->GeneratorVerbose, 0);
if(res && retVal)
{
numTries = -1;
}
numTries--;
}
if ( !res || retVal )
{
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
<< dmgCmd.str().c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return 0;
}
return 1;
}
//----------------------------------------------------------------------
int cmCPackOSXX11Generator::InitializeInternal()
{
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"cmCPackOSXX11Generator::Initialize()" << std::endl);
std::vector<std::string> path;
std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false);
if ( pkgPath.empty() )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
<< std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
pkgPath.c_str());
return this->Superclass::InitializeInternal();
}
//----------------------------------------------------------------------
/*
bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name)
{
std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
const char* inFileName = this->GetOption(cpackVar.c_str());
if ( !inFileName )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str()
<< " not specified. It should point to "
<< (name ? name : "(NULL)")
<< ".rtf, " << name
<< ".html, or " << name << ".txt file" << std::endl);
return false;
}
if ( !cmSystemTools::FileExists(inFileName) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
<< (name ? name : "(NULL)")
<< " resource file: " << inFileName << std::endl);
return false;
}
std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
if ( ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt" )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Bad file extension specified: "
<< ext << ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
<< std::endl);
return false;
}
std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
destFileName += "/Resources/";
destFileName += name + ext;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
<< (inFileName ? inFileName : "(NULL)")
<< " to " << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName, destFileName.c_str());
return true;
}
*/
//----------------------------------------------------------------------
bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name,
const char* dir, const char* outputFileName /* = 0 */,
bool copyOnly /* = false */)
{
std::string inFName = "CPack.";
inFName += name;
inFName += ".in";
std::string inFileName = this->FindTemplate(inFName.c_str());
if ( inFileName.empty() )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
<< inFName << std::endl);
return false;
}
if ( !outputFileName )
{
outputFileName = name;
}
std::string destFileName = dir;
destFileName += "/";
destFileName += outputFileName;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
<< inFileName.c_str() << " to " << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly);
return true;
}
//----------------------------------------------------------------------
const char* cmCPackOSXX11Generator::GetPackagingInstallPrefix()
{
this->InstallPrefix = "/";
this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME");
this->InstallPrefix += ".app/Contents/Resources";
return this->InstallPrefix.c_str();
}
| [
"yf20@gho.cs.rice.edu"
] | yf20@gho.cs.rice.edu |
85dae7ac51e6653c79f80915401fc3d68609de79 | fed740701d51c2ca7ce4c5ee660b4d514732f16f | /Interesting Drink.cpp | 3ae846f03ff9c07fd70144a724c5a08408057819 | [] | no_license | ManasviGoyal/Competitive-Programming | ec7eedab26f2959d3028b1341cea373c5ce8f38d | 4a267040ad0e9f484ef8af399d408dd1a35e3f6d | refs/heads/master | 2023-02-01T11:17:17.459720 | 2020-12-20T21:57:54 | 2020-12-20T21:57:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 538 | cpp | #include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define f first
#define sec second
main()
{
lli n,i,a,b,q;
cin>>n;
lli arr[100001]={0};
for(i=0;i<n;i++)
{
cin>>a;
arr[a]++;
}
cin>>q;
for(i=1;i<100001;i++)
{
arr[i] += arr[i-1];
}
for(i=0;i<q;i++)
{
cin>>a;
if(a>=100000)
{
cout<<arr[100000]<<endl;
}
else
{
cout<<arr[a]<<endl;
}
}
}
| [
"isamudri1@gmail.com"
] | isamudri1@gmail.com |
e2fbe4ec94f752ecfe01909dfb4331de9374d167 | 3913c9f90bdc6e753335d4aaa1866832d7b03222 | /HOTEL_ADT/Window.h | ee256592b3a8d137c8abfcc4fc84bb68dc2a2cc0 | [] | no_license | Aazka/CPP_Codes | d092666828eff689c36200e5a912739d76c5bcf6 | 5bca5d45359c1ce4c5f08550c2c0ec0bea795822 | refs/heads/master | 2020-04-26T03:40:46.314885 | 2019-08-22T17:23:25 | 2019-08-22T17:23:25 | 173,275,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 311 | h | #pragma once
#include<iostream>
using namespace std;
class Window
{
int no_of_window;
double height;
public:
Window(void);
Window(int,double);
Window(const Window&);
void set_num_window(int);
void set_H_window(double);
int get_num_window();
double get_H_window();
~Window(void);
};
| [
"noreply@github.com"
] | noreply@github.com |
a4bab941b1f21bc6c966a38451327ecc588b8ee9 | dad577ccaf5dcabd97af99095bf3e796226b56a1 | /ARRAY/C++ program to print common elements in three sorted arrays.cpp | 6e8dc7fd9b8b9c5a86ec9856953d9f312e6f5e96 | [] | no_license | punitsharma1009/geeks-for-geeks-solution | bed38f48d327450f1f79856bd339bfdb6fe0a6d4 | 26d6beedaa0fd4c9767c50773b5b092c00c6d46a | refs/heads/main | 2023-07-22T16:54:11.862838 | 2021-09-02T18:18:00 | 2021-09-02T18:18:00 | 332,165,663 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 796 | cpp |
#include <bits/stdc++.h>
using namespace std;
void findCommon(int ar1[], int ar2[], int ar3[], int n1, int n2, int n3)
{
int i =0, j = 0, k = 0;
while (i < n1 && j < n2 && k < n3)
{
if (ar1[i] == ar2[j] && ar2[j] == ar3[k])
{ cout << ar1[i] << " "; i++; j++; k++; }
else if (ar1[i] < ar2[j])
i++;
else if (ar2[j] < ar3[k])
j++;
else
k++;
}
}
int main()
{
int ar1[] = {21, 54, 65, 75, 854};
int ar2[] = {21, 54, 75};
int ar3[] = {20, 21, 54};
int n1 = sizeof(ar1)/sizeof(ar1[0]);
int n2 = sizeof(ar2)/sizeof(ar2[0]);
int n3 = sizeof(ar3)/sizeof(ar3[0]);
cout << "common element are ";
findCommon(ar1,ar2,ar3,n1,n2,n3);
return 0;
}
| [
"paras77295@gmail.com"
] | paras77295@gmail.com |
f670c9494df193660eaa227e912ab63a74e9091d | 968df5af7eb8ff5e8509107e89a4557d867463e7 | /main/mainwindow.cpp | b00a9a84f3f7ac7f486a34b6ed5086b6a99706d1 | [] | no_license | AidanPryde/SWR_MapEditor | 3e4ec020fd042da387be24253a903f630ac6e6d8 | 3d36d027f4dd0f2234e1a6f371dac32aec804430 | refs/heads/master | 2020-07-03T11:39:05.196227 | 2015-05-17T05:47:25 | 2015-05-17T05:47:25 | 35,753,573 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,312 | cpp | #include "main\mainwindow.h"
#include "view\viewnewmapdialog.h"
#include "main\global.h"
#include <QMenuBar>
#include <QSettings>
#include <QFileDialog>
#include <QMessageBox>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
MenuFile(tr("&File"), menuBar()),
MenuNew(tr("&New"), &MenuFile),
ActionNewMap(tr("&Map"), &MenuNew),
ActionNewGalaxy(tr("&Galaxy"), &MenuNew),
MenuOpen(tr("&Open"), &MenuFile),
ActionOpenMap(tr("&Map"), &MenuOpen),
ActionOpenGalaxy(tr("&Galaxy"), &MenuOpen),
MenuOpenRecent(tr("&Open Recent"), &MenuFile),
ActionSaveMap(tr("&Save ..."), &MenuFile),
ActionSaveMapAs(tr("&Save ... As"), &MenuFile),
ActionSaveAllMap(tr("&Save All"), &MenuFile),
ActionCloseMap(tr("&Close ..."), &MenuFile),
ActionCloseAllMap(tr("&Close All"), &MenuFile),
ActionExit(tr("&Exit"), &MenuFile),
MenuEdit(tr("&Edit"), menuBar()),
ActionUndo(tr("&Undo"), &MenuEdit),
ActionRedo(tr("&Redo"), &MenuEdit),
ActionCut(tr("&Cut"), &MenuEdit),
ActionCopy(tr("&Copy"), &MenuEdit),
ActionPaste(tr("&Paste"), &MenuEdit),
ActionSelectAll(tr("&Select All"), &MenuEdit),
ActionSearch(tr("&Search"), &MenuEdit),
MenuTools(tr("&Tools"), menuBar()),
MenuGetToolBar(tr("&Tool Bars"), menuBar()),
ActionMapToolBar(tr("&Common Tool Bar"), &MenuGetToolBar),
ActionGalaxyToolBar(tr("&Galaxy Tool Bar"), &MenuGetToolBar),
ActionOption(tr("&Options"), &MenuTools),
MenuHelp(tr("&Help"), menuBar()),
ActionInfo(tr("&Information"), &MenuHelp),
ActionReportBug(tr("&Report Bug"), &MenuHelp),
ActionAboutMapEditor(tr("&About Map Editor"), &MenuHelp),
ActionAboutQT(tr("&About QT"), &MenuHelp)/*,
MapGraphicsView(nullptr),
MapGraphicsScene(nullptr),
MapToolsDockWidget(nullptr)*/
{
this->setWindowFlags(Qt::Window);
this->setWindowTitle(tr("My Game Map Editor"));
LoadGlobalVariables();
if(GLOBAL_VARS::MainWindowIsMaximized)
{
setWindowState(Qt::WindowMaximized);
}
else
{
this->setGeometry(GLOBAL_VARS::MainWindowX, GLOBAL_VARS::MainWindowY, GLOBAL_VARS::MainWindowWidth, GLOBAL_VARS::MainWindowHeight);
}
this->menuBar()->addMenu(&MenuFile);
MenuFile.addMenu(&MenuNew);
MenuNew.addAction(&ActionNewMap);
connect(&ActionNewMap, SIGNAL(triggered()), this, SLOT(ActionNewMapClicked()));
MenuNew.addAction(&ActionNewGalaxy);
connect(&ActionNewGalaxy, SIGNAL(triggered()), this, SLOT(ActionNewGalaxyClicked()));
MenuFile.addSeparator();
MenuFile.addMenu(&MenuOpen);
MenuOpen.addAction(&ActionOpenMap);
connect(&ActionOpenMap, SIGNAL(triggered()), this, SLOT(ActionOpenMapClicked()));
MenuOpen.addAction(&ActionOpenGalaxy);
connect(&ActionOpenGalaxy, SIGNAL(triggered()), this, SLOT(ActionOpenGalaxyClicked()));
MenuFile.addMenu(&MenuOpenRecent);
if(listActionsOpenRecent.isEmpty()) { MenuOpenRecent.setDisabled(true); }
MenuOpenRecent.addActions(listActionsOpenRecent);
MenuFile.addSeparator();
MenuFile.addAction(&ActionSaveMap);
connect(&ActionSaveMap, SIGNAL(triggered()), this, SLOT(ActionSaveMapClicked()));
ActionSaveMap.setDisabled(true);
MenuFile.addAction(&ActionSaveMapAs);
connect(&ActionSaveMap, SIGNAL(triggered()), this, SLOT(ActionSaveMapClicked()));
ActionSaveMapAs.setDisabled(true);
MenuFile.addAction(&ActionSaveAllMap);
connect(&ActionSaveAllMap, SIGNAL(triggered()), this, SLOT(ActionSaveAllMapClicked()));
ActionSaveAllMap.setDisabled(true);
MenuFile.addSeparator();
MenuFile.addAction(&ActionCloseMap);
connect(&ActionCloseMap, SIGNAL(triggered()), this, SLOT(ActionCloseMapClicked()));
ActionCloseMap.setDisabled(true);
MenuFile.addAction(&ActionCloseAllMap);
connect(&ActionCloseAllMap, SIGNAL(triggered()), this, SLOT(ActionCloseAllMapClicked()));
ActionCloseAllMap.setDisabled(true);
MenuFile.addSeparator();
MenuFile.addAction(&ActionExit);
connect(&ActionExit, SIGNAL(triggered()), this, SLOT(ActionExitClicked()));
this->menuBar()->addMenu(&MenuEdit);
MenuEdit.addAction(&ActionUndo);
connect(&ActionUndo, SIGNAL(triggered()), this, SLOT(ActionUndoClicked()));
ActionUndo.setDisabled(true);
MenuEdit.addAction(&ActionRedo);
connect(&ActionRedo, SIGNAL(triggered()), this, SLOT(ActionRedoClicked()));
ActionRedo.setDisabled(true);
MenuEdit.addSeparator();
MenuEdit.addAction(&ActionCut);
connect(&ActionCut, SIGNAL(triggered()), this, SLOT(ActionCutClicked()));
ActionCut.setDisabled(true);
MenuEdit.addAction(&ActionCopy);
connect(&ActionCopy, SIGNAL(triggered()), this, SLOT(ActionCopyClicked()));
ActionCopy.setDisabled(true);
MenuEdit.addAction(&ActionPaste);
connect(&ActionPaste, SIGNAL(triggered()), this, SLOT(ActionPasteClicked()));
ActionPaste.setDisabled(true);
MenuEdit.addSeparator();
MenuEdit.addAction(&ActionSelectAll);
connect(&ActionSelectAll, SIGNAL(triggered()), this, SLOT(ActionSelectAllClicked()));
ActionSelectAll.setDisabled(true);
MenuEdit.addSeparator();
MenuEdit.addAction(&ActionSearch);
connect(&ActionSearch, SIGNAL(triggered()), this, SLOT(ActionSearchClicked()));
ActionSearch.setDisabled(true);
this->menuBar()->addMenu(&MenuTools);
MenuTools.addMenu(&MenuGetToolBar);
MenuGetToolBar.addAction(&ActionMapToolBar);
ActionMapToolBar.setDisabled(true);
connect(&ActionMapToolBar, SIGNAL(triggered()), this, SLOT(ActionMapToolBarClicked()));
MenuGetToolBar.addAction(&ActionGalaxyToolBar);
ActionGalaxyToolBar.setDisabled(true);
connect(&ActionGalaxyToolBar, SIGNAL(triggered()), this, SLOT(ActionGalaxyToolBarClicked()));
MenuTools.addSeparator();
MenuTools.addAction(&ActionOption);
connect(&ActionOption, SIGNAL(triggered()), this, SLOT(ActionOptionClicked()));
this->menuBar()->addMenu(&MenuHelp);
MenuHelp.addAction(&ActionInfo);
connect(&ActionInfo, SIGNAL(triggered()), this, SLOT(ActionInfoClicked()));
MenuHelp.addSeparator();
MenuHelp.addAction(&ActionReportBug);
connect(&ActionReportBug, SIGNAL(triggered()), this, SLOT(ActionReportBugClicked()));
MenuHelp.addSeparator();
MenuHelp.addAction(&ActionAboutMapEditor);
connect(&ActionAboutMapEditor, SIGNAL(triggered()), this, SLOT(ActionAboutMapEditorClicked()));
MenuHelp.addAction(&ActionAboutQT);
connect(&ActionAboutQT, SIGNAL(triggered()), this, SLOT(ActionAboutQTClicked()));
}
MainWindow::~MainWindow()
{
if(this->isMaximized())
{
GLOBAL_VARS::MainWindowIsMaximized = true;
}
else
{
GLOBAL_VARS::MainWindowIsMaximized = false;
Q_ASSERT(this->geometry().x() > -1 || this->geometry().x() < 65537);
GLOBAL_VARS::MainWindowX = static_cast<INT16U>(this->geometry().x());
Q_ASSERT(this->geometry().y() > -1 || this->geometry().y() < 65537);
GLOBAL_VARS::MainWindowY = static_cast<INT16U>(this->geometry().y());
Q_ASSERT(this->geometry().width() > -1 || this->geometry().x() < 65537);
GLOBAL_VARS::MainWindowWidth = static_cast<INT16U>(this->geometry().width());
Q_ASSERT(this->geometry().height() > -1 || this->geometry().y() < 65537);
GLOBAL_VARS::MainWindowHeight = static_cast<INT16U>(this->geometry().height());
}
SaveGlobalVariables();
}
void MainWindow::LoadGlobalVariables()
{
editorSettings = new QSettings(QSettings::NativeFormat, GLOBAL_CONSTS::Scope, GLOBAL_CONSTS::Organization, GLOBAL_CONSTS::Application, nullptr);
GLOBAL_VARS::MapDefaultDirectory = editorSettings->value("mapdefaultdirectory", GLOBAL_CONSTS::ProgramHomeDirectory).toString();
GLOBAL_VARS::ScaleFactorIn = editorSettings->value("scalefactorin", 1.15).toDouble();
GLOBAL_VARS::ScaleFactorOut = 1.0 / GLOBAL_VARS::ScaleFactorIn;
Q_ASSERT(editorSettings->value("mycommontoolsdockwidgetarea", Qt::RightDockWidgetArea).toInt() > -1 || editorSettings->value("mycommontoolsdockwidgetarea", Qt::RightDockWidgetArea).toInt() < 16);
GLOBAL_VARS::MyCommonToolsDockWidgetArea = static_cast<Qt::DockWidgetArea>(editorSettings->value("mycommontoolsdockwidgetarea", Qt::RightDockWidgetArea).toInt());
if(GLOBAL_VARS::MyCommonToolsDockWidgetArea == Qt::NoDockWidgetArea)
{
Q_ASSERT(editorSettings->value("mycommontoolsdockwidgetareax", 0).toInt() > -1 || editorSettings->value("mycommontoolsdockwidgetareax", 0).toInt() < 65537);
GLOBAL_VARS::MyCommonToolsDockWidgetAreaX = static_cast<INT16U>(editorSettings->value("mycommontoolsdockwidgetareax", 0).toInt());
Q_ASSERT(editorSettings->value("mycommontoolsdockwidgetareay", 0).toInt() > -1 || editorSettings->value("mycommontoolsdockwidgetareay", 0).toInt() < 65537);
GLOBAL_VARS::MyCommonToolsDockWidgetAreaY = static_cast<INT16U>(editorSettings->value("mycommontoolsdockwidgetareay", 0).toInt());
}
GLOBAL_VARS::MainWindowIsMaximized = editorSettings->value("mainwindowismaximized", true).toBool();
if(!GLOBAL_VARS::MainWindowIsMaximized)
{
Q_ASSERT(editorSettings->value("mainwindowx", 0).toInt() > -1 || editorSettings->value("mainwindowx", 0).toInt() < 65537);
GLOBAL_VARS::MainWindowX = static_cast<INT16U>(editorSettings->value("mainwindowx", 0).toInt());
Q_ASSERT(editorSettings->value("mainwindowy", 0).toInt() > -1 || editorSettings->value("mainwindowy", 0).toInt() < 65537);
GLOBAL_VARS::MainWindowY = static_cast<INT16U>(editorSettings->value("mainwindowy", 0).toInt());
Q_ASSERT(editorSettings->value("mainwindowwidth", 600).toInt() > -1 || editorSettings->value("mainwindowwidth", 600).toInt() < 65537);
GLOBAL_VARS::MainWindowWidth = static_cast<INT16U>(editorSettings->value("mainwindowwidth", 600).toInt());
Q_ASSERT(editorSettings->value("mainwindowheight", 400).toInt() > -1 || editorSettings->value("mainwindowheight", 400).toInt() < 65537);
GLOBAL_VARS::MainWindowHeight = static_cast<INT16U>(editorSettings->value("mainwindowheight", 400).toInt());
}
}
void MainWindow::ActionNewMapClicked()
{
ViewNewMapDialog newMapDialog(this);
if(newMapDialog.exec() == QDialog::Accepted)
{
QFile* currentOpenMapFile = newMapDialog.GetFile();
//create default gameLOGIC
currentLogicMap = new LogicMap(currentOpenMapFile);
QVBoxLayout * VBLayout = new QVBoxLayout();
QHBoxLayout * HBLayout = new QHBoxLayout();
QHBoxLayout * HBLayout_2 = new QHBoxLayout();
QPushButton * PButton_1 = new QPushButton("scene +10");
QPushButton * PButton_2 = new QPushButton("scene -10");
QPushButton * PButton_3 = new QPushButton("view min +10");
QPushButton * PButton_4 = new QPushButton("view min -10");
QPushButton * PButton_5 = new QPushButton("view max +10");
QPushButton * PButton_6 = new QPushButton("view max -10");
GraphicsView = new ViewGraphicsView(this);
GraphicsScene = new ViewGraphicsScene(this);
GraphicsView->setScene(GraphicsScene);
HBLayout->addWidget(PButton_1);
//connect(PButton_1, SIGNAL(clicked()), MapGraphicsScene, SLOT(debug_1()));
HBLayout->addWidget(PButton_2);
//connect(PButton_2, SIGNAL(clicked()), MapGraphicsScene, SLOT(debug_2()));
HBLayout->addWidget(PButton_3);
//connect(PButton_3, SIGNAL(clicked()), MapGraphicsView, SLOT(debug_1()));
HBLayout->addWidget(PButton_4);
//connect(PButton_4, SIGNAL(clicked()), MapGraphicsView, SLOT(debug_2()));
HBLayout->addWidget(PButton_5);
//connect(PButton_5, SIGNAL(clicked()), MapGraphicsView, SLOT(debug_3()));
HBLayout->addWidget(PButton_6);
//connect(PButton_6, SIGNAL(clicked()), MapGraphicsView, SLOT(debug_4()));
QLineEdit * lEdit1 = new QLineEdit();
//connect(MapGraphicsView, SIGNAL(debug_signal(QString)), lEdit1, SLOT(setText(QString)));
QLineEdit * lEdit2 = new QLineEdit();
//connect(MapGraphicsScene, SIGNAL(debug_signal(QString)), lEdit2, SLOT(setText(QString)));
HBLayout_2->addWidget(lEdit1);
HBLayout_2->addWidget(lEdit2);
VBLayout->addLayout(HBLayout);
VBLayout->addLayout(HBLayout_2);
VBLayout->addWidget(GraphicsView);
QWidget * QCWidget = new QWidget(this);
QCWidget->setLayout(VBLayout);
setCentralWidget(QCWidget);
/*if(MapToolsDockWidget == nullptr)
{
MapToolsDockWidget = new MyMapToolsDockWidget(MapGraphicsView, this);
}
MapToolsDockWidget->show();*/
}
}
void MainWindow::ActionNewGalaxyClicked()
{
}
void MainWindow::ActionOpenMapClicked()
{
//TODO Is there opened map? y-> Is everything saved? n-> Do we want to save all of it?
QString fileNamePath = QFileDialog::getOpenFileName(this,
tr("Open map ..."),
GLOBAL_VARS::MapDefaultDirectory,
tr("Map (*.mm)"));
QFile* currentOpenMapFile = new QFile(fileNamePath);
if(currentOpenMapFile->open(QIODevice::ReadWrite))
{
//load gameLOGIC
}
else
{
QMessageBox::warning(this,
tr("Worning ..."),
tr("The file '%1' can not be opened.").arg(fileNamePath));
}
}
void MainWindow::ActionOpenGalaxyClicked()
{
}
void MainWindow::ActionOpenRecentClicked()
{
}
void MainWindow::ActionSaveMapClicked()
{
}
void MainWindow::ActionSaveMapAsClicked()
{
}
void MainWindow::ActionSaveAllMapClicked()
{
}
void MainWindow::ActionCloseMapClicked()
{
}
void MainWindow::ActionCloseAllMapClicked()
{
}
void MainWindow::ActionExitClicked()
{
//TODO Is evrything saved?
close();
}
void MainWindow::ActionUndoClicked()
{
}
void MainWindow::ActionRedoClicked()
{
}
void MainWindow::ActionCutClicked()
{
}
void MainWindow::ActionCopyClicked()
{
}
void MainWindow::ActionPasteClicked()
{
}
void MainWindow::ActionSelectAllClicked()
{
}
void MainWindow::ActionSearchClicked()
{
}
void MainWindow::ActionGalaxyToolBarClicked()
{
}
void MainWindow::ActionMapToolBarClicked()
{
}
void MainWindow::ActionOptionClicked()
{
}
void MainWindow::ActionInfoClicked()
{
}
void MainWindow::ActionReportBugClicked()
{
}
void MainWindow::ActionAboutMapEditorClicked()
{
}
void MainWindow::ActionAboutQTClicked()
{
QMessageBox::aboutQt(this, tr("About QT ..."));
}
void MainWindow::SaveGlobalVariables()
{
editorSettings->setValue("mapdefaultdirectory", GLOBAL_VARS::MapDefaultDirectory);
editorSettings->setValue("scalefactorin", GLOBAL_VARS::ScaleFactorIn);
editorSettings->setValue("mycommontoolsdockwidgetarea", GLOBAL_VARS::MyCommonToolsDockWidgetArea);
editorSettings->setValue("mycommontoolsdockwidgetareax", GLOBAL_VARS::MyCommonToolsDockWidgetAreaX);
editorSettings->setValue("mycommontoolsdockwidgetareay", GLOBAL_VARS::MyCommonToolsDockWidgetAreaY);
editorSettings->setValue("mainwindowismaximized", GLOBAL_VARS::MainWindowIsMaximized);
editorSettings->setValue("mainwindowx", GLOBAL_VARS::MainWindowX);
editorSettings->setValue("mainwindowy", GLOBAL_VARS::MainWindowY);
editorSettings->setValue("mainwindowwidth", GLOBAL_VARS::MainWindowWidth);
editorSettings->setValue("mainwindowheight", GLOBAL_VARS::MainWindowHeight);
}
| [
"peskomarton@hotmail.com"
] | peskomarton@hotmail.com |
e9242d2a5e590558898517c5373a4568e9e594b9 | ea273a0d5a4f56a1da8b6366e8e1e3712a9efd47 | /Source/Renderer/Public/Resource/Scene/Culling/SceneItemSet.h | 35c71f82fd33a833cba298ec9a5421702589a381 | [
"MIT"
] | permissive | cofenberg/unrimp | c31eb36ebde09db70173a154be518925ba192d9a | 3d4717d0742a5bc466321905278e0110330df070 | refs/heads/master | 2022-05-27T05:20:48.463362 | 2022-05-21T08:15:15 | 2022-05-21T08:15:15 | 7,425,818 | 213 | 22 | null | null | null | null | UTF-8 | C++ | false | false | 7,310 | h | /*********************************************************\
* Copyright (c) 2012-2022 The Unrimp Team
*
* 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.
\*********************************************************/
//[-------------------------------------------------------]
//[ Header guard ]
//[-------------------------------------------------------]
#pragma once
//[-------------------------------------------------------]
//[ Includes ]
//[-------------------------------------------------------]
// Disable warnings in external headers, we can't fix them
PRAGMA_WARNING_PUSH
PRAGMA_WARNING_DISABLE_MSVC(4100) // warning C4100: 'address': unreferenced formal parameter
PRAGMA_WARNING_DISABLE_MSVC(4242) // warning C4242: '=': conversion from 'int' to 'T', possible loss of data
PRAGMA_WARNING_DISABLE_MSVC(4244) // warning C4244: '=': conversion from 'int' to 'T', possible loss of data
PRAGMA_WARNING_DISABLE_MSVC(4324) // warning C4324: 'xsimd::hadd::<unnamed-tag>': structure was padded due to alignment specifier
PRAGMA_WARNING_DISABLE_MSVC(4365) // warning C4365: '=': conversion from 'uint32_t' to 'int32_t', signed/unsigned mismatch
PRAGMA_WARNING_DISABLE_MSVC(4464) // warning C4464: relative include path contains '..'
PRAGMA_WARNING_DISABLE_MSVC(4505) // warning C4505: 'xsimd::detail::__ieee754_rem_pio2': unreferenced local function has been removed
PRAGMA_WARNING_DISABLE_MSVC(4530) // warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
PRAGMA_WARNING_DISABLE_MSVC(4625) // warning C4625: 'std::codecvt_base': copy constructor was implicitly defined as deleted
PRAGMA_WARNING_DISABLE_MSVC(4626) // warning C4626: 'std::codecvt_base': assignment operator was implicitly defined as deleted
PRAGMA_WARNING_DISABLE_MSVC(4774) // warning C4774: 'sprintf_s' : format string expected in argument 3 is not a string literal
PRAGMA_WARNING_DISABLE_MSVC(5026) // warning C5026: 'std::_Generic_error_category': move constructor was implicitly defined as deleted
PRAGMA_WARNING_DISABLE_MSVC(5027) // warning C5027: 'std::_Generic_error_category': move assignment operator was implicitly defined as deleted
PRAGMA_WARNING_DISABLE_MSVC(5219) // warning C5219: implicit conversion from 'const int' to 'const _Ty', possible loss of data
#define XSIMD_INSTR_SET_NOT_AVAILABLE 0 // warning C4668: 'XSIMD_INSTR_SET_NOT_AVAILABLE' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
#define XSIMD_FORCE_X86_INSTR_SET XSIMD_X86_SSE4_2_VERSION // TODO(co) How to use xsimd correctly to get rid of errors like "error C2440: 'initializing': cannot convert from 'xsimd::simd_batch_traits<xsimd::batch<float,8>>::batch_bool_type' to 'xsimd::batch_bool<float,4>'" when using "Advanced Vector Extensions 2 (/arch:AVX2)"?
#include <xsimd/xsimd.hpp>
PRAGMA_WARNING_POP
#include <vector>
//[-------------------------------------------------------]
//[ Forward declarations ]
//[-------------------------------------------------------]
namespace Renderer
{
class ISceneItem;
}
//[-------------------------------------------------------]
//[ Namespace ]
//[-------------------------------------------------------]
namespace Renderer
{
//[-------------------------------------------------------]
//[ Classes ]
//[-------------------------------------------------------]
/**
* @brief
* Scene item set
*
* @note
* - Basing on "The Implementation of Frustum Culling in Stingray" - http://bitsquid.blogspot.de/2016/10/the-implementation-of-frustum-culling.html
*/
struct SceneItemSet final
{
//[-------------------------------------------------------]
//[ Public definitions ]
//[-------------------------------------------------------]
typedef std::vector<float, xsimd::aligned_allocator<float, XSIMD_DEFAULT_ALIGNMENT>> FloatVector;
typedef std::vector<double, xsimd::aligned_allocator<double, XSIMD_DEFAULT_ALIGNMENT>> DoubleVector;
typedef std::vector<uint32_t, xsimd::aligned_allocator<uint32_t, XSIMD_DEFAULT_ALIGNMENT>> IntegerVector;
typedef std::vector<ISceneItem*, xsimd::aligned_allocator<ISceneItem*, XSIMD_DEFAULT_ALIGNMENT>> SceneItemVector; // TODO(co) No raw pointers here (no smart pointers either, handles please)
//[-------------------------------------------------------]
//[ Public data ]
//[-------------------------------------------------------]
// Minimum object space bounding box corner position
FloatVector minimumX;
FloatVector minimumY;
FloatVector minimumZ;
// Maximum object space bounding box corner position
FloatVector maximumX;
FloatVector maximumY;
FloatVector maximumZ;
// Object space to world space matrix
// TODO(co) Add 64 bit world space position support
FloatVector worldXX;
FloatVector worldXY;
FloatVector worldXZ;
FloatVector worldXW;
FloatVector worldYX;
FloatVector worldYY;
FloatVector worldYZ;
FloatVector worldYW;
FloatVector worldZX;
FloatVector worldZY;
FloatVector worldZZ;
FloatVector worldZW;
FloatVector worldWX;
FloatVector worldWY;
FloatVector worldWZ;
FloatVector worldWW;
// 32 bit world space position center of bounding sphere (the bounding sphere isn't always at the object center, so we need to store this beside the transform position)
// TODO(co) Add 64 bit world space position support
FloatVector spherePositionX;
FloatVector spherePositionY;
FloatVector spherePositionZ;
// Negative world space radius of bounding sphere, the bounding sphere radius is enclosing the bounding box (don't use the inner bounding box radius)
FloatVector negativeRadius;
// Flag to indicate if an object is culled or not
IntegerVector visibilityFlag;
// The type and ID of an object
SceneItemVector sceneItemVector;
uint32_t numberOfSceneItems = 0;
};
//[-------------------------------------------------------]
//[ Namespace ]
//[-------------------------------------------------------]
} // Renderer
| [
"cofenberg@gmail.com"
] | cofenberg@gmail.com |
2a46956c588445554557581eebf86baf86760b30 | 8e911106b96b472b5bc7e667a67f4ee7a3454a5b | /MPU_6050/role pitch and yaw.cpp | f656a0343481bccf872ebb22ab1a7262d1465d0d | [] | no_license | abhipray-cpu/arduino | a6640938f02853198537c22a14165cc7b7dbee94 | b534b39ca880e623c03705f202c3bc442aa86260 | refs/heads/main | 2023-07-17T01:45:48.346694 | 2021-08-18T15:24:13 | 2021-08-18T15:24:13 | 377,536,897 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,295 | cpp | //pitch role and yaw using gyroscope
#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
// Timers
unsigned long timer = 0;
float timeStep = 0.01;
// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;
void setup()
{
Serial.begin(9600);
// Initialize MPU6050
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
{
Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
delay(500);
}
// Calibrate gyroscope. The calibration must be at rest.
// If you don't want calibrate, comment this line.
mpu.calibrateGyro();
// Set threshold sensivty. Default 3.
// If you don't want use threshold, comment this line or set 0.
// mpu.setThreshold(3);
}
void loop()
{
timer = millis();
// Read normalized values
Vector norm = mpu.readNormalizeGyro();
// Calculate Pitch, Roll and Yaw
pitch = pitch + norm.YAxis * timeStep;
roll = roll + norm.XAxis * timeStep;
yaw = yaw + norm.ZAxis * timeStep;
// Output raw
Serial.print(" Pitch = ");
Serial.print(pitch);
Serial.print(" Roll = ");
Serial.print(roll);
Serial.print(" Yaw = ");
Serial.println(yaw);
// Wait to full timeStep period
delay((timeStep*1000) - (millis() - timer));
} | [
"dumkaabhipray@gmail.com"
] | dumkaabhipray@gmail.com |
f88c1878a209089869bbc0947fd986b17d253466 | bee393b9923036a5f286c9982fa2afa29a783a9b | /ball_reaching/src/cylindrical-cubic-interpolation.cc | bb59b238c5f3d4dbd96f60f9a9aca1cde7446e07 | [] | no_license | stack-of-tasks/redundant_manipulator_control_tutorial | 6a01747de33cbec33110e941dd2829d6a9131ecd | 20611461e0c2b163675f2a9f66aeba5c56ea0d80 | refs/heads/master | 2020-05-16T05:17:21.868587 | 2012-05-29T14:15:33 | 2012-05-29T14:17:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,092 | cc | //
// Copyright (C) 2012 LAAS-CNRS
//
// Author: Florent Lamiraux
//
#include <dynamic-graph/command.h>
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/factory.h>
#include "cylindrical-cubic-interpolation.hh"
namespace dynamicgraph {
namespace sot {
namespace reaching {
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CylindricalCubicInterpolationSE3,
"CylindricalCubicInterpolationSE3");
CylindricalCubicInterpolationSE3::
CylindricalCubicInterpolationSE3 (const std::string& name) :
CubicInterpolationSE3 (name),
localFrameSIN_ (NULL, "CylindricalCubicInterpolationSE3("+name+
")::input(MatrixHomo)::localFrame"),
globalPos_ (3)
{
signalRegistration (localFrameSIN_);
referenceSOUT_.setFunction (boost::bind (&CylindricalCubicInterpolationSE3::
computeReference,
this, _1, _2));
initialChestPose_.setIdentity ();
}
CylindricalCubicInterpolationSE3::~CylindricalCubicInterpolationSE3 ()
{
}
std::string CylindricalCubicInterpolationSE3::getDocString () const
{
std::string doc =
"Perform a cubic interpolation in cylindrical coordinate in SE(3).\n"
"\n"
" Initial pose is given by signal 'init', Target position is given"
" by signal\n"
" 'goal'. Interpolation is performed with zero velocities at start"
" and goal\n"
" positions.\n"
" Initial and goal poses are expressed in cylindrical coordinate in"
" frame given\n"
" by signal 'localFrame' at beginning of motion.\n"
"\n"
" This entity is aimed at performing reaching motion about the robot"
" chest.\n"
"\n";
return doc;
}
sot::MatrixHomogeneous&
CylindricalCubicInterpolationSE3::computeReference (sot::MatrixHomogeneous&
reference, const int& time)
{
if (!motionStarted_) {
reference = initSIN_ (time);
} else {
double t = (time - startTime_) * samplingPeriod_;
if (t <= duration_) {
cylindricalCoord_ = p0_ + (p1_ + (p2_ + p3_*t)*t)*t;
position_ (0) = cylindricalCoord_ (0) * cos (cylindricalCoord_ (1));
position_ (1) = cylindricalCoord_ (0) * sin (cylindricalCoord_ (1));
position_ (2) = cylindricalCoord_ (2);
initialChestPose_.multiply (position_, globalPos_);
reference (0,3) = globalPos_ (0);
reference (1,3) = globalPos_ (1);
reference (2,3) = globalPos_ (2);
} else {
motionStarted_ = false;
errorDot_.setZero ();
errorDotSOUT_.setConstant (errorDot_);
reference = goalSIN_ (time);
}
}
return reference;
}
void CylindricalCubicInterpolationSE3::doStart (const double& duration)
{
// Check that sampling period has been initialized
if (samplingPeriod_ <= 0)
throw ExceptionSignal (ExceptionSignal::NOT_INITIALIZED,
"CylindricalCubicSE3: samplingPeriod should"
" be positive. Are you sure you did\n"
"initialize it?");
int time = initSIN_.getTime ();
if (!motionStarted_) {
duration_ = duration;
startTime_ = referenceSOUT_.getTime ();
double T = duration;
// Express initial pose in cylindrical coordinate
initialChestPose_ = localFrameSIN_ (time);
inv_ = initialChestPose_.inverse ();
localPose_ = inv_ * initSIN_ (time);
double x = localPose_ (0,3);
double y = localPose_ (1,3);
double z = localPose_ (2,3);
// Initial position expressed in cylindrical coordinates
p0_ (0) = sqrt (x*x+y*y);
p0_ (1) = atan2 (y,x);
p0_ (2) = z;
// Initial velocity
p1_ (0) = 0.;
p1_ (1) = 0.;
p2_ (2) = 0.;
// Goal position expressed in cylindrical coordinates
localPose_ = inv_ * goalSIN_ (time);
x = localPose_ (0,3);
y = localPose_ (1,3);
z = localPose_ (2,3);
maal::boost::Vector P_T (3);
P_T (0) = sqrt (x*x+y*y);
P_T (1) = atan2 (y,x);
P_T (2) = z;
// Final velocity
maal::boost::Vector D_T (3); D_T.setZero ();
p2_ = (D_T + p1_*2)*(-1./T) + (P_T - p0_)*(3./(T*T));
p3_ = (P_T -p0_)*(-2/(T*T*T)) + (p1_ + D_T)*(1./(T*T));
motionStarted_ = true;
}
}
} // reaching
} // namespace sot
} // namespace dynamicgraph
| [
"florent@laas.fr"
] | florent@laas.fr |
374b0be8a3485e8bf5ba2506a15e823fcb13991d | 74e1fb89b8170c8b8a5f613aa6381f7f4cf2abc4 | /pa1/student.cpp | 41f589d9dd24d2df600cd9fb0488da95e31c0de6 | [] | no_license | nuts4nuts4nuts/CSI281 | e33b3cf8040ae2eb82f215a1c0101fed31da56c1 | cb67cd81a6e4cf4469058cda78bc6dcde8a737a5 | refs/heads/master | 2016-09-15T23:03:50.227229 | 2013-11-07T17:25:23 | 2013-11-07T17:25:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,282 | cpp | /*Author: David Johnston
Class: CSI-281-01
Assignment: pa 1
Date Assigned: 8/27/13
Due Date: 9/3/13 - 12:30
Description: The purpose of this program is to act as a database for storing information about students and faculty.
Certification of Authenticity:
I certify that this assignment is entirely my own work.*/
#include <iostream>
#include <iomanip>
#include "student.h"
Student::Student()
{
}
Student::Student(string id, Name name, Address address, string phoneNumber, string major, double gpa)
:Person(id, name, address, phoneNumber)
{
mMajor = major;
mGpa = gpa;
}
Student::~Student()
{
}
double Student::getGpa()
{
return mGpa;
}
string Student::getMajor()
{
return mMajor;
}
void Student::setGpa(double gpa)
{
mGpa = gpa;
}
void Student::setMajor(string major)
{
mMajor = major;
}
void Student::display()
{
cout << "ID: " << mID << "\n"
<< "First name: " << mName.mFirstName << "\n"
<< "Last name: " << mName.mLastName << "\n"
<< "Street address: " << mAddress.mStreetAddress << "\n"
<< "City: " << mAddress.mCity << "\n"
<< "State: " << mAddress.mState << "\n"
<< "Zip code: " << mAddress.mZip << "\n"
<< "Phone Number: " << mPhoneNumber << "\n"
<< "Major: " << mMajor << "\n"
<< fixed << setprecision(2) << "GPA: " << mGpa << "\n\n";
} | [
"nuts4nuts4nuts@gmail.com"
] | nuts4nuts4nuts@gmail.com |
4a07931d23fe47b9d443cf036cdd2bf7e32155e6 | bfdd77a196fa8492d8f6f7a4dab43ac4f7f27313 | /build dictionary/definition.h | b775bcaad5e35fe8dc26b5cbc47825f80231ab8b | [] | no_license | netanelsu/college_cpp_projects | 62caa88e31fdc7475171bcbf3fc8d2248036a46d | 3f5d2f514ad431c1a07ea1092e9a194d35cea011 | refs/heads/main | 2023-03-06T14:05:09.918951 | 2021-02-18T15:17:25 | 2021-02-18T15:17:25 | 340,089,364 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 621 | h | #include<iostream>
#include"String.h"
using namespace std;
class Definition {
private:
String word;
int defnum;
String **definitions;
friend class Dictionary;
friend class Menu;
public:
Definition() : word(), defnum(0), definitions(NULL) {};
~Definition();
const Definition& operator=(const Definition& obj);
bool operator==(const Definition& obj)const;
friend ostream& operator<<(ostream& out, const Definition& obj);
friend istream& operator>>(istream& in, Definition& obj);
const Definition& operator-=(int);
const Definition& operator+=(const String&);
String& operator[](int);
}; | [
"noreply@github.com"
] | noreply@github.com |
2b05fcd236d5702917a4d6f2f232407115325959 | a23409a54d6ef8955e8aa890c583355cdb2b2d8f | /libstreetmap/m3.h | b9a29ebefa8a13a571a1e730edb2d934657212c6 | [] | no_license | LiuKuen/CityMaps | a6f76e6d67732b436b50f13bdbdd16ca3b0fe7fa | 088cdb9a5e58d8e3927c47fac253fe2378db226d | refs/heads/master | 2021-06-01T05:45:25.236568 | 2016-09-07T03:01:53 | 2016-09-07T03:01:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,649 | h | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: m3.h
* Author: liujeffr
*
* Created on February 27, 2016, 9:27 PM
*/
#pragma once
#include <vector>
#include <string>
#include <m2.h>
// Returns a path (route) between the start intersection and the end
// intersection, if one exists. If no path exists, this routine returns
// an empty (size == 0) vector. If more than one path exists, the path
// with the shortest travel time is returned. The path is returned as a vector
// of street segment ids; traversing these street segments, in the given order,
// would take one from the start to the end intersection.
std::vector<unsigned> find_path_between_intersections(unsigned
intersect_id_start, unsigned intersect_id_end);
void find_path_between_intersections(unsigned intersect_id_start,
unsigned intersect_id_end, std::vector<unsigned>&);
void find_path_between_intersections_append(unsigned intersect_id_start,
unsigned intersect_id_end, std::vector<unsigned>& path);
// Returns the time required to travel along the path specified. The path
// is passed in as a vector of street segment ids, and this function can
// assume the vector either forms a legal path or has size == 0.
// The travel time is the sum of the length/speed-limit of each street
// segment, plus 15 seconds per turn implied by the path. A turn occurs
// when two consecutive street segments have different street names.
double compute_path_travel_time(const std::vector<unsigned>& path);
double compute_path_travel_time(const std::list<unsigned>& path);
// Returns the shortest travel time path (vector of street segments) from
// the start intersection to a point of interest with the specified name.
// If no such path exists, returns an empty (size == 0) vector.
std::vector<unsigned> find_path_to_point_of_interest (unsigned
intersect_id_start, std::string point_of_interest_name);
// Given a vector of street segment ID's corresponding to a path, returns a
// series of directives as a vector of strings
std::vector<std::string> get_path_directives(std::vector<unsigned> path);
// determines the common intersection between two street segments
inline unsigned inCommon(unsigned segment1, unsigned segment2){
StreetSegmentInfo info1 = getStreetSegmentInfo(segment1);
StreetSegmentInfo info2 = getStreetSegmentInfo(segment2);
if(info1.to == info2.to || info1.to == info2.from)
return info1.to;
return info1.from;
}
// Given a path vector (vector of street segment ID's) a 2D vector with the
// street segments sorted by streets
TwoDimVector sortPath(std::vector<unsigned> path);
// Returns a turn directive when turning from previousSegment onto next segment
std::string turnDirective(unsigned const& previousSegment, unsigned const& nextSegment);
// Tells the driver how long to continue on a street
std::string straightDirective(std::vector<unsigned> currentSegments);
/************Functions are changed to handle multi-threading*******************/
//mt stands for multi-thread
//choose_data determines which data-structure to take from the vector
//of data-structures
std::vector<unsigned> mt_find_path_between_intersections(unsigned intersect_id_start,
unsigned intersect_id_end,
unsigned choose_data);
/******************************************************************************/
| [
"kuenjeffrey@hotmail.com"
] | kuenjeffrey@hotmail.com |
daf48a1c549f812713b5c22614f1052f6b557a46 | 99e68280f78d9a508efd799f526b16f174bf942c | /Test-case-generators-master/Graphs/Tree/tree.cpp | ed11ee87978054f37dbe7d48c3eb2e2630bb8c64 | [
"MIT",
"GPL-2.0-only"
] | permissive | kunalgoyal9/scripts-templates | d3e2d311f063e17bec4d2bcf4d67f419a9f7ac93 | 85989b2e29dc78c61023e8f32c2d9f7dd8d5386b | refs/heads/master | 2020-03-16T18:03:15.915577 | 2018-10-02T17:51:08 | 2018-10-02T17:51:08 | 132,857,516 | 0 | 1 | MIT | 2018-10-02T17:51:09 | 2018-05-10T06:20:26 | C++ | UTF-8 | C++ | false | false | 2,031 | cpp | //Below code is used to generate undirected unweighted tree
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int lim_n = 100005;
vector<int> adj[lim_n+1];
int visited[lim_n+1];
//check whether the graph is connected or not
void check_graph(int n) {
memset(visited, false, sizeof(visited));
queue<int> q;
q.push(1);
visited[1] = true;
while(!q.empty()) {
int u = q.front();
q.pop();
for(vector<int>::iterator it = adj[u].begin(); it != adj[u].end(); ++it) {
if (!visited[*it]) {
visited[*it] = true;
q.push(*it);
}
}
}
bool connected = true;
for(int i=1; i<=n; ++i) {
connected &= visited[i];
}
assert(connected);
}
//Output is space separated vertices pairs which contain an edge
//There is extra line after every test case
void generate_unweighted_tree(int n) {
set< pair<int,int> > duplicates;
vector< pair<int,int> > graph;
for(int i=2; i<=n; ++i) {
int x = i;
int y = rand() % (i - 1) + 1;
if (i % 10 == 0) {
swap(x, y);
}
assert (1 <= x <= n);
assert (1 <= y <= n);
assert (x != y);
if (duplicates.find(make_pair(x, y)) != duplicates.end()) {
i -= 1;
continue;
}
if (duplicates.find(make_pair(y, x)) != duplicates.end()) {
i -= 1;
continue;
}
duplicates.insert(make_pair(x, y));
adj[x].push_back(y);
adj[y].push_back(x);
graph.push_back(make_pair(x, y));
}
random_shuffle(graph.begin(), graph.end());
for(int i=0; i<n-1; ++i) {
printf("%d %d\n", graph[i].first, graph[i].second);
}
//check whether the graph made is connected or not
check_graph(n);
for(int i=1; i<=n; ++i) {
adj[i].clear();
}
printf("\n");
}
int main() {
#ifndef ONLINE_JUDGE
freopen("inp.txt", "w", stdout);
#endif
srand(unsigned(time(0)));
int test_cases = 2;
//Comment below line if not needed
printf("%d\n", test_cases);
for(int t=1; t<=test_cases; ++t) {
//get random value of "n" between (1, lim_n)
int n = rand() % lim_n + 1;
printf("%d\n", n);
generate_unweighted_tree(n);
}
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
06d9378910dbf207c2eeb3223ce6726d4be7e442 | 427d18c0872465394931829982860d0948383c9c | /pgadmin/include/pgscript/expressions/pgsCast.h | ef4570211059bb60b8a2650f911c34c329bc6cca | [
"PostgreSQL"
] | permissive | jcjc79/pgadmin3 | 6e4b68b051ce86c831dd8e4dd320755fe12d230e | be0f94786bf5b8138c9e6ec1b0b295308f8f89b6 | refs/heads/master | 2021-10-22T23:00:01.924934 | 2019-03-13T10:51:22 | 2019-03-13T10:51:22 | 273,088,849 | 0 | 1 | NOASSERTION | 2020-06-17T22:15:54 | 2020-06-17T22:15:54 | null | UTF-8 | C++ | false | false | 851 | h | //////////////////////////////////////////////////////////////////////////
//
// pgScript - PostgreSQL Tools
//
// Copyright (C) 2002 - 2013, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
#ifndef PGSCAST_H_
#define PGSCAST_H_
#include "pgscript/pgScript.h"
#include "pgscript/expressions/pgsExpression.h"
class pgsCast : public pgsExpression
{
private:
int m_cast_type;
const pgsExpression *m_var;
public:
pgsCast(const int &cast_type, const pgsExpression *var);
virtual ~pgsCast();
virtual pgsExpression *clone() const;
pgsCast(const pgsCast &that);
pgsCast &operator=(const pgsCast &that);
public:
virtual wxString value() const;
virtual pgsOperand eval(pgsVarMap &vars) const;
};
#endif /*PGSCAST_H_*/
| [
"miaochen@mail.ustc.edu.cn"
] | miaochen@mail.ustc.edu.cn |
b5de9e7b6a3abcb1d9c169078e3a242a9fbbb6e8 | 9ea575abc4b9641d0deb5285d4e6cb2396e3ac27 | /496_Next_Greater_Element_I.cpp | d42fa3a26a4efb37b8d755fd40e45516ff20294c | [] | no_license | Ming-J/LeetCode | 65e11cdeb1530ae163fa1fc9851acbcee7f05744 | a69f56a1e92a4cb32a1a16bc3201027910f1a877 | refs/heads/master | 2022-05-08T00:37:01.830067 | 2022-03-06T15:40:43 | 2022-03-06T15:40:43 | 26,152,966 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 957 | cpp | #include <iostream>
#include <vector>
#include <stack>
#include <unordered_map>
using namespace std;
/*
Using hash map to optiimize. Using a stack to kept track of the right
most order. compare the stack until an number if bigger. If stack is
empty assign the value to -1. Linear Complexity. Line Space Complexity.
O(m+n)
S(m+n)
*/
class Solution{
public:
vector<int> nextGreaterElement(vector<int>& findNums, vector<int>& nums){
vector<int> ans;
unordered_map<int,int> hash;
stack<int> deck;
for(int i=nums.size()-1;i>=0;i--){
if(i==nums.size()-1){
hash[nums[i]]=-1;
}else{
if(nums[i]<deck.top()){
hash[nums[i]]=deck.top();
deck.push(nums[i]);
}else{
while(!deck.empty()&&deck.top()<nums[i]){
deck.pop();
}
hash[nums[i]]=deck.empty()?-1:deck.top();
}
}
deck.push(nums[i]);
}
for(int i=0;i<findNums.size();i++){
ans.push_back(hash[findNums[i]]);
}
return ans;
}
};
| [
"minwu@uk166672.uk.deloitte.com"
] | minwu@uk166672.uk.deloitte.com |
accd6196d19abbc59b91b4967d64abde992da66d | 833dfddd79ffa364d2787fdf25ef6e793aa7014e | /src/lib/win.cpp | cf52b982525b8977605c6fbcaebd70453eacc6db | [
"MIT"
] | permissive | dejbug/DejAW | 273e516c38063515e39b52f5eb15014ef508f416 | 62e6f6ab14e444df921487f5f0762a7c055c79f1 | refs/heads/master | 2020-09-03T15:05:24.839729 | 2020-02-23T09:20:14 | 2020-02-23T09:20:14 | 219,493,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,698 | cpp | #include "win.h"
#include "Rect.h"
void lib::win::init(WNDCLASSEX & wc, LPCSTR name, WNDPROC callback) noexcept
{
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.hInstance = GetModuleHandle(nullptr);
wc.hIcon = wc.hIconSm = LoadIcon(nullptr, IDI_APPLICATION);
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE+1);
wc.lpszMenuName = nullptr;
wc.lpszClassName = name;
wc.lpfnWndProc = callback;
}
ATOM lib::win::install(WNDCLASSEX const & wc) noexcept
{
return RegisterClassEx(&wc);
}
HWND lib::win::create(WNDCLASSEX const & wc, LPCSTR title) noexcept
{
return CreateWindowEx(
WS_EX_OVERLAPPEDWINDOW | WS_EX_ACCEPTFILES | WS_EX_CONTROLPARENT,
wc.lpszClassName,
title,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
nullptr,
nullptr,
wc.hInstance,
nullptr
);
}
int lib::win::run(HWND hwnd, HACCEL haccel) noexcept
{
MSG msg;
while (true)
{
int const res = GetMessage(&msg, nullptr, 0, 0);
if(0 == res) break; // WM_QUIT
else if(res < 0)
{
// throw std::runtime_exception("error in main loop");
return -1;
}
if(hwnd && haccel)
TranslateAccelerator(hwnd, haccel, &msg);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
void lib::win::closeWindow(HWND h) noexcept
{
SendMessage(h, WM_CLOSE, 0, 0);
}
void lib::win::move(HWND hwnd, int x, int y) noexcept
{
SetWindowPos(hwnd, nullptr, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
void lib::win::resize(HWND hwnd, int w, int h) noexcept
{
SetWindowPos(hwnd, nullptr, 0, 0, w, h, SWP_NOZORDER | SWP_NOMOVE);
}
void lib::win::center(HWND hwnd) noexcept
{
WindowRect c(hwnd);
WindowRect p(GetParent(hwnd));
auto const dx = (p.width() - c.width()) >> 1;
auto const dy = (p.height() - c.height()) >> 1;
move(hwnd, p.left + dx, p.top + dy);
}
HGDIOBJ lib::win::selectStockObject(HDC dc, int id) noexcept
{
return SelectObject(dc, GetStockObject(id));
}
// COLORREF lib::win::setPenColor(HDC dc, COLORREF color) noexcept
// {
// SelectObject(dc, GetStockObject(DC_PEN));
// return SetDCPenColor(dc, color);
// }
// COLORREF lib::win::setBrushColor(HDC dc, COLORREF color) noexcept
// {
// SelectObject(dc, GetStockObject(DC_BRUSH));
// return SetDCBrushColor(dc, color);
// }
void lib::win::whiteness(HDC dc, int x, int y, int w, int h, bool invert) noexcept
{
BitBlt(dc, x, y, w, h, nullptr, 0, 0, invert ? BLACKNESS : WHITENESS);
}
| [
"dejbug@users.noreply.github.com"
] | dejbug@users.noreply.github.com |
21b880342312a8ca14dad46bc3d215e91eb7268f | 46bcd6d42d012f0cd6b7138aca75902b9078d625 | /AoC_2017/day22.hpp | 275d1e86f0ee3973287ccbaf99b81f17c3d6c220 | [
"CC0-1.0"
] | permissive | c-goldschmidt/AoC_2017 | ba7e3374764bcea38d64d1f39f159f62b8cda826 | 6455b14bca9dc67ec6ceaf1f3c16ddb4c0b599e0 | refs/heads/main | 2023-02-07T15:05:35.140921 | 2020-12-31T13:53:13 | 2020-12-31T13:53:13 | 324,752,362 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,152 | hpp | #pragma once
#include "day_factory.hpp"
enum Flag {clean, weak, infected, flagged};
DAY(Day22)
class CarrierGrid {
public:
CarrierGrid(vector<string> *input);
~CarrierGrid() = default;
void tick();
void tickMulti();
int infectCount;
private:
Point2D direction;
Point2D position;
map<string, Flag> grid;
map<string, Point2D> gridCoords;
Flag at(Point2D *pos);
};
CarrierGrid::CarrierGrid(vector<string>* input) {
infectCount = 0;
for (uint i = 0; i < input->size(); i++) {
string str = input->at(i);
for (uint j = 0; j < str.length(); j++) {
Point2D coords = { i, j };
gridCoords.insert(pair(coords.str(), coords));
grid.insert(pair(coords.str(), str[j] == '#' ? infected : clean));
}
}
direction = {-1, 0};
position = { input->size() / 2, input->size() / 2 };
}
Flag CarrierGrid::at(Point2D* pos) {
if (auto it = grid.find(pos->str()); it != grid.end()) {
return it->second;
}
return clean;
}
void CarrierGrid::tick() {
Flag cellFlag = at(&position);
if (cellFlag == infected) {
Point2D newDirection = {direction.x, -direction.y};
direction = newDirection;
grid[position.str()] = clean;
} else {
Point2D newDirection = {-direction.x, direction.y };
direction = newDirection;
grid[position.str()] = infected;
infectCount++;
}
position.add(&direction);
}
void CarrierGrid::tickMulti() {
Flag cellFlag = at(&position);
switch (cellFlag) {
case clean:
direction = { -this->direction.x, this->direction.y };
grid[position.str()] = weak;
break;
case weak:
grid[position.str()] = infected;
infectCount++;
break;
case infected:
direction = { this->direction.x, -this->direction.y };
grid[position.str()] = flagged;
break;
case flagged:
direction = { -this->direction.y, -this->direction.x };
grid[position.str()] = clean;
break;
}
position.add(&direction);
}
void Day22::part1() {
CarrierGrid grid(&fileContent);
for (int i = 0; i < 10000; i++) {
grid.tick();
}
printResult(grid.infectCount);
}
void Day22::part2() {
CarrierGrid grid(&fileContent);
for (int i = 0; i < 10000000; i++) {
grid.tickMulti();
}
printResult(grid.infectCount);
} | [
"congold@live.de"
] | congold@live.de |
21f9d9b52c9ad61f7e821de842bf884da6c755e4 | 49291e1a34eb617e600ed47a5d9f56ba98342590 | /include/Utility.cpp | 85d283c8c9871bb12056de88ef32c024129eea5d | [] | no_license | FernandB/PigeonCakes | 03a7fe631deaee725565ce419c45a63de81d131d | 0bc98908b1f141f53c19e650fd6a030e3a53452d | refs/heads/master | 2021-07-19T22:52:25.060464 | 2017-10-26T09:49:30 | 2017-10-26T09:49:30 | 108,110,656 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 926 | cpp | #include "Utility.h"
Utility::Utility()
{
}
float Utility::getGravity()
{
return GRAVITY;
}
unsigned int Utility::getWindowPixelHeight()
{
return WINDOW_PIXEL_HEIGHT;
}
unsigned int Utility::getWindowPixelWidth()
{
return WINDOW_PIXEL_WIDTH;
}
unsigned int Utility::getFramerate()
{
return FRAMERATE;
}
float Utility::getVelocityIterations()
{
return VELOCITY_ITERATIONS;
}
float Utility::getPositionIterations()
{
return POSITION_ITERATIONS;
}
float Utility::getPixelPerMeter()
{
return PIXEL_PER_METER;
}
float Utility::pixel2Meter(float pixel)
{
return pixel/PIXEL_PER_METER;
}
float Utility::meter2Pixel(float meter)
{
return meter*PIXEL_PER_METER;
}
sf::Vector2i Utility::pixel2Meter(int pixelX, int pixelY)
{
return sf::Vector2i(pixel2Meter(pixelX),pixel2Meter(pixelY));
}
sf::Vector2i Utility::meter2Pixel(int meterX, int meterY)
{
return sf::Vector2i(meter2Pixel(meterX),meter2Pixel(meterY));
}
| [
"battisti.fernand@gmail.com"
] | battisti.fernand@gmail.com |
e97bc2aad22c52ac45910c0a6065ce72aa51b47d | 165be8367f5753b03fae11430b1c3ebf48aa834a | /tools/train/source/grad/RoiAlignGrad.cpp | 4737f06be5a225f17c19fd20addb7a8596afbe2e | [
"Apache-2.0"
] | permissive | alibaba/MNN | f21b31e3c62d9ba1070c2e4e931fd9220611307c | c442ff39ec9a6a99c28bddd465d8074a7b5c1cca | refs/heads/master | 2023-09-01T18:26:42.533902 | 2023-08-22T11:16:44 | 2023-08-22T11:16:44 | 181,436,799 | 8,383 | 1,789 | null | 2023-09-07T02:01:43 | 2019-04-15T07:40:18 | C++ | UTF-8 | C++ | false | false | 1,333 | cpp | //
// RoiAlignGrad.cpp
// MNN
//
// Created by MNN on 2022/12/14.
// Copyright © 2018, Alibaba Group Holding Limited
//
#include "OpGrad.hpp"
#include "core/Macro.h"
using namespace std;
using namespace MNN;
using namespace MNN::Express;
class RoiAlignGrad : public OpGrad {
public:
virtual std::vector<Express::VARP> onGrad(Express::EXPRP expr, const std::vector<Express::VARP>& backwardOutput) override {
std::vector<Express::VARP> res(1, nullptr);
auto input = expr->inputs()[0];
auto roi = expr->inputs()[1];
std::unique_ptr<OpT> forwardOp(expr->get()->UnPack());
auto param = forwardOp->main.AsRoiParameters();
int pooledHeight = param->pooledHeight;
int pooledWidth = param->pooledWidth;
auto spatialScale = param->spatialScale;
int samplingRatio = param->samplingRatio;
bool aligned = param->aligned;
auto poolType = param->poolType;
res[0] = _ROIAlign(input, roi, pooledHeight, pooledWidth, spatialScale, samplingRatio, aligned, PoolingMode(poolType), true, _Convert(backwardOutput[0], NC4HW4));
res[0] = _Convert(res[0], input->getInfo()->order);
return res;
}
};
static const auto gRegister = []() {
static RoiAlignGrad _c;
OpGrad::insert(OpType_ROIAlign, &_c);
return true;
}();
| [
"xiaotang.jxt@alibaba-inc.com"
] | xiaotang.jxt@alibaba-inc.com |
00cf10e5a9bbe9404cc5185531ce875a31eac538 | b30a5daa30e5cb32dae81dc8634ad4443bdaa9b1 | /ADCensusBM/stereoprocessor.h | de88460cc2d23cbfceafea0bd3a621994b2a5997 | [
"BSD-3-Clause"
] | permissive | Stephanie-ustc/UpdatedStereoVision-ADCensus | 87280e48edbd8391aefd21881a76963f5a337f8f | cc267721746154744a7cd6a3602764c7c7eca76b | refs/heads/master | 2020-09-10T04:47:21.131594 | 2015-06-12T09:03:53 | 2015-06-12T09:03:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,562 | h | /* ----------------------------------------------------------------------------
* Robotics Laboratory, Westphalian University of Applied Science
* ----------------------------------------------------------------------------
* Project : Stereo Vision Project
* Revision : 1.0
* Recent changes : 18.06.2014
* ----------------------------------------------------------------------------
* LOG:
* ----------------------------------------------------------------------------
* Developer : Dennis Luensch (dennis.luensch@gmail.com)
Tom Marvin Liebelt (fh@tom-liebelt.de)
Christian Blesing (christian.blesing@gmail.com)
* License : BSD
*
* Copyright (c) 2014, Dennis Lünsch, Tom Marvin Liebelt, Christian Blesing
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* # Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* # Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* # Neither the name of the {organization} nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ------------------------------------------------------------------------- */
#ifndef STEREOPROCESSOR_H
#define STEREOPROCESSOR_H
#include "adcensuscv.h"
#include "aggregation.h"
#include "scanlineoptimization.h"
#include "disparityrefinement.h"
#include <omp.h>
#include "common.h"
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
class StereoProcessor
{
public:
StereoProcessor(uint dMin, uint dMax, Mat leftImage, Mat rightImage, Size censusWin, float defaultBorderCost,
float lambdaAD, float lambdaCensus, string savePath, uint aggregatingIterations,
uint colorThreshold1, uint colorThreshold2, uint maxLength1, uint maxLength2, uint colorDifference,
float pi1, float pi2, uint dispTolerance, uint votingThreshold, float votingRatioThreshold,
uint maxSearchDepth, uint blurKernelSize, uint cannyThreshold1, uint cannyThreshold2, uint cannyKernelSize);
~StereoProcessor();
bool init(string &error);
bool compute();
Mat getDisparity();
private:
int dMin;
int dMax;
Mat images[2];
Size censusWin;
float defaultBorderCost;
float lambdaAD;
float lambdaCensus;
string savePath;
uint aggregatingIterations;
uint colorThreshold1;
uint colorThreshold2;
uint maxLength1;
uint maxLength2;
uint colorDifference;
float pi1;
float pi2;
uint dispTolerance;
uint votingThreshold;
float votingRatioThreshold;
uint maxSearchDepth;
uint blurKernelSize;
uint cannyThreshold1;
uint cannyThreshold2;
uint cannyKernelSize;
bool validParams, dispComputed;
vector<vector<Mat> > costMaps;
Size imgSize;
ADCensusCV *adCensus;
Aggregation *aggregation;
Mat disparityMap, floatDisparityMap;
DisparityRefinement *dispRef;
void costInitialization();
void costAggregation();
void scanlineOptimization();
void outlierElimination();
void regionVoting();
void properInterpolation();
void discontinuityAdjustment();
void subpixelEnhancement();
Mat cost2disparity(int imageNo);
template <typename T>
void saveDisparity(const Mat &disp, string filename, bool stretch = true);
};
#endif // STEREOPROCESSOR_H
| [
"guivi01@gmail.com"
] | guivi01@gmail.com |
b0e82c925ee49917c614406896bfda5899c9a697 | 9744b5f3eea1d5f664cfab0a28722dac80ae70ce | /Lab10Assembler/FractionReduce/Processor.cpp | ed75ebc2e3ff36b77d65310fe15c47b783f479c9 | [] | no_license | kukichek/Prog2Sem | f2cbf52a59ad50a50b12029fb384a4b01ea1204f | 5d205dab0763328c025f5f7d81569d46c8fc15ee | refs/heads/master | 2020-08-06T12:39:27.635107 | 2019-10-09T21:38:27 | 2019-10-09T21:38:27 | 212,977,362 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 231 | cpp | #include"Processor.h"
void Processor::operator() () {
cout << "Enter, please, a fraction:\n";
try {
cin >> frac;
cout << "A fraction after reduce is " << frac << endl;
}
catch (string error) {
cout << error << endl;
}
} | [
"tavi4ham@gmail.com"
] | tavi4ham@gmail.com |
02390e621f4d8d1d94139c136bd1c29e4a686f95 | 265a26e76beea44c7e61116669bf43746b27bbed | /HostApplication/addcontact.cpp | a8cef9a79f1c800421e0f428918467cf2b538e19 | [] | no_license | JethroDevon/cryptoKey | bd2e5b324a0f3798c5f93fe8f136b2b5cf3ce33c | 2163ccd99233879724cdc365e3a96a2644c744cd | refs/heads/master | 2022-11-16T10:56:10.193085 | 2020-07-07T11:43:14 | 2020-07-07T11:43:14 | 71,635,023 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 926 | cpp | #include "addcontact.h"
#include "ui_addcontact.h"
AddContact::AddContact(QWidget *parent) : QWidget(parent), ui(new Ui::AddContact){
add_button = new QPushButton( "Save", this);
add_button->setGeometry(QRect( QPoint( 100, 65), QSize( 130,30)));
namefield = new QTextEdit( "", this);
namefield->setGeometry(QRect( QPoint( 10, 65), QSize( 80, 30)));
explain = new QLabel( "Entering an eight digit name for a secure channel and then\npressing 'Save' will store new public key with\nthat channels name on the connected device.", this);
explain->setGeometry(QRect( QPoint( 10, 0), QSize( 370, 60)));
connect( add_button, SIGNAL (released()),this, SLOT (setContact()));
}
AddContact::~AddContact(){
delete ui;
}
void AddContact::setContact(){
contactname = namefield->toPlainText();
if( contactname != ""){
addingkey = true;
}else{
addingkey = false;
}
}
| [
"ma302jh@gold.ac.uk"
] | ma302jh@gold.ac.uk |
770ccc4d3a4a8ab278fb52c2820fbfc11df94607 | a5f66b8fb0ba688d2240a20b215589ab227c6537 | /codebase/apps/Radx/src/RadxPersistentClutter/RadxPersistentClutterSecondPass.hh | f3603e01d602a76603d1046f976e5b888169c9ec | [
"BSD-3-Clause"
] | permissive | marack/lrose-core | 93254fcf6c62146d437f09322922485605089e5f | 2a05ec2960c5f95bda680bf6d29176e5bc20b38f | refs/heads/master | 2020-04-16T12:42:06.895998 | 2019-01-14T03:10:02 | 2019-01-14T03:10:02 | 165,592,701 | 0 | 0 | NOASSERTION | 2019-01-14T03:58:34 | 2019-01-14T03:58:34 | null | UTF-8 | C++ | false | false | 3,087 | hh | // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
// ** Copyright UCAR (c) 1990 - 2016
// ** University Corporation for Atmospheric Research (UCAR)
// ** National Center for Atmospheric Research (NCAR)
// ** Boulder, Colorado, USA
// ** BSD licence applies - redistribution and use in source and binary
// ** forms, with or without modification, are permitted provided that
// ** the following conditions are met:
// ** 1) If the software is modified to produce derivative works,
// ** such modified software should be clearly marked, so as not
// ** to confuse it with the version available from UCAR.
// ** 2) Redistributions of source code must retain the above copyright
// ** notice, this list of conditions and the following disclaimer.
// ** 3) Redistributions in binary form must reproduce the above copyright
// ** notice, this list of conditions and the following disclaimer in the
// ** documentation and/or other materials provided with the distribution.
// ** 4) Neither the name of UCAR nor the names of its contributors,
// ** if any, may be used to endorse or promote products derived from
// ** this software without specific prior written permission.
// ** DISCLAIMER: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
// ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
/**
* @file RadxPersistentClutterSecondPass.hh
* @brief The second pass algorithm
* @class RadxPersistentClutterSecondPass
* @brief The second pass algorithm
*
* The algorithm uses the internal state to go back through the data and
* create histograms at each point with clutter, which are then used to
* estimate a clutter value, which is output.
*/
#ifndef RADXPERSISTENTCLUTTERSECONDPASS_H
#define RADXPERSISTENTCLUTTERSECONDPASS_H
#include "RadxPersistentClutter.hh"
#include "RayData.hh"
#include "RayHistoInfo.hh"
#include <Radx/RadxVol.hh>
#include <map>
class RadxPersistentClutterSecondPass : public RadxPersistentClutter
{
public:
/**
* Constructor
* @param[in] p Object to use as base class
*
* Input contains the results of the first pass
*/
RadxPersistentClutterSecondPass (const RadxPersistentClutter &p);
/**
* Destructor
*/
virtual ~RadxPersistentClutterSecondPass(void);
#include "RadxPersistentClutterVirtualMethods.hh"
protected:
private:
RayData _templateVol; /**< Saved volume used to form output */
std::map<RadxAzElev, RayHistoInfo> _histo; /**< The storage of all info needed to
* do the computations, running counts
* and histograms through time, one
* object per az/elev */
};
#endif
| [
"dixon@ucar.edu"
] | dixon@ucar.edu |
95a720ab2be1e204086fdb43695d08f7d51215b2 | 57656fb211aa11f486e1a41fb7ae144bde7c38de | /CS 455 Visual/Proj04/p4_bberger3/Proj04-3.cpp | a4303657d2a419017beb8605ee986765c62a7fbd | [] | no_license | Benjamin-Berger/Senior_Year | 7e759b9049d4d40ec635101a48176cb4e79f2c00 | 2ea9e86221fd920e2699c508443c868168e780a3 | refs/heads/master | 2021-01-01T06:56:54.775447 | 2017-07-18T05:53:08 | 2017-07-18T05:53:08 | 97,557,946 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,593 | cpp | #include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include <vector>
#include <unordered_set>
#include <iostream>
#include <map>
using namespace std;
using namespace cv;
void erosion(int m, Mat org, Mat &mod){
int r = -(m/2);
//cout << r << endl;
int test = 0;
for(int y = 0; y < org.rows; y++){
for(int x = 0; x < org.cols; x++){
for(int i = r; i <= -r; i++){
for(int j = r; j <= -r; j++){
if(x + j < 0){
test += 255;
} else if(x + j >= org.cols){
test += 255;
} else if(y + i < 0){
test += 255;
} else if(y + i >= org.rows){
test += 255;
} else {
test += org.data[(y + i) * org.cols + (x + j)];
}
}
}
if(test != 2295){
mod.data[y*org.cols + x] = 0;
} else {
//cout << test << endl;
mod.data[y*org.cols + x] = 255;
}
test = 0;
}
}
}
void dilation(int m, Mat org, Mat &mod){
int r = -(m/2);
//cout << r << endl;
int test = 0;
for(int y = 0; y < org.rows; y++){
for(int x = 0; x < org.cols; x++){
for(int i = r; i <= -r; i++){
for(int j = r; j <= -r; j++){
if(x + j < 0){
test += 0;
} else if(x + j >= org.cols){
test += 0;
} else if(y + i < 0){
test += 0;
} else if(y + i >= org.rows){
test += 0;
} else {
test += org.data[(y + i) * org.cols + (x + j)];
}
}
}
if(test == 0){
mod.data[y*org.cols + x] = 0;
} else {
mod.data[y*org.cols + x] = 255;
}
test = 0;
}
}
}
int main(int argc, char **argv) {
if(argc != 2) {
cout << "USAGE: skeleton <input file path>" << endl;
return -1;
}
//Load two copies of the image. One to leave as the original, and one to be modified.
//Done for display purposes only
//Use CV_LOAD_IMAGE_GRAYSCALE for greyscale images
//Color CV_LOAD_IMAGE_COLOR
Mat original_image = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
Mat modified_image = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
Mat modified_image1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
Mat modified_image2 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
Mat modified_image3 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
//Create a pointer so that we can quickly toggle between which image is being displayed
Mat *image = &original_image;
//Check that the images loaded
if(!original_image.data || !modified_image.data) {
cout << "ERROR: Could not load image data." << endl;
return -1;
}
//Create the display window
namedWindow("Unix Sample Skeleton");
//Otsu method for creating a Binary image
//code from http://www.dandiggins.co.uk/arlib-9.html
float w = 0; // first order cumulative
float u = 0; // second order cumulative
float uT = 0; // total mean level
int k = 255; // maximum histogram index
int T = 0; // optimal threshold value
float histNormalized[256]; // normalized histogram values
float work1, work2; // working variables
double work3 = 0.0;
float histogram[256];
int pixSize=0;
for(size_t y = 0; y < original_image.rows; y++){
for(size_t x = 0; x < original_image.cols; x++){
histogram[original_image.data[y*original_image.cols +x]]++;
pixSize++;
}
}
///////////////////////////////////////
// Create normalised histogram values
// (size=image width * image height)
for (int I=1; I<=k; I++)
histNormalized[I-1] = histogram[I-1]/(float)pixSize;
// Calculate total mean level
for (int I=1; I<=k; I++)
uT+=(I*histNormalized[I-1]);
// Find optimal threshold value
for (int I=1; I<k; I++) {
w+=histNormalized[I-1];
u+=(I*histNormalized[I-1]);
work1 = (uT * w - u);
work2 = (work1 * work1) / ( w * (1.0f-w) );
if (work2>work3) work3=work2;
}
// Convert the final value to an integer
//(1)
T = (int)sqrt(work3);
//cout << T << endl;
//hard coded my own Threshold
T = 200;
for(size_t x = 0; x < original_image.cols; x++){
for(size_t y = 0; y < original_image.rows; y++){
if(original_image.data[y*original_image.cols + x] <= T){
modified_image.data[y*original_image.cols + x] = 0;
} else {
modified_image.data[y*original_image.cols + x] = 255;
}
}
}
//dont use this!
//threshold(original_image, modified_image, T, 255, 0);
/////////////////********* AT THIS POINT I HAVE A BINARY REPRESENTATION **********///////////////////////////////
//opening operation
//flood fill labeling --- this is recursive. not using this. using connected components
erosion(3, original_image, modified_image2);
dilation(3, original_image, modified_image3);
erosion(3, original_image, modified_image1);
dilation(3, original_image, modified_image);
//Display loop
bool loop = true;
while(loop) {
imshow("Unix Sample Skeleton", *image);
switch(cvWaitKey(15)) {
case 27: //Exit display loop if ESC is pressed
loop = false;
break;
case 32: //Swap image pointer if space is pressed
if(image == &original_image){
image = &modified_image2;
} else if(image == &modified_image2){
image = &modified_image3;
} else if( image == &modified_image3){
image = &modified_image;
}
else image = &original_image;
break;
default:
break;
}
}
} | [
"Berger.Benjamin1@gmail.com"
] | Berger.Benjamin1@gmail.com |
1eb309e5f9d0234da902b674515a58eaaf577678 | 36fc46366f6e09ce553fd2a10d9cccf37e7b6195 | /프로그래머스/Lv1_행렬의 덧셈.cpp | 17cd8c80cf8df6bced2f5a1811522e8085a3d989 | [] | no_license | Seoui/Algorithm | 12e5cdd022d5989e0aa6a5ed09f7ada789614bef | 6bce7081e72c94a74b4dceb41f267c1db0a4190e | refs/heads/master | 2023-04-20T01:12:13.069113 | 2021-05-10T17:22:07 | 2021-05-10T17:22:07 | 290,984,289 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 591 | cpp | #include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<vector<int>> solution(vector<vector<int>> arr1, vector<vector<int>> arr2)
{
vector<vector<int>> answer;
for (int i = 0; i < arr1.size(); ++i) {
vector<int> row;
for (int j = 0; j < arr1[0].size(); ++j) {
row.push_back(arr1[i][j] + arr2[i][j]);
}
answer.push_back(row);
}
return answer;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solution({ {1,2},{2,3} }, { {3,4},{5,6} });
solution({ {1},{2} }, { {3},{4} });
system("pause");
return 0;
} | [
"dusto@naver.com"
] | dusto@naver.com |
a9ca3c8791d20158a9bb11b9162dd1e55b951425 | cc5d59486fdd1b68763caa93ecede262c1c92bfb | /day03/2stu.cpp | 6853af877927421fcae771a24953ca6c517098cc | [] | no_license | wk5650/study | 070b6fd587ad82cb5e5d71a130f442fee36e8105 | efd8da7e953b64226bc008c0b450c7864d60a990 | refs/heads/master | 2020-12-02T07:54:59.714407 | 2017-09-16T08:32:43 | 2017-09-16T08:32:43 | 96,747,109 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,368 | cpp | #include <iostream>
#include <string>
#include <string.h> //strlen
using namespace std;
class A
{};
class B
{
A m_a; //子对象
};
class Date
{
public:
Date():m_iYear(0), m_iMonth(0), m_iDay(0)
{}
Date(int year, int month, int day)
: m_iYear(year), m_iMonth(month)
, m_iDay(day)
{}
void showDate()
{
cout << m_iYear << "-" << m_iMonth
<< "-" << m_iDay << endl;
}
int m_iYear;
int m_iMonth;
int m_iDay;
};
//子对象的初始化必须在初始化列表中
//调用其构造函数进行初始化
class Student
{
public:
//若没有在初始化列表中显式对子对象进行初始化
//则默认调用子对象的无参构造函数对其初始化
Student(string name, float score)
: m_strName(name), m_fScore(score)
{
}
Student() //: m_date()//调用无参构造函数
{
cout << "student()" << endl;
}
Student(string name, float score
, int year, int month, int day)
: m_strName(name), m_fScore(score)
, m_date(year, month, day)
{
}
void info()
{
cout << "name:" << m_strName
<< " score:" << m_fScore
/*<< " born:" << m_strBorn*/ << endl;
m_date.showDate();
}
private:
string m_strName;
float m_fScore;
Date m_date;
};
int main(void)
{
Student s1;//调用无参构造函数
s1.info();
Student s2("aa", 89);
s2.info();
Student s3("aa", 89, 1988, 11, 11);
s3.info();
return 0;
}
| [
"“wk5650”"
] | “wk5650” |
8414844c4650bcedccec430bcdee6604f07e058e | 607e69f9e4440ef3ab9c33b7b6e85e95b5e982fb | /deps/museum/8.0.0/external/libcxx/support/win32/locale_win32.h | 9220c68a1ee8406ab5882815ff3ae69104917435 | [
"NCSA",
"MIT",
"Apache-2.0"
] | permissive | simpleton/profilo | 8bda2ebf057036a55efd4dea1564b1f114229d1a | 91ef4ba1a8316bad2b3080210316dfef4761e180 | refs/heads/master | 2023-03-12T13:34:27.037783 | 2018-04-24T22:45:58 | 2018-04-24T22:45:58 | 125,419,173 | 0 | 0 | Apache-2.0 | 2018-03-15T19:54:00 | 2018-03-15T19:54:00 | null | UTF-8 | C++ | false | false | 4,179 | h | // -*- C++ -*-
//===--------------------- support/win32/locale_win32.h -------------------===//
//
// 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 _MUSEUM_LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
#define _MUSEUM_LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
#include <crtversion.h>
#if _VC_CRT_MAJOR_VERSION < 14
// ctype mask table defined in msvcrt.dll
extern "C" unsigned short __declspec(dllimport) _ctype[];
#endif
#include <museum/8.0.0/external/libcxx/support/win32/support.h>
#include <museum/8.0.0/external/libcxx/support/win32/locale_mgmt_win32.h>
#include <museum/8.0.0/external/libcxx/stdio.h>
lconv *localeconv_l( locale_t loc );
size_t mbrlen_l( const char *__restrict s, size_t n,
mbstate_t *__restrict ps, locale_t loc);
size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
size_t len, mbstate_t *__restrict ps, locale_t loc );
size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
locale_t loc);
size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
size_t n, mbstate_t *__restrict ps, locale_t loc);
size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc);
size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src,
size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc);
wint_t btowc_l( int c, locale_t loc );
int wctob_l( wint_t c, locale_t loc );
inline _MUSEUM_LIBCPP_ALWAYS_INLINE
decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
{
return ___mb_cur_max_l_func(__l);
}
// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
#define mbtowc_l _mbtowc_l
#define strtoll_l _strtoi64_l
#define strtoull_l _strtoui64_l
#define strtof_l _strtof_l
#define strtod_l _strtod_l
#define strtold_l _strtold_l
inline _MUSEUM_LIBCPP_INLINE_VISIBILITY
int
islower_l(int c, _locale_t loc)
{
return _islower_l((int)c, loc);
}
inline _MUSEUM_LIBCPP_INLINE_VISIBILITY
int
isupper_l(int c, _locale_t loc)
{
return _isupper_l((int)c, loc);
}
#define isdigit_l _isdigit_l
#define isxdigit_l _isxdigit_l
#define strcoll_l _strcoll_l
#define strxfrm_l _strxfrm_l
#define wcscoll_l _wcscoll_l
#define wcsxfrm_l _wcsxfrm_l
#define toupper_l _toupper_l
#define tolower_l _tolower_l
#define iswspace_l _iswspace_l
#define iswprint_l _iswprint_l
#define iswcntrl_l _iswcntrl_l
#define iswupper_l _iswupper_l
#define iswlower_l _iswlower_l
#define iswalpha_l _iswalpha_l
#define iswdigit_l _iswdigit_l
#define iswpunct_l _iswpunct_l
#define iswxdigit_l _iswxdigit_l
#define towupper_l _towupper_l
#define towlower_l _towlower_l
#define strftime_l _strftime_l
#define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
#define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )
#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...);
int asprintf_l( char **ret, locale_t loc, const char *format, ... );
int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
// not-so-pressing FIXME: use locale to determine blank characters
inline int isblank_l( int c, locale_t /*loc*/ )
{
return ( c == ' ' || c == '\t' );
}
inline int iswblank_l( wint_t c, locale_t /*loc*/ )
{
return ( c == L' ' || c == L'\t' );
}
#if defined(_MUSEUM_LIBCPP_MSVCRT)
inline int isblank( int c, locale_t /*loc*/ )
{ return ( c == ' ' || c == '\t' ); }
inline int iswblank( wint_t c, locale_t /*loc*/ )
{ return ( c == L' ' || c == L'\t' ); }
#endif // _MUSEUM_LIBCPP_MSVCRT
#endif // _MUSEUM_LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
bc8128fbd49a3b5ae673bc6fe832dec5ccd679a6 | 6bdffe79068a4299e17991e36ad0115da0e0777e | /Algorithm_C/Algorithm_C/First/InversePairs/InversePairs.cpp | 36ca77c557d6f5e2e2d47ce79898647fdcad7445 | [] | no_license | chm994483868/AlgorithmExample | f1f5746a3fe2915d2df6d97f946e2a1e72907bb8 | d44fb7d408abd3a1c7c720670cd827de8e96f2e0 | refs/heads/master | 2023-05-30T17:00:28.902320 | 2021-06-25T22:31:11 | 2021-06-25T22:31:11 | 230,116,960 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,432 | cpp | //
// InversePairs.cpp
// Algorithm_C
//
// Created by CHM on 2020/7/24.
// Copyright © 2020 CHM. All rights reserved.
//
#include "InversePairs.hpp"
int inversePairsCore(int* data, int* copy, int start, int end);
int inversePairs(int* data, int length) {
if (data == nullptr || length < 0) {
return 0;
}
int* copy = new int[length];
for (int i = 0; i < length; ++i) {
copy[i] = data[i];
}
int count = inversePairsCore(data, copy, 0, length - 1);
delete [] copy;
return count;
}
int inversePairsCore(int* data, int* copy, int start, int end) {
if (start == end) {
copy[start] = data[start];
return 0;
}
int length = (end - start) / 2;
int left = inversePairsCore(copy, data, start, start + length);
int right = inversePairsCore(copy, data, start + length + 1, end);
int i = start + length;
int j = end;
int indexCopy = end;
int count = 0;
while (i >= start && j >= start + length + 1) {
if (data[i] > data[j]) {
copy[indexCopy--] = data[i--];
count += j - start - length;
} else {
copy[indexCopy--] = data[j--];
}
}
for (; i >= start; --i) {
copy[indexCopy--] = data[j];
}
for (; j >= start + length + 1; --j) {
copy[indexCopy--] = data[j];
}
return left + right + count;
}
| [
"994483868@qq.com"
] | 994483868@qq.com |
52e4cc23e003150fe09e941c298296beb1ba2a07 | 5e6df6a0296bbdbcc71712b925a99f4ef6a42732 | /trees/4.5.cpp | 1577cd275371aaebe2708b2dd13b4bfe3facfc53 | [] | no_license | olegtsts/interview_tasks | a3ffbc71627c3ae4baa2fecffd02dd2f32b1cd05 | 83eeb468ece39262567228d1e9b8dfbe3ad1299d | refs/heads/master | 2021-08-10T16:09:56.170959 | 2017-11-12T19:41:16 | 2017-11-12T19:41:16 | 109,197,309 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 699 | cpp | #include "binary_tree.hpp"
#include <iostream>
Node* GetNextInOrder(Node* node) {
if (node->right) {
node = node->right;
while (node->left) {
node = node->left;
}
return node;
} else {
while (node->parent && node == node->parent->right) {
node = node->parent;
}
return node->parent;
}
}
int main() {
BinaryTree binary_tree;
std::cin >> binary_tree;
size_t vertex;
std::cin >> vertex;
Node* next_node = GetNextInOrder(binary_tree.GetNode(vertex));
if (next_node) {
std::cout << next_node->index;
} else {
std::cout << "Traverse is over\n";
}
return 0;
}
| [
"olegtsts@gmail.com"
] | olegtsts@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.