blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
4c6ebe4594975a28f44f18e73fedd10ef257f107
3b9b4049a8e7d38b49e07bb752780b2f1d792851
/src/net/dns/dns_session.h
43228e4c5f1872ecc0af0afdc9431a133c0fb15d
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
webosce/chromium53
f8e745e91363586aee9620c609aacf15b3261540
9171447efcf0bb393d41d1dc877c7c13c46d8e38
refs/heads/webosce
2020-03-26T23:08:14.416858
2018-08-23T08:35:17
2018-09-20T14:25:18
145,513,343
0
2
Apache-2.0
2019-08-21T22:44:55
2018-08-21T05:52:31
null
UTF-8
C++
false
false
5,270
h
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_DNS_DNS_SESSION_H_ #define NET_DNS_DNS_SESSION_H_ #include <stdint.h> #include <memory> #include <vector> #include "base/lazy_instance.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/metrics/bucket_ranges.h" #include "base/time/time.h" #include "net/base/net_export.h" #include "net/base/network_change_notifier.h" #include "net/base/rand_callback.h" #include "net/dns/dns_config_service.h" #include "net/dns/dns_socket_pool.h" namespace base { class BucketRanges; class SampleVector; } namespace net { class ClientSocketFactory; class DatagramClientSocket; class NetLog; class StreamSocket; // Session parameters and state shared between DNS transactions. // Ref-counted so that DnsClient::Request can keep working in absence of // DnsClient. A DnsSession must be recreated when DnsConfig changes. class NET_EXPORT_PRIVATE DnsSession : NON_EXPORTED_BASE(public base::RefCounted<DnsSession>), public NetworkChangeNotifier::ConnectionTypeObserver { public: typedef base::Callback<int()> RandCallback; class NET_EXPORT_PRIVATE SocketLease { public: SocketLease(scoped_refptr<DnsSession> session, unsigned server_index, std::unique_ptr<DatagramClientSocket> socket); ~SocketLease(); unsigned server_index() const { return server_index_; } DatagramClientSocket* socket() { return socket_.get(); } private: scoped_refptr<DnsSession> session_; unsigned server_index_; std::unique_ptr<DatagramClientSocket> socket_; DISALLOW_COPY_AND_ASSIGN(SocketLease); }; DnsSession(const DnsConfig& config, std::unique_ptr<DnsSocketPool> socket_pool, const RandIntCallback& rand_int_callback, NetLog* net_log); const DnsConfig& config() const { return config_; } NetLog* net_log() const { return net_log_; } // Return the next random query ID. uint16_t NextQueryId() const; // Return the index of the first configured server to use on first attempt. unsigned NextFirstServerIndex(); // Start with |server_index| and find the index of the next known good server // to use on this attempt. Returns |server_index| if this server has no // recorded failures, or if there are no other servers that have not failed // or have failed longer time ago. unsigned NextGoodServerIndex(unsigned server_index); // Record that server failed to respond (due to SRV_FAIL or timeout). void RecordServerFailure(unsigned server_index); // Record that server responded successfully. void RecordServerSuccess(unsigned server_index); // Record how long it took to receive a response from the server. void RecordRTT(unsigned server_index, base::TimeDelta rtt); // Record suspected loss of a packet for a specific server. void RecordLostPacket(unsigned server_index, int attempt); // Record server stats before it is destroyed. void RecordServerStats(); // Return the timeout for the next query. |attempt| counts from 0 and is used // for exponential backoff. base::TimeDelta NextTimeout(unsigned server_index, int attempt); // Allocate a socket, already connected to the server address. // When the SocketLease is destroyed, the socket will be freed. std::unique_ptr<SocketLease> AllocateSocket(unsigned server_index, const NetLog::Source& source); // Creates a StreamSocket from the factory for a transaction over TCP. These // sockets are not pooled. std::unique_ptr<StreamSocket> CreateTCPSocket(unsigned server_index, const NetLog::Source& source); private: friend class base::RefCounted<DnsSession>; ~DnsSession() override; void UpdateTimeouts(NetworkChangeNotifier::ConnectionType type); void InitializeServerStats(); // Release a socket. void FreeSocket(unsigned server_index, std::unique_ptr<DatagramClientSocket> socket); // Return the timeout using the TCP timeout method. base::TimeDelta NextTimeoutFromJacobson(unsigned server_index, int attempt); // Compute the timeout using the histogram method. base::TimeDelta NextTimeoutFromHistogram(unsigned server_index, int attempt); // NetworkChangeNotifier::ConnectionTypeObserver: void OnConnectionTypeChanged( NetworkChangeNotifier::ConnectionType type) override; const DnsConfig config_; std::unique_ptr<DnsSocketPool> socket_pool_; RandCallback rand_callback_; NetLog* net_log_; // Current index into |config_.nameservers| to begin resolution with. int server_index_; base::TimeDelta initial_timeout_; base::TimeDelta max_timeout_; struct ServerStats; // Track runtime statistics of each DNS server. std::vector<std::unique_ptr<ServerStats>> server_stats_; // Buckets shared for all |ServerStats::rtt_histogram|. struct RttBuckets : public base::BucketRanges { RttBuckets(); }; static base::LazyInstance<RttBuckets>::Leaky rtt_buckets_; DISALLOW_COPY_AND_ASSIGN(DnsSession); }; } // namespace net #endif // NET_DNS_DNS_SESSION_H_
[ "changhyeok.bae@lge.com" ]
changhyeok.bae@lge.com
5d86c46516edb4758083731ddfe0cc33caff91f3
26870790cfcc9b0967a1dd56433f5bd5fabbb05a
/M08/ex01/main.cpp
b693619b6fe61ba71b6be8f7aa1d7e931f5cab00
[]
no_license
Zera57/CPPModules
e87bd7bcc683f64f3726217c7326fb60186ecd16
0c588ddfc2b4193fca8c7c1cb75deb83d8ef8e03
refs/heads/master
2023-05-30T10:13:11.074873
2021-06-20T17:00:09
2021-06-20T17:00:09
358,862,884
0
0
null
null
null
null
UTF-8
C++
false
false
1,374
cpp
#include "span.hpp" using std::cout; using std::endl; int main() { srand(time(NULL)); std::cout << "-----" << std::endl; std::cout << "TEST1" << std::endl; std::cout << "-----" << std::endl; { Span sp(1000); for (int i = 0; i < 1000; ++i) { sp.addNumber(i + rand() % 10); } cout << "short: " << sp.shortestSpan() << endl; cout << "longest: " << sp.longestSpan() << endl; } std::cout << "-----" << std::endl; std::cout << "TEST2" << std::endl; std::cout << "-----" << std::endl; { Span sp(5); for (int i = 0; i < 5; ++i) { sp.addNumber(i + rand() % 10); cout << sp[i] << " "; } cout << endl; cout << "short: " << sp.shortestSpan() << endl; cout << "longest: " << sp.longestSpan() << endl; } std::cout << "-------" << std::endl; std::cout << "Subject" << std::endl; std::cout << "-------" << std::endl; { Span sp = Span(5); sp.addNumber(5); sp.addNumber(3); sp.addNumber(17); sp.addNumber(9); sp.addNumber(11); for (size_t i = 0; i < sp.count(); i++) { std::cout << sp[i] << " "; } cout << endl << sp.shortestSpan() << endl; cout << sp.longestSpan() << endl; } return 0; }
[ "svetik.avtonomov@gmail.com" ]
svetik.avtonomov@gmail.com
3d3ef999b1dbb5a53f84afe0e0095dd8f2e39c1e
0fb9636b9f3fe5671374811c62616bd6c7eb6a40
/SimCache/Node.cpp
3b62481317cd5b83cd9f0092dd1bf19f8f5767f2
[]
no_license
alexbikfalvi/SimCache
44edc7be446d413679ec83316b09acf741b72132
a38bb889dc3d982f6993d7f71205d9e3af4fa899
refs/heads/master
2021-01-18T14:38:28.903756
2013-01-18T15:32:14
2013-01-18T15:32:14
7,688,956
0
1
null
null
null
null
UTF-8
C++
false
false
37
cpp
#include "stdafx.h" #include "Node.h"
[ "alex@bikfalvi.com" ]
alex@bikfalvi.com
d7c9cc4ca7fda677c48a8d63ecdd23fbe9890864
e16d4d524a9a8d35a62adf2d2c57a41a9d5651bb
/图论/树/LCA/LCA_Tarjan.cpp
6271657675e11dba2065bd4efb6b349002b91516
[ "MIT" ]
permissive
Acathe/ICPC_Template
ac23a8dfb3a095dfb1466037d8b556a373b223cf
a46e40c73db2adc821f4f9fdfd60d8fb02c773b1
refs/heads/master
2023-04-12T13:44:10.795473
2023-04-08T17:41:08
2023-04-08T17:41:08
299,807,871
11
0
null
2020-10-13T02:26:38
2020-09-30T04:23:11
C++
UTF-8
C++
false
false
2,252
cpp
/** * @birth: created by Acathe on 2020-09-28 * @content: LCA * @version 1.0.0 * @revision: last revised by Acathe on 2020-09-28 * @template: https://www.luogu.com.cn/problem/P3379 */ #include <bits/stdc++.h> using namespace std; constexpr size_t kMaxV = 5e5 + 5; struct Edge { int u, v, w; }; struct Graph { vector<int> adj[kMaxV]; vector<Edge> e; void init() { e.clear(); for (auto& i: adj) i.clear(); } void addEdge(int u, int v, int w) { adj[u].push_back(e.size()); e.push_back({u, v, w}); } }; struct DSU { int par[kMaxV]; void init() { for (int i = 0; i < kMaxV; ++i) par[i] = i; } int find(int x) { if (par[x] != x) par[x] = find(par[x]); return par[x]; } void unionXToY(int x, int y) { par[find(x)] = find(y); } }; struct LCA : Graph { bool vis[kMaxV]; DSU dsu; Graph ask; int ans[kMaxV]; void init() { Graph::init(); ask.init(); } void addEdge(int u, int v) { Graph::addEdge(u, v, 1); Graph::addEdge(v, u, 1); } void addAsk( int idx, int u, int v) { ask.addEdge(u, v, idx); ask.addEdge(v, u, idx); } void tarjan(int u, int par) { for (const auto& i: adj[u]) { int v = e[i].v; if (v == par) continue; tarjan(v, u); dsu.unionXToY(v, u); vis[v] = true; } for (const auto& i: ask.adj[u]) { int v = ask.e[i].v, id = ask.e[i].w; if (vis[v]) ans[id] = dsu.find(v); } } void solveLCA(int rt) { dsu.init(); memset(vis, 0, sizeof(vis)); tarjan(rt, 0); } }; int n, m, s; LCA tree; int main() { #ifndef DEBUG ios::sync_with_stdio(false); cin.tie(nullptr); #endif // DEBUG cin >> n >> m >> s; tree.init(); for (int i = 1; i < n; ++i) { int u, v; cin >> u >> v; tree.addEdge(u, v); } for (int i = 0; i < m; ++i) { int u, v; cin >> u >> v; tree.addAsk(i, u, v); } tree.solveLCA(s); for (int i = 0; i < m; ++i) cout << tree.ans[i] << '\n'; return 0; }
[ "1353217816@qq.com" ]
1353217816@qq.com
f9bfa4c56aa6b977cca07d9876b4e7a775a6fc93
d2d6aae454fd2042c39127e65fce4362aba67d97
/build/Android/Preview/app/src/main/jni/_root.Name.cpp
ff6aa23a1a44d7155a2283e4ccd8282190158261
[]
no_license
Medbeji/Eventy
de88386ff9826b411b243d7719b22ff5493f18f5
521261bca5b00ba879e14a2992e6980b225c50d4
refs/heads/master
2021-01-23T00:34:16.273411
2017-09-24T21:16:34
2017-09-24T21:16:34
92,812,809
2
0
null
null
null
null
UTF-8
C++
false
false
8,925
cpp
// This file was generated based on /Users/medbeji/Documents/event-app/event-app/build/Android/Preview/cache/ux11/Name.g.uno. // WARNING: Changes might be lost if you edit this file directly. #include <_root.EventApp_bundle.h> #include <_root.Name.h> #include <Fuse.Controls.TextControl.h> #include <Fuse.Font.h> #include <Uno.Float.h> #include <Uno.IO.BundleFile.h> #include <Uno.UX.BundleFileSource.h> #include <Uno.UX.FileSource.h> namespace g{ // public partial sealed class Name :2 // { // static Name() :4 static void Name__cctor_4_fn(uType* __type) { } static void Name_build(uType* type) { type->SetInterfaces( ::g::Uno::Collections::IList_typeof()->MakeType(::g::Fuse::Binding_typeof(), NULL), offsetof(::g::Fuse::Controls::TextControl_type, interface0), ::g::Fuse::Scripting::IScriptObject_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface1), ::g::Fuse::IProperties_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface2), ::g::Fuse::INotifyUnrooted_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface3), ::g::Uno::Collections::ICollection_typeof()->MakeType(::g::Fuse::Binding_typeof(), NULL), offsetof(::g::Fuse::Controls::TextControl_type, interface4), ::g::Uno::Collections::IEnumerable_typeof()->MakeType(::g::Fuse::Binding_typeof(), NULL), offsetof(::g::Fuse::Controls::TextControl_type, interface5), ::g::Uno::Collections::IList_typeof()->MakeType(::g::Fuse::Node_typeof(), NULL), offsetof(::g::Fuse::Controls::TextControl_type, interface6), ::g::Uno::UX::IPropertyListener_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface7), ::g::Uno::Collections::ICollection_typeof()->MakeType(::g::Fuse::Node_typeof(), NULL), offsetof(::g::Fuse::Controls::TextControl_type, interface8), ::g::Uno::Collections::IEnumerable_typeof()->MakeType(::g::Fuse::Node_typeof(), NULL), offsetof(::g::Fuse::Controls::TextControl_type, interface9), ::g::Fuse::Triggers::Actions::IShow_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface10), ::g::Fuse::Triggers::Actions::IHide_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface11), ::g::Fuse::Triggers::Actions::ICollapse_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface12), ::g::Fuse::IActualPlacement_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface13), ::g::Fuse::Animations::IResize_typeof(), offsetof(::g::Fuse::Controls::TextControl_type, interface14), ::g::Fuse::Triggers::IValue_typeof()->MakeType(::g::Uno::String_typeof(), NULL), offsetof(::g::Fuse::Controls::TextControl_type, interface15)); type->SetFields(104); type->Reflection.SetFunctions(1, new uFunction(".ctor", NULL, (void*)Name__New4_fn, 0, true, type, 0)); } ::g::Fuse::Controls::TextControl_type* Name_typeof() { static uSStrong< ::g::Fuse::Controls::TextControl_type*> type; if (type != NULL) return type; uTypeOptions options; options.BaseDefinition = ::g::Fuse::Controls::Text_typeof(); options.FieldCount = 104; options.InterfaceCount = 16; options.ObjectSize = sizeof(Name); options.TypeSize = sizeof(::g::Fuse::Controls::TextControl_type); type = (::g::Fuse::Controls::TextControl_type*)uClassType::New("Name", options); type->fp_build_ = Name_build; type->fp_ctor_ = (void*)Name__New4_fn; type->fp_cctor_ = Name__cctor_4_fn; type->interface15.fp_get_Value = (void(*)(uObject*, uTRef))::g::Fuse::Controls::TextControl__get_Value_fn; type->interface15.fp_set_Value = (void(*)(uObject*, void*))::g::Fuse::Controls::TextControl__set_Value_fn; type->interface15.fp_add_ValueChanged = (void(*)(uObject*, uDelegate*))::g::Fuse::Controls::TextControl__add_ValueChanged_fn; type->interface15.fp_remove_ValueChanged = (void(*)(uObject*, uDelegate*))::g::Fuse::Controls::TextControl__remove_ValueChanged_fn; type->interface10.fp_Show = (void(*)(uObject*))::g::Fuse::Elements::Element__FuseTriggersActionsIShowShow_fn; type->interface12.fp_Collapse = (void(*)(uObject*))::g::Fuse::Elements::Element__FuseTriggersActionsICollapseCollapse_fn; type->interface11.fp_Hide = (void(*)(uObject*))::g::Fuse::Elements::Element__FuseTriggersActionsIHideHide_fn; type->interface14.fp_SetSize = (void(*)(uObject*, ::g::Uno::Float2*))::g::Fuse::Elements::Element__FuseAnimationsIResizeSetSize_fn; type->interface13.fp_get_ActualSize = (void(*)(uObject*, ::g::Uno::Float3*))::g::Fuse::Elements::Element__FuseIActualPlacementget_ActualSize_fn; type->interface13.fp_get_ActualPosition = (void(*)(uObject*, ::g::Uno::Float3*))::g::Fuse::Elements::Element__FuseIActualPlacementget_ActualPosition_fn; type->interface13.fp_add_Placed = (void(*)(uObject*, uDelegate*))::g::Fuse::Elements::Element__add_Placed_fn; type->interface13.fp_remove_Placed = (void(*)(uObject*, uDelegate*))::g::Fuse::Elements::Element__remove_Placed_fn; type->interface8.fp_Clear = (void(*)(uObject*))::g::Fuse::Visual__UnoCollectionsICollectionFuseNodeClear_fn; type->interface8.fp_Contains = (void(*)(uObject*, void*, bool*))::g::Fuse::Visual__UnoCollectionsICollectionFuseNodeContains_fn; type->interface6.fp_RemoveAt = (void(*)(uObject*, int*))::g::Fuse::Visual__UnoCollectionsIListFuseNodeRemoveAt_fn; type->interface9.fp_GetEnumerator = (void(*)(uObject*, uObject**))::g::Fuse::Visual__UnoCollectionsIEnumerableFuseNodeGetEnumerator_fn; type->interface8.fp_get_Count = (void(*)(uObject*, int*))::g::Fuse::Visual__UnoCollectionsICollectionFuseNodeget_Count_fn; type->interface6.fp_get_Item = (void(*)(uObject*, int*, uTRef))::g::Fuse::Visual__UnoCollectionsIListFuseNodeget_Item_fn; type->interface6.fp_Insert = (void(*)(uObject*, int*, void*))::g::Fuse::Visual__Insert1_fn; type->interface7.fp_OnPropertyChanged = (void(*)(uObject*, ::g::Uno::UX::PropertyObject*, ::g::Uno::UX::Selector*))::g::Fuse::Controls::Control__OnPropertyChanged2_fn; type->interface8.fp_Add = (void(*)(uObject*, void*))::g::Fuse::Visual__Add1_fn; type->interface8.fp_Remove = (void(*)(uObject*, void*, bool*))::g::Fuse::Visual__Remove1_fn; type->interface4.fp_Clear = (void(*)(uObject*))::g::Fuse::Node__UnoCollectionsICollectionFuseBindingClear_fn; type->interface4.fp_Contains = (void(*)(uObject*, void*, bool*))::g::Fuse::Node__UnoCollectionsICollectionFuseBindingContains_fn; type->interface0.fp_RemoveAt = (void(*)(uObject*, int*))::g::Fuse::Node__UnoCollectionsIListFuseBindingRemoveAt_fn; type->interface5.fp_GetEnumerator = (void(*)(uObject*, uObject**))::g::Fuse::Node__UnoCollectionsIEnumerableFuseBindingGetEnumerator_fn; type->interface1.fp_SetScriptObject = (void(*)(uObject*, uObject*, ::g::Fuse::Scripting::Context*))::g::Fuse::Node__FuseScriptingIScriptObjectSetScriptObject_fn; type->interface4.fp_get_Count = (void(*)(uObject*, int*))::g::Fuse::Node__UnoCollectionsICollectionFuseBindingget_Count_fn; type->interface0.fp_get_Item = (void(*)(uObject*, int*, uTRef))::g::Fuse::Node__UnoCollectionsIListFuseBindingget_Item_fn; type->interface1.fp_get_ScriptObject = (void(*)(uObject*, uObject**))::g::Fuse::Node__FuseScriptingIScriptObjectget_ScriptObject_fn; type->interface1.fp_get_ScriptContext = (void(*)(uObject*, ::g::Fuse::Scripting::Context**))::g::Fuse::Node__FuseScriptingIScriptObjectget_ScriptContext_fn; type->interface3.fp_add_Unrooted = (void(*)(uObject*, uDelegate*))::g::Fuse::Node__FuseINotifyUnrootedadd_Unrooted_fn; type->interface3.fp_remove_Unrooted = (void(*)(uObject*, uDelegate*))::g::Fuse::Node__FuseINotifyUnrootedremove_Unrooted_fn; type->interface0.fp_Insert = (void(*)(uObject*, int*, void*))::g::Fuse::Node__Insert_fn; type->interface2.fp_get_Properties = (void(*)(uObject*, ::g::Fuse::Properties**))::g::Fuse::Node__get_Properties_fn; type->interface4.fp_Add = (void(*)(uObject*, void*))::g::Fuse::Node__Add_fn; type->interface4.fp_Remove = (void(*)(uObject*, void*, bool*))::g::Fuse::Node__Remove_fn; return type; } // public Name() :8 void Name__ctor_8_fn(Name* __this) { __this->ctor_8(); } // private void InitializeUX() :12 void Name__InitializeUX1_fn(Name* __this) { __this->InitializeUX1(); } // public Name New() :8 void Name__New4_fn(Name** __retval) { *__retval = Name::New4(); } // public Name() [instance] :8 void Name::ctor_8() { ctor_7(); InitializeUX1(); } // private void InitializeUX() [instance] :12 void Name::InitializeUX1() { uStackFrame __("Name", "InitializeUX()"); ::g::Fuse::Font* temp = ::g::Fuse::Font::New2(::g::Uno::UX::BundleFileSource::New1(::g::EventApp_bundle::RobotoBold71b103b2())); FontSize(15.0f); Font(temp); } // public Name New() [static] :8 Name* Name::New4() { Name* obj1 = (Name*)uNew(Name_typeof()); obj1->ctor_8(); return obj1; } // } } // ::g
[ "medbeji@MacBook-Pro-de-MedBeji.local" ]
medbeji@MacBook-Pro-de-MedBeji.local
d25e337effcd9ee87aff2ab7f9ad1216f061025c
27b17470be140efa743c18cbb12df7e339d46b7d
/gas_station/main.cpp
638b677c8f23eca0270e610815a4cfe65879a118
[]
no_license
slicer2/leetcode
196f0035154b1767308e39209d8574178f9e00c9
c240353d68eef24fa4de7526cbcbac9aee1323d4
refs/heads/master
2021-01-01T19:05:00.812940
2017-07-27T21:05:11
2017-07-27T21:05:11
98,502,329
0
0
null
null
null
null
UTF-8
C++
false
false
2,383
cpp
#include <iostream> #include <vector> #include <cassert> using namespace std; template <typename T> ostream & operator << (ostream & os, vector<T> v) { typename vector<T>::iterator it; for (it=v.begin(); it != v.end(); it++) os << (*it) << ' '; os<< endl; return os; } class Solution { public: int canCompleteCircuit(vector<int> &gas, vector<int> &cost) { vector<int> gasCost; //cerr << gas.size() << endl; assert(gas.size() == cost.size()); assert(gas.size() > 0); for (int i=0; i<gas.size(); i++) gasCost.push_back(gas[i]-cost[i]); if (gasCost.size() == 1) { if (gasCost[0] >= 0) return 0; else return -1; } int comb = gasCost[0]; int idx = 0; vector<int> combIdx, combCost; for (int i=1; i<gasCost.size(); i++) { if ( (gasCost[i] <= 0 && comb <= 0) || (gasCost[i] >= 0 && comb >= 0) ) comb += gasCost[i]; else { combCost.push_back(comb); comb = gasCost[i]; combIdx.push_back(idx); idx = i; } } if ( combCost.size() ) { if ( (comb <= 0 && combCost[0] <= 0) || (comb >= 0 && combCost[0] >= 0) ) { combCost[0] += comb; combIdx[0] = idx; } else { combCost.push_back(comb); combIdx.push_back(idx); } } else { combCost.push_back(comb); combIdx.push_back(idx); } if (combCost.size() == 1) { if (combCost[0] >= 0) return combIdx[0]; else return -1; } else { int startIdx = -1; for (int i=0; i<combCost.size(); i++) if (combCost[i] > 0) { startIdx = i; break; } else if (combCost[i] < 0) { startIdx = (i+1) % combCost.size(); break; } assert (startIdx != -1); vector<int> new_gas, new_cost, new_idx; int i = startIdx; do { new_gas.push_back(combCost[i]); new_idx.push_back(combIdx[i]); new_cost.push_back(-combCost[(i+1) % combCost.size()]); //cerr<< new_gas; //cerr<< new_cost; //cerr<< new_idx; i = (i+2) % combCost.size(); } while (i != startIdx); int stationIdx = canCompleteCircuit(new_gas, new_cost); if (stationIdx == -1) return -1; else return new_idx[stationIdx]; } } }; int main() { int a, c; vector<int> gas, cost; while (cin >> a >> c) { gas.push_back(a); cost.push_back(c); } Solution s; //cerr << gas; //cerr << cost; cout << s.canCompleteCircuit(gas, cost) << endl; return 0; }
[ "zhangdan@gmail.com" ]
zhangdan@gmail.com
7ca3382f0b1b81c628c6f40225ddaf1adb133926
473a938582997e411f3f67bce0c948515b7357aa
/Race/WaterMesh.h
bda56950b09d8a590c04583cafe775e3cbb50d3a
[]
no_license
dgalles/Race
be2828daa65df46fde709534a0fcbdb5ade71ed8
334d391bc4f4dbbf30b0a44eea0b4537886023bf
refs/heads/master
2021-01-25T09:04:13.692127
2017-06-08T17:47:49
2017-06-08T17:47:49
93,776,676
0
0
null
null
null
null
UTF-8
C++
false
false
1,996
h
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2013 Torus Knot Software Ltd Also see acknowledgements in Readme.html You may use this sample code for anything you like, it is not covered by the same license as the rest of the engine. -- --------------------------------------------------------------------------- s*/ #ifndef _WATER_MESH_H_ #define _WATER_MESH_H_ #include "OgrePlatform.h" #include "Ogre.h" using namespace Ogre ; class WaterMesh { private: MeshPtr mesh ; SubMesh *subMesh ; float *vertexBuffers[3] ; // we need 3 vertex buffers int currentBuffNumber ; int complexity ; String meshName ; int numFaces ; int numVertices ; Vector3* vNormals ; HardwareVertexBufferSharedPtr posVertexBuffer ; HardwareVertexBufferSharedPtr normVertexBuffer ; HardwareVertexBufferSharedPtr texcoordsVertexBuffer ; HardwareIndexBufferSharedPtr indexBuffer ; Real lastTimeStamp ; Real lastAnimationTimeStamp; Real lastFrameTime ; void calculateFakeNormals(); void calculateNormals(); public: WaterMesh(const String& meshName, Real planeSize, int complexity) ; virtual ~WaterMesh (); /** "pushes" a mesh at position [x,y]. Note, that x,y are float, hence * 4 vertices are actually pushed * @note * This should be replaced by push with 'radius' parameter to simulate * big objects falling into water */ void push(Real x, Real y, Real depth, bool absolute=false) ; /** gets height at given x and y, takes average value of the closes nodes */ Real getHeight(Real x, Real y); /** updates mesh */ void updateMesh(Real timeSinceLastFrame) ; Real PARAM_C ; // ripple speed Real PARAM_D ; // distance Real PARAM_U ; // viscosity Real PARAM_T ; // time bool useFakeNormals ; } ; #endif
[ "galles@60946281-439d-462c-8c31-fb3142b233e8" ]
galles@60946281-439d-462c-8c31-fb3142b233e8
84bc3937113cf0a1835b54e4296dbf2444b1d613
59dcfc00711dee3b426a6c5322da0141a5dd92f3
/Game/BlueBerryEngine/TimeManager.h
58515ed8481000fa7a002ca188ab0373e99cf509
[]
no_license
PeterCat12/BlueBerry_GameEngine
2692fa289a71bf197e74b734c7957436fc530a89
a629fd5f3d694a82a58ff57cead15db333f9abfb
refs/heads/master
2021-01-10T22:10:07.280351
2015-03-03T00:45:45
2015-03-03T00:45:45
31,570,956
0
0
null
null
null
null
UTF-8
C++
false
false
2,068
h
//----------------------------------------------------------------- // TimeManager class // C++ Header File TimeManager.h //----------------------------------------------------------------- #ifndef TIMEMANAGER_H #define TIMEMANAGER_H //----------------------------------------------------------------- // Include files //----------------------------------------------------------------- #include "Trace.h" #include "StopWatch.h" //class StopWatch; //----------------------------------------------------------------- // TimeManager Class //----------------------------------------------------------------- class TimeManager { protected: StopWatch m_pStopWatch; StopWatch m_pTotalWatch; public: // Constructor(s) /Destructors ~TimeManager(void); // General Methods static void InitTimeManager(); //StopWatch* _StopWatch, StopWatch* _TotalWatch); static void Delete(); static void TickTock(); static float GetFrameTime(); static float GetTotalTime(); static StopWatch* GetTotalWatch(); static StopWatch* GetStopWatch(); //static void Update(); private: // Constructor(s) //TimeManager(StopWatch* _StopWatch, StopWatch* _TotalWatch); TimeManager(); // Helper Methods static TimeManager* GetTimeManager(); float GetFrameTimeHelper(); float GetToalTimeHelper(); void TickTockHelper(); StopWatch* GetTotalWatchHelper(); StopWatch* GetStopWatchHelper(); //void UpdateHelper(); //private singleton members static bool m_bInstanceFlag; static TimeManager* m_tmSingle; }; #endif // !TIMEMANAGER_H //Time (Displayed for illustration only) // printf("TotalTime: %.2f s lastFrame: %.4f s (%.0f FPS)\n",TimeManager::GetTotalTime(), TimeManager::GetFrameTime(), 1/TimeManager::GetStopWatch()->timeInSeconds()); //char buff[50]; //sprintf_s(buff, "TotalTime: %.2f s lastFrame: %.4f s (%.0f FPS)", TimeManager::GetTotalWatch()->timeInSeconds(),TimeManager::GetStopWatch()->timeInSeconds(), 1/TimeManager::GetStopWatch()->timeInSeconds()); //glfwSetWindowTitle( this->window, buff );
[ "pwensel@gmail.com" ]
pwensel@gmail.com
ece8666ff95084b73901816b79ec8c4675e8ffe1
91a40f509a3bb263c24a8200e2dec2799f892de5
/mobile/test/common/engine_test.cc
a184a2398b9dc12f24199019e8fab7ae9b20e11c
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
peip-mirror/envoy
63adac2bfa59a54574242d827249caf931293469
317efa53c6add02fa9533fc8f93f10f590077dca
refs/heads/master
2023-03-18T19:13:13.793761
2022-12-30T12:01:17
2022-12-30T12:01:17
111,212,703
0
3
Apache-2.0
2023-03-03T20:09:06
2017-11-18T14:38:04
C++
UTF-8
C++
false
false
5,264
cc
#include "absl/synchronization/notification.h" #include "gtest/gtest.h" #include "library/common/config/templates.h" #include "library/common/engine.h" #include "library/common/engine_handle.h" #include "library/common/main_interface.h" namespace Envoy { // This config is the minimal envoy mobile config that allows for running the engine. const std::string MINIMAL_TEST_CONFIG = R"( static_resources: listeners: - name: base_api_listener address: socket_address: { protocol: TCP, address: 0.0.0.0, port_value: 10000 } api_listener: api_listener: "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.EnvoyMobileHttpConnectionManager config: stat_prefix: hcm route_config: name: api_router virtual_hosts: - name: api include_attempt_count_in_response: true domains: ["*"] routes: - match: { prefix: "/" } route: cluster_header: x-envoy-mobile-cluster retry_policy: retry_back_off: { base_interval: 0.25s, max_interval: 60s } http_filters: - name: envoy.router typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router layered_runtime: layers: - name: static_layer_0 static_layer: overload: { global_downstream_max_connections: 50000 } )"; // RAII wrapper for the engine, ensuring that we properly shut down the engine. If the engine // thread is not torn down, we end up with TSAN failures during shutdown due to a data race // between the main thread and the engine thread both writing to the // Envoy::Logger::current_log_context global. struct TestEngineHandle { envoy_engine_t handle_; TestEngineHandle(envoy_engine_callbacks callbacks, const std::string& level) { handle_ = init_engine(callbacks, {}, {}); run_engine(handle_, MINIMAL_TEST_CONFIG.c_str(), level.c_str(), ""); } void terminate() { terminate_engine(handle_, /* release */ false); } ~TestEngineHandle() { terminate_engine(handle_, /* release */ true); } }; class EngineTest : public testing::Test { public: std::unique_ptr<TestEngineHandle> engine_; }; typedef struct { absl::Notification on_engine_running; absl::Notification on_exit; } engine_test_context; TEST_F(EngineTest, EarlyExit) { const std::string level = "debug"; engine_test_context test_context{}; envoy_engine_callbacks callbacks{[](void* context) -> void { auto* engine_running = static_cast<engine_test_context*>(context); engine_running->on_engine_running.Notify(); } /*on_engine_running*/, [](void* context) -> void { auto* exit = static_cast<engine_test_context*>(context); exit->on_exit.Notify(); } /*on_exit*/, &test_context /*context*/}; engine_ = std::make_unique<TestEngineHandle>(callbacks, level); envoy_engine_t handle = engine_->handle_; ASSERT_TRUE(test_context.on_engine_running.WaitForNotificationWithTimeout(absl::Seconds(3))); engine_->terminate(); ASSERT_TRUE(test_context.on_exit.WaitForNotificationWithTimeout(absl::Seconds(3))); start_stream(handle, 0, {}, false); engine_.reset(); } TEST_F(EngineTest, AccessEngineAfterInitialization) { const std::string level = "debug"; engine_test_context test_context{}; envoy_engine_callbacks callbacks{[](void* context) -> void { auto* engine_running = static_cast<engine_test_context*>(context); engine_running->on_engine_running.Notify(); } /*on_engine_running*/, [](void*) -> void {} /*on_exit*/, &test_context /*context*/}; engine_ = std::make_unique<TestEngineHandle>(callbacks, level); envoy_engine_t handle = engine_->handle_; ASSERT_TRUE(test_context.on_engine_running.WaitForNotificationWithTimeout(absl::Seconds(3))); absl::Notification getClusterManagerInvoked; // Scheduling on the dispatcher should work, the engine is running. EXPECT_EQ(ENVOY_SUCCESS, EngineHandle::runOnEngineDispatcher( handle, [&getClusterManagerInvoked](Envoy::Engine& engine) { engine.getClusterManager(); getClusterManagerInvoked.Notify(); })); // Validate that we actually invoked the function. EXPECT_TRUE(getClusterManagerInvoked.WaitForNotificationWithTimeout(absl::Seconds(1))); engine_->terminate(); // Now that the engine has been shut down, we no longer expect scheduling to work. EXPECT_EQ(ENVOY_FAILURE, EngineHandle::runOnEngineDispatcher( handle, [](Envoy::Engine& engine) { engine.getClusterManager(); })); engine_.reset(); } } // namespace Envoy
[ "jp@jpsim.com" ]
jp@jpsim.com
1960093fd22a2aadc274941d6d2991be49e90e58
92c6a030171ea0f612e888a8b05121389a0f3aa7
/backend/backend.h
0de163d1d8e0d36fb412d0ac451316c5e9c5dd46
[ "BSD-3-Clause" ]
permissive
janLo/traffic-service-server
efec1d84ad68860ebc4e2953f4a802f77a888efc
61ffbc5697130918aa600a031ab48ea76791acb9
refs/heads/master
2021-01-13T11:17:13.714738
2015-06-17T00:30:48
2015-06-17T00:30:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,101
h
#ifndef __BACKEND__DATA_FETCH_H__ #define __BACKEND__DATA_FETCH_H__ #include "reply_message.h" #include "request_message.h" namespace traffic { /** * \brief This is the main backend data providing interface. * * This interface has to be implemented for any data backend. It provides * methods to fetch the data from the database and compose the reply. * * Its creation is controlled by the DataProviderFactory, thick is asked for * an instance() for every request. Its up to the factory to have one instance, * one per worker(thread) or one per request. */ class DataProvider { public: /** * \brief Define a shared_ptr as pointer for the lazy programmer. */ using ptr_t = std::shared_ptr<DataProvider>; /** * \brief Process a summary request. * * Summary requests get one or many addresses and a timerange and * compose a reply with the sum of input and output bytes for each * address. The number of addresses can be limited in the * implementation by returning an traffic::ErrorReply message that will * be delivered to the client. This can also be done for other errors. * * The traffic::ReplyMessage cannot be copied on return and must be * moved! * * \param request The request data for this request * \return Either a traffic::SummaryReply or a traffic::ErrorReply. */ virtual ReplyMessage fetch_summary(SummaryRequest const &request) = 0; /** * \brief Process a statistic request. * * Statistic requests get one address, an interval and a timerange and * compose a reply with imout and output sums at the requested interval * granularity within the requested timerange. On error a * traffic::ErrorReply message can be returned and will be delivered to * the client. * * The traffic::ReplyMessage cannot be copied on return and must be * moved! * * \param request The request data for this request * \return Either a traffic::StatisticReply or a traffic::ErrorReply. */ virtual ReplyMessage fetch_statistic(StatisticRequest const &request) = 0; }; /** * \brief This is a factory for creating DataProviders. * * Each worker will have a reference to it and use it to get a provider for * each request. It is up to the factory which parts of the provider * implementation are shared between the worker(threads) and the requests. * * NOTE: There is only one instance shared across all workers. So you have to * guard access to shared data either by locks or use thread-local storage * types. */ class DataProviderFactory { public: /** * \brief Create (or get) a DataProvider instance. * * This will be called from the workers on each request to get a * DataProvider instance to work with. The Factory have to care about * data races between the worker threads. * * The worker will release its reference of the provider at the end of * the request. So its up to the factory to store the pointer to * preserve the provider for another request or to drop it. * * \return A DataProvider to use from the workers. */ virtual DataProvider::ptr_t instance() = 0; }; } #endif
[ "losinski@wh2.tu-dresden.de" ]
losinski@wh2.tu-dresden.de
d56063709361aeefcd80011a3a90eab4a31662ef
e8ce6d40f69b614e7420c64edce4ef0cce79893d
/2755.cpp
48ecb102aada7f22570eebfe43df2190b413ea0f
[]
no_license
Eberty/CodigosURI
1a23af25454bc059f9cfabce1678c7d2b053aec9
65a43c59a8594940312cc4526fe63536b2ca31f2
refs/heads/master
2020-05-14T02:04:55.348762
2019-08-05T03:00:45
2019-08-05T03:00:45
181,687,981
0
0
null
null
null
null
UTF-8
C++
false
false
243
cpp
#include <bits/stdc++.h> using namespace std; int main() { cout << "\"Ro\'b\'er\tto\\/\"" << endl; cout << "(._.) ( l: ) ( .-. ) ( :l ) (._.)" << endl; cout << "(^_-) (-_-) (-_^)" << endl; cout << "(\"_\") (\'.\')" << endl; return 0; }
[ "eberty.silva@hotmail.com" ]
eberty.silva@hotmail.com
2a1c0bf776ab2ff948a9b87c3006dc2d734a52cc
87a6ad7a80369ba186f7f2063c9f656bea251444
/recursividad/main.cpp
216253f0f429724a41e3157b522a30f591799bb2
[]
no_license
Krikorotojava/1CM2_Fundamentos_Programacion
6a7a839b854bf03c127c0b5583be109a29f9d677
e09b1af3a412a5feaa9d576e2cadb75e96cf5189
refs/heads/master
2023-02-20T05:17:30.289853
2021-01-23T19:16:38
2021-01-23T19:16:38
310,423,904
0
0
null
null
null
null
UTF-8
C++
false
false
431
cpp
#include<stdio.h> #include<stdlib.h> int main (void){ int n, x; printf("El palo inicial A es el palo o \n"); printf("El palo final C es el palo1 \n"); printf("El palo auxiliar B es el palo2\n\n"); printf("Cuantos discos son?"); scanf("%d", &n); puts("\n\n"); for(x=1;x<(1<<n); x++) printf("Mueve desde el palo %i al palo %i.\n", (x&x-1)%3, ((x|x-1)+1)%3); system("pause"); }
[ "noreply@github.com" ]
noreply@github.com
eacb5b2a504e0efffdfc14fa7f8abe5a83a40a46
aea76ea0e4ec23fe27ff23f3bb55a06fe11c21a5
/Nucleo/kinematic_low_level_controller/lib/ros_lib/pacmod_msgs/BrakeAuxRpt.h
8b331dd4eb0185e8034b78612d008a9f3421b3f5
[]
no_license
dacsgb/AGC
be899a23c6d51821a442973d07c98977ffbfa295
c90bd7c0965e2b6a2ce639b503d0d5b6d10e9d1d
refs/heads/main
2023-04-15T18:16:14.175961
2021-04-23T03:30:27
2021-04-23T03:30:27
337,014,918
0
0
null
null
null
null
UTF-8
C++
false
false
11,713
h
#ifndef _ROS_pacmod_msgs_BrakeAuxRpt_h #define _ROS_pacmod_msgs_BrakeAuxRpt_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" #include "std_msgs/Header.h" namespace pacmod_msgs { class BrakeAuxRpt : public ros::Msg { public: typedef std_msgs::Header _header_type; _header_type header; typedef double _raw_pedal_pos_type; _raw_pedal_pos_type raw_pedal_pos; typedef bool _raw_pedal_pos_is_valid_type; _raw_pedal_pos_is_valid_type raw_pedal_pos_is_valid; typedef double _raw_pedal_force_type; _raw_pedal_force_type raw_pedal_force; typedef bool _raw_pedal_force_is_valid_type; _raw_pedal_force_is_valid_type raw_pedal_force_is_valid; typedef double _raw_brake_pressure_type; _raw_brake_pressure_type raw_brake_pressure; typedef bool _raw_brake_pressure_is_valid_type; _raw_brake_pressure_is_valid_type raw_brake_pressure_is_valid; typedef bool _brake_on_off_type; _brake_on_off_type brake_on_off; typedef bool _brake_on_off_is_valid_type; _brake_on_off_is_valid_type brake_on_off_is_valid; typedef bool _user_interaction_type; _user_interaction_type user_interaction; typedef bool _user_interaction_is_valid_type; _user_interaction_is_valid_type user_interaction_is_valid; BrakeAuxRpt(): header(), raw_pedal_pos(0), raw_pedal_pos_is_valid(0), raw_pedal_force(0), raw_pedal_force_is_valid(0), raw_brake_pressure(0), raw_brake_pressure_is_valid(0), brake_on_off(0), brake_on_off_is_valid(0), user_interaction(0), user_interaction_is_valid(0) { } virtual int serialize(unsigned char *outbuffer) const { int offset = 0; offset += this->header.serialize(outbuffer + offset); union { double real; uint64_t base; } u_raw_pedal_pos; u_raw_pedal_pos.real = this->raw_pedal_pos; *(outbuffer + offset + 0) = (u_raw_pedal_pos.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_raw_pedal_pos.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_raw_pedal_pos.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_raw_pedal_pos.base >> (8 * 3)) & 0xFF; *(outbuffer + offset + 4) = (u_raw_pedal_pos.base >> (8 * 4)) & 0xFF; *(outbuffer + offset + 5) = (u_raw_pedal_pos.base >> (8 * 5)) & 0xFF; *(outbuffer + offset + 6) = (u_raw_pedal_pos.base >> (8 * 6)) & 0xFF; *(outbuffer + offset + 7) = (u_raw_pedal_pos.base >> (8 * 7)) & 0xFF; offset += sizeof(this->raw_pedal_pos); union { bool real; uint8_t base; } u_raw_pedal_pos_is_valid; u_raw_pedal_pos_is_valid.real = this->raw_pedal_pos_is_valid; *(outbuffer + offset + 0) = (u_raw_pedal_pos_is_valid.base >> (8 * 0)) & 0xFF; offset += sizeof(this->raw_pedal_pos_is_valid); union { double real; uint64_t base; } u_raw_pedal_force; u_raw_pedal_force.real = this->raw_pedal_force; *(outbuffer + offset + 0) = (u_raw_pedal_force.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_raw_pedal_force.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_raw_pedal_force.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_raw_pedal_force.base >> (8 * 3)) & 0xFF; *(outbuffer + offset + 4) = (u_raw_pedal_force.base >> (8 * 4)) & 0xFF; *(outbuffer + offset + 5) = (u_raw_pedal_force.base >> (8 * 5)) & 0xFF; *(outbuffer + offset + 6) = (u_raw_pedal_force.base >> (8 * 6)) & 0xFF; *(outbuffer + offset + 7) = (u_raw_pedal_force.base >> (8 * 7)) & 0xFF; offset += sizeof(this->raw_pedal_force); union { bool real; uint8_t base; } u_raw_pedal_force_is_valid; u_raw_pedal_force_is_valid.real = this->raw_pedal_force_is_valid; *(outbuffer + offset + 0) = (u_raw_pedal_force_is_valid.base >> (8 * 0)) & 0xFF; offset += sizeof(this->raw_pedal_force_is_valid); union { double real; uint64_t base; } u_raw_brake_pressure; u_raw_brake_pressure.real = this->raw_brake_pressure; *(outbuffer + offset + 0) = (u_raw_brake_pressure.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_raw_brake_pressure.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_raw_brake_pressure.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_raw_brake_pressure.base >> (8 * 3)) & 0xFF; *(outbuffer + offset + 4) = (u_raw_brake_pressure.base >> (8 * 4)) & 0xFF; *(outbuffer + offset + 5) = (u_raw_brake_pressure.base >> (8 * 5)) & 0xFF; *(outbuffer + offset + 6) = (u_raw_brake_pressure.base >> (8 * 6)) & 0xFF; *(outbuffer + offset + 7) = (u_raw_brake_pressure.base >> (8 * 7)) & 0xFF; offset += sizeof(this->raw_brake_pressure); union { bool real; uint8_t base; } u_raw_brake_pressure_is_valid; u_raw_brake_pressure_is_valid.real = this->raw_brake_pressure_is_valid; *(outbuffer + offset + 0) = (u_raw_brake_pressure_is_valid.base >> (8 * 0)) & 0xFF; offset += sizeof(this->raw_brake_pressure_is_valid); union { bool real; uint8_t base; } u_brake_on_off; u_brake_on_off.real = this->brake_on_off; *(outbuffer + offset + 0) = (u_brake_on_off.base >> (8 * 0)) & 0xFF; offset += sizeof(this->brake_on_off); union { bool real; uint8_t base; } u_brake_on_off_is_valid; u_brake_on_off_is_valid.real = this->brake_on_off_is_valid; *(outbuffer + offset + 0) = (u_brake_on_off_is_valid.base >> (8 * 0)) & 0xFF; offset += sizeof(this->brake_on_off_is_valid); union { bool real; uint8_t base; } u_user_interaction; u_user_interaction.real = this->user_interaction; *(outbuffer + offset + 0) = (u_user_interaction.base >> (8 * 0)) & 0xFF; offset += sizeof(this->user_interaction); union { bool real; uint8_t base; } u_user_interaction_is_valid; u_user_interaction_is_valid.real = this->user_interaction_is_valid; *(outbuffer + offset + 0) = (u_user_interaction_is_valid.base >> (8 * 0)) & 0xFF; offset += sizeof(this->user_interaction_is_valid); return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; offset += this->header.deserialize(inbuffer + offset); union { double real; uint64_t base; } u_raw_pedal_pos; u_raw_pedal_pos.base = 0; u_raw_pedal_pos.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); u_raw_pedal_pos.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); u_raw_pedal_pos.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); u_raw_pedal_pos.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); u_raw_pedal_pos.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); u_raw_pedal_pos.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); u_raw_pedal_pos.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); u_raw_pedal_pos.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); this->raw_pedal_pos = u_raw_pedal_pos.real; offset += sizeof(this->raw_pedal_pos); union { bool real; uint8_t base; } u_raw_pedal_pos_is_valid; u_raw_pedal_pos_is_valid.base = 0; u_raw_pedal_pos_is_valid.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->raw_pedal_pos_is_valid = u_raw_pedal_pos_is_valid.real; offset += sizeof(this->raw_pedal_pos_is_valid); union { double real; uint64_t base; } u_raw_pedal_force; u_raw_pedal_force.base = 0; u_raw_pedal_force.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); u_raw_pedal_force.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); u_raw_pedal_force.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); u_raw_pedal_force.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); u_raw_pedal_force.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); u_raw_pedal_force.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); u_raw_pedal_force.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); u_raw_pedal_force.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); this->raw_pedal_force = u_raw_pedal_force.real; offset += sizeof(this->raw_pedal_force); union { bool real; uint8_t base; } u_raw_pedal_force_is_valid; u_raw_pedal_force_is_valid.base = 0; u_raw_pedal_force_is_valid.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->raw_pedal_force_is_valid = u_raw_pedal_force_is_valid.real; offset += sizeof(this->raw_pedal_force_is_valid); union { double real; uint64_t base; } u_raw_brake_pressure; u_raw_brake_pressure.base = 0; u_raw_brake_pressure.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); u_raw_brake_pressure.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); u_raw_brake_pressure.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); u_raw_brake_pressure.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); u_raw_brake_pressure.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); u_raw_brake_pressure.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); u_raw_brake_pressure.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); u_raw_brake_pressure.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); this->raw_brake_pressure = u_raw_brake_pressure.real; offset += sizeof(this->raw_brake_pressure); union { bool real; uint8_t base; } u_raw_brake_pressure_is_valid; u_raw_brake_pressure_is_valid.base = 0; u_raw_brake_pressure_is_valid.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->raw_brake_pressure_is_valid = u_raw_brake_pressure_is_valid.real; offset += sizeof(this->raw_brake_pressure_is_valid); union { bool real; uint8_t base; } u_brake_on_off; u_brake_on_off.base = 0; u_brake_on_off.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->brake_on_off = u_brake_on_off.real; offset += sizeof(this->brake_on_off); union { bool real; uint8_t base; } u_brake_on_off_is_valid; u_brake_on_off_is_valid.base = 0; u_brake_on_off_is_valid.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->brake_on_off_is_valid = u_brake_on_off_is_valid.real; offset += sizeof(this->brake_on_off_is_valid); union { bool real; uint8_t base; } u_user_interaction; u_user_interaction.base = 0; u_user_interaction.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->user_interaction = u_user_interaction.real; offset += sizeof(this->user_interaction); union { bool real; uint8_t base; } u_user_interaction_is_valid; u_user_interaction_is_valid.base = 0; u_user_interaction_is_valid.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->user_interaction_is_valid = u_user_interaction_is_valid.real; offset += sizeof(this->user_interaction_is_valid); return offset; } const char * getType(){ return "pacmod_msgs/BrakeAuxRpt"; }; const char * getMD5(){ return "1b24f296f5fabbe64603c0988f5aae5b"; }; }; } #endif
[ "dcolon@okstate.edu" ]
dcolon@okstate.edu
2ca04af1e8b5356039e377ded8aab23bc90218e3
bbeb7e4c334f9f33ea1106810a7113b58f281b27
/hihoCoder/1055.cpp
794af3e1dc556457c86e6a57520d81cc3ea52e31
[]
no_license
Drone-Banks/ACM
18638af3f3307ecb26dc5e79d0a06d58c87dedaf
937224c32f8a00ce4885f12ffd83e35b9c99718c
refs/heads/master
2021-04-15T13:41:20.077221
2018-04-16T13:17:33
2018-04-16T13:17:33
126,587,158
0
0
null
null
null
null
UTF-8
C++
false
false
1,887
cpp
/************************************************************************* > File Name: 1055.cpp > Author: Akira > Mail: qaq.febr2.qaq@gmail.com > Created Time: 2016年10月07日 星期五 14时21分56秒 ************************************************************************/ #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <algorithm> #include <queue> #include <stack> #include <map> #include <cmath> #include <vector> #include <set> #include <list> #include <ctime> typedef long long LL; typedef unsigned long long ULL; typedef long double LD; #define MST(a,b) memset(a,b,sizeof(a)) #define CLR(a) MST(a,0) #define Sqr(a) ((a)*(a)) using namespace std; #define MaxN 110 #define MaxM MaxN*2 #define INF 0x3f3f3f3f #define bug cout<<88888888<<endl; #define MIN(x,y) (x<y?x:y) #define MAX(x,y) (x>y?x:y) int N, M; int dp[MaxN][MaxN]; struct Edge { int u,v; int next; }edge[MaxM]; int head[MaxN]; int cont; void init() { CLR(dp); MST(head, -1); cont = 0; } void add(int u, int v) { edge[cont].v = v; edge[cont].next = head[u]; head[u] = cont++; } int dfs(int u, int m) { int sons = 1; int num; for(int i=head[u]; i!=-1; i=edge[i].next) { int v = edge[i].v; num = dfs(v, m-1); for(int j=m;j>=1;j--) { for(int k=1; k<=num && k<j; k++) { dp[u][j] = MAX( dp[u][j], dp[v][k]+dp[u][j-k] ); } } sons += num; } return sons; } int main() { while(~scanf("%d%d", &N, &M)) { init(); for(int i=1;i<=N;i++) { scanf("%d", &dp[i][1]); } int a, b; for(int i=1;i<N;i++) { scanf("%d%d", &a, &b); add(a, b); } dfs(1, M); cout << dp[1][M] << endl; } }
[ "qaq.febr2.qaq@gmail.com" ]
qaq.febr2.qaq@gmail.com
eb87d9806357644c6cf010bcc786255c00ee11f9
9a9fb43d866dc8fd829211d2b47328ef1f5ed428
/PI_ROS_WORKSPACES/test/devel_isolated/diagnostic_msgs/include/diagnostic_msgs/KeyValue.h
944a287031b84f9b55aca013e509799d217aa130
[]
no_license
droter/auto_mow
326df42a54676079cac61fe63c40d5d04beb049b
3742cb2ef78bc06d2771ac4c679e5110909774f8
refs/heads/master
2022-05-19T20:18:33.409777
2020-04-29T00:42:24
2020-04-29T00:42:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,524
h
// Generated by gencpp from file diagnostic_msgs/KeyValue.msg // DO NOT EDIT! #ifndef DIAGNOSTIC_MSGS_MESSAGE_KEYVALUE_H #define DIAGNOSTIC_MSGS_MESSAGE_KEYVALUE_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> namespace diagnostic_msgs { template <class ContainerAllocator> struct KeyValue_ { typedef KeyValue_<ContainerAllocator> Type; KeyValue_() : key() , value() { } KeyValue_(const ContainerAllocator& _alloc) : key(_alloc) , value(_alloc) { (void)_alloc; } typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _key_type; _key_type key; typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _value_type; _value_type value; typedef boost::shared_ptr< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::diagnostic_msgs::KeyValue_<ContainerAllocator> const> ConstPtr; }; // struct KeyValue_ typedef ::diagnostic_msgs::KeyValue_<std::allocator<void> > KeyValue; typedef boost::shared_ptr< ::diagnostic_msgs::KeyValue > KeyValuePtr; typedef boost::shared_ptr< ::diagnostic_msgs::KeyValue const> KeyValueConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::diagnostic_msgs::KeyValue_<ContainerAllocator> & v) { ros::message_operations::Printer< ::diagnostic_msgs::KeyValue_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace diagnostic_msgs namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': False} // {'std_msgs': ['/home/pi/test/src/std_msgs/msg'], 'diagnostic_msgs': ['/home/pi/test/src/common_msgs/diagnostic_msgs/msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::diagnostic_msgs::KeyValue_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::diagnostic_msgs::KeyValue_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::diagnostic_msgs::KeyValue_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > { static const char* value() { return "cf57fdc6617a881a88c16e768132149c"; } static const char* value(const ::diagnostic_msgs::KeyValue_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0xcf57fdc6617a881aULL; static const uint64_t static_value2 = 0x88c16e768132149cULL; }; template<class ContainerAllocator> struct DataType< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > { static const char* value() { return "diagnostic_msgs/KeyValue"; } static const char* value(const ::diagnostic_msgs::KeyValue_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > { static const char* value() { return "string key # what to label this value when viewing\n\ string value # a value to track over time\n\ "; } static const char* value(const ::diagnostic_msgs::KeyValue_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.key); stream.next(m.value); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct KeyValue_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::diagnostic_msgs::KeyValue_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::diagnostic_msgs::KeyValue_<ContainerAllocator>& v) { s << indent << "key: "; Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.key); s << indent << "value: "; Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.value); } }; } // namespace message_operations } // namespace ros #endif // DIAGNOSTIC_MSGS_MESSAGE_KEYVALUE_H
[ "joshuatygert@gmail.com" ]
joshuatygert@gmail.com
c9f3bb2aff939f9221404f6307d4f5680b1f6583
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_5/R+polp+dmb.ldla.c.cbmc.cpp
5c1d6a9060bfcc5a81b2806fa5ea4a620d7bbd37
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
25,934
cpp
// Global variabls: // 0:vars:2 // 2:atom_1_X2_0:1 // Local global variabls: // 0:thr0:1 // 1:thr1:1 #define ADDRSIZE 3 #define LOCALADDRSIZE 2 #define NTHREAD 3 #define NCONTEXT 5 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // Declare arrays for intial value version in contexts int local_mem[LOCALADDRSIZE]; // Dumping initializations local_mem[0+0] = 0; local_mem[1+0] = 0; int cstart[NTHREAD]; int creturn[NTHREAD]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NTHREAD*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NTHREAD*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NTHREAD*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NTHREAD*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NTHREAD*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NTHREAD*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NTHREAD*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NTHREAD*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NTHREAD*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NTHREAD]; int cdy[NTHREAD]; int cds[NTHREAD]; int cdl[NTHREAD]; int cisb[NTHREAD]; int caddr[NTHREAD]; int cctrl[NTHREAD]; __LOCALS__ buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(2+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; mem(0,1) = meminit(0,1); co(0,1) = coinit(0,1); delta(0,1) = deltainit(0,1); mem(0,2) = meminit(0,2); co(0,2) = coinit(0,2); delta(0,2) = deltainit(0,2); mem(0,3) = meminit(0,3); co(0,3) = coinit(0,3); delta(0,3) = deltainit(0,3); mem(0,4) = meminit(0,4); co(0,4) = coinit(0,4); delta(0,4) = deltainit(0,4); co(1,0) = 0; delta(1,0) = -1; mem(1,1) = meminit(1,1); co(1,1) = coinit(1,1); delta(1,1) = deltainit(1,1); mem(1,2) = meminit(1,2); co(1,2) = coinit(1,2); delta(1,2) = deltainit(1,2); mem(1,3) = meminit(1,3); co(1,3) = coinit(1,3); delta(1,3) = deltainit(1,3); mem(1,4) = meminit(1,4); co(1,4) = coinit(1,4); delta(1,4) = deltainit(1,4); co(2,0) = 0; delta(2,0) = -1; mem(2,1) = meminit(2,1); co(2,1) = coinit(2,1); delta(2,1) = deltainit(2,1); mem(2,2) = meminit(2,2); co(2,2) = coinit(2,2); delta(2,2) = deltainit(2,2); mem(2,3) = meminit(2,3); co(2,3) = coinit(2,3); delta(2,3) = deltainit(2,3); mem(2,4) = meminit(2,4); co(2,4) = coinit(2,4); delta(2,4) = deltainit(2,4); // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !34, metadata !DIExpression()), !dbg !43 // br label %label_1, !dbg !44 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !42), !dbg !45 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !35, metadata !DIExpression()), !dbg !46 // call void @llvm.dbg.value(metadata i64 1, metadata !38, metadata !DIExpression()), !dbg !46 // store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !47 // ST: Guess // : Release iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l19_c3 old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l19_c3 // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); ASSUME(cw(1,0) >= cr(1,0+0)); ASSUME(cw(1,0) >= cr(1,0+1)); ASSUME(cw(1,0) >= cr(1,2+0)); ASSUME(cw(1,0) >= cw(1,0+0)); ASSUME(cw(1,0) >= cw(1,0+1)); ASSUME(cw(1,0) >= cw(1,2+0)); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 1; mem(0,cw(1,0)) = 1; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; is(1,0) = iw(1,0); cs(1,0) = cw(1,0); ASSUME(creturn[1] >= cw(1,0)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !39, metadata !DIExpression()), !dbg !48 // call void @llvm.dbg.value(metadata i64 1, metadata !41, metadata !DIExpression()), !dbg !48 // store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !49 // ST: Guess iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l20_c3 old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l20_c3 // Check ASSUME(active[iw(1,0+1*1)] == 1); ASSUME(active[cw(1,0+1*1)] == 1); ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(cw(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cw(1,0+1*1) >= old_cw); ASSUME(cw(1,0+1*1) >= cr(1,0+1*1)); ASSUME(cw(1,0+1*1) >= cl[1]); ASSUME(cw(1,0+1*1) >= cisb[1]); ASSUME(cw(1,0+1*1) >= cdy[1]); ASSUME(cw(1,0+1*1) >= cdl[1]); ASSUME(cw(1,0+1*1) >= cds[1]); ASSUME(cw(1,0+1*1) >= cctrl[1]); ASSUME(cw(1,0+1*1) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0+1*1) = 1; mem(0+1*1,cw(1,0+1*1)) = 1; co(0+1*1,cw(1,0+1*1))+=1; delta(0+1*1,cw(1,0+1*1)) = -1; ASSUME(creturn[1] >= cw(1,0+1*1)); // ret i8* null, !dbg !50 ret_thread_1 = (- 1); goto T1BLOCK_END; T1BLOCK_END: // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !53, metadata !DIExpression()), !dbg !63 // br label %label_2, !dbg !46 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !62), !dbg !65 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !54, metadata !DIExpression()), !dbg !66 // call void @llvm.dbg.value(metadata i64 2, metadata !56, metadata !DIExpression()), !dbg !66 // store atomic i64 2, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) release, align 8, !dbg !49 // ST: Guess // : Release iw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l26_c3 old_cw = cw(2,0+1*1); cw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l26_c3 // Check ASSUME(active[iw(2,0+1*1)] == 2); ASSUME(active[cw(2,0+1*1)] == 2); ASSUME(sforbid(0+1*1,cw(2,0+1*1))== 0); ASSUME(iw(2,0+1*1) >= 0); ASSUME(iw(2,0+1*1) >= 0); ASSUME(cw(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cw(2,0+1*1) >= old_cw); ASSUME(cw(2,0+1*1) >= cr(2,0+1*1)); ASSUME(cw(2,0+1*1) >= cl[2]); ASSUME(cw(2,0+1*1) >= cisb[2]); ASSUME(cw(2,0+1*1) >= cdy[2]); ASSUME(cw(2,0+1*1) >= cdl[2]); ASSUME(cw(2,0+1*1) >= cds[2]); ASSUME(cw(2,0+1*1) >= cctrl[2]); ASSUME(cw(2,0+1*1) >= caddr[2]); ASSUME(cw(2,0+1*1) >= cr(2,0+0)); ASSUME(cw(2,0+1*1) >= cr(2,0+1)); ASSUME(cw(2,0+1*1) >= cr(2,2+0)); ASSUME(cw(2,0+1*1) >= cw(2,0+0)); ASSUME(cw(2,0+1*1) >= cw(2,0+1)); ASSUME(cw(2,0+1*1) >= cw(2,2+0)); // Update caddr[2] = max(caddr[2],0); buff(2,0+1*1) = 2; mem(0+1*1,cw(2,0+1*1)) = 2; co(0+1*1,cw(2,0+1*1))+=1; delta(0+1*1,cw(2,0+1*1)) = -1; is(2,0+1*1) = iw(2,0+1*1); cs(2,0+1*1) = cw(2,0+1*1); ASSUME(creturn[2] >= cw(2,0+1*1)); // call void (...) @dmbld(), !dbg !50 // dumbld: Guess cdl[2] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdl[2] >= cdy[2]); ASSUME(cdl[2] >= cr(2,0+0)); ASSUME(cdl[2] >= cr(2,0+1)); ASSUME(cdl[2] >= cr(2,2+0)); ASSUME(creturn[2] >= cdl[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !58, metadata !DIExpression()), !dbg !69 // %0 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) acquire, align 8, !dbg !52 // LD: Guess // : Acquire old_cr = cr(2,0); cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l28_c15 // Check ASSUME(active[cr(2,0)] == 2); ASSUME(cr(2,0) >= iw(2,0)); ASSUME(cr(2,0) >= 0); ASSUME(cr(2,0) >= cdy[2]); ASSUME(cr(2,0) >= cisb[2]); ASSUME(cr(2,0) >= cdl[2]); ASSUME(cr(2,0) >= cl[2]); ASSUME(cr(2,0) >= cx(2,0)); ASSUME(cr(2,0) >= cs(2,0+0)); ASSUME(cr(2,0) >= cs(2,0+1)); ASSUME(cr(2,0) >= cs(2,2+0)); // Update creg_r0 = cr(2,0); crmax(2,0) = max(crmax(2,0),cr(2,0)); caddr[2] = max(caddr[2],0); if(cr(2,0) < cw(2,0)) { r0 = buff(2,0); ASSUME((!(( (cw(2,0) < 1) && (1 < crmax(2,0)) )))||(sforbid(0,1)> 0)); ASSUME((!(( (cw(2,0) < 2) && (2 < crmax(2,0)) )))||(sforbid(0,2)> 0)); ASSUME((!(( (cw(2,0) < 3) && (3 < crmax(2,0)) )))||(sforbid(0,3)> 0)); ASSUME((!(( (cw(2,0) < 4) && (4 < crmax(2,0)) )))||(sforbid(0,4)> 0)); } else { if(pw(2,0) != co(0,cr(2,0))) { ASSUME(cr(2,0) >= old_cr); } pw(2,0) = co(0,cr(2,0)); r0 = mem(0,cr(2,0)); } cl[2] = max(cl[2],cr(2,0)); ASSUME(creturn[2] >= cr(2,0)); // call void @llvm.dbg.value(metadata i64 %0, metadata !60, metadata !DIExpression()), !dbg !69 // %conv = trunc i64 %0 to i32, !dbg !53 // call void @llvm.dbg.value(metadata i32 %conv, metadata !57, metadata !DIExpression()), !dbg !63 // %cmp = icmp eq i32 %conv, 0, !dbg !54 creg__r0__0_ = max(0,creg_r0); // %conv1 = zext i1 %cmp to i32, !dbg !54 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !61, metadata !DIExpression()), !dbg !63 // store i32 %conv1, i32* @atom_1_X2_0, align 4, !dbg !55, !tbaa !56 // ST: Guess iw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l30_c15 old_cw = cw(2,2); cw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l30_c15 // Check ASSUME(active[iw(2,2)] == 2); ASSUME(active[cw(2,2)] == 2); ASSUME(sforbid(2,cw(2,2))== 0); ASSUME(iw(2,2) >= creg__r0__0_); ASSUME(iw(2,2) >= 0); ASSUME(cw(2,2) >= iw(2,2)); ASSUME(cw(2,2) >= old_cw); ASSUME(cw(2,2) >= cr(2,2)); ASSUME(cw(2,2) >= cl[2]); ASSUME(cw(2,2) >= cisb[2]); ASSUME(cw(2,2) >= cdy[2]); ASSUME(cw(2,2) >= cdl[2]); ASSUME(cw(2,2) >= cds[2]); ASSUME(cw(2,2) >= cctrl[2]); ASSUME(cw(2,2) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,2) = (r0==0); mem(2,cw(2,2)) = (r0==0); co(2,cw(2,2))+=1; delta(2,cw(2,2)) = -1; ASSUME(creturn[2] >= cw(2,2)); // ret i8* null, !dbg !60 ret_thread_2 = (- 1); goto T2BLOCK_END; T2BLOCK_END: // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !86, metadata !DIExpression()), !dbg !106 // call void @llvm.dbg.value(metadata i8** %argv, metadata !87, metadata !DIExpression()), !dbg !106 // %0 = bitcast i64* %thr0 to i8*, !dbg !59 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !59 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !88, metadata !DIExpression()), !dbg !108 // %1 = bitcast i64* %thr1 to i8*, !dbg !61 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !61 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !92, metadata !DIExpression()), !dbg !110 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !93, metadata !DIExpression()), !dbg !111 // call void @llvm.dbg.value(metadata i64 0, metadata !95, metadata !DIExpression()), !dbg !111 // store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !64 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l38_c3 old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l38_c3 // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !96, metadata !DIExpression()), !dbg !113 // call void @llvm.dbg.value(metadata i64 0, metadata !98, metadata !DIExpression()), !dbg !113 // store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !66 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l39_c3 old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l39_c3 // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // store i32 0, i32* @atom_1_X2_0, align 4, !dbg !67, !tbaa !68 // ST: Guess iw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l40_c15 old_cw = cw(0,2); cw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l40_c15 // Check ASSUME(active[iw(0,2)] == 0); ASSUME(active[cw(0,2)] == 0); ASSUME(sforbid(2,cw(0,2))== 0); ASSUME(iw(0,2) >= 0); ASSUME(iw(0,2) >= 0); ASSUME(cw(0,2) >= iw(0,2)); ASSUME(cw(0,2) >= old_cw); ASSUME(cw(0,2) >= cr(0,2)); ASSUME(cw(0,2) >= cl[0]); ASSUME(cw(0,2) >= cisb[0]); ASSUME(cw(0,2) >= cdy[0]); ASSUME(cw(0,2) >= cdl[0]); ASSUME(cw(0,2) >= cds[0]); ASSUME(cw(0,2) >= cctrl[0]); ASSUME(cw(0,2) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,2) = 0; mem(2,cw(0,2)) = 0; co(2,cw(0,2))+=1; delta(2,cw(0,2)) = -1; ASSUME(creturn[0] >= cw(0,2)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !72 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call3 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !73 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %2 = load i64, i64* %thr0, align 8, !dbg !74, !tbaa !75 r2 = local_mem[0]; // %call4 = call i32 @pthread_join(i64 noundef %2, i8** noundef null), !dbg !77 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %3 = load i64, i64* %thr1, align 8, !dbg !78, !tbaa !75 r3 = local_mem[1]; // %call5 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !79 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !100, metadata !DIExpression()), !dbg !124 // %4 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !81 // LD: Guess old_cr = cr(0,0+1*1); cr(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l48_c12 // Check ASSUME(active[cr(0,0+1*1)] == 0); ASSUME(cr(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cr(0,0+1*1) >= 0); ASSUME(cr(0,0+1*1) >= cdy[0]); ASSUME(cr(0,0+1*1) >= cisb[0]); ASSUME(cr(0,0+1*1) >= cdl[0]); ASSUME(cr(0,0+1*1) >= cl[0]); // Update creg_r4 = cr(0,0+1*1); crmax(0,0+1*1) = max(crmax(0,0+1*1),cr(0,0+1*1)); caddr[0] = max(caddr[0],0); if(cr(0,0+1*1) < cw(0,0+1*1)) { r4 = buff(0,0+1*1); ASSUME((!(( (cw(0,0+1*1) < 1) && (1 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,1)> 0)); ASSUME((!(( (cw(0,0+1*1) < 2) && (2 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,2)> 0)); ASSUME((!(( (cw(0,0+1*1) < 3) && (3 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,3)> 0)); ASSUME((!(( (cw(0,0+1*1) < 4) && (4 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,4)> 0)); } else { if(pw(0,0+1*1) != co(0+1*1,cr(0,0+1*1))) { ASSUME(cr(0,0+1*1) >= old_cr); } pw(0,0+1*1) = co(0+1*1,cr(0,0+1*1)); r4 = mem(0+1*1,cr(0,0+1*1)); } ASSUME(creturn[0] >= cr(0,0+1*1)); // call void @llvm.dbg.value(metadata i64 %4, metadata !102, metadata !DIExpression()), !dbg !124 // %conv = trunc i64 %4 to i32, !dbg !82 // call void @llvm.dbg.value(metadata i32 %conv, metadata !99, metadata !DIExpression()), !dbg !106 // %cmp = icmp eq i32 %conv, 2, !dbg !83 creg__r4__2_ = max(0,creg_r4); // %conv6 = zext i1 %cmp to i32, !dbg !83 // call void @llvm.dbg.value(metadata i32 %conv6, metadata !103, metadata !DIExpression()), !dbg !106 // %5 = load i32, i32* @atom_1_X2_0, align 4, !dbg !84, !tbaa !68 // LD: Guess old_cr = cr(0,2); cr(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l50_c12 // Check ASSUME(active[cr(0,2)] == 0); ASSUME(cr(0,2) >= iw(0,2)); ASSUME(cr(0,2) >= 0); ASSUME(cr(0,2) >= cdy[0]); ASSUME(cr(0,2) >= cisb[0]); ASSUME(cr(0,2) >= cdl[0]); ASSUME(cr(0,2) >= cl[0]); // Update creg_r5 = cr(0,2); crmax(0,2) = max(crmax(0,2),cr(0,2)); caddr[0] = max(caddr[0],0); if(cr(0,2) < cw(0,2)) { r5 = buff(0,2); ASSUME((!(( (cw(0,2) < 1) && (1 < crmax(0,2)) )))||(sforbid(2,1)> 0)); ASSUME((!(( (cw(0,2) < 2) && (2 < crmax(0,2)) )))||(sforbid(2,2)> 0)); ASSUME((!(( (cw(0,2) < 3) && (3 < crmax(0,2)) )))||(sforbid(2,3)> 0)); ASSUME((!(( (cw(0,2) < 4) && (4 < crmax(0,2)) )))||(sforbid(2,4)> 0)); } else { if(pw(0,2) != co(2,cr(0,2))) { ASSUME(cr(0,2) >= old_cr); } pw(0,2) = co(2,cr(0,2)); r5 = mem(2,cr(0,2)); } ASSUME(creturn[0] >= cr(0,2)); // call void @llvm.dbg.value(metadata i32 %5, metadata !104, metadata !DIExpression()), !dbg !106 // %and = and i32 %conv6, %5, !dbg !85 creg_r6 = max(creg__r4__2_,creg_r5); r6 = (r4==2) & r5; // call void @llvm.dbg.value(metadata i32 %and, metadata !105, metadata !DIExpression()), !dbg !106 // %cmp7 = icmp eq i32 %and, 1, !dbg !86 creg__r6__1_ = max(0,creg_r6); // br i1 %cmp7, label %if.then, label %if.end, !dbg !88 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg__r6__1_); if((r6==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @.str.1, i64 0, i64 0), i32 noundef 52, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !89 // unreachable, !dbg !89 r7 = 1; goto T0BLOCK_END; T0BLOCK2: // %6 = bitcast i64* %thr1 to i8*, !dbg !92 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %6) #7, !dbg !92 // %7 = bitcast i64* %thr0 to i8*, !dbg !92 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %7) #7, !dbg !92 // ret i32 0, !dbg !93 ret_thread_0 = 0; goto T0BLOCK_END; T0BLOCK_END: ASSUME(meminit(0,1) == mem(0,0)); ASSUME(coinit(0,1) == co(0,0)); ASSUME(deltainit(0,1) == delta(0,0)); ASSUME(meminit(0,2) == mem(0,1)); ASSUME(coinit(0,2) == co(0,1)); ASSUME(deltainit(0,2) == delta(0,1)); ASSUME(meminit(0,3) == mem(0,2)); ASSUME(coinit(0,3) == co(0,2)); ASSUME(deltainit(0,3) == delta(0,2)); ASSUME(meminit(0,4) == mem(0,3)); ASSUME(coinit(0,4) == co(0,3)); ASSUME(deltainit(0,4) == delta(0,3)); ASSUME(meminit(1,1) == mem(1,0)); ASSUME(coinit(1,1) == co(1,0)); ASSUME(deltainit(1,1) == delta(1,0)); ASSUME(meminit(1,2) == mem(1,1)); ASSUME(coinit(1,2) == co(1,1)); ASSUME(deltainit(1,2) == delta(1,1)); ASSUME(meminit(1,3) == mem(1,2)); ASSUME(coinit(1,3) == co(1,2)); ASSUME(deltainit(1,3) == delta(1,2)); ASSUME(meminit(1,4) == mem(1,3)); ASSUME(coinit(1,4) == co(1,3)); ASSUME(deltainit(1,4) == delta(1,3)); ASSUME(meminit(2,1) == mem(2,0)); ASSUME(coinit(2,1) == co(2,0)); ASSUME(deltainit(2,1) == delta(2,0)); ASSUME(meminit(2,2) == mem(2,1)); ASSUME(coinit(2,2) == co(2,1)); ASSUME(deltainit(2,2) == delta(2,1)); ASSUME(meminit(2,3) == mem(2,2)); ASSUME(coinit(2,3) == co(2,2)); ASSUME(deltainit(2,3) == delta(2,2)); ASSUME(meminit(2,4) == mem(2,3)); ASSUME(coinit(2,4) == co(2,3)); ASSUME(deltainit(2,4) == delta(2,3)); ASSERT(r7== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
b82e44dc13034d342975f63d0f6a348e635b80f4
f55783d334b5b2af2bb7147269f5fd70e773094b
/CompileAndBuildTools/Compiler/AgapiaToCCode_ExecutorImpl - Copy.cpp
6afc23ede30777433a2f9aac271670b153378950
[]
no_license
AGAPIA/CompilerAndTools
bfb71617a8171fea788ce5b4232792b2852f9acd
5612d37423ac59620f045c6d3370a80f188b31dd
refs/heads/master
2021-07-25T09:49:21.075985
2021-02-08T16:19:11
2021-02-08T16:19:11
83,405,238
0
8
null
2021-02-08T16:19:13
2017-02-28T07:54:21
C++
UTF-8
C++
false
false
7,635
cpp
// This file contains the concrete implementations for functions that an user can put in their #include "InputTypes.h" #include "AgapiaToCCode.h" #include "calc3_defs.h" #include "calc3_utils.h" template <typename basicCType, typename basicAgapiaType> inline void AddSimpleValueType_Private(SimpleProcessItem* pItem, void* pData) { basicCType bValue = *((basicCType*)pData); basicAgapiaType* pAgapiaItem = new basicAgapiaType(); pAgapiaItem->SetValue(bValue); pItem->AddItem(pAgapiaItem); } template <typename basicElementType, typename basicAgapiaVectorType> inline void AddSimpleArrayValueType_Private(SimpleProcessItem* pItem, void* pData, int numElements) { basicElementType* pValues = (basicElementType*) pData; basicAgapiaVectorType* pAgapiaArray = new basicAgapiaVectorType(); pAgapiaArray->SetValues((basicElementType*)pData, numElements); } // PUBLIC TYPES //---------------------------------------------------------------------------------------------- void AddProcessInput(ArrayOfBaseProcessInputs& arr, BaseProcessInput* pSPI) { arr.push_back(pSPI); } void AddInputItemToVector(VectorProcessItem* pVector, ArrayOfBaseProcessInputs& arr) { pVector->AddItemInput(arr); } //------ Functions to set different stuff for vector of processes ------- //------------------------------------------------------------------------------------------------------------------ static bool CheckAndReturnVectorComponent(int lineNo, VectorProcessItem* pVector, int iVectorIndex, char* structItem, const ArrayOfBaseProcessInputs*& outVectorComponent, std::pair<int,int>& outIndex) { outVectorComponent = &pVector->GetVectorItemByIndex(iVectorIndex); outIndex = pVector->GetIndexOfItemName(structItem); if (outIndex.first < 0 || outIndex.second < 0) // Invalid index, not found show an error { // Error PrintCompileError(lineNo, " Tried to access invalid item named %s from the vector", structItem); return false; } return true; } void SetInputItemToVector(int lineNo, VectorProcessItem* pVector, int iVectorIndex, const char* structItem, int value) { std::pair<int,int> index; const ArrayOfBaseProcessInputs* outVectorComponent = NULL; if (!CheckAndReturnVectorComponent(lineNo, pVector, iVectorIndex, structItem, outVectorComponent, index)) return; SimpleProcessItem* pSPI = (SimpleProcessItem*)(*outVectorComponent)[index.first]; pSPI->SetItemValue(index.second, ETYPE_INT, structItem, value); } void SetInputItemToVector(int lineNo, VectorProcessItem* pVector, int iVectorIndex, const char* structItem, float value) { std::pair<int,int> index; const ArrayOfBaseProcessInputs* outVectorComponent = NULL; if (!CheckAndReturnVectorComponent(lineNo, pVector, iVectorIndex, structItem, outVectorComponent, index)) return; SimpleProcessItem* pSPI = (SimpleProcessItem*)(*outVectorComponent)[index.first]; pSPI->SetItemValue(index.second, ETYPE_FLOAT, structItem, value); } void SetInputItemToVector(int lineNo, VectorProcessItem* pVector, int iVectorIndex, char* structItem, char* value) { std::pair<int,int> index; const ArrayOfBaseProcessInputs* outVectorComponent = NULL; if (!CheckAndReturnVectorComponent(lineNo, pVector, iVectorIndex, structItem, outVectorComponent, index)) return; SimpleProcessItem* pSPI = (SimpleProcessItem*)(*outVectorComponent)[index.first]; pSPI->SetItemValue(index.second, ETYPE_STRING, structItem, value); } // THIS IS TO BE CALLED DIRECTLY WITHOUT ANY TRANSLATION!!!! void SetInputItemToVector(int lineNo, VectorProcessItem* pVector, int iVectorIndex, char* structItem, char* value, int buffSize) { std::pair<int,int> index; const ArrayOfBaseProcessInputs* outVectorComponent = NULL; if (!CheckAndReturnVectorComponent(0, pVector, iVectorIndex, structItem, outVectorComponent, index)) return; SimpleProcessItem* pSPI = (SimpleProcessItem*)(*outVectorComponent)[index.first]; pSPI->SetItemValue(index.second, ETYPE_DATA_BUFFER, structItem, value, buffSize); } //-------------------------------------------------------------------------------------------------------------------- void ClearVectorOfProcessItems(VectorProcessItem* pSourceVector) { pSourceVector->ClearAll(); } int GetNumItemsInVectorProcessItem(VectorProcessItem& pVector) { return pVector.m_ArrayOfItemInputs.size(); } BaseProcessInput* GetVectorItemByIndex(VectorProcessItem& pSourceVector, unsigned int iVectorIndex, unsigned int iProcessIndex) { if (pSourceVector.m_ArrayOfItemInputs.size() <= iVectorIndex) PrintExecutionError("You used GetVectorItemByIndex to access an invalid vector index"); ArrayOfBaseProcessInputs& item = pSourceVector.GetVectorItemByIndex(iVectorIndex); if (item.size() <= iProcessIndex) PrintExecutionError("You used GetVectorItemByIndex to access an invalid process index"); return item[iProcessIndex]; } void AddSimpleValueType(SimpleProcessItem* pItem, int fValue) { AddSimpleValueType_Private<int, IntDataItem>(pItem, &fValue); } inline void AddSimpleValueType(SimpleProcessItem* pItem, float fValue) { AddSimpleValueType_Private<float, FloatDataItem>(pItem, &fValue); } inline void AddSimpleValueType(SimpleProcessItem* pItem, char* fValue) { AddSimpleValueType_Private<char*, StringDataItem>(pItem, &fValue); } inline void AddSimpleValueType(SimpleProcessItem* pItem, bool fValue) { AddSimpleValueType_Private<bool, BoolDataItem>(pItem, &fValue); } inline void AddSimpleValueType(SimpleProcessItem* pItem, char fValue) { AddSimpleValueType_Private<char, CharDataItem>(pItem, &fValue); } inline void AddSimpleArrayValueType(SimpleProcessItem* pItem, int* pData, int numElements) { AddSimpleArrayValueType_Private<int, IntVectorDataItem>(pItem, pData, numElements); } inline void AddSimpleArrayValueType(SimpleProcessItem* pItem, float* pData, int numElements) { AddSimpleArrayValueType_Private<float, FloatVectorDataItem>(pItem, pData, numElements); } inline void AddSimpleArrayValueType(SimpleProcessItem* pItem, bool* pData, int numElements) { AddSimpleArrayValueType_Private<bool, BoolVectorDataItem>(pItem, pData, numElements); } inline void AddSimpleArrayValueType(SimpleProcessItem* pItem, char* pData, int numElements) { AddSimpleArrayValueType_Private<char*, CharVectorDataItem>(pItem, pData, numElements); } inline void AddSimpleArrayValueType(SimpleProcessItem* pItem, char** pData, int numElements) { AddSimpleArrayValueType_Private<char*, StringVectorDataItem>(pItem, pData, numElements); } inline void* GetSimpleArrayItem(SimpleProcessItem* pItem, int iPosition) { return pItem->GetItem(iPosition); } void AddBufferDataType(SimpleProcessItem* pItem, char* pData, int iSize) { BufferDataItem *pBufferDataItem = new BufferDataItem(); pBufferDataItem->SetValue(pData, iSize); pItem->AddItem(pBufferDataItem); } int& GetItemRefFromSimpleValueType_asInt(SimpleProcessItem* pItem, int iPosition) { return ((IntDataItem*)pItem->GetItem(iPosition))->GetValueRef(); } float& GetItemRefFromSimpleValueType_asFloat(SimpleProcessItem* pItem, int iPosition) { return ((FloatDataItem*)pItem->GetItem(iPosition))->GetValueRef(); } bool& GetItemRefFromSimpleValueType_asBool(SimpleProcessItem* pItem, int iPosition) { return ((BoolDataItem*)pItem->GetItem(iPosition))->GetValueRef(); } char& GetItemRefFromSimpleValueType_asChar(SimpleProcessItem* pItem, int iPosition) { return ((CharDataItem*)pItem->GetItem(iPosition))->GetValueRef(); } BufferDataItem* GetItemRefFromSimpleValueType_asBuffer(SimpleProcessItem* pItem, int iPosition) { return ((BufferDataItem*)pItem->m_InputItems[iPosition]); } //----------------------------------------------------------------------------------------------
[ "pciprian_ionut@yahoo.com" ]
pciprian_ionut@yahoo.com
495cfda31e53b3daeec62a0a60bdee23ac4acd1e
b1435609179cd5ce08bbea18695e0a03034fe545
/src/qt/transactiondesc.cpp
396cb686e2c8472ec238ac1373623628c6b22a8b
[ "MIT" ]
permissive
Creat-coin/Canon
827de6ba2147e1139fa731f6ff9e366f6e734026
d7524a53550e7d57a0c781abed52bc4ee6299ab2
refs/heads/master
2021-05-06T01:07:42.096634
2017-12-15T17:20:35
2017-12-15T17:20:35
114,394,777
1
1
null
null
null
null
UTF-8
C++
false
false
11,455
cpp
#include "transactiondesc.h" #include "guiutil.h" #include "bitcoinunits.h" #include "main.h" #include "wallet.h" #include "db.h" #include "ui_interface.h" #include "base58.h" #include <string> QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) { if (!wtx.IsFinal()) { if (wtx.nLockTime < LOCKTIME_THRESHOLD) return tr("Open for %n more block(s)", "", wtx.nLockTime - nBestHeight + 1); else return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime)); } else { int nDepth = wtx.GetDepthInMainChain(); if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) return tr("%1/offline").arg(nDepth); else if (nDepth < 6) return tr("%1/unconfirmed").arg(nDepth); else return tr("%1 confirmations").arg(nDepth); } } QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { QString strHTML; { LOCK(wallet->cs_wallet); strHTML.reserve(4000); strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>"; int64 nTime = wtx.GetTxTime(); int64 nCredit = wtx.GetCredit(); int64 nDebit = wtx.GetDebit(); int64 nNet = nCredit - nDebit; strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx); int nRequests = wtx.GetRequestCount(); if (nRequests != -1) { if (nRequests == 0) strHTML += tr(", has not been successfully broadcast yet"); else if (nRequests > 0) strHTML += tr(", broadcast through %n node(s)", "", nRequests); } strHTML += "<br>"; strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>"; // // From // if (wtx.IsCoinBase()) { strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>"; } else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty()) { // Online transaction strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>"; } else { // Offline transaction if (nNet > 0) { // Credit BOOST_FOREACH(const CTxOut& txout, wtx.vout) { if (wallet->IsMine(txout)) { CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address)) { if (wallet->mapAddressBook.count(address)) { strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>"; strHTML += "<b>" + tr("To") + ":</b> "; strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString()); if (!wallet->mapAddressBook[address].empty()) strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")"; else strHTML += " (" + tr("own address") + ")"; strHTML += "<br>"; } } break; } } } } // // To // if (wtx.mapValue.count("to") && !wtx.mapValue["to"].empty()) { // Online transaction std::string strAddress = wtx.mapValue["to"]; strHTML += "<b>" + tr("To") + ":</b> "; CTxDestination dest = CBitcoinAddress(strAddress).Get(); if (wallet->mapAddressBook.count(dest) && !wallet->mapAddressBook[dest].empty()) strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[dest]) + " "; strHTML += GUIUtil::HtmlEscape(strAddress) + "<br>"; } // // Amount // if (wtx.IsCoinBase() && nCredit == 0) { // // Coinbase // int64 nUnmatured = 0; BOOST_FOREACH(const CTxOut& txout, wtx.vout) nUnmatured += wallet->GetCredit(txout); strHTML += "<b>" + tr("Credit") + ":</b> "; if (wtx.IsInMainChain()) strHTML += BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")"; else strHTML += "(" + tr("not accepted") + ")"; strHTML += "<br>"; } else if (nNet > 0) { // // Credit // strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, nNet) + "<br>"; } else { bool fAllFromMe = true; BOOST_FOREACH(const CTxIn& txin, wtx.vin) fAllFromMe = fAllFromMe && wallet->IsMine(txin); bool fAllToMe = true; BOOST_FOREACH(const CTxOut& txout, wtx.vout) fAllToMe = fAllToMe && wallet->IsMine(txout); if (fAllFromMe) { // // Debit // BOOST_FOREACH(const CTxOut& txout, wtx.vout) { if (wallet->IsMine(txout)) continue; if (!wtx.mapValue.count("to") || wtx.mapValue["to"].empty()) { // Offline transaction CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address)) { strHTML += "<b>" + tr("To") + ":</b> "; if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty()) strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + " "; strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString()); strHTML += "<br>"; } } strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, -txout.nValue) + "<br>"; } if (fAllToMe) { // Payment to self int64 nChange = wtx.GetChange(); int64 nValue = nCredit - nChange; strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, -nValue) + "<br>"; strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, nValue) + "<br>"; } int64 nTxFee = nDebit - wtx.GetValueOut(); if (nTxFee > 0) strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, -nTxFee) + "<br>"; } else { // // Mixed debit transaction // BOOST_FOREACH(const CTxIn& txin, wtx.vin) if (wallet->IsMine(txin)) strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, -wallet->GetDebit(txin)) + "<br>"; BOOST_FOREACH(const CTxOut& txout, wtx.vout) if (wallet->IsMine(txout)) strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, wallet->GetCredit(txout)) + "<br>"; } } strHTML += "<b>" + tr("Net amount") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, nNet, true) + "<br>"; // // Message // if (wtx.mapValue.count("message") && !wtx.mapValue["message"].empty()) strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["message"], true) + "<br>"; if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty()) strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "<br>"; strHTML += "<b>" + tr("Transaction ID") + ":</b> " + wtx.GetHash().ToString().c_str() + "<br>"; if (wtx.IsCoinBase()) strHTML += "<br>" + tr("Generated coins must mature 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "<br>"; // // Debug view // if (fDebug) { strHTML += "<hr><br>" + tr("Debug information") + "<br><br>"; BOOST_FOREACH(const CTxIn& txin, wtx.vin) if(wallet->IsMine(txin)) strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, -wallet->GetDebit(txin)) + "<br>"; BOOST_FOREACH(const CTxOut& txout, wtx.vout) if(wallet->IsMine(txout)) strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, wallet->GetCredit(txout)) + "<br>"; strHTML += "<br><b>" + tr("Transaction") + ":</b><br>"; strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true); strHTML += "<br><b>" + tr("Inputs") + ":</b>"; strHTML += "<ul>"; { LOCK(wallet->cs_wallet); BOOST_FOREACH(const CTxIn& txin, wtx.vin) { COutPoint prevout = txin.prevout; CCoins prev; if(pcoinsTip->GetCoins(prevout.hash, prev)) { if (prevout.n < prev.vout.size()) { strHTML += "<li>"; const CTxOut &vout = prev.vout[prevout.n]; CTxDestination address; if (ExtractDestination(vout.scriptPubKey, address)) { if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty()) strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + " "; strHTML += QString::fromStdString(CBitcoinAddress(address).ToString()); } strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatWithUnit(BitcoinUnits::CNN, vout.nValue); strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) ? tr("true") : tr("false")) + "</li>"; } } } } strHTML += "</ul>"; } strHTML += "</font></html>"; } return strHTML; }
[ "nicolas_sen@hotmail.fr" ]
nicolas_sen@hotmail.fr
1283d752721bfbfe3811dbea70bcea27192130ff
2c27f66916b166d0346c4b56f2883797bfed3861
/Examen2/Ejer2/binary_tree.h
6613428b9e073298e1b37110fa46f5c8e12bbbb9
[]
no_license
tommysvs/Estructura-de-Datos-I
c0d7163f62acba4236eb4c91ba71beb80d141976
a59270e91efc8ae5310d3933989deaacde812185
refs/heads/master
2023-07-06T08:33:07.084733
2020-12-18T13:37:48
2020-12-18T13:37:48
307,531,126
0
0
null
null
null
null
UTF-8
C++
false
false
1,389
h
#ifndef _BINARY_TREE_H_ #define _BINARY_TREE_H_ template<typename TElem> class BinarySearchTree { public: class Node { public: Node(TElem data) : data(data), left(nullptr), right(nullptr) {} void print(); void inorder() const; TElem data; Node *left; Node *right; }; std::list<TElem> inorder() const { // if(left != nullptr) // left->inorder(); // std::cout << data << ' '; // if(right != nullptr) // right->inorder(); } void insert(TElem data) { if(root == nullptr) { root = new Node(data); return; } Node *n = root; do { if(n->data == data) { std::cout << "Found element: " << data << '\n'; break; } if(data < n->data ) { if(n->left == nullptr) { n->left = new Node(data); break; } else n = n->left; } else { if(n->right == nullptr) { n->right = new Node(data); break; } else n = n->right; } } while(true); } private: Node *root; }; #endif
[ "tommysvs@hotmail.com" ]
tommysvs@hotmail.com
3f431bdad45e3628dcac599222f5151512298d71
35b929181f587c81ad507c24103d172d004ee911
/SrcLib/core/fwComEd/include/fwComEd/parser/TransformationMatrix3D.hpp
b2ab6e5afcbbc31e8be6939d34d00a6a0d3a1428
[]
no_license
hamalawy/fw4spl
7853aa46ed5f96660123e88d2ba8b0465bd3f58d
680376662bf3fad54b9616d1e9d4c043d9d990df
refs/heads/master
2021-01-10T11:33:53.571504
2015-07-23T08:01:59
2015-07-23T08:01:59
50,699,438
2
1
null
null
null
null
UTF-8
C++
false
false
1,595
hpp
/* ***** BEGIN LICENSE BLOCK ***** * FW4SPL - Copyright (C) IRCAD, 2009-2012. * Distributed under the terms of the GNU Lesser General Public License (LGPL) as * published by the Free Software Foundation. * ****** END LICENSE BLOCK ****** */ #ifndef _FWCOMED_PARSER_TRANSFORMATIONMATRIX3D_HPP_ #define _FWCOMED_PARSER_TRANSFORMATIONMATRIX3D_HPP_ #include <fwTools/Failed.hpp> #include <fwTools/Object.hpp> #include <fwRuntime/ConfigurationElement.hpp> #include <fwServices/IXMLParser.hpp> #include "fwComEd/export.hpp" namespace fwComEd { namespace parser { /** * @brief Specific service for the construction of a TransformationMatrix3D and its associated services from an XML-based description. * @class TransformationMatrix3D * * @date 2007-2009 * @see ::fwServices::IXMLParser */ class FWCOMED_CLASS_API TransformationMatrix3D : public ::fwServices::IXMLParser { public : fwCoreServiceClassDefinitionsMacro ( (TransformationMatrix3D)(::fwServices::IXMLParser) ) ; /// Constructor : does nothing. TransformationMatrix3D() {}; /// Destructor : does nothing. virtual ~TransformationMatrix3D() {}; FWCOMED_API void createConfig( ::fwTools::Object::sptr _obj ); protected: /** * @brief Updating method : create the process object. * * Parse the configuration element to configure inputs and outputs and add * them in the process object. */ FWCOMED_API virtual void updating( ) throw(fwTools::Failed) ; }; } //namespace parser } //namespace fwComEd #endif // _FWCOMED_PARSER_TRANSFORMATIONMATRIX3D_HPP_
[ "fbridault@IRCAD.FR" ]
fbridault@IRCAD.FR
2364fdb8647634acb14915dc29e54fa769309a2a
cda2f7e9c664ffb3b973945d77f55ad95548ec4b
/软件部分/上位机程序/mytools.h
ec38c15344aa36af27e85b9ba6eabce7090548ec
[]
no_license
YangXi2016/ROBOT-COMPETITION
32c8b8ee914944cd8b3d9fb512f33e5c57c3b8e6
98706d1196ce82a55ed62ebcd03036070915aeb5
refs/heads/master
2021-01-20T22:15:38.218704
2016-08-06T05:51:51
2016-08-06T05:51:51
null
0
0
null
null
null
null
GB18030
C++
false
false
1,405
h
#pragma once #include <iostream> #include <sstream> #include <string> #include <iomanip> using namespace std; //计算整型数字的位数 //输入: int n //输出: n的位数, 负号将记为一位 //例如: count_int(1234)将会输出4 int count_int(int n); //该程序将坐标转换为字符串形式 //输入: 坐标a,b,抓取方向(注意一定要大写!!!!!!!!!!!!!!) //输出: 字符串aa;bb;flag //例如: assemble_point(1, 3, 'A')输出"01;03;3" string assemble_point(int a, int b, char direct); //该程序将字符串转换成int //输入:字符串形式数字 //输出:Int int strtoint(string str); //从字符串转为char数组 //输入: string为类型的字符串 //输出: char数组为类型的字符串 void strtochar(char ch[], string str); //从char数组转为字符串 //输出: char数组为类型的字符串 //输入: string为类型的字符串 void chartostr(string *str, char ch[], int num); //从浮点数转换为字符串 //////////////////////////////////////////没写完! string floattostr(float num, int sci_cut); //从方向判定机械臂转盘角度 int dirtodeg(char ch); //获取柜子的uni_ID //输入柜子编号如"A5" //返回柜子的uni_ID int getuniid(string str); //获取柜子的名字 //只能输入从0~47的数,否则后果自负 string getnamefromuniid(int tt); int dirtodegcc(char ch);
[ "yang_xi@zju.edu.cn" ]
yang_xi@zju.edu.cn
2fa9afe074d98286d5da66bbde32d76dd2f532bb
58f0f4c254237b00022142f3e0342cd56a6e333e
/include/pcl/PolarTransform.h
aa268a9827fb1fe10ffc6444bbc5d950dc0e0e6e
[ "LicenseRef-scancode-other-permissive" ]
permissive
cameronleger/PCL
fc7948e5a02a72c67c4b3798619d5d2b4a886add
a231a00ba8ca4a02bac6f19b6d7beae6cfe70728
refs/heads/master
2021-09-23T14:40:28.291908
2017-10-16T10:27:14
2017-10-16T10:27:14
109,534,105
1
0
null
2017-11-04T22:12:45
2017-11-04T22:12:44
null
UTF-8
C++
false
false
12,521
h
// ____ ______ __ // / __ \ / ____// / // / /_/ // / / / // / ____// /___ / /___ PixInsight Class Library // /_/ \____//_____/ PCL 02.01.07.0873 // ---------------------------------------------------------------------------- // pcl/PolarTransform.h - Released 2017-08-01T14:23:31Z // ---------------------------------------------------------------------------- // This file is part of the PixInsight Class Library (PCL). // PCL is a multiplatform C++ framework for development of PixInsight modules. // // Copyright (c) 2003-2017 Pleiades Astrophoto S.L. All Rights Reserved. // // Redistribution and use in both source and binary forms, with or without // modification, is permitted provided that the following conditions are met: // // 1. All redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. All 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 "PixInsight" and "Pleiades Astrophoto", nor the names // of their contributors, may be used to endorse or promote products derived // from this software without specific prior written permission. For written // permission, please contact info@pixinsight.com. // // 4. All products derived from this software, in any form whatsoever, must // reproduce the following acknowledgment in the end-user documentation // and/or other materials provided with the product: // // "This product is based on software from the PixInsight project, developed // by Pleiades Astrophoto and its contributors (http://pixinsight.com/)." // // Alternatively, if that is where third-party acknowledgments normally // appear, this acknowledgment must be reproduced in the product itself. // // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS 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 PLEIADES ASTROPHOTO OR ITS // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE, // DATA OR PROFITS) 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 __PCL_PolarTransform_h #define __PCL_PolarTransform_h /// \file pcl/PolarTransform.h #include <pcl/Defs.h> #include <pcl/Diagnostics.h> #include <pcl/GeometricTransformation.h> namespace pcl { // ---------------------------------------------------------------------------- /*! * \class PolarTransformBase * \brief Base class of polar transforms. * * %PolarTransformBase implements properties and functionality common to polar * transform classes in PCL. * * A polar transform remaps pixel values in a two-dimensional image to encode * polar coordinates on both image axes. Polar angle measured counter-clockwise * with respect to the geometric center of the image is encoded linearly on the * vertical (Y) axis. Radial distance to the center is encoded (linearly or * not, depending on each particular transform) on the horizontal (X) axis. * * Polar transforms have important applications in FFT-based image registration * algorithms (e.g. as part of Fourier-Mellin transforms). * * \sa PolarTransform, LogPolarTransform, FFTRegistrationEngine */ class PCL_CLASS PolarTransformBase : public InterpolatingGeometricTransformation { public: /*! * Constructs a %PolarTransformBase object using the specified \a p pixel * interpolation. The referenced interpolation object \a p must remain valid * while this %PolarTransformBase object exists. */ PolarTransformBase( PixelInterpolation& p ) : InterpolatingGeometricTransformation( p ), m_initialAngle( 0 ), m_finalAngle( pcl::Const<float>::_2pi() ), m_parallel( true ), m_maxProcessors( PCL_MAX_PROCESSORS ) { } /*! * Copy constructor. */ PolarTransformBase( const PolarTransformBase& ) = default; /*! * Returns the initial rotation angle in radians. The default initial * rotation angle is zero. */ float InitialRotation() const { return m_initialAngle; } /*! * Sets the initial rotation \a angle in radians. */ void SetInitialRotation( float angle ) { PCL_PRECONDITION( angle >= 0 && angle <= pcl::Const<float>::_2pi() ) if ( (m_initialAngle = angle) > m_finalAngle ) pcl::Swap( m_initialAngle, m_finalAngle ); } /*! * Returns the final rotation angle in radians. The default final rotation * angle is 2*pi (360 degrees). */ float FinalRotation() const { return m_finalAngle; } /*! * Sets the final rotation \a angle in radians. */ void SetFinalRotation( float angle ) { PCL_PRECONDITION( angle >= 0 && angle <= pcl::Const<float>::_2pi() ) if ( (m_finalAngle = angle) < m_initialAngle ) pcl::Swap( m_initialAngle, m_finalAngle ); } /*! * Sets the initial and final rotation angles, \a initialAngle and * \a finalAngle respectively, in radians. If the specified initial angle is * greater than the final angle, both values are swapped. */ void SetRotationRange( float initialAngle, float finalAngle ) { PCL_PRECONDITION( initialAngle >= 0 && initialAngle <= pcl::Const<float>::_2pi() ) PCL_PRECONDITION( finalAngle >= 0 && finalAngle <= pcl::Const<float>::_2pi() ) m_initialAngle = initialAngle; m_finalAngle = finalAngle; if ( m_finalAngle < m_initialAngle ) pcl::Swap( m_initialAngle, m_finalAngle ); } /*! */ virtual void GetNewSizes( int& w, int& h ) const { // No change } /*! * \internal */ virtual bool IsLogPolar() const { return false; } /*! * Returns true iff this object is allowed to use multiple parallel execution * threads (when multiple threads are permitted and available). */ bool IsParallelProcessingEnabled() const { return m_parallel; } /*! * Enables parallel processing for this instance. * * \param enable Whether to enable or disable parallel processing. True by * default. * * \param maxProcessors The maximum number of processors allowed for this * instance. If \a enable is false this parameter is ignored. * A value <= 0 is ignored. The default value is zero. */ void EnableParallelProcessing( bool enable = true, int maxProcessors = 0 ) { m_parallel = enable; if ( enable && maxProcessors > 0 ) SetMaxProcessors( maxProcessors ); } /*! * Disables parallel processing for this instance. * * This is a convenience function, equivalent to: * EnableParallelProcessing( !disable ) */ void DisableParallelProcessing( bool disable = true ) { EnableParallelProcessing( !disable ); } /*! * Returns the maximum number of processors allowed for this instance of. * * Irrespective of the value returned by this function, a module should not * use more processors than the maximum number of parallel threads allowed * for external modules on the PixInsight platform. This number is given by * the "Process/MaxProcessors" global variable (refer to the GlobalSettings * class for information on global variables). */ int MaxProcessors() const { return m_maxProcessors; } /*! * Sets the maximum number of processors allowed for this instance. * * In the current version of PCL, a module can use a maximum of 1023 * processors. The term \e processor actually refers to the number of * threads a module can execute concurrently. * * Irrespective of the value specified by this function, a module should not * use more processors than the maximum number of parallel threads allowed * for external modules on the PixInsight platform. This number is given by * the "Process/MaxProcessors" global variable (refer to the GlobalSettings * class for information on global variables). */ void SetMaxProcessors( int maxProcessors ) { m_maxProcessors = unsigned( Range( maxProcessors, 1, PCL_MAX_PROCESSORS ) ); } protected: float m_initialAngle; // angles in radians! float m_finalAngle; bool m_parallel : 1; unsigned m_maxProcessors : PCL_MAX_PROCESSORS_BITCOUNT; // Maximum number of processors allowed }; // ---------------------------------------------------------------------------- /*! * \class PolarTransform * \brief In-place transformation to polar coordinates. * * This class implements a Cartesian to polar coordinate transform with the * following properties: * * \li The origin of polar coordinates is located at the geometric center of * the image. * * \li Rotation angles are encoded linearly on the vertical axis, growing from * bottom to top. * * \li Distance to the origin is encoded linearly on the horizontal axis, * growing from left to right. * * \li Transform pixels mapped outside the source image (in Cartesian * coordinates) are set to zero. * * \sa LogPolarTransform, PolarTransformBase, FFTRegistrationEngine */ class PCL_CLASS PolarTransform : public PolarTransformBase { public: /*! * Constructs a %PolarTransform object using the specified pixel * interpolation \a p. The referenced interpolation object \a p must remain * valid while this %PolarTransform object exists. */ PolarTransform( PixelInterpolation& p ) : PolarTransformBase( p ) { } /*! * Copy constructor. */ PolarTransform( const PolarTransform& ) = default; protected: // Inherited from ImageTransformation. virtual void Apply( pcl::Image& ) const; virtual void Apply( pcl::DImage& ) const; virtual void Apply( pcl::UInt8Image& ) const; virtual void Apply( pcl::UInt16Image& ) const; virtual void Apply( pcl::UInt32Image& ) const; }; // ---------------------------------------------------------------------------- /*! * \class LogPolarTransform * \brief In-place transformation to log-polar coordinates. * * This class implements a Cartesian to log-polar coordinate transform with the * following properties: * * \li The origin of polar coordinates is located at the geometric center of * the image. * * \li Rotation angles are encoded linearly on the vertical axis, growing from * bottom to top. * * \li Distance to the origin is encoded logarithmically on the horizontal * axis, growing from left to right. Natural (base e) logarithms are used. * * \li Transform pixels mapped outside the source image (in Cartesian * coordinates) are set to zero. * * \sa PolarTransform, PolarTransformBase, FFTRegistrationEngine */ class PCL_CLASS LogPolarTransform : public PolarTransformBase { public: /*! * Constructs a %LogPolarTransform object using the specified pixel * interpolation \a p. The referenced interpolation object \a p must remain * valid while this %LogPolarTransform object exists. */ LogPolarTransform( PixelInterpolation& p ) : PolarTransformBase( p ) { } /*! * Copy constructor. */ LogPolarTransform( const LogPolarTransform& ) = default; /*! * \internal */ virtual bool IsLogPolar() const { return true; } protected: // Inherited from ImageTransformation. virtual void Apply( pcl::Image& ) const; virtual void Apply( pcl::DImage& ) const; virtual void Apply( pcl::UInt8Image& ) const; virtual void Apply( pcl::UInt16Image& ) const; virtual void Apply( pcl::UInt32Image& ) const; }; // ---------------------------------------------------------------------------- } // pcl #endif // __PCL_PolarTransform_h // ---------------------------------------------------------------------------- // EOF pcl/PolarTransform.h - Released 2017-08-01T14:23:31Z
[ "juan.conejero@pixinsight.com" ]
juan.conejero@pixinsight.com
2c82862f6a53d361ebd19dfe13fa290fdf448326
c0caed81b5b3e1498cbca4c1627513c456908e38
/src/protocols/denovo_design/connection/ConnectionArchitect.fwd.hh
fa2c57b484ef444332b6e2591b0bc9f6a6462c0a
[]
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,511
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 // (c) under license. The Rosetta software is developed by the contributing // (c) members of the Rosetta Commons. For more information, see // (c) http://www.rosettacommons.org. Questions about this can be addressed to // (c) University of Washington UW TechTransfer,email:license@u.washington.edu. /// @file protocols/denovo_design/connection/ConnectionArchitect.fwd.hh /// @brief Architect for covalently joining two segments of a pose /// @author Tom Linsky (tlinsky@uw.edu) #ifndef INCLUDED_protocols_denovo_design_connection_ConnectionArchitect_fwd_hh #define INCLUDED_protocols_denovo_design_connection_ConnectionArchitect_fwd_hh // Utility headers #include <utility/pointer/owning_ptr.hh> #include <utility/vector1.fwd.hh> // Forward namespace protocols { namespace denovo_design { namespace connection { class ConnectionArchitect; typedef utility::pointer::shared_ptr< ConnectionArchitect > ConnectionArchitectOP; typedef utility::pointer::shared_ptr< ConnectionArchitect const > ConnectionArchitectCOP; typedef utility::vector1< ConnectionArchitectCOP > ConnectionArchitectCOPs; class AreConnectablePredicate; } //protocols } //denovo_design } //connection #endif //INCLUDED_protocols_denovo_design_connection_ConnectionArchitect_fwd_hh
[ "malaifa@yahoo.com" ]
malaifa@yahoo.com
8888f867dfca62cfa29bc2147c1759850ec4975b
b5a7b1a505cacbe6a2ede64f22cc95297b907763
/find_reminder.cpp
028a5d3e2b59f7520096690e2652fe0ccebba220
[]
no_license
kumarkishan070997/codechef_beginner_codes.github.io
9fd7925dd3b327ecef9457e7ac215d3336335c7e
1474930bbc86cb73ca17c887c57a8a9cdf643f16
refs/heads/master
2022-02-22T03:28:27.135424
2019-10-05T16:22:46
2019-10-05T16:22:46
213,031,636
0
0
null
null
null
null
UTF-8
C++
false
false
248
cpp
#include<iostream> using namespace std; int main() { int i,n,rem,j=0,arr1[10],num1,num2; cin>>n; for(i=0;i<n;i++) { cin>>num1; cin>>num2; rem=num1%num2; arr1[j]=rem; j++; } for(i=0;i<j;i++) { cout<<arr1[i]<<endl; } return 0; }
[ "kishankumar070997@gmail.com" ]
kishankumar070997@gmail.com
c3af3fde107f36f5b72d275a0ea9eee08644d61f
16c25858ef1e5f29f653580d4aacda69a50c3244
/hikr/build/iOS/Preview/include/Fuse.Controls.EllipticalShape.h
6c89f9b8e415b6f19e50b14c43799071d0d059a2
[]
no_license
PoliGomes/tutorialfuse
69c32ff34ba9236bc3e84e99e00eb116d6f16422
0b7fadfe857fed568a5c2899d176acf45249d2b8
refs/heads/master
2021-08-16T02:50:08.993542
2017-11-18T22:04:56
2017-11-18T22:04:56
111,242,469
0
0
null
null
null
null
UTF-8
C++
false
false
4,263
h
// This file was generated based on /usr/local/share/uno/Packages/Fuse.Controls.Primitives/1.2.1/shapes/$.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Fuse.Animations.IResize.h> #include <Fuse.Binding.h> #include <Fuse.Controls.Shape.h> #include <Fuse.Drawing.IDrawObjectWatcherFeedback.h> #include <Fuse.Drawing.ISurfaceDrawable.h> #include <Fuse.IActualPlacement.h> #include <Fuse.INotifyUnrooted.h> #include <Fuse.IProperties.h> #include <Fuse.ITemplateSource.h> #include <Fuse.Node.h> #include <Fuse.Scripting.IScriptObject.h> #include <Fuse.Triggers.Actions.ICollapse.h> #include <Fuse.Triggers.Actions.IHide.h> #include <Fuse.Triggers.Actions.IShow.h> #include <Uno.Collections.ICollection-1.h> #include <Uno.Collections.IEnumerable-1.h> #include <Uno.Collections.IList-1.h> #include <Uno.UX.IPropertyListener.h> namespace g{namespace Fuse{namespace Controls{struct EllipticalShape;}}} namespace g{namespace Fuse{namespace Drawing{struct Surface;}}} namespace g{namespace Fuse{namespace Drawing{struct SurfacePath;}}} namespace g{namespace Uno{namespace UX{struct Selector;}}} namespace g{namespace Uno{struct Float2;}} namespace g{ namespace Fuse{ namespace Controls{ // public interfacemodifiers class EllipticalShape :869 // { ::g::Fuse::Controls::Shape_type* EllipticalShape_typeof(); void EllipticalShape__ctor_7_fn(EllipticalShape* __this); void EllipticalShape__CreateEllipticalPath_fn(EllipticalShape* __this, ::g::Fuse::Drawing::Surface* surface, ::g::Uno::Float2* center, ::g::Uno::Float2* radius, bool* drawArc, ::g::Fuse::Drawing::SurfacePath** __retval); void EllipticalShape__get_EffectiveEndAngle_fn(EllipticalShape* __this, float* __retval); void EllipticalShape__get_EffectiveEndAngleDegrees_fn(EllipticalShape* __this, float* __retval); void EllipticalShape__get_EndAngle_fn(EllipticalShape* __this, float* __retval); void EllipticalShape__set_EndAngle_fn(EllipticalShape* __this, float* value); void EllipticalShape__get_EndAngleDegrees_fn(EllipticalShape* __this, float* __retval); void EllipticalShape__set_EndAngleDegrees_fn(EllipticalShape* __this, float* value); void EllipticalShape__get_LengthAngle_fn(EllipticalShape* __this, float* __retval); void EllipticalShape__set_LengthAngle_fn(EllipticalShape* __this, float* value); void EllipticalShape__get_LengthAngleDegrees_fn(EllipticalShape* __this, float* __retval); void EllipticalShape__set_LengthAngleDegrees_fn(EllipticalShape* __this, float* value); void EllipticalShape__get_StartAngle_fn(EllipticalShape* __this, float* __retval); void EllipticalShape__set_StartAngle_fn(EllipticalShape* __this, float* value); void EllipticalShape__get_StartAngleDegrees_fn(EllipticalShape* __this, float* __retval); void EllipticalShape__set_StartAngleDegrees_fn(EllipticalShape* __this, float* value); void EllipticalShape__get_UseAngle_fn(EllipticalShape* __this, bool* __retval); struct EllipticalShape : ::g::Fuse::Controls::Shape { float _endAngle; bool _hasAngle; bool _hasLengthAngle; float _lengthAngle; float _startAngle; static ::g::Uno::UX::Selector EndAngleName_; static ::g::Uno::UX::Selector& EndAngleName() { return EllipticalShape_typeof()->Init(), EndAngleName_; } static ::g::Uno::UX::Selector LengthAngleName_; static ::g::Uno::UX::Selector& LengthAngleName() { return EllipticalShape_typeof()->Init(), LengthAngleName_; } static ::g::Uno::UX::Selector StartAngleName_; static ::g::Uno::UX::Selector& StartAngleName() { return EllipticalShape_typeof()->Init(), StartAngleName_; } void ctor_7(); ::g::Fuse::Drawing::SurfacePath* CreateEllipticalPath(::g::Fuse::Drawing::Surface* surface, ::g::Uno::Float2 center, ::g::Uno::Float2 radius, bool drawArc); float EffectiveEndAngle(); float EffectiveEndAngleDegrees(); float EndAngle(); void EndAngle(float value); float EndAngleDegrees(); void EndAngleDegrees(float value); float LengthAngle(); void LengthAngle(float value); float LengthAngleDegrees(); void LengthAngleDegrees(float value); float StartAngle(); void StartAngle(float value); float StartAngleDegrees(); void StartAngleDegrees(float value); bool UseAngle(); }; // } }}} // ::g::Fuse::Controls
[ "poliana.ph@gmail.com" ]
poliana.ph@gmail.com
e8257d9135b7979a3c024cc5a831871a65642926
9996d9afb4909250f25a21dca7edb5c3b8f59ece
/src/FisurasDivergencia/CVNet_Cement/pch.h
0843f350a067db43e21dc20bb865b164034b9f75
[]
no_license
scativa/ReconocimientoFisuras
2cc09d9bc25727c7899256dd5b1f3d9db135e607
5ace666b5250872f9a95e608bb0375d78698012d
refs/heads/master
2022-12-19T18:12:01.049343
2020-10-18T11:56:24
2020-10-18T11:56:24
237,234,425
0
1
null
2020-03-31T17:59:28
2020-01-30T14:47:35
C++
UTF-8
C++
false
false
481
h
#pragma once #include <stdint.h> #include <cstddef> #include <fstream> #include <iostream> #include <string> #include <vector> #include <stdlib.h> #include <tchar.h> #include <stdio.h> #include <torch/torch.h> #include <torch/script.h> //#include <torch/data/datasets/base.h> //#include <torch/data/example.h> //#include <torch/types.h> //#include <torch/csrc/WindowsTorchApiMacro.h> #include <opencv2/opencv.hpp> #include <opencv2/imgproc.hpp> #include <opencv2/imgcodecs.hpp>
[ "41231949+scativa@users.noreply.github.com" ]
41231949+scativa@users.noreply.github.com
0f389363ae0ee179d71c77d3f4be8142bea5bf0c
42180085e2f9ed8f6edbeb09ae1a2c497c2882d1
/src/sync.h
21d9e5d28510d0cc39c76cdfc75b7e9bd55214f3
[ "MIT" ]
permissive
GalacticFederation/blemflark
351be868467fbd814de8a285e6d4c611b154bc4e
c349e5afc560fff581d431c0a343fff1a02c6e05
refs/heads/master
2021-05-15T07:04:00.041219
2018-02-18T17:22:05
2018-02-18T17:22:05
112,434,619
1
0
null
null
null
null
UTF-8
C++
false
false
7,444
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BLEMFLARK_SYNC_H #define BLEMFLARK_SYNC_H #include "threadsafety.h" #include <boost/thread/condition_variable.hpp> #include <boost/thread/mutex.hpp> #include <boost/thread/recursive_mutex.hpp> //////////////////////////////////////////////// // // // THE SIMPLE DEFINITION, EXCLUDING DEBUG CODE // // // //////////////////////////////////////////////// /* CCriticalSection mutex; boost::recursive_mutex mutex; LOCK(mutex); boost::unique_lock<boost::recursive_mutex> criticalblock(mutex); LOCK2(mutex1, mutex2); boost::unique_lock<boost::recursive_mutex> criticalblock1(mutex1); boost::unique_lock<boost::recursive_mutex> criticalblock2(mutex2); TRY_LOCK(mutex, name); boost::unique_lock<boost::recursive_mutex> name(mutex, boost::try_to_lock_t); ENTER_CRITICAL_SECTION(mutex); // no RAII mutex.lock(); LEAVE_CRITICAL_SECTION(mutex); // no RAII mutex.unlock(); */ /////////////////////////////// // // // THE ACTUAL IMPLEMENTATION // // // /////////////////////////////// /** * Template mixin that adds -Wthread-safety locking * annotations to a subset of the mutex API. */ template <typename PARENT> class LOCKABLE AnnotatedMixin : public PARENT { public: void lock() EXCLUSIVE_LOCK_FUNCTION() { PARENT::lock(); } void unlock() UNLOCK_FUNCTION() { PARENT::unlock(); } bool try_lock() EXCLUSIVE_TRYLOCK_FUNCTION(true) { return PARENT::try_lock(); } }; #ifdef DEBUG_LOCKORDER void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false); void LeaveCritical(); std::string LocksHeld(); void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs); void DeleteLock(void* cs); #else void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) {} void static inline LeaveCritical() {} void static inline AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) {} void static inline DeleteLock(void* cs) {} #endif #define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs) /** * Wrapped boost mutex: supports recursive locking, but no waiting * TODO: We should move away from using the recursive lock by default. */ class CCriticalSection : public AnnotatedMixin<boost::recursive_mutex> { public: ~CCriticalSection() { DeleteLock((void*)this); } }; /** Wrapped boost mutex: supports waiting but not recursive locking */ typedef AnnotatedMixin<boost::mutex> CWaitableCriticalSection; /** Just a typedef for boost::condition_variable, can be wrapped later if desired */ typedef boost::condition_variable CConditionVariable; #ifdef DEBUG_LOCKCONTENTION void PrintLockContention(const char* pszName, const char* pszFile, int nLine); #endif /** Wrapper around boost::unique_lock<Mutex> */ template <typename Mutex> class SCOPED_LOCKABLE CMutexLock { private: boost::unique_lock<Mutex> lock; void Enter(const char* pszName, const char* pszFile, int nLine) { EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex())); #ifdef DEBUG_LOCKCONTENTION if (!lock.try_lock()) { PrintLockContention(pszName, pszFile, nLine); #endif lock.lock(); #ifdef DEBUG_LOCKCONTENTION } #endif } bool TryEnter(const char* pszName, const char* pszFile, int nLine) { EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()), true); lock.try_lock(); if (!lock.owns_lock()) LeaveCritical(); return lock.owns_lock(); } public: CMutexLock(Mutex& mutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) EXCLUSIVE_LOCK_FUNCTION(mutexIn) : lock(mutexIn, boost::defer_lock) { if (fTry) TryEnter(pszName, pszFile, nLine); else Enter(pszName, pszFile, nLine); } CMutexLock(Mutex* pmutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) EXCLUSIVE_LOCK_FUNCTION(pmutexIn) { if (!pmutexIn) return; lock = boost::unique_lock<Mutex>(*pmutexIn, boost::defer_lock); if (fTry) TryEnter(pszName, pszFile, nLine); else Enter(pszName, pszFile, nLine); } ~CMutexLock() UNLOCK_FUNCTION() { if (lock.owns_lock()) LeaveCritical(); } operator bool() { return lock.owns_lock(); } }; typedef CMutexLock<CCriticalSection> CCriticalBlock; #define PASTE(x, y) x ## y #define PASTE2(x, y) PASTE(x, y) #define LOCK(cs) CCriticalBlock PASTE2(criticalblock, __COUNTER__)(cs, #cs, __FILE__, __LINE__) #define LOCK2(cs1, cs2) CCriticalBlock criticalblock1(cs1, #cs1, __FILE__, __LINE__), criticalblock2(cs2, #cs2, __FILE__, __LINE__) #define TRY_LOCK(cs, name) CCriticalBlock name(cs, #cs, __FILE__, __LINE__, true) #define ENTER_CRITICAL_SECTION(cs) \ { \ EnterCritical(#cs, __FILE__, __LINE__, (void*)(&cs)); \ (cs).lock(); \ } #define LEAVE_CRITICAL_SECTION(cs) \ { \ (cs).unlock(); \ LeaveCritical(); \ } class CSemaphore { private: boost::condition_variable condition; boost::mutex mutex; int value; public: CSemaphore(int init) : value(init) {} void wait() { boost::unique_lock<boost::mutex> lock(mutex); while (value < 1) { condition.wait(lock); } value--; } bool try_wait() { boost::unique_lock<boost::mutex> lock(mutex); if (value < 1) return false; value--; return true; } void post() { { boost::unique_lock<boost::mutex> lock(mutex); value++; } condition.notify_one(); } }; /** RAII-style semaphore lock */ class CSemaphoreGrant { private: CSemaphore* sem; bool fHaveGrant; public: void Acquire() { if (fHaveGrant) return; sem->wait(); fHaveGrant = true; } void Release() { if (!fHaveGrant) return; sem->post(); fHaveGrant = false; } bool TryAcquire() { if (!fHaveGrant && sem->try_wait()) fHaveGrant = true; return fHaveGrant; } void MoveTo(CSemaphoreGrant& grant) { grant.Release(); grant.sem = sem; grant.fHaveGrant = fHaveGrant; fHaveGrant = false; } CSemaphoreGrant() : sem(nullptr), fHaveGrant(false) {} CSemaphoreGrant(CSemaphore& sema, bool fTry = false) : sem(&sema), fHaveGrant(false) { if (fTry) TryAcquire(); else Acquire(); } ~CSemaphoreGrant() { Release(); } operator bool() { return fHaveGrant; } }; #endif // BLEMFLARK_SYNC_H
[ "galacticfederationheadquarters@gmail.com" ]
galacticfederationheadquarters@gmail.com
b87af6634aa5131360b874e20adecbc2a99e6ddd
77c65901945c653ce0185fdcbc238bf8fbd4850f
/program obiektowy c++/pracownicy.h
7ca460135ada4153b3e80df5c4fe2b2f4c30716c
[]
no_license
magda1106/My-C
1a1b8a32dc36d374d5369c6c42e1138a7e956813
f04e85c07df9d4147bbe65d1190cbcbcbf114b38
refs/heads/main
2023-04-21T13:08:55.225975
2021-04-22T19:48:23
2021-04-22T19:48:23
360,542,583
0
0
null
null
null
null
UTF-8
C++
false
false
567
h
#ifndef PRACOWNICY_H #define PRACOWNICY_H #include<iostream> #include <string> using namespace std; class Pracownik{ friend ostream& operator<<(ostream&, Pracownik&); protected: int id; static int licznik; string imie; string nazwisko; string zawod; const float stawka=10; float zarobki; public: Pracownik(); Pracownik(int, string, string); ~Pracownik(); }; ostream& operator<<(ostream&, Pracownik&); class Kierownik : public Pracownik { public: Kierownik(int, string, string); }; class IT : public Pracownik { public: IT(); IT(const IT&); }; #endif
[ "magda.cyranska1106@gmail.com" ]
magda.cyranska1106@gmail.com
f25ff77f055bc84e9467c274041ee1229c2ed3d1
6a3bb1f6380ba58c8e43e6bc6fd7d37bdf380ebc
/repository/altera/mxp/vbxware/src/vbw_mtx_mm.cpp
8d9eeb939cc842f8071f88a1423c7d0bd0f78bea
[]
no_license
gplhegde/mxp
c0474f80fc9d176e6ce4fce85bc736f1b06eeb1d
bec72ad398a95c63c1c11adfa784a07dd1f5d9c0
refs/heads/master
2020-12-07T15:37:41.002618
2016-03-02T01:52:00
2016-03-02T01:52:00
54,526,122
2
1
null
2016-03-23T02:55:10
2016-03-23T02:55:09
null
UTF-8
C++
false
false
6,929
cpp
/* VECTORBLOX MXP SOFTWARE DEVELOPMENT KIT * * Copyright (C) 2012-2016 VectorBlox Computing Inc., Vancouver, British Columbia, Canada. * 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 VectorBlox Computing 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 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. * * This agreement shall be governed in all respects by the laws of the Province * of British Columbia and by the laws of Canada. * * This file is part of the VectorBlox MXP Software Development Kit. * */ /**@file*/ #include "vbw_mtx_mm.h" extern "C"{ int vbw_mtx_mul_scalar_ext_word( vbx_word_t *out, vbx_word_t *in1, const int IN1ROWS, const int IN1COLS, vbx_word_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mul_scalar_ext( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS );} int vbw_mtx_mul_scalar_ext_uword( vbx_uword_t *out, vbx_uword_t *in1, const int IN1ROWS, const int IN1COLS, vbx_uword_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mul_scalar_ext( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS );} int vbw_mtx_mul_scalar_ext_half( vbx_half_t *out, vbx_half_t *in1, const int IN1ROWS, const int IN1COLS, vbx_half_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mul_scalar_ext( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS );} int vbw_mtx_mul_scalar_ext_uhalf( vbx_uhalf_t *out, vbx_uhalf_t *in1, const int IN1ROWS, const int IN1COLS, vbx_uhalf_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mul_scalar_ext( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS );} int vbw_mtx_mul_scalar_ext_byte( vbx_byte_t *out, vbx_byte_t *in1, const int IN1ROWS, const int IN1COLS, vbx_byte_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mul_scalar_ext( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS );} int vbw_mtx_mul_scalar_ext_ubyte( vbx_ubyte_t *out, vbx_ubyte_t *in1, const int IN1ROWS, const int IN1COLS, vbx_ubyte_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mul_scalar_ext( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS );} int vbw_mtx_mm_trans_ext_word( vbx_word_t *out, vbx_word_t *in1,const int IN1ROWS, const int IN1COLS, vbx_word_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mm_trans_ext<vbx_word_t>( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS);} int vbw_mtx_mm_trans_ext_uword( vbx_uword_t *out, vbx_uword_t *in1,const int IN1ROWS, const int IN1COLS, vbx_uword_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mm_trans_ext<vbx_uword_t>( out, in1, IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS);} int vbw_mtx_mm_trans_ext_half( vbx_half_t *out, vbx_half_t *in1,const int IN1ROWS, const int IN1COLS, vbx_half_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mm_trans_ext<vbx_half_t>( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS);} int vbw_mtx_mm_trans_ext_uhalf( vbx_uhalf_t *out, vbx_uhalf_t *in1,const int IN1ROWS, const int IN1COLS, vbx_uhalf_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mm_trans_ext<vbx_uhalf_t>( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS);} int vbw_mtx_mm_trans_ext_byte( vbx_byte_t *out, vbx_byte_t *in1,const int IN1ROWS, const int IN1COLS, vbx_byte_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mm_trans_ext<vbx_byte_t>( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS);} int vbw_mtx_mm_trans_ext_ubyte( vbx_ubyte_t *out, vbx_ubyte_t *in1,const int IN1ROWS, const int IN1COLS, vbx_ubyte_t *in2pre, const int IN2ROWS, const int IN2COLS ) {return vbw_mtx_mm_trans_ext<vbx_ubyte_t>( out, in1,IN1ROWS,IN1COLS,in2pre,IN2ROWS,IN2COLS);} int vbw_mtx_mm_ext_word( vbx_word_t *out, vbx_word_t *in1, const int rows1, const int cols1, vbx_word_t *in2, const int rows2, const int cols2 ){ return vbw_mtx_mm_ext<vbx_word_t>(out,in1,rows1,cols1,in2,rows2,cols2) ; } int vbw_mtx_mm_ext_uword( vbx_uword_t *out, vbx_uword_t *in1, const int rows1, const int cols1, vbx_uword_t *in2, const int rows2, const int cols2 ){ return vbw_mtx_mm_ext<vbx_uword_t>(out,in1,rows1,cols1,in2,rows2,cols2) ; } int vbw_mtx_mm_ext_half( vbx_half_t *out, vbx_half_t *in1, const int rows1, const int cols1, vbx_half_t *in2, const int rows2, const int cols2 ){ return vbw_mtx_mm_ext<vbx_half_t>(out,in1,rows1,cols1,in2,rows2,cols2) ; } int vbw_mtx_mm_ext_uhalf( vbx_uhalf_t *out, vbx_uhalf_t *in1, const int rows1, const int cols1, vbx_uhalf_t *in2, const int rows2, const int cols2 ){ return vbw_mtx_mm_ext<vbx_uhalf_t>(out,in1,rows1,cols1,in2,rows2,cols2) ; } int vbw_mtx_mm_ext_byte( vbx_byte_t *out, vbx_byte_t *in1, const int rows1, const int cols1, vbx_byte_t *in2, const int rows2, const int cols2 ){ return vbw_mtx_mm_ext<vbx_byte_t>(out,in1,rows1,cols1,in2,rows2,cols2) ; } int vbw_mtx_mm_ext_ubyte( vbx_ubyte_t *out, vbx_ubyte_t *in1, const int rows1, const int cols1, vbx_ubyte_t *in2, const int rows2, const int cols2 ){ return vbw_mtx_mm_ext<vbx_ubyte_t>(out,in1,rows1,cols1,in2,rows2,cols2) ; } }
[ "joel@vectorblox.com" ]
joel@vectorblox.com
ae8f63acfb49c28f5b97c0a3a28e3fc0922ee125
9f81d77e028503dcbb6d7d4c0c302391b8fdd50c
/google/cloud/dialogflow_cx/mocks/mock_agents_connection.h
b55eb17392dea24184903205689c8e6133931f98
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
googleapis/google-cloud-cpp
b96a6ee50c972371daa8b8067ddd803de95f54ba
178d6581b499242c52f9150817d91e6c95b773a5
refs/heads/main
2023-08-31T09:30:11.624568
2023-08-31T03:29:11
2023-08-31T03:29:11
111,860,063
450
351
Apache-2.0
2023-09-14T21:52:02
2017-11-24T00:19:31
C++
UTF-8
C++
false
false
3,815
h
// Copyright 2022 Google LLC // // 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 // // https://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. // Generated by the Codegen C++ plugin. // If you make any local changes, they will be lost. // source: google/cloud/dialogflow/cx/v3/agent.proto #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_CX_MOCKS_MOCK_AGENTS_CONNECTION_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_CX_MOCKS_MOCK_AGENTS_CONNECTION_H #include "google/cloud/dialogflow_cx/agents_connection.h" #include <gmock/gmock.h> namespace google { namespace cloud { namespace dialogflow_cx_mocks { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN /** * A class to mock `AgentsConnection`. * * Application developers may want to test their code with simulated responses, * including errors, from an object of type `AgentsClient`. To do so, * construct an object of type `AgentsClient` with an instance of this * class. Then use the Google Test framework functions to program the behavior * of this mock. * * @see [This example][bq-mock] for how to test your application with GoogleTest. * While the example showcases types from the BigQuery library, the underlying * principles apply for any pair of `*Client` and `*Connection`. * * [bq-mock]: @cloud_cpp_docs_link{bigquery,bigquery-read-mock} */ class MockAgentsConnection : public dialogflow_cx::AgentsConnection { public: MOCK_METHOD(Options, options, (), (override)); MOCK_METHOD(StreamRange<google::cloud::dialogflow::cx::v3::Agent>, ListAgents, (google::cloud::dialogflow::cx::v3::ListAgentsRequest request), (override)); MOCK_METHOD( StatusOr<google::cloud::dialogflow::cx::v3::Agent>, GetAgent, (google::cloud::dialogflow::cx::v3::GetAgentRequest const& request), (override)); MOCK_METHOD( StatusOr<google::cloud::dialogflow::cx::v3::Agent>, CreateAgent, (google::cloud::dialogflow::cx::v3::CreateAgentRequest const& request), (override)); MOCK_METHOD( StatusOr<google::cloud::dialogflow::cx::v3::Agent>, UpdateAgent, (google::cloud::dialogflow::cx::v3::UpdateAgentRequest const& request), (override)); MOCK_METHOD( Status, DeleteAgent, (google::cloud::dialogflow::cx::v3::DeleteAgentRequest const& request), (override)); MOCK_METHOD( future<StatusOr<google::cloud::dialogflow::cx::v3::ExportAgentResponse>>, ExportAgent, (google::cloud::dialogflow::cx::v3::ExportAgentRequest const& request), (override)); MOCK_METHOD( future<StatusOr<google::protobuf::Struct>>, RestoreAgent, (google::cloud::dialogflow::cx::v3::RestoreAgentRequest const& request), (override)); MOCK_METHOD( StatusOr<google::cloud::dialogflow::cx::v3::AgentValidationResult>, ValidateAgent, (google::cloud::dialogflow::cx::v3::ValidateAgentRequest const& request), (override)); MOCK_METHOD( StatusOr<google::cloud::dialogflow::cx::v3::AgentValidationResult>, GetAgentValidationResult, (google::cloud::dialogflow::cx::v3::GetAgentValidationResultRequest const& request), (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_mocks } // namespace cloud } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_CX_MOCKS_MOCK_AGENTS_CONNECTION_H
[ "noreply@github.com" ]
noreply@github.com
bc316e74a02b16ff39fa502e9f493d8d71973efb
11d0011d9d922d4c5269ee8f5512e225db609fc4
/qt_server/q_android_silence_audio_recording.cpp
ced09e99b72bd1d8df69e26289ee03b39ab1e905
[]
no_license
Gabriele91/AndroidSilenceAudioRecording
ca54f2b9506ffa61cebc3916b40141be472b386c
c47101120d337fc79fde0c9c8cff1016a18115be
refs/heads/master
2022-05-10T06:54:34.275681
2017-10-27T13:29:02
2017-10-27T13:29:02
59,752,587
0
0
null
null
null
null
UTF-8
C++
false
false
7,388
cpp
#include "q_android_silence_audio_recording.h" #include "ui_q_android_silence_audio_recording.h" #include <QWindow> #include <QMouseEvent> #include <QMessageBox> q_android_silence_audio_recording::q_android_silence_audio_recording(QWidget *parent) :QMainWindow(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint) ,m_ui(new Ui::q_android_silence_audio_recording) ,m_options(new q_options(this)) ,m_settings(new q_settings(this)) { //init ui m_ui->setupUi(this); //////////////////////////////////////////////////////////////////////////// //set settings m_ui->m_w_info->layout()->addWidget(m_settings); m_settings->hide(); //////////////////////////////////////////////////////////////////////////// //set style m_ui->m_hl_top_menu->setStyleSheet(tr("QFrame[accessibleName=\"top_frame\"] " "{" "border: 1px solid #3A3939;" "color: silver;" "margin-bottom: 6px;" "padding: 0px" "}" )); m_ui->m_w_info->setStyleSheet(tr("QWidget[accessibleName=\"bottom_frame\"] " "{" "border: 1px solid #3A3939;" "color: silver;" "}" )); //show info setContextMenuPolicy(Qt::ActionsContextMenu); setToolTip(tr("Drag the application with the left mouse button.\n" "Use the right mouse button to open a context menu.")); setWindowTitle(tr("Android Silence Audio Recording")); //////////////////////////////////////////////////////////////////////////// //events //exit menu QAction *l_quit_action = new QAction(tr("E&xit"), this); l_quit_action->setShortcut(tr("Ctrl+Q")); connect(l_quit_action, SIGNAL(triggered()), this, SLOT(close())); addAction(l_quit_action); //connect exit connect(m_ui->m_cb_exit, SIGNAL(stateChanged(int)), this, SLOT(close())); //connect minimized connect(m_ui->m_cb_minimized, &QCheckBox::stateChanged, this, [this](int changed) { if(!changed) showMinimized(); else showNormal(); }); //massimize m_ui->m_hl_top_menu->set_callback( [this](bool first) { if(first) showMaximized(); else showNormal(); }); //connect select item connect(m_ui->m_lw_devices, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemClicked(QListWidgetItem*))); //////////////////////////////////////////////////////////////////////////// //set view list m_list_listener.set_list(m_ui->m_lw_devices); //init rak server m_rak_server.init(m_options->get_port(), m_options->get_max_clients()); //set callback m_rak_server.loop(m_list_listener); } void q_android_silence_audio_recording::closeEvent(QCloseEvent *event) { if(m_list_listener.some_file_are_open()) { if(QMessageBox::question(this, "AndroidSilenceAudioRecording", "Attention! " "You are still recording, " "do you really want to close the application?\n" "(Note: files will be saved on exit)", QMessageBox::Yes| QMessageBox::No) == QMessageBox::Yes) { event->accept(); } else { //ignore event event->ignore(); //ui invalid m_ui->m_cb_exit->setChecked(true); } } } q_android_silence_audio_recording::~q_android_silence_audio_recording() { //save all m_list_listener.close_all_files(this); //stop server m_rak_server.stop_loop(); //dealloc dialogs delete m_options; //delete ui delete m_ui; } //get rak server rak_server& q_android_silence_audio_recording::get_rak_server() { return m_rak_server; } //change ui void q_android_silence_audio_recording::show_settings(q_audio_server_listener* listener) { //disable signals m_settings->blockSignals(true); m_ui->m_lw_devices->blockSignals(true); //set listener m_settings->set_audio_server_listener(listener,m_options->get_path()); //change ui m_ui->m_lw_devices->hide(); m_ui->m_pb_options->hide(); m_settings->show(); //renable signals m_settings->blockSignals(false); m_ui->m_lw_devices->blockSignals(false); } void q_android_silence_audio_recording::show_list_device() { //disable signals m_settings->blockSignals(true); m_ui->m_lw_devices->blockSignals(true); //change ui m_settings->hide(); //show m_ui->m_lw_devices->show(); m_ui->m_pb_options->show(); //renable signals m_settings->blockSignals(false); m_ui->m_lw_devices->blockSignals(false); //rebuild list m_list_listener.update_all_item_status(); m_ui->m_lw_devices->repaint(); } void q_android_silence_audio_recording::itemClicked(QListWidgetItem* item) { //get value QVariant variant=item->data(Qt::UserRole); //get row auto* row = (q_list_server_listener::row_map_listener*)variant.value<void*>(); //show show_settings(&row->m_listener); } void q_android_silence_audio_recording::options() { //exec int ret_value = m_options->exec(); //test port if(ret_value = QMessageBox::Ok && m_options->get_port() != m_rak_server.get_init_port() ) { if(m_list_listener.some_file_are_open() && (QMessageBox::question(this, "AndroidSilenceAudioRecording", "Attention! " "You are still recording, " "do you really want to change the server port?\n" "(Note: files will be saved on change)", QMessageBox::Yes| QMessageBox::No) != QMessageBox::Yes)) { //reset port m_options->set_port(m_rak_server.get_init_port()); //return return; } //destoy all m_rak_server.shutdown(); //clear list m_list_listener.clear(); //init rak server m_rak_server.init(m_options->get_port(), m_options->get_max_clients()); //set callback m_rak_server.loop(m_list_listener); } } void q_android_silence_audio_recording::showEvent(QShowEvent * event) { m_ui->m_cb_minimized->setChecked(true); } void q_android_silence_audio_recording::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() & Qt::LeftButton) { move(event->globalPos() - m_drag_position); event->accept(); } } void q_android_silence_audio_recording::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { m_drag_position = event->globalPos() - frameGeometry().topLeft(); event->accept(); } }
[ "dbgabri@gmail.com" ]
dbgabri@gmail.com
e7be2cf2e0f00b63487c6da63268fcbfc06487f6
b522ef7197ce1908bd8d09d35e2033b53df7a903
/src/luascript.h
67035cc4bdbdef1249b2d92f6e958a55999a69dc
[]
no_license
EGSilver/Review
a60b539dc468bde5a724897886f6fd25bcc3b9f2
ff291c05377663aa35802c80ca7ddb2d1bede4b7
refs/heads/master
2023-03-17T05:51:06.430857
2021-03-08T14:34:35
2021-03-08T14:34:35
340,983,471
0
1
null
null
null
null
UTF-8
C++
false
false
42,667
h
/** * The Forgotten Server - a free and open-source MMORPG server emulator * Copyright (C) 2015 Mark Samman <mark.samman@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef FS_LUASCRIPT_H_5344B2BC907E46E3943EA78574A212D8 #define FS_LUASCRIPT_H_5344B2BC907E46E3943EA78574A212D8 #include <lua.hpp> #if LUA_VERSION_NUM >= 502 // NOTE: Define LUA_COMPAT_ALL as a workaround if this doesn't work #ifndef LUA_COMPAT_ALL #ifndef LUA_COMPAT_MODULE #define luaL_register(L, libname, l) (luaL_newlib(L, l), lua_pushvalue(L, -1), lua_setglobal(L, libname)) #endif #define lua_equal(L, i1, i2) lua_compare(L, (i1), (i2), LUA_OPEQ) #endif #endif #include "database.h" #include "enums.h" #include "position.h" class Thing; class Creature; class Player; class Item; class Container; class AreaCombat; class Combat; class Condition; class Npc; class Monster; enum LuaVariantType_t { VARIANT_NONE, VARIANT_NUMBER, VARIANT_POSITION, VARIANT_TARGETPOSITION, VARIANT_STRING, }; enum LuaDataType { LuaData_Unknown, LuaData_Item, LuaData_Container, LuaData_Teleport, LuaData_Player, LuaData_Monster, LuaData_Npc, LuaData_Tile, }; struct LuaVariant { LuaVariant() { type = VARIANT_NONE; number = 0; } LuaVariantType_t type; std::string text; Position pos; uint32_t number; }; struct LuaTimerEventDesc { int32_t scriptId; int32_t function; std::list<int32_t> parameters; uint32_t eventId; LuaTimerEventDesc() : scriptId(-1), function(-1), eventId(0) {} LuaTimerEventDesc(LuaTimerEventDesc&& other) : scriptId(other.scriptId), function(other.function), parameters(std::move(other.parameters)), eventId(other.eventId) {} }; class LuaScriptInterface; class Game; class Npc; class ScriptEnvironment { public: ScriptEnvironment(); ~ScriptEnvironment(); // non-copyable ScriptEnvironment(const ScriptEnvironment&) = delete; ScriptEnvironment& operator=(const ScriptEnvironment&) = delete; void resetEnv(); void setScriptId(int32_t scriptId, LuaScriptInterface* scriptInterface) { m_scriptId = scriptId; m_interface = scriptInterface; } bool setCallbackId(int32_t callbackId, LuaScriptInterface* scriptInterface); void setEventDesc(std::string desc) { m_eventdesc = desc; } std::string getEventDesc() const { return m_eventdesc; } int32_t getScriptId() const { return m_scriptId; } int32_t getCallbackId() const { return m_callbackId; } LuaScriptInterface* getScriptInterface() { return m_interface; } void setTimerEvent() { m_timerEvent = true; } void resetTimerEvent() { m_timerEvent = false; } void getEventInfo(int32_t& scriptId, std::string& desc, LuaScriptInterface*& scriptInterface, int32_t& callbackId, bool& timerEvent) const; void addTempItem(Item* item); static void removeTempItem(Item* item); uint32_t addThing(Thing* thing); void insertItem(uint32_t uid, Item* item); static DBResult_ptr getResultByID(uint32_t id); static uint32_t addResult(DBResult_ptr res); static bool removeResult(uint32_t id); void setNpc(Npc* npc) { m_curNpc = npc; } Npc* getNpc() const { return m_curNpc; } Thing* getThingByUID(uint32_t uid); Item* getItemByUID(uint32_t uid); Container* getContainerByUID(uint32_t uid); void removeItemByUID(uint32_t uid); private: typedef std::vector<const LuaVariant*> VariantVector; typedef std::map<uint32_t, int32_t> StorageMap; typedef std::map<uint32_t, DBResult_ptr> DBResultMap; //script file id int32_t m_scriptId; int32_t m_callbackId; bool m_timerEvent; LuaScriptInterface* m_interface; //script event desc std::string m_eventdesc; //local item map uint32_t m_lastUID; std::unordered_map<uint32_t, Item*> localMap; //temporary item list static std::multimap<ScriptEnvironment*, Item*> tempItems; //result map static uint32_t m_lastResultId; static DBResultMap m_tempResults; //for npc scripts Npc* m_curNpc; }; #define reportErrorFunc(a) reportError(__FUNCTION__, a, true) enum ErrorCode_t { LUA_ERROR_PLAYER_NOT_FOUND, LUA_ERROR_CREATURE_NOT_FOUND, LUA_ERROR_ITEM_NOT_FOUND, LUA_ERROR_THING_NOT_FOUND, LUA_ERROR_TILE_NOT_FOUND, LUA_ERROR_HOUSE_NOT_FOUND, LUA_ERROR_COMBAT_NOT_FOUND, LUA_ERROR_CONDITION_NOT_FOUND, LUA_ERROR_AREA_NOT_FOUND, LUA_ERROR_CONTAINER_NOT_FOUND, LUA_ERROR_VARIANT_NOT_FOUND, LUA_ERROR_VARIANT_UNKNOWN, LUA_ERROR_SPELL_NOT_FOUND, }; class LuaScriptInterface { public: explicit LuaScriptInterface(std::string interfaceName); virtual ~LuaScriptInterface(); // non-copyable LuaScriptInterface(const LuaScriptInterface&) = delete; LuaScriptInterface& operator=(const LuaScriptInterface&) = delete; virtual bool initState(); bool reInitState(); int32_t loadFile(const std::string& file, Npc* npc = nullptr); const std::string& getFileById(int32_t scriptId); int32_t getEvent(const std::string& eventName); int32_t getMetaEvent(const std::string& globalName, const std::string& eventName); static ScriptEnvironment* getScriptEnv() { assert(m_scriptEnvIndex >= 0 && m_scriptEnvIndex < 16); return m_scriptEnv + m_scriptEnvIndex; } static bool reserveScriptEnv() { return ++m_scriptEnvIndex < 16; } static void resetScriptEnv() { assert(m_scriptEnvIndex >= 0); m_scriptEnv[m_scriptEnvIndex--].resetEnv(); } static void reportError(const char* function, const std::string& error_desc, bool stack_trace = false); const std::string& getInterfaceName() const { return m_interfaceName; } const std::string& getLastLuaError() const { return m_lastLuaError; } lua_State* getLuaState() const { return m_luaState; } bool pushFunction(int32_t functionId); static int luaErrorHandler(lua_State* L); bool callFunction(int params); void callVoidFunction(int params); //push/pop common structures static void pushThing(lua_State* L, Thing* thing); static void pushVariant(lua_State* L, const LuaVariant& var); static void pushString(lua_State* L, const std::string& value); static void pushCallback(lua_State* L, int32_t callback); static std::string popString(lua_State* L); static int32_t popCallback(lua_State* L); // Userdata template<class T> static void pushUserdata(lua_State* L, T* value) { T** userdata = static_cast<T**>(lua_newuserdata(L, sizeof(T*))); *userdata = value; } // Metatables static void setMetatable(lua_State* L, int32_t index, const std::string& name); static void setWeakMetatable(lua_State* L, int32_t index, const std::string& name); static void setItemMetatable(lua_State* L, int32_t index, const Item* item); static void setCreatureMetatable(lua_State* L, int32_t index, const Creature* creature); // Get template<typename T> inline static typename std::enable_if<std::is_enum<T>::value, T>::type getNumber(lua_State* L, int32_t arg) { return static_cast<T>(static_cast<int64_t>(lua_tonumber(L, arg))); } template<typename T> inline static typename std::enable_if<std::is_integral<T>::value || std::is_floating_point<T>::value, T>::type getNumber(lua_State* L, int32_t arg) { return static_cast<T>(lua_tonumber(L, arg)); } template<typename T> static T getNumber(lua_State *L, int32_t arg, T defaultValue) { const auto parameters = lua_gettop(L); if (parameters == 0 || arg > parameters) { return defaultValue; } return getNumber<T>(L, arg); } template<class T> static T* getUserdata(lua_State* L, int32_t arg) { T** userdata = getRawUserdata<T>(L, arg); if (!userdata) { return nullptr; } return *userdata; } template<class T> inline static T** getRawUserdata(lua_State* L, int32_t arg) { return static_cast<T**>(lua_touserdata(L, arg)); } inline static bool getBoolean(lua_State* L, int32_t arg) { return lua_toboolean(L, arg) != 0; } inline static bool getBoolean(lua_State* L, int32_t arg, bool defaultValue) { const auto parameters = lua_gettop(L); if (parameters == 0 || arg > parameters) { return defaultValue; } return lua_toboolean(L, arg) != 0; } static std::string getString(lua_State* L, int32_t arg); static Position getPosition(lua_State* L, int32_t arg, int32_t& stackpos); static Position getPosition(lua_State* L, int32_t arg); static Outfit_t getOutfit(lua_State* L, int32_t arg); static LuaVariant getVariant(lua_State* L, int32_t arg); static Thing* getThing(lua_State* L, int32_t arg); static Creature* getCreature(lua_State* L, int32_t arg); static Player* getPlayer(lua_State* L, int32_t arg); template<typename T> static T getField(lua_State* L, int32_t arg, const std::string& key) { lua_getfield(L, arg, key.c_str()); return getNumber<T>(L, -1); } static std::string getFieldString(lua_State* L, int32_t arg, const std::string& key); static LuaDataType getUserdataType(lua_State* L, int32_t arg); // Is inline static bool isNumber(lua_State* L, int32_t arg) { return lua_isnumber(L, arg) != 0; } inline static bool isString(lua_State* L, int32_t arg) { return lua_isstring(L, arg) != 0; } inline static bool isBoolean(lua_State* L, int32_t arg) { return lua_isboolean(L, arg); } inline static bool isTable(lua_State* L, int32_t arg) { return lua_istable(L, arg); } inline static bool isFunction(lua_State* L, int32_t arg) { return lua_isfunction(L, arg); } inline static bool isUserdata(lua_State* L, int32_t arg) { return lua_isuserdata(L, arg) != 0; } // Push static void pushBoolean(lua_State* L, bool value); static void pushPosition(lua_State* L, const Position& position, int32_t stackpos = 0); static void pushOutfit(lua_State* L, const Outfit_t& outfit); // inline static void setField(lua_State* L, const char* index, lua_Number value) { lua_pushnumber(L, value); lua_setfield(L, -2, index); } inline static void setField(lua_State* L, const char* index, const std::string& value) { pushString(L, value); lua_setfield(L, -2, index); } static std::string escapeString(const std::string& string); #ifndef LUAJIT_VERSION static const luaL_Reg luaBitReg[7]; #endif static const luaL_Reg luaConfigManagerTable[4]; static const luaL_Reg luaDatabaseTable[9]; static const luaL_Reg luaResultTable[6]; static int protectedCall(lua_State* L, int nargs, int nresults); protected: virtual bool closeState(); void registerFunctions(); void registerClass(const std::string& className, const std::string& baseClass, lua_CFunction newFunction = nullptr); void registerTable(const std::string& tableName); void registerMethod(const std::string& className, const std::string& methodName, lua_CFunction func); void registerMetaMethod(const std::string& className, const std::string& methodName, lua_CFunction func); void registerGlobalMethod(const std::string& functionName, lua_CFunction func); void registerVariable(const std::string& tableName, const std::string& name, lua_Number value); void registerGlobalVariable(const std::string& name, lua_Number value); void registerGlobalBoolean(const std::string& name, bool value); std::string getStackTrace(const std::string& error_desc); static std::string getErrorDesc(ErrorCode_t code); static bool getArea(lua_State* L, std::list<uint32_t>& list, uint32_t& rows); //lua functions static int luaDoCreateItem(lua_State* L); static int luaDoCreateItemEx(lua_State* L); static int luaDoMoveCreature(lua_State* L); static int luaDoPlayerAddItem(lua_State* L); static int luaDoTileAddItemEx(lua_State* L); static int luaDoSetCreatureLight(lua_State* L); //get item info static int luaGetDepotId(lua_State* L); //get creature info functions static int luaGetPlayerFlagValue(lua_State* L); static int luaGetCreatureCondition(lua_State* L); static int luaGetPlayerInstantSpellInfo(lua_State* L); static int luaGetPlayerInstantSpellCount(lua_State* L); static int luaGetWorldTime(lua_State* L); static int luaGetWorldLight(lua_State* L); static int luaGetWorldUpTime(lua_State* L); //type validation static int luaIsDepot(lua_State* L); static int luaIsMoveable(lua_State* L); static int luaIsValidUID(lua_State* L); //container static int luaDoAddContainerItem(lua_State* L); // static int luaCreateCombatArea(lua_State* L); static int luaDoAreaCombatHealth(lua_State* L); static int luaDoTargetCombatHealth(lua_State* L); // static int luaDoAreaCombatMana(lua_State* L); static int luaDoTargetCombatMana(lua_State* L); static int luaDoAreaCombatCondition(lua_State* L); static int luaDoTargetCombatCondition(lua_State* L); static int luaDoAreaCombatDispel(lua_State* L); static int luaDoTargetCombatDispel(lua_State* L); static int luaDoChallengeCreature(lua_State* L); static int luaSetCreatureOutfit(lua_State* L); static int luaSetMonsterOutfit(lua_State* L); static int luaSetItemOutfit(lua_State* L); static int luaDebugPrint(lua_State* L); static int luaIsInArray(lua_State* L); static int luaAddEvent(lua_State* L); static int luaStopEvent(lua_State* L); static int luaSaveServer(lua_State* L); static int luaCleanMap(lua_State* L); static int luaIsInWar(lua_State* L); static int luaGetWaypointPositionByName(lua_State* L); static int luaSendChannelMessage(lua_State* L); static int luaSendGuildChannelMessage(lua_State* L); #ifndef LUAJIT_VERSION static int luaBitNot(lua_State* L); static int luaBitAnd(lua_State* L); static int luaBitOr(lua_State* L); static int luaBitXor(lua_State* L); static int luaBitLeftShift(lua_State* L); static int luaBitRightShift(lua_State* L); #endif static int luaConfigManagerGetString(lua_State* L); static int luaConfigManagerGetNumber(lua_State* L); static int luaConfigManagerGetBoolean(lua_State* L); static int luaDatabaseExecute(lua_State* L); static int luaDatabaseAsyncExecute(lua_State* L); static int luaDatabaseStoreQuery(lua_State* L); static int luaDatabaseAsyncStoreQuery(lua_State* L); static int luaDatabaseEscapeString(lua_State* L); static int luaDatabaseEscapeBlob(lua_State* L); static int luaDatabaseLastInsertId(lua_State* L); static int luaDatabaseConnected(lua_State* L); static int luaDatabaseTableExists(lua_State* L); static int luaResultGetNumber(lua_State* L); static int luaResultGetString(lua_State* L); static int luaResultGetStream(lua_State* L); static int luaResultNext(lua_State* L); static int luaResultFree(lua_State* L); // Userdata static int luaUserdataCompare(lua_State* L); // _G static int luaIsType(lua_State* L); static int luaRawGetMetatable(lua_State* L); // os static int luaSystemTime(lua_State* L); // table static int luaTableCreate(lua_State* L); // Game static int luaGameGetSpectators(lua_State* L); static int luaGameGetPlayers(lua_State* L); static int luaGameLoadMap(lua_State* L); static int luaGameGetExperienceStage(lua_State* L); static int luaGameGetMonsterCount(lua_State* L); static int luaGameGetPlayerCount(lua_State* L); static int luaGameGetNpcCount(lua_State* L); static int luaGameGetTowns(lua_State* L); static int luaGameGetHouses(lua_State* L); static int luaGameGetGameState(lua_State* L); static int luaGameSetGameState(lua_State* L); static int luaGameGetWorldType(lua_State* L); static int luaGameSetWorldType(lua_State* L); static int luaGameGetReturnMessage(lua_State* L); static int luaGameCreateItem(lua_State* L); static int luaGameCreateContainer(lua_State* L); static int luaGameCreateMonster(lua_State* L); static int luaGameCreateNpc(lua_State* L); static int luaGameCreateTile(lua_State* L); static int luaGameStartRaid(lua_State* L); // Variant static int luaVariantCreate(lua_State* L); static int luaVariantGetNumber(lua_State* L); static int luaVariantGetString(lua_State* L); static int luaVariantGetPosition(lua_State* L); // Position static int luaPositionCreate(lua_State* L); static int luaPositionAdd(lua_State* L); static int luaPositionSub(lua_State* L); static int luaPositionCompare(lua_State* L); static int luaPositionGetDistance(lua_State* L); static int luaPositionIsSightClear(lua_State* L); static int luaPositionSendMagicEffect(lua_State* L); static int luaPositionSendDistanceEffect(lua_State* L); // Tile static int luaTileCreate(lua_State* L); static int luaTileGetPosition(lua_State* L); static int luaTileGetGround(lua_State* L); static int luaTileGetThing(lua_State* L); static int luaTileGetThingCount(lua_State* L); static int luaTileGetTopVisibleThing(lua_State* L); static int luaTileGetTopTopItem(lua_State* L); static int luaTileGetTopDownItem(lua_State* L); static int luaTileGetFieldItem(lua_State* L); static int luaTileGetItemById(lua_State* L); static int luaTileGetItemByType(lua_State* L); static int luaTileGetItemByTopOrder(lua_State* L); static int luaTileGetItemCountById(lua_State* L); static int luaTileGetBottomCreature(lua_State* L); static int luaTileGetTopCreature(lua_State* L); static int luaTileGetBottomVisibleCreature(lua_State* L); static int luaTileGetTopVisibleCreature(lua_State* L); static int luaTileGetItems(lua_State* L); static int luaTileGetItemCount(lua_State* L); static int luaTileGetDownItemCount(lua_State* L); static int luaTileGetTopItemCount(lua_State* L); static int luaTileGetCreatures(lua_State* L); static int luaTileGetCreatureCount(lua_State* L); static int luaTileHasProperty(lua_State* L); static int luaTileHasFlag(lua_State* L); static int luaTileGetThingIndex(lua_State* L); static int luaTileQueryAdd(lua_State* L); static int luaTileGetHouse(lua_State* L); // NetworkMessage static int luaNetworkMessageCreate(lua_State* L); static int luaNetworkMessageDelete(lua_State* L); static int luaNetworkMessageGetByte(lua_State* L); static int luaNetworkMessageGetU16(lua_State* L); static int luaNetworkMessageGetU32(lua_State* L); static int luaNetworkMessageGetU64(lua_State* L); static int luaNetworkMessageGetString(lua_State* L); static int luaNetworkMessageGetPosition(lua_State* L); static int luaNetworkMessageAddByte(lua_State* L); static int luaNetworkMessageAddU16(lua_State* L); static int luaNetworkMessageAddU32(lua_State* L); static int luaNetworkMessageAddU64(lua_State* L); static int luaNetworkMessageAddString(lua_State* L); static int luaNetworkMessageAddPosition(lua_State* L); static int luaNetworkMessageAddDouble(lua_State* L); static int luaNetworkMessageAddItem(lua_State* L); static int luaNetworkMessageAddItemId(lua_State* L); static int luaNetworkMessageReset(lua_State* L); static int luaNetworkMessageSkipBytes(lua_State* L); static int luaNetworkMessageSendToPlayer(lua_State* L); // ModalWindow static int luaModalWindowCreate(lua_State* L); static int luaModalWindowDelete(lua_State* L); static int luaModalWindowGetId(lua_State* L); static int luaModalWindowGetTitle(lua_State* L); static int luaModalWindowGetMessage(lua_State* L); static int luaModalWindowSetTitle(lua_State* L); static int luaModalWindowSetMessage(lua_State* L); static int luaModalWindowGetButtonCount(lua_State* L); static int luaModalWindowGetChoiceCount(lua_State* L); static int luaModalWindowAddButton(lua_State* L); static int luaModalWindowAddChoice(lua_State* L); static int luaModalWindowGetDefaultEnterButton(lua_State* L); static int luaModalWindowSetDefaultEnterButton(lua_State* L); static int luaModalWindowGetDefaultEscapeButton(lua_State* L); static int luaModalWindowSetDefaultEscapeButton(lua_State* L); static int luaModalWindowHasPriority(lua_State* L); static int luaModalWindowSetPriority(lua_State* L); static int luaModalWindowSendToPlayer(lua_State* L); // Item static int luaItemCreate(lua_State* L); static int luaItemIsItem(lua_State* L); static int luaItemGetParent(lua_State* L); static int luaItemGetTopParent(lua_State* L); static int luaItemGetId(lua_State* L); static int luaItemClone(lua_State* L); static int luaItemSplit(lua_State* L); static int luaItemRemove(lua_State* L); static int luaItemGetUniqueId(lua_State* L); static int luaItemGetActionId(lua_State* L); static int luaItemSetActionId(lua_State* L); static int luaItemGetCount(lua_State* L); static int luaItemGetCharges(lua_State* L); static int luaItemGetFluidType(lua_State* L); static int luaItemGetWeight(lua_State* L); static int luaItemGetSubType(lua_State* L); static int luaItemGetName(lua_State* L); static int luaItemGetPluralName(lua_State* L); static int luaItemGetArticle(lua_State* L); static int luaItemGetPosition(lua_State* L); static int luaItemGetTile(lua_State* L); static int luaItemHasAttribute(lua_State* L); static int luaItemGetAttribute(lua_State* L); static int luaItemSetAttribute(lua_State* L); static int luaItemRemoveAttribute(lua_State* L); static int luaItemMoveTo(lua_State* L); static int luaItemTransform(lua_State* L); static int luaItemDecay(lua_State* L); static int luaItemGetDescription(lua_State* L); static int luaItemHasProperty(lua_State* L); // Container static int luaContainerCreate(lua_State* L); static int luaContainerGetSize(lua_State* L); static int luaContainerGetCapacity(lua_State* L); static int luaContainerGetEmptySlots(lua_State* L); static int luaContainerGetItemHoldingCount(lua_State* L); static int luaContainerGetItemCountById(lua_State* L); static int luaContainerGetItem(lua_State* L); static int luaContainerHasItem(lua_State* L); static int luaContainerAddItem(lua_State* L); static int luaContainerAddItemEx(lua_State* L); // Teleport static int luaTeleportCreate(lua_State* L); static int luaTeleportGetDestination(lua_State* L); static int luaTeleportSetDestination(lua_State* L); // Creature static int luaCreatureCreate(lua_State* L); static int luaCreatureRegisterEvent(lua_State* L); static int luaCreatureUnregisterEvent(lua_State* L); static int luaCreatureIsRemoved(lua_State* L); static int luaCreatureIsCreature(lua_State* L); static int luaCreatureIsInGhostMode(lua_State* L); static int luaCreatureIsHealthHidden(lua_State* L); static int luaCreatureCanSee(lua_State* L); static int luaCreatureCanSeeCreature(lua_State* L); static int luaCreatureGetParent(lua_State* L); static int luaCreatureGetId(lua_State* L); static int luaCreatureGetName(lua_State* L); static int luaCreatureGetTarget(lua_State* L); static int luaCreatureSetTarget(lua_State* L); static int luaCreatureGetFollowCreature(lua_State* L); static int luaCreatureSetFollowCreature(lua_State* L); static int luaCreatureGetMaster(lua_State* L); static int luaCreatureSetMaster(lua_State* L); static int luaCreatureGetLight(lua_State* L); static int luaCreatureSetLight(lua_State* L); static int luaCreatureGetSpeed(lua_State* L); static int luaCreatureGetBaseSpeed(lua_State* L); static int luaCreatureChangeSpeed(lua_State* L); static int luaCreatureSetDropLoot(lua_State* L); static int luaCreatureGetPosition(lua_State* L); static int luaCreatureGetTile(lua_State* L); static int luaCreatureGetDirection(lua_State* L); static int luaCreatureSetDirection(lua_State* L); static int luaCreatureGetHealth(lua_State* L); static int luaCreatureAddHealth(lua_State* L); static int luaCreatureGetMaxHealth(lua_State* L); static int luaCreatureSetMaxHealth(lua_State* L); static int luaCreatureSetHiddenHealth(lua_State* L); static int luaCreatureGetMana(lua_State* L); static int luaCreatureAddMana(lua_State* L); static int luaCreatureGetMaxMana(lua_State* L); static int luaCreatureGetSkull(lua_State* L); static int luaCreatureSetSkull(lua_State* L); static int luaCreatureGetOutfit(lua_State* L); static int luaCreatureSetOutfit(lua_State* L); static int luaCreatureGetCondition(lua_State* L); static int luaCreatureAddCondition(lua_State* L); static int luaCreatureRemoveCondition(lua_State* L); static int luaCreatureRemove(lua_State* L); static int luaCreatureTeleportTo(lua_State* L); static int luaCreatureSay(lua_State* L); static int luaCreatureGetDamageMap(lua_State* L); static int luaCreatureGetSummons(lua_State* L); static int luaCreatureGetDescription(lua_State* L); static int luaCreatureGetPathTo(lua_State* L); // Player static int luaPlayerCreate(lua_State* L); static int luaPlayerIsPlayer(lua_State* L); static int luaPlayerSetLossSkill(lua_State* L); static int luaPlayerGetGuid(lua_State* L); static int luaPlayerGetIp(lua_State* L); static int luaPlayerGetAccountId(lua_State* L); static int luaPlayerGetLastLoginSaved(lua_State* L); static int luaPlayerGetLastLogout(lua_State* L); static int luaPlayerGetAccountType(lua_State* L); static int luaPlayerSetAccountType(lua_State* L); static int luaPlayerGetCapacity(lua_State* L); static int luaPlayerSetCapacity(lua_State* L); static int luaPlayerGetFreeCapacity(lua_State* L); static int luaPlayerGetDepotChest(lua_State* L); static int luaPlayerGetInbox(lua_State* L); static int luaPlayerGetSkullTime(lua_State* L); static int luaPlayerSetSkullTime(lua_State* L); static int luaPlayerGetDeathPenalty(lua_State* L); static int luaPlayerGetExperience(lua_State* L); static int luaPlayerAddExperience(lua_State* L); static int luaPlayerRemoveExperience(lua_State* L); static int luaPlayerGetLevel(lua_State* L); static int luaPlayerGetMagicLevel(lua_State* L); static int luaPlayerGetBaseMagicLevel(lua_State* L); static int luaPlayerSetMaxMana(lua_State* L); static int luaPlayerGetManaSpent(lua_State* L); static int luaPlayerAddManaSpent(lua_State* L); static int luaPlayerGetSkillLevel(lua_State* L); static int luaPlayerGetEffectiveSkillLevel(lua_State* L); static int luaPlayerGetSkillPercent(lua_State* L); static int luaPlayerGetSkillTries(lua_State* L); static int luaPlayerAddSkillTries(lua_State* L); static int luaPlayerAddOfflineTrainingTime(lua_State* L); static int luaPlayerGetOfflineTrainingTime(lua_State* L); static int luaPlayerRemoveOfflineTrainingTime(lua_State* L); static int luaPlayerAddOfflineTrainingTries(lua_State* L); static int luaPlayerGetOfflineTrainingSkill(lua_State* L); static int luaPlayerSetOfflineTrainingSkill(lua_State* L); static int luaPlayerGetItemCount(lua_State* L); static int luaPlayerGetItemById(lua_State* L); static int luaPlayerGetVocation(lua_State* L); static int luaPlayerSetVocation(lua_State* L); static int luaPlayerGetSex(lua_State* L); static int luaPlayerSetSex(lua_State* L); static int luaPlayerGetTown(lua_State* L); static int luaPlayerSetTown(lua_State* L); static int luaPlayerGetGuild(lua_State* L); static int luaPlayerSetGuild(lua_State* L); static int luaPlayerGetGuildLevel(lua_State* L); static int luaPlayerSetGuildLevel(lua_State* L); static int luaPlayerGetGuildNick(lua_State* L); static int luaPlayerSetGuildNick(lua_State* L); static int luaPlayerGetGroup(lua_State* L); static int luaPlayerSetGroup(lua_State* L); static int luaPlayerGetStamina(lua_State* L); static int luaPlayerSetStamina(lua_State* L); static int luaPlayerGetSoul(lua_State* L); static int luaPlayerAddSoul(lua_State* L); static int luaPlayerGetMaxSoul(lua_State* L); static int luaPlayerGetBankBalance(lua_State* L); static int luaPlayerSetBankBalance(lua_State* L); static int luaPlayerGetStorageValue(lua_State* L); static int luaPlayerSetStorageValue(lua_State* L); static int luaPlayerAddItem(lua_State* L); static int luaPlayerAddItemEx(lua_State* L); static int luaPlayerRemoveItem(lua_State* L); static int luaPlayerGetMoney(lua_State* L); static int luaPlayerAddMoney(lua_State* L); static int luaPlayerRemoveMoney(lua_State* L); static int luaPlayerShowTextDialog(lua_State* L); static int luaPlayerSendTextMessage(lua_State* L); static int luaPlayerSendChannelMessage(lua_State* L); static int luaPlayerSendPrivateMessage(lua_State* L); static int luaPlayerChannelSay(lua_State* L); static int luaPlayerOpenChannel(lua_State* L); static int luaPlayerGetSlotItem(lua_State* L); static int luaPlayerGetParty(lua_State* L); static int luaPlayerAddOutfit(lua_State* L); static int luaPlayerAddOutfitAddon(lua_State* L); static int luaPlayerRemoveOutfit(lua_State* L); static int luaPlayerRemoveOutfitAddon(lua_State* L); static int luaPlayerHasOutfit(lua_State* L); static int luaPlayerSendOutfitWindow(lua_State* L); static int luaPlayerAddMount(lua_State* L); static int luaPlayerRemoveMount(lua_State* L); static int luaPlayerHasMount(lua_State* L); static int luaPlayerGetPremiumDays(lua_State* L); static int luaPlayerAddPremiumDays(lua_State* L); static int luaPlayerRemovePremiumDays(lua_State* L); static int luaPlayerHasBlessing(lua_State* L); static int luaPlayerAddBlessing(lua_State* L); static int luaPlayerRemoveBlessing(lua_State* L); static int luaPlayerCanLearnSpell(lua_State* L); static int luaPlayerLearnSpell(lua_State* L); static int luaPlayerForgetSpell(lua_State* L); static int luaPlayerHasLearnedSpell(lua_State* L); static int luaPlayerSendTutorial(lua_State* L); static int luaPlayerAddMapMark(lua_State* L); static int luaPlayerSave(lua_State* L); static int luaPlayerPopupFYI(lua_State* L); static int luaPlayerIsPzLocked(lua_State* L); static int luaPlayerGetClient(lua_State* L); static int luaPlayerGetHouse(lua_State* L); static int luaPlayerSetGhostMode(lua_State* L); static int luaPlayerGetContainerId(lua_State* L); static int luaPlayerGetContainerById(lua_State* L); static int luaPlayerGetContainerIndex(lua_State* L); static int32_t luaPlayerStartLiveCast(lua_State* L); static int32_t luaPlayerStopLiveCast(lua_State* L); static int32_t luaPlayerIsLiveCaster(lua_State* L); // Monster static int luaMonsterCreate(lua_State* L); static int luaMonsterIsMonster(lua_State* L); static int luaMonsterGetType(lua_State* L); static int luaMonsterGetSpawnPosition(lua_State* L); static int luaMonsterIsInSpawnRange(lua_State* L); static int luaMonsterIsIdle(lua_State* L); static int luaMonsterSetIdle(lua_State* L); static int luaMonsterIsTarget(lua_State* L); static int luaMonsterIsOpponent(lua_State* L); static int luaMonsterIsFriend(lua_State* L); static int luaMonsterAddFriend(lua_State* L); static int luaMonsterRemoveFriend(lua_State* L); static int luaMonsterGetFriendList(lua_State* L); static int luaMonsterGetFriendCount(lua_State* L); static int luaMonsterAddTarget(lua_State* L); static int luaMonsterRemoveTarget(lua_State* L); static int luaMonsterGetTargetList(lua_State* L); static int luaMonsterGetTargetCount(lua_State* L); static int luaMonsterSelectTarget(lua_State* L); static int luaMonsterSearchTarget(lua_State* L); // Npc static int luaNpcCreate(lua_State* L); static int luaNpcIsNpc(lua_State* L); static int luaNpcSetMasterPos(lua_State* L); static int luaNpcGetSpeechBubble(lua_State* L); static int luaNpcSetSpeechBubble(lua_State* L); // Guild static int luaGuildCreate(lua_State* L); static int luaGuildGetId(lua_State* L); static int luaGuildGetName(lua_State* L); static int luaGuildGetMembersOnline(lua_State* L); static int luaGuildAddRank(lua_State* L); static int luaGuildGetRankById(lua_State* L); static int luaGuildGetRankByLevel(lua_State* L); static int luaGuildGetMotd(lua_State* L); static int luaGuildSetMotd(lua_State* L); // Group static int luaGroupCreate(lua_State* L); static int luaGroupGetId(lua_State* L); static int luaGroupGetName(lua_State* L); static int luaGroupGetFlags(lua_State* L); static int luaGroupGetAccess(lua_State* L); static int luaGroupGetMaxDepotItems(lua_State* L); static int luaGroupGetMaxVipEntries(lua_State* L); // Vocation static int luaVocationCreate(lua_State* L); static int luaVocationGetId(lua_State* L); static int luaVocationGetClientId(lua_State* L); static int luaVocationGetName(lua_State* L); static int luaVocationGetDescription(lua_State* L); static int luaVocationGetRequiredSkillTries(lua_State* L); static int luaVocationGetRequiredManaSpent(lua_State* L); static int luaVocationGetCapacityGain(lua_State* L); static int luaVocationGetHealthGain(lua_State* L); static int luaVocationGetHealthGainTicks(lua_State* L); static int luaVocationGetHealthGainAmount(lua_State* L); static int luaVocationGetManaGain(lua_State* L); static int luaVocationGetManaGainTicks(lua_State* L); static int luaVocationGetManaGainAmount(lua_State* L); static int luaVocationGetMaxSoul(lua_State* L); static int luaVocationGetSoulGainTicks(lua_State* L); static int luaVocationGetAttackSpeed(lua_State* L); static int luaVocationGetBaseSpeed(lua_State* L); static int luaVocationGetDemotion(lua_State* L); static int luaVocationGetPromotion(lua_State* L); // Town static int luaTownCreate(lua_State* L); static int luaTownGetId(lua_State* L); static int luaTownGetName(lua_State* L); static int luaTownGetTemplePosition(lua_State* L); // House static int luaHouseCreate(lua_State* L); static int luaHouseGetId(lua_State* L); static int luaHouseGetName(lua_State* L); static int luaHouseGetTown(lua_State* L); static int luaHouseGetExitPosition(lua_State* L); static int luaHouseGetRent(lua_State* L); static int luaHouseGetOwnerGuid(lua_State* L); static int luaHouseSetOwnerGuid(lua_State* L); static int luaHouseGetBeds(lua_State* L); static int luaHouseGetBedCount(lua_State* L); static int luaHouseGetDoors(lua_State* L); static int luaHouseGetDoorCount(lua_State* L); static int luaHouseGetTiles(lua_State* L); static int luaHouseGetTileCount(lua_State* L); static int luaHouseGetAccessList(lua_State* L); static int luaHouseSetAccessList(lua_State* L); // ItemType static int luaItemTypeCreate(lua_State* L); static int luaItemTypeIsCorpse(lua_State* L); static int luaItemTypeIsDoor(lua_State* L); static int luaItemTypeIsContainer(lua_State* L); static int luaItemTypeIsFluidContainer(lua_State* L); static int luaItemTypeIsMovable(lua_State* L); static int luaItemTypeIsRune(lua_State* L); static int luaItemTypeIsStackable(lua_State* L); static int luaItemTypeIsReadable(lua_State* L); static int luaItemTypeIsWritable(lua_State* L); static int luaItemTypeGetType(lua_State* L); static int luaItemTypeGetId(lua_State* L); static int luaItemTypeGetClientId(lua_State* L); static int luaItemTypeGetName(lua_State* L); static int luaItemTypeGetPluralName(lua_State* L); static int luaItemTypeGetArticle(lua_State* L); static int luaItemTypeGetDescription(lua_State* L); static int luaItemTypeGetSlotPosition(lua_State *L); static int luaItemTypeGetCharges(lua_State* L); static int luaItemTypeGetFluidSource(lua_State* L); static int luaItemTypeGetCapacity(lua_State* L); static int luaItemTypeGetWeight(lua_State* L); static int luaItemTypeGetHitChance(lua_State* L); static int luaItemTypeGetShootRange(lua_State* L); static int luaItemTypeGetAttack(lua_State* L); static int luaItemTypeGetDefense(lua_State* L); static int luaItemTypeGetExtraDefense(lua_State* L); static int luaItemTypeGetArmor(lua_State* L); static int luaItemTypeGetWeaponType(lua_State* L); static int luaItemTypeGetElementType(lua_State* L); static int luaItemTypeGetElementDamage(lua_State* L); static int luaItemTypeGetTransformEquipId(lua_State* L); static int luaItemTypeGetTransformDeEquipId(lua_State* L); static int luaItemTypeGetDestroyId(lua_State* L); static int luaItemTypeGetDecayId(lua_State* L); static int luaItemTypeGetRequiredLevel(lua_State* L); static int luaItemTypeHasSubType(lua_State* L); // Reward static int luaItemGetNameDescription(lua_State* L); static int luaMonsterTypeUseRewardChest(lua_State* L); // Combat static int luaCombatCreate(lua_State* L); static int luaCombatSetParameter(lua_State* L); static int luaCombatSetFormula(lua_State* L); static int luaCombatSetArea(lua_State* L); static int luaCombatSetCondition(lua_State* L); static int luaCombatSetCallback(lua_State* L); static int luaCombatSetOrigin(lua_State* L); static int luaCombatExecute(lua_State* L); // Condition static int luaConditionCreate(lua_State* L); static int luaConditionDelete(lua_State* L); static int luaConditionGetId(lua_State* L); static int luaConditionGetSubId(lua_State* L); static int luaConditionGetType(lua_State* L); static int luaConditionGetIcons(lua_State* L); static int luaConditionGetEndTime(lua_State* L); static int luaConditionClone(lua_State* L); static int luaConditionGetTicks(lua_State* L); static int luaConditionSetTicks(lua_State* L); static int luaConditionSetParameter(lua_State* L); static int luaConditionSetFormula(lua_State* L); static int luaConditionSetOutfit(lua_State* L); static int luaConditionAddDamage(lua_State* L); // MonsterType static int luaMonsterTypeCreate(lua_State* L); static int luaMonsterTypeIsAttackable(lua_State* L); static int luaMonsterTypeIsConvinceable(lua_State* L); static int luaMonsterTypeIsSummonable(lua_State* L); static int luaMonsterTypeIsIllusionable(lua_State* L); static int luaMonsterTypeIsHostile(lua_State* L); static int luaMonsterTypeIsPushable(lua_State* L); static int luaMonsterTypeIsHealthShown(lua_State* L); static int luaMonsterTypeCanPushItems(lua_State* L); static int luaMonsterTypeCanPushCreatures(lua_State* L); static int luaMonsterTypeGetName(lua_State* L); static int luaMonsterTypeGetNameDescription(lua_State* L); static int luaMonsterTypeGetHealth(lua_State* L); static int luaMonsterTypeGetMaxHealth(lua_State* L); static int luaMonsterTypeGetRunHealth(lua_State* L); static int luaMonsterTypeGetExperience(lua_State* L); static int luaMonsterTypeGetCombatImmunities(lua_State* L); static int luaMonsterTypeGetConditionImmunities(lua_State* L); static int luaMonsterTypeGetAttackList(lua_State* L); static int luaMonsterTypeGetDefenseList(lua_State* L); static int luaMonsterTypeGetElementList(lua_State* L); static int luaMonsterTypeGetVoices(lua_State* L); static int luaMonsterTypeGetLoot(lua_State* L); static int luaMonsterTypeGetCreatureEvents(lua_State* L); static int luaMonsterTypeGetSummonList(lua_State* L); static int luaMonsterTypeGetMaxSummons(lua_State* L); static int luaMonsterTypeGetArmor(lua_State* L); static int luaMonsterTypeGetDefense(lua_State* L); static int luaMonsterTypeGetOutfit(lua_State* L); static int luaMonsterTypeGetRace(lua_State* L); static int luaMonsterTypeGetCorpseId(lua_State* L); static int luaMonsterTypeGetManaCost(lua_State* L); static int luaMonsterTypeGetBaseSpeed(lua_State* L); static int luaMonsterTypeGetLight(lua_State* L); static int luaMonsterTypeGetStaticAttackChance(lua_State* L); static int luaMonsterTypeGetTargetDistance(lua_State* L); static int luaMonsterTypeGetYellChance(lua_State* L); static int luaMonsterTypeGetYellSpeedTicks(lua_State* L); static int luaMonsterTypeGetChangeTargetChance(lua_State* L); static int luaMonsterTypeGetChangeTargetSpeed(lua_State* L); // Party static int luaPartyDisband(lua_State* L); static int luaPartyGetLeader(lua_State* L); static int luaPartySetLeader(lua_State* L); static int luaPartyGetMembers(lua_State* L); static int luaPartyGetMemberCount(lua_State* L); static int luaPartyGetInvitees(lua_State* L); static int luaPartyGetInviteeCount(lua_State* L); static int luaPartyAddInvite(lua_State* L); static int luaPartyRemoveInvite(lua_State* L); static int luaPartyAddMember(lua_State* L); static int luaPartyRemoveMember(lua_State* L); static int luaPartyIsSharedExperienceActive(lua_State* L); static int luaPartyIsSharedExperienceEnabled(lua_State* L); static int luaPartyShareExperience(lua_State* L); static int luaPartySetSharedExperience(lua_State* L); // lua_State* m_luaState; std::string m_lastLuaError; std::string m_interfaceName; int32_t m_eventTableRef; static ScriptEnvironment m_scriptEnv[16]; static int32_t m_scriptEnvIndex; int32_t m_runningEventId; std::string m_loadingFile; //script file cache std::map<int32_t, std::string> m_cacheFiles; }; class LuaEnvironment : public LuaScriptInterface { public: LuaEnvironment(); ~LuaEnvironment(); // non-copyable LuaEnvironment(const LuaEnvironment&) = delete; LuaEnvironment& operator=(const LuaEnvironment&) = delete; bool initState(); bool reInitState(); bool closeState(); LuaScriptInterface* getTestInterface(); Combat* getCombatObject(uint32_t id) const; Combat* createCombatObject(LuaScriptInterface* interface); void clearCombatObjects(LuaScriptInterface* interface); AreaCombat* getAreaObject(uint32_t id) const; uint32_t createAreaObject(LuaScriptInterface* interface); void clearAreaObjects(LuaScriptInterface* interface); private: void executeTimerEvent(uint32_t eventIndex); // std::unordered_map<uint32_t, LuaTimerEventDesc> m_timerEvents; std::unordered_map<uint32_t, Combat*> m_combatMap; std::unordered_map<uint32_t, AreaCombat*> m_areaMap; std::unordered_map<LuaScriptInterface*, std::vector<uint32_t>> m_combatIdMap; std::unordered_map<LuaScriptInterface*, std::vector<uint32_t>> m_areaIdMap; LuaScriptInterface* m_testInterface; uint32_t m_lastEventTimerId; uint32_t m_lastCombatId; uint32_t m_lastAreaId; // friend class LuaScriptInterface; friend class CombatSpell; }; #endif
[ "dean.vervaeck@outlook.com" ]
dean.vervaeck@outlook.com
fdc049786ec8ed00f6516bb54ff45beb3ecac35a
d2490ebcb141b77224e43d5438b6700f501aa281
/CodeForces/Educational Codeforces Round 100/ques1.cpp
17644bb89724fbb2254ed73548404fb132610209
[]
no_license
swimmingturtle165/Coding
de51aa87dce71eb68eaea3c695b69f10ac9f514c
257aedc3eb40eef2a0ab4a7c31432e3e8f77a8da
refs/heads/main
2023-08-15T06:00:50.950875
2021-10-10T17:44:56
2021-10-10T17:44:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,910
cpp
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef unsigned long long int ull; typedef long long int ll; typedef long double ld; typedef pair<ll,ll> pll; #define FOR(i,a,b) for(ll i=a;i<b;i++) #define FORE(i,a,b) for(int i=a;i<=b;i++) #define FORD(i,b,a) for(int i=b;i>a;i--) #define FORDE(i,b,a) for(ll i=b;i>=a;i--) #define debug(x) cout<< '>'<<#x<<" : "<<x<<"\n"; #define debug2(x,y) cout<< '>'<<#x<<" : "<<x<<"\n"; cout<< '>'<<#y<<" : "<<y<<"\n"; #define debug3(x,y,z) cout<< '>'<<#x<<" : "<<x<<"\n"; cout<< '>'<<#y<<" : "<<y<<"\n";cout<< '>'<<#z<<" : "<<z<<"\n"; #define umap unordered_map #define uset unordered_set #define lb lower_bound #define ub upper_bound #define mp make_pair #define in insert #define s second #define f first #define nn cout<<"\n" #define pb push_back #define testcase int t;cin>>t;while(t--) #define gcd(a,b) __gcd(a,b) #define maxv INT_MAX #define minv INT_MIN #define MOD 1000000007 #define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0); #define here cout<<"I'm here\n"; #define flush fflush(stdout); #define endl '\n' #define ordered_set_single tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> typedef tree< pair<ll, ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_pair; ll power(ll x, ll y, ll p) { ll res = 1; // Initialize result x = x % p; // Update x if it is more than or // equal to p while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res*x) % p; // y must be even now y = y>>1; // y = y/2 x = (x*x) % p; } return res; } ll modInverse(ll n, ll p) { return power(n, p-2, p); } // ll factorialNumInverse[300000 + 1]; // // array to precompute inverse of 1! to N! // ll naturalNumInverse[300000 + 1]; // // array to store factorial of first N numbers // ll fact[300000 + 1]; // // Function to precompute inverse of numbers // void InverseofNumber(ll p=MOD) // { // naturalNumInverse[0] = naturalNumInverse[1] = 1; // for (int i = 2; i <= 300000; i++) // naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; // } // // Function to precompute inverse of factorials // void InverseofFactorial(ll p=MOD) // { // factorialNumInverse[0] = factorialNumInverse[1] = 1; // // precompute inverse of natural numbers // for (int i = 2; i <= 300000; i++) // factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; // } // // Function to calculate factorial of 1 to N // void factorial(ll p=MOD) // { // fact[0] = 1; // // precompute factorials // for (int i = 1; i <= 300000; i++) { // fact[i] = (fact[i - 1] * i) % p; // } // } // // Function to return nCr % p in O(1) time // ll Binomial(ll N, ll R, ll p=MOD) // { // // n C r = n!*inverse(r!)*inverse((n-r)!) // ll ans = ((fact[N] * factorialNumInverse[R]) // % p * factorialNumInverse[N - R]) // % p; // return ans; // } struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; ll ntopowermandMod(ll n,ll m,ll mod_v) { if(m==0) { return 1; } if(m==1) { return n; } else { ll val=ntopowermandMod(n,m/2,mod_v); val=val%mod_v; val=val*val; val=val%mod_v; if(m%2==1) { val=val*n; val=val%mod_v; } return val; } } ll ntopowerm(ll n,ll m) { if(m==0) { return 1; } if(m==1) { return n; } else { ll val=ntopowerm(n,m/2); val=val*val; if(m%2==1) { val=val*n; } return val; } } vector<int> pi; void prefix_function(string s) { int n = (int)s.length(); for (int i = 1; i < n; i++) { int j = pi[i-1]; while (j > 0 && s[i] != s[j]) j = pi[j-1]; if (s[i] == s[j]) j++; pi[i] = j; } } template<class T> void dispvector(vector<T> v){for(int i=0;i<v.size();i++) cout<<v[i]<<" "; nn;} template<class T> void disparray(T *v, int n){for(int i=0;i<n;i++) cout<<v[i]<<" "; nn;} template<class T> int sizeofarr(T *v){return sizeof(v)/sizeof(T);} void initialize( vector<ll>&Arr,vector<ll>&size, int N) { for(int i = 0;i<N;i++) { Arr[ i ] = i; size[ i ] = 1; } } // O(log*N) ==> recursive log log log log .....(log N) // finding root of an element. // modified root function. int root (vector<ll>&Arr ,int i) { if(i<0 || i>=Arr.size()) return -2; if(Arr[ i ] != i) //chase parent of current element until it reaches root. { Arr[ i ] = root(Arr, Arr[ i ] ) ; //path compression } return Arr[i]; } void weighted_union(vector<ll>&Arr,vector<ll>&size,int A,int B) { int root_A = root(Arr,A); int root_B = root(Arr,B); if(root_A==root_B) return; if(size[root_A] < size[root_B ]) { Arr[ root_A ] = Arr[root_B]; size[root_B] += size[root_A]; } else { Arr[ root_B ] = Arr[root_A]; size[root_A] += size[root_B]; // size[root_B]=size[root_A]; } } bool find(vector<ll>&Arr,int A,int B) { if( root(Arr,A)==root(Arr,B) ) //if A and B have same root,means they are connected. return true; else return false; } signed main(int argc, char** argv) { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif FastIO; long t=1; cin>>t; while(t--) { ll a,b,c; cin>>a>>b>>c; if((a+b+c)%9==0 && min(a,min(b,c))>=((a+b+c)/9)) { cout<<"YES"<<endl; } else { cout<<"NO"<<endl; } } return 0; }
[ "sachitjaggi.1562@gmail.com" ]
sachitjaggi.1562@gmail.com
f7d0178942c16ab6a873e85433a5835d4e5a6b39
a181a8e4c629a5337e19a6cd1a59007464935bbb
/src/shared/wx_report/reportgen/src/wxMaskController.cpp
def70748e62e0fc593686721c3cd0cc37fe167ee
[]
no_license
ddpub/cafe
1dfde966cbee6acb1cd622370d4291946dfe41e1
e7ba88d1c9dcc1e449ebc6a2401c1f21192eac00
refs/heads/master
2021-10-27T21:56:56.684590
2011-10-02T18:31:19
2011-10-02T18:31:19
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
43,364
cpp
///////////////////////////////////////////////////////////////////////////// // Name: wxMaskController.cpp // Purpose: wxMaskController: masked edit control class modified to // work as a general purpose text mask handler // Author: Thomas Härtel ( later modified by Scott Fant ) // Modified by: // Created: 2002-11-14, modified on 2005-06-14 // RCS-ID: $Id: wxMaskController.cpp,v 1.1 2009/09/03 12:07:28 ola Exp $ // Copyright: (c) Thomas Härtel // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". #if defined(__WXGTK__) || defined(__WXMOTIF__) #include "wx/wx.h" #endif #include "wx/wxprec.h" #include "wxMaskController.h" IMPLEMENT_DYNAMIC_CLASS(wxFieldMaskData, wxObject) wxFieldMaskData::wxFieldMaskData() : m_eType(MaskDataTypeLITERAL), m_chValue(chNULL) { } wxFieldMaskData::~wxFieldMaskData() { } void wxFieldMaskData::operator=(const wxFieldMaskData& src) { m_eType = src.m_eType; m_chValue = src.m_chValue; } bool wxFieldMaskData::IsInputData() { bool bIsInputData=FALSE; switch(m_eType) { // These are the input types. case MaskDataTypeDIGIT: case MaskDataTypeALPHANUMERIC: case MaskDataTypeALPHABETIC: case MaskDataTypeALPHAETICUPPER: case MaskDataTypeALPHAETICLOWER: case MaskDataTypeCHARACTER: bIsInputData=TRUE; break; } return bIsInputData; } bool wxFieldMaskData::IsValidInput(wxChar chNewChar) { bool bIsValidInput=FALSE; switch(m_eType) { // These are the input types. case MaskDataTypeDIGIT: bIsValidInput=wxIsdigit(chNewChar) != 0; break; case MaskDataTypeALPHANUMERIC: bIsValidInput=wxIsalnum(chNewChar) != 0; break; case MaskDataTypeALPHABETIC: case MaskDataTypeALPHAETICUPPER: case MaskDataTypeALPHAETICLOWER: bIsValidInput=wxIsalpha(chNewChar) != 0; break; case MaskDataTypeCHARACTER: if((chNewChar >= 32) && (chNewChar <= 126)) bIsValidInput=TRUE; if((chNewChar >= 128) && (chNewChar <= 255)) bIsValidInput = TRUE; break; } return bIsValidInput; } wxChar wxFieldMaskData::PreProcessChar(wxChar chNewChar) { wxChar chProcessedChar=chNewChar; switch(m_eType) { case MaskDataTypeALPHAETICUPPER: chProcessedChar=(wxChar) wxToupper(chNewChar); break; case MaskDataTypeALPHAETICLOWER: chProcessedChar=(wxChar) wxTolower(chNewChar); break; } return chProcessedChar; } wxMaskController::wxMaskController(const wxString& mask, const wxString &value) : m_bInsertMode(TRUE), m_chPromptSymbol(chSPACE), m_chIntlDecimal(chPERIOD), m_chIntlThousands(chCOMMA), m_chIntlTime(chCOLON), m_chIntlDate(chSLASH), m_bAutoTab(FALSE), m_bBackwardLocationRight(TRUE), m_dtMinDateTime(wxInvalidDateTime), m_dtDateTime(wxInvalidDateTime), m_dtMaxDateTime(wxInvalidDateTime), m_bNeedValidation(TRUE), m_bValidation(FALSE) { SetMask(wxString(mask)); SetValue( (wxString&)value ); if(m_listData.GetCount() != 0) Update(); } wxMaskController::wxMaskController() { } wxMaskController::~wxMaskController() { DeleteContents(); } void wxMaskController::DeleteContents() { if(m_listData.GetCount() == 0) return; m_listData.DeleteContents(TRUE); m_bNeedValidation = FALSE; m_bValidation = TRUE; } wxString wxMaskController::GetMask() { wxString csMask; wxFieldMaskData* pobjData=NULL; for(unsigned long pos = 0; pos < m_listData.GetCount();pos++) { pobjData= (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); switch(pobjData->m_eType) { case MaskDataTypeDECIMALSEPARATOR: csMask += chMaskPlaceholderDECIMALSEPARATOR; break; case MaskDataTypeTHOUSANDSSEPARATOR: csMask += chMaskPlaceholderTHOUSANDSSEPARATOR; break; case MaskDataTypeTIMESEPARATOR: csMask += chMaskPlaceholderTIMESEPARATOR; break; case MaskDataTypeDATESEPARATOR: csMask += chMaskPlaceholderDATESEPARATOR; break; case MaskDataTypeALPHANUMERIC: csMask += chMaskPlaceholderALPHANUMERIC; break; case MaskDataTypeALPHABETIC: csMask += chMaskPlaceholderALPHABETIC; break; case MaskDataTypeALPHAETICUPPER: csMask += chMaskPlaceholderALPHABETICUPPER; break; case MaskDataTypeALPHAETICLOWER: csMask += chMaskPlaceholderALPHABETICLOWER; break; case MaskDataTypeCHARACTER: csMask += chMaskPlaceholderCHARACTER; break; case MaskDataTypeDIGIT: switch(pobjData->m_eSubType) { case MaskDataSubTypeDATEDAY: csMask += chMaskPlaceholderDATEDAY; break; case MaskDataSubTypeDATEMONTH: csMask += chMaskPlaceholderDATEMONTH; break; case MaskDataSubTypeDATEYEAR: csMask += chMaskPlaceholderDATEYEAR; break; case MaskDataSubTypeTIMEHOUR: csMask += chMaskPlaceholderTIMEHOUR; break; case MaskDataSubTypeTIMEMINUTE: csMask += chMaskPlaceholderTIMEMINUTE; break; case MaskDataSubTypeTIMESECOND: csMask += chMaskPlaceholderTIMESECOND; break; default: csMask += chMaskPlaceholderDIGIT; break; } break; case MaskDataTypeLITERALESCAPE: // Need to add the escape to things that were escaped. csMask += chMaskPlaceholderLITERALESCAPE; csMask += pobjData->m_chValue; break; default: // Literals and everything else is kept the same. csMask += pobjData->m_chValue; break; } } return csMask; } void wxMaskController::SetMask(wxString mask) { if(mask.IsEmpty()) { mask = wxT(""); } DeleteContents(); wxFieldMaskData* pobjData = NULL; for(unsigned int i = 0;i < mask.Length(); i++) { wxChar chNew = mask[i]; pobjData = new wxFieldMaskData(); if(pobjData) { m_listData.Append(pobjData); pobjData->m_eSubType = MaskDataSubTypeNONE; switch(chNew) { case chMaskPlaceholderDECIMALSEPARATOR: pobjData->m_eType = MaskDataTypeDECIMALSEPARATOR; pobjData->m_chValue = m_chIntlDecimal; break; case chMaskPlaceholderTHOUSANDSSEPARATOR: pobjData->m_eType = MaskDataTypeTHOUSANDSSEPARATOR; pobjData->m_chValue = m_chIntlThousands; break; case chMaskPlaceholderTIMESEPARATOR: pobjData->m_eType = MaskDataTypeTIMESEPARATOR; pobjData->m_chValue = m_chIntlTime; break; case chMaskPlaceholderDATESEPARATOR: pobjData->m_eType = MaskDataTypeDATESEPARATOR; pobjData->m_chValue = m_chIntlDate; break; case chMaskPlaceholderDIGIT: pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderALPHANUMERIC: pobjData->m_eType = MaskDataTypeALPHANUMERIC; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderALPHABETIC: pobjData->m_eType = MaskDataTypeALPHABETIC; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderALPHABETICUPPER: pobjData->m_eType = MaskDataTypeALPHAETICUPPER; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderALPHABETICLOWER: pobjData->m_eType = MaskDataTypeALPHAETICLOWER; pobjData->m_chValue = m_chPromptSymbol; break; case chMaskPlaceholderCHARACTER: pobjData->m_eType = MaskDataTypeCHARACTER; pobjData->m_chValue = m_chPromptSymbol; break; default: if(chNew == chMaskPlaceholderLITERALESCAPE) { // It is the next character that is inserted. chNew = mask[++i]; if(chNew) { pobjData->m_eType = MaskDataTypeLITERALESCAPE; pobjData->m_chValue = chNew; break; } } else if(chNew == chMaskPlaceholderDATEDAY) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderDATEDAY || chBefore == chMaskPlaceholderDATEDAY) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeDATEDAY; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderDATEMONTH) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderDATEMONTH || chBefore == chMaskPlaceholderDATEMONTH) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeDATEMONTH; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderDATEYEAR) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if(chNext == chMaskPlaceholderDATEYEAR || chBefore == chMaskPlaceholderDATEYEAR) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeDATEYEAR; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderTIMEHOUR) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderTIMEHOUR || chBefore == chMaskPlaceholderTIMEHOUR) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeTIMEHOUR; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderTIMEMINUTE) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderTIMEMINUTE || chBefore == chMaskPlaceholderTIMEMINUTE) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeTIMEMINUTE; pobjData->m_chValue = m_chPromptSymbol; break; } } else if(chNew == chMaskPlaceholderTIMESECOND) { // It is the next character that is inserted. wxChar chNext = (i < (mask.Length()-1) ? mask[i+1] : wxT('\0')); wxChar chBefore = (i > 0 ? mask[i-1] : wxT('\0')); if((chNext == chMaskPlaceholderTIMESECOND || chBefore == chMaskPlaceholderTIMESECOND) && chBefore != chNext) { pobjData->m_eType = MaskDataTypeDIGIT; pobjData->m_eSubType = MaskDataSubTypeTIMESECOND; pobjData->m_chValue = m_chPromptSymbol; break; } } // Everything else is just a literal. pobjData->m_eType = MaskDataTypeLITERAL; pobjData->m_chValue = chNew; break; } } } Update(); } wxString wxMaskController::GetInputData() { wxString csInputData; if(m_listData.GetCount() == 0) { csInputData = GetTextValue(); return csInputData; } wxFieldMaskData* pobjData=NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData= (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); // Ignore everything that is not data. if(pobjData->IsInputData()) csInputData += pobjData->m_chValue; } return csInputData; } wxString wxMaskController::GetInputData(wxString& value) { wxString csInputData = value; unsigned int nSymbolCount = (int)csInputData.Length(); wxFieldMaskData* pobjData = NULL; wxString sToExclude; int nStartPos = -1; int nEndPos = -1; unsigned int nIndex = 0; int nRemovedCount = 0; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(!pobjData->IsInputData()) { if(nStartPos == -1) { nStartPos = nIndex; sToExclude.Empty(); } sToExclude+=pobjData->m_chValue; } else { if(nStartPos != -1) { nEndPos = nIndex-1; if(csInputData.Mid(nStartPos-nRemovedCount, nEndPos-nStartPos+1) == sToExclude) { csInputData=csInputData.Left(nStartPos-nRemovedCount) + csInputData.Mid(nEndPos-nRemovedCount+1); nRemovedCount+=nEndPos-nStartPos+1; } nStartPos = -1; } } nIndex++; if(nIndex >= nSymbolCount) break; } return csInputData; } bool wxMaskController::SetInputData(wxString value, int nBeginPos/*=0*/, bool bAllowPrompt/*=TRUE*/) { wxString csFullInput; m_bNeedValidation = TRUE; m_bValidation = FALSE; // Start with existing data and append the new data. csFullInput = GetInputData(); csFullInput = csFullInput.Left(nBeginPos); if(bAllowPrompt) csFullInput += value; else { // If the prompt symbol is not valid, then // add the data one-by-one ignoring any prompt symbols. for(unsigned int i = 0;i < value.Length();i++) { if(value[i] != m_chPromptSymbol) csFullInput += value[i]; } } bool bCompleteSuccess=TRUE; wxString pszReplaceData=csFullInput; wxFieldMaskData* pobjData=NULL; unsigned int posReplaceData=0; for(unsigned long pos = 0; pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); // Ignore everything that is not data. if(pobjData->IsInputData()) { // If we run out of replacement data, then use the prompt symbol. // Make sure we iterate through the entire list so that the // prompt symbol is applied to any empty areas. if(posReplaceData < pszReplaceData.Length()) { // This inner while loop is so that we can re-apply input data // after an error. This will allow us to skip over invalid // input data and try the next character. while(posReplaceData< pszReplaceData.Length()) { wxChar chReplace = pszReplaceData[posReplaceData++]; // Make sure to follow the input validation. // The prompt symbol is always valid at this level. // This allows the user to erase a string by overtyping a space. // On error, just skip the character being inserted. // This will allow the DeleteRange() function to have the remaining // characters validated. if((chReplace == m_chPromptSymbol) || pobjData->IsValidInput(chReplace)) { pobjData->m_chValue = pobjData->PreProcessChar(chReplace); break; } else bCompleteSuccess = FALSE; } } else pobjData->m_chValue = m_chPromptSymbol; } } Update(); return bCompleteSuccess; } wxChar wxMaskController::GetPromptSymbol() { return m_chPromptSymbol; } void wxMaskController::SetPromptSymbol(wxChar chNewPromptSymbol) { // The prompt symbol must be a valid edit box symbol. if(wxIsprint((int) chNewPromptSymbol)) { // Just for the heck of it, if the prompt symbol changes, // go through and replace the existing prompts with the new prompt. wxFieldMaskData* pobjData = NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->IsInputData()) { if(pobjData->m_chValue == m_chPromptSymbol) pobjData->m_chValue = chNewPromptSymbol; } } m_chPromptSymbol = chNewPromptSymbol; } // Don't update the insertion point if just setting the prompt symbol. Update(-1); } wxChar wxMaskController::GetDecimalSeperator() { return m_chIntlDecimal; } void wxMaskController::SetDecimalSeperator(wxChar chNewDecimalSeperator) { // The decimal seperator must be a valid edit box symbol. if(wxIsprint((int) chNewDecimalSeperator)) { // Just for the heck of it, if the decimal symbol changes, // go through and replace the existing symbols with the new symbol. wxFieldMaskData* pobjData = NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->m_eType == MaskDataTypeDECIMALSEPARATOR) pobjData->m_chValue = chNewDecimalSeperator; } m_chIntlDecimal = chNewDecimalSeperator; } // Don't update the insertion point if just setting the decimal symbol. Update(-1); } wxChar wxMaskController::GetThousandsSeperator() { return m_chIntlThousands; } void wxMaskController::SetThousandsSeperator(wxChar chNewThousandsSeperator) { // The thousands seperator must be a valid edit box symbol. if(wxIsprint((int) chNewThousandsSeperator)) { // Just for the heck of it, if the thousands symbol changes, // go through and replace the existing symbols with the new symbol. wxFieldMaskData* pobjData = NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->m_eType == MaskDataTypeTHOUSANDSSEPARATOR) pobjData->m_chValue = chNewThousandsSeperator; } m_chIntlThousands = chNewThousandsSeperator; } // Don't update the insertion point if just setting the thousands symbol. Update(-1); } wxChar wxMaskController::GetTimeSeperator() { return m_chIntlTime; } void wxMaskController::SetTimeSeperator(wxChar chNewTimeSeperator) { // The time seperator must be a valid edit box symbol. if(wxIsprint((int) chNewTimeSeperator)) { // Just for the heck of it, if the time symbol changes, // go through and replace the existing symbols with the new symbol. wxFieldMaskData* pobjData = NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->m_eType == MaskDataTypeTIMESEPARATOR) pobjData->m_chValue = chNewTimeSeperator; } m_chIntlTime = chNewTimeSeperator; } // Don't update the insertion point if just setting the time symbol. Update(-1); } wxChar wxMaskController::GetDateSeperator() { return m_chIntlDate; } void wxMaskController::SetDateSeperator(wxChar chNewDateSeperator) { // The time seperator must be a valid edit box symbol. if(wxIsprint((int) chNewDateSeperator)) { // Just for the heck of it, if the date symbol changes, // go through and replace the existing symbols with the new symbol. wxFieldMaskData* pobjData=NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->m_eType == MaskDataTypeDATESEPARATOR) pobjData->m_chValue = chNewDateSeperator; } m_chIntlDate = chNewDateSeperator; } // Don't update the insertion point if just setting the date symbol. Update(-1); } void wxMaskController::EmptyData(bool bOnlyInput/*=FALSE*/) { if(m_listData.GetCount()==0) { DeleteContents(); return; } if(bOnlyInput) { // If emptying only the data, the iterate through the list // of data and replace input data with the prompt symbol. wxFieldMaskData* pobjData = NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->IsInputData()) pobjData->m_chValue=m_chPromptSymbol; } } else DeleteContents(); Update(); } bool wxMaskController::IsInputEmpty() { if(m_listData.GetCount() == 0) { wxString csInputData; csInputData = GetTextValue(); return csInputData.IsEmpty(); } wxFieldMaskData* pobjData=NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if (pobjData->IsInputData() && pobjData->m_chValue!=m_chPromptSymbol) return FALSE; } return TRUE; } bool wxMaskController::GetInsertMode() { return m_bInsertMode; } void wxMaskController::SetInsertMode(bool bInsertMode) { m_bInsertMode=bInsertMode; } bool wxMaskController::GetAutoTab() { return m_bAutoTab; } void wxMaskController::SetAutoTab(bool bAutoTab) { m_bAutoTab=bAutoTab; } void wxMaskController::SetBackwardLocationRight(bool bRight) { m_bBackwardLocationRight = bRight; } bool wxMaskController::GetBackwardLocationRight() { return m_bBackwardLocationRight; } wxString wxMaskController::ShowMask() { wxString csShow; wxFieldMaskData* pobjData=NULL; for(unsigned long pos = 0;pos < m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); // There is no need to do any fancy string building because // all validation is done when characters are inserted into the list. // Literals and placeholders are converted properly at that time // so all we have to do here is get the value. if(pobjData->m_chValue != chNULL) csShow += pobjData->m_chValue; } return csShow; } bool wxMaskController::IsInputData(int nPosition) { if(m_listData.GetCount() == 0) { return TRUE; } // We frequently need to know if a position refers to // input data or to a literal. bool bIsInputData=FALSE; if(nPosition >= 0 && nPosition < (int) m_listData.GetCount()) { wxFieldMaskData* pobjData = (wxFieldMaskData*) (m_listData.Item(nPosition))->GetData(); if(pobjData) { bIsInputData = pobjData->IsInputData(); } } return bIsInputData; } int wxMaskController::DeleteRange(int nSelectionStart, int nSelectionEnd) { // In order to delete properly, we must count the number of // input characters that are selected and only delete that many. // This is because the selection can include literals. int nCharIndex =0; int nDeleteCount=0; wxString csInputData; wxFieldMaskData* pobjData = NULL; m_bNeedValidation = TRUE; m_bValidation = FALSE; for(unsigned long pos = 0;pos < m_listData.GetCount(); pos++,nCharIndex++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); // Ignore everything that is not data. // This is just like we do in GetInputData except that we // will ignore the input data within the selection range. if(pobjData->IsInputData()) { if((nCharIndex < nSelectionStart) || (nCharIndex >= nSelectionEnd)) { // The SetInputData() function will take care of validating // the shifted characters. csInputData += pobjData->m_chValue; } else nDeleteCount++; } } // Now apply the filtered data stream. SetInputData(csInputData); // return the deleted count so that an error can be generated // if none were deleted. return nDeleteCount; } int wxMaskController::InsertAt(int nSelectionStart, wxChar chNewChar) { // Although we could have some complex, yet efficient, routine // that would error if inserting pushed an existing character // into an invalid region. Instead, just save the current // state and restore it on error. wxString csPreviousInput=GetInputData(); int nCharIndex = 0; int nInsertionPoint = -1; wxString csInputData; wxFieldMaskData* pobjData = NULL; for(unsigned long pos = 0;pos < m_listData.GetCount(); pos++,nCharIndex++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); // Ignore everything that is not data. // This is just like we do in GetInputData except that we // will ignore the input data within the selection range. if(pobjData->IsInputData()) { // Wait until a valid insertion point and // only make sure to insert once. if((nInsertionPoint < 0) && (nCharIndex >= nSelectionStart)) { csInputData += chNewChar; nInsertionPoint=nCharIndex; } csInputData += pobjData->m_chValue; } } // Now apply the filtered data stream and check if it was successful. if(!SetInputData(csInputData)) { // If not successful, then restore the previous input and return -1. SetInputData(csPreviousInput); return -1; } return nInsertionPoint; } int wxMaskController::SetAt(int nSelectionStart, wxChar chNewChar) { if(nSelectionStart >= 0) { m_bNeedValidation = TRUE; m_bValidation = FALSE; wxFieldMaskData* pobjData=(wxFieldMaskData*) (m_listData.Item(nSelectionStart))->GetData(); if(pobjData) { if(pobjData->IsInputData()) { if((chNewChar == m_chPromptSymbol) || pobjData->IsValidInput(chNewChar)) pobjData->m_chValue=pobjData->PreProcessChar(chNewChar); else return -1; // Input value is invalid or not allowed. } } } return nSelectionStart; } int wxMaskController::GetNextInputLocation(int nSelectionStart) { // One of the functions of this edit control is that it skips over literals. // We need a function to help skip to the next position. int nNextInputLocation=nSelectionStart; if(nNextInputLocation < 0) nNextInputLocation = 0; wxFieldMaskData* pobjData = NULL; while(nNextInputLocation < (int) m_listData.GetCount()) { pobjData = (wxFieldMaskData *) (m_listData.Item(nNextInputLocation))->GetData(); if(pobjData->IsInputData()) break; nNextInputLocation++; } return nNextInputLocation; } int wxMaskController::GetPreviousInputLocation(int nSelectionStart) { // One of the functions of this edit control is that it skips over literals. // We need a function to help skip to the next position. int nNextInputLocation=nSelectionStart; if(nNextInputLocation < 0) nNextInputLocation = 0; // Need to determine if we moved to a previous location. // There will need to be some correction. int nInitialInputLocation=nNextInputLocation; wxFieldMaskData* pobjData = NULL; for(wxNode* node = m_listData.Item(nNextInputLocation);node;nNextInputLocation--) { pobjData = (wxFieldMaskData *) node->GetData(); if(pobjData->IsInputData()) { if(nInitialInputLocation != nNextInputLocation) { // If we find a valid previous location, then move to the right of it. // This backup, then move forward is typical when seeking backward. if(m_bBackwardLocationRight) nNextInputLocation++; } break; } node = node->GetPrevious(); } // If there is no input data to the left of the selection, // then seek forward to the next location. if(nNextInputLocation < 0) return GetNextInputLocation(nSelectionStart); return nNextInputLocation; } int wxMaskController::GetEmptyInputLocation(int nSelectionStart) { int nEmptyInputLocation=nSelectionStart; if(nEmptyInputLocation < 0) nEmptyInputLocation = 0; wxFieldMaskData* pobjData=NULL; for(unsigned long pos = nEmptyInputLocation;;pos++,nEmptyInputLocation++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->IsInputData()) { if(pobjData->m_chValue == m_chPromptSymbol) break; } } return nEmptyInputLocation; } void wxMaskController::Update(int WXUNUSED(nSelectionStart)) { // Update the edit control if it exists. wxString sText = ShowMask(); SetTextValue(sText); } void wxMaskController::ValidationError() { wxBell(); } void wxMaskController::Clear() { if(m_listData.GetCount() == 0) SetTextValue(_("")); else { long nSelectionStart = 0; // Now we update with our standard mask. Update(nSelectionStart); } } bool wxMaskController::Validate() { int day = 0, month = 0, year = 0, hour = 0, minute = 0, second = 0; bool bDay = FALSE, bMonth = FALSE, bYear = FALSE, bHour = FALSE, bMinute = FALSE, bSecond = FALSE; bool DateValid, TimeValid; int year_len = 0; unsigned long used = 0; long StartPosDay = -1, EndPosDay = -1, StartPosMonth = -1, EndPosMonth = -1, StartPosYear = -1, EndPosYear = -1; long StartPosHour = -1, EndPosHour = -1, StartPosMinute = -1, EndPosMinute = -1, StartPosSecond = -1, EndPosSecond = -1; if(!m_bNeedValidation) return m_bValidation; wxFieldMaskData* pobjData=NULL; m_dtDateTime = wxInvalidDateTime; for(unsigned long pos = 0; pos < m_listData.GetCount();pos++) { pobjData= (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->m_eType == MaskDataTypeDIGIT) { if(pobjData->m_chValue != m_chPromptSymbol) used++; wxFieldMaskData* pobjDataNext = NULL; switch(pobjData->m_eSubType) { case MaskDataSubTypeDATEDAY: bDay = TRUE; if(StartPosDay == -1) { StartPosDay = pos; EndPosDay = pos; } EndPosDay++; pobjDataNext = (wxFieldMaskData *) (pos < (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjData->m_chValue != m_chPromptSymbol) { day = (day * 10) + (pobjData->m_chValue - 48); if(pobjDataNext != NULL) { if(pobjDataNext->m_eType == MaskDataTypeDIGIT && pobjDataNext->m_eSubType == MaskDataSubTypeDATEDAY) { day = (day * 10) + (pobjDataNext->m_chValue != m_chPromptSymbol ? (pobjDataNext->m_chValue - 48) : 0); EndPosDay++; pos++; } } } break; case MaskDataSubTypeDATEMONTH: bMonth = TRUE; if(StartPosMonth == -1) { StartPosMonth = pos; EndPosMonth = pos; } EndPosMonth++; pobjDataNext = (wxFieldMaskData *) (pos < (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjData->m_chValue != m_chPromptSymbol) { month = (month * 10) + (pobjData->m_chValue - 48); if(pobjDataNext != NULL) { if(pobjDataNext->m_eType == MaskDataTypeDIGIT && pobjDataNext->m_eSubType == MaskDataSubTypeDATEMONTH) { month = (month * 10) + (pobjDataNext->m_chValue != m_chPromptSymbol ? (pobjDataNext->m_chValue - 48) : 0); EndPosMonth++; pos++; } } } break; case MaskDataSubTypeDATEYEAR: bYear = TRUE; if(StartPosYear == -1) { StartPosYear = pos; EndPosYear = pos; } EndPosYear++; if(pobjData->m_chValue != m_chPromptSymbol) { year = (year * 10) + (pobjData->m_chValue - 48); year_len++; } break; case MaskDataSubTypeTIMEHOUR: bHour = TRUE; if(StartPosHour == -1) { StartPosHour = pos; EndPosHour = pos; } EndPosHour++; pobjDataNext = (wxFieldMaskData *) (pos < (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjData->m_chValue != m_chPromptSymbol) { hour = (hour * 10) + (pobjData->m_chValue - 48); if(pobjDataNext != NULL) { if(pobjDataNext->m_eType == MaskDataTypeDIGIT && pobjDataNext->m_eSubType == MaskDataSubTypeTIMEHOUR) { hour = (hour * 10) + (pobjDataNext->m_chValue != m_chPromptSymbol ? (pobjDataNext->m_chValue - 48) : 0); EndPosHour++; pos++; } } } break; case MaskDataSubTypeTIMEMINUTE: bMinute = TRUE; if(StartPosMinute == -1) { StartPosMinute = pos; EndPosMinute = pos; } EndPosMinute++; pobjDataNext = (wxFieldMaskData *) (pos < (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjData->m_chValue != m_chPromptSymbol) { minute = (minute * 10) + (pobjData->m_chValue - 48); if(pobjDataNext != NULL) { if(pobjDataNext->m_eType == MaskDataTypeDIGIT && pobjDataNext->m_eSubType == MaskDataSubTypeTIMEMINUTE) { minute = (minute * 10) + (pobjDataNext->m_chValue != m_chPromptSymbol ? (pobjDataNext->m_chValue - 48) : 0); EndPosMinute++; pos++; } } } break; case MaskDataSubTypeTIMESECOND: bSecond = TRUE; if(StartPosSecond == -1) { StartPosSecond = pos; EndPosSecond = pos; } EndPosSecond++; pobjDataNext = (wxFieldMaskData *) (pos < (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjData->m_chValue != m_chPromptSymbol) { second = (second * 10) + (pobjData->m_chValue - 48); if(pobjDataNext != NULL) { if(pobjDataNext->m_eType == MaskDataTypeDIGIT && pobjDataNext->m_eSubType == MaskDataSubTypeTIMESECOND) { second = (second * 10) + (pobjDataNext->m_chValue != m_chPromptSymbol ? (pobjDataNext->m_chValue - 48) : 0); EndPosSecond++; pos++; } } } break; } } } m_bNeedValidation = FALSE; if(used == 0) return (m_bValidation = TRUE); bool minValid = m_dtMinDateTime.IsValid(); bool maxValid = m_dtMaxDateTime.IsValid(); DateValid = TRUE; if(bDay || bMonth || bYear) { long pos; wxDateTime minDate = m_dtMinDateTime; wxDateTime maxDate = m_dtMaxDateTime; wxDateTime Date = wxDateTime(1, wxDateTime::Jan, (wxDateTime::Now()).GetYear(), 0, 0, 0, 0); if((bDay && day == 0) || (bMonth && month == 0)) DateValid = FALSE; else if((bDay && day > 31) || (bMonth && month > 12)) DateValid = FALSE; if(DateValid) { if(bYear && year_len < 3 && year < 100) { if(year_len == 0) { year = (wxDateTime::Now()).GetYear(); year_len = 1; } else year += ((wxDateTime::Now()).GetYear() / 1000) * 1000; } if(bYear) { if(StartPosYear != -1) { wxString Year_Str = wxString::Format(_("%04d"), year); for(pos = StartPosYear; pos < EndPosYear;pos++) SetAt(pos, Year_Str.GetChar(Year_Str.Length() + pos - EndPosYear)); } Date.SetYear(year); if(minValid) { minDate.SetMonth(wxDateTime::Jan); minDate.SetDay(1); } if(maxValid) { maxDate.SetMonth(wxDateTime::Dec); maxDate.SetDay(31); } } else { if(minValid) minDate.SetYear(Date.GetYear()); if(maxValid) maxDate.SetYear(Date.GetYear()); } if(bMonth) { if(StartPosMonth != -1) { wxString Month_Str = wxString::Format(_("%02d"), month); for(pos = StartPosMonth; pos < EndPosMonth;pos++) SetAt(pos, Month_Str.GetChar(pos - StartPosMonth)); } Date.SetMonth(wxDateTime::Month(month-1)); if(minValid) minDate.SetMonth(m_dtMinDateTime.GetMonth()); if(maxValid) { maxDate.SetDay(1); maxDate.SetMonth(m_dtMaxDateTime.GetMonth()); maxDate.SetDay(m_dtMaxDateTime.GetNumberOfDays(m_dtMaxDateTime.GetMonth(), m_dtMaxDateTime.GetYear())); } } else { if(minValid) minDate.SetMonth(m_dtMinDateTime.GetMonth()); if(maxValid) maxDate.SetMonth(m_dtMaxDateTime.GetMonth()); } if(bDay) { if(StartPosDay != -1) { wxString Day_Str = wxString::Format(_("%02d"), day); for(pos = StartPosDay; pos < EndPosDay;pos++) SetAt(pos, Day_Str.GetChar(pos - StartPosDay)); } if(day > Date.GetNumberOfDays(Date.GetMonth(), Date.GetYear())) DateValid = FALSE; if(DateValid) { Date.SetDay(day); if(minValid) minDate.SetDay(m_dtMinDateTime.GetDay()); if(maxValid) maxDate.SetDay(m_dtMaxDateTime.GetDay()); } } else { if(minValid) minDate.SetDay(1); if(maxValid) maxDate.SetDay(m_dtMaxDateTime.GetNumberOfDays(m_dtMaxDateTime.GetMonth(), m_dtMaxDateTime.GetYear())); } if(DateValid) { if(!Date.IsValid()) DateValid = FALSE; if(minValid && m_bValidation) { if(Date.IsEarlierThan(minDate)) DateValid = FALSE; } if(maxValid && m_bValidation) { if(Date.IsLaterThan(maxDate)) DateValid = FALSE; } m_dtDateTime = Date; } } } TimeValid = TRUE; if(bHour || bMinute || bSecond) { long pos; wxDateTime minDate = m_dtMinDateTime; wxDateTime maxDate = m_dtMaxDateTime; wxDateTime Date; if(m_dtDateTime.IsValid()) Date = m_dtDateTime; else Date = wxDateTime(1, wxDateTime::Jan, (wxDateTime::Now()).GetYear(), 0, 0, 0, 0); if((bHour && hour > 23) || (bMinute && minute > 59) || (bSecond && second > 59)) TimeValid = FALSE; if(TimeValid) { if(bHour) { if(StartPosHour != -1) { wxString Hour_Str = wxString::Format(_("%02d"), hour); for(pos = StartPosHour; pos < EndPosHour;pos++) SetAt(pos, Hour_Str.GetChar(pos - StartPosHour)); } Date.SetHour(hour); } else { if(minValid) minDate.SetHour(0); if(maxValid) maxDate.SetHour(1); } if(bMinute) { if(StartPosMinute != -1) { wxString Minute_Str = wxString::Format(_("%02d"), minute); for(pos = StartPosMinute; pos < EndPosMinute;pos++) SetAt(pos, Minute_Str.GetChar(pos - StartPosMinute)); } Date.SetMinute(minute); } else { if(minValid) minDate.SetMinute(0); if(maxValid) maxDate.SetMinute(59); } if(bSecond) { if(StartPosSecond != -1) { wxString Second_Str = wxString::Format(_("%02d"), second); for(pos = StartPosSecond; pos < EndPosSecond;pos++) SetAt(pos, Second_Str.GetChar(pos - StartPosSecond)); } Date.SetSecond(second); } else { if(minValid) minDate.SetSecond(0); if(maxValid) maxDate.SetSecond(59); } if(!Date.IsValid()) TimeValid = FALSE; if(TimeValid) { if(minValid) { if(Date.IsEarlierThan(minDate)) TimeValid = FALSE; } if(maxValid) { if(Date.IsLaterThan(maxDate)) TimeValid = FALSE; } m_dtDateTime.Set(hour, minute, second); } } } Update(-1); m_bValidation = DateValid & TimeValid; m_bNeedValidation = FALSE; return m_bValidation; } bool wxMaskController::IsValid(void) { if(m_bNeedValidation) Validate(); return m_bValidation; } bool wxMaskController::IsEmpty(void) { return IsInputEmpty(); } wxDateTime wxMaskController::GetMinDateTime(void) { return m_dtMinDateTime; } void wxMaskController::SetMinDateTime(wxDateTime& minDateTime) { m_dtMinDateTime = minDateTime; } wxDateTime wxMaskController::GetMaxDateTime(void) { return m_dtMaxDateTime; } void wxMaskController::SetMaxDateTime(wxDateTime& maxDateTime) { m_dtMaxDateTime = maxDateTime; } void wxMaskController::SetDateTimeRange(wxDateTime& minDateTime, wxDateTime& maxDateTime) { m_dtMinDateTime = minDateTime; m_dtMaxDateTime = maxDateTime; } void wxMaskController::SetValue(wxString& value) { if(m_listData.GetCount() == 0) SetTextValue(value); else SetInputData(GetInputData(value), 0, true); } void wxMaskController::SetDateTimeValue(wxDateTime& value) { wxFieldMaskData *pobjData = NULL, *pobjDataNext = NULL; wxString str_Value; long length; int year_len; if(m_listData.GetCount() == 0 && value.IsValid()) return; for(long pos = 0;pos < (long) m_listData.GetCount();pos++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->m_eType == MaskDataTypeDIGIT) { if(pobjData->m_eSubType == MaskDataSubTypeDATEDAY) { pobjDataNext = (wxFieldMaskData *) (pos < (long) (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjDataNext) { if(pobjData->m_eType == MaskDataTypeDIGIT && pobjData->m_eSubType == MaskDataSubTypeDATEDAY) str_Value = wxString::Format(_("%02d"), value.GetDay()); else str_Value = wxString::Format(_("%d"), value.GetDay() % 10); } } else if(pobjData->m_eSubType == MaskDataSubTypeDATEMONTH) { pobjDataNext = (wxFieldMaskData *) (pos < (long) (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjDataNext) { if(pobjData->m_eType == MaskDataTypeDIGIT && pobjData->m_eSubType == MaskDataSubTypeDATEMONTH) str_Value = wxString::Format(_("%02d"), value.GetMonth()); else str_Value = wxString::Format(_("%d"), value.GetMonth() % 10); } } else if(pobjData->m_eSubType == MaskDataSubTypeDATEYEAR) { year_len = 1; for(long i = pos; i < (long) m_listData.GetCount();i++) { pobjDataNext = (wxFieldMaskData *) (m_listData.Item(pos+1))->GetData(); if(pobjDataNext->m_eType == MaskDataTypeDIGIT && pobjDataNext->m_eSubType == MaskDataSubTypeDATEYEAR) year_len++; else break; } str_Value = (wxString::Format(_("%04d"), value.GetYear())).Right(year_len);; } else if(pobjData->m_eSubType == MaskDataSubTypeTIMEHOUR) { pobjDataNext = (wxFieldMaskData *) (pos < (long) (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjDataNext) { if(pobjData->m_eType == MaskDataTypeDIGIT && pobjData->m_eSubType == MaskDataSubTypeTIMEHOUR) str_Value = wxString::Format(_("%02d"), value.GetHour()); else str_Value = wxString::Format(_("%d"), value.GetHour() % 10); } } else if(pobjData->m_eSubType == MaskDataSubTypeTIMEMINUTE) { pobjDataNext = (wxFieldMaskData *) (pos < (long) (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjDataNext) { if(pobjData->m_eType == MaskDataTypeDIGIT && pobjData->m_eSubType == MaskDataSubTypeTIMEMINUTE) str_Value = wxString::Format(_("%02d"), value.GetMinute()); else str_Value = wxString::Format(_("%d"), value.GetMinute() % 10); } } else if(pobjData->m_eSubType == MaskDataSubTypeTIMESECOND) { pobjDataNext = (wxFieldMaskData *) (pos < (long) (m_listData.GetCount()-1) ? (m_listData.Item(pos+1))->GetData() : NULL); if(pobjDataNext) { if(pobjData->m_eType == MaskDataTypeDIGIT && pobjData->m_eSubType == MaskDataSubTypeTIMESECOND) str_Value = wxString::Format(_("%02d"), value.GetSecond()); else str_Value = wxString::Format(_("%d"), value.GetSecond() % 10); } } length = (long)str_Value.Length(); if(pos + length > (long) m_listData.GetCount()) length = (long) str_Value.Length() - pos; for(long i = pos; pos < (long) (i + length);pos++) SetAt(pos, str_Value.GetChar(pos-i)); } } Update(); } wxDateTime wxMaskController::GetDateTimeValue() { if(m_bNeedValidation) Validate(); return m_dtDateTime; } int wxMaskController::RPtoLP(int nRealPos) { // All wxMaskController functions that take cursor position as argument interpret it // as real position within edit control (taking into account all symbols including // literals). But sometimes we want to know which non-literal symbol is at // particular real position. In that case this function is really useful if(nRealPos < 0 || nRealPos >= (int) m_listData.GetCount()) return -1; int nLogicalPos = -1; wxFieldMaskData* pobjData = NULL; int nNextInputLocation = 0; for(unsigned long pos = nNextInputLocation;pos < m_listData.GetCount();pos++, nNextInputLocation++) { pobjData = (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); if(pobjData->IsInputData()) { nLogicalPos++; } if(nNextInputLocation == nRealPos) { return pobjData->IsInputData() ? nLogicalPos : -1; } } return -1; } int wxMaskController::LPtoRP(int nLogicalPos) { // All wxMaskController functions that take cursor position as argument interpret it // as real position within edit control (taking into account all symbols including // literals). But sometimes we want to set cursor at position before or after // particular non-literal symbol. In that case this function is really useful if(nLogicalPos < 0 || nLogicalPos >= (int) m_listData.GetCount()) return -1; int nRealPos = -1; int nNonLiterals = -1; wxFieldMaskData* pobjData = NULL; int nNextInputLocation = 0; for(unsigned long pos = nNextInputLocation; pos < m_listData.GetCount();pos++, nNextInputLocation++) { pobjData= (wxFieldMaskData *) (m_listData.Item(pos))->GetData(); nRealPos++; if(pobjData->IsInputData()) { nNonLiterals++; if(nNonLiterals == nLogicalPos) { return nRealPos; } } } return -1; }
[ "dmitry.dergachev@gmail.com" ]
dmitry.dergachev@gmail.com
846c7303c8ac3b85da64148fc9e78ad861d28101
d36f11ac4059d5806348d322cf065a0e30fa6ffe
/ZF/ZFUIKit/src/ZFUIKit/ZFUIKeyEvent.cpp
4015a72e26f5d613a4b8468d2bcf0e783e591f75
[]
no_license
hasmorebug/ZFFramework
ea9fa14d375658dd843b1f62ec34fcd2b5b1446f
fa14d0f04ad68cc59457908a3fcba148738ef8c3
refs/heads/master
2021-01-15T08:28:09.034834
2016-08-04T17:35:36
2016-08-04T17:35:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
796
cpp
/* ====================================================================== * * Copyright (c) 2010-2016 ZFFramework * home page: http://ZFFramework.com * blog: http://zsaber.com * contact: master@zsaber.com (Chinese and English only) * Distributed under MIT license: * https://github.com/ZFFramework/ZFFramework/blob/master/license/license.txt * ====================================================================== */ #include "ZFUIKeyEvent.h" ZF_NAMESPACE_GLOBAL_BEGIN ZFOBJECT_REGISTER(ZFUIKeyEvent) ZFCACHEABLE_DEFINE(ZFUIKeyEvent, ZFUIKeyEvent) void ZFUIKeyEvent::objectInfoOnAppend(ZF_IN_OUT zfstring &ret) { ret += ZFUIKeyAction::EnumNameForValue(this->keyAction); ret += zfText(" "); ret += ZFUIKeyCode::EnumNameForValue(this->keyCode); } ZF_NAMESPACE_GLOBAL_END
[ "z@zsaber.com" ]
z@zsaber.com
4a631a8a411d015ddfbd94608338e5d8e28c04db
885da21a1d3649d5eed97b381cff6d7478ad7809
/src/BlackBoneTest/TestRemoteCall.cpp
f5ab1f714b155b193138c5fa154791b4468199a8
[ "MIT" ]
permissive
Shhoya/Blackbone
3554cb26a3fe98788daf78171031533e776ce833
b18a470a68c5e921122f973e6b1c74c94a4f327c
refs/heads/master
2023-02-22T01:27:55.106768
2021-01-29T09:56:21
2021-01-29T09:56:21
257,532,729
0
1
MIT
2021-01-29T09:56:22
2020-04-21T08:39:19
null
UTF-8
C++
false
false
8,648
cpp
#include "Common.h" namespace Testing { constexpr char g_string[] = "The quick brown fox jumps over the lazy dog"; constexpr wchar_t g_wstring[] = L"The quick brown fox jumps over the lazy dog"; struct Dummy { uint32_t ival = 0; float fval = 0.0f; uint64_t uval = 0ull; }; int TestFn( int a1, float a2, double a3, double* a4, int64_t a5, char* a6, wchar_t* a7, Dummy* a8, Dummy a9 ) { *a4 = a3 + a2; strcpy_s( a6, MAX_PATH, g_string ); wcscpy_s( a7, MAX_PATH, g_wstring ); *a8 = a9; return static_cast<int>(a1 + a5); } TEST_CLASS( RemoteCall ) { public: template<typename T> void ValidateArg( const AsmVariant& arg, AsmVariant::eType type, size_t size, T value ) { AssertEx::AreEqual( type, arg.type ); AssertEx::AreEqual( size, arg.size ); if constexpr (std::is_same_v<T, float>) { AssertEx::AreEqual( value, arg.imm_float_val ); } else if constexpr(std::is_same_v<T, double>) { AssertEx::AreEqual( value, arg.imm_double_val ); } else if constexpr (std::is_pointer_v<std::decay_t<T>>) { AssertEx::AreEqual( reinterpret_cast<uint64_t>(value), arg.imm_val64 ); } else if (value != 0) { AssertEx::AreEqual( uint64_t( value ), arg.imm_val64 ); } } TEST_METHOD( ConstructDirect ) { Process process; RemoteFunction<decltype(&TestFn)> pFN( process, ptr_t( 0 ) ); float f = 2.0; double d = 3.0; double& ref = d; decltype(pFN)::CallArguments args( 1, f, ref, &d, 5ll, _cbuf, _wbuf, &_output, _input ); AssertEx::AreEqual( size_t( 9 ), args.arguments.size() ); ValidateArg( args.arguments[0], AsmVariant::imm, sizeof( int ), 1 ); ValidateArg( args.arguments[1], AsmVariant::imm_float, sizeof( float ), 2.0f ); ValidateArg( args.arguments[2], AsmVariant::imm_double, sizeof( double ), 3.0 ); ValidateArg( args.arguments[3], AsmVariant::dataPtr, sizeof( double ), &d ); ValidateArg( args.arguments[4], AsmVariant::imm, sizeof( int64_t ), 5 ); ValidateArg( args.arguments[5], AsmVariant::dataPtr, sizeof( '\0' ), _cbuf ); ValidateArg( args.arguments[6], AsmVariant::dataPtr, sizeof( L'\0' ), _wbuf ); ValidateArg( args.arguments[7], AsmVariant::dataPtr, sizeof( _output ), &_output ); ValidateArg( args.arguments[8], AsmVariant::dataStruct, sizeof( _input ), 0 ); } TEST_METHOD( ConstructFromList ) { Process process; RemoteFunction<decltype(&TestFn)> pFN( process, ptr_t( 0 ) ); float f = 2.0; double d = 3.0; double& ref = d; decltype(pFN)::CallArguments args{ 1, f, ref, &d, 5ll, _cbuf, _wbuf, &_output, _input }; AssertEx::AreEqual( size_t( 9 ), args.arguments.size() ); ValidateArg( args.arguments[0], AsmVariant::imm, sizeof( int ), 1 ); ValidateArg( args.arguments[1], AsmVariant::imm_float, sizeof( float ), 2.0f ); ValidateArg( args.arguments[2], AsmVariant::imm_double, sizeof( double ), 3.0 ); ValidateArg( args.arguments[3], AsmVariant::dataPtr, sizeof( double ), &d ); ValidateArg( args.arguments[4], AsmVariant::imm, sizeof( int64_t ), 5 ); ValidateArg( args.arguments[5], AsmVariant::dataPtr, sizeof( _cbuf ), _cbuf ); ValidateArg( args.arguments[6], AsmVariant::dataPtr, sizeof( _wbuf ), _wbuf ); ValidateArg( args.arguments[7], AsmVariant::dataPtr, sizeof( _output ), &_output ); ValidateArg( args.arguments[8], AsmVariant::dataStruct, sizeof( _input ), 0 ); } TEST_METHOD( LocalCall ) { Process process; AssertEx::NtSuccess( process.Attach( GetCurrentProcessId() ) ); auto pFN = MakeRemoteFunction<decltype(&TestFn)>( process, &TestFn ); double d = 0.0; _input.ival = 0xDEAD; _input.fval = 1337.0f; _input.uval = 0xDEADC0DEA4DBEEFull; auto[status, result] = pFN.Call( { 1, 2.0f, 3.0, &d, 5ll, _cbuf, _wbuf, &_output, _input } ); AssertEx::NtSuccess( status ); AssertEx::IsTrue( result.has_value() ); AssertEx::AreEqual( 1 + 5, result.value() ); AssertEx::AreEqual( 3.0 + 2.0f, d, 0.001 ); AssertEx::AreEqual( _cbuf, g_string ); AssertEx::AreEqual( _wbuf, g_wstring ); AssertEx::IsZero( memcmp( &_input, &_output, sizeof( _input ) ) ); } TEST_METHOD( NtQueryVirtualMemory ) { auto path = GetTestHelperHost(); AssertEx::IsTrue( Utils::FileExists( path ) ); // Give process some time to initialize Process process; AssertEx::NtSuccess( process.CreateAndAttach( path ) ); Sleep( 100 ); auto hMainMod = process.modules().GetMainModule(); AssertEx::IsNotNull( hMainMod.get() ); auto pFN = MakeRemoteFunction<fnNtQueryVirtualMemory>( process, L"ntdll.dll", "NtQueryVirtualMemory" ); AssertEx::IsTrue( pFN.valid() ); uint8_t buf[0x200] = { }; auto result = pFN.Call( { INVALID_HANDLE_VALUE, static_cast<uintptr_t>(hMainMod->baseAddress), MemorySectionName, buf, sizeof( buf ), nullptr } ); process.Terminate(); AssertEx::NtSuccess( result.status ); AssertEx::NtSuccess( result.result() ); std::wstring name( reinterpret_cast<wchar_t*>(buf + sizeof( UNICODE_STRING )) ); AssertEx::AreNotEqual( name.npos, name.rfind( Utils::StripPath( path ) ) ); } TEST_METHOD( FileOP ) { auto path = GetTestHelperHost(); AssertEx::IsTrue( Utils::FileExists( path ) ); // Give process some time to initialize Process process; AssertEx::NtSuccess( process.CreateAndAttach( path ) ); Sleep( 100 ); auto CreateFileWPtr = process.modules().GetExport( L"kernel32.dll", "CreateFileW" ); auto WriteFilePtr = process.modules().GetExport( L"kernel32.dll", "WriteFile" ); auto CloseHandlePtr = process.modules().GetExport( L"kernel32.dll", "CloseHandle" ); AssertEx::IsTrue( CreateFileWPtr.success() ); AssertEx::IsTrue( WriteFilePtr.success() ); AssertEx::IsTrue( CloseHandlePtr.success() ); uint8_t writeBuf[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; RemoteFunction<decltype(&CreateFileW)> pCreateFile( process, CreateFileWPtr->procAddress ); RemoteFunction<decltype(&WriteFile)> pWriteFile( process, WriteFilePtr->procAddress ); RemoteFunction<decltype(&CloseHandle)> pCloseHandle( process, CloseHandlePtr->procAddress ); auto filePath = L"DummyFile_FileOP.dat"; auto handle = pCreateFile.Call( filePath, GENERIC_WRITE, 0x7, nullptr, CREATE_ALWAYS, 0, nullptr ); AssertEx::NtSuccess( handle.status ); AssertEx::IsNotNull( handle.result() ); DWORD bytes = 0; auto success = pWriteFile.Call( { handle.result(), writeBuf, sizeof( writeBuf ), &bytes, nullptr } ); pCloseHandle.Call( handle.result(), nullptr ); process.Terminate(); AssertEx::NtSuccess( success.status ); AssertEx::IsTrue( success.result() ); AssertEx::AreEqual( static_cast<DWORD>(sizeof( writeBuf )), bytes ); // Check locally auto hFile = Handle( CreateFileW( filePath, GENERIC_READ, 0x7, nullptr, OPEN_EXISTING, FILE_DELETE_ON_CLOSE, nullptr ) ); AssertEx::IsTrue( hFile ); uint8_t readBuf[sizeof( writeBuf )] = { }; BOOL b = ReadFile( hFile, readBuf, sizeof( readBuf ), &bytes, nullptr ); AssertEx::IsTrue( b ); AssertEx::AreEqual( static_cast<DWORD>(sizeof( readBuf )), bytes ); AssertEx::IsZero( memcmp( writeBuf, readBuf, sizeof( readBuf ) ) ); } private: char _cbuf[MAX_PATH] = { }; wchar_t _wbuf[MAX_PATH] = { }; Dummy _input, _output; }; }
[ "DarthTon@gmail.com" ]
DarthTon@gmail.com
d07ca12e6fdc2d88b0ac1e15a808dc1e09b37d83
685944df003a0267659d5b74a7edc11e063907e7
/src/rectangle.cpp
e5a217065580e66b69b2fa264277a5fbe400d155
[]
no_license
Samudraneel24/Jet-Combat
a4def33c0544cbd6186887a9dab9c97f19bdcbc6
11ad47b1d0b0bd2c7e8230820384f36a6afe9c61
refs/heads/master
2020-04-20T15:02:02.650291
2019-02-20T11:27:01
2019-02-20T11:27:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,283
cpp
#define GLM_ENABLE_EXPERIMENTAL #include <iostream> #include <fstream> #include "rectangle.h" #include "main.h" using namespace std; Rectangle::Rectangle(Point a, Point b, Point c, Point d, color_t color) { this->position = glm::vec3(0, 0, 0); GLfloat vertex_buffer_data[] = { a.x, a.y, a.z, b.x, b.y, b.z, c.x, c.y, c.z, a.x, a.y, a.z, c.x, c.y, c.z, d.x, d.y, d.z, }; this->object = create3DObject(GL_TRIANGLES, 6, vertex_buffer_data, color, GL_FILL); } void Rectangle::draw(glm::mat4 VP) { Matrices.model = glm::mat4(1.0f); glm::mat4 translate = glm::translate (this->position); // glTranslatef glm::mat4 rotate = glm::rotate((float) (0.0 * M_PI / 180.0f), glm::vec3(1, 0, 0)); // No need as coords centered at 0, 0, 0 of cube arouund which we waant to rotate // rotate = rotate * glm::translate(glm::vec3(0, -0.6, 0)); Matrices.model *= (translate * rotate); glm::mat4 MVP = VP * Matrices.model; glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]); draw3DObject(this->object); } void Rectangle::set_position(float x, float y, float z) { this->position = glm::vec3(x, y, z); } void Rectangle::tick() { // this->position.x -= this->speedx; }
[ "samudraneel.das@students.iiit.ac.in" ]
samudraneel.das@students.iiit.ac.in
1e0e6927882d7e8e0048888107fb41e3d9eefe51
883887c3c84bd3ac4a11ac76414129137a1b643b
/goVacademy/Registry.cpp
9d6310a6c581fa5ec3cbec7f6a6d9655b0beed25
[]
no_license
15831944/vAcademia
4dbb36d9d772041e2716506602a602d516e77c1f
447f9a93defb493ab3b6f6c83cbceb623a770c5c
refs/heads/master
2022-03-01T05:28:24.639195
2016-08-18T12:32:22
2016-08-18T12:32:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,750
cpp
///////////////////////////////////////////////////////////////////////////// // Copyright (C) 1998 by Shane Martin // All rights reserved // // Distribute freely, except: don't remove my name from the source or // documentation (don't take credit for my work), mark your changes (don't // get me blamed for your possible bugs), don't alter or remove this // notice. // No warrantee of any kind, express or implied, is included with this // software; use at your own risk, responsibility for damages (if any) to // anyone resulting from the use of this software rests entirely with the // user. // // Send bug reports, bug fixes, enhancements, requests, flames, etc., and // I'll try to keep a version up to date. I can be reached as follows: // shane.kim@kaiserslautern.netsurf.de ///////////////////////////////////////////////////////////////////////////// // last revised: 24 Apr 98 // Registry.cpp : implementation file // // Description: // CRegistry is a wrapper for the Windows Registry API. It allows // easy modification of the Registry with easy to remember terms like // Read, Write, Open, and Close. #include "stdafx.h" #include "Registry.h" CRegistry::CRegistry(HKEY hKeyRoot) { m_hKey = hKeyRoot; } CRegistry::~CRegistry() { Close(); } BOOL CRegistry::VerifyKey (HKEY hKeyRoot, LPCTSTR pszPath) { ATLASSERT (hKeyRoot); ATLASSERT (pszPath); LONG ReturnValue = RegOpenKeyEx (hKeyRoot, pszPath, 0L, KEY_ALL_ACCESS, &m_hKey); if(ReturnValue == ERROR_SUCCESS) return TRUE; m_Info.lMessage = ReturnValue; m_Info.dwSize = 0L; m_Info.dwType = 0L; return FALSE; } BOOL CRegistry::VerifyKey (LPCTSTR pszPath) { ATLASSERT (m_hKey); LONG ReturnValue = RegOpenKeyEx (m_hKey, pszPath, 0L, KEY_ALL_ACCESS, &m_hKey); m_Info.lMessage = ReturnValue; m_Info.dwSize = 0L; m_Info.dwType = 0L; if(ReturnValue == ERROR_SUCCESS) return TRUE; return FALSE; } BOOL CRegistry::VerifyValue (LPCTSTR pszValue) { ATLASSERT(m_hKey); LONG lReturn = RegQueryValueEx(m_hKey, pszValue, NULL, NULL, NULL, NULL); m_Info.lMessage = lReturn; m_Info.dwSize = 0L; m_Info.dwType = 0L; if(lReturn == ERROR_SUCCESS) return TRUE; return FALSE; } BOOL CRegistry::CreateKey (HKEY hKeyRoot, LPCTSTR pszPath) { DWORD dw; LONG ReturnValue = RegCreateKeyEx (hKeyRoot, pszPath, 0L, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &m_hKey, &dw); m_Info.lMessage = ReturnValue; m_Info.dwSize = 0L; m_Info.dwType = 0L; if(ReturnValue == ERROR_SUCCESS) return TRUE; return FALSE; } BOOL CRegistry::Open (HKEY hKeyRoot, LPCTSTR pszPath) { m_sPath = pszPath; LONG ReturnValue = RegOpenKeyEx (hKeyRoot, pszPath, 0L, KEY_ALL_ACCESS, &m_hKey); m_Info.lMessage = ReturnValue; m_Info.dwSize = 0L; m_Info.dwType = 0L; if(ReturnValue == ERROR_SUCCESS) return TRUE; return FALSE; } void CRegistry::Close() { if (m_hKey) { RegCloseKey (m_hKey); m_hKey = NULL; } } BOOL CRegistry::Write (LPCTSTR pszKey, int iVal) { DWORD dwValue; ATLASSERT(m_hKey); ATLASSERT(pszKey); dwValue = (DWORD)iVal; LONG ReturnValue = RegSetValueEx (m_hKey, pszKey, 0L, REG_DWORD, (CONST BYTE*) &dwValue, sizeof(DWORD)); m_Info.lMessage = ReturnValue; m_Info.dwSize = sizeof(DWORD); m_Info.dwType = REG_DWORD; if(ReturnValue == ERROR_SUCCESS) return TRUE; return FALSE; } BOOL CRegistry::Write (LPCTSTR pszKey, DWORD dwVal) { ATLASSERT(m_hKey); ATLASSERT(pszKey); return RegSetValueEx (m_hKey, pszKey, 0L, REG_DWORD, (CONST BYTE*) &dwVal, sizeof(DWORD)); } BOOL CRegistry::Write (LPCTSTR pszKey, LPCTSTR pszData) { ATLASSERT(m_hKey); ATLASSERT(pszKey); ATLASSERT(pszData); LONG ReturnValue = RegSetValueEx (m_hKey, pszKey, 0L, REG_SZ, (CONST BYTE*) pszData, strlen(pszData) + 1); m_Info.lMessage = ReturnValue; m_Info.dwSize = strlen(pszData) + 1; m_Info.dwType = REG_SZ; if(ReturnValue == ERROR_SUCCESS) return TRUE; return FALSE; } BOOL CRegistry::Read(LPCTSTR pszKey, int& iVal) { ATLASSERT(m_hKey); ATLASSERT(pszKey); DWORD dwType; DWORD dwSize = sizeof (DWORD); DWORD dwDest; LONG lReturn = RegQueryValueEx (m_hKey, (LPSTR) pszKey, NULL, &dwType, (BYTE *) &dwDest, &dwSize); m_Info.lMessage = lReturn; m_Info.dwType = dwType; m_Info.dwSize = dwSize; if(lReturn == ERROR_SUCCESS) { iVal = (int)dwDest; return TRUE; } return FALSE; } BOOL CRegistry::Read (LPCTSTR pszKey, DWORD& dwVal) { ATLASSERT(m_hKey); ATLASSERT(pszKey); DWORD dwType; DWORD dwSize = sizeof (DWORD); DWORD dwDest; LONG lReturn = RegQueryValueEx (m_hKey, (LPSTR) pszKey, NULL, &dwType, (BYTE *) &dwDest, &dwSize); m_Info.lMessage = lReturn; m_Info.dwType = dwType; m_Info.dwSize = dwSize; if(lReturn == ERROR_SUCCESS) { dwVal = dwDest; return TRUE; } return FALSE; } BOOL CRegistry::Read (LPCTSTR pszKey, CComString& sVal) { ATLASSERT(m_hKey); ATLASSERT(pszKey); DWORD dwType; DWORD dwSize = 200; char szString[255]; LONG lReturn = RegQueryValueEx (m_hKey, (LPSTR) pszKey, NULL, &dwType, (BYTE *) szString, &dwSize); m_Info.lMessage = lReturn; m_Info.dwType = dwType; m_Info.dwSize = dwSize; if(lReturn == ERROR_SUCCESS) { sVal = szString; return TRUE; } return FALSE; } BOOL CRegistry::DeleteValue (LPCTSTR pszValue) { ATLASSERT(m_hKey); LONG lReturn = RegDeleteValue(m_hKey, pszValue); m_Info.lMessage = lReturn; m_Info.dwType = 0L; m_Info.dwSize = 0L; if(lReturn == ERROR_SUCCESS) return TRUE; return FALSE; } BOOL CRegistry::DeleteValueKey (HKEY hKeyRoot, LPCTSTR pszPath) { ATLASSERT(pszPath); ATLASSERT(hKeyRoot); LONG lReturn = RegDeleteKey(hKeyRoot, pszPath); m_Info.lMessage = lReturn; m_Info.dwType = 0L; m_Info.dwSize = 0L; if(lReturn == ERROR_SUCCESS) return TRUE; return FALSE; }
[ "ooo.vspaces@gmail.com" ]
ooo.vspaces@gmail.com
df397cdfc0e24008531ad0d5f3d107f0ea8265a3
58ffaa5f43e14321bb1602767e2cb4305ea4818b
/Bigram.cc
a82ef5ff044aae51497cf00e1c87fd9a27c38f01
[ "BSD-3-Clause" ]
permissive
torus/2g-redis
88d2cfd3fc4fddd9784da88120b5c3808a5cb00c
20e5354fd02c73a3761d1aee5cea5f88e59a42ab
refs/heads/master
2021-01-19T15:27:28.321043
2013-04-29T13:06:57
2013-04-29T13:06:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,966
cc
#include <string> #include <vector> #include <set> #include <list> #include <map> #include <ostream> #include <istream> #include <sstream> #include <fstream> #include <iostream> #include <memory> #include <algorithm> #include <utility> #include <list> #include <iterator> #include <sqlite3.h> #include <openssl/sha.h> #include <openssl/bio.h> #include <openssl/evp.h> #include "utf8/source/utf8.h" #include "Bigram.hh" using namespace Bigram; Dictionary::Dictionary(std::shared_ptr<Driver> drv) : driver_(drv) { } Dictionary::Dictionary() : driver_(new MemoryDriver) { } std::set<Record> Dictionary::lookup(int char1, int char2) const { return driver_->lookup(char1, char2); } void Dictionary::add(const std::string &fileid, std::istream &is) { std::string line; int offset = 0; while (std::getline(is, line)) { add(fileid, line, offset); offset += line.length(); } } void Dictionary::add(const std::string &fileid, const std::string &text, size_t offset) { auto chars = disassemble(text); int count = 0; for (auto it = chars.cbegin(); it != chars.cend() && (it + 1) != chars.cend(); it ++, count ++) { Bigram::Record rec((*it).first, (*(it + 1)).first, Bigram::Position(fileid, count + offset)); add(rec); } } void Dictionary::add(const Path &filepath) { std::string hash = Bigram::digest_file(filepath); std::ifstream is(filepath); add(hash, is); register_path(filepath, hash); } void Dictionary::add(const Record &rec) { driver_->add(rec); } std::list<Position> Dictionary::search(const std::string &text) const { std::map<Position, int> map; auto chars = disassemble(text); for (int i = 0; i < chars.size() - 1; i ++) { auto recs = lookup(chars[i].first, chars[i + 1].first); for (auto rec : recs) { auto offset = rec.position().position() - chars[i].second; Position pos(rec.position().docid(), offset); map[pos]++; } } std::list<std::pair<Position, int>> result(map.cbegin(), map.cend()); result.remove_if([&chars](std::pair<Position, int> elem){ return elem.second < chars.size() - 1; }); std::list<Position> dest; std::transform(result.cbegin(), result.cend(), std::back_inserter(dest), [](const std::pair<Position, int> &a){ return a.first; }); return dest; } void Dictionary::register_path(const Path &path, const std::string &digest) { driver_->register_path(path, digest); } std::set<Path> Dictionary::lookup_digest(const std::string &digest) { return driver_->lookup_digest(digest); } Record::Record(int char1, int char2, const Position &pos) : first_(char1), second_(char2), position_(pos) { } bool Position::operator==(const Position &pos) const { return this == &pos || pos.docid_ == docid_ && pos.position_ == position_; } bool Position::operator<(const Position &pos) const { if (this == &pos) return false; if (pos.docid_ < docid_) return true; if (pos.docid_ > docid_) return false; if (pos.position_ < position_) return true; return false; } bool Record::operator==(const Record &rec) const { return this == &rec || rec.first() == first_ && rec.second() == second_ && rec.position() == position_; } bool Record::operator<(const Record &rec) const { if (this == &rec) return false; if (rec.first() < first_) return true; if (rec.first() > first_) return false; if (rec.second() < second_) return true; if (rec.second() > second_) return false; if (rec.position() < position_) return true; return false; } std::ostream& operator<<(std::ostream &os, const Position& pos) { os << "Bigram::Position(\"" << pos.docid() << "\", " << pos.position() << ")"; return os; } std::ostream& operator<<(std::ostream &os, const Record& rec) { os << "Bigram::Record(" << rec.first() << ", " << rec.second() << ", " << rec.position() << ")"; return os; } std::vector<std::pair<CodePoint, size_t>> Bigram::disassemble(const std::string &text) { auto it = text.cbegin(); auto end = text.cend(); std::vector<std::pair<CodePoint, size_t>> dest; while (it != end) { auto offset = it - text.cbegin(); int cp = utf8::next(it, end); dest.push_back(std::pair<CodePoint, size_t>(CodePoint(cp), offset)); } return dest; } void MemoryDriver::add(const Record &rec) { records_.insert(rec); } std::set<Record> MemoryDriver::lookup(int char1, int char2) const { std::set<Record> dest; for (auto &rec : records_) { if (rec.first() == char1 && rec.second() == char2) dest.insert(rec); } return dest; } void MemoryDriver::register_path(const Path &path, const std::string &digest) { path_digest_map_[digest].insert(path); } std::set<Path> MemoryDriver::lookup_digest(const std::string &digest) { return path_digest_map_[digest]; } SQLiteDriver::SQLiteDriver(const std::string &filename) : db_(nullptr), insert_statement_(nullptr) { int rc = sqlite3_open(filename.c_str(), &db_); if (rc) { sqlite3_close(db_); throw new std::bad_alloc(); } std::ostringstream oss; oss << "CREATE TABLE IF NOT EXISTS dictionary (" << "first INTEGER, " << "second INTEGER, " << "docid VARCHAR(20), " << "position INTEGER, " << "PRIMARY KEY(first, second, docid, position)" << ");"; char *zErrMsg; rc = sqlite3_exec(db_, oss.str().c_str(), nullptr, nullptr, &zErrMsg); if(rc!=SQLITE_OK){ std::string err(zErrMsg); sqlite3_free(zErrMsg); throw err; } try { prepare_insert_statement(); } catch (int) { throw std::bad_alloc(); } { std::ostringstream oss; oss << "CREATE TABLE IF NOT EXISTS path_map (" << "path VARCHAR(255), " << "docid VARCHAR(20)" << ");"; char *zErrMsg; rc = sqlite3_exec(db_, oss.str().c_str(), nullptr, nullptr, &zErrMsg); if(rc!=SQLITE_OK){ std::string err(zErrMsg); sqlite3_free(zErrMsg); throw err; } } } void SQLiteDriver::prepare_insert_statement() { std::ostringstream oss; oss << "INSERT INTO dictionary (first, second, docid, position) VALUES " << "(?, ?, ?, ?)"; int rc = sqlite3_prepare_v2(db_, oss.str().c_str(), oss.str().length(), &insert_statement_, nullptr); if (rc != SQLITE_OK) { throw rc; } } void SQLiteDriver::add(const Record &rec) { if (sqlite3_bind_int(insert_statement_, 1, rec.first())) throw; if (sqlite3_bind_int(insert_statement_, 2, rec.second())) throw; if (sqlite3_bind_text(insert_statement_, 3, rec.position().docid().c_str(), rec.position().docid().length(), nullptr)) throw; if (sqlite3_bind_int(insert_statement_, 4, rec.position().position())) throw; int rc = sqlite3_step(insert_statement_); if (rc != SQLITE_DONE) { std::cout << " error code: " << rc << std::endl; throw rc; } if (sqlite3_reset(insert_statement_)) throw; } std::set<Record> SQLiteDriver::lookup(int char1, int char2) const { std::ostringstream oss; oss << "SELECT first, second, docid, position FROM dictionary " << "WHERE first=" << char1 << " AND second=" << char2; std::set<Record> dest; struct X { X(std::set<Record> &dest, int c1, int c2) : dest_(dest), c1_(c1), c2_(c2) { } int operator()(int argc, char** argv, char** columns) { for (int i = 0; i < argc; i ++) { std::string fileid; std::istringstream ost(argv[2]); ost >> fileid; std::istringstream ost2(argv[3]); int pos; ost2 >> pos; dest_.insert(Record(c1_, c2_, Bigram::Position(fileid, pos))); } return 0; } int c1_, c2_; std::set<Record> &dest_; static int doit(void* self, int argc, char** argv, char** columns) { return (*((X*)self))(argc, argv, columns); } } callback(dest, char1, char2); char *zErrMsg; int rc = sqlite3_exec( db_, oss.str().c_str(), X::doit, &callback, &zErrMsg); if(rc!=SQLITE_OK){ std::string err(zErrMsg); sqlite3_free(zErrMsg); throw err; } return dest; } void SQLiteDriver::register_path(const Path &path, const std::string &digest) { std::ostringstream oss; oss << "INSERT INTO path_map (path, docid) " << "VALUES (\"" << std::string(path) << "\", \"" << digest << "\")"; char *zErrMsg; int rc = sqlite3_exec(db_, oss.str().c_str(), nullptr, nullptr, &zErrMsg); if(rc!=SQLITE_OK){ std::string err(zErrMsg); sqlite3_free(zErrMsg); throw err; } } std::set<Path> SQLiteDriver::lookup_digest(const std::string &digest) { std::ostringstream oss; oss << "SELECT path FROM path_map " << "WHERE docid=\"" << digest << "\""; std::set<Path> dest; struct X { X(std::set<Path> &dest) : dest_(dest) { } int operator()(int argc, char** argv, char** columns) { for (int i = 0; i < argc; i ++) { std::string path; std::istringstream ost(argv[0]); ost >> path; dest_.insert(Path(path)); } return 0; } int c1_, c2_; std::set<Path> &dest_; static int doit(void* self, int argc, char** argv, char** columns) { return (*((X*)self))(argc, argv, columns); } } callback(dest); char *zErrMsg; int rc = sqlite3_exec( db_, oss.str().c_str(), X::doit, &callback, &zErrMsg); if(rc!=SQLITE_OK){ std::string err(zErrMsg); sqlite3_free(zErrMsg); throw err; } return dest; } std::string Bigram::digest_file(const std::string &path) { std::ifstream is(path); SHA_CTX c; SHA1_Init(&c); std::string line; while (std::getline(is, line)) { SHA1_Update(&c, line.c_str(), line.length()); } unsigned char md[SHA_DIGEST_LENGTH]; SHA1_Final(md, &c); return std::string((const char*)md, SHA_DIGEST_LENGTH); // std::ostringstream ost; // ost.fill('0'); // ost.width(2); // ost << std::hex; // for (auto p = md; p < md + SHA_DIGEST_LENGTH; p ++) { // ost << (int)*p; // } // return ost.str(); }
[ "toru@torus.jp" ]
toru@torus.jp
e33528719e025a44bdd313f6ba8ce33ec694205a
8fb9ae63c6a64d9f0789643405be4282c33c3a1b
/Timus/1204.cpp
d89bbb0eaddd1a554e98265302eb2924aa114a06
[]
no_license
RafikFarhad/Code_is_fun
7c67b4d9c97d7e58ccf822214d1ba4fe51b88ba6
08fd1c53125deaaeb0d6aac8f9c2fd7c76a05e4d
refs/heads/master
2021-07-25T13:32:48.839014
2021-01-10T00:23:34
2021-01-10T00:23:34
46,503,470
0
0
null
null
null
null
UTF-8
C++
false
false
4,196
cpp
#include <cstdio> #include <iostream> #include <string> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> #include <algorithm> #include <new> #include <vector> #include <stack> #include <queue> #include <map> #include <set> /******************************************/ /** Author : Rafik Farhad */ /** Mail to : rafikfarhad@gmail.com */ /*****************************************/ #define CLR(o) memset(o, 0x00, sizeof o) #define CLR1(o) memset(o, -1, sizeof o) #define takei(a) scanf("%d", &a) #define takell(a) scanf("%lld", &a) #define takellu(a) scanf("%llu", &a) #define sf scanf #define pb push_back #define mp make_pair #define ppp system("pause") #define ok cout << "OKA" <<endl; #define pf printf #define NL printf("\n") #define PI 2*acos(0) #define all(o) o.begin(), o.end() #define csi pf("Case %d: ", ++keis) #define csll pf("Case %lld: ", ++keis) #define _(o) pf("%d", o) ///Helper using namespace std; template <class T> T MAX(T a, T b) { return a>b?a:b; } template <class T> T MIN(T a, T b) { return a<b?a:b; } template <class T1> void __(T1 p) { cout << p << endl; } template <class T1> void deb(T1 p) { cout << "Debugging: " << p << endl; } template <class T1, class T2> void deb(T1 p, T2 q) { cout << "Debugging: " << p << "\t" << q << endl; } template <class T1, class T2, class T3> void deb(T1 p, T2 q, T3 r) { cout << "Debugging: " << p << "\t " << q << "\t " << r << endl; } template <class T1, class T2, class T3, class T4> void deb(T1 p, T2 q, T3 r, T4 s) { cout << "Debugging: " << p << "\t " << q << "\t " << r << "\t " << s << endl; } long long int POOW(long long b, long long p) { if(p==0) return 1; return b*POOW(b, p-1); } const int xx[] = {0, 0, 1, -1, -1, 1, -1, 1}; const int yy[] = {1, -1, 0, 0, 1, 1, -1, -1}; const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2}; const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1}; // KX-> Knight moves xx-> diagonal -> 8 horizontal/vertical->4 #define SIZE 100005 int prime[10000], ss; bool p[SIZE+5]; void SEIVE() { int i, j; ss = 0; prime[ss++] = 2; for(i=3; i<SIZE; i+=2) { if(!p[i]) { prime[ss++] = i; for(j=i*i; j>0 and j<SIZE; j+=i) p[j] = 1; } } return; for(i=0; i<25; i++) deb(prime[i]); deb(ss, prime[ss-1]); } typedef pair<int, int> pii; #define x first #define y second pii extendedEuclid(int a, int b) // returns x, y | ax + by = gcd(a,b) { if(b == 0) return pii(1, 0); else { pii d = extendedEuclid(b, a % b); return pii(d.y, d.x - d.y * (a / b)); } } int main() { #ifndef ONLINE_JUDGE //freopen("000.txt","r",stdin); //freopen("output.txt", "w", stdout); #endif /// MAIN int n, p, q, i, j, k, l, t, keis=0; SEIVE(); pii temp1, temp2, qu; takei(t); while(t--) { takei(n); for(i=0; i<ss; i++) if(n%prime[i]==0) { p = prime[i]; q = n/prime[i]; break; } temp1 = extendedEuclid(p, q); temp2 = extendedEuclid(q, p); //deb(temp1.x*p-temp1.y*q, temp1.x*p, temp1.y*q); //deb(temp2.x*q-temp2.y*p, temp2.x*q, temp2.y*p); i = p*temp1.x; j = temp2.x*q; //deb(i, j); if(i<0) i+=n; //i%=n; if(j<0) j+=n; //j%=n; pf("0 1 %d %d\n", min(i, j), max(i, j)); } /* Coding is FUN */ /// ENDD return 0; }
[ "rafikfarhad@gmail.com" ]
rafikfarhad@gmail.com
459250bc9e352bc9fc9f64215ab4168136175a3b
8a87f5b889a9ce7d81421515f06d9c9cbf6ce64a
/3rdParty/boost/1.78.0/boost/system/detail/error_category.hpp
a205d81cab279a7865d85baa89530ad401c53f20
[ "BSL-1.0", "Apache-2.0", "BSD-3-Clause", "ICU", "Zlib", "GPL-1.0-or-later", "OpenSSL", "ISC", "LicenseRef-scancode-gutenberg-2020", "MIT", "GPL-2.0-only", "CC0-1.0", "LicenseRef-scancode-autoconf-simple-exception", "LicenseRef-scancode-pcre", "Bison-exception-2.2", "LicenseRef-scancode...
permissive
arangodb/arangodb
0980625e76c56a2449d90dcb8d8f2c485e28a83b
43c40535cee37fc7349a21793dc33b1833735af5
refs/heads/devel
2023-08-31T09:34:47.451950
2023-08-31T07:25:02
2023-08-31T07:25:02
2,649,214
13,385
982
Apache-2.0
2023-09-14T17:02:16
2011-10-26T06:42:00
C++
UTF-8
C++
false
false
5,129
hpp
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED #define BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED // Copyright Beman Dawes 2006, 2007 // Copyright Christoper Kohlhoff 2007 // Copyright Peter Dimov 2017, 2018 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See library home page at http://www.boost.org/libs/system #include <boost/system/detail/config.hpp> #include <boost/cstdint.hpp> #include <boost/config.hpp> #include <string> #include <functional> #include <cstddef> #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) # include <system_error> # include <atomic> #endif namespace boost { namespace system { class error_category; class error_code; class error_condition; std::size_t hash_value( error_code const & ec ); namespace detail { BOOST_SYSTEM_CONSTEXPR bool failed_impl( int ev, error_category const & cat ); class std_category; } // namespace detail #if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG ) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif class BOOST_SYMBOL_VISIBLE error_category { private: friend std::size_t hash_value( error_code const & ec ); friend BOOST_SYSTEM_CONSTEXPR bool detail::failed_impl( int ev, error_category const & cat ); friend class error_code; friend class error_condition; #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) public: error_category( error_category const & ) = delete; error_category& operator=( error_category const & ) = delete; #else private: error_category( error_category const & ); error_category& operator=( error_category const & ); #endif private: boost::ulong_long_type id_; #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) mutable std::atomic< boost::system::detail::std_category* > ps_; #else boost::system::detail::std_category* ps_; #endif protected: #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS) ~error_category() = default; #else // We'd like to make the destructor protected, to make code that deletes // an error_category* not compile; unfortunately, doing the below makes // the destructor user-provided and hence breaks use after main, as the // categories may get destroyed before code that uses them // ~error_category() {} #endif BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 ), ps_() { } explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id ), ps_() { } public: virtual const char * name() const BOOST_NOEXCEPT = 0; virtual error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT; virtual bool equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT; virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT; virtual std::string message( int ev ) const = 0; virtual char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT; virtual bool failed( int ev ) const BOOST_NOEXCEPT { return ev != 0; } friend BOOST_SYSTEM_CONSTEXPR bool operator==( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT { return rhs.id_ == 0? &lhs == &rhs: lhs.id_ == rhs.id_; } friend BOOST_SYSTEM_CONSTEXPR bool operator!=( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT { return !( lhs == rhs ); } friend BOOST_SYSTEM_CONSTEXPR bool operator<( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT { if( lhs.id_ < rhs.id_ ) { return true; } if( lhs.id_ > rhs.id_ ) { return false; } if( rhs.id_ != 0 ) { return false; // equal } return std::less<error_category const *>()( &lhs, &rhs ); } #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) # if defined(__SUNPRO_CC) // trailing __global is not supported operator std::error_category const & () const; # else operator std::error_category const & () const BOOST_SYMBOL_VISIBLE; # endif #endif }; #if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG ) #pragma GCC diagnostic pop #endif namespace detail { static const boost::ulong_long_type generic_category_id = ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDFD0; static const boost::ulong_long_type system_category_id = generic_category_id + 1; static const boost::ulong_long_type interop_category_id = generic_category_id + 2; BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat ) { if( cat.id_ == system_category_id || cat.id_ == generic_category_id ) { return ev != 0; } else { return cat.failed( ev ); } } } // namespace detail } // namespace system } // namespace boost #endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED
[ "noreply@github.com" ]
noreply@github.com
3162ff8e9383de99a695668734c29c19ecefd9d8
c7f159c52ec9d525b1d10d6f5fbc4b934f30d714
/DBUFFMGR.Cpp
92d8773401984d22fcb5e6728b9aa52eafcfc76b
[]
no_license
breezechen/layered
e9d2122dbbdcde916cd878115a22247da6a0414c
888f3bb27b40450fed6fdbaabd52f8149bb33c3f
refs/heads/master
2021-01-21T01:50:22.833030
2016-07-21T11:46:04
2016-07-21T11:46:04
63,864,879
5
3
null
null
null
null
UTF-8
C++
false
false
5,443
cpp
/*++ Copyright (c) 1996 Intel Corporation Copyright 1996 - 1998 Microsoft Corporation All Rights Reserved Permission is granted to use, copy and distribute this software and its documentation for any purpose and without fee, provided, that the above copyright notice and this statement appear in all copies. Intel makes no representations about the suitability of this software for any purpose. This software is provided "AS IS." Intel specifically disclaims all warranties, express or implied, and all liability, including consequential and other indirect damages, for the use of this software, including liability for infringement of any proprietary rights, and including the warranties of merchantability and fitness for a particular purpose. Intel does not assume any responsibility for any errors which may appear in this software nor any responsibility to update it. Module Name: dbuffmgr.cpp Abstract: This module defines and interface for a buffer manager for managing WSABUF's. If a layered provider needs to modify application data The CopyBuffer() routine should be modifed to do so. --*/ #include "precomp.h" DBUFFERMANAGER::DBUFFERMANAGER( ) /*++ Routine Description: DBUFFERMANAGER object constructor. Creates and returns a DBUFFERMANAGER object. Note that the DBUFFERMANAGER object has not been fully initialized. The "Initialize" member function must be the first member function called on the new DBUFFERMANAGER object. Arguments: None Return Value: None --*/ { // Null function body. A full implemantation would initialize member // varialbles to know values for use in Initailize(). } INT DBUFFERMANAGER::Initialize( ) /*++ Routine Description: The initialization routine for a buffer manager object. This procedure completes the initialzation of the object. This procedure preforms initialization operations that may fail and must be reported since there is no way to fail the constructor. Arguments: None Return Value: The function returns NO_ERROR if successful. Otherwise it returns an appropriate WinSock error code if the initialization cannot be completed. --*/ { return(NO_ERROR); } DBUFFERMANAGER::~DBUFFERMANAGER() /*++ Routine Description: DBUFFERMANAGER object destructor. This procedure has the responsibility to perform any required shutdown operations for the DBUFFERMANAGER object before the object memory is deallocated. Arguments: None Return Value: None --*/ { // Null function body } INT DBUFFERMANAGER::AllocBuffer( IN LPWSABUF UserBuffer, IN DWORD UserBufferCount, OUT LPWSABUF* InternalBuffer, OUT DWORD* InternalBufferCount ) /*++ Routine Description: This routine allocates a set of WSABUF's to pass to the underlying service provider. Arguments: UserBuffer - A pointer to the array user WSABUFs UserBufferCount - The number of user WSABUF structs. InternalBuffer - A pointer to a pointer to a WSABUF InternalBufferCount - The pointer to a DWORD to revceive the number of WSABUFs pointed to by InternalBuffer. Return Value: The function returns NO_ERROR if successful. Otherwise it returns an appropriate WinSock error code if the initialization cannot be completed. --*/ { // ****** // Note this procedure returns the user buffer(s) undistrubed. This is the // wrong thing for providers that wish to modify the data stream. The // proper buffer management policy is left to the provider developer. *InternalBuffer = UserBuffer; *InternalBufferCount = UserBufferCount; return(NO_ERROR); } VOID DBUFFERMANAGER::FreeBuffer( IN LPWSABUF InternalBuffer, IN DWORD InternalBufferCount ) /*++ Routine Description: This routine frees a set of WSABUF's allocated by AllocBuffer(); Arguments: InternalBuffer - A pointer to WSABUF array InternalBufferCount - The number of WSABUFs pointed to by InternalBuffer. Return Value: The function returns NO_ERROR if successful. Otherwise it returns an appropriate WinSock error code if the initialization cannot be completed. --*/ { } INT DBUFFERMANAGER::CopyBuffer( IN LPWSABUF SourceBuffer, IN DWORD SourceBufferCount, IN DWORD SourceOffset, IN DWORD BytesToCopy, IN LPWSABUF DestinationBuffer, IN DWORD DestinationBufferCount, IN DWORD DestionationOffset ) /*++ Routine Description: This routine copies one set of WSABUFs to another. Arguments: SourceBuffer - A pointer to an array of WSABUFs. SourceBuferCount - The number of WSABUFs pointed to by SourceBuffer. SourceOffset - offset to start copying from in source BytesToCopy - maximum number of bytest to copy DestinationBuffer - A pointer to an array of WSABUFs. DestinationBufferCount - The number of WSABUFs pointed to by DestinationBuffer . DestinationOffset - offset to start writing to in destionation buffer Return Value: The function returns NO_ERROR if successful. Otherwise it returns an appropriate WinSock error code if the initialization cannot be completed. --*/ { return(NO_ERROR); }
[ "breezechen356@gmail.com" ]
breezechen356@gmail.com
cf73ffb297aed5b19399dcb9b10fccd563a8cffe
fa634b0885177ea36b7283bda59916c95b8560c5
/include/Customs/PreMenuScene.h
db59c951be3d5bc220a11f2a1fc2583f9e885193
[ "MIT" ]
permissive
Diego-BF/voID
1e5f3d90d2fa62132b3c94daa3463d9c100b1c9f
8374147cacc0758071651e8a5d35b7bcb9ec4e9f
refs/heads/FirstMark
2021-01-23T16:52:22.281891
2017-07-09T20:58:30
2017-07-09T20:58:30
101,098,547
0
0
null
2017-08-22T19:12:27
2017-08-22T19:12:27
null
UTF-8
C++
false
false
488
h
#ifndef __PRE_MENU_SCENE__ #define __PRE_MENU_SCENE__ #include "Engine/GameObject.h" #include "Engine/Scene.h" #include "Engine/Image.h" #include "Components/Animator.h" #include "Components/Animation.h" class PreMenuScene : public Scene { public: void OnActivation() override; void OnDeactivation() override; void OnShown() override; void OnHidden() override; private: void CreateLogoSdl(); void CreateLogoUnb(); void CreateLogoControle(); void CreateLogoZebra(); }; #endif
[ "walysonmaxwel@hotmail.com" ]
walysonmaxwel@hotmail.com
f73d90b124617e36ee3634ae76f229763f6a0076
5181e2dd87941613b74be655fd621c13c1032d31
/1. Nhap mon lap trinh_chuong04_ma tran/bai106.cpp
27b7799c90c08d3c09baa09f785751cd03b20ccb
[]
no_license
my-hoang-huu/My-hh
36c57bcc0ff2a6f09d1404af502a63c94dfd7b92
176a0ec629438260ef1a44db82fe1a99a59c809f
refs/heads/main
2023-06-05T03:03:18.421699
2021-05-07T00:36:26
2021-05-07T00:36:26
342,750,649
0
0
null
2021-05-07T00:36:27
2021-02-27T02:18:47
C++
UTF-8
C++
false
false
1,412
cpp
#include<iostream> #include<iomanip> #include<cstdlib> #include<ctime> using namespace std; void Nhap(float[][50], int&, int&); void Xuat(float[][50], int, int); bool Kt(float); void XuLy(float[][50], int, int); int main() { float a[20][50]; int m; int n; Nhap(a, m, n); cout << "Ma tran ban dau: \n"; Xuat(a, m, n); XuLy(a, m, n); return 1; } void Nhap(float a[][50], int& m, int& n) { cout << "Nhap so dong m = "; cin >> m; cout << "\nNhap so cot n = "; cin >> n; srand(time(NULL)); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { a[i][j] = rand() * 1.0 / RAND_MAX * 200 - 100; /* cout << setw(7) << "a[" << i << "]" << "[" << j << "] = "; cin >> a[i][j];*/ } } cout << endl; } void Xuat(float a[][50], int m, int n) { for (int i = 0; i < m; i++) { cout << endl; for (int j = 0; j < n; j++) { cout << setw(8) << "a[" << i << "][" << j << "] = " << fixed << setprecision(2) << a[i][j]; } } cout << endl; } bool Kt(float n) { return true; } void XuLy(float a[][50], int m, int n) { int d; cout << "\nNhap dong: "; cin >> d; for (int j = 1; j < n; j++) { if (a[d][j] < a[d][j-1]) { cout << "\nDong "<<d<<" cua ma tran Khong tang dan.\n"; cout << "\nVi tri giam: "; cout << setw(8) << "a[" << d << "][" << j << "] = " << fixed << setprecision(2) << a[d][j]; return; } } cout << "\nDong " << d << " cua ma tran Tang dan.\n"; }
[ "hhmy1995@gmail.com" ]
hhmy1995@gmail.com
9c4f405d4ba276e9d1807e3bd1e08f1079af0cc0
dbcf311d97da672c49f2753cf927ec4eb93b5fc0
/cpp04/ex03/Ice.cpp
d998d7da78c044ca8da2dc24c237639ec58c2049
[]
no_license
ekmbcd/Cpp_Piscine
fdbcd5b408ecba504e328f143caf9146fef838b6
b8d4123229f362e0e50acc65020f1ded8d3d073a
refs/heads/main
2023-05-01T06:05:11.494469
2021-05-12T16:20:22
2021-05-12T16:20:22
361,516,339
0
0
null
null
null
null
UTF-8
C++
false
false
423
cpp
#include "Ice.hpp" Ice::Ice() : AMateria("ice") {} Ice::Ice(const Ice & src) { *this = src; } Ice::~Ice() { } Ice & Ice::operator=(const Ice & src) { _xp = src._xp; return(*this); } AMateria* Ice::clone() const { AMateria * clone = new Ice; *clone = *this; return (clone); } void Ice::use(ICharacter& target) { std::cout << "* shoots an ice bolt at " << target.getName() << " *" << std::endl; increaseXP(); }
[ "ekmbcd@gmail.com" ]
ekmbcd@gmail.com
286142193f36c386481a5a90822b6fbf30debac6
2dd571c2d8b30d5d0c4fcb0beaf9e762dbd4174a
/opencv/widget.cpp
26ee26053c9e67265e94d10a8306dc404f32690e
[]
no_license
Baiyun-u-smartAI/QT
5e43af83828f12dc2f1048fe73a6822f75600275
58c73820be82fe837f26bc2c81918ea575b4d27a
refs/heads/master
2023-04-27T09:30:39.169330
2023-04-26T01:03:39
2023-04-26T01:03:39
167,105,787
0
0
null
null
null
null
UTF-8
C++
false
false
447
cpp
#include "widget.h" #include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); } Widget::~Widget() { delete ui; } //QPixmap convert2QT(const cv::Mat &src) //{ // cv::cvtColor(src,src,cv::COLOR_BGR2RGB); // QImage imdisplay((uchar*)src.data, src.cols, src.rows, src.step, QImage::Format_RGB888); // return QPixmap::fromImage(imdisplay); //}
[ "noreply@github.com" ]
noreply@github.com
69e75e13fb6846e508cbfcb95342ca0a92bd2c96
3b9b4049a8e7d38b49e07bb752780b2f1d792851
/src/chrome/common/instant_types.h
329cf3fe0aa9f632b8fadc010e22e6056c6f424f
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
webosce/chromium53
f8e745e91363586aee9620c609aacf15b3261540
9171447efcf0bb393d41d1dc877c7c13c46d8e38
refs/heads/webosce
2020-03-26T23:08:14.416858
2018-08-23T08:35:17
2018-09-20T14:25:18
145,513,343
0
2
Apache-2.0
2019-08-21T22:44:55
2018-08-21T05:52:31
null
UTF-8
C++
false
false
5,796
h
// Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_COMMON_INSTANT_TYPES_H_ #define CHROME_COMMON_INSTANT_TYPES_H_ #include <stdint.h> #include <string> #include <utility> #include "base/strings/string16.h" #include "url/gurl.h" // ID used by Instant code to refer to objects (e.g. Autocomplete results, Most // Visited items) that the Instant page needs access to. typedef int InstantRestrictedID; // A wrapper to hold Instant suggested text and its metadata. Used to tell the // server what suggestion to prefetch. struct InstantSuggestion { InstantSuggestion(); InstantSuggestion(const base::string16& in_text, const std::string& in_metadata); ~InstantSuggestion(); // Full suggested text. base::string16 text; // JSON metadata from the server response which produced this suggestion. std::string metadata; }; // The alignment of the theme background image. enum ThemeBackgroundImageAlignment { THEME_BKGRND_IMAGE_ALIGN_CENTER, THEME_BKGRND_IMAGE_ALIGN_LEFT, THEME_BKGRND_IMAGE_ALIGN_TOP, THEME_BKGRND_IMAGE_ALIGN_RIGHT, THEME_BKGRND_IMAGE_ALIGN_BOTTOM, THEME_BKGRND_IMAGE_ALIGN_LAST = THEME_BKGRND_IMAGE_ALIGN_BOTTOM, }; // The tiling of the theme background image. enum ThemeBackgroundImageTiling { THEME_BKGRND_IMAGE_NO_REPEAT, THEME_BKGRND_IMAGE_REPEAT_X, THEME_BKGRND_IMAGE_REPEAT_Y, THEME_BKGRND_IMAGE_REPEAT, THEME_BKGRND_IMAGE_LAST = THEME_BKGRND_IMAGE_REPEAT, }; // The RGBA color components for the text and links of the theme. struct RGBAColor { RGBAColor(); ~RGBAColor(); bool operator==(const RGBAColor& rhs) const; // The color in RGBA format where the R, G, B and A values // are between 0 and 255 inclusive and always valid. uint8_t r; uint8_t g; uint8_t b; uint8_t a; }; // Theme background settings for the NTP. struct ThemeBackgroundInfo { ThemeBackgroundInfo(); ~ThemeBackgroundInfo(); bool operator==(const ThemeBackgroundInfo& rhs) const; // True if the default theme is selected. bool using_default_theme; // The theme background color in RGBA format always valid. RGBAColor background_color; // The theme text color in RGBA format. RGBAColor text_color; // The theme link color in RGBA format. RGBAColor link_color; // The theme text color light in RGBA format. RGBAColor text_color_light; // The theme color for the header in RGBA format. RGBAColor header_color; // The theme color for the section border in RGBA format. RGBAColor section_border_color; // The theme id for the theme background image. // Value is only valid if there's a custom theme background image. std::string theme_id; // The theme background image horizontal alignment is only valid if |theme_id| // is valid. ThemeBackgroundImageAlignment image_horizontal_alignment; // The theme background image vertical alignment is only valid if |theme_id| // is valid. ThemeBackgroundImageAlignment image_vertical_alignment; // The theme background image tiling is only valid if |theme_id| is valid. ThemeBackgroundImageTiling image_tiling; // The theme background image height. // Value is only valid if |theme_id| is valid. uint16_t image_height; // True if theme has attribution logo. // Value is only valid if |theme_id| is valid. bool has_attribution; // True if theme has an alternate logo. bool logo_alternate; }; struct InstantMostVisitedItem { InstantMostVisitedItem(); InstantMostVisitedItem(const InstantMostVisitedItem& other); ~InstantMostVisitedItem(); // The URL of the Most Visited item. GURL url; // The title of the Most Visited page. May be empty, in which case the |url| // is used as the title. base::string16 title; // The external URL of the thumbnail associated with this page. GURL thumbnail; // The external URL of the favicon associated with this page. GURL favicon; // The external URL that should be pinged when this item is suggested/clicked. GURL impression_url; GURL click_url; // True if it's a server side suggestion. // Otherwise, it's a client side suggestion. bool is_server_side_suggestion; }; // An InstantMostVisitedItem along with its assigned restricted ID. typedef std::pair<InstantRestrictedID, InstantMostVisitedItem> InstantMostVisitedItemIDPair; // Embedded search request logging stats params. extern const char kSearchQueryKey[]; extern const char kOriginalQueryKey[]; extern const char kRLZParameterKey[]; extern const char kInputEncodingKey[]; extern const char kAssistedQueryStatsKey[]; // A wrapper to hold embedded search request params. Used to tell the server // about the search query logging stats at the query submission time. struct EmbeddedSearchRequestParams { EmbeddedSearchRequestParams(); // Extracts the request params from the |url| and initializes the member // variables. explicit EmbeddedSearchRequestParams(const GURL& url); ~EmbeddedSearchRequestParams(); // Submitted search query. base::string16 search_query; // User typed query. base::string16 original_query; // RLZ parameter. base::string16 rlz_parameter_value; // Character input encoding type. base::string16 input_encoding; // The optional assisted query stats, aka AQS, used for logging purposes. // This string contains impressions of all autocomplete matches shown // at the query submission time. For privacy reasons, we require the // search provider to support HTTPS protocol in order to receive the AQS // param. // For more details, see http://goto.google.com/binary-clients-logging. base::string16 assisted_query_stats; }; #endif // CHROME_COMMON_INSTANT_TYPES_H_
[ "changhyeok.bae@lge.com" ]
changhyeok.bae@lge.com
d64e86d9b84c705a9bd4626b773243578bbed498
0a999d3115e5a13c25f7e6a55bb44f436318b7c6
/ex01/Form.hpp
f769bdfabd9fbb41b113d8e5bca8602ee122e21e
[]
no_license
ZectorJay/CPP_MODULE_05
abdadc9fd0800a03b39c66caa07dbbab0ab624e5
e2214667a043d8f2cefa8d8e0b69ed7cba1226aa
refs/heads/main
2023-06-16T17:26:11.870438
2021-07-08T16:00:50
2021-07-08T16:00:50
382,380,485
0
0
null
null
null
null
UTF-8
C++
false
false
1,889
hpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Form.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: hmickey <hmickey@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/07/05 17:31:17 by hmickey #+# #+# */ /* Updated: 2021/07/06 09:06:33 by hmickey ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FORM_HPP # define FORM_HPP # include "Bureaucrat.hpp" class Bureaucrat; class Form { public: Form( std::string name, short int gradeToSign, short int _gradeToExec ); Form (Form const & src ); ~Form(){} Form & operator= (Form const & src ); std::string const getName() const; bool getSignStatus() const; short int const getGradeToSign() const; short int const getGradeToExec() const; int beSigned( Bureaucrat const & signer ); class GradeTooHighException : public std::exception { public: GradeTooHighException(){}; char const *what() const throw(); }; class GradeTooLowException: public std::exception { public: GradeTooLowException(){} char const *what() const throw(); }; private: Form() : _name(NULL), _sign(0), _gradeToExec(0), _gradeToSign(0) {} std::string const _name; bool _sign; short int const _gradeToSign; short int const _gradeToExec; }; std::ostream & operator<<(std::ostream & o, Form const & src ); #endif
[ "zKimiko@yandex.ru" ]
zKimiko@yandex.ru
d2deda83fa3356ef3f9683a304e3883fd8668ee1
2ce74641bdcb82c8d5183915b3830e296efe7ef5
/백준 11048/백준 11048/소스.cpp
f6a48665a6bf7552f5d4ab78f421a51176634cd9
[]
no_license
jhhan00/Baekjoon-Online-Judge-2019
c4c5c33ddb85ed7b5b53dd237067b1b81247382f
84b3aeae71b2a8c549aae6e574847edb55868cd1
refs/heads/main
2023-03-20T12:23:39.296658
2021-03-04T14:49:01
2021-03-04T14:49:01
344,501,183
0
0
null
null
null
null
UTF-8
C++
false
false
822
cpp
#pragma warning(disable : 4996) #include <iostream> using namespace std; int miro[1000][1000]; int candy[1000][1000]; int main() { freopen("input.txt", "r", stdin); int n, m, i, j; cin >> n >> m; for (i = 0; i < n; i++) for (j = 0; j < m; j++) cin >> miro[i][j]; candy[0][0] = miro[0][0]; for (i = 1; i < m; i++) candy[0][i] = miro[0][i] + candy[0][i - 1]; for (i = 1; i < n; i++) candy[i][0] = miro[i][0] + candy[i - 1][0]; for (i = 1; i < n; i++) { for (j = 1; j < m; j++) { if (candy[i - 1][j] + miro[i][j] > candy[i][j - 1] + miro[i][j]) candy[i][j] = candy[i - 1][j] + miro[i][j]; else candy[i][j] = candy[i][j - 1] + miro[i][j]; } } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) cout << candy[i][j] << " "; cout << "\n"; } cout << candy[n - 1][m - 1] << endl; }
[ "48585234+jhhan00@users.noreply.github.com" ]
48585234+jhhan00@users.noreply.github.com
3421eda5b93825711a4453cd327c614aaf08c351
ccebd834ec504593fbe26736f5d05835bec4c1b4
/include/MvrIrrfDevice.h
d1706f8ed11fcefb8af3c8a3801547591c8de109
[]
no_license
yjcs1990/mvr
bc32b286d9e49f1797361953c14c01772e848841
80a3e7dd4ea9857bbc8b75a3e4099d90d9972ab7
refs/heads/master
2020-12-30T11:15:40.387284
2017-07-19T06:38:56
2017-07-19T06:38:56
91,542,255
0
0
null
null
null
null
UTF-8
C++
false
false
1,516
h
#ifndef MVRIRRFDEVICE_H #define MVRIRRFDEVICE_H #include "mvriaTypedefs.h" #include "MvrRangeDevice.h" #include "MvrFunctor.h" #include "MvrRobot.h" /// A class for connecting to a PB-9 and managing the resulting data /** This class is for use with a PB9 IR rangefinder. It has the packethandler necessary to process the packets, and will put the data into MvrRangeBuffers for use with obstacle avoidance, etc. The PB9 is still under development, and only works on an H8 controller running AROS. */ class MvrIrrfDevice : public MvrRangeDevice { public: /// Constructor MVREXPORT MvrIrrfDevice(size_t currentBufferSize = 91, size_t cumulativeBufferSize = 273, const char * name = "irrf"); /// Destructor MVREXPORT virtual ~MvrIrrfDevice(); /// The packet handler for use when connecting to an H8 micro-controller MVREXPORT bool packetHandler(MvrRobotPacket *packet); /// Maximum range for a reading to be added to the cumulative buffer (mm) MVREXPORT void setCumulativeMaxRange(double r) { myCumulativeMaxRange = r; } MVREXPORT virtual void setRobot(MvrRobot *); protected: MvrRetFunctor1C<bool, MvrIrrfDevice, MvrRobotPacket *> myPacketHandler; MvrTime myLastReading; MVREXPORT void processReadings(void); double myCumulativeMaxRange; double myFilterNearDist; double myFilterFarDist; std::map<int, MvrSensorReading *> myIrrfReadings; }; #endif // ARIRRFDEVICE_H
[ "yjcs1990@163.com" ]
yjcs1990@163.com
27c9a15b30ba5322cc97f862471edbf3e6090b50
ee9ae08815d2f792b6b610ec7193302d64248132
/xr_3da/xrGame/WeaponWalther.h
1dbcd7598fa4e3ad1792ddfd4714e3e773ce0c05
[]
no_license
xrLil-Batya/Yara-SDK
e77a15ff6960b7c71cd07e628ed818c7e8c29e64
cec683d61d9be9759108a67baf6ac90f222f006b
refs/heads/master
2023-07-17T08:01:53.958929
2021-08-26T01:08:34
2021-08-26T01:08:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
369
h
#pragma once #include "WeaponPistol.h" #include "script_export_space.h" class CWeaponWalther : public CWeaponPistol { typedef CWeaponPistol inherited; public: CWeaponWalther(void); virtual ~CWeaponWalther(void); DECLARE_SCRIPT_REGISTER_FUNCTION }; add_to_type_list(CWeaponWalther) #undef script_type_list #define script_type_list save_type_list(CWeaponWalther)
[ "yros1av@yandex.ru" ]
yros1av@yandex.ru
3a19ddeff39d92869a39a675c4f1823375e807dc
65742553e5efdfe8f09ee93fbd7b3339bc75563e
/Kapital06/Exercise6.3.2/Student.h
4fb622a02ebb14d6987d7c31b0700df31868eef7
[]
no_license
ThisIsRWTH/CPP__VS_Tutorial
a649eb946de58db2995bfd5e512cd9a3b2f5d4fe
ae9770afbd642af35b5fafda5b4c2bab6c5d6fb8
refs/heads/master
2020-03-14T17:47:26.011276
2018-07-08T22:50:49
2018-07-08T22:50:49
131,728,295
0
0
null
null
null
null
UTF-8
C++
false
false
450
h
#ifndef STUDENT_H_ #define STUDENT_H_ #include <string> class Student { public: Student(); Student(unsigned int matNr, std::string name, std::string dateOfBirth, std::string address); unsigned int getMatNr() const; std::string getName() const; std::string getDateOfBirth() const; std::string getAddress() const; void print() const; private: unsigned int matNr; std::string name; std::string dateOfBirth; std::string address; }; #endif
[ "mysoodonims@gmail.com" ]
mysoodonims@gmail.com
5699f19b14a8f4d3de55e4ffb0aa49feb0f78405
79de021aec11f4c802d3105e350ff32acd0e8fb5
/Community_c++/main_hierarchy.cpp
2296acfbb36100480ad50f3f6abae702dfaa9bdf
[]
no_license
SkipToYourSoul/communityFinal
49d3909f7e6c6bd35a8a03b934cb1e5263230c32
f82bdc4107622afcf3792e28907d0a2c2670d899
refs/heads/master
2021-01-23T02:54:36.155448
2013-12-20T04:49:29
2013-12-20T04:49:29
15,329,977
1
0
null
null
null
null
UTF-8
C++
false
false
3,358
cpp
// File: main_hierarchy.cpp // -- output community structure handling (number of levels, communities of one level) //----------------------------------------------------------------------------- // Community detection // Based on the article "Fast unfolding of community hierarchies in large networks" // Copyright (C) 2008 V. Blondel, J.-L. Guillaume, R. Lambiotte, E. Lefebvre // // This program must not be distributed without agreement of the above mentionned authors. //----------------------------------------------------------------------------- // Author : E. Lefebvre, adapted by J.-L. Guillaume // Email : jean-loup.guillaume@lip6.fr // Location : Paris, France // Time : February 2008 //----------------------------------------------------------------------------- // see readme.txt for more details #include <stdlib.h> #include <stdio.h> #include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <map> #include <set> #include <algorithm> using namespace std; int display_level = -1; char *filename = NULL; void usage(char *prog_name, const char *more) { cerr << more; cerr << "usage: " << prog_name << " input_file [options]" << endl << endl; cerr << "input_file: read the community tree from this file." << endl; cerr << "-l xx\t display the community structure for the level xx." << endl; cerr << "\t outputs the community for each node." << endl; cerr << "\t xx must belong to [-1,N] if N is the number of levels." << endl; cerr << "-n\t displays the number of levels and the size of each level." << endl; cerr << "\t equivalent to -l -1." << endl; cerr << "-h\tshow this usage message." << endl; exit(0); } void parse_args(int argc, char **argv) { if (argc<2) usage(argv[0], "Bad arguments number\n"); for (int i = 1; i < argc; i++) { if(argv[i][0] == '-') { switch(argv[i][1]) { case 'l': display_level = atoi(argv[i+1]); i++; break; case 'n': display_level = -1; break; default: usage(argv[0], "Unknown option\n"); } } else { if (filename==NULL) filename = argv[i]; else usage(argv[0], "More than one filename\n"); } } if (filename==NULL) usage(argv[0], "No input file has been provided.\n"); } int main(int argc, char **argv) { parse_args(argc, argv); vector<vector<int> >levels; ifstream finput; finput.open(filename,fstream::in); int l=-1; while (!finput.eof()) { int node, nodecomm; finput >> node >> nodecomm; if (finput) { if (node==0) { l++; levels.resize(l+1); } levels[l].push_back(nodecomm); } } if (display_level==-1) { cout << "Number of levels: " << levels.size() << endl; for (unsigned int i=0 ; i<levels.size();i++) cout << "level " << i << ": " << levels[i].size() << " nodes" << endl; } else if (display_level<0 || (unsigned)display_level>=levels.size()) { cerr << "Incorrect level\n"; } else { vector<int> n2c(levels[0].size()); for (unsigned int i=0 ; i<levels[0].size() ; i++) n2c[i]=i; for (l=0 ; l<display_level ; l++) for (unsigned int node=0 ; node<levels[0].size() ; node++) n2c[node] = levels[l][n2c[node]]; for (unsigned int node=0 ; node<levels[0].size() ; node++) cout << node << " " << n2c[node] << endl; } system("pause"); }
[ "ly901001@gmail.com" ]
ly901001@gmail.com
132aea5099c9ee708ba1cecfc11bf98972710486
1dbb60db92072801e3e7eaf6645ef776e2a26b29
/server/src/common/proto/viptimelimitshop/SUserVipTimeLimitGoods.h
93ee77f462d9d0287d967216c4f16a69865efc3a
[]
no_license
atom-chen/phone-code
5a05472fcf2852d1943ad869b37603a4901749d5
c0c0f112c9a2570cc0390703b1bff56d67508e89
refs/heads/master
2020-07-05T01:15:00.585018
2015-06-17T08:52:21
2015-06-17T08:52:21
202,480,234
0
1
null
2019-08-15T05:36:11
2019-08-15T05:36:09
null
UTF-8
C++
false
false
1,373
h
#ifndef _SUserVipTimeLimitGoods_H_ #define _SUserVipTimeLimitGoods_H_ #include <weedong/core/seq/seq.h> /*vip限时商店-黄少杰*/ class SUserVipTimeLimitGoods : public wd::CSeq { public: uint32 vip_package_id; //礼包等级 uint32 buyed_count; //购买数量 uint32 next_buy_time; //下次可以购买的时间 SUserVipTimeLimitGoods() : vip_package_id(0), buyed_count(0), next_buy_time(0) { } virtual ~SUserVipTimeLimitGoods() { } virtual wd::CSeq* clone(void) { return ( new SUserVipTimeLimitGoods(*this) ); } virtual bool write( wd::CStream &stream ) { uint32 uiSize = 0; return loop( stream, wd::CSeq::eWrite, uiSize ); } virtual bool read( wd::CStream &stream ) { uint32 uiSize = 0; return loop( stream, wd::CSeq::eRead, uiSize ); } bool loop( wd::CStream &stream, wd::CSeq::ELoopType eType, uint32& uiSize ) { return wd::CSeq::loop( stream, eType, uiSize ) && TFVarTypeProcess( vip_package_id, eType, stream, uiSize ) && TFVarTypeProcess( buyed_count, eType, stream, uiSize ) && TFVarTypeProcess( next_buy_time, eType, stream, uiSize ) && loopend( stream, eType, uiSize ); } operator const char* () { return "SUserVipTimeLimitGoods"; } }; #endif
[ "757690733@qq.com" ]
757690733@qq.com
7ffaa7572b55d71f5e97d0069e472756e73b52c2
36ce92927aad48af03f2d2d38c3979261f47697e
/doc/MSc/msc_students/former/ChristianF/ThesisCodes/Hartree-Fock/quantumstate.cpp
b15bea88b8964f1bb85117925aece9ebea49e15b
[ "CC0-1.0" ]
permissive
CompPhysics/ThesisProjects
47fe8f0215525bca42cc76485c75101c9ab10a36
8267e3c9b48ee6f46de391e0ec1cb250ae6476e2
refs/heads/master
2023-08-16T15:14:40.203860
2023-08-09T14:53:48
2023-08-09T14:53:48
42,999,924
9
4
null
null
null
null
UTF-8
C++
false
false
241
cpp
#include "quantumstate.h" QuantumState::QuantumState() { } void QuantumState::setQuantumNumbers(int n, int m, int sm, double s) { m_n = n; m_m = m; m_sm = sm; m_s = s; } void QuantumState::flipSpin() { m_sm *= -1; }
[ "morten.hjorth-jensen@fys.uio.no" ]
morten.hjorth-jensen@fys.uio.no
b35a2ca0ce81a08e893f47d16ff72ea2409f5718
625b8648879193c9449da751643ba8c969ffc177
/DM2212_Framework/Base/Source/GameAsset/Customer.h
257ec9b05ff29e88cb123180d5100915883abdc4
[]
no_license
TammieTSF/AI
78b03be498bf735edc89d11718013b0c5b77cb8d
f04b676a53b1ad0f170e21ec72d9e8a196b2f746
refs/heads/master
2021-01-10T15:05:25.477758
2015-12-17T03:41:02
2015-12-17T03:41:02
46,915,658
0
1
null
null
null
null
UTF-8
C++
false
false
670
h
#pragma once #include "../GameObject.h" class Customer : public GameObject { public: enum GENDER { g_MALE, // done g_FEMALE, // done }; enum STATE { s_ENTER,// done s_REQUEST, // done s_LEAVE, // done }; Customer(); ~Customer(); GENDER gender; STATE state; // Gender Setting void setToMale(); // set gender to male void setToFemale(); // set gender to female bool isMale(); // get the male gender bool isFemale(); // get the female gender // States Setting void SetEnterState(); void SetRequestState(); void SetLeaveState(); bool isEnter(); bool isRequest(); bool isLeave(); //Get the state of the customer int getState(); };
[ "vinceajy93@hotmail.com" ]
vinceajy93@hotmail.com
fd4597cadfaac25191feb38943116cab9a48ea30
005cb1c69358d301f72c6a6890ffeb430573c1a1
/Pods/Headers/Private/GeoFeatures/boost/geometry/util/calculation_type.hpp
019b25fbc8a93ea7fe877432524f01c59d655135
[ "Apache-2.0" ]
permissive
TheClimateCorporation/DemoCLUs
05588dcca687cc5854755fad72f07759f81fe673
f343da9b41807694055151a721b497cf6267f829
refs/heads/master
2021-01-10T15:10:06.021498
2016-04-19T20:31:34
2016-04-19T20:31:34
51,960,444
0
0
null
null
null
null
UTF-8
C++
false
false
82
hpp
../../../../../../GeoFeatures/GeoFeatures/boost/geometry/util/calculation_type.hpp
[ "tommy.rogers@climate.com" ]
tommy.rogers@climate.com
ba7b3958e1a30a85d4e6bf0c14c1dc54871ed1d5
eb8d36a89dbaeffeedd8584d970aa2b33a8b2c6e
/CQ-0143/sequence/sequence.cpp
8ae47a1571831d5dd3fc6a96c61b412ad9b8d991
[]
no_license
mcfx0/CQ-NOIP-2021
fe3f3a88c8b0cd594eb05b0ea71bfa2505818919
774d04aab2955fc4d8e833deabe43e91b79632c2
refs/heads/main
2023-09-05T12:41:42.711401
2021-11-20T08:59:40
2021-11-20T08:59:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
764
cpp
#include<bits/stdc++.h> using namespace std; int n,m,k; long long ans; int v[31],cnt[110],num[31],ccnt[110]; void dfs(int x,int h){ if(x>n){ memset(ccnt,0,sizeof(ccnt)); int num1=0; for(int i=0;i<=h;i++){ ccnt[i]=cnt[i]; } for(int i=0;i<=h+5;i++){ if(ccnt[i]%2==1)num1++; ccnt[i+1]+=ccnt[i]/2; } if(num1<=k){ long long ji=1; for(int i=1;i<=n;i++){ ji=(ji%998244353*v[num[i]])%998244353; } ans=(ans+ji)%998244353; } return; } for(int i=0;i<=m;i++){ cnt[i]++; num[x]=i; h=max(h,i); dfs(x+1,h); cnt[i]--; } } int main(){ freopen("sequence.in","r",stdin); freopen("sequence.out","w",stdout); cin>>n>>m>>k; for(int i=0;i<=m;i++)cin>>v[i]; dfs(1,0); cout<<ans; return 0; fclose(stdin); fclose(stdout); }
[ "3286767741@qq.com" ]
3286767741@qq.com
3c142a60a6e256582cf2985a72f308490c6e4338
451ff5a40071578341ca195908276992bd5396fa
/Codeforces/900/B6-A.cpp
ac302f9dfd1c376181abc4b9fca6593006519dd5
[]
no_license
Tanjim131/Problem-Solving
ba31d31601798ba585a3f284bb169d67794af6c0
6dc9c0023058655ead7da7da08eed11bf48a0dfa
refs/heads/master
2023-05-02T06:38:34.014689
2021-05-14T18:26:15
2021-05-14T18:26:15
267,421,671
5
0
null
null
null
null
UTF-8
C++
false
false
1,132
cpp
#include <iostream> #include <vector> #include <cmath> using std::cin; using std::cout; // nearly equal to 0 ? bool isNearlyEqual(double a){ constexpr double EPS = 1e-7; return std::abs(a) < EPS; } bool isNonDegenerate(const std::vector <int> &edge){ int a = edge[0], b = edge[1], c = edge[2]; return a + b > c && a + c > b && b + c > a; } bool isDegenerate(const std::vector <int> &edge){ int a = edge[0], b = edge[1], c = edge[2]; double s = (a + b + c) / 2.0; double area = s * (s - a) * (s - b) * (s - c); return isNearlyEqual(area); } int main(int argc, char const *argv[]) { int a,b,c,d; cin >> a >> b >> c >> d; std::vector <std::vector<int>> edges{ {a,b,c}, {a,b,d}, {a,c,d}, {b,c,d} }; for(int i = 0 ; i < edges.size() ; ++i){ if(isNonDegenerate(edges[i])){ cout << "TRIANGLE\n"; return 0; } } for(int i = 0 ; i < edges.size() ; ++i){ if(isDegenerate(edges[i])){ cout << "SEGMENT\n"; return 0; } } cout << "IMPOSSIBLE\n"; return 0; }
[ "1505082.tbf@ugrad.cse.buet.ac.bd" ]
1505082.tbf@ugrad.cse.buet.ac.bd
90f3dc37a9f3b79baaa50cae2bc215e1ce80b315
0e87292cf33fc8a4289af492ffdc363808d13725
/Otchet.cpp
9cf651fc0337a3a2c2ba1f53056e891ac25cbbba
[]
no_license
ErshovDA2112/TestWork
6c97b7132531a55e42bb9892462230dccf0c8171
16caf2e37c4584f52d2fa61fc26df7335d7ea081
refs/heads/master
2020-03-21T17:56:47.882002
2018-06-29T07:32:06
2018-06-29T07:32:06
138,863,577
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
38,315
cpp
//--------------------------------------------------------------------------- //Что-то подправил #include <vcl.h> #include <fstream> #include <iostream> #pragma hdrstop #include "Otchet.h" #include "Main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" const String TMP_SCHET = "SELECT [Param_1] \ ,[Param_2] \ ,[Param_3] \ ,[Param_4] \ ,[Param_5] \ ,[Param_6] \ ,[Param_7] \ ,[Param_8] \ ,[Param_9] \ ,[Param_10] \ ,[Param_11] \ ,[Param_12] \ ,[Param_13] \ FROM [MyTempTable] ORDER BY _id ASC"; const String MY_SCHET = "SELECT [_id] \ , row_number() over (order by _id desc) as [№ ] \ ,[CODE] 'Код' \ ,CONCAT(case \ when [MONTH] = '1' then 'Январь' \ when [MONTH] = '2' then 'Февраль' \ when [MONTH] = '3' then 'Март' \ when [MONTH] = '4' then 'Апрель' \ when [MONTH] = '5' then 'Май' \ when [MONTH] = '6' then 'Июнь' \ when [MONTH] = '7' then 'Июль' \ when [MONTH] = '8' then 'Август' \ when [MONTH] = '9' then 'Сентябрь' \ when [MONTH] = '10' then 'Октябрь' \ when [MONTH] = '11' then 'Ноябрь' \ when [MONTH] = '12' then 'Декабрь' \ end, \ ' ', \ [YEAR]) 'Отчетный период' \ ,[NSCHET] 'Номер счёта' \ ,[DISP] 'Тип дисп.' \ ,(case when IS_HMP = '1' \ then 'да' \ else 'нет' end) 'ВМП' \ ,[DSCHET] 'Дата счета' \ FROM [R_SCHET]"; String Zapros_R_SL = "SELECT R_SL.DS1 \ ,SPR_M001._id \ ,R_SL.DN \ ,R_PERS.DR \ FROM R_SL \ LEFT JOIN SPR_M001 ON (SPR_M001.MKB10 = R_SL.DS1) \ LEFT JOIN R_Z_SL on R_SL._zslid = R_Z_SL._id \ LEFT JOIN R_ZAP on R_Z_SL._idzap = R_ZAP._id \ LEFT JOIN R_PACIENT on R_ZAP._pid = R_PACIENT._id \ LEFT JOIN R_PERS on R_PACIENT.ID_PAC = R_PERS.ID_PAC \ WHERE R_SL._zslid in (SELECT R_Z_SL._id \ FROM R_Z_SL \ WHERE R_Z_SL._idzap in (SELECT R_ZAP._id \ FROM R_ZAP \ WHERE R_ZAP._schet_id = '"; String Zapros_R_SL_D = " SELECT R_SL_D.DS1 \ ,SPR_M001._id \ ,R_SL_D.PR_D_N \ ,R_SL_D.DS1_PR \ FROM R_SL_D \ LEFT JOIN SPR_M001 ON (SPR_M001.MKB10 = R_SL_D.DS1) \ WHERE R_SL_D._zslid in (SELECT R_Z_SL_D._id \ FROM R_Z_SL_D \ WHERE R_Z_SL_D._idzap in (SELECT R_ZAP._id \ FROM R_ZAP \ WHERE R_ZAP._schet_id = '"; String Zapros_R_SL_HMP = " SELECT R_SL_HMP.DS1 \ ,SPR_M001._id \ ,R_PERS.DR \ FROM R_SL_HMP \ LEFT JOIN SPR_M001 ON (SPR_M001.MKB10 = R_SL_HMP.DS1) \ LEFT JOIN R_Z_SL_HMP on R_SL_HMP._zslid = R_Z_SL_HMP._id \ LEFT JOIN R_ZAP on R_Z_SL_HMP._idzap = R_ZAP._id \ LEFT JOIN R_PACIENT on R_ZAP._pid = R_PACIENT._id \ LEFT JOIN R_PERS on R_PACIENT.ID_PAC = R_PERS.ID_PAC \ WHERE R_SL_HMP._zslid in (SELECT R_Z_SL_HMP._id \ FROM R_Z_SL_HMP \ WHERE R_Z_SL_HMP._idzap in (SELECT R_ZAP._id \ FROM R_ZAP \ WHERE R_ZAP._schet_id = '"; struct Tab_Param { String Param_1, Param_2, Param_3, Param_4, Param_5, Param_6, Param_7, Param_8, Param_9, Param_10, Param_11, Param_12, Param_13, Param_14; } Struct_Param; AnsiString Src; TTreeNode *NewRoot; AnsiString Dir1; AnsiString Address; int n = 0; extern int SchetForYarik; int Vozrast_0_4; int Vozrast_5_9; int Vozrast_14_15; int Vozrast_15_18; int KolCount; int SnyatDisp; int SostoitDisp; int VzyatDisp; int TypeSchet; int DS1_PR; int Vzyato_10; int Viyavleno_11; int ViyavlenoProfOsmoyr; int ViyavlenoDisp; String MyCHET; String YEAR_OT; String MONTH_OT; int KolPers; int Sovp; TForm12 *Form12; //--------------------------------------------------------------------------- __fastcall TForm12::TForm12(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm12::FormActivate(TObject *Sender) { TTreeNode *Node; this->ADOQuery1->Active = False; this->ADOQuery1->SQL->Clear(); this->ADOQuery1->SQL->Add(MY_SCHET); this->ADOQuery1->Active = True; UpdateLen(); this->Constraints->MaxHeight = this->Constraints->MinHeight; this->Constraints->MaxWidth = this->Constraints->MinWidth; this->DBGrid1CellClick(0); Dir1 = "D:\\WORK\\REPT" ; n = 0; this->TreeView1->Items->BeginUpdate(); this->TreeView1->Items->Clear(); //Очистка списка this->TreeView1->Items->Add(NULL,Dir1); Node = this->TreeView1->Items->Item[0]; Node->ImageIndex = n; CreateTreeView(Dir1, Node); this->TreeView1->Items->EndUpdate(); this->Label3->Caption = "Номер счета : " + IntToStr(SchetForYarik); } //--------------------------------------------------------------------------- void __fastcall TForm12::UpdateLen() { int j; int Maxlen = 0; int TekLen = 0; String DataLen = ""; String ItogData = ""; this->DBGrid1->Visible = false; if (this->ADOQuery1->RecordCount > 0) { this->ADOQuery1->Open(); for (j = 0; j < this->ADOQuery1->FieldCount; j++) { DataLen = this->ADOQuery1->Fields->Fields[j]->FieldName; Maxlen = this->DBGrid1->Canvas->TextWidth(DataLen); for (this->ADOQuery1->First(); !this->ADOQuery1->Eof; this->ADOQuery1->Next()) { ItogData = this->ADOQuery1->FieldByName(DataLen)->AsString; TekLen = this->DBGrid1->Canvas->TextWidth(ItogData); if (TekLen > Maxlen) Maxlen = TekLen; } if (Maxlen == 0) { this->DBGrid1->Columns->Items[j]->Width = 6; } else { this->DBGrid1->Columns->Items[j]->Width = Maxlen + 7; this->DBGrid1->Columns->Items[j]->Alignment = taLeftJustify; } } this->ADOQuery1->First(); this->DBGrid1->Visible = true; this->DBGrid1->DataSource->DataSet->Fields->Fields[1]->Visible = false; } } //--------------------------------------------------------------------------- void __fastcall TForm12::CreateTreeView(AnsiString Dir, TTreeNode *Root) { TSearchRec sr; Src = Dir; AnsiString Dir_1; if (FindFirst(Src+"\\*", faAnyFile, sr) == 0) { do { if (!((sr.Name == ".") || (sr.Name == ".."))) { Dir_1 = Src+"\\"+sr.Name; NewRoot = this->TreeView1->Items->AddChild(Root,sr.Name); n++; NewRoot->ImageIndex = n; CreateTreeView(Dir_1, NewRoot); // РЕКУРСИВНЫЙ ВЫЗОВ Src = Dir; } } while (FindNext(sr) == 0); FindClose(sr); } else { Root->ImageIndex = -1; } n--; } //--------------------------------------------------------------------------- void __fastcall TForm12::Button2Click(TObject *Sender) { TypeSchet = 0; KolPers = 0; Sovp = 0; String FisrtDS, SecondDS,TekName; int FisrtID, SecondID; String ZP; InfoShet(); Form7->QRLabel63->Caption = "Код по ОКЕИ: - Человек " + IntToStr(Sovp); Struct_Param.Param_13 = "!!!!"; String Zapros = "DELETE FROM [ITMed54].[dbo].[MyTempTable]"; this->ADOQuery3->Active = False; this->ADOQuery3->SQL->Clear(); this->ADOQuery3->SQL->Add(Zapros); this->ADOQuery3->ExecSQL(); char line[1024]; ifstream F("OTCHET\\Test.ini"); int Kol = 0; if(!F) { Abort(); } while(F.getline(line, sizeof(line))) { if (Kol == 0) Struct_Param.Param_1 = line; if (Kol == 1) Struct_Param.Param_2 = line; if (Kol == 2) FisrtDS = line; if (Kol == 3) { SecondDS = line; if (FisrtDS == SecondDS.SubString(1,3)) { Struct_Param.Param_3 = FisrtDS; } else { Struct_Param.Param_3 = FisrtDS + "-" + SecondDS.SubString(1,3); } PoiskDS_15_18(FisrtDS,SecondDS,1); //всего 14-18 [4] Struct_Param.Param_4 = IntToStr(KolCount); //из них юноши [7] Struct_Param.Param_5 = IntToStr(Vozrast_15_18); Struct_Param.Param_6 = IntToStr(VzyatDisp); Struct_Param.Param_7 = IntToStr(DS1_PR); Struct_Param.Param_8 = IntToStr(Vzyato_10); Struct_Param.Param_9 = IntToStr(ViyavlenoProfOsmoyr); Struct_Param.Param_10 = IntToStr(ViyavlenoDisp); Struct_Param.Param_11 = IntToStr(SnyatDisp); Struct_Param.Param_12 = IntToStr(SostoitDisp); } ZP = line; if (ZP == "//---------------") { Kol = 0; Zapros = "INSERT INTO [MyTempTable] ([Param_1], \ [Param_2], \ [Param_3], \ [Param_4], \ [Param_5], \ [Param_6], \ [Param_7], \ [Param_8], \ [Param_9], \ [Param_10], \ [Param_11], \ [Param_12], \ [Param_13]) \ OUTPUT INSERTED._id VALUES ('" + Struct_Param.Param_1 + "'," + "'" + Struct_Param.Param_2 + "'," + "'" + Struct_Param.Param_3 + "'," + "'" + Struct_Param.Param_4 + "'," + "'" + Struct_Param.Param_5 + "'," + "'" + Struct_Param.Param_6 + "'," + "'" + Struct_Param.Param_7 + "'," + "'" + Struct_Param.Param_8 + "'," + "'" + Struct_Param.Param_9 + "'," + "'" + Struct_Param.Param_10 + "'," + "'" + Struct_Param.Param_11 + "'," + "'" + Struct_Param.Param_12 + "'," + "'" + Struct_Param.Param_13 + "')"; this->ADOQuery3->Active = False; this->ADOQuery3->SQL->Clear(); this->ADOQuery3->SQL->Add(Zapros); this->ADOQuery3->Active = True; continue; } if (Kol == 4) FisrtDS = line; if (Kol == 5) { SecondDS = line; PoiskDS_15_18(FisrtDS,SecondDS,2); if (FisrtDS == SecondDS.SubString(1,3)) { Struct_Param.Param_3 = Struct_Param.Param_3 + ", \n " + FisrtDS; } else { Struct_Param.Param_3 = Struct_Param.Param_3 + ", \n " + FisrtDS + "-" + SecondDS.SubString(1,3); } Struct_Param.Param_4 = IntToStr(StrToInt(Struct_Param.Param_4) + KolCount); } if (Kol == 6) FisrtDS = line; if (Kol == 7) { SecondDS = line; PoiskDS_15_18(FisrtDS,SecondDS,2); if (FisrtDS == SecondDS.SubString(1,3)) { Struct_Param.Param_3 = Struct_Param.Param_3 + ", \n " + FisrtDS; } else { Struct_Param.Param_3 = Struct_Param.Param_3 + ", \n " + FisrtDS + "-" + SecondDS.SubString(1,3); } Struct_Param.Param_4 = IntToStr(StrToInt(Struct_Param.Param_4) + KolCount); } Kol++; } Form7->ADOQuery3->Active = False; Form7->ADOQuery3->SQL->Clear(); Form7->ADOQuery3->SQL->Add(TMP_SCHET); Form7->ADOQuery3->Active = True; Form7->QRDBText1->DataField = Form7->ADOQuery3->Fields->Fields[0]->FieldName; Form7->QRDBText2->DataField = Form7->ADOQuery3->Fields->Fields[1]->FieldName; Form7->QRDBText3->DataField = Form7->ADOQuery3->Fields->Fields[2]->FieldName; Form7->QRDBText4->DataField = Form7->ADOQuery3->Fields->Fields[3]->FieldName; Form7->QRDBText5->DataField = Form7->ADOQuery3->Fields->Fields[4]->FieldName; Form7->QRDBText6->DataField = Form7->ADOQuery3->Fields->Fields[5]->FieldName; Form7->QRDBText7->DataField = Form7->ADOQuery3->Fields->Fields[6]->FieldName; Form7->QRDBText8->DataField = Form7->ADOQuery3->Fields->Fields[7]->FieldName; Form7->QRDBText9->DataField = Form7->ADOQuery3->Fields->Fields[8]->FieldName; Form7->QRDBText10->DataField = Form7->ADOQuery3->Fields->Fields[9]->FieldName; Form7->QRDBText11->DataField = Form7->ADOQuery3->Fields->Fields[10]->FieldName; Form7->QRDBText12->DataField = Form7->ADOQuery3->Fields->Fields[11]->FieldName; Form7->QRDBText13->DataField = Form7->ADOQuery3->Fields->Fields[12]->FieldName; // this->QRDBText27->DataField = this->ADOQuery2->Fields->Fields[13]->FieldName; Form7->QuickRep2->Preview() ; } //--------------------------------------------------------------------------- void __fastcall TForm12::TreeView1Click(TObject *Sender) { TTreeNode *CurItem, *Prev; if ( !TreeView1 -> Selected -> HasChildren ) { Prev = TreeView1 -> Selected; Address = Prev -> Text; while ( Prev ) { if ( Prev -> HasChildren ) Address = Prev -> Text + "\\" + Address; Prev = Prev -> Parent; } } this->Label1->Caption=Address; } //--------------------------------------------------------------------------- void __fastcall TForm12::TreeView1GetSelectedIndex(TObject *Sender, TTreeNode *Node) { Node->SelectedIndex = Node->ImageIndex; } //--------------------------------------------------------------------------- void __fastcall TForm12::TreeView1DblClick(TObject *Sender) { ShowMessage("Запуск отчетности. В стадии разработки"); } //--------------------------------------------------------------------------- void __fastcall TForm12::PoiskDS_0_4(String FisrtDS,String SecondDS, int TypeWork) { bool Work; if (TypeWork ==1 ) { Vozrast_0_4 = 0; Vozrast_5_9 = 0; KolCount = 0; SnyatDisp = 0; SostoitDisp = 0; VzyatDisp = 0; DS1_PR = 0; Vzyato_10 = 0; Viyavleno_11 = 0; } String DataTemp; int FisrtID, SecondID, Tek; String ZP ="SELECT SPR_M001._id \ FROM SPR_M001 \ WHERE SPR_M001.MKB10 = '" + FisrtDS + "'"; this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(ZP); this->ADOQuery2->Active = True; if (this->ADOQuery2->RecordCount == 1) { FisrtID = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[0]->FieldName)->AsInteger; } else { HWND hWnd = GetForegroundWindow(); FisrtDS ="Неправильный код диагноза: " + FisrtDS; char *MesData = AnsiString(FisrtDS).c_str(); MessageBoxA(hWnd, MesData, "Внимание!", MB_OK); Abort(); } ZP ="SELECT SPR_M001._id \ FROM SPR_M001 \ WHERE SPR_M001.MKB10 = '" + SecondDS + "'"; this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(ZP); this->ADOQuery2->Active = True; if (this->ADOQuery2->RecordCount == 1) { SecondID = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[0]->FieldName)->AsInteger; } else { HWND hWnd = GetForegroundWindow(); SecondDS = "Неправильный код диагноза: " + SecondDS; char *MesData = AnsiString(SecondDS).c_str(); MessageBoxA(hWnd, MesData, "Обшика в ini файле!", MB_OK); Abort(); } //Данные по обычному счету if (TypeSchet == 1) { ZP = Zapros_R_SL + MyCHET + "'))"; this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(ZP); this->ADOQuery2->Active = True; if (this->ADOQuery2->RecordCount >0) { this->ADOQuery2->Open(); for (this->ADOQuery2->First(); !this->ADOQuery2->Eof; this->ADOQuery2->Next()) { Work = false; //Поиск диагноза согласно диапазона Tek = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[1]->FieldName)->AsInteger; if ((Tek >= FisrtID) && (SecondID >= Tek)) { //День рождения пациентов DataTemp = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[3]->FieldName)->AsString; if ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 15) { KolCount++; Work = true; } if ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 5) { Vozrast_0_4++; Work = true; } if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 4) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 10) ) { Vozrast_5_9++; Work = true; } if (Work) { //Диспансерное наблюдение Tek = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[2]->FieldName)->AsInteger; if ((Tek == 4) || (Tek == 6)) SnyatDisp++; if (Tek == 1) SostoitDisp++; if (Tek == 2) VzyatDisp++; } //String YEAR_OT; //String MONTH_OT; } } } } if (TypeSchet == 2) { ZP =Zapros_R_SL_D + MyCHET + "'))"; this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(ZP); this->ADOQuery2->Active = True; if (this->ADOQuery2->RecordCount >0) { this->ADOQuery2->Open(); for (this->ADOQuery2->First(); !this->ADOQuery2->Eof; this->ADOQuery2->Next()) { Work = false; //Поиск диагноза согласно диапазона Tek = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[1]->FieldName)->AsInteger; if ((Tek >= FisrtID) && (SecondID >= Tek)) { //День рождения пациентов //String YEAR_OT; //String MONTH_OT; DataTemp = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[2]->FieldName)->AsString; if ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 15) { KolCount++; Work = true; } if ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 5) { Vozrast_0_4++; Work = true; } if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 4) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 10) ) { Vozrast_5_9++; Work = true; } if (Work) { //Диспансерное наблюдение Tek = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[2]->FieldName)->AsInteger; //if ((Tek == 4) || (Tek == 6)) SnyatDisp++; if (Tek == 1) SostoitDisp++; if (Tek == 2) VzyatDisp++; //Установлен впервые Tek = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[3]->FieldName)->AsInteger; if (Tek == 1) DS1_PR++; if ( this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[2]->FieldName)->AsInteger == this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[3]->FieldName)->AsInteger ) { Vzyato_10++; } } } } } } if (TypeSchet == 3) { ZP = Zapros_R_SL_HMP + MyCHET + "'))";// \ this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(ZP); this->ADOQuery2->Active = True; if (this->ADOQuery2->RecordCount >0) { this->ADOQuery2->Open(); for (this->ADOQuery2->First(); !this->ADOQuery2->Eof; this->ADOQuery2->Next()) { Work = false; //Поиск диагноза согласно диапазона Tek = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[1]->FieldName)->AsInteger; if ((Tek >= FisrtID) && (SecondID >= Tek)) { //День рождения пациентов //String YEAR_OT; //String MONTH_OT; DataTemp = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[2]->FieldName)->AsString; if ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 15) { KolCount++; Work = true; } if ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 5) { Vozrast_0_4++; Work = true; } if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 4) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 10) ) { Vozrast_5_9++; Work = true; } if (Work) { //Диспансерное наблюдение //Tek = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[2]->FieldName)->AsInteger; //if ((Tek == 4) || (Tek == 6)) SnyatDisp++; //if (Tek == 1) SostoitDisp++; //if (Tek == 2) VzyatDisp++; } } } } } } //--------------------------------------------------------------------------- void __fastcall TForm12::PoiskDS_15_18(String FisrtDS,String SecondDS, int TypeWork) { bool Work; if (TypeWork ==1 ) { Vozrast_14_15 = 0; Vozrast_15_18 = 0; KolCount = 0; SnyatDisp = 0; SostoitDisp = 0; VzyatDisp = 0; DS1_PR = 0; Vzyato_10 = 0; ViyavlenoDisp = 0; ViyavlenoProfOsmoyr = 0; } String DataTemp; int FisrtID, SecondID, Tek; String ZP ="SELECT SPR_M001._id \ FROM SPR_M001 \ WHERE SPR_M001.MKB10 = '" + FisrtDS + "'"; this->ADOQuery3->Active = False; this->ADOQuery3->SQL->Clear(); this->ADOQuery3->SQL->Add(ZP); this->ADOQuery3->Active = True; if (this->ADOQuery3->RecordCount == 1) { FisrtID = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[0]->FieldName)->AsInteger; } else { HWND hWnd = GetForegroundWindow(); FisrtDS ="Неправильный код диагноза: " + FisrtDS; char *MesData = AnsiString(FisrtDS).c_str(); MessageBoxA(hWnd, MesData, "Внимание!", MB_OK); Abort(); } ZP ="SELECT SPR_M001._id \ FROM SPR_M001 \ WHERE SPR_M001.MKB10 = '" + SecondDS + "'"; this->ADOQuery3->Active = False; this->ADOQuery3->SQL->Clear(); this->ADOQuery3->SQL->Add(ZP); this->ADOQuery3->Active = True; if (this->ADOQuery3->RecordCount == 1) { SecondID = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[0]->FieldName)->AsInteger; } else { HWND hWnd = GetForegroundWindow(); SecondDS = "Неправильный код диагноза: " + SecondDS; char *MesData = AnsiString(SecondDS).c_str(); MessageBoxA(hWnd, MesData, "Обшика в ini файле!", MB_OK); Abort(); } //Данные по обычному счету if (TypeSchet == 1) { ZP = Zapros_R_SL + MyCHET + "'))"; this->ADOQuery3->Active = False; this->ADOQuery3->SQL->Clear(); this->ADOQuery3->SQL->Add(ZP); this->ADOQuery3->Active = True; if (this->ADOQuery3->RecordCount >0) { this->ADOQuery3->Open(); for (this->ADOQuery3->First(); !this->ADOQuery3->Eof; this->ADOQuery3->Next()) { Work = false; //Поиск диагноза согласно диапазона Tek = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[1]->FieldName)->AsInteger; if ((Tek >= FisrtID) && (SecondID >= Tek)) { //День рождения пациентов DataTemp = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[3]->FieldName)->AsString; if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 13) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 18) ) { KolCount++; Work = true; } if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 13) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 16) ) { Vozrast_14_15++; Work = true; } if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 15) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 18) ) { Vozrast_15_18++; Work = true; } if (Work) { //Диспансерное наблюдение Tek = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[2]->FieldName)->AsInteger; if ((Tek == 4) || (Tek == 6)) SnyatDisp++; if (Tek == 1) SostoitDisp++; if (Tek == 2) VzyatDisp++; } //String YEAR_OT; //String MONTH_OT; } } } } if (TypeSchet == 2) { ZP = Zapros_R_SL_D + MyCHET + "'))"; this->ADOQuery3->Active = False; this->ADOQuery3->SQL->Clear(); this->ADOQuery3->SQL->Add(ZP); this->ADOQuery3->Active = True; if (this->ADOQuery3->RecordCount >0) { this->ADOQuery3->Open(); for (this->ADOQuery3->First(); !this->ADOQuery3->Eof; this->ADOQuery3->Next()) { Work = false; //Поиск диагноза согласно диапазона Tek = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[1]->FieldName)->AsInteger; if ((Tek >= FisrtID) && (SecondID >= Tek)) { //День рождения пациентов //String YEAR_OT; //String MONTH_OT; DataTemp = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[2]->FieldName)->AsString; if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 9) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 15) ) { Vozrast_14_15++; Work = true; } if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 14) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 18) ) { Vozrast_15_18++; Work = true; } if (Work) { //Диспансерное наблюдение Tek = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[2]->FieldName)->AsInteger; //if ((Tek == 4) || (Tek == 6)) SnyatDisp++; if (Tek == 1) SostoitDisp++; if (Tek == 2) VzyatDisp++; //Установлен впервые Tek = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[3]->FieldName)->AsInteger; if (Tek == 1) DS1_PR++; if ( this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[2]->FieldName)->AsInteger == this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[3]->FieldName)->AsInteger ) { Vzyato_10++; } } } } } } if (TypeSchet == 3) { ZP = Zapros_R_SL_HMP + MyCHET + "'))";// \ this->ADOQuery3->Active = False; this->ADOQuery3->SQL->Clear(); this->ADOQuery3->SQL->Add(ZP); this->ADOQuery3->Active = True; if (this->ADOQuery3->RecordCount >0) { this->ADOQuery3->Open(); for (this->ADOQuery3->First(); !this->ADOQuery3->Eof; this->ADOQuery3->Next()) { Work = false; //Поиск диагноза согласно диапазона Tek = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[1]->FieldName)->AsInteger; if ((Tek >= FisrtID) && (SecondID >= Tek)) { //День рождения пациентов //String YEAR_OT; //String MONTH_OT; DataTemp = this->ADOQuery3->FieldByName(this->ADOQuery3->Fields->Fields[2]->FieldName)->AsString; if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 9) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 15) ) { Vozrast_14_15++; Work = true; } if ( ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) > 14) && ((StrToInt(YEAR_OT) - StrToInt(DataTemp.SubString(1,4))) < 18) ) { Vozrast_15_18++; Work = true; } if (Work) { //Диспансерное наблюдение //Tek = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[2]->FieldName)->AsInteger; //if ((Tek == 4) || (Tek == 6)) SnyatDisp++; //if (Tek == 1) SostoitDisp++; //if (Tek == 2) VzyatDisp++; } } } } } } //--------------------------------------------------------------------------- void __fastcall TForm12::InfoShet() { String ZP,TekName; String MasName[512]; int i; for (i = 0; i < 512; i++) MasName[i] = ""; //Установление типа счета ZP = "SELECT [DISP] \ ,[IS_HMP] \ ,[YEAR] \ ,[MONTH] \ FROM R_SCHET \ WHERE [_id] = '" + MyCHET + "'"; this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(ZP); this->ADOQuery2->Active = True; if (this->ADOQuery2->RecordCount == 1) { if ( (this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[0]->FieldName)->AsString.Length() == 0) && (this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[1]->FieldName)->AsString == "False") ) { TypeSchet = 1; } if ( (this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[0]->FieldName)->AsString.Length() != 0) && (this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[1]->FieldName)->AsString == "False") ) { TypeSchet = 2; } if (this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[1]->FieldName)->AsString == "True") { TypeSchet = 3; } YEAR_OT = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[2]->FieldName)->AsString; MONTH_OT = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[3]->FieldName)->AsString; } if (TypeSchet == 1) { ZP =" SELECT R_Z_SL._id \ ,R_PERS.ID_PAC \ FROM R_Z_SL \ LEFT JOIN R_ZAP on R_Z_SL._idzap = R_ZAP._id \ LEFT JOIN R_PACIENT on R_ZAP._pid = R_PACIENT._id \ LEFT JOIN R_PERS on R_PACIENT.ID_PAC = R_PERS.ID_PAC \ WHERE R_Z_SL._idzap in (SELECT R_ZAP._id \ FROM R_ZAP \ WHERE R_ZAP._schet_id = '" + MyCHET + "')"; } if (TypeSchet == 2) { ZP =" SELECT R_Z_SL_D._id \ ,R_PERS.ID_PAC \ FROM R_Z_SL_D \ LEFT JOIN R_ZAP on R_Z_SL_D._idzap = R_ZAP._id \ LEFT JOIN R_PACIENT on R_ZAP._pid = R_PACIENT._id \ LEFT JOIN R_PERS on R_PACIENT.ID_PAC = R_PERS.ID_PAC \ WHERE R_Z_SL_D._idzap in (SELECT R_ZAP._id \ FROM R_ZAP \ WHERE R_ZAP._schet_id = '" + MyCHET + "')"; } if (TypeSchet == 3) { ZP =" SELECT R_Z_SL_HMP._id \ ,R_PERS.ID_PAC \ FROM R_Z_SL_HMP \ LEFT JOIN R_ZAP on R_Z_SL_HMP._idzap = R_ZAP._id \ LEFT JOIN R_PACIENT on R_ZAP._pid = R_PACIENT._id \ LEFT JOIN R_PERS on R_PACIENT.ID_PAC = R_PERS.ID_PAC \ WHERE R_Z_SL_HMP._idzap in (SELECT R_ZAP._id \ FROM R_ZAP \ WHERE R_ZAP._schet_id = '" + MyCHET + "')"; } this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(ZP); this->ADOQuery2->Active = True; if (this->ADOQuery2->RecordCount > 0) { this->ADOQuery2->Open(); for (this->ADOQuery2->First(); !this->ADOQuery2->Eof; this->ADOQuery2->Next()) { TekName = this->ADOQuery2->FieldByName(this->ADOQuery2->Fields->Fields[1]->FieldName)->AsString; Sovp = 0; i = 0; while (MasName[i].Length()!=0) { if (TekName == MasName[i]) { Sovp++; break; } i++; } if (Sovp == 0) { MasName[i] = TekName; } } Sovp = 0; while (MasName[Sovp].Length()!=0) { Sovp ++; } } } //--------------------------------------------------------------------------- void __fastcall TForm12::Button1Click(TObject *Sender) { TypeSchet = 0; KolPers = 0; Sovp = 0; String FisrtDS, SecondDS,TekName; int FisrtID, SecondID; String ZP; InfoShet(); Form1->QRLabel1->Caption = "Код по ОКЕИ: - Человек " + IntToStr(Sovp); Struct_Param.Param_13 = "!!!!"; String Zapros = "DELETE FROM [ITMed54].[dbo].[MyTempTable]"; this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(Zapros); this->ADOQuery2->ExecSQL(); char line[1024]; ifstream F("OTCHET\\Test.ini"); int Kol = 0; if(!F) { Abort(); } while(F.getline(line, sizeof(line))) { if (Kol == 0) Struct_Param.Param_1 = line; if (Kol == 1) Struct_Param.Param_2 = line; if (Kol == 2) FisrtDS = line; if (Kol == 3) { SecondDS = line; if (FisrtDS == SecondDS.SubString(1,3)) { Struct_Param.Param_3 = FisrtDS; } else { Struct_Param.Param_3 = FisrtDS + "-" + SecondDS.SubString(1,3); } PoiskDS_0_4(FisrtDS,SecondDS,1); Struct_Param.Param_4 = IntToStr(KolCount); Struct_Param.Param_5 = IntToStr(Vozrast_0_4); Struct_Param.Param_6 = IntToStr(Vozrast_5_9); Struct_Param.Param_7 = IntToStr(VzyatDisp); Struct_Param.Param_8 = IntToStr(DS1_PR); Struct_Param.Param_9 = IntToStr(Vzyato_10); Struct_Param.Param_10 = IntToStr(Viyavleno_11); Struct_Param.Param_11 = IntToStr(SnyatDisp); Struct_Param.Param_12 = IntToStr(SostoitDisp); } ZP = line; if (ZP == "//---------------") { Kol = 0; Zapros = "INSERT INTO [MyTempTable] ([Param_1], \ [Param_2], \ [Param_3], \ [Param_4], \ [Param_5], \ [Param_6], \ [Param_7], \ [Param_8], \ [Param_9], \ [Param_10], \ [Param_11], \ [Param_12], \ [Param_13]) \ OUTPUT INSERTED._id VALUES ('" + Struct_Param.Param_1 + "'," + "'" + Struct_Param.Param_2 + "'," + "'" + Struct_Param.Param_3 + "'," + "'" + Struct_Param.Param_4 + "'," + "'" + Struct_Param.Param_5 + "'," + "'" + Struct_Param.Param_6 + "'," + "'" + Struct_Param.Param_7 + "'," + "'" + Struct_Param.Param_8 + "'," + "'" + Struct_Param.Param_9 + "'," + "'" + Struct_Param.Param_10 + "'," + "'" + Struct_Param.Param_11 + "'," + "'" + Struct_Param.Param_12 + "'," + "'" + Struct_Param.Param_13 + "')"; this->ADOQuery2->Active = False; this->ADOQuery2->SQL->Clear(); this->ADOQuery2->SQL->Add(Zapros); this->ADOQuery2->Active = True; continue; } if (Kol == 4) FisrtDS = line; if (Kol == 5) { SecondDS = line; PoiskDS_0_4(FisrtDS,SecondDS,2); if (FisrtDS == SecondDS.SubString(1,3)) { Struct_Param.Param_3 = Struct_Param.Param_3 + ", \n " + FisrtDS; } else { Struct_Param.Param_3 = Struct_Param.Param_3 + ", \n " + FisrtDS + "-" + SecondDS.SubString(1,3); } Struct_Param.Param_4 = IntToStr(StrToInt(Struct_Param.Param_4) + KolCount); } if (Kol == 6) FisrtDS = line; if (Kol == 7) { SecondDS = line; PoiskDS_0_4(FisrtDS,SecondDS,2); if (FisrtDS == SecondDS.SubString(1,3)) { Struct_Param.Param_3 = Struct_Param.Param_3 + ", \n " + FisrtDS; } else { Struct_Param.Param_3 = Struct_Param.Param_3 + ", \n " + FisrtDS + "-" + SecondDS.SubString(1,3); } Struct_Param.Param_4 = IntToStr(StrToInt(Struct_Param.Param_4) + KolCount); } Kol++; } Form1->ADOQuery2->Active = False; Form1->ADOQuery2->SQL->Clear(); Form1->ADOQuery2->SQL->Add(TMP_SCHET); Form1->ADOQuery2->Active = True; Form1->QRDBText1->DataField = Form1->ADOQuery2->Fields->Fields[0]->FieldName; Form1->QRDBText2->DataField = Form1->ADOQuery2->Fields->Fields[1]->FieldName; Form1->QRDBText3->DataField = Form1->ADOQuery2->Fields->Fields[2]->FieldName; Form1->QRDBText4->DataField = Form1->ADOQuery2->Fields->Fields[3]->FieldName; Form1->QRDBText5->DataField = Form1->ADOQuery2->Fields->Fields[4]->FieldName; Form1->QRDBText6->DataField = Form1->ADOQuery2->Fields->Fields[5]->FieldName; Form1->QRDBText7->DataField = Form1->ADOQuery2->Fields->Fields[6]->FieldName; Form1->QRDBText8->DataField = Form1->ADOQuery2->Fields->Fields[7]->FieldName; Form1->QRDBText9->DataField = Form1->ADOQuery2->Fields->Fields[8]->FieldName; Form1->QRDBText10->DataField = Form1->ADOQuery2->Fields->Fields[9]->FieldName; Form1->QRDBText11->DataField = Form1->ADOQuery2->Fields->Fields[10]->FieldName; Form1->QRDBText12->DataField = Form1->ADOQuery2->Fields->Fields[11]->FieldName; Form1->QRDBText13->DataField = Form1->ADOQuery2->Fields->Fields[12]->FieldName; Form1->QuickRep1->Preview() ; } //--------------------------------------------------------------------------- void __fastcall TForm12::DBGrid1ColumnMoved(TObject *Sender, int FromIndex, int ToIndex) { this->DBGrid1->Columns->Items[ToIndex]->Index = FromIndex; } //--------------------------------------------------------------------------- void __fastcall TForm12::DBGrid1DrawColumnCell(TObject *Sender, const TRect &Rect, int DataCol, TColumn *Column, TGridDrawState State) { F1MyDBGrid *grid = static_cast<F1MyDBGrid*>(Sender); if (grid->DataLink->ActiveRecord == grid->Row -1) { TField *F = Column->Field; TCanvas *Cvs = DBGrid1->Canvas; Cvs->Brush->Color = clSkyBlue; Cvs->FillRect(Rect); Cvs->Font->Color = clBlack; Cvs->TextOut(Rect.Left+2, Rect.Top+2, F->Text); Cvs->TextOut(Rect.Left+2, Rect.Top+2, F->Text); } } //--------------------------------------------------------------------------- void __fastcall TForm12::DBGrid1CellClick(TColumn *Column) { this->Label3->Caption = "Номер счета : " + this->ADOQuery1->FieldByName(this->ADOQuery1->Fields->Fields[0]->FieldName)->AsString; MyCHET = this->ADOQuery1->FieldByName(this->ADOQuery1->Fields->Fields[0]->FieldName)->AsString; } //--------------------------------------------------------------------------- void __fastcall TForm12::Button3Click(TObject *Sender) { // } //---------------------------------------------------------------------------
[ "superbrat@mail.ru" ]
superbrat@mail.ru
7009b30958a8b6ffa60721e8786eada67345209c
b057ebf9e39bf55801b658f3dd0561449c990d22
/app/src/main/cpp/graphmap/index/index_hash.cc
ce4a5cebbf03d01844ce6309916e82be239ac4a1
[ "MIT" ]
permissive
ffloreani/Metagenomix-Android
227939d219836d5a3ea75c438cf2156bfc26a5f9
5bb4e41862f1bd8801121d542e703bd5370b4f55
refs/heads/master
2021-04-30T22:36:01.059203
2017-02-20T22:09:06
2017-02-20T22:09:06
75,603,125
0
0
null
null
null
null
UTF-8
C++
false
false
14,981
cc
/* * index_hash.cpp * * Created on: Oct 21, 2014 * Author: ivan */ #include <algorithm> #include "index_hash.h" IndexHash::IndexHash() { Init(); } IndexHash::~IndexHash() { Clear(); } void IndexHash::Init() { k_ = 6; // kmer_hash_.clear(); kmer_hash_ = NULL; num_threads_ = 1; data_ = NULL; suffix_array_ = NULL; kmer_hash_size_ = 0; kmer_hash_counts_size_ = 0; kmer_hash_counts_ = NULL; kmer_hash_last_key_ = 0; kmer_hash_last_key_initialized_ = false; all_kmers_ = NULL; all_kmers_size_ = 0; } void IndexHash::Clear() { if (data_) delete[] data_; data_ = NULL; if (suffix_array_) delete suffix_array_; suffix_array_ = NULL; if (kmer_hash_counts_) free(kmer_hash_counts_); kmer_hash_counts_ = NULL; // if (kmer_hash_ != NULL) { // for (int64_t i=0; i<kmer_hash_size_; i++) { // if (kmer_hash_[i] != NULL) // free(kmer_hash_[i]); // kmer_hash_[i] = NULL; // } // free(kmer_hash_); // } if (kmer_hash_) free(kmer_hash_); kmer_hash_ = NULL; if (all_kmers_) free(all_kmers_); all_kmers_ = NULL; all_kmers_size_ = 0; // kmer_hash_.clear(); reference_starting_pos_.clear(); reference_lengths_.clear(); data_length_ = 0; data_length_forward_ = 0; data_ptr_ = 0; num_sequences_ = 0; kmer_hash_size_ = 0; kmer_hash_last_key_ = 0; kmer_hash_last_key_initialized_ = false; kmer_hash_counts_size_ = 0; } int64_t IndexHash::GenerateHashKey(const int8_t *seed, uint64_t seed_length) const { int64_t ret = 0; // std::string temp = ""; int current_base_MSB = (seed_length - 1) * 2; for (uint64_t current_base = 0; current_base < seed_length; current_base++) { if (!kIsBase[seed[current_base]]) return -1; // temp += ((char) seed[current_base]); // ret |= (kBaseToBwa[seed[current_base]] << (current_base * 2)); ret |= (kBaseToBwa[seed[current_base]] << (current_base_MSB)); current_base_MSB -= 2; // new_data[current_base >> 2] |= // kBaseToBwa[(int32_t) data_[current_base]] // << ((3 - (current_base & 3)) << 1); } // // // printf ("hash_key = %X, seed = %s\n", ret, temp.c_str()); // printf ("%s", temp.c_str()); return ret; } int64_t IndexHash::UpdateHashKey(const int8_t *seed, uint64_t seed_length, int64_t hash_key) const { int64_t ret = 0; uint64_t current_base_num = seed_length - 1; int8_t current_base_2bit = kBaseToBwa[seed[current_base_num]]; if (current_base_2bit > 3) return -1; // ret = (hash_key >> 2) | (kBaseToBwa[seed[current_base]] << (current_base * 2)); ret = (hash_key << 2) | current_base_2bit; uint64_t bit_mask = (uint64_t) 0; bit_mask = (1 << (seed_length * 2)) - 1; // Only the seed bits are equal to 1, others are 0. // Seed length should never be more than 31, or we'll jump into negative numbers. ret &= bit_mask; return ret; } void IndexHash::CountKmers(const SingleSequence &sequence, int k, int64_t **ret_kmer_counts, int64_t *ret_num_kmers) const { // std::vector<int64_t> &ret_kmer_counts) { int64_t hash_key = -1; // ret_kmer_counts.resize(std::pow(2, (2 * k))); int64_t num_kmers = std::pow(2, (2*k)); int64_t *kmer_counts = (int64_t *) calloc(sizeof(int64_t), num_kmers); bool last_skipped = true; for (uint64_t i=0; i<(sequence.get_sequence_length() - k + 1); i++) { const int8_t *seed_start = &(sequence.get_data()[i]); if (i == 0 || last_skipped == true) { hash_key = GenerateHashKey(seed_start, k); last_skipped = false; } else { hash_key = UpdateHashKey(seed_start, k, hash_key); } if (hash_key < 0) { last_skipped = true; continue; } kmer_counts[hash_key] += 1; } *ret_kmer_counts = kmer_counts; *ret_num_kmers = num_kmers; } int IndexHash::GenerateFromSingleSequenceOnlyForward(const SingleSequence& sequence) { Clear(); // std::vector<int64_t> kmer_counts; // CountKmers(sequence, k_, kmer_counts); CountKmers(sequence, k_, &kmer_hash_counts_, &kmer_hash_counts_size_); int64_t *kmer_countdown = (int64_t *) malloc(sizeof(int64_t) * kmer_hash_counts_size_); memmove(kmer_countdown, kmer_hash_counts_, sizeof(int64_t) * kmer_hash_counts_size_); // kmer_counts.resize(std::pow(2, (2 * k_))); // for (uint64_t i=0; i<(sequence.get_sequence_length() - k_ + 1); i++) { // int8_t *seed_start = &(sequence.get_data()[i]); // int64_t hash_key = GenerateHashKey(seed_start, k_); // if (hash_key < 0) // continue; // kmer_counts[hash_key] += 1; // } if (data_) delete[] data_; data_ = NULL; uint64_t mem_to_alloc = (sequence.get_data_length() + 1); data_ = new int8_t[mem_to_alloc]; if (data_ == NULL) { // ErrorReporting::GetInstance().Log(SEVERITY_INT_FATAL, __FUNCTION__, ErrorReporting::GetInstance().GenerateErrorMessage(ERR_MEMORY, "Offending variable: data_.")); return 1; } data_length_ = mem_to_alloc; data_ptr_ = 0; data_length_forward_ = data_length_ + 1; num_sequences_forward_ = 1; memmove(data_, sequence.get_data(), data_length_); for (int64_t i=0; i<data_length_; i++) { data_[i] = kBaseToUpper[data_[i]]; } // int k = 6; // // k_ = k; // kmer_hash_.resize(std::pow(2, (2 * k_))); // kmer_hash_size_ = kmer_hash_.size(); kmer_hash_size_ = std::pow(2, (2 * k_)); kmer_hash_ = (int64_t **) malloc(sizeof(int64_t *) * kmer_hash_size_); all_kmers_size_ = sequence.get_data_length() - k_ + 1; if (all_kmers_) free(all_kmers_); all_kmers_ = NULL; all_kmers_ = (int64_t *) calloc(sizeof(int64_t), all_kmers_size_); int64_t kmer_hash_ptr = 0; for (int64_t i=0; i<kmer_hash_size_; i++) { // kmer_hash_[i] = (int64_t *) calloc(sizeof(int64_t), kmer_hash_counts_[i]); if (kmer_hash_counts_[i] > 0) kmer_hash_[i] = (all_kmers_ + kmer_hash_ptr); else kmer_hash_[i] = NULL; kmer_hash_ptr += kmer_hash_counts_[i]; kmer_countdown[i] -= 1; } kmer_hash_last_key_ = 0; kmer_hash_last_key_initialized_ = false; // for (uint64_t i=0; i<kmer_hash_size_; i++) { // kmer_hash_[i].resize(kmer_hash_counts_[i]); // kmer_countdown[i] -= 1; // } int64_t hash_key = -1; bool last_skipped = true; for (uint64_t i=0; i<(sequence.get_sequence_length() - k_ + 1); i++) { int8_t *seed_start = &(data_[i]); // int64_t hash_key = GenerateHashKey(seed_start, k_); if (i == 0 || last_skipped == true) { hash_key = GenerateHashKey(seed_start, k_); last_skipped = false; } else { hash_key = UpdateHashKey(seed_start, k_, hash_key); } if (hash_key < 0) { last_skipped = true; continue; } // kmer_hash_[hash_key].push_back(((int64_t) i)); // printf ("\nkmer_counts[%ld] = %ld\n", hash_key, kmer_counts[hash_key]); // fflush(stdout); kmer_hash_[hash_key][kmer_countdown[hash_key]] = ((int64_t) i); kmer_countdown[hash_key] -= 1; // for (int j=0; j<kmer_hash_[hash_key].size(); j++) // { // printf (", "); // printf ("%ld", kmer_hash_[hash_key][j]); // } // printf ("\n"); } if (kmer_countdown) free(kmer_countdown); kmer_countdown = NULL; // for (uint64_t i=0; i<kmer_hash_.size(); i++) { // std::sort(kmer_hash_[i].begin(), kmer_hash_[i].end(), std::greater<int64_t>()); // } return 0; } int IndexHash::FindAllRawPositionsOfSeed(int8_t* seed, uint64_t seed_length, uint64_t max_num_of_hits, int64_t** hits, uint64_t* start_hit, uint64_t* num_hits) const { int64_t hash_key = GenerateHashKey(seed, seed_length); if (hash_key < 0 || hash_key >= kmer_hash_size_) { return 3; } *hits = &(kmer_hash_[hash_key][0]); *start_hit = 0; *num_hits = kmer_hash_counts_[hash_key]; if (kmer_hash_counts_[hash_key] == 0) return 1; if (kmer_hash_counts_[hash_key] > max_num_of_hits) return 2; return 0; } int IndexHash::FindAllRawPositionsOfIncrementalSeed(int8_t* seed, uint64_t seed_length, uint64_t max_num_of_hits, int64_t** hits, uint64_t* start_hit, uint64_t* num_hits) { // int64_t hash_key = GenerateHashKey(seed, seed_length); int64_t hash_key = 0; if (kmer_hash_last_key_initialized_ == false) { hash_key = GenerateHashKey(seed, seed_length); kmer_hash_last_key_initialized_ = true; // printf ("GenerateHashKey: hash_key = %ld\n", hash_key); // printf ("GenerateHashKey: kmer_hash_last_key_ = %ld\n", kmer_hash_last_key_); // printf ("seed = %s\n", GetSubstring((char *) seed, seed_length).c_str()); // printf ("kmer_hash_size_ = %ld\n", kmer_hash_size_); // fflush(stdout); } else { hash_key = UpdateHashKey(seed, seed_length, kmer_hash_last_key_); // printf ("UpdateHashKey: hash_key = %ld\n", hash_key); // printf ("UpdateHashKey: kmer_hash_last_key_ = %ld\n", kmer_hash_last_key_); // printf ("seed = %s\n", GetSubstring((char *) seed, seed_length).c_str()); // fflush(stdout); // exit(1); } if (hash_key < 0 || hash_key >= kmer_hash_size_) { kmer_hash_last_key_initialized_ = false; return 3; } kmer_hash_last_key_ = hash_key; int64_t kmer_hash_count = kmer_hash_counts_[hash_key]; *hits = &(kmer_hash_[hash_key][0]); *start_hit = 0; *num_hits = kmer_hash_count; if (kmer_hash_count == 0) return 1; if (kmer_hash_count > max_num_of_hits) return 2; return 0; } //int IndexHash::FindAllRawPositionsOfSeedHash(int8_t* seed, uint64_t seed_length, // uint64_t max_num_of_hits, // HashIndexVector** hits, // uint64_t* start_hit, // uint64_t* num_hits, int64_t *kmer_hash_key) { // int64_t hash_key = *kmer_hash_key; // if (hash_key < 0) // hash_key = GenerateHashKey(seed, seed_length); // else // hash_key = UpdateHashKey(seed, seed_length, hash_key); // *kmer_hash_key = hash_key; // //// for (uint64_t current_base = 0; current_base < seed_length; //// current_base++) { //// printf ("%c", ((char) seed[current_base])); //// } //// printf ("\n"); // // if (hash_key < 0) { // *hits = NULL; // *start_hit = 0; // *num_hits = 0; // return 3; // } // // *hits = &(kmer_hash_[hash_key]); // *start_hit = 0; //// printf ("num_hits = %ld, hash_key = %ld (%X), kmer_hash_.size() = %ld\n", kmer_hash_[hash_key].size(), hash_key, hash_key, kmer_hash_.size()); // *num_hits = kmer_hash_[hash_key].size(); // //// printf ("hits.size() = %ld\n", (*hits)->size()); // // if (kmer_hash_[hash_key].size() == 0) // return 1; // // if (kmer_hash_[hash_key].size() > max_num_of_hits) // return 2; // //// printf ("num_hits = %ld\n", *num_hits); //// printf ("Good!\n"); // // return 0; //} const int8_t* IndexHash::get_data() const { return data_; } //void IndexHash::set_data(int8_t* data) { // data_ = data; //} uint64_t IndexHash::get_data_length() const { return data_length_; } //void IndexHash::set_data_length(uint64_t dataLength) { // data_length_ = dataLength; //} uint64_t IndexHash::get_data_length_forward() const { return data_length_forward_; } //void IndexHash::set_data_length_forward(uint64_t dataLengthForward) { // data_length_forward_ = dataLengthForward; //} // //uint64_t IndexHash::get_data_ptr() const { // return data_ptr_; //} // //void IndexHash::set_data_ptr(uint64_t dataPtr) { // data_ptr_ = dataPtr; //} const std::vector<std::string>& IndexHash::get_headers() const { return headers_; } //void IndexHash::set_headers(const std::vector<std::string>& headers) { // headers_ = headers; //} int IndexHash::get_k() const { return k_; } void IndexHash::set_k(int k) { k_ = k; } //const std::vector<HashIndexVector>& IndexHash::get_kmer_hash() const { // return kmer_hash_; //} // //void IndexHash::set_kmer_hash(const std::vector<HashIndexVector>& kmerHash) { // kmer_hash_ = kmerHash; //} uint64_t IndexHash::get_num_sequences() const { return num_sequences_; } //void IndexHash::set_num_sequences(uint64_t numSequences) { // num_sequences_ = numSequences; //} uint64_t IndexHash::get_num_sequences_forward() const { return num_sequences_forward_; } //void IndexHash::set_num_sequences_forward(uint64_t numSequencesForward) { // num_sequences_forward_ = numSequencesForward; //} // //uint64_t IndexHash::get_num_threads() const { // return num_threads_; //} // //void IndexHash::set_num_threads(uint64_t numThreads) { // num_threads_ = numThreads; //} const std::vector<uint64_t>& IndexHash::get_reference_lengths() const { return reference_lengths_; } std::string IndexHash::VerboseToString() const { return (std::string("")); } //void IndexHash::set_reference_lengths( // const std::vector<uint64_t>& referenceLengths) { // reference_lengths_ = referenceLengths; //} const std::vector<uint64_t>& IndexHash::get_reference_starting_pos() const { return reference_starting_pos_; } //void IndexHash::set_reference_starting_pos( // const std::vector<uint64_t>& referenceStartingPos) { // reference_starting_pos_ = referenceStartingPos; //} //int64_t*& IndexHash::get_suffix_array() { // return suffix_array_; //} //void IndexHash::InitNumThreads(uint32_t num_threads) { //} int IndexHash::LoadFromFile(std::string index_path) { return 0; } int IndexHash::GenerateFromFile(std::string sequence_file_path) { return 0; } int IndexHash::GenerateFromSequenceFile(SequenceFile& sequence_file) { return 0; } int IndexHash::GenerateFromSingleSequence(SingleSequence& sequence) { return 0; } int IndexHash::LoadOrGenerate(std::string reference_path, std::string out_index_path, bool verbose) { return 0; } int IndexHash::StoreToFile(std::string output_index_path) { return 0; } int64_t IndexHash::RawPositionConverter( int64_t raw_position, int64_t query_length, int64_t* ret_absolute_position, int64_t* ret_relative_position, SeqOrientation* ret_orientation, int64_t* ret_reference_index_with_reverse) const { return 0; } int64_t IndexHash::RawPositionToReferenceIndexWithReverse(int64_t raw_position) const { return 0; } //int64_t IndexHash::RawToAbsolutePositionConverter(int64_t raw_position) { // return raw_position; //} void IndexHash::Verbose(FILE* fp) const { } int IndexHash::SerializeIndex_(FILE *fp_out) { return 0; } int IndexHash::DeserializeIndex_(FILE *fp_in) { return 0; } int IndexHash::IsManualCleanupRequired(std::string function_name) const { return 1; } int IndexHash::CreateIndex_(int8_t* data, uint64_t data_length) { return 1; } //void IndexHash::set_suffix_array(int64_t*& suffixArray) { // suffix_array_ = suffixArray; //}
[ "floreani.filip@gmail.com" ]
floreani.filip@gmail.com
3f60d229b9112e72fa2540858053aeffb9217f20
03ddc09ce9a1ae64bcef735438d4d1fca7025e7b
/OpenSteamworks/Interfaces/Steam/ISteamMatchmaking/ISteamMatchmaking007.h
b3bbcb1bcd55d511798220041d87755687c6a68f
[]
no_license
m4dEngi/open-steamworks
212590141205a6c5855a4a6772f391906f7e5601
34c146542fe20d175913f35945928af9ac26c837
refs/heads/master
2023-06-22T22:47:18.935532
2023-06-15T16:51:44
2023-06-15T16:51:44
63,839,816
42
9
null
2022-06-11T22:23:09
2016-07-21T05:31:15
C++
UTF-8
C++
false
false
12,562
h
//========================== Open Steamworks ================================ // // This file is part of the Open Steamworks project. All individuals associated // with this project do not claim ownership of the contents // // The code, comments, and all related files, projects, resources, // redistributables included with this project are Copyright Valve Corporation. // Additionally, Valve, the Valve logo, Half-Life, the Half-Life logo, the // Lambda logo, Steam, the Steam logo, Team Fortress, the Team Fortress logo, // Opposing Force, Day of Defeat, the Day of Defeat logo, Counter-Strike, the // Counter-Strike logo, Source, the Source logo, and Counter-Strike Condition // Zero are trademarks and or registered trademarks of Valve Corporation. // All other trademarks are property of their respective owners. // //============================================================================= #ifndef ISTEAMMATCHMAKING007_H #define ISTEAMMATCHMAKING007_H #ifdef _WIN32 #pragma once #endif #include "Types/SteamTypes.h" #include "Types/MatchmakingCommon.h" //----------------------------------------------------------------------------- // Purpose: Functions for match making services for clients to get to favorites // and to operate on game lobbies. //----------------------------------------------------------------------------- abstract_class ISteamMatchmaking007 { public: // game server favorites storage // saves basic details about a multiplayer game server locally // returns the number of favorites servers the user has stored virtual int GetFavoriteGameCount() = 0; // returns the details of the game server // iGame is of range [0,GetFavoriteGameCount()) // *pnIP, *pnConnPort are filled in the with IP:port of the game server // *punFlags specify whether the game server was stored as an explicit favorite or in the history of connections // *pRTime32LastPlayedOnServer is filled in the with the Unix time the favorite was added virtual bool GetFavoriteGame( int iGame, AppId_t *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint16 *pnQueryPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ) = 0; // adds the game server to the local list; updates the time played of the server if it already exists in the list virtual int AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) =0; // removes the game server from the local storage; returns true if one was removed virtual bool RemoveFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags ) = 0; /////// // Game lobby functions // Get a list of relevant lobbies // this is an asynchronous request // results will be returned by LobbyMatchList_t callback & call result, with the number of lobbies found // this will never return lobbies that are full // to add more filter, the filter calls below need to be call before each and every RequestLobbyList() call // use the CCallResult<> object in steam_api.h to match the SteamAPICall_t call result to a function in an object, e.g. /* class CMyLobbyListManager { CCallResult<CMyLobbyListManager, LobbyMatchList_t> m_CallResultLobbyMatchList; void FindLobbies() { // SteamMatchmaking()->AddRequestLobbyListFilter*() functions would be called here, before RequestLobbyList() SteamAPICall_t hSteamAPICall = SteamMatchmaking()->RequestLobbyList(); m_CallResultLobbyMatchList.Set( hSteamAPICall, this, &CMyLobbyListManager::OnLobbyMatchList ); } void OnLobbyMatchList( LobbyMatchList_t *pLobbyMatchList, bool bIOFailure ) { // lobby list has be retrieved from Steam back-end, use results } } */ // virtual SteamAPICall_t RequestLobbyList() = 0; // filters for lobbies // this needs to be called before RequestLobbyList() to take effect // these are cleared on each call to RequestLobbyList() virtual void AddRequestLobbyListStringFilter( const char *pchKeyToMatch, const char *pchValueToMatch, ELobbyComparison eComparisonType ) = 0; // numerical comparison virtual void AddRequestLobbyListNumericalFilter( const char *pchKeyToMatch, int nValueToMatch, ELobbyComparison eComparisonType ) = 0; // returns results closest to the specified value. Multiple near filters can be added, with early filters taking precedence virtual void AddRequestLobbyListNearValueFilter( const char *pchKeyToMatch, int nValueToBeCloseTo ) = 0; // returns only lobbies with the specified number of slots available virtual void AddRequestLobbyListFilterSlotsAvailable( int nSlotsAvailable ) = 0; // returns the CSteamID of a lobby, as retrieved by a RequestLobbyList call // should only be called after a LobbyMatchList_t callback is received // iLobby is of the range [0, LobbyMatchList_t::m_nLobbiesMatching) // the returned CSteamID::IsValid() will be false if iLobby is out of range STEAMWORKS_STRUCT_RETURN_1(CSteamID, GetLobbyByIndex, int, iLobby) /*virtual CSteamID GetLobbyByIndex( int iLobby ) = 0;*/ // Create a lobby on the Steam servers. // If private, then the lobby will not be returned by any RequestLobbyList() call; the CSteamID // of the lobby will need to be communicated via game channels or via InviteUserToLobby() // this is an asynchronous request // results will be returned by LobbyCreated_t callback and call result; lobby is joined & ready to use at this pointer // a LobbyEnter_t callback will also be received (since the local user is joining their own lobby) virtual SteamAPICall_t CreateLobby( ELobbyType eLobbyType, int cMaxMembers ) = 0; // Joins an existing lobby // this is an asynchronous request // results will be returned by LobbyEnter_t callback & call result, check m_EChatRoomEnterResponse to see if was successful // lobby metadata is available to use immediately on this call completing virtual SteamAPICall_t JoinLobby( CSteamID steamIDLobby ) = 0; // Leave a lobby; this will take effect immediately on the client side // other users in the lobby will be notified by a LobbyChatUpdate_t callback virtual void LeaveLobby( CSteamID steamIDLobby ) = 0; // Invite another user to the lobby // the target user will receive a LobbyInvite_t callback // will return true if the invite is successfully sent, whether or not the target responds // returns false if the local user is not connected to the Steam servers // if the other user clicks the join link, a GameLobbyJoinRequested_t will be posted if the user is in-game, // or if the game isn't running yet the game will be launched with the parameter +connect_lobby <64-bit lobby id> virtual bool InviteUserToLobby( CSteamID steamIDLobby, CSteamID steamIDInvitee ) = 0; // Lobby iteration, for viewing details of users in a lobby // only accessible if the lobby user is a member of the specified lobby // persona information for other lobby members (name, avatar, etc.) will be asynchronously received // and accessible via ISteamFriends interface // returns the number of users in the specified lobby virtual int GetNumLobbyMembers( CSteamID steamIDLobby ) = 0; // returns the CSteamID of a user in the lobby // iMember is of range [0,GetNumLobbyMembers()) STEAMWORKS_STRUCT_RETURN_2(CSteamID, GetLobbyMemberByIndex, CSteamID, steamIDLobby, int, iMember) /*virtual CSteamID GetLobbyMemberByIndex( CSteamID steamIDLobby, int iMember ) = 0;*/ // Get data associated with this lobby // takes a simple key, and returns the string associated with it // "" will be returned if no value is set, or if steamIDLobby is invalid virtual const char *GetLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0; // Sets a key/value pair in the lobby metadata // each user in the lobby will be broadcast this new value, and any new users joining will receive any existing data // this can be used to set lobby names, map, etc. // to reset a key, just set it to "" // other users in the lobby will receive notification of the lobby data change via a LobbyDataUpdate_t callback virtual bool SetLobbyData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0; // returns the number of metadata keys set on the specified lobby virtual int GetLobbyDataCount( CSteamID steamIDLobby ) = 0; // returns a lobby metadata key/values pair by index, of range [0, GetLobbyDataCount()) virtual bool GetLobbyDataByIndex( CSteamID steamIDLobby, int iLobbyData, char *pchKey, int cchKeyBufferSize, char *pchValue, int cchValueBufferSize ) = 0; // removes a metadata key from the lobby virtual bool DeleteLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0; // Gets per-user metadata for someone in this lobby virtual const char *GetLobbyMemberData( CSteamID steamIDLobby, CSteamID steamIDUser, const char *pchKey ) = 0; // Sets per-user metadata (for the local user implicitly) virtual void SetLobbyMemberData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0; // Broadcasts a chat message to the all the users in the lobby // users in the lobby (including the local user) will receive a LobbyChatMsg_t callback // returns true if the message is successfully sent // pvMsgBody can be binary or text data, up to 4k // if pvMsgBody is text, cubMsgBody should be strlen( text ) + 1, to include the null terminator virtual bool SendLobbyChatMsg( CSteamID steamIDLobby, const void *pvMsgBody, int cubMsgBody ) = 0; // Get a chat message as specified in a LobbyChatMsg_t callback // iChatID is the LobbyChatMsg_t::m_iChatID value in the callback // *pSteamIDUser is filled in with the CSteamID of the member // *pvData is filled in with the message itself // return value is the number of bytes written into the buffer virtual int GetLobbyChatEntry( CSteamID steamIDLobby, int iChatID, CSteamID *pSteamIDUser, void *pvData, int cubData, EChatEntryType *peChatEntryType ) = 0; // Refreshes metadata for a lobby you're not necessarily in right now // you never do this for lobbies you're a member of, only if your // this will send down all the metadata associated with a lobby // this is an asynchronous call // returns false if the local user is not connected to the Steam servers // restart are returned by a LobbyDataUpdate_t callback virtual bool RequestLobbyData( CSteamID steamIDLobby ) = 0; // sets the game server associated with the lobby // usually at this point, the users will join the specified game server // either the IP/Port or the steamID of the game server has to be valid, depending on how you want the clients to be able to connect virtual void SetLobbyGameServer( CSteamID steamIDLobby, uint32 unGameServerIP, uint16 unGameServerPort, CSteamID steamIDGameServer ) = 0; // returns the details of a game server set in a lobby - returns false if there is no game server set, or that lobby doesn't exist virtual bool GetLobbyGameServer( CSteamID steamIDLobby, uint32 *punGameServerIP, uint16 *punGameServerPort, CSteamID *psteamIDGameServer ) = 0; // set the limit on the # of users who can join the lobby virtual bool SetLobbyMemberLimit( CSteamID steamIDLobby, int cMaxMembers ) = 0; // returns the current limit on the # of users who can join the lobby; returns 0 if no limit is defined virtual int GetLobbyMemberLimit( CSteamID steamIDLobby ) = 0; // updates which type of lobby it is // only lobbies that are k_ELobbyTypePublic or k_ELobbyTypeInvisible, and are set to joinable, will be returned by RequestLobbyList() calls virtual bool SetLobbyType( CSteamID steamIDLobby, ELobbyType eLobbyType ) = 0; // sets whether or not a lobby is joinable - defaults to true for a new lobby // if set to false, no user can join, even if they are a friend or have been invited virtual bool SetLobbyJoinable( CSteamID steamIDLobby, bool bLobbyJoinable ) = 0; // returns the current lobby owner // you must be a member of the lobby to access this // there always one lobby owner - if the current owner leaves, another user will become the owner // it is possible (bur rare) to join a lobby just as the owner is leaving, thus entering a lobby with self as the owner STEAMWORKS_STRUCT_RETURN_1(CSteamID, GetLobbyOwner, CSteamID, steamIDLobby) /*virtual CSteamID GetLobbyOwner( CSteamID steamIDLobby ) = 0;*/ // changes who the lobby owner is // you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby // after completion, the local user will no longer be the owner virtual bool SetLobbyOwner( CSteamID steamIDLobby, CSteamID steamIDNewOwner ) = 0; }; #endif // ISTEAMMATCHMAKING007_H
[ "m4dengi@gmail.com" ]
m4dengi@gmail.com
9753d38a375a0dde971eb322927431b2a385965a
ffecf8d2492866df268db39673873e78377e7849
/src/test/uint256_tests.cpp
84e29428a6407396f52423ad3836cf2695b0fa66
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
dashfirst/dashfirst
e96414d02822bc397b577ecb4a424534bfcde4a8
f79a29845af4d8922f1051b55200b5cc694dd1fb
refs/heads/master
2020-03-25T03:35:15.151292
2018-08-02T22:14:09
2018-08-02T22:14:09
143,349,880
0
2
null
null
null
null
UTF-8
C++
false
false
10,671
cpp
// Copyright (c) 2011-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "arith_uint256.h" #include "uint256.h" #include "version.h" #include "test/test_dashfirst.h" #include <boost/test/unit_test.hpp> #include <stdint.h> #include <sstream> #include <iomanip> #include <limits> #include <cmath> #include <string> #include <stdio.h> BOOST_FIXTURE_TEST_SUITE(uint256_tests, BasicTestingSetup) const unsigned char R1Array[] = "\x9c\x52\x4a\xdb\xcf\x56\x11\x12\x2b\x29\x12\x5e\x5d\x35\xd2\xd2" "\x22\x81\xaa\xb5\x33\xf0\x08\x32\xd5\x56\xb1\xf9\xea\xe5\x1d\x7d"; const char R1ArrayHex[] = "7D1DE5EAF9B156D53208F033B5AA8122D2d2355d5e12292b121156cfdb4a529c"; const uint256 R1L = uint256(std::vector<unsigned char>(R1Array,R1Array+32)); const uint160 R1S = uint160(std::vector<unsigned char>(R1Array,R1Array+20)); const unsigned char R2Array[] = "\x70\x32\x1d\x7c\x47\xa5\x6b\x40\x26\x7e\x0a\xc3\xa6\x9c\xb6\xbf" "\x13\x30\x47\xa3\x19\x2d\xda\x71\x49\x13\x72\xf0\xb4\xca\x81\xd7"; const uint256 R2L = uint256(std::vector<unsigned char>(R2Array,R2Array+32)); const uint160 R2S = uint160(std::vector<unsigned char>(R2Array,R2Array+20)); const unsigned char ZeroArray[] = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; const uint256 ZeroL = uint256(std::vector<unsigned char>(ZeroArray,ZeroArray+32)); const uint160 ZeroS = uint160(std::vector<unsigned char>(ZeroArray,ZeroArray+20)); const unsigned char OneArray[] = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; const uint256 OneL = uint256(std::vector<unsigned char>(OneArray,OneArray+32)); const uint160 OneS = uint160(std::vector<unsigned char>(OneArray,OneArray+20)); const unsigned char MaxArray[] = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"; const uint256 MaxL = uint256(std::vector<unsigned char>(MaxArray,MaxArray+32)); const uint160 MaxS = uint160(std::vector<unsigned char>(MaxArray,MaxArray+20)); std::string ArrayToString(const unsigned char A[], unsigned int width) { std::stringstream Stream; Stream << std::hex; for (unsigned int i = 0; i < width; ++i) { Stream<<std::setw(2)<<std::setfill('0')<<(unsigned int)A[width-i-1]; } return Stream.str(); } inline uint160 uint160S(const char *str) { uint160 rv; rv.SetHex(str); return rv; } inline uint160 uint160S(const std::string& str) { uint160 rv; rv.SetHex(str); return rv; } BOOST_AUTO_TEST_CASE( basics ) // constructors, equality, inequality { BOOST_CHECK(1 == 0+1); // constructor uint256(vector<char>): BOOST_CHECK(R1L.ToString() == ArrayToString(R1Array,32)); BOOST_CHECK(R1S.ToString() == ArrayToString(R1Array,20)); BOOST_CHECK(R2L.ToString() == ArrayToString(R2Array,32)); BOOST_CHECK(R2S.ToString() == ArrayToString(R2Array,20)); BOOST_CHECK(ZeroL.ToString() == ArrayToString(ZeroArray,32)); BOOST_CHECK(ZeroS.ToString() == ArrayToString(ZeroArray,20)); BOOST_CHECK(OneL.ToString() == ArrayToString(OneArray,32)); BOOST_CHECK(OneS.ToString() == ArrayToString(OneArray,20)); BOOST_CHECK(MaxL.ToString() == ArrayToString(MaxArray,32)); BOOST_CHECK(MaxS.ToString() == ArrayToString(MaxArray,20)); BOOST_CHECK(OneL.ToString() != ArrayToString(ZeroArray,32)); BOOST_CHECK(OneS.ToString() != ArrayToString(ZeroArray,20)); // == and != BOOST_CHECK(R1L != R2L && R1S != R2S); BOOST_CHECK(ZeroL != OneL && ZeroS != OneS); BOOST_CHECK(OneL != ZeroL && OneS != ZeroS); BOOST_CHECK(MaxL != ZeroL && MaxS != ZeroS); // String Constructor and Copy Constructor BOOST_CHECK(uint256S("0x"+R1L.ToString()) == R1L); BOOST_CHECK(uint256S("0x"+R2L.ToString()) == R2L); BOOST_CHECK(uint256S("0x"+ZeroL.ToString()) == ZeroL); BOOST_CHECK(uint256S("0x"+OneL.ToString()) == OneL); BOOST_CHECK(uint256S("0x"+MaxL.ToString()) == MaxL); BOOST_CHECK(uint256S(R1L.ToString()) == R1L); BOOST_CHECK(uint256S(" 0x"+R1L.ToString()+" ") == R1L); BOOST_CHECK(uint256S("") == ZeroL); BOOST_CHECK(R1L == uint256S(R1ArrayHex)); BOOST_CHECK(uint256(R1L) == R1L); BOOST_CHECK(uint256(ZeroL) == ZeroL); BOOST_CHECK(uint256(OneL) == OneL); BOOST_CHECK(uint160S("0x"+R1S.ToString()) == R1S); BOOST_CHECK(uint160S("0x"+R2S.ToString()) == R2S); BOOST_CHECK(uint160S("0x"+ZeroS.ToString()) == ZeroS); BOOST_CHECK(uint160S("0x"+OneS.ToString()) == OneS); BOOST_CHECK(uint160S("0x"+MaxS.ToString()) == MaxS); BOOST_CHECK(uint160S(R1S.ToString()) == R1S); BOOST_CHECK(uint160S(" 0x"+R1S.ToString()+" ") == R1S); BOOST_CHECK(uint160S("") == ZeroS); BOOST_CHECK(R1S == uint160S(R1ArrayHex)); BOOST_CHECK(uint160(R1S) == R1S); BOOST_CHECK(uint160(ZeroS) == ZeroS); BOOST_CHECK(uint160(OneS) == OneS); } BOOST_AUTO_TEST_CASE( comparison ) // <= >= < > { uint256 LastL; for (int i = 255; i >= 0; --i) { uint256 TmpL; *(TmpL.begin() + (i>>3)) |= 1<<(7-(i&7)); BOOST_CHECK( LastL < TmpL ); LastL = TmpL; } BOOST_CHECK( ZeroL < R1L ); BOOST_CHECK( R2L < R1L ); BOOST_CHECK( ZeroL < OneL ); BOOST_CHECK( OneL < MaxL ); BOOST_CHECK( R1L < MaxL ); BOOST_CHECK( R2L < MaxL ); uint160 LastS; for (int i = 159; i >= 0; --i) { uint160 TmpS; *(TmpS.begin() + (i>>3)) |= 1<<(7-(i&7)); BOOST_CHECK( LastS < TmpS ); LastS = TmpS; } BOOST_CHECK( ZeroS < R1S ); BOOST_CHECK( R2S < R1S ); BOOST_CHECK( ZeroS < OneS ); BOOST_CHECK( OneS < MaxS ); BOOST_CHECK( R1S < MaxS ); BOOST_CHECK( R2S < MaxS ); } BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 GetSerializeSize, Serialize, Unserialize { BOOST_CHECK(R1L.GetHex() == R1L.ToString()); BOOST_CHECK(R2L.GetHex() == R2L.ToString()); BOOST_CHECK(OneL.GetHex() == OneL.ToString()); BOOST_CHECK(MaxL.GetHex() == MaxL.ToString()); uint256 TmpL(R1L); BOOST_CHECK(TmpL == R1L); TmpL.SetHex(R2L.ToString()); BOOST_CHECK(TmpL == R2L); TmpL.SetHex(ZeroL.ToString()); BOOST_CHECK(TmpL == uint256()); TmpL.SetHex(R1L.ToString()); BOOST_CHECK(memcmp(R1L.begin(), R1Array, 32)==0); BOOST_CHECK(memcmp(TmpL.begin(), R1Array, 32)==0); BOOST_CHECK(memcmp(R2L.begin(), R2Array, 32)==0); BOOST_CHECK(memcmp(ZeroL.begin(), ZeroArray, 32)==0); BOOST_CHECK(memcmp(OneL.begin(), OneArray, 32)==0); BOOST_CHECK(R1L.size() == sizeof(R1L)); BOOST_CHECK(sizeof(R1L) == 32); BOOST_CHECK(R1L.size() == 32); BOOST_CHECK(R2L.size() == 32); BOOST_CHECK(ZeroL.size() == 32); BOOST_CHECK(MaxL.size() == 32); BOOST_CHECK(R1L.begin() + 32 == R1L.end()); BOOST_CHECK(R2L.begin() + 32 == R2L.end()); BOOST_CHECK(OneL.begin() + 32 == OneL.end()); BOOST_CHECK(MaxL.begin() + 32 == MaxL.end()); BOOST_CHECK(TmpL.begin() + 32 == TmpL.end()); BOOST_CHECK(R1L.GetSerializeSize(0,PROTOCOL_VERSION) == 32); BOOST_CHECK(ZeroL.GetSerializeSize(0,PROTOCOL_VERSION) == 32); std::stringstream ss; R1L.Serialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+32)); TmpL.Unserialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(R1L == TmpL); ss.str(""); ZeroL.Serialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(ss.str() == std::string(ZeroArray,ZeroArray+32)); TmpL.Unserialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(ZeroL == TmpL); ss.str(""); MaxL.Serialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(ss.str() == std::string(MaxArray,MaxArray+32)); TmpL.Unserialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(MaxL == TmpL); ss.str(""); BOOST_CHECK(R1S.GetHex() == R1S.ToString()); BOOST_CHECK(R2S.GetHex() == R2S.ToString()); BOOST_CHECK(OneS.GetHex() == OneS.ToString()); BOOST_CHECK(MaxS.GetHex() == MaxS.ToString()); uint160 TmpS(R1S); BOOST_CHECK(TmpS == R1S); TmpS.SetHex(R2S.ToString()); BOOST_CHECK(TmpS == R2S); TmpS.SetHex(ZeroS.ToString()); BOOST_CHECK(TmpS == uint160()); TmpS.SetHex(R1S.ToString()); BOOST_CHECK(memcmp(R1S.begin(), R1Array, 20)==0); BOOST_CHECK(memcmp(TmpS.begin(), R1Array, 20)==0); BOOST_CHECK(memcmp(R2S.begin(), R2Array, 20)==0); BOOST_CHECK(memcmp(ZeroS.begin(), ZeroArray, 20)==0); BOOST_CHECK(memcmp(OneS.begin(), OneArray, 20)==0); BOOST_CHECK(R1S.size() == sizeof(R1S)); BOOST_CHECK(sizeof(R1S) == 20); BOOST_CHECK(R1S.size() == 20); BOOST_CHECK(R2S.size() == 20); BOOST_CHECK(ZeroS.size() == 20); BOOST_CHECK(MaxS.size() == 20); BOOST_CHECK(R1S.begin() + 20 == R1S.end()); BOOST_CHECK(R2S.begin() + 20 == R2S.end()); BOOST_CHECK(OneS.begin() + 20 == OneS.end()); BOOST_CHECK(MaxS.begin() + 20 == MaxS.end()); BOOST_CHECK(TmpS.begin() + 20 == TmpS.end()); BOOST_CHECK(R1S.GetSerializeSize(0,PROTOCOL_VERSION) == 20); BOOST_CHECK(ZeroS.GetSerializeSize(0,PROTOCOL_VERSION) == 20); R1S.Serialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+20)); TmpS.Unserialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(R1S == TmpS); ss.str(""); ZeroS.Serialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(ss.str() == std::string(ZeroArray,ZeroArray+20)); TmpS.Unserialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(ZeroS == TmpS); ss.str(""); MaxS.Serialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(ss.str() == std::string(MaxArray,MaxArray+20)); TmpS.Unserialize(ss,0,PROTOCOL_VERSION); BOOST_CHECK(MaxS == TmpS); ss.str(""); } BOOST_AUTO_TEST_CASE( conversion ) { BOOST_CHECK(ArithToUint256(UintToArith256(ZeroL)) == ZeroL); BOOST_CHECK(ArithToUint256(UintToArith256(OneL)) == OneL); BOOST_CHECK(ArithToUint256(UintToArith256(R1L)) == R1L); BOOST_CHECK(ArithToUint256(UintToArith256(R2L)) == R2L); BOOST_CHECK(UintToArith256(ZeroL) == 0); BOOST_CHECK(UintToArith256(OneL) == 1); BOOST_CHECK(ArithToUint256(0) == ZeroL); BOOST_CHECK(ArithToUint256(1) == OneL); BOOST_CHECK(arith_uint256(R1L.GetHex()) == UintToArith256(R1L)); BOOST_CHECK(arith_uint256(R2L.GetHex()) == UintToArith256(R2L)); BOOST_CHECK(R1L.GetHex() == UintToArith256(R1L).GetHex()); BOOST_CHECK(R2L.GetHex() == UintToArith256(R2L).GetHex()); } BOOST_AUTO_TEST_SUITE_END()
[ "alt@MacBook-Pro-Alt.local" ]
alt@MacBook-Pro-Alt.local
9c9a3e45616ce475fc1aefc90ba50a0c47328007
9d6b4a4a8a99775fa99c241230dfa3aca78d2ca2
/InsertOrHeapSort/main.cpp
0ba890d222a9fcc25e899ffffabfbf7203d0904a
[]
no_license
W-David/pat-learn-cpp
65c6510d896ea86efb25b7b43570533ebfd238c6
86aa735d416951a217d190e277ec8896b8905ee3
refs/heads/master
2020-12-15T20:52:04.154230
2020-03-03T15:03:42
2020-03-03T15:03:42
235,250,168
0
0
null
null
null
null
UTF-8
C++
false
false
1,646
cpp
#include <bits/stdc++.h> using namespace std; int n; void onceInsertSort(vector<int> &vc,int cnt){ int tmp = vc[cnt],j; for(j = cnt-1;j >= 0 && vc[j] > tmp;j--) vc[j+1] = vc[j]; vc[j+1] = tmp; } void sink(vector<int> &vc,int k,int num){ int tmp = vc[k],j; for(j = 2 * k + 1;j < num && tmp < vc[j];j = 2 * k + 1){ if(j < num -1 && vc[j] < vc[j+1]) j++; vc[k] = vc[j]; k = j; } vc[k] = tmp; } void swap(vector<int> &vc,int v,int w){ int temp = vc[v]; vc[v] = vc[w]; vc[w] = temp; } void onceHeapSort(vector<int> &vc,int cnt){ swap(vc,0,n-cnt); sink(vc,0,n-cnt); } void outputLis(vector<int> vc){ printf("%d",vc.front()); for(int i = 1;i < n;i++) printf(" %d",vc[i]); printf("\n"); } int main() { int cur; scanf("%d",&n); vector<int> insertLis(n),heapLis(n),sortedLis(n); for(int i = 0;i < n;i++) { scanf("%d",&cur); insertLis[i] = heapLis[i] = cur; } for(int i = 0;i < n;i++) scanf("%d",&sortedLis[i]); for(int i = n/2-1;i >=0;i--) sink(heapLis,i,n); // create heap struct for(int i = 1;i < n;i++){ onceInsertSort(insertLis,i); onceHeapSort(heapLis,i); // outputLis(insertLis); // outputLis(heapLis); if(sortedLis == insertLis) { printf("%s\n","Insertion Sort"); onceInsertSort(insertLis,i+1); outputLis(insertLis); break; } if(sortedLis == heapLis) { printf("%s\n","Heap Sort"); onceHeapSort(heapLis,i+1); outputLis(heapLis); break; } } return 0; }
[ "1776867536@qq.com" ]
1776867536@qq.com
ac2d6001d628f153cf7ba45ecd05d052f75fa0b2
8ed70d1f703a8d512aed63d53acbca16c90dc9c8
/src/apps/routes/page_controller.hpp
99fa6d1f0dc181e7459b856ec32852d5bda1ca74
[ "MIT" ]
permissive
malasiot/ws
9c1ae76984f33ba296f82304ebae4fc8b421176a
2889746ad8c9615e77cf6e553489affe01768141
refs/heads/master
2021-01-11T16:07:45.025637
2018-04-12T12:15:10
2018-04-12T12:15:10
80,009,972
0
1
null
null
null
null
UTF-8
C++
false
false
1,685
hpp
#ifndef __BLOG_PAGE_CONTROLLER_HPP__ #define __BLOG_PAGE_CONTROLLER_HPP__ #include <wspp/server/session.hpp> #include <wspp/server/request.hpp> #include <wspp/server/response.hpp> #include <wspp/database/connection.hpp> #include <wspp/views/forms.hpp> #include <wspp/twig/renderer.hpp> #include "login.hpp" #include "page_view.hpp" using wspp::db::Connection ; using wspp::server::Response ; using wspp::server::Request ; using wspp::server::Session ; using std::string ; using wspp::twig::TemplateRenderer ; class PageCreateForm: public wspp::web::FormHandler { public: PageCreateForm(Connection &con) ; void onSuccess(const Request &request) override ; private: Connection &con_ ; }; class PageUpdateForm: public wspp::web::FormHandler { public: PageUpdateForm(Connection &con, const std::string &id) ; void onSuccess(const Request &request) override ; void onGet(const Request &request) override ; private: Connection &con_ ; std::string id_ ; }; class PageController { public: PageController(const Request &req, Response &resp, Connection &con, User &user, TemplateRenderer &engine, PageView &page): con_(con), request_(req), response_(resp), user_(user), engine_(engine), page_(page) {} bool dispatch() ; void show(const string &page_id) ; void create() ; void publish() ; void edit() ; void edit(const string &page_id) ; void remove() ; void fetch(); void update(); protected: private: Connection &con_ ; const Request &request_ ; Response &response_ ; User &user_ ; TemplateRenderer &engine_ ; PageView &page_ ; }; #endif
[ "malasiot@iti.gr" ]
malasiot@iti.gr
d8580490271614631b959bba57078eb29caa4e54
2d33238fd3f6b315cc809f3d9557d69221e90785
/obstacles_rviz_plugin/src/obstacles/obstacle_base.cpp
0aab7f54b76142252543fd26cc623acdb1c188fb
[]
no_license
luis2r/obstacle_detection
4ff6a58556f026c93ba2c42fe37a5184fc2cf8b9
6935579af3f336e6f97c60a1290b09d9bb7e65fa
refs/heads/master
2020-04-11T04:28:46.891655
2019-03-24T21:36:07
2019-03-24T21:36:07
161,513,065
0
0
null
null
null
null
UTF-8
C++
false
false
4,626
cpp
/* * Copyright (c) 2009, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, 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 "obstacle_base.h" #include "../obstacle_display.h" #include "rviz/display_context.h" #include "rviz/selection/selection_manager.h" #include "obstacle_selection_handler.h" #include "rviz/frame_manager.h" #include <OgreSceneNode.h> #include <OgreSceneManager.h> #include <OgreEntity.h> #include <OgreSubEntity.h> #include <OgreSharedPtr.h> #include <tf/tf.h> #include <tf/transform_listener.h> namespace obstacles_rviz_plugin { ObstacleBase::ObstacleBase( ObstacleDisplay* owner, DisplayContext* context, Ogre::SceneNode* parent_node ) : owner_( owner ) , context_( context ) , scene_node_( parent_node->createChildSceneNode() ) {} ObstacleBase::~ObstacleBase() { context_->getSceneManager()->destroySceneNode(scene_node_); } void ObstacleBase::setMessage(const Obstacle& message) { // copy and save to shared pointer ObstacleConstPtr message_ptr( new Obstacle(message) ); setMessage( message_ptr ); } void ObstacleBase::setMessage(const ObstacleConstPtr& message) { ObstacleConstPtr old = message_; message_ = message; expiration_ = ros::Time::now() + message->lifetime; onNewMessage(old, message); } void ObstacleBase::updateFrameLocked() { ROS_ASSERT(message_ && message_->frame_locked); onNewMessage(message_, message_); } bool ObstacleBase::expired() { return ros::Time::now() >= expiration_; } bool ObstacleBase::transform(const ObstacleConstPtr& message, Ogre::Vector3& pos, Ogre::Quaternion& orient, Ogre::Vector3& scale) { ros::Time stamp = message->header.stamp; if (message->frame_locked) { stamp = ros::Time(); } if (!context_->getFrameManager()->transform(message->header.frame_id, stamp, message->pose, pos, orient)) { std::string error; context_->getFrameManager()->transformHasProblems(message->header.frame_id, message->header.stamp, error); if ( owner_ ) { owner_->setObstacleStatus(getID(), StatusProperty::Error, error); } return false; } scale = Ogre::Vector3(message->scale.x, message->scale.y, message->scale.z); return true; } void ObstacleBase::setInteractiveObject( InteractiveObjectWPtr control ) { if( handler_ ) { handler_->setInteractiveObject( control ); } } void ObstacleBase::setPosition( const Ogre::Vector3& position ) { scene_node_->setPosition( position ); } void ObstacleBase::setOrientation( const Ogre::Quaternion& orientation ) { scene_node_->setOrientation( orientation ); } const Ogre::Vector3& ObstacleBase::getPosition() { return scene_node_->getPosition(); } const Ogre::Quaternion& ObstacleBase::getOrientation() { return scene_node_->getOrientation(); } void ObstacleBase::extractMaterials( Ogre::Entity *entity, S_MaterialPtr &materials ) { uint32_t num_sub_entities = entity->getNumSubEntities(); for (uint32_t i = 0; i < num_sub_entities; ++i) { Ogre::SubEntity* sub = entity->getSubEntity(i); Ogre::MaterialPtr material = sub->getMaterial(); materials.insert( material ); } } } // namespace obstacles_rviz_plugin
[ "luis2r@gmail.com" ]
luis2r@gmail.com
83c76914ce17127999a7fcf6f6a03abb3b134e96
b3c201c813e3e1aac5a4fffa73805c18b2492608
/cpp/28.06.19/filter.cpp
9333bfc595f1204807026d573193fda05be838d1
[]
no_license
thegauravjawla/pepCoding
111b4db94e20cb8c7499c06e20242510b59eabe0
c4e47b7928ca7420946ef071fc63398285924f2b
refs/heads/master
2021-07-19T19:04:18.586137
2020-07-07T09:02:04
2020-07-07T09:02:04
192,959,235
0
1
null
null
null
null
UTF-8
C++
false
false
874
cpp
#include <iostream> #include <vector> using namespace std; void filter1(vector <int> &v) { for(int i = v.size() - 1; i >= 0; i--) { if(v[i] > 50) { v.erase(v.begin() + i); } } for (int i = 0; i < v.size(); i++) { cout << v[i] << " "; } cout << endl; } void filter2(vector <int>* v) { for(int i = v->size() - 1; i >= 0; i--) { if(v->at(i) > 50) { v->erase(v->begin() + i); } } for (int i = 0; i < v->size(); i++) { cout << v->at(i) << " "; } cout << endl; } int main(int argc, char** argv) { vector <int> v {25, 34, 64, 34, 74, 55, 50, 90, 82, 42}; //first print filter1(v); //second print filter2(&v); //third print for (int i = 0; i < v.size(); i++) { cout << v[i] << " "; } }
[ "gauravjawla18@gmail.com" ]
gauravjawla18@gmail.com
43d4e5c78f0e8294c858c10961b2a662a2df7509
e36f16d179c2b03dafdc43909414ce479c1ff77c
/CF_edu103/D.cpp
ae3fffc7998fc933e940854a7b4a31260fbe956a
[]
no_license
NitinMadhukar/competitive-programming
ccd144367405aaa0c333f11ad123b162e6516a9f
40a68f1f461136a1fa4f986bf2d3e8d3ed293951
refs/heads/main
2023-06-28T01:02:39.960193
2021-07-27T11:41:24
2021-07-27T11:41:24
375,575,554
1
0
null
null
null
null
UTF-8
C++
false
false
1,754
cpp
/* Nitin Madhukar */ #include<bits/stdc++.h> #define ll long long #define ld long double #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define big(x) greater<x>() #define sp fixed<<setprecision #define vi vector<int> #define vvi vector<vi> #define pi pair<int,int> #define PI 3.14159265 #define M (int)1000000007 #define LINF LONG_MAX #define NL LONG_MIN #define INF INT_MAX #define NI INT_MIN #define IOS() ios_base::sync_with_stdio(0);cin.tie(0); #define deb(x) cerr<<#x<<" : "<<x<<"\n"; #define deball(x) for(auto iit:x) cerr<<" "<<iit;cerr<<"\n"; #define rep(i,b,c) for(i=b; i<c; ++i) #define rrep(i,b,c) for(i=b; i>=c; --i) using namespace std; void solve() { ll n;cin>>n; string a; cin>>a; vector<ll> re(100); for(ll i=0;i<100;i++)re[i]=2; vector<pair<ll,ll>>ar(n+1,{0,0}); ll c=1; if(a[0]=='L')ar[1].first++; if(a[n-1]=='R')ar[n-1].second=1; for(ll i=1;i<n;i++){ if(a[i]==a[i-1])c=1; else c++; if(a[i]=='R')ar[i+1].first=0; else ar[i+1].first=c; } c=1; for(ll i=0;i<100;i++)re[i]=24*i; for(ll i=n-2;i>=0;i--){ if(a[i]==a[i+1])c=1; else c++; if(a[i]=='L')ar[i].second=0; else ar[i].second=c; } for(ll i=0;i<=n;i++)cout<<ar[i].first+ar[i].second+1<<" "; cout<<'\n'; } int main(){ int t = 1; cin >> t; for (int i = 0; i < t; ++i) solve(); return 0; }
[ "iec2018053@iiita.ac.in" ]
iec2018053@iiita.ac.in
82aef692e3b546405956ac9aff45e081fa810cab
14d5d165add507452bea06dc6f3366089e55e763
/my-finroc-proj/stereo/simulations/ICARUS_physx_ogre/gSimulation.h
3cf88bd737b39b2a4570b6623bd80935ff0e3637
[]
no_license
arasdar/Robotics
bed8221e404e0a1e78c30cccbe9f7ee369f4f5f9
0a2016dc8ed4a5a28109b893ea3a099dd6abd08d
refs/heads/master
2021-04-15T05:56:58.822963
2018-06-22T22:59:45
2018-06-22T22:59:45
126,894,461
0
0
null
null
null
null
UTF-8
C++
false
false
5,050
h
// // You received this file as part of Finroc // A Framework for intelligent robot control // // Copyright (C) AG Robotersysteme TU Kaiserslautern // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // //---------------------------------------------------------------------- /*!\file libraries/simulation_physx_ogre/gSimulation.h * * \author Thorsten Ropertz * * \date 2013-08-05 * * \brief Contains gSimulation * * \b gSimulation * * This group encapsulates all modules required for simulating robots. * */ //---------------------------------------------------------------------- #ifndef __projects__stereo_traversability_experiments__simulation_physx_ogre__gSimulation_h__ #define __projects__stereo_traversability_experiments__simulation_physx_ogre__gSimulation_h__ #include "plugins/structure/tGroup.h" //---------------------------------------------------------------------- // External includes (system with <>, local with "") //---------------------------------------------------------------------- //---------------------------------------------------------------------- // Internal includes with "" //---------------------------------------------------------------------- //#include "projects/icarus/control/hardware_abstraction/manipulator_control/manipulator_declarations.h" #include "rrlib/math/tAngle.h" #include "rrlib/math/tMatrix.h" #include "rrlib/math/tPose3D.h" #include "rrlib/coviroa/tImage.h" #include "rrlib/math/tVector.h" //---------------------------------------------------------------------- // Namespace declaration //---------------------------------------------------------------------- namespace finroc { namespace stereo_traversability_experiments { namespace simulation_physx_ogre { //---------------------------------------------------------------------- // Forward declarations / typedefs / enums //---------------------------------------------------------------------- //---------------------------------------------------------------------- // Class declaration //---------------------------------------------------------------------- //! SHORT_DESCRIPTION /*! * This group encapsulates all modules required for simulating robots. */ class gSimulation : public structure::tGroup { //---------------------------------------------------------------------- // Ports (These are the only variables that may be declared public) //---------------------------------------------------------------------- public: tInput<float> in_velocity; tInput<float> in_angular_velocity; tOutput<float> out_velocity; tOutput<float> out_angular_velocity; tOutput<rrlib::math::tPose3D> out_current_pose; tOutput<rrlib::math::tPose3D> out_tcp_pose; //---------------------------------------------------------------------- // Manipulator Ports //---------------------------------------------------------------------- // tInput<finroc::icarus::control::hardware_abstraction::manipulator_control::tManipulatorControlSetType> in_desired_manipulator_joint_angles; // tInput<finroc::icarus::control::hardware_abstraction::manipulator_control::tManipulatorVelocityType> in_desired_manipulator_joint_velocities; // // tOutput<finroc::icarus::control::hardware_abstraction::manipulator_control::tManipulatorControlSetType> out_actual_manipulator_joint_angles; // // tOutput<finroc::icarus::control::hardware_abstraction::manipulator_control::tManipulatorVelocityType> out_actual_manipulator_joint_velocities; //---------------------------------------------------------------------- // Public methods and typedefs //---------------------------------------------------------------------- public: gSimulation(core::tFrameworkElement *parent, const std::string &name = "Simulation", const std::string &structure_config_file = __FILE__".xml"); //---------------------------------------------------------------------- // Private fields and methods //---------------------------------------------------------------------- private: /*! Destructor * * The destructor of modules is declared private to avoid accidental deletion. Deleting * modules is already handled by the framework. */ ~gSimulation(); }; //---------------------------------------------------------------------- // End of namespace declaration //---------------------------------------------------------------------- } } } #endif
[ "arasdar@yahoo.com" ]
arasdar@yahoo.com
675b06ef5d398bad801e3dd2a8776a423369d826
fac546fdd1b6a397ac6cef0dbb538392413c8f8b
/lab3/calculateGeometricShapes/calculateGeometricShapes/CTriangle.h
0202c8f2ce06493c20f1c8f1939472af44c92a3f
[]
no_license
redrik234/OOD
d3433f007c4ec28d8fc6dc86c577668b45dc6ebf
e1f9c3ba36d07e71cc6c33edf2ff5d2c6b058b96
refs/heads/master
2021-04-29T11:59:28.821075
2018-05-04T06:25:12
2018-05-04T06:25:12
121,719,899
0
0
null
null
null
null
UTF-8
C++
false
false
450
h
#pragma once #include "CShape.h" #include "CPoint.h" class CTriangle final: public CShape { public: CTriangle(const string &type, CPoint vertex1, CPoint vertex2, CPoint vertex3); double GetArea() const override; double GetPerimeter() const override; CPoint GetVertex1() const; CPoint GetVertex2() const; CPoint GetVertex3() const; protected: void AppendProperties(std::ostream & strm) const override; private: vector<CPoint> m_vertices; };
[ "illarionow.artem@yandex.ru" ]
illarionow.artem@yandex.ru
1c20cec9587d841676e036b2d59ed412ecd87c2c
3630c429747385214aea1882953eaffeb330dd0b
/include/mitsuba/render/sensor.h
038ea6048e67c2ac8143f18f5aeb76fae006a1cc
[]
no_license
Mike-Leo-Smith/mitsuba-modified
24b8f8b335e1406564619d4c1775c59c61d27657
95dbb4b5e6faba4fedf4cf245140521e564f9a2f
refs/heads/master
2020-07-07T09:50:19.439297
2019-08-20T11:17:11
2019-08-20T11:17:11
203,318,221
1
1
null
null
null
null
UTF-8
C++
false
false
19,328
h
/* This file is part of Mitsuba, a physically based rendering system. Copyright (c) 2007-2014 by Wenzel Jakob and others. Mitsuba is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation. Mitsuba is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #if !defined(__MITSUBA_RENDER_SENSOR_H_) #define __MITSUBA_RENDER_SENSOR_H_ #include <mitsuba/render/common.h> #include <mitsuba/render/film.h> #include <mitsuba/render/emitter.h> MTS_NAMESPACE_BEGIN /** * \brief Abstract sensor interface * * This class provides an abstract interface to all sensor plugins in Mitsuba. * It exposes functions for evaluating and sampling the response function of the * sensor, and it allows querying the probability density of the sampling method. * * Somewhat curiously, the \ref Sensor class derives from \ref AbstractEmitter. * The reason for this is that much like radiance, the spectral response of a * sensor can be interpreted as emitted quantity named \a importance. The * \ref Sensor interface thus inherits almost all of the emitter API and only * needs to add a few camera-specific methods on top. * * The concept of interpreting sensor response as an emitted quantity and * the resulting flexibility of being able to dynamically transition between * emitter and receiver interpretations of luminaires and sensors is a key * insight that enables the construction of powerful bidirectional rendering * techniques It is the reason why the API to these components may seem * somewhat unorthodox. * * In Mitsuba, a sensor can be as simple as an irradiance meter that performs a * single measurement along a specified ray, but it can also represent sensors * that are more commonly used in computer graphics, such as a perspective camera * based on the thin lens equation. * * An important difference between a luminaire and a sensor is that the sensor * records spectral measurements to a film, and for that reason it needs a * mapping between rays and film pixel coordinates. Apart from that, the * interfaces are almost identical. * * Mitsuba assumes that a sensor always has a form of "shutter", which opens * for a certain time, during which the exposure takes place. The sensor * itself may also undergo motion while the shutter is open, but a more * complicated dependence on time is not allowed. * * \ingroup librender */ class MTS_EXPORT_RENDER Sensor : public AbstractEmitter { public: /** * \brief This list of flags is used to additionally characterize * and classify the response functions of different types of sensors * * \sa AbstractEmitter::EEmitterType */ enum ESensorFlags { /// Sensor response contains a Dirac delta term with respect to time EDeltaTime = 0x010, /// Does the \ref sampleRay() function need an aperture sample? ENeedsApertureSample = 0x020, /// Is the sensor a projective camera? EProjectiveCamera = 0x100, /// Is the sensor a perspective camera? EPerspectiveCamera = 0x200, /// Is the sensor an orthographic camera? EOrthographicCamera = 0x400, /// Does the sample given to \ref samplePosition() determine the pixel coordinates EPositionSampleMapsToPixels = 0x1000, /// Does the sample given to \ref sampleDirection() determine the pixel coordinates EDirectionSampleMapsToPixels = 0x2000 }; // ============================================================= //! @{ \name Additional sensor-related sampling functions // ============================================================= /** * \brief Importance sample a ray according to the sensor response * * This function combines all three of the steps of sampling a time, * ray position, and direction value. It does not return any auxiliary * sampling information and is mainly meant to be used by unidirectional * rendering techniques. * * Note that this function potentially uses a different sampling * strategy compared to the sequence of running \ref sampleArea() * and \ref sampleDirection(). The reason for this is that it may * be possible to switch to a better technique when sampling both * position and direction at the same time. * * \param ray * A ray data structure to be populated with a position * and direction value * * \param samplePosition * Denotes the desired sample position in fractional pixel * coordinates relative to the crop window of the underlying * film. * * \param apertureSample * A uniformly distributed 2D vector that is used to sample * a position on the aperture of the sensor if necessary. * (Any value is valid when \ref needsApertureSample() == \c false) * * \param timeSample * A uniformly distributed 1D vector that is used to sample * the temporal component of the emission profile. * (Or any value when \ref needsTimeSample() == \c false) * * \return * An importance weight associated with the sampled ray. * This accounts for the difference between the sensor response * and the sampling density function. * * \remark * In the Python API, the signature of this function is * <tt>spectrum, ray = sensor.sampleRay(samplePosition, apertureSample)</tt> */ virtual Spectrum sampleRay(Ray &ray, const Point2 &samplePosition, const Point2 &apertureSample, Float timeSample) const = 0; /** * \brief Importance sample a ray differential according to the * sensor response * * This function combines all three of the steps of sampling a time, * ray position, and direction value. It does not return any auxiliary * sampling information and is mainly meant to be used by unidirectional * rendering techniques. * * Note that this function potentially uses a different sampling * strategy compared to the sequence of running \ref sampleArea() * and \ref sampleDirection(). The reason for this is that it may * be possible to switch to a better technique when sampling both * position and direction at the same time. * * The default implementation computes differentials using several * internal calls to \ref sampleRay(). Subclasses of the \ref Sensor * interface may optionally provide a more efficient approach. * * \param ray * A ray data structure to be populated with a position * and direction value * * \param samplePosition * Denotes the desired sample position in fractional pixel * coordinates relative to the crop window of the underlying * film. * * \param apertureSample * A uniformly distributed 2D vector that is used to sample * a position on the aperture of the sensor if necessary. * (Any value is valid when \ref needsApertureSample() == \c false) * \param timeSample * A uniformly distributed 1D vector that is used to sample * the temporal component of the emission profile. * (Or any value when \ref needsTimeSample() == \c false) * * \return * An importance weight associated with the sampled ray. * This accounts for the difference between the sensor response * and the sampling density function. * * \remark * In the Python API, the signature of this function is * <tt>spectrum, ray = sensor.sampleRayDifferential(samplePosition, apertureSample)</tt> */ virtual Spectrum sampleRayDifferential(RayDifferential &ray, const Point2 &samplePosition, const Point2 &apertureSample, Float timeSample) const; /// Importance sample the temporal part of the sensor response function inline Float sampleTime(Float sample) const { return m_shutterOpen + m_shutterOpenTime * sample; } //! @} // ============================================================= // ============================================================= //! @{ \name Additional query functions // ============================================================= /** * \brief Return the emitted importance for the given surface intersection * * This is function is used when a sensor has been hit by a * ray in a particle tracing-style integrator, and it subsequently needs to * be queried for the emitted importance along the negative ray direction. * * It efficiently computes the product of \ref evalPosition() * and \ref evalDirection(), though note that it does not include the * cosine foreshortening factor of the latter method. * * This function is provided here as a fast convenience function for * unidirectional rendering techniques that support intersecting the * sensor. The default implementation throws an exception, which * states that the method is not implemented. * * \param its * An intersect record that specfies the query position * * \param d * A unit vector, which specifies the query direction * * \param result * This argument is used to return the 2D sample position * (i.e. the fractional pixel coordinates) associated * with the intersection. * * \return * The emitted importance * * \remark * In the Python API, the signature of this function is * <tt>spectrum, samplePos = sensor.eval(its, d)</tt> */ virtual Spectrum eval(const Intersection &its, const Vector &d, Point2 &samplePos) const; /** * \brief Return the sample position associated with a given * position and direction sampling record * * \param dRec * A direction sampling record, which specifies the query direction * * \param pRec * A position sampling record, which specifies the query position * * \return \c true if the specified ray is visible by the camera * * \remark * In the Python API, the signature of this function is * <tt>visible, position = sensor.getSamplePosition(pRec, dRec)</tt> */ virtual bool getSamplePosition(const PositionSamplingRecord &pRec, const DirectionSamplingRecord &dRec, Point2 &position) const; /** * \brief Evaluate the temporal component of the sampling density * implemented by the \ref sampleRay() method. */ Float pdfTime(const Ray &ray, EMeasure measure) const; /// Return the time value of the shutter opening event inline Float getShutterOpen() const { return m_shutterOpen; } /// Set the time value of the shutter opening event void setShutterOpen(Float time) { m_shutterOpen = time; } /// Return the length, for which the shutter remains open inline Float getShutterOpenTime() const { return m_shutterOpenTime; } /// Set the length, for which the shutter remains open void setShutterOpenTime(Float time); /** * \brief Does the method \ref sampleRay() require a uniformly distributed * sample for the time-dependent component? */ inline bool needsTimeSample() const { return !(m_type & EDeltaTime); } //! @} // ============================================================= // ============================================================= //! @{ \name Miscellaneous // ============================================================= /** * \brief Does the method \ref sampleRay() require a uniformly * distributed sample for the aperture component? */ inline bool needsApertureSample() const { return m_type & ENeedsApertureSample; } /// Return the \ref Film instance associated with this sensor inline Film *getFilm() { return m_film; } /// Return the \ref Film instance associated with this sensor (const) inline const Film *getFilm() const { return m_film.get(); } /// Return the aspect ratio of the sensor and its underlying film inline Float getAspect() const { return m_aspect; } /** * \brief Return the sensor's sample generator * * This is the \a root sampler, which will later be cloned a * number of times to provide each participating worker thread * with its own instance (see \ref Scene::getSampler()). * Therefore, this sampler should never be used for anything * except creating clones. */ inline Sampler *getSampler() { return m_sampler; } /** * \brief Return the sensor's sampler (const version). * * This is the \a root sampler, which will later be cloned a * number of times to provide each participating worker thread * with its own instance (see \ref Scene::getSampler()). * Therefore, this sampler should never be used for anything * except creating clones. */ inline const Sampler *getSampler() const { return m_sampler.get(); } inline void setSampler(Sampler *sampler) { m_sampler = sampler; } /// Serialize this sensor to a binary data stream virtual void serialize(Stream *stream, InstanceManager *manager) const; //! @} // ============================================================= // ============================================================= //! @{ \name ConfigurableObject interface // ============================================================= /// Add a child ConfigurableObject virtual void addChild(const std::string &name, ConfigurableObject *child); /// Add an unnamed child inline void addChild(ConfigurableObject *child) { addChild("", child); } /** \brief Configure the object (called \a once after construction and addition of all child \ref ConfigurableObject instances). */ virtual void configure(); //! @} // ============================================================= MTS_DECLARE_CLASS() protected: /// Construct a new sensor instance Sensor(const Properties &props); /// Unserialize a sensor instance from a binary data stream Sensor(Stream *stream, InstanceManager *manager); /// Virtual destructor virtual ~Sensor(); protected: ref<Film> m_film; ref<Sampler> m_sampler; Vector2 m_resolution; Vector2 m_invResolution; Float m_shutterOpen; Float m_shutterOpenTime; Float m_aspect; }; /** * \brief Projective camera interface * * This class provides an abstract interface to several types of sensors that * are commonly used in computer graphics, such as perspective and orthographic * camera models. * * The interface is meant to be implemented by any kind of sensor, whose * world to clip space transformation can be explained using only linear * operations on homogeneous coordinates. * * A useful feature of \ref ProjectiveCamera sensors is that their view can be * rendered using the traditional OpenGL pipeline. * * \ingroup librender */ class MTS_EXPORT_RENDER ProjectiveCamera : public Sensor { public: using Sensor::getWorldTransform; /// Return the world-to-view (aka "view") transformation at time \c t inline const Transform getViewTransform(Float t) const { return getWorldTransform()->eval(t).inverse(); } /// Return the view-to-world transformation at time \c t inline const Transform getWorldTransform(Float t) const { return getWorldTransform()->eval(t); } /** * \brief Overwrite the view-to-world transformation * with a static (i.e. non-animated) transformation. */ void setWorldTransform(const Transform &trafo); /** * \brief Overwrite the view-to-world transformation * with an animated transformation */ void setWorldTransform(AnimatedTransform *trafo); /** * \brief Return a projection matrix suitable for rendering the * scene using OpenGL * * For scenes involving a narrow depth of field and antialiasing, * it is necessary to average many separately rendered images using * different pixel offsets and aperture positions. * * \param apertureSample * Sample for rendering with defocus blur. This should be a * uniformly distributed random point in [0,1]^2 (or any value * when \ref needsApertureSample() == \c false) * * \param aaSample * Sample for antialiasing. This should be a uniformly * distributed random point in [0,1]^2. */ virtual Transform getProjectionTransform(const Point2 &apertureSample, const Point2 &aaSample) const = 0; /// Serialize this camera to a binary data stream virtual void serialize(Stream *stream, InstanceManager *manager) const; /// Return the near clip plane distance inline Float getNearClip() const { return m_nearClip; } /// Set the near clip plane distance void setNearClip(Float nearClip); /// Return the far clip plane distance inline Float getFarClip() const { return m_farClip; } /// Set the far clip plane distance void setFarClip(Float farClip); /// Return the distance to the focal plane inline Float getFocusDistance() const { return m_focusDistance; } /// Set the distance to the focal plane void setFocusDistance(Float focusDistance); MTS_DECLARE_CLASS() protected: /// Construct a new camera instance ProjectiveCamera(const Properties &props); /// Unserialize a camera instance from a binary data stream ProjectiveCamera(Stream *stream, InstanceManager *manager); /// Virtual destructor virtual ~ProjectiveCamera(); protected: Float m_nearClip; Float m_farClip; Float m_focusDistance; }; /** * \brief Perspective camera interface * * This class provides an abstract interface to several types of sensors that * are commonly used in computer graphics, such as perspective and orthographic * camera models. * * The interface is meant to be implemented by any kind of sensor, whose * world to clip space transformation can be explained using only linear * operations on homogeneous coordinates. * * A useful feature of \ref ProjectiveCamera sensors is that their view can be * rendered using the traditional OpenGL pipeline. * * \ingroup librender */ class MTS_EXPORT_RENDER PerspectiveCamera : public ProjectiveCamera { public: // ============================================================= //! @{ \name Field of view-related // ============================================================= /// Return the horizontal field of view in degrees inline Float getXFov() const { return m_xfov; } /// Set the horizontal field of view in degrees void setXFov(Float xfov); /// Return the vertical field of view in degrees Float getYFov() const; /// Set the vertical field of view in degrees void setYFov(Float yfov); /// Return the diagonal field of view in degrees Float getDiagonalFov() const; /// Set the diagonal field of view in degrees void setDiagonalFov(Float dfov); //! @} // ============================================================= /** \brief Configure the object (called \a once after construction and addition of all child \ref ConfigurableObject instances). */ virtual void configure(); /// Serialize this camera to a binary data stream virtual void serialize(Stream *stream, InstanceManager *manager) const; MTS_DECLARE_CLASS() protected: /// Construct a new perspective camera instance PerspectiveCamera(const Properties &props); /// Unserialize a perspective camera instance from a binary data stream PerspectiveCamera(Stream *stream, InstanceManager *manager); /// Virtual destructor virtual ~PerspectiveCamera(); protected: Float m_xfov; }; MTS_NAMESPACE_END #endif /* __MITSUBA_RENDER_SENSOR_H_ */
[ "mango@live.cn" ]
mango@live.cn
39e6485cbf326d32f7f547aad20659bdd5fbdbcb
4ad4ae971ffebe4eb2544fc0e61709637a1d0b5f
/HedgeGI/HedgeGI/BakePoint.h
3055f810b58c4c1d7cd4a738e193aa11d096b5d8
[]
no_license
Resilixia/HedgeGI
dbd657305df0db6bfc3b879a8a41603640028dc6
a533e13d78de6a5b9e77af9dd3e54a2100885424
refs/heads/master
2023-06-29T20:06:26.263000
2021-07-22T20:16:40
2021-07-22T20:16:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,022
h
#pragma once #include "Scene.h" enum BakePointFlags : size_t { BAKE_POINT_FLAGS_DISCARD_BACKFACE = 1 << 0, BAKE_POINT_FLAGS_AO = 1 << 1, BAKE_POINT_FLAGS_SHADOW = 1 << 2, BAKE_POINT_FLAGS_SOFT_SHADOW = 1 << 3, BAKE_POINT_FLAGS_NONE = 0, BAKE_POINT_FLAGS_ALL = ~0 }; template<uint32_t BasisCount, size_t Flags> struct BakePoint { static constexpr uint32_t BASIS_COUNT = BasisCount; static constexpr size_t FLAGS = Flags; Vector3 position; Vector3 smoothPosition; Matrix3 tangentToWorldMatrix; Color3 colors[BasisCount]; float shadow{}; uint16_t x{ (uint16_t)-1 }; uint16_t y{ (uint16_t)-1 }; static Vector3 sampleDirection(size_t index, size_t sampleCount, float u1, float u2); bool valid() const; void discard(); void begin(); void addSample(const Color3& color, const Vector3& tangentSpaceDirection, const Vector3& worldSpaceDirection) = delete; void end(uint32_t sampleCount); }; template <uint32_t BasisCount, size_t Flags> Vector3 BakePoint<BasisCount, Flags>::sampleDirection(const size_t index, const size_t sampleCount, const float u1, const float u2) { return sampleCosineWeightedHemisphere(u1, u2); } template <uint32_t BasisCount, size_t Flags> bool BakePoint<BasisCount, Flags>::valid() const { return x != (uint16_t)-1 && y != (uint16_t)-1; } template <uint32_t BasisCount, size_t Flags> void BakePoint<BasisCount, Flags>::discard() { x = (uint16_t)-1; y = (uint16_t)-1; } template <uint32_t BasisCount, size_t Flags> void BakePoint<BasisCount, Flags>::begin() { for (uint32_t i = 0; i < BasisCount; i++) colors[i] = Color3::Zero(); shadow = 0.0f; } template <uint32_t BasisCount, size_t Flags> void BakePoint<BasisCount, Flags>::end(const uint32_t sampleCount) { for (uint32_t i = 0; i < BasisCount; i++) colors[i] /= (float)sampleCount; } // Thanks Mr F static const Vector2 BAKE_POINT_OFFSETS[] = { {-2, -2}, {2, -2}, {-2, 2}, {2, 2}, {-1, -2}, {1, -2}, {-2, -1}, {2, -1}, {-2, 1}, {2, 1}, {-1, 2}, {1, 2}, {-2, 0}, {2, 0}, {0, -2}, {0, 2}, {-1, -1}, {1, -1}, {-1, 0}, {1, 0}, {-1, 1}, {1, 1}, {0, -1}, {0, 1}, {0, 0} }; template <typename TBakePoint> std::vector<TBakePoint> createBakePoints(const RaytracingContext& raytracingContext, const Instance& instance, const uint16_t size) { const float factor = 0.5f * (1.0f / (float)size); std::vector<TBakePoint> bakePoints; bakePoints.resize(size * size); for (auto& offset : BAKE_POINT_OFFSETS) { for (auto& mesh : instance.meshes) { for (uint32_t i = 0; i < mesh->triangleCount; i++) { const Triangle& triangle = mesh->triangles[i]; const Vertex& a = mesh->vertices[triangle.a]; const Vertex& b = mesh->vertices[triangle.b]; const Vertex& c = mesh->vertices[triangle.c]; Vector3 aVPos(a.vPos[0] + offset.x() * factor, a.vPos[1] + offset.y() * factor, 0); Vector3 bVPos(b.vPos[0] + offset.x() * factor, b.vPos[1] + offset.y() * factor, 0); Vector3 cVPos(c.vPos[0] + offset.x() * factor, c.vPos[1] + offset.y() * factor, 0); const float xMin = std::min(a.vPos[0], std::min(b.vPos[0], c.vPos[0])); const float xMax = std::max(a.vPos[0], std::max(b.vPos[0], c.vPos[0])); const float yMin = std::min(a.vPos[1], std::min(b.vPos[1], c.vPos[1])); const float yMax = std::max(a.vPos[1], std::max(b.vPos[1], c.vPos[1])); const uint16_t xBegin = std::max(0, (uint16_t)std::roundf((float)size * xMin) - 1); const uint16_t xEnd = std::min(size - 1, (uint16_t)std::roundf((float)size * xMax) + 1); const uint16_t yBegin = std::max(0, (uint16_t)std::roundf((float)size * yMin) - 1); const uint16_t yEnd = std::min(size - 1, (uint16_t)std::roundf((float)size * yMax) + 1); for (uint16_t x = xBegin; x <= xEnd; x++) { for (uint16_t y = yBegin; y <= yEnd; y++) { const Vector3 vPos(x / (float)size, y / (float)size, 0); const Vector2 baryUV = getBarycentricCoords(vPos, aVPos, bVPos, cVPos); if (baryUV[0] < 0 || baryUV[0] > 1 || baryUV[1] < 0 || baryUV[1] > 1 || 1 - baryUV[0] - baryUV[1] < 0 || 1 - baryUV[0] - baryUV[1] > 1) continue; const Vector3 position = barycentricLerp(a.position, b.position, c.position, baryUV); const Vector3 smoothPosition = getSmoothPosition(a, b, c, baryUV); const Vector3 normal = barycentricLerp(a.normal, b.normal, c.normal, baryUV).normalized(); const Vector3 tangent = barycentricLerp(a.tangent, b.tangent, c.tangent, baryUV).normalized(); const Vector3 binormal = barycentricLerp(a.binormal, b.binormal, c.binormal, baryUV).normalized(); Matrix3 tangentToWorld; tangentToWorld << tangent[0], binormal[0], normal[0], tangent[1], binormal[1], normal[1], tangent[2], binormal[2], normal[2]; bakePoints[y * size + x] = { position + position.cwiseAbs().cwiseProduct(normal.cwiseSign()) * 0.0000002f, smoothPosition + smoothPosition.cwiseAbs().cwiseProduct(normal.cwiseSign()) * 0.0000002f, tangentToWorld, {}, {}, x, y }; } } } } } return bakePoints; }
[ "19259897+blueskythlikesclouds@users.noreply.github.com" ]
19259897+blueskythlikesclouds@users.noreply.github.com
ab30dc5d6c841f8462ac5d9516625b926c49b233
014abde4a9ef62ed287b74d8bd88d6d9b99082ba
/c++/games/Tank/BasicTank/OgrePong/MainListener.h
fa02fedbf762a09d762a36c3e25daedb146c609c
[]
no_license
jpbullalayao/projects
09a03ce84dcc73bd1a2b8842509665bd0335019d
9b7bb008563221e1f59c3b4bb393ce6c21c0ce65
refs/heads/master
2016-09-06T10:21:00.639455
2015-03-17T00:54:09
2015-03-17T00:54:09
9,569,291
0
0
null
null
null
null
UTF-8
C++
false
false
738
h
#ifndef __MainListener_h_ #define __MainListener_h_ #include "Ogre.h" #include "OgreFrameListener.h" // Forward declaration of classes namespace Ogre { class RenderWindow; } class InputHandler; class AIManager; class World; class PongCamera; class ProjectileManager; class MainListener : public Ogre::FrameListener { public: MainListener(Ogre::RenderWindow *mainWindow, InputHandler *inputHandler, AIManager *aiManager, World *world, PongCamera *cam, ProjectileManager *pm); bool frameStarted(const Ogre::FrameEvent &evt); protected: InputHandler *mInputHandler; AIManager *mAIManager; World *mWorld; PongCamera *mPongCamera; ProjectileManager *mProjectileManager; Ogre::RenderWindow *mRenderWindow; int x; }; #endif
[ "jpbullalayao@gmail.com" ]
jpbullalayao@gmail.com
96fd61dabb76c72dee5f7ed8d359d6e56fbd6f9a
cafe4cc5e7b49b7628440bd4abe060b2b375b8d2
/Team_Alien/GAM 550/AlienEngine/source/BoomBoom.h
61f5ebe495bc137f7eedcec91121a4c00cb8ac5f
[]
no_license
sshedbalkar/DigiPen_Backup
47e75d03d06f8753c34c3777f2685a1fa055b7c9
a4bc4446e28bd997a4ad35bf53d70fa3707189ff
refs/heads/main
2022-12-25T18:36:22.711116
2020-10-11T09:32:22
2020-10-11T09:32:22
303,085,254
0
0
null
null
null
null
UTF-8
C++
false
false
447
h
#pragma once //Makes sure this header is only included once #include "PhysicsMath.h" #include <vector> namespace Framework { typedef struct { Vector3 pos; real distance; real force; }Bomb; class BoomBoom { //friend class GameLogic; public: BoomBoom(){} ~BoomBoom(){} void Initialize(); void Update(); void AddBomb(Bomb); private: typedef std::vector<Bomb> Bombs; Bombs bomb_list; }; }
[ "sanoysyg@gmail.com" ]
sanoysyg@gmail.com
1fff248e9d140669a61b6cdd90056920bbefbb43
5fd0b45b2f6ec6a6c1802fce1b52e0218d189f89
/platform/android/MapboxGLAndroidSDK/src/cpp/mapbox.cpp
5246739cf6e51a725808f37a166a9f73bbb05546
[ "BSD-3-Clause", "MIT", "Apache-2.0", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "curl", "ISC", "BSL-1.0", "JSON" ]
permissive
reezer/maplibre-gl-native
ca8e7a87331e39a23e2f3cade3578cfb7be50aa8
d716b5b408900776cbffdc5cffa00c5486e7d1d2
refs/heads/master
2023-04-17T03:24:26.571128
2021-04-07T01:46:21
2021-04-07T01:46:21
357,980,368
0
1
BSD-2-Clause
2021-04-30T12:59:38
2021-04-14T17:00:10
null
UTF-8
C++
false
false
717
cpp
#include "mapbox.hpp" namespace mbgl { namespace android { jni::Local<jni::Object<AssetManager>> Mapbox::getAssetManager(jni::JNIEnv& env) { static auto& javaClass = jni::Class<Mapbox>::Singleton(env); auto method = javaClass.GetStaticMethod<jni::Object<AssetManager>()>(env, "getAssetManager"); return javaClass.Call(env, method); } jboolean Mapbox::hasInstance(jni::JNIEnv& env) { static auto& javaClass = jni::Class<Mapbox>::Singleton(env); auto method = javaClass.GetStaticMethod<jboolean()>(env, "hasInstance"); return javaClass.Call(env, method); } void Mapbox::registerNative(jni::JNIEnv& env) { jni::Class<Mapbox>::Singleton(env); } } // namespace android } // namespace mbgl
[ "noreply@github.com" ]
noreply@github.com
1504f16c6e573dc31e70e39698bbbf420079ce84
6b2b16ae3d1c0ae91117a163df4d4f4434d66ad0
/home_led/home_led.ino
d186122262a51cfbd78a581892bebb014038fdac
[]
no_license
wojcikm/DevMeetings-Arduino
ab812f3b9a217082dfd1b43a76a4d57721ed6433
bf383cc7b8e422c871931c0da9076f3fe5a905d4
refs/heads/master
2022-11-09T23:43:34.929903
2020-06-26T20:11:08
2020-06-26T20:11:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,349
ino
/* HOME LED v0.1 Works as perhiperal (server) */ #include <FastLED.h> #define NUM_PIXELS 2 #define LED_PIN 7 CRGB leds[NUM_PIXELS]; // // Color format: ${r}-${g}-${b}-${a}- // e.g. 112-3-150-20 // int readNum() { char val = '_'; String txt = ""; while(val != '-' && Serial.available()) { if (val != '_') { txt += val; } // read the incoming byte val = Serial.read(); //slow looping to allow buffer to fill with next character delay(2); } return txt.toInt(); } // // MAIN // void setup() { // power-up safety delay delay( 3000 ); // initial the Serial Serial.begin(115200); FastLED.addLeds<WS2811, LED_PIN, RGB>(leds, NUM_PIXELS); } // void loop() { // new colors if (Serial.available()) { Serial.println("NEW COLOR"); int r = readNum(); int g = readNum(); int b = readNum(); int a = readNum(); // fill all pixels with color for (int i=0; i<NUM_PIXELS; i++) { leds[i].r = r; leds[i].g = b; leds[i].b = g; } FastLED.show(); // say what you got: Serial.print("R:"); Serial.println(r, DEC); Serial.print("G:"); Serial.println(g, DEC); Serial.print("B:"); Serial.println(b, DEC); Serial.print("a:"); Serial.println(a, DEC); Serial.println(); } }
[ "" ]
f2192bd3a43adcb5558da226e7468f8e52609eac
327b359509396a71433e073d92297d4dec488556
/lib/tests/xml_schema_validator_test.cpp
e2af1efa19159459cd2d4318a65d7d1460783f5d
[ "ISC" ]
permissive
timeout/xml_named_entity_miner
ca908c17734c9ed4aab980d1d239ffd5885cdde1
0d3c6f59b7cb1c2f585b25d86eb0cc8a6a532839
refs/heads/master
2021-01-25T10:44:13.183229
2015-03-25T22:58:11
2015-03-25T22:58:11
32,734,797
0
0
null
null
null
null
UTF-8
C++
false
false
3,804
cpp
#include "xml_schema_validator.hpp" #include "xml_schema.hpp" #include "xml_schema_parser.hpp" #include "dir.hpp" #include <fstream> #include <array> #include "gtest/gtest.h" #include <limits.h> static const Pathname buildDir_{Dir::getInstance( )->pwd( )}; static const std::array<std::string, 32> dirnames = { "001", "002", "003", "004", "005", "006", "007", "008", "009", "xsd001", "xsd002", "xsd003a", "xsd003b", "xsd004", "xsd005", "xsd006", "xsd007", "xsd008", "xsd009", "xsd010", "xsd011", "xsd012", "xsd013", "xsd014", "xsd015", "xsd016", "xsd017", "xsd018", "xsd019", "xsd020", "xsd021", "xsd022"}; class XmlSchemaValidatorTests : public testing::Test { protected: virtual auto SetUp( ) -> void { Dir::getInstance( )->chdir( buildDir_ ); } auto populate( ) -> const std::vector<Pathname> & { Pathname dirname{buildDir_ + std::string{"tests/validation/sunData/combined"}}; for ( auto subdir : dirnames ) { sunData_.push_back( Pathname{dirname} + subdir ); } return sunData_; } private: std::vector<Pathname> sunData_; }; TEST_F( XmlSchemaValidatorTests, DefaultCtor ) { XmlSchemaValidator validator; EXPECT_FALSE( validator.errorHandler( ).hasErrors( ) ); } TEST_F( XmlSchemaValidatorTests, Ctor ) { std::regex glob{R"(.*\.xsd)"}; std::vector<Pathname> schemas; for ( auto p : populate( ) ) { auto ls = Dir::getInstance( )->chdir( p ).entries( ); auto xsds = filter( ls, glob ); schemas.insert( schemas.end( ), xsds.begin( ), xsds.end( ) ); } for ( auto p : schemas ) { std::ifstream f{p.toString( ), std::ios::in}; ASSERT_TRUE( f.is_open( ) ); XmlDoc xml{f}; XmlSchemaParser parser; XmlSchema schema; XmlSchemaValidator validator; xml >> parser >> schema >> validator; ASSERT_FALSE( xml.errorHandler( ).hasErrors( ) ); ASSERT_FALSE( parser.errorHandler( ).hasErrors( ) ); ASSERT_FALSE( schema.errorHandler( ).hasErrors( ) ); EXPECT_FALSE( validator.errorHandler( ).hasErrors( ) ); } } TEST_F( XmlSchemaValidatorTests, validate ) { std::regex xGlob{R"(.*[^e]\.xsd)"}; // no erronous xsds std::regex vGlob( R"(.*v\.xml)" ); // validates std::regex nGlob( R"(.*n\.xml)" ); // doesn't std::vector<Pathname> xsds, validXmls, nonValidXmls; unsigned count = 0; for ( auto p : populate( ) ) { auto ls = Dir::getInstance( )->chdir( p ).read( ).entries( ); xsds = filter( ls, xGlob ); validXmls = filter( ls, vGlob ); nonValidXmls = filter( ls, nGlob ); if ( !xsds.empty( ) ) { XmlSchemaParser parser; XmlSchema schema; XmlSchemaValidator validator; for ( auto fs : xsds ) { std::ifstream f{fs.toString( ), std::ios::in}; XmlDoc xml{f}; xml >> parser >> schema >> validator; } for ( auto fv : validXmls ) { std::ifstream f{fv.toString( ), std::ios::in}; XmlDoc vXml{f}; EXPECT_TRUE( validator.validate( vXml ) ); if ( !validator.validate( vXml ) ) { std::cerr << fv << std::endl; } ++count; } for ( auto fn : nonValidXmls ) { std::ifstream f{fn.toString( ), std::ios::in}; XmlDoc nXml{f}; EXPECT_FALSE( validator.validate( nXml ) ); if ( validator.validate( nXml ) ) { std::cerr << fn << std::endl; } ++count; } } } std::cerr << "tested: " << count << " files" << std::endl; }
[ "joe.gain@gmail.com" ]
joe.gain@gmail.com
747aaf1b11a299ceccaab57197c09cf3d15fc09d
4a54dd5a93bbb3f603a2875d5e6dcb3020fb52f2
/custom/client-2004-03-09a-Sakexe-taiwan/src/Pc.h
800095dd857e18bc4e406dfa55c8af5626f6dfad
[]
no_license
Torashi1069/xenophase
400ebed356cff6bfb735f9c03f10994aaad79f5e
c7bf89281c95a3c5cf909a14d0568eb940ad7449
refs/heads/master
2023-02-02T19:15:08.013577
2020-08-17T00:41:43
2020-08-17T00:41:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,577
h
#pragma once #include "GameActor.h" #include "Struct.h" class CSprRes; class CActRes; class UIPcGage; class CPc : public CGameActor { struct vtable_t { void* (CPc::* scalar_deleting_destructor)(unsigned int flags); bool (CPc::* OnProcess)(void); void (CPc::* SendMsg)(CGameObject* sender, int message, int arg1, int arg2, int arg3); void (CPc::* Render)(matrix& ptm); int (CGameActor::* Get8Dir)(float rot); void (CGameActor::* SetRenderInfo)(RENDER_INFO_RECT& info, const float tlvertX, const float tlvertY); void (CRenderObject::* SetTlvert)(float tlvertX, float tlvertY); void (CGameActor::* SetAction)(int action, int speed, int type); void (CRenderObject::* ProcessMotion)(void); bool (CPc::* ProcessState)(void); void (CPc::* SetState)(int stateId); void (CGameActor::* RegisterPos)(void); void (CGameActor::* UnRegisterPos)(void); void (CGameActor::* SetSprAct)(int job, int sex); void (CPc::* SetSprAct_)(int job, int sex, int head, int weapon, int accessory, int accessory2, int accessory3, int shield, int headPal, int bodyPal); void (CPc::* SetSprAct2)(int job, int sex, int head, int weapon, int accessory, int accessory2, int accessory3, int shield, int headPal, int bodyPal, int effectState); void (CPc::* SetSprJob)(int job); void (CPc::* SetSprHead)(int head); void (CPc::* SetSprJobDye)(int job); void (CPc::* SetSprWeapon)(int weapon); void (CPc::* SetSprWeapon2)(int weapon); void (CPc::* SetSprAccessory)(int accessory); void (CPc::* SetSprAccessory2)(int accessory); void (CPc::* SetSprAccessory3)(int accessory); void (CPc::* SetSprShield)(int shield); void (CPc::* SetSprShoe)(int shoe); void (CPc::* SetImfFileName)(void); void (CPc::* SetHeadPaletteName)(void); void (CPc::* SetBodyPaletteName)(void); void (CPc::* SetBodyPalette)(int bodyPalette); void (CPc::* SetHeadPalette)(int headPalette); int (CPc::* GetWeapon)(void); void (CGameActor::* ProcessMotionWithDist)(void); int (CGameActor::* GetAttackMotion)(void); void (CGameActor::* MakeCorpse)(void); void (CPc::* SetModifyFactorOfmotionSpeed)(int attackM); void (CPc::* SetHonor)(int honor); void (CPc::* SetPropensityInfo)(int honor, int virtue); void (CGameActor::* SetGuildInfo)(int gdid, int emblemVersion); int (CGameActor::* GetGdid)(void); int (CGameActor::* GetEmblemVersion)(void); }; /* this+ 0 */ public: //CGameActor baseclass_0; /* this+684 */ protected: mystd::string m_imfName; /* this+700 */ protected: int m_honor; /* this+704 */ protected: int m_virtue; /* this+708 */ protected: int m_headDir; /* this+712 */ protected: int m_head; /* this+716 */ protected: int m_headPalette; /* this+720 */ protected: int m_weapon; /* this+724 */ protected: int m_accessory; /* this+728 */ protected: int m_accessory2; /* this+732 */ protected: int m_accessory3; /* this+736 */ protected: int m_shield; /* this+740 */ protected: int m_shoe; /* this+744 */ protected: int m_shoe_count; /* this+748 */ protected: vector3d shoe_pos; /* this+760 */ protected: int m_renderWithoutLayer; /* this+764 */ protected: mystd::string m_headPaletteName; /* this+780 */ protected: UIPcGage* m_gage; /* this+784 */ protected: long m_pk_rank; /* this+788 */ protected: long m_pk_total; /* this+792 */ private: mystd::vector<CSprRes*> m_sprResList; /* this+808 */ private: mystd::vector<CActRes*> m_actResList; public: CPc::CPc(void); public: virtual CPc::~CPc(void); public: void CPc::OnInit(void); public: void CPc::OnExit(void); public: virtual bool CPc::OnProcess(void); public: virtual bool CPc::ProcessState(void); public: virtual void CPc::SetState(int stateId); public: virtual void CPc::Render(matrix& ptm); public: virtual void CPc::SetSprAct(int job, int sex, int head, int weapon, int accessory, int accessory2, int accessory3, int shield, int headPal, int bodyPal); public: virtual void CPc::SetSprAct2(int job, int sex, int head, int weapon, int accessory, int accessory2, int accessory3, int shield, int headPal, int bodyPal, int effectState); public: virtual void CPc::SetSprJob(int job); public: virtual void CPc::SetSprHead(int head); public: virtual void CPc::SetSprJobDye(int job); public: virtual void CPc::SetSprWeapon(int weapon); public: virtual void CPc::SetSprWeapon2(int weapon); public: virtual void CPc::SetSprAccessory(int accessory); public: virtual void CPc::SetSprAccessory2(int accessory); public: virtual void CPc::SetSprAccessory3(int accessory); public: virtual void CPc::SetSprShield(int shield); public: virtual void CPc::SetSprShoe(int shoe); public: virtual void CPc::SetImfFileName(void); public: virtual void CPc::SetHeadPaletteName(void); public: virtual void CPc::SetBodyPaletteName(void); public: virtual int CPc::GetWeapon(void); public: virtual void CPc::SetModifyFactorOfmotionSpeed(int attackM); public: virtual void CPc::SendMsg(CGameObject* sender, int message, int arg1, int arg2, int arg3); public: virtual void CPc::SetBodyPalette(int bodyPalette); public: virtual void CPc::SetHeadPalette(int headPalette); public: virtual void CPc::SetHonor(int honor); public: virtual void CPc::SetPropensityInfo(int honor, int virtue); public: long CPc::GetPKRank(void); public: long CPc::GetPKTotal(void); public: void CPc::SetPKRank(int rank); public: void CPc::SetPKTotal(int total); public: void CPc::RenderBody2(matrix& vtm, int isBlur); public: void CPc::RenderBodyLayer(matrix& vtm, int isBlur); public: void CPc::RenderShadowLayer(matrix& vtm); public: void CPc::ProcessGage(void); public: void CPc::SetRank(int Total, int Rank); public: const mystd::vector<mystd::string> CPc::GetSprNames(void); public: void CPc::SetSprNames(const mystd::vector<mystd::string>& sprNames); public: const mystd::vector<mystd::string> CPc::GetActNames(void); public: void CPc::SetActNames(const mystd::vector<mystd::string>& actNames); public: const mystd::string& CPc::GetImfNames(void); public: int CPc::GetHeadPalette(void); public: mystd::string CPc::GetHeadPaletteName(void); public: void CPc::RenderShoe(int shoenum); protected: void CPc::SetSprNameList(int layer, const char* sprName); protected: const char* CPc::GetSprNameList(int layer); protected: CSprRes* CPc::GetSprResList(int layer); protected: void CPc::SetActNameList(int layer, const char* actName); protected: const char* CPc::GetActNameList(int layer); protected: CActRes* CPc::GetActResList(int layer); protected: int CPc::MakeWeaponType(int left, int right); private: static hook_method<void (CPc::*)(void)> CPc::_OnInit; static hook_method<void (CPc::*)(void)> CPc::_OnExit; static hook_method<bool (CPc::*)(void)> CPc::_OnProcess; static hook_method<bool (CPc::*)(void)> CPc::_ProcessState; static hook_method<void (CPc::*)(int stateId)> CPc::_SetState; static hook_method<void (CPc::*)(matrix& ptm)> CPc::_Render; static hook_method<void (CPc::*)(int job, int sex, int head, int weapon, int accessory, int accessory2, int accessory3, int shield, int headPal, int bodyPal)> CPc::_SetSprAct; static hook_method<void (CPc::*)(int job, int sex, int head, int weapon, int accessory, int accessory2, int accessory3, int shield, int headPal, int bodyPal, int effectState)> CPc::_SetSprAct2; static hook_method<void (CPc::*)(int job)> CPc::_SetSprJob; static hook_method<void (CPc::*)(int head)> CPc::_SetSprHead; static hook_method<void (CPc::*)(int job)> CPc::_SetSprJobDye; static hook_method<void (CPc::*)(int weapon)> CPc::_SetSprWeapon; static hook_method<void (CPc::*)(int weapon)> CPc::_SetSprWeapon2; static hook_method<void (CPc::*)(int accessory)> CPc::_SetSprAccessory; static hook_method<void (CPc::*)(int accessory)> CPc::_SetSprAccessory2; static hook_method<void (CPc::*)(int accessory)> CPc::_SetSprAccessory3; static hook_method<void (CPc::*)(int shield)> CPc::_SetSprShield; static hook_method<void (CPc::*)(int shoe)> CPc::_SetSprShoe; static hook_method<void (CPc::*)(void)> CPc::_SetImfFileName; static hook_method<void (CPc::*)(void)> CPc::_SetHeadPaletteName; static hook_method<void (CPc::*)(void)> CPc::_SetBodyPaletteName; static hook_method<int (CPc::*)(void)> CPc::_GetWeapon; static hook_method<void (CPc::*)(int attackM)> CPc::_SetModifyFactorOfmotionSpeed; static hook_method<void (CPc::*)(CGameObject* sender, int message, int arg1, int arg2, int arg3)> CPc::_SendMsg; static hook_method<void (CPc::*)(int bodyPalette)> CPc::_SetBodyPalette; static hook_method<void (CPc::*)(int headPalette)> CPc::_SetHeadPalette; static hook_method<void (CPc::*)(int honor)> CPc::_SetHonor; static hook_method<void (CPc::*)(int honor, int virtue)> CPc::_SetPropensityInfo; static hook_method<long (CPc::*)(void)> CPc::_GetPKRank; static hook_method<long (CPc::*)(void)> CPc::_GetPKTotal; static hook_method<void (CPc::*)(int rank)> CPc::_SetPKRank; static hook_method<void (CPc::*)(int total)> CPc::_SetPKTotal; static hook_method<void (CPc::*)(matrix& vtm, int isBlur)> CPc::_RenderBody2; static hook_method<void (CPc::*)(matrix& vtm, int isBlur)> CPc::_RenderBodyLayer; static hook_method<void (CPc::*)(matrix& vtm)> CPc::_RenderShadowLayer; static hook_method<void (CPc::*)(void)> CPc::_ProcessGage; static hook_method<void (CPc::*)(int Total, int Rank)> CPc::_SetRank; static hook_method<const mystd::vector<mystd::string> (CPc::*)(void)> CPc::_GetSprNames; static hook_method<void (CPc::*)(const mystd::vector<mystd::string>& sprNames)> CPc::_SetSprNames; static hook_method<const mystd::vector<mystd::string> (CPc::*)(void)> CPc::_GetActNames; static hook_method<void (CPc::*)(const mystd::vector<mystd::string>& actNames)> CPc::_SetActNames; static hook_method<const mystd::string& (CPc::*)(void)> CPc::_GetImfNames; static hook_method<int (CPc::*)(void)> CPc::_GetHeadPalette; static hook_method<mystd::string (CPc::*)(void)> CPc::_GetHeadPaletteName; static hook_method<void (CPc::*)(int shoenum)> CPc::_RenderShoe; static hook_method<void (CPc::*)(int layer, const char* sprName)> CPc::_SetSprNameList; static hook_method<const char* (CPc::*)(int layer)> CPc::_GetSprNameList; static hook_method<CSprRes* (CPc::*)(int layer)> CPc::_GetSprResList; static hook_method<void (CPc::*)(int layer, const char* actName)> CPc::_SetActNameList; static hook_method<const char* (CPc::*)(int layer)> CPc::_GetActNameList; static hook_method<CActRes* (CPc::*)(int layer)> CPc::_GetActResList; static hook_method<int (CPc::*)(int left, int right)> CPc::_MakeWeaponType; }; class CBlurPC : public CPc { struct vtable_t { //TOOD }; /* this+ 0 */ public: //CPc baseclass_0; /* this+824 */ protected: float m_motionY; /* this+828 */ protected: unsigned long m_alphaDelta; /* this+832 */ protected: unsigned long m_r; /* this+836 */ protected: unsigned long m_g; /* this+840 */ protected: unsigned long m_b; public: CBlurPC::CBlurPC(CPc* pc); public: virtual CBlurPC::~CBlurPC(void); public: void CBlurPC::OnInit(void); public: void CBlurPC::OnExit(void); public: virtual bool CBlurPC::OnProcess(void); public: virtual void CBlurPC::Render(matrix& ptm); public: virtual void CBlurPC::SendMsg(CGameObject* sender, int message, int arg1, int arg2, int arg3); private: static hook_method<void (CBlurPC::*)(void)> CBlurPC::_OnInit; static hook_method<void (CBlurPC::*)(void)> CBlurPC::_OnExit; static hook_method<bool (CBlurPC::*)(void)> CBlurPC::_OnProcess; static hook_method<void (CBlurPC::*)(matrix& ptm)> CBlurPC::_Render; static hook_method<void (CBlurPC::*)(CGameObject* sender, int message, int arg1, int arg2, int arg3)> CBlurPC::_SendMsg; };
[ "50342848+Kokotewa@users.noreply.github.com" ]
50342848+Kokotewa@users.noreply.github.com
9e65043d4a926975dd8b8c7a046826d39645ed4e
fa0102a202fc3b00e16782484b0af19df298abb1
/Extremamente Básico/1050.cpp
889c7d940d80015bb284abbd5b2603d9d298230f
[]
no_license
felipe-melo/uri
dc2416f45650086fe0ff8ef1423f3a4737c55b7d
fc9c956df09369db7af32ea27aa5cde377366f9d
refs/heads/master
2020-05-20T05:51:39.934363
2015-09-14T19:35:30
2015-09-14T19:35:30
42,471,854
0
0
null
null
null
null
UTF-8
C++
false
false
557
cpp
#include <stdlib.h> #include <iostream> #include <string> using namespace std; int main() { string cidade; int a; cin >> a; if (a == 61) cidade = "Brasilia"; else if (a == 71) cidade = "Salvador"; else if (a == 11) cidade = "Sao Paulo"; else if (a == 21) cidade = "Rio de Janeiro"; else if (a == 32) cidade = "Juiz de Fora"; else if (a == 19) cidade = "Campinas"; else if (a == 27) cidade = "Vitoria"; else if (a == 31) cidade = "Belo Horizonte"; else cidade = "DDD nao cadastrado"; cout << cidade << endl; return 0; }
[ "felipe.melo.devel@gmail.com" ]
felipe.melo.devel@gmail.com
8be8c433b2fae716a3366d119c733e4298a4ba62
94c2bb3a34f08376549ea321a0b0f949abbff53a
/src/sporkdb.h
67fce6a6d256be5e7d810294612c6b285d25d771
[ "MIT" ]
permissive
quickcoin1/quickcoin
fdd0c06a0e44ce0406e7281c6dbf489ce31b4c7a
364bf7f6e67f2085e5cf8468b5142d369e3c9b78
refs/heads/master
2020-03-22T05:53:48.066796
2018-07-03T14:50:40
2018-07-03T14:50:40
139,597,875
0
0
null
null
null
null
UTF-8
C++
false
false
744
h
// Copyright (c) 2017 The PIVX developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef QICITAS_CSPORKDB_H #define QICITAS_CSPORKDB_H #include <boost/filesystem/path.hpp> #include "leveldbwrapper.h" #include "spork.h" class CSporkDB : public CLevelDBWrapper { public: CSporkDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); private: CSporkDB(const CSporkDB&); void operator=(const CSporkDB&); public: bool WriteSpork(const int nSporkId, const CSporkMessage& spork); bool ReadSpork(const int nSporkId, CSporkMessage& spork); bool SporkExists(const int nSporkId); }; #endif //QICITAS_CSPORKDB_H
[ "root@q1" ]
root@q1
d8e38cc00f4034384a43caca41d640bcefa1d254
4ee48abecc6039c7598b5a7a7db61fc081b4a77a
/Dos_class/Testing_Dision_System_Dos_Class.cpp
2f7e1671b19b62dd275a04b6a87a1f340e3b4952
[]
no_license
SrmHitter9062/IDS
63fdc215fdb2ae1e51f89f7f1d382f592842dcad
5f4cbbc349aa07290931568935e887ead8739e10
refs/heads/master
2020-12-24T14:10:33.121533
2014-12-18T11:22:24
2014-12-18T11:22:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,159
cpp
//-----------------------------------------project_test_main.cpp-------------------------------------- // // Code is use to taking object which we want to classify and after that dscretization happen and // using the generated rule we decide which class our new object is related saaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa dsdsdsdsds #include <iostream> #include<vector> #include<set> #include<map> #include<queue> #include<stack> #include<string> #include<algorithm> #include<functional> #include<iomanip> #include<cstdio> #include<cmath> #include<cstring> #include<cstdlib> #include<cassert> #include<climits> #include <fstream> #include <utility> #include <time.h> // hello this is dfdfdfIDS project // #define CROSSOVER_RATE 0.9 //Crossover rate for crossover method #define MUTATION_RATE 0.01 //mutation rate for mutation method #define TOTAL_OBJECT 24 // no of object inlude in training purpose #define CHROMO_LENGTH 42 //Number of attribute for a particular chromosome #define MAX_ALLOWABLE_GENERATIONS 1 //maximum allowed no of repetation of GA #define DISCRITE_COF 4 //Cofficient for discretization #define DECISION_ABILITY_COFF 0.9 //Decision cofficient #define RULE_THERSOLD 4 //Number of attribute choosen #define TOTAL_TEST_OBJECT 136 //Number f testing object using namespace std; //---------------------------------Discritization_algorithm----------------------------------------- // // This function returns a real value attribute value as in eqaul width interwal . // //----------------------------------------------------------------------------------------- void Discritization(float &input_value, float min, float max){ float width; width = (max+1-min)/DISCRITE_COF; //Calculate width for attribute j int l; for (l= 1; l <= DISCRITE_COF ; l++) { if (input_value >= min + (l-1)*width && input_value < min + l*width) { input_value = l; break; } } } void Discritization_algorithm(vector < vector <float> > & input ){ int i,j; for(i=0;i<TOTAL_TEST_OBJECT;i++) { for(j=0;j<CHROMO_LENGTH-1 ;j++) { //input_value = input[i][j]; switch(j) { case 0: Discritization(input[i][j],0,58329); break; case 1: Discritization(input[i][j],1,3); break; case 2: Discritization(input[i][j],1,70); break; case 3: Discritization(input[i][j],1,10); break; case 4: Discritization(input[i][j],0,90000000); break; case 5: Discritization(input[i][j],0,90000000); break; case 6: Discritization(input[i][j],0,1); break; case 7: Discritization(input[i][j],0,3); break; case 8: Discritization(input[i][j],0,14); break; case 9: Discritization(input[i][j],0,101); break; case 10: Discritization(input[i][j],0,5); break; case 11: Discritization(input[i][j],0,1); break; case 12: Discritization(input[i][j],0,7479); break; case 13: Discritization(input[i][j],0,1); break; case 14: Discritization(input[i][j],0,1); break; case 15: Discritization(input[i][j],0,7468); break; case 16: Discritization(input[i][j],0,100); break; case 17: Discritization(input[i][j],0,5); break; case 18: Discritization(input[i][j],0,9); break; case 19: Discritization(input[i][j],0,1); break; case 20: Discritization(input[i][j],0,1); break; case 21: Discritization(input[i][j],0,1); break; case 22: Discritization(input[i][j],0,511); break; case 23: Discritization(input[i][j],0,511); break; case 24: Discritization(input[i][j],0,1); break; case 25: Discritization(input[i][j],0,1); break; case 26: Discritization(input[i][j],0,1); break; case 27: Discritization(input[i][j],0,1); break; case 28: Discritization(input[i][j],0,1); break; case 29: Discritization(input[i][j],0,1); break; case 30: Discritization(input[i][j],0,1); break; case 31: Discritization(input[i][j],0,255); break; case 32: Discritization(input[i][j],0,255); break; case 33: Discritization(input[i][j],0,1); break; case 34: Discritization(input[i][j],0,1); break; case 35: Discritization(input[i][j],0,1); break; case 36: Discritization(input[i][j],0,1); break; case 37: Discritization(input[i][j],0,1); break; case 38: Discritization(input[i][j],0,1); break; case 39: Discritization(input[i][j],0,1); break; case 40: Discritization(input[i][j],0,1); break; } } } } int main(){ ifstream infile1,infile2,infile3,infile4; //Declare objects for open file in reading mode infile1.open("DoS_Class_data250_raw.txt"); //This file contans attribute data in real value formate infile2.open("rules_class1_binary"); //Generated Rule by training dataset using hybrid GA //infile3.open("discretization_usefull_data"); //Usefull data for Dscretization of new objects infile4.open("reduct_attribute_index_class1"); //Optimize reduct attribute index ofstream outfile4,outfile5; //Declare objects for open file in writting mode outfile4.open("testing_result_class1"); //Store final classified result for testing object outfile5.open("check1"); vector < vector <float> > test_input (TOTAL_TEST_OBJECT,vector<float> (CHROMO_LENGTH)); //Store test input as marix formate vector < vector <int> > rule_matrix (TOTAL_OBJECT,vector<int> (RULE_THERSOLD + 1)); //Store generated rule in matrix formate vector <int> final_reduct; //Store attribute index vector < pair <float , float > > width_data; for (int i = 0; i < CHROMO_LENGTH-1; i++ ) { float max,min; infile3 >> min >> max; width_data.push_back(make_pair(min,max)); } for (int i=0;i<TOTAL_TEST_OBJECT;i++) { for (int j=0;j<CHROMO_LENGTH;j++) { infile1 >> test_input[i][j]; } } Discritization_algorithm(test_input); for (int i=0;i<TOTAL_TEST_OBJECT;i++) { for (int j=0;j<CHROMO_LENGTH-1;j++) { outfile5 << test_input[i][j]<< " "; }outfile5 << endl; } int x; for (int i = 0; i < RULE_THERSOLD; i++ ){ infile4 >> x; final_reduct.push_back(x); //Puting index of attribute in vector } for (int i=0;i<TOTAL_OBJECT;i++) { for (int j=0;j<RULE_THERSOLD + 1;j++) { infile2 >> rule_matrix[i][j]; //Puting rules iin matrix formate } } for (int i=0;i<TOTAL_TEST_OBJECT;i++) { int flag; for (int j=0;j<TOTAL_OBJECT;j++) { flag = 0; for (int k = 0; k < RULE_THERSOLD; k++ ){ cout << test_input[i][final_reduct[k]] <<" "; if (test_input[i][final_reduct[k]] == rule_matrix[j][k]){ //Testing attribute value of new objects with generated rules to classify object flag = 1; }else { flag = 0; break; } } cout <<endl; if (flag == 1){ // Condition to find class for object outfile4 << "class of object "<< i<<" is calculated by our model is -- " << rule_matrix[j][RULE_THERSOLD]<< " and actual by dataset is " << test_input[i][CHROMO_LENGTH-1] <<endl; break; } } if (flag == 0) //Condition to not find class for object outfile4 << "No result for this object --" << endl; } }
[ "malavsiya@gmail.com" ]
malavsiya@gmail.com
de8b3d7fb21de26f94796818f019d38daf39f7eb
61df3aabbf17cc33e85720b2710519da94776674
/cpp/source_files/SyncChunk.h
c2157ba36cc01d2393a9455b95e4ad48c81f7dfc
[]
no_license
serik1987/ihna_kozhuhov_image_analysis
3efd93feb8578bf2fe60057a2ddc8d7f4f59eceb
ccfb3b48cbf6b351acb10f8b99315c65281f8ab8
refs/heads/master
2021-07-05T12:13:32.159553
2021-03-08T21:09:51
2021-03-08T21:09:51
228,234,318
0
0
null
null
null
null
UTF-8
C++
false
false
1,636
h
// // Created by serik1987 on 16.12.2019. // #ifndef IHNA_KOZHUHOV_IMAGE_ANALYSIS_SYNCCHUNK_H #define IHNA_KOZHUHOV_IMAGE_ANALYSIS_SYNCCHUNK_H #include "Chunk.h" namespace GLOBAL_NAMESPACE { /** * I actually don't have any idea why this chunk is needed */ class SyncChunk: public Chunk { public: #pragma pack(push, 1) struct SYNC_CHUNK { char Tag[4] = "\x00\x00\x00"; //01 01 uint32_t RecordSize = 0; //02 02 uint32_t RecordType = 0; //03 03 BYTE, USHORT,... uint32_t RecordCount = 0; //04 04 uint32_t ChannelNumber = 0; //05 05 uint32_t ChannelMaxValue = 0;//06 06 uint32_t StimulusPeriod = 0; //07 07 milliseconds uint32_t Free[3] = {0, 0, 0}; //08 10 }; #pragma pack(pop) private: SYNC_CHUNK info; public: explicit SyncChunk(uint32_t size): Chunk("SYNC", size){ body = (char*)&info; } [[nodiscard]] const char* getTag() const { return info.Tag; } [[nodiscard]] uint32_t getRecordSize() const { return info.RecordSize; } [[nodiscard]] uint32_t getRecordType() const { return info.RecordType; } [[nodiscard]] uint32_t getRecordCount() const { return info.RecordCount; } [[nodiscard]] uint32_t getChannelNumber() const { return info.ChannelNumber;} [[nodiscard]] uint32_t getChannelMaxValue() const { return info.ChannelMaxValue; } [[nodiscard]] uint32_t getStimulusPeriod() const { return info.StimulusPeriod; } }; } #endif //IHNA_KOZHUHOV_IMAGE_ANALYSIS_SYNCCHUNK_H
[ "serik1987@gmail.com" ]
serik1987@gmail.com
83c47e315a699314432f7b73d4fe1f046aba0aa6
e247fd7ff5883f39d5ef327e8bc0d97b251d725c
/7找出一个二维数组的鞍点.cpp
16aa2895e0369ea8bb8c92e97580d330a4dae523
[]
no_license
suxueshi/chapter5_array_test
772d8f5e34ab6b2537319f232bb43c7e1c7f09e6
4887d39525509c2f0e7f67dd4a0ac6de31abd083
refs/heads/master
2022-12-03T08:55:33.918891
2020-08-12T05:27:51
2020-08-12T05:27:51
286,925,266
0
0
null
null
null
null
GB18030
C++
false
false
1,123
cpp
//#include<iostream> //using namespace std; //int main() { // const int n = 4, m = 5; // int i, j, max, maxj, a[n][m]; // bool flag; // cout << "enter " << n << " * " << m << " data: " << endl; // for (i = 0; i < n; i++) // for (j = 0; j < m; j++) // cin >> a[i][j]; // cout << endl; // for (i = 0; i < n; i++) { // max = a[i][0]; //先将每行的第一个数视作最大值 // maxj = 0; // for (j = 0; j < m; j++) { // if (max < a[i][j]) { // max = a[i][j]; //先找到一行之中最大的那个数 // maxj = j; //将该数的列号赋给maxj // } // } // flag = true; //先假设是鞍点 flag等于true // for (int k=0;k<n;k++) //在同一列比较,重新定义一个k值代表行号 // if (max > a[k][maxj]) { // flag = false; // continue; //如果max不是同列最小,则表示不是鞍点,flag为false // } // if (flag) { // cout << "a[" << i << "][" << maxj << "]"" = " << max ; // break; //一个数组就只有一个鞍点,如果找到了的话直接结束循环 // } // } // if (!flag) // cout << "it does not exist!" << endl; // return 0; //}
[ "1136975295@qq.com" ]
1136975295@qq.com
79453406541cee235c8e086563769cd54c3fbdb2
dca653bb975528bd1b8ab2547f6ef4f48e15b7b7
/tags/wxPy-2.8.6.0/src/msw/dc.cpp
90ed5d53a0eda7e1d1944e60496c5fb79807aef6
[]
no_license
czxxjtu/wxPython-1
51ca2f62ff6c01722e50742d1813f4be378c0517
6a7473c258ea4105f44e31d140ea5c0ae6bc46d8
refs/heads/master
2021-01-15T12:09:59.328778
2015-01-05T20:55:10
2015-01-05T20:55:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
80,049
cpp
///////////////////////////////////////////////////////////////////////////// // Name: src/msw/dc.cpp // Purpose: wxDC class for MSW port // Author: Julian Smart // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // =========================================================================== // declarations // =========================================================================== // --------------------------------------------------------------------------- // headers // --------------------------------------------------------------------------- // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/msw/wrapcdlg.h" #include "wx/image.h" #include "wx/window.h" #include "wx/dc.h" #include "wx/utils.h" #include "wx/dialog.h" #include "wx/app.h" #include "wx/bitmap.h" #include "wx/dcmemory.h" #include "wx/log.h" #include "wx/icon.h" #include "wx/dcprint.h" #include "wx/module.h" #endif #include "wx/sysopt.h" #include "wx/dynlib.h" #ifdef wxHAVE_RAW_BITMAP #include "wx/rawbmp.h" #endif #include <string.h> #ifndef __WIN32__ #include <print.h> #endif #ifndef AC_SRC_ALPHA #define AC_SRC_ALPHA 1 #endif #ifndef LAYOUT_RTL #define LAYOUT_RTL 1 #endif /* Quaternary raster codes */ #ifndef MAKEROP4 #define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore)) #endif // apparently with MicroWindows it is possible that HDC is 0 so we have to // check for this ourselves #ifdef __WXMICROWIN__ #define WXMICROWIN_CHECK_HDC if ( !GetHDC() ) return; #define WXMICROWIN_CHECK_HDC_RET(x) if ( !GetHDC() ) return x; #else #define WXMICROWIN_CHECK_HDC #define WXMICROWIN_CHECK_HDC_RET(x) #endif IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase) // --------------------------------------------------------------------------- // constants // --------------------------------------------------------------------------- static const int VIEWPORT_EXTENT = 1000; static const int MM_POINTS = 9; static const int MM_METRIC = 10; // ROPs which don't have standard names (see "Ternary Raster Operations" in the // MSDN docs for how this and other numbers in wxDC::Blit() are obtained) #define DSTCOPY 0x00AA0029 // a.k.a. NOP operation // ---------------------------------------------------------------------------- // macros for logical <-> device coords conversion // ---------------------------------------------------------------------------- /* We currently let Windows do all the translations itself so these macros are not really needed (any more) but keep them to enhance readability of the code by allowing to see where are the logical and where are the device coordinates used. */ #ifdef __WXWINCE__ #define XLOG2DEV(x) ((x-m_logicalOriginX)*m_signX) #define YLOG2DEV(y) ((y-m_logicalOriginY)*m_signY) #define XDEV2LOG(x) ((x)*m_signX+m_logicalOriginX) #define YDEV2LOG(y) ((y)*m_signY+m_logicalOriginY) #else #define XLOG2DEV(x) (x) #define YLOG2DEV(y) (y) #define XDEV2LOG(x) (x) #define YDEV2LOG(y) (y) #endif // --------------------------------------------------------------------------- // private functions // --------------------------------------------------------------------------- // convert degrees to radians static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } // call AlphaBlend() to blit contents of hdcSrc to hdcDst using alpha // // NB: bmpSrc is the bitmap selected in hdcSrc, it is not really needed // to pass it to this function but as we already have it at the point // of call anyhow we do // // return true if we could draw the bitmap in one way or the other, false // otherwise static bool AlphaBlt(HDC hdcDst, int x, int y, int w, int h, int srcX, int srcY, HDC hdcSrc, const wxBitmap& bmpSrc); #ifdef wxHAVE_RAW_BITMAP // our (limited) AlphaBlend() replacement for Windows versions not providing it static void wxAlphaBlend(HDC hdcDst, int x, int y, int w, int h, int srcX, int srcY, const wxBitmap& bmp); #endif // wxHAVE_RAW_BITMAP // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- // instead of duplicating the same code which sets and then restores text // colours in each wxDC method working with wxSTIPPLE_MASK_OPAQUE brushes, // encapsulate this in a small helper class // wxColourChanger: changes the text colours in the ctor if required and // restores them in the dtor class wxColourChanger { public: wxColourChanger(wxDC& dc); ~wxColourChanger(); private: wxDC& m_dc; COLORREF m_colFgOld, m_colBgOld; bool m_changed; DECLARE_NO_COPY_CLASS(wxColourChanger) }; // this class saves the old stretch blit mode during its life time class StretchBltModeChanger { public: StretchBltModeChanger(HDC hdc, int WXUNUSED_IN_WINCE(mode)) : m_hdc(hdc) { #ifndef __WXWINCE__ m_modeOld = ::SetStretchBltMode(m_hdc, mode); if ( !m_modeOld ) wxLogLastError(_T("SetStretchBltMode")); #endif } ~StretchBltModeChanger() { #ifndef __WXWINCE__ if ( !::SetStretchBltMode(m_hdc, m_modeOld) ) wxLogLastError(_T("SetStretchBltMode")); #endif } private: const HDC m_hdc; int m_modeOld; DECLARE_NO_COPY_CLASS(StretchBltModeChanger) }; // helper class to cache dynamically loaded libraries and not attempt reloading // them if it fails class wxOnceOnlyDLLLoader { public: // ctor argument must be a literal string as we don't make a copy of it! wxOnceOnlyDLLLoader(const wxChar *dllName) : m_dllName(dllName) { } // return the symbol with the given name or NULL if the DLL not loaded // or symbol not present void *GetSymbol(const wxChar *name) { // we're prepared to handle errors here wxLogNull noLog; if ( m_dllName ) { m_dll.Load(m_dllName); // reset the name whether we succeeded or failed so that we don't // try again the next time m_dllName = NULL; } return m_dll.IsLoaded() ? m_dll.GetSymbol(name) : NULL; } private: wxDynamicLibrary m_dll; const wxChar *m_dllName; }; static wxOnceOnlyDLLLoader wxGDI32DLL(_T("gdi32")); static wxOnceOnlyDLLLoader wxMSIMG32DLL(_T("msimg32")); // =========================================================================== // implementation // =========================================================================== // ---------------------------------------------------------------------------- // wxColourChanger // ---------------------------------------------------------------------------- wxColourChanger::wxColourChanger(wxDC& dc) : m_dc(dc) { const wxBrush& brush = dc.GetBrush(); if ( brush.Ok() && brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) { HDC hdc = GetHdcOf(dc); m_colFgOld = ::GetTextColor(hdc); m_colBgOld = ::GetBkColor(hdc); // note that Windows convention is opposite to wxWidgets one, this is // why text colour becomes the background one and vice versa const wxColour& colFg = dc.GetTextForeground(); if ( colFg.Ok() ) { ::SetBkColor(hdc, colFg.GetPixel()); } const wxColour& colBg = dc.GetTextBackground(); if ( colBg.Ok() ) { ::SetTextColor(hdc, colBg.GetPixel()); } SetBkMode(hdc, dc.GetBackgroundMode() == wxTRANSPARENT ? TRANSPARENT : OPAQUE); // flag which telsl us to undo changes in the dtor m_changed = true; } else { // nothing done, nothing to undo m_changed = false; } } wxColourChanger::~wxColourChanger() { if ( m_changed ) { // restore the colours we changed HDC hdc = GetHdcOf(m_dc); ::SetBkMode(hdc, TRANSPARENT); ::SetTextColor(hdc, m_colFgOld); ::SetBkColor(hdc, m_colBgOld); } } // --------------------------------------------------------------------------- // wxDC // --------------------------------------------------------------------------- wxDC::~wxDC() { if ( m_hDC != 0 ) { SelectOldObjects(m_hDC); // if we own the HDC, we delete it, otherwise we just release it if ( m_bOwnsDC ) { ::DeleteDC(GetHdc()); } else // we don't own our HDC { if (m_canvas) { ::ReleaseDC(GetHwndOf(m_canvas), GetHdc()); } else { // Must have been a wxScreenDC ::ReleaseDC((HWND) NULL, GetHdc()); } } } } // This will select current objects out of the DC, // which is what you have to do before deleting the // DC. void wxDC::SelectOldObjects(WXHDC dc) { if (dc) { if (m_oldBitmap) { ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap); #ifdef __WXDEBUG__ if (m_selectedBitmap.Ok()) { m_selectedBitmap.SetSelectedInto(NULL); } #endif } m_oldBitmap = 0; if (m_oldPen) { ::SelectObject((HDC) dc, (HPEN) m_oldPen); } m_oldPen = 0; if (m_oldBrush) { ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush); } m_oldBrush = 0; if (m_oldFont) { ::SelectObject((HDC) dc, (HFONT) m_oldFont); } m_oldFont = 0; #if wxUSE_PALETTE if (m_oldPalette) { ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, FALSE); } m_oldPalette = 0; #endif // wxUSE_PALETTE } m_brush = wxNullBrush; m_pen = wxNullPen; #if wxUSE_PALETTE m_palette = wxNullPalette; #endif // wxUSE_PALETTE m_font = wxNullFont; m_backgroundBrush = wxNullBrush; m_selectedBitmap = wxNullBitmap; } // --------------------------------------------------------------------------- // clipping // --------------------------------------------------------------------------- void wxDC::UpdateClipBox() { WXMICROWIN_CHECK_HDC RECT rect; ::GetClipBox(GetHdc(), &rect); m_clipX1 = (wxCoord) XDEV2LOG(rect.left); m_clipY1 = (wxCoord) YDEV2LOG(rect.top); m_clipX2 = (wxCoord) XDEV2LOG(rect.right); m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); } void wxDC::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const { // check if we should try to retrieve the clipping region possibly not set // by our SetClippingRegion() but preset by Windows:this can only happen // when we're associated with an existing HDC usign SetHDC(), see there if ( m_clipping && !m_clipX1 && !m_clipX2 ) { wxDC *self = wxConstCast(this, wxDC); self->UpdateClipBox(); if ( !m_clipX1 && !m_clipX2 ) self->m_clipping = false; } wxDCBase::DoGetClippingBox(x, y, w, h); } // common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion() void wxDC::SetClippingHrgn(WXHRGN hrgn) { wxCHECK_RET( hrgn, wxT("invalid clipping region") ); WXMICROWIN_CHECK_HDC // note that we combine the new clipping region with the existing one: this // is compatible with what the other ports do and is the documented // behaviour now (starting with 2.3.3) #if defined(__WXWINCE__) RECT rectClip; if ( !::GetClipBox(GetHdc(), &rectClip) ) return; // GetClipBox returns logical coordinates, so transform to device rectClip.left = LogicalToDeviceX(rectClip.left); rectClip.top = LogicalToDeviceY(rectClip.top); rectClip.right = LogicalToDeviceX(rectClip.right); rectClip.bottom = LogicalToDeviceY(rectClip.bottom); HRGN hrgnDest = ::CreateRectRgn(0, 0, 0, 0); HRGN hrgnClipOld = ::CreateRectRgn(rectClip.left, rectClip.top, rectClip.right, rectClip.bottom); if ( ::CombineRgn(hrgnDest, hrgnClipOld, (HRGN)hrgn, RGN_AND) != ERROR ) { ::SelectClipRgn(GetHdc(), hrgnDest); } ::DeleteObject(hrgnClipOld); ::DeleteObject(hrgnDest); #else // !WinCE if ( ::ExtSelectClipRgn(GetHdc(), (HRGN)hrgn, RGN_AND) == ERROR ) { wxLogLastError(_T("ExtSelectClipRgn")); return; } #endif // WinCE/!WinCE m_clipping = true; UpdateClipBox(); } void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { // the region coords are always the device ones, so do the translation // manually // // FIXME: possible +/-1 error here, to check! HRGN hrgn = ::CreateRectRgn(LogicalToDeviceX(x), LogicalToDeviceY(y), LogicalToDeviceX(x + w), LogicalToDeviceY(y + h)); if ( !hrgn ) { wxLogLastError(_T("CreateRectRgn")); } else { SetClippingHrgn((WXHRGN)hrgn); ::DeleteObject(hrgn); } } void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) { SetClippingHrgn(region.GetHRGN()); } void wxDC::DestroyClippingRegion() { WXMICROWIN_CHECK_HDC if (m_clipping && m_hDC) { #if 1 // On a PocketPC device (not necessarily emulator), resetting // the clip region as per the old method causes bad display // problems. In fact setting a null region is probably OK // on desktop WIN32 also, since the WIN32 docs imply that the user // clipping region is independent from the paint clipping region. ::SelectClipRgn(GetHdc(), 0); #else // TODO: this should restore the previous clipping region, // so that OnPaint processing works correctly, and the update // clipping region doesn't get destroyed after the first // DestroyClippingRegion. HRGN rgn = CreateRectRgn(0, 0, 32000, 32000); ::SelectClipRgn(GetHdc(), rgn); ::DeleteObject(rgn); #endif } wxDCBase::DestroyClippingRegion(); } // --------------------------------------------------------------------------- // query capabilities // --------------------------------------------------------------------------- bool wxDC::CanDrawBitmap() const { return true; } bool wxDC::CanGetTextExtent() const { #ifdef __WXMICROWIN__ // TODO Extend MicroWindows' GetDeviceCaps function return true; #else // What sort of display is it? int technology = ::GetDeviceCaps(GetHdc(), TECHNOLOGY); return (technology == DT_RASDISPLAY) || (technology == DT_RASPRINTER); #endif } int wxDC::GetDepth() const { WXMICROWIN_CHECK_HDC_RET(16) return (int)::GetDeviceCaps(GetHdc(), BITSPIXEL); } // --------------------------------------------------------------------------- // drawing // --------------------------------------------------------------------------- void wxDC::Clear() { WXMICROWIN_CHECK_HDC RECT rect; if ( m_canvas ) { GetClientRect((HWND) m_canvas->GetHWND(), &rect); } else { // No, I think we should simply ignore this if printing on e.g. // a printer DC. // wxCHECK_RET( m_selectedBitmap.Ok(), wxT("this DC can't be cleared") ); if (!m_selectedBitmap.Ok()) return; rect.left = -m_deviceOriginX; rect.top = -m_deviceOriginY; rect.right = m_selectedBitmap.GetWidth()-m_deviceOriginX; rect.bottom = m_selectedBitmap.GetHeight()-m_deviceOriginY; } #ifndef __WXWINCE__ (void) ::SetMapMode(GetHdc(), MM_TEXT); #endif DWORD colour = ::GetBkColor(GetHdc()); HBRUSH brush = ::CreateSolidBrush(colour); ::FillRect(GetHdc(), &rect, brush); ::DeleteObject(brush); #ifndef __WXWINCE__ int width = DeviceToLogicalXRel(VIEWPORT_EXTENT)*m_signX, height = DeviceToLogicalYRel(VIEWPORT_EXTENT)*m_signY; ::SetMapMode(GetHdc(), MM_ANISOTROPIC); ::SetViewportExtEx(GetHdc(), VIEWPORT_EXTENT, VIEWPORT_EXTENT, NULL); ::SetWindowExtEx(GetHdc(), width, height, NULL); ::SetViewportOrgEx(GetHdc(), (int)m_deviceOriginX, (int)m_deviceOriginY, NULL); ::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL); #endif } bool wxDC::DoFloodFill(wxCoord WXUNUSED_IN_WINCE(x), wxCoord WXUNUSED_IN_WINCE(y), const wxColour& WXUNUSED_IN_WINCE(col), int WXUNUSED_IN_WINCE(style)) { #ifdef __WXWINCE__ return false; #else WXMICROWIN_CHECK_HDC_RET(false) bool success = (0 != ::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), col.GetPixel(), style == wxFLOOD_SURFACE ? FLOODFILLSURFACE : FLOODFILLBORDER) ) ; if (!success) { // quoting from the MSDN docs: // // Following are some of the reasons this function might fail: // // * The filling could not be completed. // * The specified point has the boundary color specified by the // crColor parameter (if FLOODFILLBORDER was requested). // * The specified point does not have the color specified by // crColor (if FLOODFILLSURFACE was requested) // * The point is outside the clipping region that is, it is not // visible on the device. // wxLogLastError(wxT("ExtFloodFill")); } CalcBoundingBox(x, y); return success; #endif } bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const { WXMICROWIN_CHECK_HDC_RET(false) wxCHECK_MSG( col, false, _T("NULL colour parameter in wxDC::GetPixel") ); // get the color of the pixel COLORREF pixelcolor = ::GetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y)); wxRGBToColour(*col, pixelcolor); return true; } void wxDC::DoCrossHair(wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC wxCoord x1 = x-VIEWPORT_EXTENT; wxCoord y1 = y-VIEWPORT_EXTENT; wxCoord x2 = x+VIEWPORT_EXTENT; wxCoord y2 = y+VIEWPORT_EXTENT; wxDrawLine(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y)); wxDrawLine(GetHdc(), XLOG2DEV(x), YLOG2DEV(y1), XLOG2DEV(x), YLOG2DEV(y2)); CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); } void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { WXMICROWIN_CHECK_HDC wxDrawLine(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2)); CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); } // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1) // and ending at (x2, y2) void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) { #ifdef __WXWINCE__ // Slower emulation since WinCE doesn't support Pie and Arc double r = sqrt( (x1-xc)*(x1-xc) + (y1-yc)*(y1-yc) ); double sa = acos((x1-xc)/r)/M_PI*180; // between 0 and 180 if( y1>yc ) sa = -sa; // below center double ea = atan2(yc-y2, x2-xc)/M_PI*180; DoDrawEllipticArcRot( xc-r, yc-r, 2*r, 2*r, sa, ea ); #else WXMICROWIN_CHECK_HDC wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling double dx = xc - x1; double dy = yc - y1; double radius = (double)sqrt(dx*dx+dy*dy); wxCoord r = (wxCoord)radius; // treat the special case of full circle separately if ( x1 == x2 && y1 == y2 ) { DrawEllipse(xc - r, yc - r, 2*r, 2*r); return; } wxCoord xx1 = XLOG2DEV(x1); wxCoord yy1 = YLOG2DEV(y1); wxCoord xx2 = XLOG2DEV(x2); wxCoord yy2 = YLOG2DEV(y2); wxCoord xxc = XLOG2DEV(xc); wxCoord yyc = YLOG2DEV(yc); wxCoord ray = (wxCoord) sqrt(double((xxc-xx1)*(xxc-xx1)+(yyc-yy1)*(yyc-yy1))); wxCoord xxx1 = (wxCoord) (xxc-ray); wxCoord yyy1 = (wxCoord) (yyc-ray); wxCoord xxx2 = (wxCoord) (xxc+ray); wxCoord yyy2 = (wxCoord) (yyc+ray); if ( m_brush.Ok() && m_brush.GetStyle() != wxTRANSPARENT ) { // Have to add 1 to bottom-right corner of rectangle // to make semi-circles look right (crooked line otherwise). // Unfortunately this is not a reliable method, depends // on the size of shape. // TODO: figure out why this happens! Pie(GetHdc(),xxx1,yyy1,xxx2+1,yyy2+1, xx1,yy1,xx2,yy2); } else { Arc(GetHdc(),xxx1,yyy1,xxx2,yyy2, xx1,yy1,xx2,yy2); } CalcBoundingBox(xc - r, yc - r); CalcBoundingBox(xc + r, yc + r); #endif } void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) { // cases when we don't have DrawFrameControl() #if defined(__SYMANTEC__) || defined(__WXMICROWIN__) return wxDCBase::DoDrawCheckMark(x1, y1, width, height); #else // normal case wxCoord x2 = x1 + width, y2 = y1 + height; RECT rect; rect.left = x1; rect.top = y1; rect.right = x2; rect.bottom = y2; #ifdef __WXWINCE__ DrawFrameControl(GetHdc(), &rect, DFC_BUTTON, DFCS_BUTTONCHECK); #else DrawFrameControl(GetHdc(), &rect, DFC_MENU, DFCS_MENUCHECK); #endif CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); #endif // Microwin/Normal } void wxDC::DoDrawPoint(wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC COLORREF color = 0x00ffffff; if (m_pen.Ok()) { color = m_pen.GetColour().GetPixel(); } SetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), color); CalcBoundingBox(x, y); } void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int WXUNUSED_IN_WINCE(fillStyle)) { WXMICROWIN_CHECK_HDC wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) { POINT *cpoints = new POINT[n]; int i; for (i = 0; i < n; i++) { cpoints[i].x = (int)(points[i].x + xoffset); cpoints[i].y = (int)(points[i].y + yoffset); CalcBoundingBox(cpoints[i].x, cpoints[i].y); } #ifndef __WXWINCE__ int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); #endif (void)Polygon(GetHdc(), cpoints, n); #ifndef __WXWINCE__ SetPolyFillMode(GetHdc(),prev); #endif delete[] cpoints; } else { int i; for (i = 0; i < n; i++) CalcBoundingBox(points[i].x, points[i].y); #ifndef __WXWINCE__ int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); #endif (void)Polygon(GetHdc(), (POINT*) points, n); #ifndef __WXWINCE__ SetPolyFillMode(GetHdc(),prev); #endif } } void wxDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { #ifdef __WXWINCE__ wxDCBase::DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); #else WXMICROWIN_CHECK_HDC wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling int i, cnt; for (i = cnt = 0; i < n; i++) cnt += count[i]; // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) { POINT *cpoints = new POINT[cnt]; for (i = 0; i < cnt; i++) { cpoints[i].x = (int)(points[i].x + xoffset); cpoints[i].y = (int)(points[i].y + yoffset); CalcBoundingBox(cpoints[i].x, cpoints[i].y); } #ifndef __WXWINCE__ int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); #endif (void)PolyPolygon(GetHdc(), cpoints, count, n); #ifndef __WXWINCE__ SetPolyFillMode(GetHdc(),prev); #endif delete[] cpoints; } else { for (i = 0; i < cnt; i++) CalcBoundingBox(points[i].x, points[i].y); #ifndef __WXWINCE__ int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); #endif (void)PolyPolygon(GetHdc(), (POINT*) points, count, n); #ifndef __WXWINCE__ SetPolyFillMode(GetHdc(),prev); #endif } #endif // __WXWINCE__ } void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { WXMICROWIN_CHECK_HDC // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) { POINT *cpoints = new POINT[n]; int i; for (i = 0; i < n; i++) { cpoints[i].x = (int)(points[i].x + xoffset); cpoints[i].y = (int)(points[i].y + yoffset); CalcBoundingBox(cpoints[i].x, cpoints[i].y); } (void)Polyline(GetHdc(), cpoints, n); delete[] cpoints; } else { int i; for (i = 0; i < n; i++) CalcBoundingBox(points[i].x, points[i].y); (void)Polyline(GetHdc(), (POINT*) points, n); } } void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { WXMICROWIN_CHECK_HDC wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling wxCoord x2 = x + width; wxCoord y2 = y + height; if ((m_logicalFunction == wxCOPY) && (m_pen.GetStyle() == wxTRANSPARENT)) { RECT rect; rect.left = XLOG2DEV(x); rect.top = YLOG2DEV(y); rect.right = XLOG2DEV(x2); rect.bottom = YLOG2DEV(y2); (void)FillRect(GetHdc(), &rect, (HBRUSH)m_brush.GetResourceHandle() ); } else { // Windows draws the filled rectangles without outline (i.e. drawn with a // transparent pen) one pixel smaller in both directions and we want them // to have the same size regardless of which pen is used - adjust // I wonder if this shouldnt be done after the LOG2DEV() conversions. RR. if ( m_pen.GetStyle() == wxTRANSPARENT ) { // Apparently not needed for WinCE (see e.g. Life! demo) #ifndef __WXWINCE__ x2++; y2++; #endif } (void)Rectangle(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2)); } CalcBoundingBox(x, y); CalcBoundingBox(x2, y2); } void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { WXMICROWIN_CHECK_HDC wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling // Now, a negative radius value is interpreted to mean // 'the proportion of the smallest X or Y dimension' if (radius < 0.0) { double smallest = (width < height) ? width : height; radius = (- radius * smallest); } wxCoord x2 = (x+width); wxCoord y2 = (y+height); // Windows draws the filled rectangles without outline (i.e. drawn with a // transparent pen) one pixel smaller in both directions and we want them // to have the same size regardless of which pen is used - adjust if ( m_pen.GetStyle() == wxTRANSPARENT ) { x2++; y2++; } (void)RoundRect(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2), (int) (2*XLOG2DEV(radius)), (int)( 2*YLOG2DEV(radius))); CalcBoundingBox(x, y); CalcBoundingBox(x2, y2); } void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { WXMICROWIN_CHECK_HDC wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling wxCoord x2 = (x+width); wxCoord y2 = (y+height); (void)Ellipse(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2)); CalcBoundingBox(x, y); CalcBoundingBox(x2, y2); } #if wxUSE_SPLINES void wxDC::DoDrawSpline(wxList *points) { #ifdef __WXWINCE__ // WinCE does not support ::PolyBezier so use generic version wxDCBase::DoDrawSpline(points); #else // quadratic b-spline to cubic bezier spline conversion // // quadratic spline with control points P0,P1,P2 // P(s) = P0*(1-s)^2 + P1*2*(1-s)*s + P2*s^2 // // bezier spline with control points B0,B1,B2,B3 // B(s) = B0*(1-s)^3 + B1*3*(1-s)^2*s + B2*3*(1-s)*s^2 + B3*s^3 // // control points of bezier spline calculated from b-spline // B0 = P0 // B1 = (2*P1 + P0)/3 // B2 = (2*P1 + P2)/3 // B3 = P2 WXMICROWIN_CHECK_HDC wxASSERT_MSG( points, wxT("NULL pointer to spline points?") ); const size_t n_points = points->GetCount(); wxASSERT_MSG( n_points > 2 , wxT("incomplete list of spline points?") ); const size_t n_bezier_points = n_points * 3 + 1; POINT *lppt = (POINT *)malloc(n_bezier_points*sizeof(POINT)); size_t bezier_pos = 0; wxCoord x1, y1, x2, y2, cx1, cy1, cx4, cy4; wxList::compatibility_iterator node = points->GetFirst(); wxPoint *p = (wxPoint *)node->GetData(); lppt[ bezier_pos ].x = x1 = p->x; lppt[ bezier_pos ].y = y1 = p->y; bezier_pos++; lppt[ bezier_pos ] = lppt[ bezier_pos-1 ]; bezier_pos++; node = node->GetNext(); p = (wxPoint *)node->GetData(); x2 = p->x; y2 = p->y; cx1 = ( x1 + x2 ) / 2; cy1 = ( y1 + y2 ) / 2; lppt[ bezier_pos ].x = XLOG2DEV(cx1); lppt[ bezier_pos ].y = YLOG2DEV(cy1); bezier_pos++; lppt[ bezier_pos ] = lppt[ bezier_pos-1 ]; bezier_pos++; #if !wxUSE_STL while ((node = node->GetNext()) != NULL) #else while ((node = node->GetNext())) #endif // !wxUSE_STL { p = (wxPoint *)node->GetData(); x1 = x2; y1 = y2; x2 = p->x; y2 = p->y; cx4 = (x1 + x2) / 2; cy4 = (y1 + y2) / 2; // B0 is B3 of previous segment // B1: lppt[ bezier_pos ].x = XLOG2DEV((x1*2+cx1)/3); lppt[ bezier_pos ].y = YLOG2DEV((y1*2+cy1)/3); bezier_pos++; // B2: lppt[ bezier_pos ].x = XLOG2DEV((x1*2+cx4)/3); lppt[ bezier_pos ].y = YLOG2DEV((y1*2+cy4)/3); bezier_pos++; // B3: lppt[ bezier_pos ].x = XLOG2DEV(cx4); lppt[ bezier_pos ].y = YLOG2DEV(cy4); bezier_pos++; cx1 = cx4; cy1 = cy4; } lppt[ bezier_pos ] = lppt[ bezier_pos-1 ]; bezier_pos++; lppt[ bezier_pos ].x = XLOG2DEV(x2); lppt[ bezier_pos ].y = YLOG2DEV(y2); bezier_pos++; lppt[ bezier_pos ] = lppt[ bezier_pos-1 ]; bezier_pos++; ::PolyBezier( GetHdc(), lppt, bezier_pos ); free(lppt); #endif } #endif // Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { #ifdef __WXWINCE__ DoDrawEllipticArcRot( x, y, w, h, sa, ea ); #else WXMICROWIN_CHECK_HDC wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling wxCoord x2 = x + w; wxCoord y2 = y + h; int rx1 = XLOG2DEV(x+w/2); int ry1 = YLOG2DEV(y+h/2); int rx2 = rx1; int ry2 = ry1; sa = DegToRad(sa); ea = DegToRad(ea); rx1 += (int)(100.0 * abs(w) * cos(sa)); ry1 -= (int)(100.0 * abs(h) * m_signY * sin(sa)); rx2 += (int)(100.0 * abs(w) * cos(ea)); ry2 -= (int)(100.0 * abs(h) * m_signY * sin(ea)); // draw pie with NULL_PEN first and then outline otherwise a line is // drawn from the start and end points to the centre HPEN hpenOld = (HPEN) ::SelectObject(GetHdc(), (HPEN) ::GetStockObject(NULL_PEN)); if (m_signY > 0) { (void)Pie(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2)+1, YLOG2DEV(y2)+1, rx1, ry1, rx2, ry2); } else { (void)Pie(GetHdc(), XLOG2DEV(x), YLOG2DEV(y)-1, XLOG2DEV(x2)+1, YLOG2DEV(y2), rx1, ry1-1, rx2, ry2-1); } ::SelectObject(GetHdc(), hpenOld); (void)Arc(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2), rx1, ry1, rx2, ry2); CalcBoundingBox(x, y); CalcBoundingBox(x2, y2); #endif } void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC wxCHECK_RET( icon.Ok(), wxT("invalid icon in DrawIcon") ); #ifdef __WIN32__ ::DrawIconEx(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), GetHiconOf(icon), icon.GetWidth(), icon.GetHeight(), 0, NULL, DI_NORMAL); #else ::DrawIcon(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), GetHiconOf(icon)); #endif CalcBoundingBox(x, y); CalcBoundingBox(x + icon.GetWidth(), y + icon.GetHeight()); } void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) { WXMICROWIN_CHECK_HDC wxCHECK_RET( bmp.Ok(), _T("invalid bitmap in wxDC::DrawBitmap") ); int width = bmp.GetWidth(), height = bmp.GetHeight(); HBITMAP hbmpMask = 0; #if wxUSE_PALETTE HPALETTE oldPal = 0; #endif // wxUSE_PALETTE if ( bmp.HasAlpha() ) { MemoryHDC hdcMem; SelectInHDC select(hdcMem, GetHbitmapOf(bmp)); if ( AlphaBlt(GetHdc(), x, y, width, height, 0, 0, hdcMem, bmp) ) return; } if ( useMask ) { wxMask *mask = bmp.GetMask(); if ( mask ) hbmpMask = (HBITMAP)mask->GetMaskBitmap(); if ( !hbmpMask ) { // don't give assert here because this would break existing // programs - just silently ignore useMask parameter useMask = false; } } if ( useMask ) { #ifdef __WIN32__ // use MaskBlt() with ROP which doesn't do anything to dst in the mask // points // On some systems, MaskBlt succeeds yet is much much slower // than the wxWidgets fall-back implementation. So we need // to be able to switch this on and off at runtime. bool ok = false; #if wxUSE_SYSTEM_OPTIONS if (wxSystemOptions::GetOptionInt(wxT("no-maskblt")) == 0) #endif { HDC cdc = GetHdc(); HDC hdcMem = ::CreateCompatibleDC(GetHdc()); HGDIOBJ hOldBitmap = ::SelectObject(hdcMem, GetHbitmapOf(bmp)); #if wxUSE_PALETTE wxPalette *pal = bmp.GetPalette(); if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 ) { oldPal = ::SelectPalette(hdcMem, GetHpaletteOf(*pal), FALSE); ::RealizePalette(hdcMem); } #endif // wxUSE_PALETTE ok = ::MaskBlt(cdc, x, y, width, height, hdcMem, 0, 0, hbmpMask, 0, 0, MAKEROP4(SRCCOPY, DSTCOPY)) != 0; #if wxUSE_PALETTE if (oldPal) ::SelectPalette(hdcMem, oldPal, FALSE); #endif // wxUSE_PALETTE ::SelectObject(hdcMem, hOldBitmap); ::DeleteDC(hdcMem); } if ( !ok ) #endif // Win32 { // Rather than reproduce wxDC::Blit, let's do it at the wxWin API // level wxMemoryDC memDC; memDC.SelectObjectAsSource(bmp); Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask); memDC.SelectObject(wxNullBitmap); } } else // no mask, just use BitBlt() { HDC cdc = GetHdc(); HDC memdc = ::CreateCompatibleDC( cdc ); HBITMAP hbitmap = (HBITMAP) bmp.GetHBITMAP( ); wxASSERT_MSG( hbitmap, wxT("bitmap is ok but HBITMAP is NULL?") ); COLORREF old_textground = ::GetTextColor(GetHdc()); COLORREF old_background = ::GetBkColor(GetHdc()); if (m_textForegroundColour.Ok()) { ::SetTextColor(GetHdc(), m_textForegroundColour.GetPixel() ); } if (m_textBackgroundColour.Ok()) { ::SetBkColor(GetHdc(), m_textBackgroundColour.GetPixel() ); } #if wxUSE_PALETTE wxPalette *pal = bmp.GetPalette(); if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 ) { oldPal = ::SelectPalette(memdc, GetHpaletteOf(*pal), FALSE); ::RealizePalette(memdc); } #endif // wxUSE_PALETTE HGDIOBJ hOldBitmap = ::SelectObject( memdc, hbitmap ); ::BitBlt( cdc, x, y, width, height, memdc, 0, 0, SRCCOPY); #if wxUSE_PALETTE if (oldPal) ::SelectPalette(memdc, oldPal, FALSE); #endif // wxUSE_PALETTE ::SelectObject( memdc, hOldBitmap ); ::DeleteDC( memdc ); ::SetTextColor(GetHdc(), old_textground); ::SetBkColor(GetHdc(), old_background); } } void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC DrawAnyText(text, x, y); // update the bounding box CalcBoundingBox(x, y); wxCoord w, h; GetTextExtent(text, &w, &h); CalcBoundingBox(x + w, y + h); } void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC // prepare for drawing the text if ( m_textForegroundColour.Ok() ) SetTextColor(GetHdc(), m_textForegroundColour.GetPixel()); DWORD old_background = 0; if ( m_textBackgroundColour.Ok() ) { old_background = SetBkColor(GetHdc(), m_textBackgroundColour.GetPixel() ); } SetBkMode(GetHdc(), m_backgroundMode == wxTRANSPARENT ? TRANSPARENT : OPAQUE); #ifdef __WXWINCE__ if ( ::ExtTextOut(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), 0, NULL, text.c_str(), text.length(), NULL) == 0 ) { wxLogLastError(wxT("TextOut")); } #else if ( ::TextOut(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), text.c_str(), text.length()) == 0 ) { wxLogLastError(wxT("TextOut")); } #endif // restore the old parameters (text foreground colour may be left because // it never is set to anything else, but background should remain // transparent even if we just drew an opaque string) if ( m_textBackgroundColour.Ok() ) (void)SetBkColor(GetHdc(), old_background); SetBkMode(GetHdc(), TRANSPARENT); } void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { WXMICROWIN_CHECK_HDC // we test that we have some font because otherwise we should still use the // "else" part below to avoid that DrawRotatedText(angle = 180) and // DrawRotatedText(angle = 0) use different fonts (we can't use the default // font for drawing rotated fonts unfortunately) if ( (angle == 0.0) && m_font.Ok() ) { DoDrawText(text, x, y); } #ifndef __WXMICROWIN__ else { // NB: don't take DEFAULT_GUI_FONT (a.k.a. wxSYS_DEFAULT_GUI_FONT) // because it's not TrueType and so can't have non zero // orientation/escapement under Win9x wxFont font = m_font.Ok() ? m_font : *wxSWISS_FONT; HFONT hfont = (HFONT)font.GetResourceHandle(); LOGFONT lf; if ( ::GetObject(hfont, sizeof(lf), &lf) == 0 ) { wxLogLastError(wxT("GetObject(hfont)")); } // GDI wants the angle in tenth of degree long angle10 = (long)(angle * 10); lf.lfEscapement = angle10; lf. lfOrientation = angle10; hfont = ::CreateFontIndirect(&lf); if ( !hfont ) { wxLogLastError(wxT("CreateFont")); } else { HFONT hfontOld = (HFONT)::SelectObject(GetHdc(), hfont); DrawAnyText(text, x, y); (void)::SelectObject(GetHdc(), hfontOld); (void)::DeleteObject(hfont); } // call the bounding box by adding all four vertices of the rectangle // containing the text to it (simpler and probably not slower than // determining which of them is really topmost/leftmost/...) wxCoord w, h; GetTextExtent(text, &w, &h); double rad = DegToRad(angle); // "upper left" and "upper right" CalcBoundingBox(x, y); CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); // "bottom left" and "bottom right" x += (wxCoord)(h*sin(rad)); y += (wxCoord)(h*cos(rad)); CalcBoundingBox(x, y); CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); } #endif } // --------------------------------------------------------------------------- // set GDI objects // --------------------------------------------------------------------------- #if wxUSE_PALETTE void wxDC::DoSelectPalette(bool realize) { WXMICROWIN_CHECK_HDC // Set the old object temporarily, in case the assignment deletes an object // that's not yet selected out. if (m_oldPalette) { ::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, FALSE); m_oldPalette = 0; } if ( m_palette.Ok() ) { HPALETTE oldPal = ::SelectPalette(GetHdc(), GetHpaletteOf(m_palette), false); if (!m_oldPalette) m_oldPalette = (WXHPALETTE) oldPal; if (realize) ::RealizePalette(GetHdc()); } } void wxDC::SetPalette(const wxPalette& palette) { if ( palette.Ok() ) { m_palette = palette; DoSelectPalette(true); } } void wxDC::InitializePalette() { if ( wxDisplayDepth() <= 8 ) { // look for any window or parent that has a custom palette. If any has // one then we need to use it in drawing operations wxWindow *win = m_canvas->GetAncestorWithCustomPalette(); m_hasCustomPalette = win && win->HasCustomPalette(); if ( m_hasCustomPalette ) { m_palette = win->GetPalette(); // turn on MSW translation for this palette DoSelectPalette(); } } } #endif // wxUSE_PALETTE // SetFont/Pen/Brush() really ask to be implemented as a single template // function... but doing it is not worth breaking OpenWatcom build <sigh> void wxDC::SetFont(const wxFont& font) { WXMICROWIN_CHECK_HDC if ( font == m_font ) return; if ( font.Ok() ) { HGDIOBJ hfont = ::SelectObject(GetHdc(), GetHfontOf(font)); if ( hfont == HGDI_ERROR ) { wxLogLastError(_T("SelectObject(font)")); } else // selected ok { if ( !m_oldFont ) m_oldFont = (WXHFONT)hfont; m_font = font; } } else // invalid font, reset the current font { if ( m_oldFont ) { if ( ::SelectObject(GetHdc(), (HPEN) m_oldFont) == HGDI_ERROR ) { wxLogLastError(_T("SelectObject(old font)")); } m_oldFont = 0; } m_font = wxNullFont; } } void wxDC::SetPen(const wxPen& pen) { WXMICROWIN_CHECK_HDC if ( pen == m_pen ) return; if ( pen.Ok() ) { HGDIOBJ hpen = ::SelectObject(GetHdc(), GetHpenOf(pen)); if ( hpen == HGDI_ERROR ) { wxLogLastError(_T("SelectObject(pen)")); } else // selected ok { if ( !m_oldPen ) m_oldPen = (WXHPEN)hpen; m_pen = pen; } } else // invalid pen, reset the current pen { if ( m_oldPen ) { if ( ::SelectObject(GetHdc(), (HPEN) m_oldPen) == HGDI_ERROR ) { wxLogLastError(_T("SelectObject(old pen)")); } m_oldPen = 0; } m_pen = wxNullPen; } } void wxDC::SetBrush(const wxBrush& brush) { WXMICROWIN_CHECK_HDC if ( brush == m_brush ) return; if ( brush.Ok() ) { // we must make sure the brush is aligned with the logical coordinates // before selecting it wxBitmap *stipple = brush.GetStipple(); if ( stipple && stipple->Ok() ) { if ( !::SetBrushOrgEx ( GetHdc(), m_deviceOriginX % stipple->GetWidth(), m_deviceOriginY % stipple->GetHeight(), NULL // [out] previous brush origin ) ) { wxLogLastError(_T("SetBrushOrgEx()")); } } HGDIOBJ hbrush = ::SelectObject(GetHdc(), GetHbrushOf(brush)); if ( hbrush == HGDI_ERROR ) { wxLogLastError(_T("SelectObject(brush)")); } else // selected ok { if ( !m_oldBrush ) m_oldBrush = (WXHBRUSH)hbrush; m_brush = brush; } } else // invalid brush, reset the current brush { if ( m_oldBrush ) { if ( ::SelectObject(GetHdc(), (HPEN) m_oldBrush) == HGDI_ERROR ) { wxLogLastError(_T("SelectObject(old brush)")); } m_oldBrush = 0; } m_brush = wxNullBrush; } } void wxDC::SetBackground(const wxBrush& brush) { WXMICROWIN_CHECK_HDC m_backgroundBrush = brush; if ( m_backgroundBrush.Ok() ) { (void)SetBkColor(GetHdc(), m_backgroundBrush.GetColour().GetPixel()); } } void wxDC::SetBackgroundMode(int mode) { WXMICROWIN_CHECK_HDC m_backgroundMode = mode; // SetBackgroundColour now only refers to text background // and m_backgroundMode is used there } void wxDC::SetLogicalFunction(int function) { WXMICROWIN_CHECK_HDC m_logicalFunction = function; SetRop(m_hDC); } void wxDC::SetRop(WXHDC dc) { if ( !dc || m_logicalFunction < 0 ) return; int rop; switch (m_logicalFunction) { case wxCLEAR: rop = R2_BLACK; break; case wxXOR: rop = R2_XORPEN; break; case wxINVERT: rop = R2_NOT; break; case wxOR_REVERSE: rop = R2_MERGEPENNOT; break; case wxAND_REVERSE: rop = R2_MASKPENNOT; break; case wxCOPY: rop = R2_COPYPEN; break; case wxAND: rop = R2_MASKPEN; break; case wxAND_INVERT: rop = R2_MASKNOTPEN; break; case wxNO_OP: rop = R2_NOP; break; case wxNOR: rop = R2_NOTMERGEPEN; break; case wxEQUIV: rop = R2_NOTXORPEN; break; case wxSRC_INVERT: rop = R2_NOTCOPYPEN; break; case wxOR_INVERT: rop = R2_MERGENOTPEN; break; case wxNAND: rop = R2_NOTMASKPEN; break; case wxOR: rop = R2_MERGEPEN; break; case wxSET: rop = R2_WHITE; break; default: wxFAIL_MSG( wxT("unsupported logical function") ); return; } SetROP2(GetHdc(), rop); } bool wxDC::StartDoc(const wxString& WXUNUSED(message)) { // We might be previewing, so return true to let it continue. return true; } void wxDC::EndDoc() { } void wxDC::StartPage() { } void wxDC::EndPage() { } // --------------------------------------------------------------------------- // text metrics // --------------------------------------------------------------------------- wxCoord wxDC::GetCharHeight() const { WXMICROWIN_CHECK_HDC_RET(0) TEXTMETRIC lpTextMetric; GetTextMetrics(GetHdc(), &lpTextMetric); return lpTextMetric.tmHeight; } wxCoord wxDC::GetCharWidth() const { WXMICROWIN_CHECK_HDC_RET(0) TEXTMETRIC lpTextMetric; GetTextMetrics(GetHdc(), &lpTextMetric); return lpTextMetric.tmAveCharWidth; } void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, wxFont *font) const { #ifdef __WXMICROWIN__ if (!GetHDC()) { if (x) *x = 0; if (y) *y = 0; if (descent) *descent = 0; if (externalLeading) *externalLeading = 0; return; } #endif // __WXMICROWIN__ HFONT hfontOld; if ( font ) { wxASSERT_MSG( font->Ok(), _T("invalid font in wxDC::GetTextExtent") ); hfontOld = (HFONT)::SelectObject(GetHdc(), GetHfontOf(*font)); } else // don't change the font { hfontOld = 0; } SIZE sizeRect; const size_t len = string.length(); if ( !::GetTextExtentPoint32(GetHdc(), string, len, &sizeRect) ) { wxLogLastError(_T("GetTextExtentPoint32()")); } #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) // the result computed by GetTextExtentPoint32() may be too small as it // accounts for under/overhang of the first/last character while we want // just the bounding rect for this string so adjust the width as needed // (using API not available in 2002 SDKs of WinCE) if ( len > 0 ) { ABC width; const wxChar chFirst = *string.begin(); if ( ::GetCharABCWidths(GetHdc(), chFirst, chFirst, &width) ) { if ( width.abcA < 0 ) sizeRect.cx -= width.abcA; if ( len > 1 ) { const wxChar chLast = *string.rbegin(); ::GetCharABCWidths(GetHdc(), chLast, chLast, &width); } //else: we already have the width of the last character if ( width.abcC < 0 ) sizeRect.cx -= width.abcC; } //else: GetCharABCWidths() failed, not a TrueType font? } #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) TEXTMETRIC tm; ::GetTextMetrics(GetHdc(), &tm); if (x) *x = sizeRect.cx; if (y) *y = sizeRect.cy; if (descent) *descent = tm.tmDescent; if (externalLeading) *externalLeading = tm.tmExternalLeading; if ( hfontOld ) { ::SelectObject(GetHdc(), hfontOld); } } // Each element of the array will be the width of the string up to and // including the coresoponding character in text. bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { static int maxLenText = -1; static int maxWidth = -1; int fit = 0; SIZE sz = {0,0}; int stlen = text.length(); if (maxLenText == -1) { // Win9x and WinNT+ have different limits int version = wxGetOsVersion(); maxLenText = version == wxOS_WINDOWS_NT ? 65535 : 8192; maxWidth = version == wxOS_WINDOWS_NT ? INT_MAX : 32767; } widths.Empty(); widths.Add(0, stlen); // fill the array with zeros if (stlen == 0) return true; if (!::GetTextExtentExPoint(GetHdc(), text.c_str(), // string to check wxMin(stlen, maxLenText), maxWidth, &fit, // [out] count of chars // that will fit &widths[0], // array to fill &sz)) { // API failed wxLogLastError(wxT("GetTextExtentExPoint")); return false; } return true; } void wxDC::SetMapMode(int mode) { WXMICROWIN_CHECK_HDC m_mappingMode = mode; if ( mode == wxMM_TEXT ) { m_logicalScaleX = m_logicalScaleY = 1.0; } else // need to do some calculations { int pixel_width = ::GetDeviceCaps(GetHdc(), HORZRES), pixel_height = ::GetDeviceCaps(GetHdc(), VERTRES), mm_width = ::GetDeviceCaps(GetHdc(), HORZSIZE), mm_height = ::GetDeviceCaps(GetHdc(), VERTSIZE); if ( (mm_width == 0) || (mm_height == 0) ) { // we can't calculate mm2pixels[XY] then! return; } double mm2pixelsX = (double)pixel_width / mm_width, mm2pixelsY = (double)pixel_height / mm_height; switch (mode) { case wxMM_TWIPS: m_logicalScaleX = twips2mm * mm2pixelsX; m_logicalScaleY = twips2mm * mm2pixelsY; break; case wxMM_POINTS: m_logicalScaleX = pt2mm * mm2pixelsX; m_logicalScaleY = pt2mm * mm2pixelsY; break; case wxMM_METRIC: m_logicalScaleX = mm2pixelsX; m_logicalScaleY = mm2pixelsY; break; case wxMM_LOMETRIC: m_logicalScaleX = mm2pixelsX / 10.0; m_logicalScaleY = mm2pixelsY / 10.0; break; default: wxFAIL_MSG( _T("unknown mapping mode in SetMapMode") ); } } // VZ: it seems very wasteful to always use MM_ANISOTROPIC when in 99% of // cases we could do with MM_TEXT and in the remaining 0.9% with // MM_ISOTROPIC (TODO!) #ifndef __WXWINCE__ ::SetMapMode(GetHdc(), MM_ANISOTROPIC); int width = DeviceToLogicalXRel(VIEWPORT_EXTENT)*m_signX, height = DeviceToLogicalYRel(VIEWPORT_EXTENT)*m_signY; ::SetViewportExtEx(GetHdc(), VIEWPORT_EXTENT, VIEWPORT_EXTENT, NULL); ::SetWindowExtEx(GetHdc(), width, height, NULL); ::SetViewportOrgEx(GetHdc(), m_deviceOriginX, m_deviceOriginY, NULL); ::SetWindowOrgEx(GetHdc(), m_logicalOriginX, m_logicalOriginY, NULL); #endif } void wxDC::SetUserScale(double x, double y) { WXMICROWIN_CHECK_HDC if ( x == m_userScaleX && y == m_userScaleY ) return; m_userScaleX = x; m_userScaleY = y; this->SetMapMode(m_mappingMode); } void wxDC::SetAxisOrientation(bool WXUNUSED_IN_WINCE(xLeftRight), bool WXUNUSED_IN_WINCE(yBottomUp)) { WXMICROWIN_CHECK_HDC #ifndef __WXWINCE__ int signX = xLeftRight ? 1 : -1, signY = yBottomUp ? -1 : 1; if ( signX != m_signX || signY != m_signY ) { m_signX = signX; m_signY = signY; SetMapMode(m_mappingMode); } #endif } void wxDC::SetSystemScale(double x, double y) { WXMICROWIN_CHECK_HDC if ( x == m_scaleX && y == m_scaleY ) return; m_scaleX = x; m_scaleY = y; #ifndef __WXWINCE__ SetMapMode(m_mappingMode); #endif } void wxDC::SetLogicalOrigin(wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC if ( x == m_logicalOriginX && y == m_logicalOriginY ) return; m_logicalOriginX = x; m_logicalOriginY = y; #ifndef __WXWINCE__ ::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL); #endif } void wxDC::SetDeviceOrigin(wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC if ( x == m_deviceOriginX && y == m_deviceOriginY ) return; m_deviceOriginX = x; m_deviceOriginY = y; ::SetViewportOrgEx(GetHdc(), (int)m_deviceOriginX, (int)m_deviceOriginY, NULL); } // --------------------------------------------------------------------------- // coordinates transformations // --------------------------------------------------------------------------- wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const { return DeviceToLogicalXRel(x - m_deviceOriginX)*m_signX + m_logicalOriginX; } wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const { // axis orientation is not taken into account for conversion of a distance return (wxCoord)(x / (m_logicalScaleX*m_userScaleX*m_scaleX)); } wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const { return DeviceToLogicalYRel(y - m_deviceOriginY)*m_signY + m_logicalOriginY; } wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const { // axis orientation is not taken into account for conversion of a distance return (wxCoord)( y / (m_logicalScaleY*m_userScaleY*m_scaleY)); } wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const { return LogicalToDeviceXRel(x - m_logicalOriginX)*m_signX + m_deviceOriginX; } wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const { // axis orientation is not taken into account for conversion of a distance return (wxCoord) (x*m_logicalScaleX*m_userScaleX*m_scaleX); } wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const { return LogicalToDeviceYRel(y - m_logicalOriginY)*m_signY + m_deviceOriginY; } wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const { // axis orientation is not taken into account for conversion of a distance return (wxCoord) (y*m_logicalScaleY*m_userScaleY*m_scaleY); } // --------------------------------------------------------------------------- // bit blit // --------------------------------------------------------------------------- bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask) { wxCHECK_MSG( source, false, _T("wxDC::Blit(): NULL wxDC pointer") ); WXMICROWIN_CHECK_HDC_RET(false) // if either the source or destination has alpha channel, we must use // AlphaBlt() as other function don't handle it correctly const wxBitmap& bmpSrc = source->m_selectedBitmap; if ( bmpSrc.Ok() && (bmpSrc.HasAlpha() || (m_selectedBitmap.Ok() && m_selectedBitmap.HasAlpha())) ) { if ( AlphaBlt(GetHdc(), xdest, ydest, width, height, xsrc, ysrc, GetHdcOf(*source), bmpSrc) ) return true; } wxMask *mask = NULL; if ( useMask ) { mask = bmpSrc.GetMask(); if ( !(bmpSrc.Ok() && mask && mask->GetMaskBitmap()) ) { // don't give assert here because this would break existing // programs - just silently ignore useMask parameter useMask = false; } } if (xsrcMask == -1 && ysrcMask == -1) { xsrcMask = xsrc; ysrcMask = ysrc; } COLORREF old_textground = ::GetTextColor(GetHdc()); COLORREF old_background = ::GetBkColor(GetHdc()); if (m_textForegroundColour.Ok()) { ::SetTextColor(GetHdc(), m_textForegroundColour.GetPixel() ); } if (m_textBackgroundColour.Ok()) { ::SetBkColor(GetHdc(), m_textBackgroundColour.GetPixel() ); } DWORD dwRop; switch (rop) { case wxXOR: dwRop = SRCINVERT; break; case wxINVERT: dwRop = DSTINVERT; break; case wxOR_REVERSE: dwRop = 0x00DD0228; break; case wxAND_REVERSE: dwRop = SRCERASE; break; case wxCLEAR: dwRop = BLACKNESS; break; case wxSET: dwRop = WHITENESS; break; case wxOR_INVERT: dwRop = MERGEPAINT; break; case wxAND: dwRop = SRCAND; break; case wxOR: dwRop = SRCPAINT; break; case wxEQUIV: dwRop = 0x00990066; break; case wxNAND: dwRop = 0x007700E6; break; case wxAND_INVERT: dwRop = 0x00220326; break; case wxCOPY: dwRop = SRCCOPY; break; case wxNO_OP: dwRop = DSTCOPY; break; case wxSRC_INVERT: dwRop = NOTSRCCOPY; break; case wxNOR: dwRop = NOTSRCCOPY; break; default: wxFAIL_MSG( wxT("unsupported logical function") ); return false; } bool success = false; if (useMask) { #ifdef __WIN32__ // we want the part of the image corresponding to the mask to be // transparent, so use "DSTCOPY" ROP for the mask points (the usual // meaning of fg and bg is inverted which corresponds to wxWin notion // of the mask which is also contrary to the Windows one) // On some systems, MaskBlt succeeds yet is much much slower // than the wxWidgets fall-back implementation. So we need // to be able to switch this on and off at runtime. #if wxUSE_SYSTEM_OPTIONS if (wxSystemOptions::GetOptionInt(wxT("no-maskblt")) == 0) #endif { success = ::MaskBlt ( GetHdc(), xdest, ydest, width, height, GetHdcOf(*source), xsrc, ysrc, (HBITMAP)mask->GetMaskBitmap(), xsrcMask, ysrcMask, MAKEROP4(dwRop, DSTCOPY) ) != 0; } if ( !success ) #endif // Win32 { // Blit bitmap with mask HDC dc_mask ; HDC dc_buffer ; HBITMAP buffer_bmap ; #if wxUSE_DC_CACHEING // create a temp buffer bitmap and DCs to access it and the mask wxDCCacheEntry* dcCacheEntry1 = FindDCInCache(NULL, source->GetHDC()); dc_mask = (HDC) dcCacheEntry1->m_dc; wxDCCacheEntry* dcCacheEntry2 = FindDCInCache(dcCacheEntry1, GetHDC()); dc_buffer = (HDC) dcCacheEntry2->m_dc; wxDCCacheEntry* bitmapCacheEntry = FindBitmapInCache(GetHDC(), width, height); buffer_bmap = (HBITMAP) bitmapCacheEntry->m_bitmap; #else // !wxUSE_DC_CACHEING // create a temp buffer bitmap and DCs to access it and the mask dc_mask = ::CreateCompatibleDC(GetHdcOf(*source)); dc_buffer = ::CreateCompatibleDC(GetHdc()); buffer_bmap = ::CreateCompatibleBitmap(GetHdc(), width, height); #endif // wxUSE_DC_CACHEING/!wxUSE_DC_CACHEING HGDIOBJ hOldMaskBitmap = ::SelectObject(dc_mask, (HBITMAP) mask->GetMaskBitmap()); HGDIOBJ hOldBufferBitmap = ::SelectObject(dc_buffer, buffer_bmap); // copy dest to buffer if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, GetHdc(), xdest, ydest, SRCCOPY) ) { wxLogLastError(wxT("BitBlt")); } // copy src to buffer using selected raster op if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, GetHdcOf(*source), xsrc, ysrc, dwRop) ) { wxLogLastError(wxT("BitBlt")); } // set masked area in buffer to BLACK (pixel value 0) COLORREF prevBkCol = ::SetBkColor(GetHdc(), RGB(255, 255, 255)); COLORREF prevCol = ::SetTextColor(GetHdc(), RGB(0, 0, 0)); if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, dc_mask, xsrcMask, ysrcMask, SRCAND) ) { wxLogLastError(wxT("BitBlt")); } // set unmasked area in dest to BLACK ::SetBkColor(GetHdc(), RGB(0, 0, 0)); ::SetTextColor(GetHdc(), RGB(255, 255, 255)); if ( !::BitBlt(GetHdc(), xdest, ydest, (int)width, (int)height, dc_mask, xsrcMask, ysrcMask, SRCAND) ) { wxLogLastError(wxT("BitBlt")); } ::SetBkColor(GetHdc(), prevBkCol); // restore colours to original values ::SetTextColor(GetHdc(), prevCol); // OR buffer to dest success = ::BitBlt(GetHdc(), xdest, ydest, (int)width, (int)height, dc_buffer, 0, 0, SRCPAINT) != 0; if ( !success ) { wxLogLastError(wxT("BitBlt")); } // tidy up temporary DCs and bitmap ::SelectObject(dc_mask, hOldMaskBitmap); ::SelectObject(dc_buffer, hOldBufferBitmap); #if !wxUSE_DC_CACHEING { ::DeleteDC(dc_mask); ::DeleteDC(dc_buffer); ::DeleteObject(buffer_bmap); } #endif } } else // no mask, just BitBlt() it { // if we already have a DIB, draw it using StretchDIBits(), otherwise // use StretchBlt() if available and finally fall back to BitBlt() // FIXME: use appropriate WinCE functions #ifndef __WXWINCE__ const int caps = ::GetDeviceCaps(GetHdc(), RASTERCAPS); if ( bmpSrc.Ok() && (caps & RC_STRETCHDIB) ) { DIBSECTION ds; wxZeroMemory(ds); if ( ::GetObject(GetHbitmapOf(bmpSrc), sizeof(ds), &ds) == sizeof(ds) ) { StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR); // Figure out what co-ordinate system we're supposed to specify // ysrc in. const LONG hDIB = ds.dsBmih.biHeight; if ( hDIB > 0 ) { // reflect ysrc ysrc = hDIB - (ysrc + height); } if ( ::StretchDIBits(GetHdc(), xdest, ydest, width, height, xsrc, ysrc, width, height, ds.dsBm.bmBits, (LPBITMAPINFO)&ds.dsBmih, DIB_RGB_COLORS, dwRop ) == (int)GDI_ERROR ) { // On Win9x this API fails most (all?) of the time, so // logging it becomes quite distracting. Since it falls // back to the code below this is not really serious, so // don't log it. //wxLogLastError(wxT("StretchDIBits")); } else { success = true; } } } if ( !success && (caps & RC_STRETCHBLT) ) #endif // __WXWINCE__ { #ifndef __WXWINCE__ StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR); #endif if ( !::StretchBlt ( GetHdc(), xdest, ydest, width, height, GetHdcOf(*source), xsrc, ysrc, width, height, dwRop ) ) { wxLogLastError(_T("StretchBlt")); } else { success = true; } } if ( !success ) { if ( !::BitBlt ( GetHdc(), xdest, ydest, (int)width, (int)height, GetHdcOf(*source), xsrc, ysrc, dwRop ) ) { wxLogLastError(_T("BitBlt")); } else { success = true; } } } ::SetTextColor(GetHdc(), old_textground); ::SetBkColor(GetHdc(), old_background); return success; } void wxDC::GetDeviceSize(int *width, int *height) const { WXMICROWIN_CHECK_HDC if ( width ) *width = ::GetDeviceCaps(GetHdc(), HORZRES); if ( height ) *height = ::GetDeviceCaps(GetHdc(), VERTRES); } void wxDC::DoGetSizeMM(int *w, int *h) const { WXMICROWIN_CHECK_HDC // if we implement it in terms of DoGetSize() instead of directly using the // results returned by GetDeviceCaps(HORZ/VERTSIZE) as was done before, it // will also work for wxWindowDC and wxClientDC even though their size is // not the same as the total size of the screen int wPixels, hPixels; DoGetSize(&wPixels, &hPixels); if ( w ) { int wTotal = ::GetDeviceCaps(GetHdc(), HORZRES); wxCHECK_RET( wTotal, _T("0 width device?") ); *w = (wPixels * ::GetDeviceCaps(GetHdc(), HORZSIZE)) / wTotal; } if ( h ) { int hTotal = ::GetDeviceCaps(GetHdc(), VERTRES); wxCHECK_RET( hTotal, _T("0 height device?") ); *h = (hPixels * ::GetDeviceCaps(GetHdc(), VERTSIZE)) / hTotal; } } wxSize wxDC::GetPPI() const { WXMICROWIN_CHECK_HDC_RET(wxSize(0,0)) int x = ::GetDeviceCaps(GetHdc(), LOGPIXELSX); int y = ::GetDeviceCaps(GetHdc(), LOGPIXELSY); return wxSize(x, y); } // For use by wxWidgets only, unless custom units are required. void wxDC::SetLogicalScale(double x, double y) { WXMICROWIN_CHECK_HDC m_logicalScaleX = x; m_logicalScaleY = y; } // ---------------------------------------------------------------------------- // DC caching // ---------------------------------------------------------------------------- #if wxUSE_DC_CACHEING /* * This implementation is a bit ugly and uses the old-fashioned wxList class, so I will * improve it in due course, either using arrays, or simply storing pointers to one * entry for the bitmap, and two for the DCs. -- JACS */ wxList wxDC::sm_bitmapCache; wxList wxDC::sm_dcCache; wxDCCacheEntry::wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth) { m_bitmap = hBitmap; m_dc = 0; m_width = w; m_height = h; m_depth = depth; } wxDCCacheEntry::wxDCCacheEntry(WXHDC hDC, int depth) { m_bitmap = 0; m_dc = hDC; m_width = 0; m_height = 0; m_depth = depth; } wxDCCacheEntry::~wxDCCacheEntry() { if (m_bitmap) ::DeleteObject((HBITMAP) m_bitmap); if (m_dc) ::DeleteDC((HDC) m_dc); } wxDCCacheEntry* wxDC::FindBitmapInCache(WXHDC dc, int w, int h) { int depth = ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL); wxList::compatibility_iterator node = sm_bitmapCache.GetFirst(); while (node) { wxDCCacheEntry* entry = (wxDCCacheEntry*) node->GetData(); if (entry->m_depth == depth) { if (entry->m_width < w || entry->m_height < h) { ::DeleteObject((HBITMAP) entry->m_bitmap); entry->m_bitmap = (WXHBITMAP) ::CreateCompatibleBitmap((HDC) dc, w, h); if ( !entry->m_bitmap) { wxLogLastError(wxT("CreateCompatibleBitmap")); } entry->m_width = w; entry->m_height = h; return entry; } return entry; } node = node->GetNext(); } WXHBITMAP hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap((HDC) dc, w, h); if ( !hBitmap) { wxLogLastError(wxT("CreateCompatibleBitmap")); } wxDCCacheEntry* entry = new wxDCCacheEntry(hBitmap, w, h, depth); AddToBitmapCache(entry); return entry; } wxDCCacheEntry* wxDC::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc) { int depth = ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL); wxList::compatibility_iterator node = sm_dcCache.GetFirst(); while (node) { wxDCCacheEntry* entry = (wxDCCacheEntry*) node->GetData(); // Don't return the same one as we already have if (!notThis || (notThis != entry)) { if (entry->m_depth == depth) { return entry; } } node = node->GetNext(); } WXHDC hDC = (WXHDC) ::CreateCompatibleDC((HDC) dc); if ( !hDC) { wxLogLastError(wxT("CreateCompatibleDC")); } wxDCCacheEntry* entry = new wxDCCacheEntry(hDC, depth); AddToDCCache(entry); return entry; } void wxDC::AddToBitmapCache(wxDCCacheEntry* entry) { sm_bitmapCache.Append(entry); } void wxDC::AddToDCCache(wxDCCacheEntry* entry) { sm_dcCache.Append(entry); } void wxDC::ClearCache() { WX_CLEAR_LIST(wxList, sm_dcCache); WX_CLEAR_LIST(wxList, sm_bitmapCache); } // Clean up cache at app exit class wxDCModule : public wxModule { public: virtual bool OnInit() { return true; } virtual void OnExit() { wxDC::ClearCache(); } private: DECLARE_DYNAMIC_CLASS(wxDCModule) }; IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule) #endif // wxUSE_DC_CACHEING // ---------------------------------------------------------------------------- // alpha channel support // ---------------------------------------------------------------------------- static bool AlphaBlt(HDC hdcDst, int x, int y, int width, int height, int srcX, int srcY, HDC hdcSrc, const wxBitmap& bmp) { wxASSERT_MSG( bmp.Ok() && bmp.HasAlpha(), _T("AlphaBlt(): invalid bitmap") ); wxASSERT_MSG( hdcDst && hdcSrc, _T("AlphaBlt(): invalid HDC") ); // do we have AlphaBlend() and company in the headers? #if defined(AC_SRC_OVER) && wxUSE_DYNLIB_CLASS // yes, now try to see if we have it during run-time typedef BOOL (WINAPI *AlphaBlend_t)(HDC,int,int,int,int, HDC,int,int,int,int, BLENDFUNCTION); static AlphaBlend_t pfnAlphaBlend = (AlphaBlend_t)wxMSIMG32DLL.GetSymbol(_T("AlphaBlend")); if ( pfnAlphaBlend ) { BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.SourceConstantAlpha = 0xff; bf.AlphaFormat = AC_SRC_ALPHA; if ( pfnAlphaBlend(hdcDst, x, y, width, height, hdcSrc, srcX, srcY, width, height, bf) ) { // skip wxAlphaBlend() call below return true; } wxLogLastError(_T("AlphaBlend")); } #else wxUnusedVar(hdcSrc); #endif // defined(AC_SRC_OVER) // AlphaBlend() unavailable of failed: use our own (probably much slower) // implementation #ifdef wxHAVE_RAW_BITMAP wxAlphaBlend(hdcDst, x, y, width, height, srcX, srcY, bmp); return true; #else // !wxHAVE_RAW_BITMAP // no wxAlphaBlend() neither, fall back to using simple BitBlt() (we lose // alpha but at least something will be shown like this) wxUnusedVar(bmp); return false; #endif // wxHAVE_RAW_BITMAP } // wxAlphaBlend: our fallback if ::AlphaBlend() is unavailable #ifdef wxHAVE_RAW_BITMAP static void wxAlphaBlend(HDC hdcDst, int xDst, int yDst, int w, int h, int srcX, int srcY, const wxBitmap& bmpSrc) { // get the destination DC pixels wxBitmap bmpDst(w, h, 32 /* force creating RGBA DIB */); MemoryHDC hdcMem; SelectInHDC select(hdcMem, GetHbitmapOf(bmpDst)); if ( !::BitBlt(hdcMem, 0, 0, w, h, hdcDst, xDst, yDst, SRCCOPY) ) { wxLogLastError(_T("BitBlt")); } // combine them with the source bitmap using alpha wxAlphaPixelData dataDst(bmpDst), dataSrc((wxBitmap &)bmpSrc); wxCHECK_RET( dataDst && dataSrc, _T("failed to get raw data in wxAlphaBlend") ); wxAlphaPixelData::Iterator pDst(dataDst), pSrc(dataSrc); pSrc.Offset(dataSrc, srcX, srcY); for ( int y = 0; y < h; y++ ) { wxAlphaPixelData::Iterator pDstRowStart = pDst, pSrcRowStart = pSrc; for ( int x = 0; x < w; x++ ) { // note that source bitmap uses premultiplied alpha (as required by // the real AlphaBlend) const unsigned beta = 255 - pSrc.Alpha(); pDst.Red() = pSrc.Red() + (beta * pDst.Red() + 127) / 255; pDst.Blue() = pSrc.Blue() + (beta * pDst.Blue() + 127) / 255; pDst.Green() = pSrc.Green() + (beta * pDst.Green() + 127) / 255; ++pDst; ++pSrc; } pDst = pDstRowStart; pSrc = pSrcRowStart; pDst.OffsetY(dataDst, 1); pSrc.OffsetY(dataSrc, 1); } // and finally blit them back to the destination DC if ( !::BitBlt(hdcDst, xDst, yDst, w, h, hdcMem, 0, 0, SRCCOPY) ) { wxLogLastError(_T("BitBlt")); } } #endif // #ifdef wxHAVE_RAW_BITMAP void wxDC::DoGradientFillLinear (const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) { // use native function if we have compile-time support it and can load it // during run-time (linking to it statically would make the program // unusable on earlier Windows versions) #if defined(GRADIENT_FILL_RECT_H) && wxUSE_DYNLIB_CLASS typedef BOOL (WINAPI *GradientFill_t)(HDC, PTRIVERTEX, ULONG, PVOID, ULONG, ULONG); static GradientFill_t pfnGradientFill = (GradientFill_t)wxMSIMG32DLL.GetSymbol(_T("GradientFill")); if ( pfnGradientFill ) { GRADIENT_RECT grect; grect.UpperLeft = 0; grect.LowerRight = 1; // invert colours direction if not filling from left-to-right or // top-to-bottom int firstVertex = nDirection == wxNORTH || nDirection == wxWEST ? 1 : 0; // one vertex for upper left and one for upper-right TRIVERTEX vertices[2]; vertices[0].x = rect.GetLeft(); vertices[0].y = rect.GetTop(); vertices[1].x = rect.GetRight()+1; vertices[1].y = rect.GetBottom()+1; vertices[firstVertex].Red = (COLOR16)(initialColour.Red() << 8); vertices[firstVertex].Green = (COLOR16)(initialColour.Green() << 8); vertices[firstVertex].Blue = (COLOR16)(initialColour.Blue() << 8); vertices[firstVertex].Alpha = 0; vertices[1 - firstVertex].Red = (COLOR16)(destColour.Red() << 8); vertices[1 - firstVertex].Green = (COLOR16)(destColour.Green() << 8); vertices[1 - firstVertex].Blue = (COLOR16)(destColour.Blue() << 8); vertices[1 - firstVertex].Alpha = 0; if ( (*pfnGradientFill) ( GetHdc(), vertices, WXSIZEOF(vertices), &grect, 1, nDirection == wxWEST || nDirection == wxEAST ? GRADIENT_FILL_RECT_H : GRADIENT_FILL_RECT_V ) ) { // skip call of the base class version below return; } wxLogLastError(_T("GradientFill")); } #endif // wxUSE_DYNLIB_CLASS wxDCBase::DoGradientFillLinear(rect, initialColour, destColour, nDirection); } static DWORD wxGetDCLayout(HDC hdc) { typedef DWORD (WINAPI *GetLayout_t)(HDC); static GetLayout_t pfnGetLayout = (GetLayout_t)wxGDI32DLL.GetSymbol(_T("GetLayout")); return pfnGetLayout ? pfnGetLayout(hdc) : (DWORD)-1; } wxLayoutDirection wxDC::GetLayoutDirection() const { DWORD layout = wxGetDCLayout(GetHdc()); if ( layout == (DWORD)-1 ) return wxLayout_Default; return layout & LAYOUT_RTL ? wxLayout_RightToLeft : wxLayout_LeftToRight; } void wxDC::SetLayoutDirection(wxLayoutDirection dir) { typedef DWORD (WINAPI *SetLayout_t)(HDC, DWORD); static SetLayout_t pfnSetLayout = (SetLayout_t)wxGDI32DLL.GetSymbol(_T("SetLayout")); if ( !pfnSetLayout ) return; if ( dir == wxLayout_Default ) { dir = wxTheApp->GetLayoutDirection(); if ( dir == wxLayout_Default ) return; } DWORD layout = wxGetDCLayout(GetHdc()); if ( dir == wxLayout_RightToLeft ) layout |= LAYOUT_RTL; else layout &= ~LAYOUT_RTL; pfnSetLayout(GetHdc(), layout); }
[ "RD@c3d73ce0-8a6f-49c7-b76d-6d57e0e08775" ]
RD@c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
0b6d01df97bcbe20324867f820768d98715d3ce8
f95f90b67990775c4e985398ef033a06157a8dc0
/sprrentgenvatable.cpp
fa95c66a5ec3e037900fc022b7bdf4dbd9e780ee
[]
no_license
longway34/SeparatorQt2_Demo
f47dde468570d7f5977989681369f688696d53b9
05380fee5ddf33484f892854d2a3373553d66d80
refs/heads/master
2023-01-30T03:20:15.930640
2020-12-10T14:54:57
2020-12-10T14:54:57
319,998,795
0
0
null
null
null
null
UTF-8
C++
false
false
7,119
cpp
#include "sprrentgenvatable.h" #include <QHeaderView> #include <QSpinBox> /** * @brief SPRRentgenVATableDelegate::createEditor * @param parent * @param option * @param index * @return */ QWidget *SPRRentgenVATableDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { QSpinBox * lineEdit = new QSpinBox(parent); lineEdit->setRange(0, 255); lineEdit->setSingleStep(1); return lineEdit; } void SPRRentgenVATableDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QSpinBox *sb = qobject_cast<QSpinBox*>(editor); if(sb){ bool isOk; int value = index.model()->data(index).toInt(&isOk); if(isOk){ sb->setValue(value); } } } void SPRRentgenVATableDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QSpinBox *sb = qobject_cast<QSpinBox*>(editor); if(sb){ // QString txt = int val = sb->value(); model->setData(index, QVariant(val)); } } /** * @brief SPRRentgenVATableModel::columnCount * @param parent * @return */ int SPRRentgenVATableModel::columnCount(const QModelIndex &parent) const { if(rsModel){ return rsModel->getRentgens()->getData(); } } QVariant SPRRentgenVATableModel::data(const QModelIndex &index, int role) const { QVariant res; if(rsModel){ if(index.column() < rsModel->getRentgens()->getData()){ if(role == Qt::DisplayRole || role == Qt::EditRole){ if(index.row() == 0){ res = QVariant(QString::number(rsModel->iTubes[index.column()]->getData())); } else if(index.row() == 1){ res = QVariant(QString::number(rsModel->uTubes[index.column()]->getData())); } } if(role == Qt::ToolTipRole){ uint val = index.column() == 0 ? rsModel->iTubes[index.column()]->getData() : rsModel->uTubes[index.column()]->getData(); if(index.row() == 0){ QString tt = QString(tr("Величина устанавливаемого тока для трубки №%1 - %2мкА").arg(index.column()+1).arg(val)); res = QVariant(tt); } else if(index.row() == 1){ QString tt = QString(tr("Величина устанавливаемого напряжения для трубки №%1 - %2кВ").arg(index.column()+1).arg(val)); res = QVariant(tt); } } if(role == Qt::TextAlignmentRole){ res = QVariant(Qt::AlignCenter); } } } return res; } bool SPRRentgenVATableModel::setData(const QModelIndex &index, const QVariant &value, int role) { if(rsModel){ if(index.column() < rsModel->getRentgens()->getData()){ if(role == Qt::EditRole){ bool isOk = false; uint val = value.toInt(&isOk); if(index.row()== 0){ rsModel->iTubes[index.column()]->setData(val); } else if(index.row() == 1){ rsModel->uTubes[index.column()]->setData(val); } return isOk; } } } return QAbstractItemModel::setData(index, value, role); } QVariant SPRRentgenVATableModel::headerData(int section, Qt::Orientation orientation, int role) const { QVariant res = QAbstractItemModel::headerData(section, orientation, role); if(rsModel){ if(role == Qt::DisplayRole || role == Qt::EditRole){ if(orientation == Qt::Horizontal){ QString tt = QString(tr("Трубка №%1")).arg(section + 1); res = QVariant(tt); } else if(orientation == Qt::Vertical){ QString tt = section == 0 ? QString(tr("I (мкА)")) : QString(tr("U (кВ)")); res = QVariant(tt); } } if(role == Qt::TextAlignmentRole){ if(orientation == Qt::Horizontal){ res = QVariant(Qt::AlignCenter); } else { res = QVariant(Qt::AlignLeft); } } } return res; } Qt::ItemFlags SPRRentgenVATableModel::flags(const QModelIndex &index) const { return Qt::ItemIsEditable | QAbstractTableModel::flags(index); } void SPRRentgenVATableModel::setModelData(SPRSettingsRentgenModel *_rsModel){ if(_rsModel && _rsModel != rsModel){ connect(_rsModel, &IModelVariable::modelChanget, this, &SPRRentgenVATableModel::onModelChanget); } rsModel = _rsModel; } void SPRRentgenVATableModel::onModelChanget(IModelVariable *var){ if(sender() == rsModel || var == rsModel){ // beginResetModel(); // endResetModel(); emit dataChanged(this->index(0,0), this->index(rowCount(QModelIndex())-1,columnCount(QModelIndex())-1)); } } SPRRentgenVATable::SPRRentgenVATable(QWidget *parent): QTableView(parent), rsModel(nullptr), tableModel(nullptr), tableDelegate(nullptr) { } void SPRRentgenVATable::widgetsShow() { if(rsModel){ tableModel->onModelChanget(rsModel); // resizeColumnsToContents(); // resizeRowsToContents(); // updateGeometry(); } } ISPRModelData *SPRRentgenVATable::setModelData(ISPRModelData *data) { if(data){ if(rsModel){ delete rsModel; } rsModel = (SPRSettingsRentgenModel*)data; if(rsModel){ connect(rsModel, SIGNAL(modelChanget(IModelVariable*)), this, SLOT(onModelChanget(IModelVariable*))); } tableModel = new SPRRentgenVATableModel(this); tableModel->setModelData(rsModel); this->setModel(tableModel); tableDelegate = new SPRRentgenVATableDelegate(this); this->setItemDelegate(tableDelegate); } // onModelChanget(model); widgetsShow(); return rsModel; } ISPRModelData *SPRRentgenVATable::getModelData() { return rsModel; } void SPRRentgenVATable::onModelChanget(IModelVariable *) { if(sender() == rsModel){ // widgetsShow(); } } QSize SPRRentgenVATable::sizeHint() const { QHeaderView *hhor = horizontalHeader(); QHeaderView *hver = verticalHeader(); QRect rect = geometry(); QAbstractItemModel *mod = model(); if(mod){ int row = mod->rowCount(); int col = mod->columnCount(); int w = !hver->isHidden() ? hver->width()+2*lineWidth() : lineWidth(); int h = !hhor->isHidden() ? hhor->height()+2*lineWidth() : lineWidth(); for(int c=0; c<col; c++){ if(!isColumnHidden(c)) w += hhor->sectionSize(c) + lineWidth(); } for(int r=0; r< row; r++){ if(!isRowHidden(r)) h += hver->sectionSize(r) + lineWidth(); } rect.setWidth(w); rect.setHeight(h); } // setGeometry(rect); // view->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); // view->updateGeometry(); return rect.size(); }
[ "33542510+longway34@users.noreply.github.com" ]
33542510+longway34@users.noreply.github.com
ab94a6f902db366d28b411170a27a5106aa968b9
23ac686521127c7ef191abf2e33bb5b2cc6bac55
/source/framework/model/loader/ModelLoader.h
9debf889c9bb635c8291808ab7aa4921aa63eb10
[]
no_license
cauchywei/Shiba
ef181b92fc9501d0735896211029cfcaa19071f2
e1800203c9f3b53d681a8e25f0c51a7187f78953
refs/heads/master
2021-01-19T12:48:06.018791
2017-09-01T19:35:33
2017-09-01T19:35:33
100,811,619
1
0
null
null
null
null
UTF-8
C++
false
false
4,847
h
// // Created by cauchywei on 2017/8/20. // #ifndef SHIBA_MODELLOADER_H #define SHIBA_MODELLOADER_H #define TINYOBJLOADER_IMPLEMENTATION #include "../../../thirdpart/tiny_obj_loader.h" #include "../Model.h" #include <fstream> #include <iostream> #include <memory> namespace shiba { namespace framework { namespace model { void extractVertex2Vec3(size_t offset, Vector3 &vertex, int verIndex, std::vector<tinyobj::index_t> &meshIndices, std::vector<tinyobj::real_t> &vertices); Model *load(char *name, char *path) { tinyobj::attrib_t attrib; std::vector<tinyobj::shape_t> shapes; std::vector<tinyobj::material_t> materials; std::string err; bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, path); if (!err.empty()) { // `err` may contain warning message. std::cerr << err << std::endl; return nullptr; } if (!ret) { return nullptr; } Model *model = new Model(name); auto vertexCount = attrib.vertices.size() / 3; for (int i = 0; i < vertexCount; ++i) { model->vertices.push_back({attrib.vertices[i * 3], attrib.vertices[i * 3 + 1], attrib.vertices[i * 3 + 2]}); } // bool hasNormals = !attrib.normals.empty(); for (size_t s = 0; s < shapes.size(); s++) { // Loop over faces(polygon) size_t index_offset = 0; for (size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++) { int fv = shapes[s].mesh.num_face_vertices[f]; Vector3 normal(0, 0, 0); Vector3 current, next; std::vector<tinyobj::index_t> &meshIndices = shapes[s].mesh.indices; std::vector<tinyobj::real_t> &vertices = attrib.vertices; for (int verIndex = 0; verIndex < fv; ++verIndex) { extractVertex2Vec3(index_offset, current, verIndex, meshIndices, vertices); if (verIndex == fv - 1) { extractVertex2Vec3(index_offset, next, 0, meshIndices, vertices); } else { extractVertex2Vec3(index_offset, next, verIndex + 1, meshIndices, vertices); } normal.x += current.y * next.y - current.z * current.z; normal.y += current.z * next.z - current.x * current.x; normal.z += current.x * next.x - current.y * current.y; } model->normals.push_back(normal); // Loop over vertices in the face. for (size_t v = 0; v < fv; v++) { // access to vertex tinyobj::index_t idx = meshIndices[index_offset + v]; tinyobj::real_t vx = vertices[3 * idx.vertex_index + 0]; tinyobj::real_t vy = vertices[3 * idx.vertex_index + 1]; tinyobj::real_t vz = vertices[3 * idx.vertex_index + 2]; tinyobj::real_t nx, ny, nz, tx, ty; // tx = attrib.texcoords[2 * idx.texcoord_index + 0]; // ty = attrib.texcoords[2 * idx.texcoord_index + 1]; // model->vertices.push_back({vx, vy, vz}); model->textures.push_back({tx, ty, 0}); model->indices.push_back((uint32_t) idx.vertex_index); } index_offset += fv; // per-face material // shapes[s].mesh.material_ids[f]; } } return model; } void extractVertex2Vec3(size_t offset, Vector3 &vertex, int verIndex, std::vector<tinyobj::index_t> &meshIndices, std::vector<tinyobj::real_t> &vertices) { tinyobj::index_t idx = meshIndices[offset + verIndex]; vertex.x = vertices[3 * idx.vertex_index + 0]; vertex.y = vertices[3 * idx.vertex_index + 1]; vertex.z = vertices[3 * idx.vertex_index + 2]; } } } } #endif //SHIBA_MODELLOADER_H
[ "cauchywei@gmail.com" ]
cauchywei@gmail.com
0aba9552f7c50afccbcc277a617ae2b0b8353e26
4f76464ab556ee36e00881f661bbfdee98d69add
/projects/engine/nex/mesh/MeshGroup.hpp
637230b51932ff4d15516344d7d2919743b749fc
[]
no_license
Neconspictor/Euclid
5406c25cf0089d0c11c319349ae4b7a7a437774c
3a144723d1e79b9670336ec66cbdee875d97a1d6
refs/heads/master
2022-04-14T17:48:23.527977
2020-04-01T14:47:18
2020-04-01T15:14:06
251,591,695
2
0
null
null
null
null
UTF-8
C++
false
false
3,057
hpp
#pragma once #include <nex/mesh/Mesh.hpp> #include <nex/material/Material.hpp> #include <unordered_map> #include <memory> #include <nex/mesh/MeshStore.hpp> namespace nex { class AbstractMaterialLoader; class SceneNode; class Scene; class Material; class Shader; /** * A batch of meshes having the same render state and shader */ class MeshBatch { public: using Entry = std::pair<Mesh*, Material*>; /** * A comparator class for mesh/material entries. * Can be used for sorting mesh and materials and thus creating batches. */ struct EntryComparator { bool operator()(const Entry& a, const Entry& b) const; }; /** * Comparator for materials. Materials are said to be equal if they use the same shader * and have the same render state. Other data is not considered. */ struct MaterialComparator { bool operator()(const Material* a, const Material* b) const; }; MeshBatch(Material* referenceMaterial = nullptr); MeshBatch(const MeshBatch&) = default; MeshBatch(MeshBatch&&) = default; ~MeshBatch(); void add(Mesh* mesh, Material* material); void calcBoundingBox(); const AABB& getBoundingBox() const; const std::vector<Entry>& getEntries() const; Material* getReferenceMaterial(); const Material* getReferenceMaterial() const; Shader* getShader() const; const RenderState& getState() const; void setReferenceMaterial(Material* referenceMaterial); private: std::vector<Entry> mMeshes; Material* mMaterial; AABB mBoundingBox; }; class MeshGroup : public nex::Resource { public: using Meshes = std::vector<std::unique_ptr<Mesh>>; using Materials = std::vector<std::unique_ptr<Material>>; using Mappings = std::unordered_map<Mesh*, Material*>; MeshGroup() = default; virtual ~MeshGroup(); void finalize() override; void init(const std::vector<MeshStore>& stores, const nex::AbstractMaterialLoader& materialLoader); void add(std::unique_ptr<Mesh> mesh, std::unique_ptr<Material> material); void add(std::unique_ptr<Mesh> mesh); void addMaterial(std::unique_ptr<Material> material); void addMapping(Mesh* mesh, Material* material); const Mappings& getMappings() const; const Materials& getMaterials() const; const Meshes& getEntries() const; std::vector<MeshBatch>* getBatches(); const std::vector<MeshBatch>* getBatches() const; void calcBatches(); /** * Merges meshes with same material. */ void merge(); protected: std::vector<Material*> collectMaterials() const; std::vector<Mesh*> collectMeshes(const Material* material) const; std::unique_ptr<Mesh> merge(const std::vector<Mesh*>& meshes, const Material* material, IndexElementType type); void removeMeshes(std::vector<Mesh*>& meshes); void translate(size_t offset, IndexElementType type, size_t count, void* data); /** * Batches meshes having equal shader and render state */ std::vector<MeshBatch> createBatches() const; Mappings mMappings; Materials mMaterials; Meshes mMeshes; std::vector<MeshBatch> mBatches; }; }
[ "goeth@fim.uni-passau.de" ]
goeth@fim.uni-passau.de
fdff82ba5e579bc5a52aff51f3586755eabc6efa
367d2670c75d385d122bca60b9f550ca5b3888c1
/gem5/src/dev/arm/energy_ctrl.cc
15c29fe51149447aaabbf181d7bd46b2481ac271
[ "BSD-3-Clause", "LicenseRef-scancode-proprietary-license", "LGPL-2.0-or-later", "MIT" ]
permissive
Anish-Saxena/aqua_rowhammer_mitigation
4f060037d50fb17707338a6edcaa0ac33c39d559
3fef5b6aa80c006a4bd6ed4bedd726016142a81c
refs/heads/main
2023-04-13T05:35:20.872581
2023-01-05T21:10:39
2023-01-05T21:10:39
519,395,072
4
3
Unlicense
2023-01-05T21:10:40
2022-07-30T02:03:02
C++
UTF-8
C++
false
false
9,201
cc
/* * Copyright (c) 2012-2014 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall * not be construed as granting a license to any other intellectual * property including but not limited to intellectual property relating * to a hardware implementation of the functionality of the software * licensed hereunder. You may use the software subject to the license * terms below provided that you ensure that this notice is replicated * unmodified and in its entirety in all distributions of the software, * modified or unmodified, in source code or in binary form. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer; * redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution; * neither the name of the copyright holders 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 "dev/arm/energy_ctrl.hh" #include "base/trace.hh" #include "debug/EnergyCtrl.hh" #include "mem/packet.hh" #include "mem/packet_access.hh" #include "params/EnergyCtrl.hh" #include "sim/dvfs_handler.hh" EnergyCtrl::EnergyCtrl(const Params *p) : BasicPioDevice(p, PIO_NUM_FIELDS * 4), // each field is 32 bit dvfsHandler(p->dvfs_handler), domainID(0), domainIDIndexToRead(0), perfLevelAck(0), perfLevelToRead(0), updateAckEvent([this]{ updatePLAck(); }, name()) { fatal_if(!p->dvfs_handler, "EnergyCtrl: Needs a DVFSHandler for a " "functioning system.\n"); } Tick EnergyCtrl::read(PacketPtr pkt) { assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); assert(pkt->getSize() == 4); Addr daddr = pkt->getAddr() - pioAddr; assert((daddr & 3) == 0); Registers reg = Registers(daddr / 4); if (!dvfsHandler->isEnabled()) { // NB: Zero is a good response if the handler is disabled pkt->setLE<uint32_t>(0); warn_once("EnergyCtrl: Disabled handler, ignoring read from reg %i\n", reg); DPRINTF(EnergyCtrl, "dvfs handler disabled, return 0 for read from "\ "reg %i\n", reg); pkt->makeAtomicResponse(); return pioDelay; } uint32_t result = 0; Tick period; double voltage; switch(reg) { case DVFS_HANDLER_STATUS: result = 1; DPRINTF(EnergyCtrl, "dvfs handler enabled\n"); break; case DVFS_NUM_DOMAINS: result = dvfsHandler->numDomains(); DPRINTF(EnergyCtrl, "reading number of domains %d\n", result); break; case DVFS_DOMAINID_AT_INDEX: result = dvfsHandler->domainID(domainIDIndexToRead); DPRINTF(EnergyCtrl, "reading domain id at index %d as %d\n", domainIDIndexToRead, result); break; case DVFS_HANDLER_TRANS_LATENCY: // Return transition latency in nanoseconds result = dvfsHandler->transLatency() / SimClock::Int::ns; DPRINTF(EnergyCtrl, "reading dvfs handler trans latency %d ns\n", result); break; case DOMAIN_ID: result = domainID; DPRINTF(EnergyCtrl, "reading domain id:%d\n", result); break; case PERF_LEVEL: result = dvfsHandler->perfLevel(domainID); DPRINTF(EnergyCtrl, "reading domain %d perf level: %d\n", domainID, result); break; case PERF_LEVEL_ACK: result = perfLevelAck; DPRINTF(EnergyCtrl, "reading ack:%d\n", result); // Signal is set for a single read only if (result == 1) perfLevelAck = 0; break; case NUM_OF_PERF_LEVELS: result = dvfsHandler->numPerfLevels(domainID); DPRINTF(EnergyCtrl, "reading num of perf level:%d\n", result); break; case FREQ_AT_PERF_LEVEL: period = dvfsHandler->clkPeriodAtPerfLevel(domainID, perfLevelToRead); result = ticksTokHz(period); DPRINTF(EnergyCtrl, "reading freq %d KHz at perf level: %d\n", result, perfLevelToRead); break; case VOLT_AT_PERF_LEVEL: voltage = dvfsHandler->voltageAtPerfLevel(domainID, perfLevelToRead); result = toMicroVolt(voltage); DPRINTF(EnergyCtrl, "reading voltage %d u-volt at perf level: %d\n", result, perfLevelToRead); break; default: panic("Tried to read EnergyCtrl at offset %#x / reg %i\n", daddr, reg); } pkt->setLE<uint32_t>(result); pkt->makeAtomicResponse(); return pioDelay; } Tick EnergyCtrl::write(PacketPtr pkt) { assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); assert(pkt->getSize() == 4); uint32_t data; data = pkt->getLE<uint32_t>(); Addr daddr = pkt->getAddr() - pioAddr; assert((daddr & 3) == 0); Registers reg = Registers(daddr / 4); if (!dvfsHandler->isEnabled()) { // Ignore writes to a disabled controller warn_once("EnergyCtrl: Disabled handler, ignoring write %u to "\ "reg %i\n", data, reg); DPRINTF(EnergyCtrl, "dvfs handler disabled, ignoring write %u to "\ "reg %i\n", data, reg); pkt->makeAtomicResponse(); return pioDelay; } switch(reg) { case DVFS_DOMAINID_AT_INDEX: domainIDIndexToRead = data; DPRINTF(EnergyCtrl, "writing domain id index:%d\n", domainIDIndexToRead); break; case DOMAIN_ID: // Extra check to ensure that a valid domain ID is being queried if (dvfsHandler->validDomainID(data)) { domainID = data; DPRINTF(EnergyCtrl, "writing domain id:%d\n", domainID); } else { DPRINTF(EnergyCtrl, "invalid domain id:%d\n", domainID); } break; case PERF_LEVEL: if (dvfsHandler->perfLevel(domainID, data)) { if (updateAckEvent.scheduled()) { // The OS driver is trying to change the perf level while // another change is in flight. This is fine, but only a // single acknowledgment will be sent. DPRINTF(EnergyCtrl, "descheduling previous pending ack "\ "event\n"); deschedule(updateAckEvent); } schedule(updateAckEvent, curTick() + dvfsHandler->transLatency()); DPRINTF(EnergyCtrl, "writing domain %d perf level: %d\n", domainID, data); } else { DPRINTF(EnergyCtrl, "invalid / ineffective perf level:%d for "\ "domain:%d\n", data, domainID); } break; case PERF_LEVEL_TO_READ: perfLevelToRead = data; DPRINTF(EnergyCtrl, "writing perf level to read opp at: %d\n", data); break; default: panic("Tried to write EnergyCtrl at offset %#x\n", daddr); break; } pkt->makeAtomicResponse(); return pioDelay; } void EnergyCtrl::serialize(CheckpointOut &cp) const { SERIALIZE_SCALAR(domainID); SERIALIZE_SCALAR(domainIDIndexToRead); SERIALIZE_SCALAR(perfLevelToRead); SERIALIZE_SCALAR(perfLevelAck); Tick next_event = updateAckEvent.scheduled() ? updateAckEvent.when() : 0; SERIALIZE_SCALAR(next_event); } void EnergyCtrl::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(domainID); UNSERIALIZE_SCALAR(domainIDIndexToRead); UNSERIALIZE_SCALAR(perfLevelToRead); UNSERIALIZE_SCALAR(perfLevelAck); Tick next_event = 0; UNSERIALIZE_SCALAR(next_event); // restore scheduled events if (next_event != 0) { schedule(updateAckEvent, next_event); } } EnergyCtrl * EnergyCtrlParams::create() { return new EnergyCtrl(this); } void EnergyCtrl::startup() { if (!dvfsHandler->isEnabled()) { warn("Existing EnergyCtrl, but no enabled DVFSHandler found.\n"); } } void EnergyCtrl::init() { BasicPioDevice::init(); }
[ "asaxena317@krishna-srv4.ece.gatech.edu" ]
asaxena317@krishna-srv4.ece.gatech.edu
c5350a28c3d1db242bcbb502479102aee42cad6d
1d6803e6a0de8c30da18a750ab294ea6c43e7f6a
/Other Languages/Javascript/Node/v8-master/test/cctest/compiler/test-run-machops.cc
2e2587d40f4c05b3ac391ce55e2f782edba3f4ba
[ "BSD-3-Clause", "bzip2-1.0.6" ]
permissive
zsc282797/Google_Track
a71ab859a7956dedf15af07d1fcc78fa3367f472
a71ac3f928225cf6a908578877c22a9855666b85
refs/heads/master
2020-12-25T16:53:30.760595
2016-12-18T03:26:08
2016-12-18T03:26:08
47,584,799
0
0
null
null
null
null
UTF-8
C++
false
false
179,029
cc
// Copyright 2014 the V8 project authors. All rights reserved. Use of this // source code is governed by a BSD-style license that can be found in the // LICENSE file. #include <cmath> #include <functional> #include <limits> #include "src/base/bits.h" #include "src/base/utils/random-number-generator.h" #include "src/codegen.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" #include "test/cctest/compiler/value-helper.h" using namespace v8::base; namespace v8 { namespace internal { namespace compiler { TEST(RunInt32Add) { RawMachineAssemblerTester<int32_t> m; Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); m.Return(add); CHECK_EQ(1, m.Call()); } TEST(RunWord32Ctz) { BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); if (!m.machine()->Word32Ctz().IsSupported()) { // We can only test the operator if it exists on the testing platform. return; } m.Return(m.AddNode(m.machine()->Word32Ctz().op(), m.Parameter(0))); CHECK_EQ(32, m.Call(uint32_t(0x00000000))); CHECK_EQ(31, m.Call(uint32_t(0x80000000))); CHECK_EQ(30, m.Call(uint32_t(0x40000000))); CHECK_EQ(29, m.Call(uint32_t(0x20000000))); CHECK_EQ(28, m.Call(uint32_t(0x10000000))); CHECK_EQ(27, m.Call(uint32_t(0xa8000000))); CHECK_EQ(26, m.Call(uint32_t(0xf4000000))); CHECK_EQ(25, m.Call(uint32_t(0x62000000))); CHECK_EQ(24, m.Call(uint32_t(0x91000000))); CHECK_EQ(23, m.Call(uint32_t(0xcd800000))); CHECK_EQ(22, m.Call(uint32_t(0x09400000))); CHECK_EQ(21, m.Call(uint32_t(0xaf200000))); CHECK_EQ(20, m.Call(uint32_t(0xac100000))); CHECK_EQ(19, m.Call(uint32_t(0xe0b80000))); CHECK_EQ(18, m.Call(uint32_t(0x9ce40000))); CHECK_EQ(17, m.Call(uint32_t(0xc7920000))); CHECK_EQ(16, m.Call(uint32_t(0xb8f10000))); CHECK_EQ(15, m.Call(uint32_t(0x3b9f8000))); CHECK_EQ(14, m.Call(uint32_t(0xdb4c4000))); CHECK_EQ(13, m.Call(uint32_t(0xe9a32000))); CHECK_EQ(12, m.Call(uint32_t(0xfca61000))); CHECK_EQ(11, m.Call(uint32_t(0x6c8a7800))); CHECK_EQ(10, m.Call(uint32_t(0x8ce5a400))); CHECK_EQ(9, m.Call(uint32_t(0xcb7d0200))); CHECK_EQ(8, m.Call(uint32_t(0xcb4dc100))); CHECK_EQ(7, m.Call(uint32_t(0xdfbec580))); CHECK_EQ(6, m.Call(uint32_t(0x27a9db40))); CHECK_EQ(5, m.Call(uint32_t(0xde3bcb20))); CHECK_EQ(4, m.Call(uint32_t(0xd7e8a610))); CHECK_EQ(3, m.Call(uint32_t(0x9afdbc88))); CHECK_EQ(2, m.Call(uint32_t(0x9afdbc84))); CHECK_EQ(1, m.Call(uint32_t(0x9afdbc82))); CHECK_EQ(0, m.Call(uint32_t(0x9afdbc81))); } TEST(RunWord32Clz) { BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); m.Return(m.Word32Clz(m.Parameter(0))); CHECK_EQ(0, m.Call(uint32_t(0x80001000))); CHECK_EQ(1, m.Call(uint32_t(0x40000500))); CHECK_EQ(2, m.Call(uint32_t(0x20000300))); CHECK_EQ(3, m.Call(uint32_t(0x10000003))); CHECK_EQ(4, m.Call(uint32_t(0x08050000))); CHECK_EQ(5, m.Call(uint32_t(0x04006000))); CHECK_EQ(6, m.Call(uint32_t(0x02000000))); CHECK_EQ(7, m.Call(uint32_t(0x010000a0))); CHECK_EQ(8, m.Call(uint32_t(0x00800c00))); CHECK_EQ(9, m.Call(uint32_t(0x00400000))); CHECK_EQ(10, m.Call(uint32_t(0x0020000d))); CHECK_EQ(11, m.Call(uint32_t(0x00100f00))); CHECK_EQ(12, m.Call(uint32_t(0x00080000))); CHECK_EQ(13, m.Call(uint32_t(0x00041000))); CHECK_EQ(14, m.Call(uint32_t(0x00020020))); CHECK_EQ(15, m.Call(uint32_t(0x00010300))); CHECK_EQ(16, m.Call(uint32_t(0x00008040))); CHECK_EQ(17, m.Call(uint32_t(0x00004005))); CHECK_EQ(18, m.Call(uint32_t(0x00002050))); CHECK_EQ(19, m.Call(uint32_t(0x00001700))); CHECK_EQ(20, m.Call(uint32_t(0x00000870))); CHECK_EQ(21, m.Call(uint32_t(0x00000405))); CHECK_EQ(22, m.Call(uint32_t(0x00000203))); CHECK_EQ(23, m.Call(uint32_t(0x00000101))); CHECK_EQ(24, m.Call(uint32_t(0x00000089))); CHECK_EQ(25, m.Call(uint32_t(0x00000041))); CHECK_EQ(26, m.Call(uint32_t(0x00000022))); CHECK_EQ(27, m.Call(uint32_t(0x00000013))); CHECK_EQ(28, m.Call(uint32_t(0x00000008))); CHECK_EQ(29, m.Call(uint32_t(0x00000004))); CHECK_EQ(30, m.Call(uint32_t(0x00000002))); CHECK_EQ(31, m.Call(uint32_t(0x00000001))); CHECK_EQ(32, m.Call(uint32_t(0x00000000))); } TEST(RunWord32Popcnt) { BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); if (!m.machine()->Word32Popcnt().IsSupported()) { // We can only test the operator if it exists on the testing platform. return; } m.Return(m.AddNode(m.machine()->Word32Popcnt().op(), m.Parameter(0))); CHECK_EQ(0, m.Call(uint32_t(0x00000000))); CHECK_EQ(1, m.Call(uint32_t(0x00000001))); CHECK_EQ(1, m.Call(uint32_t(0x80000000))); CHECK_EQ(32, m.Call(uint32_t(0xffffffff))); CHECK_EQ(6, m.Call(uint32_t(0x000dc100))); CHECK_EQ(9, m.Call(uint32_t(0xe00dc100))); CHECK_EQ(11, m.Call(uint32_t(0xe00dc103))); CHECK_EQ(9, m.Call(uint32_t(0x000dc107))); } #if V8_TARGET_ARCH_64_BIT TEST(RunWord64Clz) { BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint64()); m.Return(m.Word64Clz(m.Parameter(0))); CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000))); CHECK_EQ(1, m.Call(uint64_t(0x4000050000000000))); CHECK_EQ(2, m.Call(uint64_t(0x2000030000000000))); CHECK_EQ(3, m.Call(uint64_t(0x1000000300000000))); CHECK_EQ(4, m.Call(uint64_t(0x0805000000000000))); CHECK_EQ(5, m.Call(uint64_t(0x0400600000000000))); CHECK_EQ(6, m.Call(uint64_t(0x0200000000000000))); CHECK_EQ(7, m.Call(uint64_t(0x010000a000000000))); CHECK_EQ(8, m.Call(uint64_t(0x00800c0000000000))); CHECK_EQ(9, m.Call(uint64_t(0x0040000000000000))); CHECK_EQ(10, m.Call(uint64_t(0x0020000d00000000))); CHECK_EQ(11, m.Call(uint64_t(0x00100f0000000000))); CHECK_EQ(12, m.Call(uint64_t(0x0008000000000000))); CHECK_EQ(13, m.Call(uint64_t(0x0004100000000000))); CHECK_EQ(14, m.Call(uint64_t(0x0002002000000000))); CHECK_EQ(15, m.Call(uint64_t(0x0001030000000000))); CHECK_EQ(16, m.Call(uint64_t(0x0000804000000000))); CHECK_EQ(17, m.Call(uint64_t(0x0000400500000000))); CHECK_EQ(18, m.Call(uint64_t(0x0000205000000000))); CHECK_EQ(19, m.Call(uint64_t(0x0000170000000000))); CHECK_EQ(20, m.Call(uint64_t(0x0000087000000000))); CHECK_EQ(21, m.Call(uint64_t(0x0000040500000000))); CHECK_EQ(22, m.Call(uint64_t(0x0000020300000000))); CHECK_EQ(23, m.Call(uint64_t(0x0000010100000000))); CHECK_EQ(24, m.Call(uint64_t(0x0000008900000000))); CHECK_EQ(25, m.Call(uint64_t(0x0000004100000000))); CHECK_EQ(26, m.Call(uint64_t(0x0000002200000000))); CHECK_EQ(27, m.Call(uint64_t(0x0000001300000000))); CHECK_EQ(28, m.Call(uint64_t(0x0000000800000000))); CHECK_EQ(29, m.Call(uint64_t(0x0000000400000000))); CHECK_EQ(30, m.Call(uint64_t(0x0000000200000000))); CHECK_EQ(31, m.Call(uint64_t(0x0000000100000000))); CHECK_EQ(32, m.Call(uint64_t(0x0000000080001000))); CHECK_EQ(33, m.Call(uint64_t(0x0000000040000500))); CHECK_EQ(34, m.Call(uint64_t(0x0000000020000300))); CHECK_EQ(35, m.Call(uint64_t(0x0000000010000003))); CHECK_EQ(36, m.Call(uint64_t(0x0000000008050000))); CHECK_EQ(37, m.Call(uint64_t(0x0000000004006000))); CHECK_EQ(38, m.Call(uint64_t(0x0000000002000000))); CHECK_EQ(39, m.Call(uint64_t(0x00000000010000a0))); CHECK_EQ(40, m.Call(uint64_t(0x0000000000800c00))); CHECK_EQ(41, m.Call(uint64_t(0x0000000000400000))); CHECK_EQ(42, m.Call(uint64_t(0x000000000020000d))); CHECK_EQ(43, m.Call(uint64_t(0x0000000000100f00))); CHECK_EQ(44, m.Call(uint64_t(0x0000000000080000))); CHECK_EQ(45, m.Call(uint64_t(0x0000000000041000))); CHECK_EQ(46, m.Call(uint64_t(0x0000000000020020))); CHECK_EQ(47, m.Call(uint64_t(0x0000000000010300))); CHECK_EQ(48, m.Call(uint64_t(0x0000000000008040))); CHECK_EQ(49, m.Call(uint64_t(0x0000000000004005))); CHECK_EQ(50, m.Call(uint64_t(0x0000000000002050))); CHECK_EQ(51, m.Call(uint64_t(0x0000000000001700))); CHECK_EQ(52, m.Call(uint64_t(0x0000000000000870))); CHECK_EQ(53, m.Call(uint64_t(0x0000000000000405))); CHECK_EQ(54, m.Call(uint64_t(0x0000000000000203))); CHECK_EQ(55, m.Call(uint64_t(0x0000000000000101))); CHECK_EQ(56, m.Call(uint64_t(0x0000000000000089))); CHECK_EQ(57, m.Call(uint64_t(0x0000000000000041))); CHECK_EQ(58, m.Call(uint64_t(0x0000000000000022))); CHECK_EQ(59, m.Call(uint64_t(0x0000000000000013))); CHECK_EQ(60, m.Call(uint64_t(0x0000000000000008))); CHECK_EQ(61, m.Call(uint64_t(0x0000000000000004))); CHECK_EQ(62, m.Call(uint64_t(0x0000000000000002))); CHECK_EQ(63, m.Call(uint64_t(0x0000000000000001))); CHECK_EQ(64, m.Call(uint64_t(0x0000000000000000))); } TEST(RunWord64Ctz) { RawMachineAssemblerTester<int32_t> m(MachineType::Uint64()); if (!m.machine()->Word64Ctz().IsSupported()) { return; } m.Return(m.AddNode(m.machine()->Word64Ctz().op(), m.Parameter(0))); CHECK_EQ(64, m.Call(uint64_t(0x0000000000000000))); CHECK_EQ(63, m.Call(uint64_t(0x8000000000000000))); CHECK_EQ(62, m.Call(uint64_t(0x4000000000000000))); CHECK_EQ(61, m.Call(uint64_t(0x2000000000000000))); CHECK_EQ(60, m.Call(uint64_t(0x1000000000000000))); CHECK_EQ(59, m.Call(uint64_t(0xa800000000000000))); CHECK_EQ(58, m.Call(uint64_t(0xf400000000000000))); CHECK_EQ(57, m.Call(uint64_t(0x6200000000000000))); CHECK_EQ(56, m.Call(uint64_t(0x9100000000000000))); CHECK_EQ(55, m.Call(uint64_t(0xcd80000000000000))); CHECK_EQ(54, m.Call(uint64_t(0x0940000000000000))); CHECK_EQ(53, m.Call(uint64_t(0xaf20000000000000))); CHECK_EQ(52, m.Call(uint64_t(0xac10000000000000))); CHECK_EQ(51, m.Call(uint64_t(0xe0b8000000000000))); CHECK_EQ(50, m.Call(uint64_t(0x9ce4000000000000))); CHECK_EQ(49, m.Call(uint64_t(0xc792000000000000))); CHECK_EQ(48, m.Call(uint64_t(0xb8f1000000000000))); CHECK_EQ(47, m.Call(uint64_t(0x3b9f800000000000))); CHECK_EQ(46, m.Call(uint64_t(0xdb4c400000000000))); CHECK_EQ(45, m.Call(uint64_t(0xe9a3200000000000))); CHECK_EQ(44, m.Call(uint64_t(0xfca6100000000000))); CHECK_EQ(43, m.Call(uint64_t(0x6c8a780000000000))); CHECK_EQ(42, m.Call(uint64_t(0x8ce5a40000000000))); CHECK_EQ(41, m.Call(uint64_t(0xcb7d020000000000))); CHECK_EQ(40, m.Call(uint64_t(0xcb4dc10000000000))); CHECK_EQ(39, m.Call(uint64_t(0xdfbec58000000000))); CHECK_EQ(38, m.Call(uint64_t(0x27a9db4000000000))); CHECK_EQ(37, m.Call(uint64_t(0xde3bcb2000000000))); CHECK_EQ(36, m.Call(uint64_t(0xd7e8a61000000000))); CHECK_EQ(35, m.Call(uint64_t(0x9afdbc8800000000))); CHECK_EQ(34, m.Call(uint64_t(0x9afdbc8400000000))); CHECK_EQ(33, m.Call(uint64_t(0x9afdbc8200000000))); CHECK_EQ(32, m.Call(uint64_t(0x9afdbc8100000000))); CHECK_EQ(31, m.Call(uint64_t(0x0000000080000000))); CHECK_EQ(30, m.Call(uint64_t(0x0000000040000000))); CHECK_EQ(29, m.Call(uint64_t(0x0000000020000000))); CHECK_EQ(28, m.Call(uint64_t(0x0000000010000000))); CHECK_EQ(27, m.Call(uint64_t(0x00000000a8000000))); CHECK_EQ(26, m.Call(uint64_t(0x00000000f4000000))); CHECK_EQ(25, m.Call(uint64_t(0x0000000062000000))); CHECK_EQ(24, m.Call(uint64_t(0x0000000091000000))); CHECK_EQ(23, m.Call(uint64_t(0x00000000cd800000))); CHECK_EQ(22, m.Call(uint64_t(0x0000000009400000))); CHECK_EQ(21, m.Call(uint64_t(0x00000000af200000))); CHECK_EQ(20, m.Call(uint64_t(0x00000000ac100000))); CHECK_EQ(19, m.Call(uint64_t(0x00000000e0b80000))); CHECK_EQ(18, m.Call(uint64_t(0x000000009ce40000))); CHECK_EQ(17, m.Call(uint64_t(0x00000000c7920000))); CHECK_EQ(16, m.Call(uint64_t(0x00000000b8f10000))); CHECK_EQ(15, m.Call(uint64_t(0x000000003b9f8000))); CHECK_EQ(14, m.Call(uint64_t(0x00000000db4c4000))); CHECK_EQ(13, m.Call(uint64_t(0x00000000e9a32000))); CHECK_EQ(12, m.Call(uint64_t(0x00000000fca61000))); CHECK_EQ(11, m.Call(uint64_t(0x000000006c8a7800))); CHECK_EQ(10, m.Call(uint64_t(0x000000008ce5a400))); CHECK_EQ(9, m.Call(uint64_t(0x00000000cb7d0200))); CHECK_EQ(8, m.Call(uint64_t(0x00000000cb4dc100))); CHECK_EQ(7, m.Call(uint64_t(0x00000000dfbec580))); CHECK_EQ(6, m.Call(uint64_t(0x0000000027a9db40))); CHECK_EQ(5, m.Call(uint64_t(0x00000000de3bcb20))); CHECK_EQ(4, m.Call(uint64_t(0x00000000d7e8a610))); CHECK_EQ(3, m.Call(uint64_t(0x000000009afdbc88))); CHECK_EQ(2, m.Call(uint64_t(0x000000009afdbc84))); CHECK_EQ(1, m.Call(uint64_t(0x000000009afdbc82))); CHECK_EQ(0, m.Call(uint64_t(0x000000009afdbc81))); } TEST(RunWord64Popcnt) { BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint64()); if (!m.machine()->Word64Popcnt().IsSupported()) { return; } m.Return(m.AddNode(m.machine()->Word64Popcnt().op(), m.Parameter(0))); CHECK_EQ(0, m.Call(uint64_t(0x0000000000000000))); CHECK_EQ(1, m.Call(uint64_t(0x0000000000000001))); CHECK_EQ(1, m.Call(uint64_t(0x8000000000000000))); CHECK_EQ(64, m.Call(uint64_t(0xffffffffffffffff))); CHECK_EQ(12, m.Call(uint64_t(0x000dc100000dc100))); CHECK_EQ(18, m.Call(uint64_t(0xe00dc100e00dc100))); CHECK_EQ(22, m.Call(uint64_t(0xe00dc103e00dc103))); CHECK_EQ(18, m.Call(uint64_t(0x000dc107000dc107))); } #endif // V8_TARGET_ARCH_64_BIT static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) { switch (index) { case 0: return m->Parameter(0); case 1: return m->Parameter(1); case 2: return m->Int32Constant(0); case 3: return m->Int32Constant(1); case 4: return m->Int32Constant(-1); case 5: return m->Int32Constant(0xff); case 6: return m->Int32Constant(0x01234567); case 7: return m->Load(MachineType::Int32(), m->PointerConstant(NULL)); default: return NULL; } } TEST(CodeGenInt32Binop) { RawMachineAssemblerTester<void> m; const Operator* kOps[] = { m.machine()->Word32And(), m.machine()->Word32Or(), m.machine()->Word32Xor(), m.machine()->Word32Shl(), m.machine()->Word32Shr(), m.machine()->Word32Sar(), m.machine()->Word32Equal(), m.machine()->Int32Add(), m.machine()->Int32Sub(), m.machine()->Int32Mul(), m.machine()->Int32MulHigh(), m.machine()->Int32Div(), m.machine()->Uint32Div(), m.machine()->Int32Mod(), m.machine()->Uint32Mod(), m.machine()->Uint32MulHigh(), m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual()}; for (size_t i = 0; i < arraysize(kOps); ++i) { for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), MachineType::Int32()); Node* a = Int32Input(&m, j); Node* b = Int32Input(&m, k); m.Return(m.AddNode(kOps[i], a, b)); m.GenerateCode(); } } } } TEST(CodeGenNop) { RawMachineAssemblerTester<void> m; m.Return(m.Int32Constant(0)); m.GenerateCode(); } #if V8_TARGET_ARCH_64_BIT static Node* Int64Input(RawMachineAssemblerTester<int64_t>* m, int index) { switch (index) { case 0: return m->Parameter(0); case 1: return m->Parameter(1); case 2: return m->Int64Constant(0); case 3: return m->Int64Constant(1); case 4: return m->Int64Constant(-1); case 5: return m->Int64Constant(0xff); case 6: return m->Int64Constant(0x0123456789abcdefLL); case 7: return m->Load(MachineType::Int64(), m->PointerConstant(NULL)); default: return NULL; } } TEST(CodeGenInt64Binop) { RawMachineAssemblerTester<void> m; const Operator* kOps[] = { m.machine()->Word64And(), m.machine()->Word64Or(), m.machine()->Word64Xor(), m.machine()->Word64Shl(), m.machine()->Word64Shr(), m.machine()->Word64Sar(), m.machine()->Word64Equal(), m.machine()->Int64Add(), m.machine()->Int64Sub(), m.machine()->Int64Mul(), m.machine()->Int64Div(), m.machine()->Uint64Div(), m.machine()->Int64Mod(), m.machine()->Uint64Mod(), m.machine()->Int64LessThan(), m.machine()->Int64LessThanOrEqual(), m.machine()->Uint64LessThan(), m.machine()->Uint64LessThanOrEqual()}; for (size_t i = 0; i < arraysize(kOps); ++i) { for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { RawMachineAssemblerTester<int64_t> m(MachineType::Int64(), MachineType::Int64()); Node* a = Int64Input(&m, j); Node* b = Int64Input(&m, k); m.Return(m.AddNode(kOps[i], a, b)); m.GenerateCode(); } } } } // TODO(titzer): add tests that run 64-bit integer operations. #endif // V8_TARGET_ARCH_64_BIT TEST(RunGoto) { RawMachineAssemblerTester<int32_t> m; int constant = 99999; RawMachineLabel next; m.Goto(&next); m.Bind(&next); m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call()); } TEST(RunGotoMultiple) { RawMachineAssemblerTester<int32_t> m; int constant = 9999977; RawMachineLabel labels[10]; for (size_t i = 0; i < arraysize(labels); i++) { m.Goto(&labels[i]); m.Bind(&labels[i]); } m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call()); } TEST(RunBranch) { RawMachineAssemblerTester<int32_t> m; int constant = 999777; RawMachineLabel blocka, blockb; m.Branch(m.Int32Constant(0), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(0 - constant)); m.Bind(&blockb); m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call()); } TEST(RunDiamond2) { RawMachineAssemblerTester<int32_t> m; int constant = 995666; RawMachineLabel blocka, blockb, end; m.Branch(m.Int32Constant(0), &blocka, &blockb); m.Bind(&blocka); m.Goto(&end); m.Bind(&blockb); m.Goto(&end); m.Bind(&end); m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call()); } TEST(RunLoop) { RawMachineAssemblerTester<int32_t> m; int constant = 999555; RawMachineLabel header, body, exit; m.Goto(&header); m.Bind(&header); m.Branch(m.Int32Constant(0), &body, &exit); m.Bind(&body); m.Goto(&header); m.Bind(&exit); m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call()); } template <typename R> static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, MachineRepresentation rep, Node* true_node, Node* false_node) { RawMachineLabel blocka, blockb, end; m->Branch(cond_node, &blocka, &blockb); m->Bind(&blocka); m->Goto(&end); m->Bind(&blockb); m->Goto(&end); m->Bind(&end); Node* phi = m->Phi(rep, true_node, false_node); m->Return(phi); } TEST(RunDiamondPhiConst) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); int false_val = 0xFF666; int true_val = 0x00DDD; Node* true_node = m.Int32Constant(true_val); Node* false_node = m.Int32Constant(false_val); BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kWord32, true_node, false_node); CHECK_EQ(false_val, m.Call(0)); CHECK_EQ(true_val, m.Call(1)); } TEST(RunDiamondPhiNumber) { RawMachineAssemblerTester<Object*> m(MachineType::Int32()); double false_val = -11.1; double true_val = 200.1; Node* true_node = m.NumberConstant(true_val); Node* false_node = m.NumberConstant(false_val); BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kTagged, true_node, false_node); m.CheckNumber(false_val, m.Call(0)); m.CheckNumber(true_val, m.Call(1)); } TEST(RunDiamondPhiString) { RawMachineAssemblerTester<Object*> m(MachineType::Int32()); const char* false_val = "false"; const char* true_val = "true"; Node* true_node = m.StringConstant(true_val); Node* false_node = m.StringConstant(false_val); BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kTagged, true_node, false_node); m.CheckString(false_val, m.Call(0)); m.CheckString(true_val, m.Call(1)); } TEST(RunDiamondPhiParam) { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kWord32, m.Parameter(1), m.Parameter(2)); int32_t c1 = 0x260cb75a; int32_t c2 = 0xcd3e9c8b; int result = m.Call(0, c1, c2); CHECK_EQ(c2, result); result = m.Call(1, c1, c2); CHECK_EQ(c1, result); } TEST(RunLoopPhiConst) { RawMachineAssemblerTester<int32_t> m; int true_val = 0x44000; int false_val = 0x00888; Node* cond_node = m.Int32Constant(0); Node* true_node = m.Int32Constant(true_val); Node* false_node = m.Int32Constant(false_val); // x = false_val; while(false) { x = true_val; } return x; RawMachineLabel body, header, end; m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, true_node); m.Branch(cond_node, &body, &end); m.Bind(&body); m.Goto(&header); m.Bind(&end); m.Return(phi); CHECK_EQ(false_val, m.Call()); } TEST(RunLoopPhiParam) { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); RawMachineLabel blocka, blockb, end; m.Goto(&blocka); m.Bind(&blocka); Node* phi = m.Phi(MachineRepresentation::kWord32, m.Parameter(1), m.Parameter(2)); Node* cond = m.Phi(MachineRepresentation::kWord32, m.Parameter(0), m.Int32Constant(0)); m.Branch(cond, &blockb, &end); m.Bind(&blockb); m.Goto(&blocka); m.Bind(&end); m.Return(phi); int32_t c1 = 0xa81903b4; int32_t c2 = 0x5a1207da; int result = m.Call(0, c1, c2); CHECK_EQ(c1, result); result = m.Call(1, c1, c2); CHECK_EQ(c2, result); } TEST(RunLoopPhiInduction) { RawMachineAssemblerTester<int32_t> m; int false_val = 0x10777; // x = false_val; while(false) { x++; } return x; RawMachineLabel header, body, end; Node* false_node = m.Int32Constant(false_val); m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, false_node); m.Branch(m.Int32Constant(0), &body, &end); m.Bind(&body); Node* add = m.Int32Add(phi, m.Int32Constant(1)); phi->ReplaceInput(1, add); m.Goto(&header); m.Bind(&end); m.Return(phi); CHECK_EQ(false_val, m.Call()); } TEST(RunLoopIncrement) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); // x = 0; while(x ^ param) { x++; } return x; RawMachineLabel header, body, end; Node* zero = m.Int32Constant(0); m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Branch(m.WordXor(phi, bt.param0), &body, &end); m.Bind(&body); phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); m.Goto(&header); m.Bind(&end); bt.AddReturn(phi); CHECK_EQ(11, bt.call(11, 0)); CHECK_EQ(110, bt.call(110, 0)); CHECK_EQ(176, bt.call(176, 0)); } TEST(RunLoopIncrement2) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); // x = 0; while(x < param) { x++; } return x; RawMachineLabel header, body, end; Node* zero = m.Int32Constant(0); m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Branch(m.Int32LessThan(phi, bt.param0), &body, &end); m.Bind(&body); phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); m.Goto(&header); m.Bind(&end); bt.AddReturn(phi); CHECK_EQ(11, bt.call(11, 0)); CHECK_EQ(110, bt.call(110, 0)); CHECK_EQ(176, bt.call(176, 0)); CHECK_EQ(0, bt.call(-200, 0)); } TEST(RunLoopIncrement3) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); // x = 0; while(x < param) { x++; } return x; RawMachineLabel header, body, end; Node* zero = m.Int32Constant(0); m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Branch(m.Uint32LessThan(phi, bt.param0), &body, &end); m.Bind(&body); phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); m.Goto(&header); m.Bind(&end); bt.AddReturn(phi); CHECK_EQ(11, bt.call(11, 0)); CHECK_EQ(110, bt.call(110, 0)); CHECK_EQ(176, bt.call(176, 0)); CHECK_EQ(200, bt.call(200, 0)); } TEST(RunLoopDecrement) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); // x = param; while(x) { x--; } return x; RawMachineLabel header, body, end; m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kWord32, bt.param0, m.Int32Constant(0)); m.Branch(phi, &body, &end); m.Bind(&body); phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1))); m.Goto(&header); m.Bind(&end); bt.AddReturn(phi); CHECK_EQ(0, bt.call(11, 0)); CHECK_EQ(0, bt.call(110, 0)); CHECK_EQ(0, bt.call(197, 0)); } TEST(RunLoopIncrementFloat32) { RawMachineAssemblerTester<int32_t> m; // x = -3.0f; while(x < 10f) { x = x + 0.5f; } return (int) (double) x; RawMachineLabel header, body, end; Node* minus_3 = m.Float32Constant(-3.0f); Node* ten = m.Float32Constant(10.0f); m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kFloat32, minus_3, ten); m.Branch(m.Float32LessThan(phi, ten), &body, &end); m.Bind(&body); phi->ReplaceInput(1, m.Float32Add(phi, m.Float32Constant(0.5f))); m.Goto(&header); m.Bind(&end); m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(phi))); CHECK_EQ(10, m.Call()); } TEST(RunLoopIncrementFloat64) { RawMachineAssemblerTester<int32_t> m; // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x; RawMachineLabel header, body, end; Node* minus_3 = m.Float64Constant(-3.0); Node* ten = m.Float64Constant(10.0); m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kFloat64, minus_3, ten); m.Branch(m.Float64LessThan(phi, ten), &body, &end); m.Bind(&body); phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5))); m.Goto(&header); m.Bind(&end); m.Return(m.ChangeFloat64ToInt32(phi)); CHECK_EQ(10, m.Call()); } TEST(RunSwitch1) { RawMachineAssemblerTester<int32_t> m; int constant = 11223344; RawMachineLabel block0, block1, def, end; RawMachineLabel* case_labels[] = {&block0, &block1}; int32_t case_values[] = {0, 1}; m.Switch(m.Int32Constant(0), &def, case_values, case_labels, arraysize(case_labels)); m.Bind(&block0); m.Goto(&end); m.Bind(&block1); m.Goto(&end); m.Bind(&def); m.Goto(&end); m.Bind(&end); m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call()); } TEST(RunSwitch2) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); RawMachineLabel blocka, blockb, blockc; RawMachineLabel* case_labels[] = {&blocka, &blockb}; int32_t case_values[] = {std::numeric_limits<int32_t>::min(), std::numeric_limits<int32_t>::max()}; m.Switch(m.Parameter(0), &blockc, case_values, case_labels, arraysize(case_labels)); m.Bind(&blocka); m.Return(m.Int32Constant(-1)); m.Bind(&blockb); m.Return(m.Int32Constant(1)); m.Bind(&blockc); m.Return(m.Int32Constant(0)); CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::max())); CHECK_EQ(-1, m.Call(std::numeric_limits<int32_t>::min())); for (int i = -100; i < 100; i += 25) { CHECK_EQ(0, m.Call(i)); } } TEST(RunSwitch3) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); RawMachineLabel blocka, blockb, blockc; RawMachineLabel* case_labels[] = {&blocka, &blockb}; int32_t case_values[] = {std::numeric_limits<int32_t>::min() + 0, std::numeric_limits<int32_t>::min() + 1}; m.Switch(m.Parameter(0), &blockc, case_values, case_labels, arraysize(case_labels)); m.Bind(&blocka); m.Return(m.Int32Constant(0)); m.Bind(&blockb); m.Return(m.Int32Constant(1)); m.Bind(&blockc); m.Return(m.Int32Constant(2)); CHECK_EQ(0, m.Call(std::numeric_limits<int32_t>::min() + 0)); CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::min() + 1)); for (int i = -100; i < 100; i += 25) { CHECK_EQ(2, m.Call(i)); } } TEST(RunSwitch4) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); const size_t kNumCases = 512; const size_t kNumValues = kNumCases + 1; int32_t values[kNumValues]; m.main_isolate()->random_number_generator()->NextBytes(values, sizeof(values)); RawMachineLabel end, def; int32_t case_values[kNumCases]; RawMachineLabel* case_labels[kNumCases]; Node* results[kNumValues]; for (size_t i = 0; i < kNumCases; ++i) { case_values[i] = static_cast<int32_t>(i); case_labels[i] = new (m.main_zone()->New(sizeof(RawMachineLabel))) RawMachineLabel; } m.Switch(m.Parameter(0), &def, case_values, case_labels, arraysize(case_labels)); for (size_t i = 0; i < kNumCases; ++i) { m.Bind(case_labels[i]); results[i] = m.Int32Constant(values[i]); m.Goto(&end); } m.Bind(&def); results[kNumCases] = m.Int32Constant(values[kNumCases]); m.Goto(&end); m.Bind(&end); const int num_results = static_cast<int>(arraysize(results)); Node* phi = m.AddNode(m.common()->Phi(MachineRepresentation::kWord32, num_results), num_results, results); m.Return(phi); for (size_t i = 0; i < kNumValues; ++i) { CHECK_EQ(values[i], m.Call(static_cast<int>(i))); } } TEST(RunLoadInt32) { RawMachineAssemblerTester<int32_t> m; int32_t p1 = 0; // loads directly from this location. m.Return(m.LoadFromPointer(&p1, MachineType::Int32())); FOR_INT32_INPUTS(i) { p1 = *i; CHECK_EQ(p1, m.Call()); } } TEST(RunLoadInt32Offset) { int32_t p1 = 0; // loads directly from this location. int32_t offsets[] = {-2000000, -100, -101, 1, 3, 7, 120, 2000, 2000000000, 0xff}; for (size_t i = 0; i < arraysize(offsets); i++) { RawMachineAssemblerTester<int32_t> m; int32_t offset = offsets[i]; byte* pointer = reinterpret_cast<byte*>(&p1) - offset; // generate load [#base + #index] m.Return(m.LoadFromPointer(pointer, MachineType::Int32(), offset)); FOR_INT32_INPUTS(j) { p1 = *j; CHECK_EQ(p1, m.Call()); } } } TEST(RunLoadStoreFloat32Offset) { float p1 = 0.0f; // loads directly from this location. float p2 = 0.0f; // and stores directly into this location. FOR_INT32_INPUTS(i) { int32_t magic = 0x2342aabb + *i * 3; RawMachineAssemblerTester<int32_t> m; int32_t offset = *i; byte* from = reinterpret_cast<byte*>(&p1) - offset; byte* to = reinterpret_cast<byte*>(&p2) - offset; // generate load [#base + #index] Node* load = m.Load(MachineType::Float32(), m.PointerConstant(from), m.IntPtrConstant(offset)); m.Store(MachineRepresentation::kFloat32, m.PointerConstant(to), m.IntPtrConstant(offset), load, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); FOR_FLOAT32_INPUTS(j) { p1 = *j; p2 = *j - 5; CHECK_EQ(magic, m.Call()); CheckDoubleEq(p1, p2); } } } TEST(RunLoadStoreFloat64Offset) { double p1 = 0; // loads directly from this location. double p2 = 0; // and stores directly into this location. FOR_INT32_INPUTS(i) { int32_t magic = 0x2342aabb + *i * 3; RawMachineAssemblerTester<int32_t> m; int32_t offset = *i; byte* from = reinterpret_cast<byte*>(&p1) - offset; byte* to = reinterpret_cast<byte*>(&p2) - offset; // generate load [#base + #index] Node* load = m.Load(MachineType::Float64(), m.PointerConstant(from), m.IntPtrConstant(offset)); m.Store(MachineRepresentation::kFloat64, m.PointerConstant(to), m.IntPtrConstant(offset), load, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); FOR_FLOAT64_INPUTS(j) { p1 = *j; p2 = *j - 5; CHECK_EQ(magic, m.Call()); CheckDoubleEq(p1, p2); } } } TEST(RunInt32AddP) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Int32Add(bt.param0, bt.param1)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { // Use uint32_t because signed overflow is UB in C. int expected = static_cast<int32_t>(*i + *j); CHECK_EQ(expected, bt.call(*i, *j)); } } } TEST(RunInt32AddAndWord32EqualP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32Equal(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t const expected = bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j == *k)); CHECK_EQ(expected, m.Call(*i, *j, *k)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Word32Equal(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t const expected = bit_cast<int32_t>((*i == *j) + bit_cast<uint32_t>(*k)); CHECK_EQ(expected, m.Call(*i, *j, *k)); } } } } } TEST(RunInt32AddAndWord32EqualImm) { { FOR_INT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Int32Constant(*i), m.Word32Equal(m.Parameter(0), m.Parameter(1)))); FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t const expected = bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j == *k)); CHECK_EQ(expected, m.Call(*j, *k)); } } } } { FOR_INT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Word32Equal(m.Int32Constant(*i), m.Parameter(0)), m.Parameter(1))); FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t const expected = bit_cast<int32_t>((*i == *j) + bit_cast<uint32_t>(*k)); CHECK_EQ(expected, m.Call(*j, *k)); } } } } } TEST(RunInt32AddAndWord32NotEqualP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32NotEqual(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t const expected = bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j != *k)); CHECK_EQ(expected, m.Call(*i, *j, *k)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Word32NotEqual(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t const expected = bit_cast<int32_t>((*i != *j) + bit_cast<uint32_t>(*k)); CHECK_EQ(expected, m.Call(*i, *j, *k)); } } } } } TEST(RunInt32AddAndWord32NotEqualImm) { { FOR_INT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Int32Constant(*i), m.Word32NotEqual(m.Parameter(0), m.Parameter(1)))); FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t const expected = bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j != *k)); CHECK_EQ(expected, m.Call(*j, *k)); } } } } { FOR_INT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Word32NotEqual(m.Int32Constant(*i), m.Parameter(0)), m.Parameter(1))); FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t const expected = bit_cast<int32_t>((*i != *j) + bit_cast<uint32_t>(*k)); CHECK_EQ(expected, m.Call(*j, *k)); } } } } } TEST(RunInt32AddAndWord32SarP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { // Use uint32_t because signed overflow is UB in C. int32_t expected = *i + (*j >> shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i >> shift) + *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunInt32AddAndWord32ShlP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { // Use uint32_t because signed overflow is UB in C. int32_t expected = *i + (*j << shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i << shift) + *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunInt32AddAndWord32ShrP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { // Use uint32_t because signed overflow is UB in C. int32_t expected = *i + (*j >> shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i >> shift) + *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunInt32AddInBranch) { static const int32_t constant = 987654321; { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = (*i + *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; const Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: UNREACHABLE(); case IrOpcode::kWord32Sar: right = *j >> shift; break; case IrOpcode::kWord32Shl: right = *j << shift; break; case IrOpcode::kWord32Shr: right = static_cast<uint32_t>(*j) >> shift; break; } int32_t expected = ((*i + right) == 0) ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } } } TEST(RunInt32AddInComparison) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = (*i + *j) == 0; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Int32Add(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = (*i + *j) == 0; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i + *j) == 0; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = (*j + *i) == 0; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; const Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Word32Equal( m.Int32Add(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: UNREACHABLE(); case IrOpcode::kWord32Sar: right = *j >> shift; break; case IrOpcode::kWord32Shl: right = *j << shift; break; case IrOpcode::kWord32Shr: right = static_cast<uint32_t>(*j) >> shift; break; } int32_t expected = (*i + right) == 0; CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } } } TEST(RunInt32SubP) { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); m.Return(m.Int32Sub(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = static_cast<int32_t>(*i - *j); CHECK_EQ(expected, bt.call(*i, *j)); } } } TEST(RunInt32SubImm) { { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i - *j; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j - *i; CHECK_EQ(expected, m.Call(*j)); } } } } TEST(RunInt32SubAndWord32SarP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t expected = *i - (*j >> shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { int32_t expected = (*i >> shift) - *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunInt32SubAndWord32ShlP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t expected = *i - (*j << shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i << shift) - *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunInt32SubAndWord32ShrP) { { RawMachineAssemblerTester<uint32_t> m( MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { // Use uint32_t because signed overflow is UB in C. uint32_t expected = *i - (*j >> shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<uint32_t> m( MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { // Use uint32_t because signed overflow is UB in C. uint32_t expected = (*i >> shift) - *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunInt32SubInBranch) { static const int constant = 987654321; { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = (*i - *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i - *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; const Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: UNREACHABLE(); case IrOpcode::kWord32Sar: right = *j >> shift; break; case IrOpcode::kWord32Shl: right = *j << shift; break; case IrOpcode::kWord32Shr: right = static_cast<uint32_t>(*j) >> shift; break; } int32_t expected = ((*i - right) == 0) ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } } } TEST(RunInt32SubInComparison) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = (*i - *j) == 0; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Int32Sub(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = (*i - *j) == 0; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i - *j) == 0; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = (*j - *i) == 0; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; const Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Word32Equal( m.Int32Sub(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: UNREACHABLE(); case IrOpcode::kWord32Sar: right = *j >> shift; break; case IrOpcode::kWord32Shl: right = *j << shift; break; case IrOpcode::kWord32Shr: right = static_cast<uint32_t>(*j) >> shift; break; } int32_t expected = (*i - right) == 0; CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } } } TEST(RunInt32MulP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Int32Mul(bt.param0, bt.param1)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int expected = static_cast<int32_t>(*i * *j); CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Int32Mul(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i * *j; CHECK_EQ(expected, bt.call(*i, *j)); } } } } TEST(RunInt32MulHighP) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Int32MulHigh(bt.param0, bt.param1)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = static_cast<int32_t>( (static_cast<int64_t>(*i) * static_cast<int64_t>(*j)) >> 32); CHECK_EQ(expected, bt.call(*i, *j)); } } } TEST(RunInt32MulImm) { { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i * *j; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j * *i; CHECK_EQ(expected, m.Call(*j)); } } } } TEST(RunInt32MulAndInt32AddP) { { FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); int32_t p0 = *i; int32_t p1 = *j; m.Return(m.Int32Add(m.Int32Constant(p0), m.Int32Mul(m.Parameter(0), m.Int32Constant(p1)))); FOR_INT32_INPUTS(k) { int32_t p2 = *k; int expected = p0 + static_cast<int32_t>(p1 * p2); CHECK_EQ(expected, m.Call(p2)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return( m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { int32_t p0 = *i; int32_t p1 = *j; int32_t p2 = *k; int expected = p0 + static_cast<int32_t>(p1 * p2); CHECK_EQ(expected, m.Call(p0, p1, p2)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return( m.Int32Add(m.Int32Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { int32_t p0 = *i; int32_t p1 = *j; int32_t p2 = *k; int expected = static_cast<int32_t>(p0 * p1) + p2; CHECK_EQ(expected, m.Call(p0, p1, p2)); } } } } { FOR_INT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn( m.Int32Add(m.Int32Constant(*i), m.Int32Mul(bt.param0, bt.param1))); FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { int32_t p0 = *j; int32_t p1 = *k; int expected = *i + static_cast<int32_t>(p0 * p1); CHECK_EQ(expected, bt.call(p0, p1)); } } } } } TEST(RunInt32MulAndInt32SubP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Int32()); m.Return( m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { uint32_t p0 = *i; int32_t p1 = *j; int32_t p2 = *k; // Use uint32_t because signed overflow is UB in C. int expected = p0 - static_cast<uint32_t>(p1 * p2); CHECK_EQ(expected, m.Call(p0, p1, p2)); } } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn( m.Int32Sub(m.Int32Constant(*i), m.Int32Mul(bt.param0, bt.param1))); FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(k) { int32_t p0 = *j; int32_t p1 = *k; // Use uint32_t because signed overflow is UB in C. int expected = *i - static_cast<uint32_t>(p0 * p1); CHECK_EQ(expected, bt.call(p0, p1)); } } } } } TEST(RunUint32MulHighP) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Uint32MulHigh(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = bit_cast<int32_t>(static_cast<uint32_t>( (static_cast<uint64_t>(*i) * static_cast<uint64_t>(*j)) >> 32)); CHECK_EQ(expected, bt.call(bit_cast<int32_t>(*i), bit_cast<int32_t>(*j))); } } } TEST(RunInt32DivP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Int32Div(bt.param0, bt.param1)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int p0 = *i; int p1 = *j; if (p1 != 0 && (static_cast<uint32_t>(p0) != 0x80000000 || p1 != -1)) { int expected = static_cast<int32_t>(p0 / p1); CHECK_EQ(expected, bt.call(p0, p1)); } } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Int32Add(bt.param0, m.Int32Div(bt.param0, bt.param1))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int p0 = *i; int p1 = *j; if (p1 != 0 && (static_cast<uint32_t>(p0) != 0x80000000 || p1 != -1)) { int expected = static_cast<int32_t>(p0 + (p0 / p1)); CHECK_EQ(expected, bt.call(p0, p1)); } } } } } TEST(RunUint32DivP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Uint32Div(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t p0 = *i; uint32_t p1 = *j; if (p1 != 0) { int32_t expected = bit_cast<int32_t>(p0 / p1); CHECK_EQ(expected, bt.call(p0, p1)); } } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Int32Add(bt.param0, m.Uint32Div(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t p0 = *i; uint32_t p1 = *j; if (p1 != 0) { int32_t expected = bit_cast<int32_t>(p0 + (p0 / p1)); CHECK_EQ(expected, bt.call(p0, p1)); } } } } } TEST(RunInt32ModP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Int32Mod(bt.param0, bt.param1)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int p0 = *i; int p1 = *j; if (p1 != 0 && (static_cast<uint32_t>(p0) != 0x80000000 || p1 != -1)) { int expected = static_cast<int32_t>(p0 % p1); CHECK_EQ(expected, bt.call(p0, p1)); } } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Int32Add(bt.param0, m.Int32Mod(bt.param0, bt.param1))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int p0 = *i; int p1 = *j; if (p1 != 0 && (static_cast<uint32_t>(p0) != 0x80000000 || p1 != -1)) { int expected = static_cast<int32_t>(p0 + (p0 % p1)); CHECK_EQ(expected, bt.call(p0, p1)); } } } } } TEST(RunUint32ModP) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Uint32Mod(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t p0 = *i; uint32_t p1 = *j; if (p1 != 0) { uint32_t expected = static_cast<uint32_t>(p0 % p1); CHECK_EQ(expected, bt.call(p0, p1)); } } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Int32Add(bt.param0, m.Uint32Mod(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t p0 = *i; uint32_t p1 = *j; if (p1 != 0) { uint32_t expected = static_cast<uint32_t>(p0 + (p0 % p1)); CHECK_EQ(expected, bt.call(p0, p1)); } } } } } TEST(RunWord32AndP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Word32And(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = *i & *j; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Word32And(bt.param0, m.Word32Not(bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = *i & ~(*j); CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Word32And(m.Word32Not(bt.param0), bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = ~(*i) & *j; CHECK_EQ(expected, bt.call(*i, *j)); } } } } TEST(RunWord32AndAndWord32ShlP) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Shl(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i << (*j & 0x1f); CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Shl(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i << (0x1f & *j); CHECK_EQ(expected, bt.call(*i, *j)); } } } } TEST(RunWord32AndAndWord32ShrP) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Shr(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i >> (*j & 0x1f); CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Shr(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i >> (0x1f & *j); CHECK_EQ(expected, bt.call(*i, *j)); } } } } TEST(RunWord32AndAndWord32SarP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn( m.Word32Sar(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = *i >> (*j & 0x1f); CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn( m.Word32Sar(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = *i >> (0x1f & *j); CHECK_EQ(expected, bt.call(*i, *j)); } } } } TEST(RunWord32AndImm) { { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i & *j; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i & ~(*j); CHECK_EQ(expected, m.Call(*j)); } } } } TEST(RunWord32AndInBranch) { static const int constant = 987654321; { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; const Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: UNREACHABLE(); case IrOpcode::kWord32Sar: right = *j >> shift; break; case IrOpcode::kWord32Shl: right = *j << shift; break; case IrOpcode::kWord32Shr: right = static_cast<uint32_t>(*j) >> shift; break; } int32_t expected = ((*i & right) == 0) ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } } } TEST(RunWord32AndInComparison) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = (*i & *j) == 0; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Word32And(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = (*i & *j) == 0; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i & *j) == 0; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = (*j & *i) == 0; CHECK_EQ(expected, m.Call(*j)); } } } } TEST(RunWord32OrP) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Or(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i | *j; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Or(bt.param0, m.Word32Not(bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i | ~(*j); CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Or(m.Word32Not(bt.param0), bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = ~(*i) | *j; CHECK_EQ(expected, bt.call(*i, *j)); } } } } TEST(RunWord32OrImm) { { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i | *j; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i | ~(*j); CHECK_EQ(expected, m.Call(*j)); } } } } TEST(RunWord32OrInBranch) { static const int constant = 987654321; { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_INT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_INT32_INPUTS(j) { int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_INT32_INPUTS(i) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_INT32_INPUTS(j) { int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; const Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: UNREACHABLE(); case IrOpcode::kWord32Sar: right = *j >> shift; break; case IrOpcode::kWord32Shl: right = *j << shift; break; case IrOpcode::kWord32Shr: right = static_cast<uint32_t>(*j) >> shift; break; } int32_t expected = ((*i | right) == 0) ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } } } TEST(RunWord32OrInComparison) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = (*i | *j) == 0; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Word32Or(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = (*i | *j) == 0; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i | *j) == 0; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = (*j | *i) == 0; CHECK_EQ(expected, m.Call(*j)); } } } } TEST(RunWord32XorP) { { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i ^ *j; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Xor(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i ^ *j; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Word32Xor(bt.param0, m.Word32Not(bt.param1))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = *i ^ ~(*j); CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Word32Xor(m.Word32Not(bt.param0), bt.param1)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = ~(*i) ^ *j; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i ^ ~(*j); CHECK_EQ(expected, m.Call(*j)); } } } } TEST(RunWord32XorInBranch) { static const uint32_t constant = 987654321; { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32Equal(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; const Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: UNREACHABLE(); case IrOpcode::kWord32Sar: right = *j >> shift; break; case IrOpcode::kWord32Shl: right = *j << shift; break; case IrOpcode::kWord32Shr: right = static_cast<uint32_t>(*j) >> shift; break; } int32_t expected = ((*i ^ right) == 0) ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } } } TEST(RunWord32ShlP) { { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j << shift; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Shl(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = *i << shift; CHECK_EQ(expected, bt.call(*i, shift)); } } } } TEST(RunWord32ShlInComparison) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Word32Shl(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = 0 == (*i << shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Word32Shl(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = 0 == (*i << shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Int32Constant(0), m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)))); FOR_UINT32_INPUTS(i) { uint32_t expected = 0 == (*i << shift); CHECK_EQ(expected, m.Call(*i)); } } } { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { uint32_t expected = 0 == (*i << shift); CHECK_EQ(expected, m.Call(*i)); } } } } TEST(RunWord32ShrP) { { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j >> shift; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Shr(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = *i >> shift; CHECK_EQ(expected, bt.call(*i, shift)); } } CHECK_EQ(0x00010000u, bt.call(0x80000000, 15)); } } TEST(RunWord32ShrInComparison) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Word32Shr(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = 0 == (*i >> shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Word32Shr(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = 0 == (*i >> shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Int32Constant(0), m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); FOR_UINT32_INPUTS(i) { uint32_t expected = 0 == (*i >> shift); CHECK_EQ(expected, m.Call(*i)); } } } { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { uint32_t expected = 0 == (*i >> shift); CHECK_EQ(expected, m.Call(*i)); } } } } TEST(RunWord32SarP) { { FOR_INT32_SHIFTS(shift) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))); FOR_INT32_INPUTS(j) { int32_t expected = *j >> shift; CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Word32Sar(bt.param0, bt.param1)); FOR_INT32_INPUTS(i) { FOR_INT32_SHIFTS(shift) { int32_t expected = *i >> shift; CHECK_EQ(expected, bt.call(*i, shift)); } } CHECK_EQ(bit_cast<int32_t>(0xFFFF0000), bt.call(0x80000000, 15)); } } TEST(RunWord32SarInComparison) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Word32Sar(bt.param0, bt.param1), m.Int32Constant(0))); FOR_INT32_INPUTS(i) { FOR_INT32_SHIFTS(shift) { int32_t expected = 0 == (*i >> shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Word32Sar(bt.param0, bt.param1))); FOR_INT32_INPUTS(i) { FOR_INT32_SHIFTS(shift) { int32_t expected = 0 == (*i >> shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } { FOR_INT32_SHIFTS(shift) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); m.Return( m.Word32Equal(m.Int32Constant(0), m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)))); FOR_INT32_INPUTS(i) { int32_t expected = 0 == (*i >> shift); CHECK_EQ(expected, m.Call(*i)); } } } { FOR_INT32_SHIFTS(shift) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); m.Return( m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(0))); FOR_INT32_INPUTS(i) { int32_t expected = 0 == (*i >> shift); CHECK_EQ(expected, m.Call(*i)); } } } } TEST(RunWord32RorP) { { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); m.Return(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift))); FOR_UINT32_INPUTS(j) { int32_t expected = bits::RotateRight32(*j, shift); CHECK_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Ror(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = bits::RotateRight32(*i, shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } } TEST(RunWord32RorInComparison) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Word32Ror(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = 0 == bits::RotateRight32(*i, shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Word32Ror(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { uint32_t expected = 0 == bits::RotateRight32(*i, shift); CHECK_EQ(expected, bt.call(*i, shift)); } } } { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Int32Constant(0), m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)))); FOR_UINT32_INPUTS(i) { uint32_t expected = 0 == bits::RotateRight32(*i, shift); CHECK_EQ(expected, m.Call(*i)); } } } { FOR_UINT32_SHIFTS(shift) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { uint32_t expected = 0 == bits::RotateRight32(*i, shift); CHECK_EQ(expected, m.Call(*i)); } } } } TEST(RunWord32NotP) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); m.Return(m.Word32Not(m.Parameter(0))); FOR_INT32_INPUTS(i) { int expected = ~(*i); CHECK_EQ(expected, m.Call(*i)); } } TEST(RunInt32NegP) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); m.Return(m.Int32Neg(m.Parameter(0))); FOR_INT32_INPUTS(i) { int expected = -*i; CHECK_EQ(expected, m.Call(*i)); } } TEST(RunWord32EqualAndWord32SarP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t expected = (*i == (*j >> shift)); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Int32(), MachineType::Uint32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_INT32_INPUTS(k) { int32_t expected = ((*i >> shift) == *k); CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunWord32EqualAndWord32ShlP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t expected = (*i == (*j << shift)); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { int32_t expected = ((*i << shift) == *k); CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunWord32EqualAndWord32ShrP) { { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { FOR_UINT32_SHIFTS(shift) { int32_t expected = (*i == (*j >> shift)); CHECK_EQ(expected, m.Call(*i, *j, shift)); } } } } { RawMachineAssemblerTester<int32_t> m( MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { int32_t expected = ((*i >> shift) == *k); CHECK_EQ(expected, m.Call(*i, shift, *k)); } } } } } TEST(RunDeadNodes) { for (int i = 0; true; i++) { RawMachineAssemblerTester<int32_t> m(i == 5 ? MachineType::Int32() : MachineType::None()); int constant = 0x55 + i; switch (i) { case 0: m.Int32Constant(44); break; case 1: m.StringConstant("unused"); break; case 2: m.NumberConstant(11.1); break; case 3: m.PointerConstant(&constant); break; case 4: m.LoadFromPointer(&constant, MachineType::Int32()); break; case 5: m.Parameter(0); break; default: return; } m.Return(m.Int32Constant(constant)); if (i != 5) { CHECK_EQ(constant, m.Call()); } else { CHECK_EQ(constant, m.Call(0)); } } } TEST(RunDeadInt32Binops) { RawMachineAssemblerTester<int32_t> m; const Operator* kOps[] = { m.machine()->Word32And(), m.machine()->Word32Or(), m.machine()->Word32Xor(), m.machine()->Word32Shl(), m.machine()->Word32Shr(), m.machine()->Word32Sar(), m.machine()->Word32Ror(), m.machine()->Word32Equal(), m.machine()->Int32Add(), m.machine()->Int32Sub(), m.machine()->Int32Mul(), m.machine()->Int32MulHigh(), m.machine()->Int32Div(), m.machine()->Uint32Div(), m.machine()->Int32Mod(), m.machine()->Uint32Mod(), m.machine()->Uint32MulHigh(), m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual()}; for (size_t i = 0; i < arraysize(kOps); ++i) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), MachineType::Int32()); int32_t constant = static_cast<int32_t>(0x55555 + i); m.AddNode(kOps[i], m.Parameter(0), m.Parameter(1)); m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call(1, 1)); } } template <typename Type> static void RunLoadImmIndex(MachineType rep) { const int kNumElems = 3; Type buffer[kNumElems]; // initialize the buffer with raw data. byte* raw = reinterpret_cast<byte*>(buffer); for (size_t i = 0; i < sizeof(buffer); i++) { raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); } // Test with various large and small offsets. for (int offset = -1; offset <= 200000; offset *= -5) { for (int i = 0; i < kNumElems; i++) { RawMachineAssemblerTester<Type> m; Node* base = m.PointerConstant(buffer - offset); Node* index = m.Int32Constant((offset + i) * sizeof(buffer[0])); m.Return(m.Load(rep, base, index)); Type expected = buffer[i]; Type actual = m.Call(); CHECK(expected == actual); } } } TEST(RunLoadImmIndex) { RunLoadImmIndex<int8_t>(MachineType::Int8()); RunLoadImmIndex<uint8_t>(MachineType::Uint8()); RunLoadImmIndex<int16_t>(MachineType::Int16()); RunLoadImmIndex<uint16_t>(MachineType::Uint16()); RunLoadImmIndex<int32_t>(MachineType::Int32()); RunLoadImmIndex<uint32_t>(MachineType::Uint32()); RunLoadImmIndex<int32_t*>(MachineType::AnyTagged()); // TODO(titzer): test kRepBit loads // TODO(titzer): test MachineType::Float64() loads // TODO(titzer): test various indexing modes. } template <typename CType> static void RunLoadStore(MachineType rep) { const int kNumElems = 4; CType buffer[kNumElems]; for (int32_t x = 0; x < kNumElems; x++) { int32_t y = kNumElems - x - 1; // initialize the buffer with raw data. byte* raw = reinterpret_cast<byte*>(buffer); for (size_t i = 0; i < sizeof(buffer); i++) { raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); } RawMachineAssemblerTester<int32_t> m; int32_t OK = 0x29000 + x; Node* base = m.PointerConstant(buffer); Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0])); Node* load = m.Load(rep, base, index0); Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0])); m.Store(rep.representation(), base, index1, load, kNoWriteBarrier); m.Return(m.Int32Constant(OK)); CHECK(buffer[x] != buffer[y]); CHECK_EQ(OK, m.Call()); CHECK(buffer[x] == buffer[y]); } } TEST(RunLoadStore) { RunLoadStore<int8_t>(MachineType::Int8()); RunLoadStore<uint8_t>(MachineType::Uint8()); RunLoadStore<int16_t>(MachineType::Int16()); RunLoadStore<uint16_t>(MachineType::Uint16()); RunLoadStore<int32_t>(MachineType::Int32()); RunLoadStore<uint32_t>(MachineType::Uint32()); RunLoadStore<void*>(MachineType::AnyTagged()); RunLoadStore<float>(MachineType::Float32()); RunLoadStore<double>(MachineType::Float64()); } TEST(RunFloat32Add) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), MachineType::Float32()); m.Return(m.Float32Add(m.Parameter(0), m.Parameter(1))); FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(j) { volatile float expected = *i + *j; CheckFloatEq(expected, m.Call(*i, *j)); } } } TEST(RunFloat32Sub) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), MachineType::Float32()); m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1))); FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(j) { volatile float expected = *i - *j; CheckFloatEq(expected, m.Call(*i, *j)); } } } TEST(RunFloat32Mul) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), MachineType::Float32()); m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1))); FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(j) { volatile float expected = *i * *j; CheckFloatEq(expected, m.Call(*i, *j)); } } } TEST(RunFloat32Div) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(), MachineType::Float32()); m.Return(m.Float32Div(m.Parameter(0), m.Parameter(1))); FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(j) { volatile float expected = *i / *j; CheckFloatEq(expected, m.Call(*i, *j)); } } } TEST(RunFloat64Add) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Add(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(*i + *j, m.Call(*i, *j)); } } } TEST(RunFloat64Sub) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(*i - *j, m.Call(*i, *j)); } } } TEST(RunFloat64Mul) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { volatile double expected = *i * *j; CheckDoubleEq(expected, m.Call(*i, *j)); } } } TEST(RunFloat64Div) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Div(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { volatile double expected = *i / *j; CheckDoubleEq(expected, m.Call(*i, *j)); } } } TEST(RunFloat64Mod) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Mod(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(modulo(*i, *j), m.Call(*i, *j)); } } } TEST(RunDeadFloat32Binops) { RawMachineAssemblerTester<int32_t> m; const Operator* ops[] = {m.machine()->Float32Add(), m.machine()->Float32Sub(), m.machine()->Float32Mul(), m.machine()->Float32Div(), NULL}; for (int i = 0; ops[i] != NULL; i++) { RawMachineAssemblerTester<int32_t> m; int constant = 0x53355 + i; m.AddNode(ops[i], m.Float32Constant(0.1f), m.Float32Constant(1.11f)); m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call()); } } TEST(RunDeadFloat64Binops) { RawMachineAssemblerTester<int32_t> m; const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), m.machine()->Float64Mul(), m.machine()->Float64Div(), m.machine()->Float64Mod(), NULL}; for (int i = 0; ops[i] != NULL; i++) { RawMachineAssemblerTester<int32_t> m; int constant = 0x53355 + i; m.AddNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11)); m.Return(m.Int32Constant(constant)); CHECK_EQ(constant, m.Call()); } } TEST(RunFloat32AddP) { RawMachineAssemblerTester<int32_t> m; Float32BinopTester bt(&m); bt.AddReturn(m.Float32Add(bt.param0, bt.param1)); FOR_FLOAT32_INPUTS(pl) { FOR_FLOAT32_INPUTS(pr) { float expected = *pl + *pr; CheckFloatEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat64AddP) { RawMachineAssemblerTester<int32_t> m; Float64BinopTester bt(&m); bt.AddReturn(m.Float64Add(bt.param0, bt.param1)); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { double expected = *pl + *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloa32MaxP) { RawMachineAssemblerTester<int32_t> m; Float32BinopTester bt(&m); if (!m.machine()->Float32Max().IsSupported()) return; bt.AddReturn(m.Float32Max(bt.param0, bt.param1)); FOR_FLOAT32_INPUTS(pl) { FOR_FLOAT32_INPUTS(pr) { double expected = *pl > *pr ? *pl : *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat64MaxP) { RawMachineAssemblerTester<int32_t> m; Float64BinopTester bt(&m); if (!m.machine()->Float64Max().IsSupported()) return; bt.AddReturn(m.Float64Max(bt.param0, bt.param1)); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { double expected = *pl > *pr ? *pl : *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat32MinP) { RawMachineAssemblerTester<int32_t> m; Float32BinopTester bt(&m); if (!m.machine()->Float32Min().IsSupported()) return; bt.AddReturn(m.Float32Min(bt.param0, bt.param1)); FOR_FLOAT32_INPUTS(pl) { FOR_FLOAT32_INPUTS(pr) { double expected = *pl < *pr ? *pl : *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat64MinP) { RawMachineAssemblerTester<int32_t> m; Float64BinopTester bt(&m); if (!m.machine()->Float64Min().IsSupported()) return; bt.AddReturn(m.Float64Min(bt.param0, bt.param1)); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { double expected = *pl < *pr ? *pl : *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat32SubP) { RawMachineAssemblerTester<int32_t> m; Float32BinopTester bt(&m); bt.AddReturn(m.Float32Sub(bt.param0, bt.param1)); FOR_FLOAT32_INPUTS(pl) { FOR_FLOAT32_INPUTS(pr) { float expected = *pl - *pr; CheckFloatEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat32SubImm1) { FOR_FLOAT32_INPUTS(i) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); m.Return(m.Float32Sub(m.Float32Constant(*i), m.Parameter(0))); FOR_FLOAT32_INPUTS(j) { volatile float expected = *i - *j; CheckFloatEq(expected, m.Call(*j)); } } } TEST(RunFloat32SubImm2) { FOR_FLOAT32_INPUTS(i) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); m.Return(m.Float32Sub(m.Parameter(0), m.Float32Constant(*i))); FOR_FLOAT32_INPUTS(j) { volatile float expected = *j - *i; CheckFloatEq(expected, m.Call(*j)); } } } TEST(RunFloat64SubImm1) { FOR_FLOAT64_INPUTS(i) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); m.Return(m.Float64Sub(m.Float64Constant(*i), m.Parameter(0))); FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i - *j, m.Call(*j)); } } } TEST(RunFloat64SubImm2) { FOR_FLOAT64_INPUTS(i) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); m.Return(m.Float64Sub(m.Parameter(0), m.Float64Constant(*i))); FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j - *i, m.Call(*j)); } } } TEST(RunFloat64SubP) { RawMachineAssemblerTester<int32_t> m; Float64BinopTester bt(&m); bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { double expected = *pl - *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat32MulP) { RawMachineAssemblerTester<int32_t> m; Float32BinopTester bt(&m); bt.AddReturn(m.Float32Mul(bt.param0, bt.param1)); FOR_FLOAT32_INPUTS(pl) { FOR_FLOAT32_INPUTS(pr) { float expected = *pl * *pr; CheckFloatEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat64MulP) { RawMachineAssemblerTester<int32_t> m; Float64BinopTester bt(&m); bt.AddReturn(m.Float64Mul(bt.param0, bt.param1)); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { double expected = *pl * *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat64MulAndFloat64Add1) { BufferedRawMachineAssemblerTester<double> m( MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Add(m.Float64Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { FOR_FLOAT64_INPUTS(k) { CheckDoubleEq((*i * *j) + *k, m.Call(*i, *j, *k)); } } } } TEST(RunFloat64MulAndFloat64Add2) { BufferedRawMachineAssemblerTester<double> m( MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Add(m.Parameter(0), m.Float64Mul(m.Parameter(1), m.Parameter(2)))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { FOR_FLOAT64_INPUTS(k) { CheckDoubleEq(*i + (*j * *k), m.Call(*i, *j, *k)); } } } } TEST(RunFloat64MulAndFloat64Sub1) { BufferedRawMachineAssemblerTester<double> m( MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Sub(m.Float64Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { FOR_FLOAT64_INPUTS(k) { CheckDoubleEq((*i * *j) - *k, m.Call(*i, *j, *k)); } } } } TEST(RunFloat64MulAndFloat64Sub2) { BufferedRawMachineAssemblerTester<double> m( MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Sub(m.Parameter(0), m.Float64Mul(m.Parameter(1), m.Parameter(2)))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { FOR_FLOAT64_INPUTS(k) { CheckDoubleEq(*i - (*j * *k), m.Call(*i, *j, *k)); } } } } TEST(RunFloat64MulImm1) { FOR_FLOAT64_INPUTS(i) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); m.Return(m.Float64Mul(m.Float64Constant(*i), m.Parameter(0))); FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i * *j, m.Call(*j)); } } } TEST(RunFloat64MulImm2) { FOR_FLOAT64_INPUTS(i) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); m.Return(m.Float64Mul(m.Parameter(0), m.Float64Constant(*i))); FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j * *i, m.Call(*j)); } } } TEST(RunFloat32DivP) { RawMachineAssemblerTester<int32_t> m; Float32BinopTester bt(&m); bt.AddReturn(m.Float32Div(bt.param0, bt.param1)); FOR_FLOAT32_INPUTS(pl) { FOR_FLOAT32_INPUTS(pr) { float expected = *pl / *pr; CheckFloatEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat64DivP) { RawMachineAssemblerTester<int32_t> m; Float64BinopTester bt(&m); bt.AddReturn(m.Float64Div(bt.param0, bt.param1)); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { double expected = *pl / *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } TEST(RunFloat64ModP) { RawMachineAssemblerTester<int32_t> m; Float64BinopTester bt(&m); bt.AddReturn(m.Float64Mod(bt.param0, bt.param1)); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { double expected = modulo(*i, *j); double found = bt.call(*i, *j); CheckDoubleEq(expected, found); } } } TEST(RunChangeInt32ToFloat64_A) { int32_t magic = 0x986234; BufferedRawMachineAssemblerTester<double> m; m.Return(m.ChangeInt32ToFloat64(m.Int32Constant(magic))); CheckDoubleEq(static_cast<double>(magic), m.Call()); } TEST(RunChangeInt32ToFloat64_B) { BufferedRawMachineAssemblerTester<double> m(MachineType::Int32()); m.Return(m.ChangeInt32ToFloat64(m.Parameter(0))); FOR_INT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } } TEST(RunChangeUint32ToFloat64) { BufferedRawMachineAssemblerTester<double> m(MachineType::Uint32()); m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } } TEST(RunChangeFloat64ToInt32_A) { BufferedRawMachineAssemblerTester<int32_t> m; double magic = 11.1; m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); CHECK_EQ(static_cast<int32_t>(magic), m.Call()); } TEST(RunChangeFloat64ToInt32_B) { BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float64()); m.Return(m.ChangeFloat64ToInt32(m.Parameter(0))); // Note we don't check fractional inputs, or inputs outside the range of // int32, because these Convert operators really should be Change operators. FOR_INT32_INPUTS(i) { CHECK_EQ(*i, m.Call(static_cast<double>(*i))); } for (int32_t n = 1; n < 31; ++n) { CHECK_EQ(1 << n, m.Call(static_cast<double>(1 << n))); } for (int32_t n = 1; n < 31; ++n) { CHECK_EQ(3 << n, m.Call(static_cast<double>(3 << n))); } } TEST(RunChangeFloat64ToUint32) { BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64()); m.Return(m.ChangeFloat64ToUint32(m.Parameter(0))); { FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, m.Call(static_cast<double>(*i))); } } // Check various powers of 2. for (int32_t n = 1; n < 31; ++n) { { CHECK_EQ(1u << n, m.Call(static_cast<double>(1u << n))); } { CHECK_EQ(3u << n, m.Call(static_cast<double>(3u << n))); } } // Note we don't check fractional inputs, because these Convert operators // really should be Change operators. } TEST(RunTruncateFloat64ToFloat32) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float64()); m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { CheckFloatEq(DoubleToFloat32(*i), m.Call(*i)); } } TEST(RunDeadChangeFloat64ToInt32) { RawMachineAssemblerTester<int32_t> m; const int magic = 0x88abcda4; m.ChangeFloat64ToInt32(m.Float64Constant(999.78)); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); } TEST(RunDeadChangeInt32ToFloat64) { RawMachineAssemblerTester<int32_t> m; const int magic = 0x8834abcd; m.ChangeInt32ToFloat64(m.Int32Constant(magic - 6888)); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); } TEST(RunLoopPhiInduction2) { RawMachineAssemblerTester<int32_t> m; int false_val = 0x10777; // x = false_val; while(false) { x++; } return x; RawMachineLabel header, body, end; Node* false_node = m.Int32Constant(false_val); m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, false_node); m.Branch(m.Int32Constant(0), &body, &end); m.Bind(&body); Node* add = m.Int32Add(phi, m.Int32Constant(1)); phi->ReplaceInput(1, add); m.Goto(&header); m.Bind(&end); m.Return(phi); CHECK_EQ(false_val, m.Call()); } TEST(RunFloatDiamond) { RawMachineAssemblerTester<int32_t> m; const int magic = 99645; float buffer = 0.1f; float constant = 99.99f; RawMachineLabel blocka, blockb, end; Node* k1 = m.Float32Constant(constant); Node* k2 = m.Float32Constant(0 - constant); m.Branch(m.Int32Constant(0), &blocka, &blockb); m.Bind(&blocka); m.Goto(&end); m.Bind(&blockb); m.Goto(&end); m.Bind(&end); Node* phi = m.Phi(MachineRepresentation::kFloat32, k2, k1); m.Store(MachineRepresentation::kFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); CHECK(constant == buffer); } TEST(RunDoubleDiamond) { RawMachineAssemblerTester<int32_t> m; const int magic = 99645; double buffer = 0.1; double constant = 99.99; RawMachineLabel blocka, blockb, end; Node* k1 = m.Float64Constant(constant); Node* k2 = m.Float64Constant(0 - constant); m.Branch(m.Int32Constant(0), &blocka, &blockb); m.Bind(&blocka); m.Goto(&end); m.Bind(&blockb); m.Goto(&end); m.Bind(&end); Node* phi = m.Phi(MachineRepresentation::kFloat64, k2, k1); m.Store(MachineRepresentation::kFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); CHECK_EQ(constant, buffer); } TEST(RunRefDiamond) { RawMachineAssemblerTester<int32_t> m; const int magic = 99644; Handle<String> rexpected = CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); String* buffer; RawMachineLabel blocka, blockb, end; Node* k1 = m.StringConstant("A"); Node* k2 = m.StringConstant("B"); m.Branch(m.Int32Constant(0), &blocka, &blockb); m.Bind(&blocka); m.Goto(&end); m.Bind(&blockb); m.Goto(&end); m.Bind(&end); Node* phi = m.Phi(MachineRepresentation::kTagged, k2, k1); m.Store(MachineRepresentation::kTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); CHECK(rexpected->SameValue(buffer)); } TEST(RunDoubleRefDiamond) { RawMachineAssemblerTester<int32_t> m; const int magic = 99648; double dbuffer = 0.1; double dconstant = 99.99; Handle<String> rexpected = CcTest::i_isolate()->factory()->InternalizeUtf8String("AX"); String* rbuffer; RawMachineLabel blocka, blockb, end; Node* d1 = m.Float64Constant(dconstant); Node* d2 = m.Float64Constant(0 - dconstant); Node* r1 = m.StringConstant("AX"); Node* r2 = m.StringConstant("BX"); m.Branch(m.Int32Constant(0), &blocka, &blockb); m.Bind(&blocka); m.Goto(&end); m.Bind(&blockb); m.Goto(&end); m.Bind(&end); Node* dphi = m.Phi(MachineRepresentation::kFloat64, d2, d1); Node* rphi = m.Phi(MachineRepresentation::kTagged, r2, r1); m.Store(MachineRepresentation::kFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi, kNoWriteBarrier); m.Store(MachineRepresentation::kTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); CHECK_EQ(dconstant, dbuffer); CHECK(rexpected->SameValue(rbuffer)); } TEST(RunDoubleRefDoubleDiamond) { RawMachineAssemblerTester<int32_t> m; const int magic = 99649; double dbuffer = 0.1; double dconstant = 99.997; Handle<String> rexpected = CcTest::i_isolate()->factory()->InternalizeUtf8String("AD"); String* rbuffer; RawMachineLabel blocka, blockb, mid, blockd, blocke, end; Node* d1 = m.Float64Constant(dconstant); Node* d2 = m.Float64Constant(0 - dconstant); Node* r1 = m.StringConstant("AD"); Node* r2 = m.StringConstant("BD"); m.Branch(m.Int32Constant(0), &blocka, &blockb); m.Bind(&blocka); m.Goto(&mid); m.Bind(&blockb); m.Goto(&mid); m.Bind(&mid); Node* dphi1 = m.Phi(MachineRepresentation::kFloat64, d2, d1); Node* rphi1 = m.Phi(MachineRepresentation::kTagged, r2, r1); m.Branch(m.Int32Constant(0), &blockd, &blocke); m.Bind(&blockd); m.Goto(&end); m.Bind(&blocke); m.Goto(&end); m.Bind(&end); Node* dphi2 = m.Phi(MachineRepresentation::kFloat64, d1, dphi1); Node* rphi2 = m.Phi(MachineRepresentation::kTagged, r1, rphi1); m.Store(MachineRepresentation::kFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2, kNoWriteBarrier); m.Store(MachineRepresentation::kTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi2, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); CHECK_EQ(dconstant, dbuffer); CHECK(rexpected->SameValue(rbuffer)); } TEST(RunDoubleLoopPhi) { RawMachineAssemblerTester<int32_t> m; RawMachineLabel header, body, end; int magic = 99773; double buffer = 0.99; double dconstant = 777.1; Node* zero = m.Int32Constant(0); Node* dk = m.Float64Constant(dconstant); m.Goto(&header); m.Bind(&header); Node* phi = m.Phi(MachineRepresentation::kFloat64, dk, dk); phi->ReplaceInput(1, phi); m.Branch(zero, &body, &end); m.Bind(&body); m.Goto(&header); m.Bind(&end); m.Store(MachineRepresentation::kFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); } TEST(RunCountToTenAccRaw) { RawMachineAssemblerTester<int32_t> m; Node* zero = m.Int32Constant(0); Node* ten = m.Int32Constant(10); Node* one = m.Int32Constant(1); RawMachineLabel header, body, body_cont, end; m.Goto(&header); m.Bind(&header); Node* i = m.Phi(MachineRepresentation::kWord32, zero, zero); Node* j = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Goto(&body); m.Bind(&body); Node* next_i = m.Int32Add(i, one); Node* next_j = m.Int32Add(j, one); m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont); m.Bind(&body_cont); i->ReplaceInput(1, next_i); j->ReplaceInput(1, next_j); m.Goto(&header); m.Bind(&end); m.Return(ten); CHECK_EQ(10, m.Call()); } TEST(RunCountToTenAccRaw2) { RawMachineAssemblerTester<int32_t> m; Node* zero = m.Int32Constant(0); Node* ten = m.Int32Constant(10); Node* one = m.Int32Constant(1); RawMachineLabel header, body, body_cont, end; m.Goto(&header); m.Bind(&header); Node* i = m.Phi(MachineRepresentation::kWord32, zero, zero); Node* j = m.Phi(MachineRepresentation::kWord32, zero, zero); Node* k = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Goto(&body); m.Bind(&body); Node* next_i = m.Int32Add(i, one); Node* next_j = m.Int32Add(j, one); Node* next_k = m.Int32Add(j, one); m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont); m.Bind(&body_cont); i->ReplaceInput(1, next_i); j->ReplaceInput(1, next_j); k->ReplaceInput(1, next_k); m.Goto(&header); m.Bind(&end); m.Return(ten); CHECK_EQ(10, m.Call()); } TEST(RunAddTree) { RawMachineAssemblerTester<int32_t> m; int32_t inputs[] = {11, 12, 13, 14, 15, 16, 17, 18}; Node* base = m.PointerConstant(inputs); Node* n0 = m.Load(MachineType::Int32(), base, m.Int32Constant(0 * sizeof(int32_t))); Node* n1 = m.Load(MachineType::Int32(), base, m.Int32Constant(1 * sizeof(int32_t))); Node* n2 = m.Load(MachineType::Int32(), base, m.Int32Constant(2 * sizeof(int32_t))); Node* n3 = m.Load(MachineType::Int32(), base, m.Int32Constant(3 * sizeof(int32_t))); Node* n4 = m.Load(MachineType::Int32(), base, m.Int32Constant(4 * sizeof(int32_t))); Node* n5 = m.Load(MachineType::Int32(), base, m.Int32Constant(5 * sizeof(int32_t))); Node* n6 = m.Load(MachineType::Int32(), base, m.Int32Constant(6 * sizeof(int32_t))); Node* n7 = m.Load(MachineType::Int32(), base, m.Int32Constant(7 * sizeof(int32_t))); Node* i1 = m.Int32Add(n0, n1); Node* i2 = m.Int32Add(n2, n3); Node* i3 = m.Int32Add(n4, n5); Node* i4 = m.Int32Add(n6, n7); Node* i5 = m.Int32Add(i1, i2); Node* i6 = m.Int32Add(i3, i4); Node* i7 = m.Int32Add(i5, i6); m.Return(i7); CHECK_EQ(116, m.Call()); } static const int kFloat64CompareHelperTestCases = 15; static const int kFloat64CompareHelperNodeType = 4; static int Float64CompareHelper(RawMachineAssemblerTester<int32_t>* m, int test_case, int node_type, double x, double y) { static double buffer[2]; buffer[0] = x; buffer[1] = y; CHECK(0 <= test_case && test_case < kFloat64CompareHelperTestCases); CHECK(0 <= node_type && node_type < kFloat64CompareHelperNodeType); CHECK(x < y); bool load_a = node_type / 2 == 1; bool load_b = node_type % 2 == 1; Node* a = load_a ? m->Load(MachineType::Float64(), m->PointerConstant(&buffer[0])) : m->Float64Constant(x); Node* b = load_b ? m->Load(MachineType::Float64(), m->PointerConstant(&buffer[1])) : m->Float64Constant(y); Node* cmp = NULL; bool expected = false; switch (test_case) { // Equal tests. case 0: cmp = m->Float64Equal(a, b); expected = false; break; case 1: cmp = m->Float64Equal(a, a); expected = true; break; // LessThan tests. case 2: cmp = m->Float64LessThan(a, b); expected = true; break; case 3: cmp = m->Float64LessThan(b, a); expected = false; break; case 4: cmp = m->Float64LessThan(a, a); expected = false; break; // LessThanOrEqual tests. case 5: cmp = m->Float64LessThanOrEqual(a, b); expected = true; break; case 6: cmp = m->Float64LessThanOrEqual(b, a); expected = false; break; case 7: cmp = m->Float64LessThanOrEqual(a, a); expected = true; break; // NotEqual tests. case 8: cmp = m->Float64NotEqual(a, b); expected = true; break; case 9: cmp = m->Float64NotEqual(b, a); expected = true; break; case 10: cmp = m->Float64NotEqual(a, a); expected = false; break; // GreaterThan tests. case 11: cmp = m->Float64GreaterThan(a, a); expected = false; break; case 12: cmp = m->Float64GreaterThan(a, b); expected = false; break; // GreaterThanOrEqual tests. case 13: cmp = m->Float64GreaterThanOrEqual(a, a); expected = true; break; case 14: cmp = m->Float64GreaterThanOrEqual(b, a); expected = true; break; default: UNREACHABLE(); } m->Return(cmp); return expected; } TEST(RunFloat64Compare) { double inf = V8_INFINITY; // All pairs (a1, a2) are of the form a1 < a2. double inputs[] = {0.0, 1.0, -1.0, 0.22, -1.22, 0.22, -inf, 0.22, 0.22, inf, -inf, inf}; for (int test = 0; test < kFloat64CompareHelperTestCases; test++) { for (int node_type = 0; node_type < kFloat64CompareHelperNodeType; node_type++) { for (size_t input = 0; input < arraysize(inputs); input += 2) { RawMachineAssemblerTester<int32_t> m; int expected = Float64CompareHelper(&m, test, node_type, inputs[input], inputs[input + 1]); CHECK_EQ(expected, m.Call()); } } } } TEST(RunFloat64UnorderedCompare) { RawMachineAssemblerTester<int32_t> m; const Operator* operators[] = {m.machine()->Float64Equal(), m.machine()->Float64LessThan(), m.machine()->Float64LessThanOrEqual()}; double nan = std::numeric_limits<double>::quiet_NaN(); FOR_FLOAT64_INPUTS(i) { for (size_t o = 0; o < arraysize(operators); ++o) { for (int j = 0; j < 2; j++) { RawMachineAssemblerTester<int32_t> m; Node* a = m.Float64Constant(*i); Node* b = m.Float64Constant(nan); if (j == 1) std::swap(a, b); m.Return(m.AddNode(operators[o], a, b)); CHECK_EQ(0, m.Call()); } } } } TEST(RunFloat64Equal) { double input_a = 0.0; double input_b = 0.0; RawMachineAssemblerTester<int32_t> m; Node* a = m.LoadFromPointer(&input_a, MachineType::Float64()); Node* b = m.LoadFromPointer(&input_b, MachineType::Float64()); m.Return(m.Float64Equal(a, b)); CompareWrapper cmp(IrOpcode::kFloat64Equal); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { input_a = *pl; input_b = *pr; int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0; CHECK_EQ(expected, m.Call()); } } } TEST(RunFloat64LessThan) { double input_a = 0.0; double input_b = 0.0; RawMachineAssemblerTester<int32_t> m; Node* a = m.LoadFromPointer(&input_a, MachineType::Float64()); Node* b = m.LoadFromPointer(&input_b, MachineType::Float64()); m.Return(m.Float64LessThan(a, b)); CompareWrapper cmp(IrOpcode::kFloat64LessThan); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { input_a = *pl; input_b = *pr; int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0; CHECK_EQ(expected, m.Call()); } } } template <typename IntType> static void LoadStoreTruncation(MachineType kRepresentation) { IntType input; RawMachineAssemblerTester<int32_t> m; Node* a = m.LoadFromPointer(&input, kRepresentation); Node* ap1 = m.Int32Add(a, m.Int32Constant(1)); m.StoreToPointer(&input, kRepresentation.representation(), ap1); m.Return(ap1); const IntType max = std::numeric_limits<IntType>::max(); const IntType min = std::numeric_limits<IntType>::min(); // Test upper bound. input = max; CHECK_EQ(max + 1, m.Call()); CHECK_EQ(min, input); // Test lower bound. input = min; CHECK_EQ(static_cast<IntType>(max + 2), m.Call()); CHECK_EQ(min + 1, input); // Test all one byte values that are not one byte bounds. for (int i = -127; i < 127; i++) { input = i; int expected = i >= 0 ? i + 1 : max + (i - min) + 2; CHECK_EQ(static_cast<IntType>(expected), m.Call()); CHECK_EQ(static_cast<IntType>(i + 1), input); } } TEST(RunLoadStoreTruncation) { LoadStoreTruncation<int8_t>(MachineType::Int8()); LoadStoreTruncation<int16_t>(MachineType::Int16()); } static void IntPtrCompare(intptr_t left, intptr_t right) { for (int test = 0; test < 7; test++) { RawMachineAssemblerTester<bool> m(MachineType::Pointer(), MachineType::Pointer()); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); Node* res = NULL; bool expected = false; switch (test) { case 0: res = m.IntPtrLessThan(p0, p1); expected = true; break; case 1: res = m.IntPtrLessThanOrEqual(p0, p1); expected = true; break; case 2: res = m.IntPtrEqual(p0, p1); expected = false; break; case 3: res = m.IntPtrGreaterThanOrEqual(p0, p1); expected = false; break; case 4: res = m.IntPtrGreaterThan(p0, p1); expected = false; break; case 5: res = m.IntPtrEqual(p0, p0); expected = true; break; case 6: res = m.IntPtrNotEqual(p0, p1); expected = true; break; default: UNREACHABLE(); break; } m.Return(res); CHECK_EQ(expected, m.Call(reinterpret_cast<int32_t*>(left), reinterpret_cast<int32_t*>(right))); } } TEST(RunIntPtrCompare) { intptr_t min = std::numeric_limits<intptr_t>::min(); intptr_t max = std::numeric_limits<intptr_t>::max(); // An ascending chain of intptr_t intptr_t inputs[] = {min, min / 2, -1, 0, 1, max / 2, max}; for (size_t i = 0; i < arraysize(inputs) - 1; i++) { IntPtrCompare(inputs[i], inputs[i + 1]); } } TEST(RunTestIntPtrArithmetic) { static const int kInputSize = 10; int32_t inputs[kInputSize]; int32_t outputs[kInputSize]; for (int i = 0; i < kInputSize; i++) { inputs[i] = i; outputs[i] = -1; } RawMachineAssemblerTester<int32_t*> m; Node* input = m.PointerConstant(&inputs[0]); Node* output = m.PointerConstant(&outputs[kInputSize - 1]); Node* elem_size = m.IntPtrConstant(sizeof(inputs[0])); for (int i = 0; i < kInputSize; i++) { m.Store(MachineRepresentation::kWord32, output, m.Load(MachineType::Int32(), input), kNoWriteBarrier); input = m.IntPtrAdd(input, elem_size); output = m.IntPtrSub(output, elem_size); } m.Return(input); CHECK_EQ(&inputs[kInputSize], m.Call()); for (int i = 0; i < kInputSize; i++) { CHECK_EQ(i, inputs[i]); CHECK_EQ(kInputSize - i - 1, outputs[i]); } } TEST(RunSpillLotsOfThings) { static const int kInputSize = 1000; RawMachineAssemblerTester<int32_t> m; Node* accs[kInputSize]; int32_t outputs[kInputSize]; Node* one = m.Int32Constant(1); Node* acc = one; for (int i = 0; i < kInputSize; i++) { acc = m.Int32Add(acc, one); accs[i] = acc; } for (int i = 0; i < kInputSize; i++) { m.StoreToPointer(&outputs[i], MachineRepresentation::kWord32, accs[i]); } m.Return(one); m.Call(); for (int i = 0; i < kInputSize; i++) { CHECK_EQ(outputs[i], i + 2); } } TEST(RunSpillConstantsAndParameters) { static const int kInputSize = 1000; static const int32_t kBase = 987; RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), MachineType::Int32()); int32_t outputs[kInputSize]; Node* csts[kInputSize]; Node* accs[kInputSize]; Node* acc = m.Int32Constant(0); for (int i = 0; i < kInputSize; i++) { csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i)); } for (int i = 0; i < kInputSize; i++) { acc = m.Int32Add(acc, csts[i]); accs[i] = acc; } for (int i = 0; i < kInputSize; i++) { m.StoreToPointer(&outputs[i], MachineRepresentation::kWord32, accs[i]); } m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = *i + *j; for (int k = 0; k < kInputSize; k++) { expected += kBase + k; } CHECK_EQ(expected, m.Call(*i, *j)); expected = 0; for (int k = 0; k < kInputSize; k++) { expected += kBase + k; CHECK_EQ(expected, outputs[k]); } } } } TEST(RunNewSpaceConstantsInPhi) { RawMachineAssemblerTester<Object*> m(MachineType::Int32()); Isolate* isolate = CcTest::i_isolate(); Handle<HeapNumber> true_val = isolate->factory()->NewHeapNumber(11.2); Handle<HeapNumber> false_val = isolate->factory()->NewHeapNumber(11.3); Node* true_node = m.HeapConstant(true_val); Node* false_node = m.HeapConstant(false_val); RawMachineLabel blocka, blockb, end; m.Branch(m.Parameter(0), &blocka, &blockb); m.Bind(&blocka); m.Goto(&end); m.Bind(&blockb); m.Goto(&end); m.Bind(&end); Node* phi = m.Phi(MachineRepresentation::kTagged, true_node, false_node); m.Return(phi); CHECK_EQ(*false_val, m.Call(0)); CHECK_EQ(*true_val, m.Call(1)); } TEST(RunInt32AddWithOverflowP) { int32_t actual_val = -1; RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); bt.AddReturn(ovf); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected_val; int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, bt.call(*i, *j)); CHECK_EQ(expected_val, actual_val); } } } TEST(RunInt32AddWithOverflowImm) { int32_t actual_val = -1, expected_val = 0; FOR_INT32_INPUTS(i) { { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); m.Return(ovf); FOR_INT32_INPUTS(j) { int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call(*j)); CHECK_EQ(expected_val, actual_val); } } { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); m.Return(ovf); FOR_INT32_INPUTS(j) { int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call(*j)); CHECK_EQ(expected_val, actual_val); } } FOR_INT32_INPUTS(j) { RawMachineAssemblerTester<int32_t> m; Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); m.Return(ovf); int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call()); CHECK_EQ(expected_val, actual_val); } } } TEST(RunInt32AddWithOverflowInBranchP) { int constant = 911777; RawMachineLabel blocka, blockb; RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); Node* ovf = m.Projection(1, add); m.Branch(ovf, &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); Node* val = m.Projection(0, add); bt.AddReturn(val); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected; if (bits::SignedAddOverflow32(*i, *j, &expected)) expected = constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } TEST(RunInt32SubWithOverflowP) { int32_t actual_val = -1; RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); bt.AddReturn(ovf); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected_val; int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, bt.call(*i, *j)); CHECK_EQ(expected_val, actual_val); } } } TEST(RunInt32SubWithOverflowImm) { int32_t actual_val = -1, expected_val = 0; FOR_INT32_INPUTS(i) { { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); m.Return(ovf); FOR_INT32_INPUTS(j) { int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call(*j)); CHECK_EQ(expected_val, actual_val); } } { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); m.Return(ovf); FOR_INT32_INPUTS(j) { int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val); CHECK_EQ(expected_ovf, m.Call(*j)); CHECK_EQ(expected_val, actual_val); } } FOR_INT32_INPUTS(j) { RawMachineAssemblerTester<int32_t> m; Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); m.Return(ovf); int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call()); CHECK_EQ(expected_val, actual_val); } } } TEST(RunInt32SubWithOverflowInBranchP) { int constant = 911999; RawMachineLabel blocka, blockb; RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); Node* sub = m.Int32SubWithOverflow(bt.param0, bt.param1); Node* ovf = m.Projection(1, sub); m.Branch(ovf, &blocka, &blockb); m.Bind(&blocka); bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); Node* val = m.Projection(0, sub); bt.AddReturn(val); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected; if (bits::SignedSubOverflow32(*i, *j, &expected)) expected = constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } TEST(RunWord64EqualInBranchP) { int64_t input; RawMachineLabel blocka, blockb; RawMachineAssemblerTester<int64_t> m; if (!m.machine()->Is64()) return; Node* value = m.LoadFromPointer(&input, MachineType::Int64()); m.Branch(m.Word64Equal(value, m.Int64Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(1)); m.Bind(&blockb); m.Return(m.Int32Constant(2)); input = V8_INT64_C(0); CHECK_EQ(1, m.Call()); input = V8_INT64_C(1); CHECK_EQ(2, m.Call()); input = V8_INT64_C(0x100000000); CHECK_EQ(2, m.Call()); } TEST(RunChangeInt32ToInt64P) { if (kPointerSize < 8) return; int64_t actual = -1; RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); m.StoreToPointer(&actual, MachineRepresentation::kWord64, m.ChangeInt32ToInt64(m.Parameter(0))); m.Return(m.Int32Constant(0)); FOR_INT32_INPUTS(i) { int64_t expected = *i; CHECK_EQ(0, m.Call(*i)); CHECK_EQ(expected, actual); } } TEST(RunChangeUint32ToUint64P) { if (kPointerSize < 8) return; int64_t actual = -1; RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); m.StoreToPointer(&actual, MachineRepresentation::kWord64, m.ChangeUint32ToUint64(m.Parameter(0))); m.Return(m.Int32Constant(0)); FOR_UINT32_INPUTS(i) { int64_t expected = static_cast<uint64_t>(*i); CHECK_EQ(0, m.Call(*i)); CHECK_EQ(expected, actual); } } TEST(RunTruncateInt64ToInt32P) { if (kPointerSize < 8) return; int64_t expected = -1; RawMachineAssemblerTester<int32_t> m; m.Return(m.TruncateInt64ToInt32( m.LoadFromPointer(&expected, MachineType::Int64()))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { expected = (static_cast<uint64_t>(*j) << 32) | *i; CHECK_EQ(static_cast<int32_t>(expected), m.Call()); } } } TEST(RunTruncateFloat64ToInt32P) { struct { double from; double raw; } kValues[] = {{0, 0}, {0.5, 0}, {-0.5, 0}, {1.5, 1}, {-1.5, -1}, {5.5, 5}, {-5.0, -5}, {std::numeric_limits<double>::quiet_NaN(), 0}, {std::numeric_limits<double>::infinity(), 0}, {-std::numeric_limits<double>::quiet_NaN(), 0}, {-std::numeric_limits<double>::infinity(), 0}, {4.94065645841e-324, 0}, {-4.94065645841e-324, 0}, {0.9999999999999999, 0}, {-0.9999999999999999, 0}, {4294967296.0, 0}, {-4294967296.0, 0}, {9223372036854775000.0, 4294966272.0}, {-9223372036854775000.0, -4294966272.0}, {4.5036e+15, 372629504}, {-4.5036e+15, -372629504}, {287524199.5377777, 0x11234567}, {-287524199.5377777, -0x11234567}, {2300193596.302222, 2300193596.0}, {-2300193596.302222, -2300193596.0}, {4600387192.604444, 305419896}, {-4600387192.604444, -305419896}, {4823855600872397.0, 1737075661}, {-4823855600872397.0, -1737075661}, {4503603922337791.0, -1}, {-4503603922337791.0, 1}, {4503601774854143.0, 2147483647}, {-4503601774854143.0, -2147483647}, {9007207844675582.0, -2}, {-9007207844675582.0, 2}, {2.4178527921507624e+24, -536870912}, {-2.4178527921507624e+24, 536870912}, {2.417853945072267e+24, -536870912}, {-2.417853945072267e+24, 536870912}, {4.8357055843015248e+24, -1073741824}, {-4.8357055843015248e+24, 1073741824}, {4.8357078901445341e+24, -1073741824}, {-4.8357078901445341e+24, 1073741824}, {2147483647.0, 2147483647.0}, {-2147483648.0, -2147483648.0}, {9.6714111686030497e+24, -2147483648.0}, {-9.6714111686030497e+24, -2147483648.0}, {9.6714157802890681e+24, -2147483648.0}, {-9.6714157802890681e+24, -2147483648.0}, {1.9342813113834065e+25, 2147483648.0}, {-1.9342813113834065e+25, 2147483648.0}, {3.868562622766813e+25, 0}, {-3.868562622766813e+25, 0}, {1.7976931348623157e+308, 0}, {-1.7976931348623157e+308, 0}}; double input = -1.0; RawMachineAssemblerTester<int32_t> m; m.Return(m.TruncateFloat64ToInt32( TruncationMode::kJavaScript, m.LoadFromPointer(&input, MachineType::Float64()))); for (size_t i = 0; i < arraysize(kValues); ++i) { input = kValues[i].from; uint64_t expected = static_cast<int64_t>(kValues[i].raw); CHECK_EQ(static_cast<int>(expected), m.Call()); } } TEST(RunChangeFloat32ToFloat64) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float32()); m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); FOR_FLOAT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } } TEST(RunFloat32Constant) { FOR_FLOAT32_INPUTS(i) { BufferedRawMachineAssemblerTester<float> m; m.Return(m.Float32Constant(*i)); CheckFloatEq(*i, m.Call()); } } TEST(RunFloat64ExtractLowWord32) { BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64()); m.Return(m.Float64ExtractLowWord32(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i)); CHECK_EQ(expected, m.Call(*i)); } } TEST(RunFloat64ExtractHighWord32) { BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64()); m.Return(m.Float64ExtractHighWord32(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i) >> 32); CHECK_EQ(expected, m.Call(*i)); } } TEST(RunFloat64InsertLowWord32) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), MachineType::Int32()); m.Return(m.Float64InsertLowWord32(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_INT32_INPUTS(j) { double expected = bit_cast<double>( (bit_cast<uint64_t>(*i) & ~(V8_UINT64_C(0xFFFFFFFF))) | (static_cast<uint64_t>(bit_cast<uint32_t>(*j)))); CheckDoubleEq(expected, m.Call(*i, *j)); } } } TEST(RunFloat64InsertHighWord32) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), MachineType::Uint32()); m.Return(m.Float64InsertHighWord32(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint64_t expected = (bit_cast<uint64_t>(*i) & 0xFFFFFFFF) | (static_cast<uint64_t>(*j) << 32); CheckDoubleEq(bit_cast<double>(expected), m.Call(*i, *j)); } } } TEST(RunFloat32Abs) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); m.Return(m.Float32Abs(m.Parameter(0))); FOR_FLOAT32_INPUTS(i) { CheckFloatEq(std::abs(*i), m.Call(*i)); } } TEST(RunFloat64Abs) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); m.Return(m.Float64Abs(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::abs(*i), m.Call(*i)); } } static double two_30 = 1 << 30; // 2^30 is a smi boundary. static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. static double kValues[] = {0.1, 0.2, 0.49999999999999994, 0.5, 0.7, 1.0 - std::numeric_limits<double>::epsilon(), -0.1, -0.49999999999999994, -0.5, -0.7, 1.1, 1.0 + std::numeric_limits<double>::epsilon(), 1.5, 1.7, -1, -1 + std::numeric_limits<double>::epsilon(), -1 - std::numeric_limits<double>::epsilon(), -1.1, -1.5, -1.7, std::numeric_limits<double>::min(), -std::numeric_limits<double>::min(), std::numeric_limits<double>::max(), -std::numeric_limits<double>::max(), std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity(), two_30, two_30 + 0.1, two_30 + 0.5, two_30 + 0.7, two_30 - 1, two_30 - 1 + 0.1, two_30 - 1 + 0.5, two_30 - 1 + 0.7, -two_30, -two_30 + 0.1, -two_30 + 0.5, -two_30 + 0.7, -two_30 + 1, -two_30 + 1 + 0.1, -two_30 + 1 + 0.5, -two_30 + 1 + 0.7, two_52, two_52 + 0.1, two_52 + 0.5, two_52 + 0.5, two_52 + 0.7, two_52 + 0.7, two_52 - 1, two_52 - 1 + 0.1, two_52 - 1 + 0.5, two_52 - 1 + 0.7, -two_52, -two_52 + 0.1, -two_52 + 0.5, -two_52 + 0.7, -two_52 + 1, -two_52 + 1 + 0.1, -two_52 + 1 + 0.5, -two_52 + 1 + 0.7, two_30, two_30 - 0.1, two_30 - 0.5, two_30 - 0.7, two_30 - 1, two_30 - 1 - 0.1, two_30 - 1 - 0.5, two_30 - 1 - 0.7, -two_30, -two_30 - 0.1, -two_30 - 0.5, -two_30 - 0.7, -two_30 + 1, -two_30 + 1 - 0.1, -two_30 + 1 - 0.5, -two_30 + 1 - 0.7, two_52, two_52 - 0.1, two_52 - 0.5, two_52 - 0.5, two_52 - 0.7, two_52 - 0.7, two_52 - 1, two_52 - 1 - 0.1, two_52 - 1 - 0.5, two_52 - 1 - 0.7, -two_52, -two_52 - 0.1, -two_52 - 0.5, -two_52 - 0.7, -two_52 + 1, -two_52 + 1 - 0.1, -two_52 + 1 - 0.5, -two_52 + 1 - 0.7}; TEST(RunFloat32RoundDown) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); if (!m.machine()->Float32RoundDown().IsSupported()) return; m.Return(m.Float32RoundDown(m.Parameter(0))); FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); } } TEST(RunFloat64RoundDown1) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); if (!m.machine()->Float64RoundDown().IsSupported()) return; m.Return(m.Float64RoundDown(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(floor(*i), m.Call(*i)); } } TEST(RunFloat64RoundDown2) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); if (!m.machine()->Float64RoundDown().IsSupported()) return; m.Return(m.Float64Sub(m.Float64Constant(-0.0), m.Float64RoundDown(m.Float64Sub(m.Float64Constant(-0.0), m.Parameter(0))))); for (size_t i = 0; i < arraysize(kValues); ++i) { CHECK_EQ(ceil(kValues[i]), m.Call(kValues[i])); } } TEST(RunFloat32RoundUp) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); if (!m.machine()->Float32RoundUp().IsSupported()) return; m.Return(m.Float32RoundUp(m.Parameter(0))); FOR_FLOAT32_INPUTS(i) { CheckFloatEq(ceilf(*i), m.Call(*i)); } } TEST(RunFloat64RoundUp) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); if (!m.machine()->Float64RoundUp().IsSupported()) return; m.Return(m.Float64RoundUp(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(ceil(*i), m.Call(*i)); } } TEST(RunFloat32RoundTiesEven) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); if (!m.machine()->Float32RoundTiesEven().IsSupported()) return; m.Return(m.Float32RoundTiesEven(m.Parameter(0))); FOR_FLOAT32_INPUTS(i) { CheckFloatEq(nearbyint(*i), m.Call(*i)); } } TEST(RunFloat64RoundTiesEven) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); if (!m.machine()->Float64RoundTiesEven().IsSupported()) return; m.Return(m.Float64RoundTiesEven(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), m.Call(*i)); } } TEST(RunFloat32RoundTruncate) { BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); if (!m.machine()->Float32RoundTruncate().IsSupported()) return; m.Return(m.Float32RoundTruncate(m.Parameter(0))); FOR_FLOAT32_INPUTS(i) { CheckFloatEq(truncf(*i), m.Call(*i)); } } TEST(RunFloat64RoundTruncate) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); if (!m.machine()->Float64RoundTruncate().IsSupported()) return; m.Return(m.Float64RoundTruncate(m.Parameter(0))); for (size_t i = 0; i < arraysize(kValues); ++i) { CHECK_EQ(trunc(kValues[i]), m.Call(kValues[i])); } } TEST(RunFloat64RoundTiesAway) { BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); if (!m.machine()->Float64RoundTiesAway().IsSupported()) return; m.Return(m.Float64RoundTiesAway(m.Parameter(0))); for (size_t i = 0; i < arraysize(kValues); ++i) { CHECK_EQ(round(kValues[i]), m.Call(kValues[i])); } } #if !USE_SIMULATOR namespace { int32_t const kMagicFoo0 = 0xdeadbeef; int32_t foo0() { return kMagicFoo0; } int32_t foo1(int32_t x) { return x; } int32_t foo2(int32_t x, int32_t y) { return x - y; } int32_t foo8(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, int32_t g, int32_t h) { return a + b + c + d + e + f + g + h; } } // namespace TEST(RunCallCFunction0) { auto* foo0_ptr = &foo0; RawMachineAssemblerTester<int32_t> m; Node* function = m.LoadFromPointer(&foo0_ptr, MachineType::Pointer()); m.Return(m.CallCFunction0(MachineType::Int32(), function)); CHECK_EQ(kMagicFoo0, m.Call()); } TEST(RunCallCFunction1) { auto* foo1_ptr = &foo1; RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); Node* function = m.LoadFromPointer(&foo1_ptr, MachineType::Pointer()); m.Return(m.CallCFunction1(MachineType::Int32(), MachineType::Int32(), function, m.Parameter(0))); FOR_INT32_INPUTS(i) { int32_t const expected = *i; CHECK_EQ(expected, m.Call(expected)); } } TEST(RunCallCFunction2) { auto* foo2_ptr = &foo2; RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), MachineType::Int32()); Node* function = m.LoadFromPointer(&foo2_ptr, MachineType::Pointer()); m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), function, m.Parameter(0), m.Parameter(1))); FOR_INT32_INPUTS(i) { int32_t const x = *i; FOR_INT32_INPUTS(j) { int32_t const y = *j; CHECK_EQ(x - y, m.Call(x, y)); } } } TEST(RunCallCFunction8) { auto* foo8_ptr = &foo8; RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); Node* function = m.LoadFromPointer(&foo8_ptr, MachineType::Pointer()); Node* param = m.Parameter(0); m.Return(m.CallCFunction8( MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), function, param, param, param, param, param, param, param, param)); FOR_INT32_INPUTS(i) { int32_t const x = *i; CHECK_EQ(x * 8, m.Call(x)); } } #endif // USE_SIMULATOR #if V8_TARGET_ARCH_64_BIT // TODO(titzer): run int64 tests on all platforms when supported. TEST(RunCheckedLoadInt64) { int64_t buffer[] = {0x66bbccddeeff0011LL, 0x1122334455667788LL}; RawMachineAssemblerTester<int64_t> m(MachineType::Int32()); Node* base = m.PointerConstant(buffer); Node* index = m.Parameter(0); Node* length = m.Int32Constant(16); Node* load = m.AddNode(m.machine()->CheckedLoad(MachineType::Int64()), base, index, length); m.Return(load); CHECK_EQ(buffer[0], m.Call(0)); CHECK_EQ(buffer[1], m.Call(8)); CHECK_EQ(0, m.Call(16)); } TEST(RunCheckedStoreInt64) { const int64_t write = 0x5566778899aabbLL; const int64_t before = 0x33bbccddeeff0011LL; int64_t buffer[] = {before, before}; RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); Node* base = m.PointerConstant(buffer); Node* index = m.Parameter(0); Node* length = m.Int32Constant(16); Node* value = m.Int64Constant(write); Node* store = m.AddNode(m.machine()->CheckedStore(MachineRepresentation::kWord64), base, index, length, value); USE(store); m.Return(m.Int32Constant(11)); CHECK_EQ(11, m.Call(16)); CHECK_EQ(before, buffer[0]); CHECK_EQ(before, buffer[1]); CHECK_EQ(11, m.Call(0)); CHECK_EQ(write, buffer[0]); CHECK_EQ(before, buffer[1]); CHECK_EQ(11, m.Call(8)); CHECK_EQ(write, buffer[0]); CHECK_EQ(write, buffer[1]); } TEST(RunBitcastInt64ToFloat64) { int64_t input = 1; double output = 0.0; RawMachineAssemblerTester<int32_t> m; m.StoreToPointer( &output, MachineRepresentation::kFloat64, m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, MachineType::Int64()))); m.Return(m.Int32Constant(11)); FOR_INT64_INPUTS(i) { input = *i; CHECK_EQ(11, m.Call()); double expected = bit_cast<double>(input); CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output)); } } TEST(RunBitcastFloat64ToInt64) { BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); m.Return(m.BitcastFloat64ToInt64(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { CHECK_EQ(bit_cast<int64_t>(*i), m.Call(*i)); } } TEST(RunTryTruncateFloat32ToInt64WithoutCheck) { BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float32()); m.Return(m.TryTruncateFloat32ToInt64(m.Parameter(0))); FOR_INT64_INPUTS(i) { float input = static_cast<float>(*i); if (input < 9223372036854775808.0 && input > -9223372036854775809.0) { CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); } } } TEST(RunTryTruncateFloat32ToInt64WithCheck) { int64_t success = 0; BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float32()); Node* trunc = m.TryTruncateFloat32ToInt64(m.Parameter(0)); Node* val = m.Projection(0, trunc); Node* check = m.Projection(1, trunc); m.StoreToPointer(&success, MachineRepresentation::kWord64, check); m.Return(val); FOR_FLOAT32_INPUTS(i) { if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); CHECK_NE(0, success); } else { m.Call(*i); CHECK_EQ(0, success); } } } TEST(RunTryTruncateFloat64ToInt64WithoutCheck) { BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0))); FOR_INT64_INPUTS(i) { double input = static_cast<double>(*i); CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); } } TEST(RunTryTruncateFloat64ToInt64WithCheck) { int64_t success = 0; BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0)); Node* val = m.Projection(0, trunc); Node* check = m.Projection(1, trunc); m.StoreToPointer(&success, MachineRepresentation::kWord64, check); m.Return(val); FOR_FLOAT64_INPUTS(i) { if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { // Conversions within this range should succeed. CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); CHECK_NE(0, success); } else { m.Call(*i); CHECK_EQ(0, success); } } } TEST(RunTruncateFloat32ToUint64) { BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float32()); m.Return(m.TryTruncateFloat32ToUint64(m.Parameter(0))); FOR_UINT64_INPUTS(i) { float input = static_cast<float>(*i); if (input < 18446744073709551616.0) { CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); } } FOR_FLOAT32_INPUTS(j) { if (*j < 18446744073709551616.0 && *j >= 0) { CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j)); } } } TEST(RunTryTruncateFloat32ToUint64WithCheck) { int64_t success = 0; BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float32()); Node* trunc = m.TryTruncateFloat32ToUint64(m.Parameter(0)); Node* val = m.Projection(0, trunc); Node* check = m.Projection(1, trunc); m.StoreToPointer(&success, MachineRepresentation::kWord64, check); m.Return(val); FOR_FLOAT32_INPUTS(i) { if (*i < 18446744073709551616.0 && *i >= 0.0) { // Conversions within this range should succeed. CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i)); CHECK_NE(0, success); } else { m.Call(*i); CHECK_EQ(0, success); } } } TEST(RunTryTruncateFloat64ToUint64WithoutCheck) { BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float64()); m.Return(m.TruncateFloat64ToUint64(m.Parameter(0))); FOR_UINT64_INPUTS(j) { double input = static_cast<double>(*j); if (input < 18446744073709551616.0) { CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); } } } TEST(RunTryTruncateFloat64ToUint64WithCheck) { int64_t success = 0; BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); Node* trunc = m.TryTruncateFloat64ToUint64(m.Parameter(0)); Node* val = m.Projection(0, trunc); Node* check = m.Projection(1, trunc); m.StoreToPointer(&success, MachineRepresentation::kWord64, check); m.Return(val); FOR_FLOAT64_INPUTS(i) { if (*i < 18446744073709551616.0 && *i >= 0) { // Conversions within this range should succeed. CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i)); CHECK_NE(0, success); } else { m.Call(*i); CHECK_EQ(0, success); } } } TEST(RunRoundInt64ToFloat32) { BufferedRawMachineAssemblerTester<float> m(MachineType::Int64()); m.Return(m.RoundInt64ToFloat32(m.Parameter(0))); FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), m.Call(*i)); } } TEST(RunRoundInt64ToFloat64) { BufferedRawMachineAssemblerTester<double> m(MachineType::Int64()); m.Return(m.RoundInt64ToFloat64(m.Parameter(0))); FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), m.Call(*i)); } } TEST(RunRoundUint64ToFloat64) { struct { uint64_t input; uint64_t expected; } values[] = {{0x0, 0x0}, {0x1, 0x3ff0000000000000}, {0xffffffff, 0x41efffffffe00000}, {0x1b09788b, 0x41bb09788b000000}, {0x4c5fce8, 0x419317f3a0000000}, {0xcc0de5bf, 0x41e981bcb7e00000}, {0x2, 0x4000000000000000}, {0x3, 0x4008000000000000}, {0x4, 0x4010000000000000}, {0x5, 0x4014000000000000}, {0x8, 0x4020000000000000}, {0x9, 0x4022000000000000}, {0xffffffffffffffff, 0x43f0000000000000}, {0xfffffffffffffffe, 0x43f0000000000000}, {0xfffffffffffffffd, 0x43f0000000000000}, {0x100000000, 0x41f0000000000000}, {0xffffffff00000000, 0x43efffffffe00000}, {0x1b09788b00000000, 0x43bb09788b000000}, {0x4c5fce800000000, 0x439317f3a0000000}, {0xcc0de5bf00000000, 0x43e981bcb7e00000}, {0x200000000, 0x4200000000000000}, {0x300000000, 0x4208000000000000}, {0x400000000, 0x4210000000000000}, {0x500000000, 0x4214000000000000}, {0x800000000, 0x4220000000000000}, {0x900000000, 0x4222000000000000}, {0x273a798e187937a3, 0x43c39d3cc70c3c9c}, {0xece3af835495a16b, 0x43ed9c75f06a92b4}, {0xb668ecc11223344, 0x43a6cd1d98224467}, {0x9e, 0x4063c00000000000}, {0x43, 0x4050c00000000000}, {0xaf73, 0x40e5ee6000000000}, {0x116b, 0x40b16b0000000000}, {0x658ecc, 0x415963b300000000}, {0x2b3b4c, 0x41459da600000000}, {0x88776655, 0x41e10eeccaa00000}, {0x70000000, 0x41dc000000000000}, {0x7200000, 0x419c800000000000}, {0x7fffffff, 0x41dfffffffc00000}, {0x56123761, 0x41d5848dd8400000}, {0x7fffff00, 0x41dfffffc0000000}, {0x761c4761eeeeeeee, 0x43dd8711d87bbbbc}, {0x80000000eeeeeeee, 0x43e00000001dddde}, {0x88888888dddddddd, 0x43e11111111bbbbc}, {0xa0000000dddddddd, 0x43e40000001bbbbc}, {0xddddddddaaaaaaaa, 0x43ebbbbbbbb55555}, {0xe0000000aaaaaaaa, 0x43ec000000155555}, {0xeeeeeeeeeeeeeeee, 0x43edddddddddddde}, {0xfffffffdeeeeeeee, 0x43efffffffbdddde}, {0xf0000000dddddddd, 0x43ee0000001bbbbc}, {0x7fffffdddddddd, 0x435ffffff7777777}, {0x3fffffaaaaaaaa, 0x434fffffd5555555}, {0x1fffffaaaaaaaa, 0x433fffffaaaaaaaa}, {0xfffff, 0x412ffffe00000000}, {0x7ffff, 0x411ffffc00000000}, {0x3ffff, 0x410ffff800000000}, {0x1ffff, 0x40fffff000000000}, {0xffff, 0x40efffe000000000}, {0x7fff, 0x40dfffc000000000}, {0x3fff, 0x40cfff8000000000}, {0x1fff, 0x40bfff0000000000}, {0xfff, 0x40affe0000000000}, {0x7ff, 0x409ffc0000000000}, {0x3ff, 0x408ff80000000000}, {0x1ff, 0x407ff00000000000}, {0x3fffffffffff, 0x42cfffffffffff80}, {0x1fffffffffff, 0x42bfffffffffff00}, {0xfffffffffff, 0x42affffffffffe00}, {0x7ffffffffff, 0x429ffffffffffc00}, {0x3ffffffffff, 0x428ffffffffff800}, {0x1ffffffffff, 0x427ffffffffff000}, {0x8000008000000000, 0x43e0000010000000}, {0x8000008000000001, 0x43e0000010000000}, {0x8000000000000400, 0x43e0000000000000}, {0x8000000000000401, 0x43e0000000000001}}; BufferedRawMachineAssemblerTester<double> m(MachineType::Uint64()); m.Return(m.RoundUint64ToFloat64(m.Parameter(0))); for (size_t i = 0; i < arraysize(values); i++) { CHECK_EQ(bit_cast<double>(values[i].expected), m.Call(values[i].input)); } } TEST(RunRoundUint64ToFloat32) { struct { uint64_t input; uint32_t expected; } values[] = {{0x0, 0x0}, {0x1, 0x3f800000}, {0xffffffff, 0x4f800000}, {0x1b09788b, 0x4dd84bc4}, {0x4c5fce8, 0x4c98bf9d}, {0xcc0de5bf, 0x4f4c0de6}, {0x2, 0x40000000}, {0x3, 0x40400000}, {0x4, 0x40800000}, {0x5, 0x40a00000}, {0x8, 0x41000000}, {0x9, 0x41100000}, {0xffffffffffffffff, 0x5f800000}, {0xfffffffffffffffe, 0x5f800000}, {0xfffffffffffffffd, 0x5f800000}, {0x0, 0x0}, {0x100000000, 0x4f800000}, {0xffffffff00000000, 0x5f800000}, {0x1b09788b00000000, 0x5dd84bc4}, {0x4c5fce800000000, 0x5c98bf9d}, {0xcc0de5bf00000000, 0x5f4c0de6}, {0x200000000, 0x50000000}, {0x300000000, 0x50400000}, {0x400000000, 0x50800000}, {0x500000000, 0x50a00000}, {0x800000000, 0x51000000}, {0x900000000, 0x51100000}, {0x273a798e187937a3, 0x5e1ce9e6}, {0xece3af835495a16b, 0x5f6ce3b0}, {0xb668ecc11223344, 0x5d3668ed}, {0x9e, 0x431e0000}, {0x43, 0x42860000}, {0xaf73, 0x472f7300}, {0x116b, 0x458b5800}, {0x658ecc, 0x4acb1d98}, {0x2b3b4c, 0x4a2ced30}, {0x88776655, 0x4f087766}, {0x70000000, 0x4ee00000}, {0x7200000, 0x4ce40000}, {0x7fffffff, 0x4f000000}, {0x56123761, 0x4eac246f}, {0x7fffff00, 0x4efffffe}, {0x761c4761eeeeeeee, 0x5eec388f}, {0x80000000eeeeeeee, 0x5f000000}, {0x88888888dddddddd, 0x5f088889}, {0xa0000000dddddddd, 0x5f200000}, {0xddddddddaaaaaaaa, 0x5f5dddde}, {0xe0000000aaaaaaaa, 0x5f600000}, {0xeeeeeeeeeeeeeeee, 0x5f6eeeef}, {0xfffffffdeeeeeeee, 0x5f800000}, {0xf0000000dddddddd, 0x5f700000}, {0x7fffffdddddddd, 0x5b000000}, {0x3fffffaaaaaaaa, 0x5a7fffff}, {0x1fffffaaaaaaaa, 0x59fffffd}, {0xfffff, 0x497ffff0}, {0x7ffff, 0x48ffffe0}, {0x3ffff, 0x487fffc0}, {0x1ffff, 0x47ffff80}, {0xffff, 0x477fff00}, {0x7fff, 0x46fffe00}, {0x3fff, 0x467ffc00}, {0x1fff, 0x45fff800}, {0xfff, 0x457ff000}, {0x7ff, 0x44ffe000}, {0x3ff, 0x447fc000}, {0x1ff, 0x43ff8000}, {0x3fffffffffff, 0x56800000}, {0x1fffffffffff, 0x56000000}, {0xfffffffffff, 0x55800000}, {0x7ffffffffff, 0x55000000}, {0x3ffffffffff, 0x54800000}, {0x1ffffffffff, 0x54000000}, {0x8000008000000000, 0x5f000000}, {0x8000008000000001, 0x5f000001}, {0x8000000000000400, 0x5f000000}, {0x8000000000000401, 0x5f000000}}; BufferedRawMachineAssemblerTester<float> m(MachineType::Uint64()); m.Return(m.RoundUint64ToFloat32(m.Parameter(0))); for (size_t i = 0; i < arraysize(values); i++) { CHECK_EQ(bit_cast<float>(values[i].expected), m.Call(values[i].input)); } } #endif TEST(RunBitcastFloat32ToInt32) { float input = 32.25; RawMachineAssemblerTester<int32_t> m; m.Return(m.BitcastFloat32ToInt32( m.LoadFromPointer(&input, MachineType::Float32()))); FOR_FLOAT32_INPUTS(i) { input = *i; int32_t expected = bit_cast<int32_t>(input); CHECK_EQ(expected, m.Call()); } } TEST(RunBitcastInt32ToFloat32) { int32_t input = 1; float output = 0.0; RawMachineAssemblerTester<int32_t> m; m.StoreToPointer( &output, MachineRepresentation::kFloat32, m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32()))); m.Return(m.Int32Constant(11)); FOR_INT32_INPUTS(i) { input = *i; CHECK_EQ(11, m.Call()); float expected = bit_cast<float>(input); CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); } } TEST(RunComputedCodeObject) { GraphBuilderTester<int32_t> a; a.Return(a.Int32Constant(33)); a.End(); Handle<Code> code_a = a.GetCode(); GraphBuilderTester<int32_t> b; b.Return(b.Int32Constant(44)); b.End(); Handle<Code> code_b = b.GetCode(); RawMachineAssemblerTester<int32_t> r(MachineType::Int32()); RawMachineLabel tlabel; RawMachineLabel flabel; RawMachineLabel merge; r.Branch(r.Parameter(0), &tlabel, &flabel); r.Bind(&tlabel); Node* fa = r.HeapConstant(code_a); r.Goto(&merge); r.Bind(&flabel); Node* fb = r.HeapConstant(code_b); r.Goto(&merge); r.Bind(&merge); Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); // TODO(titzer): all this descriptor hackery is just to call the above // functions as code objects instead of direct addresses. CSignature0<int32_t> sig; CallDescriptor* c = Linkage::GetSimplifiedCDescriptor(r.zone(), &sig); LinkageLocation ret[] = {c->GetReturnLocation(0)}; Signature<LinkageLocation> loc(1, 0, ret); CallDescriptor* desc = new (r.zone()) CallDescriptor( // -- CallDescriptor::kCallCodeObject, // kind MachineType::AnyTagged(), // target_type c->GetInputLocation(0), // target_loc &sig, // machine_sig &loc, // location_sig 0, // stack count Operator::kNoProperties, // properties c->CalleeSavedRegisters(), // callee saved c->CalleeSavedFPRegisters(), // callee saved FP CallDescriptor::kNoFlags, // flags "c-call-as-code"); Node* call = r.AddNode(r.common()->Call(desc), phi); r.Return(call); CHECK_EQ(33, r.Call(1)); CHECK_EQ(44, r.Call(0)); } } // namespace compiler } // namespace internal } // namespace v8
[ "szcdanteng@gmail.com" ]
szcdanteng@gmail.com
942b07ffe4e176eb00ea7897f5c6c02b9168ae93
bc84c328d1cc2a318160d42ed1faa1961bdf1e87
/books/C++_advanced_programming/code/Chapter1/enumTest.cpp
5307f70dc6fc16ba22df6def3e7ada10a51b95ac
[ "MIT" ]
permissive
liangjisheng/C-Cpp
25d07580b5dd1ff364087c3cf8e13cebdc9280a5
8b33ba1f43580a7bdded8bb4ce3d92983ccedb81
refs/heads/master
2021-07-10T14:40:20.006051
2019-01-26T09:24:04
2019-01-26T09:24:04
136,299,205
7
2
null
null
null
null
GB18030
C++
false
false
1,158
cpp
#include <iostream> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ // PieceTypeKing的值为 0 ,定义了PieceType类型,并指定了PieceType类型变量可能具有的值 enum PieceType { PieceTypeKing,PieceTypeQueen,PieceTypeRook,PieceTypePawn }; // 上面给出的枚举并不是强类型的,意味着其并非类型安全。他们总被解释为整形数据, // 因此可以比较完全不同类型中的枚举值,enum class解决了这些问题 enum class MyEnum{ EnumValue1, EnumValue2 = 10, EnumValue3 }; // MyEnum 是一个类型安全的枚举,枚举名称不会自动超出封闭的作用域,这表示总是要使用 // 作用域解析操作符 MyEnum value1 = MyEnum::EnumValue1; // 默认情况下,枚举值的基本类型是整形,但可以采用以下方式加以改变 enum class MyEnumLong : unsigned long{ EnumValueLong1, EnumValueLong2 = 10, EnumValueLong3 }; int main(int argc, char** argv) { PieceType MyPiece; MyPiece = PieceTypeKing; cout<<MyPiece<<endl; std::cout<<"asdf"<<std::endl; system("pause"); return 0; }
[ "1294851990@qq.com" ]
1294851990@qq.com
60eb2eb4be294e2600b006ea948ec976d64c4a8b
458d19a137f653fcdffdcfaf16ca5839de8010f6
/1068/1068.cpp
665d883d84d7b23ab08610fbce3e1fb9c82b59f0
[]
no_license
danvyr/myacmjudge
a9443315415b6ca80d862eaac514bcb9aacad2af
b4cd065962284bcdc465f2d3cb0aae4cadd76d7b
refs/heads/master
2021-01-20T21:00:37.813468
2011-11-24T09:35:05
2011-11-24T09:35:05
2,842,201
0
0
null
null
null
null
UTF-8
C++
false
false
210
cpp
#include <iostream> int main() { int a,sum=1; std::cin >> a; if (a<0) for(int i=a;i<1;i++) sum+=i; else for(int i=a;i>1;i--) sum+=i; std::cout << sum << std::endl; return 0; }
[ "danvyr@gmail.com" ]
danvyr@gmail.com
8a4c2e82ded608ff8036696c8f925f30797b6f8b
a2ce5d2041ae55b61f9de89ce111bdd61dca64a5
/src/export_lookup.cpp
877d44169c6342c3a93bd77deff5691a038cb6b5
[]
no_license
pinchyCZN/objconv
218792f6b72c33753167096000bf7bd0a7bfd4b1
dc0143fa3764c271fe0c5cfdaf93fc0a31675122
refs/heads/master
2021-10-27T19:07:09.973584
2019-04-19T03:01:45
2019-04-19T03:01:45
111,463,951
0
0
null
null
null
null
UTF-8
C++
false
false
69,038
cpp
#include <string.h> #include <stdio.h> #pragma warning(disable:4996) static char *export_list[]={ "_AbortSystemShutdownA@4", "_AbortSystemShutdownW@4", "_AccessCheck@32", "_AccessCheckAndAuditAlarmA@44", "_AccessCheckAndAuditAlarmW@44", "_AccessCheckByType@44", "_AccessCheckByTypeAndAuditAlarmA@64", "_AccessCheckByTypeAndAuditAlarmW@64", "_AccessCheckByTypeResultList@44", "_AccessCheckByTypeResultListAndAuditAlarmA@64", "_AccessCheckByTypeResultListAndAuditAlarmW@64", "_AddAccessAllowedAce@16", "_AddAccessAllowedAceEx@20", "_AddAccessAllowedObjectAce@28", "_AddAccessDeniedAce@16", "_AddAccessDeniedAceEx@20", "_AddAccessDeniedObjectAce@28", "_AddAce@20", "_AddAuditAccessAce@24", "_AddAuditAccessAceEx@28", "_AddAuditAccessObjectAce@36", "_AddUsersToEncryptedFile@8", "_AdjustTokenGroups@24", "_AdjustTokenPrivileges@24", "_AllocateAndInitializeSid@44", "_AllocateLocallyUniqueId@4", "_AreAllAccessesGranted@8", "_AreAnyAccessesGranted@8", "_BackupEventLogA@8", "_BackupEventLogW@8", "_BuildExplicitAccessWithNameA@20", "_BuildExplicitAccessWithNameW@20", "_BuildImpersonateExplicitAccessWithNameA@24", "_BuildImpersonateExplicitAccessWithNameW@24", "_BuildImpersonateTrusteeA@8", "_BuildImpersonateTrusteeW@8", "_BuildSecurityDescriptorA@36", "_BuildSecurityDescriptorW@36", "_BuildTrusteeWithNameA@8", "_BuildTrusteeWithNameW@8", "_BuildTrusteeWithSidA@8", "_BuildTrusteeWithSidW@8", "_CancelOverlappedAccess@4", "_ChangeServiceConfig2A@12", "_ChangeServiceConfig2W@12", "_ChangeServiceConfigA@44", "_ChangeServiceConfigW@44", "_CheckTokenMembership@12", "_ClearEventLogA@8", "_ClearEventLogW@8", "_CloseEventLog@4", "_CloseRaw@4", "_CloseServiceHandle@4", "_ControlService@12", "_ConvertAccessToSecurityDescriptorA@20", "_ConvertAccessToSecurityDescriptorW@20", "_ConvertSecurityDescriptorToAccessA@28", "_ConvertSecurityDescriptorToAccessNamedA@28", "_ConvertSecurityDescriptorToAccessNamedW@28", "_ConvertSecurityDescriptorToAccessW@28", "_ConvertSecurityDescriptorToStringSecurityDescriptorA@12", "_ConvertSecurityDescriptorToStringSecurityDescriptorW@12", "_ConvertSidToStringSidA@8", "_ConvertSidToStringSidW@8", "_ConvertStringSecurityDescriptorToSecurityDescriptorA@16", "_ConvertStringSecurityDescriptorToSecurityDescriptorW@16", "_ConvertStringSidToSidA@8", "_ConvertStringSidToSidW@8", "_ConvertToAutoInheritPrivateObjectSecurity@24", "_CopySid@12", "_CreatePrivateObjectSecurity@24", "_CreatePrivateObjectSecurityEx@32", "_CreateProcessAsUserA@44", "_CreateProcessAsUserW@44", "_CreateProcessWithLogonW@40", "_CreateRestrictedToken@36", "_CreateServiceA@52", "_CreateServiceW@52", "_CryptAcquireContextA@20", "_CryptAcquireContextW@20", "_CryptContextAddRef@12", "_CryptCreateHash@20", "_CryptDecrypt@24", "_CryptDeriveKey@20", "_CryptDestroyHash@4", "_CryptDestroyKey@4", "_CryptDuplicateHash@16", "_CryptDuplicateKey@16", "_CryptEncrypt@28", "_CryptEnumProviderTypesA@24", "_CryptEnumProviderTypesW@24", "_CryptEnumProvidersA@24", "_CryptEnumProvidersW@24", "_CryptExportKey@24", "_CryptGenKey@16", "_CryptGenRandom@12", "_CryptGetDefaultProviderA@20", "_CryptGetDefaultProviderW@20", "_CryptGetHashParam@20", "_CryptGetKeyParam@20", "_CryptGetProvParam@20", "_CryptGetUserKey@12", "_CryptHashData@16", "_CryptHashSessionKey@12", "_CryptImportKey@24", "_CryptReleaseContext@8", "_CryptSetHashParam@16", "_CryptSetKeyParam@16", "_CryptSetProvParam@16", "_CryptSetProviderA@8", "_CryptSetProviderExA@16", "_CryptSetProviderExW@16", "_CryptSetProviderW@8", "_CryptSignHashA@24", "_CryptSignHashW@24", "_CryptVerifySignatureA@24", "_CryptVerifySignatureW@24", "_DecryptFileA@8", "_DecryptFileW@8", "_DeleteAce@8", "_DeleteService@4", "_DeregisterEventSource@4", "_DestroyPrivateObjectSecurity@4", "_DuplicateToken@12", "_DuplicateTokenEx@24", "_ElfBackupEventLogFileA@8", "_ElfBackupEventLogFileW@8", "_ElfChangeNotify@8", "_ElfClearEventLogFileA@8", "_ElfClearEventLogFileW@8", "_ElfCloseEventLog@4", "_ElfDeregisterEventSource@4", "_ElfNumberOfRecords@8", "_ElfOldestRecord@8", "_ElfOpenBackupEventLogA@12", "_ElfOpenBackupEventLogW@12", "_ElfOpenEventLogA@12", "_ElfOpenEventLogW@12", "_ElfReadEventLogA@28", "_ElfReadEventLogW@28", "_ElfRegisterEventSourceA@12", "_ElfRegisterEventSourceW@12", "_ElfReportEventA@48", "_ElfReportEventW@48", "_EncryptFileA@4", "_EncryptFileW@4", "_EnumDependentServicesA@24", "_EnumDependentServicesW@24", "_EnumServiceGroupW@36", "_EnumServicesStatusA@32", "_EnumServicesStatusW@32", "_EqualPrefixSid@8", "_EqualSid@8", "_FileEncryptionStatusA@8", "_FileEncryptionStatusW@8", "_FindFirstFreeAce@8", "_FreeEncryptionCertificateHashList@4", "_FreeSid@4", "_GetAccessPermissionsForObjectA@36", "_GetAccessPermissionsForObjectW@36", "_GetAce@12", "_GetAclInformation@16", "_GetAuditedPermissionsFromAclA@16", "_GetAuditedPermissionsFromAclW@16", "_GetCurrentHwProfileA@4", "_GetCurrentHwProfileW@4", "_GetEffectiveRightsFromAclA@12", "_GetEffectiveRightsFromAclW@12", "_GetExplicitEntriesFromAclA@12", "_GetExplicitEntriesFromAclW@12", "_GetFileSecurityA@20", "_GetFileSecurityW@20", "_GetKernelObjectSecurity@20", "_GetLengthSid@4", "_GetMultipleTrusteeA@4", "_GetMultipleTrusteeOperationA@4", "_GetMultipleTrusteeOperationW@4", "_GetMultipleTrusteeW@4", "_GetNamedSecurityInfoA@32", "_GetNamedSecurityInfoExA@36", "_GetNamedSecurityInfoExW@36", "_GetNamedSecurityInfoW@32", "_GetNumberOfEventLogRecords@8", "_GetOldestEventLogRecord@8", "_GetOverlappedAccessResults@16", "_GetPrivateObjectSecurity@20", "_GetSecurityDescriptorControl@12", "_GetSecurityDescriptorDacl@16", "_GetSecurityDescriptorGroup@12", "_GetSecurityDescriptorLength@4", "_GetSecurityDescriptorOwner@12", "_GetSecurityDescriptorSacl@16", "_GetSecurityInfo@32", "_GetSecurityInfoExA@36", "_GetSecurityInfoExW@36", "_GetServiceDisplayNameA@16", "_GetServiceDisplayNameW@16", "_GetServiceKeyNameA@16", "_GetServiceKeyNameW@16", "_GetSidIdentifierAuthority@4", "_GetSidLengthRequired@4", "_GetSidSubAuthority@8", "_GetSidSubAuthorityCount@4", "_GetSiteDirectoryA@12", "_GetSiteDirectoryW@12", "_GetSiteNameFromSid@8", "_GetSiteSidFromToken@4", "_GetSiteSidFromUrl@4", "_GetTokenInformation@20", "_GetTrusteeFormA@4", "_GetTrusteeFormW@4", "_GetTrusteeNameA@4", "_GetTrusteeNameW@4", "_GetTrusteeTypeA@4", "_GetTrusteeTypeW@4", "_GetUserNameA@8", "_GetUserNameW@8", "_I_ScSetServiceBitsA@20", "_I_ScSetServiceBitsW@20", "_ImpersonateLoggedOnUser@4", "_ImpersonateNamedPipeClient@4", "_ImpersonateSelf@4", "_InitializeAcl@12", "_InitializeSecurityDescriptor@8", "_InitializeSid@12", "_InitiateSystemShutdownA@20", "_InitiateSystemShutdownW@20", "_IsProcessRestricted@0", "_IsTextUnicode@12", "_IsTokenRestricted@4", "_IsValidAcl@4", "_IsValidSecurityDescriptor@4", "_IsValidSid@4", "_LockServiceDatabase@4", "_LogonUserA@24", "_LogonUserW@24", "_LookupAccountNameA@28", "_LookupAccountNameW@28", "_LookupAccountSidA@28", "_LookupAccountSidW@28", "_LookupPrivilegeDisplayNameA@20", "_LookupPrivilegeDisplayNameW@20", "_LookupPrivilegeNameA@16", "_LookupPrivilegeNameW@16", "_LookupPrivilegeValueA@12", "_LookupPrivilegeValueW@12", "_LookupSecurityDescriptorPartsA@28", "_LookupSecurityDescriptorPartsW@28", "_LsaAddAccountRights@16", "_LsaAddPrivilegesToAccount@8", "_LsaClearAuditLog@4", "_LsaClose@4", "_LsaCreateAccount@16", "_LsaCreateSecret@16", "_LsaCreateTrustedDomain@16", "_LsaCreateTrustedDomainEx@20", "_LsaDelete@4", "_LsaDeleteTrustedDomain@8", "_LsaEnumerateAccountRights@16", "_LsaEnumerateAccounts@20", "_LsaEnumerateAccountsWithUserRight@16", "_LsaEnumeratePrivileges@20", "_LsaEnumeratePrivilegesOfAccount@8", "_LsaEnumerateTrustedDomains@20", "_LsaEnumerateTrustedDomainsEx@24", "_LsaFreeMemory@4", "_LsaGetQuotasForAccount@8", "_LsaGetRemoteUserName@12", "_LsaGetSystemAccessAccount@8", "_LsaGetUserName@8", "_LsaICLookupNames@28", "_LsaICLookupSids@28", "_LsaIGetTrustedDomainAuthInfoBlobs@16", "_LsaISetTrustedDomainAuthInfoBlobs@16", "_LsaLookupNames@20", "_LsaLookupPrivilegeDisplayName@16", "_LsaLookupPrivilegeName@12", "_LsaLookupPrivilegeValue@12", "_LsaLookupSids@20", "_LsaNtStatusToWinError@4", "_LsaOpenAccount@16", "_LsaOpenPolicy@16", "_LsaOpenSecret@16", "_LsaOpenTrustedDomain@16", "_LsaQueryDomainInformationPolicy@12", "_LsaQueryInfoTrustedDomain@12", "_LsaQueryInformationPolicy@12", "_LsaQuerySecret@20", "_LsaQuerySecurityObject@12", "_LsaQueryTrustedDomainInfo@16", "_LsaQueryTrustedDomainInfoByName@16", "_LsaRemoveAccountRights@20", "_LsaRemovePrivilegesFromAccount@12", "_LsaRetrievePrivateData@12", "_LsaSetDomainInformationPolicy@12", "_LsaSetInformationPolicy@12", "_LsaSetInformationTrustedDomain@12", "_LsaSetQuotasForAccount@8", "_LsaSetSecret@12", "_LsaSetSecurityObject@12", "_LsaSetSystemAccessAccount@8", "_LsaSetTrustedDomainInfoByName@16", "_LsaSetTrustedDomainInformation@16", "_LsaStorePrivateData@12", "_MakeAbsoluteSD@44", "_MakeSelfRelativeSD@12", "_MapGenericMask@8", "_NotifyBootConfigStatus@4", "_NotifyChangeEventLog@8", "_ObjectCloseAuditAlarmA@12", "_ObjectCloseAuditAlarmW@12", "_ObjectDeleteAuditAlarmA@12", "_ObjectDeleteAuditAlarmW@12", "_ObjectOpenAuditAlarmA@48", "_ObjectOpenAuditAlarmW@48", "_ObjectPrivilegeAuditAlarmA@24", "_ObjectPrivilegeAuditAlarmW@24", "_OpenBackupEventLogA@8", "_OpenBackupEventLogW@8", "_OpenEventLogA@8", "_OpenEventLogW@8", "_OpenProcessToken@12", "_OpenRawA@12", "_OpenRawW@12", "_OpenSCManagerA@12", "_OpenSCManagerW@12", "_OpenServiceA@12", "_OpenServiceW@12", "_OpenThreadToken@16", "_PrivilegeCheck@12", "_PrivilegedServiceAuditAlarmA@20", "_PrivilegedServiceAuditAlarmW@20", "_QueryRecoveryAgentsOnEncryptedFile@8", "_QueryServiceConfig2A@20", "_QueryServiceConfig2W@20", "_QueryServiceConfigA@16", "_QueryServiceConfigW@16", "_QueryServiceLockStatusA@16", "_QueryServiceLockStatusW@16", "_QueryServiceObjectSecurity@20", "_QueryServiceStatus@8", "_QueryUsersOnEncryptedFile@8", "_QueryWindows31FilesMigration@4", "_ReadEventLogA@28", "_ReadEventLogW@28", "_ReadRaw@12", "_RegCloseKey@4", "_RegConnectRegistryA@12", "_RegConnectRegistryW@12", "_RegCreateKeyA@12", "_RegCreateKeyExA@36", "_RegCreateKeyExW@36", "_RegCreateKeyW@12", "_RegDeleteKeyA@8", "_RegDeleteKeyW@8", "_RegDeleteValueA@8", "_RegDeleteValueW@8", "_RegEnumKeyA@16", "_RegEnumKeyExA@32", "_RegEnumKeyExW@32", "_RegEnumKeyW@16", "_RegEnumValueA@32", "_RegEnumValueW@32", "_RegFlushKey@4", "_RegGetKeySecurity@16", "_RegLoadKeyA@12", "_RegLoadKeyW@12", "_RegNotifyChangeKeyValue@20", "_RegOpenKeyA@12", "_RegOpenKeyExA@20", "_RegOpenKeyExW@20", "_RegOpenKeyW@12", "_RegOverridePredefKey@8", "_RegQueryInfoKeyA@48", "_RegQueryInfoKeyW@48", "_RegQueryMultipleValuesA@20", "_RegQueryMultipleValuesW@20", "_RegQueryValueA@16", "_RegQueryValueExA@24", "_RegQueryValueExW@24", "_RegQueryValueW@16", "_RegReplaceKeyA@16", "_RegReplaceKeyW@16", "_RegRestoreKeyA@12", "_RegRestoreKeyW@12", "_RegSaveKeyA@12", "_RegSaveKeyW@12", "_RegSetKeySecurity@12", "_RegSetValueA@20", "_RegSetValueExA@24", "_RegSetValueExW@24", "_RegSetValueW@20", "_RegUnLoadKeyA@8", "_RegUnLoadKeyW@8", "_RegisterDomainNameChangeNotification@4", "_RegisterEventSourceA@8", "_RegisterEventSourceW@8", "_RegisterServiceCtrlHandlerA@8", "_RegisterServiceCtrlHandlerW@8", "_RemoveUsersFromEncryptedFile@8", "_ReportEventA@36", "_ReportEventW@36", "_RevertToSelf@0", "_SetAclInformation@16", "_SetEntriesInAccessListA@24", "_SetEntriesInAccessListW@24", "_SetEntriesInAclA@16", "_SetEntriesInAclW@16", "_SetEntriesInAuditListA@24", "_SetEntriesInAuditListW@24", "_SetFileSecurityA@12", "_SetFileSecurityW@12", "_SetKernelObjectSecurity@12", "_SetNamedSecurityInfoA@28", "_SetNamedSecurityInfoExA@36", "_SetNamedSecurityInfoExW@36", "_SetNamedSecurityInfoW@28", "_SetPrivateObjectSecurity@20", "_SetPrivateObjectSecurityEx@24", "_SetSecurityDescriptorControl@12", "_SetSecurityDescriptorDacl@16", "_SetSecurityDescriptorGroup@12", "_SetSecurityDescriptorOwner@12", "_SetSecurityDescriptorSacl@16", "_SetSecurityInfo@28", "_SetSecurityInfoExA@36", "_SetSecurityInfoExW@36", "_SetServiceBits@16", "_SetServiceObjectSecurity@12", "_SetServiceStatus@8", "_SetThreadToken@8", "_SetTokenInformation@16", "_SetUserFileEncryptionKey@4", "_StartServiceA@12", "_StartServiceCtrlDispatcherA@4", "_StartServiceCtrlDispatcherW@4", "_StartServiceW@12", "_SynchronizeWindows31FilesAndWindowsNTRegistry@16", "_SystemFunction001@12", "_SystemFunction002@12", "_SystemFunction003@8", "_SystemFunction004@12", "_SystemFunction005@12", "_SystemFunction006@8", "_SystemFunction007@8", "_SystemFunction008@12", "_SystemFunction009@12", "_SystemFunction010@12", "_SystemFunction011@12", "_SystemFunction012@12", "_SystemFunction013@12", "_SystemFunction014@12", "_SystemFunction015@12", "_SystemFunction016@12", "_SystemFunction017@12", "_SystemFunction018@12", "_SystemFunction019@12", "_SystemFunction020@12", "_SystemFunction021@12", "_SystemFunction022@12", "_SystemFunction023@12", "_SystemFunction024@12", "_SystemFunction025@12", "_SystemFunction026@12", "_SystemFunction027@12", "_SystemFunction028@8", "_SystemFunction029@8", "_SystemFunction030@8", "_SystemFunction031@8", "_SystemFunction032@8", "_SystemFunction033@8", "_TrusteeAccessToObjectA@24", "_TrusteeAccessToObjectW@24", "_UnlockServiceDatabase@4", "_UnregisterDomainNameChangeNotification@4", "_WriteRaw@12", "_CreateMappedBitmap@20", "_CreatePropertySheetPage@4", "_CreatePropertySheetPageA@4", "_CreatePropertySheetPageW@4", "_CreateStatusWindow@16", "_CreateStatusWindowA@16", "_CreateStatusWindowW@16", "_CreateToolbar@32", "_CreateToolbarEx@52", "_CreateUpDownControl@48", "_DestroyPropertySheetPage@4", "_DrawInsert@12", "_DrawStatusText@16", "_DrawStatusTextA@16", "_DrawStatusTextW@16", "_FlatSB_EnableScrollBar@12", "_FlatSB_GetScrollInfo@12", "_FlatSB_GetScrollPos@8", "_FlatSB_GetScrollProp@12", "_FlatSB_GetScrollRange@16", "_FlatSB_SetScrollInfo@16", "_FlatSB_SetScrollPos@16", "_FlatSB_SetScrollProp@16", "_FlatSB_SetScrollRange@20", "_FlatSB_ShowScrollBar@12", "_GetEffectiveClientRect@12", "_ImageList_Add@12", "_ImageList_AddIcon@8", "_ImageList_AddMasked@12", "_ImageList_BeginDrag@16", "_ImageList_Copy@20", "_ImageList_Create@20", "_ImageList_Destroy@4", "_ImageList_DragEnter@12", "_ImageList_DragLeave@4", "_ImageList_DragMove@8", "_ImageList_DragShowNolock@4", "_ImageList_Draw@24", "_ImageList_DrawEx@40", "_ImageList_DrawIndirect@4", "_ImageList_Duplicate@4", "_ImageList_EndDrag@0", "_ImageList_GetBkColor@4", "_ImageList_GetDragImage@8", "_ImageList_GetIcon@12", "_ImageList_GetIconSize@12", "_ImageList_GetImageCount@4", "_ImageList_GetImageInfo@12", "_ImageList_GetImageRect@12", "_ImageList_LoadImage@28", "_ImageList_LoadImageA@28", "_ImageList_LoadImageW@28", "_ImageList_Merge@24", "_ImageList_Read@4", "_ImageList_Remove@8", "_ImageList_Replace@16", "_ImageList_ReplaceIcon@12", "_ImageList_SetBkColor@8", "_ImageList_SetDragCursorImage@16", "_ImageList_SetFilter@12", "_ImageList_SetIconSize@12", "_ImageList_SetImageCount@8", "_ImageList_SetOverlayImage@12", "_ImageList_Write@8", "_InitCommonControls@0", "_InitCommonControlsEx@4", "_InitializeFlatSB@4", "_LBItemFromPt@16", "_MakeDragList@4", "_MenuHelp@28", "_PropertySheet@4", "_PropertySheetA@4", "_PropertySheetW@4", "_ShowHideMenuCtl@12", "_UninitializeFlatSB@4", "__TrackMouseEvent@4", "_ChooseColorA@4", "_ChooseColorW@4", "_ChooseFontA@4", "_ChooseFontW@4", "_CommDlgExtendedError@0", "_FindTextA@4", "_FindTextW@4", "_FormatCharDlgProc@16", "_GetFileTitleA@12", "_GetFileTitleW@12", "_GetOpenFileNameA@4", "_GetOpenFileNameW@4", "_GetSaveFileNameA@4", "_GetSaveFileNameW@4", "_LoadAlterBitmap@12", "_PageSetupDlgA@4", "_PageSetupDlgW@4", "_PrintDlgA@4", "_PrintDlgExA@4", "_PrintDlgExW@4", "_PrintDlgW@4", "_ReplaceTextA@4", "_ReplaceTextW@4", "_Ssync_ANSI_UNICODE_Struct_For_WOW@12", "_WantArrows@16", "_dwLBSubclass@16", "_dwOKSubclass@16", "_AcquireDDThreadLock@0", "_DDHAL32_VidMemAlloc@16", "_DDHAL32_VidMemFree@12", "_DDInternalLock@8", "_DDInternalUnlock@4", "_DSoundHelp@12", "_DirectDrawCreate@12", "_DirectDrawCreateClipper@12", "_DirectDrawEnumerateA@8", "_DirectDrawEnumerateW@8", "_GetSurfaceFromDC@12", "_ReleaseDDThreadLock@0", "_VidMemAlloc@12", "_VidMemAmountFree@4", "_VidMemFini@4", "_VidMemFree@8", "_VidMemInit@20", "_VidMemLargestFree@4", "_DirectPlayCreate@12", "_DirectPlayEnumerate@8", "_DirectPlayEnumerateA@8", "_DirectPlayEnumerateW@8", "_DirectPlayLobbyCreateA@20", "_DirectPlayLobbyCreateW@20", "_gdwDPlaySPRefCount", "_AbortDoc@4", "_AbortPath@4", "_AddFontMemResourceEx@16", "_AddFontResourceA@4", "_AddFontResourceExA@12", "_AddFontResourceExW@12", "_AddFontResourceW@4", "_AngleArc@24", "_AnimatePalette@16", "_Arc@36", "_ArcTo@36", "_BeginPath@4", "_BitBlt@36", "_CancelDC@4", "_CheckColorsInGamut@16", "_ChoosePixelFormat@8", "_Chord@36", "_CloseEnhMetaFile@4", "_CloseFigure@4", "_CloseMetaFile@4", "_ColorCorrectPalette@16", "_ColorMatchToTarget@12", "_CombineRgn@16", "_CombineTransform@12", "_CopyEnhMetaFileA@8", "_CopyEnhMetaFileW@8", "_CopyMetaFileA@8", "_CopyMetaFileW@8", "_CreateBitmap@20", "_CreateBitmapIndirect@4", "_CreateBrushIndirect@4", "_CreateColorSpaceA@4", "_CreateColorSpaceW@4", "_CreateCompatibleBitmap@12", "_CreateCompatibleDC@4", "_CreateDCA@16", "_CreateDCW@16", "_CreateDIBPatternBrush@8", "_CreateDIBPatternBrushPt@8", "_CreateDIBSection@24", "_CreateDIBitmap@24", "_CreateDiscardableBitmap@12", "_CreateEllipticRgn@16", "_CreateEllipticRgnIndirect@4", "_CreateEnhMetaFileA@16", "_CreateEnhMetaFileW@16", "_CreateFontA@56", "_CreateFontIndirectA@4", "_CreateFontIndirectExA@4", "_CreateFontIndirectExW@4", "_CreateFontIndirectW@4", "_CreateFontW@56", "_CreateHalftonePalette@4", "_CreateHatchBrush@8", "_CreateICA@16", "_CreateICW@16", "_CreateMetaFileA@4", "_CreateMetaFileW@4", "_CreatePalette@4", "_CreatePatternBrush@4", "_CreatePen@12", "_CreatePenIndirect@4", "_CreatePolyPolygonRgn@16", "_CreatePolygonRgn@12", "_CreateRectRgn@16", "_CreateRectRgnIndirect@4", "_CreateRoundRectRgn@24", "_CreateScalableFontResourceA@16", "_CreateScalableFontResourceW@16", "_CreateSolidBrush@4", "_DPtoLP@12", "_DeleteColorSpace@4", "_DeleteDC@4", "_DeleteEnhMetaFile@4", "_DeleteMetaFile@4", "_DeleteObject@4", "_DescribePixelFormat@16", "_DeviceCapabilitiesExA@24", "_DeviceCapabilitiesExW@24", "_DrawEscape@16", "_Ellipse@20", "_EnableEUDC@4", "_EndDoc@4", "_EndFormPage@4", "_EndPage@4", "_EndPath@4", "_EnumEnhMetaFile@20", "_EnumFontFamiliesA@16", "_EnumFontFamiliesExA@20", "_EnumFontFamiliesExW@20", "_EnumFontFamiliesW@16", "_EnumFontsA@16", "_EnumFontsW@16", "_EnumICMProfilesA@12", "_EnumICMProfilesW@12", "_EnumMetaFile@16", "_EnumObjects@16", "_EqualRgn@8", "_Escape@20", "_EudcLoadLinkW@16", "_EudcUnloadLinkW@8", "_ExcludeClipRect@20", "_ExtCreatePen@20", "_ExtCreateRegion@12", "_ExtEscape@24", "_ExtFloodFill@20", "_ExtSelectClipRgn@12", "_ExtTextOutA@32", "_ExtTextOutW@32", "_FillPath@4", "_FillRgn@12", "_FixBrushOrgEx@16", "_FlattenPath@4", "_FloodFill@16", "_FrameRgn@20", "_GdiArtificialDecrementDriver@8", "_GdiComment@12", "_GdiDeleteSpoolFileHandle@4", "_GdiEndDocEMF@4", "_GdiEndPageEMF@8", "_GdiFlush@0", "_GdiGetBatchLimit@0", "_GdiGetDC@4", "_GdiGetDevmodeForPage@16", "_GdiGetPageCount@4", "_GdiGetPageHandle@12", "_GdiGetSpoolFileHandle@12", "_GdiPlayDCScript@24", "_GdiPlayEMF@20", "_GdiPlayJournal@20", "_GdiPlayPageEMF@16", "_GdiPlayPrivatePageEMF@12", "_GdiPlayScript@28", "_GdiResetDCEMF@8", "_GdiSetBatchLimit@4", "_GdiStartDocEMF@8", "_GdiStartPageEMF@4", "_GetArcDirection@4", "_GetAspectRatioFilterEx@8", "_GetBitmapBits@12", "_GetBitmapDimensionEx@8", "_GetBkColor@4", "_GetBkMode@4", "_GetBoundsRect@12", "_GetBrushOrgEx@8", "_GetCharABCWidthsA@16", "_GetCharABCWidthsFloatA@16", "_GetCharABCWidthsFloatW@16", "_GetCharABCWidthsI@20", "_GetCharABCWidthsW@16", "_GetCharWidth32A@16", "_GetCharWidth32W@16", "_GetCharWidthA@16", "_GetCharWidthFloatA@16", "_GetCharWidthFloatW@16", "_GetCharWidthI@20", "_GetCharWidthW@16", "_GetCharacterPlacementA@24", "_GetCharacterPlacementW@24", "_GetClipBox@8", "_GetClipRgn@8", "_GetColorAdjustment@8", "_GetColorSpace@4", "_GetCurrentObject@8", "_GetCurrentPositionEx@8", "_GetDCBrushColor@4", "_GetDCOrgEx@8", "_GetDCPenColor@4", "_GetDIBColorTable@16", "_GetDIBits@28", "_GetDeviceCaps@8", "_GetDeviceGammaRamp@8", "_GetEnhMetaFileA@4", "_GetEnhMetaFileBits@12", "_GetEnhMetaFileDescriptionA@12", "_GetEnhMetaFileDescriptionW@12", "_GetEnhMetaFileHeader@12", "_GetEnhMetaFilePaletteEntries@12", "_GetEnhMetaFilePixelFormat@12", "_GetEnhMetaFileW@4", "_GetFontAssocStatus@4", "_GetFontData@20", "_GetFontLanguageInfo@4", "_GetFontResourceInfoW@16", "_GetFontUnicodeRanges@8", "_GetGlyphIndicesA@20", "_GetGlyphIndicesW@20", "_GetGlyphOutline@28", "_GetGlyphOutlineA@28", "_GetGlyphOutlineW@28", "_GetGraphicsMode@4", "_GetICMProfileA@12", "_GetICMProfileW@12", "_GetKerningPairs@12", "_GetKerningPairsA@12", "_GetKerningPairsW@12", "_GetLayout@4", "_GetLogColorSpaceA@12", "_GetLogColorSpaceW@12", "_GetMapMode@4", "_GetMetaFileA@4", "_GetMetaFileBitsEx@12", "_GetMetaFileW@4", "_GetMetaRgn@8", "_GetMiterLimit@8", "_GetNearestColor@8", "_GetNearestPaletteIndex@8", "_GetObjectA@12", "_GetObjectType@4", "_GetObjectW@12", "_GetOutlineTextMetricsA@12", "_GetOutlineTextMetricsW@12", "_GetPaletteEntries@16", "_GetPath@16", "_GetPixel@12", "_GetPixelFormat@4", "_GetPolyFillMode@4", "_GetROP2@4", "_GetRandomRgn@12", "_GetRasterizerCaps@8", "_GetRegionData@12", "_GetRelAbs@8", "_GetRgnBox@8", "_GetStockObject@4", "_GetStretchBltMode@4", "_GetSystemPaletteEntries@16", "_GetSystemPaletteUse@4", "_GetTextAlign@4", "_GetTextCharacterExtra@4", "_GetTextCharset@4", "_GetTextCharsetInfo@12", "_GetTextColor@4", "_GetTextExtentExPointA@28", "_GetTextExtentExPointI@28", "_GetTextExtentExPointW@28", "_GetTextExtentPoint32A@16", "_GetTextExtentPoint32W@16", "_GetTextExtentPointA@16", "_GetTextExtentPointI@16", "_GetTextExtentPointW@16", "_GetTextFaceA@12", "_GetTextFaceW@12", "_GetTextMetricsA@8", "_GetTextMetricsW@8", "_GetViewportExtEx@8", "_GetViewportOrgEx@8", "_GetWinMetaFileBits@20", "_GetWindowExtEx@8", "_GetWindowOrgEx@8", "_GetWorldTransform@8", "_IntersectClipRect@20", "_InvertRgn@8", "_LPtoDP@12", "_LineDDA@24", "_LineTo@12", "_MaskBlt@48", "_ModifyWorldTransform@12", "_MoveToEx@16", "_OffsetClipRgn@12", "_OffsetRgn@12", "_OffsetViewportOrgEx@16", "_OffsetWindowOrgEx@16", "_PaintRgn@8", "_PatBlt@24", "_PathToRegion@4", "_Pie@36", "_PlayEnhMetaFile@12", "_PlayEnhMetaFileRecord@16", "_PlayMetaFile@8", "_PlayMetaFileRecord@16", "_PlgBlt@40", "_PolyBezier@12", "_PolyBezierTo@12", "_PolyDraw@16", "_PolyPatBlt@20", "_PolyPolygon@16", "_PolyPolyline@16", "_PolyTextOutA@12", "_PolyTextOutW@12", "_Polygon@12", "_Polyline@12", "_PolylineTo@12", "_PtInRegion@12", "_PtVisible@12", "_RealizePalette@4", "_RectInRegion@8", "_RectVisible@8", "_Rectangle@20", "_RemoveFontMemResourceEx@4", "_RemoveFontResourceA@4", "_RemoveFontResourceExA@12", "_RemoveFontResourceExW@12", "_RemoveFontResourceW@4", "_ResetDCA@8", "_ResetDCW@8", "_ResizePalette@8", "_RestoreDC@8", "_RoundRect@28", "_SaveDC@4", "_ScaleViewportExtEx@24", "_ScaleWindowExtEx@24", "_SelectBrushLocal@8", "_SelectClipPath@8", "_SelectClipRgn@8", "_SelectFontLocal@8", "_SelectObject@8", "_SelectPalette@12", "_SetAbortProc@8", "_SetArcDirection@8", "_SetBitmapBits@12", "_SetBitmapDimensionEx@16", "_SetBkColor@8", "_SetBkMode@8", "_SetBoundsRect@12", "_SetBrushOrgEx@16", "_SetColorAdjustment@8", "_SetColorSpace@8", "_SetDCBrushColor@8", "_SetDCPenColor@8", "_SetDIBColorTable@16", "_SetDIBits@28", "_SetDIBitsToDevice@48", "_SetDeviceGammaRamp@8", "_SetEnhMetaFileBits@8", "_SetFontEnumeration@4", "_SetGraphicsMode@8", "_SetICMMode@8", "_SetICMProfileA@8", "_SetICMProfileW@8", "_SetLayout@8", "_SetMagicColors@12", "_SetMapMode@8", "_SetMapperFlags@8", "_SetMetaFileBitsEx@8", "_SetMetaRgn@4", "_SetMiterLimit@12", "_SetPaletteEntries@16", "_SetPixel@16", "_SetPixelFormat@12", "_SetPixelV@16", "_SetPolyFillMode@8", "_SetROP2@8", "_SetRectRgn@20", "_SetRelAbs@8", "_SetStretchBltMode@8", "_SetSystemPaletteUse@8", "_SetTextAlign@8", "_SetTextCharacterExtra@8", "_SetTextColor@8", "_SetTextJustification@12", "_SetViewportExtEx@16", "_SetViewportOrgEx@16", "_SetWinMetaFileBits@16", "_SetWindowExtEx@16", "_SetWindowOrgEx@16", "_SetWorldTransform@8", "_StartDocA@8", "_StartDocW@8", "_StartFormPage@4", "_StartPage@4", "_StretchBlt@44", "_StretchDIBits@52", "_StrokeAndFillPath@4", "_StrokePath@4", "_SwapBuffers@4", "_TextOutA@20", "_TextOutW@20", "_TranslateCharsetInfo@12", "_UnrealizeObject@4", "_UpdateColors@4", "_UpdateICMRegKeyA@16", "_UpdateICMRegKeyW@16", "_WidenPath@4", "_gdiPlaySpoolStream@24", "_AddAtomA@4", "_AddAtomW@4", "_AddConsoleAliasA@12", "_AddConsoleAliasW@12", "_AllocConsole@0", "_AreFileApisANSI@0", "_AssignProcessToJobObject@8", "_BackupRead@28", "_BackupSeek@24", "_BackupWrite@28", "_BaseAttachCompleteThunk@0", "_Beep@8", "_BeginUpdateResourceA@8", "_BeginUpdateResourceW@8", "_BuildCommDCBA@8", "_BuildCommDCBAndTimeoutsA@12", "_BuildCommDCBAndTimeoutsW@12", "_BuildCommDCBW@8", "_CallNamedPipeA@28", "_CallNamedPipeW@28", "_CancelIo@4", "_CancelTimerQueueTimer@8", "_CancelWaitableTimer@4", "_ChangeTimerQueueTimer@16", "_ClearCommBreak@4", "_ClearCommError@12", "_CloseConsoleHandle@4", "_CloseHandle@4", "_CloseProfileUserMapping@0", "_CmdBatNotification@4", "_CommConfigDialogA@12", "_CommConfigDialogW@12", "_CompareFileTime@8", "_CompareStringA@24", "_CompareStringW@24", "_ConnectNamedPipe@8", "_ConsoleMenuControl@12", "_ContinueDebugEvent@12", "_ConvertDefaultLocale@4", "_ConvertThreadToFiber@4", "_CopyFileA@12", "_CopyFileExA@24", "_CopyFileExW@24", "_CopyFileW@12", "_CreateConsoleScreenBuffer@20", "_CreateDirectoryA@8", "_CreateDirectoryExA@12", "_CreateDirectoryExW@12", "_CreateDirectoryW@8", "_CreateEventA@16", "_CreateEventW@16", "_CreateFiber@12", "_CreateFileA@28", "_CreateFileMappingA@24", "_CreateFileMappingW@24", "_CreateFileW@28", "_CreateHardLinkA@12", "_CreateHardLinkW@12", "_CreateIoCompletionPort@16", "_CreateJobObjectA@8", "_CreateJobObjectW@8", "_CreateMailslotA@16", "_CreateMailslotW@16", "_CreateMutexA@12", "_CreateMutexW@12", "_CreateNamedPipeA@32", "_CreateNamedPipeW@32", "_CreatePipe@16", "_CreateProcessA@40", "_CreateProcessW@40", "_CreateRemoteThread@28", "_CreateSemaphoreA@16", "_CreateSemaphoreW@16", "_CreateTapePartition@16", "_CreateThread@24", "_CreateTimerQueue@0", "_CreateToolhelp32Snapshot@8", "_CreateVirtualBuffer@12", "_CreateWaitableTimerA@12", "_CreateWaitableTimerW@12", "_DebugActiveProcess@4", "_DebugBreak@0", "_DefineDosDeviceA@12", "_DefineDosDeviceW@12", "_DeleteAtom@4", "_DeleteCriticalSection@4", "_DeleteFiber@4", "_DeleteFileA@4", "_DeleteFileW@4", "_DeleteTimerQueue@4", "_DeleteVolumeMountPointA@4", "_DeleteVolumeMountPointW@4", "_DeviceIoControl@32", "_DisableThreadLibraryCalls@4", "_DisconnectNamedPipe@4", "_DosDateTimeToFileTime@12", "_DuplicateConsoleHandle@16", "_DuplicateHandle@28", "_EndUpdateResourceA@8", "_EndUpdateResourceW@8", "_EnterCriticalSection@4", "_EnumCalendarInfoA@16", "_EnumCalendarInfoExA@16", "_EnumCalendarInfoExW@16", "_EnumCalendarInfoW@16", "_EnumDateFormatsA@12", "_EnumDateFormatsExA@12", "_EnumDateFormatsExW@12", "_EnumDateFormatsW@12", "_EnumResourceLanguagesA@20", "_EnumResourceLanguagesW@20", "_EnumResourceNamesA@16", "_EnumResourceNamesW@16", "_EnumResourceTypesA@12", "_EnumResourceTypesW@12", "_EnumSystemCodePagesA@8", "_EnumSystemCodePagesW@8", "_EnumSystemLocalesA@8", "_EnumSystemLocalesW@8", "_EnumTimeFormatsA@12", "_EnumTimeFormatsW@12", "_EraseTape@12", "_EscapeCommFunction@8", "_ExitProcess@4", "_ExitThread@4", "_ExitVDM@8", "_ExpandEnvironmentStringsA@12", "_ExpandEnvironmentStringsW@12", "_ExpungeConsoleCommandHistoryA@4", "_ExpungeConsoleCommandHistoryW@4", "_ExtendVirtualBuffer@8", "_FatalAppExitA@8", "_FatalAppExitW@8", "_FatalExit@4", "_FileTimeToDosDateTime@12", "_FileTimeToLocalFileTime@8", "_FileTimeToSystemTime@8", "_FillConsoleOutputAttribute@20", "_FillConsoleOutputCharacterA@20", "_FillConsoleOutputCharacterW@20", "_FindAtomA@4", "_FindAtomW@4", "_FindClose@4", "_FindCloseChangeNotification@4", "_FindFirstChangeNotificationA@12", "_FindFirstChangeNotificationW@12", "_FindFirstFileA@8", "_FindFirstFileExA@24", "_FindFirstFileExW@24", "_FindFirstFileW@8", "_FindFirstVolumeA@8", "_FindFirstVolumeMountPointA@12", "_FindFirstVolumeMountPointW@12", "_FindFirstVolumeW@8", "_FindNextChangeNotification@4", "_FindNextFileA@8", "_FindNextFileW@8", "_FindNextVolumeA@12", "_FindNextVolumeMountPointA@12", "_FindNextVolumeMountPointW@12", "_FindNextVolumeW@12", "_FindResourceA@12", "_FindResourceExA@16", "_FindResourceExW@16", "_FindResourceW@12", "_FindVolumeClose@4", "_FindVolumeMountPointClose@4", "_FlushConsoleInputBuffer@4", "_FlushFileBuffers@4", "_FlushInstructionCache@12", "_FlushViewOfFile@8", "_FoldStringA@20", "_FoldStringW@20", "_FormatMessageA@28", "_FormatMessageW@28", "_FreeConsole@0", "_FreeEnvironmentStringsA@4", "_FreeEnvironmentStringsW@4", "_FreeLibrary@4", "_FreeLibraryAndExitThread@8", "_FreeResource@4", "_FreeVirtualBuffer@4", "_GenerateConsoleCtrlEvent@8", "_GetACP@0", "_GetAtomNameA@12", "_GetAtomNameW@12", "_GetBinaryType@8", "_GetBinaryTypeA@8", "_GetBinaryTypeW@8", "_GetCPInfo@8", "_GetCPInfoExA@12", "_GetCPInfoExW@12", "_GetCalendarInfoA@24", "_GetCalendarInfoW@24", "_GetCommConfig@12", "_GetCommMask@8", "_GetCommModemStatus@8", "_GetCommProperties@8", "_GetCommState@8", "_GetCommTimeouts@8", "_GetCommandLineA@0", "_GetCommandLineW@0", "_GetCompressedFileSizeA@8", "_GetCompressedFileSizeW@8", "_GetComputerNameA@8", "_GetComputerNameW@8", "_GetConsoleAliasA@16", "_GetConsoleAliasExesA@8", "_GetConsoleAliasExesLengthA@0", "_GetConsoleAliasExesLengthW@0", "_GetConsoleAliasExesW@8", "_GetConsoleAliasW@16", "_GetConsoleAliasesA@12", "_GetConsoleAliasesLengthA@4", "_GetConsoleAliasesLengthW@4", "_GetConsoleAliasesW@12", "_GetConsoleCP@0", "_GetConsoleCommandHistoryA@12", "_GetConsoleCommandHistoryLengthA@4", "_GetConsoleCommandHistoryLengthW@4", "_GetConsoleCommandHistoryW@12", "_GetConsoleCursorInfo@8", "_GetConsoleDisplayMode@4", "_GetConsoleFontInfo@16", "_GetConsoleFontSize@8", "_GetConsoleHardwareState@12", "_GetConsoleInputExeNameA@8", "_GetConsoleInputExeNameW@8", "_GetConsoleInputWaitHandle@0", "_GetConsoleKeyboardLayoutNameA@4", "_GetConsoleKeyboardLayoutNameW@4", "_GetConsoleMode@8", "_GetConsoleOutputCP@0", "_GetConsoleScreenBufferInfo@8", "_GetConsoleTitleA@8", "_GetConsoleTitleW@8", "_GetConsoleWindow@0", "_GetCurrencyFormatA@24", "_GetCurrencyFormatW@24", "_GetCurrentConsoleFont@12", "_GetCurrentDirectoryA@8", "_GetCurrentDirectoryW@8", "_GetCurrentProcess@0", "_GetCurrentProcessId@0", "_GetCurrentThread@0", "_GetCurrentThreadId@0", "_GetDateFormatA@24", "_GetDateFormatW@24", "_GetDefaultCommConfigA@12", "_GetDefaultCommConfigW@12", "_GetDevicePowerState@4", "_GetDiskFreeSpaceA@20", "_GetDiskFreeSpaceExA@16", "_GetDiskFreeSpaceExW@16", "_GetDiskFreeSpaceW@20", "_GetDriveTypeA@4", "_GetDriveTypeW@4", "_GetEnvironmentStrings@0", "_GetEnvironmentStringsA@0", "_GetEnvironmentStringsW@0", "_GetEnvironmentVariableA@12", "_GetEnvironmentVariableW@12", "_GetExitCodeProcess@8", "_GetExitCodeThread@8", "_GetFileAttributesA@4", "_GetFileAttributesExA@12", "_GetFileAttributesExW@12", "_GetFileAttributesW@4", "_GetFileInformationByHandle@8", "_GetFileSize@8", "_GetFileSizeEx@8", "_GetFileTime@16", "_GetFileType@4", "_GetFullPathNameA@16", "_GetFullPathNameW@16", "_GetHandleInformation@8", "_GetLargestConsoleWindowSize@4", "_GetLastError@0", "_GetLocalTime@4", "_GetLocaleInfoA@16", "_GetLocaleInfoW@16", "_GetLogicalDriveStringsA@8", "_GetLogicalDriveStringsW@8", "_GetLogicalDrives@0", "_GetLongPathNameA@12", "_GetLongPathNameW@12", "_GetMailslotInfo@20", "_GetModuleFileNameA@12", "_GetModuleFileNameW@12", "_GetModuleHandleA@4", "_GetModuleHandleW@4", "_GetNamedPipeHandleStateA@28", "_GetNamedPipeHandleStateW@28", "_GetNamedPipeInfo@20", "_GetNextVDMCommand@4", "_GetNumberFormatA@24", "_GetNumberFormatW@24", "_GetNumberOfConsoleFonts@0", "_GetNumberOfConsoleInputEvents@8", "_GetNumberOfConsoleMouseButtons@4", "_GetOEMCP@0", "_GetOverlappedResult@16", "_GetPriorityClass@4", "_GetPrivateProfileIntA@16", "_GetPrivateProfileIntW@16", "_GetPrivateProfileSectionA@16", "_GetPrivateProfileSectionNamesA@12", "_GetPrivateProfileSectionNamesW@12", "_GetPrivateProfileSectionW@16", "_GetPrivateProfileStringA@24", "_GetPrivateProfileStringW@24", "_GetPrivateProfileStructA@20", "_GetPrivateProfileStructW@20", "_GetProcAddress@8", "_GetProcessAffinityMask@12", "_GetProcessHeap@0", "_GetProcessHeaps@8", "_GetProcessPriorityBoost@8", "_GetProcessShutdownParameters@8", "_GetProcessTimes@20", "_GetProcessVersion@4", "_GetProcessWorkingSetSize@12", "_GetProfileIntA@12", "_GetProfileIntW@12", "_GetProfileSectionA@12", "_GetProfileSectionW@12", "_GetProfileStringA@20", "_GetProfileStringW@20", "_GetQueuedCompletionStatus@20", "_GetShortPathNameA@12", "_GetShortPathNameW@12", "_GetStartupInfoA@4", "_GetStartupInfoW@4", "_GetStdHandle@4", "_GetStringTypeA@20", "_GetStringTypeExA@20", "_GetStringTypeExW@20", "_GetStringTypeW@16", "_GetSystemDefaultLCID@0", "_GetSystemDefaultLangID@0", "_GetSystemDirectoryA@8", "_GetSystemDirectoryW@8", "_GetSystemInfo@4", "_GetSystemPowerStatus@4", "_GetSystemTime@4", "_GetSystemTimeAdjustment@12", "_GetSystemTimeAsFileTime@4", "_GetTapeParameters@16", "_GetTapePosition@20", "_GetTapeStatus@4", "_GetTempFileNameA@16", "_GetTempFileNameW@16", "_GetTempPathA@8", "_GetTempPathW@8", "_GetThreadContext@8", "_GetThreadLocale@0", "_GetThreadPriority@4", "_GetThreadPriorityBoost@8", "_GetThreadSelectorEntry@12", "_GetThreadTimes@20", "_GetTickCount@0", "_GetTimeFormatA@24", "_GetTimeFormatW@24", "_GetTimeZoneInformation@4", "_GetUserDefaultLCID@0", "_GetUserDefaultLangID@0", "_GetVDMCurrentDirectories@8", "_GetVersion@0", "_GetVersionExA@4", "_GetVersionExW@4", "_GetVolumeInformationA@32", "_GetVolumeInformationW@32", "_GetVolumeNameForVolumeMountPointA@12", "_GetVolumeNameForVolumeMountPointW@12", "_GetVolumePathNameA@12", "_GetVolumePathNameW@12", "_GetWindowsDirectoryA@8", "_GetWindowsDirectoryW@8", "_GlobalAddAtomA@4", "_GlobalAddAtomW@4", "_GlobalAlloc@8", "_GlobalCompact@4", "_GlobalDeleteAtom@4", "_GlobalFindAtomA@4", "_GlobalFindAtomW@4", "_GlobalFix@4", "_GlobalFlags@4", "_GlobalFree@4", "_GlobalGetAtomNameA@12", "_GlobalGetAtomNameW@12", "_GlobalHandle@4", "_GlobalLock@4", "_GlobalMemoryStatus@4", "_GlobalMemoryStatusVlm@4", "_GlobalReAlloc@12", "_GlobalSize@4", "_GlobalUnWire@4", "_GlobalUnfix@4", "_GlobalUnlock@4", "_GlobalWire@4", "_Heap32First@12", "_Heap32ListFirst@8", "_Heap32ListNext@8", "_Heap32Next@4", "_HeapAlloc@12", "_HeapCompact@8", "_HeapCreate@12", "_HeapCreateTagsW@16", "_HeapDestroy@4", "_HeapExtend@16", "_HeapFree@12", "_HeapLock@4", "_HeapQueryTagW@20", "_HeapReAlloc@16", "_HeapSize@12", "_HeapSummary@12", "_HeapUnlock@4", "_HeapUsage@20", "_HeapValidate@12", "_HeapWalk@8", "_InitAtomTable@4", "_InitializeCriticalSection@4", "_InitializeCriticalSectionAndSpinCount@8", "_InterlockedCompareExchange@12", "_InterlockedDecrement@4", "_InterlockedExchange@8", "_InterlockedExchangeAdd@8", "_InterlockedIncrement@4", "_InvalidateConsoleDIBits@8", "_IsBadCodePtr@4", "_IsBadHugeReadPtr@8", "_IsBadHugeWritePtr@8", "_IsBadReadPtr@8", "_IsBadStringPtrA@8", "_IsBadStringPtrW@8", "_IsBadWritePtr@8", "_IsDBCSLeadByte@4", "_IsDBCSLeadByteEx@8", "_IsDebuggerPresent@0", "_IsProcessorFeaturePresent@4", "_IsValidCodePage@4", "_IsValidLocale@8", "_LCMapStringA@24", "_DirectSoundCreate@12", "_LCMapStringW@24", "_LeaveCriticalSection@4", "_LoadLibraryA@4", "_LoadLibraryExA@12", "_LoadLibraryExW@12", "_LoadLibraryW@4", "_LoadModule@8", "_LoadResource@8", "_LocalAlloc@8", "_LocalCompact@4", "_LocalFileTimeToFileTime@8", "_LocalFlags@4", "_LocalFree@4", "_LocalHandle@4", "_LocalLock@4", "_LocalReAlloc@12", "_LocalShrink@8", "_LocalSize@4", "_LocalUnlock@4", "_LockFile@20", "_LockFileEx@24", "_LockResource@4", "_MapViewOfFile@20", "_MapViewOfFileEx@24", "_MapViewOfFileVlm@28", "_Module32First@8", "_Module32FirstW@8", "_Module32Next@8", "_Module32NextW@8", "_MoveFileA@8", "_MoveFileExA@12", "_MoveFileExW@12", "_MoveFileW@8", "_MoveFileWithProgressA@20", "_MoveFileWithProgressW@20", "_MulDiv@12", "_MultiByteToWideChar@24", "_OpenConsoleW@16", "_OpenEventA@12", "_OpenEventW@12", "_OpenFile@12", "_OpenFileMappingA@12", "_OpenFileMappingW@12", "_OpenJobObjectA@12", "_OpenJobObjectW@12", "_OpenMutexA@12", "_OpenMutexW@12", "_OpenProcess@12", "_OpenProfileUserMapping@0", "_OpenSemaphoreA@12", "_OpenSemaphoreW@12", "_OpenWaitableTimerA@12", "_OpenWaitableTimerW@12", "_OutputDebugStringA@4", "_OutputDebugStringW@4", "_PeekConsoleInputA@16", "_PeekConsoleInputW@16", "_PeekNamedPipe@24", "_PostQueuedCompletionStatus@16", "_PrepareTape@12", "_Process32First@8", "_Process32FirstW@8", "_Process32Next@8", "_Process32NextW@8", "_PulseEvent@4", "_PurgeComm@8", "_QueryDosDeviceA@12", "_QueryDosDeviceW@12", "_QueryInformationJobObject@20", "_QueryPerformanceCounter@4", "_QueryPerformanceFrequency@4", "_QueryWin31IniFilesMappedToRegistry@16", "_QueueUserAPC@12", "_QueueUserWorkItem@12", "_RaiseException@16", "_ReadConsoleA@20", "_ReadConsoleInputA@16", "_ReadConsoleInputExA@20", "_ReadConsoleInputExW@20", "_ReadConsoleInputW@16", "_ReadConsoleOutputA@20", "_ReadConsoleOutputAttribute@20", "_ReadConsoleOutputCharacterA@20", "_ReadConsoleOutputCharacterW@20", "_ReadConsoleOutputW@20", "_ReadConsoleW@20", "_ReadDirectoryChangesW@32", "_ReadFile@20", "_ReadFileEx@20", "_ReadFileScatter@20", "_ReadFileVlm@20", "_ReadProcessMemory@20", "_ReadProcessMemoryVlm@20", "_RegisterConsoleVDM@44", "_RegisterWaitForInputIdle@4", "_RegisterWaitForSingleObject@16", "_RegisterWowBaseHandlers@4", "_RegisterWowExec@4", "_ReleaseMutex@4", "_ReleaseSemaphore@12", "_RemoveDirectoryA@4", "_RemoveDirectoryW@4", "_ReplaceFile@24", "_RequestWakeupLatency@4", "_ResetEvent@4", "_ResumeThread@4", "_RtlFillMemory@12", "_RtlMoveMemory@12", "_RtlUnwind@16", "_RtlZeroMemory@8", "_ScrollConsoleScreenBufferA@20", "_ScrollConsoleScreenBufferW@20", "_SearchPathA@24", "_SearchPathW@24", "_SetCalendarInfoA@16", "_SetCalendarInfoW@16", "_SetCommBreak@4", "_SetCommConfig@12", "_SetCommMask@8", "_SetCommState@8", "_SetCommTimeouts@8", "_SetComputerNameA@4", "_SetComputerNameW@4", "_SetConsoleActiveScreenBuffer@4", "_SetConsoleCP@4", "_SetConsoleCommandHistoryMode@4", "_SetConsoleCtrlHandler@8", "_SetConsoleCursor@8", "_SetConsoleCursorInfo@8", "_SetConsoleCursorPosition@8", "_SetConsoleDisplayMode@12", "_SetConsoleFont@8", "_SetConsoleHardwareState@12", "_SetConsoleIcon@4", "_SetConsoleInputExeNameA@4", "_SetConsoleInputExeNameW@4", "_SetConsoleKeyShortcuts@16", "_SetConsoleMaximumWindowSize@8", "_SetConsoleMenuClose@4", "_SetConsoleMode@8", "_SetConsoleNumberOfCommandsA@8", "_SetConsoleNumberOfCommandsW@8", "_SetConsoleOutputCP@4", "_SetConsolePalette@12", "_SetConsoleScreenBufferSize@8", "_SetConsoleTextAttribute@8", "_SetConsoleTitleA@4", "_SetConsoleTitleW@4", "_SetConsoleWindowInfo@12", "_SetCriticalSectionSpinCount@8", "_SetCurrentDirectoryA@4", "_SetCurrentDirectoryW@4", "_SetDefaultCommConfigA@12", "_SetDefaultCommConfigW@12", "_SetEndOfFile@4", "_SetEnvironmentVariableA@8", "_SetEnvironmentVariableW@8", "_SetErrorMode@4", "_SetEvent@4", "_SetFileApisToANSI@0", "_SetFileApisToOEM@0", "_SetFileAttributesA@8", "_SetFileAttributesW@8", "_SetFilePointer@16", "_SetFilePointerEx@20", "_SetFileTime@16", "_SetHandleCount@4", "_SetHandleInformation@12", "_SetInformationJobObject@16", "_SetLastConsoleEventActive@0", "_SetLastError@4", "_SetLocalTime@4", "_SetLocaleInfoA@12", "_SetLocaleInfoW@12", "_SetMailslotInfo@8", "_SetNamedPipeHandleState@16", "_SetPriorityClass@8", "_SetProcessAffinityMask@8", "_SetProcessPriorityBoost@8", "_SetProcessShutdownParameters@8", "_SetProcessWorkingSetSize@12", "_SetStdHandle@8", "_SetSystemPowerState@8", "_SetSystemTime@4", "_SetSystemTimeAdjustment@8", "_SetTapeParameters@12", "_SetTapePosition@24", "_SetThreadAffinityMask@8", "_SetThreadContext@8", "_SetThreadExecutionState@4", "_SetThreadIdealProcessor@8", "_SetThreadLocale@4", "_SetThreadPriority@8", "_SetThreadPriorityBoost@8", "_SetTimeZoneInformation@4", "_SetTimerQueueTimer@24", "_SetUnhandledExceptionFilter@4", "_SetVDMCurrentDirectories@8", "_SetVolumeLabelA@8", "_SetVolumeLabelW@8", "_SetVolumeMountPointA@8", "_SetVolumeMountPointW@8", "_SetWaitableTimer@24", "_SetupComm@12", "_ShowConsoleCursor@8", "_SignalObjectAndWait@16", "_SizeofResource@8", "_Sleep@4", "_SleepEx@8", "_SuspendThread@4", "_SwitchToFiber@4", "_SwitchToThread@0", "_SystemTimeToFileTime@8", "_SystemTimeToTzSpecificLocalTime@12", "_TerminateJobObject@8", "_TerminateProcess@8", "_TerminateThread@8", "_Thread32First@8", "_Thread32Next@8", "_TlsAlloc@0", "_TlsFree@4", "_TlsGetValue@4", "_TlsSetValue@8", "_Toolhelp32ReadProcessMemory@20", "_TransactNamedPipe@28", "_TransmitCommChar@8", "_TrimVirtualBuffer@4", "_TryEnterCriticalSection@4", "_UTRegister@28", "_UTUnRegister@4", "_UnhandledExceptionFilter@4", "_UnlockFile@20", "_UnlockFileEx@20", "_UnmapViewOfFile@4", "_UnmapViewOfFileVlm@4", "_UnregisterWait@4", "_UpdateResourceA@24", "_UpdateResourceW@24", "_VDMConsoleOperation@8", "_VDMOperationStarted@4", "_VerLanguageNameA@12", "_VerLanguageNameW@12", "_VerifyConsoleIoHandle@4", "_VirtualAlloc@16", "_VirtualAllocEx@20", "_VirtualAllocVlm@24", "_VirtualBufferExceptionHandler@12", "_VirtualFree@12", "_VirtualFreeEx@16", "_VirtualFreeVlm@20", "_VirtualLock@8", "_VirtualProtect@16", "_VirtualProtectEx@20", "_VirtualProtectVlm@24", "_VirtualQuery@12", "_VirtualQueryEx@16", "_VirtualQueryVlm@16", "_VirtualUnlock@8", "_WaitCommEvent@12", "_WaitForDebugEvent@8", "_WaitForMultipleObjects@16", "_WaitForMultipleObjectsEx@20", "_WaitForSingleObject@8", "_WaitForSingleObjectEx@12", "_WaitNamedPipeA@8", "_WaitNamedPipeW@8", "_WideCharToMultiByte@32", "_WinExec@8", "_WriteConsoleA@20", "_WriteConsoleInputA@16", "_WriteConsoleInputVDMA@16", "_WriteConsoleInputVDMW@16", "_WriteConsoleInputW@16", "_WriteConsoleOutputA@20", "_WriteConsoleOutputAttribute@20", "_WriteConsoleOutputCharacterA@20", "_WriteConsoleOutputCharacterW@20", "_WriteConsoleOutputW@20", "_WriteConsoleW@20", "_WriteFile@20", "_WriteFileEx@20", "_WriteFileGather@20", "_WriteFileVlm@20", "_WritePrivateProfileSectionA@12", "_WritePrivateProfileSectionW@12", "_WritePrivateProfileStringA@16", "_WritePrivateProfileStringW@16", "_WritePrivateProfileStructA@20", "_WritePrivateProfileStructW@20", "_WriteProcessMemory@20", "_WriteProcessMemoryVlm@20", "_WriteProfileSectionA@8", "_WriteProfileSectionW@8", "_WriteProfileStringA@12", "_WriteProfileStringW@12", "_WriteTapemark@16", "__hread@12", "__hwrite@12", "__lclose@4", "__lcreat@8", "__llseek@12", "__lopen@8", "__lread@12", "__lwrite@12", "_lstrcat@8", "_lstrcatA@8", "_lstrcatW@8", "_lstrcmp@8", "_lstrcmpA@8", "_lstrcmpW@8", "_lstrcmpi@8", "_lstrcmpiA@8", "_lstrcmpiW@8", "_lstrcpy@8", "_lstrcpyA@8", "_lstrcpyW@8", "_lstrcpyn@12", "_lstrcpynA@12", "_lstrcpynW@12", "_lstrlen@4", "_lstrlenA@4", "_lstrlenW@4", "_ActivateKeyboardLayout@8", "_AdjustWindowRect@12", "_AdjustWindowRectEx@16", "_AllowSetForegroundWindow@4", "_AnimateWindow@12", "_AnyPopup@0", "_AppendMenuA@16", "_AppendMenuW@16", "_ArrangeIconicWindows@4", "_AttachThreadInput@12", "_BeginDeferWindowPos@4", "_BeginPaint@8", "_BlockInput@4", "_BringWindowToTop@4", "_BroadcastSystemMessage@20", "_BroadcastSystemMessageA@20", "_BroadcastSystemMessageW@20", "_CallMsgFilter@8", "_CallMsgFilterA@8", "_CallMsgFilterW@8", "_CallNextHookEx@16", "_CallWindowProcA@20", "_CallWindowProcW@20", "_CascadeChildWindows@8", "_CascadeWindows@20", "_ChangeClipboardChain@8", "_ChangeDisplaySettingsA@8", "_ChangeDisplaySettingsExA@20", "_ChangeDisplaySettingsExW@20", "_ChangeDisplaySettingsW@8", "_ChangeMenuA@20", "_ChangeMenuW@20", "_CharLowerA@4", "_CharLowerBuffA@8", "_CharLowerBuffW@8", "_CharLowerW@4", "_CharNextA@4", "_CharNextExA@12", "_CharNextW@4", "_CharPrevA@8", "_CharPrevExA@16", "_CharPrevW@8", "_CharToOemA@8", "_CharToOemBuffA@12", "_CharToOemBuffW@12", "_CharToOemW@8", "_CharUpperA@4", "_CharUpperBuffA@8", "_CharUpperBuffW@8", "_CharUpperW@4", "_CheckDlgButton@12", "_CheckMenuItem@12", "_CheckMenuRadioItem@20", "_CheckRadioButton@16", "_ChildWindowFromPoint@12", "_ChildWindowFromPointEx@16", "_ClientToScreen@8", "_ClipCursor@4", "_CloseClipboard@0", "_CloseDesktop@4", "_CloseWindow@4", "_CloseWindowStation@4", "_CopyAcceleratorTableA@12", "_CopyAcceleratorTableW@12", "_CopyIcon@4", "_CopyImage@20", "_CopyRect@8", "_CountClipboardFormats@0", "_CreateAcceleratorTableA@8", "_CreateAcceleratorTableW@8", "_CreateCaret@16", "_CreateCursor@28", "_CreateDesktopA@24", "_CreateDesktopW@24", "_CreateDialogIndirectParamA@20", "_CreateDialogIndirectParamW@20", "_CreateDialogParamA@20", "_CreateDialogParamW@20", "_CreateIcon@28", "_CreateIconFromResource@16", "_CreateIconFromResourceEx@28", "_CreateIconIndirect@4", "_CreateMDIWindowA@40", "_CreateMDIWindowW@40", "_CreateMenu@0", "_CreatePopupMenu@0", "_CreateWindowExA@48", "_CreateWindowExW@48", "_CreateWindowStationA@16", "_CreateWindowStationW@16", "_DdeAbandonTransaction@12", "_DdeAccessData@8", "_DdeAddData@16", "_DdeClientTransaction@32", "_DdeCmpStringHandles@8", "_DdeConnect@16", "_DdeConnectList@20", "_DdeCreateDataHandle@28", "_DdeCreateStringHandleA@12", "_DdeCreateStringHandleW@12", "_DdeDisconnect@4", "_DdeDisconnectList@4", "_DdeEnableCallback@12", "_DdeFreeDataHandle@4", "_DdeFreeStringHandle@8", "_DdeGetData@16", "_DdeGetLastError@4", "_DdeGetQualityOfService@12", "_DdeImpersonateClient@4", "_DdeInitializeA@16", "_DdeInitializeW@16", "_DdeKeepStringHandle@8", "_DdeNameService@16", "_DdePostAdvise@12", "_DdeQueryConvInfo@12", "_DdeQueryNextServer@8", "_DdeQueryStringA@20", "_DdeQueryStringW@20", "_DdeReconnect@4", "_DdeSetQualityOfService@12", "_DdeSetUserHandle@12", "_DdeUnaccessData@4", "_DdeUninitialize@4", "_DefDlgProcA@16", "_DefDlgProcW@16", "_DefFrameProcA@20", "_DefFrameProcW@20", "_DefMDIChildProcA@16", "_DefMDIChildProcW@16", "_DefWindowProcA@16", "_DefWindowProcW@16", "_DeferWindowPos@32", "_DeleteMenu@12", "_DestroyAcceleratorTable@4", "_DestroyCaret@0", "_DestroyCursor@4", "_DestroyIcon@4", "_DestroyMenu@4", "_DestroyWindow@4", "_DialogBoxIndirectParamA@20", "_DialogBoxIndirectParamW@20", "_DialogBoxParamA@20", "_DialogBoxParamW@20", "_DispatchMessageA@4", "_DispatchMessageW@4", "_DlgDirListA@20", "_DlgDirListComboBoxA@20", "_DlgDirListComboBoxW@20", "_DlgDirListW@20", "_DlgDirSelectComboBoxExA@16", "_DlgDirSelectComboBoxExW@16", "_DlgDirSelectExA@16", "_DlgDirSelectExW@16", "_DragDetect@12", "_DragObject@20", "_DrawAnimatedRects@16", "_DrawCaption@16", "_DrawEdge@16", "_DrawFocusRect@8", "_DrawFrame@16", "_DrawFrameControl@16", "_DrawIcon@16", "_DrawIconEx@36", "_DrawMenuBar@4", "_DrawStateA@40", "_DrawStateW@40", "_DrawTextA@20", "_DrawTextExA@24", "_DrawTextExW@24", "_DrawTextW@20", "_EditWndProc@16", "_EmptyClipboard@0", "_EnableMenuItem@12", "_EnableScrollBar@12", "_EnableWindow@8", "_EndDeferWindowPos@4", "_EndDialog@8", "_EndMenu@0", "_EndPaint@8", "_EnumChildWindows@12", "_EnumClipboardFormats@4", "_EnumDesktopWindows@12", "_EnumDesktopsA@12", "_EnumDesktopsW@12", "_EnumDisplayMonitors@16", "_EnumDisplaySettingsA@12", "_EnumDisplaySettingsExA@16", "_EnumDisplaySettingsExW@16", "_EnumDisplaySettingsW@12", "_EnumPropsA@8", "_EnumPropsExA@12", "_EnumPropsExW@12", "_EnumPropsW@8", "_EnumThreadWindows@12", "_EnumWindowStationsA@8", "_EnumWindowStationsW@8", "_EnumWindows@8", "_EqualRect@8", "_ExcludeUpdateRgn@8", "_ExitWindowsEx@8", "_FillRect@12", "_FindWindowA@8", "_FindWindowExA@16", "_FindWindowExW@16", "_FindWindowW@8", "_FlashWindow@8", "_FlashWindowEx@4", "_FrameRect@12", "_FreeDDElParam@8", "_GetActiveWindow@0", "_GetAltTabInfo@20", "_GetAltTabInfoA@20", "_GetAltTabInfoW@20", "_GetAncestor@8", "_GetAsyncKeyState@4", "_GetCapture@0", "_GetCaretBlinkTime@0", "_GetCaretPos@4", "_GetClassInfoA@12", "_GetClassInfoExA@12", "_GetClassInfoExW@12", "_GetClassInfoW@12", "_GetClassLongA@8", "_GetClassLongW@8", "_GetClassNameA@12", "_GetClassNameW@12", "_GetClassWord@8", "_GetClientRect@8", "_GetClipCursor@4", "_GetClipboardData@4", "_GetClipboardFormatNameA@12", "_GetClipboardFormatNameW@12", "_GetClipboardOwner@0", "_GetClipboardSequenceNumber@0", "_GetClipboardViewer@0", "_GetComboBoxInfo@8", "_GetCursor@0", "_GetCursorInfo@4", "_GetCursorPos@4", "_GetDC@4", "_GetDCEx@12", "_GetDesktopWindow@0", "_GetDialogBaseUnits@0", "_GetDlgCtrlID@4", "_GetDlgItem@8", "_GetDlgItemInt@16", "_GetDlgItemTextA@16", "_GetDlgItemTextW@16", "_GetDoubleClickTime@0", "_GetFocus@0", "_GetForegroundWindow@0", "_GetGUIThreadInfo@8", "_GetGuiResources@8", "_GetIconInfo@8", "_GetInputDesktop@0", "_GetInputState@0", "_GetKBCodePage@0", "_GetKeyNameTextA@12", "_GetKeyNameTextW@12", "_GetKeyState@4", "_GetKeyboardLayout@4", "_GetKeyboardLayoutList@8", "_GetKeyboardLayoutNameA@4", "_GetKeyboardLayoutNameW@4", "_GetKeyboardState@4", "_GetKeyboardType@4", "_GetLastActivePopup@4", "_GetLastInputInfo@4", "_GetListBoxInfo@4", "_GetMenu@4", "_GetMenuBarInfo@16", "_GetMenuCheckMarkDimensions@0", "_GetMenuContextHelpId@4", "_GetMenuDefaultItem@12", "_GetMenuInfo@8", "_GetMenuItemCount@4", "_GetMenuItemID@8", "_GetMenuItemInfoA@16", "_GetMenuItemInfoW@16", "_GetMenuItemRect@16", "_GetMenuState@12", "_GetMenuStringA@20", "_GetMenuStringW@20", "_GetMessageA@16", "_GetMessageExtraInfo@0", "_GetMessagePos@0", "_GetMessageTime@0", "_GetMessageW@16", "_GetMonitorInfoA@8", "_GetMonitorInfoW@8", "_GetMouseMovePoints@20", "_GetNextDlgGroupItem@12", "_GetNextDlgTabItem@12", "_GetOpenClipboardWindow@0", "_GetParent@4", "_GetPriorityClipboardFormat@8", "_GetProcessDefaultLayout@4", "_GetProcessWindowStation@0", "_GetPropA@8", "_GetPropW@8", "_GetQueueStatus@4", "_GetScrollBarInfo@12", "_GetScrollInfo@12", "_GetScrollPos@8", "_GetScrollRange@16", "_GetShellWindow@0", "_GetSubMenu@8", "_GetSysColor@4", "_GetSysColorBrush@4", "_GetSystemMenu@8", "_GetSystemMetrics@4", "_GetTabbedTextExtentA@20", "_GetTabbedTextExtentW@20", "_GetThreadDesktop@4", "_GetTitleBarInfo@8", "_GetTopWindow@4", "_GetUpdateRect@12", "_GetUpdateRgn@12", "_GetUserObjectInformationA@20", "_GetUserObjectInformationW@20", "_GetUserObjectSecurity@20", "_GetWindow@8", "_GetWindowContextHelpId@4", "_GetWindowDC@4", "_GetWindowInfo@8", "_GetWindowLongA@8", "_GetWindowLongW@8", "_GetWindowModuleFileName@12", "_GetWindowModuleFileNameA@12", "_GetWindowModuleFileNameW@12", "_GetWindowPlacement@8", "_GetWindowRect@8", "_GetWindowRgn@8", "_GetWindowTextA@12", "_GetWindowTextLengthA@4", "_GetWindowTextLengthW@4", "_GetWindowTextW@12", "_GetWindowThreadProcessId@8", "_GetWindowWord@8", "_GrayStringA@36", "_GrayStringW@36", "_HideCaret@4", "_HiliteMenuItem@16", "_IMPGetIMEA@8", "_IMPGetIMEW@8", "_IMPQueryIMEA@4", "_IMPQueryIMEW@4", "_IMPSetIMEA@8", "_IMPSetIMEW@8", "_ImpersonateDdeClientWindow@8", "_InSendMessage@0", "_InSendMessageEx@4", "_InflateRect@12", "_InsertMenuA@20", "_InsertMenuItemA@16", "_InsertMenuItemW@16", "_InsertMenuW@20", "_IntersectRect@12", "_InvalidateRect@12", "_InvalidateRgn@12", "_InvertRect@8", "_IsCharAlphaA@4", "_IsCharAlphaNumericA@4", "_IsCharAlphaNumericW@4", "_IsCharAlphaW@4", "_IsCharLowerA@4", "_IsCharLowerW@4", "_IsCharUpperA@4", "_IsCharUpperW@4", "_IsChild@8", "_IsClipboardFormatAvailable@4", "_IsDialogMessage@8", "_IsDialogMessageA@8", "_IsDialogMessageW@8", "_IsDlgButtonChecked@8", "_IsIconic@4", "_IsMenu@4", "_IsRectEmpty@4", "_IsWindow@4", "_IsWindowEnabled@4", "_IsWindowUnicode@4", "_IsWindowVisible@4", "_IsZoomed@4", "_KillSystemTimer@8", "_KillTimer@8", "_LoadAcceleratorsA@8", "_LoadAcceleratorsW@8", "_LoadBitmapA@8", "_LoadBitmapW@8", "_LoadCursorA@8", "_LoadCursorFromFileA@4", "_LoadCursorFromFileW@4", "_LoadCursorW@8", "_LoadIconA@8", "_LoadIconW@8", "_LoadImageA@24", "_LoadImageW@24", "_LoadKeyboardLayoutA@8", "_LoadKeyboardLayoutW@8", "_LoadMenuA@8", "_LoadMenuIndirectA@4", "_LoadMenuIndirectW@4", "_LoadMenuW@8", "_LoadStringA@16", "_LoadStringW@16", "_LockWindowUpdate@4", "_LockWorkStation@0", "_LookupIconIdFromDirectory@8", "_LookupIconIdFromDirectoryEx@20", "_MapDialogRect@8", "_MapVirtualKeyA@8", "_MapVirtualKeyExA@12", "_MapVirtualKeyExW@12", "_MapVirtualKeyW@8", "_MapWindowPoints@16", "_MenuItemFromPoint@16", "_MessageBeep@4", "_MessageBoxA@16", "_MessageBoxExA@20", "_MessageBoxExW@20", "_MessageBoxIndirectA@4", "_MessageBoxIndirectW@4", "_MessageBoxW@16", "_ModifyMenuA@20", "_ModifyMenuW@20", "_MonitorFromPoint@12", "_MonitorFromRect@8", "_MonitorFromWindow@8", "_MoveWindow@24", "_MsgWaitForMultipleObjects@20", "_MsgWaitForMultipleObjectsEx@20", "_NotifyWinEvent@16", "_OemKeyScan@4", "_OemToCharA@8", "_OemToCharBuffA@12", "_OemToCharBuffW@12", "_OemToCharW@8", "_OffsetRect@12", "_OpenClipboard@4", "_OpenDesktopA@16", "_OpenDesktopW@16", "_OpenIcon@4", "_OpenInputDesktop@12", "_OpenWindowStationA@12", "_OpenWindowStationW@12", "_PackDDElParam@12", "_PaintDesktop@4", "_PeekMessageA@20", "_PeekMessageW@20", "_PostMessageA@16", "_PostMessageW@16", "_PostQuitMessage@4", "_PostThreadMessageA@16", "_PostThreadMessageW@16", "_PtInRect@12", "_RealChildWindowFromPoint@12", "_RealGetWindowClass@12", "_RealGetWindowClassA@12", "_RealGetWindowClassW@12", "_RedrawWindow@16", "_RegisterClassA@4", "_RegisterClassExA@4", "_RegisterClassExW@4", "_RegisterClassW@4", "_RegisterClipboardFormatA@4", "_RegisterClipboardFormatW@4", "_RegisterDeviceNotificationA@12", "_RegisterDeviceNotificationW@12", "_RegisterHotKey@16", "_RegisterWindowMessageA@4", "_RegisterWindowMessageW@4", "_ReleaseCapture@0", "_ReleaseDC@8", "_RemoveMenu@12", "_RemovePropA@8", "_RemovePropW@8", "_ReplyMessage@4", "_ReuseDDElParam@20", "_ScreenToClient@8", "_ScrollChildren@12", "_ScrollDC@28", "_ScrollWindow@20", "_ScrollWindowEx@32", "_SendDlgItemMessageA@20", "_SendDlgItemMessageW@20", "_SendIMEMessageExA@8", "_SendIMEMessageExW@8", "_SendInput@12", "_SendMessageA@16", "_SendMessageCallbackA@24", "_SendMessageCallbackW@24", "_SendMessageTimeoutA@28", "_SendMessageTimeoutW@28", "_SendMessageW@16", "_SendNotifyMessageA@16", "_SendNotifyMessageW@16", "_SetActiveWindow@4", "_SetCapture@4", "_SetCaretBlinkTime@4", "_SetCaretPos@8", "_SetClassLongA@12", "_SetClassLongW@12", "_SetClassWord@12", "_SetClipboardData@8", "_SetClipboardViewer@4", "_SetCursor@4", "_SetCursorPos@8", "_SetDebugErrorLevel@4", "_SetDeskWallpaper@4", "_SetDlgItemInt@16", "_SetDlgItemTextA@12", "_SetDlgItemTextW@12", "_SetDoubleClickTime@4", "_SetFocus@4", "_SetForegroundWindow@4", "_SetKeyboardState@4", "_SetLastErrorEx@8", "_SetMenu@8", "_SetMenuContextHelpId@8", "_SetMenuDefaultItem@12", "_SetMenuInfo@8", "_SetMenuItemBitmaps@20", "_SetMenuItemInfoA@16", "_SetMenuItemInfoW@16", "_SetMessageExtraInfo@4", "_SetMessageQueue@4", "_SetParent@8", "_SetProcessDefaultLayout@4", "_SetProcessWindowStation@4", "_SetPropA@12", "_SetPropW@12", "_SetRect@20", "_SetRectEmpty@4", "_SetScrollInfo@16", "_SetScrollPos@16", "_SetScrollRange@20", "_SetShellWindow@4", "_SetSysColors@12", "_SetSystemCursor@8", "_SetSystemMenu@8", "_SetSystemTimer@16", "_SetThreadDesktop@4", "_SetTimer@16", "_SetUserObjectInformationA@16", "_SetUserObjectInformationW@16", "_SetUserObjectSecurity@12", "_SetWinEventHook@28", "_SetWindowContextHelpId@8", "_SetWindowLongA@12", "_SetWindowLongW@12", "_SetWindowPlacement@8", "_SetWindowPos@28", "_SetWindowRgn@12", "_SetWindowTextA@8", "_SetWindowTextW@8", "_SetWindowWord@12", "_SetWindowsHookA@8", "_SetWindowsHookExA@16", "_SetWindowsHookExW@16", "_SetWindowsHookW@8", "_ShowCaret@4", "_ShowCursor@4", "_ShowOwnedPopups@8", "_ShowScrollBar@12", "_ShowWindow@8", "_ShowWindowAsync@8", "_SubtractRect@12", "_SwapMouseButton@4", "_SwitchDesktop@4", "_SystemParametersInfoA@16", "_SystemParametersInfoW@16", "_TabbedTextOutA@32", "_TabbedTextOutW@32", "_TileChildWindows@8", "_TileWindows@20", "_ToAscii@20", "_ToAsciiEx@24", "_ToUnicode@24", "_ToUnicodeEx@28", "_TrackMouseEvent@4", "_TrackPopupMenu@28", "_TrackPopupMenuEx@24", "_TranslateAccelerator@12", "_TranslateAcceleratorA@12", "_TranslateAcceleratorW@12", "_TranslateMDISysAccel@8", "_TranslateMessage@4", "_UnhookWinEvent@4", "_UnhookWindowsHook@8", "_UnhookWindowsHookEx@4", "_UnionRect@12", "_UnloadKeyboardLayout@4", "_UnpackDDElParam@16", "_UnregisterClassA@8", "_UnregisterClassW@8", "_UnregisterDeviceNotification@4", "_UnregisterHotKey@8", "_UpdateLayeredWindow@36", "_UpdateWindow@4", "_UserHandleGrantAccess@12", "_ValidateRect@8", "_ValidateRgn@8", "_VkKeyScanA@4", "_VkKeyScanExA@8", "_VkKeyScanExW@8", "_VkKeyScanW@4", "_WINNLSEnableIME@8", "_WINNLSGetEnableStatus@4", "_WINNLSGetIMEHotkey@4", "_WaitForInputIdle@8", "_WaitMessage@0", "_WinHelpA@16", "_WinHelpW@16", "_WindowFromDC@4", "_WindowFromPoint@8", "_keybd_event@16", "_mouse_event@20", "_wsprintfA", "_wsprintfW", "_wvsprintfA@12", "_wvsprintfW@12", "_wod32Message@20", "_winmmSetDebugLevel@4", "_winmmDbgOut", "_wid32Message@20", "_waveOutWrite@12", "_waveOutUnprepareHeader@12", "_waveOutSetVolume@8", "_waveOutSetPlaybackRate@8", "_waveOutSetPitch@8", "_waveOutRestart@4", "_waveOutReset@4", "_waveOutPrepareHeader@12", "_waveOutPause@4", "_waveOutOpen@24", "_waveOutMessage@16", "_waveOutGetVolume@8", "_waveOutGetPosition@12", "_waveOutGetPlaybackRate@8", "_waveOutGetPitch@8", "_waveOutGetNumDevs@0", "_waveOutGetID@8", "_waveOutGetErrorTextW@12", "_waveOutGetErrorTextA@12", "_waveOutGetDevCapsW@12", "_waveOutGetDevCapsA@12", "_waveOutClose@4", "_waveOutBreakLoop@4", "_waveInUnprepareHeader@12", "_waveInStop@4", "_waveInStart@4", "_waveInReset@4", "_waveInPrepareHeader@12", "_waveInOpen@24", "_waveInMessage@16", "_waveInGetPosition@12", "_waveInGetNumDevs@0", "_waveInGetID@8", "_waveInGetErrorTextW@12", "_waveInGetErrorTextA@12", "_waveInGetDevCapsW@12", "_waveInGetDevCapsA@12", "_waveInClose@4", "_waveInAddBuffer@12", "_timeSetEvent@20", "_timeKillEvent@4", "_timeGetTime@0", "_timeGetSystemTime@8", "_timeGetDevCaps@8", "_timeEndPeriod@4", "_timeBeginPeriod@4", "_tid32Message@20", "_sndPlaySoundW@8", "_sndPlaySoundA@8", "_mxd32Message@20", "_mod32Message@20", "_mmsystemGetVersion@0", "_mmioWrite@12", "_mmioStringToFOURCCW@8", "_mmioStringToFOURCCA@8", "_mmioSetInfo@12", "_mmioSetBuffer@16", "_mmioSendMessage@16", "_mmioSeek@12", "_mmioRenameW@16", "_mmioRenameA@16", "_mmioRead@12", "_mmioOpenW@12", "_mmioOpenA@12", "_mmioInstallIOProcW@12", "_mmioInstallIOProcA@12", "_mmioGetInfo@12", "_mmioFlush@8", "_mmioDescend@16", "_mmioCreateChunk@12", "_mmioClose@8", "_mmioAscend@12", "_mmioAdvance@12", "_mmTaskYield@0", "_mmTaskSignal@4", "_mmTaskCreate@12", "_mmTaskBlock@4", "_mmGetCurrentTask@0", "_mmDrvInstall@16", "_mixerSetControlDetails@12", "_mixerOpen@20", "_mixerMessage@16", "_mixerGetNumDevs@0", "_mixerGetLineInfoW@12", "_mixerGetLineInfoA@12", "_mixerGetLineControlsW@12", "_mixerGetLineControlsA@12", "_mixerGetID@12", "_mixerGetDevCapsW@12", "_mixerGetDevCapsA@12", "_mixerGetControlDetailsW@12", "_mixerGetControlDetailsA@12", "_mixerClose@4", "_midiStreamStop@4", "_midiStreamRestart@4", "_midiStreamProperty@12", "_midiStreamPosition@12", "_midiStreamPause@4", "_midiStreamOut@12", "_midiStreamOpen@24", "_midiStreamClose@4", "_midiOutUnprepareHeader@12", "_midiOutShortMsg@8", "_midiOutSetVolume@8", "_midiOutReset@4", "_midiOutPrepareHeader@12", "_midiOutOpen@20", "_midiOutMessage@16", "_midiOutLongMsg@12", "_midiOutGetVolume@8", "_midiOutGetNumDevs@0", "_midiOutGetID@8", "_midiOutGetErrorTextW@12", "_midiOutGetErrorTextA@12", "_midiOutGetDevCapsW@12", "_midiOutGetDevCapsA@12", "_midiOutClose@4", "_midiOutCachePatches@16", "_midiOutCacheDrumPatches@16", "_midiInUnprepareHeader@12", "_midiInStop@4", "_midiInStart@4", "_midiInReset@4", "_midiInPrepareHeader@12", "_midiInOpen@20", "_midiInMessage@16", "_midiInGetNumDevs@0", "_midiInGetID@8", "_midiInGetErrorTextW@12", "_midiInGetErrorTextA@12", "_midiInGetDevCapsW@12", "_midiInGetDevCapsA@12", "_midiInClose@4", "_midiInAddBuffer@12", "_midiDisconnect@12", "_midiConnect@12", "_mid32Message@20", "_mciSetYieldProc@12", "_mciSetDriverData@8", "_mciSendStringW@16", "_mciSendStringA@16", "_mciSendCommandW@16", "_mciSendCommandA@16", "_mciLoadCommandResource@12", "_mciGetYieldProc@8", "_mciGetErrorStringW@12", "_mciGetErrorStringA@12", "_mciGetDriverData@4", "_mciGetDeviceIDW@4", "_mciGetDeviceIDFromElementIDW@8", "_mciGetDeviceIDFromElementIDA@8", "_mciGetDeviceIDA@4", "_mciGetCreatorTask@4", "_mciFreeCommandResource@4", "_mciExecute@4", "_mciDriverYield@4", "_mciDriverNotify@12", "_mci32Message@20", "_joySetThreshold@8", "_joySetCapture@16", "_joyReleaseCapture@4", "_joyGetThreshold@8", "_joyGetPosEx@8", "_joyGetPos@8", "_joyGetNumDevs@0", "_joyGetDevCapsW@12", "_joyGetDevCapsA@12", "_joyConfigChanged@4", "_joy32Message@20", "_auxSetVolume@8", "_auxOutMessage@16", "_auxGetVolume@8", "_auxGetNumDevs@0", "_auxGetDevCapsW@12", "_auxGetDevCapsA@12", "_aux32Message@20", "_WOWAppExit@4", "_WOW32ResolveMultiMediaHandle@24", "_WOW32DriverCallback@28", "_SendDriverMessage@16", "_PlaySoundW@12", "_PlaySoundA@12", "_PlaySound@12", "_OpenDriver@12", "_NotifyCallbackData@20", "_MigrateSoundEvents@0", "_MigrateMidiUser@0", "_MigrateAllDrivers@0", "_GetDriverModuleHandle@4", "_DrvGetModuleHandle@4", "_DriverCallback@28", "_DefDriverProc@20", "_CloseDriver@12", "_ADVANCEDSETUPDIALOG@16", "_AbortPrinter@4", "_AddFormA@12", "_AddFormW@12", "_AddJobA@20", "_AddJobW@20", "_AddMonitorA@12", "_AddMonitorW@12", "_AddPerMachineConnectionA@16", "_AddPerMachineConnectionW@16", "_AddPortA@12", "_AddPortExA@16", "_AddPortExW@16", "_AddPortW@12", "_AddPrintProcessorA@16", "_AddPrintProcessorW@16", "_AddPrintProvidorA@12", "_AddPrintProvidorW@12", "_AddPrinterA@12", "_AddPrinterConnectionA@4", "_AddPrinterConnectionUI@12", "_AddPrinterConnectionW@4", "_AddPrinterDriverA@12", "_AddPrinterDriverExA@16", "_AddPrinterDriverExW@16", "_AddPrinterDriverW@12", "_AddPrinterW@12", "_AdvancedDocumentPropertiesA@20", "_AdvancedDocumentPropertiesW@20", "_AdvancedSetupDialog@16", "_ClosePrinter@4", "_CloseSpoolFileHandle@8", "_ClusterSplClose@4", "_ClusterSplIsAlive@4", "_ClusterSplOpen@20", "_CommitSpoolData@12", "_ConfigurePortA@12", "_ConfigurePortW@12", "_ConnectToPrinterDlg@8", "_ConvertAnsiDevModeToUnicodeDevmode@16", "_ConvertUnicodeDevModeToAnsiDevmode@16", "_CreatePrinterIC@8", "_DEVICECAPABILITIES@20", "_DEVICEMODE@16", "_DeleteFormA@8", "_DeleteFormW@8", "_DeleteMonitorA@12", "_DeleteMonitorW@12", "_DeletePerMachineConnectionA@8", "_DeletePerMachineConnectionW@8", "_DeletePortA@12", "_DeletePortW@12", "_DeletePrintProcessorA@12", "_DeletePrintProcessorW@12", "_DeletePrintProvidorA@12", "_DeletePrintProvidorW@12", "_DeletePrinter@4", "_DeletePrinterConnectionA@4", "_DeletePrinterConnectionW@4", "_DeletePrinterDataA@8", "_DeletePrinterDataExA@12", "_DeletePrinterDataExW@12", "_DeletePrinterDataW@8", "_DeletePrinterDriverA@12", "_DeletePrinterDriverExA@20", "_DeletePrinterDriverExW@20", "_DeletePrinterDriverW@12", "_DeletePrinterIC@4", "_DeletePrinterKeyA@8", "_DeletePrinterKeyW@8", "_DevQueryPrint@12", "_DevQueryPrintEx@4", "_DeviceCapabilities@20", "_DeviceCapabilitiesA@20", "_DeviceCapabilitiesW@20", "_DeviceMode@16", "_DevicePropertySheets@8", "_DocumentEvent@28", "_DocumentPropertiesA@24", "_DocumentPropertiesW@24", "_DocumentPropertySheets@8", "_EXTDEVICEMODE@32", "_EndDocPrinter@4", "_EndPagePrinter@4", "_EnumFormsA@24", "_EnumFormsW@24", "_EnumJobsA@32", "_EnumJobsW@32", "_EnumMonitorsA@24", "_EnumMonitorsW@24", "_EnumPerMachineConnectionsA@20", "_EnumPerMachineConnectionsW@20", "_EnumPortsA@24", "_EnumPortsW@24", "_EnumPrintProcessorDatatypesA@28", "_EnumPrintProcessorDatatypesW@28", "_EnumPrintProcessorsA@28", "_EnumPrintProcessorsW@28", "_EnumPrinterDataA@36", "_EnumPrinterDataExA@24", "_EnumPrinterDataExW@24", "_EnumPrinterDataW@36", "_EnumPrinterDriversA@28", "_EnumPrinterDriversW@28", "_EnumPrinterKeyA@20", "_EnumPrinterKeyW@20", "_EnumPrinterPropertySheets@16", "_EnumPrintersA@28", "_EnumPrintersW@28", "_ExtDeviceMode@32", "_FindClosePrinterChangeNotification@4", "_FindFirstPrinterChangeNotification@16", "_FindNextPrinterChangeNotification@16", "_ForceUnloadDriver@4", "_FreePrinterNotifyInfo@4", "_GetDefaultPrinterA@8", "_GetDefaultPrinterW@8", "_GetFormA@24", "_GetFormW@24", "_GetJobA@24", "_GetJobW@24", "_GetPrintProcessorDirectoryA@24", "_GetPrintProcessorDirectoryW@24", "_GetPrinterA@20", "_GetPrinterDataA@24", "_GetPrinterDataExA@28", "_GetPrinterDataExW@28", "_GetPrinterDataW@24", "_GetPrinterDriverA@24", "_GetPrinterDriverDirectoryA@24", "_GetPrinterDriverDirectoryW@24", "_GetPrinterDriverW@24", "_GetPrinterHTMLViewA@20", "_GetPrinterHTMLViewW@20", "_GetPrinterW@20", "_GetPrinterWebInformation@16", "_GetSpoolFileHandle@4", "_InitializeDll@12", "_LoadPrinterDriver@4", "_OpenPrinterA@12", "_OpenPrinterW@12", "_PlayGdiScriptOnPrinterIC@24", "_PrinterMessageBoxA@24", "_PrinterMessageBoxW@24", "_PrinterProperties@8", "_PublishPrinterA@24", "_PublishPrinterW@24", "_QueryColorProfile@24", "_QueryRemoteFonts@12", "_QuerySpoolMode@12", "_ReadPrinter@16", "_RefCntLoadDriver@16", "_RefCntUnloadDriver@8", "_ResetPrinterA@8", "_ResetPrinterW@8", "_ScheduleJob@8", "_SeekPrinter@24", "_SetAllocFailCount@20", "_SetDefaultPrinterA@4", "_SetDefaultPrinterW@4", "_SetFormA@16", "_SetFormW@16", "_SetJobA@20", "_SetJobW@20", "_SetPortA@16", "_SetPortW@16", "_SetPrinterA@16", "_SetPrinterDataA@20", "_SetPrinterDataExA@24", "_SetPrinterDataExW@24", "_SetPrinterDataW@20", "_SetPrinterHTMLViewA@12", "_SetPrinterHTMLViewW@12", "_SetPrinterW@16", "_SplDriverUnloadComplete@4", "_SplReadPrinter@12", "_SpoolerDevQueryPrintW@20", "_SpoolerInit@0", "_SpoolerPrinterEvent@16", "_StartDocDlgA@8", "_StartDocDlgW@8", "_StartDocPrinterA@12", "_StartDocPrinterW@12", "_StartPagePrinter@4", "_WaitForPrinterChange@8", "_WritePrinter@16", "_XcvDataW@32" }; const char *LookupExport(const char*name) { const char *result=name; int i; for(i=0;i<sizeof(export_list)/sizeof(char *);i++){ int x,index=0; char a,b; bool found=false; const char *ename=export_list[i]; ename++; for(x=0;x<128;x++){ a=ename[x]; b=name[index]; if((a=='@' || a==0) && (b==0)){ found=true; break; } if(a==0 || b==0) break; if(a!=b) break; index++; } if(found){ result=export_list[i]; break; } } return result; }
[ "pinchyCZN@gmail.com" ]
pinchyCZN@gmail.com
f6dc3a738497b0fb7756f247288763d9b08baab3
05671178a614cc436891e612d8f8a3d9046fdd10
/COMP345-A1/Orders.cpp
e2becb5a7b270ce20f6b4e89cbf733566d303b39
[]
no_license
ahmedshawn33/assignment-1
644841b40ea2fc155bcf79aa6d66afe3dbd76e7b
f79599b79096a0c0619f48a1b8f13e232198b5ca
refs/heads/main
2023-09-03T03:48:15.124597
2021-10-06T02:29:37
2021-10-06T02:29:37
414,816,335
0
0
null
2021-10-08T02:08:52
2021-10-08T02:08:51
null
UTF-8
C++
false
false
10,248
cpp
#include "Orders.h" //order class--------------------------------------------------------------------------- //default constructor Order::Order() : Order("This is an order.", "This is the effect", true) { //empty } //para constructor Order::Order(string description, string effect, bool valid) : description(new string(description)), effect(new string (effect)){ isValid = &valid; } //copy constructor Order::Order(const Order& orderToCopy) { this->description = new string(*(orderToCopy.description)); this->effect = new string(*(orderToCopy.effect)); this->isValid = orderToCopy.isValid; } //Destructor Order::~Order() { delete description; delete effect; delete isValid; } //to string, returns description string Order::toString() { return *description; } //returns effect string Order::getEffect() { return *effect; } //stream insertion operator overload ostream& operator<<(ostream& out, const Order& orderToStream) { out << *(orderToStream.description); return out; } //stream assignment operator overload Order& Order::operator=(const Order& orderToAssign) { this->description = new string(*(orderToAssign.description)); this->isValid = orderToAssign.isValid; return *this; } //Deploy order class------------------------------------------------------------------- //constructors Deploy::Deploy() : Order("Deploy Order", "Deploy effect", true) { //empty } //para const Deploy::Deploy(string description, string effect,bool valid) { this->description = &description; this->effect = &effect; this->isValid = &valid; } //copy constructor Deploy::Deploy(const Deploy& deployToCopy) : Order(deployToCopy) { //empty } //Destructor Deploy::~Deploy() { //maybe later } //inherited validate, for now just checks if true bool Deploy::validate() { if (this->isValid) return true; else return false; } //execute if validate returns true bool Deploy::execute() { if (this->validate()) return true; else return false; } // Overloads the stream insertion operator. ostream& operator<<(ostream& out, const Deploy& deployToStream) { out << static_cast <const Order&>(deployToStream); // upcast to Order to call their stream insertion operator return out; } // Overloads the assignment operator. Deploy& Deploy::operator=(const Deploy& deployToAssign) { Order::operator= (deployToAssign); return *this; } //Advance order class------------------------------------------------------------------- //constructors Advance::Advance() : Order("Advance Order", "Advance effect", true) { //empty } //para const Advance::Advance(string description, string effect, bool valid) { this->description = &description; this->effect = &effect; this->isValid = &valid; } //copy constructor Advance::Advance(const Advance& advanceToCopy) : Order(advanceToCopy) { //empty } //Destructor Advance::~Advance() { //maybe later } //inherited validate, for now just checks if true bool Advance::validate() { if (this->isValid) return true; else return false; } //execute if validate returns true bool Advance::execute() { if (this->validate()) return true; else return false; } // Overloads the stream insertion operator. ostream& operator<<(ostream& out, const Advance& advanceToStream) { out << static_cast <const Order&>(advanceToStream); // upcast to Order to call their stream insertion operator return out; } // Overloads the assignment operator. Advance& Advance::operator=(const Advance& advanceToAssign) { Order::operator= (advanceToAssign); return *this; } //Bomb order class------------------------------------------------------------------- //constructors Bomb::Bomb() : Order("Bomb Order", "Bomb effect", true) { //empty } //para const Bomb::Bomb(string description, string effect, bool valid) { this->description = &description; this->effect = &effect; this->isValid = &valid; } //copy constructor Bomb::Bomb(const Bomb& bombToCopy) : Order(bombToCopy) { //empty } //Destructor Bomb::~Bomb() { //maybe later } //inherited validate, for now just checks if true bool Bomb::validate() { if (this->isValid) return true; else return false; } //execute if validate returns true bool Bomb::execute() { if (this->validate()) return true; else return false; } // Overloads the stream insertion operator. ostream& operator<<(ostream& out, const Bomb& bombToStream) { out << static_cast <const Order&>(bombToStream); // upcast to Order to call their stream insertion operator return out; } // Overloads the assignment operator. Bomb& Bomb::operator=(const Bomb& bombToAssign) { Order::operator= (bombToAssign); return *this; } //Blockade order class------------------------------------------------------------------- //constructors Blockade::Blockade() : Order("Blockade Order", "Blockade effect", true) { //empty } //para const Blockade::Blockade(string description, string effect,bool valid) { this->description = &description; this->effect = &effect; this->isValid = &valid; } //copy constructor Blockade::Blockade(const Blockade& blockadeToCopy) : Order(blockadeToCopy) { //empty } //Destructor Blockade::~Blockade() { //maybe later } //inherited validate, for now just checks if true bool Blockade::validate() { if (this->isValid) return true; else return false; } //execute if validate returns true bool Blockade::execute() { if (this->validate()) return true; else return false; } // Overloads the stream insertion operator. ostream& operator<<(ostream& out, const Blockade& blockadeToStream) { out << static_cast <const Order&>(blockadeToStream); // upcast to Order to call their stream insertion operator return out; } // Overloads the assignment operator. Blockade& Blockade::operator=(const Blockade& blockadeToAssign) { Order::operator= (blockadeToAssign); return *this; } //Airlift order class------------------------------------------------------------------- //constructors Airlift::Airlift() : Order("Airlift Order", "Airlift order", true) { //empty } //para const Airlift::Airlift(string description, string effect, bool valid) { this->description = &description; this->effect = &effect; this->isValid = &valid; } //copy constructor Airlift::Airlift(const Airlift& airliftToCopy) : Order(airliftToCopy) { //empty } //Destructor Airlift::~Airlift() { //maybe later } //inherited validate, for now just checks if true bool Airlift::validate() { if (this->isValid) return true; else return false; } //execute if validate returns true bool Airlift::execute() { if (this->validate()) return true; else return false; } // Overloads the stream insertion operator. ostream& operator<<(ostream& out, const Airlift& airliftToStream) { out << static_cast <const Order&>(airliftToStream); // upcast to Order to call their stream insertion operator return out; } // Overloads the assignment operator. Airlift& Airlift::operator=(const Airlift& airliftToAssign) { Order::operator= (airliftToAssign); return *this; } //Negotiate order class------------------------------------------------------------------- //constructors Negotiate::Negotiate() : Order("Negotiate Order", "Negotiate effect", true) { //empty } //para const Negotiate::Negotiate(string description, string effect, bool valid) { this->description = &description; this->effect = &effect; this->isValid = &valid; } //copy constructor Negotiate::Negotiate(const Negotiate& negotiateToCopy) : Order(negotiateToCopy) { //empty } //Destructor Negotiate::~Negotiate() { //maybe later } //inherited validate, for now just checks if true bool Negotiate::validate() { if (this->isValid) return true; else return false; } //execute if validate returns true bool Negotiate::execute() { if (this->validate()) return true; else return false; } // Overloads the stream insertion operator. ostream& operator<<(ostream& out, const Negotiate& negotiateToStream) { out << static_cast <const Order&>(negotiateToStream); // upcast to Order to call their stream insertion operator return out; } // Overloads the assignment operator. Negotiate& Negotiate::operator=(const Negotiate& negotiateToAssign) { Order::operator= (negotiateToAssign); return *this; } //OrdersList class------------------------------------------------------------------- //consructors //default OrdersList::OrdersList() { orders; } //copy constructor OrdersList::OrdersList(const OrdersList &ordersListToCopy) { for (auto ordersIterator = ordersListToCopy.orders.begin(); ordersIterator != ordersListToCopy.orders.end(); ordersIterator++) { orders.push_back(*ordersIterator); } } //Destructor OrdersList::~OrdersList() { for (Order* order : orders) { delete order; } orders.clear(); } //service funcs for lists //add to the list, adds to end void OrdersList::add(Order* orderToAdd) { orders.push_back(orderToAdd); } //move func, takes old index and moves to new index uses iterators to get to the respective orders, then splices to get the right order void OrdersList::move(int oldIndex, int newIndex) { auto oldPosition = orders.begin(); advance(oldPosition, oldIndex); auto newPosition = orders.begin(); advance(newPosition, newIndex); orders.splice(newPosition, orders, oldPosition); } //remove an entry. uses iterator to find the correct index then erases entry void OrdersList::remove(int index) { int pos = 0; for (auto ordersIterator = orders.begin(); ordersIterator != orders.end(); ordersIterator++) { if (pos == index) { orders.erase(ordersIterator); return; } pos++; } } string OrdersList::toString() { string out = ""; for (auto ordersIterator : orders) { out += ordersIterator->toString() + " "; } return out; } // Overloads the stream insertion operator ostream& operator<<(ostream& out, const OrdersList& ordersListToStream) { for (auto ordersIterator = ordersListToStream.orders.begin(); ordersIterator != ordersListToStream.orders.end(); ordersIterator++) { out << **ordersIterator << " "; } out << endl; return out; } // Overloads the assignment operator OrdersList& OrdersList::operator=(OrdersList& ordersListToAssign) { for (auto ordersIterator = ordersListToAssign.orders.begin(); ordersIterator != ordersListToAssign.orders.end(); ordersIterator++) { orders.push_back(*ordersIterator); } return *this; }
[ "46114769+detbrownbear@users.noreply.github.com" ]
46114769+detbrownbear@users.noreply.github.com
fd7238d4df83654b03f76cdbdb918aafcee6c1b9
80665ad996211669a8efd22f1f1535673cdf9c14
/leecode-cn/01KnapsackProblem/ZeroOneKnapsackOptimized.cpp
9bfcb8b426e52b217c3b62a194042c3fd85883d3
[]
no_license
lovepurple/leecode
713f7256741faec5ee8189b0b54df4724bc16807
ecfab9ccff26fe914839dcd12ef8a0c6b4f7126a
refs/heads/master
2022-10-01T04:40:08.712593
2022-09-14T03:18:20
2022-09-14T03:18:20
142,042,189
1
0
null
null
null
null
UTF-8
C++
false
false
914
cpp
#include "ZeroOneKnapsackOptimized.h" #include <algorithm> /// <summary> /// 一维数组优化版的01背包 /// </summary> /// <param name="goodsValues"></param> /// <param name="goodsWeights"></param> /// <param name="totalCapacity"></param> /// <returns></returns> int ZeroOneKnapsackOptimized::ZeroOneKnapsack(const std::vector<int> goodsValues, const std::vector<int> goodsWeights, int totalCapacity) { std::vector<int> dp(totalCapacity + 1); //初始化i=0 是的dp[j] 只有一个物品时 int weightOfW0 = goodsWeights[0]; for (int j = 0; j <= totalCapacity; ++j) dp[j] = j >= weightOfW0 ? goodsValues[0] : 0; for (int i = 1; i < goodsValues.size(); ++i) { int weightOfGoods = goodsWeights[i]; //反向计算 for (int j = totalCapacity; j >= 1; --j) { if (j >= weightOfGoods) dp[j] = std::max(dp[j], dp[j - weightOfGoods] + goodsValues[i]); } } return dp[totalCapacity]; }
[ "songguangze@fotoable.com" ]
songguangze@fotoable.com
fb2fa27cdeb8b8330e98c859a09723ffd879cf06
cf777505c5e6713c7e0dd23146c24aa557a93e6e
/src/Filesystem/FilesystemChunkStorageProvider.h
5e3d83607f5d612c0c107f8f4d56c1c4d8faf007
[]
no_license
profi248/backwither
b5c8a10de28bb15845fd48e76c53175cb3f0116b
2a74448de05d545cdf0ff55a4e1d3f00cf98fadc
refs/heads/master
2023-02-26T21:10:53.273631
2021-01-21T18:58:51
2021-01-31T23:30:33
266,898,543
0
0
null
null
null
null
UTF-8
C++
false
false
873
h
#ifndef BACKUP_INCREMENTALFILESYSTEMBACKUPSTORAGEPROVIDER_H #define BACKUP_INCREMENTALFILESYSTEMBACKUPSTORAGEPROVIDER_H #include "FilesystemEntity.h" #include "ChunkStorageProvider.h" #include "../Backup/ChunkList.h" #include <string> /** * Implements ChunkStorageProvider as filesystem storage. */ class FilesystemChunkStorageProvider : public ChunkStorageProvider { std::string m_OutputPath; std::string m_ChunkDir; public: const std::string CHUNK_FOLDER = "chunks/"; /** * Constuct chunk storage. * @param outPath Output path. */ FilesystemChunkStorageProvider (std::string outPath); ~FilesystemChunkStorageProvider () override = default; size_t StoreChunk (Chunk & metadata, const char* data) override; char* RetrieveChunk (Chunk & metadata) override; }; #endif //BACKUP_INCREMENTALFILESYSTEMBACKUPSTORAGEPROVIDER_H
[ "kostal.david8@gmail.com" ]
kostal.david8@gmail.com
a0dc547815abba1c7adef48711e46d56c49591b7
a88a52599eca22b5ce1b404b34db304d659a397f
/240/240.cpp
d5c673c4f48d01b2d40dbf633c4a848c9b4e6763
[]
no_license
dingyaguang117/AOJ
fbf65c47327109e1a8fcc42707dc052a2bd35c24
b471bde54201c076bc6f34c245d90f46d90d8497
refs/heads/master
2020-05-13T01:01:47.292494
2012-10-08T13:00:15
2012-10-08T13:00:15
6,124,335
1
4
null
null
null
null
UTF-8
C++
false
false
715
cpp
#include <iostream> #include <string> #include <algorithm> using namespace std; string mrg(string s1,string s2) { int i,j; bool f; if(s1.size()>s2.size()) i=s1.size()-s2.size(); else i=0; for(;i<s1.size();++i) { f=0; for(j=0;i+j<s1.size();++j) { if(s1[i+j]!=s2[j]) { f=1; break; } } if(!f) { s1.erase(s1.begin()+i,s1.end()); s1+=s2; return s1; } } s1+=s2; return s1; } int main() { int N,i,min=100000; string s[10],st; cin>>N; for(i=0;i<N;++i) { cin>>s[i]; } sort(s,s+N); do { st=s[0]; for(i=1;i<N;++i) { st=mrg(st,s[i]); } if(st.size()<min) { min=st.size(); } }while(next_permutation(s,s+N)); cout<<min<<endl; return 0; }
[ "dingyaguang117@126.com" ]
dingyaguang117@126.com
554ce7d33be412e470aa7c943dd6f5a160ffdc6b
d147797c49e939f5f665d0201ebff8482df86a82
/headers/Mecanica.h
9c656f801190b067490143bfa58bc07f5ae15cc4
[]
no_license
JourdanHen/tp1-EstruturasDeDados
6ab633c923936aed64a15bd69b84c28d198cb01e
0a198dd1db8a0ef887d623b6eeb008c9fe0c6ad9
refs/heads/main
2023-04-02T01:14:40.907658
2021-04-05T03:11:27
2021-04-05T03:11:27
354,702,037
0
0
null
null
null
null
UTF-8
C++
false
false
508
h
//A estrutura usada para a preparação da batalha será a Fila Encadeada //Código passado nas aulas foi usado como inspiração #include <iostream> #ifndef MECANICA #define MECANICA #include "fila.h" #include "tipocelula.h" #include "Nave.h" class Mecanica : public Fila{ public: Mecanica(); ~Mecanica(); void Adiciona(Nave item); Nave Retira(); void Imprime(); void Limpa(); private: TipoCelula* frente; TipoCelula* tras; }; #endif
[ "jourdan.hen@gmail.com" ]
jourdan.hen@gmail.com
9a5db0bc776a7b8cf5af83322c207c8132183031
0dca3325c194509a48d0c4056909175d6c29f7bc
/ga/include/alibabacloud/ga/model/DeleteListenerRequest.h
b4744541922ece61bf3d76a3ac7e7a0d830cffca
[ "Apache-2.0" ]
permissive
dingshiyu/aliyun-openapi-cpp-sdk
3eebd9149c2e6a2b835aba9d746ef9e6bef9ad62
4edd799a79f9b94330d5705bb0789105b6d0bb44
refs/heads/master
2023-07-31T10:11:20.446221
2021-09-26T10:08:42
2021-09-26T10:08:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,688
h
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ALIBABACLOUD_GA_MODEL_DELETELISTENERREQUEST_H_ #define ALIBABACLOUD_GA_MODEL_DELETELISTENERREQUEST_H_ #include <string> #include <vector> #include <alibabacloud/core/RpcServiceRequest.h> #include <alibabacloud/ga/GaExport.h> namespace AlibabaCloud { namespace Ga { namespace Model { class ALIBABACLOUD_GA_EXPORT DeleteListenerRequest : public RpcServiceRequest { public: DeleteListenerRequest(); ~DeleteListenerRequest(); std::string getClientToken()const; void setClientToken(const std::string& clientToken); std::string getListenerId()const; void setListenerId(const std::string& listenerId); std::string getRegionId()const; void setRegionId(const std::string& regionId); std::string getAcceleratorId()const; void setAcceleratorId(const std::string& acceleratorId); private: std::string clientToken_; std::string listenerId_; std::string regionId_; std::string acceleratorId_; }; } } } #endif // !ALIBABACLOUD_GA_MODEL_DELETELISTENERREQUEST_H_
[ "sdk-team@alibabacloud.com" ]
sdk-team@alibabacloud.com
183de91d00d65d8527d401f1ac88bdbc4a754760
a994338fa706174570430675684d18472f90d5ec
/bullet3/modified_scripts/CommonRigidBodyBase.h
1c6594ff2acd5df924192ca24e965f621543f6d0
[ "Zlib" ]
permissive
ztzhang/SoundSynth
85f9ccf3bd6efbd47d198241124402d718b5e3de
db6ddd9f36de7ea8b19c83a40aa268338be48365
refs/heads/master
2021-09-19T07:18:22.162579
2018-07-24T19:49:46
2018-07-24T19:49:46
115,750,784
55
11
null
null
null
null
UTF-8
C++
false
false
11,423
h
#ifndef COMMON_RIGID_BODY_BASE_H #define COMMON_RIGID_BODY_BASE_H #include "btBulletDynamicsCommon.h" #include "CommonExampleInterface.h" #include "CommonGUIHelperInterface.h" #include "CommonRenderInterface.h" #include "CommonCameraInterface.h" #include "CommonGraphicsAppInterface.h" #include "CommonWindowInterface.h" struct CommonRigidBodyBase : public CommonExampleInterface { //keep the collision shapes, for deletion/cleanup btAlignedObjectArray<btCollisionShape*> m_collisionShapes; btBroadphaseInterface* m_broadphase; btCollisionDispatcher* m_dispatcher; btConstraintSolver* m_solver; btDefaultCollisionConfiguration* m_collisionConfiguration; btDiscreteDynamicsWorld* m_dynamicsWorld; //data for picking objects class btRigidBody* m_pickedBody; class btTypedConstraint* m_pickedConstraint; int m_savedState; btVector3 m_oldPickingPos; btVector3 m_hitPos; btScalar m_oldPickingDist; struct GUIHelperInterface* m_guiHelper; CommonRigidBodyBase(struct GUIHelperInterface* helper) :m_broadphase(0), m_dispatcher(0), m_solver(0), m_collisionConfiguration(0), m_dynamicsWorld(0), m_pickedBody(0), m_pickedConstraint(0), m_guiHelper(helper) { } virtual ~CommonRigidBodyBase() { } btDiscreteDynamicsWorld* getDynamicsWorld() { return m_dynamicsWorld; } virtual void createEmptyDynamicsWorld() { ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btDefaultCollisionConfiguration(); //m_collisionConfiguration->setConvexConvexMultipointIterations(); ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver; m_solver = sol; m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration); m_dynamicsWorld->setGravity(btVector3(0, -10, 0)); } virtual void stepSimulation(float deltaTime) { if (m_dynamicsWorld) { m_dynamicsWorld->stepSimulation(deltaTime, 0); } } virtual void physicsDebugDraw(int debugFlags) { if (m_dynamicsWorld && m_dynamicsWorld->getDebugDrawer()) { m_dynamicsWorld->getDebugDrawer()->setDebugMode(debugFlags); m_dynamicsWorld->debugDrawWorld(); } } virtual void exitPhysics() { removePickingConstraint(); //cleanup in the reverse order of creation/initialization //remove the rigidbodies from the dynamics world and delete them if (m_dynamicsWorld) { int i; for (i = m_dynamicsWorld->getNumConstraints() - 1; i >= 0; i--) { m_dynamicsWorld->removeConstraint(m_dynamicsWorld->getConstraint(i)); } for (i = m_dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--) { btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i]; btRigidBody* body = btRigidBody::upcast(obj); if (body && body->getMotionState()) { delete body->getMotionState(); } m_dynamicsWorld->removeCollisionObject(obj); delete obj; } } //delete collision shapes for (int j = 0; j<m_collisionShapes.size(); j++) { btCollisionShape* shape = m_collisionShapes[j]; delete shape; } m_collisionShapes.clear(); delete m_dynamicsWorld; m_dynamicsWorld=0; delete m_solver; m_solver=0; delete m_broadphase; m_broadphase=0; delete m_dispatcher; m_dispatcher=0; delete m_collisionConfiguration; m_collisionConfiguration=0; } virtual void debugDraw(int debugDrawFlags) { if (m_dynamicsWorld) { if (m_dynamicsWorld->getDebugDrawer()) { m_dynamicsWorld->getDebugDrawer()->setDebugMode(debugDrawFlags); } m_dynamicsWorld->debugDrawWorld(); } } virtual bool keyboardCallback(int key, int state) { if ((key==B3G_F3) && state && m_dynamicsWorld) { btDefaultSerializer* serializer = new btDefaultSerializer(); m_dynamicsWorld->serialize(serializer); FILE* file = fopen("testFile.bullet","wb"); fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file); fclose(file); //b3Printf("btDefaultSerializer wrote testFile.bullet"); delete serializer; return true; } return false;//don't handle this key } btVector3 getRayTo(int x,int y) { CommonRenderInterface* renderer = m_guiHelper->getRenderInterface(); if (!renderer) { btAssert(0); return btVector3(0,0,0); } float top = 1.f; float bottom = -1.f; float nearPlane = 1.f; float tanFov = (top-bottom)*0.5f / nearPlane; float fov = btScalar(2.0) * btAtan(tanFov); btVector3 camPos,camTarget; renderer->getActiveCamera()->getCameraPosition(camPos); renderer->getActiveCamera()->getCameraTargetPosition(camTarget); btVector3 rayFrom = camPos; btVector3 rayForward = (camTarget-camPos); rayForward.normalize(); float farPlane = 10000.f; rayForward*= farPlane; btVector3 rightOffset; btVector3 cameraUp=btVector3(0,0,0); cameraUp[m_guiHelper->getAppInterface()->getUpAxis()]=1; btVector3 vertical = cameraUp; btVector3 hor; hor = rayForward.cross(vertical); hor.safeNormalize(); vertical = hor.cross(rayForward); vertical.safeNormalize(); float tanfov = tanf(0.5f*fov); hor *= 2.f * farPlane * tanfov; vertical *= 2.f * farPlane * tanfov; btScalar aspect; float width = float(renderer->getScreenWidth()); float height = float (renderer->getScreenHeight()); aspect = width / height; hor*=aspect; btVector3 rayToCenter = rayFrom + rayForward; btVector3 dHor = hor * 1.f/width; btVector3 dVert = vertical * 1.f/height; btVector3 rayTo = rayToCenter - 0.5f * hor + 0.5f * vertical; rayTo += btScalar(x) * dHor; rayTo -= btScalar(y) * dVert; return rayTo; } virtual bool mouseMoveCallback(float x,float y) { CommonRenderInterface* renderer = m_guiHelper->getRenderInterface(); if (!renderer) { btAssert(0); return false; } btVector3 rayTo = getRayTo(int(x), int(y)); btVector3 rayFrom; renderer->getActiveCamera()->getCameraPosition(rayFrom); movePickedBody(rayFrom,rayTo); return false; } virtual bool mouseButtonCallback(int button, int state, float x, float y) { CommonRenderInterface* renderer = m_guiHelper->getRenderInterface(); if (!renderer) { btAssert(0); return false; } CommonWindowInterface* window = m_guiHelper->getAppInterface()->m_window; #if 0 if (window->isModifierKeyPressed(B3G_ALT)) { printf("ALT pressed\n"); } else { printf("NO ALT pressed\n"); } if (window->isModifierKeyPressed(B3G_SHIFT)) { printf("SHIFT pressed\n"); } else { printf("NO SHIFT pressed\n"); } if (window->isModifierKeyPressed(B3G_CONTROL)) { printf("CONTROL pressed\n"); } else { printf("NO CONTROL pressed\n"); } #endif if (state==1) { if(button==0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL) )) { btVector3 camPos; renderer->getActiveCamera()->getCameraPosition(camPos); btVector3 rayFrom = camPos; btVector3 rayTo = getRayTo(int(x),int(y)); pickBody(rayFrom, rayTo); } } else { if (button==0) { removePickingConstraint(); //remove p2p } } //printf("button=%d, state=%d\n",button,state); return false; } virtual bool pickBody(const btVector3& rayFromWorld, const btVector3& rayToWorld) { if (m_dynamicsWorld==0) return false; btCollisionWorld::ClosestRayResultCallback rayCallback(rayFromWorld, rayToWorld); m_dynamicsWorld->rayTest(rayFromWorld, rayToWorld, rayCallback); if (rayCallback.hasHit()) { btVector3 pickPos = rayCallback.m_hitPointWorld; btRigidBody* body = (btRigidBody*)btRigidBody::upcast(rayCallback.m_collisionObject); if (body) { //other exclusions? if (!(body->isStaticObject() || body->isKinematicObject())) { m_pickedBody = body; m_savedState = m_pickedBody->getActivationState(); m_pickedBody->setActivationState(DISABLE_DEACTIVATION); //printf("pickPos=%f,%f,%f\n",pickPos.getX(),pickPos.getY(),pickPos.getZ()); btVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos; btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*body, localPivot); m_dynamicsWorld->addConstraint(p2p, true); m_pickedConstraint = p2p; btScalar mousePickClamping = 30.f; p2p->m_setting.m_impulseClamp = mousePickClamping; //very weak constraint for picking p2p->m_setting.m_tau = 0.001f; } } // pickObject(pickPos, rayCallback.m_collisionObject); m_oldPickingPos = rayToWorld; m_hitPos = pickPos; m_oldPickingDist = (pickPos - rayFromWorld).length(); // printf("hit !\n"); //add p2p } return false; } virtual bool movePickedBody(const btVector3& rayFromWorld, const btVector3& rayToWorld) { if (m_pickedBody && m_pickedConstraint) { btPoint2PointConstraint* pickCon = static_cast<btPoint2PointConstraint*>(m_pickedConstraint); if (pickCon) { //keep it at the same picking distance btVector3 newPivotB; btVector3 dir = rayToWorld - rayFromWorld; dir.normalize(); dir *= m_oldPickingDist; newPivotB = rayFromWorld + dir; pickCon->setPivotB(newPivotB); return true; } } return false; } virtual void removePickingConstraint() { if (m_pickedConstraint) { m_pickedBody->forceActivationState(m_savedState); m_pickedBody->activate(); m_dynamicsWorld->removeConstraint(m_pickedConstraint); delete m_pickedConstraint; m_pickedConstraint = 0; m_pickedBody = 0; } } btBoxShape* createBoxShape(const btVector3& halfExtents) { btBoxShape* box = new btBoxShape(halfExtents); return box; } btRigidBody* createRigidBody(float mass, const btTransform& startTransform, btCollisionShape* shape, const btVector4& color = btVector4(1, 0, 0, 1)) { btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE)); //rigidbody is dynamic if and only if mass is non zero, otherwise static bool isDynamic = (mass != 0.f); btVector3 localInertia(0, 0, 0); if (isDynamic) shape->calculateLocalInertia(mass, localInertia); //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects #define USE_MOTIONSTATE 1 #ifdef USE_MOTIONSTATE btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform); btRigidBody::btRigidBodyConstructionInfo cInfo(mass, myMotionState, shape, localInertia); btRigidBody* body = new btRigidBody(cInfo); //body->setContactProcessingThreshold(m_defaultContactProcessingThreshold); #else btRigidBody* body = new btRigidBody(mass, 0, shape, localInertia); body->setWorldTransform(startTransform); #endif// body->setUserIndex(-1); m_dynamicsWorld->addRigidBody(body); return body; } virtual void renderScene() { { m_guiHelper->syncPhysicsToGraphics(m_dynamicsWorld); } { m_guiHelper->render(m_dynamicsWorld); } } }; #endif //COMMON_RIGID_BODY_SETUP_H
[ "ztzhang@mit.edu" ]
ztzhang@mit.edu
f367f5e924ba463dad859ff6300b4df1895a5360
e02904319de957e9e9df9062051de0d5a3737a24
/util/timingtest.cpp
bbf6f9c2a224fb88277b7eedb8c2f6ccfcb942d9
[ "MIT" ]
permissive
murfreesboro/cppints
0a523392a16163b22211a11651fbeef241e9b0d9
a7beaac034e2bfae8e71997b322133906d1afcaf
refs/heads/master
2021-01-18T06:57:48.359493
2016-10-27T15:46:45
2016-10-27T15:46:45
23,126,858
1
0
null
null
null
null
UTF-8
C++
false
false
7,228
cpp
// // this is for testing the timing of the given individual integrals // #include "libgen.h" #include <boost/algorithm/string.hpp> // string handling #include <boost/lexical_cast.hpp> #include <boost/timer.hpp> using namespace boost; extern void hgp_os_eri_sp_sp_sp_sp(const UInt& inp2, const UInt& jnp2, const Double& pMax, const Double& omega, const Double* icoe, const Double* iexp, const Double* ifac, const Double* P, const Double* A, const Double* B, const Double* jcoe, const Double* jexp, const Double* jfac, const Double* Q, const Double* C, const Double* D, Double* abcd); extern void hgp_os_eri_sp_sp_sp_sp_d1(const UInt& inp2, const UInt& jnp2, const Double& pMax, const Double& omega, const Double* icoe, const Double* iexp, const Double* iexpdiff, const Double* ifac, const Double* P, const Double* A, const Double* B, const Double* jcoe, const Double* jexp, const Double* jexpdiff, const Double* jfac, const Double* Q, const Double* C, const Double* D, Double* abcd); Int main(int argc, char* argv[]) { ///////////////////////////////////////////////////////////////////////////// // setting the shell data // all of shell data are in default to be composite shell // which contains two sub-shells ///////////////////////////////////////////////////////////////////////////// // shell 1 Int inp = 2; vector<Double> iexp(inp); vector<Double> icoe(2*inp); iexp[0] = 0.1812885; iexp[1] = 0.0442493; icoe[0] = 0.1193324; icoe[1] = 0.1608542; icoe[2] = 0.8434564; icoe[3] = 0.0689991; Double A[3]; A[0] = 1.0; A[1] = 0.0; A[2] = 0.0; // shell 2 Int jnp = 2; vector<Double> jexp(jnp); vector<Double> jcoe(2*jnp); jexp[0] = 0.1439130; jexp[1] = 0.0914760; jcoe[0] = 6.139703E-02; jcoe[1] = 3.061130E-01; jcoe[2] = 1.154890; jcoe[3] = 0.1891265; Double B[3]; B[0] = 0.0; B[1] = 1.0; B[2] = 0.0; // shell 3 Int knp = 2; vector<Double> kexp(knp); vector<Double> kcoe(2*knp); kexp[0] = 0.03628970; kexp[1] = 0.14786010; kcoe[0] = 0.09996723; kcoe[1] = 0.39951283; kcoe[2] = 0.70011547; kcoe[3] = 0.15591627; Double C[3]; C[0] = 0.0; C[1] = 0.0; C[2] = 1.0; // shell 4 Int lnp = 2; vector<Double> lexp(lnp); vector<Double> lcoe(2*lnp); lexp[0] = 0.01982050; lexp[1] = 0.16906180; lcoe[0] = 0.06723; lcoe[1] = 0.51283; lcoe[2] = 0.30011547; lcoe[3] = 0.5591627; Double D[3]; D[0] = 0.0; D[1] = 1.0; D[2] = 1.0; ///////////////////////////////////////////////////////////////////////////// // setting the shell data // all of shell data are in default to be composite shell // which contains two sub-shells ///////////////////////////////////////////////////////////////////////////// // // form the data for hgp calculation // firstly it's the bra side // Double AB2 = (A[0]-B[0])*(A[0]-B[0])+(A[1]-B[1])*(A[1]-B[1])+(A[2]-B[2])*(A[2]-B[2]); Int inp2 = inp*jnp; vector<Double> iexp2(inp2,ZERO); vector<Double> fbra(inp2,ZERO); vector<Double> P(3*inp2,ZERO); vector<Double> iexpdiff(inp2,ZERO); Int count = 0; for(Int jp=0; jp<jnp; jp++) { for(Int ip=0; ip<inp; ip++) { // prefactors etc. Double ia = iexp[ip]; Double ja = jexp[jp]; Double alpla= ia+ja; Double diff = ia-ja; Double ab = -ia*ja/alpla; Double pref = exp(ab*AB2)*pow(PI/alpla,1.5E0); iexp2[count]= ONE/alpla; fbra[count] = pref; iexpdiff[count]= diff; // form P point according to the // Gaussian pritimive product theorem Double adab = ia/alpla; Double bdab = ja/alpla; Double Px = A[0]*adab + B[0]*bdab; Double Py = A[1]*adab + B[1]*bdab; Double Pz = A[2]*adab + B[2]*bdab; P[3*count+0]= Px; P[3*count+1]= Py; P[3*count+2]= Pz; count++; } } // now it's ket side data Double CD2 = (C[0]-D[0])*(C[0]-D[0])+(C[1]-D[1])*(C[1]-D[1])+(C[2]-D[2])*(C[2]-D[2]); Int jnp2 = knp*lnp; vector<Double> jexp2(jnp2,ZERO); vector<Double> jexpdiff(jnp2,ZERO); vector<Double> fket(jnp2,ZERO); vector<Double> Q(3*jnp2,ZERO); count = 0; for(Int lp=0; lp<lnp; lp++) { for(Int kp=0; kp<knp; kp++) { // prefactors etc. Double ia = kexp[kp]; Double ja = lexp[lp]; Double alpla= ia+ja; Double diff = ia-ja; Double ab = -ia*ja/alpla; Double pref = exp(ab*CD2)*pow(PI/alpla,1.5E0); jexp2[count]= ONE/alpla; fket[count] = pref; jexpdiff[count]= diff; // form P point according to the // Gaussian pritimive product theorem Double adab = ia/alpla; Double bdab = ja/alpla; Double Qx = C[0]*adab + D[0]*bdab; Double Qy = C[1]*adab + D[1]*bdab; Double Qz = C[2]*adab + D[2]*bdab; Q[3*count+0]= Qx; Q[3*count+1]= Qy; Q[3*count+2]= Qz; count++; } } ///////////////////////////////////////////////////////////////////////////// // now it's the formal timing compare ///////////////////////////////////////////////////////////////////////////// // set the angular momentum of the results // here the user need to do that Int lmin1 = 0; Int lmax1 = 1; Int lmin2 = 0; Int lmax2 = 1; Int lmin3 = 0; Int lmax3 = 1; Int lmin4 = 0; Int lmax4 = 1; Int nBas1 = ((lmax1+1)*(lmax1+2)*(lmax1+3)-lmin1*(lmin1+1)*(lmin1+2))/6; Int nBas2 = ((lmax2+1)*(lmax2+2)*(lmax2+3)-lmin2*(lmin2+1)*(lmin2+2))/6; Int nBas3 = ((lmax3+1)*(lmax3+2)*(lmax3+3)-lmin3*(lmin3+1)*(lmin3+2))/6; Int nBas4 = ((lmax4+1)*(lmax4+2)*(lmax4+3)-lmin4*(lmin4+1)*(lmin4+2))/6; // make the coefficients pair // bra side Int nL1 = lmax1-lmin1+1; Int nL2 = lmax2-lmin2+1; count = 0; vector<Double> braCoePair(inp*jnp*nL1*nL2,ZERO); for(Int j=0; j<nL2; j++) { for(Int i=0; i<nL1; i++) { for(Int jp=0; jp<jnp; jp++) { for(Int ip=0; ip<inp; ip++) { Double ic = icoe[ip+i*inp]; Double jc = jcoe[jp+j*jnp]; braCoePair[count] = ic*jc; count++; } } } } // ket side nL1 = lmax3-lmin3+1; nL2 = lmax4-lmin4+1; count = 0; vector<Double> ketCoePair(knp*lnp*nL1*nL2,ZERO); for(Int j=0; j<nL2; j++) { for(Int i=0; i<nL1; i++) { for(Int jp=0; jp<lnp; jp++) { for(Int ip=0; ip<knp; ip++) { Double ic = kcoe[ip+i*inp]; Double jc = lcoe[jp+j*jnp]; ketCoePair[count] = ic*jc; count++; } } } } // now set up the result vectors // N is the total number of running times Int N = 1000000; Double pMax = 1.0E0; Double omega = 0.0E0; vector<Double> result1(nBas1*nBas2*nBas3*nBas4); timer t1; for(Int i=0; i<N; i++) { hgp_os_eri_sp_sp_sp_sp(inp2,jnp2,pMax,omega, &braCoePair.front(),&iexp2.front(),&fbra.front(),&P.front(),A,B, &ketCoePair.front(),&jexp2.front(),&fket.front(),&Q.front(),C,D, &result1.front()); } printf("hgp sp_sp_sp_sp energy time consuming: %-14.7f\n", t1.elapsed()); // this is another integral file vector<Double> result2(nBas1*nBas2*nBas3*nBas4*9); // dimension is responsible by the user timer t2; for(Int i=0; i<N; i++) { hgp_os_eri_sp_sp_sp_sp_d1(inp2,jnp2,pMax,omega, &braCoePair.front(),&iexp2.front(),&iexpdiff.front(),&fbra.front(),&P.front(),A,B, &ketCoePair.front(),&jexp2.front(),&jexpdiff.front(),&fket.front(),&Q.front(),C,D, &result2.front()); } printf("hgp sp_sp_sp_sp gradient time consuming: %-14.7f\n", t2.elapsed()); return 0; }
[ "fhilosophierr@gmail.com" ]
fhilosophierr@gmail.com