blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905
values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 115
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e73ded2700d011b3dfdf7aead6296db1964f945b | 0db8b08b053afbc4dbc21217b91287bee2fe5321 | /Nth Digit/Method.cpp | d5895e7bbbc8305f026eefdd0f878119c0970e5c | [] | no_license | hanrick2000/LeetCode-7 | ffae0abae6cacc2b2d5064157fe95b538b820375 | ed3cd37028d3c346a9be9ba54eff2b615f658000 | refs/heads/master | 2020-12-22T21:24:33.734588 | 2018-08-22T05:50:45 | 2018-08-22T05:50:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,056 | cpp | //Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...
//
//Note:
//n is positive and will fit within the range of a 32-bit signed integer (n < 231).
//
//Example 1:
//
//Input:
//3
//
//Output:
//3
//Example 2:
//
//Input:
//11
//
//Output:
//0
//
//Explanation:
//The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10.
分为三步,第一步求出它是几位数,一位数共有9个数字,二位数共有90*2个数字。。。
第二步求出它是哪个数。 第三步求出它是这个数哪一位数字。注意溢出。。。
class Solution {
public:
int findNthDigit(int n) {
long long m = 9, len = 0 ,n1 = n;
while (n1 > 0) {
++len;
n1 -= len * m;
m*=10;
}
n1 += len*m/10;
long long t = 1;
for(int i = 0; i < len-1-(n1-1)%len; ++i) {
t*=10;
}
return ((m/90+(n1-1)/len)/t)%10;
}
}; | [
"qiuyangy@usc.edu"
] | qiuyangy@usc.edu |
745d95110a208855b27df11213a48a8328650b1d | 2497738dabdcd3d7ccf38ccf7b08455913dece47 | /src/Reader/AsagiModule.cpp | 5f42d6c32236f659eaf2c21f5f1739bff093b260 | [
"BSD-3-Clause"
] | permissive | VMPW/SeisSol | e5b628b3e68bcbe741bd390ce65d084cf8545ecd | 641e6a2d1e49173142f85688fbf8e40828f0c37a | refs/heads/master | 2023-02-26T07:50:57.906557 | 2021-01-28T22:07:27 | 2021-01-28T22:07:27 | 274,423,469 | 0 | 0 | BSD-3-Clause | 2020-06-23T14:12:07 | 2020-06-23T14:12:06 | null | UTF-8 | C++ | false | false | 3,306 | cpp | /**
* @file
* This file is part of SeisSol.
*
* @author Sebastian Rettenberger (sebastian.rettenberger AT tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger)
*
* @section LICENSE
* Copyright (c) 2016-2017, SeisSol Group
* 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.
*
* 3. Neither the name of the copyright holder 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.
*
* @section DESCRIPTION
* Velocity field reader Fortran interface
*/
#ifdef _OPENMP
#include <omp.h>
#endif // _OPENMP
#include <string>
#include "utils/env.h"
#include "AsagiModule.h"
seissol::asagi::AsagiModule::AsagiModule()
: m_mpiMode(getMPIMode()), m_totalThreads(getTotalThreads())
{
// Register for the pre MPI hook
Modules::registerHook(*this, seissol::PRE_MPI);
// Emit a warning/error later
// TODO use a general logger that can buffer log messages and emit them later
if (m_mpiMode == MPI_UNKNOWN) {
Modules::registerHook(*this, seissol::POST_MPI_INIT);
} else if (m_mpiMode == MPI_COMM_THREAD && m_totalThreads == 1) {
m_mpiMode = MPI_WINDOWS;
Modules::registerHook(*this, seissol::POST_MPI_INIT);
}
}
seissol::asagi::AsagiModule seissol::asagi::AsagiModule::instance;
seissol::asagi::MPI_Mode seissol::asagi::AsagiModule::getMPIMode()
{
#ifdef USE_MPI
std::string mpiModeName = utils::Env::get(ENV_MPI_MODE, "WINDOWS");
if (mpiModeName == "WINDOWS")
return MPI_WINDOWS;
if (mpiModeName == "COMM_THREAD")
return MPI_COMM_THREAD;
if (mpiModeName == "OFF")
return MPI_OFF;
return MPI_UNKNOWN;
#else // USE_MPI
return MPI_OFF;
#endif // USE_MPI
}
int seissol::asagi::AsagiModule::getTotalThreads()
{
int totalThreads = 1;
#ifdef _OPENMP
totalThreads = omp_get_max_threads();
#ifdef USE_COMM_THREAD
totalThreads++;
#endif // USE_COMM_THREAD
#endif // _OPENMP
return totalThreads;
}
const char* seissol::asagi::AsagiModule::ENV_MPI_MODE = "SEISSOL_ASAGI_MPI_MODE"; | [
"rettenbs@in.tum.de"
] | rettenbs@in.tum.de |
2d57fe6c8773f924a04ad9208721965b15833d55 | a5e0ccb723c6cb118915c4d16447042783b7a8bb | /src/huffman/Huffman_PQ_generateTree.cpp | 891af6d2b1f89bcf619b79fbbfb3d779460b4efb | [] | no_license | wangfanstar/dsa | 4f358d0980e1e0919d4c42759d5954141b321dbb | 1b8941447d75f0892185c9800a8fa4fcbed4f1ac | refs/heads/master | 2021-03-01T05:27:26.354154 | 2020-03-08T05:31:58 | 2020-03-08T05:31:58 | 245,757,241 | 5 | 2 | null | null | null | null | GB18030 | C++ | false | false | 1,787 | cpp | /******************************************************************************************
* Data Structures in C++
* ISBN: 7-302-33064-6 & 7-302-33065-3 & 7-302-29652-2 & 7-302-26883-3
* Junhui DENG, deng@tsinghua.edu.cn
* Computer Science & Technology, Tsinghua University
* Copyright (c) 2003-2019. All rights reserved.
******************************************************************************************/
/*DSA*/#include "Huffman_PQ.h"
/******************************************************************************************
* Huffman树构造算法:对传入的Huffman森林forest逐步合并,直到成为一棵树
******************************************************************************************
* forest基于优先级队列实现,此算法适用于符合PQ接口的任何实现方式
* 为Huffman_PQ_List、Huffman_PQ_ComplHeap和Huffman_PQ_LeftHeap共用
* 编译前对应工程只需设置相应标志:DSA_PQ_List、DSA_PQ_ComplHeap或DSA_PQ_LeftHeap
******************************************************************************************/
HuffTree* generateTree ( HuffForest* forest ) {
while ( 1 < forest->size() ) {
HuffTree* s1 = forest->delMax(); HuffTree* s2 = forest->delMax();
HuffTree* s = new HuffTree();
/*DSA*/printf ( "Merging " ); print ( s1->root()->data ); printf ( " with " ); print ( s2->root()->data ); printf ( " ...\n" );
s->insertAsRoot ( HuffChar ( '^', s1->root()->data.weight + s2->root()->data.weight ) );
s->attachAsLC ( s->root(), s1 ); s->attachAsRC ( s->root(), s2 );
forest->insert ( s ); //将合并后的Huffman树插回Huffman森林
}
HuffTree* tree = forest->delMax(); //至此,森林中的最后一棵树
return tree; //即全局Huffman编码树
} | [
"wangfanstar@163.com"
] | wangfanstar@163.com |
171db74313651dd2b0e7434637023304246f39f8 | ddf445d763f329524ae690f86866e3b305bd136b | /qt-everywhere/include/Qt/qnetworksession.h | e7fffac534232cb0cc657a92c75f0dde3f6e0cf5 | [] | no_license | Harxon/rootfs_net | 32d3d51c479047b0d51a81b3aa0078b7f90b04b9 | e3b42ca325f4bb6742c1ce8950fc4288dc16276e | refs/heads/master | 2020-06-20T12:41:57.330230 | 2016-11-27T03:43:06 | 2016-11-27T03:43:06 | 74,865,203 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,132 | h | /****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNETWORKSESSION_H
#define QNETWORKSESSION_H
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
#include <QtNetwork/qnetworkinterface.h>
#include <QtCore/qvariant.h>
#include <QtNetwork/qnetworkconfiguration.h>
#ifndef QT_NO_BEARERMANAGEMENT
#if defined(Q_OS_WIN) && defined(interface)
#undef interface
#endif
QT_BEGIN_HEADER
#ifndef QT_MOBILITY_BEARER
#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
QT_MODULE(Network)
#define QNetworkSessionExport Q_NETWORK_EXPORT
#else
#include "qmobilityglobal.h"
QTM_BEGIN_NAMESPACE
#define QNetworkSessionExport Q_BEARER_EXPORT
#endif
class QNetworkSessionPrivate;
class QNetworkSessionExport QNetworkSession : public QObject
{
Q_OBJECT
public:
enum State {
Invalid = 0,
NotAvailable,
Connecting,
Connected,
Closing,
Disconnected,
Roaming
};
enum SessionError {
UnknownSessionError = 0,
SessionAbortedError,
RoamingError,
OperationNotSupportedError,
InvalidConfigurationError
};
#ifndef QT_MOBILITY_BEARER
QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0);
#else
explicit QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0);
#endif
virtual ~QNetworkSession();
bool isOpen() const;
QNetworkConfiguration configuration() const;
#ifndef QT_NO_NETWORKINTERFACE
QNetworkInterface interface() const;
#endif
State state() const;
SessionError error() const;
QString errorString() const;
QVariant sessionProperty(const QString& key) const;
void setSessionProperty(const QString& key, const QVariant& value);
quint64 bytesWritten() const;
quint64 bytesReceived() const;
quint64 activeTime() const;
bool waitForOpened(int msecs = 30000);
public Q_SLOTS:
void open();
void close();
void stop();
//roaming related slots
void migrate();
void ignore();
void accept();
void reject();
Q_SIGNALS:
void stateChanged(QNetworkSession::State);
void opened();
void closed();
void error(QNetworkSession::SessionError);
void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless);
void newConfigurationActivated();
protected:
virtual void connectNotify(const char *signal);
virtual void disconnectNotify(const char *signal);
private:
QNetworkSessionPrivate* d;
friend class QNetworkSessionPrivate;
};
#ifndef QT_MOBILITY_BEARER
QT_END_NAMESPACE
#else
QTM_END_NAMESPACE
#endif
QT_END_HEADER
#endif // QT_NO_BEARERMANAGEMENT
#endif //QNETWORKSESSION_H
| [
"haoxs@hqyj.com"
] | haoxs@hqyj.com |
ab16548fc0e9a2e53e5825acc20551c5f3327bff | 7aa595c8d2fd3e74489327217c6b0c9f1ad548ba | /twenty.cpp | f8ca4fc0fcb169ae833da741671d66dac0a83567 | [] | no_license | alindsharmasimply/CompetitivePractice | bdcda6693abf6e5c2815061f28fe3753918c9550 | d04f41ab543e43389f3daf0a80e8e64a1aed8c1c | refs/heads/master | 2021-01-22T02:43:03.752899 | 2017-11-08T14:25:07 | 2017-11-08T14:25:07 | 102,251,155 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,194 | cpp | #include <iostream>
using namespace std;
struct node {
int data;
node* next;
};
node* head;
node* second_Half;
bool palin = false;
node* getNewNode(int x)
{
node* temp = new node();
temp->data = x;
temp->next = NULL;
return temp;
}
void insert(int x, int n) {
node* temp = getNewNode(x);
node* temp1 = head;
if (n==1) {
temp->next = head;
head = temp;
}
else
{
for (int i = 0; i < n - 2; i++) {
temp1 = temp1->next;
}
temp->next = temp1->next;
temp1->next = temp;
}
}
void reverse(node** hh) {
node* prev = NULL;
node* current = *hh;
node* next;
while (current != NULL) {
next = current->next;
current->next = prev;
prev = current;
current = next;
}
*hh = prev;
}
bool compareLists(){
node* temp1 = head;
node* temp2 = second_Half;
while (temp1 && temp2) {
if (temp1->data == temp2->data) {
temp1 = temp1->next;
temp2 = temp2->next;
}
else
return false;
}
if (temp1 == NULL && temp2 == NULL) {
return true;
}
return false;
}
void problem() {
node* slowP = head;
node* fastP = head;
node* slow_Prev;
node* midnode = NULL;
while(fastP != NULL && fastP->next != NULL) {
fastP = fastP->next->next;
slow_Prev = slowP;
slowP = slowP->next;
}
if (fastP != NULL) {
midnode = slowP;
slowP = slowP->next;
}
second_Half = slowP;
slow_Prev->next = NULL;
reverse(&second_Half);
palin = compareLists();
if (midnode != NULL) {
slow_Prev->next = midnode;
midnode->next = second_Half;
}
else{
slow_Prev->next = second_Half;
}
if (palin == true) {
std::cout << "The list is a palindrome " << '\n';
}
else{
std::cout << "The list is not a palindrome " << '\n';
}
}
int main(int argc, char const *argv[]) {
head = NULL;
insert(2,1);
insert(3,2);
insert(6,3);
insert(8,4);
insert(8,5);
insert(6,6);
insert(4,7);
insert(2,8);
problem();
return 0;
}
| [
"alindsharmasimply@gmail.com"
] | alindsharmasimply@gmail.com |
df9d23f457fed666974712671d18efeab1094ca9 | 735c881e4840cab86572428116a2d88275f19f05 | /build/SimpleRenderEngine/SimpleRenderEngine/3rdParty/include/Simplygon/SimplygonSDKLoader.cpp | 4694addd62fb7633399b0c6c745f015611c9a318 | [] | no_license | Graphics-Physics-Libraries/SimpleRenderEngine-1 | 860037dd583260cde52193e31ee24a29e9c82010 | 1ae5db69dad27432302440c700cca22d4aea4ca6 | refs/heads/master | 2020-07-14T17:43:44.782834 | 2018-12-24T10:18:11 | 2018-12-24T10:18:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,185 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <tchar.h>
#include "SimplygonSDKLoader.h"
static std::vector<std::basic_string<TCHAR>> AdditionalSearchPaths;
#ifdef _WIN32
#include <windows.h>
#include <shlobj.h>
#include <process.h>
#include <io.h>
typedef int (CALLBACK* LPINITIALIZESIMPLYGONSDK)( LPCTSTR license_data , SimplygonSDK::ISimplygonSDK **pInterfacePtr );
typedef void (CALLBACK* LPDEINITIALIZESIMPLYGONSDK)();
typedef void (CALLBACK* LPGETINTERFACEVERSIONSIMPLYGONSDK)( char *deststring );
typedef int (CALLBACK* LPPOLLLOGSIMPLYGONSDK)( char *destbuffer , int max_length );
#define PUBLICBUILD
namespace SimplygonSDK
{
static LPINITIALIZESIMPLYGONSDK InitializeSimplygonSDKPtr = NULL;
static LPDEINITIALIZESIMPLYGONSDK DeinitializeSimplygonSDKPtr = NULL;
static LPGETINTERFACEVERSIONSIMPLYGONSDK GetInterfaceVersionSimplygonSDKPtr = NULL;
static LPPOLLLOGSIMPLYGONSDK PollLogSimplygonSDKPtr = NULL;
static HINSTANCE hDLL = NULL; // Handle to SimplygonSDK DLL
static int LoadError = 0; // if the load failed, this contains the error
// critical sections, process-local mutexes
class rcriticalsection
{
private:
CRITICAL_SECTION cs;
public:
rcriticalsection() { ::InitializeCriticalSection(&cs); }
~rcriticalsection() { ::DeleteCriticalSection(&cs); }
void Enter() { EnterCriticalSection(&cs); }
void Leave() { LeaveCriticalSection(&cs); }
};
static int GetStringFromRegistry( LPCTSTR keyid , LPCTSTR valueid , LPTSTR dest )
{
HKEY reg_key;
if( RegOpenKey( HKEY_LOCAL_MACHINE , keyid , ®_key ) != ERROR_SUCCESS )
return SimplygonSDK::SG_ERROR_NOLICENSE;
// read the value from the key
DWORD path_size = MAX_PATH;
if( RegQueryValueEx( reg_key , valueid , NULL , NULL , (unsigned char *)dest , &path_size ) != ERROR_SUCCESS )
return SimplygonSDK::SG_ERROR_NOLICENSE;
dest[path_size] = 0;
// close the key
RegCloseKey( reg_key );
return SimplygonSDK::SG_ERROR_NOERROR;
}
inline LPTSTR ConstCharPtrToLPTSTR(const char * stringToConvert)
{
size_t newsize = strlen(stringToConvert)+1;
LPTSTR returnString = (LPTSTR)malloc(newsize * sizeof(TCHAR));
#ifndef _UNICODE
memcpy( returnString , stringToConvert , newsize );
#else
size_t convertedChars = 0;
mbstowcs_s(&convertedChars, returnString, newsize, stringToConvert, _TRUNCATE);
#endif // _UNICODE
return returnString;
}
static bool FileExists( LPCTSTR path )
{
DWORD v = ::GetFileAttributes( path );
if( v == INVALID_FILE_ATTRIBUTES )
{
return false;
}
return true;
}
static std::basic_string<TCHAR> GetInstallationPath()
{
TCHAR InstallationPath[MAX_PATH];
// get the installation path string from the registry
if( GetStringFromRegistry( _T("Software\\DonyaLabs\\SimplygonSDK") , _T("InstallationPath") , InstallationPath ) != 0 )
{
return std::basic_string<TCHAR>(_T(""));
}
size_t t = _tcslen(InstallationPath);
if( InstallationPath[t] != _T('\\') )
{
InstallationPath[t] = _T('\\');
InstallationPath[t+1] = _T('\0');
}
// append a backslash
return InstallationPath;
}
static std::basic_string<TCHAR> GetLicensePath()
{
TCHAR AppDataPath[MAX_PATH];
// Get the common appdata path
if( SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA, NULL, 0, AppDataPath ) != 0 )
{
return std::basic_string<TCHAR>(_T(""));
}
// append the path to Simplygon SDK
return std::basic_string<TCHAR>(AppDataPath) + _T("\\DonyaLabs\\SimplygonSDK\\");
}
static std::basic_string<TCHAR> GetApplicationPath()
{
TCHAR Path[MAX_PATH];
TCHAR drive[_MAX_DRIVE];
TCHAR dir[_MAX_DIR];
TCHAR fname[_MAX_FNAME];
TCHAR ext[_MAX_EXT];
if( GetModuleFileName( NULL , Path , MAX_PATH ) == NULL )
{
return std::basic_string<TCHAR>(_T(""));
}
_tsplitpath_s( Path, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT );
_tmakepath_s( Path, _MAX_PATH, drive, dir, _T(""), _T("") );
return Path;
}
static std::basic_string<TCHAR> GetWorkingDirectory()
{
TCHAR dir[MAX_PATH];
GetCurrentDirectory(MAX_PATH, dir);
return dir;
}
static std::basic_string<TCHAR> GetLibraryDirectory( std::basic_string<TCHAR> path )
{
TCHAR Directory[_MAX_PATH];
TCHAR drive[_MAX_DRIVE];
TCHAR dir[_MAX_DIR];
TCHAR fname[_MAX_FNAME];
TCHAR ext[_MAX_EXT];
_tsplitpath_s( path.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT );
_tmakepath_s( Directory, _MAX_PATH, drive, dir, _T(""), _T("") );
return Directory;
}
static bool DynamicLibraryIsLoaded()
{
if(hDLL == NULL)
{
return false;
}
return true;
}
static void UnloadDynamicLibrary()
{
if( !DynamicLibraryIsLoaded() )
return;
FreeLibrary(hDLL);
hDLL = NULL;
InitializeSimplygonSDKPtr = NULL;
DeinitializeSimplygonSDKPtr = NULL;
GetInterfaceVersionSimplygonSDKPtr = NULL;
PollLogSimplygonSDKPtr = NULL;
}
static bool LoadOSLibrary( std::basic_string<TCHAR> path )
{
// if no file exists, just return
if( !FileExists( path.c_str() ) )
{
return false;
}
// get the lib directory, it should be initialized in its directory
std::basic_string<TCHAR> lib_dir = GetLibraryDirectory( path );
std::basic_string<TCHAR> curr_dir = GetWorkingDirectory();
// move to the dir where the library is
SetCurrentDirectory( lib_dir.c_str() );
// try loading the library
hDLL = LoadLibrary( path.c_str() );
// move back to the previous dir
SetCurrentDirectory( curr_dir.c_str() );
// now, check if the library was loaded
if( !DynamicLibraryIsLoaded() )
{
// load failed, probably a missing dependency
TCHAR buffer[400];
DWORD err = GetLastError();
_stprintf_s(buffer,MAX_PATH,_T("Loading the Simplygon DLL failed, which is in most cases because of a missing dependency, are all dependencies installed? Please try reinstalling Simplygon. GetLastError returns %d\n"), err);
OutputDebugString(buffer);
// set the error
LoadError = SimplygonSDK::SG_ERROR_LOADFAILED;
return false;
}
// setup the pointers
InitializeSimplygonSDKPtr = (LPINITIALIZESIMPLYGONSDK)GetProcAddress(hDLL,"InitializeSimplygonSDK");
DeinitializeSimplygonSDKPtr = (LPDEINITIALIZESIMPLYGONSDK)GetProcAddress(hDLL,"DeinitializeSimplygonSDK");
GetInterfaceVersionSimplygonSDKPtr = (LPGETINTERFACEVERSIONSIMPLYGONSDK)GetProcAddress(hDLL,"GetInterfaceVersionSimplygonSDK");
PollLogSimplygonSDKPtr = (LPPOLLLOGSIMPLYGONSDK)GetProcAddress(hDLL,"PollLogSimplygonSDK");
if( InitializeSimplygonSDKPtr==NULL ||
DeinitializeSimplygonSDKPtr==NULL ||
GetInterfaceVersionSimplygonSDKPtr==NULL )
{
// load failed, invalid version
TCHAR buffer[400];
_stprintf_s(buffer,MAX_PATH,_T("The Simplygon DLL loaded, but the .dll functions could not be retrieved, this is probably not a Simplygon dll file, or it is corrupted. Please reinstall Simplygon\n"));
OutputDebugString(buffer);
// set error
LoadError = SimplygonSDK::SG_ERROR_WRONGVERSION;
UnloadDynamicLibrary();
return false;
}
// check the version string
char versionstring[200];
GetInterfaceVersionSimplygonSDKPtr( versionstring );
const SimplygonSDK::rchar *header_version = SimplygonSDK::GetInterfaceVersionHash();
if( strcmp (versionstring,header_version) != 0 )
{
// load failed, invalid version
TCHAR buffer[400];
LPTSTR pheader_version = ConstCharPtrToLPTSTR(header_version);
LPTSTR pversionstring = ConstCharPtrToLPTSTR(versionstring);
_stprintf_s(buffer,MAX_PATH,_T("The Simplygon DLL loaded, but the interface version of the header is not the same as the library.\n\tHeader: %s\n\tLibrary: %s\n"),pheader_version,pversionstring);
OutputDebugString(buffer);
free(pheader_version);
free(pversionstring);
// set error
LoadError = SimplygonSDK::SG_ERROR_WRONGVERSION;
UnloadDynamicLibrary();
return false;
}
// loaded successfully
TCHAR buffer[400];
LPTSTR pversionstring = ConstCharPtrToLPTSTR(versionstring);
_stprintf_s(buffer,MAX_PATH,_T("The Simplygon DLL was found and loaded successfully!\n\tInterface hash: %s \n"),versionstring);
OutputDebugString(buffer);
free(pversionstring);
LoadError = SimplygonSDK::SG_ERROR_NOERROR;
return true;
}
static bool FindNamedDynamicLibrary( std::basic_string<TCHAR> DLLName )
{
std::basic_string<TCHAR> InstallationPath = GetInstallationPath();
std::basic_string<TCHAR> ApplicationPath = GetApplicationPath();
std::basic_string<TCHAR> WorkingPath = GetWorkingDirectory() + _T("/");
// try additional paths first, so they are able to override
for( size_t i=0; i<AdditionalSearchPaths.size(); ++i )
{
if( LoadOSLibrary( AdditionalSearchPaths[i] + DLLName ) )
{
return true;
}
}
// try local application path first
if( LoadOSLibrary( ApplicationPath + DLLName ) )
{
return true;
}
// next try installation path
if( !InstallationPath.empty() )
{
if( LoadOSLibrary( InstallationPath + DLLName ) )
{
return true;
}
}
// try working directory as well
if( !WorkingPath.empty() )
{
if( LoadOSLibrary( WorkingPath + DLLName ) )
{
return true;
}
}
return false;
}
static bool FindDynamicLibrary( LPCTSTR SDKPath )
{
std::basic_string<TCHAR> DLLName;
if( SDKPath != NULL )
{
// load from explicit place, fail if not found
if( LoadOSLibrary( std::basic_string<TCHAR>(SDKPath) ) )
{
return true;
}
return false;
}
// if debug version, try debug build first
#ifdef _DEBUG
#ifdef _WIN64
DLLName = _T("SimplygonSDKRuntimeDebugx64.dll");
#else
DLLName = _T("SimplygonSDKRuntimeDebugWin32.dll");
#endif
if( FindNamedDynamicLibrary( DLLName ) )
{
return true;
}
#endif//_DEBUG
// if debugrelease version, try that
#ifdef REDEBUG
#ifdef _WIN64
DLLName = _T("SimplygonSDKRuntimeDebugReleasex64.dll");
#else
DLLName = _T("SimplygonSDKRuntimeDebugReleaseWin32.dll");
#endif
if( FindNamedDynamicLibrary( DLLName ) )
{
return true;
}
#endif//REDEBUG
// next (or if release) try release builds
#ifdef _WIN64
DLLName = _T("SimplygonSDKRuntimeReleasex64.dll");
#else
DLLName = _T("SimplygonSDKRuntimeReleaseWin32.dll");
#endif
if( FindNamedDynamicLibrary( DLLName ) )
{
return true;
}
LoadError = SimplygonSDK::SG_ERROR_FILENOTFOUND;
return false;
}
static bool LoadDynamicLibrary( LPCTSTR SDKPath )
{
LoadError = SimplygonSDK::SG_ERROR_NOERROR;
if( !FindDynamicLibrary(SDKPath) )
{
return false;
}
return true;
}
static std::basic_string<TCHAR> FindNamedProcess( std::basic_string<TCHAR> EXEName )
{
std::basic_string<TCHAR> InstallationPath = GetInstallationPath();
std::basic_string<TCHAR> ApplicationPath = GetApplicationPath();
std::basic_string<TCHAR> WorkingPath = GetWorkingDirectory();
// order of running batch process
std::basic_string<TCHAR> *dirs[] = {
&ApplicationPath,
&InstallationPath,
&WorkingPath,
NULL
};
// try the different paths
int i=0;
while( dirs[i] != NULL )
{
if( !dirs[i]->empty() )
{
std::basic_string<TCHAR> path = (*dirs[i]) + EXEName;
if( FileExists( path.c_str() ) )
{
return path;
}
}
++i;
}
return _T("");
}
// executes the batch process. redirects the stdout to the handle specified
// places the handle of the process into the variable that phProcess points at
static bool ExecuteProcess( const TCHAR *exepath , const TCHAR *ini_file , HANDLE *phProcess )
{
PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;
BOOL bFuncRetn = FALSE;
// Set up members of the PROCESS_INFORMATION structure.
ZeroMemory( &piProcInfo, sizeof(PROCESS_INFORMATION) );
// Set up members of the STARTUPINFO structure.
ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
siStartInfo.cb = sizeof(STARTUPINFO);
// create a command line string
TCHAR *tmp_cmdline = new TCHAR[MAX_PATH*2];
if( ini_file != NULL )
_stprintf_s(tmp_cmdline,MAX_PATH*2,_T("\"%s\" %s"),exepath,ini_file);
else
_stprintf_s(tmp_cmdline,MAX_PATH*2,_T("\"%s\" "),exepath);
// Create the child process.
bFuncRetn = CreateProcess(
NULL, // exe file path
tmp_cmdline, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo // receives PROCESS_INFORMATION
);
delete [] tmp_cmdline;
if(bFuncRetn == 0)
{
return false;
}
// function succeeded, return handle to process, release handles we will not use anymore
*phProcess = piProcInfo.hProcess;
CloseHandle(piProcInfo.hThread);
return true;
}
// waits for process to end, and returns exit value
// the process handle is also released by the function
static DWORD WaitForProcess( HANDLE &hProcess )
{
DWORD exitcode;
for(;;)
{
// check if process has ended
GetExitCodeProcess( hProcess , &exitcode );
if( exitcode != STILL_ACTIVE )
{
break;
}
// wait for it to signal.
WaitForSingleObject( hProcess , 1000 );
}
CloseHandle(hProcess);
hProcess = INVALID_HANDLE_VALUE;
return exitcode;
}
#ifdef PUBLICBUILD
static bool ReadLicense( std::basic_string<TCHAR> LicensePath , LPTSTR *dest )
{
FILE *fp = NULL;
if( _tfopen_s(&fp,LicensePath.c_str(),_T("rb")) != 0 )
{
return false;
}
int len = _filelength(_fileno(fp));
*dest = (LPTSTR)malloc(len+1);
if( fread(*dest,1,len,fp) != len )
{
fclose(fp);
return false;
}
(*dest)[len] = '\0';
fclose(fp);
return true;
}
static bool LoadLicense( LPTSTR *dest )
{
// try the local folder first
if( ReadLicense( GetApplicationPath() + _T("License.dat") , dest ) )
{
return true;
}
// next, try the common application folder
if( ReadLicense( GetLicensePath() + _T("License.dat") , dest ) )
{
return true;
}
return false;
}
#endif//PUBLICBUILD
#endif//_WIN32
#ifdef __linux__
#include<dlfcn.h>
#include <pthread.h>
typedef int (*LPINITIALIZESIMPLYGONSDK)( LPCTSTR license_data , SimplygonSDK::ISimplygonSDK **pInterfacePtr );
typedef void (*LPDEINITIALIZESIMPLYGONSDK)();
typedef void (*LPGETINTERFACEVERSIONSIMPLYGONSDK)( char *deststring );
static LPINITIALIZESIMPLYGONSDK InitializeSimplygonSDKPtr;
static LPDEINITIALIZESIMPLYGONSDK DeinitializeSimplygonSDKPtr;
static LPGETINTERFACEVERSIONSIMPLYGONSDK GetInterfaceVersionSimplygonSDKPtr;
static void *hSO = NULL; // Handle to SimplygonSDK SO
// critical sections, process-local mutexes
class rcriticalsection
{
private:
pthread_mutex_t mutex;
public:
rcriticalsection()
{
::pthread_mutexattr_t mutexattr;
::pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP);
::pthread_mutex_init(&mutex, &mutexattr);
::pthread_mutexattr_destroy(&mutexattr);
}
~rcriticalsection()
{
::pthread_mutex_destroy(&mutex);
}
void Enter() { pthread_mutex_lock(&mutex); }
void Leave() { pthread_mutex_unlock(&mutex); }
};
static bool dlErrorHandler()
{
char *dlError = dlerror();
if(dlError)
{
fprintf(stderr,"dlErrorHandler(): Error with dl function: %s\n", dlError);
return false;
}
return true; // all ok
}
static bool LoadDynamicLibrary( LPCTSTR SDKPath )
{
if( SDKPath != NULL )
{
hSO = dlopen(SDKPath, RTLD_NOW);
}
else
{
hSO = dlopen("./libSimplygonSDK.so", RTLD_NOW);
}
if( !dlErrorHandler() )
{
return false;
}
// setup the function pointers
InitializeSimplygonSDKPtr = (LPINITIALIZESIMPLYGONSDK)dlsym(hSO,"InitializeSimplygonSDK");
DeinitializeSimplygonSDKPtr = (LPDEINITIALIZESIMPLYGONSDK)dlsym(hSO,"DeinitializeSimplygonSDK");
GetInterfaceVersionSimplygonSDKPtr = (LPGETINTERFACEVERSIONSIMPLYGONSDK)dlsym(hSO,"GetInterfaceVersionSimplygonSDK");
if( InitializeSimplygonSDKPtr==NULL ||
DeinitializeSimplygonSDKPtr==NULL ||
GetInterfaceVersionSimplygonSDKPtr==NULL )
{
dlErrorHandler();
fprintf(stderr,"LoadDynamicLibrary(): Failed to retrieve all pointers.\n");
return false;
}
return true;
}
static bool DynamicLibraryIsLoaded()
{
if(hSO == NULL)
{
return false;
}
return true;
}
static void UnloadDynamicLibrary()
{
dlclose(hSO);
hSO = NULL;
}
#endif //__linux__
int InitializeSimplygonSDK( SimplygonSDK::ISimplygonSDK **pInterfacePtr , LPCTSTR SDKPath )
{
LPTSTR LicenseData = NULL;
// load the library
if( !LoadDynamicLibrary(SDKPath) )
{
return LoadError;
}
// read the license file from the installation path
#if defined(_WIN32) && defined(PUBLICBUILD)
bool license_load_succeeded = LoadLicense(&LicenseData);
#endif
// call the initalization function
int retval = InitializeSimplygonSDKPtr(LicenseData,pInterfacePtr);
// clean up the allocated data
if( LicenseData )
{
free(LicenseData);
}
if( retval == 0 )
{
TCHAR buffer[400];
LPTSTR versionstring = ConstCharPtrToLPTSTR((*pInterfacePtr)->GetVersion());
_stprintf_s(buffer,MAX_PATH,_T("Simplygon initialized and running.\n\tVersion: %s\n"),versionstring);
OutputDebugString(buffer);
free(versionstring);
}
// return retval
return retval;
}
void DeinitializeSimplygonSDK()
{
if( !DynamicLibraryIsLoaded() )
{
return;
}
DeinitializeSimplygonSDKPtr();
UnloadDynamicLibrary();
}
////////////////////////////////////////////////////////////////////////////////////
static rcriticalsection init_guard; // only one thread is allowed to run init/deinit at any time
static int init_count = 0; // a reference count of the number of Init/Deinits
static ISimplygonSDK *InterfacePtr; // the pointer to the only interface
void AddSearchPath( LPCTSTR search_path )
{
TCHAR full[MAX_PATH];
if( _tfullpath( full, search_path, MAX_PATH ) != NULL )
{
AdditionalSearchPaths.push_back( full );
}
}
void ClearAdditionalSearchPaths()
{
AdditionalSearchPaths.clear();
#if _HAS_CPP0X
// make it release its memory, so this does not give a false positive in memory leak detection
AdditionalSearchPaths.shrink_to_fit();
#endif
}
int Initialize( ISimplygonSDK **pInterfacePtr , LPCTSTR SDKPath )
{
int retval = SG_ERROR_NOERROR;
// if the interface does not exist, init it
if( InterfacePtr == NULL )
{
init_count = 0;
retval = InitializeSimplygonSDK( &InterfacePtr , SDKPath );
}
// if everything is ok, add a reference
if( retval == SG_ERROR_NOERROR )
{
++init_count;
*pInterfacePtr = InterfacePtr;
}
return retval;
}
void Deinitialize()
{
// release a reference
--init_count;
// if the reference is less or equal to 0, release the interface
if( init_count <= 0 )
{
// only release if one exists
if( InterfacePtr != NULL )
{
DeinitializeSimplygonSDK();
InterfacePtr = NULL;
}
// make sure the init_count is 0
init_count = 0;
}
}
LPCTSTR GetError( int error_code )
{
switch( error_code )
{
case SG_ERROR_NOERROR:
return _T("No error");
case SG_ERROR_NOLICENSE:
return _T("No license was found, or the license is not valid. Please install a valid license.");
case SG_ERROR_NOTINITIALIZED:
return _T("The SDK is not initialized, or no process object is loaded.");
case SG_ERROR_ALREADYINITIALIZED:
return _T("The SDK is already initialized. Please call Deinitialize() before calling Initialize() again.");
case SG_ERROR_FILENOTFOUND:
return _T("The specified file was not found.");
case SG_ERROR_INVALIDPARAM:
return _T("An invalid parameter was passed to the method");
case SG_ERROR_WRONGVERSION:
return _T("The Simplygon DLL and header file interface versions do not match");
case SG_ERROR_LOADFAILED:
return _T("the Simplygon DLL failed loading, probably because of a missing dependency");
default:
return _T("Licensing error, check log for specifics.");
}
}
int PollLog( LPTSTR dest , int max_len_dest )
{
if( dest == nullptr || max_len_dest == 0 || PollLogSimplygonSDKPtr == nullptr )
{
return 0;
}
int sz;
#ifdef UNICODE
char *tmp = new char[max_len_dest];
PollLogSimplygonSDKPtr(tmp,max_len_dest);
size_t cnv_sz;
mbstowcs_s(
&cnv_sz,
dest,
max_len_dest,
tmp,
_TRUNCATE
);
delete [] tmp;
sz = (int)cnv_sz;
#else
sz = PollLogSimplygonSDKPtr(dest,max_len_dest);
#endif//UNICODE
return sz;
}
int RunLicenseWizard( LPCTSTR batch_file )
{
// find process
std::basic_string<TCHAR> path = FindNamedProcess( _T("LicenseApplication.exe") );
if( path.empty() )
{
return SG_ERROR_FILENOTFOUND;
}
// run process
HANDLE hProcess;
bool succ = ExecuteProcess(path.c_str(),batch_file,&hProcess);
if( !succ )
{
return SG_ERROR_LOADFAILED;
}
// wait for it to end
return WaitForProcess(hProcess);
}
// end of namespace
};
| [
"897847201@qq.com"
] | 897847201@qq.com |
9a03b355744a32f0c1e38d33dc7bd0796df17770 | 76577b38f4f06db65258b19711d0df51975a6650 | /DistanceCalculator.h | faeadbd7a6c01a9ed931c82405150550e65ecc18 | [] | no_license | cmaranes/computer-graphics | 1e2a6c0c6dd2d60562e88bb295555579d4f64e99 | fd72dc5039c705073557923b2039a56dc0037303 | refs/heads/master | 2022-04-04T06:49:01.970877 | 2019-01-31T22:23:01 | 2019-01-31T22:23:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,112 | h | //
// Created by Nicolas on 01/10/2018.
//
#ifndef COMPUTER_GRAPHICS_DISTANCECALCULATOR_H
#define COMPUTER_GRAPHICS_DISTANCECALCULATOR_H
#include <iostream>
#include "Vec.h"
#include "geometry.h"
#include "Planet.h"
#include "ReferenceSystem.h"
using namespace std;
void calculateDistances(ReferenceSystem r1, ReferenceSystem r2){
Vec distance = r2.getOrigin() - r1.getOrigin();
cout << "Distancia UCS: " << distance << endl;
Vec distanceOrigin = r1.changeReferenceSystem(distance);
cout << "Distancia Origen: " << distanceOrigin << endl;
Vec distanceDestiny = r2.changeReferenceSystem(distance);
cout << "Distancia Destino: " << distanceDestiny << endl << endl;
if(distanceOrigin.getZ()<0){
std::cout<< "ERORR: The transported matter would go through the origin planet";
std::exit(1);
}
else if(distanceDestiny.getZ()<0){
std::cout<< "ERORR: The transported matter would go through the destination planet";
std::exit(1);
}
}
#endif //COMPUTER_GRAPHICS_DISTANCECALCULATOR_H
| [
"nleralopez@gmail.com"
] | nleralopez@gmail.com |
72d5dd5213fb7b30e3c35d03bdd4888de10e4619 | 76bec25f9ed509d6ca149c6af9360e72ffbf5221 | /test/isapprox.hh | a5df7d49da155cd589c634be47a0c8760c1650a1 | [
"LicenseRef-scancode-takuya-ooura",
"MIT"
] | permissive | nakakq/reim | 0e53c3e973c3ab1cb4f20baa90051b637da121d0 | 3781a63881b8e96cb813570bce4d47fb878aabc2 | refs/heads/master | 2023-02-28T11:52:51.823518 | 2021-02-06T02:30:42 | 2021-02-06T02:30:42 | 328,058,477 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 411 | hh | #pragma once
#include <stddef.h>
namespace {
static bool isapprox(double a, double b, double eta)
{
double diff = (a > b) ? a - b : b - a;
return diff <= eta;
}
static bool isapprox_array(size_t size, double* a, double* b, double eta)
{
bool is_all_matched = true;
for (size_t i = 0; i < size; i++) {
is_all_matched &= isapprox(a[i], b[i], eta);
}
return is_all_matched;
}
}
| [
"66908843+nakakq@users.noreply.github.com"
] | 66908843+nakakq@users.noreply.github.com |
948194cea68d545d2080af0012f031433aad18c5 | 7045bb4f95ada6e1669a3cd9520681b7e548c319 | /Meijer/Source/SCOTAPP/SMInSAProgressBase.h | f380b2e96437eee0f52b78d5b0d63b98db2036e4 | [] | no_license | co185057/MeijerTESTSVN | 0ffe207db43c8e881fdbad66c1c058e25fe451f5 | 3a3df97b2decc1a04e6efe7c8ab74eff5409f39f | refs/heads/master | 2023-05-30T00:19:36.524059 | 2021-06-10T08:41:31 | 2021-06-10T08:41:31 | 375,576,064 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,024 | h | //////////////////////////////////////////////////////////////////////////////////////////////////
//
// File: SMInSAProgressBase.h
//
// Description: The InSAProgress state is used when the transition from
// TB_ITEMSOLD to the next Security event, which is the SASERVER WLBD
// lookup return, and might take some time. If App doesn't wait long
// enough, the DBDClient will return local database info
//
// Author: Leila Parker
//
//////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _InSAProgressBaseSTATE
#define _InSAProgressBaseSTATE
#include "SMState.h"
#ifdef _SCOTSSF_
class DLLIMPORT
#else
class DLLEXPORT
#endif
SMInSAProgressBase : public STATE(State)
{
public:
// Constructor - must tell InSAProgressBase the mode of the
// current state that's creating it.
SMInSAProgressBase( const bool storeMode,
const bool helpMode);
SMInSAProgressBase();
SMStateBase *Deliver( const bool storeMode,
const bool helpMode);
virtual bool inProgress() {return true;}
virtual bool storeMode() {return fStoreMode;}
virtual bool helpMode() {return fHelpMode;}
virtual SMStateBase *Initialize(void);
virtual SMStateBase *OnDataBaseInfoComplete(void);
virtual void UnInitialize(void); // optional
protected:
virtual SMStateBase *TimedOut(void);
virtual SMStateBase *DMScanner(void);
virtual SMStateBase *DMCardReader(void);
virtual SMStateBase *OnBackToLGW(void); // Smart Scale reported that the unmatched weight was removed
virtual SMStateBase *OnWtIncreaseNotAllowed(void);
virtual SMStateBase *OnWtDecrease(void);
virtual SMStateBase *DMdf_EASNoMotion(void);
virtual SMStateBase *PSButtonHelp(void); // TAR246429
//229084 created a Base function for getNextStateForGoodItem LPM022503
bool fStoreMode;
bool fHelpMode;
DECLARE_DYNCREATE(SMInSAProgressBase)// MFC Runtime class/object information
};
#endif
| [
"co185057@ncr.com"
] | co185057@ncr.com |
347ecc04828929c60f57cb02da4be093668fb4eb | 5fa00ff2f8f6e903c706d6731ee69c20e5440e5f | /src/shared/CSObject.h | 395ae225b4efc18c7d44741cb8e729364bb42388 | [
"MIT"
] | permissive | 5433D-R32433/pcap-ndis6 | 9e93d8b47ebe0b68373785323be92c57c90669e2 | 77c9f02f5a774a5976e7fb96f667b5abb335d299 | refs/heads/master | 2022-01-13T07:58:42.002164 | 2019-06-24T00:24:02 | 2019-06-24T00:24:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 688 | h | //////////////////////////////////////////////////////////////////////
// Project: pcap-ndis6
// Description: WinPCAP fork with NDIS6.x support
// License: MIT License, read LICENSE file in project root for details
//
// Copyright (c) 2019 Change Dynamix, Inc.
// All Rights Reserved.
//
// https://changedynamix.io/
//
// Author: Andrey Fedorinin
//////////////////////////////////////////////////////////////////////
#pragma once
#include <windows.h>
class CCSObject
{
private:
CRITICAL_SECTION FCriticalSection;
public:
explicit CCSObject();
virtual ~CCSObject();
virtual void Enter();
virtual BOOL TryEnter();
virtual void Leave();
}; | [
"andrey.fedorinin.wrk@gmail.com"
] | andrey.fedorinin.wrk@gmail.com |
b0be189070039445b69659506d9c218c4457b4b6 | 7a4e3b6df4ff4547e30d293a85a0d277b88bdc4b | /include/ui/menu.h | bf88d9ab7895a0e77a14a9716362d96c7029b014 | [] | no_license | sigurdurje10/pizza | 3b5aa6dd99113e485350ab39a1eb54d1fd635078 | 82ec8d26ca03f7ec9b14ac9cefc2157d96273587 | refs/heads/master | 2021-08-30T02:08:03.225203 | 2017-12-15T16:32:33 | 2017-12-15T16:32:33 | 112,198,773 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 311 | h | //
// menu.h
// pizza
//
// Created by Sigurður Jökull on 27/11/2017.
// Copyright © 2017 Sigurður Jökull. All rights reserved.
//
#ifndef menu_h
#define menu_h
#include <stdio.h>
class menu {
private:
public:
menu();
void start_menu();
};
#endif /* menu_h */
| [
"sigurdurje10@ru.is"
] | sigurdurje10@ru.is |
23bc5d92577af8137597356d50059d4a5a6bd696 | 0636e69f7cc3a94c49d6d481c0120d168d832ebf | /Solutions/TopCoder/SRM_DIV2/SRM504_DIV2/Try1/MathContest.cpp | e4fe5ad9a157d9536e005e953e7a268018ab2eb0 | [] | no_license | TurtleShip/ProgrammingContests | 33e0e261341e8f78c3d8d3bd66bbad0f511acc61 | 2ebd93f9b3d50c10a10c8731d17193e69382ca9b | refs/heads/master | 2021-01-13T02:07:37.539205 | 2016-11-30T18:50:46 | 2016-11-30T18:50:46 | 18,936,833 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,060 | cpp | #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i,a,b) for(int i=a; i < b; i++)
#define REPE(i, a, b) for(int i=a; i <=b; i++)
int INF = numeric_limits<int>::max();
int nINF = numeric_limits<int>::min();
typedef long long ll;
class MathContest {
public:
int countBlack(string, int);
};
/*
white -> reverse order of the stack
black -> reverse color
count number of black balls that will be shown the audiance.
*/
bool chk[100000];
string balls;
int N;
int leftLast;
int rightLast;
int rec(int idx, int count, bool goRight, bool colorChange)
{
if(chk[idx]) return count;
if(idx == - 1 || idx == N) return count;
chk[idx] = true;
//current ball is white => Reverse order
if( (!colorChange && balls[idx] == 'W') || (colorChange && balls[idx] == 'B') )
{
if(goRight)
{
leftLast = idx + 1;
return rec(rightLast, count, !goRight, colorChange);
}
else
{
rightLast = idx - 1;
return rec(leftLast, count, !goRight, colorChange);
}
}//current ball is black => change color
else
{
if(goRight)
{
return rec(idx + 1, count + 1, goRight, !colorChange);
}
else
{
return rec(idx - 1, count + 1, goRight, !colorChange);
}
}
cout<<"NO!!! This line should never be reached!!!"<<endl;
return -1;
}
int MathContest::countBlack(string seq, int rep) {
memset(chk, false, sizeof(chk));
balls = "";
for(int i=0; i < rep; i++)
balls = balls + seq;
N = balls.size();
leftLast = 0;
rightLast = N - 1;
return rec(0, 0, true, false);
}
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, string p0, int p1, bool hasAnswer, int p2) {
cout << "Test " << testNum << ": [" << "\"" << p0 << "\"" << "," << p1;
cout << "]" << endl;
MathContest *obj;
int answer;
obj = new MathContest();
clock_t startTime = clock();
answer = obj->countBlack(p0, p1);
clock_t endTime = clock();
delete obj;
bool res;
res = true;
cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
if (hasAnswer) {
cout << "Desired answer:" << endl;
cout << "\t" << p2 << endl;
}
cout << "Your answer:" << endl;
cout << "\t" << answer << endl;
if (hasAnswer) {
res = answer == p2;
}
if (!res) {
cout << "DOESN'T MATCH!!!!" << endl;
} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
cout << "FAIL the timeout" << endl;
res = false;
} else if (hasAnswer) {
cout << "Match :-)" << endl;
} else {
cout << "OK, but is it right?" << endl;
}
cout << "" << endl;
return res;
}
int main() {
bool all_right;
all_right = true;
string p0;
int p1;
int p2;
{
// ----- test 0 -----
p0 = "BBWWB";
p1 = 1;
p2 = 2;
all_right = KawigiEdit_RunTest(0, p0, p1, true, p2) && all_right;
// ------------------
}
{
// ----- test 1 -----
p0 = "BBB";
p1 = 10;
p2 = 1;
all_right = KawigiEdit_RunTest(1, p0, p1, true, p2) && all_right;
// ------------------
}
{
// ----- test 2 -----
p0 = "BW";
p1 = 10;
p2 = 20;
all_right = KawigiEdit_RunTest(2, p0, p1, true, p2) && all_right;
// ------------------
}
{
// ----- test 3 -----
p0 = "WWWWWWWBWWWWWWWWWWWWWW";
p1 = 1;
p2 = 2;
all_right = KawigiEdit_RunTest(3, p0, p1, true, p2) && all_right;
// ------------------
}
if (all_right) {
cout << "You're a stud (at least on the example cases)!" << endl;
} else {
cout << "Some of the test cases had errors." << endl;
}
return 0;
}
// END KAWIGIEDIT TESTING
//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!
| [
"sk765@cornell.edu"
] | sk765@cornell.edu |
3a64c2e297a287a1c157d9eab926d1cd3b80858f | b39985c2ce1fa0ce89856b6470da979c69ef1924 | /src/CL_SetupGL_stub.cpp | 87736e039869458c9ceb40893baca951861a03fa | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference",
"Zlib"
] | permissive | fccm/ocaml-clanlib | bed147f5cd5454a88d27b781d7649082b0971351 | 1929f1c11d4cc9fc19e7da22826238b4cce7a07d | refs/heads/master | 2021-01-04T02:33:41.811027 | 2020-10-27T13:12:30 | 2020-10-27T13:12:30 | 305,236,647 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 860 | cpp | /* ocaml-clanlib: OCaml bindings to the ClanLib SDK
Copyright (C) 2013 Florent Monnier
This software is provided "AS-IS", without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely. */
#include <ClanLib/GL/setup_gl.h>
#include "cl_caml_incs.hpp"
#include "cl_caml_conv.hpp"
#include "CL_SetupGL_stub.hpp"
CAMLextern_C value
caml_CL_SetupGL_init(value unit)
{
CL_SetupGL *setup_gl = new CL_SetupGL;
return Val_CL_SetupGL(setup_gl);
}
CAMLextern_C value
caml_CL_SetupGL_delete(value setup_gl)
{
delete CL_SetupGL_val(setup_gl);
nullify_ptr(setup_gl);
return Val_unit;
}
// vim: sw=4 sts=4 ts=4 et
| [
"monnier.florent@gmail.com"
] | monnier.florent@gmail.com |
eaf193fc5cc07f5225480d2aeb4059432388eea0 | 8afb5afd38548c631f6f9536846039ef6cb297b9 | /_ORGS/NPM/node/deps/v8/test/cctest/test-parsing.cc | 2d56b72a8f3318bb7f5c5ba9f67e90f4b462ce27 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"SunPro"
] | permissive | bgoonz/UsefulResourceRepo2.0 | d87588ffd668bb498f7787b896cc7b20d83ce0ad | 2cb4b45dd14a230aa0e800042e893f8dfb23beda | refs/heads/master | 2023-03-17T01:22:05.254751 | 2022-08-11T03:18:22 | 2022-08-11T03:18:22 | 382,628,698 | 10 | 12 | MIT | 2022-10-10T14:13:54 | 2021-07-03T13:58:52 | null | UTF-8 | C++ | false | false | 435,370 | cc | // Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory>
#include "src/init/v8.h"
#include "src/api/api-inl.h"
#include "src/ast/ast-value-factory.h"
#include "src/ast/ast.h"
#include "src/base/enum-set.h"
#include "src/codegen/compiler.h"
#include "src/execution/execution.h"
#include "src/execution/isolate.h"
#include "src/flags/flags.h"
#include "src/objects/objects-inl.h"
#include "src/objects/objects.h"
#include "src/parsing/parse-info.h"
#include "src/parsing/parser.h"
#include "src/parsing/parsing.h"
#include "src/parsing/preparser.h"
#include "src/parsing/rewriter.h"
#include "src/parsing/scanner-character-streams.h"
#include "src/parsing/token.h"
#include "src/zone/zone-list-inl.h" // crbug.com/v8/8816
#include "test/cctest/cctest.h"
#include "test/cctest/scope-test-helper.h"
#include "test/cctest/unicode-helpers.h"
namespace v8 {
namespace internal {
namespace test_parsing {
namespace {
int* global_use_counts = nullptr;
void MockUseCounterCallback(v8::Isolate* isolate,
v8::Isolate::UseCounterFeature feature) {
++global_use_counts[feature];
}
} // namespace
// Helpers for parsing and checking that the result has no error, implemented as
// macros to report the correct test error location.
#define FAIL_WITH_PENDING_PARSER_ERROR(info, script, isolate) \
do { \
(info)->pending_error_handler()->PrepareErrors( \
(isolate), (info)->ast_value_factory()); \
(info)->pending_error_handler()->ReportErrors((isolate), (script)); \
\
i::Handle<i::JSObject> exception_handle( \
i::JSObject::cast((isolate)->pending_exception()), (isolate)); \
i::Handle<i::String> message_string = i::Handle<i::String>::cast( \
i::JSReceiver::GetProperty((isolate), exception_handle, "message") \
.ToHandleChecked()); \
(isolate)->clear_pending_exception(); \
\
String source = String::cast((script)->source()); \
\
FATAL( \
"Parser failed on:\n" \
"\t%s\n" \
"with error:\n" \
"\t%s\n" \
"However, we expected no error.", \
source.ToCString().get(), message_string->ToCString().get()); \
} while (false)
#define CHECK_PARSE_PROGRAM(info, script, isolate) \
do { \
if (!i::parsing::ParseProgram((info), script, (isolate), \
parsing::ReportStatisticsMode::kYes)) { \
FAIL_WITH_PENDING_PARSER_ERROR((info), (script), (isolate)); \
} \
\
CHECK(!(info)->pending_error_handler()->has_pending_error()); \
CHECK_NOT_NULL((info)->literal()); \
} while (false)
#define CHECK_PARSE_FUNCTION(info, shared, isolate) \
do { \
if (!i::parsing::ParseFunction((info), (shared), (isolate), \
parsing::ReportStatisticsMode::kYes)) { \
FAIL_WITH_PENDING_PARSER_ERROR( \
(info), handle(Script::cast((shared)->script()), (isolate)), \
(isolate)); \
} \
\
CHECK(!(info)->pending_error_handler()->has_pending_error()); \
CHECK_NOT_NULL((info)->literal()); \
} while (false)
bool TokenIsAutoSemicolon(Token::Value token) {
switch (token) {
case Token::SEMICOLON:
case Token::EOS:
case Token::RBRACE:
return true;
default:
return false;
}
}
TEST(AutoSemicolonToken) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsAutoSemicolon(token), Token::IsAutoSemicolon(token));
}
}
bool TokenIsAnyIdentifier(Token::Value token) {
switch (token) {
case Token::IDENTIFIER:
case Token::GET:
case Token::SET:
case Token::ASYNC:
case Token::AWAIT:
case Token::YIELD:
case Token::LET:
case Token::STATIC:
case Token::FUTURE_STRICT_RESERVED_WORD:
case Token::ESCAPED_STRICT_RESERVED_WORD:
return true;
default:
return false;
}
}
TEST(AnyIdentifierToken) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsAnyIdentifier(token), Token::IsAnyIdentifier(token));
}
}
bool TokenIsCallable(Token::Value token) {
switch (token) {
case Token::SUPER:
case Token::IDENTIFIER:
case Token::GET:
case Token::SET:
case Token::ASYNC:
case Token::AWAIT:
case Token::YIELD:
case Token::LET:
case Token::STATIC:
case Token::FUTURE_STRICT_RESERVED_WORD:
case Token::ESCAPED_STRICT_RESERVED_WORD:
return true;
default:
return false;
}
}
TEST(CallableToken) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsCallable(token), Token::IsCallable(token));
}
}
bool TokenIsValidIdentifier(Token::Value token, LanguageMode language_mode,
bool is_generator, bool disallow_await) {
switch (token) {
case Token::IDENTIFIER:
case Token::GET:
case Token::SET:
case Token::ASYNC:
return true;
case Token::YIELD:
return !is_generator && is_sloppy(language_mode);
case Token::AWAIT:
return !disallow_await;
case Token::LET:
case Token::STATIC:
case Token::FUTURE_STRICT_RESERVED_WORD:
case Token::ESCAPED_STRICT_RESERVED_WORD:
return is_sloppy(language_mode);
default:
return false;
}
UNREACHABLE();
}
TEST(IsValidIdentifierToken) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
for (size_t raw_language_mode = 0; raw_language_mode < LanguageModeSize;
raw_language_mode++) {
LanguageMode mode = static_cast<LanguageMode>(raw_language_mode);
for (int is_generator = 0; is_generator < 2; is_generator++) {
for (int disallow_await = 0; disallow_await < 2; disallow_await++) {
CHECK_EQ(
TokenIsValidIdentifier(token, mode, is_generator, disallow_await),
Token::IsValidIdentifier(token, mode, is_generator,
disallow_await));
}
}
}
}
}
bool TokenIsStrictReservedWord(Token::Value token) {
switch (token) {
case Token::LET:
case Token::YIELD:
case Token::STATIC:
case Token::FUTURE_STRICT_RESERVED_WORD:
case Token::ESCAPED_STRICT_RESERVED_WORD:
return true;
default:
return false;
}
UNREACHABLE();
}
TEST(IsStrictReservedWord) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsStrictReservedWord(token),
Token::IsStrictReservedWord(token));
}
}
bool TokenIsLiteral(Token::Value token) {
switch (token) {
case Token::NULL_LITERAL:
case Token::TRUE_LITERAL:
case Token::FALSE_LITERAL:
case Token::NUMBER:
case Token::SMI:
case Token::BIGINT:
case Token::STRING:
return true;
default:
return false;
}
UNREACHABLE();
}
TEST(IsLiteralToken) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsLiteral(token), Token::IsLiteral(token));
}
}
bool TokenIsAssignmentOp(Token::Value token) {
switch (token) {
case Token::INIT:
case Token::ASSIGN:
#define T(name, string, precedence) case Token::name:
BINARY_OP_TOKEN_LIST(T, EXPAND_BINOP_ASSIGN_TOKEN)
#undef T
return true;
default:
return false;
}
}
TEST(AssignmentOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsAssignmentOp(token), Token::IsAssignmentOp(token));
}
}
bool TokenIsArrowOrAssignmentOp(Token::Value token) {
return token == Token::ARROW || TokenIsAssignmentOp(token);
}
TEST(ArrowOrAssignmentOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsArrowOrAssignmentOp(token),
Token::IsArrowOrAssignmentOp(token));
}
}
bool TokenIsBinaryOp(Token::Value token) {
switch (token) {
case Token::COMMA:
#define T(name, string, precedence) case Token::name:
BINARY_OP_TOKEN_LIST(T, EXPAND_BINOP_TOKEN)
#undef T
return true;
default:
return false;
}
}
TEST(BinaryOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsBinaryOp(token), Token::IsBinaryOp(token));
}
}
bool TokenIsCompareOp(Token::Value token) {
switch (token) {
case Token::EQ:
case Token::EQ_STRICT:
case Token::NE:
case Token::NE_STRICT:
case Token::LT:
case Token::GT:
case Token::LTE:
case Token::GTE:
case Token::INSTANCEOF:
case Token::IN:
return true;
default:
return false;
}
}
TEST(CompareOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsCompareOp(token), Token::IsCompareOp(token));
}
}
bool TokenIsOrderedRelationalCompareOp(Token::Value token) {
switch (token) {
case Token::LT:
case Token::GT:
case Token::LTE:
case Token::GTE:
return true;
default:
return false;
}
}
TEST(IsOrderedRelationalCompareOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsOrderedRelationalCompareOp(token),
Token::IsOrderedRelationalCompareOp(token));
}
}
bool TokenIsEqualityOp(Token::Value token) {
switch (token) {
case Token::EQ:
case Token::EQ_STRICT:
return true;
default:
return false;
}
}
TEST(IsEqualityOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsEqualityOp(token), Token::IsEqualityOp(token));
}
}
bool TokenIsBitOp(Token::Value token) {
switch (token) {
case Token::BIT_OR:
case Token::BIT_XOR:
case Token::BIT_AND:
case Token::SHL:
case Token::SAR:
case Token::SHR:
case Token::BIT_NOT:
return true;
default:
return false;
}
}
TEST(IsBitOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsBitOp(token), Token::IsBitOp(token));
}
}
bool TokenIsUnaryOp(Token::Value token) {
switch (token) {
case Token::NOT:
case Token::BIT_NOT:
case Token::DELETE:
case Token::TYPEOF:
case Token::VOID:
case Token::ADD:
case Token::SUB:
return true;
default:
return false;
}
}
TEST(IsUnaryOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsUnaryOp(token), Token::IsUnaryOp(token));
}
}
bool TokenIsPropertyOrCall(Token::Value token) {
switch (token) {
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL:
case Token::PERIOD:
case Token::QUESTION_PERIOD:
case Token::LBRACK:
case Token::LPAREN:
return true;
default:
return false;
}
}
TEST(IsPropertyOrCall) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsPropertyOrCall(token), Token::IsPropertyOrCall(token));
}
}
bool TokenIsMember(Token::Value token) {
switch (token) {
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL:
case Token::PERIOD:
case Token::LBRACK:
return true;
default:
return false;
}
}
bool TokenIsTemplate(Token::Value token) {
switch (token) {
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL:
return true;
default:
return false;
}
}
bool TokenIsProperty(Token::Value token) {
switch (token) {
case Token::PERIOD:
case Token::LBRACK:
return true;
default:
return false;
}
}
TEST(IsMember) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsMember(token), Token::IsMember(token));
}
}
TEST(IsTemplate) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsTemplate(token), Token::IsTemplate(token));
}
}
TEST(IsProperty) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsProperty(token), Token::IsProperty(token));
}
}
bool TokenIsCountOp(Token::Value token) {
switch (token) {
case Token::INC:
case Token::DEC:
return true;
default:
return false;
}
}
TEST(IsCountOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsCountOp(token), Token::IsCountOp(token));
}
}
TEST(IsUnaryOrCountOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsUnaryOp(token) || TokenIsCountOp(token),
Token::IsUnaryOrCountOp(token));
}
}
bool TokenIsShiftOp(Token::Value token) {
switch (token) {
case Token::SHL:
case Token::SAR:
case Token::SHR:
return true;
default:
return false;
}
}
TEST(IsShiftOp) {
for (int i = 0; i < Token::NUM_TOKENS; i++) {
Token::Value token = static_cast<Token::Value>(i);
CHECK_EQ(TokenIsShiftOp(token), Token::IsShiftOp(token));
}
}
TEST(ScanKeywords) {
struct KeywordToken {
const char* keyword;
i::Token::Value token;
};
static const KeywordToken keywords[] = {
#define KEYWORD(t, s, d) { s, i::Token::t },
TOKEN_LIST(IGNORE_TOKEN, KEYWORD)
#undef KEYWORD
{nullptr, i::Token::IDENTIFIER}};
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(CcTest::i_isolate());
KeywordToken key_token;
char buffer[32];
for (int i = 0; (key_token = keywords[i]).keyword != nullptr; i++) {
const char* keyword = key_token.keyword;
size_t length = strlen(key_token.keyword);
CHECK(static_cast<int>(sizeof(buffer)) >= length);
{
auto stream = i::ScannerStream::ForTesting(keyword, length);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
CHECK_EQ(key_token.token, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
}
// Removing characters will make keyword matching fail.
{
auto stream = i::ScannerStream::ForTesting(keyword, length - 1);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
}
// Adding characters will make keyword matching fail.
static const char chars_to_append[] = { 'z', '0', '_' };
for (int j = 0; j < static_cast<int>(arraysize(chars_to_append)); ++j) {
i::MemMove(buffer, keyword, length);
buffer[length] = chars_to_append[j];
auto stream = i::ScannerStream::ForTesting(buffer, length + 1);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
}
// Replacing characters will make keyword matching fail.
{
i::MemMove(buffer, keyword, length);
buffer[length - 1] = '_';
auto stream = i::ScannerStream::ForTesting(buffer, length);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
}
}
}
TEST(ScanHTMLEndComments) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
i::Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope handles(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(i_isolate);
// Regression test. See:
// http://code.google.com/p/chromium/issues/detail?id=53548
// Tests that --> is correctly interpreted as comment-to-end-of-line if there
// is only whitespace before it on the line (with comments considered as
// whitespace, even a multiline-comment containing a newline).
// This was not the case if it occurred before the first real token
// in the input.
// clang-format off
const char* tests[] = {
// Before first real token.
"-->",
"--> is eol-comment",
"--> is eol-comment\nvar y = 37;\n",
"\n --> is eol-comment\nvar y = 37;\n",
"\n-->is eol-comment\nvar y = 37;\n",
"\n-->\nvar y = 37;\n",
"/* precomment */ --> is eol-comment\nvar y = 37;\n",
"/* precomment */-->eol-comment\nvar y = 37;\n",
"\n/* precomment */ --> is eol-comment\nvar y = 37;\n",
"\n/*precomment*/-->eol-comment\nvar y = 37;\n",
// After first real token.
"var x = 42;\n--> is eol-comment\nvar y = 37;\n",
"var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n",
"x/* precomment\n */ --> is eol-comment\nvar y = 37;\n",
"var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n",
"var x = 42;/*\n*/-->is eol-comment\nvar y = 37;\n",
// With multiple comments preceding HTMLEndComment
"/* MLC \n */ /* SLDC */ --> is eol-comment\nvar y = 37;\n",
"/* MLC \n */ /* SLDC1 */ /* SLDC2 */ --> is eol-comment\nvar y = 37;\n",
"/* MLC1 \n */ /* MLC2 \n */ --> is eol-comment\nvar y = 37;\n",
"/* SLDC */ /* MLC \n */ --> is eol-comment\nvar y = 37;\n",
"/* MLC1 \n */ /* SLDC1 */ /* MLC2 \n */ /* SLDC2 */ --> is eol-comment\n"
"var y = 37;\n",
nullptr
};
const char* fail_tests[] = {
"x --> is eol-comment\nvar y = 37;\n",
"\"\\n\" --> is eol-comment\nvar y = 37;\n",
"x/* precomment */ --> is eol-comment\nvar y = 37;\n",
"var x = 42; --> is eol-comment\nvar y = 37;\n",
nullptr
};
// clang-format on
// Parser/Scanner needs a stack limit.
i_isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
uintptr_t stack_limit = i_isolate->stack_guard()->real_climit();
for (int i = 0; tests[i]; i++) {
const char* source = tests[i];
auto stream = i::ScannerStream::ForTesting(source);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
i::Zone zone(i_isolate->allocator(), ZONE_NAME);
i::AstValueFactory ast_value_factory(
&zone, i_isolate->ast_string_constants(), HashSeed(i_isolate));
i::PendingCompilationErrorHandler pending_error_handler;
i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory,
&pending_error_handler,
i_isolate->counters()->runtime_call_stats(),
i_isolate->logger(), flags);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(!pending_error_handler.has_pending_error());
}
for (int i = 0; fail_tests[i]; i++) {
const char* source = fail_tests[i];
auto stream = i::ScannerStream::ForTesting(source);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
i::Zone zone(i_isolate->allocator(), ZONE_NAME);
i::AstValueFactory ast_value_factory(
&zone, i_isolate->ast_string_constants(), HashSeed(i_isolate));
i::PendingCompilationErrorHandler pending_error_handler;
i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory,
&pending_error_handler,
i_isolate->counters()->runtime_call_stats(),
i_isolate->logger(), flags);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
// Even in the case of a syntax error, kPreParseSuccess is returned.
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(pending_error_handler.has_pending_error() ||
pending_error_handler.has_error_unidentifiable_by_preparser());
}
}
TEST(ScanHtmlComments) {
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(CcTest::i_isolate());
const char* src = "a <!-- b --> c";
// Disallow HTML comments.
{
flags.set_is_module(true);
auto stream = i::ScannerStream::ForTesting(src);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
CHECK_EQ(i::Token::ILLEGAL, scanner.Next());
}
// Skip HTML comments:
{
flags.set_is_module(false);
auto stream = i::ScannerStream::ForTesting(src);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
}
}
class ScriptResource : public v8::String::ExternalOneByteStringResource {
public:
ScriptResource(const char* data, size_t length)
: data_(data), length_(length) { }
const char* data() const override { return data_; }
size_t length() const override { return length_; }
private:
const char* data_;
size_t length_;
};
TEST(StandAlonePreParser) {
v8::V8::Initialize();
i::Isolate* i_isolate = CcTest::i_isolate();
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(i_isolate);
flags.set_allow_natives_syntax(true);
i_isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
const char* programs[] = {"{label: 42}",
"var x = 42;",
"function foo(x, y) { return x + y; }",
"%ArgleBargle(glop);",
"var x = new new Function('this.x = 42');",
"var f = (x, y) => x + y;",
nullptr};
uintptr_t stack_limit = i_isolate->stack_guard()->real_climit();
for (int i = 0; programs[i]; i++) {
auto stream = i::ScannerStream::ForTesting(programs[i]);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
i::Zone zone(i_isolate->allocator(), ZONE_NAME);
i::AstValueFactory ast_value_factory(
&zone, i_isolate->ast_string_constants(), HashSeed(i_isolate));
i::PendingCompilationErrorHandler pending_error_handler;
i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory,
&pending_error_handler,
i_isolate->counters()->runtime_call_stats(),
i_isolate->logger(), flags);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(!pending_error_handler.has_pending_error());
}
}
TEST(StandAlonePreParserNoNatives) {
v8::V8::Initialize();
i::Isolate* isolate = CcTest::i_isolate();
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(isolate);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
const char* programs[] = {"%ArgleBargle(glop);", "var x = %_IsSmi(42);",
nullptr};
uintptr_t stack_limit = isolate->stack_guard()->real_climit();
for (int i = 0; programs[i]; i++) {
auto stream = i::ScannerStream::ForTesting(programs[i]);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
// Preparser defaults to disallowing natives syntax.
i::Zone zone(isolate->allocator(), ZONE_NAME);
i::AstValueFactory ast_value_factory(&zone, isolate->ast_string_constants(),
HashSeed(isolate));
i::PendingCompilationErrorHandler pending_error_handler;
i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory,
&pending_error_handler,
isolate->counters()->runtime_call_stats(),
isolate->logger(), flags);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(pending_error_handler.has_pending_error() ||
pending_error_handler.has_error_unidentifiable_by_preparser());
}
}
TEST(RegressChromium62639) {
v8::V8::Initialize();
i::Isolate* isolate = CcTest::i_isolate();
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(isolate);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
const char* program = "var x = 'something';\n"
"escape: function() {}";
// Fails parsing expecting an identifier after "function".
// Before fix, didn't check *ok after Expect(Token::Identifier, ok),
// and then used the invalid currently scanned literal. This always
// failed in debug mode, and sometimes crashed in release mode.
auto stream = i::ScannerStream::ForTesting(program);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
i::Zone zone(isolate->allocator(), ZONE_NAME);
i::AstValueFactory ast_value_factory(&zone, isolate->ast_string_constants(),
HashSeed(isolate));
i::PendingCompilationErrorHandler pending_error_handler;
i::PreParser preparser(&zone, &scanner, isolate->stack_guard()->real_climit(),
&ast_value_factory, &pending_error_handler,
isolate->counters()->runtime_call_stats(),
isolate->logger(), flags);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
// Even in the case of a syntax error, kPreParseSuccess is returned.
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
CHECK(pending_error_handler.has_pending_error() ||
pending_error_handler.has_error_unidentifiable_by_preparser());
}
TEST(PreParseOverflow) {
v8::V8::Initialize();
i::Isolate* isolate = CcTest::i_isolate();
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(isolate);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
size_t kProgramSize = 1024 * 1024;
std::unique_ptr<char[]> program(i::NewArray<char>(kProgramSize + 1));
memset(program.get(), '(', kProgramSize);
program[kProgramSize] = '\0';
uintptr_t stack_limit = isolate->stack_guard()->real_climit();
auto stream = i::ScannerStream::ForTesting(program.get(), kProgramSize);
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
i::Zone zone(isolate->allocator(), ZONE_NAME);
i::AstValueFactory ast_value_factory(&zone, isolate->ast_string_constants(),
HashSeed(isolate));
i::PendingCompilationErrorHandler pending_error_handler;
i::PreParser preparser(
&zone, &scanner, stack_limit, &ast_value_factory, &pending_error_handler,
isolate->counters()->runtime_call_stats(), isolate->logger(), flags);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseStackOverflow, result);
}
void TestStreamScanner(i::Utf16CharacterStream* stream,
i::Token::Value* expected_tokens,
int skip_pos = 0, // Zero means not skipping.
int skip_to = 0) {
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(CcTest::i_isolate());
i::Scanner scanner(stream, flags);
scanner.Initialize();
int i = 0;
do {
i::Token::Value expected = expected_tokens[i];
i::Token::Value actual = scanner.Next();
CHECK_EQ(i::Token::String(expected), i::Token::String(actual));
if (scanner.location().end_pos == skip_pos) {
scanner.SeekForward(skip_to);
}
i++;
} while (expected_tokens[i] != i::Token::ILLEGAL);
}
TEST(StreamScanner) {
v8::V8::Initialize();
const char* str1 = "{ foo get for : */ <- \n\n /*foo*/ bib";
std::unique_ptr<i::Utf16CharacterStream> stream1(
i::ScannerStream::ForTesting(str1));
i::Token::Value expectations1[] = {
i::Token::LBRACE, i::Token::IDENTIFIER, i::Token::GET, i::Token::FOR,
i::Token::COLON, i::Token::MUL, i::Token::DIV, i::Token::LT,
i::Token::SUB, i::Token::IDENTIFIER, i::Token::EOS, i::Token::ILLEGAL};
TestStreamScanner(stream1.get(), expectations1, 0, 0);
const char* str2 = "case default const {THIS\nPART\nSKIPPED} do";
std::unique_ptr<i::Utf16CharacterStream> stream2(
i::ScannerStream::ForTesting(str2));
i::Token::Value expectations2[] = {
i::Token::CASE,
i::Token::DEFAULT,
i::Token::CONST,
i::Token::LBRACE,
// Skipped part here
i::Token::RBRACE,
i::Token::DO,
i::Token::EOS,
i::Token::ILLEGAL
};
CHECK_EQ('{', str2[19]);
CHECK_EQ('}', str2[37]);
TestStreamScanner(stream2.get(), expectations2, 20, 37);
const char* str3 = "{}}}}";
i::Token::Value expectations3[] = {
i::Token::LBRACE,
i::Token::RBRACE,
i::Token::RBRACE,
i::Token::RBRACE,
i::Token::RBRACE,
i::Token::EOS,
i::Token::ILLEGAL
};
// Skip zero-four RBRACEs.
for (int i = 0; i <= 4; i++) {
expectations3[6 - i] = i::Token::ILLEGAL;
expectations3[5 - i] = i::Token::EOS;
std::unique_ptr<i::Utf16CharacterStream> stream3(
i::ScannerStream::ForTesting(str3));
TestStreamScanner(stream3.get(), expectations3, 1, 1 + i);
}
}
void TestScanRegExp(const char* re_source, const char* expected) {
auto stream = i::ScannerStream::ForTesting(re_source);
i::HandleScope scope(CcTest::i_isolate());
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(CcTest::i_isolate());
i::Scanner scanner(stream.get(), flags);
scanner.Initialize();
i::Token::Value start = scanner.peek();
CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV);
CHECK(scanner.ScanRegExpPattern());
scanner.Next(); // Current token is now the regexp literal.
i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::AstValueFactory ast_value_factory(
&zone, CcTest::i_isolate()->ast_string_constants(),
HashSeed(CcTest::i_isolate()));
const i::AstRawString* current_symbol =
scanner.CurrentSymbol(&ast_value_factory);
ast_value_factory.Internalize(CcTest::i_isolate());
i::Handle<i::String> val = current_symbol->string();
i::DisallowGarbageCollection no_alloc;
i::String::FlatContent content = val->GetFlatContent(no_alloc);
CHECK(content.IsOneByte());
i::Vector<const uint8_t> actual = content.ToOneByteVector();
for (int i = 0; i < actual.length(); i++) {
CHECK_NE('\0', expected[i]);
CHECK_EQ(expected[i], actual[i]);
}
}
TEST(RegExpScanning) {
v8::V8::Initialize();
// RegExp token with added garbage at the end. The scanner should only
// scan the RegExp until the terminating slash just before "flipperwald".
TestScanRegExp("/b/flipperwald", "b");
// Incomplete escape sequences doesn't hide the terminating slash.
TestScanRegExp("/\\x/flipperwald", "\\x");
TestScanRegExp("/\\u/flipperwald", "\\u");
TestScanRegExp("/\\u1/flipperwald", "\\u1");
TestScanRegExp("/\\u12/flipperwald", "\\u12");
TestScanRegExp("/\\u123/flipperwald", "\\u123");
TestScanRegExp("/\\c/flipperwald", "\\c");
TestScanRegExp("/\\c//flipperwald", "\\c");
// Slashes inside character classes are not terminating.
TestScanRegExp("/[/]/flipperwald", "[/]");
TestScanRegExp("/[\\s-/]/flipperwald", "[\\s-/]");
// Incomplete escape sequences inside a character class doesn't hide
// the end of the character class.
TestScanRegExp("/[\\c/]/flipperwald", "[\\c/]");
TestScanRegExp("/[\\c]/flipperwald", "[\\c]");
TestScanRegExp("/[\\x]/flipperwald", "[\\x]");
TestScanRegExp("/[\\x1]/flipperwald", "[\\x1]");
TestScanRegExp("/[\\u]/flipperwald", "[\\u]");
TestScanRegExp("/[\\u1]/flipperwald", "[\\u1]");
TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]");
TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]");
// Escaped ']'s wont end the character class.
TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]");
// Escaped slashes are not terminating.
TestScanRegExp("/\\//flipperwald", "\\/");
// Starting with '=' works too.
TestScanRegExp("/=/", "=");
TestScanRegExp("/=?/", "=?");
}
TEST(ScopeUsesArgumentsSuperThis) {
static const struct {
const char* prefix;
const char* suffix;
} surroundings[] = {
{ "function f() {", "}" },
{ "var f = () => {", "};" },
{ "class C { constructor() {", "} }" },
};
enum Expected {
NONE = 0,
ARGUMENTS = 1,
SUPER_PROPERTY = 1 << 1,
THIS = 1 << 2,
EVAL = 1 << 4
};
// clang-format off
static const struct {
const char* body;
int expected;
} source_data[] = {
{"", NONE},
{"return this", THIS},
{"return arguments", ARGUMENTS},
{"return super.x", SUPER_PROPERTY},
{"return arguments[0]", ARGUMENTS},
{"return this + arguments[0]", ARGUMENTS | THIS},
{"return this + arguments[0] + super.x",
ARGUMENTS | SUPER_PROPERTY | THIS},
{"return x => this + x", THIS},
{"return x => super.f() + x", SUPER_PROPERTY},
{"this.foo = 42;", THIS},
{"this.foo();", THIS},
{"if (foo()) { this.f() }", THIS},
{"if (foo()) { super.f() }", SUPER_PROPERTY},
{"if (arguments.length) { this.f() }", ARGUMENTS | THIS},
{"while (true) { this.f() }", THIS},
{"while (true) { super.f() }", SUPER_PROPERTY},
{"if (true) { while (true) this.foo(arguments) }", ARGUMENTS | THIS},
// Multiple nesting levels must work as well.
{"while (true) { while (true) { while (true) return this } }", THIS},
{"while (true) { while (true) { while (true) return super.f() } }",
SUPER_PROPERTY},
{"if (1) { return () => { while (true) new this() } }", THIS},
{"return function (x) { return this + x }", NONE},
{"return { m(x) { return super.m() + x } }", NONE},
{"var x = function () { this.foo = 42 };", NONE},
{"var x = { m() { super.foo = 42 } };", NONE},
{"if (1) { return function () { while (true) new this() } }", NONE},
{"if (1) { return { m() { while (true) super.m() } } }", NONE},
{"return function (x) { return () => this }", NONE},
{"return { m(x) { return () => super.m() } }", NONE},
// Flags must be correctly set when using block scoping.
{"\"use strict\"; while (true) { let x; this, arguments; }",
THIS},
{"\"use strict\"; while (true) { let x; this, super.f(), arguments; }",
SUPER_PROPERTY | THIS},
{"\"use strict\"; if (foo()) { let x; this.f() }", THIS},
{"\"use strict\"; if (foo()) { let x; super.f() }", SUPER_PROPERTY},
{"\"use strict\"; if (1) {"
" let x; return { m() { return this + super.m() + arguments } }"
"}",
NONE},
{"eval(42)", EVAL},
{"if (1) { eval(42) }", EVAL},
{"eval('super.x')", EVAL},
{"eval('this.x')", EVAL},
{"eval('arguments')", EVAL},
};
// clang-format on
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
for (unsigned j = 0; j < arraysize(surroundings); ++j) {
for (unsigned i = 0; i < arraysize(source_data); ++i) {
// Super property is only allowed in constructor and method.
if (((source_data[i].expected & SUPER_PROPERTY) ||
(source_data[i].expected == NONE)) && j != 2) {
continue;
}
int kProgramByteSize = static_cast<int>(strlen(surroundings[j].prefix) +
strlen(surroundings[j].suffix) +
strlen(source_data[i].body));
i::ScopedVector<char> program(kProgramByteSize + 1);
i::SNPrintF(program, "%s%s%s", surroundings[j].prefix,
source_data[i].body, surroundings[j].suffix);
i::Handle<i::String> source =
factory->NewStringFromUtf8(i::CStrVector(program.begin()))
.ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
// The information we're checking is only produced when eager parsing.
flags.set_allow_lazy_parsing(false);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
i::DeclarationScope::AllocateScopeInfos(&info, isolate);
CHECK_NOT_NULL(info.literal());
i::DeclarationScope* script_scope = info.literal()->scope();
CHECK(script_scope->is_script_scope());
i::Scope* scope = script_scope->inner_scope();
DCHECK_NOT_NULL(scope);
DCHECK_NULL(scope->sibling());
// Adjust for constructor scope.
if (j == 2) {
scope = scope->inner_scope();
DCHECK_NOT_NULL(scope);
DCHECK_NULL(scope->sibling());
}
// Arrows themselves never get an arguments object.
if ((source_data[i].expected & ARGUMENTS) != 0 &&
!scope->AsDeclarationScope()->is_arrow_scope()) {
CHECK_NOT_NULL(scope->AsDeclarationScope()->arguments());
}
if (IsClassConstructor(scope->AsDeclarationScope()->function_kind())) {
CHECK_IMPLIES((source_data[i].expected & SUPER_PROPERTY) != 0 ||
(source_data[i].expected & EVAL) != 0,
scope->GetHomeObjectScope()->needs_home_object());
} else {
CHECK_IMPLIES((source_data[i].expected & SUPER_PROPERTY) != 0,
scope->GetHomeObjectScope()->needs_home_object());
}
if ((source_data[i].expected & THIS) != 0) {
// Currently the is_used() flag is conservative; all variables in a
// script scope are marked as used.
CHECK(scope->GetReceiverScope()->receiver()->is_used());
}
if (is_sloppy(scope->language_mode())) {
CHECK_EQ((source_data[i].expected & EVAL) != 0,
scope->AsDeclarationScope()->sloppy_eval_can_extend_vars());
}
}
}
}
static void CheckParsesToNumber(const char* source) {
v8::V8::Initialize();
HandleAndZoneScope handles;
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
std::string full_source = "function f() { return ";
full_source += source;
full_source += "; }";
i::Handle<i::String> source_code =
factory->NewStringFromUtf8(i::CStrVector(full_source.c_str()))
.ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source_code);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_allow_lazy_parsing(false);
flags.set_is_toplevel(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
CHECK_EQ(1, info.scope()->declarations()->LengthForTest());
i::Declaration* decl = info.scope()->declarations()->AtForTest(0);
i::FunctionLiteral* fun = decl->AsFunctionDeclaration()->fun();
CHECK_EQ(fun->body()->length(), 1);
CHECK(fun->body()->at(0)->IsReturnStatement());
i::ReturnStatement* ret = fun->body()->at(0)->AsReturnStatement();
i::Literal* lit = ret->expression()->AsLiteral();
CHECK(lit->IsNumberLiteral());
}
TEST(ParseNumbers) {
CheckParsesToNumber("1.");
CheckParsesToNumber("1.34");
CheckParsesToNumber("134");
CheckParsesToNumber("134e44");
CheckParsesToNumber("134.e44");
CheckParsesToNumber("134.44e44");
CheckParsesToNumber(".44");
CheckParsesToNumber("-1.");
CheckParsesToNumber("-1.0");
CheckParsesToNumber("-1.34");
CheckParsesToNumber("-134");
CheckParsesToNumber("-134e44");
CheckParsesToNumber("-134.e44");
CheckParsesToNumber("-134.44e44");
CheckParsesToNumber("-.44");
}
TEST(ScopePositions) {
// Test the parser for correctly setting the start and end positions
// of a scope. We check the scope positions of exactly one scope
// nested in the global scope of a program. 'inner source' is the
// source code that determines the part of the source belonging
// to the nested scope. 'outer_prefix' and 'outer_suffix' are
// parts of the source that belong to the global scope.
struct SourceData {
const char* outer_prefix;
const char* inner_source;
const char* outer_suffix;
i::ScopeType scope_type;
i::LanguageMode language_mode;
};
const SourceData source_data[] = {
{" with ({}) ", "{ block; }", " more;", i::WITH_SCOPE,
i::LanguageMode::kSloppy},
{" with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE,
i::LanguageMode::kSloppy},
{" with ({}) ",
"{\n"
" block;\n"
" }",
"\n"
" more;",
i::WITH_SCOPE, i::LanguageMode::kSloppy},
{" with ({}) ", "statement;", " more;", i::WITH_SCOPE,
i::LanguageMode::kSloppy},
{" with ({}) ", "statement",
"\n"
" more;",
i::WITH_SCOPE, i::LanguageMode::kSloppy},
{" with ({})\n"
" ",
"statement;",
"\n"
" more;",
i::WITH_SCOPE, i::LanguageMode::kSloppy},
{" try {} catch ", "(e) { block; }", " more;", i::CATCH_SCOPE,
i::LanguageMode::kSloppy},
{" try {} catch ", "(e) { block; }", "; more;", i::CATCH_SCOPE,
i::LanguageMode::kSloppy},
{" try {} catch ",
"(e) {\n"
" block;\n"
" }",
"\n"
" more;",
i::CATCH_SCOPE, i::LanguageMode::kSloppy},
{" try {} catch ", "(e) { block; }", " finally { block; } more;",
i::CATCH_SCOPE, i::LanguageMode::kSloppy},
{" start;\n"
" ",
"{ let block; }", " more;", i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" start;\n"
" ",
"{ let block; }", "; more;", i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" start;\n"
" ",
"{\n"
" let block;\n"
" }",
"\n"
" more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" start;\n"
" function fun",
"(a,b) { infunction; }", " more;", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
{" start;\n"
" function fun",
"(a,b) {\n"
" infunction;\n"
" }",
"\n"
" more;",
i::FUNCTION_SCOPE, i::LanguageMode::kSloppy},
{" start;\n", "(a,b) => a + b", "; more;", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
{" start;\n", "(a,b) => { return a+b; }", "\nmore;", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
{" start;\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
{" for ", "(let x = 1 ; x < 10; ++ x) { block; }", " more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" for ", "(let x = 1 ; x < 10; ++ x) { block; }", "; more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" for ",
"(let x = 1 ; x < 10; ++ x) {\n"
" block;\n"
" }",
"\n"
" more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" for ", "(let x = 1 ; x < 10; ++ x) statement;", " more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" for ", "(let x = 1 ; x < 10; ++ x) statement",
"\n"
" more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" for ",
"(let x = 1 ; x < 10; ++ x)\n"
" statement;",
"\n"
" more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" for ", "(let x in {}) { block; }", " more;", i::BLOCK_SCOPE,
i::LanguageMode::kStrict},
{" for ", "(let x in {}) { block; }", "; more;", i::BLOCK_SCOPE,
i::LanguageMode::kStrict},
{" for ",
"(let x in {}) {\n"
" block;\n"
" }",
"\n"
" more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" for ", "(let x in {}) statement;", " more;", i::BLOCK_SCOPE,
i::LanguageMode::kStrict},
{" for ", "(let x in {}) statement",
"\n"
" more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
{" for ",
"(let x in {})\n"
" statement;",
"\n"
" more;",
i::BLOCK_SCOPE, i::LanguageMode::kStrict},
// Check that 6-byte and 4-byte encodings of UTF-8 strings do not throw
// the preparser off in terms of byte offsets.
// 2 surrogates, encode a character that doesn't need a surrogate.
{" 'foo\xED\xA0\x81\xED\xB0\x89';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// 4-byte encoding.
{" 'foo\xF0\x90\x90\x8A';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// 3-byte encoding of \u0FFF.
{" 'foo\xE0\xBF\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// 3-byte surrogate, followed by broken 2-byte surrogate w/ impossible 2nd
// byte and last byte missing.
{" 'foo\xED\xA0\x81\xED\x89';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Broken 3-byte encoding of \u0FFF with missing last byte.
{" 'foo\xE0\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Broken 3-byte encoding of \u0FFF with missing 2 last bytes.
{" 'foo\xE0';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Broken 3-byte encoding of \u00FF should be a 2-byte encoding.
{" 'foo\xE0\x83\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Broken 3-byte encoding of \u007F should be a 2-byte encoding.
{" 'foo\xE0\x81\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Unpaired lead surrogate.
{" 'foo\xED\xA0\x81';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Unpaired lead surrogate where the following code point is a 3-byte
// sequence.
{" 'foo\xED\xA0\x81\xE0\xBF\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Unpaired lead surrogate where the following code point is a 4-byte
// encoding of a trail surrogate.
{" 'foo\xED\xA0\x81\xF0\x8D\xB0\x89';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Unpaired trail surrogate.
{" 'foo\xED\xB0\x89';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// 2-byte encoding of \u00FF.
{" 'foo\xC3\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Broken 2-byte encoding of \u00FF with missing last byte.
{" 'foo\xC3';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Broken 2-byte encoding of \u007F should be a 1-byte encoding.
{" 'foo\xC1\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Illegal 5-byte encoding.
{" 'foo\xF8\xBF\xBF\xBF\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Illegal 6-byte encoding.
{" 'foo\xFC\xBF\xBF\xBF\xBF\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Illegal 0xFE byte
{" 'foo\xFE\xBF\xBF\xBF\xBF\xBF\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
// Illegal 0xFF byte
{" 'foo\xFF\xBF\xBF\xBF\xBF\xBF\xBF\xBF';\n"
" (function fun",
"(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
{" 'foo';\n"
" (function fun",
"(a,b) { 'bar\xED\xA0\x81\xED\xB0\x8B'; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
{" 'foo';\n"
" (function fun",
"(a,b) { 'bar\xF0\x90\x90\x8C'; }", ")();", i::FUNCTION_SCOPE,
i::LanguageMode::kSloppy},
{nullptr, nullptr, nullptr, i::EVAL_SCOPE, i::LanguageMode::kSloppy}};
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
for (int i = 0; source_data[i].outer_prefix; i++) {
int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix);
int kInnerLen = Utf8LengthHelper(source_data[i].inner_source);
int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix);
int kPrefixByteLen = static_cast<int>(strlen(source_data[i].outer_prefix));
int kInnerByteLen = static_cast<int>(strlen(source_data[i].inner_source));
int kSuffixByteLen = static_cast<int>(strlen(source_data[i].outer_suffix));
int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen;
int kProgramByteSize = kPrefixByteLen + kInnerByteLen + kSuffixByteLen;
i::ScopedVector<char> program(kProgramByteSize + 1);
i::SNPrintF(program, "%s%s%s",
source_data[i].outer_prefix,
source_data[i].inner_source,
source_data[i].outer_suffix);
// Parse program source.
i::Handle<i::String> source =
factory->NewStringFromUtf8(i::CStrVector(program.begin()))
.ToHandleChecked();
CHECK_EQ(source->length(), kProgramSize);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_outer_language_mode(source_data[i].language_mode);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
// Check scope types and positions.
i::Scope* scope = info.literal()->scope();
CHECK(scope->is_script_scope());
CHECK_EQ(0, scope->start_position());
CHECK_EQ(scope->end_position(), kProgramSize);
i::Scope* inner_scope = scope->inner_scope();
DCHECK_NOT_NULL(inner_scope);
DCHECK_NULL(inner_scope->sibling());
CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type);
CHECK_EQ(inner_scope->start_position(), kPrefixLen);
// The end position of a token is one position after the last
// character belonging to that token.
CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen);
}
}
TEST(DiscardFunctionBody) {
// Test that inner function bodies are discarded if possible.
// See comments in ParseFunctionLiteral in parser.cc.
const char* discard_sources[] = {
"(function f() { function g() { var a; } })();",
"(function f() { function g() { { function h() { } } } })();",
/* TODO(conradw): In future it may be possible to apply this optimisation
* to these productions.
"(function f() { 0, function g() { var a; } })();",
"(function f() { 0, { g() { var a; } } })();",
"(function f() { 0, class c { g() { var a; } } })();", */
nullptr};
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
i::FunctionLiteral* function;
for (int i = 0; discard_sources[i]; i++) {
const char* source = discard_sources[i];
i::Handle<i::String> source_code =
factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source_code);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
function = info.literal();
CHECK_NOT_NULL(function);
// The rewriter will rewrite this to
// .result = (function f(){...})();
// return .result;
// so extract the function from there.
CHECK_EQ(2, function->body()->length());
i::FunctionLiteral* inner = function->body()
->first()
->AsExpressionStatement()
->expression()
->AsAssignment()
->value()
->AsCall()
->expression()
->AsFunctionLiteral();
i::Scope* inner_scope = inner->scope();
i::FunctionLiteral* fun = nullptr;
if (!inner_scope->declarations()->is_empty()) {
fun = inner_scope->declarations()
->AtForTest(0)
->AsFunctionDeclaration()
->fun();
} else {
// TODO(conradw): This path won't be hit until the other test cases can be
// uncommented.
UNREACHABLE();
CHECK(inner->ShouldEagerCompile());
CHECK_GE(2, inner->body()->length());
i::Expression* exp = inner->body()->at(1)->AsExpressionStatement()->
expression()->AsBinaryOperation()->right();
if (exp->IsFunctionLiteral()) {
fun = exp->AsFunctionLiteral();
} else if (exp->IsObjectLiteral()) {
fun = exp->AsObjectLiteral()->properties()->at(0)->value()->
AsFunctionLiteral();
} else {
fun = exp->AsClassLiteral()
->public_members()
->at(0)
->value()
->AsFunctionLiteral();
}
}
CHECK(!fun->ShouldEagerCompile());
}
}
const char* ReadString(unsigned* start) {
int length = start[0];
char* result = i::NewArray<char>(length + 1);
for (int i = 0; i < length; i++) {
result[i] = start[i + 1];
}
result[length] = '\0';
return result;
}
enum ParserFlag {
kAllowLazy,
kAllowNatives,
};
enum ParserSyncTestResult {
kSuccessOrError,
kSuccess,
kError
};
void SetGlobalFlags(base::EnumSet<ParserFlag> flags) {
i::FLAG_allow_natives_syntax = flags.contains(kAllowNatives);
}
void SetParserFlags(i::UnoptimizedCompileFlags* compile_flags,
base::EnumSet<ParserFlag> flags) {
compile_flags->set_allow_natives_syntax(flags.contains(kAllowNatives));
}
void TestParserSyncWithFlags(i::Handle<i::String> source,
base::EnumSet<ParserFlag> flags,
ParserSyncTestResult result,
bool is_module = false, bool test_preparser = true,
bool ignore_error_msg = false) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags compile_flags =
i::UnoptimizedCompileFlags::ForToplevelCompile(
isolate, true, LanguageMode::kSloppy, REPLMode::kNo);
SetParserFlags(&compile_flags, flags);
compile_flags.set_is_module(is_module);
uintptr_t stack_limit = isolate->stack_guard()->real_climit();
// Preparse the data.
i::PendingCompilationErrorHandler pending_error_handler;
if (test_preparser) {
std::unique_ptr<i::Utf16CharacterStream> stream(
i::ScannerStream::For(isolate, source));
i::Scanner scanner(stream.get(), compile_flags);
i::Zone zone(isolate->allocator(), ZONE_NAME);
i::AstValueFactory ast_value_factory(&zone, isolate->ast_string_constants(),
HashSeed(isolate));
i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory,
&pending_error_handler,
isolate->counters()->runtime_call_stats(),
isolate->logger(), compile_flags);
scanner.Initialize();
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
}
// Parse the data
i::FunctionLiteral* function;
{
SetGlobalFlags(flags);
i::Handle<i::Script> script =
factory->NewScriptWithId(source, compile_flags.script_id());
i::ParseInfo info(isolate, compile_flags, &compile_state);
if (!i::parsing::ParseProgram(&info, script, isolate,
parsing::ReportStatisticsMode::kYes)) {
info.pending_error_handler()->PrepareErrors(isolate,
info.ast_value_factory());
info.pending_error_handler()->ReportErrors(isolate, script);
} else {
CHECK(!info.pending_error_handler()->has_pending_error());
}
function = info.literal();
}
// Check that preparsing fails iff parsing fails.
if (function == nullptr) {
// Extract exception from the parser.
CHECK(isolate->has_pending_exception());
i::Handle<i::JSObject> exception_handle(
i::JSObject::cast(isolate->pending_exception()), isolate);
i::Handle<i::String> message_string = i::Handle<i::String>::cast(
i::JSReceiver::GetProperty(isolate, exception_handle, "message")
.ToHandleChecked());
isolate->clear_pending_exception();
if (result == kSuccess) {
FATAL(
"Parser failed on:\n"
"\t%s\n"
"with error:\n"
"\t%s\n"
"However, we expected no error.",
source->ToCString().get(), message_string->ToCString().get());
}
if (test_preparser && !pending_error_handler.has_pending_error() &&
!pending_error_handler.has_error_unidentifiable_by_preparser()) {
FATAL(
"Parser failed on:\n"
"\t%s\n"
"with error:\n"
"\t%s\n"
"However, the preparser succeeded",
source->ToCString().get(), message_string->ToCString().get());
}
// Check that preparser and parser produce the same error, except for cases
// where we do not track errors in the preparser.
if (test_preparser && !ignore_error_msg &&
!pending_error_handler.has_error_unidentifiable_by_preparser()) {
i::Handle<i::String> preparser_message =
pending_error_handler.FormatErrorMessageForTest(CcTest::i_isolate());
if (!i::String::Equals(isolate, message_string, preparser_message)) {
FATAL(
"Expected parser and preparser to produce the same error on:\n"
"\t%s\n"
"However, found the following error messages\n"
"\tparser: %s\n"
"\tpreparser: %s\n",
source->ToCString().get(), message_string->ToCString().get(),
preparser_message->ToCString().get());
}
}
} else if (test_preparser && pending_error_handler.has_pending_error()) {
FATAL(
"Preparser failed on:\n"
"\t%s\n"
"with error:\n"
"\t%s\n"
"However, the parser succeeded",
source->ToCString().get(),
pending_error_handler.FormatErrorMessageForTest(CcTest::i_isolate())
->ToCString()
.get());
} else if (result == kError) {
FATAL(
"Expected error on:\n"
"\t%s\n"
"However, parser and preparser succeeded",
source->ToCString().get());
}
}
void TestParserSync(const char* source, const ParserFlag* varying_flags,
size_t varying_flags_length,
ParserSyncTestResult result = kSuccessOrError,
const ParserFlag* always_true_flags = nullptr,
size_t always_true_flags_length = 0,
const ParserFlag* always_false_flags = nullptr,
size_t always_false_flags_length = 0,
bool is_module = false, bool test_preparser = true,
bool ignore_error_msg = false) {
i::Handle<i::String> str =
CcTest::i_isolate()
->factory()
->NewStringFromUtf8(Vector<const char>(source, strlen(source)))
.ToHandleChecked();
for (int bits = 0; bits < (1 << varying_flags_length); bits++) {
base::EnumSet<ParserFlag> flags;
for (size_t flag_index = 0; flag_index < varying_flags_length;
++flag_index) {
if ((bits & (1 << flag_index)) != 0) flags.Add(varying_flags[flag_index]);
}
for (size_t flag_index = 0; flag_index < always_true_flags_length;
++flag_index) {
flags.Add(always_true_flags[flag_index]);
}
for (size_t flag_index = 0; flag_index < always_false_flags_length;
++flag_index) {
flags.Remove(always_false_flags[flag_index]);
}
TestParserSyncWithFlags(str, flags, result, is_module, test_preparser,
ignore_error_msg);
}
}
TEST(ParserSync) {
const char* context_data[][2] = {{"", ""},
{"{", "}"},
{"if (true) ", " else {}"},
{"if (true) {} else ", ""},
{"if (true) ", ""},
{"do ", " while (false)"},
{"while (false) ", ""},
{"for (;;) ", ""},
{"with ({})", ""},
{"switch (12) { case 12: ", "}"},
{"switch (12) { default: ", "}"},
{"switch (12) { ", "case 12: }"},
{"label2: ", ""},
{nullptr, nullptr}};
const char* statement_data[] = {
"{}", "var x", "var x = 1", "const x", "const x = 1", ";", "12",
"if (false) {} else ;", "if (false) {} else {}", "if (false) {} else 12",
"if (false) ;", "if (false) {}", "if (false) 12", "do {} while (false)",
"for (;;) ;", "for (;;) {}", "for (;;) 12", "continue", "continue label",
"continue\nlabel", "break", "break label", "break\nlabel",
// TODO(marja): activate once parsing 'return' is merged into ParserBase.
// "return",
// "return 12",
// "return\n12",
"with ({}) ;", "with ({}) {}", "with ({}) 12", "switch ({}) { default: }",
"label3: ", "throw", "throw 12", "throw\n12", "try {} catch(e) {}",
"try {} finally {}", "try {} catch(e) {} finally {}", "debugger",
nullptr};
const char* termination_data[] = {"", ";", "\n", ";\n", "\n;", nullptr};
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
CcTest::i_isolate()->stack_guard()->SetStackLimit(
i::GetCurrentStackPosition() - 128 * 1024);
for (int i = 0; context_data[i][0] != nullptr; ++i) {
for (int j = 0; statement_data[j] != nullptr; ++j) {
for (int k = 0; termination_data[k] != nullptr; ++k) {
int kPrefixLen = static_cast<int>(strlen(context_data[i][0]));
int kStatementLen = static_cast<int>(strlen(statement_data[j]));
int kTerminationLen = static_cast<int>(strlen(termination_data[k]));
int kSuffixLen = static_cast<int>(strlen(context_data[i][1]));
int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen +
kSuffixLen +
static_cast<int>(strlen("label: for (;;) { }"));
// Plug the source code pieces together.
i::ScopedVector<char> program(kProgramSize + 1);
int length = i::SNPrintF(program,
"label: for (;;) { %s%s%s%s }",
context_data[i][0],
statement_data[j],
termination_data[k],
context_data[i][1]);
CHECK_EQ(length, kProgramSize);
TestParserSync(program.begin(), nullptr, 0);
}
}
}
// Neither Harmony numeric literals nor our natives syntax have any
// interaction with the flags above, so test these separately to reduce
// the combinatorial explosion.
TestParserSync("0o1234", nullptr, 0);
TestParserSync("0b1011", nullptr, 0);
static const ParserFlag flags3[] = { kAllowNatives };
TestParserSync("%DebugPrint(123)", flags3, arraysize(flags3));
}
TEST(StrictOctal) {
// Test that syntax error caused by octal literal is reported correctly as
// such (issue 2220).
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Context::Scope context_scope(v8::Context::New(isolate));
v8::TryCatch try_catch(isolate);
const char* script =
"\"use strict\"; \n"
"a = function() { \n"
" b = function() { \n"
" 01; \n"
" }; \n"
"}; \n";
CHECK(v8_try_compile(v8_str(script)).IsEmpty());
CHECK(try_catch.HasCaught());
v8::String::Utf8Value exception(isolate, try_catch.Exception());
CHECK_EQ(0,
strcmp("SyntaxError: Octal literals are not allowed in strict mode.",
*exception));
}
void RunParserSyncTest(
const char* context_data[][2], const char* statement_data[],
ParserSyncTestResult result, const ParserFlag* flags = nullptr,
int flags_len = 0, const ParserFlag* always_true_flags = nullptr,
int always_true_len = 0, const ParserFlag* always_false_flags = nullptr,
int always_false_len = 0, bool is_module = false,
bool test_preparser = true, bool ignore_error_msg = false) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
CcTest::i_isolate()->stack_guard()->SetStackLimit(
i::GetCurrentStackPosition() - 128 * 1024);
// Experimental feature flags should not go here; pass the flags as
// always_true_flags if the test needs them.
static const ParserFlag default_flags[] = {
kAllowLazy,
kAllowNatives,
};
ParserFlag* generated_flags = nullptr;
if (flags == nullptr) {
flags = default_flags;
flags_len = arraysize(default_flags);
if (always_true_flags != nullptr || always_false_flags != nullptr) {
// Remove always_true/false_flags from default_flags (if present).
CHECK((always_true_flags != nullptr) == (always_true_len > 0));
CHECK((always_false_flags != nullptr) == (always_false_len > 0));
generated_flags = new ParserFlag[flags_len + always_true_len];
int flag_index = 0;
for (int i = 0; i < flags_len; ++i) {
bool use_flag = true;
for (int j = 0; use_flag && j < always_true_len; ++j) {
if (flags[i] == always_true_flags[j]) use_flag = false;
}
for (int j = 0; use_flag && j < always_false_len; ++j) {
if (flags[i] == always_false_flags[j]) use_flag = false;
}
if (use_flag) generated_flags[flag_index++] = flags[i];
}
flags_len = flag_index;
flags = generated_flags;
}
}
for (int i = 0; context_data[i][0] != nullptr; ++i) {
for (int j = 0; statement_data[j] != nullptr; ++j) {
int kPrefixLen = static_cast<int>(strlen(context_data[i][0]));
int kStatementLen = static_cast<int>(strlen(statement_data[j]));
int kSuffixLen = static_cast<int>(strlen(context_data[i][1]));
int kProgramSize = kPrefixLen + kStatementLen + kSuffixLen;
// Plug the source code pieces together.
i::ScopedVector<char> program(kProgramSize + 1);
int length = i::SNPrintF(program,
"%s%s%s",
context_data[i][0],
statement_data[j],
context_data[i][1]);
PrintF("%s\n", program.begin());
CHECK_EQ(length, kProgramSize);
TestParserSync(program.begin(), flags, flags_len, result,
always_true_flags, always_true_len, always_false_flags,
always_false_len, is_module, test_preparser,
ignore_error_msg);
}
}
delete[] generated_flags;
}
void RunModuleParserSyncTest(
const char* context_data[][2], const char* statement_data[],
ParserSyncTestResult result, const ParserFlag* flags = nullptr,
int flags_len = 0, const ParserFlag* always_true_flags = nullptr,
int always_true_len = 0, const ParserFlag* always_false_flags = nullptr,
int always_false_len = 0, bool test_preparser = true,
bool ignore_error_msg = false) {
RunParserSyncTest(context_data, statement_data, result, flags, flags_len,
always_true_flags, always_true_len, always_false_flags,
always_false_len, true, test_preparser, ignore_error_msg);
}
TEST(NonOctalDecimalIntegerStrictError) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {{"\"use strict\";", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"09", "09.1_2", nullptr};
RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, nullptr,
0, nullptr, 0, false, true);
}
TEST(NumericSeparator) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {
{"", ""}, {"\"use strict\";", ""}, {nullptr, nullptr}};
const char* statement_data[] = {
"1_0_0_0", "1_0e+1", "1_0e+1_0", "0xF_F_FF", "0o7_7_7", "0b0_1_0_1_0",
".3_2_1", "0.0_2_1", "1_0.0_1", ".0_1_2", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(NumericSeparatorErrors) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {
{"", ""}, {"\"use strict\";", ""}, {nullptr, nullptr}};
const char* statement_data[] = {
"1_0_0_0_", "1e_1", "1e+_1", "1_e+1", "1__0", "0x_1",
"0x1__1", "0x1_", "0_x1", "0_x_1", "0b_0101", "0b11_",
"0b1__1", "0_b1", "0_b_1", "0o777_", "0o_777", "0o7__77",
"0.0_2_1_", "0.0__21", "0_.01", "0._01", nullptr};
RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, nullptr,
0, nullptr, 0, false, true);
}
TEST(NumericSeparatorImplicitOctalsErrors) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {
{"", ""}, {"\"use strict\";", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"00_122", "0_012", "07_7_7",
"0_7_7_7", "0_777", "07_7_7_",
"07__77", "0__777", nullptr};
RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, nullptr,
0, nullptr, 0, false, true);
}
TEST(NumericSeparatorNonOctalDecimalInteger) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"09.1_2", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess, nullptr, 0, nullptr,
0, nullptr, 0, false, true);
}
TEST(NumericSeparatorNonOctalDecimalIntegerErrors) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"09_12", nullptr};
RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, nullptr,
0, nullptr, 0, false, true);
}
TEST(NumericSeparatorUnicodeEscapeSequencesErrors) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {
{"", ""}, {"'use strict'", ""}, {nullptr, nullptr}};
// https://github.com/tc39/proposal-numeric-separator/issues/25
const char* statement_data[] = {"\\u{10_FFFF}", nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(OptionalChaining) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {
{"", ""}, {"'use strict';", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"a?.b", "a?.['b']", "a?.()", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(OptionalChainingTaggedError) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {
{"", ""}, {"'use strict';", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"a?.b``", "a?.['b']``", "a?.()``", nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(Nullish) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {
{"", ""}, {"'use strict';", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"a ?? b", "a ?? b ?? c",
"a ?? b ? c : d"
"a ?? b ?? c ? d : e",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(NullishNotContained) {
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
const char* context_data[][2] = {
{"", ""}, {"'use strict';", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"a || b ?? c", "a ?? b || c",
"a && b ?? c"
"a ?? b && c",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(ErrorsEvalAndArguments) {
// Tests that both preparsing and parsing produce the right kind of errors for
// using "eval" and "arguments" as identifiers. Without the strict mode, it's
// ok to use "eval" or "arguments" as identifiers. With the strict mode, it
// isn't.
const char* context_data[][2] = {
{"\"use strict\";", ""},
{"var eval; function test_func() {\"use strict\"; ", "}"},
{nullptr, nullptr}};
const char* statement_data[] = {"var eval;",
"var arguments",
"var foo, eval;",
"var foo, arguments;",
"try { } catch (eval) { }",
"try { } catch (arguments) { }",
"function eval() { }",
"function arguments() { }",
"function foo(eval) { }",
"function foo(arguments) { }",
"function foo(bar, eval) { }",
"function foo(bar, arguments) { }",
"(eval) => { }",
"(arguments) => { }",
"(foo, eval) => { }",
"(foo, arguments) => { }",
"eval = 1;",
"arguments = 1;",
"var foo = eval = 1;",
"var foo = arguments = 1;",
"++eval;",
"++arguments;",
"eval++;",
"arguments++;",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsEvalAndArgumentsSloppy) {
// Tests that both preparsing and parsing accept "eval" and "arguments" as
// identifiers when needed.
const char* context_data[][2] = {
{"", ""}, {"function test_func() {", "}"}, {nullptr, nullptr}};
const char* statement_data[] = {"var eval;",
"var arguments",
"var foo, eval;",
"var foo, arguments;",
"try { } catch (eval) { }",
"try { } catch (arguments) { }",
"function eval() { }",
"function arguments() { }",
"function foo(eval) { }",
"function foo(arguments) { }",
"function foo(bar, eval) { }",
"function foo(bar, arguments) { }",
"eval = 1;",
"arguments = 1;",
"var foo = eval = 1;",
"var foo = arguments = 1;",
"++eval;",
"++arguments;",
"eval++;",
"arguments++;",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(NoErrorsEvalAndArgumentsStrict) {
const char* context_data[][2] = {
{"\"use strict\";", ""},
{"function test_func() { \"use strict\";", "}"},
{"() => { \"use strict\"; ", "}"},
{nullptr, nullptr}};
const char* statement_data[] = {"eval;",
"arguments;",
"var foo = eval;",
"var foo = arguments;",
"var foo = { eval: 1 };",
"var foo = { arguments: 1 };",
"var foo = { }; foo.eval = {};",
"var foo = { }; foo.arguments = {};",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
#define FUTURE_STRICT_RESERVED_WORDS_NO_LET(V) \
V(implements) \
V(interface) \
V(package) \
V(private) \
V(protected) \
V(public) \
V(static) \
V(yield)
#define FUTURE_STRICT_RESERVED_WORDS(V) \
V(let) \
FUTURE_STRICT_RESERVED_WORDS_NO_LET(V)
#define LIMITED_FUTURE_STRICT_RESERVED_WORDS_NO_LET(V) \
V(implements) \
V(static) \
V(yield)
#define LIMITED_FUTURE_STRICT_RESERVED_WORDS(V) \
V(let) \
LIMITED_FUTURE_STRICT_RESERVED_WORDS_NO_LET(V)
#define FUTURE_STRICT_RESERVED_STATEMENTS(NAME) \
"var " #NAME ";", \
"var foo, " #NAME ";", \
"try { } catch (" #NAME ") { }", \
"function " #NAME "() { }", \
"(function " #NAME "() { })", \
"function foo(" #NAME ") { }", \
"function foo(bar, " #NAME ") { }", \
#NAME " = 1;", \
#NAME " += 1;", \
"var foo = " #NAME " = 1;", \
"++" #NAME ";", \
#NAME " ++;",
// clang-format off
#define FUTURE_STRICT_RESERVED_LEX_BINDINGS(NAME) \
"let " #NAME ";", \
"for (let " #NAME "; false; ) {}", \
"for (let " #NAME " in {}) {}", \
"for (let " #NAME " of []) {}", \
"const " #NAME " = null;", \
"for (const " #NAME " = null; false; ) {}", \
"for (const " #NAME " in {}) {}", \
"for (const " #NAME " of []) {}",
// clang-format on
TEST(ErrorsFutureStrictReservedWords) {
// Tests that both preparsing and parsing produce the right kind of errors for
// using future strict reserved words as identifiers. Without the strict mode,
// it's ok to use future strict reserved words as identifiers. With the strict
// mode, it isn't.
const char* strict_contexts[][2] = {
{"function test_func() {\"use strict\"; ", "}"},
{"() => { \"use strict\"; ", "}"},
{nullptr, nullptr}};
// clang-format off
const char* statement_data[] {
LIMITED_FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS)
LIMITED_FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_LEX_BINDINGS)
nullptr
};
// clang-format on
RunParserSyncTest(strict_contexts, statement_data, kError);
// From ES2015, 13.3.1.1 Static Semantics: Early Errors:
//
// > LexicalDeclaration : LetOrConst BindingList ;
// >
// > - It is a Syntax Error if the BoundNames of BindingList contains "let".
const char* non_strict_contexts[][2] = {{"", ""},
{"function test_func() {", "}"},
{"() => {", "}"},
{nullptr, nullptr}};
const char* invalid_statements[] = {
FUTURE_STRICT_RESERVED_LEX_BINDINGS(let) nullptr};
RunParserSyncTest(non_strict_contexts, invalid_statements, kError);
}
#undef LIMITED_FUTURE_STRICT_RESERVED_WORDS
TEST(NoErrorsFutureStrictReservedWords) {
const char* context_data[][2] = {{"", ""},
{"function test_func() {", "}"},
{"() => {", "}"},
{nullptr, nullptr}};
// clang-format off
const char* statement_data[] = {
FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS)
FUTURE_STRICT_RESERVED_WORDS_NO_LET(FUTURE_STRICT_RESERVED_LEX_BINDINGS)
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsReservedWords) {
// Tests that both preparsing and parsing produce the right kind of errors for
// using future reserved words as identifiers. These tests don't depend on the
// strict mode.
const char* context_data[][2] = {
{"", ""},
{"\"use strict\";", ""},
{"var eval; function test_func() {", "}"},
{"var eval; function test_func() {\"use strict\"; ", "}"},
{"var eval; () => {", "}"},
{"var eval; () => {\"use strict\"; ", "}"},
{nullptr, nullptr}};
const char* statement_data[] = {"var super;",
"var foo, super;",
"try { } catch (super) { }",
"function super() { }",
"function foo(super) { }",
"function foo(bar, super) { }",
"(super) => { }",
"(bar, super) => { }",
"super = 1;",
"var foo = super = 1;",
"++super;",
"super++;",
"function foo super",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsLetSloppyAllModes) {
// In sloppy mode, it's okay to use "let" as identifier.
const char* context_data[][2] = {{"", ""},
{"function f() {", "}"},
{"(function f() {", "})"},
{nullptr, nullptr}};
const char* statement_data[] = {
"var let;",
"var foo, let;",
"try { } catch (let) { }",
"function let() { }",
"(function let() { })",
"function foo(let) { }",
"function foo(bar, let) { }",
"let = 1;",
"var foo = let = 1;",
"let * 2;",
"++let;",
"let++;",
"let: 34",
"function let(let) { let: let(let + let(0)); }",
"({ let: 1 })",
"({ get let() { 1 } })",
"let(100)",
"L: let\nx",
"L: let\n{x}",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(NoErrorsYieldSloppyAllModes) {
// In sloppy mode, it's okay to use "yield" as identifier, *except* inside a
// generator (see other test).
const char* context_data[][2] = {{"", ""},
{"function not_gen() {", "}"},
{"(function not_gen() {", "})"},
{nullptr, nullptr}};
const char* statement_data[] = {
"var yield;",
"var foo, yield;",
"try { } catch (yield) { }",
"function yield() { }",
"(function yield() { })",
"function foo(yield) { }",
"function foo(bar, yield) { }",
"yield = 1;",
"var foo = yield = 1;",
"yield * 2;",
"++yield;",
"yield++;",
"yield: 34",
"function yield(yield) { yield: yield (yield + yield(0)); }",
"({ yield: 1 })",
"({ get yield() { 1 } })",
"yield(100)",
"yield[100]",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(NoErrorsYieldSloppyGeneratorsEnabled) {
// In sloppy mode, it's okay to use "yield" as identifier, *except* inside a
// generator (see next test).
const char* context_data[][2] = {
{"", ""},
{"function not_gen() {", "}"},
{"function * gen() { function not_gen() {", "} }"},
{"(function not_gen() {", "})"},
{"(function * gen() { (function not_gen() {", "}) })"},
{nullptr, nullptr}};
const char* statement_data[] = {
"var yield;",
"var foo, yield;",
"try { } catch (yield) { }",
"function yield() { }",
"(function yield() { })",
"function foo(yield) { }",
"function foo(bar, yield) { }",
"function * yield() { }",
"yield = 1;",
"var foo = yield = 1;",
"yield * 2;",
"++yield;",
"yield++;",
"yield: 34",
"function yield(yield) { yield: yield (yield + yield(0)); }",
"({ yield: 1 })",
"({ get yield() { 1 } })",
"yield(100)",
"yield[100]",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsYieldStrict) {
const char* context_data[][2] = {
{"\"use strict\";", ""},
{"\"use strict\"; function not_gen() {", "}"},
{"function test_func() {\"use strict\"; ", "}"},
{"\"use strict\"; function * gen() { function not_gen() {", "} }"},
{"\"use strict\"; (function not_gen() {", "})"},
{"\"use strict\"; (function * gen() { (function not_gen() {", "}) })"},
{"() => {\"use strict\"; ", "}"},
{nullptr, nullptr}};
const char* statement_data[] = {"var yield;",
"var foo, yield;",
"try { } catch (yield) { }",
"function yield() { }",
"(function yield() { })",
"function foo(yield) { }",
"function foo(bar, yield) { }",
"function * yield() { }",
"(function * yield() { })",
"yield = 1;",
"var foo = yield = 1;",
"++yield;",
"yield++;",
"yield: 34;",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(ErrorsYieldSloppy) {
const char* context_data[][2] = {{"", ""},
{"function not_gen() {", "}"},
{"(function not_gen() {", "})"},
{nullptr, nullptr}};
const char* statement_data[] = {"(function * yield() { })", nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsGenerator) {
// clang-format off
const char* context_data[][2] = {
{ "function * gen() {", "}" },
{ "(function * gen() {", "})" },
{ "(function * () {", "})" },
{ nullptr, nullptr }
};
const char* statement_data[] = {
// A generator without a body is valid.
""
// Valid yield expressions inside generators.
"yield 2;",
"yield * 2;",
"yield * \n 2;",
"yield yield 1;",
"yield * yield * 1;",
"yield 3 + (yield 4);",
"yield * 3 + (yield * 4);",
"(yield * 3) + (yield * 4);",
"yield 3; yield 4;",
"yield * 3; yield * 4;",
"(function (yield) { })",
"(function yield() { })",
"yield { yield: 12 }",
"yield /* comment */ { yield: 12 }",
"yield * \n { yield: 12 }",
"yield /* comment */ * \n { yield: 12 }",
// You can return in a generator.
"yield 1; return",
"yield * 1; return",
"yield 1; return 37",
"yield * 1; return 37",
"yield 1; return 37; yield 'dead';",
"yield * 1; return 37; yield * 'dead';",
// Yield is still a valid key in object literals.
"({ yield: 1 })",
"({ get yield() { } })",
// And in assignment pattern computed properties
"({ [yield]: x } = { })",
// Yield without RHS.
"yield;",
"yield",
"yield\n",
"yield /* comment */"
"yield // comment\n"
"(yield)",
"[yield]",
"{yield}",
"yield, yield",
"yield; yield",
"(yield) ? yield : yield",
"(yield) \n ? yield : yield",
// If there is a newline before the next token, we don't look for RHS.
"yield\nfor (;;) {}",
"x = class extends (yield) {}",
"x = class extends f(yield) {}",
"x = class extends (null, yield) { }",
"x = class extends (a ? null : yield) { }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsYieldGenerator) {
// clang-format off
const char* context_data[][2] = {
{ "function * gen() {", "}" },
{ "\"use strict\"; function * gen() {", "}" },
{ nullptr, nullptr }
};
const char* statement_data[] = {
// Invalid yield expressions inside generators.
"var yield;",
"var foo, yield;",
"try { } catch (yield) { }",
"function yield() { }",
// The name of the NFE is bound in the generator, which does not permit
// yield to be an identifier.
"(function * yield() { })",
// Yield isn't valid as a formal parameter for generators.
"function * foo(yield) { }",
"(function * foo(yield) { })",
"yield = 1;",
"var foo = yield = 1;",
"++yield;",
"yield++;",
"yield *",
"(yield *)",
// Yield binds very loosely, so this parses as "yield (3 + yield 4)", which
// is invalid.
"yield 3 + yield 4;",
"yield: 34",
"yield ? 1 : 2",
// Parses as yield (/ yield): invalid.
"yield / yield",
"+ yield",
"+ yield 3",
// Invalid (no newline allowed between yield and *).
"yield\n*3",
// Invalid (we see a newline, so we parse {yield:42} as a statement, not an
// object literal, and yield is not a valid label).
"yield\n{yield: 42}",
"yield /* comment */\n {yield: 42}",
"yield //comment\n {yield: 42}",
// Destructuring binding and assignment are both disallowed
"var [yield] = [42];",
"var {foo: yield} = {a: 42};",
"[yield] = [42];",
"({a: yield} = {a: 42});",
// Also disallow full yield expressions on LHS
"var [yield 24] = [42];",
"var {foo: yield 24} = {a: 42};",
"[yield 24] = [42];",
"({a: yield 24} = {a: 42});",
"for (yield 'x' in {});",
"for (yield 'x' of {});",
"for (yield 'x' in {} in {});",
"for (yield 'x' in {} of {});",
"class C extends yield { }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(ErrorsNameOfStrictFunction) {
// Tests that illegal tokens as names of a strict function produce the correct
// errors.
const char* context_data[][2] = {{"function ", ""},
{"\"use strict\"; function", ""},
{"function * ", ""},
{"\"use strict\"; function * ", ""},
{nullptr, nullptr}};
const char* statement_data[] = {
"eval() {\"use strict\";}", "arguments() {\"use strict\";}",
"interface() {\"use strict\";}", "yield() {\"use strict\";}",
// Future reserved words are always illegal
"super() { }", "super() {\"use strict\";}", nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsNameOfStrictFunction) {
const char* context_data[][2] = {{"function ", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"eval() { }", "arguments() { }",
"interface() { }", "yield() { }", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(NoErrorsNameOfStrictGenerator) {
const char* context_data[][2] = {{"function * ", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"eval() { }", "arguments() { }",
"interface() { }", "yield() { }", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsIllegalWordsAsLabelsSloppy) {
// Using future reserved words as labels is always an error.
const char* context_data[][2] = {{"", ""},
{"function test_func() {", "}"},
{"() => {", "}"},
{nullptr, nullptr}};
const char* statement_data[] = {"super: while(true) { break super; }",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(ErrorsIllegalWordsAsLabelsStrict) {
// Tests that illegal tokens as labels produce the correct errors.
const char* context_data[][2] = {
{"\"use strict\";", ""},
{"function test_func() {\"use strict\"; ", "}"},
{"() => {\"use strict\"; ", "}"},
{nullptr, nullptr}};
#define LABELLED_WHILE(NAME) #NAME ": while (true) { break " #NAME "; }",
const char* statement_data[] = {
"super: while(true) { break super; }",
FUTURE_STRICT_RESERVED_WORDS(LABELLED_WHILE) nullptr};
#undef LABELLED_WHILE
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsIllegalWordsAsLabels) {
// Using eval and arguments as labels is legal even in strict mode.
const char* context_data[][2] = {
{"", ""},
{"function test_func() {", "}"},
{"() => {", "}"},
{"\"use strict\";", ""},
{"\"use strict\"; function test_func() {", "}"},
{"\"use strict\"; () => {", "}"},
{nullptr, nullptr}};
const char* statement_data[] = {"mylabel: while(true) { break mylabel; }",
"eval: while(true) { break eval; }",
"arguments: while(true) { break arguments; }",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(NoErrorsFutureStrictReservedAsLabelsSloppy) {
const char* context_data[][2] = {{"", ""},
{"function test_func() {", "}"},
{"() => {", "}"},
{nullptr, nullptr}};
#define LABELLED_WHILE(NAME) #NAME ": while (true) { break " #NAME "; }",
const char* statement_data[]{
FUTURE_STRICT_RESERVED_WORDS(LABELLED_WHILE) nullptr};
#undef LABELLED_WHILE
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsParenthesizedLabels) {
// Parenthesized identifiers shouldn't be recognized as labels.
const char* context_data[][2] = {{"", ""},
{"function test_func() {", "}"},
{"() => {", "}"},
{nullptr, nullptr}};
const char* statement_data[] = {"(mylabel): while(true) { break mylabel; }",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsParenthesizedDirectivePrologue) {
// Parenthesized directive prologue shouldn't be recognized.
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"(\"use strict\"); var eval;", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsNotAnIdentifierName) {
const char* context_data[][2] = {
{"", ""}, {"\"use strict\";", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"var foo = {}; foo.{;",
"var foo = {}; foo.};",
"var foo = {}; foo.=;",
"var foo = {}; foo.888;",
"var foo = {}; foo.-;",
"var foo = {}; foo.--;",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsIdentifierNames) {
// Keywords etc. are valid as property names.
const char* context_data[][2] = {
{"", ""}, {"\"use strict\";", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"var foo = {}; foo.if;",
"var foo = {}; foo.yield;",
"var foo = {}; foo.super;",
"var foo = {}; foo.interface;",
"var foo = {}; foo.eval;",
"var foo = {}; foo.arguments;",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(FunctionDeclaresItselfStrict) {
// Tests that we produce the right kinds of errors when a function declares
// itself strict (we cannot produce there errors as soon as we see the
// offending identifiers, because we don't know at that point whether the
// function is strict or not).
const char* context_data[][2] = {{"function eval() {", "}"},
{"function arguments() {", "}"},
{"function yield() {", "}"},
{"function interface() {", "}"},
{"function foo(eval) {", "}"},
{"function foo(arguments) {", "}"},
{"function foo(yield) {", "}"},
{"function foo(interface) {", "}"},
{"function foo(bar, eval) {", "}"},
{"function foo(bar, arguments) {", "}"},
{"function foo(bar, yield) {", "}"},
{"function foo(bar, interface) {", "}"},
{"function foo(bar, bar) {", "}"},
{nullptr, nullptr}};
const char* strict_statement_data[] = {"\"use strict\";", nullptr};
const char* non_strict_statement_data[] = {";", nullptr};
RunParserSyncTest(context_data, strict_statement_data, kError);
RunParserSyncTest(context_data, non_strict_statement_data, kSuccess);
}
TEST(ErrorsTryWithoutCatchOrFinally) {
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"try { }", "try { } foo();",
"try { } catch (e) foo();",
"try { } finally foo();", nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsTryCatchFinally) {
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"try { } catch (e) { }",
"try { } catch (e) { } finally { }",
"try { } finally { }", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(OptionalCatchBinding) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"'use strict';", ""},
{"try {", "} catch (e) { }"},
{"try {} catch (e) {", "}"},
{"try {", "} catch ({e}) { }"},
{"try {} catch ({e}) {", "}"},
{"function f() {", "}"},
{ nullptr, nullptr }
};
const char* statement_data[] = {
"try { } catch { }",
"try { } catch { } finally { }",
"try { let e; } catch { let e; }",
"try { let e; } catch { let e; } finally { let e; }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsRegexpLiteral) {
const char* context_data[][2] = {{"var r = ", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"/unterminated", nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsRegexpLiteral) {
const char* context_data[][2] = {{"var r = ", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"/foo/", "/foo/g", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(NoErrorsNewExpression) {
const char* context_data[][2] = {
{"", ""}, {"var f =", ""}, {nullptr, nullptr}};
const char* statement_data[] = {
"new foo", "new foo();", "new foo(1);", "new foo(1, 2);",
// The first () will be processed as a part of the NewExpression and the
// second () will be processed as part of LeftHandSideExpression.
"new foo()();",
// The first () will be processed as a part of the inner NewExpression and
// the second () will be processed as a part of the outer NewExpression.
"new new foo()();", "new foo.bar;", "new foo.bar();", "new foo.bar.baz;",
"new foo.bar().baz;", "new foo[bar];", "new foo[bar]();",
"new foo[bar][baz];", "new foo[bar]()[baz];",
"new foo[bar].baz(baz)()[bar].baz;",
"new \"foo\"", // Runtime error
"new 1", // Runtime error
// This even runs:
"(new new Function(\"this.x = 1\")).x;",
"new new Test_Two(String, 2).v(0123).length;", nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsNewExpression) {
const char* context_data[][2] = {
{"", ""}, {"var f =", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"new foo bar", "new ) foo", "new ++foo",
"new foo ++", nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(StrictObjectLiteralChecking) {
const char* context_data[][2] = {{"\"use strict\"; var myobject = {", "};"},
{"\"use strict\"; var myobject = {", ",};"},
{"var myobject = {", "};"},
{"var myobject = {", ",};"},
{nullptr, nullptr}};
// These are only errors in strict mode.
const char* statement_data[] = {
"foo: 1, foo: 2", "\"foo\": 1, \"foo\": 2", "foo: 1, \"foo\": 2",
"1: 1, 1: 2", "1: 1, \"1\": 2",
"get: 1, get: 2", // Not a getter for real, just a property called get.
"set: 1, set: 2", // Not a setter for real, just a property called set.
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsObjectLiteralChecking) {
// clang-format off
const char* context_data[][2] = {
{"\"use strict\"; var myobject = {", "};"},
{"var myobject = {", "};"},
{ nullptr, nullptr }
};
const char* statement_data[] = {
",",
// Wrong number of parameters
"get bar(x) {}",
"get bar(x, y) {}",
"set bar() {}",
"set bar(x, y) {}",
// Parsing FunctionLiteral for getter or setter fails
"get foo( +",
"get foo() \"error\"",
// Various forbidden forms
"static x: 0",
"static x(){}",
"static async x(){}",
"static get x(){}",
"static get x : 0",
"static x",
"static 0",
"*x: 0",
"*x",
"*get x(){}",
"*set x(y){}",
"get *x(){}",
"set *x(y){}",
"get x*(){}",
"set x*(y){}",
"x = 0",
"* *x(){}",
"x*(){}",
"static async x(){}",
"static async x : 0",
"static async get x : 0",
"async static x(){}",
"*async x(){}",
"async x*(){}",
"async x : 0",
"async 0 : 0",
"async get x(){}",
"async get *x(){}",
"async set x(y){}",
"async get : 0",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsObjectLiteralChecking) {
// clang-format off
const char* context_data[][2] = {
{"var myobject = {", "};"},
{"var myobject = {", ",};"},
{"\"use strict\"; var myobject = {", "};"},
{"\"use strict\"; var myobject = {", ",};"},
{ nullptr, nullptr }
};
const char* statement_data[] = {
"foo: 1, get foo() {}",
"foo: 1, set foo(v) {}",
"\"foo\": 1, get \"foo\"() {}",
"\"foo\": 1, set \"foo\"(v) {}",
"1: 1, get 1() {}",
"1: 1, set 1(v) {}",
"get foo() {}, get foo() {}",
"set foo(_) {}, set foo(v) {}",
"foo: 1, get \"foo\"() {}",
"foo: 1, set \"foo\"(v) {}",
"\"foo\": 1, get foo() {}",
"\"foo\": 1, set foo(v) {}",
"1: 1, get \"1\"() {}",
"1: 1, set \"1\"(v) {}",
"\"1\": 1, get 1() {}",
"\"1\": 1, set 1(v) {}",
"foo: 1, bar: 2",
"\"foo\": 1, \"bar\": 2",
"1: 1, 2: 2",
// Syntax: IdentifierName ':' AssignmentExpression
"foo: bar = 5 + baz",
// Syntax: 'get' PropertyName '(' ')' '{' FunctionBody '}'
"get foo() {}",
"get \"foo\"() {}",
"get 1() {}",
// Syntax: 'set' PropertyName '(' PropertySetParameterList ')'
// '{' FunctionBody '}'
"set foo(v) {}",
"set \"foo\"(v) {}",
"set 1(v) {}",
// Non-colliding getters and setters -> no errors
"foo: 1, get bar() {}",
"foo: 1, set bar(v) {}",
"\"foo\": 1, get \"bar\"() {}",
"\"foo\": 1, set \"bar\"(v) {}",
"1: 1, get 2() {}",
"1: 1, set 2(v) {}",
"get: 1, get foo() {}",
"set: 1, set foo(_) {}",
// Potentially confusing cases
"get(){}",
"set(){}",
"static(){}",
"async(){}",
"*get() {}",
"*set() {}",
"*static() {}",
"*async(){}",
"get : 0",
"set : 0",
"static : 0",
"async : 0",
// Keywords, future reserved and strict future reserved are also allowed as
// property names.
"if: 4",
"interface: 5",
"super: 6",
"eval: 7",
"arguments: 8",
"async x(){}",
"async 0(){}",
"async get(){}",
"async set(){}",
"async static(){}",
"async async(){}",
"async : 0",
"async(){}",
"*async(){}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(TooManyArguments) {
const char* context_data[][2] = {{"foo(", "0)"}, {nullptr, nullptr}};
using v8::internal::Code;
char statement[Code::kMaxArguments * 2 + 1];
for (int i = 0; i < Code::kMaxArguments; ++i) {
statement[2 * i] = '0';
statement[2 * i + 1] = ',';
}
statement[Code::kMaxArguments * 2] = 0;
const char* statement_data[] = {statement, nullptr};
// The test is quite slow, so run it with a reduced set of flags.
static const ParserFlag empty_flags[] = {kAllowLazy};
RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1);
}
TEST(StrictDelete) {
// "delete <Identifier>" is not allowed in strict mode.
const char* strict_context_data[][2] = {{"\"use strict\"; ", ""},
{nullptr, nullptr}};
const char* sloppy_context_data[][2] = {{"", ""}, {nullptr, nullptr}};
// These are errors in the strict mode.
const char* sloppy_statement_data[] = {"delete foo;", "delete foo + 1;",
"delete (foo);", "delete eval;",
"delete interface;", nullptr};
// These are always OK
const char* good_statement_data[] = {"delete this;",
"delete 1;",
"delete 1 + 2;",
"delete foo();",
"delete foo.bar;",
"delete foo[bar];",
"delete foo--;",
"delete --foo;",
"delete new foo();",
"delete new foo(bar);",
nullptr};
// These are always errors
const char* bad_statement_data[] = {"delete if;", nullptr};
RunParserSyncTest(strict_context_data, sloppy_statement_data, kError);
RunParserSyncTest(sloppy_context_data, sloppy_statement_data, kSuccess);
RunParserSyncTest(strict_context_data, good_statement_data, kSuccess);
RunParserSyncTest(sloppy_context_data, good_statement_data, kSuccess);
RunParserSyncTest(strict_context_data, bad_statement_data, kError);
RunParserSyncTest(sloppy_context_data, bad_statement_data, kError);
}
TEST(NoErrorsDeclsInCase) {
const char* context_data[][2] = {
{"'use strict'; switch(x) { case 1:", "}"},
{"function foo() {'use strict'; switch(x) { case 1:", "}}"},
{"'use strict'; switch(x) { case 1: case 2:", "}"},
{"function foo() {'use strict'; switch(x) { case 1: case 2:", "}}"},
{"'use strict'; switch(x) { default:", "}"},
{"function foo() {'use strict'; switch(x) { default:", "}}"},
{"'use strict'; switch(x) { case 1: default:", "}"},
{"function foo() {'use strict'; switch(x) { case 1: default:", "}}"},
{ nullptr, nullptr }
};
const char* statement_data[] = {
"function f() { }",
"class C { }",
"class C extends Q {}",
"function f() { } class C {}",
"function f() { }; class C {}",
"class C {}; function f() {}",
nullptr
};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(InvalidLeftHandSide) {
const char* assignment_context_data[][2] = {
{"", " = 1;"}, {"\"use strict\"; ", " = 1;"}, {nullptr, nullptr}};
const char* prefix_context_data[][2] = {
{"++", ";"}, {"\"use strict\"; ++", ";"}, {nullptr, nullptr},
};
const char* postfix_context_data[][2] = {
{"", "++;"}, {"\"use strict\"; ", "++;"}, {nullptr, nullptr}};
// Good left hand sides for assigment or prefix / postfix operations.
const char* good_statement_data[] = {"foo",
"foo.bar",
"foo[bar]",
"foo()[bar]",
"foo().bar",
"this.foo",
"this[foo]",
"new foo()[bar]",
"new foo().bar",
"foo()",
"foo(bar)",
"foo[bar]()",
"foo.bar()",
"this()",
"this.foo()",
"this[foo].bar()",
"this.foo[foo].bar(this)(bar)[foo]()",
nullptr};
// Bad left hand sides for assigment or prefix / postfix operations.
const char* bad_statement_data_common[] = {
"2",
"new foo",
"new foo()",
"null",
"if", // Unexpected token
"{x: 1}", // Unexpected token
"this",
"\"bar\"",
"(foo + bar)",
"new new foo()[bar]", // means: new (new foo()[bar])
"new new foo().bar", // means: new (new foo()[bar])
nullptr};
// These are not okay for assignment, but okay for prefix / postix.
const char* bad_statement_data_for_assignment[] = {"++foo", "foo++",
"foo + bar", nullptr};
RunParserSyncTest(assignment_context_data, good_statement_data, kSuccess);
RunParserSyncTest(assignment_context_data, bad_statement_data_common, kError);
RunParserSyncTest(assignment_context_data, bad_statement_data_for_assignment,
kError);
RunParserSyncTest(prefix_context_data, good_statement_data, kSuccess);
RunParserSyncTest(prefix_context_data, bad_statement_data_common, kError);
RunParserSyncTest(postfix_context_data, good_statement_data, kSuccess);
RunParserSyncTest(postfix_context_data, bad_statement_data_common, kError);
}
TEST(FuncNameInferrerBasic) {
// Tests that function names are inferred properly.
i::FLAG_allow_natives_syntax = true;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext env;
CompileRun("var foo1 = function() {}; "
"var foo2 = function foo3() {}; "
"function not_ctor() { "
" var foo4 = function() {}; "
" return %FunctionGetInferredName(foo4); "
"} "
"function Ctor() { "
" var foo5 = function() {}; "
" return %FunctionGetInferredName(foo5); "
"} "
"var obj1 = { foo6: function() {} }; "
"var obj2 = { 'foo7': function() {} }; "
"var obj3 = {}; "
"obj3[1] = function() {}; "
"var obj4 = {}; "
"obj4[1] = function foo8() {}; "
"var obj5 = {}; "
"obj5['foo9'] = function() {}; "
"var obj6 = { obj7 : { foo10: function() {} } };");
ExpectString("%FunctionGetInferredName(foo1)", "foo1");
// foo2 is not unnamed -> its name is not inferred.
ExpectString("%FunctionGetInferredName(foo2)", "");
ExpectString("not_ctor()", "foo4");
ExpectString("Ctor()", "Ctor.foo5");
ExpectString("%FunctionGetInferredName(obj1.foo6)", "obj1.foo6");
ExpectString("%FunctionGetInferredName(obj2.foo7)", "obj2.foo7");
ExpectString("%FunctionGetInferredName(obj3[1])", "obj3.<computed>");
ExpectString("%FunctionGetInferredName(obj4[1])", "");
ExpectString("%FunctionGetInferredName(obj5['foo9'])", "obj5.foo9");
ExpectString("%FunctionGetInferredName(obj6.obj7.foo10)", "obj6.obj7.foo10");
}
TEST(FuncNameInferrerTwoByte) {
// Tests function name inferring in cases where some parts of the inferred
// function name are two-byte strings.
i::FLAG_allow_natives_syntax = true;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext env;
uint16_t* two_byte_source = AsciiToTwoByteString(
"var obj1 = { oXj2 : { foo1: function() {} } }; "
"%FunctionGetInferredName(obj1.oXj2.foo1)");
uint16_t* two_byte_name = AsciiToTwoByteString("obj1.oXj2.foo1");
// Make it really non-Latin1 (replace the Xs with a non-Latin1 character).
two_byte_source[14] = two_byte_source[78] = two_byte_name[6] = 0x010D;
v8::Local<v8::String> source =
v8::String::NewFromTwoByte(isolate, two_byte_source).ToLocalChecked();
v8::Local<v8::Value> result = CompileRun(source);
CHECK(result->IsString());
v8::Local<v8::String> expected_name =
v8::String::NewFromTwoByte(isolate, two_byte_name).ToLocalChecked();
CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust());
i::DeleteArray(two_byte_source);
i::DeleteArray(two_byte_name);
}
TEST(FuncNameInferrerEscaped) {
// The same as FuncNameInferrerTwoByte, except that we express the two-byte
// character as a Unicode escape.
i::FLAG_allow_natives_syntax = true;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext env;
uint16_t* two_byte_source = AsciiToTwoByteString(
"var obj1 = { o\\u010dj2 : { foo1: function() {} } }; "
"%FunctionGetInferredName(obj1.o\\u010dj2.foo1)");
uint16_t* two_byte_name = AsciiToTwoByteString("obj1.oXj2.foo1");
// Fix to correspond to the non-ASCII name in two_byte_source.
two_byte_name[6] = 0x010D;
v8::Local<v8::String> source =
v8::String::NewFromTwoByte(isolate, two_byte_source).ToLocalChecked();
v8::Local<v8::Value> result = CompileRun(source);
CHECK(result->IsString());
v8::Local<v8::String> expected_name =
v8::String::NewFromTwoByte(isolate, two_byte_name).ToLocalChecked();
CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust());
i::DeleteArray(two_byte_source);
i::DeleteArray(two_byte_name);
}
TEST(SerializationOfMaybeAssignmentFlag) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
i::HandleScope scope(isolate);
LocalContext env;
const char* src =
"function h() {"
" var result = [];"
" function f() {"
" result.push(2);"
" }"
" function assertResult(r) {"
" f();"
" result = [];"
" }"
" assertResult([2]);"
" assertResult([2]);"
" return f;"
"};"
"h();";
i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
i::SNPrintF(program, "%s", src);
i::Handle<i::String> source = factory->InternalizeUtf8String(program.begin());
source->PrintOn(stdout);
printf("\n");
i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
v8::Local<v8::Value> v = CompileRun(src);
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
i::Handle<i::Context> context(f->context(), isolate);
i::AstValueFactory avf(&zone, isolate->ast_string_constants(),
HashSeed(isolate));
const i::AstRawString* name = avf.GetOneByteString("result");
avf.Internalize(isolate);
i::Handle<i::String> str = name->string();
CHECK(str->IsInternalizedString());
i::DeclarationScope* script_scope =
zone.New<i::DeclarationScope>(&zone, &avf);
i::Scope* s = i::Scope::DeserializeScopeChain(
isolate, &zone, context->scope_info(), script_scope, &avf,
i::Scope::DeserializationMode::kIncludingVariables);
CHECK(s != script_scope);
CHECK_NOT_NULL(name);
// Get result from h's function context (that is f's context)
i::Variable* var = s->LookupForTesting(name);
CHECK_NOT_NULL(var);
// Maybe assigned should survive deserialization
CHECK_EQ(var->maybe_assigned(), i::kMaybeAssigned);
// TODO(sigurds) Figure out if is_used should survive context serialization.
}
TEST(IfArgumentsArrayAccessedThenParametersMaybeAssigned) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
i::HandleScope scope(isolate);
LocalContext env;
const char* src =
"function f(x) {"
" var a = arguments;"
" function g(i) {"
" ++a[0];"
" };"
" return g;"
" }"
"f(0);";
i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
i::SNPrintF(program, "%s", src);
i::Handle<i::String> source = factory->InternalizeUtf8String(program.begin());
source->PrintOn(stdout);
printf("\n");
i::Zone zone(isolate->allocator(), ZONE_NAME);
v8::Local<v8::Value> v = CompileRun(src);
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
i::Handle<i::Context> context(f->context(), isolate);
i::AstValueFactory avf(&zone, isolate->ast_string_constants(),
HashSeed(isolate));
const i::AstRawString* name_x = avf.GetOneByteString("x");
avf.Internalize(isolate);
i::DeclarationScope* script_scope =
zone.New<i::DeclarationScope>(&zone, &avf);
i::Scope* s = i::Scope::DeserializeScopeChain(
isolate, &zone, context->scope_info(), script_scope, &avf,
i::Scope::DeserializationMode::kIncludingVariables);
CHECK(s != script_scope);
// Get result from f's function context (that is g's outer context)
i::Variable* var_x = s->LookupForTesting(name_x);
CHECK_NOT_NULL(var_x);
CHECK_EQ(var_x->maybe_assigned(), i::kMaybeAssigned);
}
TEST(InnerAssignment) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
i::HandleScope scope(isolate);
LocalContext env;
const char* prefix = "function f() {";
const char* midfix = " function g() {";
const char* suffix = "}}; f";
struct {
const char* source;
bool assigned;
bool strict;
} outers[] = {
// Actual assignments.
{"var x; var x = 5;", true, false},
{"var x; { var x = 5; }", true, false},
{"'use strict'; let x; x = 6;", true, true},
{"var x = 5; function x() {}", true, false},
{"var x = 4; var x = 5;", true, false},
{"var [x, x] = [4, 5];", true, false},
{"var x; [x, x] = [4, 5];", true, false},
{"var {a: x, b: x} = {a: 4, b: 5};", true, false},
{"var x = {a: 4, b: (x = 5)};", true, false},
{"var {x=1} = {a: 4, b: (x = 5)};", true, false},
{"var {x} = {x: 4, b: (x = 5)};", true, false},
// Actual non-assignments.
{"var x;", false, false},
{"var x = 5;", false, false},
{"'use strict'; let x;", false, true},
{"'use strict'; let x = 6;", false, true},
{"'use strict'; var x = 0; { let x = 6; }", false, true},
{"'use strict'; var x = 0; { let x; x = 6; }", false, true},
{"'use strict'; let x = 0; { let x = 6; }", false, true},
{"'use strict'; let x = 0; { let x; x = 6; }", false, true},
{"var x; try {} catch (x) { x = 5; }", false, false},
{"function x() {}", false, false},
// Eval approximation.
{"var x; eval('');", true, false},
{"eval(''); var x;", true, false},
{"'use strict'; let x; eval('');", true, true},
{"'use strict'; eval(''); let x;", true, true},
// Non-assignments not recognized, because the analysis is approximative.
{"var x; var x;", true, false},
{"var x = 5; var x;", true, false},
{"var x; { var x; }", true, false},
{"var x; function x() {}", true, false},
{"function x() {}; var x;", true, false},
{"var x; try {} catch (x) { var x = 5; }", true, false},
};
// We set allow_error_in_inner_function to true in cases where our handling of
// assigned variables in lazy inner functions is currently overly pessimistic.
// FIXME(marja): remove it when no longer needed.
struct {
const char* source;
bool assigned;
bool with;
bool allow_error_in_inner_function;
} inners[] = {
// Actual assignments.
{"x = 1;", true, false, false},
{"x++;", true, false, false},
{"++x;", true, false, false},
{"x--;", true, false, false},
{"--x;", true, false, false},
{"{ x = 1; }", true, false, false},
{"'use strict'; { let x; }; x = 0;", true, false, false},
{"'use strict'; { const x = 1; }; x = 0;", true, false, false},
{"'use strict'; { function x() {} }; x = 0;", true, false, false},
{"with ({}) { x = 1; }", true, true, false},
{"eval('');", true, false, false},
{"'use strict'; { let y; eval('') }", true, false, false},
{"function h() { x = 0; }", true, false, false},
{"(function() { x = 0; })", true, false, false},
{"(function() { x = 0; })", true, false, false},
{"with ({}) (function() { x = 0; })", true, true, false},
{"for (x of [1,2,3]) {}", true, false, false},
{"for (x in {a: 1}) {}", true, false, false},
{"for ([x] of [[1],[2],[3]]) {}", true, false, false},
{"for ([x] in {ab: 1}) {}", true, false, false},
{"for ([...x] in {ab: 1}) {}", true, false, false},
{"[x] = [1]", true, false, false},
// Actual non-assignments.
{"", false, false, false},
{"x;", false, false, false},
{"var x;", false, false, false},
{"var x = 8;", false, false, false},
{"var x; x = 8;", false, false, false},
{"'use strict'; let x;", false, false, false},
{"'use strict'; let x = 8;", false, false, false},
{"'use strict'; let x; x = 8;", false, false, false},
{"'use strict'; const x = 8;", false, false, false},
{"function x() {}", false, false, false},
{"function x() { x = 0; }", false, false, true},
{"function h(x) { x = 0; }", false, false, false},
{"'use strict'; { let x; x = 0; }", false, false, false},
{"{ var x; }; x = 0;", false, false, false},
{"with ({}) {}", false, true, false},
{"var x; { with ({}) { x = 1; } }", false, true, false},
{"try {} catch(x) { x = 0; }", false, false, true},
{"try {} catch(x) { with ({}) { x = 1; } }", false, true, true},
// Eval approximation.
{"eval('');", true, false, false},
{"function h() { eval(''); }", true, false, false},
{"(function() { eval(''); })", true, false, false},
// Shadowing not recognized because of eval approximation.
{"var x; eval('');", true, false, false},
{"'use strict'; let x; eval('');", true, false, false},
{"try {} catch(x) { eval(''); }", true, false, false},
{"function x() { eval(''); }", true, false, false},
{"(function(x) { eval(''); })", true, false, false},
};
int prefix_len = Utf8LengthHelper(prefix);
int midfix_len = Utf8LengthHelper(midfix);
int suffix_len = Utf8LengthHelper(suffix);
for (unsigned i = 0; i < arraysize(outers); ++i) {
const char* outer = outers[i].source;
int outer_len = Utf8LengthHelper(outer);
for (unsigned j = 0; j < arraysize(inners); ++j) {
for (unsigned lazy = 0; lazy < 2; ++lazy) {
if (outers[i].strict && inners[j].with) continue;
const char* inner = inners[j].source;
int inner_len = Utf8LengthHelper(inner);
int len = prefix_len + outer_len + midfix_len + inner_len + suffix_len;
i::ScopedVector<char> program(len + 1);
i::SNPrintF(program, "%s%s%s%s%s", prefix, outer, midfix, inner,
suffix);
UnoptimizedCompileState compile_state(isolate);
std::unique_ptr<i::ParseInfo> info;
if (lazy) {
printf("%s\n", program.begin());
v8::Local<v8::Value> v = CompileRun(program.begin());
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
i::Handle<i::SharedFunctionInfo> shared =
i::handle(f->shared(), isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForFunctionCompile(isolate, *shared);
info = std::make_unique<i::ParseInfo>(isolate, flags, &compile_state);
CHECK_PARSE_FUNCTION(info.get(), shared, isolate);
} else {
i::Handle<i::String> source =
factory->InternalizeUtf8String(program.begin());
source->PrintOn(stdout);
printf("\n");
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_allow_lazy_parsing(false);
info = std::make_unique<i::ParseInfo>(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(info.get(), script, isolate);
}
i::Scope* scope = info->literal()->scope();
if (!lazy) {
scope = scope->inner_scope();
}
DCHECK_NOT_NULL(scope);
DCHECK_NULL(scope->sibling());
DCHECK(scope->is_function_scope());
const i::AstRawString* var_name =
info->ast_value_factory()->GetOneByteString("x");
i::Variable* var = scope->LookupForTesting(var_name);
bool expected = outers[i].assigned || inners[j].assigned;
CHECK_NOT_NULL(var);
bool is_maybe_assigned = var->maybe_assigned() == i::kMaybeAssigned;
CHECK(is_maybe_assigned == expected ||
(is_maybe_assigned && inners[j].allow_error_in_inner_function));
}
}
}
}
TEST(MaybeAssignedParameters) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
struct {
bool arg_assigned;
const char* source;
} tests[] = {
{false, "function f(arg) {}"},
{false, "function f(arg) {g(arg)}"},
{false, "function f(arg) {function h() { g(arg) }; h()}"},
{false, "function f(arg) {function h() { g(arg) }; return h}"},
{false, "function f(arg=1) {}"},
{false, "function f(arg=1) {g(arg)}"},
{false, "function f(arg, arguments) {g(arg); arguments[0] = 42; g(arg)}"},
{false,
"function f(arg, ...arguments) {g(arg); arguments[0] = 42; g(arg)}"},
{false,
"function f(arg, arguments=[]) {g(arg); arguments[0] = 42; g(arg)}"},
{false, "function f(...arg) {g(arg); arguments[0] = 42; g(arg)}"},
{false,
"function f(arg) {g(arg); g(function() {arguments[0] = 42}); g(arg)}"},
// strict arguments object
{false, "function f(arg, x=1) {g(arg); arguments[0] = 42; g(arg)}"},
{false, "function f(arg, ...x) {g(arg); arguments[0] = 42; g(arg)}"},
{false, "function f(arg=1) {g(arg); arguments[0] = 42; g(arg)}"},
{false,
"function f(arg) {'use strict'; g(arg); arguments[0] = 42; g(arg)}"},
{false, "function f(arg) {g(arg); f.arguments[0] = 42; g(arg)}"},
{false, "function f(arg, args=arguments) {g(arg); args[0] = 42; g(arg)}"},
{true, "function f(arg) {g(arg); arg = 42; g(arg)}"},
{true, "function f(arg) {g(arg); eval('arg = 42'); g(arg)}"},
{true, "function f(arg) {g(arg); var arg = 42; g(arg)}"},
{true, "function f(arg, x=1) {g(arg); arg = 42; g(arg)}"},
{true, "function f(arg, ...x) {g(arg); arg = 42; g(arg)}"},
{true, "function f(arg=1) {g(arg); arg = 42; g(arg)}"},
{true, "function f(arg) {'use strict'; g(arg); arg = 42; g(arg)}"},
{true, "function f(arg, {a=(g(arg), arg=42)}) {g(arg)}"},
{true, "function f(arg) {g(arg); g(function() {arg = 42}); g(arg)}"},
{true,
"function f(arg) {g(arg); g(function() {eval('arg = 42')}); g(arg)}"},
{true, "function f(arg) {g(arg); g(() => arg = 42); g(arg)}"},
{true, "function f(arg) {g(arg); g(() => eval('arg = 42')); g(arg)}"},
{true, "function f(...arg) {g(arg); eval('arg = 42'); g(arg)}"},
// sloppy arguments object
{true, "function f(arg) {g(arg); arguments[0] = 42; g(arg)}"},
{true, "function f(arg) {g(arg); h(arguments); g(arg)}"},
{true,
"function f(arg) {((args) => {arguments[0] = 42})(arguments); "
"g(arg)}"},
{true, "function f(arg) {g(arg); eval('arguments[0] = 42'); g(arg)}"},
{true, "function f(arg) {g(arg); g(() => arguments[0] = 42); g(arg)}"},
// default values
{false, "function f({x:arg = 1}) {}"},
{true, "function f({x:arg = 1}, {y:b=(arg=2)}) {}"},
{true, "function f({x:arg = (arg = 2)}) {}"},
{false, "var f = ({x:arg = 1}) => {}"},
{true, "var f = ({x:arg = 1}, {y:b=(arg=2)}) => {}"},
{true, "var f = ({x:arg = (arg = 2)}) => {}"},
};
const char* suffix = "; f";
for (unsigned i = 0; i < arraysize(tests); ++i) {
bool assigned = tests[i].arg_assigned;
const char* source = tests[i].source;
for (unsigned allow_lazy = 0; allow_lazy < 2; ++allow_lazy) {
i::ScopedVector<char> program(Utf8LengthHelper(source) +
Utf8LengthHelper(suffix) + 1);
i::SNPrintF(program, "%s%s", source, suffix);
std::unique_ptr<i::ParseInfo> info;
printf("%s\n", program.begin());
v8::Local<v8::Value> v = CompileRun(program.begin());
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared(), isolate);
i::UnoptimizedCompileState state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForFunctionCompile(isolate, *shared);
flags.set_allow_lazy_parsing(allow_lazy);
info = std::make_unique<i::ParseInfo>(isolate, flags, &state);
CHECK_PARSE_FUNCTION(info.get(), shared, isolate);
i::Scope* scope = info->literal()->scope();
CHECK(!scope->AsDeclarationScope()->was_lazily_parsed());
CHECK_NULL(scope->sibling());
CHECK(scope->is_function_scope());
const i::AstRawString* var_name =
info->ast_value_factory()->GetOneByteString("arg");
i::Variable* var = scope->LookupForTesting(var_name);
CHECK(var->is_used() || !assigned);
bool is_maybe_assigned = var->maybe_assigned() == i::kMaybeAssigned;
CHECK_EQ(is_maybe_assigned, assigned);
}
}
}
struct Input {
bool assigned;
std::string source;
std::vector<unsigned> location; // "Directions" to the relevant scope.
};
static void TestMaybeAssigned(Input input, const char* variable, bool module,
bool allow_lazy_parsing) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
i::Handle<i::String> string =
factory->InternalizeUtf8String(input.source.c_str());
string->PrintOn(stdout);
printf("\n");
i::Handle<i::Script> script = factory->NewScript(string);
i::UnoptimizedCompileState state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(module);
flags.set_allow_lazy_parsing(allow_lazy_parsing);
std::unique_ptr<i::ParseInfo> info =
std::make_unique<i::ParseInfo>(isolate, flags, &state);
CHECK_PARSE_PROGRAM(info.get(), script, isolate);
i::Scope* scope = info->literal()->scope();
CHECK(!scope->AsDeclarationScope()->was_lazily_parsed());
CHECK_NULL(scope->sibling());
CHECK(module ? scope->is_module_scope() : scope->is_script_scope());
i::Variable* var;
{
// Find the variable.
scope = i::ScopeTestHelper::FindScope(scope, input.location);
const i::AstRawString* var_name =
info->ast_value_factory()->GetOneByteString(variable);
var = scope->LookupForTesting(var_name);
}
CHECK_NOT_NULL(var);
CHECK_IMPLIES(input.assigned, var->is_used());
STATIC_ASSERT(true == i::kMaybeAssigned);
CHECK_EQ(input.assigned, var->maybe_assigned() == i::kMaybeAssigned);
}
static Input wrap(Input input) {
Input result;
result.assigned = input.assigned;
result.source = "function WRAPPED() { " + input.source + " }";
result.location.push_back(0);
for (auto n : input.location) {
result.location.push_back(n);
}
return result;
}
TEST(MaybeAssignedInsideLoop) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
std::vector<unsigned> top; // Can't use {} in initializers below.
Input module_and_script_tests[] = {
{true, "for (j=x; j<10; ++j) { foo = j }", top},
{true, "for (j=x; j<10; ++j) { [foo] = [j] }", top},
{true, "for (j=x; j<10; ++j) { [[foo]=[42]] = [] }", top},
{true, "for (j=x; j<10; ++j) { var foo = j }", top},
{true, "for (j=x; j<10; ++j) { var [foo] = [j] }", top},
{true, "for (j=x; j<10; ++j) { var [[foo]=[42]] = [] }", top},
{true, "for (j=x; j<10; ++j) { var foo; foo = j }", top},
{true, "for (j=x; j<10; ++j) { var foo; [foo] = [j] }", top},
{true, "for (j=x; j<10; ++j) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (j=x; j<10; ++j) { let foo; foo = j }", {0}},
{true, "for (j=x; j<10; ++j) { let foo; [foo] = [j] }", {0}},
{true, "for (j=x; j<10; ++j) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (j=x; j<10; ++j) { let foo = j }", {0}},
{false, "for (j=x; j<10; ++j) { let [foo] = [j] }", {0}},
{false, "for (j=x; j<10; ++j) { const foo = j }", {0}},
{false, "for (j=x; j<10; ++j) { const [foo] = [j] }", {0}},
{false, "for (j=x; j<10; ++j) { function foo() {return j} }", {0}},
{true, "for ({j}=x; j<10; ++j) { foo = j }", top},
{true, "for ({j}=x; j<10; ++j) { [foo] = [j] }", top},
{true, "for ({j}=x; j<10; ++j) { [[foo]=[42]] = [] }", top},
{true, "for ({j}=x; j<10; ++j) { var foo = j }", top},
{true, "for ({j}=x; j<10; ++j) { var [foo] = [j] }", top},
{true, "for ({j}=x; j<10; ++j) { var [[foo]=[42]] = [] }", top},
{true, "for ({j}=x; j<10; ++j) { var foo; foo = j }", top},
{true, "for ({j}=x; j<10; ++j) { var foo; [foo] = [j] }", top},
{true, "for ({j}=x; j<10; ++j) { var foo; [[foo]=[42]] = [] }", top},
{true, "for ({j}=x; j<10; ++j) { let foo; foo = j }", {0}},
{true, "for ({j}=x; j<10; ++j) { let foo; [foo] = [j] }", {0}},
{true, "for ({j}=x; j<10; ++j) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for ({j}=x; j<10; ++j) { let foo = j }", {0}},
{false, "for ({j}=x; j<10; ++j) { let [foo] = [j] }", {0}},
{false, "for ({j}=x; j<10; ++j) { const foo = j }", {0}},
{false, "for ({j}=x; j<10; ++j) { const [foo] = [j] }", {0}},
{false, "for ({j}=x; j<10; ++j) { function foo() {return j} }", {0}},
{true, "for (var j=x; j<10; ++j) { foo = j }", top},
{true, "for (var j=x; j<10; ++j) { [foo] = [j] }", top},
{true, "for (var j=x; j<10; ++j) { [[foo]=[42]] = [] }", top},
{true, "for (var j=x; j<10; ++j) { var foo = j }", top},
{true, "for (var j=x; j<10; ++j) { var [foo] = [j] }", top},
{true, "for (var j=x; j<10; ++j) { var [[foo]=[42]] = [] }", top},
{true, "for (var j=x; j<10; ++j) { var foo; foo = j }", top},
{true, "for (var j=x; j<10; ++j) { var foo; [foo] = [j] }", top},
{true, "for (var j=x; j<10; ++j) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (var j=x; j<10; ++j) { let foo; foo = j }", {0}},
{true, "for (var j=x; j<10; ++j) { let foo; [foo] = [j] }", {0}},
{true, "for (var j=x; j<10; ++j) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (var j=x; j<10; ++j) { let foo = j }", {0}},
{false, "for (var j=x; j<10; ++j) { let [foo] = [j] }", {0}},
{false, "for (var j=x; j<10; ++j) { const foo = j }", {0}},
{false, "for (var j=x; j<10; ++j) { const [foo] = [j] }", {0}},
{false, "for (var j=x; j<10; ++j) { function foo() {return j} }", {0}},
{true, "for (var {j}=x; j<10; ++j) { foo = j }", top},
{true, "for (var {j}=x; j<10; ++j) { [foo] = [j] }", top},
{true, "for (var {j}=x; j<10; ++j) { [[foo]=[42]] = [] }", top},
{true, "for (var {j}=x; j<10; ++j) { var foo = j }", top},
{true, "for (var {j}=x; j<10; ++j) { var [foo] = [j] }", top},
{true, "for (var {j}=x; j<10; ++j) { var [[foo]=[42]] = [] }", top},
{true, "for (var {j}=x; j<10; ++j) { var foo; foo = j }", top},
{true, "for (var {j}=x; j<10; ++j) { var foo; [foo] = [j] }", top},
{true, "for (var {j}=x; j<10; ++j) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (var {j}=x; j<10; ++j) { let foo; foo = j }", {0}},
{true, "for (var {j}=x; j<10; ++j) { let foo; [foo] = [j] }", {0}},
{true, "for (var {j}=x; j<10; ++j) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (var {j}=x; j<10; ++j) { let foo = j }", {0}},
{false, "for (var {j}=x; j<10; ++j) { let [foo] = [j] }", {0}},
{false, "for (var {j}=x; j<10; ++j) { const foo = j }", {0}},
{false, "for (var {j}=x; j<10; ++j) { const [foo] = [j] }", {0}},
{false, "for (var {j}=x; j<10; ++j) { function foo() {return j} }", {0}},
{true, "for (let j=x; j<10; ++j) { foo = j }", top},
{true, "for (let j=x; j<10; ++j) { [foo] = [j] }", top},
{true, "for (let j=x; j<10; ++j) { [[foo]=[42]] = [] }", top},
{true, "for (let j=x; j<10; ++j) { var foo = j }", top},
{true, "for (let j=x; j<10; ++j) { var [foo] = [j] }", top},
{true, "for (let j=x; j<10; ++j) { var [[foo]=[42]] = [] }", top},
{true, "for (let j=x; j<10; ++j) { var foo; foo = j }", top},
{true, "for (let j=x; j<10; ++j) { var foo; [foo] = [j] }", top},
{true, "for (let j=x; j<10; ++j) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (let j=x; j<10; ++j) { let foo; foo = j }", {0, 0}},
{true, "for (let j=x; j<10; ++j) { let foo; [foo] = [j] }", {0, 0}},
{true, "for (let j=x; j<10; ++j) { let foo; [[foo]=[42]] = [] }", {0, 0}},
{false, "for (let j=x; j<10; ++j) { let foo = j }", {0, 0}},
{false, "for (let j=x; j<10; ++j) { let [foo] = [j] }", {0, 0}},
{false, "for (let j=x; j<10; ++j) { const foo = j }", {0, 0}},
{false, "for (let j=x; j<10; ++j) { const [foo] = [j] }", {0, 0}},
{false,
"for (let j=x; j<10; ++j) { function foo() {return j} }",
{0, 0, 0}},
{true, "for (let {j}=x; j<10; ++j) { foo = j }", top},
{true, "for (let {j}=x; j<10; ++j) { [foo] = [j] }", top},
{true, "for (let {j}=x; j<10; ++j) { [[foo]=[42]] = [] }", top},
{true, "for (let {j}=x; j<10; ++j) { var foo = j }", top},
{true, "for (let {j}=x; j<10; ++j) { var [foo] = [j] }", top},
{true, "for (let {j}=x; j<10; ++j) { var [[foo]=[42]] = [] }", top},
{true, "for (let {j}=x; j<10; ++j) { var foo; foo = j }", top},
{true, "for (let {j}=x; j<10; ++j) { var foo; [foo] = [j] }", top},
{true, "for (let {j}=x; j<10; ++j) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (let {j}=x; j<10; ++j) { let foo; foo = j }", {0, 0}},
{true, "for (let {j}=x; j<10; ++j) { let foo; [foo] = [j] }", {0, 0}},
{true,
"for (let {j}=x; j<10; ++j) { let foo; [[foo]=[42]] = [] }",
{0, 0}},
{false, "for (let {j}=x; j<10; ++j) { let foo = j }", {0, 0}},
{false, "for (let {j}=x; j<10; ++j) { let [foo] = [j] }", {0, 0}},
{false, "for (let {j}=x; j<10; ++j) { const foo = j }", {0, 0}},
{false, "for (let {j}=x; j<10; ++j) { const [foo] = [j] }", {0, 0}},
{false,
"for (let {j}=x; j<10; ++j) { function foo(){return j} }",
{0, 0, 0}},
{true, "for (j of x) { foo = j }", top},
{true, "for (j of x) { [foo] = [j] }", top},
{true, "for (j of x) { [[foo]=[42]] = [] }", top},
{true, "for (j of x) { var foo = j }", top},
{true, "for (j of x) { var [foo] = [j] }", top},
{true, "for (j of x) { var [[foo]=[42]] = [] }", top},
{true, "for (j of x) { var foo; foo = j }", top},
{true, "for (j of x) { var foo; [foo] = [j] }", top},
{true, "for (j of x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (j of x) { let foo; foo = j }", {0}},
{true, "for (j of x) { let foo; [foo] = [j] }", {0}},
{true, "for (j of x) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (j of x) { let foo = j }", {0}},
{false, "for (j of x) { let [foo] = [j] }", {0}},
{false, "for (j of x) { const foo = j }", {0}},
{false, "for (j of x) { const [foo] = [j] }", {0}},
{false, "for (j of x) { function foo() {return j} }", {0}},
{true, "for ({j} of x) { foo = j }", top},
{true, "for ({j} of x) { [foo] = [j] }", top},
{true, "for ({j} of x) { [[foo]=[42]] = [] }", top},
{true, "for ({j} of x) { var foo = j }", top},
{true, "for ({j} of x) { var [foo] = [j] }", top},
{true, "for ({j} of x) { var [[foo]=[42]] = [] }", top},
{true, "for ({j} of x) { var foo; foo = j }", top},
{true, "for ({j} of x) { var foo; [foo] = [j] }", top},
{true, "for ({j} of x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for ({j} of x) { let foo; foo = j }", {0}},
{true, "for ({j} of x) { let foo; [foo] = [j] }", {0}},
{true, "for ({j} of x) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for ({j} of x) { let foo = j }", {0}},
{false, "for ({j} of x) { let [foo] = [j] }", {0}},
{false, "for ({j} of x) { const foo = j }", {0}},
{false, "for ({j} of x) { const [foo] = [j] }", {0}},
{false, "for ({j} of x) { function foo() {return j} }", {0}},
{true, "for (var j of x) { foo = j }", top},
{true, "for (var j of x) { [foo] = [j] }", top},
{true, "for (var j of x) { [[foo]=[42]] = [] }", top},
{true, "for (var j of x) { var foo = j }", top},
{true, "for (var j of x) { var [foo] = [j] }", top},
{true, "for (var j of x) { var [[foo]=[42]] = [] }", top},
{true, "for (var j of x) { var foo; foo = j }", top},
{true, "for (var j of x) { var foo; [foo] = [j] }", top},
{true, "for (var j of x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (var j of x) { let foo; foo = j }", {0}},
{true, "for (var j of x) { let foo; [foo] = [j] }", {0}},
{true, "for (var j of x) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (var j of x) { let foo = j }", {0}},
{false, "for (var j of x) { let [foo] = [j] }", {0}},
{false, "for (var j of x) { const foo = j }", {0}},
{false, "for (var j of x) { const [foo] = [j] }", {0}},
{false, "for (var j of x) { function foo() {return j} }", {0}},
{true, "for (var {j} of x) { foo = j }", top},
{true, "for (var {j} of x) { [foo] = [j] }", top},
{true, "for (var {j} of x) { [[foo]=[42]] = [] }", top},
{true, "for (var {j} of x) { var foo = j }", top},
{true, "for (var {j} of x) { var [foo] = [j] }", top},
{true, "for (var {j} of x) { var [[foo]=[42]] = [] }", top},
{true, "for (var {j} of x) { var foo; foo = j }", top},
{true, "for (var {j} of x) { var foo; [foo] = [j] }", top},
{true, "for (var {j} of x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (var {j} of x) { let foo; foo = j }", {0}},
{true, "for (var {j} of x) { let foo; [foo] = [j] }", {0}},
{true, "for (var {j} of x) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (var {j} of x) { let foo = j }", {0}},
{false, "for (var {j} of x) { let [foo] = [j] }", {0}},
{false, "for (var {j} of x) { const foo = j }", {0}},
{false, "for (var {j} of x) { const [foo] = [j] }", {0}},
{false, "for (var {j} of x) { function foo() {return j} }", {0}},
{true, "for (let j of x) { foo = j }", top},
{true, "for (let j of x) { [foo] = [j] }", top},
{true, "for (let j of x) { [[foo]=[42]] = [] }", top},
{true, "for (let j of x) { var foo = j }", top},
{true, "for (let j of x) { var [foo] = [j] }", top},
{true, "for (let j of x) { var [[foo]=[42]] = [] }", top},
{true, "for (let j of x) { var foo; foo = j }", top},
{true, "for (let j of x) { var foo; [foo] = [j] }", top},
{true, "for (let j of x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (let j of x) { let foo; foo = j }", {0, 0, 0}},
{true, "for (let j of x) { let foo; [foo] = [j] }", {0, 0, 0}},
{true, "for (let j of x) { let foo; [[foo]=[42]] = [] }", {0, 0, 0}},
{false, "for (let j of x) { let foo = j }", {0, 0, 0}},
{false, "for (let j of x) { let [foo] = [j] }", {0, 0, 0}},
{false, "for (let j of x) { const foo = j }", {0, 0, 0}},
{false, "for (let j of x) { const [foo] = [j] }", {0, 0, 0}},
{false, "for (let j of x) { function foo() {return j} }", {0, 0, 0}},
{true, "for (let {j} of x) { foo = j }", top},
{true, "for (let {j} of x) { [foo] = [j] }", top},
{true, "for (let {j} of x) { [[foo]=[42]] = [] }", top},
{true, "for (let {j} of x) { var foo = j }", top},
{true, "for (let {j} of x) { var [foo] = [j] }", top},
{true, "for (let {j} of x) { var [[foo]=[42]] = [] }", top},
{true, "for (let {j} of x) { var foo; foo = j }", top},
{true, "for (let {j} of x) { var foo; [foo] = [j] }", top},
{true, "for (let {j} of x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (let {j} of x) { let foo; foo = j }", {0, 0, 0}},
{true, "for (let {j} of x) { let foo; [foo] = [j] }", {0, 0, 0}},
{true, "for (let {j} of x) { let foo; [[foo]=[42]] = [] }", {0, 0, 0}},
{false, "for (let {j} of x) { let foo = j }", {0, 0, 0}},
{false, "for (let {j} of x) { let [foo] = [j] }", {0, 0, 0}},
{false, "for (let {j} of x) { const foo = j }", {0, 0, 0}},
{false, "for (let {j} of x) { const [foo] = [j] }", {0, 0, 0}},
{false, "for (let {j} of x) { function foo() {return j} }", {0, 0, 0}},
{true, "for (const j of x) { foo = j }", top},
{true, "for (const j of x) { [foo] = [j] }", top},
{true, "for (const j of x) { [[foo]=[42]] = [] }", top},
{true, "for (const j of x) { var foo = j }", top},
{true, "for (const j of x) { var [foo] = [j] }", top},
{true, "for (const j of x) { var [[foo]=[42]] = [] }", top},
{true, "for (const j of x) { var foo; foo = j }", top},
{true, "for (const j of x) { var foo; [foo] = [j] }", top},
{true, "for (const j of x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (const j of x) { let foo; foo = j }", {0, 0, 0}},
{true, "for (const j of x) { let foo; [foo] = [j] }", {0, 0, 0}},
{true, "for (const j of x) { let foo; [[foo]=[42]] = [] }", {0, 0, 0}},
{false, "for (const j of x) { let foo = j }", {0, 0, 0}},
{false, "for (const j of x) { let [foo] = [j] }", {0, 0, 0}},
{false, "for (const j of x) { const foo = j }", {0, 0, 0}},
{false, "for (const j of x) { const [foo] = [j] }", {0, 0, 0}},
{false, "for (const j of x) { function foo() {return j} }", {0, 0, 0}},
{true, "for (const {j} of x) { foo = j }", top},
{true, "for (const {j} of x) { [foo] = [j] }", top},
{true, "for (const {j} of x) { [[foo]=[42]] = [] }", top},
{true, "for (const {j} of x) { var foo = j }", top},
{true, "for (const {j} of x) { var [foo] = [j] }", top},
{true, "for (const {j} of x) { var [[foo]=[42]] = [] }", top},
{true, "for (const {j} of x) { var foo; foo = j }", top},
{true, "for (const {j} of x) { var foo; [foo] = [j] }", top},
{true, "for (const {j} of x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (const {j} of x) { let foo; foo = j }", {0, 0, 0}},
{true, "for (const {j} of x) { let foo; [foo] = [j] }", {0, 0, 0}},
{true, "for (const {j} of x) { let foo; [[foo]=[42]] = [] }", {0, 0, 0}},
{false, "for (const {j} of x) { let foo = j }", {0, 0, 0}},
{false, "for (const {j} of x) { let [foo] = [j] }", {0, 0, 0}},
{false, "for (const {j} of x) { const foo = j }", {0, 0, 0}},
{false, "for (const {j} of x) { const [foo] = [j] }", {0, 0, 0}},
{false, "for (const {j} of x) { function foo() {return j} }", {0, 0, 0}},
{true, "for (j in x) { foo = j }", top},
{true, "for (j in x) { [foo] = [j] }", top},
{true, "for (j in x) { [[foo]=[42]] = [] }", top},
{true, "for (j in x) { var foo = j }", top},
{true, "for (j in x) { var [foo] = [j] }", top},
{true, "for (j in x) { var [[foo]=[42]] = [] }", top},
{true, "for (j in x) { var foo; foo = j }", top},
{true, "for (j in x) { var foo; [foo] = [j] }", top},
{true, "for (j in x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (j in x) { let foo; foo = j }", {0}},
{true, "for (j in x) { let foo; [foo] = [j] }", {0}},
{true, "for (j in x) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (j in x) { let foo = j }", {0}},
{false, "for (j in x) { let [foo] = [j] }", {0}},
{false, "for (j in x) { const foo = j }", {0}},
{false, "for (j in x) { const [foo] = [j] }", {0}},
{false, "for (j in x) { function foo() {return j} }", {0}},
{true, "for ({j} in x) { foo = j }", top},
{true, "for ({j} in x) { [foo] = [j] }", top},
{true, "for ({j} in x) { [[foo]=[42]] = [] }", top},
{true, "for ({j} in x) { var foo = j }", top},
{true, "for ({j} in x) { var [foo] = [j] }", top},
{true, "for ({j} in x) { var [[foo]=[42]] = [] }", top},
{true, "for ({j} in x) { var foo; foo = j }", top},
{true, "for ({j} in x) { var foo; [foo] = [j] }", top},
{true, "for ({j} in x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for ({j} in x) { let foo; foo = j }", {0}},
{true, "for ({j} in x) { let foo; [foo] = [j] }", {0}},
{true, "for ({j} in x) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for ({j} in x) { let foo = j }", {0}},
{false, "for ({j} in x) { let [foo] = [j] }", {0}},
{false, "for ({j} in x) { const foo = j }", {0}},
{false, "for ({j} in x) { const [foo] = [j] }", {0}},
{false, "for ({j} in x) { function foo() {return j} }", {0}},
{true, "for (var j in x) { foo = j }", top},
{true, "for (var j in x) { [foo] = [j] }", top},
{true, "for (var j in x) { [[foo]=[42]] = [] }", top},
{true, "for (var j in x) { var foo = j }", top},
{true, "for (var j in x) { var [foo] = [j] }", top},
{true, "for (var j in x) { var [[foo]=[42]] = [] }", top},
{true, "for (var j in x) { var foo; foo = j }", top},
{true, "for (var j in x) { var foo; [foo] = [j] }", top},
{true, "for (var j in x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (var j in x) { let foo; foo = j }", {0}},
{true, "for (var j in x) { let foo; [foo] = [j] }", {0}},
{true, "for (var j in x) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (var j in x) { let foo = j }", {0}},
{false, "for (var j in x) { let [foo] = [j] }", {0}},
{false, "for (var j in x) { const foo = j }", {0}},
{false, "for (var j in x) { const [foo] = [j] }", {0}},
{false, "for (var j in x) { function foo() {return j} }", {0}},
{true, "for (var {j} in x) { foo = j }", top},
{true, "for (var {j} in x) { [foo] = [j] }", top},
{true, "for (var {j} in x) { [[foo]=[42]] = [] }", top},
{true, "for (var {j} in x) { var foo = j }", top},
{true, "for (var {j} in x) { var [foo] = [j] }", top},
{true, "for (var {j} in x) { var [[foo]=[42]] = [] }", top},
{true, "for (var {j} in x) { var foo; foo = j }", top},
{true, "for (var {j} in x) { var foo; [foo] = [j] }", top},
{true, "for (var {j} in x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (var {j} in x) { let foo; foo = j }", {0}},
{true, "for (var {j} in x) { let foo; [foo] = [j] }", {0}},
{true, "for (var {j} in x) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "for (var {j} in x) { let foo = j }", {0}},
{false, "for (var {j} in x) { let [foo] = [j] }", {0}},
{false, "for (var {j} in x) { const foo = j }", {0}},
{false, "for (var {j} in x) { const [foo] = [j] }", {0}},
{false, "for (var {j} in x) { function foo() {return j} }", {0}},
{true, "for (let j in x) { foo = j }", top},
{true, "for (let j in x) { [foo] = [j] }", top},
{true, "for (let j in x) { [[foo]=[42]] = [] }", top},
{true, "for (let j in x) { var foo = j }", top},
{true, "for (let j in x) { var [foo] = [j] }", top},
{true, "for (let j in x) { var [[foo]=[42]] = [] }", top},
{true, "for (let j in x) { var foo; foo = j }", top},
{true, "for (let j in x) { var foo; [foo] = [j] }", top},
{true, "for (let j in x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (let j in x) { let foo; foo = j }", {0, 0, 0}},
{true, "for (let j in x) { let foo; [foo] = [j] }", {0, 0, 0}},
{true, "for (let j in x) { let foo; [[foo]=[42]] = [] }", {0, 0, 0}},
{false, "for (let j in x) { let foo = j }", {0, 0, 0}},
{false, "for (let j in x) { let [foo] = [j] }", {0, 0, 0}},
{false, "for (let j in x) { const foo = j }", {0, 0, 0}},
{false, "for (let j in x) { const [foo] = [j] }", {0, 0, 0}},
{false, "for (let j in x) { function foo() {return j} }", {0, 0, 0}},
{true, "for (let {j} in x) { foo = j }", top},
{true, "for (let {j} in x) { [foo] = [j] }", top},
{true, "for (let {j} in x) { [[foo]=[42]] = [] }", top},
{true, "for (let {j} in x) { var foo = j }", top},
{true, "for (let {j} in x) { var [foo] = [j] }", top},
{true, "for (let {j} in x) { var [[foo]=[42]] = [] }", top},
{true, "for (let {j} in x) { var foo; foo = j }", top},
{true, "for (let {j} in x) { var foo; [foo] = [j] }", top},
{true, "for (let {j} in x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (let {j} in x) { let foo; foo = j }", {0, 0, 0}},
{true, "for (let {j} in x) { let foo; [foo] = [j] }", {0, 0, 0}},
{true, "for (let {j} in x) { let foo; [[foo]=[42]] = [] }", {0, 0, 0}},
{false, "for (let {j} in x) { let foo = j }", {0, 0, 0}},
{false, "for (let {j} in x) { let [foo] = [j] }", {0, 0, 0}},
{false, "for (let {j} in x) { const foo = j }", {0, 0, 0}},
{false, "for (let {j} in x) { const [foo] = [j] }", {0, 0, 0}},
{false, "for (let {j} in x) { function foo() {return j} }", {0, 0, 0}},
{true, "for (const j in x) { foo = j }", top},
{true, "for (const j in x) { [foo] = [j] }", top},
{true, "for (const j in x) { [[foo]=[42]] = [] }", top},
{true, "for (const j in x) { var foo = j }", top},
{true, "for (const j in x) { var [foo] = [j] }", top},
{true, "for (const j in x) { var [[foo]=[42]] = [] }", top},
{true, "for (const j in x) { var foo; foo = j }", top},
{true, "for (const j in x) { var foo; [foo] = [j] }", top},
{true, "for (const j in x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (const j in x) { let foo; foo = j }", {0, 0, 0}},
{true, "for (const j in x) { let foo; [foo] = [j] }", {0, 0, 0}},
{true, "for (const j in x) { let foo; [[foo]=[42]] = [] }", {0, 0, 0}},
{false, "for (const j in x) { let foo = j }", {0, 0, 0}},
{false, "for (const j in x) { let [foo] = [j] }", {0, 0, 0}},
{false, "for (const j in x) { const foo = j }", {0, 0, 0}},
{false, "for (const j in x) { const [foo] = [j] }", {0, 0, 0}},
{false, "for (const j in x) { function foo() {return j} }", {0, 0, 0}},
{true, "for (const {j} in x) { foo = j }", top},
{true, "for (const {j} in x) { [foo] = [j] }", top},
{true, "for (const {j} in x) { [[foo]=[42]] = [] }", top},
{true, "for (const {j} in x) { var foo = j }", top},
{true, "for (const {j} in x) { var [foo] = [j] }", top},
{true, "for (const {j} in x) { var [[foo]=[42]] = [] }", top},
{true, "for (const {j} in x) { var foo; foo = j }", top},
{true, "for (const {j} in x) { var foo; [foo] = [j] }", top},
{true, "for (const {j} in x) { var foo; [[foo]=[42]] = [] }", top},
{true, "for (const {j} in x) { let foo; foo = j }", {0, 0, 0}},
{true, "for (const {j} in x) { let foo; [foo] = [j] }", {0, 0, 0}},
{true, "for (const {j} in x) { let foo; [[foo]=[42]] = [] }", {0, 0, 0}},
{false, "for (const {j} in x) { let foo = j }", {0, 0, 0}},
{false, "for (const {j} in x) { let [foo] = [j] }", {0, 0, 0}},
{false, "for (const {j} in x) { const foo = j }", {0, 0, 0}},
{false, "for (const {j} in x) { const [foo] = [j] }", {0, 0, 0}},
{false, "for (const {j} in x) { function foo() {return j} }", {0, 0, 0}},
{true, "while (j) { foo = j }", top},
{true, "while (j) { [foo] = [j] }", top},
{true, "while (j) { [[foo]=[42]] = [] }", top},
{true, "while (j) { var foo = j }", top},
{true, "while (j) { var [foo] = [j] }", top},
{true, "while (j) { var [[foo]=[42]] = [] }", top},
{true, "while (j) { var foo; foo = j }", top},
{true, "while (j) { var foo; [foo] = [j] }", top},
{true, "while (j) { var foo; [[foo]=[42]] = [] }", top},
{true, "while (j) { let foo; foo = j }", {0}},
{true, "while (j) { let foo; [foo] = [j] }", {0}},
{true, "while (j) { let foo; [[foo]=[42]] = [] }", {0}},
{false, "while (j) { let foo = j }", {0}},
{false, "while (j) { let [foo] = [j] }", {0}},
{false, "while (j) { const foo = j }", {0}},
{false, "while (j) { const [foo] = [j] }", {0}},
{false, "while (j) { function foo() {return j} }", {0}},
{true, "do { foo = j } while (j)", top},
{true, "do { [foo] = [j] } while (j)", top},
{true, "do { [[foo]=[42]] = [] } while (j)", top},
{true, "do { var foo = j } while (j)", top},
{true, "do { var [foo] = [j] } while (j)", top},
{true, "do { var [[foo]=[42]] = [] } while (j)", top},
{true, "do { var foo; foo = j } while (j)", top},
{true, "do { var foo; [foo] = [j] } while (j)", top},
{true, "do { var foo; [[foo]=[42]] = [] } while (j)", top},
{true, "do { let foo; foo = j } while (j)", {0}},
{true, "do { let foo; [foo] = [j] } while (j)", {0}},
{true, "do { let foo; [[foo]=[42]] = [] } while (j)", {0}},
{false, "do { let foo = j } while (j)", {0}},
{false, "do { let [foo] = [j] } while (j)", {0}},
{false, "do { const foo = j } while (j)", {0}},
{false, "do { const [foo] = [j] } while (j)", {0}},
{false, "do { function foo() {return j} } while (j)", {0}},
};
Input script_only_tests[] = {
{true, "for (j=x; j<10; ++j) { function foo() {return j} }", top},
{true, "for ({j}=x; j<10; ++j) { function foo() {return j} }", top},
{true, "for (var j=x; j<10; ++j) { function foo() {return j} }", top},
{true, "for (var {j}=x; j<10; ++j) { function foo() {return j} }", top},
{true, "for (let j=x; j<10; ++j) { function foo() {return j} }", top},
{true, "for (let {j}=x; j<10; ++j) { function foo() {return j} }", top},
{true, "for (j of x) { function foo() {return j} }", top},
{true, "for ({j} of x) { function foo() {return j} }", top},
{true, "for (var j of x) { function foo() {return j} }", top},
{true, "for (var {j} of x) { function foo() {return j} }", top},
{true, "for (let j of x) { function foo() {return j} }", top},
{true, "for (let {j} of x) { function foo() {return j} }", top},
{true, "for (const j of x) { function foo() {return j} }", top},
{true, "for (const {j} of x) { function foo() {return j} }", top},
{true, "for (j in x) { function foo() {return j} }", top},
{true, "for ({j} in x) { function foo() {return j} }", top},
{true, "for (var j in x) { function foo() {return j} }", top},
{true, "for (var {j} in x) { function foo() {return j} }", top},
{true, "for (let j in x) { function foo() {return j} }", top},
{true, "for (let {j} in x) { function foo() {return j} }", top},
{true, "for (const j in x) { function foo() {return j} }", top},
{true, "for (const {j} in x) { function foo() {return j} }", top},
{true, "while (j) { function foo() {return j} }", top},
{true, "do { function foo() {return j} } while (j)", top},
};
for (unsigned i = 0; i < arraysize(module_and_script_tests); ++i) {
Input input = module_and_script_tests[i];
for (unsigned module = 0; module <= 1; ++module) {
for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1;
++allow_lazy_parsing) {
TestMaybeAssigned(input, "foo", module, allow_lazy_parsing);
}
TestMaybeAssigned(wrap(input), "foo", module, false);
}
}
for (unsigned i = 0; i < arraysize(script_only_tests); ++i) {
Input input = script_only_tests[i];
for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1;
++allow_lazy_parsing) {
TestMaybeAssigned(input, "foo", false, allow_lazy_parsing);
}
TestMaybeAssigned(wrap(input), "foo", false, false);
}
}
TEST(MaybeAssignedTopLevel) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
const char* prefixes[] = {
"let foo; ",
"let foo = 0; ",
"let [foo] = [1]; ",
"let {foo} = {foo: 2}; ",
"let {foo=3} = {}; ",
"var foo; ",
"var foo = 0; ",
"var [foo] = [1]; ",
"var {foo} = {foo: 2}; ",
"var {foo=3} = {}; ",
"{ var foo; }; ",
"{ var foo = 0; }; ",
"{ var [foo] = [1]; }; ",
"{ var {foo} = {foo: 2}; }; ",
"{ var {foo=3} = {}; }; ",
"function foo() {}; ",
"function* foo() {}; ",
"async function foo() {}; ",
"class foo {}; ",
"class foo extends null {}; ",
};
const char* module_and_script_tests[] = {
"function bar() {foo = 42}; ext(bar); ext(foo)",
"ext(function() {foo++}); ext(foo)",
"bar = () => --foo; ext(bar); ext(foo)",
"function* bar() {eval(ext)}; ext(bar); ext(foo)",
};
const char* script_only_tests[] = {
"",
"{ function foo() {}; }; ",
"{ function* foo() {}; }; ",
"{ async function foo() {}; }; ",
};
for (unsigned i = 0; i < arraysize(prefixes); ++i) {
for (unsigned j = 0; j < arraysize(module_and_script_tests); ++j) {
std::string source(prefixes[i]);
source += module_and_script_tests[j];
std::vector<unsigned> top;
Input input({true, source, top});
for (unsigned module = 0; module <= 1; ++module) {
for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1;
++allow_lazy_parsing) {
TestMaybeAssigned(input, "foo", module, allow_lazy_parsing);
}
}
}
}
for (unsigned i = 0; i < arraysize(prefixes); ++i) {
for (unsigned j = 0; j < arraysize(script_only_tests); ++j) {
std::string source(prefixes[i]);
source += script_only_tests[j];
std::vector<unsigned> top;
Input input({true, source, top});
for (unsigned allow_lazy_parsing = 0; allow_lazy_parsing <= 1;
++allow_lazy_parsing) {
TestMaybeAssigned(input, "foo", false, allow_lazy_parsing);
}
}
}
}
#if V8_ENABLE_WEBASSEMBLY
namespace {
i::Scope* DeserializeFunctionScope(i::Isolate* isolate, i::Zone* zone,
i::Handle<i::JSObject> m, const char* name) {
i::AstValueFactory avf(zone, isolate->ast_string_constants(),
HashSeed(isolate));
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(
i::JSReceiver::GetProperty(isolate, m, name).ToHandleChecked());
i::DeclarationScope* script_scope =
zone->New<i::DeclarationScope>(zone, &avf);
i::Scope* s = i::Scope::DeserializeScopeChain(
isolate, zone, f->context().scope_info(), script_scope, &avf,
i::Scope::DeserializationMode::kIncludingVariables);
return s;
}
} // namespace
TEST(AsmModuleFlag) {
i::FLAG_validate_asm = false;
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
const char* src =
"function m() {"
" 'use asm';"
" function f() { return 0 };"
" return { f:f };"
"}"
"m();";
i::Zone zone(isolate->allocator(), ZONE_NAME);
v8::Local<v8::Value> v = CompileRun(src);
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSObject> m = i::Handle<i::JSObject>::cast(o);
// The asm.js module should be marked as such.
i::Scope* s = DeserializeFunctionScope(isolate, &zone, m, "f");
CHECK(s->IsAsmModule() && s->AsDeclarationScope()->is_asm_module());
}
TEST(UseAsmUseCount) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
global_use_counts = use_counts;
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
CompileRun("\"use asm\";\n"
"var foo = 1;\n"
"function bar() { \"use asm\"; var baz = 1; }");
CHECK_LT(0, use_counts[v8::Isolate::kUseAsm]);
}
#endif // V8_ENABLE_WEBASSEMBLY
TEST(StrictModeUseCount) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
global_use_counts = use_counts;
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
CompileRun(
"\"use strict\";\n"
"function bar() { var baz = 1; }"); // strict mode inherits
CHECK_LT(0, use_counts[v8::Isolate::kStrictMode]);
CHECK_EQ(0, use_counts[v8::Isolate::kSloppyMode]);
}
TEST(SloppyModeUseCount) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
global_use_counts = use_counts;
// Force eager parsing (preparser doesn't update use counts).
i::FLAG_lazy = false;
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
CompileRun("function bar() { var baz = 1; }");
CHECK_LT(0, use_counts[v8::Isolate::kSloppyMode]);
CHECK_EQ(0, use_counts[v8::Isolate::kStrictMode]);
}
TEST(BothModesUseCount) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
global_use_counts = use_counts;
// Force eager parsing (preparser doesn't update use counts).
i::FLAG_lazy = false;
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
CompileRun("function bar() { 'use strict'; var baz = 1; }");
CHECK_LT(0, use_counts[v8::Isolate::kSloppyMode]);
CHECK_LT(0, use_counts[v8::Isolate::kStrictMode]);
}
TEST(LineOrParagraphSeparatorAsLineTerminator) {
// Tests that both preparsing and parsing accept U+2028 LINE SEPARATOR and
// U+2029 PARAGRAPH SEPARATOR as LineTerminator symbols outside of string
// literals.
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"\x31\xE2\x80\xA8\x32", // 1<U+2028>2
"\x31\xE2\x80\xA9\x32", // 1<U+2029>2
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(LineOrParagraphSeparatorInStringLiteral) {
// Tests that both preparsing and parsing don't treat U+2028 LINE SEPARATOR
// and U+2029 PARAGRAPH SEPARATOR as line terminators within string literals.
// https://github.com/tc39/proposal-json-superset
const char* context_data[][2] = {
{"\"", "\""}, {"'", "'"}, {nullptr, nullptr}};
const char* statement_data[] = {"\x31\xE2\x80\xA8\x32", // 1<U+2028>2
"\x31\xE2\x80\xA9\x32", // 1<U+2029>2
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ErrorsArrowFormalParameters) {
const char* context_data[][2] = {
{ "()", "=>{}" },
{ "()", "=>{};" },
{ "var x = ()", "=>{}" },
{ "var x = ()", "=>{};" },
{ "a", "=>{}" },
{ "a", "=>{};" },
{ "var x = a", "=>{}" },
{ "var x = a", "=>{};" },
{ "(a)", "=>{}" },
{ "(a)", "=>{};" },
{ "var x = (a)", "=>{}" },
{ "var x = (a)", "=>{};" },
{ "(...a)", "=>{}" },
{ "(...a)", "=>{};" },
{ "var x = (...a)", "=>{}" },
{ "var x = (...a)", "=>{};" },
{ "(a,b)", "=>{}" },
{ "(a,b)", "=>{};" },
{ "var x = (a,b)", "=>{}" },
{ "var x = (a,b)", "=>{};" },
{ "(a,...b)", "=>{}" },
{ "(a,...b)", "=>{};" },
{ "var x = (a,...b)", "=>{}" },
{ "var x = (a,...b)", "=>{};" },
{ nullptr, nullptr }
};
const char* assignment_expression_suffix_data[] = {
"?c:d=>{}",
"=c=>{}",
"()",
"(c)",
"[1]",
"[c]",
".c",
"-c",
"+c",
"c++",
"`c`",
"`${c}`",
"`template-head${c}`",
"`${c}template-tail`",
"`template-head${c}template-tail`",
"`${c}template-tail`",
nullptr
};
RunParserSyncTest(context_data, assignment_expression_suffix_data, kError);
}
TEST(ErrorsArrowFunctions) {
// Tests that parser and preparser generate the same kind of errors
// on invalid arrow function syntax.
// clang-format off
const char* context_data[][2] = {
{"", ";"},
{"v = ", ";"},
{"bar ? (", ") : baz;"},
{"bar ? baz : (", ");"},
{"bar[", "];"},
{"bar, ", ";"},
{"", ", bar;"},
{nullptr, nullptr}
};
const char* statement_data[] = {
"=> 0",
"=>",
"() =>",
"=> {}",
") => {}",
", => {}",
"(,) => {}",
"return => {}",
"() => {'value': 42}",
// Check that the early return introduced in ParsePrimaryExpression
// does not accept stray closing parentheses.
")",
") => 0",
"foo[()]",
"()",
// Parameter lists with extra parens should be recognized as errors.
"(()) => 0",
"((x)) => 0",
"((x, y)) => 0",
"(x, (y)) => 0",
"((x, y, z)) => 0",
"(x, (y, z)) => 0",
"((x, y), z) => 0",
// Arrow function formal parameters are parsed as StrictFormalParameters,
// which confusingly only implies that there are no duplicates. Words
// reserved in strict mode, and eval or arguments, are indeed valid in
// sloppy mode.
"eval => { 'use strict'; 0 }",
"arguments => { 'use strict'; 0 }",
"yield => { 'use strict'; 0 }",
"interface => { 'use strict'; 0 }",
"(eval) => { 'use strict'; 0 }",
"(arguments) => { 'use strict'; 0 }",
"(yield) => { 'use strict'; 0 }",
"(interface) => { 'use strict'; 0 }",
"(eval, bar) => { 'use strict'; 0 }",
"(bar, eval) => { 'use strict'; 0 }",
"(bar, arguments) => { 'use strict'; 0 }",
"(bar, yield) => { 'use strict'; 0 }",
"(bar, interface) => { 'use strict'; 0 }",
// TODO(aperez): Detecting duplicates does not work in PreParser.
// "(bar, bar) => {}",
// The parameter list is parsed as an expression, but only
// a comma-separated list of identifier is valid.
"32 => {}",
"(32) => {}",
"(a, 32) => {}",
"if => {}",
"(if) => {}",
"(a, if) => {}",
"a + b => {}",
"(a + b) => {}",
"(a + b, c) => {}",
"(a, b - c) => {}",
"\"a\" => {}",
"(\"a\") => {}",
"(\"a\", b) => {}",
"(a, \"b\") => {}",
"-a => {}",
"(-a) => {}",
"(-a, b) => {}",
"(a, -b) => {}",
"{} => {}",
"a++ => {}",
"(a++) => {}",
"(a++, b) => {}",
"(a, b++) => {}",
"[] => {}",
"(foo ? bar : baz) => {}",
"(a, foo ? bar : baz) => {}",
"(foo ? bar : baz, a) => {}",
"(a.b, c) => {}",
"(c, a.b) => {}",
"(a['b'], c) => {}",
"(c, a['b']) => {}",
"(...a = b) => b",
// crbug.com/582626
"(...rest - a) => b",
"(a, ...b - 10) => b",
nullptr
};
// clang-format on
// The test is quite slow, so run it with a reduced set of flags.
static const ParserFlag flags[] = {kAllowLazy};
RunParserSyncTest(context_data, statement_data, kError, flags,
arraysize(flags));
// In a context where a concise arrow body is parsed with [~In] variant,
// ensure that an error is reported in both full parser and preparser.
const char* loop_context_data[][2] = {{"for (", "; 0;);"},
{nullptr, nullptr}};
const char* loop_expr_data[] = {"f => 'key' in {}", nullptr};
RunParserSyncTest(loop_context_data, loop_expr_data, kError, flags,
arraysize(flags));
}
TEST(NoErrorsArrowFunctions) {
// Tests that parser and preparser accept valid arrow functions syntax.
// clang-format off
const char* context_data[][2] = {
{"", ";"},
{"bar ? (", ") : baz;"},
{"bar ? baz : (", ");"},
{"bar, ", ";"},
{"", ", bar;"},
{nullptr, nullptr}
};
const char* statement_data[] = {
"() => {}",
"() => { return 42 }",
"x => { return x; }",
"(x) => { return x; }",
"(x, y) => { return x + y; }",
"(x, y, z) => { return x + y + z; }",
"(x, y) => { x.a = y; }",
"() => 42",
"x => x",
"x => x * x",
"(x) => x",
"(x) => x * x",
"(x, y) => x + y",
"(x, y, z) => x, y, z",
"(x, y) => x.a = y",
"() => ({'value': 42})",
"x => y => x + y",
"(x, y) => (u, v) => x*u + y*v",
"(x, y) => z => z * (x + y)",
"x => (y, z) => z * (x + y)",
// Those are comma-separated expressions, with arrow functions as items.
// They stress the code for validating arrow function parameter lists.
"a, b => 0",
"a, b, (c, d) => 0",
"(a, b, (c, d) => 0)",
"(a, b) => 0, (c, d) => 1",
"(a, b => {}, a => a + 1)",
"((a, b) => {}, (a => a + 1))",
"(a, (a, (b, c) => 0))",
// Arrow has more precedence, this is the same as: foo ? bar : (baz = {})
"foo ? bar : baz => {}",
// Arrows with non-simple parameters.
"({}) => {}",
"(a, {}) => {}",
"({}, a) => {}",
"([]) => {}",
"(a, []) => {}",
"([], a) => {}",
"(a = b) => {}",
"(a = b, c) => {}",
"(a, b = c) => {}",
"({a}) => {}",
"(x = 9) => {}",
"(x, y = 9) => {}",
"(x = 9, y) => {}",
"(x, y = 9, z) => {}",
"(x, y = 9, z = 8) => {}",
"(...a) => {}",
"(x, ...a) => {}",
"(x = 9, ...a) => {}",
"(x, y = 9, ...a) => {}",
"(x, y = 9, {b}, z = 8, ...a) => {}",
"({a} = {}) => {}",
"([x] = []) => {}",
"({a = 42}) => {}",
"([x = 0]) => {}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kSuccess);
static const ParserFlag flags[] = {kAllowLazy};
// In a context where a concise arrow body is parsed with [~In] variant,
// ensure that nested expressions can still use the 'in' operator,
const char* loop_context_data[][2] = {{"for (", "; 0;);"},
{nullptr, nullptr}};
const char* loop_expr_data[] = {"f => ('key' in {})", nullptr};
RunParserSyncTest(loop_context_data, loop_expr_data, kSuccess, flags,
arraysize(flags));
}
TEST(ArrowFunctionsSloppyParameterNames) {
const char* strict_context_data[][2] = {{"'use strict'; ", ";"},
{"'use strict'; bar ? (", ") : baz;"},
{"'use strict'; bar ? baz : (", ");"},
{"'use strict'; bar, ", ";"},
{"'use strict'; ", ", bar;"},
{nullptr, nullptr}};
const char* sloppy_context_data[][2] = {
{"", ";"}, {"bar ? (", ") : baz;"}, {"bar ? baz : (", ");"},
{"bar, ", ";"}, {"", ", bar;"}, {nullptr, nullptr}};
const char* statement_data[] = {"eval => {}",
"arguments => {}",
"yield => {}",
"interface => {}",
"(eval) => {}",
"(arguments) => {}",
"(yield) => {}",
"(interface) => {}",
"(eval, bar) => {}",
"(bar, eval) => {}",
"(bar, arguments) => {}",
"(bar, yield) => {}",
"(bar, interface) => {}",
"(interface, eval) => {}",
"(interface, arguments) => {}",
"(eval, interface) => {}",
"(arguments, interface) => {}",
nullptr};
RunParserSyncTest(strict_context_data, statement_data, kError);
RunParserSyncTest(sloppy_context_data, statement_data, kSuccess);
}
TEST(ArrowFunctionsYieldParameterNameInGenerator) {
const char* sloppy_function_context_data[][2] = {
{"(function f() { (", "); });"}, {nullptr, nullptr}};
const char* strict_function_context_data[][2] = {
{"(function f() {'use strict'; (", "); });"}, {nullptr, nullptr}};
const char* generator_context_data[][2] = {
{"(function *g() {'use strict'; (", "); });"},
{"(function *g() { (", "); });"},
{nullptr, nullptr}};
const char* arrow_data[] = {
"yield => {}", "(yield) => {}", "(a, yield) => {}",
"(yield, a) => {}", "(yield, ...a) => {}", "(a, ...yield) => {}",
"({yield}) => {}", "([yield]) => {}", nullptr};
RunParserSyncTest(sloppy_function_context_data, arrow_data, kSuccess);
RunParserSyncTest(strict_function_context_data, arrow_data, kError);
RunParserSyncTest(generator_context_data, arrow_data, kError);
}
TEST(SuperNoErrors) {
// Tests that parser and preparser accept 'super' keyword in right places.
const char* context_data[][2] = {{"class C { m() { ", "; } }"},
{"class C { m() { k = ", "; } }"},
{"class C { m() { foo(", "); } }"},
{"class C { m() { () => ", "; } }"},
{nullptr, nullptr}};
const char* statement_data[] = {"super.x", "super[27]",
"new super.x", "new super.x()",
"new super[27]", "new super[27]()",
"z.super", // Ok, property lookup.
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(SuperErrors) {
const char* context_data[][2] = {{"class C { m() { ", "; } }"},
{"class C { m() { k = ", "; } }"},
{"class C { m() { foo(", "); } }"},
{"class C { m() { () => ", "; } }"},
{nullptr, nullptr}};
const char* expression_data[] = {"super",
"super = x",
"y = super",
"f(super)",
"new super",
"new super()",
"new super(12, 45)",
"new new super",
"new new super()",
"new new super()()",
nullptr};
RunParserSyncTest(context_data, expression_data, kError);
}
TEST(ImportExpressionSuccess) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{nullptr, nullptr}
};
const char* data[] = {
"import(1)",
"import(y=x)",
"f(...[import(y=x)])",
"x = {[import(y=x)]: 1}",
"var {[import(y=x)]: x} = {}",
"({[import(y=x)]: x} = {})",
"async () => { await import(x) }",
"() => { import(x) }",
"(import(y=x))",
"{import(y=x)}",
"import(import(x))",
"x = import(x)",
"var x = import(x)",
"let x = import(x)",
"for(x of import(x)) {}",
"import(x).then()",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
RunModuleParserSyncTest(context_data, data, kSuccess);
}
TEST(ImportExpressionWithImportAssertionSuccess) {
i::FLAG_harmony_import_assertions = true;
// clang-format off
const char* context_data[][2] = {
{"", ""},
{nullptr, nullptr}
};
const char* data[] = {
"import(x,)",
"import(x,1)",
"import(x,y)",
"import(x,y,)",
"import(x, { 'a': 'b' })",
"import(x, { a: 'b', 'c': 'd' },)",
"import(x, { 'a': { b: 'c' }, 'd': 'e' },)",
"import(x,import(y))",
"import(x,y=z)",
"import(x,[y, z])",
"import(x,undefined)",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
RunModuleParserSyncTest(context_data, data, kSuccess);
}
TEST(ImportExpressionErrors) {
{
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"var ", ""},
{"let ", ""},
{"new ", ""},
{nullptr, nullptr}
};
const char* data[] = {
"import(",
"import)",
"import()",
"import('x",
"import('x']",
"import['x')",
"import = x",
"import[",
"import[]",
"import]",
"import[x]",
"import{",
"import{x",
"import{x}",
"import(x, y)",
"import(...y)",
"import(x,)",
"import(,)",
"import(,y)",
"import(;)",
"[import]",
"{import}",
"import+",
"import = 1",
"import.wat",
"new import(x)",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
// We ignore test error messages because the error message from
// the parser/preparser is different for the same data depending
// on the context. For example, a top level "import{" is parsed
// as an import declaration. The parser parses the import token
// correctly and then shows an "Unexpected end of input" error
// message because of the '{'. The preparser shows an "Unexpected
// token '{'" because it's not a valid token in a CallExpression.
RunModuleParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0,
nullptr, 0, true, true);
}
{
// clang-format off
const char* context_data[][2] = {
{"var ", ""},
{"let ", ""},
{nullptr, nullptr}
};
const char* data[] = {
"import('x')",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
RunModuleParserSyncTest(context_data, data, kError);
}
// Import statements as arrow function params and destructuring targets.
{
// clang-format off
const char* context_data[][2] = {
{"(", ") => {}"},
{"(a, ", ") => {}"},
{"(1, ", ") => {}"},
{"let f = ", " => {}"},
{"[", "] = [1];"},
{"{", "} = {'a': 1};"},
{nullptr, nullptr}
};
const char* data[] = {
"import(foo)",
"import(1)",
"import(y=x)",
"import(import(x))",
"import(x).then()",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
RunModuleParserSyncTest(context_data, data, kError);
}
}
TEST(ImportExpressionWithImportAssertionErrors) {
{
i::FLAG_harmony_import_assertions = true;
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"var ", ""},
{"let ", ""},
{"new ", ""},
{nullptr, nullptr}
};
const char* data[] = {
"import(x,,)",
"import(x))",
"import(x,))",
"import(x,())",
"import(x,y,,)",
"import(x,y,z)",
"import(x,y",
"import(x,y,",
"import(x,y(",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
RunModuleParserSyncTest(context_data, data, kError);
}
{
// clang-format off
const char* context_data[][2] = {
{"var ", ""},
{"let ", ""},
{nullptr, nullptr}
};
const char* data[] = {
"import('x',y)",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
RunModuleParserSyncTest(context_data, data, kError);
}
// Import statements as arrow function params and destructuring targets.
{
// clang-format off
const char* context_data[][2] = {
{"(", ") => {}"},
{"(a, ", ") => {}"},
{"(1, ", ") => {}"},
{"let f = ", " => {}"},
{"[", "] = [1];"},
{"{", "} = {'a': 1};"},
{nullptr, nullptr}
};
const char* data[] = {
"import(foo,y)",
"import(1,y)",
"import(y=x,z)",
"import(import(x),y)",
"import(x,y).then()",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
RunModuleParserSyncTest(context_data, data, kError);
}
}
TEST(BasicImportAssertionParsing) {
// clang-format off
const char* kSources[] = {
"import { a as b } from 'm.js' assert { };",
"import n from 'n.js' assert { };",
"export { a as b } from 'm.js' assert { };",
"export * from 'm.js' assert { };",
"import 'm.js' assert { };",
"import * as foo from 'bar.js' assert { };",
"import { a as b } from 'm.js' assert { a: 'b' };",
"import { a as b } from 'm.js' assert { c: 'd' };",
"import { a as b } from 'm.js' assert { 'c': 'd' };",
"import { a as b } from 'm.js' assert { a: 'b', 'c': 'd', e: 'f' };",
"import { a as b } from 'm.js' assert { 'c': 'd', };",
"import n from 'n.js' assert { 'c': 'd' };",
"export { a as b } from 'm.js' assert { 'c': 'd' };",
"export * from 'm.js' assert { 'c': 'd' };",
"import 'm.js' assert { 'c': 'd' };",
"import * as foo from 'bar.js' assert { 'c': 'd' };",
"import { a as b } from 'm.js' assert { \nc: 'd'};",
"import { a as b } from 'm.js' assert { c:\n 'd'};",
"import { a as b } from 'm.js' assert { c:'d'\n};",
};
// clang-format on
i::FLAG_harmony_import_assertions = true;
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
for (unsigned i = 0; i < arraysize(kSources); ++i) {
i::Handle<i::String> source =
factory->NewStringFromAsciiChecked(kSources[i]);
// Show that parsing as a module works
{
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
}
// And that parsing a script does not.
{
i::UnoptimizedCompileState compile_state(isolate);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK(!i::parsing::ParseProgram(&info, script, isolate,
parsing::ReportStatisticsMode::kYes));
CHECK(info.pending_error_handler()->has_pending_error());
}
}
}
TEST(ImportAssertionParsingErrors) {
// clang-format off
const char* kErrorSources[] = {
"import { a } from 'm.js' assert {;",
"import { a } from 'm.js' assert };",
"import { a } from 'm.js' , assert { };",
"import { a } from 'm.js' assert , { };",
"import { a } from 'm.js' assert { , };",
"import { a } from 'm.js' assert { b };",
"import { a } from 'm.js' assert { 'b' };",
"import { a } from 'm.js' assert { for };",
"import { a } from 'm.js' assert { assert };",
"export { a } assert { };",
"export * assert { };",
"import 'm.js'\n assert { };",
"import 'm.js' \nassert { };",
"import { a } from 'm.js'\n assert { };",
"export * from 'm.js'\n assert { };",
"import { a } from 'm.js' assert { 1: 2 };",
"import { a } from 'm.js' assert { b: c };",
"import { a } from 'm.js' assert { 'b': c };",
"import { a } from 'm.js' assert { , b: c };",
"import { a } from 'm.js' assert { a: 'b', a: 'c' };",
"import { a } from 'm.js' assert { a: 'b', 'a': 'c' };",
};
// clang-format on
i::FLAG_harmony_import_assertions = true;
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
i::Handle<i::String> source =
factory->NewStringFromAsciiChecked(kErrorSources[i]);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK(!i::parsing::ParseProgram(&info, script, isolate,
parsing::ReportStatisticsMode::kYes));
CHECK(info.pending_error_handler()->has_pending_error());
}
}
TEST(SuperCall) {
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* success_data[] = {
"class C extends B { constructor() { super(); } }",
"class C extends B { constructor() { () => super(); } }", nullptr};
RunParserSyncTest(context_data, success_data, kSuccess);
const char* error_data[] = {"class C { constructor() { super(); } }",
"class C { method() { super(); } }",
"class C { method() { () => super(); } }",
"class C { *method() { super(); } }",
"class C { get x() { super(); } }",
"class C { set x(_) { super(); } }",
"({ method() { super(); } })",
"({ *method() { super(); } })",
"({ get x() { super(); } })",
"({ set x(_) { super(); } })",
"({ f: function() { super(); } })",
"(function() { super(); })",
"var f = function() { super(); }",
"({ f: function*() { super(); } })",
"(function*() { super(); })",
"var f = function*() { super(); }",
nullptr};
RunParserSyncTest(context_data, error_data, kError);
}
TEST(SuperNewNoErrors) {
const char* context_data[][2] = {{"class C { constructor() { ", " } }"},
{"class C { *method() { ", " } }"},
{"class C { get x() { ", " } }"},
{"class C { set x(_) { ", " } }"},
{"({ method() { ", " } })"},
{"({ *method() { ", " } })"},
{"({ get x() { ", " } })"},
{"({ set x(_) { ", " } })"},
{nullptr, nullptr}};
const char* expression_data[] = {"new super.x;", "new super.x();",
"() => new super.x;", "() => new super.x();",
nullptr};
RunParserSyncTest(context_data, expression_data, kSuccess);
}
TEST(SuperNewErrors) {
const char* context_data[][2] = {{"class C { method() { ", " } }"},
{"class C { *method() { ", " } }"},
{"class C { get x() { ", " } }"},
{"class C { set x(_) { ", " } }"},
{"({ method() { ", " } })"},
{"({ *method() { ", " } })"},
{"({ get x() { ", " } })"},
{"({ set x(_) { ", " } })"},
{"({ f: function() { ", " } })"},
{"(function() { ", " })"},
{"var f = function() { ", " }"},
{"({ f: function*() { ", " } })"},
{"(function*() { ", " })"},
{"var f = function*() { ", " }"},
{nullptr, nullptr}};
const char* statement_data[] = {"new super;", "new super();",
"() => new super;", "() => new super();",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(SuperErrorsNonMethods) {
// super is only allowed in methods, accessors and constructors.
const char* context_data[][2] = {{"", ";"},
{"k = ", ";"},
{"foo(", ");"},
{"if (", ") {}"},
{"if (true) {", "}"},
{"if (false) {} else {", "}"},
{"while (true) {", "}"},
{"function f() {", "}"},
{"class C extends (", ") {}"},
{"class C { m() { function f() {", "} } }"},
{"({ m() { function f() {", "} } })"},
{nullptr, nullptr}};
const char* statement_data[] = {
"super", "super = x", "y = super", "f(super)",
"super.x", "super[27]", "super.x()", "super[27]()",
"super()", "new super.x", "new super.x()", "new super[27]",
"new super[27]()", nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(NoErrorsMethodDefinition) {
const char* context_data[][2] = {{"({", "});"},
{"'use strict'; ({", "});"},
{"({*", "});"},
{"'use strict'; ({*", "});"},
{nullptr, nullptr}};
const char* object_literal_body_data[] = {
"m() {}", "m(x) { return x; }", "m(x, y) {}, n() {}",
"set(x, y) {}", "get(x, y) {}", nullptr};
RunParserSyncTest(context_data, object_literal_body_data, kSuccess);
}
TEST(MethodDefinitionNames) {
const char* context_data[][2] = {{"({", "(x, y) {}});"},
{"'use strict'; ({", "(x, y) {}});"},
{"({*", "(x, y) {}});"},
{"'use strict'; ({*", "(x, y) {}});"},
{nullptr, nullptr}};
const char* name_data[] = {
"m", "'m'", "\"m\"", "\"m n\"", "true", "false", "null", "0", "1.2",
"1e1", "1E1", "1e+1", "1e-1",
// Keywords
"async", "await", "break", "case", "catch", "class", "const", "continue",
"debugger", "default", "delete", "do", "else", "enum", "export",
"extends", "finally", "for", "function", "if", "implements", "import",
"in", "instanceof", "interface", "let", "new", "package", "private",
"protected", "public", "return", "static", "super", "switch", "this",
"throw", "try", "typeof", "var", "void", "while", "with", "yield",
nullptr};
RunParserSyncTest(context_data, name_data, kSuccess);
}
TEST(MethodDefinitionStrictFormalParamereters) {
const char* context_data[][2] = {{"({method(", "){}});"},
{"'use strict'; ({method(", "){}});"},
{"({*method(", "){}});"},
{"'use strict'; ({*method(", "){}});"},
{nullptr, nullptr}};
const char* params_data[] = {"x, x", "x, y, x", "var", "const", nullptr};
RunParserSyncTest(context_data, params_data, kError);
}
TEST(MethodDefinitionEvalArguments) {
const char* strict_context_data[][2] = {
{"'use strict'; ({method(", "){}});"},
{"'use strict'; ({*method(", "){}});"},
{nullptr, nullptr}};
const char* sloppy_context_data[][2] = {
{"({method(", "){}});"}, {"({*method(", "){}});"}, {nullptr, nullptr}};
const char* data[] = {"eval", "arguments", nullptr};
// Fail in strict mode
RunParserSyncTest(strict_context_data, data, kError);
// OK in sloppy mode
RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
TEST(MethodDefinitionDuplicateEvalArguments) {
const char* context_data[][2] = {{"'use strict'; ({method(", "){}});"},
{"'use strict'; ({*method(", "){}});"},
{"({method(", "){}});"},
{"({*method(", "){}});"},
{nullptr, nullptr}};
const char* data[] = {"eval, eval", "eval, a, eval", "arguments, arguments",
"arguments, a, arguments", nullptr};
// In strict mode, the error is using "eval" or "arguments" as parameter names
// In sloppy mode, the error is that eval / arguments are duplicated
RunParserSyncTest(context_data, data, kError);
}
TEST(MethodDefinitionDuplicateProperty) {
const char* context_data[][2] = {{"'use strict'; ({", "});"},
{nullptr, nullptr}};
const char* params_data[] = {"x: 1, x() {}",
"x() {}, x: 1",
"x() {}, get x() {}",
"x() {}, set x(_) {}",
"x() {}, x() {}",
"x() {}, y() {}, x() {}",
"x() {}, \"x\"() {}",
"x() {}, 'x'() {}",
"0() {}, '0'() {}",
"1.0() {}, 1: 1",
"x: 1, *x() {}",
"*x() {}, x: 1",
"*x() {}, get x() {}",
"*x() {}, set x(_) {}",
"*x() {}, *x() {}",
"*x() {}, y() {}, *x() {}",
"*x() {}, *\"x\"() {}",
"*x() {}, *'x'() {}",
"*0() {}, *'0'() {}",
"*1.0() {}, 1: 1",
nullptr};
RunParserSyncTest(context_data, params_data, kSuccess);
}
TEST(ClassExpressionNoErrors) {
const char* context_data[][2] = {
{"(", ");"}, {"var C = ", ";"}, {"bar, ", ";"}, {nullptr, nullptr}};
const char* class_data[] = {"class {}",
"class name {}",
"class extends F {}",
"class name extends F {}",
"class extends (F, G) {}",
"class name extends (F, G) {}",
"class extends class {} {}",
"class name extends class {} {}",
"class extends class base {} {}",
"class name extends class base {} {}",
nullptr};
RunParserSyncTest(context_data, class_data, kSuccess);
}
TEST(ClassDeclarationNoErrors) {
const char* context_data[][2] = {{"'use strict'; ", ""},
{"'use strict'; {", "}"},
{"'use strict'; if (true) {", "}"},
{nullptr, nullptr}};
const char* statement_data[] = {"class name {}",
"class name extends F {}",
"class name extends (F, G) {}",
"class name extends class {} {}",
"class name extends class base {} {}",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ClassBodyNoErrors) {
// clang-format off
// Tests that parser and preparser accept valid class syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
";",
";;",
"m() {}",
"m() {};",
"; m() {}",
"m() {}; n(x) {}",
"get x() {}",
"set x(v) {}",
"get() {}",
"set() {}",
"*g() {}",
"*g() {};",
"; *g() {}",
"*g() {}; *h(x) {}",
"async *x(){}",
"static() {}",
"get static() {}",
"set static(v) {}",
"static m() {}",
"static get x() {}",
"static set x(v) {}",
"static get() {}",
"static set() {}",
"static static() {}",
"static get static() {}",
"static set static(v) {}",
"*static() {}",
"static *static() {}",
"*get() {}",
"*set() {}",
"static *g() {}",
"async(){}",
"*async(){}",
"static async(){}",
"static *async(){}",
"static async *x(){}",
// Escaped 'static' should be allowed anywhere
// static-as-PropertyName is.
"st\\u0061tic() {}",
"get st\\u0061tic() {}",
"set st\\u0061tic(v) {}",
"static st\\u0061tic() {}",
"static get st\\u0061tic() {}",
"static set st\\u0061tic(v) {}",
"*st\\u0061tic() {}",
"static *st\\u0061tic() {}",
"static async x(){}",
"static async(){}",
"static *async(){}",
"async x(){}",
"async 0(){}",
"async get(){}",
"async set(){}",
"async static(){}",
"async async(){}",
"async(){}",
"*async(){}",
nullptr};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(ClassPropertyNameNoErrors) {
const char* context_data[][2] = {{"(class {", "() {}});"},
{"(class { get ", "() {}});"},
{"(class { set ", "(v) {}});"},
{"(class { static ", "() {}});"},
{"(class { static get ", "() {}});"},
{"(class { static set ", "(v) {}});"},
{"(class { *", "() {}});"},
{"(class { static *", "() {}});"},
{"class C {", "() {}}"},
{"class C { get ", "() {}}"},
{"class C { set ", "(v) {}}"},
{"class C { static ", "() {}}"},
{"class C { static get ", "() {}}"},
{"class C { static set ", "(v) {}}"},
{"class C { *", "() {}}"},
{"class C { static *", "() {}}"},
{nullptr, nullptr}};
const char* name_data[] = {
"42", "42.5", "42e2", "42e+2", "42e-2", "null",
"false", "true", "'str'", "\"str\"", "static", "get",
"set", "var", "const", "let", "this", "class",
"function", "yield", "if", "else", "for", "while",
"do", "try", "catch", "finally", nullptr};
RunParserSyncTest(context_data, name_data, kSuccess);
}
TEST(StaticClassFieldsNoErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
// Basic syntax
"static a = 0;",
"static a = 0; b",
"static a = 0; b(){}",
"static a = 0; *b(){}",
"static a = 0; ['b'](){}",
"static a;",
"static a; b;",
"static a; b(){}",
"static a; *b(){}",
"static a; ['b'](){}",
"static ['a'] = 0;",
"static ['a'] = 0; b",
"static ['a'] = 0; b(){}",
"static ['a'] = 0; *b(){}",
"static ['a'] = 0; ['b'](){}",
"static ['a'];",
"static ['a']; b;",
"static ['a']; b(){}",
"static ['a']; *b(){}",
"static ['a']; ['b'](){}",
"static 0 = 0;",
"static 0;",
"static 'a' = 0;",
"static 'a';",
"static c = [c] = c",
// ASI
"static a = 0\n",
"static a = 0\n b",
"static a = 0\n b(){}",
"static a\n",
"static a\n b\n",
"static a\n b(){}",
"static a\n *b(){}",
"static a\n ['b'](){}",
"static ['a'] = 0\n",
"static ['a'] = 0\n b",
"static ['a'] = 0\n b(){}",
"static ['a']\n",
"static ['a']\n b\n",
"static ['a']\n b(){}",
"static ['a']\n *b(){}",
"static ['a']\n ['b'](){}",
"static a = function t() { arguments; }",
"static a = () => function t() { arguments; }",
// ASI edge cases
"static a\n get",
"static get\n *a(){}",
"static a\n static",
// Misc edge cases
"static yield",
"static yield = 0",
"static yield\n a",
"static async;",
"static async = 0;",
"static async",
"static async = 0",
"static async\n a(){}", // a field named async, and a method named a.
"static async\n a",
"static await;",
"static await = 0;",
"static await\n a",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(ClassFieldsNoErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
// Basic syntax
"a = 0;",
"a = 0; b",
"a = 0; b(){}",
"a = 0; *b(){}",
"a = 0; ['b'](){}",
"a;",
"a; b;",
"a; b(){}",
"a; *b(){}",
"a; ['b'](){}",
"['a'] = 0;",
"['a'] = 0; b",
"['a'] = 0; b(){}",
"['a'] = 0; *b(){}",
"['a'] = 0; ['b'](){}",
"['a'];",
"['a']; b;",
"['a']; b(){}",
"['a']; *b(){}",
"['a']; ['b'](){}",
"0 = 0;",
"0;",
"'a' = 0;",
"'a';",
"c = [c] = c",
// ASI
"a = 0\n",
"a = 0\n b",
"a = 0\n b(){}",
"a\n",
"a\n b\n",
"a\n b(){}",
"a\n *b(){}",
"a\n ['b'](){}",
"['a'] = 0\n",
"['a'] = 0\n b",
"['a'] = 0\n b(){}",
"['a']\n",
"['a']\n b\n",
"['a']\n b(){}",
"['a']\n *b(){}",
"['a']\n ['b'](){}",
// ASI edge cases
"a\n get",
"get\n *a(){}",
"a\n static",
"a = function t() { arguments; }",
"a = () => function() { arguments; }",
// Misc edge cases
"yield",
"yield = 0",
"yield\n a",
"async;",
"async = 0;",
"async",
"async = 0",
"async\n a(){}", // a field named async, and a method named a.
"async\n a",
"await;",
"await = 0;",
"await\n a",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(PrivateMethodsNoErrors) {
// clang-format off
// Tests proposed class methods syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
// Basic syntax
"#a() { }",
"get #a() { }",
"set #a(foo) { }",
"*#a() { }",
"async #a() { }",
"async *#a() { }",
"#a() { } #b() {}",
"get #a() { } set #a(foo) {}",
"get #a() { } get #b() {} set #a(foo) {}",
"get #a() { } get #b() {} set #a(foo) {} set #b(foo) {}",
"set #a(foo) { } set #b(foo) {}",
"get #a() { } get #b() {}",
"#a() { } static a() {}",
"#a() { } a() {}",
"#a() { } a() {} static a() {}",
"get #a() { } get a() {} static get a() {}",
"set #a(foo) { } set a(foo) {} static set a(foo) {}",
"#a() { } get #b() {}",
"#a() { } async #b() {}",
"#a() { } async *#b() {}",
// With arguments
"#a(...args) { }",
"#a(a = 1) { }",
"get #a() { }",
"set #a(a = (...args) => {}) { }",
// Misc edge cases
"#get() {}",
"#set() {}",
"#yield() {}",
"#await() {}",
"#async() {}",
"#static() {}",
"#arguments() {}",
"get #yield() {}",
"get #await() {}",
"get #async() {}",
"get #get() {}",
"get #static() {}",
"get #arguments() {}",
"set #yield(test) {}",
"set #async(test) {}",
"set #await(test) {}",
"set #set(test) {}",
"set #static(test) {}",
"set #arguments(test) {}",
"async #yield() {}",
"async #async() {}",
"async #await() {}",
"async #get() {}",
"async #set() {}",
"async #static() {}",
"async #arguments() {}",
"*#async() {}",
"*#await() {}",
"*#yield() {}",
"*#get() {}",
"*#set() {}",
"*#static() {}",
"*#arguments() {}",
"async *#yield() {}",
"async *#async() {}",
"async *#await() {}",
"async *#get() {}",
"async *#set() {}",
"async *#static() {}",
"async *#arguments() {}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(PrivateMethodsAndFieldsNoErrors) {
// clang-format off
// Tests proposed class methods syntax in combination with fields
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
// Basic syntax
"#b;#a() { }",
"#b;get #a() { }",
"#b;set #a(foo) { }",
"#b;*#a() { }",
"#b;async #a() { }",
"#b;async *#a() { }",
"#b = 1;#a() { }",
"#b = 1;get #a() { }",
"#b = 1;set #a(foo) { }",
"#b = 1;*#a() { }",
"#b = 1;async #a() { }",
"#b = 1;async *#a() { }",
// With public fields
"a;#a() { }",
"a;get #a() { }",
"a;set #a(foo) { }",
"a;*#a() { }",
"a;async #a() { }",
"a;async *#a() { }",
"a = 1;#a() { }",
"a = 1;get #a() { }",
"a = 1;set #a(foo) { }",
"a = 1;*#a() { }",
"a = 1;async #a() { }",
"a = 1;async *#a() { }",
// ASI
"#a = 0\n #b(){}",
"#a\n *#b(){}",
"#a = 0\n get #b(){}",
"#a\n *#b(){}",
"b = 0\n #b(){}",
"b\n *#b(){}",
"b = 0\n get #b(){}",
"b\n *#b(){}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(PrivateMethodsErrors) {
// clang-format off
// Tests proposed class methods syntax in combination with fields
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"#a() : 0",
"#a() =",
"#a() => {}",
"#a => {}",
"*#a() = 0",
"*#a() => 0",
"*#a() => {}",
"get #a()[]",
"yield #a()[]",
"yield #a => {}",
"async #a() = 0",
"async #a => {}",
"#a(arguments) {}",
"set #a(arguments) {}",
"#['a']() { }",
"get #['a']() { }",
"set #['a'](foo) { }",
"*#['a']() { }",
"async #['a']() { }",
"async *#['a]() { }",
"get #a() {} get #a() {}",
"get #a() {} get #['a']() {}",
"set #a(val) {} set #a(val) {}",
"set #a(val) {} set #['a'](val) {}",
"#a\n#",
"#a() c",
"#a() #",
"#a(arg) c",
"#a(arg) #",
"#a(arg) #c",
"#a#",
"#a#b",
"#a#b(){}",
"#[test](){}",
"async *#constructor() {}",
"*#constructor() {}",
"async #constructor() {}",
"set #constructor(test) {}",
"#constructor() {}",
"get #constructor() {}",
"static async *#constructor() {}",
"static *#constructor() {}",
"static async #constructor() {}",
"static set #constructor(test) {}",
"static #constructor() {}",
"static get #constructor() {}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kError);
}
// Test that private members parse in class bodies nested in object literals
TEST(PrivateMembersNestedInObjectLiteralsNoErrors) {
// clang-format off
const char* context_data[][2] = {{"({", "})"},
{"'use strict'; ({", "});"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"a: class { #a = 1 }",
"a: class { #a = () => {} }",
"a: class { #a }",
"a: class { #a() { } }",
"a: class { get #a() { } }",
"a: class { set #a(foo) { } }",
"a: class { *#a() { } }",
"a: class { async #a() { } }",
"a: class { async *#a() { } }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
// Test that private members parse in class bodies nested in classes
TEST(PrivateMembersInNestedClassNoErrors) {
// clang-format off
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"a = class { #a = 1 }",
"a = class { #a = () => {} }",
"a = class { #a }",
"a = class { #a() { } }",
"a = class { get #a() { } }",
"a = class { set #a(foo) { } }",
"a = class { *#a() { } }",
"a = class { async #a() { } }",
"a = class { async *#a() { } }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
// Test that private members do not parse outside class bodies
TEST(PrivateMembersInNonClassErrors) {
// clang-format off
const char* context_data[][2] = {{"", ""},
{"({", "})"},
{"'use strict'; ({", "});"},
{"function() {", "}"},
{"() => {", "}"},
{"class C { test() {", "} }"},
{"const {", "} = {}"},
{"({", "} = {})"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"#a = 1",
"#a = () => {}",
"#a",
"#a() { }",
"get #a() { }",
"set #a(foo) { }",
"*#a() { }",
"async #a() { }",
"async *#a() { }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kError);
}
// Test that nested private members parse
TEST(PrivateMembersNestedNoErrors) {
// clang-format off
const char* context_data[][2] = {{"(class { get #a() { ", "} });"},
{
"(class { set #a(val) {} get #a() { ",
"} });"
},
{"(class { set #a(val) {", "} });"},
{"(class { #a() { ", "} });"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"class C { #a() {} }",
"class C { get #a() {} }",
"class C { get #a() {} set #a(val) {} }",
"class C { set #a(val) {} }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
// Test that acessing undeclared private members result in early errors
TEST(PrivateMembersEarlyErrors) {
// clang-format off
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"set #b(val) { this.#a = val; }",
"get #b() { return this.#a; }",
"foo() { return this.#a; }",
"foo() { this.#a = 1; }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kError);
}
// Test that acessing wrong kind private members do not error early.
// Instead these should be runtime errors.
TEST(PrivateMembersWrongAccessNoEarlyErrors) {
// clang-format off
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
// Private setter only
"set #b(val) {} fn() { return this.#b; }",
"set #b(val) {} fn() { this.#b++; }",
// Nested private setter only
R"(get #b() {}
fn() {
return new class { set #b(val) {} fn() { this.#b++; } };
})",
R"(get #b() {}
fn() {
return new class { set #b(val) {} fn() { return this.#b; } };
})",
// Private getter only
"get #b() { } fn() { this.#b = 1; }",
"get #b() { } fn() { this.#b++; }",
"get #b() { } fn(obj) { ({ y: this.#b } = obj); }",
// Nested private getter only
R"(set #b(val) {}
fn() {
return new class { get #b() {} fn() { this.#b++; } };
})",
R"(set #b(val) {}
fn() {
return new class { get #b() {} fn() { this.#b = 1; } };
})",
R"(set #b(val) {}
fn() {
return new class { get #b() {} fn() { ({ y: this.#b } = obj); } };
})",
// Writing to private methods
"#b() { } fn() { this.#b = 1; }",
"#b() { } fn() { this.#b++; }",
"#b() {} fn(obj) { ({ y: this.#b } = obj); }",
// Writing to nested private methods
R"(#b() {}
fn() {
return new class { get #b() {} fn() { this.#b++; } };
})",
R"(#b() {}
fn() {
return new class { get #b() {} fn() { this.#b = 1; } };
})",
R"(#b() {}
fn() {
return new class { get #b() {} fn() { ({ y: this.#b } = obj); } };
})",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(PrivateStaticClassMethodsAndAccessorsNoErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"static #a() { }",
"static get #a() { }",
"static set #a(val) { }",
"static get #a() { } static set #a(val) { }",
"static *#a() { }",
"static async #a() { }",
"static async *#a() { }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(PrivateStaticClassMethodsAndAccessorsDuplicateErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"static get #a() {} static get #a() {}",
"static get #a() {} static #a() {}",
"static get #a() {} get #a() {}",
"static get #a() {} set #a(val) {}",
"static get #a() {} #a() {}",
"static set #a(val) {} static set #a(val) {}",
"static set #a(val) {} static #a() {}",
"static set #a(val) {} get #a() {}",
"static set #a(val) {} set #a(val) {}",
"static set #a(val) {} #a() {}",
"static #a() {} static #a() {}",
"static #a() {} #a(val) {}",
"static #a() {} set #a(val) {}",
"static #a() {} get #a() {}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(PrivateClassFieldsNoErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
// Basic syntax
"#a = 0;",
"#a = 0; #b",
"#a = 0; b",
"#a = 0; b(){}",
"#a = 0; *b(){}",
"#a = 0; ['b'](){}",
"#a;",
"#a; #b;",
"#a; b;",
"#a; b(){}",
"#a; *b(){}",
"#a; ['b'](){}",
// ASI
"#a = 0\n",
"#a = 0\n #b",
"#a = 0\n b",
"#a = 0\n b(){}",
"#a\n",
"#a\n #b\n",
"#a\n b\n",
"#a\n b(){}",
"#a\n *b(){}",
"#a\n ['b'](){}",
// ASI edge cases
"#a\n get",
"#get\n *a(){}",
"#a\n static",
"#a = function t() { arguments; }",
"#a = () => function() { arguments; }",
// Misc edge cases
"#yield",
"#yield = 0",
"#yield\n a",
"#async;",
"#async = 0;",
"#async",
"#async = 0",
"#async\n a(){}", // a field named async, and a method named a.
"#async\n a",
"#await;",
"#await = 0;",
"#await\n a",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(StaticClassFieldsErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"static a : 0",
"static a =",
"static constructor",
"static prototype",
"static *a = 0",
"static *a",
"static get a",
"static get\n a",
"static yield a",
"static async a = 0",
"static async a",
"static a = arguments",
"static a = () => arguments",
"static a = () => { arguments }",
"static a = arguments[0]",
"static a = delete arguments[0]",
"static a = f(arguments)",
"static a = () => () => arguments",
// ASI requires a linebreak
"static a b",
"static a = 0 b",
"static c = [1] = [c]",
// ASI requires that the next token is not part of any legal production
"static a = 0\n *b(){}",
"static a = 0\n ['b'](){}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(ClassFieldsErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"a : 0",
"a =",
"constructor",
"*a = 0",
"*a",
"get a",
"yield a",
"async a = 0",
"async a",
"a = arguments",
"a = () => arguments",
"a = () => { arguments }",
"a = arguments[0]",
"a = delete arguments[0]",
"a = f(arguments)",
"a = () => () => arguments",
// ASI requires a linebreak
"a b",
"a = 0 b",
"c = [1] = [c]",
// ASI requires that the next token is not part of any legal production
"a = 0\n *b(){}",
"a = 0\n ['b'](){}",
"get\n a",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(PrivateClassFieldsErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
"#a : 0",
"#a =",
"#*a = 0",
"#*a",
"#get a",
"#yield a",
"#async a = 0",
"#async a",
"#a; #a",
"#a = 1; #a",
"#a; #a = 1;",
"#constructor",
"#constructor = function() {}",
"# a = 0",
"#get a() { }",
"#set a() { }",
"#*a() { }",
"async #*a() { }",
"#0 = 0;",
"#0;",
"#'a' = 0;",
"#'a';",
"#['a']",
"#['a'] = 1",
"#[a]",
"#[a] = 1",
"#a = arguments",
"#a = () => arguments",
"#a = () => { arguments }",
"#a = arguments[0]",
"#a = delete arguments[0]",
"#a = f(arguments)",
"#a = () => () => arguments",
"foo() { delete this.#a }",
"foo() { delete this.x.#a }",
"foo() { delete this.x().#a }",
"foo() { delete this?.#a }",
"foo() { delete this.x?.#a }",
"foo() { delete this?.x.#a }",
"foo() { delete this.x()?.#a }",
"foo() { delete this?.x().#a }",
"foo() { delete f.#a }",
"foo() { delete f.x.#a }",
"foo() { delete f.x().#a }",
"foo() { delete f?.#a }",
"foo() { delete f.x?.#a }",
"foo() { delete f?.x.#a }",
"foo() { delete f.x()?.#a }",
"foo() { delete f?.x().#a }",
// ASI requires a linebreak
"#a b",
"#a = 0 b",
// ASI requires that the next token is not part of any legal production
"#a = 0\n *b(){}",
"#a = 0\n ['b'](){}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(PrivateStaticClassFieldsNoErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
// Basic syntax
"static #a = 0;",
"static #a = 0; b",
"static #a = 0; #b",
"static #a = 0; b(){}",
"static #a = 0; *b(){}",
"static #a = 0; ['b'](){}",
"static #a;",
"static #a; b;",
"static #a; b(){}",
"static #a; *b(){}",
"static #a; ['b'](){}",
"#prototype",
"#prototype = function() {}",
// ASI
"static #a = 0\n",
"static #a = 0\n b",
"static #a = 0\n #b",
"static #a = 0\n b(){}",
"static #a\n",
"static #a\n b\n",
"static #a\n #b\n",
"static #a\n b(){}",
"static #a\n *b(){}",
"static #a\n ['b'](){}",
"static #a = function t() { arguments; }",
"static #a = () => function t() { arguments; }",
// ASI edge cases
"static #a\n get",
"static #get\n *a(){}",
"static #a\n static",
// Misc edge cases
"static #yield",
"static #yield = 0",
"static #yield\n a",
"static #async;",
"static #async = 0;",
"static #async",
"static #async = 0",
"static #async\n a(){}", // a field named async, and a method named a.
"static #async\n a",
"static #await;",
"static #await = 0;",
"static #await\n a",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kSuccess, nullptr);
}
TEST(PrivateStaticClassFieldsErrors) {
// clang-format off
// Tests proposed class fields syntax.
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* class_body_data[] = {
// Basic syntax
"static #['a'] = 0;",
"static #['a'] = 0; b",
"static #['a'] = 0; #b",
"static #['a'] = 0; b(){}",
"static #['a'] = 0; *b(){}",
"static #['a'] = 0; ['b'](){}",
"static #['a'];",
"static #['a']; b;",
"static #['a']; #b;",
"static #['a']; b(){}",
"static #['a']; *b(){}",
"static #['a']; ['b'](){}",
"static #0 = 0;",
"static #0;",
"static #'a' = 0;",
"static #'a';",
"static # a = 0",
"static #get a() { }",
"static #set a() { }",
"static #*a() { }",
"static async #*a() { }",
"#a = arguments",
"#a = () => arguments",
"#a = () => { arguments }",
"#a = arguments[0]",
"#a = delete arguments[0]",
"#a = f(arguments)",
"#a = () => () => arguments",
"#a; static #a",
"static #a; #a",
// ASI
"static #['a'] = 0\n",
"static #['a'] = 0\n b",
"static #['a'] = 0\n #b",
"static #['a'] = 0\n b(){}",
"static #['a']\n",
"static #['a']\n b\n",
"static #['a']\n #b\n",
"static #['a']\n b(){}",
"static #['a']\n *b(){}",
"static #['a']\n ['b'](){}",
// ASI requires a linebreak
"static #a b",
"static #a = 0 b",
// ASI requires that the next token is not part of any legal production
"static #a = 0\n *b(){}",
"static #a = 0\n ['b'](){}",
"static #a : 0",
"static #a =",
"static #*a = 0",
"static #*a",
"static #get a",
"static #yield a",
"static #async a = 0",
"static #async a",
"static # a = 0",
"#constructor",
"#constructor = function() {}",
"foo() { delete this.#a }",
"foo() { delete this.x.#a }",
"foo() { delete this.x().#a }",
"foo() { delete f.#a }",
"foo() { delete f.x.#a }",
"foo() { delete f.x().#a }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(PrivateNameResolutionErrors) {
// clang-format off
const char* context_data[][2] = {
{"class X { bar() { ", " } }"},
{"\"use strict\";", ""},
{nullptr, nullptr}
};
const char* statement_data[] = {
"this.#a",
"this.#a()",
"this.#b.#a",
"this.#b.#a()",
"foo.#a",
"foo.#a()",
"foo.#b.#a",
"foo.#b.#a()",
"foo().#a",
"foo().b.#a",
"foo().b().#a",
"foo().b().#a()",
"foo().b().#a.bar",
"foo().b().#a.bar()",
"foo(this.#a)",
"foo(bar().#a)",
"new foo.#a",
"new foo.#b.#a",
"new foo.#b.#a()",
"foo.#if;",
"foo.#yield;",
"foo.#super;",
"foo.#interface;",
"foo.#eval;",
"foo.#arguments;",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(PrivateNameErrors) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"function t() { ", " }"},
{"var t => { ", " }"},
{"var t = { [ ", " ] }"},
{"\"use strict\";", ""},
{nullptr, nullptr}
};
const char* statement_data[] = {
"#foo",
"#foo = 1",
"# a;",
"#\n a;",
"a, # b",
"a, #, b;",
"foo.#[a];",
"foo.#['a'];",
"foo()#a",
"foo()#[a]",
"foo()#['a']",
"super.#a;",
"super.#a = 1;",
"super.#['a']",
"super.#[a]",
"new.#a",
"new.#[a]",
"foo.#{;",
"foo.#};",
"foo.#=;",
"foo.#888;",
"foo.#-;",
"foo.#--;",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(ClassExpressionErrors) {
const char* context_data[][2] = {
{"(", ");"}, {"var C = ", ";"}, {"bar, ", ";"}, {nullptr, nullptr}};
const char* class_data[] = {
"class",
"class name",
"class name extends",
"class extends",
"class {",
"class { m: 1 }",
"class { m(); n() }",
"class { get m }",
"class { get m() }",
"class { get m() { }",
"class { set m() {} }", // Missing required parameter.
"class { m() {}, n() {} }", // No commas allowed.
nullptr};
RunParserSyncTest(context_data, class_data, kError);
}
TEST(ClassDeclarationErrors) {
const char* context_data[][2] = {
{"", ""}, {"{", "}"}, {"if (true) {", "}"}, {nullptr, nullptr}};
const char* class_data[] = {
"class",
"class name",
"class name extends",
"class extends",
"class name {",
"class name { m: 1 }",
"class name { m(); n() }",
"class name { get x }",
"class name { get x() }",
"class name { set x() {) }", // missing required param
"class {}", // Name is required for declaration
"class extends base {}",
"class name { *",
"class name { * }",
"class name { *; }",
"class name { *get x() {} }",
"class name { *set x(_) {} }",
"class name { *static m() {} }",
nullptr};
RunParserSyncTest(context_data, class_data, kError);
}
TEST(ClassAsyncErrors) {
// clang-format off
const char* context_data[][2] = {{"(class {", "});"},
{"(class extends Base {", "});"},
{"class C {", "}"},
{"class C extends Base {", "}"},
{nullptr, nullptr}};
const char* async_data[] = {
"*async x(){}",
"async *(){}",
"async get x(){}",
"async set x(y){}",
"async x : 0",
"async : 0",
"async static x(){}",
"static *async x(){}",
"static async *(){}",
"static async get x(){}",
"static async set x(y){}",
"static async x : 0",
"static async : 0",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, async_data, kError);
}
TEST(ClassNameErrors) {
const char* context_data[][2] = {{"class ", "{}"},
{"(class ", "{});"},
{"'use strict'; class ", "{}"},
{"'use strict'; (class ", "{});"},
{nullptr, nullptr}};
const char* class_name[] = {"arguments", "eval", "implements", "interface",
"let", "package", "private", "protected",
"public", "static", "var", "yield",
nullptr};
RunParserSyncTest(context_data, class_name, kError);
}
TEST(ClassGetterParamNameErrors) {
const char* context_data[][2] = {
{"class C { get name(", ") {} }"},
{"(class { get name(", ") {} });"},
{"'use strict'; class C { get name(", ") {} }"},
{"'use strict'; (class { get name(", ") {} })"},
{nullptr, nullptr}};
const char* class_name[] = {"arguments", "eval", "implements", "interface",
"let", "package", "private", "protected",
"public", "static", "var", "yield",
nullptr};
RunParserSyncTest(context_data, class_name, kError);
}
TEST(ClassStaticPrototypeErrors) {
const char* context_data[][2] = {
{"class C {", "}"}, {"(class {", "});"}, {nullptr, nullptr}};
const char* class_body_data[] = {"static prototype() {}",
"static get prototype() {}",
"static set prototype(_) {}",
"static *prototype() {}",
"static 'prototype'() {}",
"static *'prototype'() {}",
"static prot\\u006ftype() {}",
"static 'prot\\u006ftype'() {}",
"static get 'prot\\u006ftype'() {}",
"static set 'prot\\u006ftype'(_) {}",
"static *'prot\\u006ftype'() {}",
nullptr};
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(ClassSpecialConstructorErrors) {
const char* context_data[][2] = {
{"class C {", "}"}, {"(class {", "});"}, {nullptr, nullptr}};
const char* class_body_data[] = {"get constructor() {}",
"get constructor(_) {}",
"*constructor() {}",
"get 'constructor'() {}",
"*'constructor'() {}",
"get c\\u006fnstructor() {}",
"*c\\u006fnstructor() {}",
"get 'c\\u006fnstructor'() {}",
"get 'c\\u006fnstructor'(_) {}",
"*'c\\u006fnstructor'() {}",
nullptr};
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(ClassConstructorNoErrors) {
const char* context_data[][2] = {
{"class C {", "}"}, {"(class {", "});"}, {nullptr, nullptr}};
const char* class_body_data[] = {"constructor() {}",
"static constructor() {}",
"static get constructor() {}",
"static set constructor(_) {}",
"static *constructor() {}",
nullptr};
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(ClassMultipleConstructorErrors) {
const char* context_data[][2] = {
{"class C {", "}"}, {"(class {", "});"}, {nullptr, nullptr}};
const char* class_body_data[] = {"constructor() {}; constructor() {}",
nullptr};
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(ClassMultiplePropertyNamesNoErrors) {
const char* context_data[][2] = {
{"class C {", "}"}, {"(class {", "});"}, {nullptr, nullptr}};
const char* class_body_data[] = {
"constructor() {}; static constructor() {}",
"m() {}; static m() {}",
"m() {}; m() {}",
"static m() {}; static m() {}",
"get m() {}; set m(_) {}; get m() {}; set m(_) {};",
nullptr};
RunParserSyncTest(context_data, class_body_data, kSuccess);
}
TEST(ClassesAreStrictErrors) {
const char* context_data[][2] = {{"", ""}, {"(", ");"}, {nullptr, nullptr}};
const char* class_body_data[] = {
"class C { method() { with ({}) {} } }",
"class C extends function() { with ({}) {} } {}",
"class C { *method() { with ({}) {} } }", nullptr};
RunParserSyncTest(context_data, class_body_data, kError);
}
TEST(ObjectLiteralPropertyShorthandKeywordsError) {
const char* context_data[][2] = {
{"({", "});"}, {"'use strict'; ({", "});"}, {nullptr, nullptr}};
const char* name_data[] = {
"break", "case", "catch", "class", "const", "continue",
"debugger", "default", "delete", "do", "else", "enum",
"export", "extends", "false", "finally", "for", "function",
"if", "import", "in", "instanceof", "new", "null",
"return", "super", "switch", "this", "throw", "true",
"try", "typeof", "var", "void", "while", "with",
nullptr};
RunParserSyncTest(context_data, name_data, kError);
}
TEST(ObjectLiteralPropertyShorthandStrictKeywords) {
const char* context_data[][2] = {{"({", "});"}, {nullptr, nullptr}};
const char* name_data[] = {"implements", "interface", "let", "package",
"private", "protected", "public", "static",
"yield", nullptr};
RunParserSyncTest(context_data, name_data, kSuccess);
const char* context_strict_data[][2] = {{"'use strict'; ({", "});"},
{nullptr, nullptr}};
RunParserSyncTest(context_strict_data, name_data, kError);
}
TEST(ObjectLiteralPropertyShorthandError) {
const char* context_data[][2] = {
{"({", "});"}, {"'use strict'; ({", "});"}, {nullptr, nullptr}};
const char* name_data[] = {"1", "1.2", "0", "0.1", "1.0",
"1e1", "0x1", "\"s\"", "'s'", nullptr};
RunParserSyncTest(context_data, name_data, kError);
}
TEST(ObjectLiteralPropertyShorthandYieldInGeneratorError) {
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* name_data[] = {"function* g() { ({yield}); }", nullptr};
RunParserSyncTest(context_data, name_data, kError);
}
TEST(ConstParsingInForIn) {
const char* context_data[][2] = {{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {
"for(const x = 1; ; ) {}", "for(const x = 1, y = 2;;){}",
"for(const x in [1,2,3]) {}", "for(const x of [1,2,3]) {}", nullptr};
RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0);
}
TEST(StatementParsingInForIn) {
const char* context_data[][2] = {{"", ""},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"for(x in {}, {}) {}", "for(var x in {}, {}) {}",
"for(let x in {}, {}) {}", "for(const x in {}, {}) {}",
nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ConstParsingInForInError) {
const char* context_data[][2] = {{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {
"for(const x,y = 1; ; ) {}", "for(const x = 4 in [1,2,3]) {}",
"for(const x = 4, y in [1,2,3]) {}", "for(const x = 4 of [1,2,3]) {}",
"for(const x = 4, y of [1,2,3]) {}", "for(const x = 1, y = 2 in []) {}",
"for(const x,y in []) {}", "for(const x = 1, y = 2 of []) {}",
"for(const x,y of []) {}", nullptr};
RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0);
}
TEST(InitializedDeclarationsInForInOf) {
// https://tc39.github.io/ecma262/#sec-initializers-in-forin-statement-heads
// Initialized declarations only allowed for
// - sloppy mode (not strict mode)
// - for-in (not for-of)
// - var (not let / const)
// clang-format off
const char* strict_context[][2] = {{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{"function* foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* sloppy_context[][2] = {{"", ""},
{"function foo(){ ", "}"},
{"function* foo(){ ", "}"},
{"function foo(){ var yield = 0; ", "}"},
{nullptr, nullptr}};
const char* let_const_var_for_of[] = {
"for (let i = 1 of {}) {}",
"for (let i = void 0 of [1, 2, 3]) {}",
"for (const i = 1 of {}) {}",
"for (const i = void 0 of [1, 2, 3]) {}",
"for (var i = 1 of {}) {}",
"for (var i = void 0 of [1, 2, 3]) {}",
nullptr};
const char* let_const_for_in[] = {
"for (let i = 1 in {}) {}",
"for (let i = void 0 in [1, 2, 3]) {}",
"for (const i = 1 in {}) {}",
"for (const i = void 0 in [1, 2, 3]) {}",
nullptr};
const char* var_for_in[] = {
"for (var i = 1 in {}) {}",
"for (var i = void 0 in [1, 2, 3]) {}",
"for (var i = yield in [1, 2, 3]) {}",
nullptr};
// clang-format on
// The only allowed case is sloppy + var + for-in.
RunParserSyncTest(sloppy_context, var_for_in, kSuccess);
// Everything else is disallowed.
RunParserSyncTest(sloppy_context, let_const_var_for_of, kError);
RunParserSyncTest(sloppy_context, let_const_for_in, kError);
RunParserSyncTest(strict_context, let_const_var_for_of, kError);
RunParserSyncTest(strict_context, let_const_for_in, kError);
RunParserSyncTest(strict_context, var_for_in, kError);
}
TEST(ForInMultipleDeclarationsError) {
const char* context_data[][2] = {{"", ""},
{"function foo(){", "}"},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"for (var i, j in {}) {}",
"for (var i, j in [1, 2, 3]) {}",
"for (var i, j = 1 in {}) {}",
"for (var i, j = void 0 in [1, 2, 3]) {}",
"for (let i, j in {}) {}",
"for (let i, j in [1, 2, 3]) {}",
"for (let i, j = 1 in {}) {}",
"for (let i, j = void 0 in [1, 2, 3]) {}",
"for (const i, j in {}) {}",
"for (const i, j in [1, 2, 3]) {}",
"for (const i, j = 1 in {}) {}",
"for (const i, j = void 0 in [1, 2, 3]) {}",
nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(ForOfMultipleDeclarationsError) {
const char* context_data[][2] = {{"", ""},
{"function foo(){", "}"},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"for (var i, j of {}) {}",
"for (var i, j of [1, 2, 3]) {}",
"for (var i, j = 1 of {}) {}",
"for (var i, j = void 0 of [1, 2, 3]) {}",
"for (let i, j of {}) {}",
"for (let i, j of [1, 2, 3]) {}",
"for (let i, j = 1 of {}) {}",
"for (let i, j = void 0 of [1, 2, 3]) {}",
"for (const i, j of {}) {}",
"for (const i, j of [1, 2, 3]) {}",
"for (const i, j = 1 of {}) {}",
"for (const i, j = void 0 of [1, 2, 3]) {}",
nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(ForInOfLetExpression) {
const char* sloppy_context_data[][2] = {
{"", ""}, {"function foo(){", "}"}, {nullptr, nullptr}};
const char* strict_context_data[][2] = {
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* async_context_data[][2] = {
{"async function foo(){", "}"},
{"async function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* for_let_in[] = {"for (let.x in {}) {}", nullptr};
const char* for_let_of[] = {"for (let.x of []) {}", nullptr};
const char* for_await_let_of[] = {"for await (let.x of []) {}", nullptr};
// The only place `let.x` is legal as a left-hand side expression
// is in sloppy mode in a for-in loop.
RunParserSyncTest(sloppy_context_data, for_let_in, kSuccess);
RunParserSyncTest(strict_context_data, for_let_in, kError);
RunParserSyncTest(sloppy_context_data, for_let_of, kError);
RunParserSyncTest(strict_context_data, for_let_of, kError);
RunParserSyncTest(async_context_data, for_await_let_of, kError);
}
TEST(ForInNoDeclarationsError) {
const char* context_data[][2] = {{"", ""},
{"function foo(){", "}"},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"for (var in {}) {}", "for (const in {}) {}", nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(ForOfNoDeclarationsError) {
const char* context_data[][2] = {{"", ""},
{"function foo(){", "}"},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"for (var of [1, 2, 3]) {}",
"for (const of [1, 2, 3]) {}", nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(ForOfInOperator) {
const char* context_data[][2] = {{"", ""},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"for(x of 'foo' in {}) {}",
"for(var x of 'foo' in {}) {}",
"for(let x of 'foo' in {}) {}",
"for(const x of 'foo' in {}) {}", nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ForOfYieldIdentifier) {
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* data[] = {"for(x of yield) {}", "for(var x of yield) {}",
"for(let x of yield) {}", "for(const x of yield) {}",
nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ForOfYieldExpression) {
const char* context_data[][2] = {{"", ""},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"function* g() { for(x of yield) {} }",
"function* g() { for(var x of yield) {} }",
"function* g() { for(let x of yield) {} }",
"function* g() { for(const x of yield) {} }", nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ForOfExpressionError) {
const char* context_data[][2] = {{"", ""},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {
"for(x of [], []) {}", "for(var x of [], []) {}",
"for(let x of [], []) {}", "for(const x of [], []) {}",
// AssignmentExpression should be validated statically:
"for(x of { y = 23 }) {}", "for(var x of { y = 23 }) {}",
"for(let x of { y = 23 }) {}", "for(const x of { y = 23 }) {}", nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(ForOfAsync) {
const char* context_data[][2] = {{"", ""},
{"'use strict';", ""},
{"function foo(){ 'use strict';", "}"},
{nullptr, nullptr}};
const char* data[] = {"for(\\u0061sync of []) {}", nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(InvalidUnicodeEscapes) {
const char* context_data[][2] = {
{"", ""}, {"'use strict';", ""}, {nullptr, nullptr}};
const char* data[] = {
"var foob\\u123r = 0;", "var \\u123roo = 0;", "\"foob\\u123rr\"",
// No escapes allowed in regexp flags
"/regex/\\u0069g", "/regex/\\u006g",
// Braces gone wrong
"var foob\\u{c481r = 0;", "var foob\\uc481}r = 0;", "var \\u{0052oo = 0;",
"var \\u0052}oo = 0;", "\"foob\\u{c481r\"", "var foob\\u{}ar = 0;",
// Too high value for the Unicode code point escape
"\"\\u{110000}\"",
// Not a Unicode code point escape
"var foob\\v1234r = 0;", "var foob\\U1234r = 0;",
"var foob\\v{1234}r = 0;", "var foob\\U{1234}r = 0;", nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(UnicodeEscapes) {
const char* context_data[][2] = {
{"", ""}, {"'use strict';", ""}, {nullptr, nullptr}};
const char* data[] = {
// Identifier starting with escape
"var \\u0052oo = 0;", "var \\u{0052}oo = 0;", "var \\u{52}oo = 0;",
"var \\u{00000000052}oo = 0;",
// Identifier with an escape but not starting with an escape
"var foob\\uc481r = 0;", "var foob\\u{c481}r = 0;",
// String with an escape
"\"foob\\uc481r\"", "\"foob\\{uc481}r\"",
// This character is a valid Unicode character, representable as a
// surrogate pair, not representable as 4 hex digits.
"\"foo\\u{10e6d}\"",
// Max value for the Unicode code point escape
"\"\\u{10ffff}\"", nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(OctalEscapes) {
const char* sloppy_context_data[][2] = {{"", ""}, // as a directive
{"0;", ""}, // as a string literal
{nullptr, nullptr}};
const char* strict_context_data[][2] = {
{"'use strict';", ""}, // as a directive before 'use strict'
{"", ";'use strict';"}, // as a directive after 'use strict'
{"'use strict'; 0;", ""}, // as a string literal
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"'\\1'",
"'\\01'",
"'\\001'",
"'\\08'",
"'\\09'",
nullptr};
// clang-format on
// Permitted in sloppy mode
RunParserSyncTest(sloppy_context_data, data, kSuccess);
// Error in strict mode
RunParserSyncTest(strict_context_data, data, kError);
}
TEST(ScanTemplateLiterals) {
const char* context_data[][2] = {{"'use strict';", ""},
{"function foo(){ 'use strict';"
" var a, b, c; return ",
"}"},
{nullptr, nullptr}};
const char* data[] = {"``",
"`no-subst-template`",
"`template-head${a}`",
"`${a}`",
"`${a}template-tail`",
"`template-head${a}template-tail`",
"`${a}${b}${c}`",
"`a${a}b${b}c${c}`",
"`${a}a${b}b${c}c`",
"`foo\n\nbar\r\nbaz`",
"`foo\n\n${ bar }\r\nbaz`",
"`foo${a /* comment */}`",
"`foo${a // comment\n}`",
"`foo${a \n}`",
"`foo${a \r\n}`",
"`foo${a \r}`",
"`foo${/* comment */ a}`",
"`foo${// comment\na}`",
"`foo${\n a}`",
"`foo${\r\n a}`",
"`foo${\r a}`",
"`foo${'a' in a}`",
nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ScanTaggedTemplateLiterals) {
const char* context_data[][2] = {{"'use strict';", ""},
{"function foo(){ 'use strict';"
" function tag() {}"
" var a, b, c; return ",
"}"},
{nullptr, nullptr}};
const char* data[] = {"tag ``",
"tag `no-subst-template`",
"tag`template-head${a}`",
"tag `${a}`",
"tag `${a}template-tail`",
"tag `template-head${a}template-tail`",
"tag\n`${a}${b}${c}`",
"tag\r\n`a${a}b${b}c${c}`",
"tag `${a}a${b}b${c}c`",
"tag\t`foo\n\nbar\r\nbaz`",
"tag\r`foo\n\n${ bar }\r\nbaz`",
"tag`foo${a /* comment */}`",
"tag`foo${a // comment\n}`",
"tag`foo${a \n}`",
"tag`foo${a \r\n}`",
"tag`foo${a \r}`",
"tag`foo${/* comment */ a}`",
"tag`foo${// comment\na}`",
"tag`foo${\n a}`",
"tag`foo${\r\n a}`",
"tag`foo${\r a}`",
"tag`foo${'a' in a}`",
nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(TemplateMaterializedLiterals) {
const char* context_data[][2] = {{"'use strict';\n"
"function tag() {}\n"
"var a, b, c;\n"
"(",
")"},
{nullptr, nullptr}};
const char* data[] = {"tag``", "tag`a`", "tag`a${1}b`", "tag`a${1}b${2}c`",
"``", "`a`", "`a${1}b`", "`a${1}b${2}c`",
nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ScanUnterminatedTemplateLiterals) {
const char* context_data[][2] = {{"'use strict';", ""},
{"function foo(){ 'use strict';"
" var a, b, c; return ",
"}"},
{nullptr, nullptr}};
const char* data[] = {"`no-subst-template",
"`template-head${a}",
"`${a}template-tail",
"`template-head${a}template-tail",
"`${a}${b}${c}",
"`a${a}b${b}c${c}",
"`${a}a${b}b${c}c",
"`foo\n\nbar\r\nbaz",
"`foo\n\n${ bar }\r\nbaz",
"`foo${a /* comment } */`",
"`foo${a /* comment } `*/",
"`foo${a // comment}`",
"`foo${a \n`",
"`foo${a \r\n`",
"`foo${a \r`",
"`foo${/* comment */ a`",
"`foo${// commenta}`",
"`foo${\n a`",
"`foo${\r\n a`",
"`foo${\r a`",
"`foo${fn(}`",
"`foo${1 if}`",
nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(TemplateLiteralsIllegalTokens) {
const char* context_data[][2] = {{"'use strict';", ""},
{"function foo(){ 'use strict';"
" var a, b, c; return ",
"}"},
{nullptr, nullptr}};
const char* data[] = {
"`hello\\x`", "`hello\\x${1}`", "`hello${1}\\x`",
"`hello${1}\\x${2}`", "`hello\\x\n`", "`hello\\x\n${1}`",
"`hello${1}\\x\n`", "`hello${1}\\x\n${2}`", nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(ParseRestParameters) {
const char* context_data[][2] = {{"'use strict';(function(",
"){ return args;})(1, [], /regexp/, 'str',"
"function(){});"},
{"(function(",
"){ return args;})(1, [],"
"/regexp/, 'str', function(){});"},
{nullptr, nullptr}};
const char* data[] = {"...args",
"a, ...args",
"... args",
"a, ... args",
"...\targs",
"a, ...\targs",
"...\r\nargs",
"a, ...\r\nargs",
"...\rargs",
"a, ...\rargs",
"...\t\n\t\t\n args",
"a, ... \n \n args",
"...{ length, 0: a, 1: b}",
"...{}",
"...[a, b]",
"...[]",
"...[...[a, b, ...c]]",
nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ParseRestParametersErrors) {
const char* context_data[][2] = {{"'use strict';(function(",
"){ return args;}(1, [], /regexp/, 'str',"
"function(){});"},
{"(function(",
"){ return args;}(1, [],"
"/regexp/, 'str', function(){});"},
{nullptr, nullptr}};
const char* data[] = {"...args, b",
"a, ...args, b",
"...args, b",
"a, ...args, b",
"...args,\tb",
"a,...args\t,b",
"...args\r\n, b",
"a, ... args,\r\nb",
"...args\r,b",
"a, ... args,\rb",
"...args\t\n\t\t\n, b",
"a, ... args, \n \n b",
"a, a, ...args",
"a,\ta, ...args",
"a,\ra, ...args",
"a,\na, ...args",
nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(RestParameterInSetterMethodError) {
const char* context_data[][2] = {
{"'use strict';({ set prop(", ") {} }).prop = 1;"},
{"'use strict';(class { static set prop(", ") {} }).prop = 1;"},
{"'use strict';(new (class { set prop(", ") {} })).prop = 1;"},
{"({ set prop(", ") {} }).prop = 1;"},
{"(class { static set prop(", ") {} }).prop = 1;"},
{"(new (class { set prop(", ") {} })).prop = 1;"},
{nullptr, nullptr}};
const char* data[] = {"...a", "...arguments", "...eval", nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(RestParametersEvalArguments) {
// clang-format off
const char* strict_context_data[][2] =
{{"'use strict';(function(",
"){ return;})(1, [], /regexp/, 'str',function(){});"},
{nullptr, nullptr}};
const char* sloppy_context_data[][2] =
{{"(function(",
"){ return;})(1, [],/regexp/, 'str', function(){});"},
{nullptr, nullptr}};
const char* data[] = {
"...eval",
"eval, ...args",
"...arguments",
// See https://bugs.chromium.org/p/v8/issues/detail?id=4577
// "arguments, ...args",
nullptr};
// clang-format on
// Fail in strict mode
RunParserSyncTest(strict_context_data, data, kError);
// OK in sloppy mode
RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
TEST(RestParametersDuplicateEvalArguments) {
const char* context_data[][2] = {
{"'use strict';(function(",
"){ return;})(1, [], /regexp/, 'str',function(){});"},
{"(function(", "){ return;})(1, [],/regexp/, 'str', function(){});"},
{nullptr, nullptr}};
const char* data[] = {"eval, ...eval", "eval, eval, ...args",
"arguments, ...arguments",
"arguments, arguments, ...args", nullptr};
// In strict mode, the error is using "eval" or "arguments" as parameter names
// In sloppy mode, the error is that eval / arguments are duplicated
RunParserSyncTest(context_data, data, kError);
}
TEST(SpreadCall) {
const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"},
{"function fn() {} fn(", ");"},
{nullptr, nullptr}};
const char* data[] = {"...([1, 2, 3])",
"...'123', ...'456'",
"...new Set([1, 2, 3]), 4",
"1, ...[2, 3], 4",
"...Array(...[1,2,3,4])",
"...NaN",
"0, 1, ...[2, 3, 4], 5, 6, 7, ...'89'",
"0, 1, ...[2, 3, 4], 5, 6, 7, ...'89', 10",
"...[0, 1, 2], 3, 4, 5, 6, ...'7', 8, 9",
"...[0, 1, 2], 3, 4, 5, 6, ...'7', 8, 9, ...[10]",
nullptr};
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(SpreadCallErrors) {
const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"},
{"function fn() {} fn(", ");"},
{nullptr, nullptr}};
const char* data[] = {"(...[1, 2, 3])", "......[1,2,3]", nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(BadRestSpread) {
const char* context_data[][2] = {{"function fn() { 'use strict';", "} fn();"},
{"function fn() { ", "} fn();"},
{nullptr, nullptr}};
const char* data[] = {"return ...[1,2,3];",
"var ...x = [1,2,3];",
"var [...x,] = [1,2,3];",
"var [...x, y] = [1,2,3];",
"var { x } = {x: ...[1,2,3]}",
nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(LexicalScopingSloppyMode) {
const char* context_data[][2] = {
{"", ""}, {"function f() {", "}"}, {"{", "}"}, {nullptr, nullptr}};
const char* good_data[] = {"let = 1;", "for(let = 1;;){}", nullptr};
RunParserSyncTest(context_data, good_data, kSuccess);
}
TEST(ComputedPropertyName) {
const char* context_data[][2] = {{"({[", "]: 1});"},
{"({get [", "]() {}});"},
{"({set [", "](_) {}});"},
{"({[", "]() {}});"},
{"({*[", "]() {}});"},
{"(class {get [", "]() {}});"},
{"(class {set [", "](_) {}});"},
{"(class {[", "]() {}});"},
{"(class {*[", "]() {}});"},
{nullptr, nullptr}};
const char* error_data[] = {"1, 2", "var name", nullptr};
RunParserSyncTest(context_data, error_data, kError);
const char* name_data[] = {"1", "1 + 2", "'name'", "\"name\"",
"[]", "{}", nullptr};
RunParserSyncTest(context_data, name_data, kSuccess);
}
TEST(ComputedPropertyNameShorthandError) {
const char* context_data[][2] = {{"({", "});"}, {nullptr, nullptr}};
const char* error_data[] = {"a: 1, [2]", "[1], a: 1", nullptr};
RunParserSyncTest(context_data, error_data, kError);
}
TEST(BasicImportExportParsing) {
// clang-format off
const char* kSources[] = {
"export let x = 0;",
"export var y = 0;",
"export const z = 0;",
"export function func() { };",
"export class C { };",
"export { };",
"function f() {}; f(); export { f };",
"var a, b, c; export { a, b as baz, c };",
"var d, e; export { d as dreary, e, };",
"export default function f() {}",
"export default function() {}",
"export default function*() {}",
"export default class C {}",
"export default class {}",
"export default class extends C {}",
"export default 42",
"var x; export default x = 7",
"export { Q } from 'somemodule.js';",
"export * from 'somemodule.js';",
"var foo; export { foo as for };",
"export { arguments } from 'm.js';",
"export { for } from 'm.js';",
"export { yield } from 'm.js'",
"export { static } from 'm.js'",
"export { let } from 'm.js'",
"var a; export { a as b, a as c };",
"var a; export { a as await };",
"var a; export { a as enum };",
"import 'somemodule.js';",
"import { } from 'm.js';",
"import { a } from 'm.js';",
"import { a, b as d, c, } from 'm.js';",
"import * as thing from 'm.js';",
"import thing from 'm.js';",
"import thing, * as rest from 'm.js';",
"import thing, { a, b, c } from 'm.js';",
"import { arguments as a } from 'm.js';",
"import { for as f } from 'm.js';",
"import { yield as y } from 'm.js';",
"import { static as s } from 'm.js';",
"import { let as l } from 'm.js';",
"import thing from 'a.js'; export {thing};",
"export {thing}; import thing from 'a.js';",
"import {thing} from 'a.js'; export {thing};",
"export {thing}; import {thing} from 'a.js';",
"import * as thing from 'a.js'; export {thing};",
"export {thing}; import * as thing from 'a.js';",
};
// clang-format on
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
for (unsigned i = 0; i < arraysize(kSources); ++i) {
i::Handle<i::String> source =
factory->NewStringFromAsciiChecked(kSources[i]);
// Show that parsing as a module works
{
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
}
// And that parsing a script does not.
{
i::UnoptimizedCompileState compile_state(isolate);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK(!i::parsing::ParseProgram(&info, script, isolate,
parsing::ReportStatisticsMode::kYes));
CHECK(info.pending_error_handler()->has_pending_error());
}
}
}
TEST(NamespaceExportParsing) {
// clang-format off
const char* kSources[] = {
"export * as arguments from 'bar'",
"export * as await from 'bar'",
"export * as default from 'bar'",
"export * as enum from 'bar'",
"export * as foo from 'bar'",
"export * as for from 'bar'",
"export * as let from 'bar'",
"export * as static from 'bar'",
"export * as yield from 'bar'",
};
// clang-format on
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
for (unsigned i = 0; i < arraysize(kSources); ++i) {
i::Handle<i::String> source =
factory->NewStringFromAsciiChecked(kSources[i]);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
}
}
TEST(ImportExportParsingErrors) {
// clang-format off
const char* kErrorSources[] = {
"export {",
"var a; export { a",
"var a; export { a,",
"var a; export { a, ;",
"var a; export { a as };",
"var a, b; export { a as , b};",
"export }",
"var foo, bar; export { foo bar };",
"export { foo };",
"export { , };",
"export default;",
"export default var x = 7;",
"export default let x = 7;",
"export default const x = 7;",
"export *;",
"export * from;",
"export { Q } from;",
"export default from 'module.js';",
"export { for }",
"export { for as foo }",
"export { arguments }",
"export { arguments as foo }",
"var a; export { a, a };",
"var a, b; export { a as b, b };",
"var a, b; export { a as c, b as c };",
"export default function f(){}; export default class C {};",
"export default function f(){}; var a; export { a as default };",
"export function() {}",
"export function*() {}",
"export class {}",
"export class extends C {}",
"import from;",
"import from 'm.js';",
"import { };",
"import {;",
"import };",
"import { , };",
"import { , } from 'm.js';",
"import { a } from;",
"import { a } 'm.js';",
"import , from 'm.js';",
"import a , from 'm.js';",
"import a { b, c } from 'm.js';",
"import arguments from 'm.js';",
"import eval from 'm.js';",
"import { arguments } from 'm.js';",
"import { eval } from 'm.js';",
"import { a as arguments } from 'm.js';",
"import { for } from 'm.js';",
"import { y as yield } from 'm.js'",
"import { s as static } from 'm.js'",
"import { l as let } from 'm.js'",
"import { a as await } from 'm.js';",
"import { a as enum } from 'm.js';",
"import { x }, def from 'm.js';",
"import def, def2 from 'm.js';",
"import * as x, def from 'm.js';",
"import * as x, * as y from 'm.js';",
"import {x}, {y} from 'm.js';",
"import * as x, {y} from 'm.js';",
"export *;",
"export * as;",
"export * as foo;",
"export * as foo from;",
"export * as foo from ';",
"export * as ,foo from 'bar'",
};
// clang-format on
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
i::Handle<i::String> source =
factory->NewStringFromAsciiChecked(kErrorSources[i]);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK(!i::parsing::ParseProgram(&info, script, isolate,
parsing::ReportStatisticsMode::kYes));
CHECK(info.pending_error_handler()->has_pending_error());
}
}
TEST(ModuleTopLevelFunctionDecl) {
// clang-format off
const char* kErrorSources[] = {
"function f() {} function f() {}",
"var f; function f() {}",
"function f() {} var f;",
"function* f() {} function* f() {}",
"var f; function* f() {}",
"function* f() {} var f;",
"function f() {} function* f() {}",
"function* f() {} function f() {}",
};
// clang-format on
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
i::Handle<i::String> source =
factory->NewStringFromAsciiChecked(kErrorSources[i]);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK(!i::parsing::ParseProgram(&info, script, isolate,
parsing::ReportStatisticsMode::kYes));
CHECK(info.pending_error_handler()->has_pending_error());
}
}
TEST(ModuleAwaitReserved) {
// clang-format off
const char* kErrorSources[] = {
"await;",
"await: ;",
"var await;",
"var [await] = [];",
"var { await } = {};",
"var { x: await } = {};",
"{ var await; }",
"let await;",
"let [await] = [];",
"let { await } = {};",
"let { x: await } = {};",
"{ let await; }",
"const await = null;",
"const [await] = [];",
"const { await } = {};",
"const { x: await } = {};",
"{ const await = null; }",
"function await() {}",
"function f(await) {}",
"function* await() {}",
"function* g(await) {}",
"(function await() {});",
"(function (await) {});",
"(function* await() {});",
"(function* (await) {});",
"(await) => {};",
"await => {};",
"class await {}",
"class C { constructor(await) {} }",
"class C { m(await) {} }",
"class C { static m(await) {} }",
"class C { *m(await) {} }",
"class C { static *m(await) {} }",
"(class await {})",
"(class { constructor(await) {} });",
"(class { m(await) {} });",
"(class { static m(await) {} });",
"(class { *m(await) {} });",
"(class { static *m(await) {} });",
"({ m(await) {} });",
"({ *m(await) {} });",
"({ set p(await) {} });",
"try {} catch (await) {}",
"try {} catch (await) {} finally {}",
nullptr
};
// clang-format on
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
RunModuleParserSyncTest(context_data, kErrorSources, kError);
}
TEST(ModuleAwaitReservedPreParse) {
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* error_data[] = {"function f() { var await = 0; }", nullptr};
RunModuleParserSyncTest(context_data, error_data, kError);
}
TEST(ModuleAwaitPermitted) {
// clang-format off
const char* kValidSources[] = {
"({}).await;",
"({ await: null });",
"({ await() {} });",
"({ get await() {} });",
"({ set await(x) {} });",
"(class { await() {} });",
"(class { static await() {} });",
"(class { *await() {} });",
"(class { static *await() {} });",
nullptr
};
// clang-format on
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
RunModuleParserSyncTest(context_data, kValidSources, kSuccess);
}
TEST(EnumReserved) {
// clang-format off
const char* kErrorSources[] = {
"enum;",
"enum: ;",
"var enum;",
"var [enum] = [];",
"var { enum } = {};",
"var { x: enum } = {};",
"{ var enum; }",
"let enum;",
"let [enum] = [];",
"let { enum } = {};",
"let { x: enum } = {};",
"{ let enum; }",
"const enum = null;",
"const [enum] = [];",
"const { enum } = {};",
"const { x: enum } = {};",
"{ const enum = null; }",
"function enum() {}",
"function f(enum) {}",
"function* enum() {}",
"function* g(enum) {}",
"(function enum() {});",
"(function (enum) {});",
"(function* enum() {});",
"(function* (enum) {});",
"(enum) => {};",
"enum => {};",
"class enum {}",
"class C { constructor(enum) {} }",
"class C { m(enum) {} }",
"class C { static m(enum) {} }",
"class C { *m(enum) {} }",
"class C { static *m(enum) {} }",
"(class enum {})",
"(class { constructor(enum) {} });",
"(class { m(enum) {} });",
"(class { static m(enum) {} });",
"(class { *m(enum) {} });",
"(class { static *m(enum) {} });",
"({ m(enum) {} });",
"({ *m(enum) {} });",
"({ set p(enum) {} });",
"try {} catch (enum) {}",
"try {} catch (enum) {} finally {}",
nullptr
};
// clang-format on
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
RunModuleParserSyncTest(context_data, kErrorSources, kError);
}
static void CheckEntry(const i::SourceTextModuleDescriptor::Entry* entry,
const char* export_name, const char* local_name,
const char* import_name, int module_request) {
CHECK_NOT_NULL(entry);
if (export_name == nullptr) {
CHECK_NULL(entry->export_name);
} else {
CHECK(entry->export_name->IsOneByteEqualTo(export_name));
}
if (local_name == nullptr) {
CHECK_NULL(entry->local_name);
} else {
CHECK(entry->local_name->IsOneByteEqualTo(local_name));
}
if (import_name == nullptr) {
CHECK_NULL(entry->import_name);
} else {
CHECK(entry->import_name->IsOneByteEqualTo(import_name));
}
CHECK_EQ(entry->module_request, module_request);
}
TEST(ModuleParsingInternals) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
static const char kSource[] =
"let x = 5;"
"export { x as y };"
"import { q as z } from 'm.js';"
"import n from 'n.js';"
"export { a as b } from 'm.js';"
"export * from 'p.js';"
"export var foo;"
"export function goo() {};"
"export let hoo;"
"export const joo = 42;"
"export default (function koo() {});"
"import 'q.js';"
"let nonexport = 42;"
"import {m as mm} from 'm.js';"
"import {aa} from 'm.js';"
"export {aa as bb, x};"
"import * as loo from 'bar.js';"
"import * as foob from 'bar.js';"
"export {foob};";
i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
i::FunctionLiteral* func = info.literal();
i::ModuleScope* module_scope = func->scope()->AsModuleScope();
i::Scope* outer_scope = module_scope->outer_scope();
CHECK(outer_scope->is_script_scope());
CHECK_NULL(outer_scope->outer_scope());
CHECK(module_scope->is_module_scope());
const i::SourceTextModuleDescriptor::Entry* entry;
i::Declaration::List* declarations = module_scope->declarations();
CHECK_EQ(13, declarations->LengthForTest());
CHECK(declarations->AtForTest(0)->var()->raw_name()->IsOneByteEqualTo("x"));
CHECK(declarations->AtForTest(0)->var()->mode() == i::VariableMode::kLet);
CHECK(declarations->AtForTest(0)->var()->binding_needs_init());
CHECK(declarations->AtForTest(0)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(1)->var()->raw_name()->IsOneByteEqualTo("z"));
CHECK(declarations->AtForTest(1)->var()->mode() == i::VariableMode::kConst);
CHECK(declarations->AtForTest(1)->var()->binding_needs_init());
CHECK(declarations->AtForTest(1)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(2)->var()->raw_name()->IsOneByteEqualTo("n"));
CHECK(declarations->AtForTest(2)->var()->mode() == i::VariableMode::kConst);
CHECK(declarations->AtForTest(2)->var()->binding_needs_init());
CHECK(declarations->AtForTest(2)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(3)->var()->raw_name()->IsOneByteEqualTo("foo"));
CHECK(declarations->AtForTest(3)->var()->mode() == i::VariableMode::kVar);
CHECK(!declarations->AtForTest(3)->var()->binding_needs_init());
CHECK(declarations->AtForTest(3)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(4)->var()->raw_name()->IsOneByteEqualTo("goo"));
CHECK(declarations->AtForTest(4)->var()->mode() == i::VariableMode::kLet);
CHECK(!declarations->AtForTest(4)->var()->binding_needs_init());
CHECK(declarations->AtForTest(4)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(5)->var()->raw_name()->IsOneByteEqualTo("hoo"));
CHECK(declarations->AtForTest(5)->var()->mode() == i::VariableMode::kLet);
CHECK(declarations->AtForTest(5)->var()->binding_needs_init());
CHECK(declarations->AtForTest(5)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(6)->var()->raw_name()->IsOneByteEqualTo("joo"));
CHECK(declarations->AtForTest(6)->var()->mode() == i::VariableMode::kConst);
CHECK(declarations->AtForTest(6)->var()->binding_needs_init());
CHECK(declarations->AtForTest(6)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(7)->var()->raw_name()->IsOneByteEqualTo(
".default"));
CHECK(declarations->AtForTest(7)->var()->mode() == i::VariableMode::kConst);
CHECK(declarations->AtForTest(7)->var()->binding_needs_init());
CHECK(declarations->AtForTest(7)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(8)->var()->raw_name()->IsOneByteEqualTo(
"nonexport"));
CHECK(!declarations->AtForTest(8)->var()->binding_needs_init());
CHECK(declarations->AtForTest(8)->var()->location() ==
i::VariableLocation::LOCAL);
CHECK(declarations->AtForTest(9)->var()->raw_name()->IsOneByteEqualTo("mm"));
CHECK(declarations->AtForTest(9)->var()->mode() == i::VariableMode::kConst);
CHECK(declarations->AtForTest(9)->var()->binding_needs_init());
CHECK(declarations->AtForTest(9)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(declarations->AtForTest(10)->var()->raw_name()->IsOneByteEqualTo("aa"));
CHECK(declarations->AtForTest(10)->var()->mode() == i::VariableMode::kConst);
CHECK(declarations->AtForTest(10)->var()->binding_needs_init());
CHECK(declarations->AtForTest(10)->var()->location() ==
i::VariableLocation::MODULE);
CHECK(
declarations->AtForTest(11)->var()->raw_name()->IsOneByteEqualTo("loo"));
CHECK(declarations->AtForTest(11)->var()->mode() == i::VariableMode::kConst);
CHECK(!declarations->AtForTest(11)->var()->binding_needs_init());
CHECK(declarations->AtForTest(11)->var()->location() !=
i::VariableLocation::MODULE);
CHECK(
declarations->AtForTest(12)->var()->raw_name()->IsOneByteEqualTo("foob"));
CHECK(declarations->AtForTest(12)->var()->mode() == i::VariableMode::kConst);
CHECK(!declarations->AtForTest(12)->var()->binding_needs_init());
CHECK(declarations->AtForTest(12)->var()->location() ==
i::VariableLocation::MODULE);
i::SourceTextModuleDescriptor* descriptor = module_scope->module();
CHECK_NOT_NULL(descriptor);
CHECK_EQ(5u, descriptor->module_requests().size());
for (const auto& elem : descriptor->module_requests()) {
if (elem->specifier()->IsOneByteEqualTo("m.js")) {
CHECK_EQ(0, elem->index());
CHECK_EQ(51, elem->position());
} else if (elem->specifier()->IsOneByteEqualTo("n.js")) {
CHECK_EQ(1, elem->index());
CHECK_EQ(72, elem->position());
} else if (elem->specifier()->IsOneByteEqualTo("p.js")) {
CHECK_EQ(2, elem->index());
CHECK_EQ(123, elem->position());
} else if (elem->specifier()->IsOneByteEqualTo("q.js")) {
CHECK_EQ(3, elem->index());
CHECK_EQ(249, elem->position());
} else if (elem->specifier()->IsOneByteEqualTo("bar.js")) {
CHECK_EQ(4, elem->index());
CHECK_EQ(370, elem->position());
} else {
UNREACHABLE();
}
}
CHECK_EQ(3, descriptor->special_exports().size());
CheckEntry(descriptor->special_exports().at(0), "b", nullptr, "a", 0);
CheckEntry(descriptor->special_exports().at(1), nullptr, nullptr, nullptr, 2);
CheckEntry(descriptor->special_exports().at(2), "bb", nullptr, "aa",
0); // !!!
CHECK_EQ(8u, descriptor->regular_exports().size());
entry = descriptor->regular_exports()
.find(declarations->AtForTest(3)->var()->raw_name())
->second;
CheckEntry(entry, "foo", "foo", nullptr, -1);
entry = descriptor->regular_exports()
.find(declarations->AtForTest(4)->var()->raw_name())
->second;
CheckEntry(entry, "goo", "goo", nullptr, -1);
entry = descriptor->regular_exports()
.find(declarations->AtForTest(5)->var()->raw_name())
->second;
CheckEntry(entry, "hoo", "hoo", nullptr, -1);
entry = descriptor->regular_exports()
.find(declarations->AtForTest(6)->var()->raw_name())
->second;
CheckEntry(entry, "joo", "joo", nullptr, -1);
entry = descriptor->regular_exports()
.find(declarations->AtForTest(7)->var()->raw_name())
->second;
CheckEntry(entry, "default", ".default", nullptr, -1);
entry = descriptor->regular_exports()
.find(declarations->AtForTest(12)->var()->raw_name())
->second;
CheckEntry(entry, "foob", "foob", nullptr, -1);
// TODO(neis): The next lines are terrible. Find a better way.
auto name_x = declarations->AtForTest(0)->var()->raw_name();
CHECK_EQ(2u, descriptor->regular_exports().count(name_x));
auto it = descriptor->regular_exports().equal_range(name_x).first;
entry = it->second;
if (entry->export_name->IsOneByteEqualTo("y")) {
CheckEntry(entry, "y", "x", nullptr, -1);
entry = (++it)->second;
CheckEntry(entry, "x", "x", nullptr, -1);
} else {
CheckEntry(entry, "x", "x", nullptr, -1);
entry = (++it)->second;
CheckEntry(entry, "y", "x", nullptr, -1);
}
CHECK_EQ(2, descriptor->namespace_imports().size());
CheckEntry(descriptor->namespace_imports().at(0), nullptr, "loo", nullptr, 4);
CheckEntry(descriptor->namespace_imports().at(1), nullptr, "foob", nullptr,
4);
CHECK_EQ(4u, descriptor->regular_imports().size());
entry = descriptor->regular_imports()
.find(declarations->AtForTest(1)->var()->raw_name())
->second;
CheckEntry(entry, nullptr, "z", "q", 0);
entry = descriptor->regular_imports()
.find(declarations->AtForTest(2)->var()->raw_name())
->second;
CheckEntry(entry, nullptr, "n", "default", 1);
entry = descriptor->regular_imports()
.find(declarations->AtForTest(9)->var()->raw_name())
->second;
CheckEntry(entry, nullptr, "mm", "m", 0);
entry = descriptor->regular_imports()
.find(declarations->AtForTest(10)->var()->raw_name())
->second;
CheckEntry(entry, nullptr, "aa", "aa", 0);
}
TEST(ModuleParsingInternalsWithImportAssertions) {
i::FLAG_harmony_import_assertions = true;
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(base::Stack::GetCurrentStackPosition() -
128 * 1024);
static const char kSource[] =
"import { q as z } from 'm.js';"
"import { q as z2 } from 'm.js' assert { foo: 'bar'};"
"import { q as z3 } from 'm.js' assert { foo2: 'bar'};"
"import { q as z4 } from 'm.js' assert { foo: 'bar2'};"
"import { q as z5 } from 'm.js' assert { foo: 'bar', foo2: 'bar'};"
"import { q as z6 } from 'n.js' assert { foo: 'bar'};"
"import 'm.js' assert { foo: 'bar'};"
"export * from 'm.js' assert { foo: 'bar', foo2: 'bar'};";
i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
i::FunctionLiteral* func = info.literal();
i::ModuleScope* module_scope = func->scope()->AsModuleScope();
CHECK(module_scope->is_module_scope());
i::SourceTextModuleDescriptor* descriptor = module_scope->module();
CHECK_NOT_NULL(descriptor);
const i::AstRawString* foo_string =
info.ast_value_factory()->GetOneByteString("foo");
const i::AstRawString* foo2_string =
info.ast_value_factory()->GetOneByteString("foo2");
CHECK_EQ(6u, descriptor->module_requests().size());
for (const auto& elem : descriptor->module_requests()) {
if (elem->index() == 0) {
CHECK(elem->specifier()->IsOneByteEqualTo("m.js"));
CHECK_EQ(0, elem->import_assertions()->size());
CHECK_EQ(23, elem->position());
} else if (elem->index() == 1) {
CHECK(elem->specifier()->IsOneByteEqualTo("m.js"));
CHECK_EQ(1, elem->import_assertions()->size());
CHECK_EQ(54, elem->position());
CHECK(elem->import_assertions()
->at(foo_string)
.first->IsOneByteEqualTo("bar"));
CHECK_EQ(70, elem->import_assertions()->at(foo_string).second.beg_pos);
} else if (elem->index() == 2) {
CHECK(elem->specifier()->IsOneByteEqualTo("m.js"));
CHECK_EQ(1, elem->import_assertions()->size());
CHECK_EQ(106, elem->position());
CHECK(elem->import_assertions()
->at(foo2_string)
.first->IsOneByteEqualTo("bar"));
CHECK_EQ(122, elem->import_assertions()->at(foo2_string).second.beg_pos);
} else if (elem->index() == 3) {
CHECK(elem->specifier()->IsOneByteEqualTo("m.js"));
CHECK_EQ(1, elem->import_assertions()->size());
CHECK_EQ(159, elem->position());
CHECK(elem->import_assertions()
->at(foo_string)
.first->IsOneByteEqualTo("bar2"));
CHECK_EQ(175, elem->import_assertions()->at(foo_string).second.beg_pos);
} else if (elem->index() == 4) {
CHECK(elem->specifier()->IsOneByteEqualTo("m.js"));
CHECK_EQ(2, elem->import_assertions()->size());
CHECK_EQ(212, elem->position());
CHECK(elem->import_assertions()
->at(foo_string)
.first->IsOneByteEqualTo("bar"));
CHECK_EQ(228, elem->import_assertions()->at(foo_string).second.beg_pos);
CHECK(elem->import_assertions()
->at(foo2_string)
.first->IsOneByteEqualTo("bar"));
CHECK_EQ(240, elem->import_assertions()->at(foo2_string).second.beg_pos);
} else if (elem->index() == 5) {
CHECK(elem->specifier()->IsOneByteEqualTo("n.js"));
CHECK_EQ(1, elem->import_assertions()->size());
CHECK_EQ(277, elem->position());
CHECK(elem->import_assertions()
->at(foo_string)
.first->IsOneByteEqualTo("bar"));
CHECK_EQ(293, elem->import_assertions()->at(foo_string).second.beg_pos);
} else {
UNREACHABLE();
}
}
}
TEST(ModuleParsingModuleRequestOrdering) {
i::FLAG_harmony_import_assertions = true;
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(base::Stack::GetCurrentStackPosition() -
128 * 1024);
static const char kSource[] =
"import 'foo' assert { };"
"import 'baaaaaar' assert { };"
"import 'aa' assert { };"
"import 'a' assert { a: 'b' };"
"import 'b' assert { };"
"import 'd' assert { a: 'b' };"
"import 'c' assert { };"
"import 'f' assert { };"
"import 'f' assert { a: 'b'};"
"import 'g' assert { a: 'b' };"
"import 'g' assert { };"
"import 'h' assert { a: 'd' };"
"import 'h' assert { b: 'c' };"
"import 'i' assert { b: 'c' };"
"import 'i' assert { a: 'd' };"
"import 'j' assert { a: 'b' };"
"import 'j' assert { a: 'c' };"
"import 'k' assert { a: 'c' };"
"import 'k' assert { a: 'b' };"
"import 'l' assert { a: 'b', e: 'f' };"
"import 'l' assert { a: 'c', d: 'g' };"
"import 'm' assert { a: 'c', d: 'g' };"
"import 'm' assert { a: 'b', e: 'f' };"
"import 'n' assert { 'd': '' };"
"import 'n' assert { 'a': 'b' };"
"import 'o' assert { 'a': 'b' };"
"import 'o' assert { 'd': '' };"
"import 'p' assert { 'z': 'c' };"
"import 'p' assert { 'a': 'c', 'b': 'c' };";
i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
i::FunctionLiteral* func = info.literal();
i::ModuleScope* module_scope = func->scope()->AsModuleScope();
CHECK(module_scope->is_module_scope());
i::SourceTextModuleDescriptor* descriptor = module_scope->module();
CHECK_NOT_NULL(descriptor);
const i::AstRawString* a_string =
info.ast_value_factory()->GetOneByteString("a");
const i::AstRawString* b_string =
info.ast_value_factory()->GetOneByteString("b");
const i::AstRawString* d_string =
info.ast_value_factory()->GetOneByteString("d");
const i::AstRawString* e_string =
info.ast_value_factory()->GetOneByteString("e");
const i::AstRawString* z_string =
info.ast_value_factory()->GetOneByteString("z");
CHECK_EQ(29u, descriptor->module_requests().size());
auto request_iterator = descriptor->module_requests().cbegin();
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("a"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("aa"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("b"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("baaaaaar"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("c"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("d"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("f"));
CHECK_EQ(0, (*request_iterator)->import_assertions()->size());
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("f"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("foo"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("g"));
CHECK_EQ(0, (*request_iterator)->import_assertions()->size());
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("g"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("h"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("d"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("h"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(b_string)
.first->IsOneByteEqualTo("c"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("i"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("d"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("i"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(b_string)
.first->IsOneByteEqualTo("c"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("j"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("b"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("j"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("c"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("k"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("b"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("k"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("c"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("l"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("b"));
CHECK((*request_iterator)
->import_assertions()
->at(e_string)
.first->IsOneByteEqualTo("f"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("l"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("c"));
CHECK((*request_iterator)
->import_assertions()
->at(d_string)
.first->IsOneByteEqualTo("g"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("m"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("b"));
CHECK((*request_iterator)
->import_assertions()
->at(e_string)
.first->IsOneByteEqualTo("f"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("m"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("c"));
CHECK((*request_iterator)
->import_assertions()
->at(d_string)
.first->IsOneByteEqualTo("g"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("n"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("b"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("n"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(d_string)
.first->IsOneByteEqualTo(""));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("o"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("b"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("o"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(d_string)
.first->IsOneByteEqualTo(""));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("p"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(a_string)
.first->IsOneByteEqualTo("c"));
CHECK((*request_iterator)
->import_assertions()
->at(b_string)
.first->IsOneByteEqualTo("c"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("p"));
CHECK_EQ(1, (*request_iterator)->import_assertions()->size());
CHECK((*request_iterator)
->import_assertions()
->at(z_string)
.first->IsOneByteEqualTo("c"));
}
TEST(ModuleParsingImportAssertionKeySorting) {
i::FLAG_harmony_import_assertions = true;
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(base::Stack::GetCurrentStackPosition() -
128 * 1024);
static const char kSource[] =
"import 'a' assert { 'b':'z', 'a': 'c' };"
"import 'b' assert { 'aaaaaa': 'c', 'b': 'z' };"
"import 'c' assert { '': 'c', 'b': 'z' };"
"import 'd' assert { 'aabbbb': 'c', 'aaabbb': 'z' };"
// zzzz\u0005 is a one-byte string, yyyy\u0100 is a two-byte string.
"import 'e' assert { 'zzzz\\u0005': 'second', 'yyyy\\u0100': 'first' };"
// Both keys are two-byte strings.
"import 'f' assert { 'xxxx\\u0005\\u0101': 'first', "
"'xxxx\\u0100\\u0101': 'second' };";
i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_module(true);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
i::FunctionLiteral* func = info.literal();
i::ModuleScope* module_scope = func->scope()->AsModuleScope();
CHECK(module_scope->is_module_scope());
i::SourceTextModuleDescriptor* descriptor = module_scope->module();
CHECK_NOT_NULL(descriptor);
CHECK_EQ(6u, descriptor->module_requests().size());
auto request_iterator = descriptor->module_requests().cbegin();
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("a"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
auto assertion_iterator = (*request_iterator)->import_assertions()->cbegin();
CHECK(assertion_iterator->first->IsOneByteEqualTo("a"));
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("c"));
++assertion_iterator;
CHECK(assertion_iterator->first->IsOneByteEqualTo("b"));
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("z"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("b"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
assertion_iterator = (*request_iterator)->import_assertions()->cbegin();
CHECK(assertion_iterator->first->IsOneByteEqualTo("aaaaaa"));
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("c"));
++assertion_iterator;
CHECK(assertion_iterator->first->IsOneByteEqualTo("b"));
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("z"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("c"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
assertion_iterator = (*request_iterator)->import_assertions()->cbegin();
CHECK(assertion_iterator->first->IsOneByteEqualTo(""));
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("c"));
++assertion_iterator;
CHECK(assertion_iterator->first->IsOneByteEqualTo("b"));
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("z"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("d"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
assertion_iterator = (*request_iterator)->import_assertions()->cbegin();
CHECK(assertion_iterator->first->IsOneByteEqualTo("aaabbb"));
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("z"));
++assertion_iterator;
CHECK(assertion_iterator->first->IsOneByteEqualTo("aabbbb"));
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("c"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("e"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
assertion_iterator = (*request_iterator)->import_assertions()->cbegin();
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("first"));
++assertion_iterator;
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("second"));
++request_iterator;
CHECK((*request_iterator)->specifier()->IsOneByteEqualTo("f"));
CHECK_EQ(2, (*request_iterator)->import_assertions()->size());
assertion_iterator = (*request_iterator)->import_assertions()->cbegin();
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("first"));
++assertion_iterator;
CHECK(assertion_iterator->second.first->IsOneByteEqualTo("second"));
}
TEST(DuplicateProtoError) {
const char* context_data[][2] = {
{"({", "});"}, {"'use strict'; ({", "});"}, {nullptr, nullptr}};
const char* error_data[] = {"__proto__: {}, __proto__: {}",
"__proto__: {}, \"__proto__\": {}",
"__proto__: {}, \"__\x70roto__\": {}",
"__proto__: {}, a: 1, __proto__: {}", nullptr};
RunParserSyncTest(context_data, error_data, kError);
}
TEST(DuplicateProtoNoError) {
const char* context_data[][2] = {
{"({", "});"}, {"'use strict'; ({", "});"}, {nullptr, nullptr}};
const char* error_data[] = {
"__proto__: {}, ['__proto__']: {}", "__proto__: {}, __proto__() {}",
"__proto__: {}, get __proto__() {}", "__proto__: {}, set __proto__(v) {}",
"__proto__: {}, __proto__", nullptr};
RunParserSyncTest(context_data, error_data, kSuccess);
}
TEST(DeclarationsError) {
const char* context_data[][2] = {{"'use strict'; if (true)", ""},
{"'use strict'; if (false) {} else", ""},
{"'use strict'; while (false)", ""},
{"'use strict'; for (;;)", ""},
{"'use strict'; for (x in y)", ""},
{"'use strict'; do ", " while (false)"},
{nullptr, nullptr}};
const char* statement_data[] = {"let x = 1;", "const x = 1;", "class C {}",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
void TestLanguageMode(const char* source,
i::LanguageMode expected_language_mode) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
v8::HandleScope handles(CcTest::isolate());
v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
128 * 1024);
i::Handle<i::Script> script =
factory->NewScript(factory->NewStringFromAsciiChecked(source));
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
CHECK_EQ(expected_language_mode, info.literal()->language_mode());
}
TEST(LanguageModeDirectives) {
TestLanguageMode("\"use nothing\"", i::LanguageMode::kSloppy);
TestLanguageMode("\"use strict\"", i::LanguageMode::kStrict);
TestLanguageMode("var x = 1; \"use strict\"", i::LanguageMode::kSloppy);
TestLanguageMode("\"use some future directive\"; \"use strict\";",
i::LanguageMode::kStrict);
}
TEST(PropertyNameEvalArguments) {
const char* context_data[][2] = {{"'use strict';", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"({eval: 1})",
"({arguments: 1})",
"({eval() {}})",
"({arguments() {}})",
"({*eval() {}})",
"({*arguments() {}})",
"({get eval() {}})",
"({get arguments() {}})",
"({set eval(_) {}})",
"({set arguments(_) {}})",
"class C {eval() {}}",
"class C {arguments() {}}",
"class C {*eval() {}}",
"class C {*arguments() {}}",
"class C {get eval() {}}",
"class C {get arguments() {}}",
"class C {set eval(_) {}}",
"class C {set arguments(_) {}}",
"class C {static eval() {}}",
"class C {static arguments() {}}",
"class C {static *eval() {}}",
"class C {static *arguments() {}}",
"class C {static get eval() {}}",
"class C {static get arguments() {}}",
"class C {static set eval(_) {}}",
"class C {static set arguments(_) {}}",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(FunctionLiteralDuplicateParameters) {
const char* strict_context_data[][2] = {
{"'use strict';(function(", "){})();"},
{"(function(", ") { 'use strict'; })();"},
{"'use strict'; function fn(", ") {}; fn();"},
{"function fn(", ") { 'use strict'; }; fn();"},
{nullptr, nullptr}};
const char* sloppy_context_data[][2] = {{"(function(", "){})();"},
{"(function(", ") {})();"},
{"function fn(", ") {}; fn();"},
{"function fn(", ") {}; fn();"},
{nullptr, nullptr}};
const char* data[] = {
"a, a",
"a, a, a",
"b, a, a",
"a, b, c, c",
"a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, w",
nullptr};
RunParserSyncTest(strict_context_data, data, kError);
RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
TEST(ArrowFunctionASIErrors) {
const char* context_data[][2] = {
{"'use strict';", ""}, {"", ""}, {nullptr, nullptr}};
const char* data[] = {"(a\n=> a)(1)",
"(a/*\n*/=> a)(1)",
"((a)\n=> a)(1)",
"((a)/*\n*/=> a)(1)",
"((a, b)\n=> a + b)(1, 2)",
"((a, b)/*\n*/=> a + b)(1, 2)",
nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(ObjectSpreadPositiveTests) {
// clang-format off
const char* context_data[][2] = {
{"x = ", ""},
{"'use strict'; x = ", ""},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"{ ...y }",
"{ a: 1, ...y }",
"{ b: 1, ...y }",
"{ y, ...y}",
"{ ...z = y}",
"{ ...y, y }",
"{ ...y, ...y}",
"{ a: 1, ...y, b: 1}",
"{ ...y, b: 1}",
"{ ...1}",
"{ ...null}",
"{ ...undefined}",
"{ ...1 in {}}",
"{ ...[]}",
"{ ...async function() { }}",
"{ ...async () => { }}",
"{ ...new Foo()}",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ObjectSpreadNegativeTests) {
const char* context_data[][2] = {
{"x = ", ""}, {"'use strict'; x = ", ""}, {nullptr, nullptr}};
// clang-format off
const char* data[] = {
"{ ...var z = y}",
"{ ...var}",
"{ ...foo bar}",
"{* ...foo}",
"{get ...foo}",
"{set ...foo}",
"{async ...foo}",
nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(TemplateEscapesPositiveTests) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"'use strict';", ""},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"tag`\\08`",
"tag`\\01`",
"tag`\\01${0}right`",
"tag`left${0}\\01`",
"tag`left${0}\\01${1}right`",
"tag`\\1`",
"tag`\\1${0}right`",
"tag`left${0}\\1`",
"tag`left${0}\\1${1}right`",
"tag`\\xg`",
"tag`\\xg${0}right`",
"tag`left${0}\\xg`",
"tag`left${0}\\xg${1}right`",
"tag`\\xAg`",
"tag`\\xAg${0}right`",
"tag`left${0}\\xAg`",
"tag`left${0}\\xAg${1}right`",
"tag`\\u0`",
"tag`\\u0${0}right`",
"tag`left${0}\\u0`",
"tag`left${0}\\u0${1}right`",
"tag`\\u0g`",
"tag`\\u0g${0}right`",
"tag`left${0}\\u0g`",
"tag`left${0}\\u0g${1}right`",
"tag`\\u00g`",
"tag`\\u00g${0}right`",
"tag`left${0}\\u00g`",
"tag`left${0}\\u00g${1}right`",
"tag`\\u000g`",
"tag`\\u000g${0}right`",
"tag`left${0}\\u000g`",
"tag`left${0}\\u000g${1}right`",
"tag`\\u{}`",
"tag`\\u{}${0}right`",
"tag`left${0}\\u{}`",
"tag`left${0}\\u{}${1}right`",
"tag`\\u{-0}`",
"tag`\\u{-0}${0}right`",
"tag`left${0}\\u{-0}`",
"tag`left${0}\\u{-0}${1}right`",
"tag`\\u{g}`",
"tag`\\u{g}${0}right`",
"tag`left${0}\\u{g}`",
"tag`left${0}\\u{g}${1}right`",
"tag`\\u{0`",
"tag`\\u{0${0}right`",
"tag`left${0}\\u{0`",
"tag`left${0}\\u{0${1}right`",
"tag`\\u{\\u{0}`",
"tag`\\u{\\u{0}${0}right`",
"tag`left${0}\\u{\\u{0}`",
"tag`left${0}\\u{\\u{0}${1}right`",
"tag`\\u{110000}`",
"tag`\\u{110000}${0}right`",
"tag`left${0}\\u{110000}`",
"tag`left${0}\\u{110000}${1}right`",
"tag` ${tag`\\u`}`",
"tag` ``\\u`",
"tag`\\u`` `",
"tag`\\u``\\u`",
"` ${tag`\\u`}`",
"` ``\\u`",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(TemplateEscapesNegativeTests) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"'use strict';", ""},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"`\\08`",
"`\\01`",
"`\\01${0}right`",
"`left${0}\\01`",
"`left${0}\\01${1}right`",
"`\\1`",
"`\\1${0}right`",
"`left${0}\\1`",
"`left${0}\\1${1}right`",
"`\\xg`",
"`\\xg${0}right`",
"`left${0}\\xg`",
"`left${0}\\xg${1}right`",
"`\\xAg`",
"`\\xAg${0}right`",
"`left${0}\\xAg`",
"`left${0}\\xAg${1}right`",
"`\\u0`",
"`\\u0${0}right`",
"`left${0}\\u0`",
"`left${0}\\u0${1}right`",
"`\\u0g`",
"`\\u0g${0}right`",
"`left${0}\\u0g`",
"`left${0}\\u0g${1}right`",
"`\\u00g`",
"`\\u00g${0}right`",
"`left${0}\\u00g`",
"`left${0}\\u00g${1}right`",
"`\\u000g`",
"`\\u000g${0}right`",
"`left${0}\\u000g`",
"`left${0}\\u000g${1}right`",
"`\\u{}`",
"`\\u{}${0}right`",
"`left${0}\\u{}`",
"`left${0}\\u{}${1}right`",
"`\\u{-0}`",
"`\\u{-0}${0}right`",
"`left${0}\\u{-0}`",
"`left${0}\\u{-0}${1}right`",
"`\\u{g}`",
"`\\u{g}${0}right`",
"`left${0}\\u{g}`",
"`left${0}\\u{g}${1}right`",
"`\\u{0`",
"`\\u{0${0}right`",
"`left${0}\\u{0`",
"`left${0}\\u{0${1}right`",
"`\\u{\\u{0}`",
"`\\u{\\u{0}${0}right`",
"`left${0}\\u{\\u{0}`",
"`left${0}\\u{\\u{0}${1}right`",
"`\\u{110000}`",
"`\\u{110000}${0}right`",
"`left${0}\\u{110000}`",
"`left${0}\\u{110000}${1}right`",
"`\\1``\\2`",
"tag` ${`\\u`}`",
"`\\u```",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
TEST(DestructuringPositiveTests) {
const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
{"var ", " = {};"},
{"'use strict'; const ", " = {};"},
{"function f(", ") {}"},
{"function f(argument1, ", ") {}"},
{"var f = (", ") => {};"},
{"var f = (argument1,", ") => {};"},
{"try {} catch(", ") {}"},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"a",
"{ x : y }",
"{ x : y = 1 }",
"{ get, set }",
"{ get = 1, set = 2 }",
"[a]",
"[a = 1]",
"[a,b,c]",
"[a, b = 42, c]",
"{ x : x, y : y }",
"{ x : x = 1, y : y }",
"{ x : x, y : y = 42 }",
"[]",
"{}",
"[{x:x, y:y}, [a,b,c]]",
"[{x:x = 1, y:y = 2}, [a = 3, b = 4, c = 5]]",
"{x}",
"{x, y}",
"{x = 42, y = 15}",
"[a,,b]",
"{42 : x}",
"{42 : x = 42}",
"{42e-2 : x}",
"{42e-2 : x = 42}",
"{x : y, x : z}",
"{'hi' : x}",
"{'hi' : x = 42}",
"{var: x}",
"{var: x = 42}",
"{[x] : z}",
"{[1+1] : z}",
"{[foo()] : z}",
"{}",
"[...rest]",
"[a,b,...rest]",
"[a,,...rest]",
"{ __proto__: x, __proto__: y}",
"{arguments: x}",
"{eval: x}",
"{ x : y, ...z }",
"{ x : y = 1, ...z }",
"{ x : x, y : y, ...z }",
"{ x : x = 1, y : y, ...z }",
"{ x : x, y : y = 42, ...z }",
"[{x:x, y:y, ...z}, [a,b,c]]",
"[{x:x = 1, y:y = 2, ...z}, [a = 3, b = 4, c = 5]]",
"{...x}",
"{x, ...y}",
"{x = 42, y = 15, ...z}",
"{42 : x = 42, ...y}",
"{'hi' : x, ...z}",
"{'hi' : x = 42, ...z}",
"{var: x = 42, ...z}",
"{[x] : z, ...y}",
"{[1+1] : z, ...x}",
"{arguments: x, ...z}",
"{ __proto__: x, __proto__: y, ...z}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
// v8:5201
{
// clang-format off
const char* sloppy_context_data[][2] = {
{"var ", " = {};"},
{"function f(", ") {}"},
{"function f(argument1, ", ") {}"},
{"var f = (", ") => {};"},
{"var f = (argument1,", ") => {};"},
{"try {} catch(", ") {}"},
{nullptr, nullptr}
};
const char* data[] = {
"{arguments}",
"{eval}",
"{x: arguments}",
"{x: eval}",
"{arguments = false}",
"{eval = false}",
"{...arguments}",
"{...eval}",
nullptr
};
// clang-format on
RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
}
TEST(DestructuringNegativeTests) {
{ // All modes.
const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
{"var ", " = {};"},
{"'use strict'; const ", " = {};"},
{"function f(", ") {}"},
{"function f(argument1, ", ") {}"},
{"var f = (", ") => {};"},
{"var f = ", " => {};"},
{"var f = (argument1,", ") => {};"},
{"try {} catch(", ") {}"},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"a++",
"++a",
"delete a",
"void a",
"typeof a",
"--a",
"+a",
"-a",
"~a",
"!a",
"{ x : y++ }",
"[a++]",
"(x => y)",
"(async x => y)",
"((x, z) => y)",
"(async (x, z) => y)",
"a[i]", "a()",
"a.b",
"new a",
"a + a",
"a - a",
"a * a",
"a / a",
"a == a",
"a != a",
"a > a",
"a < a",
"a <<< a",
"a >>> a",
"function a() {}",
"function* a() {}",
"async function a() {}",
"a`bcd`",
"this",
"null",
"true",
"false",
"1",
"'abc'",
"/abc/",
"`abc`",
"class {}",
"{+2 : x}",
"{-2 : x}",
"var",
"[var]",
"{x : {y : var}}",
"{x : x = a+}",
"{x : x = (a+)}",
"{x : x += a}",
"{m() {} = 0}",
"{[1+1]}",
"[...rest, x]",
"[a,b,...rest, x]",
"[a,,...rest, x]",
"[...rest,]",
"[a,b,...rest,]",
"[a,,...rest,]",
"[...rest,...rest1]",
"[a,b,...rest,...rest1]",
"[a,,..rest,...rest1]",
"[x, y, ...z = 1]",
"[...z = 1]",
"[x, y, ...[z] = [1]]",
"[...[z] = [1]]",
"{ x : 3 }",
"{ x : 'foo' }",
"{ x : /foo/ }",
"{ x : `foo` }",
"{ get a() {} }",
"{ set a() {} }",
"{ method() {} }",
"{ *method() {} }",
"...a++",
"...++a",
"...typeof a",
"...[a++]",
"...(x => y)",
"{ ...x, }",
"{ ...x, y }",
"{ y, ...x, y }",
"{ ...x, ...y }",
"{ ...x, ...x }",
"{ ...x, ...x = {} }",
"{ ...x, ...x = ...x }",
"{ ...x, ...x = ...{ x } }",
"{ ,, ...x }",
"{ ...get a() {} }",
"{ ...set a() {} }",
"{ ...method() {} }",
"{ ...function() {} }",
"{ ...*method() {} }",
"{...{x} }",
"{...[x] }",
"{...{ x = 5 } }",
"{...[ x = 5 ] }",
"{...x.f }",
"{...x[0] }",
"async function* a() {}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
{ // All modes.
const char* context_data[][2] = {
{"'use strict'; let ", " = {};"}, {"var ", " = {};"},
{"'use strict'; const ", " = {};"}, {"function f(", ") {}"},
{"function f(argument1, ", ") {}"}, {"var f = (", ") => {};"},
{"var f = (argument1,", ") => {};"}, {nullptr, nullptr}};
// clang-format off
const char* data[] = {
"x => x",
"() => x",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
{ // Strict mode.
const char* context_data[][2] = {
{"'use strict'; var ", " = {};"},
{"'use strict'; let ", " = {};"},
{"'use strict'; const ", " = {};"},
{"'use strict'; function f(", ") {}"},
{"'use strict'; function f(argument1, ", ") {}"},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"[arguments]",
"[eval]",
"{ a : arguments }",
"{ a : eval }",
"[public]",
"{ x : private }",
"{ x : arguments }",
"{ x : eval }",
"{ arguments }",
"{ eval }",
"{ arguments = false }"
"{ eval = false }",
"{ ...eval }",
"{ ...arguments }",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
{ // 'yield' in generators.
const char* context_data[][2] = {
{"function*() { var ", " = {};"},
{"function*() { 'use strict'; let ", " = {};"},
{"function*() { 'use strict'; const ", " = {};"},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"yield",
"[yield]",
"{ x : yield }",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
{ // Declaration-specific errors
const char* context_data[][2] = {{"'use strict'; var ", ""},
{"'use strict'; let ", ""},
{"'use strict'; const ", ""},
{"'use strict'; for (var ", ";;) {}"},
{"'use strict'; for (let ", ";;) {}"},
{"'use strict'; for (const ", ";;) {}"},
{"var ", ""},
{"let ", ""},
{"const ", ""},
{"for (var ", ";;) {}"},
{"for (let ", ";;) {}"},
{"for (const ", ";;) {}"},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"{ a }",
"[ a ]",
"{ ...a }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
}
TEST(ObjectRestNegativeTestSlow) {
// clang-format off
const char* context_data[][2] = {
{"var { ", " } = { a: 1};"},
{ nullptr, nullptr }
};
using v8::internal::Code;
std::string statement;
for (int i = 0; i < Code::kMaxArguments; ++i) {
statement += std::to_string(i) + " : " + "x, ";
}
statement += "...y";
const char* statement_data[] = {
statement.c_str(),
nullptr
};
// clang-format on
// The test is quite slow, so run it with a reduced set of flags.
static const ParserFlag flags[] = {kAllowLazy};
RunParserSyncTest(context_data, statement_data, kError, nullptr, 0, flags,
arraysize(flags));
}
TEST(DestructuringAssignmentPositiveTests) {
const char* context_data[][2] = {
{"'use strict'; let x, y, z; (", " = {});"},
{"var x, y, z; (", " = {});"},
{"'use strict'; let x, y, z; for (x in ", " = {});"},
{"'use strict'; let x, y, z; for (x of ", " = {});"},
{"var x, y, z; for (x in ", " = {});"},
{"var x, y, z; for (x of ", " = {});"},
{"var x, y, z; for (", " in {});"},
{"var x, y, z; for (", " of {});"},
{"'use strict'; var x, y, z; for (", " in {});"},
{"'use strict'; var x, y, z; for (", " of {});"},
{"var x, y, z; m(['a']) ? ", " = {} : rhs"},
{"var x, y, z; m(['b']) ? lhs : ", " = {}"},
{"'use strict'; var x, y, z; m(['a']) ? ", " = {} : rhs"},
{"'use strict'; var x, y, z; m(['b']) ? lhs : ", " = {}"},
{nullptr, nullptr}};
const char* mixed_assignments_context_data[][2] = {
{"'use strict'; let x, y, z; (", " = z = {});"},
{"var x, y, z; (", " = z = {});"},
{"'use strict'; let x, y, z; (x = ", " = z = {});"},
{"var x, y, z; (x = ", " = z = {});"},
{"'use strict'; let x, y, z; for (x in ", " = z = {});"},
{"'use strict'; let x, y, z; for (x in x = ", " = z = {});"},
{"'use strict'; let x, y, z; for (x of ", " = z = {});"},
{"'use strict'; let x, y, z; for (x of x = ", " = z = {});"},
{"var x, y, z; for (x in ", " = z = {});"},
{"var x, y, z; for (x in x = ", " = z = {});"},
{"var x, y, z; for (x of ", " = z = {});"},
{"var x, y, z; for (x of x = ", " = z = {});"},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"x",
"{ x : y }",
"{ x : foo().y }",
"{ x : foo()[y] }",
"{ x : y.z }",
"{ x : y[z] }",
"{ x : { y } }",
"{ x : { foo: y } }",
"{ x : { foo: foo().y } }",
"{ x : { foo: foo()[y] } }",
"{ x : { foo: y.z } }",
"{ x : { foo: y[z] } }",
"{ x : [ y ] }",
"{ x : [ foo().y ] }",
"{ x : [ foo()[y] ] }",
"{ x : [ y.z ] }",
"{ x : [ y[z] ] }",
"{ x : y = 10 }",
"{ x : foo().y = 10 }",
"{ x : foo()[y] = 10 }",
"{ x : y.z = 10 }",
"{ x : y[z] = 10 }",
"{ x : { y = 10 } = {} }",
"{ x : { foo: y = 10 } = {} }",
"{ x : { foo: foo().y = 10 } = {} }",
"{ x : { foo: foo()[y] = 10 } = {} }",
"{ x : { foo: y.z = 10 } = {} }",
"{ x : { foo: y[z] = 10 } = {} }",
"{ x : [ y = 10 ] = {} }",
"{ x : [ foo().y = 10 ] = {} }",
"{ x : [ foo()[y] = 10 ] = {} }",
"{ x : [ y.z = 10 ] = {} }",
"{ x : [ y[z] = 10 ] = {} }",
"{ z : { __proto__: x, __proto__: y } = z }"
"[ x ]",
"[ foo().x ]",
"[ foo()[x] ]",
"[ x.y ]",
"[ x[y] ]",
"[ { x } ]",
"[ { x : y } ]",
"[ { x : foo().y } ]",
"[ { x : foo()[y] } ]",
"[ { x : x.y } ]",
"[ { x : x[y] } ]",
"[ [ x ] ]",
"[ [ foo().x ] ]",
"[ [ foo()[x] ] ]",
"[ [ x.y ] ]",
"[ [ x[y] ] ]",
"[ x = 10 ]",
"[ foo().x = 10 ]",
"[ foo()[x] = 10 ]",
"[ x.y = 10 ]",
"[ x[y] = 10 ]",
"[ { x = 10 } = {} ]",
"[ { x : y = 10 } = {} ]",
"[ { x : foo().y = 10 } = {} ]",
"[ { x : foo()[y] = 10 } = {} ]",
"[ { x : x.y = 10 } = {} ]",
"[ { x : x[y] = 10 } = {} ]",
"[ [ x = 10 ] = {} ]",
"[ [ foo().x = 10 ] = {} ]",
"[ [ foo()[x] = 10 ] = {} ]",
"[ [ x.y = 10 ] = {} ]",
"[ [ x[y] = 10 ] = {} ]",
"{ x : y = 1 }",
"{ x }",
"{ x, y, z }",
"{ x = 1, y: z, z: y }",
"{x = 42, y = 15}",
"[x]",
"[x = 1]",
"[x,y,z]",
"[x, y = 42, z]",
"{ x : x, y : y }",
"{ x : x = 1, y : y }",
"{ x : x, y : y = 42 }",
"[]",
"{}",
"[{x:x, y:y}, [,x,z,]]",
"[{x:x = 1, y:y = 2}, [z = 3, z = 4, z = 5]]",
"[x,,y]",
"[(x),,(y)]",
"[(x)]",
"{42 : x}",
"{42 : x = 42}",
"{42e-2 : x}",
"{42e-2 : x = 42}",
"{'hi' : x}",
"{'hi' : x = 42}",
"{var: x}",
"{var: x = 42}",
"{var: (x) = 42}",
"{[x] : z}",
"{[1+1] : z}",
"{[1+1] : (z)}",
"{[foo()] : z}",
"{[foo()] : (z)}",
"{[foo()] : foo().bar}",
"{[foo()] : foo()['bar']}",
"{[foo()] : this.bar}",
"{[foo()] : this['bar']}",
"{[foo()] : 'foo'.bar}",
"{[foo()] : 'foo'['bar']}",
"[...x]",
"[x,y,...z]",
"[x,,...z]",
"{ x: y }",
"[x, y]",
"[((x, y) => z).x]",
"{x: ((y, z) => z).x}",
"[((x, y) => z)['x']]",
"{x: ((y, z) => z)['x']}",
"{x: { y = 10 } }",
"[(({ x } = { x: 1 }) => x).a]",
"{ ...d.x }",
"{ ...c[0]}",
// v8:4662
"{ x: (y) }",
"{ x: (y) = [] }",
"{ x: (foo.bar) }",
"{ x: (foo['bar']) }",
"[ ...(a) ]",
"[ ...(foo['bar']) ]",
"[ ...(foo.bar) ]",
"[ (y) ]",
"[ (foo.bar) ]",
"[ (foo['bar']) ]",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
RunParserSyncTest(mixed_assignments_context_data, data, kSuccess);
const char* empty_context_data[][2] = {
{"'use strict';", ""}, {"", ""}, {nullptr, nullptr}};
// CoverInitializedName ambiguity handling in various contexts
const char* ambiguity_data[] = {
"var foo = { x = 10 } = {};",
"var foo = { q } = { x = 10 } = {};",
"var foo; foo = { x = 10 } = {};",
"var foo; foo = { q } = { x = 10 } = {};",
"var x; ({ x = 10 } = {});",
"var q, x; ({ q } = { x = 10 } = {});",
"var x; [{ x = 10 } = {}]",
"var x; (true ? { x = true } = {} : { x = false } = {})",
"var q, x; (q, { x = 10 } = {});",
"var { x = 10 } = { x = 20 } = {};",
"var { __proto__: x, __proto__: y } = {}",
"({ __proto__: x, __proto__: y } = {})",
"var { x = 10 } = (o = { x = 20 } = {});",
"var x; (({ x = 10 } = { x = 20 } = {}) => x)({})",
nullptr,
};
RunParserSyncTest(empty_context_data, ambiguity_data, kSuccess);
}
TEST(DestructuringAssignmentNegativeTests) {
const char* context_data[][2] = {
{"'use strict'; let x, y, z; (", " = {});"},
{"var x, y, z; (", " = {});"},
{"'use strict'; let x, y, z; for (x in ", " = {});"},
{"'use strict'; let x, y, z; for (x of ", " = {});"},
{"var x, y, z; for (x in ", " = {});"},
{"var x, y, z; for (x of ", " = {});"},
{nullptr, nullptr}};
// clang-format off
const char* data[] = {
"{ x : ++y }",
"{ x : y * 2 }",
"{ get x() {} }",
"{ set x() {} }",
"{ x: y() }",
"{ this }",
"{ x: this }",
"{ x: this = 1 }",
"{ super }",
"{ x: super }",
"{ x: super = 1 }",
"{ new.target }",
"{ x: new.target }",
"{ x: new.target = 1 }",
"{ import.meta }",
"{ x: import.meta }",
"{ x: import.meta = 1 }",
"[x--]",
"[--x = 1]",
"[x()]",
"[this]",
"[this = 1]",
"[new.target]",
"[new.target = 1]",
"[import.meta]",
"[import.meta = 1]",
"[super]",
"[super = 1]",
"[function f() {}]",
"[async function f() {}]",
"[function* f() {}]",
"[50]",
"[(50)]",
"[(function() {})]",
"[(async function() {})]",
"[(function*() {})]",
"[(foo())]",
"{ x: 50 }",
"{ x: (50) }",
"['str']",
"{ x: 'str' }",
"{ x: ('str') }",
"{ x: (foo()) }",
"{ x: function() {} }",
"{ x: async function() {} }",
"{ x: function*() {} }",
"{ x: (function() {}) }",
"{ x: (async function() {}) }",
"{ x: (function*() {}) }",
"{ x: y } = 'str'",
"[x, y] = 'str'",
"[(x,y) => z]",
"[async(x,y) => z]",
"[async x => z]",
"{x: (y) => z}",
"{x: (y,w) => z}",
"{x: async (y) => z}",
"{x: async (y,w) => z}",
"[x, ...y, z]",
"[...x,]",
"[x, y, ...z = 1]",
"[...z = 1]",
"[x, y, ...[z] = [1]]",
"[...[z] = [1]]",
"[...++x]",
"[...x--]",
"[...!x]",
"[...x + y]",
// v8:4657
"({ x: x4, x: (x+=1e4) })",
"(({ x: x4, x: (x+=1e4) }))",
"({ x: x4, x: (x+=1e4) } = {})",
"(({ x: x4, x: (x+=1e4) } = {}))",
"(({ x: x4, x: (x+=1e4) }) = {})",
"({ x: y } = {})",
"(({ x: y } = {}))",
"(({ x: y }) = {})",
"([a])",
"(([a]))",
"([a] = [])",
"(([a] = []))",
"(([a]) = [])",
// v8:4662
"{ x: ([y]) }",
"{ x: ([y] = []) }",
"{ x: ({y}) }",
"{ x: ({y} = {}) }",
"{ x: (++y) }",
"[ (...[a]) ]",
"[ ...([a]) ]",
"[ ...([a] = [])",
"[ ...[ ( [ a ] ) ] ]",
"[ ([a]) ]",
"[ (...[a]) ]",
"[ ([a] = []) ]",
"[ (++y) ]",
"[ ...(++y) ]",
"[ x += x ]",
"{ foo: x += x }",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kError);
const char* empty_context_data[][2] = {
{"'use strict';", ""}, {"", ""}, {nullptr, nullptr}};
// CoverInitializedName ambiguity handling in various contexts
const char* ambiguity_data[] = {
"var foo = { x = 10 };", "var foo = { q } = { x = 10 };",
"var foo; foo = { x = 10 };", "var foo; foo = { q } = { x = 10 };",
"var x; ({ x = 10 });", "var q, x; ({ q } = { x = 10 });",
"var x; [{ x = 10 }]", "var x; (true ? { x = true } : { x = false })",
"var q, x; (q, { x = 10 });", "var { x = 10 } = { x = 20 };",
"var { x = 10 } = (o = { x = 20 });",
"var x; (({ x = 10 } = { x = 20 }) => x)({})",
// Not ambiguous, but uses same context data
"switch([window %= []] = []) { default: }",
nullptr,
};
RunParserSyncTest(empty_context_data, ambiguity_data, kError);
// Strict mode errors
const char* strict_context_data[][2] = {{"'use strict'; (", " = {})"},
{"'use strict'; for (", " of {}) {}"},
{"'use strict'; for (", " in {}) {}"},
{nullptr, nullptr}};
const char* strict_data[] = {
"{ eval }", "{ arguments }", "{ foo: eval }", "{ foo: arguments }",
"{ eval = 0 }", "{ arguments = 0 }", "{ foo: eval = 0 }",
"{ foo: arguments = 0 }", "[ eval ]", "[ arguments ]", "[ eval = 0 ]",
"[ arguments = 0 ]",
// v8:4662
"{ x: (eval) }", "{ x: (arguments) }", "{ x: (eval = 0) }",
"{ x: (arguments = 0) }", "{ x: (eval) = 0 }", "{ x: (arguments) = 0 }",
"[ (eval) ]", "[ (arguments) ]", "[ (eval = 0) ]", "[ (arguments = 0) ]",
"[ (eval) = 0 ]", "[ (arguments) = 0 ]", "[ ...(eval) ]",
"[ ...(arguments) ]", "[ ...(eval = 0) ]", "[ ...(arguments = 0) ]",
"[ ...(eval) = 0 ]", "[ ...(arguments) = 0 ]",
nullptr};
RunParserSyncTest(strict_context_data, strict_data, kError);
}
TEST(DestructuringDisallowPatternsInForVarIn) {
const char* context_data[][2] = {
{"", ""}, {"function f() {", "}"}, {nullptr, nullptr}};
// clang-format off
const char* error_data[] = {
"for (let x = {} in null);",
"for (let x = {} of null);",
nullptr};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
// clang-format off
const char* success_data[] = {
"for (var x = {} in null);",
nullptr};
// clang-format on
RunParserSyncTest(context_data, success_data, kSuccess);
}
TEST(DestructuringDuplicateParams) {
const char* context_data[][2] = {{"'use strict';", ""},
{"function outer() { 'use strict';", "}"},
{nullptr, nullptr}};
// clang-format off
const char* error_data[] = {
"function f(x,x){}",
"function f(x, {x : x}){}",
"function f(x, {x}){}",
"function f({x,x}) {}",
"function f([x,x]) {}",
"function f(x, [y,{z:x}]) {}",
"function f([x,{y:x}]) {}",
// non-simple parameter list causes duplicates to be errors in sloppy mode.
"function f(x, x, {a}) {}",
nullptr};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
}
TEST(DestructuringDuplicateParamsSloppy) {
const char* context_data[][2] = {
{"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}};
// clang-format off
const char* error_data[] = {
// non-simple parameter list causes duplicates to be errors in sloppy mode.
"function f(x, {x : x}){}",
"function f(x, {x}){}",
"function f({x,x}) {}",
"function f(x, x, {a}) {}",
nullptr};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
}
TEST(DestructuringDisallowPatternsInSingleParamArrows) {
const char* context_data[][2] = {{"'use strict';", ""},
{"function outer() { 'use strict';", "}"},
{"", ""},
{"function outer() { ", "}"},
{nullptr, nullptr}};
// clang-format off
const char* error_data[] = {
"var f = {x} => {};",
"var f = {x,y} => {};",
nullptr};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
}
TEST(DefaultParametersYieldInInitializers) {
// clang-format off
const char* sloppy_function_context_data[][2] = {
{"(function f(", ") { });"},
{nullptr, nullptr}
};
const char* strict_function_context_data[][2] = {
{"'use strict'; (function f(", ") { });"},
{nullptr, nullptr}
};
const char* sloppy_arrow_context_data[][2] = {
{"((", ")=>{});"},
{nullptr, nullptr}
};
const char* strict_arrow_context_data[][2] = {
{"'use strict'; ((", ")=>{});"},
{nullptr, nullptr}
};
const char* generator_context_data[][2] = {
{"'use strict'; (function *g(", ") { });"},
{"(function *g(", ") { });"},
// Arrow function within generator has the same rules.
{"'use strict'; (function *g() { (", ") => {} });"},
{"(function *g() { (", ") => {} });"},
// And similarly for arrow functions in the parameter list.
{"'use strict'; (function *g(z = (", ") => {}) { });"},
{"(function *g(z = (", ") => {}) { });"},
{nullptr, nullptr}
};
const char* parameter_data[] = {
"x=yield",
"x, y=yield",
"{x=yield}",
"[x=yield]",
"x=(yield)",
"x, y=(yield)",
"{x=(yield)}",
"[x=(yield)]",
"x=f(yield)",
"x, y=f(yield)",
"{x=f(yield)}",
"[x=f(yield)]",
"{x}=yield",
"[x]=yield",
"{x}=(yield)",
"[x]=(yield)",
"{x}=f(yield)",
"[x]=f(yield)",
nullptr
};
// Because classes are always in strict mode, these are always errors.
const char* always_error_param_data[] = {
"x = class extends (yield) { }",
"x = class extends f(yield) { }",
"x = class extends (null, yield) { }",
"x = class extends (a ? null : yield) { }",
"[x] = [class extends (a ? null : yield) { }]",
"[x = class extends (a ? null : yield) { }]",
"[x = class extends (a ? null : yield) { }] = [null]",
"x = class { [yield]() { } }",
"x = class { static [yield]() { } }",
"x = class { [(yield, 1)]() { } }",
"x = class { [y = (yield, 1)]() { } }",
nullptr
};
// clang-format on
RunParserSyncTest(sloppy_function_context_data, parameter_data, kSuccess);
RunParserSyncTest(sloppy_arrow_context_data, parameter_data, kSuccess);
RunParserSyncTest(strict_function_context_data, parameter_data, kError);
RunParserSyncTest(strict_arrow_context_data, parameter_data, kError);
RunParserSyncTest(generator_context_data, parameter_data, kError);
RunParserSyncTest(generator_context_data, always_error_param_data, kError);
}
TEST(SpreadArray) {
const char* context_data[][2] = {
{"'use strict';", ""}, {"", ""}, {nullptr, nullptr}};
// clang-format off
const char* data[] = {
"[...a]",
"[a, ...b]",
"[...a,]",
"[...a, ,]",
"[, ...a]",
"[...a, ...b]",
"[...a, , ...b]",
"[...[...a]]",
"[, ...a]",
"[, , ...a]",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(SpreadArrayError) {
const char* context_data[][2] = {
{"'use strict';", ""}, {"", ""}, {nullptr, nullptr}};
// clang-format off
const char* data[] = {
"[...]",
"[a, ...]",
"[..., ]",
"[..., ...]",
"[ (...a)]",
nullptr};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
TEST(NewTarget) {
// clang-format off
const char* good_context_data[][2] = {
{"function f() {", "}"},
{"'use strict'; function f() {", "}"},
{"var f = function() {", "}"},
{"'use strict'; var f = function() {", "}"},
{"({m: function() {", "}})"},
{"'use strict'; ({m: function() {", "}})"},
{"({m() {", "}})"},
{"'use strict'; ({m() {", "}})"},
{"({get x() {", "}})"},
{"'use strict'; ({get x() {", "}})"},
{"({set x(_) {", "}})"},
{"'use strict'; ({set x(_) {", "}})"},
{"class C {m() {", "}}"},
{"class C {get x() {", "}}"},
{"class C {set x(_) {", "}}"},
{nullptr}
};
const char* bad_context_data[][2] = {
{"", ""},
{"'use strict';", ""},
{nullptr}
};
const char* data[] = {
"new.target",
"{ new.target }",
"() => { new.target }",
"() => new.target",
"if (1) { new.target }",
"if (1) {} else { new.target }",
"while (0) { new.target }",
"do { new.target } while (0)",
nullptr
};
// clang-format on
RunParserSyncTest(good_context_data, data, kSuccess);
RunParserSyncTest(bad_context_data, data, kError);
}
TEST(ImportMetaSuccess) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"'use strict';", ""},
{"function f() {", "}"},
{"'use strict'; function f() {", "}"},
{"var f = function() {", "}"},
{"'use strict'; var f = function() {", "}"},
{"({m: function() {", "}})"},
{"'use strict'; ({m: function() {", "}})"},
{"({m() {", "}})"},
{"'use strict'; ({m() {", "}})"},
{"({get x() {", "}})"},
{"'use strict'; ({get x() {", "}})"},
{"({set x(_) {", "}})"},
{"'use strict'; ({set x(_) {", "}})"},
{"class C {m() {", "}}"},
{"class C {get x() {", "}}"},
{"class C {set x(_) {", "}}"},
{nullptr}
};
const char* data[] = {
"import.meta",
"() => { import.meta }",
"() => import.meta",
"if (1) { import.meta }",
"if (1) {} else { import.meta }",
"while (0) { import.meta }",
"do { import.meta } while (0)",
"import.meta.url",
"import.meta[0]",
"import.meta.couldBeMutable = true",
"import.meta()",
"new import.meta.MagicClass",
"new import.meta",
"t = [...import.meta]",
"f = {...import.meta}",
"delete import.meta",
nullptr
};
// clang-format on
// 2.1.1 Static Semantics: Early Errors
// ImportMeta
// * It is an early Syntax Error if Module is not the syntactic goal symbol.
RunParserSyncTest(context_data, data, kError);
RunModuleParserSyncTest(context_data, data, kSuccess);
}
TEST(ImportMetaFailure) {
// clang-format off
const char* context_data[][2] = {
{"var ", ""},
{"let ", ""},
{"const ", ""},
{"var [", "] = [1]"},
{"([", "] = [1])"},
{"({", "} = {1})"},
{"var {", " = 1} = 1"},
{"for (var ", " of [1]) {}"},
{"(", ") => {}"},
{"let f = ", " => {}"},
{nullptr}
};
const char* data[] = {
"import.meta",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
RunModuleParserSyncTest(context_data, data, kError);
}
TEST(ConstSloppy) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"{", "}"},
{nullptr, nullptr}
};
const char* data[] = {
"const x = 1",
"for (const x = 1; x < 1; x++) {}",
"for (const x in {}) {}",
"for (const x of []) {}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(LetSloppy) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"'use strict';", ""},
{"{", "}"},
{nullptr, nullptr}
};
const char* data[] = {
"let x",
"let x = 1",
"for (let x = 1; x < 1; x++) {}",
"for (let x in {}) {}",
"for (let x of []) {}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(LanguageModeDirectivesNonSimpleParameterListErrors) {
// TC39 deemed "use strict" directives to be an error when occurring in the
// body of a function with non-simple parameter list, on 29/7/2015.
// https://goo.gl/ueA7Ln
const char* context_data[][2] = {
{"function f(", ") { 'use strict'; }"},
{"function* g(", ") { 'use strict'; }"},
{"class c { foo(", ") { 'use strict' }"},
{"var a = (", ") => { 'use strict'; }"},
{"var o = { m(", ") { 'use strict'; }"},
{"var o = { *gm(", ") { 'use strict'; }"},
{"var c = { m(", ") { 'use strict'; }"},
{"var c = { *gm(", ") { 'use strict'; }"},
{"'use strict'; function f(", ") { 'use strict'; }"},
{"'use strict'; function* g(", ") { 'use strict'; }"},
{"'use strict'; class c { foo(", ") { 'use strict' }"},
{"'use strict'; var a = (", ") => { 'use strict'; }"},
{"'use strict'; var o = { m(", ") { 'use strict'; }"},
{"'use strict'; var o = { *gm(", ") { 'use strict'; }"},
{"'use strict'; var c = { m(", ") { 'use strict'; }"},
{"'use strict'; var c = { *gm(", ") { 'use strict'; }"},
{nullptr, nullptr}};
const char* data[] = {
// TODO(@caitp): support formal parameter initializers
"{}",
"[]",
"[{}]",
"{a}",
"a, {b}",
"a, b, {c, d, e}",
"initializer = true",
"a, b, c = 1",
"...args",
"a, b, ...rest",
"[a, b, ...rest]",
"{ bindingPattern = {} }",
"{ initializedBindingPattern } = { initializedBindingPattern: true }",
nullptr};
RunParserSyncTest(context_data, data, kError);
}
TEST(LetSloppyOnly) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
{"{", "}"},
{"(function() {", "})()"},
{nullptr, nullptr}
};
const char* data[] = {
"let",
"let = 1",
"for (let = 1; let < 1; let++) {}",
"for (let in {}) {}",
"for (var let = 1; let < 1; let++) {}",
"for (var let in {}) {}",
"for (var [let] = 1; let < 1; let++) {}",
"for (var [let] in {}) {}",
"var let",
"var [let] = []",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
// Some things should be rejected even in sloppy mode
// This addresses BUG(v8:4403).
// clang-format off
const char* fail_data[] = {
"let let = 1",
"for (let let = 1; let < 1; let++) {}",
"for (let let in {}) {}",
"for (let let of []) {}",
"const let = 1",
"for (const let = 1; let < 1; let++) {}",
"for (const let in {}) {}",
"for (const let of []) {}",
"let [let] = 1",
"for (let [let] = 1; let < 1; let++) {}",
"for (let [let] in {}) {}",
"for (let [let] of []) {}",
"const [let] = 1",
"for (const [let] = 1; let < 1; let++) {}",
"for (const [let] in {}) {}",
"for (const [let] of []) {}",
// Sprinkle in the escaped version too.
"let l\\u0065t = 1",
"const l\\u0065t = 1",
"let [l\\u0065t] = 1",
"const [l\\u0065t] = 1",
"for (let l\\u0065t in {}) {}",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, fail_data, kError);
}
TEST(EscapedKeywords) {
// clang-format off
const char* sloppy_context_data[][2] = {
{"", ""},
{nullptr, nullptr}
};
const char* strict_context_data[][2] = {
{"'use strict';", ""},
{nullptr, nullptr}
};
const char* fail_data[] = {
"for (var i = 0; i < 100; ++i) { br\\u0065ak; }",
"cl\\u0061ss Foo {}",
"var x = cl\\u0061ss {}",
"\\u0063onst foo = 1;",
"while (i < 10) { if (i++ & 1) c\\u006fntinue; this.x++; }",
"d\\u0065bugger;",
"d\\u0065lete this.a;",
"\\u0063o { } while(0)",
"if (d\\u006f { true }) {}",
"if (false) { this.a = 1; } \\u0065lse { this.b = 1; }",
"e\\u0078port var foo;",
"try { } catch (e) {} f\\u0069nally { }",
"f\\u006fr (var i = 0; i < 10; ++i);",
"f\\u0075nction fn() {}",
"var f = f\\u0075nction() {}",
"\\u0069f (true) { }",
"\\u0069mport blah from './foo.js';",
"n\\u0065w function f() {}",
"(function() { r\\u0065turn; })()",
"class C extends function() {} { constructor() { sup\\u0065r() } }",
"class C extends function() {} { constructor() { sup\\u0065r.a = 1 } }",
"sw\\u0069tch (this.a) {}",
"var x = th\\u0069s;",
"th\\u0069s.a = 1;",
"thr\\u006fw 'boo';",
"t\\u0072y { true } catch (e) {}",
"var x = typ\\u0065of 'blah'",
"v\\u0061r a = true",
"var v\\u0061r = true",
"(function() { return v\\u006fid 0; })()",
"wh\\u0069le (true) { }",
"w\\u0069th (this.scope) { }",
"(function*() { y\\u0069eld 1; })()",
"(function*() { var y\\u0069eld = 1; })()",
"var \\u0065num = 1;",
"var { \\u0065num } = {}",
"(\\u0065num = 1);",
// Null / Boolean literals
"(x === n\\u0075ll);",
"var x = n\\u0075ll;",
"var n\\u0075ll = 1;",
"var { n\\u0075ll } = { 1 };",
"n\\u0075ll = 1;",
"(x === tr\\u0075e);",
"var x = tr\\u0075e;",
"var tr\\u0075e = 1;",
"var { tr\\u0075e } = {};",
"tr\\u0075e = 1;",
"(x === f\\u0061lse);",
"var x = f\\u0061lse;",
"var f\\u0061lse = 1;",
"var { f\\u0061lse } = {};",
"f\\u0061lse = 1;",
// TODO(caitp): consistent error messages for labeled statements and
// expressions
"switch (this.a) { c\\u0061se 6: break; }",
"try { } c\\u0061tch (e) {}",
"switch (this.a) { d\\u0065fault: break; }",
"class C \\u0065xtends function B() {} {}",
"for (var a i\\u006e this) {}",
"if ('foo' \\u0069n this) {}",
"if (this \\u0069nstanceof Array) {}",
"(n\\u0065w function f() {})",
"(typ\\u0065of 123)",
"(v\\u006fid 0)",
"do { ; } wh\\u0069le (true) { }",
"(function*() { return (n++, y\\u0069eld 1); })()",
"class C { st\\u0061tic bar() {} }",
"class C { st\\u0061tic *bar() {} }",
"class C { st\\u0061tic get bar() {} }",
"class C { st\\u0061tic set bar() {} }",
"(async ()=>{\\u0061wait 100})()",
"({\\u0067et get(){}})",
"({\\u0073et set(){}})",
"(async ()=>{var \\u0061wait = 100})()",
nullptr
};
// clang-format on
RunParserSyncTest(sloppy_context_data, fail_data, kError);
RunParserSyncTest(strict_context_data, fail_data, kError);
RunModuleParserSyncTest(sloppy_context_data, fail_data, kError);
// clang-format off
const char* let_data[] = {
"var l\\u0065t = 1;",
"l\\u0065t = 1;",
"(l\\u0065t === 1);",
"(y\\u0069eld);",
"var y\\u0069eld = 1;",
"var { y\\u0069eld } = {};",
nullptr
};
// clang-format on
RunParserSyncTest(sloppy_context_data, let_data, kSuccess);
RunParserSyncTest(strict_context_data, let_data, kError);
// Non-errors in sloppy mode
const char* valid_data[] = {"(\\u0069mplements = 1);",
"var impl\\u0065ments = 1;",
"var { impl\\u0065ments } = {};",
"(\\u0069nterface = 1);",
"var int\\u0065rface = 1;",
"var { int\\u0065rface } = {};",
"(p\\u0061ckage = 1);",
"var packa\\u0067e = 1;",
"var { packa\\u0067e } = {};",
"(p\\u0072ivate = 1);",
"var p\\u0072ivate;",
"var { p\\u0072ivate } = {};",
"(prot\\u0065cted);",
"var prot\\u0065cted = 1;",
"var { prot\\u0065cted } = {};",
"(publ\\u0069c);",
"var publ\\u0069c = 1;",
"var { publ\\u0069c } = {};",
"(st\\u0061tic);",
"var st\\u0061tic = 1;",
"var { st\\u0061tic } = {};",
nullptr};
RunParserSyncTest(sloppy_context_data, valid_data, kSuccess);
RunParserSyncTest(strict_context_data, valid_data, kError);
RunModuleParserSyncTest(strict_context_data, valid_data, kError);
}
TEST(MiscSyntaxErrors) {
// clang-format off
const char* context_data[][2] = {
{ "'use strict'", "" },
{ "", "" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"for (();;) {}",
// crbug.com/582626
"{ NaN ,chA((evarA=new t ( l = !.0[((... co -a0([1]))=> greturnkf",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
}
TEST(EscapeSequenceErrors) {
// clang-format off
const char* context_data[][2] = {
{ "'", "'" },
{ "\"", "\"" },
{ "`", "`" },
{ "`${'", "'}`" },
{ "`${\"", "\"}`" },
{ "`${`", "`}`" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"\\uABCG",
"\\u{ZZ}",
"\\u{FFZ}",
"\\u{FFFFFFFFFF }",
"\\u{110000}",
"\\u{110000",
"\\u{FFFD }",
"\\xZF",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
}
TEST(NewTargetErrors) {
// clang-format off
const char* context_data[][2] = {
{ "'use strict'", "" },
{ "", "" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"var x = new.target",
"function f() { return new.t\\u0061rget; }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
}
TEST(FunctionDeclarationError) {
// clang-format off
const char* strict_context[][2] = {
{ "'use strict';", "" },
{ "'use strict'; { ", "}" },
{"(function() { 'use strict';", "})()"},
{"(function() { 'use strict'; {", "} })()"},
{ nullptr, nullptr }
};
const char* sloppy_context[][2] = {
{ "", "" },
{ "{", "}" },
{"(function() {", "})()"},
{"(function() { {", "} })()"},
{ nullptr, nullptr }
};
// Invalid in all contexts
const char* error_data[] = {
"try function foo() {} catch (e) {}",
"do function foo() {} while (0);",
"for (;false;) function foo() {}",
"for (var i = 0; i < 1; i++) function f() { };",
"for (var x in {a: 1}) function f() { };",
"for (var x in {}) function f() { };",
"for (var x in {}) function foo() {}",
"for (x in {a: 1}) function f() { };",
"for (x in {}) function f() { };",
"var x; for (x in {}) function foo() {}",
"with ({}) function f() { };",
"do label: function foo() {} while (0);",
"for (;false;) label: function foo() {}",
"for (var i = 0; i < 1; i++) label: function f() { };",
"for (var x in {a: 1}) label: function f() { };",
"for (var x in {}) label: function f() { };",
"for (var x in {}) label: function foo() {}",
"for (x in {a: 1}) label: function f() { };",
"for (x in {}) label: function f() { };",
"var x; for (x in {}) label: function foo() {}",
"with ({}) label: function f() { };",
"if (true) label: function f() {}",
"if (true) {} else label: function f() {}",
"if (true) function* f() { }",
"label: function* f() { }",
"if (true) async function f() { }",
"label: async function f() { }",
"if (true) async function* f() { }",
"label: async function* f() { }",
nullptr
};
// Valid only in sloppy mode.
const char* sloppy_data[] = {
"if (true) function foo() {}",
"if (false) {} else function f() { };",
"label: function f() { }",
"label: if (true) function f() { }",
"label: if (true) {} else function f() { }",
"label: label2: function f() { }",
nullptr
};
// clang-format on
// Nothing parses in strict mode without a SyntaxError
RunParserSyncTest(strict_context, error_data, kError);
RunParserSyncTest(strict_context, sloppy_data, kError);
// In sloppy mode, sloppy_data is successful
RunParserSyncTest(sloppy_context, error_data, kError);
RunParserSyncTest(sloppy_context, sloppy_data, kSuccess);
}
TEST(ExponentiationOperator) {
// clang-format off
const char* context_data[][2] = {
{ "var O = { p: 1 }, x = 10; ; if (", ") { foo(); }" },
{ "var O = { p: 1 }, x = 10; ; (", ")" },
{ "var O = { p: 1 }, x = 10; foo(", ")" },
{ nullptr, nullptr }
};
const char* data[] = {
"(delete O.p) ** 10",
"(delete x) ** 10",
"(~O.p) ** 10",
"(~x) ** 10",
"(!O.p) ** 10",
"(!x) ** 10",
"(+O.p) ** 10",
"(+x) ** 10",
"(-O.p) ** 10",
"(-x) ** 10",
"(typeof O.p) ** 10",
"(typeof x) ** 10",
"(void 0) ** 10",
"(void O.p) ** 10",
"(void x) ** 10",
"++O.p ** 10",
"++x ** 10",
"--O.p ** 10",
"--x ** 10",
"O.p++ ** 10",
"x++ ** 10",
"O.p-- ** 10",
"x-- ** 10",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(ExponentiationOperatorErrors) {
// clang-format off
const char* context_data[][2] = {
{ "var O = { p: 1 }, x = 10; ; if (", ") { foo(); }" },
{ "var O = { p: 1 }, x = 10; ; (", ")" },
{ "var O = { p: 1 }, x = 10; foo(", ")" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"delete O.p ** 10",
"delete x ** 10",
"~O.p ** 10",
"~x ** 10",
"!O.p ** 10",
"!x ** 10",
"+O.p ** 10",
"+x ** 10",
"-O.p ** 10",
"-x ** 10",
"typeof O.p ** 10",
"typeof x ** 10",
"void ** 10",
"void O.p ** 10",
"void x ** 10",
"++delete O.p ** 10",
"--delete O.p ** 10",
"++~O.p ** 10",
"++~x ** 10",
"--!O.p ** 10",
"--!x ** 10",
"++-O.p ** 10",
"++-x ** 10",
"--+O.p ** 10",
"--+x ** 10",
"[ x ] **= [ 2 ]",
"[ x **= 2 ] = [ 2 ]",
"{ x } **= { x: 2 }",
"{ x: x **= 2 ] = { x: 2 }",
// TODO(caitp): a Call expression as LHS should be an early ReferenceError!
// "Array() **= 10",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
}
TEST(AsyncAwait) {
// clang-format off
const char* context_data[][2] = {
{ "'use strict';", "" },
{ "", "" },
{ nullptr, nullptr }
};
const char* data[] = {
"var asyncFn = async function() { await 1; };",
"var asyncFn = async function withName() { await 1; };",
"var asyncFn = async () => await 'test';",
"var asyncFn = async x => await x + 'test';",
"async function asyncFn() { await 1; }",
"var O = { async method() { await 1; } }",
"var O = { async ['meth' + 'od']() { await 1; } }",
"var O = { async 'method'() { await 1; } }",
"var O = { async 0() { await 1; } }",
"async function await() {}",
"var asyncFn = async({ foo = 1 }) => foo;",
"var asyncFn = async({ foo = 1 } = {}) => foo;",
"function* g() { var f = async(yield); }",
"function* g() { var f = async(x = yield); }",
// v8:7817 assert that `await` is still allowed in the body of an arrow fn
// within formal parameters
"async(a = a => { var await = 1; return 1; }) => a()",
"async(a = await => 1); async(a) => 1",
"(async(a = await => 1), async(a) => 1)",
"async(a = await => 1, b = async() => 1);",
"async (x = class { p = await }) => {};",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
// clang-format off
const char* async_body_context_data[][2] = {
{ "async function f() {", "}" },
{ "var f = async function() {", "}" },
{ "var f = async() => {", "}" },
{ "var O = { async method() {", "} }" },
{ "'use strict'; async function f() {", "}" },
{ "'use strict'; var f = async function() {", "}" },
{ "'use strict'; var f = async() => {", "}" },
{ "'use strict'; var O = { async method() {", "} }" },
{ nullptr, nullptr }
};
const char* body_context_data[][2] = {
{ "function f() {", "}" },
{ "function* g() {", "}" },
{ "var f = function() {", "}" },
{ "var g = function*() {", "}" },
{ "var O = { method() {", "} }" },
{ "var O = { *method() {", "} }" },
{ "var f = () => {", "}" },
{ "'use strict'; function f() {", "}" },
{ "'use strict'; function* g() {", "}" },
{ "'use strict'; var f = function() {", "}" },
{ "'use strict'; var g = function*() {", "}" },
{ "'use strict'; var O = { method() {", "} }" },
{ "'use strict'; var O = { *method() {", "} }" },
{ "'use strict'; var f = () => {", "}" },
{ nullptr, nullptr }
};
const char* body_data[] = {
"var async = 1; return async;",
"let async = 1; return async;",
"const async = 1; return async;",
"function async() {} return async();",
"var async = async => async; return async();",
"function foo() { var await = 1; return await; }",
"function foo(await) { return await; }",
"function* foo() { var await = 1; return await; }",
"function* foo(await) { return await; }",
"var f = () => { var await = 1; return await; }",
"var O = { method() { var await = 1; return await; } };",
"var O = { method(await) { return await; } };",
"var O = { *method() { var await = 1; return await; } };",
"var O = { *method(await) { return await; } };",
"var asyncFn = async function*() {}",
"async function* f() {}",
"var O = { async *method() {} };",
"(function await() {})",
nullptr
};
// clang-format on
RunParserSyncTest(async_body_context_data, body_data, kSuccess);
RunParserSyncTest(body_context_data, body_data, kSuccess);
}
TEST(AsyncAwaitErrors) {
// clang-format off
const char* context_data[][2] = {
{ "'use strict';", "" },
{ "", "" },
{ nullptr, nullptr }
};
const char* strict_context_data[][2] = {
{ "'use strict';", "" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"var asyncFn = async function await() {};",
"var asyncFn = async () => var await = 'test';",
"var asyncFn = async await => await + 'test';",
"var asyncFn = async function(await) {};",
"var asyncFn = async (await) => 'test';",
"async function f(await) {}",
"var O = { async method(a, a) {} }",
"var O = { async ['meth' + 'od'](a, a) {} }",
"var O = { async 'method'(a, a) {} }",
"var O = { async 0(a, a) {} }",
"var f = async() => await;",
"var O = { *async method() {} };",
"var O = { async method*() {} };",
"var asyncFn = async function(x = await 1) { return x; }",
"async function f(x = await 1) { return x; }",
"var f = async(x = await 1) => x;",
"var O = { async method(x = await 1) { return x; } };",
"function* g() { var f = async yield => 1; }",
"function* g() { var f = async(yield) => 1; }",
"function* g() { var f = async(x = yield) => 1; }",
"function* g() { var f = async({x = yield}) => 1; }",
"class C { async constructor() {} }",
"class C {}; class C2 extends C { async constructor() {} }",
"class C { static async prototype() {} }",
"class C {}; class C2 extends C { static async prototype() {} }",
"var f = async() => ((async(x = await 1) => x)();",
// Henrique Ferreiro's bug (tm)
"(async function foo1() { } foo2 => 1)",
"(async function foo3() { } () => 1)",
"(async function foo4() { } => 1)",
"(async function() { } foo5 => 1)",
"(async function() { } () => 1)",
"(async function() { } => 1)",
"(async.foo6 => 1)",
"(async.foo7 foo8 => 1)",
"(async.foo9 () => 1)",
"(async().foo10 => 1)",
"(async().foo11 foo12 => 1)",
"(async().foo13 () => 1)",
"(async['foo14'] => 1)",
"(async['foo15'] foo16 => 1)",
"(async['foo17'] () => 1)",
"(async()['foo18'] => 1)",
"(async()['foo19'] foo20 => 1)",
"(async()['foo21'] () => 1)",
"(async`foo22` => 1)",
"(async`foo23` foo24 => 1)",
"(async`foo25` () => 1)",
"(async`foo26`.bar27 => 1)",
"(async`foo28`.bar29 foo30 => 1)",
"(async`foo31`.bar32 () => 1)",
// v8:5148 assert that errors are still thrown for calls that may have been
// async functions
"async({ foo33 = 1 })",
"async(...a = b) => b",
"async(...a,) => b",
"async(...a, b) => b",
// v8:7817 assert that `await` is an invalid identifier in arrow formal
// parameters nested within an async arrow function
"async(a = await => 1) => a",
"async(a = (await) => 1) => a",
"async(a = (...await) => 1) => a",
nullptr
};
const char* strict_error_data[] = {
"var O = { async method(eval) {} }",
"var O = { async ['meth' + 'od'](eval) {} }",
"var O = { async 'method'(eval) {} }",
"var O = { async 0(eval) {} }",
"var O = { async method(arguments) {} }",
"var O = { async ['meth' + 'od'](arguments) {} }",
"var O = { async 'method'(arguments) {} }",
"var O = { async 0(arguments) {} }",
"var O = { async method(dupe, dupe) {} }",
// TODO(caitp): preparser needs to report duplicate parameter errors, too.
// "var f = async(dupe, dupe) => {}",
nullptr
};
RunParserSyncTest(context_data, error_data, kError);
RunParserSyncTest(strict_context_data, strict_error_data, kError);
// clang-format off
const char* async_body_context_data[][2] = {
{ "async function f() {", "}" },
{ "var f = async function() {", "}" },
{ "var f = async() => {", "}" },
{ "var O = { async method() {", "} }" },
{ "'use strict'; async function f() {", "}" },
{ "'use strict'; var f = async function() {", "}" },
{ "'use strict'; var f = async() => {", "}" },
{ "'use strict'; var O = { async method() {", "} }" },
{ nullptr, nullptr }
};
const char* async_body_error_data[] = {
"var await = 1;",
"var { await } = 1;",
"var [ await ] = 1;",
"return async (await) => {};",
"var O = { async [await](a, a) {} }",
"await;",
"function await() {}",
"var f = await => 42;",
"var f = (await) => 42;",
"var f = (await, a) => 42;",
"var f = (...await) => 42;",
"var e = (await);",
"var e = (await, f);",
"var e = (await = 42)",
"var e = [await];",
"var e = {await};",
nullptr
};
// clang-format on
RunParserSyncTest(async_body_context_data, async_body_error_data, kError);
}
TEST(Regress7173) {
// Await expression is an invalid destructuring target, and should not crash
// clang-format off
const char* error_context_data[][2] = {
{ "'use strict'; async function f() {", "}" },
{ "async function f() {", "}" },
{ "'use strict'; function f() {", "}" },
{ "function f() {", "}" },
{ "let f = async() => {", "}" },
{ "let f = () => {", "}" },
{ "'use strict'; async function* f() {", "}" },
{ "async function* f() {", "}" },
{ "'use strict'; function* f() {", "}" },
{ "function* f() {", "}" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"var [await f] = [];",
"let [await f] = [];",
"const [await f] = [];",
"var [...await f] = [];",
"let [...await f] = [];",
"const [...await f] = [];",
"var { await f } = {};",
"let { await f } = {};",
"const { await f } = {};",
"var { ...await f } = {};",
"let { ...await f } = {};",
"const { ...await f } = {};",
"var { f: await f } = {};",
"let { f: await f } = {};",
"const { f: await f } = {};"
"var { f: ...await f } = {};",
"let { f: ...await f } = {};",
"const { f: ...await f } = {};"
"var { [f]: await f } = {};",
"let { [f]: await f } = {};",
"const { [f]: await f } = {};",
"var { [f]: ...await f } = {};",
"let { [f]: ...await f } = {};",
"const { [f]: ...await f } = {};",
nullptr
};
// clang-format on
RunParserSyncTest(error_context_data, error_data, kError);
}
TEST(AsyncAwaitFormalParameters) {
// clang-format off
const char* context_for_formal_parameters[][2] = {
{ "async function f(", ") {}" },
{ "var f = async function f(", ") {}" },
{ "var f = async(", ") => {}" },
{ "'use strict'; async function f(", ") {}" },
{ "'use strict'; var f = async function f(", ") {}" },
{ "'use strict'; var f = async(", ") => {}" },
{ nullptr, nullptr }
};
const char* good_formal_parameters[] = {
"x = function await() {}",
"x = function *await() {}",
"x = function() { let await = 0; }",
"x = () => { let await = 0; }",
nullptr
};
const char* bad_formal_parameters[] = {
"{ await }",
"{ await = 1 }",
"{ await } = {}",
"{ await = 1 } = {}",
"[await]",
"[await] = []",
"[await = 1]",
"[await = 1] = []",
"...await",
"await",
"await = 1",
"...[await]",
"x = await",
// v8:5190
"1) => 1",
"'str') => 1",
"/foo/) => 1",
"{ foo = async(1) => 1 }) => 1",
"{ foo = async(a) => 1 })",
"x = async(await)",
"x = { [await]: 1 }",
"x = class extends (await) { }",
"x = class { static [await]() {} }",
"{ x = await }",
// v8:6714
"x = class await {}",
"x = 1 ? class await {} : 0",
"x = async function await() {}",
"x = y[await]",
"x = `${await}`",
"x = y()[await]",
nullptr
};
// clang-format on
RunParserSyncTest(context_for_formal_parameters, good_formal_parameters,
kSuccess);
RunParserSyncTest(context_for_formal_parameters, bad_formal_parameters,
kError);
}
TEST(AsyncAwaitModule) {
// clang-format off
const char* context_data[][2] = {
{ "", "" },
{ nullptr, nullptr }
};
const char* data[] = {
"export default async function() { await 1; }",
"export default async function async() { await 1; }",
"export async function async() { await 1; }",
nullptr
};
// clang-format on
RunModuleParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0,
nullptr, 0, false);
}
TEST(AsyncAwaitModuleErrors) {
// clang-format off
const char* context_data[][2] = {
{ "", "" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"export default (async function await() {})",
"export default async function await() {}",
"export async function await() {}",
"export async function() {}",
"export async",
"export async\nfunction async() { await 1; }",
nullptr
};
// clang-format on
RunModuleParserSyncTest(context_data, error_data, kError, nullptr, 0, nullptr,
0, nullptr, 0, false);
}
TEST(RestrictiveForInErrors) {
// clang-format off
const char* strict_context_data[][2] = {
{ "'use strict'", "" },
{ nullptr, nullptr }
};
const char* sloppy_context_data[][2] = {
{ "", "" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"for (const x = 0 in {});",
"for (let x = 0 in {});",
nullptr
};
const char* sloppy_data[] = {
"for (var x = 0 in {});",
nullptr
};
// clang-format on
RunParserSyncTest(strict_context_data, error_data, kError);
RunParserSyncTest(strict_context_data, sloppy_data, kError);
RunParserSyncTest(sloppy_context_data, error_data, kError);
RunParserSyncTest(sloppy_context_data, sloppy_data, kSuccess);
}
TEST(NoDuplicateGeneratorsInBlock) {
const char* block_context_data[][2] = {
{"'use strict'; {", "}"},
{"{", "}"},
{"(function() { {", "} })()"},
{"(function() {'use strict'; {", "} })()"},
{nullptr, nullptr}};
const char* top_level_context_data[][2] = {
{"'use strict';", ""},
{"", ""},
{"(function() {", "})()"},
{"(function() {'use strict';", "})()"},
{nullptr, nullptr}};
const char* error_data[] = {"function* x() {} function* x() {}",
"function x() {} function* x() {}",
"function* x() {} function x() {}", nullptr};
// The preparser doesn't enforce the restriction, so turn it off.
bool test_preparser = false;
RunParserSyncTest(block_context_data, error_data, kError, nullptr, 0, nullptr,
0, nullptr, 0, false, test_preparser);
RunParserSyncTest(top_level_context_data, error_data, kSuccess);
}
TEST(NoDuplicateAsyncFunctionInBlock) {
const char* block_context_data[][2] = {
{"'use strict'; {", "}"},
{"{", "}"},
{"(function() { {", "} })()"},
{"(function() {'use strict'; {", "} })()"},
{nullptr, nullptr}};
const char* top_level_context_data[][2] = {
{"'use strict';", ""},
{"", ""},
{"(function() {", "})()"},
{"(function() {'use strict';", "})()"},
{nullptr, nullptr}};
const char* error_data[] = {"async function x() {} async function x() {}",
"function x() {} async function x() {}",
"async function x() {} function x() {}",
"function* x() {} async function x() {}",
"function* x() {} async function x() {}",
"async function x() {} function* x() {}",
"function* x() {} async function x() {}",
nullptr};
// The preparser doesn't enforce the restriction, so turn it off.
bool test_preparser = false;
RunParserSyncTest(block_context_data, error_data, kError, nullptr, 0, nullptr,
0, nullptr, 0, false, test_preparser);
RunParserSyncTest(top_level_context_data, error_data, kSuccess);
}
TEST(TrailingCommasInParameters) {
// clang-format off
const char* context_data[][2] = {
{ "", "" },
{ "'use strict';", "" },
{ "function foo() {", "}" },
{ "function foo() {'use strict';", "}" },
{ nullptr, nullptr }
};
const char* data[] = {
" function a(b,) {}",
" function* a(b,) {}",
"(function a(b,) {});",
"(function* a(b,) {});",
"(function (b,) {});",
"(function* (b,) {});",
" function a(b,c,d,) {}",
" function* a(b,c,d,) {}",
"(function a(b,c,d,) {});",
"(function* a(b,c,d,) {});",
"(function (b,c,d,) {});",
"(function* (b,c,d,) {});",
"(b,) => {};",
"(b,c,d,) => {};",
"a(1,);",
"a(1,2,3,);",
"a(...[],);",
"a(1, 2, ...[],);",
"a(...[], 2, ...[],);",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
TEST(TrailingCommasInParametersErrors) {
// clang-format off
const char* context_data[][2] = {
{ "", "" },
{ "'use strict';", "" },
{ "function foo() {", "}" },
{ "function foo() {'use strict';", "}" },
{ nullptr, nullptr }
};
const char* data[] = {
// too many trailing commas
" function a(b,,) {}",
" function* a(b,,) {}",
"(function a(b,,) {});",
"(function* a(b,,) {});",
"(function (b,,) {});",
"(function* (b,,) {});",
" function a(b,c,d,,) {}",
" function* a(b,c,d,,) {}",
"(function a(b,c,d,,) {});",
"(function* a(b,c,d,,) {});",
"(function (b,c,d,,) {});",
"(function* (b,c,d,,) {});",
"(b,,) => {};",
"(b,c,d,,) => {};",
"a(1,,);",
"a(1,2,3,,);",
// only a trailing comma and no parameters
" function a1(,) {}",
" function* a2(,) {}",
"(function a3(,) {});",
"(function* a4(,) {});",
"(function (,) {});",
"(function* (,) {});",
"(,) => {};",
"a1(,);",
// no trailing commas after rest parameter declaration
" function a(...b,) {}",
" function* a(...b,) {}",
"(function a(...b,) {});",
"(function* a(...b,) {});",
"(function (...b,) {});",
"(function* (...b,) {});",
" function a(b, c, ...d,) {}",
" function* a(b, c, ...d,) {}",
"(function a(b, c, ...d,) {});",
"(function* a(b, c, ...d,) {});",
"(function (b, c, ...d,) {});",
"(function* (b, c, ...d,) {});",
"(...b,) => {};",
"(b, c, ...d,) => {};",
// parenthesized trailing comma without arrow is still an error
"(,);",
"(a,);",
"(a,b,c,);",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
TEST(ArgumentsRedeclaration) {
{
// clang-format off
const char* context_data[][2] = {
{ "function f(", ") {}" },
{ nullptr, nullptr }
};
const char* success_data[] = {
"{arguments}",
"{arguments = false}",
"arg1, arguments",
"arg1, ...arguments",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, success_data, kSuccess);
}
{
// clang-format off
const char* context_data[][2] = {
{ "function f() {", "}" },
{ nullptr, nullptr }
};
const char* data[] = {
"const arguments = 1",
"let arguments",
"var arguments",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
}
// Test that lazily parsed inner functions don't result in overly pessimistic
// context allocations.
TEST(NoPessimisticContextAllocation) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
i::HandleScope scope(isolate);
LocalContext env;
const char* prefix = "(function outer() { var my_var; ";
const char* suffix = " })();";
int prefix_len = Utf8LengthHelper(prefix);
int suffix_len = Utf8LengthHelper(suffix);
// Test both normal inner functions and inner arrow functions.
const char* inner_functions[] = {"function inner(%s) { %s }",
"(%s) => { %s }"};
struct {
const char* params;
const char* source;
bool ctxt_allocate;
} inners[] = {
// Context allocating because we need to:
{"", "my_var;", true},
{"", "if (true) { let my_var; } my_var;", true},
{"", "eval('foo');", true},
{"", "function inner2() { my_var; }", true},
{"", "function inner2() { eval('foo'); }", true},
{"", "var {my_var : a} = {my_var};", true},
{"", "let {my_var : a} = {my_var};", true},
{"", "const {my_var : a} = {my_var};", true},
{"", "var [a, b = my_var] = [1, 2];", true},
{"", "var [a, b = my_var] = [1, 2]; my_var;", true},
{"", "let [a, b = my_var] = [1, 2];", true},
{"", "let [a, b = my_var] = [1, 2]; my_var;", true},
{"", "const [a, b = my_var] = [1, 2];", true},
{"", "const [a, b = my_var] = [1, 2]; my_var;", true},
{"", "var {a = my_var} = {}", true},
{"", "var {a: b = my_var} = {}", true},
{"", "let {a = my_var} = {}", true},
{"", "let {a: b = my_var} = {}", true},
{"", "const {a = my_var} = {}", true},
{"", "const {a: b = my_var} = {}", true},
{"a = my_var", "", true},
{"a = my_var", "let my_var;", true},
{"", "function inner2(a = my_var) { }", true},
{"", "(a = my_var) => { }", true},
{"{a} = {a: my_var}", "", true},
{"", "function inner2({a} = {a: my_var}) { }", true},
{"", "({a} = {a: my_var}) => { }", true},
{"[a] = [my_var]", "", true},
{"", "function inner2([a] = [my_var]) { }", true},
{"", "([a] = [my_var]) => { }", true},
{"", "function inner2(a = eval('')) { }", true},
{"", "(a = eval('')) => { }", true},
{"", "try { } catch (my_var) { } my_var;", true},
{"", "for (my_var in {}) { my_var; }", true},
{"", "for (my_var in {}) { }", true},
{"", "for (my_var of []) { my_var; }", true},
{"", "for (my_var of []) { }", true},
{"", "for ([a, my_var, b] in {}) { my_var; }", true},
{"", "for ([a, my_var, b] of []) { my_var; }", true},
{"", "for ({x: my_var} in {}) { my_var; }", true},
{"", "for ({x: my_var} of []) { my_var; }", true},
{"", "for ({my_var} in {}) { my_var; }", true},
{"", "for ({my_var} of []) { my_var; }", true},
{"", "for ({y, x: my_var} in {}) { my_var; }", true},
{"", "for ({y, x: my_var} of []) { my_var; }", true},
{"", "for ({a, my_var} in {}) { my_var; }", true},
{"", "for ({a, my_var} of []) { my_var; }", true},
{"", "for (let my_var in {}) { } my_var;", true},
{"", "for (let my_var of []) { } my_var;", true},
{"", "for (let [a, my_var, b] in {}) { } my_var;", true},
{"", "for (let [a, my_var, b] of []) { } my_var;", true},
{"", "for (let {x: my_var} in {}) { } my_var;", true},
{"", "for (let {x: my_var} of []) { } my_var;", true},
{"", "for (let {my_var} in {}) { } my_var;", true},
{"", "for (let {my_var} of []) { } my_var;", true},
{"", "for (let {y, x: my_var} in {}) { } my_var;", true},
{"", "for (let {y, x: my_var} of []) { } my_var;", true},
{"", "for (let {a, my_var} in {}) { } my_var;", true},
{"", "for (let {a, my_var} of []) { } my_var;", true},
{"", "for (let my_var = 0; my_var < 1; ++my_var) { } my_var;", true},
{"", "'use strict'; if (true) { function my_var() {} } my_var;", true},
{"",
"'use strict'; function inner2() { if (true) { function my_var() {} } "
"my_var; }",
true},
{"",
"function inner2() { 'use strict'; if (true) { function my_var() {} } "
"my_var; }",
true},
{"",
"() => { 'use strict'; if (true) { function my_var() {} } my_var; }",
true},
{"",
"if (true) { let my_var; if (true) { function my_var() {} } } my_var;",
true},
{"", "function inner2(a = my_var) {}", true},
{"", "function inner2(a = my_var) { let my_var; }", true},
{"", "(a = my_var) => {}", true},
{"", "(a = my_var) => { let my_var; }", true},
// No pessimistic context allocation:
{"", "var my_var; my_var;", false},
{"", "var my_var;", false},
{"", "var my_var = 0;", false},
{"", "if (true) { var my_var; } my_var;", false},
{"", "let my_var; my_var;", false},
{"", "let my_var;", false},
{"", "let my_var = 0;", false},
{"", "const my_var = 0; my_var;", false},
{"", "const my_var = 0;", false},
{"", "var [a, my_var] = [1, 2]; my_var;", false},
{"", "let [a, my_var] = [1, 2]; my_var;", false},
{"", "const [a, my_var] = [1, 2]; my_var;", false},
{"", "var {a: my_var} = {a: 3}; my_var;", false},
{"", "let {a: my_var} = {a: 3}; my_var;", false},
{"", "const {a: my_var} = {a: 3}; my_var;", false},
{"", "var {my_var} = {my_var: 3}; my_var;", false},
{"", "let {my_var} = {my_var: 3}; my_var;", false},
{"", "const {my_var} = {my_var: 3}; my_var;", false},
{"my_var", "my_var;", false},
{"my_var", "", false},
{"my_var = 5", "my_var;", false},
{"my_var = 5", "", false},
{"...my_var", "my_var;", false},
{"...my_var", "", false},
{"[a, my_var, b]", "my_var;", false},
{"[a, my_var, b]", "", false},
{"[a, my_var, b] = [1, 2, 3]", "my_var;", false},
{"[a, my_var, b] = [1, 2, 3]", "", false},
{"{x: my_var}", "my_var;", false},
{"{x: my_var}", "", false},
{"{x: my_var} = {x: 0}", "my_var;", false},
{"{x: my_var} = {x: 0}", "", false},
{"{my_var}", "my_var;", false},
{"{my_var}", "", false},
{"{my_var} = {my_var: 0}", "my_var;", false},
{"{my_var} = {my_var: 0}", "", false},
{"", "function inner2(my_var) { my_var; }", false},
{"", "function inner2(my_var) { }", false},
{"", "function inner2(my_var = 5) { my_var; }", false},
{"", "function inner2(my_var = 5) { }", false},
{"", "function inner2(...my_var) { my_var; }", false},
{"", "function inner2(...my_var) { }", false},
{"", "function inner2([a, my_var, b]) { my_var; }", false},
{"", "function inner2([a, my_var, b]) { }", false},
{"", "function inner2([a, my_var, b] = [1, 2, 3]) { my_var; }", false},
{"", "function inner2([a, my_var, b] = [1, 2, 3]) { }", false},
{"", "function inner2({x: my_var}) { my_var; }", false},
{"", "function inner2({x: my_var}) { }", false},
{"", "function inner2({x: my_var} = {x: 0}) { my_var; }", false},
{"", "function inner2({x: my_var} = {x: 0}) { }", false},
{"", "function inner2({my_var}) { my_var; }", false},
{"", "function inner2({my_var}) { }", false},
{"", "function inner2({my_var} = {my_var: 8}) { my_var; } ", false},
{"", "function inner2({my_var} = {my_var: 8}) { }", false},
{"", "my_var => my_var;", false},
{"", "my_var => { }", false},
{"", "(my_var = 5) => my_var;", false},
{"", "(my_var = 5) => { }", false},
{"", "(...my_var) => my_var;", false},
{"", "(...my_var) => { }", false},
{"", "([a, my_var, b]) => my_var;", false},
{"", "([a, my_var, b]) => { }", false},
{"", "([a, my_var, b] = [1, 2, 3]) => my_var;", false},
{"", "([a, my_var, b] = [1, 2, 3]) => { }", false},
{"", "({x: my_var}) => my_var;", false},
{"", "({x: my_var}) => { }", false},
{"", "({x: my_var} = {x: 0}) => my_var;", false},
{"", "({x: my_var} = {x: 0}) => { }", false},
{"", "({my_var}) => my_var;", false},
{"", "({my_var}) => { }", false},
{"", "({my_var} = {my_var: 5}) => my_var;", false},
{"", "({my_var} = {my_var: 5}) => { }", false},
{"", "({a, my_var}) => my_var;", false},
{"", "({a, my_var}) => { }", false},
{"", "({a, my_var} = {a: 0, my_var: 5}) => my_var;", false},
{"", "({a, my_var} = {a: 0, my_var: 5}) => { }", false},
{"", "({y, x: my_var}) => my_var;", false},
{"", "({y, x: my_var}) => { }", false},
{"", "({y, x: my_var} = {y: 0, x: 0}) => my_var;", false},
{"", "({y, x: my_var} = {y: 0, x: 0}) => { }", false},
{"", "try { } catch (my_var) { my_var; }", false},
{"", "try { } catch ([a, my_var, b]) { my_var; }", false},
{"", "try { } catch ({x: my_var}) { my_var; }", false},
{"", "try { } catch ({y, x: my_var}) { my_var; }", false},
{"", "try { } catch ({my_var}) { my_var; }", false},
{"", "for (let my_var in {}) { my_var; }", false},
{"", "for (let my_var in {}) { }", false},
{"", "for (let my_var of []) { my_var; }", false},
{"", "for (let my_var of []) { }", false},
{"", "for (let [a, my_var, b] in {}) { my_var; }", false},
{"", "for (let [a, my_var, b] of []) { my_var; }", false},
{"", "for (let {x: my_var} in {}) { my_var; }", false},
{"", "for (let {x: my_var} of []) { my_var; }", false},
{"", "for (let {my_var} in {}) { my_var; }", false},
{"", "for (let {my_var} of []) { my_var; }", false},
{"", "for (let {y, x: my_var} in {}) { my_var; }", false},
{"", "for (let {y, x: my_var} of []) { my_var; }", false},
{"", "for (let {a, my_var} in {}) { my_var; }", false},
{"", "for (let {a, my_var} of []) { my_var; }", false},
{"", "for (var my_var in {}) { my_var; }", false},
{"", "for (var my_var in {}) { }", false},
{"", "for (var my_var of []) { my_var; }", false},
{"", "for (var my_var of []) { }", false},
{"", "for (var [a, my_var, b] in {}) { my_var; }", false},
{"", "for (var [a, my_var, b] of []) { my_var; }", false},
{"", "for (var {x: my_var} in {}) { my_var; }", false},
{"", "for (var {x: my_var} of []) { my_var; }", false},
{"", "for (var {my_var} in {}) { my_var; }", false},
{"", "for (var {my_var} of []) { my_var; }", false},
{"", "for (var {y, x: my_var} in {}) { my_var; }", false},
{"", "for (var {y, x: my_var} of []) { my_var; }", false},
{"", "for (var {a, my_var} in {}) { my_var; }", false},
{"", "for (var {a, my_var} of []) { my_var; }", false},
{"", "for (var my_var in {}) { } my_var;", false},
{"", "for (var my_var of []) { } my_var;", false},
{"", "for (var [a, my_var, b] in {}) { } my_var;", false},
{"", "for (var [a, my_var, b] of []) { } my_var;", false},
{"", "for (var {x: my_var} in {}) { } my_var;", false},
{"", "for (var {x: my_var} of []) { } my_var;", false},
{"", "for (var {my_var} in {}) { } my_var;", false},
{"", "for (var {my_var} of []) { } my_var;", false},
{"", "for (var {y, x: my_var} in {}) { } my_var;", false},
{"", "for (var {y, x: my_var} of []) { } my_var;", false},
{"", "for (var {a, my_var} in {}) { } my_var;", false},
{"", "for (var {a, my_var} of []) { } my_var;", false},
{"", "for (let my_var = 0; my_var < 1; ++my_var) { my_var; }", false},
{"", "for (var my_var = 0; my_var < 1; ++my_var) { my_var; }", false},
{"", "for (var my_var = 0; my_var < 1; ++my_var) { } my_var; ", false},
{"", "for (let a = 0, my_var = 0; my_var < 1; ++my_var) { my_var }",
false},
{"", "for (var a = 0, my_var = 0; my_var < 1; ++my_var) { my_var }",
false},
{"", "class my_var {}; my_var; ", false},
{"", "function my_var() {} my_var;", false},
{"", "if (true) { function my_var() {} } my_var;", false},
{"", "function inner2() { if (true) { function my_var() {} } my_var; }",
false},
{"", "() => { if (true) { function my_var() {} } my_var; }", false},
{"",
"if (true) { var my_var; if (true) { function my_var() {} } } my_var;",
false},
};
for (unsigned inner_ix = 0; inner_ix < arraysize(inner_functions);
++inner_ix) {
const char* inner_function = inner_functions[inner_ix];
int inner_function_len = Utf8LengthHelper(inner_function) - 4;
for (unsigned i = 0; i < arraysize(inners); ++i) {
int params_len = Utf8LengthHelper(inners[i].params);
int source_len = Utf8LengthHelper(inners[i].source);
int len = prefix_len + inner_function_len + params_len + source_len +
suffix_len;
i::ScopedVector<char> program(len + 1);
i::SNPrintF(program, "%s", prefix);
i::SNPrintF(program + prefix_len, inner_function, inners[i].params,
inners[i].source);
i::SNPrintF(
program + prefix_len + inner_function_len + params_len + source_len,
"%s", suffix);
i::Handle<i::String> source =
factory->InternalizeUtf8String(program.begin());
source->PrintOn(stdout);
printf("\n");
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
i::Scope* scope = info.literal()->scope()->inner_scope();
DCHECK_NOT_NULL(scope);
DCHECK_NULL(scope->sibling());
DCHECK(scope->is_function_scope());
const i::AstRawString* var_name =
info.ast_value_factory()->GetOneByteString("my_var");
i::Variable* var = scope->LookupForTesting(var_name);
CHECK_EQ(inners[i].ctxt_allocate,
i::ScopeTestHelper::MustAllocateInContext(var));
}
}
}
TEST(EscapedStrictReservedWord) {
// Test that identifiers which are both escaped and only reserved in the
// strict mode are accepted in non-strict mode.
const char* context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* statement_data[] = {"if (true) l\\u0065t: ;",
"function l\\u0065t() { }",
"(function l\\u0065t() { })",
"async function l\\u0065t() { }",
"(async function l\\u0065t() { })",
"l\\u0065t => 42",
"async l\\u0065t => 42",
"function packag\\u0065() {}",
"function impl\\u0065ments() {}",
"function privat\\u0065() {}",
nullptr};
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(ForAwaitOf) {
// clang-format off
const char* context_data[][2] = {
{ "async function f() { for await ", " ; }" },
{ "async function f() { for await ", " { } }" },
{ "async function * f() { for await ", " { } }" },
{ "async function f() { 'use strict'; for await ", " ; }" },
{ "async function f() { 'use strict'; for await ", " { } }" },
{ "async function * f() { 'use strict'; for await ", " { } }" },
{ "async function f() { for\nawait ", " ; }" },
{ "async function f() { for\nawait ", " { } }" },
{ "async function * f() { for\nawait ", " { } }" },
{ "async function f() { 'use strict'; for\nawait ", " ; }" },
{ "async function f() { 'use strict'; for\nawait ", " { } }" },
{ "async function * f() { 'use strict'; for\nawait ", " { } }" },
{ "async function f() { for await\n", " ; }" },
{ "async function f() { for await\n", " { } }" },
{ "async function * f() { for await\n", " { } }" },
{ "async function f() { 'use strict'; for await\n", " ; }" },
{ "async function f() { 'use strict'; for await\n", " { } }" },
{ "async function * f() { 'use strict'; for await\n", " { } }" },
{ nullptr, nullptr }
};
const char* context_data2[][2] = {
{ "async function f() { let a; for await ", " ; }" },
{ "async function f() { let a; for await ", " { } }" },
{ "async function * f() { let a; for await ", " { } }" },
{ "async function f() { 'use strict'; let a; for await ", " ; }" },
{ "async function f() { 'use strict'; let a; for await ", " { } }" },
{ "async function * f() { 'use strict'; let a; for await ", " { } }" },
{ "async function f() { let a; for\nawait ", " ; }" },
{ "async function f() { let a; for\nawait ", " { } }" },
{ "async function * f() { let a; for\nawait ", " { } }" },
{ "async function f() { 'use strict'; let a; for\nawait ", " ; }" },
{ "async function f() { 'use strict'; let a; for\nawait ", " { } }" },
{ "async function * f() { 'use strict'; let a; for\nawait ", " { } }" },
{ "async function f() { let a; for await\n", " ; }" },
{ "async function f() { let a; for await\n", " { } }" },
{ "async function * f() { let a; for await\n", " { } }" },
{ "async function f() { 'use strict'; let a; for await\n", " ; }" },
{ "async function f() { 'use strict'; let a; for await\n", " { } }" },
{ "async function * f() { 'use strict'; let a; for await\n", " { } }" },
{ nullptr, nullptr }
};
const char* expr_data[] = {
// Primary Expressions
"(a of [])",
"(a.b of [])",
"([a] of [])",
"([a = 1] of [])",
"([a = 1, ...b] of [])",
"({a} of [])",
"({a: a} of [])",
"({'a': a} of [])",
"({\"a\": a} of [])",
"({[Symbol.iterator]: a} of [])",
"({0: a} of [])",
"({a = 1} of [])",
"({a: a = 1} of [])",
"({'a': a = 1} of [])",
"({\"a\": a = 1} of [])",
"({[Symbol.iterator]: a = 1} of [])",
"({0: a = 1} of [])",
nullptr
};
const char* var_data[] = {
// VarDeclarations
"(var a of [])",
"(var [a] of [])",
"(var [a = 1] of [])",
"(var [a = 1, ...b] of [])",
"(var {a} of [])",
"(var {a: a} of [])",
"(var {'a': a} of [])",
"(var {\"a\": a} of [])",
"(var {[Symbol.iterator]: a} of [])",
"(var {0: a} of [])",
"(var {a = 1} of [])",
"(var {a: a = 1} of [])",
"(var {'a': a = 1} of [])",
"(var {\"a\": a = 1} of [])",
"(var {[Symbol.iterator]: a = 1} of [])",
"(var {0: a = 1} of [])",
nullptr
};
const char* lexical_data[] = {
// LexicalDeclartions
"(let a of [])",
"(let [a] of [])",
"(let [a = 1] of [])",
"(let [a = 1, ...b] of [])",
"(let {a} of [])",
"(let {a: a} of [])",
"(let {'a': a} of [])",
"(let {\"a\": a} of [])",
"(let {[Symbol.iterator]: a} of [])",
"(let {0: a} of [])",
"(let {a = 1} of [])",
"(let {a: a = 1} of [])",
"(let {'a': a = 1} of [])",
"(let {\"a\": a = 1} of [])",
"(let {[Symbol.iterator]: a = 1} of [])",
"(let {0: a = 1} of [])",
"(const a of [])",
"(const [a] of [])",
"(const [a = 1] of [])",
"(const [a = 1, ...b] of [])",
"(const {a} of [])",
"(const {a: a} of [])",
"(const {'a': a} of [])",
"(const {\"a\": a} of [])",
"(const {[Symbol.iterator]: a} of [])",
"(const {0: a} of [])",
"(const {a = 1} of [])",
"(const {a: a = 1} of [])",
"(const {'a': a = 1} of [])",
"(const {\"a\": a = 1} of [])",
"(const {[Symbol.iterator]: a = 1} of [])",
"(const {0: a = 1} of [])",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, expr_data, kSuccess);
RunParserSyncTest(context_data2, expr_data, kSuccess);
RunParserSyncTest(context_data, var_data, kSuccess);
// TODO(marja): PreParser doesn't report early errors.
// (https://bugs.chromium.org/p/v8/issues/detail?id=2728)
// RunParserSyncTest(context_data2, var_data, kError, nullptr, 0,
// always_flags,
// arraysize(always_flags));
RunParserSyncTest(context_data, lexical_data, kSuccess);
RunParserSyncTest(context_data2, lexical_data, kSuccess);
}
TEST(ForAwaitOfErrors) {
// clang-format off
const char* context_data[][2] = {
{ "async function f() { for await ", " ; }" },
{ "async function f() { for await ", " { } }" },
{ "async function f() { 'use strict'; for await ", " ; }" },
{ "async function f() { 'use strict'; for await ", " { } }" },
{ "async function * f() { for await ", " ; }" },
{ "async function * f() { for await ", " { } }" },
{ "async function * f() { 'use strict'; for await ", " ; }" },
{ "async function * f() { 'use strict'; for await ", " { } }" },
{ nullptr, nullptr }
};
const char* data[] = {
// Primary Expressions
"(a = 1 of [])",
"(a = 1) of [])",
"(a.b = 1 of [])",
"((a.b = 1) of [])",
"([a] = 1 of [])",
"(([a] = 1) of [])",
"([a = 1] = 1 of [])",
"(([a = 1] = 1) of [])",
"([a = 1 = 1, ...b] = 1 of [])",
"(([a = 1 = 1, ...b] = 1) of [])",
"({a} = 1 of [])",
"(({a} = 1) of [])",
"({a: a} = 1 of [])",
"(({a: a} = 1) of [])",
"({'a': a} = 1 of [])",
"(({'a': a} = 1) of [])",
"({\"a\": a} = 1 of [])",
"(({\"a\": a} = 1) of [])",
"({[Symbol.iterator]: a} = 1 of [])",
"(({[Symbol.iterator]: a} = 1) of [])",
"({0: a} = 1 of [])",
"(({0: a} = 1) of [])",
"({a = 1} = 1 of [])",
"(({a = 1} = 1) of [])",
"({a: a = 1} = 1 of [])",
"(({a: a = 1} = 1) of [])",
"({'a': a = 1} = 1 of [])",
"(({'a': a = 1} = 1) of [])",
"({\"a\": a = 1} = 1 of [])",
"(({\"a\": a = 1} = 1) of [])",
"({[Symbol.iterator]: a = 1} = 1 of [])",
"(({[Symbol.iterator]: a = 1} = 1) of [])",
"({0: a = 1} = 1 of [])",
"(({0: a = 1} = 1) of [])",
"(function a() {} of [])",
"([1] of [])",
"({a: 1} of [])"
// VarDeclarations
"(var a = 1 of [])",
"(var a, b of [])",
"(var [a] = 1 of [])",
"(var [a], b of [])",
"(var [a = 1] = 1 of [])",
"(var [a = 1], b of [])",
"(var [a = 1 = 1, ...b] of [])",
"(var [a = 1, ...b], c of [])",
"(var {a} = 1 of [])",
"(var {a}, b of [])",
"(var {a: a} = 1 of [])",
"(var {a: a}, b of [])",
"(var {'a': a} = 1 of [])",
"(var {'a': a}, b of [])",
"(var {\"a\": a} = 1 of [])",
"(var {\"a\": a}, b of [])",
"(var {[Symbol.iterator]: a} = 1 of [])",
"(var {[Symbol.iterator]: a}, b of [])",
"(var {0: a} = 1 of [])",
"(var {0: a}, b of [])",
"(var {a = 1} = 1 of [])",
"(var {a = 1}, b of [])",
"(var {a: a = 1} = 1 of [])",
"(var {a: a = 1}, b of [])",
"(var {'a': a = 1} = 1 of [])",
"(var {'a': a = 1}, b of [])",
"(var {\"a\": a = 1} = 1 of [])",
"(var {\"a\": a = 1}, b of [])",
"(var {[Symbol.iterator]: a = 1} = 1 of [])",
"(var {[Symbol.iterator]: a = 1}, b of [])",
"(var {0: a = 1} = 1 of [])",
"(var {0: a = 1}, b of [])",
// LexicalDeclartions
"(let a = 1 of [])",
"(let a, b of [])",
"(let [a] = 1 of [])",
"(let [a], b of [])",
"(let [a = 1] = 1 of [])",
"(let [a = 1], b of [])",
"(let [a = 1, ...b] = 1 of [])",
"(let [a = 1, ...b], c of [])",
"(let {a} = 1 of [])",
"(let {a}, b of [])",
"(let {a: a} = 1 of [])",
"(let {a: a}, b of [])",
"(let {'a': a} = 1 of [])",
"(let {'a': a}, b of [])",
"(let {\"a\": a} = 1 of [])",
"(let {\"a\": a}, b of [])",
"(let {[Symbol.iterator]: a} = 1 of [])",
"(let {[Symbol.iterator]: a}, b of [])",
"(let {0: a} = 1 of [])",
"(let {0: a}, b of [])",
"(let {a = 1} = 1 of [])",
"(let {a = 1}, b of [])",
"(let {a: a = 1} = 1 of [])",
"(let {a: a = 1}, b of [])",
"(let {'a': a = 1} = 1 of [])",
"(let {'a': a = 1}, b of [])",
"(let {\"a\": a = 1} = 1 of [])",
"(let {\"a\": a = 1}, b of [])",
"(let {[Symbol.iterator]: a = 1} = 1 of [])",
"(let {[Symbol.iterator]: a = 1}, b of [])",
"(let {0: a = 1} = 1 of [])",
"(let {0: a = 1}, b of [])",
"(const a = 1 of [])",
"(const a, b of [])",
"(const [a] = 1 of [])",
"(const [a], b of [])",
"(const [a = 1] = 1 of [])",
"(const [a = 1], b of [])",
"(const [a = 1, ...b] = 1 of [])",
"(const [a = 1, ...b], b of [])",
"(const {a} = 1 of [])",
"(const {a}, b of [])",
"(const {a: a} = 1 of [])",
"(const {a: a}, b of [])",
"(const {'a': a} = 1 of [])",
"(const {'a': a}, b of [])",
"(const {\"a\": a} = 1 of [])",
"(const {\"a\": a}, b of [])",
"(const {[Symbol.iterator]: a} = 1 of [])",
"(const {[Symbol.iterator]: a}, b of [])",
"(const {0: a} = 1 of [])",
"(const {0: a}, b of [])",
"(const {a = 1} = 1 of [])",
"(const {a = 1}, b of [])",
"(const {a: a = 1} = 1 of [])",
"(const {a: a = 1}, b of [])",
"(const {'a': a = 1} = 1 of [])",
"(const {'a': a = 1}, b of [])",
"(const {\"a\": a = 1} = 1 of [])",
"(const {\"a\": a = 1}, b of [])",
"(const {[Symbol.iterator]: a = 1} = 1 of [])",
"(const {[Symbol.iterator]: a = 1}, b of [])",
"(const {0: a = 1} = 1 of [])",
"(const {0: a = 1}, b of [])",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
TEST(ForAwaitOfFunctionDeclaration) {
// clang-format off
const char* context_data[][2] = {
{ "async function f() {", "}" },
{ "async function f() { 'use strict'; ", "}" },
{ nullptr, nullptr }
};
const char* data[] = {
"for await (x of []) function d() {};",
"for await (x of []) function d() {}; return d;",
"for await (x of []) function* g() {};",
"for await (x of []) function* g() {}; return g;",
// TODO(caitp): handle async function declarations in ParseScopedStatement.
// "for await (x of []) async function a() {};",
// "for await (x of []) async function a() {}; return a;",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, data, kError);
}
TEST(AsyncGenerator) {
// clang-format off
const char* context_data[][2] = {
{ "async function * gen() {", "}" },
{ "(async function * gen() {", "})" },
{ "(async function * () {", "})" },
{ "({ async * gen () {", "} })" },
{ nullptr, nullptr }
};
const char* statement_data[] = {
// An async generator without a body is valid.
""
// Valid yield expressions inside generators.
"yield 2;",
"yield * 2;",
"yield * \n 2;",
"yield yield 1;",
"yield * yield * 1;",
"yield 3 + (yield 4);",
"yield * 3 + (yield * 4);",
"(yield * 3) + (yield * 4);",
"yield 3; yield 4;",
"yield * 3; yield * 4;",
"(function (yield) { })",
"(function yield() { })",
"(function (await) { })",
"(function await() { })",
"yield { yield: 12 }",
"yield /* comment */ { yield: 12 }",
"yield * \n { yield: 12 }",
"yield /* comment */ * \n { yield: 12 }",
// You can return in an async generator.
"yield 1; return",
"yield * 1; return",
"yield 1; return 37",
"yield * 1; return 37",
"yield 1; return 37; yield 'dead';",
"yield * 1; return 37; yield * 'dead';",
// Yield/Await are still a valid key in object literals.
"({ yield: 1 })",
"({ get yield() { } })",
"({ await: 1 })",
"({ get await() { } })",
// And in assignment pattern computed properties
"({ [yield]: x } = { })",
"({ [await 1]: x } = { })",
// Yield without RHS.
"yield;",
"yield",
"yield\n",
"yield /* comment */"
"yield // comment\n"
"(yield)",
"[yield]",
"{yield}",
"yield, yield",
"yield; yield",
"(yield) ? yield : yield",
"(yield) \n ? yield : yield",
// If there is a newline before the next token, we don't look for RHS.
"yield\nfor (;;) {}",
"x = class extends (yield) {}",
"x = class extends f(yield) {}",
"x = class extends (null, yield) { }",
"x = class extends (a ? null : yield) { }",
"x = class extends (await 10) {}",
"x = class extends f(await 10) {}",
"x = class extends (null, await 10) { }",
"x = class extends (a ? null : await 10) { }",
// More tests featuring AwaitExpressions
"await 10",
"await 10; return",
"await 10; return 20",
"await 10; return 20; yield 'dead'",
"await (yield 10)",
"await (yield 10); return",
"await (yield 10); return 20",
"await (yield 10); return 20; yield 'dead'",
"yield await 10",
"yield await 10; return",
"yield await 10; return 20",
"yield await 10; return 20; yield 'dead'",
"await /* comment */ 10",
"await // comment\n 10",
"yield await /* comment\n */ 10",
"yield await // comment\n 10",
"await (yield /* comment */)",
"await (yield // comment\n)",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kSuccess);
}
TEST(AsyncGeneratorErrors) {
// clang-format off
const char* context_data[][2] = {
{ "async function * gen() {", "}" },
{ "\"use strict\"; async function * gen() {", "}" },
{ nullptr, nullptr }
};
const char* statement_data[] = {
// Invalid yield expressions inside generators.
"var yield;",
"var await;",
"var foo, yield;",
"var foo, await;",
"try { } catch (yield) { }",
"try { } catch (await) { }",
"function yield() { }",
"function await() { }",
// The name of the NFE is bound in the generator, which does not permit
// yield or await to be identifiers.
"(async function * yield() { })",
"(async function * await() { })",
// Yield and Await aren't valid as a formal parameter for generators.
"async function * foo(yield) { }",
"(async function * foo(yield) { })",
"async function * foo(await) { }",
"(async function * foo(await) { })",
"yield = 1;",
"await = 1;",
"var foo = yield = 1;",
"var foo = await = 1;",
"++yield;",
"++await;",
"yield++;",
"await++;",
"yield *",
"(yield *)",
// Yield binds very loosely, so this parses as "yield (3 + yield 4)", which
// is invalid.
"yield 3 + yield 4;",
"yield: 34",
"yield ? 1 : 2",
// Parses as yield (/ yield): invalid.
"yield / yield",
"+ yield",
"+ yield 3",
// Invalid (no newline allowed between yield and *).
"yield\n*3",
// Invalid (we see a newline, so we parse {yield:42} as a statement, not an
// object literal, and yield is not a valid label).
"yield\n{yield: 42}",
"yield /* comment */\n {yield: 42}",
"yield //comment\n {yield: 42}",
// Destructuring binding and assignment are both disallowed
"var [yield] = [42];",
"var [await] = [42];",
"var {foo: yield} = {a: 42};",
"var {foo: await} = {a: 42};",
"[yield] = [42];",
"[await] = [42];",
"({a: yield} = {a: 42});",
"({a: await} = {a: 42});",
// Also disallow full yield/await expressions on LHS
"var [yield 24] = [42];",
"var [await 24] = [42];",
"var {foo: yield 24} = {a: 42};",
"var {foo: await 24} = {a: 42};",
"[yield 24] = [42];",
"[await 24] = [42];",
"({a: yield 24} = {a: 42});",
"({a: await 24} = {a: 42});",
"for (yield 'x' in {});",
"for (await 'x' in {});",
"for (yield 'x' of {});",
"for (await 'x' of {});",
"for (yield 'x' in {} in {});",
"for (await 'x' in {} in {});",
"for (yield 'x' in {} of {});",
"for (await 'x' in {} of {});",
"class C extends yield { }",
"class C extends await { }",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(LexicalLoopVariable) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
using TestCB =
std::function<void(const i::ParseInfo& info, i::DeclarationScope*)>;
auto TestProgram = [isolate](const char* program, TestCB test) {
i::Factory* const factory = isolate->factory();
i::Handle<i::String> source =
factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source);
i::UnoptimizedCompileState compile_state(isolate);
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_allow_lazy_parsing(false);
i::ParseInfo info(isolate, flags, &compile_state);
CHECK_PARSE_PROGRAM(&info, script, isolate);
i::DeclarationScope::AllocateScopeInfos(&info, isolate);
CHECK_NOT_NULL(info.literal());
i::DeclarationScope* script_scope = info.literal()->scope();
CHECK(script_scope->is_script_scope());
test(info, script_scope);
};
// Check `let` loop variables is a stack local when not captured by
// an eval or closure within the area of the loop body.
const char* local_bindings[] = {
"function loop() {"
" for (let loop_var = 0; loop_var < 10; ++loop_var) {"
" }"
" eval('0');"
"}",
"function loop() {"
" for (let loop_var = 0; loop_var < 10; ++loop_var) {"
" }"
" function foo() {}"
" foo();"
"}",
};
for (const char* source : local_bindings) {
TestProgram(source, [=](const i::ParseInfo& info, i::DeclarationScope* s) {
i::Scope* fn = s->inner_scope();
CHECK(fn->is_function_scope());
i::Scope* loop_block = fn->inner_scope();
if (loop_block->is_function_scope()) loop_block = loop_block->sibling();
CHECK(loop_block->is_block_scope());
const i::AstRawString* var_name =
info.ast_value_factory()->GetOneByteString("loop_var");
i::Variable* loop_var = loop_block->LookupLocal(var_name);
CHECK_NOT_NULL(loop_var);
CHECK(loop_var->IsStackLocal());
CHECK_EQ(loop_block->ContextLocalCount(), 0);
CHECK_NULL(loop_block->inner_scope());
});
}
// Check `let` loop variable is not a stack local, and is duplicated in the
// loop body to ensure capturing can work correctly.
// In this version of the test, the inner loop block's duplicate `loop_var`
// binding is not captured, and is a local.
const char* context_bindings1[] = {
"function loop() {"
" for (let loop_var = eval('0'); loop_var < 10; ++loop_var) {"
" }"
"}",
"function loop() {"
" for (let loop_var = (() => (loop_var, 0))(); loop_var < 10;"
" ++loop_var) {"
" }"
"}"};
for (const char* source : context_bindings1) {
TestProgram(source, [=](const i::ParseInfo& info, i::DeclarationScope* s) {
i::Scope* fn = s->inner_scope();
CHECK(fn->is_function_scope());
i::Scope* loop_block = fn->inner_scope();
CHECK(loop_block->is_block_scope());
const i::AstRawString* var_name =
info.ast_value_factory()->GetOneByteString("loop_var");
i::Variable* loop_var = loop_block->LookupLocal(var_name);
CHECK_NOT_NULL(loop_var);
CHECK(loop_var->IsContextSlot());
CHECK_EQ(loop_block->ContextLocalCount(), 1);
i::Variable* loop_var2 = loop_block->inner_scope()->LookupLocal(var_name);
CHECK_NE(loop_var, loop_var2);
CHECK(loop_var2->IsStackLocal());
CHECK_EQ(loop_block->inner_scope()->ContextLocalCount(), 0);
});
}
// Check `let` loop variable is not a stack local, and is duplicated in the
// loop body to ensure capturing can work correctly.
// In this version of the test, the inner loop block's duplicate `loop_var`
// binding is captured, and must be context allocated.
const char* context_bindings2[] = {
"function loop() {"
" for (let loop_var = 0; loop_var < 10; ++loop_var) {"
" eval('0');"
" }"
"}",
"function loop() {"
" for (let loop_var = 0; loop_var < eval('10'); ++loop_var) {"
" }"
"}",
"function loop() {"
" for (let loop_var = 0; loop_var < 10; eval('++loop_var')) {"
" }"
"}",
};
for (const char* source : context_bindings2) {
TestProgram(source, [=](const i::ParseInfo& info, i::DeclarationScope* s) {
i::Scope* fn = s->inner_scope();
CHECK(fn->is_function_scope());
i::Scope* loop_block = fn->inner_scope();
CHECK(loop_block->is_block_scope());
const i::AstRawString* var_name =
info.ast_value_factory()->GetOneByteString("loop_var");
i::Variable* loop_var = loop_block->LookupLocal(var_name);
CHECK_NOT_NULL(loop_var);
CHECK(loop_var->IsContextSlot());
CHECK_EQ(loop_block->ContextLocalCount(), 1);
i::Variable* loop_var2 = loop_block->inner_scope()->LookupLocal(var_name);
CHECK_NE(loop_var, loop_var2);
CHECK(loop_var2->IsContextSlot());
CHECK_EQ(loop_block->inner_scope()->ContextLocalCount(), 1);
});
}
// Similar to the above, but the first block scope's variables are not
// captured due to the closure occurring in a nested scope.
const char* context_bindings3[] = {
"function loop() {"
" for (let loop_var = 0; loop_var < 10; ++loop_var) {"
" (() => loop_var)();"
" }"
"}",
"function loop() {"
" for (let loop_var = 0; loop_var < (() => (loop_var, 10))();"
" ++loop_var) {"
" }"
"}",
"function loop() {"
" for (let loop_var = 0; loop_var < 10; (() => ++loop_var)()) {"
" }"
"}",
};
for (const char* source : context_bindings3) {
TestProgram(source, [=](const i::ParseInfo& info, i::DeclarationScope* s) {
i::Scope* fn = s->inner_scope();
CHECK(fn->is_function_scope());
i::Scope* loop_block = fn->inner_scope();
CHECK(loop_block->is_block_scope());
const i::AstRawString* var_name =
info.ast_value_factory()->GetOneByteString("loop_var");
i::Variable* loop_var = loop_block->LookupLocal(var_name);
CHECK_NOT_NULL(loop_var);
CHECK(loop_var->IsStackLocal());
CHECK_EQ(loop_block->ContextLocalCount(), 0);
i::Variable* loop_var2 = loop_block->inner_scope()->LookupLocal(var_name);
CHECK_NE(loop_var, loop_var2);
CHECK(loop_var2->IsContextSlot());
CHECK_EQ(loop_block->inner_scope()->ContextLocalCount(), 1);
});
}
}
TEST(PrivateNamesSyntaxErrorEarly) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
const char* context_data[][2] = {
{"", ""}, {"\"use strict\";", ""}, {nullptr, nullptr}};
const char* statement_data[] = {
"class A {"
" foo() { return this.#bar; }"
"}",
"let A = class {"
" foo() { return this.#bar; }"
"}",
"class A {"
" #foo; "
" bar() { return this.#baz; }"
"}",
"let A = class {"
" #foo; "
" bar() { return this.#baz; }"
"}",
"class A {"
" bar() {"
" class D { #baz = 1; };"
" return this.#baz;"
" }"
"}",
"let A = class {"
" bar() {"
" class D { #baz = 1; };"
" return this.#baz;"
" }"
"}",
"a.#bar",
"class Foo {};"
"Foo.#bar;",
"let Foo = class {};"
"Foo.#bar;",
"class Foo {};"
"(new Foo).#bar;",
"let Foo = class {};"
"(new Foo).#bar;",
"class Foo { #bar; };"
"(new Foo).#bar;",
"let Foo = class { #bar; };"
"(new Foo).#bar;",
"function t(){"
" class Foo { getA() { return this.#foo; } }"
"}",
"function t(){"
" return class { getA() { return this.#foo; } }"
"}",
nullptr};
RunParserSyncTest(context_data, statement_data, kError);
}
TEST(HashbangSyntax) {
const char* context_data[][2] = {
{"#!\n", ""},
{"#!---IGNORED---\n", ""},
{"#!---IGNORED---\r", ""},
{"#!---IGNORED---\xE2\x80\xA8", ""}, // <U+2028>
{"#!---IGNORED---\xE2\x80\xA9", ""}, // <U+2029>
{nullptr, nullptr}};
const char* data[] = {"function\nFN\n(\n)\n {\n}\nFN();", nullptr};
RunParserSyncTest(context_data, data, kSuccess);
RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0,
nullptr, 0, true);
}
TEST(HashbangSyntaxErrors) {
const char* file_context_data[][2] = {{"", ""}, {nullptr, nullptr}};
const char* other_context_data[][2] = {{"/**/", ""},
{"//---\n", ""},
{";", ""},
{"function fn() {", "}"},
{"function* fn() {", "}"},
{"async function fn() {", "}"},
{"async function* fn() {", "}"},
{"() => {", "}"},
{"() => ", ""},
{"function fn(a = ", ") {}"},
{"function* fn(a = ", ") {}"},
{"async function fn(a = ", ") {}"},
{"async function* fn(a = ", ") {}"},
{"(a = ", ") => {}"},
{"(a = ", ") => a"},
{"class k {", "}"},
{"[", "]"},
{"{", "}"},
{"({", "})"},
{nullptr, nullptr}};
const char* invalid_hashbang_data[] = {// Encoded characters are not allowed
"#\\u0021\n"
"#\\u{21}\n",
"#\\x21\n",
"#\\041\n",
"\\u0023!\n",
"\\u{23}!\n",
"\\x23!\n",
"\\043!\n",
"\\u0023\\u0021\n",
"\n#!---IGNORED---\n",
" #!---IGNORED---\n",
nullptr};
const char* hashbang_data[] = {"#!\n", "#!---IGNORED---\n", nullptr};
auto SyntaxErrorTest = [](const char* context_data[][2], const char* data[]) {
RunParserSyncTest(context_data, data, kError);
RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0,
nullptr, 0, true);
};
SyntaxErrorTest(file_context_data, invalid_hashbang_data);
SyntaxErrorTest(other_context_data, invalid_hashbang_data);
SyntaxErrorTest(other_context_data, hashbang_data);
}
TEST(LogicalAssignmentDestructuringErrors) {
// clang-format off
const char* context_data[][2] = {
{ "if (", ") { foo(); }" },
{ "(", ")" },
{ "foo(", ")" },
{ nullptr, nullptr }
};
const char* error_data[] = {
"[ x ] ||= [ 2 ]",
"[ x ||= 2 ] = [ 2 ]",
"{ x } ||= { x: 2 }",
"{ x: x ||= 2 ] = { x: 2 }",
"[ x ] &&= [ 2 ]",
"[ x &&= 2 ] = [ 2 ]",
"{ x } &&= { x: 2 }",
"{ x: x &&= 2 ] = { x: 2 }",
R"JS([ x ] ??= [ 2 ])JS",
R"JS([ x ??= 2 ] = [ 2 ])JS",
R"JS({ x } ??= { x: 2 })JS",
R"JS({ x: x ??= 2 ] = { x: 2 })JS",
nullptr
};
// clang-format on
RunParserSyncTest(context_data, error_data, kError);
}
} // namespace test_parsing
} // namespace internal
} // namespace v8
| [
"bryan.guner@gmail.com"
] | bryan.guner@gmail.com |
34de7142d69bcb83948942507146e3cb4ba58350 | ef11635322730255abdb8759618f6862e1544ef5 | /romanToInt.cpp | 7581911105398d061abdbe0df6f694336653e7c0 | [] | no_license | kaixinyan/leetcode | 64e97ee42c558b4e7dffdfeecba101a8f00ebaca | fb9a0294f93f271dddea61d385dd3e1c4999b753 | refs/heads/master | 2021-01-10T09:37:52.508638 | 2016-02-29T20:53:06 | 2016-02-29T20:53:06 | 49,697,873 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,204 | cpp | int romanToInt(string s) {
int n = s.size();
if (n == 0) return 0;
int ans = 0;
char pre;
for (int i = 0; i < n; ++i){
if (s[i] == 'M' && pre != 'C') ans += 1000;
if (s[i] == 'M' && pre == 'C') ans += 900 - 100;
if (s[i] == 'D' && pre != 'C') ans += 500;
if (s[i] == 'D' && pre == 'C') ans += 400 - 100;
if (s[i] == 'C' && pre != 'X') ans += 100;
if (s[i] == 'C' && pre == 'X') ans += 90 - 10;
if (s[i] == 'L' && pre != 'X') ans += 50;
if (s[i] == 'L' && pre == 'X') ans += 40 - 10;
if (s[i] == 'X' && pre != 'I') ans += 10;
if (s[i] == 'X' && pre == 'I') ans += 9 - 1;
if (s[i] == 'V' && pre != 'I') ans += 5;
if (s[i] == 'V' && pre == 'I') ans += 4 - 1;
if (s[i] == 'I') ans += 1;
pre = s[i];
}
return ans;
}
| [
"sweetviolin@Xingyes-MacBook-Air.local"
] | sweetviolin@Xingyes-MacBook-Air.local |
1c4bbaa1295bd9bcefbec1a2690124e4b46822a3 | 8629c447ba7ec73a2a72a09766e97bdaa0f10759 | /GenericsTest/results/GenericsTest.cpp | 1f01d5d09b0a992064371dc339db95348fe7d630 | [
"MIT"
] | permissive | xet7/onelang_generated | 376d648529d3f28ce3de8073a802f869e4d4e6e4 | 9685b2cf9dd5f570c29d8192e1548e4206a6dd09 | refs/heads/master | 2020-03-15T18:15:53.890490 | 2018-02-28T18:09:15 | 2018-02-28T18:09:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 704 | cpp | #include <one.hpp>
#include <iostream>
template<typename K, typename V>
class MapX {
public:
V value;
void set(K key, V value) {
this->value = value;
}
V get(K key) {
return this->value;
}
private:
};
class TestClass {
public:
void testMethod() {
auto map_x = make_shared<MapX<string, int>>();
map_x->set(string("hello"), 3);
int num_value = map_x->get(string("hello2"));
cout << string(to_string(num_value)) << endl;
}
private:
};
int main()
{
try {
TestClass c;
c.testMethod();
} catch(std::exception& err) {
cout << "Exception: " << err.what() << '\n';
}
return 0;
} | [
"koczkatamas@gmail.com"
] | koczkatamas@gmail.com |
f75145aeda371a33e126809bf571022a47376094 | c2dab5ad1c4245264d08f58e490b2b8b390c6f46 | /button.hpp | f7fcac0b6774341781d8c738391ec4620f68498a | [] | no_license | jastadj/simplexnoise | 0a834070fda39d025099310ed283761b92f11c27 | ca10d2d75a478046b51b78c8e0c8136be15b8098 | refs/heads/master | 2021-01-23T07:03:10.287182 | 2014-04-17T16:26:29 | 2014-04-17T16:26:29 | 15,568,723 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 488 | hpp | #ifndef CLASS_BUTTON
#define CLASS_BUTTON
#include <SFML\Graphics.hpp>
class Button
{
private:
sf::RenderWindow *screen;
sf::Vector2f mPosition;
sf::RectangleShape buttonShape;
sf::Text mText;
sf::Font mFont;
public:
Button(sf::RenderWindow *nscreen, std::string btext, sf::Vector2f position);
void update();
void draw();
void updateDraw() {update(); draw();}
bool mouseIn();
void setText(std::string ntext);
};
#endif // CLASS_BUTTON
| [
"jastadj@gmail.com"
] | jastadj@gmail.com |
8bdf3eb9341366c94858c19bd9b4cc42125399dd | f1c88bd33d7b7287d3fb4e13e1862d6fda77b61f | /BranchNBound/OrderedList.cpp | 45890e6951eca1be6c1e32fdbfd0ca8d746898cd | [] | no_license | MamonovNick/BranchNBound | f726ef5ec73e4ee2f175110ccab9c775987b60fb | 8859df98ce395e7ea20e59df67ed6f3124474e48 | refs/heads/master | 2021-10-24T09:51:35.086681 | 2019-03-25T01:07:46 | 2019-03-25T01:07:46 | 125,560,256 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,403 | cpp | #include "stdafx.h"
#include "OrderedList.h"
template <typename T>
OrderedList<T>::OrderedList(double T::* c_val)
{
count_ = 0;
comparison_value_ = c_val;
}
template <typename T>
OrderedList<T>::~OrderedList()
{
clear();
}
template <typename T>
void OrderedList<T>::add(T* elem)
{
if (!elem)
return;
//Current insert element value
double insert_val = (*elem).*comparison_value_;
//If list is empty simply add new element
if (!order_list_)
{
Node<T>* tmp = new Node<T>();
tmp->prev = nullptr;
tmp->next = nullptr;
tmp->elem = elem;
order_list_ = tmp;
count_++;
return;
}
//Check for adding on first index
//(We need to correct the main pointer)
double cmp_val = (*(order_list_->elem)).*comparison_value_;
if (insert_val <= cmp_val)
{
Node<T>* tmp = new Node<T>();
tmp->prev = nullptr;
tmp->next = order_list_;
tmp->elem = elem;
order_list_ = tmp;
count_++;
return;
}
Node<T>* tmp_ptr = order_list_;
bool insert_done = false;
while(tmp_ptr->next && !insert_done)
{
double next_elem_val = *((*(tmp_ptr->next)).elem).*comparison_value_;
if(insert_val <= next_elem_val)
{
Node<T>* tmp = new Node<T>();
tmp->prev = tmp_ptr;
tmp->next = tmp_ptr->next;
tmp->elem = elem;
tmp_ptr->next = tmp;
(tmp->next)->prev = tmp;
count_++;
insert_done = true;
}
tmp_ptr = tmp_ptr->next;
}
if(!insert_done)
{
Node<T>* tmp = new Node<T>();
tmp->prev = tmp_ptr;
tmp->next = nullptr;
tmp->elem = elem;
tmp_ptr->next = tmp;
count_++;
}
}
template <typename T>
T* OrderedList<T>::first()
{
if (!order_list_)
return nullptr;
return order_list_->elem;
}
template <typename T>
T* OrderedList<T>::pull_first()
{
if (!order_list_)
return nullptr;
Node<T>* tmp = order_list_;
order_list_ = tmp->next;
T* result = tmp->elem;
tmp->elem = nullptr;
delete tmp;
count_--;
return result;
}
template <typename T>
void OrderedList<T>::clear()
{
while (order_list_)
{
Node<Tree>* tmp = order_list_;
order_list_ = order_list_->next;
delete tmp;
}
}
template <typename T>
void OrderedList<T>::clear(double value)
{
if (!order_list_)
return;
Node<T>* tmp_ptr = order_list_;
while (tmp_ptr)
{
double elem_val = *(tmp_ptr->elem).*comparison_value_;
if (elem_val > value)
break;
tmp_ptr = tmp_ptr->next;
}
while(tmp_ptr)
{
Node<Tree>* tmp = tmp_ptr;
tmp_ptr = tmp_ptr->next;
delete tmp;
}
}
| [
"mnv0895@gmail.com"
] | mnv0895@gmail.com |
a55805e9461acd8921eeae31911f445a42f486bf | 9d4095d62a11c002e781b7293cf74885d0ffb7c7 | /Semaforo.cpp | e8edf956444e34fc1973821df88558bceb835395 | [] | no_license | FlorEtcheverry/DistribuidosEj2ExMutPCNoAcotado | 67091c11ec52971aa4422506d6d7c9b5afcc8252 | 46435850469d405745c09e9144fd7783e6c4feed | refs/heads/master | 2020-02-26T15:10:02.796692 | 2015-04-21T17:21:43 | 2015-04-21T17:21:43 | 33,844,923 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,715 | cpp | /*
* File: Semaforo.cpp
* Author: knoppix
*
* Created on March 28, 2015, 7:18 PM
*/
#include "Semaforo.h"
Semaforo::Semaforo(const char* sem_dir) {
key_t key = ftok(sem_dir,SEM);
this-> id = semget(key,1,0666|IPC_CREAT);
if (id == -1){
(Logger::getLogger())->escribir(ERROR,std::string(strerror(errno))+"No se pudo abrir el semaforo.");
exit(1);
}
}
void Semaforo::init(int initial_value){
union semnum {
int val;
struct semid_ds*buf;
ushort*array;
};
semnum init ;
init.val = initial_value;
int resultado = semctl (this->id,0,SETVAL,init);
if (resultado == -1){
(Logger::getLogger())->escribir(ERROR,std::string(strerror(errno))+" No se pudo inicializar el semaforo");
exit(1);
}
}
void Semaforo::p(){
struct sembuf operacion ;
operacion.sem_num = 0; // nro sem
operacion.sem_op = -1;
operacion.sem_flg = 0;
int resultado = semop(this-> id,&operacion,1) ;
if (resultado == -1){
(Logger::getLogger())->escribir(ERROR,std::string(strerror(errno))+" Error al esperar por el semaforo");
exit(1);
}
}
void Semaforo::v(){
struct sembuf operacion ;
operacion.sem_num = 0;
operacion.sem_op = 1;
operacion.sem_flg = 0;
int resultado = semop(this-> id,&operacion,1) ;
if (resultado == -1){
(Logger::getLogger())->escribir(ERROR,std::string(strerror(errno))+" Error al levantar el semaforo");
exit(1);
}
}
void Semaforo::destroy(){
int resultado = semctl(this->id,0,IPC_RMID);
if (resultado == -1){
(Logger::getLogger())->escribir(ERROR,std::string(strerror(errno))+" Error al destruir el semáforo.");
}
}
Semaforo::~Semaforo() {
} | [
"florencia.a.etcheverry@gmail.com"
] | florencia.a.etcheverry@gmail.com |
b3b95852cf34d2d43dce4bcbb13c34fda0aa6f1a | 1d3fb39f8e1438caaa4c1d75f1d0bd8f38e39060 | /project7_1/list.h | d9eed3b572973adaea4a79dcba844390272c41df | [] | no_license | hqsds/chenchen.github.io | 6319cace7e8e0a1ddb8ab32baf4838972c6b2ce5 | 3d8e699db27a3c36c721fe3806f23fac48207cc6 | refs/heads/master | 2022-03-07T18:02:46.018195 | 2022-02-14T23:56:10 | 2022-02-14T23:56:10 | 128,699,513 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,180 | h | // Fig. 21.4: list.h
// Template List class definition.
#ifndef LIST_H
#define LIST_H
#include <iostream>
using std::cout;
#include <new>
#include "listnode.h" // ListNode class definition
template< class NODETYPE >
class List {
public:
List(); // constructor
~List(); // destructor
void insertAtFront(const NODETYPE &);
void insertAtBack(const NODETYPE &);
bool removeFromFront(NODETYPE &);
bool removeFromBack(NODETYPE &);
bool isEmpty() const;
void print() const;
private:
ListNode< NODETYPE > *firstPtr; // pointer to first node
ListNode< NODETYPE > *lastPtr; // pointer to last node
// utility function to allocate new node
ListNode< NODETYPE > *getNewNode(const NODETYPE &);
}; // end class List
// default constructor
template< class NODETYPE >
List< NODETYPE >::List()
: firstPtr(0),
lastPtr(0)
{
// empty body
} // end List constructor
// destructor
template< class NODETYPE >
List< NODETYPE >::~List()
{
if (!isEmpty()) { // List is not empty
// cout << "Destroying nodes ...\n";
ListNode< NODETYPE > *currentPtr = firstPtr;
ListNode< NODETYPE > *tempPtr;
while (currentPtr != 0) // delete remaining nodes
{
tempPtr = currentPtr;
// commented out the output -- no need to print what we are deallocating
// cout << tempPtr->data << '\n';
currentPtr = currentPtr->nextPtr;
delete tempPtr;
}
}
// cout << "All nodes destroyed\n\n";
} // end List destructor
// insert node at front of list
template< class NODETYPE >
void List< NODETYPE >::insertAtFront(const NODETYPE &value)
{
ListNode< NODETYPE > *newPtr = getNewNode(value);
if (isEmpty()) // List is empty
firstPtr = lastPtr = newPtr;
else { // List is not empty
newPtr->nextPtr = firstPtr;
firstPtr = newPtr;
} // end else
} // end function insertAtFront
// insert node at back of list
template< class NODETYPE >
void List< NODETYPE >::insertAtBack(const NODETYPE &value)
{
ListNode< NODETYPE > *newPtr = getNewNode(value);
if (isEmpty()) // List is empty
firstPtr = lastPtr = newPtr;
else { // List is not empty
lastPtr->nextPtr = newPtr;
lastPtr = newPtr;
} // end else
} // end function insertAtBack
// delete node from front of list
template< class NODETYPE >
bool List< NODETYPE >::removeFromFront(NODETYPE &value)
{
if (isEmpty()) // List is empty
return false; // delete unsuccessful
else {
ListNode< NODETYPE > *tempPtr = firstPtr;
if (firstPtr == lastPtr)
firstPtr = lastPtr = 0;
else
firstPtr = firstPtr->nextPtr;
value = tempPtr->data; // data being removed
delete tempPtr;
return true; // delete successful
} // end else
} // end function removeFromFront
// delete node from back of list
template< class NODETYPE >
bool List< NODETYPE >::removeFromBack(NODETYPE &value)
{
if (isEmpty())
return false; // delete unsuccessful
else {
ListNode< NODETYPE > *tempPtr = lastPtr;
if (firstPtr == lastPtr)
firstPtr = lastPtr = 0;
else {
ListNode< NODETYPE > *currentPtr = firstPtr;
// locate second-to-last element
while (currentPtr->nextPtr != lastPtr)
currentPtr = currentPtr->nextPtr;
lastPtr = currentPtr;
currentPtr->nextPtr = 0;
} // end else
value = tempPtr->data;
delete tempPtr;
return true; // delete successful
} // end else
} // end function removeFromBack
// is List empty?
template< class NODETYPE >
bool List< NODETYPE >::isEmpty() const
{
return firstPtr == 0;
} // end function isEmpty
// return pointer to newly allocated node
template< class NODETYPE >
ListNode< NODETYPE > *List< NODETYPE >::getNewNode(
const NODETYPE &value)
{
return new ListNode< NODETYPE >(value);
} // end function getNewNode
// display contents of List
template< class NODETYPE >
void List< NODETYPE >::print() const
{
if (isEmpty()) {
cout << "The list is empty\n\n";
return;
} // end if
ListNode< NODETYPE > *currentPtr = firstPtr;
cout << "The list is: ";
while (currentPtr != 0) {
cout << currentPtr->data << ' ';
currentPtr = currentPtr->nextPtr;
} // end while
cout << "\n\n";
} // end function print
#endif
/**************************************************************************
* (C) Copyright 1992-2003 by Deitel & Associates, Inc. and Prentice *
* Hall. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/ | [
"ccz919@gmail.com"
] | ccz919@gmail.com |
6c4e50928e47d8260b56793a2f92563c58846d77 | 5898d3bd9e4cb58043b40fa58961c7452182db08 | /part1/ch03/3-4-4-variadic-template/src/variadic_template.h | 126d317649c0f4cd3121ff7cc539e1716570a698 | [] | no_license | sasaki-seiji/ProgrammingLanguageCPP4th | 1e802f3cb15fc2ac51fa70403b95f52878223cff | 2f686b385b485c27068328c6533926903b253687 | refs/heads/master | 2020-04-04T06:10:32.942026 | 2017-08-10T11:35:08 | 2017-08-10T11:35:08 | 53,772,682 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 369 | h | /*
* variadic_template.h
*
* Created on: 2016/03/30
* Author: sasaki
*/
#ifndef VARIADIC_TEMPLATE_H_
#define VARIADIC_TEMPLATE_H_
#include <iostream>
void f() {}
template<typename T>
void g(T x)
{
std::cout << x << " ";
}
template<typename T, typename... Tail>
void f(T head, Tail... tail)
{
g(head);
f(tail...);
}
#endif /* VARIADIC_TEMPLATE_H_ */
| [
"sasaki-seiji@msj.biglobe.ne.jp"
] | sasaki-seiji@msj.biglobe.ne.jp |
eacd69f186684efc8001b15026cccdf25b517d89 | 48d6d9fba59405c7b64c2906da7b728f58ad038a | /Robot Code/src/main/cpp/subsystems/SwerveController.cpp | 199d3e527affb5a82a9498632018ed733a69a5df | [] | no_license | FRC-Team3538/FRC2020Swerve | 0539083d46e45041d2141ab4a78014e1e3e6d31f | 0261c8be5b03b9099d3d3704b6b3543667e19e96 | refs/heads/master | 2022-12-02T23:51:37.948495 | 2020-08-10T16:24:22 | 2020-08-10T16:24:22 | 272,115,772 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,856 | cpp | #include "subsystems/SwerveController.hpp"
SwerveController::SwerveController()
{
ConfigureMotors();
SetAngle(0.0);
}
/**
* Main Function to control swerve drive
*
* @param x double input for Left-Right on joystick
* @param y double input for Forward-Backward on joystick
* @param rotate double input for joystick rotate input
* @param fieldCentric bool input to use field-centric control or robot-centric
*/
void SwerveController::SwerveDrive(double x, double y, double rotate, bool fieldCentric)
{
double r = sqrt(pow(x, 2) + pow(y, 2));
double theta = atan2(x, y); // Radians
// Snap to poles if within deadband
theta = deadbandPoles(theta);
// Scale the magnitude of the polar graph in order to preserve the angle
double scaledR = pow(r, 3);
// Revert to cartesian
x = scaledR * cos(theta);
y = scaledR * sin(theta);
// Convert to field-centric inputs if using field-centric control
if (fieldCentric)
{
double robotAng = GetAngle() * (Constants::pi / 180.0); // Degrees to Radians
double temp = (y * cos(robotAng)) + (x * sin(robotAng));
x = (-y * sin(robotAng)) + (x * cos(robotAng));
y = temp;
}
if ((x == 0.0) && (y == 0.0) && (rotate == 0.0))
{
double ang = Constants::frontRight.getAng();
frontRight.setModule(-ang, 0.0);
frontLeft.setModule(ang, 0.0);
backRight.setModule(ang, 0.0);
backLeft.setModule(-ang, 0.0);
}
else
{
// Calculate swerve commands based on inputs
SK.Calculate(x, y, rotate);
motorVals = SK.GetKinematics();
// Send command to modules
frontRight.setModule(motorVals[0][1], -motorVals[0][0]);
frontLeft.setModule(motorVals[1][1], -motorVals[1][0]);
backRight.setModule(motorVals[2][1], -motorVals[2][0]);
backLeft.setModule(motorVals[3][1], -motorVals[3][0]);
}
}
void SwerveController::SetIdleMode(rev::CANSparkMax::IdleMode idlemode)
{
frontRight.SetIdleMode(idlemode);
frontLeft.SetIdleMode(idlemode);
backRight.SetIdleMode(idlemode);
backLeft.SetIdleMode(idlemode);
}
void SwerveController::TestSteering(double x, double y)
{
// frontLeft.testTurning(x);
// return;
if (x == 0.0 && y == 0.0)
{
if (prevTheta != -420.0)
{
frontRight.setModule(prevTheta, 0.0);
frontLeft.setModule(prevTheta, 0.0);
backRight.setModule(prevTheta, 0.0);
backLeft.setModule(prevTheta, 0.0);
return;
}
else
{
return;
}
}
//double r = sqrt(pow(x, 2) + pow(y, 2));
double r = 0.0;
double theta = atan2(x, y); // Radians
// Snap to poles if within deadband
theta = deadbandPoles(theta);
theta *= (180.0 / Constants::pi); //Convert to Degrees
// Change to a -180 ~ 180 Scale
theta -= 180;
theta = theta > 180.0 ? theta - 360.0 : theta;
prevTheta = theta;
frontRight.setModule(theta, r);
frontLeft.setModule(theta, r);
backRight.setModule(theta, r);
backLeft.setModule(theta, r);
}
/**
* Returns robot angle heading
*
* @return angle of robot -180 ~ 180
*/
double SwerveController::GetAngle()
{
double ang = pidgeotto.GetFusedHeading();
ang *= -1;
ang = fmod(ang, 360.0);
if (ang < 0.0)
ang += 360.0;
return ang;
}
/**
* Sets current fused heading
*
* @param angle double input to set fused heading to angle
*/
void SwerveController::SetAngle(double angle)
{
pidgeotto.SetFusedHeading(angle);
}
/**
* Tests for proximity to poles (0, pi/2, pi, 3pi/2)
* and if within deadband, snaps it to the pole
*
* @param input angle in radians
* @return input angle, or pole if close enough
*/
double SwerveController::deadbandPoles(double input)
{
double temp = input;
input = fmod(input, 360.0);
if (abs(input - ((3 * Constants::pi) / 2)) < poleDeadband)
{
return ((3 * Constants::pi) / 2);
}
else if (abs(input - Constants::pi) < poleDeadband)
{
return Constants::pi;
}
else if (abs(input - (Constants::pi / 2)) < poleDeadband)
{
return (Constants::pi / 2);
}
else
{
return temp;
}
}
void SwerveController::UpdateTelemetry()
{
frc::SmartDashboard::PutNumber("fr Ang", frontRight.getModuleAngle());
frc::SmartDashboard::PutNumber("fl Ang", frontLeft.getModuleAngle());
frc::SmartDashboard::PutNumber("br Ang", backRight.getModuleAngle());
frc::SmartDashboard::PutNumber("bl Ang", backLeft.getModuleAngle());
frc::SmartDashboard::PutNumber("Robit Ang", GetAngle());
frontRight.UpdateTelemetry();
frontLeft.UpdateTelemetry();
backRight.UpdateTelemetry();
backLeft.UpdateTelemetry();
}
void SwerveController::ConfigureMotors()
{
} | [
"rfeng716@gmail.com"
] | rfeng716@gmail.com |
6ec368a4c9ca8b374bdd470ade59d406f371e959 | 3606ac437d8444e38842facb84d1ac705ff9efcf | /thrift/lib/cpp2/async/RocketClientChannel.h | 5c193a874493befd9a90329ef318b96efb7098a9 | [
"Apache-2.0"
] | permissive | ParkerWen/fbthrift | c2fb2d4187563ec260fe8d407c7312d8ee9ba96e | 88b9951f1402f73a7e67cafefac1c7a848121041 | refs/heads/master | 2020-04-18T02:35:54.721368 | 2019-01-23T02:13:41 | 2019-01-23T02:16:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,868 | h | /*
* Copyright 2015-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <chrono>
#include <limits>
#include <memory>
#include <folly/fibers/FiberManagerMap.h>
#include <folly/io/async/DelayedDestruction.h>
#include <yarpl/flowable/Flowable.h>
#include <yarpl/flowable/Subscriber.h>
#include "thrift/lib/cpp/async/TAsyncTransport.h"
#include "thrift/lib/cpp2/async/ClientChannel.h"
#include "thrift/lib/thrift/gen-cpp2/RpcMetadata_types.h"
namespace folly {
class EventBase;
class IOBuf;
} // namespace folly
namespace apache {
namespace thrift {
class ContextStack;
class RequestCallback;
class RpcOptions;
class ThriftClientCallback;
namespace rocket {
class Payload;
class RocketClient;
} // namespace rocket
namespace transport {
class THeader;
} // namespace transport
class RocketClientChannel final : public ClientChannel {
public:
using Ptr = std::
unique_ptr<RocketClientChannel, folly::DelayedDestruction::Destructor>;
static Ptr newChannel(async::TAsyncTransport::UniquePtr socket);
uint32_t sendRequest(
RpcOptions& rpcOptions,
std::unique_ptr<RequestCallback> cb,
std::unique_ptr<ContextStack> ctx,
std::unique_ptr<folly::IOBuf> buf,
std::shared_ptr<transport::THeader> header) override;
uint32_t sendOnewayRequest(
RpcOptions& rpcOptions,
std::unique_ptr<RequestCallback> cb,
std::unique_ptr<ContextStack> ctx,
std::unique_ptr<folly::IOBuf> buf,
std::shared_ptr<transport::THeader> header) override;
uint32_t sendStreamRequest(
RpcOptions&,
std::unique_ptr<RequestCallback>,
std::unique_ptr<ContextStack>,
std::unique_ptr<folly::IOBuf>,
std::shared_ptr<transport::THeader>) override;
folly::EventBase* getEventBase() const override {
return evb_;
}
uint16_t getProtocolId() override {
return protocolId_;
}
void setProtocolId(uint16_t protocolId) {
protocolId_ = protocolId;
}
async::TAsyncTransport* FOLLY_NULLABLE getTransport() override;
bool good() override;
void attachEventBase(folly::EventBase*) override;
void detachEventBase() override;
bool isDetachable() override;
void setOnDetachable(folly::Function<void()> onDetachable) override;
void unsetOnDetachable() override;
uint32_t getTimeout() override {
return timeout_.count();
}
void setTimeout(uint32_t timeoutMs) override;
CLIENT_TYPE getClientType() override {
// TODO Create a new client type
return THRIFT_HTTP_CLIENT_TYPE;
}
void setMaxPendingRequests(uint32_t n) {
inflightState_->setMaxInflightRequests(n);
}
SaturationStatus getSaturationStatus() override;
void closeNow() override;
void setCloseCallback(CloseCallback* closeCallback) override;
private:
static constexpr std::chrono::milliseconds kDefaultRpcTimeout{500};
folly::EventBase* evb_{nullptr};
std::shared_ptr<rocket::RocketClient> rclient_;
uint16_t protocolId_{apache::thrift::protocol::T_BINARY_PROTOCOL};
std::chrono::milliseconds timeout_{kDefaultRpcTimeout};
class InflightState {
public:
explicit InflightState(folly::Function<void()> onDetachable)
: onDetachable_(std::move(onDetachable)) {}
bool incPendingRequests() {
if (inflightRequests_ >= maxInflightRequests_) {
return false;
}
++inflightRequests_;
return true;
}
void decPendingRequests() {
if (!--inflightRequests_ && onDetachable_) {
onDetachable_();
}
}
uint32_t inflightRequests() const {
return inflightRequests_;
}
uint32_t maxInflightRequests() const {
return maxInflightRequests_;
}
void setMaxInflightRequests(uint32_t n) {
maxInflightRequests_ = n;
}
void unsetOnDetachable() {
onDetachable_ = nullptr;
}
private:
uint32_t inflightRequests_{0};
uint32_t maxInflightRequests_{std::numeric_limits<uint32_t>::max()};
folly::Function<void()> onDetachable_;
};
const std::shared_ptr<InflightState> inflightState_{
std::make_shared<InflightState>([this] {
DCHECK(!evb_ || evb_->isInEventBaseThread());
if (isDetachable()) {
notifyDetachable();
}
})};
explicit RocketClientChannel(async::TAsyncTransport::UniquePtr socket);
RocketClientChannel(const RocketClientChannel&) = delete;
RocketClientChannel& operator=(const RocketClientChannel&) = delete;
virtual ~RocketClientChannel();
void sendThriftRequest(
RpcOptions& rpcOptions,
RpcKind kind,
std::unique_ptr<RequestCallback> cb,
std::unique_ptr<ContextStack> ctx,
std::unique_ptr<folly::IOBuf> buf,
std::shared_ptr<apache::thrift::transport::THeader> header);
void sendSingleRequestNoResponse(
const RequestRpcMetadata& metadata,
std::unique_ptr<ContextStack> ctx,
std::unique_ptr<folly::IOBuf> buf,
std::unique_ptr<RequestCallback> cb);
void sendSingleRequestSingleResponse(
const RequestRpcMetadata& metadata,
std::unique_ptr<ContextStack> ctx,
std::unique_ptr<folly::IOBuf> buf,
std::unique_ptr<RequestCallback> cb);
void sendSingleRequestStreamResponse(
const RequestRpcMetadata& metadata,
std::unique_ptr<ContextStack> ctx,
std::unique_ptr<folly::IOBuf> buf,
std::unique_ptr<RequestCallback> cb,
std::chrono::milliseconds chunkTimeout);
RequestRpcMetadata makeRequestRpcMetadata(
RpcOptions& rpcOptions,
RpcKind kind,
ProtocolId protocolId,
transport::THeader* header);
folly::fibers::FiberManager& getFiberManager() const {
DCHECK(evb_);
return folly::fibers::getFiberManager(*evb_);
}
public:
// Helper class that gives special handling to the first payload on the
// response stream. Public only for testing purposes.
class TakeFirst
: public yarpl::flowable::Flowable<std::unique_ptr<folly::IOBuf>>,
public yarpl::flowable::Subscriber<rocket::Payload> {
public:
TakeFirst(
folly::EventBase& evb,
std::unique_ptr<ThriftClientCallback> clientCallback,
std::chrono::milliseconds chunkTimeout,
std::weak_ptr<InflightState> inflightState);
~TakeFirst() override;
void cancel();
private:
using T = rocket::Payload;
using U = std::unique_ptr<folly::IOBuf>;
bool awaitingFirstResponse_{true};
bool completeBeforeSubscribed_{false};
folly::exception_wrapper errorBeforeSubscribed_;
std::shared_ptr<yarpl::flowable::Subscriber<U>> subscriber_;
std::shared_ptr<yarpl::flowable::Subscription> subscription_;
folly::EventBase& evb_;
std::unique_ptr<ThriftClientCallback> clientCallback_;
const std::chrono::milliseconds chunkTimeout_;
std::weak_ptr<InflightState> inflightWeak_;
void subscribe(std::shared_ptr<yarpl::flowable::Subscriber<U>>) final;
void onSubscribe(std::shared_ptr<yarpl::flowable::Subscription>) final;
void onNext(T) final;
void onError(folly::exception_wrapper ew) final;
void onComplete() final;
protected:
virtual void onNormalFirstResponse(
T&& firstPayload,
std::shared_ptr<Flowable<U>> tail);
virtual void onErrorFirstResponse(folly::exception_wrapper ew);
virtual void onStreamTerminated();
};
};
} // namespace thrift
} // namespace apache
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
af7047f4219d77569d2d243a4f646e201c50785e | 8c8820fb84dea70d31c1e31dd57d295bd08dd644 | /Slate/Public/Widgets/Input/SMultiLineEditableTextBox.h | c26f01b758b7c5d8c23de1e78234fac00cf5cda3 | [] | no_license | redisread/UE-Runtime | e1a56df95a4591e12c0fd0e884ac6e54f69d0a57 | 48b9e72b1ad04458039c6ddeb7578e4fc68a7bac | refs/heads/master | 2022-11-15T08:30:24.570998 | 2020-06-20T06:37:55 | 2020-06-20T06:37:55 | 274,085,558 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,068 | h | // Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Misc/Attribute.h"
#include "SlateGlobals.h"
#include "Layout/Margin.h"
#include "Styling/SlateColor.h"
#include "Fonts/SlateFontInfo.h"
#include "Input/Reply.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Styling/SlateTypes.h"
#include "Styling/CoreStyle.h"
#include "Framework/Text/IRun.h"
#include "Framework/Text/TextLayout.h"
#include "Widgets/Layout/SBorder.h"
#include "Widgets/Layout/SScrollBar.h"
#include "Widgets/Text/SMultiLineEditableText.h"
class IErrorReportingWidget;
class ITextLayoutMarshaller;
class SBox;
class SHorizontalBox;
enum class ETextShapingMethod : uint8;
#if WITH_FANCY_TEXT
/**
* Editable text box widget
*/
class SLATE_API SMultiLineEditableTextBox : public SBorder
{
public:
SLATE_BEGIN_ARGS( SMultiLineEditableTextBox )
: _Style(&FCoreStyle::Get().GetWidgetStyle<FEditableTextBoxStyle>("NormalEditableTextBox"))
, _TextStyle(&FCoreStyle::Get().GetWidgetStyle<FTextBlockStyle>("NormalText"))
, _Marshaller()
, _Text()
, _HintText()
, _SearchText()
, _Font()
, _ForegroundColor()
, _ReadOnlyForegroundColor()
, _Justification(ETextJustify::Left)
, _LineHeightPercentage(1.0f)
, _IsReadOnly( false )
, _AllowMultiLine( true )
, _IsCaretMovedWhenGainFocus ( true )
, _SelectAllTextWhenFocused( false )
, _ClearTextSelectionOnFocusLoss( true )
, _RevertTextOnEscape( false )
, _ClearKeyboardFocusOnCommit( true )
, _AllowContextMenu(true)
, _AlwaysShowScrollbars( false )
, _HScrollBar()
, _VScrollBar()
, _WrapTextAt(0.0f)
, _AutoWrapText(false)
, _WrappingPolicy(ETextWrappingPolicy::DefaultWrapping)
, _SelectAllTextOnCommit( false )
, _BackgroundColor()
, _Padding()
, _Margin()
, _ErrorReporting()
, _ModiferKeyForNewLine(EModifierKey::None)
, _VirtualKeyboardOptions(FVirtualKeyboardOptions())
, _VirtualKeyboardTrigger(EVirtualKeyboardTrigger::OnFocusByPointer)
, _VirtualKeyboardDismissAction(EVirtualKeyboardDismissAction::TextChangeOnDismiss)
, _TextShapingMethod()
, _TextFlowDirection()
{}
/** The styling of the textbox */
SLATE_STYLE_ARGUMENT( FEditableTextBoxStyle, Style )
/** Pointer to a style of the text block, which dictates the font, color, and shadow options. */
SLATE_STYLE_ARGUMENT( FTextBlockStyle, TextStyle )
/** The marshaller used to get/set the raw text to/from the text layout. */
SLATE_ARGUMENT(TSharedPtr< ITextLayoutMarshaller >, Marshaller)
/** Sets the text content for this editable text box widget */
SLATE_ATTRIBUTE( FText, Text )
/** Hint text that appears when there is no text in the text box */
SLATE_ATTRIBUTE( FText, HintText )
/** Text to search for (a new search is triggered whenever this text changes) */
SLATE_ATTRIBUTE( FText, SearchText )
/** Font color and opacity (overrides Style) */
SLATE_ATTRIBUTE( FSlateFontInfo, Font )
/** Text color and opacity (overrides Style) */
SLATE_ATTRIBUTE( FSlateColor, ForegroundColor )
/** Text color and opacity when read-only (overrides Style) */
SLATE_ATTRIBUTE( FSlateColor, ReadOnlyForegroundColor )
/** How the text should be aligned with the margin. */
SLATE_ATTRIBUTE(ETextJustify::Type, Justification)
/** The amount to scale each lines height by. */
SLATE_ATTRIBUTE(float, LineHeightPercentage)
/** Sets whether this text box can actually be modified interactively by the user */
SLATE_ATTRIBUTE( bool, IsReadOnly )
/** Whether to allow multi-line text */
SLATE_ATTRIBUTE(bool, AllowMultiLine)
/** Workaround as we loose focus when the auto completion closes. */
SLATE_ATTRIBUTE( bool, IsCaretMovedWhenGainFocus )
/** Whether to select all text when the user clicks to give focus on the widget */
SLATE_ATTRIBUTE( bool, SelectAllTextWhenFocused )
/** Whether to clear text selection when focus is lost */
SLATE_ATTRIBUTE( bool, ClearTextSelectionOnFocusLoss )
/** Whether to allow the user to back out of changes when they press the escape key */
SLATE_ATTRIBUTE( bool, RevertTextOnEscape )
/** Whether to clear keyboard focus when pressing enter to commit changes */
SLATE_ATTRIBUTE( bool, ClearKeyboardFocusOnCommit )
/** Whether the context menu can be opened */
SLATE_ATTRIBUTE(bool, AllowContextMenu)
/** Should we always show the scrollbars (only affects internally created scroll bars) */
SLATE_ARGUMENT(bool, AlwaysShowScrollbars)
/** The horizontal scroll bar widget, or null to create one internally */
SLATE_ARGUMENT( TSharedPtr< SScrollBar >, HScrollBar )
/** The vertical scroll bar widget, or null to create one internally */
SLATE_ARGUMENT( TSharedPtr< SScrollBar >, VScrollBar )
/** Padding around the horizontal scrollbar (overrides Style) */
SLATE_ATTRIBUTE( FMargin, HScrollBarPadding )
/** Padding around the vertical scrollbar (overrides Style) */
SLATE_ATTRIBUTE( FMargin, VScrollBarPadding )
/** Delegate to call before a context menu is opened. User returns the menu content or null to the disable context menu */
SLATE_EVENT(FOnContextMenuOpening, OnContextMenuOpening)
/**
* This is NOT for validating input!
*
* Called whenever a character is typed.
* Not called for copy, paste, or any other text changes!
*/
SLATE_EVENT( FOnIsTypedCharValid, OnIsTypedCharValid )
/** Called whenever the text is changed programmatically or interactively by the user */
SLATE_EVENT( FOnTextChanged, OnTextChanged )
/** Called whenever the text is committed. This happens when the user presses enter or the text box loses focus. */
SLATE_EVENT( FOnTextCommitted, OnTextCommitted )
/** Called whenever the horizontal scrollbar is moved by the user */
SLATE_EVENT( FOnUserScrolled, OnHScrollBarUserScrolled )
/** Called whenever the vertical scrollbar is moved by the user */
SLATE_EVENT( FOnUserScrolled, OnVScrollBarUserScrolled )
/** Called when the cursor is moved within the text area */
SLATE_EVENT( SMultiLineEditableText::FOnCursorMoved, OnCursorMoved )
/** Callback delegate to have first chance handling of the OnKeyChar event */
SLATE_EVENT(FOnKeyChar, OnKeyCharHandler)
/** Callback delegate to have first chance handling of the OnKeyDown event */
SLATE_EVENT(FOnKeyDown, OnKeyDownHandler)
/** Menu extender for the right-click context menu */
SLATE_EVENT( FMenuExtensionDelegate, ContextMenuExtender )
/** Delegate used to create text layouts for this widget. If none is provided then FSlateTextLayout will be used. */
SLATE_EVENT( FCreateSlateTextLayout, CreateSlateTextLayout )
/** Whether text wraps onto a new line when it's length exceeds this width; if this value is zero or negative, no wrapping occurs. */
SLATE_ATTRIBUTE( float, WrapTextAt )
/** Whether to wrap text automatically based on the widget's computed horizontal space. IMPORTANT: Using automatic wrapping can result
in visual artifacts, as the the wrapped size will computed be at least one frame late! Consider using WrapTextAt instead. The initial
desired size will not be clamped. This works best in cases where the text block's size is not affecting other widget's layout. */
SLATE_ATTRIBUTE( bool, AutoWrapText )
/** The wrapping policy to use */
SLATE_ATTRIBUTE( ETextWrappingPolicy, WrappingPolicy )
/** Whether to select all text when pressing enter to commit changes */
SLATE_ATTRIBUTE( bool, SelectAllTextOnCommit )
/** The color of the background/border around the editable text (overrides Style) */
SLATE_ATTRIBUTE( FSlateColor, BackgroundColor )
/** Padding between the box/border and the text widget inside (overrides Style) */
SLATE_ATTRIBUTE( FMargin, Padding )
/** The amount of blank space left around the edges of text area.
This is different to Padding because this area is still considered part of the text area, and as such, can still be interacted with */
SLATE_ATTRIBUTE( FMargin, Margin )
/** Provide a alternative mechanism for error reporting. */
SLATE_ARGUMENT( TSharedPtr<class IErrorReportingWidget>, ErrorReporting )
/** The optional modifier key necessary to create a newline when typing into the editor. */
SLATE_ARGUMENT( EModifierKey::Type, ModiferKeyForNewLine)
/** Additional options used by the virtual keyboard summoned by this widget */
SLATE_ARGUMENT( FVirtualKeyboardOptions, VirtualKeyboardOptions )
/** The type of event that will trigger the display of the virtual keyboard */
SLATE_ATTRIBUTE( EVirtualKeyboardTrigger, VirtualKeyboardTrigger )
/** The message action to take when the virtual keyboard is dismissed by the user */
SLATE_ATTRIBUTE( EVirtualKeyboardDismissAction, VirtualKeyboardDismissAction )
/** Which text shaping method should we use? (unset to use the default returned by GetDefaultTextShapingMethod) */
SLATE_ARGUMENT( TOptional<ETextShapingMethod>, TextShapingMethod )
/** Which text flow direction should we use? (unset to use the default returned by GetDefaultTextFlowDirection) */
SLATE_ARGUMENT( TOptional<ETextFlowDirection>, TextFlowDirection )
SLATE_END_ARGS()
/**
* Construct this widget
*
* @param InArgs The declaration data for this widget
*/
void Construct( const FArguments& InArgs );
/**
* Returns the text string
*
* @return Text string
*/
FText GetText() const
{
return EditableText->GetText();
}
/**
* Returns the plain text string without richtext formatting
*
* @return Text string
*/
FText GetPlainText() const
{
return EditableText->GetPlainText();
}
/** See attribute Style */
void SetStyle(const FEditableTextBoxStyle* InStyle);
/** See attribute TextStyle */
void SetTextStyle(const FTextBlockStyle* InTextStyle);
/**
* Sets the text string currently being edited
*
* @param InNewText The new text string
*/
void SetText( const TAttribute< FText >& InNewText );
/**
* Returns the hint text string
*
* @return Hint text string
*/
FText GetHintText() const
{
return EditableText->GetHintText();
}
/**
* Sets the text that appears when there is no text in the text box
*
* @param InHintText The hint text string
*/
void SetHintText( const TAttribute< FText >& InHintText );
/** Set the text that is currently being searched for (if any) */
void SetSearchText(const TAttribute<FText>& InSearchText);
/** Get the text that is currently being searched for (if any) */
FText GetSearchText() const;
/**
* Sets the text color and opacity (overrides Style)
*
* @param InForegroundColor The text color and opacity
*/
void SetTextBoxForegroundColor(const TAttribute<FSlateColor>& InForegroundColor);
/**
* Sets the color of the background/border around the editable text (overrides Style)
*
* @param InBackgroundColor The background/border color
*/
void SetTextBoxBackgroundColor(const TAttribute<FSlateColor>& InBackgroundColor);
/**
* Sets the text color and opacity when read-only (overrides Style)
*
* @param InReadOnlyForegroundColor The read-only text color and opacity
*/
void SetReadOnlyForegroundColor(const TAttribute<FSlateColor>& InReadOnlyForegroundColor);
/** See TextShapingMethod attribute */
void SetTextShapingMethod(const TOptional<ETextShapingMethod>& InTextShapingMethod);
/** See TextFlowDirection attribute */
void SetTextFlowDirection(const TOptional<ETextFlowDirection>& InTextFlowDirection);
/** See WrapTextAt attribute */
void SetWrapTextAt(const TAttribute<float>& InWrapTextAt);
/** See AutoWrapText attribute */
void SetAutoWrapText(const TAttribute<bool>& InAutoWrapText);
/** Set WrappingPolicy attribute */
void SetWrappingPolicy(const TAttribute<ETextWrappingPolicy>& InWrappingPolicy);
/** See LineHeightPercentage attribute */
void SetLineHeightPercentage(const TAttribute<float>& InLineHeightPercentage);
/** See Margin attribute */
void SetMargin(const TAttribute<FMargin>& InMargin);
/** See Justification attribute */
void SetJustification(const TAttribute<ETextJustify::Type>& InJustification);
/** See the AllowContextMenu attribute */
void SetAllowContextMenu(const TAttribute< bool >& InAllowContextMenu);
/** Set the VirtualKeyboardDismissAction attribute */
void SetVirtualKeyboardDismissAction(TAttribute< EVirtualKeyboardDismissAction > InVirtualKeyboardDismissAction);
/** Set the ReadOnly attribute */
void SetIsReadOnly(const TAttribute< bool >& InIsReadOnly);
/**
* If InError is a non-empty string the TextBox will the ErrorReporting provided during construction
* If no error reporting was provided, the TextBox will create a default error reporter.
*/
void SetError( const FText& InError );
void SetError( const FString& InError );
// SWidget overrides
virtual bool SupportsKeyboardFocus() const override;
virtual bool HasKeyboardFocus() const override;
virtual FReply OnFocusReceived( const FGeometry& MyGeometry, const FFocusEvent& InFocusEvent ) override;
/** Query to see if any text is selected within the document */
bool AnyTextSelected() const;
/** Select all the text in the document */
void SelectAllText();
/** Clear the active text selection */
void ClearSelection();
/** Get the currently selected text */
FText GetSelectedText() const;
/** Insert the given text at the current cursor position, correctly taking into account new line characters */
void InsertTextAtCursor(const FText& InText);
void InsertTextAtCursor(const FString& InString);
/** Insert the given run at the current cursor position */
void InsertRunAtCursor(TSharedRef<IRun> InRun);
/** Move the cursor to the given location in the document */
void GoTo(const FTextLocation& NewLocation);
/** Move the cursor to the specified location */
void GoTo(const ETextLocation NewLocation)
{
EditableText->GoTo(NewLocation);
}
/** Scroll to the given location in the document (without moving the cursor) */
void ScrollTo(const FTextLocation& NewLocation);
/** Scroll to the given location in the document (without moving the cursor) */
void ScrollTo(const ETextLocation NewLocation)
{
EditableText->ScrollTo(NewLocation);
}
/** Apply the given style to the currently selected text (or insert a new run at the current cursor position if no text is selected) */
void ApplyToSelection(const FRunInfo& InRunInfo, const FTextBlockStyle& InStyle);
/** Begin a new text search (this is called automatically when the bound search text changes) */
void BeginSearch(const FText& InSearchText, const ESearchCase::Type InSearchCase = ESearchCase::IgnoreCase, const bool InReverse = false);
/** Advance the current search to the next match (does nothing if not currently searching) */
void AdvanceSearch(const bool InReverse = false);
/** Get the run currently under the cursor, or null if there is no run currently under the cursor */
TSharedPtr<const IRun> GetRunUnderCursor() const;
/** Get the runs currently that are current selected, some of which may be only partially selected */
TArray<TSharedRef<const IRun>> GetSelectedRuns() const;
/** Get the horizontal scroll bar widget */
TSharedPtr<const SScrollBar> GetHScrollBar() const;
/** Get the vertical scroll bar widget */
TSharedPtr<const SScrollBar> GetVScrollBar() const;
/** Refresh this text box immediately, rather than wait for the usual caching mechanisms to take affect on the text Tick */
void Refresh();
/**
* Sets the OnKeyCharHandler to provide first chance handling of the SMultiLineEditableText's OnKeyChar event
*
* @param InOnKeyCharHandler Delegate to call during OnKeyChar event
*/
void SetOnKeyCharHandler(FOnKeyChar InOnKeyCharHandler);
/**
* Sets the OnKeyDownHandler to provide first chance handling of the SMultiLineEditableText's OnKeyDown event
*
* @param InOnKeyDownHandler Delegate to call during OnKeyDown event
*/
void SetOnKeyDownHandler(FOnKeyDown InOnKeyDownHandler);
/**
*
*/
void ForceScroll(int32 UserIndex, float ScrollAxisMagnitude);
protected:
/** Editable text widget */
TSharedPtr< SMultiLineEditableText > EditableText;
/** Padding (overrides style) */
TAttribute<FMargin> PaddingOverride;
/** Horiz scrollbar padding (overrides style) */
TAttribute<FMargin> HScrollBarPaddingOverride;
/** Vert scrollbar padding (overrides style) */
TAttribute<FMargin> VScrollBarPaddingOverride;
/** Font (overrides style) */
TAttribute<FSlateFontInfo> FontOverride;
/** Foreground color (overrides style) */
TAttribute<FSlateColor> ForegroundColorOverride;
/** Background color (overrides style) */
TAttribute<FSlateColor> BackgroundColorOverride;
/** Read-only foreground color (overrides style) */
TAttribute<FSlateColor> ReadOnlyForegroundColorOverride;
/** Whether to disable the context menu */
TAttribute< bool > AllowContextMenu;
/** Allows for inserting additional widgets that extend the functionality of the text box */
TSharedPtr<SHorizontalBox> Box;
/** Whether we have an externally supplied horizontal scrollbar or one created internally */
bool bHasExternalHScrollBar;
/** Horiz scrollbar */
TSharedPtr<SScrollBar> HScrollBar;
/** Box around the horiz scrollbar used for adding padding */
TSharedPtr<SBox> HScrollBarPaddingBox;
/** Whether we have an externally supplied vertical scrollbar or one created internally */
bool bHasExternalVScrollBar;
/** Vert scrollbar */
TSharedPtr<SScrollBar> VScrollBar;
/** Box around the vert scrollbar used for adding padding */
TSharedPtr<SBox> VScrollBarPaddingBox;
/** SomeWidget reporting */
TSharedPtr<class IErrorReportingWidget> ErrorReporting;
const FEditableTextBoxStyle* Style;
private:
FMargin FORCEINLINE DeterminePadding() const { check(Style); return PaddingOverride.IsSet() ? PaddingOverride.Get() : Style->Padding; }
FMargin FORCEINLINE DetermineHScrollBarPadding() const { check(Style); return HScrollBarPaddingOverride.IsSet() ? HScrollBarPaddingOverride.Get() : Style->HScrollBarPadding; }
FMargin FORCEINLINE DetermineVScrollBarPadding() const { check(Style); return VScrollBarPaddingOverride.IsSet() ? VScrollBarPaddingOverride.Get() : Style->VScrollBarPadding; }
FSlateFontInfo FORCEINLINE DetermineFont() const { check(Style); return FontOverride.IsSet() ? FontOverride.Get() : Style->Font; }
FSlateColor FORCEINLINE DetermineBackgroundColor() const { check(Style); return BackgroundColorOverride.IsSet() ? BackgroundColorOverride.Get() : Style->BackgroundColor; }
FSlateColor DetermineForegroundColor() const;
/** Styling: border image to draw when not hovered or focused */
const FSlateBrush* BorderImageNormal;
/** Styling: border image to draw when hovered */
const FSlateBrush* BorderImageHovered;
/** Styling: border image to draw when focused */
const FSlateBrush* BorderImageFocused;
/** Styling: border image to draw when read only */
const FSlateBrush* BorderImageReadOnly;
/** @return Border image for the text box based on the hovered and focused state */
const FSlateBrush* GetBorderImage() const;
};
#endif //WITH_FANCY_TEXT
| [
"wujiahong19981022@outlook.com"
] | wujiahong19981022@outlook.com |
20961ec82f69f6b143df756b33c0572bf2750a60 | 843910b963dca4555308d2736c26fa0234d631a6 | /MathLib/src/CVec2.cpp | 1ad0055a6deed0c62d4e8caa61a03f6142196f33 | [] | no_license | kobake/KppLibs | 1bbb11bbea8765738e975ddde81d8536c6a129f1 | 60d9343a41260f3d90be61b1e6fd4ee31b05d05b | refs/heads/master | 2021-01-17T19:26:04.315121 | 2020-03-28T00:37:43 | 2020-03-28T00:37:43 | 58,841,018 | 1 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,834 | cpp | #include "_required.h"
#include "CVec2.h"
#include "CRect.h"
#include <cmath>
namespace math{
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
// Vec2Base //
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
//絶対値
template <class T>
T Vec2Base<T>::length() const
{
return (T)sqrt((double)(x*x+y*y));
}
template <class T>
T Vec2Base<T>::lengthSq() const
{
return x*x+y*y;
}
//正規化
template <class T>
Vec2Base<T>& Vec2Base<T>::normalize()
{
T len=length();
x/=len;
y/=len;
return *this;
}
//法線
template <class T>
Vec2Base<T> Vec2Base<T>::normal() const
{
return Vec2Base<T>(-y,x); //デカルト座標系において左に90°回転
}
//回転
template <class T>
void Vec2Base<T>::rotate(float angle)
{
float new_x=x*cos(angle)-y*sin(angle);
float new_y=x*sin(angle)+y*cos(angle);
x=new_x;
y=new_y;
}
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
// 外部関数 //
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
//内積 ( inner product / dot product )
template <class T>
T dot_product(const Vec2Base<T>& v0,const Vec2Base<T>& v1)
{
return v0.x*v1.x+v0.y*v1.y;
}
//外積 ( outer product / cross product )
template <class T>
T cross_product(const Vec2Base<T>& v0,const Vec2Base<T>& v1)
{
return v0.x*v1.y-v0.y*v1.x;
}
// -- -- 明示的なインスタンス化 -- -- //
template long dot_product(const Vec2Base<long>& v0,const Vec2Base<long>& v1);
template long cross_product(const Vec2Base<long>& v0,const Vec2Base<long>& v1);
template double dot_product(const Vec2Base<double>& v0,const Vec2Base<double>& v1);
template double cross_product(const Vec2Base<double>& v0,const Vec2Base<double>& v1);
} //namespace math
| [
"kobake@users.sourceforge.net"
] | kobake@users.sourceforge.net |
3050f8678b189423babcacec399ca66b51f63ac0 | e6559df51c2a14256962c3757073a491ea66de7c | /SPOJ/NKLEAVES - Leaves.cpp | 1b857f3a46e49794530bd5bac521842b00a953a1 | [] | no_license | Maycon708/Maratona | c30eaedc3ee39d69582b0ed1a60f31ad8d666d43 | b6d07582544c230e67c23a20e1a1be99d4b47576 | refs/heads/master | 2020-04-25T23:37:53.992330 | 2019-02-28T17:10:25 | 2019-02-28T17:10:25 | 143,191,679 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,661 | cpp | #include <bits/stdc++.h>
#define INF 1LL << 60;
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define pb push_back
#define debug(x) if(1)cout << #x << " = " << x << endl;
#define debug2(x,y) if(1)cout << #x << " = " << x << " --- " << #y << " = " << y << "\n";
#define debugM( x, l, c ) { rep( i, 0, l ){ rep( j, 0, c ) cout << x[i][j] << " "; printf("\n");}}
#define all(S) (S).begin(), (S).end()
#define F first
#define S second
#define mk make_pair
#define infinity 1111111111111111111ll
using namespace std;
typedef pair <int, int> ii;
typedef long long int ll;
#define N 100100
#define K 20
ll C[N];
ll sums[N];
ll F[K][N];
ll P[K][N];
ll cost(int i, int j) {
return ( i > j )? 0 : j * ( C[j] - C[i-1] ) - ( sums[j] - sums[i-1] );
}
void fill(int g, int l1, int l2, int p1, int p2) {
if (l1 > l2) return;
int lm = ( l1 + l2 ) >> 1;
P[g][lm] = -1;
F[g][lm] = infinity;
for( int k = p1; k <= p2; k++ ){
ll new_cost = F[g-1][k] + cost( k+1, lm );
if (F[g][lm] > new_cost ){
F[g][lm] = new_cost;
P[g][lm] = k;
}
}
fill(g, l1, lm-1, p1, P[g][lm]);
fill(g, lm+1, l2, P[g][lm], p2);
}
int main() {
int n, k;
while( scanf("%d%d", &n, &k ) != EOF ){
sums[0] = 0;
for( int i = 0; i < n; i++ ){
scanf("%lld", &C[n-i] );
}
for( int i = 1; i <= n; i++ ){
sums[i] = i * C[i] + sums[i-1];
C[i] += C[i-1];
}
for( int l = 0; l <= n; l++ ){
F[1][l] = cost(1,l);
P[1][l] = 0;
}
for( int g = 2; g <= k; g++ ){
fill(g, 1, n, 1, n);
}
printf("%lld\n", F[k][n] );
}
}
| [
"mayconalves@gea.inatel.br"
] | mayconalves@gea.inatel.br |
0218329b96b6aa99674c4fbd26a54c4ad97d8f1d | f3ed29d56c31168989ab88f160e4dd9f058df587 | /source/frontend/views/settings/themes_and_colors_pane.cpp | ff126801d055a576c0ba46b1c26ba2c7ee202ffd | [
"MIT"
] | permissive | bofh80/radeon_memory_visualizer | 6301598244f6238e298d2236947553ed302fe085 | a331b4472dafe15badfe1e0ebf4fe850779f7e41 | refs/heads/master | 2023-02-03T14:10:05.888254 | 2020-12-03T14:23:35 | 2020-12-08T20:40:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,658 | cpp | //=============================================================================
/// Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief Implementation of Colors and Themes pane.
//=============================================================================
#include "views/settings/themes_and_colors_pane.h"
#include "settings/rmv_settings.h"
#include "util/rmv_util.h"
#include "util/widget_util.h"
#include "util/string_util.h"
#include "views/debug_window.h"
const static int kPickerRows = 4;
const static int kPickerColumns = 8;
ThemesAndColorsPane::ThemesAndColorsPane(QWidget* parent)
: BasePane(parent)
, ui_(new Ui::ThemesAndColorsPane)
{
ui_->setupUi(this);
rmv::widget_util::ApplyStandardPaneStyle(this, ui_->main_content_, ui_->main_scroll_area_);
// Set up buttons using RMVSettingID's as buttongroup id's.
button_group_.addButton(ui_->button_snapshots_viewed_, kSettingThemesAndColorsSnapshotViewed);
button_group_.addButton(ui_->button_snapshots_compared_, kSettingThemesAndColorsSnapshotCompared);
button_group_.addButton(ui_->button_snapshots_live_, kSettingThemesAndColorsSnapshotLive);
button_group_.addButton(ui_->button_snapshots_generated_, kSettingThemesAndColorsSnapshotGenerated);
button_group_.addButton(ui_->button_snapshots_vma_, kSettingThemesAndColorsSnapshotVma);
button_group_.addButton(ui_->button_resource_depth_stencil_buffer_, kSettingThemesAndColorsResourceDsBuffer);
button_group_.addButton(ui_->button_resource_render_target_, kSettingThemesAndColorsResourceRenderTarget);
button_group_.addButton(ui_->button_resource_texture_, kSettingThemesAndColorsResourceTexture);
button_group_.addButton(ui_->button_resource_vertex_buffer_, kSettingThemesAndColorsResourceVertexBuffer);
button_group_.addButton(ui_->button_resource_index_buffer_, kSettingThemesAndColorsResourceIndexBuffer);
button_group_.addButton(ui_->button_resource_uav_, kSettingThemesAndColorsResourceUav);
button_group_.addButton(ui_->button_resource_shader_pipeline_, kSettingThemesAndColorsResourceShaderPipeline);
button_group_.addButton(ui_->button_resource_command_buffer_, kSettingThemesAndColorsResourceCommandBuffer);
button_group_.addButton(ui_->button_resource_heap_, kSettingThemesAndColorsResourceHeap);
button_group_.addButton(ui_->button_resource_descriptors_, kSettingThemesAndColorsResourceDescriptors);
button_group_.addButton(ui_->button_resource_buffer_, kSettingThemesAndColorsResourceBuffer);
button_group_.addButton(ui_->button_resource_gpu_event_, kSettingThemesAndColorsResourceGpuEvent);
button_group_.addButton(ui_->button_resource_free_space_, kSettingThemesAndColorsResourceFreeSpace);
button_group_.addButton(ui_->button_resource_internal_, kSettingThemesAndColorsResourceInternal);
button_group_.addButton(ui_->button_delta_increase_, kSettingThemesAndColorsDeltaIncrease);
button_group_.addButton(ui_->button_delta_decrease_, kSettingThemesAndColorsDeltaDecrease);
button_group_.addButton(ui_->button_delta_no_change_, kSettingThemesAndColorsDeltaNoChange);
button_group_.addButton(ui_->button_heap_local_, kSettingThemesAndColorsHeapLocal);
button_group_.addButton(ui_->button_heap_invisible_, kSettingThemesAndColorsHeapInvisible);
button_group_.addButton(ui_->button_heap_system_, kSettingThemesAndColorsHeapSystem);
button_group_.addButton(ui_->button_heap_unspecified_, kSettingThemesAndColorsHeapUnspecified);
button_group_.addButton(ui_->button_cpu_mapped_, kSettingThemesAndColorsCpuMapped);
button_group_.addButton(ui_->button_not_cpu_mapped_, kSettingThemesAndColorsNotCpuMapped);
button_group_.addButton(ui_->button_in_preferred_heap_, kSettingThemesAndColorsInPreferredHeap);
button_group_.addButton(ui_->button_not_in_preferred_heap_, kSettingThemesAndColorsNotInPreferredHeap);
button_group_.addButton(ui_->button_aliased_, kSettingThemesAndColorsAliased);
button_group_.addButton(ui_->button_not_aliased_, kSettingThemesAndColorsNotAliased);
button_group_.addButton(ui_->button_resource_history_resource_event_, kSettingThemesAndColorsResourceHistoryResourceEvent);
button_group_.addButton(ui_->button_resource_history_cpu_mapping_, kSettingThemesAndColorsResourceHistoryCpuMapUnmap);
button_group_.addButton(ui_->button_resource_history_residency_, kSettingThemesAndColorsResourceHistoryResidencyUpdate);
button_group_.addButton(ui_->button_resource_history_page_table_, kSettingThemesAndColorsResourceHistoryPageTableUpdate);
button_group_.addButton(ui_->button_resource_history_highlight_, kSettingThemesAndColorsResourceHistoryHighlight);
button_group_.addButton(ui_->button_resource_history_snapshot_, kSettingThemesAndColorsResourceHistorySnapshot);
button_group_.addButton(ui_->button_commit_type_committed_, kSettingThemesAndColorsCommitTypeCommitted);
button_group_.addButton(ui_->button_commit_type_placed_, kSettingThemesAndColorsCommitTypePlaced);
button_group_.addButton(ui_->button_commit_type_virtual_, kSettingThemesAndColorsCommitTypeVirtual);
// Slot/signal connection for various widgets
connect(ui_->color_widget_, &RMVColorPickerWidget::ColorSelected, this, &ThemesAndColorsPane::PickerColorSelected);
connect(&button_group_, SIGNAL(buttonClicked(int)), this, SLOT(ItemButtonClicked(int)));
connect(ui_->default_settings_button_, SIGNAL(clicked(bool)), this, SLOT(DefaultSettingsButtonClicked()));
connect(ui_->default_palette_button_, SIGNAL(clicked(bool)), this, SLOT(DefaultPaletteButtonClicked()));
connect(ui_->spin_box_color_red_, SIGNAL(valueChanged(int)), this, SLOT(RgbValuesChanged()));
connect(ui_->spin_box_color_green_, SIGNAL(valueChanged(int)), this, SLOT(RgbValuesChanged()));
connect(ui_->spin_box_color_blue_, SIGNAL(valueChanged(int)), this, SLOT(RgbValuesChanged()));
connect(ui_->spin_box_color_red_, SIGNAL(valueChanged(int)), ui_->slider_color_red_, SLOT(setValue(int)));
connect(ui_->spin_box_color_green_, SIGNAL(valueChanged(int)), ui_->slider_color_green_, SLOT(setValue(int)));
connect(ui_->spin_box_color_blue_, SIGNAL(valueChanged(int)), ui_->slider_color_blue_, SLOT(setValue(int)));
connect(ui_->slider_color_red_, SIGNAL(valueChanged(int)), ui_->spin_box_color_red_, SLOT(setValue(int)));
connect(ui_->slider_color_green_, SIGNAL(valueChanged(int)), ui_->spin_box_color_green_, SLOT(setValue(int)));
connect(ui_->slider_color_blue_, SIGNAL(valueChanged(int)), ui_->spin_box_color_blue_, SLOT(setValue(int)));
// Set up color picker.
ui_->color_widget_->SetRowAndColumnCount(kPickerRows, kPickerColumns);
ui_->color_widget_->SetPalette(RMVSettings::Get().GetColorPalette());
// Initial checked item.
ui_->button_snapshots_viewed_->setChecked(true);
// Add margins around the color picker label.
ui_->selected_color_label_->setContentsMargins(10, 5, 10, 5);
// Initial refresh.
Refresh();
// Safety measure to guarantee settings values are in range (should prevent crashing
// from an invalid settings file).
for (QAbstractButton* button : button_group_.buttons())
{
int button_id = button_group_.id(button);
int palette_id = GetSettingsPaletteId(button_id);
if (palette_id < 0 || palette_id >= (kPickerRows * kPickerColumns))
{
SetSettingsPaletteId(button_id, 0);
}
else
{
// Invalid settings strings which still produce an integer value in range.
// Should be overwritten with that integer value
SetSettingsPaletteId(button_id, palette_id);
}
}
// Set the cursor to pointing hand cursor for the sliders.
ui_->slider_color_red_->setCursor(Qt::PointingHandCursor);
ui_->slider_color_green_->setCursor(Qt::PointingHandCursor);
ui_->slider_color_blue_->setCursor(Qt::PointingHandCursor);
}
ThemesAndColorsPane::~ThemesAndColorsPane()
{
}
void ThemesAndColorsPane::PickerColorSelected(int palette_id, const QColor& color)
{
Q_UNUSED(color)
int button_id = button_group_.checkedId();
// Set palette id in RMV settings.
SetSettingsPaletteId(button_id, palette_id);
Refresh();
}
void ThemesAndColorsPane::ItemButtonClicked(int button_id)
{
Q_UNUSED(button_id)
Refresh();
}
void ThemesAndColorsPane::DefaultSettingsButtonClicked()
{
// Restore default palette ids.
RMVSettings::Get().RestoreDefaultColors();
Refresh();
}
void ThemesAndColorsPane::DefaultPaletteButtonClicked()
{
// Restore default palette settings.
RMVSettings::Get().RestoreDefaultPalette();
Refresh();
}
void ThemesAndColorsPane::RgbValuesChanged()
{
ColorPalette palette = ui_->color_widget_->GetPalette();
int palette_id = ui_->color_widget_->GetSelectedPaletteId();
// Get color from spinbox values.
QColor color(ui_->spin_box_color_red_->value(), ui_->spin_box_color_green_->value(), ui_->spin_box_color_blue_->value());
// Set the new color in the palette.
palette.SetColor(palette_id, color);
RMVSettings::Get().SetColorPalette(palette);
Refresh();
}
void ThemesAndColorsPane::Refresh()
{
QColor color;
// Set button color values from corresponding RMV settings.
for (QAbstractButton* button : button_group_.buttons())
{
int button_id = button_group_.id(button);
if (button->isChecked())
{
// Select the picker color that matches this buttons color (default to first color).
int palette_id = GetSettingsPaletteId(button_id);
ui_->color_widget_->Select(palette_id);
}
// Get colors.
color = GetSettingsColor(button_id);
static_cast<ThemesAndColorsItemButton*>(button)->SetColor(color);
}
// Set color picker palette.
ui_->color_widget_->SetPalette(RMVSettings::Get().GetColorPalette());
// Set RGB spinbox/slider values.
color = ui_->color_widget_->GetSelectedColor();
ui_->spin_box_color_red_->setValue(color.red());
ui_->spin_box_color_green_->setValue(color.green());
ui_->spin_box_color_blue_->setValue(color.blue());
// Set selected color hex label.
QString color_string = rmv::string_util::ToUpperCase(QString("#") + QString::number(color.rgb(), 16));
QString font_color_string = QString("#") + QString::number(rmv_util::GetTextColorForBackground(color_string).rgb(), 16);
ui_->selected_color_label_->setText("");
ui_->selected_color_label_->setStyleSheet(QString("background-color:%1;color:%2;").arg(color_string).arg(font_color_string));
// Indicate the colors may have changed.
emit RefreshedColors();
}
QColor ThemesAndColorsPane::GetSettingsColor(int button_id)
{
return RMVSettings::Get().GetColorPalette().GetColor(GetSettingsPaletteId(button_id));
}
void ThemesAndColorsPane::SetSettingsPaletteId(int button_id, int palette_id)
{
switch (button_id)
{
case kSettingThemesAndColorsSnapshotViewed:
case kSettingThemesAndColorsSnapshotCompared:
case kSettingThemesAndColorsSnapshotLive:
case kSettingThemesAndColorsSnapshotGenerated:
case kSettingThemesAndColorsSnapshotVma:
case kSettingThemesAndColorsResourceDsBuffer:
case kSettingThemesAndColorsResourceRenderTarget:
case kSettingThemesAndColorsResourceTexture:
case kSettingThemesAndColorsResourceVertexBuffer:
case kSettingThemesAndColorsResourceIndexBuffer:
case kSettingThemesAndColorsResourceUav:
case kSettingThemesAndColorsResourceShaderPipeline:
case kSettingThemesAndColorsResourceCommandBuffer:
case kSettingThemesAndColorsResourceHeap:
case kSettingThemesAndColorsResourceDescriptors:
case kSettingThemesAndColorsResourceBuffer:
case kSettingThemesAndColorsResourceGpuEvent:
case kSettingThemesAndColorsResourceFreeSpace:
case kSettingThemesAndColorsResourceInternal:
case kSettingThemesAndColorsDeltaIncrease:
case kSettingThemesAndColorsDeltaDecrease:
case kSettingThemesAndColorsDeltaNoChange:
case kSettingThemesAndColorsHeapLocal:
case kSettingThemesAndColorsHeapInvisible:
case kSettingThemesAndColorsHeapSystem:
case kSettingThemesAndColorsHeapUnspecified:
case kSettingThemesAndColorsCpuMapped:
case kSettingThemesAndColorsNotCpuMapped:
case kSettingThemesAndColorsInPreferredHeap:
case kSettingThemesAndColorsNotInPreferredHeap:
case kSettingThemesAndColorsAliased:
case kSettingThemesAndColorsNotAliased:
case kSettingThemesAndColorsResourceHistoryResourceEvent:
case kSettingThemesAndColorsResourceHistoryCpuMapUnmap:
case kSettingThemesAndColorsResourceHistoryResidencyUpdate:
case kSettingThemesAndColorsResourceHistoryPageTableUpdate:
case kSettingThemesAndColorsResourceHistoryHighlight:
case kSettingThemesAndColorsResourceHistorySnapshot:
case kSettingThemesAndColorsCommitTypeCommitted:
case kSettingThemesAndColorsCommitTypePlaced:
case kSettingThemesAndColorsCommitTypeVirtual:
RMVSettings::Get().SetPaletteId(static_cast<RMVSettingID>(button_id), palette_id);
break;
default:
DebugWindow::DbgMsg("Warning: Hit unused default switch case.");
break;
}
}
int ThemesAndColorsPane::GetSettingsPaletteId(int button_id)
{
switch (button_id)
{
case kSettingThemesAndColorsSnapshotViewed:
case kSettingThemesAndColorsSnapshotCompared:
case kSettingThemesAndColorsSnapshotLive:
case kSettingThemesAndColorsSnapshotGenerated:
case kSettingThemesAndColorsSnapshotVma:
case kSettingThemesAndColorsResourceDsBuffer:
case kSettingThemesAndColorsResourceRenderTarget:
case kSettingThemesAndColorsResourceTexture:
case kSettingThemesAndColorsResourceVertexBuffer:
case kSettingThemesAndColorsResourceIndexBuffer:
case kSettingThemesAndColorsResourceUav:
case kSettingThemesAndColorsResourceShaderPipeline:
case kSettingThemesAndColorsResourceCommandBuffer:
case kSettingThemesAndColorsResourceHeap:
case kSettingThemesAndColorsResourceDescriptors:
case kSettingThemesAndColorsResourceBuffer:
case kSettingThemesAndColorsResourceGpuEvent:
case kSettingThemesAndColorsResourceFreeSpace:
case kSettingThemesAndColorsResourceInternal:
case kSettingThemesAndColorsDeltaIncrease:
case kSettingThemesAndColorsDeltaDecrease:
case kSettingThemesAndColorsDeltaNoChange:
case kSettingThemesAndColorsHeapLocal:
case kSettingThemesAndColorsHeapInvisible:
case kSettingThemesAndColorsHeapSystem:
case kSettingThemesAndColorsHeapUnspecified:
case kSettingThemesAndColorsCpuMapped:
case kSettingThemesAndColorsNotCpuMapped:
case kSettingThemesAndColorsInPreferredHeap:
case kSettingThemesAndColorsNotInPreferredHeap:
case kSettingThemesAndColorsAliased:
case kSettingThemesAndColorsNotAliased:
case kSettingThemesAndColorsResourceHistoryResourceEvent:
case kSettingThemesAndColorsResourceHistoryCpuMapUnmap:
case kSettingThemesAndColorsResourceHistoryResidencyUpdate:
case kSettingThemesAndColorsResourceHistoryPageTableUpdate:
case kSettingThemesAndColorsResourceHistoryHighlight:
case kSettingThemesAndColorsResourceHistorySnapshot:
case kSettingThemesAndColorsCommitTypeCommitted:
case kSettingThemesAndColorsCommitTypePlaced:
case kSettingThemesAndColorsCommitTypeVirtual:
return RMVSettings::Get().GetPaletteId(static_cast<RMVSettingID>(button_id));
default:
return -1;
}
}
| [
"Anthony.Hosier@amd.com"
] | Anthony.Hosier@amd.com |
58b02fdde66bfdba273412d696b69d6ddd48db24 | 8c17304c73e1adc9b3857b2b532106e5ecd78cf2 | /BinaryIMST_Library/src/include/utils/IOUtils.hpp | b1b3e11ad2ff65b6fdb62a1cb80070f5f9a8de37 | [
"Apache-2.0"
] | permissive | PWrGitHub194238/BinaryRIMST | 42feaba5006249b53707c5a9d9a5cf70dceea619 | 53490c10580fd4ad61c9234b82b3140c5cce5de0 | refs/heads/master | 2020-12-11T06:13:30.761901 | 2016-05-02T22:00:25 | 2016-05-02T22:00:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,131 | hpp | /*
* IOUtils.hpp
*
* Created on: 26 lut 2016
* Author: tomasz
*/
#ifndef SRC_INCLUDE_UTILS_IOUTILS_HPP_
#define SRC_INCLUDE_UTILS_IOUTILS_HPP_
#include <rapidjson/document.h>
#include <rapidjson/rapidjson.h>
#include <cstdio>
#include <iostream>
#include <memory>
#include <string>
#include "../typedefs/primitive.hpp"
#include "enums/GraphVizEngine.hpp"
#include "enums/InputFormat.hpp"
#include "enums/InputMode.hpp"
#include "enums/OutputFormat.hpp"
#include "GraphVizUtils.hpp"
#include "../exp/IOExceptions.hpp"
class GraphEdgeCostsIF;
class EdgeIF;
class VertexIF;
class GraphIF;
namespace IOUtils {
namespace impl {
extern const unsigned short MAX_CHARS_IN_LINE;
extern const long MAX_STREAM_SIZE;
extern const short BUFFER_SIZE;
namespace GR {
extern const char COMMENT_LINE;
extern const unsigned short COMMENT_LINE_NUMERIC;
extern const char* COMMENT_LINE_PATTERN;
extern const unsigned short COMMENT_LINE_PATTERN_ARGS;
extern const char PROBLEM_DEF_LINE;
extern const unsigned short PROBLEM_DEF_LINE_NUMERIC;
extern const std::unique_ptr<char[]> PROBLEM_DEF_LINE_PATTERN;
extern const unsigned short PROBLEM_DEF_LINE_PATTERN_ARGS;
extern const char ARC_DEF_LINE;
extern const unsigned short ARC_DEF_LINE_NUMERIC;
extern const std::unique_ptr<char[]> ARC_DEF_LINE_PATTERN;
extern const unsigned short ARC_DEF_LINE_PATTERN_ARGS;
} // namespace GR
namespace VA {
extern const char* VERTEX_LIST_KEY;
extern const char* EDGE_LIST_KEY;
extern const char* EDGE_VERTEX_A_KEY;
extern const char* EDGE_VERTEX_B_KEY;
extern const char* EDGE_COST_KEY;
} // namespace VA
namespace DOT {
extern const char* GRAPH_DEF;
extern const char* DIR;
extern const char* LABEL;
extern const char* WEIGHT;
extern const char* LEN;
extern const char* EDGE_UNDIR;
extern const char* ENDLN;
} // namespace DOT
} // namespace impl
} // namespace IOUtils
namespace InputUtils {
GraphIF * readGraph(char const * filename, InputFormat inputFormat,
InputMode inputMode) throw (IOExceptions::FileNotFountException);
GraphEdgeCostsIF * readCosts(char const * filename, InputFormat inputFormat,
InputMode inputMode, std::string scenarioName)
throw (IOExceptions::FileNotFountException);
GraphEdgeCostsIF * readCosts(char const * filename, InputFormat inputFormat,
InputMode inputMode) throw (IOExceptions::FileNotFountException);
namespace impl {
namespace VA {
VertexIdx getVertexIdxFromValue(const rapidjson::Value& vertexIdx);
EdgeCost getEdgeCostFromValue(const rapidjson::Value& edgeCost);
} // namespace VA
namespace RAM {
GraphIF * readGraph(char const * const filename, InputFormat inputFormat)
throw (IOExceptions::FileNotFountException);
GraphEdgeCostsIF * readCosts(char const * const filename,
InputFormat inputFormat, std::string const & scenarioName)
throw (IOExceptions::FileNotFountException);
namespace GR {
GraphIF * readGraph(char const * const filename)
throw (IOExceptions::FileNotFountException);
GraphEdgeCostsIF * readCosts(char const * const filename,
std::string const & scenarioName)
throw (IOExceptions::FileNotFountException);
GraphIF * createGraph(char * const buffer)
throw (IOExceptions::InvalidProblemRead);
EdgeCount getNumberOfEdgeCosts(char * const buffer)
throw (IOExceptions::InvalidProblemRead);
void addEdge(EdgeIdx const edgeIdx, char * const buffer, GraphIF * const graph)
throw (IOExceptions::InvalidArcRead);
EdgeCost getCost(char * const buffer) throw (IOExceptions::InvalidArcRead);
} // namespace GR
namespace VA {
GraphIF * readGraph(char const * const filename)
throw (IOExceptions::FileNotFountException);
GraphEdgeCostsIF * readCosts(char const * const filename,
std::string const & scenarioName)
throw (IOExceptions::FileNotFountException);
GraphIF * createGraph(rapidjson::Value & vertexList,
rapidjson::SizeType const numberOfEdges)
throw (IOExceptions::InvalidProblemRead);
void addEdge(EdgeIdx const edgeIdx, rapidjson::Value::ConstMemberIterator& edge,
GraphIF * const graph) throw (IOExceptions::InvalidArcRead);
EdgeCost getCost(rapidjson::Value::ConstMemberIterator& edge)
throw (IOExceptions::InvalidArcRead);
} // namespace VA
} // namespace RAM
namespace HDD {
GraphIF * readGraph(char const * const filename, InputFormat inputFormat)
throw (IOExceptions::FileNotFountException);
GraphEdgeCostsIF * readCosts(char const * const filename,
InputFormat inputFormat, std::string const & scenarioName)
throw (IOExceptions::FileNotFountException);
namespace GR {
GraphIF * readGraph(char const * const filename)
throw (IOExceptions::FileNotFountException);
GraphEdgeCostsIF * readCosts(char const * const filename,
std::string const & scenarioName)
throw (IOExceptions::FileNotFountException);
GraphIF * createGraph(FILE * const dataFile)
throw (IOExceptions::InvalidProblemRead);
EdgeCount getNumberOfEdgeCosts(FILE * const dataFile)
throw (IOExceptions::InvalidProblemRead);
void addEdge(EdgeIdx const edgeIdx, FILE * const dataFile,
GraphIF * const graph) throw (IOExceptions::InvalidArcRead);
EdgeCost getCost(FILE * const dataFile) throw (IOExceptions::InvalidArcRead);
} // namespace GR
namespace VA {
GraphIF * readGraph(char const * const filename)
throw (IOExceptions::FileNotFountException);
GraphEdgeCostsIF * readCosts(char const * const filename,
std::string const & scenarioName)
throw (IOExceptions::FileNotFountException);
GraphIF * createGraph(rapidjson::Value& vertexList,
rapidjson::SizeType const numberOfEdges)
throw (IOExceptions::InvalidProblemRead);
void addEdge(EdgeIdx const edgeIdx, rapidjson::Value::ConstMemberIterator& edge,
GraphIF * const graph) throw (IOExceptions::InvalidArcRead);
EdgeCost getCost(rapidjson::Value::ConstMemberIterator& edge)
throw (IOExceptions::InvalidArcRead);
} // namespace VA
} // namespace HDD
} // namespace impl
} // namespace InputUtils
namespace OutputUtils {
void exportGraph(GraphIF* const graph, char const * exportPath,
OutputFormat const outputFormat, GraphVizEngine const layoutEngine,
GraphVizUtils::GraphDimmention graphMaxWidth,
GraphVizUtils::GraphDimmention graphMaxHeight)
throw (IOExceptions::InvalidProblemWrite,
IOExceptions::InvalidArcWrite);
void exportGraph(GraphIF* const graph, char const * exportPath,
OutputFormat const outputFormat)
throw (IOExceptions::InvalidProblemWrite,
IOExceptions::InvalidArcWrite);
namespace impl {
namespace GR {
void exportGraph(GraphIF* const graph, char const * exportPath)
throw (IOExceptions::InvalidProblemWrite, IOExceptions::InvalidArcWrite);
} // namespace GR
namespace VA {
void exportGraph(GraphIF* const graph, char const * exportPath,
GraphVizEngine const layoutEngine,
GraphVizUtils::GraphDimmention graphMaxWidth,
GraphVizUtils::GraphDimmention graphMaxHeight);
void exportGraph(GraphIF* const graph, char const * exportPath);
rapidjson::Document getVertexSetJson(
rapidjson::Document::AllocatorType& allocator, GraphIF * const graph,
GraphVizUtils::VerticesCoordinates verticesCoordinates);
rapidjson::Document getVertexSetJson(
rapidjson::Document::AllocatorType& allocator, GraphIF * const graph);
rapidjson::Document getEdgeSetJson(
rapidjson::Document::AllocatorType& allocator, GraphIF * const graph);
rapidjson::Document getVertexJson(rapidjson::Document& vertexJsonDoc,
rapidjson::Document::AllocatorType& allocator, VertexIF * const vertex,
GraphVizUtils::VertexCoordinates vertexCoordinates);
rapidjson::Document getVertexJson(rapidjson::Document& vertexJsonDoc,
rapidjson::Document::AllocatorType& allocator, VertexIF * const vertex);
rapidjson::Document getEdgeJson(rapidjson::Document& vertexJsonDoc,
rapidjson::Document::AllocatorType& allocator, EdgeIF * const edge);
} // namespace VA
namespace DOT {
void exportGraph(GraphIF* const graph, char const * exportPath);
std::string exportGraph(GraphIF* const graph);
void exportGraphToStream(GraphIF* const graph, std::ostream& stream);
} // namespace DOT
} // namespace impl
} // namespace OutputUtils
#endif /* SRC_INCLUDE_UTILS_IOUTILS_HPP_ */
| [
"194238@student.pwr.wroc.pl"
] | 194238@student.pwr.wroc.pl |
b771645f9be702b3239e9f0090cadef4a1dd3b26 | 5bb6685e574f3320284a6ce493ab72613e17f953 | /CustomIterator.h | 99d6091e91ba6628e21b7dd0537323f339d28752 | [] | no_license | alby177/DataStructures | c71d54fab90df3aa5da98a052fd83876d2dbadc2 | 94a72efeb30d557bb5cde1d5e97744266f480de3 | refs/heads/master | 2023-01-14T02:09:46.549488 | 2020-11-15T16:24:39 | 2020-11-15T16:24:39 | 312,709,759 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,862 | h | // Forward declaration for template friend operator
template <class T> class CustomIterator;
template <class T> std::ostream &operator<<(std::ostream &str, const CustomIterator<T> &it);
template <class T>
class CustomIterator
{
public:
CustomIterator (T *ptr);
bool operator== (const CustomIterator<T> &other);
bool operator!= (const CustomIterator<T> &other);
bool hasNext ();
CustomIterator<T> &next ();
CustomIterator<T> &operator++ ();
CustomIterator<T> operator++ (int);
T operator* ();
friend std::ostream &operator<< <> (std::ostream &str, const CustomIterator<T> &it);
private:
T *m_ptr;
};
template <class T>
CustomIterator<T>::CustomIterator(T *ptr) : m_ptr(ptr)
{
}
template <class T>
bool CustomIterator<T>::operator==(const CustomIterator<T> &other)
{
return m_ptr == other.m_ptr;
}
template <class T>
bool CustomIterator<T>::operator!=(const CustomIterator<T> &other)
{
return m_ptr != other.m_ptr;
}
template <class T>
bool CustomIterator<T>::hasNext()
{
return m_ptr->hasNext();
}
template <class T>
CustomIterator<T> &CustomIterator<T>::next()
{
if(m_ptr->hasNext())
m_ptr = m_ptr->next();
return (*this);
}
template <class T>
CustomIterator<T> &CustomIterator<T>::operator++()
{
return next();
}
template <class T>
CustomIterator<T> CustomIterator<T>::operator++(int)
{
CustomIterator<T> tmp = CustomIterator<T>(m_ptr);
m_ptr = m_ptr->next();
return tmp;
}
template <class T>
T CustomIterator<T>::operator*()
{
return *m_ptr;
}
template <class T>
std::ostream &operator<<(std::ostream &str, const CustomIterator<T> &it)
{
str << it.m_ptr;
return str;
} | [
"gotta.alberto@gmail.com"
] | gotta.alberto@gmail.com |
be953e6308d24e11a0dfdb0a58592c48a679893b | 5888c735ac5c17601969ebe215fd8f95d0437080 | /All code of my PC/code_forces(143)a.cpp | 2a9ecace02eb139c68d1d9971207b39ce606abce | [] | no_license | asad14053/My-Online-Judge-Solution | 8854dc2140ba7196b48eed23e48f0dcdb8aec83f | 20a72ea99fc8237ae90f3cad7624224be8ed4c6c | refs/heads/master | 2021-06-16T10:41:34.247149 | 2019-07-30T14:44:09 | 2019-07-30T14:44:09 | 40,115,430 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
int c=0;
while(t--)
{
bool a;
int sum=0;
for(int i=0; i<3; i++)
{
cin>>a;
sum+=a;
}
if(sum>=2)
c++;
}
cout<<c<<endl;
return 0;
}
| [
"asad14053@users.noreply.github.com"
] | asad14053@users.noreply.github.com |
b25dd9dfe78343e71f49477e7d84541d79ea7d6f | 107d79f2c1802a3ff66d300d5d1ab2d413bac375 | /src/eepp/graphics/ctextureloader.cpp | e5524a09a561827bf1b63cc5d4a7fb8bd6ff59d5 | [
"MIT"
] | permissive | weimingtom/eepp | 2030ab0b2a6231358f8433304f90611499b6461e | dd672ff0e108ae1e08449ca918dc144018fb4ba4 | refs/heads/master | 2021-01-10T01:36:39.879179 | 2014-06-02T02:46:33 | 2014-06-02T02:46:33 | 46,509,734 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,251 | cpp | #include <eepp/graphics/ctextureloader.hpp>
#include <eepp/graphics/ctexture.hpp>
#include <eepp/graphics/ctexturefactory.hpp>
#include <eepp/graphics/renderer/cgl.hpp>
#include <eepp/system/ciostreamfile.hpp>
#include <eepp/helper/SOIL2/src/SOIL2/stb_image.h>
#include <eepp/helper/SOIL2/src/SOIL2/SOIL2.h>
#include <eepp/helper/jpeg-compressor/jpgd.h>
#include <eepp/window/cengine.hpp>
using namespace EE::Window;
#define TEX_LT_PATH (1)
#define TEX_LT_MEM (2)
#define TEX_LT_PACK (3)
#define TEX_LT_PIXELS (4)
#define TEX_LT_STREAM (5)
namespace EE { namespace Graphics {
namespace IOCb
{
// stb_image callbacks that operate on a cIOStream
int read(void* user, char* data, int size)
{
cIOStream * stream = static_cast<cIOStream*>(user);
return static_cast<int>(stream->Read(data, size));
}
void skip(void* user, unsigned int size)
{
cIOStream * stream = static_cast<cIOStream*>(user);
stream->Seek(stream->Tell() + size);
}
int eof(void* user)
{
cIOStream* stream = static_cast<cIOStream*>(user);
return stream->Tell() >= stream->GetSize();
}
}
namespace jpeg
{
class jpeg_decoder_stream_steam : public jpgd::jpeg_decoder_stream {
public:
cIOStream * mStream;
jpeg_decoder_stream_steam( cIOStream * stream ) :
mStream( stream )
{}
virtual ~jpeg_decoder_stream_steam() {}
virtual int read(jpgd::uint8 *pBuf, int max_bytes_to_read, bool *pEOF_flag) {
return mStream->Read( (char*)pBuf, max_bytes_to_read );
}
};
}
cTextureLoader::cTextureLoader( cIOStream& Stream,
const bool& Mipmap,
const EE_CLAMP_MODE& ClampMode,
const bool& CompressTexture,
const bool& KeepLocalCopy
) : cObjectLoader( cObjectLoader::TextureLoader ),
mLoadType(TEX_LT_STREAM),
mPixels(NULL),
mTexId(0),
mImgWidth(0),
mImgHeight(0),
mFilepath(""),
mWidth(0),
mHeight(0),
mMipmap(Mipmap),
mChannels(0),
mClampMode(ClampMode),
mCompressTexture(CompressTexture),
mLocalCopy(KeepLocalCopy),
mPack(NULL),
mStream(&Stream),
mImagePtr(NULL),
mSize(0),
mColorKey(NULL),
mTexLoaded(false),
mDirectUpload(false),
mImgType(STBI_unknown),
mIsCompressed(0)
{
}
cTextureLoader::cTextureLoader( const std::string& Filepath,
const bool& Mipmap,
const EE_CLAMP_MODE& ClampMode,
const bool& CompressTexture,
const bool& KeepLocalCopy
) : cObjectLoader( cObjectLoader::TextureLoader ),
mLoadType(TEX_LT_PATH),
mPixels(NULL),
mTexId(0),
mImgWidth(0),
mImgHeight(0),
mFilepath(Filepath),
mWidth(0),
mHeight(0),
mMipmap(Mipmap),
mChannels(0),
mClampMode(ClampMode),
mCompressTexture(CompressTexture),
mLocalCopy(KeepLocalCopy),
mPack(NULL),
mStream(NULL),
mImagePtr(NULL),
mSize(0),
mColorKey(NULL),
mTexLoaded(false),
mDirectUpload(false),
mImgType(STBI_unknown),
mIsCompressed(0)
{
}
cTextureLoader::cTextureLoader( const unsigned char * ImagePtr,
const eeUint& Size,
const bool& Mipmap,
const EE_CLAMP_MODE& ClampMode,
const bool& CompressTexture,
const bool& KeepLocalCopy
) : cObjectLoader( cObjectLoader::TextureLoader ),
mLoadType(TEX_LT_MEM),
mPixels(NULL),
mTexId(0),
mImgWidth(0),
mImgHeight(0),
mFilepath(""),
mWidth(0),
mHeight(0),
mMipmap(Mipmap),
mChannels(0),
mClampMode(ClampMode),
mCompressTexture(CompressTexture),
mLocalCopy(KeepLocalCopy),
mPack(NULL),
mStream(NULL),
mImagePtr(ImagePtr),
mSize(Size),
mColorKey(NULL),
mTexLoaded(false),
mDirectUpload(false),
mImgType(STBI_unknown),
mIsCompressed(0)
{
}
cTextureLoader::cTextureLoader( cPack * Pack,
const std::string& FilePackPath,
const bool& Mipmap ,
const EE_CLAMP_MODE& ClampMode,
const bool& CompressTexture,
const bool& KeepLocalCopy
) : cObjectLoader( cObjectLoader::TextureLoader ),
mLoadType(TEX_LT_PACK),
mPixels(NULL),
mTexId(0),
mImgWidth(0),
mImgHeight(0),
mFilepath(FilePackPath),
mWidth(0),
mHeight(0),
mMipmap(Mipmap),
mChannels(0),
mClampMode(ClampMode),
mCompressTexture(CompressTexture),
mLocalCopy(KeepLocalCopy),
mPack(Pack),
mStream(NULL),
mImagePtr(NULL),
mSize(0),
mColorKey(NULL),
mTexLoaded(false),
mDirectUpload(false),
mImgType(STBI_unknown),
mIsCompressed(0)
{
}
cTextureLoader::cTextureLoader( const unsigned char * Pixels,
const eeUint& Width,
const eeUint& Height,
const eeUint& Channels,
const bool& Mipmap,
const EE_CLAMP_MODE& ClampMode,
const bool& CompressTexture,
const bool& KeepLocalCopy,
const std::string& FileName
) : cObjectLoader( cObjectLoader::TextureLoader ),
mLoadType(TEX_LT_PIXELS),
mPixels( const_cast<unsigned char *> ( Pixels ) ),
mTexId(0),
mImgWidth(Width),
mImgHeight(Height),
mFilepath(FileName),
mWidth(0),
mHeight(0),
mMipmap(Mipmap),
mChannels(Channels),
mClampMode(ClampMode),
mCompressTexture(CompressTexture),
mLocalCopy(KeepLocalCopy),
mPack(NULL),
mStream(NULL),
mImagePtr(NULL),
mSize(0),
mColorKey(NULL),
mTexLoaded(false),
mDirectUpload(false),
mImgType(STBI_unknown),
mIsCompressed(0)
{
}
cTextureLoader::~cTextureLoader() {
eeSAFE_DELETE( mColorKey );
if ( TEX_LT_PIXELS != mLoadType )
eeSAFE_FREE( mPixels );
}
void cTextureLoader::Start() {
cObjectLoader::Start();
mTE.Restart();
if ( TEX_LT_PATH == mLoadType )
LoadFromPath();
else if ( TEX_LT_MEM == mLoadType )
LoadFromMemory();
else if ( TEX_LT_PACK == mLoadType )
LoadFromPack();
else if ( TEX_LT_STREAM == mLoadType )
LoadFromStream();
mTexLoaded = true;
if ( !mThreaded || ( cEngine::instance()->IsSharedGLContextEnabled() && cEngine::instance()->GetCurrentWindow()->IsThreadedGLContext() ) ) {
LoadFromPixels();
}
}
void cTextureLoader::LoadFile() {
cIOStreamFile fs( mFilepath , std::ios::in | std::ios::binary );
mSize = FileSystem::FileSize( mFilepath );
mPixels = (Uint8*) eeMalloc( mSize );
fs.Read( reinterpret_cast<char*> ( mPixels ), mSize );
}
void cTextureLoader::LoadFromPath() {
if ( FileSystem::FileExists( mFilepath ) ) {
mImgType = stbi_test( mFilepath.c_str() );
if ( STBI_dds == mImgType && GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) {
LoadFile();
mDirectUpload = true;
stbi_dds_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed );
} else if ( STBI_pvr == mImgType &&
stbi_pvr_info_from_path( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) &&
( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) )
{
// If the PVR is valid, and the pvrtc extension is present or it's not compressed ( so it doesn't need the extension )
// means that it can be uploaded directly to the GPU.
LoadFile();
mDirectUpload = true;
} else if ( STBI_pkm == mImgType && GLi->IsExtension( EEGL_OES_compressed_ETC1_RGB8_texture ) ) {
LoadFile();
mIsCompressed = mDirectUpload = true;
stbi_pkm_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels );
} else {
if ( mCompressTexture ) {
mSize = FileSystem::FileSize( mFilepath );
}
mPixels = stbi_load( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, ( NULL != mColorKey ) ? STBI_rgb_alpha : STBI_default );
}
if ( NULL == mPixels ) {
eePRINTL( "Filed to load: %s. Reason: %s", mFilepath.c_str(), stbi_failure_reason() );
if ( STBI_jpeg == mImgType ) {
mPixels = jpgd::decompress_jpeg_image_from_file( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, 3 );
if ( NULL != mPixels ) {
eePRINTL( "Loaded: %s using jpeg-compressor.", mFilepath.c_str() );
}
}
}
} else if ( cPackManager::instance()->FallbackToPacks() ) {
mPack = cPackManager::instance()->Exists( mFilepath );
if ( NULL != mPack ) {
mLoadType = TEX_LT_PACK;
LoadFromPack();
}
}
}
void cTextureLoader::LoadFromPack() {
SafeDataPointer PData;
if ( NULL != mPack && mPack->IsOpen() && mPack->ExtractFileToMemory( mFilepath, PData ) ) {
mImagePtr = PData.Data;
mSize = PData.DataSize;
LoadFromMemory();
}
}
void cTextureLoader::LoadFromMemory() {
mImgType = stbi_test_from_memory( mImagePtr, mSize );
if ( STBI_dds == mImgType && GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) {
mPixels = (Uint8*) eeMalloc( mSize );
memcpy( mPixels, mImagePtr, mSize );
stbi_dds_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed );
mDirectUpload = true;
} else if ( STBI_pvr == mImgType &&
stbi_pvr_info_from_memory( mImagePtr, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) &&
( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) )
{
mPixels = (Uint8*) eeMalloc( mSize );
memcpy( mPixels, mImagePtr, mSize );
mDirectUpload = true;
} else if ( STBI_pkm == mImgType && GLi->IsExtension( EEGL_OES_compressed_ETC1_RGB8_texture ) ) {
mPixels = (Uint8*) eeMalloc( mSize );
memcpy( mPixels, mImagePtr, mSize );
stbi_pkm_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels );
mIsCompressed = mDirectUpload = true;
} else {
mPixels = stbi_load_from_memory( mImagePtr, mSize, &mImgWidth, &mImgHeight, &mChannels, ( NULL != mColorKey ) ? STBI_rgb_alpha : STBI_default );
}
if ( NULL == mPixels ) {
eePRINTL( "Filed to load image from memory. Reason: %s", stbi_failure_reason() );
if ( STBI_jpeg == mImgType ) {
mPixels = jpgd::decompress_jpeg_image_from_memory( mImagePtr, mSize, &mImgWidth, &mImgHeight, &mChannels, 3 );
if ( NULL != mPixels ) {
eePRINTL( "Loaded: image using jpeg-compressor." );
}
}
}
}
void cTextureLoader::LoadFromStream() {
if ( mStream->IsOpen() ) {
mSize = mStream->GetSize();
stbi_io_callbacks callbacks;
callbacks.read = &IOCb::read;
callbacks.skip = &IOCb::skip;
callbacks.eof = &IOCb::eof;
mImgType = stbi_test_from_callbacks( &callbacks, mStream );
if ( STBI_dds == mImgType && GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) {
mSize = mStream->GetSize();
mPixels = (Uint8*) eeMalloc( mSize );
mStream->Seek( 0 );
mStream->Read( reinterpret_cast<char*> ( mPixels ), mSize );
mStream->Seek( 0 );
stbi_dds_info_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed );
mStream->Seek( 0 );
mDirectUpload = true;
} else if ( STBI_pvr == mImgType &&
stbi_pvr_info_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) &&
( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) )
{
mSize = mStream->GetSize();
mPixels = (Uint8*) eeMalloc( mSize );
mStream->Seek( 0 );
mStream->Read( reinterpret_cast<char*> ( mPixels ), mSize );
mStream->Seek( 0 );
mDirectUpload = true;
} else if ( STBI_pkm == mImgType && GLi->IsExtension( EEGL_OES_compressed_ETC1_RGB8_texture ) ) {
mSize = mStream->GetSize();
mPixels = (Uint8*) eeMalloc( mSize );
mStream->Seek( 0 );
mStream->Read( reinterpret_cast<char*> ( mPixels ), mSize );
mStream->Seek( 0 );
stbi_pkm_info_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels );
mStream->Seek( 0 );
mIsCompressed = mDirectUpload = true;
} else {
mStream->Seek( 0 );
mPixels = stbi_load_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels, ( NULL != mColorKey ) ? STBI_rgb_alpha : STBI_default );
mStream->Seek( 0 );
}
if ( NULL == mPixels ) {
eePRINTL( stbi_failure_reason() );
if ( STBI_jpeg == mImgType ) {
jpeg::jpeg_decoder_stream_steam stream( mStream );
mPixels = jpgd::decompress_jpeg_image_from_stream( &stream, &mImgWidth, &mImgHeight, &mChannels, 3 );
mStream->Seek( 0 );
}
}
}
}
void cTextureLoader::LoadFromPixels() {
if ( !mLoaded && mTexLoaded ) {
Uint32 tTexId = 0;
if ( NULL != mPixels ) {
int width = mImgWidth;
int height = mImgHeight;
Uint32 flags = mMipmap ? SOIL_FLAG_MIPMAPS | SOIL_FLAG_GL_MIPMAPS : 0;
flags = ( mClampMode == CLAMP_REPEAT) ? (flags | SOIL_FLAG_TEXTURE_REPEATS) : flags;
flags = ( mCompressTexture ) ? ( flags | SOIL_FLAG_COMPRESS_TO_DXT ) : flags;
bool ForceGLThreaded = cThread::GetCurrentThreadId() != cEngine::instance()->GetMainThreadId();
if ( ( mThreaded || ForceGLThreaded ) &&
( ForceGLThreaded || cEngine::instance()->IsSharedGLContextEnabled() ) &&
cEngine::instance()->GetCurrentWindow()->IsThreadedGLContext() )
{
cEngine::instance()->GetCurrentWindow()->SetGLContextThread();
}
GLint PreviousTexture;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture);
if ( mDirectUpload ) {
if ( STBI_dds == mImgType ) {
tTexId = SOIL_direct_load_DDS_from_memory( mPixels, mSize, SOIL_CREATE_NEW_ID, flags, 0 );
} else if ( STBI_pvr == mImgType ) {
tTexId = SOIL_direct_load_PVR_from_memory( mPixels, mSize, SOIL_CREATE_NEW_ID, flags, 0 );
} else if ( STBI_pkm == mImgType ) {
tTexId = SOIL_direct_load_ETC1_from_memory( mPixels, mSize, SOIL_CREATE_NEW_ID, flags );
}
} else {
if ( NULL != mColorKey ) {
mChannels = STBI_rgb_alpha;
cImage * tImg = eeNew ( cImage, ( mPixels, mImgWidth, mImgHeight, mChannels ) );
tImg->CreateMaskFromColor( eeColorA( mColorKey->R(), mColorKey->G(), mColorKey->B(), 255 ), 0 );
tImg->AvoidFreeImage( true );
eeSAFE_DELETE( tImg );
}
tTexId = SOIL_create_OGL_texture( mPixels, &width, &height, mChannels, SOIL_CREATE_NEW_ID, flags );
}
GLi->BindTexture( GL_TEXTURE_2D, PreviousTexture );
if ( ( mThreaded || ForceGLThreaded ) &&
( ForceGLThreaded || cEngine::instance()->IsSharedGLContextEnabled() ) &&
cEngine::instance()->GetCurrentWindow()->IsThreadedGLContext() )
{
cEngine::instance()->GetCurrentWindow()->UnsetGLContextThread();
}
if ( tTexId ) {
mWidth = width;
mHeight = height;
if ( ( ( STBI_dds == mImgType && mIsCompressed ) || mCompressTexture ) && mSize > 128 ) {
mSize -= 128; // Remove the DDS header size
} else if ( STBI_pvr == mImgType && mIsCompressed && mSize > 52 ) {
mSize -= 52; // Remove the PVR header size
} else if ( STBI_pkm == mImgType && mIsCompressed && mSize > 16 ) {
mSize -= 16; // Remove the PKM header size
} else {
mSize = mWidth * mHeight * mChannels;
if( mMipmap ) {
int w = mWidth;
int h = mHeight;
while( w > 2 && h > 2 ) {
w>>=1;
h>>=1;
mSize += ( w * h * mChannels );
}
}
}
mTexId = cTextureFactory::instance()->PushTexture( mFilepath, tTexId, width, height, mImgWidth, mImgHeight, mMipmap, mChannels, mClampMode, mCompressTexture || mIsCompressed, mLocalCopy, mSize );
eePRINTL( "Texture %s loaded in %4.3f ms.", mFilepath.c_str(), mTE.Elapsed().AsMilliseconds() );
} else {
eePRINTL( "Failed to create texture. Reason: %s", SOIL_last_result() );
}
if ( TEX_LT_PIXELS != mLoadType ) {
if ( mDirectUpload ) {
eeFree( mPixels );
} else if ( NULL != mPixels ) {
free( mPixels );
}
}
mPixels = NULL;
} else {
if ( NULL != stbi_failure_reason() ) {
eePRINTL( stbi_failure_reason() );
} else {
std::string failText( "Texture " + mFilepath + " failed to load" );
failText += ( NULL != mPack ) ? ( " from Pack " + mPack->GetPackPath() + "." ) : ".";
eePRINTL( failText.c_str() );
}
}
SetLoaded();
}
}
void cTextureLoader::Update() {
if ( !( cEngine::instance()->IsSharedGLContextEnabled() && cEngine::instance()->GetCurrentWindow()->IsThreadedGLContext() ) ) {
LoadFromPixels();
}
}
const Uint32& cTextureLoader::Id() const {
return mTexId;
}
void cTextureLoader::SetColorKey( eeColor Color ) {
eeSAFE_DELETE( mColorKey );
mColorKey = eeNew( eeColor, ( Color.R(), Color.G(), Color.B() ) );
}
const std::string& cTextureLoader::Filepath() const {
return mFilepath;
}
cTexture * cTextureLoader::GetTexture() const {
if ( 0 != mTexId )
return cTextureFactory::instance()->GetTexture( mTexId );
return NULL;
}
void cTextureLoader::Unload() {
if ( mLoaded ) {
cTextureFactory::instance()->Remove( mTexId );
Reset();
}
}
void cTextureLoader::Reset() {
cObjectLoader::Reset();
mPixels = NULL;
mTexId = 0;
mImgWidth = 0;
mImgHeight = 0;
mWidth = 0;
mHeight = 0;
mChannels = 0;
mSize = 0;
mTexLoaded = false;
mDirectUpload = false;
mImgType = STBI_unknown;
mIsCompressed = 0;
}
}}
| [
"spartanj@gmail.com"
] | spartanj@gmail.com |
23a59fc0ebb6bda4aa0f64ab44106d3e876258ed | 1a1b5f542d964cb4444899872879f7ca37de187a | /src/sendalert.cpp | 70dd254842a75b9658d9f01a409118ee28e781dc | [
"MIT"
] | permissive | bankitt/bankitt | dd488300763c289e9a5c104ab315a95c59df6ede | 1e09e75f6ac717595e8baf7e1186ad8964a3338a | refs/heads/master | 2021-04-27T22:16:41.600864 | 2018-02-22T01:37:49 | 2018-02-22T01:37:49 | 122,416,780 | 1 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 3,703 | cpp | #include "alert.h"
#include "clientversion.h"
#include "chainparams.h"
#include "init.h"
#include "net.h"
#include "utilstrencodings.h"
#include "utiltime.h"
/*
If you need to broadcast an alert, here's what to do:
1. Modify alert parameters below, see alert.* and comments in the code
for what does what.
2. run bankittd with -printalert or -sendalert like this:
/path/to/bankittd -printalert
One minute after starting up the alert will be broadcast. It is then
flooded through the network until the nRelayUntil time, and will be
active until nExpiration OR the alert is cancelled.
If you screw up something, send another alert with nCancel set to cancel
the bad alert.
*/
void ThreadSendAlert(CConnman& connman)
{
if (!mapArgs.count("-sendalert") && !mapArgs.count("-printalert"))
return;
// Wait one minute so we get well connected. If we only need to print
// but not to broadcast - do this right away.
if (mapArgs.count("-sendalert"))
MilliSleep(60*1000);
//
// Alerts are relayed around the network until nRelayUntil, flood
// filling to every node.
// After the relay time is past, new nodes are told about alerts
// when they connect to peers, until either nExpiration or
// the alert is cancelled by a newer alert.
// Nodes never save alerts to disk, they are in-memory-only.
//
CAlert alert;
alert.nRelayUntil = GetAdjustedTime() + 15 * 60;
alert.nExpiration = GetAdjustedTime() + 30 * 60 * 60;
alert.nID = 1; // keep track of alert IDs somewhere
alert.nCancel = 0; // cancels previous messages up to this ID number
// These versions are protocol versions
alert.nMinVer = 70000;
alert.nMaxVer = 70103;
//
// 1000 for Misc warnings like out of disk space and clock is wrong
// 2000 for longer invalid proof-of-work chain
// Higher numbers mean higher priority
alert.nPriority = 5000;
alert.strComment = "";
alert.strStatusBar = "URGENT: Upgrade required: see https://www.bankitt.org";
// Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done:
// alert.setSubVer.insert(std::string("/Bankitt Core:0.12.0.58/"));
// Sign
if(!alert.Sign())
{
LogPrintf("ThreadSendAlert() : could not sign alert\n");
return;
}
// Test
CDataStream sBuffer(SER_NETWORK, CLIENT_VERSION);
sBuffer << alert;
CAlert alert2;
sBuffer >> alert2;
if (!alert2.CheckSignature(Params().AlertKey()))
{
printf("ThreadSendAlert() : CheckSignature failed\n");
return;
}
assert(alert2.vchMsg == alert.vchMsg);
assert(alert2.vchSig == alert.vchSig);
alert.SetNull();
printf("\nThreadSendAlert:\n");
printf("hash=%s\n", alert2.GetHash().ToString().c_str());
printf("%s", alert2.ToString().c_str());
printf("vchMsg=%s\n", HexStr(alert2.vchMsg).c_str());
printf("vchSig=%s\n", HexStr(alert2.vchSig).c_str());
// Confirm
if (!mapArgs.count("-sendalert"))
return;
while (connman.GetNodeCount(CConnman::CONNECTIONS_ALL) == 0 && !ShutdownRequested())
MilliSleep(500);
if (ShutdownRequested())
return;
// Send
printf("ThreadSendAlert() : Sending alert\n");
int nSent = 0;
{
connman.ForEachNode([&alert2, &connman, &nSent](CNode* pnode) {
if (alert2.RelayTo(pnode, connman))
{
printf("ThreadSendAlert() : Sent alert to %s\n", pnode->addr.ToString().c_str());
nSent++;
}
});
}
printf("ThreadSendAlert() : Alert sent to %d nodes\n", nSent);
}
| [
"you@example.com"
] | you@example.com |
fb289b8da783a90373ff26022be97080fef586b1 | d19edb558b5534ff2557c0cfa5375e8d81e612ea | /main.cpp | 3ecae22b3802725647dd20df71805940ad70509c | [] | no_license | Tahmid2000/word-puzzle | 5aaea965a0ee4f2796bddb272be23903cdbc8b83 | 1dc35d3af488794e96e88d523f3957322d9608da | refs/heads/master | 2022-07-04T21:46:57.000003 | 2020-05-20T08:13:58 | 2020-05-20T08:13:58 | 265,496,096 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,404 | cpp | /* Tahmid Imran
* assignment1.cpp
* The purpose of this project is to iterate through a crossword puzzle
* to find specified words using 2 files.
*/
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>
#include <algorithm>
#include <cctype>
using namespace std;
enum direction {LEFT_RIGHT, RIGHT_LEFT, DOWN, UP, RIGHT_DOWN, RIGHT_UP, LEFT_DOWN, LEFT_UP};
direction dir;
const int MAX = 50;
//sturct for the attributes of the puzzle
struct wordGame
{
int version;
int numberRows;
int numberColumns;
char puzzle[MAX][MAX];
};
//struct for the attributes of a the word being searched for in the puzzle
struct wordFind
{
string word;
bool found;
int row;
int column;
direction where;
int foundCount;
};
// find the word that is part of the wordFind structure inside the wordGame structure.
// If the word is found the wordFind structure will be updated.
void findWord(wordGame &game, wordFind &theFind){
theFind.foundCount = 0; //how many times the word was found
theFind.found = false; //changes to true if word found
theFind.row = 0; //the row of where the first letter of the word was found
theFind.column = 0; //the column of where the first letter of the word was found
int foundRow = 0; //the row of where the word was found
int foundCol = 0; //the column of where the word was found
//LEFT_RIGHT
int textLen = static_cast<int>(theFind.word.length());
int indexCounter = 0;
int i = 0;
//checks puzzle from left to right
while(i < game.numberRows){
for(int j = 0; j < (game.numberColumns - textLen + 1); j++){
//i - row
//j - col
//stops loop if out of bounds
if(i > game.numberRows || j > game.numberColumns){
return;
}
//checks if at the current index, the first letter, the second letter, and second to last letter is the same as the current word being searched for
else if((game.puzzle[i][j] == theFind.word.at(0)) && (game.puzzle[i][j+1] == theFind.word.at(1)) && (game.puzzle[i][j + (textLen - 2)] == theFind.word.at(textLen - 2))){
theFind.row = i;
theFind.column = j;
indexCounter = 0;
//if the check above works, then the rest of the column is checked with each index of each letter
for(int k = 1; k < textLen; k++){
if(game.puzzle[theFind.row][theFind.column + k] == theFind.word.at(k)){
indexCounter++;//keeps track of how many letters of the word were found
}
}
}
}
//if the index counter matches the size of the word then the found, where, foundcount, foundRow/Column are set to their appropriate values
if(indexCounter == (textLen - 1)){
theFind.found = true;
theFind.where = LEFT_RIGHT;
theFind.foundCount++;
foundRow = theFind.row;
foundCol = theFind.column;
indexCounter = 0;
}
i++;
}
//RIGHT_LEFT
i = 0;
//checks puzzle from right to left
while(i < game.numberRows){
for(int j = game.numberColumns - 1; j >= (textLen - 1); j--){
//i - row
//j - col
//stops loop if out of bounds
if(i > game.numberRows || j < 0){
return;
}
//checks if at the current index, the first letter, the second letter, and second to last letter is the same as the current word being searched for
else if(game.puzzle[i][j] == theFind.word.at(0) && (game.puzzle[i][j - 1] == theFind.word.at(1)) && (game.puzzle[i][j - (textLen - 2)] == theFind.word.at(textLen - 2))){
theFind.row = i;
theFind.column = j;
indexCounter = 0;
//if the check above works, then the rest of the column is checked with each index of each letter
for(int k = 1; k < textLen; k++){
if(game.puzzle[theFind.row][theFind.column - k] == theFind.word.at(k)){
indexCounter++;//keeps track of how many letters of the word were found
}
}
}
}
//if the index counter matches the size of the word then the found, where, foundcount, foundRow/Column are set to their appropriate values
if(indexCounter == (textLen - 1)){
theFind.found = true;
theFind.where = RIGHT_LEFT;
theFind.foundCount++;
foundRow = theFind.row;
foundCol = theFind.column;
indexCounter = 0;
}
i++;
}
//DOWN
i = 0;
//checks puzzle top to bottom
while(i < game.numberColumns){
for(int j = 0; j < (game.numberRows - textLen + 1); j++){
//i - col
//j - row
//stops loop if out of bounds
if(i > game.numberColumns || j > game.numberRows){
return;
}
//checks if at the current index, the first letter, the second letter, and second to last letter is the same as the current word being searched for
else if((game.puzzle[j][i] == theFind.word.at(0)) && (game.puzzle[j + 1][i] == theFind.word.at(1)) && (game.puzzle[j + (textLen - 2)][i] == theFind.word.at(textLen - 2))){
theFind.column = i;
theFind.row = j;
indexCounter = 0;
//if the check above works, then the rest of the row is checked with each index of each letter
for(int k = 1; k < textLen; k++){
if(game.puzzle[theFind.row + k][theFind.column] == theFind.word.at(k)){
indexCounter++;//keeps track of how many letters of the word were found
}
}
}
}
//if the index counter matches the size of the word then the found, where, foundcount, foundRow/Column are set to their appropriate values
if(indexCounter == (textLen - 1)){
theFind.found = true;
theFind.where = DOWN;
theFind.foundCount++;
foundRow = theFind.row;
foundCol = theFind.column;
indexCounter = 0;
}
i++;
}
//UP
i = 0;
//checks puzzle bottom top
while(i < game.numberColumns){
for(int j = game.numberRows - 1; j >= (textLen - 1); j--){
//i - col
//j - row
//stops loop if out of bounds
if(i > game.numberColumns || j < 0){
return;
}
//checks if at the current index, the first letter, the second letter, and second to last letter is the same as the current word being searched for
else if((game.puzzle[j][i] == theFind.word.at(0)) && (game.puzzle[j - 1][i] == theFind.word.at(1)) && (game.puzzle[j - (textLen - 2)][i] == theFind.word.at(textLen - 2))){
theFind.column = i;
theFind.row = j;
indexCounter = 0;
//if the check above works, then the rest of the row is checked with each index of each letter
for(int k = 1; k < textLen; k++){
if(game.puzzle[theFind.row - k][theFind.column] == theFind.word.at(k)){
indexCounter++;//keeps track of how many letters of the word were found
}
}
}
}
//if the index counter matches the size of the word then the found, where, foundcount, foundRow/Column are set to their appropriate values
if(indexCounter == (textLen - 1)){
theFind.found = true;
theFind.where = UP;
theFind.foundCount++;
foundRow = theFind.row;
foundCol = theFind.column;
indexCounter = 0;
}
i++;
}
//RIGHT-DOWN
i = 0;
//checks puzzle diagonally downward and to the right
while(i < game.numberRows){
for(int j = 0; j < (game.numberColumns - textLen + 1); j++){
//i - row
//j - col
//stops loop if out of bounds
if(i > game.numberRows || j > game.numberColumns){
return;
}
//checks if at the current index, the first letter, the second letter, and second to last letter is the same as the current word being searched for
else if((game.puzzle[i][j] == theFind.word.at(0)) && (game.puzzle[i + 1][j + 1] == theFind.word.at(1)) && (game.puzzle[i + (textLen - 2)][j + (textLen - 2)] == theFind.word.at(textLen - 2))){
theFind.row = i;
theFind.column = j;
indexCounter = 0;
//if the check above works, then the rest of the row and column is checked with each index of each letter
for(int k = 1; k < textLen; k++){
if(game.puzzle[theFind.row + k][theFind.column + k] == theFind.word.at(k)){
indexCounter++;//keeps track of how many letters of the word were found
}
}
}
}
//if the index counter matches the size of the word then the found, where, foundcount, foundRow/Column are set to their appropriate values
if(indexCounter == (textLen - 1)){
theFind.found = true;
theFind.where = RIGHT_DOWN;
theFind.foundCount++;
foundRow = theFind.row;
foundCol = theFind.column;
indexCounter = 0;
}
i++;
}
//RIGHT-UP
i = 0;
//checks puzzle diagonally upward and to the right
while(i < game.numberColumns){
for(int j = game.numberRows - 1; j >= (textLen - 1); j--){
//i - col
//j - row
//stops loop if out of bounds
if(i > game.numberColumns || j < 0){
return;
}
//checks if at the current index, the first letter, the second letter, and second to last letter is the same as the current word being searched for
else if((game.puzzle[j][i] == theFind.word.at(0)) && (game.puzzle[j - 1][i + 1] == theFind.word.at(1)) && (game.puzzle[j - (textLen - 2)][i + (textLen - 2)] == theFind.word.at(textLen - 2))){
theFind.column = i;
theFind.row = j;
indexCounter = 0;
//if the check above works, then the rest of the row and column is checked with each index of each letter
for(int k = 1; k < textLen; k++){
if(game.puzzle[theFind.row - k][theFind.column + k] == theFind.word.at(k)){
indexCounter++;//keeps track of how many letters of the word were found
}
}
}
}
//if the index counter matches the size of the word then the found, where, foundcount, foundRow/Column are set to their appropriate values
if(indexCounter == (textLen - 1)){
theFind.found = true;
theFind.where = RIGHT_UP;
theFind.foundCount++;
foundRow = theFind.row;
foundCol = theFind.column;
indexCounter = 0;
}
i++;
}
//LEFT-DOWN
i = 0;
//checks puzzle diagonally downward and to the left
while(i < game.numberRows){
for(int j = game.numberColumns - 1; j >= 0; j--){
//i - row
//j - col
//stops loop if out of bounds
if(i > game.numberRows || j < 0){
return;
}
//checks if at the current index, the first letter, the second letter, and second to last letter is the same as the current word being searched for
else if((game.puzzle[i][j] == theFind.word.at(0)) && (game.puzzle[i + 1][j - 1] == theFind.word.at(1)) && (game.puzzle[i + (textLen - 2)][j - (textLen - 2)] == theFind.word.at(textLen - 2))){
theFind.row = i;
theFind.column = j;
indexCounter = 0;
//if the check above works, then the rest of the row and column is checked with each index of each letter
for(int k = 1; k < textLen; k++){
if(game.puzzle[theFind.row + k][theFind.column - k] == theFind.word.at(k)){
indexCounter++;//keeps track of how many letters of the word were found
}
}
}
}
//if the index counter matches the size of the word then the found, where, foundcount, foundRow/Column are set to their appropriate values
if(indexCounter == (textLen - 1)){
theFind.found = true;
theFind.where = LEFT_DOWN;
theFind.foundCount++;
foundRow = theFind.row;
foundCol = theFind.column;
indexCounter = 0;
}
i++;
}
//LEFT-UP
i = game.numberRows - 1;
//checks puzzle diagonally upward and to the left
while(i >= 0){
for(int j = game.numberColumns - 1; j >= 0; j--){
//i - row
//j - col
//stops loop if out of bounds
if(i < 0|| j < 0){
return;
}
//checks if at the current index, the first letter, the second letter, and second to last letter is the same as the current word being searched for
else if((game.puzzle[i][j] == theFind.word.at(0)) && (game.puzzle[i - 1][j - 1] == theFind.word.at(1)) && (game.puzzle[i - (textLen - 2)][j - (textLen - 2)] == theFind.word.at(textLen - 2))){
theFind.row = i;
theFind.column = j;
indexCounter = 0;
//if the check above works, then the rest of the row and column is checked with each index of each letter
for(int k = 1; k < textLen; k++){
if(game.puzzle[theFind.row - k][theFind.column - k] == theFind.word.at(k)){
indexCounter++;//keeps track of how many letters of the word were found
}
}
}
}
//if the index counter matches the size of the word then the found, where, foundcount, foundRow/Column are set to their appropriate values
if(indexCounter == (textLen - 1)){
theFind.found = true;
theFind.where = LEFT_UP;
theFind.foundCount++;
foundRow = theFind.row;
foundCol = theFind.column;
indexCounter = 0;
}
i--;
}
if(theFind.foundCount == 1){
theFind.row = foundRow;
theFind.column = foundCol;
}
}
// read the puzzle from the input file and update the wordGame structure.
bool readPuzzle(wordGame &game, string inputFileName){
game.version = 1;
ifstream inFile;
inFile.open(inputFileName);
if(inFile.is_open()){
inFile >> game.numberRows;
inFile >> game.numberColumns;
for(int i = 0; i < game.numberRows; i++){
for(int j = 0; j < game.numberColumns; j++){
inFile >> game.puzzle[i][j];
}
}
}
else
return false;
//bonus
game.version = 2;
//checks if rows and cols are within range
if(game.numberRows < 1 || game.numberRows > MAX || game.numberColumns < 1 || game.numberColumns > MAX)
return false;
//checks if end of file
if(inFile.eof())
return false;
//changes puzzle to all uppercase
for(int i = 0; i< game.numberRows; i++){
for(int j = 0; j < game.numberColumns; j++){
game.puzzle[i][j] = toupper(game.puzzle[i][j]);
}
}
inFile.close();
return true;
}
// display the contents of the puzzle
void displayPuzzle(wordGame &game){
for(int i =0; i < game.numberRows; i++){
for(int j = 0; j < game.numberColumns; j++){
cout << game.puzzle[i][j];
}
cout << endl;
}
}
int main()
{
wordGame game1;
wordFind word1;
bool open = true;
string puzzlefile;
string wordfile;
cin >> puzzlefile;
cin >> wordfile;
//checks to see if puzzle file was properly opened
if(readPuzzle(game1, puzzlefile) == false){
cout << "The puzzle file " << "\"" << puzzlefile << "\"" << " could not be opened or is invalid" << endl;
open = false;
}
else{
cout << "The puzzle from file " << "\"" << puzzlefile << "\"" << endl;
displayPuzzle(game1);
}
ifstream inFile;
string line;
inFile.open(wordfile);
//checks to see if word file was properly opened
if(!(inFile.is_open() == true) && open == true){
cout << "The puzzle file " << "\"" << wordfile << "\"" << " could not be opened or is invalid" << endl;
}
//loops through puzzle file to see where the words are in puzzle
while(inFile >> word1.word && open == true){
cin.clear();
//bonus - changes word in word file to upper case
if(game1.version == 2)
transform(word1.word.begin(), word1.word.end(), word1.word.begin(), ::toupper);
else
game1.version = 1;
findWord(game1, word1);
//outputs a different string depending on the direction of where the word was found
if(word1.found == true && word1.foundCount == 1){
if(word1.where == LEFT_RIGHT)
cout << "The word " << word1.word << " was found at (" << (word1.row + 1) << ", " << (word1.column + 1) << ") - " << "right"<< endl;
if(word1.where == RIGHT_LEFT)
cout << "The word " << word1.word << " was found at (" << (word1.row + 1) << ", " << (word1.column + 1) << ") - " << "left"<< endl;
if(word1.where == DOWN)
cout << "The word " << word1.word << " was found at (" << (word1.row + 1) << ", " << (word1.column + 1) << ") - " << "down"<< endl;
if(word1.where == UP)
cout << "The word " << word1.word << " was found at (" << (word1.row + 1) << ", " << (word1.column + 1) << ") - " << "up"<< endl;
if(word1.where == RIGHT_DOWN)
cout << "The word " << word1.word << " was found at (" << (word1.row + 1) << ", " << (word1.column + 1) << ") - " << "right/down"<< endl;
if(word1.where == RIGHT_UP)
cout << "The word " << word1.word << " was found at (" << (word1.row + 1) << ", " << (word1.column + 1) << ") - " << "right/up"<< endl;
if(word1.where == LEFT_DOWN)
cout << "The word " << word1.word << " was found at (" << (word1.row + 1) << ", " << (word1.column + 1) << ") - " << "left/down"<< endl;
if(word1.where == LEFT_UP)
cout << "The word " << word1.word << " was found at (" << (word1.row + 1) << ", " << (word1.column + 1) << ") - " << "left/up"<< endl;
}
//prints if more than one instance of word was found
else if(word1.foundCount > 1)
cout << "The word " << word1.word << " was found " << word1.foundCount << " times" << endl;
else
cout << "The word " << word1.word << " was not found" << endl;
}
inFile.close();
}
| [
"tahmidimran1@gmail.com"
] | tahmidimran1@gmail.com |
add630ddb9b293246bc8e064526ee18093fd0437 | bd2c11922957152013488883658a959e26be3cdf | /UnB/2021pc/le8/d_canibais.cc | 3c9c65c794c084142ab2b81972faa3afda3f888e | [] | no_license | Pedenite/Maratonas | ab19907ce16be3b56845b38dcd4069d427289c2d | 945049edcd8d4fde72e96a184ab39a86ec4e0efa | refs/heads/master | 2023-05-13T07:24:33.062098 | 2021-05-29T20:47:18 | 2021-05-29T20:47:18 | 255,485,263 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,062 | cc | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define MAX (int) (1e5+1)
#define mod (int) (1e9+7)
#define forn(j,n) for(int i = j; i < n; i++)
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> ii;
vector<int> e, c;
int tab[10001][10001];
int solve(int n, int m){
for(int i = 0; i <= n; i++){
for(int j = 0; j <= m; j++){
tab[i][j] = 0;
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(c[i] <= j){
tab[i][j] = max(tab[i-1][j-c[i]]+e[i],tab[i-1][j]);
}else{
tab[i][j] = tab[i-1][j];
}
}
}
return tab[n][m];
}
int main() {
int n, m, ei, ci;
scanf("%d %d", &n, &m);
e.push_back(0);
c.push_back(0);
for (int i = 0; i < n; i++) {
scanf("%d", &ei);
e.push_back(ei);
}
for (int i = 0; i < n; i++) {
scanf("%d", &ci);
c.push_back(ci);
}
printf("%d\n", solve(n, m));
return 0;
}
| [
"pedenite@gmail.com"
] | pedenite@gmail.com |
a8a99585ed76efdcf06443ef9fa9a6bc8e9c228c | 387d2866b3f4edfc30ccc97c4cb3e26df87d57b9 | /MultiGPU Dessertation/EventsDivide/cuda/CudaKernelsNoDup.h | ea26c85b59550906cdc09a9bbc764029e7413f52 | [] | no_license | shahmedha/Alpesh_Project_2014-16 | a920c675e5e8627b32f8c5caa2979e5780c4688b | e7d7023bfe7f41682970113530811d13b5a90680 | refs/heads/master | 2021-01-17T08:04:25.972307 | 2016-07-15T12:56:32 | 2016-07-15T12:56:32 | 63,421,693 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,515 | h | #ifndef CUDAKERNELSNODUP_H_
#define CUDAKERNELSNODUP_H_
#include <map>
#include <set>
#include "cudaTypes.h"
#include "../sff/siena/types.h"
#include <iostream>
#include "../common/Timer.h"
#include "../common/Consts.h"
using namespace std;
using namespace siena;
#define MAX_FILTERS_X_CONSTR 4
class CudaKernelsNoDup {
public:
/**
* Constructor
*/
CudaKernelsNoDup();
/**
* Destructor
*/
virtual ~CudaKernelsNoDup();
/**
* Config an interface by setting its predicate (the set of its filters)
*/
void ifConfig(int interfaceId, set<CudaFilter *> &filters);
/**
* Call this after all interfaces have been set
*/
void consolidate();
/**
* Processes the given messages, storing the set of matching interfaces into the results set
*/
void processMessage(CudaOutbox *outbox);
/**
* Returns the statistics about processing time distribution
*/
void getStats(double &hToD, double &exec, double &dToH);
private:
map<int, set<CudaFilter *> > hostFilters; // Interface -> set of filters (in host memory)
int numFilters; // Number of filters
int numInterfaces; // Number of interfaces
map<string_t, int> numConstraints; // Name -> number of constraints with that name
map<string_t, Type> nameType; // Name -> type of constraints with that name
bool consolidated; // True if the consolidate method has been called
map<string_t, void *> nameDeviceConstrVal; // Name -> set of constraint values (in device memory)
map<string_t, Op *> nameDeviceConstrOp; // Name -> set of constraint operands (in device memory)
map<string_t, int *> nameDeviceFilterIdx; // Name -> set of filter indexes (in device memory)
unsigned char *currentFiltersCount; // Filter -> number of constraints satisfied (in device memory)
FilterInfo *filtersInfo; // Filter -> information for that filter (in device memory)
unsigned char *interfacesDevice; // Pointer to the array of interfaces in device memory
unsigned char *interfacesHost; // Pointer to the array of interfaces in host memory
CudaInputElem *hostInput; // Pointer to the input (in host memory)
CudaInputElem *deviceInput; // Pointer to the input (in device memory)
int numValues; // Number of values in current input
double hostToDeviceCopyTime;
double execTime;
double deviceToHostCopyTime;
inline int copyMsgToDevice(CudaMessage *msg);
inline void computeResults(int maxConstraints);
inline void getMatchingInterfaces(set<int> &results);
};
#endif /* CUDAKERNELSNODUP_H_ */
| [
"vinaykrprajapat@gmail.com"
] | vinaykrprajapat@gmail.com |
49132b3d8714d0d29868964c3139f8a2e1e590aa | 69e1199b2daffa17e4842e94a54be152df540828 | /暑假集训/Speed.cpp | ddbd523bbfe18048a2b7aca017776a475695b6c3 | [] | no_license | shaobozhong/myAcmCodes | 8c63e7992d0975626e6e583a49e59fe03f73017c | 55b31b8a4600fd3084795f71ac0d244cbdc58800 | refs/heads/master | 2023-08-04T20:05:29.165456 | 2023-07-26T03:19:52 | 2023-07-26T03:19:52 | 21,147,335 | 0 | 1 | null | 2023-07-26T03:19:53 | 2014-06-24T00:49:13 | null | UTF-8 | C++ | false | false | 293 | cpp | #include<iostream>
using namespace std;
int main()
{
int caseNum,n,even,odd,num;
cin>>caseNum;
while(caseNum--)
{
cin>>n;
even=0;
odd=0;
while(n--)
{
cin>>num;
if (num%2==0) ++even;
else ++odd;
}
cout<<even<<" even and "<<odd<<" odd."<<endl;
}
return 0;
} | [
"bozhongshao@gmail.com"
] | bozhongshao@gmail.com |
6c0344d622958a45e45c5e0d764817c484712f94 | 9934512da4a541a3e6654dd3a71512df9a9bfe14 | /GHAME6/propulsion.cpp | bacb9d69c6f4a7f0ec7c29e4e2d2dedb3e51d643 | [] | no_license | missiondesignsolutions/CADAC | a534eda151c6d8d3afba8e5d48d60201a2a591ff | 8aa2f73e551554a48abeac5416d1ec3a34ae660f | refs/heads/main | 2023-05-01T04:32:40.710534 | 2021-05-24T07:44:03 | 2021-05-24T07:44:03 | 370,660,263 | 3 | 1 | null | 2021-05-25T10:55:36 | 2021-05-25T10:55:36 | null | UTF-8 | C++ | false | false | 11,983 | cpp | ///////////////////////////////////////////////////////////////////////////////
//FILE: 'propulsion.cpp'
//Contains 'propulsion' module of class 'Round6'
//
//030514 Created by Peter H Zipfel
///////////////////////////////////////////////////////////////////////////////
#include "class_hierarchy.hpp"
///////////////////////////////////////////////////////////////////////////////
//Definition of 'propulsion' module-variables
//Member function of class 'Round6'
//Module-variable locations are assigned to round6[10-49]
//
// Hypersonic propulsion
// Ref: "Handbook of Intelligent Control", Chapter 11 "Flight
// Propulsion, and Thermal Control of Advanced Aircraft and
// Hypersonic Vehicles", Edited by D.A.White and D.A. Sofge,
// Van Nostrand Reinhold,New York, NY, 1992
// Type: turbojet 0-2 Mach
// ramjet 2-6 Mach
// scramjet 6-12 Mach
// Mass properties: take-off mass 136,077 kg
// total fuel mass 81,646 kg
//
// mrpop = 0 No thrusting
// = 1 Hypersonic propulsion throttle command (input)
// = 2 Hypersonic propulsion autothrottle (input)
// = 3 Constant thrust rocket under LTG control (set in 'guidance' module)
// = 4 Constant thrust rocket (input)
//
// This module performs the following functions:
// (1) Provides propulsion deck (capture area ratio CA and ISP)
// (2) Initializes vehicle mass properties
// (3) Sets up fuel mass integration variable
//
//030514 Created by Peter H Zipfel
//040302 Added rocket propulsion, PZi
//041009 Included 'mfreeze' capability, PZi
///////////////////////////////////////////////////////////////////////////////
void Hyper::def_propulsion()
{
//Definition and initialization of module-variables
hyper[10].init("mprop","int",0,"=0:none; =1:hyper; =2:hyper-auto; =3(LTG)&4(input):rocket","propulsion","data","");
hyper[11].init("acowl",0,"Cowl area of engine inlet - m^2","propulsion","data","");
hyper[12].init("throttle",.05,"Throttle controlling fuel/air ratio - ND","propulsion","data/diag","scrn,plot");
hyper[13].init("thrtl_max",0,"Max throttle - ND","propulsion","data","");
hyper[14].init("qhold",0,"Dynamic pressure hold command - Pa","propulsion","data","");
hyper[15].init("vmass",0,"Vehicle mass - kg","propulsion","out","scrn,plot");
hyper[16].init("vmass0",0,"Initial gross mass - kg","propulsion","data","");
hyper[18].init("IBBB",0,0,0,0,0,0,0,0,0,"Vehicle moment of inertia - kgm^2","propulsion","out","");
hyper[19].init("IBBB0",0,0,0,0,0,0,0,0,0,"Initial hypersonic vehicle moment of inertia - kgm^2","propulsion","init","");
hyper[20].init("IBBB1",0,0,0,0,0,0,0,0,0,"Burn-out hypersonic vehicle moment of inertia - kgm^2","propulsion","init","");
hyper[21].init("fmass0",0,"Initial fuel mass in stage - kg","propulsion","data","");
hyper[22].init("fmasse",0,"Fuel mass expended (zero initialization required) - kg","propulsion","state","");
hyper[23].init("fmassd",0,"Fuel mass expended derivative - kg/s","propulsion","state","");
hyper[24].init("ca",0,"Capture area factor - ND","propulsion","diag","");
hyper[25].init("spi",0,"Specific impulse - sec","propulsion","diag","");
hyper[26].init("thrust",0,"Thrust - N","propulsion","out","");
hyper[27].init("mass_flow",0,"Mass flow through hypersonic engine - kg/s","propulsion","diag","");
hyper[28].init("fmassr",0,"Remaining fuel mass - kg","propulsion","diag","scrn,plot");
hyper[29].init("thrustx",0,"Thrust in kN","propulsion","diag","scrn,plot");
hyper[30].init("tq",0,"Autothrottle time constant - sec","propulsion","data","");
hyper[31].init("thrtl_idle",0,"Idle throttle - ND","propulsion","data","");
hyper[33].init("fuel_flow_rate",0,"Fuel flow rate of rocket motor - kg/s","propulsion","data","");
hyper[36].init("vmass0_st",0,"Initial mass of exo-vehicle - kg","propulsion","data","");
hyper[37].init("fmass0_st",0,"Initial fuel mass of exo-vehicle - kg","propulsion","data","");
hyper[38].init("moi_roll_exo_0",0,"Roll MOI of exo-vehicle, initial - kgm^2","propulsion","data","");
hyper[39].init("moi_roll_exo_1",0,"Roll MOI of exo-vehicle, burn-out - kgm^2","propulsion","data","");
hyper[40].init("moi_trans_exo_0",0,"Transverse MOI of exo-vehicle, initial - kgm^2","propulsion","data","");
hyper[41].init("moi_trans_exo_1",0,"Transverse MOI of exo-vehicle, burn-out - kgm^2","propulsion","data","");
hyper[42].init("mfreeze_prop","int",0,"Saving 'mfreeze' value","propulsion","save","");
hyper[43].init("thrustf",0,"Saved thrust when mfreeze=1 - N ","propulsion","save","");
hyper[44].init("vmassf",0,"Saved mass when mfreeze=1 - N ","propulsion","save","");
hyper[45].init("IBBBF",0,0,0,0,0,0,0,0,0,"Saved MOI when mfreeze=1 - kgm^2","propulsion","save","");
}
///////////////////////////////////////////////////////////////////////////////
//Propulsion initialization module
//Member function of class 'Round6'
// Initializes mass properties
//
//030514 Created by Peter H Zipfel
//040302 Added rocket propulsion, PZi
///////////////////////////////////////////////////////////////////////////////
void Hyper::init_propulsion()
{
//local module-variables
double vmass(0);
double vmass0_st(0);
double fmass0_st(0);
Matrix IBBB(3,3);
Matrix IBBB0(3,3);
Matrix IBBB1(3,3);
//localizing module-variables
int mprop=hyper[10].integer();
double vmass0=hyper[16].real();
//-------------------------------------------------------------------------
//initialization of mass properties
//for the hypersonic vehicle with exo-vehicle in cargo bay
vmass=vmass0;
IBBB0.assign_loc(0,0,1.573e6);
IBBB0.assign_loc(1,1,31.6e6);
IBBB0.assign_loc(2,2,32.54e6);
IBBB0.assign_loc(0,2,0.38e6);
IBBB0.assign_loc(2,0,0.38e6);
IBBB1.assign_loc(0,0,1.18e6);
IBBB1.assign_loc(1,1,19.25e6);
IBBB1.assign_loc(2,2,20.2e6);
IBBB1.assign_loc(0,2,0.24e6);
IBBB1.assign_loc(2,0,0.24e6);
IBBB=IBBB0;
//-------------------------------------------------------------------------
//loading module-variables
//initialization
hyper[15].gets(vmass);
hyper[18].gets_mat(IBBB);
hyper[19].gets_mat(IBBB0);
hyper[20].gets_mat(IBBB1);
hyper[36].gets(vmass0_st);
hyper[37].gets(fmass0_st);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//Propulsion module
//Member function of class 'Round6'
// Calculates engine thrust
// Provides dynamic pressure controller
//
// mrpop = 0 No thrusting
// = 1 Hypersonic propulsion throttle command (input)
// = 2 Hypersonic propulsion autothrottle (input)
// = 3 Constant thrust rocket under LTG control (set in 'guidance' module)
// = 4 Constant thrust rocket (input)
//
//030514 Created by Peter H Zipfel
//040302 Added rocket propulsion, PZi
///////////////////////////////////////////////////////////////////////////////
void Hyper::propulsion(double int_step)
{
//local variable
double gainq(0);
//local module-variables
double spi(0);
double ca(0);
double thrust(0);
double mass_flow(0);
double thrustx(0);
//localizing module-variables
//input data
int mprop=hyper[10].integer();
double throttle=hyper[12].real();
double qhold=hyper[14].real();
double vmass0=hyper[16].real();
double fmass0=hyper[21].real();
double tq=hyper[30].real();
double thrtl_idle=hyper[31].real();
double fuel_flow_rate=hyper[33].real();
double moi_roll_exo_0=hyper[38].real();
double moi_roll_exo_1=hyper[39].real();
double moi_trans_exo_0=hyper[40].real();
double moi_trans_exo_1=hyper[41].real();
//from initialization
double acowl=hyper[11].real();
double thrtl_max=hyper[13].real();
Matrix IBBB=hyper[18].mat();
Matrix IBBB0=hyper[19].mat();
Matrix IBBB1=hyper[20].mat();
double vmass0_st=hyper[36].real();
double fmass0_st=hyper[37].real();
//getting saved variable
double vmass=hyper[15].real();
double fmassr=hyper[28].real();
int mfreeze_prop=hyper[42].integer();
double thrustf=hyper[43].real();
double vmassf=hyper[44].real();
Matrix IBBBF=hyper[45].mat();
//state variable
double fmasse=hyper[22].real();
double fmassd=hyper[23].real();
//input from other modules
double time=round6[0].real();
double rho=round6[53].real();
double vmach=round6[56].real();
double pdynmc=round6[57].real();
double dvba=round6[75].real();
double refa=hyper[104].real();
double cd=hyper[110].real();
double alphax=round6[144].real();
double isp_fuel=hyper[472].real();
double burntime=hyper[473].real();
int mfreeze=hyper[503].integer();
//-------------------------------------------------------------------------
//making thrust calculations only if engine is on
if(mprop>0){
//hypersonic propulsion table look-up
if(mprop==1||mprop==2){
//spi table look-up
spi=proptable.look_up("spi_vs_throttle_mach",throttle,vmach);
//capture area coefficient look-up
ca=proptable.look_up("ca_vs_alpha_mach",alphax,vmach);
}
//hypersonic propulsion with fixed throttle
if(mprop==1){
thrust=spi*0.029*throttle*AGRAV*rho*dvba*ca*acowl;
}
//hypersonic propulsion with auto throttle
if(mprop==2){
double denom=0.029*spi*AGRAV*rho*dvba*ca*acowl;
if(denom!=0){
double thrst_req=refa*cd*qhold/cos(alphax*RAD);
double throtl_req=thrst_req/denom;
double gainq=2*vmass/(rho*dvba*denom*tq);
double ethrotl=gainq*(qhold-pdynmc);
throttle=ethrotl+throtl_req;
}
//throttle limiters
if(throttle<0) throttle=thrtl_idle;
if (throttle>thrtl_max) throttle=thrtl_max;
//calculating thrust
spi=proptable.look_up("spi_vs_throttle_mach",throttle,vmach);
thrust=spi*0.029*throttle*AGRAV*rho*dvba*ca*acowl;
}
//constant thrust rocket engine for exo-vehicle
if(mprop==3||mprop==4){
spi=isp_fuel;
if(mprop==3){
//motor under LTG control
fuel_flow_rate=fmass0/burntime;
thrust=spi*fuel_flow_rate*AGRAV;
}
else if(mprop==4){
//motor not under LTG control
thrust=spi*fuel_flow_rate*AGRAV;
}
//load MOI of exo-vehicles (T.V. or interceptor)
IBBB0.zero();
IBBB0.assign_loc(0,0,moi_roll_exo_0);
IBBB0.assign_loc(1,1,moi_trans_exo_0);
IBBB0.assign_loc(2,2,moi_trans_exo_0);
IBBB1.zero();
IBBB1.assign_loc(0,0,moi_roll_exo_1);
IBBB1.assign_loc(1,1,moi_trans_exo_1);
IBBB1.assign_loc(2,2,moi_trans_exo_1);
}
//calculating fuel consumption
if (spi!=0){
double fmassd_next=thrust/(spi*AGRAV);
fmasse=integrate(fmassd_next,fmassd,fmasse,int_step);
fmassd=fmassd_next;
}
//calculating vehicle mass, mass flow, and fuel mass remaining
vmass=vmass0-fmasse;
fmassr=fmass0-fmasse;
//interpolating moment of inertia tensor as a fucntion of fuel expended
double mass_ratio=fmasse/fmass0;
IBBB=IBBB0+(IBBB1-IBBB0)*mass_ratio;
//diagnostics: thrust in kN
mass_flow=thrust/(AGRAV*spi);
//shutting down engine when all fuel is expended
if(fmassr<=0)
mprop=0;
}
//no thrusting
if(mprop==0){
fmassd=0;
thrust=0;
thrustx=0;
}
//freezing variables for autopilot response calculations
if(mfreeze==0)
mfreeze_prop=0;
else{
if(mfreeze!=mfreeze_prop){
mfreeze_prop=mfreeze;
thrustf=thrust;
vmassf=vmass;
IBBBF=IBBB;
}
thrust=thrustf;
vmass=vmassf;
IBBB=IBBBF;
}
//diagnostics: thrust in kN
thrustx=thrust/1000;
//-------------------------------------------------------------------------
//loading module-variables
//state variables
hyper[22].gets(fmasse);
hyper[23].gets(fmassd);
//saving variable
hyper[10].gets(mprop);
hyper[42].gets(mfreeze_prop);
hyper[43].gets(thrustf);
hyper[44].gets(vmassf);
hyper[45].gets_mat(IBBBF);
//output to other modules
hyper[15].gets(vmass);
hyper[18].gets_mat(IBBB);
hyper[26].gets(thrust);
//diagnostics
hyper[12].gets(throttle);
hyper[24].gets(ca);
hyper[25].gets(spi);
hyper[27].gets(mass_flow);
hyper[28].gets(fmassr);
hyper[29].gets(thrustx);
}
| [
"rads2995@gmail.com"
] | rads2995@gmail.com |
8812dd9be383b4bb5a79fe70e2cf274007ad2de5 | efc4772a909c360a5c82a80d5bda0971415a0361 | /third_party/openh264/src/test/encoder/EncUT_DecodeMbAux.cpp | 06590919226e2937a9f44d97175e7181a3b78792 | [
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | jasonblog/RTMPLive | 7ce6c9f950450eedff21ebae7505a62c9cb9f403 | 92a018f50f7df19c255b106dc7f584b90f1fe116 | refs/heads/master | 2020-04-22T01:31:04.504948 | 2019-02-13T05:30:19 | 2019-02-13T05:30:19 | 170,016,488 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 14,087 | cpp | #include <gtest/gtest.h>
#include "decode_mb_aux.h"
#include "wels_common_basis.h"
#include "macros.h"
#include "cpu.h"
using namespace WelsEnc;
TEST(DecodeMbAuxTest, TestIhdm_4x4_dc)
{
short W[16], T[16], Y[16];
for (int i = 0; i < 16; i++) {
W[i] = rand() % 256 + 1;
}
T[0] = W[0] + W[4] + W[8] + W[12];
T[1] = W[1] + W[5] + W[9] + W[13];
T[2] = W[2] + W[6] + W[10] + W[14];
T[3] = W[3] + W[7] + W[11] + W[15];
T[4] = W[0] + W[4] - W[8] - W[12];
T[5] = W[1] + W[5] - W[9] - W[13];
T[6] = W[2] + W[6] - W[10] - W[14];
T[7] = W[3] + W[7] - W[11] - W[15];
T[8] = W[0] - W[4] - W[8] + W[12];
T[9] = W[1] - W[5] - W[9] + W[13];
T[10] = W[2] - W[6] - W[10] + W[14];
T[11] = W[3] - W[7] - W[11] + W[15];
T[12] = W[0] - W[4] + W[8] - W[12];
T[13] = W[1] - W[5] + W[9] - W[13];
T[14] = W[2] - W[6] + W[10] - W[14];
T[15] = W[3] - W[7] + W[11] - W[15];
Y[0] = T[0] + T[1] + T[2] + T[3];
Y[1] = T[0] + T[1] - T[2] - T[3];
Y[2] = T[0] - T[1] - T[2] + T[3];
Y[3] = T[0] - T[1] + T[2] - T[3];
Y[4] = T[4] + T[5] + T[6] + T[7];
Y[5] = T[4] + T[5] - T[6] - T[7];
Y[6] = T[4] - T[5] - T[6] + T[7];
Y[7] = T[4] - T[5] + T[6] - T[7];
Y[8] = T[8] + T[9] + T[10] + T[11];
Y[9] = T[8] + T[9] - T[10] - T[11];
Y[10] = T[8] - T[9] - T[10] + T[11];
Y[11] = T[8] - T[9] + T[10] - T[11];
Y[12] = T[12] + T[13] + T[14] + T[15];
Y[13] = T[12] + T[13] - T[14] - T[15];
Y[14] = T[12] - T[13] - T[14] + T[15];
Y[15] = T[12] - T[13] + T[14] - T[15];
WelsIHadamard4x4Dc(W);
for (int i = 0; i < 16; i++) {
EXPECT_EQ(Y[i], W[i]);
}
}
TEST(DecodeMbAuxTest, TestDequant_4x4_luma_dc)
{
short T[16], W[16];
for (int qp = 0; qp < 12; qp++) {
for (int i = 0; i < 16; i++) {
T[i] = rand() % 256 + 1;
W[i] = T[i];
}
WelsDequantLumaDc4x4(W, qp);
for (int i = 0; i < 16; i++) {
T[i] = (((T[i] * g_kuiDequantCoeff[qp % 6][0] + (1 << (1 - qp / 6)))) >> (2 - qp / 6));
EXPECT_EQ(T[i], W[i]);
}
}
}
TEST(DecodeMbAuxTest, TestDequant_ihdm_4x4_c)
{
short W[16], T[16], Y[16];
const unsigned short mf = rand() % 16 + 1;
for (int i = 0; i < 16; i++) {
W[i] = rand() % 256 + 1;
}
T[0] = W[0] + W[4] + W[8] + W[12];
T[1] = W[1] + W[5] + W[9] + W[13];
T[2] = W[2] + W[6] + W[10] + W[14];
T[3] = W[3] + W[7] + W[11] + W[15];
T[4] = W[0] + W[4] - W[8] - W[12];
T[5] = W[1] + W[5] - W[9] - W[13];
T[6] = W[2] + W[6] - W[10] - W[14];
T[7] = W[3] + W[7] - W[11] - W[15];
T[8] = W[0] - W[4] - W[8] + W[12];
T[9] = W[1] - W[5] - W[9] + W[13];
T[10] = W[2] - W[6] - W[10] + W[14];
T[11] = W[3] - W[7] - W[11] + W[15];
T[12] = W[0] - W[4] + W[8] - W[12];
T[13] = W[1] - W[5] + W[9] - W[13];
T[14] = W[2] - W[6] + W[10] - W[14];
T[15] = W[3] - W[7] + W[11] - W[15];
Y[0] = (T[0] + T[1] + T[2] + T[3]) * mf;
Y[1] = (T[0] + T[1] - T[2] - T[3]) * mf;
Y[2] = (T[0] - T[1] - T[2] + T[3]) * mf;
Y[3] = (T[0] - T[1] + T[2] - T[3]) * mf;
Y[4] = (T[4] + T[5] + T[6] + T[7]) * mf;
Y[5] = (T[4] + T[5] - T[6] - T[7]) * mf;
Y[6] = (T[4] - T[5] - T[6] + T[7]) * mf;
Y[7] = (T[4] - T[5] + T[6] - T[7]) * mf;
Y[8] = (T[8] + T[9] + T[10] + T[11]) * mf;
Y[9] = (T[8] + T[9] - T[10] - T[11]) * mf;
Y[10] = (T[8] - T[9] - T[10] + T[11]) * mf;
Y[11] = (T[8] - T[9] + T[10] - T[11]) * mf;
Y[12] = (T[12] + T[13] + T[14] + T[15]) * mf;
Y[13] = (T[12] + T[13] - T[14] - T[15]) * mf;
Y[14] = (T[12] - T[13] - T[14] + T[15]) * mf;
Y[15] = (T[12] - T[13] + T[14] - T[15]) * mf;
WelsDequantIHadamard4x4_c(W, mf);
for (int i = 0; i < 16; i++) {
EXPECT_EQ(Y[i], W[i]);
}
}
TEST(DecodeMbAuxTest, TestDequant_4x4_c)
{
short W[16], T[16];
unsigned short mf[16];
for (int i = 0; i < 16; i++) {
W[i] = rand() % 256 + 1;
T[i] = W[i];
}
for (int i = 0; i < 8; i++) {
mf[i] = rand() % 16 + 1;
}
WelsDequant4x4_c(W, mf);
for (int i = 0; i < 16; i++) {
EXPECT_EQ(T[i]*mf[i % 8], W[i]);
}
}
TEST(DecodeMbAuxTest, TestDequant_4_4x4_c)
{
short W[64], T[64];
unsigned short mf[16];
for (int i = 0; i < 64; i++) {
W[i] = rand() % 256 + 1;
T[i] = W[i];
}
for (int i = 0; i < 8; i++) {
mf[i] = rand() % 16 + 1;
}
WelsDequantFour4x4_c(W, mf);
for (int i = 0; i < 64; i++) {
EXPECT_EQ(T[i]*mf[i % 8], W[i]);
}
}
void WelsDequantHadamard2x2DcAnchor(int16_t* pDct, int16_t iMF)
{
const int16_t iSumU = pDct[0] + pDct[2];
const int16_t iDelU = pDct[0] - pDct[2];
const int16_t iSumD = pDct[1] + pDct[3];
const int16_t iDelD = pDct[1] - pDct[3];
pDct[0] = ((iSumU + iSumD) * iMF) >> 1;
pDct[1] = ((iSumU - iSumD) * iMF) >> 1;
pDct[2] = ((iDelU + iDelD) * iMF) >> 1;
pDct[3] = ((iDelU - iDelD) * iMF) >> 1;
}
TEST(DecodeMbAuxTest, WelsDequantIHadamard2x2Dc)
{
int16_t iDct[4], iRefDct[4];
int16_t iMF;
iMF = rand() & 127;
for (int i = 0; i < 4; i++) {
iDct[i] = iRefDct[i] = (rand() & 65535) - 32768;
}
WelsDequantHadamard2x2DcAnchor(iRefDct, iMF);
WelsDequantIHadamard2x2Dc(iDct, iMF);
bool ok = true;
for (int i = 0; i < 4; i++) {
if (iDct[i] != iRefDct[i]) {
ok = false;
break;
}
}
EXPECT_TRUE(ok);
}
#define FDEC_STRIDE 32
void WelsIDctT4Anchor(uint8_t* p_dst, int16_t dct[16])
{
int16_t tmp[16];
int32_t iStridex2 = (FDEC_STRIDE << 1);
int32_t iStridex3 = iStridex2 + FDEC_STRIDE;
uint8_t uiDst = 0;
int i;
for (i = 0; i < 4; i++) {
tmp[i << 2] = dct[i << 2] + dct[(i << 2) + 1] + dct[(i << 2) + 2] + (dct[(i << 2) + 3] >> 1);
tmp[(i << 2) + 1] = dct[i << 2] + (dct[(i << 2) + 1] >> 1) - dct[(i << 2) + 2] - dct[(i << 2) + 3];
tmp[(i << 2) + 2] = dct[i << 2] - (dct[(i << 2) + 1] >> 1) - dct[(i << 2) + 2] + dct[(i << 2) + 3];
tmp[(i << 2) + 3] = dct[i << 2] - dct[(i << 2) + 1] + dct[(i << 2) + 2] - (dct[(i << 2) + 3] >> 1);
}
for (i = 0; i < 4; i++) {
uiDst = p_dst[i];
p_dst[i] = WelsClip1(uiDst + ((tmp[i] + tmp[4 + i] + tmp[8 + i] + (tmp[12 + i] >> 1) + 32) >> 6));
uiDst = p_dst[i + FDEC_STRIDE];
p_dst[i + FDEC_STRIDE] = WelsClip1(uiDst + ((tmp[i] + (tmp[4 + i] >> 1) - tmp[8 + i] - tmp[12 + i] + 32) >> 6));
uiDst = p_dst[i + iStridex2];
p_dst[i + iStridex2] = WelsClip1(uiDst + ((tmp[i] - (tmp[4 + i] >> 1) - tmp[8 + i] + tmp[12 + i] + 32) >> 6));
uiDst = p_dst[i + iStridex3];
p_dst[i + iStridex3] = WelsClip1(uiDst + ((tmp[i] - tmp[4 + i] + tmp[8 + i] - (tmp[12 + i] >> 1) + 32) >> 6));
}
}
TEST(DecodeMbAuxTest, WelsIDctT4Rec_c)
{
int16_t iRefDct[16];
uint8_t iRefDst[16 * FDEC_STRIDE];
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRec, 16 * FDEC_STRIDE, 16);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
iRefDct[i * 4 + j] = iDct[i * 4 + j] = (rand() & 65535) - 32768;
iPred[i * FDEC_STRIDE + j] = iRefDst[i * FDEC_STRIDE + j] = rand() & 255;
}
}
WelsIDctT4Anchor(iRefDst, iRefDct);
WelsIDctT4Rec_c(iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (iRec[i * FDEC_STRIDE + j] != iRefDst[i * FDEC_STRIDE + j]) {
ok = i * 4 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
}
#if defined(X86_ASM)
TEST(DecodeMbAuxTest, WelsIDctT4Rec_mmx)
{
int32_t iCpuCores = 0;
uint32_t uiCpuFeatureFlag = WelsCPUFeatureDetect(&iCpuCores);
if (uiCpuFeatureFlag & WELS_CPU_MMXEXT) {
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRecC, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRecM, 16 * FDEC_STRIDE, 16);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
iDct[i * 4 + j] = (rand() & ((1 << 12) - 1)) - (1 << 11);
iPred[i * FDEC_STRIDE + j] = rand() & 255;
}
}
WelsIDctT4Rec_c(iRecC, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
WelsIDctT4Rec_mmx(iRecM, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (iRecC[i * FDEC_STRIDE + j] != iRecM[i * FDEC_STRIDE + j]) {
ok = i * 4 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
}
}
#endif
void WelsIDctT8Anchor(uint8_t* p_dst, int16_t dct[4][16])
{
WelsIDctT4Anchor(&p_dst[0], dct[0]);
WelsIDctT4Anchor(&p_dst[4], dct[1]);
WelsIDctT4Anchor(&p_dst[4 * FDEC_STRIDE + 0], dct[2]);
WelsIDctT4Anchor(&p_dst[4 * FDEC_STRIDE + 4], dct[3]);
}
TEST(DecodeMbAuxTest, WelsIDctFourT4Rec_c)
{
int16_t iRefDct[4][16];
uint8_t iRefDst[16 * FDEC_STRIDE];
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 64, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRec, 16 * FDEC_STRIDE, 16);
for (int k = 0; k < 4; k++)
for (int i = 0; i < 16; i++) {
iRefDct[k][i] = iDct[k * 16 + i] = (rand() & 65535) - 32768;
}
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++) {
iPred[i * FDEC_STRIDE + j] = iRefDst[i * FDEC_STRIDE + j] = rand() & 255;
}
WelsIDctT8Anchor(iRefDst, iRefDct);
WelsIDctFourT4Rec_c(iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (iRec[i * FDEC_STRIDE + j] != iRefDst[i * FDEC_STRIDE + j]) {
ok = i * 8 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
}
void WelsIDctRecI16x4DcAnchor(uint8_t* p_dst, int16_t dct[4])
{
for (int i = 0; i < 4; i++, p_dst += FDEC_STRIDE) {
p_dst[0] = WelsClip1(p_dst[0] + ((dct[0] + 32) >> 6));
p_dst[1] = WelsClip1(p_dst[1] + ((dct[0] + 32) >> 6));
p_dst[2] = WelsClip1(p_dst[2] + ((dct[0] + 32) >> 6));
p_dst[3] = WelsClip1(p_dst[3] + ((dct[0] + 32) >> 6));
p_dst[4] = WelsClip1(p_dst[4] + ((dct[1] + 32) >> 6));
p_dst[5] = WelsClip1(p_dst[5] + ((dct[1] + 32) >> 6));
p_dst[6] = WelsClip1(p_dst[6] + ((dct[1] + 32) >> 6));
p_dst[7] = WelsClip1(p_dst[7] + ((dct[1] + 32) >> 6));
p_dst[8] = WelsClip1(p_dst[8] + ((dct[2] + 32) >> 6));
p_dst[9] = WelsClip1(p_dst[9] + ((dct[2] + 32) >> 6));
p_dst[10] = WelsClip1(p_dst[10] + ((dct[2] + 32) >> 6));
p_dst[11] = WelsClip1(p_dst[11] + ((dct[2] + 32) >> 6));
p_dst[12] = WelsClip1(p_dst[12] + ((dct[3] + 32) >> 6));
p_dst[13] = WelsClip1(p_dst[13] + ((dct[3] + 32) >> 6));
p_dst[14] = WelsClip1(p_dst[14] + ((dct[3] + 32) >> 6));
p_dst[15] = WelsClip1(p_dst[15] + ((dct[3] + 32) >> 6));
}
}
void WelsIDctRecI16x16DcAnchor(uint8_t* p_dst, int16_t dct[4][4])
{
for (int i = 0; i < 4; i++, p_dst += 4 * FDEC_STRIDE) {
WelsIDctRecI16x4DcAnchor(&p_dst[0], dct[i]);
}
}
TEST(DecodeMbAuxTest, WelsIDctRecI16x16Dc_c)
{
uint8_t iRefDst[16 * FDEC_STRIDE];
int16_t iRefDct[4][4];
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRec, 16 * FDEC_STRIDE, 16);
for (int i = 0; i < 16; i++)
for (int j = 0; j < 16; j++) {
iRefDst[i * FDEC_STRIDE + j] = iPred[i * FDEC_STRIDE + j] = rand() & 255;
}
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++) {
iRefDct[i][j] = iDct[i * 4 + j] = (rand() & 65535) - 32768;
}
WelsIDctRecI16x16DcAnchor(iRefDst, iRefDct);
WelsIDctRecI16x16Dc_c(iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
if (iRec[i * FDEC_STRIDE + j] != iRefDst[i * FDEC_STRIDE + j]) {
ok = i * 16 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
}
#if defined(X86_ASM)
TEST(DecodeMbAuxTest, WelsIDctRecI16x16Dc_sse2)
{
int32_t iCpuCores = 0;
uint32_t uiCpuFeatureFlag = WelsCPUFeatureDetect(&iCpuCores);
if (uiCpuFeatureFlag & WELS_CPU_SSE2) {
uint8_t iRefDst[16 * FDEC_STRIDE];
int16_t iRefDct[4][4];
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRec, 16 * FDEC_STRIDE, 16);
for (int i = 0; i < 16; i++)
for (int j = 0; j < 16; j++) {
iRefDst[i * FDEC_STRIDE + j] = iPred[i * FDEC_STRIDE + j] = rand() & 255;
}
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
iRefDct[i][j] = iDct[i * 4 + j] = (rand() & ((1 << 15) - 1)) - (1 <<
14); //2^14 limit, (2^15+32) will cause overflow for SSE2.
WelsIDctRecI16x16DcAnchor(iRefDst, iRefDct);
WelsIDctRecI16x16Dc_sse2(iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
if (iRec[i * FDEC_STRIDE + j] != iRefDst[i * FDEC_STRIDE + j]) {
ok = i * 16 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
}
}
#endif
| [
"jason_yao"
] | jason_yao |
ab76687061bc0b989688b17e9d4ac337ad3a6af2 | c3283332ea47f8d61b5e09ba0b31eda2bf3c3f5b | /L04/lab04ex1_master/skeleton/SocialNetwork.h | 984728687c21d83f441fb02d18070e1328046662 | [] | no_license | wrigglingears/cs1020e_2016-2017_s2 | 258cf7886842b13c236e20551a1ee4cbc4ff57f9 | d3a5a62d9a09417509306a6329c62ef189fbdbda | refs/heads/master | 2021-01-11T20:27:59.724168 | 2017-03-10T07:53:03 | 2017-03-10T07:53:03 | 79,122,059 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,067 | h | //=====================================================================
// FILE: SocialNetwork.h
//=====================================================================
//=====================================================================
// STUDENT NAME: <your name>
// MATRIC NO. : <matric no.>
// NUS EMAIL : <your NUS email address>
// COMMENTS TO GRADER:
// <comments to grader, if any>
//
//=====================================================================
#ifndef social_network_h
#define social_network_h
#include <string>
#include <vector>
#include "Person.h"
#include "Group.h"
using namespace std;
class SocialNetwork{
private:
vector <Group *> groups;
vector <Person *> persons;
public:
SocialNetwork();
Person * addPerson(string name);
Group * addGroup (string name);
Person * findPerson (string name);
Group * findGroup (string name);
void createjoin (string, string);
void quit (string, string);
string answerQuery1();
string answerQuery2();
// Add more here if necessary.
};
#endif
| [
"mattheus.lee@gmail.com"
] | mattheus.lee@gmail.com |
605fbfd558e6dccae03926aa5fbaeefc824e635c | da741c443fd6bdf19dfcfc1193ce198aff66505c | /Programación en C++/19 POO - Clases Derivadas - Herencia y Polimorfismo/Codigos/3. Destructores/ClaseDerivada.h | 321f0346afc83f7328ec398cb24b941b7157bd93 | [] | no_license | AbrahamFB/Programaci-n-en-C-B-sico---Intermedio---Avanzado- | d5dad53a83f844d93dc3fe772c6ecb80d1fd04de | 9f3c312c39a60dc7b2ca437d24cc7607055f40b0 | refs/heads/master | 2022-07-19T19:15:19.342667 | 2020-05-17T01:53:53 | 2020-05-17T01:53:53 | 264,562,774 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 364 | h | #include<iostream>
#include "ClaseBase.h"
using namespace std;
class ClaseDerivada : public ClaseBase{
private:
int numero2;
public:
ClaseDerivada(int numero,int numero2) : ClaseBase(numero){
this->numero2 = numero2;
cout<<"Constructor de la clase Derivada"<<endl;
}
~ClaseDerivada(){
cout<<"Destructor de la clase Derivada"<<endl;
}
};
| [
"44345256+AbrahamFB@users.noreply.github.com"
] | 44345256+AbrahamFB@users.noreply.github.com |
5a755ad9a9464584c1bee8d657324ff9b127953b | ece42d77ca9f1d95f0dc3da06295ce6afddae0a2 | /dire/include/DirePlugins/mg5/Processes_sm/PY8MEs_R5_P10_sm_bb_abb.h | 4e84caa54ac19852e192cef25d35f1de4d372811 | [] | no_license | prestel/hadrotomte | 7d51b6a0cc40af2ddc58cfbe126e46023b416dc3 | c537e56fe4ca8b19413bc7dcc266c1cb9b570f47 | refs/heads/master | 2023-06-30T07:27:54.987000 | 2021-08-03T12:10:56 | 2021-08-03T12:10:56 | 386,714,081 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,509 | h | //==========================================================================
// This file has been automatically generated for Pythia 8
// MadGraph5_aMC@NLO v. 2.6.0, 2017-08-16
// By the MadGraph5_aMC@NLO Development Team
// Visit launchpad.net/madgraph5 and amcatnlo.web.cern.ch
//==========================================================================
#ifndef PY8MEs_R5_P10_sm_bb_abb_H
#define PY8MEs_R5_P10_sm_bb_abb_H
#include "Complex.h"
#include <vector>
#include <set>
#include <exception>
#include <iostream>
#include "Parameters_sm.h"
#include "PY8MEs.h"
using namespace std;
namespace PY8MEs_namespace
{
//==========================================================================
// A class for calculating the matrix elements for
// Process: b b > a b b WEIGHTED<=99 @5
// Process: b b~ > a b b~ WEIGHTED<=99 @5
// Process: b~ b~ > a b~ b~ WEIGHTED<=99 @5
//--------------------------------------------------------------------------
typedef vector<double> vec_double;
typedef vector < vec_double > vec_vec_double;
typedef vector<int> vec_int;
typedef vector<bool> vec_bool;
typedef vector < vec_int > vec_vec_int;
class PY8MEs_R5_P10_sm_bb_abb : public PY8ME
{
public:
// Check for the availability of the requested proces.
// If available, this returns the corresponding permutation and Proc_ID to
// use.
// If not available, this returns a negative Proc_ID.
static pair < vector<int> , int > static_getPY8ME(vector<int> initial_pdgs,
vector<int> final_pdgs, set<int> schannels = set<int> ());
// Constructor.
PY8MEs_R5_P10_sm_bb_abb(Parameters_sm * model) : pars(model) {initProc();}
// Destructor.
~PY8MEs_R5_P10_sm_bb_abb();
// Initialize process.
virtual void initProc();
// Calculate squared ME.
virtual double sigmaKin();
// Info on the subprocess.
virtual string name() const {return "bb_abb (sm)";}
virtual int code() const {return 10510;}
virtual string inFlux() const {return "qq";}
virtual vector<double> getMasses();
virtual void setMasses(vec_double external_masses);
// Set all values of the external masses to an integer mode:
// 0 : Mass taken from the model
// 1 : Mass taken from p_i^2 if not massless to begin with
// 2 : Mass always taken from p_i^2.
virtual void setExternalMassesMode(int mode);
// Synchronize local variables of the process that depend on the model
// parameters
virtual void syncProcModelParams();
// Tell Pythia that sigmaHat returns the ME^2
virtual bool convertM2() const {return true;}
// Access to getPY8ME with polymorphism from a non-static context
virtual pair < vector<int> , int > getPY8ME(vector<int> initial_pdgs,
vector<int> final_pdgs, set<int> schannels = set<int> ())
{
return static_getPY8ME(initial_pdgs, final_pdgs, schannels);
}
// Set momenta
virtual void setMomenta(vector < vec_double > momenta_picked);
// Set color configuration to use. An empty vector means sum over all.
virtual void setColors(vector<int> colors_picked);
// Set the helicity configuration to use. Am empty vector means sum over
// all.
virtual void setHelicities(vector<int> helicities_picked);
// Set the permutation to use (will apply to momenta, colors and helicities)
virtual void setPermutation(vector<int> perm_picked);
// Set the proc_ID to use
virtual void setProcID(int procID_picked);
// Access to all the helicity and color configurations for a given process
virtual vector < vec_int > getColorConfigs(int specify_proc_ID = -1,
vector<int> permutation = vector<int> ());
virtual vector < vec_int > getHelicityConfigs(vector<int> permutation =
vector<int> ());
// Maps of Helicity <-> hel_ID and ColorConfig <-> colorConfig_ID.
virtual vector<int> getHelicityConfigForID(int hel_ID, vector<int>
permutation = vector<int> ());
virtual int getHelicityIDForConfig(vector<int> hel_config, vector<int>
permutation = vector<int> ());
virtual vector<int> getColorConfigForID(int color_ID, int specify_proc_ID =
-1, vector<int> permutation = vector<int> ());
virtual int getColorIDForConfig(vector<int> color_config, int
specify_proc_ID = -1, vector<int> permutation = vector<int> ());
virtual int getColorFlowRelativeNCPower(int color_flow_ID, int
specify_proc_ID = -1);
// Access previously computed results
virtual vector < vec_double > getAllResults(int specify_proc_ID = -1);
virtual double getResult(int helicity_ID, int color_ID, int specify_proc_ID
= -1);
// Accessors
Parameters_sm * getModel() {return pars;}
void setModel(Parameters_sm * model) {pars = model;}
// Invert the permutation mapping
vector<int> invert_mapping(vector<int> mapping);
// Control whether to include the symmetry factors or not
virtual void setIncludeSymmetryFactors(bool OnOff)
{
include_symmetry_factors = OnOff;
}
virtual bool getIncludeSymmetryFactors() {return include_symmetry_factors;}
virtual int getSymmetryFactor() {return denom_iden[proc_ID];}
// Control whether to include helicity averaging factors or not
virtual void setIncludeHelicityAveragingFactors(bool OnOff)
{
include_helicity_averaging_factors = OnOff;
}
virtual bool getIncludeHelicityAveragingFactors()
{
return include_helicity_averaging_factors;
}
virtual int getHelicityAveragingFactor() {return denom_hels[proc_ID];}
// Control whether to include color averaging factors or not
virtual void setIncludeColorAveragingFactors(bool OnOff)
{
include_color_averaging_factors = OnOff;
}
virtual bool getIncludeColorAveragingFactors()
{
return include_color_averaging_factors;
}
virtual int getColorAveragingFactor() {return denom_colors[proc_ID];}
private:
// Private functions to calculate the matrix element for all subprocesses
// Calculate wavefunctions
void calculate_wavefunctions(const int hel[]);
static const int nwavefuncs = 57;
Complex<double> w[nwavefuncs][18];
static const int namplitudes = 96;
Complex<double> amp[namplitudes];
double matrix_5_bb_abb();
double matrix_5_bbx_abbx();
double matrix_5_bxbx_abxbx();
// Constants for array limits
static const int nexternal = 5;
static const int ninitial = 2;
static const int nprocesses = 3;
static const int nreq_s_channels = 0;
static const int ncomb = 32;
// Helicities for the process
static int helicities[ncomb][nexternal];
// Normalization factors the various processes
static int denom_colors[nprocesses];
static int denom_hels[nprocesses];
static int denom_iden[nprocesses];
// Control whether to include symmetry factors or not
bool include_symmetry_factors;
// Control whether to include helicity averaging factors or not
bool include_helicity_averaging_factors;
// Control whether to include color averaging factors or not
bool include_color_averaging_factors;
// Color flows, used when selecting color
vector < vec_double > jamp2;
// Store individual results (for each color flow, helicity configurations
// and proc_ID)
// computed in the last call to sigmaKin().
vector < vec_vec_double > all_results;
// required s-channels specified
static std::set<int> s_channel_proc;
// vector with external particle masses
vector<double> mME;
// vector with momenta (to be changed for each event)
vector < double * > p;
// external particles permutation (to be changed for each event)
vector<int> perm;
// vector with colors (to be changed for each event)
vector<int> user_colors;
// vector with helicities (to be changed for each event)
vector<int> user_helicities;
// Process ID (to be changed for each event)
int proc_ID;
// All color configurations
void initColorConfigs();
vector < vec_vec_int > color_configs;
// Color flows relative N_c power (conventions are such that all elements
// on the color matrix diagonal are identical).
vector < vec_int > jamp_nc_relative_power;
// Model pointer to be used by this matrix element
Parameters_sm * pars;
};
} // end namespace PY8MEs_namespace
#endif // PY8MEs_R5_P10_sm_bb_abb_H
| [
"stefan.prestel.work@gmail.com"
] | stefan.prestel.work@gmail.com |
2e5b6d982c3e84e40ad29eabb5dba4a1777c7f54 | 0a50e8ee921eed7f7f005729bbe7eee4e03b80b1 | /PincherCommander/PincherCommander.ino | fbcdbbdbef3aae51524ab26282fcdce6787b3630 | [] | no_license | Interbotix/PincherCommander | 73217099306d8fc4e02765d4c70616d8b284a27f | 7f820fb83897e11723da2672885e408fe3b68872 | refs/heads/master | 2021-01-01T17:11:05.466830 | 2013-08-12T23:01:01 | 2013-08-12T23:01:01 | 12,066,739 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,751 | ino |
//=============================================================================
//=============================================================================
// Define Options
//=============================================================================
//#define OPT_WRISTROT // comment this out if you are not using the wrist rotate (Pincher does not)
#define ARBOTIX_TO 1000 // if no message for a second probably turned off...
#define DEADZONE 3 // deadzone around center of joystick values
#define SOUND_PIN 1 // Tell system we have added speaker to IO pin 1
#define MAX_SERVO_DELTA_PERSEC 512
//#define DEBUG // Enable Debug mode via serial
//=============================================================================
// Global Include files
//=============================================================================
#include <ax12.h>
#include <BioloidController.h>
#include <Commander.h>
//=============================================================================
//=============================================================================
/* Servo IDs */
enum {
SID_BASE=1, SID_SHOULDER, SID_ELBOW, SID_WRIST, SID_GRIP};
enum {
IKM_IK3D_CARTESIAN, IKM_CYLINDRICAL, IKM_BACKHOE};
// status messages for IK return codes..
enum {
IKS_SUCCESS=0, IKS_WARNING, IKS_ERROR};
#define CNT_SERVOS 5 //(sizeof(pgm_axdIDs)/sizeof(pgm_axdIDs[0]))
// Define some Min and Maxs for IK Movements...
// y Z
// | /
// |/
// ----+----X (X and Y are flat on ground, Z is up in air...
// |
// |
#define IK_MAX_X 200
#define IK_MIN_X -200
#define IK_MAX_Y 240
#define IK_MIN_Y 50
#define IK_MAX_Z 250
#define IK_MIN_Z 20
#define IK_MAX_GA 90
#define IK_MIN_GA -90
// Define Ranges for the different servos...
#define BASE_MIN 0
#define BASE_MAX 1023
#define SHOULDER_MIN 205
#define SHOULDER_MAX 815
#define ELBOW_MIN 205
#define ELBOW_MAX 1023
#define WRIST_MIN 205
#define WRIST_MAX 815
#define WROT_MIN 0
#define WROT_MAX 1023
#define GRIP_MIN 0
#define GRIP_MAX 512
// Define some lengths and offsets used by the arm
#define BaseHeight 140L // (L0)about 120mm
#define ShoulderLength 105L // (L1)Not sure yet what to do as the servo is not directly in line, Probably best to offset the angle?
#define ElbowLength 105L //(L2)Length of the Arm from Elbow Joint to Wrist Joint
#define WristLength 100L // (L3)Wrist length including Wrist rotate
#define G_OFFSET 0 // Offset for static side of gripper?
#define IK_FUDGE 5 // How much a fudge between warning and error
//=============================================================================
// Global Objects
//=============================================================================
Commander command = Commander();
BioloidController bioloid = BioloidController(1000000);
//=============================================================================
// Global Variables...
//=============================================================================
boolean g_fArmActive = false; // Is the arm logically on?
byte g_bIKMode = IKM_IK3D_CARTESIAN; // Which mode of operation are we in...
uint8_t g_bIKStatus = IKS_SUCCESS; // Status of last call to DoArmIK;
boolean g_fServosFree = true;
// Current IK values
int g_sIKGA; // IK Gripper angle..
int g_sIKX; // Current X value in mm
int g_sIKY; //
int g_sIKZ;
// Values for current servo values for the different joints
int g_sBase; // Current Base servo value
int g_sShoulder; // Current shoulder target
int g_sElbow; // Current
int g_sWrist; // Current Wrist value
int g_sWristRot; // Current Wrist rotation
int g_sGrip; // Current Grip position
// BUGBUG:: I hate too many globals...
int sBase, sShoulder, sElbow, sWrist, sWristRot, sGrip;
// Message informatino
unsigned long ulLastMsgTime; // Keep track of when the last message arrived to see if controller off
byte buttonsPrev; // will use when we wish to only process a button press once
//
#ifdef DEBUG
boolean g_fDebugOutput = false;
#endif
// Forward references
extern void MSound(byte cNotes, ...);
//===================================================================================================
// Setup
//====================================================================================================
void setup() {
pinMode(0,OUTPUT);
// Lets initialize the Commander
command.begin(38400);
// Next initialize the Bioloid
bioloid.poseSize = CNT_SERVOS;
// Read in the current positions...
bioloid.readPose();
// Start off to put arm to sleep...
Serial.println("Hello World!");
PutArmToSleep();
MSound(3, 60, 2000, 80, 2250, 100, 2500);
//set Gripper Compliance so it doesn't tear itself apart
ax12SetRegister(SID_GRIP, AX_CW_COMPLIANCE_SLOPE, 128);
ax12SetRegister(SID_GRIP, AX_CCW_COMPLIANCE_SLOPE, 128);
}
//===================================================================================================
// loop: Our main Loop!
//===================================================================================================
void loop() {
boolean fChanged = false;
if (command.ReadMsgs()) {
digitalWrite(0,HIGH-digitalRead(0));
// See if the Arm is active yet...
if (g_fArmActive) {
sBase = g_sBase;
sShoulder = g_sShoulder;
sElbow = g_sElbow;
sWrist = g_sWrist;
sGrip = g_sGrip;
sWristRot = g_sWristRot;
if ((command.buttons & BUT_R1) && !(buttonsPrev & BUT_R1)) {
if (++g_bIKMode > IKM_BACKHOE)
g_bIKMode = 0;
// For now lets always move arm to the home position of the new input method...
// Later maybe we will get the current position and covert to the coordinate system
// of the current input method.
MoveArmToHome();
}
else if ((command.buttons & BUT_R2) && !(buttonsPrev & BUT_R2)) {
MoveArmToHome();
}
// Going to use L6 in combination with the right joystick to control both the gripper and the
// wrist rotate...
else if (command.buttons & BUT_L6) {
sGrip = min(max(sGrip + command.lookV/5, GRIP_MIN), GRIP_MAX);
sWristRot = min(max(g_sWristRot + command.lookH/6, WROT_MIN), WROT_MAX);
fChanged = (sGrip != g_sGrip) || (sWristRot != g_sWristRot);
}
else {
switch (g_bIKMode) {
case IKM_IK3D_CARTESIAN:
fChanged |= ProcessUserInput3D();
break;
case IKM_CYLINDRICAL:
fChanged |= ProcessUserInputCylindrical();
break;
case IKM_BACKHOE:
fChanged |= ProcessUserInputBackHoe();
break;
}
}
// If something changed and we are not in an error condition
if (fChanged && (g_bIKStatus != IKS_ERROR)) {
MoveArmTo(sBase, sShoulder, sElbow, sWrist, sWristRot, sGrip, 100, true);
}
#ifdef DEBUG
if ((command.buttons & BUT_R3) && !(buttonsPrev & BUT_R3)) {
g_fDebugOutput = !g_fDebugOutput;
MSound( 1, 45, g_fDebugOutput? 3000 : 2000);
}
#endif
else if (bioloid.interpolating > 0) {
bioloid.interpolateStep();
}
}
else {
g_fArmActive = true;
MoveArmToHome();
}
buttonsPrev = command.buttons;
ulLastMsgTime = millis(); // remember when we last got a message...
}
else {
if (bioloid.interpolating > 0) {
bioloid.interpolateStep();
}
// error see if we exceeded a timeout
if (g_fArmActive && ((millis() - ulLastMsgTime) > ARBOTIX_TO)) {
PutArmToSleep();
}
}
}
//===================================================================================================
// ProcessUserInput3D: Process the Userinput when we are in 3d Mode
//===================================================================================================
boolean ProcessUserInput3D(void) {
// We Are in IK mode, so figure out what position we would like the Arm to move to.
// We have the Coordinates system like:
//
// y Z
// | /
// |/
// ----+----X (X and Y are flat on ground, Z is up in air...
// |
// |
//
boolean fChanged = false;
int sIKX; // Current X value in mm
int sIKY; //
int sIKZ;
int sIKGA;
// Limit how far we can go by checking the status of the last move. If we are in a warning or error
// condition, don't allow the arm to move farther away...
if (g_bIKStatus == IKS_SUCCESS) {
sIKX = min(max(g_sIKX + command.walkH/10, IK_MIN_X), IK_MAX_X);
sIKY = min(max(g_sIKY + command.walkV/10, IK_MIN_Y), IK_MAX_Y);
sIKZ = min(max(g_sIKZ + command.lookV/15, IK_MIN_Z), IK_MAX_Z);
if (command.buttons & BUT_LT) {
sIKGA = min(max(g_sIKGA + command.lookH/30, IK_MIN_GA), IK_MAX_GA); // Currently in Servo coords...
}
else {
sIKGA = min(max(g_sIKGA, IK_MIN_GA), IK_MAX_GA); // Currently in Servo coords...
}
}
else {
// In an Error/warning condition, only allow things to move in closer...
sIKX = g_sIKX;
sIKY = g_sIKY;
sIKZ = g_sIKZ;
sIKGA = g_sIKGA;
if (((g_sIKX > 0) && (command.walkH < 0)) || ((g_sIKX < 0) && (command.walkH > 0)))
sIKX = min(max(g_sIKX + command.walkH/10, IK_MIN_X), IK_MAX_X);
if (((g_sIKY > 0) && (command.walkV < 0)) || ((g_sIKY < 0) && (command.walkV > 0)))
sIKY = min(max(g_sIKY + command.walkV/10, IK_MIN_Y), IK_MAX_Y);
if (((g_sIKZ > 0) && (command.lookV < 0)) || ((g_sIKZ < 0) && (command.lookV > 0)))
sIKZ = min(max(g_sIKZ + command.lookV/15, IK_MIN_Z), IK_MAX_Z);
if (((g_sIKGA > 0) && (command.lookH < 0)) || ((g_sIKGA < 0) && (command.lookH > 0)))
sIKGA = min(max(g_sIKGA, IK_MIN_GA), IK_MAX_GA); // Currently in Servo coords...
}
fChanged = (sIKX != g_sIKX) || (sIKY != g_sIKY) || (sIKZ != g_sIKZ) || (sIKGA != g_sIKGA) ;
if (fChanged) {
g_bIKStatus = doArmIK(true, sIKX, sIKY, sIKZ, sIKGA);
}
return fChanged;
}
//===================================================================================================
// ProcessUserInputCylindrical: Process the Userinput when we are in 3d Mode
//===================================================================================================
boolean ProcessUserInputCylindrical() {
// We Are in IK mode, so figure out what position we would like the Arm to move to.
// We have the Coordinates system like:
//
// y Z
// | /
// |/
// ----+----X (X and Y are flat on ground, Z is up in air...
// |
// |
//
boolean fChanged = false;
int sIKY; // Distance from base in mm
int sIKZ;
int sIKGA;
// Will try combination of the other two modes. Will see if I need to do the Limits on the IK values
// or simply use the information from the Warning/Error from last call to the IK function...
sIKY = g_sIKY;
sIKZ = g_sIKZ;
sIKGA = g_sIKGA;
// The base rotate is real simple, just allow it to rotate in the min/max range...
sBase = min(max(g_sBase - command.walkH/10, BASE_MIN), BASE_MAX);
// Limit how far we can go by checking the status of the last move. If we are in a warning or error
// condition, don't allow the arm to move farther away...
// Use Y for 2d distance from base
if ((g_bIKStatus == IKS_SUCCESS) || ((g_sIKY > 0) && (command.walkV < 0)) || ((g_sIKY < 0) && (command.walkV > 0)))
sIKY += command.walkV/10;
// Now Z coordinate...
if ((g_bIKStatus == IKS_SUCCESS) || ((g_sIKZ > 0) && (command.lookV < 0)) || ((g_sIKZ < 0) && (command.lookV > 0)))
sIKZ += command.lookV/15;
// And gripper angle. May leave in Min/Max here for other reasons...
if (command.buttons & BUT_LT) {
if ((g_bIKStatus == IKS_SUCCESS) || ((g_sIKGA > 0) && (command.lookH < 0)) || ((g_sIKGA < 0) && (command.lookH > 0)))
sIKGA = min(max(g_sIKGA + command.lookH/30, IK_MIN_GA), IK_MAX_GA); // Currently in Servo coords...
}
fChanged = (sBase != g_sBase) || (sIKY != g_sIKY) || (sIKZ != g_sIKZ) || (sIKGA != g_sIKGA) ;
if (fChanged) {
g_bIKStatus = doArmIK(false, sBase, sIKY, sIKZ, sIKGA);
}
return fChanged;
}
//===================================================================================================
// ProcessUserInputBackHoe: Process the Userinput when we are in 3d Mode
//===================================================================================================
boolean ProcessUserInputBackHoe() {
// lets update positions with the 4 joystick values
// First the base
boolean fChanged = false;
sBase = min(max(g_sBase - command.walkH/6, BASE_MIN), BASE_MAX);
if (sBase != g_sBase)
fChanged = true;
// Now the Boom
sShoulder = min(max(g_sShoulder + command.lookV/6, SHOULDER_MIN), SHOULDER_MAX);
if (sShoulder != g_sShoulder)
fChanged = true;
// Now the Dipper
sElbow = min(max(g_sElbow + command.walkV/6, ELBOW_MIN), ELBOW_MAX);
if (sElbow != g_sElbow)
fChanged = true;
// Bucket Curl
sWrist = min(max(g_sWrist + command.lookH/6, WRIST_MIN), WRIST_MAX);
if (sWrist != g_sWrist)
fChanged = true;
return fChanged;
}
//===================================================================================================
// MoveArmToHome
//===================================================================================================
void MoveArmToHome(void) {
if (g_bIKMode != IKM_BACKHOE) {
g_bIKStatus = doArmIK(true, 0, (2*ElbowLength)/3+WristLength, BaseHeight+(2*ShoulderLength)/3, 0);
MoveArmTo(sBase, sShoulder, sElbow, sWrist, 512, 256, 500, true);
}
else {
g_bIKStatus = IKS_SUCCESS; // assume sucess so we will continue to move...
MoveArmTo(512, 400, 1000, 430, 512, 256, 1000, true);
}
}
//===================================================================================================
// PutArmToSleep
//===================================================================================================
void PutArmToSleep(void) {
g_fArmActive = false;
MoveArmTo(512, 400, 1000, 430, 512, 256, 1000, true);
// And Relax all of the servos...
for(uint8_t i=1; i <= CNT_SERVOS; i++) {
Relax(i);
}
g_fServosFree = true;
}
//===================================================================================================
// MoveArmTo
//===================================================================================================
void MoveArmTo(int sBase, int sShoulder, int sElbow, int sWrist, int sWristRot, int sGrip, int wTime, boolean fWait) {
int sMaxDelta;
int sDelta;
// First make sure servos are not free...
if (g_fServosFree) {
g_fServosFree = false;
for(uint8_t i=1; i <= CNT_SERVOS; i++) {
TorqueOn(i);
}
bioloid.readPose();
}
#ifdef DEBUG
if (g_fDebugOutput) {
Serial.print("[");
Serial.print(sBase, DEC);
Serial.print(" ");
Serial.print(sShoulder, DEC);
Serial.print(" ");
Serial.print(sElbow, DEC);
Serial.print(" ");
Serial.print(sWrist, DEC);
Serial.print(" ");
Serial.print(sWristRot, DEC);
Serial.print(" ");
Serial.print(sGrip, DEC);
Serial.println("]");
}
#endif
// Make sure the previous movement completed.
// Need to do it before setNextPos calls as this
// is used in the interpolating code...
while (bioloid.interpolating > 0) {
bioloid.interpolateStep();
delay(3);
}
// Also lets limit how fast the servos will move as to not get whiplash.
bioloid.setNextPose(SID_BASE, sBase);
sMaxDelta = abs(bioloid.getCurPose(SID_SHOULDER) - sShoulder);
bioloid.setNextPose(SID_SHOULDER, sShoulder);
sDelta = abs(bioloid.getCurPose(SID_ELBOW) - sElbow);
if (sDelta > sMaxDelta)
sMaxDelta = sDelta;
bioloid.setNextPose(SID_ELBOW, sElbow);
sDelta = abs(bioloid.getCurPose(SID_WRIST) - sWrist);
if (sDelta > sMaxDelta)
sMaxDelta = sDelta;
bioloid.setNextPose(SID_WRIST, sWrist);
#ifdef OPT_WRISTROT
bioloid.setNextPose(SID_WRISTROT, sWristRot);
#endif
bioloid.setNextPose(SID_GRIP, sGrip);
// Save away the current positions...
g_sBase = sBase;
g_sShoulder = sShoulder;
g_sElbow = sElbow;
g_sWrist = sWrist;
g_sWristRot = sWristRot;
g_sGrip = sGrip;
// Now start the move - But first make sure we don't move too fast.
if (((long)sMaxDelta*wTime/1000L) > MAX_SERVO_DELTA_PERSEC) {
wTime = ((long)sMaxDelta*1000L)/ MAX_SERVO_DELTA_PERSEC;
}
bioloid.interpolateSetup(wTime);
// Do at least the first movement
bioloid.interpolateStep();
// And if asked to, wait for the previous move to complete...
if (fWait) {
while (bioloid.interpolating > 0) {
bioloid.interpolateStep();
delay(3);
}
}
}
//===================================================================================================
// Convert radians to servo position offset.
//===================================================================================================
int radToServo(float rads){
float val = (rads*100)/51 * 100;
return (int) val;
}
//===================================================================================================
// Compute Arm IK for 3DOF+Mirrors+Gripper - was based on code by Michael E. Ferguson
// Hacked up by me, to allow different options...
//===================================================================================================
uint8_t doArmIK(boolean fCartesian, int sIKX, int sIKY, int sIKZ, int sIKGA)
{
int t;
int sol0;
uint8_t bRet = IKS_SUCCESS; // assume success
#ifdef DEBUG
if (g_fDebugOutput) {
Serial.print("(");
Serial.print(sIKX, DEC);
Serial.print(",");
Serial.print(sIKY, DEC);
Serial.print(",");
Serial.print(sIKZ, DEC);
Serial.print(",");
Serial.print(sIKGA, DEC);
Serial.print(")=");
}
#endif
if (fCartesian) {
// first, make this a 2DOF problem... by solving base
sol0 = radToServo(atan2(sIKX,sIKY));
// remove gripper offset from base
t = sqrt(sq((long)sIKX)+sq((long)sIKY));
// BUGBUG... Not sure about G here
#define G 30
sol0 -= radToServo(atan2((G/2)-G_OFFSET,t));
}
else {
// We are in cylindrical mode, probably simply set t to the y we passed in...
t = sIKY;
#ifdef DEBUG
sol0 = 0;
#endif
}
// convert to sIKX/sIKZ plane, remove wrist, prepare to solve other DOF
float flGripRad = (float)(sIKGA)*3.14159/180.0;
long trueX = t - (long)((float)WristLength*cos(flGripRad));
long trueZ = sIKZ - BaseHeight - (long)((float)WristLength*sin(flGripRad));
long im = sqrt(sq(trueX)+sq(trueZ)); // length of imaginary arm
float q1 = atan2(trueZ,trueX); // angle between im and X axis
long d1 = sq(ShoulderLength) - sq(ElbowLength) + sq((long)im);
long d2 = 2*ShoulderLength*im;
float q2 = acos((float)d1/float(d2));
q1 = q1 + q2;
int sol1 = radToServo(q1-1.57);
d1 = sq(ShoulderLength)-sq((long)im)+sq(ElbowLength);
d2 = 2*ElbowLength*ShoulderLength;
q2 = acos((float)d1/(float)d2);
int sol2 = radToServo(3.14-q2);
// solve for wrist rotate
int sol3 = radToServo(3.2 + flGripRad - q1 - q2 );
#ifdef DEBUG
if (g_fDebugOutput) {
Serial.print("<");
Serial.print(sol0, DEC);
Serial.print(",");
Serial.print(trueX, DEC);
Serial.print(",");
Serial.print(trueZ, DEC);
Serial.print(",");
Serial.print(sol1, DEC);
Serial.print(",");
Serial.print(sol2, DEC);
Serial.print(",");
Serial.print(sol3, DEC);
Serial.print(">");
}
#endif
// Lets calculate the actual servo values.
if (fCartesian) {
sBase = min(max(512 - sol0, BASE_MIN), BASE_MAX);
}
sShoulder = min(max(512 - sol1, SHOULDER_MIN), SHOULDER_MAX);
sElbow = min(max(512 + sol2, ELBOW_MIN), ELBOW_MAX);
#define Wrist_Offset 512
sWrist = min(max(Wrist_Offset - sol3, WRIST_MIN), WRIST_MAX);
// Remember our current IK positions
g_sIKX = sIKX;
g_sIKY = sIKY;
g_sIKZ = sIKZ;
g_sIKGA = sIKGA;
// Simple test im can not exceed the length of the Shoulder+Elbow joints...
if (im > (ShoulderLength + ElbowLength)) {
if (g_bIKStatus != IKS_ERROR) {
#ifdef DEBUG
if (g_fDebugOutput) {
Serial.println("IK Error");
}
#endif
MSound(2, 50, 3000, 50, 3000);
}
bRet = IKS_ERROR;
}
else if(im > (ShoulderLength + ElbowLength-IK_FUDGE)) {
if (g_bIKStatus != IKS_WARNING) {
#ifdef DEBUG
if (g_fDebugOutput) {
Serial.println("IK Warning");
}
#endif
MSound(1, 75, 2500);
}
bRet = IKS_WARNING;
}
return bRet;
}
// BUGBUG:: Move to some library...
//==============================================================================
// SoundNoTimer - Quick and dirty tone function to try to output a frequency
// to a speaker for some simple sounds.
//==============================================================================
#ifdef SOUND_PIN
void SoundNoTimer(unsigned long duration, unsigned int frequency)
{
#ifdef __AVR__
volatile uint8_t *pin_port;
volatile uint8_t pin_mask;
#else
volatile uint32_t *pin_port;
volatile uint16_t pin_mask;
#endif
long toggle_count = 0;
long lusDelayPerHalfCycle;
// Set the pinMode as OUTPUT
pinMode(SOUND_PIN, OUTPUT);
pin_port = portOutputRegister(digitalPinToPort(SOUND_PIN));
pin_mask = digitalPinToBitMask(SOUND_PIN);
toggle_count = 2 * frequency * duration / 1000;
lusDelayPerHalfCycle = 1000000L/(frequency * 2);
// if we are using an 8 bit timer, scan through prescalars to find the best fit
while (toggle_count--) {
// toggle the pin
*pin_port ^= pin_mask;
// delay a half cycle
delayMicroseconds(lusDelayPerHalfCycle);
}
*pin_port &= ~(pin_mask); // keep pin low after stop
}
void MSound(byte cNotes, ...)
{
va_list ap;
unsigned int uDur;
unsigned int uFreq;
va_start(ap, cNotes);
while (cNotes > 0) {
uDur = va_arg(ap, unsigned int);
uFreq = va_arg(ap, unsigned int);
SoundNoTimer(uDur, uFreq);
cNotes--;
}
va_end(ap);
}
#else
void MSound(byte cNotes, ...)
{
};
#endif
| [
"andrew@trossenrobotics.com"
] | andrew@trossenrobotics.com |
ad43a8beb8a9bf60937ba63020797ce8c3c8e7cb | 85381529f7a09d11b2e2491671c2d5e965467ac6 | /OJ/SGU/115.cpp | 74243e9e1348250ae5232d29ecd685fda2fc848e | [] | no_license | Mr-Phoebe/ACM-ICPC | 862a06666d9db622a8eded7607be5eec1b1a4055 | baf6b1b7ce3ad1592208377a13f8153a8b942e91 | refs/heads/master | 2023-04-07T03:46:03.631407 | 2023-03-19T03:41:05 | 2023-03-19T03:41:05 | 46,262,661 | 19 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 916 | cpp | #include <bits/stdc++.h>
#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)>(b))?(b):(a)
#define rep(i,initial_n,end_n) for(int (i)=(initial_n);(i)<(end_n);i++)
#define repp(i,initial_n,end_n) for(int (i)=(initial_n);(i)<=(end_n);(i)++)
#define eps 1.0E-8
#define MAX_N 1010
#define INF 1 << 30
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
int day, month, year = 2001, monthday[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
scanf("%d%d", &day, &month);
if(month > 12 || day > monthday[month])
{
puts("Impossible");
exit(0);
}
if (month<3)
{
month += 12;
year--;
}
int ans = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400 + 1) % 7;
printf("%d\n", ans == 0 ? 7 : ans);
return 0;
}
| [
"whn289467822@outlook.com"
] | whn289467822@outlook.com |
8a8cd9bdf3eb3a676c791b826242ad40237f4d3e | 6623b6a1941c7f74758b044ad59fd1528da2d821 | /WinUserHeader_new.cpp | d2e5fc7364fdc2d6ed7c05087c799e105466c4fd | [] | no_license | drunkwater/WindowMessages | 94bf569a5701061444fe2f356163819689cb0fd8 | d4223d9aca788ae6a0e329e406b78b09756bd763 | refs/heads/master | 2021-05-11T22:47:35.858812 | 2018-01-15T06:05:25 | 2018-01-15T06:05:25 | 117,500,670 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 447,508 | cpp | #include "stdafx.h"
/****************************************************************************
* *
* winuser.h -- USER procedure declarations, constant definitions and macros *
* *
* Copyright (c) Microsoft Corporation. All rights reserved. *
* *
****************************************************************************/
#define WM_MACRO_2_STRINGS(i) (#i)
// #ifndef _WINUSER_
// #define _WINUSER_
// #pragma once
// //
// // Define API decoration for direct importing of DLL references.
// //
// #if !defined(WINUSERAPI)
// #if !defined(_USER32_)
// #define WINUSERAPI DECLSPEC_IMPORT
// #else
// #define WINUSERAPI extern "C"
// #endif
// #endif
// #if !defined(WINABLEAPI)
// #if !defined(_USER32_)
// #define WINABLEAPI DECLSPEC_IMPORT
// #else
// #define WINABLEAPI
// #endif
// #endif
// #ifdef _MAC
// #include <macwin32.h>
// #endif
// #ifdef __cplusplus
// extern "C" {
// #endif /* __cplusplus */
// #if _MSC_VER >= 1200
// #pragma warning(push)
// #ifndef _MSC_EXTENSIONS
// #pragma warning(disable:4309) // truncation of constant value
// #endif
// #pragma warning(disable:4820) // padding added after data member
// #endif
// #ifndef WINVER
// #define WINVER 0x0500 /* version 5.0 */
// #endif /* !WINVER */
// #include <stdarg.h>
// #ifndef NOAPISET
// #include <libloaderapi.h> // LoadString%
// #endif
// #ifndef NOUSER
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef HANDLE HDWP;
// typedef VOID MENUTEMPLATEA;
// typedef VOID MENUTEMPLATEW;
// #ifdef UNICODE
// typedef MENUTEMPLATEW MENUTEMPLATE;
// #else
// typedef MENUTEMPLATEA MENUTEMPLATE;
// #endif // UNICODE
// typedef PVOID LPMENUTEMPLATEA;
// typedef PVOID LPMENUTEMPLATEW;
// #ifdef UNICODE
// typedef LPMENUTEMPLATEW LPMENUTEMPLATE;
// #else
// typedef LPMENUTEMPLATEA LPMENUTEMPLATE;
// #endif // UNICODE
// typedef LRESULT(CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifdef STRICT
// #pragma region Application Family or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
// typedef INT_PTR(CALLBACK* DLGPROC)(HWND, UINT, WPARAM, LPARAM);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef VOID(CALLBACK* TIMERPROC)(HWND, UINT, UINT_PTR, DWORD);
// typedef BOOL(CALLBACK* GRAYSTRINGPROC)(HDC, LPARAM, int);
// typedef BOOL(CALLBACK* WNDENUMPROC)(HWND, LPARAM);
// typedef LRESULT(CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
// typedef VOID(CALLBACK* SENDASYNCPROC)(HWND, UINT, ULONG_PTR, LRESULT);
// typedef BOOL(CALLBACK* PROPENUMPROCA)(HWND, LPCSTR, HANDLE);
// typedef BOOL(CALLBACK* PROPENUMPROCW)(HWND, LPCWSTR, HANDLE);
// typedef BOOL(CALLBACK* PROPENUMPROCEXA)(HWND, LPSTR, HANDLE, ULONG_PTR);
// typedef BOOL(CALLBACK* PROPENUMPROCEXW)(HWND, LPWSTR, HANDLE, ULONG_PTR);
// typedef int (CALLBACK* EDITWORDBREAKPROCA)(LPSTR lpch, int ichCurrent, int cch, int code);
// typedef int (CALLBACK* EDITWORDBREAKPROCW)(LPWSTR lpch, int ichCurrent, int cch, int code);
// #if(WINVER >= 0x0400)
// typedef BOOL(CALLBACK* DRAWSTATEPROC)(HDC hdc, LPARAM lData, WPARAM wData, int cx, int cy);
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #else /* !STRICT */
// #pragma region Application Family or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
// typedef FARPROC DLGPROC;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef FARPROC TIMERPROC;
// typedef FARPROC GRAYSTRINGPROC;
// typedef FARPROC WNDENUMPROC;
// typedef FARPROC HOOKPROC;
// typedef FARPROC SENDASYNCPROC;
// typedef FARPROC EDITWORDBREAKPROCA;
// typedef FARPROC EDITWORDBREAKPROCW;
// typedef FARPROC PROPENUMPROCA;
// typedef FARPROC PROPENUMPROCW;
// typedef FARPROC PROPENUMPROCEXA;
// typedef FARPROC PROPENUMPROCEXW;
// #if(WINVER >= 0x0400)
// typedef FARPROC DRAWSTATEPROC;
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !STRICT */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #ifdef UNICODE
// typedef PROPENUMPROCW PROPENUMPROC;
// typedef PROPENUMPROCEXW PROPENUMPROCEX;
// typedef EDITWORDBREAKPROCW EDITWORDBREAKPROC;
// #else /* !UNICODE */
// typedef PROPENUMPROCA PROPENUMPROC;
// typedef PROPENUMPROCEXA PROPENUMPROCEX;
// typedef EDITWORDBREAKPROCA EDITWORDBREAKPROC;
// #endif /* UNICODE */
// #ifdef STRICT
// typedef BOOL(CALLBACK* NAMEENUMPROCA)(LPSTR, LPARAM);
// typedef BOOL(CALLBACK* NAMEENUMPROCW)(LPWSTR, LPARAM);
// typedef NAMEENUMPROCA WINSTAENUMPROCA;
// typedef NAMEENUMPROCA DESKTOPENUMPROCA;
// typedef NAMEENUMPROCW WINSTAENUMPROCW;
// typedef NAMEENUMPROCW DESKTOPENUMPROCW;
// #else /* !STRICT */
// typedef FARPROC NAMEENUMPROCA;
// typedef FARPROC NAMEENUMPROCW;
// typedef FARPROC WINSTAENUMPROCA;
// typedef FARPROC DESKTOPENUMPROCA;
// typedef FARPROC WINSTAENUMPROCW;
// typedef FARPROC DESKTOPENUMPROCW;
// #endif /* !STRICT */
// #ifdef UNICODE
// typedef WINSTAENUMPROCW WINSTAENUMPROC;
// typedef DESKTOPENUMPROCW DESKTOPENUMPROC;
// #else /* !UNICODE */
// typedef WINSTAENUMPROCA WINSTAENUMPROC;
// typedef DESKTOPENUMPROCA DESKTOPENUMPROC;
// #endif /* UNICODE */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define IS_INTRESOURCE(_r) ((((ULONG_PTR)(_r)) >> 16) == 0)
// #define MAKEINTRESOURCEA(i) ((LPSTR)((ULONG_PTR)((WORD)(i))))
// #define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i))))
// #ifdef UNICODE
// #define MAKEINTRESOURCE MAKEINTRESOURCEW
// #else
// #define MAKEINTRESOURCE MAKEINTRESOURCEA
// #endif // !UNICODE
// #ifndef NORESOURCE
// /*
// * Predefined Resource Types
// */
// #define RT_CURSOR MAKEINTRESOURCE(1)
// #define RT_BITMAP MAKEINTRESOURCE(2)
// #define RT_ICON MAKEINTRESOURCE(3)
// #define RT_MENU MAKEINTRESOURCE(4)
// #define RT_DIALOG MAKEINTRESOURCE(5)
// #define RT_STRING MAKEINTRESOURCE(6)
// #define RT_FONTDIR MAKEINTRESOURCE(7)
// #define RT_FONT MAKEINTRESOURCE(8)
// #define RT_ACCELERATOR MAKEINTRESOURCE(9)
// #define RT_RCDATA MAKEINTRESOURCE(10)
// #define RT_MESSAGETABLE MAKEINTRESOURCE(11)
// #define DIFFERENCE 11
// #define RT_GROUP_CURSOR MAKEINTRESOURCE((ULONG_PTR)(RT_CURSOR) + DIFFERENCE)
// #define RT_GROUP_ICON MAKEINTRESOURCE((ULONG_PTR)(RT_ICON) + DIFFERENCE)
// #define RT_VERSION MAKEINTRESOURCE(16)
// #define RT_DLGINCLUDE MAKEINTRESOURCE(17)
// #if(WINVER >= 0x0400)
// #define RT_PLUGPLAY MAKEINTRESOURCE(19)
// #define RT_VXD MAKEINTRESOURCE(20)
// #define RT_ANICURSOR MAKEINTRESOURCE(21)
// #define RT_ANIICON MAKEINTRESOURCE(22)
// #endif /* WINVER >= 0x0400 */
// #define RT_HTML MAKEINTRESOURCE(23)
// #ifdef RC_INVOKED
// #define RT_MANIFEST 24
// #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
// #define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2
// #define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3
// #define MINIMUM_RESERVED_MANIFEST_RESOURCE_ID 1 /* inclusive */
// #define MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID 16 /* inclusive */
// #else /* RC_INVOKED */
// #define RT_MANIFEST MAKEINTRESOURCE(24)
// #define CREATEPROCESS_MANIFEST_RESOURCE_ID MAKEINTRESOURCE( 1)
// #define ISOLATIONAWARE_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(2)
// #define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(3)
// #define MINIMUM_RESERVED_MANIFEST_RESOURCE_ID MAKEINTRESOURCE( 1 /*inclusive*/)
// #define MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(16 /*inclusive*/)
// #endif /* RC_INVOKED */
// #endif /* !NORESOURCE */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if defined(DEPRECATE_SUPPORTED)
// #pragma warning(push)
// #pragma warning(disable:4995)
// #endif
// WINUSERAPI
// int
// WINAPI
// wvsprintfA(
// _Out_ LPSTR,
// _In_ _Printf_format_string_ LPCSTR,
// _In_ va_list arglist);
// WINUSERAPI
// int
// WINAPI
// wvsprintfW(
// _Out_ LPWSTR,
// _In_ _Printf_format_string_ LPCWSTR,
// _In_ va_list arglist);
// #ifdef UNICODE
// #define wvsprintf wvsprintfW
// #else
// #define wvsprintf wvsprintfA
// #endif // !UNICODE
// WINUSERAPI
// int
// WINAPIV
// wsprintfA(
// _Out_ LPSTR,
// _In_ _Printf_format_string_ LPCSTR,
// ...);
// WINUSERAPI
// int
// WINAPIV
// wsprintfW(
// _Out_ LPWSTR,
// _In_ _Printf_format_string_ LPCWSTR,
// ...);
// #ifdef UNICODE
// #define wsprintf wsprintfW
// #else
// #define wsprintf wsprintfA
// #endif // !UNICODE
// #if defined(DEPRECATE_SUPPORTED)
// #pragma warning(pop)
// #endif
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * SPI_SETDESKWALLPAPER defined constants
// */
// #define SETWALLPAPER_DEFAULT ((LPWSTR)-1)
// #ifndef NOSCROLL
// /*
// * Scroll Bar Constants
// */
// #define SB_HORZ 0
// #define SB_VERT 1
// #define SB_CTL 2
// #define SB_BOTH 3
// /*
// * Scroll Bar Commands
// */
// #define SB_LINEUP 0
// #define SB_LINELEFT 0
// #define SB_LINEDOWN 1
// #define SB_LINERIGHT 1
// #define SB_PAGEUP 2
// #define SB_PAGELEFT 2
// #define SB_PAGEDOWN 3
// #define SB_PAGERIGHT 3
// #define SB_THUMBPOSITION 4
// #define SB_THUMBTRACK 5
// #define SB_TOP 6
// #define SB_LEFT 6
// #define SB_BOTTOM 7
// #define SB_RIGHT 7
// #define SB_ENDSCROLL 8
// #endif /* !NOSCROLL */
// #ifndef NOSHOWWINDOW
// /*
// * ShowWindow() Commands
// */
// #define SW_HIDE 0
// #define SW_SHOWNORMAL 1
// #define SW_NORMAL 1
// #define SW_SHOWMINIMIZED 2
// #define SW_SHOWMAXIMIZED 3
// #define SW_MAXIMIZE 3
// #define SW_SHOWNOACTIVATE 4
// #define SW_SHOW 5
// #define SW_MINIMIZE 6
// #define SW_SHOWMINNOACTIVE 7
// #define SW_SHOWNA 8
// #define SW_RESTORE 9
// #define SW_SHOWDEFAULT 10
// #define SW_FORCEMINIMIZE 11
// #define SW_MAX 11
// /*
// * Old ShowWindow() Commands
// */
// #define HIDE_WINDOW 0
// #define SHOW_OPENWINDOW 1
// #define SHOW_ICONWINDOW 2
// #define SHOW_FULLSCREEN 3
// #define SHOW_OPENNOACTIVATE 4
// /*
// * Identifiers for the WM_SHOWWINDOW message
// */
// #define SW_PARENTCLOSING 1
// #define SW_OTHERZOOM 2
// #define SW_PARENTOPENING 3
// #define SW_OTHERUNZOOM 4
// #endif /* !NOSHOWWINDOW */
// #if(WINVER >= 0x0500)
// /*
// * AnimateWindow() Commands
// */
// #define AW_HOR_POSITIVE 0x00000001
// #define AW_HOR_NEGATIVE 0x00000002
// #define AW_VER_POSITIVE 0x00000004
// #define AW_VER_NEGATIVE 0x00000008
// #define AW_CENTER 0x00000010
// #define AW_HIDE 0x00010000
// #define AW_ACTIVATE 0x00020000
// #define AW_SLIDE 0x00040000
// #define AW_BLEND 0x00080000
// #endif /* WINVER >= 0x0500 */
// /*
// * WM_KEYUP/DOWN/CHAR HIWORD(lParam) flags
// */
// #define KF_EXTENDED 0x0100
// #define KF_DLGMODE 0x0800
// #define KF_MENUMODE 0x1000
// #define KF_ALTDOWN 0x2000
// #define KF_REPEAT 0x4000
// #define KF_UP 0x8000
// #ifndef NOVIRTUALKEYCODES
// /*
// * Virtual Keys, Standard Set
// */
// #define VK_LBUTTON 0x01
// #define VK_RBUTTON 0x02
// #define VK_CANCEL 0x03
// #define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */
// #if(_WIN32_WINNT >= 0x0500)
// #define VK_XBUTTON1 0x05 /* NOT contiguous with L & RBUTTON */
// #define VK_XBUTTON2 0x06 /* NOT contiguous with L & RBUTTON */
// #endif /* _WIN32_WINNT >= 0x0500 */
// /*
// * 0x07 : reserved
// */
// #define VK_BACK 0x08
// #define VK_TAB 0x09
// /*
// * 0x0A - 0x0B : reserved
// */
// #define VK_CLEAR 0x0C
// #define VK_RETURN 0x0D
// /*
// * 0x0E - 0x0F : unassigned
// */
// #define VK_SHIFT 0x10
// #define VK_CONTROL 0x11
// #define VK_MENU 0x12
// #define VK_PAUSE 0x13
// #define VK_CAPITAL 0x14
// #define VK_KANA 0x15
// #define VK_HANGEUL 0x15 /* old name - should be here for compatibility */
// #define VK_HANGUL 0x15
// /*
// * 0x16 : unassigned
// */
// #define VK_JUNJA 0x17
// #define VK_FINAL 0x18
// #define VK_HANJA 0x19
// #define VK_KANJI 0x19
// /*
// * 0x1A : unassigned
// */
// #define VK_ESCAPE 0x1B
// #define VK_CONVERT 0x1C
// #define VK_NONCONVERT 0x1D
// #define VK_ACCEPT 0x1E
// #define VK_MODECHANGE 0x1F
// #define VK_SPACE 0x20
// #define VK_PRIOR 0x21
// #define VK_NEXT 0x22
// #define VK_END 0x23
// #define VK_HOME 0x24
// #define VK_LEFT 0x25
// #define VK_UP 0x26
// #define VK_RIGHT 0x27
// #define VK_DOWN 0x28
// #define VK_SELECT 0x29
// #define VK_PRINT 0x2A
// #define VK_EXECUTE 0x2B
// #define VK_SNAPSHOT 0x2C
// #define VK_INSERT 0x2D
// #define VK_DELETE 0x2E
// #define VK_HELP 0x2F
// /*
// * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
// * 0x3A - 0x40 : unassigned
// * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
// */
// #define VK_LWIN 0x5B
// #define VK_RWIN 0x5C
// #define VK_APPS 0x5D
// /*
// * 0x5E : reserved
// */
// #define VK_SLEEP 0x5F
// #define VK_NUMPAD0 0x60
// #define VK_NUMPAD1 0x61
// #define VK_NUMPAD2 0x62
// #define VK_NUMPAD3 0x63
// #define VK_NUMPAD4 0x64
// #define VK_NUMPAD5 0x65
// #define VK_NUMPAD6 0x66
// #define VK_NUMPAD7 0x67
// #define VK_NUMPAD8 0x68
// #define VK_NUMPAD9 0x69
// #define VK_MULTIPLY 0x6A
// #define VK_ADD 0x6B
// #define VK_SEPARATOR 0x6C
// #define VK_SUBTRACT 0x6D
// #define VK_DECIMAL 0x6E
// #define VK_DIVIDE 0x6F
// #define VK_F1 0x70
// #define VK_F2 0x71
// #define VK_F3 0x72
// #define VK_F4 0x73
// #define VK_F5 0x74
// #define VK_F6 0x75
// #define VK_F7 0x76
// #define VK_F8 0x77
// #define VK_F9 0x78
// #define VK_F10 0x79
// #define VK_F11 0x7A
// #define VK_F12 0x7B
// #define VK_F13 0x7C
// #define VK_F14 0x7D
// #define VK_F15 0x7E
// #define VK_F16 0x7F
// #define VK_F17 0x80
// #define VK_F18 0x81
// #define VK_F19 0x82
// #define VK_F20 0x83
// #define VK_F21 0x84
// #define VK_F22 0x85
// #define VK_F23 0x86
// #define VK_F24 0x87
// #if(_WIN32_WINNT >= 0x0604)
// /*
// * 0x88 - 0x8F : UI navigation
// */
// #define VK_NAVIGATION_VIEW 0x88 // reserved
// #define VK_NAVIGATION_MENU 0x89 // reserved
// #define VK_NAVIGATION_UP 0x8A // reserved
// #define VK_NAVIGATION_DOWN 0x8B // reserved
// #define VK_NAVIGATION_LEFT 0x8C // reserved
// #define VK_NAVIGATION_RIGHT 0x8D // reserved
// #define VK_NAVIGATION_ACCEPT 0x8E // reserved
// #define VK_NAVIGATION_CANCEL 0x8F // reserved
// #endif /* _WIN32_WINNT >= 0x0604 */
// #define VK_NUMLOCK 0x90
// #define VK_SCROLL 0x91
// /*
// * NEC PC-9800 kbd definitions
// */
// #define VK_OEM_NEC_EQUAL 0x92 // '=' key on numpad
// /*
// * Fujitsu/OASYS kbd definitions
// */
// #define VK_OEM_FJ_JISHO 0x92 // 'Dictionary' key
// #define VK_OEM_FJ_MASSHOU 0x93 // 'Unregister word' key
// #define VK_OEM_FJ_TOUROKU 0x94 // 'Register word' key
// #define VK_OEM_FJ_LOYA 0x95 // 'Left OYAYUBI' key
// #define VK_OEM_FJ_ROYA 0x96 // 'Right OYAYUBI' key
// /*
// * 0x97 - 0x9F : unassigned
// */
// /*
// * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
// * Used only as parameters to GetAsyncKeyState() and GetKeyState().
// * No other API or message will distinguish left and right keys in this way.
// */
// #define VK_LSHIFT 0xA0
// #define VK_RSHIFT 0xA1
// #define VK_LCONTROL 0xA2
// #define VK_RCONTROL 0xA3
// #define VK_LMENU 0xA4
// #define VK_RMENU 0xA5
// #if(_WIN32_WINNT >= 0x0500)
// #define VK_BROWSER_BACK 0xA6
// #define VK_BROWSER_FORWARD 0xA7
// #define VK_BROWSER_REFRESH 0xA8
// #define VK_BROWSER_STOP 0xA9
// #define VK_BROWSER_SEARCH 0xAA
// #define VK_BROWSER_FAVORITES 0xAB
// #define VK_BROWSER_HOME 0xAC
// #define VK_VOLUME_MUTE 0xAD
// #define VK_VOLUME_DOWN 0xAE
// #define VK_VOLUME_UP 0xAF
// #define VK_MEDIA_NEXT_TRACK 0xB0
// #define VK_MEDIA_PREV_TRACK 0xB1
// #define VK_MEDIA_STOP 0xB2
// #define VK_MEDIA_PLAY_PAUSE 0xB3
// #define VK_LAUNCH_MAIL 0xB4
// #define VK_LAUNCH_MEDIA_SELECT 0xB5
// #define VK_LAUNCH_APP1 0xB6
// #define VK_LAUNCH_APP2 0xB7
// #endif /* _WIN32_WINNT >= 0x0500 */
// /*
// * 0xB8 - 0xB9 : reserved
// */
// #define VK_OEM_1 0xBA // ';:' for US
// #define VK_OEM_PLUS 0xBB // '+' any country
// #define VK_OEM_COMMA 0xBC // ',' any country
// #define VK_OEM_MINUS 0xBD // '-' any country
// #define VK_OEM_PERIOD 0xBE // '.' any country
// #define VK_OEM_2 0xBF // '/?' for US
// #define VK_OEM_3 0xC0 // '`~' for US
// /*
// * 0xC1 - 0xC2 : reserved
// */
// #if(_WIN32_WINNT >= 0x0604)
// /*
// * 0xC3 - 0xDA : Gamepad input
// */
// #define VK_GAMEPAD_A 0xC3 // reserved
// #define VK_GAMEPAD_B 0xC4 // reserved
// #define VK_GAMEPAD_X 0xC5 // reserved
// #define VK_GAMEPAD_Y 0xC6 // reserved
// #define VK_GAMEPAD_RIGHT_SHOULDER 0xC7 // reserved
// #define VK_GAMEPAD_LEFT_SHOULDER 0xC8 // reserved
// #define VK_GAMEPAD_LEFT_TRIGGER 0xC9 // reserved
// #define VK_GAMEPAD_RIGHT_TRIGGER 0xCA // reserved
// #define VK_GAMEPAD_DPAD_UP 0xCB // reserved
// #define VK_GAMEPAD_DPAD_DOWN 0xCC // reserved
// #define VK_GAMEPAD_DPAD_LEFT 0xCD // reserved
// #define VK_GAMEPAD_DPAD_RIGHT 0xCE // reserved
// #define VK_GAMEPAD_MENU 0xCF // reserved
// #define VK_GAMEPAD_VIEW 0xD0 // reserved
// #define VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON 0xD1 // reserved
// #define VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON 0xD2 // reserved
// #define VK_GAMEPAD_LEFT_THUMBSTICK_UP 0xD3 // reserved
// #define VK_GAMEPAD_LEFT_THUMBSTICK_DOWN 0xD4 // reserved
// #define VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT 0xD5 // reserved
// #define VK_GAMEPAD_LEFT_THUMBSTICK_LEFT 0xD6 // reserved
// #define VK_GAMEPAD_RIGHT_THUMBSTICK_UP 0xD7 // reserved
// #define VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN 0xD8 // reserved
// #define VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT 0xD9 // reserved
// #define VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT 0xDA // reserved
// #endif /* _WIN32_WINNT >= 0x0604 */
// #define VK_OEM_4 0xDB // '[{' for US
// #define VK_OEM_5 0xDC // '\|' for US
// #define VK_OEM_6 0xDD // ']}' for US
// #define VK_OEM_7 0xDE // ''"' for US
// #define VK_OEM_8 0xDF
// /*
// * 0xE0 : reserved
// */
// /*
// * Various extended or enhanced keyboards
// */
// #define VK_OEM_AX 0xE1 // 'AX' key on Japanese AX kbd
// #define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd.
// #define VK_ICO_HELP 0xE3 // Help key on ICO
// #define VK_ICO_00 0xE4 // 00 key on ICO
// #if(WINVER >= 0x0400)
// #define VK_PROCESSKEY 0xE5
// #endif /* WINVER >= 0x0400 */
// #define VK_ICO_CLEAR 0xE6
// #if(_WIN32_WINNT >= 0x0500)
// #define VK_PACKET 0xE7
// #endif /* _WIN32_WINNT >= 0x0500 */
// /*
// * 0xE8 : unassigned
// */
// /*
// * Nokia/Ericsson definitions
// */
// #define VK_OEM_RESET 0xE9
// #define VK_OEM_JUMP 0xEA
// #define VK_OEM_PA1 0xEB
// #define VK_OEM_PA2 0xEC
// #define VK_OEM_PA3 0xED
// #define VK_OEM_WSCTRL 0xEE
// #define VK_OEM_CUSEL 0xEF
// #define VK_OEM_ATTN 0xF0
// #define VK_OEM_FINISH 0xF1
// #define VK_OEM_COPY 0xF2
// #define VK_OEM_AUTO 0xF3
// #define VK_OEM_ENLW 0xF4
// #define VK_OEM_BACKTAB 0xF5
// #define VK_ATTN 0xF6
// #define VK_CRSEL 0xF7
// #define VK_EXSEL 0xF8
// #define VK_EREOF 0xF9
// #define VK_PLAY 0xFA
// #define VK_ZOOM 0xFB
// #define VK_NONAME 0xFC
// #define VK_PA1 0xFD
// #define VK_OEM_CLEAR 0xFE
// /*
// * 0xFF : reserved
// */
// #endif /* !NOVIRTUALKEYCODES */
// #ifndef NOWH
// /*
// * SetWindowsHook() codes
// */
// #define WH_MIN (-1)
// #define WH_MSGFILTER (-1)
// #define WH_JOURNALRECORD 0
// #define WH_JOURNALPLAYBACK 1
// #define WH_KEYBOARD 2
// #define WH_GETMESSAGE 3
// #define WH_CALLWNDPROC 4
// #define WH_CBT 5
// #define WH_SYSMSGFILTER 6
// #define WH_MOUSE 7
// #if defined(_WIN32_WINDOWS)
// #define WH_HARDWARE 8
// #endif
// #define WH_DEBUG 9
// #define WH_SHELL 10
// #define WH_FOREGROUNDIDLE 11
// #if(WINVER >= 0x0400)
// #define WH_CALLWNDPROCRET 12
// #endif /* WINVER >= 0x0400 */
// #if (_WIN32_WINNT >= 0x0400)
// #define WH_KEYBOARD_LL 13
// #define WH_MOUSE_LL 14
// #endif // (_WIN32_WINNT >= 0x0400)
// #if(WINVER >= 0x0400)
// #if (_WIN32_WINNT >= 0x0400)
// #define WH_MAX 14
// #else
// #define WH_MAX 12
// #endif // (_WIN32_WINNT >= 0x0400)
// #else
// #define WH_MAX 11
// #endif
// #define WH_MINHOOK WH_MIN
// #define WH_MAXHOOK WH_MAX
// /*
// * Hook Codes
// */
// #define HC_ACTION 0
// #define HC_GETNEXT 1
// #define HC_SKIP 2
// #define HC_NOREMOVE 3
// #define HC_NOREM HC_NOREMOVE
// #define HC_SYSMODALON 4
// #define HC_SYSMODALOFF 5
// /*
// * CBT Hook Codes
// */
// #define HCBT_MOVESIZE 0
// #define HCBT_MINMAX 1
// #define HCBT_QS 2
// #define HCBT_CREATEWND 3
// #define HCBT_DESTROYWND 4
// #define HCBT_ACTIVATE 5
// #define HCBT_CLICKSKIPPED 6
// #define HCBT_KEYSKIPPED 7
// #define HCBT_SYSCOMMAND 8
// #define HCBT_SETFOCUS 9
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * HCBT_CREATEWND parameters pointed to by lParam
// */
// typedef struct tagCBT_CREATEWNDA
// {
// struct tagCREATESTRUCTA *lpcs;
// HWND hwndInsertAfter;
// } CBT_CREATEWNDA, *LPCBT_CREATEWNDA;
// /*
// * HCBT_CREATEWND parameters pointed to by lParam
// */
// typedef struct tagCBT_CREATEWNDW
// {
// struct tagCREATESTRUCTW *lpcs;
// HWND hwndInsertAfter;
// } CBT_CREATEWNDW, *LPCBT_CREATEWNDW;
// #ifdef UNICODE
// typedef CBT_CREATEWNDW CBT_CREATEWND;
// typedef LPCBT_CREATEWNDW LPCBT_CREATEWND;
// #else
// typedef CBT_CREATEWNDA CBT_CREATEWND;
// typedef LPCBT_CREATEWNDA LPCBT_CREATEWND;
// #endif // UNICODE
// /*
// * HCBT_ACTIVATE structure pointed to by lParam
// */
// typedef struct tagCBTACTIVATESTRUCT
// {
// BOOL fMouse;
// HWND hWndActive;
// } CBTACTIVATESTRUCT, *LPCBTACTIVATESTRUCT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(_WIN32_WINNT >= 0x0501)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * WTSSESSION_NOTIFICATION struct pointed by lParam, for WM_WTSSESSION_CHANGE
// */
// typedef struct tagWTSSESSION_NOTIFICATION
// {
// DWORD cbSize;
// DWORD dwSessionId;
// } WTSSESSION_NOTIFICATION, *PWTSSESSION_NOTIFICATION;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * codes passed in WPARAM for WM_WTSSESSION_CHANGE
// */
// #define WTS_CONSOLE_CONNECT 0x1
// #define WTS_CONSOLE_DISCONNECT 0x2
// #define WTS_REMOTE_CONNECT 0x3
// #define WTS_REMOTE_DISCONNECT 0x4
// #define WTS_SESSION_LOGON 0x5
// #define WTS_SESSION_LOGOFF 0x6
// #define WTS_SESSION_LOCK 0x7
// #define WTS_SESSION_UNLOCK 0x8
// #define WTS_SESSION_REMOTE_CONTROL 0x9
// #define WTS_SESSION_CREATE 0xa
// #define WTS_SESSION_TERMINATE 0xb
// #endif /* _WIN32_WINNT >= 0x0501 */
// /*
// * WH_MSGFILTER Filter Proc Codes
// */
// #define MSGF_DIALOGBOX 0
// #define MSGF_MESSAGEBOX 1
// #define MSGF_MENU 2
// #define MSGF_SCROLLBAR 5
// #define MSGF_NEXTWINDOW 6
// #define MSGF_MAX 8 // unused
// #define MSGF_USER 4096
// /*
// * Shell support
// */
// #define HSHELL_WINDOWCREATED 1
// #define HSHELL_WINDOWDESTROYED 2
// #define HSHELL_ACTIVATESHELLWINDOW 3
// #if(WINVER >= 0x0400)
// #define HSHELL_WINDOWACTIVATED 4
// #define HSHELL_GETMINRECT 5
// #define HSHELL_REDRAW 6
// #define HSHELL_TASKMAN 7
// #define HSHELL_LANGUAGE 8
// #define HSHELL_SYSMENU 9
// #define HSHELL_ENDTASK 10
// #endif /* WINVER >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0500)
// #define HSHELL_ACCESSIBILITYSTATE 11
// #define HSHELL_APPCOMMAND 12
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0501)
// #define HSHELL_WINDOWREPLACED 13
// #define HSHELL_WINDOWREPLACING 14
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0602)
// #define HSHELL_MONITORCHANGED 16
// #if (NTDDI_VERSION >= NTDDI_WIN10_RS3)
// #endif // NTDDI_VERSION >= NTDDI_WIN10_RS3
// #endif /* _WIN32_WINNT >= 0x0602 */
// #define HSHELL_HIGHBIT 0x8000
// #define HSHELL_FLASH (HSHELL_REDRAW|HSHELL_HIGHBIT)
// #define HSHELL_RUDEAPPACTIVATED (HSHELL_WINDOWACTIVATED|HSHELL_HIGHBIT)
// #if(_WIN32_WINNT >= 0x0500)
// /* cmd for HSHELL_APPCOMMAND and WM_APPCOMMAND */
// #define APPCOMMAND_BROWSER_BACKWARD 1
// #define APPCOMMAND_BROWSER_FORWARD 2
// #define APPCOMMAND_BROWSER_REFRESH 3
// #define APPCOMMAND_BROWSER_STOP 4
// #define APPCOMMAND_BROWSER_SEARCH 5
// #define APPCOMMAND_BROWSER_FAVORITES 6
// #define APPCOMMAND_BROWSER_HOME 7
// #define APPCOMMAND_VOLUME_MUTE 8
// #define APPCOMMAND_VOLUME_DOWN 9
// #define APPCOMMAND_VOLUME_UP 10
// #define APPCOMMAND_MEDIA_NEXTTRACK 11
// #define APPCOMMAND_MEDIA_PREVIOUSTRACK 12
// #define APPCOMMAND_MEDIA_STOP 13
// #define APPCOMMAND_MEDIA_PLAY_PAUSE 14
// #define APPCOMMAND_LAUNCH_MAIL 15
// #define APPCOMMAND_LAUNCH_MEDIA_SELECT 16
// #define APPCOMMAND_LAUNCH_APP1 17
// #define APPCOMMAND_LAUNCH_APP2 18
// #define APPCOMMAND_BASS_DOWN 19
// #define APPCOMMAND_BASS_BOOST 20
// #define APPCOMMAND_BASS_UP 21
// #define APPCOMMAND_TREBLE_DOWN 22
// #define APPCOMMAND_TREBLE_UP 23
// #if(_WIN32_WINNT >= 0x0501)
// #define APPCOMMAND_MICROPHONE_VOLUME_MUTE 24
// #define APPCOMMAND_MICROPHONE_VOLUME_DOWN 25
// #define APPCOMMAND_MICROPHONE_VOLUME_UP 26
// #define APPCOMMAND_HELP 27
// #define APPCOMMAND_FIND 28
// #define APPCOMMAND_NEW 29
// #define APPCOMMAND_OPEN 30
// #define APPCOMMAND_CLOSE 31
// #define APPCOMMAND_SAVE 32
// #define APPCOMMAND_PRINT 33
// #define APPCOMMAND_UNDO 34
// #define APPCOMMAND_REDO 35
// #define APPCOMMAND_COPY 36
// #define APPCOMMAND_CUT 37
// #define APPCOMMAND_PASTE 38
// #define APPCOMMAND_REPLY_TO_MAIL 39
// #define APPCOMMAND_FORWARD_MAIL 40
// #define APPCOMMAND_SEND_MAIL 41
// #define APPCOMMAND_SPELL_CHECK 42
// #define APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE 43
// #define APPCOMMAND_MIC_ON_OFF_TOGGLE 44
// #define APPCOMMAND_CORRECTION_LIST 45
// #define APPCOMMAND_MEDIA_PLAY 46
// #define APPCOMMAND_MEDIA_PAUSE 47
// #define APPCOMMAND_MEDIA_RECORD 48
// #define APPCOMMAND_MEDIA_FAST_FORWARD 49
// #define APPCOMMAND_MEDIA_REWIND 50
// #define APPCOMMAND_MEDIA_CHANNEL_UP 51
// #define APPCOMMAND_MEDIA_CHANNEL_DOWN 52
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0600)
// #define APPCOMMAND_DELETE 53
// #define APPCOMMAND_DWM_FLIP3D 54
// #endif /* _WIN32_WINNT >= 0x0600 */
// #define FAPPCOMMAND_MOUSE 0x8000
// #define FAPPCOMMAND_KEY 0
// #define FAPPCOMMAND_OEM 0x1000
// #define FAPPCOMMAND_MASK 0xF000
// #define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
// #define GET_DEVICE_LPARAM(lParam) ((WORD)(HIWORD(lParam) & FAPPCOMMAND_MASK))
// #define GET_MOUSEORKEY_LPARAM GET_DEVICE_LPARAM
// #define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
// #define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)
// #endif /* _WIN32_WINNT >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct
// {
// HWND hwnd;
// RECT rc;
// } SHELLHOOKINFO, *LPSHELLHOOKINFO;
// /*
// * Message Structure used in Journaling
// */
// typedef struct tagEVENTMSG {
// UINT message;
// UINT paramL;
// UINT paramH;
// DWORD time;
// HWND hwnd;
// } EVENTMSG, *PEVENTMSGMSG, NEAR *NPEVENTMSGMSG, FAR *LPEVENTMSGMSG;
// typedef struct tagEVENTMSG *PEVENTMSG, NEAR *NPEVENTMSG, FAR *LPEVENTMSG;
// /*
// * Message structure used by WH_CALLWNDPROC
// */
// typedef struct tagCWPSTRUCT {
// LPARAM lParam;
// WPARAM wParam;
// UINT message;
// HWND hwnd;
// } CWPSTRUCT, *PCWPSTRUCT, NEAR *NPCWPSTRUCT, FAR *LPCWPSTRUCT;
// #if(WINVER >= 0x0400)
// /*
// * Message structure used by WH_CALLWNDPROCRET
// */
// typedef struct tagCWPRETSTRUCT {
// LRESULT lResult;
// LPARAM lParam;
// WPARAM wParam;
// UINT message;
// HWND hwnd;
// } CWPRETSTRUCT, *PCWPRETSTRUCT, NEAR *NPCWPRETSTRUCT, FAR *LPCWPRETSTRUCT;
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if (_WIN32_WINNT >= 0x0400)
// /*
// * Low level hook flags
// */
// #define LLKHF_EXTENDED (KF_EXTENDED >> 8) /* 0x00000001 */
// #define LLKHF_INJECTED 0x00000010
// #define LLKHF_ALTDOWN (KF_ALTDOWN >> 8) /* 0x00000020 */
// #define LLKHF_UP (KF_UP >> 8) /* 0x00000080 */
// #define LLKHF_LOWER_IL_INJECTED 0x00000002
// #define LLMHF_INJECTED 0x00000001
// #define LLMHF_LOWER_IL_INJECTED 0x00000002
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Structure used by WH_KEYBOARD_LL
// */
// typedef struct tagKBDLLHOOKSTRUCT {
// DWORD vkCode;
// DWORD scanCode;
// DWORD flags;
// DWORD time;
// ULONG_PTR dwExtraInfo;
// } KBDLLHOOKSTRUCT, FAR *LPKBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;
// /*
// * Structure used by WH_MOUSE_LL
// */
// typedef struct tagMSLLHOOKSTRUCT {
// POINT pt;
// DWORD mouseData;
// DWORD flags;
// DWORD time;
// ULONG_PTR dwExtraInfo;
// } MSLLHOOKSTRUCT, FAR *LPMSLLHOOKSTRUCT, *PMSLLHOOKSTRUCT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif // (_WIN32_WINNT >= 0x0400)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Structure used by WH_DEBUG
// */
// typedef struct tagDEBUGHOOKINFO
// {
// DWORD idThread;
// DWORD idThreadInstaller;
// LPARAM lParam;
// WPARAM wParam;
// int code;
// } DEBUGHOOKINFO, *PDEBUGHOOKINFO, NEAR *NPDEBUGHOOKINFO, FAR* LPDEBUGHOOKINFO;
// /*
// * Structure used by WH_MOUSE
// */
// typedef struct tagMOUSEHOOKSTRUCT {
// POINT pt;
// HWND hwnd;
// UINT wHitTestCode;
// ULONG_PTR dwExtraInfo;
// } MOUSEHOOKSTRUCT, FAR *LPMOUSEHOOKSTRUCT, *PMOUSEHOOKSTRUCT;
// #if(_WIN32_WINNT >= 0x0500)
// #ifdef __cplusplus
// typedef struct tagMOUSEHOOKSTRUCTEX : public tagMOUSEHOOKSTRUCT
// {
// DWORD mouseData;
// } MOUSEHOOKSTRUCTEX, *LPMOUSEHOOKSTRUCTEX, *PMOUSEHOOKSTRUCTEX;
// #else // ndef __cplusplus
// typedef struct tagMOUSEHOOKSTRUCTEX
// {
// MOUSEHOOKSTRUCT DUMMYSTRUCTNAME;
// DWORD mouseData;
// } MOUSEHOOKSTRUCTEX, *LPMOUSEHOOKSTRUCTEX, *PMOUSEHOOKSTRUCTEX;
// #endif
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(WINVER >= 0x0400)
// /*
// * Structure used by WH_HARDWARE
// */
// typedef struct tagHARDWAREHOOKSTRUCT {
// HWND hwnd;
// UINT message;
// WPARAM wParam;
// LPARAM lParam;
// } HARDWAREHOOKSTRUCT, FAR *LPHARDWAREHOOKSTRUCT, *PHARDWAREHOOKSTRUCT;
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOWH */
// /*
// * Keyboard Layout API
// */
// #define HKL_PREV 0
// #define HKL_NEXT 1
// #define KLF_ACTIVATE 0x00000001
// #define KLF_SUBSTITUTE_OK 0x00000002
// #define KLF_REORDER 0x00000008
// #if(WINVER >= 0x0400)
// #define KLF_REPLACELANG 0x00000010
// #define KLF_NOTELLSHELL 0x00000080
// #endif /* WINVER >= 0x0400 */
// #define KLF_SETFORPROCESS 0x00000100
// #if(_WIN32_WINNT >= 0x0500)
// #define KLF_SHIFTLOCK 0x00010000
// #define KLF_RESET 0x40000000
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(WINVER >= 0x0500)
// /*
// * Bits in wParam of WM_INPUTLANGCHANGEREQUEST message
// */
// #define INPUTLANGCHANGE_SYSCHARSET 0x0001
// #define INPUTLANGCHANGE_FORWARD 0x0002
// #define INPUTLANGCHANGE_BACKWARD 0x0004
// #endif /* WINVER >= 0x0500 */
// /*
// * Size of KeyboardLayoutName (number of characters), including nul terminator
// */
// #define KL_NAMELENGTH 9
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HKL
// WINAPI
// LoadKeyboardLayoutA(
// _In_ LPCSTR pwszKLID,
// _In_ UINT Flags);
// WINUSERAPI
// HKL
// WINAPI
// LoadKeyboardLayoutW(
// _In_ LPCWSTR pwszKLID,
// _In_ UINT Flags);
// #ifdef UNICODE
// #define LoadKeyboardLayout LoadKeyboardLayoutW
// #else
// #define LoadKeyboardLayout LoadKeyboardLayoutA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// WINUSERAPI
// HKL
// WINAPI
// ActivateKeyboardLayout(
// _In_ HKL hkl,
// _In_ UINT Flags);
// #else
// WINUSERAPI
// BOOL
// WINAPI
// ActivateKeyboardLayout(
// _In_ HKL hkl,
// _In_ UINT Flags);
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0400)
// WINUSERAPI
// int
// WINAPI
// ToUnicodeEx(
// _In_ UINT wVirtKey,
// _In_ UINT wScanCode,
// _In_reads_bytes_(256) CONST BYTE *lpKeyState,
// _Out_writes_(cchBuff) LPWSTR pwszBuff,
// _In_ int cchBuff,
// _In_ UINT wFlags,
// _In_opt_ HKL dwhkl);
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// BOOL
// WINAPI
// UnloadKeyboardLayout(
// _In_ HKL hkl);
// WINUSERAPI
// BOOL
// WINAPI
// GetKeyboardLayoutNameA(
// _Out_writes_(KL_NAMELENGTH) LPSTR pwszKLID);
// WINUSERAPI
// BOOL
// WINAPI
// GetKeyboardLayoutNameW(
// _Out_writes_(KL_NAMELENGTH) LPWSTR pwszKLID);
// #ifdef UNICODE
// #define GetKeyboardLayoutName GetKeyboardLayoutNameW
// #else
// #define GetKeyboardLayoutName GetKeyboardLayoutNameA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// WINUSERAPI
// int
// WINAPI
// GetKeyboardLayoutList(
// _In_ int nBuff,
// _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList);
// WINUSERAPI
// HKL
// WINAPI
// GetKeyboardLayout(
// _In_ DWORD idThread);
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0500)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagMOUSEMOVEPOINT {
// int x;
// int y;
// DWORD time;
// ULONG_PTR dwExtraInfo;
// } MOUSEMOVEPOINT, *PMOUSEMOVEPOINT, FAR* LPMOUSEMOVEPOINT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Values for resolution parameter of GetMouseMovePointsEx
// */
// #define GMMP_USE_DISPLAY_POINTS 1
// #define GMMP_USE_HIGH_RESOLUTION_POINTS 2
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// int
// WINAPI
// GetMouseMovePointsEx(
// _In_ UINT cbSize,
// _In_ LPMOUSEMOVEPOINT lppt,
// _Out_writes_(nBufPoints) LPMOUSEMOVEPOINT lpptBuf,
// _In_ int nBufPoints,
// _In_ DWORD resolution);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0500 */
// #ifndef NODESKTOP
// /*
// * Desktop-specific access flags
// */
// #define DESKTOP_READOBJECTS 0x0001L
// #define DESKTOP_CREATEWINDOW 0x0002L
// #define DESKTOP_CREATEMENU 0x0004L
// #define DESKTOP_HOOKCONTROL 0x0008L
// #define DESKTOP_JOURNALRECORD 0x0010L
// #define DESKTOP_JOURNALPLAYBACK 0x0020L
// #define DESKTOP_ENUMERATE 0x0040L
// #define DESKTOP_WRITEOBJECTS 0x0080L
// #define DESKTOP_SWITCHDESKTOP 0x0100L
// /*
// * Desktop-specific control flags
// */
// #define DF_ALLOWOTHERACCOUNTHOOK 0x0001L
// #ifdef _WINGDI_
// #ifndef NOGDI
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HDESK
// WINAPI
// CreateDesktopA(
// _In_ LPCSTR lpszDesktop,
// _Reserved_ LPCSTR lpszDevice,
// _Reserved_ DEVMODEA* pDevmode,
// _In_ DWORD dwFlags,
// _In_ ACCESS_MASK dwDesiredAccess,
// _In_opt_ LPSECURITY_ATTRIBUTES lpsa);
// WINUSERAPI
// HDESK
// WINAPI
// CreateDesktopW(
// _In_ LPCWSTR lpszDesktop,
// _Reserved_ LPCWSTR lpszDevice,
// _Reserved_ DEVMODEW* pDevmode,
// _In_ DWORD dwFlags,
// _In_ ACCESS_MASK dwDesiredAccess,
// _In_opt_ LPSECURITY_ATTRIBUTES lpsa);
// #ifdef UNICODE
// #define CreateDesktop CreateDesktopW
// #else
// #define CreateDesktop CreateDesktopA
// #endif // !UNICODE
// WINUSERAPI
// HDESK
// WINAPI
// CreateDesktopExA(
// _In_ LPCSTR lpszDesktop,
// _Reserved_ LPCSTR lpszDevice,
// _Reserved_ DEVMODEA* pDevmode,
// _In_ DWORD dwFlags,
// _In_ ACCESS_MASK dwDesiredAccess,
// _In_opt_ LPSECURITY_ATTRIBUTES lpsa,
// _In_ ULONG ulHeapSize,
// _Reserved_ PVOID pvoid);
// WINUSERAPI
// HDESK
// WINAPI
// CreateDesktopExW(
// _In_ LPCWSTR lpszDesktop,
// _Reserved_ LPCWSTR lpszDevice,
// _Reserved_ DEVMODEW* pDevmode,
// _In_ DWORD dwFlags,
// _In_ ACCESS_MASK dwDesiredAccess,
// _In_opt_ LPSECURITY_ATTRIBUTES lpsa,
// _In_ ULONG ulHeapSize,
// _Reserved_ PVOID pvoid);
// #ifdef UNICODE
// #define CreateDesktopEx CreateDesktopExW
// #else
// #define CreateDesktopEx CreateDesktopExA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* NOGDI */
// #endif /* _WINGDI_ */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HDESK
// WINAPI
// OpenDesktopA(
// _In_ LPCSTR lpszDesktop,
// _In_ DWORD dwFlags,
// _In_ BOOL fInherit,
// _In_ ACCESS_MASK dwDesiredAccess);
// WINUSERAPI
// HDESK
// WINAPI
// OpenDesktopW(
// _In_ LPCWSTR lpszDesktop,
// _In_ DWORD dwFlags,
// _In_ BOOL fInherit,
// _In_ ACCESS_MASK dwDesiredAccess);
// #ifdef UNICODE
// #define OpenDesktop OpenDesktopW
// #else
// #define OpenDesktop OpenDesktopA
// #endif // !UNICODE
// WINUSERAPI
// HDESK
// WINAPI
// OpenInputDesktop(
// _In_ DWORD dwFlags,
// _In_ BOOL fInherit,
// _In_ ACCESS_MASK dwDesiredAccess);
// WINUSERAPI
// BOOL
// WINAPI
// EnumDesktopsA(
// _In_opt_ HWINSTA hwinsta,
// _In_ DESKTOPENUMPROCA lpEnumFunc,
// _In_ LPARAM lParam);
// WINUSERAPI
// BOOL
// WINAPI
// EnumDesktopsW(
// _In_opt_ HWINSTA hwinsta,
// _In_ DESKTOPENUMPROCW lpEnumFunc,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define EnumDesktops EnumDesktopsW
// #else
// #define EnumDesktops EnumDesktopsA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// EnumDesktopWindows(
// _In_opt_ HDESK hDesktop,
// _In_ WNDENUMPROC lpfn,
// _In_ LPARAM lParam);
// WINUSERAPI
// BOOL
// WINAPI
// SwitchDesktop(
// _In_ HDESK hDesktop);
// WINUSERAPI
// BOOL
// WINAPI
// SetThreadDesktop(
// _In_ HDESK hDesktop);
// WINUSERAPI
// BOOL
// WINAPI
// CloseDesktop(
// _In_ HDESK hDesktop);
// WINUSERAPI
// HDESK
// WINAPI
// GetThreadDesktop(
// _In_ DWORD dwThreadId);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NODESKTOP */
// #ifndef NOWINDOWSTATION
// /*
// * Windowstation-specific access flags
// */
// #define WINSTA_ENUMDESKTOPS 0x0001L
// #define WINSTA_READATTRIBUTES 0x0002L
// #define WINSTA_ACCESSCLIPBOARD 0x0004L
// #define WINSTA_CREATEDESKTOP 0x0008L
// #define WINSTA_WRITEATTRIBUTES 0x0010L
// #define WINSTA_ACCESSGLOBALATOMS 0x0020L
// #define WINSTA_EXITWINDOWS 0x0040L
// #define WINSTA_ENUMERATE 0x0100L
// #define WINSTA_READSCREEN 0x0200L
// #define WINSTA_ALL_ACCESS (WINSTA_ENUMDESKTOPS | WINSTA_READATTRIBUTES | WINSTA_ACCESSCLIPBOARD | \
// WINSTA_CREATEDESKTOP | WINSTA_WRITEATTRIBUTES | WINSTA_ACCESSGLOBALATOMS | \
// WINSTA_EXITWINDOWS | WINSTA_ENUMERATE | WINSTA_READSCREEN)
// /*
// * Windowstation creation flags.
// */
// #define CWF_CREATE_ONLY 0x00000001
// /*
// * Windowstation-specific attribute flags
// */
// #define WSF_VISIBLE 0x0001L
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HWINSTA
// WINAPI
// CreateWindowStationA(
// _In_opt_ LPCSTR lpwinsta,
// _In_ DWORD dwFlags,
// _In_ ACCESS_MASK dwDesiredAccess,
// _In_opt_ LPSECURITY_ATTRIBUTES lpsa);
// WINUSERAPI
// HWINSTA
// WINAPI
// CreateWindowStationW(
// _In_opt_ LPCWSTR lpwinsta,
// _In_ DWORD dwFlags,
// _In_ ACCESS_MASK dwDesiredAccess,
// _In_opt_ LPSECURITY_ATTRIBUTES lpsa);
// #ifdef UNICODE
// #define CreateWindowStation CreateWindowStationW
// #else
// #define CreateWindowStation CreateWindowStationA
// #endif // !UNICODE
// WINUSERAPI
// HWINSTA
// WINAPI
// OpenWindowStationA(
// _In_ LPCSTR lpszWinSta,
// _In_ BOOL fInherit,
// _In_ ACCESS_MASK dwDesiredAccess);
// WINUSERAPI
// HWINSTA
// WINAPI
// OpenWindowStationW(
// _In_ LPCWSTR lpszWinSta,
// _In_ BOOL fInherit,
// _In_ ACCESS_MASK dwDesiredAccess);
// #ifdef UNICODE
// #define OpenWindowStation OpenWindowStationW
// #else
// #define OpenWindowStation OpenWindowStationA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// EnumWindowStationsA(
// _In_ WINSTAENUMPROCA lpEnumFunc,
// _In_ LPARAM lParam);
// WINUSERAPI
// BOOL
// WINAPI
// EnumWindowStationsW(
// _In_ WINSTAENUMPROCW lpEnumFunc,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define EnumWindowStations EnumWindowStationsW
// #else
// #define EnumWindowStations EnumWindowStationsA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// CloseWindowStation(
// _In_ HWINSTA hWinSta);
// WINUSERAPI
// BOOL
// WINAPI
// SetProcessWindowStation(
// _In_ HWINSTA hWinSta);
// WINUSERAPI
// HWINSTA
// WINAPI
// GetProcessWindowStation(
// VOID);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOWINDOWSTATION */
// #ifndef NOSECURITY
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// SetUserObjectSecurity(
// _In_ HANDLE hObj,
// _In_ PSECURITY_INFORMATION pSIRequested,
// _In_ PSECURITY_DESCRIPTOR pSID);
// WINUSERAPI
// BOOL
// WINAPI
// GetUserObjectSecurity(
// _In_ HANDLE hObj,
// _In_ PSECURITY_INFORMATION pSIRequested,
// _Out_writes_bytes_opt_(nLength) PSECURITY_DESCRIPTOR pSID,
// _In_ DWORD nLength,
// _Out_ LPDWORD lpnLengthNeeded);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define UOI_FLAGS 1
// #define UOI_NAME 2
// #define UOI_TYPE 3
// #define UOI_USER_SID 4
// #if(WINVER >= 0x0600)
// #define UOI_HEAPSIZE 5
// #define UOI_IO 6
// #endif /* WINVER >= 0x0600 */
// #define UOI_TIMERPROC_EXCEPTION_SUPPRESSION 7
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagUSEROBJECTFLAGS {
// BOOL fInherit;
// BOOL fReserved;
// DWORD dwFlags;
// } USEROBJECTFLAGS, *PUSEROBJECTFLAGS;
// WINUSERAPI
// BOOL
// WINAPI
// GetUserObjectInformationA(
// _In_ HANDLE hObj,
// _In_ int nIndex,
// _Out_writes_bytes_opt_(nLength) PVOID pvInfo,
// _In_ DWORD nLength,
// _Out_opt_ LPDWORD lpnLengthNeeded);
// WINUSERAPI
// BOOL
// WINAPI
// GetUserObjectInformationW(
// _In_ HANDLE hObj,
// _In_ int nIndex,
// _Out_writes_bytes_opt_(nLength) PVOID pvInfo,
// _In_ DWORD nLength,
// _Out_opt_ LPDWORD lpnLengthNeeded);
// #ifdef UNICODE
// #define GetUserObjectInformation GetUserObjectInformationW
// #else
// #define GetUserObjectInformation GetUserObjectInformationA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// SetUserObjectInformationA(
// _In_ HANDLE hObj,
// _In_ int nIndex,
// _In_reads_bytes_(nLength) PVOID pvInfo,
// _In_ DWORD nLength);
// WINUSERAPI
// BOOL
// WINAPI
// SetUserObjectInformationW(
// _In_ HANDLE hObj,
// _In_ int nIndex,
// _In_reads_bytes_(nLength) PVOID pvInfo,
// _In_ DWORD nLength);
// #ifdef UNICODE
// #define SetUserObjectInformation SetUserObjectInformationW
// #else
// #define SetUserObjectInformation SetUserObjectInformationA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOSECURITY */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if(WINVER >= 0x0400)
// typedef struct tagWNDCLASSEXA {
// UINT cbSize;
// /* Win 3.x */
// UINT style;
// WNDPROC lpfnWndProc;
// int cbClsExtra;
// int cbWndExtra;
// HINSTANCE hInstance;
// HICON hIcon;
// HCURSOR hCursor;
// HBRUSH hbrBackground;
// LPCSTR lpszMenuName;
// LPCSTR lpszClassName;
// /* Win 4.0 */
// HICON hIconSm;
// } WNDCLASSEXA, *PWNDCLASSEXA, NEAR *NPWNDCLASSEXA, FAR *LPWNDCLASSEXA;
// typedef struct tagWNDCLASSEXW {
// UINT cbSize;
// /* Win 3.x */
// UINT style;
// WNDPROC lpfnWndProc;
// int cbClsExtra;
// int cbWndExtra;
// HINSTANCE hInstance;
// HICON hIcon;
// HCURSOR hCursor;
// HBRUSH hbrBackground;
// LPCWSTR lpszMenuName;
// LPCWSTR lpszClassName;
// /* Win 4.0 */
// HICON hIconSm;
// } WNDCLASSEXW, *PWNDCLASSEXW, NEAR *NPWNDCLASSEXW, FAR *LPWNDCLASSEXW;
// #ifdef UNICODE
// typedef WNDCLASSEXW WNDCLASSEX;
// typedef PWNDCLASSEXW PWNDCLASSEX;
// typedef NPWNDCLASSEXW NPWNDCLASSEX;
// typedef LPWNDCLASSEXW LPWNDCLASSEX;
// #else
// typedef WNDCLASSEXA WNDCLASSEX;
// typedef PWNDCLASSEXA PWNDCLASSEX;
// typedef NPWNDCLASSEXA NPWNDCLASSEX;
// typedef LPWNDCLASSEXA LPWNDCLASSEX;
// #endif // UNICODE
// #endif /* WINVER >= 0x0400 */
// typedef struct tagWNDCLASSA {
// UINT style;
// WNDPROC lpfnWndProc;
// int cbClsExtra;
// int cbWndExtra;
// HINSTANCE hInstance;
// HICON hIcon;
// HCURSOR hCursor;
// HBRUSH hbrBackground;
// LPCSTR lpszMenuName;
// LPCSTR lpszClassName;
// } WNDCLASSA, *PWNDCLASSA, NEAR *NPWNDCLASSA, FAR *LPWNDCLASSA;
// typedef struct tagWNDCLASSW {
// UINT style;
// WNDPROC lpfnWndProc;
// int cbClsExtra;
// int cbWndExtra;
// HINSTANCE hInstance;
// HICON hIcon;
// HCURSOR hCursor;
// HBRUSH hbrBackground;
// LPCWSTR lpszMenuName;
// LPCWSTR lpszClassName;
// } WNDCLASSW, *PWNDCLASSW, NEAR *NPWNDCLASSW, FAR *LPWNDCLASSW;
// #ifdef UNICODE
// typedef WNDCLASSW WNDCLASS;
// typedef PWNDCLASSW PWNDCLASS;
// typedef NPWNDCLASSW NPWNDCLASS;
// typedef LPWNDCLASSW LPWNDCLASS;
// #else
// typedef WNDCLASSA WNDCLASS;
// typedef PWNDCLASSA PWNDCLASS;
// typedef NPWNDCLASSA NPWNDCLASS;
// typedef LPWNDCLASSA LPWNDCLASS;
// #endif // UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// IsHungAppWindow(
// _In_ HWND hwnd);
// #if(WINVER >= 0x0501)
// WINUSERAPI
// VOID
// WINAPI
// DisableProcessWindowsGhosting(
// VOID);
// #endif /* WINVER >= 0x0501 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NOMSG
// #pragma region Application Family or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
// /*
// * Message structure
// */
// typedef struct tagMSG {
// HWND hwnd;
// UINT message;
// WPARAM wParam;
// LPARAM lParam;
// DWORD time;
// POINT pt;
// #ifdef _MAC
// DWORD lPrivate;
// #endif
// } MSG, *PMSG, NEAR *NPMSG, FAR *LPMSG;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// #define POINTSTOPOINT(pt, pts) \
// { (pt).x = (LONG)(SHORT)LOWORD(*(LONG*)&pts); \
// (pt).y = (LONG)(SHORT)HIWORD(*(LONG*)&pts); }
// #define POINTTOPOINTS(pt) (MAKELONG((short)((pt).x), (short)((pt).y)))
// #define MAKEWPARAM(l, h) ((WPARAM)(DWORD)MAKELONG(l, h))
// #define MAKELPARAM(l, h) ((LPARAM)(DWORD)MAKELONG(l, h))
// #define MAKELRESULT(l, h) ((LRESULT)(DWORD)MAKELONG(l, h))
// #endif /* !NOMSG */
// #ifndef NOWINOFFSETS
// /*
// * Window field offsets for GetWindowLong()
// */
// #define GWL_WNDPROC (-4)
// #define GWL_HINSTANCE (-6)
// #define GWL_HWNDPARENT (-8)
// #define GWL_STYLE (-16)
// #define GWL_EXSTYLE (-20)
// #define GWL_USERDATA (-21)
// #define GWL_ID (-12)
// #ifdef _WIN64
// #undef GWL_WNDPROC
// #undef GWL_HINSTANCE
// #undef GWL_HWNDPARENT
// #undef GWL_USERDATA
// #endif /* _WIN64 */
// #define GWLP_WNDPROC (-4)
// #define GWLP_HINSTANCE (-6)
// #define GWLP_HWNDPARENT (-8)
// #define GWLP_USERDATA (-21)
// #define GWLP_ID (-12)
// /*
// * Class field offsets for GetClassLong()
// */
// #define GCL_MENUNAME (-8)
// #define GCL_HBRBACKGROUND (-10)
// #define GCL_HCURSOR (-12)
// #define GCL_HICON (-14)
// #define GCL_HMODULE (-16)
// #define GCL_CBWNDEXTRA (-18)
// #define GCL_CBCLSEXTRA (-20)
// #define GCL_WNDPROC (-24)
// #define GCL_STYLE (-26)
// #define GCW_ATOM (-32)
// #if(WINVER >= 0x0400)
// #define GCL_HICONSM (-34)
// #endif /* WINVER >= 0x0400 */
// #ifdef _WIN64
// #undef GCL_MENUNAME
// #undef GCL_HBRBACKGROUND
// #undef GCL_HCURSOR
// #undef GCL_HICON
// #undef GCL_HMODULE
// #undef GCL_WNDPROC
// #undef GCL_HICONSM
// #endif /* _WIN64 */
// #define GCLP_MENUNAME (-8)
// #define GCLP_HBRBACKGROUND (-10)
// #define GCLP_HCURSOR (-12)
// #define GCLP_HICON (-14)
// #define GCLP_HMODULE (-16)
// #define GCLP_WNDPROC (-24)
// #define GCLP_HICONSM (-34)
// #endif /* !NOWINOFFSETS */
// #ifndef NOWINMESSAGES
// /*
// * Window Messages
// */
const char *GetWindowMessagesById(UINT msg){
const char *p;
switch(msg){
case WM_NULL :
p = (const char *)WM_MACRO_2_STRINGS(WM_NULL);
break;
case WM_CREATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_CREATE);
break;
case WM_DESTROY :
p = (const char *)WM_MACRO_2_STRINGS(WM_DESTROY);
break;
case WM_MOVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOVE);
break;
case WM_SIZE :
p = (const char *)WM_MACRO_2_STRINGS(WM_SIZE);
break;
case WM_ACTIVATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_ACTIVATE);
break;
// /*
// * WM_ACTIVATE state values
// */
// #define WA_INACTIVE 0
// #define WA_ACTIVE 1
// #define WA_CLICKACTIVE 2
case WM_SETFOCUS :
p = (const char *)WM_MACRO_2_STRINGS(WM_SETFOCUS);
break;
case WM_KILLFOCUS :
p = (const char *)WM_MACRO_2_STRINGS(WM_KILLFOCUS);
break;
case WM_ENABLE :
p = (const char *)WM_MACRO_2_STRINGS(WM_ENABLE);
break;
case WM_SETREDRAW :
p = (const char *)WM_MACRO_2_STRINGS(WM_SETREDRAW);
break;
case WM_SETTEXT :
p = (const char *)WM_MACRO_2_STRINGS(WM_SETTEXT);
break;
case WM_GETTEXT :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETTEXT);
break;
case WM_GETTEXTLENGTH :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETTEXTLENGTH);
break;
case WM_PAINT :
p = (const char *)WM_MACRO_2_STRINGS(WM_PAINT);
break;
case WM_CLOSE :
p = (const char *)WM_MACRO_2_STRINGS(WM_CLOSE);
break;
#ifndef _WIN32_WCE
case WM_QUERYENDSESSION :
p = (const char *)WM_MACRO_2_STRINGS(WM_QUERYENDSESSION);
break;
case WM_QUERYOPEN :
p = (const char *)WM_MACRO_2_STRINGS(WM_QUERYOPEN);
break;
case WM_ENDSESSION :
p = (const char *)WM_MACRO_2_STRINGS(WM_ENDSESSION);
break;
#endif
case WM_QUIT :
p = (const char *)WM_MACRO_2_STRINGS(WM_QUIT);
break;
case WM_ERASEBKGND :
p = (const char *)WM_MACRO_2_STRINGS(WM_ERASEBKGND);
break;
case WM_SYSCOLORCHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_SYSCOLORCHANGE);
break;
case WM_SHOWWINDOW :
p = (const char *)WM_MACRO_2_STRINGS(WM_SHOWWINDOW);
break;
case WM_WININICHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_WININICHANGE);
break;
#if(WINVER >= 0x0400)
// #define WM_SETTINGCHANGE WM_WININICHANGE
#endif /* WINVER >= 0x0400 */
case WM_DEVMODECHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_DEVMODECHANGE);
break;
case WM_ACTIVATEAPP :
p = (const char *)WM_MACRO_2_STRINGS(WM_ACTIVATEAPP);
break;
case WM_FONTCHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_FONTCHANGE);
break;
case WM_TIMECHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_TIMECHANGE);
break;
case WM_CANCELMODE :
p = (const char *)WM_MACRO_2_STRINGS(WM_CANCELMODE);
break;
case WM_SETCURSOR :
p = (const char *)WM_MACRO_2_STRINGS(WM_SETCURSOR);
break;
case WM_MOUSEACTIVATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSEACTIVATE);
break;
case WM_CHILDACTIVATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_CHILDACTIVATE);
break;
case WM_QUEUESYNC :
p = (const char *)WM_MACRO_2_STRINGS(WM_QUEUESYNC);
break;
case WM_GETMINMAXINFO :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETMINMAXINFO);
break;
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Struct pointed to by WM_GETMINMAXINFO lParam
// */
// typedef struct tagMINMAXINFO {
// POINT ptReserved;
// POINT ptMaxSize;
// POINT ptMaxPosition;
// POINT ptMinTrackSize;
// POINT ptMaxTrackSize;
// } MINMAXINFO, *PMINMAXINFO, *LPMINMAXINFO;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
case WM_PAINTICON :
p = (const char *)WM_MACRO_2_STRINGS(WM_PAINTICON);
break;
case WM_ICONERASEBKGND :
p = (const char *)WM_MACRO_2_STRINGS(WM_ICONERASEBKGND);
break;
case WM_NEXTDLGCTL :
p = (const char *)WM_MACRO_2_STRINGS(WM_NEXTDLGCTL);
break;
case WM_SPOOLERSTATUS :
p = (const char *)WM_MACRO_2_STRINGS(WM_SPOOLERSTATUS);
break;
case WM_DRAWITEM :
p = (const char *)WM_MACRO_2_STRINGS(WM_DRAWITEM);
break;
case WM_MEASUREITEM :
p = (const char *)WM_MACRO_2_STRINGS(WM_MEASUREITEM);
break;
case WM_DELETEITEM :
p = (const char *)WM_MACRO_2_STRINGS(WM_DELETEITEM);
break;
case WM_VKEYTOITEM :
p = (const char *)WM_MACRO_2_STRINGS(WM_VKEYTOITEM);
break;
case WM_CHARTOITEM :
p = (const char *)WM_MACRO_2_STRINGS(WM_CHARTOITEM);
break;
case WM_SETFONT :
p = (const char *)WM_MACRO_2_STRINGS(WM_SETFONT);
break;
case WM_GETFONT :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETFONT);
break;
case WM_SETHOTKEY :
p = (const char *)WM_MACRO_2_STRINGS(WM_SETHOTKEY);
break;
case WM_GETHOTKEY :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETHOTKEY);
break;
case WM_QUERYDRAGICON :
p = (const char *)WM_MACRO_2_STRINGS(WM_QUERYDRAGICON);
break;
case WM_COMPAREITEM :
p = (const char *)WM_MACRO_2_STRINGS(WM_COMPAREITEM);
break;
#if(WINVER >= 0x0500)
#ifndef _WIN32_WCE
case WM_GETOBJECT :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETOBJECT);
break;
#endif
#endif /* WINVER >= 0x0500 */
case WM_COMPACTING :
p = (const char *)WM_MACRO_2_STRINGS(WM_COMPACTING);
break;
case WM_COMMNOTIFY :
p = (const char *)WM_MACRO_2_STRINGS(WM_COMMNOTIFY);
break;
case WM_WINDOWPOSCHANGING :
p = (const char *)WM_MACRO_2_STRINGS(WM_WINDOWPOSCHANGING);
break;
case WM_WINDOWPOSCHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_WINDOWPOSCHANGED);
break;
case WM_POWER :
p = (const char *)WM_MACRO_2_STRINGS(WM_POWER);
break;
// /*
// * wParam for WM_POWER window message and DRV_POWER driver notification
// */
// #define PWR_OK 1
// #define PWR_FAIL (-1)
// #define PWR_SUSPENDREQUEST 1
// #define PWR_SUSPENDRESUME 2
// #define PWR_CRITICALRESUME 3
case WM_COPYDATA :
p = (const char *)WM_MACRO_2_STRINGS(WM_COPYDATA);
break;
case WM_CANCELJOURNAL :
p = (const char *)WM_MACRO_2_STRINGS(WM_CANCELJOURNAL);
break;
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * lParam of WM_COPYDATA message points to...
// */
// typedef struct tagCOPYDATASTRUCT {
// ULONG_PTR dwData;
// DWORD cbData;
// _Field_size_bytes_(cbData) PVOID lpData;
// } COPYDATASTRUCT, *PCOPYDATASTRUCT;
// #if(WINVER >= 0x0400)
// typedef struct tagMDINEXTMENU
// {
// HMENU hmenuIn;
// HMENU hmenuNext;
// HWND hwndNext;
// } MDINEXTMENU, *PMDINEXTMENU, FAR * LPMDINEXTMENU;
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
#if(WINVER >= 0x0400)
case WM_NOTIFY :
p = (const char *)WM_MACRO_2_STRINGS(WM_NOTIFY);
break;
case WM_INPUTLANGCHANGEREQUEST :
p = (const char *)WM_MACRO_2_STRINGS(WM_INPUTLANGCHANGEREQUEST);
break;
case WM_INPUTLANGCHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_INPUTLANGCHANGE);
break;
case WM_TCARD :
p = (const char *)WM_MACRO_2_STRINGS(WM_TCARD);
break;
case WM_HELP :
p = (const char *)WM_MACRO_2_STRINGS(WM_HELP);
break;
case WM_USERCHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_USERCHANGED);
break;
case WM_NOTIFYFORMAT :
p = (const char *)WM_MACRO_2_STRINGS(WM_NOTIFYFORMAT);
break;
// #define NFR_ANSI 1
// #define NFR_UNICODE 2
// #define NF_QUERY 3
// #define NF_REQUERY 4
case WM_CONTEXTMENU :
p = (const char *)WM_MACRO_2_STRINGS(WM_CONTEXTMENU);
break;
case WM_STYLECHANGING :
p = (const char *)WM_MACRO_2_STRINGS(WM_STYLECHANGING);
break;
case WM_STYLECHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_STYLECHANGED);
break;
case WM_DISPLAYCHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_DISPLAYCHANGE);
break;
case WM_GETICON :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETICON);
break;
case WM_SETICON :
p = (const char *)WM_MACRO_2_STRINGS(WM_SETICON);
break;
#endif /* WINVER >= 0x0400 */
case WM_NCCREATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCCREATE);
break;
case WM_NCDESTROY :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCDESTROY);
break;
case WM_NCCALCSIZE :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCCALCSIZE);
break;
case WM_NCHITTEST :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCHITTEST);
break;
case WM_NCPAINT :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCPAINT);
break;
case WM_NCACTIVATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCACTIVATE);
break;
case WM_GETDLGCODE :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETDLGCODE);
break;
#ifndef _WIN32_WCE
case WM_SYNCPAINT :
p = (const char *)WM_MACRO_2_STRINGS(WM_SYNCPAINT);
break;
#endif
case WM_NCMOUSEMOVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCMOUSEMOVE);
break;
case WM_NCLBUTTONDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCLBUTTONDOWN);
break;
case WM_NCLBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCLBUTTONUP);
break;
case WM_NCLBUTTONDBLCLK :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCLBUTTONDBLCLK);
break;
case WM_NCRBUTTONDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCRBUTTONDOWN);
break;
case WM_NCRBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCRBUTTONUP);
break;
case WM_NCRBUTTONDBLCLK :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCRBUTTONDBLCLK);
break;
case WM_NCMBUTTONDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCMBUTTONDOWN);
break;
case WM_NCMBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCMBUTTONUP);
break;
case WM_NCMBUTTONDBLCLK :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCMBUTTONDBLCLK);
break;
#if(_WIN32_WINNT >= 0x0500)
case WM_NCXBUTTONDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCXBUTTONDOWN);
break;
case WM_NCXBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCXBUTTONUP);
break;
case WM_NCXBUTTONDBLCLK :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCXBUTTONDBLCLK);
break;
#endif /* _WIN32_WINNT >= 0x0500 */
#if(_WIN32_WINNT >= 0x0501)
case WM_INPUT_DEVICE_CHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_INPUT_DEVICE_CHANGE);
break;
#endif /* _WIN32_WINNT >= 0x0501 */
#if(_WIN32_WINNT >= 0x0501)
case WM_INPUT :
p = (const char *)WM_MACRO_2_STRINGS(WM_INPUT);
break;
#endif /* _WIN32_WINNT >= 0x0501 */
/*case WM_KEYFIRST :
p = (const char *)WM_MACRO_2_STRINGS(WM_KEYFIRST);
break;*/
case WM_KEYDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_KEYDOWN);
break;
case WM_KEYUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_KEYUP);
break;
case WM_CHAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_CHAR);
break;
case WM_DEADCHAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_DEADCHAR);
break;
case WM_SYSKEYDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_SYSKEYDOWN);
break;
case WM_SYSKEYUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_SYSKEYUP);
break;
case WM_SYSCHAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_SYSCHAR);
break;
case WM_SYSDEADCHAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_SYSDEADCHAR);
break;
#if(_WIN32_WINNT >= 0x0501)
case WM_UNICHAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_UNICHAR);
break;
/*case WM_KEYLAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_KEYLAST);
break;*/
// #define UNICODE_NOCHAR 0xFFFF
#else
case WM_KEYLAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_KEYLAST);
break;
#endif /* _WIN32_WINNT >= 0x0501 */
#if(WINVER >= 0x0400)
case WM_IME_STARTCOMPOSITION :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_STARTCOMPOSITION);
break;
case WM_IME_ENDCOMPOSITION :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_ENDCOMPOSITION);
break;
case WM_IME_COMPOSITION :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_COMPOSITION);
break;
/*case WM_IME_KEYLAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_KEYLAST);
break;*/
#endif /* WINVER >= 0x0400 */
case WM_INITDIALOG :
p = (const char *)WM_MACRO_2_STRINGS(WM_INITDIALOG);
break;
case WM_COMMAND :
p = (const char *)WM_MACRO_2_STRINGS(WM_COMMAND);
break;
case WM_SYSCOMMAND :
p = (const char *)WM_MACRO_2_STRINGS(WM_SYSCOMMAND);
break;
case WM_TIMER :
p = (const char *)WM_MACRO_2_STRINGS(WM_TIMER);
break;
case WM_HSCROLL :
p = (const char *)WM_MACRO_2_STRINGS(WM_HSCROLL);
break;
case WM_VSCROLL :
p = (const char *)WM_MACRO_2_STRINGS(WM_VSCROLL);
break;
case WM_INITMENU :
p = (const char *)WM_MACRO_2_STRINGS(WM_INITMENU);
break;
case WM_INITMENUPOPUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_INITMENUPOPUP);
break;
#if(WINVER >= 0x0601)
case WM_GESTURE :
p = (const char *)WM_MACRO_2_STRINGS(WM_GESTURE);
break;
case WM_GESTURENOTIFY :
p = (const char *)WM_MACRO_2_STRINGS(WM_GESTURENOTIFY);
break;
#endif /* WINVER >= 0x0601 */
case WM_MENUSELECT :
p = (const char *)WM_MACRO_2_STRINGS(WM_MENUSELECT);
break;
case WM_MENUCHAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_MENUCHAR);
break;
case WM_ENTERIDLE :
p = (const char *)WM_MACRO_2_STRINGS(WM_ENTERIDLE);
break;
#if(WINVER >= 0x0500)
#ifndef _WIN32_WCE
case WM_MENURBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_MENURBUTTONUP);
break;
case WM_MENUDRAG :
p = (const char *)WM_MACRO_2_STRINGS(WM_MENUDRAG);
break;
case WM_MENUGETOBJECT :
p = (const char *)WM_MACRO_2_STRINGS(WM_MENUGETOBJECT);
break;
case WM_UNINITMENUPOPUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_UNINITMENUPOPUP);
break;
case WM_MENUCOMMAND :
p = (const char *)WM_MACRO_2_STRINGS(WM_MENUCOMMAND);
break;
#ifndef _WIN32_WCE
#if(_WIN32_WINNT >= 0x0500)
case WM_CHANGEUISTATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_CHANGEUISTATE);
break;
case WM_UPDATEUISTATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_UPDATEUISTATE);
break;
case WM_QUERYUISTATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_QUERYUISTATE);
break;
// /*
// * LOWORD(wParam) values in WM_*UISTATE*
// */
// #define UIS_SET 1
// #define UIS_CLEAR 2
// #define UIS_INITIALIZE 3
// /*
// * HIWORD(wParam) values in WM_*UISTATE*
// */
// #define UISF_HIDEFOCUS 0x1
// #define UISF_HIDEACCEL 0x2
// #if(_WIN32_WINNT >= 0x0501)
// #define UISF_ACTIVE 0x4
// #endif /* _WIN32_WINNT >= 0x0501 */
#endif /* _WIN32_WINNT >= 0x0500 */
#endif
#endif
#endif /* WINVER >= 0x0500 */
case WM_CTLCOLORMSGBOX :
p = (const char *)WM_MACRO_2_STRINGS(WM_CTLCOLORMSGBOX);
break;
case WM_CTLCOLOREDIT :
p = (const char *)WM_MACRO_2_STRINGS(WM_CTLCOLOREDIT);
break;
case WM_CTLCOLORLISTBOX :
p = (const char *)WM_MACRO_2_STRINGS(WM_CTLCOLORLISTBOX);
break;
case WM_CTLCOLORBTN :
p = (const char *)WM_MACRO_2_STRINGS(WM_CTLCOLORBTN);
break;
case WM_CTLCOLORDLG :
p = (const char *)WM_MACRO_2_STRINGS(WM_CTLCOLORDLG);
break;
case WM_CTLCOLORSCROLLBAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_CTLCOLORSCROLLBAR);
break;
case WM_CTLCOLORSTATIC :
p = (const char *)WM_MACRO_2_STRINGS(WM_CTLCOLORSTATIC);
break;
// #define MN_GETHMENU 0x01E1
/*case WM_MOUSEFIRST :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSEFIRST);
break;*/
case WM_MOUSEMOVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSEMOVE);
break;
case WM_LBUTTONDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_LBUTTONDOWN);
break;
case WM_LBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_LBUTTONUP);
break;
case WM_LBUTTONDBLCLK :
p = (const char *)WM_MACRO_2_STRINGS(WM_LBUTTONDBLCLK);
break;
case WM_RBUTTONDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_RBUTTONDOWN);
break;
case WM_RBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_RBUTTONUP);
break;
case WM_RBUTTONDBLCLK :
p = (const char *)WM_MACRO_2_STRINGS(WM_RBUTTONDBLCLK);
break;
case WM_MBUTTONDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_MBUTTONDOWN);
break;
case WM_MBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_MBUTTONUP);
break;
case WM_MBUTTONDBLCLK :
p = (const char *)WM_MACRO_2_STRINGS(WM_MBUTTONDBLCLK);
break;
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
case WM_MOUSEWHEEL :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSEWHEEL);
break;
#endif
#if (_WIN32_WINNT >= 0x0500)
case WM_XBUTTONDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_XBUTTONDOWN);
break;
case WM_XBUTTONUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_XBUTTONUP);
break;
case WM_XBUTTONDBLCLK :
p = (const char *)WM_MACRO_2_STRINGS(WM_XBUTTONDBLCLK);
break;
#endif
#if (_WIN32_WINNT >= 0x0600)
case WM_MOUSEHWHEEL :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSEHWHEEL);
break;
#endif
#if (_WIN32_WINNT >= 0x0600)
/*case WM_MOUSELAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSELAST);
break;*/
#elif (_WIN32_WINNT >= 0x0500)
case WM_MOUSELAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSELAST);
break;
#elif (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
case WM_MOUSELAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSELAST);
break;
#else
case WM_MOUSELAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSELAST);
break;
#endif /* (_WIN32_WINNT >= 0x0600) */
// #if(_WIN32_WINNT >= 0x0400)
// /* Value for rolling one detent */
// #define WHEEL_DELTA 120
// #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
// /* Setting to scroll one page for SPI_GET/SETWHEELSCROLLLINES */
// #define WHEEL_PAGESCROLL (UINT_MAX)
// #endif /* _WIN32_WINNT >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0500)
// #define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam))
// #define GET_NCHITTEST_WPARAM(wParam) ((short)LOWORD(wParam))
// #define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
// /* XButton values are WORD flags */
// #define XBUTTON1 0x0001
// #define XBUTTON2 0x0002
// /* Were there to be an XBUTTON3, its value would be 0x0004 */
// #endif /* _WIN32_WINNT >= 0x0500 */
case WM_PARENTNOTIFY :
p = (const char *)WM_MACRO_2_STRINGS(WM_PARENTNOTIFY);
break;
case WM_ENTERMENULOOP :
p = (const char *)WM_MACRO_2_STRINGS(WM_ENTERMENULOOP);
break;
case WM_EXITMENULOOP :
p = (const char *)WM_MACRO_2_STRINGS(WM_EXITMENULOOP);
break;
#if(WINVER >= 0x0400)
case WM_NEXTMENU :
p = (const char *)WM_MACRO_2_STRINGS(WM_NEXTMENU);
break;
case WM_SIZING :
p = (const char *)WM_MACRO_2_STRINGS(WM_SIZING);
break;
case WM_CAPTURECHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_CAPTURECHANGED);
break;
case WM_MOVING :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOVING);
break;
// #endif /* WINVER >= 0x0400 */
#if(WINVER >= 0x0400)
case WM_POWERBROADCAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_POWERBROADCAST);
break;
// #ifndef _WIN32_WCE
// #define PBT_APMQUERYSUSPEND 0x0000
// #define PBT_APMQUERYSTANDBY 0x0001
// #define PBT_APMQUERYSUSPENDFAILED 0x0002
// #define PBT_APMQUERYSTANDBYFAILED 0x0003
// #define PBT_APMSUSPEND 0x0004
// #define PBT_APMSTANDBY 0x0005
// #define PBT_APMRESUMECRITICAL 0x0006
// #define PBT_APMRESUMESUSPEND 0x0007
// #define PBT_APMRESUMESTANDBY 0x0008
// #define PBTF_APMRESUMEFROMFAILURE 0x00000001
// #define PBT_APMBATTERYLOW 0x0009
// #define PBT_APMPOWERSTATUSCHANGE 0x000A
// #define PBT_APMOEMEVENT 0x000B
// #define PBT_APMRESUMEAUTOMATIC 0x0012
// #if (_WIN32_WINNT >= 0x0502)
// #ifndef PBT_POWERSETTINGCHANGE
// #define PBT_POWERSETTINGCHANGE 0x8013
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct {
// GUID PowerSetting;
// DWORD DataLength;
// UCHAR Data[1];
// } POWERBROADCAST_SETTING, *PPOWERBROADCAST_SETTING;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif // PBT_POWERSETTINGCHANGE
// #endif // (_WIN32_WINNT >= 0x0502)
#endif
#endif /* WINVER >= 0x0400 */
#if(WINVER >= 0x0400)
case WM_DEVICECHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_DEVICECHANGE);
break;
#endif /* WINVER >= 0x0400 */
case WM_MDICREATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDICREATE);
break;
case WM_MDIDESTROY :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDIDESTROY);
break;
case WM_MDIACTIVATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDIACTIVATE);
break;
case WM_MDIRESTORE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDIRESTORE);
break;
case WM_MDINEXT :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDINEXT);
break;
case WM_MDIMAXIMIZE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDIMAXIMIZE);
break;
case WM_MDITILE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDITILE);
break;
case WM_MDICASCADE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDICASCADE);
break;
case WM_MDIICONARRANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDIICONARRANGE);
break;
case WM_MDIGETACTIVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDIGETACTIVE);
break;
case WM_MDISETMENU :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDISETMENU);
break;
case WM_ENTERSIZEMOVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_ENTERSIZEMOVE);
break;
case WM_EXITSIZEMOVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_EXITSIZEMOVE);
break;
case WM_DROPFILES :
p = (const char *)WM_MACRO_2_STRINGS(WM_DROPFILES);
break;
case WM_MDIREFRESHMENU :
p = (const char *)WM_MACRO_2_STRINGS(WM_MDIREFRESHMENU);
break;
#if(WINVER >= 0x0602)
case WM_POINTERDEVICECHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERDEVICECHANGE);
break;
case WM_POINTERDEVICEINRANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERDEVICEINRANGE);
break;
case WM_POINTERDEVICEOUTOFRANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERDEVICEOUTOFRANGE);
break;
#endif /* WINVER >= 0x0602 */
#if(WINVER >= 0x0601)
case WM_TOUCH :
p = (const char *)WM_MACRO_2_STRINGS(WM_TOUCH);
break;
#endif /* WINVER >= 0x0601 */
#if(WINVER >= 0x0602)
case WM_NCPOINTERUPDATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCPOINTERUPDATE);
break;
case WM_NCPOINTERDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCPOINTERDOWN);
break;
case WM_NCPOINTERUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCPOINTERUP);
break;
case WM_POINTERUPDATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERUPDATE);
break;
case WM_POINTERDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERDOWN);
break;
case WM_POINTERUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERUP);
break;
case WM_POINTERENTER :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERENTER);
break;
case WM_POINTERLEAVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERLEAVE);
break;
case WM_POINTERACTIVATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERACTIVATE);
break;
case WM_POINTERCAPTURECHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERCAPTURECHANGED);
break;
case WM_TOUCHHITTESTING :
p = (const char *)WM_MACRO_2_STRINGS(WM_TOUCHHITTESTING);
break;
case WM_POINTERWHEEL :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERWHEEL);
break;
case WM_POINTERHWHEEL :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERHWHEEL);
break;
// #define DM_POINTERHITTEST 0x0250
case WM_POINTERROUTEDTO :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERROUTEDTO);
break;
case WM_POINTERROUTEDAWAY :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERROUTEDAWAY);
break;
case WM_POINTERROUTEDRELEASED :
p = (const char *)WM_MACRO_2_STRINGS(WM_POINTERROUTEDRELEASED);
break;
#endif /* WINVER >= 0x0602 */
#if(WINVER >= 0x0400)
case WM_IME_SETCONTEXT :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_SETCONTEXT);
break;
case WM_IME_NOTIFY :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_NOTIFY);
break;
case WM_IME_CONTROL :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_CONTROL);
break;
case WM_IME_COMPOSITIONFULL :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_COMPOSITIONFULL);
break;
case WM_IME_SELECT :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_SELECT);
break;
case WM_IME_CHAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_CHAR);
break;
#endif /* WINVER >= 0x0400 */
#if(WINVER >= 0x0500)
case WM_IME_REQUEST :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_REQUEST);
break;
#endif /* WINVER >= 0x0500 */
#if(WINVER >= 0x0400)
case WM_IME_KEYDOWN :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_KEYDOWN);
break;
case WM_IME_KEYUP :
p = (const char *)WM_MACRO_2_STRINGS(WM_IME_KEYUP);
break;
#endif /* WINVER >= 0x0400 */
#if((_WIN32_WINNT >= 0x0400) || (WINVER >= 0x0500))
case WM_MOUSEHOVER :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSEHOVER);
break;
case WM_MOUSELEAVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_MOUSELEAVE);
break;
#endif
#if(WINVER >= 0x0500)
case WM_NCMOUSEHOVER :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCMOUSEHOVER);
break;
case WM_NCMOUSELEAVE :
p = (const char *)WM_MACRO_2_STRINGS(WM_NCMOUSELEAVE);
break;
#endif /* WINVER >= 0x0500 */
#if(_WIN32_WINNT >= 0x0501)
case WM_WTSSESSION_CHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_WTSSESSION_CHANGE);
break;
case WM_TABLET_FIRST :
p = (const char *)WM_MACRO_2_STRINGS(WM_TABLET_FIRST);
break;
case WM_TABLET_LAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_TABLET_LAST);
break;
#endif /* _WIN32_WINNT >= 0x0501 */
#if(WINVER >= 0x0601)
case WM_DPICHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_DPICHANGED);
break;
#endif /* WINVER >= 0x0601 */
#if(WINVER >= 0x0605)
case WM_DPICHANGED_BEFOREPARENT :
p = (const char *)WM_MACRO_2_STRINGS(WM_DPICHANGED_BEFOREPARENT);
break;
case WM_DPICHANGED_AFTERPARENT :
p = (const char *)WM_MACRO_2_STRINGS(WM_DPICHANGED_AFTERPARENT);
break;
case WM_GETDPISCALEDSIZE :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETDPISCALEDSIZE);
break;
#endif /* WINVER >= 0x0605 */
case WM_CUT :
p = (const char *)WM_MACRO_2_STRINGS(WM_CUT);
break;
case WM_COPY :
p = (const char *)WM_MACRO_2_STRINGS(WM_COPY);
break;
case WM_PASTE :
p = (const char *)WM_MACRO_2_STRINGS(WM_PASTE);
break;
case WM_CLEAR :
p = (const char *)WM_MACRO_2_STRINGS(WM_CLEAR);
break;
case WM_UNDO :
p = (const char *)WM_MACRO_2_STRINGS(WM_UNDO);
break;
case WM_RENDERFORMAT :
p = (const char *)WM_MACRO_2_STRINGS(WM_RENDERFORMAT);
break;
case WM_RENDERALLFORMATS :
p = (const char *)WM_MACRO_2_STRINGS(WM_RENDERALLFORMATS);
break;
case WM_DESTROYCLIPBOARD :
p = (const char *)WM_MACRO_2_STRINGS(WM_DESTROYCLIPBOARD);
break;
case WM_DRAWCLIPBOARD :
p = (const char *)WM_MACRO_2_STRINGS(WM_DRAWCLIPBOARD);
break;
case WM_PAINTCLIPBOARD :
p = (const char *)WM_MACRO_2_STRINGS(WM_PAINTCLIPBOARD);
break;
case WM_VSCROLLCLIPBOARD :
p = (const char *)WM_MACRO_2_STRINGS(WM_VSCROLLCLIPBOARD);
break;
case WM_SIZECLIPBOARD :
p = (const char *)WM_MACRO_2_STRINGS(WM_SIZECLIPBOARD);
break;
case WM_ASKCBFORMATNAME :
p = (const char *)WM_MACRO_2_STRINGS(WM_ASKCBFORMATNAME);
break;
case WM_CHANGECBCHAIN :
p = (const char *)WM_MACRO_2_STRINGS(WM_CHANGECBCHAIN);
break;
case WM_HSCROLLCLIPBOARD :
p = (const char *)WM_MACRO_2_STRINGS(WM_HSCROLLCLIPBOARD);
break;
case WM_QUERYNEWPALETTE :
p = (const char *)WM_MACRO_2_STRINGS(WM_QUERYNEWPALETTE);
break;
case WM_PALETTEISCHANGING :
p = (const char *)WM_MACRO_2_STRINGS(WM_PALETTEISCHANGING);
break;
case WM_PALETTECHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_PALETTECHANGED);
break;
case WM_HOTKEY :
p = (const char *)WM_MACRO_2_STRINGS(WM_HOTKEY);
break;
#if(WINVER >= 0x0400)
case WM_PRINT :
p = (const char *)WM_MACRO_2_STRINGS(WM_PRINT);
break;
case WM_PRINTCLIENT :
p = (const char *)WM_MACRO_2_STRINGS(WM_PRINTCLIENT);
break;
#endif /* WINVER >= 0x0400 */
#if(_WIN32_WINNT >= 0x0500)
case WM_APPCOMMAND :
p = (const char *)WM_MACRO_2_STRINGS(WM_APPCOMMAND);
break;
#endif /* _WIN32_WINNT >= 0x0500 */
#if(_WIN32_WINNT >= 0x0501)
case WM_THEMECHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_THEMECHANGED);
break;
#endif /* _WIN32_WINNT >= 0x0501 */
#if(_WIN32_WINNT >= 0x0501)
case WM_CLIPBOARDUPDATE :
p = (const char *)WM_MACRO_2_STRINGS(WM_CLIPBOARDUPDATE);
break;
#endif /* _WIN32_WINNT >= 0x0501 */
#if(_WIN32_WINNT >= 0x0600)
case WM_DWMCOMPOSITIONCHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_DWMCOMPOSITIONCHANGED);
break;
case WM_DWMNCRENDERINGCHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_DWMNCRENDERINGCHANGED);
break;
case WM_DWMCOLORIZATIONCOLORCHANGED :
p = (const char *)WM_MACRO_2_STRINGS(WM_DWMCOLORIZATIONCOLORCHANGED);
break;
case WM_DWMWINDOWMAXIMIZEDCHANGE :
p = (const char *)WM_MACRO_2_STRINGS(WM_DWMWINDOWMAXIMIZEDCHANGE);
break;
#endif /* _WIN32_WINNT >= 0x0600 */
#if(_WIN32_WINNT >= 0x0601)
case WM_DWMSENDICONICTHUMBNAIL :
p = (const char *)WM_MACRO_2_STRINGS(WM_DWMSENDICONICTHUMBNAIL);
break;
case WM_DWMSENDICONICLIVEPREVIEWBITMAP :
p = (const char *)WM_MACRO_2_STRINGS(WM_DWMSENDICONICLIVEPREVIEWBITMAP);
break;
#endif /* _WIN32_WINNT >= 0x0601 */
#if(WINVER >= 0x0600)
case WM_GETTITLEBARINFOEX :
p = (const char *)WM_MACRO_2_STRINGS(WM_GETTITLEBARINFOEX);
break;
#endif /* WINVER >= 0x0600 */
#if(WINVER >= 0x0400)
#endif /* WINVER >= 0x0400 */
#if(WINVER >= 0x0400)
case WM_HANDHELDFIRST :
p = (const char *)WM_MACRO_2_STRINGS(WM_HANDHELDFIRST);
break;
case WM_HANDHELDLAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_HANDHELDLAST);
break;
case WM_AFXFIRST :
p = (const char *)WM_MACRO_2_STRINGS(WM_AFXFIRST);
break;
case WM_AFXLAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_AFXLAST);
break;
#endif /* WINVER >= 0x0400 */
case WM_PENWINFIRST :
p = (const char *)WM_MACRO_2_STRINGS(WM_PENWINFIRST);
break;
case WM_PENWINLAST :
p = (const char *)WM_MACRO_2_STRINGS(WM_PENWINLAST);
break;
#if(WINVER >= 0x0400)
case WM_APP :
p = (const char *)WM_MACRO_2_STRINGS(WM_APP);
break;
#endif /* WINVER >= 0x0400 */
// /*
// * NOTE: All Message Numbers below 0x0400 are RESERVED.
// *
// * Private Window Messages Start Here:
// */
case WM_USER :
p = (const char *)WM_MACRO_2_STRINGS(WM_USER);
break;
default :
p = (const char *)("Unknown");
break;
}
return p;
}
// #if(WINVER >= 0x0400)
// /* wParam for WM_SIZING message */
// #define WMSZ_LEFT 1
// #define WMSZ_RIGHT 2
// #define WMSZ_TOP 3
// #define WMSZ_TOPLEFT 4
// #define WMSZ_TOPRIGHT 5
// #define WMSZ_BOTTOM 6
// #define WMSZ_BOTTOMLEFT 7
// #define WMSZ_BOTTOMRIGHT 8
// #endif /* WINVER >= 0x0400 */
// #ifndef NONCMESSAGES
// /*
// * WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes
// */
// #define HTERROR (-2)
// #define HTTRANSPARENT (-1)
// #define HTNOWHERE 0
// #define HTCLIENT 1
// #define HTCAPTION 2
// #define HTSYSMENU 3
// #define HTGROWBOX 4
// #define HTSIZE HTGROWBOX
// #define HTMENU 5
// #define HTHSCROLL 6
// #define HTVSCROLL 7
// #define HTMINBUTTON 8
// #define HTMAXBUTTON 9
// #define HTLEFT 10
// #define HTRIGHT 11
// #define HTTOP 12
// #define HTTOPLEFT 13
// #define HTTOPRIGHT 14
// #define HTBOTTOM 15
// #define HTBOTTOMLEFT 16
// #define HTBOTTOMRIGHT 17
// #define HTBORDER 18
// #define HTREDUCE HTMINBUTTON
// #define HTZOOM HTMAXBUTTON
// #define HTSIZEFIRST HTLEFT
// #define HTSIZELAST HTBOTTOMRIGHT
// #if(WINVER >= 0x0400)
// #define HTOBJECT 19
// #define HTCLOSE 20
// #define HTHELP 21
// #endif /* WINVER >= 0x0400 */
// /*
// * SendMessageTimeout values
// */
// #define SMTO_NORMAL 0x0000
// #define SMTO_BLOCK 0x0001
// #define SMTO_ABORTIFHUNG 0x0002
// #if(WINVER >= 0x0500)
// #define SMTO_NOTIMEOUTIFNOTHUNG 0x0008
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0600)
// #define SMTO_ERRORONEXIT 0x0020
// #endif /* WINVER >= 0x0600 */
// #if(WINVER >= 0x0602)
// #endif /* WINVER >= 0x0602 */
// #endif /* !NONCMESSAGES */
// /*
// * WM_MOUSEACTIVATE Return Codes
// */
// #define MA_ACTIVATE 1
// #define MA_ACTIVATEANDEAT 2
// #define MA_NOACTIVATE 3
// #define MA_NOACTIVATEANDEAT 4
// /*
// * WM_SETICON / WM_GETICON Type Codes
// */
// #define ICON_SMALL 0
// #define ICON_BIG 1
// #if(_WIN32_WINNT >= 0x0501)
// #define ICON_SMALL2 2
// #endif /* _WIN32_WINNT >= 0x0501 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// UINT
// WINAPI
// RegisterWindowMessageA(
// _In_ LPCSTR lpString);
// WINUSERAPI
// UINT
// WINAPI
// RegisterWindowMessageW(
// _In_ LPCWSTR lpString);
// #ifdef UNICODE
// #define RegisterWindowMessage RegisterWindowMessageW
// #else
// #define RegisterWindowMessage RegisterWindowMessageA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * WM_SIZE message wParam values
// */
// #define SIZE_RESTORED 0
// #define SIZE_MINIMIZED 1
// #define SIZE_MAXIMIZED 2
// #define SIZE_MAXSHOW 3
// #define SIZE_MAXHIDE 4
// /*
// * Obsolete constant names
// */
// #define SIZENORMAL SIZE_RESTORED
// #define SIZEICONIC SIZE_MINIMIZED
// #define SIZEFULLSCREEN SIZE_MAXIMIZED
// #define SIZEZOOMSHOW SIZE_MAXSHOW
// #define SIZEZOOMHIDE SIZE_MAXHIDE
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * WM_WINDOWPOSCHANGING/CHANGED struct pointed to by lParam
// */
// typedef struct tagWINDOWPOS {
// HWND hwnd;
// HWND hwndInsertAfter;
// int x;
// int y;
// int cx;
// int cy;
// UINT flags;
// } WINDOWPOS, *LPWINDOWPOS, *PWINDOWPOS;
// /*
// * WM_NCCALCSIZE parameter structure
// */
// typedef struct tagNCCALCSIZE_PARAMS {
// RECT rgrc[3];
// PWINDOWPOS lppos;
// } NCCALCSIZE_PARAMS, *LPNCCALCSIZE_PARAMS;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * WM_NCCALCSIZE "window valid rect" return values
// */
// #define WVR_ALIGNTOP 0x0010
// #define WVR_ALIGNLEFT 0x0020
// #define WVR_ALIGNBOTTOM 0x0040
// #define WVR_ALIGNRIGHT 0x0080
// #define WVR_HREDRAW 0x0100
// #define WVR_VREDRAW 0x0200
// #define WVR_REDRAW (WVR_HREDRAW | \
// WVR_VREDRAW)
// #define WVR_VALIDRECTS 0x0400
// #ifndef NOKEYSTATES
// /*
// * Key State Masks for Mouse Messages
// */
// #define MK_LBUTTON 0x0001
// #define MK_RBUTTON 0x0002
// #define MK_SHIFT 0x0004
// #define MK_CONTROL 0x0008
// #define MK_MBUTTON 0x0010
// #if(_WIN32_WINNT >= 0x0500)
// #define MK_XBUTTON1 0x0020
// #define MK_XBUTTON2 0x0040
// #endif /* _WIN32_WINNT >= 0x0500 */
// #endif /* !NOKEYSTATES */
// #if(_WIN32_WINNT >= 0x0400)
// #ifndef NOTRACKMOUSEEVENT
// #define TME_HOVER 0x00000001
// #define TME_LEAVE 0x00000002
// #if(WINVER >= 0x0500)
// #define TME_NONCLIENT 0x00000010
// #endif /* WINVER >= 0x0500 */
// #define TME_QUERY 0x40000000
// #define TME_CANCEL 0x80000000
// #define HOVER_DEFAULT 0xFFFFFFFF
// #endif /* _WIN32_WINNT >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0400)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagTRACKMOUSEEVENT {
// DWORD cbSize;
// DWORD dwFlags;
// HWND hwndTrack;
// DWORD dwHoverTime;
// } TRACKMOUSEEVENT, *LPTRACKMOUSEEVENT;
// WINUSERAPI
// BOOL
// WINAPI
// TrackMouseEvent(
// _Inout_ LPTRACKMOUSEEVENT lpEventTrack);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* _WIN32_WINNT >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0400)
// #endif /* !NOTRACKMOUSEEVENT */
// #endif /* _WIN32_WINNT >= 0x0400 */
// #endif /* !NOWINMESSAGES */
// #ifndef NOWINSTYLES
// /*
// * Window Styles
// */
// #define WS_OVERLAPPED 0x00000000L
// #define WS_POPUP 0x80000000L
// #define WS_CHILD 0x40000000L
// #define WS_MINIMIZE 0x20000000L
// #define WS_VISIBLE 0x10000000L
// #define WS_DISABLED 0x08000000L
// #define WS_CLIPSIBLINGS 0x04000000L
// #define WS_CLIPCHILDREN 0x02000000L
// #define WS_MAXIMIZE 0x01000000L
// #define WS_CAPTION 0x00C00000L /* WS_BORDER | WS_DLGFRAME */
// #define WS_BORDER 0x00800000L
// #define WS_DLGFRAME 0x00400000L
// #define WS_VSCROLL 0x00200000L
// #define WS_HSCROLL 0x00100000L
// #define WS_SYSMENU 0x00080000L
// #define WS_THICKFRAME 0x00040000L
// #define WS_GROUP 0x00020000L
// #define WS_TABSTOP 0x00010000L
// #define WS_MINIMIZEBOX 0x00020000L
// #define WS_MAXIMIZEBOX 0x00010000L
// #define WS_TILED WS_OVERLAPPED
// #define WS_ICONIC WS_MINIMIZE
// #define WS_SIZEBOX WS_THICKFRAME
// #define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
// /*
// * Common Window Styles
// */
// #define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | \
// WS_CAPTION | \
// WS_SYSMENU | \
// WS_THICKFRAME | \
// WS_MINIMIZEBOX | \
// WS_MAXIMIZEBOX)
// #define WS_POPUPWINDOW (WS_POPUP | \
// WS_BORDER | \
// WS_SYSMENU)
// #define WS_CHILDWINDOW (WS_CHILD)
// /*
// * Extended Window Styles
// */
// #define WS_EX_DLGMODALFRAME 0x00000001L
// #define WS_EX_NOPARENTNOTIFY 0x00000004L
// #define WS_EX_TOPMOST 0x00000008L
// #define WS_EX_ACCEPTFILES 0x00000010L
// #define WS_EX_TRANSPARENT 0x00000020L
// #if(WINVER >= 0x0400)
// #define WS_EX_MDICHILD 0x00000040L
// #define WS_EX_TOOLWINDOW 0x00000080L
// #define WS_EX_WINDOWEDGE 0x00000100L
// #define WS_EX_CLIENTEDGE 0x00000200L
// #define WS_EX_CONTEXTHELP 0x00000400L
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0400)
// #define WS_EX_RIGHT 0x00001000L
// #define WS_EX_LEFT 0x00000000L
// #define WS_EX_RTLREADING 0x00002000L
// #define WS_EX_LTRREADING 0x00000000L
// #define WS_EX_LEFTSCROLLBAR 0x00004000L
// #define WS_EX_RIGHTSCROLLBAR 0x00000000L
// #define WS_EX_CONTROLPARENT 0x00010000L
// #define WS_EX_STATICEDGE 0x00020000L
// #define WS_EX_APPWINDOW 0x00040000L
// #define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
// #define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
// #endif /* WINVER >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0500)
// #define WS_EX_LAYERED 0x00080000
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(WINVER >= 0x0500)
// #define WS_EX_NOINHERITLAYOUT 0x00100000L // Disable inheritence of mirroring by children
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0602)
// #define WS_EX_NOREDIRECTIONBITMAP 0x00200000L
// #endif /* WINVER >= 0x0602 */
// #if(WINVER >= 0x0500)
// #define WS_EX_LAYOUTRTL 0x00400000L // Right to left mirroring
// #endif /* WINVER >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0501)
// #define WS_EX_COMPOSITED 0x02000000L
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0500)
// #define WS_EX_NOACTIVATE 0x08000000L
// #endif /* _WIN32_WINNT >= 0x0500 */
// /*
// * Class styles
// */
// #define CS_VREDRAW 0x0001
// #define CS_HREDRAW 0x0002
// #define CS_DBLCLKS 0x0008
// #define CS_OWNDC 0x0020
// #define CS_CLASSDC 0x0040
// #define CS_PARENTDC 0x0080
// #define CS_NOCLOSE 0x0200
// #define CS_SAVEBITS 0x0800
// #define CS_BYTEALIGNCLIENT 0x1000
// #define CS_BYTEALIGNWINDOW 0x2000
// #define CS_GLOBALCLASS 0x4000
// #define CS_IME 0x00010000
// #if(_WIN32_WINNT >= 0x0501)
// #define CS_DROPSHADOW 0x00020000
// #endif /* _WIN32_WINNT >= 0x0501 */
// #endif /* !NOWINSTYLES */
// #if(WINVER >= 0x0400)
// /* WM_PRINT flags */
// #define PRF_CHECKVISIBLE 0x00000001L
// #define PRF_NONCLIENT 0x00000002L
// #define PRF_CLIENT 0x00000004L
// #define PRF_ERASEBKGND 0x00000008L
// #define PRF_CHILDREN 0x00000010L
// #define PRF_OWNED 0x00000020L
// /* 3D border styles */
// #define BDR_RAISEDOUTER 0x0001
// #define BDR_SUNKENOUTER 0x0002
// #define BDR_RAISEDINNER 0x0004
// #define BDR_SUNKENINNER 0x0008
// #define BDR_OUTER (BDR_RAISEDOUTER | BDR_SUNKENOUTER)
// #define BDR_INNER (BDR_RAISEDINNER | BDR_SUNKENINNER)
// #define BDR_RAISED (BDR_RAISEDOUTER | BDR_RAISEDINNER)
// #define BDR_SUNKEN (BDR_SUNKENOUTER | BDR_SUNKENINNER)
// #define EDGE_RAISED (BDR_RAISEDOUTER | BDR_RAISEDINNER)
// #define EDGE_SUNKEN (BDR_SUNKENOUTER | BDR_SUNKENINNER)
// #define EDGE_ETCHED (BDR_SUNKENOUTER | BDR_RAISEDINNER)
// #define EDGE_BUMP (BDR_RAISEDOUTER | BDR_SUNKENINNER)
// /* Border flags */
// #define BF_LEFT 0x0001
// #define BF_TOP 0x0002
// #define BF_RIGHT 0x0004
// #define BF_BOTTOM 0x0008
// #define BF_TOPLEFT (BF_TOP | BF_LEFT)
// #define BF_TOPRIGHT (BF_TOP | BF_RIGHT)
// #define BF_BOTTOMLEFT (BF_BOTTOM | BF_LEFT)
// #define BF_BOTTOMRIGHT (BF_BOTTOM | BF_RIGHT)
// #define BF_RECT (BF_LEFT | BF_TOP | BF_RIGHT | BF_BOTTOM)
// #define BF_DIAGONAL 0x0010
// // For diagonal lines, the BF_RECT flags specify the end point of the
// // vector bounded by the rectangle parameter.
// #define BF_DIAGONAL_ENDTOPRIGHT (BF_DIAGONAL | BF_TOP | BF_RIGHT)
// #define BF_DIAGONAL_ENDTOPLEFT (BF_DIAGONAL | BF_TOP | BF_LEFT)
// #define BF_DIAGONAL_ENDBOTTOMLEFT (BF_DIAGONAL | BF_BOTTOM | BF_LEFT)
// #define BF_DIAGONAL_ENDBOTTOMRIGHT (BF_DIAGONAL | BF_BOTTOM | BF_RIGHT)
// #define BF_MIDDLE 0x0800 /* Fill in the middle */
// #define BF_SOFT 0x1000 /* For softer buttons */
// #define BF_ADJUST 0x2000 /* Calculate the space left over */
// #define BF_FLAT 0x4000 /* For flat rather than 3D borders */
// #define BF_MONO 0x8000 /* For monochrome borders */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// DrawEdge(
// _In_ HDC hdc,
// _Inout_ LPRECT qrc,
// _In_ UINT edge,
// _In_ UINT grfFlags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /* flags for DrawFrameControl */
// #define DFC_CAPTION 1
// #define DFC_MENU 2
// #define DFC_SCROLL 3
// #define DFC_BUTTON 4
// #if(WINVER >= 0x0500)
// #define DFC_POPUPMENU 5
// #endif /* WINVER >= 0x0500 */
// #define DFCS_CAPTIONCLOSE 0x0000
// #define DFCS_CAPTIONMIN 0x0001
// #define DFCS_CAPTIONMAX 0x0002
// #define DFCS_CAPTIONRESTORE 0x0003
// #define DFCS_CAPTIONHELP 0x0004
// #define DFCS_MENUARROW 0x0000
// #define DFCS_MENUCHECK 0x0001
// #define DFCS_MENUBULLET 0x0002
// #define DFCS_MENUARROWRIGHT 0x0004
// #define DFCS_SCROLLUP 0x0000
// #define DFCS_SCROLLDOWN 0x0001
// #define DFCS_SCROLLLEFT 0x0002
// #define DFCS_SCROLLRIGHT 0x0003
// #define DFCS_SCROLLCOMBOBOX 0x0005
// #define DFCS_SCROLLSIZEGRIP 0x0008
// #define DFCS_SCROLLSIZEGRIPRIGHT 0x0010
// #define DFCS_BUTTONCHECK 0x0000
// #define DFCS_BUTTONRADIOIMAGE 0x0001
// #define DFCS_BUTTONRADIOMASK 0x0002
// #define DFCS_BUTTONRADIO 0x0004
// #define DFCS_BUTTON3STATE 0x0008
// #define DFCS_BUTTONPUSH 0x0010
// #define DFCS_INACTIVE 0x0100
// #define DFCS_PUSHED 0x0200
// #define DFCS_CHECKED 0x0400
// #if(WINVER >= 0x0500)
// #define DFCS_TRANSPARENT 0x0800
// #define DFCS_HOT 0x1000
// #endif /* WINVER >= 0x0500 */
// #define DFCS_ADJUSTRECT 0x2000
// #define DFCS_FLAT 0x4000
// #define DFCS_MONO 0x8000
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// DrawFrameControl(
// _In_ HDC,
// _Inout_ LPRECT,
// _In_ UINT,
// _In_ UINT);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /* flags for DrawCaption */
// #define DC_ACTIVE 0x0001
// #define DC_SMALLCAP 0x0002
// #define DC_ICON 0x0004
// #define DC_TEXT 0x0008
// #define DC_INBUTTON 0x0010
// #if(WINVER >= 0x0500)
// #define DC_GRADIENT 0x0020
// #endif /* WINVER >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0501)
// #define DC_BUTTONS 0x1000
// #endif /* _WIN32_WINNT >= 0x0501 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// DrawCaption(
// _In_ HWND hwnd,
// _In_ HDC hdc,
// _In_ CONST RECT * lprect,
// _In_ UINT flags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define IDANI_OPEN 1
// #define IDANI_CAPTION 3
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// DrawAnimatedRects(
// _In_opt_ HWND hwnd,
// _In_ int idAni,
// _In_ CONST RECT *lprcFrom,
// _In_ CONST RECT *lprcTo);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// #ifndef NOCLIPBOARD
// /*
// * Predefined Clipboard Formats
// */
// #define CF_TEXT 1
// #define CF_BITMAP 2
// #define CF_METAFILEPICT 3
// #define CF_SYLK 4
// #define CF_DIF 5
// #define CF_TIFF 6
// #define CF_OEMTEXT 7
// #define CF_DIB 8
// #define CF_PALETTE 9
// #define CF_PENDATA 10
// #define CF_RIFF 11
// #define CF_WAVE 12
// #define CF_UNICODETEXT 13
// #define CF_ENHMETAFILE 14
// #if(WINVER >= 0x0400)
// #define CF_HDROP 15
// #define CF_LOCALE 16
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0500)
// #define CF_DIBV5 17
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0500)
// #define CF_MAX 18
// #elif(WINVER >= 0x0400)
// #define CF_MAX 17
// #else
// #define CF_MAX 15
// #endif
// #define CF_OWNERDISPLAY 0x0080
// #define CF_DSPTEXT 0x0081
// #define CF_DSPBITMAP 0x0082
// #define CF_DSPMETAFILEPICT 0x0083
// #define CF_DSPENHMETAFILE 0x008E
// /*
// * "Private" formats don't get GlobalFree()'d
// */
// #define CF_PRIVATEFIRST 0x0200
// #define CF_PRIVATELAST 0x02FF
// /*
// * "GDIOBJ" formats do get DeleteObject()'d
// */
// #define CF_GDIOBJFIRST 0x0300
// #define CF_GDIOBJLAST 0x03FF
// #endif /* !NOCLIPBOARD */
// /*
// * Defines for the fVirt field of the Accelerator table structure.
// */
// #define FVIRTKEY TRUE /* Assumed to be == TRUE */
// #define FNOINVERT 0x02
// #define FSHIFT 0x04
// #define FCONTROL 0x08
// #define FALT 0x10
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagACCEL {
// #ifndef _MAC
// BYTE fVirt; /* Also called the flags field */
// WORD key;
// WORD cmd;
// #else
// WORD fVirt; /* Also called the flags field */
// WORD key;
// DWORD cmd;
// #endif
// } ACCEL, *LPACCEL;
// typedef struct tagPAINTSTRUCT {
// HDC hdc;
// BOOL fErase;
// RECT rcPaint;
// BOOL fRestore;
// BOOL fIncUpdate;
// BYTE rgbReserved[32];
// } PAINTSTRUCT, *PPAINTSTRUCT, *NPPAINTSTRUCT, *LPPAINTSTRUCT;
// typedef struct tagCREATESTRUCTA {
// LPVOID lpCreateParams;
// HINSTANCE hInstance;
// HMENU hMenu;
// HWND hwndParent;
// int cy;
// int cx;
// int y;
// int x;
// LONG style;
// LPCSTR lpszName;
// LPCSTR lpszClass;
// DWORD dwExStyle;
// } CREATESTRUCTA, *LPCREATESTRUCTA;
// typedef struct tagCREATESTRUCTW {
// LPVOID lpCreateParams;
// HINSTANCE hInstance;
// HMENU hMenu;
// HWND hwndParent;
// int cy;
// int cx;
// int y;
// int x;
// LONG style;
// LPCWSTR lpszName;
// LPCWSTR lpszClass;
// DWORD dwExStyle;
// } CREATESTRUCTW, *LPCREATESTRUCTW;
// #ifdef UNICODE
// typedef CREATESTRUCTW CREATESTRUCT;
// typedef LPCREATESTRUCTW LPCREATESTRUCT;
// #else
// typedef CREATESTRUCTA CREATESTRUCT;
// typedef LPCREATESTRUCTA LPCREATESTRUCT;
// #endif // UNICODE
// typedef struct tagWINDOWPLACEMENT {
// UINT length;
// UINT flags;
// UINT showCmd;
// POINT ptMinPosition;
// POINT ptMaxPosition;
// RECT rcNormalPosition;
// #ifdef _MAC
// RECT rcDevice;
// #endif
// } WINDOWPLACEMENT;
// typedef WINDOWPLACEMENT *PWINDOWPLACEMENT, *LPWINDOWPLACEMENT;
// #define WPF_SETMINPOSITION 0x0001
// #define WPF_RESTORETOMAXIMIZED 0x0002
// #if(_WIN32_WINNT >= 0x0500)
// #define WPF_ASYNCWINDOWPLACEMENT 0x0004
// #endif /* _WIN32_WINNT >= 0x0500 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0400)
// #pragma region Application Family or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
// typedef struct tagNMHDR
// {
// HWND hwndFrom;
// UINT_PTR idFrom;
// UINT code; // NM_ code
// } NMHDR;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef NMHDR FAR * LPNMHDR;
// typedef struct tagSTYLESTRUCT
// {
// DWORD styleOld;
// DWORD styleNew;
// } STYLESTRUCT, *LPSTYLESTRUCT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// /*
// * Owner draw control types
// */
// #define ODT_MENU 1
// #define ODT_LISTBOX 2
// #define ODT_COMBOBOX 3
// #define ODT_BUTTON 4
// #if(WINVER >= 0x0400)
// #define ODT_STATIC 5
// #endif /* WINVER >= 0x0400 */
// /*
// * Owner draw actions
// */
// #define ODA_DRAWENTIRE 0x0001
// #define ODA_SELECT 0x0002
// #define ODA_FOCUS 0x0004
// /*
// * Owner draw state
// */
// #define ODS_SELECTED 0x0001
// #define ODS_GRAYED 0x0002
// #define ODS_DISABLED 0x0004
// #define ODS_CHECKED 0x0008
// #define ODS_FOCUS 0x0010
// #if(WINVER >= 0x0400)
// #define ODS_DEFAULT 0x0020
// #define ODS_COMBOBOXEDIT 0x1000
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0500)
// #define ODS_HOTLIGHT 0x0040
// #define ODS_INACTIVE 0x0080
// #if(_WIN32_WINNT >= 0x0500)
// #define ODS_NOACCEL 0x0100
// #define ODS_NOFOCUSRECT 0x0200
// #endif /* _WIN32_WINNT >= 0x0500 */
// #endif /* WINVER >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * MEASUREITEMSTRUCT for ownerdraw
// */
// typedef struct tagMEASUREITEMSTRUCT {
// UINT CtlType;
// UINT CtlID;
// UINT itemID;
// UINT itemWidth;
// UINT itemHeight;
// ULONG_PTR itemData;
// } MEASUREITEMSTRUCT, NEAR *PMEASUREITEMSTRUCT, FAR *LPMEASUREITEMSTRUCT;
// /*
// * DRAWITEMSTRUCT for ownerdraw
// */
// typedef struct tagDRAWITEMSTRUCT {
// UINT CtlType;
// UINT CtlID;
// UINT itemID;
// UINT itemAction;
// UINT itemState;
// HWND hwndItem;
// HDC hDC;
// RECT rcItem;
// ULONG_PTR itemData;
// } DRAWITEMSTRUCT, NEAR *PDRAWITEMSTRUCT, FAR *LPDRAWITEMSTRUCT;
// /*
// * DELETEITEMSTRUCT for ownerdraw
// */
// typedef struct tagDELETEITEMSTRUCT {
// UINT CtlType;
// UINT CtlID;
// UINT itemID;
// HWND hwndItem;
// ULONG_PTR itemData;
// } DELETEITEMSTRUCT, NEAR *PDELETEITEMSTRUCT, FAR *LPDELETEITEMSTRUCT;
// /*
// * COMPAREITEMSTUCT for ownerdraw sorting
// */
// typedef struct tagCOMPAREITEMSTRUCT {
// UINT CtlType;
// UINT CtlID;
// HWND hwndItem;
// UINT itemID1;
// ULONG_PTR itemData1;
// UINT itemID2;
// ULONG_PTR itemData2;
// DWORD dwLocaleId;
// } COMPAREITEMSTRUCT, NEAR *PCOMPAREITEMSTRUCT, FAR *LPCOMPAREITEMSTRUCT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NOMSG
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Message Function Templates
// */
// WINUSERAPI
// BOOL
// WINAPI
// GetMessageA(
// _Out_ LPMSG lpMsg,
// _In_opt_ HWND hWnd,
// _In_ UINT wMsgFilterMin,
// _In_ UINT wMsgFilterMax);
// WINUSERAPI
// BOOL
// WINAPI
// GetMessageW(
// _Out_ LPMSG lpMsg,
// _In_opt_ HWND hWnd,
// _In_ UINT wMsgFilterMin,
// _In_ UINT wMsgFilterMax);
// #ifdef UNICODE
// #define GetMessage GetMessageW
// #else
// #define GetMessage GetMessageA
// #endif // !UNICODE
// #if defined(_M_CEE)
// #undef GetMessage
// __inline
// BOOL
// GetMessage(
// LPMSG lpMsg,
// HWND hWnd,
// UINT wMsgFilterMin,
// UINT wMsgFilterMax
// )
// {
// #ifdef UNICODE
// return GetMessageW(
// #else
// return GetMessageA(
// #endif
// lpMsg,
// hWnd,
// wMsgFilterMin,
// wMsgFilterMax
// );
// }
// #endif /* _M_CEE */
// WINUSERAPI
// BOOL
// WINAPI
// TranslateMessage(
// _In_ CONST MSG *lpMsg);
// WINUSERAPI
// LRESULT
// WINAPI
// DispatchMessageA(
// _In_ CONST MSG *lpMsg);
// WINUSERAPI
// LRESULT
// WINAPI
// DispatchMessageW(
// _In_ CONST MSG *lpMsg);
// #ifdef UNICODE
// #define DispatchMessage DispatchMessageW
// #else
// #define DispatchMessage DispatchMessageA
// #endif // !UNICODE
// #if defined(_M_CEE)
// #undef DispatchMessage
// __inline
// LRESULT
// DispatchMessage(
// CONST MSG *lpMsg
// )
// {
// #ifdef UNICODE
// return DispatchMessageW(
// #else
// return DispatchMessageA(
// #endif
// lpMsg
// );
// }
// #endif /* _M_CEE */
// WINUSERAPI
// BOOL
// WINAPI
// SetMessageQueue(
// _In_ int cMessagesMax);
// WINUSERAPI
// BOOL
// WINAPI
// PeekMessageA(
// _Out_ LPMSG lpMsg,
// _In_opt_ HWND hWnd,
// _In_ UINT wMsgFilterMin,
// _In_ UINT wMsgFilterMax,
// _In_ UINT wRemoveMsg);
// WINUSERAPI
// BOOL
// WINAPI
// PeekMessageW(
// _Out_ LPMSG lpMsg,
// _In_opt_ HWND hWnd,
// _In_ UINT wMsgFilterMin,
// _In_ UINT wMsgFilterMax,
// _In_ UINT wRemoveMsg);
// #ifdef UNICODE
// #define PeekMessage PeekMessageW
// #else
// #define PeekMessage PeekMessageA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * PeekMessage() Options
// */
// #define PM_NOREMOVE 0x0000
// #define PM_REMOVE 0x0001
// #define PM_NOYIELD 0x0002
// #if(WINVER >= 0x0500)
// #define PM_QS_INPUT (QS_INPUT << 16)
// #define PM_QS_POSTMESSAGE ((QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16)
// #define PM_QS_PAINT (QS_PAINT << 16)
// #define PM_QS_SENDMESSAGE (QS_SENDMESSAGE << 16)
// #endif /* WINVER >= 0x0500 */
// #endif /* !NOMSG */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// RegisterHotKey(
// _In_opt_ HWND hWnd,
// _In_ int id,
// _In_ UINT fsModifiers,
// _In_ UINT vk);
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterHotKey(
// _In_opt_ HWND hWnd,
// _In_ int id);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define MOD_ALT 0x0001
// #define MOD_CONTROL 0x0002
// #define MOD_SHIFT 0x0004
// #define MOD_WIN 0x0008
// #if(WINVER >= 0x0601)
// #define MOD_NOREPEAT 0x4000
// #endif /* WINVER >= 0x0601 */
// #define IDHOT_SNAPWINDOW (-1) /* SHIFT-PRINTSCRN */
// #define IDHOT_SNAPDESKTOP (-2) /* PRINTSCRN */
// #ifdef WIN_INTERNAL
// #ifndef LSTRING
// #define NOLSTRING
// #endif /* LSTRING */
// #ifndef LFILEIO
// #define NOLFILEIO
// #endif /* LFILEIO */
// #endif /* WIN_INTERNAL */
// #if(WINVER >= 0x0400)
// #endif /* WINVER >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0400)
// #define ENDSESSION_CLOSEAPP 0x00000001
// #endif /* _WIN32_WINNT >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0400)
// #define ENDSESSION_CRITICAL 0x40000000
// #endif /* _WIN32_WINNT >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0400)
// #define ENDSESSION_LOGOFF 0x80000000
// #endif /* _WIN32_WINNT >= 0x0400 */
// #define EWX_LOGOFF 0x00000000
// #define EWX_SHUTDOWN 0x00000001
// #define EWX_REBOOT 0x00000002
// #define EWX_FORCE 0x00000004
// #define EWX_POWEROFF 0x00000008
// #if(_WIN32_WINNT >= 0x0500)
// #define EWX_FORCEIFHUNG 0x00000010
// #endif /* _WIN32_WINNT >= 0x0500 */
// #define EWX_QUICKRESOLVE 0x00000020
// #if(_WIN32_WINNT >= 0x0600)
// #define EWX_RESTARTAPPS 0x00000040
// #endif /* _WIN32_WINNT >= 0x0600 */
// #define EWX_HYBRID_SHUTDOWN 0x00400000
// #define EWX_BOOTOPTIONS 0x01000000
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #define ExitWindows(dwReserved, Code) ExitWindowsEx(EWX_LOGOFF, 0xFFFFFFFF)
// _When_((uFlags&(EWX_POWEROFF | EWX_SHUTDOWN | EWX_FORCE)) != 0,
// __drv_preferredFunction("InitiateSystemShutdownEx",
// "Legacy API. Rearchitect to avoid Reboot"))
// WINUSERAPI
// BOOL
// WINAPI
// ExitWindowsEx(
// _In_ UINT uFlags,
// _In_ DWORD dwReason);
// WINUSERAPI
// BOOL
// WINAPI
// SwapMouseButton(
// _In_ BOOL fSwap);
// WINUSERAPI
// DWORD
// WINAPI
// GetMessagePos(
// VOID);
// WINUSERAPI
// LONG
// WINAPI
// GetMessageTime(
// VOID);
// WINUSERAPI
// LPARAM
// WINAPI
// GetMessageExtraInfo(
// VOID);
// #if(_WIN32_WINNT >= 0x0602)
// WINUSERAPI
// DWORD
// WINAPI
// GetUnpredictedMessagePos(
// VOID);
// #endif /* _WIN32_WINNT >= 0x0602 */
// #if(_WIN32_WINNT >= 0x0501)
// WINUSERAPI
// BOOL
// WINAPI
// IsWow64Message(
// VOID);
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(WINVER >= 0x0400)
// WINUSERAPI
// LPARAM
// WINAPI
// SetMessageExtraInfo(
// _In_ LPARAM lParam);
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// LRESULT
// WINAPI
// SendMessageA(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _Pre_maybenull_ _Post_valid_ WPARAM wParam,
// _Pre_maybenull_ _Post_valid_ LPARAM lParam);
// WINUSERAPI
// LRESULT
// WINAPI
// SendMessageW(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _Pre_maybenull_ _Post_valid_ WPARAM wParam,
// _Pre_maybenull_ _Post_valid_ LPARAM lParam);
// #ifdef UNICODE
// #define SendMessage SendMessageW
// #else
// #define SendMessage SendMessageA
// #endif // !UNICODE
// #if defined(_M_CEE)
// #undef SendMessage
// __inline
// LRESULT
// SendMessage(
// HWND hWnd,
// UINT Msg,
// WPARAM wParam,
// LPARAM lParam
// )
// {
// #ifdef UNICODE
// return SendMessageW(
// #else
// return SendMessageA(
// #endif
// hWnd,
// Msg,
// wParam,
// lParam
// );
// }
// #endif /* _M_CEE */
// WINUSERAPI
// LRESULT
// WINAPI
// SendMessageTimeoutA(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam,
// _In_ UINT fuFlags,
// _In_ UINT uTimeout,
// _Out_opt_ PDWORD_PTR lpdwResult);
// WINUSERAPI
// LRESULT
// WINAPI
// SendMessageTimeoutW(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam,
// _In_ UINT fuFlags,
// _In_ UINT uTimeout,
// _Out_opt_ PDWORD_PTR lpdwResult);
// #ifdef UNICODE
// #define SendMessageTimeout SendMessageTimeoutW
// #else
// #define SendMessageTimeout SendMessageTimeoutA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// SendNotifyMessageA(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// BOOL
// WINAPI
// SendNotifyMessageW(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define SendNotifyMessage SendNotifyMessageW
// #else
// #define SendNotifyMessage SendNotifyMessageA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// SendMessageCallbackA(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam,
// _In_ SENDASYNCPROC lpResultCallBack,
// _In_ ULONG_PTR dwData);
// WINUSERAPI
// BOOL
// WINAPI
// SendMessageCallbackW(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam,
// _In_ SENDASYNCPROC lpResultCallBack,
// _In_ ULONG_PTR dwData);
// #ifdef UNICODE
// #define SendMessageCallback SendMessageCallbackW
// #else
// #define SendMessageCallback SendMessageCallbackA
// #endif // !UNICODE
// #if(_WIN32_WINNT >= 0x0501)
// typedef struct {
// UINT cbSize;
// HDESK hdesk;
// HWND hwnd;
// LUID luid;
// } BSMINFO, *PBSMINFO;
// WINUSERAPI
// long
// WINAPI
// BroadcastSystemMessageExA(
// _In_ DWORD flags,
// _Inout_opt_ LPDWORD lpInfo,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam,
// _Out_opt_ PBSMINFO pbsmInfo);
// WINUSERAPI
// long
// WINAPI
// BroadcastSystemMessageExW(
// _In_ DWORD flags,
// _Inout_opt_ LPDWORD lpInfo,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam,
// _Out_opt_ PBSMINFO pbsmInfo);
// #ifdef UNICODE
// #define BroadcastSystemMessageEx BroadcastSystemMessageExW
// #else
// #define BroadcastSystemMessageEx BroadcastSystemMessageExA
// #endif // !UNICODE
// #endif /* _WIN32_WINNT >= 0x0501 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0400)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if defined(_WIN32_WINNT)
// WINUSERAPI
// long
// WINAPI
// BroadcastSystemMessageA(
// _In_ DWORD flags,
// _Inout_opt_ LPDWORD lpInfo,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// long
// WINAPI
// BroadcastSystemMessageW(
// _In_ DWORD flags,
// _Inout_opt_ LPDWORD lpInfo,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define BroadcastSystemMessage BroadcastSystemMessageW
// #else
// #define BroadcastSystemMessage BroadcastSystemMessageA
// #endif // !UNICODE
// #elif defined(_WIN32_WINDOWS)
// // The Win95 version isn't A/W decorated
// WINUSERAPI
// long
// WINAPI
// BroadcastSystemMessage(
// _In_ DWORD flags,
// _Inout_opt_ LPDWORD lpInfo,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #endif
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// //Broadcast Special Message Recipient list
// #define BSM_ALLCOMPONENTS 0x00000000
// #define BSM_VXDS 0x00000001
// #define BSM_NETDRIVER 0x00000002
// #define BSM_INSTALLABLEDRIVERS 0x00000004
// #define BSM_APPLICATIONS 0x00000008
// #define BSM_ALLDESKTOPS 0x00000010
// //Broadcast Special Message Flags
// #define BSF_QUERY 0x00000001
// #define BSF_IGNORECURRENTTASK 0x00000002
// #define BSF_FLUSHDISK 0x00000004
// #define BSF_NOHANG 0x00000008
// #define BSF_POSTMESSAGE 0x00000010
// #define BSF_FORCEIFHUNG 0x00000020
// #define BSF_NOTIMEOUTIFNOTHUNG 0x00000040
// #if(_WIN32_WINNT >= 0x0500)
// #define BSF_ALLOWSFW 0x00000080
// #define BSF_SENDNOTIFYMESSAGE 0x00000100
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0501)
// #define BSF_RETURNHDESK 0x00000200
// #define BSF_LUID 0x00000400
// #endif /* _WIN32_WINNT >= 0x0501 */
// #define BROADCAST_QUERY_DENY 0x424D5144 // Return this value to deny a query.
// #endif /* WINVER >= 0x0400 */
// // RegisterDeviceNotification
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if(WINVER >= 0x0500)
// typedef PVOID HDEVNOTIFY;
// typedef HDEVNOTIFY *PHDEVNOTIFY;
// #define DEVICE_NOTIFY_WINDOW_HANDLE 0x00000000
// #define DEVICE_NOTIFY_SERVICE_HANDLE 0x00000001
// #if(_WIN32_WINNT >= 0x0501)
// #define DEVICE_NOTIFY_ALL_INTERFACE_CLASSES 0x00000004
// #endif /* _WIN32_WINNT >= 0x0501 */
// WINUSERAPI
// HDEVNOTIFY
// WINAPI
// RegisterDeviceNotificationA(
// _In_ HANDLE hRecipient,
// _In_ LPVOID NotificationFilter,
// _In_ DWORD Flags);
// WINUSERAPI
// HDEVNOTIFY
// WINAPI
// RegisterDeviceNotificationW(
// _In_ HANDLE hRecipient,
// _In_ LPVOID NotificationFilter,
// _In_ DWORD Flags);
// #ifdef UNICODE
// #define RegisterDeviceNotification RegisterDeviceNotificationW
// #else
// #define RegisterDeviceNotification RegisterDeviceNotificationA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterDeviceNotification(
// _In_ HDEVNOTIFY Handle
// );
// #if (_WIN32_WINNT >= 0x0502)
// #if !defined(_HPOWERNOTIFY_DEF_)
// #define _HPOWERNOTIFY_DEF_
// typedef PVOID HPOWERNOTIFY;
// typedef HPOWERNOTIFY *PHPOWERNOTIFY;
// #endif
// WINUSERAPI
// HPOWERNOTIFY
// WINAPI
// RegisterPowerSettingNotification(
// IN HANDLE hRecipient,
// IN LPCGUID PowerSettingGuid,
// IN DWORD Flags
// );
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterPowerSettingNotification(
// IN HPOWERNOTIFY Handle
// );
// WINUSERAPI
// HPOWERNOTIFY
// WINAPI
// RegisterSuspendResumeNotification(
// IN HANDLE hRecipient,
// IN DWORD Flags
// );
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterSuspendResumeNotification(
// IN HPOWERNOTIFY Handle
// );
// #endif // (_WIN32_WINNT >= 0x0502)
// #endif /* WINVER >= 0x0500 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// PostMessageA(
// _In_opt_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// BOOL
// WINAPI
// PostMessageW(
// _In_opt_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define PostMessage PostMessageW
// #else
// #define PostMessage PostMessageA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// PostThreadMessageA(
// _In_ DWORD idThread,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// BOOL
// WINAPI
// PostThreadMessageW(
// _In_ DWORD idThread,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define PostThreadMessage PostThreadMessageW
// #else
// #define PostThreadMessage PostThreadMessageA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define PostAppMessageA(idThread, wMsg, wParam, lParam)\
// PostThreadMessageA((DWORD)idThread, wMsg, wParam, lParam)
// #define PostAppMessageW(idThread, wMsg, wParam, lParam)\
// PostThreadMessageW((DWORD)idThread, wMsg, wParam, lParam)
// #ifdef UNICODE
// #define PostAppMessage PostAppMessageW
// #else
// #define PostAppMessage PostAppMessageA
// #endif // !UNICODE
// /*
// * Special HWND value for use with PostMessage() and SendMessage()
// */
// #define HWND_BROADCAST ((HWND)0xffff)
// #if(WINVER >= 0x0500)
// #define HWND_MESSAGE ((HWND)-3)
// #endif /* WINVER >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// AttachThreadInput(
// _In_ DWORD idAttach,
// _In_ DWORD idAttachTo,
// _In_ BOOL fAttach);
// WINUSERAPI
// BOOL
// WINAPI
// ReplyMessage(
// _In_ LRESULT lResult);
// WINUSERAPI
// BOOL
// WINAPI
// WaitMessage(
// VOID);
// #if (_WIN32_WINNT >= 0x602)
// #endif
// WINUSERAPI
// DWORD
// WINAPI
// WaitForInputIdle(
// _In_ HANDLE hProcess,
// _In_ DWORD dwMilliseconds);
// WINUSERAPI
// #ifndef _MAC
// LRESULT
// WINAPI
// #else
// LRESULT
// CALLBACK
// #endif
// DefWindowProcA(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// #ifndef _MAC
// LRESULT
// WINAPI
// #else
// LRESULT
// CALLBACK
// #endif
// DefWindowProcW(
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define DefWindowProc DefWindowProcW
// #else
// #define DefWindowProc DefWindowProcA
// #endif // !UNICODE
// WINUSERAPI
// VOID
// WINAPI
// PostQuitMessage(
// _In_ int nExitCode);
// #ifdef STRICT
// WINUSERAPI
// LRESULT
// WINAPI
// CallWindowProcA(
// _In_ WNDPROC lpPrevWndFunc,
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// LRESULT
// WINAPI
// CallWindowProcW(
// _In_ WNDPROC lpPrevWndFunc,
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define CallWindowProc CallWindowProcW
// #else
// #define CallWindowProc CallWindowProcA
// #endif // !UNICODE
// #else /* !STRICT */
// WINUSERAPI
// LRESULT
// WINAPI
// CallWindowProcA(
// _In_ FARPROC lpPrevWndFunc,
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// LRESULT
// WINAPI
// CallWindowProcW(
// _In_ FARPROC lpPrevWndFunc,
// _In_ HWND hWnd,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define CallWindowProc CallWindowProcW
// #else
// #define CallWindowProc CallWindowProcA
// #endif // !UNICODE
// #endif /* !STRICT */
// WINUSERAPI
// BOOL
// WINAPI
// InSendMessage(
// VOID);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0500)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// DWORD
// WINAPI
// InSendMessageEx(
// _Reserved_ LPVOID lpReserved);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * InSendMessageEx return value
// */
// #define ISMEX_NOSEND 0x00000000
// #define ISMEX_SEND 0x00000001
// #define ISMEX_NOTIFY 0x00000002
// #define ISMEX_CALLBACK 0x00000004
// #define ISMEX_REPLIED 0x00000008
// #endif /* WINVER >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// UINT
// WINAPI
// GetDoubleClickTime(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// SetDoubleClickTime(
// _In_ UINT);
// WINUSERAPI
// ATOM
// WINAPI
// RegisterClassA(
// _In_ CONST WNDCLASSA *lpWndClass);
// WINUSERAPI
// ATOM
// WINAPI
// RegisterClassW(
// _In_ CONST WNDCLASSW *lpWndClass);
// #ifdef UNICODE
// #define RegisterClass RegisterClassW
// #else
// #define RegisterClass RegisterClassA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterClassA(
// _In_ LPCSTR lpClassName,
// _In_opt_ HINSTANCE hInstance);
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterClassW(
// _In_ LPCWSTR lpClassName,
// _In_opt_ HINSTANCE hInstance);
// #ifdef UNICODE
// #define UnregisterClass UnregisterClassW
// #else
// #define UnregisterClass UnregisterClassA
// #endif // !UNICODE
// _Success_(return)
// WINUSERAPI
// BOOL
// WINAPI
// GetClassInfoA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpClassName,
// _Out_ LPWNDCLASSA lpWndClass);
// _Success_(return)
// WINUSERAPI
// BOOL
// WINAPI
// GetClassInfoW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpClassName,
// _Out_ LPWNDCLASSW lpWndClass);
// #ifdef UNICODE
// #define GetClassInfo GetClassInfoW
// #else
// #define GetClassInfo GetClassInfoA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// WINUSERAPI
// ATOM
// WINAPI
// RegisterClassExA(
// _In_ CONST WNDCLASSEXA *);
// WINUSERAPI
// ATOM
// WINAPI
// RegisterClassExW(
// _In_ CONST WNDCLASSEXW *);
// #ifdef UNICODE
// #define RegisterClassEx RegisterClassExW
// #else
// #define RegisterClassEx RegisterClassExA
// #endif // !UNICODE
// _Success_(return)
// WINUSERAPI
// BOOL
// WINAPI
// GetClassInfoExA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpszClass,
// _Out_ LPWNDCLASSEXA lpwcx);
// _Success_(return)
// WINUSERAPI
// BOOL
// WINAPI
// GetClassInfoExW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpszClass,
// _Out_ LPWNDCLASSEXW lpwcx);
// #ifdef UNICODE
// #define GetClassInfoEx GetClassInfoExW
// #else
// #define GetClassInfoEx GetClassInfoExA
// #endif // !UNICODE
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define CW_USEDEFAULT ((int)0x80000000)
// /*
// * Special value for CreateWindow, et al.
// */
// #define HWND_DESKTOP ((HWND)0)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if(_WIN32_WINNT >= 0x0501)
// typedef BOOLEAN(WINAPI * PREGISTERCLASSNAMEW)(LPCWSTR);
// #endif /* _WIN32_WINNT >= 0x0501 */
// WINUSERAPI
// HWND
// WINAPI
// CreateWindowExA(
// _In_ DWORD dwExStyle,
// _In_opt_ LPCSTR lpClassName,
// _In_opt_ LPCSTR lpWindowName,
// _In_ DWORD dwStyle,
// _In_ int X,
// _In_ int Y,
// _In_ int nWidth,
// _In_ int nHeight,
// _In_opt_ HWND hWndParent,
// _In_opt_ HMENU hMenu,
// _In_opt_ HINSTANCE hInstance,
// _In_opt_ LPVOID lpParam);
// WINUSERAPI
// HWND
// WINAPI
// CreateWindowExW(
// _In_ DWORD dwExStyle,
// _In_opt_ LPCWSTR lpClassName,
// _In_opt_ LPCWSTR lpWindowName,
// _In_ DWORD dwStyle,
// _In_ int X,
// _In_ int Y,
// _In_ int nWidth,
// _In_ int nHeight,
// _In_opt_ HWND hWndParent,
// _In_opt_ HMENU hMenu,
// _In_opt_ HINSTANCE hInstance,
// _In_opt_ LPVOID lpParam);
// #ifdef UNICODE
// #define CreateWindowEx CreateWindowExW
// #else
// #define CreateWindowEx CreateWindowExA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y,\
// nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
// CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y,\
// nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
// #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y,\
// nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
// CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y,\
// nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
// #ifdef UNICODE
// #define CreateWindow CreateWindowW
// #else
// #define CreateWindow CreateWindowA
// #endif // !UNICODE
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// IsWindow(
// _In_opt_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// IsMenu(
// _In_ HMENU hMenu);
// WINUSERAPI
// BOOL
// WINAPI
// IsChild(
// _In_ HWND hWndParent,
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// DestroyWindow(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// ShowWindow(
// _In_ HWND hWnd,
// _In_ int nCmdShow);
// #if(WINVER >= 0x0500)
// WINUSERAPI
// BOOL
// WINAPI
// AnimateWindow(
// _In_ HWND hWnd,
// _In_ DWORD dwTime,
// _In_ DWORD dwFlags);
// #endif /* WINVER >= 0x0500 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(_WIN32_WINNT >= 0x0500)
// #if defined(_WINGDI_) && !defined(NOGDI)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// UpdateLayeredWindow(
// _In_ HWND hWnd,
// _In_opt_ HDC hdcDst,
// _In_opt_ POINT* pptDst,
// _In_opt_ SIZE* psize,
// _In_opt_ HDC hdcSrc,
// _In_opt_ POINT* pptSrc,
// _In_ COLORREF crKey,
// _In_opt_ BLENDFUNCTION* pblend,
// _In_ DWORD dwFlags);
// /*
// * Layered Window Update information
// */
// typedef struct tagUPDATELAYEREDWINDOWINFO
// {
// DWORD cbSize;
// HDC hdcDst;
// const POINT* pptDst;
// const SIZE* psize;
// HDC hdcSrc;
// const POINT* pptSrc;
// COLORREF crKey;
// const BLENDFUNCTION* pblend;
// DWORD dwFlags;
// const RECT* prcDirty;
// } UPDATELAYEREDWINDOWINFO, *PUPDATELAYEREDWINDOWINFO;
// #if (_WIN32_WINNT < 0x0502)
// typedef
// #endif /* _WIN32_WINNT < 0x0502 */
// WINUSERAPI
// BOOL
// WINAPI
// UpdateLayeredWindowIndirect(
// _In_ HWND hWnd,
// _In_ const UPDATELAYEREDWINDOWINFO* pULWInfo);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif
// #if(_WIN32_WINNT >= 0x0501)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// GetLayeredWindowAttributes(
// _In_ HWND hwnd,
// _Out_opt_ COLORREF* pcrKey,
// _Out_opt_ BYTE* pbAlpha,
// _Out_opt_ DWORD* pdwFlags);
// #define PW_CLIENTONLY 0x00000001
// #if(_WIN32_WINNT >= 0x0603)
// #define PW_RENDERFULLCONTENT 0x00000002
// #endif /* _WIN32_WINNT >= 0x0603 */
// WINUSERAPI
// BOOL
// WINAPI
// PrintWindow(
// _In_ HWND hwnd,
// _In_ HDC hdcBlt,
// _In_ UINT nFlags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* _WIN32_WINNT >= 0x0501 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// SetLayeredWindowAttributes(
// _In_ HWND hwnd,
// _In_ COLORREF crKey,
// _In_ BYTE bAlpha,
// _In_ DWORD dwFlags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define LWA_COLORKEY 0x00000001
// #define LWA_ALPHA 0x00000002
// #define ULW_COLORKEY 0x00000001
// #define ULW_ALPHA 0x00000002
// #define ULW_OPAQUE 0x00000004
// #define ULW_EX_NORESIZE 0x00000008
// #endif /* _WIN32_WINNT >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if(WINVER >= 0x0400)
// WINUSERAPI
// BOOL
// WINAPI
// ShowWindowAsync(
// _In_ HWND hWnd,
// _In_ int nCmdShow);
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// BOOL
// WINAPI
// FlashWindow(
// _In_ HWND hWnd,
// _In_ BOOL bInvert);
// #if(WINVER >= 0x0500)
// typedef struct {
// UINT cbSize;
// HWND hwnd;
// DWORD dwFlags;
// UINT uCount;
// DWORD dwTimeout;
// } FLASHWINFO, *PFLASHWINFO;
// WINUSERAPI
// BOOL
// WINAPI
// FlashWindowEx(
// _In_ PFLASHWINFO pfwi);
// #define FLASHW_STOP 0
// #define FLASHW_CAPTION 0x00000001
// #define FLASHW_TRAY 0x00000002
// #define FLASHW_ALL (FLASHW_CAPTION | FLASHW_TRAY)
// #define FLASHW_TIMER 0x00000004
// #define FLASHW_TIMERNOFG 0x0000000C
// #endif /* WINVER >= 0x0500 */
// WINUSERAPI
// BOOL
// WINAPI
// ShowOwnedPopups(
// _In_ HWND hWnd,
// _In_ BOOL fShow);
// WINUSERAPI
// BOOL
// WINAPI
// OpenIcon(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// CloseWindow(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// MoveWindow(
// _In_ HWND hWnd,
// _In_ int X,
// _In_ int Y,
// _In_ int nWidth,
// _In_ int nHeight,
// _In_ BOOL bRepaint);
// WINUSERAPI
// BOOL
// WINAPI
// SetWindowPos(
// _In_ HWND hWnd,
// _In_opt_ HWND hWndInsertAfter,
// _In_ int X,
// _In_ int Y,
// _In_ int cx,
// _In_ int cy,
// _In_ UINT uFlags);
// WINUSERAPI
// BOOL
// WINAPI
// GetWindowPlacement(
// _In_ HWND hWnd,
// _Inout_ WINDOWPLACEMENT *lpwndpl);
// WINUSERAPI
// BOOL
// WINAPI
// SetWindowPlacement(
// _In_ HWND hWnd,
// _In_ CONST WINDOWPLACEMENT *lpwndpl);
// #if(_WIN32_WINNT >= 0x0601)
// #define WDA_NONE 0x00000000
// #define WDA_MONITOR 0x00000001
// WINUSERAPI
// BOOL
// WINAPI
// GetWindowDisplayAffinity(
// _In_ HWND hWnd,
// _Out_ DWORD* pdwAffinity);
// WINUSERAPI
// BOOL
// WINAPI
// SetWindowDisplayAffinity(
// _In_ HWND hWnd,
// _In_ DWORD dwAffinity);
// #endif /* _WIN32_WINNT >= 0x0601 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NODEFERWINDOWPOS
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HDWP
// WINAPI
// BeginDeferWindowPos(
// _In_ int nNumWindows);
// WINUSERAPI
// HDWP
// WINAPI
// DeferWindowPos(
// _In_ HDWP hWinPosInfo,
// _In_ HWND hWnd,
// _In_opt_ HWND hWndInsertAfter,
// _In_ int x,
// _In_ int y,
// _In_ int cx,
// _In_ int cy,
// _In_ UINT uFlags);
// WINUSERAPI
// BOOL
// WINAPI
// EndDeferWindowPos(
// _In_ HDWP hWinPosInfo);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NODEFERWINDOWPOS */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// IsWindowVisible(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// IsIconic(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// AnyPopup(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// BringWindowToTop(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// IsZoomed(
// _In_ HWND hWnd);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * SetWindowPos Flags
// */
// #define SWP_NOSIZE 0x0001
// #define SWP_NOMOVE 0x0002
// #define SWP_NOZORDER 0x0004
// #define SWP_NOREDRAW 0x0008
// #define SWP_NOACTIVATE 0x0010
// #define SWP_FRAMECHANGED 0x0020 /* The frame changed: send WM_NCCALCSIZE */
// #define SWP_SHOWWINDOW 0x0040
// #define SWP_HIDEWINDOW 0x0080
// #define SWP_NOCOPYBITS 0x0100
// #define SWP_NOOWNERZORDER 0x0200 /* Don't do owner Z ordering */
// #define SWP_NOSENDCHANGING 0x0400 /* Don't send WM_WINDOWPOSCHANGING */
// #define SWP_DRAWFRAME SWP_FRAMECHANGED
// #define SWP_NOREPOSITION SWP_NOOWNERZORDER
// #if(WINVER >= 0x0400)
// #define SWP_DEFERERASE 0x2000
// #define SWP_ASYNCWINDOWPOS 0x4000
// #endif /* WINVER >= 0x0400 */
// #define HWND_TOP ((HWND)0)
// #define HWND_BOTTOM ((HWND)1)
// #define HWND_TOPMOST ((HWND)-1)
// #define HWND_NOTOPMOST ((HWND)-2)
// #ifndef NOCTLMGR
// /*
// * WARNING:
// * The following structures must NOT be DWORD padded because they are
// * followed by strings, etc that do not have to be DWORD aligned.
// */
// #include <pshpack2.h>
// #pragma region Application Family or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
// /*
// * original NT 32 bit dialog template:
// */
// typedef struct {
// DWORD style;
// DWORD dwExtendedStyle;
// WORD cdit;
// short x;
// short y;
// short cx;
// short cy;
// } DLGTEMPLATE;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef DLGTEMPLATE *LPDLGTEMPLATEA;
// typedef DLGTEMPLATE *LPDLGTEMPLATEW;
// #ifdef UNICODE
// typedef LPDLGTEMPLATEW LPDLGTEMPLATE;
// #else
// typedef LPDLGTEMPLATEA LPDLGTEMPLATE;
// #endif // UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Application Family or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
// typedef CONST DLGTEMPLATE *LPCDLGTEMPLATEA;
// typedef CONST DLGTEMPLATE *LPCDLGTEMPLATEW;
// #ifdef UNICODE
// typedef LPCDLGTEMPLATEW LPCDLGTEMPLATE;
// #else
// typedef LPCDLGTEMPLATEA LPCDLGTEMPLATE;
// #endif // UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * 32 bit Dialog item template.
// */
// typedef struct {
// DWORD style;
// DWORD dwExtendedStyle;
// short x;
// short y;
// short cx;
// short cy;
// WORD id;
// } DLGITEMTEMPLATE;
// typedef DLGITEMTEMPLATE *PDLGITEMTEMPLATEA;
// typedef DLGITEMTEMPLATE *PDLGITEMTEMPLATEW;
// #ifdef UNICODE
// typedef PDLGITEMTEMPLATEW PDLGITEMTEMPLATE;
// #else
// typedef PDLGITEMTEMPLATEA PDLGITEMTEMPLATE;
// #endif // UNICODE
// typedef DLGITEMTEMPLATE *LPDLGITEMTEMPLATEA;
// typedef DLGITEMTEMPLATE *LPDLGITEMTEMPLATEW;
// #ifdef UNICODE
// typedef LPDLGITEMTEMPLATEW LPDLGITEMTEMPLATE;
// #else
// typedef LPDLGITEMTEMPLATEA LPDLGITEMTEMPLATE;
// #endif // UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #include <poppack.h> /* Resume normal packing */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HWND
// WINAPI
// CreateDialogParamA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpTemplateName,
// _In_opt_ HWND hWndParent,
// _In_opt_ DLGPROC lpDialogFunc,
// _In_ LPARAM dwInitParam);
// WINUSERAPI
// HWND
// WINAPI
// CreateDialogParamW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpTemplateName,
// _In_opt_ HWND hWndParent,
// _In_opt_ DLGPROC lpDialogFunc,
// _In_ LPARAM dwInitParam);
// #ifdef UNICODE
// #define CreateDialogParam CreateDialogParamW
// #else
// #define CreateDialogParam CreateDialogParamA
// #endif // !UNICODE
// WINUSERAPI
// HWND
// WINAPI
// CreateDialogIndirectParamA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCDLGTEMPLATEA lpTemplate,
// _In_opt_ HWND hWndParent,
// _In_opt_ DLGPROC lpDialogFunc,
// _In_ LPARAM dwInitParam);
// WINUSERAPI
// HWND
// WINAPI
// CreateDialogIndirectParamW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCDLGTEMPLATEW lpTemplate,
// _In_opt_ HWND hWndParent,
// _In_opt_ DLGPROC lpDialogFunc,
// _In_ LPARAM dwInitParam);
// #ifdef UNICODE
// #define CreateDialogIndirectParam CreateDialogIndirectParamW
// #else
// #define CreateDialogIndirectParam CreateDialogIndirectParamA
// #endif // !UNICODE
// #define CreateDialogA(hInstance, lpName, hWndParent, lpDialogFunc) \
// CreateDialogParamA(hInstance, lpName, hWndParent, lpDialogFunc, 0L)
// #define CreateDialogW(hInstance, lpName, hWndParent, lpDialogFunc) \
// CreateDialogParamW(hInstance, lpName, hWndParent, lpDialogFunc, 0L)
// #ifdef UNICODE
// #define CreateDialog CreateDialogW
// #else
// #define CreateDialog CreateDialogA
// #endif // !UNICODE
// #define CreateDialogIndirectA(hInstance, lpTemplate, hWndParent, lpDialogFunc) \
// CreateDialogIndirectParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
// #define CreateDialogIndirectW(hInstance, lpTemplate, hWndParent, lpDialogFunc) \
// CreateDialogIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
// #ifdef UNICODE
// #define CreateDialogIndirect CreateDialogIndirectW
// #else
// #define CreateDialogIndirect CreateDialogIndirectA
// #endif // !UNICODE
// WINUSERAPI
// INT_PTR
// WINAPI
// DialogBoxParamA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpTemplateName,
// _In_opt_ HWND hWndParent,
// _In_opt_ DLGPROC lpDialogFunc,
// _In_ LPARAM dwInitParam);
// WINUSERAPI
// INT_PTR
// WINAPI
// DialogBoxParamW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpTemplateName,
// _In_opt_ HWND hWndParent,
// _In_opt_ DLGPROC lpDialogFunc,
// _In_ LPARAM dwInitParam);
// #ifdef UNICODE
// #define DialogBoxParam DialogBoxParamW
// #else
// #define DialogBoxParam DialogBoxParamA
// #endif // !UNICODE
// WINUSERAPI
// INT_PTR
// WINAPI
// DialogBoxIndirectParamA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCDLGTEMPLATEA hDialogTemplate,
// _In_opt_ HWND hWndParent,
// _In_opt_ DLGPROC lpDialogFunc,
// _In_ LPARAM dwInitParam);
// WINUSERAPI
// INT_PTR
// WINAPI
// DialogBoxIndirectParamW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCDLGTEMPLATEW hDialogTemplate,
// _In_opt_ HWND hWndParent,
// _In_opt_ DLGPROC lpDialogFunc,
// _In_ LPARAM dwInitParam);
// #ifdef UNICODE
// #define DialogBoxIndirectParam DialogBoxIndirectParamW
// #else
// #define DialogBoxIndirectParam DialogBoxIndirectParamA
// #endif // !UNICODE
// #define DialogBoxA(hInstance, lpTemplate, hWndParent, lpDialogFunc) \
// DialogBoxParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
// #define DialogBoxW(hInstance, lpTemplate, hWndParent, lpDialogFunc) \
// DialogBoxParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
// #ifdef UNICODE
// #define DialogBox DialogBoxW
// #else
// #define DialogBox DialogBoxA
// #endif // !UNICODE
// #define DialogBoxIndirectA(hInstance, lpTemplate, hWndParent, lpDialogFunc) \
// DialogBoxIndirectParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
// #define DialogBoxIndirectW(hInstance, lpTemplate, hWndParent, lpDialogFunc) \
// DialogBoxIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
// #ifdef UNICODE
// #define DialogBoxIndirect DialogBoxIndirectW
// #else
// #define DialogBoxIndirect DialogBoxIndirectA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// EndDialog(
// _In_ HWND hDlg,
// _In_ INT_PTR nResult);
// WINUSERAPI
// HWND
// WINAPI
// GetDlgItem(
// _In_opt_ HWND hDlg,
// _In_ int nIDDlgItem);
// WINUSERAPI
// BOOL
// WINAPI
// SetDlgItemInt(
// _In_ HWND hDlg,
// _In_ int nIDDlgItem,
// _In_ UINT uValue,
// _In_ BOOL bSigned);
// WINUSERAPI
// UINT
// WINAPI
// GetDlgItemInt(
// _In_ HWND hDlg,
// _In_ int nIDDlgItem,
// _Out_opt_ BOOL *lpTranslated,
// _In_ BOOL bSigned);
// WINUSERAPI
// BOOL
// WINAPI
// SetDlgItemTextA(
// _In_ HWND hDlg,
// _In_ int nIDDlgItem,
// _In_ LPCSTR lpString);
// WINUSERAPI
// BOOL
// WINAPI
// SetDlgItemTextW(
// _In_ HWND hDlg,
// _In_ int nIDDlgItem,
// _In_ LPCWSTR lpString);
// #ifdef UNICODE
// #define SetDlgItemText SetDlgItemTextW
// #else
// #define SetDlgItemText SetDlgItemTextA
// #endif // !UNICODE
// _Ret_range_(0, cchMax)
// WINUSERAPI
// UINT
// WINAPI
// GetDlgItemTextA(
// _In_ HWND hDlg,
// _In_ int nIDDlgItem,
// _Out_writes_(cchMax) LPSTR lpString,
// _In_ int cchMax);
// _Ret_range_(0, cchMax)
// WINUSERAPI
// UINT
// WINAPI
// GetDlgItemTextW(
// _In_ HWND hDlg,
// _In_ int nIDDlgItem,
// _Out_writes_(cchMax) LPWSTR lpString,
// _In_ int cchMax);
// #ifdef UNICODE
// #define GetDlgItemText GetDlgItemTextW
// #else
// #define GetDlgItemText GetDlgItemTextA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// CheckDlgButton(
// _In_ HWND hDlg,
// _In_ int nIDButton,
// _In_ UINT uCheck);
// WINUSERAPI
// BOOL
// WINAPI
// CheckRadioButton(
// _In_ HWND hDlg,
// _In_ int nIDFirstButton,
// _In_ int nIDLastButton,
// _In_ int nIDCheckButton);
// WINUSERAPI
// UINT
// WINAPI
// IsDlgButtonChecked(
// _In_ HWND hDlg,
// _In_ int nIDButton);
// WINUSERAPI
// LRESULT
// WINAPI
// SendDlgItemMessageA(
// _In_ HWND hDlg,
// _In_ int nIDDlgItem,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// LRESULT
// WINAPI
// SendDlgItemMessageW(
// _In_ HWND hDlg,
// _In_ int nIDDlgItem,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define SendDlgItemMessage SendDlgItemMessageW
// #else
// #define SendDlgItemMessage SendDlgItemMessageA
// #endif // !UNICODE
// WINUSERAPI
// HWND
// WINAPI
// GetNextDlgGroupItem(
// _In_ HWND hDlg,
// _In_opt_ HWND hCtl,
// _In_ BOOL bPrevious);
// WINUSERAPI
// HWND
// WINAPI
// GetNextDlgTabItem(
// _In_ HWND hDlg,
// _In_opt_ HWND hCtl,
// _In_ BOOL bPrevious);
// WINUSERAPI
// int
// WINAPI
// GetDlgCtrlID(
// _In_ HWND hWnd);
// WINUSERAPI
// long
// WINAPI
// GetDialogBaseUnits(VOID);
// WINUSERAPI
// #ifndef _MAC
// LRESULT
// WINAPI
// #else
// LRESULT
// CALLBACK
// #endif
// DefDlgProcA(
// _In_ HWND hDlg,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// #ifndef _MAC
// LRESULT
// WINAPI
// #else
// LRESULT
// CALLBACK
// #endif
// DefDlgProcW(
// _In_ HWND hDlg,
// _In_ UINT Msg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define DefDlgProc DefDlgProcW
// #else
// #define DefDlgProc DefDlgProcA
// #endif // !UNICODE
// typedef enum DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS {
// DCDC_DEFAULT = 0x0000,
// DCDC_DISABLE_FONT_UPDATE = 0x0001,
// DCDC_DISABLE_RELAYOUT = 0x0002,
// } DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS;
// #ifndef MIDL_PASS
// DEFINE_ENUM_FLAG_OPERATORS(DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS);
// #endif
// BOOL
// WINAPI
// SetDialogControlDpiChangeBehavior(
// _In_ HWND hWnd,
// _In_ DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS mask,
// _In_ DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS values);
// DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS
// WINAPI
// GetDialogControlDpiChangeBehavior(
// _In_ HWND hWnd);
// typedef enum DIALOG_DPI_CHANGE_BEHAVIORS {
// DDC_DEFAULT = 0x0000,
// DDC_DISABLE_ALL = 0x0001,
// DDC_DISABLE_RESIZE = 0x0002,
// DDC_DISABLE_CONTROL_RELAYOUT = 0x0004,
// } DIALOG_DPI_CHANGE_BEHAVIORS;
// #ifndef MIDL_PASS
// DEFINE_ENUM_FLAG_OPERATORS(DIALOG_DPI_CHANGE_BEHAVIORS);
// #endif
// BOOL
// WINAPI
// SetDialogDpiChangeBehavior(
// _In_ HWND hDlg,
// _In_ DIALOG_DPI_CHANGE_BEHAVIORS mask,
// _In_ DIALOG_DPI_CHANGE_BEHAVIORS values);
// DIALOG_DPI_CHANGE_BEHAVIORS
// WINAPI
// GetDialogDpiChangeBehavior(
// _In_ HWND hDlg);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Window extra byted needed for private dialog classes.
// */
// #ifndef _MAC
// #define DLGWINDOWEXTRA 30
// #else
// #define DLGWINDOWEXTRA 48
// #endif
// #endif /* !NOCTLMGR */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #ifndef NOMSG
// WINUSERAPI
// BOOL
// WINAPI
// CallMsgFilterA(
// _In_ LPMSG lpMsg,
// _In_ int nCode);
// WINUSERAPI
// BOOL
// WINAPI
// CallMsgFilterW(
// _In_ LPMSG lpMsg,
// _In_ int nCode);
// #ifdef UNICODE
// #define CallMsgFilter CallMsgFilterW
// #else
// #define CallMsgFilter CallMsgFilterA
// #endif // !UNICODE
// #endif /* !NOMSG */
// #ifndef NOCLIPBOARD
// /*
// * Clipboard Manager Functions
// */
// WINUSERAPI
// BOOL
// WINAPI
// OpenClipboard(
// _In_opt_ HWND hWndNewOwner);
// WINUSERAPI
// BOOL
// WINAPI
// CloseClipboard(
// VOID);
// #if(WINVER >= 0x0500)
// WINUSERAPI
// DWORD
// WINAPI
// GetClipboardSequenceNumber(
// VOID);
// #endif /* WINVER >= 0x0500 */
// WINUSERAPI
// HWND
// WINAPI
// GetClipboardOwner(
// VOID);
// WINUSERAPI
// HWND
// WINAPI
// SetClipboardViewer(
// _In_ HWND hWndNewViewer);
// WINUSERAPI
// HWND
// WINAPI
// GetClipboardViewer(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// ChangeClipboardChain(
// _In_ HWND hWndRemove,
// _In_ HWND hWndNewNext);
// WINUSERAPI
// HANDLE
// WINAPI
// SetClipboardData(
// _In_ UINT uFormat,
// _In_opt_ HANDLE hMem);
// WINUSERAPI
// HANDLE
// WINAPI
// GetClipboardData(
// _In_ UINT uFormat);
// WINUSERAPI
// UINT
// WINAPI
// RegisterClipboardFormatA(
// _In_ LPCSTR lpszFormat);
// WINUSERAPI
// UINT
// WINAPI
// RegisterClipboardFormatW(
// _In_ LPCWSTR lpszFormat);
// #ifdef UNICODE
// #define RegisterClipboardFormat RegisterClipboardFormatW
// #else
// #define RegisterClipboardFormat RegisterClipboardFormatA
// #endif // !UNICODE
// WINUSERAPI
// int
// WINAPI
// CountClipboardFormats(
// VOID);
// WINUSERAPI
// UINT
// WINAPI
// EnumClipboardFormats(
// _In_ UINT format);
// WINUSERAPI
// int
// WINAPI
// GetClipboardFormatNameA(
// _In_ UINT format,
// _Out_writes_(cchMaxCount) LPSTR lpszFormatName,
// _In_ int cchMaxCount);
// WINUSERAPI
// int
// WINAPI
// GetClipboardFormatNameW(
// _In_ UINT format,
// _Out_writes_(cchMaxCount) LPWSTR lpszFormatName,
// _In_ int cchMaxCount);
// #ifdef UNICODE
// #define GetClipboardFormatName GetClipboardFormatNameW
// #else
// #define GetClipboardFormatName GetClipboardFormatNameA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// EmptyClipboard(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// IsClipboardFormatAvailable(
// _In_ UINT format);
// WINUSERAPI
// int
// WINAPI
// GetPriorityClipboardFormat(
// _In_reads_(cFormats) UINT *paFormatPriorityList,
// _In_ int cFormats);
// WINUSERAPI
// HWND
// WINAPI
// GetOpenClipboardWindow(
// VOID);
// #if(WINVER >= 0x0600)
// WINUSERAPI
// BOOL
// WINAPI
// AddClipboardFormatListener(
// _In_ HWND hwnd);
// WINUSERAPI
// BOOL
// WINAPI
// RemoveClipboardFormatListener(
// _In_ HWND hwnd);
// WINUSERAPI
// BOOL
// WINAPI
// GetUpdatedClipboardFormats(
// _Out_writes_(cFormats) PUINT lpuiFormats,
// _In_ UINT cFormats,
// _Out_ PUINT pcFormatsOut);
// #endif /* WINVER >= 0x0600 */
// #endif /* !NOCLIPBOARD */
// /*
// * Character Translation Routines
// */
// WINUSERAPI
// BOOL
// WINAPI
// CharToOemA(
// _In_ LPCSTR pSrc,
// _Out_writes_(_Inexpressible_(strlen(pSrc) + 1)) LPSTR pDst);
// WINUSERAPI
// BOOL
// WINAPI
// CharToOemW(
// _In_ LPCWSTR pSrc,
// _Out_writes_(_Inexpressible_(strlen(pSrc) + 1)) LPSTR pDst);
// #ifdef UNICODE
// #define CharToOem CharToOemW
// #else
// #define CharToOem CharToOemA
// #endif // !UNICODE
// __drv_preferredFunction("OemToCharBuff", "Does not validate buffer size")
// WINUSERAPI
// BOOL
// WINAPI
// OemToCharA(
// _In_ LPCSTR pSrc,
// _Out_writes_(_Inexpressible_(strlen(pSrc) + 1)) LPSTR pDst);
// __drv_preferredFunction("OemToCharBuff", "Does not validate buffer size")
// WINUSERAPI
// BOOL
// WINAPI
// OemToCharW(
// _In_ LPCSTR pSrc,
// _Out_writes_(_Inexpressible_(strlen(pSrc) + 1)) LPWSTR pDst);
// #ifdef UNICODE
// #define OemToChar OemToCharW
// #else
// #define OemToChar OemToCharA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// CharToOemBuffA(
// _In_ LPCSTR lpszSrc,
// _Out_writes_(cchDstLength) LPSTR lpszDst,
// _In_ DWORD cchDstLength);
// WINUSERAPI
// BOOL
// WINAPI
// CharToOemBuffW(
// _In_ LPCWSTR lpszSrc,
// _Out_writes_(cchDstLength) LPSTR lpszDst,
// _In_ DWORD cchDstLength);
// #ifdef UNICODE
// #define CharToOemBuff CharToOemBuffW
// #else
// #define CharToOemBuff CharToOemBuffA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// OemToCharBuffA(
// _In_ LPCSTR lpszSrc,
// _Out_writes_(cchDstLength) LPSTR lpszDst,
// _In_ DWORD cchDstLength);
// WINUSERAPI
// BOOL
// WINAPI
// OemToCharBuffW(
// _In_ LPCSTR lpszSrc,
// _Out_writes_(cchDstLength) LPWSTR lpszDst,
// _In_ DWORD cchDstLength);
// #ifdef UNICODE
// #define OemToCharBuff OemToCharBuffW
// #else
// #define OemToCharBuff OemToCharBuffA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Desktop Family or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
// WINUSERAPI
// LPSTR
// WINAPI
// CharUpperA(
// _Inout_ LPSTR lpsz);
// WINUSERAPI
// LPWSTR
// WINAPI
// CharUpperW(
// _Inout_ LPWSTR lpsz);
// #ifdef UNICODE
// #define CharUpper CharUpperW
// #else
// #define CharUpper CharUpperA
// #endif // !UNICODE
// WINUSERAPI
// DWORD
// WINAPI
// CharUpperBuffA(
// _Inout_updates_(cchLength) LPSTR lpsz,
// _In_ DWORD cchLength);
// WINUSERAPI
// DWORD
// WINAPI
// CharUpperBuffW(
// _Inout_updates_(cchLength) LPWSTR lpsz,
// _In_ DWORD cchLength);
// #ifdef UNICODE
// #define CharUpperBuff CharUpperBuffW
// #else
// #define CharUpperBuff CharUpperBuffA
// #endif // !UNICODE
// WINUSERAPI
// LPSTR
// WINAPI
// CharLowerA(
// _Inout_ LPSTR lpsz);
// WINUSERAPI
// LPWSTR
// WINAPI
// CharLowerW(
// _Inout_ LPWSTR lpsz);
// #ifdef UNICODE
// #define CharLower CharLowerW
// #else
// #define CharLower CharLowerA
// #endif // !UNICODE
// WINUSERAPI
// DWORD
// WINAPI
// CharLowerBuffA(
// _Inout_updates_(cchLength) LPSTR lpsz,
// _In_ DWORD cchLength);
// WINUSERAPI
// DWORD
// WINAPI
// CharLowerBuffW(
// _Inout_updates_(cchLength) LPWSTR lpsz,
// _In_ DWORD cchLength);
// #ifdef UNICODE
// #define CharLowerBuff CharLowerBuffW
// #else
// #define CharLowerBuff CharLowerBuffA
// #endif // !UNICODE
// WINUSERAPI
// LPSTR
// WINAPI
// CharNextA(
// _In_ LPCSTR lpsz);
// WINUSERAPI
// LPWSTR
// WINAPI
// CharNextW(
// _In_ LPCWSTR lpsz);
// #ifdef UNICODE
// #define CharNext CharNextW
// #else
// #define CharNext CharNextA
// #endif // !UNICODE
// WINUSERAPI
// LPSTR
// WINAPI
// CharPrevA(
// _In_ LPCSTR lpszStart,
// _In_ LPCSTR lpszCurrent);
// WINUSERAPI
// LPWSTR
// WINAPI
// CharPrevW(
// _In_ LPCWSTR lpszStart,
// _In_ LPCWSTR lpszCurrent);
// #ifdef UNICODE
// #define CharPrev CharPrevW
// #else
// #define CharPrev CharPrevA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// WINUSERAPI
// LPSTR
// WINAPI
// CharNextExA(
// _In_ WORD CodePage,
// _In_ LPCSTR lpCurrentChar,
// _In_ DWORD dwFlags);
// WINUSERAPI
// LPSTR
// WINAPI
// CharPrevExA(
// _In_ WORD CodePage,
// _In_ LPCSTR lpStart,
// _In_ LPCSTR lpCurrentChar,
// _In_ DWORD dwFlags);
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// /*
// * Compatibility defines for character translation routines
// */
// #define AnsiToOem CharToOemA
// #define OemToAnsi OemToCharA
// #define AnsiToOemBuff CharToOemBuffA
// #define OemToAnsiBuff OemToCharBuffA
// #define AnsiUpper CharUpperA
// #define AnsiUpperBuff CharUpperBuffA
// #define AnsiLower CharLowerA
// #define AnsiLowerBuff CharLowerBuffA
// #define AnsiNext CharNextA
// #define AnsiPrev CharPrevA
// #pragma region Desktop or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
// #ifndef NOLANGUAGE
// /*
// * Language dependent Routines
// */
// WINUSERAPI
// BOOL
// WINAPI
// IsCharAlphaA(
// _In_ CHAR ch);
// WINUSERAPI
// BOOL
// WINAPI
// IsCharAlphaW(
// _In_ WCHAR ch);
// #ifdef UNICODE
// #define IsCharAlpha IsCharAlphaW
// #else
// #define IsCharAlpha IsCharAlphaA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// IsCharAlphaNumericA(
// _In_ CHAR ch);
// WINUSERAPI
// BOOL
// WINAPI
// IsCharAlphaNumericW(
// _In_ WCHAR ch);
// #ifdef UNICODE
// #define IsCharAlphaNumeric IsCharAlphaNumericW
// #else
// #define IsCharAlphaNumeric IsCharAlphaNumericA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// IsCharUpperA(
// _In_ CHAR ch);
// WINUSERAPI
// BOOL
// WINAPI
// IsCharUpperW(
// _In_ WCHAR ch);
// #ifdef UNICODE
// #define IsCharUpper IsCharUpperW
// #else
// #define IsCharUpper IsCharUpperA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// IsCharLowerA(
// _In_ CHAR ch);
// WINUSERAPI
// BOOL
// WINAPI
// IsCharLowerW(
// _In_ WCHAR ch);
// #ifdef UNICODE
// #define IsCharLower IsCharLowerW
// #else
// #define IsCharLower IsCharLowerA
// #endif // !UNICODE
// #endif /* !NOLANGUAGE */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HWND
// WINAPI
// SetFocus(
// _In_opt_ HWND hWnd);
// WINUSERAPI
// HWND
// WINAPI
// GetActiveWindow(
// VOID);
// WINUSERAPI
// HWND
// WINAPI
// GetFocus(
// VOID);
// WINUSERAPI
// UINT
// WINAPI
// GetKBCodePage(
// VOID);
// WINUSERAPI
// SHORT
// WINAPI
// GetKeyState(
// _In_ int nVirtKey);
// WINUSERAPI
// SHORT
// WINAPI
// GetAsyncKeyState(
// _In_ int vKey);
// WINUSERAPI
// _Check_return_
// BOOL
// WINAPI
// GetKeyboardState(
// _Out_writes_(256) PBYTE lpKeyState);
// WINUSERAPI
// BOOL
// WINAPI
// SetKeyboardState(
// _In_reads_(256) LPBYTE lpKeyState);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Desktop or PC Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP)
// WINUSERAPI
// int
// WINAPI
// GetKeyNameTextA(
// _In_ LONG lParam,
// _Out_writes_(cchSize) LPSTR lpString,
// _In_ int cchSize);
// WINUSERAPI
// int
// WINAPI
// GetKeyNameTextW(
// _In_ LONG lParam,
// _Out_writes_(cchSize) LPWSTR lpString,
// _In_ int cchSize);
// #ifdef UNICODE
// #define GetKeyNameText GetKeyNameTextW
// #else
// #define GetKeyNameText GetKeyNameTextA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// int
// WINAPI
// GetKeyboardType(
// _In_ int nTypeFlag);
// WINUSERAPI
// int
// WINAPI
// ToAscii(
// _In_ UINT uVirtKey,
// _In_ UINT uScanCode,
// _In_reads_opt_(256) CONST BYTE *lpKeyState,
// _Out_ LPWORD lpChar,
// _In_ UINT uFlags);
// #if(WINVER >= 0x0400)
// WINUSERAPI
// int
// WINAPI
// ToAsciiEx(
// _In_ UINT uVirtKey,
// _In_ UINT uScanCode,
// _In_reads_opt_(256) CONST BYTE *lpKeyState,
// _Out_ LPWORD lpChar,
// _In_ UINT uFlags,
// _In_opt_ HKL dwhkl);
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// int
// WINAPI
// ToUnicode(
// _In_ UINT wVirtKey,
// _In_ UINT wScanCode,
// _In_reads_bytes_opt_(256) CONST BYTE *lpKeyState,
// _Out_writes_(cchBuff) LPWSTR pwszBuff,
// _In_ int cchBuff,
// _In_ UINT wFlags);
// WINUSERAPI
// DWORD
// WINAPI
// OemKeyScan(
// _In_ WORD wOemChar);
// WINUSERAPI
// SHORT
// WINAPI
// VkKeyScanA(
// _In_ CHAR ch);
// WINUSERAPI
// SHORT
// WINAPI
// VkKeyScanW(
// _In_ WCHAR ch);
// #ifdef UNICODE
// #define VkKeyScan VkKeyScanW
// #else
// #define VkKeyScan VkKeyScanA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// WINUSERAPI
// SHORT
// WINAPI
// VkKeyScanExA(
// _In_ CHAR ch,
// _In_ HKL dwhkl);
// WINUSERAPI
// SHORT
// WINAPI
// VkKeyScanExW(
// _In_ WCHAR ch,
// _In_ HKL dwhkl);
// #ifdef UNICODE
// #define VkKeyScanEx VkKeyScanExW
// #else
// #define VkKeyScanEx VkKeyScanExA
// #endif // !UNICODE
// #endif /* WINVER >= 0x0400 */
// #define KEYEVENTF_EXTENDEDKEY 0x0001
// #define KEYEVENTF_KEYUP 0x0002
// #if(_WIN32_WINNT >= 0x0500)
// #define KEYEVENTF_UNICODE 0x0004
// #define KEYEVENTF_SCANCODE 0x0008
// #endif /* _WIN32_WINNT >= 0x0500 */
// WINUSERAPI
// VOID
// WINAPI
// keybd_event(
// _In_ BYTE bVk,
// _In_ BYTE bScan,
// _In_ DWORD dwFlags,
// _In_ ULONG_PTR dwExtraInfo);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define MOUSEEVENTF_MOVE 0x0001 /* mouse move */
// #define MOUSEEVENTF_LEFTDOWN 0x0002 /* left button down */
// #define MOUSEEVENTF_LEFTUP 0x0004 /* left button up */
// #define MOUSEEVENTF_RIGHTDOWN 0x0008 /* right button down */
// #define MOUSEEVENTF_RIGHTUP 0x0010 /* right button up */
// #define MOUSEEVENTF_MIDDLEDOWN 0x0020 /* middle button down */
// #define MOUSEEVENTF_MIDDLEUP 0x0040 /* middle button up */
// #define MOUSEEVENTF_XDOWN 0x0080 /* x button down */
// #define MOUSEEVENTF_XUP 0x0100 /* x button down */
// #define MOUSEEVENTF_WHEEL 0x0800 /* wheel button rolled */
// #if (_WIN32_WINNT >= 0x0600)
// #define MOUSEEVENTF_HWHEEL 0x01000 /* hwheel button rolled */
// #endif
// #if(WINVER >= 0x0600)
// #define MOUSEEVENTF_MOVE_NOCOALESCE 0x2000 /* do not coalesce mouse moves */
// #endif /* WINVER >= 0x0600 */
// #define MOUSEEVENTF_VIRTUALDESK 0x4000 /* map to entire virtual desktop */
// #define MOUSEEVENTF_ABSOLUTE 0x8000 /* absolute move */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// VOID
// WINAPI
// mouse_event(
// _In_ DWORD dwFlags,
// _In_ DWORD dx,
// _In_ DWORD dy,
// _In_ DWORD dwData,
// _In_ ULONG_PTR dwExtraInfo);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if (_WIN32_WINNT > 0x0400)
// typedef struct tagMOUSEINPUT {
// LONG dx;
// LONG dy;
// DWORD mouseData;
// DWORD dwFlags;
// DWORD time;
// ULONG_PTR dwExtraInfo;
// } MOUSEINPUT, *PMOUSEINPUT, FAR* LPMOUSEINPUT;
// typedef struct tagKEYBDINPUT {
// WORD wVk;
// WORD wScan;
// DWORD dwFlags;
// DWORD time;
// ULONG_PTR dwExtraInfo;
// } KEYBDINPUT, *PKEYBDINPUT, FAR* LPKEYBDINPUT;
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagHARDWAREINPUT {
// DWORD uMsg;
// WORD wParamL;
// WORD wParamH;
// } HARDWAREINPUT, *PHARDWAREINPUT, FAR* LPHARDWAREINPUT;
// #define INPUT_MOUSE 0
// #define INPUT_KEYBOARD 1
// #define INPUT_HARDWARE 2
// typedef struct tagINPUT {
// DWORD type;
// union
// {
// MOUSEINPUT mi;
// KEYBDINPUT ki;
// HARDWAREINPUT hi;
// } DUMMYUNIONNAME;
// } INPUT, *PINPUT, FAR* LPINPUT;
// WINUSERAPI
// UINT
// WINAPI
// SendInput(
// _In_ UINT cInputs, // number of input in the array
// _In_reads_(cInputs) LPINPUT pInputs, // array of inputs
// _In_ int cbSize); // sizeof(INPUT)
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif // (_WIN32_WINNT > 0x0400)
// #if(WINVER >= 0x0601)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Touch Input defines and functions
// */
// /*
// * Touch input handle
// */
// DECLARE_HANDLE(HTOUCHINPUT);
// typedef struct tagTOUCHINPUT {
// LONG x;
// LONG y;
// HANDLE hSource;
// DWORD dwID;
// DWORD dwFlags;
// DWORD dwMask;
// DWORD dwTime;
// ULONG_PTR dwExtraInfo;
// DWORD cxContact;
// DWORD cyContact;
// } TOUCHINPUT, *PTOUCHINPUT;
// typedef TOUCHINPUT const * PCTOUCHINPUT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Conversion of touch input coordinates to pixels
// */
// #define TOUCH_COORD_TO_PIXEL(l) ((l) / 100)
// /*
// * Touch input flag values (TOUCHINPUT.dwFlags)
// */
// #define TOUCHEVENTF_MOVE 0x0001
// #define TOUCHEVENTF_DOWN 0x0002
// #define TOUCHEVENTF_UP 0x0004
// #define TOUCHEVENTF_INRANGE 0x0008
// #define TOUCHEVENTF_PRIMARY 0x0010
// #define TOUCHEVENTF_NOCOALESCE 0x0020
// #define TOUCHEVENTF_PEN 0x0040
// #define TOUCHEVENTF_PALM 0x0080
// /*
// * Touch input mask values (TOUCHINPUT.dwMask)
// */
// #define TOUCHINPUTMASKF_TIMEFROMSYSTEM 0x0001 // the dwTime field contains a system generated value
// #define TOUCHINPUTMASKF_EXTRAINFO 0x0002 // the dwExtraInfo field is valid
// #define TOUCHINPUTMASKF_CONTACTAREA 0x0004 // the cxContact and cyContact fields are valid
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// GetTouchInputInfo(
// _In_ HTOUCHINPUT hTouchInput, // input event handle; from touch message lParam
// _In_ UINT cInputs, // number of elements in the array
// _Out_writes_(cInputs) PTOUCHINPUT pInputs, // array of touch inputs
// _In_ int cbSize); // sizeof(TOUCHINPUT)
// WINUSERAPI
// BOOL
// WINAPI
// CloseTouchInputHandle(
// _In_ HTOUCHINPUT hTouchInput); // input event handle; from touch message lParam
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * RegisterTouchWindow flag values
// */
// #define TWF_FINETOUCH (0x00000001)
// #define TWF_WANTPALM (0x00000002)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// RegisterTouchWindow(
// _In_ HWND hwnd,
// _In_ ULONG ulFlags);
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterTouchWindow(
// _In_ HWND hwnd);
// WINUSERAPI
// BOOL
// WINAPI
// IsTouchWindow(
// _In_ HWND hwnd,
// _Out_opt_ PULONG pulFlags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0601 */
// #if(WINVER >= 0x0602)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #define POINTER_STRUCTURES
// enum tagPOINTER_INPUT_TYPE {
// PT_POINTER = 1, // Generic pointer
// PT_TOUCH = 2, // Touch
// PT_PEN = 3, // Pen
// PT_MOUSE = 4, // Mouse
// #if(WINVER >= 0x0603)
// PT_TOUCHPAD = 5, // Touchpad
// #endif /* WINVER >= 0x0603 */
// };
// typedef DWORD POINTER_INPUT_TYPE;
// typedef UINT32 POINTER_FLAGS;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define POINTER_FLAG_NONE 0x00000000 // Default
// #define POINTER_FLAG_NEW 0x00000001 // New pointer
// #define POINTER_FLAG_INRANGE 0x00000002 // Pointer has not departed
// #define POINTER_FLAG_INCONTACT 0x00000004 // Pointer is in contact
// #define POINTER_FLAG_FIRSTBUTTON 0x00000010 // Primary action
// #define POINTER_FLAG_SECONDBUTTON 0x00000020 // Secondary action
// #define POINTER_FLAG_THIRDBUTTON 0x00000040 // Third button
// #define POINTER_FLAG_FOURTHBUTTON 0x00000080 // Fourth button
// #define POINTER_FLAG_FIFTHBUTTON 0x00000100 // Fifth button
// #define POINTER_FLAG_PRIMARY 0x00002000 // Pointer is primary
// #define POINTER_FLAG_CONFIDENCE 0x00004000 // Pointer is considered unlikely to be accidental
// #define POINTER_FLAG_CANCELED 0x00008000 // Pointer is departing in an abnormal manner
// #define POINTER_FLAG_DOWN 0x00010000 // Pointer transitioned to down state (made contact)
// #define POINTER_FLAG_UPDATE 0x00020000 // Pointer update
// #define POINTER_FLAG_UP 0x00040000 // Pointer transitioned from down state (broke contact)
// #define POINTER_FLAG_WHEEL 0x00080000 // Vertical wheel
// #define POINTER_FLAG_HWHEEL 0x00100000 // Horizontal wheel
// #define POINTER_FLAG_CAPTURECHANGED 0x00200000 // Lost capture
// #define POINTER_FLAG_HASTRANSFORM 0x00400000 // Input has a transform associated with it
// /*
// * Pointer info key states defintions.
// */
// #define POINTER_MOD_SHIFT (0x0004) // Shift key is held down.
// #define POINTER_MOD_CTRL (0x0008) // Ctrl key is held down.
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef enum tagPOINTER_BUTTON_CHANGE_TYPE {
// POINTER_CHANGE_NONE,
// POINTER_CHANGE_FIRSTBUTTON_DOWN,
// POINTER_CHANGE_FIRSTBUTTON_UP,
// POINTER_CHANGE_SECONDBUTTON_DOWN,
// POINTER_CHANGE_SECONDBUTTON_UP,
// POINTER_CHANGE_THIRDBUTTON_DOWN,
// POINTER_CHANGE_THIRDBUTTON_UP,
// POINTER_CHANGE_FOURTHBUTTON_DOWN,
// POINTER_CHANGE_FOURTHBUTTON_UP,
// POINTER_CHANGE_FIFTHBUTTON_DOWN,
// POINTER_CHANGE_FIFTHBUTTON_UP,
// } POINTER_BUTTON_CHANGE_TYPE;
// typedef struct tagPOINTER_INFO {
// POINTER_INPUT_TYPE pointerType;
// UINT32 pointerId;
// UINT32 frameId;
// POINTER_FLAGS pointerFlags;
// HANDLE sourceDevice;
// HWND hwndTarget;
// POINT ptPixelLocation;
// POINT ptHimetricLocation;
// POINT ptPixelLocationRaw;
// POINT ptHimetricLocationRaw;
// DWORD dwTime;
// UINT32 historyCount;
// INT32 InputData;
// DWORD dwKeyStates;
// UINT64 PerformanceCount;
// POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
// } POINTER_INFO;
// typedef UINT32 TOUCH_FLAGS;
// #define TOUCH_FLAG_NONE 0x00000000 // Default
// typedef UINT32 TOUCH_MASK;
// #define TOUCH_MASK_NONE 0x00000000 // Default - none of the optional fields are valid
// #define TOUCH_MASK_CONTACTAREA 0x00000001 // The rcContact field is valid
// #define TOUCH_MASK_ORIENTATION 0x00000002 // The orientation field is valid
// #define TOUCH_MASK_PRESSURE 0x00000004 // The pressure field is valid
// typedef struct tagPOINTER_TOUCH_INFO {
// POINTER_INFO pointerInfo;
// TOUCH_FLAGS touchFlags;
// TOUCH_MASK touchMask;
// RECT rcContact;
// RECT rcContactRaw;
// UINT32 orientation;
// UINT32 pressure;
// } POINTER_TOUCH_INFO;
// typedef UINT32 PEN_FLAGS;
// #define PEN_FLAG_NONE 0x00000000 // Default
// #define PEN_FLAG_BARREL 0x00000001 // The barrel button is pressed
// #define PEN_FLAG_INVERTED 0x00000002 // The pen is inverted
// #define PEN_FLAG_ERASER 0x00000004 // The eraser button is pressed
// typedef UINT32 PEN_MASK;
// #define PEN_MASK_NONE 0x00000000 // Default - none of the optional fields are valid
// #define PEN_MASK_PRESSURE 0x00000001 // The pressure field is valid
// #define PEN_MASK_ROTATION 0x00000002 // The rotation field is valid
// #define PEN_MASK_TILT_X 0x00000004 // The tiltX field is valid
// #define PEN_MASK_TILT_Y 0x00000008 // The tiltY field is valid
// typedef struct tagPOINTER_PEN_INFO {
// POINTER_INFO pointerInfo;
// PEN_FLAGS penFlags;
// PEN_MASK penMask;
// UINT32 pressure;
// UINT32 rotation;
// INT32 tiltX;
// INT32 tiltY;
// } POINTER_PEN_INFO;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Flags that appear in pointer input message parameters
// */
// #define POINTER_MESSAGE_FLAG_NEW 0x00000001 // New pointer
// #define POINTER_MESSAGE_FLAG_INRANGE 0x00000002 // Pointer has not departed
// #define POINTER_MESSAGE_FLAG_INCONTACT 0x00000004 // Pointer is in contact
// #define POINTER_MESSAGE_FLAG_FIRSTBUTTON 0x00000010 // Primary action
// #define POINTER_MESSAGE_FLAG_SECONDBUTTON 0x00000020 // Secondary action
// #define POINTER_MESSAGE_FLAG_THIRDBUTTON 0x00000040 // Third button
// #define POINTER_MESSAGE_FLAG_FOURTHBUTTON 0x00000080 // Fourth button
// #define POINTER_MESSAGE_FLAG_FIFTHBUTTON 0x00000100 // Fifth button
// #define POINTER_MESSAGE_FLAG_PRIMARY 0x00002000 // Pointer is primary
// #define POINTER_MESSAGE_FLAG_CONFIDENCE 0x00004000 // Pointer is considered unlikely to be accidental
// #define POINTER_MESSAGE_FLAG_CANCELED 0x00008000 // Pointer is departing in an abnormal manner
// /*
// * Macros to retrieve information from pointer input message parameters
// */
// #define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam))
// #define IS_POINTER_FLAG_SET_WPARAM(wParam, flag) (((DWORD)HIWORD(wParam) & (flag)) == (flag))
// #define IS_POINTER_NEW_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_NEW)
// #define IS_POINTER_INRANGE_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_INRANGE)
// #define IS_POINTER_INCONTACT_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_INCONTACT)
// #define IS_POINTER_FIRSTBUTTON_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_FIRSTBUTTON)
// #define IS_POINTER_SECONDBUTTON_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_SECONDBUTTON)
// #define IS_POINTER_THIRDBUTTON_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_THIRDBUTTON)
// #define IS_POINTER_FOURTHBUTTON_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_FOURTHBUTTON)
// #define IS_POINTER_FIFTHBUTTON_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_FIFTHBUTTON)
// #define IS_POINTER_PRIMARY_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_PRIMARY)
// #define HAS_POINTER_CONFIDENCE_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_CONFIDENCE)
// #define IS_POINTER_CANCELED_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_CANCELED)
// /*
// * WM_POINTERACTIVATE return codes
// */
// #define PA_ACTIVATE MA_ACTIVATE
// #define PA_NOACTIVATE MA_NOACTIVATE
// #define MAX_TOUCH_COUNT 256
// #define TOUCH_FEEDBACK_DEFAULT 0x1
// #define TOUCH_FEEDBACK_INDIRECT 0x2
// #define TOUCH_FEEDBACK_NONE 0x3
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// InitializeTouchInjection(
// _In_ UINT32 maxCount,
// _In_ DWORD dwMode);
// WINUSERAPI
// BOOL
// WINAPI
// InjectTouchInput(
// _In_ UINT32 count,
// _In_reads_(count) CONST POINTER_TOUCH_INFO *contacts);
// typedef struct tagUSAGE_PROPERTIES {
// USHORT level;
// USHORT page;
// USHORT usage;
// INT32 logicalMinimum;
// INT32 logicalMaximum;
// USHORT unit;
// USHORT exponent;
// BYTE count;
// INT32 physicalMinimum;
// INT32 physicalMaximum;
// }USAGE_PROPERTIES, *PUSAGE_PROPERTIES;
// typedef struct tagPOINTER_TYPE_INFO {
// POINTER_INPUT_TYPE type;
// union {
// POINTER_TOUCH_INFO touchInfo;
// POINTER_PEN_INFO penInfo;
// } DUMMYUNIONNAME;
// }POINTER_TYPE_INFO, *PPOINTER_TYPE_INFO;
// typedef struct tagINPUT_INJECTION_VALUE {
// USHORT page;
// USHORT usage;
// INT32 value;
// USHORT index;
// }INPUT_INJECTION_VALUE, *PINPUT_INJECTION_VALUE;
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerType(
// _In_ UINT32 pointerId,
// _Out_ POINTER_INPUT_TYPE *pointerType);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerCursorId(
// _In_ UINT32 pointerId,
// _Out_ UINT32 *cursorId);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerInfo(
// _In_ UINT32 pointerId,
// _Out_writes_(1) POINTER_INFO *pointerInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerInfoHistory(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *entriesCount,
// _Out_writes_opt_(*entriesCount) POINTER_INFO *pointerInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerFrameInfo(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *pointerCount,
// _Out_writes_opt_(*pointerCount) POINTER_INFO *pointerInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerFrameInfoHistory(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *entriesCount,
// _Inout_ UINT32 *pointerCount,
// _Out_writes_opt_(*entriesCount * *pointerCount) POINTER_INFO *pointerInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerTouchInfo(
// _In_ UINT32 pointerId,
// _Out_writes_(1) POINTER_TOUCH_INFO *touchInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerTouchInfoHistory(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *entriesCount,
// _Out_writes_opt_(*entriesCount) POINTER_TOUCH_INFO *touchInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerFrameTouchInfo(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *pointerCount,
// _Out_writes_opt_(*pointerCount) POINTER_TOUCH_INFO *touchInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerFrameTouchInfoHistory(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *entriesCount,
// _Inout_ UINT32 *pointerCount,
// _Out_writes_opt_(*entriesCount * *pointerCount) POINTER_TOUCH_INFO *touchInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerPenInfo(
// _In_ UINT32 pointerId,
// _Out_writes_(1) POINTER_PEN_INFO *penInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerPenInfoHistory(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *entriesCount,
// _Out_writes_opt_(*entriesCount) POINTER_PEN_INFO *penInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerFramePenInfo(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *pointerCount,
// _Out_writes_opt_(*pointerCount) POINTER_PEN_INFO *penInfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerFramePenInfoHistory(
// _In_ UINT32 pointerId,
// _Inout_ UINT32 *entriesCount,
// _Inout_ UINT32 *pointerCount,
// _Out_writes_opt_(*entriesCount * *pointerCount) POINTER_PEN_INFO *penInfo);
// WINUSERAPI
// BOOL
// WINAPI
// SkipPointerFrameMessages(
// _In_ UINT32 pointerId);
// WINUSERAPI
// BOOL
// WINAPI
// RegisterPointerInputTarget(
// _In_ HWND hwnd,
// _In_ POINTER_INPUT_TYPE pointerType);
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterPointerInputTarget(
// _In_ HWND hwnd,
// _In_ POINTER_INPUT_TYPE pointerType);
// WINUSERAPI
// BOOL
// WINAPI
// RegisterPointerInputTargetEx(
// _In_ HWND hwnd,
// _In_ POINTER_INPUT_TYPE pointerType,
// _In_ BOOL fObserve);
// WINUSERAPI
// BOOL
// WINAPI
// UnregisterPointerInputTargetEx(
// _In_ HWND hwnd,
// _In_ POINTER_INPUT_TYPE pointerType);
// WINUSERAPI
// BOOL
// WINAPI
// EnableMouseInPointer(
// _In_ BOOL fEnable);
// WINUSERAPI
// BOOL
// WINAPI
// IsMouseInPointerEnabled(
// VOID);
// #if WDK_NTDDI_VERSION >= NTDDI_WIN10_RS3
// WINUSERAPI
// BOOL
// WINAPI
// EnableMouseInPointerForThread();
// #endif
// #define TOUCH_HIT_TESTING_DEFAULT 0x0
// #define TOUCH_HIT_TESTING_CLIENT 0x1
// #define TOUCH_HIT_TESTING_NONE 0x2
// WINUSERAPI
// BOOL
// WINAPI
// RegisterTouchHitTestingWindow(
// _In_ HWND hwnd,
// _In_ ULONG value);
// typedef struct tagTOUCH_HIT_TESTING_PROXIMITY_EVALUATION
// {
// UINT16 score;
// POINT adjustedPoint;
// } TOUCH_HIT_TESTING_PROXIMITY_EVALUATION, *PTOUCH_HIT_TESTING_PROXIMITY_EVALUATION;
// /*
// * WM_TOUCHHITTESTING structure
// */
// typedef struct tagTOUCH_HIT_TESTING_INPUT
// {
// UINT32 pointerId;
// POINT point;
// RECT boundingBox;
// RECT nonOccludedBoundingBox;
// UINT32 orientation;
// } TOUCH_HIT_TESTING_INPUT, *PTOUCH_HIT_TESTING_INPUT;
// #define TOUCH_HIT_TESTING_PROXIMITY_CLOSEST 0x0
// #define TOUCH_HIT_TESTING_PROXIMITY_FARTHEST 0xFFF
// WINUSERAPI
// BOOL
// WINAPI
// EvaluateProximityToRect(
// _In_ const RECT *controlBoundingBox,
// _In_ const TOUCH_HIT_TESTING_INPUT *pHitTestingInput,
// _Out_ TOUCH_HIT_TESTING_PROXIMITY_EVALUATION *pProximityEval);
// WINUSERAPI
// BOOL
// WINAPI
// EvaluateProximityToPolygon(
// UINT32 numVertices,
// _In_reads_(numVertices) const POINT *controlPolygon,
// _In_ const TOUCH_HIT_TESTING_INPUT *pHitTestingInput,
// _Out_ TOUCH_HIT_TESTING_PROXIMITY_EVALUATION *pProximityEval);
// WINUSERAPI
// LRESULT
// WINAPI
// PackTouchHitTestingProximityEvaluation(
// _In_ const TOUCH_HIT_TESTING_INPUT *pHitTestingInput,
// _In_ const TOUCH_HIT_TESTING_PROXIMITY_EVALUATION *pProximityEval);
// typedef enum tagFEEDBACK_TYPE {
// FEEDBACK_TOUCH_CONTACTVISUALIZATION = 1,
// FEEDBACK_PEN_BARRELVISUALIZATION = 2,
// FEEDBACK_PEN_TAP = 3,
// FEEDBACK_PEN_DOUBLETAP = 4,
// FEEDBACK_PEN_PRESSANDHOLD = 5,
// FEEDBACK_PEN_RIGHTTAP = 6,
// FEEDBACK_TOUCH_TAP = 7,
// FEEDBACK_TOUCH_DOUBLETAP = 8,
// FEEDBACK_TOUCH_PRESSANDHOLD = 9,
// FEEDBACK_TOUCH_RIGHTTAP = 10,
// FEEDBACK_GESTURE_PRESSANDTAP = 11,
// FEEDBACK_MAX = 0xFFFFFFFF
// } FEEDBACK_TYPE;
// #define GWFS_INCLUDE_ANCESTORS 0x00000001
// WINUSERAPI
// BOOL
// WINAPI
// GetWindowFeedbackSetting(
// _In_ HWND hwnd,
// _In_ FEEDBACK_TYPE feedback,
// _In_ DWORD dwFlags,
// _Inout_ UINT32* pSize,
// _Out_writes_bytes_opt_(*pSize) VOID* config);
// WINUSERAPI
// BOOL
// WINAPI
// SetWindowFeedbackSetting(
// _In_ HWND hwnd,
// _In_ FEEDBACK_TYPE feedback,
// _In_ DWORD dwFlags,
// _In_ UINT32 size,
// _In_reads_bytes_opt_(size) CONST VOID* configuration);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0602 */
// #if(WINVER >= 0x0603)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// //Disable warning C4201:nameless struct/union
// #if _MSC_VER >= 1200
// #pragma warning(push)
// #endif
// #pragma warning(disable : 4201)
// typedef struct tagINPUT_TRANSFORM {
// union {
// struct {
// float _11, _12, _13, _14;
// float _21, _22, _23, _24;
// float _31, _32, _33, _34;
// float _41, _42, _43, _44;
// } DUMMYSTRUCTNAME;
// float m[4][4];
// } DUMMYUNIONNAME;
// } INPUT_TRANSFORM;
// #if _MSC_VER >= 1200
// #pragma warning(pop)
// #endif
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerInputTransform(
// _In_ UINT32 pointerId,
// _In_ UINT32 historyCount,
// _Out_writes_(historyCount) INPUT_TRANSFORM *inputTransform);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0603 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP)
// #if(_WIN32_WINNT >= 0x0500)
// typedef struct tagLASTINPUTINFO {
// UINT cbSize;
// DWORD dwTime;
// } LASTINPUTINFO, *PLASTINPUTINFO;
// WINUSERAPI
// BOOL
// WINAPI
// GetLastInputInfo(
// _Out_ PLASTINPUTINFO plii);
// #endif /* _WIN32_WINNT >= 0x0500 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP) */
// #pragma endregion
// #pragma region Desktop or PC Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP)
// WINUSERAPI
// UINT
// WINAPI
// MapVirtualKeyA(
// _In_ UINT uCode,
// _In_ UINT uMapType);
// WINUSERAPI
// UINT
// WINAPI
// MapVirtualKeyW(
// _In_ UINT uCode,
// _In_ UINT uMapType);
// #ifdef UNICODE
// #define MapVirtualKey MapVirtualKeyW
// #else
// #define MapVirtualKey MapVirtualKeyA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// WINUSERAPI
// UINT
// WINAPI
// MapVirtualKeyExA(
// _In_ UINT uCode,
// _In_ UINT uMapType,
// _In_opt_ HKL dwhkl);
// WINUSERAPI
// UINT
// WINAPI
// MapVirtualKeyExW(
// _In_ UINT uCode,
// _In_ UINT uMapType,
// _In_opt_ HKL dwhkl);
// #ifdef UNICODE
// #define MapVirtualKeyEx MapVirtualKeyExW
// #else
// #define MapVirtualKeyEx MapVirtualKeyExA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #define MAPVK_VK_TO_VSC (0)
// #define MAPVK_VSC_TO_VK (1)
// #define MAPVK_VK_TO_CHAR (2)
// #define MAPVK_VSC_TO_VK_EX (3)
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0600)
// #define MAPVK_VK_TO_VSC_EX (4)
// #endif /* WINVER >= 0x0600 */
// WINUSERAPI
// BOOL
// WINAPI
// GetInputState(
// VOID);
// WINUSERAPI
// DWORD
// WINAPI
// GetQueueStatus(
// _In_ UINT flags);
// WINUSERAPI
// HWND
// WINAPI
// GetCapture(
// VOID);
// WINUSERAPI
// HWND
// WINAPI
// SetCapture(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// ReleaseCapture(
// VOID);
// WINUSERAPI
// DWORD
// WINAPI
// MsgWaitForMultipleObjects(
// _In_ DWORD nCount,
// _In_reads_opt_(nCount) CONST HANDLE *pHandles,
// _In_ BOOL fWaitAll,
// _In_ DWORD dwMilliseconds,
// _In_ DWORD dwWakeMask);
// WINUSERAPI
// DWORD
// WINAPI
// MsgWaitForMultipleObjectsEx(
// _In_ DWORD nCount,
// _In_reads_opt_(nCount) CONST HANDLE *pHandles,
// _In_ DWORD dwMilliseconds,
// _In_ DWORD dwWakeMask,
// _In_ DWORD dwFlags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define MWMO_WAITALL 0x0001
// #define MWMO_ALERTABLE 0x0002
// #define MWMO_INPUTAVAILABLE 0x0004
// /*
// * Queue status flags for GetQueueStatus() and MsgWaitForMultipleObjects()
// */
// #define QS_KEY 0x0001
// #define QS_MOUSEMOVE 0x0002
// #define QS_MOUSEBUTTON 0x0004
// #define QS_POSTMESSAGE 0x0008
// #define QS_TIMER 0x0010
// #define QS_PAINT 0x0020
// #define QS_SENDMESSAGE 0x0040
// #define QS_HOTKEY 0x0080
// #define QS_ALLPOSTMESSAGE 0x0100
// #if(_WIN32_WINNT >= 0x0501)
// #define QS_RAWINPUT 0x0400
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0602)
// #define QS_TOUCH 0x0800
// #define QS_POINTER 0x1000
// #endif /* _WIN32_WINNT >= 0x0602 */
// #define QS_MOUSE (QS_MOUSEMOVE | \
// QS_MOUSEBUTTON)
// #if (_WIN32_WINNT >= 0x602)
// #define QS_INPUT (QS_MOUSE | \
// QS_KEY | \
// QS_RAWINPUT | \
// QS_TOUCH | \
// QS_POINTER)
// #else
// #if (_WIN32_WINNT >= 0x0501)
// #define QS_INPUT (QS_MOUSE | \
// QS_KEY | \
// QS_RAWINPUT)
// #else
// #define QS_INPUT (QS_MOUSE | \
// QS_KEY)
// #endif // (_WIN32_WINNT >= 0x0501)
// #endif
// #define QS_ALLEVENTS (QS_INPUT | \
// QS_POSTMESSAGE | \
// QS_TIMER | \
// QS_PAINT | \
// QS_HOTKEY)
// #define QS_ALLINPUT (QS_INPUT | \
// QS_POSTMESSAGE | \
// QS_TIMER | \
// QS_PAINT | \
// QS_HOTKEY | \
// QS_SENDMESSAGE)
// #define USER_TIMER_MAXIMUM 0x7FFFFFFF
// #define USER_TIMER_MINIMUM 0x0000000A
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Windows Functions
// */
// WINUSERAPI
// UINT_PTR
// WINAPI
// SetTimer(
// _In_opt_ HWND hWnd,
// _In_ UINT_PTR nIDEvent,
// _In_ UINT uElapse,
// _In_opt_ TIMERPROC lpTimerFunc);
// #if(WINVER >= 0x0601)
// #define TIMERV_DEFAULT_COALESCING (0)
// #define TIMERV_NO_COALESCING (0xFFFFFFFF)
// #define TIMERV_COALESCING_MIN (1)
// #define TIMERV_COALESCING_MAX (0x7FFFFFF5)
// WINUSERAPI
// UINT_PTR
// WINAPI
// SetCoalescableTimer(
// _In_opt_ HWND hWnd,
// _In_ UINT_PTR nIDEvent,
// _In_ UINT uElapse,
// _In_opt_ TIMERPROC lpTimerFunc,
// _In_ ULONG uToleranceDelay);
// #endif /* WINVER >= 0x0601 */
// WINUSERAPI
// BOOL
// WINAPI
// KillTimer(
// _In_opt_ HWND hWnd,
// _In_ UINT_PTR uIDEvent);
// WINUSERAPI
// BOOL
// WINAPI
// IsWindowUnicode(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// EnableWindow(
// _In_ HWND hWnd,
// _In_ BOOL bEnable);
// WINUSERAPI
// BOOL
// WINAPI
// IsWindowEnabled(
// _In_ HWND hWnd);
// WINUSERAPI
// HACCEL
// WINAPI
// LoadAcceleratorsA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpTableName);
// WINUSERAPI
// HACCEL
// WINAPI
// LoadAcceleratorsW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpTableName);
// #ifdef UNICODE
// #define LoadAccelerators LoadAcceleratorsW
// #else
// #define LoadAccelerators LoadAcceleratorsA
// #endif // !UNICODE
// WINUSERAPI
// HACCEL
// WINAPI
// CreateAcceleratorTableA(
// _In_reads_(cAccel) LPACCEL paccel,
// _In_ int cAccel);
// WINUSERAPI
// HACCEL
// WINAPI
// CreateAcceleratorTableW(
// _In_reads_(cAccel) LPACCEL paccel,
// _In_ int cAccel);
// #ifdef UNICODE
// #define CreateAcceleratorTable CreateAcceleratorTableW
// #else
// #define CreateAcceleratorTable CreateAcceleratorTableA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// DestroyAcceleratorTable(
// _In_ HACCEL hAccel);
// WINUSERAPI
// int
// WINAPI
// CopyAcceleratorTableA(
// _In_ HACCEL hAccelSrc,
// _Out_writes_to_opt_(cAccelEntries, return) LPACCEL lpAccelDst,
// _In_ int cAccelEntries);
// WINUSERAPI
// int
// WINAPI
// CopyAcceleratorTableW(
// _In_ HACCEL hAccelSrc,
// _Out_writes_to_opt_(cAccelEntries, return) LPACCEL lpAccelDst,
// _In_ int cAccelEntries);
// #ifdef UNICODE
// #define CopyAcceleratorTable CopyAcceleratorTableW
// #else
// #define CopyAcceleratorTable CopyAcceleratorTableA
// #endif // !UNICODE
// #ifndef NOMSG
// WINUSERAPI
// int
// WINAPI
// TranslateAcceleratorA(
// _In_ HWND hWnd,
// _In_ HACCEL hAccTable,
// _In_ LPMSG lpMsg);
// WINUSERAPI
// int
// WINAPI
// TranslateAcceleratorW(
// _In_ HWND hWnd,
// _In_ HACCEL hAccTable,
// _In_ LPMSG lpMsg);
// #ifdef UNICODE
// #define TranslateAccelerator TranslateAcceleratorW
// #else
// #define TranslateAccelerator TranslateAcceleratorA
// #endif // !UNICODE
// #endif /* !NOMSG */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NOSYSMETRICS
// /*
// * GetSystemMetrics() codes
// */
// #define SM_CXSCREEN 0
// #define SM_CYSCREEN 1
// #define SM_CXVSCROLL 2
// #define SM_CYHSCROLL 3
// #define SM_CYCAPTION 4
// #define SM_CXBORDER 5
// #define SM_CYBORDER 6
// #define SM_CXDLGFRAME 7
// #define SM_CYDLGFRAME 8
// #define SM_CYVTHUMB 9
// #define SM_CXHTHUMB 10
// #define SM_CXICON 11
// #define SM_CYICON 12
// #define SM_CXCURSOR 13
// #define SM_CYCURSOR 14
// #define SM_CYMENU 15
// #define SM_CXFULLSCREEN 16
// #define SM_CYFULLSCREEN 17
// #define SM_CYKANJIWINDOW 18
// #define SM_MOUSEPRESENT 19
// #define SM_CYVSCROLL 20
// #define SM_CXHSCROLL 21
// #define SM_DEBUG 22
// #define SM_SWAPBUTTON 23
// #define SM_RESERVED1 24
// #define SM_RESERVED2 25
// #define SM_RESERVED3 26
// #define SM_RESERVED4 27
// #define SM_CXMIN 28
// #define SM_CYMIN 29
// #define SM_CXSIZE 30
// #define SM_CYSIZE 31
// #define SM_CXFRAME 32
// #define SM_CYFRAME 33
// #define SM_CXMINTRACK 34
// #define SM_CYMINTRACK 35
// #define SM_CXDOUBLECLK 36
// #define SM_CYDOUBLECLK 37
// #define SM_CXICONSPACING 38
// #define SM_CYICONSPACING 39
// #define SM_MENUDROPALIGNMENT 40
// #define SM_PENWINDOWS 41
// #define SM_DBCSENABLED 42
// #define SM_CMOUSEBUTTONS 43
// #if(WINVER >= 0x0400)
// #define SM_CXFIXEDFRAME SM_CXDLGFRAME /* ;win40 name change */
// #define SM_CYFIXEDFRAME SM_CYDLGFRAME /* ;win40 name change */
// #define SM_CXSIZEFRAME SM_CXFRAME /* ;win40 name change */
// #define SM_CYSIZEFRAME SM_CYFRAME /* ;win40 name change */
// #define SM_SECURE 44
// #define SM_CXEDGE 45
// #define SM_CYEDGE 46
// #define SM_CXMINSPACING 47
// #define SM_CYMINSPACING 48
// #define SM_CXSMICON 49
// #define SM_CYSMICON 50
// #define SM_CYSMCAPTION 51
// #define SM_CXSMSIZE 52
// #define SM_CYSMSIZE 53
// #define SM_CXMENUSIZE 54
// #define SM_CYMENUSIZE 55
// #define SM_ARRANGE 56
// #define SM_CXMINIMIZED 57
// #define SM_CYMINIMIZED 58
// #define SM_CXMAXTRACK 59
// #define SM_CYMAXTRACK 60
// #define SM_CXMAXIMIZED 61
// #define SM_CYMAXIMIZED 62
// #define SM_NETWORK 63
// #define SM_CLEANBOOT 67
// #define SM_CXDRAG 68
// #define SM_CYDRAG 69
// #endif /* WINVER >= 0x0400 */
// #define SM_SHOWSOUNDS 70
// #if(WINVER >= 0x0400)
// #define SM_CXMENUCHECK 71 /* Use instead of GetMenuCheckMarkDimensions()! */
// #define SM_CYMENUCHECK 72
// #define SM_SLOWMACHINE 73
// #define SM_MIDEASTENABLED 74
// #endif /* WINVER >= 0x0400 */
// #if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400)
// #define SM_MOUSEWHEELPRESENT 75
// #endif
// #if(WINVER >= 0x0500)
// #define SM_XVIRTUALSCREEN 76
// #define SM_YVIRTUALSCREEN 77
// #define SM_CXVIRTUALSCREEN 78
// #define SM_CYVIRTUALSCREEN 79
// #define SM_CMONITORS 80
// #define SM_SAMEDISPLAYFORMAT 81
// #endif /* WINVER >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0500)
// #define SM_IMMENABLED 82
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0501)
// #define SM_CXFOCUSBORDER 83
// #define SM_CYFOCUSBORDER 84
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0501)
// #define SM_TABLETPC 86
// #define SM_MEDIACENTER 87
// #define SM_STARTER 88
// #define SM_SERVERR2 89
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0600)
// #define SM_MOUSEHORIZONTALWHEELPRESENT 91
// #define SM_CXPADDEDBORDER 92
// #endif /* _WIN32_WINNT >= 0x0600 */
// #if(WINVER >= 0x0601)
// #define SM_DIGITIZER 94
// #define SM_MAXIMUMTOUCHES 95
// #endif /* WINVER >= 0x0601 */
// #if (WINVER < 0x0500) && (!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0400))
// #define SM_CMETRICS 76
// #elif WINVER == 0x500
// #define SM_CMETRICS 83
// #elif WINVER == 0x501
// #define SM_CMETRICS 91
// #elif WINVER == 0x600
// #define SM_CMETRICS 93
// #else
// #define SM_CMETRICS 97
// #endif
// #if(WINVER >= 0x0500)
// #define SM_REMOTESESSION 0x1000
// #if(_WIN32_WINNT >= 0x0501)
// #define SM_SHUTTINGDOWN 0x2000
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(WINVER >= 0x0501)
// #define SM_REMOTECONTROL 0x2001
// #endif /* WINVER >= 0x0501 */
// #if(WINVER >= 0x0501)
// #define SM_CARETBLINKINGENABLED 0x2002
// #endif /* WINVER >= 0x0501 */
// #if(WINVER >= 0x0602)
// #define SM_CONVERTIBLESLATEMODE 0x2003
// #define SM_SYSTEMDOCKED 0x2004
// #endif /* WINVER >= 0x0602 */
// #endif /* WINVER >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// int
// WINAPI
// GetSystemMetrics(
// _In_ int nIndex);
// #if(WINVER >= 0x0605)
// WINUSERAPI
// int
// WINAPI
// GetSystemMetricsForDpi(
// _In_ int nIndex,
// _In_ UINT dpi);
// #endif /* WINVER >= 0x0605 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOSYSMETRICS */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #ifndef NOMENUS
// WINUSERAPI
// HMENU
// WINAPI
// LoadMenuA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpMenuName);
// WINUSERAPI
// HMENU
// WINAPI
// LoadMenuW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpMenuName);
// #ifdef UNICODE
// #define LoadMenu LoadMenuW
// #else
// #define LoadMenu LoadMenuA
// #endif // !UNICODE
// WINUSERAPI
// HMENU
// WINAPI
// LoadMenuIndirectA(
// _In_ CONST MENUTEMPLATEA *lpMenuTemplate);
// WINUSERAPI
// HMENU
// WINAPI
// LoadMenuIndirectW(
// _In_ CONST MENUTEMPLATEW *lpMenuTemplate);
// #ifdef UNICODE
// #define LoadMenuIndirect LoadMenuIndirectW
// #else
// #define LoadMenuIndirect LoadMenuIndirectA
// #endif // !UNICODE
// WINUSERAPI
// HMENU
// WINAPI
// GetMenu(
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// SetMenu(
// _In_ HWND hWnd,
// _In_opt_ HMENU hMenu);
// WINUSERAPI
// BOOL
// WINAPI
// ChangeMenuA(
// _In_ HMENU hMenu,
// _In_ UINT cmd,
// _In_opt_ LPCSTR lpszNewItem,
// _In_ UINT cmdInsert,
// _In_ UINT flags);
// WINUSERAPI
// BOOL
// WINAPI
// ChangeMenuW(
// _In_ HMENU hMenu,
// _In_ UINT cmd,
// _In_opt_ LPCWSTR lpszNewItem,
// _In_ UINT cmdInsert,
// _In_ UINT flags);
// #ifdef UNICODE
// #define ChangeMenu ChangeMenuW
// #else
// #define ChangeMenu ChangeMenuA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// HiliteMenuItem(
// _In_ HWND hWnd,
// _In_ HMENU hMenu,
// _In_ UINT uIDHiliteItem,
// _In_ UINT uHilite);
// WINUSERAPI
// int
// WINAPI
// GetMenuStringA(
// _In_ HMENU hMenu,
// _In_ UINT uIDItem,
// _Out_writes_opt_(cchMax) LPSTR lpString,
// _In_ int cchMax,
// _In_ UINT flags);
// WINUSERAPI
// int
// WINAPI
// GetMenuStringW(
// _In_ HMENU hMenu,
// _In_ UINT uIDItem,
// _Out_writes_opt_(cchMax) LPWSTR lpString,
// _In_ int cchMax,
// _In_ UINT flags);
// #ifdef UNICODE
// #define GetMenuString GetMenuStringW
// #else
// #define GetMenuString GetMenuStringA
// #endif // !UNICODE
// WINUSERAPI
// UINT
// WINAPI
// GetMenuState(
// _In_ HMENU hMenu,
// _In_ UINT uId,
// _In_ UINT uFlags);
// WINUSERAPI
// BOOL
// WINAPI
// DrawMenuBar(
// _In_ HWND hWnd);
// #if(_WIN32_WINNT >= 0x0501)
// #define PMB_ACTIVE 0x00000001
// #endif /* _WIN32_WINNT >= 0x0501 */
// WINUSERAPI
// HMENU
// WINAPI
// GetSystemMenu(
// _In_ HWND hWnd,
// _In_ BOOL bRevert);
// WINUSERAPI
// HMENU
// WINAPI
// CreateMenu(
// VOID);
// WINUSERAPI
// HMENU
// WINAPI
// CreatePopupMenu(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// DestroyMenu(
// _In_ HMENU hMenu);
// WINUSERAPI
// DWORD
// WINAPI
// CheckMenuItem(
// _In_ HMENU hMenu,
// _In_ UINT uIDCheckItem,
// _In_ UINT uCheck);
// WINUSERAPI
// BOOL
// WINAPI
// EnableMenuItem(
// _In_ HMENU hMenu,
// _In_ UINT uIDEnableItem,
// _In_ UINT uEnable);
// WINUSERAPI
// HMENU
// WINAPI
// GetSubMenu(
// _In_ HMENU hMenu,
// _In_ int nPos);
// WINUSERAPI
// UINT
// WINAPI
// GetMenuItemID(
// _In_ HMENU hMenu,
// _In_ int nPos);
// WINUSERAPI
// int
// WINAPI
// GetMenuItemCount(
// _In_opt_ HMENU hMenu);
// WINUSERAPI
// BOOL
// WINAPI
// InsertMenuA(
// _In_ HMENU hMenu,
// _In_ UINT uPosition,
// _In_ UINT uFlags,
// _In_ UINT_PTR uIDNewItem,
// _In_opt_ LPCSTR lpNewItem);
// WINUSERAPI
// BOOL
// WINAPI
// InsertMenuW(
// _In_ HMENU hMenu,
// _In_ UINT uPosition,
// _In_ UINT uFlags,
// _In_ UINT_PTR uIDNewItem,
// _In_opt_ LPCWSTR lpNewItem);
// #ifdef UNICODE
// #define InsertMenu InsertMenuW
// #else
// #define InsertMenu InsertMenuA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// AppendMenuA(
// _In_ HMENU hMenu,
// _In_ UINT uFlags,
// _In_ UINT_PTR uIDNewItem,
// _In_opt_ LPCSTR lpNewItem);
// WINUSERAPI
// BOOL
// WINAPI
// AppendMenuW(
// _In_ HMENU hMenu,
// _In_ UINT uFlags,
// _In_ UINT_PTR uIDNewItem,
// _In_opt_ LPCWSTR lpNewItem);
// #ifdef UNICODE
// #define AppendMenu AppendMenuW
// #else
// #define AppendMenu AppendMenuA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// ModifyMenuA(
// _In_ HMENU hMnu,
// _In_ UINT uPosition,
// _In_ UINT uFlags,
// _In_ UINT_PTR uIDNewItem,
// _In_opt_ LPCSTR lpNewItem);
// WINUSERAPI
// BOOL
// WINAPI
// ModifyMenuW(
// _In_ HMENU hMnu,
// _In_ UINT uPosition,
// _In_ UINT uFlags,
// _In_ UINT_PTR uIDNewItem,
// _In_opt_ LPCWSTR lpNewItem);
// #ifdef UNICODE
// #define ModifyMenu ModifyMenuW
// #else
// #define ModifyMenu ModifyMenuA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI RemoveMenu(
// _In_ HMENU hMenu,
// _In_ UINT uPosition,
// _In_ UINT uFlags);
// WINUSERAPI
// BOOL
// WINAPI
// DeleteMenu(
// _In_ HMENU hMenu,
// _In_ UINT uPosition,
// _In_ UINT uFlags);
// WINUSERAPI
// BOOL
// WINAPI
// SetMenuItemBitmaps(
// _In_ HMENU hMenu,
// _In_ UINT uPosition,
// _In_ UINT uFlags,
// _In_opt_ HBITMAP hBitmapUnchecked,
// _In_opt_ HBITMAP hBitmapChecked);
// WINUSERAPI
// LONG
// WINAPI
// GetMenuCheckMarkDimensions(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// TrackPopupMenu(
// _In_ HMENU hMenu,
// _In_ UINT uFlags,
// _In_ int x,
// _In_ int y,
// _Reserved_ int nReserved,
// _In_ HWND hWnd,
// _Reserved_ CONST RECT *prcRect);
// #if(WINVER >= 0x0400)
// /* return codes for WM_MENUCHAR */
// #define MNC_IGNORE 0
// #define MNC_CLOSE 1
// #define MNC_EXECUTE 2
// #define MNC_SELECT 3
// typedef struct tagTPMPARAMS
// {
// UINT cbSize; /* Size of structure */
// RECT rcExclude; /* Screen coordinates of rectangle to exclude when positioning */
// } TPMPARAMS;
// typedef TPMPARAMS FAR *LPTPMPARAMS;
// WINUSERAPI
// BOOL
// WINAPI
// TrackPopupMenuEx(
// _In_ HMENU hMenu,
// _In_ UINT uFlags,
// _In_ int x,
// _In_ int y,
// _In_ HWND hwnd,
// _In_opt_ LPTPMPARAMS lptpm);
// #endif /* WINVER >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0601)
// WINUSERAPI
// BOOL
// WINAPI
// CalculatePopupWindowPosition(
// _In_ const POINT *anchorPoint,
// _In_ const SIZE *windowSize,
// _In_ UINT /* TPM_XXX values */ flags,
// _In_opt_ RECT *excludeRect,
// _Out_ RECT *popupWindowPosition);
// #endif /* _WIN32_WINNT >= 0x0601 */
// #if(WINVER >= 0x0500)
// #define MNS_NOCHECK 0x80000000
// #define MNS_MODELESS 0x40000000
// #define MNS_DRAGDROP 0x20000000
// #define MNS_AUTODISMISS 0x10000000
// #define MNS_NOTIFYBYPOS 0x08000000
// #define MNS_CHECKORBMP 0x04000000
// #define MIM_MAXHEIGHT 0x00000001
// #define MIM_BACKGROUND 0x00000002
// #define MIM_HELPID 0x00000004
// #define MIM_MENUDATA 0x00000008
// #define MIM_STYLE 0x00000010
// #define MIM_APPLYTOSUBMENUS 0x80000000
// typedef struct tagMENUINFO
// {
// DWORD cbSize;
// DWORD fMask;
// DWORD dwStyle;
// UINT cyMax;
// HBRUSH hbrBack;
// DWORD dwContextHelpID;
// ULONG_PTR dwMenuData;
// } MENUINFO, FAR *LPMENUINFO;
// typedef MENUINFO CONST FAR *LPCMENUINFO;
// WINUSERAPI
// BOOL
// WINAPI
// GetMenuInfo(
// _In_ HMENU,
// _Inout_ LPMENUINFO);
// WINUSERAPI
// BOOL
// WINAPI
// SetMenuInfo(
// _In_ HMENU,
// _In_ LPCMENUINFO);
// WINUSERAPI
// BOOL
// WINAPI
// EndMenu(
// VOID);
// /*
// * WM_MENUDRAG return values.
// */
// #define MND_CONTINUE 0
// #define MND_ENDMENU 1
// typedef struct tagMENUGETOBJECTINFO
// {
// DWORD dwFlags;
// UINT uPos;
// HMENU hmenu;
// PVOID riid;
// PVOID pvObj;
// } MENUGETOBJECTINFO, *PMENUGETOBJECTINFO;
// /*
// * MENUGETOBJECTINFO dwFlags values
// */
// #define MNGOF_TOPGAP 0x00000001
// #define MNGOF_BOTTOMGAP 0x00000002
// /*
// * WM_MENUGETOBJECT return values
// */
// #define MNGO_NOINTERFACE 0x00000000
// #define MNGO_NOERROR 0x00000001
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0400)
// #define MIIM_STATE 0x00000001
// #define MIIM_ID 0x00000002
// #define MIIM_SUBMENU 0x00000004
// #define MIIM_CHECKMARKS 0x00000008
// #define MIIM_TYPE 0x00000010
// #define MIIM_DATA 0x00000020
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0500)
// #define MIIM_STRING 0x00000040
// #define MIIM_BITMAP 0x00000080
// #define MIIM_FTYPE 0x00000100
// #define HBMMENU_CALLBACK ((HBITMAP) -1)
// #define HBMMENU_SYSTEM ((HBITMAP) 1)
// #define HBMMENU_MBAR_RESTORE ((HBITMAP) 2)
// #define HBMMENU_MBAR_MINIMIZE ((HBITMAP) 3)
// #define HBMMENU_MBAR_CLOSE ((HBITMAP) 5)
// #define HBMMENU_MBAR_CLOSE_D ((HBITMAP) 6)
// #define HBMMENU_MBAR_MINIMIZE_D ((HBITMAP) 7)
// #define HBMMENU_POPUP_CLOSE ((HBITMAP) 8)
// #define HBMMENU_POPUP_RESTORE ((HBITMAP) 9)
// #define HBMMENU_POPUP_MAXIMIZE ((HBITMAP) 10)
// #define HBMMENU_POPUP_MINIMIZE ((HBITMAP) 11)
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0400)
// typedef struct tagMENUITEMINFOA
// {
// UINT cbSize;
// UINT fMask;
// UINT fType; // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0)
// UINT fState; // used if MIIM_STATE
// UINT wID; // used if MIIM_ID
// HMENU hSubMenu; // used if MIIM_SUBMENU
// HBITMAP hbmpChecked; // used if MIIM_CHECKMARKS
// HBITMAP hbmpUnchecked; // used if MIIM_CHECKMARKS
// ULONG_PTR dwItemData; // used if MIIM_DATA
// LPSTR dwTypeData; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
// UINT cch; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
// #if(WINVER >= 0x0500)
// HBITMAP hbmpItem; // used if MIIM_BITMAP
// #endif /* WINVER >= 0x0500 */
// } MENUITEMINFOA, FAR *LPMENUITEMINFOA;
// typedef struct tagMENUITEMINFOW
// {
// UINT cbSize;
// UINT fMask;
// UINT fType; // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0)
// UINT fState; // used if MIIM_STATE
// UINT wID; // used if MIIM_ID
// HMENU hSubMenu; // used if MIIM_SUBMENU
// HBITMAP hbmpChecked; // used if MIIM_CHECKMARKS
// HBITMAP hbmpUnchecked; // used if MIIM_CHECKMARKS
// ULONG_PTR dwItemData; // used if MIIM_DATA
// LPWSTR dwTypeData; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
// UINT cch; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
// #if(WINVER >= 0x0500)
// HBITMAP hbmpItem; // used if MIIM_BITMAP
// #endif /* WINVER >= 0x0500 */
// } MENUITEMINFOW, FAR *LPMENUITEMINFOW;
// #ifdef UNICODE
// typedef MENUITEMINFOW MENUITEMINFO;
// typedef LPMENUITEMINFOW LPMENUITEMINFO;
// #else
// typedef MENUITEMINFOA MENUITEMINFO;
// typedef LPMENUITEMINFOA LPMENUITEMINFO;
// #endif // UNICODE
// typedef MENUITEMINFOA CONST FAR *LPCMENUITEMINFOA;
// typedef MENUITEMINFOW CONST FAR *LPCMENUITEMINFOW;
// #ifdef UNICODE
// typedef LPCMENUITEMINFOW LPCMENUITEMINFO;
// #else
// typedef LPCMENUITEMINFOA LPCMENUITEMINFO;
// #endif // UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// InsertMenuItemA(
// _In_ HMENU hmenu,
// _In_ UINT item,
// _In_ BOOL fByPosition,
// _In_ LPCMENUITEMINFOA lpmi);
// WINUSERAPI
// BOOL
// WINAPI
// InsertMenuItemW(
// _In_ HMENU hmenu,
// _In_ UINT item,
// _In_ BOOL fByPosition,
// _In_ LPCMENUITEMINFOW lpmi);
// #ifdef UNICODE
// #define InsertMenuItem InsertMenuItemW
// #else
// #define InsertMenuItem InsertMenuItemA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// GetMenuItemInfoA(
// _In_ HMENU hmenu,
// _In_ UINT item,
// _In_ BOOL fByPosition,
// _Inout_ LPMENUITEMINFOA lpmii);
// WINUSERAPI
// BOOL
// WINAPI
// GetMenuItemInfoW(
// _In_ HMENU hmenu,
// _In_ UINT item,
// _In_ BOOL fByPosition,
// _Inout_ LPMENUITEMINFOW lpmii);
// #ifdef UNICODE
// #define GetMenuItemInfo GetMenuItemInfoW
// #else
// #define GetMenuItemInfo GetMenuItemInfoA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// SetMenuItemInfoA(
// _In_ HMENU hmenu,
// _In_ UINT item,
// _In_ BOOL fByPositon,
// _In_ LPCMENUITEMINFOA lpmii);
// WINUSERAPI
// BOOL
// WINAPI
// SetMenuItemInfoW(
// _In_ HMENU hmenu,
// _In_ UINT item,
// _In_ BOOL fByPositon,
// _In_ LPCMENUITEMINFOW lpmii);
// #ifdef UNICODE
// #define SetMenuItemInfo SetMenuItemInfoW
// #else
// #define SetMenuItemInfo SetMenuItemInfoA
// #endif // !UNICODE
// #define GMDI_USEDISABLED 0x0001L
// #define GMDI_GOINTOPOPUPS 0x0002L
// WINUSERAPI
// UINT
// WINAPI
// GetMenuDefaultItem(
// _In_ HMENU hMenu,
// _In_ UINT fByPos,
// _In_ UINT gmdiFlags);
// WINUSERAPI
// BOOL
// WINAPI
// SetMenuDefaultItem(
// _In_ HMENU hMenu,
// _In_ UINT uItem,
// _In_ UINT fByPos);
// WINUSERAPI
// BOOL
// WINAPI
// GetMenuItemRect(
// _In_opt_ HWND hWnd,
// _In_ HMENU hMenu,
// _In_ UINT uItem,
// _Out_ LPRECT lprcItem);
// WINUSERAPI
// int
// WINAPI
// MenuItemFromPoint(
// _In_opt_ HWND hWnd,
// _In_ HMENU hMenu,
// _In_ POINT ptScreen);
// #endif /* WINVER >= 0x0400 */
// /*
// * Flags for TrackPopupMenu
// */
// #define TPM_LEFTBUTTON 0x0000L
// #define TPM_RIGHTBUTTON 0x0002L
// #define TPM_LEFTALIGN 0x0000L
// #define TPM_CENTERALIGN 0x0004L
// #define TPM_RIGHTALIGN 0x0008L
// #if(WINVER >= 0x0400)
// #define TPM_TOPALIGN 0x0000L
// #define TPM_VCENTERALIGN 0x0010L
// #define TPM_BOTTOMALIGN 0x0020L
// #define TPM_HORIZONTAL 0x0000L /* Horz alignment matters more */
// #define TPM_VERTICAL 0x0040L /* Vert alignment matters more */
// #define TPM_NONOTIFY 0x0080L /* Don't send any notification msgs */
// #define TPM_RETURNCMD 0x0100L
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0500)
// #define TPM_RECURSE 0x0001L
// #define TPM_HORPOSANIMATION 0x0400L
// #define TPM_HORNEGANIMATION 0x0800L
// #define TPM_VERPOSANIMATION 0x1000L
// #define TPM_VERNEGANIMATION 0x2000L
// #if(_WIN32_WINNT >= 0x0500)
// #define TPM_NOANIMATION 0x4000L
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0501)
// #define TPM_LAYOUTRTL 0x8000L
// #endif /* _WIN32_WINNT >= 0x0501 */
// #endif /* WINVER >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0601)
// #define TPM_WORKAREA 0x10000L
// #endif /* _WIN32_WINNT >= 0x0601 */
// #endif /* !NOMENUS */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0400)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// //
// // Drag-and-drop support
// // Obsolete - use OLE instead
// //
// typedef struct tagDROPSTRUCT
// {
// HWND hwndSource;
// HWND hwndSink;
// DWORD wFmt;
// ULONG_PTR dwData;
// POINT ptDrop;
// DWORD dwControlData;
// } DROPSTRUCT, *PDROPSTRUCT, *LPDROPSTRUCT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define DOF_EXECUTABLE 0x8001 // wFmt flags
// #define DOF_DOCUMENT 0x8002
// #define DOF_DIRECTORY 0x8003
// #define DOF_MULTIPLE 0x8004
// #define DOF_PROGMAN 0x0001
// #define DOF_SHELLDATA 0x0002
// #define DO_DROPFILE 0x454C4946L
// #define DO_PRINTFILE 0x544E5250L
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// DWORD
// WINAPI
// DragObject(
// _In_ HWND hwndParent,
// _In_ HWND hwndFrom,
// _In_ UINT fmt,
// _In_ ULONG_PTR data,
// _In_opt_ HCURSOR hcur);
// WINUSERAPI
// BOOL
// WINAPI
// DragDetect(
// _In_ HWND hwnd,
// _In_ POINT pt);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// DrawIcon(
// _In_ HDC hDC,
// _In_ int X,
// _In_ int Y,
// _In_ HICON hIcon);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NODRAWTEXT
// /*
// * DrawText() Format Flags
// */
// #define DT_TOP 0x00000000
// #define DT_LEFT 0x00000000
// #define DT_CENTER 0x00000001
// #define DT_RIGHT 0x00000002
// #define DT_VCENTER 0x00000004
// #define DT_BOTTOM 0x00000008
// #define DT_WORDBREAK 0x00000010
// #define DT_SINGLELINE 0x00000020
// #define DT_EXPANDTABS 0x00000040
// #define DT_TABSTOP 0x00000080
// #define DT_NOCLIP 0x00000100
// #define DT_EXTERNALLEADING 0x00000200
// #define DT_CALCRECT 0x00000400
// #define DT_NOPREFIX 0x00000800
// #define DT_INTERNAL 0x00001000
// #if(WINVER >= 0x0400)
// #define DT_EDITCONTROL 0x00002000
// #define DT_PATH_ELLIPSIS 0x00004000
// #define DT_END_ELLIPSIS 0x00008000
// #define DT_MODIFYSTRING 0x00010000
// #define DT_RTLREADING 0x00020000
// #define DT_WORD_ELLIPSIS 0x00040000
// #if(WINVER >= 0x0500)
// #define DT_NOFULLWIDTHCHARBREAK 0x00080000
// #if(_WIN32_WINNT >= 0x0500)
// #define DT_HIDEPREFIX 0x00100000
// #define DT_PREFIXONLY 0x00200000
// #endif /* _WIN32_WINNT >= 0x0500 */
// #endif /* WINVER >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagDRAWTEXTPARAMS
// {
// UINT cbSize;
// int iTabLength;
// int iLeftMargin;
// int iRightMargin;
// UINT uiLengthDrawn;
// } DRAWTEXTPARAMS, FAR *LPDRAWTEXTPARAMS;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #define _In_bypassable_reads_or_z_(size) \
// _When_(((size) == -1) || (_String_length_(_Curr_) < (size)), _In_z_) \
// _When_(((size) != -1) && (_String_length_(_Curr_) >= (size)), _In_reads_(size))
// #define _Inout_grows_updates_bypassable_or_z_(size, grows) \
// _When_(((size) == -1) || (_String_length_(_Curr_) < (size)), _Pre_z_ _Pre_valid_ _Out_writes_z_(_String_length_(_Curr_) + (grows))) \
// _When_(((size) != -1) && (_String_length_(_Curr_) >= (size)), _Pre_count_(size) _Pre_valid_ _Out_writes_z_((size) + (grows)))
// WINUSERAPI
// _Success_(return)
// int
// WINAPI
// DrawTextA(
// _In_ HDC hdc,
// _When_((format & DT_MODIFYSTRING), _At_((LPSTR)lpchText, _Inout_grows_updates_bypassable_or_z_(cchText, 4)))
// _When_((!(format & DT_MODIFYSTRING)), _In_bypassable_reads_or_z_(cchText))
// LPCSTR lpchText,
// _In_ int cchText,
// _Inout_ LPRECT lprc,
// _In_ UINT format);
// WINUSERAPI
// _Success_(return)
// int
// WINAPI
// DrawTextW(
// _In_ HDC hdc,
// _When_((format & DT_MODIFYSTRING), _At_((LPWSTR)lpchText, _Inout_grows_updates_bypassable_or_z_(cchText, 4)))
// _When_((!(format & DT_MODIFYSTRING)), _In_bypassable_reads_or_z_(cchText))
// LPCWSTR lpchText,
// _In_ int cchText,
// _Inout_ LPRECT lprc,
// _In_ UINT format);
// #ifdef UNICODE
// #define DrawText DrawTextW
// #else
// #define DrawText DrawTextA
// #endif // !UNICODE
// #if defined(_M_CEE)
// #undef DrawText
// __inline
// int
// DrawText(
// HDC hdc,
// LPCTSTR lpchText,
// int cchText,
// LPRECT lprc,
// UINT format
// )
// {
// #ifdef UNICODE
// return DrawTextW(
// #else
// return DrawTextA(
// #endif
// hdc,
// lpchText,
// cchText,
// lprc,
// format
// );
// }
// #endif /* _M_CEE */
// #if(WINVER >= 0x0400)
// WINUSERAPI
// _Success_(return)
// int
// WINAPI
// DrawTextExA(
// _In_ HDC hdc,
// _When_((cchText) < -1, _Unreferenced_parameter_)
// _When_((format & DT_MODIFYSTRING), _Inout_grows_updates_bypassable_or_z_(cchText, 4))
// _When_((!(format & DT_MODIFYSTRING)), _At_((LPCSTR)lpchText, _In_bypassable_reads_or_z_(cchText)))
// LPSTR lpchText,
// _In_ int cchText,
// _Inout_ LPRECT lprc,
// _In_ UINT format,
// _In_opt_ LPDRAWTEXTPARAMS lpdtp);
// WINUSERAPI
// _Success_(return)
// int
// WINAPI
// DrawTextExW(
// _In_ HDC hdc,
// _When_((cchText) < -1, _Unreferenced_parameter_)
// _When_((format & DT_MODIFYSTRING), _Inout_grows_updates_bypassable_or_z_(cchText, 4))
// _When_((!(format & DT_MODIFYSTRING)), _At_((LPCWSTR)lpchText, _In_bypassable_reads_or_z_(cchText)))
// LPWSTR lpchText,
// _In_ int cchText,
// _Inout_ LPRECT lprc,
// _In_ UINT format,
// _In_opt_ LPDRAWTEXTPARAMS lpdtp);
// #ifdef UNICODE
// #define DrawTextEx DrawTextExW
// #else
// #define DrawTextEx DrawTextExA
// #endif // !UNICODE
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NODRAWTEXT */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// GrayStringA(
// _In_ HDC hDC,
// _In_opt_ HBRUSH hBrush,
// _In_opt_ GRAYSTRINGPROC lpOutputFunc,
// _In_ LPARAM lpData,
// _In_ int nCount,
// _In_ int X,
// _In_ int Y,
// _In_ int nWidth,
// _In_ int nHeight);
// WINUSERAPI
// BOOL
// WINAPI
// GrayStringW(
// _In_ HDC hDC,
// _In_opt_ HBRUSH hBrush,
// _In_opt_ GRAYSTRINGPROC lpOutputFunc,
// _In_ LPARAM lpData,
// _In_ int nCount,
// _In_ int X,
// _In_ int Y,
// _In_ int nWidth,
// _In_ int nHeight);
// #ifdef UNICODE
// #define GrayString GrayStringW
// #else
// #define GrayString GrayStringA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0400)
// /* Monolithic state-drawing routine */
// /* Image type */
// #define DST_COMPLEX 0x0000
// #define DST_TEXT 0x0001
// #define DST_PREFIXTEXT 0x0002
// #define DST_ICON 0x0003
// #define DST_BITMAP 0x0004
// /* State type */
// #define DSS_NORMAL 0x0000
// #define DSS_UNION 0x0010 /* Gray string appearance */
// #define DSS_DISABLED 0x0020
// #define DSS_MONO 0x0080
// #if(_WIN32_WINNT >= 0x0500)
// #define DSS_HIDEPREFIX 0x0200
// #define DSS_PREFIXONLY 0x0400
// #endif /* _WIN32_WINNT >= 0x0500 */
// #define DSS_RIGHT 0x8000
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// DrawStateA(
// _In_ HDC hdc,
// _In_opt_ HBRUSH hbrFore,
// _In_opt_ DRAWSTATEPROC qfnCallBack,
// _In_ LPARAM lData,
// _In_ WPARAM wData,
// _In_ int x,
// _In_ int y,
// _In_ int cx,
// _In_ int cy,
// _In_ UINT uFlags);
// WINUSERAPI
// BOOL
// WINAPI
// DrawStateW(
// _In_ HDC hdc,
// _In_opt_ HBRUSH hbrFore,
// _In_opt_ DRAWSTATEPROC qfnCallBack,
// _In_ LPARAM lData,
// _In_ WPARAM wData,
// _In_ int x,
// _In_ int y,
// _In_ int cx,
// _In_ int cy,
// _In_ UINT uFlags);
// #ifdef UNICODE
// #define DrawState DrawStateW
// #else
// #define DrawState DrawStateA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// LONG
// WINAPI
// TabbedTextOutA(
// _In_ HDC hdc,
// _In_ int x,
// _In_ int y,
// _In_reads_(chCount) LPCSTR lpString,
// _In_ int chCount,
// _In_ int nTabPositions,
// _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions,
// _In_ int nTabOrigin);
// WINUSERAPI
// LONG
// WINAPI
// TabbedTextOutW(
// _In_ HDC hdc,
// _In_ int x,
// _In_ int y,
// _In_reads_(chCount) LPCWSTR lpString,
// _In_ int chCount,
// _In_ int nTabPositions,
// _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions,
// _In_ int nTabOrigin);
// #ifdef UNICODE
// #define TabbedTextOut TabbedTextOutW
// #else
// #define TabbedTextOut TabbedTextOutA
// #endif // !UNICODE
// WINUSERAPI
// DWORD
// WINAPI
// GetTabbedTextExtentA(
// _In_ HDC hdc,
// _In_reads_(chCount) LPCSTR lpString,
// _In_ int chCount,
// _In_ int nTabPositions,
// _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions);
// WINUSERAPI
// DWORD
// WINAPI
// GetTabbedTextExtentW(
// _In_ HDC hdc,
// _In_reads_(chCount) LPCWSTR lpString,
// _In_ int chCount,
// _In_ int nTabPositions,
// _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions);
// #ifdef UNICODE
// #define GetTabbedTextExtent GetTabbedTextExtentW
// #else
// #define GetTabbedTextExtent GetTabbedTextExtentA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// UpdateWindow(
// _In_ HWND hWnd);
// WINUSERAPI
// HWND
// WINAPI
// SetActiveWindow(
// _In_ HWND hWnd);
// WINUSERAPI
// HWND
// WINAPI
// GetForegroundWindow(
// VOID);
// #if(WINVER >= 0x0400)
// WINUSERAPI
// BOOL
// WINAPI
// PaintDesktop(
// _In_ HDC hdc);
// WINUSERAPI
// VOID
// WINAPI
// SwitchToThisWindow(
// _In_ HWND hwnd,
// _In_ BOOL fUnknown);
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// BOOL
// WINAPI
// SetForegroundWindow(
// _In_ HWND hWnd);
// #if(_WIN32_WINNT >= 0x0500)
// WINUSERAPI
// BOOL
// WINAPI
// AllowSetForegroundWindow(
// _In_ DWORD dwProcessId);
// #define ASFW_ANY ((DWORD)-1)
// WINUSERAPI
// BOOL
// WINAPI
// LockSetForegroundWindow(
// _In_ UINT uLockCode);
// #define LSFW_LOCK 1
// #define LSFW_UNLOCK 2
// #endif /* _WIN32_WINNT >= 0x0500 */
// WINUSERAPI
// HWND
// WINAPI
// WindowFromDC(
// _In_ HDC hDC);
// WINUSERAPI
// HDC
// WINAPI
// GetDC(
// _In_opt_ HWND hWnd);
// WINUSERAPI
// HDC
// WINAPI
// GetDCEx(
// _In_opt_ HWND hWnd,
// _In_opt_ HRGN hrgnClip,
// _In_ DWORD flags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * GetDCEx() flags
// */
// #define DCX_WINDOW 0x00000001L
// #define DCX_CACHE 0x00000002L
// #define DCX_NORESETATTRS 0x00000004L
// #define DCX_CLIPCHILDREN 0x00000008L
// #define DCX_CLIPSIBLINGS 0x00000010L
// #define DCX_PARENTCLIP 0x00000020L
// #define DCX_EXCLUDERGN 0x00000040L
// #define DCX_INTERSECTRGN 0x00000080L
// #define DCX_EXCLUDEUPDATE 0x00000100L
// #define DCX_INTERSECTUPDATE 0x00000200L
// #define DCX_LOCKWINDOWUPDATE 0x00000400L
// #define DCX_VALIDATE 0x00200000L
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HDC
// WINAPI
// GetWindowDC(
// _In_opt_ HWND hWnd);
// WINUSERAPI
// int
// WINAPI
// ReleaseDC(
// _In_opt_ HWND hWnd,
// _In_ HDC hDC);
// WINUSERAPI
// HDC
// WINAPI
// BeginPaint(
// _In_ HWND hWnd,
// _Out_ LPPAINTSTRUCT lpPaint);
// WINUSERAPI
// BOOL
// WINAPI
// EndPaint(
// _In_ HWND hWnd,
// _In_ CONST PAINTSTRUCT *lpPaint);
// WINUSERAPI
// BOOL
// WINAPI
// GetUpdateRect(
// _In_ HWND hWnd,
// _Out_opt_ LPRECT lpRect,
// _In_ BOOL bErase);
// WINUSERAPI
// int
// WINAPI
// GetUpdateRgn(
// _In_ HWND hWnd,
// _In_ HRGN hRgn,
// _In_ BOOL bErase);
// WINUSERAPI
// int
// WINAPI
// SetWindowRgn(
// _In_ HWND hWnd,
// _In_opt_ HRGN hRgn,
// _In_ BOOL bRedraw);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// int
// WINAPI
// GetWindowRgn(
// _In_ HWND hWnd,
// _In_ HRGN hRgn);
// #if(_WIN32_WINNT >= 0x0501)
// WINUSERAPI
// int
// WINAPI
// GetWindowRgnBox(
// _In_ HWND hWnd,
// _Out_ LPRECT lprc);
// #endif /* _WIN32_WINNT >= 0x0501 */
// WINUSERAPI
// int
// WINAPI
// ExcludeUpdateRgn(
// _In_ HDC hDC,
// _In_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// InvalidateRect(
// _In_opt_ HWND hWnd,
// _In_opt_ CONST RECT *lpRect,
// _In_ BOOL bErase);
// WINUSERAPI
// BOOL
// WINAPI
// ValidateRect(
// _In_opt_ HWND hWnd,
// _In_opt_ CONST RECT *lpRect);
// WINUSERAPI
// BOOL
// WINAPI
// InvalidateRgn(
// _In_ HWND hWnd,
// _In_opt_ HRGN hRgn,
// _In_ BOOL bErase);
// WINUSERAPI
// BOOL
// WINAPI
// ValidateRgn(
// _In_ HWND hWnd,
// _In_opt_ HRGN hRgn);
// WINUSERAPI
// BOOL
// WINAPI
// RedrawWindow(
// _In_opt_ HWND hWnd,
// _In_opt_ CONST RECT *lprcUpdate,
// _In_opt_ HRGN hrgnUpdate,
// _In_ UINT flags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * RedrawWindow() flags
// */
// #define RDW_INVALIDATE 0x0001
// #define RDW_INTERNALPAINT 0x0002
// #define RDW_ERASE 0x0004
// #define RDW_VALIDATE 0x0008
// #define RDW_NOINTERNALPAINT 0x0010
// #define RDW_NOERASE 0x0020
// #define RDW_NOCHILDREN 0x0040
// #define RDW_ALLCHILDREN 0x0080
// #define RDW_UPDATENOW 0x0100
// #define RDW_ERASENOW 0x0200
// #define RDW_FRAME 0x0400
// #define RDW_NOFRAME 0x0800
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * LockWindowUpdate API
// */
// WINUSERAPI
// BOOL
// WINAPI
// LockWindowUpdate(
// _In_opt_ HWND hWndLock);
// WINUSERAPI
// BOOL
// WINAPI
// ScrollWindow(
// _In_ HWND hWnd,
// _In_ int XAmount,
// _In_ int YAmount,
// _In_opt_ CONST RECT *lpRect,
// _In_opt_ CONST RECT *lpClipRect);
// WINUSERAPI
// BOOL
// WINAPI
// ScrollDC(
// _In_ HDC hDC,
// _In_ int dx,
// _In_ int dy,
// _In_opt_ CONST RECT *lprcScroll,
// _In_opt_ CONST RECT *lprcClip,
// _In_opt_ HRGN hrgnUpdate,
// _Out_opt_ LPRECT lprcUpdate);
// WINUSERAPI
// int
// WINAPI
// ScrollWindowEx(
// _In_ HWND hWnd,
// _In_ int dx,
// _In_ int dy,
// _In_opt_ CONST RECT *prcScroll,
// _In_opt_ CONST RECT *prcClip,
// _In_opt_ HRGN hrgnUpdate,
// _Out_opt_ LPRECT prcUpdate,
// _In_ UINT flags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define SW_SCROLLCHILDREN 0x0001 /* Scroll children within *lprcScroll. */
// #define SW_INVALIDATE 0x0002 /* Invalidate after scrolling */
// #define SW_ERASE 0x0004 /* If SW_INVALIDATE, don't send WM_ERASEBACKGROUND */
// #if(WINVER >= 0x0500)
// #define SW_SMOOTHSCROLL 0x0010 /* Use smooth scrolling */
// #endif /* WINVER >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #ifndef NOSCROLL
// WINUSERAPI
// int
// WINAPI
// SetScrollPos(
// _In_ HWND hWnd,
// _In_ int nBar,
// _In_ int nPos,
// _In_ BOOL bRedraw);
// WINUSERAPI
// int
// WINAPI
// GetScrollPos(
// _In_ HWND hWnd,
// _In_ int nBar);
// WINUSERAPI
// BOOL
// WINAPI
// SetScrollRange(
// _In_ HWND hWnd,
// _In_ int nBar,
// _In_ int nMinPos,
// _In_ int nMaxPos,
// _In_ BOOL bRedraw);
// WINUSERAPI
// BOOL
// WINAPI
// GetScrollRange(
// _In_ HWND hWnd,
// _In_ int nBar,
// _Out_ LPINT lpMinPos,
// _Out_ LPINT lpMaxPos);
// WINUSERAPI
// BOOL
// WINAPI
// ShowScrollBar(
// _In_ HWND hWnd,
// _In_ int wBar,
// _In_ BOOL bShow);
// WINUSERAPI
// BOOL
// WINAPI
// EnableScrollBar(
// _In_ HWND hWnd,
// _In_ UINT wSBflags,
// _In_ UINT wArrows);
// /*
// * EnableScrollBar() flags
// */
// #define ESB_ENABLE_BOTH 0x0000
// #define ESB_DISABLE_BOTH 0x0003
// #define ESB_DISABLE_LEFT 0x0001
// #define ESB_DISABLE_RIGHT 0x0002
// #define ESB_DISABLE_UP 0x0001
// #define ESB_DISABLE_DOWN 0x0002
// #define ESB_DISABLE_LTUP ESB_DISABLE_LEFT
// #define ESB_DISABLE_RTDN ESB_DISABLE_RIGHT
// #endif /* !NOSCROLL */
// WINUSERAPI
// BOOL
// WINAPI
// SetPropA(
// _In_ HWND hWnd,
// _In_ LPCSTR lpString,
// _In_opt_ HANDLE hData);
// WINUSERAPI
// BOOL
// WINAPI
// SetPropW(
// _In_ HWND hWnd,
// _In_ LPCWSTR lpString,
// _In_opt_ HANDLE hData);
// #ifdef UNICODE
// #define SetProp SetPropW
// #else
// #define SetProp SetPropA
// #endif // !UNICODE
// WINUSERAPI
// HANDLE
// WINAPI
// GetPropA(
// _In_ HWND hWnd,
// _In_ LPCSTR lpString);
// WINUSERAPI
// HANDLE
// WINAPI
// GetPropW(
// _In_ HWND hWnd,
// _In_ LPCWSTR lpString);
// #ifdef UNICODE
// #define GetProp GetPropW
// #else
// #define GetProp GetPropA
// #endif // !UNICODE
// WINUSERAPI
// HANDLE
// WINAPI
// RemovePropA(
// _In_ HWND hWnd,
// _In_ LPCSTR lpString);
// WINUSERAPI
// HANDLE
// WINAPI
// RemovePropW(
// _In_ HWND hWnd,
// _In_ LPCWSTR lpString);
// #ifdef UNICODE
// #define RemoveProp RemovePropW
// #else
// #define RemoveProp RemovePropA
// #endif // !UNICODE
// WINUSERAPI
// int
// WINAPI
// EnumPropsExA(
// _In_ HWND hWnd,
// _In_ PROPENUMPROCEXA lpEnumFunc,
// _In_ LPARAM lParam);
// WINUSERAPI
// int
// WINAPI
// EnumPropsExW(
// _In_ HWND hWnd,
// _In_ PROPENUMPROCEXW lpEnumFunc,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define EnumPropsEx EnumPropsExW
// #else
// #define EnumPropsEx EnumPropsExA
// #endif // !UNICODE
// WINUSERAPI
// int
// WINAPI
// EnumPropsA(
// _In_ HWND hWnd,
// _In_ PROPENUMPROCA lpEnumFunc);
// WINUSERAPI
// int
// WINAPI
// EnumPropsW(
// _In_ HWND hWnd,
// _In_ PROPENUMPROCW lpEnumFunc);
// #ifdef UNICODE
// #define EnumProps EnumPropsW
// #else
// #define EnumProps EnumPropsA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// SetWindowTextA(
// _In_ HWND hWnd,
// _In_opt_ LPCSTR lpString);
// WINUSERAPI
// BOOL
// WINAPI
// SetWindowTextW(
// _In_ HWND hWnd,
// _In_opt_ LPCWSTR lpString);
// #ifdef UNICODE
// #define SetWindowText SetWindowTextW
// #else
// #define SetWindowText SetWindowTextA
// #endif // !UNICODE
// _Ret_range_(0, nMaxCount)
// WINUSERAPI
// int
// WINAPI
// GetWindowTextA(
// _In_ HWND hWnd,
// _Out_writes_(nMaxCount) LPSTR lpString,
// _In_ int nMaxCount);
// _Ret_range_(0, nMaxCount)
// WINUSERAPI
// int
// WINAPI
// GetWindowTextW(
// _In_ HWND hWnd,
// _Out_writes_(nMaxCount) LPWSTR lpString,
// _In_ int nMaxCount);
// #ifdef UNICODE
// #define GetWindowText GetWindowTextW
// #else
// #define GetWindowText GetWindowTextA
// #endif // !UNICODE
// WINUSERAPI
// int
// WINAPI
// GetWindowTextLengthA(
// _In_ HWND hWnd);
// WINUSERAPI
// int
// WINAPI
// GetWindowTextLengthW(
// _In_ HWND hWnd);
// #ifdef UNICODE
// #define GetWindowTextLength GetWindowTextLengthW
// #else
// #define GetWindowTextLength GetWindowTextLengthA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// GetClientRect(
// _In_ HWND hWnd,
// _Out_ LPRECT lpRect);
// WINUSERAPI
// BOOL
// WINAPI
// GetWindowRect(
// _In_ HWND hWnd,
// _Out_ LPRECT lpRect);
// WINUSERAPI
// BOOL
// WINAPI
// AdjustWindowRect(
// _Inout_ LPRECT lpRect,
// _In_ DWORD dwStyle,
// _In_ BOOL bMenu);
// WINUSERAPI
// BOOL
// WINAPI
// AdjustWindowRectEx(
// _Inout_ LPRECT lpRect,
// _In_ DWORD dwStyle,
// _In_ BOOL bMenu,
// _In_ DWORD dwExStyle);
// #if(WINVER >= 0x0605)
// WINUSERAPI
// BOOL
// WINAPI
// AdjustWindowRectExForDpi(
// _Inout_ LPRECT lpRect,
// _In_ DWORD dwStyle,
// _In_ BOOL bMenu,
// _In_ DWORD dwExStyle,
// _In_ UINT dpi);
// #endif /* WINVER >= 0x0605 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0400)
// #define HELPINFO_WINDOW 0x0001
// #define HELPINFO_MENUITEM 0x0002
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagHELPINFO /* Structure pointed to by lParam of WM_HELP */
// {
// UINT cbSize; /* Size in bytes of this struct */
// int iContextType; /* Either HELPINFO_WINDOW or HELPINFO_MENUITEM */
// int iCtrlId; /* Control Id or a Menu item Id. */
// HANDLE hItemHandle; /* hWnd of control or hMenu. */
// DWORD_PTR dwContextId; /* Context Id associated with this item */
// POINT MousePos; /* Mouse Position in screen co-ordinates */
// } HELPINFO, FAR *LPHELPINFO;
// WINUSERAPI
// BOOL
// WINAPI
// SetWindowContextHelpId(
// _In_ HWND,
// _In_ DWORD);
// WINUSERAPI
// DWORD
// WINAPI
// GetWindowContextHelpId(
// _In_ HWND);
// WINUSERAPI
// BOOL
// WINAPI
// SetMenuContextHelpId(
// _In_ HMENU,
// _In_ DWORD);
// WINUSERAPI
// DWORD
// WINAPI
// GetMenuContextHelpId(
// _In_ HMENU);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// #ifndef NOMB
// /*
// * MessageBox() Flags
// */
// #define MB_OK 0x00000000L
// #define MB_OKCANCEL 0x00000001L
// #define MB_ABORTRETRYIGNORE 0x00000002L
// #define MB_YESNOCANCEL 0x00000003L
// #define MB_YESNO 0x00000004L
// #define MB_RETRYCANCEL 0x00000005L
// #if(WINVER >= 0x0500)
// #define MB_CANCELTRYCONTINUE 0x00000006L
// #endif /* WINVER >= 0x0500 */
// #define MB_ICONHAND 0x00000010L
// #define MB_ICONQUESTION 0x00000020L
// #define MB_ICONEXCLAMATION 0x00000030L
// #define MB_ICONASTERISK 0x00000040L
// #if(WINVER >= 0x0400)
// #define MB_USERICON 0x00000080L
// #define MB_ICONWARNING MB_ICONEXCLAMATION
// #define MB_ICONERROR MB_ICONHAND
// #endif /* WINVER >= 0x0400 */
// #define MB_ICONINFORMATION MB_ICONASTERISK
// #define MB_ICONSTOP MB_ICONHAND
// #define MB_DEFBUTTON1 0x00000000L
// #define MB_DEFBUTTON2 0x00000100L
// #define MB_DEFBUTTON3 0x00000200L
// #if(WINVER >= 0x0400)
// #define MB_DEFBUTTON4 0x00000300L
// #endif /* WINVER >= 0x0400 */
// #define MB_APPLMODAL 0x00000000L
// #define MB_SYSTEMMODAL 0x00001000L
// #define MB_TASKMODAL 0x00002000L
// #if(WINVER >= 0x0400)
// #define MB_HELP 0x00004000L // Help Button
// #endif /* WINVER >= 0x0400 */
// #define MB_NOFOCUS 0x00008000L
// #define MB_SETFOREGROUND 0x00010000L
// #define MB_DEFAULT_DESKTOP_ONLY 0x00020000L
// #if(WINVER >= 0x0400)
// #define MB_TOPMOST 0x00040000L
// #define MB_RIGHT 0x00080000L
// #define MB_RTLREADING 0x00100000L
// #endif /* WINVER >= 0x0400 */
// #ifdef _WIN32_WINNT
// #if (_WIN32_WINNT >= 0x0400)
// #define MB_SERVICE_NOTIFICATION 0x00200000L
// #else
// #define MB_SERVICE_NOTIFICATION 0x00040000L
// #endif
// #define MB_SERVICE_NOTIFICATION_NT3X 0x00040000L
// #endif
// #define MB_TYPEMASK 0x0000000FL
// #define MB_ICONMASK 0x000000F0L
// #define MB_DEFMASK 0x00000F00L
// #define MB_MODEMASK 0x00003000L
// #define MB_MISCMASK 0x0000C000L
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// int
// WINAPI
// MessageBoxA(
// _In_opt_ HWND hWnd,
// _In_opt_ LPCSTR lpText,
// _In_opt_ LPCSTR lpCaption,
// _In_ UINT uType);
// WINUSERAPI
// int
// WINAPI
// MessageBoxW(
// _In_opt_ HWND hWnd,
// _In_opt_ LPCWSTR lpText,
// _In_opt_ LPCWSTR lpCaption,
// _In_ UINT uType);
// #ifdef UNICODE
// #define MessageBox MessageBoxW
// #else
// #define MessageBox MessageBoxA
// #endif // !UNICODE
// #if defined(_M_CEE)
// #undef MessageBox
// __inline
// int
// MessageBox(
// HWND hWnd,
// LPCTSTR lpText,
// LPCTSTR lpCaption,
// UINT uType
// )
// {
// #ifdef UNICODE
// return MessageBoxW(
// #else
// return MessageBoxA(
// #endif
// hWnd,
// lpText,
// lpCaption,
// uType
// );
// }
// #endif /* _M_CEE */
// WINUSERAPI
// int
// WINAPI
// MessageBoxExA(
// _In_opt_ HWND hWnd,
// _In_opt_ LPCSTR lpText,
// _In_opt_ LPCSTR lpCaption,
// _In_ UINT uType,
// _In_ WORD wLanguageId);
// WINUSERAPI
// int
// WINAPI
// MessageBoxExW(
// _In_opt_ HWND hWnd,
// _In_opt_ LPCWSTR lpText,
// _In_opt_ LPCWSTR lpCaption,
// _In_ UINT uType,
// _In_ WORD wLanguageId);
// #ifdef UNICODE
// #define MessageBoxEx MessageBoxExW
// #else
// #define MessageBoxEx MessageBoxExA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// typedef VOID(CALLBACK *MSGBOXCALLBACK)(LPHELPINFO lpHelpInfo);
// typedef struct tagMSGBOXPARAMSA
// {
// UINT cbSize;
// HWND hwndOwner;
// HINSTANCE hInstance;
// LPCSTR lpszText;
// LPCSTR lpszCaption;
// DWORD dwStyle;
// LPCSTR lpszIcon;
// DWORD_PTR dwContextHelpId;
// MSGBOXCALLBACK lpfnMsgBoxCallback;
// DWORD dwLanguageId;
// } MSGBOXPARAMSA, *PMSGBOXPARAMSA, *LPMSGBOXPARAMSA;
// typedef struct tagMSGBOXPARAMSW
// {
// UINT cbSize;
// HWND hwndOwner;
// HINSTANCE hInstance;
// LPCWSTR lpszText;
// LPCWSTR lpszCaption;
// DWORD dwStyle;
// LPCWSTR lpszIcon;
// DWORD_PTR dwContextHelpId;
// MSGBOXCALLBACK lpfnMsgBoxCallback;
// DWORD dwLanguageId;
// } MSGBOXPARAMSW, *PMSGBOXPARAMSW, *LPMSGBOXPARAMSW;
// #ifdef UNICODE
// typedef MSGBOXPARAMSW MSGBOXPARAMS;
// typedef PMSGBOXPARAMSW PMSGBOXPARAMS;
// typedef LPMSGBOXPARAMSW LPMSGBOXPARAMS;
// #else
// typedef MSGBOXPARAMSA MSGBOXPARAMS;
// typedef PMSGBOXPARAMSA PMSGBOXPARAMS;
// typedef LPMSGBOXPARAMSA LPMSGBOXPARAMS;
// #endif // UNICODE
// WINUSERAPI
// int
// WINAPI
// MessageBoxIndirectA(
// _In_ CONST MSGBOXPARAMSA * lpmbp);
// WINUSERAPI
// int
// WINAPI
// MessageBoxIndirectW(
// _In_ CONST MSGBOXPARAMSW * lpmbp);
// #ifdef UNICODE
// #define MessageBoxIndirect MessageBoxIndirectW
// #else
// #define MessageBoxIndirect MessageBoxIndirectA
// #endif // !UNICODE
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// MessageBeep(
// _In_ UINT uType);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOMB */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// int
// WINAPI
// ShowCursor(
// _In_ BOOL bShow);
// WINUSERAPI
// BOOL
// WINAPI
// SetCursorPos(
// _In_ int X,
// _In_ int Y);
// #if(WINVER >= 0x0600)
// WINUSERAPI
// BOOL
// WINAPI
// SetPhysicalCursorPos(
// _In_ int X,
// _In_ int Y);
// #endif /* WINVER >= 0x0600 */
// WINUSERAPI
// HCURSOR
// WINAPI
// SetCursor(
// _In_opt_ HCURSOR hCursor);
// WINUSERAPI
// BOOL
// WINAPI
// GetCursorPos(
// _Out_ LPPOINT lpPoint);
// #if(WINVER >= 0x0600)
// WINUSERAPI
// BOOL
// WINAPI
// GetPhysicalCursorPos(
// _Out_ LPPOINT lpPoint);
// #endif /* WINVER >= 0x0600 */
// WINUSERAPI
// BOOL
// WINAPI
// GetClipCursor(
// _Out_ LPRECT lpRect);
// WINUSERAPI
// HCURSOR
// WINAPI
// GetCursor(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// CreateCaret(
// _In_ HWND hWnd,
// _In_opt_ HBITMAP hBitmap,
// _In_ int nWidth,
// _In_ int nHeight);
// WINUSERAPI
// UINT
// WINAPI
// GetCaretBlinkTime(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// SetCaretBlinkTime(
// _In_ UINT uMSeconds);
// WINUSERAPI
// BOOL
// WINAPI
// DestroyCaret(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// HideCaret(
// _In_opt_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// ShowCaret(
// _In_opt_ HWND hWnd);
// WINUSERAPI
// BOOL
// WINAPI
// SetCaretPos(
// _In_ int X,
// _In_ int Y);
// WINUSERAPI
// BOOL
// WINAPI
// GetCaretPos(
// _Out_ LPPOINT lpPoint);
// WINUSERAPI
// BOOL
// WINAPI
// ClientToScreen(
// _In_ HWND hWnd,
// _Inout_ LPPOINT lpPoint);
// WINUSERAPI
// BOOL
// WINAPI
// ScreenToClient(
// _In_ HWND hWnd,
// _Inout_ LPPOINT lpPoint);
// #if(WINVER >= 0x0600)
// WINUSERAPI
// BOOL
// WINAPI
// LogicalToPhysicalPoint(
// _In_ HWND hWnd,
// _Inout_ LPPOINT lpPoint);
// WINUSERAPI
// BOOL
// WINAPI
// PhysicalToLogicalPoint(
// _In_ HWND hWnd,
// _Inout_ LPPOINT lpPoint);
// #endif /* WINVER >= 0x0600 */
// #if(WINVER >= 0x0603)
// WINUSERAPI
// BOOL
// WINAPI
// LogicalToPhysicalPointForPerMonitorDPI(
// _In_opt_ HWND hWnd,
// _Inout_ LPPOINT lpPoint);
// WINUSERAPI
// BOOL
// WINAPI
// PhysicalToLogicalPointForPerMonitorDPI(
// _In_opt_ HWND hWnd,
// _Inout_ LPPOINT lpPoint);
// #endif /* WINVER >= 0x0603 */
// WINUSERAPI
// int
// WINAPI
// MapWindowPoints(
// _In_opt_ HWND hWndFrom,
// _In_opt_ HWND hWndTo,
// _Inout_updates_(cPoints) LPPOINT lpPoints,
// _In_ UINT cPoints);
// WINUSERAPI
// HWND
// WINAPI
// WindowFromPoint(
// _In_ POINT Point);
// #if(WINVER >= 0x0600)
// WINUSERAPI
// HWND
// WINAPI
// WindowFromPhysicalPoint(
// _In_ POINT Point);
// #endif /* WINVER >= 0x0600 */
// WINUSERAPI
// HWND
// WINAPI
// ChildWindowFromPoint(
// _In_ HWND hWndParent,
// _In_ POINT Point);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Desktop or PC Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP)
// WINUSERAPI
// BOOL
// WINAPI
// ClipCursor(
// _In_opt_ CONST RECT *lpRect);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP) */
// #pragma endregion
// #if(WINVER >= 0x0400)
// #define CWP_ALL 0x0000
// #define CWP_SKIPINVISIBLE 0x0001
// #define CWP_SKIPDISABLED 0x0002
// #define CWP_SKIPTRANSPARENT 0x0004
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HWND
// WINAPI
// ChildWindowFromPointEx(
// _In_ HWND hwnd,
// _In_ POINT pt,
// _In_ UINT flags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// #ifndef NOCOLOR
// /*
// * Color Types
// */
// #define CTLCOLOR_MSGBOX 0
// #define CTLCOLOR_EDIT 1
// #define CTLCOLOR_LISTBOX 2
// #define CTLCOLOR_BTN 3
// #define CTLCOLOR_DLG 4
// #define CTLCOLOR_SCROLLBAR 5
// #define CTLCOLOR_STATIC 6
// #define CTLCOLOR_MAX 7
// #define COLOR_SCROLLBAR 0
// #define COLOR_BACKGROUND 1
// #define COLOR_ACTIVECAPTION 2
// #define COLOR_INACTIVECAPTION 3
// #define COLOR_MENU 4
// #define COLOR_WINDOW 5
// #define COLOR_WINDOWFRAME 6
// #define COLOR_MENUTEXT 7
// #define COLOR_WINDOWTEXT 8
// #define COLOR_CAPTIONTEXT 9
// #define COLOR_ACTIVEBORDER 10
// #define COLOR_INACTIVEBORDER 11
// #define COLOR_APPWORKSPACE 12
// #define COLOR_HIGHLIGHT 13
// #define COLOR_HIGHLIGHTTEXT 14
// #define COLOR_BTNFACE 15
// #define COLOR_BTNSHADOW 16
// #define COLOR_GRAYTEXT 17
// #define COLOR_BTNTEXT 18
// #define COLOR_INACTIVECAPTIONTEXT 19
// #define COLOR_BTNHIGHLIGHT 20
// #if(WINVER >= 0x0400)
// #define COLOR_3DDKSHADOW 21
// #define COLOR_3DLIGHT 22
// #define COLOR_INFOTEXT 23
// #define COLOR_INFOBK 24
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0500)
// #define COLOR_HOTLIGHT 26
// #define COLOR_GRADIENTACTIVECAPTION 27
// #define COLOR_GRADIENTINACTIVECAPTION 28
// #if(WINVER >= 0x0501)
// #define COLOR_MENUHILIGHT 29
// #define COLOR_MENUBAR 30
// #endif /* WINVER >= 0x0501 */
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0400)
// #define COLOR_DESKTOP COLOR_BACKGROUND
// #define COLOR_3DFACE COLOR_BTNFACE
// #define COLOR_3DSHADOW COLOR_BTNSHADOW
// #define COLOR_3DHIGHLIGHT COLOR_BTNHIGHLIGHT
// #define COLOR_3DHILIGHT COLOR_BTNHIGHLIGHT
// #define COLOR_BTNHILIGHT COLOR_BTNHIGHLIGHT
// #endif /* WINVER >= 0x0400 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// DWORD
// WINAPI
// GetSysColor(
// _In_ int nIndex);
// #if(WINVER >= 0x0400)
// WINUSERAPI
// HBRUSH
// WINAPI
// GetSysColorBrush(
// _In_ int nIndex);
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// BOOL
// WINAPI
// SetSysColors(
// _In_ int cElements,
// _In_reads_(cElements) CONST INT * lpaElements,
// _In_reads_(cElements) CONST COLORREF * lpaRgbValues);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOCOLOR */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// DrawFocusRect(
// _In_ HDC hDC,
// _In_ CONST RECT * lprc);
// WINUSERAPI
// int
// WINAPI
// FillRect(
// _In_ HDC hDC,
// _In_ CONST RECT *lprc,
// _In_ HBRUSH hbr);
// WINUSERAPI
// int
// WINAPI
// FrameRect(
// _In_ HDC hDC,
// _In_ CONST RECT *lprc,
// _In_ HBRUSH hbr);
// WINUSERAPI
// BOOL
// WINAPI
// InvertRect(
// _In_ HDC hDC,
// _In_ CONST RECT *lprc);
// WINUSERAPI
// BOOL
// WINAPI
// SetRect(
// _Out_ LPRECT lprc,
// _In_ int xLeft,
// _In_ int yTop,
// _In_ int xRight,
// _In_ int yBottom);
// WINUSERAPI
// BOOL
// WINAPI
// SetRectEmpty(
// _Out_ LPRECT lprc);
// WINUSERAPI
// BOOL
// WINAPI
// CopyRect(
// _Out_ LPRECT lprcDst,
// _In_ CONST RECT *lprcSrc);
// WINUSERAPI
// BOOL
// WINAPI
// InflateRect(
// _Inout_ LPRECT lprc,
// _In_ int dx,
// _In_ int dy);
// WINUSERAPI
// BOOL
// WINAPI
// IntersectRect(
// _Out_ LPRECT lprcDst,
// _In_ CONST RECT *lprcSrc1,
// _In_ CONST RECT *lprcSrc2);
// WINUSERAPI
// BOOL
// WINAPI
// UnionRect(
// _Out_ LPRECT lprcDst,
// _In_ CONST RECT *lprcSrc1,
// _In_ CONST RECT *lprcSrc2);
// WINUSERAPI
// BOOL
// WINAPI
// SubtractRect(
// _Out_ LPRECT lprcDst,
// _In_ CONST RECT *lprcSrc1,
// _In_ CONST RECT *lprcSrc2);
// WINUSERAPI
// BOOL
// WINAPI
// OffsetRect(
// _Inout_ LPRECT lprc,
// _In_ int dx,
// _In_ int dy);
// WINUSERAPI
// BOOL
// WINAPI
// IsRectEmpty(
// _In_ CONST RECT *lprc);
// WINUSERAPI
// BOOL
// WINAPI
// EqualRect(
// _In_ CONST RECT *lprc1,
// _In_ CONST RECT *lprc2);
// WINUSERAPI
// BOOL
// WINAPI
// PtInRect(
// _In_ CONST RECT *lprc,
// _In_ POINT pt);
// #ifndef NOWINOFFSETS
// WINUSERAPI
// WORD
// WINAPI
// GetWindowWord(
// _In_ HWND hWnd,
// _In_ int nIndex);
// WINUSERAPI
// WORD
// WINAPI
// SetWindowWord(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ WORD wNewWord);
// WINUSERAPI
// LONG
// WINAPI
// GetWindowLongA(
// _In_ HWND hWnd,
// _In_ int nIndex);
// WINUSERAPI
// LONG
// WINAPI
// GetWindowLongW(
// _In_ HWND hWnd,
// _In_ int nIndex);
// #ifdef UNICODE
// #define GetWindowLong GetWindowLongW
// #else
// #define GetWindowLong GetWindowLongA
// #endif // !UNICODE
// WINUSERAPI
// LONG
// WINAPI
// SetWindowLongA(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ LONG dwNewLong);
// WINUSERAPI
// LONG
// WINAPI
// SetWindowLongW(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ LONG dwNewLong);
// #ifdef UNICODE
// #define SetWindowLong SetWindowLongW
// #else
// #define SetWindowLong SetWindowLongA
// #endif // !UNICODE
// #ifdef _WIN64
// WINUSERAPI
// LONG_PTR
// WINAPI
// GetWindowLongPtrA(
// _In_ HWND hWnd,
// _In_ int nIndex);
// WINUSERAPI
// LONG_PTR
// WINAPI
// GetWindowLongPtrW(
// _In_ HWND hWnd,
// _In_ int nIndex);
// #ifdef UNICODE
// #define GetWindowLongPtr GetWindowLongPtrW
// #else
// #define GetWindowLongPtr GetWindowLongPtrA
// #endif // !UNICODE
// WINUSERAPI
// LONG_PTR
// WINAPI
// SetWindowLongPtrA(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ LONG_PTR dwNewLong);
// WINUSERAPI
// LONG_PTR
// WINAPI
// SetWindowLongPtrW(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ LONG_PTR dwNewLong);
// #ifdef UNICODE
// #define SetWindowLongPtr SetWindowLongPtrW
// #else
// #define SetWindowLongPtr SetWindowLongPtrA
// #endif // !UNICODE
// #else /* _WIN64 */
// #define GetWindowLongPtrA GetWindowLongA
// #define GetWindowLongPtrW GetWindowLongW
// #ifdef UNICODE
// #define GetWindowLongPtr GetWindowLongPtrW
// #else
// #define GetWindowLongPtr GetWindowLongPtrA
// #endif // !UNICODE
// #define SetWindowLongPtrA SetWindowLongA
// #define SetWindowLongPtrW SetWindowLongW
// #ifdef UNICODE
// #define SetWindowLongPtr SetWindowLongPtrW
// #else
// #define SetWindowLongPtr SetWindowLongPtrA
// #endif // !UNICODE
// #endif /* _WIN64 */
// WINUSERAPI
// WORD
// WINAPI
// GetClassWord(
// _In_ HWND hWnd,
// _In_ int nIndex);
// WINUSERAPI
// WORD
// WINAPI
// SetClassWord(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ WORD wNewWord);
// WINUSERAPI
// DWORD
// WINAPI
// GetClassLongA(
// _In_ HWND hWnd,
// _In_ int nIndex);
// WINUSERAPI
// DWORD
// WINAPI
// GetClassLongW(
// _In_ HWND hWnd,
// _In_ int nIndex);
// #ifdef UNICODE
// #define GetClassLong GetClassLongW
// #else
// #define GetClassLong GetClassLongA
// #endif // !UNICODE
// WINUSERAPI
// DWORD
// WINAPI
// SetClassLongA(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ LONG dwNewLong);
// WINUSERAPI
// DWORD
// WINAPI
// SetClassLongW(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ LONG dwNewLong);
// #ifdef UNICODE
// #define SetClassLong SetClassLongW
// #else
// #define SetClassLong SetClassLongA
// #endif // !UNICODE
// #ifdef _WIN64
// WINUSERAPI
// ULONG_PTR
// WINAPI
// GetClassLongPtrA(
// _In_ HWND hWnd,
// _In_ int nIndex);
// WINUSERAPI
// ULONG_PTR
// WINAPI
// GetClassLongPtrW(
// _In_ HWND hWnd,
// _In_ int nIndex);
// #ifdef UNICODE
// #define GetClassLongPtr GetClassLongPtrW
// #else
// #define GetClassLongPtr GetClassLongPtrA
// #endif // !UNICODE
// WINUSERAPI
// ULONG_PTR
// WINAPI
// SetClassLongPtrA(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ LONG_PTR dwNewLong);
// WINUSERAPI
// ULONG_PTR
// WINAPI
// SetClassLongPtrW(
// _In_ HWND hWnd,
// _In_ int nIndex,
// _In_ LONG_PTR dwNewLong);
// #ifdef UNICODE
// #define SetClassLongPtr SetClassLongPtrW
// #else
// #define SetClassLongPtr SetClassLongPtrA
// #endif // !UNICODE
// #else /* _WIN64 */
// #define GetClassLongPtrA GetClassLongA
// #define GetClassLongPtrW GetClassLongW
// #ifdef UNICODE
// #define GetClassLongPtr GetClassLongPtrW
// #else
// #define GetClassLongPtr GetClassLongPtrA
// #endif // !UNICODE
// #define SetClassLongPtrA SetClassLongA
// #define SetClassLongPtrW SetClassLongW
// #ifdef UNICODE
// #define SetClassLongPtr SetClassLongPtrW
// #else
// #define SetClassLongPtr SetClassLongPtrA
// #endif // !UNICODE
// #endif /* _WIN64 */
// #endif /* !NOWINOFFSETS */
// #if(WINVER >= 0x0500)
// WINUSERAPI
// BOOL
// WINAPI
// GetProcessDefaultLayout(
// _Out_ DWORD *pdwDefaultLayout);
// WINUSERAPI
// BOOL
// WINAPI
// SetProcessDefaultLayout(
// _In_ DWORD dwDefaultLayout);
// #endif /* WINVER >= 0x0500 */
// WINUSERAPI
// HWND
// WINAPI
// GetDesktopWindow(
// VOID);
// WINUSERAPI
// HWND
// WINAPI
// GetParent(
// _In_ HWND hWnd);
// WINUSERAPI
// HWND
// WINAPI
// SetParent(
// _In_ HWND hWndChild,
// _In_opt_ HWND hWndNewParent);
// WINUSERAPI
// BOOL
// WINAPI
// EnumChildWindows(
// _In_opt_ HWND hWndParent,
// _In_ WNDENUMPROC lpEnumFunc,
// _In_ LPARAM lParam);
// WINUSERAPI
// HWND
// WINAPI
// FindWindowA(
// _In_opt_ LPCSTR lpClassName,
// _In_opt_ LPCSTR lpWindowName);
// WINUSERAPI
// HWND
// WINAPI
// FindWindowW(
// _In_opt_ LPCWSTR lpClassName,
// _In_opt_ LPCWSTR lpWindowName);
// #ifdef UNICODE
// #define FindWindow FindWindowW
// #else
// #define FindWindow FindWindowA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// WINUSERAPI
// HWND
// WINAPI
// FindWindowExA(
// _In_opt_ HWND hWndParent,
// _In_opt_ HWND hWndChildAfter,
// _In_opt_ LPCSTR lpszClass,
// _In_opt_ LPCSTR lpszWindow);
// WINUSERAPI
// HWND
// WINAPI
// FindWindowExW(
// _In_opt_ HWND hWndParent,
// _In_opt_ HWND hWndChildAfter,
// _In_opt_ LPCWSTR lpszClass,
// _In_opt_ LPCWSTR lpszWindow);
// #ifdef UNICODE
// #define FindWindowEx FindWindowExW
// #else
// #define FindWindowEx FindWindowExA
// #endif // !UNICODE
// WINUSERAPI
// HWND
// WINAPI
// GetShellWindow(
// VOID);
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// BOOL
// WINAPI
// RegisterShellHookWindow(
// _In_ HWND hwnd);
// WINUSERAPI
// BOOL
// WINAPI
// DeregisterShellHookWindow(
// _In_ HWND hwnd);
// WINUSERAPI
// BOOL
// WINAPI
// EnumWindows(
// _In_ WNDENUMPROC lpEnumFunc,
// _In_ LPARAM lParam);
// WINUSERAPI
// BOOL
// WINAPI
// EnumThreadWindows(
// _In_ DWORD dwThreadId,
// _In_ WNDENUMPROC lpfn,
// _In_ LPARAM lParam);
// #define EnumTaskWindows(hTask, lpfn, lParam) EnumThreadWindows(HandleToUlong(hTask), lpfn, lParam)
// WINUSERAPI
// int
// WINAPI
// GetClassNameA(
// _In_ HWND hWnd,
// _Out_writes_to_(nMaxCount, return) LPSTR lpClassName,
// _In_ int nMaxCount
// );
// WINUSERAPI
// int
// WINAPI
// GetClassNameW(
// _In_ HWND hWnd,
// _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName,
// _In_ int nMaxCount
// );
// #ifdef UNICODE
// #define GetClassName GetClassNameW
// #else
// #define GetClassName GetClassNameA
// #endif // !UNICODE
// #if defined(_M_CEE)
// #undef GetClassName
// __inline
// int
// GetClassName(
// HWND hWnd,
// LPTSTR lpClassName,
// int nMaxCount
// )
// {
// #ifdef UNICODE
// return GetClassNameW(
// #else
// return GetClassNameA(
// #endif
// hWnd,
// lpClassName,
// nMaxCount
// );
// }
// #endif /* _M_CEE */
// WINUSERAPI
// HWND
// WINAPI
// GetTopWindow(
// _In_opt_ HWND hWnd);
// #define GetNextWindow(hWnd, wCmd) GetWindow(hWnd, wCmd)
// #define GetSysModalWindow() (NULL)
// #define SetSysModalWindow(hWnd) (NULL)
// WINUSERAPI
// DWORD
// WINAPI
// GetWindowThreadProcessId(
// _In_ HWND hWnd,
// _Out_opt_ LPDWORD lpdwProcessId);
// #if(_WIN32_WINNT >= 0x0501)
// WINUSERAPI
// BOOL
// WINAPI
// IsGUIThread(
// _In_ BOOL bConvert);
// #endif /* _WIN32_WINNT >= 0x0501 */
// #define GetWindowTask(hWnd) \
// ((HANDLE)(DWORD_PTR)GetWindowThreadProcessId(hWnd, NULL))
// WINUSERAPI
// HWND
// WINAPI
// GetLastActivePopup(
// _In_ HWND hWnd);
// /*
// * GetWindow() Constants
// */
// #define GW_HWNDFIRST 0
// #define GW_HWNDLAST 1
// #define GW_HWNDNEXT 2
// #define GW_HWNDPREV 3
// #define GW_OWNER 4
// #define GW_CHILD 5
// #if(WINVER <= 0x0400)
// #define GW_MAX 5
// #else
// #define GW_ENABLEDPOPUP 6
// #define GW_MAX 6
// #endif
// WINUSERAPI
// HWND
// WINAPI
// GetWindow(
// _In_ HWND hWnd,
// _In_ UINT uCmd);
// #ifndef NOWH
// #ifdef STRICT
// WINUSERAPI
// HHOOK
// WINAPI
// SetWindowsHookA(
// _In_ int nFilterType,
// _In_ HOOKPROC pfnFilterProc);
// WINUSERAPI
// HHOOK
// WINAPI
// SetWindowsHookW(
// _In_ int nFilterType,
// _In_ HOOKPROC pfnFilterProc);
// #ifdef UNICODE
// #define SetWindowsHook SetWindowsHookW
// #else
// #define SetWindowsHook SetWindowsHookA
// #endif // !UNICODE
// #else /* !STRICT */
// WINUSERAPI
// HOOKPROC
// WINAPI
// SetWindowsHookA(
// _In_ int nFilterType,
// _In_ HOOKPROC pfnFilterProc);
// WINUSERAPI
// HOOKPROC
// WINAPI
// SetWindowsHookW(
// _In_ int nFilterType,
// _In_ HOOKPROC pfnFilterProc);
// #ifdef UNICODE
// #define SetWindowsHook SetWindowsHookW
// #else
// #define SetWindowsHook SetWindowsHookA
// #endif // !UNICODE
// #endif /* !STRICT */
// WINUSERAPI
// BOOL
// WINAPI
// UnhookWindowsHook(
// _In_ int nCode,
// _In_ HOOKPROC pfnFilterProc);
// WINUSERAPI
// HHOOK
// WINAPI
// SetWindowsHookExA(
// _In_ int idHook,
// _In_ HOOKPROC lpfn,
// _In_opt_ HINSTANCE hmod,
// _In_ DWORD dwThreadId);
// WINUSERAPI
// HHOOK
// WINAPI
// SetWindowsHookExW(
// _In_ int idHook,
// _In_ HOOKPROC lpfn,
// _In_opt_ HINSTANCE hmod,
// _In_ DWORD dwThreadId);
// #ifdef UNICODE
// #define SetWindowsHookEx SetWindowsHookExW
// #else
// #define SetWindowsHookEx SetWindowsHookExA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// UnhookWindowsHookEx(
// _In_ HHOOK hhk);
// WINUSERAPI
// LRESULT
// WINAPI
// CallNextHookEx(
// _In_opt_ HHOOK hhk,
// _In_ int nCode,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// /*
// * Macros for source-level compatibility with old functions.
// */
// #ifdef STRICT
// #define DefHookProc(nCode, wParam, lParam, phhk)\
// CallNextHookEx(*phhk, nCode, wParam, lParam)
// #else
// #define DefHookProc(nCode, wParam, lParam, phhk)\
// CallNextHookEx((HHOOK)*phhk, nCode, wParam, lParam)
// #endif /* STRICT */
// #endif /* !NOWH */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NOMENUS
// /* ;win40 -- A lot of MF_* flags have been renamed as MFT_* and MFS_* flags */
// /*
// * Menu flags for Add/Check/EnableMenuItem()
// */
// #define MF_INSERT 0x00000000L
// #define MF_CHANGE 0x00000080L
// #define MF_APPEND 0x00000100L
// #define MF_DELETE 0x00000200L
// #define MF_REMOVE 0x00001000L
// #define MF_BYCOMMAND 0x00000000L
// #define MF_BYPOSITION 0x00000400L
// #define MF_SEPARATOR 0x00000800L
// #define MF_ENABLED 0x00000000L
// #define MF_GRAYED 0x00000001L
// #define MF_DISABLED 0x00000002L
// #define MF_UNCHECKED 0x00000000L
// #define MF_CHECKED 0x00000008L
// #define MF_USECHECKBITMAPS 0x00000200L
// #define MF_STRING 0x00000000L
// #define MF_BITMAP 0x00000004L
// #define MF_OWNERDRAW 0x00000100L
// #define MF_POPUP 0x00000010L
// #define MF_MENUBARBREAK 0x00000020L
// #define MF_MENUBREAK 0x00000040L
// #define MF_UNHILITE 0x00000000L
// #define MF_HILITE 0x00000080L
// #if(WINVER >= 0x0400)
// #define MF_DEFAULT 0x00001000L
// #endif /* WINVER >= 0x0400 */
// #define MF_SYSMENU 0x00002000L
// #define MF_HELP 0x00004000L
// #if(WINVER >= 0x0400)
// #define MF_RIGHTJUSTIFY 0x00004000L
// #endif /* WINVER >= 0x0400 */
// #define MF_MOUSESELECT 0x00008000L
// #if(WINVER >= 0x0400)
// #define MF_END 0x00000080L /* Obsolete -- only used by old RES files */
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0400)
// #define MFT_STRING MF_STRING
// #define MFT_BITMAP MF_BITMAP
// #define MFT_MENUBARBREAK MF_MENUBARBREAK
// #define MFT_MENUBREAK MF_MENUBREAK
// #define MFT_OWNERDRAW MF_OWNERDRAW
// #define MFT_RADIOCHECK 0x00000200L
// #define MFT_SEPARATOR MF_SEPARATOR
// #define MFT_RIGHTORDER 0x00002000L
// #define MFT_RIGHTJUSTIFY MF_RIGHTJUSTIFY
// /* Menu flags for Add/Check/EnableMenuItem() */
// #define MFS_GRAYED 0x00000003L
// #define MFS_DISABLED MFS_GRAYED
// #define MFS_CHECKED MF_CHECKED
// #define MFS_HILITE MF_HILITE
// #define MFS_ENABLED MF_ENABLED
// #define MFS_UNCHECKED MF_UNCHECKED
// #define MFS_UNHILITE MF_UNHILITE
// #define MFS_DEFAULT MF_DEFAULT
// #endif /* WINVER >= 0x0400 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if(WINVER >= 0x0400)
// WINUSERAPI
// BOOL
// WINAPI
// CheckMenuRadioItem(
// _In_ HMENU hmenu,
// _In_ UINT first,
// _In_ UINT last,
// _In_ UINT check,
// _In_ UINT flags);
// #endif /* WINVER >= 0x0400 */
// /*
// * Menu item resource format
// */
// typedef struct {
// WORD versionNumber;
// WORD offset;
// } MENUITEMTEMPLATEHEADER, *PMENUITEMTEMPLATEHEADER;
// typedef struct { // version 0
// WORD mtOption;
// WORD mtID;
// WCHAR mtString[1];
// } MENUITEMTEMPLATE, *PMENUITEMTEMPLATE;
// #define MF_END 0x00000080L
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOMENUS */
// #ifndef NOSYSCOMMANDS
// /*
// * System Menu Command Values
// */
// #define SC_SIZE 0xF000
// #define SC_MOVE 0xF010
// #define SC_MINIMIZE 0xF020
// #define SC_MAXIMIZE 0xF030
// #define SC_NEXTWINDOW 0xF040
// #define SC_PREVWINDOW 0xF050
// #define SC_CLOSE 0xF060
// #define SC_VSCROLL 0xF070
// #define SC_HSCROLL 0xF080
// #define SC_MOUSEMENU 0xF090
// #define SC_KEYMENU 0xF100
// #define SC_ARRANGE 0xF110
// #define SC_RESTORE 0xF120
// #define SC_TASKLIST 0xF130
// #define SC_SCREENSAVE 0xF140
// #define SC_HOTKEY 0xF150
// #if(WINVER >= 0x0400)
// #define SC_DEFAULT 0xF160
// #define SC_MONITORPOWER 0xF170
// #define SC_CONTEXTHELP 0xF180
// #define SC_SEPARATOR 0xF00F
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0600)
// #define SCF_ISSECURE 0x00000001
// #endif /* WINVER >= 0x0600 */
// #define GET_SC_WPARAM(wParam) ((int)wParam & 0xFFF0)
// /*
// * Obsolete names
// */
// #define SC_ICON SC_MINIMIZE
// #define SC_ZOOM SC_MAXIMIZE
// #endif /* !NOSYSCOMMANDS */
// /*
// * Resource Loading Routines
// */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HBITMAP
// WINAPI
// LoadBitmapA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpBitmapName);
// WINUSERAPI
// HBITMAP
// WINAPI
// LoadBitmapW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpBitmapName);
// #ifdef UNICODE
// #define LoadBitmap LoadBitmapW
// #else
// #define LoadBitmap LoadBitmapA
// #endif // !UNICODE
// WINUSERAPI
// HCURSOR
// WINAPI
// LoadCursorA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpCursorName);
// WINUSERAPI
// HCURSOR
// WINAPI
// LoadCursorW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpCursorName);
// #ifdef UNICODE
// #define LoadCursor LoadCursorW
// #else
// #define LoadCursor LoadCursorA
// #endif // !UNICODE
// WINUSERAPI
// HCURSOR
// WINAPI
// LoadCursorFromFileA(
// _In_ LPCSTR lpFileName);
// WINUSERAPI
// HCURSOR
// WINAPI
// LoadCursorFromFileW(
// _In_ LPCWSTR lpFileName);
// #ifdef UNICODE
// #define LoadCursorFromFile LoadCursorFromFileW
// #else
// #define LoadCursorFromFile LoadCursorFromFileA
// #endif // !UNICODE
// WINUSERAPI
// HCURSOR
// WINAPI
// CreateCursor(
// _In_opt_ HINSTANCE hInst,
// _In_ int xHotSpot,
// _In_ int yHotSpot,
// _In_ int nWidth,
// _In_ int nHeight,
// _In_ CONST VOID *pvANDPlane,
// _In_ CONST VOID *pvXORPlane);
// WINUSERAPI
// BOOL
// WINAPI
// DestroyCursor(
// _In_ HCURSOR hCursor);
// #ifndef _MAC
// #define CopyCursor(pcur) ((HCURSOR)CopyIcon((HICON)(pcur)))
// #else
// WINUSERAPI
// HCURSOR
// WINAPI
// CopyCursor(
// _In_ HCURSOR hCursor);
// #endif
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Standard Cursor IDs
// */
// #define IDC_ARROW MAKEINTRESOURCE(32512)
// #define IDC_IBEAM MAKEINTRESOURCE(32513)
// #define IDC_WAIT MAKEINTRESOURCE(32514)
// #define IDC_CROSS MAKEINTRESOURCE(32515)
// #define IDC_UPARROW MAKEINTRESOURCE(32516)
// #define IDC_SIZE MAKEINTRESOURCE(32640) /* OBSOLETE: use IDC_SIZEALL */
// #define IDC_ICON MAKEINTRESOURCE(32641) /* OBSOLETE: use IDC_ARROW */
// #define IDC_SIZENWSE MAKEINTRESOURCE(32642)
// #define IDC_SIZENESW MAKEINTRESOURCE(32643)
// #define IDC_SIZEWE MAKEINTRESOURCE(32644)
// #define IDC_SIZENS MAKEINTRESOURCE(32645)
// #define IDC_SIZEALL MAKEINTRESOURCE(32646)
// #define IDC_NO MAKEINTRESOURCE(32648) /*not in win3.1 */
// #if(WINVER >= 0x0500)
// #define IDC_HAND MAKEINTRESOURCE(32649)
// #endif /* WINVER >= 0x0500 */
// #define IDC_APPSTARTING MAKEINTRESOURCE(32650) /*not in win3.1 */
// #if(WINVER >= 0x0400)
// #define IDC_HELP MAKEINTRESOURCE(32651)
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0606)
// #define IDC_PIN MAKEINTRESOURCE(32671)
// #define IDC_PERSON MAKEINTRESOURCE(32672)
// #endif /* WINVER >= 0x0606 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// SetSystemCursor(
// _In_ HCURSOR hcur,
// _In_ DWORD id);
// typedef struct _ICONINFO {
// BOOL fIcon;
// DWORD xHotspot;
// DWORD yHotspot;
// HBITMAP hbmMask;
// HBITMAP hbmColor;
// } ICONINFO;
// typedef ICONINFO *PICONINFO;
// WINUSERAPI
// HICON
// WINAPI
// LoadIconA(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCSTR lpIconName);
// WINUSERAPI
// HICON
// WINAPI
// LoadIconW(
// _In_opt_ HINSTANCE hInstance,
// _In_ LPCWSTR lpIconName);
// #ifdef UNICODE
// #define LoadIcon LoadIconW
// #else
// #define LoadIcon LoadIconA
// #endif // !UNICODE
// WINUSERAPI
// UINT
// WINAPI
// PrivateExtractIconsA(
// _In_reads_(MAX_PATH) LPCSTR szFileName,
// _In_ int nIconIndex,
// _In_ int cxIcon,
// _In_ int cyIcon,
// _Out_writes_opt_(nIcons) HICON *phicon,
// _Out_writes_opt_(nIcons) UINT *piconid,
// _In_ UINT nIcons,
// _In_ UINT flags);
// WINUSERAPI
// UINT
// WINAPI
// PrivateExtractIconsW(
// _In_reads_(MAX_PATH) LPCWSTR szFileName,
// _In_ int nIconIndex,
// _In_ int cxIcon,
// _In_ int cyIcon,
// _Out_writes_opt_(nIcons) HICON *phicon,
// _Out_writes_opt_(nIcons) UINT *piconid,
// _In_ UINT nIcons,
// _In_ UINT flags);
// #ifdef UNICODE
// #define PrivateExtractIcons PrivateExtractIconsW
// #else
// #define PrivateExtractIcons PrivateExtractIconsA
// #endif // !UNICODE
// WINUSERAPI
// HICON
// WINAPI
// CreateIcon(
// _In_opt_ HINSTANCE hInstance,
// _In_ int nWidth,
// _In_ int nHeight,
// _In_ BYTE cPlanes,
// _In_ BYTE cBitsPixel,
// _In_ CONST BYTE *lpbANDbits,
// _In_ CONST BYTE *lpbXORbits);
// WINUSERAPI
// BOOL
// WINAPI
// DestroyIcon(
// _In_ HICON hIcon);
// WINUSERAPI
// int
// WINAPI
// LookupIconIdFromDirectory(
// _In_reads_bytes_(sizeof(WORD) * 3) PBYTE presbits,
// _In_ BOOL fIcon);
// #if(WINVER >= 0x0400)
// WINUSERAPI
// int
// WINAPI
// LookupIconIdFromDirectoryEx(
// _In_reads_bytes_(sizeof(WORD) * 3) PBYTE presbits,
// _In_ BOOL fIcon,
// _In_ int cxDesired,
// _In_ int cyDesired,
// _In_ UINT Flags);
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// HICON
// WINAPI
// CreateIconFromResource(
// _In_reads_bytes_(dwResSize) PBYTE presbits,
// _In_ DWORD dwResSize,
// _In_ BOOL fIcon,
// _In_ DWORD dwVer);
// #if(WINVER >= 0x0400)
// WINUSERAPI
// HICON
// WINAPI
// CreateIconFromResourceEx(
// _In_reads_bytes_(dwResSize) PBYTE presbits,
// _In_ DWORD dwResSize,
// _In_ BOOL fIcon,
// _In_ DWORD dwVer,
// _In_ int cxDesired,
// _In_ int cyDesired,
// _In_ UINT Flags);
// /* Icon/Cursor header */
// typedef struct tagCURSORSHAPE
// {
// int xHotSpot;
// int yHotSpot;
// int cx;
// int cy;
// int cbWidth;
// BYTE Planes;
// BYTE BitsPixel;
// } CURSORSHAPE, FAR *LPCURSORSHAPE;
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define IMAGE_BITMAP 0
// #define IMAGE_ICON 1
// #define IMAGE_CURSOR 2
// #if(WINVER >= 0x0400)
// #define IMAGE_ENHMETAFILE 3
// #define LR_DEFAULTCOLOR 0x00000000
// #define LR_MONOCHROME 0x00000001
// #define LR_COLOR 0x00000002
// #define LR_COPYRETURNORG 0x00000004
// #define LR_COPYDELETEORG 0x00000008
// #define LR_LOADFROMFILE 0x00000010
// #define LR_LOADTRANSPARENT 0x00000020
// #define LR_DEFAULTSIZE 0x00000040
// #define LR_VGACOLOR 0x00000080
// #define LR_LOADMAP3DCOLORS 0x00001000
// #define LR_CREATEDIBSECTION 0x00002000
// #define LR_COPYFROMRESOURCE 0x00004000
// #define LR_SHARED 0x00008000
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HANDLE
// WINAPI
// LoadImageA(
// _In_opt_ HINSTANCE hInst,
// _In_ LPCSTR name,
// _In_ UINT type,
// _In_ int cx,
// _In_ int cy,
// _In_ UINT fuLoad);
// WINUSERAPI
// HANDLE
// WINAPI
// LoadImageW(
// _In_opt_ HINSTANCE hInst,
// _In_ LPCWSTR name,
// _In_ UINT type,
// _In_ int cx,
// _In_ int cy,
// _In_ UINT fuLoad);
// #ifdef UNICODE
// #define LoadImage LoadImageW
// #else
// #define LoadImage LoadImageA
// #endif // !UNICODE
// WINUSERAPI
// HANDLE
// WINAPI
// CopyImage(
// _In_ HANDLE h,
// _In_ UINT type,
// _In_ int cx,
// _In_ int cy,
// _In_ UINT flags);
// #define DI_MASK 0x0001
// #define DI_IMAGE 0x0002
// #define DI_NORMAL 0x0003
// #define DI_COMPAT 0x0004
// #define DI_DEFAULTSIZE 0x0008
// #if(_WIN32_WINNT >= 0x0501)
// #define DI_NOMIRROR 0x0010
// #endif /* _WIN32_WINNT >= 0x0501 */
// WINUSERAPI BOOL WINAPI DrawIconEx(
// _In_ HDC hdc,
// _In_ int xLeft,
// _In_ int yTop,
// _In_ HICON hIcon,
// _In_ int cxWidth,
// _In_ int cyWidth,
// _In_ UINT istepIfAniCur,
// _In_opt_ HBRUSH hbrFlickerFreeDraw,
// _In_ UINT diFlags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HICON
// WINAPI
// CreateIconIndirect(
// _In_ PICONINFO piconinfo);
// WINUSERAPI
// HICON
// WINAPI
// CopyIcon(
// _In_ HICON hIcon);
// WINUSERAPI
// BOOL
// WINAPI
// GetIconInfo(
// _In_ HICON hIcon,
// _Out_ PICONINFO piconinfo);
// #if(_WIN32_WINNT >= 0x0600)
// typedef struct _ICONINFOEXA {
// DWORD cbSize;
// BOOL fIcon;
// DWORD xHotspot;
// DWORD yHotspot;
// HBITMAP hbmMask;
// HBITMAP hbmColor;
// WORD wResID;
// CHAR szModName[MAX_PATH];
// CHAR szResName[MAX_PATH];
// } ICONINFOEXA, *PICONINFOEXA;
// typedef struct _ICONINFOEXW {
// DWORD cbSize;
// BOOL fIcon;
// DWORD xHotspot;
// DWORD yHotspot;
// HBITMAP hbmMask;
// HBITMAP hbmColor;
// WORD wResID;
// WCHAR szModName[MAX_PATH];
// WCHAR szResName[MAX_PATH];
// } ICONINFOEXW, *PICONINFOEXW;
// #ifdef UNICODE
// typedef ICONINFOEXW ICONINFOEX;
// typedef PICONINFOEXW PICONINFOEX;
// #else
// typedef ICONINFOEXA ICONINFOEX;
// typedef PICONINFOEXA PICONINFOEX;
// #endif // UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// GetIconInfoExA(
// _In_ HICON hicon,
// _Inout_ PICONINFOEXA piconinfo);
// WINUSERAPI
// BOOL
// WINAPI
// GetIconInfoExW(
// _In_ HICON hicon,
// _Inout_ PICONINFOEXW piconinfo);
// #ifdef UNICODE
// #define GetIconInfoEx GetIconInfoExW
// #else
// #define GetIconInfoEx GetIconInfoExA
// #endif // !UNICODE
// #endif /* _WIN32_WINNT >= 0x0600 */
// #if(WINVER >= 0x0400)
// #define RES_ICON 1
// #define RES_CURSOR 2
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifdef OEMRESOURCE
// /*
// * OEM Resource Ordinal Numbers
// */
// #define OBM_CLOSE 32754
// #define OBM_UPARROW 32753
// #define OBM_DNARROW 32752
// #define OBM_RGARROW 32751
// #define OBM_LFARROW 32750
// #define OBM_REDUCE 32749
// #define OBM_ZOOM 32748
// #define OBM_RESTORE 32747
// #define OBM_REDUCED 32746
// #define OBM_ZOOMD 32745
// #define OBM_RESTORED 32744
// #define OBM_UPARROWD 32743
// #define OBM_DNARROWD 32742
// #define OBM_RGARROWD 32741
// #define OBM_LFARROWD 32740
// #define OBM_MNARROW 32739
// #define OBM_COMBO 32738
// #define OBM_UPARROWI 32737
// #define OBM_DNARROWI 32736
// #define OBM_RGARROWI 32735
// #define OBM_LFARROWI 32734
// #define OBM_OLD_CLOSE 32767
// #define OBM_SIZE 32766
// #define OBM_OLD_UPARROW 32765
// #define OBM_OLD_DNARROW 32764
// #define OBM_OLD_RGARROW 32763
// #define OBM_OLD_LFARROW 32762
// #define OBM_BTSIZE 32761
// #define OBM_CHECK 32760
// #define OBM_CHECKBOXES 32759
// #define OBM_BTNCORNERS 32758
// #define OBM_OLD_REDUCE 32757
// #define OBM_OLD_ZOOM 32756
// #define OBM_OLD_RESTORE 32755
// #define OCR_NORMAL 32512
// #define OCR_IBEAM 32513
// #define OCR_WAIT 32514
// #define OCR_CROSS 32515
// #define OCR_UP 32516
// #define OCR_SIZE 32640 /* OBSOLETE: use OCR_SIZEALL */
// #define OCR_ICON 32641 /* OBSOLETE: use OCR_NORMAL */
// #define OCR_SIZENWSE 32642
// #define OCR_SIZENESW 32643
// #define OCR_SIZEWE 32644
// #define OCR_SIZENS 32645
// #define OCR_SIZEALL 32646
// #define OCR_ICOCUR 32647 /* OBSOLETE: use OIC_WINLOGO */
// #define OCR_NO 32648
// #if(WINVER >= 0x0500)
// #define OCR_HAND 32649
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0400)
// #define OCR_APPSTARTING 32650
// #endif /* WINVER >= 0x0400 */
// #define OIC_SAMPLE 32512
// #define OIC_HAND 32513
// #define OIC_QUES 32514
// #define OIC_BANG 32515
// #define OIC_NOTE 32516
// #if(WINVER >= 0x0400)
// #define OIC_WINLOGO 32517
// #define OIC_WARNING OIC_BANG
// #define OIC_ERROR OIC_HAND
// #define OIC_INFORMATION OIC_NOTE
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0600)
// #define OIC_SHIELD 32518
// #endif /* WINVER >= 0x0600 */
// #endif /* OEMRESOURCE */
// #define ORD_LANGDRIVER 1 /* The ordinal number for the entry point of
// ** language drivers.
// */
// #ifndef NOICONS
// /*
// * Standard Icon IDs
// */
// #ifdef RC_INVOKED
// #define IDI_APPLICATION 32512
// #define IDI_HAND 32513
// #define IDI_QUESTION 32514
// #define IDI_EXCLAMATION 32515
// #define IDI_ASTERISK 32516
// #if(WINVER >= 0x0400)
// #define IDI_WINLOGO 32517
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0600)
// #define IDI_SHIELD 32518
// #endif /* WINVER >= 0x0600 */
// #else
// #define IDI_APPLICATION MAKEINTRESOURCE(32512)
// #define IDI_HAND MAKEINTRESOURCE(32513)
// #define IDI_QUESTION MAKEINTRESOURCE(32514)
// #define IDI_EXCLAMATION MAKEINTRESOURCE(32515)
// #define IDI_ASTERISK MAKEINTRESOURCE(32516)
// #if(WINVER >= 0x0400)
// #define IDI_WINLOGO MAKEINTRESOURCE(32517)
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0600)
// #define IDI_SHIELD MAKEINTRESOURCE(32518)
// #endif /* WINVER >= 0x0600 */
// #endif /* RC_INVOKED */
// #if(WINVER >= 0x0400)
// #define IDI_WARNING IDI_EXCLAMATION
// #define IDI_ERROR IDI_HAND
// #define IDI_INFORMATION IDI_ASTERISK
// #endif /* WINVER >= 0x0400 */
// #endif /* !NOICONS */
// #ifdef NOAPISET
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// int
// WINAPI
// LoadStringA(
// _In_opt_ HINSTANCE hInstance,
// _In_ UINT uID,
// _Out_writes_to_(cchBufferMax, return +1) LPSTR lpBuffer,
// _In_ int cchBufferMax);
// WINUSERAPI
// int
// WINAPI
// LoadStringW(
// _In_opt_ HINSTANCE hInstance,
// _In_ UINT uID,
// _Out_writes_to_(cchBufferMax, return +1) LPWSTR lpBuffer,
// _In_ int cchBufferMax);
// #ifdef UNICODE
// #define LoadString LoadStringW
// #else
// #define LoadString LoadStringA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif
// /*
// * Dialog Box Command IDs
// */
// #define IDOK 1
// #define IDCANCEL 2
// #define IDABORT 3
// #define IDRETRY 4
// #define IDIGNORE 5
// #define IDYES 6
// #define IDNO 7
// #if(WINVER >= 0x0400)
// #define IDCLOSE 8
// #define IDHELP 9
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0500)
// #define IDTRYAGAIN 10
// #define IDCONTINUE 11
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0501)
// #ifndef IDTIMEOUT
// #define IDTIMEOUT 32000
// #endif
// #endif /* WINVER >= 0x0501 */
// #ifndef NOCTLMGR
// /*
// * Control Manager Structures and Definitions
// */
// #ifndef NOWINSTYLES
// /*
// * Edit Control Styles
// */
// #define ES_LEFT 0x0000L
// #define ES_CENTER 0x0001L
// #define ES_RIGHT 0x0002L
// #define ES_MULTILINE 0x0004L
// #define ES_UPPERCASE 0x0008L
// #define ES_LOWERCASE 0x0010L
// #define ES_PASSWORD 0x0020L
// #define ES_AUTOVSCROLL 0x0040L
// #define ES_AUTOHSCROLL 0x0080L
// #define ES_NOHIDESEL 0x0100L
// #define ES_OEMCONVERT 0x0400L
// #define ES_READONLY 0x0800L
// #define ES_WANTRETURN 0x1000L
// #if(WINVER >= 0x0400)
// #define ES_NUMBER 0x2000L
// #endif /* WINVER >= 0x0400 */
// #endif /* !NOWINSTYLES */
// /*
// * Edit Control Notification Codes
// */
// #define EN_SETFOCUS 0x0100
// #define EN_KILLFOCUS 0x0200
// #define EN_CHANGE 0x0300
// #define EN_UPDATE 0x0400
// #define EN_ERRSPACE 0x0500
// #define EN_MAXTEXT 0x0501
// #define EN_HSCROLL 0x0601
// #define EN_VSCROLL 0x0602
// #if(_WIN32_WINNT >= 0x0500)
// #define EN_ALIGN_LTR_EC 0x0700
// #define EN_ALIGN_RTL_EC 0x0701
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(WINVER >= 0x0604)
// #define EN_BEFORE_PASTE 0x0800
// #define EN_AFTER_PASTE 0x0801
// #endif /* WINVER >= 0x0604 */
// #if(WINVER >= 0x0400)
// /* Edit control EM_SETMARGIN parameters */
// #define EC_LEFTMARGIN 0x0001
// #define EC_RIGHTMARGIN 0x0002
// #define EC_USEFONTINFO 0xffff
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0500)
// /* wParam of EM_GET/SETIMESTATUS */
// #define EMSIS_COMPOSITIONSTRING 0x0001
// /* lParam for EMSIS_COMPOSITIONSTRING */
// #define EIMES_GETCOMPSTRATONCE 0x0001
// #define EIMES_CANCELCOMPSTRINFOCUS 0x0002
// #define EIMES_COMPLETECOMPSTRKILLFOCUS 0x0004
// #endif /* WINVER >= 0x0500 */
// #ifndef NOWINMESSAGES
// /*
// * Edit Control Messages
// */
// #define EM_GETSEL 0x00B0
// #define EM_SETSEL 0x00B1
// #define EM_GETRECT 0x00B2
// #define EM_SETRECT 0x00B3
// #define EM_SETRECTNP 0x00B4
// #define EM_SCROLL 0x00B5
// #define EM_LINESCROLL 0x00B6
// #define EM_SCROLLCARET 0x00B7
// #define EM_GETMODIFY 0x00B8
// #define EM_SETMODIFY 0x00B9
// #define EM_GETLINECOUNT 0x00BA
// #define EM_LINEINDEX 0x00BB
// #define EM_SETHANDLE 0x00BC
// #define EM_GETHANDLE 0x00BD
// #define EM_GETTHUMB 0x00BE
// #define EM_LINELENGTH 0x00C1
// #define EM_REPLACESEL 0x00C2
// #define EM_GETLINE 0x00C4
// #define EM_LIMITTEXT 0x00C5
// #define EM_CANUNDO 0x00C6
// #define EM_UNDO 0x00C7
// #define EM_FMTLINES 0x00C8
// #define EM_LINEFROMCHAR 0x00C9
// #define EM_SETTABSTOPS 0x00CB
// #define EM_SETPASSWORDCHAR 0x00CC
// #define EM_EMPTYUNDOBUFFER 0x00CD
// #define EM_GETFIRSTVISIBLELINE 0x00CE
// #define EM_SETREADONLY 0x00CF
// #define EM_SETWORDBREAKPROC 0x00D0
// #define EM_GETWORDBREAKPROC 0x00D1
// #define EM_GETPASSWORDCHAR 0x00D2
// #if(WINVER >= 0x0400)
// #define EM_SETMARGINS 0x00D3
// #define EM_GETMARGINS 0x00D4
// #define EM_SETLIMITTEXT EM_LIMITTEXT /* ;win40 Name change */
// #define EM_GETLIMITTEXT 0x00D5
// #define EM_POSFROMCHAR 0x00D6
// #define EM_CHARFROMPOS 0x00D7
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0500)
// #define EM_SETIMESTATUS 0x00D8
// #define EM_GETIMESTATUS 0x00D9
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0604)
// #define EM_ENABLEFEATURE 0x00DA
// #endif /* WINVER >= 0x0604 */
// #endif /* !NOWINMESSAGES */
// #if(WINVER >= 0x0604)
// /*
// * EM_ENABLEFEATURE options
// */
// typedef enum {
// EDIT_CONTROL_FEATURE_ENTERPRISE_DATA_PROTECTION_PASTE_SUPPORT = 0,
// EDIT_CONTROL_FEATURE_PASTE_NOTIFICATIONS = 1,
// } EDIT_CONTROL_FEATURE;
// #endif /* WINVER >= 0x0604 */
// /*
// * EDITWORDBREAKPROC code values
// */
// #define WB_LEFT 0
// #define WB_RIGHT 1
// #define WB_ISDELIMITER 2
// /*
// * Button Control Styles
// */
// #define BS_PUSHBUTTON 0x00000000L
// #define BS_DEFPUSHBUTTON 0x00000001L
// #define BS_CHECKBOX 0x00000002L
// #define BS_AUTOCHECKBOX 0x00000003L
// #define BS_RADIOBUTTON 0x00000004L
// #define BS_3STATE 0x00000005L
// #define BS_AUTO3STATE 0x00000006L
// #define BS_GROUPBOX 0x00000007L
// #define BS_USERBUTTON 0x00000008L
// #define BS_AUTORADIOBUTTON 0x00000009L
// #define BS_PUSHBOX 0x0000000AL
// #define BS_OWNERDRAW 0x0000000BL
// #define BS_TYPEMASK 0x0000000FL
// #define BS_LEFTTEXT 0x00000020L
// #if(WINVER >= 0x0400)
// #define BS_TEXT 0x00000000L
// #define BS_ICON 0x00000040L
// #define BS_BITMAP 0x00000080L
// #define BS_LEFT 0x00000100L
// #define BS_RIGHT 0x00000200L
// #define BS_CENTER 0x00000300L
// #define BS_TOP 0x00000400L
// #define BS_BOTTOM 0x00000800L
// #define BS_VCENTER 0x00000C00L
// #define BS_PUSHLIKE 0x00001000L
// #define BS_MULTILINE 0x00002000L
// #define BS_NOTIFY 0x00004000L
// #define BS_FLAT 0x00008000L
// #define BS_RIGHTBUTTON BS_LEFTTEXT
// #endif /* WINVER >= 0x0400 */
// /*
// * User Button Notification Codes
// */
// #define BN_CLICKED 0
// #define BN_PAINT 1
// #define BN_HILITE 2
// #define BN_UNHILITE 3
// #define BN_DISABLE 4
// #define BN_DOUBLECLICKED 5
// #if(WINVER >= 0x0400)
// #define BN_PUSHED BN_HILITE
// #define BN_UNPUSHED BN_UNHILITE
// #define BN_DBLCLK BN_DOUBLECLICKED
// #define BN_SETFOCUS 6
// #define BN_KILLFOCUS 7
// #endif /* WINVER >= 0x0400 */
// /*
// * Button Control Messages
// */
// #define BM_GETCHECK 0x00F0
// #define BM_SETCHECK 0x00F1
// #define BM_GETSTATE 0x00F2
// #define BM_SETSTATE 0x00F3
// #define BM_SETSTYLE 0x00F4
// #if(WINVER >= 0x0400)
// #define BM_CLICK 0x00F5
// #define BM_GETIMAGE 0x00F6
// #define BM_SETIMAGE 0x00F7
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0600)
// #define BM_SETDONTCLICK 0x00F8
// #endif /* WINVER >= 0x0600 */
// #if(WINVER >= 0x0400)
// #define BST_UNCHECKED 0x0000
// #define BST_CHECKED 0x0001
// #define BST_INDETERMINATE 0x0002
// #define BST_PUSHED 0x0004
// #define BST_FOCUS 0x0008
// #endif /* WINVER >= 0x0400 */
// /*
// * Static Control Constants
// */
// #define SS_LEFT 0x00000000L
// #define SS_CENTER 0x00000001L
// #define SS_RIGHT 0x00000002L
// #define SS_ICON 0x00000003L
// #define SS_BLACKRECT 0x00000004L
// #define SS_GRAYRECT 0x00000005L
// #define SS_WHITERECT 0x00000006L
// #define SS_BLACKFRAME 0x00000007L
// #define SS_GRAYFRAME 0x00000008L
// #define SS_WHITEFRAME 0x00000009L
// #define SS_USERITEM 0x0000000AL
// #define SS_SIMPLE 0x0000000BL
// #define SS_LEFTNOWORDWRAP 0x0000000CL
// #if(WINVER >= 0x0400)
// #define SS_OWNERDRAW 0x0000000DL
// #define SS_BITMAP 0x0000000EL
// #define SS_ENHMETAFILE 0x0000000FL
// #define SS_ETCHEDHORZ 0x00000010L
// #define SS_ETCHEDVERT 0x00000011L
// #define SS_ETCHEDFRAME 0x00000012L
// #define SS_TYPEMASK 0x0000001FL
// #endif /* WINVER >= 0x0400 */
// #if(WINVER >= 0x0501)
// #define SS_REALSIZECONTROL 0x00000040L
// #endif /* WINVER >= 0x0501 */
// #define SS_NOPREFIX 0x00000080L /* Don't do "&" character translation */
// #if(WINVER >= 0x0400)
// #define SS_NOTIFY 0x00000100L
// #define SS_CENTERIMAGE 0x00000200L
// #define SS_RIGHTJUST 0x00000400L
// #define SS_REALSIZEIMAGE 0x00000800L
// #define SS_SUNKEN 0x00001000L
// #define SS_EDITCONTROL 0x00002000L
// #define SS_ENDELLIPSIS 0x00004000L
// #define SS_PATHELLIPSIS 0x00008000L
// #define SS_WORDELLIPSIS 0x0000C000L
// #define SS_ELLIPSISMASK 0x0000C000L
// #endif /* WINVER >= 0x0400 */
// #ifndef NOWINMESSAGES
// /*
// * Static Control Mesages
// */
// #define STM_SETICON 0x0170
// #define STM_GETICON 0x0171
// #if(WINVER >= 0x0400)
// #define STM_SETIMAGE 0x0172
// #define STM_GETIMAGE 0x0173
// #define STN_CLICKED 0
// #define STN_DBLCLK 1
// #define STN_ENABLE 2
// #define STN_DISABLE 3
// #endif /* WINVER >= 0x0400 */
// #define STM_MSGMAX 0x0174
// #endif /* !NOWINMESSAGES */
// /*
// * Dialog window class
// */
// #define WC_DIALOG (MAKEINTATOM(0x8002))
// /*
// * Get/SetWindowWord/Long offsets for use with WC_DIALOG windows
// */
// #define DWL_MSGRESULT 0
// #define DWL_DLGPROC 4
// #define DWL_USER 8
// #ifdef _WIN64
// #undef DWL_MSGRESULT
// #undef DWL_DLGPROC
// #undef DWL_USER
// #endif /* _WIN64 */
// #define DWLP_MSGRESULT 0
// #define DWLP_DLGPROC DWLP_MSGRESULT + sizeof(LRESULT)
// #define DWLP_USER DWLP_DLGPROC + sizeof(DLGPROC)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Dialog Manager Routines
// */
// #ifndef NOMSG
// WINUSERAPI
// BOOL
// WINAPI
// IsDialogMessageA(
// _In_ HWND hDlg,
// _In_ LPMSG lpMsg);
// WINUSERAPI
// BOOL
// WINAPI
// IsDialogMessageW(
// _In_ HWND hDlg,
// _In_ LPMSG lpMsg);
// #ifdef UNICODE
// #define IsDialogMessage IsDialogMessageW
// #else
// #define IsDialogMessage IsDialogMessageA
// #endif // !UNICODE
// #endif /* !NOMSG */
// WINUSERAPI
// BOOL
// WINAPI
// MapDialogRect(
// _In_ HWND hDlg,
// _Inout_ LPRECT lpRect);
// WINUSERAPI
// int
// WINAPI
// DlgDirListA(
// _In_ HWND hDlg,
// _Inout_ LPSTR lpPathSpec,
// _In_ int nIDListBox,
// _In_ int nIDStaticPath,
// _In_ UINT uFileType);
// WINUSERAPI
// int
// WINAPI
// DlgDirListW(
// _In_ HWND hDlg,
// _Inout_ LPWSTR lpPathSpec,
// _In_ int nIDListBox,
// _In_ int nIDStaticPath,
// _In_ UINT uFileType);
// #ifdef UNICODE
// #define DlgDirList DlgDirListW
// #else
// #define DlgDirList DlgDirListA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * DlgDirList, DlgDirListComboBox flags values
// */
// #define DDL_READWRITE 0x0000
// #define DDL_READONLY 0x0001
// #define DDL_HIDDEN 0x0002
// #define DDL_SYSTEM 0x0004
// #define DDL_DIRECTORY 0x0010
// #define DDL_ARCHIVE 0x0020
// #define DDL_POSTMSGS 0x2000
// #define DDL_DRIVES 0x4000
// #define DDL_EXCLUSIVE 0x8000
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// DlgDirSelectExA(
// _In_ HWND hwndDlg,
// _Out_writes_(chCount) LPSTR lpString,
// _In_ int chCount,
// _In_ int idListBox);
// WINUSERAPI
// BOOL
// WINAPI
// DlgDirSelectExW(
// _In_ HWND hwndDlg,
// _Out_writes_(chCount) LPWSTR lpString,
// _In_ int chCount,
// _In_ int idListBox);
// #ifdef UNICODE
// #define DlgDirSelectEx DlgDirSelectExW
// #else
// #define DlgDirSelectEx DlgDirSelectExA
// #endif // !UNICODE
// WINUSERAPI
// int
// WINAPI
// DlgDirListComboBoxA(
// _In_ HWND hDlg,
// _Inout_ LPSTR lpPathSpec,
// _In_ int nIDComboBox,
// _In_ int nIDStaticPath,
// _In_ UINT uFiletype);
// WINUSERAPI
// int
// WINAPI
// DlgDirListComboBoxW(
// _In_ HWND hDlg,
// _Inout_ LPWSTR lpPathSpec,
// _In_ int nIDComboBox,
// _In_ int nIDStaticPath,
// _In_ UINT uFiletype);
// #ifdef UNICODE
// #define DlgDirListComboBox DlgDirListComboBoxW
// #else
// #define DlgDirListComboBox DlgDirListComboBoxA
// #endif // !UNICODE
// WINUSERAPI
// BOOL
// WINAPI
// DlgDirSelectComboBoxExA(
// _In_ HWND hwndDlg,
// _Out_writes_(cchOut) LPSTR lpString,
// _In_ int cchOut,
// _In_ int idComboBox);
// WINUSERAPI
// BOOL
// WINAPI
// DlgDirSelectComboBoxExW(
// _In_ HWND hwndDlg,
// _Out_writes_(cchOut) LPWSTR lpString,
// _In_ int cchOut,
// _In_ int idComboBox);
// #ifdef UNICODE
// #define DlgDirSelectComboBoxEx DlgDirSelectComboBoxExW
// #else
// #define DlgDirSelectComboBoxEx DlgDirSelectComboBoxExA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Dialog Styles
// */
// #define DS_ABSALIGN 0x01L
// #define DS_SYSMODAL 0x02L
// #define DS_LOCALEDIT 0x20L /* Edit items get Local storage. */
// #define DS_SETFONT 0x40L /* User specified font for Dlg controls */
// #define DS_MODALFRAME 0x80L /* Can be combined with WS_CAPTION */
// #define DS_NOIDLEMSG 0x100L /* WM_ENTERIDLE message will not be sent */
// #define DS_SETFOREGROUND 0x200L /* not in win3.1 */
// #if(WINVER >= 0x0400)
// #define DS_3DLOOK 0x0004L
// #define DS_FIXEDSYS 0x0008L
// #define DS_NOFAILCREATE 0x0010L
// #define DS_CONTROL 0x0400L
// #define DS_CENTER 0x0800L
// #define DS_CENTERMOUSE 0x1000L
// #define DS_CONTEXTHELP 0x2000L
// #define DS_SHELLFONT (DS_SETFONT | DS_FIXEDSYS)
// #endif /* WINVER >= 0x0400 */
// #if defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0500)
// #define DS_USEPIXELS 0x8000L
// #endif
// #define DM_GETDEFID (WM_USER+0)
// #define DM_SETDEFID (WM_USER+1)
// #if(WINVER >= 0x0400)
// #define DM_REPOSITION (WM_USER+2)
// #endif /* WINVER >= 0x0400 */
// /*
// * Returned in HIWORD() of DM_GETDEFID result if msg is supported
// */
// #define DC_HASDEFID 0x534B
// /*
// * Dialog Codes
// */
// #define DLGC_WANTARROWS 0x0001 /* Control wants arrow keys */
// #define DLGC_WANTTAB 0x0002 /* Control wants tab keys */
// #define DLGC_WANTALLKEYS 0x0004 /* Control wants all keys */
// #define DLGC_WANTMESSAGE 0x0004 /* Pass message to control */
// #define DLGC_HASSETSEL 0x0008 /* Understands EM_SETSEL message */
// #define DLGC_DEFPUSHBUTTON 0x0010 /* Default pushbutton */
// #define DLGC_UNDEFPUSHBUTTON 0x0020 /* Non-default pushbutton */
// #define DLGC_RADIOBUTTON 0x0040 /* Radio button */
// #define DLGC_WANTCHARS 0x0080 /* Want WM_CHAR messages */
// #define DLGC_STATIC 0x0100 /* Static item: don't include */
// #define DLGC_BUTTON 0x2000 /* Button item: can be checked */
// #define LB_CTLCODE 0L
// /*
// * Listbox Return Values
// */
// #define LB_OKAY 0
// #define LB_ERR (-1)
// #define LB_ERRSPACE (-2)
// /*
// ** The idStaticPath parameter to DlgDirList can have the following values
// ** ORed if the list box should show other details of the files along with
// ** the name of the files;
// */
// /* all other details also will be returned */
// /*
// * Listbox Notification Codes
// */
// #define LBN_ERRSPACE (-2)
// #define LBN_SELCHANGE 1
// #define LBN_DBLCLK 2
// #define LBN_SELCANCEL 3
// #define LBN_SETFOCUS 4
// #define LBN_KILLFOCUS 5
// #ifndef NOWINMESSAGES
// /*
// * Listbox messages
// */
// #define LB_ADDSTRING 0x0180
// #define LB_INSERTSTRING 0x0181
// #define LB_DELETESTRING 0x0182
// #define LB_SELITEMRANGEEX 0x0183
// #define LB_RESETCONTENT 0x0184
// #define LB_SETSEL 0x0185
// #define LB_SETCURSEL 0x0186
// #define LB_GETSEL 0x0187
// #define LB_GETCURSEL 0x0188
// #define LB_GETTEXT 0x0189
// #define LB_GETTEXTLEN 0x018A
// #define LB_GETCOUNT 0x018B
// #define LB_SELECTSTRING 0x018C
// #define LB_DIR 0x018D
// #define LB_GETTOPINDEX 0x018E
// #define LB_FINDSTRING 0x018F
// #define LB_GETSELCOUNT 0x0190
// #define LB_GETSELITEMS 0x0191
// #define LB_SETTABSTOPS 0x0192
// #define LB_GETHORIZONTALEXTENT 0x0193
// #define LB_SETHORIZONTALEXTENT 0x0194
// #define LB_SETCOLUMNWIDTH 0x0195
// #define LB_ADDFILE 0x0196
// #define LB_SETTOPINDEX 0x0197
// #define LB_GETITEMRECT 0x0198
// #define LB_GETITEMDATA 0x0199
// #define LB_SETITEMDATA 0x019A
// #define LB_SELITEMRANGE 0x019B
// #define LB_SETANCHORINDEX 0x019C
// #define LB_GETANCHORINDEX 0x019D
// #define LB_SETCARETINDEX 0x019E
// #define LB_GETCARETINDEX 0x019F
// #define LB_SETITEMHEIGHT 0x01A0
// #define LB_GETITEMHEIGHT 0x01A1
// #define LB_FINDSTRINGEXACT 0x01A2
// #define LB_SETLOCALE 0x01A5
// #define LB_GETLOCALE 0x01A6
// #define LB_SETCOUNT 0x01A7
// #if(WINVER >= 0x0400)
// #define LB_INITSTORAGE 0x01A8
// #define LB_ITEMFROMPOINT 0x01A9
// #endif /* WINVER >= 0x0400 */
// #if defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0400)
// #define LB_MULTIPLEADDSTRING 0x01B1
// #endif
// #if(_WIN32_WINNT >= 0x0501)
// #define LB_GETLISTBOXINFO 0x01B2
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0501)
// #define LB_MSGMAX 0x01B3
// #elif defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0400)
// #define LB_MSGMAX 0x01B1
// #elif(WINVER >= 0x0400)
// #define LB_MSGMAX 0x01B0
// #else
// #define LB_MSGMAX 0x01A8
// #endif
// #endif /* !NOWINMESSAGES */
// #ifndef NOWINSTYLES
// /*
// * Listbox Styles
// */
// #define LBS_NOTIFY 0x0001L
// #define LBS_SORT 0x0002L
// #define LBS_NOREDRAW 0x0004L
// #define LBS_MULTIPLESEL 0x0008L
// #define LBS_OWNERDRAWFIXED 0x0010L
// #define LBS_OWNERDRAWVARIABLE 0x0020L
// #define LBS_HASSTRINGS 0x0040L
// #define LBS_USETABSTOPS 0x0080L
// #define LBS_NOINTEGRALHEIGHT 0x0100L
// #define LBS_MULTICOLUMN 0x0200L
// #define LBS_WANTKEYBOARDINPUT 0x0400L
// #define LBS_EXTENDEDSEL 0x0800L
// #define LBS_DISABLENOSCROLL 0x1000L
// #define LBS_NODATA 0x2000L
// #if(WINVER >= 0x0400)
// #define LBS_NOSEL 0x4000L
// #endif /* WINVER >= 0x0400 */
// #define LBS_COMBOBOX 0x8000L
// #define LBS_STANDARD (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)
// #endif /* !NOWINSTYLES */
// /*
// * Combo Box return Values
// */
// #define CB_OKAY 0
// #define CB_ERR (-1)
// #define CB_ERRSPACE (-2)
// /*
// * Combo Box Notification Codes
// */
// #define CBN_ERRSPACE (-1)
// #define CBN_SELCHANGE 1
// #define CBN_DBLCLK 2
// #define CBN_SETFOCUS 3
// #define CBN_KILLFOCUS 4
// #define CBN_EDITCHANGE 5
// #define CBN_EDITUPDATE 6
// #define CBN_DROPDOWN 7
// #define CBN_CLOSEUP 8
// #define CBN_SELENDOK 9
// #define CBN_SELENDCANCEL 10
// #ifndef NOWINSTYLES
// /*
// * Combo Box styles
// */
// #define CBS_SIMPLE 0x0001L
// #define CBS_DROPDOWN 0x0002L
// #define CBS_DROPDOWNLIST 0x0003L
// #define CBS_OWNERDRAWFIXED 0x0010L
// #define CBS_OWNERDRAWVARIABLE 0x0020L
// #define CBS_AUTOHSCROLL 0x0040L
// #define CBS_OEMCONVERT 0x0080L
// #define CBS_SORT 0x0100L
// #define CBS_HASSTRINGS 0x0200L
// #define CBS_NOINTEGRALHEIGHT 0x0400L
// #define CBS_DISABLENOSCROLL 0x0800L
// #if(WINVER >= 0x0400)
// #define CBS_UPPERCASE 0x2000L
// #define CBS_LOWERCASE 0x4000L
// #endif /* WINVER >= 0x0400 */
// #endif /* !NOWINSTYLES */
// /*
// * Combo Box messages
// */
// #ifndef NOWINMESSAGES
// #define CB_GETEDITSEL 0x0140
// #define CB_LIMITTEXT 0x0141
// #define CB_SETEDITSEL 0x0142
// #define CB_ADDSTRING 0x0143
// #define CB_DELETESTRING 0x0144
// #define CB_DIR 0x0145
// #define CB_GETCOUNT 0x0146
// #define CB_GETCURSEL 0x0147
// #define CB_GETLBTEXT 0x0148
// #define CB_GETLBTEXTLEN 0x0149
// #define CB_INSERTSTRING 0x014A
// #define CB_RESETCONTENT 0x014B
// #define CB_FINDSTRING 0x014C
// #define CB_SELECTSTRING 0x014D
// #define CB_SETCURSEL 0x014E
// #define CB_SHOWDROPDOWN 0x014F
// #define CB_GETITEMDATA 0x0150
// #define CB_SETITEMDATA 0x0151
// #define CB_GETDROPPEDCONTROLRECT 0x0152
// #define CB_SETITEMHEIGHT 0x0153
// #define CB_GETITEMHEIGHT 0x0154
// #define CB_SETEXTENDEDUI 0x0155
// #define CB_GETEXTENDEDUI 0x0156
// #define CB_GETDROPPEDSTATE 0x0157
// #define CB_FINDSTRINGEXACT 0x0158
// #define CB_SETLOCALE 0x0159
// #define CB_GETLOCALE 0x015A
// #if(WINVER >= 0x0400)
// #define CB_GETTOPINDEX 0x015b
// #define CB_SETTOPINDEX 0x015c
// #define CB_GETHORIZONTALEXTENT 0x015d
// #define CB_SETHORIZONTALEXTENT 0x015e
// #define CB_GETDROPPEDWIDTH 0x015f
// #define CB_SETDROPPEDWIDTH 0x0160
// #define CB_INITSTORAGE 0x0161
// #if defined(_WIN32_WCE) &&(_WIN32_WCE >= 0x0400)
// #define CB_MULTIPLEADDSTRING 0x0163
// #endif
// #endif /* WINVER >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0501)
// #define CB_GETCOMBOBOXINFO 0x0164
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0501)
// #define CB_MSGMAX 0x0165
// #elif defined(_WIN32_WCE) && (_WIN32_WCE >= 0x0400)
// #define CB_MSGMAX 0x0163
// #elif(WINVER >= 0x0400)
// #define CB_MSGMAX 0x0162
// #else
// #define CB_MSGMAX 0x015B
// #endif
// #endif /* !NOWINMESSAGES */
// #ifndef NOWINSTYLES
// /*
// * Scroll Bar Styles
// */
// #define SBS_HORZ 0x0000L
// #define SBS_VERT 0x0001L
// #define SBS_TOPALIGN 0x0002L
// #define SBS_LEFTALIGN 0x0002L
// #define SBS_BOTTOMALIGN 0x0004L
// #define SBS_RIGHTALIGN 0x0004L
// #define SBS_SIZEBOXTOPLEFTALIGN 0x0002L
// #define SBS_SIZEBOXBOTTOMRIGHTALIGN 0x0004L
// #define SBS_SIZEBOX 0x0008L
// #if(WINVER >= 0x0400)
// #define SBS_SIZEGRIP 0x0010L
// #endif /* WINVER >= 0x0400 */
// #endif /* !NOWINSTYLES */
// /*
// * Scroll bar messages
// */
// #ifndef NOWINMESSAGES
// #define SBM_SETPOS 0x00E0 /*not in win3.1 */
// #define SBM_GETPOS 0x00E1 /*not in win3.1 */
// #define SBM_SETRANGE 0x00E2 /*not in win3.1 */
// #define SBM_SETRANGEREDRAW 0x00E6 /*not in win3.1 */
// #define SBM_GETRANGE 0x00E3 /*not in win3.1 */
// #define SBM_ENABLE_ARROWS 0x00E4 /*not in win3.1 */
// #if(WINVER >= 0x0400)
// #define SBM_SETSCROLLINFO 0x00E9
// #define SBM_GETSCROLLINFO 0x00EA
// #endif /* WINVER >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0501)
// #define SBM_GETSCROLLBARINFO 0x00EB
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(WINVER >= 0x0400)
// #define SIF_RANGE 0x0001
// #define SIF_PAGE 0x0002
// #define SIF_POS 0x0004
// #define SIF_DISABLENOSCROLL 0x0008
// #define SIF_TRACKPOS 0x0010
// #define SIF_ALL (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagSCROLLINFO
// {
// UINT cbSize;
// UINT fMask;
// int nMin;
// int nMax;
// UINT nPage;
// int nPos;
// int nTrackPos;
// } SCROLLINFO, FAR *LPSCROLLINFO;
// typedef SCROLLINFO CONST FAR *LPCSCROLLINFO;
// WINUSERAPI
// int
// WINAPI
// SetScrollInfo(
// _In_ HWND hwnd,
// _In_ int nBar,
// _In_ LPCSCROLLINFO lpsi,
// _In_ BOOL redraw);
// WINUSERAPI
// BOOL
// WINAPI
// GetScrollInfo(
// _In_ HWND hwnd,
// _In_ int nBar,
// _Inout_ LPSCROLLINFO lpsi);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0400 */
// #endif /* !NOWINMESSAGES */
// #endif /* !NOCTLMGR */
// #ifndef NOMDI
// /*
// * MDI client style bits
// */
// #define MDIS_ALLCHILDSTYLES 0x0001
// /*
// * wParam Flags for WM_MDITILE and WM_MDICASCADE messages.
// */
// #define MDITILE_VERTICAL 0x0000 /*not in win3.1 */
// #define MDITILE_HORIZONTAL 0x0001 /*not in win3.1 */
// #define MDITILE_SKIPDISABLED 0x0002 /*not in win3.1 */
// #if(_WIN32_WINNT >= 0x0500)
// #define MDITILE_ZORDER 0x0004
// #endif /* _WIN32_WINNT >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagMDICREATESTRUCTA {
// LPCSTR szClass;
// LPCSTR szTitle;
// HANDLE hOwner;
// int x;
// int y;
// int cx;
// int cy;
// DWORD style;
// LPARAM lParam; /* app-defined stuff */
// } MDICREATESTRUCTA, *LPMDICREATESTRUCTA;
// typedef struct tagMDICREATESTRUCTW {
// LPCWSTR szClass;
// LPCWSTR szTitle;
// HANDLE hOwner;
// int x;
// int y;
// int cx;
// int cy;
// DWORD style;
// LPARAM lParam; /* app-defined stuff */
// } MDICREATESTRUCTW, *LPMDICREATESTRUCTW;
// #ifdef UNICODE
// typedef MDICREATESTRUCTW MDICREATESTRUCT;
// typedef LPMDICREATESTRUCTW LPMDICREATESTRUCT;
// #else
// typedef MDICREATESTRUCTA MDICREATESTRUCT;
// typedef LPMDICREATESTRUCTA LPMDICREATESTRUCT;
// #endif // UNICODE
// typedef struct tagCLIENTCREATESTRUCT {
// HANDLE hWindowMenu;
// UINT idFirstChild;
// } CLIENTCREATESTRUCT, *LPCLIENTCREATESTRUCT;
// WINUSERAPI
// LRESULT
// WINAPI
// DefFrameProcA(
// _In_ HWND hWnd,
// _In_opt_ HWND hWndMDIClient,
// _In_ UINT uMsg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// LRESULT
// WINAPI
// DefFrameProcW(
// _In_ HWND hWnd,
// _In_opt_ HWND hWndMDIClient,
// _In_ UINT uMsg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define DefFrameProc DefFrameProcW
// #else
// #define DefFrameProc DefFrameProcA
// #endif // !UNICODE
// WINUSERAPI
// #ifndef _MAC
// LRESULT
// WINAPI
// #else
// LRESULT
// CALLBACK
// #endif
// DefMDIChildProcA(
// _In_ HWND hWnd,
// _In_ UINT uMsg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// WINUSERAPI
// #ifndef _MAC
// LRESULT
// WINAPI
// #else
// LRESULT
// CALLBACK
// #endif
// DefMDIChildProcW(
// _In_ HWND hWnd,
// _In_ UINT uMsg,
// _In_ WPARAM wParam,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define DefMDIChildProc DefMDIChildProcW
// #else
// #define DefMDIChildProc DefMDIChildProcA
// #endif // !UNICODE
// #ifndef NOMSG
// WINUSERAPI
// BOOL
// WINAPI
// TranslateMDISysAccel(
// _In_ HWND hWndClient,
// _In_ LPMSG lpMsg);
// #endif /* !NOMSG */
// WINUSERAPI
// UINT
// WINAPI
// ArrangeIconicWindows(
// _In_ HWND hWnd);
// WINUSERAPI
// HWND
// WINAPI
// CreateMDIWindowA(
// _In_ LPCSTR lpClassName,
// _In_ LPCSTR lpWindowName,
// _In_ DWORD dwStyle,
// _In_ int X,
// _In_ int Y,
// _In_ int nWidth,
// _In_ int nHeight,
// _In_opt_ HWND hWndParent,
// _In_opt_ HINSTANCE hInstance,
// _In_ LPARAM lParam);
// WINUSERAPI
// HWND
// WINAPI
// CreateMDIWindowW(
// _In_ LPCWSTR lpClassName,
// _In_ LPCWSTR lpWindowName,
// _In_ DWORD dwStyle,
// _In_ int X,
// _In_ int Y,
// _In_ int nWidth,
// _In_ int nHeight,
// _In_opt_ HWND hWndParent,
// _In_opt_ HINSTANCE hInstance,
// _In_ LPARAM lParam);
// #ifdef UNICODE
// #define CreateMDIWindow CreateMDIWindowW
// #else
// #define CreateMDIWindow CreateMDIWindowA
// #endif // !UNICODE
// #if(WINVER >= 0x0400)
// WINUSERAPI
// WORD
// WINAPI
// TileWindows(
// _In_opt_ HWND hwndParent,
// _In_ UINT wHow,
// _In_opt_ CONST RECT * lpRect,
// _In_ UINT cKids,
// _In_reads_opt_(cKids) const HWND FAR * lpKids);
// WINUSERAPI
// WORD
// WINAPI CascadeWindows(
// _In_opt_ HWND hwndParent,
// _In_ UINT wHow,
// _In_opt_ CONST RECT * lpRect,
// _In_ UINT cKids,
// _In_reads_opt_(cKids) const HWND FAR * lpKids);
// #endif /* WINVER >= 0x0400 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOMDI */
// #endif /* !NOUSER */
// /****** Help support ********************************************************/
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #ifndef NOHELP
// typedef DWORD HELPPOLY;
// typedef struct tagMULTIKEYHELPA {
// #ifndef _MAC
// DWORD mkSize;
// #else
// WORD mkSize;
// #endif
// CHAR mkKeylist;
// CHAR szKeyphrase[1];
// } MULTIKEYHELPA, *PMULTIKEYHELPA, *LPMULTIKEYHELPA;
// typedef struct tagMULTIKEYHELPW {
// #ifndef _MAC
// DWORD mkSize;
// #else
// WORD mkSize;
// #endif
// WCHAR mkKeylist;
// WCHAR szKeyphrase[1];
// } MULTIKEYHELPW, *PMULTIKEYHELPW, *LPMULTIKEYHELPW;
// #ifdef UNICODE
// typedef MULTIKEYHELPW MULTIKEYHELP;
// typedef PMULTIKEYHELPW PMULTIKEYHELP;
// typedef LPMULTIKEYHELPW LPMULTIKEYHELP;
// #else
// typedef MULTIKEYHELPA MULTIKEYHELP;
// typedef PMULTIKEYHELPA PMULTIKEYHELP;
// typedef LPMULTIKEYHELPA LPMULTIKEYHELP;
// #endif // UNICODE
// typedef struct tagHELPWININFOA {
// int wStructSize;
// int x;
// int y;
// int dx;
// int dy;
// int wMax;
// CHAR rgchMember[2];
// } HELPWININFOA, *PHELPWININFOA, *LPHELPWININFOA;
// typedef struct tagHELPWININFOW {
// int wStructSize;
// int x;
// int y;
// int dx;
// int dy;
// int wMax;
// WCHAR rgchMember[2];
// } HELPWININFOW, *PHELPWININFOW, *LPHELPWININFOW;
// #ifdef UNICODE
// typedef HELPWININFOW HELPWININFO;
// typedef PHELPWININFOW PHELPWININFO;
// typedef LPHELPWININFOW LPHELPWININFO;
// #else
// typedef HELPWININFOA HELPWININFO;
// typedef PHELPWININFOA PHELPWININFO;
// typedef LPHELPWININFOA LPHELPWININFO;
// #endif // UNICODE
// /*
// * Commands to pass to WinHelp()
// */
// #define HELP_CONTEXT 0x0001L /* Display topic in ulTopic */
// #define HELP_QUIT 0x0002L /* Terminate help */
// #define HELP_INDEX 0x0003L /* Display index */
// #define HELP_CONTENTS 0x0003L
// #define HELP_HELPONHELP 0x0004L /* Display help on using help */
// #define HELP_SETINDEX 0x0005L /* Set current Index for multi index help */
// #define HELP_SETCONTENTS 0x0005L
// #define HELP_CONTEXTPOPUP 0x0008L
// #define HELP_FORCEFILE 0x0009L
// #define HELP_KEY 0x0101L /* Display topic for keyword in offabData */
// #define HELP_COMMAND 0x0102L
// #define HELP_PARTIALKEY 0x0105L
// #define HELP_MULTIKEY 0x0201L
// #define HELP_SETWINPOS 0x0203L
// #if(WINVER >= 0x0400)
// #define HELP_CONTEXTMENU 0x000a
// #define HELP_FINDER 0x000b
// #define HELP_WM_HELP 0x000c
// #define HELP_SETPOPUP_POS 0x000d
// #define HELP_TCARD 0x8000
// #define HELP_TCARD_DATA 0x0010
// #define HELP_TCARD_OTHER_CALLER 0x0011
// // These are in winhelp.h in Win95.
// #define IDH_NO_HELP 28440
// #define IDH_MISSING_CONTEXT 28441 // Control doesn't have matching help context
// #define IDH_GENERIC_HELP_BUTTON 28442 // Property sheet help button
// #define IDH_OK 28443
// #define IDH_CANCEL 28444
// #define IDH_HELP 28445
// #endif /* WINVER >= 0x0400 */
// WINUSERAPI
// BOOL
// WINAPI
// WinHelpA(
// _In_opt_ HWND hWndMain,
// _In_opt_ LPCSTR lpszHelp,
// _In_ UINT uCommand,
// _In_ ULONG_PTR dwData);
// WINUSERAPI
// BOOL
// WINAPI
// WinHelpW(
// _In_opt_ HWND hWndMain,
// _In_opt_ LPCWSTR lpszHelp,
// _In_ UINT uCommand,
// _In_ ULONG_PTR dwData);
// #ifdef UNICODE
// #define WinHelp WinHelpW
// #else
// #define WinHelp WinHelpA
// #endif // !UNICODE
// #endif /* !NOHELP */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0500)
// #define GR_GDIOBJECTS 0 /* Count of GDI objects */
// #define GR_USEROBJECTS 1 /* Count of USER objects */
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0601)
// #define GR_GDIOBJECTS_PEAK 2 /* Peak count of GDI objects */
// #define GR_USEROBJECTS_PEAK 4 /* Peak count of USER objects */
// #endif /* WINVER >= 0x0601 */
// #if(WINVER >= 0x0601)
// #define GR_GLOBAL ((HANDLE)-2)
// #endif /* WINVER >= 0x0601 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if(WINVER >= 0x0500)
// WINUSERAPI
// DWORD
// WINAPI
// GetGuiResources(
// _In_ HANDLE hProcess,
// _In_ DWORD uiFlags);
// #endif /* WINVER >= 0x0500 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NOSYSPARAMSINFO
// /*
// * Parameter for SystemParametersInfo.
// */
// #define SPI_GETBEEP 0x0001
// #define SPI_SETBEEP 0x0002
// #define SPI_GETMOUSE 0x0003
// #define SPI_SETMOUSE 0x0004
// #define SPI_GETBORDER 0x0005
// #define SPI_SETBORDER 0x0006
// #define SPI_GETKEYBOARDSPEED 0x000A
// #define SPI_SETKEYBOARDSPEED 0x000B
// #define SPI_LANGDRIVER 0x000C
// #define SPI_ICONHORIZONTALSPACING 0x000D
// #define SPI_GETSCREENSAVETIMEOUT 0x000E
// #define SPI_SETSCREENSAVETIMEOUT 0x000F
// #define SPI_GETSCREENSAVEACTIVE 0x0010
// #define SPI_SETSCREENSAVEACTIVE 0x0011
// #define SPI_GETGRIDGRANULARITY 0x0012
// #define SPI_SETGRIDGRANULARITY 0x0013
// #define SPI_SETDESKWALLPAPER 0x0014
// #define SPI_SETDESKPATTERN 0x0015
// #define SPI_GETKEYBOARDDELAY 0x0016
// #define SPI_SETKEYBOARDDELAY 0x0017
// #define SPI_ICONVERTICALSPACING 0x0018
// #define SPI_GETICONTITLEWRAP 0x0019
// #define SPI_SETICONTITLEWRAP 0x001A
// #define SPI_GETMENUDROPALIGNMENT 0x001B
// #define SPI_SETMENUDROPALIGNMENT 0x001C
// #define SPI_SETDOUBLECLKWIDTH 0x001D
// #define SPI_SETDOUBLECLKHEIGHT 0x001E
// #define SPI_GETICONTITLELOGFONT 0x001F
// #define SPI_SETDOUBLECLICKTIME 0x0020
// #define SPI_SETMOUSEBUTTONSWAP 0x0021
// #define SPI_SETICONTITLELOGFONT 0x0022
// #define SPI_GETFASTTASKSWITCH 0x0023
// #define SPI_SETFASTTASKSWITCH 0x0024
// #if(WINVER >= 0x0400)
// #define SPI_SETDRAGFULLWINDOWS 0x0025
// #define SPI_GETDRAGFULLWINDOWS 0x0026
// #define SPI_GETNONCLIENTMETRICS 0x0029
// #define SPI_SETNONCLIENTMETRICS 0x002A
// #define SPI_GETMINIMIZEDMETRICS 0x002B
// #define SPI_SETMINIMIZEDMETRICS 0x002C
// #define SPI_GETICONMETRICS 0x002D
// #define SPI_SETICONMETRICS 0x002E
// #define SPI_SETWORKAREA 0x002F
// #define SPI_GETWORKAREA 0x0030
// #define SPI_SETPENWINDOWS 0x0031
// #define SPI_GETHIGHCONTRAST 0x0042
// #define SPI_SETHIGHCONTRAST 0x0043
// #define SPI_GETKEYBOARDPREF 0x0044
// #define SPI_SETKEYBOARDPREF 0x0045
// #define SPI_GETSCREENREADER 0x0046
// #define SPI_SETSCREENREADER 0x0047
// #define SPI_GETANIMATION 0x0048
// #define SPI_SETANIMATION 0x0049
// #define SPI_GETFONTSMOOTHING 0x004A
// #define SPI_SETFONTSMOOTHING 0x004B
// #define SPI_SETDRAGWIDTH 0x004C
// #define SPI_SETDRAGHEIGHT 0x004D
// #define SPI_SETHANDHELD 0x004E
// #define SPI_GETLOWPOWERTIMEOUT 0x004F
// #define SPI_GETPOWEROFFTIMEOUT 0x0050
// #define SPI_SETLOWPOWERTIMEOUT 0x0051
// #define SPI_SETPOWEROFFTIMEOUT 0x0052
// #define SPI_GETLOWPOWERACTIVE 0x0053
// #define SPI_GETPOWEROFFACTIVE 0x0054
// #define SPI_SETLOWPOWERACTIVE 0x0055
// #define SPI_SETPOWEROFFACTIVE 0x0056
// #define SPI_SETCURSORS 0x0057
// #define SPI_SETICONS 0x0058
// #define SPI_GETDEFAULTINPUTLANG 0x0059
// #define SPI_SETDEFAULTINPUTLANG 0x005A
// #define SPI_SETLANGTOGGLE 0x005B
// #define SPI_GETWINDOWSEXTENSION 0x005C
// #define SPI_SETMOUSETRAILS 0x005D
// #define SPI_GETMOUSETRAILS 0x005E
// #define SPI_SETSCREENSAVERRUNNING 0x0061
// #define SPI_SCREENSAVERRUNNING SPI_SETSCREENSAVERRUNNING
// #endif /* WINVER >= 0x0400 */
// #define SPI_GETFILTERKEYS 0x0032
// #define SPI_SETFILTERKEYS 0x0033
// #define SPI_GETTOGGLEKEYS 0x0034
// #define SPI_SETTOGGLEKEYS 0x0035
// #define SPI_GETMOUSEKEYS 0x0036
// #define SPI_SETMOUSEKEYS 0x0037
// #define SPI_GETSHOWSOUNDS 0x0038
// #define SPI_SETSHOWSOUNDS 0x0039
// #define SPI_GETSTICKYKEYS 0x003A
// #define SPI_SETSTICKYKEYS 0x003B
// #define SPI_GETACCESSTIMEOUT 0x003C
// #define SPI_SETACCESSTIMEOUT 0x003D
// #if(WINVER >= 0x0400)
// #define SPI_GETSERIALKEYS 0x003E
// #define SPI_SETSERIALKEYS 0x003F
// #endif /* WINVER >= 0x0400 */
// #define SPI_GETSOUNDSENTRY 0x0040
// #define SPI_SETSOUNDSENTRY 0x0041
// #if(_WIN32_WINNT >= 0x0400)
// #define SPI_GETSNAPTODEFBUTTON 0x005F
// #define SPI_SETSNAPTODEFBUTTON 0x0060
// #endif /* _WIN32_WINNT >= 0x0400 */
// #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
// #define SPI_GETMOUSEHOVERWIDTH 0x0062
// #define SPI_SETMOUSEHOVERWIDTH 0x0063
// #define SPI_GETMOUSEHOVERHEIGHT 0x0064
// #define SPI_SETMOUSEHOVERHEIGHT 0x0065
// #define SPI_GETMOUSEHOVERTIME 0x0066
// #define SPI_SETMOUSEHOVERTIME 0x0067
// #define SPI_GETWHEELSCROLLLINES 0x0068
// #define SPI_SETWHEELSCROLLLINES 0x0069
// #define SPI_GETMENUSHOWDELAY 0x006A
// #define SPI_SETMENUSHOWDELAY 0x006B
// #if (_WIN32_WINNT >= 0x0600)
// #define SPI_GETWHEELSCROLLCHARS 0x006C
// #define SPI_SETWHEELSCROLLCHARS 0x006D
// #endif
// #define SPI_GETSHOWIMEUI 0x006E
// #define SPI_SETSHOWIMEUI 0x006F
// #endif
// #if(WINVER >= 0x0500)
// #define SPI_GETMOUSESPEED 0x0070
// #define SPI_SETMOUSESPEED 0x0071
// #define SPI_GETSCREENSAVERRUNNING 0x0072
// #define SPI_GETDESKWALLPAPER 0x0073
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0600)
// #define SPI_GETAUDIODESCRIPTION 0x0074
// #define SPI_SETAUDIODESCRIPTION 0x0075
// #define SPI_GETSCREENSAVESECURE 0x0076
// #define SPI_SETSCREENSAVESECURE 0x0077
// #endif /* WINVER >= 0x0600 */
// #if(_WIN32_WINNT >= 0x0601)
// #define SPI_GETHUNGAPPTIMEOUT 0x0078
// #define SPI_SETHUNGAPPTIMEOUT 0x0079
// #define SPI_GETWAITTOKILLTIMEOUT 0x007A
// #define SPI_SETWAITTOKILLTIMEOUT 0x007B
// #define SPI_GETWAITTOKILLSERVICETIMEOUT 0x007C
// #define SPI_SETWAITTOKILLSERVICETIMEOUT 0x007D
// #define SPI_GETMOUSEDOCKTHRESHOLD 0x007E
// #define SPI_SETMOUSEDOCKTHRESHOLD 0x007F
// #define SPI_GETPENDOCKTHRESHOLD 0x0080
// #define SPI_SETPENDOCKTHRESHOLD 0x0081
// #define SPI_GETWINARRANGING 0x0082
// #define SPI_SETWINARRANGING 0x0083
// #define SPI_GETMOUSEDRAGOUTTHRESHOLD 0x0084
// #define SPI_SETMOUSEDRAGOUTTHRESHOLD 0x0085
// #define SPI_GETPENDRAGOUTTHRESHOLD 0x0086
// #define SPI_SETPENDRAGOUTTHRESHOLD 0x0087
// #define SPI_GETMOUSESIDEMOVETHRESHOLD 0x0088
// #define SPI_SETMOUSESIDEMOVETHRESHOLD 0x0089
// #define SPI_GETPENSIDEMOVETHRESHOLD 0x008A
// #define SPI_SETPENSIDEMOVETHRESHOLD 0x008B
// #define SPI_GETDRAGFROMMAXIMIZE 0x008C
// #define SPI_SETDRAGFROMMAXIMIZE 0x008D
// #define SPI_GETSNAPSIZING 0x008E
// #define SPI_SETSNAPSIZING 0x008F
// #define SPI_GETDOCKMOVING 0x0090
// #define SPI_SETDOCKMOVING 0x0091
// #endif /* _WIN32_WINNT >= 0x0601 */
// #if(WINVER >= 0x0602)
// #define MAX_TOUCH_PREDICTION_FILTER_TAPS 3
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagTouchPredictionParameters
// {
// UINT cbSize;
// UINT dwLatency; // Latency in millisecs
// UINT dwSampleTime; // Sample time in millisecs (used to deduce velocity)
// UINT bUseHWTimeStamp; // Use H/W TimeStamps
// } TOUCHPREDICTIONPARAMETERS, *PTOUCHPREDICTIONPARAMETERS;
// #define TOUCHPREDICTIONPARAMETERS_DEFAULT_LATENCY 8
// #define TOUCHPREDICTIONPARAMETERS_DEFAULT_SAMPLETIME 8
// #define TOUCHPREDICTIONPARAMETERS_DEFAULT_USE_HW_TIMESTAMP 1
// #define TOUCHPREDICTIONPARAMETERS_DEFAULT_RLS_DELTA 0.001f
// #define TOUCHPREDICTIONPARAMETERS_DEFAULT_RLS_LAMBDA_MIN 0.9f
// #define TOUCHPREDICTIONPARAMETERS_DEFAULT_RLS_LAMBDA_MAX 0.999f
// #define TOUCHPREDICTIONPARAMETERS_DEFAULT_RLS_LAMBDA_LEARNING_RATE 0.001f
// #define TOUCHPREDICTIONPARAMETERS_DEFAULT_RLS_EXPO_SMOOTH_ALPHA 0.99f
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define SPI_GETTOUCHPREDICTIONPARAMETERS 0x009C
// #define SPI_SETTOUCHPREDICTIONPARAMETERS 0x009D
// #define MAX_LOGICALDPIOVERRIDE 2
// #define MIN_LOGICALDPIOVERRIDE -2
// #define SPI_GETLOGICALDPIOVERRIDE 0x009E
// #define SPI_SETLOGICALDPIOVERRIDE 0x009F
// #define SPI_GETMENURECT 0x00A2
// #define SPI_SETMENURECT 0x00A3
// #endif /* WINVER >= 0x0602 */
// #if(WINVER >= 0x0500)
// #define SPI_GETACTIVEWINDOWTRACKING 0x1000
// #define SPI_SETACTIVEWINDOWTRACKING 0x1001
// #define SPI_GETMENUANIMATION 0x1002
// #define SPI_SETMENUANIMATION 0x1003
// #define SPI_GETCOMBOBOXANIMATION 0x1004
// #define SPI_SETCOMBOBOXANIMATION 0x1005
// #define SPI_GETLISTBOXSMOOTHSCROLLING 0x1006
// #define SPI_SETLISTBOXSMOOTHSCROLLING 0x1007
// #define SPI_GETGRADIENTCAPTIONS 0x1008
// #define SPI_SETGRADIENTCAPTIONS 0x1009
// #define SPI_GETKEYBOARDCUES 0x100A
// #define SPI_SETKEYBOARDCUES 0x100B
// #define SPI_GETMENUUNDERLINES SPI_GETKEYBOARDCUES
// #define SPI_SETMENUUNDERLINES SPI_SETKEYBOARDCUES
// #define SPI_GETACTIVEWNDTRKZORDER 0x100C
// #define SPI_SETACTIVEWNDTRKZORDER 0x100D
// #define SPI_GETHOTTRACKING 0x100E
// #define SPI_SETHOTTRACKING 0x100F
// #define SPI_GETMENUFADE 0x1012
// #define SPI_SETMENUFADE 0x1013
// #define SPI_GETSELECTIONFADE 0x1014
// #define SPI_SETSELECTIONFADE 0x1015
// #define SPI_GETTOOLTIPANIMATION 0x1016
// #define SPI_SETTOOLTIPANIMATION 0x1017
// #define SPI_GETTOOLTIPFADE 0x1018
// #define SPI_SETTOOLTIPFADE 0x1019
// #define SPI_GETCURSORSHADOW 0x101A
// #define SPI_SETCURSORSHADOW 0x101B
// #if(_WIN32_WINNT >= 0x0501)
// #define SPI_GETMOUSESONAR 0x101C
// #define SPI_SETMOUSESONAR 0x101D
// #define SPI_GETMOUSECLICKLOCK 0x101E
// #define SPI_SETMOUSECLICKLOCK 0x101F
// #define SPI_GETMOUSEVANISH 0x1020
// #define SPI_SETMOUSEVANISH 0x1021
// #define SPI_GETFLATMENU 0x1022
// #define SPI_SETFLATMENU 0x1023
// #define SPI_GETDROPSHADOW 0x1024
// #define SPI_SETDROPSHADOW 0x1025
// #define SPI_GETBLOCKSENDINPUTRESETS 0x1026
// #define SPI_SETBLOCKSENDINPUTRESETS 0x1027
// #endif /* _WIN32_WINNT >= 0x0501 */
// #define SPI_GETUIEFFECTS 0x103E
// #define SPI_SETUIEFFECTS 0x103F
// #if(_WIN32_WINNT >= 0x0600)
// #define SPI_GETDISABLEOVERLAPPEDCONTENT 0x1040
// #define SPI_SETDISABLEOVERLAPPEDCONTENT 0x1041
// #define SPI_GETCLIENTAREAANIMATION 0x1042
// #define SPI_SETCLIENTAREAANIMATION 0x1043
// #define SPI_GETCLEARTYPE 0x1048
// #define SPI_SETCLEARTYPE 0x1049
// #define SPI_GETSPEECHRECOGNITION 0x104A
// #define SPI_SETSPEECHRECOGNITION 0x104B
// #endif /* _WIN32_WINNT >= 0x0600 */
// #if(WINVER >= 0x0601)
// #define SPI_GETCARETBROWSING 0x104C
// #define SPI_SETCARETBROWSING 0x104D
// #define SPI_GETTHREADLOCALINPUTSETTINGS 0x104E
// #define SPI_SETTHREADLOCALINPUTSETTINGS 0x104F
// #define SPI_GETSYSTEMLANGUAGEBAR 0x1050
// #define SPI_SETSYSTEMLANGUAGEBAR 0x1051
// #endif /* WINVER >= 0x0601 */
// #if (NTDDI_VERSION >= NTDDI_WIN10_RS3)
// #endif // NTDDI_VERSION >= NTDDI_WIN10_RS3
// #define SPI_GETFOREGROUNDLOCKTIMEOUT 0x2000
// #define SPI_SETFOREGROUNDLOCKTIMEOUT 0x2001
// #define SPI_GETACTIVEWNDTRKTIMEOUT 0x2002
// #define SPI_SETACTIVEWNDTRKTIMEOUT 0x2003
// #define SPI_GETFOREGROUNDFLASHCOUNT 0x2004
// #define SPI_SETFOREGROUNDFLASHCOUNT 0x2005
// #define SPI_GETCARETWIDTH 0x2006
// #define SPI_SETCARETWIDTH 0x2007
// #if(_WIN32_WINNT >= 0x0501)
// #define SPI_GETMOUSECLICKLOCKTIME 0x2008
// #define SPI_SETMOUSECLICKLOCKTIME 0x2009
// #define SPI_GETFONTSMOOTHINGTYPE 0x200A
// #define SPI_SETFONTSMOOTHINGTYPE 0x200B
// /* constants for SPI_GETFONTSMOOTHINGTYPE and SPI_SETFONTSMOOTHINGTYPE: */
// #define FE_FONTSMOOTHINGSTANDARD 0x0001
// #define FE_FONTSMOOTHINGCLEARTYPE 0x0002
// #define SPI_GETFONTSMOOTHINGCONTRAST 0x200C
// #define SPI_SETFONTSMOOTHINGCONTRAST 0x200D
// #define SPI_GETFOCUSBORDERWIDTH 0x200E
// #define SPI_SETFOCUSBORDERWIDTH 0x200F
// #define SPI_GETFOCUSBORDERHEIGHT 0x2010
// #define SPI_SETFOCUSBORDERHEIGHT 0x2011
// #define SPI_GETFONTSMOOTHINGORIENTATION 0x2012
// #define SPI_SETFONTSMOOTHINGORIENTATION 0x2013
// /* constants for SPI_GETFONTSMOOTHINGORIENTATION and SPI_SETFONTSMOOTHINGORIENTATION: */
// #define FE_FONTSMOOTHINGORIENTATIONBGR 0x0000
// #define FE_FONTSMOOTHINGORIENTATIONRGB 0x0001
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0600)
// #define SPI_GETMINIMUMHITRADIUS 0x2014
// #define SPI_SETMINIMUMHITRADIUS 0x2015
// #define SPI_GETMESSAGEDURATION 0x2016
// #define SPI_SETMESSAGEDURATION 0x2017
// #endif /* _WIN32_WINNT >= 0x0600 */
// #if(WINVER >= 0x0602)
// #define SPI_GETCONTACTVISUALIZATION 0x2018
// #define SPI_SETCONTACTVISUALIZATION 0x2019
// /* constants for SPI_GETCONTACTVISUALIZATION and SPI_SETCONTACTVISUALIZATION */
// #define CONTACTVISUALIZATION_OFF 0x0000
// #define CONTACTVISUALIZATION_ON 0x0001
// #define CONTACTVISUALIZATION_PRESENTATIONMODE 0x0002
// #define SPI_GETGESTUREVISUALIZATION 0x201A
// #define SPI_SETGESTUREVISUALIZATION 0x201B
// /* constants for SPI_GETGESTUREVISUALIZATION and SPI_SETGESTUREVISUALIZATION */
// #define GESTUREVISUALIZATION_OFF 0x0000
// #define GESTUREVISUALIZATION_ON 0x001F
// #define GESTUREVISUALIZATION_TAP 0x0001
// #define GESTUREVISUALIZATION_DOUBLETAP 0x0002
// #define GESTUREVISUALIZATION_PRESSANDTAP 0x0004
// #define GESTUREVISUALIZATION_PRESSANDHOLD 0x0008
// #define GESTUREVISUALIZATION_RIGHTTAP 0x0010
// #endif /* WINVER >= 0x0602 */
// #if(WINVER >= 0x0602)
// #define SPI_GETMOUSEWHEELROUTING 0x201C
// #define SPI_SETMOUSEWHEELROUTING 0x201D
// #define MOUSEWHEEL_ROUTING_FOCUS 0
// #define MOUSEWHEEL_ROUTING_HYBRID 1
// #if(WINVER >= 0x0603)
// #define MOUSEWHEEL_ROUTING_MOUSE_POS 2
// #endif /* WINVER >= 0x0603 */
// #endif /* WINVER >= 0x0602 */
// #if(WINVER >= 0x0604)
// #define SPI_GETPENVISUALIZATION 0x201E
// #define SPI_SETPENVISUALIZATION 0x201F
// /* constants for SPI_{GET|SET}PENVISUALIZATION */
// #define PENVISUALIZATION_ON 0x0023
// #define PENVISUALIZATION_OFF 0x0000
// #define PENVISUALIZATION_TAP 0x0001
// #define PENVISUALIZATION_DOUBLETAP 0x0002
// #define PENVISUALIZATION_CURSOR 0x0020
// #define SPI_GETPENARBITRATIONTYPE 0x2020
// #define SPI_SETPENARBITRATIONTYPE 0x2021
// /* constants for SPI_{GET|SET}PENARBITRATIONTYPE */
// #define PENARBITRATIONTYPE_NONE 0x0000
// #define PENARBITRATIONTYPE_WIN8 0x0001
// #define PENARBITRATIONTYPE_FIS 0x0002
// #define PENARBITRATIONTYPE_SPT 0x0003
// #define PENARBITRATIONTYPE_MAX 0x0004
// #endif /* WINVER >= 0x0604 */
// #if (NTDDI_VERSION >= NTDDI_WIN10_RS3)
// #define SPI_GETCARETTIMEOUT 0x2022
// #define SPI_SETCARETTIMEOUT 0x2023
// #endif // NTDDI_VERSION >= NTDDI_WIN10_RS3
// #endif /* WINVER >= 0x0500 */
// /*
// * Flags
// */
// #define SPIF_UPDATEINIFILE 0x0001
// #define SPIF_SENDWININICHANGE 0x0002
// #define SPIF_SENDCHANGE SPIF_SENDWININICHANGE
// #define METRICS_USEDEFAULT -1
// #ifdef _WINGDI_
// #ifndef NOGDI
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagNONCLIENTMETRICSA
// {
// UINT cbSize;
// int iBorderWidth;
// int iScrollWidth;
// int iScrollHeight;
// int iCaptionWidth;
// int iCaptionHeight;
// LOGFONTA lfCaptionFont;
// int iSmCaptionWidth;
// int iSmCaptionHeight;
// LOGFONTA lfSmCaptionFont;
// int iMenuWidth;
// int iMenuHeight;
// LOGFONTA lfMenuFont;
// LOGFONTA lfStatusFont;
// LOGFONTA lfMessageFont;
// #if(WINVER >= 0x0600)
// int iPaddedBorderWidth;
// #endif /* WINVER >= 0x0600 */
// } NONCLIENTMETRICSA, *PNONCLIENTMETRICSA, FAR* LPNONCLIENTMETRICSA;
// typedef struct tagNONCLIENTMETRICSW
// {
// UINT cbSize;
// int iBorderWidth;
// int iScrollWidth;
// int iScrollHeight;
// int iCaptionWidth;
// int iCaptionHeight;
// LOGFONTW lfCaptionFont;
// int iSmCaptionWidth;
// int iSmCaptionHeight;
// LOGFONTW lfSmCaptionFont;
// int iMenuWidth;
// int iMenuHeight;
// LOGFONTW lfMenuFont;
// LOGFONTW lfStatusFont;
// LOGFONTW lfMessageFont;
// #if(WINVER >= 0x0600)
// int iPaddedBorderWidth;
// #endif /* WINVER >= 0x0600 */
// } NONCLIENTMETRICSW, *PNONCLIENTMETRICSW, FAR* LPNONCLIENTMETRICSW;
// #ifdef UNICODE
// typedef NONCLIENTMETRICSW NONCLIENTMETRICS;
// typedef PNONCLIENTMETRICSW PNONCLIENTMETRICS;
// typedef LPNONCLIENTMETRICSW LPNONCLIENTMETRICS;
// #else
// typedef NONCLIENTMETRICSA NONCLIENTMETRICS;
// typedef PNONCLIENTMETRICSA PNONCLIENTMETRICS;
// typedef LPNONCLIENTMETRICSA LPNONCLIENTMETRICS;
// #endif // UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* NOGDI */
// #endif /* _WINGDI_ */
// #define ARW_BOTTOMLEFT 0x0000L
// #define ARW_BOTTOMRIGHT 0x0001L
// #define ARW_TOPLEFT 0x0002L
// #define ARW_TOPRIGHT 0x0003L
// #define ARW_STARTMASK 0x0003L
// #define ARW_STARTRIGHT 0x0001L
// #define ARW_STARTTOP 0x0002L
// #define ARW_LEFT 0x0000L
// #define ARW_RIGHT 0x0000L
// #define ARW_UP 0x0004L
// #define ARW_DOWN 0x0004L
// #define ARW_HIDE 0x0008L
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagMINIMIZEDMETRICS
// {
// UINT cbSize;
// int iWidth;
// int iHorzGap;
// int iVertGap;
// int iArrange;
// } MINIMIZEDMETRICS, *PMINIMIZEDMETRICS, *LPMINIMIZEDMETRICS;
// #ifdef _WINGDI_
// #ifndef NOGDI
// typedef struct tagICONMETRICSA
// {
// UINT cbSize;
// int iHorzSpacing;
// int iVertSpacing;
// int iTitleWrap;
// LOGFONTA lfFont;
// } ICONMETRICSA, *PICONMETRICSA, *LPICONMETRICSA;
// typedef struct tagICONMETRICSW
// {
// UINT cbSize;
// int iHorzSpacing;
// int iVertSpacing;
// int iTitleWrap;
// LOGFONTW lfFont;
// } ICONMETRICSW, *PICONMETRICSW, *LPICONMETRICSW;
// #ifdef UNICODE
// typedef ICONMETRICSW ICONMETRICS;
// typedef PICONMETRICSW PICONMETRICS;
// typedef LPICONMETRICSW LPICONMETRICS;
// #else
// typedef ICONMETRICSA ICONMETRICS;
// typedef PICONMETRICSA PICONMETRICS;
// typedef LPICONMETRICSA LPICONMETRICS;
// #endif // UNICODE
// #endif /* NOGDI */
// #endif /* _WINGDI_ */
// typedef struct tagANIMATIONINFO
// {
// UINT cbSize;
// int iMinAnimate;
// } ANIMATIONINFO, *LPANIMATIONINFO;
// typedef struct tagSERIALKEYSA
// {
// UINT cbSize;
// DWORD dwFlags;
// LPSTR lpszActivePort;
// LPSTR lpszPort;
// UINT iBaudRate;
// UINT iPortState;
// UINT iActive;
// } SERIALKEYSA, *LPSERIALKEYSA;
// typedef struct tagSERIALKEYSW
// {
// UINT cbSize;
// DWORD dwFlags;
// LPWSTR lpszActivePort;
// LPWSTR lpszPort;
// UINT iBaudRate;
// UINT iPortState;
// UINT iActive;
// } SERIALKEYSW, *LPSERIALKEYSW;
// #ifdef UNICODE
// typedef SERIALKEYSW SERIALKEYS;
// typedef LPSERIALKEYSW LPSERIALKEYS;
// #else
// typedef SERIALKEYSA SERIALKEYS;
// typedef LPSERIALKEYSA LPSERIALKEYS;
// #endif // UNICODE
// /* flags for SERIALKEYS dwFlags field */
// #define SERKF_SERIALKEYSON 0x00000001
// #define SERKF_AVAILABLE 0x00000002
// #define SERKF_INDICATOR 0x00000004
// typedef struct tagHIGHCONTRASTA
// {
// UINT cbSize;
// DWORD dwFlags;
// LPSTR lpszDefaultScheme;
// } HIGHCONTRASTA, *LPHIGHCONTRASTA;
// typedef struct tagHIGHCONTRASTW
// {
// UINT cbSize;
// DWORD dwFlags;
// LPWSTR lpszDefaultScheme;
// } HIGHCONTRASTW, *LPHIGHCONTRASTW;
// #ifdef UNICODE
// typedef HIGHCONTRASTW HIGHCONTRAST;
// typedef LPHIGHCONTRASTW LPHIGHCONTRAST;
// #else
// typedef HIGHCONTRASTA HIGHCONTRAST;
// typedef LPHIGHCONTRASTA LPHIGHCONTRAST;
// #endif // UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /* flags for HIGHCONTRAST dwFlags field */
// #define HCF_HIGHCONTRASTON 0x00000001
// #define HCF_AVAILABLE 0x00000002
// #define HCF_HOTKEYACTIVE 0x00000004
// #define HCF_CONFIRMHOTKEY 0x00000008
// #define HCF_HOTKEYSOUND 0x00000010
// #define HCF_INDICATOR 0x00000020
// #define HCF_HOTKEYAVAILABLE 0x00000040
// #define HCF_LOGONDESKTOP 0x00000100
// #define HCF_DEFAULTDESKTOP 0x00000200
// /* Flags for ChangeDisplaySettings */
// #define CDS_UPDATEREGISTRY 0x00000001
// #define CDS_TEST 0x00000002
// #define CDS_FULLSCREEN 0x00000004
// #define CDS_GLOBAL 0x00000008
// #define CDS_SET_PRIMARY 0x00000010
// #define CDS_VIDEOPARAMETERS 0x00000020
// #if(WINVER >= 0x0600)
// #define CDS_ENABLE_UNSAFE_MODES 0x00000100
// #define CDS_DISABLE_UNSAFE_MODES 0x00000200
// #endif /* WINVER >= 0x0600 */
// #define CDS_RESET 0x40000000
// #define CDS_RESET_EX 0x20000000
// #define CDS_NORESET 0x10000000
// #include <tvout.h>
// /* Return values for ChangeDisplaySettings */
// #define DISP_CHANGE_SUCCESSFUL 0
// #define DISP_CHANGE_RESTART 1
// #define DISP_CHANGE_FAILED -1
// #define DISP_CHANGE_BADMODE -2
// #define DISP_CHANGE_NOTUPDATED -3
// #define DISP_CHANGE_BADFLAGS -4
// #define DISP_CHANGE_BADPARAM -5
// #if(_WIN32_WINNT >= 0x0501)
// #define DISP_CHANGE_BADDUALVIEW -6
// #endif /* _WIN32_WINNT >= 0x0501 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #ifdef _WINGDI_
// #ifndef NOGDI
// WINUSERAPI
// LONG
// WINAPI
// ChangeDisplaySettingsA(
// _In_opt_ DEVMODEA* lpDevMode,
// _In_ DWORD dwFlags);
// WINUSERAPI
// LONG
// WINAPI
// ChangeDisplaySettingsW(
// _In_opt_ DEVMODEW* lpDevMode,
// _In_ DWORD dwFlags);
// #ifdef UNICODE
// #define ChangeDisplaySettings ChangeDisplaySettingsW
// #else
// #define ChangeDisplaySettings ChangeDisplaySettingsA
// #endif // !UNICODE
// WINUSERAPI
// LONG
// WINAPI
// ChangeDisplaySettingsExA(
// _In_opt_ LPCSTR lpszDeviceName,
// _In_opt_ DEVMODEA* lpDevMode,
// _Reserved_ HWND hwnd,
// _In_ DWORD dwflags,
// _In_opt_ LPVOID lParam);
// WINUSERAPI
// LONG
// WINAPI
// ChangeDisplaySettingsExW(
// _In_opt_ LPCWSTR lpszDeviceName,
// _In_opt_ DEVMODEW* lpDevMode,
// _Reserved_ HWND hwnd,
// _In_ DWORD dwflags,
// _In_opt_ LPVOID lParam);
// #ifdef UNICODE
// #define ChangeDisplaySettingsEx ChangeDisplaySettingsExW
// #else
// #define ChangeDisplaySettingsEx ChangeDisplaySettingsExA
// #endif // !UNICODE
// #define ENUM_CURRENT_SETTINGS ((DWORD)-1)
// #define ENUM_REGISTRY_SETTINGS ((DWORD)-2)
// WINUSERAPI
// BOOL
// WINAPI
// EnumDisplaySettingsA(
// _In_opt_ LPCSTR lpszDeviceName,
// _In_ DWORD iModeNum,
// _Inout_ DEVMODEA* lpDevMode);
// WINUSERAPI
// BOOL
// WINAPI
// EnumDisplaySettingsW(
// _In_opt_ LPCWSTR lpszDeviceName,
// _In_ DWORD iModeNum,
// _Inout_ DEVMODEW* lpDevMode);
// #ifdef UNICODE
// #define EnumDisplaySettings EnumDisplaySettingsW
// #else
// #define EnumDisplaySettings EnumDisplaySettingsA
// #endif // !UNICODE
// #if(WINVER >= 0x0500)
// WINUSERAPI
// BOOL
// WINAPI
// EnumDisplaySettingsExA(
// _In_opt_ LPCSTR lpszDeviceName,
// _In_ DWORD iModeNum,
// _Inout_ DEVMODEA* lpDevMode,
// _In_ DWORD dwFlags);
// WINUSERAPI
// BOOL
// WINAPI
// EnumDisplaySettingsExW(
// _In_opt_ LPCWSTR lpszDeviceName,
// _In_ DWORD iModeNum,
// _Inout_ DEVMODEW* lpDevMode,
// _In_ DWORD dwFlags);
// #ifdef UNICODE
// #define EnumDisplaySettingsEx EnumDisplaySettingsExW
// #else
// #define EnumDisplaySettingsEx EnumDisplaySettingsExA
// #endif // !UNICODE
// /* Flags for EnumDisplaySettingsEx */
// #define EDS_RAWMODE 0x00000002
// #define EDS_ROTATEDMODE 0x00000004
// WINUSERAPI
// BOOL
// WINAPI
// EnumDisplayDevicesA(
// _In_opt_ LPCSTR lpDevice,
// _In_ DWORD iDevNum,
// _Inout_ PDISPLAY_DEVICEA lpDisplayDevice,
// _In_ DWORD dwFlags);
// WINUSERAPI
// BOOL
// WINAPI
// EnumDisplayDevicesW(
// _In_opt_ LPCWSTR lpDevice,
// _In_ DWORD iDevNum,
// _Inout_ PDISPLAY_DEVICEW lpDisplayDevice,
// _In_ DWORD dwFlags);
// #ifdef UNICODE
// #define EnumDisplayDevices EnumDisplayDevicesW
// #else
// #define EnumDisplayDevices EnumDisplayDevicesA
// #endif // !UNICODE
// /* Flags for EnumDisplayDevices */
// #define EDD_GET_DEVICE_INTERFACE_NAME 0x00000001
// #endif /* WINVER >= 0x0500 */
// #if(WINVER >= 0x0601)
// WINUSERAPI
// LONG
// WINAPI
// GetDisplayConfigBufferSizes(
// _In_ UINT32 flags,
// _Out_ UINT32* numPathArrayElements,
// _Out_ UINT32* numModeInfoArrayElements);
// WINUSERAPI
// LONG
// WINAPI
// SetDisplayConfig(
// _In_ UINT32 numPathArrayElements,
// _In_reads_opt_(numPathArrayElements) DISPLAYCONFIG_PATH_INFO* pathArray,
// _In_ UINT32 numModeInfoArrayElements,
// _In_reads_opt_(numModeInfoArrayElements) DISPLAYCONFIG_MODE_INFO* modeInfoArray,
// _In_ UINT32 flags);
// WINUSERAPI
// _Success_(return == ERROR_SUCCESS) LONG
// WINAPI
// QueryDisplayConfig(
// _In_ UINT32 flags,
// _Inout_ UINT32* numPathArrayElements,
// _Out_writes_to_(*numPathArrayElements, *numPathArrayElements) DISPLAYCONFIG_PATH_INFO* pathArray,
// _Inout_ UINT32* numModeInfoArrayElements,
// _Out_writes_to_(*numModeInfoArrayElements, *numModeInfoArrayElements) DISPLAYCONFIG_MODE_INFO* modeInfoArray,
// _When_(!(flags & QDC_DATABASE_CURRENT), _Pre_null_)
// _When_(flags & QDC_DATABASE_CURRENT, _Out_)
// DISPLAYCONFIG_TOPOLOGY_ID* currentTopologyId);
// WINUSERAPI
// LONG
// WINAPI
// DisplayConfigGetDeviceInfo(
// _Inout_ DISPLAYCONFIG_DEVICE_INFO_HEADER* requestPacket);
// WINUSERAPI
// LONG
// WINAPI
// DisplayConfigSetDeviceInfo(
// _In_ DISPLAYCONFIG_DEVICE_INFO_HEADER* setPacket);
// #endif /* WINVER >= 0x0601 */
// #endif /* NOGDI */
// #endif /* _WINGDI_ */
// WINUSERAPI
// _Success_(return != FALSE)
// BOOL
// WINAPI
// SystemParametersInfoA(
// _In_ UINT uiAction,
// _In_ UINT uiParam,
// _Pre_maybenull_ _Post_valid_ PVOID pvParam,
// _In_ UINT fWinIni);
// WINUSERAPI
// _Success_(return != FALSE)
// BOOL
// WINAPI
// SystemParametersInfoW(
// _In_ UINT uiAction,
// _In_ UINT uiParam,
// _Pre_maybenull_ _Post_valid_ PVOID pvParam,
// _In_ UINT fWinIni);
// #ifdef UNICODE
// #define SystemParametersInfo SystemParametersInfoW
// #else
// #define SystemParametersInfo SystemParametersInfoA
// #endif // !UNICODE
// #if(WINVER >= 0x0605)
// WINUSERAPI
// _Success_(return != FALSE)
// BOOL
// WINAPI
// SystemParametersInfoForDpi(
// _In_ UINT uiAction,
// _In_ UINT uiParam,
// _Pre_maybenull_ _Post_valid_ PVOID pvParam,
// _In_ UINT fWinIni,
// _In_ UINT dpi);
// #endif /* WINVER >= 0x0605 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* !NOSYSPARAMSINFO */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Accessibility support
// */
// typedef struct tagFILTERKEYS
// {
// UINT cbSize;
// DWORD dwFlags;
// DWORD iWaitMSec; // Acceptance Delay
// DWORD iDelayMSec; // Delay Until Repeat
// DWORD iRepeatMSec; // Repeat Rate
// DWORD iBounceMSec; // Debounce Time
// } FILTERKEYS, *LPFILTERKEYS;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * FILTERKEYS dwFlags field
// */
// #define FKF_FILTERKEYSON 0x00000001
// #define FKF_AVAILABLE 0x00000002
// #define FKF_HOTKEYACTIVE 0x00000004
// #define FKF_CONFIRMHOTKEY 0x00000008
// #define FKF_HOTKEYSOUND 0x00000010
// #define FKF_INDICATOR 0x00000020
// #define FKF_CLICKON 0x00000040
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagSTICKYKEYS
// {
// UINT cbSize;
// DWORD dwFlags;
// } STICKYKEYS, *LPSTICKYKEYS;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * STICKYKEYS dwFlags field
// */
// #define SKF_STICKYKEYSON 0x00000001
// #define SKF_AVAILABLE 0x00000002
// #define SKF_HOTKEYACTIVE 0x00000004
// #define SKF_CONFIRMHOTKEY 0x00000008
// #define SKF_HOTKEYSOUND 0x00000010
// #define SKF_INDICATOR 0x00000020
// #define SKF_AUDIBLEFEEDBACK 0x00000040
// #define SKF_TRISTATE 0x00000080
// #define SKF_TWOKEYSOFF 0x00000100
// #if(_WIN32_WINNT >= 0x0500)
// #define SKF_LALTLATCHED 0x10000000
// #define SKF_LCTLLATCHED 0x04000000
// #define SKF_LSHIFTLATCHED 0x01000000
// #define SKF_RALTLATCHED 0x20000000
// #define SKF_RCTLLATCHED 0x08000000
// #define SKF_RSHIFTLATCHED 0x02000000
// #define SKF_LWINLATCHED 0x40000000
// #define SKF_RWINLATCHED 0x80000000
// #define SKF_LALTLOCKED 0x00100000
// #define SKF_LCTLLOCKED 0x00040000
// #define SKF_LSHIFTLOCKED 0x00010000
// #define SKF_RALTLOCKED 0x00200000
// #define SKF_RCTLLOCKED 0x00080000
// #define SKF_RSHIFTLOCKED 0x00020000
// #define SKF_LWINLOCKED 0x00400000
// #define SKF_RWINLOCKED 0x00800000
// #endif /* _WIN32_WINNT >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagMOUSEKEYS
// {
// UINT cbSize;
// DWORD dwFlags;
// DWORD iMaxSpeed;
// DWORD iTimeToMaxSpeed;
// DWORD iCtrlSpeed;
// DWORD dwReserved1;
// DWORD dwReserved2;
// } MOUSEKEYS, *LPMOUSEKEYS;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * MOUSEKEYS dwFlags field
// */
// #define MKF_MOUSEKEYSON 0x00000001
// #define MKF_AVAILABLE 0x00000002
// #define MKF_HOTKEYACTIVE 0x00000004
// #define MKF_CONFIRMHOTKEY 0x00000008
// #define MKF_HOTKEYSOUND 0x00000010
// #define MKF_INDICATOR 0x00000020
// #define MKF_MODIFIERS 0x00000040
// #define MKF_REPLACENUMBERS 0x00000080
// #if(_WIN32_WINNT >= 0x0500)
// #define MKF_LEFTBUTTONSEL 0x10000000
// #define MKF_RIGHTBUTTONSEL 0x20000000
// #define MKF_LEFTBUTTONDOWN 0x01000000
// #define MKF_RIGHTBUTTONDOWN 0x02000000
// #define MKF_MOUSEMODE 0x80000000
// #endif /* _WIN32_WINNT >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagACCESSTIMEOUT
// {
// UINT cbSize;
// DWORD dwFlags;
// DWORD iTimeOutMSec;
// } ACCESSTIMEOUT, *LPACCESSTIMEOUT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * ACCESSTIMEOUT dwFlags field
// */
// #define ATF_TIMEOUTON 0x00000001
// #define ATF_ONOFFFEEDBACK 0x00000002
// /* values for SOUNDSENTRY iFSGrafEffect field */
// #define SSGF_NONE 0
// #define SSGF_DISPLAY 3
// /* values for SOUNDSENTRY iFSTextEffect field */
// #define SSTF_NONE 0
// #define SSTF_CHARS 1
// #define SSTF_BORDER 2
// #define SSTF_DISPLAY 3
// /* values for SOUNDSENTRY iWindowsEffect field */
// #define SSWF_NONE 0
// #define SSWF_TITLE 1
// #define SSWF_WINDOW 2
// #define SSWF_DISPLAY 3
// #define SSWF_CUSTOM 4
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagSOUNDSENTRYA
// {
// UINT cbSize;
// DWORD dwFlags;
// DWORD iFSTextEffect;
// DWORD iFSTextEffectMSec;
// DWORD iFSTextEffectColorBits;
// DWORD iFSGrafEffect;
// DWORD iFSGrafEffectMSec;
// DWORD iFSGrafEffectColor;
// DWORD iWindowsEffect;
// DWORD iWindowsEffectMSec;
// LPSTR lpszWindowsEffectDLL;
// DWORD iWindowsEffectOrdinal;
// } SOUNDSENTRYA, *LPSOUNDSENTRYA;
// typedef struct tagSOUNDSENTRYW
// {
// UINT cbSize;
// DWORD dwFlags;
// DWORD iFSTextEffect;
// DWORD iFSTextEffectMSec;
// DWORD iFSTextEffectColorBits;
// DWORD iFSGrafEffect;
// DWORD iFSGrafEffectMSec;
// DWORD iFSGrafEffectColor;
// DWORD iWindowsEffect;
// DWORD iWindowsEffectMSec;
// LPWSTR lpszWindowsEffectDLL;
// DWORD iWindowsEffectOrdinal;
// } SOUNDSENTRYW, *LPSOUNDSENTRYW;
// #ifdef UNICODE
// typedef SOUNDSENTRYW SOUNDSENTRY;
// typedef LPSOUNDSENTRYW LPSOUNDSENTRY;
// #else
// typedef SOUNDSENTRYA SOUNDSENTRY;
// typedef LPSOUNDSENTRYA LPSOUNDSENTRY;
// #endif // UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * SOUNDSENTRY dwFlags field
// */
// #define SSF_SOUNDSENTRYON 0x00000001
// #define SSF_AVAILABLE 0x00000002
// #define SSF_INDICATOR 0x00000004
// #pragma region Desktop or PC Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP)
// #if(_WIN32_WINNT >= 0x0600)
// WINUSERAPI
// BOOL
// WINAPI
// SoundSentry(VOID);
// #endif /* _WIN32_WINNT >= 0x0600 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PC_APP) */
// #pragma endregion
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagTOGGLEKEYS
// {
// UINT cbSize;
// DWORD dwFlags;
// } TOGGLEKEYS, *LPTOGGLEKEYS;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * TOGGLEKEYS dwFlags field
// */
// #define TKF_TOGGLEKEYSON 0x00000001
// #define TKF_AVAILABLE 0x00000002
// #define TKF_HOTKEYACTIVE 0x00000004
// #define TKF_CONFIRMHOTKEY 0x00000008
// #define TKF_HOTKEYSOUND 0x00000010
// #define TKF_INDICATOR 0x00000020
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if(_WIN32_WINNT >= 0x0600)
// typedef struct tagAUDIODESCRIPTION {
// UINT cbSize; // sizeof(AudioDescriptionType)
// BOOL Enabled; // On/Off
// LCID Locale; // locale ID for language
// } AUDIODESCRIPTION, *LPAUDIODESCRIPTION;
// #endif /* _WIN32_WINNT >= 0x0600 */
// /*
// * Set debug level
// */
// WINUSERAPI
// VOID
// WINAPI
// SetDebugErrorLevel(
// _In_ DWORD dwLevel);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * SetLastErrorEx() types.
// */
// #define SLE_ERROR 0x00000001
// #define SLE_MINORERROR 0x00000002
// #define SLE_WARNING 0x00000003
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// VOID
// WINAPI
// SetLastErrorEx(
// _In_ DWORD dwErrCode,
// _In_ DWORD dwType);
// WINUSERAPI
// int
// WINAPI
// InternalGetWindowText(
// _In_ HWND hWnd,
// _Out_writes_to_(cchMaxCount, return +1) LPWSTR pString,
// _In_ int cchMaxCount);
// #if defined(WINNT)
// WINUSERAPI
// BOOL
// WINAPI
// EndTask(
// _In_ HWND hWnd,
// _In_ BOOL fShutDown,
// _In_ BOOL fForce);
// #endif
// WINUSERAPI
// BOOL
// WINAPI
// CancelShutdown(
// VOID);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0500)
// /*
// * Multimonitor API.
// */
// #define MONITOR_DEFAULTTONULL 0x00000000
// #define MONITOR_DEFAULTTOPRIMARY 0x00000001
// #define MONITOR_DEFAULTTONEAREST 0x00000002
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HMONITOR
// WINAPI
// MonitorFromPoint(
// _In_ POINT pt,
// _In_ DWORD dwFlags);
// WINUSERAPI
// HMONITOR
// WINAPI
// MonitorFromRect(
// _In_ LPCRECT lprc,
// _In_ DWORD dwFlags);
// WINUSERAPI
// HMONITOR
// WINAPI
// MonitorFromWindow(
// _In_ HWND hwnd,
// _In_ DWORD dwFlags);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define MONITORINFOF_PRIMARY 0x00000001
// #ifndef CCHDEVICENAME
// #define CCHDEVICENAME 32
// #endif
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagMONITORINFO
// {
// DWORD cbSize;
// RECT rcMonitor;
// RECT rcWork;
// DWORD dwFlags;
// } MONITORINFO, *LPMONITORINFO;
// #ifdef __cplusplus
// typedef struct tagMONITORINFOEXA : public tagMONITORINFO
// {
// CHAR szDevice[CCHDEVICENAME];
// } MONITORINFOEXA, *LPMONITORINFOEXA;
// typedef struct tagMONITORINFOEXW : public tagMONITORINFO
// {
// WCHAR szDevice[CCHDEVICENAME];
// } MONITORINFOEXW, *LPMONITORINFOEXW;
// #ifdef UNICODE
// typedef MONITORINFOEXW MONITORINFOEX;
// typedef LPMONITORINFOEXW LPMONITORINFOEX;
// #else
// typedef MONITORINFOEXA MONITORINFOEX;
// typedef LPMONITORINFOEXA LPMONITORINFOEX;
// #endif // UNICODE
// #else // ndef __cplusplus
// typedef struct tagMONITORINFOEXA
// {
// MONITORINFO DUMMYSTRUCTNAME;
// CHAR szDevice[CCHDEVICENAME];
// } MONITORINFOEXA, *LPMONITORINFOEXA;
// typedef struct tagMONITORINFOEXW
// {
// MONITORINFO DUMMYSTRUCTNAME;
// WCHAR szDevice[CCHDEVICENAME];
// } MONITORINFOEXW, *LPMONITORINFOEXW;
// #ifdef UNICODE
// typedef MONITORINFOEXW MONITORINFOEX;
// typedef LPMONITORINFOEXW LPMONITORINFOEX;
// #else
// typedef MONITORINFOEXA MONITORINFOEX;
// typedef LPMONITORINFOEXA LPMONITORINFOEX;
// #endif // UNICODE
// #endif
// WINUSERAPI
// BOOL
// WINAPI
// GetMonitorInfoA(
// _In_ HMONITOR hMonitor,
// _Inout_ LPMONITORINFO lpmi);
// WINUSERAPI
// BOOL
// WINAPI
// GetMonitorInfoW(
// _In_ HMONITOR hMonitor,
// _Inout_ LPMONITORINFO lpmi);
// #ifdef UNICODE
// #define GetMonitorInfo GetMonitorInfoW
// #else
// #define GetMonitorInfo GetMonitorInfoA
// #endif // !UNICODE
// typedef BOOL(CALLBACK* MONITORENUMPROC)(HMONITOR, HDC, LPRECT, LPARAM);
// WINUSERAPI
// BOOL
// WINAPI
// EnumDisplayMonitors(
// _In_opt_ HDC hdc,
// _In_opt_ LPCRECT lprcClip,
// _In_ MONITORENUMPROC lpfnEnum,
// _In_ LPARAM dwData);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NOWINABLE
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * WinEvents - Active Accessibility hooks
// */
// WINUSERAPI
// VOID
// WINAPI
// NotifyWinEvent(
// _In_ DWORD event,
// _In_ HWND hwnd,
// _In_ LONG idObject,
// _In_ LONG idChild);
// typedef VOID(CALLBACK* WINEVENTPROC)(
// HWINEVENTHOOK hWinEventHook,
// DWORD event,
// HWND hwnd,
// LONG idObject,
// LONG idChild,
// DWORD idEventThread,
// DWORD dwmsEventTime);
// WINUSERAPI
// HWINEVENTHOOK
// WINAPI
// SetWinEventHook(
// _In_ DWORD eventMin,
// _In_ DWORD eventMax,
// _In_opt_ HMODULE hmodWinEventProc,
// _In_ WINEVENTPROC pfnWinEventProc,
// _In_ DWORD idProcess,
// _In_ DWORD idThread,
// _In_ DWORD dwFlags);
// #if(_WIN32_WINNT >= 0x0501)
// WINUSERAPI
// BOOL
// WINAPI
// IsWinEventHookInstalled(
// _In_ DWORD event);
// #endif /* _WIN32_WINNT >= 0x0501 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * dwFlags for SetWinEventHook
// */
// #define WINEVENT_OUTOFCONTEXT 0x0000 // Events are ASYNC
// #define WINEVENT_SKIPOWNTHREAD 0x0001 // Don't call back for events on installer's thread
// #define WINEVENT_SKIPOWNPROCESS 0x0002 // Don't call back for events on installer's process
// #define WINEVENT_INCONTEXT 0x0004 // Events are SYNC, this causes your dll to be injected into every process
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// UnhookWinEvent(
// _In_ HWINEVENTHOOK hWinEventHook);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * idObject values for WinEventProc and NotifyWinEvent
// */
// /*
// * hwnd + idObject can be used with OLEACC.DLL's OleGetObjectFromWindow()
// * to get an interface pointer to the container. indexChild is the item
// * within the container in question. Setup a VARIANT with vt VT_I4 and
// * lVal the indexChild and pass that in to all methods. Then you
// * are raring to go.
// */
// /*
// * Common object IDs (cookies, only for sending WM_GETOBJECT to get at the
// * thing in question). Positive IDs are reserved for apps (app specific),
// * negative IDs are system things and are global, 0 means "just little old
// * me".
// */
// #define CHILDID_SELF 0
// #define INDEXID_OBJECT 0
// #define INDEXID_CONTAINER 0
// /*
// * Reserved IDs for system objects
// */
// #define OBJID_WINDOW ((LONG)0x00000000)
// #define OBJID_SYSMENU ((LONG)0xFFFFFFFF)
// #define OBJID_TITLEBAR ((LONG)0xFFFFFFFE)
// #define OBJID_MENU ((LONG)0xFFFFFFFD)
// #define OBJID_CLIENT ((LONG)0xFFFFFFFC)
// #define OBJID_VSCROLL ((LONG)0xFFFFFFFB)
// #define OBJID_HSCROLL ((LONG)0xFFFFFFFA)
// #define OBJID_SIZEGRIP ((LONG)0xFFFFFFF9)
// #define OBJID_CARET ((LONG)0xFFFFFFF8)
// #define OBJID_CURSOR ((LONG)0xFFFFFFF7)
// #define OBJID_ALERT ((LONG)0xFFFFFFF6)
// #define OBJID_SOUND ((LONG)0xFFFFFFF5)
// #define OBJID_QUERYCLASSNAMEIDX ((LONG)0xFFFFFFF4)
// #define OBJID_NATIVEOM ((LONG)0xFFFFFFF0)
// /*
// * EVENT DEFINITION
// */
// #define EVENT_MIN 0x00000001
// #define EVENT_MAX 0x7FFFFFFF
// /*
// * EVENT_SYSTEM_SOUND
// * Sent when a sound is played. Currently nothing is generating this, we
// * this event when a system sound (for menus, etc) is played. Apps
// * generate this, if accessible, when a private sound is played. For
// * example, if Mail plays a "New Mail" sound.
// *
// * System Sounds:
// * (Generated by PlaySoundEvent in USER itself)
// * hwnd is NULL
// * idObject is OBJID_SOUND
// * idChild is sound child ID if one
// * App Sounds:
// * (PlaySoundEvent won't generate notification; up to app)
// * hwnd + idObject gets interface pointer to Sound object
// * idChild identifies the sound in question
// * are going to be cleaning up the SOUNDSENTRY feature in the control panel
// * and will use this at that time. Applications implementing WinEvents
// * are perfectly welcome to use it. Clients of IAccessible* will simply
// * turn around and get back a non-visual object that describes the sound.
// */
// #define EVENT_SYSTEM_SOUND 0x0001
// /*
// * EVENT_SYSTEM_ALERT
// * System Alerts:
// * (Generated by MessageBox() calls for example)
// * hwnd is hwndMessageBox
// * idObject is OBJID_ALERT
// * App Alerts:
// * (Generated whenever)
// * hwnd+idObject gets interface pointer to Alert
// */
// #define EVENT_SYSTEM_ALERT 0x0002
// /*
// * EVENT_SYSTEM_FOREGROUND
// * Sent when the foreground (active) window changes, even if it is changing
// * to another window in the same thread as the previous one.
// * hwnd is hwndNewForeground
// * idObject is OBJID_WINDOW
// * idChild is INDEXID_OBJECT
// */
// #define EVENT_SYSTEM_FOREGROUND 0x0003
// /*
// * Menu
// * hwnd is window (top level window or popup menu window)
// * idObject is ID of control (OBJID_MENU, OBJID_SYSMENU, OBJID_SELF for popup)
// * idChild is CHILDID_SELF
// *
// * EVENT_SYSTEM_MENUSTART
// * EVENT_SYSTEM_MENUEND
// * For MENUSTART, hwnd+idObject+idChild refers to the control with the menu bar,
// * or the control bringing up the context menu.
// *
// * Sent when entering into and leaving from menu mode (system, app bar, and
// * track popups).
// */
// #define EVENT_SYSTEM_MENUSTART 0x0004
// #define EVENT_SYSTEM_MENUEND 0x0005
// /*
// * EVENT_SYSTEM_MENUPOPUPSTART
// * EVENT_SYSTEM_MENUPOPUPEND
// * Sent when a menu popup comes up and just before it is taken down. Note
// * that for a call to TrackPopupMenu(), a client will see EVENT_SYSTEM_MENUSTART
// * followed almost immediately by EVENT_SYSTEM_MENUPOPUPSTART for the popup
// * being shown.
// *
// * For MENUPOPUP, hwnd+idObject+idChild refers to the NEW popup coming up, not the
// * parent item which is hierarchical. You can get the parent menu/popup by
// * asking for the accParent object.
// */
// #define EVENT_SYSTEM_MENUPOPUPSTART 0x0006
// #define EVENT_SYSTEM_MENUPOPUPEND 0x0007
// /*
// * EVENT_SYSTEM_CAPTURESTART
// * EVENT_SYSTEM_CAPTUREEND
// * Sent when a window takes the capture and releases the capture.
// */
// #define EVENT_SYSTEM_CAPTURESTART 0x0008
// #define EVENT_SYSTEM_CAPTUREEND 0x0009
// /*
// * Move Size
// * EVENT_SYSTEM_MOVESIZESTART
// * EVENT_SYSTEM_MOVESIZEEND
// * Sent when a window enters and leaves move-size dragging mode.
// */
// #define EVENT_SYSTEM_MOVESIZESTART 0x000A
// #define EVENT_SYSTEM_MOVESIZEEND 0x000B
// /*
// * Context Help
// * EVENT_SYSTEM_CONTEXTHELPSTART
// * EVENT_SYSTEM_CONTEXTHELPEND
// * Sent when a window enters and leaves context sensitive help mode.
// */
// #define EVENT_SYSTEM_CONTEXTHELPSTART 0x000C
// #define EVENT_SYSTEM_CONTEXTHELPEND 0x000D
// /*
// * Drag & Drop
// * EVENT_SYSTEM_DRAGDROPSTART
// * EVENT_SYSTEM_DRAGDROPEND
// * Send the START notification just before going into drag&drop loop. Send
// * the END notification just after canceling out.
// * Note that it is up to apps and OLE to generate this, since the system
// * doesn't know. Like EVENT_SYSTEM_SOUND, it will be a while before this
// * is prevalent.
// */
// #define EVENT_SYSTEM_DRAGDROPSTART 0x000E
// #define EVENT_SYSTEM_DRAGDROPEND 0x000F
// /*
// * Dialog
// * Send the START notification right after the dialog is completely
// * initialized and visible. Send the END right before the dialog
// * is hidden and goes away.
// * EVENT_SYSTEM_DIALOGSTART
// * EVENT_SYSTEM_DIALOGEND
// */
// #define EVENT_SYSTEM_DIALOGSTART 0x0010
// #define EVENT_SYSTEM_DIALOGEND 0x0011
// /*
// * EVENT_SYSTEM_SCROLLING
// * EVENT_SYSTEM_SCROLLINGSTART
// * EVENT_SYSTEM_SCROLLINGEND
// * Sent when beginning and ending the tracking of a scrollbar in a window,
// * and also for scrollbar controls.
// */
// #define EVENT_SYSTEM_SCROLLINGSTART 0x0012
// #define EVENT_SYSTEM_SCROLLINGEND 0x0013
// /*
// * Alt-Tab Window
// * Send the START notification right after the switch window is initialized
// * and visible. Send the END right before it is hidden and goes away.
// * EVENT_SYSTEM_SWITCHSTART
// * EVENT_SYSTEM_SWITCHEND
// */
// #define EVENT_SYSTEM_SWITCHSTART 0x0014
// #define EVENT_SYSTEM_SWITCHEND 0x0015
// /*
// * EVENT_SYSTEM_MINIMIZESTART
// * EVENT_SYSTEM_MINIMIZEEND
// * Sent when a window minimizes and just before it restores.
// */
// #define EVENT_SYSTEM_MINIMIZESTART 0x0016
// #define EVENT_SYSTEM_MINIMIZEEND 0x0017
// #if(_WIN32_WINNT >= 0x0600)
// #define EVENT_SYSTEM_DESKTOPSWITCH 0x0020
// #endif /* _WIN32_WINNT >= 0x0600 */
// #if(_WIN32_WINNT >= 0x0602)
// // AppGrabbed: HWND = hwnd of app thumbnail, objectID = 0, childID = 0
// #define EVENT_SYSTEM_SWITCHER_APPGRABBED 0x0024
// // OverTarget: HWND = hwnd of app thumbnail, objectID =
// // 1 for center
// // 2 for near snapped
// // 3 for far snapped
// // 4 for prune
// // childID = 0
// #define EVENT_SYSTEM_SWITCHER_APPOVERTARGET 0x0025
// // Dropped: HWND = hwnd of app thumbnail, objectID = <same as above>, childID = 0
// #define EVENT_SYSTEM_SWITCHER_APPDROPPED 0x0026
// // Cancelled: HWND = hwnd of app thumbnail, objectID = 0, childID = 0
// #define EVENT_SYSTEM_SWITCHER_CANCELLED 0x0027
// #endif /* _WIN32_WINNT >= 0x0602 */
// #if(_WIN32_WINNT >= 0x0602)
// /*
// * Sent when an IME's soft key is pressed and should be echoed,
// * but is not passed through the keyboard hook.
// * Must not be sent when a key is sent through the keyboard hook.
// * HWND is the hwnd of the UI containing the soft key
// * idChild is the Unicode value of the character entered
// * idObject is a bitfield
// * 0x00000001: set if a 32-bit Unicode surrogate pair is used
// */
// #define EVENT_SYSTEM_IME_KEY_NOTIFICATION 0x0029
// #endif /* _WIN32_WINNT >= 0x0602 */
// #if(_WIN32_WINNT >= 0x0601)
// #define EVENT_SYSTEM_END 0x00FF
// #define EVENT_OEM_DEFINED_START 0x0101
// #define EVENT_OEM_DEFINED_END 0x01FF
// #define EVENT_UIA_EVENTID_START 0x4E00
// #define EVENT_UIA_EVENTID_END 0x4EFF
// #define EVENT_UIA_PROPID_START 0x7500
// #define EVENT_UIA_PROPID_END 0x75FF
// #endif /* _WIN32_WINNT >= 0x0601 */
// #if(_WIN32_WINNT >= 0x0501)
// #define EVENT_CONSOLE_CARET 0x4001
// #define EVENT_CONSOLE_UPDATE_REGION 0x4002
// #define EVENT_CONSOLE_UPDATE_SIMPLE 0x4003
// #define EVENT_CONSOLE_UPDATE_SCROLL 0x4004
// #define EVENT_CONSOLE_LAYOUT 0x4005
// #define EVENT_CONSOLE_START_APPLICATION 0x4006
// #define EVENT_CONSOLE_END_APPLICATION 0x4007
// /*
// * Flags for EVENT_CONSOLE_START/END_APPLICATION.
// */
// #if defined(_WIN64)
// #define CONSOLE_APPLICATION_16BIT 0x0000
// #else
// #define CONSOLE_APPLICATION_16BIT 0x0001
// #endif
// /*
// * Flags for EVENT_CONSOLE_CARET
// */
// #define CONSOLE_CARET_SELECTION 0x0001
// #define CONSOLE_CARET_VISIBLE 0x0002
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(_WIN32_WINNT >= 0x0601)
// #define EVENT_CONSOLE_END 0x40FF
// #endif /* _WIN32_WINNT >= 0x0601 */
// /*
// * Object events
// *
// * The system AND apps generate these. The system generates these for
// * real windows. Apps generate these for objects within their window which
// * act like a separate control, e.g. an item in a list view.
// *
// * When the system generate them, dwParam2 is always WMOBJID_SELF. When
// * apps generate them, apps put the has-meaning-to-the-app-only ID value
// * in dwParam2.
// * For all events, if you want detailed accessibility information, callers
// * should
// * * Call AccessibleObjectFromWindow() with the hwnd, idObject parameters
// * of the event, and IID_IAccessible as the REFIID, to get back an
// * IAccessible* to talk to
// * * Initialize and fill in a VARIANT as VT_I4 with lVal the idChild
// * parameter of the event.
// * * If idChild isn't zero, call get_accChild() in the container to see
// * if the child is an object in its own right. If so, you will get
// * back an IDispatch* object for the child. You should release the
// * parent, and call QueryInterface() on the child object to get its
// * IAccessible*. Then you talk directly to the child. Otherwise,
// * if get_accChild() returns you nothing, you should continue to
// * use the child VARIANT. You will ask the container for the properties
// * of the child identified by the VARIANT. In other words, the
// * child in this case is accessible but not a full-blown object.
// * Like a button on a titlebar which is 'small' and has no children.
// */
// /*
// * For all EVENT_OBJECT events,
// * hwnd is the dude to Send the WM_GETOBJECT message to (unless NULL,
// * see above for system things)
// * idObject is the ID of the object that can resolve any queries a
// * client might have. It's a way to deal with windowless controls,
// * controls that are just drawn on the screen in some larger parent
// * window (like SDM), or standard frame elements of a window.
// * idChild is the piece inside of the object that is affected. This
// * allows clients to access things that are too small to have full
// * blown objects in their own right. Like the thumb of a scrollbar.
// * The hwnd/idObject pair gets you to the container, the dude you
// * probably want to talk to most of the time anyway. The idChild
// * can then be passed into the acc properties to get the name/value
// * of it as needed.
// *
// * Example #1:
// * System propagating a listbox selection change
// * EVENT_OBJECT_SELECTION
// * hwnd == listbox hwnd
// * idObject == OBJID_WINDOW
// * idChild == new selected item, or CHILDID_SELF if
// * nothing now selected within container.
// * Word '97 propagating a listbox selection change
// * hwnd == SDM window
// * idObject == SDM ID to get at listbox 'control'
// * idChild == new selected item, or CHILDID_SELF if
// * nothing
// *
// * Example #2:
// * System propagating a menu item selection on the menu bar
// * EVENT_OBJECT_SELECTION
// * hwnd == top level window
// * idObject == OBJID_MENU
// * idChild == ID of child menu bar item selected
// *
// * Example #3:
// * System propagating a dropdown coming off of said menu bar item
// * EVENT_OBJECT_CREATE
// * hwnd == popup item
// * idObject == OBJID_WINDOW
// * idChild == CHILDID_SELF
// *
// * Example #4:
// *
// * For EVENT_OBJECT_REORDER, the object referred to by hwnd/idObject is the
// * PARENT container in which the zorder is occurring. This is because if
// * one child is zordering, all of them are changing their relative zorder.
// */
// #define EVENT_OBJECT_CREATE 0x8000 // hwnd + ID + idChild is created item
// #define EVENT_OBJECT_DESTROY 0x8001 // hwnd + ID + idChild is destroyed item
// #define EVENT_OBJECT_SHOW 0x8002 // hwnd + ID + idChild is shown item
// #define EVENT_OBJECT_HIDE 0x8003 // hwnd + ID + idChild is hidden item
// #define EVENT_OBJECT_REORDER 0x8004 // hwnd + ID + idChild is parent of zordering children
// /*
// * NOTE:
// * Minimize the number of notifications!
// *
// * When you are hiding a parent object, obviously all child objects are no
// * longer visible on screen. They still have the same "visible" status,
// * but are not truly visible. Hence do not send HIDE notifications for the
// * children also. One implies all. The same goes for SHOW.
// */
// #define EVENT_OBJECT_FOCUS 0x8005 // hwnd + ID + idChild is focused item
// #define EVENT_OBJECT_SELECTION 0x8006 // hwnd + ID + idChild is selected item (if only one), or idChild is OBJID_WINDOW if complex
// #define EVENT_OBJECT_SELECTIONADD 0x8007 // hwnd + ID + idChild is item added
// #define EVENT_OBJECT_SELECTIONREMOVE 0x8008 // hwnd + ID + idChild is item removed
// #define EVENT_OBJECT_SELECTIONWITHIN 0x8009 // hwnd + ID + idChild is parent of changed selected items
// /*
// * NOTES:
// * There is only one "focused" child item in a parent. This is the place
// * keystrokes are going at a given moment. Hence only send a notification
// * about where the NEW focus is going. A NEW item getting the focus already
// * implies that the OLD item is losing it.
// *
// * SELECTION however can be multiple. Hence the different SELECTION
// * notifications. Here's when to use each:
// *
// * (1) Send a SELECTION notification in the simple single selection
// * case (like the focus) when the item with the selection is
// * merely moving to a different item within a container. hwnd + ID
// * is the container control, idChildItem is the new child with the
// * selection.
// *
// * (2) Send a SELECTIONADD notification when a new item has simply been added
// * to the selection within a container. This is appropriate when the
// * number of newly selected items is very small. hwnd + ID is the
// * container control, idChildItem is the new child added to the selection.
// *
// * (3) Send a SELECTIONREMOVE notification when a new item has simply been
// * removed from the selection within a container. This is appropriate
// * when the number of newly selected items is very small, just like
// * SELECTIONADD. hwnd + ID is the container control, idChildItem is the
// * new child removed from the selection.
// *
// * (4) Send a SELECTIONWITHIN notification when the selected items within a
// * control have changed substantially. Rather than propagate a large
// * number of changes to reflect removal for some items, addition of
// * others, just tell somebody who cares that a lot happened. It will
// * be faster an easier for somebody watching to just turn around and
// * query the container control what the new bunch of selected items
// * are.
// */
// #define EVENT_OBJECT_STATECHANGE 0x800A // hwnd + ID + idChild is item w/ state change
// /*
// * Examples of when to send an EVENT_OBJECT_STATECHANGE include
// * * It is being enabled/disabled (USER does for windows)
// * * It is being pressed/released (USER does for buttons)
// * * It is being checked/unchecked (USER does for radio/check buttons)
// */
// #define EVENT_OBJECT_LOCATIONCHANGE 0x800B // hwnd + ID + idChild is moved/sized item
// /*
// * Note:
// * A LOCATIONCHANGE is not sent for every child object when the parent
// * changes shape/moves. Send one notification for the topmost object
// * that is changing. For example, if the user resizes a top level window,
// * USER will generate a LOCATIONCHANGE for it, but not for the menu bar,
// * title bar, scrollbars, etc. that are also changing shape/moving.
// *
// * In other words, it only generates LOCATIONCHANGE notifications for
// * real windows that are moving/sizing. It will not generate a LOCATIONCHANGE
// * for every non-floating child window when the parent moves (the children are
// * logically moving also on screen, but not relative to the parent).
// *
// * Now, if the app itself resizes child windows as a result of being
// * sized, USER will generate LOCATIONCHANGEs for those dudes also because
// * it doesn't know better.
// *
// * Note also that USER will generate LOCATIONCHANGE notifications for two
// * non-window sys objects:
// * (1) System caret
// * (2) Cursor
// */
// #define EVENT_OBJECT_NAMECHANGE 0x800C // hwnd + ID + idChild is item w/ name change
// #define EVENT_OBJECT_DESCRIPTIONCHANGE 0x800D // hwnd + ID + idChild is item w/ desc change
// #define EVENT_OBJECT_VALUECHANGE 0x800E // hwnd + ID + idChild is item w/ value change
// #define EVENT_OBJECT_PARENTCHANGE 0x800F // hwnd + ID + idChild is item w/ new parent
// #define EVENT_OBJECT_HELPCHANGE 0x8010 // hwnd + ID + idChild is item w/ help change
// #define EVENT_OBJECT_DEFACTIONCHANGE 0x8011 // hwnd + ID + idChild is item w/ def action change
// #define EVENT_OBJECT_ACCELERATORCHANGE 0x8012 // hwnd + ID + idChild is item w/ keybd accel change
// #if(_WIN32_WINNT >= 0x0600)
// #define EVENT_OBJECT_INVOKED 0x8013 // hwnd + ID + idChild is item invoked
// #define EVENT_OBJECT_TEXTSELECTIONCHANGED 0x8014 // hwnd + ID + idChild is item w? test selection change
// /*
// * EVENT_OBJECT_CONTENTSCROLLED
// * Sent when ending the scrolling of a window object.
// *
// * Unlike the similar event (EVENT_SYSTEM_SCROLLEND), this event will be
// * associated with the scrolling window itself. There is no difference
// * between horizontal or vertical scrolling.
// *
// * This event should be posted whenever scroll action is completed, including
// * when it is scrolled by scroll bars, mouse wheel, or keyboard navigations.
// *
// * example:
// * hwnd == window that is scrolling
// * idObject == OBJID_CLIENT
// * idChild == CHILDID_SELF
// */
// #define EVENT_OBJECT_CONTENTSCROLLED 0x8015
// #endif /* _WIN32_WINNT >= 0x0600 */
// #if(_WIN32_WINNT >= 0x0601)
// #define EVENT_SYSTEM_ARRANGMENTPREVIEW 0x8016
// #endif /* _WIN32_WINNT >= 0x0601 */
// #if(_WIN32_WINNT >= 0x0602)
// /*
// * EVENT_OBJECT_CLOAKED / UNCLOAKED
// * Sent when a window is cloaked or uncloaked.
// * A cloaked window still exists, but is invisible to
// * the user.
// */
// #define EVENT_OBJECT_CLOAKED 0x8017
// #define EVENT_OBJECT_UNCLOAKED 0x8018
// /*
// * EVENT_OBJECT_LIVEREGIONCHANGED
// * Sent when an object that is part of a live region
// * changes. A live region is an area of an application
// * that changes frequently and/or asynchronously, so
// * that an assistive technology tool might want to pay
// * special attention to it.
// */
// #define EVENT_OBJECT_LIVEREGIONCHANGED 0x8019
// /*
// * EVENT_OBJECT_HOSTEDOBJECTSINVALIDATED
// * Sent when a window that is hosting other Accessible
// * objects changes the hosted objects. A client may
// * wish to requery to see what the new hosted objects are,
// * especially if it has been monitoring events from this
// * window. A hosted object is one with a different Accessibility
// * framework (MSAA or UI Automation) from its host.
// *
// * Changes in hosted objects with the *same* framework
// * as the parent should be handed with the usual structural
// * change events, such as EVENT_OBJECT_CREATED for MSAA.
// * see above.
// */
// #define EVENT_OBJECT_HOSTEDOBJECTSINVALIDATED 0x8020
// /*
// * Drag / Drop Events
// * These events are used in conjunction with the
// * UI Automation Drag/Drop patterns.
// *
// * For DRAGSTART, DRAGCANCEL, and DRAGCOMPLETE,
// * HWND+objectID+childID refers to the object being dragged.
// *
// * For DRAGENTER, DRAGLEAVE, and DRAGDROPPED,
// * HWND+objectID+childID refers to the target of the drop
// * that is being hovered over.
// */
// #define EVENT_OBJECT_DRAGSTART 0x8021
// #define EVENT_OBJECT_DRAGCANCEL 0x8022
// #define EVENT_OBJECT_DRAGCOMPLETE 0x8023
// #define EVENT_OBJECT_DRAGENTER 0x8024
// #define EVENT_OBJECT_DRAGLEAVE 0x8025
// #define EVENT_OBJECT_DRAGDROPPED 0x8026
// /*
// * EVENT_OBJECT_IME_SHOW/HIDE
// * Sent by an IME window when it has become visible or invisible.
// */
// #define EVENT_OBJECT_IME_SHOW 0x8027
// #define EVENT_OBJECT_IME_HIDE 0x8028
// /*
// * EVENT_OBJECT_IME_CHANGE
// * Sent by an IME window whenever it changes size or position.
// */
// #define EVENT_OBJECT_IME_CHANGE 0x8029
// #define EVENT_OBJECT_TEXTEDIT_CONVERSIONTARGETCHANGED 0x8030
// #endif /* _WIN32_WINNT >= 0x0602 */
// #if(_WIN32_WINNT >= 0x0601)
// #define EVENT_OBJECT_END 0x80FF
// #define EVENT_AIA_START 0xA000
// #define EVENT_AIA_END 0xAFFF
// #endif /* _WIN32_WINNT >= 0x0601 */
// /*
// * Child IDs
// */
// /*
// * System Sounds (idChild of system SOUND notification)
// */
// #define SOUND_SYSTEM_STARTUP 1
// #define SOUND_SYSTEM_SHUTDOWN 2
// #define SOUND_SYSTEM_BEEP 3
// #define SOUND_SYSTEM_ERROR 4
// #define SOUND_SYSTEM_QUESTION 5
// #define SOUND_SYSTEM_WARNING 6
// #define SOUND_SYSTEM_INFORMATION 7
// #define SOUND_SYSTEM_MAXIMIZE 8
// #define SOUND_SYSTEM_MINIMIZE 9
// #define SOUND_SYSTEM_RESTOREUP 10
// #define SOUND_SYSTEM_RESTOREDOWN 11
// #define SOUND_SYSTEM_APPSTART 12
// #define SOUND_SYSTEM_FAULT 13
// #define SOUND_SYSTEM_APPEND 14
// #define SOUND_SYSTEM_MENUCOMMAND 15
// #define SOUND_SYSTEM_MENUPOPUP 16
// #define CSOUND_SYSTEM 16
// /*
// * System Alerts (indexChild of system ALERT notification)
// */
// #define ALERT_SYSTEM_INFORMATIONAL 1 // MB_INFORMATION
// #define ALERT_SYSTEM_WARNING 2 // MB_WARNING
// #define ALERT_SYSTEM_ERROR 3 // MB_ERROR
// #define ALERT_SYSTEM_QUERY 4 // MB_QUESTION
// #define ALERT_SYSTEM_CRITICAL 5 // HardSysErrBox
// #define CALERT_SYSTEM 6
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagGUITHREADINFO
// {
// DWORD cbSize;
// DWORD flags;
// HWND hwndActive;
// HWND hwndFocus;
// HWND hwndCapture;
// HWND hwndMenuOwner;
// HWND hwndMoveSize;
// HWND hwndCaret;
// RECT rcCaret;
// } GUITHREADINFO, *PGUITHREADINFO, FAR * LPGUITHREADINFO;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define GUI_CARETBLINKING 0x00000001
// #define GUI_INMOVESIZE 0x00000002
// #define GUI_INMENUMODE 0x00000004
// #define GUI_SYSTEMMENUMODE 0x00000008
// #define GUI_POPUPMENUMODE 0x00000010
// #if(_WIN32_WINNT >= 0x0501)
// #if defined(_WIN64)
// #define GUI_16BITTASK 0x00000000
// #else
// #define GUI_16BITTASK 0x00000020
// #endif
// #endif /* _WIN32_WINNT >= 0x0501 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// GetGUIThreadInfo(
// _In_ DWORD idThread,
// _Inout_ PGUITHREADINFO pgui);
// WINUSERAPI
// BOOL
// WINAPI
// BlockInput(
// BOOL fBlockIt);
// #if(_WIN32_WINNT >= 0x0600)
// #define USER_DEFAULT_SCREEN_DPI 96
// WINUSERAPI
// BOOL
// WINAPI
// SetProcessDPIAware(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// IsProcessDPIAware(
// VOID);
// #endif /* _WIN32_WINNT >= 0x0600 */
// #if(WINVER >= 0x0605)
// WINUSERAPI
// DPI_AWARENESS_CONTEXT
// WINAPI
// SetThreadDpiAwarenessContext(
// _In_ DPI_AWARENESS_CONTEXT dpiContext);
// WINUSERAPI
// DPI_AWARENESS_CONTEXT
// WINAPI
// GetThreadDpiAwarenessContext(
// VOID);
// WINUSERAPI
// DPI_AWARENESS_CONTEXT
// WINAPI
// GetWindowDpiAwarenessContext(
// _In_ HWND hwnd);
// WINUSERAPI
// DPI_AWARENESS
// WINAPI
// GetAwarenessFromDpiAwarenessContext(
// _In_ DPI_AWARENESS_CONTEXT value);
// WINUSERAPI
// BOOL
// WINAPI
// AreDpiAwarenessContextsEqual(
// _In_ DPI_AWARENESS_CONTEXT dpiContextA,
// _In_ DPI_AWARENESS_CONTEXT dpiContextB);
// WINUSERAPI
// BOOL
// WINAPI
// IsValidDpiAwarenessContext(
// _In_ DPI_AWARENESS_CONTEXT value);
// WINUSERAPI
// UINT
// WINAPI
// GetDpiForWindow(
// _In_ HWND hwnd);
// WINUSERAPI
// UINT
// WINAPI
// GetDpiForSystem(
// VOID);
// WINUSERAPI
// BOOL
// WINAPI
// EnableNonClientDpiScaling(
// _In_ HWND hwnd);
// WINUSERAPI
// BOOL
// WINAPI
// InheritWindowMonitor(
// _In_ HWND hwnd,
// _In_opt_ HWND hwndInherit);
// #endif /* WINVER >= 0x0605 */
// #if(WINVER >= 0x0605)
// WINUSERAPI
// BOOL
// WINAPI
// SetProcessDpiAwarenessContext(
// _In_ DPI_AWARENESS_CONTEXT value);
// #endif /* WINVER >= 0x0605 */
// WINUSERAPI
// UINT
// WINAPI
// GetWindowModuleFileNameA(
// _In_ HWND hwnd,
// _Out_writes_to_(cchFileNameMax, return) LPSTR pszFileName,
// _In_ UINT cchFileNameMax);
// WINUSERAPI
// UINT
// WINAPI
// GetWindowModuleFileNameW(
// _In_ HWND hwnd,
// _Out_writes_to_(cchFileNameMax, return) LPWSTR pszFileName,
// _In_ UINT cchFileNameMax);
// #ifdef UNICODE
// #define GetWindowModuleFileName GetWindowModuleFileNameW
// #else
// #define GetWindowModuleFileName GetWindowModuleFileNameA
// #endif // !UNICODE
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifndef NO_STATE_FLAGS
// #define STATE_SYSTEM_UNAVAILABLE 0x00000001 // Disabled
// #define STATE_SYSTEM_SELECTED 0x00000002
// #define STATE_SYSTEM_FOCUSED 0x00000004
// #define STATE_SYSTEM_PRESSED 0x00000008
// #define STATE_SYSTEM_CHECKED 0x00000010
// #define STATE_SYSTEM_MIXED 0x00000020 // 3-state checkbox or toolbar button
// #define STATE_SYSTEM_INDETERMINATE STATE_SYSTEM_MIXED
// #define STATE_SYSTEM_READONLY 0x00000040
// #define STATE_SYSTEM_HOTTRACKED 0x00000080
// #define STATE_SYSTEM_DEFAULT 0x00000100
// #define STATE_SYSTEM_EXPANDED 0x00000200
// #define STATE_SYSTEM_COLLAPSED 0x00000400
// #define STATE_SYSTEM_BUSY 0x00000800
// #define STATE_SYSTEM_FLOATING 0x00001000 // Children "owned" not "contained" by parent
// #define STATE_SYSTEM_MARQUEED 0x00002000
// #define STATE_SYSTEM_ANIMATED 0x00004000
// #define STATE_SYSTEM_INVISIBLE 0x00008000
// #define STATE_SYSTEM_OFFSCREEN 0x00010000
// #define STATE_SYSTEM_SIZEABLE 0x00020000
// #define STATE_SYSTEM_MOVEABLE 0x00040000
// #define STATE_SYSTEM_SELFVOICING 0x00080000
// #define STATE_SYSTEM_FOCUSABLE 0x00100000
// #define STATE_SYSTEM_SELECTABLE 0x00200000
// #define STATE_SYSTEM_LINKED 0x00400000
// #define STATE_SYSTEM_TRAVERSED 0x00800000
// #define STATE_SYSTEM_MULTISELECTABLE 0x01000000 // Supports multiple selection
// #define STATE_SYSTEM_EXTSELECTABLE 0x02000000 // Supports extended selection
// #define STATE_SYSTEM_ALERT_LOW 0x04000000 // This information is of low priority
// #define STATE_SYSTEM_ALERT_MEDIUM 0x08000000 // This information is of medium priority
// #define STATE_SYSTEM_ALERT_HIGH 0x10000000 // This information is of high priority
// #define STATE_SYSTEM_PROTECTED 0x20000000 // access to this is restricted
// #define STATE_SYSTEM_VALID 0x3FFFFFFF
// #endif
// #define CCHILDREN_TITLEBAR 5
// #define CCHILDREN_SCROLLBAR 5
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Information about the global cursor.
// */
// typedef struct tagCURSORINFO
// {
// DWORD cbSize;
// DWORD flags;
// HCURSOR hCursor;
// POINT ptScreenPos;
// } CURSORINFO, *PCURSORINFO, *LPCURSORINFO;
// #define CURSOR_SHOWING 0x00000001
// #if(WINVER >= 0x0602)
// #define CURSOR_SUPPRESSED 0x00000002
// #endif /* WINVER >= 0x0602 */
// WINUSERAPI
// BOOL
// WINAPI
// GetCursorInfo(
// _Inout_ PCURSORINFO pci);
// /*
// * Window information snapshot
// */
// typedef struct tagWINDOWINFO
// {
// DWORD cbSize;
// RECT rcWindow;
// RECT rcClient;
// DWORD dwStyle;
// DWORD dwExStyle;
// DWORD dwWindowStatus;
// UINT cxWindowBorders;
// UINT cyWindowBorders;
// ATOM atomWindowType;
// WORD wCreatorVersion;
// } WINDOWINFO, *PWINDOWINFO, *LPWINDOWINFO;
// #define WS_ACTIVECAPTION 0x0001
// WINUSERAPI
// BOOL
// WINAPI
// GetWindowInfo(
// _In_ HWND hwnd,
// _Inout_ PWINDOWINFO pwi);
// /*
// * Titlebar information.
// */
// typedef struct tagTITLEBARINFO
// {
// DWORD cbSize;
// RECT rcTitleBar;
// DWORD rgstate[CCHILDREN_TITLEBAR + 1];
// } TITLEBARINFO, *PTITLEBARINFO, *LPTITLEBARINFO;
// WINUSERAPI
// BOOL
// WINAPI
// GetTitleBarInfo(
// _In_ HWND hwnd,
// _Inout_ PTITLEBARINFO pti);
// #if(WINVER >= 0x0600)
// typedef struct tagTITLEBARINFOEX
// {
// DWORD cbSize;
// RECT rcTitleBar;
// DWORD rgstate[CCHILDREN_TITLEBAR + 1];
// RECT rgrect[CCHILDREN_TITLEBAR + 1];
// } TITLEBARINFOEX, *PTITLEBARINFOEX, *LPTITLEBARINFOEX;
// #endif /* WINVER >= 0x0600 */
// /*
// * Menubar information
// */
// typedef struct tagMENUBARINFO
// {
// DWORD cbSize;
// RECT rcBar; // rect of bar, popup, item
// HMENU hMenu; // real menu handle of bar, popup
// HWND hwndMenu; // hwnd of item submenu if one
// BOOL fBarFocused : 1; // bar, popup has the focus
// BOOL fFocused : 1; // item has the focus
// } MENUBARINFO, *PMENUBARINFO, *LPMENUBARINFO;
// WINUSERAPI
// BOOL
// WINAPI
// GetMenuBarInfo(
// _In_ HWND hwnd,
// _In_ LONG idObject,
// _In_ LONG idItem,
// _Inout_ PMENUBARINFO pmbi);
// /*
// * Scrollbar information
// */
// typedef struct tagSCROLLBARINFO
// {
// DWORD cbSize;
// RECT rcScrollBar;
// int dxyLineButton;
// int xyThumbTop;
// int xyThumbBottom;
// int reserved;
// DWORD rgstate[CCHILDREN_SCROLLBAR + 1];
// } SCROLLBARINFO, *PSCROLLBARINFO, *LPSCROLLBARINFO;
// WINUSERAPI
// BOOL
// WINAPI
// GetScrollBarInfo(
// _In_ HWND hwnd,
// _In_ LONG idObject,
// _Inout_ PSCROLLBARINFO psbi);
// /*
// * Combobox information
// */
// typedef struct tagCOMBOBOXINFO
// {
// DWORD cbSize;
// RECT rcItem;
// RECT rcButton;
// DWORD stateButton;
// HWND hwndCombo;
// HWND hwndItem;
// HWND hwndList;
// } COMBOBOXINFO, *PCOMBOBOXINFO, *LPCOMBOBOXINFO;
// WINUSERAPI
// BOOL
// WINAPI
// GetComboBoxInfo(
// _In_ HWND hwndCombo,
// _Inout_ PCOMBOBOXINFO pcbi);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * The "real" ancestor window
// */
// #define GA_PARENT 1
// #define GA_ROOT 2
// #define GA_ROOTOWNER 3
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// HWND
// WINAPI
// GetAncestor(
// _In_ HWND hwnd,
// _In_ UINT gaFlags);
// /*
// * This gets the REAL child window at the point. If it is in the dead
// * space of a group box, it will try a sibling behind it. But static
// * fields will get returned. In other words, it is kind of a cross between
// * ChildWindowFromPointEx and WindowFromPoint.
// */
// WINUSERAPI
// HWND
// WINAPI
// RealChildWindowFromPoint(
// _In_ HWND hwndParent,
// _In_ POINT ptParentClientCoords);
// /*
// * This gets the name of the window TYPE, not class. This allows us to
// * recognize ThunderButton32 et al.
// */
// WINUSERAPI
// UINT
// WINAPI
// RealGetWindowClassA(
// _In_ HWND hwnd,
// _Out_writes_to_(cchClassNameMax, return) LPSTR ptszClassName,
// _In_ UINT cchClassNameMax);
// /*
// * This gets the name of the window TYPE, not class. This allows us to
// * recognize ThunderButton32 et al.
// */
// WINUSERAPI
// UINT
// WINAPI
// RealGetWindowClassW(
// _In_ HWND hwnd,
// _Out_writes_to_(cchClassNameMax, return) LPWSTR ptszClassName,
// _In_ UINT cchClassNameMax);
// #ifdef UNICODE
// #define RealGetWindowClass RealGetWindowClassW
// #else
// #define RealGetWindowClass RealGetWindowClassA
// #endif // !UNICODE
// /*
// * Alt-Tab Switch window information.
// */
// typedef struct tagALTTABINFO
// {
// DWORD cbSize;
// int cItems;
// int cColumns;
// int cRows;
// int iColFocus;
// int iRowFocus;
// int cxItem;
// int cyItem;
// POINT ptStart;
// } ALTTABINFO, *PALTTABINFO, *LPALTTABINFO;
// WINUSERAPI
// BOOL
// WINAPI
// GetAltTabInfoA(
// _In_opt_ HWND hwnd,
// _In_ int iItem,
// _Inout_ PALTTABINFO pati,
// _Out_writes_opt_(cchItemText) LPSTR pszItemText,
// _In_ UINT cchItemText);
// WINUSERAPI
// BOOL
// WINAPI
// GetAltTabInfoW(
// _In_opt_ HWND hwnd,
// _In_ int iItem,
// _Inout_ PALTTABINFO pati,
// _Out_writes_opt_(cchItemText) LPWSTR pszItemText,
// _In_ UINT cchItemText);
// #ifdef UNICODE
// #define GetAltTabInfo GetAltTabInfoW
// #else
// #define GetAltTabInfo GetAltTabInfoA
// #endif // !UNICODE
// /*
// * Listbox information.
// * Returns the number of items per row.
// */
// WINUSERAPI
// DWORD
// WINAPI
// GetListBoxInfo(
// _In_ HWND hwnd);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* NOWINABLE */
// #endif /* WINVER >= 0x0500 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #if(_WIN32_WINNT >= 0x0500)
// WINUSERAPI
// BOOL
// WINAPI
// LockWorkStation(
// VOID);
// #endif /* _WIN32_WINNT >= 0x0500 */
// #if(_WIN32_WINNT >= 0x0500)
// WINUSERAPI
// BOOL
// WINAPI
// UserHandleGrantAccess(
// _In_ HANDLE hUserHandle,
// _In_ HANDLE hJob,
// _In_ BOOL bGrant);
// #endif /* _WIN32_WINNT >= 0x0500 */
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(_WIN32_WINNT >= 0x0501)
// /*
// * Raw Input Messages.
// */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// DECLARE_HANDLE(HRAWINPUT);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * WM_INPUT wParam
// */
// /*
// * Use this macro to get the input code from wParam.
// */
// #define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff)
// /*
// * The input is in the regular message flow,
// * the app is required to call DefWindowProc
// * so that the system can perform clean ups.
// */
// #define RIM_INPUT 0
// /*
// * The input is sink only. The app is expected
// * to behave nicely.
// */
// #define RIM_INPUTSINK 1
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Raw Input data header
// */
// typedef struct tagRAWINPUTHEADER {
// DWORD dwType;
// DWORD dwSize;
// HANDLE hDevice;
// WPARAM wParam;
// } RAWINPUTHEADER, *PRAWINPUTHEADER, *LPRAWINPUTHEADER;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Type of the raw input
// */
// #define RIM_TYPEMOUSE 0
// #define RIM_TYPEKEYBOARD 1
// #define RIM_TYPEHID 2
// #define RIM_TYPEMAX 2
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// //Disable warning C4201:nameless struct/union
// #if _MSC_VER >= 1200
// #pragma warning(push)
// #endif
// #pragma warning(disable : 4201)
// /*
// * Raw format of the mouse input
// */
// typedef struct tagRAWMOUSE {
// /*
// * Indicator flags.
// */
// USHORT usFlags;
// /*
// * The transition state of the mouse buttons.
// */
// union {
// ULONG ulButtons;
// struct {
// USHORT usButtonFlags;
// USHORT usButtonData;
// } DUMMYSTRUCTNAME;
// } DUMMYUNIONNAME;
// /*
// * The raw state of the mouse buttons.
// */
// ULONG ulRawButtons;
// /*
// * The signed relative or absolute motion in the X direction.
// */
// LONG lLastX;
// /*
// * The signed relative or absolute motion in the Y direction.
// */
// LONG lLastY;
// /*
// * Device-specific additional information for the event.
// */
// ULONG ulExtraInformation;
// } RAWMOUSE, *PRAWMOUSE, *LPRAWMOUSE;
// #if _MSC_VER >= 1200
// #pragma warning(pop)
// #endif
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Define the mouse button state indicators.
// */
// #define RI_MOUSE_LEFT_BUTTON_DOWN 0x0001 // Left Button changed to down.
// #define RI_MOUSE_LEFT_BUTTON_UP 0x0002 // Left Button changed to up.
// #define RI_MOUSE_RIGHT_BUTTON_DOWN 0x0004 // Right Button changed to down.
// #define RI_MOUSE_RIGHT_BUTTON_UP 0x0008 // Right Button changed to up.
// #define RI_MOUSE_MIDDLE_BUTTON_DOWN 0x0010 // Middle Button changed to down.
// #define RI_MOUSE_MIDDLE_BUTTON_UP 0x0020 // Middle Button changed to up.
// #define RI_MOUSE_BUTTON_1_DOWN RI_MOUSE_LEFT_BUTTON_DOWN
// #define RI_MOUSE_BUTTON_1_UP RI_MOUSE_LEFT_BUTTON_UP
// #define RI_MOUSE_BUTTON_2_DOWN RI_MOUSE_RIGHT_BUTTON_DOWN
// #define RI_MOUSE_BUTTON_2_UP RI_MOUSE_RIGHT_BUTTON_UP
// #define RI_MOUSE_BUTTON_3_DOWN RI_MOUSE_MIDDLE_BUTTON_DOWN
// #define RI_MOUSE_BUTTON_3_UP RI_MOUSE_MIDDLE_BUTTON_UP
// #define RI_MOUSE_BUTTON_4_DOWN 0x0040
// #define RI_MOUSE_BUTTON_4_UP 0x0080
// #define RI_MOUSE_BUTTON_5_DOWN 0x0100
// #define RI_MOUSE_BUTTON_5_UP 0x0200
// /*
// * If usButtonFlags has RI_MOUSE_WHEEL, the wheel delta is stored in usButtonData.
// * Take it as a signed value.
// */
// #define RI_MOUSE_WHEEL 0x0400
// #if(WINVER >= 0x0600)
// #define RI_MOUSE_HWHEEL 0x0800
// #endif /* WINVER >= 0x0600 */
// /*
// * Define the mouse indicator flags.
// */
// #define MOUSE_MOVE_RELATIVE 0
// #define MOUSE_MOVE_ABSOLUTE 1
// #define MOUSE_VIRTUAL_DESKTOP 0x02 // the coordinates are mapped to the virtual desktop
// #define MOUSE_ATTRIBUTES_CHANGED 0x04 // requery for mouse attributes
// #if(WINVER >= 0x0600)
// #define MOUSE_MOVE_NOCOALESCE 0x08 // do not coalesce mouse moves
// #endif /* WINVER >= 0x0600 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Raw format of the keyboard input
// */
// typedef struct tagRAWKEYBOARD {
// /*
// * The "make" scan code (key depression).
// */
// USHORT MakeCode;
// /*
// * The flags field indicates a "break" (key release) and other
// * miscellaneous scan code information defined in ntddkbd.h.
// */
// USHORT Flags;
// USHORT Reserved;
// /*
// * Windows message compatible information
// */
// USHORT VKey;
// UINT Message;
// /*
// * Device-specific additional information for the event.
// */
// ULONG ExtraInformation;
// } RAWKEYBOARD, *PRAWKEYBOARD, *LPRAWKEYBOARD;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Define the keyboard overrun MakeCode.
// */
// #define KEYBOARD_OVERRUN_MAKE_CODE 0xFF
// /*
// * Define the keyboard input data Flags.
// */
// #define RI_KEY_MAKE 0
// #define RI_KEY_BREAK 1
// #define RI_KEY_E0 2
// #define RI_KEY_E1 4
// #define RI_KEY_TERMSRV_SET_LED 8
// #define RI_KEY_TERMSRV_SHADOW 0x10
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Raw format of the input from Human Input Devices
// */
// typedef struct tagRAWHID {
// DWORD dwSizeHid; // byte size of each report
// DWORD dwCount; // number of input packed
// BYTE bRawData[1];
// } RAWHID, *PRAWHID, *LPRAWHID;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * RAWINPUT data structure.
// */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagRAWINPUT {
// RAWINPUTHEADER header;
// union {
// RAWMOUSE mouse;
// RAWKEYBOARD keyboard;
// RAWHID hid;
// } data;
// } RAWINPUT, *PRAWINPUT, *LPRAWINPUT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #ifdef _WIN64
// #define RAWINPUT_ALIGN(x) (((x) + sizeof(QWORD) - 1) & ~(sizeof(QWORD) - 1))
// #else // _WIN64
// #define RAWINPUT_ALIGN(x) (((x) + sizeof(DWORD) - 1) & ~(sizeof(DWORD) - 1))
// #endif // _WIN64
// #define NEXTRAWINPUTBLOCK(ptr) ((PRAWINPUT)RAWINPUT_ALIGN((ULONG_PTR)((PBYTE)(ptr) + (ptr)->header.dwSize)))
// /*
// * Flags for GetRawInputData
// */
// #define RID_INPUT 0x10000003
// #define RID_HEADER 0x10000005
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// UINT
// WINAPI
// GetRawInputData(
// _In_ HRAWINPUT hRawInput,
// _In_ UINT uiCommand,
// _Out_writes_bytes_to_opt_(*pcbSize, return) LPVOID pData,
// _Inout_ PUINT pcbSize,
// _In_ UINT cbSizeHeader);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Raw Input Device Information
// */
// #define RIDI_PREPARSEDDATA 0x20000005
// #define RIDI_DEVICENAME 0x20000007 // the return valus is the character length, not the byte size
// #define RIDI_DEVICEINFO 0x2000000b
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagRID_DEVICE_INFO_MOUSE {
// DWORD dwId;
// DWORD dwNumberOfButtons;
// DWORD dwSampleRate;
// BOOL fHasHorizontalWheel;
// } RID_DEVICE_INFO_MOUSE, *PRID_DEVICE_INFO_MOUSE;
// typedef struct tagRID_DEVICE_INFO_KEYBOARD {
// DWORD dwType;
// DWORD dwSubType;
// DWORD dwKeyboardMode;
// DWORD dwNumberOfFunctionKeys;
// DWORD dwNumberOfIndicators;
// DWORD dwNumberOfKeysTotal;
// } RID_DEVICE_INFO_KEYBOARD, *PRID_DEVICE_INFO_KEYBOARD;
// typedef struct tagRID_DEVICE_INFO_HID {
// DWORD dwVendorId;
// DWORD dwProductId;
// DWORD dwVersionNumber;
// /*
// * Top level collection UsagePage and Usage
// */
// USHORT usUsagePage;
// USHORT usUsage;
// } RID_DEVICE_INFO_HID, *PRID_DEVICE_INFO_HID;
// typedef struct tagRID_DEVICE_INFO {
// DWORD cbSize;
// DWORD dwType;
// union {
// RID_DEVICE_INFO_MOUSE mouse;
// RID_DEVICE_INFO_KEYBOARD keyboard;
// RID_DEVICE_INFO_HID hid;
// } DUMMYUNIONNAME;
// } RID_DEVICE_INFO, *PRID_DEVICE_INFO, *LPRID_DEVICE_INFO;
// WINUSERAPI
// UINT
// WINAPI
// GetRawInputDeviceInfoA(
// _In_opt_ HANDLE hDevice,
// _In_ UINT uiCommand,
// _Inout_updates_bytes_to_opt_(*pcbSize, *pcbSize) LPVOID pData,
// _Inout_ PUINT pcbSize);
// WINUSERAPI
// UINT
// WINAPI
// GetRawInputDeviceInfoW(
// _In_opt_ HANDLE hDevice,
// _In_ UINT uiCommand,
// _Inout_updates_bytes_to_opt_(*pcbSize, *pcbSize) LPVOID pData,
// _Inout_ PUINT pcbSize);
// #ifdef UNICODE
// #define GetRawInputDeviceInfo GetRawInputDeviceInfoW
// #else
// #define GetRawInputDeviceInfo GetRawInputDeviceInfoA
// #endif // !UNICODE
// /*
// * Raw Input Bulk Read: GetRawInputBuffer
// */
// WINUSERAPI
// UINT
// WINAPI
// GetRawInputBuffer(
// _Out_writes_bytes_opt_(*pcbSize) PRAWINPUT pData,
// _Inout_ PUINT pcbSize,
// _In_ UINT cbSizeHeader);
// /*
// * Raw Input request APIs
// */
// typedef struct tagRAWINPUTDEVICE {
// USHORT usUsagePage; // Toplevel collection UsagePage
// USHORT usUsage; // Toplevel collection Usage
// DWORD dwFlags;
// HWND hwndTarget; // Target hwnd. NULL = follows keyboard focus
// } RAWINPUTDEVICE, *PRAWINPUTDEVICE, *LPRAWINPUTDEVICE;
// typedef CONST RAWINPUTDEVICE* PCRAWINPUTDEVICE;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #define RIDEV_REMOVE 0x00000001
// #define RIDEV_EXCLUDE 0x00000010
// #define RIDEV_PAGEONLY 0x00000020
// #define RIDEV_NOLEGACY 0x00000030
// #define RIDEV_INPUTSINK 0x00000100
// #define RIDEV_CAPTUREMOUSE 0x00000200 // effective when mouse nolegacy is specified, otherwise it would be an error
// #define RIDEV_NOHOTKEYS 0x00000200 // effective for keyboard.
// #define RIDEV_APPKEYS 0x00000400 // effective for keyboard.
// #if(_WIN32_WINNT >= 0x0501)
// #define RIDEV_EXINPUTSINK 0x00001000
// #define RIDEV_DEVNOTIFY 0x00002000
// #endif /* _WIN32_WINNT >= 0x0501 */
// #define RIDEV_EXMODEMASK 0x000000F0
// #define RIDEV_EXMODE(mode) ((mode) & RIDEV_EXMODEMASK)
// #if(_WIN32_WINNT >= 0x0501)
// /*
// * Flags for the WM_INPUT_DEVICE_CHANGE message.
// */
// #define GIDC_ARRIVAL 1
// #define GIDC_REMOVAL 2
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if (_WIN32_WINNT >= 0x0601)
// #define GET_DEVICE_CHANGE_WPARAM(wParam) (LOWORD(wParam))
// #elif (_WIN32_WINNT >= 0x0501)
// #define GET_DEVICE_CHANGE_LPARAM(lParam) (LOWORD(lParam))
// #endif /* (_WIN32_WINNT >= 0x0601) */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// RegisterRawInputDevices(
// _In_reads_(uiNumDevices) PCRAWINPUTDEVICE pRawInputDevices,
// _In_ UINT uiNumDevices,
// _In_ UINT cbSize);
// WINUSERAPI
// UINT
// WINAPI
// GetRegisteredRawInputDevices(
// _Out_writes_opt_(*puiNumDevices) PRAWINPUTDEVICE pRawInputDevices,
// _Inout_ PUINT puiNumDevices,
// _In_ UINT cbSize);
// typedef struct tagRAWINPUTDEVICELIST {
// HANDLE hDevice;
// DWORD dwType;
// } RAWINPUTDEVICELIST, *PRAWINPUTDEVICELIST;
// WINUSERAPI
// UINT
// WINAPI
// GetRawInputDeviceList(
// _Out_writes_opt_(*puiNumDevices) PRAWINPUTDEVICELIST pRawInputDeviceList,
// _Inout_ PUINT puiNumDevices,
// _In_ UINT cbSize);
// WINUSERAPI
// LRESULT
// WINAPI
// DefRawInputProc(
// _In_reads_(nInput) PRAWINPUT* paRawInput,
// _In_ INT nInput,
// _In_ UINT cbSizeHeader);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* _WIN32_WINNT >= 0x0501 */
// #if(WINVER >= 0x0602)
// #define POINTER_DEVICE_PRODUCT_STRING_MAX 520
// /*
// * wParam values for WM_POINTERDEVICECHANGE
// */
// #define PDC_ARRIVAL 0x001
// #define PDC_REMOVAL 0x002
// #define PDC_ORIENTATION_0 0x004
// #define PDC_ORIENTATION_90 0x008
// #define PDC_ORIENTATION_180 0x010
// #define PDC_ORIENTATION_270 0x020
// #define PDC_MODE_DEFAULT 0x040
// #define PDC_MODE_CENTERED 0x080
// #define PDC_MAPPING_CHANGE 0x100
// #define PDC_RESOLUTION 0x200
// #define PDC_ORIGIN 0x400
// #define PDC_MODE_ASPECTRATIOPRESERVED 0x800
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef enum tagPOINTER_DEVICE_TYPE {
// POINTER_DEVICE_TYPE_INTEGRATED_PEN = 0x00000001,
// POINTER_DEVICE_TYPE_EXTERNAL_PEN = 0x00000002,
// POINTER_DEVICE_TYPE_TOUCH = 0x00000003,
// #if(WINVER >= 0x0603)
// POINTER_DEVICE_TYPE_TOUCH_PAD = 0x00000004,
// #endif /* WINVER >= 0x0603 */
// POINTER_DEVICE_TYPE_MAX = 0xFFFFFFFF
// } POINTER_DEVICE_TYPE;
// typedef struct tagPOINTER_DEVICE_INFO {
// DWORD displayOrientation;
// HANDLE device;
// POINTER_DEVICE_TYPE pointerDeviceType;
// HMONITOR monitor;
// ULONG startingCursorId;
// USHORT maxActiveContacts;
// WCHAR productString[POINTER_DEVICE_PRODUCT_STRING_MAX];
// } POINTER_DEVICE_INFO;
// typedef struct tagPOINTER_DEVICE_PROPERTY {
// INT32 logicalMin;
// INT32 logicalMax;
// INT32 physicalMin;
// INT32 physicalMax;
// UINT32 unit;
// UINT32 unitExponent;
// USHORT usagePageId;
// USHORT usageId;
// } POINTER_DEVICE_PROPERTY;
// typedef enum tagPOINTER_DEVICE_CURSOR_TYPE {
// POINTER_DEVICE_CURSOR_TYPE_UNKNOWN = 0x00000000,
// POINTER_DEVICE_CURSOR_TYPE_TIP = 0x00000001,
// POINTER_DEVICE_CURSOR_TYPE_ERASER = 0x00000002,
// POINTER_DEVICE_CURSOR_TYPE_MAX = 0xFFFFFFFF
// } POINTER_DEVICE_CURSOR_TYPE;
// typedef struct tagPOINTER_DEVICE_CURSOR_INFO {
// UINT32 cursorId;
// POINTER_DEVICE_CURSOR_TYPE cursor;
// } POINTER_DEVICE_CURSOR_INFO;
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerDevices(
// _Inout_ UINT32* deviceCount,
// _Out_writes_opt_(*deviceCount) POINTER_DEVICE_INFO *pointerDevices);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerDevice(
// _In_ HANDLE device,
// _Out_writes_(1) POINTER_DEVICE_INFO *pointerDevice);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerDeviceProperties(
// _In_ HANDLE device,
// _Inout_ UINT32* propertyCount,
// _Out_writes_opt_(*propertyCount) POINTER_DEVICE_PROPERTY *pointerProperties);
// WINUSERAPI
// BOOL
// WINAPI
// RegisterPointerDeviceNotifications(
// _In_ HWND window,
// _In_ BOOL notifyRange);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerDeviceRects(
// _In_ HANDLE device,
// _Out_writes_(1) RECT* pointerDeviceRect,
// _Out_writes_(1) RECT* displayRect);
// WINUSERAPI
// BOOL
// WINAPI
// GetPointerDeviceCursors(
// _In_ HANDLE device,
// _Inout_ UINT32* cursorCount,
// _Out_writes_opt_(*cursorCount) POINTER_DEVICE_CURSOR_INFO *deviceCursors);
// WINUSERAPI
// BOOL
// WINAPI
// GetRawPointerDeviceData(
// _In_ UINT32 pointerId,
// _In_ UINT32 historyCount,
// _In_ UINT32 propertiesCount,
// _In_reads_(propertiesCount) POINTER_DEVICE_PROPERTY* pProperties,
// _Out_writes_(historyCount * propertiesCount) LONG* pValues);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0602 */
// #if(WINVER >= 0x0600)
// /*
// * Message Filter
// */
// #define MSGFLT_ADD 1
// #define MSGFLT_REMOVE 2
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// ChangeWindowMessageFilter(
// _In_ UINT message,
// _In_ DWORD dwFlag);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0600 */
// #if(WINVER >= 0x0601)
// /*
// * Message filter info values (CHANGEFILTERSTRUCT.ExtStatus)
// */
// #define MSGFLTINFO_NONE (0)
// #define MSGFLTINFO_ALREADYALLOWED_FORWND (1)
// #define MSGFLTINFO_ALREADYDISALLOWED_FORWND (2)
// #define MSGFLTINFO_ALLOWED_HIGHER (3)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// typedef struct tagCHANGEFILTERSTRUCT {
// DWORD cbSize;
// DWORD ExtStatus;
// } CHANGEFILTERSTRUCT, *PCHANGEFILTERSTRUCT;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Message filter action values (action parameter to ChangeWindowMessageFilterEx)
// */
// #define MSGFLT_RESET (0)
// #define MSGFLT_ALLOW (1)
// #define MSGFLT_DISALLOW (2)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// ChangeWindowMessageFilterEx(
// _In_ HWND hwnd, // Window
// _In_ UINT message, // WM_ message
// _In_ DWORD action, // Message filter action value
// _Inout_opt_ PCHANGEFILTERSTRUCT pChangeFilterStruct); // Optional
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0601 */
// #if(WINVER >= 0x0601)
// #endif /* WINVER >= 0x0601 */
// #if(WINVER >= 0x0601)
// /*
// * Gesture defines and functions
// */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Gesture information handle
// */
// DECLARE_HANDLE(HGESTUREINFO);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Gesture flags - GESTUREINFO.dwFlags
// */
// #define GF_BEGIN 0x00000001
// #define GF_INERTIA 0x00000002
// #define GF_END 0x00000004
// /*
// * Gesture IDs
// */
// #define GID_BEGIN 1
// #define GID_END 2
// #define GID_ZOOM 3
// #define GID_PAN 4
// #define GID_ROTATE 5
// #define GID_TWOFINGERTAP 6
// #define GID_PRESSANDTAP 7
// #define GID_ROLLOVER GID_PRESSANDTAP
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Gesture information structure
// * - Pass the HGESTUREINFO received in the WM_GESTURE message lParam into the
// * GetGestureInfo function to retrieve this information.
// * - If cbExtraArgs is non-zero, pass the HGESTUREINFO received in the WM_GESTURE
// * message lParam into the GetGestureExtraArgs function to retrieve extended
// * argument information.
// */
// typedef struct tagGESTUREINFO {
// UINT cbSize; // size, in bytes, of this structure (including variable length Args field)
// DWORD dwFlags; // see GF_* flags
// DWORD dwID; // gesture ID, see GID_* defines
// HWND hwndTarget; // handle to window targeted by this gesture
// POINTS ptsLocation; // current location of this gesture
// DWORD dwInstanceID; // internally used
// DWORD dwSequenceID; // internally used
// ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES
// UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture
// } GESTUREINFO, *PGESTUREINFO;
// typedef GESTUREINFO const * PCGESTUREINFO;
// /*
// * Gesture notification structure
// * - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
// * - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
// * in progress and a gesture will be generated if one is recognized under the
// * current gesture settings.
// */
// typedef struct tagGESTURENOTIFYSTRUCT {
// UINT cbSize; // size, in bytes, of this structure
// DWORD dwFlags; // unused
// HWND hwndTarget; // handle to window targeted by the gesture
// POINTS ptsLocation; // starting location
// DWORD dwInstanceID; // internally used
// } GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT;
// /*
// * Gesture argument helpers
// * - Angle should be a double in the range of -2pi to +2pi
// * - Argument should be an unsigned 16-bit value
// */
// #define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0))
// #define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265)
// /*
// * Gesture information retrieval
// * - HGESTUREINFO is received by a window in the lParam of a WM_GESTURE message.
// */
// WINUSERAPI
// BOOL
// WINAPI
// GetGestureInfo(
// _In_ HGESTUREINFO hGestureInfo,
// _Out_ PGESTUREINFO pGestureInfo);
// /*
// * Gesture extra arguments retrieval
// * - HGESTUREINFO is received by a window in the lParam of a WM_GESTURE message.
// * - Size, in bytes, of the extra argument data is available in the cbExtraArgs
// * field of the GESTUREINFO structure retrieved using the GetGestureInfo function.
// */
// WINUSERAPI
// BOOL
// WINAPI
// GetGestureExtraArgs(
// _In_ HGESTUREINFO hGestureInfo,
// _In_ UINT cbExtraArgs,
// _Out_writes_bytes_(cbExtraArgs) PBYTE pExtraArgs);
// /*
// * Gesture information handle management
// * - If an application processes the WM_GESTURE message, then once it is done
// * with the associated HGESTUREINFO, the application is responsible for
// * closing the handle using this function. Failure to do so may result in
// * process memory leaks.
// * - If the message is instead passed to DefWindowProc, or is forwarded using
// * one of the PostMessage or SendMessage class of API functions, the handle
// * is transfered with the message and need not be closed by the application.
// */
// WINUSERAPI
// BOOL
// WINAPI
// CloseGestureInfoHandle(
// _In_ HGESTUREINFO hGestureInfo);
// /*
// * Gesture configuration structure
// * - Used in SetGestureConfig and GetGestureConfig
// * - Note that any setting not included in either GESTURECONFIG.dwWant or
// * GESTURECONFIG.dwBlock will use the parent window's preferences or
// * system defaults.
// */
// typedef struct tagGESTURECONFIG {
// DWORD dwID; // gesture ID
// DWORD dwWant; // settings related to gesture ID that are to be turned on
// DWORD dwBlock; // settings related to gesture ID that are to be turned off
// } GESTURECONFIG, *PGESTURECONFIG;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// /*
// * Gesture configuration flags - GESTURECONFIG.dwWant or GESTURECONFIG.dwBlock
// */
// /*
// * Common gesture configuration flags - set GESTURECONFIG.dwID to zero
// */
// #define GC_ALLGESTURES 0x00000001
// /*
// * Zoom gesture configuration flags - set GESTURECONFIG.dwID to GID_ZOOM
// */
// #define GC_ZOOM 0x00000001
// /*
// * Pan gesture configuration flags - set GESTURECONFIG.dwID to GID_PAN
// */
// #define GC_PAN 0x00000001
// #define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
// #define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
// #define GC_PAN_WITH_GUTTER 0x00000008
// #define GC_PAN_WITH_INERTIA 0x00000010
// /*
// * Rotate gesture configuration flags - set GESTURECONFIG.dwID to GID_ROTATE
// */
// #define GC_ROTATE 0x00000001
// /*
// * Two finger tap gesture configuration flags - set GESTURECONFIG.dwID to GID_TWOFINGERTAP
// */
// #define GC_TWOFINGERTAP 0x00000001
// /*
// * PressAndTap gesture configuration flags - set GESTURECONFIG.dwID to GID_PRESSANDTAP
// */
// #define GC_PRESSANDTAP 0x00000001
// #define GC_ROLLOVER GC_PRESSANDTAP
// #define GESTURECONFIGMAXCOUNT 256 // Maximum number of gestures that can be included
// // in a single call to SetGestureConfig / GetGestureConfig
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// SetGestureConfig(
// _In_ HWND hwnd, // window for which configuration is specified
// _In_ DWORD dwReserved, // reserved, must be 0
// _In_ UINT cIDs, // count of GESTURECONFIG structures
// _In_reads_(cIDs) PGESTURECONFIG pGestureConfig, // array of GESTURECONFIG structures, dwIDs will be processed in the
// // order specified and repeated occurances will overwrite previous ones
// _In_ UINT cbSize); // sizeof(GESTURECONFIG)
// #define GCF_INCLUDE_ANCESTORS 0x00000001 // If specified, GetGestureConfig returns consolidated configuration
// // for the specified window and it's parent window chain
// WINUSERAPI
// BOOL
// WINAPI
// GetGestureConfig(
// _In_ HWND hwnd, // window for which configuration is required
// _In_ DWORD dwReserved, // reserved, must be 0
// _In_ DWORD dwFlags, // see GCF_* flags
// _In_ PUINT pcIDs, // *pcIDs contains the size, in number of GESTURECONFIG structures,
// // of the buffer pointed to by pGestureConfig
// _Inout_updates_(*pcIDs) PGESTURECONFIG pGestureConfig,
// // pointer to buffer to receive the returned array of GESTURECONFIG structures
// _In_ UINT cbSize); // sizeof(GESTURECONFIG)
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0601 */
// #if(WINVER >= 0x0601)
// /*
// * GetSystemMetrics(SM_DIGITIZER) flag values
// */
// #define NID_INTEGRATED_TOUCH 0x00000001
// #define NID_EXTERNAL_TOUCH 0x00000002
// #define NID_INTEGRATED_PEN 0x00000004
// #define NID_EXTERNAL_PEN 0x00000008
// #define NID_MULTI_INPUT 0x00000040
// #define NID_READY 0x00000080
// #endif /* WINVER >= 0x0601 */
// #define MAX_STR_BLOCKREASON 256
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// ShutdownBlockReasonCreate(
// _In_ HWND hWnd,
// _In_ LPCWSTR pwszReason);
// WINUSERAPI
// BOOL
// WINAPI
// ShutdownBlockReasonQuery(
// _In_ HWND hWnd,
// _Out_writes_opt_(*pcchBuff) LPWSTR pwszBuff,
// _Inout_ DWORD *pcchBuff);
// WINUSERAPI
// BOOL
// WINAPI
// ShutdownBlockReasonDestroy(
// _In_ HWND hWnd);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #if(WINVER >= 0x0601)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Identifiers for message input source device type.
// */
// typedef enum tagINPUT_MESSAGE_DEVICE_TYPE {
// IMDT_UNAVAILABLE = 0x00000000, // not specified
// IMDT_KEYBOARD = 0x00000001, // from keyboard
// IMDT_MOUSE = 0x00000002, // from mouse
// IMDT_TOUCH = 0x00000004, // from touch
// IMDT_PEN = 0x00000008, // from pen
// #if(WINVER >= 0x0603)
// IMDT_TOUCHPAD = 0x00000010, // from touchpad
// #endif /* WINVER >= 0x0603 */
// } INPUT_MESSAGE_DEVICE_TYPE;
// typedef enum tagINPUT_MESSAGE_ORIGIN_ID {
// IMO_UNAVAILABLE = 0x00000000, // not specified
// IMO_HARDWARE = 0x00000001, // from a hardware device or injected by a UIAccess app
// IMO_INJECTED = 0x00000002, // injected via SendInput() by a non-UIAccess app
// IMO_SYSTEM = 0x00000004, // injected by the system
// } INPUT_MESSAGE_ORIGIN_ID;
// /*
// * Input source structure.
// */
// typedef struct tagINPUT_MESSAGE_SOURCE {
// INPUT_MESSAGE_DEVICE_TYPE deviceType;
// INPUT_MESSAGE_ORIGIN_ID originId;
// } INPUT_MESSAGE_SOURCE;
// /*
// * API to determine the input source of the current messsage.
// */
// WINUSERAPI
// BOOL
// WINAPI
// GetCurrentInputMessageSource(
// _Out_ INPUT_MESSAGE_SOURCE *inputMessageSource);
// WINUSERAPI
// BOOL
// WINAPI
// GetCIMSSM(
// _Out_ INPUT_MESSAGE_SOURCE *inputMessageSource);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0601 */
// #if(WINVER >= 0x0601)
// #pragma region Application Family or OneCore Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
// /*
// * AutoRotation state structure
// */
// typedef enum tagAR_STATE {
// AR_ENABLED = 0x0,
// AR_DISABLED = 0x1,
// AR_SUPPRESSED = 0x2,
// AR_REMOTESESSION = 0x4,
// AR_MULTIMON = 0x8,
// AR_NOSENSOR = 0x10,
// AR_NOT_SUPPORTED = 0x20,
// AR_DOCKED = 0x40,
// AR_LAPTOP = 0x80
// } AR_STATE, *PAR_STATE;
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
// #pragma endregion
// #ifndef MIDL_PASS
// // Don't define this for MIDL compiler passes over winuser.h. Some of them
// // don't include winnt.h (where DEFINE_ENUM_FLAG_OPERATORS is defined and
// // get compile errors.
// DEFINE_ENUM_FLAG_OPERATORS(AR_STATE)
// #endif
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// /*
// * Orientation preference structure. This is used by applications to specify
// * their orientation preferences to windows.
// */
// typedef enum ORIENTATION_PREFERENCE {
// ORIENTATION_PREFERENCE_NONE = 0x0,
// ORIENTATION_PREFERENCE_LANDSCAPE = 0x1,
// ORIENTATION_PREFERENCE_PORTRAIT = 0x2,
// ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED = 0x4,
// ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED = 0x8
// } ORIENTATION_PREFERENCE;
// #ifndef MIDL_PASS
// // Don't define this for MIDL compiler passes over winuser.h. Some of them
// // don't include winnt.h (where DEFINE_ENUM_FLAG_OPERATORS is defined and
// // get compile errors.
// DEFINE_ENUM_FLAG_OPERATORS(ORIENTATION_PREFERENCE)
// #endif
// WINUSERAPI
// BOOL
// WINAPI
// GetAutoRotationState(
// _Out_ PAR_STATE pState);
// WINUSERAPI
// BOOL
// WINAPI
// GetDisplayAutoRotationPreferences(
// _Out_ ORIENTATION_PREFERENCE *pOrientation);
// WINUSERAPI
// BOOL
// WINAPI
// GetDisplayAutoRotationPreferencesByProcessId(
// _In_ DWORD dwProcessId,
// _Out_ ORIENTATION_PREFERENCE *pOrientation,
// _Out_ BOOL *fRotateScreen);
// WINUSERAPI
// BOOL
// WINAPI
// SetDisplayAutoRotationPreferences(
// _In_ ORIENTATION_PREFERENCE orientation);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0601 */
// #if(WINVER >= 0x0601)
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// WINUSERAPI
// BOOL
// WINAPI
// IsImmersiveProcess(
// _In_ HANDLE hProcess);
// WINUSERAPI
// BOOL
// WINAPI
// SetProcessRestrictionExemption(
// _In_ BOOL fEnableExemption);
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// #pragma endregion
// #endif /* WINVER >= 0x0601 */
// #pragma region Desktop Family
// #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// /*
// * Ink Feedback APIs
// */
// #if _MSC_VER >= 1200
// #pragma warning(pop)
// #endif
// #if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
// #if defined(ISOLATION_AWARE_ENABLED) && (ISOLATION_AWARE_ENABLED != 0)
// #include "winuser.inl"
// #endif /* ISOLATION_AWARE_ENABLED */
// #endif /* RC */
// #ifdef __cplusplus
// }
// #endif /* __cplusplus */
// #endif /* !_WINUSER_ */
| [
"Church.Zhong@audiocodes.com"
] | Church.Zhong@audiocodes.com |
e782750011e23aed7c36be3435dfd610ceac989f | a7d059ecb3f56b8166153b273d8d12997097287b | /Painting_iterative.cpp | b00422c337f016b503c46fd360865ec42044d21a | [] | no_license | stratwine/epi | 6cb1c87099f419d23efe5e42ba7f91bd8ae3bc6c | 448d76467b24d5b0a72681ed5124944def089f17 | refs/heads/master | 2021-01-19T13:50:36.415721 | 2013-08-20T18:23:22 | 2013-08-20T18:23:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,046 | cpp | // Copyright (c) 2013 Elements of Programming Interviews. All rights reserved.
#include <array>
#include <deque>
#include <iostream>
#include <queue>
#include <random>
#include <utility>
#include <vector>
using std::array;
using std::cout;
using std::default_random_engine;
using std::deque;
using std::endl;
using std::queue;
using std::pair;
using std::random_device;
using std::uniform_int_distribution;
using std::vector;
void print_matrix(const vector<deque<bool>> &A) {
for (int i = 0; i < A.size(); ++i) {
for (int j = 0; j < A.size(); ++j) {
cout << A[i][j] << ' ';
}
cout << endl;
}
}
// @include
void flip_color(vector<deque<bool>> *A, int x, int y) {
const array<array<int, 2>, 4> dir = {{{{0, 1}}, {{0, -1}},
{{1, 0}}, {{-1, 0}}}};
const bool color = (*A)[x][y];
queue<pair<int, int>> q;
q.emplace(x, y);
while (q.empty() == false) {
pair<int, int> curr(q.front());
(*A)[curr.first][curr.second] = !(*A)[curr.first][curr.second]; // flip
for (const auto &d : dir) {
pair<int, int> next(curr.first + d[0], curr.second + d[1]);
if (next.first >= 0 && next.first < A->size() &&
next.second >= 0 && next.second < (*A)[next.first].size() &&
(*A)[next.first][next.second] == color) {
q.emplace(next);
}
}
q.pop();
}
}
// @exclude
int main(int argc, char *argv[]) {
int n;
default_random_engine gen((random_device())());
if (argc == 2) {
n = atoi(argv[1]);
} else {
uniform_int_distribution<int> dis(1, 100);
n = dis(gen);
}
vector<deque<bool>> A(n, deque<bool>(n));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
uniform_int_distribution<int> zero_or_one(0, 1);
A[i][j] = zero_or_one(gen);
}
}
uniform_int_distribution<int> dis(0, n - 1);
int i = dis(gen), j = dis(gen);
cout << "color = " << i << ' ' << j << ' ' << A[i][j] << endl;
print_matrix(A);
flip_color(&A, i, j);
cout << endl;
print_matrix(A);
return 0;
}
| [
"tovishwanath@gmail.com"
] | tovishwanath@gmail.com |
3c9b567cabe854b001933a573ace794a9c062da2 | a685ceeffe00535752d379ff5f783d6f8fcb20cd | /Invasion/Private/Animations/AnimNotify_PauseAnimInstance.cpp | 59bc8eb307643919161db4b0dd8fd587eaeda58b | [] | no_license | UnrealXinda/Invasion | 1848e809590a920fd7c83c7fe36bfaea9e231e4d | c9869ad73a5f472d8b7859815165900d36a931ba | refs/heads/master | 2021-08-28T07:17:25.807439 | 2021-08-23T04:13:37 | 2021-08-23T04:13:37 | 223,698,131 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 471 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "AnimNotify_PauseAnimInstance.h"
void UAnimNotify_PauseAnimInstance::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
#ifdef UE_BUILD_DEBUG
if (UWorld* World = MeshComp->GetWorld())
{
switch (World->WorldType)
{
case EWorldType::Game:
case EWorldType::PIE:
#endif
MeshComp->bPauseAnims = true;
#ifdef UE_BUILD_DEBUG
break;
}
}
#endif
}
| [
"unreal.xinda@gmail.com"
] | unreal.xinda@gmail.com |
80273d98a0269fc90f23d3c2eeb914d59fa93961 | a33aac97878b2cb15677be26e308cbc46e2862d2 | /program_data/PKU_raw/56/2961.c | 450b7219e148bc36e8a9386de0e17b72987768c2 | [] | no_license | GabeOchieng/ggnn.tensorflow | f5d7d0bca52258336fc12c9de6ae38223f28f786 | 7c62c0e8427bea6c8bec2cebf157b6f1ea70a213 | refs/heads/master | 2022-05-30T11:17:42.278048 | 2020-05-02T11:33:31 | 2020-05-02T11:33:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 186 | c | int main()
{
int n;
void reverse(int n);
scanf("%d",&n);
reverse(n);
return 0;
}
void reverse(int n)
{
if(n < 1)
return;
printf("%d",n % 10);
reverse(n / 10);
}
| [
"bdqnghi@gmail.com"
] | bdqnghi@gmail.com |
b1ab1e05791f8ff48c0eff81feb7f8c5cfc49f8c | 8912e1a4746c449fbccb707438f3b4fe1c9a1912 | /OldMan/Tool/MyFormView.cpp | c1c44a47deb76ee7d959c0b82b92668eba8a232e | [] | no_license | plmnb14/TeamProject_2.5D_DukeNukem | 065bc57d968bac025a54501f5c97112f55ad6220 | d5049d4d04786501eb6e2fbb77e0b637bc6c4507 | refs/heads/master | 2022-04-06T13:56:53.639539 | 2019-11-13T17:31:41 | 2019-11-13T17:31:41 | 220,400,745 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 17,313 | cpp | // MyFormView.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "Tool.h"
#include "MyFormView.h"
#include "MainFrm.h"
#include "ToolView.h"
#include "ToolTerrain.h"
#include "Trasform.h"
#include "ToolTerrainCube.h"
#include "ToolTerrainWallCube.h"
#include "ToolTerrainRect.h"
#include "PathExtract.h"
// CMyFormView
IMPLEMENT_DYNCREATE(CMyFormView, CFormView)
CMyFormView::CMyFormView()
: CFormView(IDD_MYFORMVIEW),
m_strObjectName(_T("")),
m_wstrFileName(L""), m_wstrFilePath(L""),
m_eTerrainType(ENGINE::TERRAIN_END)
, m_strPositionX(_T("0"))
, m_strPositionY(_T("0"))
, m_strPositionZ(_T("0"))
, m_strRotationX(_T("0"))
, m_strRotationY(_T("0"))
, m_strRotationZ(_T("0"))
, m_strScaleX(_T("1"))
, m_strScaleY(_T("1"))
, m_strScaleZ(_T("1"))
{
}
CMyFormView::~CMyFormView()
{
}
void CMyFormView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
DDX_Control(pDX, IDC_FORMPICTURE, m_PictureControl);
DDX_Text(pDX, IDC_EDIT1, m_strObjectName);
DDX_Control(pDX, IDC_RADIO1, m_TerrainTypeRadioBtn[0]);
DDX_Control(pDX, IDC_RADIO2, m_TerrainTypeRadioBtn[1]);
DDX_Control(pDX, IDC_RADIO3, m_TerrainTypeRadioBtn[2]);
DDX_Text(pDX, IDC_EDIT2, m_strPositionX);
DDX_Text(pDX, IDC_EDIT3, m_strPositionY);
DDX_Text(pDX, IDC_EDIT4, m_strPositionZ);
DDX_Text(pDX, IDC_EDIT5, m_strRotationX);
DDX_Text(pDX, IDC_EDIT6, m_strRotationY);
DDX_Text(pDX, IDC_EDIT7, m_strRotationZ);
DDX_Text(pDX, IDC_EDIT8, m_strScaleX);
DDX_Text(pDX, IDC_EDIT9, m_strScaleY);
DDX_Text(pDX, IDC_EDIT10, m_strScaleZ);
DDX_Control(pDX, IDC_CHECK1, m_CheckButton_Grid);
}
BEGIN_MESSAGE_MAP(CMyFormView, CFormView)
ON_BN_CLICKED(IDC_BUTTON1, &CMyFormView::OnBnClickedButtonMapObj)
ON_BN_CLICKED(IDC_BUTTON2, &CMyFormView::OnBnClickedButtonMonster)
ON_BN_CLICKED(IDC_BUTTON3, &CMyFormView::OnBnClickedButtonTrigger)
ON_WM_LBUTTONDOWN()
ON_WM_KEYDOWN()
ON_WM_MOUSEMOVE()
ON_WM_KEYDOWN()
ON_EN_CHANGE(IDC_EDIT9, &CMyFormView::OnEnChangeEdit9)
ON_EN_CHANGE(IDC_EDIT2, &CMyFormView::OnEnChangeEdit2)
ON_EN_CHANGE(IDC_EDIT3, &CMyFormView::OnEnChangeEdit3)
ON_EN_CHANGE(IDC_EDIT4, &CMyFormView::OnEnChangeEdit4)
ON_EN_CHANGE(IDC_EDIT5, &CMyFormView::OnEnChangeEdit5)
ON_EN_CHANGE(IDC_EDIT6, &CMyFormView::OnEnChangeEdit6)
ON_EN_CHANGE(IDC_EDIT7, &CMyFormView::OnEnChangeEdit7)
ON_EN_CHANGE(IDC_EDIT8, &CMyFormView::OnEnChangeEdit8)
ON_EN_CHANGE(IDC_EDIT10, &CMyFormView::OnEnChangeEdit10)
ON_BN_CLICKED(IDC_BUTTON4, &CMyFormView::OnBnClickedButton_Save)
ON_BN_CLICKED(IDC_BUTTON5, &CMyFormView::OnBnClickedButton_Load)
ON_BN_CLICKED(IDC_BUTTON6, &CMyFormView::OnBnClickedButton_PathUpdate)
END_MESSAGE_MAP()
// CMyFormView 진단입니다.
#ifdef _DEBUG
void CMyFormView::AssertValid() const
{
CFormView::AssertValid();
}
#ifndef _WIN32_WCE
void CMyFormView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif
#endif //_DEBUG
// CMyFormView 메시지 처리기입니다.
void CMyFormView::OnBnClickedButtonMapObj()
{
// TODO: 여기에 컨트롤 알림 처리기 코드 추가합니다.
m_ObjSelect_Map.ShowWindow(SW_SHOW);
}
void CMyFormView::OnBnClickedButtonMonster()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_ObjSelect_Monster.ShowWindow(SW_SHOW);
}
void CMyFormView::OnBnClickedButtonTrigger()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_ObjSelect_Trigger.ShowWindow(SW_SHOW);
}
void CMyFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if (nullptr == m_ObjSelect_Map.GetSafeHwnd())
{
m_ObjSelect_Map.Create(IDD_OBJECTSELECTDLG);
m_ObjSelect_Map.SetType(CMapObjectSelectDlg::OBJ_MAP);
}
if (nullptr == m_ObjSelect_Monster.GetSafeHwnd())
{
m_ObjSelect_Monster.Create(IDD_OBJECTSELECTDLG);
m_ObjSelect_Monster.SetType(CMapObjectSelectDlg::OBJ_MONSTER);
}
if (nullptr == m_ObjSelect_Trigger.GetSafeHwnd())
{
m_ObjSelect_Trigger.Create(IDD_OBJECTSELECTDLG);
m_ObjSelect_Trigger.SetType(CMapObjectSelectDlg::OBJ_TRIGGER);
}
m_TerrainTypeRadioBtn[0].SetCheck(true);
}
void CMyFormView::UpdatePicture(wstring _wstrName, wstring _wstrPath)
{
UpdateData(TRUE);
//CString strFileName = L"";
m_strObjectName = _wstrName.c_str();
m_wstrFileName = _wstrName;
m_wstrFilePath = _wstrPath;
if (!lstrcmp(m_wstrFileName.c_str(), L""))
return;
CRect StaticPictureRect;
m_PictureControl.GetClientRect(StaticPictureRect);
if (!m_Img.IsNull())
{
m_Img.Destroy();
m_PictureControl.SetBitmap(NULL);
// CImage 초기화가 안되서 임시 방편.
m_Img.Load(L"..\\Client\\Texture\\Tiles\\No_Animaition\\64 x 64\\Tile64x64_9.png");
int iWidth = (m_Img.GetWidth() / StaticPictureRect.Width()) * StaticPictureRect.Width();
int iHeight = (m_Img.GetHeight() / StaticPictureRect.Height() * StaticPictureRect.Height());
if (iWidth <= 0) iWidth = StaticPictureRect.Width();
if (iHeight <= 0) iHeight = StaticPictureRect.Height();
m_Img.Draw(m_PictureControl.GetWindowDC()->m_hDC,
StaticPictureRect.TopLeft().x,
StaticPictureRect.TopLeft().y,
iWidth,
iHeight);
m_Img.Destroy();
}
m_Img.Load(_wstrPath.c_str());
int iWidth = (m_Img.GetWidth() / StaticPictureRect.Width()) * StaticPictureRect.Width();
int iHeeght = (m_Img.GetHeight() / StaticPictureRect.Height() * StaticPictureRect.Height());
if (iWidth <= 0) iWidth = StaticPictureRect.Width();
if (iHeeght <= 0) iHeeght = StaticPictureRect.Height();
m_Img.Draw(m_PictureControl.GetWindowDC()->m_hDC,
StaticPictureRect.TopLeft().x,
StaticPictureRect.TopLeft().y,
iWidth,
iHeeght);
//// TextureMgr 사용
//const ENGINE::TEX_INFO* pTexInfo = ENGINE::GetTextureMgr()->GetTexInfo(m_wstrFileName);
//NULL_CHECK(pTexInfo);
//ENGINE::GetGraphicDev()->Render_Begin();
//D3DXMATRIX matScale, matTrans, matWorld;
//D3DXMatrixIdentity(&matWorld);
//D3DXMatrixScaling(&matScale, (float)WINCX / pTexInfo->tImgInfo.Width, (float)WINCY / pTexInfo->tImgInfo.Height, 0.f);
//D3DXMatrixTranslation(&matTrans, 0.f, 0.f, 0.f);
//matWorld = matScale * matTrans;
//ENGINE::GetGraphicDev()->GetSprite()->SetTransform(&matWorld);
//ENGINE::GetGraphicDev()->GetSprite()->Draw(pTexInfo->pTexture,
// nullptr, nullptr, nullptr, D3DCOLOR_ARGB(255, 255, 255, 255));
//ENGINE::GetGraphicDev()->Render_End(m_PictureControl.m_hWnd);
UpdateData(FALSE);
}
void CMyFormView::UpdateTransformStr(D3DXVECTOR3 _vPos, D3DXVECTOR3 _vRot, D3DXVECTOR3 _vSize)
{
UpdateData(TRUE);
m_strPositionX = to_string(_vPos.x).substr(0, (_vPos.x < 0) ? 5 : 4).c_str();
m_strPositionY = to_string(_vPos.y).substr(0, (_vPos.y < 0) ? 5 : 4).c_str();
m_strPositionZ = to_string(_vPos.z).substr(0, (_vPos.z < 0) ? 5 : 4).c_str();
m_strRotationX = to_string(_vRot.x).substr(0, (_vRot.x < 0) ? 5 : 4).c_str();
m_strRotationY = to_string(_vRot.y).substr(0, (_vRot.y < 0) ? 5 : 4).c_str();
m_strRotationZ = to_string(_vRot.z).substr(0, (_vRot.z < 0) ? 5 : 4).c_str();
m_strScaleX = to_string(_vSize.x).substr(0, (_vSize.x < 0) ? 5 : 4).c_str();
m_strScaleY = to_string(_vSize.y).substr(0, (_vSize.y < 0) ? 5 : 4).c_str();
m_strScaleZ = to_string(_vSize.z).substr(0, (_vSize.z < 0) ? 5 : 4).c_str();
UpdateData(FALSE);
}
D3DXVECTOR3 CMyFormView::GetPositionVec()
{
return D3DXVECTOR3(stof((wstring)m_strPositionX), stof((wstring)m_strPositionY), stof((wstring)m_strPositionZ));
}
D3DXVECTOR3 CMyFormView::GetRotationVec()
{
return D3DXVECTOR3(stof((wstring)m_strRotationX), stof((wstring)m_strRotationY), stof((wstring)m_strRotationZ));
}
D3DXVECTOR3 CMyFormView::GetScaleVec()
{
return D3DXVECTOR3(stof((wstring)m_strScaleX), stof((wstring)m_strScaleY), stof((wstring)m_strScaleZ));
}
void CMyFormView::EditDataExchange()
{
UpdateData(TRUE);
CMainFrame* pMainFrm = dynamic_cast<CMainFrame*>(::AfxGetApp()->GetMainWnd());
NULL_CHECK(pMainFrm);
CToolView* pView = dynamic_cast<CToolView*>(pMainFrm->m_MainSplitter.GetPane(0, 1));
NULL_CHECK(pView);
pView->ChangeValueAfter();
m_fPositionValue[X] = GetPositionVec().x;
m_fPositionValue[Y] = GetPositionVec().y;
m_fPositionValue[Z] = GetPositionVec().z;
m_fRotaionValue[X] = GetRotationVec().x;
m_fRotaionValue[Y] = GetRotationVec().y;
m_fRotaionValue[Z] = GetRotationVec().z;
m_fScaleValue[X] = GetScaleVec().x;
m_fScaleValue[Y] = GetScaleVec().y;
m_fScaleValue[Z] = GetScaleVec().z;
UpdateData(FALSE);
}
void CMyFormView::InitData()
{
UpdateData(TRUE);
m_strPositionX = to_string(m_fPositionValue[X]).substr(0, (m_fPositionValue[X] < 0) ? 5 : 4).c_str();
m_strPositionY = to_string(m_fPositionValue[Y]).substr(0, (m_fPositionValue[Y] < 0) ? 5 : 4).c_str();
m_strPositionZ = to_string(m_fPositionValue[Z]).substr(0, (m_fPositionValue[Z] < 0) ? 5 : 4).c_str();
m_strRotationX = to_string(m_fRotaionValue[X]).substr(0, (m_fRotaionValue[X] < 0) ? 5 : 4).c_str();
m_strRotationY = to_string(m_fRotaionValue[Y]).substr(0, (m_fRotaionValue[Y] < 0) ? 5 : 4).c_str();
m_strRotationZ = to_string(m_fRotaionValue[Z]).substr(0, (m_fRotaionValue[Z] < 0) ? 5 : 4).c_str();
m_strScaleX = to_string(m_fScaleValue[X]).substr(0, (m_fScaleValue[X] < 0) ? 5 : 4).c_str();
m_strScaleY = to_string(m_fScaleValue[Y]).substr(0, (m_fScaleValue[Y] < 0) ? 5 : 4).c_str();
m_strScaleZ = to_string(m_fScaleValue[Z]).substr(0, (m_fScaleValue[Z] < 0) ? 5 : 4).c_str();
CMainFrame* pMainFrm = dynamic_cast<CMainFrame*>(::AfxGetApp()->GetMainWnd());
NULL_CHECK(pMainFrm);
CToolView* pView = dynamic_cast<CToolView*>(pMainFrm->m_MainSplitter.GetPane(0, 1));
NULL_CHECK(pView);
pView->ChangeValueAfter();
UpdateData(FALSE);
}
void CMyFormView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
CFormView::OnLButtonDown(nFlags, point);
CMainFrame* pMainFrm = dynamic_cast<CMainFrame*>(::AfxGetApp()->GetMainWnd());
NULL_CHECK(pMainFrm);
CToolView* pView = dynamic_cast<CToolView*>(pMainFrm->m_MainSplitter.GetPane(0, 1));
NULL_CHECK(pView);
pView->ChangeValueAfter();
}
void CMyFormView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
CFormView::OnMouseMove(nFlags, point);
UpdateData(TRUE);
UpdatePicture(m_wstrFileName, m_wstrFilePath);
for (int i = 0; i < 3; i++)
{
if ((m_TerrainTypeRadioBtn[i].GetCheck() >= 1))
{
if (m_eTerrainType != (ENGINE::TERRAIN_TYPE)i)
{
if (m_eTerrainType != ENGINE::TERRAIN_END)
{
CMainFrame* pMainFrm = dynamic_cast<CMainFrame*>(::AfxGetApp()->GetMainWnd());
NULL_CHECK(pMainFrm);
m_eTerrainType = (ENGINE::TERRAIN_TYPE)i;
CToolView* pView = dynamic_cast<CToolView*>(pMainFrm->m_MainSplitter.GetPane(0, 1));
NULL_CHECK(pView);
pView->ChangeTerrainType();
}
m_eTerrainType = (ENGINE::TERRAIN_TYPE)i;
}
}
}
UpdateData(FALSE);
}
void CMyFormView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CFormView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CMyFormView::OnEnChangeEdit2()
{
EditDataExchange();
}
void CMyFormView::OnEnChangeEdit3()
{
EditDataExchange();
}
void CMyFormView::OnEnChangeEdit4()
{
EditDataExchange();
}
void CMyFormView::OnEnChangeEdit5()
{
EditDataExchange();
}
void CMyFormView::OnEnChangeEdit6()
{
EditDataExchange();
}
void CMyFormView::OnEnChangeEdit7()
{
EditDataExchange();
}
void CMyFormView::OnEnChangeEdit8()
{
EditDataExchange();
}
void CMyFormView::OnEnChangeEdit9()
{
EditDataExchange();
}
void CMyFormView::OnEnChangeEdit10()
{
EditDataExchange();
}
#pragma endregion
void CMyFormView::OnBnClickedButton_Save()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CMainFrame* pMainFrm = dynamic_cast<CMainFrame*>(::AfxGetApp()->GetMainWnd());
NULL_CHECK(pMainFrm);
// GetPane(row, col): row, col 위치에 배치된 CWnd* 를 반환하는 CSplitterWnd의 멤버 함수.
CToolView* pView = dynamic_cast<CToolView*>(pMainFrm->m_MainSplitter.GetPane(0, 1));
NULL_CHECK(pView);
list<CToolTerrain*> pTerrainList = pView->m_pCubeList;
UpdateData(TRUE);
CFileDialog Dlg(FALSE, L".dat", L"제목없음.dat",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
L"Data Files(*.dat)|*.dat||", this);
TCHAR szCurrentPath[MAX_STR] = L"";
// 현재 작업경로를 얻어오는 함수
::GetCurrentDirectory(MAX_STR, szCurrentPath);
// 현재 경로에서 파일명을 제거하는 함수. 제거할 파일명 없다면 말단 폴더명을 제거 (\Debug ,\Tool)
::PathRemoveFileSpec(szCurrentPath);
lstrcat(szCurrentPath, L"\\Data");
// 절대 경로만 가능
Dlg.m_ofn.lpstrInitialDir = szCurrentPath;
if (IDOK == Dlg.DoModal()) // IDOK : 확인, 저장, 열기 등 버튼 눌렀을 때 반환
{
HANDLE hFile = ::CreateFile(Dlg.GetPathName(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (INVALID_HANDLE_VALUE == hFile)
FAILED_CHECK_MSG(-1, L"Save Failed. [INVALID_HANDLE_VALUE]");
DWORD dwByte = 0;
D3DXVECTOR3 vPos, vSize, vAngle;
ENGINE::TERRAIN_TYPE eTerrainType;
for (auto iter : pTerrainList)
{
TCHAR szName[MAX_STR] = L"";
lstrcpy(szName, iter->GetTexName().c_str());
ENGINE::CTransform* pTransform = dynamic_cast<ENGINE::CTransform*>(iter->Get_Component(L"Transform"));
vPos = pTransform->GetPos();
vSize = pTransform->GetSize();
vAngle = D3DXVECTOR3(pTransform->GetAngle(ENGINE::ANGLE_X), pTransform->GetAngle(ENGINE::ANGLE_Y), pTransform->GetAngle(ENGINE::ANGLE_Z));
eTerrainType = iter->GetTerrainType();
::WriteFile(hFile, &szName, sizeof(TCHAR) * MAX_STR, &dwByte, nullptr);
::WriteFile(hFile, &vPos, sizeof(D3DXVECTOR3), &dwByte, nullptr);
::WriteFile(hFile, &vSize, sizeof(D3DXVECTOR3), &dwByte, nullptr);
::WriteFile(hFile, &vAngle, sizeof(D3DXVECTOR3), &dwByte, nullptr);
::WriteFile(hFile, &eTerrainType, sizeof(ENGINE::TERRAIN_TYPE), &dwByte, nullptr);
}
CloseHandle(hFile);
MessageBox(_T("Save Success."), _T("Save"), MB_OK);
}
UpdateData(FALSE);
}
void CMyFormView::OnBnClickedButton_Load()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
UpdateData(TRUE);
CMainFrame* pMainFrm = dynamic_cast<CMainFrame*>(::AfxGetApp()->GetMainWnd());
NULL_CHECK(pMainFrm);
// GetPane(row, col): row, col 위치에 배치된 CWnd* 를 반환하는 CSplitterWnd의 멤버 함수.
CToolView* pView = dynamic_cast<CToolView*>(pMainFrm->m_MainSplitter.GetPane(0, 1));
NULL_CHECK(pView);
list<CToolTerrain*> pTerrainList = pView->m_pCubeList;
CFileDialog Dlg(TRUE, L".dat", L"제목없음.dat",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
L"Data Files(*.dat)|*.dat||", this);
TCHAR szCurrentPath[MAX_STR] = L"";
// 현재 작업경로를 얻어오는 함수
::GetCurrentDirectory(MAX_STR, szCurrentPath);
// 현재 경로에서 파일명을 제거하는 함수. 제거할 파일명 없다면 말단 폴더명을 제거 (\Debug ,\Tool)
::PathRemoveFileSpec(szCurrentPath);
lstrcat(szCurrentPath, L"\\Data");
// 절대 경로만 가능
Dlg.m_ofn.lpstrInitialDir = szCurrentPath;
if (IDOK == Dlg.DoModal()) // IDOK : 확인, 저장, 열기 등 버튼 눌렀을 때 반환
{
HANDLE hFile = CreateFile(Dlg.GetPathName(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (INVALID_HANDLE_VALUE == hFile)
FAILED_CHECK_MSG(-1, L"Load Failed. [INVALID_HANDLE_VALUE]");
for (auto& _rObj : pTerrainList)
{
//_rObj->SetDead();
Safe_Delete(_rObj);
}
pView->m_pCubeList.clear();
DWORD dwByte = 0;
TCHAR szName[MAX_STR] = L"";
D3DXVECTOR3 vPos, vSize, vAngle;
ENGINE::TERRAIN_TYPE eTerrainType;
while (true)
{
::ReadFile(hFile, &szName, sizeof(TCHAR) * MAX_STR, &dwByte, nullptr);
::ReadFile(hFile, &vPos, sizeof(D3DXVECTOR3), &dwByte, nullptr);
::ReadFile(hFile, &vSize, sizeof(D3DXVECTOR3), &dwByte, nullptr);
::ReadFile(hFile, &vAngle, sizeof(D3DXVECTOR3), &dwByte, nullptr);
::ReadFile(hFile, &eTerrainType, sizeof(ENGINE::TERRAIN_TYPE), &dwByte, nullptr);
if (0 == dwByte)
break;
CToolTerrain* pTerrain = nullptr;
switch (eTerrainType)
{
case ENGINE::TERRAIN_CUBE:
{
pTerrain = CToolTerrainCube::Create(ENGINE::GetGraphicDev()->GetDevice());
break;
}
case ENGINE::TERRAIN_WALL:
{
pTerrain = CToolTerrainWallCube::Create(ENGINE::GetGraphicDev()->GetDevice());
break;
}
case ENGINE::TERRAIN_RECT:
{
pTerrain = CToolTerrainRect::Create(ENGINE::GetGraphicDev()->GetDevice());
break;
}
}
ENGINE::CTransform* pTransform = dynamic_cast<ENGINE::CTransform*>(pTerrain->Get_Component(L"Transform"));
pTransform->SetPos(vPos);
pTransform->SetSize(vSize);
pTransform->SetAngle(vAngle.x, ENGINE::ANGLE_X);
pTransform->SetAngle(vAngle.y, ENGINE::ANGLE_Y);
pTransform->SetAngle(vAngle.z, ENGINE::ANGLE_Z);
pTerrain->SetTexName(szName);
pView->AddCubeForLoad(pTerrain);
}
CloseHandle(hFile);
MessageBox(_T("Load Success."), _T("Load"), MB_OK);
}
UpdateData(FALSE);
}
void CMyFormView::OnBnClickedButton_PathUpdate()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CPathExtract* pPath = new CPathExtract;
pPath->MakePathFile();
ENGINE::Safe_Delete(pPath);
}
| [
"une6204@gmail.com"
] | une6204@gmail.com |
9aa3c52bac2f701068274acf27fc0c83f6cf3a36 | 7205079d758988e4b9f3740a7e6b2a91f429cd79 | /Maze/NodeDraft.cpp | dcb8ec38e8f25ced0ceb42176e3f129c5a757137 | [] | no_license | 123Phil/Useless-projects | d075ff98c8c21fe74edb01156e0bd7347b04371a | cce3db3fb7a9dc9a786a34ca57d36bedc90fcbf3 | refs/heads/master | 2021-01-13T01:06:53.485105 | 2015-12-05T00:58:21 | 2015-12-05T00:58:21 | 47,436,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,925 | cpp | #include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
#include <queue>
using namespace std;
//make a grid based node class
class Node{
public:
Node(int value, int x_coord, int y_coord){
_value = value;
_x_coord = x_coord;
_y_coord = y_coord;
_down = nullptr;
_right = nullptr;
}
~Node();
int value() const{return _value;}
void set_value(int value) {_value = value;}
int x_coord(){return _x_coord;}
int y_coord(){return _y_coord;}
Node* right() const{return _right;}
void set_right(Node* right){_right = _right;}
Node* down() const{return _down;}
void set_down(Node* down){_down = _down;}
private:
int _value, _x_coord, _y_coord;
Node *_right, *_down;
};
class Maze{
public:
//===================================================================================
//Constructor, Destructor
//===================================================================================
Maze(int width, int height, int density){
_width = width;
_height = height;
_density = density;
_size = 0;
generate_map();
}
~Maze(){clear();}
//===================================================================================
//Functions for Destructor: empty(), pop(), clear()
//===================================================================================
bool empty() const{return _size == 0;}
void pop(Node *node){
//if there is a node to the right, move along to the right
if(node->right()!=nullptr)
pop(node->right());
//if there isn't a not to the right, try going down
else if(node->right()==nullptr){
//if there is a node below, move along downward
if(node->down()!=nullptr){
pop(node->down());
//if there isn't a not downward, pop it
}else if(node->down()==nullptr){
delete node;
_size--;
}
}
}
void clear(){
while(!empty())
pop(_origin);
}
//===================================================================================
//Variable Set and Get Functions (removed set and made maze a one-time use per call)
//===================================================================================
int width() const{return _width;}
// void set_width(int width){_width = width;}
int height() const{return _height;}
// void set_height(int height){_height = height;}
int density() const{return _density;}
// void set_density(int density){_density = density;}
Node *start(){return _start;}
Node *finish(){return _finish;}
//===================================================================================
//Base Map Generator: create the plane
//===================================================================================
void generate_map(){
srand(time(NULL));
int space;
if(_origin==nullptr){
if(rand()%100 < _density){
//wall
space = 1;
}else{
//space
space = 0;
}
_origin = new Node(space, 1, 1);
}
add_x_node(_origin);
//set starting point
_start = iterator(1, (rand()%_height + 1));
_start->set_value(0);
//set finishing point
_finish = iterator(_width, (rand()%_height + 1));
_finish->set_value(0);
}
//===================================================================================
//Iterator
//===================================================================================
Node* iterator(int x, int y){
return y_iter(x_iter(_origin, x), y);
}
//===================================================================================
//Print
//===================================================================================
void print(){
int read;
for(int i = 0; i <= _width+1; i++)
cout << 'X';
cout << endl;
for(int j = 1; j <= _height; j++){
cout << 'X';
for(int i = 1; i <= _width; i++){
read = iterator(i, j)->value();
switch(read){
case 0:
cout << ' ';
break;
case 1:
cout << 'X';
break;
case 2:
cout << '*';
break;
}
}
cout << 'X' << endl;
}
for(int i = 0; i <= _width+1; i++){
cout << 'X';
}
cout << endl;
}
private:
//===================================================================================
//Helper Functions
//===================================================================================
void add_x_node(Node *node){
int space;
if(node->down()==nullptr){
add_y_node(node);
}
if(node->x_coord() != _width){
if(rand()%100 < _density){
space = 1;
}else{
space = 0;
Node *new_node = new Node(space, node->x_coord() + 1, 0);
node->set_right(new_node);
_size++;
add_x_node(new_node);
}
}
}
void add_y_node(Node *node){
int space;
Node *new_node;
if(node->y_coord() != _height){
if(rand()%100 < _density){
space = 1;
}else{
space = 0;
new_node = new Node(space, node->x_coord(), node->y_coord() + 1);
node->set_down(new_node);
_size++;
add_y_node(new_node);
}
}
}
Node* x_iter(Node *node, int x){
if(x != 0){
return x_iter(node->right(), x--);
}
else if(x == 0){
return node;
}
}
Node* y_iter(Node *node, int y){
if(y != 0){
return y_iter(node->down(), y--);
}
else if(y == 0){
return node;
}
}
int _width, _height, _density, _size;
Node *_origin, *_start, *_finish;
};
class Tnode{
public:
Tnode(Node *value){
_value = value;
_prev = nullptr;
}
~Tnode(){}
void set_prev(Tnode *node){
_prev = node;
}
Tnode *prev(){
return _prev;
}
Node *value(){
return _value;
}
private:
Tnode *_prev;
Node *_value;
};
class Mouse{
public:
Mouse(Maze *maze){
_root = nullptr;
_shortest = nullptr;
_finished = false;
_maze = maze;
solve();
}
~Mouse();
bool finish(){return _finished;}
void solve(){
Tnode *active_node;
if(_root == nullptr){
_root = new Tnode(_maze->start());
_maze->start()->set_value(2);
}
_queuednode.push(_root);
do{
active_node = _queuednode.front();
_queuednode.pop();
search(active_node);
}while(_queuednode.size() != 0);
if(_finishnode.size() > 0)
_finished = true;
}
void search(Tnode *node){
//right
Tnode *new_node;
if(_maze->iterator(node->value()->x_coord()+1,node->value()->y_coord())->value() == 0){
//maze -> iterated node -> setting its value
_maze->iterator(node->value()->x_coord()+1,node->value()->y_coord())->set_value(2);
new_node = new Tnode(_maze->iterator(node->value()->x_coord()+1,node->value()->y_coord()));
new_node->set_prev(node);
if(new_node->value()->x_coord() == _maze->finish()->x_coord() && node->value()->y_coord() == _maze->finish()->y_coord())
_finishnode.push(node);
else
_queuednode.push(new_node);
}
//up
if(_maze->iterator(node->value()->x_coord(),node->value()->y_coord()-1)->value() == 0){
_maze->iterator(node->value()->x_coord(),node->value()->y_coord()-1)->set_value(2);
new_node = new Tnode(_maze->iterator(node->value()->x_coord(),node->value()->y_coord()-1));
new_node->set_prev(node);
if(new_node->value()->x_coord() == _maze->finish()->x_coord() && node->value()->y_coord() == _maze->finish()->y_coord())
_finishnode.push(node);
else
_queuednode.push(new_node);
}
//down
if(_maze->iterator(node->value()->x_coord(),node->value()->y_coord()+1)->value() == 0){
_maze->iterator(node->value()->x_coord(),node->value()->y_coord()+1)->set_value(2);
new_node = new Tnode(_maze->iterator(node->value()->x_coord()+1,node->value()->y_coord()));
new_node->set_prev(node);
if(new_node->value()->x_coord() == _maze->finish()->x_coord() && node->value()->y_coord() == _maze->finish()->y_coord())
_finishnode.push(node);
else
_queuednode.push(new_node);
}
//left
if(_maze->iterator(node->value()->x_coord()-1,node->value()->y_coord())->value() == 0){
_maze->iterator(node->value()->x_coord()-1,node->value()->y_coord())->set_value(2);
new_node = new Tnode(_maze->iterator(node->value()->x_coord()-1,node->value()->y_coord()));
new_node->set_prev(node);
if(new_node->value()->x_coord() == _maze->finish()->x_coord() && node->value()->y_coord() == _maze->finish()->y_coord())
_finishnode.push(node);
else
_queuednode.push(new_node);
}
}
int shortestlength(){
Tnode *active_node;
int current_shortest = 9999999999;
do{
active_node = _finishnode.front();
if(chainlength(active_node, 0) < current_shortest){
current_shortest = chainlength(active_node, 0);
//try to figure out for printing use
_shortest = active_node;
}
_finishnode.pop();
}while(_finishnode.size() != 0);
return current_shortest;
}
int chainlength(Tnode *node, int length){
if(node->prev() == nullptr)
return length;
else
return chainlength(node->prev(), length++);
}
private:
Tnode *_root, *_shortest;
bool _finished;
Maze *_maze;
queue<Tnode*> _queuednode, _finishnode;
};
void welcome();
void user_input(int& w, int& h, int& d);
void result(Mouse *mouse);
void shortestroute(int x);
int main(){
//Declare variable
int width, height, density;
//Take values for width. height, and density
user_input(width, height, density);
//Create maze
Maze maze(width, height, density);
maze.print();
Mouse mouse(&maze);
result(&mouse);
maze.print();
}
void welcome();
void user_input(int& w, int& h, int& d){
//input width
cout << "Enter the width of the maze (1-99): ";
cin >> w;
cout << '\n';
//input height
cout << "Enter the height of the maze (1-99): ";
cin >> h;
cout << '\n';
//input density
cout << "Enter the density of the maze (1-99): ";
cin >> d;
cout << '\n';
}
void result(Mouse *mouse){
if(mouse->finish()){
cout << "The mouse have successfully cross the maze.\n";
shortestroute(mouse->shortestlength());
}
else
cout << "The mouse have failed to cross the maze.\n";
}
void shortestroute(int x){
cout << "The shortest route took x steps\n";
}
| [
"phillipwstewart@gmail.com"
] | phillipwstewart@gmail.com |
ddf80695d4b55dd8e77649afe70b047231bdb44d | a9921bd48da8870a589fe8f0e2a1a023991b6c12 | /divison.cpp | a90315e3316ad4ba802e4397275e06a42222f825 | [] | no_license | atyamsriharsha/My-Uva-solutions- | 36b89d88c2c62db8431918b5cbcb1819a9b0052c | e36942e48203594ec895502ff2affe9d7d3620e2 | refs/heads/master | 2021-01-15T16:17:31.091882 | 2015-07-22T21:05:57 | 2015-07-22T21:05:57 | 38,688,856 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,533 | cpp | #include <iostream>
#include <cstring>
#include <cstdio>
#include <ctime>
using namespace std;
bool digits[10];
int last;
bool valid(int numerador, int denominador)
{
if (numerador > 99999) return false;
memset(digits, true, sizeof digits);
if (numerador / 10000 == 0) digits[0] = false;
while(numerador > 0)
{
last = numerador % 10;
if (digits[last]) digits[last] = false;
else return false;
numerador /= 10;
}
if(denominador / 10000 == 0)
if (digits[0]) digits[0] = false;
else return false;
while (denominador > 0) {
last = denominador % 10;
if (digits[last]) digits[last] = false;
else return false;
denominador /= 10;
}
return true;
}
int main()
{
int N, num;
bool ok;
scanf("%d", &N);
if (N != 0) {
while (true) {
ok = false;
for (int f = 0; f < 10; f++) {
num = f;
for (int g = 0; g < 10; g++) {
if (g == f) continue;
num = num * 10 + g;
for (int h = 0; h < 10; h++) {
if (h == g || h == f) continue;
num = num * 10 + h;
for (int i = 0; i < 10; i++) {
if (i == h || i == g || i == f) continue;
num = num * 10 + i;
for (int j = 0; j < 10; j++) {
if (j == i || j == h || j == g || j == f) continue;
num = num * 10 + j;
//db(num);
int numerator = num * N;
if (valid(numerator, num)) {
ok = true;
//db(numerator % num);
if (numerator / 10000 == 0) {
if (num / 10000 == 0) {
//db2(num, num / 10000);
printf("0%d / 0%d = %d\n", numerator, num, N);
} else
printf("0%d / %d = %d\n", numerator, num, N);
} else {
if (num / 10000 == 0) {
//db2(num,num / 10000);
printf("%d / 0%d = %d\n", numerator, num, N);
} else
printf("%d / %d = %d\n", numerator, num, N);
}
}
num -= j;
num /= 10;
}
num -= i;
num /= 10;
}
num -= h;
num /= 10;
}
num -= g;
num /= 10;
}
}
int temp = N;
scanf("%d", &N);
if (!ok)
if(N != 0)
printf("There are no solutions for %d.\n\n", temp);
else
printf("There are no solutions for %d.\n", temp);
else printf("\n");
if(N == 0) break;
}
}
return 0;
}
| [
"atyamsriharsha@gmail.com"
] | atyamsriharsha@gmail.com |
90852fafa9be0c1f1efa13d7d15a02a340d2e26c | f698a822a129d23ef93f65a49e3b20bdcd5d3ec8 | /moc_basicopenglview.cpp | 384f4245ae085ffdf37d28e16e42f2150ab29471 | [] | no_license | GriffinLedingham/Flocking | 0a987202a0f46590f9ff9eb5943b63fc0aec0cc6 | 23d9d666ce58529a8c482a9d1fe31750f32cfe28 | refs/heads/master | 2020-04-13T22:58:33.094336 | 2012-12-15T22:14:55 | 2012-12-15T22:14:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,967 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'basicopenglview.h'
**
** Created: Wed Dec 12 14:49:18 2012
** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "basicopenglview.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'basicopenglview.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_BasicOpenGLView[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: signature, parameters, type, tag, flags
17, 16, 16, 16, 0x0a,
29, 16, 16, 16, 0x0a,
0 // eod
};
static const char qt_meta_stringdata_BasicOpenGLView[] = {
"BasicOpenGLView\0\0animateGL()\0paintGL()\0"
};
void BasicOpenGLView::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
BasicOpenGLView *_t = static_cast<BasicOpenGLView *>(_o);
switch (_id) {
case 0: _t->animateGL(); break;
case 1: _t->paintGL(); break;
default: ;
}
}
Q_UNUSED(_a);
}
const QMetaObjectExtraData BasicOpenGLView::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject BasicOpenGLView::staticMetaObject = {
{ &QGLWidget::staticMetaObject, qt_meta_stringdata_BasicOpenGLView,
qt_meta_data_BasicOpenGLView, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &BasicOpenGLView::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *BasicOpenGLView::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *BasicOpenGLView::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_BasicOpenGLView))
return static_cast<void*>(const_cast< BasicOpenGLView*>(this));
return QGLWidget::qt_metacast(_clname);
}
int BasicOpenGLView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QGLWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
}
return _id;
}
QT_END_MOC_NAMESPACE
| [
"gcledingham@gmail.com"
] | gcledingham@gmail.com |
fd9a0b93ac9a1efb951e25ee7d561e9887a053a1 | 84173c56d1fd47e81bbfde6eeaa108d8378922ce | /llvm/lib/Analysis/ConstantFolding.cpp | f169a123e4503e140c3d90588dc3cff273ed1749 | [
"NCSA",
"MIT"
] | permissive | gbeauchesne/cm-compiler | 3c8840e4c9959f9bd604e955c2a447b5c9583ee9 | dd211eea3a2f2e27e1014ee05a94535ae78031a9 | refs/heads/master | 2023-08-04T03:54:49.660141 | 2018-05-17T13:45:44 | 2018-05-17T17:28:01 | 126,233,617 | 0 | 0 | null | 2018-03-21T20:00:30 | 2018-03-21T20:00:30 | null | UTF-8 | C++ | false | false | 69,602 | cpp | //===-- ConstantFolding.cpp - Fold instructions into constants ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines routines for folding instructions into constants.
//
// Also, to supplement the basic IR ConstantExpr simplifications,
// this file defines some additional folding routines that can make use of
// DataLayout information. These functions cannot go in IR due to library
// dependency issues.
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Config/config.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include <cerrno>
#include <cmath>
#ifdef HAVE_FENV_H
#include <fenv.h>
#endif
using namespace llvm;
//===----------------------------------------------------------------------===//
// Constant Folding internal helper functions
//===----------------------------------------------------------------------===//
/// FoldBitCast - Constant fold bitcast, symbolically evaluating it with
/// DataLayout. This always returns a non-null constant, but it may be a
/// ConstantExpr if unfoldable.
static Constant *FoldBitCast(Constant *C, Type *DestTy,
const DataLayout &TD) {
// Catch the obvious splat cases.
if (C->isNullValue() && !DestTy->isX86_MMXTy())
return Constant::getNullValue(DestTy);
if (C->isAllOnesValue() && !DestTy->isX86_MMXTy())
return Constant::getAllOnesValue(DestTy);
// Handle a vector->integer cast.
if (IntegerType *IT = dyn_cast<IntegerType>(DestTy)) {
VectorType *VTy = dyn_cast<VectorType>(C->getType());
if (!VTy)
return ConstantExpr::getBitCast(C, DestTy);
unsigned NumSrcElts = VTy->getNumElements();
Type *SrcEltTy = VTy->getElementType();
// If the vector is a vector of floating point, convert it to vector of int
// to simplify things.
if (SrcEltTy->isFloatingPointTy()) {
unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits();
Type *SrcIVTy =
VectorType::get(IntegerType::get(C->getContext(), FPWidth), NumSrcElts);
// Ask IR to do the conversion now that #elts line up.
C = ConstantExpr::getBitCast(C, SrcIVTy);
}
ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(C);
if (!CDV)
return ConstantExpr::getBitCast(C, DestTy);
// Now that we know that the input value is a vector of integers, just shift
// and insert them into our result.
unsigned BitShift = TD.getTypeAllocSizeInBits(SrcEltTy);
APInt Result(IT->getBitWidth(), 0);
for (unsigned i = 0; i != NumSrcElts; ++i) {
Result <<= BitShift;
if (TD.isLittleEndian())
Result |= CDV->getElementAsInteger(NumSrcElts-i-1);
else
Result |= CDV->getElementAsInteger(i);
}
return ConstantInt::get(IT, Result);
}
// The code below only handles casts to vectors currently.
VectorType *DestVTy = dyn_cast<VectorType>(DestTy);
if (!DestVTy)
return ConstantExpr::getBitCast(C, DestTy);
// If this is a scalar -> vector cast, convert the input into a <1 x scalar>
// vector so the code below can handle it uniformly.
if (isa<ConstantFP>(C) || isa<ConstantInt>(C)) {
Constant *Ops = C; // don't take the address of C!
return FoldBitCast(ConstantVector::get(Ops), DestTy, TD);
}
// If this is a bitcast from constant vector -> vector, fold it.
if (!isa<ConstantDataVector>(C) && !isa<ConstantVector>(C))
return ConstantExpr::getBitCast(C, DestTy);
// If the element types match, IR can fold it.
unsigned NumDstElt = DestVTy->getNumElements();
unsigned NumSrcElt = C->getType()->getVectorNumElements();
if (NumDstElt == NumSrcElt)
return ConstantExpr::getBitCast(C, DestTy);
Type *SrcEltTy = C->getType()->getVectorElementType();
Type *DstEltTy = DestVTy->getElementType();
// Otherwise, we're changing the number of elements in a vector, which
// requires endianness information to do the right thing. For example,
// bitcast (<2 x i64> <i64 0, i64 1> to <4 x i32>)
// folds to (little endian):
// <4 x i32> <i32 0, i32 0, i32 1, i32 0>
// and to (big endian):
// <4 x i32> <i32 0, i32 0, i32 0, i32 1>
// First thing is first. We only want to think about integer here, so if
// we have something in FP form, recast it as integer.
if (DstEltTy->isFloatingPointTy()) {
// Fold to an vector of integers with same size as our FP type.
unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits();
Type *DestIVTy =
VectorType::get(IntegerType::get(C->getContext(), FPWidth), NumDstElt);
// Recursively handle this integer conversion, if possible.
C = FoldBitCast(C, DestIVTy, TD);
// Finally, IR can handle this now that #elts line up.
return ConstantExpr::getBitCast(C, DestTy);
}
// Okay, we know the destination is integer, if the input is FP, convert
// it to integer first.
if (SrcEltTy->isFloatingPointTy()) {
unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits();
Type *SrcIVTy =
VectorType::get(IntegerType::get(C->getContext(), FPWidth), NumSrcElt);
// Ask IR to do the conversion now that #elts line up.
C = ConstantExpr::getBitCast(C, SrcIVTy);
// If IR wasn't able to fold it, bail out.
if (!isa<ConstantVector>(C) && // FIXME: Remove ConstantVector.
!isa<ConstantDataVector>(C))
return C;
}
// Now we know that the input and output vectors are both integer vectors
// of the same size, and that their #elements is not the same. Do the
// conversion here, which depends on whether the input or output has
// more elements.
bool isLittleEndian = TD.isLittleEndian();
SmallVector<Constant*, 32> Result;
if (NumDstElt < NumSrcElt) {
// Handle: bitcast (<4 x i32> <i32 0, i32 1, i32 2, i32 3> to <2 x i64>)
Constant *Zero = Constant::getNullValue(DstEltTy);
unsigned Ratio = NumSrcElt/NumDstElt;
unsigned SrcBitSize = SrcEltTy->getPrimitiveSizeInBits();
unsigned SrcElt = 0;
for (unsigned i = 0; i != NumDstElt; ++i) {
// Build each element of the result.
Constant *Elt = Zero;
unsigned ShiftAmt = isLittleEndian ? 0 : SrcBitSize*(Ratio-1);
for (unsigned j = 0; j != Ratio; ++j) {
if (isa<UndefValue>(C->getAggregateElement(SrcElt))) {
Elt = UndefValue::get(DstEltTy);
continue;
}
Constant *Src =dyn_cast<ConstantInt>(C->getAggregateElement(SrcElt++));
if (!Src) // Reject constantexpr elements.
return ConstantExpr::getBitCast(C, DestTy);
// Zero extend the element to the right size.
Src = ConstantExpr::getZExt(Src, Elt->getType());
// Shift it to the right place, depending on endianness.
Src = ConstantExpr::getShl(Src,
ConstantInt::get(Src->getType(), ShiftAmt));
ShiftAmt += isLittleEndian ? SrcBitSize : -SrcBitSize;
// Mix it in.
Elt = ConstantExpr::getOr(Elt, Src);
}
Result.push_back(Elt);
}
return ConstantVector::get(Result);
}
// Handle: bitcast (<2 x i64> <i64 0, i64 1> to <4 x i32>)
unsigned Ratio = NumDstElt/NumSrcElt;
unsigned DstBitSize = DstEltTy->getPrimitiveSizeInBits();
// Loop over each source value, expanding into multiple results.
for (unsigned i = 0; i != NumSrcElt; ++i) {
Constant *Src = C->getAggregateElement(i);
if (isa<UndefValue>(Src)) {
// undef element casts into Ratio undef elements
for (unsigned j = 0; j != Ratio; ++j)
Result.push_back(UndefValue::get(DstEltTy));
continue;
}
if (!isa<ConstantInt>(Src)) // Reject constantexpr elements.
return ConstantExpr::getBitCast(C, DestTy);
unsigned ShiftAmt = isLittleEndian ? 0 : DstBitSize*(Ratio-1);
for (unsigned j = 0; j != Ratio; ++j) {
// Shift the piece of the value into the right place, depending on
// endianness.
Constant *Elt = ConstantExpr::getLShr(Src,
ConstantInt::get(Src->getType(), ShiftAmt));
ShiftAmt += isLittleEndian ? DstBitSize : -DstBitSize;
// Truncate and remember this piece.
Result.push_back(ConstantExpr::getTrunc(Elt, DstEltTy));
}
}
return ConstantVector::get(Result);
}
/// IsConstantOffsetFromGlobal - If this constant is actually a constant offset
/// from a global, return the global and the constant. Because of
/// constantexprs, this function is recursive.
static bool IsConstantOffsetFromGlobal(Constant *C, GlobalValue *&GV,
APInt &Offset, const DataLayout &TD) {
// Trivial case, constant is the global.
if ((GV = dyn_cast<GlobalValue>(C))) {
unsigned BitWidth = TD.getPointerTypeSizeInBits(GV->getType());
Offset = APInt(BitWidth, 0);
return true;
}
// Otherwise, if this isn't a constant expr, bail out.
ConstantExpr *CE = dyn_cast<ConstantExpr>(C);
if (!CE) return false;
// Look through ptr->int and ptr->ptr casts.
if (CE->getOpcode() == Instruction::PtrToInt ||
CE->getOpcode() == Instruction::BitCast ||
CE->getOpcode() == Instruction::AddrSpaceCast)
return IsConstantOffsetFromGlobal(CE->getOperand(0), GV, Offset, TD);
// i32* getelementptr ([5 x i32]* @a, i32 0, i32 5)
GEPOperator *GEP = dyn_cast<GEPOperator>(CE);
if (!GEP)
return false;
unsigned BitWidth = TD.getPointerTypeSizeInBits(GEP->getType());
APInt TmpOffset(BitWidth, 0);
// If the base isn't a global+constant, we aren't either.
if (!IsConstantOffsetFromGlobal(CE->getOperand(0), GV, TmpOffset, TD))
return false;
// Otherwise, add any offset that our operands provide.
if (!GEP->accumulateConstantOffset(TD, TmpOffset))
return false;
Offset = TmpOffset;
return true;
}
/// ReadDataFromGlobal - Recursive helper to read bits out of global. C is the
/// constant being copied out of. ByteOffset is an offset into C. CurPtr is the
/// pointer to copy results into and BytesLeft is the number of bytes left in
/// the CurPtr buffer. TD is the target data.
static bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset,
unsigned char *CurPtr, unsigned BytesLeft,
const DataLayout &TD) {
assert(ByteOffset <= TD.getTypeAllocSize(C->getType()) &&
"Out of range access");
// If this element is zero or undefined, we can just return since *CurPtr is
// zero initialized.
if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C))
return true;
if (ConstantInt *CI = dyn_cast<ConstantInt>(C)) {
if (CI->getBitWidth() > 64 ||
(CI->getBitWidth() & 7) != 0)
return false;
uint64_t Val = CI->getZExtValue();
unsigned IntBytes = unsigned(CI->getBitWidth()/8);
for (unsigned i = 0; i != BytesLeft && ByteOffset != IntBytes; ++i) {
int n = ByteOffset;
if (!TD.isLittleEndian())
n = IntBytes - n - 1;
CurPtr[i] = (unsigned char)(Val >> (n * 8));
++ByteOffset;
}
return true;
}
if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
if (CFP->getType()->isDoubleTy()) {
C = FoldBitCast(C, Type::getInt64Ty(C->getContext()), TD);
return ReadDataFromGlobal(C, ByteOffset, CurPtr, BytesLeft, TD);
}
if (CFP->getType()->isFloatTy()){
C = FoldBitCast(C, Type::getInt32Ty(C->getContext()), TD);
return ReadDataFromGlobal(C, ByteOffset, CurPtr, BytesLeft, TD);
}
if (CFP->getType()->isHalfTy()){
C = FoldBitCast(C, Type::getInt16Ty(C->getContext()), TD);
return ReadDataFromGlobal(C, ByteOffset, CurPtr, BytesLeft, TD);
}
return false;
}
if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) {
const StructLayout *SL = TD.getStructLayout(CS->getType());
unsigned Index = SL->getElementContainingOffset(ByteOffset);
uint64_t CurEltOffset = SL->getElementOffset(Index);
ByteOffset -= CurEltOffset;
while (1) {
// If the element access is to the element itself and not to tail padding,
// read the bytes from the element.
uint64_t EltSize = TD.getTypeAllocSize(CS->getOperand(Index)->getType());
if (ByteOffset < EltSize &&
!ReadDataFromGlobal(CS->getOperand(Index), ByteOffset, CurPtr,
BytesLeft, TD))
return false;
++Index;
// Check to see if we read from the last struct element, if so we're done.
if (Index == CS->getType()->getNumElements())
return true;
// If we read all of the bytes we needed from this element we're done.
uint64_t NextEltOffset = SL->getElementOffset(Index);
if (BytesLeft <= NextEltOffset - CurEltOffset - ByteOffset)
return true;
// Move to the next element of the struct.
CurPtr += NextEltOffset - CurEltOffset - ByteOffset;
BytesLeft -= NextEltOffset - CurEltOffset - ByteOffset;
ByteOffset = 0;
CurEltOffset = NextEltOffset;
}
// not reached.
}
if (isa<ConstantArray>(C) || isa<ConstantVector>(C) ||
isa<ConstantDataSequential>(C)) {
Type *EltTy = C->getType()->getSequentialElementType();
uint64_t EltSize = TD.getTypeAllocSize(EltTy);
uint64_t Index = ByteOffset / EltSize;
uint64_t Offset = ByteOffset - Index * EltSize;
uint64_t NumElts;
if (ArrayType *AT = dyn_cast<ArrayType>(C->getType()))
NumElts = AT->getNumElements();
else
NumElts = C->getType()->getVectorNumElements();
for (; Index != NumElts; ++Index) {
if (!ReadDataFromGlobal(C->getAggregateElement(Index), Offset, CurPtr,
BytesLeft, TD))
return false;
uint64_t BytesWritten = EltSize - Offset;
assert(BytesWritten <= EltSize && "Not indexing into this element?");
if (BytesWritten >= BytesLeft)
return true;
Offset = 0;
BytesLeft -= BytesWritten;
CurPtr += BytesWritten;
}
return true;
}
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
if (CE->getOpcode() == Instruction::IntToPtr &&
CE->getOperand(0)->getType() == TD.getIntPtrType(CE->getType())) {
return ReadDataFromGlobal(CE->getOperand(0), ByteOffset, CurPtr,
BytesLeft, TD);
}
}
// Otherwise, unknown initializer type.
return false;
}
static Constant *FoldReinterpretLoadFromConstPtr(Constant *C,
const DataLayout &TD) {
PointerType *PTy = cast<PointerType>(C->getType());
Type *LoadTy = PTy->getElementType();
IntegerType *IntType = dyn_cast<IntegerType>(LoadTy);
// If this isn't an integer load we can't fold it directly.
if (!IntType) {
unsigned AS = PTy->getAddressSpace();
// If this is a float/double load, we can try folding it as an int32/64 load
// and then bitcast the result. This can be useful for union cases. Note
// that address spaces don't matter here since we're not going to result in
// an actual new load.
Type *MapTy;
if (LoadTy->isHalfTy())
MapTy = Type::getInt16PtrTy(C->getContext(), AS);
else if (LoadTy->isFloatTy())
MapTy = Type::getInt32PtrTy(C->getContext(), AS);
else if (LoadTy->isDoubleTy())
MapTy = Type::getInt64PtrTy(C->getContext(), AS);
else if (LoadTy->isVectorTy()) {
MapTy = PointerType::getIntNPtrTy(C->getContext(),
TD.getTypeAllocSizeInBits(LoadTy),
AS);
} else
return nullptr;
C = FoldBitCast(C, MapTy, TD);
if (Constant *Res = FoldReinterpretLoadFromConstPtr(C, TD))
return FoldBitCast(Res, LoadTy, TD);
return nullptr;
}
unsigned BytesLoaded = (IntType->getBitWidth() + 7) / 8;
if (BytesLoaded > 32 || BytesLoaded == 0)
return nullptr;
GlobalValue *GVal;
APInt Offset;
if (!IsConstantOffsetFromGlobal(C, GVal, Offset, TD))
return nullptr;
GlobalVariable *GV = dyn_cast<GlobalVariable>(GVal);
if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer() ||
!GV->getInitializer()->getType()->isSized())
return nullptr;
// If we're loading off the beginning of the global, some bytes may be valid,
// but we don't try to handle this.
if (Offset.isNegative())
return nullptr;
// If we're not accessing anything in this constant, the result is undefined.
if (Offset.getZExtValue() >=
TD.getTypeAllocSize(GV->getInitializer()->getType()))
return UndefValue::get(IntType);
unsigned char RawBytes[32] = {0};
if (!ReadDataFromGlobal(GV->getInitializer(), Offset.getZExtValue(), RawBytes,
BytesLoaded, TD))
return nullptr;
APInt ResultVal = APInt(IntType->getBitWidth(), 0);
if (TD.isLittleEndian()) {
ResultVal = RawBytes[BytesLoaded - 1];
for (unsigned i = 1; i != BytesLoaded; ++i) {
ResultVal <<= 8;
ResultVal |= RawBytes[BytesLoaded - 1 - i];
}
} else {
ResultVal = RawBytes[0];
for (unsigned i = 1; i != BytesLoaded; ++i) {
ResultVal <<= 8;
ResultVal |= RawBytes[i];
}
}
return ConstantInt::get(IntType->getContext(), ResultVal);
}
static Constant *ConstantFoldLoadThroughBitcast(ConstantExpr *CE,
const DataLayout *DL) {
if (!DL)
return nullptr;
auto *DestPtrTy = dyn_cast<PointerType>(CE->getType());
if (!DestPtrTy)
return nullptr;
Type *DestTy = DestPtrTy->getElementType();
Constant *C = ConstantFoldLoadFromConstPtr(CE->getOperand(0), DL);
if (!C)
return nullptr;
do {
Type *SrcTy = C->getType();
// If the type sizes are the same and a cast is legal, just directly
// cast the constant.
if (DL->getTypeSizeInBits(DestTy) == DL->getTypeSizeInBits(SrcTy)) {
Instruction::CastOps Cast = Instruction::BitCast;
// If we are going from a pointer to int or vice versa, we spell the cast
// differently.
if (SrcTy->isIntegerTy() && DestTy->isPointerTy())
Cast = Instruction::IntToPtr;
else if (SrcTy->isPointerTy() && DestTy->isIntegerTy())
Cast = Instruction::PtrToInt;
if (CastInst::castIsValid(Cast, C, DestTy))
return ConstantExpr::getCast(Cast, C, DestTy);
}
// If this isn't an aggregate type, there is nothing we can do to drill down
// and find a bitcastable constant.
if (!SrcTy->isAggregateType())
return nullptr;
// We're simulating a load through a pointer that was bitcast to point to
// a different type, so we can try to walk down through the initial
// elements of an aggregate to see if some part of th e aggregate is
// castable to implement the "load" semantic model.
C = C->getAggregateElement(0u);
} while (C);
return nullptr;
}
/// ConstantFoldLoadFromConstPtr - Return the value that a load from C would
/// produce if it is constant and determinable. If this is not determinable,
/// return null.
Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C,
const DataLayout *TD) {
// First, try the easy cases:
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
if (GV->isConstant() && GV->hasDefinitiveInitializer())
return GV->getInitializer();
// If the loaded value isn't a constant expr, we can't handle it.
ConstantExpr *CE = dyn_cast<ConstantExpr>(C);
if (!CE)
return nullptr;
if (CE->getOpcode() == Instruction::GetElementPtr) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0))) {
if (GV->isConstant() && GV->hasDefinitiveInitializer()) {
if (Constant *V =
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE))
return V;
}
}
}
if (CE->getOpcode() == Instruction::BitCast)
if (Constant *LoadedC = ConstantFoldLoadThroughBitcast(CE, TD))
return LoadedC;
// Instead of loading constant c string, use corresponding integer value
// directly if string length is small enough.
StringRef Str;
if (TD && getConstantStringInfo(CE, Str) && !Str.empty()) {
unsigned StrLen = Str.size();
Type *Ty = cast<PointerType>(CE->getType())->getElementType();
unsigned NumBits = Ty->getPrimitiveSizeInBits();
// Replace load with immediate integer if the result is an integer or fp
// value.
if ((NumBits >> 3) == StrLen + 1 && (NumBits & 7) == 0 &&
(isa<IntegerType>(Ty) || Ty->isFloatingPointTy())) {
APInt StrVal(NumBits, 0);
APInt SingleChar(NumBits, 0);
if (TD->isLittleEndian()) {
for (signed i = StrLen-1; i >= 0; i--) {
SingleChar = (uint64_t) Str[i] & UCHAR_MAX;
StrVal = (StrVal << 8) | SingleChar;
}
} else {
for (unsigned i = 0; i < StrLen; i++) {
SingleChar = (uint64_t) Str[i] & UCHAR_MAX;
StrVal = (StrVal << 8) | SingleChar;
}
// Append NULL at the end.
SingleChar = 0;
StrVal = (StrVal << 8) | SingleChar;
}
Constant *Res = ConstantInt::get(CE->getContext(), StrVal);
if (Ty->isFloatingPointTy())
Res = ConstantExpr::getBitCast(Res, Ty);
return Res;
}
}
// If this load comes from anywhere in a constant global, and if the global
// is all undef or zero, we know what it loads.
if (GlobalVariable *GV =
dyn_cast<GlobalVariable>(GetUnderlyingObject(CE, TD))) {
if (GV->isConstant() && GV->hasDefinitiveInitializer()) {
Type *ResTy = cast<PointerType>(C->getType())->getElementType();
if (GV->getInitializer()->isNullValue())
return Constant::getNullValue(ResTy);
if (isa<UndefValue>(GV->getInitializer()))
return UndefValue::get(ResTy);
}
}
// Try hard to fold loads from bitcasted strange and non-type-safe things.
if (TD)
return FoldReinterpretLoadFromConstPtr(CE, *TD);
return nullptr;
}
static Constant *ConstantFoldLoadInst(const LoadInst *LI, const DataLayout *TD){
if (LI->isVolatile()) return nullptr;
if (Constant *C = dyn_cast<Constant>(LI->getOperand(0)))
return ConstantFoldLoadFromConstPtr(C, TD);
return nullptr;
}
/// SymbolicallyEvaluateBinop - One of Op0/Op1 is a constant expression.
/// Attempt to symbolically evaluate the result of a binary operator merging
/// these together. If target data info is available, it is provided as DL,
/// otherwise DL is null.
static Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0,
Constant *Op1, const DataLayout *DL){
// SROA
// Fold (and 0xffffffff00000000, (shl x, 32)) -> shl.
// Fold (lshr (or X, Y), 32) -> (lshr [X/Y], 32) if one doesn't contribute
// bits.
if (Opc == Instruction::And && DL) {
unsigned BitWidth = DL->getTypeSizeInBits(Op0->getType()->getScalarType());
APInt KnownZero0(BitWidth, 0), KnownOne0(BitWidth, 0);
APInt KnownZero1(BitWidth, 0), KnownOne1(BitWidth, 0);
computeKnownBits(Op0, KnownZero0, KnownOne0, DL);
computeKnownBits(Op1, KnownZero1, KnownOne1, DL);
if ((KnownOne1 | KnownZero0).isAllOnesValue()) {
// All the bits of Op0 that the 'and' could be masking are already zero.
return Op0;
}
if ((KnownOne0 | KnownZero1).isAllOnesValue()) {
// All the bits of Op1 that the 'and' could be masking are already zero.
return Op1;
}
APInt KnownZero = KnownZero0 | KnownZero1;
APInt KnownOne = KnownOne0 & KnownOne1;
if ((KnownZero | KnownOne).isAllOnesValue()) {
return ConstantInt::get(Op0->getType(), KnownOne);
}
}
// If the constant expr is something like &A[123] - &A[4].f, fold this into a
// constant. This happens frequently when iterating over a global array.
if (Opc == Instruction::Sub && DL) {
GlobalValue *GV1, *GV2;
APInt Offs1, Offs2;
if (IsConstantOffsetFromGlobal(Op0, GV1, Offs1, *DL))
if (IsConstantOffsetFromGlobal(Op1, GV2, Offs2, *DL) &&
GV1 == GV2) {
unsigned OpSize = DL->getTypeSizeInBits(Op0->getType());
// (&GV+C1) - (&GV+C2) -> C1-C2, pointer arithmetic cannot overflow.
// PtrToInt may change the bitwidth so we have convert to the right size
// first.
return ConstantInt::get(Op0->getType(), Offs1.zextOrTrunc(OpSize) -
Offs2.zextOrTrunc(OpSize));
}
}
return nullptr;
}
/// CastGEPIndices - If array indices are not pointer-sized integers,
/// explicitly cast them so that they aren't implicitly casted by the
/// getelementptr.
static Constant *CastGEPIndices(ArrayRef<Constant *> Ops,
Type *ResultTy, const DataLayout *TD,
const TargetLibraryInfo *TLI) {
if (!TD)
return nullptr;
Type *IntPtrTy = TD->getIntPtrType(ResultTy);
bool Any = false;
SmallVector<Constant*, 32> NewIdxs;
for (unsigned i = 1, e = Ops.size(); i != e; ++i) {
if ((i == 1 ||
!isa<StructType>(GetElementPtrInst::getIndexedType(
Ops[0]->getType(),
Ops.slice(1, i - 1)))) &&
Ops[i]->getType() != IntPtrTy) {
Any = true;
NewIdxs.push_back(ConstantExpr::getCast(CastInst::getCastOpcode(Ops[i],
true,
IntPtrTy,
true),
Ops[i], IntPtrTy));
} else
NewIdxs.push_back(Ops[i]);
}
if (!Any)
return nullptr;
Constant *C = ConstantExpr::getGetElementPtr(Ops[0], NewIdxs);
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
if (Constant *Folded = ConstantFoldConstantExpression(CE, TD, TLI))
C = Folded;
}
return C;
}
/// Strip the pointer casts, but preserve the address space information.
static Constant* StripPtrCastKeepAS(Constant* Ptr) {
assert(Ptr->getType()->isPointerTy() && "Not a pointer type");
PointerType *OldPtrTy = cast<PointerType>(Ptr->getType());
Ptr = Ptr->stripPointerCasts();
PointerType *NewPtrTy = cast<PointerType>(Ptr->getType());
// Preserve the address space number of the pointer.
if (NewPtrTy->getAddressSpace() != OldPtrTy->getAddressSpace()) {
NewPtrTy = NewPtrTy->getElementType()->getPointerTo(
OldPtrTy->getAddressSpace());
Ptr = ConstantExpr::getPointerCast(Ptr, NewPtrTy);
}
return Ptr;
}
/// SymbolicallyEvaluateGEP - If we can symbolically evaluate the specified GEP
/// constant expression, do so.
static Constant *SymbolicallyEvaluateGEP(ArrayRef<Constant *> Ops,
Type *ResultTy, const DataLayout *TD,
const TargetLibraryInfo *TLI) {
Constant *Ptr = Ops[0];
if (!TD || !Ptr->getType()->getPointerElementType()->isSized() ||
!Ptr->getType()->isPointerTy())
return nullptr;
Type *IntPtrTy = TD->getIntPtrType(Ptr->getType());
Type *ResultElementTy = ResultTy->getPointerElementType();
// If this is a constant expr gep that is effectively computing an
// "offsetof", fold it into 'cast int Size to T*' instead of 'gep 0, 0, 12'
for (unsigned i = 1, e = Ops.size(); i != e; ++i)
if (!isa<ConstantInt>(Ops[i])) {
// If this is "gep i8* Ptr, (sub 0, V)", fold this as:
// "inttoptr (sub (ptrtoint Ptr), V)"
if (Ops.size() == 2 && ResultElementTy->isIntegerTy(8)) {
ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[1]);
assert((!CE || CE->getType() == IntPtrTy) &&
"CastGEPIndices didn't canonicalize index types!");
if (CE && CE->getOpcode() == Instruction::Sub &&
CE->getOperand(0)->isNullValue()) {
Constant *Res = ConstantExpr::getPtrToInt(Ptr, CE->getType());
Res = ConstantExpr::getSub(Res, CE->getOperand(1));
Res = ConstantExpr::getIntToPtr(Res, ResultTy);
if (ConstantExpr *ResCE = dyn_cast<ConstantExpr>(Res))
Res = ConstantFoldConstantExpression(ResCE, TD, TLI);
return Res;
}
}
return nullptr;
}
unsigned BitWidth = TD->getTypeSizeInBits(IntPtrTy);
APInt Offset =
APInt(BitWidth, TD->getIndexedOffset(Ptr->getType(),
makeArrayRef((Value *const*)
Ops.data() + 1,
Ops.size() - 1)));
Ptr = StripPtrCastKeepAS(Ptr);
// If this is a GEP of a GEP, fold it all into a single GEP.
while (GEPOperator *GEP = dyn_cast<GEPOperator>(Ptr)) {
SmallVector<Value *, 4> NestedOps(GEP->op_begin() + 1, GEP->op_end());
// Do not try the incorporate the sub-GEP if some index is not a number.
bool AllConstantInt = true;
for (unsigned i = 0, e = NestedOps.size(); i != e; ++i)
if (!isa<ConstantInt>(NestedOps[i])) {
AllConstantInt = false;
break;
}
if (!AllConstantInt)
break;
Ptr = cast<Constant>(GEP->getOperand(0));
Offset += APInt(BitWidth,
TD->getIndexedOffset(Ptr->getType(), NestedOps));
Ptr = StripPtrCastKeepAS(Ptr);
}
// If the base value for this address is a literal integer value, fold the
// getelementptr to the resulting integer value casted to the pointer type.
APInt BasePtr(BitWidth, 0);
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr)) {
if (CE->getOpcode() == Instruction::IntToPtr) {
if (ConstantInt *Base = dyn_cast<ConstantInt>(CE->getOperand(0)))
BasePtr = Base->getValue().zextOrTrunc(BitWidth);
}
}
if (Ptr->isNullValue() || BasePtr != 0) {
Constant *C = ConstantInt::get(Ptr->getContext(), Offset + BasePtr);
return ConstantExpr::getIntToPtr(C, ResultTy);
}
// Otherwise form a regular getelementptr. Recompute the indices so that
// we eliminate over-indexing of the notional static type array bounds.
// This makes it easy to determine if the getelementptr is "inbounds".
// Also, this helps GlobalOpt do SROA on GlobalVariables.
Type *Ty = Ptr->getType();
assert(Ty->isPointerTy() && "Forming regular GEP of non-pointer type");
SmallVector<Constant *, 32> NewIdxs;
do {
if (SequentialType *ATy = dyn_cast<SequentialType>(Ty)) {
if (ATy->isPointerTy()) {
// The only pointer indexing we'll do is on the first index of the GEP.
if (!NewIdxs.empty())
break;
// Only handle pointers to sized types, not pointers to functions.
if (!ATy->getElementType()->isSized())
return nullptr;
}
// Determine which element of the array the offset points into.
APInt ElemSize(BitWidth, TD->getTypeAllocSize(ATy->getElementType()));
if (ElemSize == 0)
// The element size is 0. This may be [0 x Ty]*, so just use a zero
// index for this level and proceed to the next level to see if it can
// accommodate the offset.
NewIdxs.push_back(ConstantInt::get(IntPtrTy, 0));
else {
// The element size is non-zero divide the offset by the element
// size (rounding down), to compute the index at this level.
APInt NewIdx = Offset.udiv(ElemSize);
Offset -= NewIdx * ElemSize;
NewIdxs.push_back(ConstantInt::get(IntPtrTy, NewIdx));
}
Ty = ATy->getElementType();
} else if (StructType *STy = dyn_cast<StructType>(Ty)) {
// If we end up with an offset that isn't valid for this struct type, we
// can't re-form this GEP in a regular form, so bail out. The pointer
// operand likely went through casts that are necessary to make the GEP
// sensible.
const StructLayout &SL = *TD->getStructLayout(STy);
if (Offset.uge(SL.getSizeInBytes()))
break;
// Determine which field of the struct the offset points into. The
// getZExtValue is fine as we've already ensured that the offset is
// within the range representable by the StructLayout API.
unsigned ElIdx = SL.getElementContainingOffset(Offset.getZExtValue());
NewIdxs.push_back(ConstantInt::get(Type::getInt32Ty(Ty->getContext()),
ElIdx));
Offset -= APInt(BitWidth, SL.getElementOffset(ElIdx));
Ty = STy->getTypeAtIndex(ElIdx);
} else {
// We've reached some non-indexable type.
break;
}
} while (Ty != ResultElementTy);
// If we haven't used up the entire offset by descending the static
// type, then the offset is pointing into the middle of an indivisible
// member, so we can't simplify it.
if (Offset != 0)
return nullptr;
// Create a GEP.
Constant *C = ConstantExpr::getGetElementPtr(Ptr, NewIdxs);
assert(C->getType()->getPointerElementType() == Ty &&
"Computed GetElementPtr has unexpected type!");
// If we ended up indexing a member with a type that doesn't match
// the type of what the original indices indexed, add a cast.
if (Ty != ResultElementTy)
C = FoldBitCast(C, ResultTy, *TD);
return C;
}
//===----------------------------------------------------------------------===//
// Constant Folding public APIs
//===----------------------------------------------------------------------===//
/// ConstantFoldInstruction - Try to constant fold the specified instruction.
/// If successful, the constant result is returned, if not, null is returned.
/// Note that this fails if not all of the operands are constant. Otherwise,
/// this function can only fail when attempting to fold instructions like loads
/// and stores, which have no constant expression form.
Constant *llvm::ConstantFoldInstruction(Instruction *I,
const DataLayout *TD,
const TargetLibraryInfo *TLI) {
// Handle PHI nodes quickly here...
if (PHINode *PN = dyn_cast<PHINode>(I)) {
Constant *CommonValue = nullptr;
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
Value *Incoming = PN->getIncomingValue(i);
// If the incoming value is undef then skip it. Note that while we could
// skip the value if it is equal to the phi node itself we choose not to
// because that would break the rule that constant folding only applies if
// all operands are constants.
if (isa<UndefValue>(Incoming))
continue;
// If the incoming value is not a constant, then give up.
Constant *C = dyn_cast<Constant>(Incoming);
if (!C)
return nullptr;
// Fold the PHI's operands.
if (ConstantExpr *NewC = dyn_cast<ConstantExpr>(C))
C = ConstantFoldConstantExpression(NewC, TD, TLI);
// If the incoming value is a different constant to
// the one we saw previously, then give up.
if (CommonValue && C != CommonValue)
return nullptr;
CommonValue = C;
}
// If we reach here, all incoming values are the same constant or undef.
return CommonValue ? CommonValue : UndefValue::get(PN->getType());
}
// Scan the operand list, checking to see if they are all constants, if so,
// hand off to ConstantFoldInstOperands.
SmallVector<Constant*, 8> Ops;
for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) {
Constant *Op = dyn_cast<Constant>(*i);
if (!Op)
return nullptr; // All operands not constant!
// Fold the Instruction's operands.
if (ConstantExpr *NewCE = dyn_cast<ConstantExpr>(Op))
Op = ConstantFoldConstantExpression(NewCE, TD, TLI);
Ops.push_back(Op);
}
if (const CmpInst *CI = dyn_cast<CmpInst>(I))
return ConstantFoldCompareInstOperands(CI->getPredicate(), Ops[0], Ops[1],
TD, TLI);
if (const LoadInst *LI = dyn_cast<LoadInst>(I))
return ConstantFoldLoadInst(LI, TD);
if (InsertValueInst *IVI = dyn_cast<InsertValueInst>(I)) {
return ConstantExpr::getInsertValue(
cast<Constant>(IVI->getAggregateOperand()),
cast<Constant>(IVI->getInsertedValueOperand()),
IVI->getIndices());
}
if (ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(I)) {
return ConstantExpr::getExtractValue(
cast<Constant>(EVI->getAggregateOperand()),
EVI->getIndices());
}
return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Ops, TD, TLI);
}
static Constant *
ConstantFoldConstantExpressionImpl(const ConstantExpr *CE, const DataLayout *TD,
const TargetLibraryInfo *TLI,
SmallPtrSet<ConstantExpr *, 4> &FoldedOps) {
SmallVector<Constant *, 8> Ops;
for (User::const_op_iterator i = CE->op_begin(), e = CE->op_end(); i != e;
++i) {
Constant *NewC = cast<Constant>(*i);
// Recursively fold the ConstantExpr's operands. If we have already folded
// a ConstantExpr, we don't have to process it again.
if (ConstantExpr *NewCE = dyn_cast<ConstantExpr>(NewC)) {
if (FoldedOps.insert(NewCE))
NewC = ConstantFoldConstantExpressionImpl(NewCE, TD, TLI, FoldedOps);
}
Ops.push_back(NewC);
}
if (CE->isCompare())
return ConstantFoldCompareInstOperands(CE->getPredicate(), Ops[0], Ops[1],
TD, TLI);
return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(), Ops, TD, TLI);
}
/// ConstantFoldConstantExpression - Attempt to fold the constant expression
/// using the specified DataLayout. If successful, the constant result is
/// result is returned, if not, null is returned.
Constant *llvm::ConstantFoldConstantExpression(const ConstantExpr *CE,
const DataLayout *TD,
const TargetLibraryInfo *TLI) {
SmallPtrSet<ConstantExpr *, 4> FoldedOps;
return ConstantFoldConstantExpressionImpl(CE, TD, TLI, FoldedOps);
}
/// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
/// specified opcode and operands. If successful, the constant result is
/// returned, if not, null is returned. Note that this function can fail when
/// attempting to fold instructions like loads and stores, which have no
/// constant expression form.
///
/// TODO: This function neither utilizes nor preserves nsw/nuw/inbounds/etc
/// information, due to only being passed an opcode and operands. Constant
/// folding using this function strips this information.
///
Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
ArrayRef<Constant *> Ops,
const DataLayout *TD,
const TargetLibraryInfo *TLI) {
// Handle easy binops first.
if (Instruction::isBinaryOp(Opcode)) {
if (isa<ConstantExpr>(Ops[0]) || isa<ConstantExpr>(Ops[1])) {
if (Constant *C = SymbolicallyEvaluateBinop(Opcode, Ops[0], Ops[1], TD))
return C;
}
return ConstantExpr::get(Opcode, Ops[0], Ops[1]);
}
switch (Opcode) {
default: return nullptr;
case Instruction::ICmp:
case Instruction::FCmp: llvm_unreachable("Invalid for compares");
case Instruction::Call:
if (Function *F = dyn_cast<Function>(Ops.back()))
if (canConstantFoldCallTo(F))
return ConstantFoldCall(F, Ops.slice(0, Ops.size() - 1), TLI);
return nullptr;
case Instruction::PtrToInt:
// If the input is a inttoptr, eliminate the pair. This requires knowing
// the width of a pointer, so it can't be done in ConstantExpr::getCast.
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[0])) {
if (TD && CE->getOpcode() == Instruction::IntToPtr) {
Constant *Input = CE->getOperand(0);
unsigned InWidth = Input->getType()->getScalarSizeInBits();
unsigned PtrWidth = TD->getPointerTypeSizeInBits(CE->getType());
if (PtrWidth < InWidth) {
Constant *Mask =
ConstantInt::get(CE->getContext(),
APInt::getLowBitsSet(InWidth, PtrWidth));
Input = ConstantExpr::getAnd(Input, Mask);
}
// Do a zext or trunc to get to the dest size.
return ConstantExpr::getIntegerCast(Input, DestTy, false);
}
}
return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
case Instruction::IntToPtr:
// If the input is a ptrtoint, turn the pair into a ptr to ptr bitcast if
// the int size is >= the ptr size and the address spaces are the same.
// This requires knowing the width of a pointer, so it can't be done in
// ConstantExpr::getCast.
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[0])) {
if (TD && CE->getOpcode() == Instruction::PtrToInt) {
Constant *SrcPtr = CE->getOperand(0);
unsigned SrcPtrSize = TD->getPointerTypeSizeInBits(SrcPtr->getType());
unsigned MidIntSize = CE->getType()->getScalarSizeInBits();
if (MidIntSize >= SrcPtrSize) {
unsigned SrcAS = SrcPtr->getType()->getPointerAddressSpace();
if (SrcAS == DestTy->getPointerAddressSpace())
return FoldBitCast(CE->getOperand(0), DestTy, *TD);
}
}
}
return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
case Instruction::Trunc:
case Instruction::ZExt:
case Instruction::SExt:
case Instruction::FPTrunc:
case Instruction::FPExt:
case Instruction::UIToFP:
case Instruction::SIToFP:
case Instruction::FPToUI:
case Instruction::FPToSI:
case Instruction::AddrSpaceCast:
return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
case Instruction::BitCast:
if (TD)
return FoldBitCast(Ops[0], DestTy, *TD);
return ConstantExpr::getBitCast(Ops[0], DestTy);
case Instruction::Select:
return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2]);
case Instruction::ExtractElement:
return ConstantExpr::getExtractElement(Ops[0], Ops[1]);
case Instruction::InsertElement:
return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
case Instruction::ShuffleVector:
return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
case Instruction::GetElementPtr:
if (Constant *C = CastGEPIndices(Ops, DestTy, TD, TLI))
return C;
if (Constant *C = SymbolicallyEvaluateGEP(Ops, DestTy, TD, TLI))
return C;
return ConstantExpr::getGetElementPtr(Ops[0], Ops.slice(1));
}
}
/// ConstantFoldCompareInstOperands - Attempt to constant fold a compare
/// instruction (icmp/fcmp) with the specified operands. If it fails, it
/// returns a constant expression of the specified operands.
///
Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate,
Constant *Ops0, Constant *Ops1,
const DataLayout *TD,
const TargetLibraryInfo *TLI) {
// fold: icmp (inttoptr x), null -> icmp x, 0
// fold: icmp (ptrtoint x), 0 -> icmp x, null
// fold: icmp (inttoptr x), (inttoptr y) -> icmp trunc/zext x, trunc/zext y
// fold: icmp (ptrtoint x), (ptrtoint y) -> icmp x, y
//
// ConstantExpr::getCompare cannot do this, because it doesn't have TD
// around to know if bit truncation is happening.
if (ConstantExpr *CE0 = dyn_cast<ConstantExpr>(Ops0)) {
if (TD && Ops1->isNullValue()) {
if (CE0->getOpcode() == Instruction::IntToPtr) {
Type *IntPtrTy = TD->getIntPtrType(CE0->getType());
// Convert the integer value to the right size to ensure we get the
// proper extension or truncation.
Constant *C = ConstantExpr::getIntegerCast(CE0->getOperand(0),
IntPtrTy, false);
Constant *Null = Constant::getNullValue(C->getType());
return ConstantFoldCompareInstOperands(Predicate, C, Null, TD, TLI);
}
// Only do this transformation if the int is intptrty in size, otherwise
// there is a truncation or extension that we aren't modeling.
if (CE0->getOpcode() == Instruction::PtrToInt) {
Type *IntPtrTy = TD->getIntPtrType(CE0->getOperand(0)->getType());
if (CE0->getType() == IntPtrTy) {
Constant *C = CE0->getOperand(0);
Constant *Null = Constant::getNullValue(C->getType());
return ConstantFoldCompareInstOperands(Predicate, C, Null, TD, TLI);
}
}
}
if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(Ops1)) {
if (TD && CE0->getOpcode() == CE1->getOpcode()) {
if (CE0->getOpcode() == Instruction::IntToPtr) {
Type *IntPtrTy = TD->getIntPtrType(CE0->getType());
// Convert the integer value to the right size to ensure we get the
// proper extension or truncation.
Constant *C0 = ConstantExpr::getIntegerCast(CE0->getOperand(0),
IntPtrTy, false);
Constant *C1 = ConstantExpr::getIntegerCast(CE1->getOperand(0),
IntPtrTy, false);
return ConstantFoldCompareInstOperands(Predicate, C0, C1, TD, TLI);
}
// Only do this transformation if the int is intptrty in size, otherwise
// there is a truncation or extension that we aren't modeling.
if (CE0->getOpcode() == Instruction::PtrToInt) {
Type *IntPtrTy = TD->getIntPtrType(CE0->getOperand(0)->getType());
if (CE0->getType() == IntPtrTy &&
CE0->getOperand(0)->getType() == CE1->getOperand(0)->getType()) {
return ConstantFoldCompareInstOperands(Predicate,
CE0->getOperand(0),
CE1->getOperand(0),
TD,
TLI);
}
}
}
}
// icmp eq (or x, y), 0 -> (icmp eq x, 0) & (icmp eq y, 0)
// icmp ne (or x, y), 0 -> (icmp ne x, 0) | (icmp ne y, 0)
if ((Predicate == ICmpInst::ICMP_EQ || Predicate == ICmpInst::ICMP_NE) &&
CE0->getOpcode() == Instruction::Or && Ops1->isNullValue()) {
Constant *LHS =
ConstantFoldCompareInstOperands(Predicate, CE0->getOperand(0), Ops1,
TD, TLI);
Constant *RHS =
ConstantFoldCompareInstOperands(Predicate, CE0->getOperand(1), Ops1,
TD, TLI);
unsigned OpC =
Predicate == ICmpInst::ICMP_EQ ? Instruction::And : Instruction::Or;
Constant *Ops[] = { LHS, RHS };
return ConstantFoldInstOperands(OpC, LHS->getType(), Ops, TD, TLI);
}
}
return ConstantExpr::getCompare(Predicate, Ops0, Ops1);
}
/// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a
/// getelementptr constantexpr, return the constant value being addressed by the
/// constant expression, or null if something is funny and we can't decide.
Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
ConstantExpr *CE) {
if (!CE->getOperand(1)->isNullValue())
return nullptr; // Do not allow stepping over the value!
// Loop over all of the operands, tracking down which value we are
// addressing.
for (unsigned i = 2, e = CE->getNumOperands(); i != e; ++i) {
C = C->getAggregateElement(CE->getOperand(i));
if (!C)
return nullptr;
}
return C;
}
/// ConstantFoldLoadThroughGEPIndices - Given a constant and getelementptr
/// indices (with an *implied* zero pointer index that is not in the list),
/// return the constant value being addressed by a virtual load, or null if
/// something is funny and we can't decide.
Constant *llvm::ConstantFoldLoadThroughGEPIndices(Constant *C,
ArrayRef<Constant*> Indices) {
// Loop over all of the operands, tracking down which value we are
// addressing.
for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
C = C->getAggregateElement(Indices[i]);
if (!C)
return nullptr;
}
return C;
}
//===----------------------------------------------------------------------===//
// Constant Folding for Calls
//
/// canConstantFoldCallTo - Return true if its even possible to fold a call to
/// the specified function.
bool llvm::canConstantFoldCallTo(const Function *F) {
switch (unsigned IID = F->getIntrinsicID()) {
case Intrinsic::fabs:
case Intrinsic::log:
case Intrinsic::log2:
case Intrinsic::log10:
case Intrinsic::exp:
case Intrinsic::exp2:
case Intrinsic::floor:
case Intrinsic::ceil:
case Intrinsic::sqrt:
case Intrinsic::pow:
case Intrinsic::powi:
case Intrinsic::bswap:
case Intrinsic::ctpop:
case Intrinsic::ctlz:
case Intrinsic::cttz:
case Intrinsic::fma:
case Intrinsic::fmuladd:
case Intrinsic::copysign:
case Intrinsic::round:
case Intrinsic::sadd_with_overflow:
case Intrinsic::uadd_with_overflow:
case Intrinsic::ssub_with_overflow:
case Intrinsic::usub_with_overflow:
case Intrinsic::smul_with_overflow:
case Intrinsic::umul_with_overflow:
case Intrinsic::convert_from_fp16:
case Intrinsic::convert_to_fp16:
case Intrinsic::x86_sse_cvtss2si:
case Intrinsic::x86_sse_cvtss2si64:
case Intrinsic::x86_sse_cvttss2si:
case Intrinsic::x86_sse_cvttss2si64:
case Intrinsic::x86_sse2_cvtsd2si:
case Intrinsic::x86_sse2_cvtsd2si64:
case Intrinsic::x86_sse2_cvttsd2si:
case Intrinsic::x86_sse2_cvttsd2si64:
return true;
default:
// This comparison uses the start and end markers of the genx intrinsic enum
// values, relying on tablegen outputting the intrinsics in sorted by name
// order.
if ((unsigned)(IID - Intrinsic::genx_aaaabegin)
<= (Intrinsic::genx_zzzzend - Intrinsic::genx_aaaabegin))
return canConstantFoldGenXIntrinsic(IID);
return false;
case 0: break;
}
if (!F->hasName())
return false;
StringRef Name = F->getName();
// In these cases, the check of the length is required. We don't want to
// return true for a name like "cos\0blah" which strcmp would return equal to
// "cos", but has length 8.
switch (Name[0]) {
default: return false;
case 'a':
return Name == "acos" || Name == "asin" || Name == "atan" || Name =="atan2";
case 'c':
return Name == "cos" || Name == "ceil" || Name == "cosf" || Name == "cosh";
case 'e':
return Name == "exp" || Name == "exp2";
case 'f':
return Name == "fabs" || Name == "fmod" || Name == "floor";
case 'l':
return Name == "log" || Name == "log10";
case 'p':
return Name == "pow";
case 's':
return Name == "sin" || Name == "sinh" || Name == "sqrt" ||
Name == "sinf" || Name == "sqrtf";
case 't':
return Name == "tan" || Name == "tanh";
}
}
static Constant *GetConstantFoldFPValue(double V, Type *Ty) {
if (Ty->isHalfTy()) {
APFloat APF(V);
bool unused;
APF.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven, &unused);
return ConstantFP::get(Ty->getContext(), APF);
}
if (Ty->isFloatTy())
return ConstantFP::get(Ty->getContext(), APFloat((float)V));
if (Ty->isDoubleTy())
return ConstantFP::get(Ty->getContext(), APFloat(V));
llvm_unreachable("Can only constant fold half/float/double");
}
namespace {
/// llvm_fenv_clearexcept - Clear the floating-point exception state.
static inline void llvm_fenv_clearexcept() {
#if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT
feclearexcept(FE_ALL_EXCEPT);
#endif
errno = 0;
}
/// llvm_fenv_testexcept - Test if a floating-point exception was raised.
static inline bool llvm_fenv_testexcept() {
int errno_val = errno;
if (errno_val == ERANGE || errno_val == EDOM)
return true;
#if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT && HAVE_DECL_FE_INEXACT
if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
return true;
#endif
return false;
}
} // End namespace
static Constant *ConstantFoldFP(double (*NativeFP)(double), double V,
Type *Ty) {
llvm_fenv_clearexcept();
V = NativeFP(V);
if (llvm_fenv_testexcept()) {
llvm_fenv_clearexcept();
return nullptr;
}
return GetConstantFoldFPValue(V, Ty);
}
static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double),
double V, double W, Type *Ty) {
llvm_fenv_clearexcept();
V = NativeFP(V, W);
if (llvm_fenv_testexcept()) {
llvm_fenv_clearexcept();
return nullptr;
}
return GetConstantFoldFPValue(V, Ty);
}
/// ConstantFoldConvertToInt - Attempt to an SSE floating point to integer
/// conversion of a constant floating point. If roundTowardZero is false, the
/// default IEEE rounding is used (toward nearest, ties to even). This matches
/// the behavior of the non-truncating SSE instructions in the default rounding
/// mode. The desired integer type Ty is used to select how many bits are
/// available for the result. Returns null if the conversion cannot be
/// performed, otherwise returns the Constant value resulting from the
/// conversion.
static Constant *ConstantFoldConvertToInt(const APFloat &Val,
bool roundTowardZero, Type *Ty) {
// All of these conversion intrinsics form an integer of at most 64bits.
unsigned ResultWidth = Ty->getIntegerBitWidth();
assert(ResultWidth <= 64 &&
"Can only constant fold conversions to 64 and 32 bit ints");
uint64_t UIntVal;
bool isExact = false;
APFloat::roundingMode mode = roundTowardZero? APFloat::rmTowardZero
: APFloat::rmNearestTiesToEven;
APFloat::opStatus status = Val.convertToInteger(&UIntVal, ResultWidth,
/*isSigned=*/true, mode,
&isExact);
if (status != APFloat::opOK && status != APFloat::opInexact)
return nullptr;
return ConstantInt::get(Ty, UIntVal, /*isSigned=*/true);
}
static double getValueAsDouble(ConstantFP *Op) {
Type *Ty = Op->getType();
if (Ty->isFloatTy())
return Op->getValueAPF().convertToFloat();
if (Ty->isDoubleTy())
return Op->getValueAPF().convertToDouble();
bool unused;
APFloat APF = Op->getValueAPF();
APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &unused);
return APF.convertToDouble();
}
static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID,
Type *Ty, ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI) {
if (Operands.size() == 1) {
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
if (IntrinsicID == Intrinsic::convert_to_fp16) {
APFloat Val(Op->getValueAPF());
bool lost = false;
Val.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven, &lost);
return ConstantInt::get(Ty->getContext(), Val.bitcastToAPInt());
}
if (!Ty->isHalfTy() && !Ty->isFloatTy() && !Ty->isDoubleTy())
return nullptr;
if (IntrinsicID == Intrinsic::round) {
APFloat V = Op->getValueAPF();
V.roundToIntegral(APFloat::rmNearestTiesToAway);
return ConstantFP::get(Ty->getContext(), V);
}
/// We only fold functions with finite arguments. Folding NaN and inf is
/// likely to be aborted with an exception anyway, and some host libms
/// have known errors raising exceptions.
if (Op->getValueAPF().isNaN() || Op->getValueAPF().isInfinity())
return nullptr;
/// Currently APFloat versions of these functions do not exist, so we use
/// the host native double versions. Float versions are not called
/// directly but for all these it is true (float)(f((double)arg)) ==
/// f(arg). Long double not supported yet.
double V = getValueAsDouble(Op);
switch (IntrinsicID) {
default: break;
case Intrinsic::fabs:
return ConstantFoldFP(fabs, V, Ty);
#if HAVE_LOG2
case Intrinsic::log2:
return ConstantFoldFP(log2, V, Ty);
#endif
#if HAVE_LOG
case Intrinsic::log:
return ConstantFoldFP(log, V, Ty);
#endif
#if HAVE_LOG10
case Intrinsic::log10:
return ConstantFoldFP(log10, V, Ty);
#endif
#if HAVE_EXP
case Intrinsic::exp:
return ConstantFoldFP(exp, V, Ty);
#endif
#if HAVE_EXP2
case Intrinsic::exp2:
return ConstantFoldFP(exp2, V, Ty);
#endif
case Intrinsic::floor:
return ConstantFoldFP(floor, V, Ty);
case Intrinsic::ceil:
return ConstantFoldFP(ceil, V, Ty);
}
if (!TLI)
return nullptr;
switch (Name[0]) {
case 'a':
if (Name == "acos" && TLI->has(LibFunc::acos))
return ConstantFoldFP(acos, V, Ty);
else if (Name == "asin" && TLI->has(LibFunc::asin))
return ConstantFoldFP(asin, V, Ty);
else if (Name == "atan" && TLI->has(LibFunc::atan))
return ConstantFoldFP(atan, V, Ty);
break;
case 'c':
if (Name == "ceil" && TLI->has(LibFunc::ceil))
return ConstantFoldFP(ceil, V, Ty);
else if (Name == "cos" && TLI->has(LibFunc::cos))
return ConstantFoldFP(cos, V, Ty);
else if (Name == "cosh" && TLI->has(LibFunc::cosh))
return ConstantFoldFP(cosh, V, Ty);
else if (Name == "cosf" && TLI->has(LibFunc::cosf))
return ConstantFoldFP(cos, V, Ty);
break;
case 'e':
if (Name == "exp" && TLI->has(LibFunc::exp))
return ConstantFoldFP(exp, V, Ty);
if (Name == "exp2" && TLI->has(LibFunc::exp2)) {
// Constant fold exp2(x) as pow(2,x) in case the host doesn't have a
// C99 library.
return ConstantFoldBinaryFP(pow, 2.0, V, Ty);
}
break;
case 'f':
if (Name == "fabs" && TLI->has(LibFunc::fabs))
return ConstantFoldFP(fabs, V, Ty);
else if (Name == "floor" && TLI->has(LibFunc::floor))
return ConstantFoldFP(floor, V, Ty);
break;
case 'l':
if (Name == "log" && V > 0 && TLI->has(LibFunc::log))
return ConstantFoldFP(log, V, Ty);
else if (Name == "log10" && V > 0 && TLI->has(LibFunc::log10))
return ConstantFoldFP(log10, V, Ty);
else if (IntrinsicID == Intrinsic::sqrt &&
(Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy())) {
if (V >= -0.0)
return ConstantFoldFP(sqrt, V, Ty);
else // Undefined
return Constant::getNullValue(Ty);
}
break;
case 's':
if (Name == "sin" && TLI->has(LibFunc::sin))
return ConstantFoldFP(sin, V, Ty);
else if (Name == "sinh" && TLI->has(LibFunc::sinh))
return ConstantFoldFP(sinh, V, Ty);
else if (Name == "sqrt" && V >= 0 && TLI->has(LibFunc::sqrt))
return ConstantFoldFP(sqrt, V, Ty);
else if (Name == "sqrtf" && V >= 0 && TLI->has(LibFunc::sqrtf))
return ConstantFoldFP(sqrt, V, Ty);
else if (Name == "sinf" && TLI->has(LibFunc::sinf))
return ConstantFoldFP(sin, V, Ty);
break;
case 't':
if (Name == "tan" && TLI->has(LibFunc::tan))
return ConstantFoldFP(tan, V, Ty);
else if (Name == "tanh" && TLI->has(LibFunc::tanh))
return ConstantFoldFP(tanh, V, Ty);
break;
default:
break;
}
return nullptr;
}
if (ConstantInt *Op = dyn_cast<ConstantInt>(Operands[0])) {
switch (IntrinsicID) {
case Intrinsic::bswap:
return ConstantInt::get(Ty->getContext(), Op->getValue().byteSwap());
case Intrinsic::ctpop:
return ConstantInt::get(Ty, Op->getValue().countPopulation());
case Intrinsic::convert_from_fp16: {
APFloat Val(APFloat::IEEEhalf, Op->getValue());
bool lost = false;
APFloat::opStatus status =
Val.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &lost);
// Conversion is always precise.
(void)status;
assert(status == APFloat::opOK && !lost &&
"Precision lost during fp16 constfolding");
return ConstantFP::get(Ty->getContext(), Val);
}
default:
return nullptr;
}
}
// Support ConstantVector in case we have an Undef in the top.
if (isa<ConstantVector>(Operands[0]) ||
isa<ConstantDataVector>(Operands[0])) {
Constant *Op = cast<Constant>(Operands[0]);
switch (IntrinsicID) {
default: break;
case Intrinsic::x86_sse_cvtss2si:
case Intrinsic::x86_sse_cvtss2si64:
case Intrinsic::x86_sse2_cvtsd2si:
case Intrinsic::x86_sse2_cvtsd2si64:
if (ConstantFP *FPOp =
dyn_cast_or_null<ConstantFP>(Op->getAggregateElement(0U)))
return ConstantFoldConvertToInt(FPOp->getValueAPF(),
/*roundTowardZero=*/false, Ty);
case Intrinsic::x86_sse_cvttss2si:
case Intrinsic::x86_sse_cvttss2si64:
case Intrinsic::x86_sse2_cvttsd2si:
case Intrinsic::x86_sse2_cvttsd2si64:
if (ConstantFP *FPOp =
dyn_cast_or_null<ConstantFP>(Op->getAggregateElement(0U)))
return ConstantFoldConvertToInt(FPOp->getValueAPF(),
/*roundTowardZero=*/true, Ty);
}
}
if (isa<UndefValue>(Operands[0])) {
if (IntrinsicID == Intrinsic::bswap)
return Operands[0];
return nullptr;
}
return nullptr;
}
if (Operands.size() == 2) {
if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
if (!Ty->isHalfTy() && !Ty->isFloatTy() && !Ty->isDoubleTy())
return nullptr;
double Op1V = getValueAsDouble(Op1);
if (ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) {
if (Op2->getType() != Op1->getType())
return nullptr;
double Op2V = getValueAsDouble(Op2);
if (IntrinsicID == Intrinsic::pow) {
return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty);
}
if (IntrinsicID == Intrinsic::copysign) {
APFloat V1 = Op1->getValueAPF();
APFloat V2 = Op2->getValueAPF();
V1.copySign(V2);
return ConstantFP::get(Ty->getContext(), V1);
}
if (!TLI)
return nullptr;
if (Name == "pow" && TLI->has(LibFunc::pow))
return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty);
if (Name == "fmod" && TLI->has(LibFunc::fmod))
return ConstantFoldBinaryFP(fmod, Op1V, Op2V, Ty);
if (Name == "atan2" && TLI->has(LibFunc::atan2))
return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty);
} else if (ConstantInt *Op2C = dyn_cast<ConstantInt>(Operands[1])) {
if (IntrinsicID == Intrinsic::powi && Ty->isHalfTy())
return ConstantFP::get(Ty->getContext(),
APFloat((float)std::pow((float)Op1V,
(int)Op2C->getZExtValue())));
if (IntrinsicID == Intrinsic::powi && Ty->isFloatTy())
return ConstantFP::get(Ty->getContext(),
APFloat((float)std::pow((float)Op1V,
(int)Op2C->getZExtValue())));
if (IntrinsicID == Intrinsic::powi && Ty->isDoubleTy())
return ConstantFP::get(Ty->getContext(),
APFloat((double)std::pow((double)Op1V,
(int)Op2C->getZExtValue())));
}
return nullptr;
}
if (ConstantInt *Op1 = dyn_cast<ConstantInt>(Operands[0])) {
if (ConstantInt *Op2 = dyn_cast<ConstantInt>(Operands[1])) {
switch (IntrinsicID) {
default: break;
case Intrinsic::sadd_with_overflow:
case Intrinsic::uadd_with_overflow:
case Intrinsic::ssub_with_overflow:
case Intrinsic::usub_with_overflow:
case Intrinsic::smul_with_overflow:
case Intrinsic::umul_with_overflow: {
APInt Res;
bool Overflow;
switch (IntrinsicID) {
default: llvm_unreachable("Invalid case");
case Intrinsic::sadd_with_overflow:
Res = Op1->getValue().sadd_ov(Op2->getValue(), Overflow);
break;
case Intrinsic::uadd_with_overflow:
Res = Op1->getValue().uadd_ov(Op2->getValue(), Overflow);
break;
case Intrinsic::ssub_with_overflow:
Res = Op1->getValue().ssub_ov(Op2->getValue(), Overflow);
break;
case Intrinsic::usub_with_overflow:
Res = Op1->getValue().usub_ov(Op2->getValue(), Overflow);
break;
case Intrinsic::smul_with_overflow:
Res = Op1->getValue().smul_ov(Op2->getValue(), Overflow);
break;
case Intrinsic::umul_with_overflow:
Res = Op1->getValue().umul_ov(Op2->getValue(), Overflow);
break;
}
Constant *Ops[] = {
ConstantInt::get(Ty->getContext(), Res),
ConstantInt::get(Type::getInt1Ty(Ty->getContext()), Overflow)
};
return ConstantStruct::get(cast<StructType>(Ty), Ops);
}
case Intrinsic::cttz:
if (Op2->isOne() && Op1->isZero()) // cttz(0, 1) is undef.
return UndefValue::get(Ty);
return ConstantInt::get(Ty, Op1->getValue().countTrailingZeros());
case Intrinsic::ctlz:
if (Op2->isOne() && Op1->isZero()) // ctlz(0, 1) is undef.
return UndefValue::get(Ty);
return ConstantInt::get(Ty, Op1->getValue().countLeadingZeros());
}
}
return nullptr;
}
return nullptr;
}
if (Operands.size() != 3)
return nullptr;
if (const ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
if (const ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) {
if (const ConstantFP *Op3 = dyn_cast<ConstantFP>(Operands[2])) {
switch (IntrinsicID) {
default: break;
case Intrinsic::fma:
case Intrinsic::fmuladd: {
APFloat V = Op1->getValueAPF();
APFloat::opStatus s = V.fusedMultiplyAdd(Op2->getValueAPF(),
Op3->getValueAPF(),
APFloat::rmNearestTiesToEven);
if (s != APFloat::opInvalidOp)
return ConstantFP::get(Ty->getContext(), V);
return nullptr;
}
}
}
}
}
return nullptr;
}
static Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID,
VectorType *VTy,
ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI) {
SmallVector<Constant *, 4> Result(VTy->getNumElements());
SmallVector<Constant *, 4> Lane(Operands.size());
Type *Ty = VTy->getElementType();
for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
// Gather a column of constants.
for (unsigned J = 0, JE = Operands.size(); J != JE; ++J) {
Constant *Agg = Operands[J]->getAggregateElement(I);
if (!Agg)
return nullptr;
Lane[J] = Agg;
}
// Use the regular scalar folding to simplify this column.
Constant *Folded = ConstantFoldScalarCall(Name, IntrinsicID, Ty, Lane, TLI);
if (!Folded)
return nullptr;
Result[I] = Folded;
}
return ConstantVector::get(Result);
}
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
/// with the specified arguments, returning null if unsuccessful.
Constant *
llvm::ConstantFoldCall(Function *F, ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI) {
if (!F->hasName())
return nullptr;
StringRef Name = F->getName();
Type *Ty = F->getReturnType();
// This comparison uses the start and end markers of the genx intrinsic enum
// values, relying on tablegen outputting the intrinsics in sorted by name
// order.
unsigned IID = F->getIntrinsicID();
if ((unsigned)(IID - Intrinsic::genx_aaaabegin)
<= (Intrinsic::genx_zzzzend - Intrinsic::genx_aaaabegin))
return ConstantFoldGenXIntrinsic(IID, Ty, Operands);
if (VectorType *VTy = dyn_cast<VectorType>(Ty))
return ConstantFoldVectorCall(Name, F->getIntrinsicID(), VTy, Operands, TLI);
return ConstantFoldScalarCall(Name, F->getIntrinsicID(), Ty, Operands, TLI);
}
| [
"gang.y.chen@intel.com"
] | gang.y.chen@intel.com |
6a42ca6d7e2bbdebffc182dc389f23c3d64548ff | 5ebd5cee801215bc3302fca26dbe534e6992c086 | /blazemark/blazemark/blaze/Complex1.h | 53423aac50d95d4d341186abe38f7096797fce6d | [
"BSD-3-Clause"
] | permissive | mhochsteger/blaze | c66d8cf179deeab4f5bd692001cc917fe23e1811 | fd397e60717c4870d942055496d5b484beac9f1a | refs/heads/master | 2020-09-17T01:56:48.483627 | 2019-11-20T05:40:29 | 2019-11-20T05:41:35 | 223,951,030 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,019 | h | //=================================================================================================
/*!
// \file blazemark/blaze/Complex1.h
// \brief Header file for the Blaze kernel for the complex expression c = A * ( a + b )
//
// Copyright (C) 2012-2019 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. 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.
// 3. Neither the names of the Blaze development group 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 _BLAZEMARK_BLAZE_COMPLEX1_H_
#define _BLAZEMARK_BLAZE_COMPLEX1_H_
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <blazemark/system/Types.h>
namespace blazemark {
namespace blaze {
//=================================================================================================
//
// KERNEL FUNCTIONS
//
//=================================================================================================
//*************************************************************************************************
/*!\name Blaze kernel functions */
//@{
double complex1( size_t N, size_t steps );
//@}
//*************************************************************************************************
} // namespace blaze
} // namespace blazemark
#endif
| [
"klaus.iglberger@gmail.com"
] | klaus.iglberger@gmail.com |
516a694a4815a20c9f7a5b504a4e40db5ae2ac5c | 9f35bea3c50668a4205c04373da95195e20e5427 | /chrome/browser/language/translate_frame_binder.h | 2aef69975fd4c635c36d7d37871ea955a1543b22 | [
"BSD-3-Clause"
] | permissive | foolcodemonkey/chromium | 5958fb37df91f92235fa8cf2a6e4a834c88f44aa | c155654fdaeda578cebc218d47f036debd4d634f | refs/heads/master | 2023-02-21T00:56:13.446660 | 2020-01-07T05:12:51 | 2020-01-07T05:12:51 | 232,250,603 | 1 | 0 | BSD-3-Clause | 2020-01-07T05:38:18 | 2020-01-07T05:38:18 | null | UTF-8 | C++ | false | false | 697 | h | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_LANGUAGE_TRANSLATE_FRAME_BINDER_H_
#define CHROME_BROWSER_LANGUAGE_TRANSLATE_FRAME_BINDER_H_
#include "components/translate/content/common/translate.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace content {
class RenderFrameHost;
}
namespace language {
void BindContentTranslateDriver(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<translate::mojom::ContentTranslateDriver> receiver);
}
#endif // CHROME_BROWSER_LANGUAGE_TRANSLATE_FRAME_BINDER_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
1a18bdd1873fc286252565e6f0db08c09c57e124 | e32e55529f1a3812b7361400048413a0a763b4b9 | /TTP/Semana3/NEIBOR/main.cpp | 149a3051a6dab042e1db91a5c1161cdcc88d4a02 | [] | no_license | PedroVillezca/TTP2017 | 0905e6fd61d742ab3f50ae3b9eea4cd41bd46183 | 344ce81a73b975af9caa6592ca018696f2b70269 | refs/heads/master | 2020-03-24T19:54:51.946324 | 2018-07-31T02:39:23 | 2018-07-31T02:39:23 | 142,950,126 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,018 | cpp | #include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
char num[7], newNum[7], initialNum[7], temp, minN = 'p';
int pos = -1, minP = -1, result = 0, y;
stringstream ss;
scanf("%6s", num);
for(int x = 0; x < strlen(num)-1; x++){
if(num[x] < num[x+1])
pos = x;
}
if(pos == -1)
printf("%d\n", 0);
else{
for(y = 0; y < strlen(num); y++){
if(num[y] < minN && num[y] > num[pos]){
minP = y;
}
}
temp = num[pos];
num[pos] = num[minP];
num[minP] = temp;
for(y = 0; y < strlen(num)-pos-1; y++){
newNum[y] = num[pos+1+y];
}
newNum[y] = '\0';
sort(newNum, newNum+strlen(newNum));
for(y = 0; y < pos+1; y++){
initialNum[y] = num[y];
}
initialNum[y] = '\0';
ss << initialNum << newNum;
ss >> result;
printf("%d\n", result);
}
}
| [
"villezcag.pedro@gmail.com"
] | villezcag.pedro@gmail.com |
c18739e2eca595ce1fc27da9e05bdce66e0d17cf | 0b4c63ce6dfde4ceb184a9c12564e1cfb3a079c1 | /tensorflow-square/kernel/custom_square.cc | ad47f896b36d24306db46a9a28b34739de2b6d59 | [] | no_license | alrojo/course-02456-sparsemax | 4363dc982e6b9e9425bdcbf0b926622525861b11 | ef5b7d915caadc384a0df167c5fff3bb816c0706 | refs/heads/master | 2021-01-12T11:30:40.835156 | 2016-10-31T22:29:48 | 2016-10-31T22:29:48 | 72,942,390 | 2 | 0 | null | 2016-11-05T17:32:04 | 2016-11-05T17:32:03 | null | UTF-8 | C++ | false | false | 2,463 | cc | #include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/shape_inference.h"
#include <string>
#include <cstdlib>
#include <cstdio>
static void debugprint(std::string msg) {
if (std::getenv("DEBUG")) {
std::printf("> debug: %s\n", msg.c_str());
}
}
using namespace tensorflow;
// NOTE: I think there is a buildin Op called Square. Thus calling it just
// Square causes it to fail.
REGISTER_OP("CustomSquare")
.Input("source: int32")
.Output("squared: int32")
.SetShapeFn([](shape_inference::InferenceContext* c) {
debugprint("c++ shape");
c->set_output(0, c->input(0));
return Status::OK();
});
class CustomSquareCPUOp : public OpKernel {
public:
explicit CustomSquareCPUOp(OpKernelConstruction* context) : OpKernel(context) {}
void Compute(OpKernelContext* context) override {
// Grab the input tensor
const Tensor& input_tensor = context->input(0);
auto input = input_tensor.flat<int32>();
// Create an output tensor
Tensor* output_tensor = NULL;
OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(),
&output_tensor));
auto output = output_tensor->flat<int32>();
// output = input * input
debugprint("c++ cpu-op");
const int N = input.size();
for (int i = 0; i < N; i++) {
output(i) = input(i) * input(i);
}
}
};
REGISTER_KERNEL_BUILDER(Name("CustomSquare").Device(DEVICE_CPU), CustomSquareCPUOp);
#if GOOGLE_CUDA
void CustomSquareKernelLauncher(const int* in, const int N, int* out);
class CustomSquareGPUOp : public OpKernel {
public:
explicit CustomSquareGPUOp(OpKernelConstruction* context) : OpKernel(context) {}
void Compute(OpKernelContext* context) override {
// Grab the input tensor
const Tensor& input_tensor = context->input(0);
auto input = input_tensor.flat<int32>();
// Create an output tensor
Tensor* output_tensor = NULL;
OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(),
&output_tensor));
auto output = output_tensor->template flat<int32>();
const int N = input.size();
debugprint("c++ gpu-op");
CustomSquareKernelLauncher(input.data(), N, output.data());
}
};
REGISTER_KERNEL_BUILDER(Name("CustomSquare").Device(DEVICE_GPU), CustomSquareGPUOp);
#endif
| [
"amwebdk@gmail.com"
] | amwebdk@gmail.com |
b29e266409ef8fb936fffb6bc80a8f3fdbb22f58 | 48a730edb4b088c0dfb5bdba6ff864b1ff68790d | /src/core/config.h | ae6fa0da102510052e5c105ce516d6f9ad47013f | [
"WTFPL"
] | permissive | massix/lali | 8aa9e10d4722126e86279da8d466df81d84dfb07 | 9b83eeb79f90af9af42b19ad59b35ac7555d8e19 | refs/heads/master | 2021-01-01T06:11:08.677410 | 2014-11-09T10:33:41 | 2014-11-09T10:33:41 | 25,535,545 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,335 | h | //
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
//
// Software :
// Copyright (C) 2014 Massimo Gengarelli <massimo.gengarelli@gmail.com>
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
//
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
//
// 0. You just DO WHAT THE FUCK YOU WANT TO.
//
#ifndef _CONFIG_H_
#define _CONFIG_H_
#include <string>
#include <stdint.h>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <map>
#define NOTE_ID_COLOR "note_id_color"
#define NOTE_ID_FORMAT "note_id_format"
#define NOTE_TITLE_COLOR "note_title_color"
#define NOTE_COUNT_COLOR "note_count_color"
#define NOTE_BODY_COLOR "note_body_color"
#define PRIORITY_LOW_COLOR "priority_low_color"
#define PRIORITY_DEFAULT_COLOR "priority_default_color"
#define PRIORITY_HIGH_COLOR "priority_high_color"
#define PRIORITY_LOW_TEXT "priority_low_text"
#define PRIORITY_HIGH_TEXT "priority_high_text"
#define PRIORITY_DEFAULT_TEXT "priority_default_text"
#define NOTE_SEARCH_COLOR "note_search_color"
#define FILE_NOTES_DB "file_notes_db"
#define ALWAYS_ASK_CONFIRMATION "always_ask_for_confirmation"
#define MONOCHROME "monochrome"
#define LIST_FORMAT "list_format"
#define PRINT_COUNTER "print_counter"
namespace todo
{
//// Thrown if the configuration file doesn't exist or if it is badly formatted
//class bad_config_file : public std::runtime_exception
//{
//};
class config : public std::map<std::string, std::string>
{
public:
config(std::string const & p_filename);
bool parse_config();
std::string const & operator[](std::string const & p_key);
bool isAskForConfirmation();
bool isMonochrome();
bool isCounterPrintable();
private:
std::string & operator()(std::string const & p_key);
std::string m_config_file;
bool isKeyTrue(std::string const & p_key);
};
}
#endif
| [
"massimo.gengarelli@gmail.com"
] | massimo.gengarelli@gmail.com |
0f2282c9c667df5cbb8902037d4c577ee38fcd0d | f4cdff13b74cdc3d8e1c98f3bdd69c17964876a5 | /raspi/Project/sample-code/csv-file-comp.cpp | 477e30fd8a7afbed4ffac9da6ddf18fff711811d | [] | no_license | praneethdodedu/Robotics | 57a5577816d0e2fac73f2380053a2de089c0e821 | 03d20a917883b206aa4f93d0a8cfde4b118db947 | refs/heads/master | 2022-03-14T05:57:52.796107 | 2022-02-08T16:21:48 | 2022-02-08T16:21:48 | 152,742,644 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,241 | cpp | #include <stdio.h>
#include <string.h>
#include <errno.h>
#include<iostream>
#include <wiringSerial.h>
#include<bits/stdc++.h>
using namespace std;
int main (int argc, char **argv)
{
fstream fin1;
fin1.open("lidar-data.csv", ios::in);
fstream fin2;
fin2.open("lidar-data-0-1.csv", ios::in);
vector<string> row1;
vector<string> row2;
string word1, temp1, word2, temp2;
double sum=0;
while (fin1 >> temp1) {
row1.clear();
while (getline(fin1, word1, '\n')) {
row1.push_back(word1.substr(word1.find(",") + 1));
}
}
while (fin2 >> temp2) {
row2.clear();
while (getline(fin2, word2, '\n')) {
row2.push_back(word2.substr(word2.find(",") + 1));
}
}
for(int i=1; i<row2.size();i++) {
stringstream sFirst(row1[i]);
int firstData = 0;
sFirst >> firstData;
stringstream sSecond(row2[i]);
int secondData = 0;
sSecond >> secondData;
if(firstData > 1000 || secondData > 1000)
continue;
cout << "firstData :" << firstData << " secondData :" << secondData << " pow : " << pow((firstData-secondData), 2) << endl;
sum = sum + pow((firstData-secondData), 2);
}
cout << sum << endl;
cout << sqrt(sum) << endl;
}
| [
"praneeth.dodedu@gmail.com"
] | praneeth.dodedu@gmail.com |
46179b83a237165e28405d29ddee7206cd924b4f | 71854d8ad5d947b9b82592e09493a8ef5376d1a6 | /pengirim/src/main.cpp | 50cffa86d0ca8eb5bad3a07cbe3b97d75220db9c | [] | no_license | nobbyphala/TA | b43ba05f8f0d1cfe5b80217b21e43f546f778bb8 | 40b0815165bd7d5b2b372bf29ae6a44d29bcb2a3 | refs/heads/master | 2020-03-18T13:34:25.426143 | 2018-06-03T08:53:46 | 2018-06-03T08:53:46 | 134,792,976 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,074 | cpp | // #include <SPI.h>
// #include <nRF24L01.h>
// #include <RF24.h>
// #include<CountUpDownTimer.h>
//
// RF24 radio(7, 8);
//
// const long broadcast_addr = 1000;
//
// struct data_CH{
// long CH_addr;
// long status;
// };
//
// data_CH text;
// CountUpDownTimer T(UP, HIGH);
//
//
// void setup()
// {
// while (!Serial);
// Serial.begin(57600);
// Serial.println("mulai");
// radio.begin();
// radio.openReadingPipe(0, broadcast_addr);
// radio.openWritingPipe(broadcast_addr);
// // radio.openReadingPipe(0, rxAddr);
// //
// // radio.startListening();
// T.StartTimer();
// }
//
// bool radio_listening(long addr, data_CH *ret)
// {
//
// radio.startListening();
//
// if(radio.available())
// {
// radio.read(ret, sizeof(ret));
// return true;
// }
//
// return false;
// }
//
// void radio_send(long addr, data_CH * msg, long delay_micro)
// {
//
// radio.stopListening();
// delay(delay_micro);
// radio.write(msg, sizeof(msg));
// }
//
// void loop()
// {
// T.Timer();
//
// if(T.ShowSeconds() % 2 == 0)
// {
// if(radio_listening(broadcast_addr, &text))
// {
// Serial.println(text.status);
// }
// }
//
// if(T.ShowSeconds() % 5 == 0)
// {
// randomSeed(analogRead(0));
// data_CH data;
// data.status = 2.0;
// radio_send(broadcast_addr, &data, random(1,200));
// }
// }
// Pengiriman per 5 detik dengan delay 1 (bisa diextend untuk listening di setiap 1 microsecond
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00003";
int a = 0, xMili = 0, xSecond = 0, xMinute = 0, xHour = 0, currentSecond = 0, currentMilis = 0;
unsigned long wTime;
struct data_CH{
long CH_addr;
float status;
};
float getRandom()
{
randomSeed(analogRead(0));
return random(1,100) / 100.0;
}
void setup()
{
xMili = 0; xSecond = 0; xMinute = 0; xHour = 0; currentMilis=0;
// while (!Serial);
Serial.begin(57600);
radio.begin();
radio.openReadingPipe(0, rxAddr);
radio.startListening();
}
void countTime() {
if (xMili == 999) {
++xSecond;
xMili = 0;
}
if ((xSecond > 59)) {
++xMinute;
xSecond = 0;
currentSecond = -1;
}
if (xMinute > 59) {
++xHour;
xMinute = 0;
}
++xMili;
}
void countMillis() {
wTime = millis();
if (currentMilis == 0) {
currentMilis = wTime;
}
if ((wTime - currentMilis > 999)) {
++xSecond;
currentMilis = wTime;
}
if ((xSecond > 59)) {
++xMinute;
xSecond = 0;
currentSecond = -1;
}
if (xMinute > 59) {
++xHour;
xMinute = 0;
}
// ++xMili;
}
void tapListening() {
// radio.openReadingPipe(0, rxAddr);
// radio.startListening();
data_CH data;
if (radio.available())
{
// int a = 0;
//const char rtext[25];
Serial.print("Dapat data: ");
radio.read(&data, sizeof(data_CH));
Serial.println(data.status);
}
}
void transmit(data_CH* Message)
{
//Serial.print("Alamat2");
//Serial.println(Message->status);
//radio.setRetries(15, 15);
radio.stopListening();
radio.openWritingPipe(rxAddr);
// String c = Message;
// char pesan[25];
// c.toCharArray(pesan, 25);
radio.write(Message, sizeof(data_CH));
radio.openReadingPipe(0, rxAddr);
radio.startListening();
}
void loop()
{
currentSecond = xSecond;
countTime();
tapListening();
if ((currentSecond < xSecond) && ((xSecond % 2) == 0)) {
// char text[25];
// String myMessage = String(xHour, DEC) + ":" + String(xMinute, DEC) + ":" + String(xSecond, DEC);
// myMessage.concat("Uno 2");
// Serial.println(myMessage);
data_CH ch;
ch.status = getRandom();
//Serial.print("Alamat1 ");
//Serial.println(sizeof(ch));
transmit(&ch);
}
delay(1);
}
| [
"nobby.phala@gmail.com"
] | nobby.phala@gmail.com |
a0ca45a610a3deaa8a6137b7b5c8880e6d03369c | e79a4fb59ead906489e8c8a0457407d4f559604f | /tests/CustomerTests.h | 888f5e6a8225f7a9a34fc88af5041f86d2cfe8c3 | [] | no_license | Furkanzmc/QStripe | 034cc7c26711debdd38bdcbaa5fbed5ce8a27307 | 7b77c0bd5620a4df3a665755bff9cfb3ec1b9a75 | refs/heads/master | 2021-04-03T07:25:49.561526 | 2019-04-09T22:23:44 | 2019-04-22T20:48:52 | 124,796,188 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 718 | h | #pragma once
#include <QObject>
class CustomerTests : public QObject
{
Q_OBJECT
public:
explicit CustomerTests(QObject *parent = nullptr);
QString getCustomerID() const;
private:
QVariantMap getAddressData() const;
QVariantMap getShippingInformationData() const;
QVariantMap getData() const;
private slots:
void testSignals();
void testFromJson();
void testJsonStr();
void testJson();
void testSet();
void testCreateCustomerErrors();
void testCreateCustomer();
void testUpdateCustomerErrors();
void testUpdateCustomer();
void testDeleteCustomerErrors();
void testDeleteCustomer();
private:
QString m_CustomerID, m_CustomerIDToDelete;
};
| [
"furkanuzumcu@gmail.com"
] | furkanuzumcu@gmail.com |
b4e14fb04778a34f63c1ad3d5588c567101e5882 | beaccd4ca566e9f7f112b98dfe3e32ade0feabcc | /code chef/twodogs.cpp | 245e502b7050360f05de1285e54974277771affa | [] | no_license | maddotexe/Competitive-contest-programs | 83bb41521f80e2eea5c08f198aa9384cd0986cde | 4bc37c5167a432c47a373c548721aedd871fc6b7 | refs/heads/master | 2020-04-17T08:08:43.922419 | 2015-03-10T19:26:55 | 2015-03-10T19:26:55 | 31,177,844 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,105 | cpp | #include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <cstdlib>
#include <string>
#include <list>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <deque>
#include <climits>
#include <cassert>
using namespace std;
#define ull unsigned long long
#define ll long long
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define Sl(x) scanf("%lld",&x)
#define Su(x) scanf("%llu",&x)
#define S(x) scanf("%d",&x)
#define IS(x) cin>>x
#define ISF(x) getline(cin,x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pps pair<ll,pll>
#define ppf pair<pll,ll>
#define psi pair<string,int>
#define pis pair<int,string>
#define fr first
#define se second
#define MOD 1000000007
#define MP(x,y) make_pair(x,y)
#define eps 1e-7
#define V(x) vector<x>
#define pb(x) push_back(x)
#define mem(x,i) memset(x,i,sizeof(x))
#define fori(i,s,n) for(i=(s);i<(n);i++)
#define ford(i,s,n) for(i=(n);i>=(s);--i)
#define INF 8944674407370955161LL
#define debug(i,st,arr) fori(i,0,st){cout<<arr[i]<<" ";}cout<<endl;
#define forci(i,sw) for((i)=(sw).begin();(i)!=(sw).end();(i)++)
#define forcd(i,sw) for((i)=(sw).rbegin();(i)!=(sw).rend();(i)++)
int abs(int x) {if(x < 0) return -x; return x;}
int v[1000001];
inline void fastRead(int *a)
{
register char c=0;
while (c<33) c=getchar_unlocked();
*a=0;
while (c>33)
{
*a=*a*10+c-'0';
c=getchar_unlocked();
}
}
int main()
{
int n, k, x = -1, y = -1;
scanf("%d%d", &n, &k);
int a[n];
int ans = n;
memset(v, -1, sizeof(v));
for (int i = 0; i < n; i++) {
fastRead(&a[i]);
if (a[i] * 2 == k) {
} else {
if (v[a[i]] == -1) {
v[a[i]] = min(i + 1, n - i);
} else {
v[a[i]] = min(v[a[i]], min(i + 1, n - i));
}
}
}
for (int i = 1; i < (k + 1) / 2; i++) {
if (v[i] != -1 && v[k - i] != -1) {
ans = min(ans, max(v[i], v[k - i]));
}
}
if (ans == n) {
cout << -1 << endl;
} else {
cout << ans << endl;
}
return 0;
}
| [
"agarwal.shubham21@gmail.com"
] | agarwal.shubham21@gmail.com |
018370335e3a73b8b0e736056cb95f0adf899d1c | fba8406c19ec34038ad1a93b1260ea3ff7baa431 | /PBattleCity/Perro.cpp | d9b776482cd27297e5708778179848e615789c13 | [] | no_license | gase1209/ProyectoBattleCity | 05ae39048921ae8c0c121f0393d1469bf400a7a8 | 96f15090b170393c7a9893dc1230763a6800e3b8 | refs/heads/main | 2023-03-06T01:38:17.365939 | 2021-02-18T00:05:38 | 2021-02-18T00:05:38 | 339,885,725 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 486 | cpp | #include "Perro.h"
#include "Utilitarios.h"
Perro::Perro(string _NombrePerro, string _RepresentacionVisual, int _PosicionXI, int _PosicionXD, int _PosicionYS, int _PosicionYI) : NombrePerro(_NombrePerro), RepresentacionVisual(_RepresentacionVisual),
PosicionXI(_PosicionXI), PosicionXD(_PosicionXD),
PosicionYS(_PosicionYS), PosicionYI(_PosicionYI)
{
}
void Perro::VisualizarEnPantalla()
{
gotoxy(PosicionXI, PosicionYI);
cout << RepresentacionVisual << "(((" << ")))" << endl;
}
| [
"jms25348@gmail.com"
] | jms25348@gmail.com |
602d15b60d0107ea2be9a0c768f0f55bc4260664 | 7d55e549ea3fedec538865721ca46531ba4a8c7a | /examples/SHT31_ReadValues/SHT31_ReadValues.ino | 866356b3930b3e381fb1e7547ae161c5f2c0a09a | [
"BSD-3-Clause"
] | permissive | jacobstim/Adafruit_SHT31 | f47cf0f23c5d5706c0cae40d7708f970e45191c9 | d07fbc96557050865ad4e6e5250634bb83d85bd0 | refs/heads/master | 2021-07-07T16:43:31.585725 | 2017-10-05T16:01:48 | 2017-10-05T16:01:48 | 105,910,328 | 0 | 0 | null | 2017-10-05T15:57:07 | 2017-10-05T15:57:06 | null | UTF-8 | C++ | false | false | 3,594 | ino | /****************************************************************************
SHT31D Unified Sensor Driver
*****************************************************************************
Example illustrating how to read data using the unified sensor driver (from
Adafruit's Sensor framework).
Written in 2017 by Tim Jacobs
*****************************************************************************/
#include <Arduino.h>
#include <Adafruit_Sensor.h>
#include <SHT31D_Universal.h>
#define SERIALOUT Serial
SHT31_Unified sht31;
// =============================================================================
// =============================================================================
// =============================================================================
void setup() {
SERIALOUT.begin(57600);
// Initialize sensor
if (sht31.begin(0x44)) {
// Configure sensor
SERIALOUT.println("Found SHT31-D Temperature/Humidity sensor!");
// Read sensor data
sensor_t sensor;
SERIALOUT.println("------------------------------------");
sht31.temperature().getSensor(&sensor);
displaySensorDetails(sensor, "C");
SERIALOUT.println("------------------------------------");
sht31.humidity().getSensor(&sensor);
displaySensorDetails(sensor, "%");
SERIALOUT.println("------------------------------------");
} else {
SERIALOUT.println("Couldn't find SHT31-D Temperature/Humidity sensor!");
while(1);
}
}
// =============================================================================
// =============================================================================
// =============================================================================
// Track number of loops
uint32_t loopcounter = 1;
void loop() {
SERIALOUT.print("=== LOOP "); SERIALOUT.print(loopcounter); SERIALOUT.println(" ======================================");
// Read sensor using single shot mode every 5 seconds
sensors_event_t event;
sht31.temperature().getEvent(&event);
if (!isnan(event.temperature)) {
SERIALOUT.print("Temperature : "); SERIALOUT.print(event.temperature,2); SERIALOUT.println(" C");
}
sht31.humidity().getEvent(&event);
if (!isnan(event.relative_humidity)) {
SERIALOUT.print("Relative Humidity : "); SERIALOUT.print(event.relative_humidity,2); SERIALOUT.println(" %");
}
delay(5000);
loopcounter++;
}
// =============================================================================
// =============================================================================
// =============================================================================
/**************************************************************************/
/*
Displays some basic information on this sensor from the unified
sensor API sensor_t type (see Adafruit_Sensor for more information)
*/
/**************************************************************************/
void displaySensorDetails(sensor_t sensor, String siunit) {
SERIALOUT.print ("Sensor: "); SERIALOUT.println(sensor.name);
SERIALOUT.print ("Driver Ver: "); SERIALOUT.println(sensor.version);
SERIALOUT.print ("Unique ID: "); SERIALOUT.println(sensor.sensor_id);
SERIALOUT.print ("Max Value: "); SERIALOUT.print(sensor.max_value); SERIALOUT.print(" "); SERIALOUT.println(siunit);
SERIALOUT.print ("Min Value: "); SERIALOUT.print(sensor.min_value); SERIALOUT.print(" "); SERIALOUT.println(siunit);
SERIALOUT.print ("Resolution: "); SERIALOUT.print(sensor.resolution); SERIALOUT.print(" "); SERIALOUT.println(siunit);
}
| [
"jacobs.tim@gmail.com"
] | jacobs.tim@gmail.com |
0b4479345a6c610f7fc5efbab6774a5ea134697a | 7638d92d07112e839d4c8d9e4c60b3b36bbe3237 | /LearnOpenGLES/libs/ftgl/Vectoriser.cpp | 3d590e080bffc29116c4cc98c09e1ad60dd5db89 | [] | no_license | erpapa/LearnOpenGLES | daa6ab2792df6470e7cbc75790d454ace43b3e40 | 1a45457212e9fc16c0b44e4736b3a3ec693ab2e0 | refs/heads/master | 2021-05-02T12:55:11.685870 | 2020-10-26T10:08:25 | 2020-10-26T10:08:25 | 120,749,355 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,289 | cpp | /*
* FTGL - OpenGL font library
*
* Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
* Copyright (c) 2008 Éric Beets <ericbeets@free.fr>
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "Vectoriser.h"
namespace ftgl {
Vectoriser::Vectoriser(const FT_GlyphSlot glyph, unsigned short bezierSteps) :
contourList(0),
ftContourCount(0),
contourFlag(0)
{
if(glyph)
{
outline = glyph->outline;
ftContourCount = outline.n_contours;
contourList = 0;
contourFlag = outline.flags;
ProcessContours(bezierSteps);
}
}
Vectoriser::~Vectoriser()
{
for(size_t c = 0; c < ContourCount(); ++c)
{
delete contourList[c];
}
delete [] contourList;
}
void Vectoriser::ProcessContours(unsigned short bezierSteps)
{
short contourLength = 0;
short startIndex = 0;
short endIndex = 0;
contourList = new Contour*[ftContourCount];
for(int i = 0; i < ftContourCount; ++i)
{
FT_Vector* pointList = &outline.points[startIndex];
char* tagList = &outline.tags[startIndex];
endIndex = outline.contours[i];
contourLength = (endIndex - startIndex) + 1;
Contour* contour = new Contour(pointList, tagList, contourLength, bezierSteps);
contourList[i] = contour;
startIndex = endIndex + 1;
}
// Compute each contour's parity. FIXME: see if FT_Outline_Get_Orientation
// can do it for us.
for(int i = 0; i < ftContourCount; i++)
{
Contour *c1 = contourList[i];
// 1. Find the leftmost point.
Point leftmost(65536.0, 0.0);
for(size_t n = 0; n < c1->PointCount(); n++)
{
Point p = c1->GetPoint(n);
if(p.X() < leftmost.X())
{
leftmost = p;
}
}
// 2. Count how many other contours we cross when going further to
// the left.
int parity = 0;
for(int j = 0; j < ftContourCount; j++)
{
if(j == i)
{
continue;
}
Contour *c2 = contourList[j];
for(size_t n = 0; n < c2->PointCount(); n++)
{
Point p1 = c2->GetPoint(n);
Point p2 = c2->GetPoint((n + 1) % c2->PointCount());
/* FIXME: combinations of >= > <= and < do not seem stable */
if((p1.Y() < leftmost.Y() && p2.Y() < leftmost.Y())
|| (p1.Y() >= leftmost.Y() && p2.Y() >= leftmost.Y())
|| (p1.X() > leftmost.X() && p2.X() > leftmost.X()))
{
continue;
}
else if(p1.X() < leftmost.X() && p2.X() < leftmost.X())
{
parity++;
}
else
{
Point a = p1 - leftmost;
Point b = p2 - leftmost;
if(b.X() * a.Y() > b.Y() * a.X())
{
parity++;
}
}
}
}
// 3. Make sure the glyph has the proper parity.
c1->SetParity(parity);
}
}
size_t Vectoriser::PointCount()
{
size_t s = 0;
for(size_t c = 0; c < ContourCount(); ++c)
{
s += contourList[c]->PointCount();
}
return s;
}
const Contour* const Vectoriser::GetContour(size_t index) const
{
return (index < ContourCount()) ? contourList[index] : NULL;
}
}
| [
"hyplcf@163.com"
] | hyplcf@163.com |
dc9a3749773d5d7b997eae9dfdc3f094ed40862c | 19d0ce325216c56a0260edfb38ff8c328cb754f4 | /Export/android/release/obj/src/haxe/_Unserializer/DefaultResolver.cpp | b2fd431ff5025f532c31d7971673cad7d3e6d171 | [] | no_license | HerbinCommando/TokyoTrail | 42fcb0569e5028c2e96b100ad20008304370c16e | 8737240e8782f5357f472dead574fb956243e48a | refs/heads/master | 2021-01-01T20:08:20.336935 | 2017-08-06T05:58:30 | 2017-08-06T05:58:30 | 98,772,096 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 4,884 | cpp | // Generated by Haxe 3.4.2
#include <hxcpp.h>
#ifndef INCLUDED_Type
#include <Type.h>
#endif
#ifndef INCLUDED_haxe__Unserializer_DefaultResolver
#include <haxe/_Unserializer/DefaultResolver.h>
#endif
HX_DEFINE_STACK_FRAME(_hx_pos_68dfa52f787219bb_476_new,"haxe._Unserializer.DefaultResolver","new",0xe2809ead,"haxe._Unserializer.DefaultResolver.new","/usr/local/lib/haxe/std/haxe/Unserializer.hx",476,0x60de4a67)
HX_LOCAL_STACK_FRAME(_hx_pos_68dfa52f787219bb_477_resolveClass,"haxe._Unserializer.DefaultResolver","resolveClass",0xbc0d3dbf,"haxe._Unserializer.DefaultResolver.resolveClass","/usr/local/lib/haxe/std/haxe/Unserializer.hx",477,0x60de4a67)
HX_LOCAL_STACK_FRAME(_hx_pos_68dfa52f787219bb_478_resolveEnum,"haxe._Unserializer.DefaultResolver","resolveEnum",0x8198f35a,"haxe._Unserializer.DefaultResolver.resolveEnum","/usr/local/lib/haxe/std/haxe/Unserializer.hx",478,0x60de4a67)
namespace haxe{
namespace _Unserializer{
void DefaultResolver_obj::__construct(){
HX_STACKFRAME(&_hx_pos_68dfa52f787219bb_476_new)
}
Dynamic DefaultResolver_obj::__CreateEmpty() { return new DefaultResolver_obj; }
void *DefaultResolver_obj::_hx_vtable = 0;
Dynamic DefaultResolver_obj::__Create(hx::DynamicArray inArgs)
{
hx::ObjectPtr< DefaultResolver_obj > _hx_result = new DefaultResolver_obj();
_hx_result->__construct();
return _hx_result;
}
bool DefaultResolver_obj::_hx_isInstanceOf(int inClassId) {
return inClassId==(int)0x00000001 || inClassId==(int)0x2712964b;
}
hx::Class DefaultResolver_obj::resolveClass(::String name){
HX_STACKFRAME(&_hx_pos_68dfa52f787219bb_477_resolveClass)
HXDLIN( 477) return ::Type_obj::resolveClass(name);
}
HX_DEFINE_DYNAMIC_FUNC1(DefaultResolver_obj,resolveClass,return )
hx::Class DefaultResolver_obj::resolveEnum(::String name){
HX_STACKFRAME(&_hx_pos_68dfa52f787219bb_478_resolveEnum)
HXDLIN( 478) return ::Type_obj::resolveEnum(name);
}
HX_DEFINE_DYNAMIC_FUNC1(DefaultResolver_obj,resolveEnum,return )
hx::ObjectPtr< DefaultResolver_obj > DefaultResolver_obj::__new() {
hx::ObjectPtr< DefaultResolver_obj > __this = new DefaultResolver_obj();
__this->__construct();
return __this;
}
hx::ObjectPtr< DefaultResolver_obj > DefaultResolver_obj::__alloc(hx::Ctx *_hx_ctx) {
DefaultResolver_obj *__this = (DefaultResolver_obj*)(hx::Ctx::alloc(_hx_ctx, sizeof(DefaultResolver_obj), false, "haxe._Unserializer.DefaultResolver"));
*(void **)__this = DefaultResolver_obj::_hx_vtable;
__this->__construct();
return __this;
}
DefaultResolver_obj::DefaultResolver_obj()
{
}
hx::Val DefaultResolver_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 11:
if (HX_FIELD_EQ(inName,"resolveEnum") ) { return hx::Val( resolveEnum_dyn() ); }
break;
case 12:
if (HX_FIELD_EQ(inName,"resolveClass") ) { return hx::Val( resolveClass_dyn() ); }
}
return super::__Field(inName,inCallProp);
}
#if HXCPP_SCRIPTABLE
static hx::StorageInfo *DefaultResolver_obj_sMemberStorageInfo = 0;
static hx::StaticInfo *DefaultResolver_obj_sStaticStorageInfo = 0;
#endif
static ::String DefaultResolver_obj_sMemberFields[] = {
HX_HCSTRING("resolveClass","\xac","\xbd","\xdd","\x80"),
HX_HCSTRING("resolveEnum","\x0d","\x90","\x51","\xde"),
::String(null()) };
static void DefaultResolver_obj_sMarkStatics(HX_MARK_PARAMS) {
HX_MARK_MEMBER_NAME(DefaultResolver_obj::__mClass,"__mClass");
};
#ifdef HXCPP_VISIT_ALLOCS
static void DefaultResolver_obj_sVisitStatics(HX_VISIT_PARAMS) {
HX_VISIT_MEMBER_NAME(DefaultResolver_obj::__mClass,"__mClass");
};
#endif
hx::Class DefaultResolver_obj::__mClass;
void DefaultResolver_obj::__register()
{
hx::Object *dummy = new DefaultResolver_obj;
DefaultResolver_obj::_hx_vtable = *(void **)dummy;
hx::Static(__mClass) = new hx::Class_obj();
__mClass->mName = HX_HCSTRING("haxe._Unserializer.DefaultResolver","\x3b","\xc4","\x6e","\x72");
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &hx::Class_obj::GetNoStaticField;
__mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField;
__mClass->mMarkFunc = DefaultResolver_obj_sMarkStatics;
__mClass->mStatics = hx::Class_obj::dupFunctions(0 /* sStaticFields */);
__mClass->mMembers = hx::Class_obj::dupFunctions(DefaultResolver_obj_sMemberFields);
__mClass->mCanCast = hx::TCanCast< DefaultResolver_obj >;
#ifdef HXCPP_VISIT_ALLOCS
__mClass->mVisitFunc = DefaultResolver_obj_sVisitStatics;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = DefaultResolver_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = DefaultResolver_obj_sStaticStorageInfo;
#endif
hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
} // end namespace haxe
} // end namespace _Unserializer
| [
"heath@wgcells.com"
] | heath@wgcells.com |
4a442a5ab0db7fe5b0d99be5a7620caaf6c869e9 | b9fdc902fa6a3c275c800a4ad721cfc94774fa54 | /Tests/VECMatrices5678/avx512debug.cpp | 57529121a43e7cbff4d5d2275e4c6c1d6008462e | [] | no_license | r-aax/ipar | fd51ce2f137f20135cc6e54861fdaf0e57b3dc47 | 42499b16e653c97aa3c43b0cbf2fae82c7211ad3 | refs/heads/master | 2022-05-15T17:56:45.475825 | 2022-04-11T10:33:29 | 2022-04-11T10:33:29 | 108,764,737 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,362 | cpp | /// \file
/// \brief AVX-512 debug functions implementations.
#include "avx512debug.h"
#include "../../Utils/IO.h"
#ifdef INTEL
#include <immintrin.h>
using namespace std;
/// \brief Get <c>i</c>-th element from vector.
///
/// \param[in] v - vector
/// \param[in] i - index
///
/// \return
/// Element.
float get(__m512 v, int i)
{
float arr[16];
_mm512_store_ps(&arr[0], v);
return arr[i];
}
/// \brief Set <c>i</c>-th element in vector.
///
/// \param[in,out] v - vector
/// \param[in] i - index
/// \param[in] f - value
void set(__m512 *v, int i, float f)
{
float arr[16];
_mm512_store_ps(&arr[0], *v);
arr[i] = f;
*v = _mm512_load_ps(&arr[0]);
}
/// \brief Print __m512 vector.
///
/// \param v - vector
void print_m512(__m512 v)
{
__declspec(align(64)) float tmp[16];
__assume_aligned(&tmp[0], 64);
_mm512_store_ps(&tmp[0], v);
cout << "__m512 [";
for (int i = 0; i < 16; i++)
{
cout << tmp[i] << ", ";
}
cout << "]" << endl;
}
#endif
/// \brief Print matrix 8x8.
///
/// \param Matrix pointer.
void print_matrix8x8(float *m)
{
cout << "matrix 8x8" << endl;
for (int i = 0; i < 8; i++)
{
int ii = i * 8;
cout << " ";
for (int j = 0; j < 8; j++)
{
cout << m[ii + j] << " ";
}
cout << endl;
}
}
| [
"rybakov.aax@gmail.com"
] | rybakov.aax@gmail.com |
5c8e9c400eb3f94030040a1cd38c9a34f6fbb89a | 4335c83a37839036a855dc5539553e1faef25389 | /io.h | 56e2b36de35c383c00eff69b4eda9966bfc00a02 | [] | no_license | Tachikoma2018/imageretrieve | 71fe5939cac90209013620b7128eb00ab14d7620 | e0f77314d02069911c3b0a828eae56aa1bff2f26 | refs/heads/master | 2020-06-12T20:00:14.759948 | 2015-07-20T00:46:49 | 2015-07-20T00:46:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 574 | h | #ifndef __IO_PROCESS__
#define __IO_PROCESS__
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
#include <stdio.h>
#include <sstream>
using std::string;
using std::ofstream;
using std::ifstream;
using std::ostringstream;
using std::vector;
using std::istringstream;
using std::ostringstream;
class IOProcess
{
public:
IOProcess(void);
~IOProcess(void);
void ReadFile(const string &path,vector<string> &features);
void WriteFile(const string &path,vector<string> &features);
void Write(const string &path,const string &data);
};
#endif
| [
"wyb621@163.com"
] | wyb621@163.com |
1a9002214ca48a74e45737aa5ce561b89547e443 | a2a4878a9b8905b67ec6593e38ffe9ccc6b61616 | /ex02/Warrior.hh | 0cfe5b12987f79c5180e6a5d2fa32046e7b8548c | [] | no_license | 17150008/piscine_cpp_d05 | 9aea97cc38d1a326fa569ea547d39d5291647692 | 18dba6b8240192351a675e417a83bf1d9d17c209 | refs/heads/master | 2020-03-22T12:29:34.359125 | 2018-07-09T01:58:02 | 2018-07-09T01:58:02 | 140,043,487 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 307 | hh | #ifndef WARRIOR_H_
#define WARRIOR_H_
#include <string>
#include "Character.hh"
class Warrior : public Character
{
public:
explicit Warrior(std::string const& name, int level);
virtual ~Warrior() {}
int CloseAttack();
int RangeAttack();
private:
std::string const _weapon;
};
#endif
| [
"qiaolinqi@yeah.net"
] | qiaolinqi@yeah.net |
5cb4d9bc91e35809d208dc731272ae91c33ed306 | 49022e7430be70ab6880c28b759f9c68e1e2edf8 | /Game/Entities/Entrance.cpp | 1545142bc2d00f1f7387b7f343dc972185885546 | [] | no_license | f3db43f4g443/SimpleSample11 | 61a634afa664676f94bf51f58c38640ee7ee1b64 | e6aa0ceb34843defd0433b09f42f2de036d443d7 | refs/heads/master | 2022-03-10T18:21:42.698566 | 2022-02-18T06:42:18 | 2022-02-18T06:42:18 | 68,726,252 | 0 | 1 | null | 2021-04-15T18:51:36 | 2016-09-20T15:30:41 | C++ | UTF-8 | C++ | false | false | 625 | cpp | #include "stdafx.h"
#include "Entrance.h"
#include "Stage.h"
#include "Player.h"
CEntrance::CEntrance( const char* szStage, const char* szStartPoint, const char* szText, float fTime, float fCircleSize )
: CFastUseable( szText, fTime, fCircleSize )
, m_strStageName( szStage )
, m_strStartPointName( szStartPoint )
{
}
CEntrance::CEntrance( const SClassCreateContext& context )
: CFastUseable( context )
, m_strStageName( context )
, m_strStartPointName( context )
{
}
void CEntrance::OnUse()
{
SetEnabled( false );
GetStage()->GetPlayer()->DelayChangeStage( m_strStageName.c_str(), m_strStartPointName.c_str() );
} | [
"654656040@qq.com"
] | 654656040@qq.com |
f4fdee97ce09b42bae2f215165af1ebc5e234c85 | 8c9a869239aa842bbb44e17baba8ed41e189192f | /jni/application/Player.h | d146a172f2eb0e0f391855c0fcb077eb9b9ec97e | [] | no_license | linshu123/494_p3 | 3f73246d3e065c5b53aefb7de65dbd3f14bbe1ef | 9f5a59a0b7b923a3cd721ce104709c62a8e1ca90 | refs/heads/master | 2020-04-19T03:55:00.574175 | 2013-10-31T05:02:36 | 2013-10-31T05:02:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,406 | h | #ifndef PLAYER_H
#define PLAYER_H
#include <Zeni/Camera.h>
#include <Zeni/Collision.h>
#include <Zeni/Quaternion.h>
#include <Zeni/Vector3f.h>
namespace Crate {
class Player {
public:
Player(const Zeni::Camera &camera_,
const Zeni::Vector3f &end_point_b_,
const float radius_);
// Level 1
const Zeni::Camera & get_camera() const {return m_camera;}
// Level 2
void set_position(const Zeni::Point3f &position);
void adjust_pitch(const float &phi);
void turn_left_xy(const float &theta);
// Level 3
const Zeni::Collision::Capsule & get_body() const {return m_body;}
bool is_on_ground() const {return m_is_on_ground;}
const Zeni::Vector3f & get_velocity() const {return m_velocity;}
void set_velocity(const Zeni::Vector3f &velocity_) {m_velocity = velocity_;}
void set_on_ground(const bool &is_on_ground_);
void jump();
void step(const float &time_step);
void look_at(const Zeni::Point3f &);
private:
//void create_body();
// Level 1/2
Zeni::Camera m_camera;
// Level 2
Zeni::Vector3f m_end_point_b;
float m_radius;
// Level 3
Zeni::Collision::Capsule m_body; // collision
Zeni::Vector3f m_velocity;
bool m_is_on_ground;
// Level 4
// Controls are external to Player
};
}
#endif
| [
"linshu123@gmail.com"
] | linshu123@gmail.com |
6cd54b448e3356950c284b82782724e25b2d028d | cc0893757997cd4ad92971c52d4002d6644a1db3 | /shadowmapdemo1byzwqxin/StdAfx.cpp | 05a12f0fe11335ae1ae3c381de870b5c5fae2df1 | [] | no_license | karry9527/HW2-displacement-and-bump-map | 7c1af691cb82fd4ac6d79dbe2494005950649785 | 5d0d4acb8c167f2861d1115a311aff9e1246f905 | refs/heads/master | 2020-05-19T19:16:09.952360 | 2015-09-17T07:02:29 | 2015-09-17T07:02:29 | 41,012,017 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 213 | cpp | // stdafx.cpp : source file that includes just the standard includes
// shadowvolume.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"karry9527100@gmail.com"
] | karry9527100@gmail.com |
9ebb8ed4fbb125c71cd738f654a56d69c191dbff | 06bd944813c066bc16446ee321ceaf3a7673fe7a | /SD/Sortari/src/countSort.cpp | c03cc82b8897796819f0af1aea89ebd32aee1449 | [] | no_license | Rpd-Strike/Courses | bfebaab2f80147cc2a854f27ab4c30406b7f061f | d5e0d472b5f4a924422495bbfeedcabce7077802 | refs/heads/master | 2021-08-08T02:08:34.940731 | 2021-04-20T11:23:37 | 2021-04-20T11:23:37 | 248,713,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 806 | cpp | #include "countSort.hpp"
#include "Felix/Colors.hpp"
namespace Sortari
{
std::string CountSort(std::vector<int>& v)
{
using Felix::Colors::File::red;
using Felix::Colors::File::reset;
if( v.empty() )
return "";
int valmin = *std::min_element(v.begin(), v.end());
int valmax = *std::max_element(v.begin(), v.end());
if( valmax - valmin > VALMAX ) {
return red + "Values from given vector too big for CountSort" + reset;
}
std::vector<int> values(VALMAX + 2, 0);
for( auto & x : v )
++values[x - valmin];
v.clear();
for ( int i = 0; i <= VALMAX; ++i )
for( int j = 0; j < values[i]; ++j )
v.push_back(i + valmin);
return "";
}
} | [
"puscasu.felix1@gmail.com"
] | puscasu.felix1@gmail.com |
2ce54ef44fdb8e91dbb8ecd0e603a4f5a555de60 | 1a1a850a849cb4b173f359b4b30a66a357109e46 | /console/iui.cpp | 2306ea09b84ca0381d74192ce780bd18ef33290c | [] | no_license | Akikaze/ComCheck | 4bfc92f50bb5baa01d8aec5d1df52b3855ee948f | 2b81098d27196f39cc66c16ee8c4fcc99017f6bf | refs/heads/master | 2020-05-22T01:05:59.664422 | 2016-10-31T14:44:36 | 2016-10-31T14:44:36 | 62,927,780 | 0 | 2 | null | 2016-09-23T21:16:21 | 2016-07-09T02:14:13 | C++ | UTF-8 | C++ | false | false | 461 | cpp | #include "iui.hpp"
#include "core.hpp"
///
/// \brief Constructor
/// \param parent Parent for this QObject
///
IUI::IUI
(
QObject * core
)
: QObject( core )
{
// get a pointer to the core
core_ = ( Core * )( core ) ;
}
///
/// \brief Destructor
///
IUI::~IUI
()
{
// release the core
core_ = nullptr ;
}
///
/// \brief Slot to run an interface
///
void
IUI::run
()
{
// launch the interface
process() ;
// emit the stop signal
emit finished() ;
}
| [
"david.feraud@nist.gov"
] | david.feraud@nist.gov |
26763a2a64e3302d50e49701e41c9989265b5c1e | 817dc9bebf0d278fcf474f31a77cb23ada61056c | /QL/Common/CommonInclude/Global/Macro/rnfile.h | f96d3975f6a6f9f6dcfd6e6b5bea2f0ad09dd1e1 | [] | no_license | dudugi/NewForTortoise | 6f7d82cea00b49af3c38f1e332937ce3edf894b4 | 685ba32e8d7ee16c22f115b681a21f3d4e3fddf8 | refs/heads/master | 2022-02-08T11:56:42.102049 | 2022-01-25T07:02:47 | 2022-01-25T07:02:47 | 196,016,007 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 29,906 | h | #pragma once
/********************************************************************
// 作者: linyp
// CopyRight(c) 2010 Burnon All Rights Reserved
// 创建时间: 2014/04/17 15:08
// 类描述: 文件操作相关
// 修改时间:
// 修改目的:
*********************************************************************/
#include "rnstring.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <cstdlib>
#include <map>
using namespace std;
namespace RnFile
{//文件操作
//************************************
// 函数名: [GetFileOnPath]
// 返回值: [std::vector<CString>]
// 参数: [CString strExt]
// 函数描述:获取当前文件夹下指定后缀的所有文件,不包括子文件,输入后缀为空的情况下返回空
// 作者: linyp 2016/02/25 16:34
// 修改时间:
// 修改目的:
//************************************
inline std::vector<CString> GetFileOnPath(CString strPath,CString strExt)
{
std::vector<CString> vecFileName;
if (strExt.IsEmpty())
{
return vecFileName;
}
CFileFind finder;
// build a string with wildcards
CString strWildcard = strPath + _T("//*.") + strExt;
// start working for files
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
if (finder.IsDots())
continue;
vecFileName.push_back(finder.GetFileName());
}
return vecFileName;
}
//文件名操作相关
/*-------------------------------------------------------------------
-@brief [获取文件名,去掉目录和后缀]
-
-[函数详细描述]
-@n<b>函数名称</b> : GetNameWithoutDirExt
-@n@param const tstring & str : [全路径名]
-@return [结果文件名]
-@see [参见函数]
-@n<b>作者</b> :
-@n<b>创建时间</b> : 2009-3-17 17:46:25
-@version 修改者 时间 描述@n
-@n 2009-03-17 [描述]
--------------------------------------------------------------------*/
inline tstring GetNameWithoutDirExt(const tstring& str)
{
//最后一个点号
int nPointPos = static_cast<int>( str.find_last_of(STR_POINT) );
//最后一个斜杠
int nLastSlant = static_cast<int>( str.find_last_of(STR_SLANT) );
int nStart = nLastSlant + 1;
int nLength = nPointPos - nLastSlant - 1;
tstring strTest = str.substr(nStart, nLength);
return strTest;
}
/*-------------------------------------------------------------------
-@brief [获得大写的文件扩展名]
-
-[函数详细描述]
-@n<b>函数名称</b>: GetFileNameExtUpper
-@n@param std ::string & strFile : [参数描述]
-@return [返回值描述]
-@see [参见函数]
-@n<b>作者</b> :
-@n<b>创建时间</b>: 2009-1-12 13:21:08
-@version 修改者 时间 描述@n
-@n 2009-01-12 [描述]
--------------------------------------------------------------------*/
inline tstring GetFileNameExtUpper( tstring &strFile )
{
int nPoint = static_cast<int>( strFile.find_last_of( _T('.') ) );
int nAll = static_cast<int>( strFile.length() );
tstring strFormat = strFile.substr( nPoint + 1, nAll-nPoint); //加1越过点号
CString strUpper = strFormat.c_str();
strUpper.MakeUpper();
strFormat = strUpper.GetBuffer();
strUpper.ReleaseBuffer();
return strFormat;
}
/*************************************
/* Method: GetModulePathFile
/* Returns: CString
/* Parameter: CString strFileName :文件名称
/* author: JiangXh
/* Modifier:
/* Last Modified: 2010/05/21 15:15
/* Purpose: 获得和EXE文件在同一目录下的文件全路径
/*************************************/
inline CString GetModulePathFile(CString strFileName)
{
TCHAR szModuleName[MAX_PATH] = {0};
GetModuleFileName(NULL, szModuleName , MAX_PATH);
CString strModuleName;
strModuleName.Format(_T("%s"), szModuleName);
int iPos = strModuleName.ReverseFind('\\');
int iLen = strModuleName.GetLength();
strModuleName = strModuleName.Left(iPos + 1);
CString strRetFilePath = strModuleName + strFileName;
return strRetFilePath;
}
//获得文件名,不包括扩展名
inline CString MyGetFileName(CString strPathName,CString strExt = L"")
{
ASSERT(AfxIsValidString(strPathName));
//start Duchen 2016/04/17 17:59 dc170417
strPathName.Replace(_T("/"), _T("\\"));
//end Duchen 2016/04/17 17:59 dc170417
CString strFileName;
int nPathSepPos = strPathName.ReverseFind('\\');
if (-1 == nPathSepPos)
{//没有斜杠号
strFileName = strPathName;
}
else
{
strFileName = strPathName.Right(strPathName.GetLength() - nPathSepPos - 1);
}
//linyp 新增判断后缀名的逻辑,如果面位置的刚好为提供的后缀名称则剔除后缀返回,否则不剔除后缀
if(strExt != L"" )
{
int suffixPos = strPathName.ReverseFind('.');
CString strSuffixName = (-1 != suffixPos) ? strPathName.Right(strPathName.GetLength() -suffixPos ):strPathName;
//后缀一致返回0 返回不为0说明后缀不一致 不需要剔除后缀处理
if(0 != strSuffixName.CompareNoCase(strExt))
{
return strFileName;
}
}
int nDotPos = strFileName.ReverseFind('.'); //最后一个Dot的位置
if (nDotPos != -1)
{
strFileName = strFileName.Left(nDotPos); //最后一个Dot前的字符串
}
return strFileName;
}
//获得包括扩展名的文件名
inline CString MyGetFileNameWithExt(CString strPathName)
{
CString strFileName;
int nPathSepPos = strPathName.ReverseFind('\\');
strFileName = strPathName.Right(strPathName.GetLength() - nPathSepPos - 1);
return strFileName;
}
//获得扩展名
inline CString MyGetFileExtName(CString strFileName)
{
ASSERT(AfxIsValidString(strFileName));
CString strExtname;
int nExtPos = strFileName.ReverseFind('.');
if (-1 == nExtPos)
{//没有后缀名
return _T("");
}
strExtname = strFileName.Right(strFileName.GetLength() - nExtPos -1);
return strExtname;
}
//获得文件路径
inline CString MyGetFilePath(CString strFilePathName)
{
ASSERT(AfxIsValidString(strFilePathName));
CString strPath;
int nSepPos = strFilePathName.ReverseFind('\\');
int nSepPos2 = strFilePathName.ReverseFind('/');
if (nSepPos2>nSepPos)
{
nSepPos = nSepPos2;
}
strPath = strFilePathName.Left(nSepPos);
return strPath;
}
//确保路径有包括反斜杆
inline void MyAppendOppSlash(CString& strPath)
{
int nSlashPos = strPath.ReverseFind('\\');
int nLen = strPath.GetLength() - 1;
if (nSlashPos != nLen)
{
strPath.AppendChar('\\');
}
}
/**
* @brief [函数简要描述]
* 根据绝对路径获得文件的相对路径,(为了效率不判断strAbsPath是否是strFileFullPathName的子串,使用函数者需确保 strFileFullPathName.Find(strAbsPath) == 0)
* [函数详细描述]
* @n<b>函数名称</b> : MyGetRelativePath
* @n@param CString strAbsPath : [绝对路径]
* @param CString strFileFullPathName : [文件的全路径名]
* @return [相对路径]
* @see [参见函数]
* @n<b>作者</b> :
* @n<b>创建时间</b> : 2009-6-29 16:33:24
* @version 修改者 时间 描述@n
* @n [修改者] 2009-06-29 [描述]
*/
inline CString MyGetRelativePath(CString strAbsPath, CString strFileFullPathName)
{
ASSERT(strFileFullPathName.Find(strAbsPath) == 0);
CString strAbsFilePath;
strAbsFilePath= MyGetFilePath(strFileFullPathName);
strAbsFilePath.Delete(0, strAbsPath.GetLength());
return strAbsFilePath;
}
//获得父文件夹,如果自身是硬盘分区的话,返回空字符串
inline CString MyGetParenteDir(CString strSubDir)
{
MyAppendOppSlash(strSubDir);
CString strPath;
strPath.Empty();
int nSepPos = strSubDir.ReverseFind('\\');
if (nSepPos == -1)
{
return strSubDir;
}
strSubDir = strSubDir.Left(nSepPos);
nSepPos = strSubDir.ReverseFind('\\');
if (nSepPos == -1)
{
return strSubDir;
}
strPath = strSubDir.Left(nSepPos);
return strPath;
}
//获取我的文档路径
inline CString MyGetMyDocumentPath()
{
//文档保存路径默认路径为我的文档
TCHAR szDocument[MAX_PATH]={0};
TCHAR m_lpszDefaultDir[MAX_PATH] = {0};
LPITEMIDLIST pidl=NULL;
SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl);
if (pidl&&SHGetPathFromIDList(pidl,szDocument))
{
GetShortPathName(szDocument,m_lpszDefaultDir,_MAX_PATH);
}
CString strDocPath = szDocument;
return strDocPath;
}
//检查文件是否存在
inline BOOL IsFileExist(CString &strFilePathName)
{
//00 只判断是否存在
//02 只判断是否有写权限
//04 只判断是否有读权限
//06 判断是否有读并且有写权限
//文件存在
if(_waccess(strFilePathName.GetBuffer(), 0) == 0)
{
strFilePathName.ReleaseBuffer();
return TRUE;
}
strFilePathName.ReleaseBuffer();
return FALSE;
}
//检查文件是否存在并且可以读
inline BOOL IsFileExistCanRead(CString &strFilePathName)
{
//00 只判断是否存在
//02 只判断是否有写权限
//04 只判断是否有读权限
//06 判断是否有读并且有写权限
//文件存在
if(_waccess(strFilePathName.GetBuffer(), 04) == 0)
{
strFilePathName.ReleaseBuffer();
return TRUE;
}
strFilePathName.ReleaseBuffer();
return FALSE;
}
//检查文件是否存在并且可以读
inline BOOL IsFileExistCanReadWrite(CString &strFilePathName)
{
//00 只判断是否存在
//02 只判断是否有写权限
//04 只判断是否有读权限
//06 判断是否有读并且有写权限
//文件存在
if(_waccess(strFilePathName.GetBuffer(), 06) == 0)
{
strFilePathName.ReleaseBuffer();
return TRUE;
}
strFilePathName.ReleaseBuffer();
return FALSE;
}
//函数作用
//该函数的作用是检查指定目录是否存在,如果不存在则创建整个Dirpath所表示的整个目录。
//参数
//要检查的目录名。如果是路径不是文件名,需以 '\' 结尾。
//返回值
//如果目录存在,返回TRUE;如果不存在但全部路径创建成功,返回TRUE;
//如果不存在且创建失败,返回FALSE。
inline BOOL WINAPI MakeSureDirectoryPathExists(LPCTSTR pszDirPath)
{
LPTSTR p, pszDirCopy;
DWORD dwAttributes;
// Make a copy of the string for editing.
__try
{
pszDirCopy = (LPTSTR)RnString::_tCharAlloc(lstrlen(pszDirPath) + 1);
if(pszDirCopy == NULL)
return FALSE;
lstrcpy(pszDirCopy, pszDirPath);
p = pszDirCopy;
// If the second character in the path is "\", then this is a UNC
// path, and we should skip forward until we reach the 2nd \ in the path.
if((*p == TEXT('\\')) && (*(p+1) == TEXT('\\')))
{
p++; // Skip over the first \ in the name.
p++; // Skip over the second \ in the name.
// Skip until we hit the first "\" (\\Server\).
while(*p && *p != TEXT('\\'))
{
p = CharNext(p);
}
// Advance over it.
if(*p)
{
p++;
}
// Skip until we hit the second "\" (\\Server\Share\).
while(*p && *p != TEXT('\\'))
{
p = CharNext(p);
}
// Advance over it also.
if(*p)
{
p++;
}
}
else if(*(p+1) == TEXT(':')) // Not a UNC. See if it's <drive>:
{
p++;
p++;
// If it exists, skip over the root specifier
if(*p && (*p == TEXT('\\')))
{
p++;
}
}
while(*p)
{
if(*p == TEXT('\\'))
{
*p = TEXT('\0');
dwAttributes = GetFileAttributes(pszDirCopy);
// Nothing exists with this name. Try to make the directory name and error if unable to.
if(dwAttributes == 0xffffffff)
{
if(!CreateDirectory(pszDirCopy, NULL))
{
if(GetLastError() != ERROR_ALREADY_EXISTS)
{
RnString::_tCharFree(pszDirCopy);
return FALSE;
}
}
}
else
{
if((dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
{
// Something exists with this name, but it's not a directory... Error
RnString::_tCharFree(pszDirCopy);
return FALSE;
}
}
*p = TEXT('\\');
}
p = CharNext(p);
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
// SetLastError(GetExceptionCode());
RnString::_tCharFree(pszDirCopy);
return FALSE;
}
RnString::_tCharFree(pszDirCopy);
return TRUE;
}
//删除一个文件夹下的所有内容以及自己本身
inline void MyDeleteDirectory(CString directory_path)
{
int nSlashPos = directory_path.ReverseFind('\\');
int nLen = directory_path.GetLength() - 1;
CString pathTmp = directory_path;
if (nSlashPos == nLen)
{
pathTmp = directory_path.Left(nLen);
}
CFileFind finder;
CString path;
path.Format(L"%s\\*.*",pathTmp);
BOOL bWorking = finder.FindFile(path);
while(bWorking){
bWorking = finder.FindNextFile();
if(finder.IsDirectory() && !finder.IsDots()){//处理文件夹
MyDeleteDirectory(finder.GetFilePath()); //递归删除文件夹
RemoveDirectory(finder.GetFilePath());
}
else{//处理文件
DeleteFile(finder.GetFilePath());
}
}
finder.Close();
RemoveDirectory(pathTmp);
}//end of func
//获取某磁盘的卷标 by WangZY 2015/08/17
//strPath: 盘符 如: "H:\\"
inline BOOL GetUDiskName(__in CString strPath,
__out CString &strUDiskName)
{
DWORD dwVolumeSerialNumber;
DWORD dwMaximumComponentLength;
DWORD dwFileSystemFlags;
TCHAR szFileSystemNameBuffer[MAX_PATH]; // #define BUF 1024
TCHAR szDirveName[MAX_PATH];
BOOL bRet = GetVolumeInformation(strPath,
szDirveName,
MAX_PATH,
&dwVolumeSerialNumber,
&dwMaximumComponentLength,
&dwFileSystemFlags,
szFileSystemNameBuffer,
MAX_PATH);
strUDiskName = szDirveName;
return bRet;
}
inline LPCTSTR GetFilterString(CString& sFilter)
{
LPTSTR psz = sFilter.GetBuffer(0);
LPCTSTR pszRet = psz;
while ( '\0' != *psz )
{
if ( '|' == *psz )
*psz++ = '\0';
else
psz = CharNext ( psz );
}
return pszRet;
}
//区分U盘与软盘相关 by WangZY 2015/10/23
#include <Winioctl.h>
#define MEDIA_INFO_SIZE sizeof(GET_MEDIA_TYPES)+15*sizeof(DEVICE_MEDIA_INFO)
inline BOOL GetDriveGeometry(const TCHAR * filename, DISK_GEOMETRY * pdg)
{
HANDLE hDevice; // 设备句柄
BOOL bResult; // DeviceIoControl的返回结果
GET_MEDIA_TYPES *pmt; // 内部用的输出缓冲区
DWORD dwOutBytes; // 输出数据长度
// 打开设备
hDevice = ::CreateFile(filename, // 文件名
GENERIC_READ, // 软驱需要读盘
FILE_SHARE_READ | FILE_SHARE_WRITE, // 共享方式
NULL, // 默认的安全描述符
OPEN_EXISTING, // 创建方式
0, // 不需设置文件属性
NULL); // 不需参照模板文件
if (hDevice == INVALID_HANDLE_VALUE)
{
// 设备无法打开...
return FALSE;
}
// 用IOCTL_DISK_GET_DRIVE_GEOMETRY取磁盘参数
bResult = ::DeviceIoControl(hDevice, // 设备句柄
IOCTL_DISK_GET_DRIVE_GEOMETRY, // 取磁盘参数
NULL, 0, // 不需要输入数据
pdg, sizeof(DISK_GEOMETRY), // 输出数据缓冲区
&dwOutBytes, // 输出数据长度
(LPOVERLAPPED)NULL); // 用同步I/O
// 如果失败,再用IOCTL_STORAGE_GET_MEDIA_TYPES_EX取介质类型参数
if (!bResult)
{
pmt = (GET_MEDIA_TYPES *)new BYTE[MEDIA_INFO_SIZE];
bResult = ::DeviceIoControl(hDevice, // 设备句柄
IOCTL_STORAGE_GET_MEDIA_TYPES_EX, // 取介质类型参数
NULL, 0, // 不需要输入数据
pmt, MEDIA_INFO_SIZE, // 输出数据缓冲区
&dwOutBytes, // 输出数据长度
(LPOVERLAPPED)NULL); // 用同步I/O
if (bResult)
{
// 注意到结构DEVICE_MEDIA_INFO是在结构DISK_GEOMETRY的基础上扩充的
// 为简化程序,用memcpy代替如下多条赋值语句:
// pdg->MediaType = (MEDIA_TYPE)pmt->MediaInfo[0].DeviceSpecific.DiskInfo.MediaType;
// pdg->Cylinders = pmt->MediaInfo[0].DeviceSpecific.DiskInfo.Cylinders;
// pdg->TracksPerCylinder = pmt->MediaInfo[0].DeviceSpecific.DiskInfo.TracksPerCylinder;
// ... ...
::memcpy(pdg, pmt->MediaInfo, sizeof(DISK_GEOMETRY));
}
delete pmt;
}
// 关闭设备句柄
::CloseHandle(hDevice);
return (bResult);
}
//判断是否是U盘 by WangZY 2015/10/23
inline BOOL IsU_Disk(CString strDrivePath)
{
DISK_GEOMETRY dg;
// TCHAR szPath[100] = _T("////.//");
// ::_tcscat(szPath,sDrivePath);
// int nSize = ::_tcslen(szPath);
// szPath[nSize-1] = '/0';
CString strName;
strName = _T("//./");
strName += strDrivePath.Left(2);
BOOL bRetVal = GetDriveGeometry(strName.GetBuffer(0),&dg);
if(dg.MediaType == RemovableMedia)
{
//这就是U盘
return TRUE;
}
return FALSE;
}
//判断目录是否存在 by WangZY 2016/05/31
inline BOOL FolderExist(CString strPath)
{
WIN32_FIND_DATA wfd;
BOOL rValue = FALSE;
HANDLE hFind = FindFirstFile(strPath, &wfd);
if ((hFind!=INVALID_HANDLE_VALUE)
&&(wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
{
rValue = TRUE;
}
FindClose(hFind);
return rValue;
}
inline int GetTempPathNew(CString &strTmpPath)
{
//获取临时目录 by WangZY 2016/05/31
DWORD dwLen = 0;
TCHAR szBuf[MAX_PATH] = {0};
dwLen = GetTempPath(MAX_PATH-1, szBuf);
if (dwLen > MAX_PATH -1)
{
TCHAR *pszBuf = new TCHAR[dwLen+1];
memset(pszBuf,0,sizeof(TCHAR)*(dwLen+1));
dwLen = GetTempPath(dwLen, pszBuf);
strTmpPath = pszBuf;
delete []pszBuf;
pszBuf = NULL;
return -1;
}
else if (dwLen <= 0)
{
strTmpPath = _T("");
int nError = GetLastError();
return nError;
}
else
{
strTmpPath = szBuf;
return 0;
}
}
#pragma region ini配置文件读写UNICODE版本
//remove all blank space
static CString &trimString(CString &str)
{
str.Trim(_T(" "));
return str;
}
static bool readLineW(CFile &file, CStringW &str)
{
WCHAR wchar;
UINT ret = 0;
std::wstring buf;
buf.reserve(40);
while(1)
{
ret = file.Read(&wchar, sizeof(wchar));
if(ret > 0)
{
if(ret != sizeof(wchar))
{
return false;
}
if(wchar == L'\r')
{
ret = file.Read(&wchar, sizeof(wchar));
if(ret != sizeof(wchar))
{
return false;
}
if(wchar != L'\n')
{
return false;
}
str = buf.c_str();
return true;
}
else if(wchar == L'\n')
{
str = buf.c_str();
return true;
}
else
{
buf.push_back(wchar);
}
}
else //if(ret == 0)
{
if(buf.size() == 0)
{
return false;
}
else
{
str = buf.c_str();
return true;
}
}
}
}
class ININode
{
public:
ININode(CString root, CString key, CString value)
{
this->root = root;
this->key = key;
this->value = value;
}
CString root;
CString key;
CString value;
};
class SubNode
{
public:
void InsertElement(CString key, CString value)
{
sub_node.insert(pair<CString, CString>(key, value));
}
map<CString, CString> sub_node;
};
inline char* Ansi2Unicode(const char* str,int &iLength)
{
int dwUnicodeLen = MultiByteToWideChar(CP_ACP,0,str,-1,NULL,0);
if(!dwUnicodeLen)
{
return _strdup(str);
}
size_t num = dwUnicodeLen*sizeof(wchar_t);
iLength = num;
wchar_t *pwText = (wchar_t*)malloc(num);
memset(pwText,0,num);
MultiByteToWideChar(CP_ACP,0,str,-1,pwText,dwUnicodeLen);
return (char*)pwText;
}
class INIParser
{
public:
int ReadINI(CString path)
{
{
CFile file;
if(!file.Open(path, CFile::modeReadWrite ))
return 0;
CString str_line = _T("");
CString str_root = _T("");
vector<ININode> vec_ini;
USHORT s = 0;
file.Read(&s, sizeof(s));
if(s != 0xfeff)
{
//非UNICODE编码INI配置文件转换为UNICODE编码
std::vector<char> byte;
byte.resize(file.GetLength());
file.SeekToBegin();
file.Read(&(byte[0]),file.GetLength());
int iNewLength = 0;
char *pNewByte = Ansi2Unicode(&(byte[0]),iNewLength);
file.SeekToBegin();
USHORT head = 0xfeff;
file.Write(&head, sizeof(head));
file.Write(pNewByte,iNewLength);
file.SeekToBegin();
file.Read(&s, sizeof(s));
free(pNewByte);
}
while(readLineW(file, str_line))
{
int left_pos = 0;
int right_pos = 0;
int equal_div_pos = 0;
CString str_key = _T("");
CString str_value = _T("");
if((-1 != (left_pos = str_line.Find(_T("[")))) && (-1 != (right_pos = str_line.Find(_T("]")))))
{
str_root = str_line.Mid(left_pos + 1, right_pos-1);
}
if(-1 != (equal_div_pos = str_line.Find(_T("="))))
{
str_key = str_line.Mid(0, equal_div_pos);
str_value = str_line.Mid(equal_div_pos+1, str_line.GetLength()-1);
str_key = trimString(str_key);
str_value = trimString(str_value);
}
if((!str_root.IsEmpty()) && (!str_key.IsEmpty()) && (!str_value.IsEmpty()))
{
ININode ini_node(str_root, str_key, str_value);
vec_ini.push_back(ini_node);
}
}
map<CString, CString> map_tmp;
for(vector<ININode>::iterator itr = vec_ini.begin(); itr != vec_ini.end(); ++itr)
{
map_tmp.insert(pair<CString, CString>(itr->root, ""));
}
SubNode sn;
for(map<CString, CString>::iterator itr = map_tmp.begin(); itr != map_tmp.end(); ++itr)
{
sn.sub_node.clear();
for(vector<ININode>::iterator sub_itr = vec_ini.begin(); sub_itr != vec_ini.end(); ++sub_itr)
{
if(sub_itr->root == itr->first)
{
sn.InsertElement(sub_itr->key, sub_itr->value);
}
}
map_ini.insert(pair<CString, SubNode>(itr->first, sn));
}
return 1;
}
}
CString GetValue(CString root, CString key) const
{
{
map<CString, SubNode>::const_iterator itr = map_ini.find(root);
if (itr==map_ini.end())
{
return _T("");
}
map<CString, CString>::const_iterator sub_itr = itr->second.sub_node.find(key);
if (sub_itr==itr->second.sub_node.end())
{
return _T("");
}
if(!(sub_itr->second).IsEmpty())
return sub_itr->second;
return _T("");
}
}
int GetThePrivateProfileInt(const CString &strGrpSectionName, const CString &strKeyName, int iDefaultValue) const
{
const CString &root = strGrpSectionName;
const CString &key = strKeyName;
map<CString, SubNode>::const_iterator itr = map_ini.find(root);
if (itr == map_ini.end())
{
return iDefaultValue;
}
map<CString, CString>::const_iterator sub_itr = itr->second.sub_node.find(key);
if (sub_itr == itr->second.sub_node.end())
{
return iDefaultValue;
}
if(!(sub_itr->second).IsEmpty())
{
int b =_ttoi(sub_itr->second);
return b;
}
return iDefaultValue;
}
void GetThePrivateProfileString(const CString &strRoot, const CString &strKeyName, const CString &strDefault,
CString *pStrReturnedString, DWORD nSize) const
{
if(!pStrReturnedString)
return;
map<CString, SubNode>::const_iterator itr = map_ini.find(strRoot);
if (itr == map_ini.end())
{
*pStrReturnedString = strDefault;
return;
}
map<CString, CString>::const_iterator sub_itr = itr->second.sub_node.find(strKeyName);
if (sub_itr == itr->second.sub_node.end())
{
*pStrReturnedString = strDefault;
return;
}
if(!(sub_itr->second).IsEmpty())
{
*pStrReturnedString = sub_itr->second;
return;
}
*pStrReturnedString = strDefault;
return;
}
vector<ININode>::size_type GetSize() const {return map_ini.size();}
vector<ININode>::size_type SetValue(CString root, CString key, CString value)
{
map<CString, SubNode>::iterator itr = map_ini.find(root);
if(map_ini.end() != itr)
//itr->second.sub_node.insert(pair<CString, CString>(key, value));
itr->second.sub_node[key] = value;
else
{
SubNode sn;
sn.InsertElement(key, value);
map_ini.insert(pair<CString, SubNode>(root, sn));
}
return map_ini.size();
}
vector<ININode>::size_type SetValue(CString root, CString key, int iValue)
{
CString value = L"";
value.Format(_T("%d"),iValue);
map<CString, SubNode>::iterator itr = map_ini.find(root);
if(map_ini.end() != itr)
//itr->second.sub_node.insert(pair<CString, CString>(key, value));
itr->second.sub_node[key] = value;
else
{
SubNode sn;
sn.InsertElement(key, value);
map_ini.insert(pair<CString, SubNode>(root, sn));
}
return map_ini.size();
}
int WriteINI(CString path)
{
CFile file;
if(FALSE == file.Open(path ,CFile::modeWrite | CFile::modeCreate))
return -1;
USHORT s = 0xfeff;
file.Write(&s, sizeof(s));
for(map<CString, SubNode>::iterator itr = map_ini.begin(); itr != map_ini.end(); ++itr)
{
CString tmp;
tmp.Format(_T("[%s]\n"), itr->first);
int len = tmp.GetLength();
file.Write(tmp, len * sizeof(TCHAR));
for(map<CString, CString>::iterator sub_itr = itr->second.sub_node.begin(); sub_itr != itr->second.sub_node.end(); ++sub_itr)
{
CString tmp;
tmp.Format(_T("%s=%s\n"), sub_itr->first, sub_itr->second);
int len = tmp.GetLength();
file.Write(tmp, len * sizeof(TCHAR));
}
}
file.Close();
return 1;
}
void Clear(){map_ini.clear();}
private:
map<CString, SubNode> map_ini;
};
#pragma endregion
}
| [
"du_chen_hi@126.com"
] | du_chen_hi@126.com |
925cf5052a8a53fb77cc0a4ce4f025f40d9c8dd6 | c02c335c9e5663655a803cd5bb4bf976870cf055 | /opensubdiv-sys/osd-capi/far/primvar_refiner.cpp | b12af78bd71ef3cdc3ce3da63b6553ebbba428dd | [
"Apache-2.0"
] | permissive | anderslanglands/opensubdiv-rs | bcabf011caf14d7a9e9a6951f19d44ab738a6d03 | 46f19f56db1c35ab9f768e16ece8c40310bf13cd | refs/heads/master | 2020-06-24T23:20:47.719309 | 2019-08-27T00:02:42 | 2019-08-27T00:02:42 | 199,123,067 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,651 | cpp | #include <opensubdiv/far/primvarRefiner.h>
#include <opensubdiv/sdc/options.h>
#include <opensubdiv/sdc/types.h>
#include <stdio.h>
typedef OpenSubdiv::Far::PrimvarRefiner PrimvarRefiner;
typedef OpenSubdiv::Far::TopologyRefiner TopologyRefiner;
template <int N> struct Primvar {
float v[N];
void Clear() {
for (int i = 0; i < N; ++i) {
v[i] = 0.0f;
}
}
void AddWithWeight(const Primvar& p, float weight) {
for (int i = 0; i < N; ++i) {
v[i] += p.v[i] * weight;
}
}
};
extern "C" {
PrimvarRefiner* PrimvarRefiner_create(TopologyRefiner* tr) {
return new PrimvarRefiner(*tr);
}
void PrimvarRefiner_destroy(PrimvarRefiner* pr) { delete pr; }
const TopologyRefiner* PrimvarRefiner_GetTopologyRefiner(PrimvarRefiner* pr) {
return &pr->GetTopologyRefiner();
}
void PrimvarRefiner_Interpolate(PrimvarRefiner* pr, int num_elements, int level,
float* src, float* dst) {
Primvar<3>* dst3;
switch (num_elements) {
case 3:
dst3 = (Primvar<3>*)dst;
pr->Interpolate(level, (Primvar<3>*)src, dst3);
break;
default:
printf("Invalid num elements for Interpolate: %d\n", num_elements);
std::terminate();
}
}
void PrimvarRefiner_InterpolateVarying(PrimvarRefiner* pr, int num_elements,
int level, float* src, float* dst) {
Primvar<3>* dst3;
switch (num_elements) {
case 3:
dst3 = (Primvar<3>*)dst;
pr->InterpolateVarying(level, (Primvar<3>*)src, dst3);
break;
default:
printf("Invalid num elements for Interpolate: %d\n", num_elements);
std::terminate();
}
}
void PrimvarRefiner_InterpolateFaceUniform(PrimvarRefiner* pr, int num_elements,
int level, float* src, float* dst) {
Primvar<3>* dst3;
switch (num_elements) {
case 3:
dst3 = (Primvar<3>*)dst;
pr->InterpolateFaceUniform(level, (Primvar<3>*)src, dst3);
break;
default:
printf("Invalid num elements for Interpolate: %d\n", num_elements);
std::terminate();
}
}
void PrimvarRefiner_InterpolateFaceVarying(PrimvarRefiner* pr, int num_elements,
int level, float* src, float* dst) {
Primvar<3>* dst3;
switch (num_elements) {
case 3:
dst3 = (Primvar<3>*)dst;
pr->InterpolateFaceVarying(level, (Primvar<3>*)src, dst3);
break;
default:
printf("Invalid num elements for Interpolate: %d\n", num_elements);
std::terminate();
}
}
} | [
"anderslanglands@gmail.com"
] | anderslanglands@gmail.com |
903c9908316a4b0fc3ebf8d781baed68f2894672 | 0db10f9d35a9cea4165ffbe62cf7f19cae252056 | /src/nnet3/nnet-discriminative-example.h | 3dd91c2c8c250128794c6f869087fa8ed8327b43 | [
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | nichongjia/kaldi | 4da4b985f8fe3b484d60d8929d4b9046f8174372 | c7a2331e593da84ad43d13f902b8c6971a1f5bb1 | refs/heads/master | 2021-01-17T16:08:46.590348 | 2017-07-21T07:09:48 | 2017-07-21T07:09:48 | 72,055,985 | 1 | 0 | null | 2016-10-27T00:23:45 | 2016-10-27T00:23:45 | null | UTF-8 | C++ | false | false | 9,097 | h | // nnet3/nnet-discriminative-example.h
// Copyright 2012-2015 Johns Hopkins University (author: Daniel Povey)
// 2014-2015 Vimal Manohar
// See ../../COPYING for clarification regarding multiple authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
// WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABLITY OR NON-INFRINGEMENT.
// See the Apache 2 License for the specific language governing permissions and
// limitations under the License.
#ifndef KALDI_NNET3_NNET_DISCRIMINATIVE_EXAMPLE_H_
#define KALDI_NNET3_NNET_DISCRIMINATIVE_EXAMPLE_H_
#include "nnet3/nnet-nnet.h"
#include "nnet3/nnet-computation.h"
#include "util/table-types.h"
#include "nnet3/discriminative-supervision.h"
#include "nnet3/nnet-example.h"
#include "hmm/posterior.h"
#include "hmm/transition-model.h"
namespace kaldi {
namespace nnet3 {
// Glossary: mmi = Maximum Mutual Information,
// mpfe = Minimum Phone Frame Error
// smbr = State-level Minimum Bayes Risk
// This file relates to the creation of examples for discriminative training
struct NnetDiscriminativeSupervision {
// the name of the output in the neural net; in simple setups it
// will just be "output".
std::string name;
// The indexes that the output corresponds to. The size of this vector will
// be equal to supervision.num_sequences * supervision.frames_per_sequence.
// Be careful about the order of these indexes-- it is a little confusing.
// The indexes in the 'index' vector are ordered as: (frame 0 of each sequence);
// (frame 1 of each sequence); and so on. But in the 'supervision' object,
// the lattice contains (sequence 0; sequence 1; ...). So reordering is needed.
// This is done to make the code similar that for the 'chain' model.
std::vector<Index> indexes;
// The supervision object, containing the numerator and denominator
// lattices.
discriminative::DiscriminativeSupervision supervision;
// This is a vector of per-frame weights, required to be between 0 and 1,
// that is applied to the derivative during training (but not during model
// combination, where the derivatives need to agree with the computed objf
// values for the optimization code to work). The reason for this is to more
// exactly handle edge effects and to ensure that no frames are
// 'double-counted'. The order of this vector corresponds to the order of
// the 'indexes' (i.e. all the first frames, then all the second frames,
// etc.)
// If this vector is empty it means we're not applying per-frame weights,
// so it's equivalent to a vector of all ones. This vector is written
// to disk compactly as unsigned char.
Vector<BaseFloat> deriv_weights;
// Use default assignment operator
NnetDiscriminativeSupervision() { }
// Initialize the object from an object of type discriminative::Supervision,
// and some extra information.
// Note: you probably want to set 'name' to "output".
// 'first_frame' will often be zero but you can choose (just make it
// consistent with how you numbered your inputs), and 'frame_skip' would be 1
// in a vanilla setup, but 3 in the case of 'chain' models
NnetDiscriminativeSupervision(const std::string &name,
const discriminative::DiscriminativeSupervision &supervision,
const Vector<BaseFloat> &deriv_weights,
int32 first_frame,
int32 frame_skip);
NnetDiscriminativeSupervision(const NnetDiscriminativeSupervision &other);
void Write(std::ostream &os, bool binary) const;
void Read(std::istream &is, bool binary);
void Swap(NnetDiscriminativeSupervision *other);
void CheckDim() const;
bool operator == (const NnetDiscriminativeSupervision &other) const;
};
/// NnetDiscriminativeExample is like NnetExample, but specialized for
/// sequence training.
struct NnetDiscriminativeExample {
/// 'inputs' contains the input to the network-- normally just it has just one
/// element called "input", but there may be others (e.g. one called
/// "ivector")... this depends on the setup.
std::vector<NnetIo> inputs;
/// 'outputs' contains the sequence output supervision. There will normally
/// be just one member with name == "output".
std::vector<NnetDiscriminativeSupervision> outputs;
void Write(std::ostream &os, bool binary) const;
void Read(std::istream &is, bool binary);
void Swap(NnetDiscriminativeExample *other);
// Compresses the input features (if not compressed)
void Compress();
NnetDiscriminativeExample() { }
NnetDiscriminativeExample(const NnetDiscriminativeExample &other);
bool operator == (const NnetDiscriminativeExample &other) const {
return inputs == other.inputs && outputs == other.outputs;
}
};
/**
Appends the given vector of examples (which must be non-empty) into
a single output example.
Intended to be used when forming minibatches for neural net training. If
'compress' it compresses the output features (recommended to save disk
space).
Note: the input is left as it was at the start, but it is temporarily
changed inside the function; this is a trick to allow us to use the
MergeExamples() routine while avoiding having to rewrite code.
*/
void MergeDiscriminativeExamples(
bool compress,
std::vector<NnetDiscriminativeExample> *input,
NnetDiscriminativeExample *output);
// called from MergeDiscriminativeExamples, this function merges the Supervision
// objects into one. Requires (and checks) that they all have the same name.
void MergeSupervision(
const std::vector<const NnetDiscriminativeSupervision*> &inputs,
NnetDiscriminativeSupervision *output);
/** Shifts the time-index t of everything in the input of "eg" by adding
"t_offset" to all "t" values-- but excluding those with names listed in
"exclude_names", e.g. "ivector". This might be useful if you are doing
subsampling of frames at the output, because shifted examples won't be quite
equivalent to their non-shifted counterparts. "exclude_names" is a vector
of names of nnet inputs that we avoid shifting the "t" values of-- normally
it will contain just the single string "ivector" because we always leave t=0
for any ivector.
Note: input features will be shifted by 'frame_shift', and indexes in the
supervision in (eg->output) will be shifted by 'frame_shift' rounded to the
closest multiple of the frame subsampling factor (e.g. 3). The frame
subsampling factor is worked out from the time spacing between the indexes
in the output. */
void ShiftDiscriminativeExampleTimes(int32 frame_shift,
const std::vector<std::string> &exclude_names,
NnetDiscriminativeExample *eg);
/**
This sets to zero any elements of 'egs->outputs[*].deriv_weights' that correspond
to frames within the first or last 'truncate' frames of the sequence (e.g. you could
set 'truncate=5' to set zero deriv-weight for the first and last 5 frames of the
sequence).
*/
void TruncateDerivWeights(int32 truncate,
NnetDiscriminativeExample *eg);
/** This function takes a NnetDiscriminativeExample and produces a
ComputationRequest.
Assumes you don't want the derivatives w.r.t. the inputs; if you do, you
can create the ComputationRequest manually. Assumes that if
need_model_derivative is true, you will be supplying derivatives w.r.t. all
outputs.
*/
void GetDiscriminativeComputationRequest(const Nnet &nnet,
const NnetDiscriminativeExample &eg,
bool need_model_derivative,
bool store_component_stats,
bool use_xent_regularization,
bool use_xent_derivative,
ComputationRequest *computation_request);
typedef TableWriter<KaldiObjectHolder<NnetDiscriminativeExample > > NnetDiscriminativeExampleWriter;
typedef SequentialTableReader<KaldiObjectHolder<NnetDiscriminativeExample > > SequentialNnetDiscriminativeExampleReader;
typedef RandomAccessTableReader<KaldiObjectHolder<NnetDiscriminativeExample > > RandomAccessNnetDiscriminativeExampleReader;
} // namespace nnet3
} // namespace kaldi
#endif // KALDI_NNET3_NNET_DISCRIMINATIVE_EXAMPLE_H_
| [
"nicj@i2r.a-star.edu.sg"
] | nicj@i2r.a-star.edu.sg |
8173baf9e5e50997cc08d6a6f279ab6f858cd910 | c0caed81b5b3e1498cbca4c1627513c456908e38 | /src/protocols/match/downstream/SecondaryMatcherToDownstreamResidue.fwd.hh | e9618f8de49e0f6c1f6e5c1e12f35055e798e755 | [] | no_license | malaifa/source | 5b34ac0a4e7777265b291fc824da8837ecc3ee84 | fc0af245885de0fb82e0a1144422796a6674aeae | refs/heads/master | 2021-01-19T22:10:22.942155 | 2017-04-19T14:13:07 | 2017-04-19T14:13:07 | 88,761,668 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,383 | hh | // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
// vi: set ts=2 noet:
//
// (c) Copyright Rosetta Commons Member Institutions.
// (c) This file is part of the Rosetta software suite and is made available under license.
// (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
// (c) For more information, see http://www.rosettacommons.org. Questions about this can be
// (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
/// @file protocols/match/downstream/SecondaryMatcherToDownstreamResidue.fwd.hh
/// @brief
/// @author Alex Zanghellini (zanghell@u.washington.edu)
/// @author Andrew Leaver-Fay (aleaverfay@gmail.com), porting to mini
#ifndef INCLUDED_protocols_match_downstream_SecondaryMatcherToDownstreamResidue_fwd_hh
#define INCLUDED_protocols_match_downstream_SecondaryMatcherToDownstreamResidue_fwd_hh
// Unit headers
// Utility headers
#include <utility/pointer/owning_ptr.hh>
namespace protocols {
namespace match {
namespace downstream {
class SecondaryMatcherToDownstreamResidue;
typedef utility::pointer::shared_ptr< SecondaryMatcherToDownstreamResidue > SecondaryMatcherToDownstreamResidueOP;
typedef utility::pointer::shared_ptr< SecondaryMatcherToDownstreamResidue const > SecondaryMatcherToDownstreamResidueCOP;
}
}
}
#endif
| [
"malaifa@yahoo.com"
] | malaifa@yahoo.com |
012c1302a324677d885823dbbf1eb0ab6e2c8517 | 88ae8695987ada722184307301e221e1ba3cc2fa | /chrome/browser/ash/phonehub/phone_hub_manager_factory.h | 43f7836a4dd08f0817e426e1c2ce0bcd1414b0f8 | [
"BSD-3-Clause"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 1,676 | h | // Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_PHONEHUB_PHONE_HUB_MANAGER_FACTORY_H_
#define CHROME_BROWSER_ASH_PHONEHUB_PHONE_HUB_MANAGER_FACTORY_H_
#include "base/memory/singleton.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
class Profile;
namespace ash {
namespace phonehub {
class PhoneHubManager;
class PhoneHubManagerFactory : public ProfileKeyedServiceFactory {
public:
// Returns the PhoneHubManager instance associated with |profile|. Null is
// returned if |profile| is not the primary Profile, if the kPhoneHub flag
// is disabled, or if the feature is prohibited by policy.
static PhoneHubManager* GetForProfile(Profile* profile);
static PhoneHubManagerFactory* GetInstance();
private:
friend struct base::DefaultSingletonTraits<PhoneHubManagerFactory>;
PhoneHubManagerFactory();
PhoneHubManagerFactory(const PhoneHubManagerFactory&) = delete;
PhoneHubManagerFactory& operator=(const PhoneHubManagerFactory&) = delete;
~PhoneHubManagerFactory() override;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
bool ServiceIsNULLWhileTesting() const override;
bool ServiceIsCreatedWithBrowserContext() const override;
void BrowserContextShutdown(content::BrowserContext* context) override;
void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) override;
};
} // namespace phonehub
} // namespace ash
#endif // CHROME_BROWSER_ASH_PHONEHUB_PHONE_HUB_MANAGER_FACTORY_H_
| [
"jengelh@inai.de"
] | jengelh@inai.de |
ccd38f0857825dbc3a9779fa90c9810b48b0bd63 | 7eafbceed38bd4ac9ef10003ef0bb0622064564b | /Exercises/Exercise-4/question-3/capture.cpp | 0440f320b083fc887637d1aca4e9bd7780d13451 | [] | no_license | AbikametCU/ECEN_5763-EMVIA- | e0cfbae57a48f0b546c11d18cdc9600a18f0f4d3 | 503629072aa0d0ff4e4f76cdac543f2964cf07d4 | refs/heads/master | 2022-01-19T14:55:07.367582 | 2019-07-29T04:33:29 | 2019-07-29T04:33:29 | 192,027,753 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,456 | cpp |
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;
Mat skeletal_transform(Mat src){
Mat temp;
Mat eroded;
Mat element = getStructuringElement(MORPH_CROSS, Size(3, 3));
Mat gray,binary,mfblur;
cvtColor(src, gray, CV_BGR2GRAY);
// show graymap of source image and wait for input to next step
// Use 70 negative for Moose, 150 positive for hand
//
// To improve, compute a histogram here and set threshold to first peak
//
// For now, histogram analysis was done with GIMP
//
threshold(gray, binary, 115, 255, CV_THRESH_BINARY);
binary = 255 - binary;
// show bitmap of source image and wait for input to next step
// To remove median filter, just replace blurr value with 1
medianBlur(binary, mfblur, 1);
// show median blur filter of source image and wait for input to next step
//imshow("mfblur", mfblur);
//waitKey();
// This section of code was adapted from the following post, which was
// based in turn on the Wikipedia description of a morphological skeleton
//
// http://felix.abecassis.me/2011/09/opencv-morphological-skeleton/
//
bool done;
int iterations=0;
Mat skel(mfblur.size(), CV_8UC1, Scalar(0));
do
{
erode(mfblur, eroded, element);
dilate(eroded, temp, element);
subtract(mfblur, temp, temp);
bitwise_or(skel, temp, skel);
eroded.copyTo(mfblur);
done = (countNonZero(mfblur) == 0);
iterations++;
} while (!done && (iterations < 100));
cout << "iterations=" << iterations << endl;
return skel;
}
int main( int argc, char** argv )
{
cvNamedWindow("Capture Example", CV_WINDOW_AUTOSIZE);
VideoCapture cap(0);
Mat frame,skel;
int frames_count = 0;
string image_name = "image_1";
int i=0;
while(1)
{
cap >> frame;
if(frame.empty()){
break;
}
frames_count++;
if(frames_count>300){
break;
}
skel = skeletal_transform(frame);
image_name = "image_"+to_string(i)+".pgm";
imshow("skeleton", skel);
//imwrite(image_name,skel);
char c = cvWaitKey(33);
if( c == 27 ) {
break;
}
i++;
}
//cvReleaseCapture(&capture);
cvDestroyWindow("Capture Example");
} | [
"aban7446@colorado.edu"
] | aban7446@colorado.edu |
e391998c4c6c7b604e50c671384c5ad70cff7453 | 93c4e7e85941796952833286f25eb6c1bee9b366 | /Arduino/sketch_nov15a.ino | 61798f628f634ebfc8c4edfceaf7012f55f32162 | [] | no_license | SzymonOzog/Bluetooth | b254a7e46e7aa48e7528c16dceb53bb05a070512 | d1b78009d25b54a826ea60bed4de3c1203f886d7 | refs/heads/master | 2020-09-25T05:30:39.765616 | 2020-06-18T10:29:42 | 2020-06-18T10:29:42 | 225,928,112 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,703 | ino | //Library Import
#include <SoftwareSerial.h>
#include "DHT.h"
DHT dht;
//Pin number to whitch we connected the sensor
#define DHT11_PIN 2
// Adres czujnika
int alarm_threshold = 0;
int temperature = 0;
int a;
//Declaring the port for bluetooth
SoftwareSerial Bluetooth(10, 11); //create Bluetooth instance for 10-RX 11-TX
int buffer_in[200];
int i=0;
int BluetoothDane; //Recieved data will be stored here
void setup() {
pinMode(5, OUTPUT);
while(!Serial); //start the transmission with the terminal
Serial.begin(9600);
dht.setup(DHT11_PIN);
Bluetooth.begin(9600); //start SerialSoftware with 9600 baud speed
Serial.println("Polaczyles sie z modulem Bluetooth HC-05");
}
void loop() {
a = dht.getTemperature();//untill the temperature will be checked
//the getStatusString funcition will always return TIMEOUT
if(dht.getStatusString() == "OK"){
temperature = dht.getTemperature();
}
if (temperature>alarm_threshold)
{
digitalWrite(5, HIGH);
}
else if(temperature<alarm_threshold)
{
digitalWrite(5, LOW);
}
if (Bluetooth.available()) //If there is data
{
i=0;
while (Bluetooth.available()>0) //Read data from HC-05
{
buffer_in[i]=Bluetooth.read(); //copy the data to the buffer
i++;
}
Serial.println(i);
for(int j=0;j<i-2;j++)
Serial.println(buffer_in[j]);
if (buffer_in[0]==1) //command 1 sets the alarm threshold
{
if (i>1)
{
if (buffer_in[1]!=0)
{
alarm_threshold=buffer_in[1];
Serial.print("Ustawiono alarm na : ");
Serial.println(alarm_threshold); //print info on serial monitor
} else
Serial.println("Wartość progu nie może być równa 0.");
}else
Serial.println("Błąd polecenia: za mała liczba bajtów");
}
else if (buffer_in[0]==2) //command 2 asks for current alarm threshold
{
Bluetooth.println(alarm_threshold); //send anwser
Serial.println("Wysłano alarm : ");
Serial.print(alarm_threshold); //print info on serial monitor
}
else if (buffer_in[0]==3) //command 3 asks for current temperature
{
Serial.println("Temperatura: ");
Serial.println(temperature);
Bluetooth.println(temperature);
}
}
delay(100); //wait 100ms
}
| [
"szymon.ozog@gmail.com"
] | szymon.ozog@gmail.com |
e5fa8e53b407b780d1b72e67dcdec3cebbaf75b9 | 85455876309135778cba6bbf16933ca514f457f8 | /2000/2014.cpp | 143be670e39b46f77b8e7858ccf84d05297b55f9 | [] | no_license | kks227/BOJ | 679598042f5d5b9c3cb5285f593231a4cd508196 | 727a5d5def7dbbc937bd39713f9c6c96b083ab59 | refs/heads/master | 2020-04-12T06:42:59.890166 | 2020-03-09T14:30:54 | 2020-03-09T14:30:54 | 64,221,108 | 83 | 19 | null | null | null | null | UTF-8 | C++ | false | false | 551 | cpp | #include <cstdio>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
int main(){
int K, N, P[100];
priority_queue<int, vector<int>, greater<int>> PQ;
scanf("%d %d", &K, &N);
for(int i=0; i<K; i++){
scanf("%d", P+i);
PQ.push(P[i]);
}
int prev = -1;
for(int i=0; i<N-1; i++){
int curr = PQ.top();
PQ.pop();
for(int j=0; j<K; j++){
long long temp = 1LL * curr * P[j];
if(temp < 1LL<<31) PQ.push(temp);
else break;
}
prev = curr;
while(prev == PQ.top()) PQ.pop();
}
printf("%d\n", PQ.top());
} | [
"wongrikera@nate.com"
] | wongrikera@nate.com |
0b0af186d206cbc0b72df1011aa989fe24f0f832 | 1f0fb1bc4810d65ac042f532a9c7056dfb0438a5 | /oopLab2_5.cpp | a8eb742087b7ceead13755c0cb3bf0f061dee8c9 | [] | no_license | jubayertalha/OOP_C_Plus_Plus | 48e847ad4ba3d304afe90e64b497ef219829fc05 | 42511e4df9e617dff9084c0734b77d4173de2404 | refs/heads/master | 2023-02-24T14:00:13.721653 | 2021-01-25T21:17:31 | 2021-01-25T21:17:31 | 332,818,403 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,903 | cpp | #include<iostream>
using namespace std;
class vehicle{
public:
static string vName,vColor;
static int noOfWheels, engineSize;
/*static void setVname(string n){
vName = n;
}
static void setVcolor(string c){
vColor = c;
}
static void setWheels(int w){
noOfWheels = w;
}
static void setEngine(int e){
engineSize = e;
}*/
static void displayVehicle(){
cout<<vName<<" has "<<noOfWheels<<" wheels"<<endl;
cout<<vName<<" has "<<engineSize<<" CC engine"<<endl;
}
};
string vehicle::vName = "BMW";
int vehicle::noOfWheels = 4;
int vehicle::engineSize = 1500;
class Bus:public vehicle{
public:
static void displayBus(){
cout<<vName<<" has "<<noOfWheels<<" wheels"<<endl;
cout<<vName<<" has "<<engineSize<<" CC engine"<<endl;
}
};
class Car:public vehicle{
public:
static void displayCar(){
cout<<vName<<" has "<<noOfWheels<<" wheels"<<endl;
cout<<vName<<" has "<<engineSize<<" CC engine"<<endl;
}
};
class Bike:public vehicle{
public:
static void displayBike(){
cout<<vName<<" has "<<noOfWheels<<" wheels"<<endl;
cout<<vName<<" has "<<engineSize<<" CC engine"<<endl;
}
};
int main(){
//Bus b1;
//Car c1;
//Bike bi1;
//Bus::setVname("Double-Decker");
//Bus::setWheels(6);
//Bus::setEngine(2500);
//c1.setVname("BMW");
//c1.setWheels(4);
//c1.setEngine(1500);
//bi1.setVname("Yamaha");
//bi1.setWheels(2);
//bi1.setEngine(100);
Bus::displayBus();
Car::displayCar();
Bike::displayBike();
//vehicle::setVname("Double-Decker");
//vehicle::setWheels(6);
//vehicle::setEngine(2500);
vehicle::displayVehicle();
return 0;
}
| [
"jubayertalha194@gmail.com"
] | jubayertalha194@gmail.com |
0af0d27865c326978e235b8a2e893cfaa6c697e6 | 8b8042915b0641143d76998b3b03519b3bcee9b6 | /Final_Release/ros_ws/src/taches/src/tache2.cpp | 9b0c58258df5f5f1dbbd9c92e3b8661a2bb006a7 | [] | no_license | ProjetLongAIP/Livrable-Final | aaedb49ac65b415144fad3117cbc177bb4fbe61f | 4b03fa1f6f7f613f840cd8973b3e0d87d5ae6091 | refs/heads/master | 2021-01-22T20:08:22.308031 | 2017-06-20T12:43:18 | 2017-06-20T12:43:18 | 85,282,992 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,299 | cpp | /**** Projet long N7 2017 ****/
#include "tache2.h"
//Constructeur
Tache2::Tache2()
{}
//Destructeur
Tache2::~Tache2()
{}
/** Fonction interne permettant d'évacuer le produit de la table lorsque le robot l'a récupéré **/
//Fonction permettant de changer la couleur de la table lorsque le traitement est terminé
void Tache2::FinTraitementProduit(int numTable)
{
if((numTable == 1)&&(position==4)&&(bras == 1)&&(pince == 1))
{
srv_simRosColor.request.signalName = table;
srv_simRosColor.request.signalValue = 0; //couleur de base
client_simRosColor.call(srv_simRosColor);
finTraitement = -1;
oldproduit = -1;
}
}
/** Fonctions permettant de connaître la position du robot ainsi que l'état de la pince et du bras **/
//Fonction Callback permettant de récupérer la position du robot 1
void Tache2::PositionRobotCallback(const std_msgs::Int32::ConstPtr& msg)
{
position = msg->data;
}
//Fonction Callback permettant de récupérer l'état du bras du robot 1
void Tache2::BrasRobotCallback(const std_msgs::Int32::ConstPtr& msg)
{
bras = msg->data;
}
//Fonction Callback permettant de récupérer l'état de la pince du robot 1
void Tache2::PinceRobotCallback(const std_msgs::Int32::ConstPtr& msg)
{
pince = msg->data;
}
/** Fonction permettant le traitement d'un produit à la réception du message venant du noeud Poste associé **/
//Fonction Callback permettant de traiter le produit s'il est en position
void Tache2::TraitementProduitCallback(const std_msgs::Int32::ConstPtr& msg)
{
produit=msg->data;
finTraitement = 0;
retourTraitement.data=0;
while(finTraitement != -1)
{
ros::spinOnce();
if(produit != oldproduit)
{
if((position==4)&&(bras==0)&&(pince==0))
{
//Coloration de la table associée à la tâche lors de la réception du produit
srv_simRosColor.request.signalName = table;
srv_simRosColor.request.signalValue = produit;
client_simRosColor.call(srv_simRosColor);
///Traitement du produit
//Temps de Traitement du produit
iteratorPMap = ProductsMap.find(produit);
ProductTache* productPointer;
if (iteratorPMap != ProductsMap.end()) // Vrai si l'itérateur n'est pas hors de la liste
{
productPointer = iteratorPMap->second;
client_simGetVrepTime.call(srv_simGetVrepTime);
t0 = srv_simGetVrepTime.response.simulationTime;
time = t0;
while(time - t0 < productPointer->jobTime)
{
client_simGetVrepTime.call(srv_simGetVrepTime);
time = srv_simGetVrepTime.response.simulationTime;
}
//Fin de traitement
produit++;
oldproduit = produit;
srv_simRosColor.request.signalValue = produit;
client_simRosColor.call(srv_simRosColor);
//Retour du traitement vers le node poste associé
traitementProduit.data = produit;
pub_traitementProduitTache.publish(traitementProduit);
//Retour du traitement vers le node commmande
retourTraitement.data=1;
finTraitement = 1;
}
}
pub_retourTraitement.publish(retourTraitement);
}
FinTraitementProduit(finTraitement);
}
}
/** Initialisation **/
//Initialisation des différents services, publishers et subscribers
void Tache2::init(ros::NodeHandle noeud, std::string executionPath)
{
//Déclaration service simRosSetIntegerSignal
client_simRosColor = noeud.serviceClient<vrep_common::simRosSetIntegerSignal>("/vrep/simRosSetIntegerSignal");
//Déclaration service simRosGetInfo
client_simGetVrepTime = noeud.serviceClient<vrep_common::simRosGetInfo>("/vrep/simRosGetInfo");
//Subscribers
robotPosition = noeud.subscribe("/robot/PositionRobot1", 10, &Tache2::PositionRobotCallback, this);
robotBras = noeud.subscribe("/robot/BrasRobot1",10,&Tache2::BrasRobotCallback,this);
robotPince = noeud.subscribe("/robot/PinceRobot1",10,&Tache2::PinceRobotCallback,this);
posteProduit = noeud.subscribe("/P2_Tache/ProduitATraiter",10,&Tache2::TraitementProduitCallback,this);
//Publishers
pub_traitementProduitTache = noeud.advertise<std_msgs::Int32>("/Tache_P2/Tache2Finie",10);
pub_retourTraitement = noeud.advertise<std_msgs::Int32>("/commande/Simulation/ProduitTraitement2",10);
//Définition des noms des signaux
table = "Table#0_color";
//Initialisation des variables de retour du robot
position = -1;
bras = -1;
pince = -1;
oldproduit = -1;
// Récupération du chemin vers le Working_Folder
int count = 0 ;
int pos = 0 ;
while (count < 4)
{
if(executionPath[pos] == '/') count++;
pos++;
}
std::string Working_Folder = executionPath.substr(0,pos);
//Initialisation des produits à l'aide du fichier de configuration
//Définition du chemin du fichier de config
std::string configFile = Working_Folder + "/ProductConfiguration.config";
std::ifstream streamConfigFile(configFile.c_str(), std::ios::in);
if (streamConfigFile)
{
std::string pNameFF,destinationPart,jobTimePart,contents;
//saut des lignes d'entêtes, repèrage du start.
while(1)
{
std::getline(streamConfigFile,contents);
std::size_t found = contents.find("Start");
if (found!=std::string::npos)
{
break;
}
}
//Configuration nombre max de shuttle
std::getline(streamConfigFile,contents);
//Configuration temps entre lancement
std::getline(streamConfigFile,contents);
//GAMME/TEMPS
while (std::getline(streamConfigFile, contents))
{
if (contents.find(':') != std::string::npos )
{
//ROS_INFO("%s",contents.c_str()) ;
std::size_t pos2 = contents.find(":");
std::size_t pos3 = contents.find_last_of(":");
pNameFF = contents.substr(0,pos2);
ROS_INFO("Product %s",pNameFF.c_str());
destinationPart = contents.substr(pos2+1,pos3-pos2-1);
ROS_INFO("destination part =%s",destinationPart.c_str());
jobTimePart = contents.substr(pos3+1);
ROS_INFO("jobTimePart =%s",jobTimePart.c_str());
int destination[10];
int jobTime[10];
int manRSize = 0; //manufacturing range size of the produit = number of operation
char * cstr2 = new char [destinationPart.length()+1];
std::strcpy (cstr2, destinationPart.c_str()); // création objet cstring
char * cstr3 = new char [jobTimePart.length()+1];
std::strcpy (cstr3, jobTimePart.c_str());
// cstr now contains a c-string copy of str
int n2 = 0; //compteur sur les destinations
int n3 = 0; //compteur sur les temps de fabrications
char * p2 = std::strtok (cstr2," ");
while (p2!=NULL)
{
destination[n2++] = atoi(p2);
manRSize++ ;
p2 = std::strtok(NULL," ");
}
char * p3 = std::strtok (cstr3," ");
while (p3!=NULL)
{
jobTime[n3++] = atoi(p3);
p3 = std::strtok(NULL," ");
}
delete[] cstr2;
delete[] cstr3;
char charName;
charName = char(pNameFF.c_str()[0]-16);
int pNumberBase = atoi(&charName) * 10 ;
int pNumber;
int JobTimeProduct;
// Pour gérer le n° de la prochaine destination d'un produit
for (int i = 0; i < manRSize; i++)
{
if(destination[i] == 2)
{
pNumber = pNumberBase + i;
JobTimeProduct = jobTime[i];
initProduct(JobTimeProduct,pNumber);
}
}
}
}
streamConfigFile.close(); //fermeture du fichier ProductConfiguration.txt ouvert en lecture//
}
else ROS_ERROR("Impossible d'ouvrir le fichier ProductConfiguration.config !");
}
// Fonction Init du fichier configuration pour créer un produit
void Tache2::initProduct(int nJobtime, int pNumber)
{
ROS_INFO("Creation Produit, temps de traitement = %d, numero produit = %d ", nJobtime,pNumber);
// Création dynamique de l'object product
ProductTache* newProductTache = new ProductTache(nJobtime,pNumber);
// Insertion dans le map de la classe de la paire <key=pNumber,T=Product*>
std::pair<std::map<int,ProductTache*>::iterator,bool> ret; // ret permet d'avoir un retour de la fonction insert, il est faux si la key existe dèjà dans la map
ret = ProductsMap.insert(std::pair<int,ProductTache*>(newProductTache->productNumber,newProductTache));
if (ret.second==false) // Si un produit avec le même nom existe déjà, celui-ci n'est pas ajouté à la collection
{
ROS_WARN("Ordonnanceur : Un Produit de ce nom existe deja !");
}
}
| [
"maxime-maurin@hotmail.fr"
] | maxime-maurin@hotmail.fr |
40979dbf15328b381c238fd00bfa3a14b0e00463 | 2cf838b54b556987cfc49f42935f8aa7563ea1f4 | /aws-cpp-sdk-personalize/include/aws/personalize/model/OptimizationObjective.h | 3e31e9ed59b10ff9f1eb5d20a40a9b7ffe695902 | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | QPC-database/aws-sdk-cpp | d11e9f0ff6958c64e793c87a49f1e034813dac32 | 9f83105f7e07fe04380232981ab073c247d6fc85 | refs/heads/main | 2023-06-14T17:41:04.817304 | 2021-07-09T20:28:20 | 2021-07-09T20:28:20 | 384,714,703 | 1 | 0 | Apache-2.0 | 2021-07-10T14:16:41 | 2021-07-10T14:16:41 | null | UTF-8 | C++ | false | false | 5,839 | h | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/personalize/Personalize_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/personalize/model/ObjectiveSensitivity.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace Personalize
{
namespace Model
{
/**
* <p>Describes the additional objective for the solution, such as maximizing
* streaming minutes or increasing revenue. For more information see <a
* href="https://docs.aws.amazon.com/personalize/latest/dg/optimizing-solution-for-objective.html">Optimizing
* a solution</a>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/personalize-2018-05-22/OptimizationObjective">AWS
* API Reference</a></p>
*/
class AWS_PERSONALIZE_API OptimizationObjective
{
public:
OptimizationObjective();
OptimizationObjective(Aws::Utils::Json::JsonView jsonValue);
OptimizationObjective& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p>The numerical metadata column in an Items dataset related to the optimization
* objective. For example, VIDEO_LENGTH (to maximize streaming minutes), or PRICE
* (to maximize revenue).</p>
*/
inline const Aws::String& GetItemAttribute() const{ return m_itemAttribute; }
/**
* <p>The numerical metadata column in an Items dataset related to the optimization
* objective. For example, VIDEO_LENGTH (to maximize streaming minutes), or PRICE
* (to maximize revenue).</p>
*/
inline bool ItemAttributeHasBeenSet() const { return m_itemAttributeHasBeenSet; }
/**
* <p>The numerical metadata column in an Items dataset related to the optimization
* objective. For example, VIDEO_LENGTH (to maximize streaming minutes), or PRICE
* (to maximize revenue).</p>
*/
inline void SetItemAttribute(const Aws::String& value) { m_itemAttributeHasBeenSet = true; m_itemAttribute = value; }
/**
* <p>The numerical metadata column in an Items dataset related to the optimization
* objective. For example, VIDEO_LENGTH (to maximize streaming minutes), or PRICE
* (to maximize revenue).</p>
*/
inline void SetItemAttribute(Aws::String&& value) { m_itemAttributeHasBeenSet = true; m_itemAttribute = std::move(value); }
/**
* <p>The numerical metadata column in an Items dataset related to the optimization
* objective. For example, VIDEO_LENGTH (to maximize streaming minutes), or PRICE
* (to maximize revenue).</p>
*/
inline void SetItemAttribute(const char* value) { m_itemAttributeHasBeenSet = true; m_itemAttribute.assign(value); }
/**
* <p>The numerical metadata column in an Items dataset related to the optimization
* objective. For example, VIDEO_LENGTH (to maximize streaming minutes), or PRICE
* (to maximize revenue).</p>
*/
inline OptimizationObjective& WithItemAttribute(const Aws::String& value) { SetItemAttribute(value); return *this;}
/**
* <p>The numerical metadata column in an Items dataset related to the optimization
* objective. For example, VIDEO_LENGTH (to maximize streaming minutes), or PRICE
* (to maximize revenue).</p>
*/
inline OptimizationObjective& WithItemAttribute(Aws::String&& value) { SetItemAttribute(std::move(value)); return *this;}
/**
* <p>The numerical metadata column in an Items dataset related to the optimization
* objective. For example, VIDEO_LENGTH (to maximize streaming minutes), or PRICE
* (to maximize revenue).</p>
*/
inline OptimizationObjective& WithItemAttribute(const char* value) { SetItemAttribute(value); return *this;}
/**
* <p>Specifies how Amazon Personalize balances the importance of your optimization
* objective versus relevance.</p>
*/
inline const ObjectiveSensitivity& GetObjectiveSensitivity() const{ return m_objectiveSensitivity; }
/**
* <p>Specifies how Amazon Personalize balances the importance of your optimization
* objective versus relevance.</p>
*/
inline bool ObjectiveSensitivityHasBeenSet() const { return m_objectiveSensitivityHasBeenSet; }
/**
* <p>Specifies how Amazon Personalize balances the importance of your optimization
* objective versus relevance.</p>
*/
inline void SetObjectiveSensitivity(const ObjectiveSensitivity& value) { m_objectiveSensitivityHasBeenSet = true; m_objectiveSensitivity = value; }
/**
* <p>Specifies how Amazon Personalize balances the importance of your optimization
* objective versus relevance.</p>
*/
inline void SetObjectiveSensitivity(ObjectiveSensitivity&& value) { m_objectiveSensitivityHasBeenSet = true; m_objectiveSensitivity = std::move(value); }
/**
* <p>Specifies how Amazon Personalize balances the importance of your optimization
* objective versus relevance.</p>
*/
inline OptimizationObjective& WithObjectiveSensitivity(const ObjectiveSensitivity& value) { SetObjectiveSensitivity(value); return *this;}
/**
* <p>Specifies how Amazon Personalize balances the importance of your optimization
* objective versus relevance.</p>
*/
inline OptimizationObjective& WithObjectiveSensitivity(ObjectiveSensitivity&& value) { SetObjectiveSensitivity(std::move(value)); return *this;}
private:
Aws::String m_itemAttribute;
bool m_itemAttributeHasBeenSet;
ObjectiveSensitivity m_objectiveSensitivity;
bool m_objectiveSensitivityHasBeenSet;
};
} // namespace Model
} // namespace Personalize
} // namespace Aws
| [
"aws-sdk-cpp-automation@github.com"
] | aws-sdk-cpp-automation@github.com |
a9699887d117d2fe14625e43412870b342724d98 | c3a78d39b996a6860a8a2076f50d5523e3ad9ed0 | /Algorithm/Experiment/2/A.cpp | a41fabb25e051ab289ee37f52cf0fd5710b743c6 | [] | no_license | BanSheeGun/Learning | 61bfc0c79a2a04e4c2d8dccb063a007463fbe25f | cbb785eec763f0d15406e6993febf8c16159140d | refs/heads/master | 2021-01-17T14:09:48.763244 | 2018-04-02T05:39:29 | 2018-04-02T05:39:29 | 47,012,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 551 | cpp | #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int a, b, tmp, t, d, n;
int main() {
scanf("%d", &n);
t = 0;
for (a = n/2; a < n; ++a) {
tmp = 1;
b = n - a;
while (tmp <= a) {
d = (a / tmp / 10 * tmp) + (a % tmp);
if (d == b) {
++t;
printf("%d %d\n", a, b);
}
tmp *= 10;
}
}
printf("%d\n", t);
return 0;
} | [
"ccp750707@126.com"
] | ccp750707@126.com |
ef6496aeb8c17d6c7017bfaf24c6573a89a9e974 | 8ab7d5e26ebdb9b89208912bc506fb4994c14ca2 | /Day 26/subsetsumdpgeeksforgeeks.cpp | b05471474cb15e2b87e3cb097723bb0ce22e4e7b | [] | no_license | samfubuki/striver-sde-solutions | d95808a6cf3dcb3a2c254afe5e068819fca71247 | 8ae67f7d9995ca8a3af7067fba0631183bc53400 | refs/heads/main | 2023-07-15T07:55:35.043304 | 2021-08-29T18:32:34 | 2021-08-29T18:32:34 | 401,113,622 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,296 | cpp | #include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
// User function Template for C++
class Solution{
public:
bool subsetsum(int arr[] , int sum , int n)
{
bool t[n+1][sum+1];
for(int i=0;i<=n;i++)
{
t[i][0]=true;
}
for(int i=1;i<=sum;i++)
{
t[0][i]=false;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=sum;j++)
{
if(arr[i-1]<=j)
{
t[i][j]=t[i-1][j-arr[i-1]] || t[i-1][j];
}
else
{
t[i][j]=t[i-1][j];
}
}
}
return t[n][sum];
}
int equalPartition(int N, int arr[])
{
int sum = 0;
for(int i=0;i<N;i++)
{
sum = sum + arr[i];
}
if(sum%2!=0)
{
return false;
}
else if(sum%2==0)
{
return subsetsum(arr,sum/2,N);
}
}
};
// { Driver Code Starts.
int main(){
int t;
cin>>t;
while(t--){
int N;
cin>>N;
int arr[N];
for(int i = 0;i < N;i++)
cin>>arr[i];
Solution ob;
if(ob.equalPartition(N, arr))
cout<<"YES\n";
else
cout<<"NO\n";
}
return 0;
} // } Driver Code Ends
| [
"pbhardwaj.preet@gmail.com"
] | pbhardwaj.preet@gmail.com |
aad54af71fa1fa7d1464fb6ecd0149a18c9c64d9 | 073b677e7256a8b705c1f3230b64664f55e265b2 | /Lab3/Lab1/RectangleCreator.h | d79b8f20cd02c7fa40e47a2c45206a2448fe203d | [] | no_license | DolgushevEvgeny/KPO | ee4d650d45588a61e247e688536d4100268a5894 | 01403b7cb16e4cb0c00661252ec0818f9bc441e0 | refs/heads/master | 2021-01-18T23:07:09.874065 | 2016-06-13T16:22:45 | 2016-06-13T16:22:45 | 51,082,448 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 289 | h | #pragma once
#include "Shape.h"
#include "Point.h"
class CRectangleCreator
{
public:
std::unique_ptr<CShape> Create(const Point &point1, const Point &point2) const;
static CRectangleCreator* GetInstance();
static void DestroyInstance();
private:
static CRectangleCreator *inst;
};
| [
"baraxlush1995@gmail.com"
] | baraxlush1995@gmail.com |
13d63712187732538d309c01d3a336187d8210ce | 60cfe9ed4709e44d61ff1a207ffb426ffff4259f | /src/Scene.h | 8be0159a637b568165d6b36f87cac072759aec8b | [] | no_license | yohkaz/BasicRayTracer | 8a5b70b58b5b91a7a81489ca9034d53750f4aae6 | 5c36a3d9786b0a3eeb755b2b4e0cd55252e799d9 | refs/heads/master | 2020-12-20T13:59:44.222236 | 2020-03-31T19:37:38 | 2020-03-31T19:37:38 | 236,101,044 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 672 | h | #ifndef SCENE_H
#define SCENE_H
#include <vector>
#include "Camera.h"
#include "Model.h"
#include "Light.h"
class Scene {
public:
Scene() = default;
void add(Model& model) {
models.push_back(&model);
}
void add(Light& light) {
ligths.push_back(&light);
}
const Camera& getCamera() const { return camera; }
const std::vector<Model*>& getModels() const { return models; }
const std::vector<Light*>& getLights() const { return ligths; }
const Vec3<float>& getCameraPosition() const { return camera.getPosition(); }
private:
Camera camera;
std::vector<Model*> models;
std::vector<Light*> ligths;
};
#endif | [
"yoh.kzl@gmail.com"
] | yoh.kzl@gmail.com |
fa98ce24995ec04ed3db9539d06c07f4b7e3a8f0 | 29a8e350ee9c5ce63302381ea7e85efb691d7b37 | /src/nco/contact.h | 8a0e82949c91a40856a06795c4df5b48c14b47a6 | [] | no_license | sandeepraju/MovieManager | 87a13af20e8650a8c6707863c333ed6bfe19da9a | df93216482c6ab73f324d10f9ae90bf1915809a7 | refs/heads/master | 2020-04-06T04:29:31.111916 | 2012-07-24T09:23:28 | 2012-07-24T09:23:28 | 3,428,521 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,401 | h | #ifndef _NCO_CONTACT_H_
#define _NCO_CONTACT_H_
#include <QtCore/QVariant>
#include <QtCore/QStringList>
#include <QtCore/QUrl>
#include <QtCore/QDate>
#include <QtCore/QTime>
#include <QtCore/QDateTime>
#include <nepomuk/simpleresource.h>
#include "nie/informationelement.h"
#include "nco/role.h"
namespace Nepomuk {
namespace NCO {
/**
* A Contact. A piece of data that can provide means to identify
* or communicate with an entity.
*/
class Contact : public virtual NIE::InformationElement, public virtual NCO::Role
{
public:
Contact(const QUrl& uri = QUrl())
: SimpleResource(uri), NIE::InformationElement(uri, QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact", QUrl::StrictMode)), NCO::Role(uri, QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact", QUrl::StrictMode)) {
}
Contact(const SimpleResource& res)
: SimpleResource(res), NIE::InformationElement(res, QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact", QUrl::StrictMode)), NCO::Role(res, QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact", QUrl::StrictMode)) {
}
Contact& operator=(const SimpleResource& res) {
SimpleResource::operator=(res);
addType(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact", QUrl::StrictMode));
return *this;
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#belongsToGroup.
* Links a Contact with a ContactGroup it belongs to.
*/
QList<QUrl> belongsToGroups() const {
QList<QUrl> value;
foreach(const QVariant& v, property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#belongsToGroup", QUrl::StrictMode)))
value << v.value<QUrl>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#belongsToGroup.
* Links a Contact with a ContactGroup it belongs to.
*/
void setBelongsToGroups(const QList<QUrl>& value) {
QVariantList values;
foreach(const QUrl& v, value)
values << v;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#belongsToGroup", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#belongsToGroup.
* Links a Contact with a ContactGroup it belongs to.
*/
void addBelongsToGroup(const QUrl& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#belongsToGroup", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname.
* To specify the formatted text corresponding to the name of the
* object the Contact represents. An equivalent of the FN property
* as defined in RFC 2426 Sec. 3.1.1.
*/
QString fullname() const {
QString value;
if(contains(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname", QUrl::StrictMode)))
value = property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname", QUrl::StrictMode)).first().value<QString>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname.
* To specify the formatted text corresponding to the name of the
* object the Contact represents. An equivalent of the FN property
* as defined in RFC 2426 Sec. 3.1.1.
*/
void setFullname(const QString& value) {
QVariantList values;
values << value;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname.
* To specify the formatted text corresponding to the name of the
* object the Contact represents. An equivalent of the FN property
* as defined in RFC 2426 Sec. 3.1.1.
*/
void addFullname(const QString& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#birthDate.
* Birth date of the object represented by this Contact. An equivalent
* of the 'BDAY' property as defined in RFC 2426 Sec. 3.1.5.
*/
QDate birthDate() const {
QDate value;
if(contains(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#birthDate", QUrl::StrictMode)))
value = property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#birthDate", QUrl::StrictMode)).first().value<QDate>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#birthDate.
* Birth date of the object represented by this Contact. An equivalent
* of the 'BDAY' property as defined in RFC 2426 Sec. 3.1.5.
*/
void setBirthDate(const QDate& value) {
QVariantList values;
values << value;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#birthDate", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#birthDate.
* Birth date of the object represented by this Contact. An equivalent
* of the 'BDAY' property as defined in RFC 2426 Sec. 3.1.5.
*/
void addBirthDate(const QDate& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#birthDate", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#sound.
* Sound clip attached to a Contact. The DataObject referred to
* by this property is usually interpreted as an nfo:Audio. Inspired
* by the SOUND property defined in RFC 2425 sec. 3.6.6.
*/
QList<QUrl> sounds() const {
QList<QUrl> value;
foreach(const QVariant& v, property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#sound", QUrl::StrictMode)))
value << v.value<QUrl>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#sound.
* Sound clip attached to a Contact. The DataObject referred to
* by this property is usually interpreted as an nfo:Audio. Inspired
* by the SOUND property defined in RFC 2425 sec. 3.6.6.
*/
void setSounds(const QList<QUrl>& value) {
QVariantList values;
foreach(const QUrl& v, value)
values << v;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#sound", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#sound.
* Sound clip attached to a Contact. The DataObject referred to
* by this property is usually interpreted as an nfo:Audio. Inspired
* by the SOUND property defined in RFC 2425 sec. 3.6.6.
*/
void addSound(const QUrl& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#sound", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#photo.
* Photograph attached to a Contact. The DataObject referred
* to by this property is usually interpreted as an nfo:Image.
* Inspired by the PHOTO property defined in RFC 2426 sec. 3.1.4
*/
QList<QUrl> photos() const {
QList<QUrl> value;
foreach(const QVariant& v, property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#photo", QUrl::StrictMode)))
value << v.value<QUrl>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#photo.
* Photograph attached to a Contact. The DataObject referred
* to by this property is usually interpreted as an nfo:Image.
* Inspired by the PHOTO property defined in RFC 2426 sec. 3.1.4
*/
void setPhotos(const QList<QUrl>& value) {
QVariantList values;
foreach(const QUrl& v, value)
values << v;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#photo", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#photo.
* Photograph attached to a Contact. The DataObject referred
* to by this property is usually interpreted as an nfo:Image.
* Inspired by the PHOTO property defined in RFC 2426 sec. 3.1.4
*/
void addPhoto(const QUrl& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#photo", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#representative.
* An object that represent an object represented by this Contact.
* Usually this property is used to link a Contact to an organization,
* to a contact to the representative of this organization the
* user directly interacts with. An equivalent for the 'AGENT'
* property defined in RFC 2426 Sec. 3.5.4
*/
QList<QUrl> representatives() const {
QList<QUrl> value;
foreach(const QVariant& v, property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#representative", QUrl::StrictMode)))
value << v.value<QUrl>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#representative.
* An object that represent an object represented by this Contact.
* Usually this property is used to link a Contact to an organization,
* to a contact to the representative of this organization the
* user directly interacts with. An equivalent for the 'AGENT'
* property defined in RFC 2426 Sec. 3.5.4
*/
void setRepresentatives(const QList<QUrl>& value) {
QVariantList values;
foreach(const QUrl& v, value)
values << v;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#representative", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#representative.
* An object that represent an object represented by this Contact.
* Usually this property is used to link a Contact to an organization,
* to a contact to the representative of this organization the
* user directly interacts with. An equivalent for the 'AGENT'
* property defined in RFC 2426 Sec. 3.5.4
*/
void addRepresentative(const QUrl& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#representative", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contactUID.
* A value that represents a globally unique identifier corresponding
* to the individual or resource associated with the Contact.
* An equivalent of the 'UID' property defined in RFC 2426 Sec.
* 3.6.7
*/
QString contactUID() const {
QString value;
if(contains(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contactUID", QUrl::StrictMode)))
value = property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contactUID", QUrl::StrictMode)).first().value<QString>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contactUID.
* A value that represents a globally unique identifier corresponding
* to the individual or resource associated with the Contact.
* An equivalent of the 'UID' property defined in RFC 2426 Sec.
* 3.6.7
*/
void setContactUID(const QString& value) {
QVariantList values;
values << value;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contactUID", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contactUID.
* A value that represents a globally unique identifier corresponding
* to the individual or resource associated with the Contact.
* An equivalent of the 'UID' property defined in RFC 2426 Sec.
* 3.6.7
*/
void addContactUID(const QString& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contactUID", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#nickname.
* A nickname of the Object represented by this Contact. This is
* an equivalent of the 'NICKNAME' property as defined in RFC 2426
* Sec. 3.1.3.
*/
QStringList nicknames() const {
QStringList value;
foreach(const QVariant& v, property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#nickname", QUrl::StrictMode)))
value << v.value<QString>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#nickname.
* A nickname of the Object represented by this Contact. This is
* an equivalent of the 'NICKNAME' property as defined in RFC 2426
* Sec. 3.1.3.
*/
void setNicknames(const QStringList& value) {
QVariantList values;
foreach(const QString& v, value)
values << v;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#nickname", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#nickname.
* A nickname of the Object represented by this Contact. This is
* an equivalent of the 'NICKNAME' property as defined in RFC 2426
* Sec. 3.1.3.
*/
void addNickname(const QString& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#nickname", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasLocation.
* Geographical location of the contact. Inspired by the 'GEO'
* property specified in RFC 2426 Sec. 3.4.2
*/
QUrl location() const {
QUrl value;
if(contains(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasLocation", QUrl::StrictMode)))
value = property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasLocation", QUrl::StrictMode)).first().value<QUrl>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasLocation.
* Geographical location of the contact. Inspired by the 'GEO'
* property specified in RFC 2426 Sec. 3.4.2
*/
void setLocation(const QUrl& value) {
QVariantList values;
values << value;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasLocation", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasLocation.
* Geographical location of the contact. Inspired by the 'GEO'
* property specified in RFC 2426 Sec. 3.4.2
*/
void addLocation(const QUrl& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasLocation", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#key.
* An encryption key attached to a contact. Inspired by the KEY
* property defined in RFC 2426 sec. 3.7.2
*/
QList<QUrl> keys() const {
QList<QUrl> value;
foreach(const QVariant& v, property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#key", QUrl::StrictMode)))
value << v.value<QUrl>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#key.
* An encryption key attached to a contact. Inspired by the KEY
* property defined in RFC 2426 sec. 3.7.2
*/
void setKeys(const QList<QUrl>& value) {
QVariantList values;
foreach(const QUrl& v, value)
values << v;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#key", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#key.
* An encryption key attached to a contact. Inspired by the KEY
* property defined in RFC 2426 sec. 3.7.2
*/
void addKey(const QUrl& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#key", QUrl::StrictMode), value);
}
/**
* Get property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#note.
* A note about the object represented by this Contact. An equivalent
* for the 'NOTE' property defined in RFC 2426 Sec. 3.6.2
*/
QStringList notes() const {
QStringList value;
foreach(const QVariant& v, property(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#note", QUrl::StrictMode)))
value << v.value<QString>();
return value;
}
/**
* Set property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#note.
* A note about the object represented by this Contact. An equivalent
* for the 'NOTE' property defined in RFC 2426 Sec. 3.6.2
*/
void setNotes(const QStringList& value) {
QVariantList values;
foreach(const QString& v, value)
values << v;
setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#note", QUrl::StrictMode), values);
}
/**
* Add value to property http://www.semanticdesktop.org/ontologies/2007/03/22/nco#note.
* A note about the object represented by this Contact. An equivalent
* for the 'NOTE' property defined in RFC 2426 Sec. 3.6.2
*/
void addNote(const QString& value) {
addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#note", QUrl::StrictMode), value);
}
protected:
Contact(const QUrl& uri, const QUrl& type) : SimpleResource(uri), NIE::InformationElement(uri, type), NCO::Role(uri, type) {
}
Contact(const SimpleResource& res, const QUrl& type)
: SimpleResource(res), NIE::InformationElement(res, type), NCO::Role(res, type) {
}
};
}
}
#endif
| [
"sandeep080@gmail.com"
] | sandeep080@gmail.com |
cb42f221a986ad891831b2ea2c0fc0ea5e97957b | f9451e836cbd9c8a8d1e1ed3ce7db92a9cf3c294 | /include/GameState.h | 7d5d42e09fbd2f418232176f23dec7d9acc028f4 | [] | no_license | exomo/Snake | 85bf28f733c4a089596ea9d9af4c29cbc168f196 | cb23ddb0cc766f971c6a3a301d49daa667850603 | refs/heads/master | 2020-05-03T16:35:15.350347 | 2019-03-31T18:37:27 | 2019-03-31T18:37:27 | 178,726,098 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 1,021 | h | #ifndef GAMESTATE_H
#define GAMESTATE_H
#include <memory>
#include <SFML/Graphics.hpp>
namespace ExomoSnake
{
/*
* Abstrakte Basisklasse für den Spielzustand. In jedem Spielzustand müssen werden die drei Methoden
* handleEvents(), updateGame() und render() implementiert werden. Spielzustände sind z.B. "das Spiel läuft"
* oder "Im Menü".
*/
class GameState
{
public:
/** Default constructor */
GameState();
/** Default destructor */
virtual ~GameState();
virtual void handleEvent(const sf::Event& event) = 0;
virtual std::shared_ptr<GameState> updateGame(sf::Time elapsed, const std::shared_ptr<GameState>& currentState) = 0;
virtual void render(sf::RenderWindow& window) = 0;
};
using GameStatePtr = std::shared_ptr<GameState>;
class StateMachine
{
public:
StateMachine(const GameStatePtr& initialState);
protected:
GameStatePtr currentState;
};
}
#endif // GAMESTATE_H
| [
"exomo@gmx.de"
] | exomo@gmx.de |
2740d0bd05df1f4d6c575f21c0bc5b2872ddce92 | 1c7523f0f2af2b815d97b312bed24a11ee880dd1 | /tests/test_machine.cpp | 2d8aeca162ef471a945291343ceef5366c26ad6b | [] | no_license | bgalvan/CPU_Simulator | ebe543db773e1660ea02afda742303d8d0d08df8 | 057a7f614e9185106965f4b81b8003e982ec65da | refs/heads/master | 2020-05-19T23:12:29.396952 | 2019-05-14T18:53:14 | 2019-05-14T18:53:14 | 185,261,904 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 228 | cpp | // Copyright 2018 Roie R. Black
#include <catch.hpp>
#include "Machine.h"
TEST_CASE( "test machine constructor", "machine" ){
const std::string name = "TinySim";
Machine sim(name);
REQUIRE(sim.get_name() == name);
} | [
"bgalvan10@gmail.com"
] | bgalvan10@gmail.com |
2f2b60ba01ca4e9e0b511949a94cbba5dd5b99d1 | c1493df6bba79f68ca1dcbb190aa027f3de900e9 | /procedure/mooc_cpp/work4/插入加密.cpp | 906a2b3bee075f9209b6d33625ba156707de8513 | [] | no_license | Richardcsb/github | 6ad474f5d286eacbdfafd6edfc048455b8c56985 | ea712f7e8db2e6f1352a3eb91276fc91ebffc0f8 | refs/heads/master | 2021-01-01T06:52:49.565716 | 2018-03-14T13:42:05 | 2018-03-14T13:42:05 | 97,539,129 | 1 | 1 | null | null | null | null | GB18030 | C++ | false | false | 428 | cpp | #include<iostream>
#include<string>
using namespace std;
int main()
{
int n,k;
char str1[120];
char str2[6]="abcde";
string text;
cin>>str1;
cin>>n; //当输入n等于1时程序正常运行,当输入n大于1时程序执行异常
text=str1;
k=n+1;
for(int i=0;str1[i]!='\0';i++)
{
text.insert(n,str2,i%5,1);
n=n+k;
}
cout<<text<<endl;
return 0;
}
| [
"chenshaobo272@gmail.com"
] | chenshaobo272@gmail.com |
17d63385ab5a4f05e2dd8d925c7f85cefb2dba94 | 1a2190b96ca17719d2b41a5fbcac6043cf9f08e4 | /SPOJ BR/LCAIXA.cpp | 2209ad433d7f862c3a8f799500cfb8b5ab0dae52 | [] | no_license | eliasm2/problem-solving | 13c1abbf397bb41683fccb3490b0113c36ce9010 | 15becf49315b5defb8c1267e0c43ce1579dcae1a | refs/heads/master | 2020-09-07T07:12:17.112311 | 2018-07-20T17:27:43 | 2018-07-20T17:27:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,773 | cpp | #include <map>
#include <set>
#include <list>
#include <stack>
#include <cmath>
#include <queue>
#include <ctime>
#include <cfloat>
#include <vector>
#include <string>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3FFFFFFFFFLL
#define FILL(X, V) memset( X, V, sizeof(X) )
#define TI(X) __typeof((X).begin())
#define ALL(V) V.begin(), V.end()
#define SIZE(V) int((V).size())
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define RFOR(i, b, a) for(int i = b; i >= a; --i)
#define REP(i, N) for(int i = 0; i < N; ++i)
#define RREP(i, N) for(int i = N-1; i >= 0; --i)
#define FORIT(i, a) for( TI(a) i = a.begin(); i != a.end(); i++ )
#define PB push_back
#define MP make_pair
template<typename T> T inline SQR( const T &a ){ return a*a; }
template<typename T> T inline ABS( const T &a ){ return a < 0 ? -a : a; }
template<typename T> T inline MIN( const T& a, const T& b){ if( a < b ) return a; return b; }
template<typename T> T inline MAX( const T& a, const T& b){ if( a > b ) return a; return b; }
const double EPS = 1e-9;
inline int SGN( double a ){ return a > EPS ? 1 : (a < -EPS ? -1 : 0); }
inline int CMP( double a, double b ){ return SGN(a - b); }
typedef long long int64;
typedef unsigned long long uint64;
using namespace std;
char dp[44][80011];
char sgn[44];
int acm, N, F, t[44];
string ans;
bool play( int pos, int val ){
if( pos == N ) return (val == F);
if( dp[pos][val+acm] ) return ( dp[pos][val+acm] != '*' );
bool pls = play( pos+1, val+t[pos] );
bool mns = play( pos+1, val-t[pos] );
if( pls && mns )
dp[pos][val+acm] = '?';
else if( pls )
dp[pos][val+acm] = '+';
else if( mns )
dp[pos][val+acm] = '-';
else dp[pos][val+acm] = '*';
if( dp[pos][val+acm] != '*' ){
if( ans[pos] == '.' ) ans[pos] = dp[pos][val+acm];
else if( ans[pos] != dp[pos][val+acm] ) ans[pos] = '?';
}
return (dp[pos][val+acm] != '*' );
}
void build( int pos, int val ){
if( pos == N-1 ){
return;
}
bool pls = (dp[ pos+1 ][ val+t[pos]+acm ] > 0);
bool mns = (dp[ pos+1 ][ val-t[pos]+acm ] > 0);
if( pls && mns ){
dp[pos][val+acm] = '?';
} else if( pls ){
dp[pos][val+acm] = '+';
} else if( mns ){
dp[pos][val+acm] = '-';
}
}
int main( int argc, char* argv[] ){
ios::sync_with_stdio( false );
cin >> N >> F;
while( N || F ){
acm = 0;
REP( i, N ){
cin >> t[i];
acm += t[i];
}
REP( i, N )
REP( j, 2*acm+1 )
dp[i][j] = 0;
ans = "";
REP( i, N ) ans += ".";
if( play( 0, 0 ) ){
cout << ans << "\n";
} else cout << "*\n";
cin >> N >> F;
}
return 0;
}
| [
"paulocezar.ufg@gmail.com"
] | paulocezar.ufg@gmail.com |
5e984dac9f6acbc17d07183f0e580ae5618e85d7 | 6b29d51de8184ce5a7c9f508865b01d0ea04112c | /pat_L_01/pat010.cpp | d59ab21988717eec2f871525b873d6456f22f20a | [] | no_license | narutouzmk/pat | 2d1270607e2570d73b8a06612b1923d61ef8c255 | c5470eea38d8d9158bfde61f7495acf68261a1cf | refs/heads/master | 2020-05-03T09:48:06.870796 | 2019-03-30T14:48:37 | 2019-03-30T14:48:37 | 178,560,426 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 368 | cpp | #include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(){
int age, time;
double wage = 0.0;
scanf("%d %d", &age, &time);
if(age >= 5){
wage = time > 40 ? 40 * 50.0 + (time - 40) * 50.0 * 1.5 : time * 50;
}else{
wage = time > 40 ? 40 * 30.0 + (time - 40) * 30.0 * 1.5 : time * 30;
}
printf("%.2lf\n", wage);
return 0;
}
| [
"18840818956@163.com"
] | 18840818956@163.com |
e10a4e3f62b2341652dfa8942592209e36bb97cf | c5056f45428aae36b646834e9776f616d44ad54f | /Implimentationofarray.cpp | e5099a832de144f3cca8f11070c5cfc08677bef5 | [] | no_license | KarthikP1999/assignment | 2edc72939eefb51ea0f203d8ee78ca7afc7952b5 | c2e106a6ed3740a32038ca99ec8ff8d9cf761dad | refs/heads/master | 2021-04-15T06:35:14.100652 | 2018-03-21T17:47:24 | 2018-03-21T17:47:24 | 126,215,108 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 696 | cpp | #include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
class RandomInt
{
public:
RandomInt(int, int);
int operator()();
int operator()(int nb);
int operator()(int , int);
private:
int a,b;
};
RandomInt :: RandomInt(int ia, int ib):a(ia),b(ib)
{}
int RandomInt :: operator()()
{
return a+rand()%(b-a+1);
}
int RandomInt :: operator()(int nb)
{
return a+rand()%(nb-a+1);
}
int RandomInt :: operator()(int na,int nb)
{
return na+rand()%(nb-na+1);
}
int main()
{
RandomInt r(3,7);
srand(time(NULL));
cout<<"random value below 7:"<<r(7)<<endl;
cout<<"random value between 3 and 7:"<<r(7)<<endl;
cout<<"random value between 23 and 30:"<<r(23,30)<<endl;
}
| [
"karu372@gmail.com"
] | karu372@gmail.com |
5c7e4a27c357c4383239e45a5255a8da8d07530a | 90fc041cb98dd71d34bfff72761226d63c74f23e | /markus_crack/src/DllLoader.h | e4bb591e8b636dd67d87d0c58c6a8c9fe90159cb | [
"Unlicense"
] | permissive | mudlord/crackme_solutions | 510eb3258778febc0971dea4bb0aef67837cb95f | 9877a16e51bc41027d0363841f182e49bcee70ff | refs/heads/master | 2023-03-27T21:45:58.205384 | 2022-06-15T00:28:54 | 2022-06-15T00:28:54 | 212,070,700 | 8 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 10,276 | h | #pragma once
#pragma warning( disable : 4197 )
#include "Common.h"
#include "_EXP_Control.h"
#include "PatchUtil.h"
#include "DoPatch.h"
#define dll_export extern "C" __declspec(dllexport) void __cdecl
#define var_export extern "C" __declspec(dllexport)
#define dll_export2 extern "C" void __cdecl
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
void FixLibraryImport();
void ExitLibrary();
static HINSTANCE hInstance;
static HMODULE hDll;
void FixSingleApi(LPCSTR lpProcName, uAddr a);
void StartPatch();
void OpenConsole();
//#pragma comment(linker, "/EXPORT:crackedbymudlord,@1988")
void DLL_patch(HMODULE base);
namespace API_EXPORT
{
#ifdef __EXP_VERSION
dll_export GetFileVersionInfoA(void);
dll_export GetFileVersionInfoByHandle(void);
dll_export GetFileVersionInfoExW(void);
dll_export GetFileVersionInfoSizeA(void);
dll_export GetFileVersionInfoSizeExW(void);
dll_export GetFileVersionInfoSizeW(void);
dll_export GetFileVersionInfoW(void);
dll_export VerFindFileA(void);
dll_export VerFindFileW(void);
dll_export VerInstallFileA(void);
dll_export VerInstallFileW(void);
dll_export VerLanguageNameA(void);
dll_export VerLanguageNameW(void);
dll_export VerQueryValueA(void);
dll_export VerQueryValueW(void);
dll_export VerQueryValueIndexA(void);
dll_export VerQueryValueIndexW(void);
#endif
#ifdef __EXP_DINPUT8
#pragma comment(linker, "/EXPORT:DirectInput8Create,@100")
#pragma comment(linker, "/EXPORT:DllUnregisterServer,PRIVATE")
#pragma comment(linker, "/EXPORT:DllRegisterServer,PRIVATE")
#pragma comment(linker, "/EXPORT:DllCanUnloadNow,PRIVATE")
#pragma comment(linker, "/EXPORT:DllGetClassObject,PRIVATE")
#pragma comment(linker, "/EXPORT:GetdfDIJoystick")
dll_export DirectInput8Create();
dll_export DllCanUnloadNow();
dll_export DllGetClassObject();
dll_export DllRegisterServer();
dll_export DllUnregisterServer();
dll_export GetdfDIJoystick();
#endif
#ifdef __EXP_DSOUND
#pragma comment(linker, "/EXPORT:DirectSoundCreate,@1")
#pragma comment(linker, "/EXPORT:DirectSoundEnumerateA,@2")
#pragma comment(linker, "/EXPORT:DirectSoundEnumerateW,@3")
#pragma comment(linker, "/EXPORT:DllCanUnloadNow,PRIVATE")
#pragma comment(linker, "/EXPORT:DllGetClassObject,PRIVATE")
#pragma comment(linker, "/EXPORT:DirectSoundCaptureCreate,@6")
#pragma comment(linker, "/EXPORT:DirectSoundCaptureEnumerateA,@7")
#pragma comment(linker, "/EXPORT:DirectSoundCaptureEnumerateW,@8")
#pragma comment(linker, "/EXPORT:GetDeviceID,@9")
#pragma comment(linker, "/EXPORT:DirectSoundFullDuplexCreate,@10")
#pragma comment(linker, "/EXPORT:DirectSoundCreate8,@11")
#pragma comment(linker, "/EXPORT:DirectSoundCaptureCreate8,@12")
dll_export2 DirectSoundCaptureCreate();
dll_export2 DirectSoundCaptureCreate8();
dll_export2 DirectSoundCaptureEnumerateA();
dll_export2 DirectSoundCaptureEnumerateW();
dll_export2 DirectSoundCreate();
dll_export2 DirectSoundCreate8();
dll_export2 DirectSoundEnumerateA();
dll_export2 DirectSoundEnumerateW();
dll_export2 DirectSoundFullDuplexCreate();
dll_export2 DllCanUnloadNow();
dll_export2 DllGetClassObject();
dll_export2 GetDeviceID();
#endif
#ifdef __EXP_LPK
dll_export LpkDllInitialize(void);
dll_export LpkDrawTextEx(void);
var_export VOID(*LpkEditControl[14])();
dll_export LpkExtTextOut(void);
dll_export LpkGetCharacterPlacement(void);
dll_export LpkGetTextExtentExPoint(void);
dll_export LpkInitialize(void);
dll_export LpkPSMTextOut(void);
dll_export LpkTabbedTextOut(void);
dll_export LpkUseGDIWidthCache(void);
dll_export ftsWordBreak(void);
#endif
#ifdef __EXP_MSIMG32
dll_export AlphaBlend(void);
dll_export DllInitialize(void);
dll_export GradientFill(void);
dll_export TransparentBlt(void);
dll_export vSetDdrawflag(void);
#endif
#ifdef __EXP_WINMM
#ifdef PlaySound
#ifndef __BAK__PlaySound
#define __BAK__PlaySound PlaySound
#endif
#undef PlaySound
#endif
dll_export mciExecute(void);
dll_export CloseDriver(void);
dll_export DefDriverProc(void);
dll_export DriverCallback(void);
dll_export DrvGetModuleHandle(void);
dll_export GetDriverModuleHandle(void);
dll_export OpenDriver(void);
dll_export PlaySound(void);
dll_export PlaySoundA(void);
dll_export PlaySoundW(void);
dll_export SendDriverMessage(void);
dll_export WOWAppExit(void);
dll_export auxGetDevCapsA(void);
dll_export auxGetDevCapsW(void);
dll_export auxGetNumDevs(void);
dll_export auxGetVolume(void);
dll_export auxOutMessage(void);
dll_export auxSetVolume(void);
dll_export joyConfigChanged(void);
dll_export joyGetDevCapsA(void);
dll_export joyGetDevCapsW(void);
dll_export joyGetNumDevs(void);
dll_export joyGetPos(void);
dll_export joyGetPosEx(void);
dll_export joyGetThreshold(void);
dll_export joyReleaseCapture(void);
dll_export joySetCapture(void);
dll_export joySetThreshold(void);
dll_export mciDriverNotify(void);
dll_export mciDriverYield(void);
dll_export mciFreeCommandResource(void);
dll_export mciGetCreatorTask(void);
dll_export mciGetDeviceIDA(void);
dll_export mciGetDeviceIDFromElementIDA(void);
dll_export mciGetDeviceIDFromElementIDW(void);
dll_export mciGetDeviceIDW(void);
dll_export mciGetDriverData(void);
dll_export mciGetErrorStringA(void);
dll_export mciGetErrorStringW(void);
dll_export mciGetYieldProc(void);
dll_export mciLoadCommandResource(void);
dll_export mciSendCommandA(void);
dll_export mciSendCommandW(void);
dll_export mciSendStringA(void);
dll_export mciSendStringW(void);
dll_export mciSetDriverData(void);
dll_export mciSetYieldProc(void);
dll_export midiConnect(void);
dll_export midiDisconnect(void);
dll_export midiInAddBuffer(void);
dll_export midiInClose(void);
dll_export midiInGetDevCapsA(void);
dll_export midiInGetDevCapsW(void);
dll_export midiInGetErrorTextA(void);
dll_export midiInGetErrorTextW(void);
dll_export midiInGetID(void);
dll_export midiInGetNumDevs(void);
dll_export midiInMessage(void);
dll_export midiInOpen(void);
dll_export midiInPrepareHeader(void);
dll_export midiInReset(void);
dll_export midiInStart(void);
dll_export midiInStop(void);
dll_export midiInUnprepareHeader(void);
dll_export midiOutCacheDrumPatches(void);
dll_export midiOutCachePatches(void);
dll_export midiOutClose(void);
dll_export midiOutGetDevCapsA(void);
dll_export midiOutGetDevCapsW(void);
dll_export midiOutGetErrorTextA(void);
dll_export midiOutGetErrorTextW(void);
dll_export midiOutGetID(void);
dll_export midiOutGetNumDevs(void);
dll_export midiOutGetVolume(void);
dll_export midiOutLongMsg(void);
dll_export midiOutMessage(void);
dll_export midiOutOpen(void);
dll_export midiOutPrepareHeader(void);
dll_export midiOutReset(void);
dll_export midiOutSetVolume(void);
dll_export midiOutShortMsg(void);
dll_export midiOutUnprepareHeader(void);
dll_export midiStreamClose(void);
dll_export midiStreamOpen(void);
dll_export midiStreamOut(void);
dll_export midiStreamPause(void);
dll_export midiStreamPosition(void);
dll_export midiStreamProperty(void);
dll_export midiStreamRestart(void);
dll_export midiStreamStop(void);
dll_export mixerClose(void);
dll_export mixerGetControlDetailsA(void);
dll_export mixerGetControlDetailsW(void);
dll_export mixerGetDevCapsA(void);
dll_export mixerGetDevCapsW(void);
dll_export mixerGetID(void);
dll_export mixerGetLineControlsA(void);
dll_export mixerGetLineControlsW(void);
dll_export mixerGetLineInfoA(void);
dll_export mixerGetLineInfoW(void);
dll_export mixerGetNumDevs(void);
dll_export mixerMessage(void);
dll_export mixerOpen(void);
dll_export mixerSetControlDetails(void);
dll_export mmDrvInstall(void);
dll_export mmGetCurrentTask(void);
dll_export mmTaskBlock(void);
dll_export mmTaskCreate(void);
dll_export mmTaskSignal(void);
dll_export mmTaskYield(void);
dll_export mmioAdvance(void);
dll_export mmioAscend(void);
dll_export mmioClose(void);
dll_export mmioCreateChunk(void);
dll_export mmioDescend(void);
dll_export mmioFlush(void);
dll_export mmioGetInfo(void);
dll_export mmioInstallIOProcA(void);
dll_export mmioInstallIOProcW(void);
dll_export mmioOpenA(void);
dll_export mmioOpenW(void);
dll_export mmioRead(void);
dll_export mmioRenameA(void);
dll_export mmioRenameW(void);
dll_export mmioSeek(void);
dll_export mmioSendMessage(void);
dll_export mmioSetBuffer(void);
dll_export mmioSetInfo(void);
dll_export mmioStringToFOURCCA(void);
dll_export mmioStringToFOURCCW(void);
dll_export mmioWrite(void);
dll_export mmsystemGetVersion(void);
dll_export sndPlaySoundA(void);
dll_export sndPlaySoundW(void);
dll_export timeBeginPeriod(void);
dll_export timeEndPeriod(void);
dll_export timeGetDevCaps(void);
dll_export timeGetSystemTime(void);
dll_export timeGetTime(void);
dll_export timeKillEvent(void);
dll_export timeSetEvent(void);
dll_export waveInAddBuffer(void);
dll_export waveInClose(void);
dll_export waveInGetDevCapsA(void);
dll_export waveInGetDevCapsW(void);
dll_export waveInGetErrorTextA(void);
dll_export waveInGetErrorTextW(void);
dll_export waveInGetID(void);
dll_export waveInGetNumDevs(void);
dll_export waveInGetPosition(void);
dll_export waveInMessage(void);
dll_export waveInOpen(void);
dll_export waveInPrepareHeader(void);
dll_export waveInReset(void);
dll_export waveInStart(void);
dll_export waveInStop(void);
dll_export waveInUnprepareHeader(void);
dll_export waveOutBreakLoop(void);
dll_export waveOutClose(void);
dll_export waveOutGetDevCapsA(void);
dll_export waveOutGetDevCapsW(void);
dll_export waveOutGetErrorTextA(void);
dll_export waveOutGetErrorTextW(void);
dll_export waveOutGetID(void);
dll_export waveOutGetNumDevs(void);
dll_export waveOutGetPitch(void);
dll_export waveOutGetPlaybackRate(void);
dll_export waveOutGetPosition(void);
dll_export waveOutGetVolume(void);
dll_export waveOutMessage(void);
dll_export waveOutOpen(void);
dll_export waveOutPause(void);
dll_export waveOutPrepareHeader(void);
dll_export waveOutReset(void);
dll_export waveOutRestart(void);
dll_export waveOutSetPitch(void);
dll_export waveOutSetPlaybackRate(void);
dll_export waveOutSetVolume(void);
dll_export waveOutUnprepareHeader(void);
dll_export waveOutWrite(void);
#ifdef __BAK__PlaySound
#define PlaySound __BAK__PlaySound
#undef __BAK__PlaySound
#endif
#endif
} | [
"mudlord@protonmail.com"
] | mudlord@protonmail.com |
6ea885b50be074cc2ea8772786ef9734f96e130b | 1dbf007249acad6038d2aaa1751cbde7e7842c53 | /frs/include/huaweicloud/frs/v2/model/DetectFaceByUrlIntlRequest.h | 3227b6cb506fb72eddeee3df04c6d4d5759c2485 | [] | permissive | huaweicloud/huaweicloud-sdk-cpp-v3 | 24fc8d93c922598376bdb7d009e12378dff5dd20 | 71674f4afbb0cd5950f880ec516cfabcde71afe4 | refs/heads/master | 2023-08-04T19:37:47.187698 | 2023-08-03T08:25:43 | 2023-08-03T08:25:43 | 324,328,641 | 11 | 10 | Apache-2.0 | 2021-06-24T07:25:26 | 2020-12-25T09:11:43 | C++ | UTF-8 | C++ | false | false | 2,697 | h |
#ifndef HUAWEICLOUD_SDK_FRS_V2_MODEL_DetectFaceByUrlIntlRequest_H_
#define HUAWEICLOUD_SDK_FRS_V2_MODEL_DetectFaceByUrlIntlRequest_H_
#include <huaweicloud/frs/v2/FrsExport.h>
#include <huaweicloud/core/utils/ModelBase.h>
#include <huaweicloud/core/http/HttpResponse.h>
#include <huaweicloud/frs/v2/model/FaceDetectUrlReq.h>
#include <string>
namespace HuaweiCloud {
namespace Sdk {
namespace Frs {
namespace V2 {
namespace Model {
using namespace HuaweiCloud::Sdk::Core::Utils;
using namespace HuaweiCloud::Sdk::Core::Http;
/// <summary>
/// Request Object
/// </summary>
class HUAWEICLOUD_FRS_V2_EXPORT DetectFaceByUrlIntlRequest
: public ModelBase
{
public:
DetectFaceByUrlIntlRequest();
virtual ~DetectFaceByUrlIntlRequest();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
/////////////////////////////////////////////
/// DetectFaceByUrlIntlRequest members
/// <summary>
/// 企业项目ID。FRS支持通过企业项目管理(EPS)对不同用户组和用户的资源使用,进行分账。当前仅支持按需计费模式。 获取方法:进入“[企业项目管理](https://console.huaweicloud.com/eps/?region=cn-north-4#/projects/list)”页面,单击企业项目名称,在企业项目详情页获取Enterprise-Project-Id(企业项目ID)。 企业项目创建步骤请参见用户指南。 > 说明: 创建企业项目后,在传参时,有以下三类场景。 - 携带正确的ID,正常使用FRS服务,账单归到企业ID对应的企业项目中。 - 携带错误的ID,正常使用FRS服务,账单的企业项目会被分类为“未归集”。 - 不携带ID,正常使用FRS服务,账单的企业项目会被分类为“未归集”。
/// </summary>
std::string getEnterpriseProjectId() const;
bool enterpriseProjectIdIsSet() const;
void unsetenterpriseProjectId();
void setEnterpriseProjectId(const std::string& value);
/// <summary>
///
/// </summary>
FaceDetectUrlReq getBody() const;
bool bodyIsSet() const;
void unsetbody();
void setBody(const FaceDetectUrlReq& value);
protected:
std::string enterpriseProjectId_;
bool enterpriseProjectIdIsSet_;
FaceDetectUrlReq body_;
bool bodyIsSet_;
#ifdef RTTR_FLAG
RTTR_ENABLE()
public:
DetectFaceByUrlIntlRequest& dereference_from_shared_ptr(std::shared_ptr<DetectFaceByUrlIntlRequest> ptr) {
return *ptr;
}
#endif
};
}
}
}
}
}
#endif // HUAWEICLOUD_SDK_FRS_V2_MODEL_DetectFaceByUrlIntlRequest_H_
| [
"hwcloudsdk@huawei.com"
] | hwcloudsdk@huawei.com |
d52b68e2cc15d7ec0da06f1687ff4b917c23cc0d | 892d25a9cd975ef7f4cffe025e8e875d1bd06e1d | /srvutils.hpp | 13071b3ed0ea08aafb2578f6999576c58241847c | [] | no_license | xsilvertom/smithproxy | 576c61d49456f1980374055f214d5da2c8b54d4e | 2cf4accaf3598636db5cc6402f3d8e34a8af8ce7 | refs/heads/master | 2020-08-04T07:41:31.335180 | 2019-08-19T16:35:28 | 2019-08-19T16:35:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,945 | hpp | /*
Smithproxy- transparent proxy with SSL inspection capabilities.
Copyright (c) 2014, Ales Stibal <astib@mag0.net>, All rights reserved.
Smithproxy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Smithproxy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Smithproxy. If not, see <http://www.gnu.org/licenses/>.
Linking Smithproxy statically or dynamically with other modules is
making a combined work based on Smithproxy. Thus, the terms and
conditions of the GNU General Public License cover the whole combination.
In addition, as a special exception, the copyright holders of Smithproxy
give you permission to combine Smithproxy with free software programs
or libraries that are released under the GNU LGPL and with code
included in the standard release of OpenSSL under the OpenSSL's license
(or modified versions of such code, with unchanged license).
You may copy and distribute such a system following the terms
of the GNU GPL for Smithproxy and the licenses of the other code
concerned, provided that you include the source code of that other code
when and as the GNU GPL requires distribution of source code.
Note that people who make modified versions of Smithproxy are not
obligated to grant this special exception for their modified versions;
it is their choice whether to do so. The GNU General Public License
gives permission to release a modified version without this exception;
this exception also makes it possible to release a modified version
which carries forward this exception.
*/
#ifndef SRVUTILS_HPP_
#define SRVUTILS_HPP_
template <class Listener, class Com>
Listener* prepare_listener(std::string& str_port,const char* friendly_name,int def_port,int sub_workers) {
if(sub_workers < 0) {
return nullptr;
}
int port = def_port;
if(str_port.size()) {
try {
port = std::stoi(str_port);
}
catch(std::invalid_argument e) {
ERR_("Invalid port specified: %s",str_port.c_str());
return NULL;
}
}
NOT_("Entering %s mode on port %d",friendly_name,port);
auto s_p = new Listener(new Com());
s_p->com()->nonlocal_dst(true);
s_p->worker_count_preference(sub_workers);
// bind with master proxy (.. and create child proxies for new connections)
int s = s_p->bind(port,'L');
if (s < 0) {
FAT_("Error binding %s port (%d), exiting",friendly_name,s);
delete s_p;
return NULL;
};
s_p->com()->unblock(s);
s_p->com()->set_monitor(s);
s_p->com()->set_poll_handler(s,s_p);
return s_p;
}
template <class Listener, class Com>
Listener* prepare_listener(std::string& str_path,const char* friendly_name,std::string def_path,int sub_workers) {
if(sub_workers < 0) {
return nullptr;
}
std::string path = str_path;
if( path.size() == 0 ) {
path = def_path;
}
NOT_("Entering %s mode on port %s",friendly_name,path.c_str());
auto s_p = new Listener(new Com());
s_p->com()->nonlocal_dst(true);
s_p->worker_count_preference(sub_workers);
// bind with master proxy (.. and create child proxies for new connections)
int s = s_p->bind(path.c_str(),'L');
if (s < 0) {
FAT_("Error binding %s port (%d), exiting",friendly_name,s);
delete s_p;
return NULL;
};
return s_p;
}
#endif | [
"astib@mag0.net"
] | astib@mag0.net |
2f930e6a8681a4ca7c144becb6d236f491d77d9a | 6cc00c07a75bf18a2b1824383c3acc050098d9ed | /AtCoder/Solutions/abc174_b.cpp | 283d6473fb72e7746e55901c187eb8540d27fd34 | [
"MIT"
] | permissive | Mohammed-Shoaib/Coding-Problems | ac681c16c0f7c6d83f7cb46be71ea304d238344e | ccfb9fc2f0d8dff454439d75ce519cf83bad7c3b | refs/heads/master | 2022-06-14T02:24:10.316962 | 2022-03-20T20:04:16 | 2022-03-20T20:04:16 | 145,226,886 | 75 | 31 | MIT | 2020-10-02T07:46:58 | 2018-08-18T14:31:33 | C++ | UTF-8 | C++ | false | false | 499 | cpp | // Problem Code: abc174_b
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int distance(long long D, vector<pair<long long, long long>>& P) {
return count_if(P.begin(), P.end(), [&D](auto& p) {
return p.first * p.first + p.second * p.second <= D * D;
});
}
int main() {
int N, D;
cin >> N >> D;
vector<pair<long long, long long>> P(N);
for (int i = 0; i < N; i++)
cin >> P[i].first >> P[i].second;
cout << distance(D, P);
return 0;
} | [
"shoaib98libra@gmail.com"
] | shoaib98libra@gmail.com |
1392532c4214e35f98d01082e759c3a61ecebf14 | 527739ed800e3234136b3284838c81334b751b44 | /include/RED4ext/Types/generated/anim/IKTargetParams_Update.hpp | ae35cb2e3e039d8425aa46ce522a37d26a647595 | [
"MIT"
] | permissive | 0xSombra/RED4ext.SDK | 79ed912e5b628ef28efbf92d5bb257b195bfc821 | 218b411991ed0b7cb7acd5efdddd784f31c66f20 | refs/heads/master | 2023-07-02T11:03:45.732337 | 2021-04-15T16:38:19 | 2021-04-15T16:38:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 527 | hpp | #pragma once
// This file is generated from the Game's Reflection data
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/REDhash.hpp>
#include <RED4ext/ISerializable.hpp>
namespace RED4ext
{
namespace anim {
struct IKTargetParams_Update : ISerializable
{
static constexpr const char* NAME = "animIKTargetParams_Update";
static constexpr const char* ALIAS = NAME;
uint8_t unk30[0x40 - 0x30]; // 30
};
RED4EXT_ASSERT_SIZE(IKTargetParams_Update, 0x40);
} // namespace anim
} // namespace RED4ext
| [
"expired6978@gmail.com"
] | expired6978@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.