hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
031a0a878b8f1e0a2ef224cd8448a6a7acf14f9f
3,873
h
C
media/midi/midi_service.h
Yannic/chromium
ab32e8aacb08c9fce0dc4bf09eec456ba46e3710
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
76
2020-09-02T03:05:41.000Z
2022-03-30T04:40:55.000Z
media/midi/midi_service.h
blueboxd/chromium-legacy
07223bc94bd97499909c9ed3c3f5769d718fe2e0
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
45
2020-09-02T03:21:37.000Z
2022-03-31T22:19:45.000Z
media/midi/midi_service.h
Yannic/chromium
ab32e8aacb08c9fce0dc4bf09eec456ba46e3710
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
8
2020-07-22T18:49:18.000Z
2022-02-08T10:27:16.000Z
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_MIDI_MIDI_SERVICE_H_ #define MEDIA_MIDI_MIDI_SERVICE_H_ #include <stdint.h> #include <memory> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/synchronization/lock.h" #include "base/task/single_thread_task_runner.h" #include "base/threading/thread.h" #include "base/time/time.h" #include "media/midi/midi_export.h" #include "media/midi/midi_manager.h" namespace midi { class TaskService; // Manages MidiManager backends. This class expects to be constructed and // destructed on the browser main thread, but methods can be called on both // the main thread and the I/O thread. class MIDI_EXPORT MidiService final { public: class MIDI_EXPORT ManagerFactory { public: ManagerFactory() = default; ManagerFactory(const ManagerFactory&) = delete; ManagerFactory& operator=(const ManagerFactory&) = delete; virtual ~ManagerFactory() = default; virtual std::unique_ptr<MidiManager> Create(MidiService* service); }; // Converts Web MIDI timestamp to base::TimeDelta delay for PostDelayedTask. static base::TimeDelta TimestampToTimeDeltaDelay(base::TimeTicks timestamp); MidiService(); // Customized ManagerFactory can be specified in the constructor for testing. explicit MidiService(std::unique_ptr<ManagerFactory> factory); MidiService(const MidiService&) = delete; MidiService& operator=(const MidiService&) = delete; ~MidiService(); // Called on the browser main thread to notify the I/O thread will stop and // the instance will be destructed on the main thread soon. void Shutdown(); // A client calls StartSession() to receive and send MIDI data. void StartSession(MidiManagerClient* client); // A client calls EndSession() to stop receiving MIDI data. // Returns false if |client| did not start a session. bool EndSession(MidiManagerClient* client); // A client calls DispatchSendMidiData() to send MIDI data. void DispatchSendMidiData(MidiManagerClient* client, uint32_t port_index, const std::vector<uint8_t>& data, base::TimeTicks timestamp); // Returns a SingleThreadTaskRunner reference to serve MidiManager. Each // TaskRunner will be constructed on demand. // MidiManager that supports the dynamic instantiation feature will use this // method to post tasks that should not run on I/O. Since TaskRunners outlive // MidiManager, each task should ensure that MidiManager that posted the task // is still alive while accessing |this|. TaskRunners will be reused when // another MidiManager is instantiated. // TODO(toyoshim): Remove this interface. scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(size_t runner_id); // Obtains a TaskService that lives with MidiService. TaskService* task_service() { return task_service_.get(); } private: // ManagerFactory passed in the constructor. std::unique_ptr<ManagerFactory> manager_factory_; // Holds MidiManager instance. The MidiManager is constructed and destructed // on the I/O thread, and all MidiManager methods should be called on the I/O // thread. std::unique_ptr<MidiManager> manager_; // Holds TaskService instance. std::unique_ptr<TaskService> task_service_; // TaskRunner to destruct |manager_| on the right thread. scoped_refptr<base::SingleThreadTaskRunner> manager_destructor_runner_; // Protects all members above. base::Lock lock_; // Threads to host SingleThreadTaskRunners. std::vector<std::unique_ptr<base::Thread>> threads_; // Protects |threads_|. base::Lock threads_lock_; }; } // namespace midi #endif // MEDIA_MIDI_MIDI_SERVICE_H_
34.580357
79
0.743868
[ "vector" ]
03278b069293488e9c8053741fb02748c7f50ce1
4,320
h
C
src/mongo/db/query/plan_cache_indexability.h
LightBitsLabs/mongo
9480ef00a8df2464457ab0f31c7a336f882e8ec1
[ "Apache-2.0" ]
25
2016-12-07T09:39:51.000Z
2021-12-16T11:17:37.000Z
src/mongo/db/query/plan_cache_indexability.h
Man1029/CMONGO
c40380caa14e05509f46993aa8b8da966b09b0b5
[ "ECL-2.0", "Apache-2.0" ]
1
2015-05-29T16:12:10.000Z
2015-05-29T16:12:10.000Z
src/mongo/db/query/plan_cache_indexability.h
Man1029/CMONGO
c40380caa14e05509f46993aa8b8da966b09b0b5
[ "ECL-2.0", "Apache-2.0" ]
23
2017-01-22T03:35:26.000Z
2021-12-16T11:17:39.000Z
/** * Copyright (C) 2015 10gen Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #pragma once #include <vector> #include "mongo/base/disallow_copying.h" #include "mongo/stdx/functional.h" #include "mongo/util/string_map.h" namespace mongo { class BSONObj; class MatchExpression; struct IndexEntry; using IndexabilityDiscriminator = stdx::function<bool(const MatchExpression* me)>; using IndexabilityDiscriminators = std::vector<IndexabilityDiscriminator>; /** * PlanCacheIndexabilityState holds a set of "indexability discriminators" for certain paths. * An indexability discriminator is a binary predicate function, used to classify match * expressions based on the data values in the expression. */ class PlanCacheIndexabilityState { MONGO_DISALLOW_COPYING(PlanCacheIndexabilityState); public: PlanCacheIndexabilityState() = default; /** * Gets the set of discriminators associated with 'path'. Returns an empty set if no * discriminators are registered for 'path'. * * The object returned by reference is valid until the next call to updateDiscriminators() * or until destruction of 'this', whichever is first. */ const IndexabilityDiscriminators& getDiscriminators(StringData path) const; /** * Clears discriminators for all paths, and regenerate them from 'indexEntries'. */ void updateDiscriminators(const std::vector<IndexEntry>& indexEntries); private: /** * Adds sparse index discriminators for the sparse index with the given key pattern to * '_pathDiscriminatorsMap'. * * A sparse index discriminator distinguishes equality matches to null from other expression * types. For example, this allows the predicate {a: 1} to be considered of a different * shape from the predicate {a: null}, if there is a sparse index defined with "a" as an * element of the key pattern. The former predicate is compatibile with this index, but the * latter is not compatible. */ void processSparseIndex(const BSONObj& keyPattern); /** * Adds partial index discriminators for the partial index with the given filter expression * to '_pathDiscriminatorsMap'. * * A partial index discriminator distinguishes expressions that match a given partial index * predicate from expressions that don't match the partial index predicate. For example, * this allows the predicate {a: {$gt: 5}} to be considered a different shape than the * predicate {a: {$gt: -5}}, if there is a partial index defined with document filter {a: * {$gt: 0}}. The former is compatible with this index, but the latter is not compatible. */ void processPartialIndex(const MatchExpression* filterExpr); using PathDiscriminatorsMap = StringMap<IndexabilityDiscriminators>; PathDiscriminatorsMap _pathDiscriminatorsMap; }; } // namespace mongo
42.772277
96
0.731713
[ "object", "shape", "vector" ]
032a0ecf6e3e49dbdb44700e93e36b35a6b039f3
5,629
h
C
enduser/troubleshoot/tshoot/threadpool.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
enduser/troubleshoot/tshoot/threadpool.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
enduser/troubleshoot/tshoot/threadpool.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
// // MODULE: ThreadPool.h // // PURPOSE: interface for classes for high level of pool thread activity // // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint // // COMPANY: Saltmine Creative, Inc. (206)-284-7511 support@saltmine.com // // AUTHOR: Joe Mabel, based on earlier (8-2-96) work by Roman Mach // // ORIGINAL DATE: 9/23/98 // // NOTES: // 1. // // Version Date By Comments //-------------------------------------------------------------------- // V0.1 - RM Original // V3.0 9/23/98 JM better encapsulation & some chages to algorithm // #if !defined(AFX_THREADPOOL_H__0F43119D_5247_11D2_95FC_00C04FC22ADD__INCLUDED_) #define AFX_THREADPOOL_H__0F43119D_5247_11D2_95FC_00C04FC22ADD__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 #include <time.h> #include "stateless.h" class CPoolQueue; // forward reference class APGTSContext; // forward reference // Status class for pool threads, used by both the thread pool in order to handle stuck threads // as well as by the status page for reporting on thread status. If time permits, we should // convert the member variable to private and add get-set methods in order to be consistent with // the rest of the code. class CPoolThreadStatus { public: time_t m_timeCreated; // time CThreadPool::CThreadControl object was constructed // If this CPoolThreadStatusobject is the return of a thread // status request, 0 here implies there is no such // CThreadPool::CThreadControl object DWORD m_seconds; // time elapsed since last started or finished a request. // That is, how long this thread has been working on a task // (or how long since it finished its last task) // If task was never started - this is time since m_timeCreated bool m_bWorking; // true = currently working on a request. bool m_bFailed; // true = encountered a majorly unexpected situation & // chose to exit. CString m_strTopic; // current topic we are working on, // It is not initialized in the constructor so it can be zero length // Is used to transport the current topic name back to the status page. CString m_strBrowser; // Current client browser. Used to transport the browser name back to // the status page. CString m_strClientIP; // Current Client IP address. Used to transport the client IP address // back to the status page. CPoolThreadStatus() : m_timeCreated(0), m_seconds(0), m_bWorking(false), m_bFailed(false) {}; bool operator < (const CPoolThreadStatus&) const {return false;} bool operator == (const CPoolThreadStatus&) const {return false;} }; class CSniffConnector; class CThreadPool { friend class CDBLoadConfiguration; private: class CThreadControl { private: HANDLE m_hThread; // thread handle HANDLE m_hevDone; // Thread uses this event only to say, effectively, // "outta here" as it dies. HANDLE m_hMutex; // protect access to m_time, m_bWorking. bool m_bExit; // set true when either a normal queued-up task or an explicit // "kill" wants the thread to break out of its loop. CPoolQueue *m_pPoolQueue; // point to the one and only instance of CPoolQueue time_t m_timeCreated; // time this object was constructed time_t m_time; // time last started or finished a request; init'd 0, but will // be non-zero if thread ever used. bool m_bWorking; // true = currently working on a request. bool m_bFailed; // true = encountered a majorly unexpected situation & // chose to exit. CNameStateless m_strBrowser; // Current client browser. CNameStateless m_strClientIP; // Current Client IP address. APGTSContext *m_pContext; // pointer to context of a request. CSniffConnector *m_pSniffConnector; // pointer to sniff connector base class, // the only purpose of storing this pointer // as member variable is to pass it to // constructor of APGTSContext public: CThreadControl(CSniffConnector*); ~CThreadControl(); // This function may throw an exceptions of type CGeneralException. DWORD Initialize(CPoolQueue * pPoolQueue); void Kill(DWORD milliseconds); bool WaitForThreadToFinish(DWORD milliseconds); void WorkingStatus(CPoolThreadStatus & status); time_t GetTimeCreated() const; private: static UINT WINAPI PoolTask( LPVOID lpParams ); bool ProcessRequest(); void PoolTaskLoop(); void Lock(); void Unlock(); bool Exit(); }; public: CThreadPool(CPoolQueue * pPoolQueue, CSniffConnector * pSniffConnector); ~CThreadPool(); DWORD GetStatus() const; // get any error during construction DWORD GetWorkingThreadCount() const; void ExpandPool(DWORD dwDesiredThreadCount); bool ReinitializeThread(DWORD i); void ReinitializeStuckThreads(); bool ThreadStatus(DWORD i, CPoolThreadStatus &status); private: void DestroyThreads(); private: DWORD m_dwErr; CThreadControl **m_ppThreadCtl; // thread management CSniffConnector *m_pSniffConnector; // pointer to sniff connector base class, // the only purpose of storing this pointer // as member variable is to pass it to // constructor of CThreadControl DWORD m_dwWorkingThreadCount; // threads actually created CPoolQueue *m_pPoolQueue; // Keeps track of user requests queued up to be serviced // by working threads (a.k.a. "pool threads") }; #endif // !defined(AFX_THREADPOOL_H__0F43119D_5247_11D2_95FC_00C04FC22ADD__INCLUDED_)
39.090278
97
0.699414
[ "object" ]
032db102c694b45c0484999a51a751e9e7eb233d
6,824
h
C
avogadro/qtplugins/bondcentrictool/bondcentrictool.h
aerkiaga/avogadrolibs
f0a64061f521dce156e67e07118db546da6b9f1b
[ "BSD-3-Clause" ]
null
null
null
avogadro/qtplugins/bondcentrictool/bondcentrictool.h
aerkiaga/avogadrolibs
f0a64061f521dce156e67e07118db546da6b9f1b
[ "BSD-3-Clause" ]
null
null
null
avogadro/qtplugins/bondcentrictool/bondcentrictool.h
aerkiaga/avogadrolibs
f0a64061f521dce156e67e07118db546da6b9f1b
[ "BSD-3-Clause" ]
null
null
null
/****************************************************************************** This source file is part of the Avogadro project. Copyright 2013 Kitware, Inc. Adapted from Avogadro 1.x with the following authors' permission: Copyright (C) 2007 by Shahzad Ali Copyright (C) 2007 by Ross Braithwaite Copyright (C) 2007 by James Bunt Copyright (C) 2007,2008 by Marcus D. Hanwell Copyright (C) 2006,2007 by Benoit Jacob This source code is released under the New BSD License, (the "License"). 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 AVOGADRO_QTPLUGINS_BONDCENTRICTOOL_H #define AVOGADRO_QTPLUGINS_BONDCENTRICTOOL_H #include <avogadro/qtgui/toolplugin.h> #include <avogadro/rendering/primitive.h> #include <avogadro/qtgui/persistentatom.h> #include <avogadro/qtgui/persistentbond.h> #include <avogadro/qtgui/rwmolecule.h> #include <avogadro/core/avogadrocore.h> #include <QtCore/QPoint> #include <Eigen/Geometry> #include <set> namespace Avogadro { namespace Rendering { class GeometryNode; } namespace QtPlugins { /** * @brief BondCentricTool manipulates molecular geometry by adjusting bond * angles/lengths. * * @note This class is adapted from the class of the same name in Avogadro 1.x, * written by Shahzad Ali, Ross Braithwaite, James Bunt, Marcus D. Hanwell, and * Benoit Jacob. */ class BondCentricTool : public QtGui::ToolPlugin { Q_OBJECT public: explicit BondCentricTool(QObject* parent_ = nullptr); ~BondCentricTool() override; QString name() const override; QString description() const override; unsigned char priority() const override { return 40; } QAction* activateAction() const override { return m_activateAction; } QWidget* toolWidget() const override; void setMolecule(QtGui::Molecule*) override; void setEditMolecule(QtGui::RWMolecule*) override; void setGLWidget(QtOpenGL::GLWidget* widget) override; void setGLRenderer(Rendering::GLRenderer* ren) override; QUndoCommand* mousePressEvent(QMouseEvent* e) override; QUndoCommand* mouseDoubleClickEvent(QMouseEvent* e) override; QUndoCommand* mouseMoveEvent(QMouseEvent* e) override; QUndoCommand* mouseReleaseEvent(QMouseEvent* e) override; void draw(Rendering::GroupNode& node) override; private: enum MoveState { IgnoreMove = 0, RotatePlane, RotateBondedAtom, AdjustBondLength, RotateNeighborAtom }; enum ResetBondBehavior { KeepBond = 0, ResetBond }; void reset(ResetBondBehavior bond = ResetBond); void initializeBondVectors(); void updateBondVector(); // Mouse press event handlers: QUndoCommand* initRotatePlane(QMouseEvent* e, const Rendering::Identifier& ident); QUndoCommand* initRotateBondedAtom(QMouseEvent* e, const QtGui::RWAtom& clickedAtom); QUndoCommand* initAdjustBondLength(QMouseEvent* e, const QtGui::RWAtom& clickedAtom); QUndoCommand* initRotateNeighborAtom(QMouseEvent* e, const QtGui::RWAtom& clickedAtom, const QtGui::RWAtom& anchorAtom); // Mouse move event handlers: QUndoCommand* rotatePlane(QMouseEvent* e); QUndoCommand* rotateBondedAtom(QMouseEvent* e); QUndoCommand* adjustBondLength(QMouseEvent* e); QUndoCommand* rotateNeighborAtom(QMouseEvent* e); // Drawing helpers: void drawBondQuad(Rendering::GeometryNode& node, const QtGui::RWBond& bond) const; void drawBondAngle(Rendering::GeometryNode& node, const QtGui::RWBond& selectedBond, const QtGui::RWBond& movingBond) const; void drawBondLengthLabel(Rendering::GeometryNode& node, const QtGui::RWBond& bond); void drawAtomBondAngles(Rendering::GeometryNode& node, const QtGui::RWAtom& atom, const QtGui::RWBond& anchorBond); void drawAtomBondAngle(Rendering::GeometryNode& node, const QtGui::RWAtom& atom, const QtGui::RWBond& anchorBond, const QtGui::RWBond& otherBond, const Vector3ub& color); // Bond utilities bool bondContainsAtom(const QtGui::RWBond& bond, const QtGui::RWAtom& atom) const; // The 'fragment' is the SkeletonTree of the 1.x implementation. It is a list // of atoms created by buildFragment(bond, startAtom), which walks the bonds // connected to startAtom (not including the passed-in bond), adding each // atom it encounters to the list, and then walking that atom's bonds. If a // cycle is detected, only startAtom is added to m_fragment. void resetFragment() { m_fragment.clear(); } bool fragmentHasAtom(int uid) const; void buildFragment(const QtGui::RWBond& bond, const QtGui::RWAtom& startAtom); bool buildFragmentRecurse(const QtGui::RWBond& bond, const QtGui::RWAtom& startAtom, const QtGui::RWAtom& currentAtom); // Use transformFragment to transform the position of each atom in the // fragment by m_transform. void transformFragment() const; QAction* m_activateAction; QtGui::RWMolecule* m_molecule; Rendering::GLRenderer* m_renderer; MoveState m_moveState; QPoint m_clickedPoint; QPoint m_lastDragPoint; Vector3f m_bondVector; Vector3f m_planeNormalMouse; Vector3f m_planeNormal; // unique ids of atoms that will need to be moved: std::vector<int> m_fragment; Eigen::Affine3f m_transform; // Snap angles for RotatePlane. Angles are relative to m_planeSnapRef and // follow a right-hand rule around m_bondVector. Range is [-180, 180). std::set<float> m_planeSnapAngles; float m_planeSnapIncr; Vector3f m_planeSnapRef; bool m_snapPlaneToBonds; void updatePlaneSnapAngles(); void updateSnappedPlaneNormal(); QtGui::RWMolecule::PersistentBondType m_selectedBond; QtGui::RWMolecule::PersistentAtomType m_anchorAtom; QtGui::RWMolecule::PersistentAtomType m_clickedAtom; }; inline QString BondCentricTool::name() const { return tr("Bond centric manipulation tool."); } inline QString BondCentricTool::description() const { return tr("Tool used to edit molecular geometry by changing bond lengths and " "angles."); } } // namespace QtPlugins } // namespace Avogadro #endif // AVOGADRO_QTPLUGINS_BONDCENTRICTOOL_H
34.291457
80
0.690504
[ "geometry", "vector", "transform" ]
032e8399ab6110311a238d06e5c8890356b25df3
1,871
h
C
include/CImportScene.h
colinw7/CImportModel
1314163d3434dfa2d6516ed9618bbe2aa97adb2d
[ "MIT" ]
1
2021-12-23T02:23:52.000Z
2021-12-23T02:23:52.000Z
include/CImportScene.h
colinw7/CImportModel
1314163d3434dfa2d6516ed9618bbe2aa97adb2d
[ "MIT" ]
null
null
null
include/CImportScene.h
colinw7/CImportModel
1314163d3434dfa2d6516ed9618bbe2aa97adb2d
[ "MIT" ]
null
null
null
#ifndef CIMPORT_SCENE_H #define CIMPORT_SCENE_H #include <CImportBase.h> #include <CFile.h> #include <CMatrix3D.h> #include <CRGBA.h> #include <CAutoPtr.h> #include <map> class CGeomScene3D; class CGeomObject3D; class CGeomFace3D; class CGeomLine3D; class CGeomVertex3D; class CImportScene : public CImportBase { public: CImportScene(CGeomScene3D *scene=nullptr, const std::string &name="scene"); ~CImportScene(); bool read(CFile &file) override; CGeomScene3D &getScene() override { return *scene_; } CGeomObject3D &getObject(); CGeomScene3D *releaseScene() { pscene_.release(); return scene_; } private: void readScene(); void addObject(const std::string &name); void readPrimitive(const std::string &name); void readObject(const std::string &name); void readFaces(CGeomObject3D *object, int pface_num); void readLines(CGeomObject3D *object, int pface_num); void readVertices(CGeomObject3D *object); void readRotate(CGeomObject3D *object, int num_patches); void readColors(); void readTextures(); CMatrix3D readTransforms(); CGeomObject3D *getObject(const std::string &name); CGeomObject3D *getPrimitive(const std::string &name); int lookupCommand(const std::string &command, const char **commands); void getRGBA(int color, CRGBA *rgba); private: using NameObjMap = std::map<std::string, CGeomObject3D *>; using Names = std::vector<std::string>; CGeomScene3D* scene_ { nullptr }; CAutoPtr<CGeomScene3D> pscene_; CFile* file_ { nullptr }; NameObjMap objects_; NameObjMap primitives_; Names colors_; Names textures_; int orientation_ { 1 }; }; #endif
27.925373
82
0.642437
[ "object", "vector" ]
03335383be423b41ab03ca92292ebff956d1ee18
3,839
h
C
src/utils/rdsn_exp_delay.h
pengdu/bubblefs
9b27e191a287b3a1d012adfd3bab6a30629a5f33
[ "BSD-3-Clause" ]
1
2021-01-11T14:19:51.000Z
2021-01-11T14:19:51.000Z
src/utils/rdsn_exp_delay.h
pengdu/bubblefs
9b27e191a287b3a1d012adfd3bab6a30629a5f33
[ "BSD-3-Clause" ]
null
null
null
src/utils/rdsn_exp_delay.h
pengdu/bubblefs
9b27e191a287b3a1d012adfd3bab6a30629a5f33
[ "BSD-3-Clause" ]
null
null
null
/* * The MIT License (MIT) * * Copyright (c) 2015 Microsoft Corporation * * -=- Robust Distributed System Nucleus (rDSN) -=- * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ // rdsn/include/dsn/utility/exp_delay.h #ifndef BUBBLEFS_UTILS_RDSN_EXP_DELAY_H_ #define BUBBLEFS_UTILS_RDSN_EXP_DELAY_H_ #include <assert.h> #include <vector> #include "utils/rdsn_singleton.h" namespace bubblefs { namespace myrdsn { constexpr int MYRDSN_DELAY_COUNT = 6; static const double s_default_delay_points[MYRDSN_DELAY_COUNT] = {1.0, 1.2, 1.4, 1.6, 1.8, 2.0}; static const int s_default_delay[MYRDSN_DELAY_COUNT] = {0, 0, 1, 2, 5, 10}; // millieseconds class exp_delay { public: exp_delay() { memcpy((void *)_delay, (const void *)s_default_delay, sizeof(_delay)); _threshold = 0x0fffffff; } void initialize(const std::vector<int> &delays, int threshold) { assert((int)delays.size() == MYRDSN_DELAY_COUNT); int i = 0; for (auto &d : delays) { _delay[i++] = d; } _threshold = threshold; } void initialize(int threshold) { _threshold = threshold; } inline int delay(int value) { if (value >= _threshold) { double f = (double)value / (double)_threshold; int delay_milliseconds; if (f < s_default_delay_points[MYRDSN_DELAY_COUNT - 1]) { int idx = static_cast<int>((f - 1.0) / 0.2); delay_milliseconds = _delay[idx]; } else { delay_milliseconds = _delay[MYRDSN_DELAY_COUNT - 1]; } return delay_milliseconds; } else { return 0; } } private: int _delay[MYRDSN_DELAY_COUNT]; int _threshold; }; class shared_exp_delay { public: shared_exp_delay() { memcpy((void *)_delay, (const void *)s_default_delay, sizeof(_delay)); } void initialize(const std::vector<int> &delays) { assert((int)delays.size() == MYRDSN_DELAY_COUNT); int i = 0; for (auto &d : delays) { _delay[i++] = d; } } inline int delay(int value, int threshold) { if (value >= threshold) { double f = (double)value / (double)threshold; int delay_milliseconds; if (f < s_default_delay_points[MYRDSN_DELAY_COUNT - 1]) { int idx = static_cast<int>((f - 1.0) / 0.2); delay_milliseconds = _delay[idx]; } else { delay_milliseconds = _delay[MYRDSN_DELAY_COUNT - 1]; } return delay_milliseconds; } else { return 0; } } private: int _delay[MYRDSN_DELAY_COUNT]; }; } // namespace myrdsn } // namespace bubblefs #endif // BUBBLEFS_UTILS_RDSN_EXP_DELAY_H_
29.530769
97
0.637666
[ "vector" ]
033354700956353c475ba328e86eacc5182ea635
1,739
h
C
Sources/Vector.h
Leo-Besancon/RayTracer
4603d9abf95f36bfd58f18184e63a1d994049686
[ "MIT" ]
null
null
null
Sources/Vector.h
Leo-Besancon/RayTracer
4603d9abf95f36bfd58f18184e63a1d994049686
[ "MIT" ]
null
null
null
Sources/Vector.h
Leo-Besancon/RayTracer
4603d9abf95f36bfd58f18184e63a1d994049686
[ "MIT" ]
null
null
null
#pragma once class Vector { double _x; double _y; double _z; public: Vector() { }; Vector(double x, double y, double z) : _x(x), _y(y), _z(z) { }; ~Vector() { }; double get_x() const { return _x; }; double get_y() const { return _y; }; double get_z() const { return _z; }; void set_x(double x) { _x = x; }; void set_y(double y) { _y = y; }; void set_z(double z) { _z = z; }; double get_norm() const { return sqrt(_x*_x + _y * _y + _z * _z); }; double get_norm2() const { return (_x*_x + _y * _y + _z * _z); }; double min() const { return std::min(std::min(_x, _y), _z); } double max() const { return std::max(std::max(_x, _y), _z); } double moy() const { return ((_x + _y + _z) / 3.); } Vector min(double a) const { return Vector(std::min(a, _x), std::min(a, _y), std::min(a, _z)); } Vector max(double a) const { return Vector(std::max(a, _x), std::max(a, _y), std::max(a, _z)); } double scalar(Vector a) const { return (_x * a.get_x() + _y * a.get_y() + _z * a.get_z()); }; Vector cross(Vector a) const; Vector operator+(const Vector& a) const { return Vector(_x + a.get_x(), _y + a.get_y(), _z + a.get_z()); }; void operator+=(const Vector& a); Vector operator-(const Vector& a) const { return Vector(_x - a.get_x(), _y - a.get_y(), _z - a.get_z()); }; Vector operator*(double a) const { return Vector(_x*a, _y*a, _z*a); }; Vector operator/(double a) const { return Vector(_x/a, _y/a, _z/a); }; Vector operator*(const Vector& a) const { return Vector(_x * a.get_x(), _y * a.get_y(), _z * a.get_z());}; friend std::ostream& operator <<(std::ostream& sortie, const Vector& A); Vector normalize(); Vector rotate_x(double theta); Vector rotate_y(double theta); Vector rotate_z(double theta); };
34.098039
109
0.614146
[ "vector" ]
03366a03056dc6c872de83fc9f7cf72e753f67d7
1,730
c
C
tests/testthat/seir_int.c
cran/dde
73cef0df96a4170b855879a6a253ed8652bc5456
[ "MIT" ]
9
2016-06-16T06:06:07.000Z
2018-12-01T11:52:59.000Z
tests/testthat/seir_int.c
cran/dde
73cef0df96a4170b855879a6a253ed8652bc5456
[ "MIT" ]
16
2019-03-22T07:35:42.000Z
2021-01-27T09:16:59.000Z
tests/testthat/seir_int.c
cran/dde
73cef0df96a4170b855879a6a253ed8652bc5456
[ "MIT" ]
1
2020-03-20T17:25:02.000Z
2020-03-20T17:25:02.000Z
#include <dde/dde.h> #include <stddef.h> #include <math.h> void seir(size_t n, double t, double *y, double *dydt, void *data) { // Hard code the parameters for now, rather than passing them // through as `data`. double b = 1.0 / 10.0, N = 1e7, beta = 10.0, sigma = 1.0 / 3.0, delta = 1.0 / 21.0, lat_hum = 14.0; double Births = N * b, surv = exp(-b * lat_hum); const double tau = t - lat_hum; static const int idx[2] = {0, 2}; double ylag[2]; ylag_vec_int(tau, idx, 2, ylag); double S_lag = ylag[0], I_lag = ylag[1]; // This is an alternative mode that looks up the value of the lags // by index. // size_t lag_idx[2] = {0, 2}; // double y_lag[2]; // ylag_vec(tau, lag_idx, 2, y_lag); // double S_lag = y_lag[0], I_lag = y_lag[1]; const double S = y[0], E = y[1], I = y[2], R = y[3]; const double new_inf = beta * S * I / N; const double lag_inf = beta * S_lag * I_lag * surv / N; dydt[0] = Births - b * S - new_inf + delta * R; dydt[1] = new_inf - lag_inf - b * E; dydt[2] = lag_inf - (b + sigma) * I; dydt[3] = sigma * I - b * R - delta * R; } // An output function that takes the sum over all compartments in the // model. Unlike deSolve, these can be added and removed at runtime, // rather than just at compile time. // // The downside of this is that it's going to require an additional // set of calls to the lag functions to get access to lag variables. // That's going to complicate things a bit for odin I think. void seir_output(size_t n, double t, const double *y, size_t n_out, double *out, const void *data) { out[0] = y[0] + y[1] + y[2] + y[3]; } // This needs to be included exactly once per shared library. #include <dde/dde.c>
34.6
69
0.618497
[ "model" ]
0337b36a6d873438e247feb0853d93228e65b0a8
17,194
c
C
sys/track.c
SirWumpus/libsnert
087968a94df77bf0685749b678258e7987b889c6
[ "BSD-2-Clause" ]
null
null
null
sys/track.c
SirWumpus/libsnert
087968a94df77bf0685749b678258e7987b889c6
[ "BSD-2-Clause" ]
null
null
null
sys/track.c
SirWumpus/libsnert
087968a94df77bf0685749b678258e7987b889c6
[ "BSD-2-Clause" ]
null
null
null
/* * track.c * * Copyright 2015 by Anthony Howe. All rights reserved. */ #ifndef DUMP_LINE #define DUMP_LINE 16 #endif #ifndef DUMP_SIZE #define DUMP_SIZE (2 * DUMP_LINE) #endif #ifndef DUMP_FILE #define DUMP_FILE "./track_leaks.log" #endif /*********************************************************************** *** No configuration below this point. ***********************************************************************/ #include <com/snert/lib/version.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <com/snert/lib/sys/sysexits.h> #include <com/snert/lib/util/Text.h> #define HERE_FMT "%s:%ld " #define HERE_ARG here, (long)lineno #ifdef TEST # define TRACK_STATS # define LOGMSG(...) (void) fprintf(stderr, __VA_ARGS__) # define LOGTRACE() LOGMSG("%s:%d\n", __func__, __LINE__) # define LOGTRACK(t) LOGMSG("%s: " TRACK_FMT "\r\n",__func__, TRACK_ARG(t)) # define LOGTRACKAT(t,f,l) LOGMSG("%s: at " HERE_FMT TRACK_FMT "\r\n",__func__, f, l, TRACK_ARG(t)) # define LOGMALLOC(p,n,f,l) LOGMSG("%s: ptr=%p size=%zu" HERE_FMT "\r\n", __func__, p, n, f, l) # define LOGFREE(p,f,l) LOGMSG("%s: ptr=%p " HERE_FMT "\r\n", __func__, p, f, l) #else # define LOGMSG(...) # define LOGTRACE() # define LOGTRACK(t) # define LOGTRACKAT(t,f,l) # define LOGMALLOC(p,n,f,l) # define LOGFREE(p,f,l) #endif #if defined(_REENTRANT) # include <com/snert/lib/sys/pthread.h> // Not sure is I should have two compiled versions of libsnert; // normally or pthread ready. //# define T(name) ptrack_ ## name # define LOCK_INITIALISER PTHREAD_MUTEX_INITIALIZER # define LOCK_T pthread_mutex_t # define LOCK_INIT(L) pthread_mutex_init(L, NULL) # define LOCK_FREE(L) pthread_mutex_destroy(L) # define LOCK_LOCK(L) pthread_mutex_lock(L) # define LOCK_TRYLOCK(L) pthread_mutex_trylock(L) # define LOCK_UNLOCK(L) pthread_mutex_unlock(L) # if !defined(HAVE_PTHREAD_YIELD) && !defined(pthread_yield) # define pthread_yield() (0) # endif #else /* No pthread support. */ /* Mimick a mutex (mostly to silence compiler errors). */ # define LOCK_INITIALISER 0 # define LOCK_T int # define LOCK_INIT(L) (*(L) = 1) # define LOCK_FREE(L) (*(L) = 0, 0) # define LOCK_LOCK(L) ((*(L))--, 0) # define LOCK_TRYLOCK(L) ((*(L))--, 0) # define LOCK_UNLOCK(L) ((*(L))++, 0) # define PTHREAD_ONCE_INIT 0 # define pthread_t unsigned # define pthread_self() (0) # define pthread_once_t unsigned # define pthread_once(o, f) (0) /* Mimick per thread data object. thread_key will be the list head. */ # define pthread_key_t track_list * # define pthread_key_create(k, f) (*(k) = NULL) # define pthread_key_delete(k) (0) # define pthread_getspecific(k) (k) # define pthread_setspecific(k, v) (k = (v), 0) # define pthread_create(t,a,f,d) (*(t) = 0, 0) # define pthread_yield() (0) # define pthread_join(t,r) (0) # define pthread_cleanup_push(f, d) # define pthread_cleanup_pop(b) #endif #ifndef T # define T(name) track_ ## name #endif typedef void *Marker; typedef struct track_data { Marker lo_guard; struct track_data *prev; struct track_data *next; size_t size; unsigned long id; const char *here; long lineno; long crc; } track_data; #define TRACK_FMT "ptr=%p id=%lu size=%zu from " HERE_FMT #define TRACK_ARG(p) &(p)[1], (p)->id, (p)->size, (p)->here, (p)->lineno #define TRACK_CRC(p) ((long)((long)(p) ^ (p)->size ^ (p)->lineno ^ (long)(p)->here)) typedef struct track_list { struct track_list *prev; struct track_list *next; struct track_data *head; pthread_t thread; } track_list; static track_list *main_list; static LOCK_T lock; static unsigned long free_count; static unsigned long malloc_count; void (*track_hook__exit)(int); void (*track_hook_free)(void *); void *(*track_hook_malloc)(size_t); static Marker lo_guard; static pthread_t main_thread; static pthread_key_t thread_key; #ifdef SIGNAL_SAFE /* * @note * Signal safe. */ static size_t T(dump_mem)(const unsigned char *mem, size_t count, char *buffer, size_t size) { size_t i, n; if (0 < size) *buffer = '\0'; if (size <= count * 4 + 4) return count * 4 + 4; *buffer++ = '\t'; for (i = 0; i < count; i++) { n = ulong_format(mem[i], 16, -3, 2, 0, 0, buffer, size); buffer +=n; size -= n; } *buffer++ = ' '; for (i = 0; i < count; i++) { *buffer++ = isprint(mem[i]) ? mem[i] : '.'; } *buffer++ = '\r'; *buffer++ = '\n'; *buffer = '\0'; return count * 4 + 4; } /* * @note * Signal safe. */ static size_t T(tostring)(track_data *track, size_t dump_len, char *buffer, size_t size) { int i; size_t n; char *buf; buf = buffer; n = TextCopy(buf, size, " ptr=0x"); buf += n; if (buf-buffer < size) size -= n; else size = 0; n = ulong_format((unsigned long)(track+1), 16, 0, 0, 0, 0, buf, size); buf += n; if (buf-buffer < size) size -= n; else size = 0; n = TextCopy(buf, size, " id="); buf += n; if (buf-buffer < size) size -= n; else size = 0; n = ulong_format(track->id, 10, 0, 0, 0, 0, buf, size); buf += n; if (buf-buffer < size) size -= n; else size = 0; n = TextCopy(buf, size, " size="); buf += n; if (buf-buffer < size) size -= n; else size = 0; n = ulong_format(track->size, 10, 0, 0, 0, 0, buf, size); buf += n; if (buf-buffer < size) size -= n; else size = 0; n = TextCopy(buf, size, " from "); buf += n; if (buf-buffer < size) size -= n; else size = 0; n = TextCopy(buf, size, track->here); buf += n; if (buf-buffer < size) size -= n; else size = 0; if (0 < size) { *buf++ = ':'; size--; } n = ulong_format(track->lineno, 10, 0, 0, 0, 0, buf, size); buf += n; if (buf-buffer < size) size -= n; else size = 0; n = TextCopy(buf, size, "\r\n"); buf += n; if (buf-buffer < size) size -= n; else size = 0; /* Round up to multiple of 16. */ dump_len = ((dump_len + 15) / 16) * 16; for (i = 0; i < dump_len; i += 16) { n = T(dump_mem)((unsigned char *)(track+1)+i, 16, buf, size); buf += n; if (buf-buffer < size) size -= n; else size = 0; } return buf - buffer; } void T(report_all_fd)(int fd) { track_list *list; list = main_list; do { T(report_fd)(fd, list); list = list->next; } while (list != main_list); #ifdef TRACK_STATS if (malloc_count != free_count) (void) fprintf(stderr, "malloc=%lu free=%lu\r\n", malloc_count, free_count); #endif } void sig_dump(int signum) { int fd; if (0 <= (fd = open(DUMP_FILE, O_CREAT|O_WRONLY|O_APPEND, 0))) { T(report_all_fd)(fd); (void) close(fd); } } #else static void T(dump)(FILE *fp, track_data *track, size_t dump_len) { size_t i, j; unsigned char *chunk; if (track->size < dump_len) dump_len = track->size; dump_len = ((dump_len + (DUMP_LINE-1)) / DUMP_LINE) * DUMP_LINE; chunk = (unsigned char *)(track+1); (void) fprintf(fp, " " TRACK_FMT "\r\n", TRACK_ARG(track)); for (i = 0; i < dump_len; i += DUMP_LINE) { (void) fputc('\t', fp); for (j = 0; j < DUMP_LINE; j++) (void) fprintf(fp, "%-3.2X", chunk[i+j]); (void) fputc(' ', fp); for (j = 0; j < DUMP_LINE; j++) (void) fputc(isprint(chunk[j]) ? chunk[i+j] : '.', fp); (void) fputs("\r\n", fp); } (void) fflush(fp); } #endif /* * Dump the list of leaked memory at thread exit. */ static void T(report)(track_list *list) { size_t size; unsigned count; track_data *track; if (list == NULL) return; if (main_thread == list->thread) (void) fprintf(stderr, "main:\r\n"); else (void) fprintf(stderr, "thread 0x%lx:\r\n", (unsigned long) list->thread); size = 0; for (count = 0, track = list->head; track != NULL; track = track-> next, count++) { /* The thread data cleanup will be called before * the thread releases its pthread_t data, which * can result in a spurious leak being reported. */ #ifdef SIGNAL_SAFE char buffer[512]; (void) T(tostring)(track, DUMP_SIZE, buffer, sizeof (buffer)); fputs(buffer, stderr); #else (void) T(dump)(stderr, track, DUMP_SIZE); #endif (void) fputs("\r\n", stderr); size += track->size; } if (0 < count) (void) fprintf(stderr, " leaked blocks=%u size=%zu\r\n", count, size); } void T(report_all_unsafe)(void) { track_list *list; list = main_list; do { T(report)(list); list = list->next; } while (list != main_list); #ifdef TRACK_STATS if (malloc_count != free_count) (void) fprintf(stderr, "malloc=%lu free=%lu\r\n", malloc_count, free_count); #endif } void T(report_all)(void) { (void) LOCK_LOCK(&lock); T(report_all_unsafe)(); (void) LOCK_UNLOCK(&lock); } void T(clean_key)(void *data) { track_list *list; LOGTRACE(); if (data != NULL) { list = data; (void) LOCK_LOCK(&lock); list->prev->next = list->next; list->next->prev = list->prev; (void) LOCK_UNLOCK(&lock); T(report)(list); (free)(list); (void) pthread_setspecific(thread_key, NULL); } } static void T(init_common)(void) { (void) LOCK_INIT(&lock); (void) LOCK_LOCK(&lock); (void) LOCK_UNLOCK(&lock); (void) pthread_key_create(&thread_key, T(clean_key)); (void) pthread_setspecific(thread_key, NULL); main_thread = pthread_self(); (void) memset(&lo_guard, '[', sizeof (lo_guard)); } #if defined(__WIN32__) # error "Windows support not implemented." #elif defined(HAVE_DLFCN_H) && defined(LIBC_PATH) # include <dlfcn.h> static void T(init)(void) { void *libc; const char *err; void (*libc__exit)(int); void (*libc_free)(void *); void *(*libc_malloc)(size_t); LOGTRACE(); libc = dlopen(LIBC_PATH, RTLD_NOW); if ((err = dlerror()) != NULL) { (void) fprintf(stderr, "libc.so load error: %s\r\n", err); exit(EX_OSERR); } libc_malloc = (void *(*)(size_t)) dlsym(libc, "malloc"); if ((err = dlerror()) != NULL) { (void) fprintf(stderr, "libc malloc() not found: %s\r\n", err); exit(EX_OSERR); } libc_free = (void (*)(void *)) dlsym(libc, "free"); if ((err = dlerror()) != NULL) { (void) fprintf(stderr, "libc free() not found: %s\r\n", err); exit(EX_OSERR); } libc__exit = dlsym(libc, "_exit"); if ((err = dlerror()) != NULL) { (void) fprintf(stderr, "libc _exit() not found: %s\r\n", err); exit(EX_OSERR); } (void) dlclose(libc); T(init_common)(); /* We've completed initialisation. */ track_hook__exit = libc__exit; track_hook_malloc = libc_malloc; track_hook_free = libc_free; } #endif #ifdef TRACK /* Only hook _exit() when we build with -DTRACK (see --enable-track). */ void (_exit)(int ex_code) { track_list *list; LOGTRACE(); if (track_hook__exit == NULL) T(init)(); /* We need to hook _exit() so that we can report leaks after * all the atexit() functions, which might release dynamic * memory. We cannot simply use atexit() for reporting since * there is no way to garantee we are executed last. * * NOTE sys/track.c and sys/malloc.c both hook _exit(), so * cannot be used together (yet). */ list = (track_list *)pthread_getspecific(thread_key); T(report)(list); (void) pthread_key_delete(thread_key); (void) LOCK_FREE(&lock); (*track_hook__exit)(ex_code); } #endif /* TRACK */ void T(free)(void *chunk, const char *here, long lineno) { track_list *list; track_data *track; if (chunk == NULL) { LOGFREE(chunk, here, lineno); return; } track = &((track_data *) chunk)[-1]; LOGTRACKAT(track, here, lineno); /* Check the pointer and core data are valid. */ if (track->crc != TRACK_CRC(track)) { /* The rest of the data is suspect. */ (void) fprintf(stderr, HERE_FMT "buffer under run or bad pointer!\n", HERE_ARG); abort(); } /* Did something run into us from below? */ if (track->lo_guard != lo_guard) { (void) fprintf( stderr, HERE_FMT "buffer guard corrupted! size=%zu %s:%ld\n", HERE_ARG, track->size, track->here, track->lineno ); abort(); } /* Maintain list of allocated memory per thread, including main() */ list = pthread_getspecific(thread_key); if (track->prev == NULL) list->head = track->next; else track->prev->next = track->next; if (track->next != NULL) track->next->prev = track->prev; (void) pthread_setspecific(thread_key, list); (free)(track); (void) LOCK_LOCK(&lock); free_count++; (void) LOCK_UNLOCK(&lock); } void * T(malloc)(size_t size, const char *here, long lineno) { track_list *list; track_data *track; if (track_hook__exit == NULL) T(init)(); if ((track = (malloc)(sizeof (*track) + size + (size == 0))) == NULL) { LOGMALLOC(NULL, size, here, lineno); return NULL; } (void) LOCK_LOCK(&lock); malloc_count++; track->id = malloc_count; (void) LOCK_UNLOCK(&lock); track->size = size; track->here = here; track->lineno = lineno; track->lo_guard = lo_guard; track->crc = TRACK_CRC(track); /* Maintain list of allocated memory per thread, including main() */ list = (track_list *)pthread_getspecific(thread_key); if (list == NULL) { if ((list = (malloc)(sizeof (*list))) == NULL) { (free)(track); return NULL; } list->thread = pthread_self(); list->head = NULL; /* Each thread maintains an allocation list and each * allocation list is a member of a circular double * link list of lists. This allows us to dump all * the current allocations for all threads any time. */ (void) LOCK_LOCK(&lock); if (main_list == NULL) { list->prev = list; list->next = list; main_list = list; } else { list->prev = main_list->prev; list->next = main_list; main_list->prev->next = list; main_list->prev = list; } (void) LOCK_UNLOCK(&lock); } /* Push allocation to head of list. */ track->prev = NULL; track->next = list->head; if (list->head != NULL) list->head->prev = track; list->head = track; (void) pthread_setspecific(thread_key, list); LOGTRACKAT(track, here, lineno); return &track[1]; } void * T(calloc)(size_t m, size_t n, const char *here, long lineno) { void *chunk; size_t size; size = m * n; if ((chunk = T(malloc)(size, here, lineno)) != NULL) (void) memset(chunk, 0, size); return chunk; } void * T(realloc)(void *orig, size_t size, const char *here, long lineno) { void *chunk; track_data *track; if ((chunk = T(malloc)(size, here, lineno)) != NULL && orig != NULL) { track = &((track_data *) chunk)[-1]; (void) memcpy(chunk, orig, track->size < size ? track->size : size); T(free)(orig, here, lineno); } return chunk; } #define is_power_two(x) (((x) != 0) && !((x) & ((x) - 1))) void * T(aligned_alloc)(size_t alignment, size_t size, const char *here, long lineno) { if (is_power_two(alignment) && sizeof (void *) <= alignment && (size / alignment) * alignment == size) return T(malloc)(size, here, lineno); return NULL; } char * T(strdup)(const char *orig, const char *here, long lineno) { char *copy; size_t size; size = strlen(orig) + 1; if ((copy = T(malloc)(size, here, lineno)) != NULL) (void) memcpy(copy, orig, size); return copy; } #ifdef TRACK /* * Use our version of strdup() so we ensure that we use matching * malloc/free family of functions. Otherwise you get can get * false positives about buffer under runs. */ char * (strdup)(const char *orig) { return T(strdup)(orig, __func__, __LINE__); } #endif /*********************************************************************** *** Test Suite ***********************************************************************/ #ifdef TEST #include <errno.h> struct main_args { int argc; char **argv; }; void * test_thread(void *data) { int argi; char **base; struct main_args *arg = data; if ((base = calloc(arg->argc+1, sizeof (*base))) == NULL) { (void) fprintf(stderr, "%s:%d memory\n", __FILE__, __LINE__); return (void *) EXIT_FAILURE; } /* Force a leak. */ (void) fprintf(stderr, "create test leak 1\n"); (void) TextCopy(malloc(101), 101, "leak 1 abcdefghijklmnopqrstuvwxyz"); for (argi = 0; argi < arg->argc; argi++) { base[argi] = strdup(arg->argv[argi]); // (void) pthread_yield(); if (base[argi] == NULL) { (void) fprintf(stderr, "%s:%d memory\n", __FILE__, __LINE__); return (void *) EXIT_FAILURE; } } base[argi] = NULL; for (argi = 0; argi < arg->argc; argi++) { (void) printf("%d: %s\n", argi, base[argi]); free(base[argi]); // (void) pthread_yield(); } free(base); /* Force a leak. */ (void) fprintf(stderr, "create test leak 2\n"); (void) TextCopy(malloc(102), 102, "leak 2 abcdefghijklmnopqrstuvwxyz"); return NULL; } int main(int argc, char **argv) { int err_no; void *test_ret; pthread_t testy; struct main_args arg; if (argc <= 1) { (void) fprintf(stderr, "usage: %s [string ...]\n", argv[0]); return EXIT_FAILURE; } arg.argc = argc; arg.argv = argv; if (pthread_create(&testy, NULL, test_thread, &arg)) { (void) fprintf(stderr, "%s:%d %s (%d)\r\n", __FILE__, __LINE__, strerror(errno), errno); return EXIT_FAILURE; } (void) test_thread(&arg); test_ret = NULL; if ((err_no = pthread_join(testy, &test_ret))) { (void) fprintf(stderr, "%s:%d %s (%d)\r\n", __FILE__, __LINE__, strerror(err_no), err_no); return EXIT_FAILURE; } if ((long) test_ret) { (void) fprintf(stderr, "%s:%d test_thread() failed\r\n", __FILE__, __LINE__); return EXIT_FAILURE; } return EXIT_SUCCESS; } #endif /* TEST */
23.203779
103
0.625974
[ "object" ]
0339c7923eecdb149f123f5bb10043815ec06f75
2,538
h
C
include/libhaloc/publisher.h
markvilar/libhaloc
0e80b6da28d714cf916c26bfce42317aad00b680
[ "BSD-4-Clause" ]
40
2015-05-29T16:43:32.000Z
2022-03-04T01:47:49.000Z
include/libhaloc/publisher.h
markvilar/libhaloc
0e80b6da28d714cf916c26bfce42317aad00b680
[ "BSD-4-Clause" ]
2
2017-08-21T18:32:03.000Z
2021-03-23T11:59:28.000Z
include/libhaloc/publisher.h
markvilar/libhaloc
0e80b6da28d714cf916c26bfce42317aad00b680
[ "BSD-4-Clause" ]
25
2015-03-09T19:49:26.000Z
2022-03-04T01:47:51.000Z
// Copyright (c) 2017 Universitat de les Illes Balears // This file is part of LIBHALOC. // // LIBHALOC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // LIBHALOC 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 LIBHALOC. If not, see <http://www.gnu.org/licenses/>. #ifndef LIBHALOC_INCLUDE_LIBHALOC_PUBLISHER_H_ #define LIBHALOC_INCLUDE_LIBHALOC_PUBLISHER_H_ #include <ros/ros.h> #include <sensor_msgs/Image.h> #include <cv_bridge/cv_bridge.h> #include <std_msgs/String.h> #include <vector> #include "libhaloc/state.h" #include <opencv2/core/core.hpp> #include <opencv2/features2d/features2d.hpp> namespace haloc { class Publisher { public: /** * @brief Empty class constructor. */ Publisher(); /** * @brief Publishes the bucketed image. * * @param[in] state The state obtained after a hash computation. * @param[in] img The original image. * @param[in] bucket_rows The bucket rows * @param[in] bucket_cols The bucket cols */ void PublishBucketedImage(const State& state, const cv::Mat& img, const int& bucket_rows, const int& bucket_cols); /** * @brief Publishes the bucketed info * * @param[in] state The state obtained after a hash computation. * @param[in] max_feat The maximum number of features per bucket */ void PublishBucketedInfo(const State& state, const int& max_feat); protected: /** * @brief Returns a debug image with the bucketed keypoints. * * @param[in] state The state obtained after a hash computation. * @param[in] img The original image. * @param[in] bucket_rows The bucket rows * @param[in] bucket_cols The bucket cols * * @return The bucketed image. */ cv::Mat BuildBucketedImage(const State& state, const cv::Mat& img, const int& bucket_rows, const int& bucket_cols); private: // The ROS publishers ros::Publisher pub_bucketed_img_; ros::Publisher pub_bucketed_info_; }; } // namespace haloc #endif // LIBHALOC_INCLUDE_LIBHALOC_PUBLISHER_H_
29.858824
74
0.695035
[ "vector" ]
033d66773e570b08ae03a4cff13a81b3ab5cd7cd
3,034
h
C
src/meshes/simple_rectangular_tri_mesh.template.h
pkeuchel/oomph-lib
37c1c61425d6b9ea1c2ddceef63a68a228af6fa4
[ "RSA-MD" ]
4
2020-11-16T12:25:09.000Z
2021-06-29T08:53:25.000Z
src/meshes/simple_rectangular_tri_mesh.template.h
pkeuchel/oomph-lib
37c1c61425d6b9ea1c2ddceef63a68a228af6fa4
[ "RSA-MD" ]
2
2020-05-05T22:41:37.000Z
2020-05-10T14:14:17.000Z
src/meshes/simple_rectangular_tri_mesh.template.h
pkeuchel/oomph-lib
37c1c61425d6b9ea1c2ddceef63a68a228af6fa4
[ "RSA-MD" ]
3
2021-01-31T14:09:20.000Z
2021-06-07T07:20:51.000Z
// LIC// ==================================================================== // LIC// This file forms part of oomph-lib, the object-oriented, // LIC// multi-physics finite-element library, available // LIC// at http://www.oomph-lib.org. // LIC// // LIC// Copyright (C) 2006-2021 Matthias Heil and Andrew Hazel // LIC// // LIC// This library is free software; you can redistribute it and/or // LIC// modify it under the terms of the GNU Lesser General Public // LIC// License as published by the Free Software Foundation; either // LIC// version 2.1 of the License, or (at your option) any later version. // LIC// // LIC// This library is distributed in the hope that it will be useful, // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // LIC// Lesser General Public License for more details. // LIC// // LIC// You should have received a copy of the GNU Lesser General Public // LIC// License along with this library; if not, write to the Free Software // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA // LIC// 02110-1301 USA. // LIC// // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk. // LIC// // LIC//==================================================================== // Header file for simple 2D triangle mesh class // Include guards to prevent multiple inclusion of the header #ifndef OOMPH_SIMPLE_RECTANGULAR_TRIMESH_HEADER #define OOMPH_SIMPLE_RECTANGULAR_TRIMESH_HEADER // Config header generated by autoconfig #ifdef HAVE_CONFIG_H #include <oomph-lib-config.h> #endif // Oomph-lib includes #include "../generic/mesh.h" #include "../generic/triangle_mesh.h" namespace oomph { //=================================================================== /// Simple 2D triangular mesh for TElements //=================================================================== template<class ELEMENT> class SimpleRectangularTriMesh : public virtual TriangleMeshBase { public: /// Constructor /// n_x : number of elements in the x direction; /// n_y : number of elements in the y direction; /// l_x : length in the x direction /// l_y : length in the y direction /// Ordering of elements: 'lower left' to 'lower right' then 'upwards' SimpleRectangularTriMesh( const unsigned& n_x, const unsigned& n_y, const double& l_x, const double& l_y, TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper); /// Access function for number of elements in x directions const unsigned& nx() const { return Nx; } /// Access function for number of elements in y directions const unsigned& ny() const { return Ny; } private: /// Number of elements in x direction unsigned Nx; /// Number of elements in y directions unsigned Ny; /// Length of mesh in x-direction double Lx; /// Length of mesh in y-direction double Ly; }; } // namespace oomph #endif
32.623656
77
0.628873
[ "mesh", "object" ]
033f334a6af4d469c4df3d84bed200eaeda95620
23,107
h
C
tensorflow/lite/kernels/internal/optimized/integer_ops/fully_connected.h
indiewebconsulting/mind-tensorflow
15ac248a9b883033b723d6fd6eb4335102c5780e
[ "Apache-2.0" ]
1
2020-09-01T03:03:43.000Z
2020-09-01T03:03:43.000Z
tensorflow/lite/kernels/internal/optimized/integer_ops/fully_connected.h
indiewebconsulting/mind-tensorflow
15ac248a9b883033b723d6fd6eb4335102c5780e
[ "Apache-2.0" ]
null
null
null
tensorflow/lite/kernels/internal/optimized/integer_ops/fully_connected.h
indiewebconsulting/mind-tensorflow
15ac248a9b883033b723d6fd6eb4335102c5780e
[ "Apache-2.0" ]
2
2020-03-25T12:52:20.000Z
2020-08-11T09:31:43.000Z
/* Copyright 2019 The TensorFlow Authors. 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 TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_INTEGER_OPS_FULLY_CONNECTED_H_ #define TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_INTEGER_OPS_FULLY_CONNECTED_H_ #include "public/gemmlowp.h" #include "tensorflow/lite/kernels/cpu_backend_context.h" #include "tensorflow/lite/kernels/internal/common.h" #include "tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h" namespace tflite { namespace optimized_integer_ops { inline void optimized_ops_preload_l1_stream(const int8_t* ptr) { #ifdef GEMMLOWP_ARM_64 asm volatile("prfm pldl1strm, [%[ptr]]\n" ::[ptr] "r"(ptr) :); #else gemmlowp::Prefetch(ptr); #endif } inline void optimized_ops_preload_l1_keep(const int8_t* ptr) { #ifdef GEMMLOWP_ARM_64 asm volatile("prfm pldl1keep, [%[ptr]]\n" ::[ptr] "r"(ptr) :); #else gemmlowp::Prefetch(ptr); #endif } #ifdef USE_NEON inline void FullyConnectedAsGEMVWorkerImpl( const RuntimeShape& input_shape, const int8_t* input_data, int32 input_offset, const RuntimeShape& filter_shape, const int8_t* filter_data, int32 filter_offset, const RuntimeShape& bias_shape, const int32* bias_data, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, const RuntimeShape& output_shape, int8_t* output_data, int row_start, int row_end) { gemmlowp::ScopedProfilingLabel label("FullyConnectedAsGEMVInt8/8bit"); TFLITE_DCHECK_GE(input_shape.DimensionsCount(), 1); TFLITE_DCHECK_GE(filter_shape.DimensionsCount(), 2); TFLITE_DCHECK_GE(output_shape.DimensionsCount(), 1); const int output_dim_count = output_shape.DimensionsCount(); TFLITE_DCHECK_EQ(FlatSizeSkipDim(output_shape, output_dim_count - 1), 1); const int input_size = FlatSizeSkipDim(input_shape, 0); static constexpr int kPeel = 4; const bool shift_left = (output_shift > 0); for (int k = 0; k < input_size; k += 64) { optimized_ops_preload_l1_stream(input_data + k); } for (int k = 0; k < kPeel * input_size; k += 64) { optimized_ops_preload_l1_stream(filter_data + k); } TFLITE_DCHECK_GE(row_end - row_start, kPeel); for (int out = row_start; out < row_end; out += kPeel) { out = std::min(out, row_end - kPeel); int32x4_t acc0 = vdupq_n_s32(0); int32x4_t acc1 = acc0; int32x4_t acc2 = acc0; int32x4_t acc3 = acc0; const int16x8_t input_offset_vec = vdupq_n_s16(input_offset); const int16x8_t filter_offset_vec = vdupq_n_s16(filter_offset); int in = 0; for (; in <= input_size - 16; in += 16) { const int8x16_t input_val_s8 = vld1q_s8(input_data + in); const int8_t* filter_ptr = filter_data + in + out * input_size; int8x16_t filter_val_s8_0 = vld1q_s8(filter_ptr); optimized_ops_preload_l1_stream(filter_ptr + 64); filter_ptr += input_size; int8x16_t filter_val_s8_1 = vld1q_s8(filter_ptr); optimized_ops_preload_l1_stream(filter_ptr + 64); filter_ptr += input_size; int8x16_t filter_val_s8_2 = vld1q_s8(filter_ptr); optimized_ops_preload_l1_stream(filter_ptr + 64); filter_ptr += input_size; int8x16_t filter_val_s8_3 = vld1q_s8(filter_ptr); optimized_ops_preload_l1_stream(filter_ptr + 64); int16x8_t input_val_0, input_val_1; int8x8_t low = vget_low_s8(input_val_s8); int8x8_t high = vget_high_s8(input_val_s8); input_val_0 = vmovl_s8(low); input_val_1 = vmovl_s8(high); input_val_0 = vaddq_s16(input_val_0, input_offset_vec); input_val_1 = vaddq_s16(input_val_1, input_offset_vec); low = vget_low_s8(filter_val_s8_0); high = vget_high_s8(filter_val_s8_0); int16x8_t filter_val_0_0 = vmovl_s8(low); int16x8_t filter_val_0_1 = vmovl_s8(high); filter_val_0_0 = vaddq_s16(filter_val_0_0, filter_offset_vec); filter_val_0_1 = vaddq_s16(filter_val_0_1, filter_offset_vec); low = vget_low_s8(filter_val_s8_1); high = vget_high_s8(filter_val_s8_1); int16x8_t filter_val_1_0 = vmovl_s8(low); int16x8_t filter_val_1_1 = vmovl_s8(high); filter_val_1_0 = vaddq_s16(filter_val_1_0, filter_offset_vec); filter_val_1_1 = vaddq_s16(filter_val_1_1, filter_offset_vec); low = vget_low_s8(filter_val_s8_2); high = vget_high_s8(filter_val_s8_2); int16x8_t filter_val_2_0 = vmovl_s8(low); int16x8_t filter_val_2_1 = vmovl_s8(high); filter_val_2_0 = vaddq_s16(filter_val_2_0, filter_offset_vec); filter_val_2_1 = vaddq_s16(filter_val_2_1, filter_offset_vec); low = vget_low_s8(filter_val_s8_3); high = vget_high_s8(filter_val_s8_3); int16x8_t filter_val_3_0 = vmovl_s8(low); int16x8_t filter_val_3_1 = vmovl_s8(high); filter_val_3_0 = vaddq_s16(filter_val_3_0, filter_offset_vec); filter_val_3_1 = vaddq_s16(filter_val_3_1, filter_offset_vec); acc0 = vmlal_s16(acc0, vget_low_s16(filter_val_0_0), vget_low_s16(input_val_0)); acc1 = vmlal_s16(acc1, vget_low_s16(filter_val_1_0), vget_low_s16(input_val_0)); acc2 = vmlal_s16(acc2, vget_low_s16(filter_val_2_0), vget_low_s16(input_val_0)); acc3 = vmlal_s16(acc3, vget_low_s16(filter_val_3_0), vget_low_s16(input_val_0)); acc0 = vmlal_s16(acc0, vget_low_s16(filter_val_0_1), vget_low_s16(input_val_1)); acc1 = vmlal_s16(acc1, vget_low_s16(filter_val_1_1), vget_low_s16(input_val_1)); acc2 = vmlal_s16(acc2, vget_low_s16(filter_val_2_1), vget_low_s16(input_val_1)); acc3 = vmlal_s16(acc3, vget_low_s16(filter_val_3_1), vget_low_s16(input_val_1)); acc0 = vmlal_s16(acc0, vget_high_s16(filter_val_0_0), vget_high_s16(input_val_0)); acc1 = vmlal_s16(acc1, vget_high_s16(filter_val_1_0), vget_high_s16(input_val_0)); acc2 = vmlal_s16(acc2, vget_high_s16(filter_val_2_0), vget_high_s16(input_val_0)); acc3 = vmlal_s16(acc3, vget_high_s16(filter_val_3_0), vget_high_s16(input_val_0)); acc0 = vmlal_s16(acc0, vget_high_s16(filter_val_0_1), vget_high_s16(input_val_1)); acc1 = vmlal_s16(acc1, vget_high_s16(filter_val_1_1), vget_high_s16(input_val_1)); acc2 = vmlal_s16(acc2, vget_high_s16(filter_val_2_1), vget_high_s16(input_val_1)); acc3 = vmlal_s16(acc3, vget_high_s16(filter_val_3_1), vget_high_s16(input_val_1)); } for (; in <= input_size - 8; in += 8) { const int8x8_t input_val_s8 = vld1_s8(input_data + in); const int8_t* filter_ptr = filter_data + in + out * input_size; int8x8_t filter_val_s8_0 = vld1_s8(filter_ptr); filter_ptr += input_size; int8x8_t filter_val_s8_1 = vld1_s8(filter_ptr); filter_ptr += input_size; int8x8_t filter_val_s8_2 = vld1_s8(filter_ptr); filter_ptr += input_size; int8x8_t filter_val_s8_3 = vld1_s8(filter_ptr); int16x8_t input_val = vmovl_s8(input_val_s8); input_val = vaddq_s16(input_val, input_offset_vec); int16x8_t filter_val_0 = vmovl_s8(filter_val_s8_0); filter_val_0 = vaddq_s16(filter_val_0, filter_offset_vec); int16x8_t filter_val_1 = vmovl_s8(filter_val_s8_1); filter_val_1 = vaddq_s16(filter_val_1, filter_offset_vec); int16x8_t filter_val_2 = vmovl_s8(filter_val_s8_2); filter_val_2 = vaddq_s16(filter_val_2, filter_offset_vec); int16x8_t filter_val_3 = vmovl_s8(filter_val_s8_3); filter_val_3 = vaddq_s16(filter_val_3, filter_offset_vec); acc0 = vmlal_s16(acc0, vget_low_s16(filter_val_0), vget_low_s16(input_val)); acc1 = vmlal_s16(acc1, vget_low_s16(filter_val_1), vget_low_s16(input_val)); acc2 = vmlal_s16(acc2, vget_low_s16(filter_val_2), vget_low_s16(input_val)); acc3 = vmlal_s16(acc3, vget_low_s16(filter_val_3), vget_low_s16(input_val)); acc0 = vmlal_s16(acc0, vget_high_s16(filter_val_0), vget_high_s16(input_val)); acc1 = vmlal_s16(acc1, vget_high_s16(filter_val_1), vget_high_s16(input_val)); acc2 = vmlal_s16(acc2, vget_high_s16(filter_val_2), vget_high_s16(input_val)); acc3 = vmlal_s16(acc3, vget_high_s16(filter_val_3), vget_high_s16(input_val)); } if (in < input_size) { int32 buf[16]; vst1q_s32(buf + 0, acc0); vst1q_s32(buf + 4, acc1); vst1q_s32(buf + 8, acc2); vst1q_s32(buf + 12, acc3); for (; in < input_size; in++) { int lane = (in + 8 - input_size) % 4; const int32 input_val = input_data[in] + input_offset; for (int k = 0; k < kPeel; k++) { int32 filter_val = filter_data[in + (out + k) * input_size] + filter_offset; buf[lane + 4 * k] += filter_val * input_val; } } acc0 = vld1q_s32(buf + 0); acc1 = vld1q_s32(buf + 4); acc2 = vld1q_s32(buf + 8); acc3 = vld1q_s32(buf + 12); } // Horizontally reduce accumulators int32x2_t pairwise_reduced_acc_0 = vpadd_s32(vget_low_s32(acc0), vget_high_s32(acc0)); int32x2_t pairwise_reduced_acc_1 = vpadd_s32(vget_low_s32(acc1), vget_high_s32(acc1)); int32x2_t pairwise_reduced_acc_2 = vpadd_s32(vget_low_s32(acc2), vget_high_s32(acc2)); int32x2_t pairwise_reduced_acc_3 = vpadd_s32(vget_low_s32(acc3), vget_high_s32(acc3)); const int32x2_t reduced_lo = vpadd_s32(pairwise_reduced_acc_0, pairwise_reduced_acc_1); const int32x2_t reduced_hi = vpadd_s32(pairwise_reduced_acc_2, pairwise_reduced_acc_3); int32x4_t reduced = vcombine_s32(reduced_lo, reduced_hi); // Add bias values. int32x4_t bias_vec = vld1q_s32(bias_data + out); reduced = vaddq_s32(reduced, bias_vec); if (shift_left) { const int32 multiplier_power_of_two = 1 << output_shift; reduced = vmulq_n_s32(reduced, multiplier_power_of_two); reduced = vqrdmulhq_n_s32(reduced, output_multiplier); } else { // Multiply by the fixed-point multiplier. reduced = vqrdmulhq_n_s32(reduced, output_multiplier); // Rounding-shift-right. using gemmlowp::RoundingDivideByPOT; reduced = RoundingDivideByPOT(reduced, -output_shift); } // Add the output offset. const int32x4_t output_offset_vec = vdupq_n_s32(output_offset); reduced = vaddq_s32(reduced, output_offset_vec); // Narrow values down to 16 bit signed. const int16x4_t res16 = vqmovn_s32(reduced); // Narrow values down to 8 bit signed, saturating. int8x8_t res8 = vqmovn_s16(vcombine_s16(res16, res16)); // Apply the clamping from the activation function res8 = vmax_s8(res8, vdup_n_s8(output_activation_min)); res8 = vmin_s8(res8, vdup_n_s8(output_activation_max)); // Store results to destination. vst1_lane_s8(output_data + out + 0, res8, 0); vst1_lane_s8(output_data + out + 1, res8, 1); vst1_lane_s8(output_data + out + 2, res8, 2); vst1_lane_s8(output_data + out + 3, res8, 3); } } struct FullyConnectedAsGEMVWorkerTask : public gemmlowp::Task { FullyConnectedAsGEMVWorkerTask( const RuntimeShape& input_shape, const int8_t* input_data, int32 input_offset, const RuntimeShape& filter_shape, const int8_t* filter_data, int32 filter_offset, const RuntimeShape& bias_shape, const int32* bias_data, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, const RuntimeShape& output_shape, int8_t* output_data, int row_start, int row_end) : input_shape_(input_shape), input_data_(input_data), input_offset_(input_offset), filter_shape_(filter_shape), filter_data_(filter_data), filter_offset_(filter_offset), bias_shape_(bias_shape), bias_data_(bias_data), output_offset_(output_offset), output_multiplier_(output_multiplier), output_shift_(output_shift), output_activation_min_(output_activation_min), output_activation_max_(output_activation_max), output_shape_(output_shape), output_data_(output_data), row_start_(row_start), row_end_(row_end) {} void Run() override { FullyConnectedAsGEMVWorkerImpl( input_shape_, input_data_, input_offset_, filter_shape_, filter_data_, filter_offset_, bias_shape_, bias_data_, output_offset_, output_multiplier_, output_shift_, output_activation_min_, output_activation_max_, output_shape_, output_data_, row_start_, row_end_); } const RuntimeShape& input_shape_; const int8_t* input_data_; int32 input_offset_; const RuntimeShape& filter_shape_; const int8_t* filter_data_; int32 filter_offset_; const RuntimeShape& bias_shape_; const int32* bias_data_; int32 output_offset_; int32 output_multiplier_; int output_shift_; int32 output_activation_min_; int32 output_activation_max_; const RuntimeShape& output_shape_; int8_t* output_data_; int row_start_; int row_end_; }; inline void FullyConnectedAsGEMV( const RuntimeShape& input_shape, const int8_t* input_data, int32 input_offset, const RuntimeShape& filter_shape, const int8_t* filter_data, int32 filter_offset, const RuntimeShape& bias_shape, const int32* bias_data, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, const RuntimeShape& output_shape, int8_t* output_data, gemmlowp::GemmContext* gemmlowp_context) { const int output_dim_count = output_shape.DimensionsCount(); const int batches = FlatSizeSkipDim(output_shape, output_dim_count - 1); const int output_rows = output_shape.Dims(output_dim_count - 1); const int input_size = FlatSizeSkipDim(input_shape, 0); static constexpr int kKernelRows = 4; const int thread_count = gemmlowp::HowManyThreads<kKernelRows>( gemmlowp_context->max_num_threads(), output_rows, batches, input_size); if (thread_count == 1) { // Single-thread case: do the computation on the current thread, don't // use a threadpool FullyConnectedAsGEMVWorkerImpl( input_shape, input_data, input_offset, filter_shape, filter_data, filter_offset, bias_shape, bias_data, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_shape, output_data, 0, output_rows); return; } // Multi-threaded case: use the gemmlowp context's threadpool. TFLITE_DCHECK_GT(thread_count, 1); std::vector<gemmlowp::Task*> tasks(thread_count); const int kRowsPerWorker = gemmlowp::RoundUp<kKernelRows>( gemmlowp::CeilQuotient(output_rows, thread_count)); int row_start = 0; for (int i = 0; i < thread_count; ++i) { int row_end = std::min(output_rows, row_start + kRowsPerWorker); tasks[i] = new FullyConnectedAsGEMVWorkerTask( input_shape, input_data, input_offset, filter_shape, filter_data, filter_offset, bias_shape, bias_data, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_shape, output_data, row_start, row_end); row_start = row_end; } TFLITE_DCHECK_EQ(row_start, output_rows); gemmlowp_context->workers_pool()->Execute(tasks); } #endif // USE_NEON struct GemmlowpOutputPipeline { typedef gemmlowp::VectorMap<const int32, gemmlowp::VectorShape::Col> ColVectorMap; typedef std::tuple<gemmlowp::OutputStageBiasAddition<ColVectorMap>, gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToInt8> Pipeline; static Pipeline MakeExp(const int32* bias_data, int output_rows, int32 output_offset, int32 output_multiplier, int output_left_shift, int32 output_activation_min, int32 output_activation_max) { ColVectorMap bias_vector(bias_data, output_rows); gemmlowp::OutputStageBiasAddition<ColVectorMap> bias_addition_stage; bias_addition_stage.bias_vector = bias_vector; gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent quantize_down_stage; quantize_down_stage.result_offset_after_shift = output_offset; quantize_down_stage.result_fixedpoint_multiplier = output_multiplier; quantize_down_stage.result_exponent = output_left_shift; gemmlowp::OutputStageClamp clamp_stage; clamp_stage.min = output_activation_min; clamp_stage.max = output_activation_max; gemmlowp::OutputStageSaturatingCastToInt8 saturating_cast_stage; return std::make_tuple(bias_addition_stage, quantize_down_stage, clamp_stage, saturating_cast_stage); } }; struct GemmlowpOutputPipelineInt8 { typedef gemmlowp::VectorMap<const int32, gemmlowp::VectorShape::Col> ColVectorMap; typedef std::tuple<gemmlowp::OutputStageBiasAddition<ColVectorMap>, gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToInt8> Pipeline; static Pipeline MakeExp(const int32* bias_data, int output_rows, int32 output_offset, int32 output_multiplier, int output_left_shift, int32 output_activation_min, int32 output_activation_max) { ColVectorMap bias_vector(bias_data, output_rows); gemmlowp::OutputStageBiasAddition<ColVectorMap> bias_addition_stage; bias_addition_stage.bias_vector = bias_vector; gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent quantize_down_stage; quantize_down_stage.result_offset_after_shift = output_offset; quantize_down_stage.result_fixedpoint_multiplier = output_multiplier; quantize_down_stage.result_exponent = output_left_shift; gemmlowp::OutputStageClamp clamp_stage; clamp_stage.min = output_activation_min; clamp_stage.max = output_activation_max; gemmlowp::OutputStageSaturatingCastToInt8 saturating_cast_stage; return std::make_tuple(bias_addition_stage, quantize_down_stage, clamp_stage, saturating_cast_stage); } }; inline void FullyConnected( const FullyConnectedParams& params, const RuntimeShape& input_shape, const int8* input_data, const RuntimeShape& filter_shape, const int8* filter_data, const RuntimeShape& bias_shape, const int32* bias_data, const RuntimeShape& output_shape, int8* output_data, CpuBackendContext* cpu_backend_context) { gemmlowp::ScopedProfilingLabel label("FullyConnectedInt8/8bit"); gemmlowp::GemmContext* gemmlowp_context = cpu_backend_context->gemmlowp_context(); #ifdef USE_NEON const int32 input_offset = params.input_offset; const int32 filter_offset = params.weights_offset; const int32 output_offset = params.output_offset; const int32 output_multiplier = params.output_multiplier; const int output_shift = params.output_shift; const int32 output_activation_min = params.quantized_activation_min; const int32 output_activation_max = params.quantized_activation_max; TFLITE_DCHECK_GE(filter_shape.DimensionsCount(), 2); TFLITE_DCHECK_GE(output_shape.DimensionsCount(), 1); // TODO(benoitjacob): This really should be: // const int batches = ArraySize(output_dims, 1); // but the current --variable_batch hack consists in overwriting the 3rd // dimension with the runtime batch size, as we don't keep track for each // array of which dimension is the batch dimension in it. const int output_dim_count = output_shape.DimensionsCount(); const int filter_dim_count = filter_shape.DimensionsCount(); const int batches = FlatSizeSkipDim(output_shape, output_dim_count - 1); if (batches == 1) { const int output_size = MatchingDim(filter_shape, filter_dim_count - 2, output_shape, output_dim_count - 1); if (output_size >= 4) { return FullyConnectedAsGEMV( input_shape, input_data, input_offset, filter_shape, filter_data, filter_offset, bias_shape, bias_data, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_shape, output_data, gemmlowp_context); } } #endif // USE_NEON #ifdef GEMMLOWP_NEON const int filter_rows = filter_shape.Dims(filter_dim_count - 2); const int filter_cols = filter_shape.Dims(filter_dim_count - 1); TFLITE_DCHECK_EQ(filter_shape.FlatSize(), filter_rows * filter_cols); const int output_rows = output_shape.Dims(output_dim_count - 1); TFLITE_DCHECK_EQ(output_rows, filter_rows); TFLITE_DCHECK_EQ(bias_shape.FlatSize(), output_rows); gemmlowp::MatrixMap<const int8, gemmlowp::MapOrder::RowMajor> filter_matrix( filter_data, output_rows, filter_cols, filter_cols); gemmlowp::MatrixMap<const int8, gemmlowp::MapOrder::ColMajor> input_matrix( input_data, filter_cols, batches, filter_cols); gemmlowp::MatrixMap<int8, gemmlowp::MapOrder::ColMajor> output_matrix( output_data, output_rows, batches, output_rows); const auto& output_pipeline = GemmlowpOutputPipelineInt8::MakeExp( bias_data, output_rows, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max); gemmlowp::GemmWithOutputPipeline< int8, int8, gemmlowp::SignedL8R8WithLhsNonzeroBitDepthParams>( gemmlowp_context, filter_matrix, input_matrix, &output_matrix, filter_offset, input_offset, output_pipeline); return; #endif // GEMMLOWP_NEON (void)gemmlowp_context; // If both GEMMLOWP_NEON && NEON paths are skipped, fallback to reference // implementation. reference_integer_ops::FullyConnected(params, input_shape, input_data, filter_shape, filter_data, bias_shape, bias_data, output_shape, output_data); } } // namespace optimized_integer_ops } // namespace tflite #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_INTEGER_OPS_FULLY_CONNECTED_H_
46.492958
84
0.717705
[ "vector" ]
033f3f604ac40f4edd8f102e2b848f0f79d61393
17,192
c
C
tool/SecVerilog-1.0/SecVerilog/tgt-vvp/eval_real.c
gokulprasath7c/secure_i2c_using_ift
124384983ba70e8164b7217db70c43dfdf302d4b
[ "MIT" ]
1
2019-01-28T21:23:37.000Z
2019-01-28T21:23:37.000Z
tool/SecVerilog-1.0/SecVerilog/tgt-vvp/eval_real.c
gokulprasath7c/secure_i2c_using_ift
124384983ba70e8164b7217db70c43dfdf302d4b
[ "MIT" ]
null
null
null
tool/SecVerilog-1.0/SecVerilog/tgt-vvp/eval_real.c
gokulprasath7c/secure_i2c_using_ift
124384983ba70e8164b7217db70c43dfdf302d4b
[ "MIT" ]
null
null
null
/* * Copyright (c) 2003-2010 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form 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 */ /* * This file includes functions for evaluating REAL expressions. */ # include "vvp_priv.h" # include <string.h> # include <stdlib.h> # include <math.h> # include <assert.h> static unsigned long word_alloc_mask = 0x0f; int allocate_word() { int res = 4; int max = WORD_COUNT; while (res < max && (1U << res) & word_alloc_mask) res += 1; if (res >= max) { fprintf(stderr, "vvp.tgt error: Thread words exhausted.\n"); exit(1); } word_alloc_mask |= 1U << res; return res; } void clr_word(int res) { int max = WORD_COUNT; assert(res < max); word_alloc_mask &= ~ (1U << res); } static void warn_about_large_cast(ivl_expr_t expr, unsigned wid) { if (ivl_expr_signed(expr)) { if (wid > 64) { fprintf(stderr, "%s:%u: tgt-vvp warning: V0.9 may give " "incorrect results when casting a signed " "value greater than 64 bits to a real " "value.\n", ivl_expr_file(expr), ivl_expr_lineno(expr)); } } else { if (wid > 63) { fprintf(stderr, "%s:%u: tgt-vvp warning: V0.9 may give " "incorrect results when casting an unsigned " "value greater than 63 bits to a real " "value.\n", ivl_expr_file(expr), ivl_expr_lineno(expr)); } } } static int draw_binary_real(ivl_expr_t expr) { int l, r = -1; switch (ivl_expr_opcode(expr)) { case 'E': case 'N': case 'l': case 'r': case 'R': case '&': case '|': case '^': case 'A': case 'O': case 'X': /* These should be caught in draw_eval_real(). */ assert(0); } l = draw_eval_real(ivl_expr_oper1(expr)); r = draw_eval_real(ivl_expr_oper2(expr)); switch (ivl_expr_opcode(expr)) { case '+': fprintf(vvp_out, " %%add/wr %d, %d;\n", l, r); break; case '-': fprintf(vvp_out, " %%sub/wr %d, %d;\n", l, r); break; case '*': fprintf(vvp_out, " %%mul/wr %d, %d;\n", l, r); break; case '/': fprintf(vvp_out, " %%div/wr %d, %d;\n", l, r); break; case '%': fprintf(vvp_out, " %%mod/wr %d, %d;\n", l, r); break; case 'p': fprintf(vvp_out, " %%pow/wr %d, %d;\n", l, r); break; case 'm': { /* min(l,r) */ int lab_out = local_count++; int lab_r = local_count++; /* If r is NaN, the go out and accept l as result. */ fprintf(vvp_out, " %%cmp/wr %d, %d; Is NaN?\n", r, r); fprintf(vvp_out, " %%jmp/0xz T_%d.%d, 4;\n", thread_count, lab_out); /* If l is NaN, the go out and accept r as result. */ fprintf(vvp_out, " %%cmp/wr %d, %d; Is NaN?\n", l, l); fprintf(vvp_out, " %%jmp/0xz T_%d.%d, 4;\n", thread_count, lab_r); /* If l <= r then go out. */ fprintf(vvp_out, " %%cmp/wr %d, %d;\n", r, l); fprintf(vvp_out, " %%jmp/0xz T_%d.%d, 5;\n", thread_count, lab_out); /* At this point we know we want r as the result. */ fprintf(vvp_out, "T_%d.%d %%mov/wr %d, %d;\n", thread_count, lab_r, l, r); fprintf(vvp_out, "T_%d.%d ;\n", thread_count, lab_out); break; } case 'M': { /* max(l,r) */ int lab_out = local_count++; int lab_r = local_count++; /* If r is NaN, the go out and accept l as result. */ fprintf(vvp_out, " %%cmp/wr %d, %d; Is NaN?\n", r, r); fprintf(vvp_out, " %%jmp/0xz T_%d.%d, 4;\n", thread_count, lab_out); /* If l is NaN, the go out and accept r as result. */ fprintf(vvp_out, " %%cmp/wr %d, %d; Is NaN?\n", l, l); fprintf(vvp_out, " %%jmp/0xz T_%d.%d, 4;\n", thread_count, lab_r); /* if l >= r then go out. */ fprintf(vvp_out, " %%cmp/wr %d, %d;\n", l, r); fprintf(vvp_out, " %%jmp/0xz T_%d.%d, 5;\n", thread_count, lab_out); fprintf(vvp_out, "T_%d.%d %%mov/wr %d, %d;\n", thread_count, lab_r, l, r); fprintf(vvp_out, "T_%d.%d ;\n", thread_count, lab_out); break; } default: fprintf(stderr, "XXXX draw_binary_real(%c)\n", ivl_expr_opcode(expr)); assert(0); } if (r >= 0) clr_word(r); return l; } static int draw_number_real(ivl_expr_t expr) { unsigned int idx; int res = allocate_word(); const char*bits = ivl_expr_bits(expr); unsigned wid = ivl_expr_width(expr); unsigned long mant = 0, mask = -1UL; int vexp = 0x1000; /* If this is a negative number, then arrange for the 2's complement to be calculated as we scan through the value. Real values are sign-magnitude, and this negation gets us a magnitude. */ int negate = 0; int carry = 0; if (ivl_expr_signed(expr) && (bits[wid-1] == '1')) { negate = 1; carry = 1; } for (idx = 0 ; idx < wid && idx < IMM_WID ; idx += 1) { mask <<= 1; int cur_bit = bits[idx] == '1'? 1 : 0; if (negate) { cur_bit ^= 1; cur_bit += carry; carry = (cur_bit >> 1) & 1; cur_bit &= 1; } if (cur_bit) mant |= 1 << idx; } for ( ; idx < wid ; idx += 1) { if (ivl_expr_signed(expr) && (bits[idx] == bits[IMM_WID-1])) continue; if (bits[idx] == '0') continue; fprintf(stderr, "vvp.tgt error: mantissa doesn't fit!\n"); assert(0); } /* If required, add in a sign bit. */ if (negate) vexp |= 0x4000; fprintf(vvp_out, " %%loadi/wr %d, %lu, %d; load(num)= %c%lu (wid=%u)\n", res, mant, vexp, (vexp&0x4000)? '-' : '+', mant, wid); return res; } static int draw_realnum_real(ivl_expr_t expr) { int res = allocate_word(); double value = ivl_expr_dvalue(expr); double fract; int expo, vexp; unsigned long mant; int sign = 0; /* Handle the special case that the value is +-inf. */ if (isinf(value)) { if (value > 0) fprintf(vvp_out, " %%loadi/wr %d, 0, %d; load=+inf\n", res, 0x3fff); else fprintf(vvp_out, " %%loadi/wr %d, 0, %d; load=-inf\n", res, 0x7fff); return res; } /* Handle the special case that the value is NaN. */ if (value != value) { fprintf(vvp_out, " %%loadi/wr %d, 1, %d; load=NaN\n", res, 0x3fff); return res; } if (value < 0) { sign = 0x4000; value *= -1; } fract = frexp(value, &expo); fract = ldexp(fract, 31); mant = fract; expo -= 31; vexp = expo + 0x1000; assert(vexp >= 0); assert(vexp < 0x2000); vexp += sign; fprintf(vvp_out, " %%loadi/wr %d, %lu, %d; load=%#g\n", res, mant, vexp, ivl_expr_dvalue(expr)); /* Capture the residual bits, if there are any. Note that an IEEE754 mantissa has 52 bits, 31 of which were accounted for already. */ fract -= floor(fract); fract = ldexp(fract, 22); mant = fract; expo -= 22; vexp = expo + 0x1000; assert(vexp >= 0); assert(vexp < 0x2000); vexp += sign; if (mant != 0) { int tmp_word = allocate_word(); fprintf(vvp_out, " %%loadi/wr %d, %lu, %d; load=%#g\n", tmp_word, mant, vexp, ivl_expr_dvalue(expr)); fprintf(vvp_out, " %%add/wr %d, %d;\n", res, tmp_word); clr_word(tmp_word); } return res; } static int draw_sfunc_real(ivl_expr_t expr) { struct vector_info sv; int res; const char*sign_flag = ""; switch (ivl_expr_value(expr)) { case IVL_VT_REAL: if (ivl_expr_parms(expr) == 0) { res = allocate_word(); fprintf(vvp_out, " %%vpi_func/r %u %u \"%s\", %d;\n", ivl_file_table_index(ivl_expr_file(expr)), ivl_expr_lineno(expr), ivl_expr_name(expr), res); } else { res = draw_vpi_rfunc_call(expr); } break; case IVL_VT_VECTOR: /* If the value of the sfunc is a vector, then evaluate it as a vector, then convert the result to a real (via an index register) for the result. */ sv = draw_eval_expr(expr, 0); clr_vector(sv); if (ivl_expr_signed(expr)) sign_flag = "/s"; res = allocate_word(); fprintf(vvp_out, " %%ix/get%s %d, %u, %u;\n", sign_flag, res, sv.base, sv.wid); warn_about_large_cast(expr, sv.wid); fprintf(vvp_out, " %%cvt/ri %d, %d;\n", res, res); break; default: assert(0); res = -1; } return res; } /* * The real value of a signal is the integer value of a signal * converted to real. */ static int draw_signal_real_logic(ivl_expr_t expr) { int res = allocate_word(); struct vector_info sv = draw_eval_expr(expr, 0); const char*sign_flag = ivl_expr_signed(expr)? "/s" : ""; fprintf(vvp_out, " %%ix/get%s %d, %u, %u; logic signal as real\n", sign_flag, res, sv.base, sv.wid); clr_vector(sv); warn_about_large_cast(expr, sv.wid); fprintf(vvp_out, " %%cvt/ri %d, %d;\n", res, res); return res; } static int draw_signal_real_real(ivl_expr_t expr) { ivl_signal_t sig = ivl_expr_signal(expr); int res = allocate_word(); if (ivl_signal_dimensions(sig) == 0) { fprintf(vvp_out, " %%load/wr %d, v%p_0;\n", res, sig); return res; } ivl_expr_t word_ex = ivl_expr_oper1(expr); int word_ix = allocate_word(); draw_eval_expr_into_integer(word_ex, word_ix); fprintf(vvp_out, " %%load/ar %d, v%p, %d;\n", res, sig, word_ix); clr_word(word_ix); return res; } static int draw_signal_real(ivl_expr_t expr) { ivl_signal_t sig = ivl_expr_signal(expr); switch (ivl_signal_data_type(sig)) { case IVL_VT_LOGIC: return draw_signal_real_logic(expr); case IVL_VT_REAL: return draw_signal_real_real(expr); default: fprintf(stderr, "vvp.tgt error: signal_data_type=%d\n", ivl_signal_data_type(sig)); assert(0); return -1; } } /* If we have nested ternary operators they are likely tail recursive. * This code is structured to allow this recursion without overflowing * the available thread words. */ static int draw_ternary_real(ivl_expr_t expr) { ivl_expr_t cond = ivl_expr_oper1(expr); ivl_expr_t true_ex = ivl_expr_oper2(expr); ivl_expr_t false_ex = ivl_expr_oper3(expr); struct vector_info tst; unsigned lab_true = local_count++; unsigned lab_move = local_count++; unsigned lab_out = local_count++; int tru, fal, res; /* Evaluate the ternary condition. */ tst = draw_eval_expr(cond, STUFF_OK_XZ|STUFF_OK_RO); if ((tst.base >= 4) && (tst.wid > 1)) { struct vector_info tmp; fprintf(vvp_out, " %%or/r %u, %u, %u;\n", tst.base, tst.base, tst.wid); tmp = tst; tmp.base += 1; tmp.wid -= 1; clr_vector(tmp); tst.wid = 1; } /* Evaluate the true expression second. */ fprintf(vvp_out, " %%jmp/1 T_%d.%d, %u;\n", thread_count, lab_true, tst.base); /* Evaluate the false expression and copy it to the result word. */ fal = draw_eval_real(false_ex); res = allocate_word(); fprintf(vvp_out, " %%mov/wr %d, %d;\n", res, fal); clr_word(fal); fprintf(vvp_out, " %%jmp/0 T_%d.%d, %u; End of false expr.\n", thread_count, lab_out, tst.base); /* Evaluate the true expression. */ fprintf(vvp_out, "T_%d.%d ;\n", thread_count, lab_true); tru = draw_eval_real(true_ex); fprintf(vvp_out, " %%jmp/1 T_%d.%d, %u; End of true expr.\n", thread_count, lab_move, tst.base); /* If the conditional is undefined then blend the real words. */ fprintf(vvp_out, " %%blend/wr %d, %d;\n", res, tru); fprintf(vvp_out, " %%jmp T_%d.%d; End of blend\n", thread_count, lab_out); /* If we only need the true result then copy it to the result word. */ fprintf(vvp_out, "T_%d.%d ; Move true result.\n", thread_count, lab_move); fprintf(vvp_out, " %%mov/wr %d, %d;\n", res, tru); clr_word(tru); /* This is the out label. */ fprintf(vvp_out, "T_%d.%d ;\n", thread_count, lab_out); clr_vector(tst); return res; } static int draw_unary_real(ivl_expr_t expr) { ivl_expr_t sube; int sub; /* If the opcode is a ~ then the sub expression must not be a * real expression, so use vector evaluation and then convert * that result to a real value. */ if (ivl_expr_opcode(expr) == '~') { struct vector_info vi; int res; const char*sign_flag; vi = draw_eval_expr(expr, STUFF_OK_XZ); res = allocate_word(); sign_flag = ivl_expr_signed(expr)? "/s" : ""; fprintf(vvp_out, " %%ix/get%s %d, %u, %u;\n", sign_flag, res, vi.base, vi.wid); warn_about_large_cast(expr, vi.wid); fprintf(vvp_out, " %%cvt/ri %d, %d;\n", res, res); clr_vector(vi); return res; } if (ivl_expr_opcode(expr) == '!') { struct vector_info vi; int res; const char*sign_flag; vi = draw_eval_expr(expr, STUFF_OK_XZ); res = allocate_word(); sign_flag = ivl_expr_signed(expr)? "/s" : ""; fprintf(vvp_out, " %%ix/get%s %d, %u, %u;\n", sign_flag, res, vi.base, vi.wid); warn_about_large_cast(expr, vi.wid); fprintf(vvp_out, " %%cvt/ri %d, %d;\n", res, res); clr_vector(vi); return res; } sube = ivl_expr_oper1(expr); sub = draw_eval_real(sube); if (ivl_expr_opcode(expr) == '+') return sub; if (ivl_expr_opcode(expr) == '-') { int res = allocate_word(); fprintf(vvp_out, " %%loadi/wr %d, 0, 0; load 0.0\n", res); fprintf(vvp_out, " %%sub/wr %d, %d;\n", res, sub); clr_word(sub); return res; } if (ivl_expr_opcode(expr) == 'm') { /* abs(sube) */ fprintf(vvp_out, " %%abs/wr %d, %d;\n", sub, sub); return sub; } fprintf(stderr, "vvp.tgt error: unhandled real unary operator: %c.\n", ivl_expr_opcode(expr)); assert(0); } int draw_eval_real(ivl_expr_t expr) { int res = 0; /* If this expression/sub-expression is not real then we need * to evaluate it as a bit value and then convert the bit based * result to a real value. This is required to get integer * division to work correctly. */ if (ivl_expr_value(expr) != IVL_VT_REAL) { struct vector_info vi; const char*sign_flag; vi = draw_eval_expr(expr, STUFF_OK_XZ); res = allocate_word(); sign_flag = ivl_expr_signed(expr)? "/s" : ""; fprintf(vvp_out, " %%ix/get%s %d, %u, %u;\n", sign_flag, res, vi.base, vi.wid); warn_about_large_cast(expr, vi.wid); fprintf(vvp_out, " %%cvt/ri %d, %d;\n", res, res); clr_vector(vi); return res; } switch (ivl_expr_type(expr)) { case IVL_EX_BINARY: res = draw_binary_real(expr); break; case IVL_EX_NUMBER: res = draw_number_real(expr); break; case IVL_EX_REALNUM: res = draw_realnum_real(expr); break; case IVL_EX_SFUNC: res = draw_sfunc_real(expr); break; case IVL_EX_SIGNAL: res = draw_signal_real(expr); break; case IVL_EX_TERNARY: res = draw_ternary_real(expr); break; case IVL_EX_UFUNC: res = draw_ufunc_real(expr); break; case IVL_EX_UNARY: res = draw_unary_real(expr); break; default: if (ivl_expr_value(expr) == IVL_VT_VECTOR) { struct vector_info sv = draw_eval_expr(expr, 0); const char*sign_flag = ivl_expr_signed(expr)? "/s" : ""; clr_vector(sv); res = allocate_word(); fprintf(vvp_out, " %%ix/get%s %d, %u, %u;\n", sign_flag, res, sv.base, sv.wid); warn_about_large_cast(expr, sv.wid); fprintf(vvp_out, " %%cvt/ri %d, %d;\n", res, res); } else { fprintf(stderr, "XXXX Evaluate real expression (%d)\n", ivl_expr_type(expr)); fprintf(vvp_out, " ; XXXX Evaluate real expression (%d)\n", ivl_expr_type(expr)); return 0; } break; } return res; }
27.5072
81
0.565379
[ "vector" ]
0346d6f16ae4c1189f9894e1b5948c0f943b80f5
1,669
h
C
mbed/hal/trng_api.h
ValhollFuture/STM32_Button_Debounce-
2b6ee082c6ea7bef49b8bbc19603bd093d75e0d7
[ "Apache-2.0" ]
993
2017-12-13T21:28:24.000Z
2022-03-30T20:43:35.000Z
mbed/hal/trng_api.h
ValhollFuture/STM32_Button_Debounce-
2b6ee082c6ea7bef49b8bbc19603bd093d75e0d7
[ "Apache-2.0" ]
144
2017-12-14T22:43:35.000Z
2022-01-12T13:46:33.000Z
mbed/hal/trng_api.h
ValhollFuture/STM32_Button_Debounce-
2b6ee082c6ea7bef49b8bbc19603bd093d75e0d7
[ "Apache-2.0" ]
400
2017-12-14T05:15:20.000Z
2022-02-18T02:03:39.000Z
/** \addtogroup hal */ /** @{*/ /* mbed Microcontroller Library * Copyright (c) 2016 ARM Limited * * 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 MBED_TRNG_API_H #define MBED_TRNG_API_H #include <stddef.h> #include "device.h" #if DEVICE_TRNG /** TRNG HAL structure. trng_s is declared in the target's HAL */ typedef struct trng_s trng_t; #ifdef __cplusplus extern "C" { #endif /** * \defgroup hal_trng TRNG hal functions * @{ */ /** Initialize the TRNG peripheral * * @param obj The TRNG object */ void trng_init(trng_t *obj); /** Deinitialize the TRNG peripheral * * @param obj The TRNG object */ void trng_free(trng_t *obj); /** Get random data from TRNG peripheral * * @param obj The TRNG object * @param output The pointer to an output array * @param length The size of output data, to avoid buffer overwrite * @param output_length The length of generated data * @return 0 success, -1 fail */ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length); /**@}*/ #ifdef __cplusplus } #endif #endif #endif /** @}*/
22.863014
88
0.681845
[ "object" ]
034a6001d8167861b9b17b166c4f8d4e7ca0ad5d
796
h
C
SFLiveLib/include/SFDownLoadManager.h
joygo-tech/SFLiveLib
0f1e9df0c1803aee75a54b0f0bdd22740ca92863
[ "MIT" ]
2
2016-10-10T04:38:13.000Z
2016-10-11T04:10:01.000Z
SFLiveLib/include/SFDownLoadManager.h
joygo-tech/SFLiveLib
0f1e9df0c1803aee75a54b0f0bdd22740ca92863
[ "MIT" ]
null
null
null
SFLiveLib/include/SFDownLoadManager.h
joygo-tech/SFLiveLib
0f1e9df0c1803aee75a54b0f0bdd22740ca92863
[ "MIT" ]
null
null
null
// // SFDownLoadManager.h // SFLiveLib // // Created by 李晓宁 on 2016/12/7. // Copyright © 2016年 Joygo. All rights reserved. // #import <Foundation/Foundation.h> #import "SUKaraokeModel.h" #import "SUKaraokeResModel.h" #import "KalaOkManager.h" @interface SFDownLoadManager : NSObject + (instancetype)defaultSFDownLoadManager; //下载文件 - (void)downloadWithModel:(SUKaraokeResModel *)downloadModel musicModel:(SUKaraokeModel *)musicModel progress:(void (^)(float progressPlan))progress complete:(void (^)(SUKaraokeModel *model,NSError *error))complete; //暂停下载 //- (void)stopDownload:(NSNumber *)s_id; //重新恢复下载 //- (void)resumeDownloa:(NSString *)key; //停止所有的下载 - (void)stopAllDownloadTask; //删除所有的下载临时文件 //- (void)deleteAllDownloadTmpFile; //取消所有的下载请求 - (void)cancelAllDownloadTask; @end
22.111111
215
0.747487
[ "model" ]
034ade144ae8cd383493c491b13631dbd0d9317d
3,042
h
C
Core/Level.h
zaphire/Monocle-Engine
a4558b5436681ab0ec95aec388cbb791b26f0b81
[ "Unlicense" ]
72
2015-02-09T06:24:57.000Z
2022-02-05T20:02:49.000Z
Core/Level.h
zaphire/Monocle-Engine
a4558b5436681ab0ec95aec388cbb791b26f0b81
[ "Unlicense" ]
null
null
null
Core/Level.h
zaphire/Monocle-Engine
a4558b5436681ab0ec95aec388cbb791b26f0b81
[ "Unlicense" ]
14
2015-02-14T05:04:17.000Z
2022-03-09T19:55:33.000Z
#pragma once #include <string> #include <vector> #include <list> #include "Graphics.h" #include "Tileset.h" #include "Graphics/Tilemap.h" #include "LevelEditor/FringeTile.h" // temp, replace with generic file interface later #include <TinyXML/tinyxml.h> #include <XML/XMLFileNode.h> namespace Monocle { class Scene; class EntityType { public: EntityType(); std::string name; std::string image; void Save(FileNode *fileNode); void Load(FileNode *fileNode); }; //! //! \brief Manages the saving and loading of Entity instances as well as other objects. //! //! Can be extended to save/load any derivation of Entity, by overriding a few functions. //! class Level { public: Level(); void Init(); static void SetScene(Scene *scene); static void LoadProject(const std::string &filename); static void Load(const std::string &filename, Scene* scene=NULL); static void Save(); static void SaveAs(const std::string &filename); static void End(); // called on scene end static FringeTileset* GetCurrentFringeTileset(); std::string name; std::list<Tilemap*> tilemaps; std::list<Tileset> tilesets; std::list<FringeTileset> fringeTilesets; int width, height; template <class T> static void SaveEntitiesOfType(const std::string &name, TiXmlElement *element, Entity *fromEntity=NULL) { XMLFileNode xmlFileNode; const std::list<Entity*> *entities; //if (fromEntity) // entities = fromEntity->GetChildren(); //else entities = instance->scene->GetEntities(); for (std::list<Entity*>::const_iterator i = entities->begin(); i != entities->end(); ++i) { Entity *entity = *i; T *t = dynamic_cast<T*>(entity); if (t && !t->GetParent()) { TiXmlElement saveElement(name); xmlFileNode.element = &saveElement; //instance->SaveEntities(&saveElement, entity); entity->Save(&xmlFileNode); element->InsertEndChild(saveElement); } } } template <class T> static void LoadEntitiesOfType(const std::string &name, TiXmlElement *element, Entity *intoEntity=NULL) { XMLFileNode xmlFileNode; TiXmlElement *eEntity = element->FirstChildElement(name); while (eEntity) { T *t = new T(); printf("made a new %s\n", name.c_str()); Entity *entity = dynamic_cast<Entity*>(t); //if (intoEntity == NULL) instance->scene->Add(entity); entity->SetParent(intoEntity); //else //intoEntity->Add(entity); //instance->LoadEntities(eEntity, entity); xmlFileNode.element = eEntity; entity->Load(&xmlFileNode); eEntity = eEntity->NextSiblingElement(name); } } private: Tileset *GetTilesetByName(const std::string &name); FringeTileset *GetFringeTilesetByName(const std::string &name); Scene *scene; static Level *instance; std::string filename; FringeTileset *fringeTileset; std::list<EntityType> entityTypes; void SaveEntities(TiXmlElement *element, Entity *fromEntity=NULL); void LoadEntities(TiXmlElement *element, Entity *intoEntity=NULL); }; }
22.701493
124
0.686719
[ "vector" ]
035280e99b987e67f0887d1977e9a271445cc86c
97,125
c
C
src/pl-wic.c
mb64/swipl-devel
13d86a3e4cf65653b5a2efcfba88624d1840b072
[ "BSD-2-Clause" ]
null
null
null
src/pl-wic.c
mb64/swipl-devel
13d86a3e4cf65653b5a2efcfba88624d1840b072
[ "BSD-2-Clause" ]
null
null
null
src/pl-wic.c
mb64/swipl-devel
13d86a3e4cf65653b5a2efcfba88624d1840b072
[ "BSD-2-Clause" ]
null
null
null
/* Part of SWI-Prolog Author: Jan Wielemaker E-mail: J.Wielemaker@vu.nl WWW: http://www.swi-prolog.org Copyright (c) 1985-2021, University of Amsterdam VU University Amsterdam CWI, Amsterdam SWI-Prolog Solutions b.v. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY 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. */ /*#define O_DEBUG 1*/ #include "pl-incl.h" #include "pl-comp.h" #include "pl-arith.h" #include "os/pl-utf8.h" #include "pl-dbref.h" #include "pl-dict.h" #ifdef HAVE_SYS_PARAM_H #include <sys/param.h> #endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #ifdef O_DEBUG #define Qgetc(s) Sgetc(s) #define TRACK_POS "" #else #define Qgetc(s) Snpgetc(s) /* ignore position recording */ #define TRACK_POS "r" #endif /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SWI-Prolog can compile Prolog source files into intermediate code files, which can be loaded very fast. They can be saved as stand alone executables using Unix #! magic number. A wic file consists of the magic code and a version check code. This is followed by the command line option defaults. Then an optional series of `include' statements follow. Finally the predicates and directives are described. Predicates are described close to the internal representation. Directives are stored as binary terms representing the query. The default options and include statements are written incrementally in each wic file. In the normal boot cycle first the boot file is determined. Then the option structure is filled with the default option found in this boot file. Next the command line arguments are scanned to obtain all options. Then stacks, built in's, etc. are initialised. The the boot file is read again, but now only scanning for directives and predicates. IF YOU CHANGE ANYTHING TO THIS FILE, SO THAT OLD WIC-FILES CAN NO LONGER BE READ, PLEASE DO NOT FORGET TO INCREMENT THE VERSION NUMBER! Below is an informal description of the format of a `.qlf' file: <wic-file> ::= <magic code> <version number> <bits-per-word> <home> % a <string> {<statement>} 'T' ---------------------------------------------------------------- <qlf-file> ::= <qlf-magic> <version-number> <bits-per-word> 'F' <string> % path of qlf file {'I' <include>} 'Q' <qlf-part> <qlf-magic> ::= <string> <qlf-module> ::= <qlf-header> <size> % size in bytes {<statement>} 'X' <qlf-header> ::= 'M' <XR/modulename> % module name <source> % file + time <line> {'S' <XR/supername>} {<qlf-export>} 'X' | <source> % not a module <time> <qlf-export> ::= 'E' <XR/functor> <source> ::= 'F' <string> <time> <system> | '-' ---------------------------------------------------------------- <magic code> ::= <string> % normally #!<path> <version number>::= <num> <statement> ::= 'W' <string> % include wic file | 'P' <XR/functor> % predicate <flags> {<clause>} <pattern> | 'O' <XR/modulename> % pred out of module <XR/functor> <flags> {<clause>} <pattern> | 'D' <lineno> % source line number <term> % directive | 'E' <XR/functor> % export predicate | 'I' <XR/procedure> <flags> % import predicate | 'Q' <qlf-module> % include module | 'M' <XR/modulename> % load-in-module {<statement>} 'X' <flags> ::= <num> % Bitwise or of PRED_* <clause> ::= 'C' <#codes> <line_no> <owner_file> <source_file> <# prolog vars> <# vars> <is_fact> % 0 or 1 <#n subclause> <codes> | 'X' % end of list <XR> ::= XR_REF <num> % XR id from table XR_NIL % [] XR_CONS % functor of [_|_] XR_ATOM <len><chars> % atom XR_BLOB <blob><private> % typed atom (blob) XR_INT <num> % number XR_FLOAT <word>* % float (double) XR_STRING <string> % string XR_STRING_UTF8 <utf-8 string> % wide string XR_FUNCTOR <XR/name> <num> % functor XR_PRED <XR/fdef> <XR/module>% predicate XR_MODULE <XR/name> % module XR_FILE 's'|'u' <XR/atom> <time> '-' XR_BLOB_TYPE <len><chars> % blob type-name <term> ::= <num> % # variables in term <theterm> <theterm> ::= <XR/atomic> % atomic data | 'v' <num> % variable | 't' <XR/functor> {<theterm>} % compound <system> ::= 's' % system source file | 'u' % user source file <time> ::= <word> % time file was loaded <line> ::= <num> <codes> ::= <num> {<code>} <string> ::= {<non-zero byte>} <0> <word> ::= <4 byte entity> <include> ::= <owner> <parent> <line> <file> <time> Integers are stored in a packed format to reduce the size of the intermediate code file as 99% of them is normally small, but in principle not limited (virtual machine codes, arities, table sizes, etc). We use the "zigzag" encoding to deal with negative integers and write the positive value in chunks of 7 bits, least significant bits first. The last byte has its 0x80 mask set. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define QLFMAGICNUM 0x716c7374 /* "qlst" on little-endian machine */ #define XR_REF 0 /* reference to previous */ #define XR_NIL 1 /* [] */ #define XR_CONS 2 /* functor of [_|_] */ #define XR_ATOM 3 /* atom */ #define XR_FUNCTOR 4 /* functor */ #define XR_PRED 5 /* procedure */ #define XR_INT 6 /* int */ #define XR_FLOAT 7 /* float */ #define XR_STRING 8 /* string */ #define XR_FILE 9 /* source file */ #define XR_MODULE 10 /* a module */ #define XR_BLOB 11 /* a typed atom (blob) */ #define XR_BLOB_TYPE 12 /* name of atom-type declaration */ #define XR_STRING_UTF8 13 /* Wide character string */ #define XR_NULL 14 /* NULL pointer */ #define V_LABEL 256 /* Label pseudo opcode */ #define V_H_INTEGER 257 /* Abstract various H_INT variations */ #define V_B_INTEGER 258 /* Abstract various B_INT variations */ #define V_A_INTEGER 259 /* Abstract various A_INT variations */ #define PRED_SYSTEM 0x01 /* system predicate */ #define PRED_HIDE_CHILDS 0x02 /* hide my childs */ #define PRED_DET 0x04 /* Determinism flag */ #define CLAUSE_UNIT_CLAUSE 0x01 #define CLAUSE_SSU_COMMIT 0x02 #define CLAUSE_SSU_CHOICE 0x04 static char saveMagic[] = "SWI-Prolog state (www.swi-prolog.org)\n"; static char qlfMagic[] = "SWI-Prolog .qlf file\n"; typedef struct source_mark { long file_index; struct source_mark *next; } source_mark, *SourceMark; #define XR_BLOCKS 32 typedef struct xr_table { unsigned int id; /* next id to give out */ struct xr_table* previous; /* stack */ Word blocks[XR_BLOCKS]; /* main table */ word preallocated[7]; } xr_table, *XrTable; typedef struct path_translated { struct path_translated *next; atom_t from; atom_t to; } path_translated; typedef struct qlf_state { char *save_dir; /* Directory saved */ char *load_dir; /* Directory loading */ int has_moved; /* Paths must be translated */ path_translated *translated; /* Translated paths */ struct qlf_state *previous; /* previous saved state (reentrance) */ } qlf_state; typedef struct wic_state { char *wicFile; /* name of output file */ char *mkWicFile; /* Wic file under construction */ IOSTREAM *wicFd; /* file descriptor of wic file */ Definition currentPred; /* current procedure */ SourceFile currentSource; /* current source file */ Table idMap; /* mapped identifiers */ Table savedXRTable; /* saved XR entries */ intptr_t savedXRTableId; /* next id to hand out */ SourceMark source_mark_head; /* Locations of sources */ SourceMark source_mark_tail; int has_source_marks; int saved_version; /* Version saved */ int obfuscate; /* Obfuscate source */ int load_nesting; /* Nesting level of loadPart() */ qlf_state *load_state; /* current load-state */ xr_table *XR; /* external references */ struct { int invalid_wide_chars; /* Cannot represent due to UCS-2 */ } errors; struct wic_state *parent; /* parent state */ } wic_state; static char * getString(IOSTREAM *, size_t *len); static int64_t getInt64(IOSTREAM *); static int getInt32(IOSTREAM *s); static int getInt(IOSTREAM *); static double getFloat(IOSTREAM *); static bool loadWicFd(wic_state *state); static bool loadPredicate(wic_state *state, int skip ARG_LD); static bool loadImport(wic_state *state, int skip ARG_LD); static void saveXRBlobType(wic_state *state, PL_blob_t *type); static void putString(const char *, size_t len, IOSTREAM *); static void putInt64(int64_t, IOSTREAM *); static void putFloat(double, IOSTREAM *); static void saveWicClause(wic_state *state, Clause cl); static void closePredicateWic(wic_state *state); static word loadXRc(wic_state *state, int c ARG_LD); static atom_t getBlob(wic_state *state ARG_LD); static bool loadStatement(wic_state *state, int c, int skip ARG_LD); static bool loadPart(wic_state *state, Module *module, int skip ARG_LD); static bool loadInModule(wic_state *state, int skip ARG_LD); static int qlfVersion(wic_state *state, const char *magic, int *vp); static atom_t qlfFixSourcePath(wic_state *state, const char *raw); static int pushPathTranslation(wic_state *state, const char *loadname, int flags); static void popPathTranslation(wic_state *state); static int qlfIsCompatible(wic_state *state, const char *magic); /* Convert CA1_VAR arguments to VM independent and back */ #define VAR_OFFSET(i) ((intptr_t)((i) - (ARGOFFSET / (intptr_t) sizeof(word)))) #define OFFSET_VAR(i) ((intptr_t)((i) + (ARGOFFSET / (intptr_t) sizeof(word)))) #undef LD #define LD LOCAL_LD /******************************* * LOADED XR ID HANDLING * *******************************/ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - XR reference handling during loading. This uses a dynamic array using doubling sub arrays as also used for atoms, functors, etc. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void pushXrIdTable(wic_state *state) { XrTable t = allocHeapOrHalt(sizeof(*t)); memset(t, 0, sizeof(*t)); t->id = 0; t->blocks[0] = t->preallocated - 1; t->blocks[1] = t->preallocated - 1; t->blocks[2] = t->preallocated - 1; t->previous = state->XR; state->XR = t; } static void popXrIdTable(wic_state *state) { XrTable t = state->XR; unsigned int id, idx; state->XR = t->previous; /* pop the stack */ for(id=0; id < 7; id++) { word w = t->preallocated[id]; if ( isAtom(w) ) PL_unregister_atom(w); } for(idx = 3; idx < XR_BLOCKS && t->blocks[idx]; idx++) { size_t bs = (size_t)1<<idx; Word p = t->blocks[idx]+bs; size_t i; for(i=0; i<bs && id < t->id; i++, id++) { word w = p[i]; if ( isAtom(w) ) PL_unregister_atom(w); } freeHeap(p, bs*sizeof(word)); } freeHeap(t, sizeof(*t)); } static word lookupXrId(wic_state *state, unsigned int id) { XrTable t = state->XR; unsigned int idx = MSB(id); DEBUG(CHK_SECURE, assert(t->blocks[idx])); return t->blocks[idx][id]; } static void storeXrId(wic_state *state, unsigned int id, word value) { XrTable t = state->XR; unsigned int idx = MSB(id); if ( !t->blocks[idx] ) { size_t bs = (size_t)1<<idx; Word newblock; newblock = allocHeapOrHalt(bs*sizeof(word)); t->blocks[idx] = newblock-bs; } t->blocks[idx][id] = value; } /******************************* * PRIMITIVE LOADING * *******************************/ #define PATH_ISDIR 0x1 /* pushPathTranslation() flags */ static bool qlfLoadError_ctx(wic_state *state, char *file, int line) { fatalError("%s: QLF format error at index = %ld (%s:%d)", state->wicFile, Stell(state->wicFd), file, line); fail; } #define qlfLoadError(state) qlfLoadError_ctx(state, __FILE__, __LINE__) /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load a string from the input stream. There are two cases: 0-terminated short strings (files, etc) have length set to NULL and the general Prolog string case has length pointing to a pointer. The latter is used only for saved (directive) terms and the result is thus pushed to the global stack. Returns NULL if the string is too large. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char * getString(IOSTREAM *fd, size_t *length) { GET_LD char *s; size_t len = (size_t)getInt64(fd); size_t i; if ( !length && len > MAXPATHLEN ) return NULL; if ( length && len > globalStackLimit() ) return NULL; if ( LD->qlf.getstr_buffer_size < len+1 ) { size_t size = ((len+1+1023)/1024)*1024; if ( LD->qlf.getstr_buffer ) LD->qlf.getstr_buffer = realloc(LD->qlf.getstr_buffer, size); else LD->qlf.getstr_buffer = malloc(size); if ( LD->qlf.getstr_buffer ) LD->qlf.getstr_buffer_size = size; else outOfCore(); } for( i=0, s = LD->qlf.getstr_buffer; i<len; i++ ) { int c = Qgetc(fd); if ( c == EOF ) fatalError("Unexpected EOF on QLF file at offset %d", Stell(fd)); *s++ = c; } *s = EOS; if ( length ) *length = (unsigned) len; return LD->qlf.getstr_buffer; } pl_wchar_t * wicGetStringUTF8(IOSTREAM *fd, size_t *length, pl_wchar_t *buf, size_t bufsize) { size_t i, len = (size_t)getInt64(fd); IOENC oenc = fd->encoding; pl_wchar_t *tmp, *o; if ( length ) *length = len; if ( len < bufsize ) tmp = buf; else tmp = PL_malloc(len*sizeof(pl_wchar_t)); fd->encoding = ENC_UTF8; for(i=0, o=tmp; i<len; i++) { int c = Sgetcode(fd); if ( c < 0 ) fatalError("Unexpected EOF in UCS atom"); *o++ = c; } fd->encoding = oenc; return tmp; } static atom_t getAtom(IOSTREAM *fd, PL_blob_t *type) { char buf[1024]; char *tmp, *s; size_t len = getInt(fd); size_t i; atom_t a; if ( len < sizeof(buf) ) tmp = buf; else tmp = allocHeapOrHalt(len); for(s=tmp, i=0; i<len; i++) { int c = Qgetc(fd); if ( c == EOF ) fatalError("Unexpected EOF on intermediate code file at offset %d", Stell(fd)); *s++ = c; } if ( type ) { int new; a = lookupBlob(tmp, len, type, &new); } else { a = lookupAtom(tmp, len); } if ( tmp != buf ) freeHeap(tmp, len); return a; } static PL_blob_t * getBlobType(IOSTREAM *fd) { const char *name; if ( !(name = getString(fd, NULL)) ) fatalError("Invalid blob type in QLF"); return PL_find_blob_type(name); } static char * getMagicString(IOSTREAM *fd, char *buf, int maxlen) { char *s; int c; for( s = buf; --maxlen >= 0 && (*s = (c = Sgetc(fd))); s++ ) { if ( c == EOF ) return NULL; } if ( maxlen > 0 ) return buf; return NULL; } static inline uint64_t zigzag_encode(int64_t n) { return (n << 1) ^ (n >> 63); } static inline int64_t zigzag_decode(uint64_t n) { return (n >> 1) ^ -(n&1); } static int64_t getInt64(IOSTREAM *fd) { int c = Qgetc(fd); if ( c&0x80 ) { DEBUG(MSG_QLF_INTEGER, Sdprintf("%" PRId64 "\n", zigzag_decode(c&0x7f))); return zigzag_decode(c&0x7f); } else { uint64_t v = c&0x7f; int shift = 7; for(;;) { c = Qgetc(fd); if ( c&0x80 ) { uint64_t l = (c&0x7f); v |= l<<shift; DEBUG(MSG_QLF_INTEGER, Sdprintf("%" PRId64 "\n", zigzag_decode(v))); return zigzag_decode(v); } else { uint64_t b = c; v |= b<<shift; shift += 7; } } } } static int getInt(IOSTREAM *fd) { int64_t val = getInt64(fd); return (int)val; } static unsigned int getUInt(IOSTREAM *fd) { unsigned int c = Qgetc(fd); if ( c&0x80 ) { DEBUG(MSG_QLF_INTEGER, Sdprintf("%d\n", c&0x7f)); return c&0x7f; } else { unsigned int v = c&0x7f; int shift = 7; for(;;) { c = Qgetc(fd); if ( c&0x80 ) { unsigned int l = (c&0x7f); v |= l<<shift; DEBUG(MSG_QLF_INTEGER, Sdprintf("%d\n", v)); return v; } else { unsigned int b = c; v |= b<<shift; shift += 7; } } } } #ifdef WORDS_BIGENDIAN static const int double_byte_order[] = { 7,6,5,4,3,2,1,0 }; #else static const int double_byte_order[] = { 0,1,2,3,4,5,6,7 }; #endif #define BYTES_PER_DOUBLE (sizeof(double_byte_order)/sizeof(int)) static double getFloat(IOSTREAM *fd) { double f; unsigned char *cl = (unsigned char *)&f; unsigned int i; for(i=0; i<BYTES_PER_DOUBLE; i++) { int c = Qgetc(fd); if ( c == -1 ) fatalError("Unexpected end-of-file in QLT file"); cl[double_byte_order[i]] = c; } DEBUG(MSG_QLF_FLOAT, Sdprintf("getFloat() --> %f\n", f)); return f; } static int getInt32(IOSTREAM *s) { int v; v = (Sgetc(s) & 0xff) << 24; v |= (Sgetc(s) & 0xff) << 16; v |= (Sgetc(s) & 0xff) << 8; v |= (Sgetc(s) & 0xff); return v; } static inline word loadXR__LD(wic_state *state ARG_LD) { return loadXRc(state, Qgetc(state->wicFd) PASS_LD); } #define loadXR(s) loadXR__LD(s PASS_LD) /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - loadXRc(int c0, IOSTREAM *fd ARG_LD) loads a constant from the stream. Note that some constants (integers, floats and strings) can cause GC or stack-shifts. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static word loadXRc(wic_state *state, int c ARG_LD) { IOSTREAM *fd = state->wicFd; word xr; int id = 0; /* make gcc happy! */ switch( c ) { case XR_REF: { unsigned int xr = getUInt(fd); DEBUG(MSG_QLF_XR, Sdprintf("Reuse XR(%d)\n", (long)xr)); word val = lookupXrId(state, xr); return val; } case XR_NIL: return ATOM_nil; case XR_CONS: return ATOM_dot; case XR_ATOM: { id = ++state->XR->id; xr = getAtom(fd, NULL); DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = '%s'\n", id, stringAtom(xr))); break; } case XR_BLOB: { id = ++state->XR->id; xr = getBlob(state PASS_LD); DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = <blob>\n", id)); break; } case XR_BLOB_TYPE: { id = ++state->XR->id; xr = (word)getBlobType(fd); DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = <blob-type>%s", id, ((PL_blob_t*)xr)->name)); break; } case XR_FUNCTOR: { atom_t name; int arity; id = ++state->XR->id; name = loadXR(state); arity = getInt(fd); xr = (word) lookupFunctorDef(name, arity); DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = %s/%d\n", id, stringAtom(name), arity)); break; } case XR_PRED: { functor_t f; Module m; id = ++state->XR->id; f = (functor_t) loadXR(state); m = (Module) loadXR(state); xr = (word) lookupProcedure(f, m); DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = proc %s\n", id, procedureName((Procedure)xr))); break; } case XR_MODULE: { GET_LD atom_t name; id = ++state->XR->id; name = loadXR(state); xr = (word) lookupModule(name); DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = module %s\n", id, stringAtom(name))); break; } case XR_INT: { int64_t i = getInt64(fd); word w; int rc; if ( (rc=put_int64(&w, i, ALLOW_GC PASS_LD)) != TRUE ) { raiseStackOverflow(rc); return 0; } return w; } case XR_FLOAT: { word w; double f = getFloat(fd); int rc; if ( (rc=put_double(&w, f, ALLOW_GC PASS_LD)) != TRUE ) { raiseStackOverflow(rc); return 0; } return w; } #if O_STRING case XR_STRING: { char *s; size_t len; if ( (s = getString(fd, &len)) ) { return globalString(len, s); } else { raiseStackOverflow(GLOBAL_OVERFLOW); return 0; } } case XR_STRING_UTF8: { pl_wchar_t *w; size_t len; pl_wchar_t buf[256]; word s; w = wicGetStringUTF8(fd, &len, buf, sizeof(buf)/sizeof(pl_wchar_t)); s = globalWString(len, w); if ( w != buf ) PL_free(w); return s; } #endif case XR_FILE: { int c; id = ++state->XR->id; switch( (c=Qgetc(fd)) ) { case 'u': case 's': { atom_t name = loadXR(state); double time = getFloat(fd); PL_chars_t text; SourceFile sf; PL_STRINGS_MARK(); get_atom_text(name, &text); PL_mb_text(&text, REP_UTF8); sf = lookupSourceFile(qlfFixSourcePath(state, text.text.t), TRUE); PL_STRINGS_RELEASE(); if ( sf->mtime == 0.0 ) { sf->mtime = time; sf->system = (c == 's' ? TRUE : FALSE); } sf->count++; xr = (word)sf; /* do not release sf; part of state */ break; } case '-': xr = 0; break; default: xr = 0; /* make gcc happy */ fatalError("Illegal XR file index %d: %c", Stell(fd)-1, c); } break; } case XR_NULL: return 0; default: { xr = 0; /* make gcc happy */ fatalError("Illegal XR entry at index %ld: %d", Stell(fd)-1, c); } } storeXrId(state, id, xr); return xr; } static atom_t getBlob(wic_state *state ARG_LD) { PL_blob_t *type = (PL_blob_t*)loadXR(state); if ( type->load ) { return (*type->load)(state->wicFd); } else { return getAtom(state->wicFd, type); } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Returns FALSE while leaving a resource exception if the term cannot be allocated. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static int do_load_qlf_term(wic_state *state, term_t vars[], term_t term ARG_LD) { IOSTREAM *fd = state->wicFd; int c = Qgetc(fd); if ( c == 'v' ) { int id = getInt(fd); if ( vars[id] ) { return PL_unify(term, vars[id]); } else { if ( (vars[id] = PL_new_term_ref()) ) { PL_put_term(vars[id], term); return TRUE; } return FALSE; } } else if ( c == 't' ) { functor_t f; term_t c2; if ( (f = (functor_t) loadXR(state)) && (c2 = PL_new_term_ref()) && PL_unify_functor(term, f) ) { int arity = arityFunctor(f); int n; for(n=0; n < arity; n++) { _PL_get_arg(n+1, term, c2); if ( !do_load_qlf_term(state, vars, c2 PASS_LD) ) return FALSE; } return TRUE; } return FALSE; } else { word w; if ( (w=loadXRc(state, c PASS_LD)) ) return _PL_unify_atomic(term, w); return FALSE; } } static int loadQlfTerm(wic_state *state, term_t term ARG_LD) { IOSTREAM *fd = state->wicFd; int nvars; Word vars; int rc; DEBUG(MSG_QLF_TERM, Sdprintf("Loading from %ld ...", (long)Stell(fd))); if ( (nvars = getInt(fd)) ) { term_t *v; int n; vars = alloca(nvars * sizeof(term_t)); for(n=nvars, v=vars; n>0; n--, v++) *v = 0L; } else vars = NULL; PL_put_variable(term); rc = do_load_qlf_term(state, vars, term PASS_LD); if ( rc ) resortDictsInTerm(term); DEBUG(MSG_QLF_TERM, Sdprintf("Loaded "); PL_write_term(Serror, term, 1200, 0); Sdprintf(" to %ld\n", (long)Stell(fd))); return rc; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load intermediate code state from the specified stream. rcpath contains the ZIP file name. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ int loadWicFromStream(const char *rcpath, IOSTREAM *fd) { wic_state state; int rval; memset(&state, 0, sizeof(state)); state.wicFd = fd; state.wicFile = (char*)rcpath; pushXrIdTable(&state); rval = loadWicFd(&state); popXrIdTable(&state); return rval; } static int loadWicFile(const char *file) { IOSTREAM *fd; int rval; if ( !(fd = Sopen_file(file, "rb" TRACK_POS)) ) { warning("Cannot open Quick Load File %s: %s", file, OsError()); return FALSE; } rval = loadWicFromStream(file, fd); Sclose(fd); return rval; } static bool loadWicFd(wic_state *state) { GET_LD IOSTREAM *fd = state->wicFd; if ( !qlfIsCompatible(state, saveMagic) || !pushPathTranslation(state, systemDefaults.home, PATH_ISDIR) ) return FALSE; for(;;) { int c = Qgetc(fd); switch( c ) { case EOF: case 'T': /* trailer */ popPathTranslation(state); succeed; case 'W': { char *name = store_string(getString(fd, NULL) ); if ( (name=getString(fd, NULL)) ) { name = store_string(name); loadWicFile(name); continue; } else { fatalError("Invalid QLF: bad string"); return FALSE; } } case 'X': break; default: { loadStatement(state, c, FALSE PASS_LD); continue; } } } } static bool loadStatement(wic_state *state, int c, int skip ARG_LD) { IOSTREAM *fd = state->wicFd; switch(c) { case 'P': return loadPredicate(state, skip PASS_LD); case 'O': { word mname = loadXR(state); Module om = LD->modules.source; bool rval; LD->modules.source = lookupModule(mname); rval = loadPredicate(state, skip PASS_LD); LD->modules.source = om; return rval; } case 'I': return loadImport(state, skip PASS_LD); case 'D': { fid_t cid; if ( (cid=PL_open_foreign_frame()) ) { term_t goal = PL_new_term_ref(); atom_t osf = source_file_name; int oln = source_line_no; source_file_name = (state->currentSource ? state->currentSource->name : NULL_ATOM); source_line_no = getInt(fd); if ( !loadQlfTerm(state, goal PASS_LD) ) return FALSE; DEBUG(MSG_QLF_DIRECTIVE, if ( source_file_name ) { Sdprintf("%s:%d: Directive: ", PL_atom_chars(source_file_name), source_line_no); } else { Sdprintf("Directive: "); } PL_write_term(Serror, goal, 1200, PL_WRT_NEWLINE)); if ( !skip ) { if ( !callProlog(MODULE_user, goal, PL_Q_NODEBUG, NULL) ) { if ( !printMessage(ATOM_warning, PL_FUNCTOR_CHARS, "goal_failed", 2, PL_CHARS, "directive", PL_TERM, goal) ) PL_clear_exception(); } } PL_discard_foreign_frame(cid); source_file_name = osf; source_line_no = oln; succeed; } return FALSE; } case 'Q': { bool rc; state->load_nesting++; rc = loadPart(state, NULL, skip PASS_LD); state->load_nesting--; return rc; } case 'M': return loadInModule(state, skip PASS_LD); default: return qlfLoadError(state); } } static void loadPredicateFlags(wic_state *state, Definition def, int skip) { unsigned int flags = getUInt(state->wicFd); if ( !skip ) { unsigned long lflags = 0L; if ( flags & PRED_SYSTEM ) lflags |= P_LOCKED; if ( flags & PRED_HIDE_CHILDS ) lflags |= HIDE_CHILDS; if ( flags & PRED_DET ) lflags |= P_DET; set(def, lflags); } } #ifdef O_GMP static int mp_cpsign(ssize_t hdrsize, int mpsize) { return hdrsize >= 0 ? mpsize : -mpsize; } static void mpz_hdr_size(ssize_t hdrsize, mpz_t mpz, size_t *wszp) { size_t size = hdrsize >= 0 ? hdrsize : -hdrsize; size_t limpsize = (size+sizeof(mp_limb_t)-1)/sizeof(mp_limb_t); size_t wsize = (limpsize*sizeof(mp_limb_t)+sizeof(word)-1)/sizeof(word); mpz->_mp_size = limpsize; mpz->_mp_alloc = limpsize; *wszp = wsize; } static void mpz_load_bits(IOSTREAM *fd, Word p, mpz_t mpz, size_t bytes) { char fast[1024]; char *cbuf; size_t i; if ( bytes < sizeof(fast) ) cbuf = fast; else cbuf = PL_malloc(bytes); for(i=0; i<bytes; i++) cbuf[i] = Qgetc(fd); mpz->_mp_d = (mp_limb_t*)p; mpz_import(mpz, bytes, 1, 1, 1, 0, cbuf); assert((Word)mpz->_mp_d == p); /* check no (re-)allocation is done */ if ( cbuf != fast ) PL_free(cbuf); } #endif /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Label handling - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef struct vm_rlabel { size_t offset; /* location of jump */ size_t soi; /* start of instruction */ unsigned int id; /* label id */ } vm_rlabel; typedef struct vm_rlabel_state { size_t soi; /* offset for start of instruction */ tmp_buffer buf; /* buffer labels */ } vm_rlabel_state; static void init_rlabels(vm_rlabel_state *state) { initBuffer(&state->buf); } static void exit_rlabels(vm_rlabel_state *state) { discardBuffer(&state->buf); } static void push_rlabel(vm_rlabel_state *state, unsigned int id, size_t offset) { vm_rlabel *top = allocFromBuffer(&state->buf, sizeof(*top)); vm_rlabel *bottom = baseBuffer(&state->buf, vm_rlabel); vm_rlabel *prev = top; while(prev > bottom && id > prev[-1].id) prev--; memmove(prev+1, prev, (char*)top - (char*)prev); prev->id = id; prev->soi = state->soi; prev->offset = offset; } static void resolve_rlabel(vm_rlabel_state *state, unsigned int id, Code base, Clause clause) { vm_rlabel *top = topBuffer(&state->buf, vm_rlabel); vm_rlabel *bottom = baseBuffer(&state->buf, vm_rlabel); size_t copy = 0; DEBUG(MSG_QLF_LABEL, Sdprintf("%s: V_LABEL %d\n", predicateName(clause->predicate), id)); for(--top; top >= bottom; top--) { if ( top->id < id ) { copy++; continue; } if ( top->id == id ) { Code pc = &base[top->soi]; size_t jmp; pc = stepPC(pc); /* end of instruction */ assert(base[top->offset] == (code)id); jmp = &base[state->soi] - pc; base[top->offset] = jmp; DEBUG(MSG_QLF_LABEL, Sdprintf(" Put %d at %zd\n", (int)jmp, top->offset)); continue; } if ( top->id > id ) { top++; if ( copy ) { vm_rlabel *cptop = topBuffer(&state->buf, vm_rlabel); size_t cpsize = copy*sizeof(*cptop); memmove(top, cptop - copy, cpsize); state->buf.top = (char*)(top+copy); } else { state->buf.top = (char*)top; } break; } } } static void loadClauseFlags(wic_state *state, Clause cl, int skip) { unsigned int flags = getUInt(state->wicFd); if ( !skip ) { unsigned int lflags = 0; if ( (flags&CLAUSE_UNIT_CLAUSE) ) lflags |= UNIT_CLAUSE; if ( (flags&CLAUSE_SSU_COMMIT) ) lflags |= SSU_COMMIT_CLAUSE; if ( (flags&CLAUSE_SSU_CHOICE) ) lflags |= SSU_CHOICE_CLAUSE; cl->flags = lflags; } } static bool loadPredicate(wic_state *state, int skip ARG_LD) { IOSTREAM *fd = state->wicFd; Procedure proc; Definition def; Clause clause; functor_t f = (functor_t) loadXR(state); SourceFile csf = NULL; proc = lookupProcedureToDefine(f, LD->modules.source); DEBUG(MSG_QLF_PREDICATE, Sdprintf("Loading %s%s", procedureName(proc), skip ? " (skip)" : "")); def = proc->definition; if ( !skip && state->currentSource ) { if ( def->impl.any.defined ) { if ( !redefineProcedure(proc, state->currentSource, DISCONTIGUOUS_STYLE) ) { int rc = printMessage(ATOM_error, exception_term); (void)rc; PL_clear_exception(); skip = TRUE; } } addProcedureSourceFile(state->currentSource, proc); } loadPredicateFlags(state, def, skip); for(;;) { switch(Qgetc(fd) ) { case 'X': { DEBUG(MSG_QLF_PREDICATE, Sdprintf("ok\n")); succeed; } case 'C': { int has_dicts = 0; tmp_buffer buf; vm_rlabel_state lstate; DEBUG(MSG_QLF_PREDICATE, Sdprintf(".")); initBuffer(&buf); init_rlabels(&lstate); clause = (Clause)allocFromBuffer(&buf, sizeofClause(0)); clause->references = 0; clause->tr_erased_no = 0; clause->line_no = getUInt(fd); { SourceFile of = (void *) loadXR(state); SourceFile sf = (void *) loadXR(state); unsigned int ono = (of ? of->index : 0); unsigned int sno = (sf ? sf->index : 0); if ( sf ) { acquireSourceFile(sf); if ( of != sf ) acquireSourceFile(of); } clause->owner_no = ono; clause->source_no = sno; if ( of && of != csf ) { addProcedureSourceFile(sf, proc); csf = of; } } clause->prolog_vars = (unsigned short) getUInt(fd); clause->variables = (unsigned short) getUInt(fd); loadClauseFlags(state, clause, skip); clause->predicate = def; #define addCode(c) addBuffer(&buf, (c), code) for(;;) { code op = getUInt(fd); const char *ats; int n = 0; lstate.soi = entriesBuffer(&buf, code); switch(op) { case V_LABEL: { unsigned lbl = getUInt(fd); resolve_rlabel(&lstate, lbl, baseBuffer(&buf, code), baseBuffer(&buf, struct clause)); continue; } case V_H_INTEGER: case V_B_INTEGER: { int64_t val = getInt64(fd); word w = consInt(val); if ( valInt(w) == val ) { addCode(encode(op==V_H_INTEGER ? H_SMALLINT : B_SMALLINT)); addCode(w); #if SIZEOF_VOIDP == 8 } else { addCode(encode(op==V_H_INTEGER ? H_INTEGER : B_INTEGER)); addCode((intptr_t)val); } #else } else if ( val >= INTPTR_MIN && val <= INTPTR_MAX ) { addCode(encode(op==V_H_INTEGER ? H_INTEGER : B_INTEGER)); addCode((intptr_t)val); } else { addCode(encode(op==V_H_INTEGER ? H_INT64 : B_INT64)); addMultipleBuffer(&buf, (char*)&val, sizeof(int64_t), char); } #endif continue; } case V_A_INTEGER: { int64_t val = getInt64(fd); #if SIZEOF_VOIDP == 8 addCode(encode(A_INTEGER)); addCode((intptr_t)val); #else if ( val >= INTPTR_MIN && val <= INTPTR_MAX ) { addCode(encode(A_INTEGER)); addCode((intptr_t)val); } else { addCode(encode(A_INT64)); addMultipleBuffer(&buf, (char*)&val, sizeof(int64_t), char); } #endif continue; } } if ( op >= I_HIGHEST ) fatalError("Illegal op-code (%d) at %ld", op, Stell(fd)); ats = codeTable[op].argtype; DEBUG(MSG_QLF_VMI, Sdprintf("\t%s from %ld\n", codeTable[op].name, Stell(fd))); if ( op == I_CONTEXT ) { clause = baseBuffer(&buf, struct clause); set(clause, CL_BODY_CONTEXT); set(def, P_MFCONTEXT); } addCode(encode(op)); DEBUG(0, { const char ca1_float[2] = {CA1_FLOAT}; const char ca1_int64[2] = {CA1_INT64}; assert(codeTable[op].arguments == VM_DYNARGC || (size_t)codeTable[op].arguments == strlen(ats) || (streq(ats, ca1_float) && codeTable[op].arguments == WORDS_PER_DOUBLE) || (streq(ats, ca1_int64) && codeTable[op].arguments == WORDS_PER_INT64)); }); for(n=0; ats[n]; n++) { switch(ats[n]) { case CA1_PROC: { addCode(loadXR(state)); break; } case CA1_FUNC: { word w = loadXR(state); FunctorDef fd = valueFunctor(w); if ( fd->name == ATOM_dict ) has_dicts++; addCode(w); break; } case CA1_DATA: { word w = loadXR(state); if ( isAtom(w) ) PL_register_atom(w); addCode(w); break; } case CA1_AFUNC: { word f = loadXR(state); int i = indexArithFunction(f); assert(i>0); addCode(i); break; } case CA1_MODULE: addCode(loadXR(state)); break; case CA1_JUMP: { unsigned lbl = getUInt(fd); size_t off = entriesBuffer(&buf, code); addCode(lbl); push_rlabel(&lstate, lbl, off); break; } case CA1_INTEGER: addCode((code)getInt64(fd)); break; case CA1_VAR: case CA1_FVAR: case CA1_CHP: addCode((code)OFFSET_VAR(getInt64(fd))); break; case CA1_INT64: { int64_t val = getInt64(fd); addMultipleBuffer(&buf, (char*)&val, sizeof(int64_t), char); break; } case CA1_FLOAT: { double f = getFloat(fd); addMultipleBuffer(&buf, (char*)&f, sizeof(double), char); break; } case CA1_STRING: /* <n> chars */ { size_t l = getInt(fd); int c0 = Qgetc(fd); if ( c0 == 'B' ) { int lw = (l+sizeof(word))/sizeof(word); int pad = (lw*sizeof(word) - l); Code bp; char *s; DEBUG(MSG_QLF_VMI, Sdprintf("String of %ld bytes\n", l)); bp = allocFromBuffer(&buf, sizeof(word)*(lw+1)); s = (char *)&bp[1]; *bp = mkStrHdr(lw, pad); bp += lw; *bp++ = 0L; *s++ = 'B'; l--; while(l-- > 0) *s++ = Qgetc(fd); } else { size_t i; size_t bs = (l+1)*sizeof(pl_wchar_t); size_t lw = (bs+sizeof(word))/sizeof(word); int pad = (lw*sizeof(word) - bs); word m = mkStrHdr(lw, pad); IOENC oenc = fd->encoding; DEBUG(MSG_QLF_VMI, Sdprintf("Wide string of %zd chars; lw=%zd; pad=%d\n", l, lw, pad)); assert(c0 == 'W'); addCode(m); /* The header */ addBuffer(&buf, 'W', char); for(i=1; i<sizeof(pl_wchar_t); i++) addBuffer(&buf, 0, char); fd->encoding = ENC_UTF8; for(i=0; i<l; i++) { int code = Sgetcode(fd); pl_wchar_t c = code; if ( (int)c != code ) { state->errors.invalid_wide_chars++; c = UTF8_MALFORMED_REPLACEMENT; } addBuffer(&buf, c, pl_wchar_t); } fd->encoding = oenc; for(i=0; i<pad; i++) addBuffer(&buf, 0, char); } break; } case CA1_MPZ: #ifdef O_GMP #define ABS(x) ((x) >= 0 ? (x) : -(x)) DEBUG(MSG_QLF_VMI, Sdprintf("Loading MPZ from %ld\n", Stell(fd))); { ssize_t hdrsize = getInt64(fd); size_t wsize; mpz_t mpz; word m; Word p; mpz_hdr_size(hdrsize, mpz, &wsize); m = mkIndHdr(wsize+1, TAG_INTEGER); p = allocFromBuffer(&buf, sizeof(word)*(wsize+2)); *p++ = m; p[wsize] = 0; *p++ = mpz_size_stack(mp_cpsign(hdrsize, mpz->_mp_size)); p[wsize] = 0; mpz_load_bits(fd, p, mpz, ABS(hdrsize)); DEBUG(MSG_QLF_VMI, Sdprintf("Loaded MPZ to %ld\n", Stell(fd))); break; } case CA1_MPQ: DEBUG(MSG_QLF_VMI, Sdprintf("Loading MPQ from %ld\n", Stell(fd))); { ssize_t num_hdrsize = getInt64(fd); ssize_t den_hdrsize = getInt64(fd); size_t wsize, num_wsize, den_wsize; mpz_t num; mpz_t den; word m; Word p; mpz_hdr_size(num_hdrsize, num, &num_wsize); mpz_hdr_size(den_hdrsize, den, &den_wsize); wsize = num_wsize + den_wsize; m = mkIndHdr(wsize+2, TAG_INTEGER); p = allocFromBuffer(&buf, sizeof(word)*(wsize+3)); *p++ = m; *p++ = mpq_size_stack(mp_cpsign(num_hdrsize, num->_mp_size)); *p++ = mpq_size_stack(mp_cpsign(den_hdrsize, den->_mp_size)); p[num_wsize] = 0; mpz_load_bits(fd, p, num, ABS(num_hdrsize)); p += num_wsize; p[den_wsize] = 0; mpz_load_bits(fd, p, den, ABS(den_hdrsize)); DEBUG(MSG_QLF_VMI, Sdprintf("Loaded MPQ to %ld\n", Stell(fd))); break; } #else fatalError("No support for MPZ numbers"); #endif default: fatalError("No support for VM argtype %d (arg %d of %s)", ats[n], n, codeTable[op].name); } } switch(op) { case I_EXITFACT: case I_EXIT: /* fact */ goto done; } } done: exit_rlabels(&lstate); if ( !skip ) { size_t csize = sizeOfBuffer(&buf); size_t ncodes = (csize-sizeofClause(0))/sizeof(code); Clause bcl = baseBuffer(&buf, struct clause); bcl->code_size = ncodes; clause = (Clause)PL_malloc_atomic(csize); memcpy(clause, bcl, csize); if ( has_dicts ) { if ( !resortDictsInClause(clause) ) { outOfCore(); exit(1); } } if ( csf ) csf->current_procedure = proc; GD->statistics.codes += clause->code_size; assertProcedureSource(csf, proc, clause PASS_LD); } discardBuffer(&buf); } } } } static bool runInitialization(SourceFile sf) { int rc = FALSE; if ( sf ) { GET_LD fid_t fid = PL_open_foreign_frame(); term_t av = PL_new_term_refs(2); static predicate_t pred = NULL; if ( !pred ) pred = PL_predicate("$run_initialization", 2, "system"); PL_put_atom(av+0, sf->name); PL_put_nil( av+1); rc = PL_call_predicate(MODULE_system, PL_Q_NORMAL, pred, av); PL_discard_foreign_frame(fid); } return rc; } static bool loadImport(wic_state *state, int skip ARG_LD) { Procedure proc = (Procedure) loadXR(state); int flags = getInt(state->wicFd); if ( !skip ) return importDefinitionModule(LD->modules.source, proc->definition, flags); succeed; } static atom_t qlfFixSourcePath(wic_state *state, const char *raw) { char buf[MAXPATHLEN]; char *canonical; if ( state->load_state->has_moved && strprefix(raw, state->load_state->save_dir) ) { char *s; size_t lensave = strlen(state->load_state->save_dir); const char *tail = &raw[lensave]; if ( strlen(state->load_state->load_dir)+1+strlen(tail)+1 > MAXPATHLEN ) fatalError("Path name too long: %s", raw); strcpy(buf, state->load_state->load_dir); s = &buf[strlen(buf)]; strcpy(s, tail); } else { if ( strlen(raw)+1 > MAXPATHLEN ) { fatalError("Path name too long: %s", raw); return NULL_ATOM; } strcpy(buf, raw); } if ( (canonical=canonicalisePath(buf)) ) { atom_t translated = file_name_to_atom(canonical); if ( strcmp(raw, canonical) ) { path_translated *tr = PL_malloc(sizeof(*tr)); tr->from = file_name_to_atom(raw); tr->to = translated; tr->next = state->load_state->translated; state->load_state->translated = tr; } return translated; } else { fatalError("Path name too long: %s", buf); return NULL_ATOM; } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (**) Note. When loading a qlf file we must do the possible reconsult stuff associated with loading sourcefiles. If we are loading a state all is nice and fresh, so we can skip that. Actually, we *must* skip that as a state is created based on modules rather than files. Multifile predicates are stored with the module. If we take no measures loading the file from which a clause originates will remove the one loaded with the module where it is a multifile one. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static bool qlfLoadSource(wic_state *state) { IOSTREAM *fd = state->wicFd; char *str = getString(fd, NULL); double time = getFloat(fd); int issys = (Qgetc(fd) == 's') ? TRUE : FALSE; atom_t fname; if ( !str ) { fatalError("Invalid QLF: illegal string"); return FALSE; } fname = qlfFixSourcePath(state, str); DEBUG(MSG_QLF_PATH, if ( !streq(stringAtom(fname), str) ) Sdprintf("Replaced path %s --> %s\n", str, stringAtom(fname))); state->currentSource = lookupSourceFile(fname, TRUE); PL_unregister_atom(fname); /* locked with sourceFile */ state->currentSource->mtime = time; state->currentSource->system = issys; if ( GD->bootsession ) /* (**) */ state->currentSource->count++; else startConsult(state->currentSource); succeed; } static bool loadModuleProperties(wic_state *state, Module m, int skip ARG_LD) { IOSTREAM *fd = state->wicFd; if ( !skip ) clearSupersModule(m); for(;;) { switch(Qgetc(fd)) { case 'C': { atom_t cname = loadXR(state); if ( !skip ) m->class = cname; continue; } case 'S': { atom_t sname = loadXR(state); Module s = lookupModule(sname); if ( !skip ) addSuperModule(m, s, 'Z'); continue; } case 'E': { functor_t f = (functor_t) loadXR(state); if ( !skip ) { Procedure proc = lookupProcedure(f, LD->modules.source); addNewHTable(LD->modules.source->public, (void *)f, proc); if ( state->currentSource ) exportProcedureSource(state->currentSource, m, proc); } else { if ( !lookupHTable(m->public, (void *)f) ) { FunctorDef fd = valueFunctor(f); warning("%s: skipped module \"%s\" lacks %s/%d", state->wicFile, stringAtom(m->name), stringAtom(fd->name), fd->arity); } } continue; } case 'X': break; default: return qlfLoadError(state); } break; } succeed; } static bool loadPart(wic_state *state, Module *module, int skip ARG_LD) { IOSTREAM *fd = state->wicFd; Module om = LD->modules.source; SourceFile of = state->currentSource; int stchk = debugstatus.styleCheck; access_level_t alevel = LD->prolog_flag.access_level; switch(Qgetc(fd)) { case 'M': { atom_t mname = loadXR(state); int c = Qgetc(fd); DEBUG(MSG_QLF_SECTION, Sdprintf("Loading module %s\n", PL_atom_chars(mname))); switch( c ) { case '-': { LD->modules.source = lookupModule(mname); /* TBD: clear module? */ DEBUG(MSG_QLF_SECTION, Sdprintf("\tNo source\n")); break; } case 'F': { Module m; int line; qlfLoadSource(state); line = getInt(fd); DEBUG(MSG_QLF_SECTION, Sdprintf("\tSource = %s:%d\n", PL_atom_chars(state->currentSource->name), line)); m = lookupModule(mname); if ( m->file && m->file != state->currentSource ) { warning("%s:\n\tmodule \"%s\" already loaded from \"%s\" (skipped)", state->wicFile, stringAtom(m->name), stringAtom(m->file->name)); skip = TRUE; LD->modules.source = m; } else { if ( !declareModule(mname, NULL_ATOM, NULL_ATOM, state->currentSource, line, FALSE) ) fail; } if ( module ) *module = LD->modules.source; break; } default: qlfLoadError(state); break; } if ( !loadModuleProperties(state, LD->modules.source, skip PASS_LD) ) fail; break; } case 'F': { qlfLoadSource(state); if ( module ) *module = NULL; break; } default: return qlfLoadError(state); } for(;;) { int c = Qgetc(fd); switch(c) { case 'X': { if ( !GD->bootsession ) { runInitialization(state->currentSource); if ( state->currentSource ) endConsult(state->currentSource); } LD->modules.source = om; state->currentSource = of; debugstatus.styleCheck = stchk; setAccessLevel(alevel); succeed; } default: loadStatement(state, c, skip PASS_LD); } } } static bool loadInModule(wic_state *state, int skip ARG_LD) { IOSTREAM *fd = state->wicFd; word mname = loadXR(state); Module om = LD->modules.source; LD->modules.source = lookupModule(mname); for(;;) { int c = Qgetc(fd); switch(c) { case 'X': { LD->modules.source = om; succeed; } default: loadStatement(state, c, skip PASS_LD); } } } static bool loadInclude(wic_state *state ARG_LD) { IOSTREAM *fd = state->wicFd; atom_t owner, pn, fn; int line; double time; fid_t fid = PL_open_foreign_frame(); term_t t = PL_new_term_ref(); sourceloc loc; owner = loadXR(state); pn = loadXR(state); line = getInt(fd); fn = loadXR(state); time = getFloat(fd); if ( !PL_unify_term(t, PL_FUNCTOR, FUNCTOR_colon2, PL_ATOM, ATOM_system, PL_FUNCTOR_CHARS, "$included", 4, PL_ATOM, pn, PL_INT, line, PL_ATOM, fn, PL_FLOAT, time) ) return FALSE; loc.file = pn; loc.line = line; assert_term(t, NULL, CL_END, owner, &loc, 0 PASS_LD); PL_discard_foreign_frame(fid); return TRUE; } /******************************* * WRITING .QLF FILES * *******************************/ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The code below handles the creation of `wic' files. It offers a number of predicates which enables us to write the compilation toplevel in Prolog. Note that we keep track of the `current procedure' to keep all clauses of a predicate together. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define STR_NOLEN ((size_t)-1) static void putString(const char *s, size_t len, IOSTREAM *fd) { const char *e; if ( len == STR_NOLEN ) len = strlen(s); e = &s[len]; putInt64(len, fd); while(s<e) { Sputc(*s, fd); s++; } } static void putStringW(const pl_wchar_t *s, size_t len, IOSTREAM *fd) { const pl_wchar_t *e; IOENC oenc = fd->encoding; if ( len == STR_NOLEN ) len = wcslen(s); e = &s[len]; putInt64(len, fd); fd->encoding = ENC_UTF8; while(s<e) { Sputcode(*s, fd); s++; } fd->encoding = oenc; } static void putAtom(wic_state *state, atom_t w) { GET_LD IOSTREAM *fd = state->wicFd; atom_t mapped; Atom a; static PL_blob_t *text_blob; if ( state->idMap && (mapped = (atom_t)lookupHTable(state->idMap, (void*)w)) ) { assert(isAtom(mapped)); w = mapped; } if ( !text_blob ) text_blob = PL_find_blob_type("text"); a = atomValue(w); if ( a->type != text_blob ) { Sputc(XR_BLOB, fd); saveXRBlobType(state, a->type); if ( a->type->save ) { (*a->type->save)(a->atom, fd); } else { putString(a->name, a->length, fd); } } else { Sputc(XR_ATOM, fd); putString(a->name, a->length, fd); } } static void putInt64(int64_t n, IOSTREAM *fd) { uint64_t i = zigzag_encode(n); do { int b = i&0x7f; i >>= 7; if ( !i ) b |= 0x80; Sputc(b, fd); } while ( i ); } static void putUInt(unsigned int i, IOSTREAM *fd) { do { int b = i&0x7f; i >>= 7; if ( !i ) b |= 0x80; Sputc(b, fd); } while ( i ); } static void putFloat(double f, IOSTREAM *fd) { unsigned char *cl = (unsigned char *)&f; unsigned int i; DEBUG(MSG_QLF_FLOAT, Sdprintf("putFloat(%f)\n", f)); for(i=0; i<BYTES_PER_DOUBLE; i++) Sputc(cl[double_byte_order[i]], fd); } static void putInt32(int v, IOSTREAM *fd) { Sputc((v>>24)&0xff, fd); Sputc((v>>16)&0xff, fd); Sputc((v>>8)&0xff, fd); Sputc(v&0xff, fd); } static void freeXRSymbol(void *name, void *value) { word w = (word)name; if ( w&0x1 ) { w &= ~0x1; if ( isAtom(w) ) { PL_unregister_atom(w); DEBUG(5, Sdprintf("UNREG: %s\n", stringAtom(w))); } } } void initXR(wic_state *state) { state->currentPred = NULL; state->currentSource = NULL; state->savedXRTable = newHTable(256); state->savedXRTable->free_symbol = freeXRSymbol; state->savedXRTableId = 0; } void destroyXR(wic_state *state) { destroyHTable(state->savedXRTable); state->savedXRTable = NULL; if ( state->idMap ) { destroyHTable(state->idMap); state->idMap = NULL; } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - XR (External Reference) table handling. The table contains atoms, functors and various types of pointers (Module, Procedure and SourceFile). For savedXR() to work, atom_t and functor_t may not conflict with pointers. We assume -as in many other places in the code- that pointers are 4-byte aligned. savedXRConstant() must be used for atom_t and functor_t, while savedXRPointer must be used for the pointers. The value for savedXRConstant() is or-ed with 0x1 to avoid conflict with pointers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static int savedXR(wic_state *state, void *xr) { GET_LD IOSTREAM *fd = state->wicFd; unsigned int id; if ( (id = (intptr_t)lookupHTable(state->savedXRTable, xr)) ) { Sputc(XR_REF, fd); putUInt(id, fd); succeed; } else { id = ++state->savedXRTableId; addNewHTable(state->savedXRTable, xr, (void *)(intptr_t)id); } fail; } static inline int savedXRConstant(wic_state *state, word w) { int rc; assert(tag(w) == TAG_ATOM); /* Only functor_t and atom_t */ if ( !(rc=savedXR(state, (void *)(w|0x1))) && isAtom(w) ) { DEBUG(MSG_QLF_XR, Sdprintf("REG: %s\n", stringAtom(w))); PL_register_atom(w); } return rc; } static int XRNullPointer = 0; static inline int savedXRPointer(wic_state *state, void *p) { assert(((word)p & 0x1) == 0); if ( !p ) { return savedXR(state, &XRNullPointer); } return savedXR(state, p); } static void saveXR__LD(wic_state *state, word xr ARG_LD) { IOSTREAM *fd = state->wicFd; if ( isTaggedInt(xr) ) /* TBD: switch */ { Sputc(XR_INT, fd); putInt64(valInt(xr), fd); return; } else if ( isBignum(xr) ) { Sputc(XR_INT, fd); putInt64(valBignum(xr), fd); return; } else if ( isFloat(xr) ) { Sputc(XR_FLOAT, fd); putFloat(valFloat(xr), fd); return; #if O_STRING } else if ( isString(xr) ) { char *s; pl_wchar_t *w; size_t len; if ( (s = getCharsString(xr, &len)) ) { Sputc(XR_STRING, fd); putString(s, len, fd); } else if ( (w=getCharsWString(xr, &len)) ) { Sputc(XR_STRING_UTF8, fd); putStringW(w, len, fd); } return; #endif /* O_STRING */ } if ( xr == ATOM_nil ) { Sputc(XR_NIL, fd); return; } if ( xr == ATOM_dot ) { Sputc(XR_CONS, fd); return; } if ( savedXRConstant(state, xr) ) return; if ( isAtom(xr) ) { DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = '%s'\n", state->savedXRTableId, stringAtom(xr))); putAtom(state, xr); return; } assert(0); } #define saveXR(state, xr) saveXR__LD(state, xr PASS_LD) static void saveXRBlobType(wic_state *state, PL_blob_t *type) { IOSTREAM *fd = state->wicFd; if ( savedXRPointer(state, type) ) return; Sputc(XR_BLOB_TYPE, fd); putString(type->name, STR_NOLEN, fd); } static void saveXRModule(wic_state *state, Module m ARG_LD) { IOSTREAM *fd = state->wicFd; if ( !m ) { Sputc(XR_NULL, fd); return; } if ( savedXRPointer(state, m) ) return; Sputc(XR_MODULE, fd); DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = module %s\n", state->savedXRTableId, stringAtom(m->name))); saveXR(state, m->name); } static void saveXRFunctor(wic_state *state, functor_t f ARG_LD) { IOSTREAM *fd = state->wicFd; FunctorDef fdef; functor_t mapped; if ( savedXRConstant(state, f) ) return; if ( state->idMap && (mapped = (functor_t)lookupHTable(state->idMap, (void*)f)) ) f = mapped; fdef = valueFunctor(f); DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = %s/%d\n", state->savedXRTableId, stringAtom(fdef->name), fdef->arity)); Sputc(XR_FUNCTOR, fd); saveXR(state, fdef->name); putInt64(fdef->arity, fd); } static void saveXRProc(wic_state *state, Procedure p ARG_LD) { IOSTREAM *fd = state->wicFd; if ( savedXRPointer(state, p) ) return; DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = proc %s\n", state->savedXRTableId, procedureName(p))); Sputc(XR_PRED, fd); saveXRFunctor(state, p->definition->functor->functor PASS_LD); saveXRModule(state, p->definition->module PASS_LD); } static void saveXRSourceFile(wic_state *state, SourceFile f ARG_LD) { IOSTREAM *fd = state->wicFd; if ( savedXRPointer(state, f) ) return; Sputc(XR_FILE, fd); if ( f ) { DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = file %s\n", state->savedXRTableId, stringAtom(f->name))); Sputc(f->system ? 's' : 'u', fd); saveXR(state, f->name); putFloat(f->mtime, fd); } else { DEBUG(MSG_QLF_XR, Sdprintf("XR(%d) = <no file>\n", state->savedXRTableId)); Sputc('-', fd); } } static void do_save_qlf_term(wic_state *state, Word t ARG_LD) { IOSTREAM *fd = state->wicFd; deRef(t); if ( isTerm(*t) ) { functor_t f = functorTerm(*t); if ( f == FUNCTOR_dvard1 ) { int id = (int)valInt(argTerm(*t, 0)); Sputc('v', fd); putInt64(id, fd); } else { Word q = argTermP(*t, 0); int n, arity = arityFunctor(f); Sputc('t', fd); saveXRFunctor(state, f PASS_LD); for(n=0; n < arity; n++, q++) do_save_qlf_term(state, q PASS_LD); } } else { assert(isAtomic(*t)); saveXR(state, *t); } } static int saveQlfTerm(wic_state *state, term_t t ARG_LD) { IOSTREAM *fd = state->wicFd; intptr_t nvars, rc=TRUE; fid_t cid; nv_options options; cid = PL_open_foreign_frame(); DEBUG(MSG_QLF_TERM, Sdprintf("Saving "); PL_write_term(Serror, t, 1200, 0); Sdprintf(" from %d ... ", Stell(fd))); options.functor = FUNCTOR_dvard1; options.on_attvar = AV_SKIP; options.singletons = FALSE; /* TBD: TRUE may be better! */ options.numbered_check = TRUE; /* otherwise may be wrong */ if ( (nvars = numberVars(t, &options, 0 PASS_LD)) != NV_ERROR ) { putInt64(nvars, fd); do_save_qlf_term(state, valTermRef(t) PASS_LD); /* TBD */ DEBUG(MSG_QLF_TERM, Sdprintf("to %d\n", Stell(fd))); } else { rc = FALSE; } PL_discard_foreign_frame(cid); return rc; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Label handling - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ typedef struct vm_wlabel { Code address; unsigned int id; } vm_wlabel; typedef struct vm_wlabel_state { tmp_buffer buf; vm_wlabel current; unsigned int next_id; } vm_wlabel_state; static void init_wlabels(vm_wlabel_state *state) { initBuffer(&state->buf); state->current.address = NULL; state->next_id = 0; } static void exit_wlabels(vm_wlabel_state *state) { assert(entriesBuffer(&state->buf, vm_wlabel) == 0); discardBuffer(&state->buf); } static vm_wlabel * push_wlabel(vm_wlabel_state *state, Code to, Clause clause) { vm_wlabel *lbl; if ( state->current.address ) { if ( to == state->current.address ) { lbl = &state->current; } else if ( to < state->current.address ) { addBuffer(&state->buf, state->current, vm_wlabel); state->current.address = to; state->current.id = ++state->next_id; lbl = &state->current; } else { vm_wlabel *top = allocFromBuffer(&state->buf, sizeof(*top)); vm_wlabel *bottom = baseBuffer(&state->buf, vm_wlabel); vm_wlabel *prev = top; while(prev > bottom && to > prev[-1].address) prev--; if ( prev > bottom && prev[-1].address == to ) { (void)popBuffer(&state->buf, vm_wlabel); lbl = &prev[-1]; } else { memmove(prev+1, prev, (char*)top - (char*)prev); prev->address = to; prev->id = ++state->next_id; lbl = prev; } } } else { state->current.address = to; state->current.id = ++state->next_id; lbl = &state->current; } DEBUG(MSG_QLF_LABEL, { Sdprintf("%s, clause %d: current: %d at %p\n", predicateName(clause->predicate), clauseNo(clause, 0), state->current.id, state->current.address); vm_wlabel *top = topBuffer(&state->buf, vm_wlabel); vm_wlabel *bottom = baseBuffer(&state->buf, vm_wlabel); for(--top; top >= bottom; top--) Sdprintf(" %d at %p\n", top->id, top->address); }); return lbl; } static void emit_wlabels(vm_wlabel_state *state, Code here, IOSTREAM *fd) { while(state->current.address == here) { putUInt(V_LABEL, fd); putUInt(state->current.id, fd); if ( entriesBuffer(&state->buf, vm_wlabel) != 0 ) state->current = popBuffer(&state->buf, vm_wlabel); else state->current.address = NULL; } } #ifdef O_GMP static void put_mpz_size(IOSTREAM *fd, mpz_t mpz, size_t *szp) { size_t size = (mpz_sizeinbase(mpz, 2)+7)/8; ssize_t hdrsize; if ( mpz_sgn(mpz) < 0 ) hdrsize = -(ssize_t)size; else hdrsize = (ssize_t)size; *szp = size; putInt64(hdrsize, fd); } static void put_mpz_bits(IOSTREAM *fd, mpz_t mpz, size_t size) { size_t i, count; char fast[1024]; char *buf; if ( size < sizeof(fast) ) buf = fast; else buf = PL_malloc(size); mpz_export(buf, &count, 1, 1, 1, 0, mpz); assert(count == size); for(i=0; i<count; i++) Sputc(buf[i]&0xff, fd); if ( buf != fast ) PL_free(buf); } #endif static unsigned int clauseFlags(const Clause clause) { unsigned int flags = 0; if ( true(clause, UNIT_CLAUSE) ) flags |= CLAUSE_UNIT_CLAUSE; if ( true(clause, SSU_COMMIT_CLAUSE) ) flags |= CLAUSE_SSU_COMMIT; if ( true(clause, SSU_CHOICE_CLAUSE) ) flags |= CLAUSE_SSU_CHOICE; return flags; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - saveWicClause() saves a clause to the .qlf file. For predicate references of I_CALL and I_DEPART, we cannot store the predicate itself as this would lead to an inconsistency if the .qlf file is loaded into another context module. Therefore we just store the functor. For now this is ok as constructs of the form module:goal are translated using the meta-call mechanism. This needs consideration if we optimise this (which is not that likely as I think module:goal, where `module' is an atom, should be restricted to very special cases and toplevel interaction. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void saveWicClause(wic_state *state, Clause clause) { GET_LD IOSTREAM *fd = state->wicFd; Code bp, ep; vm_wlabel_state lstate; Sputc('C', fd); putUInt(state->obfuscate ? 0 : clause->line_no, fd); saveXRSourceFile(state, state->obfuscate ? NULL : indexToSourceFile(clause->owner_no) PASS_LD); saveXRSourceFile(state, state->obfuscate ? NULL : indexToSourceFile(clause->source_no) PASS_LD); putUInt(clause->prolog_vars, fd); putUInt(clause->variables, fd); putUInt(clauseFlags(clause), fd); bp = clause->codes; ep = bp + clause->code_size; init_wlabels(&lstate); while( bp < ep ) { Code si = bp; /* start instruction */ unsigned int op = decode(*bp++); const char *ats = codeTable[op].argtype; int n; emit_wlabels(&lstate, si, fd); switch(op) { { int64_t v; case H_SMALLINT: v = valInt(*bp++); goto vh_int; #if SIZEOF_VOIDP == 4 case H_INT64: { Word p = (Word)&v; cpInt64Data(p, bp); goto vh_int; } #endif case H_INTEGER: v = (intptr_t)*bp++; vh_int: putUInt(V_H_INTEGER, fd); putInt64(v, fd); continue; } { int64_t v; case B_SMALLINT: v = valInt(*bp++); goto vb_int; #if SIZEOF_VOIDP == 4 case B_INT64: { Word p = (Word)&v; cpInt64Data(p, bp); goto vb_int; } #endif case B_INTEGER: v = (intptr_t)*bp++; vb_int: putUInt(V_B_INTEGER, fd); putInt64(v, fd); continue; } { int64_t v; #if SIZEOF_VOIDP == 4 case A_INT64: { Word p = (Word)&v; cpInt64Data(p, bp); goto va_int; } #endif case A_INTEGER: v = (intptr_t)*bp++; #if SIZEOF_VOIDP == 4 va_int: #endif putUInt(V_A_INTEGER, fd); putInt64(v, fd); continue; } } putUInt(op, fd); DEBUG(MSG_QLF_VMI, Sdprintf("\t%s at %ld\n", codeTable[op].name, Stell(fd))); for(n=0; ats[n]; n++) { switch(ats[n]) { case CA1_PROC: { Procedure p = (Procedure) *bp++; saveXRProc(state, p PASS_LD); break; } case CA1_MODULE: { Module m = (Module) *bp++; /* can be NULL, see I_CALLATMV */ saveXRModule(state, m PASS_LD); break; } case CA1_FUNC: { functor_t f = (functor_t) *bp++; saveXRFunctor(state, f PASS_LD); break; } case CA1_AFUNC: { functor_t f = functorArithFunction((unsigned int)*bp++); saveXRFunctor(state, f PASS_LD); break; } case CA1_DATA: { word xr = (word) *bp++; saveXR(state, xr); break; } case CA1_JUMP: { Code to = stepPC(si) + *bp++; vm_wlabel *lbl = push_wlabel(&lstate, to, clause); putUInt(lbl->id, fd); break; } case CA1_INTEGER: { putInt64(*bp++, fd); break; } case CA1_VAR: case CA1_FVAR: case CA1_CHP: { intptr_t var = *bp++; putInt64(VAR_OFFSET(var), fd); break; } case CA1_INT64: { int64_t val; Word p = (Word)&val; cpInt64Data(p, bp); putInt64(val, fd); break; } case CA1_FLOAT: { union { word w[WORDS_PER_DOUBLE]; double f; } v; Word p = v.w; cpDoubleData(p, bp); putFloat(v.f, fd); break; } case CA1_STRING: { word m = *bp; char *s = (char *)++bp; size_t wn = wsizeofInd(m); size_t l = wn*sizeof(word) - padHdr(m); bp += wn; if ( *s == 'B' ) { putInt64(l, fd); while( l-- > 0 ) Sputc(*s++&0xff, fd); } else { pl_wchar_t *w = (pl_wchar_t*)s + 1; IOENC oenc = fd->encoding; assert(*s == 'W'); l /= sizeof(pl_wchar_t); l--; putInt64(l, fd); Sputc('W', fd); fd->encoding = ENC_UTF8; for( ; l-- > 0; w++) { Sputcode(*w, fd); } fd->encoding = oenc; } break; } #ifdef O_GMP case CA1_MPZ: { mpz_t mpz; size_t size; bp = get_mpz_from_code(bp, mpz); put_mpz_size(fd, mpz, &size); put_mpz_bits(fd, mpz, size); DEBUG(MSG_QLF_VMI, Sdprintf("Saved MPZ to %ld\n", Stell(fd))); break; } case CA1_MPQ: { mpq_t mpq; size_t num_size; size_t den_size; bp = get_mpq_from_code(bp, mpq); put_mpz_size(fd, mpq_numref(mpq), &num_size); put_mpz_size(fd, mpq_denref(mpq), &den_size); put_mpz_bits(fd, mpq_numref(mpq), num_size); put_mpz_bits(fd, mpq_denref(mpq), den_size); DEBUG(MSG_QLF_VMI, Sdprintf("Saved MPQ to %ld\n", Stell(fd))); break; } #endif default: fatalError("No support for VM argtype %d (arg %d of %s)", ats[n], n, codeTable[op].name); } } } exit_wlabels(&lstate); } /******************************** * COMPILATION * *********************************/ static void closePredicateWic(wic_state *state) { if ( state->currentPred ) { Sputc('X', state->wicFd); state->currentPred = NULL; } } static unsigned int predicateFlags(Definition def, atom_t sclass) { unsigned int flags = 0; if ( sclass == ATOM_kernel ) { if ( true(def, P_LOCKED) && false(def, HIDE_CHILDS) ) return PRED_SYSTEM; return (PRED_SYSTEM|PRED_HIDE_CHILDS); } if ( true(def, P_LOCKED) ) flags |= PRED_SYSTEM; if ( true(def, HIDE_CHILDS) ) flags |= PRED_HIDE_CHILDS; if ( true(def, P_DET) ) flags |= PRED_DET; return flags; } static void openPredicateWic(wic_state *state, Definition def, atom_t sclass ARG_LD) { if ( def != state->currentPred) { IOSTREAM *fd = state->wicFd; unsigned int mode = predicateFlags(def, sclass); closePredicateWic(state); state->currentPred = def; if ( def->module != LD->modules.source ) { Sputc('O', fd); saveXR(state, def->module->name); } else { Sputc('P', fd); } saveXRFunctor(state, def->functor->functor PASS_LD); putUInt(mode, fd); } } static bool putMagic(const char *s, IOSTREAM *fd) { for(; *s; s++) Sputc(*s, fd); Sputc(EOS, fd); succeed; } static bool writeWicHeader(wic_state *state) { IOSTREAM *fd = state->wicFd; putMagic(saveMagic, fd); putInt64(PL_QLF_VERSION, fd); putInt64(VM_SIGNATURE, fd); if ( systemDefaults.home ) putString(systemDefaults.home, STR_NOLEN, fd); else putString("<no home>", STR_NOLEN, fd); initXR(state); DEBUG(MSG_QLF_SECTION, Sdprintf("Header complete ...\n")); succeed; } static bool writeWicTrailer(wic_state *state) { IOSTREAM *fd = state->wicFd; closePredicateWic(state); Sputc('X', fd); destroyXR(state); Sputc('T', fd); state->wicFd = NULL; if ( state->wicFile ) { remove_string(state->wicFile); state->wicFile = NULL; } succeed; } /* FIXME: Deal with owner/real location in saved state */ static bool addClauseWic(wic_state *state, term_t term, atom_t file ARG_LD) { Clause clause; sourceloc loc; loc.file = file; loc.line = source_line_no; if ( (clause = assert_term(term, NULL, CL_END, file, &loc, 0 PASS_LD)) ) { openPredicateWic(state, clause->predicate, ATOM_development PASS_LD); saveWicClause(state, clause); succeed; } Sdprintf("Failed to compile: "); pl_write(term); Sdprintf("\n"); fail; } static bool addDirectiveWic(wic_state *state, term_t term ARG_LD) { IOSTREAM *fd = state->wicFd; closePredicateWic(state); Sputc('D', fd); putInt64(source_line_no, fd); return saveQlfTerm(state, term PASS_LD); } static bool importWic(wic_state *state, Procedure proc, atom_t strength ARG_LD) { int flags = atomToImportStrength(strength); assert(flags >= 0); closePredicateWic(state); Sputc('I', state->wicFd); saveXRProc(state, proc PASS_LD); putInt64(flags, state->wicFd); succeed; } /******************************* * PART MARKS * *******************************/ static void initSourceMarks(wic_state *state) { state->has_source_marks = TRUE; state->source_mark_head = NULL; state->source_mark_tail = NULL; } static void sourceMark(wic_state *state) { if ( state->has_source_marks ) { SourceMark pm = allocHeapOrHalt(sizeof(struct source_mark)); pm->file_index = Stell(state->wicFd); pm->next = NULL; if ( state->source_mark_tail ) { state->source_mark_tail->next = pm; state->source_mark_tail = pm; } else { state->source_mark_tail = pm; state->source_mark_head = pm; } } } static int writeSourceMarks(wic_state *state) { long n = 0; SourceMark pn, pm = state->source_mark_head; DEBUG(MSG_QLF_SECTION, Sdprintf("Writing source marks: ")); for( ; pm; pm = pn ) { pn = pm->next; DEBUG(MSG_QLF_SECTION, Sdprintf(" %d", pm->file_index)); putInt32(pm->file_index, state->wicFd); freeHeap(pm, sizeof(*pm)); n++; } state->source_mark_head = state->source_mark_tail = NULL; DEBUG(MSG_QLF_SECTION, Sdprintf("\nWritten %d marks\n", n)); putInt32(n, state->wicFd); return 0; } /* Raise an error of the format error(qlf_format_error(File, Message), _) */ static int qlfError(wic_state *state, const char *error, ...) { va_list args; char message[LINESIZ]; int rc; const char *file = state->wicFile; if ( !file ) file = "<unknown>"; va_start(args, error); Svsnprintf(message, sizeof(message), error, args); va_end(args); if ( GD->bootsession ) { fatalError("%s: %s", file, message); rc = FALSE; /* keep compiler happy */ exit(1); } else { GET_LD term_t ex, fn; rc = ( (ex=PL_new_term_ref()) && (fn=PL_new_term_ref()) && PL_unify_chars(fn, PL_ATOM|REP_FN, (size_t)-1, file) && PL_unify_term(ex, PL_FUNCTOR, FUNCTOR_error2, PL_FUNCTOR_CHARS, "qlf_format_error", 2, PL_TERM, fn, PL_CHARS, message, PL_VARIABLE) && PL_raise_exception(ex) ); } return rc; } static int qlfSourceInfo(wic_state *state, size_t offset, term_t list ARG_LD) { IOSTREAM *s = state->wicFd; char *str; term_t head = PL_new_term_ref(); atom_t fname; if ( Sseek(s, (long)offset, SIO_SEEK_SET) != 0 ) return qlfError(state, "seek to %zd failed: %s", offset, OsError()); if ( Sgetc(s) != 'F' || !(str=getString(s, NULL)) ) return qlfError(state, "invalid string (offset %zd)", offset); fname = qlfFixSourcePath(state, str); return PL_unify_list(list, head, list) && PL_unify_atom(head, fname); } static word qlfInfo(const char *file, term_t cversion, term_t minload, term_t fversion, term_t csig, term_t fsig, term_t files0 ARG_LD) { IOSTREAM *s = NULL; int lversion; int nqlf, i; size_t *qlfstart = NULL; word rval = FALSE; term_t files = PL_copy_term_ref(files0); wic_state state; memset(&state, 0, sizeof(state)); state.wicFile = (char*)file; if ( !(s = Sopen_file(file, "rbr")) ) { term_t f = PL_new_term_ref(); PL_put_atom_chars(f, file); return PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION, ATOM_open, ATOM_source_sink, f); } state.wicFd = s; if ( cversion ) { int vm_signature; if ( !PL_unify_integer(cversion, PL_QLF_VERSION) || !PL_unify_integer(minload, PL_QLF_LOADVERSION) || !PL_unify_integer(csig, (int)VM_SIGNATURE) ) goto out; if ( !qlfVersion(&state, qlfMagic, &lversion) || !PL_unify_integer(fversion, lversion) ) goto out; vm_signature = getInt(s); /* TBD: provide to Prolog layer */ if ( !PL_unify_integer(fsig, vm_signature) ) goto out; } else { if ( !qlfIsCompatible(&state, qlfMagic) ) goto out; } if ( !pushPathTranslation(&state, file, 0) ) goto out; if ( Sseek(s, -4, SIO_SEEK_END) < 0 ) /* 4 bytes of PutInt32() */ { qlfError(&state, "seek to index failed: %s", OsError()); goto out; } if ( (nqlf = getInt32(s)) < 0 ) { qlfError(&state, "invalid number of files (%d)", nqlf); goto out; } if ( Sseek(s, -4 * (nqlf+1), SIO_SEEK_END) < 0 ) { qlfError(&state, "seek to files failed: %s", OsError()); goto out; } DEBUG(MSG_QLF_SECTION, Sdprintf("Found %d sources at", nqlf)); if ( !(qlfstart = malloc(sizeof(size_t)*nqlf)) ) { PL_no_memory(); goto out; } for(i=0; i<nqlf; i++) { qlfstart[i] = (size_t)getInt32(s); DEBUG(MSG_QLF_SECTION, Sdprintf(" %ld", qlfstart[i])); } DEBUG(MSG_QLF_SECTION, Sdprintf("\n")); for(i=0; i<nqlf; i++) { if ( !qlfSourceInfo(&state, qlfstart[i], files PASS_LD) ) goto out; } rval = PL_unify_nil(files); out: popPathTranslation(&state); if ( qlfstart ) free(qlfstart); if ( s ) Sclose(s); return rval; } /** '$qlf_info'(+File, -CurrentVersion, -MinLOadVersion, -FileVersion, -CurrentSignature, -FileSignature, -Files) Provide information about a QLF file. @arg CurrentVersion is the current save version @arg FileVersion is the version of the file @arg CurrentSignature is the current VM signature @arg FileSignature is the signature of the file @arg Files is a list of atoms representing the files used to create the QLF */ static PRED_IMPL("$qlf_info", 7, qlf_info, 0) { PRED_LD char *name; if ( !PL_get_file_name(A1, &name, PL_FILE_ABSOLUTE) ) fail; return qlfInfo(name, A2, A3, A4, A5, A6, A8 PASS_LD); } static PRED_IMPL("$qlf_sources", 2, qlf_sources, 0) { PRED_LD char *name; if ( !PL_get_file_name(A1, &name, PL_FILE_ABSOLUTE) ) fail; return qlfInfo(name, 0, 0, 0, 0, 0, A2 PASS_LD); } /******************************* * NEW MODULE SUPPORT * *******************************/ static wic_state * qlfOpen(term_t file) { char *name; char *absname; char tmp[MAXPATHLEN]; IOSTREAM *out; wic_state *state; if ( !PL_get_file_name(file, &name, 0) || !(absname = AbsoluteFile(name, tmp)) ) return NULL; if ( !(out = Sopen_file(name, "wb" TRACK_POS)) ) { PL_error(NULL, 0, NULL, ERR_PERMISSION, ATOM_write, ATOM_file, file); return NULL; } state = allocHeapOrHalt(sizeof(*state)); memset(state, 0, sizeof(*state)); state->wicFile = store_string(name); state->mkWicFile = store_string(name); state->wicFd = out; initXR(state); initSourceMarks(state); putMagic(qlfMagic, state->wicFd); putInt64(PL_QLF_VERSION, state->wicFd); putInt64(VM_SIGNATURE, state->wicFd); putString(absname, STR_NOLEN, state->wicFd); return state; } static bool qlfClose(wic_state *state ARG_LD) { int rc; closePredicateWic(state); writeSourceMarks(state); rc = Sclose(state->wicFd); state->wicFd = NULL; if ( state->mkWicFile ) { remove_string(state->mkWicFile); state->mkWicFile = NULL; } destroyXR(state); LD->qlf.current_state = state->parent; freeHeap(state, sizeof(*state)); return rc == 0; } static int qlfVersion(wic_state *state, const char *exp_magic, int *vp) { IOSTREAM *s = state->wicFd; char mbuf[100]; char *magic; if ( !(magic = getMagicString(s, mbuf, sizeof(mbuf))) || !streq(magic, exp_magic) ) return qlfError(state, "Not a %s", exp_magic); *vp = getInt(s); return TRUE; } static int pushPathTranslation(wic_state *state, const char *absloadname, int flags) { IOSTREAM *fd = state->wicFd; char *abssavename; qlf_state *new = allocHeapOrHalt(sizeof(*new)); memset(new, 0, sizeof(*new)); new->previous = state->load_state; state->load_state = new; if ( !(abssavename = getString(fd, NULL)) ) return qlfError(state, "bad string"); if ( absloadname && !streq(absloadname, abssavename) ) { char load[MAXPATHLEN]; char save[MAXPATHLEN]; char *l, *s, *le, *se; if ( ( strlen(abssavename)+1 > MAXPATHLEN || strlen(absloadname)+1 > MAXPATHLEN ) ) return PL_representation_error("max_path_length"); new->has_moved = TRUE; if ( (flags & PATH_ISDIR) ) { l = strcpy(load, absloadname); s = strcpy(save, abssavename); } else { l = DirName(absloadname, load); s = DirName(abssavename, save); } le = l+strlen(l); se = s+strlen(s); for( ;le>l && se>s && le[-1] == se[-1]; le--, se--) { if ( le[-1] == '/' ) { *le = EOS; *se = EOS; } } new->load_dir = store_string(l); new->save_dir = store_string(s); DEBUG(MSG_QLF_PATH, Sdprintf("QLF file has moved; replacing %s --> %s\n", state->load_state->save_dir, state->load_state->load_dir)); } return TRUE; } static void popPathTranslation(wic_state *state) { if ( state->load_state ) { qlf_state *old = state->load_state; state->load_state = old->previous; if ( old->has_moved ) { path_translated *tr; remove_string(old->load_dir); remove_string(old->save_dir); if ( (tr=old->translated) ) { GET_LD path_translated *n; static predicate_t pred = NULL; fid_t fid = PL_open_foreign_frame(); term_t av = PL_new_term_refs(2); if ( !pred ) pred = PL_predicate("$translated_source", 2, "system"); for(; tr; tr=n) { n = tr->next; PL_put_atom(av+0, tr->from); PL_put_atom(av+1, tr->to); PL_unregister_atom(tr->from); if ( !PL_call_predicate(NULL, PL_Q_NORMAL, pred, av) ) Sdprintf("$translated_source/2 failed~n"); PL_free(tr); } PL_discard_foreign_frame(fid); } } freeHeap(old, sizeof(*old)); } } static int qlfIsCompatible(wic_state *state, const char *magic) { int lversion; int vm_signature; if ( !qlfVersion(state, magic, &lversion) ) return FALSE; if ( lversion < PL_QLF_LOADVERSION ) return qlfError(state, "incompatible version (file: %d, Prolog: %d)", lversion, PL_QLF_VERSION); state->saved_version = lversion; vm_signature = getInt(state->wicFd); if ( vm_signature != (int)VM_SIGNATURE ) return qlfError(state, "incompatible VM-signature (file: 0x%x; Prolog: 0x%x)", (unsigned int)vm_signature, (unsigned int)VM_SIGNATURE); return TRUE; } static bool qlfLoad(wic_state *state, Module *module ARG_LD) { IOSTREAM *fd = state->wicFd; bool rval; const char *absloadname; char tmp[MAXPATHLEN]; atom_t file; if ( (file = fileNameStream(fd)) ) { PL_chars_t text; if ( !get_atom_text(file, &text) ) fail; if ( !PL_mb_text(&text, REP_FN) ) { PL_free_text(&text); fail; } state->wicFile = store_string(text.text.t); if ( !(absloadname = AbsoluteFile(state->wicFile, tmp)) ) fail; PL_free_text(&text); } else { absloadname = NULL; } if ( !qlfIsCompatible(state, qlfMagic) ) return FALSE; if ( !pushPathTranslation(state, absloadname, 0) ) return FALSE; pushXrIdTable(state); for(;;) { int c = Qgetc(fd); switch(c) { case 'Q': break; case 'I': loadInclude(state PASS_LD); continue; default: qlfLoadError(state); } break; } rval = loadPart(state, module, FALSE PASS_LD); popXrIdTable(state); popPathTranslation(state); if ( state->errors.invalid_wide_chars ) Sdprintf("WARNING: %d wide characters could not be represented as UCS-2\n", state->errors.invalid_wide_chars); return rval; } static bool qlfSaveSource(wic_state *state, SourceFile f) { GET_LD IOSTREAM *fd = state->wicFd; PL_chars_t text; PL_STRINGS_MARK(); get_atom_text(f->name, &text); PL_mb_text(&text, REP_UTF8); sourceMark(state); Sputc('F', fd); putString(text.text.t, text.length, fd); putFloat(f->mtime, fd); Sputc(f->system ? 's' : 'u', fd); PL_STRINGS_RELEASE(); state->currentSource = f; succeed; } static bool qlfStartModule(wic_state *state, Module m ARG_LD) { IOSTREAM *fd = state->wicFd; ListCell c; closePredicateWic(state); Sputc('Q', fd); Sputc('M', fd); saveXR(state, m->name); if ( m->file ) { qlfSaveSource(state, m->file); putInt64(m->line_no, fd); } else { Sputc('-', fd); } Sputc('C', fd); saveXR(state, m->class); for(c=m->supers; c; c=c->next) { Module s = c->value; Sputc('S', fd); saveXR(state, s->name); } DEBUG(MSG_QLF_SECTION, Sdprintf("MODULE %s\n", stringAtom(m->name))); for_table(m->public, name, value, { functor_t f = (functor_t)name; DEBUG(MSG_QLF_EXPORT, Sdprintf("Exported %s/%d\n", stringAtom(nameFunctor(f)), arityFunctor(f))); Sputc('E', fd); saveXRFunctor(state, f PASS_LD); }) Sputc('X', fd); succeed; } static bool qlfStartSubModule(wic_state *state, Module m ARG_LD) { IOSTREAM *fd = state->wicFd; closePredicateWic(state); Sputc('M', fd); saveXR(state, m->name); succeed; } static bool qlfStartFile(wic_state *state, SourceFile f) { IOSTREAM *fd = state->wicFd; closePredicateWic(state); Sputc('Q', fd); qlfSaveSource(state, f); succeed; } static bool qlfEndPart(wic_state *state) { IOSTREAM *fd = state->wicFd; closePredicateWic(state); Sputc('X', fd); succeed; } /** '$qlf_start_module'(+Module) Start emitting a module. */ static PRED_IMPL("$qlf_start_module", 1, qlf_start_module, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { Module m; if ( !PL_get_module_ex(A1, &m) ) fail; return qlfStartModule(state, m PASS_LD); } succeed; } static PRED_IMPL("$qlf_start_sub_module", 1, qlf_start_sub_module, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { Module m; if ( !PL_get_module_ex(A1, &m) ) fail; return qlfStartSubModule(state, m PASS_LD); } succeed; } static PRED_IMPL("$qlf_start_file", 1, qlf_start_file, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { atom_t a; if ( !PL_get_atom_ex(A1, &a) ) fail; return qlfStartFile(state, lookupSourceFile(a, TRUE)); } succeed; } static PRED_IMPL("$qlf_current_source", 1, qlf_current_source, 0) { PRED_LD wic_state *state; SourceFile sf; if ( (state=LD->qlf.current_state) && (sf = state->currentSource) ) { return PL_unify_atom(A1, sf->name); } return FALSE; } static PRED_IMPL("$qlf_include", 5, qlf_include, 0) { PRED_LD atom_t owner, pn, fn; int line; double time; wic_state *state; if ( PL_get_atom_ex(A1, &owner) && PL_get_atom_ex(A2, &pn) && PL_get_integer_ex(A3, &line) && PL_get_atom_ex(A4, &fn) && PL_get_float(A5, &time) && (state=LD->qlf.current_state) ) { IOSTREAM *fd = state->wicFd; Sputc('I', fd); saveXR(state, owner); saveXR(state, pn); putInt64(line, fd); saveXR(state, fn); putFloat(time, fd); return TRUE; } return FALSE; } static PRED_IMPL("$qlf_end_part", 0, qlf_end_part, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { return qlfEndPart(state); } succeed; } static PRED_IMPL("$qlf_open", 1, qlf_open, 0) { PRED_LD wic_state *state = qlfOpen(A1); if ( state ) { state->parent = LD->qlf.current_state; LD->qlf.current_state = state; return TRUE; } return FALSE; } static PRED_IMPL("$qlf_close", 0, qlf_close, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) return qlfClose(state PASS_LD); succeed; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $qlf_load(:Stream, -ModuleOut) Load QLF data from Stream. @param ModuleOut is unified to an atom holding the name of the loaded module or the integer 0 if the loaded object is not a module. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static PRED_IMPL("$qlf_load", 2, qlf_load, PL_FA_TRANSPARENT) { GET_LD term_t qstream = A1; term_t module = A2; Module m, oldsrc = LD->modules.source; bool rval; term_t stream = PL_new_term_ref(); IOSTREAM *fd; IOENC saved_enc; wic_state state; m = oldsrc; if ( !PL_strip_module(qstream, &m, stream) ) fail; if ( !PL_get_stream_handle(stream, &fd) ) fail; memset(&state, 0, sizeof(state)); state.wicFd = fd; saved_enc = fd->encoding; fd->encoding = ENC_OCTET; LD->modules.source = m; rval = qlfLoad(&state, &m PASS_LD); LD->modules.source = oldsrc; fd->encoding = saved_enc; if ( state.wicFile ) remove_string(state.wicFile); PL_release_stream(fd); if ( rval ) { if ( m ) return PL_unify_atom(module, m->name); return PL_unify_integer(module, 0); } fail; } /******************************** * PROLOG SUPPORT * *********************************/ /** '$open_wic'(+Stream) is det. Write a header for a QLF-stream */ static const opt_spec open_wic_options[] = { { ATOM_obfuscate, OPT_BOOL }, { NULL_ATOM, 0 } }; static PRED_IMPL("$open_wic", 2, open_wic, 0) { GET_LD IOSTREAM *fd; int obfuscate = FALSE; assert(V_LABEL > I_HIGHEST); if ( !scan_options(A2, 0, ATOM_state_option, open_wic_options, &obfuscate) ) fail; if ( PL_get_stream_handle(A1, &fd) ) { wic_state *state = allocHeapOrHalt(sizeof(*state)); memset(state, 0, sizeof(*state)); state->obfuscate = obfuscate; state->wicFd = fd; writeWicHeader(state); state->parent = LD->qlf.current_state; LD->qlf.current_state = state; succeed; } fail; /* PL_get_stream_handle() */ /* throws exception */ } static PRED_IMPL("$close_wic", 0, close_wic, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { writeWicTrailer(state); LD->qlf.current_state = state->parent; freeHeap(state, sizeof(*state)); succeed; } fail; } static void freeMapping(void *name, void *value) { word id_from = (word)name; word id_to = (word)value; if ( isAtom(id_from) ) PL_unregister_atom(id_from); if ( isAtom(id_to) ) PL_unregister_atom(id_to); } static int get_id(term_t t, void **id) { GET_LD atom_t a; functor_t f; if ( PL_get_atom(t, &a) ) { *id = (void *)a; } else if ( PL_get_functor(t, &f) ) { if ( f == FUNCTOR_colon2 ) { Procedure proc; if ( get_procedure(t, &proc, 0, GP_FINDHERE|GP_EXISTENCE_ERROR) ) { *id = (void *)proc->definition; } else { return FALSE; } } *id = (void *)f; } else { return PL_type_error("identifier", t); } return TRUE; } /** '$map_id'(+IdFrom, +IdTo) is det. Add a mapping between an identifier when saving a state. @arg IdFrom, IdTo are either atoms or compound terms. In the latter case the functor is mapped. */ static PRED_IMPL("$map_id", 2, map_id, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { void *id_from, *id_to, *old; if ( !get_id(A1, &id_from) || !get_id(A2, &id_to) ) return FALSE; if ( (isAtom((word)id_from) && !isAtom((word)id_to)) || (isFunctor((word)id_from) && !isFunctor((word)id_to)) ) return PL_permission_error("map", "identifier", A1); if ( !state->idMap ) { state->idMap = newHTable(256); state->idMap->free_symbol = freeMapping; } if ( (old=lookupHTable(state->idMap, id_from)) ) { if ( old == id_to ) return TRUE; else return PL_permission_error("map", "identifier", A1); } else { addNewHTable(state->idMap, id_from, id_to); if ( isAtom((word)id_from) ) { PL_register_atom((atom_t)id_from); PL_register_atom((atom_t)id_to); } return TRUE; } } else { return PL_permission_error("map", "identifier", A1); } } static PRED_IMPL("$unmap_id", 1, unmap_id, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { void *id_from; if ( !get_id(A1, &id_from) ) return FALSE; if ( state->idMap ) deleteHTable(state->idMap, id_from); } return TRUE; } static PRED_IMPL("$add_directive_wic", 1, add_directive_wic, PL_FA_TRANSPARENT) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { Module m = MODULE_system; term_t term = PL_new_term_ref(); term_t qterm = PL_new_term_ref(); if ( !PL_strip_module(A1, &m, term) ) return FALSE; if ( !(PL_is_callable(term)) ) return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_callable, A1); if ( !PL_unify_term(qterm, PL_FUNCTOR, FUNCTOR_colon2, PL_ATOM, m->name, PL_TERM, term) ) return FALSE; return addDirectiveWic(state, qterm PASS_LD); } succeed; } /** '$import_wic'(+Module, +PredicateIndicator, +Strength) */ static PRED_IMPL("$import_wic", 3, import_wic, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { Module m = NULL; functor_t fd; atom_t strength; if ( !PL_get_module(A1, &m) || !get_functor(A2, &fd, &m, 0, GF_PROCEDURE) || !PL_get_atom_ex(A3, &strength) ) fail; return importWic(state, lookupProcedure(fd, m), strength PASS_LD); } succeed; } /** '$qlf_assert_clause'(+ClauseRef, +Class) is det. */ static PRED_IMPL("$qlf_assert_clause", 2, qlf_assert_clause, 0) { PRED_LD wic_state *state; if ( (state=LD->qlf.current_state) ) { Clause clause; atom_t sclass; if ( (PL_get_clref(A1, &clause) != TRUE) || !PL_get_atom_ex(A2, &sclass) ) fail; openPredicateWic(state, clause->predicate, sclass PASS_LD); saveWicClause(state, clause); } succeed; } /******************************** * BOOTSTRAP COMPILATION * *********************************/ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The code below offers a restricted compilation toplevel used for the bootstrap compilation (-b option). It handles most things the Prolog defined compiler handles as well, except: - Be carefull to define a predicate first before using it as a directive - It does not offer `consult', `ensure_loaded' or the list notation. (there is no way to include other files). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Check whether clause is of the form :- directive. If so, put the directive in directive and succeed. If the term has no explicit module tag, add one from the current source-module. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static int directiveClause(term_t directive, term_t clause, const char *functor) { GET_LD atom_t name; size_t arity; term_t d0 = PL_new_term_ref(); functor_t f; if ( !PL_get_name_arity(clause, &name, &arity) || arity != 1 || !streq(stringAtom(name), functor) ) fail; _PL_get_arg(1, clause, d0); if ( PL_get_functor(d0, &f) && f == FUNCTOR_colon2 ) { PL_put_term(directive, d0); } else { term_t m; if ( !(m = PL_new_term_ref()) ) return FALSE; PL_put_atom(m, LD->modules.source->name); return PL_cons_functor(directive, FUNCTOR_colon2, m, d0); } succeed; } /* Compile an entire file into intermediate code. ** Thu Apr 28 13:44:43 1988 jan@swivax.UUCP (Jan Wielemaker) */ static bool compileFile(wic_state *state, const char *file) { GET_LD char tmp[MAXPATHLEN]; char *path; term_t f = PL_new_term_ref(); SourceFile sf; atom_t nf; DEBUG(MSG_QLF_BOOT, Sdprintf("Boot compilation of %s\n", file)); if ( !(path = AbsoluteFile(file, tmp)) ) fail; DEBUG(MSG_QLF_PATH, Sdprintf("Expanded to %s\n", path)); if ( PL_unify_chars(f, PL_ATOM|REP_MB, (size_t)-1, path) ) PL_get_atom(f, &nf); else fatalError("Could not unify path"); DEBUG(MSG_QLF_BOOT, Sdprintf("Opening\n")); if ( !pl_see(f) ) { Sdprintf("Failed to open %s\n", path); return FALSE; } DEBUG(MSG_QLF_BOOT, Sdprintf("pl_start_consult()\n")); sf = lookupSourceFile(nf, TRUE); startConsult(sf); if ( !LastModifiedFile(path, &sf->mtime) ) Sdprintf("Failed to get time from %s\n", path); qlfStartFile(state, sf); for(;;) { fid_t cid = PL_open_foreign_frame(); term_t t = PL_new_term_ref(); term_t directive = PL_new_term_ref(); atom_t eof; DEBUG(2, Sdprintf("pl_read_clause() -> ")); PL_put_variable(t); if ( !read_clause(Scurin, t, 0 PASS_LD) ) /* syntax error */ { Sdprintf("%s:%d: Syntax error\n", PL_atom_chars(source_file_name), source_line_no); continue; } if ( PL_get_atom(t, &eof) && eof == ATOM_end_of_file ) break; DEBUG(MSG_QLF_BOOT_READ, Sdprintf(""); /* To output line header */ PL_write_term(Serror, t, 1200, PL_WRT_NUMBERVARS); Sdprintf("\n")); if ( directiveClause(directive, t, ":-") ) { DEBUG(MSG_QLF_DIRECTIVE, Sdprintf(":- "); PL_write_term(Serror, directive, 1200, 0); Sdprintf(".\n") ); addDirectiveWic(state, directive PASS_LD); if ( !callProlog(MODULE_user, directive, PL_Q_NODEBUG, NULL) ) Sdprintf("%s:%d: directive failed\n", PL_atom_chars(source_file_name), source_line_no); } else if ( directiveClause(directive, t, "$:-") ) { DEBUG(MSG_QLF_DIRECTIVE, Sdprintf("$:- "); PL_write_term(Serror, directive, 1200, 0); Sdprintf(".\n")); callProlog(MODULE_user, directive, PL_Q_NODEBUG, NULL); } else addClauseWic(state, t, nf PASS_LD); PL_discard_foreign_frame(cid); } qlfEndPart(state); pl_seen(); succeed; } bool compileFileList(IOSTREAM *fd, int argc, char **argv) { GET_LD wic_state *state = allocHeapOrHalt(sizeof(*state)); predicate_t pred; int rc; access_level_t alevel; memset(state, 0, sizeof(*state)); state->wicFd = fd; if ( !writeWicHeader(state) ) return FALSE; alevel = setAccessLevel(ACCESS_LEVEL_SYSTEM); PL_set_prolog_flag("autoload", PL_BOOL, FALSE); LD->qlf.current_state = state; /* make Prolog compilation go into state */ for(;argc > 0; argc--, argv++) { if ( streq(argv[0], "-c" ) ) break; if ( !compileFile(state, argv[0]) ) return FALSE; } PL_set_prolog_flag("autoload", PL_BOOL, TRUE); setAccessLevel(alevel); pred = PL_predicate("$load_additional_boot_files", 0, "user"); rc = PL_call_predicate(MODULE_user, TRUE, pred, 0); if ( rc ) rc = writeWicTrailer(state); LD->qlf.current_state = NULL; freeHeap(state, sizeof(*state)); return rc; } /******************************* * CLEANUP * *******************************/ void qlfCleanup(void) { GET_LD wic_state *state; char *buf; while ( (state=LD->qlf.current_state) ) { if ( state->mkWicFile ) { if ( !printMessage(ATOM_warning, PL_FUNCTOR_CHARS, "qlf", 1, PL_FUNCTOR_CHARS, "removed_after_error", 1, PL_CHARS, state->mkWicFile) ) PL_clear_exception(); RemoveFile(state->mkWicFile); remove_string(state->mkWicFile); state->mkWicFile = NULL; } LD->qlf.current_state = state->parent; freeHeap(state, sizeof(*state)); } if ( (buf=LD->qlf.getstr_buffer) ) { LD->qlf.getstr_buffer = NULL; LD->qlf.getstr_buffer_size = 0; free(buf); } } /******************************* * PUBLIC FUNCTIONS * *******************************/ void wicPutStringW(const pl_wchar_t *w, size_t len, IOSTREAM *fd) { putStringW(w, len, fd); } /******************************* * PUBLISH PREDICATES * *******************************/ BeginPredDefs(wic) PRED_DEF("$qlf_info", 7, qlf_info, 0) PRED_DEF("$qlf_sources", 2, qlf_sources, 0) PRED_DEF("$qlf_load", 2, qlf_load, PL_FA_TRANSPARENT) PRED_DEF("$add_directive_wic", 1, add_directive_wic, PL_FA_TRANSPARENT) PRED_DEF("$qlf_start_module", 1, qlf_start_module, 0) PRED_DEF("$qlf_start_sub_module", 1, qlf_start_sub_module, 0) PRED_DEF("$qlf_start_file", 1, qlf_start_file, 0) PRED_DEF("$qlf_current_source", 1, qlf_current_source, 0) PRED_DEF("$qlf_include", 5, qlf_include, 0) PRED_DEF("$qlf_end_part", 0, qlf_end_part, 0) PRED_DEF("$qlf_open", 1, qlf_open, 0) PRED_DEF("$qlf_close", 0, qlf_close, 0) PRED_DEF("$qlf_assert_clause", 2, qlf_assert_clause, 0) PRED_DEF("$open_wic", 2, open_wic, 0) PRED_DEF("$close_wic", 0, close_wic, 0) PRED_DEF("$map_id", 2, map_id, 0) PRED_DEF("$unmap_id", 1, unmap_id, 0) PRED_DEF("$import_wic", 3, import_wic, 0) EndPredDefs
22.971854
82
0.605261
[ "object" ]
035787eb3b6cfa744a355e81e2153bf9e7c4bbe1
307
h
C
HotTopicForMaintenance/HotTopicForMaintenance/Views/TableViewCells/MyInspectTableViewCell.h
SavorGit/HotTopicForMaintenance
1f19af8b06bc7f926721a6da322671a95a267ed3
[ "Apache-2.0" ]
null
null
null
HotTopicForMaintenance/HotTopicForMaintenance/Views/TableViewCells/MyInspectTableViewCell.h
SavorGit/HotTopicForMaintenance
1f19af8b06bc7f926721a6da322671a95a267ed3
[ "Apache-2.0" ]
null
null
null
HotTopicForMaintenance/HotTopicForMaintenance/Views/TableViewCells/MyInspectTableViewCell.h
SavorGit/HotTopicForMaintenance
1f19af8b06bc7f926721a6da322671a95a267ed3
[ "Apache-2.0" ]
null
null
null
// // MyInspectTableViewCell.h // HotTopicForMaintenance // // Created by 王海朋 on 2018/1/23. // Copyright © 2018年 郭春城. All rights reserved. // #import <UIKit/UIKit.h> #import "MyInspectModel.h" @interface MyInspectTableViewCell : UITableViewCell - (void)configWithModel:(MyInspectModel *)model; @end
18.058824
51
0.732899
[ "model" ]
03578d1d8616c9d6df37422c8401868d6647e42d
27,190
c
C
drivers/input/hidport/kbdhid/kbdhid.c
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
drivers/input/hidport/kbdhid/kbdhid.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
drivers/input/hidport/kbdhid/kbdhid.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*++ Copyright (c) 1996 Microsoft Corporation Module Name: KBDHID.C Abstract: This module contains the init code for the i8042 to hid converter. Note: This is NOT a WDM driver, since it cannot run as a HID mapper on Memphis (Memphis requires that the keyboard to HID mapper be a VXD) and since it uses Event logs, which are not part of WDM 1.0 Environment: Kernel mode Revision History: Nov-96 : created by Kenneth D. Ray Jan-97 : Dan Markarian : Made work May-97 : Kenneth D. Ray : reconstructed as PnP filter for Keyboard class --*/ #include "kbdhid.h" #include "hidclass.h" // // Use the alloc_text pragma to specify the driver initialization routines // (they can be paged out). [DAN] // #ifdef ALLOC_PRAGMA #pragma alloc_text(INIT,DriverEntry) #pragma alloc_text(PAGE,KbdHid_Unload) #endif GLOBALS Globals; NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ) /*++ Routine Description: Installable driver initialization entry point. Arguments: DriverObject - pointer to the driver object RegistryPath - pointer to a unicode string representing the path to driver-specific key in the registry Return Value: NT status code --*/ { NTSTATUS status = STATUS_SUCCESS; PUNICODE_STRING registryPath = &Globals.RegistryPath; Print (DBG_SS_TRACE, ("entering DriverEntry\n")); Print (DBG_SS_INFO, ("Keyboard to hid mapper\n")); RtlZeroMemory (&Globals, sizeof (GLOBALS)); // // Need to ensure that the registry path is null-terminated. // Allocate pool to hold a null-terminated copy of the path. // Safe in paged pool since all registry routines execute at // PASSIVE_LEVEL. // registryPath->MaximumLength = RegistryPath->Length + sizeof(UNICODE_NULL); registryPath->Length = RegistryPath->Length; registryPath->Buffer = ExAllocatePool( PagedPool, registryPath->MaximumLength ); if (!registryPath->Buffer) { Print (DBG_SS_ERROR, ("Initialize: Couldn't allocate pool for registry path.")); status = STATUS_INSUFFICIENT_RESOURCES; goto DriverEntryReject; } RtlZeroMemory (registryPath->Buffer, registryPath->MaximumLength); RtlMoveMemory (registryPath->Buffer, RegistryPath->Buffer, RegistryPath->Length); // // Set up the device driver entry points. // DriverObject->MajorFunction[IRP_MJ_CREATE] = KbdHid_Create; DriverObject->MajorFunction[IRP_MJ_CLOSE] = KbdHid_Close; DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL]=KbdHid_IOCTL; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = KbdHid_PassThrough; DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = KbdHid_Flush; DriverObject->MajorFunction[IRP_MJ_PNP] = KbdHid_PnP; DriverObject->MajorFunction[IRP_MJ_POWER] = KbdHid_Power; DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = KbdHid_SystemControl; DriverObject->DriverUnload = KbdHid_Unload; DriverObject->DriverExtension->AddDevice = KbdHid_AddDevice; Print (DBG_SS_TRACE, ("exit DriverEntry (0x%x) \n", status)); return status; DriverEntryReject: if (registryPath->Buffer) { ExFreePool (registryPath->Buffer); } return status; } NTSTATUS KbdHid_PassThrough ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) /*++ Routine Description: Pass the irp on through --*/ { NTSTATUS status; PDEVICE_EXTENSION data; data = DeviceObject->DeviceExtension; status = IoAcquireRemoveLock (&data->RemoveLock, Irp); if (!NT_SUCCESS (status)) { Irp->IoStatus.Status = status; IoCompleteRequest (Irp, IO_NO_INCREMENT); return status; } IoSkipCurrentIrpStackLocation (Irp); status = IoCallDriver (data->TopOfStack, Irp); IoReleaseRemoveLock (&data->RemoveLock, Irp); return status; } VOID KbdHid_Unload( IN PDRIVER_OBJECT Driver ) /*++ Routine Description: Free all the allocated resources, etc. Arguments: DriverObject - pointer to a driver object Return Value: None --*/ { PAGED_CODE (); ASSERT (NULL == Driver->DeviceObject); Print (DBG_SS_INFO, ("Unload \n")); // // Free resources in device extension. // ExFreePool (Globals.RegistryPath.Buffer); return; } NTSTATUS KbdHid_Flush( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) /*++ Routine Description: Respond to flush requests from the mouse class driver. Currently does nothing but pass IRP down to next lower driver. This routine expects the current IRQL to be < DISPATCH_LEVEL. Arguments: DeviceObject - Pointer to the device object. Irp - Pointer to the request packet. Return Value: NT status code. --*/ { PDEVICE_EXTENSION data; NTSTATUS status; PIO_STACK_LOCATION stack; Print (DBG_CALL_INFO, ("Flush \n")); TRAP(); // // Get a pointer to the device extension. // data = DeviceObject->DeviceExtension; status = IoAcquireRemoveLock (&data->RemoveLock, Irp); if (!NT_SUCCESS (status)) { Irp->IoStatus.Status = status; IoCompleteRequest (Irp, IO_NO_INCREMENT); return status; } // // Send the flush request down to the HID class driver, one for each // of our mouse device context structures. // IoCopyCurrentIrpStackLocationToNext (Irp); stack = IoGetNextIrpStackLocation (Irp); stack->MajorFunction = IRP_MJ_DEVICE_CONTROL; stack->Parameters.DeviceIoControl.IoControlCode = IOCTL_HID_FLUSH_QUEUE; // // Fire and forget // status = IoCallDriver (data->TopOfStack, Irp); IoReleaseRemoveLock (&data->RemoveLock, Irp); return status; } NTSTATUS KbdHid_IOCTL ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) /*++ Routine Description: Respond to queries from the mouse class driver. The IOCTLs for DISABLE, ENABLE, and QUERY_ATTRIBUTES, expect the current IRQL to be < DISPATCH_LEVEL. Arguments: DeviceObject - Pointer to the device object. Irp - Pointer to the request packet. Return Value: NT status code. --*/ { PIO_STACK_LOCATION stack; NTSTATUS status = STATUS_SUCCESS; PDEVICE_EXTENSION data; ULONG length; PKEYBOARD_INDICATOR_TRANSLATION translation; BOOLEAN completeIt = TRUE; data = DeviceObject->DeviceExtension; Irp->IoStatus.Information = 0; stack = IoGetCurrentIrpStackLocation (Irp); status = IoAcquireRemoveLock (&data->RemoveLock, Irp); if (!NT_SUCCESS (status)) { Irp->IoStatus.Status = status; IoCompleteRequest (Irp, IO_NO_INCREMENT); return status; } ASSERT (data->Started || (IOCTL_INTERNAL_KEYBOARD_CONNECT == stack->Parameters.DeviceIoControl.IoControlCode)); switch (stack->Parameters.DeviceIoControl.IoControlCode) { case IOCTL_INTERNAL_KEYBOARD_CONNECT: // // Connect a keyboard class device driver to the port driver. // Print (DBG_IOCTL_TRACE, ("enter Connect \n")); // // Connect a mouse class device driver to the filter driver. // Only allow one connection. // if (NULL != data->ConnectData.ClassService) { Print (DBG_IOCTL_ERROR, ("ERROR: Multiple connects \n")); TRAP (); status = STATUS_SHARING_VIOLATION; break; } else if (stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA)) { Print (DBG_IOCTL_ERROR, ("ERROR: Invalid connect parameter size. \n")); TRAP (); status = STATUS_INVALID_PARAMETER; break; } // // Copy the connection parameters to the device extension. // data->ConnectData = *(PCONNECT_DATA) stack->Parameters.DeviceIoControl.Type3InputBuffer; status = STATUS_SUCCESS; break; case IOCTL_INTERNAL_KEYBOARD_DISCONNECT: // // Disconnect a keyboard class device driver from the port driver. // Print (DBG_IOCTL_TRACE, ("Disconnect \n")); // // Not implemented. // // To implement, code the following: // --------------------------------- // o ENSURE that we are NOT enabled (mouHidDeviceExt->EnableCount); // o If we are, then (a) return STATUS_UNSUCCESSFUL, or // (b) disable all devices immediately; see // DISABLE IOCTL call for necessary code. // o SYNCHRONIZE with the mouse read completion routine (must // protect the callback pointer from being dereferenced when // it becomes null). Note that no mechanism currently exists // for this. // o CLEAR the connection parameters in the device extension; // ie. mouHidDeviceExt->MouClassObject = NULL; // mouHidDeviceExt->MouClassCallback = NULL; // o RELEASE the synchronizing lock. // o RETURN STATUS_SUCCESS. // status = STATUS_NOT_IMPLEMENTED; break; case IOCTL_INTERNAL_KEYBOARD_ENABLE: // // Enable keyboard interrupts which really means start the ping pong // down to hid class. // Print (DBG_IOCTL_ERROR, ("ERROR: PnP => use create not enable! \n")); status = STATUS_NOT_SUPPORTED; break; case IOCTL_INTERNAL_KEYBOARD_DISABLE: // // Disable keyboard interrupts which really means stop the ping pongs // down to hid class. // Print (DBG_IOCTL_ERROR, ("ERROR: PnP => use close not Disable! \n")); status = STATUS_NOT_SUPPORTED; break; case IOCTL_KEYBOARD_QUERY_ATTRIBUTES: // // Query the keyboard attributes. First check for adequate buffer // length. Then, copy the keyboard attributes from the first device // context to the output buffer. [DAN] // Print (DBG_IOCTL_TRACE, ("Query Attributes \n")); if (stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_ATTRIBUTES)) { Print (DBG_IOCTL_ERROR, ("ERROR: Query Attributes buffer too small \n")); status = STATUS_BUFFER_TOO_SMALL; } else { // // Copy the keyboard attributes to the buffer. // *(PKEYBOARD_ATTRIBUTES) Irp->AssociatedIrp.SystemBuffer = data->Attributes; Irp->IoStatus.Information = sizeof (KEYBOARD_ATTRIBUTES); status = STATUS_SUCCESS; } break; case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION: // // Query the scan code to indicator-light mapping. Validate the // parameters, and copy the indicator mapping information from // the static translation list to the SystemBuffer. // Print (DBG_IOCTL_TRACE, ("Query Indicator Translation \n")); length = sizeof(KEYBOARD_INDICATOR_TRANSLATION) + (sizeof(INDICATOR_LIST) * (HID_KEYBOARD_NUMBER_OF_INDICATORS - 1)); if (stack->Parameters.DeviceIoControl.OutputBufferLength < length) { status = STATUS_BUFFER_TOO_SMALL; break; } // // Copy the indicator mapping information to the system // buffer. // translation = ((PKEYBOARD_INDICATOR_TRANSLATION) Irp->AssociatedIrp.SystemBuffer); translation->NumberOfIndicatorKeys = HID_KEYBOARD_NUMBER_OF_INDICATORS; RtlMoveMemory(translation->IndicatorList, (PCHAR) IndicatorList, length - FIELD_OFFSET (KEYBOARD_INDICATOR_TRANSLATION, IndicatorList)); Irp->IoStatus.Information = length; status = STATUS_SUCCESS; break; case IOCTL_KEYBOARD_QUERY_INDICATORS: // // Query the keyboard indicators. Validate the parameters, and // copy the indicator information from the device context to // the SystemBuffer. [DAN] // Print (DBG_IOCTL_TRACE, ("Query Indicators \n")); if (stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_INDICATOR_PARAMETERS)) { status = STATUS_BUFFER_TOO_SMALL; break; } // // Copy the keyboard indicators to the buffer. // // // Don't bother to synchronize access to the device context // KeyboardIndicators field while copying it. We don't care // if another process is setting the LEDs. // // Copy the keyboard indicators to the buffer. *(PKEYBOARD_INDICATOR_PARAMETERS) Irp->AssociatedIrp.SystemBuffer = data->Indicators; Irp->IoStatus.Information = sizeof(KEYBOARD_INDICATOR_PARAMETERS); status = STATUS_SUCCESS; break; case IOCTL_KEYBOARD_SET_INDICATORS: // // Set the keyboard indicators for all known device contexts. [DAN] // Print (DBG_IOCTL_TRACE, ("Set Indicators \n")); if (stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KEYBOARD_INDICATOR_PARAMETERS)) { Print (DBG_IOCTL_ERROR, ("ERROR: Set Indicators size!\n")); status = STATUS_INVALID_PARAMETER; break; } status = KbdHid_SetLedIndicators ( data, (PKEYBOARD_INDICATOR_PARAMETERS) Irp->AssociatedIrp.SystemBuffer, Irp); completeIt = FALSE; break; case IOCTL_KEYBOARD_QUERY_TYPEMATIC: // // Query the current keyboard typematic rate and delay. Validate // the parameters, and copy the typematic information from the port // device extension to the SystemBuffer. [DAN] // Print (DBG_IOCTL_TRACE, ("Query Typematic \n")); if (stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_TYPEMATIC_PARAMETERS)) { Print (DBG_IOCTL_ERROR, ("ERROR: query typematic size!\n")); status = STATUS_BUFFER_TOO_SMALL; break; } // // Copy the keyboard typematic info to the buffer. // // // Don't bother to synchronize access to the device context // KeyboardTypematic field while copying it. We don't care // if another process is setting the typematic info. // *(PKEYBOARD_TYPEMATIC_PARAMETERS) Irp->AssociatedIrp.SystemBuffer = data->Typematic; Irp->IoStatus.Information = sizeof(KEYBOARD_TYPEMATIC_PARAMETERS); status = STATUS_SUCCESS; break; case IOCTL_KEYBOARD_SET_TYPEMATIC: // // Set the keyboard typematic rate and delay for all known device // contexts. [DAN] // Print (DBG_IOCTL_TRACE, ("Set Typematic \n")); if (stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KEYBOARD_TYPEMATIC_PARAMETERS)) { Print (DBG_IOCTL_ERROR, ("ERROR: Set Typematic size\n")); status = STATUS_INVALID_PARAMETER; break; } #define NewTypematic ((PKEYBOARD_TYPEMATIC_PARAMETERS) \ Irp->AssociatedIrp.SystemBuffer) if ((NewTypematic->Rate == 0) && (NewTypematic->Delay == 0)) { break; } if ((NewTypematic->Rate < data->Attributes.KeyRepeatMinimum.Rate) || (NewTypematic->Rate > data->Attributes.KeyRepeatMaximum.Rate) || (NewTypematic->Delay < data->Attributes.KeyRepeatMinimum.Delay) || (NewTypematic->Delay > data->Attributes.KeyRepeatMaximum.Delay)) { Print (DBG_IOCTL_ERROR, ("ERROR: Set Typematic range\n")); status = STATUS_INVALID_PARAMETER; break; } Print (DBG_IOCTL_INFO, ("Set Typematic Rate: %d Delay: %d\n", NewTypematic->Rate, NewTypematic->Delay)); // // Don't bother to synchronize access to the device context // KeyboardTypematic field while copying it. We don't care // if another thread is reading the typematic info. // // Note the only danger here is in setting the 64-bit integer // "AutoRepeatDelay" in two non-atomic statements. However, // we are safe since we never set "HighPart" to anything but // -1. // data->Typematic = *NewTypematic; data->AutoRepeatRate = 1000 / NewTypematic->Rate; // ms data->AutoRepeatDelay.LowPart = -NewTypematic->Delay*10000; // 100ns data->AutoRepeatDelay.HighPart = -1; break; #undef NewTypematic default: Print (DBG_IOCTL_ERROR, ("ERROR: unknown IOCTL: 0x%x \n", stack->Parameters.DeviceIoControl.IoControlCode)); status = STATUS_INVALID_DEVICE_REQUEST; break; } if (completeIt) { Irp->IoStatus.Status = status; IoCompleteRequest(Irp, IO_NO_INCREMENT); } IoReleaseRemoveLock (&data->RemoveLock, Irp); Print (DBG_IOCTL_TRACE, ("IOCTL exit (%x)\n", status)); return status; } NTSTATUS KbdHid_SetLedIndicatorsComplete ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context ) { PIO_STACK_LOCATION stack; PDEVICE_EXTENSION data; stack = IoGetCurrentIrpStackLocation (Irp); data = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; if (Irp->PendingReturned) { IoMarkIrpPending (Irp); } IoFreeMdl (Irp->MdlAddress); Irp->MdlAddress = (PMDL) stack->Parameters.Others.Argument4; ExFreePool (Context); IoReleaseRemoveLock (&data->RemoveLock, Irp); return STATUS_SUCCESS; } NTSTATUS KbdHid_SetLedIndicators ( PDEVICE_EXTENSION Data, PKEYBOARD_INDICATOR_PARAMETERS NewIndicators, PIRP Irp ) /*++ Routine Description: Set the LED indicators of the supplied keyboard device context. Arguments: Data - Pointer to the driver device extension. Parameters - Pointer to the keyboard indicators to set/unset. Irp - An Irp to use for setting these parameters Return Value: STATUS_SUCCESS on success, STATUS_PENDING if operation is still pending, or otherwise an NTSTATUS error code on an error. --*/ { PIO_STACK_LOCATION nextStack; PIO_STACK_LOCATION curStack; NTSTATUS status = STATUS_SUCCESS; USAGE usageBuffer [4]; // only 4 known usages hardcoded below ULONG usageBufferLen = 0; PCHAR outputBuffer = 0; PMDL outputMdl = 0; PHID_EXTENSION hid = Data->HidExtension; status = IoAcquireRemoveLock (&Data->RemoveLock, Irp); if (!NT_SUCCESS (status)) { Irp->IoStatus.Status = status; IoCompleteRequest (Irp, IO_NO_INCREMENT); return status; } if (0 == hid->Caps.OutputReportByteLength) { // // This device has no LEDs, now while that is strange it is not really // an error. HID keyboards can have any LEDs that they want, including // none. // status = STATUS_SUCCESS; goto KbdHid_SetIndicatorsReject; } outputBuffer = ExAllocatePool (NonPagedPool, hid->Caps.OutputReportByteLength); if (NULL == outputBuffer) { status = STATUS_INSUFFICIENT_RESOURCES; goto KbdHid_SetIndicatorsReject; } outputMdl = IoAllocateMdl (outputBuffer, // The virtual address hid->Caps.OutputReportByteLength, // length of the MDL FALSE, // No associated IRP -> not secondary FALSE, // No quota charge 0); // No associated IRP if (NULL == outputMdl) { status = STATUS_INSUFFICIENT_RESOURCES; goto KbdHid_SetIndicatorsReject; } MmBuildMdlForNonPagedPool (outputMdl); // Build this MDL. // // Zero the output report packet. // RtlZeroMemory(outputBuffer, hid->Caps.OutputReportByteLength); // // Setup the usage list of LEDs. // if (NewIndicators->LedFlags & KEYBOARD_KANA_LOCK_ON) { usageBuffer[usageBufferLen++] = HID_USAGE_LED_KANA; } if (NewIndicators->LedFlags & KEYBOARD_CAPS_LOCK_ON) { usageBuffer[usageBufferLen++] = HID_USAGE_LED_CAPS_LOCK; } if (NewIndicators->LedFlags & KEYBOARD_NUM_LOCK_ON) { usageBuffer[usageBufferLen++] = HID_USAGE_LED_NUM_LOCK; } if (NewIndicators->LedFlags & KEYBOARD_SCROLL_LOCK_ON) { usageBuffer[usageBufferLen++] = HID_USAGE_LED_SCROLL_LOCK; } if (usageBufferLen == 0) { ASSERT((NewIndicators->LedFlags & (KEYBOARD_KANA_LOCK_ON | KEYBOARD_CAPS_LOCK_ON | KEYBOARD_NUM_LOCK_ON | KEYBOARD_SCROLL_LOCK_ON)) == 0); // // In order to fix led setting on a multiple collection keyboard, we // have to initialize the output report to make sure we get the correct // collection id. This is for the case where we are going from one // led on to all leds off. If not initialized, we'll get a report with no // collection id at the beginning. // usageBuffer[0] = HID_USAGE_LED_SCROLL_LOCK; // arbitirary led usageBufferLen = 1; HidP_UnsetUsages(HidP_Output, HID_USAGE_PAGE_LED, 0, usageBuffer, &usageBufferLen, hid->Ppd, outputBuffer, hid->Caps.OutputReportByteLength); } else { // // Set the usages in the output report. // HidP_SetUsages(HidP_Output, HID_USAGE_PAGE_LED, 0, usageBuffer, &usageBufferLen, hid->Ppd, outputBuffer, hid->Caps.OutputReportByteLength); } // // Obtain a pointer to the next IRP stack location. // nextStack = IoGetNextIrpStackLocation (Irp); curStack = IoGetCurrentIrpStackLocation (Irp); ASSERT(nextStack != NULL); // // Set up our write to HIDCLASS. // curStack->Parameters.Others.Argument4 = (PVOID) Irp->MdlAddress; Irp->MdlAddress = outputMdl; IoCopyCurrentIrpStackLocationToNext (Irp); nextStack->MajorFunction = IRP_MJ_WRITE; nextStack->Parameters.Write.Length = hid->Caps.OutputReportByteLength; nextStack->Parameters.Write.Key = 0; nextStack->Parameters.Write.ByteOffset.QuadPart = 0; // // Hook a completion routine to be called when the request completes. // IoSetCompletionRoutine (Irp, KbdHid_SetLedIndicatorsComplete, outputBuffer, TRUE, TRUE, TRUE); // // Call the next driver. // status = IoCallDriver(Data->TopOfStack, Irp); // // Return status. // return status; KbdHid_SetIndicatorsReject: Irp->IoStatus.Status = status; IoCompleteRequest(Irp, IO_NO_INCREMENT); if (NULL != outputBuffer) { ExFreePool (outputBuffer); } if (NULL != outputMdl) { IoFreeMdl (outputMdl); } IoReleaseRemoveLock (&Data->RemoveLock, Irp); return status; } VOID KbdHid_LogError( IN PDRIVER_OBJECT DriverObject, IN NTSTATUS ErrorCode, IN PWSTR ErrorInsertionString OPTIONAL) /*++ [DAN] Routine Description: Logs an error to the system. Arguments: DriverObject - Pointer to driver object reporting the error. ErrorCode - Indicates the type of error, system or driver-defined. ErrorInsertionString - Null-terminated Unicode string inserted into error description, as defined by error code. Must be no no longer than 50 characters. Return Value: None. --*/ { ULONG errorInsertionStringSize = 0; PIO_ERROR_LOG_PACKET errorLogEntry; ULONG errorLogEntrySize; // [including null] PWCHAR pWChar; if (ErrorInsertionString) { for (pWChar = ErrorInsertionString; *pWChar; pWChar++) { errorInsertionStringSize += sizeof(WCHAR); } errorInsertionStringSize += sizeof(UNICODE_NULL); } errorLogEntrySize = sizeof(IO_ERROR_LOG_PACKET) + errorInsertionStringSize; // // Log an error. // if (errorLogEntrySize <= ERROR_LOG_MAXIMUM_SIZE) { errorLogEntry = IoAllocateErrorLogEntry(DriverObject, (UCHAR)errorLogEntrySize); if (errorLogEntry != NULL) { RtlZeroMemory(errorLogEntry, errorLogEntrySize); errorLogEntry->ErrorCode = ErrorCode; errorLogEntry->FinalStatus = ErrorCode; errorLogEntry->NumberOfStrings = (ErrorInsertionString) ? 1 : 0; if (ErrorInsertionString) { RtlCopyMemory(errorLogEntry->DumpData, ErrorInsertionString, errorInsertionStringSize); } IoWriteErrorLogEntry(errorLogEntry); } } return; }
29.813596
87
0.587017
[ "object" ]
0358e831cca15ddee6971efb8b886491b7b1a01b
12,104
c
C
src/Core/regularisers_CPU/Diffus4th_order_core.c
vais-ral/CCPi-FISTA_Reconstruction
3c9ae36ac8e492d1c47142c808a8b643a16961c6
[ "Apache-2.0" ]
34
2018-07-30T21:42:45.000Z
2021-11-18T06:01:19.000Z
src/Core/regularisers_CPU/Diffus4th_order_core.c
vais-ral/CCPi-FISTA_Reconstruction
3c9ae36ac8e492d1c47142c808a8b643a16961c6
[ "Apache-2.0" ]
77
2018-05-02T14:59:49.000Z
2021-11-19T11:55:17.000Z
src/Core/regularisers_CPU/Diffus4th_order_core.c
vais-ral/CCPi-FISTA_Reconstruction
3c9ae36ac8e492d1c47142c808a8b643a16961c6
[ "Apache-2.0" ]
19
2018-11-13T20:30:16.000Z
2021-11-02T18:12:09.000Z
/* * This work is part of the Core Imaging Library developed by * Visual Analytics and Imaging System Group of the Science Technology * Facilities Council, STFC * * Copyright 2017 Daniil Kazantsev * Copyright 2017 Srikanth Nagella, Edoardo Pasca * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "Diffus4th_order_core.h" #include "utils.h" #define EPS 1.0e-7 /* C-OMP implementation of fourth-order diffusion scheme [1] for piecewise-smooth recovery (2D/3D case) * The minimisation is performed using explicit scheme. * * Input Parameters: * 1. Noisy image/volume * 2. lambda - regularization parameter * 3. Edge-preserving parameter (sigma) * 4. Number of iterations, for explicit scheme >= 150 is recommended * 5. tau - time-marching step for the explicit scheme * 6. eplsilon: tolerance constant * * Output: * [1] Regularized image/volume * [2] Information vector which contains [iteration no., reached tolerance] * * This function is based on the paper by * [1] Hajiaboli, M.R., 2011. An anisotropic fourth-order diffusion filter for image noise removal. International Journal of Computer Vision, 92(2), pp.177-191. */ float Diffus4th_CPU_main(float *Input, float *Output, float *infovector, float lambdaPar, float sigmaPar, int iterationsNumb, float tau, float epsil, int dimX, int dimY, int dimZ) { int i,DimTotal,j,count; float sigmaPar2, re, re1; re = 0.0f; re1 = 0.0f; count = 0; float *W_Lapl=NULL, *Output_prev=NULL; sigmaPar2 = sigmaPar*sigmaPar; DimTotal = dimX*dimY*dimZ; W_Lapl = calloc(DimTotal, sizeof(float)); if (epsil != 0.0f) Output_prev = calloc(DimTotal, sizeof(float)); /* copy into output */ copyIm(Input, Output, (long)(dimX), (long)(dimY), (long)(dimZ)); for(i=0; i < iterationsNumb; i++) { if ((epsil != 0.0f) && (i % 5 == 0)) copyIm(Output, Output_prev, (long)(dimX), (long)(dimY), (long)(dimZ)); if (dimZ == 1) { /* running 2D diffusion iterations */ /* Calculating weighted Laplacian */ Weighted_Laplc2D(W_Lapl, Output, sigmaPar2, dimX, dimY); /* Perform iteration step */ Diffusion_update_step2D(Output, Input, W_Lapl, lambdaPar, sigmaPar2, tau, (long)(dimX), (long)(dimY)); } else { /* running 3D diffusion iterations */ /* Calculating weighted Laplacian */ Weighted_Laplc3D(W_Lapl, Output, sigmaPar2, dimX, dimY, dimZ); /* Perform iteration step */ Diffusion_update_step3D(Output, Input, W_Lapl, lambdaPar, sigmaPar2, tau, (long)(dimX), (long)(dimY), (long)(dimZ)); } /* check early stopping criteria */ if ((epsil != 0.0f) && (i % 5 == 0)) { re = 0.0f; re1 = 0.0f; for(j=0; j<DimTotal; j++) { re += powf(Output[j] - Output_prev[j],2); re1 += powf(Output[j],2); } re = sqrtf(re)/sqrtf(re1); if (re < epsil) count++; if (count > 3) break; } } free(W_Lapl); if (epsil != 0.0f) free(Output_prev); /*adding info into info_vector */ infovector[0] = (float)(i); /*iterations number (if stopped earlier based on tolerance)*/ infovector[1] = re; /* reached tolerance */ return 0; } /********************************************************************/ /***************************2D Functions*****************************/ /********************************************************************/ float Weighted_Laplc2D(float *W_Lapl, float *U0, float sigma, long dimX, long dimY) { long i,j,i1,i2,j1,j2,index; float gradX, gradX_sq, gradY, gradY_sq, gradXX, gradYY, gradXY, xy_2, denom, V_norm, V_orth, c, c_sq; #pragma omp parallel for shared(W_Lapl) private(i,j,i1,i2,j1,j2,index,gradX, gradX_sq, gradY, gradY_sq, gradXX, gradYY, gradXY, xy_2, denom, V_norm, V_orth, c, c_sq) for(j=0; j<dimY; j++) { /* symmetric boundary conditions */ j1 = j+1; if (j1 == dimY) j1 = j-1; j2 = j-1; if (j2 < 0) j2 = j+1; for(i=0; i<dimX; i++) { /* symmetric boundary conditions */ i1 = i+1; if (i1 == dimX) i1 = i-1; i2 = i-1; if (i2 < 0) i2 = i+1; index = j*dimX+i; gradX = 0.5f*(U0[j*dimX+i2] - U0[j*dimX+i1]); gradX_sq = gradX*gradX; gradY = 0.5f*(U0[j2*dimX+i] - U0[j1*dimX+i]); gradY_sq = gradY*gradY; gradXX = U0[j*dimX+i2] + U0[j*dimX+i1] - 2*U0[index]; gradYY = U0[j2*dimX+i] + U0[j1*dimX+i] - 2*U0[index]; gradXY = 0.25f*(U0[j2*dimX+i2] + U0[j1*dimX+i1] - U0[j1*dimX+i2] - U0[j2*dimX+i1]); xy_2 = 2.0f*gradX*gradY*gradXY; denom = gradX_sq + gradY_sq; if (denom <= EPS) { V_norm = (gradXX*gradX_sq + xy_2 + gradYY*gradY_sq)/EPS; V_orth = (gradXX*gradY_sq - xy_2 + gradYY*gradX_sq)/EPS; } else { V_norm = (gradXX*gradX_sq + xy_2 + gradYY*gradY_sq)/denom; V_orth = (gradXX*gradY_sq - xy_2 + gradYY*gradX_sq)/denom; } c = 1.0f/(1.0f + denom/sigma); c_sq = c*c; W_Lapl[index] = c_sq*V_norm + c*V_orth; }} return *W_Lapl; } float Diffusion_update_step2D(float *Output, float *Input, float *W_Lapl, float lambdaPar, float sigmaPar2, float tau, long dimX, long dimY) { long i,j,i1,i2,j1,j2,index; float gradXXc, gradYYc; #pragma omp parallel for shared(Output, Input, W_Lapl) private(i,j,i1,i2,j1,j2,index,gradXXc,gradYYc) for(j=0; j<dimY; j++) { /* symmetric boundary conditions */ j1 = j+1; if (j1 == dimY) j1 = j-1; j2 = j-1; if (j2 < 0) j2 = j+1; for(i=0; i<dimX; i++) { /* symmetric boundary conditions */ i1 = i+1; if (i1 == dimX) i1 = i-1; i2 = i-1; if (i2 < 0) i2 = i+1; index = j*dimX+i; gradXXc = W_Lapl[j*dimX+i2] + W_Lapl[j*dimX+i1] - 2*W_Lapl[index]; gradYYc = W_Lapl[j2*dimX+i] + W_Lapl[j1*dimX+i] - 2*W_Lapl[index]; Output[index] += tau*(-lambdaPar*(gradXXc + gradYYc) - (Output[index] - Input[index])); }} return *Output; } /********************************************************************/ /***************************3D Functions*****************************/ /********************************************************************/ float Weighted_Laplc3D(float *W_Lapl, float *U0, float sigma, long dimX, long dimY, long dimZ) { long i,j,k,i1,i2,j1,j2,k1,k2,index; float gradX, gradX_sq, gradY, gradY_sq, gradXX, gradYY, gradXY, xy_2, denom, V_norm, V_orth, c, c_sq, gradZ, gradZ_sq, gradZZ, gradXZ, gradYZ, xyz_1, xyz_2; #pragma omp parallel for shared(W_Lapl) private(i,j,k,i1,i2,j1,j2,k1,k2,index,gradX, gradX_sq, gradY, gradY_sq, gradXX, gradYY, gradXY, xy_2, denom, V_norm, V_orth, c, c_sq, gradZ, gradZ_sq, gradZZ, gradXZ, gradYZ, xyz_1, xyz_2) for(k=0; k<dimZ; k++) { /* symmetric boundary conditions */ k1 = k+1; if (k1 == dimZ) k1 = k-1; k2 = k-1; if (k2 < 0) k2 = k+1; for(j=0; j<dimY; j++) { /* symmetric boundary conditions */ j1 = j+1; if (j1 == dimY) j1 = j-1; j2 = j-1; if (j2 < 0) j2 = j+1; for(i=0; i<dimX; i++) { /* symmetric boundary conditions */ i1 = i+1; if (i1 == dimX) i1 = i-1; i2 = i-1; if (i2 < 0) i2 = i+1; index = (dimX*dimY)*k + j*dimX+i; gradX = 0.5f*(U0[(dimX*dimY)*k + j*dimX+i2] - U0[(dimX*dimY)*k + j*dimX+i1]); gradX_sq = gradX*gradX; gradY = 0.5f*(U0[(dimX*dimY)*k + j2*dimX+i] - U0[(dimX*dimY)*k + j1*dimX+i]); gradY_sq = gradY*gradY; gradZ = 0.5f*(U0[(dimX*dimY)*k2 + j*dimX+i] - U0[(dimX*dimY)*k1 + j*dimX+i]); gradZ_sq = gradZ*gradZ; gradXX = U0[(dimX*dimY)*k + j*dimX+i2] + U0[(dimX*dimY)*k + j*dimX+i1] - 2*U0[index]; gradYY = U0[(dimX*dimY)*k + j2*dimX+i] + U0[(dimX*dimY)*k + j1*dimX+i] - 2*U0[index]; gradZZ = U0[(dimX*dimY)*k2 + j*dimX+i] + U0[(dimX*dimY)*k1 + j*dimX+i] - 2*U0[index]; gradXY = 0.25f*(U0[(dimX*dimY)*k + j2*dimX+i2] + U0[(dimX*dimY)*k + j1*dimX+i1] - U0[(dimX*dimY)*k + j1*dimX+i2] - U0[(dimX*dimY)*k + j2*dimX+i1]); gradXZ = 0.25f*(U0[(dimX*dimY)*k2 + j*dimX+i2] - U0[(dimX*dimY)*k2+j*dimX+i1] - U0[(dimX*dimY)*k1+j*dimX+i2] + U0[(dimX*dimY)*k1+j*dimX+i1]); gradYZ = 0.25f*(U0[(dimX*dimY)*k2 +j2*dimX+i] - U0[(dimX*dimY)*k2+j1*dimX+i] - U0[(dimX*dimY)*k1+j2*dimX+i] + U0[(dimX*dimY)*k1+j1*dimX+i]); xy_2 = 2.0f*gradX*gradY*gradXY; xyz_1 = 2.0f*gradX*gradZ*gradXZ; xyz_2 = 2.0f*gradY*gradZ*gradYZ; denom = gradX_sq + gradY_sq + gradZ_sq; if (denom <= EPS) { V_norm = (gradXX*gradX_sq + gradYY*gradY_sq + gradZZ*gradZ_sq + xy_2 + xyz_1 + xyz_2)/EPS; V_orth = ((gradY_sq + gradZ_sq)*gradXX + (gradX_sq + gradZ_sq)*gradYY + (gradX_sq + gradY_sq)*gradZZ - xy_2 - xyz_1 - xyz_2)/EPS; } else { V_norm = (gradXX*gradX_sq + gradYY*gradY_sq + gradZZ*gradZ_sq + xy_2 + xyz_1 + xyz_2)/denom; V_orth = ((gradY_sq + gradZ_sq)*gradXX + (gradX_sq + gradZ_sq)*gradYY + (gradX_sq + gradY_sq)*gradZZ - xy_2 - xyz_1 - xyz_2)/denom; } c = 1.0f/(1.0f + denom/sigma); c_sq = c*c; W_Lapl[index] = c_sq*V_norm + c*V_orth; }}} return *W_Lapl; } float Diffusion_update_step3D(float *Output, float *Input, float *W_Lapl, float lambdaPar, float sigmaPar2, float tau, long dimX, long dimY, long dimZ) { long i,j,i1,i2,j1,j2,index,k,k1,k2; float gradXXc, gradYYc, gradZZc; #pragma omp parallel for shared(Output, Input, W_Lapl) private(i,j,i1,i2,j1,j2,k,k1,k2,index,gradXXc,gradYYc,gradZZc) for(k=0; k<dimZ; k++) { /* symmetric boundary conditions */ k1 = k+1; if (k1 == dimZ) k1 = k-1; k2 = k-1; if (k2 < 0) k2 = k+1; for(j=0; j<dimY; j++) { /* symmetric boundary conditions */ j1 = j+1; if (j1 == dimY) j1 = j-1; j2 = j-1; if (j2 < 0) j2 = j+1; for(i=0; i<dimX; i++) { /* symmetric boundary conditions */ i1 = i+1; if (i1 == dimX) i1 = i-1; i2 = i-1; if (i2 < 0) i2 = i+1; index = (dimX*dimY)*k + j*dimX+i; gradXXc = W_Lapl[(dimX*dimY)*k + j*dimX+i2] + W_Lapl[(dimX*dimY)*k + j*dimX+i1] - 2*W_Lapl[index]; gradYYc = W_Lapl[(dimX*dimY)*k + j2*dimX+i] + W_Lapl[(dimX*dimY)*k + j1*dimX+i] - 2*W_Lapl[index]; gradZZc = W_Lapl[(dimX*dimY)*k2 + j*dimX+i] + W_Lapl[(dimX*dimY)*k1 + j*dimX+i] - 2*W_Lapl[index]; Output[index] += tau*(-lambdaPar*(gradXXc + gradYYc + gradZZc) - (Output[index] - Input[index])); }}} return *Output; }
45.503759
228
0.525777
[ "vector", "3d" ]
03594a2b40223e463c81b66900b02a7d3d246127
3,938
h
C
private/windows/shell/accesory/packager/packager.h
King0987654/windows2000
01f9c2e62c4289194e33244aade34b7d19e7c9b8
[ "MIT" ]
11
2017-09-02T11:27:08.000Z
2022-01-02T15:25:24.000Z
private/windows/shell/accesory/packager/packager.h
King0987654/windows2000
01f9c2e62c4289194e33244aade34b7d19e7c9b8
[ "MIT" ]
null
null
null
private/windows/shell/accesory/packager/packager.h
King0987654/windows2000
01f9c2e62c4289194e33244aade34b7d19e7c9b8
[ "MIT" ]
14
2019-01-16T01:01:23.000Z
2022-02-20T15:54:27.000Z
/* packager.h - Constants, types, and exports from the main module. */ #include <windows.h> #ifdef STRICT # undef STRICT # define PACKGR_STRICT #endif #define SERVERONLY #include <ole.h> #ifdef PACKGR_STRICT # define STRICT # undef PACKGR_STRICT #endif #include "ids.h" #define HIMETRIC_PER_INCH 2540 // Number of HIMETRIC units per inch #define DEF_LOGPIXELSX 96 // Default values for pixels per #define DEF_LOGPIXELSY 96 // logical inch #define KEYNAMESIZE 300 // Maximum registration key length #define CCLIENTNAMEMAX 50 // Maximum length of client app name #define CBCMDLINKMAX 500 #define CBMESSAGEMAX 128 #define CBSTRINGMAX 256 // Maximum lenght of a string in the res. #define CBSHORTSTRING 20 #define CBFILTERMAX 50 // Max # chars in a filter specification #define CBPATHMAX 260 // Most chars in a fully qual. filename #define CharCountOf(a) (sizeof(a) / sizeof(a[0])) #define CITEMSMAX 100 #define APPEARANCE 0 #define CONTENT 1 #define CCHILDREN 2 // Number of panes which precede #define OLE_PLAY 0 #define OLE_EDIT 1 #define WM_FIXSCROLL (WM_USER+100) #define WM_REDRAW (WM_USER+101) #define WM_READEMBEDDED (WM_USER+102) #define CHAR_SPACE TEXT(' ') #define CHAR_QUOTE TEXT('"') #define SZ_QUOTE TEXT("\"") typedef enum { NOTHING, CMDLINK, ICON, PEMBED, PICTURE } PANETYPE; typedef enum { SOP_FILE, SOP_MEMORY } STREAMOP; typedef struct _APPSTREAM { LPOLESTREAMVTBL lpstbl; INT fh; } APPSTREAM, *LPAPPSTREAM; typedef struct _EMBED // embed { ATOM aFileName; ATOM aTempName; DWORD dwSize; HANDLE hContents; HANDLE hdata; HANDLE hTask; HANDLE hSvrInst; BOOL bOleSvrFile; LPOLECLIENT lpclient; // At activation time we check whether the file LPOLEOBJECT lpLinkObj; // is a OLE server file. If so, we will create // a link to it, and activate it in OLE fashion } EMBED, *LPEMBED; typedef struct _CML // cml { HANDLE hdata; RECT rc; // HACK: Same location as in PICT BOOL fCmdIsLink; CHAR szCommand[CBCMDLINKMAX]; } CML, *LPCML; typedef struct _IC // ic { HANDLE hdata; HICON hDlgIcon; CHAR szIconPath[CBPATHMAX]; CHAR szIconText[CBPATHMAX]; INT iDlgIcon; } IC, *LPIC; typedef struct _PICT // pict { HANDLE hdata; RECT rc; // HACK: Same location as in CML LPOLEOBJECT lpObject; BOOL fNotReady; // TRUE if object creation is not complete } PICT, *LPPICT; typedef struct _SAMPSRVR // srvr { OLESERVER olesrvr; // Server HANDLE hsrvr; // Handle to server memory block LHSERVER lhsrvr; // Registration handle } PBSRVR, *LPSAMPSRVR; typedef struct _SAMPDOC // doc { OLESERVERDOC oledoc; // Document HANDLE hdoc; // Handle to document memory block LHSERVERDOC lhdoc; // Registration handle ATOM aName; // Document name atom } PBDOC, *LPSAMPDOC; typedef struct _SAMPITEM // item { OLEOBJECT oleobject; // Object HANDLE hitem; // Handle to item memory block LPOLECLIENT lpoleclient; INT ref; // # of references to document ATOM aName; // Item name atom } ITEM, *LPSAMPITEM; #include "globals.h" #include "function.h" #if DBG_PRNT #define DPRINT(s) OutputDebugString(TEXT(s) TEXT("\n")) #else #define DPRINT(s) #endif
24.159509
80
0.581513
[ "object" ]
035ab72beb9c0029029706a6f9589bed4a0c3471
7,507
c
C
src/other/libosmesa/src/glapi/glthread.c
dservin/brlcad
34b72d3efd24ac2c84abbccf9452323231751cd1
[ "BSD-4-Clause", "BSD-3-Clause" ]
83
2021-03-10T05:54:52.000Z
2022-03-31T16:33:46.000Z
src/other/libosmesa/src/glapi/glthread.c
dservin/brlcad
34b72d3efd24ac2c84abbccf9452323231751cd1
[ "BSD-4-Clause", "BSD-3-Clause" ]
13
2021-06-24T17:07:48.000Z
2022-03-31T15:31:33.000Z
src/other/libosmesa/src/glapi/glthread.c
dservin/brlcad
34b72d3efd24ac2c84abbccf9452323231751cd1
[ "BSD-4-Clause", "BSD-3-Clause" ]
54
2021-03-10T07:57:06.000Z
2022-03-28T23:20:37.000Z
/* * Mesa 3-D graphics library * Version: 6.5.1 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* * XXX There's probably some work to do in order to make this file * truly reusable outside of Mesa. First, the glheader.h include must go. */ #include "glheader.h" #include "glthread.h" /* * This file should still compile even when THREADS is not defined. * This is to make things easier to deal with on the makefile scene.. */ #ifdef THREADS #include <errno.h> /* * Error messages */ #define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific data" #define GET_TSD_ERROR "_glthread_: failed to get thread specific data" #define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data" /* * Magic number to determine if a TSD object has been initialized. * Kind of a hack but there doesn't appear to be a better cross-platform * solution. */ #define INIT_MAGIC 0xff8adc98 /* * POSIX Threads -- The best way to go if your platform supports them. * Solaris >= 2.5 have POSIX threads, IRIX >= 6.4 reportedly * has them, and many of the free Unixes now have them. * Be sure to use appropriate -mt or -D_REENTRANT type * compile flags when building. */ #ifdef PTHREADS unsigned long _glthread_GetID(void) { return (unsigned long) pthread_self(); } void _glthread_InitTSD(_glthread_TSD *tsd) { if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) { perror(INIT_TSD_ERROR); exit(-1); } tsd->initMagic = INIT_MAGIC; } void * _glthread_GetTSD(_glthread_TSD *tsd) { if (tsd->initMagic != (int) INIT_MAGIC) { _glthread_InitTSD(tsd); } return pthread_getspecific(tsd->key); } void _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) { if (tsd->initMagic != (int) INIT_MAGIC) { _glthread_InitTSD(tsd); } if (pthread_setspecific(tsd->key, ptr) != 0) { perror(SET_TSD_ERROR); exit(-1); } } #endif /* PTHREADS */ /* * Solaris/Unix International Threads -- Use only if POSIX threads * aren't available on your Unix platform. Solaris 2.[34] are examples * of platforms where this is the case. Be sure to use -mt and/or * -D_REENTRANT when compiling. */ #ifdef SOLARIS_THREADS #define USE_LOCK_FOR_KEY /* undef this to try a version without lock for the global key... */ unsigned long _glthread_GetID(void) { abort(); /* XXX not implemented yet */ return (unsigned long) 0; } void _glthread_InitTSD(_glthread_TSD *tsd) { if ((errno = mutex_init(&tsd->keylock, 0, NULL)) != 0 || (errno = thr_keycreate(&(tsd->key), free)) != 0) { perror(INIT_TSD_ERROR); exit(-1); } tsd->initMagic = INIT_MAGIC; } void * _glthread_GetTSD(_glthread_TSD *tsd) { void* ret; if (tsd->initMagic != INIT_MAGIC) { _glthread_InitTSD(tsd); } #ifdef USE_LOCK_FOR_KEY mutex_lock(&tsd->keylock); thr_getspecific(tsd->key, &ret); mutex_unlock(&tsd->keylock); #else if ((errno = thr_getspecific(tsd->key, &ret)) != 0) { perror(GET_TSD_ERROR); exit(-1); } #endif return ret; } void _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) { if (tsd->initMagic != INIT_MAGIC) { _glthread_InitTSD(tsd); } if ((errno = thr_setspecific(tsd->key, ptr)) != 0) { perror(SET_TSD_ERROR); exit(-1); } } #undef USE_LOCK_FOR_KEY #endif /* SOLARIS_THREADS */ /* * Win32 Threads. The only available option for Windows 95/NT. * Be sure that you compile using the Multithreaded runtime, otherwise * bad things will happen. */ #ifdef WIN32_THREADS void FreeTSD(_glthread_TSD *p) { if (p->initMagic==INIT_MAGIC) { TlsFree(p->key); p->initMagic=0; } } void InsteadOf_exit(int nCode) { DWORD dwErr=GetLastError(); } unsigned long _glthread_GetID(void) { return GetCurrentThreadId(); } void _glthread_InitTSD(_glthread_TSD *tsd) { tsd->key = TlsAlloc(); if (tsd->key == TLS_OUT_OF_INDEXES) { perror("Mesa:_glthread_InitTSD"); InsteadOf_exit(-1); } tsd->initMagic = INIT_MAGIC; } void * _glthread_GetTSD(_glthread_TSD *tsd) { if (tsd->initMagic != INIT_MAGIC) { _glthread_InitTSD(tsd); } return TlsGetValue(tsd->key); } void _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) { /* the following code assumes that the _glthread_TSD has been initialized to zero at creation */ if (tsd->initMagic != INIT_MAGIC) { _glthread_InitTSD(tsd); } if (TlsSetValue(tsd->key, ptr) == 0) { perror("Mesa:_glthread_SetTSD"); InsteadOf_exit(-1); } } #endif /* WIN32_THREADS */ /* * XFree86 has its own thread wrapper, Xthreads.h * We wrap it again for GL. */ #ifdef USE_XTHREADS unsigned long _glthread_GetID(void) { return (unsigned long) xthread_self(); } void _glthread_InitTSD(_glthread_TSD *tsd) { if (xthread_key_create(&tsd->key, NULL) != 0) { perror(INIT_TSD_ERROR); exit(-1); } tsd->initMagic = INIT_MAGIC; } void * _glthread_GetTSD(_glthread_TSD *tsd) { void *ptr; if (tsd->initMagic != INIT_MAGIC) { _glthread_InitTSD(tsd); } xthread_get_specific(tsd->key, &ptr); return ptr; } void _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) { if (tsd->initMagic != INIT_MAGIC) { _glthread_InitTSD(tsd); } xthread_set_specific(tsd->key, ptr); } #endif /* XTHREAD */ /* * BeOS threads */ #ifdef BEOS_THREADS unsigned long _glthread_GetID(void) { return (unsigned long) find_thread(NULL); } void _glthread_InitTSD(_glthread_TSD *tsd) { tsd->key = tls_allocate(); tsd->initMagic = INIT_MAGIC; } void * _glthread_GetTSD(_glthread_TSD *tsd) { if (tsd->initMagic != (int) INIT_MAGIC) { _glthread_InitTSD(tsd); } return tls_get(tsd->key); } void _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) { if (tsd->initMagic != (int) INIT_MAGIC) { _glthread_InitTSD(tsd); } tls_set(tsd->key, ptr); } #endif /* BEOS_THREADS */ #else /* THREADS */ /* * no-op functions */ unsigned long _glthread_GetID(void) { return 0; } void _glthread_InitTSD(_glthread_TSD *tsd) { (void) tsd; } void * _glthread_GetTSD(_glthread_TSD *tsd) { (void) tsd; return NULL; } void _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) { (void) tsd; (void) ptr; } #endif /* THREADS */ /* * Local Variables: * tab-width: 8 * mode: C * indent-tabs-mode: t * c-file-style: "stroustrup" * End: * ex: shiftwidth=4 tabstop=8 */
19.498701
84
0.678433
[ "object" ]
035efb1c32e4cb6c8639ae9c4d89a4cf9b3a75a7
2,612
h
C
autoload/fuzzycomt.h
ptzz/ctrlp-cmatcher
d07dc2dc837427db25910f57ddf96f6f53c37ec9
[ "BSD-2-Clause" ]
6
2017-12-12T21:24:17.000Z
2018-07-09T11:50:30.000Z
autoload/fuzzycomt.h
ptzz/ctrlp-cmatcher
d07dc2dc837427db25910f57ddf96f6f53c37ec9
[ "BSD-2-Clause" ]
null
null
null
autoload/fuzzycomt.h
ptzz/ctrlp-cmatcher
d07dc2dc837427db25910f57ddf96f6f53c37ec9
[ "BSD-2-Clause" ]
1
2020-01-07T01:55:04.000Z
2020-01-07T01:55:04.000Z
// Copyright 2013 Stanislav Golovanov <stgolovanov@gmail.com> // Matching algorithm by Wincent Colaiuta, 2010. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY 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 HOLDERS 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 <Python.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> extern "C" { typedef enum mmode { fullLine, filenameOnly, firstNonTab, untilLastTab } mmode_t; typedef struct { PyObject *str; // Python object with file path double score; // score of string } matchobj_t; typedef struct { char *haystack_p; // pointer to string to be searched long haystack_len; // length of same char *needle_p; // pointer to search string (abbreviation) long needle_len; // length of same double max_score_per_char; int dot_file; // boolean: true if str is a dot-file double *memo; // memoization } matchinfo_t; matchobj_t ctrlp_find_match(PyObject* str, PyObject* abbrev, mmode_t mmode); void ctrlp_get_line_matches(PyObject* paths, PyObject* abbrev, matchobj_t matches[], char *mode); PyObject* ctrlp_fuzzycomt_match(PyObject* self, PyObject* args); PyObject* ctrlp_fuzzycomt_sorted_match_list(PyObject* self, PyObject* args); } // extern "C"
40.8125
97
0.703292
[ "object" ]
036c68324e6c9444a7a8115b1b5efe04f85474da
14,758
h
C
be/src/scheduling/admission-controller.h
AtScaleInc/Impala
1073a9108220faffe61c3bc9dff7a953adde12df
[ "Apache-2.0" ]
2
2017-05-30T16:47:31.000Z
2020-07-21T04:28:17.000Z
be/src/scheduling/admission-controller.h
AtScaleInc/Impala
1073a9108220faffe61c3bc9dff7a953adde12df
[ "Apache-2.0" ]
1
2016-03-10T16:34:10.000Z
2016-03-10T16:34:10.000Z
be/src/scheduling/admission-controller.h
AtScaleInc/Impala
1073a9108220faffe61c3bc9dff7a953adde12df
[ "Apache-2.0" ]
6
2015-12-22T14:52:38.000Z
2019-07-06T08:34:23.000Z
// Copyright 2014 Cloudera Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef SCHEDULING_ADMISSION_CONTROLLER_H #define SCHEDULING_ADMISSION_CONTROLLER_H #include <vector> #include <string> #include <list> #include <boost/unordered_map.hpp> #include <boost/unordered_set.hpp> #include <boost/thread/mutex.hpp> #include "common/status.h" #include "scheduling/request-pool-service.h" #include "statestore/statestore-subscriber.h" #include "statestore/query-schedule.h" #include "util/internal-queue.h" #include "util/thread.h" namespace impala { class QuerySchedule; class ExecEnv; // The AdmissionController is used to make local admission decisions based on cluster // state disseminated by the statestore. Requests are submitted for execution to a given // pool via AdmitQuery(). A request will either be admitted immediately, queued, or // rejected. This decision is based on per-pool estimates of the total number of // concurrently executing queries across the entire cluster, their memory usage, and the // total number of queued requests across the entire cluster. When the number of // concurrently executing queries goes above a configurable per-pool threshold or the // memory usage of those queries goes above a per-pool memory limit, requests // will be queued. When the total number of queued requests in a particular pool goes // above a configurable threshold, incoming requests to that pool will be rejected. // TODO: When we resolve users->pools, explain the model and configuration story. // (There is one hard-coded pool right now, configurable via gflags.) // // The pool statistics are updated by the statestore using the // IMPALA_REQUEST_QUEUE_TOPIC topic. Every <impalad, pool> pair is sent as a topic update // when pool statistics change, and the topic updates from other impalads are used to // re-compute the total per-pool stats. When there are queued requests, the number of // executing queries drops below the configured maximum, and the memory usage of those // queries is below the memory limit, a number of queued requests will be admitted // according to the following formula: // N = (#local_pool_queued / #global_pool_queued) * (pool_limit - #global_pool_running) // If there is a memory limit specified but no limit on the number of running queries, we // will dequeue and admit all of the queued requests because we don't attempt to estimate // request memory usage. Because the pool statistics are only updated on statestore // heartbeats and all decisions are made locally, the total pool statistics are // estimates. As a result, more requests may be admitted or queued than the configured // thresholds, which are really soft limits. // // Because the memory usage (tracked by the per-pool mem trackers) may not reflect the // peak memory usage of a query for some time, it would be possible to over admit // requests if they are submitted much faster than running queries were to start using // memory. However, to avoid this, we use the request's memory estimate from planning // (even though we know these estimates may be off) before admitting a request, and we // also keep track of the sum of the memory estimates for all running queries, per-pool. // The local, per-pool mem_usage is set to the maximum of the estimate and the actual // per-pool current consumption. We then need to update the local and cluster mem_usage // stats when admitting (in AdmitQuery() and DequeueLoop()) as well as in ReleaseQuery(). // When requests are submitted very quickly and the memory estimates from planning are // significantly off this strategy can still result in over or under subscription, but // this is not completely unavoidable unless we can produce better estimates. // TODO: We can reduce the effect of very high estimates by using a weighted // combination of the estimate and the actual consumption as a function of time. class AdmissionController { public: AdmissionController(RequestPoolService* request_pool_service, Metrics* metrics, const std::string& backend_id); ~AdmissionController(); // Submits the request for admission. Returns immediately if rejected, but // otherwise blocks until the request is admitted. When this method returns, // schedule->is_admitted() is true if and only if the request was admitted. // For all calls to AdmitQuery(), ReleaseQuery() should also be called after // the query completes to ensure that the pool statistics are updated. Status AdmitQuery(QuerySchedule* schedule); // Updates the pool statistics when a query completes (either successfully, // is cancelled or failed). This should be called for all requests that have // been submitted via AdmitQuery(). (If the request was not admitted, this is // a no-op.) // This does not block. Status ReleaseQuery(QuerySchedule* schedule); // Registers with the subscription manager. Status Init(StatestoreSubscriber* subscriber); private: static const std::string IMPALA_REQUEST_QUEUE_TOPIC; // Structure stored in a QueryQueue representing a request. This struct lives only // during the call to AdmitQuery(). struct QueueNode : public InternalQueue<QueueNode>::Node { QueueNode(const QuerySchedule& query_schedule) : schedule(query_schedule) { } // Set when the request is admitted or rejected by the dequeuing thread. Used // by AdmitQuery() to wait for admission or until the timeout is reached. // The admission_ctrl_lock_ is not held while waiting on this promise, but // the lock should be held when checking the result because the dequeuing // thread holds it to Set(). Promise<bool> is_admitted; // The query schedule of the queued request. The schedule lives longer than the // duration of the the QueueNode, which only lives the duration of the call to // AdmitQuery. const QuerySchedule& schedule; }; // Metrics exposed for a pool. // Created by GetPoolMetrics() and stored in pool_metrics_map_. struct PoolMetrics { // Monotonically increasing counters since process start, i.e. counters: // The total number of requests that have been admitted locally. This includes // requests that are admitted immediately as well as requests that are admitted // after being queued. Incremented when AdmitQuery() returns and the request is // admitted. Metrics::IntMetric* local_admitted; // The total number of requests that have been queued locally. Incremented // when a request is queued. Metrics::IntMetric* local_queued; // The total number of requests that have been dequeued locally. Metrics::IntMetric* local_dequeued; // The total number of requests that have been rejected locally. Incremented when // AdmitQuery() returns and the request is rejected because the queue is full. Metrics::IntMetric* local_rejected; // The total number of requests that timed out while waiting for admission locally. Metrics::IntMetric* local_timed_out; // The total number of requests that have completed locally. Incremented in // ReleaseQuery(). Metrics::IntMetric* local_completed; // The total amount of time (in milliseconds) that locally queued requests have // spent waiting to be admitted. Metrics::IntMetric* local_time_in_queue_ms; // Instantaneous statistics, i.e. gauges: // The estimated total number of queries currently running across the cluster. Metrics::IntMetric* cluster_num_running; // The estimated total number of requests currently queued across the cluster. Metrics::IntMetric* cluster_in_queue; // Approximate total amount of memory used by this pool across the cluster. Metrics::BytesMetric* cluster_mem_usage; // The sum of planner memory estimates for requests across the cluster. Metrics::BytesMetric* cluster_mem_estimate; // The total number of queries currently running that were initiated locally. Metrics::IntMetric* local_num_running; // The total number of requests currently queued locally. Metrics::IntMetric* local_in_queue; // The total amount of memory used by this pool locally. Metrics::BytesMetric* local_mem_usage; // The sum of planner memory estimates for requests that were started locally. Metrics::BytesMetric* local_mem_estimate; }; // Used for user-to-pool resolution and looking up pool configurations. Not owned by // the AdmissionController. RequestPoolService* request_pool_service_; // Metrics subsystem access Metrics* metrics_; // Thread dequeuing and admitting queries. boost::scoped_ptr<Thread> dequeue_thread_; // Unique id for this impalad, used to construct topic keys. const std::string backend_id_; // Serializes/deserializes TPoolStats when sending and receiving topic updates. ThriftSerializer thrift_serializer_; // Protects all access to all variables below. // Coordinates access to the results of the promise QueueNode::is_admitted, // but the lock is not required to wait on the promise. boost::mutex admission_ctrl_lock_; // Map of pool names to pool statistics. typedef boost::unordered_map<std::string, TPoolStats> PoolStatsMap; // The local pool statistics. Updated when requests are executed, queued, and // completed. PoolStatsMap local_pool_stats_; // A set of pool names. typedef boost::unordered_set<std::string> PoolSet; // The set of local pools that have changed between topic updates that // need to be sent to the statestore. PoolSet pools_for_updates_; // Mimics the statestore topic, i.e. stores a local copy of the logical data structure // that the statestore broadcasts. The local stats are not stored in this map because // we need to be able to clear the stats for all remote backends when a full topic // update is received. By storing the local pool stats in local_pool_stats_, we can // simply clear() the map. // Pool names -> full topic keys (i.e. "<topic>!<backend_id>") -> pool stats typedef boost::unordered_map<std::string, PoolStatsMap> PerBackendPoolStatsMap; PerBackendPoolStatsMap per_backend_pool_stats_map_; // The (estimated) total pool statistics for the entire cluster. Includes the current // local stats in local_pool_stats_. Updated when (a) IMPALA_REQUEST_QUEUE_TOPIC // updates are received by aggregating the stats in per_backend_pool_stats_map_ and (b) // when local stats change (i.e. AdmitQuery(), ReleaseQuery(), and when dequeuing in // DequeueLoop()). // Pool names -> estimated total pool stats PoolStatsMap cluster_pool_stats_; // Queue for the queries waiting to be admitted for execution. Once the // maximum number of concurrently executing queries has been reached, // incoming queries are queued and admitted FCFS. typedef InternalQueue<QueueNode> RequestQueue; // Map of pool names to request queues. typedef boost::unordered_map<std::string, RequestQueue> RequestQueueMap; RequestQueueMap request_queue_map_; // Map of pool names to pool metrics. typedef boost::unordered_map<std::string, PoolMetrics> PoolMetricsMap; PoolMetricsMap pool_metrics_map_; // Map of pool names to the most recent pool configs returned by request_pool_service_. // Stored so that the dequeue thread does not need to access the configs via the // request pool service again (which involves a JNI call and error checking). typedef boost::unordered_map<std::string, TPoolConfigResult> PoolConfigMap; PoolConfigMap pool_config_cache_; // Notifies the dequeuing thread that pool stats have changed and it may be // possible to dequeue and admit queries. boost::condition_variable dequeue_cv_; // If true, tear down the dequeuing thread. This only happens in unit tests. bool done_; // Statestore subscriber callback that updates the pool stats state. void UpdatePoolStats( const StatestoreSubscriber::TopicDeltaMap& incoming_topic_deltas, std::vector<TTopicDelta>* subscriber_topic_updates); // Updates the per_backend_pool_stats_map_ with topic_updates. // Called by UpdatePoolStats(). Must hold admission_ctrl_lock_. void HandleTopicUpdates(const std::vector<TTopicItem>& topic_updates); // Removes stats from the per_backend_pool_stats_map_ from topic deletions. // Called by UpdatePoolStats(). Must hold admission_ctrl_lock_. void HandleTopicDeletions(const std::vector<std::string>& topic_deletions); // Re-computes the cluster_pool_stats_ aggregate stats for all pools. // Called by UpdatePoolStats() after handling updates and deletions. // Must hold admission_ctrl_lock_. void UpdateClusterAggregates(const std::string& pool_name); // Updates the memory usage of the local pool stats based on the most recent mem // tracker consumption. Called by UpdatePoolStats() before sending local pool updates. // Must hold admission_ctrl_lock_. void UpdateLocalMemUsage(const std::string& pool_name); // Adds updates for local pools that have changed to the subscriber topic updates. // Called by UpdatePoolStats() before handling updates. // Must hold admission_ctrl_lock_. void AddPoolUpdates(std::vector<TTopicDelta>* subscriber_topic_updates); // Dequeues and admits queued queries when notified by dequeue_cv_. void DequeueLoop(); // Returns OK if the request can be admitted, i.e. admitting would not go over the // limits for this pool. Otherwise, the error message specifies the reason the // request can not be admitted immediately. Status CanAdmitRequest(const std::string& pool, const int64_t max_requests, const int64_t mem_limit, const QuerySchedule& schedule, bool admit_from_queue); // Returns an error status if this request must be rejected; the error message // specifies the reason the request is rejected. Status RejectRequest(const std::string& pool, const int64_t max_requests, const int64_t mem_limit, const int64_t max_queued, const QuerySchedule& schedule); // Gets the metrics for a pool. The metrics are initialized if they don't already // exist. Returns NULL if there is no metrics system available. Must hold // admission_ctrl_lock_. PoolMetrics* GetPoolMetrics(const std::string& pool_name); }; } #endif // SCHEDULING_ADMISSION_CONTROLLER_H
49.35786
89
0.763789
[ "vector", "model" ]
0371db6531ea61e923ed3f16d0f7bfb88e12c369
924
h
C
code/modules/engine/vulkan/frame.h
a-day-old-bagel/brickmap-vulkan
e82b680d507e5c2b09dc8e0b8cbd9907a4fd60c1
[ "MIT" ]
8
2021-12-16T20:12:06.000Z
2022-01-01T16:50:21.000Z
code/modules/engine/vulkan/frame.h
a-day-old-bagel/brickmap-vulkan
e82b680d507e5c2b09dc8e0b8cbd9907a4fd60c1
[ "MIT" ]
null
null
null
code/modules/engine/vulkan/frame.h
a-day-old-bagel/brickmap-vulkan
e82b680d507e5c2b09dc8e0b8cbd9907a4fd60c1
[ "MIT" ]
1
2022-02-25T22:12:55.000Z
2022-02-25T22:12:55.000Z
#pragma once #include "push_buffer.h" #include "descriptors.h" namespace rebel_road { namespace vulkan { class device_context; class render_context; class frame { public: void begin_frame(); void submit_and_present(); struct { device_context* device {}; render_context* render {}; } context; vk::Semaphore present_semaphore; vk::Semaphore render_semaphore; vk::Fence render_fence; util::deletion_queue frame_deletion_queue; vk::CommandPool command_pool; vk::CommandBuffer command_buffer; push_buffer dynamic_data; descriptor_allocator* dynamic_descriptor_allocator; uint32_t swapchain_image_index {}; }; } // namespace vulkan } // namepsace rebel_road
21
63
0.569264
[ "render" ]
037699539afac016e6f4e255a463254835f01983
5,903
h
C
aws-cpp-sdk-dynamodb/include/aws/dynamodb/model/UpdateGlobalSecondaryIndexAction.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-dynamodb/include/aws/dynamodb/model/UpdateGlobalSecondaryIndexAction.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-dynamodb/include/aws/dynamodb/model/UpdateGlobalSecondaryIndexAction.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
1
2020-11-04T03:18:11.000Z
2020-11-04T03:18:11.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/dynamodb/DynamoDB_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/dynamodb/model/ProvisionedThroughput.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace DynamoDB { namespace Model { /** * <p>Represents the new provisioned throughput settings to be applied to a global * secondary index.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/dynamodb-2012-08-10/UpdateGlobalSecondaryIndexAction">AWS * API Reference</a></p> */ class AWS_DYNAMODB_API UpdateGlobalSecondaryIndexAction { public: UpdateGlobalSecondaryIndexAction(); UpdateGlobalSecondaryIndexAction(Aws::Utils::Json::JsonView jsonValue); UpdateGlobalSecondaryIndexAction& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The name of the global secondary index to be updated.</p> */ inline const Aws::String& GetIndexName() const{ return m_indexName; } /** * <p>The name of the global secondary index to be updated.</p> */ inline bool IndexNameHasBeenSet() const { return m_indexNameHasBeenSet; } /** * <p>The name of the global secondary index to be updated.</p> */ inline void SetIndexName(const Aws::String& value) { m_indexNameHasBeenSet = true; m_indexName = value; } /** * <p>The name of the global secondary index to be updated.</p> */ inline void SetIndexName(Aws::String&& value) { m_indexNameHasBeenSet = true; m_indexName = std::move(value); } /** * <p>The name of the global secondary index to be updated.</p> */ inline void SetIndexName(const char* value) { m_indexNameHasBeenSet = true; m_indexName.assign(value); } /** * <p>The name of the global secondary index to be updated.</p> */ inline UpdateGlobalSecondaryIndexAction& WithIndexName(const Aws::String& value) { SetIndexName(value); return *this;} /** * <p>The name of the global secondary index to be updated.</p> */ inline UpdateGlobalSecondaryIndexAction& WithIndexName(Aws::String&& value) { SetIndexName(std::move(value)); return *this;} /** * <p>The name of the global secondary index to be updated.</p> */ inline UpdateGlobalSecondaryIndexAction& WithIndexName(const char* value) { SetIndexName(value); return *this;} /** * <p>Represents the provisioned throughput settings for the specified global * secondary index.</p> <p>For current minimum and maximum provisioned throughput * values, see <a * href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a> * in the <i>Amazon DynamoDB Developer Guide</i>.</p> */ inline const ProvisionedThroughput& GetProvisionedThroughput() const{ return m_provisionedThroughput; } /** * <p>Represents the provisioned throughput settings for the specified global * secondary index.</p> <p>For current minimum and maximum provisioned throughput * values, see <a * href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a> * in the <i>Amazon DynamoDB Developer Guide</i>.</p> */ inline bool ProvisionedThroughputHasBeenSet() const { return m_provisionedThroughputHasBeenSet; } /** * <p>Represents the provisioned throughput settings for the specified global * secondary index.</p> <p>For current minimum and maximum provisioned throughput * values, see <a * href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a> * in the <i>Amazon DynamoDB Developer Guide</i>.</p> */ inline void SetProvisionedThroughput(const ProvisionedThroughput& value) { m_provisionedThroughputHasBeenSet = true; m_provisionedThroughput = value; } /** * <p>Represents the provisioned throughput settings for the specified global * secondary index.</p> <p>For current minimum and maximum provisioned throughput * values, see <a * href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a> * in the <i>Amazon DynamoDB Developer Guide</i>.</p> */ inline void SetProvisionedThroughput(ProvisionedThroughput&& value) { m_provisionedThroughputHasBeenSet = true; m_provisionedThroughput = std::move(value); } /** * <p>Represents the provisioned throughput settings for the specified global * secondary index.</p> <p>For current minimum and maximum provisioned throughput * values, see <a * href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a> * in the <i>Amazon DynamoDB Developer Guide</i>.</p> */ inline UpdateGlobalSecondaryIndexAction& WithProvisionedThroughput(const ProvisionedThroughput& value) { SetProvisionedThroughput(value); return *this;} /** * <p>Represents the provisioned throughput settings for the specified global * secondary index.</p> <p>For current minimum and maximum provisioned throughput * values, see <a * href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a> * in the <i>Amazon DynamoDB Developer Guide</i>.</p> */ inline UpdateGlobalSecondaryIndexAction& WithProvisionedThroughput(ProvisionedThroughput&& value) { SetProvisionedThroughput(std::move(value)); return *this;} private: Aws::String m_indexName; bool m_indexNameHasBeenSet; ProvisionedThroughput m_provisionedThroughput; bool m_provisionedThroughputHasBeenSet; }; } // namespace Model } // namespace DynamoDB } // namespace Aws
39.61745
162
0.70947
[ "model" ]
03779e6f377c9710eff6fa7de41c8f655302a5a4
2,065
h
C
src/atlas_fusion/include/data_models/camera/DepthMapDataModel.h
Robotics-BUT/Atlas-Fusion
3237f65d84a2686c5a20b89def4b706d89744ffb
[ "MIT" ]
15
2020-10-27T01:38:05.000Z
2021-09-21T07:27:01.000Z
src/atlas_fusion/include/data_models/camera/DepthMapDataModel.h
Robotics-BUT/Atlas-Fusion
3237f65d84a2686c5a20b89def4b706d89744ffb
[ "MIT" ]
2
2021-06-02T11:54:38.000Z
2021-10-05T13:05:29.000Z
src/atlas_fusion/include/data_models/camera/DepthMapDataModel.h
Robotics-BUT/Atlas-Fusion
3237f65d84a2686c5a20b89def4b706d89744ffb
[ "MIT" ]
4
2021-04-10T09:12:47.000Z
2021-04-27T15:33:27.000Z
#pragma once #include <opencv2/opencv.hpp> #include <iostream> #include "data_models/GenericDataModel.h" #include "data_models/all.h" #include "data_models/DataModelTypes.h" #include "data_loader/DataLoaderIdentifiers.h" namespace AtlasFusion::DataModels { /** * Camera Frame Data Model represents single RGB frame captured by the camera */ class DepthMapDataModel : public GenericDataModel { public: /** * Constructor * @param timestamp frame capture timestamp * @param img image representation * @param cameraIdentifier camera sensor identifier * @param yolo neural network's detections */ DepthMapDataModel(uint64_t timestamp, cv::Mat img, DataLoader::CameraIndentifier cameraIdentifier, const std::vector<std::shared_ptr<YoloDetection>>& yolo) : GenericDataModel(timestamp) , image_(img) , yoloDetections_(std::move(yolo)) , cameraIdentifier_(cameraIdentifier) { type_ = DataModelTypes::kCameraDataModelType; } std::string toString() override; /** * Image getter * @return opencv image */ cv::Mat getImage() {return image_;}; /** * Vector of NN's detections * @return NN's detections */ std::vector<std::shared_ptr<YoloDetection>> getYoloDetections() {return yoloDetections_;}; /** * NN's detections setter * @param detections */ void setYoloDetections(std::vector<std::shared_ptr<YoloDetection>>& detections) {yoloDetections_ = detections;}; /** * Unique camera sensor identifier getter * @return source sensor camera identifier */ DataLoader::CameraIndentifier getCameraIdentifier() { return cameraIdentifier_;}; private: cv::Mat image_; std::vector<std::shared_ptr<YoloDetection>> yoloDetections_{} ; DataLoader::CameraIndentifier cameraIdentifier_; }; }
29.5
163
0.627603
[ "vector", "model" ]
0379a92ae0da7123483b24debd6420473cc5169a
19,912
c
C
src/shogun/lib/external/dSFMT/dSFMT.c
cloner1984/shogun
901c04b2c6550918acf0594ef8afeb5dcd840a7d
[ "BSD-3-Clause" ]
2
2021-08-12T18:11:06.000Z
2021-11-17T10:56:49.000Z
src/shogun/lib/external/dSFMT/dSFMT.c
cloner1984/shogun
901c04b2c6550918acf0594ef8afeb5dcd840a7d
[ "BSD-3-Clause" ]
null
null
null
src/shogun/lib/external/dSFMT/dSFMT.c
cloner1984/shogun
901c04b2c6550918acf0594ef8afeb5dcd840a7d
[ "BSD-3-Clause" ]
null
null
null
/** * @file dSFMT.c * @brief double precision SIMD-oriented Fast Mersenne Twister (dSFMT) * based on IEEE 754 format. * * @author Mutsuo Saito (Hiroshima University) * @author Makoto Matsumoto (Hiroshima University) * * Copyright (C) 2007,2008 Mutsuo Saito, Makoto Matsumoto and Hiroshima * University. All rights reserved. * * The new BSD License is applied to this software, see LICENSE.txt */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <shogun/lib/external/dSFMT/dSFMT-params.h> #include <shogun/lib/external/dSFMT/dSFMT-common.h> #if defined(__cplusplus) extern "C" { #endif /** dsfmt internal state vector */ dsfmt_t dsfmt_global_data; /** dsfmt mexp for check */ static const int dsfmt_mexp = DSFMT_MEXP; /*---------------- STATIC FUNCTIONS ----------------*/ inline static uint32_t ini_func1(uint32_t x); inline static uint32_t ini_func2(uint32_t x); inline static void gen_rand_array_c1o2(dsfmt_t *dsfmt, dw128_t *array, int size); inline static void gen_rand_array_c0o1(dsfmt_t *dsfmt, dw128_t *array, int size); inline static void gen_rand_array_o0c1(dsfmt_t *dsfmt, dw128_t *array, int size); inline static void gen_rand_array_o0o1(dsfmt_t *dsfmt, dw128_t *array, int size); inline static int idxof(int i); static void initial_mask(dsfmt_t *dsfmt); static void period_certification(dsfmt_t *dsfmt); #if defined(HAVE_SSE2) /** 1 in 64bit for sse2 */ static const union X128I_T sse2_int_one = {{1, 1}}; /** 2.0 double for sse2 */ static const union X128D_T sse2_double_two = {{2.0, 2.0}}; /** -1.0 double for sse2 */ static const union X128D_T sse2_double_m_one = {{-1.0, -1.0}}; #endif /** * This function simulate a 32-bit array index overlapped to 64-bit * array of LITTLE ENDIAN in BIG ENDIAN machine. */ #if defined(DSFMT_BIG_ENDIAN) inline static int idxof(int i) { return i ^ 1; } #else inline static int idxof(int i) { return i; } #endif #if defined(HAVE_SSE2) /** * This function converts the double precision floating point numbers which * distribute uniformly in the range [1, 2) to those which distribute uniformly * in the range [0, 1). * @param w 128bit stracture of double precision floating point numbers (I/O) */ inline static void convert_c0o1(dw128_t *w) { w->sd = _mm_add_pd(w->sd, sse2_double_m_one.d128); } /** * This function converts the double precision floating point numbers which * distribute uniformly in the range [1, 2) to those which distribute uniformly * in the range (0, 1]. * @param w 128bit stracture of double precision floating point numbers (I/O) */ inline static void convert_o0c1(dw128_t *w) { w->sd = _mm_sub_pd(sse2_double_two.d128, w->sd); } /** * This function converts the double precision floating point numbers which * distribute uniformly in the range [1, 2) to those which distribute uniformly * in the range (0, 1). * @param w 128bit stracture of double precision floating point numbers (I/O) */ inline static void convert_o0o1(dw128_t *w) { w->si = _mm_or_si128(w->si, sse2_int_one.i128); w->sd = _mm_add_pd(w->sd, sse2_double_m_one.d128); } #else /* standard C and altivec */ /** * This function converts the double precision floating point numbers which * distribute uniformly in the range [1, 2) to those which distribute uniformly * in the range [0, 1). * @param w 128bit stracture of double precision floating point numbers (I/O) */ inline static void convert_c0o1(dw128_t *w) { w->d[0] -= 1.0; w->d[1] -= 1.0; } /** * This function converts the double precision floating point numbers which * distribute uniformly in the range [1, 2) to those which distribute uniformly * in the range (0, 1]. * @param w 128bit stracture of double precision floating point numbers (I/O) */ inline static void convert_o0c1(dw128_t *w) { w->d[0] = 2.0 - w->d[0]; w->d[1] = 2.0 - w->d[1]; } /** * This function converts the double precision floating point numbers which * distribute uniformly in the range [1, 2) to those which distribute uniformly * in the range (0, 1). * @param w 128bit stracture of double precision floating point numbers (I/O) */ inline static void convert_o0o1(dw128_t *w) { w->u[0] |= 1; w->u[1] |= 1; w->d[0] -= 1.0; w->d[1] -= 1.0; } #endif /** * This function fills the user-specified array with double precision * floating point pseudorandom numbers of the IEEE 754 format. * @param dsfmt dsfmt state vector. * @param array an 128-bit array to be filled by pseudorandom numbers. * @param size number of 128-bit pseudorandom numbers to be generated. */ inline static void gen_rand_array_c1o2(dsfmt_t *dsfmt, dw128_t *array, int size) { int i, j; dw128_t lung; lung = dsfmt->status[DSFMT_N]; do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { do_recursion(&array[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], &lung); } for (; i < DSFMT_N; i++) { do_recursion(&array[i], &dsfmt->status[i], &array[i + DSFMT_POS1 - DSFMT_N], &lung); } for (; i < size - DSFMT_N; i++) { do_recursion(&array[i], &array[i - DSFMT_N], &array[i + DSFMT_POS1 - DSFMT_N], &lung); } for (j = 0; j < 2 * DSFMT_N - size; j++) { dsfmt->status[j] = array[j + size - DSFMT_N]; } for (; i < size; i++, j++) { do_recursion(&array[i], &array[i - DSFMT_N], &array[i + DSFMT_POS1 - DSFMT_N], &lung); dsfmt->status[j] = array[i]; } dsfmt->status[DSFMT_N] = lung; } /** * This function fills the user-specified array with double precision * floating point pseudorandom numbers of the IEEE 754 format. * @param dsfmt dsfmt state vector. * @param array an 128-bit array to be filled by pseudorandom numbers. * @param size number of 128-bit pseudorandom numbers to be generated. */ inline static void gen_rand_array_c0o1(dsfmt_t *dsfmt, dw128_t *array, int size) { int i, j; dw128_t lung; lung = dsfmt->status[DSFMT_N]; do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { do_recursion(&array[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], &lung); } for (; i < DSFMT_N; i++) { do_recursion(&array[i], &dsfmt->status[i], &array[i + DSFMT_POS1 - DSFMT_N], &lung); } for (; i < size - DSFMT_N; i++) { do_recursion(&array[i], &array[i - DSFMT_N], &array[i + DSFMT_POS1 - DSFMT_N], &lung); convert_c0o1(&array[i - DSFMT_N]); } for (j = 0; j < 2 * DSFMT_N - size; j++) { dsfmt->status[j] = array[j + size - DSFMT_N]; } for (; i < size; i++, j++) { do_recursion(&array[i], &array[i - DSFMT_N], &array[i + DSFMT_POS1 - DSFMT_N], &lung); dsfmt->status[j] = array[i]; convert_c0o1(&array[i - DSFMT_N]); } for (i = size - DSFMT_N; i < size; i++) { convert_c0o1(&array[i]); } dsfmt->status[DSFMT_N] = lung; } /** * This function fills the user-specified array with double precision * floating point pseudorandom numbers of the IEEE 754 format. * @param dsfmt dsfmt state vector. * @param array an 128-bit array to be filled by pseudorandom numbers. * @param size number of 128-bit pseudorandom numbers to be generated. */ inline static void gen_rand_array_o0o1(dsfmt_t *dsfmt, dw128_t *array, int size) { int i, j; dw128_t lung; lung = dsfmt->status[DSFMT_N]; do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { do_recursion(&array[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], &lung); } for (; i < DSFMT_N; i++) { do_recursion(&array[i], &dsfmt->status[i], &array[i + DSFMT_POS1 - DSFMT_N], &lung); } for (; i < size - DSFMT_N; i++) { do_recursion(&array[i], &array[i - DSFMT_N], &array[i + DSFMT_POS1 - DSFMT_N], &lung); convert_o0o1(&array[i - DSFMT_N]); } for (j = 0; j < 2 * DSFMT_N - size; j++) { dsfmt->status[j] = array[j + size - DSFMT_N]; } for (; i < size; i++, j++) { do_recursion(&array[i], &array[i - DSFMT_N], &array[i + DSFMT_POS1 - DSFMT_N], &lung); dsfmt->status[j] = array[i]; convert_o0o1(&array[i - DSFMT_N]); } for (i = size - DSFMT_N; i < size; i++) { convert_o0o1(&array[i]); } dsfmt->status[DSFMT_N] = lung; } /** * This function fills the user-specified array with double precision * floating point pseudorandom numbers of the IEEE 754 format. * @param dsfmt dsfmt state vector. * @param array an 128-bit array to be filled by pseudorandom numbers. * @param size number of 128-bit pseudorandom numbers to be generated. */ inline static void gen_rand_array_o0c1(dsfmt_t *dsfmt, dw128_t *array, int size) { int i, j; dw128_t lung; lung = dsfmt->status[DSFMT_N]; do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { do_recursion(&array[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], &lung); } for (; i < DSFMT_N; i++) { do_recursion(&array[i], &dsfmt->status[i], &array[i + DSFMT_POS1 - DSFMT_N], &lung); } for (; i < size - DSFMT_N; i++) { do_recursion(&array[i], &array[i - DSFMT_N], &array[i + DSFMT_POS1 - DSFMT_N], &lung); convert_o0c1(&array[i - DSFMT_N]); } for (j = 0; j < 2 * DSFMT_N - size; j++) { dsfmt->status[j] = array[j + size - DSFMT_N]; } for (; i < size; i++, j++) { do_recursion(&array[i], &array[i - DSFMT_N], &array[i + DSFMT_POS1 - DSFMT_N], &lung); dsfmt->status[j] = array[i]; convert_o0c1(&array[i - DSFMT_N]); } for (i = size - DSFMT_N; i < size; i++) { convert_o0c1(&array[i]); } dsfmt->status[DSFMT_N] = lung; } /** * This function represents a function used in the initialization * by init_by_array * @param x 32-bit integer * @return 32-bit integer */ static uint32_t ini_func1(uint32_t x) { return (x ^ (x >> 27)) * (uint32_t)1664525UL; } /** * This function represents a function used in the initialization * by init_by_array * @param x 32-bit integer * @return 32-bit integer */ static uint32_t ini_func2(uint32_t x) { return (x ^ (x >> 27)) * (uint32_t)1566083941UL; } /** * This function initializes the internal state array to fit the IEEE * 754 format. * @param dsfmt dsfmt state vector. */ static void initial_mask(dsfmt_t *dsfmt) { int i; uint64_t *psfmt; psfmt = &dsfmt->status[0].u[0]; for (i = 0; i < DSFMT_N * 2; i++) { psfmt[i] = (psfmt[i] & DSFMT_LOW_MASK) | DSFMT_HIGH_CONST; } } /** * This function certificate the period of 2^{SFMT_MEXP}-1. * @param dsfmt dsfmt state vector. */ static void period_certification(dsfmt_t *dsfmt) { uint64_t pcv[2] = {DSFMT_PCV1, DSFMT_PCV2}; uint64_t tmp[2]; uint64_t inner; int i; #if (DSFMT_PCV2 & 1) != 1 int j; uint64_t work; #endif tmp[0] = (dsfmt->status[DSFMT_N].u[0] ^ DSFMT_FIX1); tmp[1] = (dsfmt->status[DSFMT_N].u[1] ^ DSFMT_FIX2); inner = tmp[0] & pcv[0]; inner ^= tmp[1] & pcv[1]; for (i = 32; i > 0; i >>= 1) { inner ^= inner >> i; } inner &= 1; /* check OK */ if (inner == 1) { return; } /* check NG, and modification */ #if (DSFMT_PCV2 & 1) == 1 dsfmt->status[DSFMT_N].u[1] ^= 1; #else for (i = 1; i >= 0; i--) { work = 1; for (j = 0; j < 64; j++) { if ((work & pcv[i]) != 0) { dsfmt->status[DSFMT_N].u[i] ^= work; return; } work = work << 1; } } #endif return; } /*---------------- PUBLIC FUNCTIONS ----------------*/ /** * This function returns the identification string. The string shows * the Mersenne exponent, and all parameters of this generator. * @return id string. */ const char *dsfmt_get_idstring(void) { return DSFMT_IDSTR; } /** * This function returns the minimum size of array used for \b * fill_array functions. * @return minimum size of array used for fill_array functions. */ int dsfmt_get_min_array_size(void) { return DSFMT_N64; } /** * This function fills the internal state array with double precision * floating point pseudorandom numbers of the IEEE 754 format. * @param dsfmt dsfmt state vector. */ void dsfmt_gen_rand_all(dsfmt_t *dsfmt) { int i; dw128_t lung; lung = dsfmt->status[DSFMT_N]; do_recursion(&dsfmt->status[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { do_recursion(&dsfmt->status[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], &lung); } for (; i < DSFMT_N; i++) { do_recursion(&dsfmt->status[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1 - DSFMT_N], &lung); } dsfmt->status[DSFMT_N] = lung; } /** * This function generates double precision floating point * pseudorandom numbers which distribute in the range [1, 2) to the * specified array[] by one call. The number of pseudorandom numbers * is specified by the argument \b size, which must be at least (SFMT_MEXP * / 128) * 2 and a multiple of two. The function * get_min_array_size() returns this minimum size. The generation by * this function is much faster than the following fill_array_xxx functions. * * For initialization, init_gen_rand() or init_by_array() must be called * before the first call of this function. This function can not be * used after calling genrand_xxx functions, without initialization. * * @param dsfmt dsfmt state vector. * @param array an array where pseudorandom numbers are filled * by this function. The pointer to the array must be "aligned" * (namely, must be a multiple of 16) in the SIMD version, since it * refers to the address of a 128-bit integer. In the standard C * version, the pointer is arbitrary. * * @param size the number of 64-bit pseudorandom integers to be * generated. size must be a multiple of 2, and greater than or equal * to (SFMT_MEXP / 128) * 2. * * @note \b memalign or \b posix_memalign is available to get aligned * memory. Mac OSX doesn't have these functions, but \b malloc of OSX * returns the pointer to the aligned memory block. */ void dsfmt_fill_array_close1_open2(dsfmt_t *dsfmt, double array[], int size) { assert(size % 2 == 0); assert(size >= DSFMT_N64); gen_rand_array_c1o2(dsfmt, (dw128_t *)array, size / 2); } /** * This function generates double precision floating point * pseudorandom numbers which distribute in the range (0, 1] to the * specified array[] by one call. This function is the same as * fill_array_close1_open2() except the distribution range. * * @param dsfmt dsfmt state vector. * @param array an array where pseudorandom numbers are filled * by this function. * @param size the number of pseudorandom numbers to be generated. * see also \sa fill_array_close1_open2() */ void dsfmt_fill_array_open_close(dsfmt_t *dsfmt, double array[], int size) { assert(size % 2 == 0); assert(size >= DSFMT_N64); gen_rand_array_o0c1(dsfmt, (dw128_t *)array, size / 2); } /** * This function generates double precision floating point * pseudorandom numbers which distribute in the range [0, 1) to the * specified array[] by one call. This function is the same as * fill_array_close1_open2() except the distribution range. * * @param array an array where pseudorandom numbers are filled * by this function. * @param dsfmt dsfmt state vector. * @param size the number of pseudorandom numbers to be generated. * see also \sa fill_array_close1_open2() */ void dsfmt_fill_array_close_open(dsfmt_t *dsfmt, double array[], int size) { assert(size % 2 == 0); assert(size >= DSFMT_N64); gen_rand_array_c0o1(dsfmt, (dw128_t *)array, size / 2); } /** * This function generates double precision floating point * pseudorandom numbers which distribute in the range (0, 1) to the * specified array[] by one call. This function is the same as * fill_array_close1_open2() except the distribution range. * * @param dsfmt dsfmt state vector. * @param array an array where pseudorandom numbers are filled * by this function. * @param size the number of pseudorandom numbers to be generated. * see also \sa fill_array_close1_open2() */ void dsfmt_fill_array_open_open(dsfmt_t *dsfmt, double array[], int size) { assert(size % 2 == 0); assert(size >= DSFMT_N64); gen_rand_array_o0o1(dsfmt, (dw128_t *)array, size / 2); } #if defined(__INTEL_COMPILER) # pragma warning(disable:981) #endif /** * This function initializes the internal state array with a 32-bit * integer seed. * @param dsfmt dsfmt state vector. * @param seed a 32-bit integer used as the seed. * @param mexp caller's mersenne expornent */ void dsfmt_chk_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed, int mexp) { int i; uint32_t *psfmt; /* make sure caller program is compiled with the same MEXP */ if (mexp != dsfmt_mexp) { fprintf(stderr, "DSFMT_MEXP doesn't match with dSFMT.c\n"); exit(1); } psfmt = &dsfmt->status[0].u32[0]; psfmt[idxof(0)] = seed; for (i = 1; i < (DSFMT_N + 1) * 4; i++) { psfmt[idxof(i)] = 1812433253UL * (psfmt[idxof(i - 1)] ^ (psfmt[idxof(i - 1)] >> 30)) + i; } initial_mask(dsfmt); period_certification(dsfmt); dsfmt->idx = DSFMT_N64; } /** * This function initializes the internal state array, * with an array of 32-bit integers used as the seeds * @param dsfmt dsfmt state vector. * @param init_key the array of 32-bit integers, used as a seed. * @param key_length the length of init_key. * @param mexp caller's mersenne expornent */ void dsfmt_chk_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[], int key_length, int mexp) { int i, j, count; uint32_t r; uint32_t *psfmt32; int lag; int mid; int size = (DSFMT_N + 1) * 4; /* pulmonary */ /* make sure caller program is compiled with the same MEXP */ if (mexp != dsfmt_mexp) { fprintf(stderr, "DSFMT_MEXP doesn't match with dSFMT.c\n"); exit(1); } if (size >= 623) { lag = 11; } else if (size >= 68) { lag = 7; } else if (size >= 39) { lag = 5; } else { lag = 3; } mid = (size - lag) / 2; psfmt32 = &dsfmt->status[0].u32[0]; memset(dsfmt->status, 0x8b, sizeof(dsfmt->status)); if (key_length + 1 > size) { count = key_length + 1; } else { count = size; } r = ini_func1(psfmt32[idxof(0)] ^ psfmt32[idxof(mid % size)] ^ psfmt32[idxof((size - 1) % size)]); psfmt32[idxof(mid % size)] += r; r += key_length; psfmt32[idxof((mid + lag) % size)] += r; psfmt32[idxof(0)] = r; count--; for (i = 1, j = 0; (j < count) && (j < key_length); j++) { r = ini_func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % size)] ^ psfmt32[idxof((i + size - 1) % size)]); psfmt32[idxof((i + mid) % size)] += r; r += init_key[j] + i; psfmt32[idxof((i + mid + lag) % size)] += r; psfmt32[idxof(i)] = r; i = (i + 1) % size; } for (; j < count; j++) { r = ini_func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % size)] ^ psfmt32[idxof((i + size - 1) % size)]); psfmt32[idxof((i + mid) % size)] += r; r += i; psfmt32[idxof((i + mid + lag) % size)] += r; psfmt32[idxof(i)] = r; i = (i + 1) % size; } for (j = 0; j < size; j++) { r = ini_func2(psfmt32[idxof(i)] + psfmt32[idxof((i + mid) % size)] + psfmt32[idxof((i + size - 1) % size)]); psfmt32[idxof((i + mid) % size)] ^= r; r -= i; psfmt32[idxof((i + mid + lag) % size)] ^= r; psfmt32[idxof(i)] = r; i = (i + 1) % size; } initial_mask(dsfmt); period_certification(dsfmt); dsfmt->idx = DSFMT_N64; } #if defined(__INTEL_COMPILER) # pragma warning(default:981) #endif #if defined(__cplusplus) } #endif
31.40694
79
0.645791
[ "vector" ]
037f06145c1c0ce7a9932e82eaf229cabbadbac0
3,313
h
C
include/valueiterator.h
DigDeeply/PHP-CPP
778561e1739a4a7ef20e85b713b4790e6be225d3
[ "Apache-2.0" ]
1
2020-04-07T03:26:48.000Z
2020-04-07T03:26:48.000Z
include/valueiterator.h
DigDeeply/PHP-CPP
778561e1739a4a7ef20e85b713b4790e6be225d3
[ "Apache-2.0" ]
null
null
null
include/valueiterator.h
DigDeeply/PHP-CPP
778561e1739a4a7ef20e85b713b4790e6be225d3
[ "Apache-2.0" ]
null
null
null
/** * ValueIterator.h * * This is an internal helper class that is used when iterating over a * Php::Value object - stl style. * * Thus, when you do c++ things like "for (auto &iter : value)", internally * a ValueIterator object is being used. * * @author Emiel Bruijntjes * @copyright 2014 Copernica BV */ /** * Forward declaration */ struct _hashtable; struct bucket; /** * Set up namespace */ namespace Php { /** * Class definition */ class ValueIterator { public: /** * Constructor * @param hashtable The hashtable to iterate over * @param first Should it start on the first position? */ ValueIterator(struct _hashtable *hashtable, bool first); /** * Copy constructor * @param that */ ValueIterator(const ValueIterator &that); /** * Destructor */ virtual ~ValueIterator() {} /** * Increment position (pre-increment) * @return ValueIterator */ ValueIterator &operator++(); /** * Increment position (post-increment) * @return ValueIterator */ ValueIterator operator++(int) { // make a copy ValueIterator copy(*this); // increment current object ++(*this); // and return the unchanged original return copy; } /** * Decrement position (pre-decrement) * @return ValueIterator */ ValueIterator &operator--(); /** * Increment position (post-decrement) * @return ValueIterator */ ValueIterator operator--(int) { // make a copy ValueIterator copy(*this); // decrement current object --(*this); // and return the unchanged original return copy; } /** * Compare with other iterator * @param that * @return bool */ bool operator==(const ValueIterator &that) const { return _position == that._position; } /** * Compare with other iterator * @param that * @return bool */ bool operator!=(const ValueIterator &that) const { return _position != that._position; } /** * Derefecence, this returns a std::pair with the current key and value * @return std::pair */ const std::pair<Value,Value> &operator*() const { return _current; } /** * Dereference, this returns a std::pair with the current key and value * @return std::pair */ const std::pair<Value,Value> *operator->() const { return &_current; } private: /** * The hash table over which is being iterated * @var HashTable */ struct _hashtable *_table = nullptr; /** * The position in the hash table * @var HashPosition */ struct bucket *_position = nullptr; /** * The current key and value * @var std::pair */ std::pair<Value,Value> _current; /** * Read current key and value * @return ValueIterator */ ValueIterator &read(); /** * Invalidate the iterator * @return ValueIterator */ ValueIterator &invalidate(); }; /** * End namespace */ }
19.720238
76
0.550558
[ "object" ]
038c41731a2ccf0912ddd280db1d503f081b955a
16,733
c
C
klic/compiler/atom.c
GunterMueller/KLIC
75e541269b4ad0bb6e23b73e7310f626b59830d2
[ "Xnet", "X11" ]
5
2020-02-02T04:51:16.000Z
2022-01-16T01:32:13.000Z
klic/compiler/atom.c
GunterMueller/KLIC
75e541269b4ad0bb6e23b73e7310f626b59830d2
[ "Xnet", "X11" ]
1
2021-08-04T13:33:53.000Z
2021-08-04T13:33:53.000Z
klic/compiler/atom.c
GunterMueller/KLIC
75e541269b4ad0bb6e23b73e7310f626b59830d2
[ "Xnet", "X11" ]
3
2020-10-18T23:08:38.000Z
2021-02-21T05:13:33.000Z
#include <klic/basic.h> unsigned char * Const init_atomname[] = { (unsigned char *)"call", (unsigned char *)"element", (unsigned char *)"size", (unsigned char *)"set_element", (unsigned char *)"split", (unsigned char *)"join", (unsigned char *)"vector", (unsigned char *)"string", (unsigned char *)"element_size", (unsigned char *)"search_character", (unsigned char *)"less_than", (unsigned char *)"not_less_than", (unsigned char *)"estring", (unsigned char *)"print", (unsigned char *)"int", (unsigned char *)"sin", (unsigned char *)"cos", (unsigned char *)"tan", (unsigned char *)"asin", (unsigned char *)"acos", (unsigned char *)"atan", (unsigned char *)"sinh", (unsigned char *)"cosh", (unsigned char *)"tanh", (unsigned char *)"asinh", (unsigned char *)"acosh", (unsigned char *)"atanh", (unsigned char *)"exp", (unsigned char *)"log", (unsigned char *)"sqrt", (unsigned char *)"ceil", (unsigned char *)"floor", (unsigned char *)"round", (unsigned char *)"plus", (unsigned char *)"minus", (unsigned char *)"add", (unsigned char *)"subtract", (unsigned char *)"multiply", (unsigned char *)"divide", (unsigned char *)"pow", (unsigned char *)"not_greater_than", (unsigned char *)"greater_than", (unsigned char *)"equal", (unsigned char *)"not_equal", (unsigned char *)"float", (unsigned char *)"module", (unsigned char *)"name", (unsigned char *)"arity", (unsigned char *)"apply", (unsigned char *)"predicate", (unsigned char *)"defined", (unsigned char *)"reduce", (unsigned char *)"step", (unsigned char *)"arg", (unsigned char *)"setarg", (unsigned char *)"id", (unsigned char *)"set_predicate", (unsigned char *)"normal", (unsigned char *)"get_atom", (unsigned char *)"get_atom_name", (unsigned char *)"intern", (unsigned char *)"power", (unsigned char *)"eof", (unsigned char *)"end_of_file", (unsigned char *)"[", (unsigned char *)"{", (unsigned char *)" (", (unsigned char *)"(", (unsigned char *)"-", (unsigned char *)"]", (unsigned char *)"never", (unsigned char *)"}", (unsigned char *)")", (unsigned char *)"|", (unsigned char *)",", (unsigned char *)"fx", (unsigned char *)"fy", (unsigned char *)"xfx", (unsigned char *)"xfy", (unsigned char *)"yfx", (unsigned char *)"xf", (unsigned char *)"yf", (unsigned char *)"none", (unsigned char *)"yes", (unsigned char *)"no", (unsigned char *)"abnormal", (unsigned char *)"variable", (unsigned char *)"error", (unsigned char *)"number", (unsigned char *)"integer", (unsigned char *)"floating_point", (unsigned char *)"prefix", (unsigned char *)"infix", (unsigned char *)"ops", (unsigned char *)"postfix", (unsigned char *)"op", (unsigned char *)"atom", (unsigned char *)"list", (unsigned char *)"functor", (unsigned char *)"!", (unsigned char *)";", (unsigned char *)"void", (unsigned char *)"escaped_newline", (unsigned char *)"hexadecimal", (unsigned char *)"getc", (unsigned char *)"vtab", (unsigned char *)"=", (unsigned char *)"var", (unsigned char *)"octal", (unsigned char *)"ungetc", (unsigned char *)"stderr", (unsigned char *)"linecount", (unsigned char *)"putc", (unsigned char *)"fwrite", (unsigned char *)"fflush", (unsigned char *)"s", (unsigned char *)"open", (unsigned char *)"unknown", (unsigned char *)"nl", (unsigned char *)"&", (unsigned char *)"?-", (unsigned char *)"implicit", (unsigned char *)"local_implicit", (unsigned char *)"mode", (unsigned char *)"nospy", (unsigned char *)"public", (unsigned char *)"spy", (unsigned char *)"with_macro", (unsigned char *)"~", (unsigned char *)"$~", (unsigned char *)"\\+", (unsigned char *)"#", (unsigned char *)"$$:=", (unsigned char *)"$$<", (unsigned char *)"$$<=", (unsigned char *)"$$=:=", (unsigned char *)"$$=<", (unsigned char *)"$$=\\=", (unsigned char *)"$$>", (unsigned char *)"$$>=", (unsigned char *)"$:=", (unsigned char *)"$<", (unsigned char *)"$<=", (unsigned char *)"$=:=", (unsigned char *)"$=<", (unsigned char *)"$=\\=", (unsigned char *)"$>", (unsigned char *)"$>=", (unsigned char *)"&<", (unsigned char *)"&<=", (unsigned char *)"&=<", (unsigned char *)"&>", (unsigned char *)"&>=", (unsigned char *)"$+=", (unsigned char *)"$-=", (unsigned char *)"$*=", (unsigned char *)"$/=", (unsigned char *)"*", (unsigned char *)"**", (unsigned char *)"+", (unsigned char *)"-->", (unsigned char *)"->", (unsigned char *)"/", (unsigned char *)"//", (unsigned char *)"/\\", (unsigned char *)":", (unsigned char *)":-", (unsigned char *)"::", (unsigned char *)":=", (unsigned char *)"<", (unsigned char *)"<<", (unsigned char *)"<<=", (unsigned char *)"<=", (unsigned char *)"<==", (unsigned char *)"=..", (unsigned char *)"=:=", (unsigned char *)"=<", (unsigned char *)"==", (unsigned char *)"=>", (unsigned char *)"=\\=", (unsigned char *)">", (unsigned char *)">=", (unsigned char *)"+=", (unsigned char *)"-=", (unsigned char *)"*=", (unsigned char *)"/=", (unsigned char *)">>", (unsigned char *)"@", (unsigned char *)"@<", (unsigned char *)"@=<", (unsigned char *)"@>", (unsigned char *)"@>=", (unsigned char *)"\\/", (unsigned char *)"\\=", (unsigned char *)"\\==", (unsigned char *)"^", (unsigned char *)"is", (unsigned char *)"mod", (unsigned char *)"xor", (unsigned char *)"++", (unsigned char *)"--", (unsigned char *)"stdin", (unsigned char *)"stdout", (unsigned char *)"read_open", (unsigned char *)"write_open", (unsigned char *)"append_open", (unsigned char *)"update_open", (unsigned char *)"unix", (unsigned char *)"string_output", (unsigned char *)"string_input", (unsigned char *)"gett", (unsigned char *)"getwt", (unsigned char *)"putt", (unsigned char *)"puttq", (unsigned char *)"putwt", (unsigned char *)"putwtq", (unsigned char *)"addop", (unsigned char *)"rmop", (unsigned char *)"on_error", (unsigned char *)"connect", (unsigned char *)"bind", (unsigned char *)"accept", (unsigned char *)"connect2", (unsigned char *)"accept2", (unsigned char *)"sym", (unsigned char *)"unparser", (unsigned char *)"unparse", (unsigned char *)"unwparse", (unsigned char *)"qtd", (unsigned char *)"alf", (unsigned char *)"do", (unsigned char *)"empty", (unsigned char *)"put", (unsigned char *)"get", (unsigned char *)"get_if_any", (unsigned char *)"get_all", (unsigned char *)"carbon_copy", (unsigned char *)"get_max_if_any", (unsigned char *)"get_min_if_any", (unsigned char *)"get_if_any_and_put", (unsigned char *)"get_and_put_if_any", (unsigned char *)"get_and_put", (unsigned char *)"comparator", (unsigned char *)"sort", (unsigned char *)"pool", (unsigned char *)"n", (unsigned char *)"time", (unsigned char *)"signal_stream", (unsigned char *)"pipe", (unsigned char *)"system", (unsigned char *)"cd", (unsigned char *)"unlink", (unsigned char *)"mktemp", (unsigned char *)"access", (unsigned char *)"chmod", (unsigned char *)"umask", (unsigned char *)"getenv", (unsigned char *)"putenv", (unsigned char *)"kill", (unsigned char *)"fork", (unsigned char *)"fork_with_pipes", (unsigned char *)"inet", (unsigned char *)"fread", (unsigned char *)"feof", (unsigned char *)"sync", (unsigned char *)"parent", (unsigned char *)"child", (unsigned char *)"fseek", (unsigned char *)"ftell", (unsigned char *)"fclose", (unsigned char *)"stdio", (unsigned char *)"flush", (unsigned char *)"puts", (unsigned char *)"bind_mcast", (unsigned char *)"send_mcast", (unsigned char *)"builtin", (unsigned char *)"integer_arithmetics", (unsigned char *)"floating_arithmetics", (unsigned char *)"bblt_add", (unsigned char *)"bblt_sub", (unsigned char *)"bblt_mult", (unsigned char *)"bblt_div", (unsigned char *)"modulo", (unsigned char *)"bblt_mod", (unsigned char *)"and", (unsigned char *)"bblt_and", (unsigned char *)"or", (unsigned char *)"bblt_or", (unsigned char *)"exclusive_or", (unsigned char *)"bblt_exclusive_or", (unsigned char *)"shift_left", (unsigned char *)"bblt_lshift", (unsigned char *)"shift_right", (unsigned char *)"bblt_rshift", (unsigned char *)"complement", (unsigned char *)"bblt_complement", (unsigned char *)"bblt_plus", (unsigned char *)"bblt_minus", (unsigned char *)"floating_point_add", (unsigned char *)"bblt_float_add", (unsigned char *)"floating_point_subtract", (unsigned char *)"bblt_float_sub", (unsigned char *)"floating_point_multiply", (unsigned char *)"bblt_float_mult", (unsigned char *)"floating_point_divide", (unsigned char *)"bblt_float_div", (unsigned char *)"floating_point_power", (unsigned char *)"bblt_float_pow", (unsigned char *)"floating_point_sin", (unsigned char *)"bblt_float_sin", (unsigned char *)"floating_point_cos", (unsigned char *)"bblt_float_cos", (unsigned char *)"floating_point_tan", (unsigned char *)"bblt_float_tan", (unsigned char *)"floating_point_asin", (unsigned char *)"bblt_float_asin", (unsigned char *)"floating_point_acos", (unsigned char *)"bblt_float_acos", (unsigned char *)"floating_point_atan", (unsigned char *)"bblt_float_atan", (unsigned char *)"floating_point_sinh", (unsigned char *)"bblt_float_sinh", (unsigned char *)"floating_point_cosh", (unsigned char *)"bblt_float_cosh", (unsigned char *)"floating_point_tanh", (unsigned char *)"bblt_float_tanh", (unsigned char *)"floating_point_exp", (unsigned char *)"bblt_float_exp", (unsigned char *)"floating_point_log", (unsigned char *)"bblt_float_log", (unsigned char *)"floating_point_sqrt", (unsigned char *)"bblt_float_sqrt", (unsigned char *)"floating_point_ceil", (unsigned char *)"bblt_float_ceil", (unsigned char *)"floating_point_floor", (unsigned char *)"bblt_float_floor", (unsigned char *)"floating_point_to_integer", (unsigned char *)"bblt_fix", (unsigned char *)"current_node", (unsigned char *)"bblt_current_node", (unsigned char *)"object", (unsigned char *)"gblt_hash", (unsigned char *)"gblt_deep_hash", (unsigned char *)"gblt_compare", (unsigned char *)"gblt_current_prio", (unsigned char *)"gblt_wait", (unsigned char *)"gblt_list", (unsigned char *)"gblt_atom", (unsigned char *)"gblt_integer", (unsigned char *)"atomic", (unsigned char *)"gblt_atomic", (unsigned char *)"gblt_float", (unsigned char *)"gblt_size_of_vector", (unsigned char *)"gblt_element_of_vector", (unsigned char *)"gblt_size_of_string", (unsigned char *)"gblt_element_size_of_string", (unsigned char *)"gblt_is_string", (unsigned char *)"gblt_element_of_string", (unsigned char *)"gblt_pfunctor", (unsigned char *)"gblt_arity", (unsigned char *)"any", (unsigned char *)"gblt_arg", (unsigned char *)"gblt_less", (unsigned char *)"gblt_greater_or_eq", (unsigned char *)"gblt_greater", (unsigned char *)"gblt_less_or_eq", (unsigned char *)"gblt_eq", (unsigned char *)"gblt_not_eq", (unsigned char *)"gblt_diff", (unsigned char *)"gblt_and", (unsigned char *)"gblt_or", (unsigned char *)"gblt_exclusive_or", (unsigned char *)"gblt_rshift", (unsigned char *)"gblt_lshift", (unsigned char *)"gblt_add", (unsigned char *)"gblt_subtract", (unsigned char *)"gblt_multiply", (unsigned char *)"gblt_divide", (unsigned char *)"gblt_modulo", (unsigned char *)"gblt_complement", (unsigned char *)"gblt_plus", (unsigned char *)"gblt_minus", (unsigned char *)"gblt_fix", (unsigned char *)"gblt_tag", (unsigned char *)"gblt_value", (unsigned char *)"bound", (unsigned char *)"gblt_display_console", (unsigned char *)"hash", (unsigned char *)"compare", (unsigned char *)"current_priority", (unsigned char *)"wait", (unsigned char *)"vector_element", (unsigned char *)"string_element", (unsigned char *)"diff", (unsigned char *)"tag_and_value", (unsigned char *)"display_console", (unsigned char *)"put_console", (unsigned char *)"$", (unsigned char *)"interrupt", (unsigned char *)"e", (unsigned char *)"otherwise", (unsigned char *)"alternatively", (unsigned char *)"head", (unsigned char *)"cdr", (unsigned char *)"car", (unsigned char *)"inline", (unsigned char *)"new", (unsigned char *)"generic", (unsigned char *)"lower_priority", (unsigned char *)"lab", (unsigned char *)"a", (unsigned char *)"clause", (unsigned char *)"il", (unsigned char *)"gg", (unsigned char *)"gp", (unsigned char *)"gb", (unsigned char *)"$macroexpanded", (unsigned char *)"gcall", (unsigned char *)"xcall", (unsigned char *)"priority", (unsigned char *)"node", (unsigned char *)"xpcall", (unsigned char *)"pcall", (unsigned char *)"xlcall", (unsigned char *)"lcall", (unsigned char *)"xthrow", (unsigned char *)"throw", (unsigned char *)"rename", (unsigned char *)"mkfunct", (unsigned char *)"mkvect", (unsigned char *)"cons", (unsigned char *)"version 3.005", (unsigned char *)"Thu Feb 13 17:11:01 JST 2003", (unsigned char *)"end_sw", (unsigned char *)"funct", (unsigned char *)"abs", (unsigned char *)"rel", (unsigned char *)"qp", (unsigned char *)"known", (unsigned char *)"other", (unsigned char *)"alter", (unsigned char *)"l", (unsigned char *)"x", (unsigned char *)"if_ref", (unsigned char *)"if_not_ref", (unsigned char *)"v", (unsigned char *)"deref", (unsigned char *)"sw_tag", (unsigned char *)"case_label", (unsigned char *)"if_not_int", (unsigned char *)"if_int", (unsigned char *)"f", (unsigned char *)"o", (unsigned char *)"if_not_gobj", (unsigned char *)"if_not_class", (unsigned char *)"goto", (unsigned char *)"if_not", (unsigned char *)"if_funct_not", (unsigned char *)"sw_sym", (unsigned char *)"sw_int", (unsigned char *)"sw_funct", (unsigned char *)"case_sym", (unsigned char *)"case_int", (unsigned char *)"case_funct", (unsigned char *)"label", (unsigned char *)"gblt_pred", (unsigned char *)"guard_generic", (unsigned char *)"eq", (unsigned char *)"if_not_eq", (unsigned char *)"load_generic_arg", (unsigned char *)"make_cons", (unsigned char *)"make_functor", (unsigned char *)"alloc_functor_id", (unsigned char *)"make_vector", (unsigned char *)"const", (unsigned char *)"alloc_value", (unsigned char *)"alloc_const", (unsigned char *)"exec", (unsigned char *)"execute", (unsigned char *)"proceed", (unsigned char *)"bblt", (unsigned char *)"push_goal", (unsigned char *)"gnew", (unsigned char *)"new_generic", (unsigned char *)"call_generic", (unsigned char *)"throw_goal", (unsigned char *)"set_pred", (unsigned char *)"ext", (unsigned char *)"heappos", (unsigned char *)"set_ext_pred", (unsigned char *)"enq_at_prio_no_check", (unsigned char *)"enq_at_prio", (unsigned char *)"enq_at_lower_prio_no_check", (unsigned char *)"enq_at_lower_prio", (unsigned char *)"alloc_var", (unsigned char *)"make_space", (unsigned char *)"unify_value", (unsigned char *)"unify", (unsigned char *)"set_const", (unsigned char *)"set_value", (unsigned char *)"set_newvar", (unsigned char *)"store_generic_arg", (unsigned char *)"load_const", (unsigned char *)"get_elem", (unsigned char *)"load_newvar", (unsigned char *)"move", (unsigned char *)"r", (unsigned char *)"guse", (unsigned char *)"set_qp", (unsigned char *)"case_default", (unsigned char *)"clear_reason", (unsigned char *)"user_error", (unsigned char *)"alloc_elem", (unsigned char *)"if_list", (unsigned char *)"if_not_list", (unsigned char *)"if_funct", (unsigned char *)"if_not_funct", (unsigned char *)"set_elem", (unsigned char *)"gblt", (unsigned char *)"equiv", (unsigned char *)"info", (unsigned char *)"class", (unsigned char *)"pred", (unsigned char *)"true", (unsigned char *)"functor_table", (unsigned char *)"merge", (unsigned char *)"builtin_utility", (unsigned char *)"g", (unsigned char *)"`", (unsigned char *)"``", (unsigned char *)"c", (unsigned char *)"key", (unsigned char *)"lf", (unsigned char *)"cr", (unsigned char *)"b", (unsigned char *)"fix", (unsigned char *)"expanded", (unsigned char *)"unbound", (unsigned char *)"new_functor", (unsigned char *)"set_string_element", (unsigned char *)"set_vector_element", (unsigned char *)"new_string", (unsigned char *)"new_vector", (unsigned char *)"predicate_to_code", (unsigned char *)"string_less_than", (unsigned char *)"string_not_less_than", (unsigned char *)"code", (unsigned char *)"general", (unsigned char *)"\\", (unsigned char *)"byte_string", (unsigned char *)"inputfile", (unsigned char *)"fileopen", (unsigned char *)"fileoutput", (unsigned char *)"compiling_module", (unsigned char *)"compiling_predicate", (unsigned char *)"ambiguous", (unsigned char *)"token", (unsigned char *)"was", (unsigned char *)"found", (unsigned char *)"end", (unsigned char *)"$VAR", (unsigned char *)"with", }; Const unsigned long initial_atoms = 562; unsigned char **atomname = (unsigned char **)init_atomname;
29.459507
59
0.648718
[ "object", "vector" ]
03928e789cea124ca09c81024c1565eb7fe7440d
1,335
h
C
ClassicStartSrc/ClassicExplorer/ClassicCopyExt.h
Duzzy-ExoDuus/Classic-Start
8b70f64b5bceeadfa4e5599b299a856c1e452e80
[ "MIT" ]
1
2018-07-19T20:59:32.000Z
2018-07-19T20:59:32.000Z
ClassicStartSrc/ClassicExplorer/ClassicCopyExt.h
Duzzy-ExoDuus/Classic-Start
8b70f64b5bceeadfa4e5599b299a856c1e452e80
[ "MIT" ]
null
null
null
ClassicStartSrc/ClassicExplorer/ClassicCopyExt.h
Duzzy-ExoDuus/Classic-Start
8b70f64b5bceeadfa4e5599b299a856c1e452e80
[ "MIT" ]
null
null
null
// Classic Shell (c) 2009-2017, Ivo Beltchev // Classic Start (c) 2017-2018, The Passionate-Coder Team // Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author // ClassicCopyExt.h : Declaration of the CClassicCopyExt #pragma once #include "resource.h" // main symbols #include "ClassicExplorer_i.h" #include <vector> // CClassicCopyExt class ATL_NO_VTABLE CClassicCopyExt : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CClassicCopyExt, &CLSID_ClassicCopyExt>, public IShellExtInit, public IContextMenu { public: CClassicCopyExt() { } static HRESULT WINAPI UpdateRegistry( BOOL bRegister ); DECLARE_NOT_AGGREGATABLE(CClassicCopyExt) BEGIN_COM_MAP(CClassicCopyExt) COM_INTERFACE_ENTRY(IShellExtInit) COM_INTERFACE_ENTRY(IContextMenu) END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } public: // IShellExtInit STDMETHODIMP Initialize(PCIDLIST_ABSOLUTE, LPDATAOBJECT, HKEY); // IContextMenu STDMETHODIMP GetCommandString(UINT_PTR, UINT, UINT*, LPSTR, UINT); STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO); STDMETHODIMP QueryContextMenu(HMENU, UINT, UINT, UINT, UINT); }; OBJECT_ENTRY_AUTO(__uuidof(ClassicCopyExt), CClassicCopyExt)
22.25
125
0.790262
[ "vector" ]
0392a6d7c78e33c68b1818a468c8c5efa92d7f66
8,841
h
C
dependancies/include/gtkmm/gtkmm/bin.h
Illation/synthesizer
da77d55c1c69829bbad76d0c14b9c56a5261b642
[ "MIT" ]
2
2020-03-24T09:46:35.000Z
2020-06-16T01:42:46.000Z
dependancies/include/gtkmm/gtkmm/bin.h
Illation/synthesizer
da77d55c1c69829bbad76d0c14b9c56a5261b642
[ "MIT" ]
null
null
null
dependancies/include/gtkmm/gtkmm/bin.h
Illation/synthesizer
da77d55c1c69829bbad76d0c14b9c56a5261b642
[ "MIT" ]
null
null
null
// Generated by gmmproc 2.54.0 -- DO NOT MODIFY! #ifndef _GTKMM_BIN_H #define _GTKMM_BIN_H #include <glibmm/ustring.h> #include <sigc++/sigc++.h> /* * Copyright (C) 1998-2002 The gtkmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <gtkmm/container.h> #ifndef DOXYGEN_SHOULD_SKIP_THIS using GtkBin = struct _GtkBin; using GtkBinClass = struct _GtkBinClass; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ #ifndef DOXYGEN_SHOULD_SKIP_THIS namespace Gtk { class Bin_Class; } // namespace Gtk #endif //DOXYGEN_SHOULD_SKIP_THIS namespace Gtk { //TODO: Add an add_pixbuf() method? /** A container with just one child. * * This is an abstract base class from which all classes holding * up to 1 widget inside of them derive. It provides access to methods * relevent to a single object, such as add_label, etc. * * @ingroup Widgets */ class Bin : public Container { public: #ifndef DOXYGEN_SHOULD_SKIP_THIS typedef Bin CppObjectType; typedef Bin_Class CppClassType; typedef GtkBin BaseObjectType; typedef GtkBinClass BaseClassType; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ Bin(Bin&& src) noexcept; Bin& operator=(Bin&& src) noexcept; // noncopyable Bin(const Bin&) = delete; Bin& operator=(const Bin&) = delete; ~Bin() noexcept override; #ifndef DOXYGEN_SHOULD_SKIP_THIS private: friend class Bin_Class; static CppClassType bin_class_; protected: explicit Bin(const Glib::ConstructParams& construct_params); explicit Bin(GtkBin* castitem); #endif /* DOXYGEN_SHOULD_SKIP_THIS */ public: /** Get the GType for this class, for use with the underlying GObject type system. */ static GType get_type() G_GNUC_CONST; #ifndef DOXYGEN_SHOULD_SKIP_THIS static GType get_base_type() G_GNUC_CONST; #endif ///Provides access to the underlying C GtkObject. GtkBin* gobj() { return reinterpret_cast<GtkBin*>(gobject_); } ///Provides access to the underlying C GtkObject. const GtkBin* gobj() const { return reinterpret_cast<GtkBin*>(gobject_); } public: //C++ methods used to invoke GTK+ virtual functions: protected: //GTK+ Virtual Functions (override these to change behaviour): //Default Signal Handlers:: private: protected: /** This constructor is protected because only derived * classes should be instantiated. */ Bin(); public: /** Gets the child of the Gtk::Bin, or <tt>nullptr</tt> if the bin contains * no child widget. The returned widget does not have a reference * added, so you do not need to unref it. * * @return Pointer to child of the Gtk::Bin. */ Gtk::Widget* get_child(); /** Gets the child of the Gtk::Bin, or <tt>nullptr</tt> if the bin contains * no child widget. The returned widget does not have a reference * added, so you do not need to unref it. * * @return Pointer to child of the Gtk::Bin. */ const Gtk::Widget* get_child() const; /** Remove the contained widget. * Since this can only hold one widget it is not necessary to * specify which widget to remove like other containers. * * Sometimes when a widget is added to a Gtk::ScrolledWindow, a Gtk::Viewport * is created and inserted between the ScrolledWindow and the added widget. * If the child is such an automatically created Viewport, remove() removes * the Viewport's child from the Viewport, and removes the Viewport from the * ScrolledWindow. The Viewport is destroyed. */ void remove(); //Convenience methods that don't correspond to GTK+ functions: #ifndef GTKMM_DISABLE_DEPRECATED /** Add a Label object. * This does not correspond to any GTK+ function and is provided purely for * convenience. * @param label The text for the label. * @param mnemonic If <tt>true</tt>, characters preceded by an underscore * (_) will be underlined and used as a keyboard accelerator (shortcut). * @param x_align The horizontal alignment of the text. This ranges from * 0.0 (left aligned) to 1.0 (right aligned). * @param y_align The vertical alignment of the text. This ranges from * 0.0 (top aligned) to 1.0 (bottom aligned). * * @deprecated Use the other add_label(). */ void add_label(const Glib::ustring& label, bool mnemonic = false, double x_align = 0.5, double y_align = 0.5); #endif // GTKMM_DISABLE_DEPRECATED /** Add a Label object. * This does not correspond to any GTK+ function and is provided purely for * convenience. * @param label The label text. * @param mnemonic If <tt>true</tt>, characters preceded by an underscore * (_) will be underlined and used as a keyboard accelerator (shortcut). * @param x_align The horizontal alignment of the text. For possible * values, see Gtk::Align. * @param y_align The vertical alignment of the text. For possible * values, see Gtk::Align. */ #ifndef GTKMM_DISABLE_DEPRECATED void add_label(const Glib::ustring& label, bool mnemonic, Align x_align, Align y_align = ALIGN_CENTER); #else void add_label(const Glib::ustring& label, bool mnemonic = false, Align x_align = ALIGN_CENTER, Align y_align = ALIGN_CENTER); #endif // GTKMM_DISABLE_DEPRECATED //TODO: Change this to Pixbuf? /* Add Image and Label objects. * This does not correspond to any GTK+ function and is provided purely for * convenience. * This will create, manage, add, and show a new Image and Label (within a * horizontal Box) to this Bin. * @param pixmap A Glib::RefPtr to a Gdk::Pixmap. * @param mask A Glib::RefPtr to a Gdk::Bitmap. * @param label The text for the label. * @param x_align The horizontal alignment of the text in the label. * @param y_align The vertical alignment of the text in the label. */ /* void add_pixlabel(const Glib::RefPtr<Gdk::Pixmap>& pixmap, const Glib::RefPtr<Gdk::Bitmap>& mask, const Glib::ustring& label, Align x_align = ALIGN_CENTER, Align y_align = ALIGN_CENTER); */ #ifndef GTKMM_DISABLE_DEPRECATED /** Add Image and Label objects. * This does not correspond to any GTK+ function and is provided purely for * convenience. * This will create, manage, add, and show a new Image and Label (within a * horizontal Box) to this Bin. * @param pixfile The path to a file to be displayed. * @param label The text for the label. * @param x_align The horizontal alignment of the text in the label. * @param y_align The vertical alignment of the text in the label. * * @deprecated Use the other add_pixlabel(). */ void add_pixlabel(const std::string& pixfile, const Glib::ustring& label, double x_align = 0.5, double y_align = 0.5); #endif // GTKMM_DISABLE_DEPRECATED /** Add Image and Label objects. * This does not correspond to any GTK+ function and is provided purely for * convenience. * This will create, manage, add, and show a new Image and Label (within a * horizontal Box) to this Bin. * @param pixfile The path to a file to be displayed. * @param label The text for the label. * @param x_align The horizontal alignment of the text in the label. * @param y_align The vertical alignment of the text in the label. * * @newin{3,14} */ #ifndef GTKMM_DISABLE_DEPRECATED void add_pixlabel(const std::string& pixfile, const Glib::ustring& label, Align x_align, Align y_align = ALIGN_CENTER); #else void add_pixlabel(const std::string& pixfile, const Glib::ustring& label, Align x_align = ALIGN_CENTER, Align y_align = ALIGN_CENTER); #endif // GTKMM_DISABLE_DEPRECATED }; } //namespace Gtk namespace Glib { /** A Glib::wrap() method for this object. * * @param object The C instance. * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. * @result A C++ instance that wraps this C instance. * * @relates Gtk::Bin */ Gtk::Bin* wrap(GtkBin* object, bool take_copy = false); } //namespace Glib #endif /* _GTKMM_BIN_H */
31.688172
124
0.699695
[ "object" ]
03971063765a271eea445f505c639be11cccd517
18,223
h
C
libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/utilities/fsl_os_abstraction.h
oliviermartin/mbed
2f63fa7d78a264b26ea626d542ae1b19e239bb6a
[ "Apache-2.0" ]
188
2015-07-08T21:13:28.000Z
2022-01-01T09:29:33.000Z
libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/utilities/fsl_os_abstraction.h
oliviermartin/mbed
2f63fa7d78a264b26ea626d542ae1b19e239bb6a
[ "Apache-2.0" ]
239
2015-07-10T00:48:20.000Z
2017-09-21T14:04:58.000Z
libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/utilities/fsl_os_abstraction.h
oliviermartin/mbed
2f63fa7d78a264b26ea626d542ae1b19e239bb6a
[ "Apache-2.0" ]
73
2015-07-09T21:02:42.000Z
2022-01-01T09:31:26.000Z
/* * Copyright (c) 2013 - 2014, Freescale Semiconductor, 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: * * o Redistributions of source code must retain the above copyright notice, this list * of conditions and the following disclaimer. * * o 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. * * o Neither the name of Freescale Semiconductor, 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. */ #if !defined(__FSL_OS_ABSTRACTION_H__) #define __FSL_OS_ABSTRACTION_H__ #include <stdint.h> #include <stdbool.h> #include <stdlib.h> #if defined __CC_ARM #define inline __inline #endif /*! * @addtogroup os_abstraction * @{ */ /*! @brief Status values to be returned by functions. */ typedef enum { kSuccess = 0, /*!< Functions work correctly. */ kError, /*!< Functions work failed. */ kTimeout, /*!< Timeout occurs while waiting for an object. */ kIdle /*!< Can not get the object in non-blocking mode.*/ }fsl_rtos_status; /*! @brief The event flags are set or not.*/ typedef enum { kFlagNotSet = 0, /*!< The flags checked are set. */ kFlagSet /*!< The flags checked are not set. */ }event_status; /*! @brief The event flags are cleared automatically or manually.*/ typedef enum { kEventAutoClr = 0, /*!< The flags of the event will be cleared automatically. */ kEventManualClr /*!< The flags of the event will be cleared manually. */ }event_clear_type; // Temporary "fix", until the proper macros are integrated in the on-line build system #define FSL_RTOS_MBED /* Include required header file based on RTOS selection */ #if defined (FSL_RTOS_MQX) /*! @brief Macro to set message queue copy messages to internal memory or not. */ #define __FSL_RTOS_MSGQ_COPY_MSG__ 1 #include "fsl_os_abstraction_mqx.h" #elif defined (FSL_RTOS_FREE_RTOS) #define __FSL_RTOS_MSGQ_COPY_MSG__ 1 #include "fsl_os_abstraction_free_rtos.h" #elif defined (FSL_RTOS_UCOSII) #define __FSL_RTOS_MSGQ_COPY_MSG__ 1 #include "fsl_os_abstraction_ucosii.h" #elif defined (FSL_RTOS_UCOSIII) #define __FSL_RTOS_MSGQ_COPY_MSG__ 1 #include "fsl_os_abstraction_ucosiii.h" #elif defined (FSL_RTOS_CMSIS) #define __FSL_RTOS_MSGQ_COPY_MSG__ 0 #include "fsl_os_abstraction_cmsis.h" #elif defined (FSL_RTOS_MBED) #define __FSL_RTOS_MSGQ_COPY_MSG__ 1 #include "fsl_os_abstraction_mbed.h" #else #define __FSL_RTOS_MSGQ_COPY_MSG__ 1 #include "fsl_os_abstraction_bm.h" #endif /******************************************************************************* * API ******************************************************************************/ #if defined(__cplusplus) extern "C" { #endif /*! * @name Synchronization * @{ */ /*! * @brief Initialize a synchronization object to a given state. * * @param obj The sync object to initialize. * @param initValue The initial value the object will be set to. * * @retval kSuccess The object was successfully created. * @retval kError Invalid parameter or no more objects can be created. */ fsl_rtos_status sync_create(sync_object_t *obj, uint8_t initValue); /*! * @brief Wait for the synchronization object. * * This function checks the sync object's counting value, if it is * positive, decreases it and returns kSuccess, otherwise, timeout will be * used for wait. * * @param obj Pointer to the synchronization object. * @param timeout The maximum number of milliseconds to wait for the object to be signalled. * Pass the #kSyncWaitForever constant to wait indefinitely for someone to signal the object. * A value of 0 should not be passed to this function. Instead, use sync_poll for * a non blocking check. * * @retval kSuccess The object was signalled. * @retval kTimeout A timeout occurred. * @retval kError An incorrect parameter was passed. * @retval kIdle The object has not been signalled. * * @note There could be only one process waiting for the object at the same time. */ fsl_rtos_status sync_wait(sync_object_t *obj, uint32_t timeout); /*! * @brief Checks a synchronization object's status. * * This function is used to poll a sync object's status. * If the sync object's counting value is positive, decrease it and return * kSuccess. If the object's counting value is 0, the function will * return kIdle immediately * * @param obj The synchronization object. * * @retval kSuccess The object was signalled. * @retval kIdle The object was not signalled. * @retval kError An incorrect parameter was passed. */ fsl_rtos_status sync_poll(sync_object_t *obj); /*! * @brief Signal for someone waiting on the synchronization object to wake up. * * This function should not be called from an ISR. * * @param obj The synchronization object to signal. * * @retval kSuccess The object was successfully signaled. * @retval kError The object can not be signaled or invalid parameter. */ fsl_rtos_status sync_signal(sync_object_t *obj); /*! * @brief Signal for someone waiting on the synchronization object to wake up. * * This function should only be called from an ISR. * * @param obj The synchronization object to signal. * * @retval kSuccess The object was successfully signaled. * @retval kError The object can not be signaled or invalid parameter. */ fsl_rtos_status sync_signal_from_isr(sync_object_t *obj); /*! * @brief Destroy a previously created synchronization object. * * @param obj The synchronization object to destroy. * * @retval kSuccess The object was successfully destroyed. * @retval kError Object destruction failed. */ fsl_rtos_status sync_destroy(sync_object_t *obj); /* @} */ /*! * @name Resource locking * @{ */ /*! * @brief Initialize a locking object. * * @param obj The lock object to initialize. * * @retval kSuccess The lock is created successfully. * @retval kError Tke lock creation failed. */ fsl_rtos_status lock_create(lock_object_t *obj); /*! * @brief Wait for the object to be unlocked and lock it. * * This function will wait for some time or wait forever if could not get the lock. * * @param obj The locking object. * @param timeout The maximum number of milliseconds to wait for the mutex. * Pass the #kSyncWaitForever constant to wait indefinitely for someone to unlock the object. * A value of 0 should not be passed to this function. Instead, use lock_poll for a non * blocking check. * * @retval kSuccess The lock was obtained. * @retval kTimeout A timeout occurred. * @retval kError An incorrect parameter was passed. */ fsl_rtos_status lock_wait(lock_object_t *obj, uint32_t timeout); /*! * @brief Checks if a locking object can be locked and locks it if possible. * * This function returns instantly if could not get the lock. * * @param obj The locking object. * * @retval kSuccess The lock was obtained. * @retval kIdle The lock could not be obtained. * @retval kError An incorrect parameter was passed. * * @note There could be only one process waiting for the object at the same time. * For RTOSes, wait for a lock recursively by one task is not supported. * */ fsl_rtos_status lock_poll(lock_object_t *obj); /*! * @brief Unlock a previously locked object. * * @param obj The locking object to unlock. * * @retval kSuccess The object was successfully unlocked. * @retval kError The object can not be unlocked or invalid parameter. */ fsl_rtos_status lock_release(lock_object_t *obj); /*! * @brief Destroy a previously created locking object. * * @param obj The locking object to destroy. * * @retval kSuccess The object was successfully destroyed. * @retval kError Object destruction failed. */ fsl_rtos_status lock_destroy(lock_object_t *obj); /* @} */ /*! * @name Event signaling * @{ */ /*! * @brief Initializes the event object. * * When the object is created, the flags is 0. * * @param obj Pointer to the event object to initialize. * @param clearType The event is auto-clear or manual-clear. * * @retval kSuccess The object was successfully created. * @retval kError Incorrect parameter or no more objects can be created. */ fsl_rtos_status event_create(event_object_t *obj, event_clear_type clearType); /*! * @brief Wait for any event flags to be set. * * This function will wait for some time or wait forever if no flags are set. Any flags set * will wake up the function. * * @param obj The event object. * @param timeout The maximum number of milliseconds to wait for the event. * Pass the #kSyncWaitForever constant to wait indefinitely. A value of 0 should not be passed * to this function. * @param setFlags Pointer to receive the flags that were set. * * @retval kSuccess An event was set. * @retval kTimeout A timeout occurred. * @retval kError An incorrect parameter was passed. */ fsl_rtos_status event_wait(event_object_t *obj, uint32_t timeout, event_group_t *setFlags); /*! * @brief Set one or more event flags of an event object. * * This function should not be called from an ISR. * * @param obj The event object. * @param flags Event flags to be set. * * @retval kSuccess The flags were successfully set. * @retval kError An incorrect parameter was passed. * * @note There could be only one process waiting for the event. * */ fsl_rtos_status event_set(event_object_t *obj, event_group_t flags); /*! * @brief Set one or more event flags of an event object. * * This function should only be called from an ISR. * * @param obj The event object. * @param flags Event flags to be set. * * @retval kSuccess The flags were successfully set. * @retval kError An incorrect parameter was passed. */ fsl_rtos_status event_set_from_isr(event_object_t *obj, event_group_t flags); /*! * @brief Clear one or more events of an event object. * * This function should not be called from an ISR. * * @param obj The event object. * @param flags Event flags to be clear. * * @retval kSuccess The flags were successfully cleared. * @retval kError An incorrect parameter was passed. */ fsl_rtos_status event_clear(event_object_t *obj, event_group_t flags); /*! * @brief Check the flags are set or not. * * @param obj The event object. * @param flag The flag to check. * * @retval kFlagsSet The flags checked are set. * @retval kFlagsNotSet The flags checked are not set or got an error. */ event_status event_check_flags(event_object_t *obj, event_group_t flag); /*! * @brief Destroy a previously created event object. * * @param obj The event object to destroy. * * @retval kSuccess The object was successfully destroyed. * @retval kError Event destruction failed. */ fsl_rtos_status event_destroy(event_object_t *obj); /* @} */ /*! * @name Thread management * @{ */ /*! * @brief Create a task. * * This function is wrapped by the macro task_create. Generally, this function is for * internal use only, applications must use FSL_RTOS_TASK_DEFINE to define resources for * task statically then use task_create to create task. If applications have prepare * the resouces for task dynamically, they can use this function to create the task. * * @param task The task function. * @param name The name of this task. * @param stackSize The stack size in byte. * @param stackMem Pointer to the stack. For bare metal, MQX and FreeRTOS, this could be NULL. * @param priority Initial priority of the task. * @param param Pointer to be passed to the task when it is created. * @param usesFloat This task will use float register or not. * @param handler Pointer to the task handler. * * @retval kSuccess The task was successfully created. * @retval kError The task could not be created. * * @note Different tasks can not use the same task function. */ fsl_rtos_status __task_create(task_t task, uint8_t *name, uint16_t stackSize, task_stack_t *stackMem, uint16_t priority, void *param, bool usesFloat, task_handler_t *handler); /*! * @brief Destroy a previously created task. * @note Depending on the RTOS, task resources may or may not be automatically freed, * and this function may not return if the current task is destroyed. * * @param handler The handler of the task to destroy. Returned by the task_create function. * * @retval kSuccess The task was successfully destroyed. * @retval kError Task destruction failed or invalid parameter. */ fsl_rtos_status task_destroy(task_handler_t handler); /* @} */ /*! * @name Message queues * @{ */ /*! * @brief Initialize the message queue. * * This function will initialize the message queue that declared previously. * Here is an example demonstrating how to use: @code msg_queue_handler_t handler; MSG_QUEUE_DECLARE(my_message, msg_num, msg_size); handler = msg_queue_create(&my_message, msg_num, msg_size); @endcode * * @param queue The queue declared through the MSG_QUEUE_DECLARE macro. * @param number The number of elements in the queue. * @param size Size of every elements in words. * * @retval Handler to access the queue for put and get operations. If message queue * created failed, return 0. */ msg_queue_handler_t msg_queue_create(msg_queue_t *queue, uint16_t number, uint16_t size); /*! * @brief Introduce an element at the tail of the queue. * * @param handler Queue handler returned by the msg_queue_create function. * @param item Pointer to the element to be introduced in the queue. * * @retval kSuccess Element successfully introduced in the queue. * @retval kError The queue was full or an invalid parameter was passed. */ fsl_rtos_status msg_queue_put(msg_queue_handler_t handler, msg_queue_item_t item); /*! * @brief Read and remove an element at the head of the queue. * * @param handler Queue handler returned by the msg_queue_create function. * @param item Pointer to store a pointer to the element of the queue. * @param timeout In case the queue is empty, the number of milliseconds to * wait for an element to be introduced into the queue. Use 0 to return * immediately or #kSyncWaitForever to wait indefinitely. * * @retval kSuccess Element successfully obtained from the queue. * @retval kTimeout If a timeout was specified, the queue remained empty after timeout. * @retval kError The queue was empty or the handler was invalid. * @retval kIdle The queue was empty and the timeout has not expired. * * @note There should be only one process waiting on the queue. */ fsl_rtos_status msg_queue_get(msg_queue_handler_t handler, msg_queue_item_t *item, uint32_t timeout); /*! * @brief Discards all elements in the queue and leaves the queue empty. * * @param handler Queue handler returned by the msg_queue_create function. * * @retval kSuccess Queue successfully emptied. * @retval kError Emptying queue failed. */ fsl_rtos_status msg_queue_flush(msg_queue_handler_t handler); /*! * @brief Destroy a previously created queue. * * @param handler Queue handler returned by the msg_queue_create function. * * @retval kSuccess The queue was successfully destroyed. * @retval kError Message queue destruction failed. */ fsl_rtos_status msg_queue_destroy(msg_queue_handler_t handler); /* @} */ #ifndef FSL_RTOS_MBED /*! * @name Memory Management * @{ */ /*! * @brief Reserves the requested amount of memory in bytes. * * @param size Amount of bytes to reserve. * * @retval Pointer to the reserved memory. NULL if memory could not be allocated. */ void * mem_allocate(size_t size); /*! * @brief Reserves the requested amount of memory in bytes and initializes it to 0. * * @param size Amount of bytes to reserve. * * @retval Pointer to the reserved memory. NULL if memory could not be allocated. */ void * mem_allocate_zero(size_t size); /*! * @brief Releases the memory previously reserved. * * @param ptr Pointer to the start of the memory block previously reserved. * * @retval kSuccess Memory correctly released. */ fsl_rtos_status mem_free(void *ptr); #endif /* @} */ /*! * @name Time management * @{ */ /*! * @brief Delays execution for a number of milliseconds. * * @param delay The time in milliseconds to wait. */ void time_delay(uint32_t delay); /* @} */ /*! * @name Interrupt management * @{ */ /*! * @brief Install interrupt handler. * * @param irqNumber IRQ number of the interrupt. * @param handler The interrupt handler to install. * * @retval kSuccess Handler is installed successfully. * @retval kSuccess Handler could not be installed. */ fsl_rtos_status interrupt_handler_register(int32_t irqNumber, void (*handler)(void)); /* @} */ #if defined(__cplusplus) } #endif /*! @}*/ #endif /* __FSL_OS_ABSTRACTION_H__ */ /******************************************************************************* * EOF ******************************************************************************/
31.802792
100
0.713055
[ "object" ]
039a7159379a8bb95b87888fa2e1073ed5a884a2
4,445
h
C
applications/physbam/physbam-lib/Public_Library/PhysBAM_Solids/PhysBAM_Rigids/Collisions_Computations/PARTICLES_IN_IMPLICIT_OBJECT.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
20
2017-07-03T19:09:09.000Z
2021-09-10T02:53:56.000Z
applications/physbam/physbam-lib/Public_Library/PhysBAM_Solids/PhysBAM_Rigids/Collisions_Computations/PARTICLES_IN_IMPLICIT_OBJECT.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
null
null
null
applications/physbam/physbam-lib/Public_Library/PhysBAM_Solids/PhysBAM_Rigids/Collisions_Computations/PARTICLES_IN_IMPLICIT_OBJECT.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
9
2017-09-17T02:05:06.000Z
2020-01-31T00:12:01.000Z
//##################################################################### // Copyright 2010, Ronald Fedkiw, Eran Guendelman, Geoffrey Irving, Michael Lentine, Craig Schroeder, Tamar Shinar, Rachel Weinstein. // This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt. //##################################################################### // Namespace PARTICLES_IN_IMPLICIT_OBJECT //##################################################################### #ifndef __PARTICLES_IN_IMPLICIT_OBJECT__ #define __PARTICLES_IN_IMPLICIT_OBJECT__ #include <PhysBAM_Tools/Matrices/MATRIX_FORWARD.h> #include <PhysBAM_Geometry/Topology_Based_Geometry/TOPOLOGY_BASED_SIMPLEX_POLICY.h> #include <PhysBAM_Tools/Vectors/VECTOR_POLICY.h> namespace PhysBAM{ template<class TV> class RIGID_BODY; template<class TV> struct RIGID_BODY_PARTICLE_INTERSECTION; template<class T,class ID> class ARRAY_VIEW; template<class T,class ID> class ARRAY; template<class TV> class IMPLICIT_OBJECT; template<class T,int d> class VECTOR; template<class T,int m_input,int n_input> class MATRIX; template<class K,class T> class HASHTABLE; template<class TV> class GEOMETRY_PARTICLES; template<class TV,class T_ARRAY> class PARTICLE_HIERARCHY; namespace PARTICLES_IN_IMPLICIT_OBJECT { template<class TV> void Append_All_Intersections(RIGID_BODY<TV>& body1, RIGID_BODY<TV>& body2,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value,const bool use_triangle_hierarchy,const bool use_edge_intersection,const bool use_triangle_hierarchy_center_phi_test); template<class TV> void Append_All_Intersections_Points(RIGID_BODY<TV>& body1, RIGID_BODY<TV>& body2,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value); template<class TV> void Append_All_Intersections_Triangles(RIGID_BODY<TV>& body1,RIGID_BODY<TV>& body2,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value,const bool use_triangle_hierarchy_center_phi_test); template<class TV> void Append_All_Intersections_Edges(RIGID_BODY<TV>& body1,RIGID_BODY<TV>& body2,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value,const bool use_triangle_hierarchy_center_phi_test); template<class TV> void Get_Interfering_Simplices(const RIGID_BODY<TV>& body1,const RIGID_BODY<TV>& body2,ARRAY<int>& simplex_list,MATRIX<typename TV::SCALAR,TV::dimension>& rotation,TV& translation,const bool use_triangle_hierarchy_center_phi_test); template<class TV> const typename TOPOLOGY_BASED_SIMPLEX_POLICY<TV,VECTOR_POLICY<TV>::DIMMINUSONE>::HIERARCHY& Simplex_Hierarchy(const RIGID_BODY<TV>& rigid_body); template<class TV> void Intersections_Using_Hierarchy(RIGID_BODY<TV>& particle_body,RIGID_BODY<TV>& levelset_body,ARRAY<int>& simplex_list,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value,const bool exit_early,MATRIX<typename TV::SCALAR,TV::dimension>& rotation,TV& translation); template<class TV> void Intersections_Using_Hierarchy_And_Edges(RIGID_BODY<TV>& body1,RIGID_BODY<TV>& body2,ARRAY<int>& simplex_list1,ARRAY<int>& simplex_list2,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value,const bool exit_early,MATRIX<typename TV::SCALAR,TV::dimension>& rotation,TV& translation); template<class TV> void Particles_In_Implicit_Object(RIGID_BODY<TV>& particle_body,RIGID_BODY<TV>& levelset_body,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value,const bool exit_early); template<class TV> void Particles_In_Implicit_Object_Hierarchy(RIGID_BODY<TV>& particle_body,RIGID_BODY<TV>& levelset_body,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value,HASHTABLE<const GEOMETRY_PARTICLES<TV>*,const PARTICLE_HIERARCHY<TV>*>& particle_hierarchies); template<class TV> void Particles_In_Implicit_Object_Partition(RIGID_BODY<TV>& particle_body,RIGID_BODY<TV>& levelset_body,ARRAY<RIGID_BODY_PARTICLE_INTERSECTION<TV> >& particle_intersections,const typename TV::SCALAR contour_value,const bool use_particle_partition_center_phi_test,const VECTOR<int,TV::dimension>& particle_partition_size,const bool exit_early); } } #endif
82.314815
343
0.806974
[ "vector" ]
039b8ec2bcca035da2dfb8e0f790a6b61518f95b
3,832
h
C
include/java_classfile_parser/internal/constants.h
jddurand/c-java-classfile-parser
9aaa419a57b14f76ff95c65fa60ae365034f986f
[ "MIT" ]
null
null
null
include/java_classfile_parser/internal/constants.h
jddurand/c-java-classfile-parser
9aaa419a57b14f76ff95c65fa60ae365034f986f
[ "MIT" ]
null
null
null
include/java_classfile_parser/internal/constants.h
jddurand/c-java-classfile-parser
9aaa419a57b14f76ff95c65fa60ae365034f986f
[ "MIT" ]
null
null
null
#ifndef JAVA_CLASSFILE_PARSER_INTERNAL_CONSTANTS_H #define JAVA_CLASSFILE_PARSER_INTERNAL_CONSTANTS_H #define UTF8_BYTES_ConstantValue "ConstantValue" #define UTF8_BYTES_Code "Code" #define UTF8_BYTES_StackMapTable "StackMapTable" #define UTF8_BYTES_Exceptions "Exceptions" #define UTF8_BYTES_InnerClasses "InnerClasses" #define UTF8_BYTES_EnclosingMethod "EnclosingMethod" #define UTF8_BYTES_Synthetic "Synthetic" #define UTF8_BYTES_Signature "Signature" #define UTF8_BYTES_SourceFile "SourceFile" #define UTF8_BYTES_SourceDebugExtension "SourceDebugExtension" #define UTF8_BYTES_LineNumberTable "LineNumberTable" #define UTF8_BYTES_LocalVariableTable "LocalVariableTable" #define UTF8_BYTES_LocalVariableTypeTable "LocalVariableTypeTable" #define UTF8_BYTES_Deprecated "Deprecated" #define UTF8_BYTES_RuntimeVisibleAnnotations "RuntimeVisibleAnnotations" #define UTF8_BYTES_RuntimeInvisibleAnnotations "RuntimeInvisibleAnnotations" #define UTF8_BYTES_RuntimeVisibleParameterAnnotations "RuntimeVisibleParameterAnnotations" #define UTF8_BYTES_RuntimeInvisibleParameterAnnotations "RuntimeInvisibleParameterAnnotations" #define UTF8_BYTES_RuntimeVisibleTypeAnnotations "RuntimeVisibleTypeAnnotations" #define UTF8_BYTES_RuntimeInvisibleTypeAnnotations "RuntimeInvisibleTypeAnnotations" #define UTF8_BYTES_AnnotationDefault "AnnotationDefault" #define UTF8_BYTES_BootstrapMethods "BootstrapMethods" #define UTF8_BYTES_MethodParameters "MethodParameters" #define UTF8_BYTES_Module "Module" #define UTF8_BYTES_ModulePackages "ModulePackages" #define UTF8_BYTES_ModuleMainClass "ModuleMainClass" #define UTF8_BYTES_java_lang_Object "java/lang/Object" #define UTF8_LENGTH_ConstantValue 13 #define UTF8_LENGTH_Code 4 #define UTF8_LENGTH_StackMapTable 13 #define UTF8_LENGTH_Exceptions 10 #define UTF8_LENGTH_InnerClasses 12 #define UTF8_LENGTH_EnclosingMethod 15 #define UTF8_LENGTH_Synthetic 9 #define UTF8_LENGTH_Signature 9 #define UTF8_LENGTH_SourceFile 10 #define UTF8_LENGTH_SourceDebugExtension 20 #define UTF8_LENGTH_LineNumberTable 15 #define UTF8_LENGTH_LocalVariableTable 18 #define UTF8_LENGTH_LocalVariableTypeTable 22 #define UTF8_LENGTH_Deprecated 10 #define UTF8_LENGTH_RuntimeVisibleAnnotations 25 #define UTF8_LENGTH_RuntimeInvisibleAnnotations 27 #define UTF8_LENGTH_RuntimeVisibleParameterAnnotations 34 #define UTF8_LENGTH_RuntimeInvisibleParameterAnnotations 36 #define UTF8_LENGTH_RuntimeVisibleTypeAnnotations 29 #define UTF8_LENGTH_RuntimeInvisibleTypeAnnotations 31 #define UTF8_LENGTH_AnnotationDefault 17 #define UTF8_LENGTH_BootstrapMethods 16 #define UTF8_LENGTH_MethodParameters 16 #define UTF8_LENGTH_Module 6 #define UTF8_LENGTH_ModulePackages 14 #define UTF8_LENGTH_ModuleMainClass 15 #define UTF8_LENGTH_java_lang_Object 16 #endif /* JAVA_CLASSFILE_PARSER_INTERNAL_CONSTANTS_H */
62.819672
94
0.658142
[ "object" ]
039d397875a6841818d2fff95882c1e6629de0b9
14,429
c
C
lib/libvcc/vcc_vmod.c
delthas/varnish-cache
fe8602b42d98f56379b53eed6ab55ff53984ce10
[ "BSD-2-Clause" ]
1
2020-12-23T10:26:26.000Z
2020-12-23T10:26:26.000Z
lib/libvcc/vcc_vmod.c
X3NOSIZ/varnish-cache
cd048454894466e979bc96c022bff9be9d968786
[ "BSD-2-Clause" ]
1
2021-07-24T15:59:05.000Z
2021-07-24T15:59:05.000Z
lib/libvcc/vcc_vmod.c
sitedata/varnish-cache
d5c072da9f37dd929dc1ba8d8698d84442fb2ffb
[ "BSD-2-Clause" ]
1
2019-05-25T13:29:22.000Z
2019-05-25T13:29:22.000Z
/*- * Copyright (c) 2010-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp <phk@phk.freebsd.dk> * * SPDX-License-Identifier: BSD-2-Clause * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 "config.h" #include <dlfcn.h> #include <stdlib.h> #include <string.h> #include "vcc_compile.h" #include "libvcc.h" #include "vfil.h" #include "vjsn.h" #include "vmod_abi.h" #include "vsb.h" struct vmod_open { unsigned magic; #define VMOD_OPEN_MAGIC 0x9995b1f3 void *hdl; const char *err; }; struct vmod_obj { unsigned magic; #define VMOD_OBJ_MAGIC 0x349885f8 char *name; struct type type[1]; VTAILQ_ENTRY(vmod_obj) list; }; static int vcc_path_dlopen(void *priv, const char *fn) { struct vmod_open *vop; CAST_OBJ_NOTNULL(vop, priv, VMOD_OPEN_MAGIC); AN(fn); vop->hdl = dlopen(fn, RTLD_NOW | RTLD_LOCAL); if (vop->hdl == NULL) { vop->err = dlerror(); return (-1); } return (0); } static void vcc_VmodObject(struct vcc *tl, struct symbol *sym); static void vcc_VmodSymbols(struct vcc *tl, const struct symbol *sym); static void func_sym(struct vcc *tl, vcc_kind_t kind, const struct symbol *psym, const struct vjsn_val *v) { struct symbol *sym; struct vsb *buf; buf = VSB_new_auto(); AN(buf); VSB_clear(buf); VCC_SymName(buf, psym); VSB_printf(buf, ".%s", v->value); AZ(VSB_finish(buf)); sym = VCC_MkSym(tl, VSB_data(buf), SYM_MAIN, kind, VCL_LOW, VCL_HIGH); AN(sym); VSB_destroy(&buf); if (kind == SYM_OBJECT) { sym->eval_priv = v; sym->vmod_name = psym->vmod_name; vcc_VmodObject(tl, sym); vcc_VmodSymbols(tl, sym); return; } if (kind == SYM_METHOD) sym->extra = psym->rname; v = VTAILQ_NEXT(v, list); assert(v->type == VJSN_ARRAY); sym->action = vcc_Act_Call; sym->vmod_name = psym->vmod_name; sym->eval = vcc_Eval_SymFunc; sym->eval_priv = v; v = VTAILQ_FIRST(&v->children); assert(v->type == VJSN_ARRAY); v = VTAILQ_FIRST(&v->children); assert(v->type == VJSN_STRING); sym->type = VCC_Type(v->value); AN(sym->type); } static void vcc_json_always(struct vcc *tl, const struct vjsn *vj, const char *vmod_name) { struct inifin *ifp; const struct vjsn_val *vv, *vv2; double vmod_syntax = 0.0; AN(vj); AN(vmod_name); ifp = NULL; VTAILQ_FOREACH(vv, &vj->value->children, list) { assert(vv->type == VJSN_ARRAY); vv2 = VTAILQ_FIRST(&vv->children); assert(vv2->type == VJSN_STRING); if (!strcmp(vv2->value, "$VMOD")) { vmod_syntax = strtod(VTAILQ_NEXT(vv2, list)->value, NULL); continue; } assert (vmod_syntax == 1.0); if (!strcmp(vv2->value, "$EVENT")) { /* XXX: What about the rest of the events ? */ if (ifp == NULL) ifp = New_IniFin(tl); vv2 = VTAILQ_NEXT(vv2, list); VSB_printf(ifp->ini, "\tif (%s(ctx, &vmod_priv_%s, VCL_EVENT_LOAD))\n" "\t\treturn(1);", vv2->value, vmod_name); VSB_printf(ifp->fin, "\t\t(void)%s(ctx, &vmod_priv_%s,\n" "\t\t\t VCL_EVENT_DISCARD);", vv2->value, vmod_name); VSB_printf(ifp->event, "%s(ctx, &vmod_priv_%s, ev)", vv2->value, vmod_name); } else if (!strcmp(vv2->value, "$FUNC")) { } else if (!strcmp(vv2->value, "$OBJ")) { } else { VTAILQ_FOREACH(vv2, &vv->children, list) fprintf(stderr, "\tt %s n %s v %s\n", vv2->type, vv2->name, vv2->value); WRONG("Vmod JSON syntax error"); } } } static const struct vmod_data * vcc_VmodSanity(struct vcc *tl, void *hdl, const struct token *mod, char *fnp) { char buf[256]; const struct vmod_data *vmd; bprintf(buf, "Vmod_%.*s_Data", PF(mod)); vmd = dlsym(hdl, buf); if (vmd == NULL) { VSB_printf(tl->sb, "Malformed VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "\tFile name: %s\n", fnp); VSB_cat(tl->sb, "\t(no Vmod_Data symbol)\n"); vcc_ErrWhere(tl, mod); return (NULL); } if (vmd->vrt_major == 0 && vmd->vrt_minor == 0 && (vmd->abi == NULL || strcmp(vmd->abi, VMOD_ABI_Version) != 0)) { VSB_printf(tl->sb, "Incompatible VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "\tFile name: %s\n", fnp); VSB_printf(tl->sb, "\tABI mismatch, expected <%s>, got <%s>\n", VMOD_ABI_Version, vmd->abi); vcc_ErrWhere(tl, mod); return (NULL); } if (vmd->vrt_major != 0 && (vmd->vrt_major != VRT_MAJOR_VERSION || vmd->vrt_minor > VRT_MINOR_VERSION)) { VSB_printf(tl->sb, "Incompatible VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "\tFile name: %s\n", fnp); VSB_printf(tl->sb, "\tVMOD wants ABI version %u.%u\n", vmd->vrt_major, vmd->vrt_minor); VSB_printf(tl->sb, "\tvarnishd provides ABI version %u.%u\n", VRT_MAJOR_VERSION, VRT_MINOR_VERSION); vcc_ErrWhere(tl, mod); return (NULL); } if (vmd->name == NULL || vmd->func == NULL || vmd->func_len <= 0 || vmd->proto == NULL || vmd->abi == NULL) { VSB_printf(tl->sb, "Mangled VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "\tFile name: %s\n", fnp); VSB_cat(tl->sb, "\tInconsistent metadata\n"); vcc_ErrWhere(tl, mod); return (NULL); } if (!vcc_IdIs(mod, vmd->name)) { VSB_printf(tl->sb, "Wrong file for VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "\tFile name: %s\n", fnp); VSB_printf(tl->sb, "\tContains vmod \"%s\"\n", vmd->name); vcc_ErrWhere(tl, mod); return (NULL); } return (vmd); } static vcc_kind_t vcc_vmod_kind(const char *type) { #define VMOD_KIND(str, kind) \ do { \ if (!strcmp(str, type)) \ return (kind); \ } while (0) VMOD_KIND("$OBJ", SYM_OBJECT); VMOD_KIND("$METHOD", SYM_METHOD); VMOD_KIND("$FUNC", SYM_FUNC); #undef VMOD_KIND return (SYM_NONE); } static void vcc_VmodObject(struct vcc *tl, struct symbol *sym) { struct vmod_obj *obj; struct vsb *buf; buf = VSB_new_auto(); AN(buf); VSB_printf(buf, "%s.%s", sym->vmod_name, sym->name); AZ(VSB_finish(buf)); ALLOC_OBJ(obj, VMOD_OBJ_MAGIC); AN(obj); REPLACE(obj->name, VSB_data(buf)); INIT_OBJ(obj->type, TYPE_MAGIC); obj->type->name = obj->name; sym->type = obj->type; VTAILQ_INSERT_TAIL(&tl->vmod_objects, obj, list); VSB_destroy(&buf); } static void vcc_VmodSymbols(struct vcc *tl, const struct symbol *sym) { const struct vjsn *vj; const struct vjsn_val *vv, *vv1, *vv2; vcc_kind_t kind; if (sym->kind == SYM_VMOD) { CAST_OBJ_NOTNULL(vj, sym->eval_priv, VJSN_MAGIC); vv = VTAILQ_FIRST(&vj->value->children); } else if (sym->kind == SYM_OBJECT) { CAST_OBJ_NOTNULL(vv, sym->eval_priv, VJSN_VAL_MAGIC); } else { WRONG("symbol kind"); } for (; vv != NULL; vv = VTAILQ_NEXT(vv, list)) { if (vv->type != VJSN_ARRAY) continue; vv1 = VTAILQ_FIRST(&vv->children); assert(vv1->type == VJSN_STRING); vv2 = VTAILQ_NEXT(vv1, list); if (vv2->type != VJSN_STRING) continue; kind = vcc_vmod_kind(vv1->value); if (kind == SYM_NONE) continue; func_sym(tl, kind, sym, vv2); } } void vcc_ParseImport(struct vcc *tl) { char fn[1024], *fnpx; const char *p; struct token *mod, *tmod, *t1; struct inifin *ifp; struct symbol *msym, *vsym; const struct vmod_data *vmd; struct vjsn *vj; struct vmod_open vop[1]; INIT_OBJ(vop, VMOD_OPEN_MAGIC); t1 = tl->t; SkipToken(tl, ID); /* "import" */ ExpectErr(tl, ID); /* "vmod_name" */ mod = tl->t; tmod = VTAILQ_NEXT(mod, list); if (tmod->tok == ID && vcc_IdIs(tmod, "as")) { vcc_NextToken(tl); /* "vmod_name" */ vcc_NextToken(tl); /* "as" */ ExpectErr(tl, ID); /* "vcl_name" */ } tmod = tl->t; msym = VCC_SymbolGet(tl, SYM_MAIN, SYM_VMOD, SYMTAB_CREATE, XREF_NONE); ERRCHK(tl); AN(msym); if (tl->t->tok == ID) { if (!vcc_IdIs(tl->t, "from")) { VSB_cat(tl->sb, "Expected 'from path ...'\n"); vcc_ErrWhere(tl, tl->t); return; } vcc_NextToken(tl); if (!tl->unsafe_path && strchr(tl->t->dec, '/')) { VSB_cat(tl->sb, "'import ... from path ...' is unsafe.\nAt:"); vcc_ErrToken(tl, tl->t); vcc_ErrWhere(tl, tl->t); return; } ExpectErr(tl, CSTR); p = strrchr(tl->t->dec, '/'); if (p != NULL && p[1] == '\0') bprintf(fn, "%slibvmod_%.*s.so", tl->t->dec, PF(mod)); else bprintf(fn, "%s", tl->t->dec); vcc_NextToken(tl); } else { bprintf(fn, "libvmod_%.*s.so", PF(mod)); } SkipToken(tl, ';'); if (VFIL_searchpath(tl->vmod_path, vcc_path_dlopen, vop, fn, &fnpx)) { if (vop->err == NULL) { VSB_printf(tl->sb, "Could not find VMOD %.*s\n", PF(mod)); } else { VSB_printf(tl->sb, "Could not open VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "\tFile name: %s\n", fnpx != NULL ? fnpx : fn); VSB_printf(tl->sb, "\tdlerror: %s\n", vop->err); } vcc_ErrWhere(tl, mod); free(fnpx); return; } vmd = vcc_VmodSanity(tl, vop->hdl, mod, fnpx); if (vmd == NULL || tl->err) { AZ(dlclose(vop->hdl)); free(fnpx); return; } if (msym->extra != NULL) { if (!strcmp(msym->extra, vmd->file_id)) { /* Identical import is OK */ } else { VSB_printf(tl->sb, "Another module already imported as %.*s.\n", PF(tmod)); vcc_ErrWhere2(tl, t1, tl->t); } AZ(dlclose(vop->hdl)); free(fnpx); return; } msym->def_b = t1; msym->def_e = tl->t; VTAILQ_FOREACH(vsym, &tl->sym_vmods, sideways) { assert(vsym->kind == SYM_VMOD); if (!strcmp(vsym->extra, vmd->file_id)) { /* Already loaded under different name */ msym->eval_priv = vsym->eval_priv; msym->extra = vsym->extra; msym->vmod_name = vsym->vmod_name; vcc_VmodSymbols(tl, msym); AZ(dlclose(vop->hdl)); free(fnpx); return; } } VTAILQ_INSERT_TAIL(&tl->sym_vmods, msym, sideways); ifp = New_IniFin(tl); VSB_cat(ifp->ini, "\tif (VPI_Vmod_Init(ctx,\n"); VSB_printf(ifp->ini, "\t &VGC_vmod_%.*s,\n", PF(mod)); VSB_printf(ifp->ini, "\t %u,\n", tl->vmod_count++); VSB_printf(ifp->ini, "\t &%s,\n", vmd->func_name); VSB_printf(ifp->ini, "\t sizeof(%s),\n", vmd->func_name); VSB_printf(ifp->ini, "\t \"%.*s\",\n", PF(mod)); VSB_cat(ifp->ini, "\t "); VSB_quote(ifp->ini, fnpx, -1, VSB_QUOTE_CSTR); VSB_cat(ifp->ini, ",\n"); AN(vmd); AN(vmd->file_id); VSB_printf(ifp->ini, "\t \"%s\",\n", vmd->file_id); VSB_printf(ifp->ini, "\t \"./vmod_cache/_vmod_%.*s.%s\"\n", PF(mod), vmd->file_id); VSB_cat(ifp->ini, "\t ))\n"); VSB_cat(ifp->ini, "\t\treturn(1);"); VSB_cat(tl->symtab, ",\n {\n"); VSB_cat(tl->symtab, "\t\"dir\": \"import\",\n"); VSB_cat(tl->symtab, "\t\"type\": \"$VMOD\",\n"); VSB_printf(tl->symtab, "\t\"name\": \"%.*s\",\n", PF(mod)); VSB_printf(tl->symtab, "\t\"file\": \"%s\",\n", fnpx); VSB_printf(tl->symtab, "\t\"dst\": \"./vmod_cache/_vmod_%.*s.%s\"\n", PF(mod), vmd->file_id); VSB_cat(tl->symtab, " }"); /* XXX: zero the function pointer structure ?*/ VSB_printf(ifp->fin, "\t\tVRT_priv_fini(&vmod_priv_%.*s);", PF(mod)); VSB_printf(ifp->final, "\t\tVPI_Vmod_Unload(&VGC_vmod_%.*s);", PF(mod)); vj = vjsn_parse(vmd->json, &p); XXXAZ(p); AN(vj); msym->eval_priv = vj; msym->extra = TlDup(tl, vmd->file_id); msym->vmod_name = TlDup(tl, vmd->name); vcc_VmodSymbols(tl, msym); vcc_json_always(tl, vj, msym->vmod_name); Fh(tl, 0, "\n/* --- BEGIN VMOD %.*s --- */\n\n", PF(mod)); Fh(tl, 0, "static struct vmod *VGC_vmod_%.*s;\n", PF(mod)); Fh(tl, 0, "static struct vmod_priv vmod_priv_%.*s;\n", PF(mod)); Fh(tl, 0, "\n%s\n", vmd->proto); Fh(tl, 0, "\n/* --- END VMOD %.*s --- */\n\n", PF(mod)); free(fnpx); } void v_matchproto_(sym_act_f) vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) { struct symbol *isym, *osym; struct inifin *ifp; struct vsb *buf; const struct vjsn_val *vv, *vf; int null_ok = 0; (void)sym; (void)t; ExpectErr(tl, ID); vcc_ExpectVid(tl, "VCL object"); ERRCHK(tl); isym = VCC_HandleSymbol(tl, INSTANCE, "vo"); ERRCHK(tl); AN(isym); isym->noref = 1; isym->action = vcc_Act_Obj; SkipToken(tl, '='); ExpectErr(tl, ID); osym = VCC_SymbolGet(tl, SYM_MAIN, SYM_OBJECT, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); AN(osym); /* Scratch the generic INSTANCE type */ isym->type = osym->type; CAST_OBJ_NOTNULL(vv, osym->eval_priv, VJSN_VAL_MAGIC); // vv = object name isym->vmod_name = osym->vmod_name; isym->eval_priv = vv; vv = VTAILQ_NEXT(vv, list); // vv = flags assert(vv->type == VJSN_OBJECT); VTAILQ_FOREACH(vf, &vv->children, list) if (!strcmp(vf->name, "NULL_OK") && vf->type == VJSN_TRUE) null_ok = 1; if (!null_ok) VTAILQ_INSERT_TAIL(&tl->sym_objects, isym, sideways); vv = VTAILQ_NEXT(vv, list); // vv = struct name Fh(tl, 0, "static %s *%s;\n\n", vv->value, isym->rname); vv = VTAILQ_NEXT(vv, list); vf = VTAILQ_FIRST(&vv->children); vv = VTAILQ_NEXT(vv, list); assert(vf->type == VJSN_STRING); assert(!strcmp(vf->value, "$INIT")); vf = VTAILQ_NEXT(vf, list); buf = VSB_new_auto(); AN(buf); VSB_printf(buf, "&%s, \"%s\"", isym->rname, isym->name); AZ(VSB_finish(buf)); vcc_Eval_Func(tl, vf, VSB_data(buf), osym); VSB_destroy(&buf); ERRCHK(tl); SkipToken(tl, ';'); isym->def_e = tl->t; vf = VTAILQ_FIRST(&vv->children); assert(vf->type == VJSN_STRING); assert(!strcmp(vf->value, "$FINI")); vf = VTAILQ_NEXT(vf, list); vf = VTAILQ_FIRST(&vf->children); vf = VTAILQ_NEXT(vf, list); ifp = New_IniFin(tl); VSB_printf(ifp->fin, "\t\tif (%s)\n", isym->rname); VSB_printf(ifp->fin, "\t\t\t\t%s(&%s);", vf->value, isym->rname); }
26.72037
77
0.633169
[ "object" ]
039f5a496bd354fd6a9e7f66af65082be7191e34
204,531
c
C
c_code/7_1/compiler_vmgen.c
FedericoCeratto/debian-nim
a029bf7b350731aa9b59a9be7d441a6b7e93ce27
[ "MIT" ]
null
null
null
c_code/7_1/compiler_vmgen.c
FedericoCeratto/debian-nim
a029bf7b350731aa9b59a9be7d441a6b7e93ce27
[ "MIT" ]
null
null
null
c_code/7_1/compiler_vmgen.c
FedericoCeratto/debian-nim
a029bf7b350731aa9b59a9be7d441a6b7e93ce27
[ "MIT" ]
null
null
null
/* Generated by Nim Compiler v0.15.0 */ /* (c) 2016 Andreas Rumpf */ /* The generated code is subject to the original license. */ #define NIM_INTBITS 32 #include "nimbase.h" #include <string.h> typedef struct Tctx344035 Tctx344035; typedef struct Tsym293834 Tsym293834; typedef struct Tnode293802 Tnode293802; typedef struct Tidobj200004 Tidobj200004; typedef struct TNimObject TNimObject; typedef struct TNimType TNimType; typedef struct TNimNode TNimNode; typedef struct Ttypeseq293836 Ttypeseq293836; typedef struct TY293929 TY293929; typedef struct Tstrtable293806 Tstrtable293806; typedef struct Tsymseq293804 Tsymseq293804; typedef struct Ttype293840 Ttype293840; typedef struct Tident200010 Tident200010; typedef struct Tlineinfo192336 Tlineinfo192336; typedef struct Tloc293816 Tloc293816; typedef struct Ropeobj179006 Ropeobj179006; typedef struct Tlib293820 Tlib293820; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; typedef struct Tnodeseq293796 Tnodeseq293796; typedef struct Tpasscontext342002 Tpasscontext342002; typedef struct TY344241 TY344241; typedef struct TY193086 TY193086; typedef struct PprocHEX3Aobjecttype344220 PprocHEX3Aobjecttype344220; typedef struct TY344260 TY344260; typedef struct Cell47305 Cell47305; typedef struct Cellseq47321 Cellseq47321; typedef struct Gcheap49818 Gcheap49818; typedef struct Gcstack49816 Gcstack49816; typedef struct Memregion29485 Memregion29485; typedef struct Smallchunk29439 Smallchunk29439; typedef struct Llchunk29479 Llchunk29479; typedef struct Bigchunk29441 Bigchunk29441; typedef struct Intset29414 Intset29414; typedef struct Trunk29410 Trunk29410; typedef struct Avlnode29483 Avlnode29483; typedef struct Gcstat49814 Gcstat49814; typedef struct Cellset47317 Cellset47317; typedef struct Pagedesc47313 Pagedesc47313; typedef struct TY344221 TY344221; typedef struct TY344226 TY344226; typedef struct Tblock344017 Tblock344017; typedef struct TY344201 TY344201; typedef struct TY293960 TY293960; typedef struct TY204018 TY204018; typedef struct Vmargs344029 Vmargs344029; typedef struct TY344261 TY344261; typedef struct TY135002 TY135002; typedef struct Tinstantiation293824 Tinstantiation293824; typedef struct Tlistentry147007 Tlistentry147007; typedef struct Basechunk29437 Basechunk29437; typedef struct Freecell29429 Freecell29429; typedef struct TY293961 TY293961; typedef NU8 Tnimkind3403; typedef NU8 Tnimtypeflag3409Set; typedef N_NIMCALL_PTR(void, TY3489) (void* p0, NI op0); typedef N_NIMCALL_PTR(void*, TY3494) (void* p0); struct TNimType { NI size; Tnimkind3403 kind; Tnimtypeflag3409Set flags; TNimType* base; TNimNode* node; void* finalizer; TY3489 marker; TY3494 deepcopy; }; struct TNimObject { TNimType* m_type; }; struct Tidobj200004 { TNimObject Sup; NI id; }; typedef NU8 Tsymkind293435; struct Tstrtable293806 { NI counter; Tsymseq293804* data; }; typedef NU16 Tmagic293524; struct Tlineinfo192336 { NI16 line; NI16 col; NI32 fileindex; }; typedef NU32 Tsymflag293184Set; typedef NU32 Toption170009Set; typedef NU8 Tlockind293808; typedef NU8 Tstorageloc293812; typedef NU16 Tlocflag293810Set; struct Tloc293816 { Tlockind293808 k; Tstorageloc293812 s; Tlocflag293810Set flags; Ttype293840* t; Ropeobj179006* r; }; struct Tsym293834 { Tidobj200004 Sup; Tsymkind293435 kind; union{ struct {Ttypeseq293836* typeinstcache; } S1; struct {TY293929* procinstcache; Tsym293834* gcunsafetyreason; } S2; struct {TY293929* usedgenerics; Tstrtable293806 tab; } S3; struct {Tsym293834* guard; NI bitsize; } S4; } kindU; Tmagic293524 magic; Ttype293840* typ; Tident200010* name; Tlineinfo192336 info; Tsym293834* owner; Tsymflag293184Set flags; Tnode293802* ast; Toption170009Set options; NI position; NI offset; Tloc293816 loc; Tlib293820* annex; Tnode293802* constraint; }; typedef NU16 Tnodeflag293427Set; typedef NU8 Tnodekind293020; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; struct Tnode293802 { Ttype293840* typ; Tlineinfo192336 info; Tnodeflag293427Set flags; Tnodekind293020 kind; union{ struct {NI64 intval; } S1; struct {NF floatval; } S2; struct {NimStringDesc* strval; } S3; struct {Tsym293834* sym; } S4; struct {Tident200010* ident; } S5; struct {Tnodeseq293796* sons; } S6; } kindU; NimStringDesc* comment; }; struct Tpasscontext342002 { TNimObject Sup; NIM_BOOL fromcache; }; typedef NU8 Tevalmode344019; typedef NU8 Tsandboxflag344021Set; struct Tctx344035 { Tpasscontext342002 Sup; TY344241* code; TY193086* debug; Tnode293802* globals; Tnode293802* constants; Ttypeseq293836* types; Tnode293802* currentexceptiona; Tnode293802* currentexceptionb; NI exceptioninstr; PprocHEX3Aobjecttype344220* prc; Tsym293834* module; Tnode293802* callsite; Tevalmode344019 mode; Tsandboxflag344021Set features; NIM_BOOL traceactive; NI loopiterations; Tlineinfo192336 comesfromheuristic; TY344260* callbacks; NimStringDesc* errorflag; }; typedef NU8 Topcode344015; typedef Tnode293802* TY441139[2]; struct Cell47305 { NI refcount; TNimType* typ; }; struct Cellseq47321 { NI len; NI cap; Cell47305** d; }; typedef Smallchunk29439* TY29500[512]; typedef Trunk29410* Trunkbuckets29412[256]; struct Intset29414 { Trunkbuckets29412 data; }; struct Memregion29485 { NI minlargeobj; NI maxlargeobj; TY29500 freesmallchunks; Llchunk29479* llmem; NI currmem; NI maxmem; NI freemem; NI lastsize; Bigchunk29441* freechunkslist; Intset29414 chunkstarts; Avlnode29483* root; Avlnode29483* deleted; Avlnode29483* last; Avlnode29483* freeavlnodes; NIM_BOOL locked; }; struct Gcstat49814 { NI stackscans; NI cyclecollections; NI maxthreshold; NI maxstacksize; NI maxstackcells; NI cycletablesize; NI64 maxpause; }; struct Cellset47317 { NI counter; NI max; Pagedesc47313* head; Pagedesc47313** data; }; struct Gcheap49818 { Gcstack49816* stack; void* stackbottom; NI cyclethreshold; Cellseq47321 zct; Cellseq47321 decstack; Cellseq47321 tempstack; NI recgclock; Memregion29485 region; Gcstat49814 stat; Cellset47317 marked; Cellseq47321 additionalroots; }; typedef NU16 Tmsgkind192002; typedef NU8 Tslotkind344025; struct TY344226 { NIM_BOOL Field0; Tslotkind344025 Field1; }; typedef TY344226 TY344229[256]; struct PprocHEX3Aobjecttype344220 { TY344221* blocks; Tsym293834* sym; TY344229 slots; NI maxslots; }; typedef NU8 Tnimnodekind3405; struct TNimNode { Tnimnodekind3405 kind; NI offset; TNimType* typ; NCSTRING name; NI len; TNimNode** sons; }; struct Tblock344017 { Tsym293834* label; TY344201* fixups; }; typedef NU8 Ttypekind293244; typedef NU8 Tcallingconvention293002; typedef NU32 Ttypeflag293431Set; struct Ttype293840 { Tidobj200004 Sup; Ttypekind293244 kind; Tcallingconvention293002 callconv; Ttypeflag293431Set flags; Ttypeseq293836* sons; Tnode293802* n; Tsym293834* owner; Tsym293834* sym; Tsym293834* destructor; Tsym293834* deepcopy; Tsym293834* assignment; TY293960* methods; NI64 size; NI16 align; NI16 locklevel; Tloc293816 loc; }; typedef NU8 Tsymflag293184; typedef NU8 Ttypeflag293431; typedef NU8 Tgenflag446202Set; typedef NU8 Trenderflag312004Set; typedef NU64 Ttypekind293244Set; struct TY204018 { NimStringDesc* Field0; NI Field1; }; typedef NU8 Tgenflag446202; typedef struct { N_NIMCALL_PTR(void, ClPrc) (Vmargs344029* args0, void* ClEnv); void* ClEnv; } Vmcallback344031; struct TY344261 { NimStringDesc* Field0; Vmcallback344031 Field1; }; struct Tident200010 { Tidobj200004 Sup; NimStringDesc* s; Tident200010* next; NI h; }; typedef NU8 Tnodeflag293427; typedef NU8 Ttypecmpflag325429Set; typedef NimStringDesc* TY194140[3]; typedef NU8 Tsandboxflag344021; struct Ropeobj179006 { TNimObject Sup; Ropeobj179006* left; Ropeobj179006* right; NI length; NimStringDesc* data; }; struct Tlistentry147007 { TNimObject Sup; Tlistentry147007* prev; Tlistentry147007* next; }; typedef NU8 Tlibkind293818; struct Tlib293820 { Tlistentry147007 Sup; Tlibkind293818 kind; NIM_BOOL generated; NIM_BOOL isoverriden; Ropeobj179006* name; Tnode293802* path; }; struct Gcstack49816 { Gcstack49816* prev; Gcstack49816* next; void* starts; void* pos; NI maxstacksize; }; struct Basechunk29437 { NI prevsize; NI size; NIM_BOOL used; }; struct Smallchunk29439 { Basechunk29437 Sup; Smallchunk29439* next; Smallchunk29439* prev; Freecell29429* freelist; NI free; NI acc; NF data; }; struct Llchunk29479 { NI size; NI acc; Llchunk29479* next; }; struct Bigchunk29441 { Basechunk29437 Sup; Bigchunk29441* next; Bigchunk29441* prev; NI align; NF data; }; typedef NI TY29418[16]; struct Trunk29410 { Trunk29410* next; NI key; TY29418 bits; }; typedef Avlnode29483* TY29490[2]; struct Avlnode29483 { TY29490 link; NI key; NI upperbound; NI level; }; struct Pagedesc47313 { Pagedesc47313* next; NI key; TY29418 bits; }; struct TY293961 { NI Field0; Tsym293834* Field1; }; struct Vmargs344029 { NI ra; NI rb; NI rc; void* slots; Tnode293802* currentexception; }; struct Tinstantiation293824 { Tsym293834* sym; Ttypeseq293836* concretetypes; NI compilesid; }; struct Freecell29429 { Freecell29429* next; NI zerofield; }; struct TY344241 { TGenericSeq Sup; NU32 data[SEQ_DECL_SIZE]; }; struct TY193086 { TGenericSeq Sup; Tlineinfo192336 data[SEQ_DECL_SIZE]; }; struct TY344221 { TGenericSeq Sup; Tblock344017 data[SEQ_DECL_SIZE]; }; struct TY344260 { TGenericSeq Sup; TY344261 data[SEQ_DECL_SIZE]; }; struct TY135002 { TGenericSeq Sup; NimStringDesc* data[SEQ_DECL_SIZE]; }; struct Ttypeseq293836 { TGenericSeq Sup; Ttype293840* data[SEQ_DECL_SIZE]; }; struct TY344201 { TGenericSeq Sup; NI data[SEQ_DECL_SIZE]; }; struct TY293929 { TGenericSeq Sup; Tinstantiation293824* data[SEQ_DECL_SIZE]; }; struct Tsymseq293804 { TGenericSeq Sup; Tsym293834* data[SEQ_DECL_SIZE]; }; struct Tnodeseq293796 { TGenericSeq Sup; Tnode293802* data[SEQ_DECL_SIZE]; }; struct TY293960 { TGenericSeq Sup; TY293961 data[SEQ_DECL_SIZE]; }; static N_INLINE(Tnode293802*, HEX5BHEX5D_294238_850551059)(Tnode293802* n0, NI i0); N_NIMCALL(TGenericSeq*, setLengthSeq)(TGenericSeq* seq0, NI elemsize0, NI newlen0); N_NIMCALL(Tnode293802*, newtree_294602_850551059)(Tnodekind293020 kind0, Tnode293802** children0, NI children0Len0); N_NIMCALL(Tnode293802*, newintnode_294660_850551059)(Tnodekind293020 kind0, NI64 intval0); static N_INLINE(void, asgnRefNoCycle)(void** dest0, void* src0); static N_INLINE(Cell47305*, usrtocell_51440_1689653243)(void* usr0); static N_INLINE(void, rtladdzct_52601_1689653243)(Cell47305* c0); N_NOINLINE(void, addzct_51417_1689653243)(Cellseq47321* s0, Cell47305* c0); N_NIMCALL(Tnode293802*, getbody_336227_1724185294)(Tsym293834* s0); N_NIMCALL(NI, xjmp_447264_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI a0); N_NIMCALL(void, gabx_447116_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI a0, NI bx0); N_NIMCALL(TGenericSeq*, incrSeqV2)(TGenericSeq* seq0, NI elemsize0); N_NIMCALL(void, localerror_197080_155036129)(Tlineinfo192336 info0, Tmsgkind192002 msg0, NimStringDesc* arg0); N_NIMCALL(void*, newObj)(TNimType* typ0, NI size0); static N_INLINE(void, nimGCunrefNoCycle)(void* p0); N_NIMCALL(void*, newSeqRC1)(TNimType* typ0, NI len0); N_NIMCALL(void, genparams_453655_1009139178)(Tctx344035* c0, Tnode293802* params0); static N_INLINE(NI, len_294081_850551059)(Tnode293802* n0); N_NIMCALL(void, gengenericparams_453745_1009139178)(Tctx344035* c0, Tnode293802* gp0); N_NIMCALL(void, gen_447852_1009139178)(Tctx344035* c0, Tnode293802* n0, Tgenflag446202Set flags0); N_NIMCALL(void, gen_447825_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0); N_NIMCALL(void, checkcaneval_450700_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(NIM_BOOL, isownedby_450646_1009139178)(Tsym293834* a_450648_1009139178, Tsym293834* b0); N_NOINLINE(void, cannoteval_450642_1009139178)(Tnode293802* n0); N_NIMCALL(void, globalerror_197071_155036129)(Tlineinfo192336 info0, Tmsgkind192002 msg0, NimStringDesc* arg0); static N_INLINE(void, appendString)(NimStringDesc* dest0, NimStringDesc* src0); static N_INLINE(void, copymem_7485_1689653243)(void* dest0, void* source0, NI size0); N_NIMCALL(NimStringDesc*, rendertree_312044_382274130)(Tnode293802* n0, Trenderflag312004Set renderflags0); N_NIMCALL(NimStringDesc*, rawNewString)(NI space0); N_NIMCALL(void, genrdvar_451432_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0); N_NIMCALL(void, importcsym_451223_1009139178)(Tctx344035* c0, Tlineinfo192336 info0, Tsym293834* s0); N_NIMCALL(void, genglobalinit_451405_1009139178)(Tctx344035* c0, Tnode293802* n0, Tsym293834* s0); N_NIMCALL(void, add_294136_850551059)(Tnode293802* father0, Tnode293802* son0); N_NIMCALL(Tnode293802*, getnullvalue_451401_1009139178)(Ttype293840* typ0, Tlineinfo192336 info0); N_NIMCALL(Ttype293840*, skiptypes_297099_850551059)(Ttype293840* t0, Ttypekind293244Set kinds0); N_NIMCALL(Tnode293802*, newnodeit_295801_850551059)(Tnodekind293020 kind0, Tlineinfo192336 info0, Ttype293840* typ0); N_NIMCALL(void, getnullvalueaux_451818_1009139178)(Tnode293802* obj0, Tnode293802* result0); N_NIMCALL(NI, sonslen_296351_850551059)(Tnode293802* n0); N_NIMCALL(Tnode293802*, lastson_296364_850551059)(Tnode293802* n0); N_NIMCALL(Tnode293802*, newnodei_295197_850551059)(Tnodekind293020 kind0, Tlineinfo192336 info0); N_NIMCALL(void, addson_295807_850551059)(Tnode293802* father0, Tnode293802* son0); N_NIMCALL(void, globalerror_197076_155036129)(Tlineinfo192336 info0, NimStringDesc* arg0); N_NIMCALL(NimStringDesc*, HEX24_312066_382274130)(Tnode293802* n0); N_NIMCALL(NI64, lengthord_321007_3876443242)(Ttype293840* t0); N_NIMCALL(Ttype293840*, elemtype_321394_3876443242)(Ttype293840* t0); N_NIMCALL(NI, sonslen_296327_850551059)(Ttype293840* n0); N_NIMCALL(NimStringDesc*, reprEnum)(NI e0, TNimType* typ0); N_NIMCALL(NI, gettemp_447412_1009139178)(Tctx344035* cc0, Ttype293840* tt0); N_NIMCALL(Ttype293840*, skiptypesornil_297115_850551059)(Ttype293840* t0, Ttypekind293244Set kinds0); N_NIMCALL(Tslotkind344025, getslotkind_447376_1009139178)(Ttype293840* t0); N_NIMCALL(Tlineinfo192336, besteffort_447394_1009139178)(Tctx344035* c0); N_NIMCALL(NI, genx_447862_1009139178)(Tctx344035* c0, Tnode293802* n0, Tgenflag446202Set flags0); N_NIMCALL(void, internalerror_197113_155036129)(NimStringDesc* errmsg0); N_NIMCALL(NimStringDesc*, HEX24_197185_1689653243)(TY204018 x0); N_NIMCALL(void, preventfalsealias_450795_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI dest0, NI idx0, NI value0); N_NIMCALL(NIM_BOOL, istemp_450774_1009139178)(Tctx344035* c0, NI dest0); N_NIMCALL(NIM_BOOL, fitsregister_449844_1009139178)(Ttype293840* t0); N_NIMCALL(void, gabc_446714_1009139178)(Tctx344035* ctx0, Tnode293802* n0, Topcode344015 opc0, NI a0, NI b0, NI c0); N_NIMCALL(Topcode344015, whichasgnopc_450420_1009139178)(Tnode293802* n0); N_NIMCALL(void, freetemp_447493_1009139178)(Tctx344035* c_447495_1009139178, NI r0); N_NIMCALL(void, setslot_450609_1009139178)(Tctx344035* c0, Tsym293834* v0); N_NIMCALL(void, genasgn_450442_1009139178)(Tctx344035* c0, NI dest0, Tnode293802* ri0, NIM_BOOL requirescopy0); N_NIMCALL(NIM_BOOL, prociscallback_452963_1009139178)(Tctx344035* c0, Tsym293834* s0); N_NIMCALL(NIM_BOOL, matches_452871_1009139178)(Tsym293834* s_452873_1009139178, NimStringDesc* x0); N_NIMCALL(TY135002*, nsuSplitChar)(NimStringDesc* s0, NIM_CHAR sep0, NI maxsplit0); N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a0, NimStringDesc* b0); static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a0, NimStringDesc* b0); static N_INLINE(NIM_BOOL, equalmem_7495_1689653243)(void* a0, void* b0, NI size0); N_NOINLINE(void, raiseassert_91216_1689653243)(NimStringDesc* msg0); N_NIMCALL(void, genlit_448891_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(NI, genliteral_448377_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(NIM_BOOL, sameconstant_448274_1009139178)(Tnode293802* a0, Tnode293802* b0); N_NIMCALL(NI, rawgenliteral_448248_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(Tnode293802*, canonvalue_448244_1009139178)(Tnode293802* n0); N_NIMCALL(void, gentypelit_451216_1009139178)(Tctx344035* c0, Ttype293840* t0, NI* dest0); N_NIMCALL(Tnode293802*, newnode_294401_850551059)(Tnodekind293020 kind0); N_NIMCALL(void, genmagic_449556_1009139178)(Tctx344035* c0, Tnode293802* n_449559_1009139178, NI* dest0, Tmagic293524 m0); N_NIMCALL(void, genandor_448234_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI* dest0); N_NIMCALL(void, patch_447318_1009139178)(Tctx344035* c0, NI p_447321_1009139178); N_NIMCALL(void, gabi_447026_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI a0, NI b0, NI64 imm0); N_NIMCALL(void, genaddsubint_449495_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(NIM_BOOL, isint8lit_449453_1009139178)(Tnode293802* n0); N_NIMCALL(void, genbinaryabc_449232_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(void, gennarrow_449256_1009139178)(Tctx344035* c0, Tnode293802* n0, NI dest0); static N_INLINE(void, unused_448409_1009139178)(Tnode293802* n0, NI x0); N_NIMCALL(void, genasgnpatch_449090_1009139178)(Tctx344035* c0, Tnode293802* le0, NI value0); N_NIMCALL(NI, genindex_449073_1009139178)(Tctx344035* c0, Tnode293802* n0, Ttype293840* arr0); N_NIMCALL(NI64, firstord_321001_3876443242)(Ttype293840* t0); N_NIMCALL(NI, genfield_449043_1009139178)(Tnode293802* n0); N_NIMCALL(void, gennew_449144_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(NIM_BOOL, needsasgnpatch_448997_1009139178)(Tnode293802* n0); N_NIMCALL(NI, gentype_448502_1009139178)(Tctx344035* c0, Ttype293840* typ0); N_NIMCALL(NIM_BOOL, sametype_325633_3876443242)(Ttype293840* a0, Ttype293840* b0, Ttypecmpflag325429Set flags0); N_NIMCALL(void, gennewseq_449167_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(void, gennewseqofcap_449192_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, genunaryabc_449214_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(void, genunaryabi_449223_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(void, gensettype_449341_1009139178)(Tctx344035* c0, Tnode293802* n0, NI dest0); N_NIMCALL(void, gencard_449547_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, genbinaryabcnarrow_449327_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(void, genbinaryabcnarrowu_449334_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(void, gennarrowu_449297_1009139178)(Tctx344035* c0, Tnode293802* n0, NI dest0); N_NIMCALL(void, genconv_449518_1009139178)(Tctx344035* c0, Tnode293802* n0, Tnode293802* arg0, NI* dest0, Topcode344015 opc0); N_NIMCALL(void, genbinaryset_449369_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(void, genvarargsabc_449420_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(NI, gettemprange_447509_1009139178)(Tctx344035* cc0, NI n0, Tslotkind344025 kind0); N_NIMCALL(void, gen_447834_1009139178)(Tctx344035* c0, Tnode293802* n0, NI dest0, Tgenflag446202Set flags0); N_NIMCALL(void, freetemprange_447680_1009139178)(Tctx344035* c0, NI start0, NI n0); N_NIMCALL(Tnode293802*, lowerswap_434300_2218250499)(Tnode293802* n0, Tsym293834* owner0); N_NIMCALL(Ttype293840*, getsystype_339150_3937434831)(Ttypekind293244 kind0); N_NIMCALL(Tnode293802*, skipconv_329882_3876443242)(Tnode293802* n0); N_NIMCALL(void, genbinarystmtvar_449391_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0); N_NIMCALL(void, genbinaryabcd_449243_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0); N_NIMCALL(void, genbinarystmt_449382_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0); N_NIMCALL(void, localerror_197085_155036129)(Tlineinfo192336 info0, NimStringDesc* arg0); N_NIMCALL(void, genunarystmt_449413_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0); N_NIMCALL(void, gencall_448898_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); static N_INLINE(NIM_BOOL, isemptytype_298440_850551059)(Ttype293840* t0); N_NIMCALL(NI, len_296339_850551059)(Ttype293840* n0); N_NIMCALL(NIM_BOOL, matches_452911_1009139178)(Tsym293834* s_452913_1009139178, NimStringDesc** y0, NI y0Len0); N_NIMCALL(void, genmarshalload_449825_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, genmarshalstore_449833_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); static N_INLINE(void, cleardest_447880_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(NIM_BOOL, isint16lit_449474_1009139178)(Tnode293802* n0); N_NIMCALL(void, genasgn_451002_1009139178)(Tctx344035* c0, Tnode293802* le0, Tnode293802* ri0, NIM_BOOL requirescopy0); N_NIMCALL(void, genobjaccess_451743_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0); N_NIMCALL(void, gencheckedobjaccess_451766_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0); N_NIMCALL(void, genarraccess_451774_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0); N_NIMCALL(void, genarraccess2_451718_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0, Tgenflag446202Set flags0); N_NIMCALL(void, genaddrderef_450104_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0, Tgenflag446202Set flags0); N_NIMCALL(Tnode293802*, canelimaddr_450051_1009139178)(Tnode293802* n0); N_NIMCALL(Tnode293802*, copynode_297528_850551059)(Tnode293802* src0); N_NIMCALL(NIM_BOOL, unneededindirection_450025_1009139178)(Tnode293802* n0); N_NIMCALL(NIM_BOOL, isglobal_448963_1009139178)(Tnode293802* n0); N_NIMCALL(void, genif_448147_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void*, newSeq)(TNimType* typ0, NI len0); N_NIMCALL(NIM_BOOL, isnotopr_447903_1009139178)(Tnode293802* n0); N_NIMCALL(void, gencase_448413_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, genwhile_447974_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(NI, genlabel_447280_1009139178)(Tctx344035* c0); N_NIMCALL(void, genericSeqAssign)(void* dest0, void* src_86404_1689653243, TNimType* mt0); N_NIMCALL(NIM_BOOL, istrue_447939_1009139178)(Tnode293802* n0); N_NIMCALL(void, jmpback_447293_1009139178)(Tctx344035* c0, Tnode293802* n0, NI p0); N_NIMCALL(void, popblock_447709_1009139178)(Tctx344035* c0, NI oldlen0); N_NIMCALL(void, genblock_448027_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, genreturn_448876_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(void, genraise_448870_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(void, genbreak_448072_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(void, gentry_448573_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, genvarsection_452001_1009139178)(Tctx344035* c0, Tnode293802* n0); N_NIMCALL(Tnode293802*, lowertupleunpacking_434037_2218250499)(Tnode293802* n0, Tsym293834* owner0); N_NIMCALL(Tsym293834*, getowner_450687_1009139178)(Tctx344035* c0); N_NIMCALL(Topcode344015, ldnullopcode_451962_1009139178)(Ttype293840* t0); N_NIMCALL(Tnode293802*, newsymnode_295183_850551059)(Tsym293834* sym0); N_NIMCALL(void, genarrayconstr_452654_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(Topcode344015, whichasgnopc_450437_1009139178)(Tnode293802* n0, Topcode344015 opc0); N_NIMCALL(void, gensetconstr_452701_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, genobjconstr_452733_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, gentupleconstr_452816_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0); N_NIMCALL(void, optimizejumps_453785_1009139178)(Tctx344035* c0, NI start0); N_NIMCALL(void, finaljumptarget_453697_1009139178)(Tctx344035* c0, NI pc0, NI diff0); N_NIMCALL(void, removelasteof_453399_1009139178)(Tctx344035* c0); STRING_LITERAL(T1009139178_2, "VM: immediate value does not fit into an int16", 46); NIM_CONST TY344226 T1009139178_3 = {NIM_TRUE, ((Tslotkind344025) 1)} ; NIM_CONST TY344226 T1009139178_4 = {NIM_TRUE, ((Tslotkind344025) 2)} ; NIM_CONST TY344226 T1009139178_5 = {NIM_TRUE, ((Tslotkind344025) 2)} ; NIM_CONST TY344226 T1009139178_6 = {NIM_TRUE, ((Tslotkind344025) 2)} ; STRING_LITERAL(T1009139178_7, "cannot evaluate at compile time: ", 33); STRING_LITERAL(T1009139178_8, "cannot \'importc\' variable at compile time", 41); STRING_LITERAL(T1009139178_9, "cannot create null element for: ", 32); STRING_LITERAL(T1009139178_10, "VM problem: too many registers required", 39); STRING_LITERAL(T1009139178_12, "compiler/vmgen.nim", 18); NIM_CONST TY204018 T1009139178_11 = {((NimStringDesc*) &T1009139178_12), ((NI) 264)} ; STRING_LITERAL(T1009139178_13, "cannot generate code; too many registers required", 49); NIM_CONST TY204018 T1009139178_14 = {((NimStringDesc*) &T1009139178_12), ((NI) 1385)} ; STRING_LITERAL(T1009139178_15, "*", 1); STRING_LITERAL(T1009139178_16, "s.offset == -1 ", 15); NIM_CONST TY204018 T1009139178_17 = {((NimStringDesc*) &T1009139178_12), ((NI) 380)} ; STRING_LITERAL(T1009139178_18, "cannot generate code for: ", 26); NIM_CONST TY204018 T1009139178_19 = {((NimStringDesc*) &T1009139178_12), ((NI) 162)} ; STRING_LITERAL(T1009139178_20, "VM: immediate value does not fit into an int8", 45); STRING_LITERAL(T1009139178_21, "not unused", 10); STRING_LITERAL(T1009139178_22, "no field symbol", 15); STRING_LITERAL(T1009139178_23, "too large offset! cannot generate code for: ", 44); NIM_CONST TY204018 T1009139178_24 = {((NimStringDesc*) &T1009139178_12), ((NI) 453)} ; NIM_CONST TY204018 T1009139178_25 = {((NimStringDesc*) &T1009139178_12), ((NI) 254)} ; NIM_CONST TY204018 T1009139178_26 = {((NimStringDesc*) &T1009139178_12), ((NI) 965)} ; STRING_LITERAL(T1009139178_27, "getType", 7); STRING_LITERAL(T1009139178_28, "typeKind", 8); STRING_LITERAL(T1009139178_29, "getTypeInst", 11); STRING_LITERAL(T1009139178_30, "invalid bindSym usage", 21); NIM_CONST TY204018 T1009139178_31 = {((NimStringDesc*) &T1009139178_12), ((NI) 527)} ; STRING_LITERAL(T1009139178_32, "expandToAst requires 1 argument", 31); STRING_LITERAL(T1009139178_33, "expandToAst requires a call expression", 38); STRING_LITERAL(T1009139178_35, "stdlib", 6); STRING_LITERAL(T1009139178_36, "marshal", 7); STRING_LITERAL(T1009139178_37, "to", 2); NIM_CONST TY194140 T1009139178_34 = {((NimStringDesc*) &T1009139178_35), ((NimStringDesc*) &T1009139178_36), ((NimStringDesc*) &T1009139178_37)} ; STRING_LITERAL(T1009139178_39, "$$", 2); NIM_CONST TY194140 T1009139178_38 = {((NimStringDesc*) &T1009139178_35), ((NimStringDesc*) &T1009139178_36), ((NimStringDesc*) &T1009139178_39)} ; NIM_CONST TY204018 T1009139178_40 = {((NimStringDesc*) &T1009139178_12), ((NI) 1311)} ; NIM_CONST struct { TGenericSeq Sup; NI data[0]; } T1009139178_42 = {{0, 0}}; NIM_CONST Tblock344017 T1009139178_41 = {NIM_NIL, ((TY344201*)&T1009139178_42)} ; NIM_CONST TY204018 T1009139178_43 = {((NimStringDesc*) &T1009139178_12), ((NI) 154)} ; STRING_LITERAL(T1009139178_44, "VM problem: cannot find \'break\' target", 38); STRING_LITERAL(T1009139178_45, "invalid object constructor", 26); STRING_LITERAL(T1009139178_46, "VM is not allowed to \'cast\'", 27); STRING_LITERAL(T1009139178_47, "cannot generate VM code for ", 28); NIM_CONST TY204018 T1009139178_48 = {((NimStringDesc*) &T1009139178_12), ((NI) 1842)} ; STRING_LITERAL(T1009139178_49, "VM problem: dest register is not set", 36); STRING_LITERAL(T1009139178_50, "VM problem: dest register is set", 32); extern Tnode293802* emptynode_294801_850551059; extern Gcheap49818 gch_49858_1689653243; extern TNimType NTI344027; /* PProc */ extern TNimType NTI344221; /* seq[TBlock] */ extern TNimType NTI293244; /* TTypeKind */ extern TNimType NTI293524; /* TMagic */ extern TNimType NTI344201; /* seq[TPosition] */ static N_INLINE(Tnode293802*, HEX5BHEX5D_294238_850551059)(Tnode293802* n0, NI i0) { Tnode293802* result0; result0 = (Tnode293802*)0; result0 = (*n0).kindU.S6.sons->data[i0]; return result0; } static N_INLINE(Cell47305*, usrtocell_51440_1689653243)(void* usr0) { Cell47305* result0; result0 = (Cell47305*)0; result0 = ((Cell47305*) ((NI)((NU32)(((NI) (usr0))) - (NU32)(((NI)sizeof(Cell47305)))))); return result0; } static N_INLINE(void, rtladdzct_52601_1689653243)(Cell47305* c0) { addzct_51417_1689653243((&gch_49858_1689653243.zct), c0); } static N_INLINE(void, asgnRefNoCycle)(void** dest0, void* src0) { { Cell47305* c0; if (!!((src0 == NIM_NIL))) goto LA3; c0 = usrtocell_51440_1689653243(src0); (*c0).refcount += ((NI) 8); } LA3: ; { Cell47305* c0; if (!!(((*dest0) == NIM_NIL))) goto LA7; c0 = usrtocell_51440_1689653243((*dest0)); { (*c0).refcount -= ((NI) 8); if (!((NU32)((*c0).refcount) < (NU32)(((NI) 8)))) goto LA11; rtladdzct_52601_1689653243(c0); } LA11: ; } LA7: ; (*dest0) = src0; } N_NIMCALL(void, gabx_447116_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI a0, NI bx0) { { NIM_BOOL LOC3; NU32 ins0; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) -32768) <= bx0); if (!(LOC3)) goto LA4; LOC3 = (bx0 <= ((NI) 32767)); LA4: ; if (!LOC3) goto LA5; ins0 = (unsigned int)((unsigned int)(((NU32) (opc0)) | (NU32)((NU32)(((NU32) (a0))) << (NU32)(((NU32) 8)))) | (NU32)((NU32)(((NU32) ((NI)(bx0 + ((NI) 32768))))) << (NU32)(((NU32) 16)))); (*c0).code = (TY344241*) incrSeqV2(&((*c0).code)->Sup, sizeof(NU32)); (*c0).code->data[(*c0).code->Sup.len] = ins0; ++(*c0).code->Sup.len; (*c0).debug = (TY193086*) incrSeqV2(&((*c0).debug)->Sup, sizeof(Tlineinfo192336)); (*c0).debug->data[(*c0).debug->Sup.len] = (*n0).info; ++(*c0).debug->Sup.len; } goto LA1; LA5: ; { localerror_197080_155036129((*n0).info, ((Tmsgkind192002) 4), ((NimStringDesc*) &T1009139178_2)); } LA1: ; } N_NIMCALL(NI, xjmp_447264_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI a0) { NI result0; result0 = (NI)0; result0 = ((*c0).code ? (*c0).code->Sup.len : 0); gabx_447116_1009139178(c0, n0, opc0, a0, ((NI) 0)); return result0; } static N_INLINE(void, nimGCunrefNoCycle)(void* p0) { Cell47305* c0; c0 = usrtocell_51440_1689653243(p0); { (*c0).refcount -= ((NI) 8); if (!((NU32)((*c0).refcount) < (NU32)(((NI) 8)))) goto LA3; rtladdzct_52601_1689653243(c0); } LA3: ; } static N_INLINE(NI, len_294081_850551059)(Tnode293802* n0) { NI result0; result0 = (NI)0; { if (!(*n0).kindU.S6.sons == 0) goto LA3; result0 = ((NI) 0); } goto LA1; LA3: ; { result0 = ((*n0).kindU.S6.sons ? (*n0).kindU.S6.sons->Sup.len : 0); } LA1: ; return result0; } N_NIMCALL(void, genparams_453655_1009139178)(Tctx344035* c0, Tnode293802* params0) { NI LOC5; (*(*c0).prc).slots[(((NI) 0))- 0] = T1009139178_3; { NI i_453680_1009139178; NI HEX3Atmp_453690_1009139178; NI LOC2; NI res_453693_1009139178; i_453680_1009139178 = (NI)0; HEX3Atmp_453690_1009139178 = (NI)0; LOC2 = (NI)0; LOC2 = len_294081_850551059(params0); HEX3Atmp_453690_1009139178 = (LOC2 - 1); res_453693_1009139178 = ((NI) 1); { while (1) { if (!(res_453693_1009139178 <= HEX3Atmp_453690_1009139178)) goto LA4; i_453680_1009139178 = res_453693_1009139178; (*(*c0).prc).slots[(i_453680_1009139178)- 0] = T1009139178_4; res_453693_1009139178 += ((NI) 1); } LA4: ; } } LOC5 = (NI)0; LOC5 = len_294081_850551059(params0); (*(*c0).prc).maxslots = ((LOC5 >= ((NI) 1)) ? LOC5 : ((NI) 1)); } N_NIMCALL(void, gengenericparams_453745_1009139178)(Tctx344035* c0, Tnode293802* gp0) { NI base0; NI LOC5; base0 = (*(*c0).prc).maxslots; { NI i_453768_1009139178; NI HEX3Atmp_453778_1009139178; NI LOC2; NI res_453781_1009139178; i_453768_1009139178 = (NI)0; HEX3Atmp_453778_1009139178 = (NI)0; LOC2 = (NI)0; LOC2 = len_294081_850551059(gp0); HEX3Atmp_453778_1009139178 = (LOC2 - 1); res_453781_1009139178 = ((NI) 0); { while (1) { Tsym293834* param0; if (!(res_453781_1009139178 <= HEX3Atmp_453778_1009139178)) goto LA4; i_453768_1009139178 = res_453781_1009139178; param0 = (*(*gp0).kindU.S6.sons->data[i_453768_1009139178]).kindU.S4.sym; (*param0).position = (NI)(base0 + i_453768_1009139178); (*(*c0).prc).slots[((NI)(base0 + i_453768_1009139178))- 0] = T1009139178_5; res_453781_1009139178 += ((NI) 1); } LA4: ; } } LOC5 = (NI)0; LOC5 = len_294081_850551059(gp0); (*(*c0).prc).maxslots = (NI)(base0 + LOC5); } N_NIMCALL(NIM_BOOL, isownedby_450646_1009139178)(Tsym293834* a_450648_1009139178, Tsym293834* b0) { NIM_BOOL result0; Tsym293834* a0; { result0 = (NIM_BOOL)0; a0 = (*a_450648_1009139178).owner; { while (1) { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = !((a0 == NIM_NIL)); if (!(LOC3)) goto LA4; LOC3 = !(((*a0).kind == ((Tsymkind293435) 6))); LA4: ; if (!LOC3) goto LA2; { if (!(a0 == b0)) goto LA7; result0 = NIM_TRUE; goto BeforeRet; } LA7: ; a0 = (*a0).owner; } LA2: ; } }BeforeRet: ; return result0; } static N_INLINE(void, copymem_7485_1689653243)(void* dest0, void* source0, NI size0) { void* LOC1; LOC1 = (void*)0; LOC1 = memcpy(dest0, source0, ((size_t) (size0))); } static N_INLINE(void, appendString)(NimStringDesc* dest0, NimStringDesc* src0) { copymem_7485_1689653243(((void*) ((&(*dest0).data[((*dest0).Sup.len)- 0]))), ((void*) ((*src0).data)), ((NI) ((NI)((*src0).Sup.len + ((NI) 1))))); (*dest0).Sup.len += (*src0).Sup.len; } N_NOINLINE(void, cannoteval_450642_1009139178)(Tnode293802* n0) { NimStringDesc* LOC1; NimStringDesc* LOC2; LOC1 = (NimStringDesc*)0; LOC2 = (NimStringDesc*)0; LOC2 = rendertree_312044_382274130(n0, 0); LOC1 = rawNewString(LOC2->Sup.len + 33); appendString(LOC1, ((NimStringDesc*) &T1009139178_7)); appendString(LOC1, LOC2); globalerror_197071_155036129((*n0).info, ((Tmsgkind192002) 4), LOC1); } N_NIMCALL(void, checkcaneval_450700_1009139178)(Tctx344035* c0, Tnode293802* n0) { Tsym293834* s0; { s0 = (*n0).kindU.S4.sym; { if (!((8388616 & ~ (*s0).flags)==0)) goto LA3; goto BeforeRet; } LA3: ; { NIM_BOOL LOC7; NIM_BOOL LOC8; NIM_BOOL LOC9; NIM_BOOL LOC11; LOC7 = (NIM_BOOL)0; LOC8 = (NIM_BOOL)0; LOC9 = (NIM_BOOL)0; LOC9 = ((2856 &(1U<<((NU)((*s0).kind)&31U)))!=0); if (!(LOC9)) goto LA10; LOC11 = (NIM_BOOL)0; LOC11 = isownedby_450646_1009139178(s0, (*(*c0).prc).sym); LOC9 = !(LOC11); LA10: ; LOC8 = LOC9; if (!(LOC8)) goto LA12; LOC8 = !(((*s0).owner == (*c0).module)); LA12: ; LOC7 = LOC8; if (!(LOC7)) goto LA13; LOC7 = !(((*c0).mode == ((Tevalmode344019) 0))); LA13: ; if (!LOC7) goto LA14; cannoteval_450642_1009139178(n0); } goto LA5; LA14: ; { NIM_BOOL LOC17; LOC17 = (NIM_BOOL)0; LOC17 = ((61440 &(1U<<((NU)((*s0).kind)&31U)))!=0); if (!(LOC17)) goto LA18; LOC17 = (((*s0).flags &(1U<<((NU)(((Tsymflag293184) 4))&31U)))!=0); LA18: ; if (!LOC17) goto LA19; cannoteval_450642_1009139178(n0); } goto LA5; LA19: ; LA5: ; }BeforeRet: ; } N_NIMCALL(void, importcsym_451223_1009139178)(Tctx344035* c0, Tlineinfo192336 info0, Tsym293834* s0) { localerror_197080_155036129(info0, ((Tmsgkind192002) 4), ((NimStringDesc*) &T1009139178_8)); } N_NIMCALL(void, getnullvalueaux_451818_1009139178)(Tnode293802* obj0, Tnode293802* result0) { switch ((*obj0).kind) { case ((Tnodekind293020) 138): { { NI i_451833_1009139178; NI HEX3Atmp_451855_1009139178; NI LOC3; NI res_451858_1009139178; i_451833_1009139178 = (NI)0; HEX3Atmp_451855_1009139178 = (NI)0; LOC3 = (NI)0; LOC3 = sonslen_296351_850551059(obj0); HEX3Atmp_451855_1009139178 = (NI)(LOC3 - ((NI) 1)); res_451858_1009139178 = ((NI) 0); { while (1) { if (!(res_451858_1009139178 <= HEX3Atmp_451855_1009139178)) goto LA5; i_451833_1009139178 = res_451858_1009139178; getnullvalueaux_451818_1009139178((*obj0).kindU.S6.sons->data[i_451833_1009139178], result0); res_451858_1009139178 += ((NI) 1); } LA5: ; } } } break; case ((Tnodekind293020) 139): { getnullvalueaux_451818_1009139178((*obj0).kindU.S6.sons->data[((NI) 0)], result0); { NI i_451847_1009139178; NI HEX3Atmp_451863_1009139178; NI LOC8; NI res_451866_1009139178; i_451847_1009139178 = (NI)0; HEX3Atmp_451863_1009139178 = (NI)0; LOC8 = (NI)0; LOC8 = sonslen_296351_850551059(obj0); HEX3Atmp_451863_1009139178 = (NI)(LOC8 - ((NI) 1)); res_451866_1009139178 = ((NI) 1); { while (1) { Tnode293802* LOC11; if (!(res_451866_1009139178 <= HEX3Atmp_451863_1009139178)) goto LA10; i_451847_1009139178 = res_451866_1009139178; LOC11 = (Tnode293802*)0; LOC11 = lastson_296364_850551059((*obj0).kindU.S6.sons->data[i_451847_1009139178]); getnullvalueaux_451818_1009139178(LOC11, result0); res_451866_1009139178 += ((NI) 1); } LA10: ; } } } break; case ((Tnodekind293020) 3): { Tnode293802* field0; Tnode293802* LOC13; field0 = newnodei_295197_850551059(((Tnodekind293020) 34), (*result0).info); add_294136_850551059(field0, obj0); LOC13 = (Tnode293802*)0; LOC13 = getnullvalue_451401_1009139178((*(*obj0).kindU.S4.sym).typ, (*result0).info); add_294136_850551059(field0, LOC13); addson_295807_850551059(result0, field0); } break; default: { NimStringDesc* LOC15; NimStringDesc* LOC16; LOC15 = (NimStringDesc*)0; LOC16 = (NimStringDesc*)0; LOC16 = HEX24_312066_382274130(obj0); LOC15 = rawNewString(LOC16->Sup.len + 32); appendString(LOC15, ((NimStringDesc*) &T1009139178_9)); appendString(LOC15, LOC16); globalerror_197076_155036129((*result0).info, LOC15); } break; } } N_NIMCALL(Tnode293802*, getnullvalue_451401_1009139178)(Ttype293840* typ0, Tlineinfo192336 info0) { Tnode293802* result0; Ttype293840* t0; result0 = (Tnode293802*)0; t0 = skiptypes_297099_850551059(typ0, IL64(211106233624576)); result0 = emptynode_294801_850551059; switch ((*t0).kind) { case ((Ttypekind293244) 1): case ((Ttypekind293244) 14): case ((Ttypekind293244) 2): case ((Ttypekind293244) 31) ... ((Ttypekind293244) 35): { result0 = newnodeit_295801_850551059(((Tnodekind293020) 6), info0, t0); } break; case ((Ttypekind293244) 40) ... ((Ttypekind293244) 44): { result0 = newnodeit_295801_850551059(((Tnodekind293020) 11), info0, t0); } break; case ((Ttypekind293244) 36) ... ((Ttypekind293244) 39): { result0 = newnodeit_295801_850551059(((Tnodekind293020) 16), info0, t0); } break; case ((Ttypekind293244) 29): case ((Ttypekind293244) 28): { result0 = newnodeit_295801_850551059(((Tnodekind293020) 20), info0, t0); } break; case ((Ttypekind293244) 23): case ((Ttypekind293244) 26): case ((Ttypekind293244) 21): case ((Ttypekind293244) 24): case ((Ttypekind293244) 6): case ((Ttypekind293244) 7): case ((Ttypekind293244) 8): case ((Ttypekind293244) 59): case ((Ttypekind293244) 22): case ((Ttypekind293244) 5): { result0 = newnodeit_295801_850551059(((Tnodekind293020) 23), info0, t0); } break; case ((Ttypekind293244) 25): { { if (!!(((*t0).callconv == ((Tcallingconvention293002) 8)))) goto LA9; result0 = newnodeit_295801_850551059(((Tnodekind293020) 23), info0, t0); } goto LA7; LA9: ; { Tnode293802* LOC12; Tnode293802* LOC13; result0 = newnodeit_295801_850551059(((Tnodekind293020) 37), info0, t0); LOC12 = (Tnode293802*)0; LOC12 = newnodeit_295801_850551059(((Tnodekind293020) 23), info0, t0); add_294136_850551059(result0, LOC12); LOC13 = (Tnode293802*)0; LOC13 = newnodeit_295801_850551059(((Tnodekind293020) 23), info0, t0); add_294136_850551059(result0, LOC13); } LA7: ; } break; case ((Ttypekind293244) 17): { Tnode293802* LOC15; Ttype293840* base0; result0 = newnodeit_295801_850551059(((Tnodekind293020) 38), info0, t0); LOC15 = (Tnode293802*)0; LOC15 = newnodeit_295801_850551059(((Tnodekind293020) 1), info0, t0); add_294136_850551059(result0, LOC15); base0 = (*t0).sons->data[((NI) 0)]; { while (1) { Ttype293840* LOC18; if (!!((base0 == NIM_NIL))) goto LA17; LOC18 = (Ttype293840*)0; LOC18 = skiptypes_297099_850551059(base0, IL64(211106247215360)); getnullvalueaux_451818_1009139178((*LOC18).n, result0); base0 = (*base0).sons->data[((NI) 0)]; } LA17: ; } getnullvalueaux_451818_1009139178((*t0).n, result0); } break; case ((Ttypekind293244) 16): case ((Ttypekind293244) 4): { result0 = newnodeit_295801_850551059(((Tnodekind293020) 41), info0, t0); { NI i_451925_1009139178; NI HEX3Atmp_451947_1009139178; NI64 LOC21; NI res_451950_1009139178; i_451925_1009139178 = (NI)0; HEX3Atmp_451947_1009139178 = (NI)0; LOC21 = (NI64)0; LOC21 = lengthord_321007_3876443242(t0); HEX3Atmp_451947_1009139178 = (NI)(((NI) (LOC21)) - ((NI) 1)); res_451950_1009139178 = ((NI) 0); { while (1) { Ttype293840* LOC24; Tnode293802* LOC25; if (!(res_451950_1009139178 <= HEX3Atmp_451947_1009139178)) goto LA23; i_451925_1009139178 = res_451950_1009139178; LOC24 = (Ttype293840*)0; LOC24 = elemtype_321394_3876443242(t0); LOC25 = (Tnode293802*)0; LOC25 = getnullvalue_451401_1009139178(LOC24, info0); addson_295807_850551059(result0, LOC25); res_451950_1009139178 += ((NI) 1); } LA23: ; } } } break; case ((Ttypekind293244) 18): { result0 = newnodeit_295801_850551059(((Tnodekind293020) 37), info0, t0); { NI i_451937_1009139178; NI HEX3Atmp_451955_1009139178; NI LOC28; NI res_451958_1009139178; i_451937_1009139178 = (NI)0; HEX3Atmp_451955_1009139178 = (NI)0; LOC28 = (NI)0; LOC28 = sonslen_296327_850551059(t0); HEX3Atmp_451955_1009139178 = (NI)(LOC28 - ((NI) 1)); res_451958_1009139178 = ((NI) 0); { while (1) { Tnode293802* LOC31; if (!(res_451958_1009139178 <= HEX3Atmp_451955_1009139178)) goto LA30; i_451937_1009139178 = res_451958_1009139178; LOC31 = (Tnode293802*)0; LOC31 = getnullvalue_451401_1009139178((*t0).sons->data[i_451937_1009139178], info0); addson_295807_850551059(result0, LOC31); res_451958_1009139178 += ((NI) 1); } LA30: ; } } } break; case ((Ttypekind293244) 19): { result0 = newnodeit_295801_850551059(((Tnodekind293020) 39), info0, t0); } break; default: { NimStringDesc* LOC34; LOC34 = (NimStringDesc*)0; LOC34 = rawNewString(reprEnum((NI)(*t0).kind, (&NTI293244))->Sup.len + 32); appendString(LOC34, ((NimStringDesc*) &T1009139178_9)); appendString(LOC34, reprEnum((NI)(*t0).kind, (&NTI293244))); globalerror_197076_155036129(info0, LOC34); } break; } return result0; } N_NIMCALL(Tslotkind344025, getslotkind_447376_1009139178)(Ttype293840* t0) { Tslotkind344025 result0; Ttype293840* LOC1; result0 = (Tslotkind344025)0; LOC1 = (Ttype293840*)0; LOC1 = skiptypes_297099_850551059(t0, IL64(211106233624576)); switch ((*LOC1).kind) { case ((Ttypekind293244) 1): case ((Ttypekind293244) 2): case ((Ttypekind293244) 14): case ((Ttypekind293244) 15): case ((Ttypekind293244) 31) ... ((Ttypekind293244) 35): case ((Ttypekind293244) 40) ... ((Ttypekind293244) 44): { result0 = ((Tslotkind344025) 4); } break; case ((Ttypekind293244) 28): case ((Ttypekind293244) 29): { result0 = ((Tslotkind344025) 6); } break; case ((Ttypekind293244) 36) ... ((Ttypekind293244) 39): { result0 = ((Tslotkind344025) 5); } break; default: { result0 = ((Tslotkind344025) 7); } break; } return result0; } N_NIMCALL(Tlineinfo192336, besteffort_447394_1009139178)(Tctx344035* c0) { Tlineinfo192336 result0; memset((void*)(&result0), 0, sizeof(result0)); { if (!((*c0).prc == NIM_NIL)) goto LA3; result0 = (*(*c0).module).info; } goto LA1; LA3: ; { result0 = (*(*(*c0).prc).sym).info; } LA1: ; return result0; } N_NIMCALL(NI, gettemp_447412_1009139178)(Tctx344035* cc0, Ttype293840* tt0) { NI result0; Ttype293840* typ0; PprocHEX3Aobjecttype344220* c0; Tslotkind344025 k0; { result0 = (NI)0; typ0 = skiptypesornil_297115_850551059(tt0, IL64(576460752303423488)); c0 = (*cc0).prc; { if (!typ0 == 0) goto LA3; k0 = ((Tslotkind344025) 7); } goto LA1; LA3: ; { k0 = getslotkind_447376_1009139178(typ0); } LA1: ; { NI i_447438_1009139178; NI HEX3Atmp_447476_1009139178; NI res_447479_1009139178; i_447438_1009139178 = (NI)0; HEX3Atmp_447476_1009139178 = (NI)0; HEX3Atmp_447476_1009139178 = (NI)((*c0).maxslots - ((NI) 1)); res_447479_1009139178 = ((NI) 0); { while (1) { if (!(res_447479_1009139178 <= HEX3Atmp_447476_1009139178)) goto LA8; i_447438_1009139178 = res_447479_1009139178; { NIM_BOOL LOC11; LOC11 = (NIM_BOOL)0; LOC11 = ((*c0).slots[(i_447438_1009139178)- 0].Field1 == k0); if (!(LOC11)) goto LA12; LOC11 = !((*c0).slots[(i_447438_1009139178)- 0].Field0); LA12: ; if (!LOC11) goto LA13; (*c0).slots[(i_447438_1009139178)- 0].Field0 = NIM_TRUE; result0 = ((NI) (i_447438_1009139178)); goto BeforeRet; } LA13: ; res_447479_1009139178 += ((NI) 1); } LA8: ; } } { NIM_BOOL LOC17; LOC17 = (NIM_BOOL)0; LOC17 = (((NI) 40) <= (*c0).maxslots); if (!(LOC17)) goto LA18; LOC17 = NIM_FALSE; LA18: ; if (!LOC17) goto LA19; { NI i_447457_1009139178; NI HEX3Atmp_447484_1009139178; NI res_447487_1009139178; i_447457_1009139178 = (NI)0; HEX3Atmp_447484_1009139178 = (NI)0; HEX3Atmp_447484_1009139178 = (NI)((*c0).maxslots - ((NI) 1)); res_447487_1009139178 = ((NI) 0); { while (1) { if (!(res_447487_1009139178 <= HEX3Atmp_447484_1009139178)) goto LA23; i_447457_1009139178 = res_447487_1009139178; { if (!!((*c0).slots[(i_447457_1009139178)- 0].Field0)) goto LA26; (*c0).slots[(i_447457_1009139178)- 0].Field0 = NIM_TRUE; (*c0).slots[(i_447457_1009139178)- 0].Field1 = k0; result0 = ((NI) (i_447457_1009139178)); goto BeforeRet; } LA26: ; res_447487_1009139178 += ((NI) 1); } LA23: ; } } } LA19: ; { Tlineinfo192336 LOC32; if (!(((NI) 255) <= (*c0).maxslots)) goto LA30; LOC32 = besteffort_447394_1009139178(cc0); globalerror_197076_155036129(LOC32, ((NimStringDesc*) &T1009139178_10)); } LA30: ; result0 = ((NI) ((*c0).maxslots)); (*c0).slots[((*c0).maxslots)- 0].Field0 = NIM_TRUE; (*c0).slots[((*c0).maxslots)- 0].Field1 = k0; (*c0).maxslots += ((NI) 1); }BeforeRet: ; return result0; } N_NIMCALL(NI, genx_447862_1009139178)(Tctx344035* c0, Tnode293802* n0, Tgenflag446202Set flags0) { NI result0; NI tmp0; result0 = (NI)0; tmp0 = ((NI) -1); gen_447825_1009139178(c0, n0, (&tmp0), flags0); { NimStringDesc* LOC5; if (!!((((NI) 0) <= ((NI) (tmp0))))) goto LA3; LOC5 = (NimStringDesc*)0; LOC5 = HEX24_197185_1689653243(T1009139178_11); internalerror_197113_155036129(LOC5); } LA3: ; result0 = ((NI) (tmp0)); return result0; } N_NIMCALL(NIM_BOOL, istemp_450774_1009139178)(Tctx344035* c0, NI dest0) { NIM_BOOL result0; NIM_BOOL LOC1; result0 = (NIM_BOOL)0; LOC1 = (NIM_BOOL)0; LOC1 = (((NI) 0) <= ((NI) (dest0))); if (!(LOC1)) goto LA2; LOC1 = (((Tslotkind344025) 3) <= (*(*c0).prc).slots[(dest0)- 0].Field1); LA2: ; result0 = LOC1; return result0; } N_NIMCALL(NIM_BOOL, fitsregister_449844_1009139178)(Ttype293840* t0) { NIM_BOOL result0; Ttype293840* LOC1; result0 = (NIM_BOOL)0; LOC1 = (Ttype293840*)0; LOC1 = skiptypes_297099_850551059(t0, IL64(211106232576000)); result0 = ((*LOC1).kind == ((Ttypekind293244) 20) || (*LOC1).kind == ((Ttypekind293244) 14) || (*LOC1).kind == ((Ttypekind293244) 1) || (*LOC1).kind >= ((Ttypekind293244) 31) && (*LOC1).kind <= ((Ttypekind293244) 44) || (*LOC1).kind == ((Ttypekind293244) 2)); return result0; } N_NIMCALL(void, gabc_446714_1009139178)(Tctx344035* ctx0, Tnode293802* n0, Topcode344015 opc0, NI a0, NI b0, NI c0) { NU32 ins0; ins0 = (unsigned int)((unsigned int)((unsigned int)(((NU32) (opc0)) | (NU32)((NU32)(((NU32) (a0))) << (NU32)(((NU32) 8)))) | (NU32)((NU32)(((NU32) (b0))) << (NU32)(((NU32) 16)))) | (NU32)((NU32)(((NU32) (c0))) << (NU32)(((NU32) 24)))); (*ctx0).code = (TY344241*) incrSeqV2(&((*ctx0).code)->Sup, sizeof(NU32)); (*ctx0).code->data[(*ctx0).code->Sup.len] = ins0; ++(*ctx0).code->Sup.len; (*ctx0).debug = (TY193086*) incrSeqV2(&((*ctx0).debug)->Sup, sizeof(Tlineinfo192336)); (*ctx0).debug->data[(*ctx0).debug->Sup.len] = (*n0).info; ++(*ctx0).debug->Sup.len; } N_NIMCALL(Topcode344015, whichasgnopc_450420_1009139178)(Tnode293802* n0) { Topcode344015 result0; Ttype293840* LOC1; result0 = (Topcode344015)0; LOC1 = (Ttype293840*)0; LOC1 = skiptypes_297099_850551059((*n0).typ, IL64(211106233624576)); switch ((*LOC1).kind) { case ((Ttypekind293244) 1): case ((Ttypekind293244) 2): case ((Ttypekind293244) 14): case ((Ttypekind293244) 15): case ((Ttypekind293244) 31) ... ((Ttypekind293244) 35): case ((Ttypekind293244) 40) ... ((Ttypekind293244) 44): { result0 = ((Topcode344015) 4); } break; case ((Ttypekind293244) 28): case ((Ttypekind293244) 29): { result0 = ((Topcode344015) 5); } break; case ((Ttypekind293244) 36) ... ((Ttypekind293244) 39): { result0 = ((Topcode344015) 6); } break; case ((Ttypekind293244) 22): case ((Ttypekind293244) 5): case ((Ttypekind293244) 23): { result0 = ((Topcode344015) 7); } break; default: { result0 = ((Topcode344015) 8); } break; } return result0; } N_NIMCALL(void, freetemp_447493_1009139178)(Tctx344035* c_447495_1009139178, NI r0) { PprocHEX3Aobjecttype344220* c0; c0 = (*c_447495_1009139178).prc; { if (!((248 &(1U<<((NU)((*c0).slots[(r0)- 0].Field1)&15U)))!=0)) goto LA3; (*c0).slots[(r0)- 0].Field0 = NIM_FALSE; } LA3: ; } N_NIMCALL(void, preventfalsealias_450795_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI dest0, NI idx0, NI value0) { { NIM_BOOL LOC3; NIM_BOOL LOC4; NIM_BOOL LOC6; NI cc0; Topcode344015 LOC9; LOC3 = (NIM_BOOL)0; LOC4 = (NIM_BOOL)0; LOC4 = istemp_450774_1009139178(c0, ((NI) (dest0))); LOC3 = !(LOC4); if (!(LOC3)) goto LA5; LOC6 = (NIM_BOOL)0; LOC6 = fitsregister_449844_1009139178((*n0).typ); LOC3 = !(LOC6); LA5: ; if (!LOC3) goto LA7; cc0 = gettemp_447412_1009139178(c0, (*n0).typ); LOC9 = (Topcode344015)0; LOC9 = whichasgnopc_450420_1009139178(n0); gabc_446714_1009139178(c0, n0, LOC9, cc0, value0, ((NI) 0)); gabc_446714_1009139178(c0, n0, opc0, dest0, idx0, cc0); freetemp_447493_1009139178(c0, cc0); } goto LA1; LA7: ; { gabc_446714_1009139178(c0, n0, opc0, dest0, idx0, value0); } LA1: ; } N_NIMCALL(void, genglobalinit_451405_1009139178)(Tctx344035* c0, Tnode293802* n0, Tsym293834* s0) { Tnode293802* LOC1; NI dest0; LOC1 = (Tnode293802*)0; LOC1 = getnullvalue_451401_1009139178((*s0).typ, (*n0).info); add_294136_850551059((*c0).globals, LOC1); (*s0).position = len_294081_850551059((*c0).globals); dest0 = gettemp_447412_1009139178(c0, (*s0).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 150), dest0, (*s0).position); { NI tmp0; if (!!(((*s0).ast == NIM_NIL))) goto LA4; tmp0 = genx_447862_1009139178(c0, (*s0).ast, 0); preventfalsealias_450795_1009139178(c0, n0, ((Topcode344015) 18), dest0, ((NI) 0), tmp0); freetemp_447493_1009139178(c0, dest0); freetemp_447493_1009139178(c0, tmp0); } LA4: ; } N_NIMCALL(void, setslot_450609_1009139178)(Tctx344035* c0, Tsym293834* v0) { { if (!((*v0).position == ((NI) 0))) goto LA3; { if (!((*(*c0).prc).maxslots == ((NI) 0))) goto LA7; (*(*c0).prc).maxslots = ((NI) 1); } LA7: ; { if (!(((NI) 255) <= (*(*c0).prc).maxslots)) goto LA11; globalerror_197076_155036129((*v0).info, ((NimStringDesc*) &T1009139178_13)); } LA11: ; (*v0).position = (*(*c0).prc).maxslots; (*(*c0).prc).slots[((*v0).position)- 0].Field0 = NIM_TRUE; { if (!((*v0).kind == ((Tsymkind293435) 9))) goto LA15; (*(*c0).prc).slots[((*v0).position)- 0].Field1 = ((Tslotkind344025) 2); } goto LA13; LA15: ; { (*(*c0).prc).slots[((*v0).position)- 0].Field1 = ((Tslotkind344025) 1); } LA13: ; (*(*c0).prc).maxslots += ((NI) 1); } LA3: ; } N_NIMCALL(void, genasgn_450442_1009139178)(Tctx344035* c0, NI dest0, Tnode293802* ri0, NIM_BOOL requirescopy0) { NI tmp0; Topcode344015 LOC1; tmp0 = genx_447862_1009139178(c0, ri0, 0); LOC1 = (Topcode344015)0; LOC1 = whichasgnopc_450420_1009139178(ri0); gabc_446714_1009139178(c0, ri0, LOC1, ((NI) (dest0)), tmp0, ((NI) ((NI)(((NI) 1) - ((NI) (requirescopy0)))))); freetemp_447493_1009139178(c0, tmp0); } N_NIMCALL(void, genrdvar_451432_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0) { Tsym293834* s0; s0 = (*n0).kindU.S4.sym; { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = (((*s0).flags &(1U<<((NU)(((Tsymflag293184) 3))&31U)))!=0); if (!(LOC3)) goto LA4; LOC3 = !(((*s0).kind == ((Tsymkind293435) 20))); LA4: ; if (!LOC3) goto LA5; { NIM_BOOL LOC9; LOC9 = (NIM_BOOL)0; LOC9 = (((*s0).flags &(1U<<((NU)(((Tsymflag293184) 23))&31U)))!=0); if (LOC9) goto LA10; LOC9 = ((*c0).mode == ((Tevalmode344019) 0)); LA10: ; if (!LOC9) goto LA11; } goto LA7; LA11: ; { if (!((*s0).position == ((NI) 0))) goto LA14; cannoteval_450642_1009139178(n0); } goto LA7; LA14: ; LA7: ; { if (!((*s0).position == ((NI) 0))) goto LA18; { if (!(((*s0).flags &(1U<<((NU)(((Tsymflag293184) 5))&31U)))!=0)) goto LA22; importcsym_451223_1009139178(c0, (*n0).info, s0); } goto LA20; LA22: ; { genglobalinit_451405_1009139178(c0, n0, s0); } LA20: ; } LA18: ; { NI LOC29; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA27; LOC29 = (NI)0; LOC29 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC29)); } LA27: ; { NIM_BOOL LOC32; NI cc0; LOC32 = (NIM_BOOL)0; LOC32 = !(((flags0 &(1U<<((NU)(((Tgenflag446202) 0))&7U)))!=0)); if (!(LOC32)) goto LA33; LOC32 = fitsregister_449844_1009139178((*s0).typ); LA33: ; if (!LOC32) goto LA34; cc0 = gettemp_447412_1009139178(c0, (*n0).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 150), cc0, (*s0).position); gabc_446714_1009139178(c0, n0, ((Topcode344015) 10), ((NI) ((*dest0))), cc0, ((NI) 0)); freetemp_447493_1009139178(c0, cc0); } goto LA30; LA34: ; { if (!((3 & flags0) == 1)) goto LA37; gabx_447116_1009139178(c0, n0, ((Topcode344015) 151), ((NI) ((*dest0))), (*s0).position); } goto LA30; LA37: ; { gabx_447116_1009139178(c0, n0, ((Topcode344015) 150), ((NI) ((*dest0))), (*s0).position); } LA30: ; } goto LA1; LA5: ; { { NIM_BOOL LOC43; LOC43 = (NIM_BOOL)0; LOC43 = ((*s0).kind == ((Tsymkind293435) 20)); if (!(LOC43)) goto LA44; LOC43 = ((*c0).mode == ((Tevalmode344019) 0)); LA44: ; if (!LOC43) goto LA45; setslot_450609_1009139178(c0, s0); } LA45: ; { NIM_BOOL LOC49; NIM_BOOL LOC51; LOC49 = (NIM_BOOL)0; LOC49 = (((NI) 0) < (*s0).position); if (LOC49) goto LA50; LOC51 = (NIM_BOOL)0; LOC51 = ((*s0).position == ((NI) 0)); if (!(LOC51)) goto LA52; LOC51 = ((2056 &(1U<<((NU)((*s0).kind)&31U)))!=0); LA52: ; LOC49 = LOC51; LA50: ; if (!LOC49) goto LA53; { if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA57; (*dest0) = ((NI) ((NI)((*s0).position + ((NI) (((*s0).kind == ((Tsymkind293435) 3))))))); { NimStringDesc* LOC63; if (!!(((*(*c0).prc).slots[((*dest0))- 0].Field1 < ((Tslotkind344025) 3)))) goto LA61; LOC63 = (NimStringDesc*)0; LOC63 = HEX24_197185_1689653243(T1009139178_14); internalerror_197113_155036129(LOC63); } LA61: ; } goto LA55; LA57: ; { genasgn_450442_1009139178(c0, (*dest0), n0, (((Tslotkind344025) 3) <= (*(*c0).prc).slots[((*dest0))- 0].Field1)); } LA55: ; } goto LA47; LA53: ; { cannoteval_450642_1009139178(n0); } LA47: ; } LA1: ; } static N_INLINE(NIM_BOOL, equalmem_7495_1689653243)(void* a0, void* b0, NI size0) { NIM_BOOL result0; int LOC1; result0 = (NIM_BOOL)0; LOC1 = (int)0; LOC1 = memcmp(a0, b0, ((size_t) (size0))); result0 = (LOC1 == ((NI32) 0)); return result0; } static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a0, NimStringDesc* b0) { NIM_BOOL result0; NIM_BOOL LOC11; { result0 = (NIM_BOOL)0; { if (!(a0 == b0)) goto LA3; result0 = NIM_TRUE; goto BeforeRet; } LA3: ; { NIM_BOOL LOC7; LOC7 = (NIM_BOOL)0; LOC7 = (a0 == NIM_NIL); if (LOC7) goto LA8; LOC7 = (b0 == NIM_NIL); LA8: ; if (!LOC7) goto LA9; result0 = NIM_FALSE; goto BeforeRet; } LA9: ; LOC11 = (NIM_BOOL)0; LOC11 = ((*a0).Sup.len == (*b0).Sup.len); if (!(LOC11)) goto LA12; LOC11 = equalmem_7495_1689653243(((void*) ((*a0).data)), ((void*) ((*b0).data)), ((NI) ((*a0).Sup.len))); LA12: ; result0 = LOC11; goto BeforeRet; }BeforeRet: ; return result0; } N_NIMCALL(NIM_BOOL, matches_452871_1009139178)(Tsym293834* s_452873_1009139178, NimStringDesc* x0) { NIM_BOOL result0; TY135002* y0; Tsym293834* s0; NI L0; { result0 = (NIM_BOOL)0; y0 = nsuSplitChar(x0, 46, ((NI) -1)); s0 = s_452873_1009139178; L0 = (NI)((y0 ? y0->Sup.len : 0) - ((NI) 1)); { while (1) { if (!(((NI) 0) <= L0)) goto LA2; { NIM_BOOL LOC5; NIM_BOOL LOC7; NI LOC8; LOC5 = (NIM_BOOL)0; LOC5 = (s0 == NIM_NIL); if (LOC5) goto LA6; LOC7 = (NIM_BOOL)0; LOC8 = (NI)0; LOC8 = nsuCmpIgnoreStyle(y0->data[L0], (*(*s0).name).s); LOC7 = !((LOC8 == ((NI) 0))); if (!(LOC7)) goto LA9; LOC7 = !(eqStrings(y0->data[L0], ((NimStringDesc*) &T1009139178_15))); LA9: ; LOC5 = LOC7; LA6: ; if (!LOC5) goto LA10; result0 = NIM_FALSE; goto BeforeRet; } LA10: ; s0 = (*s0).owner; L0 -= ((NI) 1); } LA2: ; } result0 = NIM_TRUE; }BeforeRet: ; return result0; } N_NIMCALL(NIM_BOOL, prociscallback_452963_1009139178)(Tctx344035* c0, Tsym293834* s0) { NIM_BOOL result0; NI i0; { result0 = (NIM_BOOL)0; { if (!((*s0).offset < ((NI) -1))) goto LA3; result0 = NIM_TRUE; goto BeforeRet; } LA3: ; i0 = ((NI) -2); { NimStringDesc* key_453202_1009139178; Vmcallback344031 value_453203_1009139178; TY344260* HEX3Atmp_453219_1009139178; NI i_453222_1009139178; NI L_453224_1009139178; key_453202_1009139178 = (NimStringDesc*)0; memset((void*)(&value_453203_1009139178), 0, sizeof(value_453203_1009139178)); HEX3Atmp_453219_1009139178 = (TY344260*)0; HEX3Atmp_453219_1009139178 = (*c0).callbacks; i_453222_1009139178 = ((NI) 0); L_453224_1009139178 = (HEX3Atmp_453219_1009139178 ? HEX3Atmp_453219_1009139178->Sup.len : 0); { while (1) { if (!(i_453222_1009139178 < L_453224_1009139178)) goto LA7; key_453202_1009139178 = HEX3Atmp_453219_1009139178->data[i_453222_1009139178].Field0; value_453203_1009139178.ClEnv = HEX3Atmp_453219_1009139178->data[i_453222_1009139178].Field1.ClEnv; value_453203_1009139178.ClPrc = HEX3Atmp_453219_1009139178->data[i_453222_1009139178].Field1.ClPrc; { NIM_BOOL LOC10; LOC10 = (NIM_BOOL)0; LOC10 = matches_452871_1009139178(s0, key_453202_1009139178); if (!LOC10) goto LA11; { if (!!(((*s0).offset == ((NI) -1)))) goto LA15; raiseassert_91216_1689653243(((NimStringDesc*) &T1009139178_16)); } LA15: ; (*s0).offset = i0; result0 = NIM_TRUE; goto BeforeRet; } LA11: ; i0 -= ((NI) 1); i_453222_1009139178 += ((NI) 1); } LA7: ; } } }BeforeRet: ; return result0; } N_NIMCALL(NIM_BOOL, sameconstant_448274_1009139178)(Tnode293802* a0, Tnode293802* b0) { NIM_BOOL result0; { result0 = (NIM_BOOL)0; result0 = NIM_FALSE; { if (!(a0 == b0)) goto LA3; result0 = NIM_TRUE; } goto LA1; LA3: ; { NIM_BOOL LOC6; NIM_BOOL LOC7; LOC6 = (NIM_BOOL)0; LOC7 = (NIM_BOOL)0; LOC7 = !((a0 == NIM_NIL)); if (!(LOC7)) goto LA8; LOC7 = !((b0 == NIM_NIL)); LA8: ; LOC6 = LOC7; if (!(LOC6)) goto LA9; LOC6 = ((*a0).kind == (*b0).kind); LA9: ; if (!LOC6) goto LA10; switch ((*a0).kind) { case ((Tnodekind293020) 3): { result0 = ((*a0).kindU.S4.sym == (*b0).kindU.S4.sym); } break; case ((Tnodekind293020) 2): { result0 = ((*(*a0).kindU.S5.ident).Sup.id == (*(*b0).kindU.S5.ident).Sup.id); } break; case ((Tnodekind293020) 5) ... ((Tnodekind293020) 15): { result0 = ((*a0).kindU.S1.intval == (*b0).kindU.S1.intval); } break; case ((Tnodekind293020) 16) ... ((Tnodekind293020) 18): { result0 = ((*a0).kindU.S2.floatval == (*b0).kindU.S2.floatval); } break; case ((Tnodekind293020) 20) ... ((Tnodekind293020) 22): { result0 = eqStrings((*a0).kindU.S3.strval, (*b0).kindU.S3.strval); } break; case ((Tnodekind293020) 4): case ((Tnodekind293020) 23): { result0 = ((*a0).typ == (*b0).typ); } break; case ((Tnodekind293020) 1): { result0 = NIM_TRUE; } break; default: { { NI LOC22; NI LOC23; LOC22 = (NI)0; LOC22 = sonslen_296351_850551059(a0); LOC23 = (NI)0; LOC23 = sonslen_296351_850551059(b0); if (!(LOC22 == LOC23)) goto LA24; { NI i_448366_1009139178; NI HEX3Atmp_448370_1009139178; NI LOC27; NI res_448373_1009139178; i_448366_1009139178 = (NI)0; HEX3Atmp_448370_1009139178 = (NI)0; LOC27 = (NI)0; LOC27 = sonslen_296351_850551059(a0); HEX3Atmp_448370_1009139178 = (NI)(LOC27 - ((NI) 1)); res_448373_1009139178 = ((NI) 0); { while (1) { if (!(res_448373_1009139178 <= HEX3Atmp_448370_1009139178)) goto LA29; i_448366_1009139178 = res_448373_1009139178; { NIM_BOOL LOC32; LOC32 = (NIM_BOOL)0; LOC32 = sameconstant_448274_1009139178((*a0).kindU.S6.sons->data[i_448366_1009139178], (*b0).kindU.S6.sons->data[i_448366_1009139178]); if (!!(LOC32)) goto LA33; goto BeforeRet; } LA33: ; res_448373_1009139178 += ((NI) 1); } LA29: ; } } result0 = NIM_TRUE; } LA24: ; } break; } } goto LA1; LA10: ; LA1: ; }BeforeRet: ; return result0; } N_NIMCALL(Tnode293802*, canonvalue_448244_1009139178)(Tnode293802* n0) { Tnode293802* result0; result0 = (Tnode293802*)0; result0 = n0; return result0; } N_NIMCALL(NI, rawgenliteral_448248_1009139178)(Tctx344035* c0, Tnode293802* n0) { NI result0; Tnode293802* LOC1; result0 = (NI)0; result0 = len_294081_850551059((*c0).constants); (*n0).flags |= ((NU16)1)<<((((Tnodeflag293427) 4))%(sizeof(NU16)*8)); LOC1 = (Tnode293802*)0; LOC1 = canonvalue_448244_1009139178(n0); add_294136_850551059((*c0).constants, LOC1); { NimStringDesc* LOC6; if (!!((result0 < ((NI) 32767)))) goto LA4; LOC6 = (NimStringDesc*)0; LOC6 = HEX24_197185_1689653243(T1009139178_17); internalerror_197113_155036129(LOC6); } LA4: ; return result0; } N_NIMCALL(NI, genliteral_448377_1009139178)(Tctx344035* c0, Tnode293802* n0) { NI result0; { result0 = (NI)0; { NI i_448400_1009139178; NI HEX3Atmp_448402_1009139178; NI LOC2; NI res_448405_1009139178; i_448400_1009139178 = (NI)0; HEX3Atmp_448402_1009139178 = (NI)0; LOC2 = (NI)0; LOC2 = len_294081_850551059((*c0).constants); HEX3Atmp_448402_1009139178 = (LOC2 - 1); res_448405_1009139178 = ((NI) 0); { while (1) { if (!(res_448405_1009139178 <= HEX3Atmp_448402_1009139178)) goto LA4; i_448400_1009139178 = res_448405_1009139178; { Tnode293802* LOC7; NIM_BOOL LOC8; LOC7 = (Tnode293802*)0; LOC7 = HEX5BHEX5D_294238_850551059((*c0).constants, i_448400_1009139178); LOC8 = (NIM_BOOL)0; LOC8 = sameconstant_448274_1009139178(LOC7, n0); if (!LOC8) goto LA9; result0 = i_448400_1009139178; goto BeforeRet; } LA9: ; res_448405_1009139178 += ((NI) 1); } LA4: ; } } result0 = rawgenliteral_448248_1009139178(c0, n0); }BeforeRet: ; return result0; } N_NIMCALL(void, genlit_448891_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI lit0; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; lit0 = genliteral_448377_1009139178(c0, n0); gabx_447116_1009139178(c0, n0, ((Topcode344015) 148), ((NI) ((*dest0))), lit0); } N_NIMCALL(void, gentypelit_451216_1009139178)(Tctx344035* c0, Ttype293840* t0, NI* dest0) { Tnode293802* n0; n0 = newnode_294401_850551059(((Tnodekind293020) 4)); asgnRefNoCycle((void**) (&(*n0).typ), t0); genlit_448891_1009139178(c0, n0, dest0); } N_NIMCALL(void, patch_447318_1009139178)(Tctx344035* c0, NI p_447321_1009139178) { NI p0; NI diff0; NU32 oldinstr0; p0 = p_447321_1009139178; diff0 = (NI)(((*c0).code ? (*c0).code->Sup.len : 0) - p0); { NIM_BOOL LOC3; NimStringDesc* LOC7; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) -32767) < diff0); if (!(LOC3)) goto LA4; LOC3 = (diff0 < ((NI) 32767)); LA4: ; if (!!(LOC3)) goto LA5; LOC7 = (NimStringDesc*)0; LOC7 = HEX24_197185_1689653243(T1009139178_19); internalerror_197113_155036129(LOC7); } LA5: ; oldinstr0 = (*c0).code->data[p0]; (*c0).code->data[p0] = (unsigned int)(((NU32) ((NU32)(oldinstr0 & ((NU32) 65535)))) | (NU32)((NU32)(((NU32) ((NI)(diff0 + ((NI) 32768))))) << (NU32)(((NU32) 16)))); } N_NIMCALL(void, genandor_448234_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI* dest0) { NI L10; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; gen_447825_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], dest0, 0); L10 = xjmp_447264_1009139178(c0, n0, opc0, ((NI) ((*dest0)))); gen_447825_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], dest0, 0); patch_447318_1009139178(c0, L10); } N_NIMCALL(void, gabi_447026_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0, NI a0, NI b0, NI64 imm0) { { NIM_BOOL LOC3; NU32 ins0; LOC3 = (NIM_BOOL)0; LOC3 = (IL64(-128) <= imm0); if (!(LOC3)) goto LA4; LOC3 = (imm0 <= IL64(127)); LA4: ; if (!LOC3) goto LA5; ins0 = (unsigned int)((unsigned int)((unsigned int)(((NU32) (opc0)) | (NU32)((NU32)(((NU32) (a0))) << (NU32)(((NU32) 8)))) | (NU32)((NU32)(((NU32) (b0))) << (NU32)(((NU32) 16)))) | (NU32)((NU32)(((NU32) ((NI64)(imm0 + IL64(128))))) << (NU32)(((NU32) 24)))); (*c0).code = (TY344241*) incrSeqV2(&((*c0).code)->Sup, sizeof(NU32)); (*c0).code->data[(*c0).code->Sup.len] = ins0; ++(*c0).code->Sup.len; (*c0).debug = (TY193086*) incrSeqV2(&((*c0).debug)->Sup, sizeof(Tlineinfo192336)); (*c0).debug->data[(*c0).debug->Sup.len] = (*n0).info; ++(*c0).debug->Sup.len; } goto LA1; LA5: ; { localerror_197080_155036129((*n0).info, ((Tmsgkind192002) 4), ((NimStringDesc*) &T1009139178_20)); } LA1: ; } N_NIMCALL(NIM_BOOL, isint8lit_449453_1009139178)(Tnode293802* n0) { NIM_BOOL result0; result0 = (NIM_BOOL)0; { NIM_BOOL LOC5; if (!((*n0).kind >= ((Tnodekind293020) 5) && (*n0).kind <= ((Tnodekind293020) 15))) goto LA3; LOC5 = (NIM_BOOL)0; LOC5 = (IL64(-128) <= (*n0).kindU.S1.intval); if (!(LOC5)) goto LA6; LOC5 = ((*n0).kindU.S1.intval <= IL64(127)); LA6: ; result0 = LOC5; } LA3: ; return result0; } N_NIMCALL(void, genbinaryabc_449232_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { NI tmp0; NI tmp20; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); tmp20 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], 0); { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; gabc_446714_1009139178(c0, n0, opc0, ((NI) ((*dest0))), tmp0, tmp20); freetemp_447493_1009139178(c0, tmp0); freetemp_447493_1009139178(c0, tmp20); } N_NIMCALL(void, gennarrow_449256_1009139178)(Tctx344035* c0, Tnode293802* n0, NI dest0) { Ttype293840* t0; t0 = skiptypes_297099_850551059((*n0).typ, IL64(211106240964608)); { if (!((*t0).kind >= ((Ttypekind293244) 41) && (*t0).kind <= ((Ttypekind293244) 43))) goto LA3; gabc_446714_1009139178(c0, n0, ((Topcode344015) 89), ((NI) (dest0)), ((NI) ((NI64)((*t0).size * IL64(8)))), ((NI) 0)); } goto LA1; LA3: ; { if (!((*t0).kind >= ((Ttypekind293244) 32) && (*t0).kind <= ((Ttypekind293244) 34))) goto LA6; gabc_446714_1009139178(c0, n0, ((Topcode344015) 88), ((NI) (dest0)), ((NI) ((NI64)((*t0).size * IL64(8)))), ((NI) 0)); } goto LA1; LA6: ; LA1: ; } N_NIMCALL(void, genaddsubint_449495_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { { NIM_BOOL LOC3; NI tmp0; LOC3 = (NIM_BOOL)0; LOC3 = isint8lit_449453_1009139178((*n0).kindU.S6.sons->data[((NI) 2)]); if (!LOC3) goto LA4; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); { NI LOC10; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA8; LOC10 = (NI)0; LOC10 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC10)); } LA8: ; gabi_447026_1009139178(c0, n0, (Topcode344015)(opc0 + ((NI) 1)), ((NI) ((*dest0))), tmp0, (*(*n0).kindU.S6.sons->data[((NI) 2)]).kindU.S1.intval); freetemp_447493_1009139178(c0, tmp0); } goto LA1; LA4: ; { genbinaryabc_449232_1009139178(c0, n0, dest0, opc0); } LA1: ; gennarrow_449256_1009139178(c0, n0, (*dest0)); } static N_INLINE(void, unused_448409_1009139178)(Tnode293802* n0, NI x0) { { if (!(((NI) 0) <= ((NI) (x0)))) goto LA3; globalerror_197076_155036129((*n0).info, ((NimStringDesc*) &T1009139178_21)); } LA3: ; } N_NIMCALL(NI, genindex_449073_1009139178)(Tctx344035* c0, Tnode293802* n0, Ttype293840* arr0) { NI result0; result0 = (NI)0; { NIM_BOOL LOC3; Ttype293840* LOC4; NI64 x0; NI tmp0; LOC3 = (NIM_BOOL)0; LOC4 = (Ttype293840*)0; LOC4 = skiptypes_297099_850551059(arr0, IL64(211106232576256)); LOC3 = ((*LOC4).kind == ((Ttypekind293244) 16)); if (!(LOC3)) goto LA5; x0 = firstord_321001_3876443242(arr0); LOC3 = !((x0 == IL64(0))); LA5: ; if (!LOC3) goto LA6; tmp0 = genx_447862_1009139178(c0, n0, 0); freetemp_447493_1009139178(c0, tmp0); result0 = gettemp_447412_1009139178(c0, (*n0).typ); gabi_447026_1009139178(c0, n0, ((Topcode344015) 24), result0, tmp0, ((NI64) (((NI) (x0))))); } goto LA1; LA6: ; { result0 = genx_447862_1009139178(c0, n0, 0); } LA1: ; return result0; } N_NIMCALL(NI, genfield_449043_1009139178)(Tnode293802* n0) { NI result0; Tsym293834* s0; result0 = (NI)0; { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = !(((*n0).kind == ((Tnodekind293020) 3))); if (LOC3) goto LA4; LOC3 = !(((*(*n0).kindU.S4.sym).kind == ((Tsymkind293435) 18))); LA4: ; if (!LOC3) goto LA5; globalerror_197076_155036129((*n0).info, ((NimStringDesc*) &T1009139178_22)); } LA5: ; s0 = (*n0).kindU.S4.sym; { NimStringDesc* LOC11; if (!(((NI) 255) < (*s0).position)) goto LA9; LOC11 = (NimStringDesc*)0; LOC11 = rawNewString((*(*s0).name).s->Sup.len + 44); appendString(LOC11, ((NimStringDesc*) &T1009139178_23)); appendString(LOC11, (*(*s0).name).s); globalerror_197076_155036129((*n0).info, LOC11); } LA9: ; result0 = ((NI) ((*s0).position)); return result0; } N_NIMCALL(void, genasgnpatch_449090_1009139178)(Tctx344035* c0, Tnode293802* le0, NI value0) { switch ((*le0).kind) { case ((Tnodekind293020) 42): { NI dest0; NI idx0; dest0 = genx_447862_1009139178(c0, (*le0).kindU.S6.sons->data[((NI) 0)], 3); idx0 = genindex_449073_1009139178(c0, (*le0).kindU.S6.sons->data[((NI) 1)], (*(*le0).kindU.S6.sons->data[((NI) 0)]).typ); gabc_446714_1009139178(c0, le0, ((Topcode344015) 12), dest0, idx0, value0); freetemp_447493_1009139178(c0, dest0); freetemp_447493_1009139178(c0, idx0); } break; case ((Tnodekind293020) 45): case ((Tnodekind293020) 46): { Tnode293802* left0; NI dest0; NI idx0; { if (!((*le0).kind == ((Tnodekind293020) 45))) goto LA5; left0 = le0; } goto LA3; LA5: ; { left0 = (*le0).kindU.S6.sons->data[((NI) 0)]; } LA3: ; dest0 = genx_447862_1009139178(c0, (*left0).kindU.S6.sons->data[((NI) 0)], 3); idx0 = genfield_449043_1009139178((*left0).kindU.S6.sons->data[((NI) 1)]); gabc_446714_1009139178(c0, left0, ((Topcode344015) 14), dest0, idx0, value0); freetemp_447493_1009139178(c0, dest0); } break; case ((Tnodekind293020) 47): case ((Tnodekind293020) 65): { NI dest0; dest0 = genx_447862_1009139178(c0, (*le0).kindU.S6.sons->data[((NI) 0)], 1); gabc_446714_1009139178(c0, le0, ((Topcode344015) 18), dest0, ((NI) 0), value0); freetemp_447493_1009139178(c0, dest0); } break; case ((Tnodekind293020) 3): { { NIM_BOOL LOC12; NI dest0; LOC12 = (NIM_BOOL)0; LOC12 = (((*(*le0).kindU.S4.sym).flags &(1U<<((NU)(((Tsymflag293184) 3))&31U)))!=0); if (!(LOC12)) goto LA13; LOC12 = !(((*(*le0).kindU.S4.sym).kind == ((Tsymkind293435) 20))); LA13: ; if (!LOC12) goto LA14; dest0 = genx_447862_1009139178(c0, le0, 1); gabc_446714_1009139178(c0, le0, ((Topcode344015) 18), dest0, ((NI) 0), value0); freetemp_447493_1009139178(c0, dest0); } LA14: ; } break; default: { } break; } } N_NIMCALL(NIM_BOOL, needsasgnpatch_448997_1009139178)(Tnode293802* n0) { NIM_BOOL result0; NIM_BOOL LOC1; NIM_BOOL LOC3; NIM_BOOL LOC5; result0 = (NIM_BOOL)0; LOC1 = (NIM_BOOL)0; LOC1 = ((*n0).kind == ((Tnodekind293020) 42) || (*n0).kind == ((Tnodekind293020) 45) || (*n0).kind == ((Tnodekind293020) 46) || (*n0).kind == ((Tnodekind293020) 47) || (*n0).kind == ((Tnodekind293020) 65)); if (LOC1) goto LA2; LOC3 = (NIM_BOOL)0; LOC3 = ((*n0).kind == ((Tnodekind293020) 3)); if (!(LOC3)) goto LA4; LOC5 = (NIM_BOOL)0; LOC5 = (((*(*n0).kindU.S4.sym).flags &(1U<<((NU)(((Tsymflag293184) 3))&31U)))!=0); if (!(LOC5)) goto LA6; LOC5 = !(((*(*n0).kindU.S4.sym).kind == ((Tsymkind293435) 20))); LA6: ; LOC3 = LOC5; LA4: ; LOC1 = LOC3; LA2: ; result0 = LOC1; return result0; } N_NIMCALL(NI, gentype_448502_1009139178)(Tctx344035* c0, Ttype293840* typ0) { NI result0; { result0 = (NI)0; { NI i_448540_1009139178; Ttype293840* t_448541_1009139178; Ttypeseq293836* HEX3Atmp_448569_1009139178; NI i_448572_1009139178; i_448540_1009139178 = (NI)0; t_448541_1009139178 = (Ttype293840*)0; HEX3Atmp_448569_1009139178 = (Ttypeseq293836*)0; HEX3Atmp_448569_1009139178 = (*c0).types; i_448572_1009139178 = ((NI) 0); { while (1) { if (!(i_448572_1009139178 < (HEX3Atmp_448569_1009139178 ? HEX3Atmp_448569_1009139178->Sup.len : 0))) goto LA3; i_448540_1009139178 = i_448572_1009139178; t_448541_1009139178 = HEX3Atmp_448569_1009139178->data[i_448572_1009139178]; { NIM_BOOL LOC6; LOC6 = (NIM_BOOL)0; LOC6 = sametype_325633_3876443242(t_448541_1009139178, typ0, 0); if (!LOC6) goto LA7; result0 = i_448540_1009139178; goto BeforeRet; } LA7: ; i_448572_1009139178 += ((NI) 1); } LA3: ; } } result0 = ((*c0).types ? (*c0).types->Sup.len : 0); (*c0).types = (Ttypeseq293836*) incrSeqV2(&((*c0).types)->Sup, sizeof(Ttype293840*)); asgnRefNoCycle((void**) (&(*c0).types->data[(*c0).types->Sup.len]), typ0); ++(*c0).types->Sup.len; { NimStringDesc* LOC13; if (!!((result0 <= ((NI) 32767)))) goto LA11; LOC13 = (NimStringDesc*)0; LOC13 = HEX24_197185_1689653243(T1009139178_24); internalerror_197113_155036129(LOC13); } LA11: ; }BeforeRet: ; return result0; } N_NIMCALL(void, gennew_449144_1009139178)(Tctx344035* c0, Tnode293802* n0) { NI dest0; Ttype293840* LOC7; NI LOC8; { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = needsasgnpatch_448997_1009139178((*n0).kindU.S6.sons->data[((NI) 1)]); if (!LOC3) goto LA4; dest0 = gettemp_447412_1009139178(c0, (*(*n0).kindU.S6.sons->data[((NI) 1)]).typ); } goto LA1; LA4: ; { dest0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); } LA1: ; LOC7 = (Ttype293840*)0; LOC7 = skiptypes_297099_850551059((*(*n0).kindU.S6.sons->data[((NI) 1)]).typ, IL64(211106240964608)); LOC8 = (NI)0; LOC8 = gentype_448502_1009139178(c0, (*LOC7).sons->data[((NI) 0)]); gabx_447116_1009139178(c0, n0, ((Topcode344015) 144), dest0, LOC8); genasgnpatch_449090_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], dest0); freetemp_447493_1009139178(c0, dest0); } N_NIMCALL(void, gennewseq_449167_1009139178)(Tctx344035* c0, Tnode293802* n0) { Ttype293840* t0; NI dest0; NI tmp0; Ttype293840* LOC7; NI LOC8; t0 = (*(*n0).kindU.S6.sons->data[((NI) 1)]).typ; { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = needsasgnpatch_448997_1009139178((*n0).kindU.S6.sons->data[((NI) 1)]); if (!LOC3) goto LA4; dest0 = gettemp_447412_1009139178(c0, t0); } goto LA1; LA4: ; { dest0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); } LA1: ; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], 0); LOC7 = (Ttype293840*)0; LOC7 = skiptypes_297099_850551059(t0, IL64(211106240964608)); LOC8 = (NI)0; LOC8 = gentype_448502_1009139178(c0, LOC7); gabx_447116_1009139178(c0, n0, ((Topcode344015) 145), dest0, LOC8); gabx_447116_1009139178(c0, n0, ((Topcode344015) 145), tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); genasgnpatch_449090_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], dest0); freetemp_447493_1009139178(c0, dest0); } N_NIMCALL(void, gennewseqofcap_449192_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { Ttype293840* t0; NI tmp0; NI LOC1; Ttype293840* LOC2; NI LOC3; t0 = (*n0).typ; tmp0 = gettemp_447412_1009139178(c0, (*(*n0).kindU.S6.sons->data[((NI) 1)]).typ); LOC1 = (NI)0; LOC1 = gentype_448502_1009139178(c0, t0); gabx_447116_1009139178(c0, n0, ((Topcode344015) 146), ((NI) ((*dest0))), LOC1); gabx_447116_1009139178(c0, n0, ((Topcode344015) 152), tmp0, ((NI) 0)); LOC2 = (Ttype293840*)0; LOC2 = skiptypes_297099_850551059(t0, IL64(211106240964608)); LOC3 = (NI)0; LOC3 = gentype_448502_1009139178(c0, LOC2); gabx_447116_1009139178(c0, n0, ((Topcode344015) 145), ((NI) ((*dest0))), LOC3); gabx_447116_1009139178(c0, n0, ((Topcode344015) 145), tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } N_NIMCALL(void, genunaryabc_449214_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { NI tmp0; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; gabc_446714_1009139178(c0, n0, opc0, ((NI) ((*dest0))), tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } N_NIMCALL(void, genunaryabi_449223_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { NI tmp0; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; gabi_447026_1009139178(c0, n0, opc0, ((NI) ((*dest0))), tmp0, IL64(0)); freetemp_447493_1009139178(c0, tmp0); } N_NIMCALL(void, gensettype_449341_1009139178)(Tctx344035* c0, Tnode293802* n0, NI dest0) { Ttype293840* t0; t0 = skiptypes_297099_850551059((*n0).typ, IL64(211106232576000)); { NI LOC5; if (!((*t0).kind == ((Ttypekind293244) 19))) goto LA3; LOC5 = (NI)0; LOC5 = gentype_448502_1009139178(c0, t0); gabx_447116_1009139178(c0, n0, ((Topcode344015) 154), dest0, LOC5); } LA3: ; } N_NIMCALL(void, gencard_449547_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI tmp0; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; gensettype_449341_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], tmp0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 30), ((NI) ((*dest0))), tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } N_NIMCALL(void, genbinaryabcnarrow_449327_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { genbinaryabc_449232_1009139178(c0, n0, dest0, opc0); gennarrow_449256_1009139178(c0, n0, (*dest0)); } N_NIMCALL(void, gennarrowu_449297_1009139178)(Tctx344035* c0, Tnode293802* n0, NI dest0) { Ttype293840* t0; t0 = skiptypes_297099_850551059((*n0).typ, IL64(211106240964608)); { if (!((*t0).kind >= ((Ttypekind293244) 41) && (*t0).kind <= ((Ttypekind293244) 43) || (*t0).kind >= ((Ttypekind293244) 32) && (*t0).kind <= ((Ttypekind293244) 34))) goto LA3; gabc_446714_1009139178(c0, n0, ((Topcode344015) 89), ((NI) (dest0)), ((NI) ((NI64)((*t0).size * IL64(8)))), ((NI) 0)); } LA3: ; } N_NIMCALL(void, genbinaryabcnarrowu_449334_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { genbinaryabc_449232_1009139178(c0, n0, dest0, opc0); gennarrowu_449297_1009139178(c0, n0, (*dest0)); } N_NIMCALL(void, genconv_449518_1009139178)(Tctx344035* c0, Tnode293802* n0, Tnode293802* arg0, NI* dest0, Topcode344015 opc0) { NI tmp0; Ttype293840* LOC12; NI LOC13; Ttype293840* LOC14; NI LOC15; { { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = ((*(*n0).typ).kind == (*(*arg0).typ).kind); if (!(LOC3)) goto LA4; LOC3 = ((*(*arg0).typ).kind == ((Ttypekind293244) 25)); LA4: ; if (!LOC3) goto LA5; gen_447825_1009139178(c0, arg0, dest0, 0); goto BeforeRet; } LA5: ; tmp0 = genx_447862_1009139178(c0, arg0, 0); { NI LOC11; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA9; LOC11 = (NI)0; LOC11 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC11)); } LA9: ; gabc_446714_1009139178(c0, n0, opc0, ((NI) ((*dest0))), tmp0, ((NI) 0)); LOC12 = (Ttype293840*)0; LOC12 = skiptypes_297099_850551059((*n0).typ, IL64(576460752303423488)); LOC13 = (NI)0; LOC13 = gentype_448502_1009139178(c0, LOC12); gabx_447116_1009139178(c0, n0, opc0, ((NI) 0), LOC13); LOC14 = (Ttype293840*)0; LOC14 = skiptypes_297099_850551059((*arg0).typ, IL64(576460752303423488)); LOC15 = (NI)0; LOC15 = gentype_448502_1009139178(c0, LOC14); gabx_447116_1009139178(c0, n0, opc0, ((NI) 0), LOC15); freetemp_447493_1009139178(c0, tmp0); }BeforeRet: ; } N_NIMCALL(void, genbinaryset_449369_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { NI tmp0; NI tmp20; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); tmp20 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], 0); { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; gensettype_449341_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], tmp0); gensettype_449341_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], tmp20); gabc_446714_1009139178(c0, n0, opc0, ((NI) ((*dest0))), tmp0, tmp20); freetemp_447493_1009139178(c0, tmp0); freetemp_447493_1009139178(c0, tmp20); } N_NIMCALL(NI, gettemprange_447509_1009139178)(Tctx344035* cc0, NI n0, Tslotkind344025 kind0) { NI result0; PprocHEX3Aobjecttype344220* c0; { result0 = (NI)0; c0 = (*cc0).prc; { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) 40) <= (*c0).maxslots); if (LOC3) goto LA4; LOC3 = (((NI) 255) <= (NI)((*c0).maxslots + n0)); LA4: ; if (!LOC3) goto LA5; { NI i_447527_1009139178; NI HEX3Atmp_447663_1009139178; NI res_447666_1009139178; i_447527_1009139178 = (NI)0; HEX3Atmp_447663_1009139178 = (NI)0; HEX3Atmp_447663_1009139178 = (NI)((*c0).maxslots - n0); res_447666_1009139178 = ((NI) 0); { while (1) { if (!(res_447666_1009139178 <= HEX3Atmp_447663_1009139178)) goto LA9; i_447527_1009139178 = res_447666_1009139178; { if (!!((*c0).slots[(i_447527_1009139178)- 0].Field0)) goto LA12; { { NI j_447538_1009139178; NI HEX3Atmp_447647_1009139178; NI HEX3Atmp_447648_1009139178; NI res_447651_1009139178; j_447538_1009139178 = (NI)0; HEX3Atmp_447647_1009139178 = (NI)0; HEX3Atmp_447648_1009139178 = (NI)0; HEX3Atmp_447647_1009139178 = (NI)(i_447527_1009139178 + ((NI) 1)); HEX3Atmp_447648_1009139178 = (NI)((NI)(i_447527_1009139178 + n0) - ((NI) 1)); res_447651_1009139178 = HEX3Atmp_447647_1009139178; { while (1) { if (!(res_447651_1009139178 <= HEX3Atmp_447648_1009139178)) goto LA17; j_447538_1009139178 = res_447651_1009139178; { if (!(*c0).slots[(j_447538_1009139178)- 0].Field0) goto LA20; goto LA14; } LA20: ; res_447651_1009139178 += ((NI) 1); } LA17: ; } } result0 = ((NI) (i_447527_1009139178)); { NI k_447615_1009139178; NI HEX3Atmp_447656_1009139178; NI res_447659_1009139178; k_447615_1009139178 = (NI)0; HEX3Atmp_447656_1009139178 = (NI)0; HEX3Atmp_447656_1009139178 = (NI)((NI)(((NI) (result0)) + n0) - ((NI) 1)); res_447659_1009139178 = ((NI) (result0)); { while (1) { if (!(res_447659_1009139178 <= HEX3Atmp_447656_1009139178)) goto LA24; k_447615_1009139178 = res_447659_1009139178; (*c0).slots[(k_447615_1009139178)- 0].Field0 = NIM_TRUE; (*c0).slots[(k_447615_1009139178)- 0].Field1 = kind0; res_447659_1009139178 += ((NI) 1); } LA24: ; } } goto BeforeRet; } LA14: ; } LA12: ; res_447666_1009139178 += ((NI) 1); } LA9: ; } } } LA5: ; { Tlineinfo192336 LOC29; if (!(((NI) 255) <= (NI)((*c0).maxslots + n0))) goto LA27; LOC29 = besteffort_447394_1009139178(cc0); globalerror_197076_155036129(LOC29, ((NimStringDesc*) &T1009139178_10)); } LA27: ; result0 = ((NI) ((*c0).maxslots)); (*c0).maxslots += n0; { NI k_447639_1009139178; NI HEX3Atmp_447673_1009139178; NI res_447676_1009139178; k_447639_1009139178 = (NI)0; HEX3Atmp_447673_1009139178 = (NI)0; HEX3Atmp_447673_1009139178 = (NI)((NI)(((NI) (result0)) + n0) - ((NI) 1)); res_447676_1009139178 = ((NI) (result0)); { while (1) { if (!(res_447676_1009139178 <= HEX3Atmp_447673_1009139178)) goto LA32; k_447639_1009139178 = res_447676_1009139178; (*c0).slots[(k_447639_1009139178)- 0].Field0 = NIM_TRUE; (*c0).slots[(k_447639_1009139178)- 0].Field1 = kind0; res_447676_1009139178 += ((NI) 1); } LA32: ; } } }BeforeRet: ; return result0; } N_NIMCALL(void, gen_447834_1009139178)(Tctx344035* c0, Tnode293802* n0, NI dest0, Tgenflag446202Set flags0) { NI d0; d0 = ((NI) (dest0)); gen_447825_1009139178(c0, n0, (&d0), flags0); { NimStringDesc* LOC5; if (!!((((NI) (d0)) == ((NI) (dest0))))) goto LA3; LOC5 = (NimStringDesc*)0; LOC5 = HEX24_197185_1689653243(T1009139178_25); internalerror_197113_155036129(LOC5); } LA3: ; } N_NIMCALL(void, freetemprange_447680_1009139178)(Tctx344035* c0, NI start0, NI n0) { { NI i_447694_1009139178; NI HEX3Atmp_447696_1009139178; NI res_447699_1009139178; i_447694_1009139178 = (NI)0; HEX3Atmp_447696_1009139178 = (NI)0; HEX3Atmp_447696_1009139178 = (NI)((NI)(((NI) (start0)) + n0) - ((NI) 1)); res_447699_1009139178 = ((NI) (start0)); { while (1) { if (!(res_447699_1009139178 <= HEX3Atmp_447696_1009139178)) goto LA3; i_447694_1009139178 = res_447699_1009139178; freetemp_447493_1009139178(c0, ((NI) (i_447694_1009139178))); res_447699_1009139178 += ((NI) 1); } LA3: ; } } } N_NIMCALL(void, genvarargsabc_449420_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { NI x0; NI LOC6; NI LOC11; NI LOC12; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; LOC6 = (NI)0; LOC6 = len_294081_850551059(n0); x0 = gettemprange_447509_1009139178(c0, (NI)(LOC6 - ((NI) 1)), ((Tslotkind344025) 6)); { NI i_449439_1009139178; NI HEX3Atmp_449446_1009139178; NI LOC8; NI res_449449_1009139178; i_449439_1009139178 = (NI)0; HEX3Atmp_449446_1009139178 = (NI)0; LOC8 = (NI)0; LOC8 = len_294081_850551059(n0); HEX3Atmp_449446_1009139178 = (NI)(LOC8 - ((NI) 1)); res_449449_1009139178 = ((NI) 1); { while (1) { NI r0; if (!(res_449449_1009139178 <= HEX3Atmp_449446_1009139178)) goto LA10; i_449439_1009139178 = res_449449_1009139178; r0 = ((NI) ((NI)((NI)(((NI) (x0)) + i_449439_1009139178) - ((NI) 1)))); gen_447834_1009139178(c0, (*n0).kindU.S6.sons->data[i_449439_1009139178], r0, 0); res_449449_1009139178 += ((NI) 1); } LA10: ; } } LOC11 = (NI)0; LOC11 = len_294081_850551059(n0); gabc_446714_1009139178(c0, n0, opc0, ((NI) ((*dest0))), x0, ((NI) ((NI)(LOC11 - ((NI) 1))))); LOC12 = (NI)0; LOC12 = len_294081_850551059(n0); freetemprange_447680_1009139178(c0, x0, LOC12); } N_NIMCALL(void, genbinarystmtvar_449391_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0) { Tnode293802* x0; NI dest0; NI tmp0; x0 = (*n0).kindU.S6.sons->data[((NI) 1)]; { if (!((*x0).kind == ((Tnodekind293020) 63) || (*x0).kind == ((Tnodekind293020) 64))) goto LA3; x0 = (*x0).kindU.S6.sons->data[((NI) 0)]; } LA3: ; dest0 = genx_447862_1009139178(c0, x0, 0); tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], 0); gabc_446714_1009139178(c0, n0, opc0, dest0, tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } N_NIMCALL(void, genbinaryabcd_449243_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0) { NI tmp0; NI tmp20; NI tmp30; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); tmp20 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], 0); tmp30 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 3)], 0); { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; gabc_446714_1009139178(c0, n0, opc0, ((NI) ((*dest0))), tmp0, tmp20); gabc_446714_1009139178(c0, n0, opc0, tmp30, ((NI) 0), ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); freetemp_447493_1009139178(c0, tmp20); freetemp_447493_1009139178(c0, tmp30); } N_NIMCALL(void, genbinarystmt_449382_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0) { NI dest0; NI tmp0; dest0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], 0); gabc_446714_1009139178(c0, n0, opc0, dest0, tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } N_NIMCALL(void, genunarystmt_449413_1009139178)(Tctx344035* c0, Tnode293802* n0, Topcode344015 opc0) { NI tmp0; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); gabc_446714_1009139178(c0, n0, opc0, tmp0, ((NI) 0), ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } static N_INLINE(NIM_BOOL, isemptytype_298440_850551059)(Ttype293840* t0) { NIM_BOOL result0; NIM_BOOL LOC1; result0 = (NIM_BOOL)0; LOC1 = (NIM_BOOL)0; LOC1 = (t0 == NIM_NIL); if (LOC1) goto LA2; LOC1 = ((*t0).kind == ((Ttypekind293244) 62) || (*t0).kind == ((Ttypekind293244) 7)); LA2: ; result0 = LOC1; return result0; } N_NIMCALL(void, gencall_448898_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI x0; NI LOC9; Ttype293840* fntyp0; NI LOC32; { NIM_BOOL LOC3; NIM_BOOL LOC5; NI LOC8; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) ((*dest0))) < ((NI) 0)); if (!(LOC3)) goto LA4; LOC5 = (NIM_BOOL)0; LOC5 = isemptytype_298440_850551059((*n0).typ); LOC3 = !(LOC5); LA4: ; if (!LOC3) goto LA6; LOC8 = (NI)0; LOC8 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC8)); } LA6: ; LOC9 = (NI)0; LOC9 = len_294081_850551059(n0); x0 = gettemprange_447509_1009139178(c0, LOC9, ((Tslotkind344025) 3)); fntyp0 = skiptypes_297099_850551059((*(*n0).kindU.S6.sons->data[((NI) 0)]).typ, IL64(211106232576256)); { NI i_448926_1009139178; NI HEX3Atmp_448952_1009139178; NI LOC11; NI res_448955_1009139178; i_448926_1009139178 = (NI)0; HEX3Atmp_448952_1009139178 = (NI)0; LOC11 = (NI)0; LOC11 = len_294081_850551059(n0); HEX3Atmp_448952_1009139178 = (LOC11 - 1); res_448955_1009139178 = ((NI) 0); { while (1) { NI r0; if (!(res_448955_1009139178 <= HEX3Atmp_448952_1009139178)) goto LA13; i_448926_1009139178 = res_448955_1009139178; r0 = ((NI) ((NI)(((NI) (x0)) + i_448926_1009139178))); gen_447834_1009139178(c0, (*n0).kindU.S6.sons->data[i_448926_1009139178], r0, 0); { NI LOC16; NI LOC24; LOC16 = (NI)0; LOC16 = len_296339_850551059(fntyp0); if (!(LOC16 <= i_448926_1009139178)) goto LA17; { NimStringDesc* LOC23; if (!!((((*fntyp0).flags &(1U<<((NU)(((Ttypeflag293431) 0))&31U)))!=0))) goto LA21; LOC23 = (NimStringDesc*)0; LOC23 = HEX24_197185_1689653243(T1009139178_31); internalerror_197113_155036129(LOC23); } LA21: ; LOC24 = (NI)0; LOC24 = gentype_448502_1009139178(c0, (*(*n0).kindU.S6.sons->data[i_448926_1009139178]).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 154), r0, LOC24); } LA17: ; res_448955_1009139178 += ((NI) 1); } LA13: ; } } { NI LOC29; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA27; LOC29 = (NI)0; LOC29 = len_294081_850551059(n0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 128), ((NI) 0), x0, ((NI) (LOC29))); } goto LA25; LA27: ; { NI LOC31; LOC31 = (NI)0; LOC31 = len_294081_850551059(n0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 129), ((NI) ((*dest0))), x0, ((NI) (LOC31))); } LA25: ; LOC32 = (NI)0; LOC32 = len_294081_850551059(n0); freetemprange_447680_1009139178(c0, x0, LOC32); } N_NIMCALL(void, genmagic_449556_1009139178)(Tctx344035* c0, Tnode293802* n_449559_1009139178, NI* dest0, Tmagic293524 m0) { switch (m0) { case ((Tmagic293524) 126): { genandor_448234_1009139178(c0, n_449559_1009139178, ((Topcode344015) 136), dest0); } break; case ((Tmagic293524) 127): { genandor_448234_1009139178(c0, n_449559_1009139178, ((Topcode344015) 135), dest0); } break; case ((Tmagic293524) 25): { NI tmp0; tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); { NI LOC8; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA6; LOC8 = (NI)0; LOC8 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC8)); } LA6: ; gabi_447026_1009139178(c0, n_449559_1009139178, ((Topcode344015) 24), ((NI) ((*dest0))), tmp0, IL64(1)); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tmagic293524) 51): case ((Tmagic293524) 46): { genaddsubint_449495_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 23)); } break; case ((Tmagic293524) 50): case ((Tmagic293524) 45): { genaddsubint_449495_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 21)); } break; case ((Tmagic293524) 26): case ((Tmagic293524) 27): { Topcode344015 opc0; NI d0; unused_448409_1009139178(n_449559_1009139178, (*dest0)); { if (!(m0 == ((Tmagic293524) 26))) goto LA14; opc0 = ((Topcode344015) 21); } goto LA12; LA14: ; { opc0 = ((Topcode344015) 23); } LA12: ; d0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); { NIM_BOOL LOC19; LOC19 = (NIM_BOOL)0; LOC19 = isint8lit_449453_1009139178((*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)]); if (!LOC19) goto LA20; gabi_447026_1009139178(c0, n_449559_1009139178, (Topcode344015)(opc0 + ((NI) 1)), d0, d0, (*(*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)]).kindU.S1.intval); } goto LA17; LA20: ; { NI tmp0; tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)], 0); gabc_446714_1009139178(c0, n_449559_1009139178, opc0, d0, d0, tmp0); freetemp_447493_1009139178(c0, tmp0); } LA17: ; gennarrow_449256_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], ((NI) (d0))); genasgnpatch_449090_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], d0); freetemp_447493_1009139178(c0, d0); } break; case ((Tmagic293524) 28): case ((Tmagic293524) 42): case ((Tmagic293524) 158): { gen_447825_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], dest0, 0); } break; case ((Tmagic293524) 29): case ((Tmagic293524) 30): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); gennew_449144_1009139178(c0, n_449559_1009139178); } break; case ((Tmagic293524) 31): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); gennewseq_449167_1009139178(c0, n_449559_1009139178); } break; case ((Tmagic293524) 32): { gennewseqofcap_449192_1009139178(c0, n_449559_1009139178, dest0); } break; case ((Tmagic293524) 161): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 134)); } break; case ((Tmagic293524) 162): { NI tmp0; tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); gabx_447116_1009139178(c0, n_449559_1009139178, ((Topcode344015) 152), tmp0, ((NI) 0)); { NI LOC33; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA31; LOC33 = (NI)0; LOC33 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC33)); } LA31: ; gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 134), ((NI) ((*dest0))), tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tmagic293524) 33): case ((Tmagic293524) 35): case ((Tmagic293524) 36): case ((Tmagic293524) 38): { genunaryabi_449223_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 25)); } break; case ((Tmagic293524) 34): case ((Tmagic293524) 37): { genunaryabi_449223_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 26)); } break; case ((Tmagic293524) 39): case ((Tmagic293524) 40): { NI d0; NI tmp0; Topcode344015 LOC37; unused_448409_1009139178(n_449559_1009139178, (*dest0)); d0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)], 0); gensettype_449341_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], d0); LOC37 = (Topcode344015)0; { if (!(m0 == ((Tmagic293524) 39))) goto LA40; LOC37 = ((Topcode344015) 27); } goto LA38; LA40: ; { LOC37 = ((Topcode344015) 29); } LA38: ; gabc_446714_1009139178(c0, n_449559_1009139178, LOC37, d0, tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, d0); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tmagic293524) 41): { gencard_449547_1009139178(c0, n_449559_1009139178, dest0); } break; case ((Tmagic293524) 47): { genbinaryabcnarrow_449327_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 31)); } break; case ((Tmagic293524) 48): { genbinaryabcnarrow_449327_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 32)); } break; case ((Tmagic293524) 49): { genbinaryabcnarrow_449327_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 33)); } break; case ((Tmagic293524) 52): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 34)); } break; case ((Tmagic293524) 53): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 35)); } break; case ((Tmagic293524) 54): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 36)); } break; case ((Tmagic293524) 55): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 37)); } break; case ((Tmagic293524) 56): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 38)); } break; case ((Tmagic293524) 57): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 39)); } break; case ((Tmagic293524) 58): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 40)); } break; case ((Tmagic293524) 59): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 41)); } break; case ((Tmagic293524) 60): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 42)); } break; case ((Tmagic293524) 65): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 43)); } break; case ((Tmagic293524) 66): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 44)); } break; case ((Tmagic293524) 67): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 45)); } break; case ((Tmagic293524) 68): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 46)); } break; case ((Tmagic293524) 69): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 47)); } break; case ((Tmagic293524) 70): case ((Tmagic293524) 86): case ((Tmagic293524) 80): case ((Tmagic293524) 83): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 48)); } break; case ((Tmagic293524) 71): case ((Tmagic293524) 81): case ((Tmagic293524) 84): case ((Tmagic293524) 87): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 49)); } break; case ((Tmagic293524) 72): case ((Tmagic293524) 82): case ((Tmagic293524) 85): case ((Tmagic293524) 88): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 50)); } break; case ((Tmagic293524) 73): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 51)); } break; case ((Tmagic293524) 74): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 52)); } break; case ((Tmagic293524) 75): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 53)); } break; case ((Tmagic293524) 91): case ((Tmagic293524) 76): case ((Tmagic293524) 78): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 54)); } break; case ((Tmagic293524) 92): case ((Tmagic293524) 77): case ((Tmagic293524) 79): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 55)); } break; case ((Tmagic293524) 95): case ((Tmagic293524) 89): case ((Tmagic293524) 90): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 56)); } break; case ((Tmagic293524) 93): { genbinaryabcnarrowu_449334_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 59)); } break; case ((Tmagic293524) 99): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 60)); } break; case ((Tmagic293524) 96): case ((Tmagic293524) 97): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 61)); gennarrow_449256_1009139178(c0, n_449559_1009139178, (*dest0)); } break; case ((Tmagic293524) 103): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 62)); } break; case ((Tmagic293524) 100): case ((Tmagic293524) 102): { gen_447825_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], dest0, 0); } break; case ((Tmagic293524) 101): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 63)); gennarrowu_449297_1009139178(c0, n_449559_1009139178, (*dest0)); } break; case ((Tmagic293524) 105): case ((Tmagic293524) 106): case ((Tmagic293524) 107): case ((Tmagic293524) 108): case ((Tmagic293524) 109): case ((Tmagic293524) 110): case ((Tmagic293524) 111): case ((Tmagic293524) 112): case ((Tmagic293524) 113): case ((Tmagic293524) 114): case ((Tmagic293524) 115): case ((Tmagic293524) 116): case ((Tmagic293524) 117): case ((Tmagic293524) 118): case ((Tmagic293524) 119): case ((Tmagic293524) 120): case ((Tmagic293524) 121): case ((Tmagic293524) 122): case ((Tmagic293524) 123): case ((Tmagic293524) 124): case ((Tmagic293524) 125): { genconv_449518_1009139178(c0, n_449559_1009139178, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], dest0, ((Topcode344015) 84)); } break; case ((Tmagic293524) 128): case ((Tmagic293524) 94): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 64)); } break; case ((Tmagic293524) 129): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 65)); } break; case ((Tmagic293524) 130): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 66)); } break; case ((Tmagic293524) 131): { genbinaryset_449369_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 67)); } break; case ((Tmagic293524) 132): { genbinaryset_449369_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 68)); } break; case ((Tmagic293524) 133): { genbinaryset_449369_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 69)); } break; case ((Tmagic293524) 134): { genbinaryset_449369_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 70)); } break; case ((Tmagic293524) 135): { genbinaryset_449369_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 71)); } break; case ((Tmagic293524) 136): { genbinaryset_449369_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 72)); } break; case ((Tmagic293524) 137): { genbinaryset_449369_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 73)); } break; case ((Tmagic293524) 138): { genvarargsabc_449420_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 74)); } break; case ((Tmagic293524) 148): { genbinaryset_449369_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 75)); } break; case ((Tmagic293524) 149): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 76)); } break; case ((Tmagic293524) 150): { NI tmp0; unused_448409_1009139178(n_449559_1009139178, (*dest0)); tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 86), tmp0, ((NI) 0), ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tmagic293524) 151): case ((Tmagic293524) 152): { NI d0; NI tmp0; Topcode344015 LOC92; unused_448409_1009139178(n_449559_1009139178, (*dest0)); d0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)], 0); LOC92 = (Topcode344015)0; { if (!(m0 == ((Tmagic293524) 151))) goto LA95; LOC92 = ((Topcode344015) 77); } goto LA93; LA95: ; { LOC92 = ((Topcode344015) 78); } LA93: ; gabc_446714_1009139178(c0, n_449559_1009139178, LOC92, d0, tmp0, ((NI) 0)); genasgnpatch_449090_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], d0); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tmagic293524) 156): { Tsym293834* LOC99; Tnode293802* LOC105; unused_448409_1009139178(n_449559_1009139178, (*dest0)); LOC99 = (Tsym293834*)0; { if (!((*c0).prc == NIM_NIL)) goto LA102; LOC99 = (*c0).module; } goto LA100; LA102: ; { LOC99 = (*(*c0).prc).sym; } LA100: ; LOC105 = (Tnode293802*)0; LOC105 = lowerswap_434300_2218250499(n_449559_1009139178, LOC99); gen_447852_1009139178(c0, LOC105, 0); } break; case ((Tmagic293524) 157): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 79)); } break; case ((Tmagic293524) 159): { NI tmp10; NI tmp20; NI tmp30; { NI LOC112; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA110; LOC112 = (NI)0; LOC112 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC112)); } LA110: ; tmp10 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); tmp20 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)], 0); tmp30 = gettemp_447412_1009139178(c0, (*(*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)]).typ); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 26), tmp30, tmp10, ((NI) 0)); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 82), ((NI) ((*dest0))), tmp10, tmp20); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 82), tmp30, ((NI) 0), ((NI) 0)); freetemp_447493_1009139178(c0, tmp10); freetemp_447493_1009139178(c0, tmp20); freetemp_447493_1009139178(c0, tmp30); } break; case ((Tmagic293524) 160): { NI tmp10; NI tmp20; NI tmp30; { NI LOC118; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA116; LOC118 = (NI)0; LOC118 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC118)); } LA116: ; tmp10 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); tmp20 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)], 0); tmp30 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 3)], 0); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 82), ((NI) ((*dest0))), tmp10, tmp20); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 82), tmp30, ((NI) 0), ((NI) 0)); freetemp_447493_1009139178(c0, tmp10); freetemp_447493_1009139178(c0, tmp20); freetemp_447493_1009139178(c0, tmp30); } break; case ((Tmagic293524) 163): { NI d20; Tnode293802* d2asnode0; NI tmp10; NI tmp30; { NI LOC124; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA122; LOC124 = (NI)0; LOC124 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC124)); } LA122: ; d20 = (NI)0; d2asnode0 = (*(*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)]).kindU.S6.sons->data[((NI) 0)]; { NIM_BOOL LOC127; Ttype293840* LOC130; LOC127 = (NIM_BOOL)0; LOC127 = needsasgnpatch_448997_1009139178(d2asnode0); if (!LOC127) goto LA128; LOC130 = (Ttype293840*)0; LOC130 = getsystype_339150_3937434831(((Ttypekind293244) 36)); d20 = gettemp_447412_1009139178(c0, LOC130); } goto LA125; LA128: ; { d20 = genx_447862_1009139178(c0, d2asnode0, 0); } LA125: ; tmp10 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); tmp30 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 3)], 0); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 83), ((NI) ((*dest0))), tmp10, d20); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 83), tmp30, ((NI) 0), ((NI) 0)); freetemp_447493_1009139178(c0, tmp10); freetemp_447493_1009139178(c0, tmp30); genasgnpatch_449090_1009139178(c0, d2asnode0, d20); freetemp_447493_1009139178(c0, d20); } break; case ((Tmagic293524) 164): { NI d0; unused_448409_1009139178(n_449559_1009139178, (*dest0)); d0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 87), d0, ((NI) 0), ((NI) 0)); } break; case ((Tmagic293524) 12): case ((Tmagic293524) 11): { NI tmp0; NI idx0; Ttype293840* LOC139; Ttype293840* typ0; NI LOC144; Topcode344015 LOC145; { NI LOC138; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA136; LOC138 = (NI)0; LOC138 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC138)); } LA136: ; tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); LOC139 = (Ttype293840*)0; LOC139 = getsystype_339150_3937434831(((Ttypekind293244) 31)); idx0 = gettemp_447412_1009139178(c0, LOC139); typ0 = (*(*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)]).typ; { if (!(m0 == ((Tmagic293524) 12))) goto LA142; typ0 = skiptypes_297099_850551059(typ0, IL64(211106247256064)); } LA142: ; LOC144 = (NI)0; LOC144 = gentype_448502_1009139178(c0, typ0); gabx_447116_1009139178(c0, n_449559_1009139178, ((Topcode344015) 152), idx0, LOC144); LOC145 = (Topcode344015)0; { if (!(m0 == ((Tmagic293524) 12))) goto LA148; LOC145 = ((Topcode344015) 80); } goto LA146; LA148: ; { LOC145 = ((Topcode344015) 81); } LA146: ; gabc_446714_1009139178(c0, n_449559_1009139178, LOC145, ((NI) ((*dest0))), tmp0, idx0); freetemp_447493_1009139178(c0, tmp0); freetemp_447493_1009139178(c0, idx0); } break; case ((Tmagic293524) 9): { NimStringDesc* LOC152; LOC152 = (NimStringDesc*)0; LOC152 = rendertree_312044_382274130(n_449559_1009139178, 0); globalerror_197071_155036129((*n_449559_1009139178).info, ((Tmsgkind192002) 213), LOC152); } break; case ((Tmagic293524) 8): { NI tmp0; Ttype293840* LOC159; { NI LOC158; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA156; LOC158 = (NI)0; LOC158 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC158)); } LA156: ; tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); LOC159 = (Ttype293840*)0; LOC159 = skiptypes_297099_850551059((*(*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)]).typ, IL64(211106240964608)); switch ((*LOC159).kind) { case ((Ttypekind293244) 28): case ((Ttypekind293244) 29): { gabi_447026_1009139178(c0, n_449559_1009139178, ((Topcode344015) 26), ((NI) ((*dest0))), tmp0, IL64(1)); } break; default: { gabi_447026_1009139178(c0, n_449559_1009139178, ((Topcode344015) 25), ((NI) ((*dest0))), tmp0, IL64(1)); } break; } freetemp_447493_1009139178(c0, tmp0); } break; case ((Tmagic293524) 17): { Tnode293802* n0; Tnode293802* LOC163; NI x0; NI LOC164; NI LOC174; NI LOC175; unused_448409_1009139178(n_449559_1009139178, (*dest0)); LOC163 = (Tnode293802*)0; LOC163 = HEX5BHEX5D_294238_850551059(n_449559_1009139178, ((NI) 1)); n0 = skipconv_329882_3876443242(LOC163); LOC164 = (NI)0; LOC164 = len_294081_850551059(n0); x0 = gettemprange_447509_1009139178(c0, LOC164, ((Tslotkind344025) 3)); { NimStringDesc* LOC169; if (!!(((*n0).kind == ((Tnodekind293020) 41)))) goto LA167; LOC169 = (NimStringDesc*)0; LOC169 = HEX24_197185_1689653243(T1009139178_26); internalerror_197113_155036129(LOC169); } LA167: ; { NI i_449754_1009139178; NI HEX3Atmp_449818_1009139178; NI LOC171; NI res_449821_1009139178; i_449754_1009139178 = (NI)0; HEX3Atmp_449818_1009139178 = (NI)0; LOC171 = (NI)0; LOC171 = len_294081_850551059(n0); HEX3Atmp_449818_1009139178 = (LOC171 - 1); res_449821_1009139178 = ((NI) 0); { while (1) { NI r0; if (!(res_449821_1009139178 <= HEX3Atmp_449818_1009139178)) goto LA173; i_449754_1009139178 = res_449821_1009139178; r0 = ((NI) ((NI)(((NI) (x0)) + i_449754_1009139178))); gen_447834_1009139178(c0, (*n0).kindU.S6.sons->data[i_449754_1009139178], r0, 0); res_449821_1009139178 += ((NI) 1); } LA173: ; } } LOC174 = (NI)0; LOC174 = len_294081_850551059(n0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 127), x0, ((NI) (LOC174)), ((NI) 0)); LOC175 = (NI)0; LOC175 = len_294081_850551059(n0); freetemprange_447680_1009139178(c0, x0, LOC175); } break; case ((Tmagic293524) 144): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmtvar_449391_1009139178(c0, n_449559_1009139178, ((Topcode344015) 90)); } break; case ((Tmagic293524) 145): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmtvar_449391_1009139178(c0, n_449559_1009139178, ((Topcode344015) 91)); } break; case ((Tmagic293524) 146): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmtvar_449391_1009139178(c0, n_449559_1009139178, ((Topcode344015) 92)); } break; case ((Tmagic293524) 21): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 116)); } break; case ((Tmagic293524) 22): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 117)); } break; case ((Tmagic293524) 10): { NI tmp0; NI LOC187; tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); { NI LOC186; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA184; LOC186 = (NI)0; LOC186 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC186)); } LA184: ; LOC187 = (NI)0; LOC187 = gentype_448502_1009139178(c0, (*(*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)]).typ); gabx_447116_1009139178(c0, n_449559_1009139178, ((Topcode344015) 154), tmp0, LOC187); gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 155), ((NI) ((*dest0))), tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tmagic293524) 19): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 114)); } break; case ((Tmagic293524) 20): { genbinaryabcd_449243_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 115)); } break; case ((Tmagic293524) 223): { genunaryabi_449223_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 25)); } break; case ((Tmagic293524) 254): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 126)); } break; case ((Tmagic293524) 224): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 131)); } break; case ((Tmagic293524) 225): case ((Tmagic293524) 228): { NI tmp10; NI tmp20; NI tmp30; Topcode344015 LOC194; unused_448409_1009139178(n_449559_1009139178, (*dest0)); tmp10 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); tmp20 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 2)], 0); tmp30 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 3)], 0); LOC194 = (Topcode344015)0; { if (!(m0 == ((Tmagic293524) 225))) goto LA197; LOC194 = ((Topcode344015) 132); } goto LA195; LA197: ; { LOC194 = ((Topcode344015) 112); } LA195: ; gabc_446714_1009139178(c0, n_449559_1009139178, LOC194, tmp10, tmp20, tmp30); freetemp_447493_1009139178(c0, tmp10); freetemp_447493_1009139178(c0, tmp20); freetemp_447493_1009139178(c0, tmp30); } break; case ((Tmagic293524) 226): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 94)); } break; case ((Tmagic293524) 227): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 95)); } break; case ((Tmagic293524) 229): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 96)); } break; case ((Tmagic293524) 230): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 97)); } break; case ((Tmagic293524) 231): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 98)); } break; case ((Tmagic293524) 232): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 99)); } break; case ((Tmagic293524) 233): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 100)); } break; case ((Tmagic293524) 234): { NI tmp0; NI rc0; Tnode293802* LOC213; tmp0 = genx_447862_1009139178(c0, (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)], 0); { NI LOC212; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA210; LOC212 = (NI)0; LOC212 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC212)); } LA210: ; LOC213 = (Tnode293802*)0; LOC213 = HEX5BHEX5D_294238_850551059(n_449559_1009139178, ((NI) 0)); if (eqStrings((*(*(*LOC213).kindU.S4.sym).name).s, ((NimStringDesc*) &T1009139178_27))) goto LA214; if (eqStrings((*(*(*LOC213).kindU.S4.sym).name).s, ((NimStringDesc*) &T1009139178_28))) goto LA215; if (eqStrings((*(*(*LOC213).kindU.S4.sym).name).s, ((NimStringDesc*) &T1009139178_29))) goto LA216; goto LA217; LA214: ; { rc0 = ((NI) 0); } goto LA218; LA215: ; { rc0 = ((NI) 1); } goto LA218; LA216: ; { rc0 = ((NI) 2); } goto LA218; LA217: ; { rc0 = ((NI) 3); } LA218: ; gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 101), ((NI) ((*dest0))), tmp0, ((NI) (rc0))); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tmagic293524) 235): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 102)); } break; case ((Tmagic293524) 236): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmt_449382_1009139178(c0, n_449559_1009139178, ((Topcode344015) 103)); } break; case ((Tmagic293524) 237): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmt_449382_1009139178(c0, n_449559_1009139178, ((Topcode344015) 104)); } break; case ((Tmagic293524) 238): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmt_449382_1009139178(c0, n_449559_1009139178, ((Topcode344015) 105)); } break; case ((Tmagic293524) 239): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmt_449382_1009139178(c0, n_449559_1009139178, ((Topcode344015) 106)); } break; case ((Tmagic293524) 240): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmt_449382_1009139178(c0, n_449559_1009139178, ((Topcode344015) 107)); } break; case ((Tmagic293524) 241): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genbinarystmt_449382_1009139178(c0, n_449559_1009139178, ((Topcode344015) 108)); } break; case ((Tmagic293524) 243): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 109)); } break; case ((Tmagic293524) 244): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 110)); } break; case ((Tmagic293524) 245): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 111)); } break; case ((Tmagic293524) 248): { { Tnode293802* LOC236; NI idx0; Tnode293802* LOC239; LOC236 = (Tnode293802*)0; LOC236 = HEX5BHEX5D_294238_850551059(n_449559_1009139178, ((NI) 1)); if (!((*LOC236).kind == ((Tnodekind293020) 56) || (*LOC236).kind == ((Tnodekind293020) 57) || (*LOC236).kind == ((Tnodekind293020) 3))) goto LA237; LOC239 = (Tnode293802*)0; LOC239 = HEX5BHEX5D_294238_850551059(n_449559_1009139178, ((NI) 1)); idx0 = genliteral_448377_1009139178(c0, LOC239); { NI LOC244; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA242; LOC244 = (NI)0; LOC244 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC244)); } LA242: ; gabx_447116_1009139178(c0, n_449559_1009139178, ((Topcode344015) 153), ((NI) ((*dest0))), idx0); } goto LA234; LA237: ; { localerror_197085_155036129((*n_449559_1009139178).info, ((NimStringDesc*) &T1009139178_30)); } LA234: ; } break; case ((Tmagic293524) 246): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 124)); } break; case ((Tmagic293524) 247): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 125)); } break; case ((Tmagic293524) 251): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 123)); } break; case ((Tmagic293524) 252): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 57)); } break; case ((Tmagic293524) 253): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 58)); } break; case ((Tmagic293524) 242): { genunaryabc_449214_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 122)); } break; case ((Tmagic293524) 255): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genunarystmt_449413_1009139178(c0, n_449559_1009139178, ((Topcode344015) 121)); } break; case ((Tmagic293524) 256): { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genunarystmt_449413_1009139178(c0, n_449559_1009139178, ((Topcode344015) 120)); } break; case ((Tmagic293524) 257): { { NI LOC257; LOC257 = (NI)0; LOC257 = len_294081_850551059(n_449559_1009139178); if (!(LOC257 <= ((NI) 1))) goto LA258; gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 118), ((NI) ((*dest0))), ((NI) 0), ((NI) 0)); } goto LA255; LA258: ; { unused_448409_1009139178(n_449559_1009139178, (*dest0)); genunarystmt_449413_1009139178(c0, n_449559_1009139178, ((Topcode344015) 119)); } LA255: ; } break; case ((Tmagic293524) 250): { { NI LOC266; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA264; LOC266 = (NI)0; LOC266 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC266)); } LA264: ; gabc_446714_1009139178(c0, n_449559_1009139178, ((Topcode344015) 133), ((NI) ((*dest0))), ((NI) 0), ((NI) 0)); } break; case ((Tmagic293524) 260): { genbinaryabc_449232_1009139178(c0, n_449559_1009139178, dest0, ((Topcode344015) 113)); } break; case ((Tmagic293524) 61): case ((Tmagic293524) 62): case ((Tmagic293524) 104): case ((Tmagic293524) 63): case ((Tmagic293524) 64): case ((Tmagic293524) 98): case ((Tmagic293524) 140): { gencall_448898_1009139178(c0, n_449559_1009139178, dest0); } break; case ((Tmagic293524) 23): { Tnode293802* arg0; { NI LOC272; LOC272 = (NI)0; LOC272 = len_294081_850551059(n_449559_1009139178); if (!!((LOC272 == ((NI) 2)))) goto LA273; globalerror_197071_155036129((*n_449559_1009139178).info, ((Tmsgkind192002) 4), ((NimStringDesc*) &T1009139178_32)); } LA273: ; arg0 = (*n_449559_1009139178).kindU.S6.sons->data[((NI) 1)]; { if (!((*arg0).kind == ((Tnodekind293020) 27) || (*arg0).kind == ((Tnodekind293020) 29) || (*arg0).kind == ((Tnodekind293020) 30) || (*arg0).kind == ((Tnodekind293020) 31) || (*arg0).kind == ((Tnodekind293020) 26) || (*arg0).kind == ((Tnodekind293020) 28) || (*arg0).kind == ((Tnodekind293020) 32))) goto LA277; { NI LOC283; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA281; LOC283 = (NI)0; LOC283 = gettemp_447412_1009139178(c0, (*n_449559_1009139178).typ); (*dest0) = ((NI) (LOC283)); } LA281: ; gencall_448898_1009139178(c0, arg0, dest0); } goto LA275; LA277: ; { globalerror_197076_155036129((*n_449559_1009139178).info, ((NimStringDesc*) &T1009139178_33)); } LA275: ; } break; default: { NimStringDesc* LOC286; LOC286 = (NimStringDesc*)0; LOC286 = rawNewString(reprEnum((NI)m0, (&NTI293524))->Sup.len + 26); appendString(LOC286, ((NimStringDesc*) &T1009139178_18)); appendString(LOC286, reprEnum((NI)m0, (&NTI293524))); globalerror_197076_155036129((*n_449559_1009139178).info, LOC286); } break; } } N_NIMCALL(NIM_BOOL, matches_452911_1009139178)(Tsym293834* s_452913_1009139178, NimStringDesc** y0, NI y0Len0) { NIM_BOOL result0; Tsym293834* s0; NI L0; { result0 = (NIM_BOOL)0; s0 = s_452913_1009139178; L0 = (NI)(y0Len0 - ((NI) 1)); { while (1) { if (!(((NI) 0) <= L0)) goto LA2; { NIM_BOOL LOC5; NIM_BOOL LOC7; NI LOC8; LOC5 = (NIM_BOOL)0; LOC5 = (s0 == NIM_NIL); if (LOC5) goto LA6; LOC7 = (NIM_BOOL)0; LOC8 = (NI)0; LOC8 = nsuCmpIgnoreStyle(y0[L0], (*(*s0).name).s); LOC7 = !((LOC8 == ((NI) 0))); if (!(LOC7)) goto LA9; LOC7 = !(eqStrings(y0[L0], ((NimStringDesc*) &T1009139178_15))); LA9: ; LOC5 = LOC7; LA6: ; if (!LOC5) goto LA10; result0 = NIM_FALSE; goto BeforeRet; } LA10: ; { if (!(((*s0).flags &(1U<<((NU)(((Tsymflag293184) 2))&31U)))!=0)) goto LA14; s0 = (*(*s0).owner).owner; } goto LA12; LA14: ; { s0 = (*s0).owner; } LA12: ; L0 -= ((NI) 1); } LA2: ; } result0 = NIM_TRUE; }BeforeRet: ; return result0; } N_NIMCALL(void, genmarshalload_449825_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI tmp0; NI LOC6; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 156), ((NI) ((*dest0))), tmp0, ((NI) 0)); LOC6 = (NI)0; LOC6 = gentype_448502_1009139178(c0, (*n0).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 156), ((NI) 0), LOC6); freetemp_447493_1009139178(c0, tmp0); } N_NIMCALL(void, genmarshalstore_449833_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI tmp0; NI LOC6; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 157), ((NI) ((*dest0))), tmp0, ((NI) 0)); LOC6 = (NI)0; LOC6 = gentype_448502_1009139178(c0, (*(*n0).kindU.S6.sons->data[((NI) 1)]).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 157), ((NI) 0), LOC6); freetemp_447493_1009139178(c0, tmp0); } static N_INLINE(void, cleardest_447880_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { { NIM_BOOL LOC3; NIM_BOOL LOC5; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) 0) <= ((NI) ((*dest0)))); if (!(LOC3)) goto LA4; LOC5 = (NIM_BOOL)0; LOC5 = (*n0).typ == 0; if (LOC5) goto LA6; LOC5 = ((*(*n0).typ).kind == ((Ttypekind293244) 62)); LA6: ; LOC3 = LOC5; LA4: ; if (!LOC3) goto LA7; freetemp_447493_1009139178(c0, ((NI) ((*dest0)))); (*dest0) = ((NI) -1); } LA7: ; } N_NIMCALL(NIM_BOOL, isint16lit_449474_1009139178)(Tnode293802* n0) { NIM_BOOL result0; result0 = (NIM_BOOL)0; { NIM_BOOL LOC5; if (!((*n0).kind >= ((Tnodekind293020) 5) && (*n0).kind <= ((Tnodekind293020) 15))) goto LA3; LOC5 = (NIM_BOOL)0; LOC5 = (IL64(-32768) <= (*n0).kindU.S1.intval); if (!(LOC5)) goto LA6; LOC5 = ((*n0).kindU.S1.intval <= IL64(32767)); LA6: ; result0 = LOC5; } LA3: ; return result0; } N_NIMCALL(void, genasgn_451002_1009139178)(Tctx344035* c0, Tnode293802* le0, Tnode293802* ri0, NIM_BOOL requirescopy0) { switch ((*le0).kind) { case ((Tnodekind293020) 42): { NI dest0; NI idx0; NI tmp0; dest0 = genx_447862_1009139178(c0, (*le0).kindU.S6.sons->data[((NI) 0)], 3); idx0 = genindex_449073_1009139178(c0, (*le0).kindU.S6.sons->data[((NI) 1)], (*(*le0).kindU.S6.sons->data[((NI) 0)]).typ); tmp0 = genx_447862_1009139178(c0, ri0, 0); { Ttype293840* LOC4; LOC4 = (Ttype293840*)0; LOC4 = skiptypes_297099_850551059((*(*le0).kindU.S6.sons->data[((NI) 0)]).typ, IL64(211106242013184)); if (!((*LOC4).kind == ((Ttypekind293244) 28) || (*LOC4).kind == ((Ttypekind293244) 29))) goto LA5; preventfalsealias_450795_1009139178(c0, le0, ((Topcode344015) 19), dest0, idx0, tmp0); } goto LA2; LA5: ; { preventfalsealias_450795_1009139178(c0, le0, ((Topcode344015) 12), dest0, idx0, tmp0); } LA2: ; freetemp_447493_1009139178(c0, tmp0); } break; case ((Tnodekind293020) 45): case ((Tnodekind293020) 46): { Tnode293802* left0; NI dest0; NI idx0; NI tmp0; { if (!((*le0).kind == ((Tnodekind293020) 45))) goto LA11; left0 = le0; } goto LA9; LA11: ; { left0 = (*le0).kindU.S6.sons->data[((NI) 0)]; } LA9: ; dest0 = genx_447862_1009139178(c0, (*left0).kindU.S6.sons->data[((NI) 0)], 3); idx0 = genfield_449043_1009139178((*left0).kindU.S6.sons->data[((NI) 1)]); tmp0 = genx_447862_1009139178(c0, ri0, 0); preventfalsealias_450795_1009139178(c0, left0, ((Topcode344015) 14), dest0, idx0, tmp0); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tnodekind293020) 47): case ((Tnodekind293020) 65): { NI dest0; NI tmp0; dest0 = genx_447862_1009139178(c0, (*le0).kindU.S6.sons->data[((NI) 0)], 1); tmp0 = genx_447862_1009139178(c0, ri0, 0); preventfalsealias_450795_1009139178(c0, le0, ((Topcode344015) 18), dest0, ((NI) 0), tmp0); freetemp_447493_1009139178(c0, tmp0); } break; case ((Tnodekind293020) 3): { Tsym293834* s0; s0 = (*le0).kindU.S4.sym; checkcaneval_450700_1009139178(c0, le0); { NIM_BOOL LOC18; NI tmp0; NI val0; LOC18 = (NIM_BOOL)0; LOC18 = (((*s0).flags &(1U<<((NU)(((Tsymflag293184) 3))&31U)))!=0); if (!(LOC18)) goto LA19; LOC18 = !(((*s0).kind == ((Tsymkind293435) 20))); LA19: ; if (!LOC18) goto LA20; tmp0 = gettemp_447412_1009139178(c0, (*le0).typ); gen_447834_1009139178(c0, le0, tmp0, 1); val0 = genx_447862_1009139178(c0, ri0, 0); preventfalsealias_450795_1009139178(c0, le0, ((Topcode344015) 18), tmp0, ((NI) 0), val0); freetemp_447493_1009139178(c0, val0); freetemp_447493_1009139178(c0, tmp0); } goto LA16; LA20: ; { NI dest0; { if (!((*s0).kind == ((Tsymkind293435) 20))) goto LA25; setslot_450609_1009139178(c0, s0); } LA25: ; { NIM_BOOL LOC29; NIM_BOOL LOC31; NimStringDesc* LOC35; LOC29 = (NIM_BOOL)0; LOC29 = (((NI) 0) < (*s0).position); if (LOC29) goto LA30; LOC31 = (NIM_BOOL)0; LOC31 = ((*s0).position == ((NI) 0)); if (!(LOC31)) goto LA32; LOC31 = ((2056 &(1U<<((NU)((*s0).kind)&31U)))!=0); LA32: ; LOC29 = LOC31; LA30: ; if (!!(LOC29)) goto LA33; LOC35 = (NimStringDesc*)0; LOC35 = HEX24_197185_1689653243(T1009139178_40); internalerror_197113_155036129(LOC35); } LA33: ; dest0 = ((NI) ((NI)((*s0).position + ((NI) (((*s0).kind == ((Tsymkind293435) 3))))))); { NIM_BOOL LOC38; NIM_BOOL LOC39; NIM_BOOL LOC40; NIM_BOOL LOC42; NI cc0; Topcode344015 LOC46; LOC38 = (NIM_BOOL)0; LOC39 = (NIM_BOOL)0; LOC40 = (NIM_BOOL)0; LOC40 = istemp_450774_1009139178(c0, ((NI) (dest0))); LOC39 = !(LOC40); if (!(LOC39)) goto LA41; LOC42 = (NIM_BOOL)0; LOC42 = fitsregister_449844_1009139178((*le0).typ); LOC39 = !(LOC42); LA41: ; LOC38 = LOC39; if (!(LOC38)) goto LA43; LOC38 = ((2312 &(1U<<((NU)((*s0).kind)&31U)))!=0); LA43: ; if (!LOC38) goto LA44; cc0 = gettemp_447412_1009139178(c0, (*le0).typ); gen_447834_1009139178(c0, ri0, cc0, 0); LOC46 = (Topcode344015)0; LOC46 = whichasgnopc_450420_1009139178(le0); gabc_446714_1009139178(c0, le0, LOC46, dest0, cc0, ((NI) 1)); freetemp_447493_1009139178(c0, cc0); } goto LA36; LA44: ; { gen_447834_1009139178(c0, ri0, dest0, 0); } LA36: ; } LA16: ; } break; default: { NI dest0; dest0 = genx_447862_1009139178(c0, le0, 1); genasgn_450442_1009139178(c0, ((NI) (dest0)), ri0, requirescopy0); } break; } } N_NIMCALL(void, genobjaccess_451743_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0) { NI a0; NI b0; a0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], flags0); b0 = genfield_449043_1009139178((*n0).kindU.S6.sons->data[((NI) 1)]); { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; { NIM_BOOL LOC8; Ttype293840* LOC10; NI cc0; LOC8 = (NIM_BOOL)0; LOC8 = !(((flags0 &(1U<<((NU)(((Tgenflag446202) 0))&7U)))!=0)); if (!(LOC8)) goto LA9; LOC10 = (Ttype293840*)0; LOC10 = skiptypes_297099_850551059((*n0).typ, 8388608); LOC8 = fitsregister_449844_1009139178(LOC10); LA9: ; if (!LOC8) goto LA11; cc0 = gettemp_447412_1009139178(c0, (*n0).typ); gabc_446714_1009139178(c0, n0, ((Topcode344015) 13), cc0, a0, b0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 10), ((NI) ((*dest0))), cc0, ((NI) 0)); freetemp_447493_1009139178(c0, cc0); } goto LA6; LA11: ; { gabc_446714_1009139178(c0, n0, ((Topcode344015) 13), ((NI) ((*dest0))), a0, b0); } LA6: ; freetemp_447493_1009139178(c0, a0); } N_NIMCALL(void, gencheckedobjaccess_451766_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0) { genobjaccess_451743_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], dest0, flags0); } N_NIMCALL(void, genarraccess2_451718_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0, Tgenflag446202Set flags0) { NI a0; NI b0; a0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], flags0); b0 = genindex_449073_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], (*(*n0).kindU.S6.sons->data[((NI) 0)]).typ); { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; { NIM_BOOL LOC8; Ttype293840* LOC10; NI cc0; LOC8 = (NIM_BOOL)0; LOC8 = !(((flags0 &(1U<<((NU)(((Tgenflag446202) 0))&7U)))!=0)); if (!(LOC8)) goto LA9; LOC10 = (Ttype293840*)0; LOC10 = skiptypes_297099_850551059((*n0).typ, 8388608); LOC8 = fitsregister_449844_1009139178(LOC10); LA9: ; if (!LOC8) goto LA11; cc0 = gettemp_447412_1009139178(c0, (*n0).typ); gabc_446714_1009139178(c0, n0, opc0, cc0, a0, b0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 10), ((NI) ((*dest0))), cc0, ((NI) 0)); freetemp_447493_1009139178(c0, cc0); } goto LA6; LA11: ; { gabc_446714_1009139178(c0, n0, opc0, ((NI) ((*dest0))), a0, b0); } LA6: ; freetemp_447493_1009139178(c0, a0); freetemp_447493_1009139178(c0, b0); } N_NIMCALL(void, genarraccess_451774_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0) { Ttypekind293244 arraytype0; Ttype293840* LOC1; LOC1 = (Ttype293840*)0; LOC1 = skiptypes_297099_850551059((*(*n0).kindU.S6.sons->data[((NI) 0)]).typ, IL64(211106242013184)); arraytype0 = (*LOC1).kind; { if (!(arraytype0 == ((Ttypekind293244) 28) || arraytype0 == ((Ttypekind293244) 29))) goto LA4; genarraccess2_451718_1009139178(c0, n0, dest0, ((Topcode344015) 20), 0); } goto LA2; LA4: ; { if (!(arraytype0 == ((Ttypekind293244) 8))) goto LA7; gentypelit_451216_1009139178(c0, (*n0).typ, dest0); } goto LA2; LA7: ; { genarraccess2_451718_1009139178(c0, n0, dest0, ((Topcode344015) 11), flags0); } LA2: ; } N_NIMCALL(Tnode293802*, canelimaddr_450051_1009139178)(Tnode293802* n0) { Tnode293802* result0; result0 = (Tnode293802*)0; switch ((*(*n0).kindU.S6.sons->data[((NI) 0)]).kind) { case ((Tnodekind293020) 67): case ((Tnodekind293020) 66): case ((Tnodekind293020) 70): case ((Tnodekind293020) 68): case ((Tnodekind293020) 69): { Tnode293802* m0; m0 = (*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S6.sons->data[((NI) 0)]; { if (!((*m0).kind == ((Tnodekind293020) 47) || (*m0).kind == ((Tnodekind293020) 65))) goto LA4; result0 = copynode_297528_850551059((*n0).kindU.S6.sons->data[((NI) 0)]); add_294136_850551059(result0, (*m0).kindU.S6.sons->data[((NI) 0)]); } LA4: ; } break; case ((Tnodekind293020) 58): case ((Tnodekind293020) 59): case ((Tnodekind293020) 60): { Tnode293802* m0; m0 = (*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S6.sons->data[((NI) 1)]; { if (!((*m0).kind == ((Tnodekind293020) 47) || (*m0).kind == ((Tnodekind293020) 65))) goto LA9; result0 = copynode_297528_850551059((*n0).kindU.S6.sons->data[((NI) 0)]); add_294136_850551059(result0, (*m0).kindU.S6.sons->data[((NI) 0)]); } LA9: ; } break; default: { { if (!((*(*n0).kindU.S6.sons->data[((NI) 0)]).kind == ((Tnodekind293020) 47) || (*(*n0).kindU.S6.sons->data[((NI) 0)]).kind == ((Tnodekind293020) 65))) goto LA14; result0 = (*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S6.sons->data[((NI) 0)]; } LA14: ; } break; } return result0; } N_NIMCALL(NIM_BOOL, unneededindirection_450025_1009139178)(Tnode293802* n0) { NIM_BOOL result0; Ttype293840* LOC1; result0 = (NIM_BOOL)0; LOC1 = (Ttype293840*)0; LOC1 = skiptypes_297099_850551059((*n0).typ, IL64(211106232576000)); result0 = ((*LOC1).kind == ((Ttypekind293244) 22)); return result0; } N_NIMCALL(NIM_BOOL, isglobal_448963_1009139178)(Tnode293802* n0) { NIM_BOOL result0; NIM_BOOL LOC1; NIM_BOOL LOC3; result0 = (NIM_BOOL)0; LOC1 = (NIM_BOOL)0; LOC1 = ((*n0).kind == ((Tnodekind293020) 3)); if (!(LOC1)) goto LA2; LOC3 = (NIM_BOOL)0; LOC3 = (((*(*n0).kindU.S4.sym).flags &(1U<<((NU)(((Tsymflag293184) 3))&31U)))!=0); if (!(LOC3)) goto LA4; LOC3 = !(((*(*n0).kindU.S4.sym).kind == ((Tsymkind293435) 20))); LA4: ; LOC1 = LOC3; LA2: ; result0 = LOC1; return result0; } N_NIMCALL(void, genaddrderef_450104_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Topcode344015 opc0, Tgenflag446202Set flags0) { NIM_BOOL isaddr0; Tgenflag446202Set af0; Tgenflag446202Set newflags0; { isaddr0 = (opc0 == ((Topcode344015) 16) || opc0 == ((Topcode344015) 15)); { NIM_BOOL LOC3; Tnode293802* m0; LOC3 = (NIM_BOOL)0; LOC3 = isaddr0; if (!(LOC3)) goto LA4; m0 = canelimaddr_450051_1009139178(n0); LOC3 = !((m0 == NIM_NIL)); LA4: ; if (!LOC3) goto LA5; gen_447825_1009139178(c0, m0, dest0, flags0); goto BeforeRet; } LA5: ; { Tnode293802* LOC9; LOC9 = (Tnode293802*)0; LOC9 = HEX5BHEX5D_294238_850551059(n0, ((NI) 0)); if (!((*LOC9).kind == ((Tnodekind293020) 42) || (*LOC9).kind == ((Tnodekind293020) 45) || (*LOC9).kind == ((Tnodekind293020) 46))) goto LA10; af0 = 3; } goto LA7; LA10: ; { af0 = 1; } LA7: ; { if (!isaddr0) goto LA15; newflags0 = (flags0 | af0); } goto LA13; LA15: ; { newflags0 = flags0; } LA13: ; { NIM_BOOL LOC20; LOC20 = (NIM_BOOL)0; LOC20 = !(isaddr0); if (!(LOC20)) goto LA21; LOC20 = unneededindirection_450025_1009139178((*n0).kindU.S6.sons->data[((NI) 0)]); LA21: ; if (!LOC20) goto LA22; gen_447825_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], dest0, newflags0); { NIM_BOOL LOC26; LOC26 = (NIM_BOOL)0; LOC26 = !(((flags0 &(1U<<((NU)(((Tgenflag446202) 0))&7U)))!=0)); if (!(LOC26)) goto LA27; LOC26 = fitsregister_449844_1009139178((*n0).typ); LA27: ; if (!LOC26) goto LA28; gabc_446714_1009139178(c0, n0, ((Topcode344015) 10), ((NI) ((*dest0))), ((NI) ((*dest0))), ((NI) 0)); } LA28: ; } goto LA18; LA22: ; { NIM_BOOL LOC31; LOC31 = (NIM_BOOL)0; LOC31 = isaddr0; if (!(LOC31)) goto LA32; LOC31 = isglobal_448963_1009139178((*n0).kindU.S6.sons->data[((NI) 0)]); LA32: ; if (!LOC31) goto LA33; gen_447825_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], dest0, (flags0 | af0)); } goto LA18; LA33: ; { NI tmp0; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], newflags0); { NI LOC40; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA38; LOC40 = (NI)0; LOC40 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC40)); } LA38: ; { if (!!(isaddr0)) goto LA43; gabc_446714_1009139178(c0, n0, opc0, ((NI) ((*dest0))), tmp0, ((NI) 0)); { NIM_BOOL LOC47; LOC47 = (NIM_BOOL)0; LOC47 = !(((flags0 &(1U<<((NU)(((Tgenflag446202) 0))&7U)))!=0)); if (!(LOC47)) goto LA48; LOC47 = fitsregister_449844_1009139178((*n0).typ); LA48: ; if (!LOC47) goto LA49; gabc_446714_1009139178(c0, n0, ((Topcode344015) 10), ((NI) ((*dest0))), ((NI) ((*dest0))), ((NI) 0)); } LA49: ; } goto LA41; LA43: ; { if (!(((Tslotkind344025) 3) <= (*(*c0).prc).slots[(tmp0)- 0].Field1)) goto LA52; gabc_446714_1009139178(c0, n0, ((Topcode344015) 16), ((NI) ((*dest0))), tmp0, ((NI) 0)); (*(*c0).prc).slots[(tmp0)- 0].Field1 = ((Tslotkind344025) 8); } goto LA41; LA52: ; { gabc_446714_1009139178(c0, n0, ((Topcode344015) 15), ((NI) ((*dest0))), tmp0, ((NI) 0)); } LA41: ; freetemp_447493_1009139178(c0, tmp0); } LA18: ; }BeforeRet: ; } N_NIMCALL(NIM_BOOL, isnotopr_447903_1009139178)(Tnode293802* n0) { NIM_BOOL result0; NIM_BOOL LOC1; NIM_BOOL LOC2; result0 = (NIM_BOOL)0; LOC1 = (NIM_BOOL)0; LOC2 = (NIM_BOOL)0; LOC2 = ((*n0).kind == ((Tnodekind293020) 27) || (*n0).kind == ((Tnodekind293020) 29) || (*n0).kind == ((Tnodekind293020) 30) || (*n0).kind == ((Tnodekind293020) 31) || (*n0).kind == ((Tnodekind293020) 26) || (*n0).kind == ((Tnodekind293020) 28) || (*n0).kind == ((Tnodekind293020) 32)); if (!(LOC2)) goto LA3; LOC2 = ((*(*n0).kindU.S6.sons->data[((NI) 0)]).kind == ((Tnodekind293020) 3)); LA3: ; LOC1 = LOC2; if (!(LOC1)) goto LA4; LOC1 = ((*(*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S4.sym).magic == ((Tmagic293524) 99)); LA4: ; result0 = LOC1; return result0; } N_NIMCALL(void, genif_448147_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { TY344201* endings0; { NIM_BOOL LOC3; NIM_BOOL LOC5; NI LOC8; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) ((*dest0))) < ((NI) 0)); if (!(LOC3)) goto LA4; LOC5 = (NIM_BOOL)0; LOC5 = isemptytype_298440_850551059((*n0).typ); LOC3 = !(LOC5); LA4: ; if (!LOC3) goto LA6; LOC8 = (NI)0; LOC8 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC8)); } LA6: ; endings0 = (TY344201*) newSeq((&NTI344201), 0); { NI i_448182_1009139178; NI HEX3Atmp_448221_1009139178; NI LOC10; NI res_448224_1009139178; i_448182_1009139178 = (NI)0; HEX3Atmp_448221_1009139178 = (NI)0; LOC10 = (NI)0; LOC10 = len_294081_850551059(n0); HEX3Atmp_448221_1009139178 = (NI)(LOC10 - ((NI) 1)); res_448224_1009139178 = ((NI) 0); { while (1) { Tnode293802* it0; if (!(res_448224_1009139178 <= HEX3Atmp_448221_1009139178)) goto LA12; i_448182_1009139178 = res_448224_1009139178; it0 = (*n0).kindU.S6.sons->data[i_448182_1009139178]; { NI LOC15; NI tmp0; NI elsepos0; LOC15 = (NI)0; LOC15 = len_294081_850551059(it0); if (!(LOC15 == ((NI) 2))) goto LA16; tmp0 = gettemp_447412_1009139178(c0, (*(*it0).kindU.S6.sons->data[((NI) 0)]).typ); elsepos0 = (NI)0; { NIM_BOOL LOC20; LOC20 = (NIM_BOOL)0; LOC20 = isnotopr_447903_1009139178((*it0).kindU.S6.sons->data[((NI) 0)]); if (!LOC20) goto LA21; gen_447834_1009139178(c0, (*(*it0).kindU.S6.sons->data[((NI) 0)]).kindU.S6.sons->data[((NI) 1)], tmp0, 0); elsepos0 = xjmp_447264_1009139178(c0, (*(*it0).kindU.S6.sons->data[((NI) 0)]).kindU.S6.sons->data[((NI) 1)], ((Topcode344015) 135), tmp0); } goto LA18; LA21: ; { gen_447834_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 0)], tmp0, 0); elsepos0 = xjmp_447264_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 0)], ((Topcode344015) 136), tmp0); } LA18: ; freetemp_447493_1009139178(c0, tmp0); cleardest_447880_1009139178(c0, n0, dest0); gen_447825_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 1)], dest0, 0); { NI LOC26; NI LOC29; LOC26 = (NI)0; LOC26 = sonslen_296351_850551059(n0); if (!(i_448182_1009139178 < (NI)(LOC26 - ((NI) 1)))) goto LA27; LOC29 = (NI)0; LOC29 = xjmp_447264_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 1)], ((Topcode344015) 137), ((NI) 0)); endings0 = (TY344201*) incrSeqV2(&(endings0)->Sup, sizeof(NI)); endings0->data[endings0->Sup.len] = LOC29; ++endings0->Sup.len; } LA27: ; patch_447318_1009139178(c0, elsepos0); } goto LA13; LA16: ; { cleardest_447880_1009139178(c0, n0, dest0); gen_447825_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 0)], dest0, 0); } LA13: ; res_448224_1009139178 += ((NI) 1); } LA12: ; } } { NI endpos_448217_1009139178; NI i_448231_1009139178; NI L_448233_1009139178; endpos_448217_1009139178 = (NI)0; i_448231_1009139178 = ((NI) 0); L_448233_1009139178 = (endings0 ? endings0->Sup.len : 0); { while (1) { if (!(i_448231_1009139178 < L_448233_1009139178)) goto LA33; endpos_448217_1009139178 = endings0->data[i_448231_1009139178]; patch_447318_1009139178(c0, endpos_448217_1009139178); i_448231_1009139178 += ((NI) 1); } LA33: ; } } cleardest_447880_1009139178(c0, n0, dest0); } N_NIMCALL(void, gencase_448413_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { TY344201* endings0; NI tmp0; { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = isemptytype_298440_850551059((*n0).typ); if (!!(LOC3)) goto LA4; { NI LOC10; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA8; LOC10 = (NI)0; LOC10 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC10)); } LA8: ; } goto LA1; LA4: ; { unused_448409_1009139178(n0, (*dest0)); } LA1: ; endings0 = (TY344201*) newSeq((&NTI344201), 0); tmp0 = gettemp_447412_1009139178(c0, (*(*n0).kindU.S6.sons->data[((NI) 0)]).typ); gen_447834_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], tmp0, 0); { NI i_448458_1009139178; NI HEX3Atmp_448489_1009139178; NI LOC13; NI res_448492_1009139178; i_448458_1009139178 = (NI)0; HEX3Atmp_448489_1009139178 = (NI)0; LOC13 = (NI)0; LOC13 = len_294081_850551059(n0); HEX3Atmp_448489_1009139178 = (LOC13 - 1); res_448492_1009139178 = ((NI) 1); { while (1) { Tnode293802* it0; if (!(res_448492_1009139178 <= HEX3Atmp_448489_1009139178)) goto LA15; i_448458_1009139178 = res_448492_1009139178; it0 = (*n0).kindU.S6.sons->data[i_448458_1009139178]; { NI LOC18; LOC18 = (NI)0; LOC18 = len_294081_850551059(it0); if (!(LOC18 == ((NI) 1))) goto LA19; gen_447825_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 0)], dest0, 0); } goto LA16; LA19: ; { NI b0; NI elsepos0; Tnode293802* LOC22; Tnode293802* LOC23; b0 = rawgenliteral_448248_1009139178(c0, it0); gabx_447116_1009139178(c0, it0, ((Topcode344015) 139), tmp0, b0); LOC22 = (Tnode293802*)0; LOC22 = lastson_296364_850551059(it0); elsepos0 = xjmp_447264_1009139178(c0, LOC22, ((Topcode344015) 136), tmp0); LOC23 = (Tnode293802*)0; LOC23 = lastson_296364_850551059(it0); gen_447825_1009139178(c0, LOC23, dest0, 0); { NI LOC26; Tnode293802* LOC29; NI LOC30; LOC26 = (NI)0; LOC26 = sonslen_296351_850551059(n0); if (!(i_448458_1009139178 < (NI)(LOC26 - ((NI) 1)))) goto LA27; LOC29 = (Tnode293802*)0; LOC29 = lastson_296364_850551059(it0); LOC30 = (NI)0; LOC30 = xjmp_447264_1009139178(c0, LOC29, ((Topcode344015) 137), ((NI) 0)); endings0 = (TY344201*) incrSeqV2(&(endings0)->Sup, sizeof(NI)); endings0->data[endings0->Sup.len] = LOC30; ++endings0->Sup.len; } LA27: ; patch_447318_1009139178(c0, elsepos0); } LA16: ; cleardest_447880_1009139178(c0, n0, dest0); res_448492_1009139178 += ((NI) 1); } LA15: ; } } freetemp_447493_1009139178(c0, tmp0); { NI endpos_448486_1009139178; NI i_448499_1009139178; NI L_448501_1009139178; endpos_448486_1009139178 = (NI)0; i_448499_1009139178 = ((NI) 0); L_448501_1009139178 = (endings0 ? endings0->Sup.len : 0); { while (1) { if (!(i_448499_1009139178 < L_448501_1009139178)) goto LA33; endpos_448486_1009139178 = endings0->data[i_448499_1009139178]; patch_447318_1009139178(c0, endpos_448486_1009139178); i_448499_1009139178 += ((NI) 1); } LA33: ; } } } N_NIMCALL(NI, genlabel_447280_1009139178)(Tctx344035* c0) { NI result0; result0 = (NI)0; result0 = ((*c0).code ? (*c0).code->Sup.len : 0); return result0; } N_NIMCALL(NIM_BOOL, istrue_447939_1009139178)(Tnode293802* n0) { NIM_BOOL result0; NIM_BOOL LOC1; NIM_BOOL LOC2; NIM_BOOL LOC3; NIM_BOOL LOC7; result0 = (NIM_BOOL)0; LOC1 = (NIM_BOOL)0; LOC2 = (NIM_BOOL)0; LOC3 = (NIM_BOOL)0; LOC3 = ((*n0).kind == ((Tnodekind293020) 3)); if (!(LOC3)) goto LA4; LOC3 = ((*(*n0).kindU.S4.sym).kind == ((Tsymkind293435) 19)); LA4: ; LOC2 = LOC3; if (!(LOC2)) goto LA5; LOC2 = !(((*(*n0).kindU.S4.sym).position == ((NI) 0))); LA5: ; LOC1 = LOC2; if (LOC1) goto LA6; LOC7 = (NIM_BOOL)0; LOC7 = ((*n0).kind == ((Tnodekind293020) 6)); if (!(LOC7)) goto LA8; LOC7 = !(((*n0).kindU.S1.intval == IL64(0))); LA8: ; LOC1 = LOC7; LA6: ; result0 = LOC1; return result0; } N_NIMCALL(void, jmpback_447293_1009139178)(Tctx344035* c0, Tnode293802* n0, NI p0) { NI dist0; dist0 = (NI)(p0 - ((*c0).code ? (*c0).code->Sup.len : 0)); { NIM_BOOL LOC3; NimStringDesc* LOC7; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) -32767) < dist0); if (!(LOC3)) goto LA4; LOC3 = (dist0 < ((NI) 32767)); LA4: ; if (!!(LOC3)) goto LA5; LOC7 = (NimStringDesc*)0; LOC7 = HEX24_197185_1689653243(T1009139178_43); internalerror_197113_155036129(LOC7); } LA5: ; gabx_447116_1009139178(c0, n0, ((Topcode344015) 138), ((NI) 0), dist0); } N_NIMCALL(void, popblock_447709_1009139178)(Tctx344035* c0, NI oldlen0) { { NI f_447802_1009139178; TY344201* HEX3Atmp_447814_1009139178; NI i_447817_1009139178; NI L_447819_1009139178; f_447802_1009139178 = (NI)0; HEX3Atmp_447814_1009139178 = (TY344201*)0; HEX3Atmp_447814_1009139178 = (*(*c0).prc).blocks->data[oldlen0].fixups; i_447817_1009139178 = ((NI) 0); L_447819_1009139178 = (HEX3Atmp_447814_1009139178 ? HEX3Atmp_447814_1009139178->Sup.len : 0); { while (1) { if (!(i_447817_1009139178 < L_447819_1009139178)) goto LA3; f_447802_1009139178 = HEX3Atmp_447814_1009139178->data[i_447817_1009139178]; patch_447318_1009139178(c0, f_447802_1009139178); i_447817_1009139178 += ((NI) 1); } LA3: ; } } (*(*c0).prc).blocks = (TY344221*) setLengthSeq(&((*(*c0).prc).blocks)->Sup, sizeof(Tblock344017), ((NI) (oldlen0))); } N_NIMCALL(void, genwhile_447974_1009139178)(Tctx344035* c0, Tnode293802* n0) { NI L10; NI oldlen0; L10 = genlabel_447280_1009139178(c0); oldlen0 = ((*(*c0).prc).blocks ? (*(*c0).prc).blocks->Sup.len : 0); (*(*c0).prc).blocks = (TY344221*) incrSeqV2(&((*(*c0).prc).blocks)->Sup, sizeof(Tblock344017)); asgnRefNoCycle((void**) (&(*(*c0).prc).blocks->data[(*(*c0).prc).blocks->Sup.len].label), T1009139178_41.label); genericSeqAssign((&(*(*c0).prc).blocks->data[(*(*c0).prc).blocks->Sup.len].fixups), T1009139178_41.fixups, (&NTI344201)); ++(*(*c0).prc).blocks->Sup.len; { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = istrue_447939_1009139178((*n0).kindU.S6.sons->data[((NI) 0)]); if (!LOC3) goto LA4; gen_447852_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); jmpback_447293_1009139178(c0, n0, L10); } goto LA1; LA4: ; { NIM_BOOL LOC7; NI tmp0; NI L20; LOC7 = (NIM_BOOL)0; LOC7 = isnotopr_447903_1009139178((*n0).kindU.S6.sons->data[((NI) 0)]); if (!LOC7) goto LA8; tmp0 = genx_447862_1009139178(c0, (*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S6.sons->data[((NI) 1)], 0); L20 = xjmp_447264_1009139178(c0, n0, ((Topcode344015) 135), tmp0); freetemp_447493_1009139178(c0, tmp0); gen_447852_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); jmpback_447293_1009139178(c0, n0, L10); patch_447318_1009139178(c0, L20); } goto LA1; LA8: ; { NI tmp0; NI L20; tmp0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], 0); L20 = xjmp_447264_1009139178(c0, n0, ((Topcode344015) 136), tmp0); freetemp_447493_1009139178(c0, tmp0); gen_447852_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); jmpback_447293_1009139178(c0, n0, L10); patch_447318_1009139178(c0, L20); } LA1: ; popblock_447709_1009139178(c0, oldlen0); } N_NIMCALL(void, genblock_448027_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI oldlen0; Tblock344017 LOC1; oldlen0 = ((*(*c0).prc).blocks ? (*(*c0).prc).blocks->Sup.len : 0); memset((void*)(&LOC1), 0, sizeof(LOC1)); memset((void*)(&LOC1), 0, sizeof(LOC1)); LOC1.label = (*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S4.sym; LOC1.fixups = (TY344201*) newSeq((&NTI344201), 0); (*(*c0).prc).blocks = (TY344221*) incrSeqV2(&((*(*c0).prc).blocks)->Sup, sizeof(Tblock344017)); asgnRefNoCycle((void**) (&(*(*c0).prc).blocks->data[(*(*c0).prc).blocks->Sup.len].label), LOC1.label); genericSeqAssign((&(*(*c0).prc).blocks->data[(*(*c0).prc).blocks->Sup.len].fixups), LOC1.fixups, (&NTI344201)); ++(*(*c0).prc).blocks->Sup.len; gen_447825_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], dest0, 0); popblock_447709_1009139178(c0, oldlen0); cleardest_447880_1009139178(c0, n0, dest0); } N_NIMCALL(void, genreturn_448876_1009139178)(Tctx344035* c0, Tnode293802* n0) { { if (!!(((*(*n0).kindU.S6.sons->data[((NI) 0)]).kind == ((Tnodekind293020) 1)))) goto LA3; gen_447852_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], 0); } LA3: ; gabc_446714_1009139178(c0, n0, ((Topcode344015) 1), ((NI) 0), ((NI) 0), ((NI) 0)); } N_NIMCALL(void, genraise_448870_1009139178)(Tctx344035* c0, Tnode293802* n0) { NI dest0; dest0 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], 0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 130), dest0, ((NI) 0), ((NI) 0)); freetemp_447493_1009139178(c0, dest0); } N_NIMCALL(void, genbreak_448072_1009139178)(Tctx344035* c0, Tnode293802* n0) { NI L10; { L10 = xjmp_447264_1009139178(c0, n0, ((Topcode344015) 137), ((NI) 0)); { if (!((*(*n0).kindU.S6.sons->data[((NI) 0)]).kind == ((Tnodekind293020) 3))) goto LA3; { NI i_448105_1009139178; NI HEX3Atmp_448140_1009139178; NI res_448143_1009139178; i_448105_1009139178 = (NI)0; HEX3Atmp_448140_1009139178 = (NI)0; HEX3Atmp_448140_1009139178 = (NI)(((*(*c0).prc).blocks ? (*(*c0).prc).blocks->Sup.len : 0) - ((NI) 1)); res_448143_1009139178 = HEX3Atmp_448140_1009139178; { while (1) { if (!(((NI) 0) <= res_448143_1009139178)) goto LA7; i_448105_1009139178 = res_448143_1009139178; { if (!((*(*c0).prc).blocks->data[i_448105_1009139178].label == (*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S4.sym)) goto LA10; (*(*c0).prc).blocks->data[i_448105_1009139178].fixups = (TY344201*) incrSeqV2(&((*(*c0).prc).blocks->data[i_448105_1009139178].fixups)->Sup, sizeof(NI)); (*(*c0).prc).blocks->data[i_448105_1009139178].fixups->data[(*(*c0).prc).blocks->data[i_448105_1009139178].fixups->Sup.len] = L10; ++(*(*c0).prc).blocks->data[i_448105_1009139178].fixups->Sup.len; goto BeforeRet; } LA10: ; res_448143_1009139178 -= ((NI) 1); } LA7: ; } } globalerror_197071_155036129((*n0).info, ((Tmsgkind192002) 4), ((NimStringDesc*) &T1009139178_44)); } goto LA1; LA3: ; { (*(*c0).prc).blocks->data[((*(*c0).prc).blocks ? ((*(*c0).prc).blocks->Sup.len-1) : -1)].fixups = (TY344201*) incrSeqV2(&((*(*c0).prc).blocks->data[((*(*c0).prc).blocks ? ((*(*c0).prc).blocks->Sup.len-1) : -1)].fixups)->Sup, sizeof(NI)); (*(*c0).prc).blocks->data[((*(*c0).prc).blocks ? ((*(*c0).prc).blocks->Sup.len-1) : -1)].fixups->data[(*(*c0).prc).blocks->data[((*(*c0).prc).blocks ? ((*(*c0).prc).blocks->Sup.len-1) : -1)].fixups->Sup.len] = L10; ++(*(*c0).prc).blocks->data[((*(*c0).prc).blocks ? ((*(*c0).prc).blocks->Sup.len-1) : -1)].fixups->Sup.len; } LA1: ; }BeforeRet: ; } N_NIMCALL(void, gentry_448573_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { TY344201* endings0; NI elsepos0; Tnode293802* fin0; { NIM_BOOL LOC3; NIM_BOOL LOC5; NI LOC8; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) ((*dest0))) < ((NI) 0)); if (!(LOC3)) goto LA4; LOC5 = (NIM_BOOL)0; LOC5 = isemptytype_298440_850551059((*n0).typ); LOC3 = !(LOC5); LA4: ; if (!LOC3) goto LA6; LOC8 = (NI)0; LOC8 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC8)); } LA6: ; endings0 = (TY344201*) newSeq((&NTI344201), 0); elsepos0 = xjmp_447264_1009139178(c0, n0, ((Topcode344015) 140), ((NI) 0)); gen_447825_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], dest0, 0); cleardest_447880_1009139178(c0, n0, dest0); patch_447318_1009139178(c0, elsepos0); { NI i_448617_1009139178; NI HEX3Atmp_448857_1009139178; NI LOC10; NI res_448860_1009139178; i_448617_1009139178 = (NI)0; HEX3Atmp_448857_1009139178 = (NI)0; LOC10 = (NI)0; LOC10 = len_294081_850551059(n0); HEX3Atmp_448857_1009139178 = (LOC10 - 1); res_448860_1009139178 = ((NI) 1); { while (1) { Tnode293802* it0; if (!(res_448860_1009139178 <= HEX3Atmp_448857_1009139178)) goto LA12; i_448617_1009139178 = res_448860_1009139178; it0 = (*n0).kindU.S6.sons->data[i_448617_1009139178]; { NI blen0; NI endexcept0; Tnode293802* LOC25; if (!!(((*it0).kind == ((Tnodekind293020) 107)))) goto LA15; blen0 = len_294081_850551059(it0); endexcept0 = xjmp_447264_1009139178(c0, it0, ((Topcode344015) 141), ((NI) 0)); { NI j_448642_1009139178; NI HEX3Atmp_448850_1009139178; NI res_448853_1009139178; j_448642_1009139178 = (NI)0; HEX3Atmp_448850_1009139178 = (NI)0; HEX3Atmp_448850_1009139178 = (NI)(blen0 - ((NI) 2)); res_448853_1009139178 = ((NI) 0); { while (1) { Ttype293840* typ0; NI LOC20; if (!(res_448853_1009139178 <= HEX3Atmp_448850_1009139178)) goto LA19; j_448642_1009139178 = res_448853_1009139178; typ0 = skiptypes_297099_850551059((*(*it0).kindU.S6.sons->data[j_448642_1009139178]).typ, IL64(211106247256064)); LOC20 = (NI)0; LOC20 = gentype_448502_1009139178(c0, typ0); gabx_447116_1009139178(c0, it0, ((Topcode344015) 141), ((NI) 0), LOC20); res_448853_1009139178 += ((NI) 1); } LA19: ; } } { if (!(blen0 == ((NI) 1))) goto LA23; gabx_447116_1009139178(c0, it0, ((Topcode344015) 141), ((NI) 0), ((NI) 0)); } LA23: ; LOC25 = (Tnode293802*)0; LOC25 = lastson_296364_850551059(it0); gen_447825_1009139178(c0, LOC25, dest0, 0); cleardest_447880_1009139178(c0, n0, dest0); { NI LOC28; NI LOC31; LOC28 = (NI)0; LOC28 = sonslen_296351_850551059(n0); if (!(i_448617_1009139178 < (NI)(LOC28 - ((NI) 1)))) goto LA29; LOC31 = (NI)0; LOC31 = xjmp_447264_1009139178(c0, it0, ((Topcode344015) 137), ((NI) 0)); endings0 = (TY344201*) incrSeqV2(&(endings0)->Sup, sizeof(NI)); endings0->data[endings0->Sup.len] = LOC31; ++endings0->Sup.len; } LA29: ; patch_447318_1009139178(c0, endexcept0); } LA15: ; res_448860_1009139178 += ((NI) 1); } LA12: ; } } { NI endpos_448835_1009139178; NI i_448867_1009139178; NI L_448869_1009139178; endpos_448835_1009139178 = (NI)0; i_448867_1009139178 = ((NI) 0); L_448869_1009139178 = (endings0 ? endings0->Sup.len : 0); { while (1) { if (!(i_448867_1009139178 < L_448869_1009139178)) goto LA34; endpos_448835_1009139178 = endings0->data[i_448867_1009139178]; patch_447318_1009139178(c0, endpos_448835_1009139178); i_448867_1009139178 += ((NI) 1); } LA34: ; } } fin0 = lastson_296364_850551059(n0); gabx_447116_1009139178(c0, fin0, ((Topcode344015) 142), ((NI) 0), ((NI) 0)); { if (!((*fin0).kind == ((Tnodekind293020) 107))) goto LA37; gen_447852_1009139178(c0, (*fin0).kindU.S6.sons->data[((NI) 0)], 0); cleardest_447880_1009139178(c0, n0, dest0); } LA37: ; gabx_447116_1009139178(c0, fin0, ((Topcode344015) 143), ((NI) 0), ((NI) 0)); } N_NIMCALL(Tsym293834*, getowner_450687_1009139178)(Tctx344035* c0) { Tsym293834* result0; result0 = (Tsym293834*)0; result0 = (*(*c0).prc).sym; { if (!result0 == 0) goto LA3; result0 = (*c0).module; } LA3: ; return result0; } N_NIMCALL(Topcode344015, ldnullopcode_451962_1009139178)(Ttype293840* t0) { Topcode344015 result0; result0 = (Topcode344015)0; { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = fitsregister_449844_1009139178(t0); if (!LOC3) goto LA4; result0 = ((Topcode344015) 147); } goto LA1; LA4: ; { result0 = ((Topcode344015) 146); } LA1: ; return result0; } N_NIMCALL(void, genvarsection_452001_1009139178)(Tctx344035* c0, Tnode293802* n0) { { Tnode293802* a_452005_1009139178; a_452005_1009139178 = (Tnode293802*)0; { NI i_452647_1009139178; NI HEX3Atmp_452649_1009139178; NI LOC3; NI res_452651_1009139178; i_452647_1009139178 = (NI)0; HEX3Atmp_452649_1009139178 = (NI)0; LOC3 = (NI)0; LOC3 = len_294081_850551059(n0); HEX3Atmp_452649_1009139178 = (LOC3 - 1); res_452651_1009139178 = ((NI) 0); { while (1) { if (!(res_452651_1009139178 <= HEX3Atmp_452649_1009139178)) goto LA5; i_452647_1009139178 = res_452651_1009139178; a_452005_1009139178 = (*n0).kindU.S6.sons->data[i_452647_1009139178]; { { if (!((*a_452005_1009139178).kind == ((Tnodekind293020) 125))) goto LA9; goto LA6; } LA9: ; { Tsym293834* LOC21; Tnode293802* LOC22; if (!((*a_452005_1009139178).kind == ((Tnodekind293020) 36))) goto LA13; { NI i_452034_1009139178; NI HEX3Atmp_452637_1009139178; NI LOC16; NI res_452640_1009139178; i_452034_1009139178 = (NI)0; HEX3Atmp_452637_1009139178 = (NI)0; LOC16 = (NI)0; LOC16 = len_294081_850551059(a_452005_1009139178); HEX3Atmp_452637_1009139178 = (NI)(LOC16 - ((NI) 3)); res_452640_1009139178 = ((NI) 0); { while (1) { Tnode293802* LOC19; Tnode293802* LOC20; if (!(res_452640_1009139178 <= HEX3Atmp_452637_1009139178)) goto LA18; i_452034_1009139178 = res_452640_1009139178; LOC19 = (Tnode293802*)0; LOC19 = HEX5BHEX5D_294238_850551059(a_452005_1009139178, i_452034_1009139178); setslot_450609_1009139178(c0, (*LOC19).kindU.S4.sym); LOC20 = (Tnode293802*)0; LOC20 = HEX5BHEX5D_294238_850551059(a_452005_1009139178, i_452034_1009139178); checkcaneval_450700_1009139178(c0, LOC20); res_452640_1009139178 += ((NI) 1); } LA18: ; } } LOC21 = (Tsym293834*)0; LOC21 = getowner_450687_1009139178(c0); LOC22 = (Tnode293802*)0; LOC22 = lowertupleunpacking_434037_2218250499(a_452005_1009139178, LOC21); gen_447852_1009139178(c0, LOC22, 0); } goto LA11; LA13: ; { Tsym293834* s0; if (!((*(*a_452005_1009139178).kindU.S6.sons->data[((NI) 0)]).kind == ((Tnodekind293020) 3))) goto LA24; s0 = (*(*a_452005_1009139178).kindU.S6.sons->data[((NI) 0)]).kindU.S4.sym; checkcaneval_450700_1009139178(c0, (*a_452005_1009139178).kindU.S6.sons->data[((NI) 0)]); { NIM_BOOL LOC28; LOC28 = (NIM_BOOL)0; LOC28 = (((*s0).flags &(1U<<((NU)(((Tsymflag293184) 3))&31U)))!=0); if (!(LOC28)) goto LA29; LOC28 = !(((*s0).kind == ((Tsymkind293435) 20))); LA29: ; if (!LOC28) goto LA30; { if (!((*s0).position == ((NI) 0))) goto LA34; { if (!(((*s0).flags &(1U<<((NU)(((Tsymflag293184) 5))&31U)))!=0)) goto LA38; importcsym_451223_1009139178(c0, (*a_452005_1009139178).info, s0); } goto LA36; LA38: ; { Tnode293802* sa0; sa0 = getnullvalue_451401_1009139178((*s0).typ, (*a_452005_1009139178).info); add_294136_850551059((*c0).globals, sa0); (*s0).position = len_294081_850551059((*c0).globals); } LA36: ; } LA34: ; { NI tmp0; NI val0; if (!!(((*(*a_452005_1009139178).kindU.S6.sons->data[((NI) 2)]).kind == ((Tnodekind293020) 1)))) goto LA43; tmp0 = genx_447862_1009139178(c0, (*a_452005_1009139178).kindU.S6.sons->data[((NI) 0)], 1); val0 = genx_447862_1009139178(c0, (*a_452005_1009139178).kindU.S6.sons->data[((NI) 2)], 0); preventfalsealias_450795_1009139178(c0, (*a_452005_1009139178).kindU.S6.sons->data[((NI) 2)], ((Topcode344015) 18), tmp0, ((NI) 0), val0); freetemp_447493_1009139178(c0, val0); freetemp_447493_1009139178(c0, tmp0); } LA43: ; } goto LA26; LA30: ; { setslot_450609_1009139178(c0, s0); { Topcode344015 LOC50; NI LOC51; if (!((*(*a_452005_1009139178).kindU.S6.sons->data[((NI) 2)]).kind == ((Tnodekind293020) 1))) goto LA48; LOC50 = (Topcode344015)0; LOC50 = ldnullopcode_451962_1009139178((*s0).typ); LOC51 = (NI)0; LOC51 = gentype_448502_1009139178(c0, (*s0).typ); gabx_447116_1009139178(c0, a_452005_1009139178, LOC50, ((NI) ((*s0).position)), LOC51); } goto LA46; LA48: ; { Tnode293802* le0; { NIM_BOOL LOC55; Topcode344015 LOC58; NI LOC59; LOC55 = (NIM_BOOL)0; LOC55 = fitsregister_449844_1009139178((*s0).typ); if (!!(LOC55)) goto LA56; LOC58 = (Topcode344015)0; LOC58 = ldnullopcode_451962_1009139178((*s0).typ); LOC59 = (NI)0; LOC59 = gentype_448502_1009139178(c0, (*s0).typ); gabx_447116_1009139178(c0, a_452005_1009139178, LOC58, ((NI) ((*s0).position)), LOC59); } LA56: ; le0 = (*a_452005_1009139178).kindU.S6.sons->data[((NI) 0)]; { NIM_BOOL LOC62; NIM_BOOL LOC63; NI cc0; Topcode344015 LOC67; LOC62 = (NIM_BOOL)0; LOC63 = (NIM_BOOL)0; LOC63 = fitsregister_449844_1009139178((*le0).typ); LOC62 = !(LOC63); if (!(LOC62)) goto LA64; LOC62 = ((2312 &(1U<<((NU)((*s0).kind)&31U)))!=0); LA64: ; if (!LOC62) goto LA65; cc0 = gettemp_447412_1009139178(c0, (*le0).typ); gen_447834_1009139178(c0, (*a_452005_1009139178).kindU.S6.sons->data[((NI) 2)], cc0, 0); LOC67 = (Topcode344015)0; LOC67 = whichasgnopc_450420_1009139178(le0); gabc_446714_1009139178(c0, le0, LOC67, ((NI) ((*s0).position)), cc0, ((NI) 1)); freetemp_447493_1009139178(c0, cc0); } goto LA60; LA65: ; { gen_447834_1009139178(c0, (*a_452005_1009139178).kindU.S6.sons->data[((NI) 2)], ((NI) ((*s0).position)), 0); } LA60: ; } LA46: ; } LA26: ; } goto LA11; LA24: ; { { NI tmp0; Tnode293802* LOC74; Topcode344015 LOC75; NI LOC76; if (!((*(*a_452005_1009139178).kindU.S6.sons->data[((NI) 2)]).kind == ((Tnodekind293020) 1))) goto LA72; tmp0 = genx_447862_1009139178(c0, (*a_452005_1009139178).kindU.S6.sons->data[((NI) 0)], 0); LOC74 = (Tnode293802*)0; LOC74 = HEX5BHEX5D_294238_850551059(a_452005_1009139178, ((NI) 0)); LOC75 = (Topcode344015)0; LOC75 = ldnullopcode_451962_1009139178((*LOC74).typ); LOC76 = (NI)0; LOC76 = gentype_448502_1009139178(c0, (*(*a_452005_1009139178).kindU.S6.sons->data[((NI) 0)]).typ); gabx_447116_1009139178(c0, a_452005_1009139178, LOC75, tmp0, LOC76); freetemp_447493_1009139178(c0, tmp0); } goto LA70; LA72: ; { genasgn_451002_1009139178(c0, (*a_452005_1009139178).kindU.S6.sons->data[((NI) 0)], (*a_452005_1009139178).kindU.S6.sons->data[((NI) 2)], NIM_TRUE); } LA70: ; } LA11: ; } LA6: ; res_452651_1009139178 += ((NI) 1); } LA5: ; } } } } N_NIMCALL(Topcode344015, whichasgnopc_450437_1009139178)(Tnode293802* n0, Topcode344015 opc0) { Topcode344015 result0; result0 = (Topcode344015)0; result0 = opc0; return result0; } N_NIMCALL(void, genarrayconstr_452654_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI LOC6; Ttype293840* inttype0; Ttype293840* seqtype0; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; LOC6 = (NI)0; LOC6 = gentype_448502_1009139178(c0, (*n0).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 146), ((NI) ((*dest0))), LOC6); inttype0 = getsystype_339150_3937434831(((Ttypekind293244) 31)); seqtype0 = skiptypes_297099_850551059((*n0).typ, IL64(211106240964608)); { NI tmp0; NI LOC11; NI LOC12; if (!((*seqtype0).kind == ((Ttypekind293244) 24))) goto LA9; tmp0 = gettemp_447412_1009139178(c0, inttype0); LOC11 = (NI)0; LOC11 = len_294081_850551059(n0); gabx_447116_1009139178(c0, n0, ((Topcode344015) 152), tmp0, LOC11); LOC12 = (NI)0; LOC12 = gentype_448502_1009139178(c0, seqtype0); gabx_447116_1009139178(c0, n0, ((Topcode344015) 145), ((NI) ((*dest0))), LOC12); gabx_447116_1009139178(c0, n0, ((Topcode344015) 145), tmp0, ((NI) 0)); freetemp_447493_1009139178(c0, tmp0); } LA9: ; { NI LOC15; NI tmp0; NI LOC18; LOC15 = (NI)0; LOC15 = len_294081_850551059(n0); if (!(((NI) 0) < LOC15)) goto LA16; tmp0 = gettemp_447412_1009139178(c0, inttype0); LOC18 = (NI)0; LOC18 = gentype_448502_1009139178(c0, inttype0); gabx_447116_1009139178(c0, n0, ((Topcode344015) 147), tmp0, LOC18); { Tnode293802* x_452688_1009139178; x_452688_1009139178 = (Tnode293802*)0; { NI i_452694_1009139178; NI HEX3Atmp_452696_1009139178; NI LOC21; NI res_452698_1009139178; i_452694_1009139178 = (NI)0; HEX3Atmp_452696_1009139178 = (NI)0; LOC21 = (NI)0; LOC21 = len_294081_850551059(n0); HEX3Atmp_452696_1009139178 = (LOC21 - 1); res_452698_1009139178 = ((NI) 0); { while (1) { NI a0; Topcode344015 LOC24; if (!(res_452698_1009139178 <= HEX3Atmp_452696_1009139178)) goto LA23; i_452694_1009139178 = res_452698_1009139178; x_452688_1009139178 = (*n0).kindU.S6.sons->data[i_452694_1009139178]; a0 = genx_447862_1009139178(c0, x_452688_1009139178, 0); LOC24 = (Topcode344015)0; LOC24 = whichasgnopc_450437_1009139178(x_452688_1009139178, ((Topcode344015) 12)); preventfalsealias_450795_1009139178(c0, n0, LOC24, ((NI) ((*dest0))), tmp0, a0); gabi_447026_1009139178(c0, n0, ((Topcode344015) 22), tmp0, tmp0, IL64(1)); freetemp_447493_1009139178(c0, a0); res_452698_1009139178 += ((NI) 1); } LA23: ; } } } freetemp_447493_1009139178(c0, tmp0); } LA16: ; } N_NIMCALL(void, gensetconstr_452701_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI LOC6; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; LOC6 = (NI)0; LOC6 = gentype_448502_1009139178(c0, (*n0).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 146), ((NI) ((*dest0))), LOC6); { Tnode293802* x_452707_1009139178; x_452707_1009139178 = (Tnode293802*)0; { NI i_452726_1009139178; NI HEX3Atmp_452728_1009139178; NI LOC9; NI res_452730_1009139178; i_452726_1009139178 = (NI)0; HEX3Atmp_452728_1009139178 = (NI)0; LOC9 = (NI)0; LOC9 = len_294081_850551059(n0); HEX3Atmp_452728_1009139178 = (LOC9 - 1); res_452730_1009139178 = ((NI) 0); { while (1) { if (!(res_452730_1009139178 <= HEX3Atmp_452728_1009139178)) goto LA11; i_452726_1009139178 = res_452730_1009139178; x_452707_1009139178 = (*n0).kindU.S6.sons->data[i_452726_1009139178]; { NI a0; NI b0; if (!((*x_452707_1009139178).kind == ((Tnodekind293020) 44))) goto LA14; a0 = genx_447862_1009139178(c0, (*x_452707_1009139178).kindU.S6.sons->data[((NI) 0)], 0); b0 = genx_447862_1009139178(c0, (*x_452707_1009139178).kindU.S6.sons->data[((NI) 1)], 0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 28), ((NI) ((*dest0))), a0, b0); freetemp_447493_1009139178(c0, b0); freetemp_447493_1009139178(c0, a0); } goto LA12; LA14: ; { NI a0; a0 = genx_447862_1009139178(c0, x_452707_1009139178, 0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 27), ((NI) ((*dest0))), a0, ((NI) 0)); freetemp_447493_1009139178(c0, a0); } LA12: ; res_452730_1009139178 += ((NI) 1); } LA11: ; } } } } N_NIMCALL(void, genobjconstr_452733_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { Ttype293840* t0; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; t0 = skiptypes_297099_850551059((*n0).typ, IL64(211106233624576)); { NI LOC10; if (!((*t0).kind == ((Ttypekind293244) 22))) goto LA8; LOC10 = (NI)0; LOC10 = gentype_448502_1009139178(c0, (*t0).sons->data[((NI) 0)]); gabx_447116_1009139178(c0, n0, ((Topcode344015) 144), ((NI) ((*dest0))), LOC10); } goto LA6; LA8: ; { NI LOC12; LOC12 = (NI)0; LOC12 = gentype_448502_1009139178(c0, (*n0).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 146), ((NI) ((*dest0))), LOC12); } LA6: ; { NI i_452780_1009139178; NI HEX3Atmp_452809_1009139178; NI LOC14; NI res_452812_1009139178; i_452780_1009139178 = (NI)0; HEX3Atmp_452809_1009139178 = (NI)0; LOC14 = (NI)0; LOC14 = len_294081_850551059(n0); HEX3Atmp_452809_1009139178 = (LOC14 - 1); res_452812_1009139178 = ((NI) 1); { while (1) { Tnode293802* it0; if (!(res_452812_1009139178 <= HEX3Atmp_452809_1009139178)) goto LA16; i_452780_1009139178 = res_452812_1009139178; it0 = (*n0).kindU.S6.sons->data[i_452780_1009139178]; { NIM_BOOL LOC19; NI idx0; NI tmp0; Topcode344015 LOC23; LOC19 = (NIM_BOOL)0; LOC19 = ((*it0).kind == ((Tnodekind293020) 34)); if (!(LOC19)) goto LA20; LOC19 = ((*(*it0).kindU.S6.sons->data[((NI) 0)]).kind == ((Tnodekind293020) 3)); LA20: ; if (!LOC19) goto LA21; idx0 = genfield_449043_1009139178((*it0).kindU.S6.sons->data[((NI) 0)]); tmp0 = genx_447862_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 1)], 0); LOC23 = (Topcode344015)0; LOC23 = whichasgnopc_450437_1009139178((*it0).kindU.S6.sons->data[((NI) 1)], ((Topcode344015) 14)); preventfalsealias_450795_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 1)], LOC23, ((NI) ((*dest0))), idx0, tmp0); freetemp_447493_1009139178(c0, tmp0); } goto LA17; LA21: ; { globalerror_197076_155036129((*n0).info, ((NimStringDesc*) &T1009139178_45)); } LA17: ; res_452812_1009139178 += ((NI) 1); } LA16: ; } } } N_NIMCALL(void, gentupleconstr_452816_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0) { NI LOC6; { NI LOC5; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA3; LOC5 = (NI)0; LOC5 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC5)); } LA3: ; LOC6 = (NI)0; LOC6 = gentype_448502_1009139178(c0, (*n0).typ); gabx_447116_1009139178(c0, n0, ((Topcode344015) 146), ((NI) ((*dest0))), LOC6); { NI i_452840_1009139178; NI HEX3Atmp_452860_1009139178; NI LOC8; NI res_452863_1009139178; i_452840_1009139178 = (NI)0; HEX3Atmp_452860_1009139178 = (NI)0; LOC8 = (NI)0; LOC8 = len_294081_850551059(n0); HEX3Atmp_452860_1009139178 = (LOC8 - 1); res_452863_1009139178 = ((NI) 0); { while (1) { Tnode293802* it0; if (!(res_452863_1009139178 <= HEX3Atmp_452860_1009139178)) goto LA10; i_452840_1009139178 = res_452863_1009139178; it0 = (*n0).kindU.S6.sons->data[i_452840_1009139178]; { NI idx0; NI tmp0; Topcode344015 LOC15; if (!((*it0).kind == ((Tnodekind293020) 34))) goto LA13; idx0 = genfield_449043_1009139178((*it0).kindU.S6.sons->data[((NI) 0)]); tmp0 = genx_447862_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 1)], 0); LOC15 = (Topcode344015)0; LOC15 = whichasgnopc_450437_1009139178((*it0).kindU.S6.sons->data[((NI) 1)], ((Topcode344015) 14)); preventfalsealias_450795_1009139178(c0, (*it0).kindU.S6.sons->data[((NI) 1)], LOC15, ((NI) ((*dest0))), idx0, tmp0); freetemp_447493_1009139178(c0, tmp0); } goto LA11; LA13: ; { NI tmp0; Topcode344015 LOC17; tmp0 = genx_447862_1009139178(c0, it0, 0); LOC17 = (Topcode344015)0; LOC17 = whichasgnopc_450437_1009139178(it0, ((Topcode344015) 14)); preventfalsealias_450795_1009139178(c0, it0, LOC17, ((NI) ((*dest0))), ((NI) (i_452840_1009139178)), tmp0); freetemp_447493_1009139178(c0, tmp0); } LA11: ; res_452863_1009139178 += ((NI) 1); } LA10: ; } } } N_NIMCALL(void, gen_447825_1009139178)(Tctx344035* c0, Tnode293802* n0, NI* dest0, Tgenflag446202Set flags0) { switch ((*n0).kind) { case ((Tnodekind293020) 3): { Tsym293834* s0; s0 = (*n0).kindU.S4.sym; checkcaneval_450700_1009139178(c0, n0); switch ((*s0).kind) { case ((Tsymkind293435) 8): case ((Tsymkind293435) 20): case ((Tsymkind293435) 5): case ((Tsymkind293435) 9): case ((Tsymkind293435) 3): case ((Tsymkind293435) 11): { genrdvar_451432_1009139178(c0, n0, dest0, flags0); } break; case ((Tsymkind293435) 12): case ((Tsymkind293435) 15): case ((Tsymkind293435) 16): case ((Tsymkind293435) 17): case ((Tsymkind293435) 13): case ((Tsymkind293435) 14): { { NIM_BOOL LOC6; LOC6 = (NIM_BOOL)0; LOC6 = prociscallback_452963_1009139178(c0, s0); if (!LOC6) goto LA7; } goto LA4; LA7: ; { if (!(((*s0).flags &(1U<<((NU)(((Tsymflag293184) 5))&31U)))!=0)) goto LA10; importcsym_451223_1009139178(c0, (*n0).info, s0); } goto LA4; LA10: ; LA4: ; genlit_448891_1009139178(c0, n0, dest0); } break; case ((Tsymkind293435) 10): { gen_447825_1009139178(c0, (*s0).ast, dest0, 0); } break; case ((Tsymkind293435) 19): { { NI LOC18; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA16; LOC18 = (NI)0; LOC18 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC18)); } LA16: ; { NIM_BOOL LOC21; LOC21 = (NIM_BOOL)0; LOC21 = (((NI) -32768) <= (*s0).position); if (!(LOC21)) goto LA22; LOC21 = ((*s0).position <= ((NI) 32767)); LA22: ; if (!LOC21) goto LA23; gabx_447116_1009139178(c0, n0, ((Topcode344015) 152), ((NI) ((*dest0))), (*s0).position); } goto LA19; LA23: ; { NI lit0; Tnode293802* LOC26; LOC26 = (Tnode293802*)0; LOC26 = newintnode_294660_850551059(((Tnodekind293020) 6), ((NI64) ((*s0).position))); lit0 = genliteral_448377_1009139178(c0, LOC26); gabx_447116_1009139178(c0, n0, ((Topcode344015) 148), ((NI) ((*dest0))), lit0); } LA19: ; } break; case ((Tsymkind293435) 7): { gentypelit_451216_1009139178(c0, (*s0).typ, dest0); } break; case ((Tsymkind293435) 4): { { NIM_BOOL LOC31; LOC31 = (NIM_BOOL)0; LOC31 = !(((*(*c0).prc).sym == NIM_NIL)); if (!(LOC31)) goto LA32; LOC31 = ((*(*(*c0).prc).sym).kind == ((Tsymkind293435) 16)); LA32: ; if (!LOC31) goto LA33; genrdvar_451432_1009139178(c0, n0, dest0, flags0); } goto LA29; LA33: ; { NimStringDesc* LOC36; LOC36 = (NimStringDesc*)0; LOC36 = rawNewString((*(*s0).name).s->Sup.len + 26); appendString(LOC36, ((NimStringDesc*) &T1009139178_18)); appendString(LOC36, (*(*s0).name).s); globalerror_197071_155036129((*n0).info, ((Tmsgkind192002) 4), LOC36); } LA29: ; } break; default: { NimStringDesc* LOC38; LOC38 = (NimStringDesc*)0; LOC38 = rawNewString((*(*s0).name).s->Sup.len + 26); appendString(LOC38, ((NimStringDesc*) &T1009139178_18)); appendString(LOC38, (*(*s0).name).s); globalerror_197071_155036129((*n0).info, ((Tmsgkind192002) 4), LOC38); } break; } } break; case ((Tnodekind293020) 27): case ((Tnodekind293020) 29): case ((Tnodekind293020) 30): case ((Tnodekind293020) 31): case ((Tnodekind293020) 26): case ((Tnodekind293020) 28): case ((Tnodekind293020) 32): { { Tsym293834* s0; if (!((*(*n0).kindU.S6.sons->data[((NI) 0)]).kind == ((Tnodekind293020) 3))) goto LA42; s0 = (*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S4.sym; { if (!!(((*s0).magic == ((Tmagic293524) 0)))) goto LA46; genmagic_449556_1009139178(c0, n0, dest0, (*s0).magic); } goto LA44; LA46: ; { NIM_BOOL LOC49; LOC49 = (NIM_BOOL)0; LOC49 = matches_452911_1009139178(s0, T1009139178_34, 3); if (!LOC49) goto LA50; genmarshalload_449825_1009139178(c0, n0, dest0); } goto LA44; LA50: ; { NIM_BOOL LOC53; LOC53 = (NIM_BOOL)0; LOC53 = matches_452911_1009139178(s0, T1009139178_38, 3); if (!LOC53) goto LA54; genmarshalstore_449833_1009139178(c0, n0, dest0); } goto LA44; LA54: ; { gencall_448898_1009139178(c0, n0, dest0); cleardest_447880_1009139178(c0, n0, dest0); } LA44: ; } goto LA40; LA42: ; { gencall_448898_1009139178(c0, n0, dest0); cleardest_447880_1009139178(c0, n0, dest0); } LA40: ; } break; case ((Tnodekind293020) 5) ... ((Tnodekind293020) 10): { { NIM_BOOL LOC61; LOC61 = (NIM_BOOL)0; LOC61 = isint16lit_449474_1009139178(n0); if (!LOC61) goto LA62; { NI LOC68; if (!(((NI) ((*dest0))) < ((NI) 0))) goto LA66; LOC68 = (NI)0; LOC68 = gettemp_447412_1009139178(c0, (*n0).typ); (*dest0) = ((NI) (LOC68)); } LA66: ; gabx_447116_1009139178(c0, n0, ((Topcode344015) 152), ((NI) ((*dest0))), ((NI) ((*n0).kindU.S1.intval))); } goto LA59; LA62: ; { genlit_448891_1009139178(c0, n0, dest0); } LA59: ; } break; case ((Tnodekind293020) 11) ... ((Tnodekind293020) 22): { genlit_448891_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 23): { { NIM_BOOL LOC74; Tnode293802* LOC77; LOC74 = (NIM_BOOL)0; LOC74 = isemptytype_298440_850551059((*n0).typ); if (!!(LOC74)) goto LA75; LOC77 = (Tnode293802*)0; LOC77 = getnullvalue_451401_1009139178((*n0).typ, (*n0).info); genlit_448891_1009139178(c0, LOC77, dest0); } goto LA72; LA75: ; { unused_448409_1009139178(n0, (*dest0)); } LA72: ; } break; case ((Tnodekind293020) 73): case ((Tnodekind293020) 74): { unused_448409_1009139178(n0, (*dest0)); genasgn_451002_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], (*n0).kindU.S6.sons->data[((NI) 1)], ((*n0).kind == ((Tnodekind293020) 73))); } break; case ((Tnodekind293020) 45): { genobjaccess_451743_1009139178(c0, n0, dest0, flags0); } break; case ((Tnodekind293020) 46): { gencheckedobjaccess_451766_1009139178(c0, n0, dest0, flags0); } break; case ((Tnodekind293020) 42): { genarraccess_451774_1009139178(c0, n0, dest0, flags0); } break; case ((Tnodekind293020) 47): case ((Tnodekind293020) 65): { genaddrderef_450104_1009139178(c0, n0, dest0, ((Topcode344015) 17), flags0); } break; case ((Tnodekind293020) 63): case ((Tnodekind293020) 64): { genaddrderef_450104_1009139178(c0, n0, dest0, ((Topcode344015) 16), flags0); } break; case ((Tnodekind293020) 92): case ((Tnodekind293020) 48): { genif_448147_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 93): { gen_447825_1009139178(c0, (*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S6.sons->data[((NI) 1)], dest0, 0); } break; case ((Tnodekind293020) 97): { gencase_448413_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 96): { unused_448409_1009139178(n0, (*dest0)); genwhile_447974_1009139178(c0, n0); } break; case ((Tnodekind293020) 127): case ((Tnodekind293020) 112): { genblock_448027_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 109): { unused_448409_1009139178(n0, (*dest0)); genreturn_448876_1009139178(c0, n0); } break; case ((Tnodekind293020) 108): { unused_448409_1009139178(n0, (*dest0)); genraise_448870_1009139178(c0, n0); } break; case ((Tnodekind293020) 110): { unused_448409_1009139178(n0, (*dest0)); genbreak_448072_1009139178(c0, n0); } break; case ((Tnodekind293020) 106): { gentry_448573_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 115): { { Tnode293802* x_453331_1009139178; x_453331_1009139178 = (Tnode293802*)0; { NI i_453384_1009139178; NI HEX3Atmp_453386_1009139178; NI LOC97; NI res_453388_1009139178; i_453384_1009139178 = (NI)0; HEX3Atmp_453386_1009139178 = (NI)0; LOC97 = (NI)0; LOC97 = len_294081_850551059(n0); HEX3Atmp_453386_1009139178 = (LOC97 - 1); res_453388_1009139178 = ((NI) 0); { while (1) { if (!(res_453388_1009139178 <= HEX3Atmp_453386_1009139178)) goto LA99; i_453384_1009139178 = res_453388_1009139178; x_453331_1009139178 = (*n0).kindU.S6.sons->data[i_453384_1009139178]; gen_447852_1009139178(c0, x_453331_1009139178, 0); res_453388_1009139178 += ((NI) 1); } LA99: ; } } } } break; case ((Tnodekind293020) 126): { NI L0; NI LOC101; LOC101 = (NI)0; LOC101 = len_294081_850551059(n0); L0 = (NI)(LOC101 - ((NI) 1)); { NI i_453351_1009139178; NI HEX3Atmp_453392_1009139178; NI res_453395_1009139178; i_453351_1009139178 = (NI)0; HEX3Atmp_453392_1009139178 = (NI)0; HEX3Atmp_453392_1009139178 = (L0 - 1); res_453395_1009139178 = ((NI) 0); { while (1) { if (!(res_453395_1009139178 <= HEX3Atmp_453392_1009139178)) goto LA104; i_453351_1009139178 = res_453395_1009139178; gen_447852_1009139178(c0, (*n0).kindU.S6.sons->data[i_453351_1009139178], 0); res_453395_1009139178 += ((NI) 1); } LA104: ; } } gen_447825_1009139178(c0, (*n0).kindU.S6.sons->data[L0], dest0, flags0); } break; case ((Tnodekind293020) 91): { Tnode293802* LOC106; LOC106 = (Tnode293802*)0; LOC106 = lastson_296364_850551059(n0); gen_447825_1009139178(c0, LOC106, dest0, flags0); } break; case ((Tnodekind293020) 114): { unused_448409_1009139178(n0, (*dest0)); gen_447852_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], 0); } break; case ((Tnodekind293020) 58): case ((Tnodekind293020) 59): case ((Tnodekind293020) 60): { genconv_449518_1009139178(c0, n0, (*n0).kindU.S6.sons->data[((NI) 1)], dest0, ((Topcode344015) 84)); } break; case ((Tnodekind293020) 66): { genconv_449518_1009139178(c0, n0, (*n0).kindU.S6.sons->data[((NI) 0)], dest0, ((Topcode344015) 84)); } break; case ((Tnodekind293020) 99): case ((Tnodekind293020) 100): { unused_448409_1009139178(n0, (*dest0)); genvarsection_452001_1009139178(c0, n0); } break; case ((Tnodekind293020) 79): case ((Tnodekind293020) 80): case ((Tnodekind293020) 84): case ((Tnodekind293020) 81): { unused_448409_1009139178(n0, (*dest0)); } break; case ((Tnodekind293020) 51): case ((Tnodekind293020) 52): { Tnode293802* LOC113; LOC113 = (Tnode293802*)0; LOC113 = newsymnode_295183_850551059((*(*n0).kindU.S6.sons->data[((NI) 0)]).kindU.S4.sym); genlit_448891_1009139178(c0, LOC113, dest0); } break; case ((Tnodekind293020) 68): case ((Tnodekind293020) 69): case ((Tnodekind293020) 70): { NI tmp00; NI tmp10; NI tmp20; tmp00 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], 0); tmp10 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 1)], 0); tmp20 = genx_447862_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 2)], 0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 93), tmp00, tmp10, tmp20); freetemp_447493_1009139178(c0, tmp10); freetemp_447493_1009139178(c0, tmp20); { Topcode344015 LOC119; if (!(((NI) 0) <= ((NI) ((*dest0))))) goto LA117; LOC119 = (Topcode344015)0; LOC119 = whichasgnopc_450420_1009139178(n0); gabc_446714_1009139178(c0, n0, LOC119, ((NI) ((*dest0))), tmp00, ((NI) 1)); freetemp_447493_1009139178(c0, tmp00); } goto LA115; LA117: ; { (*dest0) = ((NI) (tmp00)); } LA115: ; } break; case ((Tnodekind293020) 1): case ((Tnodekind293020) 125): case ((Tnodekind293020) 98): case ((Tnodekind293020) 101): case ((Tnodekind293020) 90): case ((Tnodekind293020) 83): case ((Tnodekind293020) 121): case ((Tnodekind293020) 116): case ((Tnodekind293020) 120): { unused_448409_1009139178(n0, (*dest0)); } break; case ((Tnodekind293020) 71): case ((Tnodekind293020) 72): { gen_447825_1009139178(c0, (*n0).kindU.S6.sons->data[((NI) 0)], dest0, 0); } break; case ((Tnodekind293020) 41): { genarrayconstr_452654_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 39): { gensetconstr_452701_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 38): { genobjconstr_452733_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 37): case ((Tnodekind293020) 155): { gentupleconstr_452816_1009139178(c0, n0, dest0); } break; case ((Tnodekind293020) 61): { { if (!(((*c0).features &(1U<<((NU)(((Tsandboxflag344021) 0))&7U)))!=0)) goto LA130; genconv_449518_1009139178(c0, n0, (*n0).kindU.S6.sons->data[((NI) 1)], dest0, ((Topcode344015) 85)); } goto LA128; LA130: ; { globalerror_197071_155036129((*n0).info, ((Tmsgkind192002) 4), ((NimStringDesc*) &T1009139178_46)); } LA128: ; } break; case ((Tnodekind293020) 132): { gentypelit_451216_1009139178(c0, (*n0).typ, dest0); } break; default: { NimStringDesc* LOC135; NimStringDesc* LOC136; LOC135 = (NimStringDesc*)0; LOC136 = (NimStringDesc*)0; LOC136 = HEX24_312066_382274130(n0); LOC135 = rawNewString(LOC136->Sup.len + 28); appendString(LOC135, ((NimStringDesc*) &T1009139178_47)); appendString(LOC135, LOC136); globalerror_197071_155036129((*n0).info, ((Tmsgkind192002) 4), LOC135); } break; } } N_NIMCALL(void, gen_447852_1009139178)(Tctx344035* c0, Tnode293802* n0, Tgenflag446202Set flags0) { NI tmp0; tmp0 = ((NI) -1); gen_447825_1009139178(c0, n0, (&tmp0), flags0); } N_NIMCALL(void, finaljumptarget_453697_1009139178)(Tctx344035* c0, NI pc0, NI diff0) { NU32 oldinstr0; { NIM_BOOL LOC3; NimStringDesc* LOC7; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) -32767) < diff0); if (!(LOC3)) goto LA4; LOC3 = (diff0 < ((NI) 32767)); LA4: ; if (!!(LOC3)) goto LA5; LOC7 = (NimStringDesc*)0; LOC7 = HEX24_197185_1689653243(T1009139178_48); internalerror_197113_155036129(LOC7); } LA5: ; oldinstr0 = (*c0).code->data[pc0]; (*c0).code->data[pc0] = (unsigned int)(((NU32) ((NU32)(oldinstr0 & ((NU32) 65535)))) | (NU32)((NU32)(((NU32) ((NI)(diff0 + ((NI) 32768))))) << (NU32)(((NU32) 16)))); } N_NIMCALL(void, optimizejumps_453785_1009139178)(Tctx344035* c0, NI start0) { { NI i_453815_1009139178; NI HEX3Atmp_454044_1009139178; NI res_454047_1009139178; i_453815_1009139178 = (NI)0; HEX3Atmp_454044_1009139178 = (NI)0; HEX3Atmp_454044_1009139178 = (((*c0).code ? (*c0).code->Sup.len : 0) - 1); res_454047_1009139178 = start0; { while (1) { Topcode344015 opc0; if (!(res_454047_1009139178 <= HEX3Atmp_454044_1009139178)) goto LA3; i_453815_1009139178 = res_454047_1009139178; opc0 = ((Topcode344015) ((NU32)((*c0).code->data[i_453815_1009139178] & ((NU32) 255)))); switch (opc0) { case ((Topcode344015) 135): case ((Topcode344015) 136): { NI reg0; NI d0; reg0 = ((NI) ((NU32)((NU32)((NU32)((*c0).code->data[i_453815_1009139178]) >> (NU32)(((NU32) 8))) & ((NU32) 255)))); d0 = (NI)(i_453815_1009139178 + (NI)(((NI) ((NU32)((NU32)((*c0).code->data[i_453815_1009139178]) >> (NU32)(((NU32) 16))))) - ((NI) 32768))); { NI iters_453867_1009139178; NI res_454033_1009139178; iters_453867_1009139178 = (NI)0; res_454033_1009139178 = ((NI) 10); { while (1) { if (!(((NI) 0) <= res_454033_1009139178)) goto LA7; iters_453867_1009139178 = res_454033_1009139178; switch (((Topcode344015) ((NU32)((*c0).code->data[d0] & ((NU32) 255))))) { case ((Topcode344015) 137): case ((Topcode344015) 138): { d0 = (NI)(d0 + (NI)(((NI) ((NU32)((NU32)((*c0).code->data[d0]) >> (NU32)(((NU32) 16))))) - ((NI) 32768))); } break; case ((Topcode344015) 135): case ((Topcode344015) 136): { { if (!!((((NI) (((NI) ((NU32)((NU32)((NU32)((*c0).code->data[d0]) >> (NU32)(((NU32) 8))) & ((NU32) 255)))))) == ((NI) (reg0))))) goto LA12; goto LA5; } LA12: ; { if (!(((Topcode344015) ((NU32)((*c0).code->data[d0] & ((NU32) 255)))) == opc0)) goto LA16; d0 = (NI)(d0 + (NI)(((NI) ((NU32)((NU32)((*c0).code->data[d0]) >> (NU32)(((NU32) 16))))) - ((NI) 32768))); } goto LA14; LA16: ; { d0 = (NI)(d0 + ((NI) 1)); } LA14: ; } break; default: { goto LA5; } break; } res_454033_1009139178 -= ((NI) 1); } LA7: ; } } LA5: ; { if (!!((d0 == (NI)(i_453815_1009139178 + (NI)(((NI) ((NU32)((NU32)((*c0).code->data[i_453815_1009139178]) >> (NU32)(((NU32) 16))))) - ((NI) 32768)))))) goto LA22; finaljumptarget_453697_1009139178(c0, i_453815_1009139178, (NI)(d0 - i_453815_1009139178)); } LA22: ; } break; case ((Topcode344015) 137): case ((Topcode344015) 138): { NI d0; NI iters0; d0 = (NI)(i_453815_1009139178 + (NI)(((NI) ((NU32)((NU32)((*c0).code->data[i_453815_1009139178]) >> (NU32)(((NU32) 16))))) - ((NI) 32768))); iters0 = ((NI) 10); { while (1) { NIM_BOOL LOC27; LOC27 = (NIM_BOOL)0; LOC27 = (((Topcode344015) ((NU32)((*c0).code->data[d0] & ((NU32) 255)))) == ((Topcode344015) 137)); if (!(LOC27)) goto LA28; LOC27 = (((NI) 0) < iters0); LA28: ; if (!LOC27) goto LA26; d0 = (NI)(d0 + (NI)(((NI) ((NU32)((NU32)((*c0).code->data[d0]) >> (NU32)(((NU32) 16))))) - ((NI) 32768))); iters0 -= ((NI) 1); } LA26: ; } { if (!(((Topcode344015) ((NU32)((*c0).code->data[d0] & ((NU32) 255)))) == ((Topcode344015) 1))) goto LA31; (*c0).code->data[i_453815_1009139178] = (*c0).code->data[d0]; } goto LA29; LA31: ; { if (!!((d0 == (NI)(i_453815_1009139178 + (NI)(((NI) ((NU32)((NU32)((*c0).code->data[i_453815_1009139178]) >> (NU32)(((NU32) 16))))) - ((NI) 32768)))))) goto LA34; finaljumptarget_453697_1009139178(c0, i_453815_1009139178, (NI)(d0 - i_453815_1009139178)); } goto LA29; LA34: ; LA29: ; } break; default: { } break; } res_454047_1009139178 += ((NI) 1); } LA3: ; } } } N_NIMCALL(NI, genproc_452867_1009139178)(Tctx344035* c0, Tsym293834* s0) { NI result0; Tnode293802* x0; result0 = (NI)0; x0 = (*(*s0).ast).kindU.S6.sons->data[((NI) 5)]; { NIM_BOOL LOC3; Tnode293802* LOC5; NI last0; NU32 eofinstr0; Tnode293802* body0; NI procstart0; PprocHEX3Aobjecttype344220* p0; PprocHEX3Aobjecttype344220* LOC20; PprocHEX3Aobjecttype344220* oldprc0; LOC3 = (NIM_BOOL)0; LOC3 = ((*x0).kind == ((Tnodekind293020) 1)); if (LOC3) goto LA4; LOC5 = (Tnode293802*)0; LOC5 = HEX5BHEX5D_294238_850551059(x0, ((NI) 0)); LOC3 = ((*LOC5).kind == ((Tnodekind293020) 1)); LA4: ; if (!LOC3) goto LA6; last0 = (NI)(((*c0).code ? (*c0).code->Sup.len : 0) - ((NI) 1)); eofinstr0 = (NU32)0; { NIM_BOOL LOC10; LOC10 = (NIM_BOOL)0; LOC10 = (((NI) 0) <= last0); if (!(LOC10)) goto LA11; LOC10 = (((Topcode344015) ((NU32)((*c0).code->data[last0] & ((NU32) 255)))) == ((Topcode344015) 0)); LA11: ; if (!LOC10) goto LA12; eofinstr0 = (*c0).code->data[last0]; (*c0).code = (TY344241*) setLengthSeq(&((*c0).code)->Sup, sizeof(NU32), ((NI) (last0))); (*c0).debug = (TY193086*) setLengthSeq(&((*c0).debug)->Sup, sizeof(Tlineinfo192336), ((NI) (last0))); } LA12: ; result0 = (NI)(((*c0).code ? (*c0).code->Sup.len : 0) + ((NI) 1)); { TY441139 LOC18; if (!((*x0).kind == ((Tnodekind293020) 1))) goto LA16; memset((void*)LOC18, 0, sizeof(LOC18)); LOC18[0] = newintnode_294660_850551059(((Tnodekind293020) 6), ((NI64) (result0))); LOC18[1] = emptynode_294801_850551059; x0 = newtree_294602_850551059(((Tnodekind293020) 41), LOC18, 2); } goto LA14; LA16: ; { asgnRefNoCycle((void**) (&(*x0).kindU.S6.sons->data[((NI) 0)]), newintnode_294660_850551059(((Tnodekind293020) 6), ((NI64) (result0)))); } LA14: ; asgnRefNoCycle((void**) (&(*(*s0).ast).kindU.S6.sons->data[((NI) 5)]), x0); body0 = getbody_336227_1724185294(s0); procstart0 = xjmp_447264_1009139178(c0, body0, ((Topcode344015) 137), ((NI) 0)); LOC20 = (PprocHEX3Aobjecttype344220*)0; LOC20 = (PprocHEX3Aobjecttype344220*) newObj((&NTI344027), sizeof(PprocHEX3Aobjecttype344220)); if ((*LOC20).blocks) nimGCunrefNoCycle((*LOC20).blocks); (*LOC20).blocks = (TY344221*) newSeqRC1((&NTI344221), 0); asgnRefNoCycle((void**) (&(*LOC20).sym), s0); p0 = LOC20; oldprc0 = (*c0).prc; asgnRefNoCycle((void**) (&(*c0).prc), p0); genparams_453655_1009139178(c0, (*(*s0).typ).n); { NIM_BOOL LOC23; NIM_BOOL LOC24; Tnode293802* LOC27; Tnode293802* LOC30; LOC23 = (NIM_BOOL)0; LOC24 = (NIM_BOOL)0; LOC24 = ((*s0).kind == ((Tsymkind293435) 16)); if (!(LOC24)) goto LA25; LOC24 = !((((*s0).flags &(1U<<((NU)(((Tsymflag293184) 25))&31U)))!=0)); LA25: ; LOC23 = LOC24; if (!(LOC23)) goto LA26; LOC27 = (Tnode293802*)0; LOC27 = HEX5BHEX5D_294238_850551059((*s0).ast, ((NI) 2)); LOC23 = !(((*LOC27).kind == ((Tnodekind293020) 1))); LA26: ; if (!LOC23) goto LA28; LOC30 = (Tnode293802*)0; LOC30 = HEX5BHEX5D_294238_850551059((*s0).ast, ((NI) 2)); gengenericparams_453745_1009139178(c0, LOC30); } LA28: ; { if (!(((*(*s0).typ).flags &(1U<<((NU)(((Ttypeflag293431) 11))&31U)))!=0)) goto LA33; (*(*c0).prc).slots[((*(*c0).prc).maxslots)- 0] = T1009139178_6; (*(*c0).prc).maxslots += ((NI) 1); } LA33: ; gen_447852_1009139178(c0, body0, 0); gabc_446714_1009139178(c0, body0, ((Topcode344015) 1), ((NI) 0), ((NI) 0), ((NI) 0)); patch_447318_1009139178(c0, procstart0); gabc_446714_1009139178(c0, body0, ((Topcode344015) 0), ((NI) ((NU32)((NU32)((NU32)(eofinstr0) >> (NU32)(((NU32) 8))) & ((NU32) 255)))), ((NI) 0), ((NI) 0)); optimizejumps_453785_1009139178(c0, result0); (*s0).offset = (*(*c0).prc).maxslots; asgnRefNoCycle((void**) (&(*c0).prc), oldprc0); } goto LA1; LA6: ; { Tnode293802* LOC36; (*(*c0).prc).maxslots = (*s0).offset; LOC36 = (Tnode293802*)0; LOC36 = HEX5BHEX5D_294238_850551059(x0, ((NI) 0)); result0 = ((NI) ((*LOC36).kindU.S1.intval)); } LA1: ; return result0; } N_NIMCALL(void, removelasteof_453399_1009139178)(Tctx344035* c0) { NI last0; last0 = (NI)(((*c0).code ? (*c0).code->Sup.len : 0) - ((NI) 1)); { NIM_BOOL LOC3; LOC3 = (NIM_BOOL)0; LOC3 = (((NI) 0) <= last0); if (!(LOC3)) goto LA4; LOC3 = (((Topcode344015) ((NU32)((*c0).code->data[last0] & ((NU32) 255)))) == ((Topcode344015) 0)); LA4: ; if (!LOC3) goto LA5; (*c0).code = (TY344241*) setLengthSeq(&((*c0).code)->Sup, sizeof(NU32), ((NI) (last0))); (*c0).debug = (TY193086*) setLengthSeq(&((*c0).debug)->Sup, sizeof(Tlineinfo192336), ((NI) (last0))); } LA5: ; } N_NIMCALL(NI, genexpr_453638_1009139178)(Tctx344035* c0, Tnode293802* n0, NIM_BOOL requiresvalue0) { NI result0; NI d0; result0 = (NI)0; removelasteof_453399_1009139178(c0); result0 = ((*c0).code ? (*c0).code->Sup.len : 0); d0 = ((NI) -1); gen_447825_1009139178(c0, n0, (&d0), 0); { if (!(((NI) (d0)) < ((NI) 0))) goto LA3; { if (!requiresvalue0) goto LA7; globalerror_197071_155036129((*n0).info, ((Tmsgkind192002) 4), ((NimStringDesc*) &T1009139178_49)); } LA7: ; d0 = ((NI) 0); } LA3: ; gabc_446714_1009139178(c0, n0, ((Topcode344015) 0), ((NI) (d0)), ((NI) 0), ((NI) 0)); return result0; } N_NIMCALL(NI, genstmt_453622_1009139178)(Tctx344035* c0, Tnode293802* n0) { NI result0; NI d0; result0 = (NI)0; removelasteof_453399_1009139178(c0); result0 = ((*c0).code ? (*c0).code->Sup.len : 0); d0 = ((NI) -1); gen_447825_1009139178(c0, n0, (&d0), 0); gabc_446714_1009139178(c0, n0, ((Topcode344015) 0), ((NI) 0), ((NI) 0), ((NI) 0)); { if (!(((NI) 0) <= ((NI) (d0)))) goto LA3; globalerror_197071_155036129((*n0).info, ((Tmsgkind192002) 4), ((NimStringDesc*) &T1009139178_50)); } LA3: ; return result0; } NIM_EXTERNC N_NOINLINE(void, compiler_vmgenInit000)(void) { } NIM_EXTERNC N_NOINLINE(void, compiler_vmgenDatInit000)(void) { }
30.793586
313
0.664374
[ "object" ]
03a46fe409c079cb39093254f5bbc056b9095ae8
2,060
h
C
CalibTracker/SiPixelESProducers/interface/SiPixelFakeLorentzAngleESSource.h
PKUfudawei/cmssw
8fbb5ce74398269c8a32956d7c7943766770c093
[ "Apache-2.0" ]
2
2020-10-26T18:40:32.000Z
2021-04-10T16:33:25.000Z
CalibTracker/SiPixelESProducers/interface/SiPixelFakeLorentzAngleESSource.h
gartung/cmssw
3072dde3ce94dcd1791d778988198a44cde02162
[ "Apache-2.0" ]
25
2016-06-24T20:55:32.000Z
2022-02-01T19:24:45.000Z
CalibTracker/SiPixelESProducers/interface/SiPixelFakeLorentzAngleESSource.h
gartung/cmssw
3072dde3ce94dcd1791d778988198a44cde02162
[ "Apache-2.0" ]
8
2016-03-25T07:17:43.000Z
2021-07-08T17:11:21.000Z
#ifndef CalibTracker_SiPixelESProducers_SiPixelFakeLorentzAngleESSource_h #define CalibTracker_SiPixelESProducers_SiPixelFakeLorentzAngleESSource_h // -*- C++ -*- // // Package: SiPixelFakeLorentzAngleESSource // Class: SiPixelFakeLorentzAngleESSource // /**\class SiPixelFakeLorentzAngleESSource SiPixelFakeLorentzAngleESSource.h CalibTracker/SiPixelGainESProducer/src/SiPixelFakeLorentzAngleESSource.cc Description: <one line class summary> Implementation: <Notes on implementation> */ // // Original Author: Lotte Wilke // Created: Jan. 31st, 2008 // // // system include files #include <memory> // user include files #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" #include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h" #include "CondFormats/DataRecord/interface/SiPixelLorentzAngleRcd.h" #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h" // // class decleration // class SiPixelFakeLorentzAngleESSource : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder { public: SiPixelFakeLorentzAngleESSource(const edm::ParameterSet &); ~SiPixelFakeLorentzAngleESSource() override = default; virtual std::unique_ptr<SiPixelLorentzAngle> produce(const SiPixelLorentzAngleRcd &); static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); protected: void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override; private: int HVgroup(int panel, int module); // data members const edm::FileInPath fp_; const edm::FileInPath t_topo_fp_; const std::string myLabel_; typedef std::vector<edm::ParameterSet> Parameters; Parameters BPixParameters_; Parameters FPixParameters_; Parameters ModuleParameters_; float bPixLorentzAnglePerTesla_; float fPixLorentzAnglePerTesla_; }; #endif
32.1875
149
0.786893
[ "vector" ]
03a605606a1e721eb35019c53859cbd7c0d26768
1,852
h
C
assemble_aux.h
yrabbit/macro-11
4c2a960def8812fdd4db387b264befb4bfbb588c
[ "BSD-3-Clause" ]
null
null
null
assemble_aux.h
yrabbit/macro-11
4c2a960def8812fdd4db387b264befb4bfbb588c
[ "BSD-3-Clause" ]
null
null
null
assemble_aux.h
yrabbit/macro-11
4c2a960def8812fdd4db387b264befb4bfbb588c
[ "BSD-3-Clause" ]
null
null
null
#ifndef ASSEMBLE_AUX__H #define ASSEMBLE_AUX__H #include "stream2.h" #include "object.h" #include "extree.h" #define NO_REG 0777 typedef struct addr_mode { unsigned type; /* The bits that represent the addressing mode */ /* bits 0:2 are register number */ /* bit 3 is indirect */ /* bits 4:6 are mode, where 0=Rn, 1=(Rn)+, 2=-(Rn), 3=offset(Rn) */ int rel; /* the addressing mode is PC-relative */ EX_TREE *offset; /* Expression giving the offset */ } ADDR_MODE; void push_cond( int ok, STREAM *str); void pop_cond( int to); int express_sym_offset( EX_TREE *value, SYMBOL **sym, unsigned *offset); void change_dot( TEXT_RLD *tr, int size); int store_word( STREAM *str, TEXT_RLD *tr, int size, unsigned word); int store_limits( STREAM *str, TEXT_RLD *tr); void store_value( STACK *stack, TEXT_RLD *tr, int size, EX_TREE *value); int do_word( STACK *stack, TEXT_RLD *tr, char *cp, int size); SECTION *new_section( void); void go_section( TEXT_RLD *tr, SECTION *sect); void free_addr_mode( ADDR_MODE *mode); int eval_defined( EX_TREE *value); int eval_undefined( EX_TREE *value); void mode_extension( TEXT_RLD *tr, ADDR_MODE *mode, STREAM *str); int check_branch( STACK *stack, unsigned offset, int min, int max); unsigned get_register( EX_TREE *expr); void write_globals( FILE *obj); void migrate_implicit( void); #endif
20.130435
82
0.523218
[ "object" ]
03a709ec82114eb1b17691d6400211ffb5d294d2
3,671
h
C
Source/Signal/FrequencyDomain.h
mdahlgrengadd/AudioLib-Emscripten
5ce6c31650c1e285e50badfead170e12b6c54a13
[ "MIT", "Unlicense" ]
7
2017-12-08T19:52:01.000Z
2022-01-16T19:52:29.000Z
Source/Signal/FrequencyDomain.h
mdahlgrengadd/AudioLib-Emscripten
5ce6c31650c1e285e50badfead170e12b6c54a13
[ "MIT", "Unlicense" ]
null
null
null
Source/Signal/FrequencyDomain.h
mdahlgrengadd/AudioLib-Emscripten
5ce6c31650c1e285e50badfead170e12b6c54a13
[ "MIT", "Unlicense" ]
4
2018-04-02T09:48:07.000Z
2022-01-16T19:52:32.000Z
/* * AudioLib * * Copyright (c) 2017 - Terence M. Darwen - tmdarwen.com * * The MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ //! @file FrequencyDomain.h //! @brief Class to hold frequency domain information for a signal. #pragma once #include <AudioData/AudioData.h> #include <vector> namespace Signal { //! Simple structure to hold a single frequency bin's frequency domain data. struct FrequencyBin { //! Instantiates frequency bin data with zeroes for real and imaginary values. FrequencyBin() : reX_(0.0), imX_(0.0) { } //! Instantiates frequency bin data with the given values. FrequencyBin(double reX, double imX) : reX_(reX), imX_(imX) { } //! The real component of the frequency. double reX_; //! The imaginary component of the frequency. double imX_; }; //! Class to hold frequency domain information for a signal. class FrequencyDomain { public: //! Constructs object with no frequency data. FrequencyDomain(); //! Constructs object with the given frequency domain data. FrequencyDomain(std::vector<Signal::FrequencyBin> FrequencyBin); //! Add the given frequency bin data. void PushFrequencyBin(Signal::FrequencyBin FrequencyBin); //! Get the number of frequency bins in this frequency domain data. std::size_t GetSize() const; //! Get frequency bin data for the given frequency bin. const FrequencyBin& GetBin(std::size_t binNumber) const; //! Get the magnitudes for all frequency bins. const std::vector<double>& GetMagnitudes(); //! Get the wrapped phase values for all frequency bins. const std::vector<double>& GetWrappedPhases(); //! Get the real components of all frequency bins. const std::vector<double>& GetRealComponent(); //! Get the imaginary components of all frequency bins. const std::vector<double>& GetImaginaryComponent(); //! Get the data for all frequency bins. std::vector<Signal::FrequencyBin> GetRectangularFrequencyData() const; private: double CalculateArcTangent(double imaginary, double real); enum Quadrant { QUADRANT1, QUADRANT2, QUADRANT3, QUADRANT4, BETWEEN_QUADRANT1_AND_QUADRANT2, BETWEEN_QUADRANT2_AND_QUADRANT3, BETWEEN_QUADRANT3_AND_QUADRANT4, BETWEEN_QUADRANT4_AND_QUADRANT1 }; Quadrant GetQuadrant(double reX, double imX); double GetWrappedPhase(double reX, double imX); std::vector<FrequencyBin> data_; // Cached data, lazy initialized std::vector<double> magnitudes_; std::vector<double> wrappedPhases_; std::vector<double> realComponent_; std::vector<double> imaginaryComponent_; }; }
31.110169
80
0.733043
[ "object", "vector" ]
03aa1e234a4eb837a47202781889dc5e6da443cb
678
h
C
Source/RE_Particle.h
MissclickStudios/The-Mandalorian-Sands-of-Arvala
346081b26409a33f129189dbcd5a830d6d58f7da
[ "MIT" ]
1
2021-05-14T13:08:40.000Z
2021-05-14T13:08:40.000Z
Source/RE_Particle.h
MissclickStudios/The-Mandalorian-Sands-of-Arvala
346081b26409a33f129189dbcd5a830d6d58f7da
[ "MIT" ]
null
null
null
Source/RE_Particle.h
MissclickStudios/The-Mandalorian-Sands-of-Arvala
346081b26409a33f129189dbcd5a830d6d58f7da
[ "MIT" ]
1
2021-07-05T08:18:36.000Z
2021-07-05T08:18:36.000Z
#ifndef __RE_PARTICLE_H__ #define __RE_PARTICLE_H__ #include "Renderer.h" class R_Texture; class R_Shader; typedef unsigned int uint; const float Particles_Coords[] = { // Change later to ParticlesCoords 1, 1, 1, 0, 0, 0, 1, 0, }; class RE_Particle : public Renderer { public: RE_Particle(float4x4* transform, float lineWidth, Color color, R_Texture* rTexture, R_Shader* rShader); RE_Particle(float4x4* transform, R_Texture* rTexture, R_Shader* rShader); ~RE_Particle(); bool Render() override; bool CleanUp() override; private: void LoadBuffers(); private: uint VAO; R_Texture* rTexture; R_Shader* rShader; }; #endif // !__RE_PARTICLE_H__
17.842105
104
0.724189
[ "render", "transform" ]
03b0eebb73a7af0f8b468580c4a46ec654f729f1
3,482
h
C
plugins/community/repos/squinkylabs-plug1/test/ExtremeTester.h
guillaume-plantevin/VeeSeeVSTRack
76fafc8e721613669d6f5ae82a0f58ce923a91e1
[ "Zlib", "BSD-3-Clause" ]
233
2018-07-02T16:49:36.000Z
2022-02-27T21:45:39.000Z
plugins/community/repos/squinkylabs-plug1/test/ExtremeTester.h
guillaume-plantevin/VeeSeeVSTRack
76fafc8e721613669d6f5ae82a0f58ce923a91e1
[ "Zlib", "BSD-3-Clause" ]
24
2018-07-09T11:32:15.000Z
2022-01-07T01:45:43.000Z
plugins/community/repos/squinkylabs-plug1/test/ExtremeTester.h
guillaume-plantevin/VeeSeeVSTRack
76fafc8e721613669d6f5ae82a0f58ce923a91e1
[ "Zlib", "BSD-3-Clause" ]
24
2018-07-14T21:55:30.000Z
2021-05-04T04:20:34.000Z
#pragma once #include "asserts.h" #include <vector> /** * Utility class that counts up in binary using an array of ints to hold the bits. * */ class BitCounter { public: void reset(int size) { done = false; state.resize(size); for (int i = 0; i < size; ++i) { state[i] = 0; } } bool atMax() const { for (size_t i = 0; i < state.size(); ++i) { if (state[i] == 0) { return false; } } return true; } bool isDone() const { return done; } void next() { if (atMax()) { done = true; return; } state[0]++; for (size_t i = 0; i < state.size(); ++i) { if (state[i] > 1) { state[i] = 0; ++state[i + 1]; } } } template <typename Q> void setState(std::vector<Q>& testSignal, const std::vector< std::pair<float, float>>* signalLimits) { for (int i = (int) state.size() - 1; i >= 0; --i) { float min = -10.f; float max = 10.f; if (signalLimits) { // here we want to clip these to the possible values of params min = (*signalLimits)[i].first; max = (*signalLimits)[i].second; assertNE(min, max); assertGT(max, min); } testSignal[i].value = state[i] > 0 ? max : min; } } void dump(const char * label) { printf("State (%s): ", label); for (int i = (int) state.size() - 1; i >= 0; --i) { printf("%d ", state[i]); } printf("\n"); } private: std::vector<int> state; bool done; }; /** * Tests a composite by feeding all the inputs and parameters (in every possible permutation) * with extreme inputs. Asserts that the output stays in a semi-sane range. * Typically this test will fail by triggering an assert in some distant code. */ template <typename T> class ExtremeTester { public: static void test(T& dut, const std::vector< std::pair<float, float>>& paramLimits, bool checkOutput, const char * testName) { printf("extreme test starting for %s. %s ....\n", testName, checkOutput ? "test output" : ""); const int numInputs = dut.NUM_INPUTS; const int numParams = dut.NUM_PARAMS; const int numOutputs = dut.NUM_OUTPUTS; assert(numInputs < 20); assertEQ(paramLimits.size(), numParams); const std::vector< std::pair<float, float>> * nullLimits = nullptr; BitCounter inputState; BitCounter paramsState; for (inputState.reset(numInputs); !inputState.isDone(); inputState.next()) { inputState.setState(dut.inputs, nullLimits); for (paramsState.reset(numParams); !paramsState.isDone(); paramsState.next()) { paramsState.setState(dut.params, &paramLimits); for (int i = 0; i < 100; ++i) { dut.step(); for (int j = 0; j < numOutputs; ++j) { const float out = dut.outputs[j].value; if (checkOutput) { assertGE(out, -150); assertLE(out, 150); } } } } } printf("extreme test done\n"); } };
27.634921
104
0.491097
[ "vector" ]
03b6e608c2fc598264684ec1c94f8fe4255e87f9
1,135
h
C
Cocos2dx-3x/PhotoExample/cocos2d/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h
ezibyte/EziSocial-PhotoExample
12818880696d3f76ffd5b66646bab21fa3619821
[ "Apache-2.0" ]
14
2015-01-29T08:41:15.000Z
2017-09-03T14:29:32.000Z
Cocos2dx-3x/PhotoExample/cocos2d/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h
ezibyte/EziSocial-PhotoExample
12818880696d3f76ffd5b66646bab21fa3619821
[ "Apache-2.0" ]
1
2016-09-20T10:54:53.000Z
2016-09-20T10:54:53.000Z
Cocos2dx-3x/PhotoExample/cocos2d/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h
ezibyte/EziSocial-PhotoExample
12818880696d3f76ffd5b66646bab21fa3619821
[ "Apache-2.0" ]
22
2015-01-05T08:07:50.000Z
2019-03-25T07:52:48.000Z
#ifndef _DRAW_PRIMITIVES_TEST_H_ #define _DRAW_PRIMITIVES_TEST_H_ #include "cocos2d.h" #include "../testBasic.h" #include "../BaseTest.h" #include <string> class BaseLayer : public BaseTest { public: BaseLayer(); void restartCallback(Ref* sender); void nextCallback(Ref* sender); void backCallback(Ref* sender); virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter() override; }; class DrawPrimitivesTest : public BaseLayer { public: DrawPrimitivesTest(); virtual std::string title() const override; virtual std::string subtitle() const override; virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: void onDraw(const Mat4 &transform, uint32_t flags); CustomCommand _customCommand; }; class DrawNodeTest : public BaseLayer { public: DrawNodeTest(); virtual std::string title() const override; virtual std::string subtitle() const override; }; class DrawPrimitivesTestScene : public TestScene { public: virtual void runThisTest(); }; #endif
21.415094
90
0.718943
[ "transform" ]
03b90b2126023deacd709c20e9a86f456a94aaa6
10,620
c
C
xen/xen-4.2.2/xen/arch/x86/x86_64/compat/traps.c
zhiming-shen/Xen-Blanket-NG
47e59d9bb92e8fdc60942df526790ddb983a5496
[ "Apache-2.0" ]
1
2018-02-02T00:15:26.000Z
2018-02-02T00:15:26.000Z
xen/xen-4.2.2/xen/arch/x86/x86_64/compat/traps.c
zhiming-shen/Xen-Blanket-NG
47e59d9bb92e8fdc60942df526790ddb983a5496
[ "Apache-2.0" ]
null
null
null
xen/xen-4.2.2/xen/arch/x86/x86_64/compat/traps.c
zhiming-shen/Xen-Blanket-NG
47e59d9bb92e8fdc60942df526790ddb983a5496
[ "Apache-2.0" ]
1
2019-05-27T09:47:18.000Z
2019-05-27T09:47:18.000Z
#include <xen/event.h> #include <asm/regs.h> #include <compat/callback.h> #include <compat/arch-x86_32.h> void compat_show_guest_stack(struct vcpu *v, struct cpu_user_regs *regs, int debug_stack_lines) { unsigned int i, *stack, addr, mask = STACK_SIZE; stack = (unsigned int *)(unsigned long)regs->_esp; printk("Guest stack trace from esp=%08lx:\n ", (unsigned long)stack); if ( !__compat_access_ok(v->domain, stack, sizeof(*stack)) ) { printk("Guest-inaccessible memory.\n"); return; } if ( v != current ) { struct vcpu *vcpu; unsigned long mfn; ASSERT(guest_kernel_mode(v, regs)); mfn = read_cr3() >> PAGE_SHIFT; for_each_vcpu( v->domain, vcpu ) if ( pagetable_get_pfn(vcpu->arch.guest_table) == mfn ) break; if ( !vcpu ) { stack = do_page_walk(v, (unsigned long)stack); if ( (unsigned long)stack < PAGE_SIZE ) { printk("Inaccessible guest memory.\n"); return; } mask = PAGE_SIZE; } } for ( i = 0; i < debug_stack_lines * 8; i++ ) { if ( (((long)stack - 1) ^ ((long)(stack + 1) - 1)) & mask ) break; if ( __get_user(addr, stack) ) { if ( i != 0 ) printk("\n "); printk("Fault while accessing guest memory."); i = 1; break; } if ( (i != 0) && ((i % 8) == 0) ) printk("\n "); printk(" %08x", addr); stack++; } if ( i == 0 ) printk("Stack empty."); printk("\n"); } unsigned int compat_iret(void) { struct cpu_user_regs *regs = guest_cpu_user_regs(); struct vcpu *v = current; u32 eflags; /* Trim stack pointer to 32 bits. */ regs->rsp = (u32)regs->rsp; /* Restore EAX (clobbered by hypercall). */ if ( unlikely(__get_user(regs->_eax, (u32 *)regs->rsp)) ) goto exit_and_crash; /* Restore CS and EIP. */ if ( unlikely(__get_user(regs->_eip, (u32 *)regs->rsp + 1)) || unlikely(__get_user(regs->cs, (u32 *)regs->rsp + 2)) ) goto exit_and_crash; /* * Fix up and restore EFLAGS. We fix up in a local staging area * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest. */ if ( unlikely(__get_user(eflags, (u32 *)regs->rsp + 3)) ) goto exit_and_crash; regs->_eflags = (eflags & ~X86_EFLAGS_IOPL) | X86_EFLAGS_IF; if ( unlikely(eflags & X86_EFLAGS_VM) ) { /* * Cannot return to VM86 mode: inject a GP fault instead. Note that * the GP fault is reported on the first VM86 mode instruction, not on * the IRET (which is why we can simply leave the stack frame as-is * (except for perhaps having to copy it), which in turn seems better * than teaching create_bounce_frame() to needlessly deal with vm86 * mode frames). */ const struct trap_info *ti; u32 x, ksp = v->arch.pv_vcpu.kernel_sp - 40; unsigned int i; int rc = 0; gdprintk(XENLOG_ERR, "VM86 mode unavailable (ksp:%08X->%08X)\n", regs->_esp, ksp); if ( ksp < regs->_esp ) { for (i = 1; i < 10; ++i) { rc |= __get_user(x, (u32 *)regs->rsp + i); rc |= __put_user(x, (u32 *)(unsigned long)ksp + i); } } else if ( ksp > regs->_esp ) { for (i = 9; i > 0; ++i) { rc |= __get_user(x, (u32 *)regs->rsp + i); rc |= __put_user(x, (u32 *)(unsigned long)ksp + i); } } if ( rc ) goto exit_and_crash; regs->_esp = ksp; regs->ss = v->arch.pv_vcpu.kernel_ss; ti = &v->arch.pv_vcpu.trap_ctxt[TRAP_gp_fault]; if ( TI_GET_IF(ti) ) eflags &= ~X86_EFLAGS_IF; regs->_eflags &= ~(X86_EFLAGS_VM|X86_EFLAGS_RF| X86_EFLAGS_NT|X86_EFLAGS_TF); if ( unlikely(__put_user(0, (u32 *)regs->rsp)) ) goto exit_and_crash; regs->_eip = ti->address; regs->cs = ti->cs; } else if ( unlikely(ring_0(regs)) ) goto exit_and_crash; else if ( !ring_1(regs) ) { /* Return to ring 2/3: restore ESP and SS. */ if ( __get_user(regs->ss, (u32 *)regs->rsp + 5) || __get_user(regs->_esp, (u32 *)regs->rsp + 4)) goto exit_and_crash; } else regs->_esp += 16; /* Restore upcall mask from supplied EFLAGS.IF. */ vcpu_info(v, evtchn_upcall_mask) = !(eflags & X86_EFLAGS_IF); async_exception_cleanup(v); /* * The hypercall exit path will overwrite EAX with this return * value. */ return regs->_eax; exit_and_crash: gdprintk(XENLOG_ERR, "Fatal error\n"); domain_crash(v->domain); return 0; } static long compat_register_guest_callback( struct compat_callback_register *reg) { long ret = 0; struct vcpu *v = current; fixup_guest_code_selector(v->domain, reg->address.cs); switch ( reg->type ) { case CALLBACKTYPE_event: v->arch.pv_vcpu.event_callback_cs = reg->address.cs; v->arch.pv_vcpu.event_callback_eip = reg->address.eip; break; case CALLBACKTYPE_failsafe: v->arch.pv_vcpu.failsafe_callback_cs = reg->address.cs; v->arch.pv_vcpu.failsafe_callback_eip = reg->address.eip; if ( reg->flags & CALLBACKF_mask_events ) set_bit(_VGCF_failsafe_disables_events, &v->arch.vgc_flags); else clear_bit(_VGCF_failsafe_disables_events, &v->arch.vgc_flags); break; case CALLBACKTYPE_syscall32: v->arch.pv_vcpu.syscall32_callback_cs = reg->address.cs; v->arch.pv_vcpu.syscall32_callback_eip = reg->address.eip; v->arch.pv_vcpu.syscall32_disables_events = (reg->flags & CALLBACKF_mask_events) != 0; break; case CALLBACKTYPE_sysenter: v->arch.pv_vcpu.sysenter_callback_cs = reg->address.cs; v->arch.pv_vcpu.sysenter_callback_eip = reg->address.eip; v->arch.pv_vcpu.sysenter_disables_events = (reg->flags & CALLBACKF_mask_events) != 0; break; case CALLBACKTYPE_nmi: ret = register_guest_nmi_callback(reg->address.eip); break; default: ret = -ENOSYS; break; } return ret; } static long compat_unregister_guest_callback( struct compat_callback_unregister *unreg) { long ret; switch ( unreg->type ) { case CALLBACKTYPE_event: case CALLBACKTYPE_failsafe: case CALLBACKTYPE_syscall32: case CALLBACKTYPE_sysenter: ret = -EINVAL; break; case CALLBACKTYPE_nmi: ret = unregister_guest_nmi_callback(); break; default: ret = -ENOSYS; break; } return ret; } long compat_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg) { long ret; switch ( cmd ) { case CALLBACKOP_register: { struct compat_callback_register reg; ret = -EFAULT; if ( copy_from_guest(&reg, arg, 1) ) break; ret = compat_register_guest_callback(&reg); } break; case CALLBACKOP_unregister: { struct compat_callback_unregister unreg; ret = -EFAULT; if ( copy_from_guest(&unreg, arg, 1) ) break; ret = compat_unregister_guest_callback(&unreg); } break; default: ret = -EINVAL; break; } return ret; } long compat_set_callbacks(unsigned long event_selector, unsigned long event_address, unsigned long failsafe_selector, unsigned long failsafe_address) { struct compat_callback_register event = { .type = CALLBACKTYPE_event, .address = { .cs = event_selector, .eip = event_address } }; struct compat_callback_register failsafe = { .type = CALLBACKTYPE_failsafe, .address = { .cs = failsafe_selector, .eip = failsafe_address } }; compat_register_guest_callback(&event); compat_register_guest_callback(&failsafe); return 0; } DEFINE_XEN_GUEST_HANDLE(trap_info_compat_t); int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps) { struct compat_trap_info cur; struct trap_info *dst = current->arch.pv_vcpu.trap_ctxt; long rc = 0; /* If no table is presented then clear the entire virtual IDT. */ if ( guest_handle_is_null(traps) ) { memset(dst, 0, 256 * sizeof(*dst)); return 0; } for ( ; ; ) { if ( hypercall_preempt_check() ) { rc = hypercall_create_continuation( __HYPERVISOR_set_trap_table, "h", traps); break; } if ( copy_from_guest(&cur, traps, 1) ) { rc = -EFAULT; break; } if ( cur.address == 0 ) break; fixup_guest_code_selector(current->domain, cur.cs); XLAT_trap_info(dst + cur.vector, &cur); if ( cur.vector == 0x80 ) init_int80_direct_trap(current); guest_handle_add_offset(traps, 1); } return rc; } static void hypercall_page_initialise_ring1_kernel(void *hypercall_page) { char *p; int i; /* Fill in all the transfer points with template machine code. */ for ( i = 0; i < (PAGE_SIZE / 32); i++ ) { p = (char *)(hypercall_page + (i * 32)); *(u8 *)(p+ 0) = 0xb8; /* mov $<i>,%eax */ *(u32 *)(p+ 1) = i; *(u16 *)(p+ 5) = (HYPERCALL_VECTOR << 8) | 0xcd; /* int $xx */ *(u8 *)(p+ 7) = 0xc3; /* ret */ } /* * HYPERVISOR_iret is special because it doesn't return and expects a * special stack frame. Guests jump at this transfer point instead of * calling it. */ p = (char *)(hypercall_page + (__HYPERVISOR_iret * 32)); *(u8 *)(p+ 0) = 0x50; /* push %eax */ *(u8 *)(p+ 1) = 0xb8; /* mov $__HYPERVISOR_iret,%eax */ *(u32 *)(p+ 2) = __HYPERVISOR_iret; *(u16 *)(p+ 6) = (HYPERCALL_VECTOR << 8) | 0xcd; /* int $xx */ } /* * Local variables: * mode: C * c-set-style: "BSD" * c-basic-offset: 4 * tab-width: 4 * indent-tabs-mode: nil * End: */
27.022901
78
0.553202
[ "vector" ]
03c5d4dfe9b56a5ee0e67d228ca57472b7190e2d
2,657
h
C
src/Modules/MaterializeCssModule/Components/Button/Button.h
Di-Strix/MaterializeLayout
4cf1b4c696c961b4909cb1e149e3bef44310a145
[ "MIT" ]
1
2021-07-25T08:35:08.000Z
2021-07-25T08:35:08.000Z
src/Modules/MaterializeCssModule/Components/Button/Button.h
Di-Strix/MaterializeLayout
4cf1b4c696c961b4909cb1e149e3bef44310a145
[ "MIT" ]
null
null
null
src/Modules/MaterializeCssModule/Components/Button/Button.h
Di-Strix/MaterializeLayout
4cf1b4c696c961b4909cb1e149e3bef44310a145
[ "MIT" ]
null
null
null
#ifndef _MATERIALIZE_LAYOUT_BUTTON_H_ #define _MATERIALIZE_LAYOUT_BUTTON_H_ #include <Arduino.h> #include <functional> #include "../../../../DynamicComponentRegistrationService/DynamicComponentRegistrationService.h" #include "../../../../HTMLElement/HTMLElement.h" typedef std::function<void()> ButtonCallback; template <typename T> class Button : public HTMLElement<T> { private: using HTMLElement<T>::appendChild; using HTMLElement<T>::removeAllChildren; using HTMLElement<T>::removeChild; String caption; ButtonCallback callback; void onEmit(String value); public: /** * @brief Constructs a new Button object * * @param caption the caption of the button * @param callback callback that is called when the button is clicked */ Button(DynamicComponentRegistrationService<T>* registrationService); virtual String getHTML(); /** * @brief Gets the caption of the button * * @return String */ String getCaption(); /** * @brief Sets the caption of the button * * @param caption the new caption of the button * * @return void */ void setCaption(String caption); /** * @brief Sets callback that is called when the button is clicked * * @param callback * * @return void */ void setCallback(ButtonCallback callback); }; // ======================= IMPLEMENTATION ======================= template <typename T> Button<T>::Button(DynamicComponentRegistrationService<T>* registrationService) : HTMLElement<T>(registrationService) { this->classList.add(F("waves-effect")); this->classList.add(F("waves-light")); this->classList.add(F("btn")); } template <typename T> String Button<T>::getCaption() { return this->caption; } template <typename T> void Button<T>::setCaption(String caption) { caption.trim(); this->caption = caption; } template <typename T> void Button<T>::setCallback(ButtonCallback callback) { this->callback = callback; } template <typename T> String Button<T>::getHTML() { String elemTemplate = F("<a data-id=\""); elemTemplate += (String)this->getId(); elemTemplate += F("\" data-MCSS-emitOnClick=\"true\" class=\""); elemTemplate += this->classList.value(); elemTemplate += F("\""); if (this->getWidth() > 0) { elemTemplate += F("\"style=\"width:calc(100%/12*"); elemTemplate += this->getWidth(); elemTemplate += F(");\""); } elemTemplate += F(">"); elemTemplate += this->caption; elemTemplate += F("</a>\n"); return elemTemplate; } template <typename T> void Button<T>::onEmit(String value) { if (this->callback) this->callback(); } #endif //_MATERIALIZE_LAYOUT_BUTTON_H_
22.516949
96
0.669176
[ "object" ]
03c7bc6cbd3f276af63db2a7cc36e02ad03b1f0d
12,408
h
C
lib/pxr/usd/usdAi/aiVolumeAPI.h
chunkified/usd-arnold
e344f002a1073b37b837882417588e689dc73673
[ "Apache-2.0" ]
57
2017-07-29T10:28:06.000Z
2022-02-27T09:40:38.000Z
lib/pxr/usd/usdAi/aiVolumeAPI.h
BigRoy/usd-arnold
8df3f080119016ed571e1dc0db68849a1cb81c25
[ "Apache-2.0" ]
35
2017-07-31T01:31:11.000Z
2020-04-24T00:50:31.000Z
lib/pxr/usd/usdAi/aiVolumeAPI.h
BigRoy/usd-arnold
8df3f080119016ed571e1dc0db68849a1cb81c25
[ "Apache-2.0" ]
12
2017-07-29T06:46:00.000Z
2021-08-14T23:38:55.000Z
// // Copyright 2016 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // #ifndef USDAI_GENERATED_AIVOLUMEAPI_H #define USDAI_GENERATED_AIVOLUMEAPI_H /// \file usdAi/aiVolumeAPI.h #include "pxr/pxr.h" #include "pxr/usd/usdAi/api.h" #include "pxr/usd/usd/apiSchemaBase.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usd/stage.h" #include "pxr/usd/usdAi/tokens.h" #include "pxr/base/vt/value.h" #include "pxr/base/gf/vec3d.h" #include "pxr/base/gf/vec3f.h" #include "pxr/base/gf/matrix4d.h" #include "pxr/base/tf/token.h" #include "pxr/base/tf/type.h" PXR_NAMESPACE_OPEN_SCOPE class SdfAssetPath; // -------------------------------------------------------------------------- // // AIVOLUMEAPI // // -------------------------------------------------------------------------- // /// \class UsdAiVolumeAPI /// /// API for interacting with common Arnold volume node parameters on prims. /// class UsdAiVolumeAPI : public UsdAPISchemaBase { public: /// Compile time constant representing what kind of schema this class is. /// /// \sa UsdSchemaType static const UsdSchemaType schemaType = UsdSchemaType::SingleApplyAPI; /// Construct a UsdAiVolumeAPI on UsdPrim \p prim . /// Equivalent to UsdAiVolumeAPI::Get(prim.GetStage(), prim.GetPath()) /// for a \em valid \p prim, but will not immediately throw an error for /// an invalid \p prim explicit UsdAiVolumeAPI(const UsdPrim& prim=UsdPrim()) : UsdAPISchemaBase(prim) { } /// Construct a UsdAiVolumeAPI on the prim held by \p schemaObj . /// Should be preferred over UsdAiVolumeAPI(schemaObj.GetPrim()), /// as it preserves SchemaBase state. explicit UsdAiVolumeAPI(const UsdSchemaBase& schemaObj) : UsdAPISchemaBase(schemaObj) { } /// Destructor. USDAI_API virtual ~UsdAiVolumeAPI(); /// Return a vector of names of all pre-declared attributes for this schema /// class and all its ancestor classes. Does not include attributes that /// may be authored by custom/extended methods of the schemas involved. USDAI_API static const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true); /// Return a UsdAiVolumeAPI holding the prim adhering to this /// schema at \p path on \p stage. If no prim exists at \p path on /// \p stage, or if the prim at that path does not adhere to this schema, /// return an invalid schema object. This is shorthand for the following: /// /// \code /// UsdAiVolumeAPI(stage->GetPrimAtPath(path)); /// \endcode /// USDAI_API static UsdAiVolumeAPI Get(const UsdStagePtr &stage, const SdfPath &path); /// Applies this <b>single-apply</b> API schema to the given \p prim. /// This information is stored by adding "AiVolumeAPI" to the /// token-valued, listOp metadata \em apiSchemas on the prim. /// /// \return A valid UsdAiVolumeAPI object is returned upon success. /// An invalid (or empty) UsdAiVolumeAPI object is returned upon /// failure. See \ref UsdAPISchemaBase::_ApplyAPISchema() for conditions /// resulting in failure. /// /// \sa UsdPrim::GetAppliedSchemas() /// \sa UsdPrim::HasAPI() /// USDAI_API static UsdAiVolumeAPI Apply(const UsdPrim &prim); protected: /// Returns the type of schema this class belongs to. /// /// \sa UsdSchemaType USDAI_API virtual UsdSchemaType _GetSchemaType() const; private: // needs to invoke _GetStaticTfType. friend class UsdSchemaRegistry; USDAI_API static const TfType &_GetStaticTfType(); static bool _IsTypedSchema(); // override SchemaBase virtuals. USDAI_API virtual const TfType &_GetTfType() const; public: // --------------------------------------------------------------------- // // AIVOLUMEPADDING // --------------------------------------------------------------------- // /// Amount to enlarge the volume bounds by. /// /// \n C++ Type: float /// \n Usd Type: SdfValueTypeNames->Float /// \n Variability: SdfVariabilityVarying /// \n Fallback Value: 0.0 USDAI_API UsdAttribute GetAiVolumePaddingAttr() const; /// See GetAiVolumePaddingAttr(), and also /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. /// If specified, author \p defaultValue as the attribute's default, /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - /// the default for \p writeSparsely is \c false. USDAI_API UsdAttribute CreateAiVolumePaddingAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; public: // --------------------------------------------------------------------- // // AISTEPSIZE // --------------------------------------------------------------------- // /// The step size for sampling inside the volume. If this is set to /// 0, a step size will be automatically calculated based on the /// volume's grid information. /// /// \n C++ Type: float /// \n Usd Type: SdfValueTypeNames->Float /// \n Variability: SdfVariabilityVarying /// \n Fallback Value: 0.0 USDAI_API UsdAttribute GetAiStepSizeAttr() const; /// See GetAiStepSizeAttr(), and also /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. /// If specified, author \p defaultValue as the attribute's default, /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - /// the default for \p writeSparsely is \c false. USDAI_API UsdAttribute CreateAiStepSizeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; public: // --------------------------------------------------------------------- // // AISTEPSCALE // --------------------------------------------------------------------- // /// A scaling factor applied to the step size, mostly useful when /// `step_size` is set to 0 to modulate the automatic value. /// /// \n C++ Type: float /// \n Usd Type: SdfValueTypeNames->Float /// \n Variability: SdfVariabilityVarying /// \n Fallback Value: 1.0 USDAI_API UsdAttribute GetAiStepScaleAttr() const; /// See GetAiStepScaleAttr(), and also /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. /// If specified, author \p defaultValue as the attribute's default, /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - /// the default for \p writeSparsely is \c false. USDAI_API UsdAttribute CreateAiStepScaleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; public: // --------------------------------------------------------------------- // // AICOMPRESS // --------------------------------------------------------------------- // /// Whether to compress grids to reduce memory usage. This is a /// lossy compression, however in most cases renders will be almost /// the same. /// /// \n C++ Type: bool /// \n Usd Type: SdfValueTypeNames->Bool /// \n Variability: SdfVariabilityUniform /// \n Fallback Value: True USDAI_API UsdAttribute GetAiCompressAttr() const; /// See GetAiCompressAttr(), and also /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. /// If specified, author \p defaultValue as the attribute's default, /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - /// the default for \p writeSparsely is \c false. USDAI_API UsdAttribute CreateAiCompressAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; public: // --------------------------------------------------------------------- // // AIVELOCITYSCALE // --------------------------------------------------------------------- // /// A scale factor for the velocity field. A value of 0 disables /// motion blur. /// /// \n C++ Type: float /// \n Usd Type: SdfValueTypeNames->Float /// \n Variability: SdfVariabilityVarying /// \n Fallback Value: 1.0 USDAI_API UsdAttribute GetAiVelocityScaleAttr() const; /// See GetAiVelocityScaleAttr(), and also /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. /// If specified, author \p defaultValue as the attribute's default, /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - /// the default for \p writeSparsely is \c false. USDAI_API UsdAttribute CreateAiVelocityScaleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; public: // --------------------------------------------------------------------- // // AIVELOCITYFPS // --------------------------------------------------------------------- // /// The frame rate of the velocity value. /// /// \n C++ Type: float /// \n Usd Type: SdfValueTypeNames->Float /// \n Variability: SdfVariabilityVarying /// \n Fallback Value: 24.0 USDAI_API UsdAttribute GetAiVelocityFPSAttr() const; /// See GetAiVelocityFPSAttr(), and also /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. /// If specified, author \p defaultValue as the attribute's default, /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - /// the default for \p writeSparsely is \c false. USDAI_API UsdAttribute CreateAiVelocityFPSAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; public: // --------------------------------------------------------------------- // // AIVELOCITYOUTLIERTHRESHOLD // --------------------------------------------------------------------- // /// Controls the filtering of noisy velocities, which can result in /// faster rendering of motion blur from physics simulations. The /// default value of 0.001 should have little to no visual impact. /// Setting this to zero disables filtering entirely. /// /// \n C++ Type: float /// \n Usd Type: SdfValueTypeNames->Float /// \n Variability: SdfVariabilityVarying /// \n Fallback Value: 0.0010000000475 USDAI_API UsdAttribute GetAiVelocityOutlierThresholdAttr() const; /// See GetAiVelocityOutlierThresholdAttr(), and also /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. /// If specified, author \p defaultValue as the attribute's default, /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - /// the default for \p writeSparsely is \c false. USDAI_API UsdAttribute CreateAiVelocityOutlierThresholdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; public: // ===================================================================== // // Feel free to add custom code below this line, it will be preserved by // the code generator. // // Just remember to: // - Close the class declaration with }; // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE // - Close the include guard with #endif // ===================================================================== // // --(BEGIN CUSTOM CODE)-- }; PXR_NAMESPACE_CLOSE_SCOPE #endif
39.515924
127
0.605658
[ "object", "vector" ]
03c8df648c75302d3b75345b2b2c2cd6f035381d
735
h
C
source/SigmaFunct.h
CavHack/gravitino
9eb2ac36d4881158ee70077405f5a8d173c97982
[ "MIT" ]
null
null
null
source/SigmaFunct.h
CavHack/gravitino
9eb2ac36d4881158ee70077405f5a8d173c97982
[ "MIT" ]
null
null
null
source/SigmaFunct.h
CavHack/gravitino
9eb2ac36d4881158ee70077405f5a8d173c97982
[ "MIT" ]
null
null
null
#ifndef __SIGMAFUNCT_H__ #define __SIGMAFUNCT_H__ #include "common.h" void complementSeqNumbers(char *, char *, uint); void convertNucleotidesToNumbers(const char * R0, char* R1, const uint Lread); uint convertNucleotidesToNumbersRemoveControls(cons char * R0, char *R1, const uint Lread); void revComplementNucleotides(string &seq); char nuclToNumBAM(char cc); void nuclPackBAM(char* ReadsIn, char* ReadsOut, uint Lread); char convertNt01234(const char R0); // transform sequence from ACGT into 0-1-2-3-4 code uint chrFind(uint, uint, uint*); //Find chromosome from global locus uint localSearch(const char *v, uint nx, const char *y, uint ny, double pMM); uint qualitySplit(char*, char*, uint, char, uint, uint, uint**); #endif
36.75
91
0.763265
[ "transform" ]
03cc61b37ae63836c8bae3fc906062c7c3f76f51
9,835
h
C
src/direction.h
thomasp85/euclid
cb7783d5b17680f5e1a9feb18968f9f7471e150e
[ "MIT" ]
68
2020-09-17T13:17:03.000Z
2022-02-20T09:14:54.000Z
src/direction.h
thomasp85/euclid
cb7783d5b17680f5e1a9feb18968f9f7471e150e
[ "MIT" ]
27
2020-09-17T13:35:53.000Z
2022-01-20T09:12:48.000Z
src/direction.h
thomasp85/euclid
cb7783d5b17680f5e1a9feb18968f9f7471e150e
[ "MIT" ]
11
2020-09-17T11:43:37.000Z
2022-01-10T13:08:27.000Z
#pragma once #include <cpp11/strings.hpp> #include <cpp11/doubles.hpp> #include "cgal_types.h" #include "geometry_vector.h" #include "exact_numeric.h" #include "intersection.h" #include "distance.h" class direction2 : public geometry_vector<Direction_2, 2> { public: using geometry_vector::geometry_vector; ~direction2() = default; Primitive geometry_type() const { return DIRECTION; } cpp11::writable::strings def_names() const { return {"dx", "dy"}; } Exact_number get_single_definition(size_t i, int which, int element) const { switch(which) { case 0: return _storage[i].dx(); case 1: return _storage[i].dy(); } return _storage[i].dx(); } std::vector<double> get_row(size_t i, size_t j) const { return { CGAL::to_double(_storage[i].dx().exact()), CGAL::to_double(_storage[i].dy().exact()) }; } cpp11::writable::list intersection(const geometry_vector_base& other) const { cpp11::stop("Don't know how to calculate the intersection of these geometries"); } cpp11::writable::logicals do_intersect(const geometry_vector_base& other) const { if (other.dimensions() != dimensions()) { cpp11::stop("Only geometries of the same dimensionality can intersect"); } return unknown_intersect_impl(std::max(size(), other.size())); } std::vector<Exact_number> squared_distance(const geometry_vector_base& other) const { if (other.dimensions() != dimensions()) { cpp11::stop("Only geometries of the same dimensionality can intersect"); } return unknown_squared_distance_impl(std::max(size(), other.size())); } cpp11::writable::doubles_matrix distance_matrix(const geometry_vector_base& other) const { if (other.dimensions() != dimensions()) { cpp11::stop("Only geometries of the same dimensionality can intersect"); } return unknown_distance_matrix_impl(size(), other.size()); } std::vector<Direction_2> operator-() const { std::vector<Direction_2> result; result.reserve(size()); for (size_t i = 0; i < size(); ++i) { if (!_storage[i]) { result.push_back(Direction_2::NA_value()); continue; } result.push_back(-_storage[i]); } return result; } cpp11::writable::logicals operator<(const std::vector<Direction_2>& other) const { if (size() == 0 || other.size() == 0) { return {}; } size_t final_size = std::max(size(), other.size()); cpp11::writable::logicals result; result.reserve(final_size); for (size_t i = 0; i < final_size; ++i) { if (!_storage[i % size()] || !other[i % other.size()]) { result.push_back(NA_LOGICAL); continue; } result.push_back((Rboolean) (_storage[i % size()] < other[i % other.size()])); } return result; } cpp11::writable::logicals operator>(const std::vector<Direction_2>& other) const { if (size() == 0 || other.size() == 0) { return {}; } size_t final_size = std::max(size(), other.size()); cpp11::writable::logicals result; result.reserve(final_size); for (size_t i = 0; i < final_size; ++i) { if (!_storage[i % size()] || !other[i % other.size()]) { result.push_back(NA_LOGICAL); continue; } result.push_back((Rboolean) (_storage[i % size()] > other[i % other.size()])); } return result; } std::vector<Direction_2> sort(bool decreasing, cpp11::logicals na_last) const { std::vector<Direction_2> result(_storage.begin(), _storage.end()); auto end = std::remove_if(result.begin(), result.end(), [](const Direction_2& x) { return !x.is_valid(); }); int n_na = result.end() - end; result.resize(end - result.begin()); if (decreasing) { std::stable_sort(result.begin(), result.end(), std::greater<Direction_2>()); } else { std::stable_sort(result.begin(), result.end()); } if (cpp11::is_na(na_last[0])) { for (int i = 0; i < n_na; ++i) { result.push_back(Direction_2::NA_value()); } if (n_na > 0 && na_last[0] == FALSE) { std::rotate(result.rbegin(), result.rbegin() + n_na, result.rend()); } } return result; } cpp11::writable::integers rank() const { std::vector< std::pair<Direction_2, size_t> > ranks; ranks.reserve(size()); for (size_t i = 0; i < size(); ++i) { ranks.emplace_back(_storage[i], i); } std::stable_sort(ranks.begin(), ranks.end(), [](const std::pair<Direction_2, size_t>& l, const std::pair<Direction_2, size_t> & r) { if (l.first && r.first) { return l.first < r.first; } else if (l.first) { return true; } return false; }); cpp11::writable::integers result; result.reserve(size()); for (auto iter = ranks.begin(); iter != ranks.end(); ++iter) { result.push_back(iter->second + 1); } return result; } std::vector<Direction_2> min(bool na_rm) const { if (size() == 0) { return {Direction_2::NA_value()}; } Direction_2 minimum = _storage[0]; for (size_t i = 1; i < size(); ++i) { if (!_storage[i]) { if (!na_rm) { minimum = Direction_2::NA_value(); break; } continue; } minimum = _storage[i] < minimum ? _storage[i] : minimum; } return {minimum}; } std::vector<Direction_2> max(bool na_rm) const { if (size() == 0) { return {Direction_2::NA_value()}; } Direction_2 maximum = _storage[0]; for (size_t i = 1; i < size(); ++i) { if (!_storage[i]) { if (!na_rm) { maximum = Direction_2::NA_value(); break; } continue; } maximum = _storage[i] > maximum ? _storage[i] : maximum; } return {maximum}; } std::vector<Direction_2> cummin() const { std::vector<Direction_2> result; result.reserve(size()); if (size() == 0) { return {result}; } Direction_2 cum_min = _storage[0]; result.push_back(cum_min); bool is_na = false; for (size_t i = 1; i < size(); ++i) { if (!is_na && !_storage[i]) { is_na = true; cum_min = Direction_2::NA_value(); } if (!is_na) { cum_min = _storage[i] < cum_min ? _storage[i] : cum_min; } result.push_back(cum_min); } return {result}; } std::vector<Direction_2> cummax() const { std::vector<Direction_2> result; result.reserve(size()); if (size() == 0) { return {result}; } Direction_2 cum_max = _storage[0]; result.push_back(cum_max); bool is_na = false; for (size_t i = 1; i < size(); ++i) { if (!is_na && !_storage[i]) { is_na = true; cum_max = Direction_2::NA_value(); } if (!is_na) { cum_max = _storage[i] < cum_max ? _storage[i] : cum_max; } result.push_back(cum_max); } return {result}; } cpp11::writable::logicals between(const direction2& d1, const direction2& d2) const { if (size() == 0 || d1.size() == 0 || d2.size() == 0) { return {}; } size_t final_size = std::max(std::max(size(), d1.size()), d2.size()); cpp11::writable::logicals result; result.reserve(final_size); for (size_t i = 0; i < final_size; ++i) { if (!_storage[i % size()] || !d1[i % d1.size()] || !d2[i % d2.size()]) { result.push_back(NA_LOGICAL); continue; } result.push_back((Rboolean) _storage[i % size()].counterclockwise_in_between(d1[i % d1.size()], d2[i % d2.size()])); } return result; } }; typedef cpp11::external_pointer<direction2> direction2_p; class direction3 : public geometry_vector<Direction_3, 3, Direction_2> { public: using geometry_vector::geometry_vector; ~direction3() = default; Primitive geometry_type() const { return DIRECTION; } cpp11::writable::strings def_names() const { return {"dx", "dy", "dz"}; } Exact_number get_single_definition(size_t i, int which, int element) const { switch(which) { case 0: return _storage[i].dx(); case 1: return _storage[i].dy(); case 2: return _storage[i].dz(); } return _storage[i].dx(); } std::vector<double> get_row(size_t i, size_t j) const { return { CGAL::to_double(_storage[i].dx().exact()), CGAL::to_double(_storage[i].dy().exact()), CGAL::to_double(_storage[i].dz().exact()) }; } cpp11::writable::list intersection(const geometry_vector_base& other) const { cpp11::stop("Don't know how to calculate the intersection of these geometries"); } cpp11::writable::logicals do_intersect(const geometry_vector_base& other) const { if (other.dimensions() != dimensions()) { cpp11::stop("Only geometries of the same dimensionality can intersect"); } return unknown_intersect_impl(std::max(size(), other.size())); } std::vector<Exact_number> squared_distance(const geometry_vector_base& other) const { if (other.dimensions() != dimensions()) { cpp11::stop("Only geometries of the same dimensionality can intersect"); } return unknown_squared_distance_impl(std::max(size(), other.size())); } cpp11::writable::doubles_matrix distance_matrix(const geometry_vector_base& other) const { if (other.dimensions() != dimensions()) { cpp11::stop("Only geometries of the same dimensionality can intersect"); } return unknown_distance_matrix_impl(size(), other.size()); } std::vector<Direction_3> operator-() const { std::vector<Direction_3> result; result.reserve(size()); for (size_t i = 0; i < size(); ++i) { if (!_storage[i]) { result[i] = Direction_3::NA_value(); continue; } result.push_back(-_storage[i]); } return result; } }; typedef cpp11::external_pointer<direction3> direction3_p;
29.623494
136
0.607931
[ "vector" ]
03d90ea4d3416f9b2819bc0def3bf64af14674f6
2,369
c
C
sjjg/4/4.1/4.1_2.c
D1N910/learn-c
688103eb2c1173bb13a52df92296f979bb97d422
[ "MIT" ]
null
null
null
sjjg/4/4.1/4.1_2.c
D1N910/learn-c
688103eb2c1173bb13a52df92296f979bb97d422
[ "MIT" ]
null
null
null
sjjg/4/4.1/4.1_2.c
D1N910/learn-c
688103eb2c1173bb13a52df92296f979bb97d422
[ "MIT" ]
null
null
null
/** * @file 4.1_2.c 基本操作实现,用方案4 * @author your name (you@domain.com) * @brief * @version 0.1 * @date 2022-04-14 * * @copyright Copyright (c) 2022 * */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #define MAXSIZE 255 // 预定串的长度是 255 // 静态数组实现(定长顺序存储) typedef struct { char ch[MAXSIZE]; // 每个分量存储一个字符,系统会自动回收空间 int length; // 串的实际长度 }SString; /** * @brief 求串长。返回串S的元素个数。 * * @return int */ int StrLength(SString); /** * @brief 清空操作。将S清空为空串。—— 空间还能用 * */ void ClearString(SString *); /** * @brief Construct a new Sub String object * 求子串。用Sub返回串S的第pos个字符起长度为len的子串 * */ _Bool SubString(SString *, SString, int, int); /** * @brief 清空操作。将S清空为空串。—— 空间还能用 * * @return _Bool */ _Bool StrEmpty(SString); /** * @brief 比较操作。若 S>T,则返回值 > 0;若S=T,则返回值=0;如果S < T , 则返回值 < 0。 * */ int StrCompare(SString, SString); /** * @brief 定位操作。若主串S中存在与串T值相同的子串,则返回它在主串S中第一次出现的位置;否则函数为0. * * @return int */ int Index(SString, SString); /** * @brief 赋值操作。把串T赋值为chars * */ _Bool StrAssign(SString *, char[]); int main() { SString S; SString Sub; S.length = 4; S.ch[1] = 'c'; S.ch[2] = 'b'; S.ch[3] = 'd'; S.ch[4] = 'f'; if (SubString(&Sub, S, 3, 1)) { printf("成功地成功了 %c \n", S.ch[2]); printf("成功地成功了 %c \n", Sub.ch[1]); } printf("比较是否相等 %d \n", StrCompare(S, Sub)); printf("获取对应下标 %d \n", Index(S, Sub)); } int StrLength(SString S) { return S.length; } void ClearString(SString * S) { S->length = 0; } _Bool StrEmpty(SString S) { if (S.length == 0) return true; else return false; } _Bool SubString(SString * Sub, SString S, int pos, int len) { // 子串范围越界 if (pos + len - 1 > S.length) { return false; } for (int i = pos;i<= pos + len -1; i++) { Sub->ch[i-pos+1] = S.ch[i]; } Sub->length = len; return true; } int StrCompare(SString S, SString T) { for (int i = 1; i <= S.length && i <= T.length; i++) { if (S.ch[i] != T.ch[i]) return S.ch[i] - T.ch[i]; } return S.length - T.length; } int Index(SString S, SString T) { int i=1, n =StrLength(S), m=StrLength(T); SString Sub; while ( i<=n-m+1) { SubString(&Sub, S, i, m); if (StrCompare(Sub, T) != 0) ++i; else return i; // 返回子串在主串中的位置 } return 0; }
17.548148
61
0.550021
[ "object" ]
03dfd922af88fd1fbc0980e4c1315c38339f3679
2,504
h
C
artifact/storm/src/storm/utility/Engine.h
glatteis/tacas21-artifact
30b4f522bd3bdb4bebccbfae93f19851084a3db5
[ "MIT" ]
null
null
null
artifact/storm/src/storm/utility/Engine.h
glatteis/tacas21-artifact
30b4f522bd3bdb4bebccbfae93f19851084a3db5
[ "MIT" ]
null
null
null
artifact/storm/src/storm/utility/Engine.h
glatteis/tacas21-artifact
30b4f522bd3bdb4bebccbfae93f19851084a3db5
[ "MIT" ]
1
2022-02-05T12:39:53.000Z
2022-02-05T12:39:53.000Z
#pragma once #include <ostream> #include <vector> #include "storm/models/ModelType.h" #include "storm/storage/dd/DdType.h" #include "storm/builder/BuilderType.h" namespace storm { // Forward Declarations namespace jani { class Property; } namespace logic { class Formula; } namespace modelchecker{ template<typename FormulaType, typename ValueType> class CheckTask; } namespace storage { class SymbolicModelDescription; } namespace utility { /// An enumeration of all engines. enum class Engine { // The last one should always be 'Unknown' to make sure that the getEngines() method below works. Sparse, Hybrid, Dd, DdSparse, Jit, Exploration, AbstractionRefinement, Automatic, Unknown }; /*! * Returns a list of all available engines (excluding Unknown) */ std::vector<Engine> getEngines(); /*! * Returns a string representation of the given engine. */ std::string toString(Engine const& engine); /*! * Writes the string representation of the given engine to the given stream */ std::ostream& operator<<(std::ostream& os, Engine const& engine); /*! * Parses the string representation of an engine and returns the corresponding engine. * If the engine is not found, we print an error and return Engine::Unknown. */ Engine engineFromString(std::string const& engineStr); /*! * Returns the builder type used for the given engine. */ storm::builder::BuilderType getBuilderType(storm::utility::Engine const& engine); /*! * Returns false if the given model description and one of the given properties can certainly not be handled by the given engine. * Notice that the set of handable model checking queries is only overapproximated, i.e. if this returns true, * the query could still be not supported by the engine. This behavior is due to the fact that we sometimes need * to actually build the model in order to decide whether it is supported. */ template <typename ValueType> bool canHandle(storm::utility::Engine const& engine, std::vector<storm::jani::Property> const& properties, storm::storage::SymbolicModelDescription const& modelDescription); } }
35.267606
181
0.630591
[ "vector", "model" ]
03e39b24da97663d544777403853026cd573b39e
13,808
h
C
aws-cpp-sdk-datasync/include/aws/datasync/model/PrivateLinkConfig.h
neil-b/aws-sdk-cpp
1602b75abbca880b770c12788f6d2bac0c87176a
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-datasync/include/aws/datasync/model/PrivateLinkConfig.h
neil-b/aws-sdk-cpp
1602b75abbca880b770c12788f6d2bac0c87176a
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-datasync/include/aws/datasync/model/PrivateLinkConfig.h
neil-b/aws-sdk-cpp
1602b75abbca880b770c12788f6d2bac0c87176a
[ "Apache-2.0" ]
1
2020-11-04T03:18:11.000Z
2020-11-04T03:18:11.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/datasync/DataSync_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace DataSync { namespace Model { /** * <p>The VPC endpoint, subnet and security group that an agent uses to access IP * addresses in a VPC (Virtual Private Cloud).</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/datasync-2018-11-09/PrivateLinkConfig">AWS * API Reference</a></p> */ class AWS_DATASYNC_API PrivateLinkConfig { public: PrivateLinkConfig(); PrivateLinkConfig(Aws::Utils::Json::JsonView jsonValue); PrivateLinkConfig& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The ID of the VPC endpoint that is configured for an agent. An agent that is * configured with a VPC endpoint will not be accessible over the public * Internet.</p> */ inline const Aws::String& GetVpcEndpointId() const{ return m_vpcEndpointId; } /** * <p>The ID of the VPC endpoint that is configured for an agent. An agent that is * configured with a VPC endpoint will not be accessible over the public * Internet.</p> */ inline bool VpcEndpointIdHasBeenSet() const { return m_vpcEndpointIdHasBeenSet; } /** * <p>The ID of the VPC endpoint that is configured for an agent. An agent that is * configured with a VPC endpoint will not be accessible over the public * Internet.</p> */ inline void SetVpcEndpointId(const Aws::String& value) { m_vpcEndpointIdHasBeenSet = true; m_vpcEndpointId = value; } /** * <p>The ID of the VPC endpoint that is configured for an agent. An agent that is * configured with a VPC endpoint will not be accessible over the public * Internet.</p> */ inline void SetVpcEndpointId(Aws::String&& value) { m_vpcEndpointIdHasBeenSet = true; m_vpcEndpointId = std::move(value); } /** * <p>The ID of the VPC endpoint that is configured for an agent. An agent that is * configured with a VPC endpoint will not be accessible over the public * Internet.</p> */ inline void SetVpcEndpointId(const char* value) { m_vpcEndpointIdHasBeenSet = true; m_vpcEndpointId.assign(value); } /** * <p>The ID of the VPC endpoint that is configured for an agent. An agent that is * configured with a VPC endpoint will not be accessible over the public * Internet.</p> */ inline PrivateLinkConfig& WithVpcEndpointId(const Aws::String& value) { SetVpcEndpointId(value); return *this;} /** * <p>The ID of the VPC endpoint that is configured for an agent. An agent that is * configured with a VPC endpoint will not be accessible over the public * Internet.</p> */ inline PrivateLinkConfig& WithVpcEndpointId(Aws::String&& value) { SetVpcEndpointId(std::move(value)); return *this;} /** * <p>The ID of the VPC endpoint that is configured for an agent. An agent that is * configured with a VPC endpoint will not be accessible over the public * Internet.</p> */ inline PrivateLinkConfig& WithVpcEndpointId(const char* value) { SetVpcEndpointId(value); return *this;} /** * <p>The private endpoint that is configured for an agent that has access to IP * addresses in a <a * href="https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html">PrivateLink</a>. * An agent that is configured with this endpoint will not be accessible over the * public Internet.</p> */ inline const Aws::String& GetPrivateLinkEndpoint() const{ return m_privateLinkEndpoint; } /** * <p>The private endpoint that is configured for an agent that has access to IP * addresses in a <a * href="https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html">PrivateLink</a>. * An agent that is configured with this endpoint will not be accessible over the * public Internet.</p> */ inline bool PrivateLinkEndpointHasBeenSet() const { return m_privateLinkEndpointHasBeenSet; } /** * <p>The private endpoint that is configured for an agent that has access to IP * addresses in a <a * href="https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html">PrivateLink</a>. * An agent that is configured with this endpoint will not be accessible over the * public Internet.</p> */ inline void SetPrivateLinkEndpoint(const Aws::String& value) { m_privateLinkEndpointHasBeenSet = true; m_privateLinkEndpoint = value; } /** * <p>The private endpoint that is configured for an agent that has access to IP * addresses in a <a * href="https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html">PrivateLink</a>. * An agent that is configured with this endpoint will not be accessible over the * public Internet.</p> */ inline void SetPrivateLinkEndpoint(Aws::String&& value) { m_privateLinkEndpointHasBeenSet = true; m_privateLinkEndpoint = std::move(value); } /** * <p>The private endpoint that is configured for an agent that has access to IP * addresses in a <a * href="https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html">PrivateLink</a>. * An agent that is configured with this endpoint will not be accessible over the * public Internet.</p> */ inline void SetPrivateLinkEndpoint(const char* value) { m_privateLinkEndpointHasBeenSet = true; m_privateLinkEndpoint.assign(value); } /** * <p>The private endpoint that is configured for an agent that has access to IP * addresses in a <a * href="https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html">PrivateLink</a>. * An agent that is configured with this endpoint will not be accessible over the * public Internet.</p> */ inline PrivateLinkConfig& WithPrivateLinkEndpoint(const Aws::String& value) { SetPrivateLinkEndpoint(value); return *this;} /** * <p>The private endpoint that is configured for an agent that has access to IP * addresses in a <a * href="https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html">PrivateLink</a>. * An agent that is configured with this endpoint will not be accessible over the * public Internet.</p> */ inline PrivateLinkConfig& WithPrivateLinkEndpoint(Aws::String&& value) { SetPrivateLinkEndpoint(std::move(value)); return *this;} /** * <p>The private endpoint that is configured for an agent that has access to IP * addresses in a <a * href="https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html">PrivateLink</a>. * An agent that is configured with this endpoint will not be accessible over the * public Internet.</p> */ inline PrivateLinkConfig& WithPrivateLinkEndpoint(const char* value) { SetPrivateLinkEndpoint(value); return *this;} /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline const Aws::Vector<Aws::String>& GetSubnetArns() const{ return m_subnetArns; } /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline bool SubnetArnsHasBeenSet() const { return m_subnetArnsHasBeenSet; } /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline void SetSubnetArns(const Aws::Vector<Aws::String>& value) { m_subnetArnsHasBeenSet = true; m_subnetArns = value; } /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline void SetSubnetArns(Aws::Vector<Aws::String>&& value) { m_subnetArnsHasBeenSet = true; m_subnetArns = std::move(value); } /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline PrivateLinkConfig& WithSubnetArns(const Aws::Vector<Aws::String>& value) { SetSubnetArns(value); return *this;} /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline PrivateLinkConfig& WithSubnetArns(Aws::Vector<Aws::String>&& value) { SetSubnetArns(std::move(value)); return *this;} /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline PrivateLinkConfig& AddSubnetArns(const Aws::String& value) { m_subnetArnsHasBeenSet = true; m_subnetArns.push_back(value); return *this; } /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline PrivateLinkConfig& AddSubnetArns(Aws::String&& value) { m_subnetArnsHasBeenSet = true; m_subnetArns.push_back(std::move(value)); return *this; } /** * <p>The Amazon Resource Names (ARNs) of the subnets that are configured for an * agent activated in a VPC or an agent that has access to a VPC endpoint.</p> */ inline PrivateLinkConfig& AddSubnetArns(const char* value) { m_subnetArnsHasBeenSet = true; m_subnetArns.push_back(value); return *this; } /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline const Aws::Vector<Aws::String>& GetSecurityGroupArns() const{ return m_securityGroupArns; } /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline bool SecurityGroupArnsHasBeenSet() const { return m_securityGroupArnsHasBeenSet; } /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline void SetSecurityGroupArns(const Aws::Vector<Aws::String>& value) { m_securityGroupArnsHasBeenSet = true; m_securityGroupArns = value; } /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline void SetSecurityGroupArns(Aws::Vector<Aws::String>&& value) { m_securityGroupArnsHasBeenSet = true; m_securityGroupArns = std::move(value); } /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline PrivateLinkConfig& WithSecurityGroupArns(const Aws::Vector<Aws::String>& value) { SetSecurityGroupArns(value); return *this;} /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline PrivateLinkConfig& WithSecurityGroupArns(Aws::Vector<Aws::String>&& value) { SetSecurityGroupArns(std::move(value)); return *this;} /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline PrivateLinkConfig& AddSecurityGroupArns(const Aws::String& value) { m_securityGroupArnsHasBeenSet = true; m_securityGroupArns.push_back(value); return *this; } /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline PrivateLinkConfig& AddSecurityGroupArns(Aws::String&& value) { m_securityGroupArnsHasBeenSet = true; m_securityGroupArns.push_back(std::move(value)); return *this; } /** * <p>The Amazon Resource Names (ARNs) of the security groups that are configured * for the EC2 resource that hosts an agent activated in a VPC or an agent that has * access to a VPC endpoint.</p> */ inline PrivateLinkConfig& AddSecurityGroupArns(const char* value) { m_securityGroupArnsHasBeenSet = true; m_securityGroupArns.push_back(value); return *this; } private: Aws::String m_vpcEndpointId; bool m_vpcEndpointIdHasBeenSet; Aws::String m_privateLinkEndpoint; bool m_privateLinkEndpointHasBeenSet; Aws::Vector<Aws::String> m_subnetArns; bool m_subnetArnsHasBeenSet; Aws::Vector<Aws::String> m_securityGroupArns; bool m_securityGroupArnsHasBeenSet; }; } // namespace Model } // namespace DataSync } // namespace Aws
44.831169
176
0.696842
[ "vector", "model" ]
03e3c3661763db3bd814c14386d185c74184ad4c
1,168
h
C
11/debian-10/postgresql-repmgr-11.11.0-15-linux-amd64-debian-10/files/postgresql/include/geos/operation/valid/RepeatedPointRemover.h
molliezhang/radondb-postgresql-kubernetes-1
7a3cbb050eb708a6db209e0effc8e5a4b34a2900
[ "Apache-2.0" ]
57
2020-02-08T17:52:17.000Z
2021-10-14T03:45:09.000Z
11/debian-10/postgresql-repmgr-11.11.0-15-linux-amd64-debian-10/files/postgresql/include/geos/operation/valid/RepeatedPointRemover.h
molliezhang/radondb-postgresql-kubernetes-1
7a3cbb050eb708a6db209e0effc8e5a4b34a2900
[ "Apache-2.0" ]
47
2020-02-12T16:41:40.000Z
2021-09-28T22:27:56.000Z
11/debian-10/postgresql-repmgr-11.11.0-15-linux-amd64-debian-10/files/postgresql/include/geos/operation/valid/RepeatedPointRemover.h
molliezhang/radondb-postgresql-kubernetes-1
7a3cbb050eb708a6db209e0effc8e5a4b34a2900
[ "Apache-2.0" ]
8
2020-03-17T11:18:07.000Z
2021-10-14T03:45:15.000Z
/********************************************************************** * * GEOS - Geometry Engine Open Source * http://geos.osgeo.org * * Copyright (C) 2019 Daniel Baston <dbaston@gmail.com> * * This is free software; you can redistribute and/or modify it under * the terms of the GNU Lesser General Public Licence as published * by the Free Software Foundation. * See the COPYING file for more information. * **********************************************************************/ #ifndef GEOS_OP_VALID_REPEATEDPOINTREMOVER_H #define GEOS_OP_VALID_REPEATEDPOINTREMOVER_H #include <geos/geom/CoordinateArraySequence.h> namespace geos { namespace operation { namespace valid { class GEOS_DLL RepeatedPointRemover { /// \brief /// Returns a new CoordinateSequence being a copy of the input /// with any consecutive equal Coordinate removed. /// /// Equality test is 2D based /// /// Ownership of returned object goes to the caller. /// \param seq /// \return public: static std::unique_ptr<geom::CoordinateArraySequence> removeRepeatedPoints(const geom::CoordinateSequence* seq); }; } } } #endif
27.809524
120
0.625856
[ "geometry", "object" ]
03e528de480ff9f7e78158b0697c47a7b3bedf47
10,188
c
C
enclave/core/linux/threadlocal.c
crisl-ms/openenclave
89689eef3a4409ad1d63d12c0957a8b4455ec776
[ "MIT" ]
null
null
null
enclave/core/linux/threadlocal.c
crisl-ms/openenclave
89689eef3a4409ad1d63d12c0957a8b4455ec776
[ "MIT" ]
null
null
null
enclave/core/linux/threadlocal.c
crisl-ms/openenclave
89689eef3a4409ad1d63d12c0957a8b4455ec776
[ "MIT" ]
null
null
null
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "threadlocal.h" #include <openenclave/bits/safecrt.h> #include <openenclave/enclave.h> #include <openenclave/internal/enclavelibc.h> #include <openenclave/internal/globals.h> #include <openenclave/internal/raise.h> #include <openenclave/internal/utils.h> #include "../td.h" /* **============================================================================== ** ** Thread-Local Storage implementation. ** **============================================================================== */ /** * There are two ways to create thread-local variables: * 1) GNU __thread keyword * This can be applied only to POD types; i.e types that are initialized to * a constant value, and don't have a constructor or destructor. * 2) C++11 thread_local keyword * This can be applied to POD types, as well as to types with constructors * and/or destructors. * * Thread-local variables that are explicitly initialized to constant values are * put in .tdata section. Thread-local variables that are not initialized or * that have complex initializers and/or destructors are put in .tbss section. * E.g: * __thread int v1 = 56; // Put in .tdata * thread_local int v2 = 77; // Put in .tdata * * __thread int v3; // Not initialized. Put in .tbss * thread_local string s("Hello"); // Complex initializer. Put in .tbss * * .tdata section acts as a template for initializing the thread local-storage * of each thread since it contains the initial values of the variables. * * .tbss section just contains total size of the variables in .tbss section. * * In order to initialize the thread-local storage for a thread, the .tdata * section must be copied over to the correct offset from the fs register. * Also the space for .tbss section must be allocated and initialized to zeros. * The typical layout is as follows: * * +----------------------------+ * FS[0] | Self pointer (value of FS) | * +----------------------------+ * FS[-1] | tbss variables | * | This section is zero | * | initialized. Section size | * | is aligned according to | * | alignment specified in elf| * FS[-tbss start offset] +----------------------------+ * | tdata variables | * | The contents of .tdata | * | template is copied here. | * | Section size is aligned | * | according to alignment | * | specified in elf. | * FS[-tdata start offset] +----------------------------+ <- tls data start * * In x86-64, the FS register is used to access thread-local data. * Just like GS[0], FS[0] is a self pointer and must contain the value of FS. * Note that negative indexing is used with FS. Thus the thread-local variables * lie before FS. * * Both .tdata and .tbss sections have alignment. The alignment must be used to * adjust their specified size values. * Consider * __thread char chars[6]; // 6 bytes * __thread int g = 45; // 4 bytes * Assume that g is the first variable in the .tdata section and that * the .tdata section size is 10 bytes and that the alignment is 4 bytes. * Then the aligned size of the section is 12 bytes and the compiler * uses the offset %FS:-12 to access g instead of %FS:-10. * * Note: Both .tdata and .tbss sections can have different alignments. * In such cases, the larger of the alignments is used to align both the * sections. In x86-64, as observed by doing 'objdump -h' on an elf file, all * sections are aligned to a power of two. This implies that the alignment of * one section must be a multiple of the alignment of the other. * * Initializing variables with complex initializers: * Consider * thread_local int x = random(); * int foo() { return x; } * * This variable is put in .tbss section. * At a high-level, the compiler transforms the access of x to call to * a thread-local dynamic initializer of x. * thread_local int x; // Put in .tbss * thread_local bool x_initialized; // Introduced by compiler to keep * // track of x's initialization. * int foo() * { * if (!x_initialized) * dynamic_initializer_for_x(); * return x; * } * The compiler uses an extra thread-local variable to check if x has been * initialized or not. If x has not been initialized, then the initializer * for x is called. With optimizations enabled, many if not all, of * these function calls get inlined and optimized. * * Variables with complex destructors: * Consider * thread_local my_class x; * In the thread-local dynamic initializer for x, immediately after x has been * initialized, a call is made to the ABI function __cxa_thread_atexit: * __cxa_thread_atexit(&my_class::~myclass, &x) * This allows the runtime system to invoke the destructor on the object when * the thread shutsdown. * * Note: * There are different thread-local models (see -ftls-model compiler option) * and the compiler normally emits a call to __tls_get_addr function to * access thread local variables. Since the enclave is linked as the main * executable, the linker performs *guaranteed optimizations* to remove the * calls to __tls_get_addr and to reduce thread-local variable access to simple * FS register offsets. To handle dynamically loaded modules we need to * implement __tls_get_addr. * For complete reference see: Elf Handling for Thread-Local Storage */ static volatile uint64_t _tdata_rva = 0; static volatile uint64_t _tdata_size = 0; static volatile uint64_t _tdata_align = 1; static volatile uint64_t _tbss_size = 0; static volatile uint64_t _tbss_align = 1; /** * Get the address of the FS segment given a thread data object. * Currently FS is assumed to exist one page after the thread data. * This needs to be made more flexible, taking into account the * actual size of the tls data. */ static uint8_t* _get_fs_from_td(td_t* td) { // TODO: Make this flexible uint8_t* fs = (uint8_t*)td + 1 * OE_PAGE_SIZE; return fs; } /** * Return aligned size. */ static uint64_t _get_aligned_size(uint64_t size, uint64_t align) { return align ? oe_round_up_to_multiple(size, align) : size; } /** * Return pointer to start of tls data. * tls-data-start = %FS - (aligned .tdata size + aligned .tbss size) */ static uint8_t* _get_thread_local_data_start(td_t* td) { // Check if this enclave has thread-local data. if (!_tdata_size && !_tbss_size) return NULL; uint8_t* fs = _get_fs_from_td(td); uint64_t alignment = 0; // Alignments must be non-zero. if (!_tdata_align || !_tbss_align) oe_abort(); // Choose the largest of the two alignments to align both the sections. // Assert that one alignment is a multiple of the other. if (_tdata_align >= _tbss_align) { alignment = _tdata_align; if (alignment % _tbss_align) oe_abort(); } else { alignment = _tbss_align; if (alignment % _tdata_align) oe_abort(); } // Alignment must be a power of two. if (alignment & (alignment - 1)) oe_abort(); // Align both the sections. fs -= _get_aligned_size(_tbss_size, alignment); fs -= _get_aligned_size(_tdata_size, alignment); return fs; } /** * Initialize the thread-local section for a given thread. * This must be called immediately after td itself is initialized. */ oe_result_t oe_thread_local_init(td_t* td) { oe_result_t result = OE_FAILURE; uint8_t* tls_start = _get_thread_local_data_start(td); if (td == NULL) OE_RAISE(OE_INVALID_PARAMETER); if (tls_start) { // Fetch the tls data start for the thread. uint8_t* fs = _get_fs_from_td(td); // Set the self pointer. *(void**)fs = fs; uint64_t tls_data_size = (uint64_t)(fs - tls_start); // Initialize the tls data to zero. oe_memset_s(tls_start, tls_data_size, 0, tls_data_size); // Fetch the .tdata template. void* tdata = (uint8_t*)__oe_get_enclave_base() + _tdata_rva; // Copy the template oe_memcpy_s(tls_start, _tdata_size, tdata, _tdata_size); } result = OE_OK; done: return result; } /** * Register a destructor to be called on the given object when the * thread exits. This call is emitted by the compiler. */ void __cxa_thread_atexit(void (*destructor)(void*), void* object) { td_t* td = oe_get_td(); oe_tls_atexit_t item = {destructor, object}; td->num_tls_atexit_functions++; // TODO: What happens if realloc fails? td->tls_atexit_functions = oe_realloc( td->tls_atexit_functions, sizeof(oe_tls_atexit_t) * td->num_tls_atexit_functions); td->tls_atexit_functions[td->num_tls_atexit_functions - 1] = item; } /** * Cleanup the thread-local section for a given thread. * This must be called *before* the td itself is cleaned up. */ oe_result_t oe_thread_local_cleanup(td_t* td) { /* Call tls atexit functions in reverse order*/ if (td->tls_atexit_functions) { for (uint64_t i = td->num_tls_atexit_functions; i > 0; --i) { td->tls_atexit_functions[i - 1].destructor( td->tls_atexit_functions[i - 1].object); } // Free the allocated at exit buffer. oe_free(td->tls_atexit_functions); td->tls_atexit_functions = NULL; td->num_tls_atexit_functions = 0; } /* Clear tls section */ uint8_t* fs = _get_fs_from_td(td); uint8_t* tls_start = _get_thread_local_data_start(td); oe_memset_s(tls_start, (uint64_t)(fs - tls_start), 0, 0); return OE_OK; }
35.873239
80
0.633981
[ "object", "model" ]
03e5313d9a2f00df6ff64d5a551309a949e542cb
504
h
C
src/Shadow.h
cooperhewitt/Planetary
03b152c255d191e3a0f6e90369126b8017ac60c0
[ "BSD-3-Clause" ]
43
2015-02-07T13:30:03.000Z
2021-08-02T02:58:57.000Z
src/Shadow.h
bobwol/Planetary
03b152c255d191e3a0f6e90369126b8017ac60c0
[ "BSD-3-Clause" ]
4
2015-01-04T23:54:22.000Z
2021-05-12T09:56:09.000Z
src/Shadow.h
bobwol/Planetary
03b152c255d191e3a0f6e90369126b8017ac60c0
[ "BSD-3-Clause" ]
23
2015-01-03T10:00:37.000Z
2021-04-16T18:57:52.000Z
// // Shadow.h // Kepler // // Created by Tom Carden on 6/25/11. // Copyright 2013 Smithsonian Institution. All rights reserved. // #include "cinder/Vector.h" #include "cinder/gl/gl.h" class Node; class Shadow { public: Shadow(); ~Shadow(); void setup( Node* node, Node* mParentNode, float camAlpha ); void draw(); private: void buildVerts( ci::Vec3f p1, ci::Vec3f p2, ci::Vec3f p3, ci::Vec3f p4 ); GLfloat *mShadowVerts; GLfloat *mShadowTexCoords; };
16.258065
78
0.630952
[ "vector" ]
03f1422c7c92e9bd6b13ce299f764f43ea3da1d3
1,955
c
C
d/magic/obj/weapons/auppenser_knights.c
facadepapergirl/shadowgate
2b811671c5c85952ed93767753d72fc0d12819d8
[ "MIT" ]
null
null
null
d/magic/obj/weapons/auppenser_knights.c
facadepapergirl/shadowgate
2b811671c5c85952ed93767753d72fc0d12819d8
[ "MIT" ]
null
null
null
d/magic/obj/weapons/auppenser_knights.c
facadepapergirl/shadowgate
2b811671c5c85952ed93767753d72fc0d12819d8
[ "MIT" ]
null
null
null
//Bane Weapon Spell #include <std.h> inherit "/d/magic/obj/weapons/godwpns_knights"; void create() { ::create(); set_name("%^BOLD%^%^CYAN%^Blade of the %^RESET%^"+ "%^ORANGE%^Mind's %^CYAN%^E%^BOLD%^%^CYAN%^y"+ "%^RESET%^%^CYAN%^e%^RESET%^"); set_short("%^BOLD%^%^CYAN%^Blade of the %^RESET%^"+ "%^ORANGE%^Mind's %^CYAN%^E%^BOLD%^%^CYAN%^y"+ "%^RESET%^%^CYAN%^e%^RESET%^"); set_id(({"blade","blade of the mind's eye","sword","weapon"})); set_long( @CYTHERA This smooth and uniform blade has been crafted out of a solid piece of %^BOLD%^%^CYAN%^blue quartz%^RESET%^ crystal. The %^BOLD%^%^CYAN%^blue quartz%^RESET%^ blade has been sharpened to a fine edge. The multiple facets of the quartz crystal reflect and refract the light around, causing the sword to %^BOLD%^glow%^RESET%^. Twin eyes made of %^ORANGE%^bronze%^RESET%^ have been set on either side of the blade, at the base. The pupils of the %^ORANGE%^bronze%^RESET%^ eyes have been left void, letting the %^BOLD%^%^CYAN%^blue quartz%^RESET%^ of the blade shine through. Crafted out of %^ORANGE%^bronze%^RESET%^ the smooth and symmetrical pommel of the blade is left unadorned. CYTHERA ); set_value(0); set_hit((:TO,"hit_func":)); } int hit_func(object targ){ targ = ETO->query_current_attacker(); if(!objectp(ETO)) return 1; if(!objectp(targ)) return 1; if(!random(10)) { tell_object(ETO,"%^BOLD%^%^CYAN%^A bright glow radiates outwards"+ " from deep within the blade as you slash into"+ " "+targ->QCN+"."); tell_object(targ,"%^BOLD%^%^CYAN%^A bright glow raidates "+ "outwards from deep within "+ETO->QCN+"'s"+ " blade as "+ETO->QS+" slashes into you."); tell_room(environment(ETO),"%^BOLD%^%^CYAN%^A bright glow raidates "+ "outwards from deep within "+ETO->QCN+"'s"+ " blade as "+ETO->QS+" slashes into"+ " "+targ->QCN+".",({ETO,targ})); targ->do_damage("torso",random(4)+4); return 1; } }
46.547619
681
0.640409
[ "object", "solid" ]
03f4e8f6463386e22c0fdeb5e0c8de485e889d25
2,712
c
C
render/command.c
mjansson/render_lib
cd6d7b1a6220386f50fdc906a9286e6f52493065
[ "Unlicense" ]
3
2021-09-07T02:27:51.000Z
2022-03-30T18:09:14.000Z
render/command.c
mjansson/render_lib
cd6d7b1a6220386f50fdc906a9286e6f52493065
[ "Unlicense" ]
null
null
null
render/command.c
mjansson/render_lib
cd6d7b1a6220386f50fdc906a9286e6f52493065
[ "Unlicense" ]
null
null
null
/* command.c - Render library - Public Domain - 2014 Mattias Jansson / Rampant Pixels * * This library provides a cross-platform rendering library in C11 providing * basic 2D/3D rendering functionality for projects based on our foundation library. * * The latest source code maintained by Rampant Pixels is always available at * * https://github.com/rampantpixels/render_lib * * The dependent library source code maintained by Rampant Pixels is always available at * * https://github.com/rampantpixels * * This library is put in the public domain; you can redistribute it and/or modify it without any restrictions. * */ #include <foundation/foundation.h> #include <render/render.h> #include <render/internal.h> render_command_t* render_command_allocate(void) { return memory_allocate(HASH_RENDER, sizeof(render_command_t), 0, MEMORY_PERSISTENT); } void render_command_null(render_command_t* command) { command->type = RENDERCOMMAND_INVALID; } void render_command_clear(render_command_t* command, unsigned int buffer_mask, uint32_t color, unsigned int color_mask, float depth, uint32_t stencil) { command->type = RENDERCOMMAND_CLEAR; command->data.clear.buffer_mask = buffer_mask; command->data.clear.color = color; command->data.clear.color_mask = color_mask; command->data.clear.depth = depth; command->data.clear.stencil = stencil; } void render_command_viewport(render_command_t* command, unsigned int x, unsigned int y, unsigned int width, unsigned int height, real min_z, real max_z) { command->type = RENDERCOMMAND_VIEWPORT; command->data.viewport.x = (uint16_t)x; command->data.viewport.y = (uint16_t)y; command->data.viewport.width = (uint16_t)width; command->data.viewport.height = (uint16_t)height; command->data.viewport.min_z = min_z; command->data.viewport.max_z = max_z; } void render_command_render(render_command_t* command, render_primitive_t type, size_t num, render_program_t* program, render_vertexbuffer_t* vertexbuffer, render_indexbuffer_t* indexbuffer, render_parameterbuffer_t* parameterbuffer, render_statebuffer_t* statebuffer) { command->type = RENDERCOMMAND_RENDER_TRIANGLELIST + (type - 1); command->count = (unsigned int)num; command->data.render.program = program; command->data.render.vertexbuffer = vertexbuffer; command->data.render.indexbuffer = indexbuffer; command->data.render.parameterbuffer = parameterbuffer; command->data.render.statebuffer = statebuffer; }
38.742857
111
0.707596
[ "render", "3d" ]
03f8f0efd168001f34aaacfb2c8a15571b8eaa68
1,104
h
C
tests/calculator.h
svenslaggare/termcalc
1bdc4c873003b636ccd73f86400d87808560b822
[ "MIT" ]
4
2019-06-11T11:17:08.000Z
2020-09-18T18:28:37.000Z
tests/calculator.h
svenslaggare/termcalc
1bdc4c873003b636ccd73f86400d87808560b822
[ "MIT" ]
1
2017-11-11T11:32:27.000Z
2017-11-18T08:57:49.000Z
tests/calculator.h
svenslaggare/termcalc
1bdc4c873003b636ccd73f86400d87808560b822
[ "MIT" ]
null
null
null
#include <string> #include <vector> #include <cxxtest/TestSuite.h> #include "../src/calculator.h" class CalculatorTestSuite : public CxxTest::TestSuite { public: void testPrintInBase() { std::stringstream stream; Calculator calculator(stream); calculator.setEvalMode(ResultValueType::INTEGER); calculator.setPrintNumBase(16); calculator.execute("4251"); TS_ASSERT_EQUALS(stream.str(), "0x109b\n"); stream.str(""); calculator.setPrintNumBase(2); calculator.execute("4251"); TS_ASSERT_EQUALS(stream.str(), "0b1000010011011\n"); } void testToLargeForInt() { std::stringstream stream; Calculator calculator(stream); calculator.setEvalMode(ResultValueType::INTEGER); calculator.execute("54645345364563453534654646"); TS_ASSERT_EQUALS(stream.str(), "Error: The given number is too large.\n"); } void testPrintInPolar() { std::stringstream stream; Calculator calculator(stream); calculator.setEvalMode(ResultValueType::COMPLEX); calculator.setPrintInPolar(true); calculator.execute("2+4i"); TS_ASSERT_EQUALS(stream.str(), "4.47214 * e^(1.10715i)\n"); } };
26.285714
76
0.740036
[ "vector" ]
83be626ca46e216f10da80bf7991043ebccdae38
10,720
h
C
win32-OpenGL/Math/Mtx44.h
Peanoquio/fuzzy-logic-demo
100a64094adb2d5274c32761ed4ede15b912dd90
[ "MIT" ]
null
null
null
win32-OpenGL/Math/Mtx44.h
Peanoquio/fuzzy-logic-demo
100a64094adb2d5274c32761ed4ede15b912dd90
[ "MIT" ]
null
null
null
win32-OpenGL/Math/Mtx44.h
Peanoquio/fuzzy-logic-demo
100a64094adb2d5274c32761ed4ede15b912dd90
[ "MIT" ]
null
null
null
/******************************************************************************/ /*! \file Mtx44.cpp \author Oliver Ryan Chong \par email: oliver.chong\@digipen.edu \par oliver.chong 900863 \par Course: CS1250 \par Project #01 \date 12/12/2011 \brief Implementation file for a 4 by 4 matrix that has the following functions: Default Constructor Copy Constructor Constructor that takes 16 floats A function called SetColumns that takes in three vectors that will be the columns of the matrix. A function called SetRows that takes three vectors that will be the rows of the matrix. A function called GetRow that takes a row number and returns a vector. A function called GetColumn that takes a column number and returns a vector. A function called SetRow, that takes a row number and a vector4. A function called SetColumn that takes a column number and a vector4 A function called SetToIdentity that sets this matrix as an identity matrix. A function called Transpose that sets this matrix to its transpose. A function called SetToZero that sets all of the values to zero A function called GetTranspose that Returns a matrix that is the transpose of this matrix. A function called GetElement that takes a row and a column and returns the value. A function called SetElement that takes a row a column and a value and sets that element to the value. Operator* for two Mtx44 classes. Operator*= for two Mtx44 classes. Operator* for a Matrix and a vector. Operator= for the matrix class Operator* for a scalar and a matrix. A function called SetToRotation that takes an angle in radians and sets this matrix to the rotation matrix. A function called SetToRotationDegrees that takes an angle in degrees and sets this matrix to the rotation matrix. A function called SetToScale that takes a scale value x, y and z and makes this matrix the scale matrix. A function called SetToTranslation that takes an x, y and z value and sets this matrix to the translation matrix. projection transformations A function called Ortho that sets this matrix to the orthographic projection matrix. A function called GetOrtho that returns an orthographic projection matrix A function called Frustum that sets this matrix to the asymmetric frustum projection matrix. A function called GetFrustum that returns an asymmetric frustum projection matrix A function called Perspective that sets this matrix to the symmetric perspective projection matrix. A function called GetPerspective that returns an symmetric perspective projection matrix rotation along general axis A function called SetGeneralRotationAxis that does a rotation along general axis in radians A function called SetGeneralRotationAxisDegrees that does a rotation along general axis in degrees Copyright (C) 2011 DigiPen Institute of Technology Singapore */ /******************************************************************************/ //////////////////////////////////////////////////////////////////////////////// #ifndef MTX_44_H #define MTX_44_H //////////////////////////////////////////////////////////////////////////////// #include "Vector4.h" static const int MAX_ROW = 4; static const int MAX_COL = 4; namespace Math { class Mtx44 { public: //default constructor Mtx44 (void); //constructor Mtx44 (const float a, const float b, const float c, const float d, const float e, const float f, const float g, const float h, const float i, const float j, const float k, const float l, const float m, const float n, const float o, const float p); //operator overload //Operator* for two Mtx44 classes. Mtx44 operator* (const Mtx44& rhsMatrix) const; //Operator* for a Matrix and a vector. Vector4 operator* (const Vector4& vectorVal) const; //Operator* for a scalar and a matrix. Mtx44 operator* (const float factor) const; //Operator*= for two Mtx44 classes. Mtx44& operator*= (const Mtx44 rhsMatrix); //Operator= for the matrix class Mtx44& operator= (const Mtx44 rhsMatrix); //Operator!= for the matrix class bool operator!= (const Mtx44 rhsMatrix) const; //Operator== for the matrix class bool operator== (const Mtx44 rhsMatrix) const; //methods //A function called SetColumns that takes in three vectors that will be the columns of the matrix. void SetColumns (const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4); //A function called SetRows that takes three vectors that will be the rows of the matrix. void SetRows (const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4); //A function called GetRow that takes a row number and returns a vector. Vector4 GetRow (const int rowNum) const; //A function called GetColumn that takes a column number and returns a vector. Vector4 GetColumn (const int colNum) const; //A function called SetRow, that takes a row number and a vector4. void SetRow (const int rowNum, const Vector4& vectorVal); //A function called SetColumn that takes a column number and a vector4 void SetColumn (const int colNum, const Vector4& vectorVal); //A function called SetToIdentity that sets this matrix as an identity matrix. void SetToIdentity (void); //A function called SetToZero that sets all of the values to zero void SetToZero (void); //A function called Transpose that sets this matrix to its transpose. void Transpose (void); //A function called Inverse that sets this matrix to its inverse. //void Inverse (void); //A function called GetDeterminant that returns the determinant of this matrix. //float GetDeterminant (void) const; //A function called GetAdjugate that returns a matrix that is the adjugate of this matrix //Mtx44 GetAdjugate (void) const; //A function called GetInverse that returns a matrix that is the inverse of this matrix. //Mtx44 GetInverse (void) const; //A function called GetTranspose that Returns a matrix that is the transpose of this matrix. Mtx44 GetTranspose (void) const; //A function called GetElement that takes a row and a column and returns the value. float GetElement (unsigned rowVal, unsigned colVal) const; //A function called SetElement that takes a row a column and a value and sets that element to the value. void SetElement (unsigned rowVal, unsigned colVal, float elementVal); //A function called SetToRotationX that takes an angle in radians and sets this matrix to the rotation matrix. void SetToRotationX (const float radianValue); //A function called SetToRotationDegreesX that takes an angle in degrees and sets this matrix to the rotation matrix. void SetToRotationDegreesX (const float degreeValue); //A function called SetToRotationY that takes an angle in radians and sets this matrix to the rotation matrix. void SetToRotationY (const float radianValue); //A function called SetToRotationDegreesY that takes an angle in degrees and sets this matrix to the rotation matrix. void SetToRotationDegreesY (const float degreeValue); //A function called SetToRotationZ that takes an angle in radians and sets this matrix to the rotation matrix. void SetToRotationZ (const float radianValue); //A function called SetToRotationDegreesZ that takes an angle in degrees and sets this matrix to the rotation matrix. void SetToRotationDegreesZ (const float degreeValue); //A function called SetToScale that takes a scale value x, y and z and makes this matrix the scale matrix. void SetToScale (const float xVal, const float yVal, const float zVal); //A function called SetToTranslation that takes an x, y and z value and sets this matrix to the translation matrix. void SetToTranslation (const float xTransVal, const float yTransVal, const float zTransVal); //custom method //A function called CopyArray that copies the contents of a source array into the destination array void CopyArray (const float* sourceArray, float* destinationArray, const unsigned arrSize) const; //This method is used to validate if the values of the two matrices are different bool IsMatrixDifferent(const Mtx44& rhsMatrix) const; //A function called GetSubMatrix that populates an array only with the matrix values found in rows and columns that are not excluded //void GetSubMatrix (const unsigned ignoreRowVal, const unsigned ignoreColVal, float* floatArr, const unsigned arrSize) const; //projection transformations //A function called Ortho that sets this matrix to the orthographic projection matrix. void Ortho (const float left, const float right, const float bottom, const float top, const float nearVal, const float farVal); //A function called GetOrtho that returns an orthographic projection matrix Mtx44 GetOrtho (const float left, const float right, const float bottom, const float top, const float nearVal, const float farVal) const; //A function called Frustum that sets this matrix to the asymmetric frustum projection matrix. void Frustum (const float left, const float right, const float bottom, const float top, const float nearVal, const float farVal); //A function called GetFrustum that returns an asymmetric frustum projection matrix Mtx44 GetFrustum (const float left, const float right, const float bottom, const float top, const float nearVal, const float farVal) const; //A function called Perspective that sets this matrix to the symmetric perspective projection matrix. void Perspective (const float fieldOfView, const float aspectRatio, const float nearVal, const float farVal); //A function called GetPerspective that returns an symmetric perspective projection matrix Mtx44 GetPerspective (const float fieldOfView, const float aspectRatio, const float nearVal, const float farVal) const; //rotation along general axis //A function called SetGeneralRotationAxis that does a rotation along general axis in radians void SetGeneralRotationAxis ( const float radianValue, const Vector4 & rotationAxis ); //A function called SetGeneralRotationAxisDegrees that does a rotation along general axis in degrees void SetGeneralRotationAxisDegrees ( const float degreeValue, const Vector4 & rotationAxis ); //set the planar reflection matrix void SetPlanarReflection ( const Vector4& reflectorVertex, const Vector4& vectorPerpToPlane ); const float * GetMatrixArr (void) const; private: float m_matrixArr[MAX_ROW * MAX_COL]; }; //non-class methods //Operator* for a scalar and a matrix. Mtx44 operator* (const float factor, Mtx44& rhsMatrix); //Operator* for a vector and a matrix. Vector4 operator* (const Vector4& vectorVal, const Mtx44& rhsMatrix); }//end namespace Math #endif //MTX_44_H ////////////////////////////////////////////////////////////////////////////////
51.047619
141
0.749907
[ "vector" ]
83c2c073d45bf70cebcba840403fd7c0e1461e72
1,343
h
C
Tools/LayoutEditor/WidgetsWindow.h
lmj0591/mygui
311fb9d07089f64558eb7f77e9b37c4cb91e3559
[ "MIT" ]
590
2015-01-06T09:22:06.000Z
2022-03-21T18:23:02.000Z
Tools/LayoutEditor/WidgetsWindow.h
lmj0591/mygui
311fb9d07089f64558eb7f77e9b37c4cb91e3559
[ "MIT" ]
159
2015-01-07T03:34:23.000Z
2022-02-21T21:28:51.000Z
Tools/LayoutEditor/WidgetsWindow.h
lmj0591/mygui
311fb9d07089f64558eb7f77e9b37c4cb91e3559
[ "MIT" ]
212
2015-01-05T07:33:33.000Z
2022-03-28T22:11:51.000Z
/*! @file @author Georgiy Evmenov @date 09/2008 */ #ifndef _ae329786_acd2_4c09_ab3b_73baa2294a60_ #define _ae329786_acd2_4c09_ab3b_73baa2294a60_ #include "BaseLayout/BaseLayout.h" #include "EditorToolTip.h" namespace tools { class WidgetsWindow : public wraps::BaseLayout { public: WidgetsWindow(MyGUI::Widget* _parent = nullptr); ~WidgetsWindow() override; private: void requestCreateWidgetItem(MyGUI::ItemBox* _sender, MyGUI::Widget* _item); void requestCoordItem(MyGUI::ItemBox* _sender, MyGUI::IntCoord& _coord, bool _drag); void requestDrawItem(MyGUI::ItemBox* _sender, MyGUI::Widget* _item, const MyGUI::IBDrawItemInfo& _info); void notifyToolTip(MyGUI::Widget* _sender, const MyGUI::ToolTipInfo& _info); void notifySelectWidgetType(MyGUI::Widget* _sender); void notifyChangeCreatorMode(bool _modeCreate); void notifyMouseButtonClickPopupMode(MyGUI::Widget* _sender); void initialise(); SkinInfo getCellData(MyGUI::Widget* _widget); bool getCellSelected(MyGUI::Widget* _widget); private: MyGUI::TabControl* mTabSkins; MyGUI::Button* mPopupMode; int mWidgetsButtonWidth; int mWidgetsButtonHeight; int mWidgetsButtonOffset; std::string mSkinSheetName; std::string mButtonSkinName; typedef std::vector<MyGUI::ItemBox*> VectorItemBox; VectorItemBox mItemBoxs; }; } #endif
23.982143
106
0.767684
[ "vector" ]
83c449e689c93c300a67364783512bc284dc083b
2,081
c
C
d/hengyang/npc/feiyan.c
afeizh/mud
3a605483a38dd215e477d340c3f12387b9372fbe
[ "MIT" ]
null
null
null
d/hengyang/npc/feiyan.c
afeizh/mud
3a605483a38dd215e477d340c3f12387b9372fbe
[ "MIT" ]
null
null
null
d/hengyang/npc/feiyan.c
afeizh/mud
3a605483a38dd215e477d340c3f12387b9372fbe
[ "MIT" ]
null
null
null
#include <ansi.h> inherit NPC; inherit F_DEALER; void create() { set_name("绯胭", ({ "fei yan", "fei", "yan" })); set("nickname", HIM "八音狐仙" NOR); set("title", "老板娘"); set("long", @LONG 绯胭原本在青楼以卖唱为生,因为被逼无奈,误杀县老 爷的公子,险被处死,后来据说她被狐仙所救,从此隐 姓埋名,做起这乐器的买卖。还有的说她本身就是狐仙 所化,又由于她的一曲《恋八音》,所以人人都称她为 「八音狐仙」。 LONG); set("shen_type", 1); set("gender", "女性"); set("age", 25); set("per", 28); set_skill("unarmed", 200); set_skill("dodge", 200); set_temp("apply/damage", 25); set("combat_exp", 800000); set("no_get", "1"); set("attitude", "friendly"); set("vendor_goods", ({ "/d/hengyang/yueqi/shixuanqin-zhanguo", "/d/hengyang/yueqi/jiuxiaoqin", "/d/hengyang/yueqi/zhongnishi", "/d/hengyang/yueqi/jiaoyeqin", "/d/hengyang/yueqi/qin-jueyin", "/d/hengyang/yueqi/qin-konggu", "/d/hengyang/yueqi/qin-jimo", "/d/hengyang/yueqi/qin-tianlai", "/d/hengyang/yueqi/huqin", "/d/hengyang/yueqi/zhuxiao", "/d/hengyang/yueqi/honghuqin", "/d/hengyang/yueqi/zhuxiao-youlan", "/d/hengyang/yueqi/zhuxiao-shuiyun", "/d/hengyang/yueqi/zhuxiao-liuquan", "/d/hengyang/yueqi/zhuxiao-qingyin", "/d/hengyang/yueqi/yuepu-book", "/d/hengyang/yueqi/yueqi-book", "/d/hengyang/yueqi/huxian-book", })); set("inquiry", ([ "杜凤鄂" : "杜公子,他还好吗?\n", ])); setup(); carry_object("/d/hengyang/npc/obj/female-shoe")->wear(); carry_object("/d/hengyang/npc/obj/female1")->wear(); } void init() { object ob; ob = this_player(); ::init(); if (interactive(ob) && ! is_fighting()) { remove_call_out("greeting"); call_out("greeting", 2, ob); } add_action("do_buy", "buy"); add_action("do_list", "list"); } void greeting(object ob) { if (! ob || environment(ob) != environment()) return; say(CYN "绯胭笑着说道:这位" + RANK_D->query_respect(ob)+ "这里" "各种乐器应有尽有,请随便看看。\n" NOR); return; }
24.77381
64
0.558385
[ "object" ]
83c5a9174403f6a9c4a36f457098f0db5f4cb2df
4,390
h
C
CondTools/BTau/test/BTagCalibrationStandalone.h
ckamtsikis/cmssw
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
[ "Apache-2.0" ]
852
2015-01-11T21:03:51.000Z
2022-03-25T21:14:00.000Z
CondTools/BTau/test/BTagCalibrationStandalone.h
ckamtsikis/cmssw
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
[ "Apache-2.0" ]
30,371
2015-01-02T00:14:40.000Z
2022-03-31T23:26:05.000Z
CondTools/BTau/test/BTagCalibrationStandalone.h
ckamtsikis/cmssw
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
[ "Apache-2.0" ]
3,240
2015-01-02T05:53:18.000Z
2022-03-31T17:24:21.000Z
#ifndef BTagEntry_H #define BTagEntry_H /** * * BTagEntry * * Represents one pt- or discriminator-dependent calibration function. * * measurement_type: e.g. comb, ttbar, di-mu, boosted, ... * sys_type: e.g. central, plus, minus, plus_JEC, plus_JER, ... * * Everything is converted into a function, as it is easiest to store it in a * txt or json file. * ************************************************************/ #include <string> #include <TF1.h> #include <TH1.h> class BTagEntry { public: enum OperatingPoint { OP_LOOSE=0, OP_MEDIUM=1, OP_TIGHT=2, OP_RESHAPING=3, }; enum JetFlavor { FLAV_B=0, FLAV_C=1, FLAV_UDSG=2, }; struct Parameters { OperatingPoint operatingPoint; std::string measurementType; std::string sysType; JetFlavor jetFlavor; float etaMin; float etaMax; float ptMin; float ptMax; float discrMin; float discrMax; // default constructor Parameters( OperatingPoint op=OP_TIGHT, std::string measurement_type="comb", std::string sys_type="central", JetFlavor jf=FLAV_B, float eta_min=-99999., float eta_max=99999., float pt_min=0., float pt_max=99999., float discr_min=0., float discr_max=99999. ); }; BTagEntry() {} BTagEntry(const std::string &csvLine); BTagEntry(const std::string &func, Parameters p); BTagEntry(const TF1* func, Parameters p); BTagEntry(const TH1* histo, Parameters p); ~BTagEntry() {} static std::string makeCSVHeader(); std::string makeCSVLine() const; static std::string trimStr(std::string str); // public, no getters needed std::string formula; Parameters params; }; #endif // BTagEntry_H #ifndef BTagCalibration_H #define BTagCalibration_H /** * BTagCalibration * * The 'hierarchy' of stored information is this: * - by tagger (BTagCalibration) * - by operating point or reshape bin * - by jet parton flavor * - by type of measurement * - by systematic * - by eta bin * - as 1D-function dependent of pt or discriminant * ************************************************************/ #include <map> #include <vector> #include <string> #include <istream> #include <ostream> class BTagCalibration { public: BTagCalibration() {} BTagCalibration(const std::string &tagger); BTagCalibration(const std::string &tagger, const std::string &filename); ~BTagCalibration() {} std::string tagger() const {return tagger_;} void addEntry(const BTagEntry &entry); const std::vector<BTagEntry>& getEntries(const BTagEntry::Parameters &par) const; void readCSV(std::istream &s); void readCSV(const std::string &s); void makeCSV(std::ostream &s) const; std::string makeCSV() const; protected: static std::string token(const BTagEntry::Parameters &par); std::string tagger_; std::map<std::string, std::vector<BTagEntry> > data_; }; #endif // BTagCalibration_H #ifndef BTagCalibrationReader_H #define BTagCalibrationReader_H /** * BTagCalibrationReader * * Helper class to pull out a specific set of BTagEntry's out of a * BTagCalibration. TF1 functions are set up at initialization time. * ************************************************************/ #include <memory> #include <string> class BTagCalibrationReader { public: class BTagCalibrationReaderImpl; BTagCalibrationReader() {} BTagCalibrationReader(BTagEntry::OperatingPoint op, const std::string & sysType="central", const std::vector<std::string> & otherSysTypes={}); void load(const BTagCalibration & c, BTagEntry::JetFlavor jf, const std::string & measurementType="comb"); double eval(BTagEntry::JetFlavor jf, float eta, float pt, float discr=0.) const; double eval_auto_bounds(const std::string & sys, BTagEntry::JetFlavor jf, float eta, float pt, float discr=0.) const; std::pair<float, float> min_max_pt(BTagEntry::JetFlavor jf, float eta, float discr=0.) const; protected: std::shared_ptr<BTagCalibrationReaderImpl> pimpl; }; #endif // BTagCalibrationReader_H
23.227513
83
0.614806
[ "vector" ]
83c5d95fe539602bda647a8fe8b453766535896f
7,658
h
C
communication/ComInterpNodes3D.h
smarkidis/iPIC3D-serial
cf4429232d8a8d26c373c18c855ff1e1ebbd726b
[ "Apache-2.0" ]
1
2020-10-15T01:35:50.000Z
2020-10-15T01:35:50.000Z
communication/ComInterpNodes3D.h
smarkidis/iPIC3D-serial
cf4429232d8a8d26c373c18c855ff1e1ebbd726b
[ "Apache-2.0" ]
null
null
null
communication/ComInterpNodes3D.h
smarkidis/iPIC3D-serial
cf4429232d8a8d26c373c18c855ff1e1ebbd726b
[ "Apache-2.0" ]
1
2019-11-04T17:05:11.000Z
2019-11-04T17:05:11.000Z
#ifndef ComInterpNodes_H #define ComInterpNodes_H #include "ComBasic3D.h" /** communicate ghost cells and sum the contribution with a index indicating the number of species*/ inline void communicateInterp(int nx, int ny, int nz, int ns, double ****vector, int bcFaceXright, int bcFaceXleft, int bcFaceYright, int bcFaceYleft,int bcFaceZright,int bcFaceZleft, VirtualTopology3D *vct){ // allocate 6 ghost cell Faces double *ghostXrightFace = new double[(ny-2)*(nz-2)]; double *ghostXleftFace = new double[(ny-2)*(nz-2)]; double *ghostYrightFace = new double[(nx-2)*(nz-2)]; double *ghostYleftFace = new double[(nx-2)*(nz-2)]; double *ghostZrightFace = new double[(nx-2)*(ny-2)]; double *ghostZleftFace = new double[(nx-2)*(ny-2)]; // allocate 12 ghost cell Edges // X EDGE double *ghostXsameYleftZleftEdge = new double[nx-2]; double *ghostXsameYrightZleftEdge = new double[nx-2]; double *ghostXsameYleftZrightEdge = new double[nx-2]; double *ghostXsameYrightZrightEdge = new double[nx-2]; // Y EDGE double *ghostXrightYsameZleftEdge = new double[ny-2]; double *ghostXleftYsameZleftEdge = new double[ny-2]; double *ghostXrightYsameZrightEdge = new double[ny-2]; double *ghostXleftYsameZrightEdge = new double[ny-2]; // Z EDGE double *ghostXrightYleftZsameEdge = new double[nz-2]; double *ghostXrightYrightZsameEdge = new double[nz-2]; double *ghostXleftYleftZsameEdge = new double[nz-2]; double *ghostXleftYrightZsameEdge = new double[nz-2]; // allocate 8 ghost cell corner double ghostXrightYrightZrightCorner,ghostXleftYrightZrightCorner,ghostXrightYleftZrightCorner,ghostXleftYleftZrightCorner; double ghostXrightYrightZleftCorner, ghostXleftYrightZleftCorner, ghostXrightYleftZleftCorner, ghostXleftYleftZleftCorner; // apply boundary condition to 6 Ghost Faces and communicate if necessary to 6 processors: along 3 DIRECTIONS makeCenterFace(nx,ny,nz,vector,ns,ghostXrightFace,ghostXleftFace,ghostYrightFace,ghostYleftFace,ghostZrightFace,ghostZleftFace); //communication communicateGhostFace((ny-2)*(nz-2),vct->getCartesian_rank(),vct->getXright_neighbor_P(),vct->getXleft_neighbor_P(),0,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostXrightFace, ghostXleftFace); communicateGhostFace((nx-2)*(nz-2),vct->getCartesian_rank(),vct->getYright_neighbor_P(),vct->getYleft_neighbor_P(),1,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostYrightFace, ghostYleftFace); communicateGhostFace((nx-2)*(ny-2),vct->getCartesian_rank(),vct->getZright_neighbor_P(),vct->getZleft_neighbor_P(),2,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostZrightFace, ghostZleftFace); addFace(nx,ny,nz,vector,ns,ghostXrightFace,ghostXleftFace,ghostYrightFace,ghostYleftFace,ghostZrightFace,ghostZleftFace,vct); /** prepare ghost cell Edge Y for communication: these are communicate: these are communicated in X direction */ makeNodeEdgeY(nx,ny,nz,ghostZleftFace,ghostZrightFace,ghostXrightYsameZrightEdge,ghostXleftYsameZleftEdge,ghostXleftYsameZrightEdge,ghostXrightYsameZleftEdge); /** prepare ghost cell Edge Z for communication: these are communicated in Y direction */ makeNodeEdgeZ(nx,ny,nz,ghostXleftFace,ghostXrightFace,ghostXrightYrightZsameEdge,ghostXleftYleftZsameEdge,ghostXrightYleftZsameEdge,ghostXleftYrightZsameEdge); /** prepare ghost cell Edge X for communication: these are communicated in Z direction*/ makeNodeEdgeX(nx,ny,nz,ghostYleftFace,ghostYrightFace,ghostXsameYrightZrightEdge,ghostXsameYleftZleftEdge,ghostXsameYleftZrightEdge,ghostXsameYrightZleftEdge); // communicate twice each direction // X-DIRECTION: Z -> X -> Y //; communicateGhostFace(ny-2,vct->getCartesian_rank(),vct->getXright_neighbor_P(),vct->getXleft_neighbor_P(),0,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostXrightYsameZleftEdge,ghostXleftYsameZleftEdge); communicateGhostFace(ny-2,vct->getCartesian_rank(),vct->getXright_neighbor_P(),vct->getXleft_neighbor_P(),0,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostXrightYsameZrightEdge,ghostXleftYsameZrightEdge); // Y-DIRECTION: X -> Y -> Z //; communicateGhostFace(nz-2,vct->getCartesian_rank(),vct->getYright_neighbor_P(),vct->getYleft_neighbor_P(),1,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostXleftYrightZsameEdge,ghostXleftYleftZsameEdge); communicateGhostFace(nz-2,vct->getCartesian_rank(),vct->getYright_neighbor_P(),vct->getYleft_neighbor_P(),1,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostXrightYrightZsameEdge,ghostXrightYleftZsameEdge); // Z-DIRECTION: Y -> Z //; communicateGhostFace(nx-2,vct->getCartesian_rank(),vct->getZright_neighbor_P(),vct->getZleft_neighbor_P(),2,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostXsameYleftZrightEdge,ghostXsameYleftZleftEdge); communicateGhostFace(nx-2,vct->getCartesian_rank(),vct->getZright_neighbor_P(),vct->getZleft_neighbor_P(),2,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),ghostXsameYrightZrightEdge,ghostXsameYrightZleftEdge); //parse //; addEdgeZ(nx,ny,nz,vector,ns,ghostXrightYrightZsameEdge,ghostXleftYleftZsameEdge,ghostXrightYleftZsameEdge,ghostXleftYrightZsameEdge,vct); addEdgeY(nx,ny,nz,vector,ns,ghostXrightYsameZrightEdge,ghostXleftYsameZleftEdge,ghostXleftYsameZrightEdge,ghostXrightYsameZleftEdge,vct); addEdgeX(nx,ny,nz,vector,ns,ghostXsameYrightZrightEdge,ghostXsameYleftZleftEdge,ghostXsameYleftZrightEdge,ghostXsameYrightZleftEdge,vct); makeNodeCorner(nx,ny,nz,ghostXsameYrightZrightEdge,ghostXsameYleftZleftEdge,ghostXsameYleftZrightEdge,ghostXsameYrightZleftEdge,&ghostXrightYrightZrightCorner,&ghostXleftYrightZrightCorner,&ghostXrightYleftZrightCorner,&ghostXleftYleftZrightCorner,&ghostXrightYrightZleftCorner,&ghostXleftYrightZleftCorner,&ghostXrightYleftZleftCorner,&ghostXleftYleftZleftCorner); // communicate only in the X-DIRECTION communicateGhostFace(1,vct->getCartesian_rank(),vct->getXright_neighbor_P(),vct->getXleft_neighbor_P(),0,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),&ghostXrightYrightZrightCorner,&ghostXleftYrightZrightCorner); communicateGhostFace(1,vct->getCartesian_rank(),vct->getXright_neighbor_P(),vct->getXleft_neighbor_P(),0,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),&ghostXrightYleftZrightCorner,&ghostXleftYleftZrightCorner); communicateGhostFace(1,vct->getCartesian_rank(),vct->getXright_neighbor_P(),vct->getXleft_neighbor_P(),0,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),&ghostXrightYleftZleftCorner,&ghostXleftYleftZleftCorner); communicateGhostFace(1,vct->getCartesian_rank(),vct->getXright_neighbor_P(),vct->getXleft_neighbor_P(),0,vct->getXLEN(),vct->getYLEN(),vct->getZLEN(),&ghostXrightYrightZleftCorner,&ghostXleftYrightZleftCorner); // parse addCorner(nx,ny,nz,vector,ns,&ghostXrightYrightZrightCorner,&ghostXleftYrightZrightCorner,&ghostXrightYleftZrightCorner,&ghostXleftYleftZrightCorner,&ghostXrightYrightZleftCorner,&ghostXleftYrightZleftCorner,&ghostXrightYleftZleftCorner,&ghostXleftYleftZleftCorner,vct); delete[] ghostXrightFace; delete[] ghostXleftFace; delete[] ghostYrightFace; delete[] ghostYleftFace; delete[] ghostZrightFace; delete[] ghostZleftFace; // X EDGE delete[] ghostXsameYleftZleftEdge; delete[]ghostXsameYrightZleftEdge; delete[] ghostXsameYleftZrightEdge; delete[] ghostXsameYrightZrightEdge; // Y EDGE delete[] ghostXrightYsameZleftEdge; delete[] ghostXleftYsameZleftEdge; delete[] ghostXrightYsameZrightEdge; delete[] ghostXleftYsameZrightEdge; // Z EDGE delete[] ghostXrightYleftZsameEdge; delete[] ghostXrightYrightZsameEdge; delete[] ghostXleftYleftZsameEdge; delete[] ghostXleftYrightZsameEdge; } #endif
65.452991
367
0.795377
[ "vector" ]
83cda9d49309cf82dbcb03a2e1e83432d257d2d1
2,340
h
C
pandatool/src/softegg/softNodeTree.h
kestred/panda3d
16bfd3750f726a8831771b81649d18d087917fd5
[ "PHP-3.01", "PHP-3.0" ]
3
2018-03-09T12:07:29.000Z
2021-02-25T06:50:25.000Z
pandatool/src/softegg/softNodeTree.h
Sinkay/panda3d
16bfd3750f726a8831771b81649d18d087917fd5
[ "PHP-3.01", "PHP-3.0" ]
null
null
null
pandatool/src/softegg/softNodeTree.h
Sinkay/panda3d
16bfd3750f726a8831771b81649d18d087917fd5
[ "PHP-3.01", "PHP-3.0" ]
null
null
null
// Filename: softNodeTree.h // Created by: masad (03Oct03) // //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE // Copyright (c) Carnegie Mellon University. All rights reserved. // // All use of this software is subject to the terms of the revised BSD // license. You should have received a copy of this license along // with this source code in a file named "LICENSE." // //////////////////////////////////////////////////////////////////// #ifndef SOFTNODETREE_H #define SOFTNODETREE_H #include "pandatoolbase.h" #include "softNodeDesc.h" #include <SAA.h> class EggGroup; class EggTable; class EggXfmSAnim; class EggData; class EggGroupNode; //////////////////////////////////////////////////////////////////// // Class : SoftNodeTree // Description : Describes a complete tree of soft nodes for // conversion. //////////////////////////////////////////////////////////////////// class SoftNodeTree { public: SoftNodeTree(); SoftNodeDesc *build_node(SAA_Scene *scene, SAA_Elem *model); bool build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database); void handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name); // bool build_selected_hierarchy(SAA_Scene *s, SAA_Database *d, char *scene_name); int get_num_nodes() const; SoftNodeDesc *get_node(int n) const; SoftNodeDesc *get_node(string name) const; char *GetRootName(const char *); char *GetModelNoteInfo(SAA_Scene *, SAA_Elem *); char *GetName(SAA_Scene *scene, SAA_Elem *element); char *GetFullName(SAA_Scene *scene, SAA_Elem *element); EggGroupNode *get_egg_root() {return _egg_root;} EggGroup *get_egg_group(SoftNodeDesc *node_desc); EggTable *get_egg_table(SoftNodeDesc *node_desc); EggXfmSAnim *get_egg_anim(SoftNodeDesc *node_desc); void clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node); PT(SoftNodeDesc) _root; PN_stdfloat _fps; int _use_prefix; char *_search_prefix; private: EggData *_egg_data; EggGroupNode *_egg_root; EggGroupNode *_skeleton_node; SoftNodeDesc *r_build_node(SoftNodeDesc *parent_node, const string &path); typedef pmap<string, SoftNodeDesc *> NodesByName; NodesByName _nodes_by_name; typedef pvector<SoftNodeDesc *> Nodes; Nodes _nodes; }; #endif
28.888889
89
0.660684
[ "model", "3d" ]
83ce4ea3129aa6fdef0fd726cfd3d0f437763cf0
8,827
c
C
src/plugins/fcrypt/testmod_fcrypt.c
rkamisetti792/libelektra
9228d8f5af8dd878a63053213b1466fb9551f694
[ "BSD-3-Clause" ]
null
null
null
src/plugins/fcrypt/testmod_fcrypt.c
rkamisetti792/libelektra
9228d8f5af8dd878a63053213b1466fb9551f694
[ "BSD-3-Clause" ]
null
null
null
src/plugins/fcrypt/testmod_fcrypt.c
rkamisetti792/libelektra
9228d8f5af8dd878a63053213b1466fb9551f694
[ "BSD-3-Clause" ]
null
null
null
/** * @file * * @brief test suite for the fcrypt plugin * * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) * */ #include <kdb.h> #include <kdbinternal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <tests_internal.h> #include <tests_plugin.h> #include <gpg.h> #include <test_key.h> #include "../crypto/common_gpg_tests.c" #include "../crypto/gpgagent_teardown.h" #include "fcrypt.h" #define PLUGIN_NAME "fcrypt" #define TEST_KEY_ID "DDEBEF9EE2DC931701338212DAF635B17F230E8D" #define TEST_FILE "fcrypt_testfile" #define BUFFER_SIZE 2048 #define FAULTY_SIGNATURE_FILE \ "-----BEGIN PGP SIGNED MESSAGE-----\n\ Hash: SHA512\n\ \n\ test (modified)\n\ -----BEGIN PGP SIGNATURE-----\n\ \n\ iJwEAQEKAAYFAlmqZsMACgkQ2vY1sX8jDo2etAP/UA4s7e+SR38wa+AqQbWXKrPp\n\ i3hoYLPP9lIz5ypedFBlNjcJRjv47wvGc0Z2C1Q6pMtTNcI+is2X9zJNucv9aMeA\n\ nghsNiEgaIARzOFIe13QTevCg/HEFnq48gFSYNyeVgcsPmVP6tu3xWoEUkVEu6Vf\n\ XRrYPw+gFVq5zeOAI4A=\n\ =MjjB\n\ -----END PGP SIGNATURE-----\n" static const kdb_octet_t testContent[] = { 0x01, 0x02, 0xCA, 0xFE, 0xBA, 0xBE, 0x03, 0x04 }; static KeySet * newPluginConfiguration (void) { // clang-format off return ksNew (3, keyNew (ELEKTRA_RECIPIENT_KEY, KEY_VALUE, TEST_KEY_ID, KEY_END), keyNew (ELEKTRA_CRYPTO_PARAM_GPG_UNIT_TEST, KEY_VALUE, "1", KEY_END), keyNew (ELEKTRA_SIGNATURE_KEY, KEY_VALUE, TEST_KEY_ID, KEY_END), keyNew (ELEKTRA_FCRYPT_CONFIG_TEXTMODE, KEY_VALUE, "0", KEY_END), KS_END); // clang-format on } static KeySet * newPluginConfigurationWithTextmodeEnabled (void) { // clang-format off return ksNew (3, keyNew (ELEKTRA_RECIPIENT_KEY, KEY_VALUE, TEST_KEY_ID, KEY_END), keyNew (ELEKTRA_CRYPTO_PARAM_GPG_UNIT_TEST, KEY_VALUE, "1", KEY_END), keyNew (ELEKTRA_SIGNATURE_KEY, KEY_VALUE, TEST_KEY_ID, KEY_END), keyNew (ELEKTRA_FCRYPT_CONFIG_TEXTMODE, KEY_VALUE, "1", KEY_END), KS_END); // clang-format on } static void writeTestFile (const char * file) { FILE * f = fopen (file, "wb"); succeed_if (f, "can not write to temporary file"); if (!f) return; succeed_if (fwrite (testContent, 1, sizeof (testContent), f) == sizeof (testContent), "test file preparation failed"); fclose (f); } static void writeFaultySignatureFile (const char * file) { FILE * f = fopen (file, "w"); succeed_if (f, "can not write to temporary file"); if (!f) return; succeed_if (fwrite (FAULTY_SIGNATURE_FILE, 1, strlen (FAULTY_SIGNATURE_FILE), f) == strlen (FAULTY_SIGNATURE_FILE), "test file preparation failed"); fclose (f); } /** * @brief read in the content stored in file and compare it to the test vector. * @retval 1 if the file content is equal to the test vector. * @retval -1 if the file content is not equal to the test vector or an error occurred. */ static int isTestFileCorrect (const char * file) { int returnValue = -1; kdb_octet_t readBuffer[2 * sizeof (testContent)] = { 0 }; size_t readCount = 0; FILE * f = fopen (file, "rb"); succeed_if (f, "can not read from temporary file"); if (!f) return -1; readCount = fread (readBuffer, 1, sizeof (readBuffer), f); succeed_if (readCount > 0, "temporary file is empty."); if (readCount == sizeof (testContent)) { if (memcmp (readBuffer, testContent, sizeof (testContent)) == 0) { returnValue = 1; } } fclose (f); return returnValue; } static void test_init (void) { Plugin * plugin = NULL; Key * parentKey = keyNew ("system", KEY_END); KeySet * modules = ksNew (0, KS_END); KeySet * configKs = newPluginConfiguration (); elektraModulesInit (modules, 0); plugin = elektraPluginOpen (PLUGIN_NAME, modules, configKs, 0); succeed_if (plugin != 0, "failed to open the plugin"); if (plugin) { succeed_if (!strcmp (plugin->name, PLUGIN_NAME), "got wrong name"); KeySet * config = elektraPluginGetConfig (plugin); succeed_if (config != 0, "there should be a config"); succeed_if (plugin->kdbOpen != 0, "no open pointer"); succeed_if (plugin->kdbClose != 0, "no close pointer"); succeed_if (plugin->kdbGet != 0, "no get pointer"); succeed_if (plugin->kdbSet != 0, "no set pointer"); elektraPluginClose (plugin, 0); } elektraModulesClose (modules, 0); ksDel (modules); keyDel (parentKey); } static void test_gpg (void) { // Plugin configuration KeySet * conf = newPluginConfiguration (); Key * errorKey = keyNew (0); // install the gpg key char * argv[] = { "", "-a", "--import", NULL }; const size_t argc = 4; Key * msg = keyNew (0); keySetBinary (msg, test_key_asc, test_key_asc_len); succeed_if (CRYPTO_PLUGIN_FUNCTION (gpgCall) (conf, errorKey, msg, argv, argc) == 1, "failed to install the GPG test key"); keyDel (msg); keyDel (errorKey); ksDel (conf); } static void test_file_crypto_operations (void) { Plugin * plugin = NULL; Key * parentKey = keyNew ("system", KEY_END); KeySet * modules = ksNew (0, KS_END); KeySet * config = newPluginConfiguration (); elektraModulesInit (modules, 0); plugin = elektraPluginOpen (PLUGIN_NAME, modules, config, 0); succeed_if (plugin, "failed to open plugin handle"); if (plugin) { KeySet * data = ksNew (0, KS_END); const char * tmpFile = elektraFilename (); if (tmpFile) { // prepare test file to be encrypted writeTestFile (tmpFile); keySetString (parentKey, tmpFile); // try to encrypt the file succeed_if (plugin->kdbSet (plugin, data, parentKey) == 1, "kdb set failed"); succeed_if (isTestFileCorrect (tmpFile) == -1, "file content did not change during encryption"); // try to decrypt the file again (simulating the pregetstorage call) succeed_if (plugin->kdbGet (plugin, data, parentKey) == 1, "kdb get (pregetstorage) failed"); succeed_if (isTestFileCorrect (keyString (parentKey)) == 1, "file content could not be restored during decryption"); // a second call to kdb get (the postgetstorage call) should re-encrypt the file again succeed_if (plugin->kdbGet (plugin, data, parentKey) == 1, "kdb get (postgetstorage) failed"); succeed_if (isTestFileCorrect (tmpFile) == -1, "postgetstorage did not encrypt the file again"); remove (tmpFile); } ksDel (data); elektraPluginClose (plugin, 0); } elektraModulesClose (modules, 0); ksDel (modules); keyDel (parentKey); } static void test_file_signature_operations (void) { Plugin * plugin = NULL; Key * parentKey = keyNew ("system", KEY_END); KeySet * modules = ksNew (0, KS_END); KeySet * config = newPluginConfiguration (); elektraModulesInit (modules, 0); plugin = elektraPluginOpen (PLUGIN_NAME, modules, config, 0); succeed_if (plugin, "failed to open plugin handle"); if (plugin) { KeySet * data = ksNew (0, KS_END); const char * tmpFile = elektraFilename (); if (tmpFile) { // prepare test file to be encrypted writeTestFile (tmpFile); keySetString (parentKey, tmpFile); // try to encrypt the file succeed_if (plugin->kdbSet (plugin, data, parentKey) == 1, "kdb set failed"); succeed_if (isTestFileCorrect (tmpFile) == -1, "file content did not change during encryption"); // try to decrypt/verify the file succeed_if (plugin->kdbGet (plugin, data, parentKey) == 1, "kdb get failed"); remove (tmpFile); } ksDel (data); elektraPluginClose (plugin, 0); } elektraModulesClose (modules, 0); ksDel (modules); keyDel (parentKey); } static void test_file_faulty_signature (void) { Plugin * plugin = NULL; Key * parentKey = keyNew ("system", KEY_END); KeySet * modules = ksNew (0, KS_END); KeySet * config = newPluginConfigurationWithTextmodeEnabled (); elektraModulesInit (modules, 0); plugin = elektraPluginOpen (PLUGIN_NAME, modules, config, 0); succeed_if (plugin, "failed to open plugin handle"); if (plugin) { KeySet * data = ksNew (0, KS_END); const char * tmpFile = elektraFilename (); if (tmpFile) { // prepare test file to be encrypted writeFaultySignatureFile (tmpFile); keySetString (parentKey, tmpFile); // try to decrypt/verify the file -- should fail succeed_if (plugin->kdbGet (plugin, data, parentKey) == -1, "kdb get succeeded on a faulty signature"); remove (tmpFile); } ksDel (data); elektraPluginClose (plugin, 0); } elektraModulesClose (modules, 0); ksDel (modules); keyDel (parentKey); } int main (int argc, char ** argv) { printf ("FCRYPT TESTS\n"); printf ("==================\n\n"); init (argc, argv); if (!gpg_available (newPluginConfiguration ())) { printf ("The test was disabled because gpg could not be found on the system.\n"); return nbError; } test_gpg (); test_init (); test_file_crypto_operations (); test_file_signature_operations (); test_file_faulty_signature (); test_teardown (); print_result (ELEKTRA_PLUGIN_NAME); return nbError; }
28.566343
140
0.693441
[ "vector" ]
83cff3c17b6499316dc4a4e1bf34f4de375d09b4
7,999
h
C
libraries/lib-xml/XMLMethodRegistry.h
joshrose/audacity
e2b1a2be6b92661628bbb054f915bc50b211c020
[ "CC-BY-3.0" ]
2
2021-05-26T18:08:59.000Z
2021-09-21T16:50:39.000Z
libraries/lib-xml/XMLMethodRegistry.h
joshrose/audacity
e2b1a2be6b92661628bbb054f915bc50b211c020
[ "CC-BY-3.0" ]
70
2021-07-18T18:11:53.000Z
2021-12-05T20:22:15.000Z
libraries/lib-xml/XMLMethodRegistry.h
joshrose/audacity
e2b1a2be6b92661628bbb054f915bc50b211c020
[ "CC-BY-3.0" ]
2
2021-09-08T18:12:22.000Z
2021-12-24T16:39:47.000Z
/********************************************************************** Audacity: A Digital Audio Editor XMLMethodRegistry.h Paul Licameli **********************************************************************/ #ifndef __AUDACITY_XML_METHOD_REGISTRY__ #define __AUDACITY_XML_METHOD_REGISTRY__ #include <forward_list> #include <string> #include <string_view> #include <functional> #include <type_traits> #include <unordered_map> #include <utility> #include <vector> class XMLTagHandler; class XMLWriter; class XMLAttributeValueView; //! Implementation helper for ProjectFileIORegistry. /*! It makes most of the work non-inline and is used by derived classes that supply thin inline type-erasing wrappers. */ class XML_API XMLMethodRegistryBase { public: //! A helper type alias for a function taking a structure and a string value template< typename Substructure > using Mutator = std::function< void(Substructure&, const XMLAttributeValueView &) >; //! A helper type alias for a list of mutators, associated with tag strings template< typename Substructure > using Mutators = std::vector< std::pair< std::string, Mutator<Substructure> > >; XMLMethodRegistryBase(); ~XMLMethodRegistryBase(); protected: using TypeErasedObjectAccessor = std::function< XMLTagHandler *( void* ) >; using TagTable = std::unordered_map< std::string_view, TypeErasedObjectAccessor >; TagTable mTagTable; std::forward_list<std::string> mTags; void Register(std::string tag, TypeErasedObjectAccessor accessor); XMLTagHandler *CallObjectAccessor( const std::string_view &tag, void *p ); using TypeErasedAccessor = std::function< void*( void* ) >; using TypeErasedAccessors = std::vector< TypeErasedAccessor >; TypeErasedAccessors mAccessors; void PushAccessor( TypeErasedAccessor accessor ); using TypeErasedMutator = std::function< void( void*, const XMLAttributeValueView& ) >; //! From attribute name, to index in accessor table with a mutator using MutatorTable = std::unordered_map<std::string_view, std::pair<size_t, TypeErasedMutator>>; MutatorTable mMutatorTable; std::forward_list<std::string> mMutatorTags; void Register(std::string tag, TypeErasedMutator mutator); bool CallAttributeHandler(const std::string_view& tag, void *p, const XMLAttributeValueView &value ); using TypeErasedWriter = std::function< void(const void *, XMLWriter &) >; using WriterTable = std::vector< TypeErasedWriter >; WriterTable mAttributeWriterTable; void RegisterAttributeWriter( TypeErasedWriter writer ); void CallAttributeWriters( const void *p, XMLWriter &writer ); WriterTable mObjectWriterTable; void RegisterObjectWriter( TypeErasedWriter writer ); void CallObjectWriters( const void *p, XMLWriter &writer ); }; /*! A class template of inline type-erasing wrapper functions, but one function with linkage is also needed. See the macros that help generate that function. */ template< typename Host > class XMLMethodRegistry : public XMLMethodRegistryBase { public: // Typically statically constructed struct ObjectReaderEntry { template < /*! This "accessor" may or may not act as a "factory" that builds a new object and may return nullptr. Caller of the accessor is not responsible for the object lifetime, which is assumed to outlast the project loading procedure. */ typename ObjectAccessor /*!< Often a lambda. A function from Host& to XMLTagHandler*, maybe returning null */ > ObjectReaderEntry( const std::string &tag, ObjectAccessor fn ) { // Remember the function, type-erased Get().Register( tag, [ fn = std::move(fn) ] (void *p) { // CallObjectAccessor will guarantee p is not null return fn( *static_cast<Host *>(p) ); } ); } }; XMLTagHandler *CallObjectAccessor(const std::string_view& tag, Host& host) { return XMLMethodRegistryBase::CallObjectAccessor( tag, &host ); } /*! Typically statically constructed */ /*! Registers procedures to update the host for certain attributes, in two steps: first the `accessor` which fetches some substructure owned by the host, which is the common step; then, the `mutators` that rewrite the substructure, each of them associated with one attribute string, and taking a reference to the substructure and a value string. */ struct AttributeReaderEntries { template< typename Accessor, /*!< Often a lambda. Takes const Host& and returns Substructure& */ typename Substructure //<! Type deduction of the return of Accessor = std::remove_reference_t< decltype( std::declval<Accessor>()( std::declval<Host &>() ) ) > > AttributeReaderEntries( Accessor fn, Mutators<Substructure> pairs ) { // Remember the functions, type-erased auto &registry = Get(); registry.PushAccessor( [ fn = std::move(fn) ] ( void *p ) { // CallAttributeHandler will guarantee p is not null return &fn( *static_cast<Host *>(p) ); } ); for (auto &pair : pairs) registry.Register( pair.first, [ fn = move(pair.second) ]( auto p, auto value ){ fn( *static_cast<Substructure*>(p), value ); } ); } }; // @return whether any function was found and called for the tag bool CallAttributeHandler( const std::string_view &tag, Host &host, const XMLAttributeValueView& value ) { return XMLMethodRegistryBase::CallAttributeHandler( tag, &host, value ); } //! Typically statically constructed struct AttributeWriterEntry { template < /*! The Writer may write any number of XML attributes, but must not write tags. So there should be some reader entries corresponding to each writer, and that may be many-to-one. The readers must not make assumptions about the sequence in which they will be called. */ typename Writer /*!< Often a lambda. Takes const Host& and XMLWriter& and returns void */ > explicit AttributeWriterEntry( Writer fn ) { // Remember the function, type-erased Get().RegisterAttributeWriter( [ fn = std::move(fn) ] ( const void *p, XMLWriter &writer ) { // CallObjectAccessor will guarantee p is not null return fn( *static_cast<const Host *>(p), writer ); } ); } }; //! Typically statically constructed struct ObjectWriterEntry { template < /*! The Writer may write any number of XML tags, but no attributes. So there should be some reader entries corresponding to each writer, and that may be many-to-one. The readers must not make assumptions about the sequence in which they will be called. */ typename Writer /*!< Often a lambda. Takes const Host& and XMLWriter& and returns void */ > explicit ObjectWriterEntry( Writer fn ) { // Remember the function, type-erased Get().RegisterObjectWriter( [ fn = std::move(fn) ] ( const void *p, XMLWriter &writer ) { // CallObjectAccessor will guarantee p is not null return fn( *static_cast<const Host *>(p), writer ); } ); } }; void CallAttributeWriters( const Host &host, XMLWriter &writer ) { XMLMethodRegistryBase::CallAttributeWriters( &host, writer ); } void CallObjectWriters( const Host &host, XMLWriter &writer ) { XMLMethodRegistryBase::CallObjectWriters( &host, writer ); } //! Get the unique instance static XMLMethodRegistry &Get(); }; /*! Typically follows the `using` declaration of an XMLMethodRegistry specialization; DECLSPEC is for linkage visibility */ #define DECLARE_XML_METHOD_REGISTRY(DECLSPEC, Name) \ template<> auto DECLSPEC Name::Get() -> Name &; /*! Typically in the companion .cpp file */ #define DEFINE_XML_METHOD_REGISTRY(Name) \ template<> auto Name::Get() -> Name & \ { \ static Name registry; \ return registry; \ } #endif
34.183761
90
0.684086
[ "object", "vector" ]
83dd556b774af26316780926a7a27a845f617723
25,610
c
C
BNPM.c
Aditya-AS/ParallelComputing_MPI
2d22e17fcae73e038970a6f6121bef002a0082e5
[ "MIT" ]
null
null
null
BNPM.c
Aditya-AS/ParallelComputing_MPI
2d22e17fcae73e038970a6f6121bef002a0082e5
[ "MIT" ]
null
null
null
BNPM.c
Aditya-AS/ParallelComputing_MPI
2d22e17fcae73e038970a6f6121bef002a0082e5
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include <string.h> #include <mpi.h> #include <stddef.h> #include "BNPM.h" void copyNewsStructure(news *dest, news *src) { if(dest == NULL) {printf("Memory not allocated.\n");return;} if(src == NULL){printf("chodu src null hai\n");return;} dest->newsId = src->newsId; dest->timestamp = src->timestamp; strcpy(dest->location, src->location); strcpy(dest->category, src->category); strcpy(dest->content, src->content); } void printNewsReporterMapping(NewsReporterMap *map, ReporterNewsMap *rmap) { int i; printf("Reporter to news mapping.\n\n"); for(i=0;i<numReporters;i++) { printf("Reporter: %d\t", i+1); int j; for(j=0;j<numNews;j++) { if((*rmap)[i][j]==1) printf("%d\t", j); } printf("\n"); } printf("\nNews to reporter mappint.\n\n"); for(i=0;i<numNews;i++) { printf("News: %d\t", i); int j; printf("num: %d\t", (*map)[i][0]); for(j=1;j<(numReporters+1);j++) { if((*map)[i][j]==1) printf("%d\t", j); } printf("\n"); } } void printStruct(news* new, FILE *fp) { fprintf(fp,"Id:\t%d\n",new->newsId); fprintf(fp,"Location:\t%s\n",new->location); fprintf(fp,"EventTime:\t%d\n",new->timestamp); fprintf(fp,"Category:\t%s\n",new->category); fprintf(fp,"Content:\t%s\n",new->content); } void doNewsReporterMapping(NewsReporterMap *map, ReporterNewsMap *rmap) { int i; for(i=0;i<numNews;i++) { int j; for(j=0;j<(numReporters+1);j++) (*map)[i][j] = 0; } for(i=0;i<numReporters;i++) { int j; for(j=0;j<numNews;j++) (*rmap)[i][j] = 0; } int n; n = 1 + rand() % (numNews/2); n = numNews/n; for(i=0;i<numNews;i++) { //printf("i: %d\t", i); //news covered by multiple reporters //printf("%d %d\n",i,n); if(i%n==0) { int m = 2 + rand() % (numReporters/2); //printf("num: %d\t", m); int j; int o = rand() % numReporters; for(j=0;j<m;j++) { //printf("%d\t", o); (*map)[i][o+1] = 1; (*map)[i][0]++; (*rmap)[o][i] = 1; o++; o %= numReporters; } } //news covered by a single reporter else { int o = rand() % numReporters; //printf("num: 1\t%d\t", o); (*map)[i][o+1] = 1; (*map)[i][0]++; (*rmap)[o][i] = 1; } //printf("\n"); } } void doEditorReporterMapping(EditorReportMap* ermap, EditorNewsMap* enewsmap, ReporterNewsMap* rmap){ int i=0;int e=0; printf("%d\n",numEditors); printf("%d\n",numReporters); //printf("%d\n",e); for(i=0;i<numReporters;i++){ //printf("%d\t%d\n",e,i); int rem = i%numEditors; int k; (*ermap)[rem][i] = 1; // If Reporter i leaves a reminder of x when divided by numEditors then Map Editor x to Reporter i. for(k=0;k<numNews;k++) { if((*rmap)[i][k]==1) (*enewsmap)[rem][k] = 1; } } //EditorReporting Mapping has been completed. Time to use this info to do Editor News Mapping. printf("yoyoo\n"); } void printEditorReporterMapping(EditorReportMap* ermap, EditorNewsMap *enewsmap){ int i,j; printf("%d\n",*(ermap)[0][5]); for(i=0;i<numEditors;i++){ printf("Editor %d:",i); for(j=0;j<numReporters;j++){ //if(j==5){printf("5 mil gay\n");} if((*ermap)[i][j] == 1){printf(" %d",j);fflush(stdout);} else{ ; } } printf("\n"); } for(i=0;i<numEditors;i++){ printf("Editor %d:",i); for(j=0;j<numNews;j++){ //if(j==5){printf("5 mil gay\n");} if((*enewsmap)[i][j] == 1){printf(" %d",j);fflush(stdout);} else{ ; } } printf("\n"); } } void publishNews(char *filename, news *update) { static int numUpdate[numNews] = {0}; FILE *fp = fopen(filename, "a+"); fprintf(fp,"News Update: %d\n", numUpdate[update->newsId]); printStruct(update, fp); numUpdate[update->newsId]++; fclose(fp); } char* randomTextGenerator() { time_t t; //srand((unsigned) time(&t)); char* news = (char*)malloc(sizeof(char)*101); int i=0; for(i=0;i<100;i++){ char c = 65 + (char)(rand() % 57) ; news[i] = c; if(news[i] == '\n') i--; } news[i] = '\0'; return news; } news* fillFile(char* filename, int id) { news* new = (news*)malloc(sizeof(news)); FILE* fp = fopen(filename, "a+"); char* location = locations[rand()%LOCATION_SIZE]; char* category = categories[rand()%CATEGORY_SIZE]; char* content = randomTextGenerator(); strcpy(new->location,location); strcpy(new->category,category); strcpy(new->content,content); new->newsId = id; new->timestamp = timestamp; printStruct(new, fp); //free(location);free(category);free(content); fclose(fp); timestamp++; return new; } void BNPM(int *argc, char **argv[]) { NewsReporterMap map = {0}; ReporterNewsMap rmap = {0}; //EditorReportMap emap = {0}; int myid; MPI_Init(argc,argv); MPI_Comm_rank(MPI_COMM_WORLD, &myid); //Definition of NewsType MPI_Datatype newstype, oldtypes[2]; int blockcounts[2]; MPI_Aint offsets[2], extent_int, extent_char; offsets[0] = offsetof(news, newsId); oldtypes[0] = MPI_INT; blockcounts[0] = 2; //MPI_Type_extent(MPI_INT, &extent_int); offsets[1] = offsetof(news, location); oldtypes[1] = MPI_CHAR; blockcounts[1] = 131; // 15 + 15 + 101 MPI_Type_struct(2, blockcounts, offsets, oldtypes, &newstype); MPI_Type_commit(&newstype); //Definition of MessageType MPI_Datatype messagetype, oldtype[2]; int blockcount[2]; MPI_Aint offset[2], extentint; offset[0] = offsetof(Message, messageType); oldtype[0] = MPI_INT; blockcount[0] = 2; //MPI_Type_extent(MPI_INT, &extentint); offset[1] = offsetof(Message, update); oldtype[1] = newstype; blockcount[1] = 1; MPI_Type_struct(2, blockcount, offset, oldtype, &messagetype); MPI_Type_commit(&messagetype); //-------------------------------------------------------------------------------------- //Definition of MapType MPI_Datatype maptype, oldtypemap[1]; int blockcountmap[1]; MPI_Aint offsetmap[1], extentmap; offsetmap[0] = 0; oldtypemap[0] = MPI_INT; blockcountmap[0] = numNews * (numReporters+1); MPI_Type_struct(1, blockcountmap, offsetmap, oldtypemap, &maptype); MPI_Type_commit(&maptype); //Definition of RmapType MPI_Datatype rmaptype, oldtypermap[1]; int blockcountrmap[1]; MPI_Aint offsetrmap[1], extentrmap; offsetrmap[0] = 0; oldtypermap[0] = MPI_INT; blockcountrmap[0] = numReporters*numNews; MPI_Type_struct(1, blockcountrmap, offsetrmap, oldtypermap, &rmaptype); MPI_Type_commit(&rmaptype); //Definition of WrapperType MPI_Datatype wrappertype, oldtypewrap[2]; int blockcountwrap[2]; MPI_Aint offsetwrap[2]; offsetwrap[0] = offsetof(Wrapper, map); oldtypewrap[0] = maptype; blockcountwrap[0] = 1; //MPI_Type_extent(maptype, &extentmap); offsetwrap[1] = offsetof(Wrapper, rmap); oldtypewrap[1] = rmaptype; blockcountwrap[1] = 1; MPI_Type_struct(2, blockcount, offsetwrap, oldtypewrap, &wrappertype); MPI_Type_commit(&wrappertype); //------------------------------------------------------------------------------ MPI_Datatype emaptype, oldtypeemap[1]; int blockcountemap[1]; MPI_Aint offsetemap[1], extentemap; offsetemap[0] = 0; oldtypeemap[0] = MPI_INT; blockcountemap[0] = numReporters*numEditors; MPI_Type_struct(1, blockcountemap, offsetemap, oldtypeemap, &emaptype); MPI_Type_commit(&emaptype); //-------------------------------------------------------------------------------- MPI_Datatype enewsmaptype, oldtypeenewsmap[1]; int blockcountenewsmap[1]; MPI_Aint offsetenewsmap[1], extentemnewsap; offsetenewsmap[0] = 0; oldtypeenewsmap[0] = MPI_INT; blockcountenewsmap[0] = numNews*numEditors; MPI_Type_struct(1, blockcountenewsmap, offsetenewsmap, oldtypeenewsmap, &enewsmaptype); MPI_Type_commit(&enewsmaptype); //----------------------------------------------------------------------------------- //editor variables Message msg; int src, tag; MPI_Status status; char dest[35]; int i,j; //source variables MPI_Request req; news* new; int id; //reporter variables int editor_count; int editor; Record record[numNews]; int newsid; int size; int source = 0; int reporter; news* update; news* myLatestCopy; int rqstCheck; MPI_Status stat; EditorReportMap emap1; EditorReportMap* emap = &emap1; memset(emap, 0, numEditors*numReporters); Wrapper wrap; //LOL MAxx, Funny errors. If instead of this, you allocate memory on heap, Editor doesn't work. Gives Seg Fault before the First Recv Completes. Find out why???? Wrapper* wrapper = &wrap; EditorNewsMap enewsmap; EditorNewsMap* eNewsMap = &enewsmap; //Emulate Process according to rank switch(myid) { case 0: //source //create mapping doNewsReporterMapping(&(wrapper->map), &(wrapper->rmap)); //create wrapper printNewsReporterMapping(&(wrapper->map), &(wrapper->rmap)); //copyIntoWrapper(&wrapper, &map, &rmap); doEditorReporterMapping(emap, eNewsMap, &(wrapper->rmap)); printEditorReporterMapping(emap,eNewsMap); //send to everyone for(j=1;j<(numEditors+numReporters+1);j++){MPI_Send(wrapper, 1, wrappertype, j, 5, MPI_COMM_WORLD);printf("Wrapper received by %d\n",j);sleep(1);} for(j=1;j<(numEditors+numReporters+1);j++){MPI_Send(emap, 1, emaptype, j, 5, MPI_COMM_WORLD);printf("EMAP received by %d\n",j);sleep(1);} for(j=1;j<(numEditors+numReporters+1);j++){MPI_Send(eNewsMap, 1, enewsmaptype, j, 5, MPI_COMM_WORLD);printf("EMAP received by %d\n",j);sleep(1);} // The mappings has been shared with all the processes involved. Time to do some real work. printf("I am the source. %d\n",myid); for(i=0;i<numNews;i++){ sprintf(dest, "./news/file%d.txt",i); new = fillFile(dest,i); msg.messageType = 0; msg.source = 0; //printf("yoyo1\n"); copyNewsStructure(&(msg.update),new); printf("Generating news: %d %d\n", new->newsId,i); for(j=1;j<(numReporters+1);j++) if(wrapper->map[new->newsId][j] == 1) {printf("sending : %d to: %d with msgtype: %d\n", new->newsId, j, msg.messageType); MPI_Isend(&msg, 1, messagetype, j+1, new->newsId, MPI_COMM_WORLD,&req);} //printStruct(new); sleep(1); } while(i<TOTAL_NEWS){ id = rand()%numNews; sprintf(dest, "./news/file%d.txt",id); new = fillFile(dest,id); msg.messageType = 0; msg.source = 0; copyNewsStructure(&(msg.update),new); printf("Generating news: %d %d\n", new->newsId,i); for(j=1;j<(numReporters+1);j++) if(wrapper->map[new->newsId][j] == 1) {printf("sending : %d to: %d with msgtype: %d\n", new->newsId, j, msg.messageType); MPI_Isend(&msg, 1, messagetype, j+1, new->newsId, MPI_COMM_WORLD,&req);} i++; sleep(1); } printf("About to send broadcast!!\n"); msg.messageType = -1; //int j; for(j=1;j<(numReporters+numEditors+1);j++){MPI_Isend(&msg, 1, messagetype, j, 0, MPI_COMM_WORLD,&req);printf("Send\n");} printf("broadcast sent\n"); //exit(-1); break; case 1 ... numEditors: //editor //recieve the mapping printf("I am the Editor. %d\n",myid); MPI_Recv(wrapper, 1, wrappertype, source, 5, MPI_COMM_WORLD, &status); printf("Received the Wrapper Object\n"); //print the mapping printNewsReporterMapping(&(wrapper->map), &(wrapper->rmap)); printf("Successfully printed NewsReporter Mapping\n"); MPI_Recv(emap, 1, emaptype, source, 5, MPI_COMM_WORLD, &status); MPI_Recv(eNewsMap, 1, enewsmaptype, source, 5, MPI_COMM_WORLD, &status); printf("Received the EMAP Object\n"); printEditorReporterMapping(emap,eNewsMap); //printf("%p %p\n", &map, &rmap); for(i=0;i<numNews;i++) { editor_count = 0; record[i].ready = 0; for(j=0;j<numEditors;j++){ if((*eNewsMap)[j][i] == 1)editor_count++; } record[i].latestCopy = NULL; //record[i].latestCopy->timestamp = -1; record[i].numNewsFriends = editor_count - 1; record[i].rqst = NULL; } src = MPI_ANY_SOURCE; tag = MPI_ANY_TAG; while(MPI_Recv(&msg, 1, messagetype, src, tag, MPI_COMM_WORLD, &status) == MPI_SUCCESS) { if(msg.messageType == -1) {printf("Editor Exiting\n");break;} if(status.MPI_SOURCE ==0){ //this should not happen ever!!!! ; } else if(msg.source <= numEditors) { //meaning the message was from one of the editors!!! editor = msg.source; newsid = status.MPI_TAG; if(msg.messageType == 1) { // this is a reqquest form one of the editors .. printf("editor: %d requested for news: %d with time: %d\n", msg.source, newsid, msg.update.timestamp); update = &(msg.update); //first update of newsid recieved if(record[newsid].latestCopy == NULL) { record[newsid].latestCopy = malloc(sizeof(news)); copyNewsStructure(record[newsid].latestCopy, update); record[newsid].ready = 0; msg.messageType = 2; printf("sending back positive feedback.\n"); msg.source = myid; MPI_Isend(&msg, 1, messagetype, editor, newsid, MPI_COMM_WORLD, &req); continue; } myLatestCopy = record[newsid].latestCopy; //He has the latest copy if(update->timestamp > myLatestCopy->timestamp) { copyNewsStructure(record[newsid].latestCopy, update); record[newsid].ready = 0; // Message tempMsg; // tempMsg.messageType = 2; // tempMsg.update = update; msg.messageType = 2; printf("sending back positive feedback.\n"); msg.source = myid; MPI_Isend(&msg, 1, messagetype, editor, newsid, MPI_COMM_WORLD, &req); continue; } //we have the same copy else if(update->timestamp == myLatestCopy->timestamp) { //He has smaller id. Positive feedback. if(editor < myid) { // Message tempMsg; // tempMsg.messageType = 2; // tempMsg.update = update; msg.messageType = 2; printf("sending back positive feedback.\n"); msg.source = myid; MPI_Isend(&msg, 1, messagetype, editor, newsid, MPI_COMM_WORLD, &req); continue; } //I have smaller id. Negative feedback. else { // Message tempMsg; // tempMsg.messageType = 3; // tempMsg.update = update; msg.messageType = 3; printf("sending back negative feedback.\n"); msg.source = myid; MPI_Isend(&msg, 1, messagetype, editor, newsid, MPI_COMM_WORLD, &req); continue; } } //I have the latest copy else { // Message tempMsg; // tempMsg.messageType = 3; // tempMsg.update = record[newsid].latestCopy; msg.messageType = 3; printf("sending back negative feedback.\n"); copyNewsStructure(&(msg.update), record[newsid].latestCopy); msg.source = myid; MPI_Isend(&msg, 1, messagetype, editor, newsid, MPI_COMM_WORLD, &req); continue; } } //Positive response from an editor else if(msg.messageType == 2) { //Drop the response if not expecting any. if(record[newsid].ready == 0) continue; printf("editor: %d responded positive for news: %d with time: %d\n", editor, newsid, record[newsid].latestCopy->timestamp); //see if expecting this specific response MPI_Request_get_status(record[newsid].rqst[editor-1] , &rqstCheck, &stat); if(rqstCheck!=0) { printf("counting this response.\n"); record[newsid].ready--; if(record[newsid].ready==0) { printf("all responses recieved for news: %d with time: %d\n", newsid, record[newsid].latestCopy->timestamp); // Message tempMsg; // tempMsg.messageType = 0; // tempMsg.update = record[newsid].latestCopy; msg.messageType = 0; copyNewsStructure(&(msg.update), record[newsid].latestCopy); msg.source = myid; MPI_Isend(&msg, 1, messagetype, editor, newsid, MPI_COMM_WORLD, &req); } } } } else{ //NEWS received from one of the reporter.... newsid = status.MPI_TAG; reporter = msg.source - numEditors; printf("for news: %d , msgtype: %d from: %d\n", newsid, msg.messageType, msg.source); //exclusive news. publish. if(record[newsid].numNewsFriends ==0) { sprintf(dest, "./publication/out%d.txt", newsid); publishNews(dest, &(msg.update)); } //Shared news. Communicate with newsFriends else { //Check if the update is already published if(record[newsid].latestCopy != NULL){ if(record[newsid].latestCopy->timestamp >= msg.update.timestamp){ continue; } } //Update record for this news update record[newsid].ready = record[newsid].numNewsFriends; if(record[newsid].latestCopy == NULL) record[newsid].latestCopy = (news*)malloc(sizeof(news)); copyNewsStructure(record[newsid].latestCopy, &(msg.update)); // int i; // for(i=0;i<record[newsid].numNewsFriends;i++) // record[newsid].pendingRequests[i]++; //if(record[newsid].rqst != NULL) free(record[newsid].rqst); record[newsid].rqst = malloc(numEditors * sizeof(MPI_Request)); //Prepare to communicate // Message tempMsg; // tempMsg.messageType = 1; // tempMsg.update = msg.update; msg.messageType = 1; //Send messages to newsFriends for(i=0;i<numEditors;i++) { if((*eNewsMap)[i][newsid] ==1 && (i+1) != myid) { msg.source = myid; printf("Requesting editor: %d for news: %d with time: %d\n", i+1, newsid, msg.update.timestamp); MPI_Isend(&msg, 1, messagetype, i+1, newsid, MPI_COMM_WORLD, &(record[newsid].rqst[i])); } } } } printf("%d\n", status.MPI_TAG); sprintf(dest, "./publication/out%d.txt", status.MPI_TAG); publishNews(dest, &(msg.update)); } break; default: //reporters //recieve the mapping printf("WAITING FOR THE MAP AND RMAP\n"); MPI_Recv(wrapper, 1, wrappertype, 0, 5, MPI_COMM_WORLD, &status); printf("received map and ramp\n"); //print the mapping //printf("%p %p\n", &map, &rmap); printNewsReporterMapping(&(wrapper->map), &(wrapper->rmap)); MPI_Recv(emap, 1, emaptype, 0, 5, MPI_COMM_WORLD, &status); MPI_Recv(eNewsMap, 1, enewsmaptype, 0, 5, MPI_COMM_WORLD, &status); printEditorReporterMapping(emap,eNewsMap); id = myid - numEditors; printf("I am the reporter: %d\n", id); //src = MPI_ANY_SOURCE; //tag = MPI_ANY_TAG; editor = id % numEditors; //check if initialized properly for(i=0;i<numNews;i++) { record[i].ready = 0; record[i].numNewsFriends = wrapper->map[i][0] - 1; record[i].latestCopy = NULL; //record[i].latestCopy->timestamp = -1; record[i].rqst = NULL; } while(MPI_Recv(&msg, 1, messagetype, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status) == MPI_SUCCESS) { //end of simulation if(msg.messageType == -1) {printf("Reporter Exiting\n");break;} //printf("tag: %d , id: %d\n", status.MPI_TAG, status.MPI_SOURCE); //Update recieved from source if(status.MPI_SOURCE = 1 && status.MPI_TAG == msg.update.newsId && msg.messageType == 0) { newsid = status.MPI_TAG; size = wrapper->map[newsid][0]; printf("for news: %d , msgtype: %d from: %d\n", newsid, msg.messageType, status.MPI_SOURCE); //exclusive news. Send it to editor. if(size==1) { // Message tempMsg; // tempMsg.messageType = 0; // tempMsg.update = msg.update; msg.messageType = 0; msg.source = myid; MPI_Isend(&msg, 1, messagetype, editor, newsid, MPI_COMM_WORLD, &req); } //Shared news. Communicate with newsFriends else { //Check if the update is already published if(record[newsid].latestCopy != NULL){ if(record[newsid].latestCopy->timestamp >= msg.update.timestamp){ continue; } } //Update record for this news update record[newsid].ready = record[newsid].numNewsFriends; if(record[newsid].latestCopy == NULL) record[newsid].latestCopy = (news*)malloc(sizeof(news)); copyNewsStructure(record[newsid].latestCopy, &(msg.update)); // int i; // for(i=0;i<record[newsid].numNewsFriends;i++) // record[newsid].pendingRequests[i]++; //if(record[newsid].rqst != NULL) free(record[newsid].rqst); record[newsid].rqst = malloc(numReporters * sizeof(MPI_Request)); //Prepare to communicate // Message tempMsg; // tempMsg.messageType = 1; // tempMsg.update = msg.update; msg.messageType = 1; //Send messages to newsFriends for(i=1;i<(numReporters+1);i++) { if(wrapper->map[newsid][i]==1 && i != id) { msg.source = myid; printf("Requesting reporter: %d for news: %d with time: %d\n", i, newsid, msg.update.timestamp); MPI_Isend(&msg, 1, messagetype, i + numEditors, newsid, MPI_COMM_WORLD, &(record[newsid].rqst[i-1])); } } } } //Message recieved from some reporter else { reporter = msg.source - numEditors; newsid = status.MPI_TAG; //Request from a reporter if(msg.messageType==1) { printf("reporter: %d requested for news: %d with time: %d\n", reporter, newsid, msg.update.timestamp); update = &(msg.update); //first update of newsid recieved if(record[newsid].latestCopy == NULL) { record[newsid].latestCopy = malloc(sizeof(news)); copyNewsStructure(record[newsid].latestCopy, update); record[newsid].ready = 0; msg.messageType = 2; printf("sending back positive feedback.\n"); msg.source = myid; MPI_Isend(&msg, 1, messagetype, reporter+numEditors, newsid, MPI_COMM_WORLD, &req); continue; } myLatestCopy = record[newsid].latestCopy; //He has the latest copy if(update->timestamp > myLatestCopy->timestamp) { copyNewsStructure(record[newsid].latestCopy, update); record[newsid].ready = 0; // Message tempMsg; // tempMsg.messageType = 2; // tempMsg.update = update; msg.messageType = 2; printf("sending back positive feedback.\n"); msg.source = myid; MPI_Isend(&msg, 1, messagetype, reporter+numEditors, newsid, MPI_COMM_WORLD, &req); continue; } //we have the same copy else if(update->timestamp == myLatestCopy->timestamp) { //He has smaller id. Positive feedback. if(reporter < id) { // Message tempMsg; // tempMsg.messageType = 2; // tempMsg.update = update; msg.messageType = 2; printf("sending back positive feedback.\n"); msg.source = myid; MPI_Isend(&msg, 1, messagetype, reporter+numEditors, newsid, MPI_COMM_WORLD, &req); continue; } //I have smaller id. Negative feedback. else { // Message tempMsg; // tempMsg.messageType = 3; // tempMsg.update = update; msg.messageType = 3; printf("sending back negative feedback.\n"); msg.source = myid; MPI_Isend(&msg, 1, messagetype, reporter+numEditors, newsid, MPI_COMM_WORLD, &req); continue; } } //I have the latest copy else { // Message tempMsg; // tempMsg.messageType = 3; // tempMsg.update = record[newsid].latestCopy; msg.messageType = 3; printf("sending back negative feedback.\n"); copyNewsStructure(&(msg.update), record[newsid].latestCopy); msg.source = myid; MPI_Isend(&msg, 1, messagetype, reporter+numEditors, newsid, MPI_COMM_WORLD, &req); continue; } } //Positive response from a reporter else if(msg.messageType==2) { //Drop the response if not expecting any. if(record[newsid].ready == 0) continue; printf("reporter: %d responded positive for news: %d with time: %d\n", reporter, newsid, record[newsid].latestCopy->timestamp); //see if expecting this specific response MPI_Request_get_status(record[newsid].rqst[reporter-1] , &rqstCheck, &stat); if(rqstCheck!=0) { printf("counting this response.\n"); record[newsid].ready--; if(record[newsid].ready==0) { printf("all responses recieved for news: %d with time: %d\n", newsid, record[newsid].latestCopy->timestamp); // Message tempMsg; // tempMsg.messageType = 0; // tempMsg.update = record[newsid].latestCopy; msg.messageType = 0; copyNewsStructure(&(msg.update), record[newsid].latestCopy); msg.source = myid; MPI_Isend(&msg, 1, messagetype, editor, newsid, MPI_COMM_WORLD, &req); } } } //Negative response from a reporter else if(msg.messageType==3) { printf("reporter: %d responded negative for news: %d with time: %d and latest time is: %d\n", reporter, newsid, record[newsid].latestCopy->timestamp, msg.update.timestamp); record[newsid].ready = 0; copyNewsStructure(record[newsid].latestCopy, &(msg.update)); } } } break; } MPI_Finalize(); } int main(int argc, char *argv[]) { time_t t; //EditorReportMap ermap = {0}; //EditorReportMap* emap = &ermap; srand((unsigned int) time(&t)); //EditorReportMap* ermap = (EditorReportMap*)malloc(sizeof(EditorReportMap)); //doEditorReporterMapping(ermap); //printEditorReporterMapping(ermap); //doEditorReporterMapping(emap); //printEditorReporterMapping(emap); BNPM(&argc, &argv); }
28.518931
200
0.614487
[ "object" ]
83e15ded537ead71657f1c1fdc3873e4a31d4e46
539
h
C
Engine/source/EtFramework/Systems/ModelInit.h
NeroBurner/ETEngine
3fe039ff65cd1355957bcfce3f851fa411a86d94
[ "MIT" ]
552
2017-08-21T18:12:52.000Z
2022-03-31T15:41:56.000Z
Engine/source/EtFramework/Systems/ModelInit.h
NeroBurner/ETEngine
3fe039ff65cd1355957bcfce3f851fa411a86d94
[ "MIT" ]
14
2017-08-07T23:36:13.000Z
2021-05-10T08:41:19.000Z
Engine/source/EtFramework/Systems/ModelInit.h
NeroBurner/ETEngine
3fe039ff65cd1355957bcfce3f851fa411a86d94
[ "MIT" ]
40
2017-10-10T14:42:22.000Z
2022-03-10T07:14:33.000Z
#pragma once #include <EtFramework/Components/ModelComponent.h> #include <EtFramework/ECS/EcsController.h> namespace et { namespace fw { //------------- // ModelInit // // Events for adding and removing model components from the scene // class ModelInit final { public: static void OnComponentAdded(EcsController& controller, ModelComponent& component, T_EntityId const entity); static void OnComponentRemoved(EcsController& controller, ModelComponent& component, T_EntityId const entity); }; } // namespace fw } // namespace et
20.730769
111
0.755102
[ "model" ]
83e680193603ef414d842fdd59771714ecb04ab7
2,155
h
C
cpp/secretcode/ModelTracker.h
CodeApprenticeRai/newt
0e07a87aa6b8d4b238c1a9fd3fef363133866c57
[ "Apache-2.0" ]
1
2021-06-21T12:23:55.000Z
2021-06-21T12:23:55.000Z
cpp/secretcode/ModelTracker.h
CodeApprenticeRai/newt
0e07a87aa6b8d4b238c1a9fd3fef363133866c57
[ "Apache-2.0" ]
null
null
null
cpp/secretcode/ModelTracker.h
CodeApprenticeRai/newt
0e07a87aa6b8d4b238c1a9fd3fef363133866c57
[ "Apache-2.0" ]
6
2019-10-17T21:16:21.000Z
2020-10-19T08:27:01.000Z
/* * ModelTracker: a simple class that gets the exchange of a symbol from the parameter-file and keeps it * ModelTracker: keeps a ModelTracker for each symbol referred to by DataManager * Adapted from ExchangeTracker code * */ #ifndef _MODELTRACKER_H_ #define _MODELTRACKER_H_ #include <vector> #include <string> #include "Markets.h" #include <vector> #include <string> using std::vector; using std::string; /// An exchange-tracker for a single particular symbol class SymbolModelTracker { public: typedef std::string key_type; // the key-word "key_type" is used in clite::util::file_table /// returns the symbol this line refers to std::string const &get_key() const { return _symbol; } /// fields - those in the line dedicated to a specific symbol; fieldNames - the header line (ignored for now) SymbolModelTracker( const vector<string>& fieldNames, const vector<string>& fields ); /// for manual initialization SymbolModelTracker( const string& symbol ); SymbolModelTracker( const char* symbol ); double linearBlend( double _q, double _p2, double _h1, double _h2, double _dpq, double _dpull, double _dpsd, double _ltm, double _imb, double _excessimb, double _aspd); int snprint(char *s, int n) const; void print(); double cutoff; bool valid; protected: string _symbol; double k; double r; double meany; double stdy; double c,q,p2,h1,h2,dpull,dpq,dspd,ltm,crimb,aspd,excessimb; }; class ModelTracker; /// An exchange-tracker for all symbols referred to by DataManager class ModelTracker { public: /// create an exchange-tracker from the "exchanges" file using file_table, and completing it with default values for all those /// symbols that were not found in the file ModelTracker(); virtual ~ModelTracker(); SymbolModelTracker * getModel(int cid) { return _data[cid]; } void print(); void setallCutoffs(double cutoff); bool modelApplies( int cid ){ return (_enabled && _data[cid]->valid);} void enable( bool b) { _enabled = b; } private: vector<SymbolModelTracker*> _data; bool _enabled; }; # endif // _MODELTRACKER_H_
25.654762
129
0.716009
[ "vector" ]
83ee9266f1bbee1a65af1399d9853033d694452d
5,785
h
C
old-junk/libicp/src/kdtree.h
chipbuster/skull-atlas
7f3ee009e1d5f65f101fe853a2cf6e12662970ee
[ "BSD-3-Clause" ]
40
2015-02-24T23:02:49.000Z
2022-03-18T01:37:42.000Z
old-junk/libicp/src/kdtree.h
chipbuster/skull-atlas
7f3ee009e1d5f65f101fe853a2cf6e12662970ee
[ "BSD-3-Clause" ]
3
2018-10-19T04:46:11.000Z
2022-03-25T10:38:31.000Z
old-junk/libicp/src/kdtree.h
chipbuster/skull-atlas
7f3ee009e1d5f65f101fe853a2cf6e12662970ee
[ "BSD-3-Clause" ]
21
2016-01-13T21:03:52.000Z
2020-07-26T12:23:01.000Z
#ifndef __KDTREE_HPP #define __KDTREE_HPP // (c) Matthew B. Kennel, Institute for Nonlinear Science, UCSD (2004) // // Licensed under the Academic Free License version 1.1 found in file LICENSE // with additional provisions in that same file. // // Implement a kd tree for fast searching of points in a fixed data base // in k-dimensional Euclidean space. #include <vector> #include <algorithm> #include <boost/multi_array.hpp> #include <boost/array.hpp> namespace kdtree { typedef boost::multi_array<float, 2> KDTreeArray; typedef boost::const_multi_array_ref<float, 2> KDTreeROArray; typedef struct { float lower, upper; } interval; // let the compiler know that this is a names of classes. class KDTreeNode; class SearchRecord; struct KDTreeResult { public: float dis; // square distance int idx; // neighbor index }; class KDTreeResultVector : public std::vector<KDTreeResult> { // inherit a std::vector<KDTreeResult> // but, optionally maintain it in heap form as a priority // queue. public: // // add one new element to the list of results, and // keep it in heap order. To keep it in ordinary, as inserted, // order, then simply use push_back() as inherited // via std::vector<> void push_element_and_heapify(KDTreeResult&); float replace_maxpri_elt_return_new_maxpri(KDTreeResult&); float max_value(); // return the distance which has the maximum value of all on list, // assuming that ALL insertions were made by // push_element_and_heapify() }; class KDTree { public: const KDTreeArray& the_data; // "the_data" is a reference to the underlying multi_array of the // data to be included in the tree. // // NOTE: this structure does *NOT* own the storage underlying this. // Hence, it would be a very bad idea to change the underlying data // during use of the search facilities of this tree. // Also, the user must deallocate the memory underlying it. const int N; // number of data points int dim; bool sort_results; // sorting result? const bool rearrange; // are we rearranging? public: // constructor, has optional 'dim_in' feature, to use only // first 'dim_in' components for definition of nearest neighbors. KDTree(KDTreeArray& data_in, bool rearrange_in = true, int dim_in=-1); // destructor ~KDTree(); public: void n_nearest_brute_force(std::vector<float>& qv, int nn, KDTreeResultVector& result); // search for n nearest to a given query vector 'qv' usin // exhaustive slow search. For debugging, usually. void n_nearest(std::vector<float>& qv, int nn, KDTreeResultVector& result); // search for n nearest to a given query vector 'qv'. void n_nearest_around_point(int idxin, int correltime, int nn, KDTreeResultVector& result); // search for 'nn' nearest to point [idxin] of the input data, excluding // neighbors within correltime void r_nearest(std::vector<float>& qv, float r2, KDTreeResultVector& result); // search for all neighbors in ball of size (square Euclidean distance) // r2. Return number of neighbors in 'result.size()', void r_nearest_around_point(int idxin, int correltime, float r2, KDTreeResultVector& result); // like 'r_nearest', but around existing point, with decorrelation // interval. int r_count(std::vector<float>& qv, float r2); // count number of neighbors within square distance r2. int r_count_around_point(int idxin, int correltime, float r2); // like r_count, c friend class KDTreeNode; friend class SearchRecord; private: KDTreeNode* root; // the root pointer const KDTreeArray* data; // pointing either to the_data or an internal // rearranged data as necessary std::vector<int> ind; // the index for the tree leaves. Data in a leaf with bounds [l,u] are // in 'the_data[ind[l],*] to the_data[ind[u],*] KDTreeArray rearranged_data; // if rearrange is true then this is the rearranged data storage. static const int bucketsize = 12; // global constant. private: void set_data(KDTreeArray& din); void build_tree(); // builds the tree. Used upon construction. KDTreeNode* build_tree_for_range(int l, int u, KDTreeNode* parent); void select_on_coordinate(int c, int k, int l, int u); int select_on_coordinate_value(int c, float alpha, int l, int u); void spread_in_coordinate(int c, int l, int u, interval& interv); }; class KDTreeNode { public: KDTreeNode(int dim); ~KDTreeNode(); private: // visible to self and KDTree. friend class KDTree; // allow kdtree to access private data int cut_dim; // dimension to cut; float cut_val, cut_val_left, cut_val_right; //cut value int l, u; // extents in index array for searching std::vector<interval> box; // [min,max] of the box enclosing all points KDTreeNode *left, *right; // pointers to left and right nodes. void search(SearchRecord& sr); // recursive innermost core routine for searching.. bool box_in_search_range(SearchRecord& sr); // return true if the bounding box for this node is within the // search range given by the searchvector and maximum ballsize in 'sr'. void check_query_in_bound(SearchRecord& sr); // debugging only // for processing final buckets. void process_terminal_node(SearchRecord& sr); void process_terminal_node_fixedball(SearchRecord& sr); }; } // namespace kdtree #endif
32.683616
91
0.671219
[ "vector" ]
83f3f4a9f8a81fa6206198480219f576a76b8eb3
1,290
h
C
Spectrum/src/EditorLayer.h
CalSeedy/Cherenkov-Engine
d6d95feae207a9a4a10fef521768943c6b891025
[ "Apache-2.0" ]
null
null
null
Spectrum/src/EditorLayer.h
CalSeedy/Cherenkov-Engine
d6d95feae207a9a4a10fef521768943c6b891025
[ "Apache-2.0" ]
null
null
null
Spectrum/src/EditorLayer.h
CalSeedy/Cherenkov-Engine
d6d95feae207a9a4a10fef521768943c6b891025
[ "Apache-2.0" ]
null
null
null
#pragma once #include <Cherenkov.h> #include "Panels/SceneHierarchy.h" #include "Panels/EntityProperties.h" namespace Cherenkov { class EditorLayer : public Layer { Ref<Scene> m_ActiveScene; // Assets for rendering Ref<Shader> m_Shader; Ref<Texture2D> m_Texture; Ref<VertexArray> m_VertexArray; // Framebuffer/viewport EditorCamera m_EditorCamera; Ref<Framebuffer> m_Framebuffer; glm::vec2 m_VpBounds[2]; bool m_VpFocused = false; bool m_VpHovered = false; glm::vec2 m_VpSize = {0, 0}; // Profiling struct ProfileResult { const char* Name; float Time; }; std::vector<ProfileResult> m_Results; // Panels/Guizmos int m_GuizmoOp = -1; std::string m_SavePath{}; SceneHierarchy m_SceneHierarchy; EntityProperties m_Properties; bool onKeyPressed(KeyPressedEvent& ev); bool onMouseButtonPressed(MouseButtonPressedEvent& ev); void openScene(); void saveScene(); void saveAs(); void newScene(); public: EditorLayer(); virtual ~EditorLayer() = default; virtual void onUpdate(Timestep dt) override; void onImGuiDraw() override; void onEvent(Event& ev) override; virtual void onAttach() override; virtual void onDetach() override; }; }
23.888889
57
0.68062
[ "vector" ]
8602e112ad35d1af0527e5eed80b155c3e956875
963
h
C
SDLSandbox/SDLSandbox/Source/Controller/PauseState.h
kyuuzou/poison-strike
f9d0c41575ed94fd725ca48457e0eb54bf58cc4d
[ "MIT" ]
null
null
null
SDLSandbox/SDLSandbox/Source/Controller/PauseState.h
kyuuzou/poison-strike
f9d0c41575ed94fd725ca48457e0eb54bf58cc4d
[ "MIT" ]
null
null
null
SDLSandbox/SDLSandbox/Source/Controller/PauseState.h
kyuuzou/poison-strike
f9d0c41575ed94fd725ca48457e0eb54bf58cc4d
[ "MIT" ]
1
2022-03-16T23:01:04.000Z
2022-03-16T23:01:04.000Z
/* * Miniclip Challenge: Poison Strike * @author Nelson Rodrigues */ #pragma once #include "GameState.h" #include <vector> namespace Challenge { class GameObject; class PauseState : public GameState { public: virtual std::string getStateFile () const override; virtual std::string getStateID () const override; virtual bool onEnter () override; virtual bool onExit () override; virtual void render () override; virtual void update () override; private: static const std::string file; static const std::string id; /// <summary> /// Switches to the main menu state. /// </summary> static void onPressedMainMenu (); /// <summary> /// Toggles whether the sounds and music are muted. /// </summary> static void onPressedMute (); /// <summary> /// Resumes the game level from where it left off. /// </summary> static void onPressedResume (); }; }
21.4
55
0.635514
[ "render", "vector" ]
8605d991c8eaaf4751b0ac11bb5375229782ddda
3,200
h
C
native/avos/external/android/include/21/frameworks/av/include/media/stagefright/MediaCodecList.h
goyourfly/NovaCustom
c55265060a84b7b5b1f4b42ae096370205c66ad7
[ "Apache-2.0" ]
7
2017-07-13T10:34:54.000Z
2021-04-16T05:40:35.000Z
native/avos/external/android/include/21/frameworks/av/include/media/stagefright/MediaCodecList.h
goyourfly/NovaCustom
c55265060a84b7b5b1f4b42ae096370205c66ad7
[ "Apache-2.0" ]
1
2020-02-05T22:19:24.000Z
2020-02-05T22:19:24.000Z
native/avos/external/android/include/21/frameworks/av/include/media/stagefright/MediaCodecList.h
goyourfly/NovaCustom
c55265060a84b7b5b1f4b42ae096370205c66ad7
[ "Apache-2.0" ]
9
2017-07-13T12:33:20.000Z
2021-06-19T02:46:48.000Z
/* * Copyright 2012, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MEDIA_CODEC_LIST_H_ #define MEDIA_CODEC_LIST_H_ #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/AString.h> #include <media/IMediaCodecList.h> #include <media/IOMX.h> #include <media/MediaCodecInfo.h> #include <sys/types.h> #include <utils/Errors.h> #include <utils/KeyedVector.h> #include <utils/Vector.h> #include <utils/StrongPointer.h> namespace android { struct AMessage; struct MediaCodecList : public BnMediaCodecList { static sp<IMediaCodecList> getInstance(); virtual ssize_t findCodecByType( const char *type, bool encoder, size_t startIndex = 0) const; virtual ssize_t findCodecByName(const char *name) const; virtual size_t countCodecs() const; virtual sp<MediaCodecInfo> getCodecInfo(size_t index) const { return mCodecInfos.itemAt(index); } // to be used by MediaPlayerService alone static sp<IMediaCodecList> getLocalInstance(); private: enum Section { SECTION_TOPLEVEL, SECTION_DECODERS, SECTION_DECODER, SECTION_DECODER_TYPE, SECTION_ENCODERS, SECTION_ENCODER, SECTION_ENCODER_TYPE, SECTION_INCLUDE, }; static sp<IMediaCodecList> sCodecList; static sp<IMediaCodecList> sRemoteList; status_t mInitCheck; Section mCurrentSection; Vector<Section> mPastSections; int32_t mDepth; AString mHrefBase; Vector<sp<MediaCodecInfo> > mCodecInfos; sp<MediaCodecInfo> mCurrentInfo; sp<IOMX> mOMX; MediaCodecList(); ~MediaCodecList(); status_t initCheck() const; void parseXMLFile(const char *path); void parseTopLevelXMLFile(const char *path); static void StartElementHandlerWrapper( void *me, const char *name, const char **attrs); static void EndElementHandlerWrapper(void *me, const char *name); void startElementHandler(const char *name, const char **attrs); void endElementHandler(const char *name); status_t includeXMLFile(const char **attrs); status_t addMediaCodecFromAttributes(bool encoder, const char **attrs); void addMediaCodec(bool encoder, const char *name, const char *type = NULL); status_t addQuirk(const char **attrs); status_t addTypeFromAttributes(const char **attrs); status_t addLimit(const char **attrs); status_t addFeature(const char **attrs); void addType(const char *name); status_t initializeCapabilities(const char *type); DISALLOW_EVIL_CONSTRUCTORS(MediaCodecList); }; } // namespace android #endif // MEDIA_CODEC_LIST_H_
28.318584
80
0.7225
[ "vector" ]
860961ebba7905c3162705d380295dc01803cb05
3,499
h
C
src/chrome/browser/chromeos/drive/cache_metadata.h
jxjnjjn/chromium
435c1d02fd1b99001dc9e1e831632c894523580d
[ "Apache-2.0" ]
9
2018-09-21T05:36:12.000Z
2021-11-15T15:14:36.000Z
src/chrome/browser/chromeos/drive/cache_metadata.h
jxjnjjn/chromium
435c1d02fd1b99001dc9e1e831632c894523580d
[ "Apache-2.0" ]
null
null
null
src/chrome/browser/chromeos/drive/cache_metadata.h
jxjnjjn/chromium
435c1d02fd1b99001dc9e1e831632c894523580d
[ "Apache-2.0" ]
3
2018-11-28T14:54:13.000Z
2020-07-02T07:36:07.000Z
// 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 CHROME_BROWSER_CHROMEOS_DRIVE_CACHE_METADATA_H_ #define CHROME_BROWSER_CHROMEOS_DRIVE_CACHE_METADATA_H_ #include <map> #include <string> #include <vector> #include "base/callback_forward.h" #include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" namespace base { class SequencedTaskRunner; } // namespace base namespace drive { class CacheEntry; // Callback for Iterate(). typedef base::Callback<void(const std::string& resource_id, const CacheEntry& cache_entry)> CacheIterateCallback; // CacheMetadata is interface to maintain metadata of DriveCache's cached // files. This class only manages metadata. File operations are done by // DriveCache. // All member access including ctor and dtor must be made on the blocking pool. class CacheMetadata { public: // A map table of cache file's resource id to its CacheEntry* entry. typedef std::map<std::string, CacheEntry> CacheMap; // Database path. static const base::FilePath::CharType* kCacheMetadataDBPath; virtual ~CacheMetadata(); // Creates CacheMetadata instance. static scoped_ptr<CacheMetadata> CreateCacheMetadata( base::SequencedTaskRunner* blocking_task_runner); // Creates CacheMetadata instance. This uses FakeCacheMetadata, // which is an in-memory implementation and faster than CacheMetadataDB. static scoped_ptr<CacheMetadata> CreateCacheMetadataForTesting( base::SequencedTaskRunner* blocking_task_runner); // Initialize the cache metadata store. Returns true on success. virtual bool Initialize(const std::vector<base::FilePath>& cache_paths) = 0; // Adds a new cache entry corresponding to |resource_id| if it doesn't // exist, otherwise update the existing entry. virtual void AddOrUpdateCacheEntry(const std::string& resource_id, const CacheEntry& cache_entry) = 0; // Removes entry corresponding to |resource_id| from cache map. virtual void RemoveCacheEntry(const std::string& resource_id) = 0; // Gets the cache entry for file corresponding to |resource_id| and |md5| // and returns true if entry exists in cache map. Otherwise, returns false. // |md5| can be empty if only matching |resource_id| is desired, which may // happen when looking for pinned entries where symlinks' filenames have no // extension and hence no md5. virtual bool GetCacheEntry(const std::string& resource_id, const std::string& md5, CacheEntry* entry) = 0; // Removes temporary files (files in CACHE_TYPE_TMP) from the cache map. virtual void RemoveTemporaryFiles() = 0; // Iterates over all the cache entries synchronously. |callback| is called // on each cache entry. virtual void Iterate(const CacheIterateCallback& callback) = 0; protected: explicit CacheMetadata(base::SequencedTaskRunner* blocking_task_runner); // Checks whether the current thread is on the right sequenced worker pool // with the right sequence ID. If not, DCHECK will fail. void AssertOnSequencedWorkerPool(); private: scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; DISALLOW_COPY_AND_ASSIGN(CacheMetadata); }; } // namespace drive #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CACHE_METADATA_H_
36.072165
79
0.742498
[ "vector" ]
860e65a5094e23d29926ad1af43f04050088983e
1,150
h
C
dlls/npcs/CSentry.h
sohl-modders/halflife-vs2019-sohl12
d6c1d6c0e690e6045ebc03d1d728678be762aec9
[ "Unlicense" ]
null
null
null
dlls/npcs/CSentry.h
sohl-modders/halflife-vs2019-sohl12
d6c1d6c0e690e6045ebc03d1d728678be762aec9
[ "Unlicense" ]
null
null
null
dlls/npcs/CSentry.h
sohl-modders/halflife-vs2019-sohl12
d6c1d6c0e690e6045ebc03d1d728678be762aec9
[ "Unlicense" ]
null
null
null
/*** * * Copyright (c) 1996-2001, Valve LLC. All rights reserved. * * This product contains software technology licensed from Id * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting * object code is restricted to non-commercial enhancements to products from * Valve LLC. All other use, distribution, or modification is prohibited * without written permission from Valve LLC. * ****/ #ifndef CSENTRY_H #define CSENTRY_H #ifndef CBASETURRET_H #include "CBaseTurret.h" #endif //========================================================= // Class definition of CSentry //========================================================= class CSentry : public CBaseTurret { public: void Spawn() override; void Precache() override; // other functions void Shoot(Vector& vecSrc, Vector& vecDirToEnemy) override; int TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) override; void EXPORT SentryTouch(CBaseEntity* pOther); void EXPORT SentryDeath(); }; #endif // CSENTRY_H
28.04878
110
0.674783
[ "object", "vector" ]
860f82b168b4e4e51487c99e5c6955b46778837a
640
h
C
src/linear_method/batch_scheduler.h
yipeiw/parameter_server
07cbfbf2dc727ee0787d7e66e58a1f7fd8333aff
[ "Apache-2.0" ]
null
null
null
src/linear_method/batch_scheduler.h
yipeiw/parameter_server
07cbfbf2dc727ee0787d7e66e58a1f7fd8333aff
[ "Apache-2.0" ]
null
null
null
src/linear_method/batch_scheduler.h
yipeiw/parameter_server
07cbfbf2dc727ee0787d7e66e58a1f7fd8333aff
[ "Apache-2.0" ]
null
null
null
#pragma once #include "linear_method/scheduler.h" #include "linear_method/batch_common.h" namespace PS { namespace LM { class BatchScheduler : public Scheduler, public BatchCommon { public: virtual void init(); virtual void run(); protected: virtual void runIteration(); virtual void showProgress(int iter); // feature block info, format: pair<fea_grp_id, fea_range> typedef std::vector<std::pair<int, Range<Key>>> FeatureBlocks; FeatureBlocks fea_blk_; std::vector<int> blk_order_; std::vector<int> prior_blk_order_; // global data information ExampleInfo g_train_info_; }; } // namespace LM } // namespace PS
22.857143
64
0.739063
[ "vector" ]
861af95c11b756e3193733290f95498ae409c71b
6,247
h
C
3rdParty/vcglib/vcg/complex/algorithms/point_outlier.h
TonyGauss/tg3DLib
d425e91567b9e1642e7411330738d8e2b0880a2b
[ "MIT" ]
1
2020-07-18T20:35:40.000Z
2020-07-18T20:35:40.000Z
3rdParty/vcglib/vcg/complex/algorithms/point_outlier.h
TonyGauss/tg3DLib
d425e91567b9e1642e7411330738d8e2b0880a2b
[ "MIT" ]
null
null
null
3rdParty/vcglib/vcg/complex/algorithms/point_outlier.h
TonyGauss/tg3DLib
d425e91567b9e1642e7411330738d8e2b0880a2b
[ "MIT" ]
null
null
null
/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2004-2015 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * * All rights reserved. * * * * 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 (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * ****************************************************************************/ #ifndef VCG_TRI_OUTLIERS__H #define VCG_TRI_OUTLIERS__H #include <vcg/space/index/kdtree/kdtree.h> namespace vcg { namespace tri { template <class MeshType> class OutlierRemoval { public: typedef typename MeshType::ScalarType ScalarType; typedef typename vcg::KdTree<ScalarType> KdTreeType; typedef typename vcg::KdTree<ScalarType>::PriorityQueue PriorityQueue; /** Compute an outlier probability value for each vertex of the mesh using the approch in the paper "LoOP: Local Outlier Probabilities". The outlier probability is stored in the vertex attribute "outlierScore". It use the input kdtree to find the kNearest of each vertex. "LoOP: local outlier probabilities" by Hans-Peter Kriegel et al. Proceedings of the 18th ACM conference on Information and knowledge management */ static void ComputeLoOPScore(MeshType& mesh, KdTreeType& kdTree, int kNearest) { vcg::tri::RequireCompactness(mesh); typename MeshType::template PerVertexAttributeHandle<ScalarType> outlierScore = tri::Allocator<MeshType>:: template GetPerVertexAttribute<ScalarType>(mesh, std::string("outlierScore")); typename MeshType::template PerVertexAttributeHandle<ScalarType> sigma = tri::Allocator<MeshType>:: template GetPerVertexAttribute<ScalarType>(mesh, std::string("sigma")); typename MeshType::template PerVertexAttributeHandle<ScalarType> plof = tri::Allocator<MeshType>:: template GetPerVertexAttribute<ScalarType>(mesh, std::string("plof")); #pragma omp parallel for schedule(dynamic, 10) for (size_t i = 0; i < mesh.vert.size(); i++) { PriorityQueue queue; kdTree.doQueryK(mesh.vert[i].cP(), kNearest, queue); ScalarType sum = 0; for (int j = 0; j < queue.getNofElements(); j++) sum += queue.getWeight(j); sum /= (queue.getNofElements()); sigma[i] = sqrt(sum); } float mean = 0; #pragma omp parallel for reduction(+: mean) schedule(dynamic, 10) for (size_t i = 0; i < mesh.vert.size(); i++) { PriorityQueue queue; kdTree.doQueryK(mesh.vert[i].cP(), kNearest, queue); ScalarType sum = 0; for (int j = 0; j < queue.getNofElements(); j++) sum += sigma[queue.getIndex(j)]; sum /= (queue.getNofElements()); plof[i] = sigma[i] / sum - 1.0f; mean += plof[i] * plof[i]; } mean /= mesh.vert.size(); mean = sqrt(mean); #pragma omp parallel for schedule(dynamic, 10) for (size_t i = 0; i < mesh.vert.size(); i++) { ScalarType value = plof[i] / (mean * sqrt(2.0f)); double dem = 1.0 + 0.278393 * value; dem += 0.230389 * value * value; dem += 0.000972 * value * value * value; dem += 0.078108 * value * value * value * value; ScalarType op = max(0.0, 1.0 - 1.0 / dem); outlierScore[i] = op; } tri::Allocator<MeshType>::DeletePerVertexAttribute(mesh, std::string("sigma")); tri::Allocator<MeshType>::DeletePerVertexAttribute(mesh, std::string("plof")); }; /** Select all the vertex of the mesh with an outlier probability above the input threshold [0.0, 1.0]. */ static int SelectLoOPOutliers(MeshType& mesh, KdTreeType& kdTree, int kNearest, float threshold) { ComputeLoOPScore(mesh, kdTree, kNearest); int count = 0; typename MeshType:: template PerVertexAttributeHandle<ScalarType> outlierScore = tri::Allocator<MeshType>::template GetPerVertexAttribute<ScalarType>(mesh, std::string("outlierScore")); for (int i = 0; i < mesh.vert.size(); i++) { if (outlierScore[i] > threshold) { mesh.vert[i].SetS(); count++; } } return count; } /** Delete all the vertex of the mesh with an outlier probability above the input threshold [0.0, 1.0]. */ static int DeleteLoOPOutliers(MeshType& m, KdTreeType& kdTree, int kNearest, float threshold) { SelectLoOPOutliers(m,kdTree,kNearest,threshold); int ovn = m.vn; for(typename MeshType::VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi) if((*vi).IsS() ) tri::Allocator<MeshType>::DeleteVertex(m,*vi); tri::Allocator<MeshType>::CompactVertexVector(m); tri::Allocator<MeshType>::DeletePerVertexAttribute(m, std::string("outlierScore")); return m.vn - ovn; } }; } // end namespace tri } // end namespace vcg #endif // VCG_TRI_OUTLIERS_H
42.496599
191
0.554026
[ "mesh" ]
861c161340289596019030ffbbfefceaf4f14d60
15,363
h
C
Future.h
otrempe/watchman
155d656ca218ca8d677638b8cdd3d9196d68a2d2
[ "Apache-2.0" ]
null
null
null
Future.h
otrempe/watchman
155d656ca218ca8d677638b8cdd3d9196d68a2d2
[ "Apache-2.0" ]
null
null
null
Future.h
otrempe/watchman
155d656ca218ca8d677638b8cdd3d9196d68a2d2
[ "Apache-2.0" ]
null
null
null
/* Copyright 2017-present Facebook, Inc. * Licensed under the Apache License, Version 2.0 */ #pragma once #include <condition_variable> #include <memory> #include <mutex> #include <vector> #include "Result.h" namespace watchman { // An executor is a very light abstraction over something that can run // some function. We use this to perform the WaitableResult callback // in some other context (eg: ThreadPool). In practice, this is used // to move the execution context for a .then call to a worker thread. struct Executor { virtual ~Executor() = default; virtual void run(std::function<void()>&& func) = 0; }; // WaitableResult<T> encapsulates a Result<T> and allows waiting and notifying // and interested party. You are not expected to create an instance of this // class directly; it is used as the shared state between the Promise and // Future classes. template <typename T> class WaitableResult : public std::enable_shared_from_this<WaitableResult<T>> { static_assert(!std::is_same<T, void>::value, "use Unit instead of void"); public: WaitableResult() = default; explicit WaitableResult(Result<T>&& t) : result_(std::move(t)) {} WaitableResult(const WaitableResult&) = delete; WaitableResult(WaitableResult&&) = delete; // Assign to the underlying Result<T>. // After assigning, dispatch any associated callback and notify any waiters template <typename U> void assign(U&& value) { std::unique_lock<std::mutex> lock(mutex_); result_ = Result<T>(std::forward<U>(value)); maybeCallback(std::move(lock)); } // Get a reference to the enclosed result Result<T>& result() { return result_; } // Wait until the result is no longer empty void wait() const { std::unique_lock<std::mutex> lock(mutex_); condition_.wait(lock, [&] { return !result_.empty(); }); } // Wait for up to the specified duration. // Returns true as soon as the result is no longer empty. // Returns false if the result is still empty after duration has // passed. template <class Rep, class Period> bool wait_for(const std::chrono::duration<Rep, Period>& duration) { std::unique_lock<std::mutex> lock(mutex_); return condition_.wait_for( lock, duration, [&] { return !result_.empty(); }); } // Associate a callback with the result. // This is intended for use by internal plumbing and a casual // user of a Future should not call this method; instead, // you want to use Future::then(). // // The callback will be dispatched when the assign() method // is called. If the assign() method was called prior to // setCallback(), it will be called by setCallback(). // // It is possible for the callback to fire twice for the // same Future if setExecutor() was used to assign an // executor that runs immediately, and if the callback // throws an exception. If this happens, callback will be // called a second time with the Result containing the // exception that it called previously. Throwing an // exception in that context will bubble up to the caller // of assign(). // // If you stick to Future::then(), you don't need to // worry about this. template <typename Func> void setCallback(Func&& func) { std::unique_lock<std::mutex> lock(mutex_); callback_ = std::forward<Func>(func); if (!result_.empty()) { maybeCallback(std::move(lock)); } } // Change the executor associated with the future void setExecutor(Executor* executor) { std::unique_lock<std::mutex> lock(mutex_); executor_ = executor; } private: Result<T> result_; mutable std::condition_variable condition_; mutable std::mutex mutex_; std::function<void(Result<T>&&)> callback_; Executor* executor_{nullptr}; // If a callback is set, call it. // Then notify any waiters that the result is available. void maybeCallback(std::unique_lock<std::mutex>&& lock) { if (result_.empty()) { return; } if (callback_) { // Ensure that we are kept alive while we dispatch the callback auto scope_guard = this->shared_from_this(); // Steal the callback std::function<void(Result<T> &&)> func; std::swap(func, callback_); // For safety, ensure that we are unlocked while calling the callback. // While the intent is that the executor run the callback in a // different thread context, it may choose to run something // immediately. lock.unlock(); if (executor_) { try { // Unfortunately, have to make a copy of func here in // order to have sane exception handling executor_->run([scope_guard, this, func] { func(std::move(result_)); }); condition_.notify_all(); return; } catch (const std::exception& exc) { // We get here if executor_->run() threw an exception. // This is most likely to happen if the thread pool is // full, but we can't make any assumptions of the nature // of the exception; it may have simply run the callback // immediately, and we're just seeing the exception from // the callback here. // We're really only capturing this so that we can // propagate thread pool errors through the exception // chain. // Replace the current value with the exception, and we'll // dispatch the exception to the callback below. result_ = Result<T>(std::current_exception()); } } // We don't catch and propagate exceptions that this function // throws (like we do in the executor case above), because // the callback is supposed to manage exceptions and do // the right thing for itself. func(std::move(result_)); } condition_.notify_all(); } }; template <typename T> class Promise; template <typename T> class Future; // A little bit of helper glue for unwrapping Future<Future<T>> template <typename T> struct isFuture : std::false_type { using Inner = typename Unit::Lift<T>::type; }; template <typename T> struct isFuture<Future<T>> : std::true_type { using Inner = T; }; // Extracts the return type of a functor call template <typename F, typename... Args> using resultOf = decltype(std::declval<F>()(std::declval<Args>()...)); // The Future is the client side of the Promise/Future pair. // A Promise can return a single instance of a Future. The two // are linked by a shared WaitableResult object. // A Future is only safe for access from a single thread at a time. template <typename T> class Future { static_assert(!std::is_same<T, void>::value, "use Unit instead of void"); public: using value_type = T; Future() noexcept = default; // Moveable Future(Future&&) noexcept = default; Future& operator=(Future&&) noexcept = default; // Not copyable Future(const Future&) = delete; Future& operator=(const Future&) = delete; // makeFuture() uses this to build ready Future instances explicit Future(std::shared_ptr<WaitableResult<T>> state) : state_(state) {} // Block until the associated Promise is fulfilled void wait() const { if (!state_) { throw std::logic_error("Future has no shared state"); } state_->wait(); } // Wait for up to the specified duration for the associated Promise to // be fulfilled. // Returns true as soon as the Promise is fulfilled. // Returns false if the Promise was not fulfilled within the specified // duration. template <class Rep, class Period> bool wait_for(const std::chrono::duration<Rep, Period>& duration) const { if (!state_) { throw std::logic_error("Future has no shared state"); } return state_->wait_for(duration); } // Returns true if the associated Promise has been fulfilled. bool isReady() const { return this->wait_for(std::chrono::milliseconds(0)); } // Waits for the Promise to be fulfilled, then returns a reference // to the value in the promise. // If the Result holds an error this will cause the error to be // thrown. T& get() { return result().value(); } // As get() above, but returns a const reference. const T& get() const { return result().value(); } // Waits for the Promise to be fulfilled, then returns a reference // to the Result in the promise. Result<T>& result() { wait(); return state_->result(); } // Waits for the Promise to be fulfilled, then returns a const reference // to the Result in the promise. const Result<T>& result() const { wait(); return state_->result(); } // Chain a future together with some action to happen once // it is ready. // f.then([](Result<T>&& result) { return something; }) // This handles the case where something is not a Future<> template <typename Func> typename std::enable_if< !isFuture<resultOf<Func, Result<T>&&>>::value, Future<typename isFuture<resultOf<Func, Result<T>&&>>::Inner>>::type then(Func&& func) { using Ret = typename isFuture<resultOf<Func, Result<T>&&>>::Inner; struct thenState { Promise<Ret> promise; Func func; thenState(Func&& func) : func(std::forward<Func>(func)) {} }; auto state = std::make_shared<thenState>(std::forward<Func>(func)); auto result = state->promise.getFuture(); state_->setCallback([state](Result<T>&& result) { state->promise.setResult(makeResultWith( [&]() mutable { return state->func(std::move(result)); })); }); return result; } // Chain a future together with some action to happen once // it is ready. // f.then([](Result<T>&& result) { return something; }) // This handles the case where something is a Future<> and // unwraps it so that the result of .then is Future<> rather // than Future<Future<>>. template <typename Func> typename std::enable_if< isFuture<resultOf<Func, Result<T>&&>>::value, Future<typename isFuture<resultOf<Func, Result<T>&&>>::Inner>>::type then(Func&& func) { using Ret = resultOf<Func, Result<T>&&>; using InnerRet = typename isFuture<Ret>::Inner; struct thenState { Promise<InnerRet> promise; Func func; thenState(Func&& func) : func(std::forward<Func>(func)) {} }; auto state = std::make_shared<thenState>(std::forward<Func>(func)); auto result = state->promise.getFuture(); state_->setCallback([state](Result<T>&& res) { try { auto future = state->func(std::move(res)); future.setCallback([state](Result<InnerRet>&& res2) { state->promise.setResult(std::move(res2)); }); } catch (const std::exception& exc) { state->promise.setException(std::current_exception()); } }); return result; } // Exposes setCallback for .then when unwrapping Future<Future<>>. // Since Future<Future<T>> is a different class from Future<T>, // we have to make this public. // You probably want to use .then() and not this directly. template <typename Func> void setCallback(Func&& func) { state_->setCallback(std::forward<Func>(func)); } // Returns a future with its execution context switched to the provided // executor. A subsequent then() call will be dispatched by that // executor. Note that, depending on timing, this sequence: // makeFuture().via(exec).then(A).then(B) // will execute A in the context of exec, but may execute B either in // exec or the current context. If you need to ensure the execution // context for a then() call, you must precede it with a via() call // and supply the appropriate executor: // makeFuture().via(exec).then(A).via(exec).then(B) Future<T> via(Executor* executor) && { state_->setExecutor(executor); return std::move(*this); } private: std::shared_ptr<WaitableResult<T>> state_; }; // The Promise is the server side of the Promise/Future pair. template <typename T> class Promise { static_assert(!std::is_same<T, void>::value, "use Unit instead of void"); public: // Default construct to an un-fulfilled Promise Promise() : state_(std::make_shared<WaitableResult<T>>()) {} // Moveable Promise(Promise&&) noexcept = default; Promise& operator=(Promise&&) noexcept = default; // Copyable Promise(const Promise&) = delete; Promise& operator=(const Promise&) = delete; // Fulfills the promise with a value of type T. // Causes any waiters/callbacks associated with the Promise to be // notified/dispatched. // It is an error fulfill the same promise multiple times. void setValue(T&& value) { setResult(Result<T>(std::forward<T>(value))); } // Fulfills the promise with a Result<T>. // Causes any waiters/callbacks associated with the Promise to be // notified/dispatched. // It is an error fulfill the same promise multiple times. void setResult(Result<T>&& result) { if (assigned_) { throw std::logic_error("Promise already fulfilled"); } assigned_ = true; state_->assign(std::move(result)); } // Fulfills the promise with an exception. // Causes any waiters/callbacks associated with the Promise to be // notified/dispatched. // It is an error fulfill the same promise multiple times. void setException(std::exception_ptr exc) { setResult(Result<T>(exc)); } // Returns a Future associated with this Promise. The Future // allows a client to wait for the results. // It is an error to call getFuture() multiple times. Future<T> getFuture() { if (gotFuture_) { throw std::logic_error("Future already obtained"); } gotFuture_ = true; return Future<T>(state_); } private: std::shared_ptr<WaitableResult<T>> state_; bool gotFuture_{false}; bool assigned_{false}; }; // Convert a Result<T> to a Future<T> that is ready immediately template <typename T> Future<T> makeFuture(Result<T>&& t) { return Future<T>(std::make_shared<WaitableResult<T>>(std::move(t))); } // Helper for making an already fulfilled Future from a value; // auto-deduces the Value type. template <typename T> Future<typename std::decay<T>::type> makeFuture(T&& t) { return makeFuture(Result<typename std::decay<T>::type>(std::forward<T>(t))); } inline Future<Unit> makeFuture() { return makeFuture(Result<Unit>(Unit{})); } // Yields a Future holding a vector<Result<T>> for each of the input futures template <typename InputIterator> Future<std::vector<Result< typename std::iterator_traits<InputIterator>::value_type::value_type>>> collectAll(InputIterator first, InputIterator last) { using T = typename std::iterator_traits<InputIterator>::value_type::value_type; struct CollectAll { // Pre-allocate enough room for all results to avoid needing to // synchronize when the callback assigns everything CollectAll(size_t n) : results(n) {} // The destructor triggers the assignment and fulfillment of the Promise ~CollectAll() { p.setValue(std::move(results)); } Promise<std::vector<Result<T>>> p; std::vector<Result<T>> results; }; auto state = std::make_shared<CollectAll>(std::distance(first, last)); size_t i = 0; while (first != last) { first->setCallback([state, i](Result<T>&& result) { state->results[i] = std::move(result); }); ++i; ++first; } return state->p.getFuture(); } }
33.397826
79
0.670767
[ "object", "vector" ]
8621c23fa5c947909f5a4e4cc76b3b63aec0aee0
58,860
h
C
cdx/cdx_i.h
c-ohle/Apex-VSIX
966c7a281c208343a08fd39f5f4840fb113823c9
[ "Apache-2.0" ]
1
2021-06-27T10:19:42.000Z
2021-06-27T10:19:42.000Z
cdx/cdx_i.h
c-ohle/Apex-VSIX
966c7a281c208343a08fd39f5f4840fb113823c9
[ "Apache-2.0" ]
null
null
null
cdx/cdx_i.h
c-ohle/Apex-VSIX
966c7a281c208343a08fd39f5f4840fb113823c9
[ "Apache-2.0" ]
null
null
null
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 8.01.0622 */ /* at Tue Jan 19 04:14:07 2038 */ /* Compiler settings for cdx.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ /* @@MIDL_FILE_HEADING( ) */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 500 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif /* __RPCNDR_H_VERSION__ */ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __cdx_i_h__ #define __cdx_i_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef __ICDXView_FWD_DEFINED__ #define __ICDXView_FWD_DEFINED__ typedef interface ICDXView ICDXView; #endif /* __ICDXView_FWD_DEFINED__ */ #ifndef __ICDXSink_FWD_DEFINED__ #define __ICDXSink_FWD_DEFINED__ typedef interface ICDXSink ICDXSink; #endif /* __ICDXSink_FWD_DEFINED__ */ #ifndef __ICDXRoot_FWD_DEFINED__ #define __ICDXRoot_FWD_DEFINED__ typedef interface ICDXRoot ICDXRoot; #endif /* __ICDXRoot_FWD_DEFINED__ */ #ifndef __ICDXScene_FWD_DEFINED__ #define __ICDXScene_FWD_DEFINED__ typedef interface ICDXScene ICDXScene; #endif /* __ICDXScene_FWD_DEFINED__ */ #ifndef __ICDXNode_FWD_DEFINED__ #define __ICDXNode_FWD_DEFINED__ typedef interface ICDXNode ICDXNode; #endif /* __ICDXNode_FWD_DEFINED__ */ #ifndef __ICDXFont_FWD_DEFINED__ #define __ICDXFont_FWD_DEFINED__ typedef interface ICDXFont ICDXFont; #endif /* __ICDXFont_FWD_DEFINED__ */ #ifndef __ICDXBuffer_FWD_DEFINED__ #define __ICDXBuffer_FWD_DEFINED__ typedef interface ICDXBuffer ICDXBuffer; #endif /* __ICDXBuffer_FWD_DEFINED__ */ #ifndef __ICDXFactory_FWD_DEFINED__ #define __ICDXFactory_FWD_DEFINED__ typedef interface ICDXFactory ICDXFactory; #endif /* __ICDXFactory_FWD_DEFINED__ */ #ifndef __Factory_FWD_DEFINED__ #define __Factory_FWD_DEFINED__ #ifdef __cplusplus typedef class Factory Factory; #else typedef struct Factory Factory; #endif /* __cplusplus */ #endif /* __Factory_FWD_DEFINED__ */ /* header files for imported files */ #include "oaidl.h" #include "ocidl.h" #include "shobjidl.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_cdx_0000_0000 */ /* [local] */ #if(0) typedef IUnknown ICSGMesh; typedef DECIMAL CSGVAR; typedef DECIMAL XMFLOAT2; typedef DECIMAL XMFLOAT3; typedef DECIMAL XMFLOAT4; typedef DECIMAL XMFLOAT4X3; typedef DECIMAL XMFLOAT4X4; #endif typedef enum CDX_RENDER { CDX_RENDER_BOUNDINGBOX = 0x1, CDX_RENDER_COORDINATES = 0x2, CDX_RENDER_NORMALS = 0x4, CDX_RENDER_WIREFRAME = 0x8, CDX_RENDER_OUTLINES = 0x10, CDX_RENDER_SHADOWS = 0x400, CDX_RENDER_ZPLANESHADOWS = 0x800, CDX_RENDER_SELONLY = 0x1000, CDX_RENDER_FPS = 0x2000 } CDX_RENDER; typedef enum CDX_CMD { CDX_CMD_CENTER = 1, CDX_CMD_CENTERSEL = 2, CDX_CMD_GETBOX = 3, CDX_CMD_GETBOXSEL = 4, CDX_CMD_SETPLANE = 5, CDX_CMD_PICKPLANE = 6, CDX_CMD_SELECTRECT = 7, CDX_CMD_BOXESSET = 8, CDX_CMD_BOXESGET = 9, CDX_CMD_BOXESTRA = 10, CDX_CMD_BOXESIND = 11 } CDX_CMD; typedef enum CDX_DRAW { CDX_DRAW_ORTHOGRAPHIC = 0, CDX_DRAW_GET_TRANSFORM = 1, CDX_DRAW_SET_TRANSFORM = 2, CDX_DRAW_GET_COLOR = 3, CDX_DRAW_SET_COLOR = 4, CDX_DRAW_GET_FONT = 5, CDX_DRAW_SET_FONT = 6, CDX_DRAW_GET_TEXTURE = 7, CDX_DRAW_SET_TEXTURE = 8, CDX_DRAW_GET_MAPPING = 9, CDX_DRAW_SET_MAPPING = 10, CDX_DRAW_FILL_RECT = 11, CDX_DRAW_FILL_ELLIPSE = 12, CDX_DRAW_GET_TEXTEXTENT = 13, CDX_DRAW_DRAW_TEXT = 14, CDX_DRAW_DRAW_RECT = 15, CDX_DRAW_DRAW_POINTS = 16, CDX_DRAW_CATCH = 17, CDX_DRAW_DRAW_POLYLINE = 18, CDX_DRAW_DRAW_ELLIPSE = 19, CDX_DRAW_DRAW_BOX = 20 } CDX_DRAW; extern RPC_IF_HANDLE __MIDL_itf_cdx_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_cdx_0000_0000_v0_0_s_ifspec; #ifndef __ICDXView_INTERFACE_DEFINED__ #define __ICDXView_INTERFACE_DEFINED__ /* interface ICDXView */ /* [unique][uuid][object] */ EXTERN_C const IID IID_ICDXView; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("4C0EC273-CA2F-48F4-B871-E487E2774492") ICDXView : public IUnknown { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Samples( /* [retval][out] */ BSTR *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Samples( /* [in] */ BSTR p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_BkColor( /* [retval][out] */ UINT *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_BkColor( /* [in] */ UINT p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Render( /* [retval][out] */ CDX_RENDER *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Render( /* [in] */ CDX_RENDER p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Scene( /* [retval][out] */ ICDXScene **p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Scene( /* [in] */ ICDXScene *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Camera( /* [retval][out] */ ICDXNode **p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Camera( /* [in] */ ICDXNode *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_OverNode( /* [retval][out] */ ICDXNode **p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_OverId( /* [retval][out] */ UINT *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_OverPoint( /* [retval][out] */ XMFLOAT3 *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Dpi( /* [retval][out] */ UINT *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Fps( /* [retval][out] */ UINT *p) = 0; virtual HRESULT STDMETHODCALLTYPE Draw( /* [in] */ CDX_DRAW idc, /* [in] */ UINT *data) = 0; virtual HRESULT STDMETHODCALLTYPE Command( /* [in] */ CDX_CMD cmd, /* [in] */ UINT *data) = 0; virtual HRESULT STDMETHODCALLTYPE Thumbnail( /* [in] */ UINT dx, /* [in] */ UINT dy, /* [in] */ UINT samples, /* [in] */ UINT bkcolor, /* [in] */ IStream *str) = 0; }; #else /* C style interface */ typedef struct ICDXViewVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICDXView * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICDXView * This); ULONG ( STDMETHODCALLTYPE *Release )( ICDXView * This); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Samples )( ICDXView * This, /* [retval][out] */ BSTR *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Samples )( ICDXView * This, /* [in] */ BSTR p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_BkColor )( ICDXView * This, /* [retval][out] */ UINT *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_BkColor )( ICDXView * This, /* [in] */ UINT p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Render )( ICDXView * This, /* [retval][out] */ CDX_RENDER *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Render )( ICDXView * This, /* [in] */ CDX_RENDER p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Scene )( ICDXView * This, /* [retval][out] */ ICDXScene **p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Scene )( ICDXView * This, /* [in] */ ICDXScene *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Camera )( ICDXView * This, /* [retval][out] */ ICDXNode **p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Camera )( ICDXView * This, /* [in] */ ICDXNode *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_OverNode )( ICDXView * This, /* [retval][out] */ ICDXNode **p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_OverId )( ICDXView * This, /* [retval][out] */ UINT *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_OverPoint )( ICDXView * This, /* [retval][out] */ XMFLOAT3 *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Dpi )( ICDXView * This, /* [retval][out] */ UINT *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Fps )( ICDXView * This, /* [retval][out] */ UINT *p); HRESULT ( STDMETHODCALLTYPE *Draw )( ICDXView * This, /* [in] */ CDX_DRAW idc, /* [in] */ UINT *data); HRESULT ( STDMETHODCALLTYPE *Command )( ICDXView * This, /* [in] */ CDX_CMD cmd, /* [in] */ UINT *data); HRESULT ( STDMETHODCALLTYPE *Thumbnail )( ICDXView * This, /* [in] */ UINT dx, /* [in] */ UINT dy, /* [in] */ UINT samples, /* [in] */ UINT bkcolor, /* [in] */ IStream *str); END_INTERFACE } ICDXViewVtbl; interface ICDXView { CONST_VTBL struct ICDXViewVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICDXView_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ICDXView_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ICDXView_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ICDXView_get_Samples(This,p) \ ( (This)->lpVtbl -> get_Samples(This,p) ) #define ICDXView_put_Samples(This,p) \ ( (This)->lpVtbl -> put_Samples(This,p) ) #define ICDXView_get_BkColor(This,p) \ ( (This)->lpVtbl -> get_BkColor(This,p) ) #define ICDXView_put_BkColor(This,p) \ ( (This)->lpVtbl -> put_BkColor(This,p) ) #define ICDXView_get_Render(This,p) \ ( (This)->lpVtbl -> get_Render(This,p) ) #define ICDXView_put_Render(This,p) \ ( (This)->lpVtbl -> put_Render(This,p) ) #define ICDXView_get_Scene(This,p) \ ( (This)->lpVtbl -> get_Scene(This,p) ) #define ICDXView_put_Scene(This,p) \ ( (This)->lpVtbl -> put_Scene(This,p) ) #define ICDXView_get_Camera(This,p) \ ( (This)->lpVtbl -> get_Camera(This,p) ) #define ICDXView_put_Camera(This,p) \ ( (This)->lpVtbl -> put_Camera(This,p) ) #define ICDXView_get_OverNode(This,p) \ ( (This)->lpVtbl -> get_OverNode(This,p) ) #define ICDXView_get_OverId(This,p) \ ( (This)->lpVtbl -> get_OverId(This,p) ) #define ICDXView_get_OverPoint(This,p) \ ( (This)->lpVtbl -> get_OverPoint(This,p) ) #define ICDXView_get_Dpi(This,p) \ ( (This)->lpVtbl -> get_Dpi(This,p) ) #define ICDXView_get_Fps(This,p) \ ( (This)->lpVtbl -> get_Fps(This,p) ) #define ICDXView_Draw(This,idc,data) \ ( (This)->lpVtbl -> Draw(This,idc,data) ) #define ICDXView_Command(This,cmd,data) \ ( (This)->lpVtbl -> Command(This,cmd,data) ) #define ICDXView_Thumbnail(This,dx,dy,samples,bkcolor,str) \ ( (This)->lpVtbl -> Thumbnail(This,dx,dy,samples,bkcolor,str) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ICDXView_INTERFACE_DEFINED__ */ #ifndef __ICDXSink_INTERFACE_DEFINED__ #define __ICDXSink_INTERFACE_DEFINED__ /* interface ICDXSink */ /* [local][unique][uuid][object] */ EXTERN_C const IID IID_ICDXSink; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("982A1DBA-0C12-4342-8F58-A34D83956F0D") ICDXSink : public IUnknown { public: virtual void STDMETHODCALLTYPE Render( UINT fl) = 0; virtual void STDMETHODCALLTYPE Timer( void) = 0; virtual void STDMETHODCALLTYPE Animate( ICDXNode *p, UINT t) = 0; virtual void STDMETHODCALLTYPE Resolve( IUnknown *p, IStream *s) = 0; }; #else /* C style interface */ typedef struct ICDXSinkVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICDXSink * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICDXSink * This); ULONG ( STDMETHODCALLTYPE *Release )( ICDXSink * This); void ( STDMETHODCALLTYPE *Render )( ICDXSink * This, UINT fl); void ( STDMETHODCALLTYPE *Timer )( ICDXSink * This); void ( STDMETHODCALLTYPE *Animate )( ICDXSink * This, ICDXNode *p, UINT t); void ( STDMETHODCALLTYPE *Resolve )( ICDXSink * This, IUnknown *p, IStream *s); END_INTERFACE } ICDXSinkVtbl; interface ICDXSink { CONST_VTBL struct ICDXSinkVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICDXSink_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ICDXSink_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ICDXSink_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ICDXSink_Render(This,fl) \ ( (This)->lpVtbl -> Render(This,fl) ) #define ICDXSink_Timer(This) \ ( (This)->lpVtbl -> Timer(This) ) #define ICDXSink_Animate(This,p,t) \ ( (This)->lpVtbl -> Animate(This,p,t) ) #define ICDXSink_Resolve(This,p,s) \ ( (This)->lpVtbl -> Resolve(This,p,s) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ICDXSink_INTERFACE_DEFINED__ */ /* interface __MIDL_itf_cdx_0000_0002 */ /* [local] */ typedef enum CDX_UNIT { CDX_UNIT_UNDEF = 0, CDX_UNIT_METER = 1, CDX_UNIT_CENTIMETER = 2, CDX_UNIT_MILLIMETER = 3, CDX_UNIT_MICRON = 4, CDX_UNIT_FOOT = 5, CDX_UNIT_INCH = 6 } CDX_UNIT; extern RPC_IF_HANDLE __MIDL_itf_cdx_0000_0002_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_cdx_0000_0002_v0_0_s_ifspec; #ifndef __ICDXRoot_INTERFACE_DEFINED__ #define __ICDXRoot_INTERFACE_DEFINED__ /* interface ICDXRoot */ /* [unique][uuid][object] */ EXTERN_C const IID IID_ICDXRoot; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("344CC49E-4BBF-4F1E-A17A-55CBF848EED3") ICDXRoot : public IUnknown { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Child( /* [retval][out] */ ICDXNode **p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Count( /* [retval][out] */ UINT *p) = 0; virtual HRESULT STDMETHODCALLTYPE AddNode( /* [in] */ BSTR name, /* [retval][out] */ ICDXNode **p) = 0; virtual HRESULT STDMETHODCALLTYPE InsertAt( /* [in] */ UINT i, /* [in] */ ICDXNode *p) = 0; virtual HRESULT STDMETHODCALLTYPE RemoveAt( /* [in] */ UINT i) = 0; }; #else /* C style interface */ typedef struct ICDXRootVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICDXRoot * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICDXRoot * This); ULONG ( STDMETHODCALLTYPE *Release )( ICDXRoot * This); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Child )( ICDXRoot * This, /* [retval][out] */ ICDXNode **p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Count )( ICDXRoot * This, /* [retval][out] */ UINT *p); HRESULT ( STDMETHODCALLTYPE *AddNode )( ICDXRoot * This, /* [in] */ BSTR name, /* [retval][out] */ ICDXNode **p); HRESULT ( STDMETHODCALLTYPE *InsertAt )( ICDXRoot * This, /* [in] */ UINT i, /* [in] */ ICDXNode *p); HRESULT ( STDMETHODCALLTYPE *RemoveAt )( ICDXRoot * This, /* [in] */ UINT i); END_INTERFACE } ICDXRootVtbl; interface ICDXRoot { CONST_VTBL struct ICDXRootVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICDXRoot_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ICDXRoot_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ICDXRoot_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ICDXRoot_get_Child(This,p) \ ( (This)->lpVtbl -> get_Child(This,p) ) #define ICDXRoot_get_Count(This,p) \ ( (This)->lpVtbl -> get_Count(This,p) ) #define ICDXRoot_AddNode(This,name,p) \ ( (This)->lpVtbl -> AddNode(This,name,p) ) #define ICDXRoot_InsertAt(This,i,p) \ ( (This)->lpVtbl -> InsertAt(This,i,p) ) #define ICDXRoot_RemoveAt(This,i) \ ( (This)->lpVtbl -> RemoveAt(This,i) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ICDXRoot_INTERFACE_DEFINED__ */ #ifndef __ICDXScene_INTERFACE_DEFINED__ #define __ICDXScene_INTERFACE_DEFINED__ /* interface ICDXScene */ /* [unique][uuid][object] */ EXTERN_C const IID IID_ICDXScene; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("98068F4F-7768-484B-A2F8-21D4F7B5D811") ICDXScene : public ICDXRoot { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Camera( /* [retval][out] */ ICDXNode **p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Camera( /* [in] */ ICDXNode *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Tag( /* [retval][out] */ IUnknown **p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Tag( /* [in] */ IUnknown *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Unit( /* [retval][out] */ CDX_UNIT *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Unit( /* [in] */ CDX_UNIT p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_SelectionCount( /* [retval][out] */ UINT *p) = 0; virtual HRESULT STDMETHODCALLTYPE GetSelection( /* [in] */ UINT i, /* [retval][out] */ ICDXNode **p) = 0; virtual HRESULT STDMETHODCALLTYPE Clear( void) = 0; virtual HRESULT STDMETHODCALLTYPE SaveToStream( /* [in] */ IStream *s, /* [optional][in] */ ICDXNode *cam) = 0; virtual HRESULT STDMETHODCALLTYPE LoadFromStream( /* [in] */ IStream *s) = 0; }; #else /* C style interface */ typedef struct ICDXSceneVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICDXScene * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICDXScene * This); ULONG ( STDMETHODCALLTYPE *Release )( ICDXScene * This); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Child )( ICDXScene * This, /* [retval][out] */ ICDXNode **p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Count )( ICDXScene * This, /* [retval][out] */ UINT *p); HRESULT ( STDMETHODCALLTYPE *AddNode )( ICDXScene * This, /* [in] */ BSTR name, /* [retval][out] */ ICDXNode **p); HRESULT ( STDMETHODCALLTYPE *InsertAt )( ICDXScene * This, /* [in] */ UINT i, /* [in] */ ICDXNode *p); HRESULT ( STDMETHODCALLTYPE *RemoveAt )( ICDXScene * This, /* [in] */ UINT i); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Camera )( ICDXScene * This, /* [retval][out] */ ICDXNode **p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Camera )( ICDXScene * This, /* [in] */ ICDXNode *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Tag )( ICDXScene * This, /* [retval][out] */ IUnknown **p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Tag )( ICDXScene * This, /* [in] */ IUnknown *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Unit )( ICDXScene * This, /* [retval][out] */ CDX_UNIT *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Unit )( ICDXScene * This, /* [in] */ CDX_UNIT p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_SelectionCount )( ICDXScene * This, /* [retval][out] */ UINT *p); HRESULT ( STDMETHODCALLTYPE *GetSelection )( ICDXScene * This, /* [in] */ UINT i, /* [retval][out] */ ICDXNode **p); HRESULT ( STDMETHODCALLTYPE *Clear )( ICDXScene * This); HRESULT ( STDMETHODCALLTYPE *SaveToStream )( ICDXScene * This, /* [in] */ IStream *s, /* [optional][in] */ ICDXNode *cam); HRESULT ( STDMETHODCALLTYPE *LoadFromStream )( ICDXScene * This, /* [in] */ IStream *s); END_INTERFACE } ICDXSceneVtbl; interface ICDXScene { CONST_VTBL struct ICDXSceneVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICDXScene_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ICDXScene_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ICDXScene_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ICDXScene_get_Child(This,p) \ ( (This)->lpVtbl -> get_Child(This,p) ) #define ICDXScene_get_Count(This,p) \ ( (This)->lpVtbl -> get_Count(This,p) ) #define ICDXScene_AddNode(This,name,p) \ ( (This)->lpVtbl -> AddNode(This,name,p) ) #define ICDXScene_InsertAt(This,i,p) \ ( (This)->lpVtbl -> InsertAt(This,i,p) ) #define ICDXScene_RemoveAt(This,i) \ ( (This)->lpVtbl -> RemoveAt(This,i) ) #define ICDXScene_get_Camera(This,p) \ ( (This)->lpVtbl -> get_Camera(This,p) ) #define ICDXScene_put_Camera(This,p) \ ( (This)->lpVtbl -> put_Camera(This,p) ) #define ICDXScene_get_Tag(This,p) \ ( (This)->lpVtbl -> get_Tag(This,p) ) #define ICDXScene_put_Tag(This,p) \ ( (This)->lpVtbl -> put_Tag(This,p) ) #define ICDXScene_get_Unit(This,p) \ ( (This)->lpVtbl -> get_Unit(This,p) ) #define ICDXScene_put_Unit(This,p) \ ( (This)->lpVtbl -> put_Unit(This,p) ) #define ICDXScene_get_SelectionCount(This,p) \ ( (This)->lpVtbl -> get_SelectionCount(This,p) ) #define ICDXScene_GetSelection(This,i,p) \ ( (This)->lpVtbl -> GetSelection(This,i,p) ) #define ICDXScene_Clear(This) \ ( (This)->lpVtbl -> Clear(This) ) #define ICDXScene_SaveToStream(This,s,cam) \ ( (This)->lpVtbl -> SaveToStream(This,s,cam) ) #define ICDXScene_LoadFromStream(This,s) \ ( (This)->lpVtbl -> LoadFromStream(This,s) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ICDXScene_INTERFACE_DEFINED__ */ /* interface __MIDL_itf_cdx_0000_0004 */ /* [local] */ typedef enum CDX_BUFFER { CDX_BUFFER_POINTBUFFER = 0, CDX_BUFFER_INDEXBUFFER = 1, CDX_BUFFER_TEXCOORDS = 2, CDX_BUFFER_PROPS = 3, CDX_BUFFER_RANGES = 4, CDX_BUFFER_SCRIPT = 10, CDX_BUFFER_TEXTURE = 16 } CDX_BUFFER; extern RPC_IF_HANDLE __MIDL_itf_cdx_0000_0004_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_cdx_0000_0004_v0_0_s_ifspec; #ifndef __ICDXNode_INTERFACE_DEFINED__ #define __ICDXNode_INTERFACE_DEFINED__ /* interface ICDXNode */ /* [unique][uuid][object] */ EXTERN_C const IID IID_ICDXNode; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("2BB87169-81D3-405E-9C16-E4C22177BBAA") ICDXNode : public ICDXRoot { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Name( /* [retval][out] */ BSTR *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Name( /* [in] */ BSTR p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Parent( /* [retval][out] */ ICDXRoot **p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Scene( /* [retval][out] */ ICDXScene **p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Next( /* [retval][out] */ ICDXNode **p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Index( /* [retval][out] */ UINT *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Index( /* [in] */ UINT p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_IsSelect( /* [retval][out] */ BOOL *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_IsSelect( /* [in] */ BOOL p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_IsStatic( /* [retval][out] */ BOOL *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_IsStatic( /* [in] */ BOOL p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_IsActive( /* [retval][out] */ BOOL *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_IsActive( /* [in] */ BOOL p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Transform( /* [retval][out] */ XMFLOAT4X3 *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Transform( /* [in] */ XMFLOAT4X3 p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Color( /* [retval][out] */ UINT *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Color( /* [in] */ UINT p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Texture( /* [retval][out] */ ICDXBuffer **p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Texture( /* [in] */ ICDXBuffer *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Tag( /* [retval][out] */ IUnknown **p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Tag( /* [in] */ IUnknown *p) = 0; virtual HRESULT STDMETHODCALLTYPE NextSibling( /* [in] */ ICDXNode *root, /* [retval][out] */ ICDXNode **p) = 0; virtual HRESULT STDMETHODCALLTYPE GetTransform( /* [in] */ ICDXNode *root, /* [retval][out] */ XMFLOAT4X3 *p) = 0; virtual HRESULT STDMETHODCALLTYPE HasBuffer( /* [in] */ CDX_BUFFER id, /* [retval][out] */ BOOL *p) = 0; virtual HRESULT STDMETHODCALLTYPE GetBuffer( /* [in] */ CDX_BUFFER id, /* [retval][out] */ ICDXBuffer **p) = 0; virtual HRESULT STDMETHODCALLTYPE SetBuffer( /* [in] */ CDX_BUFFER id, /* [in] */ ICDXBuffer *p) = 0; virtual HRESULT STDMETHODCALLTYPE GetBufferPtr( /* [in] */ CDX_BUFFER id, /* [in] */ const BYTE **p, /* [retval][out] */ UINT *n) = 0; virtual HRESULT STDMETHODCALLTYPE SetBufferPtr( /* [in] */ CDX_BUFFER id, /* [in] */ const BYTE *p, /* [in] */ UINT n) = 0; virtual HRESULT STDMETHODCALLTYPE GetBox( /* [out][in] */ XMFLOAT3 box[ 2 ], /* [in] */ const XMFLOAT4X3 *pm) = 0; virtual HRESULT STDMETHODCALLTYPE GetTypeTransform( /* [in] */ UINT typ, /* [retval][out] */ XMFLOAT4X3 *p) = 0; virtual HRESULT STDMETHODCALLTYPE SetTypeTransform( /* [in] */ UINT typ, /* [in] */ const XMFLOAT4X3 *p) = 0; virtual HRESULT STDMETHODCALLTYPE SetProp( /* [in] */ LPCWSTR s, /* [in] */ const BYTE *p, /* [in] */ UINT n, /* [in] */ UINT typ) = 0; virtual HRESULT STDMETHODCALLTYPE GetProp( /* [in] */ LPCWSTR s, /* [in] */ const BYTE **p, /* [out] */ UINT *typ, /* [retval][out] */ UINT *n) = 0; virtual HRESULT STDMETHODCALLTYPE GetProps( /* [retval][out] */ BSTR *p) = 0; }; #else /* C style interface */ typedef struct ICDXNodeVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICDXNode * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICDXNode * This); ULONG ( STDMETHODCALLTYPE *Release )( ICDXNode * This); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Child )( ICDXNode * This, /* [retval][out] */ ICDXNode **p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Count )( ICDXNode * This, /* [retval][out] */ UINT *p); HRESULT ( STDMETHODCALLTYPE *AddNode )( ICDXNode * This, /* [in] */ BSTR name, /* [retval][out] */ ICDXNode **p); HRESULT ( STDMETHODCALLTYPE *InsertAt )( ICDXNode * This, /* [in] */ UINT i, /* [in] */ ICDXNode *p); HRESULT ( STDMETHODCALLTYPE *RemoveAt )( ICDXNode * This, /* [in] */ UINT i); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Name )( ICDXNode * This, /* [retval][out] */ BSTR *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Name )( ICDXNode * This, /* [in] */ BSTR p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Parent )( ICDXNode * This, /* [retval][out] */ ICDXRoot **p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Scene )( ICDXNode * This, /* [retval][out] */ ICDXScene **p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Next )( ICDXNode * This, /* [retval][out] */ ICDXNode **p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Index )( ICDXNode * This, /* [retval][out] */ UINT *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Index )( ICDXNode * This, /* [in] */ UINT p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsSelect )( ICDXNode * This, /* [retval][out] */ BOOL *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_IsSelect )( ICDXNode * This, /* [in] */ BOOL p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsStatic )( ICDXNode * This, /* [retval][out] */ BOOL *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_IsStatic )( ICDXNode * This, /* [in] */ BOOL p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsActive )( ICDXNode * This, /* [retval][out] */ BOOL *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_IsActive )( ICDXNode * This, /* [in] */ BOOL p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Transform )( ICDXNode * This, /* [retval][out] */ XMFLOAT4X3 *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Transform )( ICDXNode * This, /* [in] */ XMFLOAT4X3 p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Color )( ICDXNode * This, /* [retval][out] */ UINT *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Color )( ICDXNode * This, /* [in] */ UINT p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Texture )( ICDXNode * This, /* [retval][out] */ ICDXBuffer **p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Texture )( ICDXNode * This, /* [in] */ ICDXBuffer *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Tag )( ICDXNode * This, /* [retval][out] */ IUnknown **p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Tag )( ICDXNode * This, /* [in] */ IUnknown *p); HRESULT ( STDMETHODCALLTYPE *NextSibling )( ICDXNode * This, /* [in] */ ICDXNode *root, /* [retval][out] */ ICDXNode **p); HRESULT ( STDMETHODCALLTYPE *GetTransform )( ICDXNode * This, /* [in] */ ICDXNode *root, /* [retval][out] */ XMFLOAT4X3 *p); HRESULT ( STDMETHODCALLTYPE *HasBuffer )( ICDXNode * This, /* [in] */ CDX_BUFFER id, /* [retval][out] */ BOOL *p); HRESULT ( STDMETHODCALLTYPE *GetBuffer )( ICDXNode * This, /* [in] */ CDX_BUFFER id, /* [retval][out] */ ICDXBuffer **p); HRESULT ( STDMETHODCALLTYPE *SetBuffer )( ICDXNode * This, /* [in] */ CDX_BUFFER id, /* [in] */ ICDXBuffer *p); HRESULT ( STDMETHODCALLTYPE *GetBufferPtr )( ICDXNode * This, /* [in] */ CDX_BUFFER id, /* [in] */ const BYTE **p, /* [retval][out] */ UINT *n); HRESULT ( STDMETHODCALLTYPE *SetBufferPtr )( ICDXNode * This, /* [in] */ CDX_BUFFER id, /* [in] */ const BYTE *p, /* [in] */ UINT n); HRESULT ( STDMETHODCALLTYPE *GetBox )( ICDXNode * This, /* [out][in] */ XMFLOAT3 box[ 2 ], /* [in] */ const XMFLOAT4X3 *pm); HRESULT ( STDMETHODCALLTYPE *GetTypeTransform )( ICDXNode * This, /* [in] */ UINT typ, /* [retval][out] */ XMFLOAT4X3 *p); HRESULT ( STDMETHODCALLTYPE *SetTypeTransform )( ICDXNode * This, /* [in] */ UINT typ, /* [in] */ const XMFLOAT4X3 *p); HRESULT ( STDMETHODCALLTYPE *SetProp )( ICDXNode * This, /* [in] */ LPCWSTR s, /* [in] */ const BYTE *p, /* [in] */ UINT n, /* [in] */ UINT typ); HRESULT ( STDMETHODCALLTYPE *GetProp )( ICDXNode * This, /* [in] */ LPCWSTR s, /* [in] */ const BYTE **p, /* [out] */ UINT *typ, /* [retval][out] */ UINT *n); HRESULT ( STDMETHODCALLTYPE *GetProps )( ICDXNode * This, /* [retval][out] */ BSTR *p); END_INTERFACE } ICDXNodeVtbl; interface ICDXNode { CONST_VTBL struct ICDXNodeVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICDXNode_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ICDXNode_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ICDXNode_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ICDXNode_get_Child(This,p) \ ( (This)->lpVtbl -> get_Child(This,p) ) #define ICDXNode_get_Count(This,p) \ ( (This)->lpVtbl -> get_Count(This,p) ) #define ICDXNode_AddNode(This,name,p) \ ( (This)->lpVtbl -> AddNode(This,name,p) ) #define ICDXNode_InsertAt(This,i,p) \ ( (This)->lpVtbl -> InsertAt(This,i,p) ) #define ICDXNode_RemoveAt(This,i) \ ( (This)->lpVtbl -> RemoveAt(This,i) ) #define ICDXNode_get_Name(This,p) \ ( (This)->lpVtbl -> get_Name(This,p) ) #define ICDXNode_put_Name(This,p) \ ( (This)->lpVtbl -> put_Name(This,p) ) #define ICDXNode_get_Parent(This,p) \ ( (This)->lpVtbl -> get_Parent(This,p) ) #define ICDXNode_get_Scene(This,p) \ ( (This)->lpVtbl -> get_Scene(This,p) ) #define ICDXNode_get_Next(This,p) \ ( (This)->lpVtbl -> get_Next(This,p) ) #define ICDXNode_get_Index(This,p) \ ( (This)->lpVtbl -> get_Index(This,p) ) #define ICDXNode_put_Index(This,p) \ ( (This)->lpVtbl -> put_Index(This,p) ) #define ICDXNode_get_IsSelect(This,p) \ ( (This)->lpVtbl -> get_IsSelect(This,p) ) #define ICDXNode_put_IsSelect(This,p) \ ( (This)->lpVtbl -> put_IsSelect(This,p) ) #define ICDXNode_get_IsStatic(This,p) \ ( (This)->lpVtbl -> get_IsStatic(This,p) ) #define ICDXNode_put_IsStatic(This,p) \ ( (This)->lpVtbl -> put_IsStatic(This,p) ) #define ICDXNode_get_IsActive(This,p) \ ( (This)->lpVtbl -> get_IsActive(This,p) ) #define ICDXNode_put_IsActive(This,p) \ ( (This)->lpVtbl -> put_IsActive(This,p) ) #define ICDXNode_get_Transform(This,p) \ ( (This)->lpVtbl -> get_Transform(This,p) ) #define ICDXNode_put_Transform(This,p) \ ( (This)->lpVtbl -> put_Transform(This,p) ) #define ICDXNode_get_Color(This,p) \ ( (This)->lpVtbl -> get_Color(This,p) ) #define ICDXNode_put_Color(This,p) \ ( (This)->lpVtbl -> put_Color(This,p) ) #define ICDXNode_get_Texture(This,p) \ ( (This)->lpVtbl -> get_Texture(This,p) ) #define ICDXNode_put_Texture(This,p) \ ( (This)->lpVtbl -> put_Texture(This,p) ) #define ICDXNode_get_Tag(This,p) \ ( (This)->lpVtbl -> get_Tag(This,p) ) #define ICDXNode_put_Tag(This,p) \ ( (This)->lpVtbl -> put_Tag(This,p) ) #define ICDXNode_NextSibling(This,root,p) \ ( (This)->lpVtbl -> NextSibling(This,root,p) ) #define ICDXNode_GetTransform(This,root,p) \ ( (This)->lpVtbl -> GetTransform(This,root,p) ) #define ICDXNode_HasBuffer(This,id,p) \ ( (This)->lpVtbl -> HasBuffer(This,id,p) ) #define ICDXNode_GetBuffer(This,id,p) \ ( (This)->lpVtbl -> GetBuffer(This,id,p) ) #define ICDXNode_SetBuffer(This,id,p) \ ( (This)->lpVtbl -> SetBuffer(This,id,p) ) #define ICDXNode_GetBufferPtr(This,id,p,n) \ ( (This)->lpVtbl -> GetBufferPtr(This,id,p,n) ) #define ICDXNode_SetBufferPtr(This,id,p,n) \ ( (This)->lpVtbl -> SetBufferPtr(This,id,p,n) ) #define ICDXNode_GetBox(This,box,pm) \ ( (This)->lpVtbl -> GetBox(This,box,pm) ) #define ICDXNode_GetTypeTransform(This,typ,p) \ ( (This)->lpVtbl -> GetTypeTransform(This,typ,p) ) #define ICDXNode_SetTypeTransform(This,typ,p) \ ( (This)->lpVtbl -> SetTypeTransform(This,typ,p) ) #define ICDXNode_SetProp(This,s,p,n,typ) \ ( (This)->lpVtbl -> SetProp(This,s,p,n,typ) ) #define ICDXNode_GetProp(This,s,p,typ,n) \ ( (This)->lpVtbl -> GetProp(This,s,p,typ,n) ) #define ICDXNode_GetProps(This,p) \ ( (This)->lpVtbl -> GetProps(This,p) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ICDXNode_INTERFACE_DEFINED__ */ #ifndef __ICDXFont_INTERFACE_DEFINED__ #define __ICDXFont_INTERFACE_DEFINED__ /* interface ICDXFont */ /* [unique][uuid][object] */ EXTERN_C const IID IID_ICDXFont; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("F063C32D-59D1-4A0D-B209-323268059C12") ICDXFont : public IUnknown { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Name( /* [retval][out] */ BSTR *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Size( /* [retval][out] */ FLOAT *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Style( /* [retval][out] */ UINT *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Ascent( /* [retval][out] */ FLOAT *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Descent( /* [retval][out] */ FLOAT *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Height( /* [retval][out] */ FLOAT *p) = 0; }; #else /* C style interface */ typedef struct ICDXFontVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICDXFont * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICDXFont * This); ULONG ( STDMETHODCALLTYPE *Release )( ICDXFont * This); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Name )( ICDXFont * This, /* [retval][out] */ BSTR *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Size )( ICDXFont * This, /* [retval][out] */ FLOAT *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Style )( ICDXFont * This, /* [retval][out] */ UINT *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Ascent )( ICDXFont * This, /* [retval][out] */ FLOAT *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Descent )( ICDXFont * This, /* [retval][out] */ FLOAT *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Height )( ICDXFont * This, /* [retval][out] */ FLOAT *p); END_INTERFACE } ICDXFontVtbl; interface ICDXFont { CONST_VTBL struct ICDXFontVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICDXFont_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ICDXFont_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ICDXFont_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ICDXFont_get_Name(This,p) \ ( (This)->lpVtbl -> get_Name(This,p) ) #define ICDXFont_get_Size(This,p) \ ( (This)->lpVtbl -> get_Size(This,p) ) #define ICDXFont_get_Style(This,p) \ ( (This)->lpVtbl -> get_Style(This,p) ) #define ICDXFont_get_Ascent(This,p) \ ( (This)->lpVtbl -> get_Ascent(This,p) ) #define ICDXFont_get_Descent(This,p) \ ( (This)->lpVtbl -> get_Descent(This,p) ) #define ICDXFont_get_Height(This,p) \ ( (This)->lpVtbl -> get_Height(This,p) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ICDXFont_INTERFACE_DEFINED__ */ #ifndef __ICDXBuffer_INTERFACE_DEFINED__ #define __ICDXBuffer_INTERFACE_DEFINED__ /* interface ICDXBuffer */ /* [unique][uuid][object] */ EXTERN_C const IID IID_ICDXBuffer; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("A21FB8D8-33B3-4F8E-8740-8EB4B1FD4153") ICDXBuffer : public IUnknown { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Id( /* [retval][out] */ CDX_BUFFER *p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Name( /* [retval][out] */ BSTR *p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Name( /* [in] */ BSTR p) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Tag( /* [retval][out] */ IUnknown **p) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Tag( /* [in] */ IUnknown *p) = 0; virtual HRESULT STDMETHODCALLTYPE GetBufferPtr( /* [out][in] */ BYTE **p, /* [retval][out] */ UINT *size) = 0; virtual HRESULT STDMETHODCALLTYPE Update( /* [in] */ const BYTE *p, /* [in] */ UINT n) = 0; }; #else /* C style interface */ typedef struct ICDXBufferVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICDXBuffer * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICDXBuffer * This); ULONG ( STDMETHODCALLTYPE *Release )( ICDXBuffer * This); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Id )( ICDXBuffer * This, /* [retval][out] */ CDX_BUFFER *p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Name )( ICDXBuffer * This, /* [retval][out] */ BSTR *p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Name )( ICDXBuffer * This, /* [in] */ BSTR p); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Tag )( ICDXBuffer * This, /* [retval][out] */ IUnknown **p); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Tag )( ICDXBuffer * This, /* [in] */ IUnknown *p); HRESULT ( STDMETHODCALLTYPE *GetBufferPtr )( ICDXBuffer * This, /* [out][in] */ BYTE **p, /* [retval][out] */ UINT *size); HRESULT ( STDMETHODCALLTYPE *Update )( ICDXBuffer * This, /* [in] */ const BYTE *p, /* [in] */ UINT n); END_INTERFACE } ICDXBufferVtbl; interface ICDXBuffer { CONST_VTBL struct ICDXBufferVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICDXBuffer_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ICDXBuffer_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ICDXBuffer_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ICDXBuffer_get_Id(This,p) \ ( (This)->lpVtbl -> get_Id(This,p) ) #define ICDXBuffer_get_Name(This,p) \ ( (This)->lpVtbl -> get_Name(This,p) ) #define ICDXBuffer_put_Name(This,p) \ ( (This)->lpVtbl -> put_Name(This,p) ) #define ICDXBuffer_get_Tag(This,p) \ ( (This)->lpVtbl -> get_Tag(This,p) ) #define ICDXBuffer_put_Tag(This,p) \ ( (This)->lpVtbl -> put_Tag(This,p) ) #define ICDXBuffer_GetBufferPtr(This,p,size) \ ( (This)->lpVtbl -> GetBufferPtr(This,p,size) ) #define ICDXBuffer_Update(This,p,n) \ ( (This)->lpVtbl -> Update(This,p,n) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ICDXBuffer_INTERFACE_DEFINED__ */ /* interface __MIDL_itf_cdx_0000_0007 */ /* [local] */ typedef enum CDX_INFO { CDX_INFO_VERTEXBUFFER = 0, CDX_INFO_INDEXBUFFER = 1, CDX_INFO_MAPPINGS = 2, CDX_INFO_TEXTURES = 3, CDX_INFO_FONTS = 4, CDX_INFO_VIEWS = 5 } CDX_INFO; extern RPC_IF_HANDLE __MIDL_itf_cdx_0000_0007_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_cdx_0000_0007_v0_0_s_ifspec; #ifndef __ICDXFactory_INTERFACE_DEFINED__ #define __ICDXFactory_INTERFACE_DEFINED__ /* interface ICDXFactory */ /* [unique][uuid][object] */ EXTERN_C const IID IID_ICDXFactory; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("f0993d73-ea2a-4bf1-b128-826d4a3ba584") ICDXFactory : public IUnknown { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Version( /* [retval][out] */ UINT *pVal) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Devices( /* [retval][out] */ BSTR *p) = 0; virtual HRESULT STDMETHODCALLTYPE SetDevice( /* [in] */ UINT id) = 0; virtual HRESULT STDMETHODCALLTYPE CreateView( /* [in] */ HWND hwnd, /* [in] */ ICDXSink *sink, /* [in] */ UINT sampels, /* [retval][out] */ ICDXView **p) = 0; virtual HRESULT STDMETHODCALLTYPE CreateScene( /* [retval][out] */ ICDXScene **p) = 0; virtual HRESULT STDMETHODCALLTYPE CreateNode( /* [retval][out] */ ICDXNode **p) = 0; virtual HRESULT STDMETHODCALLTYPE GetFont( /* [in] */ BSTR name, FLOAT size, UINT style, /* [retval][out] */ ICDXFont **p) = 0; virtual HRESULT STDMETHODCALLTYPE GetInfo( /* [in] */ CDX_INFO id, /* [retval][out] */ UINT *v) = 0; virtual HRESULT STDMETHODCALLTYPE GetBuffer( /* [in] */ CDX_BUFFER id, /* [in] */ const BYTE *p, /* [in] */ UINT n, /* [retval][out] */ ICDXBuffer **v) = 0; virtual HRESULT STDMETHODCALLTYPE CopyCoords( /* [in] */ const XMFLOAT3 *appp, /* [in] */ const USHORT *aiip, /* [in] */ UINT aiin, /* [in] */ const XMFLOAT2 *attp, /* [in] */ const XMFLOAT3 *bppp, /* [in] */ const USHORT *biip, /* [in] */ UINT biin, /* [in] */ XMFLOAT2 *bttp, /* [in] */ FLOAT eps) = 0; virtual HRESULT STDMETHODCALLTYPE RestoreRanges( /* [in] */ const XMFLOAT3 *pp, /* [in] */ UINT np, /* [in] */ const USHORT *ii, /* [in] */ UINT ni, /* [in] */ ICDXNode *n1, /* [in] */ ICDXNode *n2, /* [in] */ const XMFLOAT4X3 *rm, /* [in] */ UINT fl, /* [in] */ FLOAT eps, /* [retval][out] */ ICDXNode **p) = 0; }; #else /* C style interface */ typedef struct ICDXFactoryVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICDXFactory * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICDXFactory * This); ULONG ( STDMETHODCALLTYPE *Release )( ICDXFactory * This); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Version )( ICDXFactory * This, /* [retval][out] */ UINT *pVal); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Devices )( ICDXFactory * This, /* [retval][out] */ BSTR *p); HRESULT ( STDMETHODCALLTYPE *SetDevice )( ICDXFactory * This, /* [in] */ UINT id); HRESULT ( STDMETHODCALLTYPE *CreateView )( ICDXFactory * This, /* [in] */ HWND hwnd, /* [in] */ ICDXSink *sink, /* [in] */ UINT sampels, /* [retval][out] */ ICDXView **p); HRESULT ( STDMETHODCALLTYPE *CreateScene )( ICDXFactory * This, /* [retval][out] */ ICDXScene **p); HRESULT ( STDMETHODCALLTYPE *CreateNode )( ICDXFactory * This, /* [retval][out] */ ICDXNode **p); HRESULT ( STDMETHODCALLTYPE *GetFont )( ICDXFactory * This, /* [in] */ BSTR name, FLOAT size, UINT style, /* [retval][out] */ ICDXFont **p); HRESULT ( STDMETHODCALLTYPE *GetInfo )( ICDXFactory * This, /* [in] */ CDX_INFO id, /* [retval][out] */ UINT *v); HRESULT ( STDMETHODCALLTYPE *GetBuffer )( ICDXFactory * This, /* [in] */ CDX_BUFFER id, /* [in] */ const BYTE *p, /* [in] */ UINT n, /* [retval][out] */ ICDXBuffer **v); HRESULT ( STDMETHODCALLTYPE *CopyCoords )( ICDXFactory * This, /* [in] */ const XMFLOAT3 *appp, /* [in] */ const USHORT *aiip, /* [in] */ UINT aiin, /* [in] */ const XMFLOAT2 *attp, /* [in] */ const XMFLOAT3 *bppp, /* [in] */ const USHORT *biip, /* [in] */ UINT biin, /* [in] */ XMFLOAT2 *bttp, /* [in] */ FLOAT eps); HRESULT ( STDMETHODCALLTYPE *RestoreRanges )( ICDXFactory * This, /* [in] */ const XMFLOAT3 *pp, /* [in] */ UINT np, /* [in] */ const USHORT *ii, /* [in] */ UINT ni, /* [in] */ ICDXNode *n1, /* [in] */ ICDXNode *n2, /* [in] */ const XMFLOAT4X3 *rm, /* [in] */ UINT fl, /* [in] */ FLOAT eps, /* [retval][out] */ ICDXNode **p); END_INTERFACE } ICDXFactoryVtbl; interface ICDXFactory { CONST_VTBL struct ICDXFactoryVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICDXFactory_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ICDXFactory_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ICDXFactory_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ICDXFactory_get_Version(This,pVal) \ ( (This)->lpVtbl -> get_Version(This,pVal) ) #define ICDXFactory_get_Devices(This,p) \ ( (This)->lpVtbl -> get_Devices(This,p) ) #define ICDXFactory_SetDevice(This,id) \ ( (This)->lpVtbl -> SetDevice(This,id) ) #define ICDXFactory_CreateView(This,hwnd,sink,sampels,p) \ ( (This)->lpVtbl -> CreateView(This,hwnd,sink,sampels,p) ) #define ICDXFactory_CreateScene(This,p) \ ( (This)->lpVtbl -> CreateScene(This,p) ) #define ICDXFactory_CreateNode(This,p) \ ( (This)->lpVtbl -> CreateNode(This,p) ) #define ICDXFactory_GetFont(This,name,size,style,p) \ ( (This)->lpVtbl -> GetFont(This,name,size,style,p) ) #define ICDXFactory_GetInfo(This,id,v) \ ( (This)->lpVtbl -> GetInfo(This,id,v) ) #define ICDXFactory_GetBuffer(This,id,p,n,v) \ ( (This)->lpVtbl -> GetBuffer(This,id,p,n,v) ) #define ICDXFactory_CopyCoords(This,appp,aiip,aiin,attp,bppp,biip,biin,bttp,eps) \ ( (This)->lpVtbl -> CopyCoords(This,appp,aiip,aiin,attp,bppp,biip,biin,bttp,eps) ) #define ICDXFactory_RestoreRanges(This,pp,np,ii,ni,n1,n2,rm,fl,eps,p) \ ( (This)->lpVtbl -> RestoreRanges(This,pp,np,ii,ni,n1,n2,rm,fl,eps,p) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ICDXFactory_INTERFACE_DEFINED__ */ #ifndef __cdxLib_LIBRARY_DEFINED__ #define __cdxLib_LIBRARY_DEFINED__ /* library cdxLib */ /* [version][uuid] */ EXTERN_C const IID LIBID_cdxLib; EXTERN_C const CLSID CLSID_Factory; #ifdef __cplusplus class DECLSPEC_UUID("4e957503-5aeb-41f2-975b-3e6ae9f9c75a") Factory; #endif #endif /* __cdxLib_LIBRARY_DEFINED__ */ /* Additional Prototypes for ALL interfaces */ unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); unsigned long __RPC_USER HWND_UserSize( unsigned long *, unsigned long , HWND * ); unsigned char * __RPC_USER HWND_UserMarshal( unsigned long *, unsigned char *, HWND * ); unsigned char * __RPC_USER HWND_UserUnmarshal(unsigned long *, unsigned char *, HWND * ); void __RPC_USER HWND_UserFree( unsigned long *, HWND * ); unsigned long __RPC_USER BSTR_UserSize64( unsigned long *, unsigned long , BSTR * ); unsigned char * __RPC_USER BSTR_UserMarshal64( unsigned long *, unsigned char *, BSTR * ); unsigned char * __RPC_USER BSTR_UserUnmarshal64(unsigned long *, unsigned char *, BSTR * ); void __RPC_USER BSTR_UserFree64( unsigned long *, BSTR * ); unsigned long __RPC_USER HWND_UserSize64( unsigned long *, unsigned long , HWND * ); unsigned char * __RPC_USER HWND_UserMarshal64( unsigned long *, unsigned char *, HWND * ); unsigned char * __RPC_USER HWND_UserUnmarshal64(unsigned long *, unsigned char *, HWND * ); void __RPC_USER HWND_UserFree64( unsigned long *, HWND * ); /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
28.966535
113
0.548998
[ "render", "object" ]
2fd434ec6fc5176158c1129c6868c2aa048227e2
669
h
C
LogDefer.h
rfarr/LogDefer-CXX
de838f661aca1b1b55e6177ac38695a084ac2d08
[ "BSD-2-Clause" ]
null
null
null
LogDefer.h
rfarr/LogDefer-CXX
de838f661aca1b1b55e6177ac38695a084ac2d08
[ "BSD-2-Clause" ]
null
null
null
LogDefer.h
rfarr/LogDefer-CXX
de838f661aca1b1b55e6177ac38695a084ac2d08
[ "BSD-2-Clause" ]
null
null
null
#pragma once #include <functional> #include "picojson/picojson.h" class LogDefer { public: LogDefer(std::function<void (const std::string&)> callback); ~LogDefer(); void data(const std::string &key, const std::string &value); void add_log(int verbosity, const std::string &msg); void error(const std::string &msg); void warn(const std::string &msg); void info(const std::string &msg); void debug(const std::string &msg); private: std::function<void (const std::string &)> callback_; struct timeval start_tv_; picojson::object o_; picojson::object data_; picojson::array logs_; picojson::array timers_; };
25.730769
64
0.671151
[ "object" ]
2fd7a56ee81033ace76cb5e482a31a88fdea78e3
4,690
c
C
third_party/Phigs/PVT/PVT_c/V2LIB/e03108.c
n1ckfg/Telidon
f4e2c693ec7d67245974b73a602d5d40df6a6d69
[ "MIT" ]
18
2017-07-08T02:34:02.000Z
2022-01-08T03:42:48.000Z
third_party/Phigs/PVT/PVT_c/V2LIB/e03108.c
n1ckfg/Telidon
f4e2c693ec7d67245974b73a602d5d40df6a6d69
[ "MIT" ]
null
null
null
third_party/Phigs/PVT/PVT_c/V2LIB/e03108.c
n1ckfg/Telidon
f4e2c693ec7d67245974b73a602d5d40df6a6d69
[ "MIT" ]
3
2018-02-03T04:44:00.000Z
2020-08-05T15:31:18.000Z
/* e03108.f -- translated by f2c (version of 22 July 1992 22:54:52). You must link the resulting object file with the libraries: -lF77 -lI77 -lm -lc (in that order) */ #include "f2c.h" /* Common Block Declarations */ struct { integer ctlhnd, errsig, errfil, ierrct, unerr, testct, iflerr, passsw, errsw, maxlin, conid, memun, wkid, wtype, glblun, indlun, dumint[ 20]; real dumrl[20]; } globnu_; #define globnu_1 globnu_ struct { integer errcom, funcom, filcom, ernmsw, expsiz, experr[10], usrerr, errsav[200], funsav[200], filsav[200], efcnt, efid[100]; } errinf_; #define errinf_1 errinf_ struct { char curcon[200], errsrs[40], errmrk[20], erflnm[80], contab[6000]; } errchr_; #define errchr_1 errchr_ /* Table of constant values */ static integer c__0 = 0; static integer c__1 = 1; static integer c__2 = 2; #ifndef NO_PROTO /* Subroutine */ int e03108_(integer *useprm) #else /* NO_PROTO */ /* Subroutine */ int e03108_(useprm) integer *useprm; #endif /* NO_PROTO */ { /* Initialized data */ static logical isavl[5] = { FALSE_,FALSE_,FALSE_,FALSE_,FALSE_ }; /* System generated locals */ integer i__1; logical L__1; /* Builtin functions */ #ifndef NO_PROTO /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen); #else /* NO_PROTO */ /* Subroutine */ int s_copy(); #endif /* NO_PROTO */ /* Local variables */ static integer ix; #ifndef NO_PROTO extern /* Subroutine */ int nqif (integer *, integer *, integer *, integer *, integer *, integer *, integer *, integer *, integer *), nqir (integer *, integer *, integer *, integer *, integer *, integer *, integer *), nsir (integer *, integer *, integer *, integer *, integer *), rsir_(integer *, integer *, integer *, integer *, integer *); #else /* NO_PROTO */ extern /* Subroutine */ int nqif (), nqir (), nsir (), rsir_(); #endif /* NO_PROTO */ static integer idum1, idum2, idum3, idum4, idum5; #ifndef NO_PROTO extern /* Subroutine */ int inmsg_(char *, ftnlen), nclwk (integer *), nqwkc (integer *, integer *, integer *, integer *); extern logical streq_(char *, ftnlen); extern /* Subroutine */ int nopwk (integer *, integer *, integer *), setvs_(char *, integer *, integer *, ftnlen); #else /* NO_PROTO */ extern /* Subroutine */ int inmsg_(), nclwk (), nqwkc (); extern logical streq_(); extern /* Subroutine */ int nopwk (), setvs_(); #endif /* NO_PROTO */ static integer nisty1; #ifndef NO_PROTO extern /* Subroutine */ int chkinq_(char *, integer *, ftnlen), enderr_( void); #else /* NO_PROTO */ extern /* Subroutine */ int chkinq_(), enderr_(); #endif /* NO_PROTO */ static integer errind, istyle, isindx, iscolo, thisis, specwt, untype; #ifndef NO_PROTO extern /* Subroutine */ int esetup_(integer *), tstign_(logical *); #else /* NO_PROTO */ extern /* Subroutine */ int esetup_(), tstign_(); #endif /* NO_PROTO */ /* E03108 tests the handling of error 108 */ /* interior style */ /* type of returned value */ setvs_("108", errinf_1.experr, &errinf_1.expsiz, 3L); #ifndef NO_PROTO s_copy(errchr_1.curcon, "the specified interior style is not available o" "n the specified workstation", 200L, 74L); #else /* NO_PROTO */ s_copy(errchr_1.curcon, "the specified interior style is not available o\ n the specified workstation", 200L, 74L); #endif /* NO_PROTO */ s_copy(errchr_1.errsrs, "8", 40L, 1L); esetup_(useprm); nopwk (&globnu_1.wkid, &globnu_1.conid, &globnu_1.wtype); nqwkc (&globnu_1.wkid, &errind, &globnu_1.conid, &specwt); chkinq_("pqwkc", &errind, 5L); nqif (&specwt, &c__0, &c__0, &errind, &nisty1, &idum1, &idum2, &idum3, & idum4); chkinq_("pqif", &errind, 4L); i__1 = nisty1; for (ix = 1; ix <= i__1; ++ix) { nqif (&specwt, &ix, &c__0, &errind, &idum2, &thisis, &idum3, &idum4, & idum5); chkinq_("pqif", &errind, 4L); if (thisis >= 0 && thisis <= 4) { isavl[thisis] = TRUE_; } /* L50: */ } for (ix = 0; ix <= 4; ++ix) { if (! isavl[ix]) { untype = ix; goto L70; } /* L60: */ } inmsg_("No unavailable interior styles; test is skipped.", 48L); return 0; L70: nsir (&globnu_1.wkid, &c__1, &thisis, &c__1, &c__0); rsir_(&globnu_1.wkid, &c__1, &untype, &c__2, &c__1); nqir (&globnu_1.wkid, &c__1, &c__0, &errind, &istyle, &isindx, &iscolo); chkinq_("pqir", &errind, 4L); L__1 = streq_("OO**", 4L) && istyle == thisis && isindx == 1 && iscolo == 0; tstign_(&L__1); nclwk (&globnu_1.wkid); enderr_(); #ifndef NO_PROTO return 0; #endif /* not NO_PROTO */ } /* e03108_ */
31.059603
78
0.621322
[ "object" ]
2fddc40ede9d9c8265d2dbad4567c6c0a03e0ac0
1,487
h
C
inc/enumser/StdAfx.h
slaterbbx/mDjiController.fork
5dfec8bf6d5f8a153e5db57d62f0ed90a215b4a8
[ "Apache-2.0" ]
10
2019-01-19T14:34:46.000Z
2021-04-08T21:39:27.000Z
inc/enumser/StdAfx.h
slaterbbx/mDjiController
5dfec8bf6d5f8a153e5db57d62f0ed90a215b4a8
[ "Apache-2.0" ]
null
null
null
inc/enumser/StdAfx.h
slaterbbx/mDjiController
5dfec8bf6d5f8a153e5db57d62f0ed90a215b4a8
[ "Apache-2.0" ]
2
2019-05-20T13:35:45.000Z
2021-04-22T09:09:26.000Z
#pragma once #ifndef STRICT #define STRICT #endif #ifndef WINVER #define WINVER 0x0502 #endif #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0502 #endif #ifndef _WIN32_WINDOWS #define _WIN32_WINDOWS 0x0502 #endif #ifndef _WIN32_IE #define _WIN32_IE 0x0600 #endif #define VC_EXTRALEAN //Exclude rarely-used stuff from Windows headers #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS //some CString constructors will be explicit #define _AFX_ALL_WARNINGS //turns off MFC's hiding of some common and often safely ignored warning messages #define _ATL_NO_AUTOMATIC_NAMESPACE #ifndef _SECURE_ATL #define _SECURE_ATL 1 //Use the Secure C Runtime in ATL #endif //Pull in Standard Windows support #include <Windows.h> //Pull in ATL support #include <atlbase.h> #include <atlstr.h> //Other includes #include <tchar.h> #include <setupapi.h> #include <malloc.h> #include <winspool.h> #include <Wbemcli.h> #include <comdef.h> #include <stdio.h> //Pull in STL support #include <vector> #include <string> #include <utility> //Out of the box lets exclude support for CEnumerateSerial::UsingComDB on the Windows SDK 7.1 or earlier since msports.h //is only available with the Windows SDK 8 or later. #include <ntverp.h> #if VER_PRODUCTBUILD <= 7600 #define NO_CENUMERATESERIAL_USING_COMDB #endif //#if VER_PRODUCTBUILD <= 7600 #ifndef NO_CENUMERATESERIAL_USING_COMDB #include <msports.h> #endif //#ifndef NO_CENUMERATESERIAL_USING_COMDB
23.603175
121
0.755884
[ "vector" ]
2feb3310242058a668ecbcb7ebec567529651125
3,685
c
C
src/gbpAstro/gbpClustering/make_diff_grid.c
gbpoole/gbpCode
5157d2e377edbd4806258d1c16b329373186d43a
[ "MIT" ]
1
2015-10-20T11:39:53.000Z
2015-10-20T11:39:53.000Z
src/gbpAstro/gbpClustering/make_diff_grid.c
gbpoole/gbpCode
5157d2e377edbd4806258d1c16b329373186d43a
[ "MIT" ]
2
2017-07-30T11:10:49.000Z
2019-06-18T00:40:46.000Z
src/gbpAstro/gbpClustering/make_diff_grid.c
gbpoole/gbpCode
5157d2e377edbd4806258d1c16b329373186d43a
[ "MIT" ]
4
2015-01-23T00:50:40.000Z
2016-08-01T08:14:24.000Z
#define _MAIN #include <stdio.h> #include <string.h> #include <math.h> #include <gbpLib.h> #include <gbpMath.h> #include <gbpSPH.h> #include <gbpCosmo.h> #include <gbpClustering.h> #define _FILE_OFFSET_BITS 64 int main(int argc, char *argv[]) { // Initialization -- MPI etc. SID_Init(&argc, &argv, NULL); SID_log("Writing the difference between the grids in {%s} and {%s} to stdout...", SID_LOG_OPEN, argv[1], argv[2]); FILE * fp1; int nx1, ny1, nz1, ng1, as1; double Lx1, Ly1, Lz1; fp1 = fopen(argv[1], "r"); SID_fread_verify(&nx1, sizeof(int), 1, fp1); SID_fread_verify(&ny1, sizeof(int), 1, fp1); SID_fread_verify(&nz1, sizeof(int), 1, fp1); SID_fread_verify(&Lx1, sizeof(double), 1, fp1); SID_fread_verify(&Ly1, sizeof(double), 1, fp1); SID_fread_verify(&Lz1, sizeof(double), 1, fp1); SID_fread_verify(&ng1, sizeof(int), 1, fp1); SID_fread_verify(&as1, sizeof(int), 1, fp1); FILE * fp2; int nx2, ny2, nz2, ng2, as2; double Lx2, Ly2, Lz2; fp2 = fopen(argv[2], "r"); SID_fread_verify(&nx2, sizeof(int), 1, fp2); SID_fread_verify(&ny2, sizeof(int), 1, fp2); SID_fread_verify(&nz2, sizeof(int), 1, fp2); SID_fread_verify(&Lx2, sizeof(double), 1, fp2); SID_fread_verify(&Ly2, sizeof(double), 1, fp2); SID_fread_verify(&Lz2, sizeof(double), 1, fp2); SID_fread_verify(&ng2, sizeof(int), 1, fp2); SID_fread_verify(&as2, sizeof(int), 1, fp2); if(nx1 != nx2) SID_exit_error("nx's don't match (ie. %d!=%d)", SID_ERROR_LOGIC, nx1, nx2); if(ny1 != ny2) SID_exit_error("ny's don't match (ie. %d!=%d)", SID_ERROR_LOGIC, ny1, ny2); if(nz1 != nz2) SID_exit_error("nz's don't match (ie. %d!=%d)", SID_ERROR_LOGIC, nz1, nz2); if(Lx1 != Lx2) SID_exit_error("Lx's don't match (ie. %le!=%le)", SID_ERROR_LOGIC, Lx1, Lx2); if(Ly1 != Ly2) SID_exit_error("Ly's don't match (ie. %le!=%le)", SID_ERROR_LOGIC, Ly1, Ly2); if(Lz1 != Lz2) SID_exit_error("Lz's don't match (ie. %le!=%le)", SID_ERROR_LOGIC, Lz1, Lz2); if(ng1 != ng2) SID_exit_error("The number of grids don't match (ie. %d!=%d)", SID_ERROR_LOGIC, ng1, ng2); int i_x, i_y, i_z; GBPREAL d1, d2; int i_grid; char * grid_identifier_1; char * grid_identifier_2; grid_identifier_1 = (char *)SID_malloc(GRID_IDENTIFIER_SIZE * sizeof(char)); grid_identifier_2 = (char *)SID_malloc(GRID_IDENTIFIER_SIZE * sizeof(char)); for(i_grid = 0; i_grid < ng1; i_grid++) { SID_fread_verify(grid_identifier_1, sizeof(char), GRID_IDENTIFIER_SIZE, fp1); SID_fread_verify(grid_identifier_2, sizeof(char), GRID_IDENTIFIER_SIZE, fp2); if(strcmp(grid_identifier_1, grid_identifier_2)) SID_log_warning("grid identifiers don't match (ie. {%s}!={%s})", SID_ERROR_LOGIC, grid_identifier_1, grid_identifier_2); SID_log("Processing {%s} ...", SID_LOG_OPEN, grid_identifier_1); for(i_x = 0; i_x < nx1; i_x++) { for(i_y = 0; i_y < ny1; i_y++) { for(i_z = 0; i_z < nz1; i_z++) { SID_fread_verify(&d1, sizeof(GBPREAL), 1, fp1); SID_fread_verify(&d2, sizeof(GBPREAL), 1, fp2); if(d2 != d1) fprintf(stdout, "%3d %4d %4d %4d %le %le %le\n", i_grid, i_x, i_y, i_z, (double)d1, (double)d2, (double)(d2 - d1)); } } } SID_log("Done.", SID_LOG_CLOSE); } SID_free(SID_FARG grid_identifier_1); SID_free(SID_FARG grid_identifier_2); fclose(fp1); fclose(fp2); SID_log("Done.", SID_LOG_CLOSE); SID_Finalize(); }
39.202128
139
0.607056
[ "3d" ]
2fecd220f26e94353fc28b28e6c6d898b3cfec30
5,775
h
C
aws-cpp-sdk-apigateway/include/aws/apigateway/model/GetTagsRequest.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
1
2022-02-10T08:06:54.000Z
2022-02-10T08:06:54.000Z
aws-cpp-sdk-apigateway/include/aws/apigateway/model/GetTagsRequest.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
1
2022-01-03T23:59:37.000Z
2022-01-03T23:59:37.000Z
aws-cpp-sdk-apigateway/include/aws/apigateway/model/GetTagsRequest.h
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2022-03-23T15:17:18.000Z
2022-03-23T15:17:18.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/apigateway/APIGateway_EXPORTS.h> #include <aws/apigateway/APIGatewayRequest.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { namespace Http { class URI; } //namespace Http namespace APIGateway { namespace Model { /** * <p>Gets the <a>Tags</a> collection for a given resource.</p><p><h3>See * Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/apigateway-2015-07-09/GetTagsRequest">AWS * API Reference</a></p> */ class AWS_APIGATEWAY_API GetTagsRequest : public APIGatewayRequest { public: GetTagsRequest(); // Service request name is the Operation name which will send this request out, // each operation should has unique request name, so that we can get operation's name from this request. // Note: this is not true for response, multiple operations may have the same response name, // so we can not get operation's name from response. inline virtual const char* GetServiceRequestName() const override { return "GetTags"; } Aws::String SerializePayload() const override; void AddQueryStringParameters(Aws::Http::URI& uri) const override; /** * <p>[Required] The ARN of a resource that can be tagged.</p> */ inline const Aws::String& GetResourceArn() const{ return m_resourceArn; } /** * <p>[Required] The ARN of a resource that can be tagged.</p> */ inline bool ResourceArnHasBeenSet() const { return m_resourceArnHasBeenSet; } /** * <p>[Required] The ARN of a resource that can be tagged.</p> */ inline void SetResourceArn(const Aws::String& value) { m_resourceArnHasBeenSet = true; m_resourceArn = value; } /** * <p>[Required] The ARN of a resource that can be tagged.</p> */ inline void SetResourceArn(Aws::String&& value) { m_resourceArnHasBeenSet = true; m_resourceArn = std::move(value); } /** * <p>[Required] The ARN of a resource that can be tagged.</p> */ inline void SetResourceArn(const char* value) { m_resourceArnHasBeenSet = true; m_resourceArn.assign(value); } /** * <p>[Required] The ARN of a resource that can be tagged.</p> */ inline GetTagsRequest& WithResourceArn(const Aws::String& value) { SetResourceArn(value); return *this;} /** * <p>[Required] The ARN of a resource that can be tagged.</p> */ inline GetTagsRequest& WithResourceArn(Aws::String&& value) { SetResourceArn(std::move(value)); return *this;} /** * <p>[Required] The ARN of a resource that can be tagged.</p> */ inline GetTagsRequest& WithResourceArn(const char* value) { SetResourceArn(value); return *this;} /** * <p>(Not currently supported) The current pagination position in the paged result * set.</p> */ inline const Aws::String& GetPosition() const{ return m_position; } /** * <p>(Not currently supported) The current pagination position in the paged result * set.</p> */ inline bool PositionHasBeenSet() const { return m_positionHasBeenSet; } /** * <p>(Not currently supported) The current pagination position in the paged result * set.</p> */ inline void SetPosition(const Aws::String& value) { m_positionHasBeenSet = true; m_position = value; } /** * <p>(Not currently supported) The current pagination position in the paged result * set.</p> */ inline void SetPosition(Aws::String&& value) { m_positionHasBeenSet = true; m_position = std::move(value); } /** * <p>(Not currently supported) The current pagination position in the paged result * set.</p> */ inline void SetPosition(const char* value) { m_positionHasBeenSet = true; m_position.assign(value); } /** * <p>(Not currently supported) The current pagination position in the paged result * set.</p> */ inline GetTagsRequest& WithPosition(const Aws::String& value) { SetPosition(value); return *this;} /** * <p>(Not currently supported) The current pagination position in the paged result * set.</p> */ inline GetTagsRequest& WithPosition(Aws::String&& value) { SetPosition(std::move(value)); return *this;} /** * <p>(Not currently supported) The current pagination position in the paged result * set.</p> */ inline GetTagsRequest& WithPosition(const char* value) { SetPosition(value); return *this;} /** * <p>(Not currently supported) The maximum number of returned results per page. * The default value is 25 and the maximum value is 500.</p> */ inline int GetLimit() const{ return m_limit; } /** * <p>(Not currently supported) The maximum number of returned results per page. * The default value is 25 and the maximum value is 500.</p> */ inline bool LimitHasBeenSet() const { return m_limitHasBeenSet; } /** * <p>(Not currently supported) The maximum number of returned results per page. * The default value is 25 and the maximum value is 500.</p> */ inline void SetLimit(int value) { m_limitHasBeenSet = true; m_limit = value; } /** * <p>(Not currently supported) The maximum number of returned results per page. * The default value is 25 and the maximum value is 500.</p> */ inline GetTagsRequest& WithLimit(int value) { SetLimit(value); return *this;} private: Aws::String m_resourceArn; bool m_resourceArnHasBeenSet; Aws::String m_position; bool m_positionHasBeenSet; int m_limit; bool m_limitHasBeenSet; }; } // namespace Model } // namespace APIGateway } // namespace Aws
33.189655
121
0.66632
[ "model" ]
2ff1775dfcd5f393b4dcd07e03e7c1f793ab24bb
14,693
c
C
coders/histogram.c
clario-tech/ImageMagick
ed300af85f0b74302fa100f4f35fb9c24c8b79af
[ "ImageMagick" ]
1
2019-02-16T04:36:04.000Z
2019-02-16T04:36:04.000Z
coders/histogram.c
DalavanCloud/ImageMagick
1106f559f2a161b926aca0b67dea343deef3f980
[ "ImageMagick" ]
1
2022-02-18T14:23:05.000Z
2022-02-18T14:23:05.000Z
coders/histogram.c
DalavanCloud/ImageMagick
1106f559f2a161b926aca0b67dea343deef3f980
[ "ImageMagick" ]
1
2019-02-16T04:35:24.000Z
2019-02-16T04:35:24.000Z
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % H H IIIII SSSSS TTTTT OOO GGGG RRRR AAA M M % % H H I SS T O O G R R A A MM MM % % HHHHH I SSS T O O G GG RRRR AAAAA M M M % % H H I SS T O O G G R R A A M M % % H H IIIII SSSSS T OOO GGG R R A A M M % % % % % % Write A Histogram Image. % % % % Software Design % % Cristy % % July 1992 % % % % % % Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization % % dedicated to making software imaging solutions freely available. % % % % You may not use this file except in compliance with the License. You may % % obtain a copy of the License at % % % % https://www.imagemagick.org/script/license.php % % % % Unless required by applicable law or agreed to in writing, software % % distributed under the License is distributed on an "AS IS" BASIS, % % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % % See the License for the specific language governing permissions and % % limitations under the License. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % */ /* Include declarations. */ #include "MagickCore/studio.h" #include "MagickCore/artifact.h" #include "MagickCore/blob.h" #include "MagickCore/blob-private.h" #include "MagickCore/cache.h" #include "MagickCore/color.h" #include "MagickCore/color-private.h" #include "MagickCore/constitute.h" #include "MagickCore/exception.h" #include "MagickCore/exception-private.h" #include "MagickCore/geometry.h" #include "MagickCore/histogram.h" #include "MagickCore/image-private.h" #include "MagickCore/magick.h" #include "MagickCore/memory_.h" #include "MagickCore/monitor.h" #include "MagickCore/monitor-private.h" #include "MagickCore/option.h" #include "MagickCore/pixel-accessor.h" #include "MagickCore/property.h" #include "MagickCore/quantum-private.h" #include "MagickCore/resource_.h" #include "MagickCore/static.h" #include "MagickCore/statistic.h" #include "MagickCore/string_.h" #include "MagickCore/module.h" #include "MagickCore/token.h" #include "MagickCore/utility.h" /* Forward declarations. */ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *,Image *,ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e g i s t e r H I S T O G R A M I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % RegisterHISTOGRAMImage() adds attributes for the Histogram image format % to the list of supported formats. The attributes include the image format % tag, a method to read and/or write the format, whether the format % supports the saving of more than one frame to the same file or blob, % whether the format supports native in-memory I/O, and a brief % description of the format. % % The format of the RegisterHISTOGRAMImage method is: % % size_t RegisterHISTOGRAMImage(void) % */ ModuleExport size_t RegisterHISTOGRAMImage(void) { MagickInfo *entry; entry=AcquireMagickInfo("HISTOGRAM","HISTOGRAM","Histogram of the image"); entry->encoder=(EncodeImageHandler *) WriteHISTOGRAMImage; entry->flags^=CoderAdjoinFlag; entry->format_type=ImplicitFormatType; (void) RegisterMagickInfo(entry); return(MagickImageCoderSignature); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % U n r e g i s t e r H I S T O G R A M I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % UnregisterHISTOGRAMImage() removes format registrations made by the % HISTOGRAM module from the list of supported formats. % % The format of the UnregisterHISTOGRAMImage method is: % % UnregisterHISTOGRAMImage(void) % */ ModuleExport void UnregisterHISTOGRAMImage(void) { (void) UnregisterMagickInfo("HISTOGRAM"); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W r i t e H I S T O G R A M I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % WriteHISTOGRAMImage() writes an image to a file in Histogram format. % The image shows a histogram of the color (or gray) values in the image. The % image consists of three overlaid histograms: a red one for the red channel, % a green one for the green channel, and a blue one for the blue channel. The % image comment contains a list of unique pixel values and the number of times % each occurs in the image. % % This method is strongly based on a similar one written by % muquit@warm.semcor.com which in turn is based on ppmhistmap of netpbm. % % The format of the WriteHISTOGRAMImage method is: % % MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info, % Image *image,ExceptionInfo *exception) % % A description of each parameter follows. % % o image_info: the image info. % % o image: The image. % % o exception: return any errors or warnings in this structure. % */ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info, Image *image,ExceptionInfo *exception) { #define HistogramDensity "256x200" char filename[MagickPathExtent]; const char *option; Image *histogram_image; ImageInfo *write_info; MagickBooleanType status; PixelInfo *histogram; double maximum, scale; RectangleInfo geometry; register const Quantum *p; register Quantum *q, *r; register ssize_t x; size_t length; ssize_t y; /* Allocate histogram image. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); SetGeometry(image,&geometry); if (image_info->density == (char *) NULL) (void) ParseAbsoluteGeometry(HistogramDensity,&geometry); else (void) ParseAbsoluteGeometry(image_info->density,&geometry); histogram_image=CloneImage(image,geometry.width,geometry.height,MagickTrue, exception); if (histogram_image == (Image *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); (void) SetImageStorageClass(histogram_image,DirectClass,exception); /* Allocate histogram count arrays. */ length=MagickMax((size_t) ScaleQuantumToChar(QuantumRange)+1UL, histogram_image->columns); histogram=(PixelInfo *) AcquireQuantumMemory(length,sizeof(*histogram)); if (histogram == (PixelInfo *) NULL) { histogram_image=DestroyImage(histogram_image); ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); } /* Initialize histogram count arrays. */ (void) ResetMagickMemory(histogram,0,length*sizeof(*histogram)); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1,exception); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) histogram[ScaleQuantumToChar(GetPixelRed(image,p))].red++; if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) histogram[ScaleQuantumToChar(GetPixelGreen(image,p))].green++; if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) histogram[ScaleQuantumToChar(GetPixelBlue(image,p))].blue++; p+=GetPixelChannels(image); } } maximum=histogram[0].red; for (x=0; x < (ssize_t) histogram_image->columns; x++) { if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) && (maximum < histogram[x].red)) maximum=histogram[x].red; if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) && (maximum < histogram[x].green)) maximum=histogram[x].green; if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) && (maximum < histogram[x].blue)) maximum=histogram[x].blue; } scale=0.0; if (fabs(maximum) >= MagickEpsilon) scale=(double) histogram_image->rows/maximum; /* Initialize histogram image. */ (void) QueryColorCompliance("#000000",AllCompliance, &histogram_image->background_color,exception); (void) SetImageBackgroundColor(histogram_image,exception); for (x=0; x < (ssize_t) histogram_image->columns; x++) { q=GetAuthenticPixels(histogram_image,x,0,1,histogram_image->rows,exception); if (q == (Quantum *) NULL) break; if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].red-0.5); r=q+y*GetPixelChannels(histogram_image); for ( ; y < (ssize_t) histogram_image->rows; y++) { SetPixelRed(histogram_image,QuantumRange,r); r+=GetPixelChannels(histogram_image); } } if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].green-0.5); r=q+y*GetPixelChannels(histogram_image); for ( ; y < (ssize_t) histogram_image->rows; y++) { SetPixelGreen(histogram_image,QuantumRange,r); r+=GetPixelChannels(histogram_image); } } if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].blue-0.5); r=q+y*GetPixelChannels(histogram_image); for ( ; y < (ssize_t) histogram_image->rows; y++) { SetPixelBlue(histogram_image,QuantumRange,r); r+=GetPixelChannels(histogram_image); } } if (SyncAuthenticPixels(histogram_image,exception) == MagickFalse) break; status=SetImageProgress(image,SaveImageTag,y,histogram_image->rows); if (status == MagickFalse) break; } histogram=(PixelInfo *) RelinquishMagickMemory(histogram); option=GetImageOption(image_info,"histogram:unique-colors"); if ((IsHistogramImage(image,exception) != MagickFalse) || (IsStringTrue(option) != MagickFalse)) { FILE *file; int unique_file; /* Add a unique colors as an image comment. */ file=(FILE *) NULL; unique_file=AcquireUniqueFileResource(filename); if (unique_file != -1) file=fdopen(unique_file,"wb"); if ((unique_file != -1) && (file != (FILE *) NULL)) { char *property; (void) GetNumberColors(image,file,exception); (void) fclose(file); property=FileToString(filename,~0UL,exception); if (property != (char *) NULL) { (void) SetImageProperty(histogram_image,"comment",property, exception); property=DestroyString(property); } } (void) RelinquishUniqueFileResource(filename); } /* Write Histogram image. */ (void) CopyMagickString(histogram_image->filename,image_info->filename, MagickPathExtent); (void) ResetImagePage(histogram_image,"0x0+0+0"); write_info=CloneImageInfo(image_info); *write_info->magick='\0'; (void) SetImageInfo(write_info,1,exception); if ((*write_info->magick == '\0') || (LocaleCompare(write_info->magick,"HISTOGRAM") == 0)) (void) FormatLocaleString(histogram_image->filename,MagickPathExtent, "miff:%s",write_info->filename); status=WriteImage(write_info,histogram_image,exception); histogram_image=DestroyImage(histogram_image); write_info=DestroyImageInfo(write_info); return(status); }
38.163636
80
0.511672
[ "geometry" ]
2ff345813d7e80825c81e83e4bbe1983b535e428
2,357
h
C
src/ANEObject.h
thomasrzhao/ANEWrapper
2803cb8e435e9d1621848638e56560b3d4f8f400
[ "MIT" ]
12
2015-08-26T14:36:07.000Z
2017-03-15T19:03:31.000Z
src/ANEObject.h
thomasrzhao/ANEWrapper
2803cb8e435e9d1621848638e56560b3d4f8f400
[ "MIT" ]
null
null
null
src/ANEObject.h
thomasrzhao/ANEWrapper
2803cb8e435e9d1621848638e56560b3d4f8f400
[ "MIT" ]
null
null
null
// // ANEObject.m // ANEWrappers // // Created by thomasrzhao on 8/24/15. // Copyright (c) 2015 Thomas Zhao. All rights reserved. // @import Foundation; #import "FlashRuntimeExtensions.h" #import "ANECommon.h" @interface ANEObject : NSObject @property (readonly) FREObject FREObject; - (instancetype) init __attribute__((unavailable("use the objectWithX: factory methods instead"))); + (ANEObject*) objectWithInt:(int32_t)value; + (ANEObject*) objectWithUnsignedInt:(uint32_t)value; + (ANEObject*) objectWithBool:(BOOL)value; + (ANEObject*) objectWithDouble:(double)value; + (ANEObject*) objectWithString:(NSString*)value; + (instancetype) objectWithClassName:(NSString*)className constructorArgs:(ANEObject*)args, ... NS_REQUIRES_NIL_TERMINATION; + (instancetype) objectWithClassName:(NSString*)className constructorArgs:(ANEObject*)firstArg vaList:(va_list)vaList; //The NSArray argument should only contain ANEObject* + (instancetype) objectWithClassName:(NSString*)className constructorArgsArray:(NSArray*)argsArray; //This factory method will return an ANEObject that can be downcasted to a subtype (ANEArray, ANEByteArray, ANEBitmapData) if the underlying FREObject corresponds to one of those types //This magic boxing only works if you call objectWithFREObject: on the ANEObject class. For example, [ANEArray objectWithFREObject:obj] will only ever return an ANEArray object or nil (if the FREObject is not an array type). + (instancetype) objectWithFREObject:(FREObject)value; @property (readonly) int32_t intValue; @property (readonly) uint32_t unsignedIntValue; @property (readonly) BOOL boolValue; @property (readonly) double doubleValue; @property (readonly) NSString* stringValue; @property (readonly) FREObjectType type; @property (readonly, getter=isNull) BOOL null; - (ANEObject*) getProperty:(NSString*)propertyName; - (void) setProperty:(NSString*)propertyName value:(ANEObject*)propertyValue; - (ANEObject*) callMethod:(NSString*)methodName methodArgs:(ANEObject*)args, ... NS_REQUIRES_NIL_TERMINATION; - (ANEObject*) callMethod:(NSString*)methodName methodArgs:(ANEObject*)firstArg vaList:(va_list)vaList; - (ANEObject*) callMethod:(NSString*)methodName methodArgsArray:(NSArray*)argsArray; - (ANEObject*) objectForKeyedSubscript:(NSString*)key; - (void) setObject:(ANEObject*)obj forKeyedSubscript:(NSString*)key; @end
44.471698
224
0.786593
[ "object" ]
2ff66dd0783adcac8597d35ccba47432312f6a1b
448
h
C
Symbol.h
xaddee/LFA
28a1268fe2c02be31fa503b8b35797a96f89cc8f
[ "MIT" ]
null
null
null
Symbol.h
xaddee/LFA
28a1268fe2c02be31fa503b8b35797a96f89cc8f
[ "MIT" ]
null
null
null
Symbol.h
xaddee/LFA
28a1268fe2c02be31fa503b8b35797a96f89cc8f
[ "MIT" ]
null
null
null
// // Created by Adelin on 4/27/2018. // #ifndef LFA_HOMEWORK2_SYMBOL_H #define LFA_HOMEWORK2_SYMBOL_H #include <iostream> #include <vector> class Symbol { int _number_of_roads; int _index; bool _final; public: Symbol(); ~Symbol(); void setNumberOfRoads(int); int showNumberOfRoads(); void setIndex(int); int showIndex(); bool showFinal(); void setFinal(bool); }; #endif //LFA_HOMEWORK2_SYMBOL_H
14.451613
34
0.671875
[ "vector" ]
2ff678e8af63447c34efba6655649b0e0bfe52c9
615
h
C
React3D/Core/src/Mesh.h
ankitpriyarup/React3D
a5874f3e600bef27c9ed7a346ed2ca0440dee5a5
[ "MIT" ]
null
null
null
React3D/Core/src/Mesh.h
ankitpriyarup/React3D
a5874f3e600bef27c9ed7a346ed2ca0440dee5a5
[ "MIT" ]
null
null
null
React3D/Core/src/Mesh.h
ankitpriyarup/React3D
a5874f3e600bef27c9ed7a346ed2ca0440dee5a5
[ "MIT" ]
1
2022-03-22T11:41:13.000Z
2022-03-22T11:41:13.000Z
#pragma once #include <iostream> #include <assimp/Importer.hpp> #include <assimp/scene.h> #include <assimp/postprocess.h> #include <vector> class Mesh { private: std::string directory; void loadMesh(bool _isPerspective, const std::string& path); void processNode(bool _isPerspective, aiNode* node, const aiScene* scene); public: struct meshData { float* data; unsigned int* indices; int dataSize; int indicesSize; }; std::vector<meshData*> data; enum PrimitiveMesh { quad, cube }; Mesh(bool _isPerspective, PrimitiveMesh _mesh); Mesh(bool _isPerspective, const std::string& path); ~Mesh(); };
20.5
75
0.731707
[ "mesh", "vector" ]
2ff9bfc53b16b22a4bcfea3f8a0d925efd9c1dfa
1,728
h
C
core/dc.h
JulNadeauCA/edacious
41787e2dc7d42226313fb65c79d00c1d94ec8e36
[ "BSD-2-Clause" ]
8
2017-08-02T00:57:51.000Z
2022-03-13T17:46:23.000Z
core/dc.h
JulNadeauCA/edacious
41787e2dc7d42226313fb65c79d00c1d94ec8e36
[ "BSD-2-Clause" ]
null
null
null
core/dc.h
JulNadeauCA/edacious
41787e2dc7d42226313fb65c79d00c1d94ec8e36
[ "BSD-2-Clause" ]
2
2020-06-13T03:33:39.000Z
2021-04-02T17:23:15.000Z
/* Public domain */ typedef struct es_sim_dc { struct es_sim _inherit; enum es_integration_method method; /* Method of integration used */ AG_Timer toUpdate; /* Timer for simulation updates */ M_Real Telapsed; /* Simulated elapsed time (s) */ M_Real deltaT; /* Simulated time since last iteration (s) */ Uint ticksDelay; /* Simulation speed (delay ms) */ Uint currStep; /* Number of current step */ Uint isDamped; /* 1 if any components had to damp voltage guesses in the previous iteration, 0 otherwise */ Uint inputStep; /* flag that can be set by active components to aid simulation: 1 if there is a discontinuity in input, 0 otherwise */ Uint retriesMax; /* Maximum number of times time step may be decimated before halting simulation */ Uint itersMax; /* Limit on iterations/step */ Uint itersHigh; /* Most iterations/step recorded */ Uint itersLow; /* Least iterations/step recorded */ M_Real stepLow; /* Smallest timestep used */ M_Real stepHigh; /* Largest timestep used */ M_Real T0; /* Reference temperature */ M_Matrix *A; /* Block matrix [G,B; C,D] */ M_Vector *z; /* Right-hand side vector (i,e) */ M_Vector *x; /* Vector of unknowns (v,j) */ M_Vector *xPrevIter; /* Solution from last iteration */ int stepsToKeep; /* Number of previous solutions to keep */ M_Vector **xPrevSteps; /* Solutions from last steps */ M_Real *deltaTPrevSteps;/* Previous timesteps. deltaTPrevSteps[i] is * the timestep used to compute xPrevSteps[i] */ M_Real *groundNode; /* Pointer to A(0, 0) */ } ES_SimDC; __BEGIN_DECLS extern const ES_SimOps esSimDcOps; __END_DECLS
36.765957
70
0.667824
[ "vector" ]
64060b5aeb5aed357110cf60829641f4c7044564
1,479
h
C
test/GsmCommandAction.h
iwasz/libstatemachine
6e6accc3085bd2d5ea130665a9618b16fea38980
[ "MIT" ]
null
null
null
test/GsmCommandAction.h
iwasz/libstatemachine
6e6accc3085bd2d5ea130665a9618b16fea38980
[ "MIT" ]
null
null
null
test/GsmCommandAction.h
iwasz/libstatemachine
6e6accc3085bd2d5ea130665a9618b16fea38980
[ "MIT" ]
null
null
null
#ifndef GSMCOMMANDACTION_H #define GSMCOMMANDACTION_H #include <Action.h> #include <cstdint> #include <cstdio> #include <string> #include <vector> extern std::vector<std::string> gsmModemCommandsIssued; /** * @brief Wysyłajakieś polecenie AT do modemu. */ template <typename EventT = string> class GsmCommandAction : public Action<EventT> { public: using EventType = EventT; GsmCommandAction (const char *c) : command (c), len (0) {} GsmCommandAction (uint8_t const *c, uint16_t len) : command (reinterpret_cast<const char *> (c)), len (len) {} virtual ~GsmCommandAction () = default; bool run (EventType const &event); protected: const char *command; uint16_t len; }; /*****************************************************************************/ template <typename EventT> bool GsmCommandAction<EventT>::run (EventType const &) { gsmModemCommandsIssued.push_back (command); return true; } /*****************************************************************************/ template <typename EventT = string> GsmCommandAction<EventT> *gsm (const char *command) { return new GsmCommandAction<EventT> (command); } /*****************************************************************************/ template <typename EventT = string> GsmCommandAction<EventT> *gsmBin (uint8_t const *command, uint16_t len) { return new GsmCommandAction<EventT> (command, len); } #endif // GSMCOMMANDACTION_H
29.58
138
0.587559
[ "vector" ]
6411fd7483da7d4f6f6be17d21f3dc8836adecd8
8,055
h
C
lib/Target/AMDGPU/Disassembler/CodeObject.h
AlexVlx/llvm
08ba61dfeeac3e1eccff413870340197935e28bc
[ "Apache-2.0" ]
18
2016-08-16T08:33:57.000Z
2021-05-11T18:56:34.000Z
lib/Target/AMDGPU/Disassembler/CodeObject.h
AlexVlx/llvm
08ba61dfeeac3e1eccff413870340197935e28bc
[ "Apache-2.0" ]
71
2016-07-26T15:16:53.000Z
2022-03-31T14:39:47.000Z
lib/Target/AMDGPU/Disassembler/CodeObject.h
AlexVlx/llvm
08ba61dfeeac3e1eccff413870340197935e28bc
[ "Apache-2.0" ]
66
2016-08-12T21:37:57.000Z
2020-04-03T16:51:44.000Z
//===- CodeObject.hpp - ELF object file implementation ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file declares the HSA Code Object file class. // //===----------------------------------------------------------------------===// #ifndef AMDGPU_DISASSEMBLER_HSA_CODE_OBJECT_HPP #define AMDGPU_DISASSEMBLER_HSA_CODE_OBJECT_HPP #include "AMDKernelCodeT.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/StringRef.h" #include "llvm/Object/ELFObjectFile.h" #include "llvm/Support/Endian.h" namespace llvm { //===----------------------------------------------------------------------===// // ELFNote //===----------------------------------------------------------------------===// struct amdgpu_hsa_code_object_version { support::ulittle32_t major_version; support::ulittle32_t minor_version; }; struct amdgpu_hsa_isa { support::ulittle16_t vendor_name_size; support::ulittle16_t architecture_name_size; support::ulittle32_t major; support::ulittle32_t minor; support::ulittle32_t stepping; char names[1]; StringRef getVendorName() const { return StringRef(names, vendor_name_size - 1); } StringRef getArchitectureName() const { return StringRef(names + vendor_name_size, architecture_name_size - 1); } }; struct ELFNote { support::ulittle32_t namesz; support::ulittle32_t descsz; support::ulittle32_t type; enum {ALIGN = 4}; ELFNote() = delete; ELFNote(const ELFNote&) = delete; ELFNote& operator =(const ELFNote&) = delete; StringRef getName() const { return StringRef(reinterpret_cast<const char*>(this) + sizeof(*this), namesz); } StringRef getDesc() const { return StringRef(getName().data() + alignTo(namesz, ALIGN), descsz); } size_t getSize() const { return sizeof(*this) + alignTo(namesz, ALIGN) + alignTo(descsz, ALIGN); } template <typename D> Expected<const D*> as() const { if (descsz < sizeof(D)) { return make_error<StringError>("invalid descsz", object::object_error::parse_failed); } return reinterpret_cast<const D*>(getDesc().data()); } }; const ELFNote* getNext(const ELFNote &N); template <typename Item> class const_varsize_item_iterator : std::iterator<std::forward_iterator_tag, const Item, void> { ArrayRef<uint8_t> Ref; const Item *item() const { return reinterpret_cast<const Item*>(Ref.data()); } size_t getItemPadSize() const { assert(Ref.size() >= sizeof(Item)); return (const uint8_t*)getNext(*item()) - (const uint8_t*)item(); } public: const_varsize_item_iterator() {} const_varsize_item_iterator(ArrayRef<uint8_t> Ref_) : Ref(Ref_) {} bool valid() const { return Ref.size() >= sizeof(Item) && Ref.size() >= getItemPadSize(); } Expected<const Item&> operator*() const { if (!valid()) { return make_error<StringError>("invalid item", object::object_error::parse_failed); } return *item(); } bool operator==(const const_varsize_item_iterator &Other) const { return (Ref.size() == Other.Ref.size()) && (Ref.empty() || Ref.data() == Other.Ref.data()); } bool operator!=(const const_varsize_item_iterator &Other) const { return !(*this == Other); } const_varsize_item_iterator &operator++() { // preincrement Ref = Ref.size() >= sizeof(Item) ? Ref.slice((std::min)(getItemPadSize(), Ref.size())) : decltype(Ref)(); return *this; } }; //===----------------------------------------------------------------------===// // FunctionSym //===----------------------------------------------------------------------===// class HSACodeObject; class FunctionSym : public object::ELF64LEObjectFile::Elf_Sym { public: Expected<uint64_t> getAddress(const HSACodeObject *CodeObject) const; Expected<uint64_t> getAddress( const HSACodeObject *CodeObject, const object::ELF64LEObjectFile::Elf_Shdr *Text) const; Expected<uint64_t> getSectionOffset(const HSACodeObject *CodeObject) const; Expected<uint64_t> getSectionOffset( const HSACodeObject *CodeObject, const object::ELF64LEObjectFile::Elf_Shdr *Text) const; Expected<uint64_t> getCodeOffset( const HSACodeObject *CodeObject, const object::ELF64LEObjectFile::Elf_Shdr *Text) const; static Expected<const FunctionSym *> asFunctionSym(const object::ELF64LEObjectFile::Elf_Sym *Sym); }; class KernelSym : public FunctionSym { public: Expected<uint64_t> getCodeOffset(const HSACodeObject *CodeObject, const object::ELF64LEObjectFile::Elf_Shdr *Text) const; Expected<const amd_kernel_code_t *> getAmdKernelCodeT(const HSACodeObject *CodeObject) const; Expected<const amd_kernel_code_t *> getAmdKernelCodeT(const HSACodeObject *CodeObject, const object::ELF64LEObjectFile::Elf_Shdr *Text) const; static Expected<const KernelSym *> asKernelSym(const FunctionSym *Sym); }; template <typename BaseIterator> class conditional_iterator : public iterator_adaptor_base< conditional_iterator<BaseIterator>, BaseIterator, std::forward_iterator_tag> { public: typedef std::function< bool(const typename conditional_iterator::iterator_adaptor_base::value_type&) > PredicateTy; protected: BaseIterator End; PredicateTy Predicate; public: conditional_iterator(BaseIterator BI, BaseIterator E, PredicateTy P) : conditional_iterator::iterator_adaptor_base(BI), End(E), Predicate(P) { while (this->I != End && !Predicate(*this->I)) { ++this->I; } } conditional_iterator &operator++() { do { ++this->I; } while (this->I != End && !Predicate(*this->I)); return *this; } }; class function_sym_iterator : public conditional_iterator<object::elf_symbol_iterator> { public: function_sym_iterator(object::elf_symbol_iterator It, object::elf_symbol_iterator End, PredicateTy P) : conditional_iterator<object::elf_symbol_iterator>(It, End, P) {} const object::ELFSymbolRef &operator*() const { return *I; } }; //===----------------------------------------------------------------------===// // HSACodeObject //===----------------------------------------------------------------------===// class HSACodeObject : public object::ELF64LEObjectFile { private: mutable SmallVector<uint64_t, 8> FunctionMarkers; void InitMarkers() const; HSACodeObject(object::ELF64LEObjectFile &&Obj) : object::ELF64LEObjectFile(std::move(Obj)) { InitMarkers(); } public: static Expected<std::unique_ptr<HSACodeObject>> create(MemoryBufferRef Wrapper) { auto Obj = object::ELF64LEObjectFile::create(Wrapper); if (auto E = Obj.takeError()) return std::move(E); std::unique_ptr<HSACodeObject> Ret(new HSACodeObject(std::move(*Obj))); return std::move(Ret); } typedef const_varsize_item_iterator<ELFNote> note_iterator; note_iterator notes_begin() const; note_iterator notes_end() const; iterator_range<note_iterator> notes() const; function_sym_iterator functions_begin() const; function_sym_iterator functions_end() const; iterator_range<function_sym_iterator> functions() const; Expected<ArrayRef<uint8_t>> getCode(const FunctionSym *Function) const; Expected<const Elf_Shdr *> getSectionByName(StringRef Name) const; Expected<uint32_t> getSectionIdxByName(StringRef) const; Expected<uint32_t> getTextSectionIdx() const; Expected<uint32_t> getNoteSectionIdx() const; Expected<const Elf_Shdr *> getTextSection() const; Expected<const Elf_Shdr *> getNoteSection() const; friend class FunctionSym; friend class KernelSym; }; } // namespace llvm #endif
29.184783
82
0.637616
[ "object" ]
641204a49ef0a77133041c935a77870464a12228
2,025
h
C
client/src/datahandler/accountManagement.h
zDestinate/InventoryManagement
b2f568cbeca3e9fa7e2c1fc213f3b527a6755216
[ "MIT" ]
null
null
null
client/src/datahandler/accountManagement.h
zDestinate/InventoryManagement
b2f568cbeca3e9fa7e2c1fc213f3b527a6755216
[ "MIT" ]
null
null
null
client/src/datahandler/accountManagement.h
zDestinate/InventoryManagement
b2f568cbeca3e9fa7e2c1fc213f3b527a6755216
[ "MIT" ]
null
null
null
#pragma once #include <string> #include <vector> #include "datahandler/getData.h" #include "datahandler/LogIn.h" #include "lib/json.hpp" using json = nlohmann::json; //user/create/:username/:phone/:email/:perm/:flname class User { public: std::string id,user, phone, email,perm,flname; User(std::string id,std::string user, std::string phone, std::string email,std::string perm,std::string flname) { this->id = id; this->user = user; this->phone = phone; this->email = email; this->perm = perm; this->flname = flname; } }; class custAcc : public User { public: custAcc(std::string id,std::string user, std::string phone, std::string email,std::string perm,std::string flname) : User(id,user, phone, email, perm, flname) { //Constructor of Customer } }; class workerEmp : public User { public: workerEmp(std::string id,std::string user, std::string phone, std::string email,std::string perm,std::string flname) : User(id,user, phone, email, perm, flname) { //Constructor of Customer } }; class accountManagement { private: //CUSTOMER FUNCTIONS bool checkphoneNum(std::string phoneNum); bool isChar(char c); bool isDigit(const char c); bool is_valid(std::string email); //EMP & SUP FUNCTIONS const std::string URL; getData* getEmp; std:: string empName,empID,empPosition; UserLogIn* checkPass; public: //user/create/:username/:phone/:email/:perm/:flname std::vector<workerEmp> vectEmp; std::vector<custAcc> vectCust; std::vector<User> vUser; bool checkPhoneEmail(std::string phoneNum, std::string email); bool allUserData(json userData); bool checkName(std::string flname); bool editUserInfo(std::string userName,std::string fullName,std::string email,std::string phoneNumber,std::string permission); };
25.961538
130
0.624198
[ "vector" ]
64124ac125da5a1f48f3f61e74e0cdc2b9face80
932
h
C
src/vant/include/vant/vant.h
RPerobeli/Type-2-FLS-Simulation
3b78fc9b670da489792361693ed664a3ce594cb7
[ "Apache-2.0" ]
null
null
null
src/vant/include/vant/vant.h
RPerobeli/Type-2-FLS-Simulation
3b78fc9b670da489792361693ed664a3ce594cb7
[ "Apache-2.0" ]
null
null
null
src/vant/include/vant/vant.h
RPerobeli/Type-2-FLS-Simulation
3b78fc9b670da489792361693ed664a3ce594cb7
[ "Apache-2.0" ]
null
null
null
#ifndef VANT_H #define VANT_H #include <iostream> #include <ros/ros.h> #include "geometry_msgs/PoseStamped.h" #include "tf/tf.h" #include <cstdlib> #include "Eigen/Core" #include "Eigen/Geometry" #include <Eigen/LU> using namespace std; class vant{ public: vant(); struct dataPos{ double x,y,z; }; struct dataOrient{ double x,y,z,w; }; struct RPY{ double roll,pitch,yaw; }; void setVarCallback(const geometry_msgs::PoseStamped*); //void getVarCallback(dataPos*,dataOrient*); void getVarCallback(geometry_msgs::PoseStamped*); //void chatterCallback(const geometry_msgs::PoseStamped::ConstPtr&,geometry_msgs::PoseStamped::ConstPtr&); private: dataPos position; dataOrient orientation; geometry_msgs::PoseStamped poseVant; Eigen::MatrixXf m; }; #endif // VANT_H
19.020408
113
0.626609
[ "geometry" ]
641306f773ded029482b830b3475f05529f08f88
9,196
h
C
gpu/ipc/service/command_buffer_stub.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
gpu/ipc/service/command_buffer_stub.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
gpu/ipc/service/command_buffer_stub.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2021-01-05T23:43:46.000Z
2021-01-07T23:36:34.000Z
// 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 GPU_IPC_SERVICE_COMMAND_BUFFER_STUB_H_ #define GPU_IPC_SERVICE_COMMAND_BUFFER_STUB_H_ #include <stddef.h> #include <stdint.h> #include <memory> #include <string> #include <vector> #include "base/callback.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/time/time.h" #include "build/build_config.h" #include "gpu/command_buffer/common/command_buffer_id.h" #include "gpu/command_buffer/common/constants.h" #include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "gpu/command_buffer/service/command_buffer_service.h" #include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/service/decoder_client.h" #include "gpu/command_buffer/service/program_cache.h" #include "gpu/command_buffer/service/sequence_id.h" #include "gpu/ipc/common/surface_handle.h" #include "gpu/ipc/service/context_url.h" #include "gpu/ipc/service/gpu_ipc_service_export.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_sender.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/gpu_memory_buffer.h" #include "ui/gfx/swap_result.h" #include "ui/gl/gl_share_group.h" #include "ui/gl/gl_surface.h" #include "ui/gl/gpu_preference.h" #include "url/gurl.h" struct GPUCreateCommandBufferConfig; namespace gpu { class DecoderContext; class MemoryTracker; struct SyncToken; struct WaitForCommandState; class GpuChannel; class SyncPointClientState; class GPU_IPC_SERVICE_EXPORT CommandBufferStub : public IPC::Listener, public IPC::Sender, public CommandBufferServiceClient, public DecoderClient, public base::SupportsWeakPtr<CommandBufferStub> { public: class DestructionObserver { public: // Called in Destroy(), before the context/surface are released. // If |have_context| is false, then the context cannot be made current, else // it already is. virtual void OnWillDestroyStub(bool have_context) = 0; protected: virtual ~DestructionObserver() = default; }; CommandBufferStub(GpuChannel* channel, const GPUCreateCommandBufferConfig& init_params, CommandBufferId command_buffer_id, SequenceId sequence_id, int32_t stream_id, int32_t route_id); ~CommandBufferStub() override; // This must leave the GL context associated with the newly-created // CommandBufferStub current, so the GpuChannel can initialize // the gpu::Capabilities. virtual gpu::ContextResult Initialize( CommandBufferStub* share_group, const GPUCreateCommandBufferConfig& init_params, base::UnsafeSharedMemoryRegion shared_state_shm) = 0; virtual MemoryTracker* GetMemoryTracker() const = 0; // IPC::Listener implementation: bool OnMessageReceived(const IPC::Message& message) override; // IPC::Sender implementation: bool Send(IPC::Message* msg) override; // CommandBufferServiceClient implementation: CommandBatchProcessedResult OnCommandBatchProcessed() override; void OnParseError() override; // DecoderClient implementation: void OnConsoleMessage(int32_t id, const std::string& message) override; void CacheShader(const std::string& key, const std::string& shader) override; void OnFenceSyncRelease(uint64_t release) override; void OnDescheduleUntilFinished() override; void OnRescheduleAfterFinished() override; void ScheduleGrContextCleanup() override; void HandleReturnData(base::span<const uint8_t> data) override; using MemoryTrackerFactory = base::RepeatingCallback<std::unique_ptr<MemoryTracker>( const GPUCreateCommandBufferConfig&)>; // Overrides the way CreateMemoryTracker() uses to create a MemoryTracker. // This is intended for mocking the MemoryTracker in tests. static void SetMemoryTrackerFactoryForTesting(MemoryTrackerFactory factory); scoped_refptr<Buffer> GetTransferBuffer(int32_t id); void RegisterTransferBufferForTest(int32_t id, scoped_refptr<Buffer> buffer); // Whether this command buffer can currently handle IPC messages. bool IsScheduled(); // Whether there are commands in the buffer that haven't been processed. bool HasUnprocessedCommands(); DecoderContext* decoder_context() const { return decoder_context_.get(); } GpuChannel* channel() const { return channel_; } // Unique command buffer ID for this command buffer stub. CommandBufferId command_buffer_id() const { return command_buffer_id_; } SequenceId sequence_id() const { return sequence_id_; } int32_t stream_id() const { return stream_id_; } gl::GLSurface* surface() const { return surface_.get(); } ContextType context_type() const { return context_type_; } void AddDestructionObserver(DestructionObserver* observer); void RemoveDestructionObserver(DestructionObserver* observer); void MarkContextLost(); scoped_refptr<gl::GLShareGroup> share_group() { return share_group_; } protected: virtual bool HandleMessage(const IPC::Message& message) = 0; std::unique_ptr<MemoryTracker> CreateMemoryTracker( const GPUCreateCommandBufferConfig& init_params) const; // Must be called during Initialize(). Takes ownership to co-ordinate // teardown in Destroy(). void set_decoder_context(std::unique_ptr<DecoderContext> decoder_context) { decoder_context_ = std::move(decoder_context); } void CheckContextLost(); // Sets |active_url_| as the active GPU process URL. void UpdateActiveUrl(); // The lifetime of objects of this class is managed by a GpuChannel. The // GpuChannels destroy all the CommandBufferStubs that they own when // they are destroyed. So a raw pointer is safe. GpuChannel* const channel_; ContextType context_type_; ContextUrl active_url_; bool initialized_; const SurfaceHandle surface_handle_; bool use_virtualized_gl_context_; std::unique_ptr<CommandBufferService> command_buffer_; scoped_refptr<gl::GLSurface> surface_; scoped_refptr<SyncPointClientState> sync_point_client_state_; scoped_refptr<gl::GLShareGroup> share_group_; const CommandBufferId command_buffer_id_; const SequenceId sequence_id_; const int32_t stream_id_; const int32_t route_id_; private: void Destroy(); bool MakeCurrent(); gles2::ProgramCache::ScopedCacheUse CreateCacheUse(); // Message handlers: void OnSetGetBuffer(int32_t shm_id); void OnGetState(IPC::Message* reply_message); void OnWaitForTokenInRange(int32_t start, int32_t end, IPC::Message* reply_message); void OnWaitForGetOffsetInRange(uint32_t set_get_buffer_count, int32_t start, int32_t end, IPC::Message* reply_message); void OnAsyncFlush(int32_t put_offset, uint32_t flush_id, const std::vector<SyncToken>& sync_token_fences); void OnRegisterTransferBuffer(int32_t id, base::UnsafeSharedMemoryRegion transfer_buffer); void OnDestroyTransferBuffer(int32_t id); void OnGetTransferBuffer(int32_t id, IPC::Message* reply_message); void OnSignalSyncToken(const SyncToken& sync_token, uint32_t id); void OnSignalAck(uint32_t id); void OnSignalQuery(uint32_t query, uint32_t id); void ReportState(); // Poll the command buffer to execute work. void PollWork(); void PerformWork(); // Schedule processing of delayed work. This updates the time at which // delayed work should be processed. |process_delayed_work_time_| is // updated to current time + delay. Call this after processing some amount // of delayed work. void ScheduleDelayedWork(base::TimeDelta delay); void CheckCompleteWaits(); // Set driver bug workarounds and disabled GL extensions to the context. static void SetContextGpuFeatureInfo(gl::GLContext* context, const GpuFeatureInfo& gpu_feature_info); static MemoryTrackerFactory GetMemoryTrackerFactory(); // Overrides the way CreateMemoryTracker() uses to create a MemoryTracker. If // |factory| is base::NullCallback(), it returns the current // MemoryTrackerFactory (initially base::NullCallback() which // CreateMemoryTracker() should interpret as a signal to use the default). // This is intended for mocking the MemoryTracker in tests. static MemoryTrackerFactory SetOrGetMemoryTrackerFactory( MemoryTrackerFactory factory); std::unique_ptr<DecoderContext> decoder_context_; uint32_t last_flush_id_; base::ObserverList<DestructionObserver>::Unchecked destruction_observers_; base::TimeTicks process_delayed_work_time_; uint32_t previous_processed_num_; base::TimeTicks last_idle_time_; std::unique_ptr<WaitForCommandState> wait_for_token_; std::unique_ptr<WaitForCommandState> wait_for_get_offset_; uint32_t wait_set_get_buffer_count_; DISALLOW_COPY_AND_ASSIGN(CommandBufferStub); }; } // namespace gpu #endif // GPU_IPC_SERVICE_COMMAND_BUFFER_STUB_H_
35.099237
80
0.749783
[ "geometry", "vector" ]
641d934a2cd4f22164f57a001d2769496e29f5f1
9,248
h
C
src/mongo/s/query/results_merger_test_fixture.h
Icantjuddle/mongo
dd246cc1d48436d15a7a6f7e93aa78b47332edfe
[ "Apache-2.0" ]
1
2019-01-16T12:59:12.000Z
2019-01-16T12:59:12.000Z
src/mongo/s/query/results_merger_test_fixture.h
Icantjuddle/mongo
dd246cc1d48436d15a7a6f7e93aa78b47332edfe
[ "Apache-2.0" ]
null
null
null
src/mongo/s/query/results_merger_test_fixture.h
Icantjuddle/mongo
dd246cc1d48436d15a7a6f7e93aa78b47332edfe
[ "Apache-2.0" ]
null
null
null
/** * Copyright (C) 2018 MongoDB Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects * for all of the code used other than as permitted herein. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you do not * wish to do so, delete this exception statement from your version. If you * delete this exception statement from all source files in the program, * then also delete it in the license file. */ #pragma once #include "mongo/s/query/async_results_merger.h" #include "mongo/s/sharding_router_test_fixture.h" namespace mongo { /** * Test fixture which is useful to both the tests for AsyncResultsMerger and BlockingResultsMerger. */ class ResultsMergerTestFixture : public ShardingTestFixture { public: static const HostAndPort kTestConfigShardHost; static const std::vector<ShardId> kTestShardIds; static const std::vector<HostAndPort> kTestShardHosts; static const NamespaceString kTestNss; ResultsMergerTestFixture() {} void setUp() override; protected: /** * Constructs an AsyncResultsMergerParams object with the given vector of existing cursors. * * If 'findCmd' is not set, the default AsyncResultsMergerParams are used. Otherwise, the * 'findCmd' is used to construct the AsyncResultsMergerParams. * * 'findCmd' should not have a 'batchSize', since the find's batchSize is used just in the * initial find. The getMore 'batchSize' can be passed in through 'getMoreBatchSize.' */ AsyncResultsMergerParams makeARMParamsFromExistingCursors( std::vector<RemoteCursor> remoteCursors, boost::optional<BSONObj> findCmd = boost::none, boost::optional<std::int64_t> getMoreBatchSize = boost::none) { AsyncResultsMergerParams params; params.setNss(kTestNss); params.setRemotes(std::move(remoteCursors)); if (findCmd) { const auto qr = unittest::assertGet( QueryRequest::makeFromFindCommand(kTestNss, *findCmd, false /* isExplain */)); if (!qr->getSort().isEmpty()) { params.setSort(qr->getSort().getOwned()); } if (getMoreBatchSize) { params.setBatchSize(getMoreBatchSize); } else { params.setBatchSize(qr->getBatchSize() ? boost::optional<std::int64_t>( static_cast<std::int64_t>(*qr->getBatchSize())) : boost::none); } params.setTailableMode(qr->getTailableMode()); params.setAllowPartialResults(qr->isAllowPartialResults()); } OperationSessionInfo sessionInfo; sessionInfo.setSessionId(operationContext()->getLogicalSessionId()); sessionInfo.setTxnNumber(operationContext()->getTxnNumber()); params.setOperationSessionInfo(sessionInfo); return params; } /** * Constructs an ARM with the given vector of existing cursors. * * If 'findCmd' is not set, the default AsyncResultsMergerParams are used. * Otherwise, the 'findCmd' is used to construct the AsyncResultsMergerParams. * * 'findCmd' should not have a 'batchSize', since the find's batchSize is used just in the * initial find. The getMore 'batchSize' can be passed in through 'getMoreBatchSize.' */ std::unique_ptr<AsyncResultsMerger> makeARMFromExistingCursors( std::vector<RemoteCursor> remoteCursors, boost::optional<BSONObj> findCmd = boost::none, boost::optional<std::int64_t> getMoreBatchSize = boost::none) { return stdx::make_unique<AsyncResultsMerger>( operationContext(), executor(), makeARMParamsFromExistingCursors(std::move(remoteCursors), findCmd, getMoreBatchSize)); } /** * Schedules a "CommandOnShardedViewNotSupportedOnMongod" error response w/ view definition. */ void scheduleNetworkViewResponse(const std::string& ns, const std::string& pipelineJsonArr) { BSONObjBuilder viewDefBob; viewDefBob.append("ns", ns); viewDefBob.append("pipeline", fromjson(pipelineJsonArr)); BSONObjBuilder bob; bob.append("resolvedView", viewDefBob.obj()); bob.append("ok", 0.0); bob.append("errmsg", "Command on view must be executed by mongos"); bob.append("code", 169); std::vector<BSONObj> batch = {bob.obj()}; scheduleNetworkResponseObjs(batch); } /** * Schedules a list of cursor responses to be returned by the mock network. */ void scheduleNetworkResponses(std::vector<CursorResponse> responses) { std::vector<BSONObj> objs; for (const auto& cursorResponse : responses) { // For tests of the AsyncResultsMerger, all CursorRepsonses scheduled by the tests are // subsequent responses, since the AsyncResultsMerger will only ever run getMores. objs.push_back(cursorResponse.toBSON(CursorResponse::ResponseType::SubsequentResponse)); } scheduleNetworkResponseObjs(objs); } /** * Schedules a list of raw BSON command responses to be returned by the mock network. */ void scheduleNetworkResponseObjs(std::vector<BSONObj> objs) { executor::NetworkInterfaceMock* net = network(); net->enterNetwork(); for (const auto& obj : objs) { ASSERT_TRUE(net->hasReadyRequests()); Milliseconds millis(0); executor::RemoteCommandResponse response(obj, millis); executor::TaskExecutor::ResponseStatus responseStatus(response); net->scheduleResponse(net->getNextReadyRequest(), net->now(), responseStatus); } net->runReadyNetworkOperations(); net->exitNetwork(); } executor::RemoteCommandRequest getNthPendingRequest(size_t n) { executor::NetworkInterfaceMock* net = network(); net->enterNetwork(); ASSERT_TRUE(net->hasReadyRequests()); executor::NetworkInterfaceMock::NetworkOperationIterator noi = net->getNthUnscheduledRequest(n); executor::RemoteCommandRequest retRequest = noi->getRequest(); net->exitNetwork(); return retRequest; } bool networkHasReadyRequests() { executor::NetworkInterfaceMock::InNetworkGuard guard(network()); return guard->hasReadyRequests(); } void scheduleErrorResponse(executor::ResponseStatus rs) { invariant(!rs.isOK()); rs.elapsedMillis = Milliseconds(0); executor::NetworkInterfaceMock* net = network(); net->enterNetwork(); ASSERT_TRUE(net->hasReadyRequests()); net->scheduleResponse(net->getNextReadyRequest(), net->now(), rs); net->runReadyNetworkOperations(); net->exitNetwork(); } void runReadyCallbacks() { executor::NetworkInterfaceMock* net = network(); net->enterNetwork(); net->runReadyNetworkOperations(); net->exitNetwork(); } void blackHoleNextRequest() { executor::NetworkInterfaceMock* net = network(); net->enterNetwork(); ASSERT_TRUE(net->hasReadyRequests()); net->blackHole(net->getNextReadyRequest()); net->exitNetwork(); } void assertKillCusorsCmdHasCursorId(const BSONObj& killCmd, CursorId cursorId) { std::cout << "CHARLIE: " << killCmd; ASSERT_TRUE(killCmd.hasElement("killCursors")); ASSERT_EQ(killCmd["cursors"].type(), BSONType::Array); size_t numCursors = 0; for (auto&& cursor : killCmd["cursors"].Obj()) { ASSERT_EQ(cursor.type(), BSONType::NumberLong); ASSERT_EQ(cursor.numberLong(), cursorId); ++numCursors; } ASSERT_EQ(numCursors, 1u); } RemoteCursor makeRemoteCursor(ShardId shardId, HostAndPort host, CursorResponse response) { RemoteCursor remoteCursor; remoteCursor.setShardId(std::move(shardId)); remoteCursor.setHostAndPort(std::move(host)); remoteCursor.setCursorResponse(std::move(response)); return remoteCursor; } }; } // namespace mongo
40.384279
100
0.665766
[ "object", "vector" ]
642a0dc08f5fab4c5642cc44201f537bc5e7f1fe
5,048
h
C
src/core/engine/scene/Transform.h
Kelan0/WorldEngine
e76e7ff47278e837f4d1b9216773dd79eeee1b52
[ "MIT" ]
null
null
null
src/core/engine/scene/Transform.h
Kelan0/WorldEngine
e76e7ff47278e837f4d1b9216773dd79eeee1b52
[ "MIT" ]
null
null
null
src/core/engine/scene/Transform.h
Kelan0/WorldEngine
e76e7ff47278e837f4d1b9216773dd79eeee1b52
[ "MIT" ]
null
null
null
#ifndef WORLDENGINE_TRANSFORM_H #define WORLDENGINE_TRANSFORM_H #include "core/core.h" #include "core/util/EntityChangeTracker.h" class Transform { friend class SceneRenderer; public: Transform(); Transform(const glm::mat4& transformationMatrix); Transform(const Transform& copy); Transform(Transform&& move) noexcept; ~Transform(); const glm::dvec3& getTranslation() const; const double& getX() const; const double& getY() const; const double& getZ() const; glm::quat getRotation() const; const glm::mat3& getRotationMatrix() const; const glm::vec3& getXAxis() const; glm::vec3 getLeftAxis() const; glm::vec3 getRightAxis() const; const glm::vec3& getYAxis() const; glm::vec3 getDownAxis() const; glm::vec3 getUpAxis() const; const glm::vec3& getZAxis() const; glm::vec3 getForwardAxis() const; glm::vec3 getBackwardAxis() const; glm::vec3 getEulerAngles() const; float getPitch() const; float getYaw() const; float getRoll() const; const glm::dvec3& getScale() const; const double& getScaleX() const; const double& getScaleY() const; const double& getScaleZ() const; Transform& setTranslation(const glm::dvec4& translation); Transform& setTranslation(const glm::dvec3& translation); Transform& setTranslation(const glm::dvec2& translation); Transform& setTranslation(double x, double y, double z); Transform& setTranslation(double x, double y); Transform& setRotation(const glm::mat3& rotation); Transform& setRotation(const glm::mat4& rotation); Transform& setRotation(const glm::vec3& forward, const glm::vec3& up, bool normalized = true); Transform& setRotation(const glm::quat& rotation, bool normalized = true); Transform& setRotation(const glm::vec3& eulerAngles); Transform& setRotation(float pitch, float yaw, float roll); Transform& setRotation(float pitch, float yaw); Transform& setScale(const glm::dvec3& scale); Transform& setScale(double x, double y, double z); Transform& setScale(double scale); Transform& translate(const glm::dvec4& translation); Transform& translate(const glm::dvec3& translation); Transform& translate(const glm::dvec2& translation); Transform& translate(double x, double y, double z); Transform& translate(double x, double y); Transform& rotate(const glm::quat& rotation, bool normalized = true); Transform& rotate(const glm::mat3& rotation, bool normalized = true); Transform& rotate(const glm::mat4& rotation, bool normalized = true); Transform& rotate(const glm::vec3& axis, float angle); Transform& rotate(const glm::vec4& axisAngle); Transform& rotate(float x, float y, float z, float angle); Transform& rotate(const glm::vec3& eulerAngles); Transform& rotate(float pitch, float yaw, float roll); Transform& scale(const glm::dvec3& scale); Transform& scale(double x, double y, double z); Transform& scale(double scale); Transform operator*(const glm::dmat4& other) const; Transform operator*(const Transform& other) const; Transform& operator=(glm::dmat4 other); Transform& operator=(const Transform& other); bool equalsTranslation(const Transform& other, double epsilon) const; bool equalsRotation(const Transform& other, double epsilon) const; bool equalsScale(const Transform& other, double epsilon) const; bool equalsTranslation(const Transform& other) const; bool equalsRotation(const Transform& other) const; bool equalsScale(const Transform& other) const; bool operator==(const Transform& other) const; bool operator==(const glm::dmat4& other) const; bool operator==(const glm::mat4& other) const; bool operator!=(const Transform& other) const; bool operator!=(const glm::dmat4& other) const; bool operator!=(const glm::mat4& other) const; glm::dmat4 getMatrix() const; glm::dmat4& fillMatrix(glm::dmat4& matrix) const; glm::mat4& fillMatrix(glm::mat4& matrix) const; glm::mat4x3& fillMatrix(glm::mat4x3& matrix) const; Transform& setMatrix(const glm::dmat4& matrix); operator glm::dmat4() const; static void reindex(Transform& transform, const EntityChangeTracker::entity_index& newEntityIndex); private: void change(); private: glm::dvec3 m_translation; glm::mat3 m_rotation; glm::dvec3 m_scale; EntityChangeTracker::entity_index m_entityIndex = EntityChangeTracker::INVALID_INDEX; }; namespace std { template<> struct hash<Transform> { size_t operator()(const Transform& v) const { size_t seed = 0; std::hash_combine(seed, v.getTranslation()); std::hash_combine(seed, v.getEulerAngles()); std::hash_combine(seed, v.getScale()); return seed; } }; } #endif //WORLDENGINE_TRANSFORM_H
35.055556
104
0.6771
[ "transform" ]
64355dd8d0220eb2688402457f08d7d053735d0d
4,618
h
C
Classes/EventListController.h
lsst-epo/transient_events_ios_app
f37492c27f679be5857b00d590dd79261f78f2fa
[ "Apache-2.0" ]
null
null
null
Classes/EventListController.h
lsst-epo/transient_events_ios_app
f37492c27f679be5857b00d590dd79261f78f2fa
[ "Apache-2.0" ]
null
null
null
Classes/EventListController.h
lsst-epo/transient_events_ios_app
f37492c27f679be5857b00d590dd79261f78f2fa
[ "Apache-2.0" ]
null
null
null
// // EventListController.h // Transient Events // // Created by Bruce E Truax on 8/7/09. // Copyright 2009 Diffraction Limited Design LLC. All rights reserved. // #import <UIKit/UIKit.h> /** @brief Downloads and displays event table view The event list controller handles the Events tab on the tab bar. This is the first page which comes up when the app is first launched. The EventListController creates a POST request based on the values of the settings which are stored in user defaults. This POST request is sent to the server. The server then returns a JSON formatted response string which is parsed and the individual events are put into an array which is then used to populate the table. The thumbnail images which are also displayed in the table are queued up and downloaded in the background. When an event is touch the EventListController loads a detail view controller and hands off control to the detail controller by pushing it onto the top of the navigation controller stack. There is a reasonable amount if intelligence in determining if the data needs to be reloaded from the server. If you go to the detail controller and then back there is no need to reload. If you change a setting it is the responsibility of the setting controller to send either a kRefreshNotification or a kReloadNotification to tell the EventList controller whether it needs to reload the data or just refresh the table view. I have tested this with very large amount of downloaded data on a first gen iPod Touch without encountering memory issues. Just in case, if a memory warning is issued the image cache is cleared of all images. They then reload when needed. This object does not use CoreData for storage, just a simple array store. This is different from the BookMarkListController which uses CoreData. Perhaps someday this can be changed. */ @interface EventListController : UIViewController <UITableViewDataSource, UITableViewDelegate>{ UINavigationController *navController; //!< Contains the navigation controller UITableView *tableView; //!< pointer to the table view NSArray *transientDataArray; //!< The array of transient data after parsing by the JSON parser NSOperationQueue *operationQueue; UIActivityIndicatorView *spinner; UILabel *loadingLabel; BOOL returningFromDetailView; NSMutableDictionary *cachedImages; //!< store for cached images url is key for image data NSMutableData *resultsData; //!< store fore results data after parsing NSURLConnection *urlConnection; UIImage *loadingImage; //!< pointer to "Loading…" image UIImage *alertImage; //!< pointer to ALERT image NSIndexPath *currentSelection; //!< state variable for selected row NSUserDefaults *userDefaults; int resumptionToken; //!< token telling the server where to resume its search for the next batch of results BOOL reloadNeeded; BOOL refreshNeeded; BOOL loadingMoreData; } @property (nonatomic, retain) UINavigationController *navController; @property (nonatomic, retain) UITableView *tableView; @property (nonatomic, retain) NSArray *transientDataArray; @property (nonatomic, retain) NSMutableDictionary *cachedImages; @property (nonatomic, retain) NSMutableData *resultsData; @property (nonatomic, retain) NSURLConnection *urlConnection; @property (nonatomic, retain) UIImage *loadingImage; @property (nonatomic, retain) UIImage *alertImage; @property (nonatomic, retain) NSIndexPath *currentSelection; @property (assign) int resumptionToken; - (void)beginLoadingTransientData; //!< starts loading transient data synchronously - (void)showLoadingIndicators; //!< shows the loading indicator - (void)hideLoadingIndicators; //!< hides the loading indicator - (UIImage *)cachedImageForURL:(NSURL *)url; //!< gets the image with the specified URL downloads if necessary - (void)didFinishLoadingImageWithResult:(NSDictionary *)result; //!< callback function for ImageLoadingOperation - (void)beginLoadingTransientDataAsync; //!< starts background loading of Transient data from server - (void)removeNonVisibleObjects; //!< Removes objects which are below minimum elevation - (IBAction)displayHelp; //!< displays help page - (IBAction)reloadEvents; //!< forces reload of all events - (void)setNeedsReload; //!< sets flag to to tell EventListController to reload all data - (void)setNeedsRefresh; //!< sets flag to tell EventListController to redisplay table - (void)alertOccurred; //!< handles an immediate redisplay if an alert occurs - (void)setFooterForTableView; //!< sets the correct size footer for the event list table. DEPRECATED @end
51.311111
112
0.782373
[ "object" ]
643b48466591913e39063b1c5ed7e9bdd9407f86
1,757
c
C
src/item_type.c
wolfgangmauer/valadevelop
135439ece170f9d4719313d7b5dd6b12f2dba74d
[ "MIT" ]
30
2019-03-03T12:33:18.000Z
2021-02-04T20:11:46.000Z
src/item_type.c
wolfgangmauer/valadevelop
135439ece170f9d4719313d7b5dd6b12f2dba74d
[ "MIT" ]
14
2019-02-22T15:19:07.000Z
2019-10-12T16:38:30.000Z
src/item_type.c
wolfgangmauer/valadevelop
135439ece170f9d4719313d7b5dd6b12f2dba74d
[ "MIT" ]
3
2019-04-04T22:00:28.000Z
2020-07-30T07:35:43.000Z
/* item_type.c generated by valac UNKNOWN, the Vala compiler * generated from item_type.vala, do not modify */ #include <glib-object.h> typedef enum { VALA_DEVELOP_ITEM_TYPE_None = 0, VALA_DEVELOP_ITEM_TYPE_Solution = 1, VALA_DEVELOP_ITEM_TYPE_Project = 2, VALA_DEVELOP_ITEM_TYPE_Resource = 4, VALA_DEVELOP_ITEM_TYPE_Source = 8, VALA_DEVELOP_ITEM_TYPE_Package = 16, VALA_DEVELOP_ITEM_TYPE_Directory = 32, VALA_DEVELOP_ITEM_TYPE_Vapi = 64 } valaDevelopItemType; #define VALA_DEVELOP_TYPE_ITEM_TYPE (vala_develop_item_type_get_type ()) GType vala_develop_item_type_get_type (void) G_GNUC_CONST; GType vala_develop_item_type_get_type (void) { static volatile gsize vala_develop_item_type_type_id__volatile = 0; if (g_once_init_enter (&vala_develop_item_type_type_id__volatile)) { static const GEnumValue values[] = {{VALA_DEVELOP_ITEM_TYPE_None, "VALA_DEVELOP_ITEM_TYPE_None", "none"}, {VALA_DEVELOP_ITEM_TYPE_Solution, "VALA_DEVELOP_ITEM_TYPE_Solution", "solution"}, {VALA_DEVELOP_ITEM_TYPE_Project, "VALA_DEVELOP_ITEM_TYPE_Project", "project"}, {VALA_DEVELOP_ITEM_TYPE_Resource, "VALA_DEVELOP_ITEM_TYPE_Resource", "resource"}, {VALA_DEVELOP_ITEM_TYPE_Source, "VALA_DEVELOP_ITEM_TYPE_Source", "source"}, {VALA_DEVELOP_ITEM_TYPE_Package, "VALA_DEVELOP_ITEM_TYPE_Package", "package"}, {VALA_DEVELOP_ITEM_TYPE_Directory, "VALA_DEVELOP_ITEM_TYPE_Directory", "directory"}, {VALA_DEVELOP_ITEM_TYPE_Vapi, "VALA_DEVELOP_ITEM_TYPE_Vapi", "vapi"}, {0, NULL, NULL}}; GType vala_develop_item_type_type_id; vala_develop_item_type_type_id = g_enum_register_static ("valaDevelopItemType", values); g_once_init_leave (&vala_develop_item_type_type_id__volatile, vala_develop_item_type_type_id); } return vala_develop_item_type_type_id__volatile; }
51.676471
678
0.833238
[ "object" ]
643c3267406826c4e49329b930f9a6e5e3092c95
16,108
h
C
inc/core/EventModel.h
sudoBash418/microbit-dal
5c62d29418f73ca16d02a9e847d2ad0ecbeda0b4
[ "MIT" ]
null
null
null
inc/core/EventModel.h
sudoBash418/microbit-dal
5c62d29418f73ca16d02a9e847d2ad0ecbeda0b4
[ "MIT" ]
null
null
null
inc/core/EventModel.h
sudoBash418/microbit-dal
5c62d29418f73ca16d02a9e847d2ad0ecbeda0b4
[ "MIT" ]
null
null
null
/* The MIT License (MIT) Copyright (c) 2016 British Broadcasting Corporation. This software is provided by Lancaster University by arrangement with the BBC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef EVENT_MODEL_H #define EVENT_MODEL_H #include "mbed.h" #include "MicroBitConfig.h" #include "MicroBitComponent.h" #include "MicroBitEvent.h" #include "MicroBitListener.h" #include "ErrorNo.h" /** * Class definition for the micro:bit EventModel. * * It is common to need to send events from one part of a program (or system) to another. * The way that these events are stored and delivered is known as an Event Model... * * The micro:bit can be programmed in a number of languages, and it not be good to * constrain those languages to any particular event model (e.g. they may have their own already). * * This class defines the functionality an event model needs to have to be able to interact * with events generated and/or used by the micro:bit runtime. Programmer may choose to implement * such funcitonality to integrate their own event models. * * This is an example of a key principle in computing - ABSTRACTION. This is now part of the * UK's Computing curriculum in schools... so ask your teacher about it. :-) * * An EventModel implementation is provided in the MicroBitMessageBus class. */ class EventModel { protected: void (*listener_deletion_callback)(MicroBitListener *); // if not null, this function is invoked when a listener is removed. public: static EventModel *defaultEventBus; // Set listener_deletion_callback to NULL. EventModel() : listener_deletion_callback(NULL) {} /** * Queues the given event to be sent to all registered recipients. * The method of delivery will vary depending on the underlying implementation. * * @param The event to send. * * @return This default implementation simply returns MICROBIT_NOT_SUPPORTED. */ virtual int send(MicroBitEvent evt) { (void) evt; return MICROBIT_NOT_SUPPORTED; } /** * Add the given MicroBitListener to the list of event handlers, unconditionally. * * @param listener The MicroBitListener to validate. * * @return This default implementation simply returns MICROBIT_NOT_SUPPORTED. */ virtual int add(MicroBitListener *listener) { (void) listener; return MICROBIT_NOT_SUPPORTED; } /** * Remove the given MicroBitListener from the list of event handlers. * * @param listener The MicroBitListener to remove. * * @return This default implementation simply returns MICROBIT_NOT_SUPPORTED. */ virtual int remove(MicroBitListener *listener) { (void) listener; return MICROBIT_NOT_SUPPORTED; } /** * Returns the MicroBitListener at the given position in the list. * * @param n The index of the desired MicroBitListener. * * @return This default implementation simply returns NULL. */ MicroBitListener *elementAt(int n) { (void) n; return NULL; } /** * Define the default EventModel to use for events raised and consumed by the microbit-dal runtime. * The default EventModel may be changed at any time. * * @param model A new instance of an EventModel to use as the default. * * @return MICROBIT_OK on success. * * Example: * @code * MicroBitMessageBus b(); * EventModel:setDefaultEventModel(b); * @endcode */ static int setDefaultEventModel(EventModel &model) { EventModel::defaultEventBus = &model; return MICROBIT_OK; } /** * Sets a pointer to handler that's invoked when any listener is deleted. * * @returns MICROBIT_OK on success. **/ int setListenerDeletionCallback(void (*listener_deletion_callback)(MicroBitListener *)) { this->listener_deletion_callback = listener_deletion_callback; return MICROBIT_OK; } /** * Register a listener function. * * An EventModel implementing this interface may optionally choose to override this method, * if that EventModel supports asynchronous callbacks to user code, but there is no * requirement to do so. * * @param id The source of messages to listen for. Events sent from any other IDs will be filtered. * Use MICROBIT_ID_ANY to receive events from all components. * * @param value The value of messages to listen for. Events with any other values will be filtered. * Use MICROBIT_EVT_ANY to receive events of any value. * * @param handler The function to call when an event is received. * * @param flags User specified, implementation specific flags, that allow behaviour of this events listener * to be tuned. * * @return MICROBIT_OK on success, or any valid error code defined in "ErrNo.h". The default implementation * simply returns MICROBIT_NOT_SUPPORTED. * * @code * void onButtonBClicked(MicroBitEvent) * { * //do something * } * * // call onButtonBClicked when ever a click event from buttonB is detected. * uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonBClick); * @endcode */ int listen(int id, int value, void (*handler)(MicroBitEvent), uint16_t flags = EVENT_LISTENER_DEFAULT_FLAGS) { if (handler == NULL) return MICROBIT_INVALID_PARAMETER; MicroBitListener *newListener = new MicroBitListener(id, value, handler, flags); if(add(newListener) == MICROBIT_OK) return MICROBIT_OK; delete newListener; return MICROBIT_NOT_SUPPORTED; } /** * Register a listener function. * * An EventModel implementing this interface may optionally choose to override this method, * if that EventModel supports asynchronous callbacks to user code, but there is no * requirement to do so. * * @param id The source of messages to listen for. Events sent from any other IDs will be filtered. * Use MICROBIT_ID_ANY to receive events from all components. * * @param value The value of messages to listen for. Events with any other values will be filtered. * Use MICROBIT_EVT_ANY to receive events of any value. * * @param handler The function to call when an event is received. * * @param arg Provide the callback with in an additional argument. * * @param flags User specified, implementation specific flags, that allow behaviour of this events listener * to be tuned. * * @return MICROBIT_OK on success, or any valid error code defined in "ErrNo.h". The default implementation * simply returns MICROBIT_NOT_SUPPORTED. * * @code * void onButtonBClicked(MicroBitEvent, void* data) * { * //do something * } * * // call onButtonBClicked when ever a click event from buttonB is detected. * uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonBClick); * @endcode */ int listen(int id, int value, void (*handler)(MicroBitEvent, void*), void* arg, uint16_t flags = EVENT_LISTENER_DEFAULT_FLAGS) { if (handler == NULL) return MICROBIT_INVALID_PARAMETER; MicroBitListener *newListener = new MicroBitListener(id, value, handler, arg, flags); if(add(newListener) == MICROBIT_OK) return MICROBIT_OK; delete newListener; return MICROBIT_NOT_SUPPORTED; } /** * Register a listener function. * * @param id The source of messages to listen for. Events sent from any other IDs will be filtered. * Use MICROBIT_ID_ANY to receive events from all components. * * @param value The value of messages to listen for. Events with any other values will be filtered. * Use MICROBIT_EVT_ANY to receive events of any value. * * @param hander The function to call when an event is received. * * @param flags User specified, implementation specific flags, that allow behaviour of this events listener * to be tuned. * * @return MICROBIT_OK on success or MICROBIT_INVALID_PARAMETER if the handler or object * pointers are NULL. * * @code * void SomeClass::onButtonBClicked(MicroBitEvent) * { * //do something * } * * SomeClass s = new SomeClass(); * * uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, s, &SomeClass::onButtonBClick); * @endcode */ template <typename T> int listen(uint16_t id, uint16_t value, T* object, void (T::*handler)(MicroBitEvent), uint16_t flags = EVENT_LISTENER_DEFAULT_FLAGS); /** * Unregister a listener function. * Listeners are identified by the Event ID, Event value and handler registered using listen(). * * @param id The Event ID used to register the listener. * @param value The Event value used to register the listener. * @param handler The function used to register the listener. * * @return MICROBIT_OK on success or MICROBIT_INVALID_PARAMETER if the handler * given is NULL. * * Example: * @code * void onButtonBClick(MicroBitEvent) * { * //do something * } * * uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonBClick); * * // the previously created listener is now ignored. * uBit.messageBus.ignore(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonBClick); * @endcode */ int ignore(int id, int value, void (*handler)(MicroBitEvent)) { if (handler == NULL) return MICROBIT_INVALID_PARAMETER; MicroBitListener listener(id, value, handler); remove(&listener); return MICROBIT_OK; } /** * Unregister a listener function. * Listeners are identified by the Event ID, Event value and handler registered using listen(). * * @param id The Event ID used to register the listener. * @param value The Event value used to register the listener. * @param handler The function used to register the listener. * @param arg the arg that is passed to the handler on an event. Used to differentiate between handlers with the same id and source, but not the same arg. * Defaults to NULL, which means any handler with the same id, event and callback is removed. * * @return MICROBIT_OK on success or MICROBIT_INVALID_PARAMETER if the handler * given is NULL. * * Example: * @code * void onButtonBClick(MicroBitEvent, void* data) * { * //do something * } * * uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonBClick); * * // the previously created listener is now ignored. * uBit.messageBus.ignore(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonBClick); * @endcode */ int ignore(int id, int value, void (*handler)(MicroBitEvent, void*), void* arg = NULL) { if (handler == NULL) return MICROBIT_INVALID_PARAMETER; MicroBitListener listener(id, value, handler, arg); remove(&listener); return MICROBIT_OK; } /** * Unregister a listener function. * Listners are identified by the Event ID, Event value and handler registered using listen(). * * @param id The Event ID used to register the listener. * @param value The Event value used to register the listener. * @param handler The function used to register the listener. * * @return MICROBIT_OK on success or MICROBIT_INVALID_PARAMETER if the handler or object * pointers are NULL. * * Example: * @code * * void SomeClass::onButtonBClick() * { * //do something * } * * SomeClass s = new SomeClass(); * uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, s, &SomeClass::onButtonBClick); * * // the previously created listener is now ignored. * uBit.messageBus.ignore(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, s, &SomeClass::onButtonBClick); * @endcode */ template <typename T> int ignore(uint16_t id, uint16_t value, T* object, void (T::*handler)(MicroBitEvent)); }; /** * A registration function to allow C++ member functions (methods) to be registered as an event * listener. * * @param id The source of messages to listen for. Events sent from any other IDs will be filtered. * Use MICROBIT_ID_ANY to receive events from all components. * * @param value The value of messages to listen for. Events with any other values will be filtered. * Use MICROBIT_EVT_ANY to receive events of any value. * * @param object The object on which the method should be invoked. * * @param handler The method to call when an event is received. * * @return MICROBIT_OK on success or MICROBIT_INVALID_PARAMETER if the handler or object * pointers are NULL. */ template <typename T> int EventModel::listen(uint16_t id, uint16_t value, T* object, void (T::*handler)(MicroBitEvent), uint16_t flags) { if (object == NULL || handler == NULL) return MICROBIT_INVALID_PARAMETER; MicroBitListener *newListener = new MicroBitListener(id, value, object, handler, flags); if(add(newListener) == MICROBIT_OK) return MICROBIT_OK; delete newListener; return MICROBIT_NOT_SUPPORTED; } /** * Unregister a listener function. * Listners are identified by the Event ID, Event value and handler registered using listen(). * * @param id The Event ID used to register the listener. * @param value The Event value used to register the listener. * @param handler The function used to register the listener. * * @return MICROBIT_OK on success or MICROBIT_INVALID_PARAMETER if the handler or object * pointers are NULL. * * Example: * @code * * void SomeClass::onButtonBClick() * { * //do something * } * * SomeClass s = new SomeClass(); * uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, s, &SomeClass::onButtonBClick); * * // the previously created listener is now ignored. * uBit.messageBus.ignore(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, s, &SomeClass::onButtonBClick); * @endcode */ template <typename T> int EventModel::ignore(uint16_t id, uint16_t value, T* object, void (T::*handler)(MicroBitEvent)) { if (handler == NULL) return MICROBIT_INVALID_PARAMETER; MicroBitListener listener(id, value, object, handler); remove(&listener); return MICROBIT_OK; } #endif
35.795556
159
0.675192
[ "object", "model" ]
643dbe7c1da6a37a9e56e3ffc3d0b50533a50952
2,039
h
C
igl/boundary_conditions.h
aviadtzemah/animation2
9a3f980fbe27672fe71f8f61f73b5713f2af5089
[ "Apache-2.0" ]
2,392
2016-12-17T14:14:12.000Z
2022-03-30T19:40:40.000Z
igl/boundary_conditions.h
aviadtzemah/animation2
9a3f980fbe27672fe71f8f61f73b5713f2af5089
[ "Apache-2.0" ]
106
2018-04-19T17:47:31.000Z
2022-03-01T19:44:11.000Z
igl/boundary_conditions.h
aviadtzemah/animation2
9a3f980fbe27672fe71f8f61f73b5713f2af5089
[ "Apache-2.0" ]
184
2017-11-15T09:55:37.000Z
2022-02-21T16:30:46.000Z
// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com> // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #ifndef IGL_BOUNDARY_CONDITIONS_H #define IGL_BOUNDARY_CONDITIONS_H #include "igl_inline.h" #include <Eigen/Dense> namespace igl { // Compute boundary conditions for automatic weights computation. This // function expects that the given mesh (V,Ele) has sufficient samples // (vertices) exactly at point handle locations and exactly along bone and // cage edges. // // Inputs: // V #V by dim list of domain vertices // Ele #Ele by simplex-size list of simplex indices // C #C by dim list of handle positions // P #P by 1 list of point handle indices into C // BE #BE by 2 list of bone edge indices into C // CE #CE by 2 list of cage edge indices into *P* // Outputs: // b #b list of boundary indices (indices into V of vertices which have // known, fixed values) // bc #b by #weights list of known/fixed values for boundary vertices // (notice the #b != #weights in general because #b will include all the // intermediary samples along each bone, etc.. The ordering of the // weights corresponds to [P;BE] // Returns false if boundary conditions are suspicious: // P and BE are empty // bc is empty // some column of bc doesn't have a 0 (assuming bc has >1 columns) // some column of bc doesn't have a 1 (assuming bc has >1 columns) IGL_INLINE bool boundary_conditions( const Eigen::MatrixXd & V, const Eigen::MatrixXi & Ele, const Eigen::MatrixXd & C, const Eigen::VectorXi & P, const Eigen::MatrixXi & BE, const Eigen::MatrixXi & CE, Eigen::VectorXi & b, Eigen::MatrixXd & bc); } #ifndef IGL_STATIC_LIBRARY # include "boundary_conditions.cpp" #endif #endif
36.410714
79
0.68514
[ "mesh", "geometry" ]
64537e2bdd2e9ec31b252f882762e2c14ba6f7ac
1,001
h
C
routers/router_server.h
apppur/canna
bdcce4f16be56da40445fec79959b6bc90003573
[ "MIT" ]
null
null
null
routers/router_server.h
apppur/canna
bdcce4f16be56da40445fec79959b6bc90003573
[ "MIT" ]
null
null
null
routers/router_server.h
apppur/canna
bdcce4f16be56da40445fec79959b6bc90003573
[ "MIT" ]
null
null
null
#include <string> #include <vector> #include "zmq.hpp" class router_server { public: router_server(); ~router_server(); int initialize(); public: void router_init(); std::vector<std::string> router_name(); private: zmq::socket_t * sock_create(int type); void sock_bind(zmq::socket_t * sock, const char * addr); void sock_identity(zmq::socket_t * sock, const char * addr); void sock_setfilter(zmq::socket_t * sock, const char * filter); void sock_connect(zmq::socket_t * sock, const char * addr); std::string sock_recv(zmq::socket_t &socket); bool sock_send(zmq::socket_t &socket, const std::string &string); bool sock_sendmore(zmq::socket_t &socket, const std::string &string); private: zmq::context_t * m_context; zmq::socket_t * m_clusterfe; zmq::socket_t * m_clusterbe; zmq::socket_t * m_subscribe; zmq::socket_t * m_requester; };
27.805556
77
0.62038
[ "vector" ]