max_stars_count
int64
301
224k
text
stringlengths
6
1.05M
token_count
int64
3
727k
2,040
<reponame>burjakremen/AI-on-the-edge-device #include <string> class ClassLogFile { private: std::string logroot; std::string logfile; bool doLogFile; unsigned short retentionInDays; int loglevel; public: ClassLogFile(std::string _logpath, std::string _logfile); std::string getESPHeapInfo(); void setLogLevel(int i){loglevel = i;}; void WriteHeapInfo(std::string _id); void SwitchOnOff(bool _doLogFile); void SetRetention(unsigned short _retentionInDays); void WriteToFile(std::string info, bool _time = true); void WriteToDedicatedFile(std::string _fn, std::string info, bool _time = true); void RemoveOld(); std::string GetCurrentFileName(); }; extern ClassLogFile LogFile;
273
1,374
<reponame>norzak/jsweet<filename>core-lib/es5/src/main/java/def/dom/FocusEvent.java package def.dom; public class FocusEvent extends UIEvent { public EventTarget relatedTarget; native public void initFocusEvent(String typeArg, Boolean canBubbleArg, Boolean cancelableArg, Window viewArg, double detailArg, EventTarget relatedTargetArg); public static FocusEvent prototype; public FocusEvent(String typeArg, FocusEventInit eventInitDict){} public FocusEvent(String typeArg){} protected FocusEvent(){} }
157
6,660
# # This file is part of the LibreOffice project. # # 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/. # # This file incorporates work covered by the following license notice: # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed # with this work for additional information regarding copyright # ownership. The ASF licenses this file to you under the Apache # License, Version 2.0 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of # the License at http://www.apache.org/licenses/LICENSE-2.0 . # import uno import traceback import time from datetime import date as dateTimeObject from .TextFieldHandler import TextFieldHandler from ..document.OfficeDocument import OfficeDocument from ..common.Desktop import Desktop from ..common.Configuration import Configuration from ..common.NumberFormatter import NumberFormatter from com.sun.star.i18n.NumberFormatIndex import DATE_SYS_DDMMYY from com.sun.star.view.DocumentZoomType import ENTIRE_PAGE from com.sun.star.beans.PropertyState import DIRECT_VALUE class TextDocument(object): def __init__(self, xMSF,listener=None,bShowStatusIndicator=None, FrameName=None,_sPreviewURL=None,_moduleIdentifier=None, _textDocument=None, xArgs=None): self.xMSF = xMSF self.xTextDocument = None if listener is not None: if FrameName is not None: '''creates an instance of TextDocument and creates a named frame. No document is actually loaded into this frame.''' self.xFrame = OfficeDocument.createNewFrame( xMSF, listener, FrameName) return elif _sPreviewURL is not None: '''creates an instance of TextDocument by loading a given URL as preview''' self.xFrame = OfficeDocument.createNewFrame(xMSF, listener) self.xTextDocument = self.loadAsPreview(_sPreviewURL, True) elif xArgs is not None: '''creates an instance of TextDocument and creates a frame and loads a document''' self.xDesktop = Desktop.getDesktop(xMSF); self.xFrame = OfficeDocument.createNewFrame(xMSF, listener) self.xTextDocument = OfficeDocument.load( self.xFrame, URL, "_self", xArgs); self.xWindowPeer = self.xFrame.getComponentWindow() self.m_xDocProps = self.xTextDocument.DocumentProperties CharLocale = self.xTextDocument.CharLocale return else: '''creates an instance of TextDocument from the desktop's current frame''' self.xDesktop = Desktop.getDesktop(xMSF); self.xFrame = self.xDesktop.getActiveFrame() self.xTextDocument = self.xFrame.getController().Model elif _moduleIdentifier is not None: try: '''create the empty document, and set its module identifier''' self.xTextDocument = xMSF.createInstance( "com.sun.star.text.TextDocument") self.xTextDocument.initNew() self.xTextDocument.setIdentifier( _moduleIdentifier.Identifier) # load the document into a blank frame xDesktop = Desktop.getDesktop(xMSF) loadArgs = list(range(1)) loadArgs[0] = "Model" loadArgs[0] = -1 loadArgs[0] = self.xTextDocument loadArgs[0] = DIRECT_VALUE xDesktop.loadComponentFromURL( "private:object", "_blank", 0, loadArgs) # remember some things for later usage self.xFrame = self.xTextDocument.CurrentController.Frame except Exception: traceback.print_exc() elif _textDocument is not None: '''creates an instance of TextDocument from a given XTextDocument''' self.xFrame = _textDocument.CurrentController.Frame self.xTextDocument = _textDocument if bShowStatusIndicator: self.showStatusIndicator() self.init() def init(self): self.xWindowPeer = self.xFrame.getComponentWindow() self.m_xDocProps = self.xTextDocument.DocumentProperties self.CharLocale = self.xTextDocument.CharLocale self.xText = self.xTextDocument.Text def showStatusIndicator(self): self.xProgressBar = self.xFrame.createStatusIndicator() self.xProgressBar.start("", 100) self.xProgressBar.setValue(5) def loadAsPreview(self, sDefaultTemplate, asTemplate): loadValues = list(range(3)) # open document in the Preview mode loadValues[0] = uno.createUnoStruct( 'com.sun.star.beans.PropertyValue') loadValues[0].Name = "ReadOnly" loadValues[0].Value = True loadValues[1] = uno.createUnoStruct( 'com.sun.star.beans.PropertyValue') loadValues[1].Name = "AsTemplate" if asTemplate: loadValues[1].Value = True else: loadValues[1].Value = False loadValues[2] = uno.createUnoStruct( 'com.sun.star.beans.PropertyValue') loadValues[2].Name = "Preview" loadValues[2].Value = True self.xTextDocument = OfficeDocument.load( self.xFrame, sDefaultTemplate, "_self", loadValues) self.DocSize = self.getPageSize() try: self.xTextDocument.CurrentController.ViewSettings.ZoomType = ENTIRE_PAGE except Exception: traceback.print_exc() myFieldHandler = TextFieldHandler(self.xMSF, self.xTextDocument) myFieldHandler.updateDocInfoFields() return self.xTextDocument def getPageSize(self): try: xNameAccess = self.xTextDocument.StyleFamilies xPageStyleCollection = xNameAccess.getByName("PageStyles") xPageStyle = xPageStyleCollection.getByName("First Page") return xPageStyle.Size except Exception: traceback.print_exc() return None '''creates an instance of TextDocument and creates a frame and loads a document''' def createTextCursor(self, oCursorContainer): xTextCursor = oCursorContainer.createTextCursor() return xTextCursor def refresh(self): self.xTextDocument.refresh() ''' This method sets the Author of a Wizard-generated template correctly and adds an explanatory sentence to the template description. @param WizardName The name of the Wizard. @param TemplateDescription The old Description which is being appended with another sentence. @return void. ''' def setWizardTemplateDocInfo(self, WizardName, TemplateDescription): try: xNA = Configuration.getConfigurationRoot( self.xMSF, "/org.openoffice.UserProfile/Data", False) gn = xNA.getByName("givenname") sn = xNA.getByName("sn") fullname = str(gn) + " " + str(sn) now = time.localtime(time.time()) year = time.strftime("%Y", now) month = time.strftime("%m", now) day = time.strftime("%d", now) dateObject = dateTimeObject(int(year), int(month), int(day)) du = self.DateUtils(self.xMSF, self.xTextDocument) ff = du.getFormat(DATE_SYS_DDMMYY) myDate = du.format(ff, dateObject) xDocProps2 = self.xTextDocument.DocumentProperties xDocProps2.Author = fullname xDocProps2.ModifiedBy = fullname description = xDocProps2.Description description = description + " " + TemplateDescription description = description.replace("<wizard_name>", WizardName) description = description.replace("<current_date>", myDate) xDocProps2.Description = description except Exception: traceback.print_exc() @classmethod def getFrameByName(self, sFrameName, xTD): if xTD.TextFrames.hasByName(sFrameName): return xTD.TextFrames.getByName(sFrameName) return None def searchFillInItems(self, typeSearch): sd = self.xTextDocument.createSearchDescriptor() if typeSearch == 0: sd.setSearchString("<[^>]+>") elif typeSearch == 1: sd.setSearchString("#[^#]+#") sd.setPropertyValue("SearchRegularExpression", True) sd.setPropertyValue("SearchWords", True) auxList = [] allItems = self.xTextDocument.findAll(sd) for i in list(range(allItems.Count)): auxList.append(allItems.getByIndex(i)) return auxList class DateUtils(object): def __init__(self, xmsf, document): self.formatSupplier = document formatSettings = self.formatSupplier.getNumberFormatSettings() date = formatSettings.NullDate self.calendar = dateTimeObject(date.Year, date.Month, date.Day) self.formatter = NumberFormatter.createNumberFormatter(xmsf, self.formatSupplier) ''' @param format a constant of the enumeration NumberFormatIndex @return ''' def getFormat(self, format): return NumberFormatter.getNumberFormatterKey( self.formatSupplier, format) ''' @param date a VCL date in form of 20041231 @return a document relative date ''' def format(self, formatIndex, date): difference = date - self.calendar return self.formatter.convertNumberToString(formatIndex, difference.days)
4,362
474
<filename>javacord-core/src/main/java/org/javacord/core/util/cache/Cache.java package org.javacord.core.util.cache; import io.vavr.collection.HashMap; import io.vavr.collection.HashSet; import io.vavr.collection.Map; import io.vavr.collection.Set; import java.util.Optional; import java.util.function.Function; /** * An immutable cache, optionally with indexes. * * <p>The cache can store any elements and supports indexes to quickly access a subset of elements by a specific * criteria (the "key") with an effective (assuming an even distribution of hash keys) time-complexity of {@code O(1)}. * * <p>Ideally, the cache is only filled with immutable elements, but it also supports mutable objects. * However, for mutable objects, the {@link #updateIndexesOfElement(Object)} methods should be called every time an * element update changes the key for this element for one of the indexes. * * @param <T> The type of the elements in the cache. */ public class Cache<T> { /** * A set with all elements in the cache. */ private final Set<T> elements; /** * A map with all indexes. * * <p>The map's key is the index name and the value is the index itself. */ private final Map<String, Index<Object, T>> indexes; /** * Creates a new cache. * * @param elements The elements in the cache. * @param indexes The indexes. */ private Cache(Set<T> elements, Map<String, Index<Object, T>> indexes) { this.elements = elements; this.indexes = indexes; } /** * Gets an empty cache with no elements and no indexes. * * @param <T> The type of the elements in the cache. * @return An empty element cache. */ public static <T> Cache<T> empty() { return new Cache<>(HashSet.empty(), HashMap.empty()); } /** * Adds an index to the cache. * * <p>Indexes allow quick access (effectively {@code O(1)} to elements in the cache by the key for the index like * for example the id or sub type. * * <p>Compound indexes can easily be achieved by using a {@link io.vavr.Tuple} or {@link io.vavr.collection.Seq} * with all keys as the return value of the mapping function. * * <p>This method has a time-complexity of {@code O(n)} with {@code n} being the amount of elements in the cache. * * @param indexName The name of the index. * @param mappingFunction A function to map elements to their key. * The function is allowed to return {@code null} which means that the element will not be * included in the index. * @return The new cache with the added index. * @throws IllegalStateException If the cache already has an index with the given name. */ public Cache<T> addIndex(String indexName, Function<T, Object> mappingFunction) { if (indexes.containsKey(indexName)) { throw new IllegalStateException("The cache already has an index with name " + indexName); } Index<Object, T> index = new Index<>(mappingFunction); for (T element : elements) { index = index.addElement(element); } Map<String, Index<Object, T>> newIndexes = indexes.put(indexName, index); return new Cache<>(elements, newIndexes); } /** * Adds an element to the cache. * * <p>This method has an effective time complexity of {@code O(1)} regarding the amount of elements already in the * cache and a time complexity of {@code O(n)} regarding the amount of indexes in the cache (assuming the index's * mapping function has an effective complexity of {@code O(1)}). * * @param element The element to add. * @return The new cache after adding the element. */ public Cache<T> addElement(T element) { Set<T> newElements = elements.add(element); Map<String, Index<Object, T>> newIndexes = indexes.mapValues(index -> index.addElement(element)); return new Cache<>(newElements, newIndexes); } /** * Removes an element from the cache. * * <p>This method has an effective time complexity of {@code O(1)} regarding the amount of elements already in the * cache and a time complexity of {@code O(n)} regarding the amount of indexes in the cache. * * @param element The element to remove. * @return The new cache after removing the element. */ public Cache<T> removeElement(T element) { Set<T> newElements = elements.remove(element); Map<String, Index<Object, T>> newIndexes = indexes.mapValues(index -> index.removeElement(element)); return new Cache<>(newElements, newIndexes); } /** * Updates the indexes of the cache for the given element. * * <p>The update method should be called every time an element's mutation changes the key of one of the indexes. * Ideally the {@code IndexedCache} is only filled with immutable elements which would make this method obsolete. * * <p>This method has an effective time complexity of {@code O(1)} regarding the amount of elements already in the * cache and a time complexity of {@code O(n)} regarding the amount of indexes in the cache (assuming the index's * mapping function has an effective complexity of {@code O(1)}). * * @param element The element of which the values did change. * @return The new cache after updating the element. */ public Cache<T> updateIndexesOfElement(T element) { if (!elements.contains(element)) { return this; } return removeElement(element).addElement(element); } /** * Gets a set with all elements in the cache. * * <p>This method has a time complexity of {@code O(1)}. * * @return All elements in the cache. */ public Set<T> getAll() { return elements; } /** * Gets any element in the cache that has the given key. * * <p>This method has an effective time complexity of {@code O(1)}. * * @param indexName The name of the index. * @param key The key of the element. * @return An element with the given key. * @throws IllegalArgumentException If the cache has no index with the given name. */ public Optional<T> findAnyByIndex(String indexName, Object key) { Index<Object, T> index = indexes.get(indexName).getOrElseThrow( () -> new IllegalArgumentException("No index with given name (" + indexName + ") found")); return index.findAny(key); } /** * Gets a set with all elements in the cache that have the given key. * * <p>This method has an effective time complexity of {@code O(1)}. * * @param indexName The name of the index. * @param key The key of the elements. * @return A set with all the elements that have the given key. * @throws IllegalArgumentException If the cache has no index with the given name. */ public Set<T> findByIndex(String indexName, Object key) { Index<Object, T> index = indexes.get(indexName).getOrElseThrow( () -> new IllegalArgumentException("No index with given name (" + indexName + ") found")); return index.find(key); } }
2,594
32,544
<reponame>zeesh49/tutorials package com.baeldung.singleton.synchronization; /** * Singleton with early initialization. Inlines the singleton instance * initialization. * * @author <NAME> * */ public class EarlyInitSingleton { /** * Current instance of the singleton. */ private static final EarlyInitSingleton INSTANCE = new EarlyInitSingleton(); /** * Private constructor to avoid instantiation. */ private EarlyInitSingleton() { } /** * Returns the current instance of the singleton. * * @return the current instance of the singleton */ public static EarlyInitSingleton getInstance() { return INSTANCE; } }
191
1,013
<reponame>JosephChataignon/pyclustering /*! @authors <NAME> (<EMAIL>) @date 2014-2020 @copyright BSD-3-Clause */ #include <pyclustering/container/adjacency_connector.hpp> namespace pyclustering { namespace container { std::ostream & operator<<(std::ostream & p_stream, const connection_t & p_structure) { switch (p_structure) { case connection_t::CONNECTION_ALL_TO_ALL: p_stream << "all-to-all"; break; case connection_t::CONNECTION_GRID_EIGHT: p_stream << "grid eight"; break; case connection_t::CONNECTION_GRID_FOUR: p_stream << "grid four"; break; case connection_t::CONNECTION_LIST_BIDIRECTIONAL: p_stream << "bidirectional list"; break; case connection_t::CONNECTION_NONE: p_stream << "none structure"; break; default: p_stream << "unknown structure"; break; } return p_stream; } } }
468
546
<gh_stars>100-1000 #ifndef PIPER_VIEW_H #define PIPER_VIEW_H #include <QGraphicsView> #include <MsnhViewerScene.h> namespace MsnhViewer { class View : public QGraphicsView { public: View(QWidget* parent = nullptr); void fitView(); protected: void wheelEvent(QWheelEvent* event) override; void keyPressEvent(QKeyEvent * event) override; }; } #endif
199
450
//============================================================================= // // Adventure Game Studio (AGS) // // Copyright (C) 1999-2011 <NAME> and 2011-20xx others // The full list of copyright holders can be found in the Copyright.txt // file, which is part of this source code distribution. // // The AGS source code is provided under the Artistic License 2.0. // A copy of this license can be found in the file License.txt and at // http://www.opensource.org/licenses/artistic-license-2.0.php // //============================================================================= // // Few graphic utility functions, remains of a bigger deprecated api. // //============================================================================= #ifndef __WGT4_H #define __WGT4_H #include <allegro.h> // RGB namespace AGS { namespace Common { class Bitmap; }} using namespace AGS; // FIXME later //============================================================================= // [IKM] 2012-09-13: this function is now defined in engine and editor separately extern void __my_setcolor(int *ctset, int newcol, int wantColDep); extern void wsetrgb(int coll, int r, int g, int b, RGB * pall); extern void wcolrotate(unsigned char start, unsigned char finish, int dir, RGB * pall); extern Common::Bitmap *wnewblock(Common::Bitmap *src, int x1, int y1, int x2, int y2); extern void wputblock(Common::Bitmap *ds, int xx, int yy, Common::Bitmap *bll, int xray); // CHECKME: temporary solution for plugin system extern void wputblock_raw(Common::Bitmap *ds, int xx, int yy, BITMAP *bll, int xray); extern const int col_lookups[32]; // TODO: these are used only in the Editor's agsnative.cpp extern int __wremap_keep_transparent; extern void wremap(RGB * pal1, Common::Bitmap *picc, RGB * pal2); extern void wremapall(RGB * pal1, Common::Bitmap *picc, RGB * pal2); #endif // __WGT4_H
573
765
/* rgbtobgr565 - convert 24-bit RGB pixels to 16-bit BGR565 pixels Written in 2016 by <NAME> <<EMAIL>> To the extent possible under law, the author has dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. See <http://creativecommons.org/publicdomain/zero/1.0/>. Use with ImageMagick or GraphicsMagick to convert 24-bit RGB pixels to 16-bit BGR565 pixels, e.g., magick file.png -depth 8 rgb:- | rgbtobgr565 > file.bgr565 Note that the 16-bit pixels are written in network byte order (most significant byte first), with blue in the most significant bits and red in the least significant bits. ChangLog: Jan 2017: changed bgr565 from int to unsigned short (suggested by <NAME>) */ #include <stdio.h> int main() { int red,green,blue; unsigned short bgr565; while (1) { red=getchar(); if (red == EOF) return (0); green=getchar(); if (green == EOF) return (1); blue=getchar(); if (blue == EOF) return (1); bgr565 = (unsigned short)(red * 31.0 / 255.0) | (unsigned short)(green * 63.0 / 255.0) << 5 | (unsigned short)(blue * 31.0 / 255.0) << 11; putchar((bgr565 >> 8) & 0xFF); putchar(bgr565 & 0xFF); } }
494
1,851
// // VROAnimationQuaternion.h // ViroRenderer // // Created by <NAME> on 12/28/15. // Copyright © 2015 Viro Media. 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 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 VROAnimationQuaternion_h #define VROAnimationQuaternion_h #include <stdio.h> #include "VROQuaternion.h" #include "VROAnimation.h" #include "VROAnimatable.h" #include "VROMath.h" class VROAnimationQuaternion : public VROAnimation { public: VROAnimationQuaternion(std::function<void(VROAnimatable *const, VROQuaternion)> method, VROQuaternion start, VROQuaternion end) : VROAnimation(), _keyTimes({ 0, 1 }), _keyValues({ start, end }), _method(method) {} VROAnimationQuaternion(std::function<void(VROAnimatable *const, VROQuaternion)> method, VROQuaternion start, VROQuaternion end, std::function<void(VROAnimatable *const)> finishCallback) : VROAnimation(finishCallback), _keyTimes({ 0, 1 }), _keyValues({ start, end }), _method(method) {} VROAnimationQuaternion(std::function<void(VROAnimatable *const, VROQuaternion)> method, std::vector<float> keyTimes, std::vector<VROQuaternion> keyValues) : VROAnimation(), _keyTimes(keyTimes), _keyValues(keyValues), _method(method) {} VROAnimationQuaternion(std::function<void(VROAnimatable *const, VROQuaternion)> method, std::vector<float> keyTimes, std::vector<VROQuaternion> keyValues, std::function<void(VROAnimatable *const)> finishCallback) : VROAnimation(finishCallback), _keyTimes(keyTimes), _keyValues(keyValues), _method(method) {} void processAnimationFrame(float t) { VROQuaternion value = VROMathInterpolateKeyFrameQuaternion(t, _keyTimes, _keyValues); std::shared_ptr<VROAnimatable> animatable = _animatable.lock(); if (animatable) { _method(animatable.get(), value); } } void finish() { std::shared_ptr<VROAnimatable> animatable = _animatable.lock(); if (animatable) { _method(animatable.get(), _keyValues.back()); } } private: std::vector<float> _keyTimes; std::vector<VROQuaternion> _keyValues; std::function<void(VROAnimatable *const, VROQuaternion)> _method; }; #endif /* VROAnimationQuaternion_h */
1,561
335
<gh_stars>100-1000 { "word": "Intentionality", "definitions": [ "The fact of being deliberate or purposive.", "The quality of mental states (e.g. thoughts, beliefs, desires, hopes) which consists in their being directed towards some object or state of affairs." ], "parts-of-speech": "Noun" }
113
451
#include "include/MMVII_all.h" #include "include/MMVII_2Include_Serial_Tpl.h" #include "LearnDM.h" #include "include/MMVII_util_tpl.h" #include "include/MMVII_Tpl_Images.h" //#include "include/MMVII_Tpl_Images.h" namespace MMVII { void AddData(const cAuxAr2007 & anAux,eModeCaracMatch & aMCM) {EnumAddData(anAux,aMCM,"ModeCar");} /* ************************************************ */ /* */ /* cHistoCarNDim */ /* */ /* ************************************************ */ void cHistoCarNDim::AddData(const cAuxAr2007 & anAux) { // eModeCaracMatch aMC; // F2(aMC); MMVII::AddData(cAuxAr2007("Car",anAux),mVCar); MMVII::AddData(cAuxAr2007("Sz",anAux),mSz); MMVII::AddData(cAuxAr2007("Hd1",anAux),mHd1_0); MMVII::AddData(cAuxAr2007("HN0",anAux),mHist0); MMVII::AddData(cAuxAr2007("HN2",anAux),mHist2); if (anAux.Input()) { mName = NameVecCar(mVCar); mSz = mHist0.Sz().Dup(); mDim = mSz.Sz(); mPts = tIndex(mDim); mPtsInit = tIndex(mDim); mRPts = tRIndex(mDim); } } void AddData(const cAuxAr2007 & anAux,cHistoCarNDim & aHND) { aHND.AddData(anAux); } cHistoCarNDim::cHistoCarNDim() : mIP (false), mDim (1), mSz (tIndex::Cste(mDim,1)), mVCar (), mPts (1), mPtsInit (1), mRPts (1), mHd1_0 (), mHist0 (mSz), mHist2 (mSz), mName (""), mNbOk (0.0), mNbNotOk (0.0), mGV2I (false), mHistoI0 (cPt2di(1,1)), mHistoI2 (cPt2di(1,1)) { } cHistoCarNDim::cHistoCarNDim(const std::string & aNameFile) : cHistoCarNDim () { ReadFromFile(*this,aNameFile); } cHistoCarNDim::~cHistoCarNDim() { if (! mIP) DeleteAllAndClear(mHd1_0); } cHistoCarNDim::cHistoCarNDim(int aSzH,const tVecCar & aVCar,const cStatAllVecCarac & aStat,bool genVis2DI) : mIP (true), mDim (aVCar.size()), mSz (tIndex::Cste(mDim,aSzH)), mVCar (aVCar), mPts (mDim), mPtsInit (mDim), mRPts (mDim), mHd1_0 (), mHist0 (mSz), mHist2 (mSz), mName (NameVecCar(aVCar)), mNbOk (0.0), mNbNotOk (0.0), mGV2I (genVis2DI && (mDim==2)), mHistoI0 (cPt2di(1,1) * (mGV2I ? cVecCaracMatch::TheDyn4Visu : 1),nullptr,eModeInitImage::eMIA_Null), mHistoI2 (cPt2di(1,1) * (mGV2I ? cVecCaracMatch::TheDyn4Visu : 1),nullptr,eModeInitImage::eMIA_Null) { for (const auto & aLabel : aVCar) mHd1_0.push_back(&(aStat.OneStat(aLabel).HistSom(7))); //mHd1_0.push_back(&(aStat.OneStat(aLabel).Hist(0))); } double cHistoCarNDim::CarSep() const { cComputeSeparDist aCSD; tDataNd * aDH0 = mHist0.RawDataLin(); tDataNd * aDH2 = mHist2.RawDataLin(); for (int aK=0 ; aK<mHist0.NbElem() ; aK++) aCSD.AddPops(aDH0[aK],aDH2[aK]); return aCSD.Sep(); } double cHistoCarNDim::Correctness() const { return mNbOk / (mNbOk+mNbNotOk); } void cHistoCarNDim::Show(cMultipleOfs & anOfs,bool WithCr) const { anOfs << "Name = " << mName << " Sep: " << CarSep() ; if (WithCr) anOfs << " UnCorec: " << 1-Correctness(); anOfs << "\n"; } void cHistoCarNDim::ComputePts(const cVecCaracMatch & aVCM) const { aVCM.FillVect(mPts,mVCar); if (mGV2I) mPtsInit = mPts.Dup(); for (int aK=0 ; aK<mDim ; aK++) { int aSzK = mSz(aK); double aV = mHd1_0[aK]->PropCumul(mPts(aK)) * aSzK; mPts(aK) = std::min(round_down(aV),aSzK-1); mRPts(aK) = std::min(aV,aSzK-1.0001); /* int aV = round_down(mHd1_0[aK]->PropCumul(mPts(aK)) * aSzK); mPts(aK) = std::min(aV,aSzK-1); */ } } void cHistoCarNDim::Add(const cVecCaracMatch & aVCM,bool isH0) { ComputePts(aVCM); tHistND & aHist = (isH0 ? mHist0 : mHist2); aHist.AddV(mPts,1); if (mGV2I) { cPt2di aPt = cVecCaracMatch::ToVisu(cPt2di::FromVect(mPtsInit)); if (isH0) mHistoI0.DIm().AddVal(aPt,1); else mHistoI2.DIm().AddVal(aPt,1); } } template <class Type> double ScoreHnH(const Type & aV0,const Type & aV2) { if ((aV0==0) && (aV2==0)) return 0.5; return aV0 / double(aV0+aV2); } // tREAL4 GetNLinearVal(const tRIndex&) const; // Get value by N-Linear interpolation // void AddNLinearVal(const tRIndex&,const double & aVal) ; // Get value by N-Linear interpolation double cHistoCarNDim::HomologyLikelihood(const cVecCaracMatch & aVCM,bool Interpol) const { ComputePts(aVCM); double aV0 = Interpol ? mHist0.GetNLinearVal(mRPts) : mHist0.GetV(mPts); double aV2 = Interpol ? mHist2.GetNLinearVal(mRPts) : mHist2.GetV(mPts); return ScoreHnH(aV0,aV2); // return ScoreHnH(mHist0.GetV(mPts),mHist2.GetV(mPts)); } void cHistoCarNDim::UpDateCorrectness(const cVecCaracMatch & aHom,const cVecCaracMatch & aNotHom) { double aScH = HomologyLikelihood(aHom,false); double aScNH = HomologyLikelihood(aNotHom,false); if (aScH<aScNH) mNbNotOk++; else if (aScH>aScNH) mNbOk++; else { mNbOk += 0.5; mNbNotOk += 0.5; } } const std::string & cHistoCarNDim::Name() const { return mName; } void cHistoCarNDim::GenerateVisuOneIm(const std::string & aDir,const std::string & aPrefix,const tHistND & aHist) { // make a float image, of the int image, for Vino ... cIm2D<float> anIm = Convert((float*)nullptr,aHist.ToIm2D().DIm()); std::string aName = aDir + "Histo-" + aPrefix + mName + ".tif"; anIm.DIm().ToFile(aName); } void cHistoCarNDim::GenerateVisu(const std::string & aDir) { if (mDim==2) { GenerateVisuOneIm(aDir,"Hom",mHist0); GenerateVisuOneIm(aDir,"NonH",mHist2); cIm2D<tDataNd> aI0 = mHist0.ToIm2D(); cIm2D<tDataNd> aI2 = mHist2.ToIm2D(); cIm2D<tREAL4> aImSc(aI0.DIm().Sz()); cIm2D<tREAL4> aImPop(aI0.DIm().Sz()); for (const auto & aP : aImSc.DIm()) { tINT4 aV0 = aI0.DIm().GetV(aP); tINT4 aV2 = aI2.DIm().GetV(aP); aImSc.DIm().SetV(aP,ScoreHnH(aV0,aV2)); aImPop.DIm().SetV(aP,aV0+aV2); } std::string aName = aDir + "HistoScore-"+ mName + ".tif"; aImSc.DIm().ToFile(aName); aName = aDir + "HistoPop-"+ mName + ".tif"; aImPop.DIm().ToFile(aName); } } void cHistoCarNDim::GenerateVis2DInitOneInit(const std::string & aDir,const std::string & aPrefix,cIm2D<double> aH,const tHistND& aHN) { std::string aName = aDir + "HistoInit-" + aPrefix + mName + ".tif"; aH.DIm().ToFile(aName); /* int aTx = mSz(0); int aTy = mSz(1); cIm1D<double> aH1D(aTy,nullptr,eModeInitImage::eMIA_Null); double aSomV=0.0; for (int aX=0 ; aX<aTx ;aX++) { for (int aY=0 ; aY<aTy ;aY++) { cPt2di aP(aX,aY); double aV = aHN.GetV(aP.ToVect()); aH1D.DIm().AddV(aY,aV); aSomV += aV; } } for (int aY=0 ; aY<aTy ;aY++) { StdOut() << "Y=" << aY << " V=" << aH1D.DIm().GetV(aY) * (aTy/aSomV) << "\n"; } getchar(); */ } void cHistoCarNDim::GenerateVis2DInit(const std::string & aDir) { if (mGV2I) { GenerateVis2DInitOneInit(aDir,"Hom" ,mHistoI0,mHist0); GenerateVis2DInitOneInit(aDir,"NonH",mHistoI2,mHist2); } } /* ************************************************ */ /* */ /* cAppliCalcHistoNDim */ /* */ /* ************************************************ */ class cAppliCalcHistoNDim : public cAppliLearningMatch { public : cAppliCalcHistoNDim(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec); private : int Exe() override; cCollecSpecArg2007 & ArgObl(cCollecSpecArg2007 & anArgObl) override ; cCollecSpecArg2007 & ArgOpt(cCollecSpecArg2007 & anArgOpt) override ; std::vector<std::string> Samples() const override; void AddHistoOneFile(const std::string &,int aKFile,int aNbFile); // print performance : Separibility + (If computed) Correctness void ShowPerf(cMultipleOfs &) const; std::string NameSaveH(const cHistoCarNDim & aHND,bool isInput) { return FileHistoNDIm(aHND.Name(),isInput); } // -- Mandatory args ---- std::string mPatHom0; std::string mNameInput; std::string mNameOutput; std::vector<std::string> mPatsCar; // -- Optionnal args ---- int mSzH1; std::string mSerialSeparator; bool mAddPrefixSeq; bool mInitialProcess; // Post Processing bool mCloseH; bool mGenerateVisu; // Do we generate visual (Image for 2d, later ply for 3d) bool mGenVis2DInit; // Do we generate visual init (w/o equal) bool mOkDuplicata; // Do accept duplicata in sequence, // std::string mPatShowSep; // bool mWithCr; // -- Internal variables ---- int mDim; int mMaxSzH; cStatAllVecCarac mStats; std::vector<cHistoCarNDim*> mVHistN; }; cAppliCalcHistoNDim::cAppliCalcHistoNDim(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec) : cAppliLearningMatch (aVArgs,aSpec), mAddPrefixSeq (false), mInitialProcess (true), mCloseH (false), mGenerateVisu (false), mGenVis2DInit (false), mOkDuplicata (false), mMaxSzH (50), mStats (false) { } cCollecSpecArg2007 & cAppliCalcHistoNDim::ArgObl(cCollecSpecArg2007 & anArgObl) { return anArgObl << Arg2007(mPatHom0,"Name of input(s) file(s)",{{eTA2007::MPatFile,"0"}}) << Arg2007(mNameInput,"Name used for input ") << Arg2007(mNameOutput,"Name used for output ") << Arg2007(mPatsCar,"vector of pattern of carac") ; } cCollecSpecArg2007 & cAppliCalcHistoNDim::ArgOpt(cCollecSpecArg2007 & anArgOpt) { return anArgOpt << AOpt2007(mSzH1, "SzH","Size of histogramm in each dim") << AOpt2007(mSerialSeparator, "SerSep","Serial Separator, if no pattern, e.q [a@b,c@d@e] with \"@ \"") << AOpt2007(mAddPrefixSeq, "APS","Add Prefix subseq of carac(i.e abc=>a,ab,abc)",{eTA2007::HDV}) << AOpt2007(mInitialProcess, "IP","Initial processing. If not , read previous histo, more stat, post proc",{eTA2007::HDV}) << AOpt2007(mCloseH, "CloseH","Use close homologs, instead of random",{eTA2007::HDV}) << AOpt2007(mGenerateVisu, "GeneVisu","Generate visualisation",{eTA2007::HDV}) << AOpt2007(mGenVis2DInit, "GV2DI","Generate vis 2D w/o equalization",{eTA2007::HDV,eTA2007::Tuning}) << AOpt2007(mOkDuplicata, "OkDupl","Accept duplicatas in sequences",{eTA2007::HDV,eTA2007::Tuning}) ; } void cAppliCalcHistoNDim::AddHistoOneFile(const std::string & aStr0,int aKFile,int aNbFile) { StdOut() << " ####### " << aStr0 << " : " << aKFile << "/" << aNbFile << " ####### \n"; int aMulH = (mCloseH ? 1 : 2); if (mInitialProcess) { for (const int & aKNumH : {0,1}) { std::string aStr = HomFromHom0(aStr0,aKNumH*aMulH); cFileVecCaracMatch aFCV(aStr); for (const auto & aPtrH : mVHistN) { for (const auto & aVCM : aFCV.VVCM()) { aPtrH->Add(aVCM,aKNumH==0); } } } } else { cFileVecCaracMatch aFCV0(HomFromHom0(aStr0,0)); cFileVecCaracMatch aFCV2(HomFromHom0(aStr0,aMulH)); const std::vector<cVecCaracMatch> & aV0 = aFCV0.VVCM(); const std::vector<cVecCaracMatch> & aV2 = aFCV2.VVCM(); MMVII_INTERNAL_ASSERT_strong(aV0.size()==aV2.size(),"Diff size in Hom/NonHom"); for (auto & aPtrH : mVHistN) { for (int aK=0 ; aK<int(aV0.size()) ; aK++) { aPtrH->UpDateCorrectness(aV0[aK],aV2[aK]); } } } } void cAppliCalcHistoNDim::ShowPerf(cMultipleOfs & anOfs) const { std::vector<cHistoCarNDim*> aVHSort = mVHistN; if (mInitialProcess) SortOnCriteria(aVHSort,[](const auto & aPtr){return aPtr->CarSep();}); else SortOnCriteria(aVHSort,[](const auto & aPtr){return 1-aPtr->Correctness();}); for (const auto & aPtrH : aVHSort) { aPtrH->Show(anOfs,!mInitialProcess); } anOfs << "-------------------------------------------------\n"; } std::vector<std::string> cAppliCalcHistoNDim::Samples() const { return std::vector<std::string> ( { "MMVII DM3CalcHistoNDim \".*\" Test Test [xx] # Generate enum values", "MMVII DM3CalcHistoNDim DMTrain.*LDHAime0.dmp AllMDLB2014 AllMDLB2014 [.*]" } ); } int cAppliCalcHistoNDim::Exe() { if (mGenerateVisu) { if (IsInit(&mInitialProcess)) { MMVII_INTERNAL_ASSERT_strong(!mInitialProcess,"IP Specified with Visu ..."); } else { mInitialProcess = false; } } if (mGenVis2DInit) { if (IsInit(&mInitialProcess)) { MMVII_INTERNAL_ASSERT_strong(mInitialProcess,"IP false with Vis2DI"); } else { mInitialProcess = true; } } SetNamesProject(mNameInput,mNameOutput); mDim = mPatsCar.size(); if ( mInitialProcess) { ReadFromFile(mStats,FileHisto1Carac(true)); } // ------------------------------------------------------------------------------ // 1 ---------- Compute the sequence of caracteristique matched by pattern ---- // ------------------------------------------------------------------------------ std::map<tVecCar,tVecCar> aMapSeq; // Used to select unique sequence on set criteria but maintain initial order if (! IsInit(&mSerialSeparator)) { // --- 1.1 compute rough cartersian product std::vector<tVecCar> aVPatExt; for (const auto & aPat: mPatsCar) { aVPatExt.push_back(SubOfPat<eModeCaracMatch>(aPat,false)); } std::vector<tVecCar> aVSeqCarInit = ProdCart(aVPatExt); if (mAddPrefixSeq) { std::vector<tVecCar> aVSeqSub; for (const auto & aSeq : aVSeqCarInit) { for (int aK=1 ; aK<=int(aSeq.size()) ; aK++) { aVSeqSub.push_back(tVecCar(aSeq.begin(),aSeq.begin()+aK)); } } aVSeqCarInit = aVSeqSub; } // --- 1.2 order is not important in the sequence for (const auto & aSeq : aVSeqCarInit) { tVecCar aSeqId = aSeq; std::sort ( aSeqId.begin(), aSeqId.end()); // Supress the possible duplicate carac, can be maintained for mNoDuplicata if (! mOkDuplicata) { aSeqId.erase( unique( aSeqId.begin(), aSeqId.end() ), aSeqId.end() ); } // For now, supress those where there were duplicates if (aSeqId.size() == aSeq.size()) { aMapSeq[aSeqId] = aSeq; } } } else { for (const auto & aPat: mPatsCar) { tVecCar aVCar; for (const auto & aStr : SplitString(aPat,mSerialSeparator)) { aVCar.push_back(Str2E<eModeCaracMatch>(aStr)); StdOut() << aStr << "///"; } StdOut() << "\n"; aMapSeq[aVCar] = aVCar; } // BREAK_POINT("Test Separe"); } // ------------------------------------------------------------------------------ // 2 ---------- Initialise the N Dimensionnal histogramm --------------------- // ------------------------------------------------------------------------------ if (mInitialProcess) { if (! IsInit(&mSzH1)) { double aNbCell = 5e8 / aMapSeq.size(); mSzH1 = round_down(pow(aNbCell,1/double(mDim))); mSzH1 = std::min(mSzH1,mMaxSzH); } } else { mSzH1 = 1; // put low value it will be reallocated after read } for (const auto & aPair : aMapSeq) { if ( mInitialProcess) { mVHistN.push_back(new cHistoCarNDim(mSzH1,aPair.second,mStats,mGenVis2DInit)); } else { std::string aNameFile = FileHistoNDIm(NameVecCar(aPair.second),true); mVHistN.push_back(new cHistoCarNDim(aNameFile)); } } if (1) { cMultipleOfs aMulOfs(NameReport(),false); aMulOfs << "COM=[" << Command() << "]\n\n"; for (bool InReport : {false,true}) { cMultipleOfs & aOfs = InReport ? aMulOfs : StdOut() ; for (const auto & aPair : aMapSeq) { aOfs << "* " << NameVecCar(aPair.second) << " <= Id:" << NameVecCar(aPair.first) << "\n"; } aOfs << "NB SEQ=" << aMapSeq.size() << " NBLAB=" << (int) eModeCaracMatch::eNbVals << "\n"; aOfs << "SzH=" << mSzH1 << " NbSeq= " << mVHistN.size() << "\n"; } // getchar(); } // ------------------------------------------------------------------------------ // 4 ---------- Parse the files of veccar -------------------------------- // ------------------------------------------------------------------------------ if (mGenerateVisu) { for (const auto & aPtrH : mVHistN) { aPtrH->GenerateVisu(DirVisu()); } } else { int aKFile =0 ; int aNbFile = MainSet0().size(); for (const auto & aStr : ToVect(MainSet0())) { AddHistoOneFile(aStr,aKFile,aNbFile); ShowPerf(StdOut()); aKFile++; } } // ------------------------------------------------------------------------------ // 5 ---------- Save the results -------------------------------- // ------------------------------------------------------------------------------ if (! mGenerateVisu) { cMultipleOfs aMulOfs(NameReport(),true); aMulOfs << "\n========================================\n\n"; ShowPerf(aMulOfs); if (mInitialProcess) { for (const auto & aPtrH : mVHistN) { // std::string aNameSave = FileHistoNDIm(aPtrH->Name(),false); SaveInFile(*aPtrH,NameSaveH(*aPtrH,false)); aPtrH->GenerateVis2DInit(DirVisu()); } } } // ------------------------------------------------------------------------------ // ZZZZ ---------------- Free and quit ---------------------------------------- // ------------------------------------------------------------------------------ DeleteAllAndClear(mVHistN); return EXIT_SUCCESS; } /* =============================================== */ /* */ /* :: */ /* */ /* =============================================== */ tMMVII_UnikPApli Alloc_CalcHistoNDim(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec) { return tMMVII_UnikPApli(new cAppliCalcHistoNDim(aVArgs,aSpec)); } cSpecMMVII_Appli TheSpecCalcHistoNDim ( "DM3CalcHistoNDim", Alloc_CalcHistoNDim, "Compute and save histogramm on multiple caracteristics", {eApF::Match}, {eApDT::FileSys}, {eApDT::FileSys}, __FILE__ ); /* */ };
10,249
434
<reponame>hhb584520/inclavare-containers<filename>rune/libenclave/internal/runtime/pal/kvmtool/powerpc/spapr_hvcons.c /* * SPAPR HV console * * Borrowed lightly from QEMU's spapr_vty.c, Copyright (c) 2010 <NAME>, * IBM Corporation. * * Copyright (c) 2011 <NAME> <<EMAIL>>, IBM Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. */ #include "kvm/term.h" #include "kvm/kvm.h" #include "kvm/kvm-cpu.h" #include "kvm/util.h" #include "spapr.h" #include "spapr_hvcons.h" #include <stdio.h> #include <sys/uio.h> #include <errno.h> #include <linux/byteorder.h> union hv_chario { struct { uint64_t char0_7; uint64_t char8_15; } a; uint8_t buf[16]; }; static unsigned long h_put_term_char(struct kvm_cpu *vcpu, unsigned long opcode, unsigned long *args) { /* To do: Read register from args[0], and check it. */ unsigned long len = args[1]; union hv_chario data; struct iovec iov; if (len > 16) { return H_PARAMETER; } data.a.char0_7 = cpu_to_be64(args[2]); data.a.char8_15 = cpu_to_be64(args[3]); iov.iov_base = data.buf; iov.iov_len = len; do { int ret; ret = term_putc_iov(&iov, 1, 0); if (ret < 0) { die("term_putc_iov error %d!\n", errno); } iov.iov_base += ret; iov.iov_len -= ret; } while (iov.iov_len > 0); return H_SUCCESS; } static unsigned long h_get_term_char(struct kvm_cpu *vcpu, unsigned long opcode, unsigned long *args) { /* To do: Read register from args[0], and check it. */ unsigned long *len = args + 0; unsigned long *char0_7 = args + 1; unsigned long *char8_15 = args + 2; union hv_chario data; struct iovec iov; if (vcpu->kvm->cfg.active_console != CONSOLE_HV) return H_SUCCESS; if (term_readable(0)) { iov.iov_base = data.buf; iov.iov_len = 16; *len = term_getc_iov(vcpu->kvm, &iov, 1, 0); *char0_7 = be64_to_cpu(data.a.char0_7); *char8_15 = be64_to_cpu(data.a.char8_15); } else { *len = 0; } return H_SUCCESS; } void spapr_hvcons_poll(struct kvm *kvm) { if (term_readable(0)) { /* * We can inject an IRQ to guest here if we want. The guest * will happily poll, though, so not required. */ } } void spapr_hvcons_init(void) { spapr_register_hypercall(H_PUT_TERM_CHAR, h_put_term_char); spapr_register_hypercall(H_GET_TERM_CHAR, h_get_term_char); }
1,046
7,137
<reponame>java-app-scans/onedev package io.onedev.server.plugin.imports.youtrack; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.hibernate.validator.constraints.NotEmpty; import io.onedev.server.OneDev; import io.onedev.server.entitymanager.SettingManager; import io.onedev.server.model.support.administration.GlobalIssueSetting; import io.onedev.server.model.support.issue.StateSpec; import io.onedev.server.web.editable.annotation.ChoiceProvider; import io.onedev.server.web.editable.annotation.Editable; @Editable public class IssueStateMapping implements Serializable { private static final long serialVersionUID = 1L; private String youTrackIssueState; private String oneDevIssueState; @Editable(order=100, name="YouTrack Issue State") @NotEmpty public String getYouTrackIssueState() { return youTrackIssueState; } public void setYouTrackIssueState(String youTrackIssueState) { this.youTrackIssueState = youTrackIssueState; } @Editable(order=200, name="OneDev Issue State") @ChoiceProvider("getOneDevIssueStateChoices") @NotEmpty public String getOneDevIssueState() { return oneDevIssueState; } public void setOneDevIssueState(String oneDevIssueState) { this.oneDevIssueState = oneDevIssueState; } @SuppressWarnings("unused") private static List<String> getOneDevIssueStateChoices() { List<String> choices = new ArrayList<>(); GlobalIssueSetting issueSetting = OneDev.getInstance(SettingManager.class).getIssueSetting(); for (StateSpec state: issueSetting.getStateSpecs()) choices.add(state.getName()); return choices; } }
521
892
{ "schema_version": "1.2.0", "id": "GHSA-f7p4-692g-f4w7", "modified": "2022-05-13T01:21:32Z", "published": "2022-05-13T01:21:32Z", "aliases": [ "CVE-2019-0762" ], "details": "A security feature bypass vulnerability exists when Microsoft browsers improperly handle requests of different origins, aka 'Microsoft Browsers Security Feature Bypass Vulnerability'.", "severity": [ { "type": "CVSS_V3", "score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N" } ], "affected": [ ], "references": [ { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2019-0762" }, { "type": "WEB", "url": "https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2019-0762" } ], "database_specific": { "cwe_ids": [ "CWE-863" ], "severity": "MODERATE", "github_reviewed": false } }
427
2,151
#!/usr/bin/env vpython # Copyright 2018 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. """Utilities for creating a phased orderfile. This kind of orderfile is based on cygprofile lightweight instrumentation. The profile dump format is described in process_profiles.py. These tools assume profiling has been done with two phases. The first phase, labeled 0 in the filename, is called "startup" and the second, labeled 1, is called "interaction". These two phases are used to create an orderfile with three parts: the code touched only in startup, the code touched only during interaction, and code common to the two phases. We refer to these parts as the orderfile phases. """ import argparse import collections import glob import itertools import logging import os.path import process_profiles # Files matched when using this script to analyze directly (see main()). PROFILE_GLOB = 'cygprofile-*.txt_*' OrderfilePhaseOffsets = collections.namedtuple( 'OrderfilePhaseOffsets', ('startup', 'common', 'interaction')) class PhasedAnalyzer(object): """A class which collects analysis around phased orderfiles. It maintains common data such as symbol table information to make analysis more convenient. """ # These figures are taken from running memory and speedometer telemetry # benchmarks, and are still subject to change as of 2018-01-24. STARTUP_STABILITY_THRESHOLD = 1.5 COMMON_STABILITY_THRESHOLD = 1.75 INTERACTION_STABILITY_THRESHOLD = 2.5 def __init__(self, profiles, processor): """Intialize. Args: profiles (ProfileManager) Manager of the profile dump files. processor (SymbolOffsetProcessor) Symbol table processor for the dumps. """ self._profiles = profiles self._processor = processor self._phase_offsets = None def IsStableProfile(self): """Verify that the profiling has been stable. See ComputeStability for details. Returns: True if the profile was stable as described above. """ (startup_stability, common_stability, interaction_stability) = self.ComputeStability() stable = True if startup_stability > self.STARTUP_STABILITY_THRESHOLD: logging.error('Startup unstable: %.3f', startup_stability) stable = False if common_stability > self.COMMON_STABILITY_THRESHOLD: logging.error('Common unstable: %.3f', common_stability) stable = False if interaction_stability > self.INTERACTION_STABILITY_THRESHOLD: logging.error('Interaction unstable: %.3f', interaction_stability) stable = False return stable def ComputeStability(self): """Compute heuristic phase stability metrics. This computes the ratio in size of symbols between the union and intersection of all orderfile phases. Intuitively if this ratio is not too large it means that the profiling phases are stable with respect to the code they cover. Returns: (float, float, float) A heuristic stability metric for startup, common and interaction orderfile phases, respectively. """ phase_offsets = self._GetOrderfilePhaseOffsets() assert len(phase_offsets) > 1 # Otherwise the analysis is silly. startup_union = set(phase_offsets[0].startup) startup_intersection = set(phase_offsets[0].startup) common_union = set(phase_offsets[0].common) common_intersection = set(phase_offsets[0].common) interaction_union = set(phase_offsets[0].interaction) interaction_intersection = set(phase_offsets[0].interaction) for offsets in phase_offsets[1:]: startup_union |= set(offsets.startup) startup_intersection &= set(offsets.startup) common_union |= set(offsets.common) common_intersection &= set(offsets.common) interaction_union |= set(offsets.interaction) interaction_intersection &= set(offsets.interaction) startup_stability = self._SafeDiv( self._processor.OffsetsPrimarySize(startup_union), self._processor.OffsetsPrimarySize(startup_intersection)) common_stability = self._SafeDiv( self._processor.OffsetsPrimarySize(common_union), self._processor.OffsetsPrimarySize(common_intersection)) interaction_stability = self._SafeDiv( self._processor.OffsetsPrimarySize(interaction_union), self._processor.OffsetsPrimarySize(interaction_intersection)) return (startup_stability, common_stability, interaction_stability) def _GetOrderfilePhaseOffsets(self): """Compute the phase offsets for each run. Returns: [OrderfilePhaseOffsets] Each run corresponds to an OrderfilePhaseOffsets, which groups the symbol offsets discovered in the runs. """ if self._phase_offsets is not None: return self._phase_offsets assert self._profiles.GetPhases() == set([0, 1]), 'Unexpected phases' self._phase_offsets = [] for first, second in zip(self._profiles.GetRunGroupOffsets(phase=0), self._profiles.GetRunGroupOffsets(phase=1)): all_first_offsets = self._processor.GetReachedOffsetsFromDump(first) all_second_offsets = self._processor.GetReachedOffsetsFromDump(second) first_offsets_set = set(all_first_offsets) second_offsets_set = set(all_second_offsets) common_offsets_set = first_offsets_set & second_offsets_set first_offsets_set -= common_offsets_set second_offsets_set -= common_offsets_set startup = [x for x in all_first_offsets if x in first_offsets_set] interaction = [x for x in all_second_offsets if x in second_offsets_set] common_seen = set() common = [] for x in itertools.chain(all_first_offsets, all_second_offsets): if x in common_offsets_set and x not in common_seen: common_seen.add(x) common.append(x) self._phase_offsets.append(OrderfilePhaseOffsets( startup=startup, interaction=interaction, common=common)) return self._phase_offsets @classmethod def _SafeDiv(cls, a, b): if not b: return None return float(a) / b def _CreateArgumentParser(): parser = argparse.ArgumentParser( description='Compute statistics on phased orderfiles') parser.add_argument('--profile-directory', type=str, required=True, help=('Directory containing profile runs. Files ' 'matching {} are used.'.format(PROFILE_GLOB))) parser.add_argument('--instrumented-build-dir', type=str, help='Path to the instrumented build', required=True) parser.add_argument('--library-name', default='libchrome.so', help=('Chrome shared library name (usually libchrome.so ' 'or libmonochrome.so')) return parser def main(): logging.basicConfig(level=logging.INFO) parser = _CreateArgumentParser() args = parser.parse_args() profiles = process_profiles.ProfileManager( glob.glob(os.path.join(args.profile_directory, PROFILE_GLOB))) processor = process_profiles.SymbolOffsetProcessor(os.path.join( args.instrumented_build_dir, 'lib.unstripped', args.library_name)) phaser = PhasedAnalyzer(profiles, processor) print 'Stability: {:.2f} {:.2f} {:.2f}'.format(*phaser.ComputeStability()) if __name__ == '__main__': main()
2,627
12,824
<reponame>jamesanto/scala public class Test { public static void main(String[] args) { Object o = new Object(); System.out.println(o instanceof MyTrait); } }
73
407
<gh_stars>100-1000 # -*- coding: utf-8 -*- # @author: 丛戎 # @target: 对源数据进行一些预处理的方法,如数据平滑、季节性分解、剔除异常值等 import pandas as pd from statsmodels.tsa.seasonal import seasonal_decompose class DataPreprocessUtils(object): def get_complete_date_range(self, downdate, update, freq, tsname): """ 根据开始和结束日期补全日期 :param downdate: :param update: :param freq: 如5H, 3min20S, 3D :param tsname: :return: """ timeindex = pd.date_range(start=downdate, end=update, freq=freq) timeindex = pd.DataFrame(timeindex, columns=[tsname]) return timeindex def data_smoothing_function(self, data, colname_list, windowsize=3, func='avg'): """ 将原始数据按照一定的聚合方式进行平滑处理 :param data: DataFrame格式,包含ts和kpi两列,ts为时间戳格式 :param colname_list: 需要聚合的列名, 为list类型 :param windowsize: 平滑的窗口大小 :param func: avg, min, max, median, sum, var :return: 聚合后的DataFrame, 新ts为窗口内的最小ts, kpi为聚合后的值 """ # groupby_data = pd.DataFrame(columns=['ts'] + colname_list) # 因为传递进来的ts字段是datetime类型,无法直接做rolling, 所以先转化为timestamp格式 # ts_origin = data['ts'].copy() # data['ts'] = data['ts'].apply((lambda x: time.mktime(time.strptime(str(x), "%Y-%m-%d %H:%M:%S")))) # groupby_data['ts'] = data['ts'].rolling(window=windowsize, center=False).max() groupby_data = data # 取移动平均值来平滑数据 if func == 'avg': groupby_data[colname_list] = data[colname_list].rolling(window=windowsize, center=False).mean() elif func == 'min': groupby_data[colname_list] = data[colname_list].rolling(window=windowsize, center=False).min() elif func == 'max': groupby_data[colname_list] = data[colname_list].rolling(window=windowsize, center=False).max() elif func == 'median': groupby_data[colname_list] = data[colname_list].rolling(window=windowsize, center=False).median() elif func == 'sum': groupby_data[colname_list] = data[colname_list].rolling(window=windowsize, center=False).sum() elif func == 'var': groupby_data[colname_list] = data[colname_list].rolling(window=windowsize, center=False).var() # Coefficient Of Variation变异系数,即sigma/mean,衡量抖动的大小,一般用于检测突然的抖动 elif func == 'cv': for eachcolname in colname_list: groupby_data['temp_sigma'] = data[eachcolname].rolling(window=windowsize, center=False).std() groupby_data['temp_mean'] = data[eachcolname].rolling(window=windowsize, center=False).mean() groupby_data[eachcolname] = 0 groupby_data.loc[groupby_data['temp_mean'] != 0, eachcolname] = ( groupby_data['temp_sigma'] / groupby_data['temp_mean']) # Coefficient Of Variation变异系数,即sigma/mean,这里我们取倒数,即mean/sigma,当sigma为0,取很大的数,为了检测打平的情况 elif func == 'cv_reciprocal': for eachcolname in colname_list: groupby_data['temp_sigma'] = data[eachcolname].rolling(window=windowsize, center=False).std() groupby_data['temp_mean'] = data[eachcolname].rolling(window=windowsize, center=False).mean() groupby_data[eachcolname] = 1E20 groupby_data.loc[groupby_data['temp_sigma'] != 0, eachcolname] = ( groupby_data['temp_mean'] / groupby_data['temp_sigma']) groupby_data = groupby_data.dropna() # groupby_data['ts'] = ts_origin return groupby_data def stl_decomp(self, data, colname, period): """ stl季节性分解,将数据分解为趋势、季节项和残差三部分 :param data: DataFrame格式数据 :param colname: 需要分解的列名,如kpi :param period: 一个周期包含几个点 :return: 返回DataFrame,包含ts, trend, seasonal, remainder, 以及trend+seasonal的decomp_kpi """ res = seasonal_decompose(data[colname], model='additive', freq=period, two_sided=False, extrapolate_trend='freq') decomp_data = data.copy() decomp_data['remainder'] = res.resid decomp_data['seasonal'] = res.seasonal decomp_data['trend'] = res.trend decomp_data['decomp_kpi'] = decomp_data['trend'] + decomp_data['seasonal'] decomp_data['deseasonal'] = decomp_data['trend'] + decomp_data['remainder'] return decomp_data def drop_noise_by_nsigma(self, data, colname, n=3): """ 根据n-sigma原则对某一列剔除异常点 :param data: DataFrame格式数据 :param colname: 要去噪的列名,如kpi, remainder :param n: nsigma系数 :return: 去除噪音后的数据 """ mean = data[colname].mean() sigma = data[colname].std() data = data[(data[colname] >= mean - n * sigma) & (data[colname] <= mean + n * sigma)] return data def ts_fill_na(self, kpidata, startdate, enddate, freq, fillvalue=True): """ 时间序列数据缺失日期和缺失值补齐 :param kpidata: DataFrame格式的数据 :param startdate: 数据的开始日期 :param enddate: 数据的结束日期 :param interval: 日期的间隔 :param fillvalue: 是否要用前后的真实值来填补缺失值, 否则直接用0填充 :return: 返回填补完日期和缺失值后的DataFrame """ # 是否要用前后的真实值来填补缺失值, 否则直接用0填充 if fillvalue: kpidata['kpi_median'] = kpidata['kpi'].rolling(window=5, center=False).median() # 日期补全 timeindex = self.get_complete_date_range(startdate, enddate, freq, 'ts') timeindex['ts'] = pd.to_datetime(timeindex['ts']) kpidata['ts'] = pd.to_datetime(kpidata['ts']) kpidata = pd.merge(timeindex, kpidata.copy(), on=['ts'], how='left') kpidata['kpi_median'] = kpidata['kpi_median'].fillna(method='pad') kpidata['kpi_median'] = kpidata['kpi_median'].fillna(method='bfill') kpidata.loc[kpidata['kpi'].isnull(), 'kpi'] = kpidata['kpi_median'] kpidata = kpidata.drop('kpi_median', 1) kpidata = kpidata.fillna(0) else: # 缺失值直接全部填0 # 日期补全 timeindex = self.get_complete_date_range(startdate, enddate, freq, 'ts') timeindex['ts'] = pd.to_datetime(timeindex['ts']) kpidata['ts'] = pd.to_datetime(kpidata['ts']) kpidata = pd.merge(timeindex, kpidata.copy(), on=['ts'], how='left') kpidata = kpidata.fillna(0) return kpidata def ts_clean_and_fill(self, dataset, colname, period, interval): """ 时序分解、异常值剔除、缺失值补全的方法封装 :param dataset: DataFrame格式 :param colname: 需要预处理的列名 :param period: 一个周期的点数 :param interval: 点与点之间的时间间隔(按秒计) :return: 预处理完毕的DataFrame """ dataset = self.stl_decomp(dataset, colname, period) dataset = self.drop_noise_by_nsigma(dataset, 'remainder') # 利用trend+seasonal组合成的值进行3sigma的去噪 clean_dataset = self.drop_noise_by_nsigma(dataset, 'decomp_kpi') # 数据补全 freq = str(interval) + 's' clean_dataset = self.ts_fill_na(clean_dataset, clean_dataset['ts'].min(), clean_dataset['ts'].max(), freq, True) return clean_dataset
4,257
1,021
#pragma once #include "Buffer.h" #ifdef fcWindows #define fcDLLExt ".dll" #else #ifdef fcMac #define fcDLLExt ".dylib" #else #define fcDLLExt ".so" #endif #endif typedef void* module_t; module_t DLLLoad(const char *path); void DLLUnload(module_t mod); void* DLLGetSymbol(module_t mod, const char *name); void DLLAddSearchPath(const char *path); const char* DLLGetDirectoryOfCurrentModule(); double GetCurrentTimeInSeconds(); // execute command and **wait until it ends** // return exit-code int Execute(const char *command); void MilliSleep(int ms); // ------------------------------------------------------------- // Math functions // ------------------------------------------------------------- typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; template<class Int> inline u16 u16_be(Int v_) { u16 v = (u16)v_; return ((v >> 8) & 0xFF) | ((v & 0xFF) << 8); } template<class Int> inline u32 u32_be(Int v_) { u32 v = (u32)v_; return ((v >> 24) & 0xFF) | (((v >> 16) & 0xFF) << 8) | (((v >> 8) & 0xFF) << 16) | ((v & 0xFF) << 24); } template<class Int> inline u64 u64_be(Int v_) { u64 v = (u64)v_; return ((v >> 56) & 0xFF) | (((v >> 48) & 0xFF) << 8) | (((v >> 40) & 0xFF) << 16) | (((v >> 32) & 0xFF) << 24) | (((v >> 24) & 0xFF) << 32) | (((v >> 16) & 0xFF) << 40) | (((v >> 8) & 0xFF) << 48) | ((v & 0xFF) << 56); } // i.e: // ceildiv(31, 16) : 2 // ceildiv(32, 16) : 2 // ceildiv(33, 16) : 3 template<class IntType> inline IntType ceildiv(IntType a, IntType b) { return (a + b - 1) / b; } // i.e: // roundup<16>(31) : 32 // roundup<16>(32) : 32 // roundup<16>(33) : 48 template<int N, class IntType> inline IntType roundup(IntType v) { IntType mask = N - 1; return (v + mask) & ~mask; } inline uint64_t to_msec(double seconds) { return uint64_t(seconds * 1000.0); } inline uint64_t to_usec(double seconds) { return uint64_t(seconds * 1000000.0); } inline uint64_t to_nsec(double seconds) { return uint64_t(seconds * 1000000000.0); } inline double msec_to_sec(uint64_t t) { return double(t) / 1000.0; } inline double usec_to_sec(uint64_t t) { return double(t) / 1000000.0; } inline double nsec_to_sec(uint64_t t) { return double(t) / 1000000000.0; }
1,110
1,268
<gh_stars>1000+ package xiaofei.library.hermestest.test; /** * Created by Xiaofei on 16/4/14. */ public interface Call2 { A g(A a); }
61
2,313
<gh_stars>1000+ /* * Copyright (c) 2021 Arm Limited. * * SPDX-License-Identifier: MIT * * 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 ARM_COMPUTE_CPU_CAST_H #define ARM_COMPUTE_CPU_CAST_H #include "src/runtime/cpu/ICpuOperator.h" namespace arm_compute { namespace cpu { /** Basic function to run @ref kernels::CpuCastKernel */ class CpuCast : public ICpuOperator { public: /** Configure operator for a given list of arguments * * Input data type must be different than output data type. * * Valid data layouts: * - All * * Valid data type configurations: * |src |dst | * |:--------------|:-----------------------------------------------| * |QASYMM8_SIGNED | S16, S32, F32, F16 | * |QASYMM8 | U16, S16, S32, F32, F16 | * |U8 | U16, S16, S32, F32, F16 | * |U16 | U8, U32 | * |S16 | QASYMM8_SIGNED, U8, S32 | * |F16 | QASYMM8_SIGNED, QASYMM8, F32, S32, U8 | * |S32 | QASYMM8_SIGNED, QASYMM8, F16, F32, U8 | * |F32 | QASYMM8_SIGNED, QASYMM8, BFLOAT16, F16, S32, U8| * * @param[in] src The source tensor to convert. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32. * @param[out] dst The destination tensor. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32. * @param[in] policy Conversion policy. */ void configure(const ITensorInfo *src, ITensorInfo *dst, ConvertPolicy policy); /** Static function to check if given info will lead to a valid configuration * * Similar to @ref CpuCast::configure() * * @return a status */ static Status validate(const ITensorInfo *src, const ITensorInfo *dst, ConvertPolicy policy); }; } // namespace cpu } // namespace arm_compute #endif /* ARM_COMPUTE_CPU_ACTIVATION_H */
1,286
335
<reponame>Safal08/Hacktoberfest-1 { "word": "Convert", "definitions": [ "A person who has been persuaded to change their religious faith or other belief." ], "parts-of-speech": "Noun" }
84
403
<gh_stars>100-1000 package com.camunda.bpm.demo.process_engine_load_test; import org.camunda.bpm.model.bpmn.Bpmn; import org.camunda.bpm.model.bpmn.BpmnModelInstance; import org.camunda.bpm.model.bpmn.builder.ServiceTaskBuilder; import org.camunda.bpm.model.bpmn.builder.UserTaskBuilder; public class ProcessGenerator { public static BpmnModelInstance generateSequenceOf100ServiceTasks() { ServiceTaskBuilder serviceTaskBuilder = Bpmn.createExecutableProcess("ServiceTasksSR").name("ServiceTasksSR").startEvent().serviceTask() .camundaExpression("${true}"); for (int i = 0; i < 100; i++) { serviceTaskBuilder = serviceTaskBuilder.serviceTask().camundaExpression("${true}"); } BpmnModelInstance modelInstance = serviceTaskBuilder.endEvent().done(); return modelInstance; } public static BpmnModelInstance generateSequenceOf100AsyncServiceTasks() { ServiceTaskBuilder serviceTaskBuilder = Bpmn.createExecutableProcess("SequenceOf100AsyncServiceTasks").name("SequenceOf100AsyncServiceTasks").startEvent() .camundaAsyncBefore().serviceTask().camundaDelegateExpression("${logger}").camundaAsyncBefore(); for (int i = 0; i < 100; i++) { serviceTaskBuilder = serviceTaskBuilder.serviceTask().camundaDelegateExpression("${logger}").camundaAsyncBefore(); } BpmnModelInstance modelInstance = serviceTaskBuilder.endEvent().done(); return modelInstance; } public static BpmnModelInstance generateMixOf100ServiceAnd10UserTasks() { ServiceTaskBuilder serviceTaskBuilder = Bpmn.createExecutableProcess("ServiceUserTasksLR").name("ServiceUserTasksLR").startEvent().serviceTask() .camundaExpression("${true}"); for (int i = 0; i < 100; i++) { if (i % 10 == 0) { UserTaskBuilder userTaskBuilder = serviceTaskBuilder.userTask().id("UserTask-" + (i / 10)); serviceTaskBuilder = userTaskBuilder.serviceTask().camundaExpression("${true}"); } else { serviceTaskBuilder = serviceTaskBuilder.serviceTask().camundaExpression("${true}"); } } BpmnModelInstance modelInstance = serviceTaskBuilder.endEvent().done(); return modelInstance; } public static BpmnModelInstance generateMixOf100ServiceAnd10UserTasksAsync() { ServiceTaskBuilder serviceTaskBuilder = Bpmn.createExecutableProcess("ServiceUserTasksLR").name("ServiceUserTasksLR").startEvent().serviceTask() .camundaExpression("${true}").camundaAsyncAfter(); for (int i = 0; i < 100; i++) { if (i % 10 == 0) { UserTaskBuilder userTaskBuilder = serviceTaskBuilder.userTask().id("UserTask-" + (i / 10)).camundaAsyncBefore().camundaAsyncAfter(); serviceTaskBuilder = userTaskBuilder.serviceTask().camundaExpression("${true}").camundaAsyncAfter(); } else { serviceTaskBuilder = serviceTaskBuilder.serviceTask().camundaExpression("${true}").camundaAsyncAfter(); } } BpmnModelInstance modelInstance = serviceTaskBuilder.endEvent().done(); return modelInstance; } }
1,003
631
<filename>Source/Modules/nimMockNodes/MockMapGenerator.cpp /***************************************************************************** * * * OpenNI 1.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * * This file is part of OpenNI. * * * * 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 "MockMapGenerator.h" #include <XnPropNames.h> #include <XnOS.h> #include <XnLog.h> MockMapGenerator::MockMapGenerator(xn::Context& context, const XnChar* strName) : MockGenerator(context, strName), m_nSupportedMapOutputModesCount(0), m_bSupportedMapOutputModesCountReceived(0), m_pSupportedMapOutputModes(NULL), m_nBytesPerPixel(0) { xnOSMemSet(&m_mapOutputMode, 0, sizeof(m_mapOutputMode)); xnOSMemSet(&m_cropping, 0, sizeof(m_cropping)); } MockMapGenerator::~MockMapGenerator() { XN_DELETE_ARR(m_pSupportedMapOutputModes); } XnBool MockMapGenerator::IsCapabilitySupported(const XnChar* strCapabilityName) { if (strcmp(strCapabilityName, XN_CAPABILITY_CROPPING) == 0) return TRUE; return MockGenerator::IsCapabilitySupported(strCapabilityName); } XnStatus MockMapGenerator::SetIntProperty(const XnChar* strName, XnUInt64 nValue) { if (strcmp(strName, XN_PROP_SUPPORTED_MAP_OUTPUT_MODES_COUNT) == 0) { m_nSupportedMapOutputModesCount = (XnUInt32)nValue; m_bSupportedMapOutputModesCountReceived = TRUE; } else if (strcmp(strName, XN_PROP_BYTES_PER_PIXEL) == 0) { m_nBytesPerPixel = (XnUInt32)nValue; } else { return MockGenerator::SetIntProperty(strName, nValue); } return XN_STATUS_OK; } XnStatus MockMapGenerator::SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer) { XN_VALIDATE_INPUT_PTR(strName); XN_VALIDATE_INPUT_PTR(pBuffer); XnStatus nRetVal = XN_STATUS_OK; if (strcmp(strName, XN_PROP_MAP_OUTPUT_MODE) == 0) { if (nBufferSize != sizeof(m_mapOutputMode)) { XN_LOG_ERROR_RETURN(XN_STATUS_INVALID_BUFFER_SIZE, XN_MASK_OPEN_NI, "Cannot set XN_PROP_MAP_OUTPUT_MODE - buffer size is incorrect"); } const XnMapOutputMode* pOutputMode = (const XnMapOutputMode*)pBuffer; nRetVal = SetMapOutputMode(*pOutputMode); XN_IS_STATUS_OK(nRetVal); } else if (strcmp(strName, XN_PROP_SUPPORTED_MAP_OUTPUT_MODES) == 0) { if (m_bSupportedMapOutputModesCountReceived) { m_bSupportedMapOutputModesCountReceived = FALSE; //For next time if (nBufferSize != m_nSupportedMapOutputModesCount * sizeof(XnMapOutputMode)) { XN_LOG_ERROR_RETURN(XN_STATUS_INVALID_BUFFER_SIZE, XN_MASK_OPEN_NI, "Cannot set XN_PROP_SUPPORTED_MAP_OUTPUT_MODES - buffer size is incorrect"); } XN_DELETE_ARR(m_pSupportedMapOutputModes); m_pSupportedMapOutputModes = XN_NEW_ARR(XnMapOutputMode, m_nSupportedMapOutputModesCount); XN_VALIDATE_ALLOC_PTR(m_pSupportedMapOutputModes); xnOSMemCopy(m_pSupportedMapOutputModes, pBuffer, nBufferSize); } else { XN_ASSERT(FALSE); XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Got XN_PROP_SUPPORTED_MAP_OUTPUT_MODES without XN_PROP_SUPPORTED_MAP_OUTPUT_MODES_COUNT before it"); } } else if (strcmp(strName, XN_PROP_CROPPING) == 0) { if (nBufferSize != sizeof(m_cropping)) { XN_LOG_ERROR_RETURN(XN_STATUS_INVALID_BUFFER_SIZE, XN_MASK_OPEN_NI, "Cannot set XN_PROP_CROPPING - buffer size is incorrect"); } const XnCropping* pCropping = (const XnCropping*)pBuffer; nRetVal = SetCropping(*pCropping); XN_IS_STATUS_OK(nRetVal); } else if (strcmp(strName, XN_PROP_NEWDATA) == 0) { // Check buffer size. Note: the expected size is the minimum one. We allow bigger frames (sometimes generators // place debug information *after* the data) XnUInt32 nExpectedSize = GetExpectedBufferSize(); if (nBufferSize < nExpectedSize) { xnLogWarning(XN_MASK_OPEN_NI, "%s: Got new data with illegal buffer size (%u) - ignoring.", m_strName, nBufferSize); } else { //Send it to be handled by our base class nRetVal = MockGenerator::SetGeneralProperty(strName, nBufferSize, pBuffer); XN_IS_STATUS_OK(nRetVal); } } else { nRetVal = MockGenerator::SetGeneralProperty(strName, nBufferSize, pBuffer); XN_IS_STATUS_OK(nRetVal); } return XN_STATUS_OK; } XnUInt32 MockMapGenerator::GetSupportedMapOutputModesCount() { return m_nSupportedMapOutputModesCount; } XnStatus MockMapGenerator::GetSupportedMapOutputModes(XnMapOutputMode aModes[], XnUInt32& nCount) { XN_VALIDATE_PTR(m_pSupportedMapOutputModes, XN_STATUS_PROPERTY_NOT_SET); nCount = XN_MIN(nCount, m_nSupportedMapOutputModesCount); xnOSMemCopy(aModes, m_pSupportedMapOutputModes, nCount * sizeof(m_pSupportedMapOutputModes[0])); return XN_STATUS_OK; } XnStatus MockMapGenerator::SetMapOutputMode(const XnMapOutputMode& mode) { XnStatus nRetVal = XN_STATUS_OK; xnLogVerbose(XN_MASK_OPEN_NI, "%s: Setting map output mode to %ux%u, %u fps", m_strName, mode.nXRes, mode.nYRes, mode.nFPS); //TODO: Check if mode is in supported modes. If not, return error. if (xnOSMemCmp(&mode, &m_mapOutputMode, sizeof(mode)) != 0) { m_mapOutputMode = mode; nRetVal = m_outputModeChangeEvent.Raise(); XN_IS_STATUS_OK(nRetVal); } return XN_STATUS_OK; } XnStatus MockMapGenerator::GetMapOutputMode(XnMapOutputMode& mode) { mode = m_mapOutputMode; return XN_STATUS_OK; } XnStatus MockMapGenerator::RegisterToMapOutputModeChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) { return m_outputModeChangeEvent.Register(handler, pCookie, hCallback); } void MockMapGenerator::UnregisterFromMapOutputModeChange(XnCallbackHandle hCallback) { m_outputModeChangeEvent.Unregister(hCallback); } XnUInt32 MockMapGenerator::GetBytesPerPixel() { return m_nBytesPerPixel; } xn::ModuleCroppingInterface* MockMapGenerator::GetCroppingInterface() { return this; } XnStatus MockMapGenerator::SetCropping(const XnCropping &Cropping) { XnStatus nRetVal = XN_STATUS_OK; if (xnOSMemCmp(&Cropping, &m_cropping, sizeof(Cropping)) != 0) { m_cropping = Cropping; nRetVal = m_croppingChangeEvent.Raise(); XN_IS_STATUS_OK(nRetVal); } return XN_STATUS_OK; } XnStatus MockMapGenerator::GetCropping(XnCropping &Cropping) { Cropping = m_cropping; return XN_STATUS_OK; } XnStatus MockMapGenerator::RegisterToCroppingChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) { return m_croppingChangeEvent.Register(handler, pCookie, hCallback); } void MockMapGenerator::UnregisterFromCroppingChange(XnCallbackHandle hCallback) { m_croppingChangeEvent.Unregister(hCallback); } XnUInt32 MockMapGenerator::GetRequiredBufferSize() { XnUInt32 nPixels = m_mapOutputMode.nXRes * m_mapOutputMode.nYRes; XnUInt32 nBytes = nPixels * GetBytesPerPixel(); return nBytes; } XnUInt32 MockMapGenerator::GetExpectedBufferSize() { XnUInt32 nPixels = 0; if (m_cropping.bEnabled) { nPixels = m_cropping.nXSize * m_cropping.nYSize; } else { nPixels = m_mapOutputMode.nXRes * m_mapOutputMode.nYRes; } XnUInt32 nBytes = nPixels * GetBytesPerPixel(); return nBytes; }
4,003
1,734
<reponame>japzio/slf4j package org.slf4j.helpers; import org.slf4j.Marker; /** * Provides minimal default implementations for {@link #isTraceEnabled(Marker)}, {@link #isDebugEnabled(Marker)} and other similar methods. * * @since 2.0 */ abstract public class LegacyAbstractLogger extends AbstractLogger { private static final long serialVersionUID = -7041884104854048950L; @Override public boolean isTraceEnabled(Marker marker) { return isTraceEnabled(); } @Override public boolean isDebugEnabled(Marker marker) { return isDebugEnabled(); } @Override public boolean isInfoEnabled(Marker marker) { return isInfoEnabled(); } @Override public boolean isWarnEnabled(Marker marker) { return isWarnEnabled(); } @Override public boolean isErrorEnabled(Marker marker) { return isErrorEnabled(); } }
330
11,750
from plotly.graph_objs import Scatterternary
14
782
<gh_stars>100-1000 package client; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.util.Bytes; import util.HBaseHelper; // cc CRUDExamplePreV1API Example application using all of the basic access methods (before v1.0) @SuppressWarnings("deprecation") // because of old API usage public class CRUDExamplePreV1API { public static void main(String[] args) throws IOException { // vv CRUDExamplePreV1API Configuration conf = HBaseConfiguration.create(); // ^^ CRUDExamplePreV1API HBaseHelper helper = HBaseHelper.getHelper(conf); helper.dropTable("testtable"); helper.createTable("testtable", "colfam1", "colfam2"); // vv CRUDExamplePreV1API HTable table = new HTable(conf, "testtable"); Put put = new Put(Bytes.toBytes("row1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), Bytes.toBytes("val1")); put.add(Bytes.toBytes("colfam2"), Bytes.toBytes("qual2"), Bytes.toBytes("val2")); table.put(put); Scan scan = new Scan(); ResultScanner scanner = table.getScanner(scan); for (Result result2 : scanner) { System.out.println("Scan 1: " + result2); } Get get = new Get(Bytes.toBytes("row1")); get.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1")); Result result = table.get(get); System.out.println("Get result: " + result); byte[] val = result.getValue(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1")); System.out.println("Value only: " + Bytes.toString(val)); Delete delete = new Delete(Bytes.toBytes("row1")); delete.deleteColumns(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1")); table.delete(delete); Scan scan2 = new Scan(); ResultScanner scanner2 = table.getScanner(scan2); for (Result result2 : scanner2) { System.out.println("Scan2: " + result2); } // ^^ CRUDExamplePreV1API } }
867
568
<filename>enews/enews-java/aws-runner/src/main/java/com/novoda/RunnerMain.java package com.novoda; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.novoda.enews.*; import java.time.LocalDateTime; import java.util.stream.Stream; public class RunnerMain implements RequestHandler<Request, Response> { public static void main(String[] args) { if (args.length == 0 || args.length < 2) { throw new IllegalStateException("You need to pass a Slack token as the first arg and MailChimp API token as the second."); } Request request = new Request(args[0], args[1]); new RunnerMain().handleRequest(request, null); } @Override public Response handleRequest(Request input, Context context) { String slackToken = input.getSlackToken(); String mailChimpApiKey = input.getMailChimpApiKey(); Scraper scraper = new Scraper.Factory().newInstance(slackToken); HtmlGenerator htmlGenerator = new HtmlGenerator.Factory().newInstance(); NewsletterPublisher newsletterPublisher = new NewsletterPublisher.Factory().newInstance(mailChimpApiKey); ArticleEditor articleEditor = new ArticleEditor.Factory().newInstance(); LocalDateTime start = LocalDateTime.now(); LocalDateTime end = LocalDateTime.now().minusDays(6); Stream<ChannelHistory.Message> messageStream = scraper.scrape(start, end); Stream<Article> articleStream = articleEditor.generateArticle(messageStream); String html = htmlGenerator.generate(articleStream); LocalDateTime atLocalDateTime = LocalDateTime.now().plusDays(1).plusHours(1); newsletterPublisher.publish(html, atLocalDateTime); // Time warp campaigns have to be 24 hours in the future // The scheduling is completely hidden here and is a TODO // - because if someone set up a cron job they cannot *fully* control the time right now JsonObject jsonObject = new JsonObject(); jsonObject.add("message", new JsonPrimitive("complete!")); return new Response(jsonObject.getAsJsonObject().toString()); } }
760
3,968
from ...error import GraphQLError from ...utils.type_comparators import do_types_overlap from ...utils.type_from_ast import type_from_ast from .base import ValidationRule class PossibleFragmentSpreads(ValidationRule): def enter_InlineFragment(self, node, key, parent, path, ancestors): frag_type = self.context.get_type() parent_type = self.context.get_parent_type() schema = self.context.get_schema() if frag_type and parent_type and not do_types_overlap(schema, frag_type, parent_type): self.context.report_error(GraphQLError( self.type_incompatible_anon_spread_message(parent_type, frag_type), [node] )) def enter_FragmentSpread(self, node, key, parent, path, ancestors): frag_name = node.name.value frag_type = self.get_fragment_type(self.context, frag_name) parent_type = self.context.get_parent_type() schema = self.context.get_schema() if frag_type and parent_type and not do_types_overlap(schema, frag_type, parent_type): self.context.report_error(GraphQLError( self.type_incompatible_spread_message(frag_name, parent_type, frag_type), [node] )) @staticmethod def get_fragment_type(context, name): frag = context.get_fragment(name) return frag and type_from_ast(context.get_schema(), frag.type_condition) @staticmethod def type_incompatible_spread_message(frag_name, parent_type, frag_type): return 'Fragment {} cannot be spread here as objects of type {} can never be of type {}'.format(frag_name, parent_type, frag_type) @staticmethod def type_incompatible_anon_spread_message(parent_type, frag_type): return 'Fragment cannot be spread here as objects of type {} can never be of type {}'.format(parent_type, frag_type)
1,055
478
<reponame>MobileUpLLC/geofire-objc<filename>examples/SFVehicles/SFVehicles/SFViewController.h // // SFViewController.h // SFVehicles // // Created by <NAME> on 7/7/14. // Copyright (c) 2014 Firebase. All rights reserved. // #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> @interface SFViewController : UIViewController<MKMapViewDelegate> @end
134
2,824
<filename>spine-c/spine-c/include/spine/SkeletonClipping.h /****************************************************************************** * Spine Runtimes License Agreement * Last updated January 1, 2020. Replaces all prior versions. * * Copyright (c) 2013-2020, Esoteric Software LLC * * Integration of the Spine Runtimes into software or otherwise creating * derivative works of the Spine Runtimes is permitted under the terms and * conditions of Section 2 of the Spine Editor License Agreement: * http://esotericsoftware.com/spine-editor-license * * Otherwise, it is permitted to integrate the Spine Runtimes into software * or otherwise create derivative works of the Spine Runtimes (collectively, * "Products"), provided that each user of the Products must obtain their own * Spine Editor license and redistribution of the Products in any form must * include this license and copyright notice. * * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "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 ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ #ifndef SPINE_SKELETONCLIPPING_H #define SPINE_SKELETONCLIPPING_H #include <spine/dll.h> #include <spine/Array.h> #include <spine/ClippingAttachment.h> #include <spine/Slot.h> #include <spine/Triangulator.h> #ifdef __cplusplus extern "C" { #endif typedef struct spSkeletonClipping { spTriangulator *triangulator; spFloatArray *clippingPolygon; spFloatArray *clipOutput; spFloatArray *clippedVertices; spFloatArray *clippedUVs; spUnsignedShortArray *clippedTriangles; spFloatArray *scratch; spClippingAttachment *clipAttachment; spArrayFloatArray *clippingPolygons; } spSkeletonClipping; SP_API spSkeletonClipping *spSkeletonClipping_create(); SP_API int spSkeletonClipping_clipStart(spSkeletonClipping *self, spSlot *slot, spClippingAttachment *clip); SP_API void spSkeletonClipping_clipEnd(spSkeletonClipping *self, spSlot *slot); SP_API void spSkeletonClipping_clipEnd2(spSkeletonClipping *self); SP_API int /*boolean*/ spSkeletonClipping_isClipping(spSkeletonClipping *self); SP_API void spSkeletonClipping_clipTriangles(spSkeletonClipping *self, float *vertices, int verticesLength, unsigned short *triangles, int trianglesLength, float *uvs, int stride); SP_API void spSkeletonClipping_dispose(spSkeletonClipping *self); #ifdef __cplusplus } #endif #endif /* SPINE_SKELETONCLIPPING_H */
954
416
<filename>sfm-map/src/main/java/org/simpleflatmapper/map/property/ConverterProperty.java package org.simpleflatmapper.map.property; import org.simpleflatmapper.converter.ContextualConverter; import org.simpleflatmapper.converter.ContextualConverterAdapter; import org.simpleflatmapper.converter.Converter; import org.simpleflatmapper.util.TypeHelper; import java.lang.reflect.Type; public class ConverterProperty<I, O> { public final ContextualConverter<I, O> function; public final Type inType; public ConverterProperty(Converter<I, O> function, Type inType) { this.function = new ContextualConverterAdapter<I, O>(function); this.inType = inType; } public ConverterProperty(ContextualConverter<I, O> function, Type inType) { this.function = function; this.inType = inType; } public static <I, O> ConverterProperty of(ContextualConverter<I, O> converter, Type inType) { return new ConverterProperty<I, O>(converter, inType); } public static <I, O> ConverterProperty of(ContextualConverter<I, O> converter) { return new ConverterProperty<I, O>(converter, getInType(converter)); } private static <O, I> Type getInType(ContextualConverter<I, O> converter) { Type[] types = TypeHelper.getGenericParameterForClass(converter.getClass(), ContextualConverter.class); if ( types == null) { return Object.class; } else { return types[0]; } } }
568
617
<gh_stars>100-1000 /* * Copyright Beijing 58 Information Technology Co.,Ltd. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package com.bj58.oceanus.core.loadbalance.ha; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.bj58.oceanus.core.context.StatementContext.BatchItem; import com.bj58.oceanus.core.loadbalance.Dispatcher; import com.bj58.oceanus.core.loadbalance.RandomDispatcher; import com.bj58.oceanus.core.resource.DataNode; import com.bj58.oceanus.core.resource.NameNode; /** * 分发器:支持HA、随机负载 * * @author Service Platform Architecture Team (<EMAIL>) */ public class SwapRandomDispatcher extends RandomDispatcher implements Dispatcher, Swapable{ static Logger logger = LoggerFactory.getLogger(SwapRandomDispatcher.class); @Override public DataNode dispatch(NameNode nameNode, BatchItem batchItem) { DataNode dataNode = super.dispatch(nameNode, batchItem); if(!dataNode.isAlive()){ DataNode slave = swapAvailable(dataNode, batchItem); if(slave!=null) return slave; } return dataNode; } @Override public DataNode swapAvailable(DataNode dataNode, BatchItem batchItem) { DataNode[] slaves = dataNode.getSlaves(); DataNode slave = null; if(slaves != null && slaves.length>0){ for(DataNode tmp : slaves){ if(!tmp.isAlive()) continue; slave = tmp; break; } } if(slave == null){ logger.error("DataNode <"+dataNode.getId()+"> has no avaliable slaves"); } return slave; } }
862
8,805
<reponame>thisisgopalmandal/opencv<filename>3rdparty/libwebp/src/enc/vp8li_enc.h<gh_stars>1000+ // Copyright 2012 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Lossless encoder: internal header. // // Author: <NAME> (<EMAIL>) #ifndef WEBP_ENC_VP8LI_ENC_H_ #define WEBP_ENC_VP8LI_ENC_H_ #ifdef HAVE_CONFIG_H #include "src/webp/config.h" #endif // Either WEBP_NEAR_LOSSLESS is defined as 0 in config.h when compiling to // disable near-lossless, or it is enabled by default. #ifndef WEBP_NEAR_LOSSLESS #define WEBP_NEAR_LOSSLESS 1 #endif #include "src/enc/backward_references_enc.h" #include "src/enc/histogram_enc.h" #include "src/utils/bit_writer_utils.h" #include "src/webp/encode.h" #include "src/webp/format_constants.h" #ifdef __cplusplus extern "C" { #endif // maximum value of transform_bits_ in VP8LEncoder. #define MAX_TRANSFORM_BITS 6 typedef enum { kEncoderNone = 0, kEncoderARGB, kEncoderNearLossless, kEncoderPalette } VP8LEncoderARGBContent; typedef struct { const WebPConfig* config_; // user configuration and parameters const WebPPicture* pic_; // input picture. uint32_t* argb_; // Transformed argb image data. VP8LEncoderARGBContent argb_content_; // Content type of the argb buffer. uint32_t* argb_scratch_; // Scratch memory for argb rows // (used for prediction). uint32_t* transform_data_; // Scratch memory for transform data. uint32_t* transform_mem_; // Currently allocated memory. size_t transform_mem_size_; // Currently allocated memory size. int current_width_; // Corresponds to packed image width. // Encoding parameters derived from quality parameter. int histo_bits_; int transform_bits_; // <= MAX_TRANSFORM_BITS. int cache_bits_; // If equal to 0, don't use color cache. // Encoding parameters derived from image characteristics. int use_cross_color_; int use_subtract_green_; int use_predict_; int use_palette_; int palette_size_; uint32_t palette_[MAX_PALETTE_SIZE]; // Some 'scratch' (potentially large) objects. struct VP8LBackwardRefs refs_[3]; // Backward Refs array for temporaries. VP8LHashChain hash_chain_; // HashChain data for constructing // backward references. } VP8LEncoder; //------------------------------------------------------------------------------ // internal functions. Not public. // Encodes the picture. // Returns 0 if config or picture is NULL or picture doesn't have valid argb // input. int VP8LEncodeImage(const WebPConfig* const config, const WebPPicture* const picture); // Encodes the main image stream using the supplied bit writer. // If 'use_cache' is false, disables the use of color cache. WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, const WebPPicture* const picture, VP8LBitWriter* const bw, int use_cache); #if (WEBP_NEAR_LOSSLESS == 1) // in near_lossless.c // Near lossless preprocessing in RGB color-space. int VP8ApplyNearLossless(const WebPPicture* const picture, int quality, uint32_t* const argb_dst); #endif //------------------------------------------------------------------------------ // Image transforms in predictor.c. void VP8LResidualImage(int width, int height, int bits, int low_effort, uint32_t* const argb, uint32_t* const argb_scratch, uint32_t* const image, int near_lossless, int exact, int used_subtract_green); void VP8LColorSpaceTransform(int width, int height, int bits, int quality, uint32_t* const argb, uint32_t* image); //------------------------------------------------------------------------------ #ifdef __cplusplus } // extern "C" #endif #endif // WEBP_ENC_VP8LI_ENC_H_
1,664
819
/* * Copyright (c) 2016, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ #ifndef FATAL_INCLUDE_fatal_type_has_type_h #define FATAL_INCLUDE_fatal_type_has_type_h #include <type_traits> namespace fatal { /** * This macro creates a class named `Class` that can check whether some * type has a member type with name `Member`. * * The class created by this macro looks like this: * * struct Class { * template <typename T> * using apply = <either std::true_type or std::false_type>; * }; * * Example: * * FATAL_HAS_TYPE(has_xyz, xyz); * * struct foo { using xyz = int; }; * struct bar { typedef int xyz; }; * struct baz {}; * struct gaz { struct xyz {}; }; * * // yields `std::true_type` * using result1 = has_xyz::apply<foo>; * * // yields `std::true_type` * using result2 = has_xyz::apply<bar>; * * // yields `std::false_type` * using result3 = has_xyz::apply<baz>; * * // yields `std::true_type` * using result4 = has_xyz::apply<gaz>; * * @author: <NAME> <<EMAIL>> */ #define FATAL_HAS_TYPE(Class, ...) \ struct Class { \ template <typename T> \ static std::true_type sfinae(typename T::__VA_ARGS__ *); \ \ template <typename> \ static std::false_type sfinae(...); \ \ template <typename T> \ using apply = decltype(sfinae<T>(nullptr)); \ } /** * This is a convenience macro that calls `FATAL_HAS_TYPE` using the same * identifier for both `Class` and `Member`. * * Example: * * FATAL_HAS_TYPE_NAME(xyz); * * struct foo { using xyz = int; }; * struct bar { typedef int xyz; }; * struct baz {}; * struct gaz { struct xyz {}; }; * * // yields `std::true_type` * using result1 = xyz::apply<foo>; * * // yields `std::true_type` * using result2 = xyz::apply<bar>; * * // yields `std::false_type` * using result3 = xyz::apply<baz>; * * // yields `std::true_type` * using result4 = xyz::apply<gaz>; * * @author: <NAME> <<EMAIL>> */ #define FATAL_HAS_TYPE_NAME(Name) \ FATAL_HAS_TYPE(Name, Name) /** * A collection of instances of `FATAL_HAS_TYPE` for common member type names. * * @author: <NAME> <<EMAIL>> */ namespace has_type { FATAL_HAS_TYPE_NAME(char_type); FATAL_HAS_TYPE_NAME(int_type); FATAL_HAS_TYPE_NAME(type); FATAL_HAS_TYPE_NAME(types); # define FATAL_IMPL_HAS_TYPE(Name) \ FATAL_HAS_TYPE_NAME(Name); \ FATAL_HAS_TYPE_NAME(Name##_type) FATAL_IMPL_HAS_TYPE(allocator); FATAL_IMPL_HAS_TYPE(args); FATAL_IMPL_HAS_TYPE(array); FATAL_IMPL_HAS_TYPE(category); FATAL_IMPL_HAS_TYPE(config); FATAL_IMPL_HAS_TYPE(const_iterator); FATAL_IMPL_HAS_TYPE(const_pointer); FATAL_IMPL_HAS_TYPE(const_ptr); FATAL_IMPL_HAS_TYPE(const_ref); FATAL_IMPL_HAS_TYPE(const_reference); FATAL_IMPL_HAS_TYPE(const_reverse_iterator); FATAL_IMPL_HAS_TYPE(data); FATAL_IMPL_HAS_TYPE(decode); FATAL_IMPL_HAS_TYPE(decoder); FATAL_IMPL_HAS_TYPE(difference); FATAL_IMPL_HAS_TYPE(element); FATAL_IMPL_HAS_TYPE(encode); FATAL_IMPL_HAS_TYPE(encoder); FATAL_IMPL_HAS_TYPE(extension); FATAL_IMPL_HAS_TYPE(first); FATAL_IMPL_HAS_TYPE(flag); FATAL_IMPL_HAS_TYPE(hash); FATAL_IMPL_HAS_TYPE(id); FATAL_IMPL_HAS_TYPE(ids); FATAL_IMPL_HAS_TYPE(index); FATAL_IMPL_HAS_TYPE(info); FATAL_IMPL_HAS_TYPE(information); FATAL_IMPL_HAS_TYPE(instance); FATAL_IMPL_HAS_TYPE(item); FATAL_IMPL_HAS_TYPE(iterator); FATAL_IMPL_HAS_TYPE(key); FATAL_IMPL_HAS_TYPE(list); FATAL_IMPL_HAS_TYPE(map); FATAL_IMPL_HAS_TYPE(mapped); FATAL_IMPL_HAS_TYPE(mapping); FATAL_IMPL_HAS_TYPE(mappings); FATAL_IMPL_HAS_TYPE(member); FATAL_IMPL_HAS_TYPE(members); FATAL_IMPL_HAS_TYPE(name); FATAL_IMPL_HAS_TYPE(names); FATAL_IMPL_HAS_TYPE(pair); FATAL_IMPL_HAS_TYPE(pointer); FATAL_IMPL_HAS_TYPE(predicate); FATAL_IMPL_HAS_TYPE(ptr); FATAL_IMPL_HAS_TYPE(reader); FATAL_IMPL_HAS_TYPE(ref); FATAL_IMPL_HAS_TYPE(reference); FATAL_IMPL_HAS_TYPE(request); FATAL_IMPL_HAS_TYPE(response); FATAL_IMPL_HAS_TYPE(result); FATAL_IMPL_HAS_TYPE(reverse); FATAL_IMPL_HAS_TYPE(reverse_iterator); FATAL_IMPL_HAS_TYPE(second); FATAL_IMPL_HAS_TYPE(set); FATAL_IMPL_HAS_TYPE(size); FATAL_IMPL_HAS_TYPE(str); FATAL_IMPL_HAS_TYPE(string); FATAL_IMPL_HAS_TYPE(tag); FATAL_IMPL_HAS_TYPE(traits); FATAL_IMPL_HAS_TYPE(tuple); FATAL_IMPL_HAS_TYPE(value); FATAL_IMPL_HAS_TYPE(values); FATAL_IMPL_HAS_TYPE(version); FATAL_IMPL_HAS_TYPE(writer); # undef FATAL_IMPL_HAS_TYPE } } // namespace fatal #endif // FATAL_INCLUDE_fatal_type_has_type_h
2,057
892
<gh_stars>100-1000 { "schema_version": "1.2.0", "id": "GHSA-9chm-qgqp-3whh", "modified": "2022-05-01T02:31:49Z", "published": "2022-05-01T02:31:49Z", "aliases": [ "CVE-2005-4895" ], "details": "Multiple integer overflows in TCMalloc (tcmalloc.cc) in gperftools before 0.4 make it easier for context-dependent attackers to perform memory-related attacks such as buffer overflows via a large size value, which causes less memory to be allocated than expected.", "severity": [ ], "affected": [ ], "references": [ { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2005-4895" }, { "type": "WEB", "url": "http://code.google.com/p/gperftools/source/browse/tags/perftools-0.4/ChangeLog" }, { "type": "WEB", "url": "http://kqueue.org/blog/2012/03/05/memory-allocator-security-revisited/" } ], "database_specific": { "cwe_ids": [ ], "severity": "MODERATE", "github_reviewed": false } }
437
450
<filename>app/src/main/java/ru/krlvm/powertunnel/utilities/PacketUtility.java<gh_stars>100-1000 package ru.krlvm.powertunnel.utilities; import java.util.Arrays; import java.util.LinkedList; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import ru.krlvm.powertunnel.PowerTunnel; /** * Utility with working with * HTTP/HTTPS packets * * @author krlvm */ public class PacketUtility { /** * Retrieves list of packet's ByteBuf chunks * * @param buf - ByteBuf of packet * @return - ByteBuf chunks */ public static LinkedList<ByteBuf> bufferChunk(ByteBuf buf) { return bufferChunk(buf, PowerTunnel.DEFAULT_CHUNK_SIZE); } /** * Retrieves list of packet's ByteBuf chunks * * @param buf - ByteBuf of packet * @param chunkSize - size of chunk * @return - ByteBuf chunks */ public static LinkedList<ByteBuf> bufferChunk(ByteBuf buf, int chunkSize) { LinkedList<byte[]> chunks = chunk(buf, chunkSize); LinkedList<ByteBuf> buffers = new LinkedList<>(); for (byte[] chunk : chunks) { buffers.add(Unpooled.wrappedBuffer(chunk)); } return buffers; } /** * Retrieves list (byte[]) of packet's ByteBuf chunks * * @param buf - ByteBuf of packet * @return - ByteBuf chunks (byte[]) */ public static LinkedList<byte[]> chunk(ByteBuf buf) { return chunk(buf, PowerTunnel.DEFAULT_CHUNK_SIZE); } /** * Retrieves list (byte[]) of packet's ByteBuf chunks * * @param buf - ByteBuf of packet * @param chunkSize - size of chunk * @return - ByteBuf chunks (byte[]) */ public static LinkedList<byte[]> chunk(ByteBuf buf, int chunkSize) { byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); int len = bytes.length; LinkedList<byte[]> byteChunks = new LinkedList<>(); if(PowerTunnel.FULL_CHUNKING) { int i = 0; while (i < len) { byteChunks.add(Arrays.copyOfRange(bytes, i, i += chunkSize)); } } else { byteChunks.add(Arrays.copyOfRange(bytes, 0, chunkSize)); byteChunks.add(Arrays.copyOfRange(bytes, chunkSize, len)); } return byteChunks; } }
1,019
1,267
""" Frontier initialization from settings """ from frontera import FrontierManager, Settings, graphs, Request, Response SETTINGS = Settings() SETTINGS.BACKEND = 'frontera.contrib.backends.memory.FIFO' SETTINGS.LOGGING_MANAGER_ENABLED = True SETTINGS.LOGGING_BACKEND_ENABLED = True SETTINGS.LOGGING_DEBUGGING_ENABLED = True SETTINGS.TEST_MODE = True if __name__ == '__main__': # Create graph graph = graphs.Manager('sqlite:///data/graph.db') # Create frontier from settings frontier = FrontierManager.from_settings(SETTINGS) # Add seeds frontier.add_seeds([Request(seed.url) for seed in graph.seeds]) # Get next requests next_requests = frontier.get_next_requests() # Crawl pages for request in next_requests: # Fake page crawling crawled_page = graph.get_page(request.url) # Create response response = Response(url=request.url, status_code=crawled_page.status, request=request) # Create page links page_links = [Request(link.url) for link in crawled_page.links] # Update Page frontier.page_crawled(response=response, links=page_links)
476
1,628
from pulumi import ComponentResource, ResourceOptions from pulumi_gcp import compute class VpcArgs: def __init__(self, subnet_cidr_blocks=None, ): self.subnet_cidr_blocks = subnet_cidr_blocks class Vpc(ComponentResource): def __init__(self, name: str, args: VpcArgs, opts: ResourceOptions = None): super().__init__("my:modules:Vpc", name, {}, opts) child_opts = ResourceOptions(parent=self) self.network = compute.Network(name, auto_create_subnetworks=False, opts=ResourceOptions(parent=self) ) self.subnets = [] for i, ip_cidr_range in enumerate(args.subnet_cidr_blocks): subnet = compute.Subnetwork(f"{name}-{i}", network=self.network.self_link, ip_cidr_range=ip_cidr_range, opts=ResourceOptions( parent=self.network) ) self.subnets.append(subnet) self.router = compute.Router(name, network=self.network.self_link, opts=ResourceOptions(parent=self.network) ) self.nat = compute.RouterNat(name, router=self.router.name, nat_ip_allocate_option="AUTO_ONLY", source_subnetwork_ip_ranges_to_nat="ALL_SUBNETWORKS_ALL_IP_RANGES", opts=ResourceOptions(parent=self.network) ) self.register_outputs({})
1,187
1,068
package com.github.jknack.handlebars; import java.io.File; import java.io.IOException; import org.junit.Test; public class Issue308 extends AbstractTest { @Override protected void configure(final Handlebars handlebars) { try { handlebars.registerHelpers(new File("src/test/resources/issue308.js")); } catch (Exception ex) { throw new IllegalStateException(ex); } } @Test public void dowork() throws IOException { shouldCompileTo( "{{#dowork root/results}}name:{{name}}, age:{{age}}, newval:{{newval}} {{/dowork}}", $("root", $("results", new Object[]{$("name", "edgar", "age", 34), $("name", "pato", "age", 34) })), "name:edgar, age:34, newval:colleague name:pato, age:34, newval:friend "); } }
307
576
#pragma once #include "core/templates/paged_allocator.h" #include "dense_vector.h" #include "storage.h" /// The `SharedSteadyStorage` is the perfect choice when you want to share the /// same component between entities, and that components memory never changes. /// /// When dealing with physics engines or audio engines, etc... it's usually /// needed to have objects that are shared between some other objects: in /// all those cases, it's possible to use this storage. template <class T> class SharedSteadyStorage : public SharedStorage<T> { PagedAllocator<T, false> allocator; LocalVector<T *> allocated_pointers; DenseVector<godex::SID> storage; public: virtual void configure(const Dictionary &p_config) override { clear(); allocator.configure(p_config.get("page_size", 200)); } virtual String get_type_name() const override { return "SteadyStorage[" + String(typeid(T).name()) + "]"; } virtual bool is_steady() const override { return true; } virtual godex::SID create_shared_component(const T &p_data) override { T *d = allocator.alloc(); *d = p_data; godex::SID id = allocated_pointers.size(); allocated_pointers.push_back(d); return id; } virtual void free_shared_component(godex::SID p_id) override { if (p_id < allocated_pointers.size()) { if (allocated_pointers[p_id] != nullptr) { allocator.free(allocated_pointers[p_id]); allocated_pointers[p_id] = nullptr; } } } virtual bool has_shared_component(godex::SID p_id) const override { if (p_id < allocated_pointers.size()) { return allocated_pointers[p_id] != nullptr; } return false; } virtual void insert(EntityID p_entity, godex::SID p_id) override { if (p_id < allocated_pointers.size()) { if (allocated_pointers[p_id] != nullptr) { storage.insert(p_entity, p_id); StorageBase::notify_changed(p_entity); return; } } ERR_PRINT("The SID is not poiting to any valid object. This is not supposed to happen."); } virtual T *get_shared_component(godex::SID p_id) override { if (p_id < allocated_pointers.size()) { if (allocated_pointers[p_id] != nullptr) { return allocated_pointers[p_id]; } } CRASH_NOW_MSG("This Entity doesn't have anything stored, before get the data you have to use `has()`."); return nullptr; } virtual const T *get_shared_component(godex::SID p_id) const override { if (p_id < allocated_pointers.size()) { if (allocated_pointers[p_id] != nullptr) { return allocated_pointers[p_id]; } } CRASH_NOW_MSG("This Entity doesn't have anything stored, before get the data you have to use `has()`."); return nullptr; } virtual bool has(EntityID p_entity) const override { bool h = storage.has(p_entity); if (h) { const godex::SID id = storage.get(p_entity); if (id < allocated_pointers.size()) { h = allocated_pointers[id] != nullptr; } else { // Doesn't have. h = false; } } return h; } virtual T *get(EntityID p_entity, Space p_mode = Space::LOCAL) override { StorageBase::notify_changed(p_entity); return get_shared_component(storage.get(p_entity)); } virtual const T *get(EntityID p_entity, Space p_mode = Space::LOCAL) const override { return get_shared_component(storage.get(p_entity)); } virtual void remove(EntityID p_entity) override { storage.remove(p_entity); // Make sure to remove as changed. StorageBase::notify_updated(p_entity); } virtual void clear() override { allocator.reset(); allocated_pointers.reset(); storage.clear(); StorageBase::flush_changed(); } virtual EntitiesBuffer get_stored_entities() const { return { storage.get_entities().size(), storage.get_entities().ptr() }; } };
1,330
323
<reponame>pavanbadugu/cachelot #include <cachelot/common.h> #include <cachelot/cache.h> #include <cachelot/random.h> #include <cachelot/hash_fnv1a.h> #include <cachelot/stats.h> #include <iostream> #include <iomanip> using namespace cachelot; using std::chrono::microseconds; using std::chrono::milliseconds; using std::chrono::seconds; using std::chrono::minutes; using std::chrono::hours; constexpr size_t num_items = 1000000; constexpr size_t cache_memory = 64 * Megabyte; constexpr size_t page_size = 4 * Megabyte; constexpr size_t hash_initial = 131072; constexpr uint8 min_key_len = 14; constexpr uint8 max_key_len = 40; constexpr uint32 min_value_len = 14; constexpr uint32 max_value_len = 40; namespace { // Hash function static auto calc_hash = fnv1a<cache::Cache::hash_type>::hasher(); static struct stats_type { uint64 num_get = 0; uint64 num_set = 0; uint64 num_del = 0; uint64 num_cache_hit = 0; uint64 num_cache_miss = 0; uint64 num_error = 0; } bench_stats; inline void reset_stats() { new (&bench_stats)stats_type(); } } typedef std::tuple<string, string> kv_type; typedef std::vector<kv_type> array_type; typedef array_type::const_iterator iterator; class CacheWrapper { public: CacheWrapper() : m_cache(cache::Cache::Create(cache_memory, page_size, hash_initial, true)) {} void set(iterator it) { slice k (std::get<0>(*it).c_str(), std::get<0>(*it).size()); slice v (std::get<1>(*it).c_str(), std::get<1>(*it).size()); cache::ItemPtr item = nullptr; try { item = m_cache.create_item(k, calc_hash(k), v.length(), /*flags*/0, cache::Item::infinite_TTL); item->assign_value(v); m_cache.do_set(item); bench_stats.num_set += 1; } catch (const std::exception &) { bench_stats.num_error += 1; } } void get(iterator it) { slice k (std::get<0>(*it).c_str(), std::get<0>(*it).size()); auto found_item = m_cache.do_get(k, calc_hash(k)); bench_stats.num_get += 1; auto & counter = found_item ? bench_stats.num_cache_hit : bench_stats.num_cache_miss; counter += 1; } void del(iterator it) { slice k (std::get<0>(*it).c_str(), std::get<0>(*it).size()); bool found = m_cache.do_delete(k, calc_hash(k)); bench_stats.num_del += 1; auto & counter = found ? bench_stats.num_cache_hit : bench_stats.num_cache_miss; counter += 1; } private: cache::Cache m_cache; }; array_type data_array; std::unique_ptr<CacheWrapper> csh; inline iterator random_pick() { debug_assert(data_array.size() > 0); static random_int<array_type::size_type> rndelem(0, data_array.size() - 1); auto at = rndelem(); return data_array.begin() + at; } static void generate_test_data() { data_array.reserve(num_items); for (auto n=num_items; n > 0; --n) { kv_type kv(random_string(min_key_len, max_key_len), random_string(min_value_len, max_value_len)); data_array.emplace_back(kv); } } static void warmup() { for (auto n=hash_initial; n > 0; --n) { csh->set(random_pick()); } } auto chance = random_int<size_t>(1, 100); int main(int /*argc*/, char * /*argv*/[]) { csh.reset(new CacheWrapper()); generate_test_data(); warmup(); reset_stats(); auto start_time = std::chrono::high_resolution_clock::now(); for (int i=0; i<3; ++i) { for (iterator kv = data_array.begin(); kv < data_array.end(); ++kv) { csh->set(kv); if (chance() > 70) { csh->del(random_pick()); } if (chance() > 30) { csh->get(random_pick()); } } } auto time_passed = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - start_time); const double sec = time_passed.count() / 1000000000; std::cout << std::fixed << std::setprecision(3); std::cout << "Time spent: " << sec << "s" << std::endl; std::cout << "get: " << bench_stats.num_get << std::endl; std::cout << "set: " << bench_stats.num_set << std::endl; std::cout << "del: " << bench_stats.num_del << std::endl; std::cout << "cache_hit: " << bench_stats.num_cache_hit << std::endl; std::cout << "cache_miss: " << bench_stats.num_cache_miss << std::endl; std::cout << "error: " << bench_stats.num_error << std::endl; const double RPS = (bench_stats.num_get + bench_stats.num_set + bench_stats.num_del) / sec; std::cout << "rps: " << RPS << std::endl; std::cout << "avg. cost: " << static_cast<unsigned>(1000000000 / RPS) << "ns" << std::endl; std::cout << std::endl; PrintStats(); return 0; }
2,185
23,901
<reponame>deepneuralmachine/google-research // Copyright 2020 The Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // 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. // // Random Subset Algorithm // // This algorithm returns a random subetset of the universe as the solution. #ifndef FULLY_DYNAMIC_SUBMODULAR_MAXIMIZATION_RANDOM_SUBSET_ALGORITHM_H_ #define FULLY_DYNAMIC_SUBMODULAR_MAXIMIZATION_RANDOM_SUBSET_ALGORITHM_H_ #include "algorithm.h" #include "utilities.h" class RandomSubsetAlgorithm : public Algorithm { public: void Initialization(const SubmodularFunction& sub_func_f, int cardinality_k); void Insert(int element); void Erase(int element); double GetSolutionValue(); std::vector<int> GetSolutionVector(); std::string GetAlgorithmName() const; private: // Cardinality constraint. int cardinality_k_; // The solution (i.e. sampled elements), all the elements in the universe. std::vector<int> solution_, universe_elements_; // Submodulaer function. std::unique_ptr<SubmodularFunction> sub_func_f_; }; #endif // FULLY_DYNAMIC_SUBMODULAR_MAXIMIZATION_RANDOM_SUBSET_ALGORITHM_H_
504
1,144
<gh_stars>1000+ /* * #%L * de.metas.adempiere.adempiere.base * %% * Copyright (C) 2021 metas GmbH * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-2.0.html>. * #L% */ package de.metas.dao.sql; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.*; class SqlParamsInlinerTest { @Test void standardCase() { final SqlParamsInliner sqlParamsInliner = SqlParamsInliner.builder().failOnError(false).build(); assertThat(sqlParamsInliner.inline("SELECT * FROM MD_Stock WHERE ((M_Product_ID = ?) AND (M_Warehouse_ID=?) AND (1=1))", 1000111, 540008)) .isEqualTo("SELECT * FROM MD_Stock WHERE ((M_Product_ID = 1000111) AND (M_Warehouse_ID=540008) AND (1=1))"); } @Nested class missingParams { @Test void doNotFailOnError() { final SqlParamsInliner sqlParamsInliner = SqlParamsInliner.builder().failOnError(false).build(); assertThat(sqlParamsInliner.inline("SELECT * FROM Table where a=? and b=? and c=?", 1, "str")) .isEqualTo("SELECT * FROM Table where a=1 and b='str' and c=?missing3?"); } @Test void failOnError() { final SqlParamsInliner sqlParamsInliner = SqlParamsInliner.builder().failOnError(true).build(); assertThatThrownBy(() -> sqlParamsInliner.inline("SELECT * FROM Table where a=? and b=? and c=?", 1, "str")) .hasMessageStartingWith("Missing SQL parameter with index=3"); } } @Nested class exceeedingParams { @Test void doNotFailOnError() { final SqlParamsInliner sqlParamsInliner = SqlParamsInliner.builder().failOnError(false).build(); assertThat(sqlParamsInliner.inline("SELECT * FROM Table where c=?", 1, "str", 3)) .isEqualTo("SELECT * FROM Table where c=1 -- Exceeding params: 'str', 3"); } @Test void failOnError() { final SqlParamsInliner sqlParamsInliner = SqlParamsInliner.builder().failOnError(true).build(); assertThatThrownBy(() -> sqlParamsInliner.inline("SELECT * FROM Table where c=?", 1, "str", 3)) .hasMessageStartingWith("Got more SQL params than needed: [str, 3]"); } } }
962
3,227
<reponame>ffteja/cgal /*! \ingroup PkgAlgebraicKernelDConceptsBi \cgalConcept Computes an isolating box for a given `AlgebraicKernel_d_2::Algebraic_real_2`. \cgalRefines `AdaptableFunctor` \sa `AlgebraicKernel_d_2::IsolateX_2` \sa `AlgebraicKernel_d_2::IsolateY_2` \sa `AlgebraicKernel_d_2::ComputePolynomialX_2` \sa `AlgebraicKernel_d_2::ComputePolynomialY_2` */ class AlgebraicKernel_d_2::Isolate_2 { public: /// \name Types /// @{ /*! */ typedef std::array<AlgebraicKernel_d_1::Bound, 4> result_type; /// @} /// \name Operations /// @{ /*! The returned `std::array` \f$ [xl,xu,yl,yu]\f$ represents an open isolating box \f$ B=(xl,xu)\times(yl,yu)\f$ for \f$ a\f$ with respect to \f$ f\f$. \pre \f$ f(a)\neq0\f$ \post \f$ a \in B\f$. \post \f$ \{ r | f(r)=0 \} \cap\overline{B} = \emptyset\f$. */ result_type operator()( AlgebraicKernel_d_2::Algebraic_real_2 a, AlgebraicKernel_d_2::Polynomial_2 f); /*! The returned `std::array` \f$ [xl,xu,yl,yu]\f$ represents an open isolating box \f$ B=(xl,xu)\times(yl,yu)\f$ for \f$ a\f$ with respect to the common solutions of \f$ f\f$ and \f$ g\f$. It is not necessary that \f$ a\f$ is a common solution of \f$ f\f$ and \f$ g\f$. \post \f$ a \in B\f$. \post \f$ \{ r | f(r)=g(r)=0 \} \cap\overline{B} \in\{\{a\},\emptyset\}\f$. */ result_type operator()( AlgebraicKernel_d_2::Algebraic_real_2 a, AlgebraicKernel_d_2::Polynomial_2 f, AlgebraicKernel_d_2::Polynomial_2 g); /// @} }; /* end AlgebraicKernel_d_2::Isolate_2 */
700
2,633
<reponame>afxcn/unit<gh_stars>1000+ /* * Copyright (C) <NAME> * Copyright (C) NGINX, Inc. */ #include <nxt_main.h> typedef struct { nxt_http_chunk_parse_t parse; nxt_source_hook_t next; } nxt_http_source_chunk_t; static nxt_buf_t *nxt_http_source_request_create(nxt_http_source_t *hs); static void nxt_http_source_status_filter(nxt_task_t *task, void *obj, void *data); static void nxt_http_source_header_filter(nxt_task_t *task, void *obj, void *data); static nxt_int_t nxt_http_source_header_line_process(nxt_http_source_t *hs); static nxt_int_t nxt_http_source_content_length(nxt_upstream_source_t *us, nxt_name_value_t *nv); static nxt_int_t nxt_http_source_transfer_encoding(nxt_upstream_source_t *us, nxt_name_value_t *nv); static void nxt_http_source_header_ready(nxt_task_t *task, nxt_http_source_t *hs, nxt_buf_t *rest); static void nxt_http_source_chunk_filter(nxt_task_t *task, void *obj, void *data); static void nxt_http_source_chunk_error(nxt_task_t *task, void *obj, void *data); static void nxt_http_source_body_filter(nxt_task_t *task, void *obj, void *data); static void nxt_http_source_sync_buffer(nxt_task_t *task, nxt_http_source_t *hs, nxt_buf_t *b); static void nxt_http_source_error(nxt_task_t *task, nxt_stream_source_t *stream); static void nxt_http_source_fail(nxt_task_t *task, nxt_http_source_t *hs); static void nxt_http_source_message(const char *msg, size_t len, u_char *p); void nxt_http_source_handler(nxt_task_t *task, nxt_upstream_source_t *us, nxt_http_source_request_create_t request_create) { nxt_http_source_t *hs; nxt_stream_source_t *stream; hs = nxt_mp_zget(us->buffers.mem_pool, sizeof(nxt_http_source_t)); if (nxt_slow_path(hs == NULL)) { goto fail; } us->protocol_source = hs; hs->header_in.list = nxt_list_create(us->buffers.mem_pool, 8, sizeof(nxt_name_value_t)); if (nxt_slow_path(hs->header_in.list == NULL)) { goto fail; } hs->header_in.hash = us->header_hash; hs->upstream = us; hs->request_create = request_create; stream = us->stream; if (stream == NULL) { stream = nxt_mp_zget(us->buffers.mem_pool, sizeof(nxt_stream_source_t)); if (nxt_slow_path(stream == NULL)) { goto fail; } us->stream = stream; stream->upstream = us; } else { nxt_memzero(stream, sizeof(nxt_stream_source_t)); } /* * Create the HTTP source filter chain: * stream source | HTTP status line filter */ stream->next = &hs->query; stream->error_handler = nxt_http_source_error; hs->query.context = hs; hs->query.filter = nxt_http_source_status_filter; hs->header_in.content_length = -1; stream->out = nxt_http_source_request_create(hs); if (nxt_fast_path(stream->out != NULL)) { nxt_memzero(&hs->u.status_parse, sizeof(nxt_http_status_parse_t)); nxt_stream_source_connect(task, stream); return; } fail: nxt_http_source_fail(task, hs); } nxt_inline u_char * nxt_http_source_copy(u_char *p, nxt_str_t *src, size_t len) { u_char *s; if (nxt_fast_path(len >= src->len)) { len = src->len; src->len = 0; } else { src->len -= len; } s = src->data; src->data += len; return nxt_cpymem(p, s, len); } static nxt_buf_t * nxt_http_source_request_create(nxt_http_source_t *hs) { nxt_int_t ret; nxt_buf_t *b, *req, **prev; nxt_thread_log_debug("http source create request"); prev = &req; new_buffer: ret = nxt_buf_pool_mem_alloc(&hs->upstream->buffers, 0); if (nxt_slow_path(ret != NXT_OK)) { return NULL; } b = hs->upstream->buffers.current; hs->upstream->buffers.current = NULL; *prev = b; prev = &b->next; for ( ;; ) { ret = hs->request_create(hs); if (nxt_fast_path(ret == NXT_OK)) { b->mem.free = nxt_http_source_copy(b->mem.free, &hs->u.request.copy, b->mem.end - b->mem.free); if (nxt_fast_path(hs->u.request.copy.len == 0)) { continue; } nxt_thread_log_debug("\"%*s\"", b->mem.free - b->mem.pos, b->mem.pos); goto new_buffer; } if (nxt_slow_path(ret == NXT_ERROR)) { return NULL; } /* ret == NXT_DONE */ break; } nxt_thread_log_debug("\"%*s\"", b->mem.free - b->mem.pos, b->mem.pos); return req; } static void nxt_http_source_status_filter(nxt_task_t *task, void *obj, void *data) { nxt_int_t ret; nxt_buf_t *b; nxt_http_source_t *hs; hs = obj; b = data; /* * No cycle over buffer chain is required since at * start the stream source passes buffers one at a time. */ nxt_debug(task, "http source status filter"); if (nxt_slow_path(nxt_buf_is_sync(b))) { nxt_http_source_sync_buffer(task, hs, b); return; } ret = nxt_http_status_parse(&hs->u.status_parse, &b->mem); if (nxt_fast_path(ret == NXT_OK)) { /* * Change the HTTP source filter chain: * stream source | HTTP header filter */ hs->query.filter = nxt_http_source_header_filter; nxt_debug(task, "upstream status: \"%*s\"", hs->u.status_parse.end - b->mem.start, b->mem.start); hs->header_in.status = hs->u.status_parse.code; nxt_debug(task, "upstream version:%d status:%uD \"%*s\"", hs->u.status_parse.http_version, hs->u.status_parse.code, hs->u.status_parse.end - hs->u.status_parse.start, hs->u.status_parse.start); nxt_memzero(&hs->u.header, sizeof(nxt_http_split_header_parse_t)); hs->u.header.mem_pool = hs->upstream->buffers.mem_pool; nxt_http_source_header_filter(task, hs, b); return; } if (nxt_slow_path(ret == NXT_ERROR)) { /* HTTP/0.9 response. */ hs->header_in.status = 200; nxt_http_source_header_ready(task, hs, b); return; } /* ret == NXT_AGAIN */ /* * b->mem.pos is always equal to b->mem.end because b is a buffer * which points to a response part read by the stream source. * However, since the stream source is an immediate source of the * status filter, b->parent is a buffer the stream source reads in. */ if (b->parent->mem.pos == b->parent->mem.end) { nxt_http_source_message("upstream sent too long status line: \"%*s\"", b->mem.pos - b->mem.start, b->mem.start); nxt_http_source_fail(task, hs); } } static void nxt_http_source_header_filter(nxt_task_t *task, void *obj, void *data) { nxt_int_t ret; nxt_buf_t *b; nxt_http_source_t *hs; hs = obj; b = data; /* * No cycle over buffer chain is required since at * start the stream source passes buffers one at a time. */ nxt_debug(task, "http source header filter"); if (nxt_slow_path(nxt_buf_is_sync(b))) { nxt_http_source_sync_buffer(task, hs, b); return; } for ( ;; ) { ret = nxt_http_split_header_parse(&hs->u.header, &b->mem); if (nxt_slow_path(ret != NXT_OK)) { break; } ret = nxt_http_source_header_line_process(hs); if (nxt_slow_path(ret != NXT_OK)) { break; } } if (nxt_fast_path(ret == NXT_DONE)) { nxt_debug(task, "http source header done"); nxt_http_source_header_ready(task, hs, b); return; } if (nxt_fast_path(ret == NXT_AGAIN)) { return; } if (ret != NXT_ERROR) { /* ret == NXT_DECLINED: "\r" is not followed by "\n" */ nxt_log(task, NXT_LOG_ERR, "upstream sent invalid header line: \"%*s\\r...\"", hs->u.header.parse.header_end - hs->u.header.parse.header_name_start, hs->u.header.parse.header_name_start); } /* ret == NXT_ERROR */ nxt_http_source_fail(task, hs); } static nxt_int_t nxt_http_source_header_line_process(nxt_http_source_t *hs) { size_t name_len; nxt_name_value_t *nv; nxt_lvlhsh_query_t lhq; nxt_http_header_parse_t *hp; nxt_upstream_name_value_t *unv; hp = &hs->u.header.parse; name_len = hp->header_name_end - hp->header_name_start; if (name_len > 255) { nxt_http_source_message("upstream sent too long header field name: " "\"%*s\"", name_len, hp->header_name_start); return NXT_ERROR; } nv = nxt_list_add(hs->header_in.list); if (nxt_slow_path(nv == NULL)) { return NXT_ERROR; } nv->hash = hp->header_hash; nv->skip = 0; nv->name_len = name_len; nv->name_start = hp->header_name_start; nv->value_len = hp->header_end - hp->header_start; nv->value_start = hp->header_start; nxt_thread_log_debug("upstream header: \"%*s: %*s\"", nv->name_len, nv->name_start, nv->value_len, nv->value_start); lhq.key_hash = nv->hash; lhq.key.len = nv->name_len; lhq.key.data = nv->name_start; lhq.proto = &nxt_upstream_header_hash_proto; if (nxt_lvlhsh_find(&hs->header_in.hash, &lhq) == NXT_OK) { unv = lhq.value; if (unv->handler(hs->upstream, nv) != NXT_OK) { return NXT_ERROR; } } return NXT_OK; } static const nxt_upstream_name_value_t nxt_http_source_headers[] nxt_aligned(32) = { { nxt_http_source_content_length, nxt_upstream_name_value("content-length") }, { nxt_http_source_transfer_encoding, nxt_upstream_name_value("transfer-encoding") }, }; nxt_int_t nxt_http_source_hash_create(nxt_mp_t *mp, nxt_lvlhsh_t *lh) { return nxt_upstream_header_hash_add(mp, lh, nxt_http_source_headers, nxt_nitems(nxt_http_source_headers)); } static nxt_int_t nxt_http_source_content_length(nxt_upstream_source_t *us, nxt_name_value_t *nv) { nxt_off_t length; nxt_http_source_t *hs; length = nxt_off_t_parse(nv->value_start, nv->value_len); if (nxt_fast_path(length > 0)) { hs = us->protocol_source; hs->header_in.content_length = length; return NXT_OK; } return NXT_ERROR; } static nxt_int_t nxt_http_source_transfer_encoding(nxt_upstream_source_t *us, nxt_name_value_t *nv) { u_char *end; nxt_http_source_t *hs; end = nv->value_start + nv->value_len; if (nxt_memcasestrn(nv->value_start, end, "chunked", 7) != NULL) { hs = us->protocol_source; hs->chunked = 1; } return NXT_OK; } static void nxt_http_source_header_ready(nxt_task_t *task, nxt_http_source_t *hs, nxt_buf_t *rest) { nxt_buf_t *b; nxt_upstream_source_t *us; nxt_http_source_chunk_t *hsc; us = hs->upstream; /* Free buffers used for request header. */ for (b = us->stream->out; b != NULL; b = b->next) { nxt_buf_pool_free(&us->buffers, b); } if (nxt_fast_path(nxt_buf_pool_available(&us->buffers))) { if (hs->chunked) { hsc = nxt_mp_zalloc(hs->upstream->buffers.mem_pool, sizeof(nxt_http_source_chunk_t)); if (nxt_slow_path(hsc == NULL)) { goto fail; } /* * Change the HTTP source filter chain: * stream source | chunk filter | HTTP body filter */ hs->query.context = hsc; hs->query.filter = nxt_http_source_chunk_filter; hsc->next.context = hs; hsc->next.filter = nxt_http_source_body_filter; hsc->parse.mem_pool = hs->upstream->buffers.mem_pool; if (nxt_buf_mem_used_size(&rest->mem) != 0) { hs->rest = nxt_http_chunk_parse(task, &hsc->parse, rest); if (nxt_slow_path(hs->rest == NULL)) { goto fail; } } } else { /* * Change the HTTP source filter chain: * stream source | HTTP body filter */ hs->query.filter = nxt_http_source_body_filter; if (nxt_buf_mem_used_size(&rest->mem) != 0) { hs->rest = rest; } } hs->upstream->state->ready_handler(hs); return; } nxt_thread_log_error(NXT_LOG_ERR, "%d buffers %uDK each " "are not enough to read upstream response", us->buffers.max, us->buffers.size / 1024); fail: nxt_http_source_fail(task, hs); } static void nxt_http_source_chunk_filter(nxt_task_t *task, void *obj, void *data) { nxt_buf_t *b; nxt_http_source_t *hs; nxt_http_source_chunk_t *hsc; hsc = obj; b = data; nxt_debug(task, "http source chunk filter"); b = nxt_http_chunk_parse(task, &hsc->parse, b); hs = hsc->next.context; if (hsc->parse.error) { nxt_http_source_fail(task, hs); return; } if (hsc->parse.chunk_error) { /* Output all parsed before a chunk error and close upstream. */ nxt_thread_current_work_queue_add(task->thread, nxt_http_source_chunk_error, task, hs, NULL); } if (b != NULL) { nxt_source_filter(task->thread, hs->upstream->work_queue, task, &hsc->next, b); } } static void nxt_http_source_chunk_error(nxt_task_t *task, void *obj, void *data) { nxt_http_source_t *hs; hs = obj; nxt_http_source_fail(task, hs); } /* * The HTTP source body filter accumulates first body buffers before the next * filter will be established and sets completion handler for the last buffer. */ static void nxt_http_source_body_filter(nxt_task_t *task, void *obj, void *data) { nxt_buf_t *b, *in; nxt_http_source_t *hs; hs = obj; in = data; nxt_debug(task, "http source body filter"); for (b = in; b != NULL; b = b->next) { if (nxt_buf_is_last(b)) { b->data = hs->upstream->data; b->completion_handler = hs->upstream->state->completion_handler; } } if (hs->next != NULL) { nxt_source_filter(task->thread, hs->upstream->work_queue, task, hs->next, in); return; } nxt_buf_chain_add(&hs->rest, in); } static void nxt_http_source_sync_buffer(nxt_task_t *task, nxt_http_source_t *hs, nxt_buf_t *b) { if (nxt_buf_is_last(b)) { nxt_log(task, NXT_LOG_ERR, "upstream closed prematurely connection"); } else { nxt_log(task, NXT_LOG_ERR,"%ui buffers %uz each are not " "enough to process upstream response header", hs->upstream->buffers.max, hs->upstream->buffers.size); } /* The stream source sends only the last and the nobuf sync buffer. */ nxt_http_source_fail(task, hs); } static void nxt_http_source_error(nxt_task_t *task, nxt_stream_source_t *stream) { nxt_http_source_t *hs; nxt_thread_log_debug("http source error"); hs = stream->next->context; nxt_http_source_fail(task, hs); } static void nxt_http_source_fail(nxt_task_t *task, nxt_http_source_t *hs) { nxt_debug(task, "http source fail"); /* TODO: fail, next upstream, or bad gateway */ hs->upstream->state->error_handler(task, hs, NULL); } static void nxt_http_source_message(const char *msg, size_t len, u_char *p) { if (len > NXT_MAX_ERROR_STR - 300) { len = NXT_MAX_ERROR_STR - 300; p[len++] = '.'; p[len++] = '.'; p[len++] = '.'; } nxt_thread_log_error(NXT_LOG_ERR, msg, len, p); }
8,114
369
// Copyright (c) 2017-2021, Mudit<NAME>.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include "BatteryBase.hpp" namespace gui { class Label; } namespace gui::status_bar { class BatteryText : public BatteryBase { public: BatteryText(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h); private: void showBatteryLevel(std::uint32_t percentage) override; void showBatteryChargingDone() override; void showBatteryCharging() override; Label *label = nullptr; }; } // namespace gui::status_bar
249
3,986
/* * Copyright (C) 2018 xuexiangjys(<EMAIL>) * * 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. * */ package com.xuexiang.xui.widget.dialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.drawable.Drawable; import androidx.annotation.StyleRes; import android.text.TextUtils; import android.view.View; import android.widget.TextView; import com.xuexiang.xui.R; import com.xuexiang.xui.widget.progress.loading.ARCLoadingView; import com.xuexiang.xui.widget.progress.loading.IMessageLoader; import com.xuexiang.xui.widget.progress.loading.LoadingCancelListener; /** * loading加载框 * * @author xuexiang * @since 2019/1/14 下午10:08 */ public class LoadingDialog extends BaseDialog implements IMessageLoader { private ARCLoadingView mLoadingView; private TextView mTvTipMessage; private LoadingCancelListener mLoadingCancelListener; public LoadingDialog(Context context) { super(context, R.layout.xui_dialog_loading); initView(getString(R.string.xui_tip_loading_message)); } public LoadingDialog(Context context, String tipMessage) { super(context, R.layout.xui_dialog_loading); initView(tipMessage); } public LoadingDialog(Context context, @StyleRes int themeResId) { super(context, themeResId, R.layout.xui_dialog_loading); initView(getString(R.string.xui_tip_loading_message)); } public LoadingDialog(Context context, @StyleRes int themeResId, String tipMessage) { super(context, themeResId, R.layout.xui_dialog_loading); initView(tipMessage); } private void initView(String tipMessage) { mLoadingView = findViewById(R.id.arc_loading_view); mTvTipMessage = findViewById(R.id.tv_tip_message); updateMessage(tipMessage); setCancelable(false); setCanceledOnTouchOutside(false); } /** * 更新提示信息 * * @param tipMessage * @return */ @Override public void updateMessage(String tipMessage) { if (mTvTipMessage != null) { if (!TextUtils.isEmpty(tipMessage)) { mTvTipMessage.setText(tipMessage); mTvTipMessage.setVisibility(View.VISIBLE); } else { mTvTipMessage.setText(""); mTvTipMessage.setVisibility(View.GONE); } } } /** * 更新提示信息 * * @param tipMessageId * @return */ @Override public void updateMessage(int tipMessageId) { updateMessage(getString(tipMessageId)); } /** * 设置loading的图标 * * @param icon * @return */ public LoadingDialog setLoadingIcon(Drawable icon) { if (mLoadingView != null) { mLoadingView.setLoadingIcon(icon); } return this; } /** * 设置loading的图标 * * @param iconResId * @return */ public LoadingDialog setLoadingIcon(int iconResId) { return setLoadingIcon(getDrawable(iconResId)); } /** * 设置图标的缩小比例 * * @param iconScale * @return */ public LoadingDialog setIconScale(float iconScale) { if (mLoadingView != null) { mLoadingView.setIconScale(iconScale); } return this; } /** * 设置loading旋转的速度 * * @param speed * @return */ public LoadingDialog setLoadingSpeed(int speed) { if (mLoadingView != null) { mLoadingView.setSpeedOfDegree(speed); } return this; } @Override public void show() { super.show(); if (mLoadingView != null) { mLoadingView.start(); } } @Override public void dismiss() { if (mLoadingView != null) { mLoadingView.stop(); } super.dismiss(); } /** * 资源释放 */ @Override public void recycle() { if (mLoadingView != null) { mLoadingView.recycle(); } } @Override public boolean isLoading() { return isShowing(); } @Override public void setCancelable(boolean flag) { super.setCancelable(flag); if (flag) { setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { if (mLoadingCancelListener != null) { mLoadingCancelListener.onCancelLoading(); } } }); } } @Override public void setLoadingCancelListener(LoadingCancelListener listener) { mLoadingCancelListener = listener; } }
2,310
605
<gh_stars>100-1000 #include "libvim.h" #include "minunit.h" #include "vim.h" static int mappingCallbackCount = 0; static const mapblock_T *lastMapping = NULL; static int unmappingCallbackCount = 0; static char_u *lastUnmapKeys = NULL; static int lastUnmapMode = -1; void onMessage(char_u *title, char_u *msg, msgPriority_T priority) { printf("onMessage - title: |%s| contents: |%s|", title, msg); }; void onMap(const mapblock_T *mapping) { printf("onMapping - orig_keys: |%s| keys: |%s| orig_str: |%s| script id: |%d|\n", mapping->m_orig_keys, mapping->m_keys, mapping->m_orig_str, mapping->m_script_ctx.sc_sid); lastMapping = mapping; mappingCallbackCount++; }; void onUnmap(int mode, const char_u *keys) { // printf("onUnmapping - mode: %d keys: %s\n", // mode, // keys); lastUnmapMode = mode; if (keys != NULL) { lastUnmapKeys = vim_strsave((char_u *)keys); } unmappingCallbackCount++; }; void test_setup(void) { vimKey("<esc>"); vimKey("<esc>"); vimExecute("e!"); vimInput("g"); vimInput("g"); vimExecute("mapclear"); mappingCallbackCount = 0; unmappingCallbackCount = 0; lastMapping = NULL; if (lastUnmapKeys != NULL) { vim_free(lastUnmapKeys); lastUnmapKeys = NULL; } lastUnmapMode = -1; } void test_teardown(void) {} MU_TEST(test_simple_mapping) { vimExecute("inoremap jk <Esc>"); mu_check(strcmp("jk", lastMapping->m_orig_keys) == 0); mu_check(strcmp("<Esc>", lastMapping->m_orig_str) == 0); mu_check(mappingCallbackCount == 1); }; MU_TEST(test_lhs_termcode) { vimExecute("inoremap <Esc> jk"); mu_check(strcmp("<Esc>", lastMapping->m_orig_keys) == 0); mu_check(strcmp("jk", lastMapping->m_orig_str) == 0); mu_check(mappingCallbackCount == 1); }; MU_TEST(test_map_same_keys) { vimExecute("inoremap jj <Esc>"); mu_check(mappingCallbackCount == 1); vimExecute("inoremap jj <F1>"); mu_check(mappingCallbackCount == 2); mu_check(strcmp("jj", lastMapping->m_orig_keys) == 0); mu_check(strcmp("<F1>", lastMapping->m_orig_str) == 0); }; MU_TEST(test_map_same_keys_multiple_modes) { vimExecute("inoremap jj <Esc>"); mu_check(mappingCallbackCount == 1); vimExecute("nnoremap jj <F1>"); mu_check(mappingCallbackCount == 2); mu_check(lastMapping->m_mode == NORMAL); mu_check(strcmp("jj", lastMapping->m_orig_keys) == 0); mu_check(strcmp("<F1>", lastMapping->m_orig_str) == 0); }; MU_TEST(test_sid_resolution) { vimExecute("source collateral/map_plug_sid.vim"); mu_check(mappingCallbackCount == 1); vimExecute("call <SNR>1_sayhello()"); }; MU_TEST(test_simple_unmap) { vimExecute("imap jj <Esc>"); mu_check(mappingCallbackCount == 1); vimExecute("iunmap jj"); mu_check(unmappingCallbackCount == 1); mu_check(strcmp("jj", lastUnmapKeys) == 0); }; MU_TEST(test_map_clear) { // vimExecute("inoremap jj <Esc>"); // // mu_check(mappingCallbackCount == 1); vimExecute("mapclear"); mu_check(lastUnmapKeys == NULL); mu_check(unmappingCallbackCount == 1); }; MU_TEST_SUITE(test_suite) { MU_SUITE_CONFIGURE(&test_setup, &test_teardown); MU_RUN_TEST(test_simple_mapping); MU_RUN_TEST(test_map_same_keys_multiple_modes); MU_RUN_TEST(test_lhs_termcode); MU_RUN_TEST(test_map_same_keys); MU_RUN_TEST(test_sid_resolution); MU_RUN_TEST(test_simple_unmap); MU_RUN_TEST(test_map_clear); } int main(int argc, char **argv) { vimInit(argc, argv); vimSetInputMapCallback(&onMap); vimSetInputUnmapCallback(&onUnmap); vimSetMessageCallback(&onMessage); win_setwidth(5); win_setheight(100); vimBufferOpen("collateral/testfile.txt", 1, 0); MU_RUN_SUITE(test_suite); MU_REPORT(); return minunit_status; }
1,568
679
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sd.hxx" #include "TextLogger.hxx" #include "EditWindow.hxx" #include <vos/mutex.hxx> #include <vcl/svapp.hxx> namespace sd { namespace notes { TextLogger* TextLogger::spInstance = NULL; TextLogger& TextLogger::Instance (void) { if (spInstance == NULL) { ::vos::OGuard aGuard (::Application::GetSolarMutex()); if (spInstance == NULL) spInstance = new TextLogger (); } return *spInstance; } TextLogger::TextLogger (void) : mpEditWindow (NULL) { } void TextLogger::AppendText (const char* sText) { OSL_TRACE (sText); if (mpEditWindow != NULL) mpEditWindow->InsertText (UniString::CreateFromAscii(sText)); } void TextLogger::AppendText (const String& sText) { ByteString s(sText, RTL_TEXTENCODING_ISO_8859_1); OSL_TRACE (s.GetBuffer()); if (mpEditWindow != NULL) mpEditWindow->InsertText (sText); } void TextLogger::AppendNumber (long int nValue) { AppendText (String::CreateFromInt32(nValue)); } void TextLogger::ConnectToEditWindow (EditWindow* pEditWindow) { if (mpEditWindow != pEditWindow) { if (pEditWindow != NULL) pEditWindow->AddEventListener( LINK(this, TextLogger, WindowEventHandler)); else mpEditWindow->RemoveEventListener( LINK(this, TextLogger, WindowEventHandler)); mpEditWindow = pEditWindow; } } IMPL_LINK(TextLogger, WindowEventHandler, VclWindowEvent*, pEvent) { if (pEvent != NULL) { DBG_ASSERT(static_cast<VclWindowEvent*>(pEvent)->GetWindow() == mpEditWindow, "TextLogger: received event from unknown window"); switch (pEvent->GetId()) { case VCLEVENT_WINDOW_CLOSE: case VCLEVENT_OBJECT_DYING: mpEditWindow = NULL; break; } } return sal_True; } } } // end of namespace ::sd::notes
1,113
24,939
#!/usr/bin/env python3 import os import re import subprocess from pathlib import Path from typing import Optional # Security: No third-party dependencies here! if __name__ == "__main__": ref = os.environ["GITHUB_REF"] branch: Optional[str] = None tag: Optional[str] = None if ref.startswith("refs/heads/"): branch = ref.replace("refs/heads/", "") elif ref.startswith("refs/tags/"): tag = ref.replace("refs/tags/", "") else: raise AssertionError # Upload binaries (be it release or snapshot) if tag: # remove "v" prefix from version tags. upload_dir = re.sub(r"^v([\d.]+)$", r"\1", tag) else: upload_dir = f"branches/{branch}" subprocess.check_call([ "aws", "s3", "cp", "--acl", "public-read", f"./release/dist/", f"s3://snapshots.mitmproxy.org/{upload_dir}/", "--recursive", ]) # Upload releases to PyPI if tag: whl, = Path("release/dist/").glob('mitmproxy-*-py3-none-any.whl') subprocess.check_call(["twine", "upload", whl]) # Upload dev docs if branch == "main" or branch == "actions-hardening": # FIXME remove subprocess.check_call([ "aws", "configure", "set", "preview.cloudfront", "true" ]) subprocess.check_call([ "aws", "s3", "sync", "--delete", "--acl", "public-read", "docs/public", "s3://docs.mitmproxy.org/dev" ]) subprocess.check_call([ "aws", "cloudfront", "create-invalidation", "--distribution-id", "E1TH3USJHFQZ5Q", "--paths", "/dev/*" ])
835
3,897
<reponame>adelcrosge1/mbed-os<filename>targets/TARGET_Cypress/TARGET_PSOC6/mtb-hal-cat1/source/triggers/cyhal_triggers_psoc6_02.c /***************************************************************************//** * \file cyhal_triggers_psoc6_02.c * * \brief * PSoC6_02 family HAL triggers header * * \note * Generator version: 1.6.0.453 * ******************************************************************************** * \copyright * Copyright 2016-2021 Cypress Semiconductor Corporation * SPDX-License-Identifier: Apache-2.0 * * 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 "cy_device_headers.h" #include "cyhal_hw_types.h" #ifdef CY_DEVICE_PSOC6A2M #include "triggers/cyhal_triggers_psoc6_02.h" const uint16_t cyhal_sources_per_mux[17] = { 87, 86, 135, 135, 223, 251, 27, 3, 127, 127, 12, 14, 1, 2, 5, 8, 8, }; const bool cyhal_is_mux_1to1[17] = { false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, }; const cyhal_source_t cyhal_mux0_sources[87] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT7, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT7, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH8, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH9, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH10, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH11, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW11, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT0, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT1, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT2, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT3, CYHAL_TRIGGER_PERI_TR_IO_INPUT0, CYHAL_TRIGGER_PERI_TR_IO_INPUT1, CYHAL_TRIGGER_PERI_TR_IO_INPUT2, CYHAL_TRIGGER_PERI_TR_IO_INPUT3, CYHAL_TRIGGER_PERI_TR_IO_INPUT4, CYHAL_TRIGGER_PERI_TR_IO_INPUT5, CYHAL_TRIGGER_PERI_TR_IO_INPUT6, CYHAL_TRIGGER_PERI_TR_IO_INPUT7, CYHAL_TRIGGER_PERI_TR_IO_INPUT8, CYHAL_TRIGGER_PERI_TR_IO_INPUT9, CYHAL_TRIGGER_PERI_TR_IO_INPUT10, CYHAL_TRIGGER_PERI_TR_IO_INPUT11, CYHAL_TRIGGER_PERI_TR_IO_INPUT12, CYHAL_TRIGGER_PERI_TR_IO_INPUT13, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT0, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT1, CYHAL_TRIGGER_CPUSS_TR_FAULT0, CYHAL_TRIGGER_CPUSS_TR_FAULT1, }; const cyhal_source_t cyhal_mux1_sources[86] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT7, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT7, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH12, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH13, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH14, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH15, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH16, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH17, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH18, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH19, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH20, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH21, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH22, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW23, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH23, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW23, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT0, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT1, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT2, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT3, CYHAL_TRIGGER_CSD_TR_ADC_DONE, CYHAL_TRIGGER_PERI_TR_IO_INPUT14, CYHAL_TRIGGER_PERI_TR_IO_INPUT15, CYHAL_TRIGGER_PERI_TR_IO_INPUT16, CYHAL_TRIGGER_PERI_TR_IO_INPUT17, CYHAL_TRIGGER_PERI_TR_IO_INPUT18, CYHAL_TRIGGER_PERI_TR_IO_INPUT19, CYHAL_TRIGGER_PERI_TR_IO_INPUT20, CYHAL_TRIGGER_PERI_TR_IO_INPUT21, CYHAL_TRIGGER_PERI_TR_IO_INPUT22, CYHAL_TRIGGER_PERI_TR_IO_INPUT23, CYHAL_TRIGGER_PERI_TR_IO_INPUT24, CYHAL_TRIGGER_PERI_TR_IO_INPUT25, CYHAL_TRIGGER_PERI_TR_IO_INPUT26, CYHAL_TRIGGER_PERI_TR_IO_INPUT27, CYHAL_TRIGGER_LPCOMP_DSI_COMP0, CYHAL_TRIGGER_LPCOMP_DSI_COMP1, }; const cyhal_source_t cyhal_mux2_sources[135] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT7, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW7, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT0, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT1, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT2, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT3, CYHAL_TRIGGER_SCB0_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB0_TR_TX_REQ, CYHAL_TRIGGER_SCB0_TR_RX_REQ, CYHAL_TRIGGER_SCB1_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB1_TR_TX_REQ, CYHAL_TRIGGER_SCB1_TR_RX_REQ, CYHAL_TRIGGER_SCB2_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB2_TR_TX_REQ, CYHAL_TRIGGER_SCB2_TR_RX_REQ, CYHAL_TRIGGER_SCB3_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB3_TR_TX_REQ, CYHAL_TRIGGER_SCB3_TR_RX_REQ, CYHAL_TRIGGER_SCB4_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB4_TR_TX_REQ, CYHAL_TRIGGER_SCB4_TR_RX_REQ, CYHAL_TRIGGER_SCB5_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB5_TR_TX_REQ, CYHAL_TRIGGER_SCB5_TR_RX_REQ, CYHAL_TRIGGER_SCB6_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB6_TR_TX_REQ, CYHAL_TRIGGER_SCB6_TR_RX_REQ, CYHAL_TRIGGER_SCB7_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB7_TR_TX_REQ, CYHAL_TRIGGER_SCB7_TR_RX_REQ, CYHAL_TRIGGER_SCB8_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB8_TR_TX_REQ, CYHAL_TRIGGER_SCB8_TR_RX_REQ, CYHAL_TRIGGER_SCB9_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB9_TR_TX_REQ, CYHAL_TRIGGER_SCB9_TR_RX_REQ, CYHAL_TRIGGER_SCB10_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB10_TR_TX_REQ, CYHAL_TRIGGER_SCB10_TR_RX_REQ, CYHAL_TRIGGER_SCB11_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB11_TR_TX_REQ, CYHAL_TRIGGER_SCB11_TR_RX_REQ, CYHAL_TRIGGER_SCB12_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB12_TR_TX_REQ, CYHAL_TRIGGER_SCB12_TR_RX_REQ, CYHAL_TRIGGER_SMIF_TR_TX_REQ, CYHAL_TRIGGER_SMIF_TR_RX_REQ, CYHAL_TRIGGER_USB_DMA_REQ0, CYHAL_TRIGGER_USB_DMA_REQ1, CYHAL_TRIGGER_USB_DMA_REQ2, CYHAL_TRIGGER_USB_DMA_REQ3, CYHAL_TRIGGER_USB_DMA_REQ4, CYHAL_TRIGGER_USB_DMA_REQ5, CYHAL_TRIGGER_USB_DMA_REQ6, CYHAL_TRIGGER_USB_DMA_REQ7, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_RX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_PDM_RX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_RX_REQ, CYHAL_TRIGGER_PASS_TR_SAR_OUT, CYHAL_TRIGGER_CSD_DSI_SENSE_OUT, CYHAL_TRIGGER_PERI_TR_IO_INPUT0, CYHAL_TRIGGER_PERI_TR_IO_INPUT1, CYHAL_TRIGGER_PERI_TR_IO_INPUT2, CYHAL_TRIGGER_PERI_TR_IO_INPUT3, CYHAL_TRIGGER_PERI_TR_IO_INPUT4, CYHAL_TRIGGER_PERI_TR_IO_INPUT5, CYHAL_TRIGGER_PERI_TR_IO_INPUT6, CYHAL_TRIGGER_PERI_TR_IO_INPUT7, CYHAL_TRIGGER_PERI_TR_IO_INPUT8, CYHAL_TRIGGER_PERI_TR_IO_INPUT9, CYHAL_TRIGGER_PERI_TR_IO_INPUT10, CYHAL_TRIGGER_PERI_TR_IO_INPUT11, CYHAL_TRIGGER_PERI_TR_IO_INPUT12, CYHAL_TRIGGER_PERI_TR_IO_INPUT13, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT0, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT1, CYHAL_TRIGGER_LPCOMP_DSI_COMP0, CYHAL_TRIGGER_LPCOMP_DSI_COMP1, }; const cyhal_source_t cyhal_mux3_sources[135] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT7, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW7, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT0, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT1, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT2, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT3, CYHAL_TRIGGER_SCB0_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB0_TR_TX_REQ, CYHAL_TRIGGER_SCB0_TR_RX_REQ, CYHAL_TRIGGER_SCB1_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB1_TR_TX_REQ, CYHAL_TRIGGER_SCB1_TR_RX_REQ, CYHAL_TRIGGER_SCB2_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB2_TR_TX_REQ, CYHAL_TRIGGER_SCB2_TR_RX_REQ, CYHAL_TRIGGER_SCB3_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB3_TR_TX_REQ, CYHAL_TRIGGER_SCB3_TR_RX_REQ, CYHAL_TRIGGER_SCB4_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB4_TR_TX_REQ, CYHAL_TRIGGER_SCB4_TR_RX_REQ, CYHAL_TRIGGER_SCB5_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB5_TR_TX_REQ, CYHAL_TRIGGER_SCB5_TR_RX_REQ, CYHAL_TRIGGER_SCB6_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB6_TR_TX_REQ, CYHAL_TRIGGER_SCB6_TR_RX_REQ, CYHAL_TRIGGER_SCB7_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB7_TR_TX_REQ, CYHAL_TRIGGER_SCB7_TR_RX_REQ, CYHAL_TRIGGER_SCB8_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB8_TR_TX_REQ, CYHAL_TRIGGER_SCB8_TR_RX_REQ, CYHAL_TRIGGER_SCB9_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB9_TR_TX_REQ, CYHAL_TRIGGER_SCB9_TR_RX_REQ, CYHAL_TRIGGER_SCB10_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB10_TR_TX_REQ, CYHAL_TRIGGER_SCB10_TR_RX_REQ, CYHAL_TRIGGER_SCB11_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB11_TR_TX_REQ, CYHAL_TRIGGER_SCB11_TR_RX_REQ, CYHAL_TRIGGER_SCB12_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB12_TR_TX_REQ, CYHAL_TRIGGER_SCB12_TR_RX_REQ, CYHAL_TRIGGER_SMIF_TR_TX_REQ, CYHAL_TRIGGER_SMIF_TR_RX_REQ, CYHAL_TRIGGER_USB_DMA_REQ0, CYHAL_TRIGGER_USB_DMA_REQ1, CYHAL_TRIGGER_USB_DMA_REQ2, CYHAL_TRIGGER_USB_DMA_REQ3, CYHAL_TRIGGER_USB_DMA_REQ4, CYHAL_TRIGGER_USB_DMA_REQ5, CYHAL_TRIGGER_USB_DMA_REQ6, CYHAL_TRIGGER_USB_DMA_REQ7, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_RX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_PDM_RX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_RX_REQ, CYHAL_TRIGGER_PASS_TR_SAR_OUT, CYHAL_TRIGGER_CSD_DSI_SENSE_OUT, CYHAL_TRIGGER_PERI_TR_IO_INPUT14, CYHAL_TRIGGER_PERI_TR_IO_INPUT15, CYHAL_TRIGGER_PERI_TR_IO_INPUT16, CYHAL_TRIGGER_PERI_TR_IO_INPUT17, CYHAL_TRIGGER_PERI_TR_IO_INPUT18, CYHAL_TRIGGER_PERI_TR_IO_INPUT19, CYHAL_TRIGGER_PERI_TR_IO_INPUT20, CYHAL_TRIGGER_PERI_TR_IO_INPUT21, CYHAL_TRIGGER_PERI_TR_IO_INPUT22, CYHAL_TRIGGER_PERI_TR_IO_INPUT23, CYHAL_TRIGGER_PERI_TR_IO_INPUT24, CYHAL_TRIGGER_PERI_TR_IO_INPUT25, CYHAL_TRIGGER_PERI_TR_IO_INPUT26, CYHAL_TRIGGER_PERI_TR_IO_INPUT27, CYHAL_TRIGGER_CPUSS_TR_FAULT0, CYHAL_TRIGGER_CPUSS_TR_FAULT1, CYHAL_TRIGGER_LPCOMP_DSI_COMP0, CYHAL_TRIGGER_LPCOMP_DSI_COMP1, }; const cyhal_source_t cyhal_mux4_sources[223] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT7, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT8, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT9, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT10, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT11, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT12, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT13, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT14, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT15, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT16, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT17, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT18, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT19, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT20, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT21, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT22, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT23, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT24, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT25, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT26, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT27, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT28, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT7, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT8, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT9, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT10, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT11, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT12, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT13, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT14, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT15, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT16, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT17, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT18, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT19, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT20, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT21, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT22, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT23, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT24, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT25, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT26, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT27, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT28, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH8, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH9, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH10, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH11, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH12, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH13, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH14, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH15, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH16, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH17, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH18, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH19, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH20, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH21, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH22, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW23, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH23, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW23, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT0, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT1, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT2, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT3, CYHAL_TRIGGER_SCB0_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB0_TR_TX_REQ, CYHAL_TRIGGER_SCB0_TR_RX_REQ, CYHAL_TRIGGER_SCB1_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB1_TR_TX_REQ, CYHAL_TRIGGER_SCB1_TR_RX_REQ, CYHAL_TRIGGER_SCB2_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB2_TR_TX_REQ, CYHAL_TRIGGER_SCB2_TR_RX_REQ, CYHAL_TRIGGER_SCB3_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB3_TR_TX_REQ, CYHAL_TRIGGER_SCB3_TR_RX_REQ, CYHAL_TRIGGER_SCB4_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB4_TR_TX_REQ, CYHAL_TRIGGER_SCB4_TR_RX_REQ, CYHAL_TRIGGER_SCB5_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB5_TR_TX_REQ, CYHAL_TRIGGER_SCB5_TR_RX_REQ, CYHAL_TRIGGER_SCB6_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB6_TR_TX_REQ, CYHAL_TRIGGER_SCB6_TR_RX_REQ, CYHAL_TRIGGER_SCB7_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB7_TR_TX_REQ, CYHAL_TRIGGER_SCB7_TR_RX_REQ, CYHAL_TRIGGER_SCB8_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB8_TR_TX_REQ, CYHAL_TRIGGER_SCB8_TR_RX_REQ, CYHAL_TRIGGER_SCB9_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB9_TR_TX_REQ, CYHAL_TRIGGER_SCB9_TR_RX_REQ, CYHAL_TRIGGER_SCB10_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB10_TR_TX_REQ, CYHAL_TRIGGER_SCB10_TR_RX_REQ, CYHAL_TRIGGER_SCB11_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB11_TR_TX_REQ, CYHAL_TRIGGER_SCB11_TR_RX_REQ, CYHAL_TRIGGER_SCB12_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB12_TR_TX_REQ, CYHAL_TRIGGER_SCB12_TR_RX_REQ, CYHAL_TRIGGER_SMIF_TR_TX_REQ, CYHAL_TRIGGER_SMIF_TR_RX_REQ, CYHAL_TRIGGER_USB_DMA_REQ0, CYHAL_TRIGGER_USB_DMA_REQ1, CYHAL_TRIGGER_USB_DMA_REQ2, CYHAL_TRIGGER_USB_DMA_REQ3, CYHAL_TRIGGER_USB_DMA_REQ4, CYHAL_TRIGGER_USB_DMA_REQ5, CYHAL_TRIGGER_USB_DMA_REQ6, CYHAL_TRIGGER_USB_DMA_REQ7, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_RX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_PDM_RX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_RX_REQ, CYHAL_TRIGGER_CSD_DSI_SENSE_OUT, CYHAL_TRIGGER_CSD_DSI_SAMPLE_OUT, CYHAL_TRIGGER_CSD_TR_ADC_DONE, CYHAL_TRIGGER_PASS_TR_SAR_OUT, CYHAL_TRIGGER_CPUSS_TR_FAULT0, CYHAL_TRIGGER_CPUSS_TR_FAULT1, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT0, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT1, CYHAL_TRIGGER_LPCOMP_DSI_COMP0, CYHAL_TRIGGER_LPCOMP_DSI_COMP1, }; const cyhal_source_t cyhal_mux5_sources[251] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT7, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT8, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT9, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT10, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT11, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT12, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT13, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT14, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT15, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT16, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT17, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT18, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT19, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT20, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT21, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT22, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT23, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT24, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT25, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT26, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT27, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT28, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT0, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT1, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT2, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT3, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT4, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT5, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT6, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT7, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT8, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT9, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT10, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT11, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT12, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT13, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT14, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT15, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT16, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT17, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT18, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT19, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT20, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT21, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT22, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT23, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT24, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT25, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT26, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT27, CYHAL_TRIGGER_CPUSS_DW1_TR_OUT28, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH8, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH9, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH10, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH11, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH12, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH13, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH14, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH15, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH16, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH17, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH18, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH19, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH20, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH21, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH22, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW23, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH23, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW23, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT0, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT1, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT2, CYHAL_TRIGGER_CPUSS_DMAC_TR_OUT3, CYHAL_TRIGGER_SCB0_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB0_TR_TX_REQ, CYHAL_TRIGGER_SCB0_TR_RX_REQ, CYHAL_TRIGGER_SCB1_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB1_TR_TX_REQ, CYHAL_TRIGGER_SCB1_TR_RX_REQ, CYHAL_TRIGGER_SCB2_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB2_TR_TX_REQ, CYHAL_TRIGGER_SCB2_TR_RX_REQ, CYHAL_TRIGGER_SCB3_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB3_TR_TX_REQ, CYHAL_TRIGGER_SCB3_TR_RX_REQ, CYHAL_TRIGGER_SCB4_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB4_TR_TX_REQ, CYHAL_TRIGGER_SCB4_TR_RX_REQ, CYHAL_TRIGGER_SCB5_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB5_TR_TX_REQ, CYHAL_TRIGGER_SCB5_TR_RX_REQ, CYHAL_TRIGGER_SCB6_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB6_TR_TX_REQ, CYHAL_TRIGGER_SCB6_TR_RX_REQ, CYHAL_TRIGGER_SCB7_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB7_TR_TX_REQ, CYHAL_TRIGGER_SCB7_TR_RX_REQ, CYHAL_TRIGGER_SCB8_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB8_TR_TX_REQ, CYHAL_TRIGGER_SCB8_TR_RX_REQ, CYHAL_TRIGGER_SCB9_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB9_TR_TX_REQ, CYHAL_TRIGGER_SCB9_TR_RX_REQ, CYHAL_TRIGGER_SCB10_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB10_TR_TX_REQ, CYHAL_TRIGGER_SCB10_TR_RX_REQ, CYHAL_TRIGGER_SCB11_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB11_TR_TX_REQ, CYHAL_TRIGGER_SCB11_TR_RX_REQ, CYHAL_TRIGGER_SCB12_TR_I2C_SCL_FILTERED, CYHAL_TRIGGER_SCB12_TR_TX_REQ, CYHAL_TRIGGER_SCB12_TR_RX_REQ, CYHAL_TRIGGER_SMIF_TR_TX_REQ, CYHAL_TRIGGER_SMIF_TR_RX_REQ, CYHAL_TRIGGER_USB_DMA_REQ0, CYHAL_TRIGGER_USB_DMA_REQ1, CYHAL_TRIGGER_USB_DMA_REQ2, CYHAL_TRIGGER_USB_DMA_REQ3, CYHAL_TRIGGER_USB_DMA_REQ4, CYHAL_TRIGGER_USB_DMA_REQ5, CYHAL_TRIGGER_USB_DMA_REQ6, CYHAL_TRIGGER_USB_DMA_REQ7, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_RX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_PDM_RX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_RX_REQ, CYHAL_TRIGGER_CSD_DSI_SENSE_OUT, CYHAL_TRIGGER_CSD_DSI_SAMPLE_OUT, CYHAL_TRIGGER_CSD_TR_ADC_DONE, CYHAL_TRIGGER_PASS_TR_SAR_OUT, CYHAL_TRIGGER_PERI_TR_IO_INPUT0, CYHAL_TRIGGER_PERI_TR_IO_INPUT1, CYHAL_TRIGGER_PERI_TR_IO_INPUT2, CYHAL_TRIGGER_PERI_TR_IO_INPUT3, CYHAL_TRIGGER_PERI_TR_IO_INPUT4, CYHAL_TRIGGER_PERI_TR_IO_INPUT5, CYHAL_TRIGGER_PERI_TR_IO_INPUT6, CYHAL_TRIGGER_PERI_TR_IO_INPUT7, CYHAL_TRIGGER_PERI_TR_IO_INPUT8, CYHAL_TRIGGER_PERI_TR_IO_INPUT9, CYHAL_TRIGGER_PERI_TR_IO_INPUT10, CYHAL_TRIGGER_PERI_TR_IO_INPUT11, CYHAL_TRIGGER_PERI_TR_IO_INPUT12, CYHAL_TRIGGER_PERI_TR_IO_INPUT13, CYHAL_TRIGGER_PERI_TR_IO_INPUT14, CYHAL_TRIGGER_PERI_TR_IO_INPUT15, CYHAL_TRIGGER_PERI_TR_IO_INPUT16, CYHAL_TRIGGER_PERI_TR_IO_INPUT17, CYHAL_TRIGGER_PERI_TR_IO_INPUT18, CYHAL_TRIGGER_PERI_TR_IO_INPUT19, CYHAL_TRIGGER_PERI_TR_IO_INPUT20, CYHAL_TRIGGER_PERI_TR_IO_INPUT21, CYHAL_TRIGGER_PERI_TR_IO_INPUT22, CYHAL_TRIGGER_PERI_TR_IO_INPUT23, CYHAL_TRIGGER_PERI_TR_IO_INPUT24, CYHAL_TRIGGER_PERI_TR_IO_INPUT25, CYHAL_TRIGGER_PERI_TR_IO_INPUT26, CYHAL_TRIGGER_PERI_TR_IO_INPUT27, CYHAL_TRIGGER_CPUSS_TR_FAULT0, CYHAL_TRIGGER_CPUSS_TR_FAULT1, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT0, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT1, CYHAL_TRIGGER_LPCOMP_DSI_COMP0, CYHAL_TRIGGER_LPCOMP_DSI_COMP1, }; const cyhal_source_t cyhal_mux6_sources[27] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW7, CYHAL_TRIGGER_SMIF_TR_TX_REQ, CYHAL_TRIGGER_SMIF_TR_RX_REQ, }; const cyhal_source_t cyhal_mux7_sources[3] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT0, CYHAL_TRIGGER_CPUSS_CTI_TR_OUT1, }; const cyhal_source_t cyhal_mux8_sources[127] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH8, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH9, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH10, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH11, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH12, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH13, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH14, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH15, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH16, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH17, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH18, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH19, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH20, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH21, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH22, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW23, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH23, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW23, CYHAL_TRIGGER_PERI_TR_IO_INPUT0, CYHAL_TRIGGER_PERI_TR_IO_INPUT1, CYHAL_TRIGGER_PERI_TR_IO_INPUT2, CYHAL_TRIGGER_PERI_TR_IO_INPUT3, CYHAL_TRIGGER_PERI_TR_IO_INPUT4, CYHAL_TRIGGER_PERI_TR_IO_INPUT5, CYHAL_TRIGGER_PERI_TR_IO_INPUT6, CYHAL_TRIGGER_PERI_TR_IO_INPUT7, CYHAL_TRIGGER_PERI_TR_IO_INPUT8, CYHAL_TRIGGER_PERI_TR_IO_INPUT9, CYHAL_TRIGGER_PERI_TR_IO_INPUT10, CYHAL_TRIGGER_PERI_TR_IO_INPUT11, CYHAL_TRIGGER_PERI_TR_IO_INPUT12, CYHAL_TRIGGER_PERI_TR_IO_INPUT13, CYHAL_TRIGGER_PERI_TR_IO_INPUT14, CYHAL_TRIGGER_PERI_TR_IO_INPUT15, CYHAL_TRIGGER_PERI_TR_IO_INPUT16, CYHAL_TRIGGER_PERI_TR_IO_INPUT17, CYHAL_TRIGGER_PERI_TR_IO_INPUT18, CYHAL_TRIGGER_PERI_TR_IO_INPUT19, CYHAL_TRIGGER_PERI_TR_IO_INPUT20, CYHAL_TRIGGER_PERI_TR_IO_INPUT21, CYHAL_TRIGGER_PERI_TR_IO_INPUT22, CYHAL_TRIGGER_PERI_TR_IO_INPUT23, CYHAL_TRIGGER_PERI_TR_IO_INPUT24, CYHAL_TRIGGER_PERI_TR_IO_INPUT25, CYHAL_TRIGGER_PERI_TR_IO_INPUT26, CYHAL_TRIGGER_PERI_TR_IO_INPUT27, CYHAL_TRIGGER_LPCOMP_DSI_COMP0, CYHAL_TRIGGER_LPCOMP_DSI_COMP1, }; const cyhal_source_t cyhal_mux9_sources[127] = { CYHAL_TRIGGER_CPUSS_ZERO, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM0_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM0_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM0_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH0, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW0, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH1, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW1, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH2, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW2, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH3, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW3, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH4, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW4, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH5, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW5, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH6, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW6, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH7, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW7, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH8, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW8, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH9, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW9, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH10, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW10, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH11, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW11, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH12, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW12, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH13, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW13, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH14, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW14, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH15, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW15, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH16, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW16, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH17, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW17, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH18, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW18, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH19, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW19, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH20, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW20, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH21, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW21, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH22, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW22, CYHAL_TRIGGER_TCPWM1_TR_OVERFLOW23, CYHAL_TRIGGER_TCPWM1_TR_COMPARE_MATCH23, CYHAL_TRIGGER_TCPWM1_TR_UNDERFLOW23, CYHAL_TRIGGER_PERI_TR_IO_INPUT0, CYHAL_TRIGGER_PERI_TR_IO_INPUT1, CYHAL_TRIGGER_PERI_TR_IO_INPUT2, CYHAL_TRIGGER_PERI_TR_IO_INPUT3, CYHAL_TRIGGER_PERI_TR_IO_INPUT4, CYHAL_TRIGGER_PERI_TR_IO_INPUT5, CYHAL_TRIGGER_PERI_TR_IO_INPUT6, CYHAL_TRIGGER_PERI_TR_IO_INPUT7, CYHAL_TRIGGER_PERI_TR_IO_INPUT8, CYHAL_TRIGGER_PERI_TR_IO_INPUT9, CYHAL_TRIGGER_PERI_TR_IO_INPUT10, CYHAL_TRIGGER_PERI_TR_IO_INPUT11, CYHAL_TRIGGER_PERI_TR_IO_INPUT12, CYHAL_TRIGGER_PERI_TR_IO_INPUT13, CYHAL_TRIGGER_PERI_TR_IO_INPUT14, CYHAL_TRIGGER_PERI_TR_IO_INPUT15, CYHAL_TRIGGER_PERI_TR_IO_INPUT16, CYHAL_TRIGGER_PERI_TR_IO_INPUT17, CYHAL_TRIGGER_PERI_TR_IO_INPUT18, CYHAL_TRIGGER_PERI_TR_IO_INPUT19, CYHAL_TRIGGER_PERI_TR_IO_INPUT20, CYHAL_TRIGGER_PERI_TR_IO_INPUT21, CYHAL_TRIGGER_PERI_TR_IO_INPUT22, CYHAL_TRIGGER_PERI_TR_IO_INPUT23, CYHAL_TRIGGER_PERI_TR_IO_INPUT24, CYHAL_TRIGGER_PERI_TR_IO_INPUT25, CYHAL_TRIGGER_PERI_TR_IO_INPUT26, CYHAL_TRIGGER_PERI_TR_IO_INPUT27, CYHAL_TRIGGER_LPCOMP_DSI_COMP0, CYHAL_TRIGGER_LPCOMP_DSI_COMP1, }; const cyhal_source_t cyhal_mux10_sources[12] = { CYHAL_TRIGGER_SCB0_TR_TX_REQ, CYHAL_TRIGGER_SCB0_TR_RX_REQ, CYHAL_TRIGGER_SCB1_TR_TX_REQ, CYHAL_TRIGGER_SCB1_TR_RX_REQ, CYHAL_TRIGGER_SCB2_TR_TX_REQ, CYHAL_TRIGGER_SCB2_TR_RX_REQ, CYHAL_TRIGGER_SCB3_TR_TX_REQ, CYHAL_TRIGGER_SCB3_TR_RX_REQ, CYHAL_TRIGGER_SCB4_TR_TX_REQ, CYHAL_TRIGGER_SCB4_TR_RX_REQ, CYHAL_TRIGGER_SCB5_TR_TX_REQ, CYHAL_TRIGGER_SCB5_TR_RX_REQ, }; const cyhal_source_t cyhal_mux11_sources[14] = { CYHAL_TRIGGER_SCB6_TR_TX_REQ, CYHAL_TRIGGER_SCB6_TR_RX_REQ, CYHAL_TRIGGER_SCB7_TR_TX_REQ, CYHAL_TRIGGER_SCB7_TR_RX_REQ, CYHAL_TRIGGER_SCB8_TR_TX_REQ, CYHAL_TRIGGER_SCB8_TR_RX_REQ, CYHAL_TRIGGER_SCB9_TR_TX_REQ, CYHAL_TRIGGER_SCB9_TR_RX_REQ, CYHAL_TRIGGER_SCB10_TR_TX_REQ, CYHAL_TRIGGER_SCB10_TR_RX_REQ, CYHAL_TRIGGER_SCB11_TR_TX_REQ, CYHAL_TRIGGER_SCB11_TR_RX_REQ, CYHAL_TRIGGER_SCB12_TR_TX_REQ, CYHAL_TRIGGER_SCB12_TR_RX_REQ, }; const cyhal_source_t cyhal_mux12_sources[1] = { CYHAL_TRIGGER_PASS_TR_SAR_OUT, }; const cyhal_source_t cyhal_mux13_sources[2] = { CYHAL_TRIGGER_SMIF_TR_TX_REQ, CYHAL_TRIGGER_SMIF_TR_RX_REQ, }; const cyhal_source_t cyhal_mux14_sources[5] = { CYHAL_TRIGGER_AUDIOSS0_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_I2S_RX_REQ, CYHAL_TRIGGER_AUDIOSS0_TR_PDM_RX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_TX_REQ, CYHAL_TRIGGER_AUDIOSS1_TR_I2S_RX_REQ, }; const cyhal_source_t cyhal_mux15_sources[8] = { CYHAL_TRIGGER_USB_DMA_REQ0, CYHAL_TRIGGER_USB_DMA_REQ1, CYHAL_TRIGGER_USB_DMA_REQ2, CYHAL_TRIGGER_USB_DMA_REQ3, CYHAL_TRIGGER_USB_DMA_REQ4, CYHAL_TRIGGER_USB_DMA_REQ5, CYHAL_TRIGGER_USB_DMA_REQ6, CYHAL_TRIGGER_USB_DMA_REQ7, }; const cyhal_source_t cyhal_mux16_sources[8] = { CYHAL_TRIGGER_CPUSS_DW0_TR_OUT8, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT9, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT10, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT11, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT12, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT13, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT14, CYHAL_TRIGGER_CPUSS_DW0_TR_OUT15, }; const cyhal_source_t* cyhal_mux_to_sources[17] = { cyhal_mux0_sources, cyhal_mux1_sources, cyhal_mux2_sources, cyhal_mux3_sources, cyhal_mux4_sources, cyhal_mux5_sources, cyhal_mux6_sources, cyhal_mux7_sources, cyhal_mux8_sources, cyhal_mux9_sources, cyhal_mux10_sources, cyhal_mux11_sources, cyhal_mux12_sources, cyhal_mux13_sources, cyhal_mux14_sources, cyhal_mux15_sources, cyhal_mux16_sources, }; const uint8_t cyhal_dest_to_mux[107] = { 5, /* CYHAL_TRIGGER_CPUSS_CTI_TR_IN0 */ 5, /* CYHAL_TRIGGER_CPUSS_CTI_TR_IN1 */ 6, /* CYHAL_TRIGGER_CPUSS_DMAC_TR_IN0 */ 6, /* CYHAL_TRIGGER_CPUSS_DMAC_TR_IN1 */ 6, /* CYHAL_TRIGGER_CPUSS_DMAC_TR_IN2 */ 6, /* CYHAL_TRIGGER_CPUSS_DMAC_TR_IN3 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN0 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN1 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN2 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN3 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN4 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN5 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN6 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN7 */ 133, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN8 */ 133, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN9 */ 133, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN10 */ 133, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN11 */ 133, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN12 */ 133, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN13 */ 133, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN14 */ 133, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN15 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN16 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN17 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN18 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN19 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN20 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN21 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN22 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN23 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN24 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN25 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN26 */ 128, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN27 */ 130, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN28 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN0 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN1 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN2 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN3 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN4 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN5 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN6 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN7 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN8 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN9 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN10 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN11 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN12 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN13 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN14 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN15 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN16 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN17 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN18 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN19 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN20 */ 129, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN21 */ 131, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN22 */ 131, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN23 */ 132, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN24 */ 132, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN25 */ 132, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN26 */ 132, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN27 */ 132, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN28 */ 8, /* CYHAL_TRIGGER_CSD_DSI_START */ 9, /* CYHAL_TRIGGER_PASS_TR_SAR_IN */ 7, /* CYHAL_TRIGGER_PERI_TR_DBG_FREEZE */ 4, /* CYHAL_TRIGGER_PERI_TR_IO_OUTPUT0 */ 4, /* CYHAL_TRIGGER_PERI_TR_IO_OUTPUT1 */ 5, /* CYHAL_TRIGGER_PROFILE_TR_START */ 5, /* CYHAL_TRIGGER_PROFILE_TR_STOP */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN0 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN1 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN2 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN3 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN4 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN5 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN6 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN7 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN8 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN9 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN10 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN11 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN12 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN13 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN0 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN1 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN2 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN3 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN4 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN5 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN6 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN7 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN8 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN9 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN10 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN11 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN12 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN13 */ 134, /* CYHAL_TRIGGER_USB_DMA_BURSTEND0 */ 134, /* CYHAL_TRIGGER_USB_DMA_BURSTEND1 */ 134, /* CYHAL_TRIGGER_USB_DMA_BURSTEND2 */ 134, /* CYHAL_TRIGGER_USB_DMA_BURSTEND3 */ 134, /* CYHAL_TRIGGER_USB_DMA_BURSTEND4 */ 134, /* CYHAL_TRIGGER_USB_DMA_BURSTEND5 */ 134, /* CYHAL_TRIGGER_USB_DMA_BURSTEND6 */ 134, /* CYHAL_TRIGGER_USB_DMA_BURSTEND7 */ }; const uint8_t cyhal_mux_dest_index[107] = { 0, /* CYHAL_TRIGGER_CPUSS_CTI_TR_IN0 */ 1, /* CYHAL_TRIGGER_CPUSS_CTI_TR_IN1 */ 0, /* CYHAL_TRIGGER_CPUSS_DMAC_TR_IN0 */ 1, /* CYHAL_TRIGGER_CPUSS_DMAC_TR_IN1 */ 2, /* CYHAL_TRIGGER_CPUSS_DMAC_TR_IN2 */ 3, /* CYHAL_TRIGGER_CPUSS_DMAC_TR_IN3 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN0 */ 1, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN1 */ 2, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN2 */ 3, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN3 */ 4, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN4 */ 5, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN5 */ 6, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN6 */ 7, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN7 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN8 */ 1, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN9 */ 2, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN10 */ 3, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN11 */ 4, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN12 */ 5, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN13 */ 6, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN14 */ 7, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN15 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN16 */ 1, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN17 */ 2, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN18 */ 3, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN19 */ 4, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN20 */ 5, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN21 */ 6, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN22 */ 7, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN23 */ 8, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN24 */ 9, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN25 */ 10, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN26 */ 11, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN27 */ 0, /* CYHAL_TRIGGER_CPUSS_DW0_TR_IN28 */ 0, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN0 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN1 */ 2, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN2 */ 3, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN3 */ 4, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN4 */ 5, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN5 */ 6, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN6 */ 7, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN7 */ 0, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN8 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN9 */ 2, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN10 */ 3, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN11 */ 4, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN12 */ 5, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN13 */ 6, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN14 */ 7, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN15 */ 8, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN16 */ 9, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN17 */ 10, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN18 */ 11, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN19 */ 12, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN20 */ 13, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN21 */ 0, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN22 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN23 */ 0, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN24 */ 1, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN25 */ 2, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN26 */ 3, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN27 */ 4, /* CYHAL_TRIGGER_CPUSS_DW1_TR_IN28 */ 0, /* CYHAL_TRIGGER_CSD_DSI_START */ 0, /* CYHAL_TRIGGER_PASS_TR_SAR_IN */ 0, /* CYHAL_TRIGGER_PERI_TR_DBG_FREEZE */ 0, /* CYHAL_TRIGGER_PERI_TR_IO_OUTPUT0 */ 1, /* CYHAL_TRIGGER_PERI_TR_IO_OUTPUT1 */ 2, /* CYHAL_TRIGGER_PROFILE_TR_START */ 3, /* CYHAL_TRIGGER_PROFILE_TR_STOP */ 0, /* CYHAL_TRIGGER_TCPWM0_TR_IN0 */ 1, /* CYHAL_TRIGGER_TCPWM0_TR_IN1 */ 2, /* CYHAL_TRIGGER_TCPWM0_TR_IN2 */ 3, /* CYHAL_TRIGGER_TCPWM0_TR_IN3 */ 4, /* CYHAL_TRIGGER_TCPWM0_TR_IN4 */ 5, /* CYHAL_TRIGGER_TCPWM0_TR_IN5 */ 6, /* CYHAL_TRIGGER_TCPWM0_TR_IN6 */ 7, /* CYHAL_TRIGGER_TCPWM0_TR_IN7 */ 8, /* CYHAL_TRIGGER_TCPWM0_TR_IN8 */ 9, /* CYHAL_TRIGGER_TCPWM0_TR_IN9 */ 10, /* CYHAL_TRIGGER_TCPWM0_TR_IN10 */ 11, /* CYHAL_TRIGGER_TCPWM0_TR_IN11 */ 12, /* CYHAL_TRIGGER_TCPWM0_TR_IN12 */ 13, /* CYHAL_TRIGGER_TCPWM0_TR_IN13 */ 0, /* CYHAL_TRIGGER_TCPWM1_TR_IN0 */ 1, /* CYHAL_TRIGGER_TCPWM1_TR_IN1 */ 2, /* CYHAL_TRIGGER_TCPWM1_TR_IN2 */ 3, /* CYHAL_TRIGGER_TCPWM1_TR_IN3 */ 4, /* CYHAL_TRIGGER_TCPWM1_TR_IN4 */ 5, /* CYHAL_TRIGGER_TCPWM1_TR_IN5 */ 6, /* CYHAL_TRIGGER_TCPWM1_TR_IN6 */ 7, /* CYHAL_TRIGGER_TCPWM1_TR_IN7 */ 8, /* CYHAL_TRIGGER_TCPWM1_TR_IN8 */ 9, /* CYHAL_TRIGGER_TCPWM1_TR_IN9 */ 10, /* CYHAL_TRIGGER_TCPWM1_TR_IN10 */ 11, /* CYHAL_TRIGGER_TCPWM1_TR_IN11 */ 12, /* CYHAL_TRIGGER_TCPWM1_TR_IN12 */ 13, /* CYHAL_TRIGGER_TCPWM1_TR_IN13 */ 0, /* CYHAL_TRIGGER_USB_DMA_BURSTEND0 */ 1, /* CYHAL_TRIGGER_USB_DMA_BURSTEND1 */ 2, /* CYHAL_TRIGGER_USB_DMA_BURSTEND2 */ 3, /* CYHAL_TRIGGER_USB_DMA_BURSTEND3 */ 4, /* CYHAL_TRIGGER_USB_DMA_BURSTEND4 */ 5, /* CYHAL_TRIGGER_USB_DMA_BURSTEND5 */ 6, /* CYHAL_TRIGGER_USB_DMA_BURSTEND6 */ 7, /* CYHAL_TRIGGER_USB_DMA_BURSTEND7 */ }; #endif /* CY_DEVICE_PSOC6A2M */
37,301
589
<filename>inspectit.shared.cs/src/main/java/rocks/inspectit/shared/cs/ci/sensor/method/impl/InvocationSequenceSensorConfig.java package rocks.inspectit.shared.cs.ci.sensor.method.impl; import javax.xml.bind.annotation.XmlRootElement; import rocks.inspectit.shared.all.instrumentation.config.PriorityEnum; import rocks.inspectit.shared.cs.ci.sensor.StringConstraintSensorConfig; import rocks.inspectit.shared.cs.ci.sensor.method.IMethodSensorConfig; /** * Invocation sequence sensor configuration. * * @author <NAME> * */ @XmlRootElement(name = "invocation-sequence-sensor-config") public class InvocationSequenceSensorConfig extends StringConstraintSensorConfig implements IMethodSensorConfig { /** * Sensor name. */ public static final String SENSOR_NAME = "Invocation Sequence Sensor"; /** * Implementing class name. */ public static final String CLASS_NAME = "rocks.inspectit.agent.java.sensor.method.invocationsequence.InvocationSequenceSensor"; /** * No-args constructor. */ public InvocationSequenceSensorConfig() { super(100); } /** * {@inheritDoc} */ @Override public String getName() { return SENSOR_NAME; } /** * {@inheritDoc} */ @Override public String getClassName() { return CLASS_NAME; } /** * {@inheritDoc} */ @Override public PriorityEnum getPriority() { return PriorityEnum.INVOC; } /** * {@inheritDoc} */ @Override public boolean isAdvanced() { return true; } }
509
988
<filename>platform/keyring.impl/src/org/netbeans/modules/keyring/kde/CommonKWalletProvider.java /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.netbeans.modules.keyring.kde; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.modules.keyring.impl.KeyringSupport; import org.netbeans.spi.keyring.KeyringProvider; /** * * @author psychollek, ynov */ class CommonKWalletProvider implements KeyringProvider{ private static final Logger logger = Logger.getLogger(CommonKWalletProvider.class.getName()); private static final char[] defaultLocalWallet = "kdewallet".toCharArray(); private char[] handler = "0".toCharArray(); private boolean timeoutHappened = false; private final char[] appName; private final String kwalletVersion; private final String pathVersion; CommonKWalletProvider(String kwalletVersion, String pathVersion) { assert kwalletVersion != null; assert pathVersion != null; this.kwalletVersion = kwalletVersion; this.pathVersion = pathVersion; this.appName = KeyringSupport.getAppName().toCharArray(); } @Override public boolean enabled(){ if (Boolean.getBoolean("netbeans.keyring.no.native")) { logger.fine("native keyring integration disabled"); return false; } CommandResult result = runCommand("isEnabled"); if(new String(result.retVal).equals("true")) { return updateHandler(); } return false; }; @Override public char[] read(String key){ if (updateHandler()){ CommandResult result = runCommand("readPassword", handler, appName, key.toCharArray(), appName); if (result.exitCode != 0){ warning("read action returned not 0 exitCode"); } return result.retVal.length > 0 ? result.retVal : null; } return null; //throw new KwalletException("read"); }; @Override public void save(String key, char[] password, String description){ //description is forgoten ! kdewallet dosen't have any facility to store //it by default and I don't want to do it by adding new fields to kwallet if (updateHandler()){ CommandResult result = runCommand("writePassword", handler , appName , key.toCharArray(), password , appName); if (result.exitCode != 0 || (new String(result.retVal)).equals("-1")){ warning("save action failed"); } return; } //throw new KwalletException("save"); }; @Override public void delete(String key){ if (updateHandler()){ CommandResult result = runCommand("removeEntry" ,handler, appName, key.toCharArray() , appName); if (result.exitCode != 0 || (new String(result.retVal)).equals("-1")){ warning("delete action failed"); } return; } //throw new KwalletException("delete"); }; private boolean updateHandler(){ if(timeoutHappened) { return false; } handler = new String(handler).equals("")? "0".toCharArray() : handler; CommandResult result = runCommand("isOpen",handler); if(new String(result.retVal).equals("true")){ return true; } char[] localWallet = defaultLocalWallet; result = runCommand("localWallet"); if(result.exitCode == 0) { localWallet = result.retVal; } if(new String(localWallet).contains(".service")) { //Temporary workaround for the bug in kdelibs/kdeui/util/kwallet.cpp //The bug was fixed http://svn.reviewboard.kde.org/r/5885/diff/ //but many people currently use buggy kwallet return false; } result = runCommand("open", localWallet , "0".toCharArray(), appName); if(result.exitCode == 2) { warning("time out happened while accessing KWallet"); //don't try to open KWallet anymore until bug https://bugs.kde.org/show_bug.cgi?id=259229 is fixed timeoutHappened = true; return false; } if(result.exitCode != 0 || new String(result.retVal).equals("-1")) { warning("failed to access KWallet"); return false; } handler = result.retVal; return true; } private CommandResult runCommand(String command,char[]... commandArgs) { String[] argv = new String[commandArgs.length+4]; argv[0] = "qdbus"; argv[1] = "org.kde.kwalletd" + kwalletVersion; // NOI18N argv[2] = "/modules/kwalletd" + pathVersion; // NOI18N argv[3] = "org.kde.KWallet."+command; for (int i = 0; i < commandArgs.length; i++) { //unfortunatelly I cannot pass char[] to the exec in any way - so this poses a security issue with passwords in String() ! //TODO: find a way to avoid changing char[] into String argv[i+4] = new String(commandArgs[i]); } Runtime rt = Runtime.getRuntime(); String retVal = ""; String errVal = ""; int exitCode = 0; try { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "executing {0}", Arrays.toString(argv)); } Process pr = rt.exec(argv); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line; while((line = input.readLine()) != null) { if (!retVal.equals("")){ retVal = retVal.concat("\n"); } retVal = retVal.concat(line); } input.close(); input = new BufferedReader(new InputStreamReader(pr.getErrorStream())); while((line = input.readLine()) != null) { if (!errVal.equals("")){ errVal = errVal.concat("\n"); } errVal = errVal.concat(line); } input.close(); exitCode = pr.waitFor(); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "application exit with code {0} for commandString: {1}; errVal: {2}", new Object[]{exitCode, Arrays.toString(argv), errVal}); } } catch (InterruptedException ex) { logger.log(Level.FINE, "exception thrown while invoking the command \""+Arrays.toString(argv)+"\"", ex); } catch (IOException ex) { logger.log(Level.FINE, "exception thrown while invoking the command \""+Arrays.toString(argv)+"\"", ex); } return new CommandResult(exitCode, retVal.trim().toCharArray(), errVal.trim()); } private void warning(String descr) { logger.log(Level.WARNING, "Something went wrong: {0}", descr); } @Override public String toString() { return "CommonKWalletProvider{" + "kwalletVersion=" + kwalletVersion + ", pathVersion=" + pathVersion + '}'; // NOI18N } private class CommandResult { private int exitCode; private char[] retVal; private String errVal; public CommandResult(int exitCode, char[] retVal, String errVal) { this.exitCode = exitCode; this.retVal = retVal; this.errVal = errVal; } } }
3,573
2,054
<reponame>w136111526/zqcnn<gh_stars>1000+ #ifndef _ZQ_CNN_TENSOR_4D_H_ #define _ZQ_CNN_TENSOR_4D_H_ #pragma once #include "ZQ_CNN_CompileConfig.h" #include <string.h> #include <stdlib.h> #include <vector> namespace ZQ { class ZQ_CNN_Tensor4D { public: enum ALIGN_TYPE { ALIGN_0 = 0, ALIGN_128bit = ALIGN_0 + 1, ALIGN_256bit = ALIGN_128bit + 1 }; public: virtual ~ZQ_CNN_Tensor4D() {} float* const GetFirstPixelPtr() { return firstPixelData; } const float* GetFirstPixelPtr() const { return firstPixelData; } void SetShape(int in_N, int in_C, int in_H, int in_W) { shape_nchw[0] = in_N; shape_nchw[1] = in_C; shape_nchw[2] = in_H; shape_nchw[3] = in_W; } void GetShape(int& out_N, int& out_C, int& out_H, int& out_W) const { out_N = shape_nchw[0]; out_C = shape_nchw[1]; out_H = shape_nchw[2]; out_W = shape_nchw[3]; } const int GetN() const { return N; } const int GetH() const { return H; } const int GetW() const { return W; } const int GetC() const { return C; } const int GetBorderH() const { return borderH; } const int GetBorderW() const { return borderW; } const int GetPixelStep() const { return pixelStep; } const int GetWidthStep() const { return widthStep; } const int GetSliceStep() const { return sliceStep; } ALIGN_TYPE GetAlignType() const { return align_type; } virtual bool Padding(int padW, int padH, int mode) = 0; virtual bool ChangeSize(int N, int H, int W, int C, int borderW, int borderH) = 0; virtual void ShrinkToFit() = 0; virtual bool IsBorderEnabled() const = 0; virtual bool ROI(ZQ_CNN_Tensor4D& dst, int off_x, int off_y, int width, int height, int dst_borderH, int dst_borderW) const { if (off_x < 0 || off_y < 0 || off_x + width > W || off_y + height > H) return false; if (!dst.ChangeSize(N, height, width, C, dst_borderH, dst_borderW)) return false; int dstWidthStep = dst.GetWidthStep(); int dstPixelStep = dst.GetPixelStep(); int dstSliceStep = dst.GetSliceStep(); int align_mode = __min(GetAlignType(), dst.GetAlignType()); const float* src_slice_ptr = GetFirstPixelPtr() + off_y * widthStep + off_x*pixelStep; float* dst_slice_ptr = dst.GetFirstPixelPtr(); for (int n = 0; n < N; n++) { const float* src_row_ptr = src_slice_ptr; float* dst_row_ptr = dst_slice_ptr; for (int h = 0; h < height; h++) { const float* src_pix_ptr = src_row_ptr; float* dst_pix_ptr = dst_row_ptr; for (int w = 0; w < width; w++) { memcpy(dst_pix_ptr, src_pix_ptr, sizeof(float)*C); if (C < dstPixelStep) memset(dst_pix_ptr + C, 0, sizeof(float)*(dstPixelStep - C)); src_pix_ptr += pixelStep; dst_pix_ptr += dstPixelStep; } src_row_ptr += widthStep; dst_row_ptr += dstWidthStep; } src_slice_ptr += sliceStep; dst_slice_ptr += dstSliceStep; } dst_slice_ptr = dst.GetFirstPixelPtr(); for (int n = 0; n < N; n++, dst_slice_ptr += dstSliceStep) { if (dst_borderH > 0) { memset(dst_slice_ptr - dstPixelStep*dst_borderW - dstWidthStep*dst_borderH, 0, sizeof(float)*dstWidthStep*dst_borderH); memset(dst_slice_ptr - dstPixelStep*dst_borderW + dstWidthStep*height, 0, sizeof(float)*dstWidthStep*dst_borderH); } if (dst_borderW > 0) { for (int h = 0; h < dst_borderH; h++) { memset(dst_slice_ptr - dstPixelStep*dst_borderW + dstWidthStep*h, 0, sizeof(float)*dstPixelStep*dst_borderW); memset(dst_slice_ptr - dstPixelStep*(dst_borderW << 1) + dstWidthStep*(h + 1), 0, sizeof(float)*dstPixelStep*dst_borderW); } } } return true; } virtual bool ConvertFromCompactNCHW(const float* data, int N, int C, int H, int W, int borderW = 0, int borderH = 0) { if (data == 0 || !ChangeSize(N, H, W, C, borderW, borderH)) return false; memset(rawData, 0, sizeof(float)*N*sliceStep); int CHW = C*H*W; int HW = H*W; for (int n = 0; n < N; n++) { for (int c = 0; c < C; c++) { for (int h = 0; h < H; h++) { for (int w = 0; w < W; w++) { firstPixelData[n*sliceStep + h*widthStep + w*pixelStep + c] = data[n*CHW + c*HW + h*W + w]; } } } } return true; } virtual void ConvertToCompactNCHW(float* data) const { int CHW = C*H*W; int HW = H*W; for (int n = 0; n < N; n++) { for (int c = 0; c < C; c++) { for (int h = 0; h < H; h++) { for (int w = 0; w < W; w++) { data[n*CHW + c*HW + h*W + w] = firstPixelData[n*sliceStep + h*widthStep + w*pixelStep + c]; } } } } } virtual bool CopyData(const ZQ_CNN_Tensor4D& other) { if (!ChangeSize(other.GetN(), other.GetH(), other.GetW(), other.GetC(), other.GetBorderW(), other.GetBorderH())) return false; Reset(); for (int n = 0; n < N; n++) { for (int h = -borderH; h < H + borderH; h++) { for (int w = -borderW; w < W + borderW; w++) { memcpy(firstPixelData + n*sliceStep + h*widthStep + w*pixelStep, other.GetFirstPixelPtr() + n*other.GetSliceStep() + h*other.GetWidthStep() + w*other.GetPixelStep(), sizeof(float)*C); } } } return true; } virtual bool Tile(ZQ_CNN_Tensor4D& out, int tile_n, int tile_h, int tile_w, int tile_c) const { int out_N = N*tile_n; int out_H = H*tile_h; int out_W = W*tile_w; int out_C = C*tile_c; if (out_N <= 0 || out_H <= 0 || out_W <= 0 || out_C <= 0) return false; if (out.N != out_N || out.H != out_H || out.W != out_W || out.C != out_C) out.ChangeSize(out_N, out_H, out_W, out_C, 0, 0); const float* in_slice_ptr, *in_row_ptr, *in_pix_ptr, *in_c_ptr; float* out_slice_ptr, *out_row_ptr, *out_pix_ptr, *out_c_ptr; int n, h, w; // Tile C for (n = 0, in_slice_ptr = firstPixelData, out_slice_ptr = out.firstPixelData; n < N; n++, in_slice_ptr += sliceStep, out_slice_ptr += sliceStep) { for (h = 0, in_row_ptr = in_slice_ptr, out_row_ptr = out_slice_ptr; h < H; h++, in_row_ptr += widthStep, out_row_ptr += out.widthStep) { for (w = 0, in_pix_ptr = in_row_ptr, out_pix_ptr = out_row_ptr; w < W; w++, in_pix_ptr += pixelStep, out_pix_ptr += out.pixelStep) { in_c_ptr = in_pix_ptr; out_c_ptr = out_pix_ptr; for (int tc = 0; tc < tile_c; tc++) { memcpy(out_c_ptr, in_c_ptr, sizeof(float)*C); out_c_ptr += C; } } } } //Tile W for (n = 0, out_slice_ptr = out.firstPixelData; n < tile_n; n++, out_slice_ptr += out.sliceStep) { for (h = 0, out_row_ptr = out_slice_ptr; h < tile_h; h++, out_row_ptr += out.widthStep) { int elt_num = out.pixelStep*W; in_pix_ptr = out_row_ptr; out_pix_ptr = out_row_ptr; for (w = 1; w < tile_w; w++) { memcpy(out_pix_ptr + w*elt_num, in_pix_ptr, sizeof(float)*elt_num); } } } //Tile H for (n = 0, out_slice_ptr = out.firstPixelData; n < tile_n; n++, out_slice_ptr += out.sliceStep) { int elt_num = out.widthStep*H; in_row_ptr = out_slice_ptr; out_row_ptr = out_slice_ptr; for (h = 1; h < tile_h; h++) { memcpy(out_row_ptr + h*elt_num, in_row_ptr, sizeof(float)*elt_num); } } //Tile N int elt_num = out.sliceStep*N; out_slice_ptr = out.firstPixelData; in_slice_ptr = out_slice_ptr; for (n = 1; n < tile_n; n++) { memcpy(out_slice_ptr + n*elt_num, in_slice_ptr, sizeof(float)*elt_num); } return true; } virtual void Reset() { if (rawData) memset(rawData, 0, rawDataLen); } virtual bool ConvertFromBGR(const unsigned char* BGR_img, int _width, int _height, int _widthStep, const float mean_val = 127.5f, const float scale = 0.0078125f) { if (!ChangeSize(1, _height, _width, 3, 1, 1)) return false; //static const float mean_val = 127.5f; //static const float scale = 0.0078125f; float* cur_row = firstPixelData; const unsigned char* bgr_row = BGR_img; for (int h = 0; h < H; h++, cur_row += widthStep, bgr_row += _widthStep) { float* cur_pix = cur_row; const unsigned char* bgr_pix = bgr_row; for (int w = 0; w < W; w++, cur_pix += pixelStep, bgr_pix += 3) { cur_pix[0] = (bgr_pix[0] - mean_val)*scale; cur_pix[1] = (bgr_pix[1] - mean_val)*scale; cur_pix[2] = (bgr_pix[2] - mean_val)*scale; } } if (borderH > 0) { memset(firstPixelData - pixelStep*borderW - widthStep*borderH, 0, sizeof(float)*widthStep*borderH); memset(firstPixelData - pixelStep*borderW + widthStep*H, 0, sizeof(float)*widthStep*borderH); } if (borderW > 0) { for (int h = 0; h < H; h++) { memset(firstPixelData - pixelStep*borderW + widthStep*h, 0, sizeof(float)*pixelStep*borderW); memset(firstPixelData - pixelStep*(borderW << 1) + widthStep*(h + 1), 0, sizeof(float)*pixelStep*borderW); } } return true; } virtual bool ConvertFromGray(const unsigned char* gray_img, int _width, int _height, int _widthStep, const float mean_val = 127.5f, const float scale = 0.0078125f) { if (!ChangeSize(1, _height, _width, 1, 1, 1)) return false; //static const float mean_val = 127.5f; //static const float scale = 0.0078125f; float* cur_row = firstPixelData; const unsigned char* gray_row = gray_img; for (int h = 0; h < H; h++, cur_row += widthStep, gray_row += _widthStep) { float* cur_pix = cur_row; const unsigned char* gray_pix = gray_row; for (int w = 0; w < W; w++, cur_pix += pixelStep, gray_pix++) { cur_pix[0] = (gray_pix[0] - mean_val)*scale; } } if (borderH > 0) { memset(firstPixelData - pixelStep*borderW - widthStep*borderH, 0, sizeof(float)*widthStep*borderH); memset(firstPixelData - pixelStep*borderW + widthStep*H, 0, sizeof(float)*widthStep*borderH); } if (borderW > 0) { for (int h = 0; h < H; h++) { memset(firstPixelData - pixelStep*borderW + widthStep*h, 0, sizeof(float)*pixelStep*borderW); memset(firstPixelData - pixelStep*(borderW << 1) + widthStep*(h + 1), 0, sizeof(float)*pixelStep*borderW); } } return true; } /*image size should match*/ bool ConvertToBGR(unsigned char* BGR_img, int _width, int _height, int _widthStep, int n_id = 0) const { if (W != _width || H != _height || n_id < 0 || n_id >= N) return false; static const float scale = 127.5f; float tmp; float* cur_row = firstPixelData + n_id*sliceStep; int widthStep = GetWidthStep(); int pixelStep = GetPixelStep(); unsigned char* bgr_row = BGR_img; for (int h = 0; h < H; h++, cur_row += widthStep, bgr_row += _widthStep) { float* cur_pix = cur_row; unsigned char* bgr_pix = bgr_row; for (int w = 0; w < W; w++, cur_pix += pixelStep, bgr_pix += 3) { tmp = (cur_pix[0] + 1.0f)*scale + 0.5f; bgr_pix[0] = __min(255, __max(0, (int)tmp)); tmp = (cur_pix[1] + 1.0f)*scale + 0.5f; bgr_pix[1] = __min(255, __max(0, (int)tmp)); tmp = (cur_pix[2] + 1.0f)*scale + 0.5f; bgr_pix[2] = __min(255, __max(0, (int)tmp)); } } return true; } static bool Permute_NCHW_get_size(const int order[4], int in_N, int in_C, int in_H, int in_W, int& out_N, int& out_C, int& out_H, int& out_W) { bool check_valid = true; bool has_order_flag[4] = { false }; for (int i = 0; i < 4; i++) { if (order[i] < 0 || order[i] >= 4) { check_valid = false; break; } has_order_flag[order[i]] = true; } if (!check_valid) return false; for (int i = 0; i < 4; i++) { if (!has_order_flag[i]) { check_valid = false; break; } } if (!check_valid) return false; int old_dim[4] = { in_N,in_C,in_H,in_W }; int new_dim[4]; for (int i = 0; i < 4; i++) new_dim[i] = old_dim[order[i]]; out_N = new_dim[0]; out_C = new_dim[1]; out_H = new_dim[2]; out_W = new_dim[3]; return true; } bool Permute_NCHW(ZQ_CNN_Tensor4D& output, const int order[4], int num_threads = 1) const { int out_N, out_C, out_H, out_W; if (!Permute_NCHW_get_size(order, N, C, H, W, out_N, out_C, out_H, out_W)) return false; if (!output.ChangeSize(out_N, out_H, out_W, out_C, 0, 0)) return false; int old_steps[4] = { C*H*W,H*W,W,1 }; int new_steps[4] = { out_C*out_H*out_W, out_H*out_W, out_W,1 }; int count = old_steps[0] * N; if (count) { std::vector<float> in_buf(count); std::vector<float> out_buf(count); ConvertToCompactNCHW(&in_buf[0]); for (int i = 0; i < count; i++) { int old_idx = 0; int idx = i; for (int j = 0; j < 4; j++) { int cur_order = order[j]; old_idx += (idx / new_steps[j]) * old_steps[cur_order]; idx %= new_steps[j]; } out_buf[i] = in_buf[old_idx]; } return output.ConvertFromCompactNCHW(&out_buf[0], out_N, out_C, out_H, out_W); } return true; } static bool Flatten_NCHW_get_size(int start_axis, int end_axis, int in_N, int in_C, int in_H, int in_W, int& out_N, int& out_C, int& out_H, int& out_W) { int old_shape[4] = { in_N,in_C,in_H,in_W }; std::vector<int> shape; for (int i = 0; i < start_axis; ++i) { shape.push_back(old_shape[i]); } int flattened_dim = 1; for (int i = start_axis; i <= end_axis; i++) flattened_dim *= old_shape[i]; shape.push_back(flattened_dim); for (int i = end_axis + 1; i < 4; ++i) { shape.push_back(old_shape[i]); } while (shape.size() < 4) { shape.push_back(1); } out_N = shape[0]; out_C = shape[1]; out_H = shape[2]; out_W = shape[3]; return true; } bool Flatten_NCHW(ZQ_CNN_Tensor4D& output, int start_axis, int end_axis, int num_threads = 1) const { int old_shape[4] = { N,C,H,W }; std::vector<int> shape; for (int i = 0; i < start_axis; ++i) { shape.push_back(old_shape[i]); } int flattened_dim = 1; for (int i = start_axis; i <= end_axis; i++) flattened_dim *= old_shape[i]; shape.push_back(flattened_dim); for (int i = end_axis + 1; i < 4; ++i) { shape.push_back(old_shape[i]); } return Reshape_NCHW(output, shape); } static bool Reshape_NCHW_get_size(const std::vector<int>& shape, int in_N, int in_C, int in_H, int in_W, int& out_N, int& out_C, int& out_H, int& out_W) { if (in_N <= 0 || in_C <= 0 || in_H <= 0 || in_W <= 0) return false; int shape_dim = shape.size(); if (shape_dim > 4) return false; int old_dim[4] = { in_N, in_C, in_H, in_W }; int new_dim[4]; int count = in_N*in_C*in_H*in_W; for (int i = shape_dim; i < 4; i++) new_dim[i] = 1; int unknown_num = 0; int id = -1; for (int i = 0; i < shape_dim; i++) { if (shape[i] == 0) { new_dim[i] = old_dim[i]; } else if (shape[i] > 0) { new_dim[i] = shape[i]; } else { id = i; unknown_num++; } } if (unknown_num == 0) { out_N = new_dim[0]; out_C = new_dim[1]; out_H = new_dim[2]; out_W = new_dim[3]; return out_N*out_C*out_H*out_W == count; } else if (unknown_num == 1) { int total = count; for (int i = 0; i < 4; i++) { if (shape[i] >= 0) { if (total % new_dim[i] != 0) return false; total /= new_dim[i]; } } new_dim[id] = total; out_N = new_dim[0]; out_C = new_dim[1]; out_H = new_dim[2]; out_W = new_dim[3]; return out_N*out_C*out_H*out_W == count; } else { return false; } } bool Reshape_NCHW(ZQ_CNN_Tensor4D& output, const std::vector<int>& shape, int num_threads = 1) const { int out_N, out_C, out_H, out_W; if (!Reshape_NCHW_get_size(shape, N, C, H, W, out_N, out_C, out_H, out_W)) return false; output.ChangeSize(out_N, out_H, out_W, out_C, 0, 0); int in_HW = H*W; int in_CHW = C*in_HW; int out_HW = out_H*out_W; int out_CHW = out_C*out_HW; int idx = 0, rest, i_n, i_c, i_h, i_w; int out_SliceStep = output.GetSliceStep(); int out_WidthStep = output.GetWidthStep(); int out_PixelStep = output.GetPixelStep(); int in_SliceStep = GetSliceStep(); int in_WidthStep = GetWidthStep(); int in_PixelStep = GetPixelStep(); float* out_ptr = output.GetFirstPixelPtr(); const float* in_ptr = GetFirstPixelPtr(); float* out_slice_ptr = out_ptr; for (int nn = 0; nn < out_N; nn++) { float* out_c_ptr = out_slice_ptr; for (int cc = 0; cc < out_C; cc++) { float* out_row_ptr = out_c_ptr; for (int hh = 0; hh < out_H; hh++) { float* out_pix_ptr = out_row_ptr; for (int ww = 0; ww < out_W; ww++) { rest = idx; i_n = rest / in_CHW; rest %= in_CHW; i_c = rest / in_HW; rest %= in_HW; i_h = rest / W; i_w = rest % W; *out_pix_ptr = in_ptr[i_n*in_SliceStep + i_c + i_h*in_WidthStep + i_w*in_PixelStep]; idx++; out_pix_ptr += out_PixelStep; } out_row_ptr += out_WidthStep; } out_c_ptr++; } out_slice_ptr += out_SliceStep; } return true; } bool SaveToFile(const char* file) { int HW = H*W; int CHW = C*HW; int buf_len = N*CHW; std::vector<float> buffer(buf_len); FILE* out; #if defined(_WIN32) if (0 != fopen_s(&out, file, "w")) return false; #else out = fopen(file, "w"); if (out == 0) return false; #endif if (buf_len > 0) { ConvertToCompactNCHW(&buffer[0]); for (int n = 0; n < N; n++) { for (int h = 0; h < H; h++) { for (int w = 0; w < W; w++) { fprintf(out, "[n,h,w]=[%04d,%04d,%04d]: ", n, h, w); for (int c = 0; c < C; c++) fprintf(out, " %4d:%12.7f", c, buffer[n*CHW + c*HW + h*W + w]); fprintf(out, "\n"); } } } } fclose(out); return true; } protected: int shape_nchw[4]; int N; int W; int H; int C; int borderH; int borderW; int realHeight; int realWidth; int pixelStep; int widthStep; int sliceStep; float* firstPixelData; unsigned char* rawData; long long rawDataLen; ALIGN_TYPE align_type; }; class ZQ_CNN_Tensor4D_NHW_C_Align0 : public ZQ_CNN_Tensor4D { public: /********************* Interface functions ********************/ bool Padding(int padW, int padH, int mode) { if (padW > borderW || padH > borderH) { ZQ_CNN_Tensor4D_NHW_C_Align0 tmp; if (!tmp.ChangeSize(N, H, W, C, padW, padH)) return false; // float* tmp_slice_ptr = tmp.firstPixelData; float* cur_slice_ptr = firstPixelData; for (int n = 0; n < N; n++, tmp_slice_ptr += tmp.sliceStep, cur_slice_ptr += sliceStep) { for (int h = 0; h < tmp.borderH; h++) { memset(tmp_slice_ptr - (h + 1)*tmp.widthStep - tmp.borderW*tmp.pixelStep, 0, sizeof(float)*tmp.widthStep); memset(tmp_slice_ptr + (H + h)*tmp.widthStep - tmp.borderW*tmp.pixelStep, 0, sizeof(float)*tmp.widthStep); } float* tmp_row_ptr = tmp_slice_ptr; float* cur_row_ptr = cur_slice_ptr; for (int h = 0; h < H; h++, tmp_row_ptr += tmp.widthStep, cur_row_ptr += widthStep) { memset(tmp_row_ptr - tmp.borderW*tmp.pixelStep, 0, sizeof(float)*tmp.borderW*tmp.pixelStep); memset(tmp_row_ptr + tmp.W*pixelStep, 0, sizeof(float)*tmp.borderW*tmp.pixelStep); memcpy(tmp_row_ptr, cur_row_ptr, sizeof(float)* W*pixelStep); } } Swap(tmp); } else { float* slice_ptr = firstPixelData; for (int n = 0; n < N; n++, slice_ptr += sliceStep) { for (int h = 0; h < borderH; h++) { memset(slice_ptr - (h + 1)*widthStep - borderW*pixelStep, 0, sizeof(float)*widthStep); memset(slice_ptr + (H + h)*widthStep - borderW*pixelStep, 0, sizeof(float)*widthStep); } float* row_ptr = slice_ptr; for (int h = 0; h < H; h++, row_ptr += widthStep) { memset(row_ptr - borderW*pixelStep, 0, sizeof(float)*borderW*pixelStep); memset(row_ptr + W*pixelStep, 0, sizeof(float)*borderW*pixelStep); } } } return true; } bool ChangeSize(int dst_N, int dst_H, int dst_W, int dst_C, int dst_borderW, int dst_borderH) { if (N == dst_N && H == dst_H && W == dst_W && C == dst_C && borderW == dst_borderW && borderH == dst_borderH) return true; shape_nchw[0] = dst_N; shape_nchw[1] = dst_C; shape_nchw[2] = dst_H; shape_nchw[3] = dst_W; int dst_realW = dst_W + (dst_borderW << 1); int dst_realH = dst_H + (dst_borderH << 1); int dst_pixelStep = dst_C; int dst_widthStep = dst_pixelStep*dst_realW; int dst_sliceStep = dst_widthStep*dst_realH; int dst_tensor_raw_size = dst_sliceStep*dst_N * sizeof(float); int needed_dst_raw_len = dst_tensor_raw_size; if (dst_tensor_raw_size == 0) { free(rawData); rawData = 0; firstPixelData = 0; rawDataLen = 0; N = 0; W = 0; H = 0; C = 0; borderW = dst_borderW; borderH = dst_borderH; realWidth = 0; realHeight = 0; pixelStep = 0; widthStep = 0; sliceStep = 0; } else { if (rawDataLen != needed_dst_raw_len) { unsigned char* tmp_data = (unsigned char*)malloc(needed_dst_raw_len); if (tmp_data == 0) return false; //memset(tmp_data, 0, needed_dst_raw_len); if (rawData) free(rawData); rawData = tmp_data; } firstPixelData = (float*)rawData + dst_borderH*dst_widthStep + dst_borderW*dst_pixelStep; rawDataLen = needed_dst_raw_len; N = dst_N; W = dst_W; H = dst_H; C = dst_C; borderW = dst_borderW; borderH = dst_borderH; realHeight = dst_realH; realWidth = dst_realW; pixelStep = dst_pixelStep; widthStep = dst_widthStep; sliceStep = dst_sliceStep; } return true; } void ShrinkToFit() { ChangeSize(0, 0, 0, 0, 0, 0); } bool IsBorderEnabled() const { return true; } /********************* other functions ********************/ ZQ_CNN_Tensor4D_NHW_C_Align0() { shape_nchw[0] = 0; shape_nchw[1] = 0; shape_nchw[2] = 0; shape_nchw[3] = 0; N = 0; W = 0; H = 0; C = 0; borderW = 0; borderH = 0; realWidth = 0; realHeight = 0; pixelStep = 0; widthStep = 0; sliceStep = 0; firstPixelData = 0; rawData = 0; rawDataLen = 0; align_type = ALIGN_0; } ~ZQ_CNN_Tensor4D_NHW_C_Align0() { if (rawData) { free(rawData); rawData = 0; } } void Swap(ZQ_CNN_Tensor4D_NHW_C_Align0& other) { int tmp_shape[4]; memcpy(tmp_shape, shape_nchw, sizeof(int) * 4); memcpy(shape_nchw, other.shape_nchw, sizeof(int) * 4); memcpy(other.shape_nchw, tmp_shape, sizeof(int) * 4); int tmp_N = N; N = other.N; other.N = tmp_N; int tmp_H = H; H = other.H; other.H = tmp_H; int tmp_W = W; W = other.W; other.W = tmp_W; int tmp_C = C; C = other.C; other.C = tmp_C; int tmp_borderH = borderH; borderH = other.borderH; other.borderH = tmp_borderH; int tmp_borderW = borderW; borderW = other.borderW; other.borderW = tmp_borderW; int tmp_realHeight = realHeight; realHeight = other.realHeight; other.realHeight = tmp_realHeight; int tmp_realWidth = realWidth; realWidth = other.realWidth; other.realWidth = tmp_realWidth; int tmp_pixStep = pixelStep; pixelStep = other.pixelStep; other.pixelStep = tmp_pixStep; int tmp_widthStep = widthStep; widthStep = other.widthStep; other.widthStep = tmp_widthStep; int tmp_sliceStep = sliceStep; sliceStep = other.sliceStep; other.sliceStep = tmp_sliceStep; float* tmp_firstPixelData = firstPixelData; firstPixelData = other.firstPixelData; other.firstPixelData = tmp_firstPixelData; unsigned char* tmp_rawData = rawData; rawData = other.rawData; other.rawData = tmp_rawData; long long tmp_rawDataLen = rawDataLen; rawDataLen = other.rawDataLen; other.rawDataLen = tmp_rawDataLen; } }; } #endif
11,843
14,668
<gh_stars>1000+ // Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/test/launcher/test_results_tracker.h" #include "base/command_line.h" #include "base/files/file_util.h" #include "base/time/time.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::HasSubstr; namespace base { TEST(TestResultsTrackerTest, SaveSummaryAsJSONWithLinkInResult) { TestResultsTracker tracker; TestResult result; result.AddLink("link", "http://google.com"); TestResultsTracker::AggregateTestResult aggregate_result; aggregate_result.test_results.push_back(result); tracker.per_iteration_data_.emplace_back( TestResultsTracker::PerIterationData()); tracker.per_iteration_data_.back().results["dummy"] = aggregate_result; FilePath temp_file; CreateTemporaryFile(&temp_file); ASSERT_TRUE(tracker.SaveSummaryAsJSON(temp_file, std::vector<std::string>())); std::string content; ASSERT_TRUE(ReadFileToString(temp_file, &content)); std::string expected_content = R"raw("links":{"link":)raw" R"raw({"content":"http://google.com"}})raw"; EXPECT_TRUE(content.find(expected_content) != std::string::npos) << expected_content << " not found in " << content; } TEST(TestResultsTrackerTest, SaveSummaryAsJSONWithOutTimestampInResult) { TestResultsTracker tracker; TestResult result; result.full_name = "A.B"; TestResultsTracker::AggregateTestResult aggregate_result; aggregate_result.test_results.push_back(result); tracker.per_iteration_data_.emplace_back( TestResultsTracker::PerIterationData()); tracker.per_iteration_data_.back().results["dummy"] = aggregate_result; FilePath temp_file; CreateTemporaryFile(&temp_file); ASSERT_TRUE(tracker.SaveSummaryAsJSON(temp_file, std::vector<std::string>())); std::string content; ASSERT_TRUE(ReadFileToString(temp_file, &content)); for (auto* not_expected_content : {"thread_id", "process_num", "timestamp"}) { EXPECT_THAT(content, ::testing::Not(HasSubstr(not_expected_content))); } } TEST(TestResultsTrackerTest, SaveSummaryAsJSONWithTimestampInResult) { TestResultsTracker tracker; TestResult result; result.full_name = "A.B"; result.thread_id = 123; result.process_num = 456; result.timestamp = Time::Now(); TestResultsTracker::AggregateTestResult aggregate_result; aggregate_result.test_results.push_back(result); tracker.per_iteration_data_.emplace_back( TestResultsTracker::PerIterationData()); tracker.per_iteration_data_.back().results["dummy"] = aggregate_result; FilePath temp_file; CreateTemporaryFile(&temp_file); ASSERT_TRUE(tracker.SaveSummaryAsJSON(temp_file, std::vector<std::string>())); std::string content; ASSERT_TRUE(ReadFileToString(temp_file, &content)); EXPECT_THAT(content, HasSubstr(R"raw("thread_id":123)raw")); EXPECT_THAT(content, HasSubstr(R"raw("process_num":456)raw")); EXPECT_THAT(content, HasSubstr(R"raw("timestamp":)raw")); } } // namespace base
1,083
862
<filename>integration_tests/conftest.py import pytest import subprocess import pathlib import os import time @pytest.fixture def session(): subprocess.call(["yes | freeport 5000"], shell=True) os.environ["ROBYN_URL"] = "127.0.0.1" current_file_path = pathlib.Path(__file__).parent.resolve() base_routes = os.path.join(current_file_path, "./base_routes.py") process = subprocess.Popen(["python3", base_routes]) time.sleep(5) yield process.terminate() del os.environ["ROBYN_URL"] @pytest.fixture def global_session(): os.environ["ROBYN_URL"] = "0.0.0.0" current_file_path = pathlib.Path(__file__).parent.resolve() base_routes = os.path.join(current_file_path, "./base_routes.py") process = subprocess.Popen(["python3", base_routes]) time.sleep(1) yield process.terminate() del os.environ["ROBYN_URL"] @pytest.fixture def dev_session(): subprocess.call(["yes | freeport 5000"], shell=True) os.environ["ROBYN_URL"] = "127.0.0.1" current_file_path = pathlib.Path(__file__).parent.resolve() base_routes = os.path.join(current_file_path, "./base_routes.py") process = subprocess.Popen(["python3", base_routes, "--dev"]) time.sleep(5) yield process.terminate() del os.environ["ROBYN_URL"]
546
15,337
# Generated by Django 2.2.6 on 2019-10-21 11:40 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [("site", "0023_auto_20191007_0835")] operations = [ migrations.AddField( model_name="sitesettings", name="customer_set_password_url", field=models.CharField(blank=True, max_length=255, null=True), ) ]
177
815
#include <stdarg.h> #include <stddef.h> #include <string.h> #include "lily.h" #include "lily_alloc.h" #include "lily_opcode.h" #include "lily_parser.h" #include "lily_value.h" #include "lily_vm.h" extern lily_gc_entry *lily_gc_stopper; /* Same here: Safely escape string values for `KeyError`. */ void lily_mb_escape_add_str(lily_msgbuf *, const char *); /* Foreign functions set this as their code so that the vm will exit when they are to be returned from. */ static uint16_t foreign_code[1] = {o_vm_exit}; /* Operations called from the vm that may raise an error must set the current frame's code first. This allows parser and vm to assume that any native function's line number exists at code[-1]. to_add should be the same value added to code at the end of the branch. */ #define SAVE_LINE(to_add) \ current_frame->code = code + to_add #define INITIAL_REGISTER_COUNT 16 /*** * ____ _ * / ___| ___| |_ _ _ _ __ * \___ \ / _ \ __| | | | '_ \ * ___) | __/ |_| |_| | |_) | * |____/ \___|\__|\__,_| .__/ * |_| */ static void add_call_frame(lily_vm_state *); static void invoke_gc(lily_vm_state *); static lily_vm_state *new_vm_state(lily_raiser *raiser, int count) { lily_vm_catch_entry *catch_entry = lily_malloc(sizeof(*catch_entry)); catch_entry->prev = NULL; catch_entry->next = NULL; int i; lily_value **register_base = lily_malloc(count * sizeof(*register_base)); for (i = 0;i < count;i++) { register_base[i] = lily_malloc(sizeof(*register_base[i])); register_base[i]->flags = 0; } lily_value **register_end = register_base + count; /* Globals are stored in this frame so they outlive __main__. This allows direct calls from outside the interpreter. */ lily_call_frame *toplevel_frame = lily_malloc(sizeof(*toplevel_frame)); /* This usually holds __main__, unless something calls into the interpreter after execution is done. */ lily_call_frame *first_frame = lily_malloc(sizeof(*toplevel_frame)); toplevel_frame->start = register_base; toplevel_frame->top = register_base; toplevel_frame->register_end = register_end; toplevel_frame->code = NULL; toplevel_frame->return_target = NULL; toplevel_frame->prev = NULL; toplevel_frame->next = first_frame; first_frame->start = register_base; first_frame->top = register_base; first_frame->register_end = register_end; first_frame->code = NULL; first_frame->function = NULL; first_frame->return_target = register_base[0]; first_frame->prev = toplevel_frame; first_frame->next = NULL; lily_vm_state *vm = lily_malloc(sizeof(*vm)); vm->call_depth = 0; vm->depth_max = 100; vm->raiser = raiser; vm->catch_chain = NULL; vm->call_chain = NULL; vm->exception_value = NULL; vm->exception_cls = NULL; vm->catch_chain = catch_entry; /* The parser will enter __main__ when the time comes. */ vm->call_chain = toplevel_frame; vm->vm_buffer = lily_new_msgbuf(64); vm->register_root = register_base; return vm; } lily_vm_state *lily_new_vm_state(lily_raiser *raiser) { lily_vm_state *vm = new_vm_state(raiser, INITIAL_REGISTER_COUNT); lily_global_state *gs = lily_malloc(sizeof(*gs)); gs->regs_from_main = vm->call_chain->start; gs->class_table = NULL; gs->readonly_table = NULL; gs->class_count = 0; gs->readonly_count = 0; gs->gc_live_entries = NULL; gs->gc_spare_entries = NULL; gs->gc_live_entry_count = 0; gs->stdout_reg_spot = UINT16_MAX; gs->first_vm = vm; vm->gs = gs; return vm; } void lily_destroy_vm(lily_vm_state *vm) { lily_value **register_root = vm->register_root; lily_value *reg; int i; if (vm->catch_chain != NULL) { while (vm->catch_chain->prev) vm->catch_chain = vm->catch_chain->prev; lily_vm_catch_entry *catch_iter = vm->catch_chain; lily_vm_catch_entry *catch_next; while (catch_iter) { catch_next = catch_iter->next; lily_free(catch_iter); catch_iter = catch_next; } } int total = (int)(vm->call_chain->register_end - register_root - 1); for (i = total;i >= 0;i--) { reg = register_root[i]; lily_deref(reg); lily_free(reg); } lily_free(register_root); lily_call_frame *frame_iter = vm->call_chain; lily_call_frame *frame_next; while (frame_iter->prev) frame_iter = frame_iter->prev; while (frame_iter) { frame_next = frame_iter->next; lily_free(frame_iter); frame_iter = frame_next; } lily_free_msgbuf(vm->vm_buffer); } static void destroy_gc_entries(lily_vm_state *vm) { lily_global_state *gs = vm->gs; lily_gc_entry *gc_iter, *gc_temp; if (gs->gc_live_entry_count) { /* This function is called after the registers are gone. This walks over the remaining gc entries and blasts them just like the gc does. This is a two-stage process because the circular values may link back to each other. */ for (gc_iter = gs->gc_live_entries; gc_iter; gc_iter = gc_iter->next) { if (gc_iter->value.generic != NULL) { /* This tells value destroy to hollow the value since other circular values may use it. */ gc_iter->status = GC_SWEEP; lily_value_destroy((lily_value *)gc_iter); } } gc_iter = gs->gc_live_entries; while (gc_iter) { gc_temp = gc_iter->next; /* It's either NULL or the remnants of a value. */ lily_free(gc_iter->value.generic); lily_free(gc_iter); gc_iter = gc_temp; } } gc_iter = vm->gs->gc_spare_entries; while (gc_iter != NULL) { gc_temp = gc_iter->next; lily_free(gc_iter); gc_iter = gc_temp; } } void lily_rewind_vm(lily_vm_state *vm) { lily_vm_catch_entry *catch_iter = vm->catch_chain; lily_call_frame *call_iter = vm->call_chain; while (catch_iter->prev) catch_iter = catch_iter->prev; while (call_iter->prev) call_iter = call_iter->prev; vm->catch_chain = catch_iter; vm->exception_value = NULL; vm->exception_cls = NULL; vm->call_chain = call_iter; vm->call_depth = 0; } void lily_free_vm(lily_vm_state *vm) { /* If there are any entries left over, then do a final gc pass that will destroy the tagged values. */ if (vm->gs->gc_live_entry_count) invoke_gc(vm); lily_destroy_vm(vm); destroy_gc_entries(vm); lily_free(vm->gs->class_table); lily_free(vm->gs); lily_free(vm); } /*** * ____ ____ * / ___| / ___| * | | _ | | * | |_| | | |___ * \____| \____| * */ static void gc_mark(lily_value *); /* This is Lily's garbage collector. It runs in multiple stages: 1: Walk registers currently in use and call the mark function on any register that's interesting to the gc (speculative or tagged). 2: Walk every gc item to determine which ones are unreachable. Unreachable items need to be hollowed out unless a deref deleted them. 3: Walk registers not currently in use. If any have a value that is going to be deleted, mark the register as cleared. 4: Delete unreachable values and relink gc items. */ static void invoke_gc(lily_vm_state *vm) { /* Coroutine vm's can invoke the gc, but the gc is rooted from the vm and expands out into others. Make sure that the first one (the right one) is the one being used. */ vm = vm->gs->first_vm; /* This is (sort of) a mark-and-sweep garbage collector. This is called when a certain number of allocations have been done. Take note that values can be destroyed by deref. However, those values will have the gc_entry's value set to NULL as an indicator. */ lily_value **regs_from_main = vm->gs->regs_from_main; uint32_t total = vm->call_chain->register_end - vm->gs->regs_from_main; lily_gc_entry *gc_iter; uint32_t i; /* Stage 1: Mark interesting values in use. */ for (i = 0;i < total;i++) { lily_value *reg = regs_from_main[i]; if (reg->flags & VAL_HAS_SWEEP_FLAG) gc_mark(reg); } /* Stage 2: Delete the contents of every value that wasn't seen. */ for (gc_iter = vm->gs->gc_live_entries; gc_iter; gc_iter = gc_iter->next) { if (gc_iter->status == GC_NOT_SEEN && gc_iter->value.generic != NULL) { /* This tells value destroy to just hollow the value since it may be visited multiple times. */ gc_iter->status = GC_SWEEP; lily_value_destroy((lily_value *)gc_iter); } } uint32_t current_top = (uint32_t)(vm->call_chain->top - vm->gs->regs_from_main); /* Stage 3: If any unused register holds a gc value that's going to be deleted, flag it as clear. This prevents double frees. */ for (i = total;i < current_top;i++) { lily_value *reg = regs_from_main[i]; if (reg->flags & VAL_IS_GC_TAGGED && reg->value.gc_generic->gc_entry == lily_gc_stopper) { reg->flags = 0; } } /* Stage 4: Delete old values and relink gc items. */ i = 0; lily_gc_entry *new_live_entries = NULL; lily_gc_entry *new_spare_entries = vm->gs->gc_spare_entries; lily_gc_entry *iter_next = NULL; gc_iter = vm->gs->gc_live_entries; while (gc_iter) { iter_next = gc_iter->next; if (gc_iter->status == GC_SWEEP) { lily_free(gc_iter->value.generic); gc_iter->next = new_spare_entries; new_spare_entries = gc_iter; } else { i++; gc_iter->next = new_live_entries; gc_iter->status = GC_NOT_SEEN; new_live_entries = gc_iter; } gc_iter = iter_next; } /* Did the sweep reclaim enough objects? If not, then increase the threshold to prevent spamming sweeps when everything is alive. */ if (vm->gs->gc_threshold <= i) vm->gs->gc_threshold *= vm->gs->gc_multiplier; vm->gs->gc_live_entry_count = i; vm->gs->gc_live_entries = new_live_entries; vm->gs->gc_spare_entries = new_spare_entries; } static void list_marker(lily_value *v) { if (v->flags & VAL_IS_GC_TAGGED) { /* Only instances/enums that pass through here are tagged. */ lily_gc_entry *e = v->value.container->gc_entry; if (e->status == GC_VISITED) return; e->status = GC_VISITED; } lily_container_val *list_val = v->value.container; uint32_t i; for (i = 0;i < list_val->num_values;i++) { lily_value *elem = list_val->values[i]; if (elem->flags & VAL_HAS_SWEEP_FLAG) gc_mark(elem); } } static void hash_marker(lily_value *v) { lily_hash_val *hv = v->value.hash; int i; for (i = 0;i < hv->num_bins;i++) { lily_hash_entry *entry = hv->bins[i]; while (entry) { gc_mark(entry->record); entry = entry->next; } } } static void function_marker(lily_value *v) { if (v->flags & VAL_IS_GC_TAGGED) { lily_gc_entry *e = v->value.function->gc_entry; if (e->status == GC_VISITED) return; e->status = GC_VISITED; } lily_function_val *function_val = v->value.function; lily_value **upvalues = function_val->upvalues; int count = function_val->num_upvalues; int i; for (i = 0;i < count;i++) { lily_value *up = upvalues[i]; if (up && (up->flags & VAL_HAS_SWEEP_FLAG)) gc_mark(up); } } static void coroutine_marker(lily_value *v) { if (v->flags & VAL_IS_GC_TAGGED) { lily_gc_entry *e = v->value.function->gc_entry; if (e->status == GC_VISITED) return; e->status = GC_VISITED; } lily_coroutine_val *co_val = v->value.coroutine; lily_vm_state *co_vm = co_val->vm; lily_value **base = co_vm->register_root; int total = co_vm->call_chain->register_end - base - 1; int i; for (i = total;i >= 0;i--) { lily_value *reg = base[i]; if (reg->flags & VAL_HAS_SWEEP_FLAG) gc_mark(reg); } lily_function_val *base_function = co_val->base_function; if (base_function->upvalues) { /* If the base Function of the Coroutine has upvalues, they need to be walked through. Since the Function is never put into a register, the Coroutine's gc tag serves as its tag. */ lily_value reg; reg.flags = V_FUNCTION_BASE; reg.value.function = base_function; function_marker(&reg); } lily_value *receiver = co_val->receiver; if (receiver->flags & VAL_HAS_SWEEP_FLAG) gc_mark(receiver); } static void gc_mark(lily_value *v) { if (v->flags & (VAL_IS_GC_TAGGED | VAL_IS_GC_SPECULATIVE)) { int base = FLAGS_TO_BASE(v); if (base == V_LIST_BASE || base == V_TUPLE_BASE || base == V_INSTANCE_BASE || base == V_VARIANT_BASE) list_marker(v); else if (base == V_HASH_BASE) hash_marker(v); else if (base == V_FUNCTION_BASE) function_marker(v); else if (base == V_COROUTINE_BASE) coroutine_marker(v); } } /* This will attempt to grab a spare entry and associate it with the value given. If there are no spare entries, then a new entry is made. These entries are how the gc is able to locate values later. If the number of living gc objects is at or past the threshold, then the collector will run BEFORE the association. This is intentional, as 'value' is not guaranteed to be in a register. */ void lily_value_tag(lily_vm_state *vm, lily_value *v) { lily_global_state *gs = vm->gs; if (gs->gc_live_entry_count >= gs->gc_threshold) /* Values are rooted in __main__'s vm, but this can be called by a Coroutine vm. Make sure invoke always gets the primary vm. */ invoke_gc(gs->first_vm); lily_gc_entry *new_entry; if (gs->gc_spare_entries != NULL) { new_entry = gs->gc_spare_entries; gs->gc_spare_entries = gs->gc_spare_entries->next; } else new_entry = lily_malloc(sizeof(*new_entry)); new_entry->value.gc_generic = v->value.gc_generic; new_entry->status = GC_NOT_SEEN; new_entry->flags = v->flags; new_entry->next = gs->gc_live_entries; gs->gc_live_entries = new_entry; /* Attach the gc_entry to the value so the caller doesn't have to. */ v->value.gc_generic->gc_entry = new_entry; gs->gc_live_entry_count++; v->flags |= VAL_IS_GC_TAGGED; } /*** * ____ _ _ * | _ \ ___ __ _(_)___| |_ ___ _ __ ___ * | |_) / _ \/ _` | / __| __/ _ \ '__/ __| * | _ < __/ (_| | \__ \ || __/ | \__ \ * |_| \_\___|\__, |_|___/\__\___|_| |___/ * |___/ */ /** This section handles growing registers and also copying register values over for calls. This is also where pushing functions are, which push new values onto the stack and increase the top pointer. Those functions are called from outside the vm. **/ static void vm_error(lily_vm_state *, uint8_t, const char *); /* A function has checked and knows it doesn't have enough size left. Ensure that there are 'size' more empty spots available. This grows by powers of 2 so that grows are not frequent. This will also fix the locals and top of all frames currently entered. */ void lily_vm_grow_registers(lily_vm_state *vm, uint16_t need) { lily_value **old_start = vm->register_root; uint16_t size = (uint16_t)(vm->call_chain->register_end - old_start); uint16_t i = size; need += size; do size *= 2; while (size < need); lily_value **new_regs = lily_realloc(old_start, size * sizeof(*new_regs)); if (vm == vm->gs->first_vm) vm->gs->regs_from_main = new_regs; /* Now create the registers as a bunch of empty values, to be filled in whenever they are needed. */ for (;i < size;i++) { lily_value *v = lily_malloc(sizeof(*v)); v->flags = 0; new_regs[i] = v; } lily_value **end = new_regs + size; lily_call_frame *frame = vm->call_chain; while (frame) { frame->start = new_regs + (frame->start - old_start); frame->top = new_regs + (frame->top - old_start); frame->register_end = end; frame = frame->prev; } frame = vm->call_chain->next; while (frame) { frame->register_end = end; frame = frame->next; } vm->register_root = new_regs; } static void vm_setup_before_call(lily_vm_state *vm, uint16_t *code) { lily_call_frame *current_frame = vm->call_chain; if (current_frame->next == NULL) { if (vm->call_depth > vm->depth_max) { SAVE_LINE(code[2] + 5); vm_error(vm, LILY_ID_RUNTIMEERROR, "Function call recursion limit reached."); } add_call_frame(vm); } int i = code[2]; current_frame->code = code + i + 5; lily_call_frame *next_frame = current_frame->next; next_frame->start = current_frame->top; next_frame->code = NULL; next_frame->return_target = current_frame->start[code[i + 3]]; } static void clear_extra_registers(lily_call_frame *next_frame, uint16_t *code) { int i = code[2]; lily_value **target_regs = next_frame->start; for (;i < next_frame->function->reg_count;i++) { lily_value *reg = target_regs[i]; lily_deref(reg); reg->flags = 0; } } static void prep_registers(lily_call_frame *frame, uint16_t *code) { lily_call_frame *next_frame = frame->next; int i; lily_value **input_regs = frame->start; lily_value **target_regs = next_frame->start; /* A function's args always come first, so copy arguments over while clearing old values. */ for (i = 0;i < code[2];i++) { lily_value *get_reg = input_regs[code[3+i]]; lily_value *set_reg = target_regs[i]; if (get_reg->flags & VAL_IS_DEREFABLE) get_reg->value.generic->refcount++; if (set_reg->flags & VAL_IS_DEREFABLE) lily_deref(set_reg); *set_reg = *get_reg; } } static void move_byte(lily_value *v, uint8_t z) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.integer = z; v->flags = V_BYTE_FLAG | V_BYTE_BASE; } static void move_function_f(uint32_t f, lily_value *v, lily_function_val *z) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.function = z; v->flags = f | V_FUNCTION_BASE | V_FUNCTION_BASE | VAL_IS_DEREFABLE; } static void move_hash_f(uint32_t f, lily_value *v, lily_hash_val *z) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.hash = z; v->flags = f | V_HASH_BASE | VAL_IS_DEREFABLE; } static void move_instance_f(uint32_t f, lily_value *v, lily_container_val *z) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.container = z; v->flags = f | V_INSTANCE_BASE | VAL_IS_DEREFABLE; } static void move_list_f(uint32_t f, lily_value *v, lily_container_val *z) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.container = z; v->flags = f | V_LIST_BASE | VAL_IS_DEREFABLE; } static void move_string(lily_value *v, lily_string_val *z) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.string = z; v->flags = VAL_IS_DEREFABLE | V_STRING_FLAG | V_STRING_BASE; } static void move_tuple_f(uint32_t f, lily_value *v, lily_container_val *z) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.container = z; v->flags = f | VAL_IS_DEREFABLE | V_TUPLE_BASE; } static void move_unit(lily_value *v) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.integer = 0; v->flags = V_UNIT_BASE; } static void move_variant_f(uint32_t f, lily_value *v, lily_container_val *z) { if (v->flags & VAL_IS_DEREFABLE) lily_deref(v); v->value.container = z; v->flags = f | VAL_IS_DEREFABLE | V_VARIANT_BASE; } /*** * _ _ _ * | | | | ___| |_ __ ___ _ __ ___ * | |_| |/ _ \ | '_ \ / _ \ '__/ __| * | _ | __/ | |_) | __/ | \__ \ * |_| |_|\___|_| .__/ \___|_| |___/ * |_| */ static void add_call_frame(lily_vm_state *vm) { lily_call_frame *new_frame = lily_malloc(sizeof(*new_frame)); new_frame->prev = vm->call_chain; new_frame->next = NULL; new_frame->return_target = NULL; /* The toplevel and __main__ frames are allocated directly, so there's always a next and a register end set. */ new_frame->register_end = vm->call_chain->register_end; vm->call_chain->next = new_frame; vm->call_chain = new_frame; } static void add_catch_entry(lily_vm_state *vm) { lily_vm_catch_entry *new_entry = lily_malloc(sizeof(*new_entry)); vm->catch_chain->next = new_entry; new_entry->next = NULL; new_entry->prev = vm->catch_chain; } /*** * _____ * | ____|_ __ _ __ ___ _ __ ___ * | _| | '__| '__/ _ \| '__/ __| * | |___| | | | | (_) | | \__ \ * |_____|_| |_| \___/|_| |___/ * */ static const char *names[] = { "Exception", "IOError", "KeyError", "RuntimeError", "ValueError", "IndexError", "DivisionByZeroError" }; static void dispatch_exception(lily_vm_state *vm); static void load_exception(lily_vm_state *vm, uint8_t id) { lily_class *c = vm->gs->class_table[id]; if (c == NULL) { /* What this does is to kick parser's exception bootstrapping machinery into gear in order to load the exception that's needed. This is unfortunate, but the vm doesn't have a sane and easy way to properly build classes here. */ c = lily_dynaload_exception(vm->gs->parser, names[id - LILY_ID_EXCEPTION]); /* The above will store at least one new function. It's extremely rare, but possible, for that to trigger a grow of symtab's literals. If realloc moves the underlying data, then vm->gs->readonly_table will be invalid. Make sure that doesn't happen. */ vm->gs->readonly_table = vm->gs->parser->symtab->literals->data; vm->gs->class_table[id] = c; } vm->exception_cls = c; } /* This raises an error in the vm that won't have a proper value backing it. The id should be the id of some exception class. This may run a faux dynaload of the error, so that printing has a class name to go by. */ static void vm_error(lily_vm_state *vm, uint8_t id, const char *message) { load_exception(vm, id); lily_msgbuf *msgbuf = lily_mb_flush(vm->vm_buffer); lily_mb_add(msgbuf, message); dispatch_exception(vm); } #define LILY_ERROR(err, id) \ void lily_##err##Error(lily_vm_state *vm, const char *fmt, ...) \ { \ lily_msgbuf *msgbuf = lily_mb_flush(vm->vm_buffer); \ \ va_list var_args; \ va_start(var_args, fmt); \ lily_mb_add_fmt_va(msgbuf, fmt, var_args); \ va_end(var_args); \ \ load_exception(vm, id); \ dispatch_exception(vm); \ } LILY_ERROR(DivisionByZero, LILY_ID_DBZERROR) LILY_ERROR(Index, LILY_ID_INDEXERROR) LILY_ERROR(IO, LILY_ID_IOERROR) LILY_ERROR(Key, LILY_ID_KEYERROR) LILY_ERROR(Runtime, LILY_ID_RUNTIMEERROR) LILY_ERROR(Value, LILY_ID_VALUEERROR) /* Raise KeyError with 'key' as the value of the message. */ static void key_error(lily_vm_state *vm, lily_value *key) { lily_msgbuf *msgbuf = lily_mb_flush(vm->vm_buffer); if (key->flags & V_STRING_FLAG) lily_mb_escape_add_str(msgbuf, key->value.string->string); else lily_mb_add_fmt(msgbuf, "%ld", key->value.integer); load_exception(vm, LILY_ID_KEYERROR); dispatch_exception(vm); } /* Raise IndexError, noting that 'bad_index' is, well, bad. */ static void boundary_error(lily_vm_state *vm, int64_t bad_index) { lily_msgbuf *msgbuf = lily_mb_flush(vm->vm_buffer); lily_mb_add_fmt(msgbuf, "Subscript index %ld is out of range.", bad_index); load_exception(vm, LILY_ID_INDEXERROR); dispatch_exception(vm); } /*** * ____ _ _ _ _ * | __ ) _ _(_) | |_(_)_ __ ___ * | _ \| | | | | | __| | '_ \/ __| * | |_) | |_| | | | |_| | | | \__ \ * |____/ \__,_|_|_|\__|_|_| |_|___/ * */ static lily_container_val *build_traceback_raw(lily_vm_state *); void lily_prelude__calltrace(lily_vm_state *vm) { /* Omit calltrace from the call stack since it's useless info. */ vm->call_depth--; vm->call_chain = vm->call_chain->prev; lily_container_val *trace = build_traceback_raw(vm); vm->call_depth++; vm->call_chain = vm->call_chain->next; move_list_f(0, vm->call_chain->return_target, trace); } static void do_print(lily_vm_state *vm, FILE *target, lily_value *source) { if (source->flags & V_STRING_FLAG) fputs(source->value.string->string, target); else { lily_msgbuf *msgbuf = lily_mb_flush(vm->vm_buffer); lily_mb_add_value(msgbuf, vm, source); fputs(lily_mb_raw(msgbuf), target); } fputc('\n', target); lily_return_unit(vm); } void lily_prelude__print(lily_vm_state *vm) { do_print(vm, stdout, lily_arg_value(vm, 0)); } /* Initially, print is implemented through lily_prelude__print. However, when stdout is dynaloaded, that doesn't work. When stdout is found, print needs to use the register holding Lily's stdout, not the plain C stdout. */ void lily_stdout_print(lily_vm_state *vm) { uint16_t spot = vm->gs->stdout_reg_spot; lily_file_val *stdout_val = vm->gs->regs_from_main[spot]->value.file; if (stdout_val->close_func == NULL) vm_error(vm, LILY_ID_VALUEERROR, "IO operation on closed file."); do_print(vm, stdout_val->inner_file, lily_arg_value(vm, 0)); } /*** * ___ _ * / _ \ _ __ ___ ___ __| | ___ ___ * | | | | '_ \ / __/ _ \ / _` |/ _ \/ __| * | |_| | |_) | (_| (_) | (_| | __/\__ \ * \___/| .__/ \___\___/ \__,_|\___||___/ * |_| */ /** These functions handle various opcodes for the vm. The thinking is to try to keep the vm exec function "small" by kicking out big things. **/ /* Internally, classes are really just tuples. So assigning them is like accessing a tuple, except that the index is a raw int instead of needing to be loaded from a register. */ static void do_o_property_set(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; uint16_t index = code[1]; lily_container_val *ival = vm_regs[code[2]]->value.container; lily_value *rhs_reg = vm_regs[code[3]]; lily_value_assign(ival->values[index], rhs_reg); } static void do_o_property_get(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; uint16_t index = code[1]; lily_container_val *ival = vm_regs[code[2]]->value.container; lily_value *result_reg = vm_regs[code[3]]; lily_value_assign(result_reg, ival->values[index]); } #define RELATIVE_INDEX(limit) \ if (index_int < 0) { \ int64_t new_index = limit + index_int; \ if (new_index < 0) \ boundary_error(vm, index_int); \ \ index_int = new_index; \ } \ else if (index_int >= limit) \ boundary_error(vm, index_int); /* This handles subscript assignment. The index is a register, and needs to be validated. */ static void do_o_subscript_set(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; lily_value *lhs_reg, *index_reg, *rhs_reg; uint16_t base; lhs_reg = vm_regs[code[1]]; index_reg = vm_regs[code[2]]; rhs_reg = vm_regs[code[3]]; base = FLAGS_TO_BASE(lhs_reg); if (base != V_HASH_BASE) { int64_t index_int = index_reg->value.integer; if (base == V_BYTESTRING_BASE) { lily_string_val *bytev = lhs_reg->value.string; RELATIVE_INDEX(bytev->size) bytev->string[index_int] = (char)rhs_reg->value.integer; } else { /* List and Tuple have the same internal representation. */ lily_container_val *list_val = lhs_reg->value.container; RELATIVE_INDEX(list_val->num_values) lily_value_assign(list_val->values[index_int], rhs_reg); } } else lily_hash_set(vm, lhs_reg->value.hash, index_reg, rhs_reg); } /* This handles subscript access. The index is a register, and needs to be validated. */ static void do_o_subscript_get(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; lily_value *lhs_reg, *index_reg, *result_reg; uint16_t base; lhs_reg = vm_regs[code[1]]; index_reg = vm_regs[code[2]]; result_reg = vm_regs[code[3]]; base = FLAGS_TO_BASE(lhs_reg); if (base != V_HASH_BASE) { int64_t index_int = index_reg->value.integer; if (base == V_BYTESTRING_BASE) { lily_string_val *bytev = lhs_reg->value.string; RELATIVE_INDEX(bytev->size) move_byte(result_reg, (uint8_t) bytev->string[index_int]); } else { /* List and Tuple have the same internal representation. */ lily_container_val *list_val = lhs_reg->value.container; RELATIVE_INDEX(list_val->num_values) lily_value_assign(result_reg, list_val->values[index_int]); } } else { lily_value *elem = lily_hash_get(vm, lhs_reg->value.hash, index_reg); /* Give up if the key doesn't exist. */ if (elem == NULL) key_error(vm, index_reg); lily_value_assign(result_reg, elem); } } #undef RELATIVE_INDEX static void do_o_build_hash(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; uint16_t count = code[2]; lily_value *result = vm_regs[code[3 + count]]; lily_hash_val *hash_val = lily_new_hash_raw(count / 2); lily_value *key_reg, *value_reg; uint16_t i; for (i = 0; i < count; i += 2) { key_reg = vm_regs[code[3 + i]]; value_reg = vm_regs[code[3 + i + 1]]; lily_hash_set(vm, hash_val, key_reg, value_reg); } move_hash_f(VAL_IS_GC_SPECULATIVE, result, hash_val); } /* Lists and tuples are effectively the same thing internally, since the list value holds proper values. This is used primarily to do as the name suggests. However, variant types are also tuples (but with a different name). */ static void do_o_build_list_tuple(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; uint16_t count = code[1]; lily_value *result = vm_regs[code[2+count]]; lily_container_val *lv; if (code[0] == o_build_list) lv = lily_new_container_raw(LILY_ID_LIST, count); else lv = lily_new_container_raw(LILY_ID_TUPLE, count); lily_value **elems = lv->values; uint16_t i; for (i = 0;i < count;i++) { lily_value *rhs_reg = vm_regs[code[2+i]]; lily_value_assign(elems[i], rhs_reg); } if (code[0] == o_build_list) move_list_f(VAL_IS_GC_SPECULATIVE, result, lv); else move_tuple_f(VAL_IS_GC_SPECULATIVE, result, lv); } static void do_o_build_variant(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; uint16_t variant_id = code[1]; uint16_t count = code[2]; lily_value *result = vm_regs[code[count + 3]]; lily_container_val *ival = lily_new_container_raw(variant_id, count); lily_value **slots = ival->values; uint16_t i; for (i = 0;i < count;i++) { lily_value *rhs_reg = vm_regs[code[3+i]]; lily_value_assign(slots[i], rhs_reg); } lily_class *variant_cls = vm->gs->class_table[variant_id]; uint32_t flags = (variant_cls->flags & CLS_GC_FLAGS) << VAL_FROM_CLS_GC_SHIFT; if (flags == VAL_IS_GC_SPECULATIVE) move_variant_f(VAL_IS_GC_SPECULATIVE, result, ival); else { move_variant_f(0, result, ival); if (flags == VAL_IS_GC_TAGGED) lily_value_tag(vm, result); } } /* This raises a user-defined exception. The emitter has verified that the thing to be raised is raiseable (extends Exception). */ static void do_o_exception_raise(lily_vm_state *vm, lily_value *exception_val) { /* The Exception class has values[0] as the message, values[1] as the container for traceback. */ lily_container_val *ival = exception_val->value.container; char *message = ival->values[0]->value.string->string; lily_class *raise_cls = vm->gs->class_table[ival->class_id]; /* There's no need for a ref/deref here, because the gc cannot trigger foreign stack unwind and/or exception capture. */ vm->exception_value = exception_val; vm->exception_cls = raise_cls; lily_msgbuf *msgbuf = lily_mb_flush(vm->vm_buffer); lily_mb_add(msgbuf, message); dispatch_exception(vm); } /* This creates a new instance of a class. This checks if the current call is part of a constructor chain. If so, it will attempt to use the value currently being built instead of making a new one. There are three opcodes that come in through here. This will use the incoming opcode as a way of deducing what to do with the newly-made instance. */ static void do_o_new_instance(lily_vm_state *vm, uint16_t *code) { int cls_id = code[1]; lily_value **vm_regs = vm->call_chain->start; lily_value *result = vm_regs[code[2]]; /* Is the caller a superclass building an instance already? */ lily_value *pending_value = vm->call_chain->return_target; if (FLAGS_TO_BASE(pending_value) == V_INSTANCE_BASE) { lily_container_val *cv = pending_value->value.container; if (cv->instance_ctor_need) { cv->instance_ctor_need--; lily_value_assign(result, pending_value); return; } } lily_class *instance_class = vm->gs->class_table[cls_id]; uint16_t total_entries = instance_class->prop_count; lily_container_val *iv = lily_new_container_raw(cls_id, total_entries); iv->instance_ctor_need = instance_class->inherit_depth; uint32_t flags = (instance_class->flags & CLS_GC_FLAGS) << VAL_FROM_CLS_GC_SHIFT; if (flags == VAL_IS_GC_SPECULATIVE) move_instance_f(VAL_IS_GC_SPECULATIVE, result, iv); else { move_instance_f(0, result, iv); if (flags == VAL_IS_GC_TAGGED) lily_value_tag(vm, result); } } static void do_o_interpolation(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; int count = code[1]; lily_msgbuf *vm_buffer = lily_mb_flush(vm->vm_buffer); int i; for (i = 0;i < count;i++) { lily_value *v = vm_regs[code[2 + i]]; lily_mb_add_value(vm_buffer, vm, v); } lily_value *result_reg = vm_regs[code[2 + i]]; lily_string_val *sv = lily_new_string_raw(lily_mb_raw(vm_buffer)); move_string(result_reg, sv); } /*** * ____ _ * / ___| | ___ ___ _ _ _ __ ___ ___ * | | | |/ _ \/ __| | | | '__/ _ \/ __| * | |___| | (_) \__ \ |_| | | | __/\__ \ * \____|_|\___/|___/\__,_|_| \___||___/ * */ /** Closures are pretty easy in the vm. It helps that the emitter has written 'mirroring' get/set upvalue instructions around closed values. That means that the closure's information will always be up-to-date. Closures in the vm work by first creating a shallow copy of a given function value. The closure will then create an area for closure values. These values are termed the closure's cells. A closure is permitted to share cells with another closure. A cell will be destroyed when it has a zero for the cell refcount. This prevents the value from being destroyed too early. Each opcode that initializes closure data is responsible for returning the cells that it made. This returned data is used by lily_vm_execute to do closure get/set but without having to fetch the closure each time. It's not strictly necessary, but it's a performance boost. **/ /* This takes a value and makes a closure cell that is a copy of that value. The value is given a ref increase. */ static lily_value *make_cell_from(lily_value *value) { lily_value *result = lily_malloc(sizeof(*result)); *result = *value; result->cell_refcount = 1; if (value->flags & VAL_IS_DEREFABLE) value->value.generic->refcount++; return result; } /* This clones the data inside of 'to_copy'. */ static lily_function_val *new_function_copy(lily_function_val *to_copy) { lily_function_val *f = lily_malloc(sizeof(*f)); *f = *to_copy; f->refcount = 1; return f; } /* This opcode is the bottom level of closure creation. It is responsible for creating the original closure. */ static lily_value **do_o_closure_new(lily_vm_state *vm, uint16_t *code) { uint16_t count = code[1]; lily_value *result = vm->call_chain->start[code[2]]; lily_function_val *last_call = vm->call_chain->function; lily_function_val *closure_func = new_function_copy(last_call); lily_value **upvalues = lily_malloc(sizeof(*upvalues) * count); uint16_t i; /* Cells are initially NULL so that o_closure_set knows to copy a new value into a cell. */ for (i = 0;i < count;i++) upvalues[i] = NULL; closure_func->num_upvalues = count; closure_func->upvalues = upvalues; /* Put the closure into a register so that the gc has an easy time of finding it. This also helps to ensure it goes away in a more predictable manner, in case there aren't many gc objects. */ move_function_f(0, result, closure_func); lily_value_tag(vm, result); /* Swap out the currently-entered function. This will make it so that all closures have upvalues set on the frame to draw from. */ vm->call_chain->function = closure_func; return upvalues; } /* This copies cells from 'source' to 'target'. Cells that exist are given a cell_refcount bump. */ static void copy_upvalues(lily_function_val *target, lily_function_val *source) { lily_value **source_upvalues = source->upvalues; uint16_t count = source->num_upvalues; lily_value **new_upvalues = lily_malloc(sizeof(*new_upvalues) * count); lily_value *up; uint16_t i; for (i = 0;i < count;i++) { up = source_upvalues[i]; if (up) up->cell_refcount++; new_upvalues[i] = up; } target->upvalues = new_upvalues; target->num_upvalues = count; } /* This opcode will create a copy of a given function that pulls upvalues from the specified closure. */ static void do_o_closure_function(lily_vm_state *vm, uint16_t *code) { lily_value **vm_regs = vm->call_chain->start; lily_function_val *input_closure = vm->call_chain->function; lily_value *target = vm->gs->readonly_table[code[1]]; lily_function_val *target_func = target->value.function; lily_value *result_reg = vm_regs[code[2]]; lily_function_val *new_closure = new_function_copy(target_func); copy_upvalues(new_closure, input_closure); uint16_t *locals = new_closure->proto->locals; if (locals) { lily_value **upvalues = new_closure->upvalues; uint16_t end = locals[0]; uint16_t i; for (i = 1;i < end;i++) { uint16_t pos = locals[i]; lily_value *up = upvalues[pos]; if (up) { up->cell_refcount--; upvalues[pos] = NULL; } } } move_function_f(VAL_IS_GC_SPECULATIVE, result_reg, new_closure); lily_value_tag(vm, result_reg); } /*** * _____ _ _ * | ____|_ _____ ___ _ __ | |_(_) ___ _ __ ___ * | _| \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \/ __| * | |___ > < (_| __/ |_) | |_| | (_) | | | \__ \ * |_____/_/\_\___\___| .__/ \__|_|\___/|_| |_|___/ * |_| */ /** Exception capture is a small but important part of the vm. Exception capturing can be thought of as two parts: One, trying to build trace, and two, trying to catch the exception. The first of those is relatively easy. Actually capturing exceptions is a little rough though. The interpreter currently allows raising a code that the vm's exception capture later has to possibly dynaload (eww). **/ /* This builds the current exception traceback into a raw list value. It is up to the caller to move the raw list to somewhere useful. */ static lily_container_val *build_traceback_raw(lily_vm_state *vm) { lily_call_frame *frame_iter = vm->call_chain; int depth = vm->call_depth; int i; lily_msgbuf *msgbuf = lily_msgbuf_get(vm); lily_container_val *lv = lily_new_container_raw(LILY_ID_LIST, depth); /* The call chain goes from the most recent to least. Work around that by allocating elements in reverse order. It's safe to do this because nothing in this loop can trigger the gc. */ for (i = depth; i >= 1; i--, frame_iter = frame_iter->prev) { lily_function_val *func_val = frame_iter->function; lily_proto *proto = func_val->proto; const char *path = proto->module_path; char line[16] = ""; if (func_val->code) sprintf(line, "%d:", frame_iter->code[-1]); const char *str = lily_mb_sprintf(msgbuf, "%s:%s in %s", path, line, proto->name); lily_string_val *sv = lily_new_string_raw(str); move_string(lv->values[i - 1], sv); } return lv; } /* This is called to catch an exception raised by vm_error. This builds a new value to store the error message and newly-made traceback. */ static void make_proper_exception_val(lily_vm_state *vm, lily_class *raised_cls, lily_value *result) { const char *raw_message = lily_mb_raw(vm->vm_buffer); lily_container_val *ival = lily_new_container_raw(raised_cls->id, 2); lily_string_val *sv = lily_new_string_raw(raw_message); move_string(ival->values[0], sv); move_list_f(0, ival->values[1], build_traceback_raw(vm)); move_instance_f(VAL_IS_GC_SPECULATIVE, result, ival); } /* This is called when 'raise' raises an error. The traceback property is assigned to freshly-made traceback. The other fields of the value are left intact, however. */ static void fixup_exception_val(lily_vm_state *vm, lily_value *result) { lily_value_assign(result, vm->exception_value); lily_container_val *raw_trace = build_traceback_raw(vm); lily_container_val *iv = result->value.container; move_list_f(VAL_IS_GC_SPECULATIVE, lily_con_get(iv, 1), raw_trace); } /* This is called when the vm has raised an exception. This changes control to a jump that handles the error (some `except` clause), or parser. */ static void dispatch_exception(lily_vm_state *vm) { lily_raiser *raiser = vm->raiser; lily_class *raised_cls = vm->exception_cls; lily_vm_catch_entry *catch_iter = vm->catch_chain->prev; int match = 0; uint16_t jump_location = 0; uint16_t *code = NULL; vm->exception_cls = raised_cls; while (catch_iter != NULL) { /* Foreign functions register callbacks so they can fix values when there is an error. Put the state where it was when the callback was registered and go back. The callback shouldn't execute code. */ if (catch_iter->catch_kind == catch_callback) { vm->call_chain = catch_iter->call_frame; vm->call_depth = catch_iter->call_frame_depth; catch_iter->callback_func(vm); catch_iter = catch_iter->prev; continue; } lily_call_frame *call_frame = catch_iter->call_frame; code = call_frame->function->code; /* A try block is done when the next jump is at 0 (because 0 would always be going back, which is illogical otherwise). */ jump_location = catch_iter->code_pos + code[catch_iter->code_pos] - 1; while (1) { lily_class *catch_class = vm->gs->class_table[code[jump_location + 1]]; if (lily_class_greater_eq(catch_class, raised_cls)) { /* ...So that execution resumes from within the except block. */ jump_location += 4; match = 1; break; } else { int move_by = code[jump_location + 2]; if (move_by == 0) break; jump_location += move_by; } } if (match) break; catch_iter = catch_iter->prev; } lily_jump_link *jump_stop; if (match) { code += jump_location; if (*code == o_exception_store) { lily_value *catch_reg = catch_iter->call_frame->start[code[1]]; /* There is a var that the exception needs to be dropped into. If this exception was triggered by raise, then use that (after dumping traceback into it). If not, create a new instance to hold the info. */ if (vm->exception_value) fixup_exception_val(vm, catch_reg); else make_proper_exception_val(vm, raised_cls, catch_reg); code += 2; } /* Make sure any exception value that was held is gone. No ref/deref is necessary, because the value was saved somewhere in a register. */ vm->exception_value = NULL; vm->exception_cls = NULL; vm->call_chain = catch_iter->call_frame; vm->call_depth = catch_iter->call_frame_depth; vm->call_chain->code = code; /* Each try block can only successfully handle one exception, so use ->prev to prevent using the same block again. */ vm->catch_chain = catch_iter; jump_stop = catch_iter->jump_entry->prev; while (raiser->all_jumps->prev != jump_stop) raiser->all_jumps = raiser->all_jumps->prev; longjmp(raiser->all_jumps->jump, 1); } while (raiser->all_jumps->prev != NULL) raiser->all_jumps = raiser->all_jumps->prev; lily_raise_class(vm->raiser, vm->exception_cls, lily_mb_raw(vm->vm_buffer)); } /*** * ____ _ _ * / ___| ___ _ __ ___ _ _| |_(_)_ __ ___ ___ * | | / _ \| '__/ _ \| | | | __| | '_ \ / _ | __| * | |___| (_) | | | (_) | |_| | |_| | | | | __|__ \ * \____|\___/|_| \___/ \__,_|\__|_|_| |_|\___|___/ * */ /** A coroutine is a special kind of function that can yield a value and suspend itself for later. There are different kinds of coroutines depending on the language, with their capabilities differing. Lily's implementation of coroutines is to create them as a value holding a vm. A coroutine vm is different than the one created by 'lily_new_state' in that it shares the global state of the calling vm. Because of this design, coroutine vms have their own stack and their own exception state. The vms share a common global state in part to prevent a parse from making coroutine tables stale. Static typing makes implementing coroutines more difficult. A coroutine cannot yield any kind of a value, and may want an initial set of extra arguments. The first problem is solved by requiring coroutines take a coroutine as their first argument. Unfortunately, this solution means that coroutines will almost always need a garbage collection cycle to go away. The second is somewhat solved by having a coroutine constructor that takes a single extra argument. It is believed that few coroutines have a valid reason for 2+ one-time arguments. Those that want such a feature can pass a Tuple for the callee to unpack, or use a closure to store arguments. **/ static lily_coroutine_val *new_coroutine(lily_vm_state *base_vm, lily_function_val *base_function, uint16_t id) { lily_coroutine_val *result = lily_malloc(sizeof(*result)); lily_value *receiver = lily_malloc(sizeof(*receiver)); /* This is ignored when resuming through .resume, and overwritten when resuming through .resume_with. */ receiver->flags = V_UNIT_BASE; result->refcount = 1; result->class_id = id; result->status = co_waiting; result->vm = base_vm; result->base_function = base_function; result->receiver = receiver; return result; } /* This marks the Coroutine's base Function as having ownership of the arguments that were just passed. It's effectively lily_call, except that there's no registers to zero (they were just made), and no growth check (vm creation already make sure of that). */ void lily_vm_coroutine_call_prep(lily_vm_state *vm, uint16_t count) { lily_call_frame *source_frame = vm->call_chain; lily_call_frame *target_frame = vm->call_chain->next; /* The last 'count' arguments go from the old frame to the new one. */ target_frame->top = source_frame->top; source_frame->top -= count; target_frame->start = source_frame->top; vm->call_depth++; target_frame->top += target_frame->function->reg_count - count; vm->call_chain = target_frame; } lily_vm_state *lily_vm_coroutine_build(lily_vm_state *vm, uint16_t id) { lily_function_val *to_copy = lily_arg_function(vm, 0); if (to_copy->foreign_func != NULL) lily_RuntimeError(vm, "Only native functions can be coroutines."); lily_function_val *base_func = new_function_copy(to_copy); if (to_copy->upvalues) copy_upvalues(base_func, to_copy); else base_func->upvalues = NULL; lily_vm_state *base_vm = new_vm_state(lily_new_raiser(), INITIAL_REGISTER_COUNT + to_copy->reg_count); lily_call_frame *toplevel_frame = base_vm->call_chain; base_vm->gs = vm->gs; base_vm->depth_max = vm->depth_max; /* Bail out of the vm loop if the Coroutine's base Function completes. */ toplevel_frame->code = foreign_code; /* Don't crash when returning to the toplevel frame. */ toplevel_frame->function = base_func; /* Make the Coroutine and hand it arguments. The first is the Coroutine itself (for control), then whatever arguments this builder was given. */ lily_coroutine_val *co_val = new_coroutine(base_vm, base_func, id); lily_push_coroutine(vm, co_val); /* Tag before pushing so that both sides have the gc tag flag. */ lily_value_tag(vm, lily_stack_get_top(vm)); /* This has the side-effect of pushing a Unit register at the very bottom as register zero. This is later used by yield since the base function cannot touch it. */ lily_call_prepare(base_vm, base_func); lily_push_value(base_vm, lily_stack_get_top(vm)); return base_vm; } void lily_vm_coroutine_resume(lily_vm_state *origin, lily_coroutine_val *co_val, lily_value *to_send) { /* Don't resume Coroutines that are already running, done, or broken. */ if (co_val->status != co_waiting) { lily_push_none(origin); return; } lily_vm_state *target = co_val->vm; lily_coroutine_status new_status = co_running; if (to_send) lily_value_assign(co_val->receiver, to_send); co_val->status = co_running; /* If the vm absolutely has to bail out, it uses the very first jump as the target. Make it point to here. */ lily_jump_link *jump_base = target->raiser->all_jumps; lily_value *result = NULL; if (setjmp(jump_base->jump) == 0) { /* Invoke the vm loop. It'll pick up from where it left off at. If the vm raises or yields, one of the other cases will be reached. */ lily_vm_execute(target); new_status = co_done; } else if (target->exception_cls == NULL) { /* The Coroutine yielded a value that's at the top of its stack. */ result = lily_stack_get_top(target); new_status = co_waiting; /* Since the Coroutine jumped back instead of exiting through the main loop, the call state needs to be fixed. */ target->call_chain = target->call_chain->prev; target->call_depth--; } else /* An exception was raised, so there's nothing to return. */ new_status = co_failed; co_val->status = new_status; if (result) { lily_container_val *con = lily_push_some(origin); lily_push_value(origin, result); lily_con_set_from_stack(origin, con, 0); } else lily_push_none(origin); } /*** * _____ _ _ ____ ___ * | ___|__ _ __ ___(_) __ _ _ __ / \ | _ \_ _| * | |_ / _ \| '__/ _ \ |/ _` | '_ \ / _ \ | |_) | | * | _| (_) | | | __/ | (_| | | | | / ___ \| __/| | * |_| \___/|_| \___|_|\__, |_| |_| /_/ \_\_| |___| * |___/ */ lily_msgbuf *lily_msgbuf_get(lily_vm_state *vm) { return lily_mb_flush(vm->vm_buffer); } /** Foreign functions that are looking to interact with the interpreter can use the functions within here. Do be careful with foreign calls, however. **/ void lily_call_prepare(lily_vm_state *vm, lily_function_val *func) { lily_call_frame *caller_frame = vm->call_chain; caller_frame->code = foreign_code; if (caller_frame->next == NULL) { add_call_frame(vm); /* The vm's call chain automatically advances when add_call_frame is used. That's useful for the vm, but not here. Rewind the frame back so that every invocation of this call will have the same call_chain. */ vm->call_chain = caller_frame; } lily_call_frame *target_frame = caller_frame->next; target_frame->code = func->code; target_frame->function = func; target_frame->return_target = *caller_frame->top; lily_push_unit(vm); } lily_value *lily_call_result(lily_vm_state *vm) { return vm->call_chain->next->return_target; } void lily_call(lily_vm_state *vm, uint16_t count) { lily_call_frame *source_frame = vm->call_chain; lily_call_frame *target_frame = vm->call_chain->next; lily_function_val *target_fn = target_frame->function; /* The last 'count' arguments go from the old frame to the new one. */ target_frame->top = source_frame->top; source_frame->top -= count; target_frame->start = source_frame->top; vm->call_depth++; if (target_fn->code == NULL) { vm->call_chain = target_frame; target_fn->foreign_func(vm); vm->call_chain = target_frame->prev; vm->call_depth--; } else { /* lily_vm_execute determines the starting code position by tapping the frame's code. That allows coroutines to resume where they left off at. Regular functions like this one start at the top every time, and this ensures that. */ target_frame->code = target_fn->code; int diff = target_frame->function->reg_count - count; if (target_frame->top + diff > target_frame->register_end) { vm->call_chain = target_frame; lily_vm_grow_registers(vm, diff); } lily_value **start = target_frame->top; lily_value **end = target_frame->top + diff; while (start != end) { lily_value *v = *start; lily_deref(v); v->flags = 0; start++; } target_frame->top += diff; vm->call_chain = target_frame; lily_vm_execute(vm); /* Native execute drops the frame and lowers the depth. In most cases, nothing more needs to be done. However, if the called function uses upvalues, the frame function will be ejected in favor of the closure copy. That copy could be deleted on the next pass when the registers are cleared, so make sure the function is what it originally was. */ target_frame->function = target_fn; } } void lily_error_callback_push(lily_state *s, lily_error_callback_func func) { if (s->catch_chain->next == NULL) add_catch_entry(s); lily_vm_catch_entry *catch_entry = s->catch_chain; catch_entry->call_frame = s->call_chain; catch_entry->call_frame_depth = s->call_depth; catch_entry->callback_func = func; catch_entry->catch_kind = catch_callback; s->catch_chain = s->catch_chain->next; } void lily_error_callback_pop(lily_state *s) { s->catch_chain = s->catch_chain->prev; } /*** * ____ * | _ \ _ __ ___ _ __ * | |_) | '__/ _ \ '_ \ * | __/| | | __/ |_) | * |_| |_| \___| .__/ * |_| */ /** These functions are used by symtab to help prepare the vm's class table. The class table is used in different areas of the vm to provide a quick mapping from class id to actual class. Usage examples include class initialization and printing classes. **/ void lily_vm_ensure_class_table(lily_vm_state *vm, uint16_t size) { uint32_t old_count = vm->gs->class_count; if (size >= vm->gs->class_count) { if (vm->gs->class_count == 0) vm->gs->class_count = 1; while (size >= vm->gs->class_count) vm->gs->class_count *= 2; vm->gs->class_table = lily_realloc(vm->gs->class_table, sizeof(*vm->gs->class_table) * vm->gs->class_count); } /* For the first pass, make sure the spots for Exception and its built-in children are zero'ed out. This allows vm_error to safely check if an exception class has been loaded by testing the class field for being NULL (and relies on holes being set aside for these exceptions). */ if (old_count == 0) { int i; for (i = LILY_ID_EXCEPTION;i < LILY_ID_UNIT;i++) vm->gs->class_table[i] = NULL; } } void lily_vm_add_class_unchecked(lily_vm_state *vm, lily_class *cls) { vm->gs->class_table[cls->id] = cls; } /*** * _____ _ * | ____|_ _____ ___ _ _| |_ ___ * | _| \ \/ / _ \/ __| | | | __/ _ \ * | |___ > < __/ (__| |_| | || __/ * |_____/_/\_\___|\___|\__,_|\__\___| * */ #define INTEGER_OP(OP) \ lhs_reg = vm_regs[code[1]]; \ rhs_reg = vm_regs[code[2]]; \ vm_regs[code[3]]->value.integer = \ lhs_reg->value.integer OP rhs_reg->value.integer; \ vm_regs[code[3]]->flags = V_INTEGER_FLAG | V_INTEGER_BASE; \ code += 5; #define DOUBLE_OP(OP) \ lhs_reg = vm_regs[code[1]]; \ rhs_reg = vm_regs[code[2]]; \ vm_regs[code[3]]->value.doubleval = \ lhs_reg->value.doubleval OP rhs_reg->value.doubleval; \ vm_regs[code[3]]->flags = V_DOUBLE_FLAG | V_DOUBLE_BASE; \ code += 5; /* EQUALITY_OP is for `!=` and `==`. This has fast paths for the usual suspects, and the heavy `lily_value_compare` for more interesting types. */ #define EQUALITY_OP(OP) \ lhs_reg = vm_regs[code[1]]; \ rhs_reg = vm_regs[code[2]]; \ if (lhs_reg->flags & (V_BOOLEAN_FLAG | V_BYTE_FLAG | V_INTEGER_FLAG)) { \ i = lhs_reg->value.integer OP rhs_reg->value.integer; \ } \ else if (lhs_reg->flags & V_STRING_FLAG) { \ i = strcmp(lhs_reg->value.string->string, \ rhs_reg->value.string->string) OP 0; \ } \ else { \ SAVE_LINE(+5); \ i = lily_value_compare(vm, lhs_reg, rhs_reg) OP 1; \ } \ \ if (i) \ code += 5; \ else \ code += code[3]; /* COMPARE_OP is for `>` and `>=`. Only `Byte`, `Integer`, `String`, and `Double` pass through here. */ #define COMPARE_OP(OP) \ lhs_reg = vm_regs[code[1]]; \ rhs_reg = vm_regs[code[2]]; \ if (lhs_reg->flags & (V_INTEGER_FLAG | V_BYTE_FLAG)) \ i = lhs_reg->value.integer OP rhs_reg->value.integer; \ else if (lhs_reg->flags & V_STRING_FLAG) { \ i = strcmp(lhs_reg->value.string->string, \ rhs_reg->value.string->string) OP 0; \ } \ else \ i = lhs_reg->value.doubleval OP rhs_reg->value.doubleval; \ \ if (i) \ code += 5; \ else \ code += code[3]; /* This is where native code is executed. Simple opcodes are handled here, while complex opcodes are handled in do_o_* functions. Native functions work by pushing data onto the vm's stack and moving the current frame. As a result, this function is only entered again when a foreign function calls back into native code. */ void lily_vm_execute(lily_vm_state *vm) { uint16_t *code; lily_value **vm_regs; int i; register int64_t for_temp; register lily_value *lhs_reg, *rhs_reg, *loop_reg, *step_reg; lily_function_val *fval; lily_value **upvalues; lily_call_frame *current_frame, *next_frame; lily_jump_link *link = lily_jump_setup(vm->raiser); /* If an exception is caught, the vm's state is fixed before sending control back here. There's no need for a condition around this setjmp call. */ setjmp(link->jump); current_frame = vm->call_chain; code = current_frame->code; upvalues = current_frame->function->upvalues; vm_regs = vm->call_chain->start; while (1) { switch(code[0]) { case o_assign_noref: rhs_reg = vm_regs[code[1]]; lhs_reg = vm_regs[code[2]]; lhs_reg->flags = rhs_reg->flags; lhs_reg->value = rhs_reg->value; code += 4; break; case o_load_readonly: rhs_reg = vm->gs->readonly_table[code[1]]; lhs_reg = vm_regs[code[2]]; lily_deref(lhs_reg); lhs_reg->value = rhs_reg->value; lhs_reg->flags = rhs_reg->flags; code += 4; break; case o_load_empty_variant: lhs_reg = vm_regs[code[2]]; lily_deref(lhs_reg); lhs_reg->value.integer = code[1]; lhs_reg->flags = V_EMPTY_VARIANT_BASE; code += 4; break; case o_load_integer: lhs_reg = vm_regs[code[2]]; lhs_reg->value.integer = (int16_t)code[1]; lhs_reg->flags = V_INTEGER_FLAG | V_INTEGER_BASE; code += 4; break; case o_load_boolean: lhs_reg = vm_regs[code[2]]; lhs_reg->value.integer = code[1]; lhs_reg->flags = V_BOOLEAN_BASE | V_BOOLEAN_FLAG; code += 4; break; case o_load_byte: lhs_reg = vm_regs[code[2]]; lhs_reg->value.integer = (uint8_t)code[1]; lhs_reg->flags = V_BYTE_FLAG | V_BYTE_BASE; code += 4; break; case o_int_add: INTEGER_OP(+) break; case o_int_minus: INTEGER_OP(-) break; case o_number_add: DOUBLE_OP(+) break; case o_number_minus: DOUBLE_OP(-) break; case o_compare_eq: EQUALITY_OP(==) break; case o_compare_greater: COMPARE_OP(>) break; case o_compare_greater_eq: COMPARE_OP(>=) break; case o_compare_not_eq: EQUALITY_OP(!=) break; case o_jump: code += (int16_t)code[1]; break; case o_int_multiply: INTEGER_OP(*) break; case o_number_multiply: DOUBLE_OP(*) break; case o_int_divide: /* Before doing INTEGER_OP, check for a division by zero. This will involve some redundant checking of the rhs, but better than dumping INTEGER_OP's contents here or rewriting INTEGER_OP for the special case of division. */ rhs_reg = vm_regs[code[2]]; if (rhs_reg->value.integer == 0) { SAVE_LINE(+5); vm_error(vm, LILY_ID_DBZERROR, "Attempt to divide by zero."); } INTEGER_OP(/) break; case o_int_modulo: /* x % 0 will do the same thing as x / 0... */ rhs_reg = vm_regs[code[2]]; if (rhs_reg->value.integer == 0) { SAVE_LINE(+5); vm_error(vm, LILY_ID_DBZERROR, "Attempt to divide by zero."); } INTEGER_OP(%) break; case o_int_left_shift: INTEGER_OP(<<) break; case o_int_right_shift: INTEGER_OP(>>) break; case o_int_bitwise_and: INTEGER_OP(&) break; case o_int_bitwise_or: INTEGER_OP(|) break; case o_int_bitwise_xor: INTEGER_OP(^) break; case o_number_divide: rhs_reg = vm_regs[code[2]]; if (rhs_reg->value.doubleval == 0) { SAVE_LINE(+5); vm_error(vm, LILY_ID_DBZERROR, "Attempt to divide by zero."); } DOUBLE_OP(/) break; case o_jump_if: lhs_reg = vm_regs[code[2]]; { int base = FLAGS_TO_BASE(lhs_reg); int result; if (lhs_reg->flags & (V_BOOLEAN_FLAG | V_INTEGER_FLAG)) result = (lhs_reg->value.integer == 0); else if (base == V_STRING_BASE) result = (lhs_reg->value.string->size == 0); else if (base == V_LIST_BASE) result = (lhs_reg->value.container->num_values == 0); else result = 1; if (result != code[1]) code += (int16_t)code[3]; else code += 4; } break; case o_call_foreign: fval = vm->gs->readonly_table[code[1]]->value.function; foreign_func_body: ; vm_setup_before_call(vm, code); i = code[2]; next_frame = current_frame->next; next_frame->function = fval; next_frame->top = next_frame->start + i; if (next_frame->top >= next_frame->register_end) { vm->call_chain = next_frame; lily_vm_grow_registers(vm, i + 1); } prep_registers(current_frame, code); vm_regs = next_frame->start; vm->call_chain = next_frame; vm->call_depth++; fval->foreign_func(vm); vm->call_depth--; vm->call_chain = current_frame; vm_regs = current_frame->start; code = current_frame->code; break; case o_call_native: { fval = vm->gs->readonly_table[code[1]]->value.function; native_func_body: ; vm_setup_before_call(vm, code); next_frame = current_frame->next; next_frame->function = fval; next_frame->top = next_frame->start + fval->reg_count; if (next_frame->top >= next_frame->register_end) { vm->call_chain = next_frame; lily_vm_grow_registers(vm, fval->reg_count); } prep_registers(current_frame, code); /* A native Function call is almost certainly going to have more registers than arguments. They need to be blasted. This is not part of prep_registers, because foreign functions do not have this same requirement. */ clear_extra_registers(next_frame, code); current_frame = current_frame->next; vm->call_chain = current_frame; vm->call_depth++; vm_regs = current_frame->start; code = fval->code; upvalues = fval->upvalues; break; } case o_call_register: fval = vm_regs[code[1]]->value.function; if (fval->code != NULL) goto native_func_body; else goto foreign_func_body; break; case o_interpolation: do_o_interpolation(vm, code); code += code[1] + 4; break; case o_unary_not: rhs_reg = vm_regs[code[1]]; lhs_reg = vm_regs[code[2]]; lhs_reg->flags = rhs_reg->flags; lhs_reg->value.integer = !(rhs_reg->value.integer); code += 4; break; case o_unary_minus: rhs_reg = vm_regs[code[1]]; lhs_reg = vm_regs[code[2]]; if (rhs_reg->flags & V_INTEGER_FLAG) { lhs_reg->value.integer = -(rhs_reg->value.integer); lhs_reg->flags = V_INTEGER_FLAG | V_INTEGER_BASE; } else { lhs_reg->value.doubleval = -(rhs_reg->value.doubleval); lhs_reg->flags = V_DOUBLE_FLAG | V_DOUBLE_BASE; } code += 4; break; case o_unary_bitwise_not: rhs_reg = vm_regs[code[1]]; lhs_reg = vm_regs[code[2]]; lhs_reg->flags = rhs_reg->flags; lhs_reg->value.integer = ~(rhs_reg->value.integer); code += 4; break; case o_return_unit: move_unit(current_frame->return_target); goto return_common; case o_return_value: lhs_reg = current_frame->return_target; rhs_reg = vm_regs[code[1]]; lily_value_assign(lhs_reg, rhs_reg); return_common: ; current_frame = current_frame->prev; vm->call_chain = current_frame; vm->call_depth--; vm_regs = current_frame->start; upvalues = current_frame->function->upvalues; code = current_frame->code; break; case o_global_get: rhs_reg = vm->gs->regs_from_main[code[1]]; lhs_reg = vm_regs[code[2]]; lily_value_assign(lhs_reg, rhs_reg); code += 4; break; case o_global_set: rhs_reg = vm_regs[code[1]]; lhs_reg = vm->gs->regs_from_main[code[2]]; lily_value_assign(lhs_reg, rhs_reg); code += 4; break; case o_assign: rhs_reg = vm_regs[code[1]]; lhs_reg = vm_regs[code[2]]; lily_value_assign(lhs_reg, rhs_reg); code += 4; break; case o_subscript_get: /* Might raise IndexError or KeyError. */ SAVE_LINE(+5); do_o_subscript_get(vm, code); code += 5; break; case o_property_get: do_o_property_get(vm, code); code += 5; break; case o_subscript_set: /* Might raise IndexError or KeyError. */ SAVE_LINE(+5); do_o_subscript_set(vm, code); code += 5; break; case o_property_set: do_o_property_set(vm, code); code += 5; break; case o_build_hash: do_o_build_hash(vm, code); code += code[2] + 5; break; case o_build_list: case o_build_tuple: do_o_build_list_tuple(vm, code); code += code[1] + 4; break; case o_build_variant: do_o_build_variant(vm, code); code += code[2] + 5; break; case o_closure_function: do_o_closure_function(vm, code); code += 4; break; case o_closure_set: lhs_reg = upvalues[code[1]]; rhs_reg = vm_regs[code[2]]; if (lhs_reg == NULL) upvalues[code[1]] = make_cell_from(rhs_reg); else lily_value_assign(lhs_reg, rhs_reg); code += 4; break; case o_closure_get: lhs_reg = vm_regs[code[2]]; rhs_reg = upvalues[code[1]]; lily_value_assign(lhs_reg, rhs_reg); code += 4; break; case o_for_integer: /* loop_reg is an internal counter, while lhs_reg is an external counter. rhs_reg is the stopping point. */ loop_reg = vm_regs[code[1]]; rhs_reg = vm_regs[code[2]]; step_reg = vm_regs[code[3]]; /* Note the use of the loop_reg. This makes it use the internal counter, and thus prevent user assignments from damaging the loop. */ for_temp = loop_reg->value.integer + step_reg->value.integer; /* This idea comes from seeing Lua do something similar. */ if ((step_reg->value.integer > 0) /* Positive bound check */ ? (for_temp <= rhs_reg->value.integer) /* Negative bound check */ : (for_temp >= rhs_reg->value.integer)) { /* Haven't reached the end yet, so bump the internal and external values.*/ lhs_reg = vm_regs[code[4]]; lhs_reg->value.integer = for_temp; loop_reg->value.integer = for_temp; code += 7; } else code += code[5]; break; case o_catch_push: { if (vm->catch_chain->next == NULL) add_catch_entry(vm); lily_vm_catch_entry *catch_entry = vm->catch_chain; catch_entry->call_frame = current_frame; catch_entry->call_frame_depth = vm->call_depth; catch_entry->code_pos = 1 + (uint16_t)(code - current_frame->function->code); catch_entry->jump_entry = vm->raiser->all_jumps; catch_entry->catch_kind = catch_native; vm->catch_chain = vm->catch_chain->next; code += 3; break; } case o_catch_pop: vm->catch_chain = vm->catch_chain->prev; code++; break; case o_exception_raise: SAVE_LINE(+3); lhs_reg = vm_regs[code[1]]; do_o_exception_raise(vm, lhs_reg); break; case o_instance_new: { do_o_new_instance(vm, code); code += 4; break; } case o_jump_if_not_class: lhs_reg = vm_regs[code[2]]; i = FLAGS_TO_BASE(lhs_reg); /* This opcode is used for match branches. The source is always a class instance or a variant (which might be empty). */ if (i == V_VARIANT_BASE || i == V_INSTANCE_BASE) i = lhs_reg->value.container->class_id; else i = (uint16_t)lhs_reg->value.integer; if (i == code[1]) code += 4; else code += code[3]; break; case o_jump_if_set: lhs_reg = vm_regs[code[1]]; if (lhs_reg->flags == 0) code += 3; else code += code[2]; break; case o_closure_new: do_o_closure_new(vm, code); upvalues = current_frame->function->upvalues; code += 4; break; case o_for_setup: /* lhs_reg is the start, rhs_reg is the stop. */ lhs_reg = vm_regs[code[1]]; rhs_reg = vm_regs[code[2]]; step_reg = vm_regs[code[3]]; loop_reg = vm_regs[code[4]]; if (step_reg->value.integer == 0) { SAVE_LINE(+6); vm_error(vm, LILY_ID_VALUEERROR, "for loop step cannot be 0."); } /* Do a negative step to offset falling into o_for_loop. */ loop_reg->value.integer = lhs_reg->value.integer - step_reg->value.integer; lhs_reg->value.integer = loop_reg->value.integer; loop_reg->flags = V_INTEGER_FLAG | V_INTEGER_BASE; code += 6; break; case o_vm_exit: lily_release_jump(vm->raiser); default: return; } } }
37,324
5,169
<gh_stars>1000+ { "name": "Rating", "version": "0.0.1", "summary": "lalala, A short description of Rating.", "description": "lalala, lalala, A short description of Rating.", "homepage": "https://github.com/fengleli/Rating/wiki", "license": "MIT", "authors": { "fengleli": "<EMAIL>" }, "platforms": { "ios": null }, "source": { "git": "https://github.com/fengleli/Rating.git", "commit": "<PASSWORD>" }, "source_files": "Rating/*.{h,m}", "exclude_files": "Classes/Exclude", "frameworks": [ "UIKit", "Foundation" ] }
241
480
<reponame>weicao/galaxysql /* * Copyright [2013-2021], Alibaba Group Holding 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. */ package com.alibaba.polardbx.executor.mpp.web; import com.alibaba.polardbx.gms.node.InternalNode; import com.alibaba.polardbx.gms.node.InternalNodeManager; import com.alibaba.polardbx.gms.node.Node; import com.alibaba.polardbx.gms.node.NodeState; import io.airlift.http.client.HttpClient; import io.airlift.http.client.Request; import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; import java.io.InputStream; import java.util.Set; import static io.airlift.http.client.HttpUriBuilder.uriBuilderFrom; import static io.airlift.http.client.Request.Builder.prepareGet; import static java.util.Objects.requireNonNull; import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE; import static javax.ws.rs.core.Response.Status.NOT_FOUND; @Path("/v1/worker") public class WorkerResource { private final InternalNodeManager nodeManager; private final HttpClient httpClient; @Inject public WorkerResource(InternalNodeManager nodeManager, @ForWorkerInfo HttpClient httpClient) { this.nodeManager = requireNonNull(nodeManager, "nodeManager is null"); this.httpClient = requireNonNull(httpClient, "httpClient is null"); } @GET @Path("{nodeId}/status") public Response getStatus(@PathParam("nodeId") String nodeId) { return proxyJsonResponse(nodeId, "v1/status"); } @GET @Path("{nodeId}/thread") public Response getThreads(@PathParam("nodeId") String nodeId) { return proxyJsonResponse(nodeId, "v1/thread"); } private Response proxyJsonResponse(String nodeId, String workerPath) { Set<InternalNode> nodes = nodeManager.getNodes(NodeState.ACTIVE, true); Node node = nodes.stream() .filter(n -> n.getNodeIdentifier().equals(nodeId)) .findFirst() .orElseThrow(() -> new WebApplicationException(NOT_FOUND)); Request request = prepareGet() .setUri(uriBuilderFrom(((InternalNode) node).getHttpUri()) .appendPath(workerPath) .build()) .build(); InputStream responseStream = httpClient.execute(request, new StreamingJsonResponseHandler()); return Response.ok(responseStream, APPLICATION_JSON_TYPE).build(); } }
1,070
578
// Created from bdf2c Version 4, (c) 2009, 2010 by <NAME> // License AGPLv3: GNU Affero General Public License version 3 #include "font.h" /// character bitmap for each encoding static const unsigned char __font_bitmap__[] = { // 0 $00 'ascii000' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _XXXX___, _XXXX___, _XXXX___, _XXXX___, _XXXX___, _XXXX___, _XXXX___, _XXXX___, _XXXX___, _XXXX___, _XXXX___, ________, // 1 $01 'ascii001' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, __X_____, _XXX____, XXXXX___, _XXX____, __X_____, ________, ________, ________, // 2 $02 'ascii002' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X_X__, X_X_X___, _X_X_X__, X_X_X___, _X_X_X__, X_X_X___, _X_X_X__, X_X_X___, _X_X_X__, X_X_X___, _X_X_X__, X_X_X___, // 3 $03 'ascii003' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, X_X_____, X_X_____, XXX_____, X_X_____, X_X_____, _XXX____, __X_____, __X_____, __X_____, // 4 $04 'ascii004' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, XXX_____, X_______, XX______, X_______, XXXX____, _X______, _XX_____, _X______, _X______, // 5 $05 'ascii005' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, _XXX____, X_______, X_______, _XXX____, _XXX____, _X__X___, _XXX____, _X_X____, _X__X___, // 6 $06 'ascii006' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, X_______, X_______, X_______, XXX_____, _XXX____, _X______, _XX_____, _X______, _X______, // 7 $07 'ascii007' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XX_____, X__X____, X__X____, _XX_____, ________, ________, ________, ________, ________, ________, ________, // 8 $08 'ascii010' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, __X_____, __X_____, XXXXX___, __X_____, __X_____, ________, XXXXX___, ________, ________, // 9 $09 'ascii011' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, X___X___, XX__X___, X_X_X___, X__XX___, X___X___, _X______, _X______, _X______, _XXXX___, // 10 $0a 'ascii012' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, X___X___, X___X___, _X_X____, __X_____, ________, XXXXX___, __X_____, __X_____, __X_____, // 11 $0b 'ascii013' // width 6, bbx 0, bby -2, bbw 6, bbh 13 __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, XXX_____, ________, ________, ________, ________, ________, // 12 $0c 'ascii014' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, XXX_____, __X_____, __X_____, __X_____, __X_____, __X_____, // 13 $0d 'ascii015' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, __XXXX__, __X_____, __X_____, __X_____, __X_____, __X_____, // 14 $0e 'ascii016' // width 6, bbx 0, bby -2, bbw 6, bbh 13 __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __XXXX__, ________, ________, ________, ________, ________, // 15 $0f 'ascii017' // width 6, bbx 0, bby -2, bbw 6, bbh 13 __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, XXXXXX__, __X_____, __X_____, __X_____, __X_____, __X_____, // 16 $10 'ascii020' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, XXXXXX__, ________, ________, ________, ________, ________, ________, ________, ________, ________, // 17 $11 'ascii021' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, XXXXXX__, ________, ________, ________, ________, ________, ________, ________, // 18 $12 'ascii022' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, XXXXXX__, ________, ________, ________, ________, ________, // 19 $13 'ascii023' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, XXXXXX__, ________, ________, ________, // 20 $14 'ascii024' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, XXXXXX__, ________, // 21 $15 'ascii025' // width 6, bbx 0, bby -2, bbw 6, bbh 13 __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __XXXX__, __X_____, __X_____, __X_____, __X_____, __X_____, // 22 $16 'ascii026' // width 6, bbx 0, bby -2, bbw 6, bbh 13 __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, XXX_____, __X_____, __X_____, __X_____, __X_____, __X_____, // 23 $17 'ascii027' // width 6, bbx 0, bby -2, bbw 6, bbh 13 __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, XXXXXX__, ________, ________, ________, ________, ________, // 24 $18 'ascii030' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, XXXXXX__, __X_____, __X_____, __X_____, __X_____, __X_____, // 25 $19 'ascii031' // width 6, bbx 0, bby -2, bbw 6, bbh 13 __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, // 26 $1a 'ascii032' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ____X___, ___X____, __X_____, _X______, __X_____, ___X____, ____X___, XXXXX___, ________, ________, // 27 $1b 'ascii033' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, X_______, _X______, __X_____, ___X____, __X_____, _X______, X_______, XXXXX___, ________, ________, // 28 $1c 'ascii034' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, XXXXX___, _X_X____, _X_X____, _X_X____, _X_X____, X__X____, ________, ________, // 29 $1d 'ascii035' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ____X___, XXXXX___, __X_____, XXXXX___, X_______, ________, ________, ________, // 30 $1e 'ascii036' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __XX____, _X__X___, _X______, _X______, XXX_____, _X______, _X______, _X__X___, X_XX____, ________, ________, // 31 $1f 'ascii037' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, __X_____, ________, ________, ________, ________, // 32 $20 'space' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, // 33 $21 'exclam' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, ________, __X_____, ________, ________, // 34 $22 'quotedbl' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _X_X____, _X_X____, _X_X____, ________, ________, ________, ________, ________, ________, ________, ________, // 35 $23 'numbersign' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, _X_X____, _X_X____, XXXXX___, _X_X____, XXXXX___, _X_X____, _X_X____, ________, ________, ________, // 36 $24 'dollar' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, _XXXX___, X_X_____, X_X_____, _XXX____, __X_X___, __X_X___, XXXX____, __X_____, ________, ________, // 37 $25 'percent' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _X__X___, X_X_X___, _X_X____, ___X____, __X_____, _X______, _X_X____, X_X_X___, X__X____, ________, ________, // 38 $26 'ampersand' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _X______, X_X_____, X_X_____, _X______, X_X_____, X__XX___, X__X____, _XX_X___, ________, ________, ________, // 39 $27 'quoteright' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __XX____, __X_____, _X______, ________, ________, ________, ________, ________, ________, ________, ________, // 40 $28 'parenleft' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ___X____, __X_____, __X_____, _X______, _X______, _X______, __X_____, __X_____, ___X____, ________, ________, // 41 $29 'parenright' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _X______, __X_____, __X_____, ___X____, ___X____, ___X____, __X_____, __X_____, _X______, ________, ________, // 42 $2a 'asterisk' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, __X_____, X_X_X___, XXXXX___, _XXX____, XXXXX___, X_X_X___, __X_____, ________, ________, ________, // 43 $2b 'plus' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, __X_____, __X_____, XXXXX___, __X_____, __X_____, ________, ________, ________, ________, // 44 $2c 'comma' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, __XX____, __X_____, _X______, ________, // 45 $2d 'hyphen' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, XXXXX___, ________, ________, ________, ________, ________, ________, // 46 $2e 'period' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, __X_____, _XXX____, __X_____, ________, // 47 $2f 'slash' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ____X___, ____X___, ___X____, ___X____, __X_____, _X______, _X______, X_______, X_______, ________, ________, // 48 $30 'zero' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, _X_X____, X___X___, X___X___, X___X___, X___X___, X___X___, _X_X____, __X_____, ________, ________, // 49 $31 'one' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, _XX_____, X_X_____, __X_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 50 $32 'two' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X___X___, ____X___, ___X____, __X_____, _X______, X_______, XXXXX___, ________, ________, // 51 $33 'three' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXXX___, ____X___, ___X____, __X_____, _XXX____, ____X___, ____X___, X___X___, _XXX____, ________, ________, // 52 $34 'four' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ___X____, ___X____, __XX____, _X_X____, _X_X____, X__X____, XXXXX___, ___X____, ___X____, ________, ________, // 53 $35 'five' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXXX___, X_______, X_______, X_XX____, XX__X___, ____X___, ____X___, X___X___, _XXX____, ________, ________, // 54 $36 'six' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X_______, X_______, XXXX____, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 55 $37 'seven' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXXX___, ____X___, ___X____, ___X____, __X_____, __X_____, _X______, _X______, _X______, ________, ________, // 56 $38 'eight' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X___X___, X___X___, _XXX____, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 57 $39 'nine' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X___X___, X___X___, _XXXX___, ____X___, ____X___, X___X___, _XXX____, ________, ________, // 58 $3a 'colon' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, __X_____, _XXX____, __X_____, ________, ________, __X_____, _XXX____, __X_____, ________, // 59 $3b 'semicolon' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, __X_____, _XXX____, __X_____, ________, ________, __XX____, __X_____, _X______, ________, // 60 $3c 'less' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ____X___, ___X____, __X_____, _X______, X_______, _X______, __X_____, ___X____, ____X___, ________, ________, // 61 $3d 'equal' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, XXXXX___, ________, ________, XXXXX___, ________, ________, ________, ________, // 62 $3e 'greater' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X_______, _X______, __X_____, ___X____, ____X___, ___X____, __X_____, _X______, X_______, ________, ________, // 63 $3f 'question' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X___X___, ____X___, ___X____, __X_____, __X_____, ________, __X_____, ________, ________, // 64 $40 'at' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X___X___, X__XX___, X_X_X___, X_X_X___, X_XX____, X_______, _XXXX___, ________, ________, // 65 $41 'A' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, _X_X____, X___X___, X___X___, X___X___, XXXXX___, X___X___, X___X___, X___X___, ________, ________, // 66 $42 'B' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXX____, _X__X___, _X__X___, _X__X___, _XXX____, _X__X___, _X__X___, _X__X___, XXXX____, ________, ________, // 67 $43 'C' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X_______, X_______, X_______, X_______, X_______, X___X___, _XXX____, ________, ________, // 68 $44 'D' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXX____, _X__X___, _X__X___, _X__X___, _X__X___, _X__X___, _X__X___, _X__X___, XXXX____, ________, ________, // 69 $45 'E' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXXX___, X_______, X_______, X_______, XXXX____, X_______, X_______, X_______, XXXXX___, ________, ________, // 70 $46 'F' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXXX___, X_______, X_______, X_______, XXXX____, X_______, X_______, X_______, X_______, ________, ________, // 71 $47 'G' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X_______, X_______, X_______, X__XX___, X___X___, X___X___, _XXX____, ________, ________, // 72 $48 'H' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, X___X___, X___X___, XXXXX___, X___X___, X___X___, X___X___, X___X___, ________, ________, // 73 $49 'I' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, _XXX____, ________, ________, // 74 $4a 'J' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __XXX___, ___X____, ___X____, ___X____, ___X____, ___X____, ___X____, X__X____, _XX_____, ________, ________, // 75 $4b 'K' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, X__X____, X_X_____, XX______, X_X_____, X__X____, X___X___, X___X___, ________, ________, // 76 $4c 'L' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X_______, X_______, X_______, X_______, X_______, X_______, X_______, X_______, XXXXX___, ________, ________, // 77 $4d 'M' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, XX_XX___, X_X_X___, X_X_X___, X___X___, X___X___, X___X___, X___X___, ________, ________, // 78 $4e 'N' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, XX__X___, XX__X___, X_X_X___, X_X_X___, X__XX___, X__XX___, X___X___, X___X___, ________, ________, // 79 $4f 'O' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 80 $50 'P' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXX____, X___X___, X___X___, X___X___, XXXX____, X_______, X_______, X_______, X_______, ________, ________, // 81 $51 'Q' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, X_X_X___, _XXX____, ____X___, ________, // 82 $52 'R' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXX____, X___X___, X___X___, X___X___, XXXX____, X_X_____, X__X____, X___X___, X___X___, ________, ________, // 83 $53 'S' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X_______, X_______, _XXX____, ____X___, ____X___, X___X___, _XXX____, ________, ________, // 84 $54 'T' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXXX___, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, ________, ________, // 85 $55 'U' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 86 $56 'V' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, X___X___, X___X___, _X_X____, _X_X____, _X_X____, __X_____, __X_____, ________, ________, // 87 $57 'W' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, X___X___, X___X___, X_X_X___, X_X_X___, X_X_X___, XX_XX___, X___X___, ________, ________, // 88 $58 'X' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, _X_X____, _X_X____, __X_____, _X_X____, _X_X____, X___X___, X___X___, ________, ________, // 89 $59 'Y' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, _X_X____, _X_X____, __X_____, __X_____, __X_____, __X_____, __X_____, ________, ________, // 90 $5a 'Z' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXXX___, ____X___, ___X____, ___X____, __X_____, _X______, _X______, X_______, XXXXX___, ________, ________, // 91 $5b 'braketleft' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, _X______, _X______, _X______, _X______, _X______, _X______, _X______, _XXX____, ________, ________, // 92 $5c 'backslash' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X_______, X_______, _X______, _X______, __X_____, ___X____, ___X____, ____X___, ____X___, ________, ________, // 93 $5d 'bracketright' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, ___X____, ___X____, ___X____, ___X____, ___X____, ___X____, ___X____, _XXX____, ________, ________, // 94 $5e 'asciicircum' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, _X_X____, X___X___, ________, ________, ________, ________, ________, ________, ________, ________, // 95 $5f 'underscore' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, XXXXX___, ________, // 96 $60 'quoteleft' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __XX____, ___X____, ____X___, ________, ________, ________, ________, ________, ________, ________, ________, // 97 $61 'a' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXX____, ____X___, _XXXX___, X___X___, X___X___, _XXXX___, ________, ________, // 98 $62 'b' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X_______, X_______, X_______, XXXX____, X___X___, X___X___, X___X___, X___X___, XXXX____, ________, ________, // 99 $63 'c' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXX____, X___X___, X_______, X_______, X___X___, _XXX____, ________, ________, // 100 $64 'd' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ____X___, ____X___, ____X___, _XXXX___, X___X___, X___X___, X___X___, X___X___, _XXXX___, ________, ________, // 101 $65 'e' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXX____, X___X___, XXXXX___, X_______, X___X___, _XXX____, ________, ________, // 102 $66 'f' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __XX____, _X__X___, _X______, _X______, XXXX____, _X______, _X______, _X______, _X______, ________, ________, // 103 $67 'g' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXX____, X___X___, X___X___, X___X___, _XXXX___, ____X___, X___X___, _XXX____, // 104 $68 'h' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X_______, X_______, X_______, X_XX____, XX__X___, X___X___, X___X___, X___X___, X___X___, ________, ________, // 105 $69 'i' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, __X_____, ________, _XX_____, __X_____, __X_____, __X_____, __X_____, _XXX____, ________, ________, // 106 $6a 'j' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ___X____, ________, __XX____, ___X____, ___X____, ___X____, ___X____, X__X____, X__X____, _XX_____, // 107 $6b 'k' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X_______, X_______, X_______, X__X____, X_X_____, XX______, X_X_____, X__X____, X___X___, ________, ________, // 108 $6c 'l' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XX_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, _XXX____, ________, ________, // 109 $6d 'm' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, XX_X____, X_X_X___, X_X_X___, X_X_X___, X_X_X___, X___X___, ________, ________, // 110 $6e 'n' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X_XX____, XX__X___, X___X___, X___X___, X___X___, X___X___, ________, ________, // 111 $6f 'o' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 112 $70 'p' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, XXXX____, X___X___, X___X___, X___X___, XXXX____, X_______, X_______, X_______, // 113 $71 'q' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXXX___, X___X___, X___X___, X___X___, _XXXX___, ____X___, ____X___, ____X___, // 114 $72 'r' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X_XX____, XX__X___, X_______, X_______, X_______, X_______, ________, ________, // 115 $73 's' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXX____, X___X___, _XX_____, ___X____, X___X___, _XXX____, ________, ________, // 116 $74 't' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, _X______, _X______, XXXX____, _X______, _X______, _X______, _X__X___, __XX____, ________, ________, // 117 $75 'u' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X___X___, X___X___, X___X___, X___X___, X__XX___, _XX_X___, ________, ________, // 118 $76 'v' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X___X___, X___X___, X___X___, _X_X____, _X_X____, __X_____, ________, ________, // 119 $77 'w' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X___X___, X___X___, X_X_X___, X_X_X___, X_X_X___, _X_X____, ________, ________, // 120 $78 'x' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X___X___, _X_X____, __X_____, __X_____, _X_X____, X___X___, ________, ________, // 121 $79 'y' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X___X___, X___X___, X___X___, X__XX___, _XX_X___, ____X___, X___X___, _XXX____, // 122 $7a 'z' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, XXXXX___, ___X____, __X_____, _X______, X_______, XXXXX___, ________, ________, // 123 $7b 'braceleft' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ___XX___, __X_____, __X_____, __X_____, XX______, __X_____, __X_____, __X_____, ___XX___, ________, ________, // 124 $7c 'bar' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, ________, ________, // 125 $7d 'braceright' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XX______, __X_____, __X_____, __X_____, ___XX___, __X_____, __X_____, __X_____, XX______, ________, ________, // 126 $7e 'asciitilde' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _X__X___, X_X_X___, X__X____, ________, ________, ________, ________, ________, ________, ________, ________, // 127 $7f 'ascii177' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, // 160 $a0 '00a0' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, // 161 $a1 '00a1' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, ________, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, __X_____, ________, ________, // 162 $a2 '00a2' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, _XXX____, X_X_X___, X_X_____, X_X_____, X_X_X___, _XXX____, __X_____, ________, ________, ________, // 163 $a3 '00a3' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __XX____, _X__X___, _X______, _X______, XXX_____, _X______, _X______, _X__X___, X_XX____, ________, ________, // 164 $a4 '00a4' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, X___X___, _XXX____, _X_X____, _X_X____, _XXX____, X___X___, ________, ________, ________, // 165 $a5 '00a5' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X___X___, X___X___, _X_X____, _X_X____, XXXXX___, __X_____, XXXXX___, __X_____, __X_____, ________, ________, // 166 $a6 '00a6' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, __X_____, __X_____, __X_____, ________, __X_____, __X_____, __X_____, __X_____, ________, ________, // 167 $a7 '00a7' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, _X______, __XX____, _X__X___, _X__X___, __XX____, ____X___, _X__X___, __XX____, ________, ________, // 168 $a8 '00a8' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XX_XX___, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, // 169 $a9 '00a9' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _XXX____, X___X___, X_X_X___, XX_XX___, XX__X___, XX_XX___, X_X_X___, X___X___, _XXX____, ________, ________, ________, // 170 $aa '00aa' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, ____X___, _XXXX___, X___X___, _XXXX___, ________, XXXXX___, ________, ________, ________, ________, // 171 $ab '00ab' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, __X_X___, _X_X____, X_X_____, X_X_____, _X_X____, __X_X___, ________, ________, ________, // 172 $ac '00ac' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, XXXXX___, ____X___, ____X___, ________, ________, ________, ________, // 173 $ad '00ad' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, XXXXX___, ________, ________, ________, ________, ________, ________, // 174 $ae '00ae' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _XXX____, X___X___, XXX_X___, XX_XX___, XX_XX___, XXX_X___, XX_XX___, X___X___, _XXX____, ________, ________, ________, // 175 $af '00af' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXXX___, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, // 176 $b0 '00b0' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __XX____, _X__X___, _X__X___, __XX____, ________, ________, ________, ________, ________, ________, ________, // 177 $b1 '00b1' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, __X_____, __X_____, XXXXX___, __X_____, __X_____, ________, XXXXX___, ________, ________, ________, // 178 $b2 '00b2' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X______, X_X_____, __X_____, _X______, XXX_____, ________, ________, ________, ________, ________, ________, ________, // 179 $b3 '00b3' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X______, X_X_____, _X______, __X_____, XX______, ________, ________, ________, ________, ________, ________, ________, // 180 $b4 '00b4' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, // 181 $b5 '00b5' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X___X___, X___X___, X___X___, X___X___, X__XX___, XXX_X___, X_______, ________, // 182 $b6 '00b6' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXXX___, XXX_X___, XXX_X___, XXX_X___, XXX_X___, _XX_X___, __X_X___, __X_X___, __X_X___, ________, ________, // 183 $b7 '00b7' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, __XX____, ________, ________, ________, ________, ________, ________, // 184 $b8 '00b8' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ___X____, __X_____, // 185 $b9 '00b9' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X______, XX______, _X______, _X______, XXX_____, ________, ________, ________, ________, ________, ________, ________, // 186 $ba '00ba' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __XX____, _X__X___, _X__X___, __XX____, ________, _XXXX___, ________, ________, ________, ________, ________, // 187 $bb '00bb' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, X_X_____, _X_X____, __X_X___, __X_X___, _X_X____, X_X_____, ________, ________, ________, // 188 $bc '00bc' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X______, XX______, _X______, _X______, XXX_____, ____X___, ___XX___, __X_X___, __XXX___, ____X___, ________, ________, // 189 $bd '00bd' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X______, XX______, _X______, _X______, XXX_____, ___X____, __X_X___, ____X___, ___X____, __XXX___, ________, ________, // 190 $be '00be' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X______, X_X_____, _X______, __X_____, X_X_____, _X__X___, ___XX___, __X_X___, __XXX___, ____X___, ________, ________, // 191 $bf '00bf' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, __X_____, ________, __X_____, __X_____, _X______, X_______, X___X___, X___X___, _XXX____, ________, ________, // 192 $c0 '00c0' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, __X_____, _X_X____, X___X___, X___X___, XXXXX___, X___X___, X___X___, ________, ________, // 193 $c1 '00c1' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, __X_____, _X_X____, X___X___, X___X___, XXXXX___, X___X___, X___X___, ________, ________, // 194 $c2 '00c2' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, __X_____, _X_X____, X___X___, X___X___, XXXXX___, X___X___, X___X___, ________, ________, // 195 $c3 '00c3' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_X___, _X_X____, ________, __X_____, _X_X____, X___X___, X___X___, XXXXX___, X___X___, X___X___, ________, ________, // 196 $c4 '00c4' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, __X_____, _X_X____, X___X___, X___X___, XXXXX___, X___X___, X___X___, ________, ________, // 197 $c5 '00c5' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, _X_X____, __X_____, __X_____, _X_X____, X___X___, X___X___, XXXXX___, X___X___, X___X___, ________, ________, // 198 $c6 '00c6' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _X_XX___, X_X_____, X_X_____, X_X_____, X_XX____, XXX_____, X_X_____, X_X_____, X_XXX___, ________, ________, // 199 $c7 '00c7' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, _XXX____, X___X___, X_______, X_______, X_______, X_______, X_______, X___X___, _XXX____, __X_____, _X______, // 200 $c8 '00c8' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, XXXXX___, X_______, X_______, XXXX____, X_______, X_______, XXXXX___, ________, ________, // 201 $c9 '00c9' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, XXXXX___, X_______, X_______, XXXX____, X_______, X_______, XXXXX___, ________, ________, // 202 $ca '00ca' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _XX_____, X__X____, ________, XXXXX___, X_______, X_______, XXXX____, X_______, X_______, XXXXX___, ________, ________, // 203 $cb '00cb' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, XXXXX___, X_______, X_______, XXXX____, X_______, X_______, XXXXX___, ________, ________, // 204 $cc '00cc' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, XXXXX___, __X_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 205 $cd '00cd' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, XXXXX___, __X_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 206 $ce '00ce' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, XXXXX___, __X_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 207 $cf '00cf' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, XXXXX___, __X_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 208 $d0 '00d0' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, XXXX____, _X__X___, _X__X___, _X__X___, XXX_X___, _X__X___, _X__X___, _X__X___, XXXX____, ________, ________, // 209 $d1 '00d1' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_X___, _X_X____, ________, X___X___, X___X___, XX__X___, X_X_X___, X__XX___, X___X___, X___X___, ________, ________, // 210 $d2 '00d2' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 211 $d3 '00d3' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 212 $d4 '00d4' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 213 $d5 '00d5' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_X___, _X_X____, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 214 $d6 '00d6' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 215 $d7 '00d7' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, X___X___, _X_X____, __X_____, _X_X____, X___X___, ________, ________, ________, // 216 $d8 '00d8' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ____X___, _XXX____, X__XX___, X__XX___, X_X_X___, X_X_X___, X_X_X___, XX__X___, XX__X___, _XXX____, X_______, ________, // 217 $d9 '00d9' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 218 $da '00da' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 219 $db '00db' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 220 $dc '00dc' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, X___X___, X___X___, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 221 $dd '00dd' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, X___X___, X___X___, _X_X____, __X_____, __X_____, __X_____, __X_____, ________, ________, // 222 $de '00de' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, X_______, XXXX____, X___X___, X___X___, X___X___, XXXX____, X_______, X_______, X_______, ________, ________, // 223 $df '00df' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, _XXX____, X___X___, X___X___, XXXX____, X___X___, X___X___, XX__X___, X_XX____, X_______, ________, // 224 $e0 '00e0' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, ________, _XXX____, ____X___, _XXXX___, X___X___, X__XX___, _XX_X___, ________, ________, // 225 $e1 '00e1' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, ________, _XXX____, ____X___, _XXXX___, X___X___, X__XX___, _XX_X___, ________, ________, // 226 $e2 '00e2' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, ________, _XXX____, ____X___, _XXXX___, X___X___, X__XX___, _XX_X___, ________, ________, // 227 $e3 '00e3' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_X___, _X_X____, ________, ________, _XXX____, ____X___, _XXXX___, X___X___, X__XX___, _XX_X___, ________, ________, // 228 $e4 '00e4' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, ________, _XXX____, ____X___, _XXXX___, X___X___, X__XX___, _XX_X___, ________, ________, // 229 $e5 '00e5' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, __XX____, ________, _XXX____, ____X___, _XXXX___, X___X___, X__XX___, _XX_X___, ________, ________, // 230 $e6 '00e6' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXX____, __X_X___, _XXX____, X_X_____, X_X_X___, _X_X____, ________, ________, // 231 $e7 '00e7' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ________, _XXX____, X___X___, X_______, X_______, X___X___, _XXX____, __X_____, _X______, // 232 $e8 '00e8' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, ________, _XXX____, X___X___, XXXXX___, X_______, X___X___, _XXX____, ________, ________, // 233 $e9 '00e9' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, ________, _XXX____, X___X___, XXXXX___, X_______, X___X___, _XXX____, ________, ________, // 234 $ea '00ea' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, ________, _XXX____, X___X___, XXXXX___, X_______, X___X___, _XXX____, ________, ________, // 235 $eb '00eb' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, ________, _XXX____, X___X___, XXXXX___, X_______, X___X___, _XXX____, ________, ________, // 236 $ec '00ec' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, ________, _XX_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 237 $ed '00ed' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, ________, _XX_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 238 $ee '00ee' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, ________, _XX_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 239 $ef '00ef' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, ________, _XX_____, __X_____, __X_____, __X_____, __X_____, XXXXX___, ________, ________, // 240 $f0 '00f0' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, __X_____, _XX_____, ___X____, _XXX____, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 241 $f1 '00f1' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_X___, _X_X____, ________, ________, X_XX____, XX__X___, X___X___, X___X___, X___X___, X___X___, ________, ________, // 242 $f2 '00f2' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 243 $f3 '00f3' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 244 $f4 '00f4' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 245 $f5 '00f5' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_X___, _X_X____, ________, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 246 $f6 '00f6' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, ________, _XXX____, X___X___, X___X___, X___X___, X___X___, _XXX____, ________, ________, // 247 $f7 '00f7' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, __X_____, __X_____, ________, XXXXX___, ________, __X_____, __X_____, ________, ________, ________, // 248 $f8 '00f8' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, ________, ____X___, _XXX____, X__XX___, X_X_X___, X_X_X___, XX__X___, _XXX____, X_______, ________, // 249 $f9 '00f9' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __X_____, ___X____, ________, ________, X___X___, X___X___, X___X___, X___X___, X___X___, _XXXX___, ________, ________, // 250 $fa '00fa' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, ________, X___X___, X___X___, X___X___, X___X___, X___X___, _XXXX___, ________, ________, // 251 $fb '00fb' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, __XX____, _X__X___, ________, ________, X___X___, X___X___, X___X___, X___X___, X___X___, _XXXX___, ________, ________, // 252 $fc '00fc' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, ________, X___X___, X___X___, X___X___, X___X___, X___X___, _XXXX___, ________, ________, // 253 $fd '00fd' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ___X____, __X_____, ________, ________, X___X___, X___X___, X___X___, X__XX___, _XX_X___, ____X___, X___X___, _XXX____, // 254 $fe '00fe' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, ________, ________, X_______, X_______, X_XX____, XX__X___, X___X___, X___X___, XX__X___, X_XX____, X_______, X_______, // 255 $ff '00ff' // width 6, bbx 0, bby -2, bbw 6, bbh 13 ________, _X_X____, _X_X____, ________, ________, X___X___, X___X___, X___X___, X__XX___, _XX_X___, ____X___, X___X___, _XXX____, }; /// character width for each encoding static const unsigned char __font_widths__[] = { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, }; /// character encoding for each index entry static const unsigned short __font_index__[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, }; /// bitmap font structure const struct bitmap_font font = { .Width = 6, .Height = 13, .Chars = 224, .Widths = __font_widths__, .Index = __font_index__, .Bitmap = __font_bitmap__, };
25,444
321
<filename>base/mac/scoped_launch_data.h // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_MAC_SCOPED_LAUNCH_DATA_H_ #define BASE_MAC_SCOPED_LAUNCH_DATA_H_ #include <launch.h> #include <algorithm> #include "base/basictypes.h" #include "base/compiler_specific.h" namespace base { namespace mac { // Just like scoped_ptr<> but for launch_data_t. class ScopedLaunchData { public: typedef launch_data_t element_type; explicit ScopedLaunchData(launch_data_t object = NULL) : object_(object) { } ~ScopedLaunchData() { if (object_) launch_data_free(object_); } void reset(launch_data_t object = NULL) { if (object != object_) { if (object_) launch_data_free(object_); object_ = object; } } bool operator==(launch_data_t that) const { return object_ == that; } bool operator!=(launch_data_t that) const { return object_ != that; } operator launch_data_t() const { return object_; } launch_data_t get() const { return object_; } void swap(ScopedLaunchData& that) { std::swap(object_, that.object_); } launch_data_t release() WARN_UNUSED_RESULT { launch_data_t temp = object_; object_ = NULL; return temp; } private: launch_data_t object_; DISALLOW_COPY_AND_ASSIGN(ScopedLaunchData); }; } // namespace mac } // namespace base #endif // BASE_MAC_SCOPED_LAUNCH_DATA_H_
590
695
<filename>cpp_src/estl/syncpool.h<gh_stars>100-1000 #pragma once #include <memory> #include <mutex> #include <vector> namespace reindexer { template <typename T, size_t maxPoolSize, size_t maxAllocSize = std::numeric_limits<size_t>::max()> class sync_pool { public: void put(std::unique_ptr<T> obj) { std::unique_lock<std::mutex> lck(lck_); if (pool_.size() < maxPoolSize) { pool_.emplace_back(std::move(obj)); } alloced_.fetch_sub(1, std::memory_order_relaxed); } template <typename... Args> std::unique_ptr<T> get(int usedCount, Args&&... args) { std::unique_lock<std::mutex> lck(lck_); if (alloced_.load(std::memory_order_relaxed) > maxAllocSize + usedCount) { return nullptr; } alloced_.fetch_add(1, std::memory_order_relaxed); if (pool_.empty()) { return std::unique_ptr<T>{new T(std::forward<Args>(args)...)}; } else { auto res = std::move(pool_.back()); pool_.pop_back(); return res; } } void clear() { std::unique_lock<std::mutex> lck(lck_); pool_.clear(); } size_t Alloced() const noexcept { return alloced_.load(std::memory_order_relaxed); } protected: std::atomic<size_t> alloced_ = 0; std::vector<std::unique_ptr<T>> pool_; std::mutex lck_; }; } // namespace reindexer
528
571
package de.gurkenlabs.utiliti.handlers; import de.gurkenlabs.litiengine.Game; import de.gurkenlabs.utiliti.components.Editor; import java.util.Arrays; public final class Zoom implements Comparable<Zoom> { private static final Zoom[] zooms = new Zoom[] { new Zoom(0.1f), new Zoom(0.25f), new Zoom(0.5f), new Zoom(1), new Zoom(1.5f), new Zoom(2f), new Zoom(3f), new Zoom(4f), new Zoom(5f), new Zoom(6f), new Zoom(7f), new Zoom(8f), new Zoom(9f), new Zoom(10f), new Zoom(16f), new Zoom(32f), new Zoom(50f), new Zoom(80f), new Zoom(100f) }; private static final int DEFAULT_ZOOM_INDEX = 3; private static int currentZoomIndex = DEFAULT_ZOOM_INDEX; private final float value; private Zoom(float value) { this.value = value; } public float getValue() { return value; } @Override public int compareTo(Zoom o) { return Float.compare(this.getValue(), o.getValue()); } @Override public String toString() { return String.format("%6d%%", (int) (this.getValue() * 100)); } public static void apply() { if (Game.world() == null || Game.world().camera() == null) { return; } Game.world().camera().setZoom(get(), 0); } public static void applyPreference() { set(Editor.preferences().getZoom()); } public static Zoom[] getAll() { return zooms; } /** * Matches the specified zoom with the closest zoom level that is provided by this class. * * <p>For example: 1.111f would be converted to the preset 1.0f zoom level. * * @param preference The preferred zoom. * @return The index of the matched zoom provided by this class. */ public static int match(float preference) { int index = Arrays.binarySearch(zooms, new Zoom(preference)); if (index >= 0) { return index; } index = -(index + 1); if (index == zooms.length || index > 0 && zooms[index].getValue() + zooms[index - 1].getValue() > 2 * preference) { index--; } return index; } public static void in() { if (currentZoomIndex < zooms.length - 1) { currentZoomIndex++; } apply(); } public static void out() { if (currentZoomIndex > 0) { currentZoomIndex--; } apply(); } public static float get() { return get(currentZoomIndex); } public static Zoom getZoom() { return zooms[currentZoomIndex]; } public static float get(int zoomIndex) { return zooms[zoomIndex].getValue(); } public static void set(float zoom) { currentZoomIndex = match(zoom); apply(); } public static float getMax() { return get(zooms.length - 1); } public static float getMin() { return get(0); } public static float getDefault() { return get(DEFAULT_ZOOM_INDEX); } }
1,334
1,867
package net.glowstone.entity.monster; import lombok.Getter; import lombok.Setter; import net.glowstone.entity.meta.MetadataIndex; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Evoker; import org.bukkit.entity.Sheep; import org.bukkit.entity.Spellcaster; import org.bukkit.event.entity.EntityDamageEvent; import org.jetbrains.annotations.NotNull; import java.util.concurrent.ThreadLocalRandom; public class GlowEvoker extends GlowSpellcaster implements Evoker { @Getter @Setter private Sheep wololoTarget; /** * Creates an evoker. * * @param loc the evoker's location */ public GlowEvoker(Location loc) { super(loc, EntityType.EVOKER, 24); metadata.set(MetadataIndex.EVOKER_SPELL, (byte) Spellcaster.Spell.NONE.ordinal()); setBoundingBox(0.6, 1.95); } @Override @Deprecated public Evoker.Spell getCurrentSpell() { switch (this.getSpell()) { case FANGS: return Evoker.Spell.FANGS; case BLINDNESS: return Evoker.Spell.BLINDNESS; case DISAPPEAR: return Evoker.Spell.DISAPPEAR; case SUMMON_VEX: return Evoker.Spell.SUMMON; case WOLOLO: return Evoker.Spell.WOLOLO; default: return Evoker.Spell.NONE; } } @Override @Deprecated public void setCurrentSpell(Evoker.Spell spell) { if (spell == null) { setSpell(Spellcaster.Spell.NONE); return; } switch (spell) { case FANGS: setSpell(Spellcaster.Spell.FANGS); break; case BLINDNESS: setSpell(Spellcaster.Spell.BLINDNESS); break; case DISAPPEAR: setSpell(Spellcaster.Spell.DISAPPEAR); break; case SUMMON: setSpell(Spellcaster.Spell.SUMMON_VEX); break; case WOLOLO: setSpell(Spellcaster.Spell.WOLOLO); break; default: setSpell(Spellcaster.Spell.NONE); } } @Override protected Sound getDeathSound() { return Sound.ENTITY_EVOKER_DEATH; } @Override protected Sound getHurtSound() { return Sound.ENTITY_EVOKER_HURT; } @Override public void damage(double amount, Entity source, @NotNull EntityDamageEvent.DamageCause cause) { super.damage(amount, source, cause); castSpell(Spellcaster.Spell.SUMMON_VEX); // todo: remove this, demo purposes } @Override protected Sound getAmbientSound() { return Sound.ENTITY_EVOKER_AMBIENT; } /** * Casts the given spell. * * @param spell the spell to cast */ @Override public void castSpell(Spellcaster.Spell spell) { setSpell(spell); ThreadLocalRandom random = ThreadLocalRandom.current(); switch (spell) { case FANGS: // todo break; case SUMMON_VEX: world .playSound(location, Sound.ENTITY_EVOKER_PREPARE_SUMMON, 1.0f, 1.0f); int count = 3; for (int i = 0; i < count; i++) { double y = random.nextDouble() + 0.5 + location.getY(); double radius = 0.5 + random.nextDouble(); double angle = random.nextDouble() * 2 * Math.PI; double x = radius * Math.sin(angle) + location.getX(); double z = radius * Math.cos(angle) + location.getZ(); Location location = new Location(world, x, y, z); world.spawnEntity(location, EntityType.VEX); } break; case WOLOLO: // todo break; default: // TODO: Should this raise a warning? } } }
2,067
418
<gh_stars>100-1000 // // BFRegion+CoreDataProperties.h // OpenShop // // Created by <NAME> // Copyright (c) 2015 Business Factory. All rights reserved. // #import "BFRegion.h" NS_ASSUME_NONNULL_BEGIN @interface BFRegion (CoreDataProperties) @property (nullable, nonatomic, retain) NSNumber *regionID; @property (nullable, nonatomic, retain) NSString *name; @end NS_ASSUME_NONNULL_END
142
622
# -*- coding: utf-8 -*- from __future__ import absolute_import import pytest import pycrfsuite def test_basic(): seq = pycrfsuite.ItemSequence([]) assert len(seq) == 0 assert seq.items() == [] def test_lists(): seq = pycrfsuite.ItemSequence([['foo', 'bar'], ['bar', 'baz']]) assert len(seq) == 2 assert seq.items() == [{'foo': 1.0, 'bar': 1.0}, {'bar': 1.0, 'baz': 1.0}] assert pycrfsuite.ItemSequence(seq.items()).items() == seq.items() def test_dicts(): seq = pycrfsuite.ItemSequence([ {'foo': True, 'bar': {'foo': -1, 'baz': False}}, ]) assert len(seq) == 1 assert seq.items() == [{'foo': 1.0, 'bar:foo': -1, 'bar:baz': 0.0}] def test_unicode(): seq = pycrfsuite.ItemSequence([ {'foo': u'привет', u'ключ': 1.0, u'привет': u'мир'}, ]) assert seq.items() == [{u'foo:привет': 1.0, u'ключ': 1.0, u'привет:мир': 1.0}] @pytest.mark.xfail() def test_bad(): with pytest.raises(ValueError): seq = pycrfsuite.ItemSequence('foo') print(seq.items()) with pytest.raises(ValueError): seq = pycrfsuite.ItemSequence([[{'foo': 'bar'}]]) print(seq.items()) def test_nested(): seq = pycrfsuite.ItemSequence([ { "foo": { "bar": "baz", "spam": 0.5, "egg": ["x", "y"], "ham": {"x": -0.5, "y": -0.1} }, }, { "foo": { "bar": "ham", "spam": -0.5, "ham": set(["x", "y"]) }, }, ]) assert len(seq) == 2 assert seq.items() == [ { 'foo:bar:baz': 1.0, 'foo:spam': 0.5, 'foo:egg:x': 1.0, 'foo:egg:y': 1.0, 'foo:ham:x': -0.5, 'foo:ham:y': -0.1, }, { 'foo:bar:ham': 1.0, 'foo:spam': -0.5, 'foo:ham:x': 1.0, 'foo:ham:y': 1.0, } ] assert pycrfsuite.ItemSequence(seq.items()).items() == seq.items()
1,204
12,560
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dubbo.remoting.transport.netty4; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.url.component.ServiceConfigURL; import org.apache.dubbo.remoting.ChannelHandler; import org.apache.dubbo.remoting.RemotingException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.net.InetSocketAddress; public class NettyChannelTest { private Channel channel = Mockito.mock(Channel.class); private URL url = new ServiceConfigURL("dubbo", "127.0.0.1", 8080); private ChannelHandler channelHandler = Mockito.mock(ChannelHandler.class); @Test public void test() throws Exception { Channel channel = Mockito.mock(Channel.class); Mockito.when(channel.isActive()).thenReturn(true); URL url = URL.valueOf("test://127.0.0.1/test"); ChannelHandler channelHandler = Mockito.mock(ChannelHandler.class); NettyChannel nettyChannel = NettyChannel.getOrAddChannel(channel, url, channelHandler); Assertions.assertEquals(nettyChannel.getChannelHandler(), channelHandler); Assertions.assertTrue(nettyChannel.isActive()); NettyChannel.removeChannel(channel); Assertions.assertFalse(nettyChannel.isActive()); nettyChannel = NettyChannel.getOrAddChannel(channel, url, channelHandler); Mockito.when(channel.isActive()).thenReturn(false); NettyChannel.removeChannelIfDisconnected(channel); Assertions.assertFalse(nettyChannel.isActive()); nettyChannel = NettyChannel.getOrAddChannel(channel, url, channelHandler); Assertions.assertFalse(nettyChannel.isConnected()); nettyChannel = NettyChannel.getOrAddChannel(channel, url, channelHandler); nettyChannel.markActive(true); Assertions.assertTrue(nettyChannel.isActive()); } @Test public void testAddress() { NettyChannel nettyChannel = NettyChannel.getOrAddChannel(channel, url, channelHandler); InetSocketAddress localAddress = InetSocketAddress.createUnresolved("127.0.0.1", 8888); InetSocketAddress remoteAddress = InetSocketAddress.createUnresolved("127.0.0.1", 9999); Mockito.when(channel.localAddress()).thenReturn(localAddress); Mockito.when(channel.remoteAddress()).thenReturn(remoteAddress); Assertions.assertEquals(nettyChannel.getLocalAddress(), localAddress); Assertions.assertEquals(nettyChannel.getRemoteAddress(), remoteAddress); } @Test public void testSend() throws Exception { NettyChannel nettyChannel = NettyChannel.getOrAddChannel(channel, url, channelHandler); ChannelFuture future = Mockito.mock(ChannelFuture.class); Mockito.when(future.await(1000)).thenReturn(true); Mockito.when(future.cause()).thenReturn(null); Mockito.when(channel.writeAndFlush(Mockito.any())).thenReturn(future); nettyChannel.send("msg", true); NettyChannel finalNettyChannel = nettyChannel; Exception exception = Mockito.mock(Exception.class); Mockito.when(exception.getMessage()).thenReturn("future cause"); Mockito.when(future.cause()).thenReturn(exception); Assertions.assertThrows(RemotingException.class, () -> { finalNettyChannel.send("msg", true); }, "future cause"); Mockito.when(future.await(1000)).thenReturn(false); Mockito.when(future.cause()).thenReturn(null); Assertions.assertThrows(RemotingException.class, () -> { finalNettyChannel.send("msg", true); }, "in timeout(1000ms) limit"); } @Test public void testAttribute() { NettyChannel nettyChannel = NettyChannel.getOrAddChannel(channel, url, channelHandler); nettyChannel.setAttribute("k1", "v1"); Assertions.assertTrue(nettyChannel.hasAttribute("k1")); Assertions.assertEquals(nettyChannel.getAttribute("k1"), "v1"); nettyChannel.removeAttribute("k1"); Assertions.assertFalse(nettyChannel.hasAttribute("k1")); } @Test public void testEquals() { Channel channel2 = Mockito.mock(Channel.class); NettyChannel nettyChannel = NettyChannel.getOrAddChannel(channel, url, channelHandler); NettyChannel nettyChannel2 = NettyChannel.getOrAddChannel(channel2, url, channelHandler); Assertions.assertEquals(nettyChannel, nettyChannel); Assertions.assertNotEquals(nettyChannel, nettyChannel2); } }
1,887
4,269
<filename>ribbon-loadbalancer/src/main/java/com/netflix/loadbalancer/ZoneAvoidancePredicate.java /* * * Copyright 2013 Netflix, 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. * */ package com.netflix.loadbalancer; import com.netflix.client.config.CommonClientConfigKey; import com.netflix.client.config.IClientConfig; import com.netflix.client.config.IClientConfigKey; import com.netflix.client.config.Property; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import java.util.Map; import java.util.Set; /** * A server predicate that filters out all servers in a worst zone if the aggregated metric for that zone reaches a threshold. * The logic to determine the worst zone is described in class {@link ZoneAwareLoadBalancer}. * * @author awang * */ public class ZoneAvoidancePredicate extends AbstractServerPredicate { private static final Logger logger = LoggerFactory.getLogger(ZoneAvoidancePredicate.class); private static final IClientConfigKey<Double> TRIGGERING_LOAD_PER_SERVER_THRESHOLD = new CommonClientConfigKey<Double>( "ZoneAwareNIWSDiscoveryLoadBalancer.%s.triggeringLoadPerServerThreshold", 0.2d) {}; private static final IClientConfigKey<Double> AVOID_ZONE_WITH_BLACKOUT_PERCENTAGE = new CommonClientConfigKey<Double>( "ZoneAwareNIWSDiscoveryLoadBalancer.%s.avoidZoneWithBlackoutPercetage", 0.99999d) {}; private static final IClientConfigKey<Boolean> ENABLED = new CommonClientConfigKey<Boolean>( "niws.loadbalancer.zoneAvoidanceRule.enabled", true) {}; private Property<Double> triggeringLoad = Property.of(TRIGGERING_LOAD_PER_SERVER_THRESHOLD.defaultValue()); private Property<Double> triggeringBlackoutPercentage = Property.of(AVOID_ZONE_WITH_BLACKOUT_PERCENTAGE.defaultValue()); private Property<Boolean> enabled = Property.of(ENABLED.defaultValue()); public ZoneAvoidancePredicate(IRule rule, IClientConfig clientConfig) { super(rule); initDynamicProperties(clientConfig); } public ZoneAvoidancePredicate(LoadBalancerStats lbStats, IClientConfig clientConfig) { super(lbStats); initDynamicProperties(clientConfig); } ZoneAvoidancePredicate(IRule rule) { super(rule); } private void initDynamicProperties(IClientConfig clientConfig) { if (clientConfig != null) { enabled = clientConfig.getGlobalProperty(ENABLED); triggeringLoad = clientConfig.getGlobalProperty(TRIGGERING_LOAD_PER_SERVER_THRESHOLD.format(clientConfig.getClientName())); triggeringBlackoutPercentage = clientConfig.getGlobalProperty(AVOID_ZONE_WITH_BLACKOUT_PERCENTAGE.format(clientConfig.getClientName())); } } @Override public boolean apply(@Nullable PredicateKey input) { if (!enabled.getOrDefault()) { return true; } String serverZone = input.getServer().getZone(); if (serverZone == null) { // there is no zone information from the server, we do not want to filter // out this server return true; } LoadBalancerStats lbStats = getLBStats(); if (lbStats == null) { // no stats available, do not filter return true; } if (lbStats.getAvailableZones().size() <= 1) { // only one zone is available, do not filter return true; } Map<String, ZoneSnapshot> zoneSnapshot = ZoneAvoidanceRule.createSnapshot(lbStats); if (!zoneSnapshot.keySet().contains(serverZone)) { // The server zone is unknown to the load balancer, do not filter it out return true; } logger.debug("Zone snapshots: {}", zoneSnapshot); Set<String> availableZones = ZoneAvoidanceRule.getAvailableZones(zoneSnapshot, triggeringLoad.getOrDefault(), triggeringBlackoutPercentage.getOrDefault()); logger.debug("Available zones: {}", availableZones); if (availableZones != null) { return availableZones.contains(input.getServer().getZone()); } else { return false; } } }
1,676
335
{ "word": "Coffee", "definitions": [ "A hot drink made from the roasted and ground seeds (coffee beans) of a tropical shrub.", "A cup of coffee.", "Coffee seeds roasted and ground, or a powder made from them.", "A pale brown colour like that of milky coffee.", "The shrub which yields coffee seeds, native to the Old World tropics." ], "parts-of-speech": "Noun" }
157
3,139
/* * Copyright (c) 2009-2014 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'jMonkeyEngine' nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jme3.renderer.opengl; /** * Describes an OpenGL image format. * * @author <NAME> */ public final class GLImageFormat { public final int internalFormat; public final int format; public final int dataType; public final boolean compressed; public final boolean swizzleRequired; /** * Constructor for formats. * * @param internalFormat OpenGL internal format * @param format OpenGL format * @param dataType OpenGL datatype */ public GLImageFormat(int internalFormat, int format, int dataType) { this.internalFormat = internalFormat; this.format = format; this.dataType = dataType; this.compressed = false; this.swizzleRequired = false; } /** * Constructor for formats. * * @param internalFormat OpenGL internal format * @param format OpenGL format * @param dataType OpenGL datatype * @param compressed Format is compressed */ public GLImageFormat(int internalFormat, int format, int dataType, boolean compressed) { this.internalFormat = internalFormat; this.format = format; this.dataType = dataType; this.compressed = compressed; this.swizzleRequired = false; } /** * Constructor for formats. * * @param internalFormat OpenGL internal format * @param format OpenGL format * @param dataType OpenGL datatype * @param compressed Format is compressed * @param swizzleRequired Need to use texture swizzle to upload texture */ public GLImageFormat(int internalFormat, int format, int dataType, boolean compressed, boolean swizzleRequired) { this.internalFormat = internalFormat; this.format = format; this.dataType = dataType; this.compressed = compressed; this.swizzleRequired = swizzleRequired; } }
1,112
1,069
<gh_stars>1000+ # coding: utf-8 from django.db import models from django_th.models.services import Services from django_th.models import TriggerService class Joplin(Services): """ joplin model to be adapted for the new service """ folder = models.TextField() trigger = models.ForeignKey(TriggerService, on_delete=models.CASCADE) class Meta: app_label = 'th_joplin' db_table = 'django_th_joplin' def __str__(self): return self.name def show(self): return "My Joplin %s" % self.name
221
852
<gh_stars>100-1000 #include "DataFormats/L1TMuon/interface/EMTFRoad.h" namespace l1t {} // End namespace l1t
46
689
/** * 输入两个单向链表,找出它们的第一个公共结点。 */ public class No37 { public static void main(String[] args) { ListNode head1 = new ListNode(); ListNode second1 = new ListNode(); ListNode third1 = new ListNode(); ListNode forth1 = new ListNode(); ListNode fifth1 = new ListNode(); ListNode head2 = new ListNode(); ListNode second2 = new ListNode(); ListNode third2 = new ListNode(); ListNode forth2 = new ListNode(); head1.nextNode = second1; second1.nextNode = third1; third1.nextNode = forth1; forth1.nextNode = fifth1; head2.nextNode = second2; second2.nextNode = forth1; third2.nextNode = fifth1; head1.data = 1; second1.data = 2; third1.data = 3; forth1.data = 6; fifth1.data = 7; head2.data = 4; second2.data = 5; third2.data = 6; forth2.data = 7; System.out.println(findFirstCommonNode(head1, head2).data); } public static ListNode findFirstCommonNode(ListNode head1, ListNode head2) { int len1 = getListLength(head1); int len2 = getListLength(head2); ListNode longListNode = null; ListNode shortListNode = null; int dif = 0; if (len1 > len2) { longListNode = head1; shortListNode = head2; dif = len1 - len2; } else { longListNode = head2; shortListNode = head1; dif = len2 - len1; } for (int i = 0; i < dif; i++) { longListNode = longListNode.nextNode; } while (longListNode != null && shortListNode != null && longListNode != shortListNode) { longListNode = longListNode.nextNode; shortListNode = shortListNode.nextNode; } return longListNode; } private static int getListLength(ListNode head1) { int result = 0; if (head1 == null) return result; ListNode point = head1; while (point != null) { point = point.nextNode; result++; } return result; } } class ListNode { int data; ListNode nextNode; }
1,125
984
// // MTFTestScreen.h // Motif // // Created by <NAME> on 1/10/16. // Copyright © 2016 <NAME>. All rights reserved. // @import UIKit; NS_ASSUME_NONNULL_BEGIN extern CGFloat MTFTestScreenBrightness; @interface MTFTestScreen : UIScreen - (CGFloat)brightness; @end NS_ASSUME_NONNULL_END
123
338
<gh_stars>100-1000 /* * Copyright (C) 2013 YIXIA.COM * * 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. */ package io.vov.vitamio.activity; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.WindowManager; import io.vov.vitamio.Vitamio; import java.lang.ref.WeakReference; public class InitActivity extends Activity { public static final String FROM_ME = "fromVitamioInitActivity"; private ProgressDialog mPD; private UIHandler uiHandler; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); uiHandler = new UIHandler(this); new AsyncTask<Object, Object, Boolean>() { @Override protected void onPreExecute() { mPD = new ProgressDialog(InitActivity.this); mPD.setCancelable(false); mPD.setMessage(InitActivity.this.getString(getResources().getIdentifier("vitamio_init_decoders", "string", getPackageName()))); mPD.show(); } @Override protected Boolean doInBackground(Object... params) { return Vitamio.initialize(InitActivity.this, getResources().getIdentifier("libarm", "raw", getPackageName())); } @Override protected void onPostExecute(Boolean inited) { if (inited) { uiHandler.sendEmptyMessage(0); } } }.execute(); } private static class UIHandler extends Handler { private WeakReference<Context> mContext; public UIHandler(Context c) { mContext = new WeakReference<Context>(c); } public void handleMessage(Message msg) { InitActivity ctx = (InitActivity) mContext.get(); switch (msg.what) { case 0: ctx.mPD.dismiss(); Intent src = ctx.getIntent(); Intent i = new Intent(); i.setClassName(src.getStringExtra("package"), src.getStringExtra("className")); i.setData(src.getData()); i.putExtras(src); i.putExtra(FROM_ME, true); ctx.startActivity(i); ctx.finish(); break; } } } }
1,038
372
<gh_stars>100-1000 // // MacBookComputer.h // AFPDemo // // Created by <NAME> on 2018/10/3. // Copyright © 2018年 Sunshijie. All rights reserved. // #import "Computer.h" @interface MacBookComputer : Computer @end
81
22,779
/* * DBeaver - Universal Database Manager * Copyright (C) 2010-2021 DBeaver Corp and others * * 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. */ package org.jkiss.dbeaver.ext.athena.model; import org.jkiss.code.NotNull; import org.jkiss.code.Nullable; import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.ext.generic.model.GenericTableBase; import org.jkiss.dbeaver.ext.generic.model.GenericView; import org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel; import org.jkiss.dbeaver.model.DBPErrorAssistant; import org.jkiss.dbeaver.model.DBPEvaluationContext; import org.jkiss.dbeaver.model.DBUtils; import org.jkiss.dbeaver.model.exec.DBCQueryTransformProvider; import org.jkiss.dbeaver.model.exec.DBCQueryTransformType; import org.jkiss.dbeaver.model.exec.DBCQueryTransformer; import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement; import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet; import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession; import org.jkiss.dbeaver.model.impl.sql.QueryTransformerLimit; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.utils.CommonUtils; import java.sql.SQLException; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Athena meta model */ public class AthenaMetaModel extends GenericMetaModel implements DBCQueryTransformProvider { private Pattern ERROR_POSITION_PATTERN = Pattern.compile(" line ([0-9]+)\\:([0-9]+)"); private static final String TABLE_DDL = "SHOW CREATE TABLE "; private static final String VIEW_DDL = "SHOW CREATE VIEW "; public AthenaMetaModel() { } @Nullable @Override public DBCQueryTransformer createQueryTransformer(@NotNull DBCQueryTransformType type) { if (type == DBCQueryTransformType.RESULT_SET_LIMIT) { return new QueryTransformerLimit(false); } return null; } @Override public String getTableDDL(DBRProgressMonitor monitor, GenericTableBase sourceObject, Map<String, Object> options) throws DBException { return getObjectDDL(monitor, sourceObject, options, TABLE_DDL); } @Override public boolean supportsTableDDLSplit(GenericTableBase sourceObject) { return false; } @Override public String getViewDDL(DBRProgressMonitor monitor, GenericView sourceObject, Map<String, Object> options) throws DBException { return getObjectDDL(monitor, sourceObject, options, VIEW_DDL); } @Override public DBPErrorAssistant.ErrorPosition getErrorPosition(@NotNull Throwable error) { String message = error.getMessage(); if (!CommonUtils.isEmpty(message)) { Matcher matcher = ERROR_POSITION_PATTERN.matcher(message); if (matcher.find()) { DBPErrorAssistant.ErrorPosition pos = new DBPErrorAssistant.ErrorPosition(); pos.line = Integer.parseInt(matcher.group(1)) - 1; pos.position = Integer.parseInt(matcher.group(2)) - 1; return pos; } } return null; } @Override public boolean isSchemasOptional() { return false; } private String getObjectDDL(DBRProgressMonitor monitor, GenericTableBase sourceObject, Map<String, Object> options, String ddlStatement) throws DBException { try (JDBCSession session = DBUtils.openMetaSession(monitor, sourceObject, "Read Athena object DDL")) { try (JDBCPreparedStatement dbStat = session.prepareStatement( ddlStatement + " " + sourceObject.getFullyQualifiedName(DBPEvaluationContext.DDL))) { try (JDBCResultSet dbResult = dbStat.executeQuery()) { StringBuilder sql = new StringBuilder(); while (dbResult.nextRow()) { sql.append(dbResult.getString(1)).append("\n"); } return sql.toString(); } } } catch (SQLException e) { throw new DBException(e, sourceObject.getDataSource()); } } }
1,726
521
<filename>third_party/virtualbox/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/Xen.h /** @file Ovmf info structure passed by Xen Copyright (c) 2013, Citrix Systems UK Ltd.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #ifndef __XEN_H__ #define __XEN_H__ #include <PiPei.h> // Physical address of OVMF info #define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000 // This structure must match the definition on Xen side #pragma pack(1) typedef struct { CHAR8 Signature[14]; // XenHVMOVMF\0 UINT8 Length; // Length of this structure UINT8 Checksum; // Set such that the sum over bytes 0..length == 0 // // Physical address of an array of TablesCount elements. // // Each element contains the physical address of a BIOS table. // EFI_PHYSICAL_ADDRESS Tables; UINT32 TablesCount; // // Physical address of the E820 table, contains E820EntriesCount entries. // EFI_PHYSICAL_ADDRESS E820; UINT32 E820EntriesCount; } EFI_XEN_OVMF_INFO; #pragma pack() #endif /* __XEN_H__ */
472
409
#include "pch.h" #include "Class.h" #include "ClassBoth.g.cpp" #include "ClassSta.g.cpp" #include "ClassMta.g.cpp" namespace winrt::TestComponent::implementation { int32_t ClassBoth::Apartment() { APTTYPE aptType; APTTYPEQUALIFIER aptQualifier; check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); return aptType; } void ClassBoth::Apartment(int32_t /* value */) { throw hresult_not_implemented(); } int32_t ClassSta::Apartment() { APTTYPE aptType; APTTYPEQUALIFIER aptQualifier; check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); return aptType; } void ClassSta::Apartment(int32_t /* value */) { throw hresult_not_implemented(); } int32_t ClassMta::Apartment() { APTTYPE aptType; APTTYPEQUALIFIER aptQualifier; check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); return aptType; } void ClassMta::Apartment(int32_t /* value */) { throw hresult_not_implemented(); } }
504
1,545
<filename>bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/stats/JournalStats.java /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.bookkeeper.bookie.stats; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.ADD_ENTRY; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.CATEGORY_SERVER; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.FORCE_LEDGER; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_ADD_ENTRY; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_CB_QUEUE_SIZE; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_CREATION_LATENCY; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_FLUSH_LATENCY; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_FORCE_LEDGER; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_FORCE_WRITE_BATCH_BYTES; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_FORCE_WRITE_BATCH_ENTRIES; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_FORCE_WRITE_ENQUEUE; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_FORCE_WRITE_GROUPING_COUNT; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_FORCE_WRITE_QUEUE_SIZE; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_MEMORY_MAX; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_MEMORY_USED; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_NUM_FLUSH_EMPTY_QUEUE; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_NUM_FLUSH_MAX_OUTSTANDING_BYTES; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_NUM_FLUSH_MAX_WAIT; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_PROCESS_TIME_LATENCY; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_QUEUE_LATENCY; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_QUEUE_SIZE; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_SCOPE; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_SYNC; import static org.apache.bookkeeper.bookie.BookKeeperServerStats.JOURNAL_WRITE_BYTES; import java.util.function.Supplier; import lombok.Getter; import org.apache.bookkeeper.bookie.BookKeeperServerStats; import org.apache.bookkeeper.stats.Counter; import org.apache.bookkeeper.stats.Gauge; import org.apache.bookkeeper.stats.OpStatsLogger; import org.apache.bookkeeper.stats.StatsLogger; import org.apache.bookkeeper.stats.annotations.StatsDoc; /** * A umbrella class for journal related stats. */ @StatsDoc( name = JOURNAL_SCOPE, category = CATEGORY_SERVER, help = "Journal related stats" ) @Getter public class JournalStats { @StatsDoc( name = JOURNAL_ADD_ENTRY, help = "operation stats of recording addEntry requests in the journal", parent = ADD_ENTRY ) private final OpStatsLogger journalAddEntryStats; @StatsDoc( name = JOURNAL_FORCE_LEDGER, help = "operation stats of recording forceLedger requests in the journal", parent = FORCE_LEDGER ) private final OpStatsLogger journalForceLedgerStats; @StatsDoc( name = JOURNAL_SYNC, help = "operation stats of syncing data to journal disks", parent = JOURNAL_ADD_ENTRY, happensAfter = JOURNAL_FORCE_WRITE_ENQUEUE ) private final OpStatsLogger journalSyncStats; @StatsDoc( name = JOURNAL_FORCE_WRITE_ENQUEUE, help = "operation stats of enqueueing force write requests to force write queue", parent = JOURNAL_ADD_ENTRY, happensAfter = JOURNAL_PROCESS_TIME_LATENCY ) private final OpStatsLogger fwEnqueueTimeStats; @StatsDoc( name = JOURNAL_CREATION_LATENCY, help = "operation stats of creating journal files", parent = JOURNAL_PROCESS_TIME_LATENCY ) private final OpStatsLogger journalCreationStats; @StatsDoc( name = JOURNAL_FLUSH_LATENCY, help = "operation stats of flushing data from memory to filesystem (but not yet fsyncing to disks)", parent = JOURNAL_PROCESS_TIME_LATENCY, happensAfter = JOURNAL_CREATION_LATENCY ) private final OpStatsLogger journalFlushStats; @StatsDoc( name = JOURNAL_PROCESS_TIME_LATENCY, help = "operation stats of processing requests in a journal (from dequeue an item to finish processing it)", parent = JOURNAL_ADD_ENTRY, happensAfter = JOURNAL_QUEUE_LATENCY ) private final OpStatsLogger journalProcessTimeStats; @StatsDoc( name = JOURNAL_QUEUE_LATENCY, help = "operation stats of enqueuing requests to a journal", parent = JOURNAL_ADD_ENTRY ) private final OpStatsLogger journalQueueStats; @StatsDoc( name = JOURNAL_FORCE_WRITE_GROUPING_COUNT, help = "The distribution of number of force write requests grouped in a force write" ) private final OpStatsLogger forceWriteGroupingCountStats; @StatsDoc( name = JOURNAL_FORCE_WRITE_BATCH_ENTRIES, help = "The distribution of number of entries grouped together into a force write request" ) private final OpStatsLogger forceWriteBatchEntriesStats; @StatsDoc( name = JOURNAL_FORCE_WRITE_BATCH_BYTES, help = "The distribution of number of bytes grouped together into a force write request" ) private final OpStatsLogger forceWriteBatchBytesStats; @StatsDoc( name = JOURNAL_QUEUE_SIZE, help = "The journal queue size" ) private final Counter journalQueueSize; @StatsDoc( name = JOURNAL_FORCE_WRITE_QUEUE_SIZE, help = "The force write queue size" ) private final Counter forceWriteQueueSize; @StatsDoc( name = JOURNAL_CB_QUEUE_SIZE, help = "The journal callback queue size" ) private final Counter journalCbQueueSize; @StatsDoc( name = JOURNAL_NUM_FLUSH_MAX_WAIT, help = "The number of journal flushes triggered by MAX_WAIT time" ) private final Counter flushMaxWaitCounter; @StatsDoc( name = JOURNAL_NUM_FLUSH_MAX_OUTSTANDING_BYTES, help = "The number of journal flushes triggered by MAX_OUTSTANDING_BYTES" ) private final Counter flushMaxOutstandingBytesCounter; @StatsDoc( name = JOURNAL_NUM_FLUSH_EMPTY_QUEUE, help = "The number of journal flushes triggered when journal queue becomes empty" ) private final Counter flushEmptyQueueCounter; @StatsDoc( name = JOURNAL_WRITE_BYTES, help = "The number of bytes appended to the journal" ) private final Counter journalWriteBytes; @StatsDoc( name = JOURNAL_MEMORY_MAX, help = "The max amount of memory in bytes that can be used by the bookie journal" ) private final Gauge<Long> journalMemoryMaxStats; @StatsDoc( name = JOURNAL_MEMORY_USED, help = "The actual amount of memory in bytes currently used by the bookie journal" ) private final Gauge<Long> journalMemoryUsedStats; public JournalStats(StatsLogger statsLogger, final long maxJournalMemoryBytes, Supplier<Long> currentJournalMemoryBytes) { journalAddEntryStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_ADD_ENTRY); journalForceLedgerStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_FORCE_LEDGER); journalSyncStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_SYNC); fwEnqueueTimeStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_FORCE_WRITE_ENQUEUE); journalCreationStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_CREATION_LATENCY); journalFlushStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_FLUSH_LATENCY); journalQueueStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_QUEUE_LATENCY); journalProcessTimeStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_PROCESS_TIME_LATENCY); forceWriteGroupingCountStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_FORCE_WRITE_GROUPING_COUNT); forceWriteBatchEntriesStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_FORCE_WRITE_BATCH_ENTRIES); forceWriteBatchBytesStats = statsLogger.getOpStatsLogger(BookKeeperServerStats.JOURNAL_FORCE_WRITE_BATCH_BYTES); journalQueueSize = statsLogger.getCounter(BookKeeperServerStats.JOURNAL_QUEUE_SIZE); forceWriteQueueSize = statsLogger.getCounter(BookKeeperServerStats.JOURNAL_FORCE_WRITE_QUEUE_SIZE); journalCbQueueSize = statsLogger.getCounter(BookKeeperServerStats.JOURNAL_CB_QUEUE_SIZE); flushMaxWaitCounter = statsLogger.getCounter(BookKeeperServerStats.JOURNAL_NUM_FLUSH_MAX_WAIT); flushMaxOutstandingBytesCounter = statsLogger.getCounter(BookKeeperServerStats.JOURNAL_NUM_FLUSH_MAX_OUTSTANDING_BYTES); flushEmptyQueueCounter = statsLogger.getCounter(BookKeeperServerStats.JOURNAL_NUM_FLUSH_EMPTY_QUEUE); journalWriteBytes = statsLogger.getCounter(BookKeeperServerStats.JOURNAL_WRITE_BYTES); journalMemoryMaxStats = new Gauge<Long>() { @Override public Long getDefaultValue() { return maxJournalMemoryBytes; } @Override public Long getSample() { return maxJournalMemoryBytes; } }; statsLogger.registerGauge(JOURNAL_MEMORY_MAX, journalMemoryMaxStats); journalMemoryUsedStats = new Gauge<Long>() { @Override public Long getDefaultValue() { return -1L; } @Override public Long getSample() { return currentJournalMemoryBytes.get(); } }; statsLogger.registerGauge(JOURNAL_MEMORY_USED, journalMemoryUsedStats); } }
4,238
388
<filename>booster/booster/locale/utf8_codecvt.h // // Copyright (c) 2015 <NAME> (Tonkikh) // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOSTER_LOCALE_UTF8_CODECVT_HPP #define BOOSTER_LOCALE_UTF8_CODECVT_HPP #include <booster/locale/utf.h> #include <booster/locale/generic_codecvt.h> #include <booster/cstdint.h> #include <locale> namespace booster { namespace locale { /// /// \brief Geneneric utf8 codecvt facet, it allows to convert UTF-8 strings to UTF-16 and UTF-32 using wchar_t, char32_t and char16_t /// template<typename CharType> class utf8_codecvt : public generic_codecvt<CharType,utf8_codecvt<CharType> > { public: struct state_type {}; utf8_codecvt(size_t refs = 0) : generic_codecvt<CharType,utf8_codecvt<CharType> >(refs) { } static int max_encoding_length() { return 4; } static state_type initial_state(generic_codecvt_base::initial_convertion_state /* unused */) { return state_type(); } static utf::code_point to_unicode(state_type &,char const *&begin,char const *end) { char const *p=begin; utf::code_point c = utf::utf_traits<char>::decode(p,end); if(c!=utf::illegal && c!=utf::incomplete) begin = p; return c; } static utf::code_point from_unicode(state_type &,utf::code_point u,char *begin,char const *end) { if(!utf::is_valid_codepoint(u)) return utf::illegal; int width; if((width=utf::utf_traits<char>::width(u)) > end - begin) return utf::incomplete; utf::utf_traits<char>::encode(u,begin); return width; } }; } // locale } // namespace boost #endif /// // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
827
755
<gh_stars>100-1000 /* * Run-time support for Information Object Classes. * Copyright (c) 2017 <NAME> <<EMAIL>>. All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef ASN_IOC_H #define ASN_IOC_H #include <asn_system.h> /* Platform-specific types */ #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; struct asn_ioc_cell_s; /* * X.681, #13 */ typedef struct asn_ioc_set_s { size_t rows_count; size_t columns_count; const struct asn_ioc_cell_s *rows; } asn_ioc_set_t; typedef struct asn_ioc_cell_s { const char *field_name; /* Is equal to corresponding column_name */ enum { aioc__value, aioc__type, aioc__open_type, } cell_kind; struct asn_TYPE_descriptor_s *type_descriptor; const void *value_sptr; struct { size_t types_count; struct { unsigned choice_position; } *types; } open_type; } asn_ioc_cell_t; #ifdef __cplusplus } #endif #endif /* ASN_IOC_H */
465
592
// // MMShareButton.h // Loose Leaf // // Created by <NAME> on 6/21/12. // Copyright (c) 2012 Milestone Made, LLC. All rights reserved. // #import "MMSidebarButton.h" @interface MMShareButton : MMSidebarButton @property (nonatomic) UIColor* arrowColor; @property (nonatomic) UIColor* topBgColor; @property (nonatomic) UIColor* bottomBgColor; @property (nonatomic, assign, getter=isGreyscale) BOOL greyscale; @end
153
852
#ifndef CalibFormats_SiStripObjects_SiStripHashedDetId_H #define CalibFormats_SiStripObjects_SiStripHashedDetId_H #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" #include <algorithm> #include <iomanip> #include <vector> #include <cstdint> class SiStripHashedDetId; std::ostream &operator<<(std::ostream &os, const SiStripHashedDetId &); /** @class SiStripHashedDetId @author R.Bainbridge @brief Provides dense hash map in place of DetId */ class SiStripHashedDetId { public: // ---------- constructors ---------- /** Constructor taking raw DetIds as input. */ SiStripHashedDetId(const std::vector<uint32_t> &); /** Constructor taking DetIds as input. */ SiStripHashedDetId(const std::vector<DetId> &); /** Copy constructor. */ SiStripHashedDetId(const SiStripHashedDetId &); /** Public default constructor. */ SiStripHashedDetId(); /** Default destructor. */ ~SiStripHashedDetId(); // ---------- typedefs ---------- typedef std::vector<uint32_t>::const_iterator const_iterator; typedef std::vector<uint32_t>::iterator iterator; // ---------- public interface ---------- /** Returns hashed index for given DetId. */ inline uint32_t hashedIndex(uint32_t det_id); /** Returns raw (32-bit) DetId for given hashed index. */ inline uint32_t unhashIndex(uint32_t hashed_index) const; /** Returns DetId object for given hashed index. */ // inline DetId detId( uint32_t index ) const; inline const_iterator begin() const; inline const_iterator end() const; private: void init(const std::vector<uint32_t> &); /** Sorted list of all silicon strip tracker DetIds. */ std::vector<uint32_t> detIds_; uint32_t id_; const_iterator iter_; }; uint32_t SiStripHashedDetId::hashedIndex(uint32_t det_id) { const_iterator iter = end(); if (det_id > id_) { iter = find(iter_, end(), det_id); } else { iter = find(begin(), iter_, det_id); } if (iter != end()) { id_ = det_id; iter_ = iter; return iter - begin(); } else { id_ = 0; iter_ = begin(); return sistrip::invalid32_; } } uint32_t SiStripHashedDetId::unhashIndex(uint32_t hashed_index) const { if (hashed_index < static_cast<uint32_t>(end() - begin())) { return detIds_[hashed_index]; } else { return sistrip::invalid32_; } } SiStripHashedDetId::const_iterator SiStripHashedDetId::begin() const { return detIds_.begin(); } SiStripHashedDetId::const_iterator SiStripHashedDetId::end() const { return detIds_.end(); } #endif // CalibFormats_SiStripObjects_SiStripHashedDetId_H
961
540
[ {"ProductionOrderName":"\"ProOrd_Xml_001\"","ProductCode":"Pro_EU_001","Batches":[{"Name":"Lote_Xml_01"}],"Levels":[{"Id":1,"Name":"Nivel_1","PkgRatio":120},{"Id":2,"Name":"Nivel_2","PkgRatio":1}],"VariableData":[{"VariableDataId":1,"Value":"Pro_EU_001","LevelId":1},{"VariableDataId":20,"Value":"Lote_Xml_01","LevelId":1},{"VariableDataId":11,"Value":"170101","LevelId":1},{"VariableDataId":17,"Value":"210101","LevelId":1},{"VariableDataId":21,"Value":"####################","LevelId":1}]} ]
177
5,169
<filename>Specs/a/d/9/CopyOnWrite/0.9.0/CopyOnWrite.podspec.json { "name": "CopyOnWrite", "version": "0.9.0", "summary": "A μframework that makes implementing value semantics easy!", "description": "CopyOnWrite is a μframework that makes implementing value semantics easy!\nWrap your reference types in the `CopyOnWrite` struct and access the value from the\nappropriate accessor properties, and your type will have proper value semantics!", "homepage": "https://github.com/klundberg/CopyOnWrite", "license": "MIT", "authors": { "<NAME>": "<EMAIL>" }, "social_media_url": "http://twitter.com/kevlario", "platforms": { "ios": "8.0", "osx": "10.9", "watchos": "2.0", "tvos": "9.0" }, "source": { "git": "https://github.com/klundberg/CopyOnWrite.git", "tag": "v0.9.0" }, "source_files": "Sources/*.swift", "pushed_with_swift_version": "3.0" }
341
1,056
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.netbeans.modules.javadoc.hints; import org.netbeans.junit.NbTestCase; import org.netbeans.modules.java.hints.test.api.HintTest; import static org.netbeans.modules.javadoc.hints.JavadocHint.AVAILABILITY_KEY; import static org.netbeans.modules.javadoc.hints.JavadocHint.SCOPE_KEY; /** * * @author <NAME> * @author <NAME> */ public class AddTagFixTest extends NbTestCase { public AddTagFixTest(String name) { super(name); } public void testInherited() throws Exception { HintTest.create() .input("package test;\n" + "import java.io.IOException;\n" + "public class Test implements CustomFileReader {\n" + " /**\n" + " * {@inheritDoc}\n" + " */\n" + " @Override\n" + " public String readFile(String path) throws IOException {\n" + "\n" + " System.out.println(\"Fake reading file [\" + path + \"]\");\n" + " return \"\";\n" + " }\n" + "}\n") .input("test/CustomFileReader.java", "package test;\n" + "import java.io.IOException;\n" + "\n" + "public interface CustomFileReader {\n" + "\n" + " /**\n" + " * Experimental operation to test Javadoc hints in NetBeans-8.0-RC1\n" + " * @param path file path\n" + " * @throws IOException when file cannot be read\n" + " * @return String the file contents\n" + " */\n" + " public String readFile(String path) throws IOException;\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .assertNotContainsWarnings("Missing @throws tag for java.io.IOException"); } public void testAddReturnTagFixInEmptyJavadoc() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("5:4-5:7:warning:Missing @return tag.") .applyFix("Add @return tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " * @return \n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddReturnTagFix() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * bla\n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("5:4-5:7:warning:Missing @return tag.") .applyFix("Add @return tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * bla\n" + " * @return \n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddReturnTagFix2() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /** bla\n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("4:4-4:7:warning:Missing @return tag.") .applyFix("Add @return tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /** bla\n" + " * @return \n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddReturnTagFixInEmpty1LineJavadoc() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /***/\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("3:4-3:7:warning:Missing @return tag.") .applyFix("Add @return tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * @return \n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddReturnTagFixIn1LineJavadoc() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /** bla */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("3:4-3:7:warning:Missing @return tag.") .applyFix("Add @return tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /** bla\n" + " * @return \n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddReturnTagFixIn1LineJavadoc2() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /** @since 1.1 */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("3:4-3:7:warning:Missing @return tag.") .applyFix("Add @return tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * @return \n" + " * @since 1.1 */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddReturnTagFixIn1LineJavadoc3() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /** bla {@link nekam} */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("3:4-3:7:warning:Missing @return tag.") .applyFix("Add @return tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /** bla {@link nekam}\n" + " * @return \n" + " */\n" + " int leden() {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddParamTagFixInEmptyJavadoc() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " */\n" + " void leden(int prvniho) {\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("5:15-5:26:warning:Missing @param tag for prvniho") .applyFix("Add @param prvniho tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " * @param prvniho \n" + " */\n" + " void leden(int prvniho) {\n" + " }\n" + "}\n"); } public void testAddParamTagFixWithReturn() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * @return bla\n" + " */\n" + " int leden(int prvniho) {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("5:14-5:25:warning:Missing @param tag for prvniho") .applyFix("Add @param prvniho tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param prvniho \n" + " * @return bla\n" + " */\n" + " int leden(int prvniho) {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddParamTagFixWithReturn_115974() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * @return bla */\n" + " int leden(int prvniho) {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("4:14-4:25:warning:Missing @param tag for prvniho") .applyFix("Add @param prvniho tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param prvniho \n" + " * @return bla */\n" + " int leden(int prvniho) {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddParamTagFixAndParamOrder() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param prvniho \n" + " * @param tretiho \n" + " * @return bla\n" + " */\n" + " int leden(int prvniho, int druheho, int tretiho) {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("7:27-7:38:warning:Missing @param tag for druheho") .applyFix("Add @param druheho tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param prvniho \n" + " * @param druheho \n" + " * @param tretiho \n" + " * @return bla\n" + " */\n" + " int leden(int prvniho, int druheho, int tretiho) {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddTypeParamTagFixInEmptyJavadoc() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " */\n" + " <T> void leden() {\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("5:5-5:6:warning:Missing @param tag for <T>") .applyFix("Add @param <T> tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " * @param <T> \n" + " */\n" + " <T> void leden() {\n" + " }\n" + "}\n"); } public void testAddTypeParamTagFixInEmptyClassJavadoc() throws Exception { HintTest.create() .input( "package test;\n" + "/**\n" + " * \n" + " */\n" + "class Zima<T> {\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("4:11-4:12:warning:Missing @param tag for <T>") .applyFix("Add @param <T> tag") .assertCompilable() .assertOutput( "package test;\n" + "/**\n" + " * \n" + " * @param <T> \n" + " */\n" + "class Zima<T> {\n" + "}\n"); } public void testAddTypeParamTagFixInClassJavadoc() throws Exception { HintTest.create() .input( "package test;\n" + "/**\n" + " * @param <Q> \n" + " */\n" + "class Zima<P,Q> {\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("4:11-4:12:warning:Missing @param tag for <P>") .applyFix("Add @param <P> tag") .assertCompilable() .assertOutput( "package test;\n" + "/**\n" + " * @param <P> \n" + " * @param <Q> \n" + " */\n" + "class Zima<P,Q> {\n" + "}\n"); } public void testAddTypeParamTagFixWithReturn() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * @return bla\n" + " */\n" + " <T> int leden() {\n" + " return 0;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("5:5-5:6:warning:Missing @param tag for <T>") .applyFix("Add @param <T> tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param <T> \n" + " * @return bla\n" + " */\n" + " <T> int leden() {\n" + " return 0;\n" + " }\n" + "}\n"); } public void testAddTypeParamTagFixAndParamOrder() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param prvniho \n" + " * @param druheho \n" + " * @param tretiho \n" + " * @return bla\n" + " */\n" + " <T> T leden(int prvniho, int druheho, T tretiho) {\n" + " return tretiho;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("8:5-8:6:warning:Missing @param tag for <T>") .applyFix("Add @param <T> tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param <T> \n" + " * @param prvniho \n" + " * @param druheho \n" + " * @param tretiho \n" + " * @return bla\n" + " */\n" + " <T> T leden(int prvniho, int druheho, T tretiho) {\n" + " return tretiho;\n" + " }\n" + "}\n"); } public void testAddTypeParamTagFixClashAndParamOrder() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param <T> \n" + " * @param prvniho \n" + " * @param druheho \n" + " * @param tretiho \n" + " * @return bla\n" + " */\n" + " <T,S> T leden(int prvniho, int druheho, T tretiho) {\n" + " return tretiho;\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("9:7-9:8:warning:Missing @param tag for <S>") .applyFix("Add @param <S> tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * @param <T> \n" + " * @param <S> \n" + " * @param prvniho \n" + " * @param druheho \n" + " * @param tretiho \n" + " * @return bla\n" + " */\n" + " <T,S> T leden(int prvniho, int druheho, T tretiho) {\n" + " return tretiho;\n" + " }\n" + "}\n"); } public void testAddThrowsTagFix() throws Exception { HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " */\n" + " void leden() throws java.io.IOException {\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("5:24-5:43:warning:Missing @throws tag for java.io.IOException") .applyFix("Add @throws java.io.IOException tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " * @throws java.io.IOException \n" + " */\n" + " void leden() throws java.io.IOException {\n" + " }\n" + "}\n"); } public void testAddThrowsTagFix2() throws Exception { HintTest.create() .input( "package test;\n" + "import java.io.IOException;\n" + "class Zima {\n" + " /**\n" + " * \n" + " */\n" + " void leden() throws IOException {\n" + " }\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("6:24-6:35:warning:Missing @throws tag for java.io.IOException") .applyFix("Add @throws java.io.IOException tag") .assertCompilable() .assertOutput( "package test;\n" + "import java.io.IOException;\n" + "class Zima {\n" + " /**\n" + " * \n" + " * @throws java.io.IOException \n" + " */\n" + " void leden() throws IOException {\n" + " }\n" + "}\n"); } public void testAddThrowsTagFix_NestedClass_160414() throws Exception { // issue 160414 HintTest.create() .input( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " */\n" + " void leden() throws MEx {\n" + " }\n" + " public static class MEx extends Exception {}\n" + "}\n") .preference(AVAILABILITY_KEY + true, true) .preference(SCOPE_KEY, "private") .run(JavadocHint.class) .findWarning("5:24-5:27:warning:Missing @throws tag for test.Zima.MEx") .applyFix("Add @throws test.Zima.MEx tag") .assertCompilable() .assertOutput( "package test;\n" + "class Zima {\n" + " /**\n" + " * \n" + " * @throws test.Zima.MEx \n" + " */\n" + " void leden() throws MEx {\n" + " }\n" + " public static class MEx extends Exception {}\n" + "}\n"); } }
16,152
1,056
<filename>ide/editor.util/test/unit/src/org/netbeans/lib/editor/util/PriorityListenerListTest.java /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.netbeans.lib.editor.util; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.EventListener; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; import org.netbeans.junit.NbTest; import org.netbeans.junit.NbTestCase; import org.netbeans.junit.NbTestSuite; import org.openide.util.io.NbMarshalledObject; /** * Test of PriorityListenerList correctness. * * @author mmetelka */ public class PriorityListenerListTest extends NbTestCase { private static final boolean debug = false; private static final int SET_RATIO_2 = 50; public PriorityListenerListTest(java.lang.String testName) { super(testName); } public void testAddAndRemoveListenersOnThreeLevels() { int TEST_PRIORITY_1 = 0; int TEST_PRIORITY_2 = 3; int TEST_PRIORITY_3 = 2; PriorityListenerListCouple couple = new PriorityListenerListCouple(); L l1 = new L(); L l11 = new L(); L l2 = new L(); L l21 = new L(); L l3 = new L(); couple.add(l1, TEST_PRIORITY_1); couple.add(l2, TEST_PRIORITY_2); couple.add(l3, TEST_PRIORITY_3); couple.add(l21, TEST_PRIORITY_2); couple.add(l11, TEST_PRIORITY_1); couple.remove(l1, TEST_PRIORITY_1); couple.remove(l2, TEST_PRIORITY_1); // should do nothing couple.remove(l2, TEST_PRIORITY_2); couple.remove(l21, TEST_PRIORITY_2); couple.remove(l3, TEST_PRIORITY_3); // should remove the levels 2 and 3 couple.checkLastPriority(1); couple.add(l3, TEST_PRIORITY_3); } public void testNegativePriorities() { try { PriorityListenerList<EventListener> ll = new PriorityListenerList<EventListener>(); ll.add(new L(), -1); fail("Should not get here"); } catch (IndexOutOfBoundsException e) { // Invalid priority properly catched } try { PriorityListenerList<EventListener> ll = new PriorityListenerList<EventListener>(); ll.remove(new L(), -1); fail("Should not get here"); } catch (IndexOutOfBoundsException e) { // Invalid priority properly catched } } public void testSerialization() throws Exception { PriorityListenerList<EventListener> ll = new PriorityListenerList<EventListener>(); ll.add(new L(), 3); ll.add(new L(), 1); ll.add(new L(), 1); NbMarshalledObject mo = new NbMarshalledObject(ll); PriorityListenerList sll = (PriorityListenerList)mo.get(); EventListener[][] lla = ll.getListenersArray(); EventListener[][] slla = sll.getListenersArray(); assertEquals(lla.length, slla.length); for (int priority = lla.length - 1; priority >= 0; priority--) { assertEquals(lla[priority].length, slla[priority].length); } } private static final class L implements EventListener, Serializable { static final long serialVersionUID = 12345L; private int notified; public void notifyChange() { notified++; } public int getNotified() { return notified; } } private static final class PriorityListenerListImitation extends HashMap<Integer,List<EventListener>> { public synchronized void add(EventListener listener, int priority) { assertTrue(priority >= 0); // Add to begining so that fired as last (comply with PriorityListenerList) getList(priority, true).add(0, listener); } public synchronized void remove(EventListener listener, int priority) { assertTrue(priority >= 0); List<EventListener> l = getList(priority, false); for (int i = l.size() - 1; i >= 0; i--) { if (l.get(i) == listener) { l.remove(i); break; } } } public synchronized List<EventListener> getList(int priority) { return getList(priority, false); } public synchronized void checkEquals(PriorityListenerList<EventListener> priorityListenerList) { // Check the same listeners are stored in imitation EventListener[][] listenersArray = priorityListenerList.getListenersArray(); for (int priority = listenersArray.length - 1; priority >= 0; priority--) { EventListener[] listeners = listenersArray[priority]; for (int i = listeners.length - 1; i >= 0; i--) { assertTrue(getList(priority).get(i) == listeners[i]); } } // Check there are no extra priorities in the imitation for (Map.Entry<Integer,List<EventListener>> entry : entrySet()) { if (entry.getValue().size() > 0) { assertTrue (entry.getKey() < listenersArray.length); } } } private List<EventListener> getList(int priority, boolean forceCreation) { List<EventListener> l = get(priority); if (l == null) { if (forceCreation) { l = new ArrayList<EventListener>(); put(priority, l); } else { // just getting the value l = Collections.emptyList(); } } return l; } } private static final class PriorityListenerListCouple { PriorityListenerList<EventListener> priorityListenerList; PriorityListenerListImitation imitation; public PriorityListenerListCouple() { priorityListenerList = new PriorityListenerList<EventListener>(); imitation = new PriorityListenerListImitation(); } public void add(EventListener listener, int priority) { priorityListenerList.add(listener, priority); imitation.add(listener, priority); imitation.checkEquals(priorityListenerList); } public void remove(EventListener listener, int priority) { priorityListenerList.remove(listener, priority); imitation.remove(listener, priority); imitation.checkEquals(priorityListenerList); } public void checkLastPriority(int priority) { assertTrue(priorityListenerList.getListenersArray().length - 1 == priority); } } }
3,261
678
/** * This header is generated by class-dump-z 0.2b. * * Source: /System/Library/PrivateFrameworks/TelephonyUI.framework/TelephonyUI */ #import <TelephonyUI/TelephonyUI-Structs.h> #import <TelephonyUI/XXUnknownSuperclass.h> #import <TelephonyUI/TPLCDTextView.h> @class NSString, UIColor, UIFrameAnimation, TPLCDTextViewScrollingView; @interface TPLCDTextView : XXUnknownSuperclass { NSString *_text; // 48 = 0x30 GSFontRef _font; // 52 = 0x34 UIColor *_shadowColor; // 56 = 0x38 UIColor *_textColor; // 60 = 0x3c TPLCDTextViewScrollingView *_scrollingView; // 64 = 0x40 float _fontSize; // 68 = 0x44 CGRect _textRect; // 72 = 0x48 UIFrameAnimation *_animation; // 88 = 0x58 id _delegate; // 92 = 0x5c float _minFontSize; // 96 = 0x60 unsigned _textRectIsValid : 1; // 100 = 0x64 unsigned _centerText : 1; // 100 = 0x64 unsigned _animates : 1; // 100 = 0x64 unsigned _isAnimating : 1; // 100 = 0x64 unsigned _leftTruncates : 1; // 100 = 0x64 } @property(retain) NSString *text; // G=0xe89; S=0x1c4d; converted property @property(readonly, assign) CGRect textRect; // G=0x1f69; converted property + (float)defaultMinimumFontSize; // 0xe45 - (id)initWithFrame:(CGRect)frame; // 0xecd - (void)dealloc; // 0x232d // converted property getter: - (CGRect)textRect; // 0x1f69 - (void)setFrame:(CGRect)frame; // 0x1e85 - (void)setCenterText:(BOOL)text; // 0x1e31 - (void)setLeftTruncatesText:(BOOL)text; // 0x1d99 - (void)setFont:(GSFontRef)font; // 0x1cfd - (void)setMinimumFontSize:(float)size; // 0xe4d // converted property setter: - (void)setText:(id)text; // 0x1c4d // converted property getter: - (id)text; // 0xe89 - (CGSize)sizeToFit; // 0x1bd9 - (void)_drawTextInRect:(CGRect)rect verticallyOffset:(BOOL)offset; // 0x1a09 - (void)setTextColor:(id)color; // 0x19b1 - (void)setShadowColor:(id)color; // 0x1959 - (void)drawRect:(CGRect)rect; // 0x18dd - (void)_tearDownAnimation; // 0x1865 - (void)_scheduleStartScrolling; // 0x17e5 - (void)_setupForAnimationIfNecessary; // 0x14e5 - (void)setAnimatesIfTruncated:(BOOL)truncated; // 0x1465 - (void)_startScrolling; // 0x123d - (void)startAnimating; // 0x11ed - (void)_finishedScrolling; // 0x1121 - (void)stopAnimating; // 0x1025 - (BOOL)animates; // 0xe99 - (void)resetAnimation; // 0xf5d - (void)setDelegate:(id)delegate; // 0xead @end @interface TPLCDTextView (SyntheticEvents) - (id)_automationID; // 0x3061 @end
1,000
448
<filename>framework/curl_test.cpp // // Created by moqi on 2019-04-12. // #include <curl/multi.h> static size_t write_callback(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; (void)contents; (void)userp; return realsize; } int main() { CURLM *m = NULL; CURLMsg *msg; /* for picking up messages with the transfer status */ int msgs_left; /* how many messages are left */ CURL *handle = nullptr; curl_global_init(CURL_GLOBAL_ALL); m = curl_multi_init(); handle = curl_easy_init(); int running = 0; int handlenum = 0; curl_easy_setopt(handle, CURLOPT_URL, "https://www.baidu.com"); curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L); curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1L); curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); curl_multi_add_handle(m, handle); for (;;) { curl_multi_perform(m, &running); /* See how the transfers went */ do { msg = curl_multi_info_read(m, &msgs_left); if (msg && msg->msg == CURLMSG_DONE) { // printf("Handle %d Completed with status %d\n", i, msg->data.result); curl_multi_remove_handle(m, handle); break; } } while (msg); if (!running) { break; /* done */ } } curl_easy_setopt(handle, CURLOPT_URL, "https://www.baidu.com/img/bd_logo1.png"); curl_multi_add_handle(m, handle); printf("xxxxxxxxxxxxxxxxx\n\n\n"); for (;;) { curl_multi_perform(m, &running); /* See how the transfers went */ do { msg = curl_multi_info_read(m, &msgs_left); if (msg && msg->msg == CURLMSG_DONE) { // printf("Handle %d Completed with status %d\n", i, msg->data.result); curl_multi_remove_handle(m, handle); break; } } while (msg); if (!running) { break; /* done */ } } }
1,012
892
<gh_stars>100-1000 { "schema_version": "1.2.0", "id": "GHSA-w42q-f4mr-jhc4", "modified": "2022-05-13T01:09:06Z", "published": "2022-05-13T01:09:06Z", "aliases": [ "CVE-2019-8277" ], "details": "UltraVNC revision 1211 contains multiple memory leaks (CWE-665) in VNC server code, which allows an attacker to read stack memory and can be abused for information disclosure. Combined with another vulnerability, it can be used to leak stack memory and bypass ASLR. This attack appears to be exploitable via network connectivity. These vulnerabilities have been fixed in revision 1212.", "severity": [ { "type": "CVSS_V3", "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N" } ], "affected": [ ], "references": [ { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2019-8277" }, { "type": "WEB", "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-286838.pdf" }, { "type": "WEB", "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-927095.pdf" }, { "type": "WEB", "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-940818.pdf" }, { "type": "WEB", "url": "https://ics-cert.kaspersky.com/advisories/klcert-advisories/2019/03/01/klcert-19-024-ultravnc-improper-initialization/" }, { "type": "WEB", "url": "https://us-cert.cisa.gov/ics/advisories/icsa-21-131-11" }, { "type": "WEB", "url": "https://www.us-cert.gov/ics/advisories/icsa-20-161-06" } ], "database_specific": { "cwe_ids": [ "CWE-665" ], "severity": "HIGH", "github_reviewed": false } }
793
14,668
#!/usr/bin/env python # 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. """Creates a zip archive for the Chrome Remote Desktop Host installer. This script builds a zip file that contains all the files needed to build an installer for Chrome Remote Desktop Host. This zip archive is then used by the signing bots to: (1) Sign the binaries (2) Build the final installer TODO(garykac) We should consider merging this with build-webapp.py. """ from __future__ import print_function import os import shutil import subprocess import sys import zipfile sys.path.append(os.path.join( os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, "build", "android", "gyp")) from util import build_utils def cleanDir(dir): """Deletes and recreates the dir to make sure it is clean. Args: dir: The directory to clean. """ try: shutil.rmtree(dir) except OSError: if os.path.exists(dir): raise else: pass os.makedirs(dir, 0o775) def buildDefDictionary(definitions): """Builds the definition dictionary from the VARIABLE=value array. Args: defs: Array of variable definitions: 'VARIABLE=value'. Returns: Dictionary with the definitions. """ defs = {} for d in definitions: (key, val) = d.split('=') defs[key] = val return defs def remapSrcFile(dst_root, src_roots, src_file): """Calculates destination file path and creates directory. Any matching |src_roots| prefix is stripped from |src_file| before appending to |dst_root|. For example, given: dst_root = '/output' src_roots = ['host/installer/mac'] src_file = 'host/installer/mac/Scripts/keystone_install.sh' The final calculated path is: '/output/Scripts/keystone_install.sh' The |src_file| must match one of the |src_roots| prefixes. If there are no matches, then an error is reported. If multiple |src_roots| match, then only the first match is applied. Because of this, if you have roots that share a common prefix, the longest string should be first in this array. Args: dst_root: Target directory where files are copied. src_roots: Array of path prefixes which will be stripped of |src_file| (if they match) before appending it to the |dst_root|. src_file: Source file to be copied. Returns: Full path to destination file in |dst_root|. """ # Strip of directory prefix. found_root = False for root in src_roots: root = os.path.normpath(root) src_file = os.path.normpath(src_file) if os.path.commonprefix([root, src_file]) == root: src_file = os.path.relpath(src_file, root) found_root = True break if not found_root: error('Unable to match prefix for %s' % src_file) dst_file = os.path.join(dst_root, src_file) # Make sure target directory exists. dst_dir = os.path.dirname(dst_file) if not os.path.exists(dst_dir): os.makedirs(dst_dir, 0o775) return dst_file def copyFileWithDefs(src_file, dst_file, defs): """Copies from src_file to dst_file, performing variable substitution. Any @@VARIABLE@@ in the source is replaced with the value of VARIABLE in the |defs| dictionary when written to the destination file. Args: src_file: Full or relative path to source file to copy. dst_file: Relative path (and filename) where src_file should be copied. defs: Dictionary of variable definitions. """ data = open(src_file, 'r').read() for key, val in defs.items(): try: data = data.replace('@@' + key + '@@', val) except TypeError: print(repr(key), repr(val)) open(dst_file, 'w').write(data) shutil.copystat(src_file, dst_file) def copyZipIntoArchive(out_dir, files_root, zip_file): """Expands the zip_file into the out_dir, preserving the directory structure. Args: out_dir: Target directory where unzipped files are copied. files_root: Path prefix which is stripped of zip_file before appending it to the out_dir. zip_file: Relative path (and filename) to the zip file. """ base_zip_name = os.path.basename(zip_file) # We don't use the 'zipfile' module here because it doesn't restore all the # file permissions correctly. We use the 'unzip' command manually. old_dir = os.getcwd(); os.chdir(os.path.dirname(zip_file)) subprocess.call(['unzip', '-qq', '-o', base_zip_name]) os.chdir(old_dir) # Unzip into correct dir in out_dir. out_zip_path = remapSrcFile(out_dir, files_root, zip_file) out_zip_dir = os.path.dirname(out_zip_path) (src_dir, ignore1) = os.path.splitext(zip_file) (base_dir_name, ignore2) = os.path.splitext(base_zip_name) shutil.copytree(src_dir, os.path.join(out_zip_dir, base_dir_name)) def buildHostArchive(temp_dir, zip_path, source_file_roots, source_files, gen_files, gen_files_dst, defs): """Builds a zip archive with the files needed to build the installer. Args: temp_dir: Temporary dir used to build up the contents for the archive. zip_path: Full path to the zip file to create. source_file_roots: Array of path prefixes to strip off |files| when adding to the archive. source_files: The array of files to add to archive. The path structure is preserved (except for the |files_root| prefix). gen_files: Full path to binaries to add to archive. gen_files_dst: Relative path of where to add binary files in archive. This array needs to parallel |binaries_src|. defs: Dictionary of variable definitions. """ cleanDir(temp_dir) for f in source_files: dst_file = remapSrcFile(temp_dir, source_file_roots, f) base_file = os.path.basename(f) (base, ext) = os.path.splitext(f) if ext == '.zip': copyZipIntoArchive(temp_dir, source_file_roots, f) elif ext in ['.packproj', '.pkgproj', '.plist', '.props', '.sh', '.json']: copyFileWithDefs(f, dst_file, defs) else: shutil.copy2(f, dst_file) for bs, bd in zip(gen_files, gen_files_dst): dst_file = os.path.join(temp_dir, bd) if not os.path.exists(os.path.dirname(dst_file)): os.makedirs(os.path.dirname(dst_file)) if os.path.isdir(bs): shutil.copytree(bs, dst_file) else: shutil.copy2(bs, dst_file) build_utils.ZipDir( zip_path, temp_dir, compress_fn=lambda _: zipfile.ZIP_DEFLATED, zip_prefix_path=os.path.splitext(os.path.basename(zip_path))[0]) def error(msg): sys.stderr.write('ERROR: %s\n' % msg) sys.exit(1) def usage(): """Display basic usage information.""" print('Usage: %s\n' ' <temp-dir> <zip-path>\n' ' --source-file-roots <list of roots to strip off source files...>\n' ' --source-files <list of source files...>\n' ' --generated-files <list of generated target files...>\n' ' --generated-files-dst <dst for each generated file...>\n' ' --defs <list of VARIABLE=value definitions...>' ) % sys.argv[0] def main(): if len(sys.argv) < 2: usage() error('Too few arguments') temp_dir = sys.argv[1] zip_path = sys.argv[2] arg_mode = '' source_file_roots = [] source_files = [] generated_files = [] generated_files_dst = [] definitions = [] for arg in sys.argv[3:]: if arg == '--source-file-roots': arg_mode = 'src-roots' elif arg == '--source-files': arg_mode = 'files' elif arg == '--generated-files': arg_mode = 'gen-src' elif arg == '--generated-files-dst': arg_mode = 'gen-dst' elif arg == '--defs': arg_mode = 'defs' elif arg_mode == 'src-roots': source_file_roots.append(arg) elif arg_mode == 'files': source_files.append(arg) elif arg_mode == 'gen-src': generated_files.append(arg) elif arg_mode == 'gen-dst': generated_files_dst.append(arg) elif arg_mode == 'defs': definitions.append(arg) else: usage() error('Expected --source-files') # Make sure at least one file was specified. if len(source_files) == 0 and len(generated_files) == 0: error('At least one input file must be specified.') # Sort roots to ensure the longest one is first. See comment in remapSrcFile # for why this is necessary. source_file_roots = list(map(os.path.normpath, source_file_roots)) source_file_roots.sort(key=len, reverse=True) # Verify that the 2 generated_files arrays have the same number of elements. if len(generated_files) != len(generated_files_dst): error('len(--generated-files) != len(--generated-files-dst)') defs = buildDefDictionary(definitions) result = buildHostArchive(temp_dir, zip_path, source_file_roots, source_files, generated_files, generated_files_dst, defs) return 0 if __name__ == '__main__': sys.exit(main())
3,420
316
/** * Contains the Mapbox Maps Android TextureView API classes. */ package com.mapbox.mapboxsdk.maps.renderer.textureview;
37
511
<reponame>SenthilKumarGS/TizenRT /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors * * 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 IOTJS_REQWRAP_H #define IOTJS_REQWRAP_H #include <uv.h> #include "iotjs_binding.h" // UV request wrapper. // Wrapping UV request and JavaScript callback. // When an instance of request wrapper is created. it will increase ref count // for JavaScript callback function to prevent it from reclaimed by GC. The // reference count will decrease back when wrapper is being freed. typedef struct { iotjs_jval_t jcallback; uv_req_t* request; } IOTJS_VALIDATED_STRUCT(iotjs_reqwrap_t); void iotjs_reqwrap_initialize(iotjs_reqwrap_t* reqwrap, const iotjs_jval_t* jcallback, uv_req_t* request); void iotjs_reqwrap_destroy(iotjs_reqwrap_t* reqwrap); // To retrieve javascript callback function object. const iotjs_jval_t* iotjs_reqwrap_jcallback(iotjs_reqwrap_t* reqwrap); // To retrieve pointer to uv request. uv_req_t* iotjs_reqwrap_req(iotjs_reqwrap_t* reqwrap); iotjs_reqwrap_t* iotjs_reqwrap_from_request(uv_req_t* req); #endif /* IOTJS_REQWRAP_H */
558
1,272
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0/ * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #ifndef ALEXA_CLIENT_SDK_STORAGE_SQLITESTORAGE_INCLUDE_SQLITESTORAGE_SQLITEDATABASE_H_ #define ALEXA_CLIENT_SDK_STORAGE_SQLITESTORAGE_INCLUDE_SQLITESTORAGE_SQLITEDATABASE_H_ #include <memory> #include <string> #include <vector> #include <sqlite3.h> #include <SQLiteStorage/SQLiteStatement.h> namespace alexaClientSDK { namespace storage { namespace sqliteStorage { /** * A basic class for performing basic SQLite database operations. This the boilerplate code used to manage the * SQLiteDatabase. This database is not thread-safe, and must be protected before being used in a mutlithreaded * fashion. */ class SQLiteDatabase { public: /** * Class to manage SQL transaction lifecycle. */ class Transaction { /// Allow @c SQLiteDatabase to access private constructor of @c Transaction. friend SQLiteDatabase; public: /** * Destructor */ ~Transaction(); /** * Commits the current transaction. * * @return true if commit was successful, false otherwise */ bool commit(); /** * Rolls back the current transaction. * * @return true if rollback was successful, false otherwise */ bool rollback(); private: /** * Constructor * * @param dbHandle weak pointer to a @c SQLiteDatabase instance that will own the transaction. */ Transaction(std::weak_ptr<SQLiteDatabase> dbHandle); /** * Pointer to a @c SQLiteDatabase instance that owns the transaction. */ std::weak_ptr<SQLiteDatabase> m_database; /** * Flag indicating whether the transaction has already been completed. */ bool m_transactionCompleted; }; /** * Constructor. The internal variables are initialized. * * @param filePath The location of the file that the SQLite DB will use as it's backing storage when initialize or * open are called. */ SQLiteDatabase(const std::string& filePath); /** * Destructor. * * On destruction, the DB is checked to see if it is closed. It must be closed before the SQLiteDatabase object is * destroyed as there is no handle to the DB to close it after this object is gone. */ ~SQLiteDatabase(); /** * The internal SQLite DB is created. * * @return true, if the (empty) DB is created successfully. If there is already a DB at the path specified, this * function fails and returns false. It also returns false if the database is already opened or if there is an * internal failure in creating the DB. */ bool initialize(); /** * The internal SQLite DB is opened. * * @return true, if the DB is opened successfully. If there is no DB at the path specified, this function fails and * returns false. It also returns false if the database is already opened or if there is an internal failure in * creating the DB. */ bool open(); /** * Run a SQL query on the database. * * @param sqlString A valid SQL query. * @return true if successful, false if there is a problem. */ bool performQuery(const std::string& sqlString); /** * Check to see if a specified table exists. * * @param tableName The name of the table to check. * @return true if the table exists, flase if it doesn't or there is an error. */ bool tableExists(const std::string& tableName); /** * Remove all the rows from the specified table. * * @param tableName The name of the table to clear. * @return true if successful, false if there was an error. */ bool clearTable(const std::string& tableName); /** * If open, close the internal SQLite DB. Do nothing if there is no DB open. */ void close(); /** * Create an SQLiteStatement object to execute the provided string. * * @param sqlString The SQL command to execute. * @return A unique_ptr to the SQLiteStatement that represents the sqlString. */ std::unique_ptr<SQLiteStatement> createStatement(const std::string& sqlString); /** * Checks if the database is ready to be acted upon. * * @return true if database is ready to be acted upon, false otherwise. */ bool isDatabaseReady(); /** * Begins transaction. * * @return true if query succeeded, false otherwise */ std::unique_ptr<Transaction> beginTransaction(); private: /** * Commits the transaction started with @c beginTransaction. * * @return true if transaction has been successfully committed, false otherwise. */ bool commitTransaction(); /** * Rolls back the transaction started with @c beginTransaction. * @return true if transaction has been successfully rolled back, false otherwise. */ bool rollbackTransaction(); /// The path to use when creating/opening the internal SQLite DB. const std::string m_storageFilePath; /// Flag indicating whether there is a transaction in progress. bool m_transactionIsInProgress; /// The sqlite database handle. sqlite3* m_dbHandle; /** * A shared_ptr to this that is used to manage viability of weak_ptrs to this. This shared_ptr has a no-op deleter, * and does not manage the lifecycle of this instance. Instead, ~SQLiteDatabase() resets this shared_ptr to signal * to any outstanding Transaction that this instance has been deleted. */ std::shared_ptr<SQLiteDatabase> m_sharedThisPlaceholder; }; } // namespace sqliteStorage } // namespace storage } // namespace alexaClientSDK #endif // ALEXA_CLIENT_SDK_STORAGE_SQLITESTORAGE_INCLUDE_SQLITESTORAGE_SQLITEDATABASE_H_
2,198
2,419
<filename>benchmarks/src/main/java/run/chronicle/staged/IFacadeBase.java package run.chronicle.staged; import net.openhft.chronicle.bytes.Byteable; interface IFacadeBase extends Byteable { short getValue0(); void setValue0(short value); byte getValue1(); void setValue1(byte value); byte getValue2(); void setValue2(byte value); int getValue3(); void setValue3(int value); short getValue4(); void setValue4(short value); boolean getValue5(); void setValue5(boolean value); boolean getValue6(); void setValue6(boolean value); short getValue7(); void setValue7(short value); short getValue8(); void setValue8(short value); long getValue9(); void setValue9(long value); long getValue10(); void setValue10(long value); long getValue11(); void setValue11(long value); long getValue12(); void setValue12(long value); long getValue13(); void setValue13(long value); long getValue14(); void setValue14(long value); long getValue15(); void setValue15(long value); short getValue16(); void setValue16(short value); short getValue17(); void setValue17(short value); short getValue18(); void setValue18(short value); }
468
1,900
/* * Copyright Terracotta, 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. */ package org.ehcache.core.util; import org.ehcache.config.CacheConfiguration; import org.ehcache.config.Eviction; import org.ehcache.config.EvictionAdvisor; import org.ehcache.config.FluentCacheConfigurationBuilder; import org.ehcache.config.ResourcePools; import org.ehcache.expiry.ExpiryPolicy; import org.ehcache.spi.copy.Copier; import org.ehcache.spi.loaderwriter.CacheLoaderWriter; import org.ehcache.spi.resilience.ResilienceStrategy; import org.ehcache.spi.serialization.Serializer; import org.ehcache.spi.service.ServiceConfiguration; import java.util.Collection; import java.util.function.Predicate; import java.util.function.UnaryOperator; import static java.util.Collections.emptyList; import static org.ehcache.core.config.ExpiryUtils.convertToExpiry; import static org.ehcache.core.config.ResourcePoolsHelper.createResourcePools; public class TestCacheConfig<K, V> implements CacheConfiguration<K,V> { private final Class<K> keyType; private final Class<V> valueType; private final ResourcePools resources; public TestCacheConfig(Class<K> keyType, Class<V> valueType) { this(keyType, valueType, createResourcePools(100L)); } public TestCacheConfig(Class<K> keyType, Class<V> valueType, ResourcePools resources) { this.keyType = keyType; this.valueType = valueType; this.resources = resources; } @Override public Collection<ServiceConfiguration<?, ?>> getServiceConfigurations() { return emptyList(); } @Override public Class<K> getKeyType() { return keyType; } @Override public Class<V> getValueType() { return valueType; } @Override public EvictionAdvisor<? super K, ? super V> getEvictionAdvisor() { return Eviction.noAdvice(); } @Override public ClassLoader getClassLoader() { return null; } @Override @SuppressWarnings("deprecation") public org.ehcache.expiry.Expiry<? super K, ? super V> getExpiry() { return convertToExpiry(getExpiryPolicy()); } @Override public ExpiryPolicy<? super K, ? super V> getExpiryPolicy() { return ExpiryPolicy.NO_EXPIRY; } @Override public ResourcePools getResourcePools() { return resources; } @Override public Builder derive() { return new Builder(); } public class Builder implements FluentCacheConfigurationBuilder<K, V, Builder> { @Override public CacheConfiguration<K, V> build() { return TestCacheConfig.this; } @Override public <C extends ServiceConfiguration<?, ?>> Collection<C> getServices(Class<C> configurationType) { throw new UnsupportedOperationException(); } @Override public Builder withService(ServiceConfiguration<?, ?> config) { throw new UnsupportedOperationException(); } @Override public <C extends ServiceConfiguration<?, ?>> Builder withoutServices(Class<C> clazz, Predicate<? super C> predicate) { throw new UnsupportedOperationException(); } @Override public <R, C extends ServiceConfiguration<?, R>> Builder updateServices(Class<C> clazz, UnaryOperator<R> update) { throw new UnsupportedOperationException(); } @Override public Builder withEvictionAdvisor(EvictionAdvisor<? super K, ? super V> evictionAdvisor) { throw new UnsupportedOperationException(); } @Override public Builder withClassLoader(ClassLoader classLoader) { return new TestCacheConfig<K, V>(getKeyType(), getValueType(), resources) { @Override public ClassLoader getClassLoader() { return classLoader; } }.derive(); } @Override public Builder withDefaultClassLoader() { throw new UnsupportedOperationException(); } @Override public Builder withResourcePools(ResourcePools resourcePools) { throw new UnsupportedOperationException(); } @Override public Builder updateResourcePools(UnaryOperator<ResourcePools> update) { throw new UnsupportedOperationException(); } @Override public Builder withExpiry(ExpiryPolicy<? super K, ? super V> expiry) { throw new UnsupportedOperationException(); } @Override public Builder withLoaderWriter(CacheLoaderWriter<K, V> loaderWriter) { throw new UnsupportedOperationException(); } @Override public Builder withLoaderWriter(Class<CacheLoaderWriter<K, V>> cacheLoaderWriterClass, Object... arguments) { throw new UnsupportedOperationException(); } @Override public Builder withoutLoaderWriter() { throw new UnsupportedOperationException(); } @Override public Builder withResilienceStrategy(ResilienceStrategy<K, V> resilienceStrategy) { throw new UnsupportedOperationException(); } @Override @SuppressWarnings("rawtypes") public Builder withResilienceStrategy(Class<? extends ResilienceStrategy> resilienceStrategyClass, Object... arguments) { throw new UnsupportedOperationException(); } @Override public Builder withDefaultResilienceStrategy() { throw new UnsupportedOperationException(); } @Override public Builder withKeySerializingCopier() { throw new UnsupportedOperationException(); } @Override public Builder withValueSerializingCopier() { throw new UnsupportedOperationException(); } @Override public Builder withKeyCopier(Copier<K> keyCopier) { throw new UnsupportedOperationException(); } @Override public Builder withKeyCopier(Class<? extends Copier<K>> keyCopierClass) { throw new UnsupportedOperationException(); } @Override public Builder withoutKeyCopier() { throw new UnsupportedOperationException(); } @Override public Builder withValueCopier(Copier<V> valueCopier) { throw new UnsupportedOperationException(); } @Override public Builder withValueCopier(Class<? extends Copier<V>> valueCopierClass) { throw new UnsupportedOperationException(); } @Override public Builder withoutValueCopier() { throw new UnsupportedOperationException(); } @Override public Builder withKeySerializer(Serializer<K> keySerializer) { throw new UnsupportedOperationException(); } @Override public Builder withKeySerializer(Class<? extends Serializer<K>> keySerializerClass) { throw new UnsupportedOperationException(); } @Override public Builder withDefaultKeySerializer() { throw new UnsupportedOperationException(); } @Override public Builder withValueSerializer(Serializer<V> valueSerializer) { throw new UnsupportedOperationException(); } @Override public Builder withValueSerializer(Class<? extends Serializer<V>> valueSerializerClass) { throw new UnsupportedOperationException(); } @Override public Builder withDefaultValueSerializer() { throw new UnsupportedOperationException(); } } }
2,407
561
########################################################################## # # Copyright (c) 2020, Cinesite VFX Ltd. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above # copyright notice, this list of conditions and the following # disclaimer. # # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided with # the distribution. # # * Neither the name of <NAME> nor the names of # any other contributors to this software may be used to endorse or # promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ########################################################################## import imath import Gaffer import GafferUI # _Formatting # ----------- # # Formatters are used to present plug values as strings in a table cell. __valueFormatters = {} ## Returns the value of the plug as it will be formatted in a Spreadsheet. def formatValue( plug, forToolTip = False ) : currentPreset = Gaffer.NodeAlgo.currentPreset( plug ) if currentPreset is not None : return currentPreset formatter = __valueFormatters.get( plug.__class__, __defaultValueFormatter ) return formatter( plug, forToolTip ) ## Registers a custom formatter for the specified `plugType`. # `formatter` must have the same signature as `formatValue()`. def registerValueFormatter( plugType, formatter ) : __valueFormatters[ plugType ] = formatter # Standard formatters # ------------------- def __defaultValueFormatter( plug, forToolTip ) : if not hasattr( plug, "getValue" ) : return "" value = plug.getValue() if isinstance( value, str ) : return value elif isinstance( value, ( int, float ) ) : return GafferUI.NumericWidget.valueToString( value ) elif isinstance( value, ( imath.V2i, imath.V2f, imath.V3i, imath.V3f ) ) : return ", ".join( GafferUI.NumericWidget.valueToString( v ) for v in value ) # Unknown type. If iteration is supported then use that to # format as a list, otherwise just cast to string. try : strings = [ str( x ) for x in value ] except : return str( value ) if forToolTip and not strings : return "Empty" separator = "\n" if forToolTip else ", " return separator.join( strings ) def __transformPlugFormatter( plug, forToolTip ) : separator = "\n" if forToolTip else " " return separator.join( "{label} : {value}".format( label = c.getName().title() if forToolTip else c.getName()[0].title(), value = formatValue( c, forToolTip ) ) for c in plug.children() ) registerValueFormatter( Gaffer.TransformPlug, __transformPlugFormatter )
1,153